@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +691 -0
- package/browser/context.d.ts +4 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
- package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
- package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/@vitest/browser/client/error-catcher.js +82 -0
- package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
- package/dist/@vitest/browser/client/favicon.svg +5 -0
- package/dist/@vitest/browser/client/orchestrator.html +35 -0
- package/dist/@vitest/browser/client/tester/tester.html +13 -0
- package/dist/@vitest/browser/client.js +456 -0
- package/dist/@vitest/browser/context.d.ts +792 -0
- package/dist/@vitest/browser/context.js +541 -0
- package/dist/@vitest/browser/expect-element.js +32 -0
- package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
- package/dist/@vitest/browser/index.d.ts +73 -0
- package/dist/@vitest/browser/index.js +3513 -0
- package/dist/@vitest/browser/jest-dom.d.ts +724 -0
- package/dist/@vitest/browser/locators.d.ts +354 -0
- package/dist/@vitest/browser/locators.js +1 -0
- package/dist/@vitest/browser/matchers.d.ts +29 -0
- package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/@vitest/browser/state.js +280 -0
- package/dist/@vitest/browser/types.d.ts +69 -0
- package/dist/@vitest/browser-playwright/context.d.ts +1 -0
- package/dist/@vitest/browser-playwright/index.d.ts +106 -0
- package/dist/@vitest/browser-playwright/index.js +1111 -0
- package/dist/@vitest/browser-playwright/locators.js +114 -0
- package/dist/@vitest/browser-preview/context.d.ts +1 -0
- package/dist/@vitest/browser-preview/index.d.ts +19 -0
- package/dist/@vitest/browser-preview/index.js +148 -0
- package/dist/@vitest/browser-preview/locators.js +79 -0
- package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
- package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
- package/dist/@vitest/browser-webdriverio/index.js +600 -0
- package/dist/@vitest/browser-webdriverio/locators.js +163 -0
- package/dist/@vitest/expect/index.d.ts +807 -0
- package/dist/@vitest/expect/index.js +1875 -0
- package/dist/@vitest/mocker/auto-register.d.ts +2 -0
- package/dist/@vitest/mocker/auto-register.js +9 -0
- package/dist/@vitest/mocker/automock.d.ts +12 -0
- package/dist/@vitest/mocker/automock.js +1 -0
- package/dist/@vitest/mocker/browser.d.ts +53 -0
- package/dist/@vitest/mocker/browser.js +91 -0
- package/dist/@vitest/mocker/chunk-automock.js +354 -0
- package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
- package/dist/@vitest/mocker/chunk-mocker.js +521 -0
- package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
- package/dist/@vitest/mocker/chunk-registry.js +185 -0
- package/dist/@vitest/mocker/chunk-utils.js +16 -0
- package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
- package/dist/@vitest/mocker/index.d.ts +2 -0
- package/dist/@vitest/mocker/index.js +185 -0
- package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
- package/dist/@vitest/mocker/node.d.ts +800 -0
- package/dist/@vitest/mocker/node.js +966 -0
- package/dist/@vitest/mocker/redirect.d.ts +3 -0
- package/dist/@vitest/mocker/redirect.js +79 -0
- package/dist/@vitest/mocker/register.d.ts +9 -0
- package/dist/@vitest/mocker/register.js +41 -0
- package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
- package/dist/@vitest/pretty-format/index.d.ts +124 -0
- package/dist/@vitest/pretty-format/index.js +1022 -0
- package/dist/@vitest/runner/chunk-tasks.js +340 -0
- package/dist/@vitest/runner/index.d.ts +180 -0
- package/dist/@vitest/runner/index.js +2114 -0
- package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
- package/dist/@vitest/runner/types.d.ts +183 -0
- package/dist/@vitest/runner/types.js +1 -0
- package/dist/@vitest/runner/utils.d.ts +45 -0
- package/dist/@vitest/runner/utils.js +5 -0
- package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
- package/dist/@vitest/snapshot/environment.d.ts +16 -0
- package/dist/@vitest/snapshot/environment.js +40 -0
- package/dist/@vitest/snapshot/index.d.ts +130 -0
- package/dist/@vitest/snapshot/index.js +1437 -0
- package/dist/@vitest/snapshot/manager.d.ts +18 -0
- package/dist/@vitest/snapshot/manager.js +73 -0
- package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/dist/@vitest/spy/index.d.ts +384 -0
- package/dist/@vitest/spy/index.js +433 -0
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
- package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/@vitest/utils/constants.d.ts +21 -0
- package/dist/@vitest/utils/constants.js +49 -0
- package/dist/@vitest/utils/diff.d.ts +93 -0
- package/dist/@vitest/utils/diff.js +2199 -0
- package/dist/@vitest/utils/display.d.ts +29 -0
- package/dist/@vitest/utils/display.js +742 -0
- package/dist/@vitest/utils/error.d.ts +7 -0
- package/dist/@vitest/utils/error.js +42 -0
- package/dist/@vitest/utils/helpers.d.ts +73 -0
- package/dist/@vitest/utils/helpers.js +295 -0
- package/dist/@vitest/utils/highlight.d.ts +9 -0
- package/dist/@vitest/utils/highlight.js +538 -0
- package/dist/@vitest/utils/index.d.ts +5 -0
- package/dist/@vitest/utils/index.js +1 -0
- package/dist/@vitest/utils/offset.d.ts +5 -0
- package/dist/@vitest/utils/offset.js +32 -0
- package/dist/@vitest/utils/resolver.d.ts +7 -0
- package/dist/@vitest/utils/resolver.js +71 -0
- package/dist/@vitest/utils/serialize.d.ts +3 -0
- package/dist/@vitest/utils/serialize.js +118 -0
- package/dist/@vitest/utils/source-map.d.ts +55 -0
- package/dist/@vitest/utils/source-map.js +478 -0
- package/dist/@vitest/utils/timers.d.ts +33 -0
- package/dist/@vitest/utils/timers.js +49 -0
- package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
- package/dist/@vitest/utils/types.d.ts +34 -0
- package/dist/@vitest/utils/types.js +1 -0
- package/dist/browser-compat.js +3 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/bg.png +0 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +5 -0
- package/dist/client/__vitest__/index.html +32 -0
- package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/client/error-catcher.js +82 -0
- package/dist/client/esm-client-injector.js +67 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/orchestrator.html +35 -0
- package/dist/client/tester/tester.html +13 -0
- package/dist/client.js +456 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/context.js +541 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/dummy.js +2 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/expect-element.js +27 -0
- package/dist/index-D6m36C6U.js +6 -0
- package/dist/index-node.js +7 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +19 -0
- package/dist/locators.d.ts +354 -0
- package/dist/locators.js +1 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner-stub.js +44 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/plugins/browser-client.mjs +2 -0
- package/dist/plugins/browser-context.mjs +2 -0
- package/dist/plugins/browser-locators.mjs +2 -0
- package/dist/plugins/browser-playwright.mjs +2 -0
- package/dist/plugins/browser-preview.mjs +2 -0
- package/dist/plugins/browser-webdriverio.mjs +2 -0
- package/dist/plugins/browser.mjs +2 -0
- package/dist/plugins/expect.mjs +2 -0
- package/dist/plugins/mocker-automock.mjs +2 -0
- package/dist/plugins/mocker-browser.mjs +2 -0
- package/dist/plugins/mocker-node.mjs +2 -0
- package/dist/plugins/mocker-redirect.mjs +2 -0
- package/dist/plugins/mocker-register.mjs +2 -0
- package/dist/plugins/mocker.mjs +2 -0
- package/dist/plugins/pretty-format.mjs +2 -0
- package/dist/plugins/runner-types.mjs +2 -0
- package/dist/plugins/runner-utils.mjs +2 -0
- package/dist/plugins/runner.mjs +2 -0
- package/dist/plugins/snapshot-environment.mjs +2 -0
- package/dist/plugins/snapshot-manager.mjs +2 -0
- package/dist/plugins/snapshot.mjs +2 -0
- package/dist/plugins/spy.mjs +2 -0
- package/dist/plugins/utils-constants.mjs +2 -0
- package/dist/plugins/utils-diff.mjs +2 -0
- package/dist/plugins/utils-display.mjs +2 -0
- package/dist/plugins/utils-error.mjs +2 -0
- package/dist/plugins/utils-helpers.mjs +2 -0
- package/dist/plugins/utils-highlight.mjs +2 -0
- package/dist/plugins/utils-offset.mjs +2 -0
- package/dist/plugins/utils-resolver.mjs +2 -0
- package/dist/plugins/utils-serialize.mjs +2 -0
- package/dist/plugins/utils-source-map.mjs +2 -0
- package/dist/plugins/utils-timers.mjs +2 -0
- package/dist/plugins/utils.mjs +2 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/state.js +280 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/types.d.ts +69 -0
- package/dist/vendor/chai.d.mts +1 -0
- package/dist/vendor/chai.mjs +3577 -0
- package/dist/vendor/es-module-lexer.d.mts +193 -0
- package/dist/vendor/es-module-lexer.mjs +79 -0
- package/dist/vendor/estree-walker.d.mts +583 -0
- package/dist/vendor/estree-walker.mjs +339 -0
- package/dist/vendor/expect-type.d.mts +1574 -0
- package/dist/vendor/expect-type.mjs +214 -0
- package/dist/vendor/magic-string.d.mts +261 -0
- package/dist/vendor/magic-string.mjs +1700 -0
- package/dist/vendor/obug.d.mts +56 -0
- package/dist/vendor/obug.mjs +276 -0
- package/dist/vendor/pathe.d.mts +46 -0
- package/dist/vendor/pathe.mjs +496 -0
- package/dist/vendor/picomatch.d.mts +1 -0
- package/dist/vendor/picomatch.mjs +1855 -0
- package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
- package/dist/vendor/std-env.d.mts +88 -0
- package/dist/vendor/std-env.mjs +159 -0
- package/dist/vendor/tinybench.d.mts +317 -0
- package/dist/vendor/tinybench.mjs +504 -0
- package/dist/vendor/tinyexec.d.mts +72 -0
- package/dist/vendor/tinyexec.mjs +637 -0
- package/dist/vendor/tinyglobby.d.mts +157 -0
- package/dist/vendor/tinyglobby.mjs +832 -0
- package/dist/vendor/tinyrainbow.d.mts +60 -0
- package/dist/vendor/tinyrainbow.mjs +93 -0
- package/dist/vendor/vitest_browser.mjs +2 -0
- package/dist/vendor/vitest_internal_browser.mjs +2 -0
- package/dist/vendor/vitest_runner.mjs +2 -0
- package/dist/vendor/vitest_runners.mjs +2 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +335 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
|
|
2
|
+
const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
|
|
3
|
+
function isImmutable(v) {
|
|
4
|
+
return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
|
|
5
|
+
}
|
|
6
|
+
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
7
|
+
function getUnserializableMessage(err) {
|
|
8
|
+
if (err instanceof Error) {
|
|
9
|
+
return `<unserializable>: ${err.message}`;
|
|
10
|
+
}
|
|
11
|
+
if (typeof err === "string") {
|
|
12
|
+
return `<unserializable>: ${err}`;
|
|
13
|
+
}
|
|
14
|
+
return "<unserializable>";
|
|
15
|
+
}
|
|
16
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
17
|
+
function serializeValue(val, seen = new WeakMap()) {
|
|
18
|
+
if (!val || typeof val === "string") {
|
|
19
|
+
return val;
|
|
20
|
+
}
|
|
21
|
+
if (val instanceof Error && "toJSON" in val && typeof val.toJSON === "function") {
|
|
22
|
+
const jsonValue = val.toJSON();
|
|
23
|
+
if (jsonValue && jsonValue !== val && typeof jsonValue === "object") {
|
|
24
|
+
if (typeof val.message === "string") {
|
|
25
|
+
safe(() => jsonValue.message ?? (jsonValue.message = normalizeErrorMessage(val.message)));
|
|
26
|
+
}
|
|
27
|
+
if (typeof val.stack === "string") {
|
|
28
|
+
safe(() => jsonValue.stack ?? (jsonValue.stack = val.stack));
|
|
29
|
+
}
|
|
30
|
+
if (typeof val.name === "string") {
|
|
31
|
+
safe(() => jsonValue.name ?? (jsonValue.name = val.name));
|
|
32
|
+
}
|
|
33
|
+
if (val.cause != null) {
|
|
34
|
+
safe(() => jsonValue.cause ?? (jsonValue.cause = serializeValue(val.cause, seen)));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return serializeValue(jsonValue, seen);
|
|
38
|
+
}
|
|
39
|
+
if (typeof val === "function") {
|
|
40
|
+
return `Function<${val.name || "anonymous"}>`;
|
|
41
|
+
}
|
|
42
|
+
if (typeof val === "symbol") {
|
|
43
|
+
return val.toString();
|
|
44
|
+
}
|
|
45
|
+
if (typeof val !== "object") {
|
|
46
|
+
return val;
|
|
47
|
+
}
|
|
48
|
+
if (typeof Buffer !== "undefined" && val instanceof Buffer) {
|
|
49
|
+
return `<Buffer(${val.length}) ...>`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof Uint8Array !== "undefined" && val instanceof Uint8Array) {
|
|
52
|
+
return `<Uint8Array(${val.length}) ...>`;
|
|
53
|
+
}
|
|
54
|
+
// cannot serialize immutables as immutables
|
|
55
|
+
if (isImmutable(val)) {
|
|
56
|
+
return serializeValue(val.toJSON(), seen);
|
|
57
|
+
}
|
|
58
|
+
if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction") {
|
|
59
|
+
return "Promise";
|
|
60
|
+
}
|
|
61
|
+
if (typeof Element !== "undefined" && val instanceof Element) {
|
|
62
|
+
return val.tagName;
|
|
63
|
+
}
|
|
64
|
+
if (typeof val.toJSON === "function") {
|
|
65
|
+
return serializeValue(val.toJSON(), seen);
|
|
66
|
+
}
|
|
67
|
+
if (seen.has(val)) {
|
|
68
|
+
return seen.get(val);
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(val)) {
|
|
71
|
+
// eslint-disable-next-line unicorn/no-new-array -- we need to keep sparse arrays ([1,,3])
|
|
72
|
+
const clone = new Array(val.length);
|
|
73
|
+
seen.set(val, clone);
|
|
74
|
+
val.forEach((e, i) => {
|
|
75
|
+
try {
|
|
76
|
+
clone[i] = serializeValue(e, seen);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
clone[i] = getUnserializableMessage(err);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return clone;
|
|
82
|
+
} else {
|
|
83
|
+
// Objects with `Error` constructors appear to cause problems during worker communication
|
|
84
|
+
// using `MessagePort`, so the serialized error object is being recreated as plain object.
|
|
85
|
+
const clone = Object.create(null);
|
|
86
|
+
seen.set(val, clone);
|
|
87
|
+
let obj = val;
|
|
88
|
+
while (obj && obj !== OBJECT_PROTO) {
|
|
89
|
+
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
90
|
+
if (key in clone) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
clone[key] = serializeValue(val[key], seen);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
// delete in case it has a setter from prototype that might throw
|
|
97
|
+
delete clone[key];
|
|
98
|
+
clone[key] = getUnserializableMessage(err);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
obj = Object.getPrototypeOf(obj);
|
|
102
|
+
}
|
|
103
|
+
if (val instanceof Error) {
|
|
104
|
+
safe(() => val.message = normalizeErrorMessage(val.message));
|
|
105
|
+
}
|
|
106
|
+
return clone;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function safe(fn) {
|
|
110
|
+
try {
|
|
111
|
+
return fn();
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
function normalizeErrorMessage(message) {
|
|
115
|
+
return message.replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { serializeValue };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TestError, ParsedStack } from './types.js';
|
|
2
|
+
|
|
3
|
+
type OriginalMapping = {
|
|
4
|
+
source: string | null;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
name: string | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface StackTraceParserOptions {
|
|
11
|
+
ignoreStackEntries?: (RegExp | string)[];
|
|
12
|
+
getSourceMap?: (file: string) => unknown;
|
|
13
|
+
getUrlId?: (id: string) => string;
|
|
14
|
+
frameFilter?: (error: TestError, frame: ParsedStack) => boolean | void;
|
|
15
|
+
}
|
|
16
|
+
declare const stackIgnorePatterns: (string | RegExp)[];
|
|
17
|
+
|
|
18
|
+
declare function parseSingleFFOrSafariStack(raw: string): ParsedStack | null;
|
|
19
|
+
declare function parseSingleStack(raw: string): ParsedStack | null;
|
|
20
|
+
declare function parseSingleV8Stack(raw: string): ParsedStack | null;
|
|
21
|
+
declare function createStackString(stacks: ParsedStack[]): string;
|
|
22
|
+
declare function parseStacktrace(stack: string, options?: StackTraceParserOptions): ParsedStack[];
|
|
23
|
+
declare function parseErrorStacktrace(e: TestError | Error, options?: StackTraceParserOptions): ParsedStack[];
|
|
24
|
+
interface SourceMapLike {
|
|
25
|
+
version: number;
|
|
26
|
+
mappings?: string;
|
|
27
|
+
names?: string[];
|
|
28
|
+
sources?: string[];
|
|
29
|
+
sourcesContent?: string[];
|
|
30
|
+
sourceRoot?: string;
|
|
31
|
+
}
|
|
32
|
+
interface Needle {
|
|
33
|
+
line: number;
|
|
34
|
+
column: number;
|
|
35
|
+
}
|
|
36
|
+
declare class DecodedMap {
|
|
37
|
+
map: SourceMapLike;
|
|
38
|
+
_encoded: string;
|
|
39
|
+
_decoded: undefined | number[][][];
|
|
40
|
+
_decodedMemo: Stats;
|
|
41
|
+
url: string;
|
|
42
|
+
version: number;
|
|
43
|
+
names: string[];
|
|
44
|
+
resolvedSources: string[];
|
|
45
|
+
constructor(map: SourceMapLike, from: string);
|
|
46
|
+
}
|
|
47
|
+
interface Stats {
|
|
48
|
+
lastKey: number;
|
|
49
|
+
lastNeedle: number;
|
|
50
|
+
lastIndex: number;
|
|
51
|
+
}
|
|
52
|
+
declare function getOriginalPosition(map: DecodedMap, needle: Needle): OriginalMapping | null;
|
|
53
|
+
|
|
54
|
+
export { DecodedMap, createStackString, stackIgnorePatterns as defaultStackIgnorePatterns, getOriginalPosition, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
|
|
55
|
+
export type { StackTraceParserOptions };
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { isPrimitive, notNullish } from './helpers.js';
|
|
2
|
+
import { r as resolve } from './chunk-pathe.M-eThtNZ.js';
|
|
3
|
+
import './constants.js';
|
|
4
|
+
|
|
5
|
+
// src/vlq.ts
|
|
6
|
+
var comma = ",".charCodeAt(0);
|
|
7
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
8
|
+
var intToChar = new Uint8Array(64);
|
|
9
|
+
var charToInt = new Uint8Array(128);
|
|
10
|
+
for (let i = 0; i < chars.length; i++) {
|
|
11
|
+
const c = chars.charCodeAt(i);
|
|
12
|
+
intToChar[i] = c;
|
|
13
|
+
charToInt[c] = i;
|
|
14
|
+
}
|
|
15
|
+
function decodeInteger(reader, relative) {
|
|
16
|
+
let value = 0;
|
|
17
|
+
let shift = 0;
|
|
18
|
+
let integer = 0;
|
|
19
|
+
do {
|
|
20
|
+
const c = reader.next();
|
|
21
|
+
integer = charToInt[c];
|
|
22
|
+
value |= (integer & 31) << shift;
|
|
23
|
+
shift += 5;
|
|
24
|
+
} while (integer & 32);
|
|
25
|
+
const shouldNegate = value & 1;
|
|
26
|
+
value >>>= 1;
|
|
27
|
+
if (shouldNegate) {
|
|
28
|
+
value = -2147483648 | -value;
|
|
29
|
+
}
|
|
30
|
+
return relative + value;
|
|
31
|
+
}
|
|
32
|
+
function hasMoreVlq(reader, max) {
|
|
33
|
+
if (reader.pos >= max) return false;
|
|
34
|
+
return reader.peek() !== comma;
|
|
35
|
+
}
|
|
36
|
+
var StringReader = class {
|
|
37
|
+
constructor(buffer) {
|
|
38
|
+
this.pos = 0;
|
|
39
|
+
this.buffer = buffer;
|
|
40
|
+
}
|
|
41
|
+
next() {
|
|
42
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
43
|
+
}
|
|
44
|
+
peek() {
|
|
45
|
+
return this.buffer.charCodeAt(this.pos);
|
|
46
|
+
}
|
|
47
|
+
indexOf(char) {
|
|
48
|
+
const { buffer, pos } = this;
|
|
49
|
+
const idx = buffer.indexOf(char, pos);
|
|
50
|
+
return idx === -1 ? buffer.length : idx;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/sourcemap-codec.ts
|
|
55
|
+
function decode(mappings) {
|
|
56
|
+
const { length } = mappings;
|
|
57
|
+
const reader = new StringReader(mappings);
|
|
58
|
+
const decoded = [];
|
|
59
|
+
let genColumn = 0;
|
|
60
|
+
let sourcesIndex = 0;
|
|
61
|
+
let sourceLine = 0;
|
|
62
|
+
let sourceColumn = 0;
|
|
63
|
+
let namesIndex = 0;
|
|
64
|
+
do {
|
|
65
|
+
const semi = reader.indexOf(";");
|
|
66
|
+
const line = [];
|
|
67
|
+
let sorted = true;
|
|
68
|
+
let lastCol = 0;
|
|
69
|
+
genColumn = 0;
|
|
70
|
+
while (reader.pos < semi) {
|
|
71
|
+
let seg;
|
|
72
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
73
|
+
if (genColumn < lastCol) sorted = false;
|
|
74
|
+
lastCol = genColumn;
|
|
75
|
+
if (hasMoreVlq(reader, semi)) {
|
|
76
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
77
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
78
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
79
|
+
if (hasMoreVlq(reader, semi)) {
|
|
80
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
81
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
82
|
+
} else {
|
|
83
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
seg = [genColumn];
|
|
87
|
+
}
|
|
88
|
+
line.push(seg);
|
|
89
|
+
reader.pos++;
|
|
90
|
+
}
|
|
91
|
+
if (!sorted) sort(line);
|
|
92
|
+
decoded.push(line);
|
|
93
|
+
reader.pos = semi + 1;
|
|
94
|
+
} while (reader.pos <= length);
|
|
95
|
+
return decoded;
|
|
96
|
+
}
|
|
97
|
+
function sort(line) {
|
|
98
|
+
line.sort(sortComparator);
|
|
99
|
+
}
|
|
100
|
+
function sortComparator(a, b) {
|
|
101
|
+
return a[0] - b[0];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/trace-mapping.ts
|
|
105
|
+
|
|
106
|
+
// src/sourcemap-segment.ts
|
|
107
|
+
var COLUMN = 0;
|
|
108
|
+
var SOURCES_INDEX = 1;
|
|
109
|
+
var SOURCE_LINE = 2;
|
|
110
|
+
var SOURCE_COLUMN = 3;
|
|
111
|
+
var NAMES_INDEX = 4;
|
|
112
|
+
|
|
113
|
+
// src/binary-search.ts
|
|
114
|
+
var found = false;
|
|
115
|
+
function binarySearch(haystack, needle, low, high) {
|
|
116
|
+
while (low <= high) {
|
|
117
|
+
const mid = low + (high - low >> 1);
|
|
118
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
119
|
+
if (cmp === 0) {
|
|
120
|
+
found = true;
|
|
121
|
+
return mid;
|
|
122
|
+
}
|
|
123
|
+
if (cmp < 0) {
|
|
124
|
+
low = mid + 1;
|
|
125
|
+
} else {
|
|
126
|
+
high = mid - 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
found = false;
|
|
130
|
+
return low - 1;
|
|
131
|
+
}
|
|
132
|
+
function upperBound(haystack, needle, index) {
|
|
133
|
+
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
134
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
135
|
+
}
|
|
136
|
+
return index;
|
|
137
|
+
}
|
|
138
|
+
function lowerBound(haystack, needle, index) {
|
|
139
|
+
for (let i = index - 1; i >= 0; index = i--) {
|
|
140
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
141
|
+
}
|
|
142
|
+
return index;
|
|
143
|
+
}
|
|
144
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
145
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
146
|
+
let low = 0;
|
|
147
|
+
let high = haystack.length - 1;
|
|
148
|
+
if (key === lastKey) {
|
|
149
|
+
if (needle === lastNeedle) {
|
|
150
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
151
|
+
return lastIndex;
|
|
152
|
+
}
|
|
153
|
+
if (needle >= lastNeedle) {
|
|
154
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
155
|
+
} else {
|
|
156
|
+
high = lastIndex;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
state.lastKey = key;
|
|
160
|
+
state.lastNeedle = needle;
|
|
161
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/trace-mapping.ts
|
|
165
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
166
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
167
|
+
var LEAST_UPPER_BOUND = -1;
|
|
168
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
169
|
+
function cast(map) {
|
|
170
|
+
return map;
|
|
171
|
+
}
|
|
172
|
+
function decodedMappings(map) {
|
|
173
|
+
var _a;
|
|
174
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
175
|
+
}
|
|
176
|
+
function originalPositionFor(map, needle) {
|
|
177
|
+
let { line, column, bias } = needle;
|
|
178
|
+
line--;
|
|
179
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
180
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
181
|
+
const decoded = decodedMappings(map);
|
|
182
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
183
|
+
const segments = decoded[line];
|
|
184
|
+
const index = traceSegmentInternal(
|
|
185
|
+
segments,
|
|
186
|
+
cast(map)._decodedMemo,
|
|
187
|
+
line,
|
|
188
|
+
column,
|
|
189
|
+
bias || GREATEST_LOWER_BOUND
|
|
190
|
+
);
|
|
191
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
192
|
+
const segment = segments[index];
|
|
193
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
194
|
+
const { names, resolvedSources } = map;
|
|
195
|
+
return OMapping(
|
|
196
|
+
resolvedSources[segment[SOURCES_INDEX]],
|
|
197
|
+
segment[SOURCE_LINE] + 1,
|
|
198
|
+
segment[SOURCE_COLUMN],
|
|
199
|
+
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
function OMapping(source, line, column, name) {
|
|
203
|
+
return { source, line, column, name };
|
|
204
|
+
}
|
|
205
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
206
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
207
|
+
if (found) {
|
|
208
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
209
|
+
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
210
|
+
if (index === -1 || index === segments.length) return -1;
|
|
211
|
+
return index;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
215
|
+
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
216
|
+
const stackIgnorePatterns = [
|
|
217
|
+
"node:internal",
|
|
218
|
+
/\/packages\/\w+\/dist\//,
|
|
219
|
+
/\/@vitest\/\w+\/dist\//,
|
|
220
|
+
"/vitest/dist/",
|
|
221
|
+
"/vitest/src/",
|
|
222
|
+
"/node_modules/chai/",
|
|
223
|
+
"/node_modules/tinyspy/",
|
|
224
|
+
"/vite/dist/node/module-runner",
|
|
225
|
+
"/rolldown-vite/dist/node/module-runner",
|
|
226
|
+
"/deps/chunk-",
|
|
227
|
+
"/deps/@vitest",
|
|
228
|
+
"/deps/loupe",
|
|
229
|
+
"/deps/chai",
|
|
230
|
+
"/browser-playwright/dist/locators.js",
|
|
231
|
+
"/browser-webdriverio/dist/locators.js",
|
|
232
|
+
"/browser-preview/dist/locators.js",
|
|
233
|
+
/node:\w+/,
|
|
234
|
+
/__vitest_test__/,
|
|
235
|
+
/__vitest_browser__/,
|
|
236
|
+
/\/deps\/vitest_/
|
|
237
|
+
];
|
|
238
|
+
function extractLocation(urlLike) {
|
|
239
|
+
// Fail-fast but return locations like "(native)"
|
|
240
|
+
if (!urlLike.includes(":")) {
|
|
241
|
+
return [urlLike];
|
|
242
|
+
}
|
|
243
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
244
|
+
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
245
|
+
if (!parts) {
|
|
246
|
+
return [urlLike];
|
|
247
|
+
}
|
|
248
|
+
let url = parts[1];
|
|
249
|
+
if (url.startsWith("async ")) {
|
|
250
|
+
url = url.slice(6);
|
|
251
|
+
}
|
|
252
|
+
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
253
|
+
const urlObj = new URL(url);
|
|
254
|
+
urlObj.searchParams.delete("import");
|
|
255
|
+
urlObj.searchParams.delete("browserv");
|
|
256
|
+
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
257
|
+
}
|
|
258
|
+
if (url.startsWith("/@fs/")) {
|
|
259
|
+
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
260
|
+
url = url.slice(isWindows ? 5 : 4);
|
|
261
|
+
}
|
|
262
|
+
return [
|
|
263
|
+
url,
|
|
264
|
+
parts[2] || undefined,
|
|
265
|
+
parts[3] || undefined
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
function parseSingleFFOrSafariStack(raw) {
|
|
269
|
+
let line = raw.trim();
|
|
270
|
+
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
if (line.includes(" > eval")) {
|
|
274
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
275
|
+
}
|
|
276
|
+
// Early return for lines that don't look like Firefox/Safari stack traces
|
|
277
|
+
// Firefox/Safari stack traces must contain '@' and should have location info after it
|
|
278
|
+
if (!line.includes("@")) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
// Find the correct @ that separates function name from location
|
|
282
|
+
// For cases like '@https://@fs/path' or 'functionName@https://@fs/path'
|
|
283
|
+
// we need to find the first @ that precedes a valid location (containing :)
|
|
284
|
+
let atIndex = -1;
|
|
285
|
+
let locationPart = "";
|
|
286
|
+
let functionName;
|
|
287
|
+
// Try each @ from left to right to find the one that gives us a valid location
|
|
288
|
+
for (let i = 0; i < line.length; i++) {
|
|
289
|
+
if (line[i] === "@") {
|
|
290
|
+
const candidateLocation = line.slice(i + 1);
|
|
291
|
+
// Minimum length 3 for valid location: 1 for filename + 1 for colon + 1 for line number (e.g., "a:1")
|
|
292
|
+
if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
|
|
293
|
+
atIndex = i;
|
|
294
|
+
locationPart = candidateLocation;
|
|
295
|
+
functionName = i > 0 ? line.slice(0, i) : undefined;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Validate we found a valid location with minimum length (filename:line format)
|
|
301
|
+
if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
const [url, lineNumber, columnNumber] = extractLocation(locationPart);
|
|
305
|
+
if (!url || !lineNumber || !columnNumber) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
file: url,
|
|
310
|
+
method: functionName || "",
|
|
311
|
+
line: Number.parseInt(lineNumber),
|
|
312
|
+
column: Number.parseInt(columnNumber)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function parseSingleStack(raw) {
|
|
316
|
+
const line = raw.trim();
|
|
317
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
318
|
+
return parseSingleFFOrSafariStack(line);
|
|
319
|
+
}
|
|
320
|
+
return parseSingleV8Stack(line);
|
|
321
|
+
}
|
|
322
|
+
// Based on https://github.com/stacktracejs/error-stack-parser
|
|
323
|
+
// Credit to stacktracejs
|
|
324
|
+
function parseSingleV8Stack(raw) {
|
|
325
|
+
let line = raw.trim();
|
|
326
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
if (line.includes("(eval ")) {
|
|
330
|
+
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
331
|
+
}
|
|
332
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
333
|
+
// capture and preserve the parenthesized location "(/foo/my bar.js:12:87)" in
|
|
334
|
+
// case it has spaces in it, as the string is split on \s+ later on
|
|
335
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
336
|
+
// remove the parenthesized location from the line, if it was matched
|
|
337
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
338
|
+
// if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
|
|
339
|
+
// because this line doesn't have function name
|
|
340
|
+
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
341
|
+
let method = location && sanitizedLine || "";
|
|
342
|
+
let file = url && ["eval", "<anonymous>"].includes(url) ? undefined : url;
|
|
343
|
+
if (!file || !lineNumber || !columnNumber) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
if (method.startsWith("async ")) {
|
|
347
|
+
method = method.slice(6);
|
|
348
|
+
}
|
|
349
|
+
if (file.startsWith("file://")) {
|
|
350
|
+
file = file.slice(7);
|
|
351
|
+
}
|
|
352
|
+
// normalize Windows path (\ -> /)
|
|
353
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
354
|
+
if (method) {
|
|
355
|
+
method = method.replace(/__vite_ssr_import_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
method,
|
|
359
|
+
file,
|
|
360
|
+
line: Number.parseInt(lineNumber),
|
|
361
|
+
column: Number.parseInt(columnNumber)
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function createStackString(stacks) {
|
|
365
|
+
return stacks.map((stack) => {
|
|
366
|
+
const line = `${stack.file}:${stack.line}:${stack.column}`;
|
|
367
|
+
if (stack.method) {
|
|
368
|
+
return ` at ${stack.method}(${line})`;
|
|
369
|
+
}
|
|
370
|
+
return ` at ${line}`;
|
|
371
|
+
}).join("\n");
|
|
372
|
+
}
|
|
373
|
+
function parseStacktrace(stack, options = {}) {
|
|
374
|
+
const { ignoreStackEntries = stackIgnorePatterns } = options;
|
|
375
|
+
const stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
|
376
|
+
return stacks.map((stack) => {
|
|
377
|
+
var _options$getSourceMap;
|
|
378
|
+
if (options.getUrlId) {
|
|
379
|
+
stack.file = options.getUrlId(stack.file);
|
|
380
|
+
}
|
|
381
|
+
const map = (_options$getSourceMap = options.getSourceMap) === null || _options$getSourceMap === void 0 ? void 0 : _options$getSourceMap.call(options, stack.file);
|
|
382
|
+
if (!map || typeof map !== "object" || !map.version) {
|
|
383
|
+
return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
|
|
384
|
+
}
|
|
385
|
+
const traceMap = new DecodedMap(map, stack.file);
|
|
386
|
+
const position = getOriginalPosition(traceMap, stack);
|
|
387
|
+
if (!position) {
|
|
388
|
+
return stack;
|
|
389
|
+
}
|
|
390
|
+
const { line, column, source, name } = position;
|
|
391
|
+
let file = source || stack.file;
|
|
392
|
+
if (file.match(/\/\w:\//)) {
|
|
393
|
+
file = file.slice(1);
|
|
394
|
+
}
|
|
395
|
+
if (shouldFilter(ignoreStackEntries, file)) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
if (line != null && column != null) {
|
|
399
|
+
return {
|
|
400
|
+
line,
|
|
401
|
+
column,
|
|
402
|
+
file,
|
|
403
|
+
method: name || stack.method
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return stack;
|
|
407
|
+
}).filter((s) => s != null);
|
|
408
|
+
}
|
|
409
|
+
function shouldFilter(ignoreStackEntries, file) {
|
|
410
|
+
return ignoreStackEntries.some((p) => file.match(p));
|
|
411
|
+
}
|
|
412
|
+
function parseFFOrSafariStackTrace(stack) {
|
|
413
|
+
return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
|
|
414
|
+
}
|
|
415
|
+
function parseV8Stacktrace(stack) {
|
|
416
|
+
return stack.split("\n").map((line) => parseSingleV8Stack(line)).filter(notNullish);
|
|
417
|
+
}
|
|
418
|
+
function parseErrorStacktrace(e, options = {}) {
|
|
419
|
+
if (!e || isPrimitive(e)) {
|
|
420
|
+
return [];
|
|
421
|
+
}
|
|
422
|
+
if ("stacks" in e && e.stacks) {
|
|
423
|
+
return e.stacks;
|
|
424
|
+
}
|
|
425
|
+
const stackStr = e.stack || "";
|
|
426
|
+
// if "stack" property was overwritten at runtime to be something else,
|
|
427
|
+
// ignore the value because we don't know how to process it
|
|
428
|
+
let stackFrames = typeof stackStr === "string" ? parseStacktrace(stackStr, options) : [];
|
|
429
|
+
if (!stackFrames.length) {
|
|
430
|
+
const e_ = e;
|
|
431
|
+
if (e_.fileName != null && e_.lineNumber != null && e_.columnNumber != null) {
|
|
432
|
+
stackFrames = parseStacktrace(`${e_.fileName}:${e_.lineNumber}:${e_.columnNumber}`, options);
|
|
433
|
+
}
|
|
434
|
+
if (e_.sourceURL != null && e_.line != null && e_._column != null) {
|
|
435
|
+
stackFrames = parseStacktrace(`${e_.sourceURL}:${e_.line}:${e_.column}`, options);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (options.frameFilter) {
|
|
439
|
+
stackFrames = stackFrames.filter((f) => options.frameFilter(e, f) !== false);
|
|
440
|
+
}
|
|
441
|
+
e.stacks = stackFrames;
|
|
442
|
+
return stackFrames;
|
|
443
|
+
}
|
|
444
|
+
class DecodedMap {
|
|
445
|
+
_encoded;
|
|
446
|
+
_decoded;
|
|
447
|
+
_decodedMemo;
|
|
448
|
+
url;
|
|
449
|
+
version;
|
|
450
|
+
names = [];
|
|
451
|
+
resolvedSources;
|
|
452
|
+
constructor(map, from) {
|
|
453
|
+
this.map = map;
|
|
454
|
+
const { mappings, names, sources } = map;
|
|
455
|
+
this.version = map.version;
|
|
456
|
+
this.names = names || [];
|
|
457
|
+
this._encoded = mappings || "";
|
|
458
|
+
this._decodedMemo = memoizedState();
|
|
459
|
+
this.url = from;
|
|
460
|
+
this.resolvedSources = (sources || []).map((s) => resolve(s || "", from));
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function memoizedState() {
|
|
464
|
+
return {
|
|
465
|
+
lastKey: -1,
|
|
466
|
+
lastNeedle: -1,
|
|
467
|
+
lastIndex: -1
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function getOriginalPosition(map, needle) {
|
|
471
|
+
const result = originalPositionFor(map, needle);
|
|
472
|
+
if (result.column == null) {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export { DecodedMap, createStackString, stackIgnorePatterns as defaultStackIgnorePatterns, getOriginalPosition, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface SafeTimers {
|
|
2
|
+
nextTick?: (cb: () => void) => void;
|
|
3
|
+
setImmediate?: {
|
|
4
|
+
<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): any;
|
|
5
|
+
__promisify__: <T = void>(value?: T, options?: any) => Promise<T>;
|
|
6
|
+
};
|
|
7
|
+
clearImmediate?: (immediateId: any) => void;
|
|
8
|
+
setTimeout: typeof setTimeout;
|
|
9
|
+
setInterval: typeof setInterval;
|
|
10
|
+
clearInterval: typeof clearInterval;
|
|
11
|
+
clearTimeout: typeof clearTimeout;
|
|
12
|
+
queueMicrotask: typeof queueMicrotask;
|
|
13
|
+
}
|
|
14
|
+
declare function getSafeTimers(): SafeTimers;
|
|
15
|
+
declare function setSafeTimers(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a promise that resolves after the specified duration.
|
|
18
|
+
*
|
|
19
|
+
* @param timeout - Delay in milliseconds
|
|
20
|
+
* @param scheduler - Timer function to use, defaults to `setTimeout`. Useful for mocked timers.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* await delay(100)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // With mocked timers
|
|
27
|
+
* const { setTimeout } = getSafeTimers()
|
|
28
|
+
* await delay(100, setTimeout)
|
|
29
|
+
*/
|
|
30
|
+
declare function delay(timeout: number, scheduler?: typeof setTimeout): Promise<void>;
|
|
31
|
+
|
|
32
|
+
export { delay, getSafeTimers, setSafeTimers };
|
|
33
|
+
export type { SafeTimers };
|