vitest 0.22.0 → 0.23.1
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 +29 -29
- package/dist/browser.d.ts +5 -4
- package/dist/browser.mjs +12 -9
- package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.9e83ca0a.mjs} +92 -90
- package/dist/chunk-constants.6196597b.mjs +284 -0
- package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
- package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.e081fc1b.mjs} +3 -3
- package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
- package/dist/chunk-integrations-globals.b1aa52c3.mjs +25 -0
- package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
- package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.f63a5ff2.mjs} +31 -193
- package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.6f289b0a.mjs} +20 -16
- package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.8bfc559b.mjs} +507 -173
- package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.252dd130.mjs} +206 -75
- package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.c6b06bd8.mjs} +18 -12
- package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.d9690273.mjs} +19 -12
- package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.48bd94e3.mjs} +1 -2
- package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.a1647f5f.mjs} +11 -5
- package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.998e04d0.mjs} +92 -31
- package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -4
- package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.3035bd5b.mjs} +515 -211
- package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.8a9b3014.mjs} +39 -41
- package/dist/cli-wrapper.mjs +54 -33
- package/dist/cli.mjs +31 -20
- package/dist/config.cjs +2 -2
- package/dist/config.d.ts +4 -3
- package/dist/config.mjs +2 -2
- package/dist/entry.mjs +20 -14
- package/dist/environments.d.ts +23 -0
- package/dist/environments.mjs +3 -0
- package/dist/{global-74489cc9.d.ts → global-ea084c9f.d.ts} +154 -24
- package/dist/{index-9eded9ec.d.ts → index-5f09f4d0.d.ts} +3 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +7 -7
- package/dist/loader.mjs +5 -6
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +17 -16
- package/dist/suite.mjs +6 -6
- package/dist/vendor-index.0557b03a.mjs +147 -0
- package/dist/{vendor-index.9d9196cc.mjs → vendor-index.13e3bda3.mjs} +0 -0
- package/dist/{vendor-index.fbec8a81.mjs → vendor-index.4aeeb598.mjs} +2 -2
- package/dist/{vendor-index.2ae8040a.mjs → vendor-index.62ce5c33.mjs} +0 -0
- package/dist/{vendor-index.29636037.mjs → vendor-index.731a22f2.mjs} +0 -0
- package/dist/worker.mjs +20 -19
- package/package.json +18 -11
- package/dist/chunk-constants.d3f8437b.mjs +0 -38
- package/dist/chunk-integrations-globals.e81d2091.mjs +0 -27
- package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
- package/dist/vendor-picocolors.807856aa.mjs +0 -64
|
@@ -1,173 +1,13 @@
|
|
|
1
|
+
import { Console } from 'console';
|
|
1
2
|
import { importModule } from 'local-pkg';
|
|
2
3
|
|
|
3
|
-
/*
|
|
4
|
-
How it works:
|
|
5
|
-
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
class Node {
|
|
9
|
-
value;
|
|
10
|
-
next;
|
|
11
|
-
|
|
12
|
-
constructor(value) {
|
|
13
|
-
this.value = value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class Queue {
|
|
18
|
-
#head;
|
|
19
|
-
#tail;
|
|
20
|
-
#size;
|
|
21
|
-
|
|
22
|
-
constructor() {
|
|
23
|
-
this.clear();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
enqueue(value) {
|
|
27
|
-
const node = new Node(value);
|
|
28
|
-
|
|
29
|
-
if (this.#head) {
|
|
30
|
-
this.#tail.next = node;
|
|
31
|
-
this.#tail = node;
|
|
32
|
-
} else {
|
|
33
|
-
this.#head = node;
|
|
34
|
-
this.#tail = node;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.#size++;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
dequeue() {
|
|
41
|
-
const current = this.#head;
|
|
42
|
-
if (!current) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
this.#head = this.#head.next;
|
|
47
|
-
this.#size--;
|
|
48
|
-
return current.value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
clear() {
|
|
52
|
-
this.#head = undefined;
|
|
53
|
-
this.#tail = undefined;
|
|
54
|
-
this.#size = 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get size() {
|
|
58
|
-
return this.#size;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
* [Symbol.iterator]() {
|
|
62
|
-
let current = this.#head;
|
|
63
|
-
|
|
64
|
-
while (current) {
|
|
65
|
-
yield current.value;
|
|
66
|
-
current = current.next;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function pLimit(concurrency) {
|
|
72
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
73
|
-
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const queue = new Queue();
|
|
77
|
-
let activeCount = 0;
|
|
78
|
-
|
|
79
|
-
const next = () => {
|
|
80
|
-
activeCount--;
|
|
81
|
-
|
|
82
|
-
if (queue.size > 0) {
|
|
83
|
-
queue.dequeue()();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const run = async (fn, resolve, args) => {
|
|
88
|
-
activeCount++;
|
|
89
|
-
|
|
90
|
-
const result = (async () => fn(...args))();
|
|
91
|
-
|
|
92
|
-
resolve(result);
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
await result;
|
|
96
|
-
} catch {}
|
|
97
|
-
|
|
98
|
-
next();
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const enqueue = (fn, resolve, args) => {
|
|
102
|
-
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
103
|
-
|
|
104
|
-
(async () => {
|
|
105
|
-
// This function needs to wait until the next microtask before comparing
|
|
106
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
107
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
108
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
109
|
-
await Promise.resolve();
|
|
110
|
-
|
|
111
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
112
|
-
queue.dequeue()();
|
|
113
|
-
}
|
|
114
|
-
})();
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const generator = (fn, ...args) => new Promise(resolve => {
|
|
118
|
-
enqueue(fn, resolve, args);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
Object.defineProperties(generator, {
|
|
122
|
-
activeCount: {
|
|
123
|
-
get: () => activeCount,
|
|
124
|
-
},
|
|
125
|
-
pendingCount: {
|
|
126
|
-
get: () => queue.size,
|
|
127
|
-
},
|
|
128
|
-
clearQueue: {
|
|
129
|
-
value: () => {
|
|
130
|
-
queue.clear();
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return generator;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const CoverageProviderMap = {
|
|
139
|
-
c8: "@vitest/coverage-c8",
|
|
140
|
-
istanbul: "@vitest/coverage-istanbul"
|
|
141
|
-
};
|
|
142
|
-
async function resolveCoverageProvider(provider) {
|
|
143
|
-
if (typeof provider === "string") {
|
|
144
|
-
const pkg = CoverageProviderMap[provider];
|
|
145
|
-
if (!pkg)
|
|
146
|
-
throw new Error(`Unknown coverage provider: ${provider}`);
|
|
147
|
-
return await importModule(pkg);
|
|
148
|
-
} else {
|
|
149
|
-
return provider;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function getCoverageProvider(options) {
|
|
153
|
-
if ((options == null ? void 0 : options.enabled) && (options == null ? void 0 : options.provider)) {
|
|
154
|
-
const { getProvider } = await resolveCoverageProvider(options.provider);
|
|
155
|
-
return await getProvider();
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
async function takeCoverageInsideWorker(options) {
|
|
160
|
-
if (options.enabled && options.provider) {
|
|
161
|
-
const { takeCoverage } = await resolveCoverageProvider(options.provider);
|
|
162
|
-
return await (takeCoverage == null ? void 0 : takeCoverage());
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
4
|
var node = {
|
|
167
5
|
name: "node",
|
|
168
|
-
async setup() {
|
|
6
|
+
async setup(global) {
|
|
7
|
+
global.console.Console = Console;
|
|
169
8
|
return {
|
|
170
|
-
teardown() {
|
|
9
|
+
teardown(global2) {
|
|
10
|
+
delete global2.console.Console;
|
|
171
11
|
}
|
|
172
12
|
};
|
|
173
13
|
}
|
|
@@ -422,7 +262,9 @@ function isClassLikeName(name) {
|
|
|
422
262
|
function populateGlobal(global, win, options = {}) {
|
|
423
263
|
const { bindFunctions = false } = options;
|
|
424
264
|
const keys = getWindowKeys(global, win);
|
|
425
|
-
const originals = new Map(
|
|
265
|
+
const originals = new Map(
|
|
266
|
+
allowRewrite.filter((key) => key in global).map((key) => [key, global[key]])
|
|
267
|
+
);
|
|
426
268
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
427
269
|
for (const key of keys) {
|
|
428
270
|
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
|
@@ -476,18 +318,21 @@ var jsdom = {
|
|
|
476
318
|
cookieJar = false,
|
|
477
319
|
...restOptions
|
|
478
320
|
} = jsdom;
|
|
479
|
-
const dom = new JSDOM(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
321
|
+
const dom = new JSDOM(
|
|
322
|
+
html,
|
|
323
|
+
{
|
|
324
|
+
pretendToBeVisual,
|
|
325
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
326
|
+
runScripts,
|
|
327
|
+
url,
|
|
328
|
+
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
329
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
330
|
+
includeNodeLocations,
|
|
331
|
+
contentType,
|
|
332
|
+
userAgent,
|
|
333
|
+
...restOptions
|
|
334
|
+
}
|
|
335
|
+
);
|
|
491
336
|
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
|
492
337
|
return {
|
|
493
338
|
teardown(global2) {
|
|
@@ -547,5 +392,12 @@ const envPackageNames = {
|
|
|
547
392
|
"happy-dom": "happy-dom",
|
|
548
393
|
"edge-runtime": "@edge-runtime/vm"
|
|
549
394
|
};
|
|
395
|
+
const getEnvPackageName = (env) => {
|
|
396
|
+
if (env === "node")
|
|
397
|
+
return null;
|
|
398
|
+
if (env in envPackageNames)
|
|
399
|
+
return envPackageNames[env];
|
|
400
|
+
return `vitest-environment-${env}`;
|
|
401
|
+
};
|
|
550
402
|
|
|
551
|
-
export {
|
|
403
|
+
export { envs as a, environments as e, getEnvPackageName as g, populateGlobal as p };
|
|
@@ -2,10 +2,10 @@ import path$2 from 'path';
|
|
|
2
2
|
import fs$2 from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
4
|
import childProcess$1 from 'child_process';
|
|
5
|
-
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.
|
|
6
|
-
import { o as onetime$1 } from './vendor-index.
|
|
5
|
+
import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.62ce5c33.mjs';
|
|
6
|
+
import { o as onetime$1 } from './vendor-index.13e3bda3.mjs';
|
|
7
7
|
import require$$0 from 'os';
|
|
8
|
-
import { s as signalExit } from './vendor-index.
|
|
8
|
+
import { s as signalExit } from './vendor-index.731a22f2.mjs';
|
|
9
9
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
10
10
|
import 'buffer';
|
|
11
11
|
import 'stream';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { importModule } from 'local-pkg';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
How it works:
|
|
5
|
+
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
class Node {
|
|
9
|
+
value;
|
|
10
|
+
next;
|
|
11
|
+
|
|
12
|
+
constructor(value) {
|
|
13
|
+
this.value = value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class Queue {
|
|
18
|
+
#head;
|
|
19
|
+
#tail;
|
|
20
|
+
#size;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
this.clear();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
enqueue(value) {
|
|
27
|
+
const node = new Node(value);
|
|
28
|
+
|
|
29
|
+
if (this.#head) {
|
|
30
|
+
this.#tail.next = node;
|
|
31
|
+
this.#tail = node;
|
|
32
|
+
} else {
|
|
33
|
+
this.#head = node;
|
|
34
|
+
this.#tail = node;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.#size++;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
dequeue() {
|
|
41
|
+
const current = this.#head;
|
|
42
|
+
if (!current) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.#head = this.#head.next;
|
|
47
|
+
this.#size--;
|
|
48
|
+
return current.value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
clear() {
|
|
52
|
+
this.#head = undefined;
|
|
53
|
+
this.#tail = undefined;
|
|
54
|
+
this.#size = 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get size() {
|
|
58
|
+
return this.#size;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
* [Symbol.iterator]() {
|
|
62
|
+
let current = this.#head;
|
|
63
|
+
|
|
64
|
+
while (current) {
|
|
65
|
+
yield current.value;
|
|
66
|
+
current = current.next;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function pLimit(concurrency) {
|
|
72
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
73
|
+
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const queue = new Queue();
|
|
77
|
+
let activeCount = 0;
|
|
78
|
+
|
|
79
|
+
const next = () => {
|
|
80
|
+
activeCount--;
|
|
81
|
+
|
|
82
|
+
if (queue.size > 0) {
|
|
83
|
+
queue.dequeue()();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const run = async (fn, resolve, args) => {
|
|
88
|
+
activeCount++;
|
|
89
|
+
|
|
90
|
+
const result = (async () => fn(...args))();
|
|
91
|
+
|
|
92
|
+
resolve(result);
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
await result;
|
|
96
|
+
} catch {}
|
|
97
|
+
|
|
98
|
+
next();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const enqueue = (fn, resolve, args) => {
|
|
102
|
+
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
103
|
+
|
|
104
|
+
(async () => {
|
|
105
|
+
// This function needs to wait until the next microtask before comparing
|
|
106
|
+
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
107
|
+
// when the run function is dequeued and called. The comparison in the if-statement
|
|
108
|
+
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
109
|
+
await Promise.resolve();
|
|
110
|
+
|
|
111
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
112
|
+
queue.dequeue()();
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const generator = (fn, ...args) => new Promise(resolve => {
|
|
118
|
+
enqueue(fn, resolve, args);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
Object.defineProperties(generator, {
|
|
122
|
+
activeCount: {
|
|
123
|
+
get: () => activeCount,
|
|
124
|
+
},
|
|
125
|
+
pendingCount: {
|
|
126
|
+
get: () => queue.size,
|
|
127
|
+
},
|
|
128
|
+
clearQueue: {
|
|
129
|
+
value: () => {
|
|
130
|
+
queue.clear();
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return generator;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const CoverageProviderMap = {
|
|
139
|
+
c8: "@vitest/coverage-c8",
|
|
140
|
+
istanbul: "@vitest/coverage-istanbul"
|
|
141
|
+
};
|
|
142
|
+
async function resolveCoverageProvider(provider) {
|
|
143
|
+
if (typeof provider === "string") {
|
|
144
|
+
const pkg = CoverageProviderMap[provider];
|
|
145
|
+
if (!pkg)
|
|
146
|
+
throw new Error(`Unknown coverage provider: ${provider}`);
|
|
147
|
+
return await importModule(pkg);
|
|
148
|
+
} else {
|
|
149
|
+
return provider;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function getCoverageProvider(options) {
|
|
153
|
+
if ((options == null ? void 0 : options.enabled) && (options == null ? void 0 : options.provider)) {
|
|
154
|
+
const { getProvider } = await resolveCoverageProvider(options.provider);
|
|
155
|
+
return await getProvider();
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
async function takeCoverageInsideWorker(options) {
|
|
160
|
+
if (options.enabled && options.provider) {
|
|
161
|
+
const { takeCoverage } = await resolveCoverageProvider(options.provider);
|
|
162
|
+
return await (takeCoverage == null ? void 0 : takeCoverage());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { CoverageProviderMap as C, getCoverageProvider as g, pLimit as p, takeCoverageInsideWorker as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { k as globalApis } from './chunk-constants.6196597b.mjs';
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.c6b06bd8.mjs';
|
|
3
|
+
import 'tty';
|
|
4
|
+
import 'url';
|
|
5
|
+
import 'path';
|
|
6
|
+
import './chunk-runtime-chain.8bfc559b.mjs';
|
|
7
|
+
import 'util';
|
|
8
|
+
import './chunk-mock-date.f63a5ff2.mjs';
|
|
9
|
+
import 'local-pkg';
|
|
10
|
+
import 'chai';
|
|
11
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
+
import './chunk-runtime-rpc.48bd94e3.mjs';
|
|
13
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import './chunk-utils-source-map.a1647f5f.mjs';
|
|
16
|
+
import './spy.mjs';
|
|
17
|
+
import 'tinyspy';
|
|
18
|
+
|
|
19
|
+
function registerApiGlobally() {
|
|
20
|
+
globalApis.forEach((api) => {
|
|
21
|
+
globalThis[api] = index[api];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { registerApiGlobally };
|
|
@@ -219,15 +219,20 @@ class Chunk {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (typeof
|
|
226
|
-
|
|
227
|
-
} else
|
|
228
|
-
|
|
222
|
+
function getBtoa () {
|
|
223
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
224
|
+
return (str) => window.btoa(unescape(encodeURIComponent(str)));
|
|
225
|
+
} else if (typeof Buffer === 'function') {
|
|
226
|
+
return (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
227
|
+
} else {
|
|
228
|
+
return () => {
|
|
229
|
+
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
230
|
+
};
|
|
231
|
+
}
|
|
229
232
|
}
|
|
230
233
|
|
|
234
|
+
const btoa = /*#__PURE__*/ getBtoa();
|
|
235
|
+
|
|
231
236
|
class SourceMap {
|
|
232
237
|
constructor(properties) {
|
|
233
238
|
this.version = 3;
|
|
@@ -419,7 +424,7 @@ class MagicString {
|
|
|
419
424
|
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
420
425
|
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
421
426
|
storedNames: { writable: true, value: {} },
|
|
422
|
-
indentStr: { writable: true, value:
|
|
427
|
+
indentStr: { writable: true, value: undefined },
|
|
423
428
|
});
|
|
424
429
|
|
|
425
430
|
this.byStart[0] = chunk;
|
|
@@ -549,7 +554,19 @@ class MagicString {
|
|
|
549
554
|
return new SourceMap(this.generateDecodedMap(options));
|
|
550
555
|
}
|
|
551
556
|
|
|
557
|
+
_ensureindentStr() {
|
|
558
|
+
if (this.indentStr === undefined) {
|
|
559
|
+
this.indentStr = guessIndent(this.original);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
_getRawIndentString() {
|
|
564
|
+
this._ensureindentStr();
|
|
565
|
+
return this.indentStr;
|
|
566
|
+
}
|
|
567
|
+
|
|
552
568
|
getIndentString() {
|
|
569
|
+
this._ensureindentStr();
|
|
553
570
|
return this.indentStr === null ? '\t' : this.indentStr;
|
|
554
571
|
}
|
|
555
572
|
|
|
@@ -561,7 +578,10 @@ class MagicString {
|
|
|
561
578
|
indentStr = undefined;
|
|
562
579
|
}
|
|
563
580
|
|
|
564
|
-
|
|
581
|
+
if (indentStr === undefined) {
|
|
582
|
+
this._ensureindentStr();
|
|
583
|
+
indentStr = this.indentStr || '\t';
|
|
584
|
+
}
|
|
565
585
|
|
|
566
586
|
if (indentStr === '') return this; // noop
|
|
567
587
|
|
|
@@ -1277,7 +1297,7 @@ class Bundle {
|
|
|
1277
1297
|
const indentStringCounts = {};
|
|
1278
1298
|
|
|
1279
1299
|
this.sources.forEach((source) => {
|
|
1280
|
-
const indentStr = source.content.
|
|
1300
|
+
const indentStr = source.content._getRawIndentString();
|
|
1281
1301
|
|
|
1282
1302
|
if (indentStr === null) return;
|
|
1283
1303
|
|