@upscopeio/sdk 2025.12.5 → 2025.12.7
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 +9 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
25
|
}
|
|
26
26
|
var loadedWindows = new WeakSet();
|
|
27
|
+
var environment = window.__upscope__sdk__load__environment;
|
|
27
28
|
function loadSDK(w, apiKey) {
|
|
28
29
|
if (typeof w.Upscope !== "undefined") {
|
|
29
30
|
loadedWindows.add(w);
|
|
@@ -41,7 +42,12 @@ function loadSDK(w, apiKey) {
|
|
|
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
|
}
|
|
@@ -55,8 +61,8 @@ var ScopedUpscope = function ScopedUpscope(w) {
|
|
|
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
63
|
loadSDK(w, config.apiKey);
|
|
58
|
-
} else {
|
|
59
|
-
throw new Error(
|
|
64
|
+
} else if (instruction[0] !== "on") {
|
|
65
|
+
throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
68
|
(_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,gBAAgB,IAAI;AAC1B,SAAS,QAAQ,CAAC,EAAE,MAAM,EAAE;IACxB,IAAI,OAAO,EAAE,OAAO,KAAK,aAAa;QAClC,cAAc,GAAG,CAAC;QAClB;IACJ,CAAC;IACD,IAAM,IAAI,SAAJ,KAAuB;QAAT,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,OAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;YAAG,KAAH,QAAA,SAAA,CAAA,KAAO;QAAD;QACtB,EAAE,CAAC,CAAC,IAAI,CAAC;IACb;IACA,EAAE,CAAC,GAAG,EAAE;IACR,kDAAkD;IAClD,EAAE,OAAO,GAAG;IACZ,IAAM,IAAI,SAAS,aAAa,CAAC;IACjC,EAAE,IAAI,GAAG;IACT,EAAE,KAAK,GAAG,IAAI;
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,gBAAgB,IAAI;AAC1B,IAAM,cAAc,OAAO,iCAAiC;AAC5D,SAAS,QAAQ,CAAC,EAAE,MAAM,EAAE;IACxB,IAAI,OAAO,EAAE,OAAO,KAAK,aAAa;QAClC,cAAc,GAAG,CAAC;QAClB;IACJ,CAAC;IACD,IAAM,IAAI,SAAJ,KAAuB;QAAT,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,OAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;YAAG,KAAH,QAAA,SAAA,CAAA,KAAO;QAAD;QACtB,EAAE,CAAC,CAAC,IAAI,CAAC;IACb;IACA,EAAE,C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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 if (instruction[0] !== \"on\") {\n throw new Error('Upscope is not loaded yet. Please call \"init\" as your first command.');\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