@shopify/create-app 3.65.2 → 3.66.0

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 (86) hide show
  1. package/dist/chunk-2RSJVBMF.js +5625 -0
  2. package/dist/{chunk-Z65QJ5D7.js → chunk-4DRC2PSU.js} +17 -30
  3. package/dist/chunk-4OD45DDO.js +31508 -0
  4. package/dist/chunk-522OB3EU.js +45 -0
  5. package/dist/{chunk-JTKTLA7L.js → chunk-5U24TEX5.js} +5434 -10324
  6. package/dist/{chunk-GJPZCXGT.js → chunk-6A7MXLVB.js} +159 -405
  7. package/dist/{chunk-ZYKRTO5P.js → chunk-7ZCQLP5Y.js} +3 -3
  8. package/dist/{chunk-5LBEKXRW.js → chunk-FIJKOZJF.js} +19 -55
  9. package/dist/{chunk-QSKQTKTB.js → chunk-FT6PCF6E.js} +2441 -5551
  10. package/dist/chunk-GIUM5DCQ.js +2144 -0
  11. package/dist/chunk-HIAKHDLR.js +54 -0
  12. package/dist/chunk-LLSRDN3T.js +15352 -0
  13. package/dist/chunk-LTDD2GRL.js +111 -0
  14. package/dist/{chunk-63QVG2CD.js → chunk-NGBYQF44.js} +9 -9
  15. package/dist/chunk-NLC7NBUB.js +80 -0
  16. package/dist/{chunk-FMKVOTQK.js → chunk-O5K4AU7Q.js} +18 -34
  17. package/dist/chunk-OMDEA7TV.js +10615 -0
  18. package/dist/chunk-PNN7RS7Y.js +105 -0
  19. package/dist/{chunk-ZPL24Y2D.js → chunk-POZ5MGPT.js} +13 -18
  20. package/dist/chunk-T7T35H4F.js +108 -0
  21. package/dist/chunk-UBB7JKND.js +55 -0
  22. package/dist/chunk-VSLR7ET4.js +3034 -0
  23. package/dist/{chunk-SAO7C4LP.js → chunk-VZVGAREJ.js} +46821 -101962
  24. package/dist/{chunk-KDNBKIH4.js → chunk-WBQF4CSV.js} +12 -22
  25. package/dist/chunk-XVNW332R.js +524 -0
  26. package/dist/{chunk-YB6D4XQ7.js → chunk-Y4ECGRAF.js} +13 -23
  27. package/dist/chunk-ZAUZQLNO.js +3774 -0
  28. package/dist/chunk-ZULFH3SL.js +1847 -0
  29. package/dist/commands/init.d.ts +0 -1
  30. package/dist/commands/init.js +27 -27
  31. package/dist/commands/init.test.js +51 -70
  32. package/dist/{constants-24TFXZKQ.js → constants-WG7I7G3O.js} +5 -5
  33. package/dist/custom-oclif-loader-JKRJZ56E.js +47 -0
  34. package/dist/del-NW5KFKFP.js +1820 -0
  35. package/dist/devtools-UBOREV57.js +2572 -0
  36. package/dist/error-handler-26SLAJTC.js +35 -0
  37. package/dist/hooks/postrun.js +35 -42
  38. package/dist/hooks/prerun.js +58 -36
  39. package/dist/index.js +7 -7
  40. package/dist/lib-3K5QYF3J.js +9 -0
  41. package/dist/{local-3VUKCW4R.js → local-H6TW5MNX.js} +13 -13
  42. package/dist/magic-string.es-3RXPUXZF.js +843 -0
  43. package/dist/multipart-parser-QKUAJJP5.js +193 -0
  44. package/dist/{node-package-manager-HYZRZNU6.js → node-package-manager-QAUN6HGS.js} +16 -14
  45. package/dist/open-MZGVNFZO.js +197 -0
  46. package/dist/out-KDGAD475.js +6 -0
  47. package/dist/{path-CFPIDSWV.js → path-L375JOQ2.js} +4 -4
  48. package/dist/prompts/init.js +13 -13
  49. package/dist/prompts/init.test.js +42 -59
  50. package/dist/services/init.js +20 -20
  51. package/dist/services/init.test.js +5 -5
  52. package/dist/system-ZI2HKAKO.js +26 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/{ui-7NEDEALP.js → ui-727JEZUX.js} +13 -13
  55. package/dist/utils/template/cleanup.js +13 -13
  56. package/dist/utils/template/cleanup.test.js +18 -30
  57. package/dist/utils/template/npm.js +15 -15
  58. package/dist/utils/template/npm.test.js +48 -87
  59. package/oclif.manifest.json +1 -1
  60. package/package.json +3 -4
  61. package/dist/chunk-3US34ZNP.js +0 -145
  62. package/dist/chunk-3XYIOBQ2.js +0 -22131
  63. package/dist/chunk-6IZMEXPW.js +0 -105
  64. package/dist/chunk-7DRS5WXI.js +0 -7843
  65. package/dist/chunk-DL3MKXVR.js +0 -4754
  66. package/dist/chunk-HDVJ5FPK.js +0 -63
  67. package/dist/chunk-IKO7JBOJ.js +0 -14788
  68. package/dist/chunk-LSCXQWNO.js +0 -822
  69. package/dist/chunk-M2VKB6RG.js +0 -146
  70. package/dist/chunk-MCED27CG.js +0 -5626
  71. package/dist/chunk-SWNRLCC6.js +0 -61
  72. package/dist/chunk-T5LLJYYS.js +0 -195
  73. package/dist/chunk-U5LTJVWL.js +0 -3185
  74. package/dist/chunk-WR7YKB6H.js +0 -44962
  75. package/dist/chunk-YC4FLMDD.js +0 -74
  76. package/dist/chunk-ZRUHMMSQ.js +0 -2477
  77. package/dist/custom-oclif-loader-5KBN3RSN.js +0 -83
  78. package/dist/del-ZCPTGWOA.js +0 -2847
  79. package/dist/devtools-5N4JAP3R.js +0 -3588
  80. package/dist/error-handler-GTW2KSRC.js +0 -35
  81. package/dist/lib-CTSCLPNV.js +0 -9
  82. package/dist/magic-string.es-ATGURXGQ.js +0 -1353
  83. package/dist/multipart-parser-KYOHF24X.js +0 -360
  84. package/dist/open-JRS7RW22.js +0 -291
  85. package/dist/out-OKI3G7I5.js +0 -6
  86. package/dist/system-4S4YXUXZ.js +0 -26
