@ionic/portals-react-native 0.3.0 → 0.4.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.
Files changed (36) hide show
  1. package/README.md +2 -2
  2. package/ReactNativePortals.podspec +2 -2
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/io/ionic/portals/reactnative/PortalView.kt +14 -4
  5. package/android/src/main/java/io/ionic/portals/reactnative/ReactNativeLiveUpdatesModule.kt +57 -74
  6. package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalManager.kt +84 -21
  7. package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalsModule.kt +19 -22
  8. package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalsPackage.kt +1 -0
  9. package/android/src/main/java/io/ionic/portals/reactnative/ReactNativeWebVitalsModule.kt +52 -0
  10. package/ios/AssetMap+Dict.swift +28 -0
  11. package/ios/ConcurrentDictionary.swift +45 -0
  12. package/ios/LiveUpdateManager+Async.swift +7 -7
  13. package/ios/Podfile +2 -2
  14. package/ios/Podfile.lock +13 -13
  15. package/ios/Portal.swift +108 -0
  16. package/ios/PortalManager.m +1 -1
  17. package/ios/PortalView.swift +1 -1
  18. package/ios/PortalWebVitals.m +15 -0
  19. package/ios/PortalsConfig.swift +18 -7
  20. package/ios/PortalsPubSub.swift +1 -0
  21. package/ios/PortalsReactNative.swift +1 -1
  22. package/ios/ReactNativePortals.xcodeproj/project.pbxproj +24 -4
  23. package/ios/SyncResult+Dict.swift +35 -0
  24. package/ios/WebVitals.swift +35 -0
  25. package/lib/commonjs/PortalView.android.js.map +1 -1
  26. package/lib/commonjs/PortalView.js.map +1 -1
  27. package/lib/commonjs/index.js +63 -3
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/module/PortalView.android.js.map +1 -1
  30. package/lib/module/PortalView.js.map +1 -1
  31. package/lib/module/index.js +55 -2
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/typescript/index.d.ts +48 -4
  34. package/package.json +1 -1
  35. package/src/index.ts +128 -5
  36. package/ios/Portal+Dict.swift +0 -35
package/ios/Podfile CHANGED
@@ -9,6 +9,6 @@ target 'ReactNativePortals' do
9
9
  use_frameworks!
10
10
  use_react_native!(path: config['reactNativePath'])
11
11
  # Pods for ReactNativePortals
12
- pod 'IonicPortals', '~> 0.7.0'
13
- pod 'IonicLiveUpdates', '~> 0.2.0'
12
+ pod 'IonicPortals', '~> 0.7.3'
13
+ pod 'IonicLiveUpdates', '~> 0.4.0'
14
14
  end
package/ios/Podfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PODS:
2
2
  - boost-for-react-native (1.63.0)
3
- - Capacitor (4.5.0):
3
+ - Capacitor (4.7.0):
4
4
  - CapacitorCordova
5
- - CapacitorCordova (4.5.0)
5
+ - CapacitorCordova (4.7.0)
6
6
  - DoubleConversion (1.1.6)
7
7
  - FBLazyVector (0.63.4)
8
8
  - FBReactNativeSpec (0.63.4):
@@ -22,10 +22,10 @@ PODS:
22
22
  - DoubleConversion
23
23
  - glog
24
24
  - glog (0.3.5)
25
- - IonicLiveUpdates (0.2.0)
26
- - IonicPortals (0.7.0):
27
- - Capacitor (~> 4.4)
28
- - IonicLiveUpdates (< 0.3.0, >= 0.1.2)
25
+ - IonicLiveUpdates (0.4.0)
26
+ - IonicPortals (0.7.3):
27
+ - Capacitor (~> 4.6)
28
+ - IonicLiveUpdates (< 0.5.0, >= 0.1.2)
29
29
  - RCTRequired (0.63.4)
30
30
  - RCTTypeSafety (0.63.4):
31
31
  - FBLazyVector (= 0.63.4)
@@ -260,8 +260,8 @@ DEPENDENCIES:
260
260
  - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
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
- - IonicLiveUpdates (~> 0.2.0)
264
- - IonicPortals (~> 0.7.0)
263
+ - IonicLiveUpdates (~> 0.4.0)
264
+ - IonicPortals (~> 0.7.3)
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: c09c7031f87bef4a4b9883866115806654ba0865
354
- CapacitorCordova: d6cf164af488874853a89579c06b877048a656ce
353
+ Capacitor: 86c48d748b59228e0fce85b1909c18c449b35f56
354
+ CapacitorCordova: 49b11f2ce72487cd751aad7181606d2a710b1549
355
355
  DoubleConversion: cde416483dac037923206447da6e1454df403714
356
356
  FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
357
357
  FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
358
358
  Folly: b73c3869541e86821df3c387eb0af5f65addfab4
359
359
  glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
360
- IonicLiveUpdates: e9cfcb6cbcf67d7b171eae417fa2802cc5826d72
361
- IonicPortals: fd21c96f9088312fc8d7ace4583c0a5f4e2ed876
360
+ IonicLiveUpdates: 77d9840ec1b2b9d1d56d4595640b5813be503fe9
361
+ IonicPortals: e44a6f9a47e7c09a879f1e2c5d901e6629ac2024
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: 353df7c7b25664ae757fa202af97c22b61c3affa
384
+ PODFILE CHECKSUM: 685fb93c81db77a563a8c1ba6999dc27b98a8d33
385
385
 
386
386
  COCOAPODS: 1.11.2
