@upscopeio/react 2025.12.7 → 2025.12.9

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/package.json +1 -1
  2. package/sdk.js +18 -3
  3. package/sdk.js.map +1 -1
package/package.json CHANGED
@@ -9,5 +9,5 @@
9
9
  "react": ">=16.2.0",
10
10
  "react-dom": ">=16.2.0"
11
11
  },
12
- "version": "2025.12.7"
12
+ "version": "2025.12.9"
13
13
  }
package/sdk.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 pendingInstructionsMap = new WeakMap();
27
28
  var environment = window.__upscope__sdk__load__environment;
28
29
  function loadSDK(w, apiKey) {
29
30
  if (typeof w.Upscope !== "undefined") {
@@ -39,7 +40,7 @@ function loadSDK(w, apiKey) {
39
40
  i.q = [];
40
41
  // The real Upscope implementation is loaded below
41
42
  w.Upscope = i;
42
- var s = document.createElement("script");
43
+ var s = w.document.createElement("script");
43
44
  s.type = "text/javascript";
44
45
  s.async = true;
45
46
  var _;
@@ -48,7 +49,7 @@ function loadSDK(w, apiKey) {
48
49
  production: "https://code.upscope.io/".concat(apiKey, ".js"),
49
50
  staging: "https://code.upscope.xyz/".concat(apiKey, ".js")
50
51
  })[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://code.upscope.io/".concat(apiKey, ".js");
51
- document.head.appendChild(s);
52
+ w.document.head.appendChild(s);
52
53
  loadedWindows.add(w);
53
54
  }
54
55
  var ScopedUpscope = function ScopedUpscope(w) {
@@ -61,7 +62,21 @@ var ScopedUpscope = function ScopedUpscope(w) {
61
62
  var config = instruction[1];
62
63
  if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
63
64
  loadSDK(w, config.apiKey);
64
- } else if (instruction[0] !== "on") {
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 {
65
80
  throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
66
81
  }
67
82
  }
package/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["sdk.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,CAAC,GAAG,EAAE;IACR,kDAAkD;IAClD,EAAE,OAAO,GAAG;IACZ,IAAM,IAAI,SAAS,aAAa,CAAC;IACjC,EAAE,IAAI,GAAG;IACT,EAAE,KAAK,GAAG,IAAI;QAEV;IADJ,EAAE,GAAG,GACD,CAAA,IAAA,CAAA;QACI,aAAa,AAAC,6BAAmC,OAAP,QAAO;QACjD,YAAY,AAAC,2BAAiC,OAAP,QAAO;QAC9C,SAAS,AAAC,4BAAkC,OAAP,QAAO;IAChD,CAAA,CAAC,CAAC,wBAAA,yBAAA,cAAe,YAAY,CAAC,cAJ9B,eAAA,IAIkC,AAAC,2BAAiC,OAAP,QAAO,MAAI;IAC5E,SAAS,IAAI,CAAC,WAAW,CAAC;IAC1B,cAAc,GAAG,CAAC;AACtB;AACA,IAAM,gBAAgB,SAAhB,cAA0B,CAAC,EAAkB;IAAhB,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,cAAH,UAAA,OAAA,IAAA,OAAA,KAAc,GAAd,OAAA,GAAA,OAAA,MAAA,OAAA;QAAG,YAAH,OAAA,KAAA,SAAA,CAAA,KAAc;IAAD;QAY5C;IAXA,IAAI,CAAC,cAAc,GAAG,CAAC,IAAI;QACvB,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,GAAG,OAAO,MAAM;QAC5B,OACK,IAAI,WAAW,CAAC,EAAE,KAAK,MAAM;YAC9B,MAAM,IAAI,MAAM,wEAAwE;QAC5F,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":"sdk.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"]}
1
+ {"version":3,"sources":["sdk.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,gBAAgB,IAAI;AAC1B,IAAM,yBAAyB,IAAI;AACnC,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,CAAC,GAAG,EAAE;IACR,kDAAkD;IAClD,EAAE,OAAO,GAAG;IACZ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AAC,mBAAI,CAAA,8BAAA,uBAAuB,GAAG,CAAC,gBAA3B,yCAAA,8BAAiC,EAAE,SAAxC;gBAA2C;aAAY;YACrF;QACJ,OACK;YACD,MAAM,IAAI,MAAM,wEAAwE;QAC5F,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":"sdk.js","sourcesContent":["const loadedWindows = new WeakSet();\nconst pendingInstructionsMap = new WeakMap();\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 = w.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 w.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 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};\nexport const upscopeFor = function (w) {\n return (...instruction) => {\n ScopedUpscope(w, ...instruction);\n };\n};\nconst _Upscope = upscopeFor(window);\nexport default _Upscope;\n"]}