@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,742 @@
|
|
|
1
|
+
import { plugins, format as format$1 } from '../pretty-format/index.js';
|
|
2
|
+
|
|
3
|
+
const ansiColors = {
|
|
4
|
+
bold: ['1', '22'],
|
|
5
|
+
dim: ['2', '22'],
|
|
6
|
+
italic: ['3', '23'],
|
|
7
|
+
underline: ['4', '24'],
|
|
8
|
+
// 5 & 6 are blinking
|
|
9
|
+
inverse: ['7', '27'],
|
|
10
|
+
hidden: ['8', '28'],
|
|
11
|
+
strike: ['9', '29'],
|
|
12
|
+
// 10-20 are fonts
|
|
13
|
+
// 21-29 are resets for 1-9
|
|
14
|
+
black: ['30', '39'],
|
|
15
|
+
red: ['31', '39'],
|
|
16
|
+
green: ['32', '39'],
|
|
17
|
+
yellow: ['33', '39'],
|
|
18
|
+
blue: ['34', '39'],
|
|
19
|
+
magenta: ['35', '39'],
|
|
20
|
+
cyan: ['36', '39'],
|
|
21
|
+
white: ['37', '39'],
|
|
22
|
+
brightblack: ['30;1', '39'],
|
|
23
|
+
brightred: ['31;1', '39'],
|
|
24
|
+
brightgreen: ['32;1', '39'],
|
|
25
|
+
brightyellow: ['33;1', '39'],
|
|
26
|
+
brightblue: ['34;1', '39'],
|
|
27
|
+
brightmagenta: ['35;1', '39'],
|
|
28
|
+
brightcyan: ['36;1', '39'],
|
|
29
|
+
brightwhite: ['37;1', '39'],
|
|
30
|
+
grey: ['90', '39'],
|
|
31
|
+
};
|
|
32
|
+
const styles = {
|
|
33
|
+
special: 'cyan',
|
|
34
|
+
number: 'yellow',
|
|
35
|
+
bigint: 'yellow',
|
|
36
|
+
boolean: 'yellow',
|
|
37
|
+
undefined: 'grey',
|
|
38
|
+
null: 'bold',
|
|
39
|
+
string: 'green',
|
|
40
|
+
symbol: 'green',
|
|
41
|
+
date: 'magenta',
|
|
42
|
+
regexp: 'red',
|
|
43
|
+
};
|
|
44
|
+
const truncator = '…';
|
|
45
|
+
function colorise(value, styleType) {
|
|
46
|
+
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || '';
|
|
47
|
+
if (!color) {
|
|
48
|
+
return String(value);
|
|
49
|
+
}
|
|
50
|
+
return `\u001b[${color[0]}m${String(value)}\u001b[${color[1]}m`;
|
|
51
|
+
}
|
|
52
|
+
function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [],
|
|
53
|
+
// eslint-disable-next-line no-shadow
|
|
54
|
+
truncate = Infinity, stylize = String, } = {}, inspect) {
|
|
55
|
+
const options = {
|
|
56
|
+
showHidden: Boolean(showHidden),
|
|
57
|
+
depth: Number(depth),
|
|
58
|
+
colors: Boolean(colors),
|
|
59
|
+
customInspect: Boolean(customInspect),
|
|
60
|
+
showProxy: Boolean(showProxy),
|
|
61
|
+
maxArrayLength: Number(maxArrayLength),
|
|
62
|
+
breakLength: Number(breakLength),
|
|
63
|
+
truncate: Number(truncate),
|
|
64
|
+
seen,
|
|
65
|
+
inspect,
|
|
66
|
+
stylize,
|
|
67
|
+
};
|
|
68
|
+
if (options.colors) {
|
|
69
|
+
options.stylize = colorise;
|
|
70
|
+
}
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
73
|
+
function isHighSurrogate(char) {
|
|
74
|
+
return char >= '\ud800' && char <= '\udbff';
|
|
75
|
+
}
|
|
76
|
+
function truncate(string, length, tail = truncator) {
|
|
77
|
+
string = String(string);
|
|
78
|
+
const tailLength = tail.length;
|
|
79
|
+
const stringLength = string.length;
|
|
80
|
+
if (tailLength > length && stringLength > tailLength) {
|
|
81
|
+
return tail;
|
|
82
|
+
}
|
|
83
|
+
if (stringLength > length && stringLength > tailLength) {
|
|
84
|
+
let end = length - tailLength;
|
|
85
|
+
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
|
86
|
+
end = end - 1;
|
|
87
|
+
}
|
|
88
|
+
return `${string.slice(0, end)}${tail}`;
|
|
89
|
+
}
|
|
90
|
+
return string;
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line complexity
|
|
93
|
+
function inspectList(list, options, inspectItem, separator = ', ') {
|
|
94
|
+
inspectItem = inspectItem || options.inspect;
|
|
95
|
+
const size = list.length;
|
|
96
|
+
if (size === 0)
|
|
97
|
+
return '';
|
|
98
|
+
const originalLength = options.truncate;
|
|
99
|
+
let output = '';
|
|
100
|
+
let peek = '';
|
|
101
|
+
let truncated = '';
|
|
102
|
+
for (let i = 0; i < size; i += 1) {
|
|
103
|
+
const last = i + 1 === list.length;
|
|
104
|
+
const secondToLast = i + 2 === list.length;
|
|
105
|
+
truncated = `${truncator}(${list.length - i})`;
|
|
106
|
+
const value = list[i];
|
|
107
|
+
// If there is more than one remaining we need to account for a separator of `, `
|
|
108
|
+
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
109
|
+
const string = peek || inspectItem(value, options) + (last ? '' : separator);
|
|
110
|
+
const nextLength = output.length + string.length;
|
|
111
|
+
const truncatedLength = nextLength + truncated.length;
|
|
112
|
+
// If this is the last element, and adding it would
|
|
113
|
+
// take us over length, but adding the truncator wouldn't - then break now
|
|
114
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
// If this isn't the last or second to last element to scan,
|
|
118
|
+
// but the string is already over length then break here
|
|
119
|
+
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
// Peek at the next string to determine if we should
|
|
123
|
+
// break early before adding this item to the output
|
|
124
|
+
peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator);
|
|
125
|
+
// If we have one element left, but this element and
|
|
126
|
+
// the next takes over length, the break early
|
|
127
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
output += string;
|
|
131
|
+
// If the next element takes us to length -
|
|
132
|
+
// but there are more after that, then we should truncate now
|
|
133
|
+
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
134
|
+
truncated = `${truncator}(${list.length - i - 1})`;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
truncated = '';
|
|
138
|
+
}
|
|
139
|
+
return `${output}${truncated}`;
|
|
140
|
+
}
|
|
141
|
+
function quoteComplexKey(key) {
|
|
142
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
143
|
+
return key;
|
|
144
|
+
}
|
|
145
|
+
return JSON.stringify(key)
|
|
146
|
+
.replace(/'/g, "\\'")
|
|
147
|
+
.replace(/\\"/g, '"')
|
|
148
|
+
.replace(/(^"|"$)/g, "'");
|
|
149
|
+
}
|
|
150
|
+
function inspectProperty([key, value], options) {
|
|
151
|
+
options.truncate -= 2;
|
|
152
|
+
if (typeof key === 'string') {
|
|
153
|
+
key = quoteComplexKey(key);
|
|
154
|
+
}
|
|
155
|
+
else if (typeof key !== 'number') {
|
|
156
|
+
key = `[${options.inspect(key, options)}]`;
|
|
157
|
+
}
|
|
158
|
+
options.truncate -= key.length;
|
|
159
|
+
value = options.inspect(value, options);
|
|
160
|
+
return `${key}: ${value}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function inspectArray(array, options) {
|
|
164
|
+
// Object.keys will always output the Array indices first, so we can slice by
|
|
165
|
+
// `array.length` to get non-index properties
|
|
166
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
167
|
+
if (!array.length && !nonIndexProperties.length)
|
|
168
|
+
return '[]';
|
|
169
|
+
options.truncate -= 4;
|
|
170
|
+
const listContents = inspectList(array, options);
|
|
171
|
+
options.truncate -= listContents.length;
|
|
172
|
+
let propertyContents = '';
|
|
173
|
+
if (nonIndexProperties.length) {
|
|
174
|
+
propertyContents = inspectList(nonIndexProperties.map(key => [key, array[key]]), options, inspectProperty);
|
|
175
|
+
}
|
|
176
|
+
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ''} ]`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const getArrayName = (array) => {
|
|
180
|
+
// We need to special case Node.js' Buffers, which report to be Uint8Array
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
if (typeof Buffer === 'function' && array instanceof Buffer) {
|
|
183
|
+
return 'Buffer';
|
|
184
|
+
}
|
|
185
|
+
if (array[Symbol.toStringTag]) {
|
|
186
|
+
return array[Symbol.toStringTag];
|
|
187
|
+
}
|
|
188
|
+
return array.constructor.name;
|
|
189
|
+
};
|
|
190
|
+
function inspectTypedArray(array, options) {
|
|
191
|
+
const name = getArrayName(array);
|
|
192
|
+
options.truncate -= name.length + 4;
|
|
193
|
+
// Object.keys will always output the Array indices first, so we can slice by
|
|
194
|
+
// `array.length` to get non-index properties
|
|
195
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
196
|
+
if (!array.length && !nonIndexProperties.length)
|
|
197
|
+
return `${name}[]`;
|
|
198
|
+
// As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply
|
|
199
|
+
// stylise the toString() value of them
|
|
200
|
+
let output = '';
|
|
201
|
+
for (let i = 0; i < array.length; i++) {
|
|
202
|
+
const string = `${options.stylize(truncate(array[i], options.truncate), 'number')}${i === array.length - 1 ? '' : ', '}`;
|
|
203
|
+
options.truncate -= string.length;
|
|
204
|
+
if (array[i] !== array.length && options.truncate <= 3) {
|
|
205
|
+
output += `${truncator}(${array.length - array[i] + 1})`;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
output += string;
|
|
209
|
+
}
|
|
210
|
+
let propertyContents = '';
|
|
211
|
+
if (nonIndexProperties.length) {
|
|
212
|
+
propertyContents = inspectList(nonIndexProperties.map(key => [key, array[key]]), options, inspectProperty);
|
|
213
|
+
}
|
|
214
|
+
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ''} ]`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function inspectDate(dateObject, options) {
|
|
218
|
+
const stringRepresentation = dateObject.toJSON();
|
|
219
|
+
if (stringRepresentation === null) {
|
|
220
|
+
return 'Invalid Date';
|
|
221
|
+
}
|
|
222
|
+
const split = stringRepresentation.split('T');
|
|
223
|
+
const date = split[0];
|
|
224
|
+
// If we need to - truncate the time portion, but never the date
|
|
225
|
+
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, 'date');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function inspectFunction(func, options) {
|
|
229
|
+
const functionType = func[Symbol.toStringTag] || 'Function';
|
|
230
|
+
const name = func.name;
|
|
231
|
+
if (!name) {
|
|
232
|
+
return options.stylize(`[${functionType}]`, 'special');
|
|
233
|
+
}
|
|
234
|
+
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, 'special');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function inspectMapEntry([key, value], options) {
|
|
238
|
+
options.truncate -= 4;
|
|
239
|
+
key = options.inspect(key, options);
|
|
240
|
+
options.truncate -= key.length;
|
|
241
|
+
value = options.inspect(value, options);
|
|
242
|
+
return `${key} => ${value}`;
|
|
243
|
+
}
|
|
244
|
+
// IE11 doesn't support `map.entries()`
|
|
245
|
+
function mapToEntries(map) {
|
|
246
|
+
const entries = [];
|
|
247
|
+
map.forEach((value, key) => {
|
|
248
|
+
entries.push([key, value]);
|
|
249
|
+
});
|
|
250
|
+
return entries;
|
|
251
|
+
}
|
|
252
|
+
function inspectMap(map, options) {
|
|
253
|
+
if (map.size === 0)
|
|
254
|
+
return 'Map{}';
|
|
255
|
+
options.truncate -= 7;
|
|
256
|
+
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const isNaN = Number.isNaN || (i => i !== i); // eslint-disable-line no-self-compare
|
|
260
|
+
function inspectNumber(number, options) {
|
|
261
|
+
if (isNaN(number)) {
|
|
262
|
+
return options.stylize('NaN', 'number');
|
|
263
|
+
}
|
|
264
|
+
if (number === Infinity) {
|
|
265
|
+
return options.stylize('Infinity', 'number');
|
|
266
|
+
}
|
|
267
|
+
if (number === -Infinity) {
|
|
268
|
+
return options.stylize('-Infinity', 'number');
|
|
269
|
+
}
|
|
270
|
+
if (number === 0) {
|
|
271
|
+
return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number');
|
|
272
|
+
}
|
|
273
|
+
return options.stylize(truncate(String(number), options.truncate), 'number');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function inspectBigInt(number, options) {
|
|
277
|
+
let nums = truncate(number.toString(), options.truncate - 1);
|
|
278
|
+
if (nums !== truncator)
|
|
279
|
+
nums += 'n';
|
|
280
|
+
return options.stylize(nums, 'bigint');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function inspectRegExp(value, options) {
|
|
284
|
+
const flags = value.toString().split('/')[2];
|
|
285
|
+
const sourceLength = options.truncate - (2 + flags.length);
|
|
286
|
+
const source = value.source;
|
|
287
|
+
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, 'regexp');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// IE11 doesn't support `Array.from(set)`
|
|
291
|
+
function arrayFromSet(set) {
|
|
292
|
+
const values = [];
|
|
293
|
+
set.forEach(value => {
|
|
294
|
+
values.push(value);
|
|
295
|
+
});
|
|
296
|
+
return values;
|
|
297
|
+
}
|
|
298
|
+
function inspectSet(set, options) {
|
|
299
|
+
if (set.size === 0)
|
|
300
|
+
return 'Set{}';
|
|
301
|
+
options.truncate -= 7;
|
|
302
|
+
return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" +
|
|
306
|
+
'\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]', 'g');
|
|
307
|
+
const escapeCharacters = {
|
|
308
|
+
'\b': '\\b',
|
|
309
|
+
'\t': '\\t',
|
|
310
|
+
'\n': '\\n',
|
|
311
|
+
'\f': '\\f',
|
|
312
|
+
'\r': '\\r',
|
|
313
|
+
"'": "\\'",
|
|
314
|
+
'\\': '\\\\',
|
|
315
|
+
};
|
|
316
|
+
const hex = 16;
|
|
317
|
+
function escape(char) {
|
|
318
|
+
return (escapeCharacters[char] ||
|
|
319
|
+
`\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`);
|
|
320
|
+
}
|
|
321
|
+
function inspectString(string, options) {
|
|
322
|
+
if (stringEscapeChars.test(string)) {
|
|
323
|
+
string = string.replace(stringEscapeChars, escape);
|
|
324
|
+
}
|
|
325
|
+
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, 'string');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function inspectSymbol(value) {
|
|
329
|
+
if ('description' in Symbol.prototype) {
|
|
330
|
+
return value.description ? `Symbol(${value.description})` : 'Symbol()';
|
|
331
|
+
}
|
|
332
|
+
return value.toString();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const getPromiseValue = () => 'Promise{…}';
|
|
336
|
+
|
|
337
|
+
function inspectObject$1(object, options) {
|
|
338
|
+
const properties = Object.getOwnPropertyNames(object);
|
|
339
|
+
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
340
|
+
if (properties.length === 0 && symbols.length === 0) {
|
|
341
|
+
return '{}';
|
|
342
|
+
}
|
|
343
|
+
options.truncate -= 4;
|
|
344
|
+
options.seen = options.seen || [];
|
|
345
|
+
if (options.seen.includes(object)) {
|
|
346
|
+
return '[Circular]';
|
|
347
|
+
}
|
|
348
|
+
options.seen.push(object);
|
|
349
|
+
const propertyContents = inspectList(properties.map(key => [key, object[key]]), options, inspectProperty);
|
|
350
|
+
const symbolContents = inspectList(symbols.map(key => [key, object[key]]), options, inspectProperty);
|
|
351
|
+
options.seen.pop();
|
|
352
|
+
let sep = '';
|
|
353
|
+
if (propertyContents && symbolContents) {
|
|
354
|
+
sep = ', ';
|
|
355
|
+
}
|
|
356
|
+
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
360
|
+
function inspectClass(value, options) {
|
|
361
|
+
let name = '';
|
|
362
|
+
if (toStringTag && toStringTag in value) {
|
|
363
|
+
name = value[toStringTag];
|
|
364
|
+
}
|
|
365
|
+
name = name || value.constructor.name;
|
|
366
|
+
// Babel transforms anonymous classes to the name `_class`
|
|
367
|
+
if (!name || name === '_class') {
|
|
368
|
+
name = '<Anonymous Class>';
|
|
369
|
+
}
|
|
370
|
+
options.truncate -= name.length;
|
|
371
|
+
return `${name}${inspectObject$1(value, options)}`;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function inspectArguments(args, options) {
|
|
375
|
+
if (args.length === 0)
|
|
376
|
+
return 'Arguments[]';
|
|
377
|
+
options.truncate -= 13;
|
|
378
|
+
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const errorKeys = [
|
|
382
|
+
'stack',
|
|
383
|
+
'line',
|
|
384
|
+
'column',
|
|
385
|
+
'name',
|
|
386
|
+
'message',
|
|
387
|
+
'fileName',
|
|
388
|
+
'lineNumber',
|
|
389
|
+
'columnNumber',
|
|
390
|
+
'number',
|
|
391
|
+
'description',
|
|
392
|
+
'cause',
|
|
393
|
+
];
|
|
394
|
+
function inspectObject(error, options) {
|
|
395
|
+
const properties = Object.getOwnPropertyNames(error).filter(key => errorKeys.indexOf(key) === -1);
|
|
396
|
+
const name = error.name;
|
|
397
|
+
options.truncate -= name.length;
|
|
398
|
+
let message = '';
|
|
399
|
+
if (typeof error.message === 'string') {
|
|
400
|
+
message = truncate(error.message, options.truncate);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
properties.unshift('message');
|
|
404
|
+
}
|
|
405
|
+
message = message ? `: ${message}` : '';
|
|
406
|
+
options.truncate -= message.length + 5;
|
|
407
|
+
options.seen = options.seen || [];
|
|
408
|
+
if (options.seen.includes(error)) {
|
|
409
|
+
return '[Circular]';
|
|
410
|
+
}
|
|
411
|
+
options.seen.push(error);
|
|
412
|
+
const propertyContents = inspectList(properties.map(key => [key, error[key]]), options, inspectProperty);
|
|
413
|
+
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ''}`;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function inspectAttribute([key, value], options) {
|
|
417
|
+
options.truncate -= 3;
|
|
418
|
+
if (!value) {
|
|
419
|
+
return `${options.stylize(String(key), 'yellow')}`;
|
|
420
|
+
}
|
|
421
|
+
return `${options.stylize(String(key), 'yellow')}=${options.stylize(`"${value}"`, 'string')}`;
|
|
422
|
+
}
|
|
423
|
+
function inspectNodeCollection(collection, options) {
|
|
424
|
+
return inspectList(collection, options, inspectNode, '\n');
|
|
425
|
+
}
|
|
426
|
+
function inspectNode(node, options) {
|
|
427
|
+
switch (node.nodeType) {
|
|
428
|
+
case 1:
|
|
429
|
+
return inspectHTML(node, options);
|
|
430
|
+
case 3:
|
|
431
|
+
return options.inspect(node.data, options);
|
|
432
|
+
default:
|
|
433
|
+
return options.inspect(node, options);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// @ts-ignore (Deno doesn't have Element)
|
|
437
|
+
function inspectHTML(element, options) {
|
|
438
|
+
const properties = element.getAttributeNames();
|
|
439
|
+
const name = element.tagName.toLowerCase();
|
|
440
|
+
const head = options.stylize(`<${name}`, 'special');
|
|
441
|
+
const headClose = options.stylize(`>`, 'special');
|
|
442
|
+
const tail = options.stylize(`</${name}>`, 'special');
|
|
443
|
+
options.truncate -= name.length * 2 + 5;
|
|
444
|
+
let propertyContents = '';
|
|
445
|
+
if (properties.length > 0) {
|
|
446
|
+
propertyContents += ' ';
|
|
447
|
+
propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, ' ');
|
|
448
|
+
}
|
|
449
|
+
options.truncate -= propertyContents.length;
|
|
450
|
+
const truncate = options.truncate;
|
|
451
|
+
let children = inspectNodeCollection(element.children, options);
|
|
452
|
+
if (children && children.length > truncate) {
|
|
453
|
+
children = `${truncator}(${element.children.length})`;
|
|
454
|
+
}
|
|
455
|
+
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* !
|
|
459
|
+
* loupe
|
|
460
|
+
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
461
|
+
* MIT Licensed
|
|
462
|
+
*/
|
|
463
|
+
const symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function';
|
|
464
|
+
const chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect';
|
|
465
|
+
const nodeInspect = Symbol.for('nodejs.util.inspect.custom');
|
|
466
|
+
const constructorMap = new WeakMap();
|
|
467
|
+
const stringTagMap = {};
|
|
468
|
+
const baseTypesMap = {
|
|
469
|
+
undefined: (value, options) => options.stylize('undefined', 'undefined'),
|
|
470
|
+
null: (value, options) => options.stylize('null', 'null'),
|
|
471
|
+
boolean: (value, options) => options.stylize(String(value), 'boolean'),
|
|
472
|
+
Boolean: (value, options) => options.stylize(String(value), 'boolean'),
|
|
473
|
+
number: inspectNumber,
|
|
474
|
+
Number: inspectNumber,
|
|
475
|
+
bigint: inspectBigInt,
|
|
476
|
+
BigInt: inspectBigInt,
|
|
477
|
+
string: inspectString,
|
|
478
|
+
String: inspectString,
|
|
479
|
+
function: inspectFunction,
|
|
480
|
+
Function: inspectFunction,
|
|
481
|
+
symbol: inspectSymbol,
|
|
482
|
+
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
|
483
|
+
Symbol: inspectSymbol,
|
|
484
|
+
Array: inspectArray,
|
|
485
|
+
Date: inspectDate,
|
|
486
|
+
Map: inspectMap,
|
|
487
|
+
Set: inspectSet,
|
|
488
|
+
RegExp: inspectRegExp,
|
|
489
|
+
Promise: getPromiseValue,
|
|
490
|
+
// WeakSet, WeakMap are totally opaque to us
|
|
491
|
+
WeakSet: (value, options) => options.stylize('WeakSet{…}', 'special'),
|
|
492
|
+
WeakMap: (value, options) => options.stylize('WeakMap{…}', 'special'),
|
|
493
|
+
Arguments: inspectArguments,
|
|
494
|
+
Int8Array: inspectTypedArray,
|
|
495
|
+
Uint8Array: inspectTypedArray,
|
|
496
|
+
Uint8ClampedArray: inspectTypedArray,
|
|
497
|
+
Int16Array: inspectTypedArray,
|
|
498
|
+
Uint16Array: inspectTypedArray,
|
|
499
|
+
Int32Array: inspectTypedArray,
|
|
500
|
+
Uint32Array: inspectTypedArray,
|
|
501
|
+
Float32Array: inspectTypedArray,
|
|
502
|
+
Float64Array: inspectTypedArray,
|
|
503
|
+
Generator: () => '',
|
|
504
|
+
DataView: () => '',
|
|
505
|
+
ArrayBuffer: () => '',
|
|
506
|
+
Error: inspectObject,
|
|
507
|
+
HTMLCollection: inspectNodeCollection,
|
|
508
|
+
NodeList: inspectNodeCollection,
|
|
509
|
+
};
|
|
510
|
+
// eslint-disable-next-line complexity
|
|
511
|
+
const inspectCustom = (value, options, type, inspectFn) => {
|
|
512
|
+
if (chaiInspect in value && typeof value[chaiInspect] === 'function') {
|
|
513
|
+
return value[chaiInspect](options);
|
|
514
|
+
}
|
|
515
|
+
if (nodeInspect in value && typeof value[nodeInspect] === 'function') {
|
|
516
|
+
return value[nodeInspect](options.depth, options, inspectFn);
|
|
517
|
+
}
|
|
518
|
+
if ('inspect' in value && typeof value.inspect === 'function') {
|
|
519
|
+
return value.inspect(options.depth, options);
|
|
520
|
+
}
|
|
521
|
+
if ('constructor' in value && constructorMap.has(value.constructor)) {
|
|
522
|
+
return constructorMap.get(value.constructor)(value, options);
|
|
523
|
+
}
|
|
524
|
+
if (stringTagMap[type]) {
|
|
525
|
+
return stringTagMap[type](value, options);
|
|
526
|
+
}
|
|
527
|
+
return '';
|
|
528
|
+
};
|
|
529
|
+
const toString = Object.prototype.toString;
|
|
530
|
+
// eslint-disable-next-line complexity
|
|
531
|
+
function inspect$1(value, opts = {}) {
|
|
532
|
+
const options = normaliseOptions(opts, inspect$1);
|
|
533
|
+
const { customInspect } = options;
|
|
534
|
+
let type = value === null ? 'null' : typeof value;
|
|
535
|
+
if (type === 'object') {
|
|
536
|
+
type = toString.call(value).slice(8, -1);
|
|
537
|
+
}
|
|
538
|
+
// If it is a base value that we already support, then use Loupe's inspector
|
|
539
|
+
if (type in baseTypesMap) {
|
|
540
|
+
return baseTypesMap[type](value, options);
|
|
541
|
+
}
|
|
542
|
+
// If `options.customInspect` is set to true then try to use the custom inspector
|
|
543
|
+
if (customInspect && value) {
|
|
544
|
+
const output = inspectCustom(value, options, type, inspect$1);
|
|
545
|
+
if (output) {
|
|
546
|
+
if (typeof output === 'string')
|
|
547
|
+
return output;
|
|
548
|
+
return inspect$1(output, options);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
552
|
+
// If it's a plain Object then use Loupe's inspector
|
|
553
|
+
if (proto === Object.prototype || proto === null) {
|
|
554
|
+
return inspectObject$1(value, options);
|
|
555
|
+
}
|
|
556
|
+
// Specifically account for HTMLElements
|
|
557
|
+
// @ts-ignore
|
|
558
|
+
if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) {
|
|
559
|
+
return inspectHTML(value, options);
|
|
560
|
+
}
|
|
561
|
+
if ('constructor' in value) {
|
|
562
|
+
// If it is a class, inspect it like an object but add the constructor name
|
|
563
|
+
if (value.constructor !== Object) {
|
|
564
|
+
return inspectClass(value, options);
|
|
565
|
+
}
|
|
566
|
+
// If it is an object with an anonymous prototype, display it as an object.
|
|
567
|
+
return inspectObject$1(value, options);
|
|
568
|
+
}
|
|
569
|
+
// last chance to check if it's an object
|
|
570
|
+
if (value === Object(value)) {
|
|
571
|
+
return inspectObject$1(value, options);
|
|
572
|
+
}
|
|
573
|
+
// We have run out of options! Just stringify the value
|
|
574
|
+
return options.stylize(String(value), type);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
578
|
+
const PLUGINS = [
|
|
579
|
+
ReactTestComponent,
|
|
580
|
+
ReactElement,
|
|
581
|
+
DOMElement,
|
|
582
|
+
DOMCollection,
|
|
583
|
+
Immutable,
|
|
584
|
+
AsymmetricMatcher
|
|
585
|
+
];
|
|
586
|
+
function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
|
|
587
|
+
const MAX_LENGTH = maxLength ?? 1e4;
|
|
588
|
+
let result;
|
|
589
|
+
try {
|
|
590
|
+
result = format$1(object, {
|
|
591
|
+
maxDepth,
|
|
592
|
+
escapeString: false,
|
|
593
|
+
plugins: PLUGINS,
|
|
594
|
+
...options
|
|
595
|
+
});
|
|
596
|
+
} catch {
|
|
597
|
+
result = format$1(object, {
|
|
598
|
+
callToJSON: false,
|
|
599
|
+
maxDepth,
|
|
600
|
+
escapeString: false,
|
|
601
|
+
plugins: PLUGINS,
|
|
602
|
+
...options
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
// Prevents infinite loop https://github.com/vitest-dev/vitest/issues/7249
|
|
606
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
|
|
607
|
+
maxLength,
|
|
608
|
+
...options
|
|
609
|
+
}) : result;
|
|
610
|
+
}
|
|
611
|
+
const formatRegExp = /%[sdjifoOc%]/g;
|
|
612
|
+
function baseFormat(args, options = {}) {
|
|
613
|
+
const formatArg = (item, inspecOptions) => {
|
|
614
|
+
if (options.prettifyObject) {
|
|
615
|
+
return stringify(item, undefined, {
|
|
616
|
+
printBasicPrototype: false,
|
|
617
|
+
escapeString: false
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return inspect(item, inspecOptions);
|
|
621
|
+
};
|
|
622
|
+
if (typeof args[0] !== "string") {
|
|
623
|
+
const objects = [];
|
|
624
|
+
for (let i = 0; i < args.length; i++) {
|
|
625
|
+
objects.push(formatArg(args[i], {
|
|
626
|
+
depth: 0,
|
|
627
|
+
colors: false
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
630
|
+
return objects.join(" ");
|
|
631
|
+
}
|
|
632
|
+
const len = args.length;
|
|
633
|
+
let i = 1;
|
|
634
|
+
const template = args[0];
|
|
635
|
+
let str = String(template).replace(formatRegExp, (x) => {
|
|
636
|
+
if (x === "%%") {
|
|
637
|
+
return "%";
|
|
638
|
+
}
|
|
639
|
+
if (i >= len) {
|
|
640
|
+
return x;
|
|
641
|
+
}
|
|
642
|
+
switch (x) {
|
|
643
|
+
case "%s": {
|
|
644
|
+
const value = args[i++];
|
|
645
|
+
if (typeof value === "bigint") {
|
|
646
|
+
return `${value.toString()}n`;
|
|
647
|
+
}
|
|
648
|
+
if (typeof value === "number" && value === 0 && 1 / value < 0) {
|
|
649
|
+
return "-0";
|
|
650
|
+
}
|
|
651
|
+
if (typeof value === "object" && value !== null) {
|
|
652
|
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
653
|
+
return value.toString();
|
|
654
|
+
}
|
|
655
|
+
return formatArg(value, {
|
|
656
|
+
depth: 0,
|
|
657
|
+
colors: false
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return String(value);
|
|
661
|
+
}
|
|
662
|
+
case "%d": {
|
|
663
|
+
const value = args[i++];
|
|
664
|
+
if (typeof value === "bigint") {
|
|
665
|
+
return `${value.toString()}n`;
|
|
666
|
+
}
|
|
667
|
+
return Number(value).toString();
|
|
668
|
+
}
|
|
669
|
+
case "%i": {
|
|
670
|
+
const value = args[i++];
|
|
671
|
+
if (typeof value === "bigint") {
|
|
672
|
+
return `${value.toString()}n`;
|
|
673
|
+
}
|
|
674
|
+
return Number.parseInt(String(value)).toString();
|
|
675
|
+
}
|
|
676
|
+
case "%f": return Number.parseFloat(String(args[i++])).toString();
|
|
677
|
+
case "%o": return formatArg(args[i++], {
|
|
678
|
+
showHidden: true,
|
|
679
|
+
showProxy: true
|
|
680
|
+
});
|
|
681
|
+
case "%O": return formatArg(args[i++]);
|
|
682
|
+
case "%c": {
|
|
683
|
+
i++;
|
|
684
|
+
return "";
|
|
685
|
+
}
|
|
686
|
+
case "%j": try {
|
|
687
|
+
return JSON.stringify(args[i++]);
|
|
688
|
+
} catch (err) {
|
|
689
|
+
const m = err.message;
|
|
690
|
+
if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) {
|
|
691
|
+
return "[Circular]";
|
|
692
|
+
}
|
|
693
|
+
throw err;
|
|
694
|
+
}
|
|
695
|
+
default: return x;
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
for (let x = args[i]; i < len; x = args[++i]) {
|
|
699
|
+
if (x === null || typeof x !== "object") {
|
|
700
|
+
str += ` ${x}`;
|
|
701
|
+
} else {
|
|
702
|
+
str += ` ${formatArg(x)}`;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return str;
|
|
706
|
+
}
|
|
707
|
+
function format(...args) {
|
|
708
|
+
return baseFormat(args);
|
|
709
|
+
}
|
|
710
|
+
function browserFormat(...args) {
|
|
711
|
+
return baseFormat(args, { prettifyObject: true });
|
|
712
|
+
}
|
|
713
|
+
function inspect(obj, options = {}) {
|
|
714
|
+
if (options.truncate === 0) {
|
|
715
|
+
options.truncate = Number.POSITIVE_INFINITY;
|
|
716
|
+
}
|
|
717
|
+
return inspect$1(obj, options);
|
|
718
|
+
}
|
|
719
|
+
function objDisplay(obj, options = {}) {
|
|
720
|
+
if (typeof options.truncate === "undefined") {
|
|
721
|
+
options.truncate = 40;
|
|
722
|
+
}
|
|
723
|
+
const str = inspect(obj, options);
|
|
724
|
+
const type = Object.prototype.toString.call(obj);
|
|
725
|
+
if (options.truncate && str.length >= options.truncate) {
|
|
726
|
+
if (type === "[object Function]") {
|
|
727
|
+
const fn = obj;
|
|
728
|
+
return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
|
|
729
|
+
} else if (type === "[object Array]") {
|
|
730
|
+
return `[ Array(${obj.length}) ]`;
|
|
731
|
+
} else if (type === "[object Object]") {
|
|
732
|
+
const keys = Object.keys(obj);
|
|
733
|
+
const kstr = keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ");
|
|
734
|
+
return `{ Object (${kstr}) }`;
|
|
735
|
+
} else {
|
|
736
|
+
return str;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return str;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export { browserFormat, format, formatRegExp, inspect, objDisplay, stringify };
|