@specific.dev/spectest 0.39.0 → 0.41.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 (100) hide show
  1. package/dist/components/supabase.d.ts +87 -27
  2. package/dist/components/supabase.js +352 -69
  3. package/dist/daemon.d.ts +38 -0
  4. package/dist/daemon.js +388 -941
  5. package/dist/harness/build-context.d.ts +82 -0
  6. package/dist/harness/build-context.js +113 -0
  7. package/dist/harness/buildkit-progress.d.ts +37 -0
  8. package/dist/harness/buildkit-progress.js +66 -0
  9. package/dist/harness/container-run.d.ts +89 -0
  10. package/dist/harness/container-run.js +118 -0
  11. package/dist/harness/file-mounts.d.ts +91 -0
  12. package/dist/harness/file-mounts.js +119 -0
  13. package/dist/harness/hostmatch.d.ts +65 -0
  14. package/dist/harness/hostmatch.js +108 -0
  15. package/dist/harness/http-proxy.d.ts +62 -0
  16. package/dist/harness/http-proxy.js +104 -0
  17. package/dist/harness/ingress-table.d.ts +148 -0
  18. package/dist/harness/ingress-table.js +129 -0
  19. package/dist/harness/log-delta.d.ts +54 -0
  20. package/dist/harness/log-delta.js +83 -0
  21. package/dist/harness/main.d.ts +47 -0
  22. package/dist/harness/main.js +164 -0
  23. package/dist/harness/methods.d.ts +54 -0
  24. package/dist/harness/methods.js +65 -0
  25. package/dist/harness/names-registry.d.ts +63 -0
  26. package/dist/harness/names-registry.js +90 -0
  27. package/dist/harness/protocol.d.ts +88 -0
  28. package/dist/harness/protocol.js +96 -0
  29. package/dist/harness/ready-poll.d.ts +47 -0
  30. package/dist/harness/ready-poll.js +67 -0
  31. package/dist/harness/service-graph.d.ts +29 -0
  32. package/dist/harness/service-graph.js +92 -0
  33. package/dist/harness/volume-paths.d.ts +70 -0
  34. package/dist/harness/volume-paths.js +81 -0
  35. package/dist/index.d.ts +3 -3
  36. package/dist/ingress.d.ts +1 -1
  37. package/dist/resolver.js +5 -8
  38. package/dist/vendor/rrweb-plugin-console-record.umd.js +521 -0
  39. package/dist/vendor/rrweb-record.min.js +5061 -0
  40. package/package.json +7 -1
  41. package/src/aws-sigv4.ts +218 -0
  42. package/src/browser.ts +2040 -0
  43. package/src/components/aws.ts +554 -0
  44. package/src/components/email.ts +398 -0
  45. package/src/components/expo.ts +167 -0
  46. package/src/components/index.ts +81 -0
  47. package/src/components/k3s.ts +2061 -0
  48. package/src/components/postgres.ts +132 -0
  49. package/src/components/replayFake.ts +1015 -0
  50. package/src/components/s3.ts +132 -0
  51. package/src/components/supabase.ts +1699 -0
  52. package/src/daemon.ts +5489 -0
  53. package/src/harness/build-context.test.ts +0 -0
  54. package/src/harness/build-context.ts +146 -0
  55. package/src/harness/buildkit-progress.test.ts +98 -0
  56. package/src/harness/buildkit-progress.ts +74 -0
  57. package/src/harness/container-run.test.ts +209 -0
  58. package/src/harness/container-run.ts +158 -0
  59. package/src/harness/file-mounts.test.ts +185 -0
  60. package/src/harness/file-mounts.ts +145 -0
  61. package/src/harness/hostmatch.test.ts +148 -0
  62. package/src/harness/hostmatch.ts +109 -0
  63. package/src/harness/http-proxy.test.ts +156 -0
  64. package/src/harness/http-proxy.ts +119 -0
  65. package/src/harness/ingress-rebind.test.ts +125 -0
  66. package/src/harness/ingress-table.test.ts +172 -0
  67. package/src/harness/ingress-table.ts +186 -0
  68. package/src/harness/log-delta.test.ts +125 -0
  69. package/src/harness/log-delta.ts +100 -0
  70. package/src/harness/main.test.ts +211 -0
  71. package/src/harness/main.ts +196 -0
  72. package/src/harness/methods.test.ts +63 -0
  73. package/src/harness/methods.ts +92 -0
  74. package/src/harness/names-registry.test.ts +137 -0
  75. package/src/harness/names-registry.ts +108 -0
  76. package/src/harness/protocol.test.ts +148 -0
  77. package/src/harness/protocol.ts +163 -0
  78. package/src/harness/ready-poll.test.ts +172 -0
  79. package/src/harness/ready-poll.ts +93 -0
  80. package/src/harness/service-graph.test.ts +97 -0
  81. package/src/harness/service-graph.ts +97 -0
  82. package/src/harness/volume-paths.test.ts +102 -0
  83. package/src/harness/volume-paths.ts +112 -0
  84. package/src/ids.ts +89 -0
  85. package/src/index.ts +2725 -0
  86. package/src/ingress.ts +305 -0
  87. package/src/inspect.ts +739 -0
  88. package/src/locator.ts +716 -0
  89. package/src/mobile.ts +133 -0
  90. package/src/record-secrets.ts +41 -0
  91. package/src/recorder.ts +846 -0
  92. package/src/redis.ts +202 -0
  93. package/src/replay-bundle.ts +108 -0
  94. package/src/resolver.ts +348 -0
  95. package/src/s3.ts +333 -0
  96. package/src/sql.ts +243 -0
  97. package/src/terminal.ts +740 -0
  98. package/src/url-match.ts +67 -0
  99. package/src/vendor/rrweb-plugin-console-record.umd.js +521 -0
  100. package/src/vendor/rrweb-record.min.js +5061 -0