@@ -0,0 +1,108 @@
1
+ //
2
+ // Portal+Dict.swift
3
+ // ReactNativePortals
4
+ //
5
+ // Created by Steven Sherry on 10/5/22.
6
+ // Copyright © 2022 Ionic. All rights reserved.
7
+ //
8
+
9
+ import Capacitor
10
+ import IonicLiveUpdates
11
+ import IonicPortals
12
+
13
+ @dynamicMemberLookup
14
+ struct Portal {
15
+ struct Plugin {
16
+ var iosClassName: String
17
+ var androidClassPath: String
18
+ }
19
+
20
+ var _portal: IonicPortals.Portal
21
+ var plugins: [Plugin]
22
+
23
+ subscript<T>(dynamicMember keypath: Swift.WritableKeyPath<IonicPortals.Portal, T>) -> T {
24
+ get { _portal[keyPath: keypath] }
25
+ set { _portal[keyPath: keypath] = newValue }
26
+ }
27
+
28
+ subscript<T>(dynamicMember keypath: Swift.KeyPath<IonicPortals.Portal, T>) -> T {
29
+ _portal[keyPath: keypath]
30
+ }
31
+ }
32
+
33
+ extension Portal {
34
+ init?(_ dict: [String: Any], _ liveUpdateManager: LiveUpdateManager) {
35
+ guard let name = dict["name"] as? String else { return nil }
36
+ var plugins: [Portal.Plugin] = []
37
+
38
+ if let capPlugins = dict["plugins"] as? Array<[String: String]> {
39
+ plugins = capPlugins.compactMap(Portal.Plugin.init)
40
+ }
41
+
42
+ var assetMaps: [AssetMap] = []
43
+
44
+ if let maps = dict["assetMaps"] as? Array<[String: String]> {
45
+ assetMaps = maps.compactMap(AssetMap.init)
46
+ }
47
+
48
+ self._portal = IonicPortals.Portal(
49
+ name: name,
50
+ startDir: dict["startDir"] as? String,
51
+ index: dict["index"] as? String ?? "index.html",
52
+ initialContext: JSTypes.coerceDictionaryToJSObject(dict["initialContext"] as? [String: Any]) ?? [:],
53
+ assetMaps: assetMaps,
54
+ pluginRegistrationMode: .manual(plugins.toCapPlugin),
55
+ liveUpdateManager: liveUpdateManager,
56
+ liveUpdateConfig: (dict["liveUpdate"] as? [String: Any]).flatMap(LiveUpdate.init)
57
+ )
58
+
59
+ self.plugins = plugins
60
+ }
61
+
62
+ var dict: [String: Any] {
63
+ var base = [
64
+ "name": self.name,
65
+ "startDir": self.startDir,
66
+ "index": self.index,
67
+ "initialContext": self.initialContext,
68
+ "liveUpdate": self.liveUpdateConfig?.dict as Any
69
+ ]
70
+
71
+ if !plugins.isEmpty {
72
+ base["plugins"] = plugins.map(\.dict)
73
+ }
74
+
75
+ return base
76
+ }
77
+ }
78
+
79
+ extension Portal.Plugin {
80
+ init?(_ dict: [String: String]) {
81
+ guard let iosClassName = dict["iosClassName"],
82
+ let androidClassPath = dict["androidClassPath"]
83
+ else { return nil }
84
+
85
+ self.iosClassName = iosClassName
86
+ self.androidClassPath = androidClassPath
87
+ }
88
+
89
+ var dict: [String: String] {
90
+ return [
91
+ "iosClassName": iosClassName,
92
+ "androidClassPath": androidClassPath
93
+ ]
94
+ }
95
+ }
96
+
97
+ extension Portal {
98
+ var capPlugins: [IonicPortals.Portal.Plugin] {
99
+ plugins.toCapPlugin
100
+ }
101
+ }
102
+
103
+ extension Array where Element == Portal.Plugin {
104
+ var toCapPlugin: [IonicPortals.Portal.Plugin] {
105
+ compactMap { NSClassFromString($0.iosClassName) as? CAPPlugin.Type }
106
+ .compactMap(IonicPortals.Portal.Plugin.type)
107
+ }
108
+ }
@@ -16,5 +16,5 @@ RCT_EXTERN_METHOD(addPortals: (NSArray) portals resolver: (RCTPromiseResolveBloc
16
16
  RCT_EXTERN_METHOD(getPortal: (NSString *) name resolver: (RCTPromiseResolveBlock) resolver rejector: (RCTPromiseRejectBlock) rejector)
17
17
  RCT_EXTERN_METHOD(syncOne: (NSString *) appId resolver: (RCTPromiseResolveBlock) resolver rejector: (RCTPromiseRejectBlock) rejector)
18
18
  RCT_EXTERN_METHOD(syncSome: (NSArray) appIds resolver: (RCTPromiseResolveBlock) resolver rejector: (RCTPromiseRejectBlock) rejector)
19
- RCT_EXTERN_METHOD(syncAll: (RCTPromiseResolveBlock) resolver)
19
+ RCT_EXTERN_METHOD(syncAll: (RCTPromiseResolveBlock) resolver rejector: (RCTPromiseRejectBlock) rejector)
20
20
  @end
@@ -51,7 +51,7 @@ class PortalView: UIView {
51
51
  DispatchQueue.main.async { [weak self] in
52
52
  guard let self = self else { return }
53
53
  self.webView?.removeFromSuperview()
54
- let webView = PortalUIView(portal: portal)
54
+ let webView = PortalUIView(portal: portal._portal)
55
55
  webView.translatesAutoresizingMaskIntoConstraints = false
56
56
  self.addSubview(webView)
57
57
  NSLayoutConstraint.activate([
@@ -0,0 +1,15 @@
1
+ //
2
+ // PortalWebVitals.m
3
+ // ReactNativePortals
4
+ //
5
+ // Created by Steven Sherry on 3/30/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTBridgeModule.h>
10
+ #import <React/RCTEventEmitter.h>
11
+
12
+ @interface RCT_EXTERN_MODULE(IONPortalsWebVitals, RCTEventEmitter)
13
+ RCT_EXTERN_METHOD(registerOnFirstContentfulPaint: (NSString *) portalName resolver: (RCTPromiseResolveBlock) resolver rejector: (RCTPromiseRejectBlock) rejector)
14
+ @end
15
+
@@ -20,16 +20,23 @@ struct PortalsConfig {
20
20
  var startDir: String?
21
21
  var index: String?
22
22
  var initialContext: JSObject?
23
+ var assetMaps: [AssetMap]?
24
+ var plugins: [ReactNativePortals.Portal.Plugin]?
23
25
  var liveUpdate: LiveUpdate?
24
26
 
25
- func portal(with liveUpdateManager: LiveUpdateManager) -> IonicPortals.Portal {
27
+ func portal(with liveUpdateManager: LiveUpdateManager) -> ReactNativePortals.Portal {
26
28
  return .init(
27
- name: name,
28
- startDir: startDir,
29
- index: index ?? "index.html",
30
- initialContext: initialContext ?? [:],
31
- liveUpdateManager: liveUpdateManager,
32
- liveUpdateConfig: liveUpdate.map { .init(appId: $0.appId, channel: $0.channel, syncOnAdd: $0.syncOnAdd) }
29
+ _portal: .init(
30
+ name: name,
31
+ startDir: startDir,
32
+ index: index ?? "index.html",
33
+ initialContext: initialContext ?? [:],
34
+ assetMaps: assetMaps ?? [],
35
+ pluginRegistrationMode: .manual(plugins?.toCapPlugin ?? []),
36
+ liveUpdateManager: liveUpdateManager,
37
+ liveUpdateConfig: liveUpdate.map { .init(appId: $0.appId, channel: $0.channel, syncOnAdd: $0.syncOnAdd) }
38
+ ),
39
+ plugins: plugins ?? []
33
40
  )
34
41
  }
35
42
 
@@ -72,6 +79,10 @@ extension PortalsConfig.Portal {
72
79
  index = dict["index"] as? String
73
80
  initialContext = (dict["initialContext"] as? [String: Any])
74
81
  .flatMap { JSTypes.coerceDictionaryToJSObject($0) }
82
+ plugins = (dict["plugins"] as? Array<[String: String]>)
83
+ .flatMap { $0.compactMap(ReactNativePortals.Portal.Plugin.init) }
84
+ assetMaps = (dict["assetMaps"] as? Array<[String: String]>)
85
+ .flatMap { $0.compactMap(AssetMap.init) }
75
86
  liveUpdate = (dict["liveUpdate"] as? [String: Any])
76
87
  .flatMap(LiveUpdate.init)
77
88
  }
@@ -45,3 +45,4 @@ class PortalsPubSub: RCTEventEmitter {
45
45
 
46
46
  override class func requiresMainQueueSetup() -> Bool { true }
47
47
  }
48
+
@@ -6,7 +6,7 @@ import React
6
6
  @objc(IONPortalsReactNative)
7
7
  public class PortalsReactNative: NSObject {
8
8
  private var lum: LiveUpdateManager
9
- private static var portals: [String: Portal] = [:]
9
+ internal static var portals = ConcurrentDictionary<String, Portal>(label: "com.portals.reactnative", dict: [:])
10
10
 
11
11
  public override init() {
12
12
  guard let configUrl = Bundle.main.url(forResource: "portals.config.json", withExtension: nil) else {
@@ -13,10 +13,15 @@
13
13
  A7128A0827F7A16200DADDF3 /* ReactNativePortals-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = F4FF95D5245B92E700C19C63 /* ReactNativePortals-Bridging-Header.h */; };
14
14
  A7128A0927F7A16200DADDF3 /* PortalsPubSub.m in Sources */ = {isa = PBXBuildFile; fileRef = A71289F827F79D4000DADDF3 /* PortalsPubSub.m */; };
15
15
  A7128A0A27F7A16200DADDF3 /* PortalView.m in Sources */ = {isa = PBXBuildFile; fileRef = A71289F727F79CDC00DADDF3 /* PortalView.m */; };
16
+ A71E306C29D392DF0073D47A /* SyncResult+Dict.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71E306B29D392DF0073D47A /* SyncResult+Dict.swift */; };
17
+ A71E306E29D4C8710073D47A /* AssetMap+Dict.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71E306D29D4C8710073D47A /* AssetMap+Dict.swift */; };
18
+ A71E307229D5FC450073D47A /* WebVitals.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71E307129D5FC450073D47A /* WebVitals.swift */; };
19
+ A71E307429D5FF650073D47A /* PortalWebVitals.m in Sources */ = {isa = PBXBuildFile; fileRef = A71E307329D5FF650073D47A /* PortalWebVitals.m */; };
20
+ A71E307629D771C90073D47A /* ConcurrentDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71E307529D771C90073D47A /* ConcurrentDictionary.swift */; };
16
21
  A795AE1928EDEB6D0092B4B1 /* PortalsConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE1828EDEB6D0092B4B1 /* PortalsConfig.swift */; };
17
22
  A795AE1B28EDEBF20092B4B1 /* PortalsPubSub.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE1A28EDEBF20092B4B1 /* PortalsPubSub.swift */; };
18
23
  A795AE1D28EDEC7A0092B4B1 /* PortalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE1C28EDEC7A0092B4B1 /* PortalView.swift */; };
19
- A795AE1F28EDED0F0092B4B1 /* Portal+Dict.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE1E28EDED0F0092B4B1 /* Portal+Dict.swift */; };
24
+ A795AE1F28EDED0F0092B4B1 /* Portal.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE1E28EDED0F0092B4B1 /* Portal.swift */; };
20
25
  A795AE2128EDED710092B4B1 /* LiveUpdate+Dict.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE2028EDED710092B4B1 /* LiveUpdate+Dict.swift */; };
