@ionic/portals-react-native 0.8.0 → 0.8.1
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/ReactNativePortalsPubSub.kt +6 -1
- package/lib/commonjs/BasePortalView.android.js +28 -0
- package/lib/commonjs/BasePortalView.android.js.map +1 -0
- package/lib/commonjs/BasePortalView.js +15 -0
- package/lib/commonjs/BasePortalView.js.map +1 -0
- package/lib/commonjs/index.js +150 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/BasePortalView.android.js +20 -0
- package/lib/module/BasePortalView.android.js.map +1 -0
- package/lib/module/BasePortalView.js +8 -0
- package/lib/module/BasePortalView.js.map +1 -0
- package/lib/module/index.js +137 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/BasePortalView.android.d.ts +4 -0
- package/lib/typescript/src/BasePortalView.android.d.ts.map +1 -0
- package/lib/typescript/src/BasePortalView.d.ts +4 -0
- package/lib/typescript/src/BasePortalView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +159 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -28,11 +28,16 @@ internal class PortalsPubSubModule(reactContext: ReactApplicationContext) :
|
|
|
28
28
|
.emit(eventName, result.toJSObject().toReactMap())
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
subscriptionRefs[
|
|
31
|
+
subscriptionRefs[topic] = ref
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
@ReactMethod
|
|
35
35
|
fun removeListeners(count: Int) {
|
|
36
|
+
subscriptionRefs.forEach {
|
|
37
|
+
PortalsPubSub.shared.unsubscribe(it.key, it.value)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
subscriptionRefs.clear()
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
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
|
+
const PortalViewManager = (0, _reactNative.requireNativeComponent)('AndroidPortalView');
|
|
13
|
+
const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId,
|
|
14
|
+
// we are calling the 'create' command
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
_reactNative.UIManager.AndroidPortalView.Commands.create.toString(), [viewId]);
|
|
17
|
+
const BasePortalView = props => {
|
|
18
|
+
const ref = (0, _react.useRef)(null);
|
|
19
|
+
(0, _react.useEffect)(() => {
|
|
20
|
+
const viewId = (0, _reactNative.findNodeHandle)(ref.current);
|
|
21
|
+
createFragment(viewId);
|
|
22
|
+
}, []);
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(PortalViewManager, _extends({}, props, {
|
|
24
|
+
ref: ref
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
var _default = exports.default = BasePortalView;
|
|
28
|
+
//# sourceMappingURL=BasePortalView.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","BasePortalView","props","ref","useRef","useEffect","findNodeHandle","current","createElement","_default","exports"],"sourceRoot":"../../src","sources":["BasePortalView.android.tsx"],"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,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,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,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,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const HostComponentPortal = (0, _reactNative.requireNativeComponent)('IONPortalView');
|
|
11
|
+
const BasePortalView = props => {
|
|
12
|
+
return /*#__PURE__*/_react.default.createElement(HostComponentPortal, props);
|
|
13
|
+
};
|
|
14
|
+
var _default = exports.default = BasePortalView;
|
|
15
|
+
//# sourceMappingURL=BasePortalView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","e","__esModule","default","HostComponentPortal","requireNativeComponent","BasePortalView","props","createElement","_default","exports"],"sourceRoot":"../../src","sources":["BasePortalView.tsx"],"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;AAEtD,MAAMG,mBAAmB,GAAG,IAAAC,mCAAsB,EAAC,eAAe,CAAC;AAEnE,MAAMC,cAAc,GAAIC,KAAU,IAAK;EACrC,oBAAOV,MAAA,CAAAM,OAAA,CAAAK,aAAA,CAACJ,mBAAmB,EAAKG,KAAQ,CAAC;AAC3C,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAP,OAAA,GAEaG,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.syncSome = exports.syncOne = exports.syncAll = exports.subscribe = exports.register = exports.publish = exports.enableSecureLiveUpdates = exports.PortalView = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _BasePortalView = _interopRequireDefault(require("./BasePortalView"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const {
|
|
12
|
+
IONPortalPubSub,
|
|
13
|
+
IONPortalsReactNative,
|
|
14
|
+
IONPortalsWebVitals
|
|
15
|
+
} = _reactNative.NativeModules;
|
|
16
|
+
const PortalView = props => {
|
|
17
|
+
let webVitals;
|
|
18
|
+
if (props.webVitals) {
|
|
19
|
+
webVitals = [];
|
|
20
|
+
if (props.webVitals.firstContentfulPaint) {
|
|
21
|
+
webVitals.push('fcp');
|
|
22
|
+
registerVital(props.portal.name, 'fcp', props.webVitals.firstContentfulPaint);
|
|
23
|
+
}
|
|
24
|
+
if (props.webVitals.firstInputDelay) {
|
|
25
|
+
webVitals.push('fid');
|
|
26
|
+
registerVital(props.portal.name, 'fid', props.webVitals.firstInputDelay);
|
|
27
|
+
}
|
|
28
|
+
if (props.webVitals.timeToFirstByte) {
|
|
29
|
+
webVitals.push('ttfb');
|
|
30
|
+
registerVital(props.portal.name, 'ttfb', props.webVitals.timeToFirstByte);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const newProps = {
|
|
34
|
+
...props,
|
|
35
|
+
webVitals: undefined
|
|
36
|
+
};
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
newProps.portal.webVitals = webVitals;
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_BasePortalView.default, newProps);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The data that is received from a subscription event.
|
|
44
|
+
*/
|
|
45
|
+
exports.PortalView = PortalView;
|
|
46
|
+
const PortalsPubSub = new _reactNative.NativeEventEmitter(IONPortalPubSub);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Subscribes to messages for a topic
|
|
50
|
+
*
|
|
51
|
+
* @param topic The topic to subscribe to
|
|
52
|
+
* @param onMessageReceived The callback to invoke when a message is received
|
|
53
|
+
* @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
|
|
54
|
+
*/
|
|
55
|
+
const subscribe = (topic, onMessageReceived) => {
|
|
56
|
+
return PortalsPubSub.addListener(`PortalsSubscription:${topic}`, message => {
|
|
57
|
+
onMessageReceived(message);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Publishes a message to the provided topic
|
|
63
|
+
*
|
|
64
|
+
* @param topic The topic to publish the message to
|
|
65
|
+
* @param data The data to publish to subscribers
|
|
66
|
+
*/
|
|
67
|
+
exports.subscribe = subscribe;
|
|
68
|
+
const publish = (topic, data) => {
|
|
69
|
+
const msg = {
|
|
70
|
+
message: data
|
|
71
|
+
};
|
|
72
|
+
IONPortalPubSub.publish(topic, msg);
|
|
73
|
+
};
|
|
74
|
+
exports.publish = publish;
|
|
75
|
+
const webVitalsMap = new Map();
|
|
76
|
+
const WebVitals = new _reactNative.NativeEventEmitter(IONPortalsWebVitals);
|
|
77
|
+
const registerVital = (portalName, vital, callback) => {
|
|
78
|
+
if (_reactNative.Platform.OS === 'ios' && vital !== 'fcp') return;
|
|
79
|
+
const listener = WebVitals.addListener(`vitals:${vital}`, event => {
|
|
80
|
+
if (event.portalName === portalName) {
|
|
81
|
+
callback(event.duration);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
webVitalsMap.set(`${portalName}-vitals:${vital}`, listener);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Validates that a valid registration key has been procured from http://ionic.io/register-portals
|
|
88
|
+
* @param key The registration key
|
|
89
|
+
* @returns Promise<void>
|
|
90
|
+
*/
|
|
91
|
+
const register = async key => {
|
|
92
|
+
return IONPortalsReactNative.register(key);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The configuration of a web application to be embedded in a React Native application.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Props needed for rendering a {@link Portal}
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/** Data needed to register a live update to be managed */
|
|
104
|
+
|
|
105
|
+
/** Used for communicating sync results of multiple live updates */
|
|
106
|
+
exports.register = register;
|
|
107
|
+
/**
|
|
108
|
+
* Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
|
|
109
|
+
* This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
|
|
110
|
+
*
|
|
111
|
+
* @param pathToKey The *relative* path to the public key for verification.
|
|
112
|
+
* This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.
|
|
113
|
+
* @returns Promise<void>
|
|
114
|
+
*/
|
|
115
|
+
const enableSecureLiveUpdates = async pathToKey => {
|
|
116
|
+
return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Syncs a single live update.
|
|
121
|
+
*
|
|
122
|
+
* @param appId The AppFlow application ID to sync.
|
|
123
|
+
* @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
|
|
124
|
+
*/
|
|
125
|
+
exports.enableSecureLiveUpdates = enableSecureLiveUpdates;
|
|
126
|
+
const syncOne = async appId => {
|
|
127
|
+
return IONPortalsReactNative.syncOne(appId);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Syncs many live updates.
|
|
132
|
+
*
|
|
133
|
+
* @param appIds The AppFlow application IDs to sync.
|
|
134
|
+
* @returns Promise<SyncResults>
|
|
135
|
+
*/
|
|
136
|
+
exports.syncOne = syncOne;
|
|
137
|
+
const syncSome = async appIds => {
|
|
138
|
+
return IONPortalsReactNative.syncSome(appIds);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Syncs all registered LiveUpdates
|
|
143
|
+
* @returns Promise<SyncResults>
|
|
144
|
+
*/
|
|
145
|
+
exports.syncSome = syncSome;
|
|
146
|
+
const syncAll = async () => {
|
|
147
|
+
return IONPortalsReactNative.syncAll();
|
|
148
|
+
};
|
|
149
|
+
exports.syncAll = syncAll;
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_BasePortalView","e","__esModule","default","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","NativeModules","PortalView","props","webVitals","firstContentfulPaint","push","registerVital","portal","name","firstInputDelay","timeToFirstByte","newProps","undefined","createElement","exports","PortalsPubSub","NativeEventEmitter","subscribe","topic","onMessageReceived","addListener","message","publish","data","msg","webVitalsMap","Map","WebVitals","portalName","vital","callback","Platform","OS","listener","event","duration","set","register","key","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAA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AAC;AAC5C,CAAC;;AAED;AACA;AACA;;AA2CA;AACA;AACA;;AAUA;;AAiCA;AAAAxB,OAAA,CAAAuB,QAAA,GAAAA,QAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAG,MACrCC,SAAiB,IACC;EAClB,OAAO1C,qBAAqB,CAACyC,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA1B,OAAA,CAAAyB,uBAAA,GAAAA,uBAAA;AAMO,MAAME,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAO5C,qBAAqB,CAAC2C,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA5B,OAAA,CAAA2B,OAAA,GAAAA,OAAA;AAMO,MAAME,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAO9C,qBAAqB,CAAC6C,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AAHA9B,OAAA,CAAA6B,QAAA,GAAAA,QAAA;AAIO,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAO/C,qBAAqB,CAAC+C,OAAO,CAAC,CAAC;AACxC,CAAC;AAAC/B,OAAA,CAAA+B,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { findNodeHandle, requireNativeComponent, UIManager } from 'react-native';
|
|
4
|
+
const PortalViewManager = requireNativeComponent('AndroidPortalView');
|
|
5
|
+
const createFragment = viewId => UIManager.dispatchViewManagerCommand(viewId,
|
|
6
|
+
// we are calling the 'create' command
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
UIManager.AndroidPortalView.Commands.create.toString(), [viewId]);
|
|
9
|
+
const BasePortalView = props => {
|
|
10
|
+
const ref = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const viewId = findNodeHandle(ref.current);
|
|
13
|
+
createFragment(viewId);
|
|
14
|
+
}, []);
|
|
15
|
+
return /*#__PURE__*/React.createElement(PortalViewManager, _extends({}, props, {
|
|
16
|
+
ref: ref
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
export default BasePortalView;
|
|
20
|
+
//# sourceMappingURL=BasePortalView.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","BasePortalView","props","ref","current","createElement","_extends"],"sourceRoot":"../../src","sources":["BasePortalView.android.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SACEC,cAAc,EACdC,sBAAsB,EACtBC,SAAS,QACJ,cAAc;AAErB,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,cAAc,GAAIC,KAAU,IAAK;EACrC,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,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { requireNativeComponent } from 'react-native';
|
|
3
|
+
const HostComponentPortal = requireNativeComponent('IONPortalView');
|
|
4
|
+
const BasePortalView = props => {
|
|
5
|
+
return /*#__PURE__*/React.createElement(HostComponentPortal, props);
|
|
6
|
+
};
|
|
7
|
+
export default BasePortalView;
|
|
8
|
+
//# sourceMappingURL=BasePortalView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","requireNativeComponent","HostComponentPortal","BasePortalView","props","createElement"],"sourceRoot":"../../src","sources":["BasePortalView.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,sBAAsB,QAAQ,cAAc;AAErD,MAAMC,mBAAmB,GAAGD,sBAAsB,CAAC,eAAe,CAAC;AAEnE,MAAME,cAAc,GAAIC,KAAU,IAAK;EACrC,oBAAOJ,KAAA,CAAAK,aAAA,CAACH,mBAAmB,EAAKE,KAAQ,CAAC;AAC3C,CAAC;AAED,eAAeD,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
3
|
+
import BasePortalView from './BasePortalView';
|
|
4
|
+
const {
|
|
5
|
+
IONPortalPubSub,
|
|
6
|
+
IONPortalsReactNative,
|
|
7
|
+
IONPortalsWebVitals
|
|
8
|
+
} = NativeModules;
|
|
9
|
+
export const PortalView = props => {
|
|
10
|
+
let webVitals;
|
|
11
|
+
if (props.webVitals) {
|
|
12
|
+
webVitals = [];
|
|
13
|
+
if (props.webVitals.firstContentfulPaint) {
|
|
14
|
+
webVitals.push('fcp');
|
|
15
|
+
registerVital(props.portal.name, 'fcp', props.webVitals.firstContentfulPaint);
|
|
16
|
+
}
|
|
17
|
+
if (props.webVitals.firstInputDelay) {
|
|
18
|
+
webVitals.push('fid');
|
|
19
|
+
registerVital(props.portal.name, 'fid', props.webVitals.firstInputDelay);
|
|
20
|
+
}
|
|
21
|
+
if (props.webVitals.timeToFirstByte) {
|
|
22
|
+
webVitals.push('ttfb');
|
|
23
|
+
registerVital(props.portal.name, 'ttfb', props.webVitals.timeToFirstByte);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const newProps = {
|
|
27
|
+
...props,
|
|
28
|
+
webVitals: undefined
|
|
29
|
+
};
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
newProps.portal.webVitals = webVitals;
|
|
32
|
+
return /*#__PURE__*/React.createElement(BasePortalView, newProps);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The data that is received from a subscription event.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Subscribes to messages for a topic
|
|
43
|
+
*
|
|
44
|
+
* @param topic The topic to subscribe to
|
|
45
|
+
* @param onMessageReceived The callback to invoke when a message is received
|
|
46
|
+
* @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
|
|
47
|
+
*/
|
|
48
|
+
export const subscribe = (topic, onMessageReceived) => {
|
|
49
|
+
return PortalsPubSub.addListener(`PortalsSubscription:${topic}`, message => {
|
|
50
|
+
onMessageReceived(message);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Publishes a message to the provided topic
|
|
56
|
+
*
|
|
57
|
+
* @param topic The topic to publish the message to
|
|
58
|
+
* @param data The data to publish to subscribers
|
|
59
|
+
*/
|
|
60
|
+
export const publish = (topic, data) => {
|
|
61
|
+
const msg = {
|
|
62
|
+
message: data
|
|
63
|
+
};
|
|
64
|
+
IONPortalPubSub.publish(topic, msg);
|
|
65
|
+
};
|
|
66
|
+
const webVitalsMap = new Map();
|
|
67
|
+
const WebVitals = new NativeEventEmitter(IONPortalsWebVitals);
|
|
68
|
+
const registerVital = (portalName, vital, callback) => {
|
|
69
|
+
if (Platform.OS === 'ios' && vital !== 'fcp') return;
|
|
70
|
+
const listener = WebVitals.addListener(`vitals:${vital}`, event => {
|
|
71
|
+
if (event.portalName === portalName) {
|
|
72
|
+
callback(event.duration);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
webVitalsMap.set(`${portalName}-vitals:${vital}`, listener);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Validates that a valid registration key has been procured from http://ionic.io/register-portals
|
|
79
|
+
* @param key The registration key
|
|
80
|
+
* @returns Promise<void>
|
|
81
|
+
*/
|
|
82
|
+
export const register = async key => {
|
|
83
|
+
return IONPortalsReactNative.register(key);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The configuration of a web application to be embedded in a React Native application.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Props needed for rendering a {@link Portal}
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/** Data needed to register a live update to be managed */
|
|
95
|
+
|
|
96
|
+
/** Used for communicating sync results of multiple live updates */
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
|
|
100
|
+
* This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
|
|
101
|
+
*
|
|
102
|
+
* @param pathToKey The *relative* path to the public key for verification.
|
|
103
|
+
* This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.
|
|
104
|
+
* @returns Promise<void>
|
|
105
|
+
*/
|
|
106
|
+
export const enableSecureLiveUpdates = async pathToKey => {
|
|
107
|
+
return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Syncs a single live update.
|
|
112
|
+
*
|
|
113
|
+
* @param appId The AppFlow application ID to sync.
|
|
114
|
+
* @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
|
|
115
|
+
*/
|
|
116
|
+
export const syncOne = async appId => {
|
|
117
|
+
return IONPortalsReactNative.syncOne(appId);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Syncs many live updates.
|
|
122
|
+
*
|
|
123
|
+
* @param appIds The AppFlow application IDs to sync.
|
|
124
|
+
* @returns Promise<SyncResults>
|
|
125
|
+
*/
|
|
126
|
+
export const syncSome = async appIds => {
|
|
127
|
+
return IONPortalsReactNative.syncSome(appIds);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Syncs all registered LiveUpdates
|
|
132
|
+
* @returns Promise<SyncResults>
|
|
133
|
+
*/
|
|
134
|
+
export const syncAll = async () => {
|
|
135
|
+
return IONPortalsReactNative.syncAll();
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","NativeEventEmitter","NativeModules","Platform","BasePortalView","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","PortalView","props","webVitals","firstContentfulPaint","push","registerVital","portal","name","firstInputDelay","timeToFirstByte","newProps","undefined","createElement","PortalsPubSub","subscribe","topic","onMessageReceived","addListener","message","publish","data","msg","webVitalsMap","Map","WebVitals","portalName","vital","callback","OS","listener","event","duration","set","register","key","enableSecureLiveUpdates","pathToKey","syncOne","appId","syncSome","appIds","syncAll"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAEEC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QAEH,cAAc;AACrB,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rCC,SAAiB,IACC;EAClB,OAAOtC,qBAAqB,CAACqC,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAOxC,qBAAqB,CAACuC,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAO1C,qBAAqB,CAACyC,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAO3C,qBAAqB,CAAC2C,OAAO,CAAC,CAAC;AACxC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePortalView.android.d.ts","sourceRoot":"","sources":["../../../src/BasePortalView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAkBjD,QAAA,MAAM,cAAc,UAAW,GAAG,sBASjC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePortalView.d.ts","sourceRoot":"","sources":["../../../src/BasePortalView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,QAAA,MAAM,cAAc,UAAW,GAAG,sBAEjC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type EmitterSubscription, type ViewProps } from 'react-native';
|
|
3
|
+
export declare const PortalView: (props: PortalProps) => React.JSX.Element;
|
|
4
|
+
/**
|
|
5
|
+
* The data that is received from a subscription event.
|
|
6
|
+
*/
|
|
7
|
+
export interface Message {
|
|
8
|
+
/** The unique subscription reference received from {@link subscribe}*/
|
|
9
|
+
subscriptionRef: number;
|
|
10
|
+
data: any;
|
|
11
|
+
/** The topic the message was sent from */
|
|
12
|
+
topic: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Subscribes to messages for a topic
|
|
16
|
+
*
|
|
17
|
+
* @param topic The topic to subscribe to
|
|
18
|
+
* @param onMessageReceived The callback to invoke when a message is received
|
|
19
|
+
* @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
|
|
20
|
+
*/
|
|
21
|
+
export declare const subscribe: (topic: string, onMessageReceived: (message: Message) => void) => EmitterSubscription;
|
|
22
|
+
/**
|
|
23
|
+
* Publishes a message to the provided topic
|
|
24
|
+
*
|
|
25
|
+
* @param topic The topic to publish the message to
|
|
26
|
+
* @param data The data to publish to subscribers
|
|
27
|
+
*/
|
|
28
|
+
export declare const publish: (topic: string, data: any) => void;
|
|
29
|
+
export type WebVitals = {
|
|
30
|
+
firstContentfulPaint?: (duration: number) => void;
|
|
31
|
+
firstInputDelay?: (duration: number) => void;
|
|
32
|
+
timeToFirstByte?: (duration: number) => void;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Validates that a valid registration key has been procured from http://ionic.io/register-portals
|
|
36
|
+
* @param key The registration key
|
|
37
|
+
* @returns Promise<void>
|
|
38
|
+
*/
|
|
39
|
+
export declare const register: (key: string) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The configuration of a web application to be embedded in a React Native application.
|
|
42
|
+
*/
|
|
43
|
+
export interface Portal {
|
|
44
|
+
/** The name of the Portal to be referenced. Must be **unique** */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Any Capacitor plugins to be made available to the Portal */
|
|
47
|
+
plugins?: CapacitorPlugin[];
|
|
48
|
+
/**
|
|
49
|
+
* The root directory of the web application relative to Bundle.main on iOS
|
|
50
|
+
* and src/main/assets on Android. If omitted, `name` is used.
|
|
51
|
+
*/
|
|
52
|
+
startDir?: string;
|
|
53
|
+
/** The name of the initial file to load. If omitted, 'index.html' is used. */
|
|
54
|
+
index?: string;
|
|
55
|
+
/** Any data needed at initial render when a portal is loaded. */
|
|
56
|
+
initialContext?: {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
59
|
+
assetMaps?: AssetMap[];
|
|
60
|
+
liveUpdate?: LiveUpdateConfig;
|
|
61
|
+
}
|
|
62
|
+
export interface CapacitorPlugin {
|
|
63
|
+
/** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */
|
|
64
|
+
androidClassPath: string;
|
|
65
|
+
/** The class name of the plugin to be used in iOS.
|
|
66
|
+
* This must be the name as it is exposed to the Objective-C runtime.
|
|
67
|
+
* For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.
|
|
68
|
+
*/
|
|
69
|
+
iosClassName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AssetMap {
|
|
72
|
+
/** The name to index the asset map by */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */
|
|
75
|
+
virtualPath?: string;
|
|
76
|
+
/** The root directory of the assets relative to Bundle.main on iOS
|
|
77
|
+
* and src/main/assets on Android. If omitted, the root of Bundle.main
|
|
78
|
+
* and src/main/assets will be used.
|
|
79
|
+
*/
|
|
80
|
+
startDir?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Props needed for rendering a {@link Portal}
|
|
84
|
+
*/
|
|
85
|
+
export type PortalProps = {
|
|
86
|
+
portal: Portal;
|
|
87
|
+
webVitals?: WebVitals;
|
|
88
|
+
} & ViewProps;
|
|
89
|
+
export interface LiveUpdate {
|
|
90
|
+
/** The AppFlow application ID */
|
|
91
|
+
appId: string;
|
|
92
|
+
/** The AppFlow distribution channel */
|
|
93
|
+
channel: string;
|
|
94
|
+
}
|
|
95
|
+
/** Data needed to register a live update to be managed */
|
|
96
|
+
export type LiveUpdateConfig = LiveUpdate & {
|
|
97
|
+
syncOnAdd: boolean;
|
|
98
|
+
};
|
|
99
|
+
export interface LiveUpdateError {
|
|
100
|
+
/** The AppFlow application ID relating to the failure */
|
|
101
|
+
appId: string;
|
|
102
|
+
/** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/
|
|
103
|
+
failStep: string;
|
|
104
|
+
/** A human readable error message */
|
|
105
|
+
message: string;
|
|
106
|
+
}
|
|
107
|
+
export interface Snapshot {
|
|
108
|
+
/** The snapshot id as found in AppFlow */
|
|
109
|
+
id: string;
|
|
110
|
+
/** The AppFlow build id that produced the snapshot */
|
|
111
|
+
buildId: string;
|
|
112
|
+
}
|
|
113
|
+
export interface SyncResult {
|
|
114
|
+
/** The {@link LiveUpdate} associated with the result */
|
|
115
|
+
liveUpdate: LiveUpdate;
|
|
116
|
+
/** The {@link Snapshot} that was sync'd */
|
|
117
|
+
snapshot: Snapshot | null;
|
|
118
|
+
/** Whether the snapshot was downloaded or already on disk */
|
|
119
|
+
source: 'download' | 'cache';
|
|
120
|
+
/** If the active application path was changed. A `false` value would indicate
|
|
121
|
+
* the application already has the latest code for the associated {@link LiveUpdate}
|
|
122
|
+
* configuration.
|
|
123
|
+
*/
|
|
124
|
+
activeApplicationPathChanged: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** Used for communicating sync results of multiple live updates */
|
|
127
|
+
export interface SyncResults {
|
|
128
|
+
results: SyncResult[];
|
|
129
|
+
errors: LiveUpdateError[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
|
|
133
|
+
* This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
|
|
134
|
+
*
|
|
135
|
+
* @param pathToKey The *relative* path to the public key for verification.
|
|
136
|
+
* This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.
|
|
137
|
+
* @returns Promise<void>
|
|
138
|
+
*/
|
|
139
|
+
export declare const enableSecureLiveUpdates: (pathToKey: string) => Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Syncs a single live update.
|
|
142
|
+
*
|
|
143
|
+
* @param appId The AppFlow application ID to sync.
|
|
144
|
+
* @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
|
|
145
|
+
*/
|
|
146
|
+
export declare const syncOne: (appId: string) => Promise<SyncResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Syncs many live updates.
|
|
149
|
+
*
|
|
150
|
+
* @param appIds The AppFlow application IDs to sync.
|
|
151
|
+
* @returns Promise<SyncResults>
|
|
152
|
+
*/
|
|
153
|
+
export declare const syncSome: (appIds: string[]) => Promise<SyncResults>;
|
|
154
|
+
/**
|
|
155
|
+
* Syncs all registered LiveUpdates
|
|
156
|
+
* @returns Promise<SyncResults>
|
|
157
|
+
*/
|
|
158
|
+
export declare const syncAll: () => Promise<SyncResults>;
|
|
159
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,mBAAmB,EAIxB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,eAAO,MAAM,UAAU,UAAW,WAAW,sBA2B5C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC;IACV,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAID;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UACb,MAAM,+BACgB,OAAO,KAAK,IAAI,KAC5C,mBAOF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,UAAW,MAAM,QAAQ,GAAG,SAG/C,CAAC;AA4BF,MAAM,MAAM,SAAS,GAAG;IACtB,oBAAoB,CAAC,EAAE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