@ionic/portals-react-native 0.5.1 → 0.5.3-dev-20250403T152128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalManager.kt +2 -2
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalsPubSub.kt +6 -1
- package/lib/commonjs/PortalView.android.js +3 -3
- package/lib/commonjs/PortalView.android.js.map +1 -1
- package/lib/commonjs/PortalView.js +1 -1
- package/lib/commonjs/PortalView.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/PortalView.android.js +1 -1
- package/lib/module/PortalView.android.js.map +1 -1
- package/lib/module/PortalView.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -182,7 +182,7 @@ internal fun JSONObject.toReactMap(): ReadableMap =
|
|
|
182
182
|
is Int -> map.putInt(key, value)
|
|
183
183
|
is Double -> map.putDouble(key, value)
|
|
184
184
|
is String -> map.putString(key, value)
|
|
185
|
-
null -> map.putNull(key)
|
|
185
|
+
null, JSONObject.NULL -> map.putNull(key)
|
|
186
186
|
else -> map.putString(key, value.toString())
|
|
187
187
|
}
|
|
188
188
|
} catch (_: JSONException) {
|
|
@@ -201,7 +201,7 @@ private fun JSONArray.toReactArray(): ReadableArray =
|
|
|
201
201
|
is Int -> array.pushInt(value)
|
|
202
202
|
is Double -> array.pushDouble(value)
|
|
203
203
|
is String -> array.pushString(value)
|
|
204
|
-
null -> array.pushNull()
|
|
204
|
+
null, JSONObject.NULL -> array.pushNull()
|
|
205
205
|
else -> array.pushString(value.toString())
|
|
206
206
|
}
|
|
207
207
|
} catch (_: JSONException) {
|
|
@@ -27,11 +27,16 @@ internal class PortalsPubSubModule(reactContext: ReactApplicationContext) :
|
|
|
27
27
|
.emit(eventName, result.toJSObject().toReactMap())
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
subscriptionRefs[
|
|
30
|
+
subscriptionRefs[topic] = ref
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
@ReactMethod
|
|
34
34
|
fun removeListeners(count: Int) {
|
|
35
|
+
subscriptionRefs.forEach {
|
|
36
|
+
PortalsPubSub.shared.unsubscribe(it.key, it.value)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
subscriptionRefs.clear()
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
11
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
12
12
|
const PortalViewManager = (0, _reactNative.requireNativeComponent)('AndroidPortalView');
|
|
13
13
|
const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId,
|
|
14
14
|
// we are calling the 'create' command
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","PortalViewManager","requireNativeComponent","createFragment","viewId","UIManager","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","useRef","useEffect","findNodeHandle","current","createElement","_default","exports"],"sources":["PortalView.android.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\nimport type { PortalProps } from '.';\n\nconst PortalViewManager = requireNativeComponent('AndroidPortalView');\n\nconst createFragment = (viewId: number | null) =>\n UIManager.dispatchViewManagerCommand(\n viewId,\n // we are calling the 'create' command\n // @ts-expect-error\n UIManager.AndroidPortalView.Commands.create.toString(),\n [viewId]\n );\n\nconst PortalView = (props: PortalProps) => {\n const ref = useRef(null);\n\n useEffect(() => {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }, []);\n\n return <PortalViewManager {...props} ref={ref} />;\n};\n\nexport default PortalView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIsB,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CA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A;AAGtB,MAAMG,iBAAiB,GAAG,IAAAC,mCAAsB,EAAC,mBAAmB,CAAC;AAErE,MAAMC,cAAc,GAAIC,MAAqB,IAC3CC,sBAAS,CAACC,0BAA0B,CAClCF,MAAM;AACN;AACA;AACAC,sBAAS,CAACE,iBAAiB,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAAC,CAAC,EACtD,CAACN,MAAM,CACT,CAAC;AAEH,MAAMO,UAAU,GAAIC,KAAkB,IAAK;EACzC,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAC,IAAI,CAAC;EAExB,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMX,MAAM,GAAG,IAAAY,2BAAc,EAACH,GAAG,CAACI,OAAO,CAAC;IAC1Cd,cAAc,CAACC,MAAM,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOjC,MAAA,CAAAU,OAAA,CAAAqC,aAAA,CAACjB,iBAAiB,EAAAN,QAAA,KAAKiB,KAAK;IAAEC,GAAG,EAAEA;EAAI,EAAE,CAAC;AACnD,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAvC,OAAA,GAEa8B,UAAU","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const HostComponentPortal = (0, _reactNative.requireNativeComponent)('IONPortalView');
|
|
11
11
|
const PortalView = props => {
|
|
12
12
|
return /*#__PURE__*/_react.default.createElement(HostComponentPortal, props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","e","__esModule","default","HostComponentPortal","requireNativeComponent","PortalView","props","createElement","_default","exports"],"sources":["PortalView.tsx"],"sourcesContent":["import React from 'react';\nimport { requireNativeComponent } from 'react-native';\nimport type { PortalProps } from '.';\n\nconst HostComponentPortal = requireNativeComponent('IONPortalView');\n\nconst PortalView = (props: PortalProps) => {\n return <HostComponentPortal {...props} />;\n};\n\nexport default PortalView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGtD,MAAMG,mBAAmB,GAAG,IAAAC,mCAAsB,EAAC,eAAe,CAAC;AAEnE,MAAMC,UAAU,GAAIC,KAAkB,IAAK;EACzC,oBAAOV,MAAA,CAAAM,OAAA,CAAAK,aAAA,CAACJ,mBAAmB,EAAKG,KAAQ,CAAC;AAC3C,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAP,OAAA,GAEaG,UAAU","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "PortalView", {
|
|
|
12
12
|
exports.syncSome = exports.syncOne = exports.syncAll = exports.subscribe = exports.registerWebVitals = exports.register = exports.publish = exports.onTimeToFirstByte = exports.onFirstInputDelay = exports.onFirstContentfulPaint = exports.getPortal = exports.enableSecureLiveUpdates = exports.addPortals = exports.addPortal = void 0;
|
|
13
13
|
var _reactNative = require("react-native");
|
|
14
14
|
var _PortalView = _interopRequireDefault(require("./PortalView"));
|
|
15
|
-
function _interopRequireDefault(
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
const {
|
|
17
17
|
IONPortalPubSub,
|
|
18
18
|
IONPortalsReactNative,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_PortalView","_interopRequireDefault","obj","__esModule","default","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","NativeModules","PortalsPubSub","NativeEventEmitter","subscribe","topic","onMessageReceived","addListener","message","exports","publish","data","msg","webVitalsMap","Map","WebVitals","onFirstContentfulPaint","portalName","callback","listener","event","duration","registerOnFirstContentfulPaint","set","onFirstInputDelay","Platform","OS","registerOnFirstInputDelay","onTimeToFirstByte","registerOnTimeToFirstByte","registerWebVitals","firstContentfulPaint","firstInputDelay","timeToFirstByte","register","key","addPortal","portal","addPortals","portals","getPortal","name","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative, IONPortalsWebVitals } =\n NativeModules;\n\nexport { default as PortalView } from './PortalView';\n\n/**\n * The data that is received from a subscription event.\n */\nexport interface Message {\n /** The unique subscription reference received from {@link subscribe}*/\n subscriptionRef: number;\n data: any;\n /** The topic the message was sent from */\n topic: string;\n}\n\nconst PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);\n\n// const subscriptionMap = new Map<number, EmitterSubscription>();\n\n/**\n * Subscribes to messages for a topic\n *\n * @param topic The topic to subscribe to\n * @param onMessageReceived The callback to invoke when a message is received\n * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.\n */\nexport const subscribe = (\n topic: string,\n onMessageReceived: (message: Message) => void\n): EmitterSubscription => {\n return PortalsPubSub.addListener(\n `PortalsSubscription:${topic}`,\n (message: Message) => {\n onMessageReceived(message);\n }\n );\n};\n\n/**\n * Publishes a message to the provided topic\n *\n * @param topic The topic to publish the message to\n * @param data The data to publish to subscribers\n */\nexport const publish = (topic: string, data: any) => {\n const msg = { message: data };\n IONPortalPubSub.publish(topic, msg);\n};\n\nconst webVitalsMap = new Map<string, EmitterSubscription>();\nconst WebVitals = new NativeEventEmitter(IONPortalsWebVitals);\n\ninterface WebVitalsEvent {\n portalName: string;\n duration: number;\n}\n\nexport const onFirstContentfulPaint = async (\n portalName: string,\n callback: (duration: number) => void\n): Promise<void> => {\n const listener = WebVitals.addListener(\n 'vitals:fcp',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n};\n\nexport const onFirstInputDelay = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:fid',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);\n webVitalsMap.set(`${portalName}-vitals:fid`, listener);\n }\n};\n\nexport const onTimeToFirstByte = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:ttfb',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);\n webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);\n }\n};\n\nexport const registerWebVitals = async (\n portalName: string,\n firstContentfulPaint: (duration: number) => void,\n firstInputDelay: (duration: number) => void,\n timeToFirstByte: (duration: number) => void\n) => {\n onFirstContentfulPaint(portalName, firstContentfulPaint);\n onFirstInputDelay(portalName, firstInputDelay);\n onTimeToFirstByte(portalName, timeToFirstByte);\n};\n\n/**\n * Validates that a valid registration key has been procured from http://ionic.io/register-portals\n * @param key The registration key\n * @returns Promise<void>\n */\nexport const register = async (key: string): Promise<void> => {\n return IONPortalsReactNative.register(key);\n};\n\n/**\n * The configuration of a web application to be embedded in a React Native application.\n */\nexport interface Portal {\n /** The name of the Portal to be referenced. Must be **unique** */\n name: string;\n /** Any Capacitor plugins to be made available to the Portal */\n plugins?: CapacitorPlugin[];\n /**\n * The root directory of the web application relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, `name` is used.\n */\n startDir?: string;\n /** The name of the initial file to load. If omitted, 'index.html' is used. */\n index?: string;\n /** Any data needed at initial render when a portal is loaded. */\n initialContext?: {\n [key: string]: any;\n };\n assetMaps?: AssetMap[];\n liveUpdate?: LiveUpdateConfig;\n}\n\nexport interface CapacitorPlugin {\n /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidClassPath: string;\n /** The class name of the plugin to be used in iOS.\n * This must be the name as it is exposed to the Objective-C runtime.\n * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.\n */\n iosClassName: string;\n}\n\nexport interface AssetMap {\n /** The name to index the asset map by */\n name: string;\n /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */\n virtualPath?: string;\n /** The root directory of the assets relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, the root of Bundle.main\n * and src/main/assets will be used.\n */\n startDir?: string;\n}\n\n/**\n * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override\n * any initialContext defined in the original {@link Portal} definition.\n */\nexport type PortalProp = {\n portal: Pick<Portal, 'name' | 'initialContext'>;\n};\n\n/**\n * Props needed for rendering a {@link Portal}\n */\nexport type PortalProps = PortalProp & ViewProps;\n\n/**\n * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.\n *\n * @param portal The portal to add to the internal registry.\n * @returns Promise containing the Portal that was added to the registry.\n */\nexport const addPortal = async (portal: Portal): Promise<Portal> => {\n return IONPortalsReactNative.addPortal(portal);\n};\n\n/**\n * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}\n *\n * @param portals The portals to add to the internal registry.\n * @returns Promise containing the Portals that were added to the registry.\n */\nexport const addPortals = async (portals: Portal[]): Promise<Portal[]> => {\n return IONPortalsReactNative.addPortals(portals);\n};\n\n/**\n * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.\n *\n * @param name The portal name to retrieve from the internal registry.\n * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.\n */\nexport const getPortal = async (name: string): Promise<Portal> => {\n return IONPortalsReactNative.getPortal(name);\n};\n\nexport interface LiveUpdate {\n /** The AppFlow application ID */\n appId: string;\n /** The AppFlow distribution channel */\n channel: string;\n}\n\n/** Data needed to register a live update to be managed */\nexport type LiveUpdateConfig = LiveUpdate & { syncOnAdd: boolean };\n\nexport interface LiveUpdateError {\n /** The AppFlow application ID relating to the failure */\n appId: string;\n /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/\n failStep: string;\n /** A human readable error message */\n message: string;\n}\n\nexport interface Snapshot {\n /** The snapshot id as found in AppFlow */\n id: string;\n /** The AppFlow build id that produced the snapshot */\n buildId: string;\n}\n\nexport interface SyncResult {\n /** The {@link LiveUpdate} associated with the result */\n liveUpdate: LiveUpdate;\n /** The {@link Snapshot} that was sync'd */\n snapshot: Snapshot | null;\n /** Whether the snapshot was downloaded or already on disk */\n source: 'download' | 'cache';\n /** If the active application path was changed. A `false` value would indicate\n * the application already has the latest code for the associated {@link LiveUpdate}\n * configuration.\n */\n activeApplicationPathChanged: boolean;\n}\n\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n results: SyncResult[];\n errors: LiveUpdateError[];\n}\n\n/**\n * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.\n * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.\n *\n * @param pathToKey The *relative* path to the public key for verification.\n * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.\n * @returns Promise<void>\n */\nexport const enableSecureLiveUpdates = async (\n pathToKey: string\n): Promise<void> => {\n return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);\n};\n\n/**\n * Syncs a single live update.\n *\n * @param appId The AppFlow application ID to sync.\n * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.\n */\nexport const syncOne = async (appId: string): Promise<SyncResult> => {\n return IONPortalsReactNative.syncOne(appId);\n};\n\n/**\n * Syncs many live updates.\n *\n * @param appIds The AppFlow application IDs to sync.\n * @returns Promise<SyncResults>\n */\nexport const syncSome = async (appIds: string[]): Promise<SyncResults> => {\n return IONPortalsReactNative.syncSome(appIds);\n};\n\n/**\n * Syncs all registered LiveUpdates\n * @returns Promise<SyncResults>\n */\nexport const syncAll = async (): Promise<SyncResults> => {\n return IONPortalsReactNative.syncAll();\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAqD,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAHrD,MAAM;EAAEG,eAAe;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GACnEC,0BAAa;AAIf;AACA;AACA;;AASA,MAAMC,aAAa,GAAG,IAAIC,+BAAkB,CAACL,eAAe,CAAC;;AAE7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,SAAS,GAAGA,CACvBC,KAAa,EACbC,iBAA6C,KACrB;EACxB,OAAOJ,aAAa,CAACK,WAAW,CAC7B,uBAAsBF,KAAM,EAAC,EAC7BG,OAAgB,IAAK;IACpBF,iBAAiB,CAACE,OAAO,CAAC;EAC5B,CACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAL,SAAA,GAAAA,SAAA;AAMO,MAAMM,OAAO,GAAGA,CAACL,KAAa,EAAEM,IAAS,KAAK;EACnD,MAAMC,GAAG,GAAG;IAAEJ,OAAO,EAAEG;EAAK,CAAC;EAC7Bb,eAAe,CAACY,OAAO,CAACL,KAAK,EAAEO,GAAG,CAAC;AACrC,CAA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AACC,OAAO,CAAC;AAClD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA9B,OAAA,CAAA6B,UAAA,GAAAA,UAAA;AAMO,MAAME,SAAS,GAAG,MAAOC,IAAY,IAAsB;EAChE,OAAO1C,qBAAqB,CAACyC,SAAS,CAACC,IAAI,CAAC;AAC9C,CAAC;;AASD;;AAiCA;AAAAhC,OAAA,CAAA+B,SAAA,GAAAA,SAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAG,MACrCC,SAAiB,IACC;EAClB,OAAO5C,qBAAqB,CAAC2C,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAlC,OAAA,CAAAiC,uBAAA,GAAAA,uBAAA;AAMO,MAAME,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAO9C,qBAAqB,CAAC6C,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALApC,OAAA,CAAAmC,OAAA,GAAAA,OAAA;AAMO,MAAME,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAOhD,qBAAqB,CAAC+C,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AAHAtC,OAAA,CAAAqC,QAAA,GAAAA,QAAA;AAIO,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAOjD,qBAAqB,CAACiD,OAAO,CAAC,CAAC;AACxC,CAAC;AAACvC,OAAA,CAAAuC,OAAA,GAAAA,OAAA"}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_PortalView","_interopRequireDefault","e","__esModule","default","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","NativeModules","PortalsPubSub","NativeEventEmitter","subscribe","topic","onMessageReceived","addListener","message","exports","publish","data","msg","webVitalsMap","Map","WebVitals","onFirstContentfulPaint","portalName","callback","listener","event","duration","registerOnFirstContentfulPaint","set","onFirstInputDelay","Platform","OS","registerOnFirstInputDelay","onTimeToFirstByte","registerOnTimeToFirstByte","registerWebVitals","firstContentfulPaint","firstInputDelay","timeToFirstByte","register","key","addPortal","portal","addPortals","portals","getPortal","name","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative, IONPortalsWebVitals } =\n NativeModules;\n\nexport { default as PortalView } from './PortalView';\n\n/**\n * The data that is received from a subscription event.\n */\nexport interface Message {\n /** The unique subscription reference received from {@link subscribe}*/\n subscriptionRef: number;\n data: any;\n /** The topic the message was sent from */\n topic: string;\n}\n\nconst PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);\n\n// const subscriptionMap = new Map<number, EmitterSubscription>();\n\n/**\n * Subscribes to messages for a topic\n *\n * @param topic The topic to subscribe to\n * @param onMessageReceived The callback to invoke when a message is received\n * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.\n */\nexport const subscribe = (\n topic: string,\n onMessageReceived: (message: Message) => void\n): EmitterSubscription => {\n return PortalsPubSub.addListener(\n `PortalsSubscription:${topic}`,\n (message: Message) => {\n onMessageReceived(message);\n }\n );\n};\n\n/**\n * Publishes a message to the provided topic\n *\n * @param topic The topic to publish the message to\n * @param data The data to publish to subscribers\n */\nexport const publish = (topic: string, data: any) => {\n const msg = { message: data };\n IONPortalPubSub.publish(topic, msg);\n};\n\nconst webVitalsMap = new Map<string, EmitterSubscription>();\nconst WebVitals = new NativeEventEmitter(IONPortalsWebVitals);\n\ninterface WebVitalsEvent {\n portalName: string;\n duration: number;\n}\n\nexport const onFirstContentfulPaint = async (\n portalName: string,\n callback: (duration: number) => void\n): Promise<void> => {\n const listener = WebVitals.addListener(\n 'vitals:fcp',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n};\n\nexport const onFirstInputDelay = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:fid',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);\n webVitalsMap.set(`${portalName}-vitals:fid`, listener);\n }\n};\n\nexport const onTimeToFirstByte = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:ttfb',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);\n webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);\n }\n};\n\nexport const registerWebVitals = async (\n portalName: string,\n firstContentfulPaint: (duration: number) => void,\n firstInputDelay: (duration: number) => void,\n timeToFirstByte: (duration: number) => void\n) => {\n onFirstContentfulPaint(portalName, firstContentfulPaint);\n onFirstInputDelay(portalName, firstInputDelay);\n onTimeToFirstByte(portalName, timeToFirstByte);\n};\n\n/**\n * Validates that a valid registration key has been procured from http://ionic.io/register-portals\n * @param key The registration key\n * @returns Promise<void>\n */\nexport const register = async (key: string): Promise<void> => {\n return IONPortalsReactNative.register(key);\n};\n\n/**\n * The configuration of a web application to be embedded in a React Native application.\n */\nexport interface Portal {\n /** The name of the Portal to be referenced. Must be **unique** */\n name: string;\n /** Any Capacitor plugins to be made available to the Portal */\n plugins?: CapacitorPlugin[];\n /**\n * The root directory of the web application relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, `name` is used.\n */\n startDir?: string;\n /** The name of the initial file to load. If omitted, 'index.html' is used. */\n index?: string;\n /** Any data needed at initial render when a portal is loaded. */\n initialContext?: {\n [key: string]: any;\n };\n assetMaps?: AssetMap[];\n liveUpdate?: LiveUpdateConfig;\n}\n\nexport interface CapacitorPlugin {\n /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidClassPath: string;\n /** The class name of the plugin to be used in iOS.\n * This must be the name as it is exposed to the Objective-C runtime.\n * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.\n */\n iosClassName: string;\n}\n\nexport interface AssetMap {\n /** The name to index the asset map by */\n name: string;\n /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */\n virtualPath?: string;\n /** The root directory of the assets relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, the root of Bundle.main\n * and src/main/assets will be used.\n */\n startDir?: string;\n}\n\n/**\n * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override\n * any initialContext defined in the original {@link Portal} definition.\n */\nexport type PortalProp = {\n portal: Pick<Portal, 'name' | 'initialContext'>;\n};\n\n/**\n * Props needed for rendering a {@link Portal}\n */\nexport type PortalProps = PortalProp & ViewProps;\n\n/**\n * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.\n *\n * @param portal The portal to add to the internal registry.\n * @returns Promise containing the Portal that was added to the registry.\n */\nexport const addPortal = async (portal: Portal): Promise<Portal> => {\n return IONPortalsReactNative.addPortal(portal);\n};\n\n/**\n * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}\n *\n * @param portals The portals to add to the internal registry.\n * @returns Promise containing the Portals that were added to the registry.\n */\nexport const addPortals = async (portals: Portal[]): Promise<Portal[]> => {\n return IONPortalsReactNative.addPortals(portals);\n};\n\n/**\n * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.\n *\n * @param name The portal name to retrieve from the internal registry.\n * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.\n */\nexport const getPortal = async (name: string): Promise<Portal> => {\n return IONPortalsReactNative.getPortal(name);\n};\n\nexport interface LiveUpdate {\n /** The AppFlow application ID */\n appId: string;\n /** The AppFlow distribution channel */\n channel: string;\n}\n\n/** Data needed to register a live update to be managed */\nexport type LiveUpdateConfig = LiveUpdate & { syncOnAdd: boolean };\n\nexport interface LiveUpdateError {\n /** The AppFlow application ID relating to the failure */\n appId: string;\n /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/\n failStep: string;\n /** A human readable error message */\n message: string;\n}\n\nexport interface Snapshot {\n /** The snapshot id as found in AppFlow */\n id: string;\n /** The AppFlow build id that produced the snapshot */\n buildId: string;\n}\n\nexport interface SyncResult {\n /** The {@link LiveUpdate} associated with the result */\n liveUpdate: LiveUpdate;\n /** The {@link Snapshot} that was sync'd */\n snapshot: Snapshot | null;\n /** Whether the snapshot was downloaded or already on disk */\n source: 'download' | 'cache';\n /** If the active application path was changed. A `false` value would indicate\n * the application already has the latest code for the associated {@link LiveUpdate}\n * configuration.\n */\n activeApplicationPathChanged: boolean;\n}\n\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n results: SyncResult[];\n errors: LiveUpdateError[];\n}\n\n/**\n * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.\n * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.\n *\n * @param pathToKey The *relative* path to the public key for verification.\n * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.\n * @returns Promise<void>\n */\nexport const enableSecureLiveUpdates = async (\n pathToKey: string\n): Promise<void> => {\n return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);\n};\n\n/**\n * Syncs a single live update.\n *\n * @param appId The AppFlow application ID to sync.\n * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.\n */\nexport const syncOne = async (appId: string): Promise<SyncResult> => {\n return IONPortalsReactNative.syncOne(appId);\n};\n\n/**\n * Syncs many live updates.\n *\n * @param appIds The AppFlow application IDs to sync.\n * @returns Promise<SyncResults>\n */\nexport const syncSome = async (appIds: string[]): Promise<SyncResults> => {\n return IONPortalsReactNative.syncSome(appIds);\n};\n\n/**\n * Syncs all registered LiveUpdates\n * @returns Promise<SyncResults>\n */\nexport const syncAll = async (): Promise<SyncResults> => {\n return IONPortalsReactNative.syncAll();\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAqD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHrD,MAAM;EAAEG,eAAe;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GACnEC,0BAAa;AAIf;AACA;AACA;;AASA,MAAMC,aAAa,GAAG,IAAIC,+BAAkB,CAACL,eAAe,CAAC;;AAE7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,SAAS,GAAGA,CACvBC,KAAa,EACbC,iBAA6C,KACrB;EACxB,OAAOJ,aAAa,CAACK,WAAW,CAC9B,uBAAuBF,KAAK,EAAE,EAC7BG,OAAgB,IAAK;IACpBF,iBAAiB,CAACE,OAAO,CAAC;EAC5B,CACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAL,SAAA,GAAAA,SAAA;AAMO,MAAMM,OAAO,GAAGA,CAACL,KAAa,EAAEM,IAAS,KAAK;EACnD,MAAMC,GAAG,GAAG;IAAEJ,OAAO,EAAEG;EAAK,CAAC;EAC7Bb,eAAe,CAACY,OAAO,CAACL,KAAK,EAAEO,GAAG,CAAC;AACrC,CAAC;AAACH,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAEF,MAAMG,YAAY,GAAG,IAAIC,GAAG,CAA8B,CAAC;AAC3D,MAAMC,SAAS,GAAG,IAAIZ,+BAAkB,CAACH,mBAAmB,CAAC;AAOtD,MAAMgB,sBAAsB,GAAG,MA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AI,CAAC;AAC9C,CAAC;;AASD;;AAiCA;AAAAhC,OAAA,CAAA+B,SAAA,GAAAA,SAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAG,MACrCC,SAAiB,IACC;EAClB,OAAO5C,qBAAqB,CAAC2C,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAlC,OAAA,CAAAiC,uBAAA,GAAAA,uBAAA;AAMO,MAAME,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAO9C,qBAAqB,CAAC6C,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALApC,OAAA,CAAAmC,OAAA,GAAAA,OAAA;AAMO,MAAME,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAOhD,qBAAqB,CAAC+C,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AAHAtC,OAAA,CAAAqC,QAAA,GAAAA,QAAA;AAIO,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAOjD,qBAAqB,CAACiD,OAAO,CAAC,CAAC;AACxC,CAAC;AAACvC,OAAA,CAAAuC,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import { findNodeHandle, requireNativeComponent, UIManager } from 'react-native';
|
|
4
4
|
const PortalViewManager = requireNativeComponent('AndroidPortalView');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","current","createElement","_extends"],"sources":["PortalView.android.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\nimport type { PortalProps } from '.';\n\nconst PortalViewManager = requireNativeComponent('AndroidPortalView');\n\nconst createFragment = (viewId: number | null) =>\n UIManager.dispatchViewManagerCommand(\n viewId,\n // we are calling the 'create' command\n // @ts-expect-error\n UIManager.AndroidPortalView.Commands.create.toString(),\n [viewId]\n );\n\nconst PortalView = (props: PortalProps) => {\n const ref = useRef(null);\n\n useEffect(() => {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }, []);\n\n return <PortalViewManager {...props} ref={ref} />;\n};\n\nexport default PortalView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SACEC,cAAc,EACdC,sBAAsB,EACtBC,SAAS,QACJ,cAAc;AAGrB,MAAMC,iBAAiB,GAAGF,sBAAsB,CAAC,mBAAmB,CAAC;AAErE,MAAMG,cAAc,GAAIC,MAAqB,IAC3CH,SAAS,CAACI,0BAA0B,CAClCD,MAAM;AACN;AACA;AACAH,SAAS,CAACK,iBAAiB,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAAC,CAAC,EACtD,CAACL,MAAM,CACT,CAAC;AAEH,MAAMM,UAAU,GAAIC,KAAkB,IAAK;EACzC,MAAMC,GAAG,GAAGd,MAAM,CAAC,IAAI,CAAC;EAExBD,SAAS,CAAC,MAAM;IACd,MAAMO,MAAM,GAAGL,cAAc,CAACa,GAAG,CAACC,OAAO,CAAC;IAC1CV,cAAc,CAACC,MAAM,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOR,KAAA,CAAAkB,aAAA,CAACZ,iBAAiB,EAAAa,QAAA,KAAKJ,KAAK;IAAEC,GAAG,EAAEA;EAAI,EAAE,CAAC;AACnD,CAAC;AAED,eAAeF,UAAU"}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","current","createElement","_extends"],"sources":["PortalView.android.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\nimport type { PortalProps } from '.';\n\nconst PortalViewManager = requireNativeComponent('AndroidPortalView');\n\nconst createFragment = (viewId: number | null) =>\n UIManager.dispatchViewManagerCommand(\n viewId,\n // we are calling the 'create' command\n // @ts-expect-error\n UIManager.AndroidPortalView.Commands.create.toString(),\n [viewId]\n );\n\nconst PortalView = (props: PortalProps) => {\n const ref = useRef(null);\n\n useEffect(() => {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }, []);\n\n return <PortalViewManager {...props} ref={ref} />;\n};\n\nexport default PortalView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SACEC,cAAc,EACdC,sBAAsB,EACtBC,SAAS,QACJ,cAAc;AAGrB,MAAMC,iBAAiB,GAAGF,sBAAsB,CAAC,mBAAmB,CAAC;AAErE,MAAMG,cAAc,GAAIC,MAAqB,IAC3CH,SAAS,CAACI,0BAA0B,CAClCD,MAAM;AACN;AACA;AACAH,SAAS,CAACK,iBAAiB,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAAC,CAAC,EACtD,CAACL,MAAM,CACT,CAAC;AAEH,MAAMM,UAAU,GAAIC,KAAkB,IAAK;EACzC,MAAMC,GAAG,GAAGd,MAAM,CAAC,IAAI,CAAC;EAExBD,SAAS,CAAC,MAAM;IACd,MAAMO,MAAM,GAAGL,cAAc,CAACa,GAAG,CAACC,OAAO,CAAC;IAC1CV,cAAc,CAACC,MAAM,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOR,KAAA,CAAAkB,aAAA,CAACZ,iBAAiB,EAAAa,QAAA,KAAKJ,KAAK;IAAEC,GAAG,EAAEA;EAAI,EAAE,CAAC;AACnD,CAAC;AAED,eAAeF,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","requireNativeComponent","HostComponentPortal","PortalView","props","createElement"],"sources":["PortalView.tsx"],"sourcesContent":["import React from 'react';\nimport { requireNativeComponent } from 'react-native';\nimport type { PortalProps } from '.';\n\nconst HostComponentPortal = requireNativeComponent('IONPortalView');\n\nconst PortalView = (props: PortalProps) => {\n return <HostComponentPortal {...props} />;\n};\n\nexport default PortalView;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,sBAAsB,QAAQ,cAAc;AAGrD,MAAMC,mBAAmB,GAAGD,sBAAsB,CAAC,eAAe,CAAC;AAEnE,MAAME,UAAU,GAAIC,KAAkB,IAAK;EACzC,oBAAOJ,KAAA,CAAAK,aAAA,CAACH,mBAAmB,EAAKE,KAAQ,CAAC;AAC3C,CAAC;AAED,eAAeD,UAAU"}
|
|
1
|
+
{"version":3,"names":["React","requireNativeComponent","HostComponentPortal","PortalView","props","createElement"],"sources":["PortalView.tsx"],"sourcesContent":["import React from 'react';\nimport { requireNativeComponent } from 'react-native';\nimport type { PortalProps } from '.';\n\nconst HostComponentPortal = requireNativeComponent('IONPortalView');\n\nconst PortalView = (props: PortalProps) => {\n return <HostComponentPortal {...props} />;\n};\n\nexport default PortalView;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,sBAAsB,QAAQ,cAAc;AAGrD,MAAMC,mBAAmB,GAAGD,sBAAsB,CAAC,eAAe,CAAC;AAEnE,MAAME,UAAU,GAAIC,KAAkB,IAAK;EACzC,oBAAOJ,KAAA,CAAAK,aAAA,CAACH,mBAAmB,EAAKE,KAAQ,CAAC;AAC3C,CAAC;AAED,eAAeD,UAAU","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","default","PortalView","PortalsPubSub","subscribe","topic","onMessageReceived","addListener","message","publish","data","msg","webVitalsMap","Map","WebVitals","onFirstContentfulPaint","portalName","callback","listener","event","duration","registerOnFirstContentfulPaint","set","onFirstInputDelay","OS","registerOnFirstInputDelay","onTimeToFirstByte","registerOnTimeToFirstByte","registerWebVitals","firstContentfulPaint","firstInputDelay","timeToFirstByte","register","key","addPortal","portal","addPortals","portals","getPortal","name","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative, IONPortalsWebVitals } =\n NativeModules;\n\nexport { default as PortalView } from './PortalView';\n\n/**\n * The data that is received from a subscription event.\n */\nexport interface Message {\n /** The unique subscription reference received from {@link subscribe}*/\n subscriptionRef: number;\n data: any;\n /** The topic the message was sent from */\n topic: string;\n}\n\nconst PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);\n\n// const subscriptionMap = new Map<number, EmitterSubscription>();\n\n/**\n * Subscribes to messages for a topic\n *\n * @param topic The topic to subscribe to\n * @param onMessageReceived The callback to invoke when a message is received\n * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.\n */\nexport const subscribe = (\n topic: string,\n onMessageReceived: (message: Message) => void\n): EmitterSubscription => {\n return PortalsPubSub.addListener(\n `PortalsSubscription:${topic}`,\n (message: Message) => {\n onMessageReceived(message);\n }\n );\n};\n\n/**\n * Publishes a message to the provided topic\n *\n * @param topic The topic to publish the message to\n * @param data The data to publish to subscribers\n */\nexport const publish = (topic: string, data: any) => {\n const msg = { message: data };\n IONPortalPubSub.publish(topic, msg);\n};\n\nconst webVitalsMap = new Map<string, EmitterSubscription>();\nconst WebVitals = new NativeEventEmitter(IONPortalsWebVitals);\n\ninterface WebVitalsEvent {\n portalName: string;\n duration: number;\n}\n\nexport const onFirstContentfulPaint = async (\n portalName: string,\n callback: (duration: number) => void\n): Promise<void> => {\n const listener = WebVitals.addListener(\n 'vitals:fcp',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n};\n\nexport const onFirstInputDelay = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:fid',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);\n webVitalsMap.set(`${portalName}-vitals:fid`, listener);\n }\n};\n\nexport const onTimeToFirstByte = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:ttfb',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);\n webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);\n }\n};\n\nexport const registerWebVitals = async (\n portalName: string,\n firstContentfulPaint: (duration: number) => void,\n firstInputDelay: (duration: number) => void,\n timeToFirstByte: (duration: number) => void\n) => {\n onFirstContentfulPaint(portalName, firstContentfulPaint);\n onFirstInputDelay(portalName, firstInputDelay);\n onTimeToFirstByte(portalName, timeToFirstByte);\n};\n\n/**\n * Validates that a valid registration key has been procured from http://ionic.io/register-portals\n * @param key The registration key\n * @returns Promise<void>\n */\nexport const register = async (key: string): Promise<void> => {\n return IONPortalsReactNative.register(key);\n};\n\n/**\n * The configuration of a web application to be embedded in a React Native application.\n */\nexport interface Portal {\n /** The name of the Portal to be referenced. Must be **unique** */\n name: string;\n /** Any Capacitor plugins to be made available to the Portal */\n plugins?: CapacitorPlugin[];\n /**\n * The root directory of the web application relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, `name` is used.\n */\n startDir?: string;\n /** The name of the initial file to load. If omitted, 'index.html' is used. */\n index?: string;\n /** Any data needed at initial render when a portal is loaded. */\n initialContext?: {\n [key: string]: any;\n };\n assetMaps?: AssetMap[];\n liveUpdate?: LiveUpdateConfig;\n}\n\nexport interface CapacitorPlugin {\n /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidClassPath: string;\n /** The class name of the plugin to be used in iOS.\n * This must be the name as it is exposed to the Objective-C runtime.\n * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.\n */\n iosClassName: string;\n}\n\nexport interface AssetMap {\n /** The name to index the asset map by */\n name: string;\n /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */\n virtualPath?: string;\n /** The root directory of the assets relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, the root of Bundle.main\n * and src/main/assets will be used.\n */\n startDir?: string;\n}\n\n/**\n * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override\n * any initialContext defined in the original {@link Portal} definition.\n */\nexport type PortalProp = {\n portal: Pick<Portal, 'name' | 'initialContext'>;\n};\n\n/**\n * Props needed for rendering a {@link Portal}\n */\nexport type PortalProps = PortalProp & ViewProps;\n\n/**\n * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.\n *\n * @param portal The portal to add to the internal registry.\n * @returns Promise containing the Portal that was added to the registry.\n */\nexport const addPortal = async (portal: Portal): Promise<Portal> => {\n return IONPortalsReactNative.addPortal(portal);\n};\n\n/**\n * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}\n *\n * @param portals The portals to add to the internal registry.\n * @returns Promise containing the Portals that were added to the registry.\n */\nexport const addPortals = async (portals: Portal[]): Promise<Portal[]> => {\n return IONPortalsReactNative.addPortals(portals);\n};\n\n/**\n * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.\n *\n * @param name The portal name to retrieve from the internal registry.\n * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.\n */\nexport const getPortal = async (name: string): Promise<Portal> => {\n return IONPortalsReactNative.getPortal(name);\n};\n\nexport interface LiveUpdate {\n /** The AppFlow application ID */\n appId: string;\n /** The AppFlow distribution channel */\n channel: string;\n}\n\n/** Data needed to register a live update to be managed */\nexport type LiveUpdateConfig = LiveUpdate & { syncOnAdd: boolean };\n\nexport interface LiveUpdateError {\n /** The AppFlow application ID relating to the failure */\n appId: string;\n /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/\n failStep: string;\n /** A human readable error message */\n message: string;\n}\n\nexport interface Snapshot {\n /** The snapshot id as found in AppFlow */\n id: string;\n /** The AppFlow build id that produced the snapshot */\n buildId: string;\n}\n\nexport interface SyncResult {\n /** The {@link LiveUpdate} associated with the result */\n liveUpdate: LiveUpdate;\n /** The {@link Snapshot} that was sync'd */\n snapshot: Snapshot | null;\n /** Whether the snapshot was downloaded or already on disk */\n source: 'download' | 'cache';\n /** If the active application path was changed. A `false` value would indicate\n * the application already has the latest code for the associated {@link LiveUpdate}\n * configuration.\n */\n activeApplicationPathChanged: boolean;\n}\n\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n results: SyncResult[];\n errors: LiveUpdateError[];\n}\n\n/**\n * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.\n * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.\n *\n * @param pathToKey The *relative* path to the public key for verification.\n * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.\n * @returns Promise<void>\n */\nexport const enableSecureLiveUpdates = async (\n pathToKey: string\n): Promise<void> => {\n return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);\n};\n\n/**\n * Syncs a single live update.\n *\n * @param appId The AppFlow application ID to sync.\n * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.\n */\nexport const syncOne = async (appId: string): Promise<SyncResult> => {\n return IONPortalsReactNative.syncOne(appId);\n};\n\n/**\n * Syncs many live updates.\n *\n * @param appIds The AppFlow application IDs to sync.\n * @returns Promise<SyncResults>\n */\nexport const syncSome = async (appIds: string[]): Promise<SyncResults> => {\n return IONPortalsReactNative.syncSome(appIds);\n};\n\n/**\n * Syncs all registered LiveUpdates\n * @returns Promise<SyncResults>\n */\nexport const syncAll = async (): Promise<SyncResults> => {\n return IONPortalsReactNative.syncAll();\n};\n"],"mappings":"AAAA,SAEEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QAEH,cAAc;AAErB,MAAM;EAAEC,eAAe;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GACnEJ,aAAa;AAEf,SAASK,OAAO,IAAIC,UAAU,QAAQ,cAAc;;AAEpD;AACA;AACA;;AASA,MAAMC,aAAa,GAAG,IAAIR,kBAAkB,CAACG,eAAe,CAAC;;AAE7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,SAAS,GAAGA,CACvBC,KAAa,EACbC,iBAA6C,KACrB;EACxB,OAAOH,aAAa,CAACI,WAAW,CAC7B,uBAAsBF,KAAM,EAAC,EAC7BG,OAAgB,IAAK;IACpBF,iBAAiB,CAACE,OAAO,CAAC;EAC5B,CACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAACJ,KAAa,EAAEK,IAAS,KAAK;EACnD,MAAMC,GAAG,GAAG;IAAEH,OAAO,EAAEE;EAAK,CAAC;EAC7BZ,eAAe,CAACW,OAAO,CAACJ,KAAK,EAAEM,GAAG,CAAC;A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MAAMC,uBAAuB,GAAG,MACrCC,SAAiB,IACC;EAClB,OAAO1C,qBAAqB,CAACyC,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAO5C,qBAAqB,CAAC2C,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAO9C,qBAAqB,CAAC6C,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAO/C,qBAAqB,CAAC+C,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","default","PortalView","PortalsPubSub","subscribe","topic","onMessageReceived","addListener","message","publish","data","msg","webVitalsMap","Map","WebVitals","onFirstContentfulPaint","portalName","callback","listener","event","duration","registerOnFirstContentfulPaint","set","onFirstInputDelay","OS","registerOnFirstInputDelay","onTimeToFirstByte","registerOnTimeToFirstByte","registerWebVitals","firstContentfulPaint","firstInputDelay","timeToFirstByte","register","key","addPortal","portal","addPortals","portals","getPortal","name","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative, IONPortalsWebVitals } =\n NativeModules;\n\nexport { default as PortalView } from './PortalView';\n\n/**\n * The data that is received from a subscription event.\n */\nexport interface Message {\n /** The unique subscription reference received from {@link subscribe}*/\n subscriptionRef: number;\n data: any;\n /** The topic the message was sent from */\n topic: string;\n}\n\nconst PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);\n\n// const subscriptionMap = new Map<number, EmitterSubscription>();\n\n/**\n * Subscribes to messages for a topic\n *\n * @param topic The topic to subscribe to\n * @param onMessageReceived The callback to invoke when a message is received\n * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.\n */\nexport const subscribe = (\n topic: string,\n onMessageReceived: (message: Message) => void\n): EmitterSubscription => {\n return PortalsPubSub.addListener(\n `PortalsSubscription:${topic}`,\n (message: Message) => {\n onMessageReceived(message);\n }\n );\n};\n\n/**\n * Publishes a message to the provided topic\n *\n * @param topic The topic to publish the message to\n * @param data The data to publish to subscribers\n */\nexport const publish = (topic: string, data: any) => {\n const msg = { message: data };\n IONPortalPubSub.publish(topic, msg);\n};\n\nconst webVitalsMap = new Map<string, EmitterSubscription>();\nconst WebVitals = new NativeEventEmitter(IONPortalsWebVitals);\n\ninterface WebVitalsEvent {\n portalName: string;\n duration: number;\n}\n\nexport const onFirstContentfulPaint = async (\n portalName: string,\n callback: (duration: number) => void\n): Promise<void> => {\n const listener = WebVitals.addListener(\n 'vitals:fcp',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n};\n\nexport const onFirstInputDelay = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:fid',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);\n webVitalsMap.set(`${portalName}-vitals:fid`, listener);\n }\n};\n\nexport const onTimeToFirstByte = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:ttfb',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);\n webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);\n }\n};\n\nexport const registerWebVitals = async (\n portalName: string,\n firstContentfulPaint: (duration: number) => void,\n firstInputDelay: (duration: number) => void,\n timeToFirstByte: (duration: number) => void\n) => {\n onFirstContentfulPaint(portalName, firstContentfulPaint);\n onFirstInputDelay(portalName, firstInputDelay);\n onTimeToFirstByte(portalName, timeToFirstByte);\n};\n\n/**\n * Validates that a valid registration key has been procured from http://ionic.io/register-portals\n * @param key The registration key\n * @returns Promise<void>\n */\nexport const register = async (key: string): Promise<void> => {\n return IONPortalsReactNative.register(key);\n};\n\n/**\n * The configuration of a web application to be embedded in a React Native application.\n */\nexport interface Portal {\n /** The name of the Portal to be referenced. Must be **unique** */\n name: string;\n /** Any Capacitor plugins to be made available to the Portal */\n plugins?: CapacitorPlugin[];\n /**\n * The root directory of the web application relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, `name` is used.\n */\n startDir?: string;\n /** The name of the initial file to load. If omitted, 'index.html' is used. */\n index?: string;\n /** Any data needed at initial render when a portal is loaded. */\n initialContext?: {\n [key: string]: any;\n };\n assetMaps?: AssetMap[];\n liveUpdate?: LiveUpdateConfig;\n}\n\nexport interface CapacitorPlugin {\n /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidClassPath: string;\n /** The class name of the plugin to be used in iOS.\n * This must be the name as it is exposed to the Objective-C runtime.\n * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.\n */\n iosClassName: string;\n}\n\nexport interface AssetMap {\n /** The name to index the asset map by */\n name: string;\n /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */\n virtualPath?: string;\n /** The root directory of the assets relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, the root of Bundle.main\n * and src/main/assets will be used.\n */\n startDir?: string;\n}\n\n/**\n * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override\n * any initialContext defined in the original {@link Portal} definition.\n */\nexport type PortalProp = {\n portal: Pick<Portal, 'name' | 'initialContext'>;\n};\n\n/**\n * Props needed for rendering a {@link Portal}\n */\nexport type PortalProps = PortalProp & ViewProps;\n\n/**\n * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.\n *\n * @param portal The portal to add to the internal registry.\n * @returns Promise containing the Portal that was added to the registry.\n */\nexport const addPortal = async (portal: Portal): Promise<Portal> => {\n return IONPortalsReactNative.addPortal(portal);\n};\n\n/**\n * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}\n *\n * @param portals The portals to add to the internal registry.\n * @returns Promise containing the Portals that were added to the registry.\n */\nexport const addPortals = async (portals: Portal[]): Promise<Portal[]> => {\n return IONPortalsReactNative.addPortals(portals);\n};\n\n/**\n * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.\n *\n * @param name The portal name to retrieve from the internal registry.\n * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.\n */\nexport const getPortal = async (name: string): Promise<Portal> => {\n return IONPortalsReactNative.getPortal(name);\n};\n\nexport interface LiveUpdate {\n /** The AppFlow application ID */\n appId: string;\n /** The AppFlow distribution channel */\n channel: string;\n}\n\n/** Data needed to register a live update to be managed */\nexport type LiveUpdateConfig = LiveUpdate & { syncOnAdd: boolean };\n\nexport interface LiveUpdateError {\n /** The AppFlow application ID relating to the failure */\n appId: string;\n /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/\n failStep: string;\n /** A human readable error message */\n message: string;\n}\n\nexport interface Snapshot {\n /** The snapshot id as found in AppFlow */\n id: string;\n /** The AppFlow build id that produced the snapshot */\n buildId: string;\n}\n\nexport interface SyncResult {\n /** The {@link LiveUpdate} associated with the result */\n liveUpdate: LiveUpdate;\n /** The {@link Snapshot} that was sync'd */\n snapshot: Snapshot | null;\n /** Whether the snapshot was downloaded or already on disk */\n source: 'download' | 'cache';\n /** If the active application path was changed. A `false` value would indicate\n * the application already has the latest code for the associated {@link LiveUpdate}\n * configuration.\n */\n activeApplicationPathChanged: boolean;\n}\n\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n results: SyncResult[];\n errors: LiveUpdateError[];\n}\n\n/**\n * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.\n * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.\n *\n * @param pathToKey The *relative* path to the public key for verification.\n * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.\n * @returns Promise<void>\n */\nexport const enableSecureLiveUpdates = async (\n pathToKey: string\n): Promise<void> => {\n return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);\n};\n\n/**\n * Syncs a single live update.\n *\n * @param appId The AppFlow application ID to sync.\n * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.\n */\nexport const syncOne = async (appId: string): Promise<SyncResult> => {\n return IONPortalsReactNative.syncOne(appId);\n};\n\n/**\n * Syncs many live updates.\n *\n * @param appIds The AppFlow application IDs to sync.\n * @returns Promise<SyncResults>\n */\nexport const syncSome = async (appIds: string[]): Promise<SyncResults> => {\n return IONPortalsReactNative.syncSome(appIds);\n};\n\n/**\n * Syncs all registered LiveUpdates\n * @returns Promise<SyncResults>\n */\nexport const syncAll = async (): Promise<SyncResults> => {\n return IONPortalsReactNative.syncAll();\n};\n"],"mappings":"AAAA,SAEEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QAEH,cAAc;AAErB,MAAM;EAAEC,eAAe;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GACnEJ,aAAa;AAEf,SAASK,OAAO,IAAIC,UAAU,QAAQ,cAAc;;AAEpD;AACA;AACA;;AASA,MAAMC,aAAa,GAAG,IAAIR,kBAAkB,CAACG,eAAe,CAAC;;AAE7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,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