21
26
  A795AE2328EDEDCC0092B4B1 /* LiveUpdateManagerError+Dict.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE2228EDEDCC0092B4B1 /* LiveUpdateManagerError+Dict.swift */; };
22
27
  A795AE2528EDEE4E0092B4B1 /* LiveUpdateManager+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = A795AE2428EDEE4E0092B4B1 /* LiveUpdateManager+Async.swift */; };
@@ -28,10 +33,15 @@
28
33
  A71289F827F79D4000DADDF3 /* PortalsPubSub.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PortalsPubSub.m; sourceTree = "<group>"; };
29
34
  A71289F927F79EB200DADDF3 /* PortalManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PortalManager.m; sourceTree = "<group>"; };
30
35
  A71289FF27F7A14900DADDF3 /* ReactNativePortals.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReactNativePortals.framework; sourceTree = BUILT_PRODUCTS_DIR; };
36
+ A71E306B29D392DF0073D47A /* SyncResult+Dict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SyncResult+Dict.swift"; sourceTree = "<group>"; };
37
+ A71E306D29D4C8710073D47A /* AssetMap+Dict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AssetMap+Dict.swift"; sourceTree = "<group>"; };
38
+ A71E307129D5FC450073D47A /* WebVitals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebVitals.swift; sourceTree = "<group>"; };
39
+ A71E307329D5FF650073D47A /* PortalWebVitals.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PortalWebVitals.m; sourceTree = "<group>"; };
40
+ A71E307529D771C90073D47A /* ConcurrentDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConcurrentDictionary.swift; sourceTree = "<group>"; };
31
41
  A795AE1828EDEB6D0092B4B1 /* PortalsConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortalsConfig.swift; sourceTree = "<group>"; };
32
42
  A795AE1A28EDEBF20092B4B1 /* PortalsPubSub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortalsPubSub.swift; sourceTree = "<group>"; };
33
43
  A795AE1C28EDEC7A0092B4B1 /* PortalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortalView.swift; sourceTree = "<group>"; };
34
- A795AE1E28EDED0F0092B4B1 /* Portal+Dict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Portal+Dict.swift"; sourceTree = "<group>"; };
44
+ A795AE1E28EDED0F0092B4B1 /* Portal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Portal.swift; sourceTree = "<group>"; };
35
45
  A795AE2028EDED710092B4B1 /* LiveUpdate+Dict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LiveUpdate+Dict.swift"; sourceTree = "<group>"; };
36
46
  A795AE2228EDEDCC0092B4B1 /* LiveUpdateManagerError+Dict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LiveUpdateManagerError+Dict.swift"; sourceTree = "<group>"; };
37
47
  A795AE2428EDEE4E0092B4B1 /* LiveUpdateManager+Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LiveUpdateManager+Async.swift"; sourceTree = "<group>"; };
@@ -71,15 +81,20 @@
71
81
  58B511D21A9E6C8500147676 = {
72
82
  isa = PBXGroup;
73
83
  children = (
84
+ A71E307529D771C90073D47A /* ConcurrentDictionary.swift */,
85
+ A71E307129D5FC450073D47A /* WebVitals.swift */,
86
+ A71E306D29D4C8710073D47A /* AssetMap+Dict.swift */,
87
+ A71E306B29D392DF0073D47A /* SyncResult+Dict.swift */,
74
88
  F4FF95D6245B92E800C19C63 /* PortalsReactNative.swift */,
