@upscopeio/react-native-sdk 2026.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +291 -0
  2. package/android/build.gradle.kts +36 -0
  3. package/android/src/main/AndroidManifest.xml +2 -0
  4. package/android/src/main/kotlin/io/upscope/reactnative/UpscopeMaskedViewManager.kt +31 -0
  5. package/android/src/main/kotlin/io/upscope/reactnative/UpscopeModule.kt +297 -0
  6. package/android/src/main/kotlin/io/upscope/reactnative/UpscopePackage.kt +31 -0
  7. package/ios/UpscopeMaskedView.swift +18 -0
  8. package/ios/UpscopeMaskedViewManager.mm +4 -0
  9. package/ios/UpscopeMaskedViewManager.swift +13 -0
  10. package/ios/UpscopeModule.mm +31 -0
  11. package/ios/UpscopeModule.swift +243 -0
  12. package/lib/commonjs/NativeUpscopeMaskedView.js +10 -0
  13. package/lib/commonjs/NativeUpscopeMaskedView.js.map +1 -0
  14. package/lib/commonjs/NativeUpscopeModule.js +9 -0
  15. package/lib/commonjs/NativeUpscopeModule.js.map +1 -0
  16. package/lib/commonjs/Upscope.js +95 -0
  17. package/lib/commonjs/Upscope.js.map +1 -0
  18. package/lib/commonjs/UpscopeMasked.js +22 -0
  19. package/lib/commonjs/UpscopeMasked.js.map +1 -0
  20. package/lib/commonjs/hooks.js +98 -0
  21. package/lib/commonjs/hooks.js.map +1 -0
  22. package/lib/commonjs/index.js +58 -0
  23. package/lib/commonjs/index.js.map +1 -0
  24. package/lib/commonjs/package.json +1 -0
  25. package/lib/commonjs/types.js +2 -0
  26. package/lib/commonjs/types.js.map +1 -0
  27. package/lib/module/NativeUpscopeMaskedView.js +5 -0
  28. package/lib/module/NativeUpscopeMaskedView.js.map +1 -0
  29. package/lib/module/NativeUpscopeModule.js +5 -0
  30. package/lib/module/NativeUpscopeModule.js.map +1 -0
  31. package/lib/module/Upscope.js +91 -0
  32. package/lib/module/Upscope.js.map +1 -0
  33. package/lib/module/UpscopeMasked.js +17 -0
  34. package/lib/module/UpscopeMasked.js.map +1 -0
  35. package/lib/module/hooks.js +89 -0
  36. package/lib/module/hooks.js.map +1 -0
  37. package/lib/module/index.js +7 -0
  38. package/lib/module/index.js.map +1 -0
  39. package/lib/module/package.json +1 -0
  40. package/lib/module/types.js +2 -0
  41. package/lib/module/types.js.map +1 -0
  42. package/lib/typescript/NativeUpscopeMaskedView.d.ts +7 -0
  43. package/lib/typescript/NativeUpscopeMaskedView.d.ts.map +1 -0
  44. package/lib/typescript/NativeUpscopeModule.d.ts +20 -0
  45. package/lib/typescript/NativeUpscopeModule.d.ts.map +1 -0
  46. package/lib/typescript/Upscope.d.ts +60 -0
  47. package/lib/typescript/Upscope.d.ts.map +1 -0
  48. package/lib/typescript/UpscopeMasked.d.ts +7 -0
  49. package/lib/typescript/UpscopeMasked.d.ts.map +1 -0
  50. package/lib/typescript/hooks.d.ts +36 -0
  51. package/lib/typescript/hooks.d.ts.map +1 -0
  52. package/lib/typescript/index.d.ts +8 -0
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/lib/typescript/types.d.ts +79 -0
  55. package/lib/typescript/types.d.ts.map +1 -0
  56. package/package.json +94 -0
  57. package/src/NativeUpscopeMaskedView.ts +9 -0
  58. package/src/NativeUpscopeModule.ts +32 -0
  59. package/src/Upscope.ts +113 -0
  60. package/src/UpscopeMasked.tsx +19 -0
  61. package/src/hooks.ts +99 -0
  62. package/src/index.ts +34 -0
  63. package/src/types.ts +109 -0
  64. package/upscopeio-react-native-sdk.podspec +17 -0
