@upscopeio/sdk 2026.1.12 → 2026.6.16
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/bundled-upscope.js +1 -0
- package/index.d.ts +88 -53
- package/index.js +8 -94
- package/index.js.map +1 -1
- package/package.json +17 -2
- package/sdk-core.js +114 -0
- package/sdk-core.js.map +1 -0
- package/static.d.ts +250 -0
- package/static.js +275 -0
- package/static.js.map +1 -0
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type CobrowsingSdkConfiguration = {
|
|
|
4
4
|
callName?: string;
|
|
5
5
|
jsConfiguration?: boolean;
|
|
6
6
|
secretKey?: string;
|
|
7
|
+
sharingRoot: Window;
|
|
7
8
|
|
|
8
9
|
// User provided nulls clear, undefined maintain existing info
|
|
9
10
|
identities?: null | string | string[];
|
|
@@ -13,15 +14,15 @@ type CobrowsingSdkConfiguration = {
|
|
|
13
14
|
uniqueId?: null | string;
|
|
14
15
|
|
|
15
16
|
// Automatic
|
|
16
|
-
agentRequestAcceptedText:
|
|
17
|
+
agentRequestAcceptedText: LocalizedMessage;
|
|
17
18
|
agentRequestButtonPages: string[];
|
|
18
|
-
agentRequestButtonRequestingSubtitle:
|
|
19
|
-
agentRequestButtonRequestingTitle:
|
|
19
|
+
agentRequestButtonRequestingSubtitle: LocalizedMessage;
|
|
20
|
+
agentRequestButtonRequestingTitle: LocalizedMessage;
|
|
20
21
|
agentRequestButtonStyle: string;
|
|
21
|
-
agentRequestButtonSubtitle:
|
|
22
|
-
agentRequestButtonTitle:
|
|
23
|
-
agentRequestNotAvailableText:
|
|
24
|
-
agentRequestResultTitle:
|
|
22
|
+
agentRequestButtonSubtitle: LocalizedMessage;
|
|
23
|
+
agentRequestButtonTitle: LocalizedMessage;
|
|
24
|
+
agentRequestNotAvailableText: LocalizedMessage;
|
|
25
|
+
agentRequestResultTitle: LocalizedMessage;
|
|
25
26
|
allowAgentRedirect: boolean;
|
|
26
27
|
allowFullScreen: boolean;
|
|
27
28
|
allowRemoteClick: boolean;
|
|
@@ -31,28 +32,33 @@ type CobrowsingSdkConfiguration = {
|
|
|
31
32
|
allowRemoteType: boolean;
|
|
32
33
|
allowRequestFullTab: boolean;
|
|
33
34
|
apiKey: string;
|
|
34
|
-
authorizationPromptMessage:
|
|
35
|
-
authorizationPromptTitle:
|
|
35
|
+
authorizationPromptMessage: LocalizedMessage;
|
|
36
|
+
authorizationPromptTitle: LocalizedMessage;
|
|
36
37
|
autoconnect: boolean;
|
|
37
38
|
automaticallyRequestFullTab: boolean;
|
|
38
39
|
beta: boolean;
|
|
39
|
-
callAudioAuthorizationFailedMessage:
|
|
40
|
-
callAudioAuthorizationFailedTitle:
|
|
41
|
-
callPopupFailedMessage:
|
|
42
|
-
callPopupFailedTitle:
|
|
43
|
-
callPopupNoInputMessage:
|
|
44
|
-
callPopupNoInputTitle:
|
|
45
|
-
callPopupNoOutputMessage:
|
|
46
|
-
callPopupNoOutputTitle:
|
|
47
|
-
|
|
40
|
+
callAudioAuthorizationFailedMessage: LocalizedMessage;
|
|
41
|
+
callAudioAuthorizationFailedTitle: LocalizedMessage;
|
|
42
|
+
callPopupFailedMessage: LocalizedMessage;
|
|
43
|
+
callPopupFailedTitle: LocalizedMessage;
|
|
44
|
+
callPopupNoInputMessage: LocalizedMessage;
|
|
45
|
+
callPopupNoInputTitle: LocalizedMessage;
|
|
46
|
+
callPopupNoOutputMessage: LocalizedMessage;
|
|
47
|
+
callPopupNoOutputTitle: LocalizedMessage;
|
|
48
|
+
callPopupNoVideoInputMessage: LocalizedMessage;
|
|
49
|
+
callPopupNoVideoInputTitle: LocalizedMessage;
|
|
50
|
+
callPromptText: LocalizedMessage;
|
|
48
51
|
callRingtone: string;
|
|
49
|
-
|
|
52
|
+
callVideoAuthorizationFailedMessage: LocalizedMessage;
|
|
53
|
+
callVideoAuthorizationFailedTitle: LocalizedMessage;
|
|
54
|
+
callVideoRequestButton: LocalizedMessage;
|
|
55
|
+
callWaitMessage: LocalizedMessage;
|
|
50
56
|
collectHistory: boolean;
|
|
51
57
|
compressImages: boolean;
|
|
52
58
|
computedStyleSelectors: "angular" | "react" | string[];
|
|
53
59
|
consoleAllowed: boolean;
|
|
54
|
-
controlRequestMessage:
|
|
55
|
-
controlRequestTitle:
|
|
60
|
+
controlRequestMessage: LocalizedMessage;
|
|
61
|
+
controlRequestTitle: LocalizedMessage;
|
|
56
62
|
cssFile: string;
|
|
57
63
|
cursorColor: string;
|
|
58
64
|
customCallController: ((callback: (accepted: boolean) => void) => (() => void) | void) | null;
|
|
@@ -66,11 +72,10 @@ type CobrowsingSdkConfiguration = {
|
|
|
66
72
|
enableCanvases: boolean;
|
|
67
73
|
enableLookupCodeOnKey: boolean;
|
|
68
74
|
enableSessionRating: boolean;
|
|
69
|
-
enableSessionRating: boolean;
|
|
70
75
|
endOfScreenshareMessage: null | string;
|
|
71
76
|
enlargeCursor: boolean;
|
|
72
|
-
fullScreenRequestMessage:
|
|
73
|
-
fullScreenRequestTitle:
|
|
77
|
+
fullScreenRequestMessage: LocalizedMessage;
|
|
78
|
+
fullScreenRequestTitle: LocalizedMessage;
|
|
74
79
|
grabIdentityFromLivechat: boolean;
|
|
75
80
|
ignoreBrowserSupport: boolean;
|
|
76
81
|
injectLookupCodeButton: boolean;
|
|
@@ -81,9 +86,9 @@ type CobrowsingSdkConfiguration = {
|
|
|
81
86
|
lookupCodeButtonStyle: string;
|
|
82
87
|
lookupCodeElement: HTMLElement | null | string;
|
|
83
88
|
lookupCodeKey: number;
|
|
84
|
-
lookupCodeKeyMessage:
|
|
89
|
+
lookupCodeKeyMessage: LocalizedMessage;
|
|
85
90
|
lookupCodeKeyRepetitions: number;
|
|
86
|
-
lookupCodeKeyTitle:
|
|
91
|
+
lookupCodeKeyTitle: LocalizedMessage;
|
|
87
92
|
maskedElements: string[];
|
|
88
93
|
maskElementMiddleware: (element: HTMLElement) => boolean;
|
|
89
94
|
noRemoteElements: string[];
|
|
@@ -95,7 +100,10 @@ type CobrowsingSdkConfiguration = {
|
|
|
95
100
|
onWaitingForCall: () => void;
|
|
96
101
|
pageviewsEndpoint: string;
|
|
97
102
|
phoneEndpoint: string;
|
|
103
|
+
videoCallPromptText: LocalizedMessage;
|
|
98
104
|
// Automatic
|
|
105
|
+
cobrowsingVideoAudioRelationship: "automatic" | "independent" | "video_requires_audio";
|
|
106
|
+
cobrowsingVideoEnabled: "disabled" | "two_way" | "viewer_to_visitor" | "visitor_to_viewer";
|
|
99
107
|
product: "cobrowsingapi" | "helloscreen" | "userview";
|
|
100
108
|
proxyAssets: string[];
|
|
101
109
|
publicLinkOrigin: null | string;
|
|
@@ -105,12 +113,12 @@ type CobrowsingSdkConfiguration = {
|
|
|
105
113
|
requireControlRequest: boolean;
|
|
106
114
|
rewriteExternalLinks: boolean;
|
|
107
115
|
screenWakeLock: boolean;
|
|
108
|
-
sessionRatingAgentLabel:
|
|
109
|
-
sessionRatingFeedbackLabel:
|
|
110
|
-
sessionRatingModalMessage:
|
|
111
|
-
sessionRatingModalTitle:
|
|
112
|
-
sessionRatingSessionLabel:
|
|
113
|
-
sessionRatingSubmitLabel:
|
|
116
|
+
sessionRatingAgentLabel: LocalizedMessage;
|
|
117
|
+
sessionRatingFeedbackLabel: LocalizedMessage;
|
|
118
|
+
sessionRatingModalMessage: LocalizedMessage;
|
|
119
|
+
sessionRatingModalTitle: LocalizedMessage;
|
|
120
|
+
sessionRatingSessionLabel: LocalizedMessage;
|
|
121
|
+
sessionRatingSubmitLabel: LocalizedMessage;
|
|
114
122
|
sfdcFieldId: string;
|
|
115
123
|
sfdcFieldLabel: string;
|
|
116
124
|
shouldComputeStyleMiddleware: (element: HTMLElement) => boolean;
|
|
@@ -121,10 +129,10 @@ type CobrowsingSdkConfiguration = {
|
|
|
121
129
|
storageKey: null | string;
|
|
122
130
|
styleSheetContentFromRules: (stylesheet: HTMLLinkElement | HTMLStyleElement) => boolean;
|
|
123
131
|
trackConsole: boolean;
|
|
124
|
-
translationsNo:
|
|
125
|
-
translationsOk:
|
|
126
|
-
translationsStopSession:
|
|
127
|
-
translationsYes:
|
|
132
|
+
translationsNo: LocalizedMessage;
|
|
133
|
+
translationsOk: LocalizedMessage;
|
|
134
|
+
translationsStopSession: LocalizedMessage;
|
|
135
|
+
translationsYes: LocalizedMessage;
|
|
128
136
|
unavailableAgentRequestRedirectImmediately: boolean;
|
|
129
137
|
unavailableAgentRequestRedirectTo: null | string;
|
|
130
138
|
useFingerprinting: boolean;
|
|
@@ -133,10 +141,15 @@ type CobrowsingSdkConfiguration = {
|
|
|
133
141
|
};
|
|
134
142
|
|
|
135
143
|
type Instruction =
|
|
144
|
+
| ["beginViewerVideoCall"]
|
|
145
|
+
| ["beginVisitorVideoCall"]
|
|
136
146
|
| ["cancelRequestAgent"]
|
|
137
147
|
| ["connect"]
|
|
138
148
|
| ["customMessage", Record<string, unknown>]
|
|
139
149
|
| ["dataBounce", (ms: number) => void]
|
|
150
|
+
| ["endAudio"]
|
|
151
|
+
| ["endViewerVideoCall"]
|
|
152
|
+
| ["endVisitorVideoCall"]
|
|
140
153
|
| ["expectDisconnect", Partial<{ message: null | string; returnTimeSeconds: null | number; title: null | string }>]
|
|
141
154
|
| ["fullTabEnd"]
|
|
142
155
|
| ["fullTabStart"]
|
|
@@ -151,9 +164,20 @@ type Instruction =
|
|
|
151
164
|
| ["on", ...(keyof SDKEvents)[], (event: any) => void] // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
152
165
|
| ["prefetchAssets"]
|
|
153
166
|
| ["requestAgent"]
|
|
167
|
+
| [
|
|
168
|
+
"requestMode",
|
|
169
|
+
(
|
|
170
|
+
| "visitor_app"
|
|
171
|
+
| "visitor_browser"
|
|
172
|
+
| `viewer_screen:${"*" | `cobrowsing_viewer_connection_${string}`}`
|
|
173
|
+
| `visitor_screen:${"*" | `cobrowsing_visitor_connection_${string}`}`
|
|
174
|
+
),
|
|
175
|
+
]
|
|
154
176
|
| ["reset", boolean]
|
|
155
177
|
| ["reset"]
|
|
156
178
|
| ["saveHistory"]
|
|
179
|
+
| ["shutdown"]
|
|
180
|
+
| ["startAudio"]
|
|
157
181
|
| ["stopSession"]
|
|
158
182
|
| [
|
|
159
183
|
"submitRating",
|
|
@@ -163,32 +187,28 @@ type Instruction =
|
|
|
163
187
|
userSessionRating?: number;
|
|
164
188
|
},
|
|
165
189
|
]
|
|
190
|
+
| ["triggerConfetti", null | string]
|
|
166
191
|
| ["updateConnection", Partial<CobrowsingSdkConfiguration>];
|
|
167
192
|
|
|
168
|
-
type
|
|
169
|
-
hasFocus: boolean;
|
|
170
|
-
id: string;
|
|
171
|
-
name: null | string;
|
|
172
|
-
screenHeight: number;
|
|
173
|
-
screenWidth: number;
|
|
174
|
-
windowHeight: number;
|
|
175
|
-
windowWidth: number;
|
|
176
|
-
};
|
|
193
|
+
type LocalizedMessage = Record<string, string> | string;
|
|
177
194
|
|
|
178
195
|
type SDKEvents = {
|
|
179
196
|
agentRequestUpdate: ["accepted" | "canceled" | "pending" | "unavailable"];
|
|
180
197
|
agentsAvailable: undefined;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
198
|
+
audioCallAccepted: undefined;
|
|
199
|
+
audioCallEnd: undefined;
|
|
200
|
+
audioCallStart: undefined;
|
|
184
201
|
connection: undefined;
|
|
185
202
|
connectionReset: undefined;
|
|
186
|
-
customMessage: [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
customMessage: [
|
|
204
|
+
{ observer: `cobrowsing_viewer_connection_${string}` } | { visitor: `cobrowsing_visitor_connection_${string}` },
|
|
205
|
+
Record<string, unknown>,
|
|
206
|
+
];
|
|
207
|
+
newObserver: [`cobrowsing_viewer_connection_${string}`, Viewer];
|
|
208
|
+
observerContentVisible: [`cobrowsing_viewer_connection_${string}`];
|
|
209
|
+
observerGone: [`cobrowsing_viewer_connection_${string}`];
|
|
190
210
|
observersCount: [number];
|
|
191
|
-
observerUpdate: [string
|
|
211
|
+
observerUpdate: [`cobrowsing_viewer_connection_${string}`, Partial<Viewer>];
|
|
192
212
|
sessionContinue: undefined;
|
|
193
213
|
sessionEnd: undefined;
|
|
194
214
|
sessionRequest: undefined;
|
|
@@ -212,4 +232,19 @@ type UpscopeStorageImplementation = {
|
|
|
212
232
|
setItem: (key: string, value: string) => Promise<void> | void;
|
|
213
233
|
};
|
|
214
234
|
|
|
235
|
+
type Viewer = {
|
|
236
|
+
audioStatus: "accepted" | "active" | "authorizing" | "off" | "ringing";
|
|
237
|
+
audioSupported: boolean;
|
|
238
|
+
connectionId: `cobrowsing_viewer_connection_${string}`;
|
|
239
|
+
externalId: "__UNKNOWN_ONPREM_EXTERNAL_VIEWER_ID__" | "__UNTRACKED__" | `ea_${string}` | `u_${string}`;
|
|
240
|
+
hasFocus: boolean;
|
|
241
|
+
keepsSessionAlive: boolean;
|
|
242
|
+
name: null | string;
|
|
243
|
+
screenHeight: number;
|
|
244
|
+
screenScale: number;
|
|
245
|
+
screenWidth: number;
|
|
246
|
+
windowHeight: number;
|
|
247
|
+
windowWidth: number;
|
|
248
|
+
};
|
|
249
|
+
|
|
215
250
|
export default function Upscope(...instruction: Instruction): void;
|
package/index.js
CHANGED
|
@@ -1,99 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _arrayWithoutHoles(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
|
-
}
|
|
9
|
-
function _iterableToArray(iter) {
|
|
10
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
-
}
|
|
12
|
-
function _nonIterableSpread() {
|
|
13
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
-
}
|
|
15
|
-
function _toConsumableArray(arr) {
|
|
16
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
17
|
-
}
|
|
18
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
19
|
-
if (!o) return;
|
|
20
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
21
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
|
-
}
|
|
26
|
-
var loadedWindows = new WeakSet();
|
|
27
|
-
var pendingInstructionsMap = new WeakMap();
|
|
28
|
-
var environment = window.__upscope__sdk__load__environment;
|
|
1
|
+
import { createStub, createUpscope, injectAccountScript } from "./sdk-core.js";
|
|
2
|
+
// Default/dynamic entrypoint (@upscopeio/sdk): the account script downloads the latest hosted
|
|
3
|
+
// SDK implementation from js.upscope.io, so the running version always tracks production.
|
|
29
4
|
function loadSDK(w, apiKey) {
|
|
30
|
-
if (typeof w.Upscope !== "undefined")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
var i = function i1() {
|
|
35
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
36
|
-
args[_key] = arguments[_key];
|
|
37
|
-
}
|
|
38
|
-
i.q.push(args);
|
|
39
|
-
};
|
|
40
|
-
i.q = [];
|
|
41
|
-
// The real Upscope implementation is loaded below
|
|
42
|
-
w.Upscope = i;
|
|
43
|
-
var s = w.document.createElement("script");
|
|
44
|
-
s.type = "text/javascript";
|
|
45
|
-
s.async = true;
|
|
46
|
-
var _;
|
|
47
|
-
s.src = (_ = ({
|
|
48
|
-
development: "http://code.upscope.local/".concat(apiKey, ".js"),
|
|
49
|
-
production: "https://code.upscope.io/".concat(apiKey, ".js"),
|
|
50
|
-
staging: "https://code.upscope.xyz/".concat(apiKey, ".js")
|
|
51
|
-
})[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://code.upscope.io/".concat(apiKey, ".js");
|
|
52
|
-
w.document.head.appendChild(s);
|
|
53
|
-
loadedWindows.add(w);
|
|
5
|
+
if (typeof w.Upscope !== "undefined") return;
|
|
6
|
+
createStub(w);
|
|
7
|
+
injectAccountScript(w, apiKey);
|
|
54
8
|
}
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
instruction[_key - 1] = arguments[_key];
|
|
58
|
-
}
|
|
59
|
-
var _w;
|
|
60
|
-
if (!loadedWindows.has(w)) {
|
|
61
|
-
if (instruction[0] === "init") {
|
|
62
|
-
var config = instruction[1];
|
|
63
|
-
if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
|
|
64
|
-
loadSDK(w, config.apiKey);
|
|
65
|
-
var pendingInstructions = pendingInstructionsMap.get(w);
|
|
66
|
-
if (pendingInstructions) {
|
|
67
|
-
pendingInstructionsMap.delete(w);
|
|
68
|
-
pendingInstructions.forEach(function(instruction) {
|
|
69
|
-
var _w;
|
|
70
|
-
(_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
} else if (instruction[0] === "on") {
|
|
74
|
-
var _pendingInstructionsMap_get;
|
|
75
|
-
pendingInstructionsMap.set(w, _toConsumableArray((_pendingInstructionsMap_get = pendingInstructionsMap.get(w)) !== null && _pendingInstructionsMap_get !== void 0 ? _pendingInstructionsMap_get : []).concat([
|
|
76
|
-
instruction
|
|
77
|
-
]));
|
|
78
|
-
return;
|
|
79
|
-
} else {
|
|
80
|
-
throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
(_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
|
|
84
|
-
};
|
|
85
|
-
export var upscopeFor = function upscopeFor(w) {
|
|
86
|
-
return function() {
|
|
87
|
-
for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
|
|
88
|
-
instruction[_key] = arguments[_key];
|
|
89
|
-
}
|
|
90
|
-
ScopedUpscope.apply(void 0, [
|
|
91
|
-
w
|
|
92
|
-
].concat(_toConsumableArray(instruction)));
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
var _Upscope = upscopeFor(window);
|
|
96
|
-
export default _Upscope;
|
|
9
|
+
export var upscopeFor = createUpscope(loadSDK);
|
|
10
|
+
export default upscopeFor(window);
|
|
97
11
|
|
|
98
12
|
|
|
99
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":[
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":["createStub","createUpscope","injectAccountScript","loadSDK","w","apiKey","Upscope","upscopeFor","window"],"mappings":"AAAA,SAASA,UAAU,EAAEC,aAAa,EAAEC,mBAAmB,QAAQ,gBAAgB;AAC/E,8FAA8F;AAC9F,0FAA0F;AAC1F,SAASC,QAAQC,CAAC,EAAEC,MAAM;IACtB,IAAI,OAAOD,EAAEE,OAAO,KAAK,aACrB;IACJN,WAAWI;IACXF,oBAAoBE,GAAGC;AAC3B;AACA,OAAO,IAAME,aAAaN,cAAcE,SAAS;AACjD,eAAeI,WAAWC,QAAQ","file":"index.js","sourcesContent":["import { createStub, createUpscope, injectAccountScript } from \"./sdk-core.js\";\n// Default/dynamic entrypoint (@upscopeio/sdk): the account script downloads the latest hosted\n// SDK implementation from js.upscope.io, so the running version always tracks production.\nfunction loadSDK(w, apiKey) {\n if (typeof w.Upscope !== \"undefined\")\n return;\n createStub(w);\n injectAccountScript(w, apiKey);\n}\nexport const upscopeFor = createUpscope(loadSDK);\nexport default upscopeFor(window);\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upscopeio/sdk",
|
|
3
3
|
"main": "index.js",
|
|
4
|
+
"types": "index.d.ts",
|
|
4
5
|
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./static": {
|
|
12
|
+
"types": "./static.d.ts",
|
|
13
|
+
"default": "./static.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"registry": "https://registry.npmjs.org",
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
5
20
|
"dependencies": {},
|
|
6
|
-
"version": "2026.
|
|
7
|
-
}
|
|
21
|
+
"version": "2026.6.16"
|
|
22
|
+
}
|
package/sdk-core.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array(iter) {
|
|
10
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
+
}
|
|
12
|
+
function _non_iterable_spread() {
|
|
13
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
+
}
|
|
15
|
+
function _to_consumable_array(arr) {
|
|
16
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
|
+
}
|
|
18
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
|
+
if (!o) return;
|
|
20
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
21
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
|
+
}
|
|
26
|
+
// URL of the per-account script (services/code/generator.ts) for the current environment. The
|
|
27
|
+
// script sets __defaultConfiguration/__defaultRegion on window.Upscope.
|
|
28
|
+
export function accountScriptUrl(apiKey) {
|
|
29
|
+
return "".concat(environmentOrigin("code"), "/").concat(apiKey, ".js");
|
|
30
|
+
}
|
|
31
|
+
// Creates the command-queue stub and installs it as w.Upscope. Commands pushed onto its queue
|
|
32
|
+
// are drained by the SDK implementation once it boots.
|
|
33
|
+
export function createStub(w) {
|
|
34
|
+
var i = function i1() {
|
|
35
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
36
|
+
args[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
i.q.push(args);
|
|
39
|
+
};
|
|
40
|
+
i.q = [];
|
|
41
|
+
w.Upscope = i;
|
|
42
|
+
return i;
|
|
43
|
+
}
|
|
44
|
+
// Builds the importable Upscope command function around a load strategy. "Loaded" is keyed off
|
|
45
|
+
// window.Upscope existing; Upscope("shutdown") deletes it, so the next "init" loads again.
|
|
46
|
+
export function createUpscope(loadSDK) {
|
|
47
|
+
var pendingInstructionsMap = new WeakMap();
|
|
48
|
+
var ScopedUpscope = function ScopedUpscope(w) {
|
|
49
|
+
for(var _len = arguments.length, instruction = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
50
|
+
instruction[_key - 1] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
var _w;
|
|
53
|
+
if (typeof w.Upscope === "undefined") {
|
|
54
|
+
if (instruction[0] === "init") {
|
|
55
|
+
var config = instruction[1];
|
|
56
|
+
if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
|
|
57
|
+
loadSDK(w, config.apiKey);
|
|
58
|
+
var pendingInstructions = pendingInstructionsMap.get(w);
|
|
59
|
+
if (pendingInstructions) {
|
|
60
|
+
pendingInstructionsMap.delete(w);
|
|
61
|
+
pendingInstructions.forEach(function(instruction) {
|
|
62
|
+
var _w;
|
|
63
|
+
(_w = w).Upscope.apply(_w, _to_consumable_array(instruction));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} else if (instruction[0] === "on") {
|
|
67
|
+
var _pendingInstructionsMap_get;
|
|
68
|
+
pendingInstructionsMap.set(w, _to_consumable_array((_pendingInstructionsMap_get = pendingInstructionsMap.get(w)) !== null && _pendingInstructionsMap_get !== void 0 ? _pendingInstructionsMap_get : []).concat([
|
|
69
|
+
instruction
|
|
70
|
+
]));
|
|
71
|
+
return;
|
|
72
|
+
} else {
|
|
73
|
+
throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
(_w = w).Upscope.apply(_w, _to_consumable_array(instruction));
|
|
77
|
+
};
|
|
78
|
+
return function(w) {
|
|
79
|
+
return function() {
|
|
80
|
+
for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
|
|
81
|
+
instruction[_key] = arguments[_key];
|
|
82
|
+
}
|
|
83
|
+
ScopedUpscope.apply(void 0, [
|
|
84
|
+
w
|
|
85
|
+
].concat(_to_consumable_array(instruction)));
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Resolves a "<subdomain>.upscope.<tld>" origin for the current load environment, matching the
|
|
90
|
+
// hosting convention shared by code/js/sdkconfig (e.g. https://code.upscope.io in production).
|
|
91
|
+
export function environmentOrigin(subdomain) {
|
|
92
|
+
var _;
|
|
93
|
+
var environment = window.__upscope__sdk__load__environment;
|
|
94
|
+
return (_ = ({
|
|
95
|
+
development: "http://".concat(subdomain, ".upscope.local"),
|
|
96
|
+
production: "https://".concat(subdomain, ".upscope.io"),
|
|
97
|
+
staging: "https://".concat(subdomain, ".upscope.xyz")
|
|
98
|
+
})[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://".concat(subdomain, ".upscope.io");
|
|
99
|
+
}
|
|
100
|
+
// Injects the per-account script. Optional handlers let the static entry boot its bundled
|
|
101
|
+
// implementation once the configuration has arrived.
|
|
102
|
+
export function injectAccountScript(w, apiKey) {
|
|
103
|
+
var handlers = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
104
|
+
var s = w.document.createElement("script");
|
|
105
|
+
s.type = "text/javascript";
|
|
106
|
+
s.async = true;
|
|
107
|
+
s.src = accountScriptUrl(apiKey);
|
|
108
|
+
if (handlers.onLoad) s.onload = handlers.onLoad;
|
|
109
|
+
if (handlers.onError) s.onerror = handlers.onError;
|
|
110
|
+
w.document.head.appendChild(s);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=sdk-core.js.map
|
package/sdk-core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["sdk-core.js"],"names":["accountScriptUrl","apiKey","environmentOrigin","createStub","w","i","args","q","push","Upscope","createUpscope","loadSDK","pendingInstructionsMap","WeakMap","ScopedUpscope","instruction","config","Error","pendingInstructions","get","delete","forEach","set","subdomain","environment","window","__upscope__sdk__load__environment","development","production","staging","injectAccountScript","handlers","s","document","createElement","type","async","src","onLoad","onload","onError","onerror","head","appendChild"],"mappings":"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","file":"sdk-core.js","sourcesContent":["// URL of the per-account script (services/code/generator.ts) for the current environment. The\n// script sets __defaultConfiguration/__defaultRegion on window.Upscope.\nexport function accountScriptUrl(apiKey) {\n return `${environmentOrigin(\"code\")}/${apiKey}.js`;\n}\n// Creates the command-queue stub and installs it as w.Upscope. Commands pushed onto its queue\n// are drained by the SDK implementation once it boots.\nexport function createStub(w) {\n const i = function (...args) {\n i.q.push(args);\n };\n i.q = [];\n w.Upscope = i;\n return i;\n}\n// Builds the importable Upscope command function around a load strategy. \"Loaded\" is keyed off\n// window.Upscope existing; Upscope(\"shutdown\") deletes it, so the next \"init\" loads again.\nexport function createUpscope(loadSDK) {\n const pendingInstructionsMap = new WeakMap();\n const ScopedUpscope = function (w, ...instruction) {\n if (typeof w.Upscope === \"undefined\") {\n if (instruction[0] === \"init\") {\n const config = instruction[1];\n if (!config?.apiKey)\n throw new Error(\"API key not specified\");\n loadSDK(w, config.apiKey);\n const pendingInstructions = pendingInstructionsMap.get(w);\n if (pendingInstructions) {\n pendingInstructionsMap.delete(w);\n pendingInstructions.forEach((instruction) => {\n w.Upscope(...instruction);\n });\n }\n }\n else if (instruction[0] === \"on\") {\n pendingInstructionsMap.set(w, [...(pendingInstructionsMap.get(w) ?? []), instruction]);\n return;\n }\n else {\n throw new Error('Upscope is not loaded yet. Please call \"init\" as your first command.');\n }\n }\n w.Upscope(...instruction);\n };\n return function (w) {\n return (...instruction) => {\n ScopedUpscope(w, ...instruction);\n };\n };\n}\n// Resolves a \"<subdomain>.upscope.<tld>\" origin for the current load environment, matching the\n// hosting convention shared by code/js/sdkconfig (e.g. https://code.upscope.io in production).\nexport function environmentOrigin(subdomain) {\n const environment = window.__upscope__sdk__load__environment;\n return ({\n development: `http://${subdomain}.upscope.local`,\n production: `https://${subdomain}.upscope.io`,\n staging: `https://${subdomain}.upscope.xyz`,\n }[environment ?? \"production\"] ?? `https://${subdomain}.upscope.io`);\n}\n// Injects the per-account script. Optional handlers let the static entry boot its bundled\n// implementation once the configuration has arrived.\nexport function injectAccountScript(w, apiKey, handlers = {}) {\n const s = w.document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src = accountScriptUrl(apiKey);\n if (handlers.onLoad)\n s.onload = handlers.onLoad;\n if (handlers.onError)\n s.onerror = handlers.onError;\n w.document.head.appendChild(s);\n}\n"]}
|