75
89
  A795AE2428EDEE4E0092B4B1 /* LiveUpdateManager+Async.swift */,
76
90
  A795AE2228EDEDCC0092B4B1 /* LiveUpdateManagerError+Dict.swift */,
77
91
  A795AE2028EDED710092B4B1 /* LiveUpdate+Dict.swift */,
78
- A795AE1E28EDED0F0092B4B1 /* Portal+Dict.swift */,
92
+ A795AE1E28EDED0F0092B4B1 /* Portal.swift */,
79
93
  A795AE1C28EDEC7A0092B4B1 /* PortalView.swift */,
80
94
  A795AE1A28EDEBF20092B4B1 /* PortalsPubSub.swift */,
81
95
  A795AE1828EDEB6D0092B4B1 /* PortalsConfig.swift */,
82
96
  A71289F727F79CDC00DADDF3 /* PortalView.m */,
97
+ A71E307329D5FF650073D47A /* PortalWebVitals.m */,
83
98
  A71289F927F79EB200DADDF3 /* PortalManager.m */,
84
99
  A71289F827F79D4000DADDF3 /* PortalsPubSub.m */,
85
100
  F4FF95D5245B92E700C19C63 /* ReactNativePortals-Bridging-Header.h */,
@@ -205,12 +220,17 @@
205
220
  buildActionMask = 2147483647;