@@ -0,0 +1,18 @@
1
+ import UIKit
2
+ import UpscopeSDK
3
+
4
+ class UpscopeMaskedView: UIView {
5
+
6
+ override func didMoveToWindow() {
7
+ super.didMoveToWindow()
8
+ if window != nil {
9
+ Task { @MainActor in
10
+ Upscope.shared.addMaskedView(self)
11
+ }
12
+ } else {
13
+ Task { @MainActor in
14
+ Upscope.shared.removeMaskedView(self)
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,4 @@
1
+ #import <React/RCTViewManager.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(UpscopeMaskedViewManager, RCTViewManager)
4
+ @end
@@ -0,0 +1,13 @@
1
+ import React
2
+
3
+ @objc(UpscopeMaskedViewManager)
4
+ class UpscopeMaskedViewManager: RCTViewManager {
5
+
6
+ override static func requiresMainQueueSetup() -> Bool {
7
+ return true
8
+ }
9
+
10
+ override func view() -> UIView {
11
+ return UpscopeMaskedView()
12
+ }
13
+ }
@@ -0,0 +1,31 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+ #import <ReactCommon/RCTTurboModule.h>
4
+ #import <UpscopeSpec/UpscopeSpec.h>
5
+
6
+ @interface RCT_EXTERN_MODULE(UpscopeModule, RCTEventEmitter)
7
+
8
+ RCT_EXTERN_METHOD(initialize:(NSDictionary *)config)
9
+ RCT_EXTERN_METHOD(connect)
10
+ RCT_EXTERN_METHOD(disconnect)
11
+ RCT_EXTERN_METHOD(reset:(BOOL)reconnect)
12
+ RCT_EXTERN_METHOD(updateConnection:(NSDictionary *)params)
13
+ RCT_EXTERN_METHOD(stopSession)
14
+ RCT_EXTERN_METHOD(requestAgent)
15
+ RCT_EXTERN_METHOD(cancelAgentRequest)
16
+ RCT_EXTERN_METHOD(getLookupCode)
17
+ RCT_EXTERN_METHOD(getShortId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
18
+ RCT_EXTERN_METHOD(getWatchLink:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
19
+ RCT_EXTERN_METHOD(sendCustomMessage:(NSString *)message)
20
+
21
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
22
+ return std::make_shared<facebook::react::NativeUpscopeModuleSpecJSI>(params);
23
+ }
24
+
25
+ @end
26
+
27
+ @interface UpscopeModule (TurboModule) <RCTTurboModule>
28
+ @end
29
+
30
+ @implementation UpscopeModule (TurboModule)
31
+ @end
@@ -0,0 +1,243 @@
1
+ import Foundation
2
+ import React
3
+ import UpscopeSDK
4
+
5
+ @objc(UpscopeModule)
6
+ class UpscopeModule: RCTEventEmitter, UpscopeDelegate {
7
+
8
+ private var hasListeners = false
9
+
10
+ override init() {
11
+ super.init()
12
+ }
13
+
14
+ @objc override static func requiresMainQueueSetup() -> Bool {
15
+ return true
16
+ }
17
+
18
+ override func supportedEvents() -> [String] {
19
+ return [
20
+ "connectionStateChanged",
21
+ "sessionStarted",
22
+ "sessionEnded",
23
+ "customMessageReceived",
24
+ "error",
25
+ "observerJoined",
26
+ "observerLeft",
27
+ "observerCountChanged",
28
+ "shortIdChanged",
29
+ "lookupCodeChanged",
30
+ ]
31
+ }
32
+
33
+ override func startObserving() {
34
+ hasListeners = true
35
+ Task { @MainActor in
36
+ for await shortId in Upscope.shared.shortIdPublisher.values {
37
+ guard self.hasListeners else { break }
38
+ self.sendEvent(withName: "shortIdChanged", body: ["shortId": shortId as Any])
39
+ }
40
+ }
41
+ Task { @MainActor in
42
+ for await code in Upscope.shared.lookupCodePublisher.values {
43
+ guard self.hasListeners else { break }
44
+ self.sendEvent(withName: "lookupCodeChanged", body: ["lookupCode": code as Any])
45
+ }
46
+ }
47
+ }
48
+
49
+ override func stopObserving() {
50
+ hasListeners = false
51
+ }
52
+
53
+ // MARK: - Initialization
54
+
55
+ @objc func initialize(_ config: NSDictionary) {
56
+ guard let apiKey = config["apiKey"] as? String else { return }
57
+
58
+ let upscopeConfig = UpscopeConfiguration(
59
+ apiKey: apiKey,
60
+ requireAuthorizationForSession: config["requireAuthorizationForSession"] as? Bool ?? true,
61
+ autoconnect: config["autoConnect"] as? Bool ?? true,
62
+ region: config["region"] as? String,
63
+ showTerminateButton: config["showTerminateButton"] as? Bool ?? true,
64
+ authorizationPromptTitle: config["authorizationPromptTitle"] as? String ?? "Screen Sharing Request",
65
+ authorizationPromptMessage: config["authorizationPromptMessage"] as? String ?? "An agent wants to view your screen. Do you accept?",
66
+ endOfSessionMessage: config["endOfSessionMessage"] as? String,
67
+ stopSessionText: config["stopSessionText"] as? String ?? "Stop Sharing",
68
+ allowRemoteClick: config["allowRemoteClick"] as? Bool,
69
+ allowRemoteScroll: config["allowRemoteScroll"] as? Bool,
70
+ requireControlRequest: config["requireControlRequest"] as? Bool,
71
+ wrapper: "react-native"
72
+ )
73
+
74
+ Task { @MainActor in
75
+ try Upscope.shared.initialize(with: upscopeConfig)
76
+ Upscope.shared.delegate = self
77
+ }
78
+ }
79
+
80
+ // MARK: - Connection
81
+
82
+ @objc func connect() {
83
+ Task { @MainActor in Upscope.shared.connect() }
84
+ }
85
+
86
+ @objc func disconnect() {
87
+ Task { @MainActor in Upscope.shared.disconnect() }
88
+ }
89
+
90
+ @objc func reset(_ reconnect: Bool) {
91
+ Task { @MainActor in Upscope.shared.reset(reconnect: reconnect) }
92
+ }
93
+
94
+ @objc func updateConnection(_ params: NSDictionary) {
95
+ Task { @MainActor in
96
+ Upscope.shared.updateConnection(
97
+ uniqueId: params["uniqueId"] as? String,
98
+ callName: params["callName"] as? String,
99
+ tags: params["tags"] as? [String],
100
+ identities: params["identities"] as? [String],
101
+ metadata: params["metadata"] as? [String: String]
102
+ )
103
+ }
104
+ }
105
+
106
+ // MARK: - Session
107
+
108
+ @objc func stopSession() {
109
+ Task { @MainActor in Upscope.shared.stopSession() }
110
+ }
111
+
112
+ @objc func requestAgent() {
113
+ Task { @MainActor in Upscope.shared.requestAgent() }
114
+ }
115
+
116
+ @objc func cancelAgentRequest() {
117
+ Task { @MainActor in Upscope.shared.cancelAgentRequest() }
118
+ }
119
+
120
+ // MARK: - Lookup
121
+
122
+ @objc func getLookupCode() {
123
+ Task { @MainActor in Upscope.shared.getLookupCode() }
124
+ }
125
+
126
+ @objc func getShortId(_ resolve: @escaping RCTPromiseResolveBlock,
127
+ reject: @escaping RCTPromiseRejectBlock) {
128
+ Task { @MainActor in
129
+ resolve(Upscope.shared.shortId)
130
+ }
131
+ }
132
+
133
+ @objc func getWatchLink(_ resolve: @escaping RCTPromiseResolveBlock,
134
+ reject: @escaping RCTPromiseRejectBlock) {
135
+ Task { @MainActor in
136
+ resolve(Upscope.shared.watchLink)
137
+ }
138
+ }
139
+
140
+ // MARK: - Messaging
141
+
142
+ @objc func sendCustomMessage(_ message: String) {
143
+ Task { @MainActor in Upscope.shared.sendCustomMessage(message) }
144
+ }
145
+
146
+ // MARK: - UpscopeDelegate
147
+
148
+ @MainActor
149
+ func upscope(_ upscope: Upscope, didChangeConnectionState state: ConnectionState) {
150
+ guard hasListeners else { return }
151
+ var body: [String: Any] = ["state": serializeConnectionState(state)]
152
+ if case let .error(error) = state {
153
+ body["error"] = serializeError(error)
154
+ }
155
+ sendEvent(withName: "connectionStateChanged", body: body)
156
+ }
157
+
158
+ @MainActor
159
+ func upscopeSessionDidStart(_ upscope: Upscope, agentName: String?) {
160
+ guard hasListeners else { return }
161
+ sendEvent(withName: "sessionStarted", body: ["agentName": agentName as Any])
162
+ }
163
+
164
+ @MainActor
165
+ func upscopeSessionDidEnd(_ upscope: Upscope, reason: SessionEndReason) {
166
+ guard hasListeners else { return }
167
+ var body: [String: Any] = ["reason": serializeEndReason(reason)]
168
+ if case let .error(error) = reason {
169
+ body["error"] = serializeError(error)
170
+ }
171
+ sendEvent(withName: "sessionEnded", body: body)
172
+ }
173
+
174
+ @MainActor
175
+ func upscope(_ upscope: Upscope, didReceiveCustomMessage message: String, from observerId: String) {
176
+ guard hasListeners else { return }
177
+ sendEvent(withName: "customMessageReceived", body: [
178
+ "message": message,
179
+ "observerId": observerId,
180
+ ])
181
+ }
182
+
183
+ @MainActor
184
+ func upscope(_ upscope: Upscope, didEncounterError error: UpscopeError) {
185
+ guard hasListeners else { return }
186
+ sendEvent(withName: "error", body: serializeError(error))
187
+ }
188
+
189
+ @MainActor
190
+ func upscope(_ upscope: Upscope, observerDidJoin observer: Observer) {
191
+ guard hasListeners else { return }
192
+ sendEvent(withName: "observerJoined", body: serializeObserver(observer))
193
+ }
194
+
195
+ @MainActor
196
+ func upscope(_ upscope: Upscope, observerDidLeave observerId: String) {
197
+ guard hasListeners else { return }
198
+ sendEvent(withName: "observerLeft", body: ["observerId": observerId])
199
+ }
200
+
201
+ @MainActor
202
+ func upscope(_ upscope: Upscope, observerCountDidChange count: Int) {
203
+ guard hasListeners else { return }
204
+ sendEvent(withName: "observerCountChanged", body: ["count": count])
205
+ }
206
+
207
+ // MARK: - Serialization
208
+
209
+ private func serializeConnectionState(_ state: ConnectionState) -> String {
210
+ switch state {
211
+ case .inactive: return "inactive"
212
+ case .connecting: return "connecting"
213
+ case .connected: return "connected"
214
+ case .reconnecting: return "reconnecting"
215
+ case .error: return "error"
216
+ }
217
+ }
218
+
219
+ private func serializeEndReason(_ reason: SessionEndReason) -> String {
220
+ switch reason {
221
+ case .userStopped: return "userStopped"
222
+ case .agentStopped: return "agentStopped"
223
+ case .timeout: return "timeout"
224
+ case .error: return "error"
225
+ }
226
+ }
227
+
228
+ private func serializeError(_ error: UpscopeError) -> [String: String] {
229
+ return ["code": error.code, "message": error.message]
230
+ }
231
+
232
+ private func serializeObserver(_ observer: Observer) -> [String: Any] {
233
+ return [
234
+ "id": observer.id,
235
+ "name": observer.name as Any,
236
+ "screenWidth": observer.screenWidth,
237
+ "screenHeight": observer.screenHeight,
238
+ "windowWidth": observer.windowWidth,
239
+ "windowHeight": observer.windowHeight,
240
+ "hasFocus": observer.hasFocus,
241
+ ]
242
+ }
243
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = (0, _codegenNativeComponent.default)("UpscopeMaskedView");
10
+ //# sourceMappingURL=NativeUpscopeMaskedView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeUpscopeMaskedView.ts"],"mappings":";;;;;;AAEA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAI9E,IAAAG,+BAAsB,EACnC,mBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing("UpscopeModule");
9
+ //# sourceMappingURL=NativeUpscopeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUpscopeModule.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA8BpCC,gCAAmB,CAACC,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _NativeUpscopeModule = _interopRequireDefault(require("./NativeUpscopeModule"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Subscription handle returned by addListener. Callers must invoke remove()
12
+ * to avoid memory leaks when the component/scope unmounts.
13
+ */
14
+
15
+ // Module-level emitter — one instance for the lifetime of the JS runtime.
16
+ const emitter = new _reactNative.NativeEventEmitter(_NativeUpscopeModule.default);
17
+
18
+ /**
19
+ * Imperative JS API over the native Upscope TurboModule.
20
+ *
21
+ * All methods are thin typed wrappers; no business logic lives here.
22
+ * Prefer using the React hooks in this package inside components.
23
+ */
24
+ const Upscope = {
25
+ /** Initialise the SDK. Must be called before any other method. */
26
+ initialize(config) {
27
+ _NativeUpscopeModule.default.initialize(config);
28
+ },
29
+ /** Open a WebSocket connection to the Upscope service. */
30
+ connect() {
31
+ _NativeUpscopeModule.default.connect();
32
+ },
33
+ /** Close the WebSocket connection. */
34
+ disconnect() {
35
+ _NativeUpscopeModule.default.disconnect();
36
+ },
37
+ /**
38
+ * Reset the connection state.
39
+ * @param reconnect - Whether to reconnect immediately after reset. Defaults to true.
40
+ */
41
+ reset(reconnect = true) {
42
+ _NativeUpscopeModule.default.reset(reconnect);
43
+ },
44
+ /**
45
+ * Update user identity and metadata sent to the Upscope service.
46
+ * Safe to call at any time; changes are pushed on the next sync.
47
+ */
48
+ updateConnection(params) {
49
+ _NativeUpscopeModule.default.updateConnection(params);
50
+ },
51
+ /** Terminate the active co-browsing session. */
52
+ stopSession() {
53
+ _NativeUpscopeModule.default.stopSession();
54
+ },
55
+ /** Request that an agent join the current session. */
56
+ requestAgent() {
57
+ _NativeUpscopeModule.default.requestAgent();
58
+ },
59
+ /** Cancel a pending agent-join request. */
60
+ cancelAgentRequest() {
61
+ _NativeUpscopeModule.default.cancelAgentRequest();
62
+ },
63
+ /**
64
+ * Ask the native layer to emit the current lookup code via the
65
+ * `lookupCodeChanged` event. The lookup code itself is delivered
66
+ * asynchronously through the event system.
67
+ */
68
+ getLookupCode() {
69
+ _NativeUpscopeModule.default.getLookupCode();
70
+ },
71
+ /** Resolve the current short ID, or null if not yet assigned. */
72
+ getShortId() {
73
+ return _NativeUpscopeModule.default.getShortId();
74
+ },
75
+ /** Resolve the watch link for the current session, or null if unavailable. */
76
+ getWatchLink() {
77
+ return _NativeUpscopeModule.default.getWatchLink();
78
+ },
79
+ /** Send an arbitrary string message to all connected observers. */
80
+ sendCustomMessage(message) {
81
+ _NativeUpscopeModule.default.sendCustomMessage(message);
82
+ },
83
+ /**
84
+ * Subscribe to a typed Upscope event.
85
+ *
86
+ * @param eventName - One of the well-known event names from UpscopeEventMap.
87
+ * @param callback - Invoked with the strongly-typed payload on each event.
88
+ * @returns A subscription handle. Call `.remove()` to unsubscribe.
89
+ */
90
+ addListener(eventName, callback) {
91
+ return emitter.addListener(eventName, callback);
92
+ }
93
+ };
94
+ var _default = exports.default = Upscope;
95
+ //# sourceMappingURL=Upscope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_NativeUpscopeModule","_interopRequireDefault","e","__esModule","default","emitter","NativeEventEmitter","NativeUpscopeModule","Upscope","initialize","config","connect","disconnect","reset","reconnect","updateConnection","params","stopSession","requestAgent","cancelAgentRequest","getLookupCode","getShortId","getWatchLink","sendCustomMessage","message","addListener","eventName","callback","_default","exports"],"sourceRoot":"../../src","sources":["Upscope.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAQxD;AACA;AACA;AACA;;AAKA;AACA,MAAMG,OAAO,GAAG,IAAIC,+BAAkB,CAACC,4BAAmB,CAAC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAG;EACd;EACAC,UAAUA,CAACC,MAAqB,EAAQ;IACtCH,4BAAmB,CAACE,UAAU,CAACC,MAA2B,CAAC;EAC7D,CAAC;EAED;EACAC,OAAOA,CAAA,EAAS;IACdJ,4BAAmB,CAACI,OAAO,CAAC,CAAC;EAC/B,CAAC;EAED;EACAC,UAAUA,CAAA,EAAS;IACjBL,4BAAmB,CAACK,UAAU,CAAC,CAAC;EAClC,CAAC;EAED;AACF;AACA;AACA;EACEC,KAAKA,CAACC,SAAkB,GAAG,IAAI,EAAQ;IACrCP,4BAAmB,CAACM,KAAK,CAACC,SAAS,CAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;EACEC,gBAAgBA,CAACC,MAA8B,EAAQ;IACrDT,4BAAmB,CAACQ,gBAAgB,CAACC,MAA2B,CAAC;EACnE,CAAC;EAED;EACAC,WAAWA,CAAA,EAAS;IAClBV,4BAAmB,CAACU,WAAW,CAAC,CAAC;EACnC,CAAC;EAED;EACAC,YAAYA,CAAA,EAAS;IACnBX,4BAAmB,CAACW,YAAY,CAAC,CAAC;EACpC,CAAC;EAED;EACAC,kBAAkBA,CAAA,EAAS;IACzBZ,4BAAmB,CAACY,kBAAkB,CAAC,CAAC;EAC1C,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,aAAaA,CAAA,EAAS;IACpBb,4BAAmB,CAACa,aAAa,CAAC,CAAC;EACrC,CAAC;EAED;EACAC,UAAUA,CAAA,EAA2B;IACnC,OAAOd,4BAAmB,CAACc,UAAU,CAAC,CAAC;EACzC,CAAC;EAED;EACAC,YAAYA,CAAA,EAA2B;IACrC,OAAOf,4BAAmB,CAACe,YAAY,CAAC,CAAC;EAC3C,CAAC;EAED;EACAC,iBAAiBA,CAACC,OAAe,EAAQ;IACvCjB,4BAAmB,CAACgB,iBAAiB,CAACC,OAAO,CAAC;EAChD,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CACTC,SAAY,EACZC,QAA6C,EAC1B;IACnB,OAAOtB,OAAO,CAACoB,WAAW,CAACC,SAAS,EAAEC,QAAQ,CAAC;EACjD;AACF,CAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzB,OAAA,GAEII,OAAO","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UpscopeMasked = UpscopeMasked;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _NativeUpscopeMaskedView = _interopRequireDefault(require("./NativeUpscopeMaskedView"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function UpscopeMasked({
12
+ children,
13
+ style,
14
+ ...props
15
+ }) {
16
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NativeUpscopeMaskedView.default, {
17
+ style: style,
18
+ ...props,
19
+ children: children
20
+ });
21
+ }
22
+ //# sourceMappingURL=UpscopeMasked.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_NativeUpscopeMaskedView","_jsxRuntime","e","__esModule","default","UpscopeMasked","children","style","props","jsx"],"sourceRoot":"../../src","sources":["UpscopeMasked.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,wBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAgE,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMzD,SAASG,aAAaA,CAAC;EAC5BC,QAAQ;EACRC,KAAK;EACL,GAAGC;AACe,CAAC,EAAE;EACrB,oBACE,IAAAP,WAAA,CAAAQ,GAAA,EAACT,wBAAA,CAAAI,OAAuB;IAACG,KAAK,EAAEA,KAAM;IAAA,GAAKC,KAAK;IAAAF,QAAA,EAC7CA;EAAQ,CACc,CAAC;AAE9B","ignoreList":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useConnectionState = useConnectionState;
7
+ exports.useLookupCode = useLookupCode;
8
+ exports.useSessionState = useSessionState;
9
+ exports.useShortId = useShortId;
10
+ exports.useUpscope = useUpscope;
11
+ var _react = require("react");
12
+ var _Upscope = _interopRequireDefault(require("./Upscope"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ /**
15
+ * Returns the current WebSocket connection state, updated reactively via the
16
+ * `connectionStateChanged` event. Starts as "inactive" before the first event.
17
+ */
18
+ function useConnectionState() {
19
+ const [state, setState] = (0, _react.useState)("inactive");
20
+ (0, _react.useEffect)(() => {
21
+ const sub = _Upscope.default.addListener("connectionStateChanged", event => {
22
+ setState(event.state);
23
+ });
24
+ return () => sub.remove();
25
+ }, []);
26
+ return state;
27
+ }
28
+
29
+ /**
30
+ * Returns the current co-browsing session state. Transitions to "active" on
31
+ * `sessionStarted` and back to "inactive" on `sessionEnded`.
32
+ */
33
+ function useSessionState() {
34
+ const [state, setState] = (0, _react.useState)("inactive");
35
+ (0, _react.useEffect)(() => {
36
+ const subStart = _Upscope.default.addListener("sessionStarted", () => {
37
+ setState("active");
38
+ });
39
+ const subEnd = _Upscope.default.addListener("sessionEnded", () => {
40
+ setState("inactive");
41
+ });
42
+ return () => {
43
+ subStart.remove();
44
+ subEnd.remove();
45
+ };
46
+ }, []);
47
+ return state;
48
+ }
49
+
50
+ /**
51
+ * Returns the SDK short ID, or null if not yet assigned.
52
+ * Resolves the current value on mount and stays in sync via `shortIdChanged`.
53
+ */
54
+ function useShortId() {
55
+ const [shortId, setShortId] = (0, _react.useState)(null);
56
+ (0, _react.useEffect)(() => {
57
+ // Seed with the current value; the listener handles all subsequent changes.
58
+ _Upscope.default.getShortId().then(setShortId);
59
+ const sub = _Upscope.default.addListener("shortIdChanged", event => {
60
+ setShortId(event.shortId);
61
+ });
62
+ return () => sub.remove();
63
+ }, []);
64
+ return shortId;
65
+ }
66
+
67
+ /**
68
+ * Returns the current lookup code, or null until the native layer emits one.
69
+ * Updated reactively via `lookupCodeChanged`.
70
+ */
71
+ function useLookupCode() {
72
+ const [code, setCode] = (0, _react.useState)(null);
73
+ (0, _react.useEffect)(() => {
74
+ const sub = _Upscope.default.addListener("lookupCodeChanged", event => {
75
+ setCode(event.lookupCode);
76
+ });
77
+ return () => sub.remove();
78
+ }, []);
79
+ return code;
80
+ }
81
+
82
+ /**
83
+ * Returns a stable object of imperative Upscope action methods.
84
+ * Safe to use as a dependency in `useCallback` / `useEffect`.
85
+ */
86
+ function useUpscope() {
87
+ return (0, _react.useMemo)(() => ({
88
+ connect: _Upscope.default.connect,
89
+ disconnect: _Upscope.default.disconnect,
90
+ stopSession: _Upscope.default.stopSession,
91
+ requestAgent: _Upscope.default.requestAgent,
92
+ cancelAgentRequest: _Upscope.default.cancelAgentRequest,
93
+ sendCustomMessage: _Upscope.default.sendCustomMessage,
94
+ getLookupCode: _Upscope.default.getLookupCode,
95
+ reset: _Upscope.default.reset
96
+ }), []);
97
+ }
98
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_Upscope","_interopRequireDefault","e","__esModule","default","useConnectionState","state","setState","useState","useEffect","sub","Upscope","addListener","event","remove","useSessionState","subStart","subEnd","useShortId","shortId","setShortId","getShortId","then","useLookupCode","code","setCode","lookupCode","useUpscope","useMemo","connect","disconnect","stopSession","requestAgent","cancelAgentRequest","sendCustomMessage","getLookupCode","reset"],"sourceRoot":"../../src","sources":["hooks.ts"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAgC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhC;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAAA,EAAoB;EACpD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAkB,UAAU,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,GAAG,GAAGC,gBAAO,CAACC,WAAW,CAAC,wBAAwB,EAAGC,KAAK,IAAK;MACnEN,QAAQ,CAACM,KAAK,CAACP,KAAK,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,MAAMI,GAAG,CAACI,MAAM,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOR,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACO,SAASS,eAAeA,CAAA,EAAiB;EAC9C,MAAM,CAACT,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAe,UAAU,CAAC;EAE5D,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMO,QAAQ,GAAGL,gBAAO,CAACC,WAAW,CAAC,gBAAgB,EAAE,MAAM;MAC3DL,QAAQ,CAAC,QAAQ,CAAC;IACpB,CAAC,CAAC;IACF,MAAMU,MAAM,GAAGN,gBAAO,CAACC,WAAW,CAAC,cAAc,EAAE,MAAM;MACvDL,QAAQ,CAAC,UAAU,CAAC;IACtB,CAAC,CAAC;IACF,OAAO,MAAM;MACXS,QAAQ,CAACF,MAAM,CAAC,CAAC;MACjBG,MAAM,CAACH,MAAM,CAAC,CAAC;IACjB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOR,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACO,SAASY,UAAUA,CAAA,EAAkB;EAC1C,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAZ,eAAQ,EAAgB,IAAI,CAAC;EAE3D,IAAAC,gBAAS,EAAC,MAAM;IACd;IACAE,gBAAO,CAACU,UAAU,CAAC,CAAC,CAACC,IAAI,CAACF,UAAU,CAAC;IACrC,MAAMV,GAAG,GAAGC,gBAAO,CAACC,WAAW,CAAC,gBAAgB,EAAGC,KAAK,IAAK;MAC3DO,UAAU,CAACP,KAAK,CAACM,OAAO,CAAC;IAC3B,CAAC,CAAC;IACF,OAAO,MAAMT,GAAG,CAACI,MAAM,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOK,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACO,SAASI,aAAaA,CAAA,EAAkB;EAC7C,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAG,IAAAjB,eAAQ,EAAgB,IAAI,CAAC;EAErD,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,GAAG,GAAGC,gBAAO,CAACC,WAAW,CAAC,mBAAmB,EAAGC,KAAK,IAAK;MAC9DY,OAAO,CAACZ,KAAK,CAACa,UAAU,CAAC;IAC3B,CAAC,CAAC;IACF,OAAO,MAAMhB,GAAG,CAACI,MAAM,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOU,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAAA,EAAG;EAC3B,OAAO,IAAAC,cAAO,EACZ,OAAO;IACLC,OAAO,EAAElB,gBAAO,CAACkB,OAAO;IACxBC,UAAU,EAAEnB,gBAAO,CAACmB,UAAU;IAC9BC,WAAW,EAAEpB,gBAAO,CAACoB,WAAW;IAChCC,YAAY,EAAErB,gBAAO,CAACqB,YAAY;IAClCC,kBAAkB,EAAEtB,gBAAO,CAACsB,kBAAkB;IAC9CC,iBAAiB,EAAEvB,gBAAO,CAACuB,iBAAiB;IAC5CC,aAAa,EAAExB,gBAAO,CAACwB,aAAa;IACpCC,KAAK,EAAEzB,gBAAO,CAACyB;EACjB,CAAC,CAAC,EACF,EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Upscope", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Upscope.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "UpscopeMasked", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _UpscopeMasked.UpscopeMasked;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "default", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _Upscope.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useConnectionState", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _hooks.useConnectionState;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "useLookupCode", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _hooks.useLookupCode;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useSessionState", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _hooks.useSessionState;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "useShortId", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _hooks.useShortId;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "useUpscope", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _hooks.useUpscope;
52
+ }
53
+ });
54
+ var _Upscope = _interopRequireDefault(require("./Upscope"));
55
+ var _hooks = require("./hooks");
56
+ var _UpscopeMasked = require("./UpscopeMasked");
57
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Upscope","_interopRequireDefault","require","_hooks","_UpscopeMasked","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,cAAA,GAAAF,OAAA;AAAgD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
4
+ export default codegenNativeComponent("UpscopeMaskedView");
5
+ //# sourceMappingURL=NativeUpscopeMaskedView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeUpscopeMaskedView.ts"],"mappings":";;AAEA,OAAOA,sBAAsB,MAAM,yDAAyD;AAI5F,eAAeA,sBAAsB,CACnC,mBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from "react-native";
4
+ export default TurboModuleRegistry.getEnforcing("UpscopeModule");
5
+ //# sourceMappingURL=NativeUpscopeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUpscopeModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AA8BlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}