@ionic/portals-react-native 0.2.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.
- package/README.md +2 -2
- package/ReactNativePortals.podspec +14 -14
- package/android/build.gradle +4 -5
- package/android/gradle.properties +1 -1
- package/android/src/main/java/io/ionic/portals/reactnative/PortalView.kt +14 -4
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativeLiveUpdatesModule.kt +57 -74
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalManager.kt +84 -21
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalsModule.kt +19 -22
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativePortalsPackage.kt +1 -0
- package/android/src/main/java/io/ionic/portals/reactnative/ReactNativeWebVitalsModule.kt +52 -0
- package/ios/AssetMap+Dict.swift +28 -0
- package/ios/ConcurrentDictionary.swift +45 -0
- package/ios/LiveUpdateManager+Async.swift +7 -7
- package/ios/Podfile +3 -4
- package/ios/Podfile.lock +13 -13
- package/ios/Portal.swift +108 -0
- package/ios/PortalManager.m +1 -1
- package/ios/PortalView.swift +1 -1
- package/ios/PortalWebVitals.m +15 -0
- package/ios/PortalsConfig.swift +18 -7
- package/ios/PortalsPubSub.swift +1 -0
- package/ios/PortalsReactNative.swift +1 -1
- package/ios/ReactNativePortals.xcodeproj/project.pbxproj +24 -4
- package/ios/SyncResult+Dict.swift +35 -0
- package/ios/WebVitals.swift +35 -0
- package/lib/commonjs/PortalView.android.js.map +1 -1
- package/lib/commonjs/PortalView.js.map +1 -1
- package/lib/commonjs/index.js +63 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/PortalView.android.js.map +1 -1
- package/lib/module/PortalView.js.map +1 -1
- package/lib/module/index.js +55 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +51 -7
- package/package.json +1 -1
- package/src/index.ts +128 -5
- package/ios/Portal+Dict.swift +0 -35
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
import IonicLiveUpdates
|
|
10
10
|
|
|
11
11
|
struct SyncResults {
|
|
12
|
-
var
|
|
12
|
+
var results: [LiveUpdateManager.SyncResult]
|
|
13
13
|
var errors: [LiveUpdateManager.Error]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
extension SyncResults {
|
|
17
17
|
var dict: [String: Any] {
|
|
18
18
|
return [
|
|
19
|
-
"
|
|
19
|
+
"results": results.map(\.dict),
|
|
20
20
|
"errors": errors.map(\.dict)
|
|
21
21
|
]
|
|
22
22
|
}
|
|
@@ -27,7 +27,7 @@ extension LiveUpdateManager {
|
|
|
27
27
|
await _syncSome(appIds).syncResults
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
private func _syncSome(_ appIds: [String]) -> AsyncStream<Result<
|
|
30
|
+
private func _syncSome(_ appIds: [String]) -> AsyncStream<Result<LiveUpdateManager.SyncResult, LiveUpdateManager.Error>> {
|
|
31
31
|
AsyncStream { continuation in
|
|
32
32
|
sync(appIds: appIds, isParallel: true) {
|
|
33
33
|
continuation.finish()
|
|
@@ -42,7 +42,7 @@ extension LiveUpdateManager {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
private func _syncAll() -> AsyncStream<Result<
|
|
45
|
+
private func _syncAll() -> AsyncStream<Result<LiveUpdateManager.SyncResult, LiveUpdateManager.Error>> {
|
|
46
46
|
AsyncStream { continuation in
|
|
47
47
|
sync(isParallel: true) {
|
|
48
48
|
continuation.finish()
|
|
@@ -53,13 +53,13 @@ extension LiveUpdateManager {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
extension AsyncStream where Element == Result<
|
|
56
|
+
extension AsyncStream where Element == Result<LiveUpdateManager.SyncResult, LiveUpdateManager.Error> {
|
|
57
57
|
var syncResults: SyncResults {
|
|
58
58
|
get async {
|
|
59
|
-
await reduce(into: SyncResults(
|
|
59
|
+
await reduce(into: SyncResults(results: [], errors: [])) { acc, next in
|
|
60
60
|
switch next {
|
|
61
61
|
case .success(let liveUpdate):
|
|
62
|
-
acc.
|
|
62
|
+
acc.results.append(liveUpdate)
|
|
63
63
|
case .failure(let error):
|
|
64
64
|
acc.errors.append(error)
|
|
65
65
|
}
|
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!(:
|
|
10
|
+
use_react_native!(path: config['reactNativePath'])
|
|
11
11
|
# Pods for ReactNativePortals
|
|
12
|
-
pod 'IonicPortals', '~> 0.
|
|
13
|
-
pod 'IonicLiveUpdates', '~> 0.
|
|
12
|
+
pod 'IonicPortals', '~> 0.7.3'
|
|
13
|
+
pod 'IonicLiveUpdates', '~> 0.4.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
|
+
- Capacitor (4.7.0):
|
|
4
4
|
- CapacitorCordova
|
|
5
|
-
- CapacitorCordova (
|
|
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.
|
|
26
|
-
- IonicPortals (0.
|
|
27
|
-
- Capacitor (~>
|
|
28
|
-
- IonicLiveUpdates (< 0.
|
|
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.
|
|
264
|
-
- IonicPortals (~> 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:
|
|
354
|
-
CapacitorCordova:
|
|
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:
|
|
361
|
-
IonicPortals:
|
|
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:
|
|
384
|
+
PODFILE CHECKSUM: 685fb93c81db77a563a8c1ba6999dc27b98a8d33
|
|
385
385
|
|
|
386
386
|
COCOAPODS: 1.11.2
|
package/ios/Portal.swift
ADDED
|
@@ -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
|
+
}
|
package/ios/PortalManager.m
CHANGED
|
@@ -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
|
package/ios/PortalView.swift
CHANGED
|
@@ -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
|
+
|
package/ios/PortalsConfig.swift
CHANGED
|
@@ -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) ->
|
|
27
|
+
func portal(with liveUpdateManager: LiveUpdateManager) -> ReactNativePortals.Portal {
|
|
26
28
|
return .init(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
}
|
package/ios/PortalsPubSub.swift
CHANGED
|
@@ -6,7 +6,7 @@ import React
|
|
|
6
6
|
@objc(IONPortalsReactNative)
|
|
7
7
|
public class PortalsReactNative: NSObject {
|
|
8
8
|
private var lum: LiveUpdateManager
|
|
9
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAAA,SAAAW,SAAA,IAAAA,QAAA,GAAAT,MAAA,CAAAU,MAAA,GAAAV,MAAA,CAAAU,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAV,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,
|
|
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"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -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.
|
|
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.
|