@wix/astro 0.0.1-experimental-react-component → 0.0.1-experimental

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 (71) hide show
  1. package/build/fsevents-X6WP4TKM.node +0 -0
  2. package/build/index.d.ts +3 -2
  3. package/build/index.js +17329 -26
  4. package/build/index.js.map +1 -1
  5. package/build-browser-runtime/setup.d.ts +5 -0
  6. package/build-browser-runtime/setup.js +963 -0
  7. package/build-runtime/auth.d.ts +5 -0
  8. package/build-runtime/auth.js +3557 -0
  9. package/build-runtime/chunk-24J7STEA.js +8 -0
  10. package/build-runtime/chunk-B6RICTPP.js +94 -0
  11. package/build-runtime/chunk-C3QOE2TZ.js +7 -0
  12. package/build-runtime/chunk-EK7YZVWJ.js +353 -0
  13. package/build-runtime/chunk-FR26HCAT.js +471 -0
  14. package/build-runtime/chunk-HDTWPOIV.js +811 -0
  15. package/build-runtime/chunk-HPW4ZAEJ.js +23 -0
  16. package/build-runtime/chunk-JODQ44LE.js +1079 -0
  17. package/build-runtime/chunk-MLKGABMK.js +9 -0
  18. package/build-runtime/chunk-NVTQFGTR.js +7 -0
  19. package/build-runtime/chunk-PSHIUVP2.js +131 -0
  20. package/build-runtime/chunk-Q3KPY4P2.js +3104 -0
  21. package/build-runtime/chunk-QRPWKJ4C.js +41 -0
  22. package/build-runtime/chunk-RKE6XT5Z.js +3104 -0
  23. package/build-runtime/chunk-UZPSWWI5.js +13 -0
  24. package/build-runtime/chunk-VMS3NKCF.js +18 -0
  25. package/build-runtime/chunk-W73LN534.js +24 -0
  26. package/build-runtime/chunk-WYNC47R3.js +7 -0
  27. package/build-runtime/chunk-YMZMZCBN.js +4063 -0
  28. package/build-runtime/chunk-YX6EVX5Q.js +11 -0
  29. package/build-runtime/context/elevated.d.ts +2 -0
  30. package/build-runtime/context/elevated.js +25 -0
  31. package/build-runtime/context/non-elevated.d.ts +2 -0
  32. package/build-runtime/context/non-elevated.js +32 -0
  33. package/build-runtime/context/nonElevated.d.ts +2 -0
  34. package/build-runtime/context/nonElevated.js +38 -0
  35. package/build-runtime/context/setupServicePlugin.d.ts +5 -0
  36. package/build-runtime/context/setupServicePlugin.js +16 -0
  37. package/build-runtime/context/setupWebhook.d.ts +5 -0
  38. package/build-runtime/context/setupWebhook.js +16 -0
  39. package/build-runtime/middleware/auth.d.ts +5 -0
  40. package/build-runtime/middleware/auth.js +74 -0
  41. package/build-runtime/middleware/html-embeds.d.ts +5 -0
  42. package/build-runtime/middleware/html-embeds.js +166 -0
  43. package/build-runtime/routes/auth/callback.d.ts +5 -0
  44. package/build-runtime/routes/auth/callback.js +52 -0
  45. package/build-runtime/routes/auth/login.d.ts +5 -0
  46. package/build-runtime/routes/auth/login.js +45 -0
  47. package/build-runtime/routes/auth/logout-callback.d.ts +5 -0
  48. package/build-runtime/routes/auth/logout-callback.js +23 -0
  49. package/build-runtime/routes/auth/logout.d.ts +5 -0
  50. package/build-runtime/routes/auth/logout.js +32 -0
  51. package/build-runtime/routes/paylink/checkout.d.ts +5 -0
  52. package/build-runtime/routes/paylink/checkout.js +35 -0
  53. package/build-runtime/routes/paylink/paylink.d.ts +5 -0
  54. package/build-runtime/routes/paylink/paylink.js +34 -0
  55. package/build-runtime/routes/robots/robots.d.ts +5 -0
  56. package/build-runtime/routes/robots/robots.js +44 -0
  57. package/build-runtime/routes/service-plugins.d.ts +5 -0
  58. package/build-runtime/routes/service-plugins.js +11 -0
  59. package/build-runtime/routes/servicePluginsDevRoute.d.ts +5 -0
  60. package/build-runtime/routes/servicePluginsDevRoute.js +13 -0
  61. package/build-runtime/routes/webhooks.d.ts +5 -0
  62. package/build-runtime/routes/webhooks.js +11 -0
  63. package/build-runtime/routes/webhooksDevRoute.d.ts +5 -0
  64. package/build-runtime/routes/webhooksDevRoute.js +13 -0
  65. package/build-runtime/routes/wix-apis/api.d.ts +5 -0
  66. package/build-runtime/routes/wix-apis/api.js +34 -0
  67. package/package.json +45 -19
  68. package/runtime/entry.astro +26 -0
  69. package/build/builders.d.ts +0 -5
  70. package/build/builders.js +0 -40
  71. package/build/builders.js.map +0 -1