@@ -0,0 +1,67 @@
1
+ // URL pattern matching — shared by `browser.waitForURL(...)` and
2
+ // `expect(browser).toHaveURL(...)`.
3
+ //
4
+ // Both take the same pattern forms as Playwright (glob string | RegExp |
5
+ // predicate over a `URL`), and both lower to `matchesUrl` here so the two
6
+ // can never disagree: `waitForURL` hands playwright a predicate that calls
7
+ // this rather than letting playwright apply its own glob dialect, and the
8
+ // matcher polls it directly. Deliberately dependency-free so `index.ts` (the
9
+ // module a project imports on the host, where playwright isn't installed) can
10
+ // use it without pulling in `browser.ts`.
11
+
12
+ /**
13
+ * How a URL is matched. A **glob string** (`*` stays inside one path segment,
14
+ * `**` crosses `/`; anything else is literal, so a plain URL is an exact
15
+ * match), a **RegExp** (tested against the full URL, unanchored), or a
16
+ * **predicate** over the parsed {@link URL}.
17
+ */
18
+ export type UrlPattern = string | RegExp | ((url: URL) => boolean);
19
+
20
+ /** Whether `current` (a full URL string) matches `pattern`. */
21
+ export function matchesUrl(current: string, pattern: UrlPattern): boolean {
22
+ if (typeof pattern === "function") {
23
+ let parsed: URL;
24
+ try {
25
+ parsed = new URL(current);
26
+ } catch {
27
+ // `about:blank`, a data: URL, or a page that never committed — nothing
28
+ // for a predicate to inspect, so it can't match.
29
+ return false;
30
+ }
31
+ return Boolean(pattern(parsed));
32
+ }
33
+ if (pattern instanceof RegExp) return pattern.test(current);
34
+ return globToRegExp(pattern).test(current);
35
+ }
36
+
37
+ /** Human display of a pattern, for timeline labels and failure messages. */
38
+ export function describeUrlPattern(pattern: UrlPattern): string {
39
+ if (typeof pattern === "function") return "a URL predicate";
40
+ if (pattern instanceof RegExp) return String(pattern);
41
+ return JSON.stringify(pattern);
42
+ }
43
+
44
+ // Compiled globs are cached: a matcher polls the same pattern every 50ms.
45
+ const GLOB_CACHE = new Map<string, RegExp>();
46
+
47
+ function globToRegExp(glob: string): RegExp {
48
+ const hit = GLOB_CACHE.get(glob);
49
+ if (hit) return hit;
50
+ let out = "";
51
+ for (let i = 0; i < glob.length; i++) {
52
+ const c = glob[i]!;
53
+ if (c === "*") {
54
+ if (glob[i + 1] === "*") {
55
+ out += ".*";
56
+ i++;
57
+ } else {
58
+ out += "[^/]*";
59
+ }
60
+ continue;
61
+ }
62
+ out += c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
63
+ }
64
+ const re = new RegExp(`^${out}$`);
65
+ GLOB_CACHE.set(glob, re);
66
+ return re;
67
+ }
@@ -0,0 +1,521 @@
1
+ (function (g, f) {
2
+ if ("object" == typeof exports && "object" == typeof module) {
3
+ module.exports = f();
4
+ } else if ("function" == typeof define && define.amd) {
5
+ define("rrwebPluginConsoleRecord", [], f);
6
+ } else if ("object" == typeof exports) {
7
+ exports["rrwebPluginConsoleRecord"] = f();
8
+ } else {
9
+ g["rrwebPluginConsoleRecord"] = f();
10
+ }
11
+ }(this, () => {
12
+ var exports = {};
13
+ var module = { exports };
14
+ "use strict";
15
+ var __defProp = Object.defineProperty;
16
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
18
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
19
+ if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) ;
20
+ function patch(source, name, replacement) {
21
+ try {
22
+ if (!(name in source)) {
23
+ return () => {
24
+ };
25
+ }
26
+ const original = source[name];
27
+ const wrapped = replacement(original);
28
+ if (typeof wrapped === "function") {
29
+ wrapped.prototype = wrapped.prototype || {};
30
+ Object.defineProperties(wrapped, {
31
+ __rrweb_original__: {
32
+ enumerable: false,
33
+ value: original
34
+ }
35
+ });
36
+ }
37
+ source[name] = wrapped;
38
+ return () => {
39
+ source[name] = original;
40
+ };
41
+ } catch (e) {
42
+ return () => {
43
+ };
44
+ }
45
+ }
46
+ class StackFrame {
47
+ constructor(obj) {
48
+ __publicField(this, "fileName");
49
+ __publicField(this, "functionName");
50
+ __publicField(this, "lineNumber");
51
+ __publicField(this, "columnNumber");
52
+ this.fileName = obj.fileName || "";
53
+ this.functionName = obj.functionName || "";
54
+ this.lineNumber = obj.lineNumber;
55
+ this.columnNumber = obj.columnNumber;
56
+ }
57
+ toString() {
58
+ const lineNumber = this.lineNumber || "";
59
+ const columnNumber = this.columnNumber || "";
60
+ if (this.functionName)
61
+ return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;
62
+ return `${this.fileName}:${lineNumber}:${columnNumber}`;
63
+ }
64
+ }
65
+ const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
66
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
67
+ const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
68
+ const ErrorStackParser = {
69
+ /**
70
+ * Given an Error object, extract the most information from it.
71
+ */
72
+ parse: function(error) {
73
+ if (!error) {
74
+ return [];
75
+ }
76
+ if (
77
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
+ // @ts-ignore
79
+ typeof error.stacktrace !== "undefined" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // @ts-ignore
81
+ typeof error["opera#sourceloc"] !== "undefined"
82
+ ) {
83
+ return this.parseOpera(
84
+ error
85
+ );
86
+ } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
87
+ return this.parseV8OrIE(error);
88
+ } else if (error.stack) {
89
+ return this.parseFFOrSafari(error);
90
+ } else {
91
+ console.warn(
92
+ "[console-record-plugin]: Failed to parse error object:",
93
+ error
94
+ );
95
+ return [];
96
+ }
97
+ },
98
+ // Separate line and column numbers from a string of the form: (URI:Line:Column)
99
+ extractLocation: function(urlLike) {
100
+ if (urlLike.indexOf(":") === -1) {
101
+ return [urlLike];
102
+ }
103
+ const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
104
+ const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
105
+ if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);
106
+ return [parts[1], parts[2] || void 0, parts[3] || void 0];
107
+ },
108
+ parseV8OrIE: function(error) {
109
+ const filtered = error.stack.split("\n").filter(function(line) {
110
+ return !!line.match(CHROME_IE_STACK_REGEXP);
111
+ }, this);
112
+ return filtered.map(function(line) {
113
+ if (line.indexOf("(eval ") > -1) {
114
+ line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
115
+ }
116
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(");
117
+ const location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
118
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
119
+ const tokens = sanitizedLine.split(/\s+/).slice(1);
120
+ const locationParts = this.extractLocation(
121
+ location ? location[1] : tokens.pop()
122
+ );
123
+ const functionName = tokens.join(" ") || void 0;
124
+ const fileName = ["eval", "<anonymous>"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
125
+ return new StackFrame({
126
+ functionName,
127
+ fileName,
128
+ lineNumber: locationParts[1],
129
+ columnNumber: locationParts[2]
130
+ });
131
+ }, this);
132
+ },
133
+ parseFFOrSafari: function(error) {
134
+ const filtered = error.stack.split("\n").filter(function(line) {
135
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
136
+ }, this);
137
+ return filtered.map(function(line) {
138
+ if (line.indexOf(" > eval") > -1) {
139
+ line = line.replace(
140
+ / line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
141
+ ":$1"
142
+ );
143
+ }
144
+ if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
145
+ return new StackFrame({
146
+ functionName: line
147
+ });
148
+ } else {
149
+ const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
150
+ const matches = line.match(functionNameRegex);
151
+ const functionName = matches && matches[1] ? matches[1] : void 0;
152
+ const locationParts = this.extractLocation(
153
+ line.replace(functionNameRegex, "")
154
+ );
155
+ return new StackFrame({
156
+ functionName,
157
+ fileName: locationParts[0],
158
+ lineNumber: locationParts[1],
159
+ columnNumber: locationParts[2]
160
+ });
161
+ }
162
+ }, this);
163
+ },
164
+ parseOpera: function(e) {
165
+ if (!e.stacktrace || e.message.indexOf("\n") > -1 && e.message.split("\n").length > e.stacktrace.split("\n").length) {
166
+ return this.parseOpera9(e);
167
+ } else if (!e.stack) {
168
+ return this.parseOpera10(e);
169
+ } else {
170
+ return this.parseOpera11(e);
171
+ }
172
+ },
173
+ parseOpera9: function(e) {
174
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
175
+ const lines = e.message.split("\n");
176
+ const result = [];
177
+ for (let i = 2, len = lines.length; i < len; i += 2) {
178
+ const match = lineRE.exec(lines[i]);
179
+ if (match) {
180
+ result.push(
181
+ new StackFrame({
182
+ fileName: match[2],
183
+ lineNumber: parseFloat(match[1])
184
+ })
185
+ );
186
+ }
187
+ }
188
+ return result;
189
+ },
190
+ parseOpera10: function(e) {
191
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
192
+ const lines = e.stacktrace.split("\n");
193
+ const result = [];
194
+ for (let i = 0, len = lines.length; i < len; i += 2) {
195
+ const match = lineRE.exec(lines[i]);
196
+ if (match) {
197
+ result.push(
198
+ new StackFrame({
199
+ functionName: match[3] || void 0,
200
+ fileName: match[2],
201
+ lineNumber: parseFloat(match[1])
202
+ })
203
+ );
204
+ }
205
+ }
206
+ return result;
207
+ },
208
+ // Opera 10.65+ Error.stack very similar to FF/Safari
209
+ parseOpera11: function(error) {
210
+ const filtered = error.stack.split("\n").filter(function(line) {
211
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
212
+ }, this);
213
+ return filtered.map(function(line) {
214
+ const tokens = line.split("@");
215
+ const locationParts = this.extractLocation(tokens.pop());
216
+ const functionCall = tokens.shift() || "";
217
+ const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
218
+ return new StackFrame({
219
+ functionName,
220
+ fileName: locationParts[0],
221
+ lineNumber: locationParts[1],
222
+ columnNumber: locationParts[2]
223
+ });
224
+ }, this);
225
+ }
226
+ };
227
+ function pathToSelector(node) {
228
+ if (!node || !node.outerHTML) {
229
+ return "";
230
+ }
231
+ let path = "";
232
+ while (node.parentElement) {
233
+ let name = node.localName;
234
+ if (!name) {
235
+ break;
236
+ }
237
+ name = name.toLowerCase();
238
+ const parent = node.parentElement;
239
+ const domSiblings = [];
240
+ if (parent.children && parent.children.length > 0) {
241
+ for (let i = 0; i < parent.children.length; i++) {
242
+ const sibling = parent.children[i];
243
+ if (sibling.localName && sibling.localName.toLowerCase) {
244
+ if (sibling.localName.toLowerCase() === name) {
245
+ domSiblings.push(sibling);
246
+ }
247
+ }
248
+ }
249
+ }
250
+ if (domSiblings.length > 1) {
251
+ name += `:eq(${domSiblings.indexOf(node)})`;
252
+ }
253
+ path = name + (path ? ">" + path : "");
254
+ node = parent;
255
+ }
256
+ return path;
257
+ }
258
+ function isObject(obj) {
259
+ return Object.prototype.toString.call(obj) === "[object Object]";
260
+ }
261
+ function isObjTooDeep(obj, limit) {
262
+ if (limit === 0) {
263
+ return true;
264
+ }
265
+ const keys = Object.keys(obj);
266
+ for (const key of keys) {
267
+ if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
268
+ return true;
269
+ }
270
+ }
271
+ return false;
272
+ }
273
+ function stringify(obj, stringifyOptions) {
274
+ const options = {
275
+ numOfKeysLimit: 50,
276
+ depthOfLimit: 4
277
+ };
278
+ Object.assign(options, stringifyOptions);
279
+ const stack = [];
280
+ const keys = [];
281
+ return JSON.stringify(
282
+ obj,
283
+ function(key, value) {
284
+ if (stack.length > 0) {
285
+ const thisPos = stack.indexOf(this);
286
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
287
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
288
+ if (~stack.indexOf(value)) {
289
+ if (stack[0] === value) {
290
+ value = "[Circular ~]";
291
+ } else {
292
+ value = "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
293
+ }
294
+ }
295
+ } else {
296
+ stack.push(value);
297
+ }
298
+ if (value === null) return value;
299
+ if (value === void 0) return "undefined";
300
+ if (shouldIgnore(value)) {
301
+ return toString(value);
302
+ }
303
+ if (typeof value === "bigint") {
304
+ return value.toString() + "n";
305
+ }
306
+ if (value instanceof Event) {
307
+ const eventResult = {};
308
+ for (const eventKey in value) {
309
+ const eventValue = value[eventKey];
310
+ if (Array.isArray(eventValue)) {
311
+ eventResult[eventKey] = pathToSelector(
312
+ eventValue.length ? eventValue[0] : null
313
+ );
314
+ } else {
315
+ eventResult[eventKey] = eventValue;
316
+ }
317
+ }
318
+ return eventResult;
319
+ } else if (value instanceof Node) {
320
+ if (value instanceof HTMLElement) {
321
+ return value ? value.outerHTML : "";
322
+ }
323
+ return value.nodeName;
324
+ } else if (value instanceof Error) {
325
+ return value.stack ? value.stack + "\nEnd of stack for Error object" : value.name + ": " + value.message;
326
+ }
327
+ return value;
328
+ }
329
+ );
330
+ function shouldIgnore(_obj) {
331
+ if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
332
+ return true;
333
+ }
334
+ if (typeof _obj === "function") {
335
+ return true;
336
+ }
337
+ if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
338
+ return true;
339
+ }
340
+ return false;
341
+ }
342
+ function toString(_obj) {
343
+ let str = _obj.toString();
344
+ if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
345
+ str = `${str.slice(0, options.stringLengthLimit)}...`;
346
+ }
347
+ return str;
348
+ }
349
+ }
350
+ const defaultLogOptions = {
351
+ level: [
352
+ "assert",
353
+ "clear",
354
+ "count",
355
+ "countReset",
356
+ "debug",
357
+ "dir",
358
+ "dirxml",
359
+ "error",
360
+ "group",
361
+ "groupCollapsed",
362
+ "groupEnd",
363
+ "info",
364
+ "log",
365
+ "table",
366
+ "time",
367
+ "timeEnd",
368
+ "timeLog",
369
+ "trace",
370
+ "warn"
371
+ ],
372
+ lengthThreshold: 1e3,
373
+ logger: "console"
374
+ };
375
+ function initLogObserver(cb, win, options) {
376
+ const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;
377
+ const loggerType = logOptions.logger;
378
+ if (!loggerType) {
379
+ return () => {
380
+ };
381
+ }
382
+ let logger;
383
+ if (typeof loggerType === "string") {
384
+ logger = win[loggerType];
385
+ } else {
386
+ logger = loggerType;
387
+ }
388
+ let logCount = 0;
389
+ let inStack = false;
390
+ const cancelHandlers = [];
391
+ if (logOptions.level.includes("error")) {
392
+ const errorHandler = (event) => {
393
+ const message = event.message, error = event.error;
394
+ const trace = ErrorStackParser.parse(error).map(
395
+ (stackFrame) => stackFrame.toString()
396
+ );
397
+ const payload = [stringify(message, logOptions.stringifyOptions)];
398
+ cb({
399
+ level: "error",
400
+ trace,
401
+ payload
402
+ });
403
+ };
404
+ win.addEventListener("error", errorHandler);
405
+ cancelHandlers.push(() => {
406
+ win.removeEventListener("error", errorHandler);
407
+ });
408
+ const unhandledrejectionHandler = (event) => {
409
+ let error;
410
+ let payload;
411
+ if (event.reason instanceof Error) {
412
+ error = event.reason;
413
+ payload = [
414
+ stringify(
415
+ `Uncaught (in promise) ${error.name}: ${error.message}`,
416
+ logOptions.stringifyOptions
417
+ )
418
+ ];
419
+ } else {
420
+ error = new Error();
421
+ payload = [
422
+ stringify("Uncaught (in promise)", logOptions.stringifyOptions),
423
+ stringify(event.reason, logOptions.stringifyOptions)
424
+ ];
425
+ }
426
+ const trace = ErrorStackParser.parse(error).map(
427
+ (stackFrame) => stackFrame.toString()
428
+ );
429
+ cb({
430
+ level: "error",
431
+ trace,
432
+ payload
433
+ });
434
+ };
435
+ win.addEventListener("unhandledrejection", unhandledrejectionHandler);
436
+ cancelHandlers.push(() => {
437
+ win.removeEventListener("unhandledrejection", unhandledrejectionHandler);
438
+ });
439
+ }
440
+ for (const levelType of logOptions.level) {
441
+ cancelHandlers.push(replace(logger, levelType));
442
+ }
443
+ return () => {
444
+ cancelHandlers.forEach((h) => h());
445
+ };
446
+ function replace(_logger, level) {
447
+ if (!_logger[level]) {
448
+ return () => {
449
+ };
450
+ }
451
+ return patch(
452
+ _logger,
453
+ level,
454
+ (original) => {
455
+ return (...args) => {
456
+ original.apply(this, args);
457
+ if (level === "assert" && !!args[0]) {
458
+ return;
459
+ }
460
+ if (inStack) {
461
+ return;
462
+ }
463
+ inStack = true;
464
+ try {
465
+ const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);
466
+ const argsForPayload = level === "assert" ? args.slice(1) : args;
467
+ const payload = argsForPayload.map(
468
+ (s) => stringify(s, logOptions.stringifyOptions)
469
+ );
470
+ logCount++;
471
+ if (logCount < logOptions.lengthThreshold) {
472
+ cb({
473
+ level,
474
+ trace,
475
+ payload
476
+ });
477
+ } else if (logCount === logOptions.lengthThreshold) {
478
+ cb({
479
+ level: "warn",
480
+ trace: [],
481
+ payload: [
482
+ stringify("The number of log records reached the threshold.")
483
+ ]
484
+ });
485
+ }
486
+ } catch (error) {
487
+ original("rrweb logger error:", error, ...args);
488
+ } finally {
489
+ inStack = false;
490
+ }
491
+ };
492
+ }
493
+ );
494
+ }
495
+ }
496
+ const PLUGIN_NAME = "rrweb/console@1";
497
+ const getRecordConsolePlugin = (options) => ({
498
+ name: PLUGIN_NAME,
499
+ observer: initLogObserver,
500
+ options
501
+ });
502
+ exports.PLUGIN_NAME = PLUGIN_NAME;
503
+ exports.getRecordConsolePlugin = getRecordConsolePlugin;
504
+ if (typeof module.exports == "object" && typeof exports == "object") {
505
+ var __cp = (to, from, except, desc) => {
506
+ if ((from && typeof from === "object") || typeof from === "function") {
507
+ for (let key of Object.getOwnPropertyNames(from)) {
508
+ if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
509
+ Object.defineProperty(to, key, {
510
+ get: () => from[key],
511
+ enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
512
+ });
513
+ }
514
+ }
515
+ return to;
516
+ };
517
+ module.exports = __cp(module.exports, exports);
518
+ }
519
+ return module.exports;
520
+ }))
521
+ //# sourceMappingURL=rrweb-plugin-console-record.umd.cjs.map