@upscopeio/sdk 2026.6.15 → 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/static.js ADDED
@@ -0,0 +1,275 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _object_spread_props(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ function _ts_generator(thisArg, body) {
83
+ var f, y, t, _ = {
84
+ label: 0,
85
+ sent: function() {
86
+ if (t[0] & 1) throw t[1];
87
+ return t[1];
88
+ },
89
+ trys: [],
90
+ ops: []
91
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
92
+ return d(g, "next", {
93
+ value: verb(0)
94
+ }), d(g, "throw", {
95
+ value: verb(1)
96
+ }), d(g, "return", {
97
+ value: verb(2)
98
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
99
+ value: function() {
100
+ return this;
101
+ }
102
+ }), g;
103
+ function verb(n) {
104
+ return function(v) {
105
+ return step([
106
+ n,
107
+ v
108
+ ]);
109
+ };
110
+ }
111
+ function step(op) {
112
+ if (f) throw new TypeError("Generator is already executing.");
113
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
114
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
115
+ if (y = 0, t) op = [
116
+ op[0] & 2,
117
+ t.value
118
+ ];
119
+ switch(op[0]){
120
+ case 0:
121
+ case 1:
122
+ t = op;
123
+ break;
124
+ case 4:
125
+ _.label++;
126
+ return {
127
+ value: op[1],
128
+ done: false
129
+ };
130
+ case 5:
131
+ _.label++;
132
+ y = op[1];
133
+ op = [
134
+ 0
135
+ ];
136
+ continue;
137
+ case 7:
138
+ op = _.ops.pop();
139
+ _.trys.pop();
140
+ continue;
141
+ default:
142
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
143
+ _ = 0;
144
+ continue;
145
+ }
146
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
147
+ _.label = op[1];
148
+ break;
149
+ }
150
+ if (op[0] === 6 && _.label < t[1]) {
151
+ _.label = t[1];
152
+ t = op;
153
+ break;
154
+ }
155
+ if (t && _.label < t[2]) {
156
+ _.label = t[2];
157
+ _.ops.push(op);
158
+ break;
159
+ }
160
+ if (t[2]) _.ops.pop();
161
+ _.trys.pop();
162
+ continue;
163
+ }
164
+ op = body.call(thisArg, _);
165
+ } catch (e) {
166
+ op = [
167
+ 6,
168
+ e
169
+ ];
170
+ y = 0;
171
+ } finally{
172
+ f = t = 0;
173
+ }
174
+ if (op[0] & 5) throw op[1];
175
+ return {
176
+ value: op[0] ? op[1] : void 0,
177
+ done: true
178
+ };
179
+ }
180
+ }
181
+ import { bootUpscope } from "./bundled-upscope.js";
182
+ import { createStub, createUpscope, environmentOrigin } from "./sdk-core.js";
183
+ // Replaced with the package version at publish time (finish-npm-packages.sh) so the config
184
+ // endpoint returns a configuration shape compatible with this exact (pinned) SDK version.
185
+ var VERSION = "2026.6.16";
186
+ // Static entrypoint (@upscopeio/sdk/static): the SDK implementation is bundled in this package,
187
+ // so the running version is pinned to the installed package version. It fetches only the account
188
+ // configuration (works on websites and in MV3 extensions — no remote code execution) and boots
189
+ // the bundled implementation once that configuration has arrived.
190
+ function loadSDK(w, apiKey) {
191
+ if (typeof w.Upscope !== "undefined") return;
192
+ var stub = createStub(w);
193
+ void loadStaticSDK(w, stub, apiKey);
194
+ }
195
+ function loadStaticSDK(w, stub, apiKey) {
196
+ return _async_to_generator(function() {
197
+ var response, config, error;
198
+ return _ts_generator(this, function(_state) {
199
+ switch(_state.label){
200
+ case 0:
201
+ _state.trys.push([
202
+ 0,
203
+ 3,
204
+ ,
205
+ 4
206
+ ]);
207
+ return [
208
+ 4,
209
+ fetch(sdkConfigUrl(apiKey))
210
+ ];
211
+ case 1:
212
+ response = _state.sent();
213
+ if (!response.ok) throw new Error("Configuration request failed with status ".concat(response.status));
214
+ return [
215
+ 4,
216
+ response.json()
217
+ ];
218
+ case 2:
219
+ config = _state.sent();
220
+ // The same account states the generated {apiKey}.js script reports today.
221
+ if (!config.exists) {
222
+ console.error("[Upscope] We could not find a bucket for api key ".concat(apiKey));
223
+ return [
224
+ 2
225
+ ];
226
+ }
227
+ if (config.expired) {
228
+ console.error("[Upscope] Your Upscope subscription has expired. Please upgrade now: https://upscope.io/purchase");
229
+ return [
230
+ 2
231
+ ];
232
+ }
233
+ if (!config.collectData) {
234
+ console.error("[Upscope] You have exceeded your Upscope subscription usage limits. We will collect data again once usage falls back within your subscription's limits.");
235
+ return [
236
+ 2
237
+ ];
238
+ }
239
+ // "shutdown" (or a fresh "init") may have replaced the stub while the config was loading.
240
+ // eslint-disable-next-line upscope/no-direct-object-comparison
241
+ if (w.Upscope !== stub) return [
242
+ 2
243
+ ];
244
+ stub.__defaultConfiguration = _object_spread_props(_object_spread({}, config.settings), {
245
+ apiKey: apiKey
246
+ });
247
+ stub.__defaultRegion = config.defaultRegion;
248
+ bootUpscope(w, stub);
249
+ return [
250
+ 3,
251
+ 4
252
+ ];
253
+ case 3:
254
+ error = _state.sent();
255
+ console.error("[Upscope] Could not load the Upscope configuration", error);
256
+ return [
257
+ 3,
258
+ 4
259
+ ];
260
+ case 4:
261
+ return [
262
+ 2
263
+ ];
264
+ }
265
+ });
266
+ })();
267
+ }
268
+ function sdkConfigUrl(apiKey) {
269
+ return "".concat(environmentOrigin("sdkconfig"), "/").concat(encodeURIComponent(apiKey), ".json?sdk=web&version=").concat(encodeURIComponent(VERSION));
270
+ }
271
+ export var upscopeFor = createUpscope(loadSDK);
272
+ export default upscopeFor(window);
273
+
274
+
275
+ //# sourceMappingURL=static.js.map
package/static.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["static.js"],"names":["bootUpscope","createStub","createUpscope","environmentOrigin","VERSION","loadSDK","w","apiKey","Upscope","stub","loadStaticSDK","response","config","error","fetch","sdkConfigUrl","ok","Error","status","json","exists","console","expired","collectData","__defaultConfiguration","settings","__defaultRegion","defaultRegion","encodeURIComponent","upscopeFor","window"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,WAAW,QAAQ,uBAAuB;AACnD,SAASC,UAAU,EAAEC,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AAC7E,2FAA2F;AAC3F,0FAA0F;AAC1F,IAAMC,UAAU;AAChB,gGAAgG;AAChG,iGAAiG;AACjG,+FAA+F;AAC/F,kEAAkE;AAClE,SAASC,QAAQC,CAAC,EAAEC,MAAM;IACtB,IAAI,OAAOD,EAAEE,OAAO,KAAK,aACrB;IACJ,IAAMC,OAAOR,WAAWK;IACxB,KAAKI,cAAcJ,GAAGG,MAAMF;AAChC;AACA,SAAeG,cAAcJ,CAAC,EAAEG,IAAI,EAAEF,MAAM;;YAE9BI,UAGAC,QAsBHC;;;;;;;;;;oBAzBc;;wBAAMC,MAAMC,aAAaR;;;oBAApCI,WAAW;oBACjB,IAAI,CAACA,SAASK,EAAE,EACZ,MAAM,IAAIC,MAAM,AAAC,4CAA2D,OAAhBN,SAASO,MAAM;oBAC/D;;wBAAMP,SAASQ,IAAI;;;oBAA7BP,SAAU;oBAChB,0EAA0E;oBAC1E,IAAI,CAACA,OAAOQ,MAAM,EAAE;wBAChBC,QAAQR,KAAK,CAAC,AAAC,oDAA0D,OAAPN;wBAClE;;;oBACJ;oBACA,IAAIK,OAAOU,OAAO,EAAE;wBAChBD,QAAQR,KAAK,CAAC;wBACd;;;oBACJ;oBACA,IAAI,CAACD,OAAOW,WAAW,EAAE;wBACrBF,QAAQR,KAAK,CAAC;wBACd;;;oBACJ;oBACA,0FAA0F;oBAC1F,+DAA+D;oBAC/D,IAAIP,EAAEE,OAAO,KAAKC,MACd;;;oBACJA,KAAKe,sBAAsB,GAAG,wCAAKZ,OAAOa,QAAQ;wBAAElB,QAAAA;;oBACpDE,KAAKiB,eAAe,GAAGd,OAAOe,aAAa;oBAC3C3B,YAAYM,GAAGG;;;;;;oBAEZI;oBACHQ,QAAQR,KAAK,CAAC,sDAAsDA;;;;;;;;;;;IAE5E;;AACA,SAASE,aAAaR,MAAM;IACxB,OAAO,AAAC,GAAoCqB,OAAlCzB,kBAAkB,cAAa,KAAsDyB,OAAnDA,mBAAmBrB,SAAQ,0BAAoD,OAA5BqB,mBAAmBxB;AACtH;AACA,OAAO,IAAMyB,aAAa3B,cAAcG,SAAS;AACjD,eAAewB,WAAWC,QAAQ","file":"static.js","sourcesContent":["import { bootUpscope } from \"./bundled-upscope.js\";\nimport { createStub, createUpscope, environmentOrigin } from \"./sdk-core.js\";\n// Replaced with the package version at publish time (finish-npm-packages.sh) so the config\n// endpoint returns a configuration shape compatible with this exact (pinned) SDK version.\nconst VERSION = \"2026.6.16\";\n// Static entrypoint (@upscopeio/sdk/static): the SDK implementation is bundled in this package,\n// so the running version is pinned to the installed package version. It fetches only the account\n// configuration (works on websites and in MV3 extensions — no remote code execution) and boots\n// the bundled implementation once that configuration has arrived.\nfunction loadSDK(w, apiKey) {\n if (typeof w.Upscope !== \"undefined\")\n return;\n const stub = createStub(w);\n void loadStaticSDK(w, stub, apiKey);\n}\nasync function loadStaticSDK(w, stub, apiKey) {\n try {\n const response = await fetch(sdkConfigUrl(apiKey));\n if (!response.ok)\n throw new Error(`Configuration request failed with status ${response.status}`);\n const config = (await response.json());\n // The same account states the generated {apiKey}.js script reports today.\n if (!config.exists) {\n console.error(`[Upscope] We could not find a bucket for api key ${apiKey}`);\n return;\n }\n if (config.expired) {\n console.error(\"[Upscope] Your Upscope subscription has expired. Please upgrade now: https://upscope.io/purchase\");\n return;\n }\n if (!config.collectData) {\n console.error(\"[Upscope] You have exceeded your Upscope subscription usage limits. We will collect data again once usage falls back within your subscription's limits.\");\n return;\n }\n // \"shutdown\" (or a fresh \"init\") may have replaced the stub while the config was loading.\n // eslint-disable-next-line upscope/no-direct-object-comparison\n if (w.Upscope !== stub)\n return;\n stub.__defaultConfiguration = { ...config.settings, apiKey };\n stub.__defaultRegion = config.defaultRegion;\n bootUpscope(w, stub);\n }\n catch (error) {\n console.error(\"[Upscope] Could not load the Upscope configuration\", error);\n }\n}\nfunction sdkConfigUrl(apiKey) {\n return `${environmentOrigin(\"sdkconfig\")}/${encodeURIComponent(apiKey)}.json?sdk=web&version=${encodeURIComponent(VERSION)}`;\n}\nexport const upscopeFor = createUpscope(loadSDK);\nexport default upscopeFor(window);\n"]}