@upscopeio/sdk 2025.11.12 → 2025.12.6
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/index.js +31 -14
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -23,10 +23,11 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
23
23
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
25
|
}
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
var loadedWindows = new WeakSet();
|
|
27
|
+
var environment = window.__upscope__sdk__load__environment;
|
|
28
|
+
function loadSDK(w, apiKey) {
|
|
29
|
+
if (typeof w.Upscope !== "undefined") {
|
|
30
|
+
loadedWindows.add(w);
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
var i = function i1() {
|
|
@@ -37,30 +38,46 @@ function loadSDK(apiKey) {
|
|
|
37
38
|
};
|
|
38
39
|
i.q = [];
|
|
39
40
|
// The real Upscope implementation is loaded below
|
|
40
|
-
|
|
41
|
+
w.Upscope = i;
|
|
41
42
|
var s = document.createElement("script");
|
|
42
43
|
s.type = "text/javascript";
|
|
43
44
|
s.async = true;
|
|
44
|
-
|
|
45
|
+
var _;
|
|
46
|
+
s.src = (_ = ({
|
|
47
|
+
development: "http://code.upscope.local/".concat(apiKey, ".js"),
|
|
48
|
+
production: "https://code.upscope.io/".concat(apiKey, ".js"),
|
|
49
|
+
staging: "https://code.upscope.xyz/".concat(apiKey, ".js")
|
|
50
|
+
})[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://code.upscope.io/".concat(apiKey, ".js");
|
|
45
51
|
document.head.appendChild(s);
|
|
46
|
-
|
|
52
|
+
loadedWindows.add(w);
|
|
47
53
|
}
|
|
48
|
-
var
|
|
49
|
-
for(var _len = arguments.length, instruction = new Array(_len), _key =
|
|
50
|
-
instruction[_key] = arguments[_key];
|
|
54
|
+
var ScopedUpscope = function ScopedUpscope(w) {
|
|
55
|
+
for(var _len = arguments.length, instruction = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
56
|
+
instruction[_key - 1] = arguments[_key];
|
|
51
57
|
}
|
|
52
|
-
var
|
|
53
|
-
if (!
|
|
58
|
+
var _w;
|
|
59
|
+
if (!loadedWindows.has(w)) {
|
|
54
60
|
if (instruction[0] === "init") {
|
|
55
61
|
var config = instruction[1];
|
|
56
62
|
if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
|
|
57
|
-
loadSDK(config.apiKey);
|
|
63
|
+
loadSDK(w, config.apiKey);
|
|
58
64
|
} else {
|
|
59
65
|
throw new Error("Upscope is not loaded");
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
(_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
|
|
63
69
|
};
|
|
70
|
+
export var upscopeFor = function upscopeFor(w) {
|
|
71
|
+
return function() {
|
|
72
|
+
for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
|
|
73
|
+
instruction[_key] = arguments[_key];
|
|
74
|
+
}
|
|
75
|
+
ScopedUpscope.apply(void 0, [
|
|
76
|
+
w
|
|
77
|
+
].concat(_toConsumableArray(instruction)));
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var _Upscope = upscopeFor(window);
|
|
64
81
|
export default _Upscope;
|
|
65
82
|
|
|
66
83
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;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AC7B,IAAI,CAAC,CAAA,mBAAA,oBAAA,KAAA,IAAA,OAAQ,MAAK,AAAC,GACf,MAAM,IAAI,MAAM,yBAAyB;YAC7C,QAAQ,GAAG,OAAO,MAAM;QAC5B,OACK;YACD,MAAM,IAAI,MAAM,yBAAyB;QAC7C,CAAC;IACL,CAAC;IACD,CAAA,KAAA,GAAE,OAAO,CAAT,MAAA,IAAU,mBAAG;AACjB;AACA,OAAO,IAAM,aAAa,SAAb,WAAuB,CAAC,EAAE;IACnC,OAAO,WAAoB;yCAAhB;YAAA;;QACP,cAAA,MAAA,KAAA,GAAA;YAAc;SAAkB,CAAhC,OAAiB,mBAAG;IACxB;AACJ,EAAE;AACF,IAAM,WAAW,WAAW;AAC5B,eAAe,SAAS","file":"index.js","sourcesContent":["const loadedWindows = new WeakSet();\nconst environment = window.__upscope__sdk__load__environment;\nfunction loadSDK(w, apiKey) {\n if (typeof w.Upscope !== \"undefined\") {\n loadedWindows.add(w);\n return;\n }\n const i = function (...args) {\n i.q.push(args);\n };\n i.q = [];\n // The real Upscope implementation is loaded below\n w.Upscope = i;\n const s = document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src =\n {\n development: `http://code.upscope.local/${apiKey}.js`,\n production: `https://code.upscope.io/${apiKey}.js`,\n staging: `https://code.upscope.xyz/${apiKey}.js`,\n }[environment ?? \"production\"] ?? `https://code.upscope.io/${apiKey}.js`;\n document.head.appendChild(s);\n loadedWindows.add(w);\n}\nconst ScopedUpscope = function (w, ...instruction) {\n if (!loadedWindows.has(w)) {\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 }\n else {\n throw new Error(\"Upscope is not loaded\");\n }\n }\n w.Upscope(...instruction);\n};\nexport const upscopeFor = function (w) {\n return (...instruction) => {\n ScopedUpscope(w, ...instruction);\n };\n};\nconst _Upscope = upscopeFor(window);\nexport default _Upscope;\n"]}
|
package/package.json
CHANGED