@@ -1,3185 +0,0 @@
1
- import {
2
- require_once
3
- } from "./chunk-FMKVOTQK.js";
4
- import {
5
- fanoutHooks,
6
- reportAnalyticsEvent
7
- } from "./chunk-QSKQTKTB.js";
8
- import {
9
- CLI_KIT_VERSION
10
- } from "./chunk-ZYKRTO5P.js";
11
- import {
12
- getEnvironmentData
13
- } from "./chunk-YB6D4XQ7.js";
14
- import {
15
- AbortSilentError,
16
- CancelExecution,
17
- cleanSingleStackTracePath,
18
- errorMapper,
19
- getAllPublicMetadata,
20
- getAllSensitiveMetadata,
21
- handler,
22
- outputDebug,
23
- outputInfo,
24
- require_stacktracey,
25
- shouldReportError
26
- } from "./chunk-WR7YKB6H.js";
27
- import {
28
- bugsnagApiKey
29
- } from "./chunk-5LBEKXRW.js";
30
- import {
31
- cwd,
32
- isAbsolutePath,
33
- joinPath,
34
- normalizePath,
35
- relativePath
36
- } from "./chunk-Z65QJ5D7.js";
37
- import {
38
- printEventsJson
39
- } from "./chunk-M2VKB6RG.js";
40
- import {
41
- require_lib
42
- } from "./chunk-SAO7C4LP.js";
43
- import {
44
- __commonJS,
45
- __require,
46
- __toESM,
47
- init_cjs_shims
48
- } from "./chunk-ZPL24Y2D.js";
49
-
50
- // ../../node_modules/.pnpm/stackframe@1.3.4/node_modules/stackframe/stackframe.js
51
- var require_stackframe = __commonJS({
52
- "../../node_modules/.pnpm/stackframe@1.3.4/node_modules/stackframe/stackframe.js"(exports, module) {
53
- init_cjs_shims();
54
- (function(root, factory) {
55
- "use strict";
56
- if (typeof define === "function" && define.amd) {
57
- define("stackframe", [], factory);
58
- } else if (typeof exports === "object") {
59
- module.exports = factory();
60
- } else {
61
- root.StackFrame = factory();
62
- }
63
- })(exports, function() {
64
- "use strict";
65
- function _isNumber(n) {
66
- return !isNaN(parseFloat(n)) && isFinite(n);
67
- }
68
- function _capitalize(str) {
69
- return str.charAt(0).toUpperCase() + str.substring(1);
70
- }
71
- function _getter(p) {
72
- return function() {
73
- return this[p];
74
- };
75
- }
76
- var booleanProps = ["isConstructor", "isEval", "isNative", "isToplevel"];
77
- var numericProps = ["columnNumber", "lineNumber"];
78
- var stringProps = ["fileName", "functionName", "source"];
79
- var arrayProps = ["args"];
80
- var objectProps = ["evalOrigin"];
81
- var props = booleanProps.concat(numericProps, stringProps, arrayProps, objectProps);
82
- function StackFrame(obj) {
83
- if (!obj)
84
- return;
85
- for (var i2 = 0; i2 < props.length; i2++) {
86
- if (obj[props[i2]] !== void 0) {
87
- this["set" + _capitalize(props[i2])](obj[props[i2]]);
88
- }
89
- }
90
- }
91
- StackFrame.prototype = {
92
- getArgs: function() {
93
- return this.args;
94
- },
95
- setArgs: function(v) {
96
- if (Object.prototype.toString.call(v) !== "[object Array]") {
97
- throw new TypeError("Args must be an Array");
98
- }
99
- this.args = v;
100
- },
101
- getEvalOrigin: function() {
102
- return this.evalOrigin;
103
- },
104
- setEvalOrigin: function(v) {
105
- if (v instanceof StackFrame) {
106
- this.evalOrigin = v;
107
- } else if (v instanceof Object) {
108
- this.evalOrigin = new StackFrame(v);
109
- } else {
110
- throw new TypeError("Eval Origin must be an Object or StackFrame");
111
- }
112
- },
113
- toString: function() {
114
- var fileName = this.getFileName() || "";
115
- var lineNumber = this.getLineNumber() || "";
116
- var columnNumber = this.getColumnNumber() || "";
117
- var functionName = this.getFunctionName() || "";
118
- if (this.getIsEval()) {
119
- if (fileName) {
120
- return "[eval] (" + fileName + ":" + lineNumber + ":" + columnNumber + ")";
121
- }
122
- return "[eval]:" + lineNumber + ":" + columnNumber;
123
- }
124
- if (functionName) {
125
- return functionName + " (" + fileName + ":" + lineNumber + ":" + columnNumber + ")";
126
- }
127
- return fileName + ":" + lineNumber + ":" + columnNumber;
128
- }
129
- };
130
- StackFrame.fromString = function StackFrame$$fromString(str) {
131
- var argsStartIndex = str.indexOf("(");
132
- var argsEndIndex = str.lastIndexOf(")");
133
- var functionName = str.substring(0, argsStartIndex);
134
- var args = str.substring(argsStartIndex + 1, argsEndIndex).split(",");
135
- var locationString = str.substring(argsEndIndex + 1);
136
- if (locationString.indexOf("@") === 0) {
137
- var parts = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString, "");
138
- var fileName = parts[1];
139
- var lineNumber = parts[2];
140
- var columnNumber = parts[3];
141
- }
142
- return new StackFrame({
143
- functionName,
144
- args: args || void 0,
145
- fileName,
146
- lineNumber: lineNumber || void 0,
147
- columnNumber: columnNumber || void 0
148
- });
149
- };
150
- for (var i = 0; i < booleanProps.length; i++) {
151
- StackFrame.prototype["get" + _capitalize(booleanProps[i])] = _getter(booleanProps[i]);
152
- StackFrame.prototype["set" + _capitalize(booleanProps[i])] = /* @__PURE__ */ function(p) {
153
- return function(v) {
154
- this[p] = Boolean(v);
155
- };
156
- }(booleanProps[i]);
157
- }
158
- for (var j = 0; j < numericProps.length; j++) {
159
- StackFrame.prototype["get" + _capitalize(numericProps[j])] = _getter(numericProps[j]);
160
- StackFrame.prototype["set" + _capitalize(numericProps[j])] = /* @__PURE__ */ function(p) {
161
- return function(v) {
162
- if (!_isNumber(v)) {
163
- throw new TypeError(p + " must be a Number");
164
- }
165
- this[p] = Number(v);
166
- };
167
- }(numericProps[j]);
168
- }
169
- for (var k = 0; k < stringProps.length; k++) {
170
- StackFrame.prototype["get" + _capitalize(stringProps[k])] = _getter(stringProps[k]);
171
- StackFrame.prototype["set" + _capitalize(stringProps[k])] = /* @__PURE__ */ function(p) {
172
- return function(v) {
173
- this[p] = String(v);
174
- };
175
- }(stringProps[k]);
176
- }
177
- return StackFrame;
178
- });
179
- }
180
- });
181
-
182
- // ../../node_modules/.pnpm/error-stack-parser@2.1.4/node_modules/error-stack-parser/error-stack-parser.js
183
- var require_error_stack_parser = __commonJS({
184
- "../../node_modules/.pnpm/error-stack-parser@2.1.4/node_modules/error-stack-parser/error-stack-parser.js"(exports, module) {
185
- init_cjs_shims();
186
- (function(root, factory) {
187
- "use strict";
188
- if (typeof define === "function" && define.amd) {
189
- define("error-stack-parser", ["stackframe"], factory);
190
- } else if (typeof exports === "object") {
191
- module.exports = factory(require_stackframe());
192
- } else {
193
- root.ErrorStackParser = factory(root.StackFrame);
194
- }
195
- })(exports, function ErrorStackParser(StackFrame) {
196
- "use strict";
197
- var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
198
- var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
199
- var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
200
- return {
201
- /**
202
- * Given an Error object, extract the most information from it.
203
- *
204
- * @param {Error} error object
205
- * @return {Array} of StackFrames
206
- */
207
- parse: function ErrorStackParser$$parse(error) {
208
- if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined") {
209
- return this.parseOpera(error);
210
- } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
211
- return this.parseV8OrIE(error);
212
- } else if (error.stack) {
213
- return this.parseFFOrSafari(error);
214
- } else {
215
- throw new Error("Cannot parse given Error object");
216
- }
217
- },
218
- // Separate line and column numbers from a string of the form: (URI:Line:Column)
219
- extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
220
- if (urlLike.indexOf(":") === -1) {
221
- return [urlLike];
222
- }
223
- var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
224
- var parts = regExp.exec(urlLike.replace(/[()]/g, ""));
225
- return [parts[1], parts[2] || void 0, parts[3] || void 0];
226
- },
227
- parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
228
- var filtered = error.stack.split("\n").filter(function(line) {
229
- return !!line.match(CHROME_IE_STACK_REGEXP);
230
- }, this);
231
- return filtered.map(function(line) {
232
- if (line.indexOf("(eval ") > -1) {
233
- line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
234
- }
235
- var sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
236
- var location = sanitizedLine.match(/ (\(.+\)$)/);
237
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
238
- var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);
239
- var functionName = location && sanitizedLine || void 0;
240
- var fileName = ["eval", "<anonymous>"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
241
- return new StackFrame({
242
- functionName,
243
- fileName,
244
- lineNumber: locationParts[1],
245
- columnNumber: locationParts[2],
246
- source: line
247
- });
248
- }, this);
249
- },
250
- parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
251
- var filtered = error.stack.split("\n").filter(function(line) {
252
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
253
- }, this);
254
- return filtered.map(function(line) {
255
- if (line.indexOf(" > eval") > -1) {
256
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
257
- }
258
- if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
259
- return new StackFrame({
260
- functionName: line
261
- });
262
- } else {
263
- var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
264
- var matches = line.match(functionNameRegex);
265
- var functionName = matches && matches[1] ? matches[1] : void 0;
266
- var locationParts = this.extractLocation(line.replace(functionNameRegex, ""));
267
- return new StackFrame({
268
- functionName,
269
- fileName: locationParts[0],
270
- lineNumber: locationParts[1],
271
- columnNumber: locationParts[2],
272
- source: line
273
- });
274
- }
275
- }, this);
276
- },
277
- parseOpera: function ErrorStackParser$$parseOpera(e) {
278
- if (!e.stacktrace || e.message.indexOf("\n") > -1 && e.message.split("\n").length > e.stacktrace.split("\n").length) {
279
- return this.parseOpera9(e);
280
- } else if (!e.stack) {
281
- return this.parseOpera10(e);
282
- } else {
283
- return this.parseOpera11(e);
284
- }
285
- },
286
- parseOpera9: function ErrorStackParser$$parseOpera9(e) {
287
- var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
288
- var lines = e.message.split("\n");
289
- var result = [];
290
- for (var i = 2, len = lines.length; i < len; i += 2) {
291
- var match = lineRE.exec(lines[i]);
292
- if (match) {
293
- result.push(new StackFrame({
294
- fileName: match[2],
295
- lineNumber: match[1],
296
- source: lines[i]
297
- }));
298
- }
299
- }
300
- return result;
301
- },
302
- parseOpera10: function ErrorStackParser$$parseOpera10(e) {
303
- var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
304
- var lines = e.stacktrace.split("\n");
305
- var result = [];
306
- for (var i = 0, len = lines.length; i < len; i += 2) {
307
- var match = lineRE.exec(lines[i]);
308
- if (match) {
309
- result.push(
310
- new StackFrame({
311
- functionName: match[3] || void 0,
312
- fileName: match[2],
313
- lineNumber: match[1],
314
- source: lines[i]
315
- })
316
- );
317
- }
318
- }
319
- return result;
320
- },
321
- // Opera 10.65+ Error.stack very similar to FF/Safari
322
- parseOpera11: function ErrorStackParser$$parseOpera11(error) {
323
- var filtered = error.stack.split("\n").filter(function(line) {
324
- return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
325
- }, this);
326
- return filtered.map(function(line) {
327
- var tokens = line.split("@");
328
- var locationParts = this.extractLocation(tokens.pop());
329
- var functionCall = tokens.shift() || "";
330
- var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
331
- var argsRaw;
332
- if (functionCall.match(/\(([^)]*)\)/)) {
333
- argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
334
- }
335
- var args = argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(",");
336
- return new StackFrame({
337
- functionName,
338
- args,
339
- fileName: locationParts[0],
340
- lineNumber: locationParts[1],
341
- columnNumber: locationParts[2],
342
- source: line
343
- });
344
- }, this);
345
- }
346
- };
347
- });
348
- }
349
- });
350
-
351
- // ../../node_modules/.pnpm/iserror@0.0.2/node_modules/iserror/index.js
352
- var require_iserror = __commonJS({
353
- "../../node_modules/.pnpm/iserror@0.0.2/node_modules/iserror/index.js"(exports, module) {
354
- init_cjs_shims();
355
- module.exports = isError;
356
- function isError(value) {
357
- switch (Object.prototype.toString.call(value)) {
358
- case "[object Error]":
359
- return true;
360
- case "[object Exception]":
361
- return true;
362
- case "[object DOMException]":
363
- return true;
364
- default:
365
- return value instanceof Error;
366
- }
367
- }
368
- }
369
- });
370
-
371
- // ../../node_modules/.pnpm/stack-generator@2.0.10/node_modules/stack-generator/stack-generator.js
372
- var require_stack_generator = __commonJS({
373
- "../../node_modules/.pnpm/stack-generator@2.0.10/node_modules/stack-generator/stack-generator.js"(exports, module) {
374
- init_cjs_shims();
375
- (function(root, factory) {
376
- "use strict";
377
- if (typeof define === "function" && define.amd) {
378
- define("stack-generator", ["stackframe"], factory);
379
- } else if (typeof exports === "object") {
380
- module.exports = factory(require_stackframe());
381
- } else {
382
- root.StackGenerator = factory(root.StackFrame);
383
- }
384
- })(exports, function(StackFrame) {
385
- return {
386
- backtrace: function StackGenerator$$backtrace(opts) {
387
- var stack = [];
388
- var maxStackSize = 10;
389
- if (typeof opts === "object" && typeof opts.maxStackSize === "number") {
390
- maxStackSize = opts.maxStackSize;
391
- }
392
- var curr = arguments.callee;
393
- while (curr && stack.length < maxStackSize && curr["arguments"]) {
394
- var args = new Array(curr["arguments"].length);
395
- for (var i = 0; i < args.length; ++i) {
396
- args[i] = curr["arguments"][i];
397
- }
398
- if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
399
- stack.push(new StackFrame({ functionName: RegExp.$1 || void 0, args }));
400
- } else {
401
- stack.push(new StackFrame({ args }));
402
- }
403
- try {
404
- curr = curr.caller;
405
- } catch (e) {
406
- break;
407
- }
408
- }
409
- return stack;
410
- }
411
- };
412
- });
413
- }
414
- });
415
-
416
- // ../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js
417
- var require_end_of_stream = __commonJS({
418
- "../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js"(exports, module) {
419
- init_cjs_shims();
420
- var once = require_once();
421
- var noop = function() {
422
- };
423
- var isRequest = function(stream) {
424
- return stream.setHeader && typeof stream.abort === "function";
425
- };
426
- var isChildProcess = function(stream) {
427
- return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
428
- };
429
- var eos = function(stream, opts, callback) {
430
- if (typeof opts === "function")
431
- return eos(stream, null, opts);
432
- if (!opts)
433
- opts = {};
434
- callback = once(callback || noop);
435
- var ws = stream._writableState;
436
- var rs = stream._readableState;
437
- var readable = opts.readable || opts.readable !== false && stream.readable;
438
- var writable = opts.writable || opts.writable !== false && stream.writable;
439
- var cancelled = false;
440
- var onlegacyfinish = function() {
441
- if (!stream.writable)
442
- onfinish();
443
- };
444
- var onfinish = function() {
445
- writable = false;
446
- if (!readable)
447
- callback.call(stream);
448
- };
449
- var onend = function() {
450
- readable = false;
451
- if (!writable)
452
- callback.call(stream);
453
- };
454
- var onexit = function(exitCode) {
455
- callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
456
- };
457
- var onerror = function(err) {
458
- callback.call(stream, err);
459
- };
460
- var onclose = function() {
461
- process.nextTick(onclosenexttick);
462
- };
463
- var onclosenexttick = function() {
464
- if (cancelled)
465
- return;
466
- if (readable && !(rs && (rs.ended && !rs.destroyed)))
467
- return callback.call(stream, new Error("premature close"));
468
- if (writable && !(ws && (ws.ended && !ws.destroyed)))
469
- return callback.call(stream, new Error("premature close"));
470
- };
471
- var onrequest = function() {
472
- stream.req.on("finish", onfinish);
473
- };
474
- if (isRequest(stream)) {
475
- stream.on("complete", onfinish);
476
- stream.on("abort", onclose);
477
- if (stream.req)
478
- onrequest();
479
- else
480
- stream.on("request", onrequest);
481
- } else if (writable && !ws) {
482
- stream.on("end", onlegacyfinish);
483
- stream.on("close", onlegacyfinish);
484
- }
485
- if (isChildProcess(stream))
486
- stream.on("exit", onexit);
487
- stream.on("end", onend);
488
- stream.on("finish", onfinish);
489
- if (opts.error !== false)
490
- stream.on("error", onerror);
491
- stream.on("close", onclose);
492
- return function() {
493
- cancelled = true;
494
- stream.removeListener("complete", onfinish);
495
- stream.removeListener("abort", onclose);
496
- stream.removeListener("request", onrequest);
497
- if (stream.req)
498
- stream.req.removeListener("finish", onfinish);
499
- stream.removeListener("end", onlegacyfinish);
500
- stream.removeListener("close", onlegacyfinish);
501
- stream.removeListener("finish", onfinish);
502
- stream.removeListener("exit", onexit);
503
- stream.removeListener("end", onend);
504
- stream.removeListener("error", onerror);
505
- stream.removeListener("close", onclose);
506
- };
507
- };
508
- module.exports = eos;
509
- }
510
- });
511
-
512
- // ../../node_modules/.pnpm/pump@3.0.0/node_modules/pump/index.js
513
- var require_pump = __commonJS({
514
- "../../node_modules/.pnpm/pump@3.0.0/node_modules/pump/index.js"(exports, module) {
515
- init_cjs_shims();
516
- var once = require_once();
517
- var eos = require_end_of_stream();
518
- var fs = __require("fs");
519
- var noop = function() {
520
- };
521
- var ancient = /^v?\.0/.test(process.version);
522
- var isFn = function(fn) {
523
- return typeof fn === "function";
524
- };
525
- var isFS = function(stream) {
526
- if (!ancient)
527
- return false;
528
- if (!fs)
529
- return false;
530
- return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
531
- };
532
- var isRequest = function(stream) {
533
- return stream.setHeader && isFn(stream.abort);
534
- };
535
- var destroyer = function(stream, reading, writing, callback) {
536
- callback = once(callback);
537
- var closed = false;
538
- stream.on("close", function() {
539
- closed = true;
540
- });
541
- eos(stream, { readable: reading, writable: writing }, function(err) {
542
- if (err)
543
- return callback(err);
544
- closed = true;
545
- callback();
546
- });
547
- var destroyed = false;
548
- return function(err) {
549
- if (closed)
550
- return;
551
- if (destroyed)
552
- return;
553
- destroyed = true;
554
- if (isFS(stream))
555
- return stream.close(noop);
556
- if (isRequest(stream))
557
- return stream.abort();
558
- if (isFn(stream.destroy))
559
- return stream.destroy();
560
- callback(err || new Error("stream was destroyed"));
561
- };
562
- };
563
- var call = function(fn) {
564
- fn();
565
- };
566
- var pipe = function(from, to) {
567
- return from.pipe(to);
568
- };
569
- var pump = function() {
570
- var streams = Array.prototype.slice.call(arguments);
571
- var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
572
- if (Array.isArray(streams[0]))
573
- streams = streams[0];
574
- if (streams.length < 2)
575
- throw new Error("pump requires two streams per minimum");
576
- var error;
577
- var destroys = streams.map(function(stream, i) {
578
- var reading = i < streams.length - 1;
579
- var writing = i > 0;
580
- return destroyer(stream, reading, writing, function(err) {
581
- if (!error)
582
- error = err;
583
- if (err)
584
- destroys.forEach(call);
585
- if (reading)
586
- return;
587
- destroys.forEach(call);
588
- callback(error);
589
- });
590
- });
591
- return streams.reduce(pipe);
592
- };
593
- module.exports = pump;
594
- }
595
- });
596
-
597
- // ../../node_modules/.pnpm/byline@5.0.0/node_modules/byline/lib/byline.js
598
- var require_byline = __commonJS({
599
- "../../node_modules/.pnpm/byline@5.0.0/node_modules/byline/lib/byline.js"(exports, module) {
600
- init_cjs_shims();
601
- var stream = __require("stream");
602
- var util = __require("util");
603
- var timers = __require("timers");
604
- module.exports = function(readStream, options) {
605
- return module.exports.createStream(readStream, options);
606
- };
607
- module.exports.createStream = function(readStream, options) {
608
- if (readStream) {
609
- return createLineStream(readStream, options);
610
- } else {
611
- return new LineStream(options);
612
- }
613
- };
614
- module.exports.createLineStream = function(readStream) {
615
- console.log("WARNING: byline#createLineStream is deprecated and will be removed soon");
616
- return createLineStream(readStream);
617
- };
618
- function createLineStream(readStream, options) {
619
- if (!readStream) {
620
- throw new Error("expected readStream");
621
- }
622
- if (!readStream.readable) {
623
- throw new Error("readStream must be readable");
624
- }
625
- var ls = new LineStream(options);
626
- readStream.pipe(ls);
627
- return ls;
628
- }
629
- module.exports.LineStream = LineStream;
630
- function LineStream(options) {
631
- stream.Transform.call(this, options);
632
- options = options || {};
633
- this._readableState.objectMode = true;
634
- this._lineBuffer = [];
635
- this._keepEmptyLines = options.keepEmptyLines || false;
636
- this._lastChunkEndedWithCR = false;
637
- var self2 = this;
638
- this.on("pipe", function(src) {
639
- if (!self2.encoding) {
640
- if (src instanceof stream.Readable) {
641
- self2.encoding = src._readableState.encoding;
642
- }
643
- }
644
- });
645
- }
646
- util.inherits(LineStream, stream.Transform);
647
- LineStream.prototype._transform = function(chunk, encoding, done) {
648
- encoding = encoding || "utf8";
649
- if (Buffer.isBuffer(chunk)) {
650
- if (encoding == "buffer") {
651
- chunk = chunk.toString();
652
- encoding = "utf8";
653
- } else {
654
- chunk = chunk.toString(encoding);
655
- }
656
- }
657
- this._chunkEncoding = encoding;
658
- var lines = chunk.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
659
- if (this._lastChunkEndedWithCR && chunk[0] == "\n") {
660
- lines.shift();
661
- }
662
- if (this._lineBuffer.length > 0) {
663
- this._lineBuffer[this._lineBuffer.length - 1] += lines[0];
664
- lines.shift();
665
- }
666
- this._lastChunkEndedWithCR = chunk[chunk.length - 1] == "\r";
667
- this._lineBuffer = this._lineBuffer.concat(lines);
668
- this._pushBuffer(encoding, 1, done);
669
- };
670
- LineStream.prototype._pushBuffer = function(encoding, keep, done) {
671
- while (this._lineBuffer.length > keep) {
672
- var line = this._lineBuffer.shift();
673
- if (this._keepEmptyLines || line.length > 0) {
674
- if (!this.push(this._reencode(line, encoding))) {
675
- var self2 = this;
676
- timers.setImmediate(function() {
677
- self2._pushBuffer(encoding, keep, done);
678
- });
679
- return;
680
- }
681
- }
682
- }
683
- done();
684
- };
685
- LineStream.prototype._flush = function(done) {
686
- this._pushBuffer(this._chunkEncoding, 0, done);
687
- };
688
- LineStream.prototype._reencode = function(line, chunkEncoding) {
689
- if (this.encoding && this.encoding != chunkEncoding) {
690
- return new Buffer(line, chunkEncoding).toString(this.encoding);
691
- } else if (this.encoding) {
692
- return line;
693
- } else {
694
- return new Buffer(line, chunkEncoding);
695
- }
696
- };
697
- }
698
- });
699
-
700
- // ../../node_modules/.pnpm/@bugsnag+node@7.22.7/node_modules/@bugsnag/node/dist/bugsnag.js
701
- var require_bugsnag = __commonJS({
702
- "../../node_modules/.pnpm/@bugsnag+node@7.22.7/node_modules/@bugsnag/node/dist/bugsnag.js"(exports, module) {
703
- init_cjs_shims();
704
- (function(f) {
705
- if (typeof exports === "object" && typeof module !== "undefined") {
706
- module.exports = f();
707
- } else if (typeof define === "function" && define.amd) {
708
- define([], f);
709
- } else {
710
- var g;
711
- if (typeof window !== "undefined") {
712
- g = window;
713
- } else if (typeof global !== "undefined") {
714
- g = global;
715
- } else if (typeof self !== "undefined") {
716
- g = self;
717
- } else {
718
- g = this;
719
- }
720
- g.bugsnag = f();
721
- }
722
- })(function() {
723
- var define2, module2, exports2;
724
- var Breadcrumb = /* @__PURE__ */ function() {
725
- function Breadcrumb2(message, metadata, type, timestamp) {
726
- if (timestamp === void 0) {
727
- timestamp = /* @__PURE__ */ new Date();
728
- }
729
- this.type = type;
730
- this.message = message;
731
- this.metadata = metadata;
732
- this.timestamp = timestamp;
733
- }
734
- var _proto = Breadcrumb2.prototype;
735
- _proto.toJSON = function toJSON() {
736
- return {
737
- type: this.type,
738
- name: this.message,
739
- timestamp: this.timestamp,
740
- metaData: this.metadata
741
- };
742
- };
743
- return Breadcrumb2;
744
- }();
745
- var _$Breadcrumb_1 = Breadcrumb;
746
- var _$breadcrumbTypes_6 = ["navigation", "request", "process", "log", "user", "state", "error", "manual"];
747
- var _$reduce_16 = function(arr, fn, accum) {
748
- var val = accum;
749
- for (var i = 0, len = arr.length; i < len; i++)
750
- val = fn(val, arr[i], i, arr);
751
- return val;
752
- };
753
- ;
754
- var _$filter_11 = function(arr, fn) {
755
- return _$reduce_16(arr, function(accum, item, i, arr2) {
756
- return !fn(item, i, arr2) ? accum : accum.concat(item);
757
- }, []);
758
- };
759
- ;
760
- var _$includes_12 = function(arr, x) {
761
- return _$reduce_16(arr, function(accum, item, i, arr2) {
762
- return accum === true || item === x;
763
- }, false);
764
- };
765
- var _$isArray_13 = function(obj) {
766
- return Object.prototype.toString.call(obj) === "[object Array]";
767
- };
768
- var _hasDontEnumBug = !{
769
- toString: null
770
- }.propertyIsEnumerable("toString");
771
- var _dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"];
772
- var _$keys_14 = function(obj) {
773
- var result = [];
774
- var prop;
775
- for (prop in obj) {
776
- if (Object.prototype.hasOwnProperty.call(obj, prop))
777
- result.push(prop);
778
- }
779
- if (!_hasDontEnumBug)
780
- return result;
781
- for (var i = 0, len = _dontEnums.length; i < len; i++) {
782
- if (Object.prototype.hasOwnProperty.call(obj, _dontEnums[i]))
783
- result.push(_dontEnums[i]);
784
- }
785
- return result;
786
- };
787
- var _$intRange_25 = function(min, max) {
788
- if (min === void 0) {
789
- min = 1;
790
- }
791
- if (max === void 0) {
792
- max = Infinity;
793
- }
794
- return function(value) {
795
- return typeof value === "number" && parseInt("" + value, 10) === value && value >= min && value <= max;
796
- };
797
- };
798
- ;
799
- ;
800
- var _$listOfFunctions_26 = function(value) {
801
- return typeof value === "function" || _$isArray_13(value) && _$filter_11(value, function(f) {
802
- return typeof f === "function";
803
- }).length === value.length;
804
- };
805
- var _$stringWithLength_27 = function(value) {
806
- return typeof value === "string" && !!value.length;
807
- };
808
- var _$config_3 = {};
809
- ;
810
- ;
811
- ;
812
- ;
813
- ;
814
- ;
815
- ;
816
- ;
817
- ;
818
- var defaultErrorTypes = function() {
819
- return {
820
- unhandledExceptions: true,
821
- unhandledRejections: true
822
- };
823
- };
824
- _$config_3.schema = {
825
- apiKey: {
826
- defaultValue: function() {
827
- return null;
828
- },
829
- message: "is required",
830
- validate: _$stringWithLength_27
831
- },
832
- appVersion: {
833
- defaultValue: function() {
834
- return void 0;
835
- },
836
- message: "should be a string",
837
- validate: function(value) {
838
- return value === void 0 || _$stringWithLength_27(value);
839
- }
840
- },
841
- appType: {
842
- defaultValue: function() {
843
- return void 0;
844
- },
845
- message: "should be a string",
846
- validate: function(value) {
847
- return value === void 0 || _$stringWithLength_27(value);
848
- }
849
- },
850
- autoDetectErrors: {
851
- defaultValue: function() {
852
- return true;
853
- },
854
- message: "should be true|false",
855
- validate: function(value) {
856
- return value === true || value === false;
857
- }
858
- },
859
- enabledErrorTypes: {
860
- defaultValue: function() {
861
- return defaultErrorTypes();
862
- },
863
- message: "should be an object containing the flags { unhandledExceptions:true|false, unhandledRejections:true|false }",
864
- allowPartialObject: true,
865
- validate: function(value) {
866
- if (typeof value !== "object" || !value)
867
- return false;
868
- var providedKeys = _$keys_14(value);
869
- var defaultKeys = _$keys_14(defaultErrorTypes());
870
- if (_$filter_11(providedKeys, function(k) {
871
- return _$includes_12(defaultKeys, k);
872
- }).length < providedKeys.length)
873
- return false;
874
- if (_$filter_11(_$keys_14(value), function(k) {
875
- return typeof value[k] !== "boolean";
876
- }).length > 0)
877
- return false;
878
- return true;
879
- }
880
- },
881
- onError: {
882
- defaultValue: function() {
883
- return [];
884
- },
885
- message: "should be a function or array of functions",
886
- validate: _$listOfFunctions_26
887
- },
888
- onSession: {
889
- defaultValue: function() {
890
- return [];
891
- },
892
- message: "should be a function or array of functions",
893
- validate: _$listOfFunctions_26
894
- },
895
- onBreadcrumb: {
896
- defaultValue: function() {
897
- return [];
898
- },
899
- message: "should be a function or array of functions",
900
- validate: _$listOfFunctions_26
901
- },
902
- endpoints: {
903
- defaultValue: function() {
904
- return {
905
- notify: "https://notify.bugsnag.com",
906
- sessions: "https://sessions.bugsnag.com"
907
- };
908
- },
909
- message: "should be an object containing endpoint URLs { notify, sessions }",
910
- validate: function(val) {
911
- return (
912
- // first, ensure it's an object
913
- val && typeof val === "object" && // notify and sessions must always be set
914
- _$stringWithLength_27(val.notify) && _$stringWithLength_27(val.sessions) && // ensure no keys other than notify/session are set on endpoints object
915
- _$filter_11(_$keys_14(val), function(k) {
916
- return !_$includes_12(["notify", "sessions"], k);
917
- }).length === 0
918
- );
919
- }
920
- },
921
- autoTrackSessions: {
922
- defaultValue: function(val) {
923
- return true;
924
- },
925
- message: "should be true|false",
926
- validate: function(val) {
927
- return val === true || val === false;
928
- }
929
- },
930
- enabledReleaseStages: {
931
- defaultValue: function() {
932
- return null;
933
- },
934
- message: "should be an array of strings",
935
- validate: function(value) {
936
- return value === null || _$isArray_13(value) && _$filter_11(value, function(f) {
937
- return typeof f === "string";
938
- }).length === value.length;
939
- }
940
- },
941
- releaseStage: {
942
- defaultValue: function() {
943
- return "production";
944
- },
945
- message: "should be a string",
946
- validate: function(value) {
947
- return typeof value === "string" && value.length;
948
- }
949
- },
950
- maxBreadcrumbs: {
951
- defaultValue: function() {
952
- return 25;
953
- },
954
- message: "should be a number \u2264100",
955
- validate: function(value) {
956
- return _$intRange_25(0, 100)(value);
957
- }
958
- },
959
- enabledBreadcrumbTypes: {
960
- defaultValue: function() {
961
- return _$breadcrumbTypes_6;
962
- },
963
- message: "should be null or a list of available breadcrumb types (" + _$breadcrumbTypes_6.join(",") + ")",
964
- validate: function(value) {
965
- return value === null || _$isArray_13(value) && _$reduce_16(value, function(accum, maybeType) {
966
- if (accum === false)
967
- return accum;
968
- return _$includes_12(_$breadcrumbTypes_6, maybeType);
969
- }, true);
970
- }
971
- },
972
- context: {
973
- defaultValue: function() {
974
- return void 0;
975
- },
976
- message: "should be a string",
977
- validate: function(value) {
978
- return value === void 0 || typeof value === "string";
979
- }
980
- },
981
- user: {
982
- defaultValue: function() {
983
- return {};
984
- },
985
- message: "should be an object with { id, email, name } properties",
986
- validate: function(value) {
987
- return value === null || value && _$reduce_16(_$keys_14(value), function(accum, key) {
988
- return accum && _$includes_12(["id", "email", "name"], key);
989
- }, true);
990
- }
991
- },
992
- metadata: {
993
- defaultValue: function() {
994
- return {};
995
- },
996
- message: "should be an object",
997
- validate: function(value) {
998
- return typeof value === "object" && value !== null;
999
- }
1000
- },
1001
- logger: {
1002
- defaultValue: function() {
1003
- return void 0;
1004
- },
1005
- message: "should be null or an object with methods { debug, info, warn, error }",
1006
- validate: function(value) {
1007
- return !value || value && _$reduce_16(["debug", "info", "warn", "error"], function(accum, method) {
1008
- return accum && typeof value[method] === "function";
1009
- }, true);
1010
- }
1011
- },
1012
- redactedKeys: {
1013
- defaultValue: function() {
1014
- return ["password"];
1015
- },
1016
- message: "should be an array of strings|regexes",
1017
- validate: function(value) {
1018
- return _$isArray_13(value) && value.length === _$filter_11(value, function(s) {
1019
- return typeof s === "string" || s && typeof s.test === "function";
1020
- }).length;
1021
- }
1022
- },
1023
- plugins: {
1024
- defaultValue: function() {
1025
- return [];
1026
- },
1027
- message: "should be an array of plugin objects",
1028
- validate: function(value) {
1029
- return _$isArray_13(value) && value.length === _$filter_11(value, function(p) {
1030
- return p && typeof p === "object" && typeof p.load === "function";
1031
- }).length;
1032
- }
1033
- },
1034
- featureFlags: {
1035
- defaultValue: function() {
1036
- return [];
1037
- },
1038
- message: 'should be an array of objects that have a "name" property',
1039
- validate: function(value) {
1040
- return _$isArray_13(value) && value.length === _$filter_11(value, function(feature) {
1041
- return feature && typeof feature === "object" && typeof feature.name === "string";
1042
- }).length;
1043
- }
1044
- }
1045
- };
1046
- var _$errorStackParser_9 = require_error_stack_parser();
1047
- var _$assign_10 = function(target) {
1048
- for (var i = 1; i < arguments.length; i++) {
1049
- var source = arguments[i];
1050
- for (var key in source) {
1051
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1052
- target[key] = source[key];
1053
- }
1054
- }
1055
- }
1056
- return target;
1057
- };
1058
- ;
1059
- var _$map_15 = function(arr, fn) {
1060
- return _$reduce_16(arr, function(accum, item, i, arr2) {
1061
- return accum.concat(fn(item, i, arr2));
1062
- }, []);
1063
- };
1064
- var _$safeJsonStringify_31 = function(data, replacer, space, opts) {
1065
- var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : [];
1066
- var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : [];
1067
- return JSON.stringify(prepareObjForSerialization(data, redactedKeys, redactedPaths), replacer, space);
1068
- };
1069
- var MAX_DEPTH = 20;
1070
- var MAX_EDGES = 25e3;
1071
- var MIN_PRESERVED_DEPTH = 8;
1072
- var REPLACEMENT_NODE = "...";
1073
- function isError(o) {
1074
- return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o));
1075
- }
1076
- function throwsMessage(err) {
1077
- return "[Throws: " + (err ? err.message : "?") + "]";
1078
- }
1079
- function find(haystack, needle) {
1080
- for (var i = 0, len = haystack.length; i < len; i++) {
1081
- if (haystack[i] === needle)
1082
- return true;
1083
- }
1084
- return false;
1085
- }
1086
- function isDescendent(paths, path2) {
1087
- for (var i = 0, len = paths.length; i < len; i++) {
1088
- if (path2.indexOf(paths[i]) === 0)
1089
- return true;
1090
- }
1091
- return false;
1092
- }
1093
- function shouldRedact(patterns, key) {
1094
- for (var i = 0, len = patterns.length; i < len; i++) {
1095
- if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase())
1096
- return true;
1097
- if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key))
1098
- return true;
1099
- }
1100
- return false;
1101
- }
1102
- function __isArray_31(obj) {
1103
- return Object.prototype.toString.call(obj) === "[object Array]";
1104
- }
1105
- function safelyGetProp(obj, prop) {
1106
- try {
1107
- return obj[prop];
1108
- } catch (err) {
1109
- return throwsMessage(err);
1110
- }
1111
- }
1112
- function prepareObjForSerialization(obj, redactedKeys, redactedPaths) {
1113
- var seen = [];
1114
- var edges = 0;
1115
- function visit(obj2, path2) {
1116
- function edgesExceeded() {
1117
- return path2.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES;
1118
- }
1119
- edges++;
1120
- if (path2.length > MAX_DEPTH)
1121
- return REPLACEMENT_NODE;
1122
- if (edgesExceeded())
1123
- return REPLACEMENT_NODE;
1124
- if (obj2 === null || typeof obj2 !== "object")
1125
- return obj2;
1126
- if (find(seen, obj2))
1127
- return "[Circular]";
1128
- seen.push(obj2);
1129
- if (typeof obj2.toJSON === "function") {
1130
- try {
1131
- edges--;
1132
- var fResult = visit(obj2.toJSON(), path2);
1133
- seen.pop();
1134
- return fResult;
1135
- } catch (err) {
1136
- return throwsMessage(err);
1137
- }
1138
- }
1139
- var er = isError(obj2);
1140
- if (er) {
1141
- edges--;
1142
- var eResult = visit({
1143
- name: obj2.name,
1144
- message: obj2.message
1145
- }, path2);
1146
- seen.pop();
1147
- return eResult;
1148
- }
1149
- if (__isArray_31(obj2)) {
1150
- var aResult = [];
1151
- for (var i = 0, len = obj2.length; i < len; i++) {
1152
- if (edgesExceeded()) {
1153
- aResult.push(REPLACEMENT_NODE);
1154
- break;
1155
- }
1156
- aResult.push(visit(obj2[i], path2.concat("[]")));
1157
- }
1158
- seen.pop();
1159
- return aResult;
1160
- }
1161
- var result = {};
1162
- try {
1163
- for (var prop in obj2) {
1164
- if (!Object.prototype.hasOwnProperty.call(obj2, prop))
1165
- continue;
1166
- if (isDescendent(redactedPaths, path2.join(".")) && shouldRedact(redactedKeys, prop)) {
1167
- result[prop] = "[REDACTED]";
1168
- continue;
1169
- }
1170
- if (edgesExceeded()) {
1171
- result[prop] = REPLACEMENT_NODE;
1172
- break;
1173
- }
1174
- result[prop] = visit(safelyGetProp(obj2, prop), path2.concat(prop));
1175
- }
1176
- } catch (e) {
1177
- }
1178
- seen.pop();
1179
- return result;
1180
- }
1181
- return visit(obj, []);
1182
- }
1183
- ;
1184
- ;
1185
- ;
1186
- ;
1187
- function add(existingFeatures, existingFeatureKeys, name2, variant) {
1188
- if (typeof name2 !== "string") {
1189
- return;
1190
- }
1191
- if (variant === void 0) {
1192
- variant = null;
1193
- } else if (variant !== null && typeof variant !== "string") {
1194
- variant = _$safeJsonStringify_31(variant);
1195
- }
1196
- var existingIndex = existingFeatureKeys[name2];
1197
- if (typeof existingIndex === "number") {
1198
- existingFeatures[existingIndex] = {
1199
- name: name2,
1200
- variant
1201
- };
1202
- return;
1203
- }
1204
- existingFeatures.push({
1205
- name: name2,
1206
- variant
1207
- });
1208
- existingFeatureKeys[name2] = existingFeatures.length - 1;
1209
- }
1210
- function merge(existingFeatures, newFeatures, existingFeatureKeys) {
1211
- if (!_$isArray_13(newFeatures)) {
1212
- return;
1213
- }
1214
- for (var i = 0; i < newFeatures.length; ++i) {
1215
- var feature = newFeatures[i];
1216
- if (feature === null || typeof feature !== "object") {
1217
- continue;
1218
- }
1219
- add(existingFeatures, existingFeatureKeys, feature.name, feature.variant);
1220
- }
1221
- return existingFeatures;
1222
- }
1223
- function toEventApi(featureFlags) {
1224
- return _$map_15(_$filter_11(featureFlags, Boolean), function(_ref) {
1225
- var name2 = _ref.name, variant = _ref.variant;
1226
- var flag = {
1227
- featureFlag: name2
1228
- };
1229
- if (typeof variant === "string") {
1230
- flag.variant = variant;
1231
- }
1232
- return flag;
1233
- });
1234
- }
1235
- function clear(features, featuresIndex, name2) {
1236
- var existingIndex = featuresIndex[name2];
1237
- if (typeof existingIndex === "number") {
1238
- features[existingIndex] = null;
1239
- delete featuresIndex[name2];
1240
- }
1241
- }
1242
- var _$featureFlagDelegate_17 = {
1243
- add,
1244
- clear,
1245
- merge,
1246
- toEventApi
1247
- };
1248
- var _$hasStack_18 = function(err) {
1249
- return !!err && (!!err.stack || !!err.stacktrace || !!err["opera#sourceloc"]) && typeof (err.stack || err.stacktrace || err["opera#sourceloc"]) === "string" && err.stack !== err.name + ": " + err.message;
1250
- };
1251
- var _$iserror_19 = require_iserror();
1252
- ;
1253
- var __add_21 = function(state, section, keyOrObj, maybeVal) {
1254
- var _updates;
1255
- if (!section)
1256
- return;
1257
- var updates;
1258
- if (keyOrObj === null)
1259
- return __clear_21(state, section);
1260
- if (typeof keyOrObj === "object")
1261
- updates = keyOrObj;
1262
- if (typeof keyOrObj === "string")
1263
- updates = (_updates = {}, _updates[keyOrObj] = maybeVal, _updates);
1264
- if (!updates)
1265
- return;
1266
- if (section === "__proto__" || section === "constructor" || section === "prototype") {
1267
- return;
1268
- }
1269
- if (!state[section])
1270
- state[section] = {};
1271
- state[section] = _$assign_10({}, state[section], updates);
1272
- };
1273
- var get = function(state, section, key) {
1274
- if (typeof section !== "string")
1275
- return void 0;
1276
- if (!key) {
1277
- return state[section];
1278
- }
1279
- if (state[section]) {
1280
- return state[section][key];
1281
- }
1282
- return void 0;
1283
- };
1284
- var __clear_21 = function(state, section, key) {
1285
- if (typeof section !== "string")
1286
- return;
1287
- if (!key) {
1288
- delete state[section];
1289
- return;
1290
- }
1291
- if (section === "__proto__" || section === "constructor" || section === "prototype") {
1292
- return;
1293
- }
1294
- if (state[section]) {
1295
- delete state[section][key];
1296
- }
1297
- };
1298
- var _$metadataDelegate_21 = {
1299
- add: __add_21,
1300
- get,
1301
- clear: __clear_21
1302
- };
1303
- ;
1304
- var StackGenerator = require_stack_generator();
1305
- ;
1306
- ;
1307
- ;
1308
- ;
1309
- ;
1310
- ;
1311
- ;
1312
- ;
1313
- var Event2 = /* @__PURE__ */ function() {
1314
- function Event3(errorClass, errorMessage, stacktrace, handledState, originalError) {
1315
- if (stacktrace === void 0) {
1316
- stacktrace = [];
1317
- }
1318
- if (handledState === void 0) {
1319
- handledState = defaultHandledState();
1320
- }
1321
- this.apiKey = void 0;
1322
- this.context = void 0;
1323
- this.groupingHash = void 0;
1324
- this.originalError = originalError;
1325
- this._handledState = handledState;
1326
- this.severity = this._handledState.severity;
1327
- this.unhandled = this._handledState.unhandled;
1328
- this.app = {};
1329
- this.device = {};
1330
- this.request = {};
1331
- this.breadcrumbs = [];
1332
- this.threads = [];
1333
- this._metadata = {};
1334
- this._features = [];
1335
- this._featuresIndex = {};
1336
- this._user = {};
1337
- this._session = void 0;
1338
- this.errors = [createBugsnagError(errorClass, errorMessage, Event3.__type, stacktrace)];
1339
- }
1340
- var _proto = Event3.prototype;
1341
- _proto.addMetadata = function addMetadata(section, keyOrObj, maybeVal) {
1342
- return _$metadataDelegate_21.add(this._metadata, section, keyOrObj, maybeVal);
1343
- };
1344
- _proto.getMetadata = function getMetadata(section, key) {
1345
- return _$metadataDelegate_21.get(this._metadata, section, key);
1346
- };
1347
- _proto.clearMetadata = function clearMetadata(section, key) {
1348
- return _$metadataDelegate_21.clear(this._metadata, section, key);
1349
- };
1350
- _proto.addFeatureFlag = function addFeatureFlag(name2, variant) {
1351
- if (variant === void 0) {
1352
- variant = null;
1353
- }
1354
- _$featureFlagDelegate_17.add(this._features, this._featuresIndex, name2, variant);
1355
- };
1356
- _proto.addFeatureFlags = function addFeatureFlags(featureFlags) {
1357
- _$featureFlagDelegate_17.merge(this._features, featureFlags, this._featuresIndex);
1358
- };
1359
- _proto.getFeatureFlags = function getFeatureFlags() {
1360
- return _$featureFlagDelegate_17.toEventApi(this._features);
1361
- };
1362
- _proto.clearFeatureFlag = function clearFeatureFlag(name2) {
1363
- _$featureFlagDelegate_17.clear(this._features, this._featuresIndex, name2);
1364
- };
1365
- _proto.clearFeatureFlags = function clearFeatureFlags() {
1366
- this._features = [];
1367
- this._featuresIndex = {};
1368
- };
1369
- _proto.getUser = function getUser() {
1370
- return this._user;
1371
- };
1372
- _proto.setUser = function setUser(id, email, name2) {
1373
- this._user = {
1374
- id,
1375
- email,
1376
- name: name2
1377
- };
1378
- };
1379
- _proto.toJSON = function toJSON() {
1380
- return {
1381
- payloadVersion: "4",
1382
- exceptions: _$map_15(this.errors, function(er) {
1383
- return _$assign_10({}, er, {
1384
- message: er.errorMessage
1385
- });
1386
- }),
1387
- severity: this.severity,
1388
- unhandled: this._handledState.unhandled,
1389
- severityReason: this._handledState.severityReason,
1390
- app: this.app,
1391
- device: this.device,
1392
- request: this.request,
1393
- breadcrumbs: this.breadcrumbs,
1394
- context: this.context,
1395
- groupingHash: this.groupingHash,
1396
- metaData: this._metadata,
1397
- user: this._user,
1398
- session: this._session,
1399
- featureFlags: this.getFeatureFlags()
1400
- };
1401
- };
1402
- return Event3;
1403
- }();
1404
- var formatStackframe = function(frame) {
1405
- var f = {
1406
- file: frame.fileName,
1407
- method: normaliseFunctionName(frame.functionName),
1408
- lineNumber: frame.lineNumber,
1409
- columnNumber: frame.columnNumber,
1410
- code: void 0,
1411
- inProject: void 0
1412
- };
1413
- if (f.lineNumber > -1 && !f.file && !f.method) {
1414
- f.file = "global code";
1415
- }
1416
- return f;
1417
- };
1418
- var normaliseFunctionName = function(name2) {
1419
- return /^global code$/i.test(name2) ? "global code" : name2;
1420
- };
1421
- var defaultHandledState = function() {
1422
- return {
1423
- unhandled: false,
1424
- severity: "warning",
1425
- severityReason: {
1426
- type: "handledException"
1427
- }
1428
- };
1429
- };
1430
- var ensureString = function(str) {
1431
- return typeof str === "string" ? str : "";
1432
- };
1433
- function createBugsnagError(errorClass, errorMessage, type, stacktrace) {
1434
- return {
1435
- errorClass: ensureString(errorClass),
1436
- errorMessage: ensureString(errorMessage),
1437
- type,
1438
- stacktrace: _$reduce_16(stacktrace, function(accum, frame) {
1439
- var f = formatStackframe(frame);
1440
- try {
1441
- if (JSON.stringify(f) === "{}")
1442
- return accum;
1443
- return accum.concat(f);
1444
- } catch (e) {
1445
- return accum;
1446
- }
1447
- }, [])
1448
- };
1449
- }
1450
- function getCauseStack(error) {
1451
- if (error.cause) {
1452
- return [error].concat(getCauseStack(error.cause));
1453
- } else {
1454
- return [error];
1455
- }
1456
- }
1457
- Event2.getStacktrace = function(error, errorFramesToSkip, backtraceFramesToSkip) {
1458
- if (_$hasStack_18(error))
1459
- return _$errorStackParser_9.parse(error).slice(errorFramesToSkip);
1460
- try {
1461
- return _$filter_11(StackGenerator.backtrace(), function(frame) {
1462
- return (frame.functionName || "").indexOf("StackGenerator$$") === -1;
1463
- }).slice(1 + backtraceFramesToSkip);
1464
- } catch (e) {
1465
- return [];
1466
- }
1467
- };
1468
- Event2.create = function(maybeError, tolerateNonErrors, handledState, component, errorFramesToSkip, logger) {
1469
- if (errorFramesToSkip === void 0) {
1470
- errorFramesToSkip = 0;
1471
- }
1472
- var _normaliseError = normaliseError(maybeError, tolerateNonErrors, component, logger), error = _normaliseError[0], internalFrames = _normaliseError[1];
1473
- var event;
1474
- try {
1475
- var stacktrace = Event2.getStacktrace(
1476
- error,
1477
- // if an error was created/throw in the normaliseError() function, we need to
1478
- // tell the getStacktrace() function to skip the number of frames we know will
1479
- // be from our own functions. This is added to the number of frames deep we
1480
- // were told about
1481
- internalFrames > 0 ? 1 + internalFrames + errorFramesToSkip : 0,
1482
- // if there's no stacktrace, the callstack may be walked to generated one.
1483
- // this is how many frames should be removed because they come from our library
1484
- 1 + errorFramesToSkip
1485
- );
1486
- event = new Event2(error.name, error.message, stacktrace, handledState, maybeError);
1487
- } catch (e) {
1488
- event = new Event2(error.name, error.message, [], handledState, maybeError);
1489
- }
1490
- if (error.name === "InvalidError") {
1491
- event.addMetadata("" + component, "non-error parameter", makeSerialisable(maybeError));
1492
- }
1493
- if (error.cause) {
1494
- var _event$errors;
1495
- var causes = getCauseStack(error).slice(1);
1496
- var normalisedCauses = _$map_15(causes, function(cause) {
1497
- var stacktrace2 = _$iserror_19(cause) && _$hasStack_18(cause) ? _$errorStackParser_9.parse(cause) : [];
1498
- var _normaliseError2 = normaliseError(cause, true, "error cause"), error2 = _normaliseError2[0];
1499
- if (error2.name === "InvalidError")
1500
- event.addMetadata("error cause", makeSerialisable(cause));
1501
- return createBugsnagError(error2.name, error2.message, Event2.__type, stacktrace2);
1502
- });
1503
- (_event$errors = event.errors).push.apply(_event$errors, normalisedCauses);
1504
- }
1505
- return event;
1506
- };
1507
- var makeSerialisable = function(err) {
1508
- if (err === null)
1509
- return "null";
1510
- if (err === void 0)
1511
- return "undefined";
1512
- return err;
1513
- };
1514
- var normaliseError = function(maybeError, tolerateNonErrors, component, logger) {
1515
- var error;
1516
- var internalFrames = 0;
1517
- var createAndLogInputError = function(reason) {
1518
- var verb = component === "error cause" ? "was" : "received";
1519
- if (logger)
1520
- logger.warn(component + " " + verb + ' a non-error: "' + reason + '"');
1521
- var err = new Error(component + " " + verb + ' a non-error. See "' + component + '" tab for more detail.');
1522
- err.name = "InvalidError";
1523
- return err;
1524
- };
1525
- if (!tolerateNonErrors) {
1526
- if (_$iserror_19(maybeError)) {
1527
- error = maybeError;
1528
- } else {
1529
- error = createAndLogInputError(typeof maybeError);
1530
- internalFrames += 2;
1531
- }
1532
- } else {
1533
- switch (typeof maybeError) {
1534
- case "string":
1535
- case "number":
1536
- case "boolean":
1537
- error = new Error(String(maybeError));
1538
- internalFrames += 1;
1539
- break;
1540
- case "function":
1541
- error = createAndLogInputError("function");
1542
- internalFrames += 2;
1543
- break;
1544
- case "object":
1545
- if (maybeError !== null && _$iserror_19(maybeError)) {
1546
- error = maybeError;
1547
- } else if (maybeError !== null && hasNecessaryFields(maybeError)) {
1548
- error = new Error(maybeError.message || maybeError.errorMessage);
1549
- error.name = maybeError.name || maybeError.errorClass;
1550
- internalFrames += 1;
1551
- } else {
1552
- error = createAndLogInputError(maybeError === null ? "null" : "unsupported object");
1553
- internalFrames += 2;
1554
- }
1555
- break;
1556
- default:
1557
- error = createAndLogInputError("nothing");
1558
- internalFrames += 2;
1559
- }
1560
- }
1561
- if (!_$hasStack_18(error)) {
1562
- try {
1563
- throw error;
1564
- } catch (e) {
1565
- if (_$hasStack_18(e)) {
1566
- error = e;
1567
- internalFrames = 1;
1568
- }
1569
- }
1570
- }
1571
- return [error, internalFrames];
1572
- };
1573
- Event2.__type = "browserjs";
1574
- var hasNecessaryFields = function(error) {
1575
- return (typeof error.name === "string" || typeof error.errorClass === "string") && (typeof error.message === "string" || typeof error.errorMessage === "string");
1576
- };
1577
- var _$Event_4 = Event2;
1578
- var _$asyncEvery_5 = function(arr, fn, cb) {
1579
- var index = 0;
1580
- var next = function() {
1581
- if (index >= arr.length)
1582
- return cb(null, true);
1583
- fn(arr[index], function(err, result) {
1584
- if (err)
1585
- return cb(err);
1586
- if (result === false)
1587
- return cb(null, false);
1588
- index++;
1589
- next();
1590
- });
1591
- };
1592
- next();
1593
- };
1594
- ;
1595
- var _$callbackRunner_7 = function(callbacks, event, onCallbackError, cb) {
1596
- var runMaybeAsyncCallback = function(fn, cb2) {
1597
- if (typeof fn !== "function")
1598
- return cb2(null);
1599
- try {
1600
- if (fn.length !== 2) {
1601
- var ret = fn(event);
1602
- if (ret && typeof ret.then === "function") {
1603
- return ret.then(
1604
- // resolve
1605
- function(val) {
1606
- return setTimeout(function() {
1607
- return cb2(null, val);
1608
- });
1609
- },
1610
- // reject
1611
- function(err) {
1612
- setTimeout(function() {
1613
- onCallbackError(err);
1614
- return cb2(null, true);
1615
- });
1616
- }
1617
- );
1618
- }
1619
- return cb2(null, ret);
1620
- }
1621
- fn(event, function(err, result) {
1622
- if (err) {
1623
- onCallbackError(err);
1624
- return cb2(null);
1625
- }
1626
- cb2(null, result);
1627
- });
1628
- } catch (e) {
1629
- onCallbackError(e);
1630
- cb2(null);
1631
- }
1632
- };
1633
- _$asyncEvery_5(callbacks, runMaybeAsyncCallback, cb);
1634
- };
1635
- var _$syncCallbackRunner_24 = function(callbacks, callbackArg, callbackType, logger) {
1636
- var ignore = false;
1637
- var cbs = callbacks.slice();
1638
- while (!ignore) {
1639
- if (!cbs.length)
1640
- break;
1641
- try {
1642
- ignore = cbs.pop()(callbackArg) === false;
1643
- } catch (e) {
1644
- logger.error("Error occurred in " + callbackType + " callback, continuing anyway\u2026");
1645
- logger.error(e);
1646
- }
1647
- }
1648
- return ignore;
1649
- };
1650
- var _$pad_30 = function pad(num, size) {
1651
- var s = "000000000" + num;
1652
- return s.substr(s.length - size);
1653
- };
1654
- ;
1655
- var os = __require("os"), padding = 2, pid = _$pad_30(process.pid.toString(36), padding), hostname = os.hostname(), length = hostname.length, hostId = _$pad_30(hostname.split("").reduce(function(prev, char) {
1656
- return +prev + char.charCodeAt(0);
1657
- }, +length + 36).toString(36), padding);
1658
- var _$fingerprint_29 = function fingerprint() {
1659
- return pid + hostId;
1660
- };
1661
- ;
1662
- ;
1663
- var c = 0, blockSize = 4, base = 36, discreteValues = Math.pow(base, blockSize);
1664
- function randomBlock() {
1665
- return _$pad_30((Math.random() * discreteValues << 0).toString(base), blockSize);
1666
- }
1667
- function safeCounter() {
1668
- c = c < discreteValues ? c : 0;
1669
- c++;
1670
- return c - 1;
1671
- }
1672
- function cuid() {
1673
- var letter = "c", timestamp = (/* @__PURE__ */ new Date()).getTime().toString(base), counter = _$pad_30(safeCounter().toString(base), blockSize), print = _$fingerprint_29(), random = randomBlock() + randomBlock();
1674
- return letter + timestamp + counter + print + random;
1675
- }
1676
- cuid.fingerprint = _$fingerprint_29;
1677
- var _$cuid_28 = cuid;
1678
- ;
1679
- var Session = /* @__PURE__ */ function() {
1680
- function Session2() {
1681
- this.id = _$cuid_28();
1682
- this.startedAt = /* @__PURE__ */ new Date();
1683
- this._handled = 0;
1684
- this._unhandled = 0;
1685
- this._user = {};
1686
- this.app = {};
1687
- this.device = {};
1688
- }
1689
- var _proto = Session2.prototype;
1690
- _proto.getUser = function getUser() {
1691
- return this._user;
1692
- };
1693
- _proto.setUser = function setUser(id, email, name2) {
1694
- this._user = {
1695
- id,
1696
- email,
1697
- name: name2
1698
- };
1699
- };
1700
- _proto.toJSON = function toJSON() {
1701
- return {
1702
- id: this.id,
1703
- startedAt: this.startedAt,
1704
- events: {
1705
- handled: this._handled,
1706
- unhandled: this._unhandled
1707
- }
1708
- };
1709
- };
1710
- _proto._track = function _track(event) {
1711
- this[event._handledState.unhandled ? "_unhandled" : "_handled"] += 1;
1712
- };
1713
- return Session2;
1714
- }();
1715
- var _$Session_32 = Session;
1716
- ;
1717
- ;
1718
- ;
1719
- ;
1720
- ;
1721
- ;
1722
- ;
1723
- ;
1724
- ;
1725
- ;
1726
- ;
1727
- ;
1728
- ;
1729
- ;
1730
- var __add_2 = _$featureFlagDelegate_17.add, __clear_2 = _$featureFlagDelegate_17.clear, __merge_2 = _$featureFlagDelegate_17.merge;
1731
- var noop = function() {
1732
- };
1733
- var Client = /* @__PURE__ */ function() {
1734
- function Client2(configuration, schema2, internalPlugins2, notifier) {
1735
- var _this = this;
1736
- if (schema2 === void 0) {
1737
- schema2 = _$config_3.schema;
1738
- }
1739
- if (internalPlugins2 === void 0) {
1740
- internalPlugins2 = [];
1741
- }
1742
- this._notifier = notifier;
1743
- this._config = {};
1744
- this._schema = schema2;
1745
- this._delivery = {
1746
- sendSession: noop,
1747
- sendEvent: noop
1748
- };
1749
- this._logger = {
1750
- debug: noop,
1751
- info: noop,
1752
- warn: noop,
1753
- error: noop
1754
- };
1755
- this._plugins = {};
1756
- this._breadcrumbs = [];
1757
- this._session = null;
1758
- this._metadata = {};
1759
- this._featuresIndex = {};
1760
- this._features = [];
1761
- this._context = void 0;
1762
- this._user = {};
1763
- this._cbs = {
1764
- e: [],
1765
- s: [],
1766
- sp: [],
1767
- b: []
1768
- };
1769
- this.Client = Client2;
1770
- this.Event = _$Event_4;
1771
- this.Breadcrumb = _$Breadcrumb_1;
1772
- this.Session = _$Session_32;
1773
- this._config = this._configure(configuration, internalPlugins2);
1774
- _$map_15(internalPlugins2.concat(this._config.plugins), function(pl) {
1775
- if (pl)
1776
- _this._loadPlugin(pl);
1777
- });
1778
- this._depth = 1;
1779
- var self2 = this;
1780
- var notify = this.notify;
1781
- this.notify = function() {
1782
- return notify.apply(self2, arguments);
1783
- };
1784
- }
1785
- var _proto = Client2.prototype;
1786
- _proto.addMetadata = function addMetadata(section, keyOrObj, maybeVal) {
1787
- return _$metadataDelegate_21.add(this._metadata, section, keyOrObj, maybeVal);
1788
- };
1789
- _proto.getMetadata = function getMetadata(section, key) {
1790
- return _$metadataDelegate_21.get(this._metadata, section, key);
1791
- };
1792
- _proto.clearMetadata = function clearMetadata(section, key) {
1793
- return _$metadataDelegate_21.clear(this._metadata, section, key);
1794
- };
1795
- _proto.addFeatureFlag = function addFeatureFlag(name2, variant) {
1796
- if (variant === void 0) {
1797
- variant = null;
1798
- }
1799
- __add_2(this._features, this._featuresIndex, name2, variant);
1800
- };
1801
- _proto.addFeatureFlags = function addFeatureFlags(featureFlags) {
1802
- __merge_2(this._features, featureFlags, this._featuresIndex);
1803
- };
1804
- _proto.clearFeatureFlag = function clearFeatureFlag(name2) {
1805
- __clear_2(this._features, this._featuresIndex, name2);
1806
- };
1807
- _proto.clearFeatureFlags = function clearFeatureFlags() {
1808
- this._features = [];
1809
- this._featuresIndex = {};
1810
- };
1811
- _proto.getContext = function getContext2() {
1812
- return this._context;
1813
- };
1814
- _proto.setContext = function setContext(c2) {
1815
- this._context = c2;
1816
- };
1817
- _proto._configure = function _configure(opts, internalPlugins2) {
1818
- var schema2 = _$reduce_16(internalPlugins2, function(schema3, plugin) {
1819
- if (plugin && plugin.configSchema)
1820
- return _$assign_10({}, schema3, plugin.configSchema);
1821
- return schema3;
1822
- }, this._schema);
1823
- var _reduce = _$reduce_16(_$keys_14(schema2), function(accum, key) {
1824
- var defaultValue = schema2[key].defaultValue(opts[key]);
1825
- if (opts[key] !== void 0) {
1826
- var valid = schema2[key].validate(opts[key]);
1827
- if (!valid) {
1828
- accum.errors[key] = schema2[key].message;
1829
- accum.config[key] = defaultValue;
1830
- } else {
1831
- if (schema2[key].allowPartialObject) {
1832
- accum.config[key] = _$assign_10(defaultValue, opts[key]);
1833
- } else {
1834
- accum.config[key] = opts[key];
1835
- }
1836
- }
1837
- } else {
1838
- accum.config[key] = defaultValue;
1839
- }
1840
- return accum;
1841
- }, {
1842
- errors: {},
1843
- config: {}
1844
- }), errors = _reduce.errors, config = _reduce.config;
1845
- if (schema2.apiKey) {
1846
- if (!config.apiKey)
1847
- throw new Error("No Bugsnag API Key set");
1848
- if (!/^[0-9a-f]{32}$/i.test(config.apiKey))
1849
- errors.apiKey = "should be a string of 32 hexadecimal characters";
1850
- }
1851
- this._metadata = _$assign_10({}, config.metadata);
1852
- __merge_2(this._features, config.featureFlags, this._featuresIndex);
1853
- this._user = _$assign_10({}, config.user);
1854
- this._context = config.context;
1855
- if (config.logger)
1856
- this._logger = config.logger;
1857
- if (config.onError)
1858
- this._cbs.e = this._cbs.e.concat(config.onError);
1859
- if (config.onBreadcrumb)
1860
- this._cbs.b = this._cbs.b.concat(config.onBreadcrumb);
1861
- if (config.onSession)
1862
- this._cbs.s = this._cbs.s.concat(config.onSession);
1863
- if (_$keys_14(errors).length) {
1864
- this._logger.warn(generateConfigErrorMessage(errors, opts));
1865
- }
1866
- return config;
1867
- };
1868
- _proto.getUser = function getUser() {
1869
- return this._user;
1870
- };
1871
- _proto.setUser = function setUser(id, email, name2) {
1872
- this._user = {
1873
- id,
1874
- email,
1875
- name: name2
1876
- };
1877
- };
1878
- _proto._loadPlugin = function _loadPlugin(plugin) {
1879
- var result = plugin.load(this);
1880
- if (plugin.name)
1881
- this._plugins["~" + plugin.name + "~"] = result;
1882
- return this;
1883
- };
1884
- _proto.getPlugin = function getPlugin(name2) {
1885
- return this._plugins["~" + name2 + "~"];
1886
- };
1887
- _proto._setDelivery = function _setDelivery(d) {
1888
- this._delivery = d(this);
1889
- };
1890
- _proto.startSession = function startSession() {
1891
- var session = new _$Session_32();
1892
- session.app.releaseStage = this._config.releaseStage;
1893
- session.app.version = this._config.appVersion;
1894
- session.app.type = this._config.appType;
1895
- session._user = _$assign_10({}, this._user);
1896
- var ignore = _$syncCallbackRunner_24(this._cbs.s, session, "onSession", this._logger);
1897
- if (ignore) {
1898
- this._logger.debug("Session not started due to onSession callback");
1899
- return this;
1900
- }
1901
- return this._sessionDelegate.startSession(this, session);
1902
- };
1903
- _proto.addOnError = function addOnError(fn, front) {
1904
- if (front === void 0) {
1905
- front = false;
1906
- }
1907
- this._cbs.e[front ? "unshift" : "push"](fn);
1908
- };
1909
- _proto.removeOnError = function removeOnError(fn) {
1910
- this._cbs.e = _$filter_11(this._cbs.e, function(f) {
1911
- return f !== fn;
1912
- });
1913
- };
1914
- _proto._addOnSessionPayload = function _addOnSessionPayload(fn) {
1915
- this._cbs.sp.push(fn);
1916
- };
1917
- _proto.addOnSession = function addOnSession(fn) {
1918
- this._cbs.s.push(fn);
1919
- };
1920
- _proto.removeOnSession = function removeOnSession(fn) {
1921
- this._cbs.s = _$filter_11(this._cbs.s, function(f) {
1922
- return f !== fn;
1923
- });
1924
- };
1925
- _proto.addOnBreadcrumb = function addOnBreadcrumb(fn, front) {
1926
- if (front === void 0) {
1927
- front = false;
1928
- }
1929
- this._cbs.b[front ? "unshift" : "push"](fn);
1930
- };
1931
- _proto.removeOnBreadcrumb = function removeOnBreadcrumb(fn) {
1932
- this._cbs.b = _$filter_11(this._cbs.b, function(f) {
1933
- return f !== fn;
1934
- });
1935
- };
1936
- _proto.pauseSession = function pauseSession() {
1937
- return this._sessionDelegate.pauseSession(this);
1938
- };
1939
- _proto.resumeSession = function resumeSession() {
1940
- return this._sessionDelegate.resumeSession(this);
1941
- };
1942
- _proto.leaveBreadcrumb = function leaveBreadcrumb(message, metadata, type) {
1943
- message = typeof message === "string" ? message : "";
1944
- type = typeof type === "string" && _$includes_12(_$breadcrumbTypes_6, type) ? type : "manual";
1945
- metadata = typeof metadata === "object" && metadata !== null ? metadata : {};
1946
- if (!message)
1947
- return;
1948
- var crumb = new _$Breadcrumb_1(message, metadata, type);
1949
- var ignore = _$syncCallbackRunner_24(this._cbs.b, crumb, "onBreadcrumb", this._logger);
1950
- if (ignore) {
1951
- this._logger.debug("Breadcrumb not attached due to onBreadcrumb callback");
1952
- return;
1953
- }
1954
- this._breadcrumbs.push(crumb);
1955
- if (this._breadcrumbs.length > this._config.maxBreadcrumbs) {
1956
- this._breadcrumbs = this._breadcrumbs.slice(this._breadcrumbs.length - this._config.maxBreadcrumbs);
1957
- }
1958
- };
1959
- _proto._isBreadcrumbTypeEnabled = function _isBreadcrumbTypeEnabled(type) {
1960
- var types = this._config.enabledBreadcrumbTypes;
1961
- return types === null || _$includes_12(types, type);
1962
- };
1963
- _proto.notify = function notify(maybeError, onError, postReportCallback) {
1964
- if (postReportCallback === void 0) {
1965
- postReportCallback = noop;
1966
- }
1967
- var event = _$Event_4.create(maybeError, true, void 0, "notify()", this._depth + 1, this._logger);
1968
- this._notify(event, onError, postReportCallback);
1969
- };
1970
- _proto._notify = function _notify(event, onError, postReportCallback) {
1971
- var _this2 = this;
1972
- if (postReportCallback === void 0) {
1973
- postReportCallback = noop;
1974
- }
1975
- event.app = _$assign_10({}, event.app, {
1976
- releaseStage: this._config.releaseStage,
1977
- version: this._config.appVersion,
1978
- type: this._config.appType
1979
- });
1980
- event.context = event.context || this._context;
1981
- event._metadata = _$assign_10({}, event._metadata, this._metadata);
1982
- event._user = _$assign_10({}, event._user, this._user);
1983
- event.breadcrumbs = this._breadcrumbs.slice();
1984
- __merge_2(event._features, this._features, event._featuresIndex);
1985
- if (this._config.enabledReleaseStages !== null && !_$includes_12(this._config.enabledReleaseStages, this._config.releaseStage)) {
1986
- this._logger.warn("Event not sent due to releaseStage/enabledReleaseStages configuration");
1987
- return postReportCallback(null, event);
1988
- }
1989
- var originalSeverity = event.severity;
1990
- var onCallbackError = function(err) {
1991
- _this2._logger.error("Error occurred in onError callback, continuing anyway\u2026");
1992
- _this2._logger.error(err);
1993
- };
1994
- var callbacks = [].concat(this._cbs.e).concat(onError);
1995
- _$callbackRunner_7(callbacks, event, onCallbackError, function(err, shouldSend) {
1996
- if (err)
1997
- onCallbackError(err);
1998
- if (!shouldSend) {
1999
- _this2._logger.debug("Event not sent due to onError callback");
2000
- return postReportCallback(null, event);
2001
- }
2002
- if (_this2._isBreadcrumbTypeEnabled("error")) {
2003
- Client2.prototype.leaveBreadcrumb.call(_this2, event.errors[0].errorClass, {
2004
- errorClass: event.errors[0].errorClass,
2005
- errorMessage: event.errors[0].errorMessage,
2006
- severity: event.severity
2007
- }, "error");
2008
- }
2009
- if (originalSeverity !== event.severity) {
2010
- event._handledState.severityReason = {
2011
- type: "userCallbackSetSeverity"
2012
- };
2013
- }
2014
- if (event.unhandled !== event._handledState.unhandled) {
2015
- event._handledState.severityReason.unhandledOverridden = true;
2016
- event._handledState.unhandled = event.unhandled;
2017
- }
2018
- if (_this2._session) {
2019
- _this2._session._track(event);
2020
- event._session = _this2._session;
2021
- }
2022
- _this2._delivery.sendEvent({
2023
- apiKey: event.apiKey || _this2._config.apiKey,
2024
- notifier: _this2._notifier,
2025
- events: [event]
2026
- }, function(err2) {
2027
- return postReportCallback(err2, event);
2028
- });
2029
- });
2030
- };
2031
- return Client2;
2032
- }();
2033
- var generateConfigErrorMessage = function(errors, rawInput) {
2034
- var er = new Error("Invalid configuration\n" + _$map_15(_$keys_14(errors), function(key) {
2035
- return " - " + key + " " + errors[key] + ", got " + stringify(rawInput[key]);
2036
- }).join("\n\n"));
2037
- return er;
2038
- };
2039
- var stringify = function(val) {
2040
- switch (typeof val) {
2041
- case "string":
2042
- case "number":
2043
- case "object":
2044
- return JSON.stringify(val);
2045
- default:
2046
- return String(val);
2047
- }
2048
- };
2049
- var _$Client_2 = Client;
2050
- var _$jsonPayload_20 = {};
2051
- ;
2052
- var EVENT_REDACTION_PATHS = ["events.[].metaData", "events.[].breadcrumbs.[].metaData", "events.[].request"];
2053
- _$jsonPayload_20.event = function(event, redactedKeys) {
2054
- var payload = _$safeJsonStringify_31(event, null, null, {
2055
- redactedPaths: EVENT_REDACTION_PATHS,
2056
- redactedKeys
2057
- });
2058
- if (payload.length > 1e6) {
2059
- event.events[0]._metadata = {
2060
- notifier: "WARNING!\nSerialized payload was " + payload.length / 1e6 + "MB (limit = 1MB)\nmetadata was removed"
2061
- };
2062
- payload = _$safeJsonStringify_31(event, null, null, {
2063
- redactedPaths: EVENT_REDACTION_PATHS,
2064
- redactedKeys
2065
- });
2066
- }
2067
- return payload;
2068
- };
2069
- _$jsonPayload_20.session = function(session, redactedKeys) {
2070
- var payload = _$safeJsonStringify_31(session, null, null);
2071
- return payload;
2072
- };
2073
- var http = __require("http");
2074
- var https = __require("https");
2075
- var ___require_34 = __require("url"), parse = ___require_34.parse;
2076
- var _$request_34 = function(_ref, cb) {
2077
- var url2 = _ref.url, headers = _ref.headers, body = _ref.body, agent = _ref.agent;
2078
- var didError = false;
2079
- var onError = function(err) {
2080
- if (didError)
2081
- return;
2082
- didError = true;
2083
- cb(err);
2084
- };
2085
- var parsedUrl = parse(url2);
2086
- var secure = parsedUrl.protocol === "https:";
2087
- var transport = secure ? https : http;
2088
- var req = transport.request({
2089
- method: "POST",
2090
- hostname: parsedUrl.hostname,
2091
- port: parsedUrl.port,
2092
- path: parsedUrl.path,
2093
- headers,
2094
- agent
2095
- });
2096
- req.on("error", onError);
2097
- req.on("response", function(res) {
2098
- bufferResponse(res, function(err, body2) {
2099
- if (err)
2100
- return onError(err);
2101
- if (res.statusCode < 200 || res.statusCode >= 300) {
2102
- return onError(new Error("Bad statusCode from API: " + res.statusCode + "\n" + body2));
2103
- }
2104
- cb(null, body2);
2105
- });
2106
- });
2107
- req.write(body);
2108
- req.end();
2109
- };
2110
- var bufferResponse = function(stream, cb) {
2111
- var data = "";
2112
- stream.on("error", cb);
2113
- stream.setEncoding("utf8");
2114
- stream.on("data", function(d) {
2115
- data += d;
2116
- });
2117
- stream.on("end", function() {
2118
- return cb(null, data);
2119
- });
2120
- };
2121
- ;
2122
- ;
2123
- var _$delivery_33 = function(client) {
2124
- return {
2125
- sendEvent: function(event, cb) {
2126
- if (cb === void 0) {
2127
- cb = function() {
2128
- };
2129
- }
2130
- var body = _$jsonPayload_20.event(event, client._config.redactedKeys);
2131
- var _cb = function(err) {
2132
- if (err)
2133
- client._logger.error("Event failed to send\u2026\n" + (err && err.stack ? err.stack : err), err);
2134
- if (body.length > 1e6) {
2135
- client._logger.warn("Event oversized (" + (body.length / 1e6).toFixed(2) + " MB)");
2136
- }
2137
- cb(err);
2138
- };
2139
- try {
2140
- _$request_34({
2141
- url: client._config.endpoints.notify,
2142
- headers: {
2143
- "Content-Type": "application/json",
2144
- "Bugsnag-Api-Key": event.apiKey || client._config.apiKey,
2145
- "Bugsnag-Payload-Version": "4",
2146
- "Bugsnag-Sent-At": (/* @__PURE__ */ new Date()).toISOString()
2147
- },
2148
- body,
2149
- agent: client._config.agent
2150
- }, function(err, body2) {
2151
- return _cb(err);
2152
- });
2153
- } catch (e) {
2154
- _cb(e);
2155
- }
2156
- },
2157
- sendSession: function(session, cb) {
2158
- if (cb === void 0) {
2159
- cb = function() {
2160
- };
2161
- }
2162
- var _cb = function(err) {
2163
- if (err)
2164
- client._logger.error("Session failed to send\u2026\n" + (err && err.stack ? err.stack : err), err);
2165
- cb(err);
2166
- };
2167
- try {
2168
- _$request_34({
2169
- url: client._config.endpoints.sessions,
2170
- headers: {
2171
- "Content-Type": "application/json",
2172
- "Bugsnag-Api-Key": client._config.apiKey,
2173
- "Bugsnag-Payload-Version": "1",
2174
- "Bugsnag-Sent-At": (/* @__PURE__ */ new Date()).toISOString()
2175
- },
2176
- body: _$jsonPayload_20.session(session, client._config.redactedKeys),
2177
- agent: client._config.agent
2178
- }, function(err) {
2179
- return _cb(err);
2180
- });
2181
- } catch (e) {
2182
- _cb(e);
2183
- }
2184
- }
2185
- };
2186
- };
2187
- function _extends() {
2188
- _extends = Object.assign ? Object.assign.bind() : function(target) {
2189
- for (var i = 1; i < arguments.length; i++) {
2190
- var source = arguments[i];
2191
- for (var key in source) {
2192
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2193
- target[key] = source[key];
2194
- }
2195
- }
2196
- }
2197
- return target;
2198
- };
2199
- return _extends.apply(this, arguments);
2200
- }
2201
- var schema = _$config_3.schema;
2202
- ;
2203
- var __os_35 = __require("os");
2204
- var _require2 = __require("util"), inspect = _require2.inspect;
2205
- var _$config_35 = {
2206
- appType: _extends({}, schema.appType, {
2207
- defaultValue: function() {
2208
- return "node";
2209
- }
2210
- }),
2211
- projectRoot: {
2212
- defaultValue: function() {
2213
- return process.cwd();
2214
- },
2215
- validate: function(value) {
2216
- return value === null || _$stringWithLength_27(value);
2217
- },
2218
- message: "should be string"
2219
- },
2220
- hostname: {
2221
- defaultValue: function() {
2222
- return __os_35.hostname();
2223
- },
2224
- message: "should be a string",
2225
- validate: function(value) {
2226
- return value === null || _$stringWithLength_27(value);
2227
- }
2228
- },
2229
- logger: _extends({}, schema.logger, {
2230
- defaultValue: function() {
2231
- return getPrefixedConsole();
2232
- }
2233
- }),
2234
- releaseStage: _extends({}, schema.releaseStage, {
2235
- defaultValue: function() {
2236
- return process.env.NODE_ENV || "production";
2237
- }
2238
- }),
2239
- agent: {
2240
- defaultValue: function() {
2241
- return void 0;
2242
- },
2243
- message: "should be an HTTP(s) agent",
2244
- validate: function(value) {
2245
- return value === void 0 || isAgent(value);
2246
- }
2247
- },
2248
- onUncaughtException: {
2249
- defaultValue: function() {
2250
- return function(err, event, logger) {
2251
- logger.error("Uncaught exception" + getContext(event) + ", the process will now terminate\u2026\n" + printError(err));
2252
- process.exit(1);
2253
- };
2254
- },
2255
- message: "should be a function",
2256
- validate: function(value) {
2257
- return typeof value === "function";
2258
- }
2259
- },
2260
- onUnhandledRejection: {
2261
- defaultValue: function() {
2262
- return function(err, event, logger) {
2263
- logger.error("Unhandled rejection" + getContext(event) + "\u2026\n" + printError(err));
2264
- };
2265
- },
2266
- message: "should be a function",
2267
- validate: function(value) {
2268
- return typeof value === "function";
2269
- }
2270
- }
2271
- };
2272
- var printError = function(err) {
2273
- return err && err.stack ? err.stack : inspect(err);
2274
- };
2275
- var getPrefixedConsole = function() {
2276
- return ["debug", "info", "warn", "error"].reduce(function(accum, method) {
2277
- var consoleMethod = console[method] || console.log;
2278
- accum[method] = consoleMethod.bind(console, "[bugsnag]");
2279
- return accum;
2280
- }, {});
2281
- };
2282
- var getContext = function(event) {
2283
- return event.request && Object.keys(event.request).length ? " at " + event.request.httpMethod + " " + (event.request.path || event.request.url) : "";
2284
- };
2285
- var isAgent = function(value) {
2286
- return typeof value === "object" && value !== null || typeof value === "boolean";
2287
- };
2288
- var appStart = /* @__PURE__ */ new Date();
2289
- var reset = function() {
2290
- appStart = /* @__PURE__ */ new Date();
2291
- };
2292
- var _$app_37 = {
2293
- name: "appDuration",
2294
- load: function(client) {
2295
- client.addOnError(function(event) {
2296
- var now = /* @__PURE__ */ new Date();
2297
- event.app.duration = now - appStart;
2298
- }, true);
2299
- return {
2300
- reset
2301
- };
2302
- }
2303
- };
2304
- var _$nodeFallbackStack_22 = {};
2305
- _$nodeFallbackStack_22.getStack = function() {
2306
- return new Error().stack.split("\n").slice(3).join("\n");
2307
- };
2308
- _$nodeFallbackStack_22.maybeUseFallbackStack = function(err, fallbackStack) {
2309
- var lines = err.stack.split("\n");
2310
- if (lines.length === 1 || lines.length === 2 && /at Error \(native\)/.test(lines[1])) {
2311
- err.stack = lines[0] + "\n" + fallbackStack;
2312
- }
2313
- return err;
2314
- };
2315
- var _$contextualize_38 = {};
2316
- var domain = __require("domain");
2317
- var getStack = _$nodeFallbackStack_22.getStack, maybeUseFallbackStack = _$nodeFallbackStack_22.maybeUseFallbackStack;
2318
- _$contextualize_38 = {
2319
- name: "contextualize",
2320
- load: function(client) {
2321
- var contextualize = function(fn, onError) {
2322
- var fallbackStack = getStack();
2323
- var dom = domain.create();
2324
- dom.on("error", function(err) {
2325
- if (err.stack)
2326
- maybeUseFallbackStack(err, fallbackStack);
2327
- var event = client.Event.create(err, true, {
2328
- severity: "error",
2329
- unhandled: true,
2330
- severityReason: {
2331
- type: "unhandledException"
2332
- }
2333
- }, "contextualize()", 1);
2334
- client._notify(event, onError, function(e, event2) {
2335
- if (e)
2336
- client._logger.error("Failed to send event to Bugsnag");
2337
- client._config.onUncaughtException(err, event2, client._logger);
2338
- });
2339
- });
2340
- process.nextTick(function() {
2341
- return dom.run(fn);
2342
- });
2343
- };
2344
- return contextualize;
2345
- }
2346
- };
2347
- _$contextualize_38["default"] = _$contextualize_38;
2348
- var _$intercept_39 = {};
2349
- var __getStack_39 = _$nodeFallbackStack_22.getStack, __maybeUseFallbackStack_39 = _$nodeFallbackStack_22.maybeUseFallbackStack;
2350
- _$intercept_39 = {
2351
- name: "intercept",
2352
- load: function(client) {
2353
- var intercept = function(onError, cb) {
2354
- if (onError === void 0) {
2355
- onError = function() {
2356
- };
2357
- }
2358
- if (typeof cb !== "function") {
2359
- cb = onError;
2360
- onError = function() {
2361
- };
2362
- }
2363
- var fallbackStack = __getStack_39();
2364
- return function(err) {
2365
- if (err) {
2366
- if (err.stack)
2367
- __maybeUseFallbackStack_39(err, fallbackStack);
2368
- var event = client.Event.create(err, true, {
2369
- severity: "warning",
2370
- unhandled: false,
2371
- severityReason: {
2372
- type: "callbackErrorIntercept"
2373
- }
2374
- }, "intercept()", 1);
2375
- client._notify(event, onError);
2376
- return;
2377
- }
2378
- for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2379
- data[_key - 1] = arguments[_key];
2380
- }
2381
- cb.apply(void 0, data);
2382
- };
2383
- };
2384
- return intercept;
2385
- }
2386
- };
2387
- _$intercept_39["default"] = _$intercept_39;
2388
- function ___extends_40() {
2389
- ___extends_40 = Object.assign ? Object.assign.bind() : function(target) {
2390
- for (var i = 1; i < arguments.length; i++) {
2391
- var source = arguments[i];
2392
- for (var key in source) {
2393
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2394
- target[key] = source[key];
2395
- }
2396
- }
2397
- }
2398
- return target;
2399
- };
2400
- return ___extends_40.apply(this, arguments);
2401
- }
2402
- var __os_40 = __require("os");
2403
- var _$device_40 = {
2404
- load: function(client) {
2405
- var device = {
2406
- osName: __os_40.platform() + " (" + __os_40.arch() + ")",
2407
- osVersion: __os_40.release(),
2408
- totalMemory: __os_40.totalmem(),
2409
- hostname: client._config.hostname,
2410
- runtimeVersions: {
2411
- node: process.versions.node
2412
- }
2413
- };
2414
- client._addOnSessionPayload(function(sp) {
2415
- sp.device = ___extends_40({}, sp.device, device);
2416
- });
2417
- client.addOnError(function(event) {
2418
- event.device = ___extends_40({}, event.device, device, {
2419
- freeMemory: __os_40.freemem(),
2420
- time: /* @__PURE__ */ new Date()
2421
- });
2422
- }, true);
2423
- }
2424
- };
2425
- var ___require_23 = __require("path"), join = ___require_23.join, resolve = ___require_23.resolve;
2426
- var _$pathNormalizer_23 = function(p) {
2427
- return join(resolve(p), "/");
2428
- };
2429
- ;
2430
- var _$inProject_41 = {
2431
- load: function(client) {
2432
- return client.addOnError(function(event) {
2433
- if (!client._config.projectRoot)
2434
- return;
2435
- var projectRoot = _$pathNormalizer_23(client._config.projectRoot);
2436
- var allFrames = event.errors.reduce(function(accum, er) {
2437
- return accum.concat(er.stacktrace);
2438
- }, []);
2439
- allFrames.map(function(stackframe) {
2440
- stackframe.inProject = typeof stackframe.file === "string" && stackframe.file.indexOf(projectRoot) === 0 && !/\/node_modules\//.test(stackframe.file);
2441
- });
2442
- });
2443
- }
2444
- };
2445
- function ___extends_42() {
2446
- ___extends_42 = Object.assign ? Object.assign.bind() : function(target) {
2447
- for (var i = 1; i < arguments.length; i++) {
2448
- var source = arguments[i];
2449
- for (var key in source) {
2450
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2451
- target[key] = source[key];
2452
- }
2453
- }
2454
- }
2455
- return target;
2456
- };
2457
- return ___extends_42.apply(this, arguments);
2458
- }
2459
- function _inheritsLoose(subClass, superClass) {
2460
- subClass.prototype = Object.create(superClass.prototype);
2461
- subClass.prototype.constructor = subClass;
2462
- _setPrototypeOf(subClass, superClass);
2463
- }
2464
- function _setPrototypeOf(o, p) {
2465
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
2466
- o2.__proto__ = p2;
2467
- return o2;
2468
- };
2469
- return _setPrototypeOf(o, p);
2470
- }
2471
- var SURROUNDING_LINES = 3;
2472
- var MAX_LINE_LENGTH = 200;
2473
- var ___require_42 = __require("fs"), createReadStream = ___require_42.createReadStream;
2474
- var ___require2_42 = __require("stream"), Writable = ___require2_42.Writable;
2475
- var pump = require_pump();
2476
- var byline = require_byline();
2477
- var path = __require("path");
2478
- var _$surroundingCode_42 = {
2479
- load: function(client) {
2480
- if (!client._config.sendCode)
2481
- return;
2482
- var loadSurroundingCode = function(stackframe, cache) {
2483
- return new Promise(function(resolve2, reject) {
2484
- try {
2485
- if (!stackframe.lineNumber || !stackframe.file)
2486
- return resolve2(stackframe);
2487
- var file = path.resolve(client._config.projectRoot, stackframe.file);
2488
- var cacheKey = file + "@" + stackframe.lineNumber;
2489
- if (cacheKey in cache) {
2490
- stackframe.code = cache[cacheKey];
2491
- return resolve2(stackframe);
2492
- }
2493
- getSurroundingCode(file, stackframe.lineNumber, function(err, code) {
2494
- if (err)
2495
- return resolve2(stackframe);
2496
- stackframe.code = cache[cacheKey] = code;
2497
- return resolve2(stackframe);
2498
- });
2499
- } catch (e) {
2500
- return resolve2(stackframe);
2501
- }
2502
- });
2503
- };
2504
- client.addOnError(function(event) {
2505
- return new Promise(function(resolve2, reject) {
2506
- var cache = /* @__PURE__ */ Object.create(null);
2507
- var allFrames = event.errors.reduce(function(accum, er) {
2508
- return accum.concat(er.stacktrace);
2509
- }, []);
2510
- pMapSeries(allFrames.map(function(stackframe) {
2511
- return function() {
2512
- return loadSurroundingCode(stackframe, cache);
2513
- };
2514
- })).then(resolve2)["catch"](reject);
2515
- });
2516
- });
2517
- },
2518
- configSchema: {
2519
- sendCode: {
2520
- defaultValue: function() {
2521
- return true;
2522
- },
2523
- validate: function(value) {
2524
- return value === true || value === false;
2525
- },
2526
- message: "should be true or false"
2527
- }
2528
- }
2529
- };
2530
- var getSurroundingCode = function(file, lineNumber, cb) {
2531
- var start = lineNumber - SURROUNDING_LINES;
2532
- var end = lineNumber + SURROUNDING_LINES;
2533
- var reader = createReadStream(file, {
2534
- encoding: "utf8"
2535
- });
2536
- var splitter = new byline.LineStream({
2537
- keepEmptyLines: true
2538
- });
2539
- var slicer = new CodeRange({
2540
- start,
2541
- end
2542
- });
2543
- slicer.on("done", function() {
2544
- return reader.destroy();
2545
- });
2546
- pump(reader, splitter, slicer, function(err) {
2547
- if (err && err.message !== "premature close")
2548
- return cb(err);
2549
- cb(null, slicer.getCode());
2550
- });
2551
- };
2552
- var CodeRange = /* @__PURE__ */ function(_Writable) {
2553
- _inheritsLoose(CodeRange2, _Writable);
2554
- function CodeRange2(opts) {
2555
- var _this;
2556
- _this = _Writable.call(this, ___extends_42({}, opts, {
2557
- decodeStrings: false
2558
- })) || this;
2559
- _this._start = opts.start;
2560
- _this._end = opts.end;
2561
- _this._n = 0;
2562
- _this._code = {};
2563
- return _this;
2564
- }
2565
- var _proto = CodeRange2.prototype;
2566
- _proto._write = function _write(chunk, enc, cb) {
2567
- this._n++;
2568
- if (this._n < this._start)
2569
- return cb(null);
2570
- if (this._n <= this._end) {
2571
- this._code[String(this._n)] = chunk.length <= MAX_LINE_LENGTH ? chunk : chunk.substr(0, MAX_LINE_LENGTH);
2572
- return cb(null);
2573
- }
2574
- this.emit("done");
2575
- return cb(null);
2576
- };
2577
- _proto.getCode = function getCode() {
2578
- return this._code;
2579
- };
2580
- return CodeRange2;
2581
- }(Writable);
2582
- var pMapSeries = function(ps) {
2583
- return new Promise(function(resolve2, reject) {
2584
- var res = [];
2585
- ps.reduce(function(accum, p) {
2586
- return accum.then(function(r) {
2587
- res.push(r);
2588
- return p();
2589
- });
2590
- }, Promise.resolve()).then(function(r) {
2591
- res.push(r);
2592
- }).then(function() {
2593
- resolve2(res.slice(1));
2594
- });
2595
- });
2596
- };
2597
- var _handler;
2598
- var _$uncaughtException_43 = {
2599
- load: function(client) {
2600
- if (!client._config.autoDetectErrors)
2601
- return;
2602
- if (!client._config.enabledErrorTypes.unhandledExceptions)
2603
- return;
2604
- _handler = function(err) {
2605
- var event = client.Event.create(err, false, {
2606
- severity: "error",
2607
- unhandled: true,
2608
- severityReason: {
2609
- type: "unhandledException"
2610
- }
2611
- }, "uncaughtException handler", 1);
2612
- client._notify(event, function() {
2613
- }, function(e, event2) {
2614
- if (e)
2615
- client._logger.error("Failed to send event to Bugsnag");
2616
- client._config.onUncaughtException(err, event2, client._logger);
2617
- });
2618
- };
2619
- process.on("uncaughtException", _handler);
2620
- },
2621
- destroy: function() {
2622
- process.removeListener("uncaughtException", _handler);
2623
- }
2624
- };
2625
- var ___handler_44;
2626
- var _$unhandledRejection_44 = {
2627
- load: function(client) {
2628
- if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections)
2629
- return;
2630
- ___handler_44 = function(err) {
2631
- var event = client.Event.create(err, false, {
2632
- severity: "error",
2633
- unhandled: true,
2634
- severityReason: {
2635
- type: "unhandledPromiseRejection"
2636
- }
2637
- }, "unhandledRejection handler", 1);
2638
- return new Promise(function(resolve2) {
2639
- client._notify(event, function() {
2640
- }, function(e, event2) {
2641
- if (e)
2642
- client._logger.error("Failed to send event to Bugsnag");
2643
- client._config.onUnhandledRejection(err, event2, client._logger);
2644
- resolve2();
2645
- });
2646
- });
2647
- };
2648
- if (process.prependListener) {
2649
- process.prependListener("unhandledRejection", ___handler_44);
2650
- } else {
2651
- process.on("unhandledRejection", ___handler_44);
2652
- }
2653
- },
2654
- destroy: function() {
2655
- process.removeListener("unhandledRejection", ___handler_44);
2656
- }
2657
- };
2658
- var _$cloneClient_8 = {};
2659
- ;
2660
- var onCloneCallbacks = [];
2661
- _$cloneClient_8 = function(client) {
2662
- var clone = new client.Client({}, {}, [], client._notifier);
2663
- clone._config = client._config;
2664
- clone._breadcrumbs = client._breadcrumbs.slice();
2665
- clone._metadata = _$assign_10({}, client._metadata);
2666
- clone._features = [].concat(client._features);
2667
- clone._featuresIndex = _$assign_10({}, client._featuresIndex);
2668
- clone._user = _$assign_10({}, client._user);
2669
- clone._context = client._context;
2670
- clone._cbs = {
2671
- e: client._cbs.e.slice(),
2672
- s: client._cbs.s.slice(),
2673
- sp: client._cbs.sp.slice(),
2674
- b: client._cbs.b.slice()
2675
- };
2676
- clone._logger = client._logger;
2677
- clone._delivery = client._delivery;
2678
- clone._sessionDelegate = client._sessionDelegate;
2679
- onCloneCallbacks.forEach(function(callback) {
2680
- callback(clone);
2681
- });
2682
- return clone;
2683
- };
2684
- _$cloneClient_8.registerCallback = function(callback) {
2685
- onCloneCallbacks.push(callback);
2686
- };
2687
- var _$Backoff_45 = Backoff;
2688
- function Backoff(opts) {
2689
- opts = opts || {};
2690
- this.ms = opts.min || 100;
2691
- this.max = opts.max || 1e4;
2692
- this.factor = opts.factor || 2;
2693
- this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
2694
- this.attempts = 0;
2695
- }
2696
- Backoff.prototype.duration = function() {
2697
- var ms = this.ms * Math.pow(this.factor, this.attempts++);
2698
- if (this.jitter) {
2699
- var rand = Math.random();
2700
- var deviation = Math.floor(rand * this.jitter * ms);
2701
- ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
2702
- }
2703
- return Math.min(ms, this.max) | 0;
2704
- };
2705
- Backoff.prototype.reset = function() {
2706
- this.attempts = 0;
2707
- };
2708
- function _assertThisInitialized(self2) {
2709
- if (self2 === void 0) {
2710
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2711
- }
2712
- return self2;
2713
- }
2714
- function ___inheritsLoose_47(subClass, superClass) {
2715
- subClass.prototype = Object.create(superClass.prototype);
2716
- subClass.prototype.constructor = subClass;
2717
- ___setPrototypeOf_47(subClass, superClass);
2718
- }
2719
- function ___setPrototypeOf_47(o, p) {
2720
- ___setPrototypeOf_47 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
2721
- o2.__proto__ = p2;
2722
- return o2;
2723
- };
2724
- return ___setPrototypeOf_47(o, p);
2725
- }
2726
- var DEFAULT_SUMMARY_INTERVAL = 10 * 1e3;
2727
- var Emitter = __require("events").EventEmitter;
2728
- var _$tracker_47 = /* @__PURE__ */ function(_Emitter) {
2729
- ___inheritsLoose_47(SessionTracker, _Emitter);
2730
- function SessionTracker(intervalLength) {
2731
- var _this;
2732
- _this = _Emitter.call(this) || this;
2733
- _this._sessions = /* @__PURE__ */ new Map();
2734
- _this._interval = null;
2735
- _this._intervalLength = intervalLength || DEFAULT_SUMMARY_INTERVAL;
2736
- _this._summarize = _this._summarize.bind(_assertThisInitialized(_this));
2737
- return _this;
2738
- }
2739
- var _proto = SessionTracker.prototype;
2740
- _proto.start = function start() {
2741
- if (!this._interval) {
2742
- this._interval = setInterval(this._summarize, this._intervalLength).unref();
2743
- }
2744
- };
2745
- _proto.stop = function stop() {
2746
- clearInterval(this._interval);
2747
- this._interval = null;
2748
- };
2749
- _proto.track = function track(session) {
2750
- var key = dateToMsKey(session.startedAt);
2751
- var cur = this._sessions.get(key);
2752
- this._sessions.set(key, typeof cur === "undefined" ? 1 : cur + 1);
2753
- return session;
2754
- };
2755
- _proto._summarize = function _summarize() {
2756
- var _this2 = this;
2757
- var summary = [];
2758
- this._sessions.forEach(function(val, key) {
2759
- summary.push({
2760
- startedAt: key,
2761
- sessionsStarted: val
2762
- });
2763
- _this2._sessions["delete"](key);
2764
- });
2765
- if (!summary.length)
2766
- return;
2767
- this.emit("summary", summary);
2768
- };
2769
- return SessionTracker;
2770
- }(Emitter);
2771
- var dateToMsKey = function(d) {
2772
- var dk = new Date(d);
2773
- dk.setSeconds(0);
2774
- dk.setMilliseconds(0);
2775
- return dk.toISOString();
2776
- };
2777
- ;
2778
- ;
2779
- ;
2780
- ;
2781
- ;
2782
- var _$session_46 = {
2783
- load: function(client) {
2784
- var sessionTracker = new _$tracker_47(client._config.sessionSummaryInterval);
2785
- sessionTracker.on("summary", sendSessionSummary(client));
2786
- sessionTracker.start();
2787
- client._sessionDelegate = {
2788
- startSession: function(client2, session) {
2789
- var sessionClient = _$cloneClient_8(client2);
2790
- sessionClient._session = session;
2791
- sessionClient._pausedSession = null;
2792
- sessionTracker.track(sessionClient._session);
2793
- return sessionClient;
2794
- },
2795
- pauseSession: function(client2) {
2796
- client2._pausedSession = client2._session;
2797
- client2._session = null;
2798
- },
2799
- resumeSession: function(client2) {
2800
- if (client2._session) {
2801
- return client2;
2802
- }
2803
- if (client2._pausedSession) {
2804
- client2._session = client2._pausedSession;
2805
- client2._pausedSession = null;
2806
- return client2;
2807
- }
2808
- return client2.startSession();
2809
- }
2810
- };
2811
- },
2812
- configSchema: {
2813
- sessionSummaryInterval: {
2814
- defaultValue: function() {
2815
- return void 0;
2816
- },
2817
- validate: function(value) {
2818
- return value === void 0 || _$intRange_25()(value);
2819
- },
2820
- message: "should be a positive integer"
2821
- }
2822
- }
2823
- };
2824
- var sendSessionSummary = function(client) {
2825
- return function(sessionCounts) {
2826
- if (client._config.enabledReleaseStages !== null && !client._config.enabledReleaseStages.includes(client._config.releaseStage)) {
2827
- client._logger.warn("Session not sent due to releaseStage/enabledReleaseStages configuration");
2828
- return;
2829
- }
2830
- if (!sessionCounts.length)
2831
- return;
2832
- var backoff = new _$Backoff_45({
2833
- min: 1e3,
2834
- max: 1e4
2835
- });
2836
- var maxAttempts = 10;
2837
- req(handleRes);
2838
- function handleRes(err) {
2839
- if (!err) {
2840
- var sessionCount = sessionCounts.reduce(function(accum, s) {
2841
- return accum + s.sessionsStarted;
2842
- }, 0);
2843
- return client._logger.debug(sessionCount + " session(s) reported");
2844
- }
2845
- if (backoff.attempts === 10) {
2846
- client._logger.error("Session delivery failed, max retries exceeded", err);
2847
- return;
2848
- }
2849
- client._logger.debug("Session delivery failed, retry #" + (backoff.attempts + 1) + "/" + maxAttempts, err);
2850
- setTimeout(function() {
2851
- return req(handleRes);
2852
- }, backoff.duration());
2853
- }
2854
- function req(cb) {
2855
- var payload = {
2856
- notifier: client._notifier,
2857
- device: {},
2858
- app: {
2859
- releaseStage: client._config.releaseStage,
2860
- version: client._config.appVersion,
2861
- type: client._config.appType
2862
- },
2863
- sessionCounts
2864
- };
2865
- var ignore = _$syncCallbackRunner_24(client._cbs.sp, payload, "onSessionPayload", client._logger);
2866
- if (ignore) {
2867
- client._logger.debug("Session not sent due to onSessionPayload callback");
2868
- return cb(null);
2869
- }
2870
- client._delivery.sendSession(payload, cb);
2871
- }
2872
- };
2873
- };
2874
- var _$pathNormaliser_48 = {
2875
- load: function(client) {
2876
- client.addOnError(function(event) {
2877
- var allFrames = event.errors.reduce(function(accum, er) {
2878
- return accum.concat(er.stacktrace);
2879
- }, []);
2880
- allFrames.forEach(function(stackframe) {
2881
- if (typeof stackframe.file !== "string") {
2882
- return;
2883
- }
2884
- stackframe.file = stackframe.file.replace(/\\/g, "/");
2885
- });
2886
- });
2887
- }
2888
- };
2889
- ;
2890
- var _$stripProjectRoot_49 = {
2891
- load: function(client) {
2892
- return client.addOnError(function(event) {
2893
- if (!client._config.projectRoot)
2894
- return;
2895
- var projectRoot = _$pathNormalizer_23(client._config.projectRoot);
2896
- var allFrames = event.errors.reduce(function(accum, er) {
2897
- return accum.concat(er.stacktrace);
2898
- }, []);
2899
- allFrames.map(function(stackframe) {
2900
- if (typeof stackframe.file === "string" && stackframe.file.indexOf(projectRoot) === 0) {
2901
- stackframe.file = stackframe.file.replace(projectRoot, "");
2902
- }
2903
- });
2904
- });
2905
- }
2906
- };
2907
- var _$notifier_36 = {};
2908
- function ___extends_36() {
2909
- ___extends_36 = Object.assign ? Object.assign.bind() : function(target) {
2910
- for (var i = 1; i < arguments.length; i++) {
2911
- var source = arguments[i];
2912
- for (var key in source) {
2913
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2914
- target[key] = source[key];
2915
- }
2916
- }
2917
- }
2918
- return target;
2919
- };
2920
- return ___extends_36.apply(this, arguments);
2921
- }
2922
- var name = "Bugsnag Node";
2923
- var version = "7.22.7";
2924
- var url = "https://github.com/bugsnag/bugsnag-js";
2925
- ;
2926
- ;
2927
- ;
2928
- ;
2929
- _$Event_4.__type = "nodejs";
2930
- ;
2931
- var __schema_36 = ___extends_36({}, _$config_3.schema, _$config_35);
2932
- delete __schema_36.enabledBreadcrumbTypes;
2933
- ;
2934
- ;
2935
- ;
2936
- ;
2937
- ;
2938
- ;
2939
- ;
2940
- ;
2941
- ;
2942
- ;
2943
- ;
2944
- var internalPlugins = [_$app_37, _$surroundingCode_42, _$inProject_41, _$stripProjectRoot_49, _$session_46, _$device_40, _$uncaughtException_43, _$unhandledRejection_44, _$intercept_39, _$contextualize_38, _$pathNormaliser_48];
2945
- var Bugsnag2 = {
2946
- _client: null,
2947
- createClient: function(opts) {
2948
- if (typeof opts === "string")
2949
- opts = {
2950
- apiKey: opts
2951
- };
2952
- if (!opts)
2953
- opts = {};
2954
- var bugsnag = new _$Client_2(opts, __schema_36, internalPlugins, {
2955
- name,
2956
- version,
2957
- url
2958
- });
2959
- bugsnag._setDelivery(_$delivery_33);
2960
- bugsnag._logger.debug("Loaded!");
2961
- bugsnag.leaveBreadcrumb = function() {
2962
- bugsnag._logger.warn("Breadcrumbs are not supported in Node.js yet");
2963
- };
2964
- bugsnag._config.enabledBreadcrumbTypes = [];
2965
- return bugsnag;
2966
- },
2967
- start: function(opts) {
2968
- if (Bugsnag2._client) {
2969
- Bugsnag2._client._logger.warn("Bugsnag.start() was called more than once. Ignoring.");
2970
- return Bugsnag2._client;
2971
- }
2972
- Bugsnag2._client = Bugsnag2.createClient(opts);
2973
- return Bugsnag2._client;
2974
- },
2975
- isStarted: function() {
2976
- return Bugsnag2._client != null;
2977
- }
2978
- };
2979
- Object.keys(_$Client_2.prototype).forEach(function(m) {
2980
- if (/^_/.test(m))
2981
- return;
2982
- Bugsnag2[m] = function() {
2983
- if (!Bugsnag2._client)
2984
- return console.error("Bugsnag." + m + "() was called before Bugsnag.start()");
2985
- Bugsnag2._client._depth += 1;
2986
- var ret = Bugsnag2._client[m].apply(Bugsnag2._client, arguments);
2987
- Bugsnag2._client._depth -= 1;
2988
- return ret;
2989
- };
2990
- });
2991
- _$notifier_36 = Bugsnag2;
2992
- _$notifier_36.Client = _$Client_2;
2993
- _$notifier_36.Event = _$Event_4;
2994
- _$notifier_36.Session = _$Session_32;
2995
- _$notifier_36.Breadcrumb = _$Breadcrumb_1;
2996
- _$notifier_36["default"] = Bugsnag2;
2997
- return _$notifier_36;
2998
- });
2999
- }
3000
- });
3001
-
3002
- // ../../node_modules/.pnpm/@bugsnag+js@7.21.0/node_modules/@bugsnag/js/node/notifier.js
3003
- var require_notifier = __commonJS({
3004
- "../../node_modules/.pnpm/@bugsnag+js@7.21.0/node_modules/@bugsnag/js/node/notifier.js"(exports, module) {
3005
- init_cjs_shims();
3006
- module.exports = require_bugsnag();
3007
- }
3008
- });
3009
-
3010
- // ../cli-kit/src/public/node/error-handler.ts
3011
- init_cjs_shims();
3012
- var import_core = __toESM(require_lib(), 1);
3013
- var import_stacktracey = __toESM(require_stacktracey(), 1);
3014
- var import_js = __toESM(require_notifier(), 1);
3015
- import { realpath } from "fs/promises";
3016
- async function errorHandler(error, config) {
3017
- if (error instanceof CancelExecution) {
3018
- if (error.message && error.message !== "") {
3019
- outputInfo(`\u2728 ${error.message}`);
3020
- }
3021
- } else if (error instanceof AbortSilentError) {
3022
- printEventsJson();
3023
- } else {
3024
- return errorMapper(error).then((error2) => {
3025
- return handler(error2);
3026
- }).then((mappedError) => {
3027
- printEventsJson();
3028
- return reportError(mappedError, config);
3029
- });
3030
- }
3031
- }
3032
- var reportError = async (error, config) => {
3033
- let exitMode = "expected_error";
3034
- if (shouldReportError(error))
3035
- exitMode = "unexpected_error";
3036
- if (config !== void 0) {
3037
- await reportAnalyticsEvent({ config, errorMessage: error instanceof Error ? error.message : void 0, exitMode });
3038
- }
3039
- await sendErrorToBugsnag(error, exitMode);
3040
- };
3041
- async function sendErrorToBugsnag(error, exitMode) {
3042
- if (import_core.settings.debug) {
3043
- outputDebug(`Skipping Bugsnag report`);
3044
- return { reported: false, error, unhandled: void 0 };
3045
- }
3046
- const unhandled = exitMode === "unexpected_error";
3047
- let reportableError;
3048
- let stacktrace;
3049
- let report = false;
3050
- if (error instanceof Error) {
3051
- report = true;
3052
- reportableError = new Error(error.message);
3053
- stacktrace = error.stack;
3054
- } else if (typeof error === "string" && error.trim().length !== 0) {
3055
- report = true;
3056
- reportableError = new Error(error);
3057
- stacktrace = reportableError.stack;
3058
- } else {
3059
- report = false;
3060
- reportableError = new Error("Unknown error");
3061
- }
3062
- const formattedStacktrace = new import_stacktracey.default(stacktrace ?? "").clean().items.map((item) => {
3063
- const filePath = cleanSingleStackTracePath(item.file);
3064
- return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
3065
- }).join("\n");
3066
- reportableError.stack = `Error: ${reportableError.message}
3067
- ${formattedStacktrace}`;
3068
- if (report) {
3069
- initializeBugsnag();
3070
- await new Promise((resolve, reject) => {
3071
- outputDebug(`Reporting ${unhandled ? "unhandled" : "handled"} error to Bugsnag: ${reportableError.message}`);
3072
- const eventHandler = (event) => {
3073
- event.severity = "error";
3074
- event.unhandled = unhandled;
3075
- };
3076
- const errorHandler2 = (error2) => {
3077
- if (error2) {
3078
- reject(error2);
3079
- } else {
3080
- resolve(reportableError);
3081
- }
3082
- };
3083
- import_js.default.notify(reportableError, eventHandler, errorHandler2);
3084
- });
3085
- }
3086
- return { error: reportableError, reported: report, unhandled };
3087
- }
3088
- function cleanStackFrameFilePath({
3089
- currentFilePath,
3090
- projectRoot,
3091
- pluginLocations
3092
- }) {
3093
- const fullLocation = isAbsolutePath(currentFilePath) ? currentFilePath : joinPath(projectRoot, currentFilePath);
3094
- const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.indexOf(pluginPath) === 0)[0];
3095
- if (matchingPluginPath !== void 0) {
3096
- return joinPath(matchingPluginPath.name, relativePath(matchingPluginPath.pluginPath, fullLocation));
3097
- }
3098
- return currentFilePath.replace(/.*node_modules\//, "");
3099
- }
3100
- async function registerCleanBugsnagErrorsFromWithinPlugins(config) {
3101
- const bugsnagConfigProjectRoot = import_js.default?._client?._config?.projectRoot ?? cwd();
3102
- const projectRoot = normalizePath(bugsnagConfigProjectRoot);
3103
- const pluginLocations = await Promise.all(
3104
- [...config.plugins].map(async ([_, plugin]) => {
3105
- const followSymlinks = await realpath(plugin.root);
3106
- return { name: plugin.name, pluginPath: normalizePath(followSymlinks) };
3107
- })
3108
- );
3109
- initializeBugsnag();
3110
- import_js.default.addOnError(async (event) => {
3111
- event.errors.forEach((error) => {
3112
- error.stacktrace.forEach((stackFrame) => {
3113
- stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
3114
- });
3115
- });
3116
- try {
3117
- await addBugsnagMetadata(event, config);
3118
- } catch (metadataError) {
3119
- outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
3120
- }
3121
- });
3122
- }
3123
- async function addBugsnagMetadata(event, config) {
3124
- const publicData = getAllPublicMetadata();
3125
- const { commandStartOptions } = getAllSensitiveMetadata();
3126
- const { startCommand } = commandStartOptions ?? {};
3127
- const { "@shopify/app": appPublic, ...otherPluginsPublic } = await fanoutHooks(config, "public_command_metadata", {});
3128
- const environment = await getEnvironmentData(config);
3129
- const allMetadata = {
3130
- command: startCommand,
3131
- ...appPublic,
3132
- ...publicData,
3133
- ...environment,
3134
- pluginData: otherPluginsPublic
3135
- };
3136
- const appData = {};
3137
- const commandData = {};
3138
- const environmentData = {};
3139
- const miscData = {};
3140
- const appKeys = ["api_key", "partner_id", "project_type"];
3141
- const commandKeys = ["command"];
3142
- const environmentKeys = ["cli_version", "node_version", "ruby_version", "uname"];
3143
- Object.entries(allMetadata).forEach(([key, value]) => {
3144
- if (key.startsWith("app_") || appKeys.includes(key)) {
3145
- appData[key] = value;
3146
- } else if (key.startsWith("cmd_") || commandKeys.includes(key)) {
3147
- commandData[key] = value;
3148
- } else if (key.startsWith("env_") || environmentKeys) {
3149
- environmentData[key] = value;
3150
- } else {
3151
- miscData[key] = value;
3152
- }
3153
- });
3154
- const bugsnagMetadata = {
3155
- "Shopify App": appData,
3156
- Command: commandData,
3157
- Environment: environmentData,
3158
- Misc: miscData
3159
- };
3160
- Object.entries(bugsnagMetadata).forEach(([section, values]) => {
3161
- event.addMetadata(section, values);
3162
- });
3163
- }
3164
- function initializeBugsnag() {
3165
- if (import_js.default.isStarted()) {
3166
- return;
3167
- }
3168
- import_js.default.start({
3169
- appType: "node",
3170
- apiKey: bugsnagApiKey,
3171
- logger: null,
3172
- appVersion: CLI_KIT_VERSION,
3173
- autoTrackSessions: false,
3174
- autoDetectErrors: false
3175
- });
3176
- }
3177
-
3178
- export {
3179
- errorHandler,
3180
- sendErrorToBugsnag,
3181
- cleanStackFrameFilePath,
3182
- registerCleanBugsnagErrorsFromWithinPlugins,
3183
- addBugsnagMetadata
3184
- };
3185
- //# sourceMappingURL=chunk-U5LTJVWL.js.map