@@ -0,0 +1,811 @@
1
+ import {
2
+ authAsyncLocalStorage
3
+ } from "./chunk-NVTQFGTR.js";
4
+ import {
5
+ resolveContext
6
+ } from "./chunk-PSHIUVP2.js";
7
+ import {
8
+ __commonJS,
9
+ __esm,
10
+ __export,
11
+ __toCommonJS,
12
+ __toESM
13
+ } from "./chunk-QRPWKJ4C.js";
14
+
15
+ // ../../node_modules/@wix/monitoring/build/index.cjs
16
+ var require_build = __commonJS({
17
+ "../../node_modules/@wix/monitoring/build/index.cjs"(exports, module) {
18
+ "use strict";
19
+ var __defProp = Object.defineProperty;
20
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
21
+ var __getOwnPropNames = Object.getOwnPropertyNames;
22
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
23
+ var __export2 = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS2 = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+ var index_exports = {};
37
+ __export2(index_exports, {
38
+ createFallbackMonitoringClient: () => createFallbackMonitoringClient,
39
+ generateTagsAndContext: () => generateTagsAndContext
40
+ });
41
+ module.exports = __toCommonJS2(index_exports);
42
+ var validValue = (value) => value !== void 0 && value !== null && value !== "";
43
+ var pickByValidValues = (obj) => pickBy(obj, validValue);
44
+ function pickBy(object, predicate = (value) => !!value) {
45
+ if (!object) {
46
+ return {};
47
+ }
48
+ const result = {};
49
+ for (const key in object) {
50
+ if (predicate(object[key], key)) {
51
+ result[key] = object[key];
52
+ }
53
+ }
54
+ return result;
55
+ }
56
+ var generateTagsAndContext = (context) => {
57
+ const tags = pickByValidValues({
58
+ "app.id": context.appId,
59
+ "app.version": context.appVersion,
60
+ "app.instanceId": context.appInstanceId,
61
+ "extension.id": context.extensionId,
62
+ "extension.name": context.extensionName,
63
+ "extension.type": context.extensionType,
64
+ platform: context.platform
65
+ });
66
+ const contexts = pickBy(
67
+ {
68
+ "extension.data": pickByValidValues({
69
+ ...context.extensionData
70
+ }),
71
+ site: pickByValidValues({
72
+ url: context.siteUrl,
73
+ id: context.tenantType === "SITE" ? context.tenantId : void 0
74
+ }),
75
+ account: pickByValidValues({
76
+ id: context.tenantType === "ACCOUNT" ? context.tenantId : void 0
77
+ })
78
+ },
79
+ (value) => !!value && Object.keys(value).length > 0
80
+ );
81
+ return {
82
+ tags,
83
+ contexts
84
+ };
85
+ };
86
+ var FallbackMonitoringClient = class {
87
+ constructor(message) {
88
+ this.message = message;
89
+ this.captureException = () => {
90
+ console.error(this.message);
91
+ };
92
+ this.captureMessage = () => {
93
+ console.error(this.message);
94
+ };
95
+ this.startSpan = (spanOptions, callback) => {
96
+ console.error(this.message);
97
+ return callback(void 0);
98
+ };
99
+ this.startSpanManual = () => {
100
+ console.error(this.message);
101
+ return {
102
+ end: () => {
103
+ },
104
+ fail: () => {
105
+ }
106
+ };
107
+ };
108
+ this.endSpanManual = () => {
109
+ console.error(this.message);
110
+ };
111
+ this.addBreadcrumb = () => {
112
+ console.error(this.message);
113
+ };
114
+ }
115
+ };
116
+ var createFallbackMonitoringClient = (message) => {
117
+ return new FallbackMonitoringClient(message);
118
+ };
119
+ }
120
+ });
121
+
122
+ // ../../node_modules/@wix/monitoring-common/build/index.js
123
+ var build_exports = {};
124
+ __export(build_exports, {
125
+ getCallLocation: () => getCallLocation,
126
+ getCallStack: () => getCallStack
127
+ });
128
+ var getCallStack, getCallLocation;
129
+ var init_build = __esm({
130
+ "../../node_modules/@wix/monitoring-common/build/index.js"() {
131
+ "use strict";
132
+ getCallStack = (stack) => {
133
+ try {
134
+ throw new Error();
135
+ } catch (e) {
136
+ return e?.stack;
137
+ }
138
+ };
139
+ getCallLocation = (stack) => {
140
+ const res = { file: "", line: 0, column: 0 };
141
+ stack = stack ?? getCallStack();
142
+ const frame = stack?.trim().split("\n").pop();
143
+ if (!frame) {
144
+ return res;
145
+ }
146
+ const match = frame.match(/https?:\/\/.+?(\/.+):(\d+):(\d+)/) ?? frame.match(/.*(\/[^/]+):(\d+):(\d+)/);
147
+ if (match) {
148
+ res.file = match[1];
149
+ res.line = parseInt(match[2], 10) ?? 0;
150
+ res.column = parseInt(match[3], 10) ?? 0;
151
+ }
152
+ return res;
153
+ };
154
+ }
155
+ });
156
+
157
+ // ../../node_modules/lodash/isObject.js
158
+ var require_isObject = __commonJS({
159
+ "../../node_modules/lodash/isObject.js"(exports, module) {
160
+ "use strict";
161
+ function isObject(value) {
162
+ var type = typeof value;
163
+ return value != null && (type == "object" || type == "function");
164
+ }
165
+ module.exports = isObject;
166
+ }
167
+ });
168
+
169
+ // ../../node_modules/lodash/_freeGlobal.js
170
+ var require_freeGlobal = __commonJS({
171
+ "../../node_modules/lodash/_freeGlobal.js"(exports, module) {
172
+ "use strict";
173
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
174
+ module.exports = freeGlobal;
175
+ }
176
+ });
177
+
178
+ // ../../node_modules/lodash/_root.js
179
+ var require_root = __commonJS({
180
+ "../../node_modules/lodash/_root.js"(exports, module) {
181
+ "use strict";
182
+ var freeGlobal = require_freeGlobal();
183
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
184
+ var root = freeGlobal || freeSelf || Function("return this")();
185
+ module.exports = root;
186
+ }
187
+ });
188
+
189
+ // ../../node_modules/lodash/now.js
190
+ var require_now = __commonJS({
191
+ "../../node_modules/lodash/now.js"(exports, module) {
192
+ "use strict";
193
+ var root = require_root();
194
+ var now = function() {
195
+ return root.Date.now();
196
+ };
197
+ module.exports = now;
198
+ }
199
+ });
200
+
201
+ // ../../node_modules/lodash/_trimmedEndIndex.js
202
+ var require_trimmedEndIndex = __commonJS({
203
+ "../../node_modules/lodash/_trimmedEndIndex.js"(exports, module) {
204
+ "use strict";
205
+ var reWhitespace = /\s/;
206
+ function trimmedEndIndex(string) {
207
+ var index = string.length;
208
+ while (index-- && reWhitespace.test(string.charAt(index))) {
209
+ }
210
+ return index;
211
+ }
212
+ module.exports = trimmedEndIndex;
213
+ }
214
+ });
215
+
216
+ // ../../node_modules/lodash/_baseTrim.js
217
+ var require_baseTrim = __commonJS({
218
+ "../../node_modules/lodash/_baseTrim.js"(exports, module) {
219
+ "use strict";
220
+ var trimmedEndIndex = require_trimmedEndIndex();
221
+ var reTrimStart = /^\s+/;
222
+ function baseTrim(string) {
223
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
224
+ }
225
+ module.exports = baseTrim;
226
+ }
227
+ });
228
+
229
+ // ../../node_modules/lodash/_Symbol.js
230
+ var require_Symbol = __commonJS({
231
+ "../../node_modules/lodash/_Symbol.js"(exports, module) {
232
+ "use strict";
233
+ var root = require_root();
234
+ var Symbol = root.Symbol;
235
+ module.exports = Symbol;
236
+ }
237
+ });
238
+
239
+ // ../../node_modules/lodash/_getRawTag.js
240
+ var require_getRawTag = __commonJS({
241
+ "../../node_modules/lodash/_getRawTag.js"(exports, module) {
242
+ "use strict";
243
+ var Symbol = require_Symbol();
244
+ var objectProto = Object.prototype;
245
+ var hasOwnProperty = objectProto.hasOwnProperty;
246
+ var nativeObjectToString = objectProto.toString;
247
+ var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
248
+ function getRawTag(value) {
249
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
250
+ try {
251
+ value[symToStringTag] = void 0;
252
+ var unmasked = true;
253
+ } catch (e) {
254
+ }
255
+ var result = nativeObjectToString.call(value);
256
+ if (unmasked) {
257
+ if (isOwn) {
258
+ value[symToStringTag] = tag;
259
+ } else {
260
+ delete value[symToStringTag];
261
+ }
262
+ }
263
+ return result;
264
+ }
265
+ module.exports = getRawTag;
266
+ }
267
+ });
268
+
269
+ // ../../node_modules/lodash/_objectToString.js
270
+ var require_objectToString = __commonJS({
271
+ "../../node_modules/lodash/_objectToString.js"(exports, module) {
272
+ "use strict";
273
+ var objectProto = Object.prototype;
274
+ var nativeObjectToString = objectProto.toString;
275
+ function objectToString(value) {
276
+ return nativeObjectToString.call(value);
277
+ }
278
+ module.exports = objectToString;
279
+ }
280
+ });
281
+
282
+ // ../../node_modules/lodash/_baseGetTag.js
283
+ var require_baseGetTag = __commonJS({
284
+ "../../node_modules/lodash/_baseGetTag.js"(exports, module) {
285
+ "use strict";
286
+ var Symbol = require_Symbol();
287
+ var getRawTag = require_getRawTag();
288
+ var objectToString = require_objectToString();
289
+ var nullTag = "[object Null]";
290
+ var undefinedTag = "[object Undefined]";
291
+ var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
292
+ function baseGetTag(value) {
293
+ if (value == null) {
294
+ return value === void 0 ? undefinedTag : nullTag;
295
+ }
296
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
297
+ }
298
+ module.exports = baseGetTag;
299
+ }
300
+ });
301
+
302
+ // ../../node_modules/lodash/isObjectLike.js
303
+ var require_isObjectLike = __commonJS({
304
+ "../../node_modules/lodash/isObjectLike.js"(exports, module) {
305
+ "use strict";
306
+ function isObjectLike(value) {
307
+ return value != null && typeof value == "object";
308
+ }
309
+ module.exports = isObjectLike;
310
+ }
311
+ });
312
+
313
+ // ../../node_modules/lodash/isSymbol.js
314
+ var require_isSymbol = __commonJS({
315
+ "../../node_modules/lodash/isSymbol.js"(exports, module) {
316
+ "use strict";
317
+ var baseGetTag = require_baseGetTag();
318
+ var isObjectLike = require_isObjectLike();
319
+ var symbolTag = "[object Symbol]";
320
+ function isSymbol(value) {
321
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
322
+ }
323
+ module.exports = isSymbol;
324
+ }
325
+ });
326
+
327
+ // ../../node_modules/lodash/toNumber.js
328
+ var require_toNumber = __commonJS({
329
+ "../../node_modules/lodash/toNumber.js"(exports, module) {
330
+ "use strict";
331
+ var baseTrim = require_baseTrim();
332
+ var isObject = require_isObject();
333
+ var isSymbol = require_isSymbol();
334
+ var NAN = 0 / 0;
335
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
336
+ var reIsBinary = /^0b[01]+$/i;
337
+ var reIsOctal = /^0o[0-7]+$/i;
338
+ var freeParseInt = parseInt;
339
+ function toNumber(value) {
340
+ if (typeof value == "number") {
341
+ return value;
342
+ }
343
+ if (isSymbol(value)) {
344
+ return NAN;
345
+ }
346
+ if (isObject(value)) {
347
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
348
+ value = isObject(other) ? other + "" : other;
349
+ }
350
+ if (typeof value != "string") {
351
+ return value === 0 ? value : +value;
352
+ }
353
+ value = baseTrim(value);
354
+ var isBinary = reIsBinary.test(value);
355
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
356
+ }
357
+ module.exports = toNumber;
358
+ }
359
+ });
360
+
361
+ // ../../node_modules/lodash/debounce.js
362
+ var require_debounce = __commonJS({
363
+ "../../node_modules/lodash/debounce.js"(exports, module) {
364
+ "use strict";
365
+ var isObject = require_isObject();
366
+ var now = require_now();
367
+ var toNumber = require_toNumber();
368
+ var FUNC_ERROR_TEXT = "Expected a function";
369
+ var nativeMax = Math.max;
370
+ var nativeMin = Math.min;
371
+ function debounce(func, wait, options) {
372
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
373
+ if (typeof func != "function") {
374
+ throw new TypeError(FUNC_ERROR_TEXT);
375
+ }
376
+ wait = toNumber(wait) || 0;
377
+ if (isObject(options)) {
378
+ leading = !!options.leading;
379
+ maxing = "maxWait" in options;
380
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
381
+ trailing = "trailing" in options ? !!options.trailing : trailing;
382
+ }
383
+ function invokeFunc(time) {
384
+ var args = lastArgs, thisArg = lastThis;
385
+ lastArgs = lastThis = void 0;
386
+ lastInvokeTime = time;
387
+ result = func.apply(thisArg, args);
388
+ return result;
389
+ }
390
+ function leadingEdge(time) {
391
+ lastInvokeTime = time;
392
+ timerId = setTimeout(timerExpired, wait);
393
+ return leading ? invokeFunc(time) : result;
394
+ }
395
+ function remainingWait(time) {
396
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
397
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
398
+ }
399
+ function shouldInvoke(time) {
400
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
401
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
402
+ }
403
+ function timerExpired() {
404
+ var time = now();
405
+ if (shouldInvoke(time)) {
406
+ return trailingEdge(time);
407
+ }
408
+ timerId = setTimeout(timerExpired, remainingWait(time));
409
+ }
410
+ function trailingEdge(time) {
411
+ timerId = void 0;
412
+ if (trailing && lastArgs) {
413
+ return invokeFunc(time);
414
+ }
415
+ lastArgs = lastThis = void 0;
416
+ return result;
417
+ }
418
+ function cancel() {
419
+ if (timerId !== void 0) {
420
+ clearTimeout(timerId);
421
+ }
422
+ lastInvokeTime = 0;
423
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
424
+ }
425
+ function flush() {
426
+ return timerId === void 0 ? result : trailingEdge(now());
427
+ }
428
+ function debounced() {
429
+ var time = now(), isInvoking = shouldInvoke(time);
430
+ lastArgs = arguments;
431
+ lastThis = this;
432
+ lastCallTime = time;
433
+ if (isInvoking) {
434
+ if (timerId === void 0) {
435
+ return leadingEdge(lastCallTime);
436
+ }
437
+ if (maxing) {
438
+ clearTimeout(timerId);
439
+ timerId = setTimeout(timerExpired, wait);
440
+ return invokeFunc(lastCallTime);
441
+ }
442
+ }
443
+ if (timerId === void 0) {
444
+ timerId = setTimeout(timerExpired, wait);
445
+ }
446
+ return result;
447
+ }
448
+ debounced.cancel = cancel;
449
+ debounced.flush = flush;
450
+ return debounced;
451
+ }
452
+ module.exports = debounce;
453
+ }
454
+ });
455
+
456
+ // ../../node_modules/lodash/throttle.js
457
+ var require_throttle = __commonJS({
458
+ "../../node_modules/lodash/throttle.js"(exports, module) {
459
+ "use strict";
460
+ var debounce = require_debounce();
461
+ var isObject = require_isObject();
462
+ var FUNC_ERROR_TEXT = "Expected a function";
463
+ function throttle(func, wait, options) {
464
+ var leading = true, trailing = true;
465
+ if (typeof func != "function") {
466
+ throw new TypeError(FUNC_ERROR_TEXT);
467
+ }
468
+ if (isObject(options)) {
469
+ leading = "leading" in options ? !!options.leading : leading;
470
+ trailing = "trailing" in options ? !!options.trailing : trailing;
471
+ }
472
+ return debounce(func, wait, {
473
+ "leading": leading,
474
+ "maxWait": wait,
475
+ "trailing": trailing
476
+ });
477
+ }
478
+ module.exports = throttle;
479
+ }
480
+ });
481
+
482
+ // ../../node_modules/@wix/monitoring-velo/build/index.cjs
483
+ var require_build2 = __commonJS({
484
+ "../../node_modules/@wix/monitoring-velo/build/index.cjs"(exports, module) {
485
+ "use strict";
486
+ var __create = Object.create;
487
+ var __defProp = Object.defineProperty;
488
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
489
+ var __getOwnPropNames = Object.getOwnPropertyNames;
490
+ var __getProtoOf = Object.getPrototypeOf;
491
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
492
+ var __export2 = (target, all) => {
493
+ for (var name in all)
494
+ __defProp(target, name, { get: all[name], enumerable: true });
495
+ };
496
+ var __copyProps = (to, from, except, desc) => {
497
+ if (from && typeof from === "object" || typeof from === "function") {
498
+ for (let key of __getOwnPropNames(from))
499
+ if (!__hasOwnProp.call(to, key) && key !== except)
500
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
501
+ }
502
+ return to;
503
+ };
504
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
505
+ // If the importer is in node compatibility mode or this is not an ESM
506
+ // file that has been converted to a CommonJS file using a Babel-
507
+ // compatible transform (i.e. "__esModule" has not been set), then set
508
+ // "default" to the CommonJS "module.exports" for node compatibility.
509
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
510
+ mod
511
+ ));
512
+ var __toCommonJS2 = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
513
+ var index_exports = {};
514
+ __export2(index_exports, {
515
+ createVeloMonitoringClient: () => createVeloMonitoringClient2
516
+ });
517
+ module.exports = __toCommonJS2(index_exports);
518
+ var import_monitoring = require_build();
519
+ var import_monitoring_common = (init_build(), __toCommonJS(build_exports));
520
+ var generateId = () => {
521
+ return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
522
+ const i = 16 * Math.random() | 0;
523
+ return ("x" === e ? i : 3 & i | 8).toString(16);
524
+ });
525
+ };
526
+ var stringifySafe = (value) => {
527
+ try {
528
+ return JSON.stringify(value);
529
+ } catch (error) {
530
+ return `Failed to stringify log value: ${error?.toString()}`;
531
+ }
532
+ };
533
+ var buildTelemetryPayload = (options, params) => {
534
+ const { namespace, producer, req, requestId } = options;
535
+ const {
536
+ message,
537
+ level = "INFO",
538
+ timestamp = Date.now(),
539
+ tags,
540
+ contexts
541
+ } = params;
542
+ const { __sourceLocation, ...restOfContext } = contexts ?? {};
543
+ let siteUrl = "";
544
+ if (req) {
545
+ try {
546
+ if (req.headers.get("referer")) {
547
+ siteUrl = new URL(req.headers.get("referer") ?? "").origin;
548
+ } else {
549
+ siteUrl = new URL(req.url).origin;
550
+ }
551
+ } catch (e) {
552
+ }
553
+ }
554
+ const messageParts = [message];
555
+ if (tags) {
556
+ messageParts.push(stringifySafe(tags));
557
+ }
558
+ if (Object.keys(restOfContext).length > 0) {
559
+ messageParts.push(stringifySafe(restOfContext));
560
+ }
561
+ const sourceLocation = __sourceLocation ?? (0, import_monitoring_common.getCallLocation)();
562
+ return {
563
+ insertId: generateId(),
564
+ timestamp: new Date(timestamp).toISOString(),
565
+ severity: level.toUpperCase(),
566
+ labels: {
567
+ tenantId: "",
568
+ namespace,
569
+ ...siteUrl ? { siteUrl } : {}
570
+ },
571
+ operation: {
572
+ id: requestId ?? generateId(),
573
+ producer
574
+ },
575
+ ...sourceLocation ? { sourceLocation } : {},
576
+ jsonPayload: {
577
+ message: messageParts.join(" ")
578
+ }
579
+ };
580
+ };
581
+ var TELEMETRY_URL = "https://www.wixapis.com/wixcode/v1/telemetry/telemetry-messages";
582
+ var MAX_BATCH_SIZE = 100;
583
+ var THROTTLE_DURATION = 300;
584
+ var report = (messages, authToken = "", fetch = globalThis.fetch) => {
585
+ fetch(TELEMETRY_URL, {
586
+ method: "POST",
587
+ body: JSON.stringify({ messages }),
588
+ headers: {
589
+ Authorization: authToken
590
+ }
591
+ }).catch(() => {
592
+ });
593
+ };
594
+ var import_throttle = __toESM2(require_throttle(), 1);
595
+ var BatchQueue = class {
596
+ constructor(options) {
597
+ this.options = options;
598
+ this.queue = [];
599
+ this.flushThrottled = (0, import_throttle.default)(
600
+ () => this.flush(),
601
+ options.throttleDuration,
602
+ {
603
+ leading: false
604
+ }
605
+ );
606
+ }
607
+ flush() {
608
+ const events = this.queue.splice(0);
609
+ this.options.flushHandler(events);
610
+ }
611
+ enqueue(payload) {
612
+ this.queue.push(payload);
613
+ if (this.queue.length === this.options.maxBatchSize) {
614
+ this.flushThrottled.cancel();
615
+ this.flush();
616
+ } else {
617
+ this.flushThrottled();
618
+ }
619
+ }
620
+ };
621
+ var isPromise = (value) => typeof value?.then === "function";
622
+ var import_monitoring_common2 = (init_build(), __toCommonJS(build_exports));
623
+ var VeloClient = class {
624
+ constructor(options) {
625
+ this.options = options;
626
+ this.reportError = (captureContext = {}, e) => {
627
+ const { tags, contexts } = captureContext;
628
+ const messagePayload = buildTelemetryPayload(this.options, {
629
+ message: e?.toString() ?? "Unknown error",
630
+ level: "error",
631
+ tags,
632
+ contexts: {
633
+ __sourceLocation: (0, import_monitoring_common2.getCallLocation)(e?.stack),
634
+ ...contexts
635
+ }
636
+ });
637
+ this.batchQueue.enqueue(messagePayload);
638
+ };
639
+ this.captureException = (error, captureContext) => {
640
+ this.reportError(captureContext, error);
641
+ };
642
+ this.captureMessage = (message, captureContext = {}) => {
643
+ const { level = "info", tags, contexts } = captureContext;
644
+ const messagePayload = buildTelemetryPayload(this.options, {
645
+ message,
646
+ level,
647
+ tags,
648
+ contexts
649
+ });
650
+ this.batchQueue.enqueue(messagePayload);
651
+ };
652
+ this.startSpan = (spanOptions, callback) => {
653
+ let res;
654
+ try {
655
+ res = callback();
656
+ if (isPromise(res)) {
657
+ res = res.then((_res) => {
658
+ return _res;
659
+ }).catch((e) => {
660
+ this.reportError(spanOptions, e);
661
+ throw e;
662
+ });
663
+ } else {
664
+ }
665
+ } catch (e) {
666
+ this.reportError(spanOptions, e);
667
+ throw e;
668
+ }
669
+ return res;
670
+ };
671
+ this.addBreadcrumb = (breadcrumb) => {
672
+ };
673
+ const { getAuthToken, fetch } = options;
674
+ this.batchQueue = new BatchQueue({
675
+ maxBatchSize: MAX_BATCH_SIZE,
676
+ throttleDuration: THROTTLE_DURATION,
677
+ flushHandler: (messages) => getAuthToken().then((token) => report(messages, token, fetch))
678
+ });
679
+ }
680
+ startSpanManual(spanOptions) {
681
+ return {
682
+ end: () => {
683
+ },
684
+ fail: (error) => {
685
+ this.reportError(spanOptions, error);
686
+ }
687
+ };
688
+ }
689
+ endSpanManual(spanOptions) {
690
+ }
691
+ };
692
+ var createVeloMonitoringClient2 = (options) => {
693
+ const { getAuthToken } = options;
694
+ if (!getAuthToken) {
695
+ return (0, import_monitoring.createFallbackMonitoringClient)("Missing getAuthToken");
696
+ }
697
+ return new VeloClient(options);
698
+ };
699
+ }
700
+ });
701
+
702
+ // ../../node_modules/@wix/headless-node/dist/esm/host-module.js
703
+ var import_monitoring_velo = __toESM(require_build2());
704
+
705
+ // ../../node_modules/@wix/headless-node/dist/esm/headers/common-config-header.js
706
+ var COMMON_CONFIG_HEADER_NAME = "commonConfig";
707
+ var BSI_COOKIE_NAME = "bSession";
708
+ var getCommonConfigHeader = (req) => {
709
+ let value = req.headers.get(COMMON_CONFIG_HEADER_NAME);
710
+ if (!value) {
711
+ const cookies = req.headers.get("cookie");
712
+ const bsiCookie = cookies == null ? void 0 : cookies.split(";").find((keyValue) => keyValue.trim().startsWith(`${BSI_COOKIE_NAME}=`));
713
+ value = bsiCookie ? encodeURIComponent(JSON.stringify({
714
+ BSI: bsiCookie.split("=")[1]
715
+ })) : "";
716
+ }
717
+ return {
718
+ [COMMON_CONFIG_HEADER_NAME]: value
719
+ };
720
+ };
721
+
722
+ // ../../node_modules/@wix/headless-node/dist/esm/headers/index.js
723
+ var getPassThroughHeaders = (req) => {
724
+ if (!req) {
725
+ return {};
726
+ }
727
+ const headers = [getCommonConfigHeader(req)];
728
+ return headers.reduce((res, header) => {
729
+ const entries = Object.entries(header).filter((_ref) => {
730
+ let [_, value] = _ref;
731
+ return !!value;
732
+ });
733
+ res = {
734
+ ...res,
735
+ ...Object.fromEntries(entries)
736
+ };
737
+ return res;
738
+ }, {});
739
+ };
740
+
741
+ // ../../node_modules/@wix/headless-node/dist/esm/utils/auth-utils.js
742
+ var resolveAuthToken = () => {
743
+ var _resolveContext;
744
+ return (_resolveContext = resolveContext()) == null ? void 0 : _resolveContext.getAuth().getTokens().accessToken.value;
745
+ };
746
+
747
+ // ../../node_modules/@wix/headless-node/dist/esm/host-module.js
748
+ var createHostModule = () => {
749
+ return {
750
+ __type: "host",
751
+ create: () => {
752
+ return {};
753
+ },
754
+ host: function(_temp) {
755
+ let {
756
+ req
757
+ } = _temp === void 0 ? {} : _temp;
758
+ const passThroughHeaders = getPassThroughHeaders(req);
759
+ return {
760
+ essentials: {
761
+ passThroughHeaders,
762
+ language: "en",
763
+ locale: "en-US",
764
+ timezone: "UTC"
765
+ },
766
+ getMonitoringClient: () => {
767
+ return (0, import_monitoring_velo.createVeloMonitoringClient)({
768
+ namespace: "Headless",
769
+ producer: "backend",
770
+ getAuthToken: async () => resolveAuthToken(),
771
+ req
772
+ });
773
+ }
774
+ };
775
+ }
776
+ };
777
+ };
778
+
779
+ // ../../node_modules/@wix/headless-node/dist/esm/index.js
780
+ var headlessNode = createHostModule();
781
+
782
+ // src/context/hostProxy.ts
783
+ var createHostWithCurrentRequest = () => {
784
+ const store = authAsyncLocalStorage.getStore();
785
+ return headlessNode.host({ req: store?.request });
786
+ };
787
+ var createHostProxy = () => {
788
+ return new Proxy(
789
+ {},
790
+ {
791
+ get(target, prop) {
792
+ const host = createHostWithCurrentRequest();
793
+ const value = host[prop];
794
+ if (typeof value !== "function") {
795
+ return value;
796
+ }
797
+ return function(...args) {
798
+ const anotherHost = createHostWithCurrentRequest();
799
+ return anotherHost[prop].apply(
800
+ anotherHost,
801
+ args
802
+ );
803
+ };
804
+ }
805
+ }
806
+ );
807
+ };
808
+
809
+ export {
810
+ createHostProxy
811
+ };