@ionic/portals-react-native 0.2.0-1 → 0.3.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.
@@ -1,21 +1,21 @@
1
- require "json"
1
+ require 'json'
2
2
 
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = "ReactNativePortals"
7
- s.version = package["version"]
8
- s.summary = package["description"]
9
- s.homepage = package["homepage"]
10
- s.license = package["license"]
11
- s.authors = package["author"]
6
+ s.name = 'ReactNativePortals'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.homepage = package['homepage']
10
+ s.license = package['license']
11
+ s.authors = package['author']
12
12
 
13
- s.platforms = { :ios => "13.0" }
14
- s.source = { :git => "https://github.com/ionic-team/react-native-ionic-portals.git", :tag => "#{s.version}" }
13
+ s.platforms = { ios: '13.0' }
14
+ s.source = { git: 'https://github.com/ionic-team/react-native-ionic-portals.git', tag: "#{s.version}" }
15
15
 
16
- s.source_files = "ios/**/*.{h,m,mm,swift}"
16
+ s.source_files = 'ios/**/*.{h,m,mm,swift}'
17
17
 
18
- s.dependency "React-Core"
19
- s.dependency "IonicPortals", "~> 0.6.4"
20
- s.dependency "IonicLiveUpdates", "~> 0.2.0"
18
+ s.dependency 'React-Core'
19
+ s.dependency 'IonicPortals', '~> 0.7.0'
20
+ s.dependency 'IonicLiveUpdates', '~> 0.2.0'
21
21
  end
@@ -45,13 +45,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
45
45
  targetCompatibility = JavaVersion.VERSION_1_8
46
46
 
47
47
  kotlinOptions {
48
- freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
48
+ freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
49
49
  }
50
50
  }
51
51
 
52
52
  repositories {
53
53
  mavenCentral()
54
- jcenter()
55
54
  google()
56
55
 
57
56
  def found = false
@@ -124,9 +123,9 @@ dependencies {
124
123
  //noinspection GradleDynamicVersion
125
124
  api 'com.facebook.react:react-native:+'
126
125
  //noinspection GradleDynamicVersion
127
- api "io.ionic:portals:0.6.+"
126
+ api "io.ionic:portals:0.7.+"
128
127
  //noinspection GradleDynamicVersion
129
- api "io.ionic:liveupdates:0.1.+"
128
+ api "io.ionic:liveupdates:0.2.+"
130
129
 
131
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
130
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3"
132
131
  }
@@ -1,4 +1,4 @@
1
- ReactNativePortals_kotlinVersion=1.5.31
1
+ ReactNativePortals_kotlinVersion=1.6.21
2
2
  ReactNativePortals_compileSdkVersion=29
3
3
  ReactNativePortals_targetSdkVersion=29
4
4
  android.useAndroidX=true
package/ios/Podfile CHANGED
@@ -7,9 +7,8 @@ target 'ReactNativePortals' do
7
7
  # Comment the next line if you don't want to use dynamic frameworks
8
8
  config = use_native_modules!
9
9
  use_frameworks!
10
- use_react_native!(:path => config["reactNativePath"])
10
+ use_react_native!(path: config['reactNativePath'])
11
11
  # Pods for ReactNativePortals
12
- pod 'IonicPortals', '~> 0.6.4'
12
+ pod 'IonicPortals', '~> 0.7.0'
13
13
  pod 'IonicLiveUpdates', '~> 0.2.0'
14
14
  end
15
-
package/ios/Podfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PODS:
2
2
  - boost-for-react-native (1.63.0)
3
- - Capacitor (3.7.0):
3
+ - Capacitor (4.5.0):
4
4
  - CapacitorCordova
5
- - CapacitorCordova (3.7.0)
5
+ - CapacitorCordova (4.5.0)
6
6
  - DoubleConversion (1.1.6)
7
7
  - FBLazyVector (0.63.4)
8
8
  - FBReactNativeSpec (0.63.4):
@@ -23,8 +23,8 @@ PODS:
23
23
  - glog
24
24
  - glog (0.3.5)
25
25
  - IonicLiveUpdates (0.2.0)
26
- - IonicPortals (0.6.4):
27
- - Capacitor (~> 3.7)
26
+ - IonicPortals (0.7.0):
27
+ - Capacitor (~> 4.4)
28
28
  - IonicLiveUpdates (< 0.3.0, >= 0.1.2)
29
29
  - RCTRequired (0.63.4)
30
30
  - RCTTypeSafety (0.63.4):
@@ -261,7 +261,7 @@ DEPENDENCIES:
261
261
  - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
262
262
  - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
263
263
  - IonicLiveUpdates (~> 0.2.0)
264
- - IonicPortals (~> 0.6.4)
264
+ - IonicPortals (~> 0.7.0)
265
265
  - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
266
266
  - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
267
267
  - React (from `../node_modules/react-native/`)
@@ -350,15 +350,15 @@ EXTERNAL SOURCES:
350
350
 
351
351
  SPEC CHECKSUMS:
352
352
  boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
353
- Capacitor: 747a1e47077e8f82abf2209867c440d7366ad68c
354
- CapacitorCordova: e6b42a8e8d5986c1eb8f02ac0be205fafc32ac33
353
+ Capacitor: c09c7031f87bef4a4b9883866115806654ba0865
354
+ CapacitorCordova: d6cf164af488874853a89579c06b877048a656ce
355
355
  DoubleConversion: cde416483dac037923206447da6e1454df403714
356
356
  FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
357
357
  FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
358
358
  Folly: b73c3869541e86821df3c387eb0af5f65addfab4
359
359
  glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
360
360
  IonicLiveUpdates: e9cfcb6cbcf67d7b171eae417fa2802cc5826d72
361
- IonicPortals: 50634da3bd7a3cf9127bbad5f21fd23afde4f0ff
361
+ IonicPortals: fd21c96f9088312fc8d7ace4583c0a5f4e2ed876
362
362
  RCTRequired: 082f10cd3f905d6c124597fd1c14f6f2655ff65e
363
363
  RCTTypeSafety: 8c9c544ecbf20337d069e4ae7fd9a377aadf504b
364
364
  React: b0a957a2c44da4113b0c4c9853d8387f8e64e615
@@ -381,6 +381,6 @@ SPEC CHECKSUMS:
381
381
  ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
382
382
  Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
383
383
 
384
- PODFILE CHECKSUM: 9dce8640a99e055a2e7fad56d00e49829114eae1
384
+ PODFILE CHECKSUM: 353df7c7b25664ae757fa202af97c22b61c3affa
385
385
 
386
386
  COCOAPODS: 1.11.2
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _reactNative = require("react-native");
11
-
12
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
11
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
-
18
12
  const PortalViewManager = (0, _reactNative.requireNativeComponent)('AndroidPortalView');
19
-
20
- const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId, // we are calling the 'create' command
13
+ const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId,
14
+ // we are calling the 'create' command
21
15
  // @ts-expect-error
22
16
  _reactNative.UIManager.AndroidPortalView.Commands.create.toString(), [viewId]);
