@upscopeio/react-native-sdk 2026.4.1 → 2026.6.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 +144 -17
- package/android/build.gradle.kts +1 -1
- package/android/src/main/kotlin/io/upscope/reactnative/UpscopeModule.kt +193 -31
- package/ios/UpscopeModule.mm +3 -0
- package/ios/UpscopeModule.swift +195 -43
- package/lib/commonjs/NativeUpscopeModule.js.map +1 -1
- package/lib/commonjs/Upscope.js +55 -18
- package/lib/commonjs/Upscope.js.map +1 -1
- package/lib/commonjs/hooks.js +45 -2
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/NativeUpscopeModule.js.map +1 -1
- package/lib/module/Upscope.js +57 -19
- package/lib/module/Upscope.js.map +1 -1
- package/lib/module/hooks.js +43 -2
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/NativeUpscopeModule.d.ts +3 -0
- package/lib/typescript/NativeUpscopeModule.d.ts.map +1 -1
- package/lib/typescript/Upscope.d.ts +20 -2
- package/lib/typescript/Upscope.d.ts.map +1 -1
- package/lib/typescript/hooks.d.ts +20 -3
- package/lib/typescript/hooks.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +7 -7
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +64 -17
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/NativeUpscopeModule.ts +5 -0
- package/src/Upscope.ts +63 -20
- package/src/hooks.ts +56 -3
- package/src/index.ts +19 -10
- package/src/types.ts +78 -30
- package/src/version.ts +1 -1
- package/upscopeio-react-native-sdk.podspec +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,cAAc,GACd,OAAO,CAAC;AAEZ,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,gBAAgB,GAChB,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,cAAc,GACd,OAAO,CAAC;AAEZ,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,gBAAgB,GAChB,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAAC;AAE1E,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvD,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,8BAA8B,CAAC,EAAE,OAAO,CAAC;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6GAA6G;IAC7G,QAAQ,CAAC,UA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@
|
|
|
1
|
-
export declare const SDK_VERSION = "2026.
|
|
1
|
+
export declare const SDK_VERSION = "2026.6.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -16,6 +16,11 @@ export interface Spec extends TurboModule {
|
|
|
16
16
|
requestAgent(): void;
|
|
17
17
|
cancelAgentRequest(): void;
|
|
18
18
|
|
|
19
|
+
// Remote control / full-device sharing
|
|
20
|
+
stopRemoteControl(): void;
|
|
21
|
+
stopFullDeviceSharing(): void;
|
|
22
|
+
respondToFullDeviceRequest(requestId: string, accept: boolean): void;
|
|
23
|
+
|
|
19
24
|
// Lookup
|
|
20
25
|
getLookupCode(): void;
|
|
21
26
|
getShortId(): Promise<string | null>;
|
package/src/Upscope.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { NativeEventEmitter } from
|
|
2
|
-
import
|
|
3
|
-
import { SDK_VERSION } from
|
|
1
|
+
import { NativeEventEmitter, TurboModuleRegistry } from 'react-native';
|
|
2
|
+
import type { Spec } from './NativeUpscopeModule';
|
|
3
|
+
import { SDK_VERSION } from './version';
|
|
4
4
|
import type {
|
|
5
5
|
UpscopeConfig,
|
|
6
6
|
ConnectionUpdateParams,
|
|
7
7
|
UpscopeEventMap,
|
|
8
8
|
UpscopeEventName,
|
|
9
|
-
} from
|
|
9
|
+
} from './types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Subscription handle returned by addListener. Callers must invoke remove()
|
|
@@ -16,8 +16,24 @@ export interface EventSubscription {
|
|
|
16
16
|
remove(): void;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the native TurboModule lazily on first use. Resolving at import time
|
|
21
|
+
* runs during the initial JS bundle evaluation — before the bridgeless runtime
|
|
22
|
+
* has finished registering third-party TurboModules — which makes
|
|
23
|
+
* `getEnforcing` throw "UpscopeModule could not be found". Deferring until a
|
|
24
|
+
* method is actually called avoids that startup ordering issue.
|
|
25
|
+
*/
|
|
26
|
+
let nativeModule: Spec | undefined;
|
|
27
|
+
function native(): Spec {
|
|
28
|
+
return (nativeModule ??=
|
|
29
|
+
TurboModuleRegistry.getEnforcing<Spec>('UpscopeModule'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Lazily-created emitter — one instance for the lifetime of the JS runtime.
|
|
33
|
+
let eventEmitter: NativeEventEmitter | undefined;
|
|
34
|
+
function emitter(): NativeEventEmitter {
|
|
35
|
+
return (eventEmitter ??= new NativeEventEmitter(native()));
|
|
36
|
+
}
|
|
21
37
|
|
|
22
38
|
/**
|
|
23
39
|
* Imperative JS API over the native Upscope TurboModule.
|
|
@@ -28,7 +44,7 @@ const emitter = new NativeEventEmitter(NativeUpscopeModule);
|
|
|
28
44
|
const Upscope = {
|
|
29
45
|
/** Initialise the SDK. Must be called before any other method. */
|
|
30
46
|
initialize(config: UpscopeConfig): void {
|
|
31
|
-
|
|
47
|
+
native().initialize({
|
|
32
48
|
...config,
|
|
33
49
|
wrapperVersion: SDK_VERSION,
|
|
34
50
|
} as unknown as Object);
|
|
@@ -36,12 +52,12 @@ const Upscope = {
|
|
|
36
52
|
|
|
37
53
|
/** Open a WebSocket connection to the Upscope service. */
|
|
38
54
|
connect(): void {
|
|
39
|
-
|
|
55
|
+
native().connect();
|
|
40
56
|
},
|
|
41
57
|
|
|
42
58
|
/** Close the WebSocket connection. */
|
|
43
59
|
disconnect(): void {
|
|
44
|
-
|
|
60
|
+
native().disconnect();
|
|
45
61
|
},
|
|
46
62
|
|
|
47
63
|
/**
|
|
@@ -49,7 +65,7 @@ const Upscope = {
|
|
|
49
65
|
* @param reconnect - Whether to reconnect immediately after reset. Defaults to true.
|
|
50
66
|
*/
|
|
51
67
|
reset(reconnect: boolean = true): void {
|
|
52
|
-
|
|
68
|
+
native().reset(reconnect);
|
|
53
69
|
},
|
|
54
70
|
|
|
55
71
|
/**
|
|
@@ -57,22 +73,49 @@ const Upscope = {
|
|
|
57
73
|
* Safe to call at any time; changes are pushed on the next sync.
|
|
58
74
|
*/
|
|
59
75
|
updateConnection(params: ConnectionUpdateParams): void {
|
|
60
|
-
|
|
76
|
+
native().updateConnection(params as unknown as Object);
|
|
61
77
|
},
|
|
62
78
|
|
|
63
79
|
/** Terminate the active co-browsing session. */
|
|
64
80
|
stopSession(): void {
|
|
65
|
-
|
|
81
|
+
native().stopSession();
|
|
66
82
|
},
|
|
67
83
|
|
|
68
84
|
/** Request that an agent join the current session. */
|
|
69
85
|
requestAgent(): void {
|
|
70
|
-
|
|
86
|
+
native().requestAgent();
|
|
71
87
|
},
|
|
72
88
|
|
|
73
89
|
/** Cancel a pending agent-join request. */
|
|
74
90
|
cancelAgentRequest(): void {
|
|
75
|
-
|
|
91
|
+
native().cancelAgentRequest();
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Revoke the agent's active remote control while keeping the session alive.
|
|
96
|
+
* No-op if remote control is not currently active.
|
|
97
|
+
*/
|
|
98
|
+
stopRemoteControl(): void {
|
|
99
|
+
native().stopRemoteControl();
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* End full-device (broadcast) sharing and revert to in-app sharing, keeping
|
|
104
|
+
* the session alive. No-op if full-device sharing is not currently active.
|
|
105
|
+
*/
|
|
106
|
+
stopFullDeviceSharing(): void {
|
|
107
|
+
native().stopFullDeviceSharing();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Answer a pending full-device sharing request delivered via the
|
|
112
|
+
* `fullDeviceRequest` event.
|
|
113
|
+
*
|
|
114
|
+
* @param requestId - The id from the `fullDeviceRequest` event payload.
|
|
115
|
+
* @param accept - `true` to allow full-device capture, `false` to reject.
|
|
116
|
+
*/
|
|
117
|
+
respondToFullDeviceRequest(requestId: string, accept: boolean): void {
|
|
118
|
+
native().respondToFullDeviceRequest(requestId, accept);
|
|
76
119
|
},
|
|
77
120
|
|
|
78
121
|
/**
|
|
@@ -81,22 +124,22 @@ const Upscope = {
|
|
|
81
124
|
* asynchronously through the event system.
|
|
82
125
|
*/
|
|
83
126
|
getLookupCode(): void {
|
|
84
|
-
|
|
127
|
+
native().getLookupCode();
|
|
85
128
|
},
|
|
86
129
|
|
|
87
130
|
/** Resolve the current short ID, or null if not yet assigned. */
|
|
88
131
|
getShortId(): Promise<string | null> {
|
|
89
|
-
return
|
|
132
|
+
return native().getShortId();
|
|
90
133
|
},
|
|
91
134
|
|
|
92
135
|
/** Resolve the watch link for the current session, or null if unavailable. */
|
|
93
136
|
getWatchLink(): Promise<string | null> {
|
|
94
|
-
return
|
|
137
|
+
return native().getWatchLink();
|
|
95
138
|
},
|
|
96
139
|
|
|
97
|
-
/** Send an arbitrary string message to all connected
|
|
140
|
+
/** Send an arbitrary string message to all connected viewers. */
|
|
98
141
|
sendCustomMessage(message: string): void {
|
|
99
|
-
|
|
142
|
+
native().sendCustomMessage(message);
|
|
100
143
|
},
|
|
101
144
|
|
|
102
145
|
/**
|
|
@@ -110,7 +153,7 @@ const Upscope = {
|
|
|
110
153
|
eventName: E,
|
|
111
154
|
callback: (event: UpscopeEventMap[E]) => void,
|
|
112
155
|
): EventSubscription {
|
|
113
|
-
return emitter.addListener(eventName, callback);
|
|
156
|
+
return emitter().addListener(eventName, callback);
|
|
114
157
|
},
|
|
115
158
|
} as const;
|
|
116
159
|
|
package/src/hooks.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useState, useEffect, useMemo } from "react";
|
|
2
2
|
import Upscope from "./Upscope";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ConnectionState,
|
|
5
|
+
SessionState,
|
|
6
|
+
RemoteControlState,
|
|
7
|
+
FullDeviceSharingState,
|
|
8
|
+
} from "./types";
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* Returns the current WebSocket connection state, updated reactively via the
|
|
@@ -20,13 +25,20 @@ export function useConnectionState(): ConnectionState {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
|
-
* Returns the current co-browsing session state.
|
|
24
|
-
*
|
|
28
|
+
* Returns the current co-browsing session state.
|
|
29
|
+
*
|
|
30
|
+
* Seeds and stays in sync via the `sessionStateChanged` event, which the
|
|
31
|
+
* native layer drives from a current-value publisher — so a fresh subscription
|
|
32
|
+
* immediately receives the real state, even across remounts. The
|
|
33
|
+
* `sessionStarted`/`sessionEnded` events provide redundant fast-path updates.
|
|
25
34
|
*/
|
|
26
35
|
export function useSessionState(): SessionState {
|
|
27
36
|
const [state, setState] = useState<SessionState>("inactive");
|
|
28
37
|
|
|
29
38
|
useEffect(() => {
|
|
39
|
+
const subState = Upscope.addListener("sessionStateChanged", (event) => {
|
|
40
|
+
setState(event.state);
|
|
41
|
+
});
|
|
30
42
|
const subStart = Upscope.addListener("sessionStarted", () => {
|
|
31
43
|
setState("active");
|
|
32
44
|
});
|
|
@@ -34,6 +46,7 @@ export function useSessionState(): SessionState {
|
|
|
34
46
|
setState("inactive");
|
|
35
47
|
});
|
|
36
48
|
return () => {
|
|
49
|
+
subState.remove();
|
|
37
50
|
subStart.remove();
|
|
38
51
|
subEnd.remove();
|
|
39
52
|
};
|
|
@@ -78,6 +91,43 @@ export function useLookupCode(): string | null {
|
|
|
78
91
|
return code;
|
|
79
92
|
}
|
|
80
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Returns whether an agent currently has remote control of the device.
|
|
96
|
+
* Defaults to "inactive" and stays in sync via `remoteControlStateChanged`.
|
|
97
|
+
*/
|
|
98
|
+
export function useRemoteControlState(): RemoteControlState {
|
|
99
|
+
const [state, setState] = useState<RemoteControlState>("inactive");
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const sub = Upscope.addListener("remoteControlStateChanged", (event) => {
|
|
103
|
+
setState(event.state);
|
|
104
|
+
});
|
|
105
|
+
return () => sub.remove();
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
return state;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns whether full-device (broadcast) screen sharing is currently running.
|
|
113
|
+
* Defaults to "inactive" and stays in sync via `fullDeviceSharingStateChanged`.
|
|
114
|
+
*/
|
|
115
|
+
export function useFullDeviceSharingState(): FullDeviceSharingState {
|
|
116
|
+
const [state, setState] = useState<FullDeviceSharingState>("inactive");
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const sub = Upscope.addListener(
|
|
120
|
+
"fullDeviceSharingStateChanged",
|
|
121
|
+
(event) => {
|
|
122
|
+
setState(event.state);
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
return () => sub.remove();
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
return state;
|
|
129
|
+
}
|
|
130
|
+
|
|
81
131
|
/**
|
|
82
132
|
* Returns a stable object of imperative Upscope action methods.
|
|
83
133
|
* Safe to use as a dependency in `useCallback` / `useEffect`.
|
|
@@ -90,6 +140,9 @@ export function useUpscope() {
|
|
|
90
140
|
stopSession: Upscope.stopSession,
|
|
91
141
|
requestAgent: Upscope.requestAgent,
|
|
92
142
|
cancelAgentRequest: Upscope.cancelAgentRequest,
|
|
143
|
+
stopRemoteControl: Upscope.stopRemoteControl,
|
|
144
|
+
stopFullDeviceSharing: Upscope.stopFullDeviceSharing,
|
|
145
|
+
respondToFullDeviceRequest: Upscope.respondToFullDeviceRequest,
|
|
93
146
|
sendCustomMessage: Upscope.sendCustomMessage,
|
|
94
147
|
getLookupCode: Upscope.getLookupCode,
|
|
95
148
|
reset: Upscope.reset,
|
package/src/index.ts
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
export { default as default } from
|
|
2
|
-
export { default as Upscope } from
|
|
3
|
-
export type { EventSubscription } from
|
|
1
|
+
export { default as default } from './Upscope';
|
|
2
|
+
export { default as Upscope } from './Upscope';
|
|
3
|
+
export type { EventSubscription } from './Upscope';
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
useConnectionState,
|
|
7
7
|
useSessionState,
|
|
8
8
|
useShortId,
|
|
9
9
|
useLookupCode,
|
|
10
|
+
useRemoteControlState,
|
|
11
|
+
useFullDeviceSharingState,
|
|
10
12
|
useUpscope,
|
|
11
|
-
} from
|
|
13
|
+
} from './hooks';
|
|
12
14
|
|
|
13
|
-
export { UpscopeMasked } from
|
|
14
|
-
export type { UpscopeMaskedProps } from
|
|
15
|
+
export { UpscopeMasked } from './UpscopeMasked';
|
|
16
|
+
export type { UpscopeMaskedProps } from './UpscopeMasked';
|
|
15
17
|
|
|
16
18
|
export type {
|
|
17
19
|
ConnectionState,
|
|
18
20
|
SessionState,
|
|
19
21
|
SessionEndReason,
|
|
22
|
+
RemoteControlState,
|
|
23
|
+
FullDeviceSharingState,
|
|
20
24
|
UpscopeError,
|
|
21
25
|
UpscopeConfig,
|
|
26
|
+
LocalizedString,
|
|
22
27
|
ConnectionUpdateParams,
|
|
23
|
-
|
|
28
|
+
Viewer,
|
|
24
29
|
UpscopeEventMap,
|
|
25
30
|
UpscopeEventName,
|
|
26
31
|
ConnectionStateChangedEvent,
|
|
27
32
|
SessionStartedEvent,
|
|
28
33
|
SessionEndedEvent,
|
|
29
34
|
CustomMessageEvent,
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
ViewerCountChangedEvent,
|
|
36
|
+
ViewerLeftEvent,
|
|
32
37
|
ShortIdChangedEvent,
|
|
33
38
|
LookupCodeChangedEvent,
|
|
34
|
-
|
|
39
|
+
SessionStateChangedEvent,
|
|
40
|
+
RemoteControlStateChangedEvent,
|
|
41
|
+
FullDeviceSharingStateChangedEvent,
|
|
42
|
+
FullDeviceRequestEvent,
|
|
43
|
+
} from './types';
|
package/src/types.ts
CHANGED
|
@@ -1,50 +1,78 @@
|
|
|
1
1
|
export type ConnectionState =
|
|
2
|
-
|
|
|
3
|
-
|
|
|
4
|
-
|
|
|
5
|
-
|
|
|
6
|
-
|
|
|
2
|
+
| 'inactive'
|
|
3
|
+
| 'connecting'
|
|
4
|
+
| 'connected'
|
|
5
|
+
| 'reconnecting'
|
|
6
|
+
| 'error';
|
|
7
7
|
|
|
8
8
|
export type SessionState =
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
15
|
-
export type SessionEndReason =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
| 'inactive'
|
|
10
|
+
| 'pendingRequest'
|
|
11
|
+
| 'active'
|
|
12
|
+
| 'paused'
|
|
13
|
+
| 'ended';
|
|
14
|
+
|
|
15
|
+
export type SessionEndReason = 'userStopped' | 'agentStopped' | 'timeout';
|
|
16
|
+
|
|
17
|
+
/** Whether an agent currently has remote control of the device. */
|
|
18
|
+
export type RemoteControlState = 'inactive' | 'active';
|
|
19
|
+
|
|
20
|
+
/** Whether full-device (broadcast) screen sharing is currently running. */
|
|
21
|
+
export type FullDeviceSharingState = 'inactive' | 'active';
|
|
20
22
|
|
|
21
23
|
export interface UpscopeError {
|
|
22
24
|
readonly code: string;
|
|
23
25
|
readonly message: string;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A translated configuration value. Either a single string (same text for every
|
|
30
|
+
* user) or a language-keyed map whose keys are BCP-47 language tags such as
|
|
31
|
+
* `"en"`, `"it"`, or `"pt-PT"`. When a map is provided, the native SDK picks
|
|
32
|
+
* the best match against the device's preferred languages.
|
|
33
|
+
*/
|
|
34
|
+
export type LocalizedString = string | { readonly [language: string]: string };
|
|
35
|
+
|
|
26
36
|
export interface UpscopeConfig {
|
|
27
37
|
readonly apiKey: string;
|
|
28
38
|
readonly requireAuthorizationForSession?: boolean;
|
|
29
39
|
readonly autoConnect?: boolean;
|
|
30
40
|
readonly region?: string;
|
|
31
|
-
|
|
41
|
+
/** Base domain for SDK endpoints (default `"upscope.io"`). Set for staging/on-prem, e.g. `"upscope.xyz"`. */
|
|
42
|
+
readonly baseDomain?: string;
|
|
32
43
|
readonly showTerminateButton?: boolean;
|
|
33
44
|
readonly authorizationPromptTitle?: string;
|
|
34
45
|
readonly authorizationPromptMessage?: string;
|
|
35
46
|
readonly endOfSessionMessage?: string;
|
|
36
|
-
readonly stopSessionText?:
|
|
47
|
+
readonly stopSessionText?: LocalizedString;
|
|
37
48
|
readonly allowRemoteClick?: boolean;
|
|
38
49
|
readonly allowRemoteScroll?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* When `true`, full-device sharing is declined while masked content is on
|
|
52
|
+
* screen (MediaProjection/ReplayKit capture the raw screen and can't apply
|
|
53
|
+
* view masking). Defaults to the server config. Set `false` to allow
|
|
54
|
+
* full-device sharing even with masked content present.
|
|
55
|
+
*/
|
|
56
|
+
readonly disableFullScreenWhenMasked?: boolean;
|
|
39
57
|
readonly requireControlRequest?: boolean;
|
|
40
58
|
readonly controlRequestTitle?: string;
|
|
41
59
|
readonly controlRequestMessage?: string;
|
|
42
60
|
readonly enableLookupCodeOnShake?: boolean;
|
|
43
61
|
readonly lookupCodeKeyTitle?: string;
|
|
44
62
|
readonly lookupCodeKeyMessage?: string;
|
|
45
|
-
readonly translationsYes?:
|
|
46
|
-
readonly translationsNo?:
|
|
47
|
-
readonly translationsOk?:
|
|
63
|
+
readonly translationsYes?: LocalizedString;
|
|
64
|
+
readonly translationsNo?: LocalizedString;
|
|
65
|
+
readonly translationsOk?: LocalizedString;
|
|
66
|
+
/**
|
|
67
|
+
* iOS only. App Group identifier shared between the host app and its
|
|
68
|
+
* Broadcast Upload Extension, required to enable full-device sharing.
|
|
69
|
+
*/
|
|
70
|
+
readonly broadcastAppGroupId?: string;
|
|
71
|
+
/**
|
|
72
|
+
* iOS only. Bundle identifier of the Broadcast Upload Extension target.
|
|
73
|
+
* Used to pre-select the extension in the broadcast picker.
|
|
74
|
+
*/
|
|
75
|
+
readonly broadcastExtensionBundleId?: string;
|
|
48
76
|
}
|
|
49
77
|
|
|
50
78
|
export interface ConnectionUpdateParams {
|
|
@@ -56,11 +84,12 @@ export interface ConnectionUpdateParams {
|
|
|
56
84
|
readonly metadata?: Readonly<Record<string, string>>;
|
|
57
85
|
}
|
|
58
86
|
|
|
59
|
-
export interface
|
|
87
|
+
export interface Viewer {
|
|
60
88
|
readonly id: string;
|
|
61
89
|
readonly name: string | null;
|
|
62
90
|
readonly screenWidth: number;
|
|
63
91
|
readonly screenHeight: number;
|
|
92
|
+
readonly screenScale: number;
|
|
64
93
|
readonly windowWidth: number;
|
|
65
94
|
readonly windowHeight: number;
|
|
66
95
|
readonly hasFocus: boolean;
|
|
@@ -78,20 +107,19 @@ export interface SessionStartedEvent {
|
|
|
78
107
|
|
|
79
108
|
export interface SessionEndedEvent {
|
|
80
109
|
readonly reason: SessionEndReason;
|
|
81
|
-
readonly error?: UpscopeError;
|
|
82
110
|
}
|
|
83
111
|
|
|
84
112
|
export interface CustomMessageEvent {
|
|
85
113
|
readonly message: string;
|
|
86
|
-
readonly
|
|
114
|
+
readonly viewerId: string;
|
|
87
115
|
}
|
|
88
116
|
|
|
89
|
-
export interface
|
|
117
|
+
export interface ViewerCountChangedEvent {
|
|
90
118
|
readonly count: number;
|
|
91
119
|
}
|
|
92
120
|
|
|
93
|
-
export interface
|
|
94
|
-
readonly
|
|
121
|
+
export interface ViewerLeftEvent {
|
|
122
|
+
readonly viewerId: string;
|
|
95
123
|
}
|
|
96
124
|
|
|
97
125
|
export interface ShortIdChangedEvent {
|
|
@@ -102,17 +130,37 @@ export interface LookupCodeChangedEvent {
|
|
|
102
130
|
readonly lookupCode: string | null;
|
|
103
131
|
}
|
|
104
132
|
|
|
133
|
+
export interface SessionStateChangedEvent {
|
|
134
|
+
readonly state: SessionState;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface RemoteControlStateChangedEvent {
|
|
138
|
+
readonly state: RemoteControlState;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface FullDeviceSharingStateChangedEvent {
|
|
142
|
+
readonly state: FullDeviceSharingState;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface FullDeviceRequestEvent {
|
|
146
|
+
readonly requestId: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
105
149
|
export type UpscopeEventMap = {
|
|
106
150
|
readonly connectionStateChanged: ConnectionStateChangedEvent;
|
|
151
|
+
readonly sessionStateChanged: SessionStateChangedEvent;
|
|
107
152
|
readonly sessionStarted: SessionStartedEvent;
|
|
108
153
|
readonly sessionEnded: SessionEndedEvent;
|
|
109
154
|
readonly customMessageReceived: CustomMessageEvent;
|
|
110
155
|
readonly error: UpscopeError;
|
|
111
|
-
readonly
|
|
112
|
-
readonly
|
|
113
|
-
readonly
|
|
156
|
+
readonly viewerJoined: Viewer;
|
|
157
|
+
readonly viewerLeft: ViewerLeftEvent;
|
|
158
|
+
readonly viewerCountChanged: ViewerCountChangedEvent;
|
|
114
159
|
readonly shortIdChanged: ShortIdChangedEvent;
|
|
115
160
|
readonly lookupCodeChanged: LookupCodeChangedEvent;
|
|
161
|
+
readonly remoteControlStateChanged: RemoteControlStateChangedEvent;
|
|
162
|
+
readonly fullDeviceSharingStateChanged: FullDeviceSharingStateChangedEvent;
|
|
163
|
+
readonly fullDeviceRequest: FullDeviceRequestEvent;
|
|
116
164
|
};
|
|
117
165
|
|
|
118
166
|
export type UpscopeEventName = keyof UpscopeEventMap;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by scripts/generate-version.sh — do not edit manually
|
|
2
|
-
export const SDK_VERSION = "2026.
|
|
2
|
+
export const SDK_VERSION = "2026.6.0";
|