206
221
  files = (
207
222
  A7128A0A27F7A16200DADDF3 /* PortalView.m in Sources */,
223
+ A71E307429D5FF650073D47A /* PortalWebVitals.m in Sources */,
208
224
  A7128A0927F7A16200DADDF3 /* PortalsPubSub.m in Sources */,
209
225
  A795AE1D28EDEC7A0092B4B1 /* PortalView.swift in Sources */,
226
+ A71E306E29D4C8710073D47A /* AssetMap+Dict.swift in Sources */,
227
+ A71E306C29D392DF0073D47A /* SyncResult+Dict.swift in Sources */,
228
+ A71E307229D5FC450073D47A /* WebVitals.swift in Sources */,
229
+ A71E307629D771C90073D47A /* ConcurrentDictionary.swift in Sources */,
210
230
  A795AE2128EDED710092B4B1 /* LiveUpdate+Dict.swift in Sources */,
211
231
  A795AE1B28EDEBF20092B4B1 /* PortalsPubSub.swift in Sources */,
212
232
  A7128A0627F7A16200DADDF3 /* PortalsReactNative.swift in Sources */,
213
- A795AE1F28EDED0F0092B4B1 /* Portal+Dict.swift in Sources */,
233
+ A795AE1F28EDED0F0092B4B1 /* Portal.swift in Sources */,
214
234
  A795AE2328EDEDCC0092B4B1 /* LiveUpdateManagerError+Dict.swift in Sources */,
215
235
  A7128A0727F7A16200DADDF3 /* PortalManager.m in Sources */,
216
236
  A795AE1928EDEB6D0092B4B1 /* PortalsConfig.swift in Sources */,
@@ -0,0 +1,35 @@
1
+ //
2
+ // SyncResult+Dict.swift
3
+ // ReactNativePortals
4
+ //
5
+ // Created by Steven Sherry on 3/28/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ import IonicLiveUpdates
10
+
11
+ extension LiveUpdateManager.SyncResult {
12
+ var dict: [String: Any] {
13
+ var base: [String: Any] = [
14
+ "liveUpdate": [
15
+ "appId": liveUpdate.appId,
16
+ "channel": liveUpdate.channel
17
+ ],
18
+ "snapshot": [
19
+ "id": snapshot.id,
20
+ "buildId": snapshot.buildId
21
+ ]
22
+ ]
23
+
24
+ switch source {
25
+ case .cache(let latestAppDirectoryChanged):
26
+ base["source"] = "cache"
27
+ base["activeApplicationPathChanged"] = latestAppDirectoryChanged
28
+ @unknown default:
29
+ base["source"] = "download"
30
+ base["activeApplicationPathChanged"] = true
31
+ }
32
+
33
+ return base
34
+ }
35
+ }
@@ -0,0 +1,35 @@
1
+ //
2
+ // WebVitals.swift
3
+ // ReactNativePortals
4
+ //
5
+ // Created by Steven Sherry on 3/30/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ import IonicPortals
10
+ import React
11
+
12
+ @objc(IONPortalsWebVitals)
13
+ class WebVitals: RCTEventEmitter {
14
+ private let fcp = "vitals:fcp"
15
+
16
+ override func supportedEvents() -> [String] {
17
+ [fcp]
18
+ }
19
+
20
+ @objc func registerOnFirstContentfulPaint(_ portalName: String, resolver: @escaping RCTPromiseResolveBlock, rejector: RCTPromiseRejectBlock) {
21
+ PortalsReactNative.portals[portalName]?.performanceReporter = WebPerformanceReporter { [weak self] _, duration in
22
+ guard let self = self else { return }
23
+ self.sendEvent(
24
+ withName: self.fcp,
25
+ body: [
26
+ "portalName": portalName,
27
+ "duration": duration
28
+ ]
29
+ )
30
+ }
31
+ resolver(())
32
+ }
33
+
34
+ override class func requiresMainQueueSetup() -> Bool { true }
35
+ }
@@ -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;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"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","PortalViewManager","requireNativeComponent","createFragment","viewId","UIManager","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","useRef","useEffect","findNodeHandle","current","createElement","_default","exports"],"sources":["PortalView.android.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\nimport type { PortalProps } from '.';\n\nconst PortalViewManager = requireNativeComponent('AndroidPortalView');\n\nconst createFragment = (viewId: number | null) =>\n UIManager.dispatchViewManagerCommand(\n viewId,\n // we are calling the 'create' command\n // @ts-expect-error\n UIManager.AndroidPortalView.Commands.create.toString(),\n [viewId]\n );\n\nconst PortalView = (props: PortalProps) => {\n const ref = useRef(null);\n\n useEffect(() => {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }, []);\n\n return <PortalViewManager {...props} ref={ref} />;\n};\n\nexport default PortalView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIsB,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA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AV,GAAA,IAAAa,MAAA,QAAAhB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAU,MAAA,EAAAb,GAAA,KAAAS,MAAA,CAAAT,GAAA,IAAAa,MAAA,CAAAb,GAAA,gBAAAS,MAAA,YAAAH,QAAA,CAAAQ,KAAA,OAAAH,SAAA;AAGtB,MAAMI,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,oBAAOtC,MAAA,CAAAW,OAAA,CAAAyC,aAAA,CAACjB,iBAAiB,EAAAT,QAAA,KAAKoB,KAAK;IAAEC,GAAG,EAAEA;EAAI,GAAG;AACnD,CAAC;AAAC,IAAAM,QAAA,GAEaR,UAAU;AAAAS,OAAA,CAAA3C,OAAA,GAAA0C,QAAA"}
@@ -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;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"}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","obj","__esModule","default","HostComponentPortal","requireNativeComponent","PortalView","props","createElement","_default","exports"],"sources":["PortalView.tsx"],"sourcesContent":["import React from 'react';\nimport { requireNativeComponent } from 'react-native';\nimport type { PortalProps } from '.';\n\nconst HostComponentPortal = requireNativeComponent('IONPortalView');\n\nconst PortalView = (props: PortalProps) => {\n return <HostComponentPortal {...props} />;\n};\n\nexport default PortalView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGtD,MAAMG,mBAAmB,GAAG,IAAAC,mCAAsB,EAAC,eAAe,CAAC;AAEnE,MAAMC,UAAU,GAAIC,KAAkB,IAAK;EACzC,oBAAOV,MAAA,CAAAM,OAAA,CAAAK,aAAA,CAACJ,mBAAmB,EAAKG,KAAK,CAAI;AAC3C,CAAC;AAAC,IAAAE,QAAA,GAEaH,UAAU;AAAAI,OAAA,CAAAP,OAAA,GAAAM,QAAA"}
@@ -9,14 +9,19 @@ Object.defineProperty(exports, "PortalView", {
9
9
  return _PortalView.default;
10
10
  }
11
11
  });
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;
12
+ exports.unsubscribe = exports.syncSome = exports.syncOne = exports.syncAll = exports.subscribe = exports.registerWebVitals = exports.register = exports.publish = exports.onTimeToFirstByte = exports.onFirstInputDelay = exports.onFirstContentfulPaint = exports.getPortal = exports.enableSecureLiveUpdates = exports.addPortals = exports.addPortal = void 0;
13
13
  var _reactNative = require("react-native");