23
-
24
17
  const PortalView = props => {
25
18
  const ref = (0, _react.useRef)(null);
26
19
  (0, _react.useEffect)(() => {
@@ -31,7 +24,6 @@ const PortalView = props => {
31
24
  ref: ref
32
25
  }));
33
26
  };
34
-
35
27
  var _default = PortalView;
36
28
  exports.default = _default;
37
29
  //# sourceMappingURL=PortalView.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PortalViewManager","requireNativeComponent","createFragment","viewId","UIManager","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","useRef","useEffect","findNodeHandle","current"],"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;;AACA;;;;;;;;AAOA,MAAMA,iBAAiB,GAAG,IAAAC,mCAAA,EAAuB,mBAAvB,CAA1B;;AAEA,MAAMC,cAAc,GAAIC,MAAD,IACrBC,sBAAA,CAAUC,0BAAV,CACEF,MADF,EAEE;AACA;AACAC,sBAAA,CAAUE,iBAAV,CAA4BC,QAA5B,CAAqCC,MAArC,CAA4CC,QAA5C,EAJF,EAKE,CAACN,MAAD,CALF,CADF;;AASA,MAAMO,UAAU,GAAIC,KAAD,IAAwB;EACzC,MAAMC,GAAG,GAAG,IAAAC,aAAA,EAAO,IAAP,CAAZ;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,MAAMX,MAAM,GAAG,IAAAY,2BAAA,EAAeH,GAAG,CAACI,OAAnB,CAAf;IACAd,cAAc,CAACC,MAAD,CAAd;EACD,CAHD,EAGG,EAHH;EAKA,oBAAO,6BAAC,iBAAD,eAAuBQ,KAAvB;IAA8B,GAAG,EAAEC;EAAnC,GAAP;AACD,CATD;;eAWeF,U"}
1
+ {"version":3,"names":["PortalViewManager","requireNativeComponent","createFragment","viewId","UIManager","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","useRef","useEffect","findNodeHandle","current"],"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;AACA;AAIsB;AAAA;AAAA;AAGtB,MAAMA,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,EAAE,EACtD,CAACN,MAAM,CAAC,CACT;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,oBAAO,6BAAC,iBAAiB,eAAKQ,KAAK;IAAE,GAAG,EAAEC;EAAI,GAAG;AACnD,CAAC;AAAC,eAEaF,UAAU;AAAA"}
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _reactNative = require("react-native");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const HostComponentPortal = (0, _reactNative.requireNativeComponent)('IONPortalView');
15
-
16
11
  const PortalView = props => {
17
12
  return /*#__PURE__*/_react.default.createElement(HostComponentPortal, props);
18
13
  };
