@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,727 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
import { Console } from 'node:console';
|
|
3
|
+
|
|
4
|
+
// SEE https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/interfaces.js
|
|
5
|
+
const LIVING_KEYS = [
|
|
6
|
+
"DOMException",
|
|
7
|
+
"EventTarget",
|
|
8
|
+
"NamedNodeMap",
|
|
9
|
+
"Node",
|
|
10
|
+
"Attr",
|
|
11
|
+
"Element",
|
|
12
|
+
"DocumentFragment",
|
|
13
|
+
"DOMImplementation",
|
|
14
|
+
"Document",
|
|
15
|
+
"XMLDocument",
|
|
16
|
+
"CharacterData",
|
|
17
|
+
"Text",
|
|
18
|
+
"CDATASection",
|
|
19
|
+
"ProcessingInstruction",
|
|
20
|
+
"Comment",
|
|
21
|
+
"DocumentType",
|
|
22
|
+
"NodeList",
|
|
23
|
+
"RadioNodeList",
|
|
24
|
+
"HTMLCollection",
|
|
25
|
+
"HTMLOptionsCollection",
|
|
26
|
+
"DOMStringMap",
|
|
27
|
+
"DOMTokenList",
|
|
28
|
+
"StyleSheetList",
|
|
29
|
+
"HTMLElement",
|
|
30
|
+
"HTMLHeadElement",
|
|
31
|
+
"HTMLTitleElement",
|
|
32
|
+
"HTMLBaseElement",
|
|
33
|
+
"HTMLLinkElement",
|
|
34
|
+
"HTMLMetaElement",
|
|
35
|
+
"HTMLStyleElement",
|
|
36
|
+
"HTMLBodyElement",
|
|
37
|
+
"HTMLHeadingElement",
|
|
38
|
+
"HTMLParagraphElement",
|
|
39
|
+
"HTMLHRElement",
|
|
40
|
+
"HTMLPreElement",
|
|
41
|
+
"HTMLUListElement",
|
|
42
|
+
"HTMLOListElement",
|
|
43
|
+
"HTMLLIElement",
|
|
44
|
+
"HTMLMenuElement",
|
|
45
|
+
"HTMLDListElement",
|
|
46
|
+
"HTMLDivElement",
|
|
47
|
+
"HTMLAnchorElement",
|
|
48
|
+
"HTMLAreaElement",
|
|
49
|
+
"HTMLBRElement",
|
|
50
|
+
"HTMLButtonElement",
|
|
51
|
+
"HTMLCanvasElement",
|
|
52
|
+
"HTMLDataElement",
|
|
53
|
+
"HTMLDataListElement",
|
|
54
|
+
"HTMLDetailsElement",
|
|
55
|
+
"HTMLDialogElement",
|
|
56
|
+
"HTMLDirectoryElement",
|
|
57
|
+
"HTMLFieldSetElement",
|
|
58
|
+
"HTMLFontElement",
|
|
59
|
+
"HTMLFormElement",
|
|
60
|
+
"HTMLHtmlElement",
|
|
61
|
+
"HTMLImageElement",
|
|
62
|
+
"HTMLInputElement",
|
|
63
|
+
"HTMLLabelElement",
|
|
64
|
+
"HTMLLegendElement",
|
|
65
|
+
"HTMLMapElement",
|
|
66
|
+
"HTMLMarqueeElement",
|
|
67
|
+
"HTMLMediaElement",
|
|
68
|
+
"HTMLMeterElement",
|
|
69
|
+
"HTMLModElement",
|
|
70
|
+
"HTMLOptGroupElement",
|
|
71
|
+
"HTMLOptionElement",
|
|
72
|
+
"HTMLOutputElement",
|
|
73
|
+
"HTMLPictureElement",
|
|
74
|
+
"HTMLProgressElement",
|
|
75
|
+
"HTMLQuoteElement",
|
|
76
|
+
"HTMLScriptElement",
|
|
77
|
+
"HTMLSelectElement",
|
|
78
|
+
"HTMLSlotElement",
|
|
79
|
+
"HTMLSourceElement",
|
|
80
|
+
"HTMLSpanElement",
|
|
81
|
+
"HTMLTableCaptionElement",
|
|
82
|
+
"HTMLTableCellElement",
|
|
83
|
+
"HTMLTableColElement",
|
|
84
|
+
"HTMLTableElement",
|
|
85
|
+
"HTMLTimeElement",
|
|
86
|
+
"HTMLTableRowElement",
|
|
87
|
+
"HTMLTableSectionElement",
|
|
88
|
+
"HTMLTemplateElement",
|
|
89
|
+
"HTMLTextAreaElement",
|
|
90
|
+
"HTMLUnknownElement",
|
|
91
|
+
"HTMLFrameElement",
|
|
92
|
+
"HTMLFrameSetElement",
|
|
93
|
+
"HTMLIFrameElement",
|
|
94
|
+
"HTMLEmbedElement",
|
|
95
|
+
"HTMLObjectElement",
|
|
96
|
+
"HTMLParamElement",
|
|
97
|
+
"HTMLVideoElement",
|
|
98
|
+
"HTMLAudioElement",
|
|
99
|
+
"HTMLTrackElement",
|
|
100
|
+
"HTMLFormControlsCollection",
|
|
101
|
+
"SVGElement",
|
|
102
|
+
"SVGGraphicsElement",
|
|
103
|
+
"SVGSVGElement",
|
|
104
|
+
"SVGTitleElement",
|
|
105
|
+
"SVGAnimatedString",
|
|
106
|
+
"SVGNumber",
|
|
107
|
+
"SVGStringList",
|
|
108
|
+
"Event",
|
|
109
|
+
"CloseEvent",
|
|
110
|
+
"CustomEvent",
|
|
111
|
+
"MessageEvent",
|
|
112
|
+
"ErrorEvent",
|
|
113
|
+
"HashChangeEvent",
|
|
114
|
+
"PopStateEvent",
|
|
115
|
+
"StorageEvent",
|
|
116
|
+
"ProgressEvent",
|
|
117
|
+
"PageTransitionEvent",
|
|
118
|
+
"SubmitEvent",
|
|
119
|
+
"UIEvent",
|
|
120
|
+
"FocusEvent",
|
|
121
|
+
"InputEvent",
|
|
122
|
+
"MouseEvent",
|
|
123
|
+
"KeyboardEvent",
|
|
124
|
+
"TouchEvent",
|
|
125
|
+
"CompositionEvent",
|
|
126
|
+
"WheelEvent",
|
|
127
|
+
"BarProp",
|
|
128
|
+
"External",
|
|
129
|
+
"Location",
|
|
130
|
+
"History",
|
|
131
|
+
"Screen",
|
|
132
|
+
"Crypto",
|
|
133
|
+
"Performance",
|
|
134
|
+
"Navigator",
|
|
135
|
+
"PluginArray",
|
|
136
|
+
"MimeTypeArray",
|
|
137
|
+
"Plugin",
|
|
138
|
+
"MimeType",
|
|
139
|
+
"FileReader",
|
|
140
|
+
"FormData",
|
|
141
|
+
"Blob",
|
|
142
|
+
"File",
|
|
143
|
+
"FileList",
|
|
144
|
+
"ValidityState",
|
|
145
|
+
"DOMParser",
|
|
146
|
+
"XMLSerializer",
|
|
147
|
+
"XMLHttpRequestEventTarget",
|
|
148
|
+
"XMLHttpRequestUpload",
|
|
149
|
+
"XMLHttpRequest",
|
|
150
|
+
"WebSocket",
|
|
151
|
+
"NodeFilter",
|
|
152
|
+
"NodeIterator",
|
|
153
|
+
"TreeWalker",
|
|
154
|
+
"AbstractRange",
|
|
155
|
+
"Range",
|
|
156
|
+
"StaticRange",
|
|
157
|
+
"Selection",
|
|
158
|
+
"Storage",
|
|
159
|
+
"CustomElementRegistry",
|
|
160
|
+
"ShadowRoot",
|
|
161
|
+
"MutationObserver",
|
|
162
|
+
"MutationRecord",
|
|
163
|
+
"Uint8Array",
|
|
164
|
+
"Uint16Array",
|
|
165
|
+
"Uint32Array",
|
|
166
|
+
"Uint8ClampedArray",
|
|
167
|
+
"Int8Array",
|
|
168
|
+
"Int16Array",
|
|
169
|
+
"Int32Array",
|
|
170
|
+
"Float32Array",
|
|
171
|
+
"Float64Array",
|
|
172
|
+
"ArrayBuffer",
|
|
173
|
+
"DOMRectReadOnly",
|
|
174
|
+
"DOMRect",
|
|
175
|
+
"Image",
|
|
176
|
+
"Audio",
|
|
177
|
+
"Option",
|
|
178
|
+
"CSS"
|
|
179
|
+
];
|
|
180
|
+
const OTHER_KEYS = [
|
|
181
|
+
"addEventListener",
|
|
182
|
+
"alert",
|
|
183
|
+
"blur",
|
|
184
|
+
"cancelAnimationFrame",
|
|
185
|
+
"close",
|
|
186
|
+
"confirm",
|
|
187
|
+
"createPopup",
|
|
188
|
+
"dispatchEvent",
|
|
189
|
+
"document",
|
|
190
|
+
"focus",
|
|
191
|
+
"frames",
|
|
192
|
+
"getComputedStyle",
|
|
193
|
+
"history",
|
|
194
|
+
"innerHeight",
|
|
195
|
+
"innerWidth",
|
|
196
|
+
"length",
|
|
197
|
+
"location",
|
|
198
|
+
"matchMedia",
|
|
199
|
+
"moveBy",
|
|
200
|
+
"moveTo",
|
|
201
|
+
"name",
|
|
202
|
+
"navigator",
|
|
203
|
+
"open",
|
|
204
|
+
"outerHeight",
|
|
205
|
+
"outerWidth",
|
|
206
|
+
"pageXOffset",
|
|
207
|
+
"pageYOffset",
|
|
208
|
+
"parent",
|
|
209
|
+
"postMessage",
|
|
210
|
+
"print",
|
|
211
|
+
"prompt",
|
|
212
|
+
"removeEventListener",
|
|
213
|
+
"requestAnimationFrame",
|
|
214
|
+
"resizeBy",
|
|
215
|
+
"resizeTo",
|
|
216
|
+
"screen",
|
|
217
|
+
"screenLeft",
|
|
218
|
+
"screenTop",
|
|
219
|
+
"screenX",
|
|
220
|
+
"screenY",
|
|
221
|
+
"scroll",
|
|
222
|
+
"scrollBy",
|
|
223
|
+
"scrollLeft",
|
|
224
|
+
"scrollTo",
|
|
225
|
+
"scrollTop",
|
|
226
|
+
"scrollX",
|
|
227
|
+
"scrollY",
|
|
228
|
+
"self",
|
|
229
|
+
"stop",
|
|
230
|
+
"top",
|
|
231
|
+
"Window",
|
|
232
|
+
"window"
|
|
233
|
+
];
|
|
234
|
+
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
235
|
+
|
|
236
|
+
const skipKeys = [
|
|
237
|
+
"window",
|
|
238
|
+
"self",
|
|
239
|
+
"top",
|
|
240
|
+
"parent"
|
|
241
|
+
];
|
|
242
|
+
function getWindowKeys(global, win, additionalKeys = []) {
|
|
243
|
+
const keysArray = [...additionalKeys, ...KEYS];
|
|
244
|
+
return new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
245
|
+
if (skipKeys.includes(k)) return false;
|
|
246
|
+
if (k in global) return keysArray.includes(k);
|
|
247
|
+
return true;
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
function isClassLikeName(name) {
|
|
251
|
+
return name[0] === name[0].toUpperCase();
|
|
252
|
+
}
|
|
253
|
+
function populateGlobal(global, win, options = {}) {
|
|
254
|
+
const { bindFunctions = false } = options;
|
|
255
|
+
const keys = getWindowKeys(global, win, options.additionalKeys);
|
|
256
|
+
const originals = /* @__PURE__ */ new Map();
|
|
257
|
+
const overridenKeys = new Set([...KEYS, ...options.additionalKeys || []]);
|
|
258
|
+
const overrideObject = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const key of keys) {
|
|
260
|
+
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
|
261
|
+
if (overridenKeys.has(key) && key in global) originals.set(key, global[key]);
|
|
262
|
+
Object.defineProperty(global, key, {
|
|
263
|
+
get() {
|
|
264
|
+
if (overrideObject.has(key)) return overrideObject.get(key);
|
|
265
|
+
if (boundFunction) return boundFunction;
|
|
266
|
+
return win[key];
|
|
267
|
+
},
|
|
268
|
+
set(v) {
|
|
269
|
+
overrideObject.set(key, v);
|
|
270
|
+
},
|
|
271
|
+
configurable: true
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
global.window = global;
|
|
275
|
+
global.self = global;
|
|
276
|
+
global.top = global;
|
|
277
|
+
global.parent = global;
|
|
278
|
+
if (global.global) global.global = global;
|
|
279
|
+
// rewrite defaultView to reference the same global context
|
|
280
|
+
if (global.document && global.document.defaultView) Object.defineProperty(global.document, "defaultView", {
|
|
281
|
+
get: () => global,
|
|
282
|
+
enumerable: true,
|
|
283
|
+
configurable: true
|
|
284
|
+
});
|
|
285
|
+
skipKeys.forEach((k) => keys.add(k));
|
|
286
|
+
return {
|
|
287
|
+
keys,
|
|
288
|
+
skipKeys,
|
|
289
|
+
originals
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var edge = {
|
|
294
|
+
name: "edge-runtime",
|
|
295
|
+
viteEnvironment: "ssr",
|
|
296
|
+
async setupVM() {
|
|
297
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
298
|
+
const vm = new EdgeVM({ extend: (context) => {
|
|
299
|
+
context.global = context;
|
|
300
|
+
context.Buffer = Buffer;
|
|
301
|
+
return context;
|
|
302
|
+
} });
|
|
303
|
+
return {
|
|
304
|
+
getVmContext() {
|
|
305
|
+
return vm.context;
|
|
306
|
+
},
|
|
307
|
+
teardown() {
|
|
308
|
+
// nothing to teardown
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
async setup(global) {
|
|
313
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
314
|
+
const { keys, originals } = populateGlobal(global, new EdgeVM({ extend: (context) => {
|
|
315
|
+
context.global = context;
|
|
316
|
+
context.Buffer = Buffer;
|
|
317
|
+
KEYS.forEach((key) => {
|
|
318
|
+
if (key in global) context[key] = global[key];
|
|
319
|
+
});
|
|
320
|
+
return context;
|
|
321
|
+
} }).context, { bindFunctions: true });
|
|
322
|
+
return { teardown(global) {
|
|
323
|
+
keys.forEach((key) => delete global[key]);
|
|
324
|
+
originals.forEach((v, k) => global[k] = v);
|
|
325
|
+
} };
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
async function teardownWindow(win) {
|
|
330
|
+
if (win.close && win.happyDOM.abort) {
|
|
331
|
+
await win.happyDOM.abort();
|
|
332
|
+
win.close();
|
|
333
|
+
} else win.happyDOM.cancelAsync();
|
|
334
|
+
}
|
|
335
|
+
var happy = {
|
|
336
|
+
name: "happy-dom",
|
|
337
|
+
viteEnvironment: "client",
|
|
338
|
+
async setupVM({ happyDOM = {} }) {
|
|
339
|
+
const { Window } = await import('happy-dom');
|
|
340
|
+
let win = new Window({
|
|
341
|
+
...happyDOM,
|
|
342
|
+
console: console && globalThis.console ? globalThis.console : void 0,
|
|
343
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
344
|
+
settings: {
|
|
345
|
+
...happyDOM.settings,
|
|
346
|
+
disableErrorCapturing: true
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
// TODO: browser doesn't expose Buffer, but a lot of dependencies use it
|
|
350
|
+
win.Buffer = Buffer;
|
|
351
|
+
// inject structuredClone if it exists
|
|
352
|
+
if (typeof structuredClone !== "undefined" && !win.structuredClone) win.structuredClone = structuredClone;
|
|
353
|
+
return {
|
|
354
|
+
getVmContext() {
|
|
355
|
+
return win;
|
|
356
|
+
},
|
|
357
|
+
async teardown() {
|
|
358
|
+
await teardownWindow(win);
|
|
359
|
+
win = void 0;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
async setup(global, { happyDOM = {} }) {
|
|
364
|
+
// happy-dom v3 introduced a breaking change to Window, but
|
|
365
|
+
// provides GlobalWindow as a way to use previous behaviour
|
|
366
|
+
const { Window, GlobalWindow } = await import('happy-dom');
|
|
367
|
+
const win = new (GlobalWindow || Window)({
|
|
368
|
+
...happyDOM,
|
|
369
|
+
console: console && global.console ? global.console : void 0,
|
|
370
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
371
|
+
settings: {
|
|
372
|
+
...happyDOM.settings,
|
|
373
|
+
disableErrorCapturing: true
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
const { keys, originals } = populateGlobal(global, win, {
|
|
377
|
+
bindFunctions: true,
|
|
378
|
+
additionalKeys: [
|
|
379
|
+
"Request",
|
|
380
|
+
"Response",
|
|
381
|
+
"MessagePort",
|
|
382
|
+
"fetch",
|
|
383
|
+
"Headers",
|
|
384
|
+
"AbortController",
|
|
385
|
+
"AbortSignal",
|
|
386
|
+
"URL",
|
|
387
|
+
"URLSearchParams",
|
|
388
|
+
"FormData"
|
|
389
|
+
]
|
|
390
|
+
});
|
|
391
|
+
return { async teardown(global) {
|
|
392
|
+
await teardownWindow(win);
|
|
393
|
+
keys.forEach((key) => delete global[key]);
|
|
394
|
+
originals.forEach((v, k) => global[k] = v);
|
|
395
|
+
} };
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
function catchWindowErrors(window) {
|
|
400
|
+
let userErrorListenerCount = 0;
|
|
401
|
+
function throwUnhandlerError(e) {
|
|
402
|
+
if (userErrorListenerCount === 0 && e.error != null) {
|
|
403
|
+
e.preventDefault();
|
|
404
|
+
process.emit("uncaughtException", e.error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const addEventListener = window.addEventListener.bind(window);
|
|
408
|
+
const removeEventListener = window.removeEventListener.bind(window);
|
|
409
|
+
window.addEventListener("error", throwUnhandlerError);
|
|
410
|
+
window.addEventListener = function(...args) {
|
|
411
|
+
if (args[0] === "error") userErrorListenerCount++;
|
|
412
|
+
return addEventListener.apply(this, args);
|
|
413
|
+
};
|
|
414
|
+
window.removeEventListener = function(...args) {
|
|
415
|
+
if (args[0] === "error" && userErrorListenerCount) userErrorListenerCount--;
|
|
416
|
+
return removeEventListener.apply(this, args);
|
|
417
|
+
};
|
|
418
|
+
return function clearErrorHandlers() {
|
|
419
|
+
window.removeEventListener("error", throwUnhandlerError);
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
let NodeFormData_;
|
|
423
|
+
let NodeBlob_;
|
|
424
|
+
let NodeRequest_;
|
|
425
|
+
var jsdom = {
|
|
426
|
+
name: "jsdom",
|
|
427
|
+
viteEnvironment: "client",
|
|
428
|
+
async setupVM({ jsdom = {} }) {
|
|
429
|
+
// delay initialization because it takes ~1s
|
|
430
|
+
NodeFormData_ = globalThis.FormData;
|
|
431
|
+
NodeBlob_ = globalThis.Blob;
|
|
432
|
+
NodeRequest_ = globalThis.Request;
|
|
433
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
434
|
+
const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false, ...restOptions } = jsdom;
|
|
435
|
+
let virtualConsole;
|
|
436
|
+
if (console && globalThis.console) {
|
|
437
|
+
virtualConsole = new VirtualConsole();
|
|
438
|
+
// jsdom <27
|
|
439
|
+
if ("sendTo" in virtualConsole) virtualConsole.sendTo(globalThis.console);
|
|
440
|
+
else virtualConsole.forwardTo(globalThis.console);
|
|
441
|
+
}
|
|
442
|
+
let dom = new JSDOM(html, {
|
|
443
|
+
pretendToBeVisual,
|
|
444
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
445
|
+
runScripts,
|
|
446
|
+
url,
|
|
447
|
+
virtualConsole,
|
|
448
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
449
|
+
includeNodeLocations,
|
|
450
|
+
contentType,
|
|
451
|
+
userAgent,
|
|
452
|
+
...restOptions
|
|
453
|
+
});
|
|
454
|
+
const clearAddEventListenerPatch = patchAddEventListener(dom.window);
|
|
455
|
+
const clearWindowErrors = catchWindowErrors(dom.window);
|
|
456
|
+
const utils = createCompatUtils(dom.window);
|
|
457
|
+
// TODO: browser doesn't expose Buffer, but a lot of dependencies use it
|
|
458
|
+
dom.window.Buffer = Buffer;
|
|
459
|
+
dom.window.jsdom = dom;
|
|
460
|
+
dom.window.Request = createCompatRequest(utils);
|
|
461
|
+
dom.window.URL = createJSDOMCompatURL(utils);
|
|
462
|
+
for (const name of [
|
|
463
|
+
"structuredClone",
|
|
464
|
+
"BroadcastChannel",
|
|
465
|
+
"MessageChannel",
|
|
466
|
+
"MessagePort",
|
|
467
|
+
"TextEncoder",
|
|
468
|
+
"TextDecoder"
|
|
469
|
+
]) {
|
|
470
|
+
const value = globalThis[name];
|
|
471
|
+
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined") dom.window[name] = value;
|
|
472
|
+
}
|
|
473
|
+
for (const name of [
|
|
474
|
+
"fetch",
|
|
475
|
+
"Response",
|
|
476
|
+
"Headers",
|
|
477
|
+
"AbortController",
|
|
478
|
+
"AbortSignal",
|
|
479
|
+
"URLSearchParams"
|
|
480
|
+
]) {
|
|
481
|
+
const value = globalThis[name];
|
|
482
|
+
if (typeof value !== "undefined") dom.window[name] = value;
|
|
483
|
+
}
|
|
484
|
+
return {
|
|
485
|
+
getVmContext() {
|
|
486
|
+
return dom.getInternalVMContext();
|
|
487
|
+
},
|
|
488
|
+
teardown() {
|
|
489
|
+
clearAddEventListenerPatch();
|
|
490
|
+
clearWindowErrors();
|
|
491
|
+
dom.window.close();
|
|
492
|
+
dom = void 0;
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
},
|
|
496
|
+
async setup(global, { jsdom = {} }) {
|
|
497
|
+
// delay initialization because it takes ~1s
|
|
498
|
+
NodeFormData_ = globalThis.FormData;
|
|
499
|
+
NodeBlob_ = globalThis.Blob;
|
|
500
|
+
NodeRequest_ = globalThis.Request;
|
|
501
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
502
|
+
const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false, ...restOptions } = jsdom;
|
|
503
|
+
let virtualConsole;
|
|
504
|
+
if (console && globalThis.console) {
|
|
505
|
+
virtualConsole = new VirtualConsole();
|
|
506
|
+
// jsdom <27
|
|
507
|
+
if ("sendTo" in virtualConsole) virtualConsole.sendTo(globalThis.console);
|
|
508
|
+
else virtualConsole.forwardTo(globalThis.console);
|
|
509
|
+
}
|
|
510
|
+
const dom = new JSDOM(html, {
|
|
511
|
+
pretendToBeVisual,
|
|
512
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
513
|
+
runScripts,
|
|
514
|
+
url,
|
|
515
|
+
virtualConsole,
|
|
516
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
517
|
+
includeNodeLocations,
|
|
518
|
+
contentType,
|
|
519
|
+
userAgent,
|
|
520
|
+
...restOptions
|
|
521
|
+
});
|
|
522
|
+
const clearAddEventListenerPatch = patchAddEventListener(dom.window);
|
|
523
|
+
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
|
524
|
+
const clearWindowErrors = catchWindowErrors(global);
|
|
525
|
+
const utils = createCompatUtils(dom.window);
|
|
526
|
+
global.jsdom = dom;
|
|
527
|
+
global.Request = createCompatRequest(utils);
|
|
528
|
+
global.URL = createJSDOMCompatURL(utils);
|
|
529
|
+
return { teardown(global) {
|
|
530
|
+
clearAddEventListenerPatch();
|
|
531
|
+
clearWindowErrors();
|
|
532
|
+
dom.window.close();
|
|
533
|
+
delete global.jsdom;
|
|
534
|
+
keys.forEach((key) => delete global[key]);
|
|
535
|
+
originals.forEach((v, k) => global[k] = v);
|
|
536
|
+
} };
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function createCompatRequest(utils) {
|
|
540
|
+
return class Request extends NodeRequest_ {
|
|
541
|
+
constructor(...args) {
|
|
542
|
+
const [input, init] = args;
|
|
543
|
+
if (init?.body != null) {
|
|
544
|
+
const compatInit = { ...init };
|
|
545
|
+
if (init.body instanceof utils.window.Blob) compatInit.body = utils.makeCompatBlob(init.body);
|
|
546
|
+
if (init.body instanceof utils.window.FormData) compatInit.body = utils.makeCompatFormData(init.body);
|
|
547
|
+
super(input, compatInit);
|
|
548
|
+
} else super(...args);
|
|
549
|
+
}
|
|
550
|
+
static [Symbol.hasInstance](instance) {
|
|
551
|
+
return instance instanceof NodeRequest_;
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function createJSDOMCompatURL(utils) {
|
|
556
|
+
return class URL$1 extends URL {
|
|
557
|
+
static createObjectURL(blob) {
|
|
558
|
+
if (blob instanceof utils.window.Blob) {
|
|
559
|
+
const compatBlob = utils.makeCompatBlob(blob);
|
|
560
|
+
return URL.createObjectURL(compatBlob);
|
|
561
|
+
}
|
|
562
|
+
return URL.createObjectURL(blob);
|
|
563
|
+
}
|
|
564
|
+
static [Symbol.hasInstance](instance) {
|
|
565
|
+
return instance instanceof URL;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function createCompatUtils(window) {
|
|
570
|
+
// this returns a hidden Symbol(impl)
|
|
571
|
+
// this is cursed, and jsdom should just implement fetch API itself
|
|
572
|
+
const implSymbol = Object.getOwnPropertySymbols(Object.getOwnPropertyDescriptors(new window.Blob()))[0];
|
|
573
|
+
const utils = {
|
|
574
|
+
window,
|
|
575
|
+
makeCompatFormData(formData) {
|
|
576
|
+
const nodeFormData = new NodeFormData_();
|
|
577
|
+
formData.forEach((value, key) => {
|
|
578
|
+
if (value instanceof window.Blob) nodeFormData.append(key, utils.makeCompatBlob(value));
|
|
579
|
+
else nodeFormData.append(key, value);
|
|
580
|
+
});
|
|
581
|
+
return nodeFormData;
|
|
582
|
+
},
|
|
583
|
+
makeCompatBlob(blob) {
|
|
584
|
+
const buffer = blob[implSymbol]._buffer;
|
|
585
|
+
return new NodeBlob_([buffer], { type: blob.type });
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
return utils;
|
|
589
|
+
}
|
|
590
|
+
function patchAddEventListener(window) {
|
|
591
|
+
const abortControllers = /* @__PURE__ */ new WeakMap();
|
|
592
|
+
const JSDOMAbortSignal = window.AbortSignal;
|
|
593
|
+
const JSDOMAbortController = window.AbortController;
|
|
594
|
+
const originalAddEventListener = window.EventTarget.prototype.addEventListener;
|
|
595
|
+
function getJsdomAbortController(signal) {
|
|
596
|
+
if (!abortControllers.has(signal)) {
|
|
597
|
+
const jsdomAbortController = new JSDOMAbortController();
|
|
598
|
+
signal.addEventListener("abort", () => {
|
|
599
|
+
jsdomAbortController.abort(signal.reason);
|
|
600
|
+
});
|
|
601
|
+
abortControllers.set(signal, jsdomAbortController);
|
|
602
|
+
}
|
|
603
|
+
return abortControllers.get(signal);
|
|
604
|
+
}
|
|
605
|
+
window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
|
|
606
|
+
if (typeof options === "object" && options?.signal != null) {
|
|
607
|
+
const { signal, ...otherOptions } = options;
|
|
608
|
+
// - this happens because AbortSignal is provided by Node.js,
|
|
609
|
+
// but jsdom APIs require jsdom's AbortSignal, while Node APIs
|
|
610
|
+
// (like fetch and Request) require a Node.js AbortSignal
|
|
611
|
+
// - disable narrow typing with "as any" because we need it later
|
|
612
|
+
if (!(signal instanceof JSDOMAbortSignal)) {
|
|
613
|
+
const jsdomCompatOptions = Object.create(null);
|
|
614
|
+
Object.assign(jsdomCompatOptions, otherOptions);
|
|
615
|
+
jsdomCompatOptions.signal = getJsdomAbortController(signal).signal;
|
|
616
|
+
return originalAddEventListener.call(this, type, callback, jsdomCompatOptions);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return originalAddEventListener.call(this, type, callback, options);
|
|
620
|
+
};
|
|
621
|
+
return () => {
|
|
622
|
+
window.EventTarget.prototype.addEventListener = originalAddEventListener;
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// some globals we do not want, either because deprecated or we set it ourselves
|
|
627
|
+
const denyList = new Set([
|
|
628
|
+
"GLOBAL",
|
|
629
|
+
"root",
|
|
630
|
+
"global",
|
|
631
|
+
"Buffer",
|
|
632
|
+
"ArrayBuffer",
|
|
633
|
+
"Uint8Array"
|
|
634
|
+
]);
|
|
635
|
+
const nodeGlobals = /* @__PURE__ */ new Map();
|
|
636
|
+
function populateNodeGlobals() {
|
|
637
|
+
if (nodeGlobals.size !== 0) return;
|
|
638
|
+
const names = Object.getOwnPropertyNames(globalThis);
|
|
639
|
+
const length = names.length;
|
|
640
|
+
for (let i = 0; i < length; i++) {
|
|
641
|
+
const globalName = names[i];
|
|
642
|
+
if (!denyList.has(globalName)) {
|
|
643
|
+
const descriptor = Object.getOwnPropertyDescriptor(globalThis, globalName);
|
|
644
|
+
if (!descriptor) throw new Error(`No property descriptor for ${globalName}, this is a bug in Vitest.`);
|
|
645
|
+
nodeGlobals.set(globalName, descriptor);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
var node = {
|
|
650
|
+
name: "node",
|
|
651
|
+
viteEnvironment: "ssr",
|
|
652
|
+
async setupVM() {
|
|
653
|
+
populateNodeGlobals();
|
|
654
|
+
const vm = await import('node:vm');
|
|
655
|
+
let context = vm.createContext();
|
|
656
|
+
let global = vm.runInContext("this", context);
|
|
657
|
+
const contextGlobals = new Set(Object.getOwnPropertyNames(global));
|
|
658
|
+
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey)) if (descriptor.configurable) Object.defineProperty(global, nodeGlobalsKey, {
|
|
659
|
+
configurable: true,
|
|
660
|
+
enumerable: descriptor.enumerable,
|
|
661
|
+
get() {
|
|
662
|
+
// @ts-expect-error: no index signature
|
|
663
|
+
const val = globalThis[nodeGlobalsKey];
|
|
664
|
+
// override lazy getter
|
|
665
|
+
Object.defineProperty(global, nodeGlobalsKey, {
|
|
666
|
+
configurable: true,
|
|
667
|
+
enumerable: descriptor.enumerable,
|
|
668
|
+
value: val,
|
|
669
|
+
writable: descriptor.writable === true || nodeGlobalsKey === "performance"
|
|
670
|
+
});
|
|
671
|
+
return val;
|
|
672
|
+
},
|
|
673
|
+
set(val) {
|
|
674
|
+
// override lazy getter
|
|
675
|
+
Object.defineProperty(global, nodeGlobalsKey, {
|
|
676
|
+
configurable: true,
|
|
677
|
+
enumerable: descriptor.enumerable,
|
|
678
|
+
value: val,
|
|
679
|
+
writable: true
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
else if ("value" in descriptor) Object.defineProperty(global, nodeGlobalsKey, {
|
|
684
|
+
configurable: false,
|
|
685
|
+
enumerable: descriptor.enumerable,
|
|
686
|
+
value: descriptor.value,
|
|
687
|
+
writable: descriptor.writable
|
|
688
|
+
});
|
|
689
|
+
else Object.defineProperty(global, nodeGlobalsKey, {
|
|
690
|
+
configurable: false,
|
|
691
|
+
enumerable: descriptor.enumerable,
|
|
692
|
+
get: descriptor.get,
|
|
693
|
+
set: descriptor.set
|
|
694
|
+
});
|
|
695
|
+
global.global = global;
|
|
696
|
+
global.Buffer = Buffer;
|
|
697
|
+
global.ArrayBuffer = ArrayBuffer;
|
|
698
|
+
// TextEncoder (global or via 'util') references a Uint8Array constructor
|
|
699
|
+
// different than the global one used by users in tests. This makes sure the
|
|
700
|
+
// same constructor is referenced by both.
|
|
701
|
+
global.Uint8Array = Uint8Array;
|
|
702
|
+
return {
|
|
703
|
+
getVmContext() {
|
|
704
|
+
return context;
|
|
705
|
+
},
|
|
706
|
+
teardown() {
|
|
707
|
+
context = void 0;
|
|
708
|
+
global = void 0;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
},
|
|
712
|
+
async setup(global) {
|
|
713
|
+
global.console.Console = Console;
|
|
714
|
+
return { teardown(global) {
|
|
715
|
+
delete global.console.Console;
|
|
716
|
+
} };
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
const environments = {
|
|
721
|
+
node,
|
|
722
|
+
jsdom,
|
|
723
|
+
"happy-dom": happy,
|
|
724
|
+
"edge-runtime": edge
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
export { environments as e, populateGlobal as p };
|