npm install --save @egym/mwa-utils
getPortalsInitialContextis the same asgetInitialContextfrom the standard@ionic/portalspackage, but with support for both v4 and v5 Capacitor versionsportalsPublishis the same aspublishfrom the standard@ionic/portalspackage, but with extra logging with the help of@egym/mwa-loggerportalsSubscribeis the same assubscribefrom the standard@ionic/portalspackage, but with extra logging with the help of@egym/mwa-logger
getMwaInitialContext()returns the initial context typed asMwaInitialContext.
The following functions are available to send commands to the BMA:
publishAuthToken()publishes theauthTokento the BMA.publishDismiss()publishes thedismisscommand to the BMA.publishExerciserInfo()publishes theexerciserInfoto the BMA.publishOpenFeature(startingRoute: string)publishes theopenFeaturecommand to the BMA.startingRouteis the route to open the feature at.
publishOpenNativeFeature(featureId: string, data?: { [key: string]: string })publishes theopenNativeFeaturecommand to the BMA.featureIdis the id of the feature to open.datais an optional object with key-value pairs to pass to the feature.
publishOpenWebView(url: string, endFlowUrlPatterns: string[] = [])publishes theopenWebViewcommand to the BMA.urlis the url to open in the webview.endFlowUrlPatternsis an optional array of strings that will be used to close the webview when a url matches any of the patterns.
publishOpenUrlExternally(url: string)publishes theopenUrlExternallycommand to the BMA.urlis the url to open in the external web view.
publishTrackEvent(eventName: string, feature?: string, parameters?: { [key: string]: string })publishes thetrackEventcommand to the BMA.eventNameis the name of the event to track.featureis an optional string parameter represents the feature where the event is tracked. If not specified, Firebase Analytics tracking will be used by default. If specified, the event will be tracked using a custom Backend or Segment analytics, depending on whether Segment settings are enabled for the brand.parametersis an optional object with key-value pairs to pass to the event.
publishOpenAppSettings()publishes theopenAppSettingscommand to the BMA.- This command requests the native app to open the device’s app settings screen, allowing the user to enable permissions such as location access.
publishNativeAppStartingRoute(startingRoute: string | null)publishes thenativeAppStartingRoutecommand to the BMA.- This command sets the starting route for the native app that will be used when the native app is freshly launched the next time (e.g. after the app was killed by the OS).
- If
startingRouteisnull, the starting route will be reset to the default starting route.
The following functions are available to subscribe to the BMA messages:
subscribeBack(callback: (result: PortalMessage<void>) => void)subscribes to thebacksubscription. The BMA will send abackmessage when the user presses the back button for instance.callbackis a function that will be called when thebackmessage is received.
subscribeAuthToken(callback: (result: PortalMessage<string>)subscribes to theauthTokensubscription. The BMA will send theauthTokenmessage when the MWA send the commandpublishAuthToken().callbackis a function that will be called when theauthTokenmessage is received.
subscribeExerciserInfo(callback: (result: PortalMessage<MwaExerciserInfo>) => void)subscribes to theexerciserInfosubscription. The BMA will send theexerciserInfomessage when the MWA send the commandpublishExerciserInfo().callbackis a function that will be called when theexerciserInfomessage is received.
The MWA Flows are an abstraction that combines the commands and subscriptions to provide a more user-friendly API. The following functions that implement the MWA Flows are available:
getAuthTokenFlow()returns a promise that resolves with theauthTokensent by the BMA over theauthTokensubscription topic. When this function is invoked, the subscription to theauthTokenis done as part of invocation, and, theauthTokencommand is sent to the BMA. When the BMA send theauthTokenmessage, the promise resolves with the message data and unsubscribes from theauthTokensubscription.getExerciserInfoFlow()returns a promise that resolves with theexerciserInfosent by the BMA over theexerciserInfosubscription topic. When this function is invoked, the subscription to theexerciserInfois done as part of invocation, and, theexerciserInfocommand is sent to the BMA. When the BMA App send theexerciserInfomessage, the promise resolves with the message data and unsubscribes from theexerciserInfosubscription.
@egym/mwa-utils uses the peer dependencies installed by the consuming MWA:
@capacitor/core4.1 through 8.x@ionic/portals0.9 through 0.13.x@egym/mwa-logger0.2.8 through 0.3.x
The peer versions must also satisfy each other's compatibility requirements. In particular, Ionic Portals 0.13 requires Capacitor 8.
getPortalsInitialContext temporarily retains a bundled Ionic Portals 0.7.1 /
Capacitor 4.8.1 fallback for DLL's Android integration. The installed
@ionic/portals peer is always attempted first; only a thrown error activates
the fallback. No other API uses the vendored implementation.
Removal is blocked until DLL upgrades its Android integration from Capacitor 4.
BMACG-317 tracks confirmation
of that rollout, deletion of src/external-libs-sources, removal of the
fallback branch, peer-range cleanup, and packed-artifact verification.
Install the dependencies:
npm ciRun and debug the module:
npm run devRun test cases:
npm run testRun static checks:
npm run lint
npm run format:check
npm run typecheckBuild the module for production:
npm run buildRun every check used by CI and the publish workflows:
npm run checkRelease/publish changes to npm:
npm run change # Add a new changeset
npm run change-status # Inspect pending releases
npm run bump # Update versions and changelogs
npm run release # Publish through Changesets with provenancePush the version changes, create a tag, and publish a GitHub release to trigger the npm and GitHub Packages workflows.
The library is bundled with tsdown into ESM, CommonJS, and declaration entry points. Modern.js was removed because its broad application toolchain accounted for most of the dependency tree of this small library. tsup was evaluated but rejected because its maintainers state that it is no longer actively maintained and recommend tsdown as its successor.