19
-
20
14
  var _default = PortalView;
21
15
  exports.default = _default;
22
16
  //# sourceMappingURL=PortalView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HostComponentPortal","requireNativeComponent","PortalView","props"],"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;;AACA;;;;AAGA,MAAMA,mBAAmB,GAAG,IAAAC,mCAAA,EAAuB,eAAvB,CAA5B;;AAEA,MAAMC,UAAU,GAAIC,KAAD,IAAwB;EACzC,oBAAO,6BAAC,mBAAD,EAAyBA,KAAzB,CAAP;AACD,CAFD;;eAIeD,U"}
1
+ {"version":3,"names":["HostComponentPortal","requireNativeComponent","PortalView","props"],"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;AACA;AAAsD;AAGtD,MAAMA,mBAAmB,GAAG,IAAAC,mCAAsB,EAAC,eAAe,CAAC;AAEnE,MAAMC,UAAU,GAAIC,KAAkB,IAAK;EACzC,oBAAO,6BAAC,mBAAmB,EAAKA,KAAK,CAAI;AAC3C,CAAC;AAAC,eAEaD,UAAU;AAAA"}
@@ -10,19 +10,16 @@ Object.defineProperty(exports, "PortalView", {
10
10
  }
11
11
  });
12
12
  exports.unsubscribe = exports.syncSome = exports.syncOne = exports.syncAll = exports.subscribe = exports.register = exports.publish = exports.getPortal = exports.enableSecureLiveUpdates = exports.addPortals = exports.addPortal = void 0;
13
-
14
13
  var _reactNative = require("react-native");
15
-
16
14
  var _PortalView = _interopRequireDefault(require("./PortalView"));
17
-
18
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
16
  const {
21
17
  IONPortalPubSub,
22
18
  IONPortalsReactNative
23
19
  } = _reactNative.NativeModules;
24
20
  const PortalsPubSub = new _reactNative.NativeEventEmitter(IONPortalPubSub);
25
21
  const subscriptionMap = new Map();
22
+
26
23
  /**
27
24
  * Subscribes to messages for a topic
28
25
  *
@@ -30,7 +27,6 @@ const subscriptionMap = new Map();
30
27
  * @param onMessageReceived The callback to invoke when a message is received
31
28
  * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
32
29
  */