14
14
  var _PortalView = _interopRequireDefault(require("./PortalView"));
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  const {
17
17
  IONPortalPubSub,
18
- IONPortalsReactNative
18
+ IONPortalsReactNative,
19
+ IONPortalsWebVitals
19
20
  } = _reactNative.NativeModules;
21
+ /**
22
+ * The data that is received from a subscription event.
23
+ */
24
+
20
25
  const PortalsPubSub = new _reactNative.NativeEventEmitter(IONPortalPubSub);
21
26
  const subscriptionMap = new Map();
22
27
 
@@ -37,6 +42,48 @@ const subscribe = async (topic, onMessageReceived) => {
37
42
  subscriptionMap.set(subscriptionRef, subscriber);
38
43
  return subscriptionRef;
39
44
  };
45
+ exports.subscribe = subscribe;
46
+ const webVitalsMap = new Map();
47
+ const WebVitals = new _reactNative.NativeEventEmitter(IONPortalsWebVitals);
48
+ const onFirstContentfulPaint = async (portalName, callback) => {
49
+ const listener = WebVitals.addListener('vitals:fcp', event => {
50
+ if (event.portalName === portalName) {
51
+ callback(event.duration);
52
+ }
53
+ });
54
+ await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);
55
+ webVitalsMap.set(`${portalName}-vitals:fcp`, listener);
56
+ };
57
+ exports.onFirstContentfulPaint = onFirstContentfulPaint;
58
+ const onFirstInputDelay = async (portalName, callback) => {
59
+ if (_reactNative.Platform.OS === 'android') {
60
+ const listener = WebVitals.addListener('vitals:fid', event => {
61
+ if (event.portalName === portalName) {
62
+ callback(event.duration);
63
+ }
64
+ });
65
+ await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);
66
+ webVitalsMap.set(`${portalName}-vitals:fcp`, listener);
67
+ }
68
+ };
69
+ exports.onFirstInputDelay = onFirstInputDelay;
70
+ const onTimeToFirstByte = async (portalName, callback) => {
71
+ if (_reactNative.Platform.OS === 'android') {
72
+ const listener = WebVitals.addListener('vitals:ttfb', event => {
73
+ if (event.portalName === portalName) {
74
+ callback(event.duration);
75
+ }
76
+ });
77
+ await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);
78
+ webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);
79
+ }
80
+ };
81
+ exports.onTimeToFirstByte = onTimeToFirstByte;
82
+ const registerWebVitals = async (portalName, firstContentfulPaint, firstInputDelay, timeToFirstByte) => {
83
+ onFirstContentfulPaint(portalName, firstContentfulPaint);
84
+ onFirstInputDelay(portalName, firstInputDelay);
85
+ onTimeToFirstByte(portalName, timeToFirstByte);
86
+ };
40
87
 
41
88
  /**
42
89
  * Unsubscribes from events for the provided topic and subscription reference
@@ -44,7 +91,7 @@ const subscribe = async (topic, onMessageReceived) => {
44
91
  * @param topic The topic to unsubscribe from
45
92
  * @param subRef The unique subscription reference received when initially calling {@link subscribe}
46
93
  */
