@upscopeio/sdk 2025.11.12 → 2025.12.5

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 (3) hide show
  1. package/index.js +24 -13
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -23,10 +23,10 @@ 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 loaded = false;
27
- function loadSDK(apiKey) {
28
- if (typeof window.Upscope !== "undefined") {
29
- loaded = true;
26
+ var loadedWindows = new WeakSet();
27
+ function loadSDK(w, apiKey) {
28
+ if (typeof w.Upscope !== "undefined") {
29
+ loadedWindows.add(w);
30
30
  return;
31
31
  }
32
32
  var i = function i1() {
@@ -37,30 +37,41 @@ function loadSDK(apiKey) {
37
37
  };
38
38
  i.q = [];
39
39
  // The real Upscope implementation is loaded below
40
- window.Upscope = i;
40
+ w.Upscope = i;
41
41
  var s = document.createElement("script");
42
42
  s.type = "text/javascript";
43
43
  s.async = true;
44
44
  s.src = "https://code.upscope.io/".concat(apiKey, ".js");
45
45
  document.head.appendChild(s);
46
- loaded = true;
46
+ loadedWindows.add(w);
47
47
  }
48
- var _Upscope = function _Upscope() {
49
- for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
50
- instruction[_key] = arguments[_key];
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
51
  }
52
- var _window;
53
- if (!loaded) {
52
+ var _w;
53
+ if (!loadedWindows.has(w)) {
54
54
  if (instruction[0] === "init") {
55
55
  var config = instruction[1];
56
56
  if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
57
- loadSDK(config.apiKey);
57
+ loadSDK(w, config.apiKey);
58
58
  } else {
59
59
  throw new Error("Upscope is not loaded");
60
60
  }
61
61
  }
62
- return (_window = window).Upscope.apply(_window, _toConsumableArray(instruction));
62
+ (_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
63
63
  };
64
+ export var upscopeFor = function upscopeFor(w) {
65
+ return function() {
66
+ for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
67
+ instruction[_key] = arguments[_key];
68
+ }
69
+ ScopedUpscope.apply(void 0, [
70
+ w
71
+ ].concat(_toConsumableArray(instruction)));
72
+ };
73
+ };
74
+ var _Upscope = upscopeFor(window);
64
75
  export default _Upscope;
65
76
 
66
77
 
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,KAAK;AAClB,SAAS,QAAQ,MAAM,EAAE;IACrB,IAAI,OAAO,OAAO,OAAO,KAAK,aAAa;QACvC,SAAS,IAAI;QACb;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,OAAO,OAAO,GAAG;IACjB,IAAM,IAAI,SAAS,aAAa,CAAC;IACjC,EAAE,IAAI,GAAG;IACT,EAAE,KAAK,GAAG,IAAI;IACd,EAAE,GAAG,GAAG,AAAC,2BAAiC,OAAP,QAAO;IAC1C,SAAS,IAAI,CAAC,WAAW,CAAC;IAC1B,SAAS,IAAI;AACjB;AACA,IAAM,WAAW,SAAX,WAAqC;IAAhB,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,cAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;QAAG,YAAH,QAAA,SAAA,CAAA,KAAc;IAAD;QAY7B;IAXP,IAAI,CAAC,QAAQ;QACT,IAAI,WAAW,CAAC,EAAE,KAAK,QAAQ;YAC3B,IAAM,SAAS,WAAW,CAAC,EAAE;YAC7B,IAAI,CAAC,CAAA,mBAAA,oBAAA,KAAA,IAAA,OAAQ,MAAK,AAAC,GACf,MAAM,IAAI,MAAM,yBAAyB;YAC7C,QAAQ,OAAO,MAAM;QACzB,OACK;YACD,MAAM,IAAI,MAAM,yBAAyB;QAC7C,CAAC;IACL,CAAC;IACD,OAAO,CAAA,UAAA,QAAO,OAAO,CAAd,MAAA,SAAe,mBAAG;AAC7B;AACA,eAAe,SAAS","file":"index.js","sourcesContent":["let loaded = false;\nfunction loadSDK(apiKey) {\n if (typeof window.Upscope !== \"undefined\") {\n loaded = true;\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 window.Upscope = i;\n const s = document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src = `https://code.upscope.io/${apiKey}.js`;\n document.head.appendChild(s);\n loaded = true;\n}\nconst _Upscope = function (...instruction) {\n if (!loaded) {\n if (instruction[0] === \"init\") {\n const config = instruction[1];\n if (!config?.apiKey)\n throw new Error(\"API key not specified\");\n loadSDK(config.apiKey);\n }\n else {\n throw new Error(\"Upscope is not loaded\");\n }\n }\n return window.Upscope(...instruction);\n};\nexport default _Upscope;\n"]}
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;Q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AW;AAC5B,eAAe,SAAS","file":"index.js","sourcesContent":["const loadedWindows = new WeakSet();\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 = `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
@@ -3,5 +3,5 @@
3
3
  "main": "index.js",
4
4
  "type": "module",
5
5
  "dependencies": {},
6
- "version": "2025.11.12"
6
+ "version": "2025.12.5"
7
7
  }