33
-
34
30
  const subscribe = async (topic, onMessageReceived) => {
35
31
  const subscriptionRef = await IONPortalPubSub.subscribe(topic);
36
32
  const subscriber = PortalsPubSub.addListener('PortalsSubscription', message => {
@@ -41,60 +37,51 @@ const subscribe = async (topic, onMessageReceived) => {
41
37
  subscriptionMap.set(subscriptionRef, subscriber);
42
38
  return subscriptionRef;
43
39
  };
40
+
44
41
  /**
45
42
  * Unsubscribes from events for the provided topic and subscription reference
46
43
  *
47
44
  * @param topic The topic to unsubscribe from
48
45
  * @param subRef The unique subscription reference received when initially calling {@link subscribe}
49
46
  */
50
-
51
-
52
47
  exports.subscribe = subscribe;
53
-
54
48
  const unsubscribe = (topic, subRef) => {
55
49
  IONPortalPubSub.unsubscribe(topic, subRef);
56
50
  const subscription = subscriptionMap.get(subRef);
57
-
58
51
  if (subscription !== undefined) {
59
52
  subscription.remove();
60
53
  subscriptionMap.delete(subRef);
61
54
  }
62
55
  };
56
+
63
57
  /**
64
58
  * Publishes a message to the provided topic
65
59
  *
66
60
  * @param topic The topic to publish the message to
67
61
  * @param data The data to publish to subscribers
68
62
  */
69
-
70
-
71
63
  exports.unsubscribe = unsubscribe;
72
-
73
64
  const publish = (topic, data) => {
74
65
  const msg = {
75
66
  message: data
76
67
  };
77
68
  IONPortalPubSub.publish(topic, msg);
78
69
  };
70
+
79
71
  /**
80
72
  * Validates that a valid registration key has been procured from http://ionic.io/register-portals
81
73
  * @param key The registration key
82
74
  * @returns Promise<void>
83
75
  */
84
-
85
-
86
76
  exports.publish = publish;
87
-
88
77
  const register = async key => {
89
78
  return IONPortalsReactNative.register(key);
90
79
  };
80
+
91
81
  /**
92
82
  * The configuration of a web application to be embedded in a React Native application.
93
83
  */
94
-
95
-
96
84
  exports.register = register;
97
-
98
85
  /**
99
86
  * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.
100
87
  *
@@ -104,35 +91,29 @@ exports.register = register;
104
91
  const addPortal = async portal => {
105
92
  return IONPortalsReactNative.addPortal(portal);
106
93
  };
94
+
107
95
  /**
108
96
  * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}
109
97
  *
110
98
  * @param portals The portals to add to the internal registry.
111
99
  * @returns Promise containing the Portals that were added to the registry.
112
100
  */
113
-
114
-
115
101
  exports.addPortal = addPortal;
116
-
117
102
  const addPortals = async portals => {
118
103
  return IONPortalsReactNative.addPortals(portals);
119
104
  };
105
+
120
106
  /**
121
107
  * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.
122
108
  *
123
109
  * @param name The portal name to retrieve from the internal registry.
124
110
  * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.
125
111
  */
126
-
127
-
128
112
  exports.addPortals = addPortals;
129
-
130
113
  const getPortal = async name => {
131
114
  return IONPortalsReactNative.getPortal(name);
132
115
  };
133
-
134
116
  exports.getPortal = getPortal;
135
-
136
117
  /**
137
118
  * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
138
119
  * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
@@ -144,43 +125,36 @@ exports.getPortal = getPortal;
144
125
  const enableSecureLiveUpdates = async pathToKey => {
145
126
  return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);
146
127
  };
128
+
147
129
  /**
148
130
  * Syncs a single live update.
149
131
  *
150
132
  * @param appId The AppFlow application ID to sync.
151
133
  * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
152
134
  */
153
-
154
-
155
135
  exports.enableSecureLiveUpdates = enableSecureLiveUpdates;
156
-
157
136
  const syncOne = async appId => {
158
137
  return IONPortalsReactNative.syncOne(appId);
159
138
  };
139
+
160
140
  /**
161
141
  * Syncs many live updates.
162
142
  *
163
143
  * @param appIds The AppFlow application IDs to sync.
164
144
  * @returns Promise<SyncResults>
165
145
  */
166
-
167
-
168
146
  exports.syncOne = syncOne;
169
-
170
147
  const syncSome = async appIds => {
171
148
  return IONPortalsReactNative.syncSome(appIds);
172
149
  };
150
+
173
151
  /**
174
152
  * Syncs all registered LiveUpdates
175
153
  * @returns Promise<SyncResults>
176
154
  */
177
-
178
-
179
155
  exports.syncSome = syncSome;
180
-
181
156
  const syncAll = async () => {
182
157
  return IONPortalsReactNative.syncAll();
183
158
  };
184
-
185
159
  exports.syncAll = syncAll;
186
160
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["IONPortalPubSub","IONPortalsReactNative","NativeModules","PortalsPubSub","NativeEventEmitter","subscriptionMap","Map","subscribe","topic","onMessageReceived","subscriptionRef","subscriber","addListener","message","set","unsubscribe","subRef","subscription","get","undefined","remove","delete","publish","data","msg","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 ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative } = 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\nconst 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 = async (\n topic: string,\n onMessageReceived: (message: Message) => void\n): Promise<number> => {\n const subscriptionRef = await IONPortalPubSub.subscribe(topic);\n\n const subscriber = PortalsPubSub.addListener(\n 'PortalsSubscription',\n (message: Message) => {\n if (message.subscriptionRef === subscriptionRef) {\n onMessageReceived(message);\n }\n }\n );\n\n subscriptionMap.set(subscriptionRef, subscriber);\n\n return subscriptionRef;\n};\n\n/**\n * Unsubscribes from events for the provided topic and subscription reference\n *\n * @param topic The topic to unsubscribe from\n * @param subRef The unique subscription reference received when initially calling {@link subscribe}\n */\nexport const unsubscribe = (topic: string, subRef: number) => {\n IONPortalPubSub.unsubscribe(topic, subRef);\n\n const subscription = subscriptionMap.get(subRef);\n if (subscription !== undefined) {\n subscription.remove();\n subscriptionMap.delete(subRef);\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\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 /** The classpath of all Capacitor plugins used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidPlugins?: string[];\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 liveUpdate?: LiveUpdateConfig;\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\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n liveUpdates: LiveUpdate[];\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<LiveUpdate> => {\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;;AASA;;;;AAFA,MAAM;EAAEA,eAAF;EAAmBC;AAAnB,IAA6CC,0BAAnD;AAeA,MAAMC,aAAa,GAAG,IAAIC,+BAAJ,CAAuBJ,eAAvB,CAAtB;AAEA,MAAMK,eAAe,GAAG,IAAIC,GAAJ,EAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,SAAS,GAAG,OACvBC,KADuB,EAEvBC,iBAFuB,KAGH;EACpB,MAAMC,eAAe,GAAG,MAAMV,eAAe,CAACO,SAAhB,CAA0BC,KAA1B,CAA9B;EAEA,MAAMG,UAAU,GAAGR,aAAa,CAACS,WAAd,CACjB,qBADiB,EAEhBC,OAAD,IAAsB;IACpB,IAAIA,OAAO,CAACH,eAAR,KAA4BA,eAAhC,EAAiD;MAC/CD,iBAAiB,CAACI,OAAD,CAAjB;IACD;EACF,CANgB,CAAnB;EASAR,eAAe,CAACS,GAAhB,CAAoBJ,eAApB,EAAqCC,UAArC;EAEA,OAAOD,eAAP;AACD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMK,WAAW,GAAG,CAACP,KAAD,EAAgBQ,MAAhB,KAAmC;EAC5DhB,eAAe,CAACe,WAAhB,CAA4BP,KAA5B,EAAmCQ,MAAnC;EAEA,MAAMC,YAAY,GAAGZ,eAAe,CAACa,GAAhB,CAAoBF,MAApB,CAArB;;EACA,IAAIC,YAAY,KAAKE,SAArB,EAAgC;IAC9BF,YAAY,CAACG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A;AACA;AACA;;;;;AACO,MAAMC,QAAQ,GAAG,MAAOC,MAAP,IAAkD;EACxE,OAAOrC,qBAAqB,CAACoC,QAAtB,CAA+BC,MAA/B,CAAP;AACD,CAFM;AAIP;AACA;AACA;AACA;;;;;AACO,MAAMC,OAAO,GAAG,YAAkC;EACvD,OAAOtC,qBAAqB,CAACsC,OAAtB,EAAP;AACD,CAFM"}
1
+ {"version":3,"names":["IONPortalPubSub","IONPortalsReactNative","NativeModules","PortalsPubSub","NativeEventEmitter","subscriptionMap","Map","subscribe","topic","onMessageReceived","subscriptionRef","subscriber","addListener","message","set","unsubscribe","subRef","subscription","get","undefined","remove","delete","publish","data","msg","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 ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative } = 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\nconst 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 = async (\n topic: string,\n onMessageReceived: (message: Message) => void\n): Promise<number> => {\n const subscriptionRef = await IONPortalPubSub.subscribe(topic);\n\n const subscriber = PortalsPubSub.addListener(\n 'PortalsSubscription',\n (message: Message) => {\n if (message.subscriptionRef === subscriptionRef) {\n onMessageReceived(message);\n }\n }\n );\n\n subscriptionMap.set(subscriptionRef, subscriber);\n\n return subscriptionRef;\n};\n\n/**\n * Unsubscribes from events for the provided topic and subscription reference\n *\n * @param topic The topic to unsubscribe from\n * @param subRef The unique subscription reference received when initially calling {@link subscribe}\n */\nexport const unsubscribe = (topic: string, subRef: number) => {\n IONPortalPubSub.unsubscribe(topic, subRef);\n\n const subscription = subscriptionMap.get(subRef);\n if (subscription !== undefined) {\n subscription.remove();\n subscriptionMap.delete(subRef);\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\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 /** The classpath of all Capacitor plugins used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidPlugins?: string[];\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 liveUpdate?: LiveUpdateConfig;\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\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n liveUpdates: LiveUpdate[];\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<LiveUpdate> => {\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;AASA;AAAqD;AAFrD,MAAM;EAAEA,eAAe;EAAEC;AAAsB,CAAC,GAAGC,0BAAa;AAehE,MAAMC,aAAa,GAAG,IAAIC,+BAAkB,CAACJ,eAAe,CAAC;AAE7D,MAAMK,eAAe,GAAG,IAAIC,GAAG,EAA+B;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAG,OACvBC,KAAa,EACbC,iBAA6C,KACzB;EACpB,MAAMC,eAAe,GAAG,MAAMV,eAAe,CAACO,SAAS,CAACC,KAAK,CAAC;EAE9D,MAAMG,UAAU,GAAGR,aAAa,CAACS,WAAW,CAC1C,qBAAqB,EACpBC,OAAgB,IAAK;IACpB,IAAIA,OAAO,CAACH,eAAe,KAAKA,eAAe,EAAE;MAC/CD,iBAAiB,CAACI,OAAO,CAAC;IAC5B;EACF,CAAC,CACF;EAEDR,eAAe,CAACS,GAAG,CAACJ,eAAe,EAAEC,UAAU,CAAC;EAEhD,OAAOD,eAAe;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMK,WAAW,GAAG,CAACP,KAAa,EAAEQ,MAAc,KAAK;EAC5DhB,eAAe,CAACe,WAAW,CAACP,KAAK,EAAEQ,MAAM,CAAC;EAE1C,MAAMC,YAAY,GAAGZ,eAAe,CAACa,GAAG,CAACF,MAAM,CAAC;EAChD,IAAIC,YAAY,KAAKE,SAAS,EAAE;IAC9BF,YAAY,CAACG,MAAM,EAAE;IACrBf,eAAe,CAACgB,MAAM,CAACL,MAAM,CAAC;EACh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IAA2B;EACxE,OAAOrC,qBAAqB,CAACoC,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AAHA;AAIO,MAAMC,OAAO,GAAG,YAAkC;EACvD,OAAOtC,qBAAqB,CAACsC,OAAO,EAAE;AACxC,CAAC;AAAC"}
@@ -1,13 +1,11 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import React, { useEffect, useRef } from 'react';
4
3
  import { findNodeHandle, requireNativeComponent, UIManager } from 'react-native';
5
4
  const PortalViewManager = requireNativeComponent('AndroidPortalView');
6
-
7
- const createFragment = viewId => UIManager.dispatchViewManagerCommand(viewId, // we are calling the 'create' command
5
+ const createFragment = viewId => UIManager.dispatchViewManagerCommand(viewId,
6
+ // we are calling the 'create' command
8
7
  // @ts-expect-error
9
8
  UIManager.AndroidPortalView.Commands.create.toString(), [viewId]);
10
-
11
9
  const PortalView = props => {
12
10
  const ref = useRef(null);
13
11
  useEffect(() => {
@@ -18,6 +16,5 @@ const PortalView = props => {
18
16
  ref: ref
19
17
  }));
20
18
  };
21
-
22
19
  export default PortalView;
23
20
  //# sourceMappingURL=PortalView.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","current"],"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,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,QAAyC,OAAzC;AACA,SACEC,cADF,EAEEC,sBAFF,EAGEC,SAHF,QAIO,cAJP;AAOA,MAAMC,iBAAiB,GAAGF,sBAAsB,CAAC,mBAAD,CAAhD;;AAEA,MAAMG,cAAc,GAAIC,MAAD,IACrBH,SAAS,CAACI,0BAAV,CACED,MADF,EAEE;AACA;AACAH,SAAS,CAACK,iBAAV,CAA4BC,QAA5B,CAAqCC,MAArC,CAA4CC,QAA5C,EAJF,EAKE,CAACL,MAAD,CALF,CADF;;AASA,MAAMM,UAAU,GAAIC,KAAD,IAAwB;EACzC,MAAMC,GAAG,GAAGd,MAAM,CAAC,IAAD,CAAlB;EAEAD,SAAS,CAAC,MAAM;IACd,MAAMO,MAAM,GAAGL,cAAc,CAACa,GAAG,CAACC,OAAL,CAA7B;IACAV,cAAc,CAACC,MAAD,CAAd;EACD,CAHQ,EAGN,EAHM,CAAT;EAKA,oBAAO,oBAAC,iBAAD,eAAuBO,KAAvB;IAA8B,GAAG,EAAEC;EAAnC,GAAP;AACD,CATD;;AAWA,eAAeF,UAAf"}
1
+ {"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","current"],"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,EAAE,EACtD,CAACL,MAAM,CAAC,CACT;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,oBAAO,oBAAC,iBAAiB,eAAKO,KAAK;IAAE,GAAG,EAAEC;EAAI,GAAG;AACnD,CAAC;AAED,eAAeF,UAAU"}
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
2
  import { requireNativeComponent } from 'react-native';
3
3
  const HostComponentPortal = requireNativeComponent('IONPortalView');
4
-
5
4
  const PortalView = props => {
6
5
  return /*#__PURE__*/React.createElement(HostComponentPortal, props);
7
6
  };
8
-
9
7
  export default PortalView;
10
8
  //# sourceMappingURL=PortalView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","requireNativeComponent","HostComponentPortal","PortalView","props"],"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,KAAP,MAAkB,OAAlB;AACA,SAASC,sBAAT,QAAuC,cAAvC;AAGA,MAAMC,mBAAmB,GAAGD,sBAAsB,CAAC,eAAD,CAAlD;;AAEA,MAAME,UAAU,GAAIC,KAAD,IAAwB;EACzC,oBAAO,oBAAC,mBAAD,EAAyBA,KAAzB,CAAP;AACD,CAFD;;AAIA,eAAeD,UAAf"}
1
+ {"version":3,"names":["React","requireNativeComponent","HostComponentPortal","PortalView","props"],"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,oBAAO,oBAAC,mBAAmB,EAAKA,KAAK,CAAI;AAC3C,CAAC;AAED,eAAeD,UAAU"}
@@ -4,12 +4,14 @@ const {
4
4
  IONPortalsReactNative
5
5
  } = NativeModules;
6
6
  export { default as PortalView } from './PortalView';
7
+
7
8
  /**
8
9
  * The data that is received from a subscription event.
9
10
  */
10
11
 
11
12
  const PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);
12
13
  const subscriptionMap = new Map();
14
+
13
15
  /**
14
16
  * Subscribes to messages for a topic
15
17
  *
@@ -17,7 +19,6 @@ const subscriptionMap = new Map();
17
19
  * @param onMessageReceived The callback to invoke when a message is received
18
20
  * @returns A Promise<number> containing the unique subscription reference. This will need to be stored for calling {@link unsubscribe}.
19
21
  */
20
-
21
22
  export const subscribe = async (topic, onMessageReceived) => {
22
23
  const subscriptionRef = await IONPortalPubSub.subscribe(topic);
23
24
  const subscriber = PortalsPubSub.addListener('PortalsSubscription', message => {
@@ -28,44 +29,44 @@ export const subscribe = async (topic, onMessageReceived) => {
28
29
  subscriptionMap.set(subscriptionRef, subscriber);
29
30
  return subscriptionRef;
30
31
  };
32
+
31
33
  /**
32
34
  * Unsubscribes from events for the provided topic and subscription reference
33
35
  *
34
36
  * @param topic The topic to unsubscribe from
35
37
  * @param subRef The unique subscription reference received when initially calling {@link subscribe}
36
38
  */
37
-
38
39
  export const unsubscribe = (topic, subRef) => {
39
40
  IONPortalPubSub.unsubscribe(topic, subRef);
40
41
  const subscription = subscriptionMap.get(subRef);
41
-
42
42
  if (subscription !== undefined) {
43
43
  subscription.remove();
44
44
  subscriptionMap.delete(subRef);
45
45
  }
46
46
  };
47
+
47
48
  /**
48
49
  * Publishes a message to the provided topic
49
50
  *
50
51
  * @param topic The topic to publish the message to
51
52
  * @param data The data to publish to subscribers
52
53
  */
53
-
54
54
  export const publish = (topic, data) => {
55
55
  const msg = {
56
56
  message: data
57
57
  };
58
58
  IONPortalPubSub.publish(topic, msg);
59
59
  };
60
+
60
61
  /**
61
62
  * Validates that a valid registration key has been procured from http://ionic.io/register-portals
62
63
  * @param key The registration key
63
64
  * @returns Promise<void>
64
65
  */
65
-
66
66
  export const register = async key => {
67
67
  return IONPortalsReactNative.register(key);
68
68
  };
69
+
69
70
  /**
70
71
  * The configuration of a web application to be embedded in a React Native application.
71
72
  */
@@ -79,27 +80,26 @@ export const register = async key => {
79
80
  export const addPortal = async portal => {
80
81
  return IONPortalsReactNative.addPortal(portal);
81
82
  };
83
+
82
84
  /**
83
85
  * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}
84
86
  *
85
87
  * @param portals The portals to add to the internal registry.
86
88
  * @returns Promise containing the Portals that were added to the registry.
87
89
  */
88
-
89
90
  export const addPortals = async portals => {
90
91
  return IONPortalsReactNative.addPortals(portals);
91
92
  };
93
+
92
94
  /**
93
95
  * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.
94
96
  *
95
97
  * @param name The portal name to retrieve from the internal registry.
96
98
  * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.
97
99
  */
98
-
99
100
  export const getPortal = async name => {
100
101
  return IONPortalsReactNative.getPortal(name);
101
102
  };
102
-
103
103
  /**
104
104
  * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
105
105
  * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.
@@ -111,31 +111,31 @@ export const getPortal = async name => {
111
111
  export const enableSecureLiveUpdates = async pathToKey => {
112
112
  return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);
113
113
  };
114
+
114
115
  /**
115
116
  * Syncs a single live update.
116
117
  *
117
118
  * @param appId The AppFlow application ID to sync.
118
119
  * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.
119
120
  */
120
-
121
121
  export const syncOne = async appId => {
122
122
  return IONPortalsReactNative.syncOne(appId);
123
123
  };
124
+
124
125
  /**
125
126
  * Syncs many live updates.
126
127
  *
127
128
  * @param appIds The AppFlow application IDs to sync.
128
129
  * @returns Promise<SyncResults>
129
130
  */
130
-
131
131
  export const syncSome = async appIds => {
132
132
  return IONPortalsReactNative.syncSome(appIds);
133
133
  };
134
+
134
135
  /**
135
136
  * Syncs all registered LiveUpdates
136
137
  * @returns Promise<SyncResults>
137
138
  */
138
-
139
139
  export const syncAll = async () => {
140
140
  return IONPortalsReactNative.syncAll();
141
141
  };
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","IONPortalPubSub","IONPortalsReactNative","default","PortalView","PortalsPubSub","subscriptionMap","Map","subscribe","topic","onMessageReceived","subscriptionRef","subscriber","addListener","message","set","unsubscribe","subRef","subscription","get","undefined","remove","delete","publish","data","msg","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 ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative } = 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\nconst 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 = async (\n topic: string,\n onMessageReceived: (message: Message) => void\n): Promise<number> => {\n const subscriptionRef = await IONPortalPubSub.subscribe(topic);\n\n const subscriber = PortalsPubSub.addListener(\n 'PortalsSubscription',\n (message: Message) => {\n if (message.subscriptionRef === subscriptionRef) {\n onMessageReceived(message);\n }\n }\n );\n\n subscriptionMap.set(subscriptionRef, subscriber);\n\n return subscriptionRef;\n};\n\n/**\n * Unsubscribes from events for the provided topic and subscription reference\n *\n * @param topic The topic to unsubscribe from\n * @param subRef The unique subscription reference received when initially calling {@link subscribe}\n */\nexport const unsubscribe = (topic: string, subRef: number) => {\n IONPortalPubSub.unsubscribe(topic, subRef);\n\n const subscription = subscriptionMap.get(subRef);\n if (subscription !== undefined) {\n subscription.remove();\n subscriptionMap.delete(subRef);\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\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 /** The classpath of all Capacitor plugins used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidPlugins?: string[];\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 liveUpdate?: LiveUpdateConfig;\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\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n liveUpdates: LiveUpdate[];\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<LiveUpdate> => {\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,kBAFF,EAGEC,aAHF,QAKO,cALP;AAOA,MAAM;EAA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version":3,"names":["NativeEventEmitter","NativeModules","IONPortalPubSub","IONPortalsReactNative","default","PortalView","PortalsPubSub","subscriptionMap","Map","subscribe","topic","onMessageReceived","subscriptionRef","subscriber","addListener","message","set","unsubscribe","subRef","subscription","get","undefined","remove","delete","publish","data","msg","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 ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative } = 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\nconst 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 = async (\n topic: string,\n onMessageReceived: (message: Message) => void\n): Promise<number> => {\n const subscriptionRef = await IONPortalPubSub.subscribe(topic);\n\n const subscriber = PortalsPubSub.addListener(\n 'PortalsSubscription',\n (message: Message) => {\n if (message.subscriptionRef === subscriptionRef) {\n onMessageReceived(message);\n }\n }\n );\n\n subscriptionMap.set(subscriptionRef, subscriber);\n\n return subscriptionRef;\n};\n\n/**\n * Unsubscribes from events for the provided topic and subscription reference\n *\n * @param topic The topic to unsubscribe from\n * @param subRef The unique subscription reference received when initially calling {@link subscribe}\n */\nexport const unsubscribe = (topic: string, subRef: number) => {\n IONPortalPubSub.unsubscribe(topic, subRef);\n\n const subscription = subscriptionMap.get(subRef);\n if (subscription !== undefined) {\n subscription.remove();\n subscriptionMap.delete(subRef);\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\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 /** The classpath of all Capacitor plugins used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidPlugins?: string[];\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 liveUpdate?: LiveUpdateConfig;\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\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n liveUpdates: LiveUpdate[];\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<LiveUpdate> => {\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"],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,OAAO,EAAE;AACxC,CAAC"}
@@ -63,13 +63,13 @@ export interface Portal {
63
63
  * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override
64
64
  * any initialContext defined in the original {@link Portal} definition.
65
65
  */
66
- export declare type PortalProp = {
66
+ export type PortalProp = {
67
67
  portal: Pick<Portal, 'name' | 'initialContext'>;
68
68
  };
69
69
  /**
70
70
  * Props needed for rendering a {@link Portal}
71
71
  */
72
- export declare type PortalProps = PortalProp & ViewProps;
72
+ export type PortalProps = PortalProp & ViewProps;
73
73
  /**
74
74
  * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.
75
75
  *
@@ -98,7 +98,7 @@ export interface LiveUpdate {
98
98
  channel: string;
99
99
  }
100
100
  /** Data needed to register a live update to be managed */
101
- export declare type LiveUpdateConfig = LiveUpdate & {
101
+ export type LiveUpdateConfig = LiveUpdate & {
102
102
  syncOnAdd: boolean;
103
103
  };
104
104
  export interface LiveUpdateError {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionic/portals-react-native",
3
- "version": "0.2.0-1",
3
+ "version": "0.3.0",
4
4
  "description": "Ionic Portals for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",