47
- exports.subscribe = subscribe;
94
+ exports.registerWebVitals = registerWebVitals;
48
95
  const unsubscribe = (topic, subRef) => {
49
96
  IONPortalPubSub.unsubscribe(topic, subRef);
50
97
  const subscription = subscriptionMap.get(subRef);
@@ -81,6 +128,15 @@ const register = async key => {
81
128
  /**
82
129
  * The configuration of a web application to be embedded in a React Native application.
83
130
  */
131
+
132
+ /**
133
+ * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override
134
+ * any initialContext defined in the original {@link Portal} definition.
135
+ */
136
+
137
+ /**
138
+ * Props needed for rendering a {@link Portal}
139
+ */
84
140
  exports.register = register;
85
141
  /**
86
142
  * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.
@@ -113,6 +169,10 @@ exports.addPortals = addPortals;
113
169
  const getPortal = async name => {
114
170
  return IONPortalsReactNative.getPortal(name);
115
171
  };
172
+
173
+ /** Data needed to register a live update to be managed */
174
+
175
+ /** Used for communicating sync results of multiple live updates */
116
176
  exports.getPortal = getPortal;
117
177
  /**
118
178
  * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.
@@ -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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{"version":3,"names":["_reactNative","require","_PortalView","_interopRequireDefault","obj","__esModule","default","IONPortalPubSub","IONPortalsReactNative","IONPortalsWebVitals","NativeModules","PortalsPubSub","NativeEventEmitter","subscriptionMap","Map","subscribe","topic","onMessageReceived","subscriptionRef","subscriber","addListener","message","set","exports","webVitalsMap","WebVitals","onFirstContentfulPaint","portalName","callback","listener","event","duration","registerOnFirstContentfulPaint","onFirstInputDelay","Platform","OS","registerOnFirstInputDelay","onTimeToFirstByte","registerOnTimeToFirstByte","registerWebVitals","firstContentfulPaint","firstInputDelay","timeToFirstByte","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 Platform,\n ViewProps,\n} from 'react-native';\n\nconst { IONPortalPubSub, IONPortalsReactNative, IONPortalsWebVitals } =\n NativeModules;\n\nexport { default as PortalView } from './PortalView';\n\n/**\n * The data that is received from a subscription event.\n */\nexport interface Message {\n /** The unique subscription reference received from {@link subscribe}*/\n subscriptionRef: number;\n data: any;\n /** The topic the message was sent from */\n topic: string;\n}\n\nconst PortalsPubSub = new NativeEventEmitter(IONPortalPubSub);\n\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\nconst webVitalsMap = new Map<string, EmitterSubscription>();\nconst WebVitals = new NativeEventEmitter(IONPortalsWebVitals);\n\ninterface WebVitalsEvent {\n portalName: string;\n duration: number;\n}\n\nexport const onFirstContentfulPaint = async (\n portalName: string,\n callback: (duration: number) => void\n): Promise<void> => {\n const listener = WebVitals.addListener(\n 'vitals:fcp',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstContentfulPaint(portalName);\n\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n};\n\nexport const onFirstInputDelay = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:fid',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnFirstInputDelay(portalName);\n\n webVitalsMap.set(`${portalName}-vitals:fcp`, listener);\n }\n};\n\nexport const onTimeToFirstByte = async (\n portalName: string,\n callback: (duration: number) => void\n) => {\n if (Platform.OS === 'android') {\n const listener = WebVitals.addListener(\n 'vitals:ttfb',\n (event: WebVitalsEvent) => {\n if (event.portalName === portalName) {\n callback(event.duration);\n }\n }\n );\n\n await IONPortalsWebVitals.registerOnTimeToFirstByte(portalName);\n\n webVitalsMap.set(`${portalName}-vitals:ttfb`, listener);\n }\n};\n\nexport const registerWebVitals = async (\n portalName: string,\n firstContentfulPaint: (duration: number) => void,\n firstInputDelay: (duration: number) => void,\n timeToFirstByte: (duration: number) => void\n) => {\n onFirstContentfulPaint(portalName, firstContentfulPaint);\n onFirstInputDelay(portalName, firstInputDelay);\n onTimeToFirstByte(portalName, timeToFirstByte);\n};\n\n/**\n * 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 /** Any Capacitor plugins to be made available to the Portal */\n plugins?: CapacitorPlugin[];\n /**\n * The root directory of the web application relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, `name` is used.\n */\n startDir?: string;\n /** The name of the initial file to load. If omitted, 'index.html' is used. */\n index?: string;\n /** Any data needed at initial render when a portal is loaded. */\n initialContext?: {\n [key: string]: any;\n };\n assetMaps?: AssetMap[];\n liveUpdate?: LiveUpdateConfig;\n}\n\nexport interface CapacitorPlugin {\n /** The classpath of the plugin to be used in Android. (e.g. com.capacitorjs.plugins.camera.CameraPlugin) */\n androidClassPath: string;\n /** The class name of the plugin to be used in iOS.\n * This must be the name as it is exposed to the Objective-C runtime.\n * For example, The CameraPlugin swift class is exposed to Objective-C as CAPCameraPlugin.\n */\n iosClassName: string;\n}\n\nexport interface AssetMap {\n /** The name to index the asset map by */\n name: string;\n /** Any path to match via the web. If omitted, {@link AssetMap#name} will be used. */\n virtualPath?: string;\n /** The root directory of the assets relative to Bundle.main on iOS\n * and src/main/assets on Android. If omitted, the root of Bundle.main\n * and src/main/assets will be used.\n */\n startDir?: string;\n}\n\n/**\n * A subset of {@link Portal} properties needed for rendering a Portal. `initialContext` can be used to override\n * any initialContext defined in the original {@link Portal} definition.\n */\nexport type PortalProp = {\n portal: Pick<Portal, 'name' | 'initialContext'>;\n};\n\n/**\n * Props needed for rendering a {@link Portal}\n */\nexport type PortalProps = PortalProp & ViewProps;\n\n/**\n * Adds a Portal to an internal registry. Must be called before attempting to render a {@link PortalView}.\n *\n * @param portal The portal to add to the internal registry.\n * @returns Promise containing the Portal that was added to the registry.\n */\nexport const addPortal = async (portal: Portal): Promise<Portal> => {\n return IONPortalsReactNative.addPortal(portal);\n};\n\n/**\n * Adds all portals to an internal registry. This or {@link addPortal} must be called before attempting to render a {@link PortalView}\n *\n * @param portals The portals to add to the internal registry.\n * @returns Promise containing the Portals that were added to the registry.\n */\nexport const addPortals = async (portals: Portal[]): Promise<Portal[]> => {\n return IONPortalsReactNative.addPortals(portals);\n};\n\n/**\n * Gets a {@link Portal} previously registered via {@link addPortal} or {@link addPortals}.\n *\n * @param name The portal name to retrieve from the internal registry.\n * @returns Promise containing the registered {@link Portal}. If the {@link Portal} was not registered, the Promise will fail.\n */\nexport const getPortal = async (name: string): Promise<Portal> => {\n return IONPortalsReactNative.getPortal(name);\n};\n\nexport interface LiveUpdate {\n /** The AppFlow application ID */\n appId: string;\n /** The AppFlow distribution channel */\n channel: string;\n}\n\n/** Data needed to register a live update to be managed */\nexport type LiveUpdateConfig = LiveUpdate & { syncOnAdd: boolean };\n\nexport interface LiveUpdateError {\n /** The AppFlow application ID relating to the failure */\n appId: string;\n /** The step in the sync process the LiveUpdate failed on. (e.g. CHECK, UNPACK)*/\n failStep: string;\n /** A human readable error message */\n message: string;\n}\n\nexport interface Snapshot {\n /** The snapshot id as found in AppFlow */\n id: string;\n /** The AppFlow build id that produced the snapshot */\n buildId: string;\n}\n\nexport interface SyncResult {\n /** The {@link LiveUpdate} associated with the result */\n liveUpdate: LiveUpdate;\n /** The {@link Snapshot} that was sync'd */\n snapshot: Snapshot | null;\n /** Whether the snapshot was downloaded or already on disk */\n source: 'download' | 'cache';\n /** If the active application path was changed. A `false` value would indicate\n * the application already has the latest code for the associated {@link LiveUpdate}\n * configuration.\n */\n activeApplicationPathChanged: boolean;\n}\n\n/** Used for communicating sync results of multiple live updates */\nexport interface SyncResults {\n results: SyncResult[];\n errors: LiveUpdateError[];\n}\n\n/**\n * Configures LiveUpdates to cyrptographically verify the contents of the downloaded bundles.\n * This method must be called before any LiveUpdates are registered otherwise they will no longer be tracked.\n *\n * @param pathToKey The *relative* path to the public key for verification.\n * This path should be the same relatibe to the main application bundle on iOS and the assets directory on Android.\n * @returns Promise<void>\n */\nexport const enableSecureLiveUpdates = async (\n pathToKey: string\n): Promise<void> => {\n return IONPortalsReactNative.enableSecureLiveUpdates(pathToKey);\n};\n\n/**\n * Syncs a single live update.\n *\n * @param appId The AppFlow application ID to sync.\n * @returns A Promise<LiveUpdate>. A failure should result in a {@link LiveUpdateError}.\n */\nexport const syncOne = async (appId: string): Promise<SyncResult> => {\n return IONPortalsReactNative.syncOne(appId);\n};\n\n/**\n * Syncs many live updates.\n *\n * @param appIds The AppFlow application IDs to sync.\n * @returns Promise<SyncResults>\n */\nexport const syncSome = async (appIds: string[]): Promise<SyncResults> => {\n return IONPortalsReactNative.syncSome(appIds);\n};\n\n/**\n * Syncs all registered LiveUpdates\n * @returns Promise<SyncResults>\n */\nexport const syncAll = async (): Promise<SyncResults> => {\n return IONPortalsReactNative.syncAll();\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAqD,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAHrD,MAAM;EAAEG,eAAe;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GACnEC,0BAAa;AAIf;AACA;AACA;;AASA,MAAMC,aAAa,GAAG,IAAIC,+BAAkB,CAACL,eAAe,CAAC;AAE7D,MAAMM,eAAe,GAAG,IAAIC,GAAG,EAA+B;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AAY,IAAsB;EAChE,OAAOpD,qBAAqB,CAACmD,SAAS,CAACC,IAAI,CAAC;AAC9C,CAAC;;AASD;;AAiCA;AAAArC,OAAA,CAAAoC,SAAA,GAAAA,SAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAG,MACrCC,SAAiB,IACC;EAClB,OAAOtD,qBAAqB,CAACqD,uBAAuB,CAACC,SAAS,CAAC;AACjE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAvC,OAAA,CAAAsC,uBAAA,GAAAA,uBAAA;AAMO,MAAME,OAAO,GAAG,MAAOC,KAAa,IAA0B;EACnE,OAAOxD,qBAAqB,CAACuD,OAAO,CAACC,KAAK,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAzC,OAAA,CAAAwC,OAAA,GAAAA,OAAA;AAMO,MAAME,QAAQ,GAAG,MAAOC,MAAgB,IAA2B;EACxE,OAAO1D,qBAAqB,CAACyD,QAAQ,CAACC,MAAM,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AAHA3C,OAAA,CAAA0C,QAAA,GAAAA,QAAA;AAIO,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAkC;EACvD,OAAO3D,qBAAqB,CAAC2D,OAAO,EAAE;AACxC,CAAC;AAAC5C,OAAA,CAAA4C,OAAA,GAAAA,OAAA"}
@@ -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,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
+ {"version":3,"names":["React","useEffect","useRef","findNodeHandle","requireNativeComponent","UIManager","PortalViewManager","createFragment","viewId","dispatchViewManagerCommand","AndroidPortalView","Commands","create","toString","PortalView","props","ref","current","createElement","_extends"],"sources":["PortalView.android.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\nimport type { PortalProps } from '.';\n\nconst PortalViewManager = requireNativeComponent('AndroidPortalView');\n\nconst createFragment = (viewId: number | null) =>\n UIManager.dispatchViewManagerCommand(\n viewId,\n // we are calling the 'create' command\n // @ts-expect-error\n UIManager.AndroidPortalView.Commands.create.toString(),\n [viewId]\n );\n\nconst PortalView = (props: PortalProps) => {\n const ref = useRef(null);\n\n useEffect(() => {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }, []);\n\n return <PortalViewManager {...props} ref={ref} />;\n};\n\nexport default PortalView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SACEC,cAAc,EACdC,sBAAsB,EACtBC,SAAS,QACJ,cAAc;AAGrB,MAAMC,iBAAiB,GAAGF,sBAAsB,CAAC,mBAAmB,CAAC;AAErE,MAAMG,cAAc,GAAIC,MAAqB,IAC3CH,SAAS,CAACI,0BAA0B,CAClCD,MAAM;AACN;AACA;AACAH,SAAS,CAACK,iBAAiB,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,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,oBAAOR,KAAA,CAAAkB,aAAA,CAACZ,iBAAiB,EAAAa,QAAA,KAAKJ,KAAK;IAAEC,GAAG,EAAEA;EAAI,GAAG;AACnD,CAAC;AAED,eAAeF,UAAU"}