vite 5.1.6 → 5.2.0-beta.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 +6 -0
- package/dist/client/client.mjs +30 -22
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-pxQDj-UY.js → dep-BC11CTkQ.js} +145 -145
- package/dist/node/chunks/{dep-sFlFG1c_.js → dep-Q9IC80br.js} +2 -2
- package/dist/node/chunks/{dep-jvB8WLp9.js → dep-Zq4BZdyw.js} +1060 -877
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +24 -4
- package/dist/node/index.js +3 -3
- package/dist/node/runtime.d.ts +2 -2
- package/dist/node/runtime.js +9 -6
- package/dist/node/{types.d-FdqQ54oU.d.ts → types.d-aGj9QkWt.d.ts} +1 -1
- package/dist/node-cjs/publicUtils.cjs +405 -405
- package/package.json +4 -3
- /package/dist/node/chunks/{dep-kjUoH5nk.js → dep-CrWVpuYf.js} +0 -0
- /package/dist/node/chunks/{dep-8a-6Quh6.js → dep-IQS-Za7F.js} +0 -0
@@ -13,6 +13,7 @@ import * as require$$0$2 from 'fs';
|
|
13
13
|
import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, readdirSync } from 'fs';
|
14
14
|
import require$$0$5 from 'events';
|
15
15
|
import require$$5 from 'assert';
|
16
|
+
import { exec, execSync } from 'node:child_process';
|
16
17
|
import { createServer as createServer$3, STATUS_CODES, get as get$2 } from 'node:http';
|
17
18
|
import { createServer as createServer$2, get as get$1 } from 'node:https';
|
18
19
|
import require$$0$6 from 'util';
|
@@ -23,10 +24,9 @@ import require$$0$7 from 'stream';
|
|
23
24
|
import require$$2 from 'os';
|
24
25
|
import require$$2$1 from 'child_process';
|
25
26
|
import os$4 from 'node:os';
|
26
|
-
import { exec } from 'node:child_process';
|
27
27
|
import { createHash as createHash$2 } from 'node:crypto';
|
28
28
|
import { promises } from 'node:dns';
|
29
|
-
import require$$
|
29
|
+
import require$$3$1 from 'crypto';
|
30
30
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
31
31
|
import assert$1 from 'node:assert';
|
32
32
|
import v8 from 'node:v8';
|
@@ -36,11 +36,11 @@ import { EventEmitter as EventEmitter$4 } from 'node:events';
|
|
36
36
|
import { parseAst, parseAstAsync } from 'rollup/parseAst';
|
37
37
|
import * as qs from 'querystring';
|
38
38
|
import readline from 'node:readline';
|
39
|
-
import
|
40
|
-
import require$$0$
|
39
|
+
import zlib$1 from 'zlib';
|
40
|
+
import require$$0$a from 'buffer';
|
41
41
|
import require$$1$1 from 'https';
|
42
42
|
import require$$4$2 from 'tls';
|
43
|
-
import
|
43
|
+
import { gzip } from 'node:zlib';
|
44
44
|
|
45
45
|
import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
|
46
46
|
import { dirname as __cjs_dirname } from 'node:path';
|
@@ -10827,7 +10827,7 @@ function remapping(input, loader, options) {
|
|
10827
10827
|
|
10828
10828
|
var src$2 = {exports: {}};
|
10829
10829
|
|
10830
|
-
var
|
10830
|
+
var browser$3 = {exports: {}};
|
10831
10831
|
|
10832
10832
|
/**
|
10833
10833
|
* Helpers.
|
@@ -11282,281 +11282,6 @@ function requireCommon () {
|
|
11282
11282
|
return common$b;
|
11283
11283
|
}
|
11284
11284
|
|
11285
|
-
/**
|
11286
|
-
* Module dependencies.
|
11287
|
-
*/
|
11288
|
-
|
11289
|
-
var hasRequiredNode$1;
|
11290
|
-
|
11291
|
-
function requireNode$1 () {
|
11292
|
-
if (hasRequiredNode$1) return node$1.exports;
|
11293
|
-
hasRequiredNode$1 = 1;
|
11294
|
-
(function (module, exports) {
|
11295
|
-
const tty = require$$0$3;
|
11296
|
-
const util = require$$0$6;
|
11297
|
-
|
11298
|
-
/**
|
11299
|
-
* This is the Node.js implementation of `debug()`.
|
11300
|
-
*/
|
11301
|
-
|
11302
|
-
exports.init = init;
|
11303
|
-
exports.log = log;
|
11304
|
-
exports.formatArgs = formatArgs;
|
11305
|
-
exports.save = save;
|
11306
|
-
exports.load = load;
|
11307
|
-
exports.useColors = useColors;
|
11308
|
-
exports.destroy = util.deprecate(
|
11309
|
-
() => {},
|
11310
|
-
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
11311
|
-
);
|
11312
|
-
|
11313
|
-
/**
|
11314
|
-
* Colors.
|
11315
|
-
*/
|
11316
|
-
|
11317
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
11318
|
-
|
11319
|
-
try {
|
11320
|
-
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
11321
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
11322
|
-
const supportsColor = require('supports-color');
|
11323
|
-
|
11324
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
11325
|
-
exports.colors = [
|
11326
|
-
20,
|
11327
|
-
21,
|
11328
|
-
26,
|
11329
|
-
27,
|
11330
|
-
32,
|
11331
|
-
33,
|
11332
|
-
38,
|
11333
|
-
39,
|
11334
|
-
40,
|
11335
|
-
41,
|
11336
|
-
42,
|
11337
|
-
43,
|
11338
|
-
44,
|
11339
|
-
45,
|
11340
|
-
56,
|
11341
|
-
57,
|
11342
|
-
62,
|
11343
|
-
63,
|
11344
|
-
68,
|
11345
|
-
69,
|
11346
|
-
74,
|
11347
|
-
75,
|
11348
|
-
76,
|
11349
|
-
77,
|
11350
|
-
78,
|
11351
|
-
79,
|
11352
|
-
80,
|
11353
|
-
81,
|
11354
|
-
92,
|
11355
|
-
93,
|
11356
|
-
98,
|
11357
|
-
99,
|
11358
|
-
112,
|
11359
|
-
113,
|
11360
|
-
128,
|
11361
|
-
129,
|
11362
|
-
134,
|
11363
|
-
135,
|
11364
|
-
148,
|
11365
|
-
149,
|
11366
|
-
160,
|
11367
|
-
161,
|
11368
|
-
162,
|
11369
|
-
163,
|
11370
|
-
164,
|
11371
|
-
165,
|
11372
|
-
166,
|
11373
|
-
167,
|
11374
|
-
168,
|
11375
|
-
169,
|
11376
|
-
170,
|
11377
|
-
171,
|
11378
|
-
172,
|
11379
|
-
173,
|
11380
|
-
178,
|
11381
|
-
179,
|
11382
|
-
184,
|
11383
|
-
185,
|
11384
|
-
196,
|
11385
|
-
197,
|
11386
|
-
198,
|
11387
|
-
199,
|
11388
|
-
200,
|
11389
|
-
201,
|
11390
|
-
202,
|
11391
|
-
203,
|
11392
|
-
204,
|
11393
|
-
205,
|
11394
|
-
206,
|
11395
|
-
207,
|
11396
|
-
208,
|
11397
|
-
209,
|
11398
|
-
214,
|
11399
|
-
215,
|
11400
|
-
220,
|
11401
|
-
221
|
11402
|
-
];
|
11403
|
-
}
|
11404
|
-
} catch (error) {
|
11405
|
-
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
11406
|
-
}
|
11407
|
-
|
11408
|
-
/**
|
11409
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
11410
|
-
*
|
11411
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
11412
|
-
*/
|
11413
|
-
|
11414
|
-
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
11415
|
-
return /^debug_/i.test(key);
|
11416
|
-
}).reduce((obj, key) => {
|
11417
|
-
// Camel-case
|
11418
|
-
const prop = key
|
11419
|
-
.substring(6)
|
11420
|
-
.toLowerCase()
|
11421
|
-
.replace(/_([a-z])/g, (_, k) => {
|
11422
|
-
return k.toUpperCase();
|
11423
|
-
});
|
11424
|
-
|
11425
|
-
// Coerce string value into JS value
|
11426
|
-
let val = process.env[key];
|
11427
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
11428
|
-
val = true;
|
11429
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
11430
|
-
val = false;
|
11431
|
-
} else if (val === 'null') {
|
11432
|
-
val = null;
|
11433
|
-
} else {
|
11434
|
-
val = Number(val);
|
11435
|
-
}
|
11436
|
-
|
11437
|
-
obj[prop] = val;
|
11438
|
-
return obj;
|
11439
|
-
}, {});
|
11440
|
-
|
11441
|
-
/**
|
11442
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
11443
|
-
*/
|
11444
|
-
|
11445
|
-
function useColors() {
|
11446
|
-
return 'colors' in exports.inspectOpts ?
|
11447
|
-
Boolean(exports.inspectOpts.colors) :
|
11448
|
-
tty.isatty(process.stderr.fd);
|
11449
|
-
}
|
11450
|
-
|
11451
|
-
/**
|
11452
|
-
* Adds ANSI color escape codes if enabled.
|
11453
|
-
*
|
11454
|
-
* @api public
|
11455
|
-
*/
|
11456
|
-
|
11457
|
-
function formatArgs(args) {
|
11458
|
-
const {namespace: name, useColors} = this;
|
11459
|
-
|
11460
|
-
if (useColors) {
|
11461
|
-
const c = this.color;
|
11462
|
-
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
11463
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
11464
|
-
|
11465
|
-
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
11466
|
-
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
11467
|
-
} else {
|
11468
|
-
args[0] = getDate() + name + ' ' + args[0];
|
11469
|
-
}
|
11470
|
-
}
|
11471
|
-
|
11472
|
-
function getDate() {
|
11473
|
-
if (exports.inspectOpts.hideDate) {
|
11474
|
-
return '';
|
11475
|
-
}
|
11476
|
-
return new Date().toISOString() + ' ';
|
11477
|
-
}
|
11478
|
-
|
11479
|
-
/**
|
11480
|
-
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
11481
|
-
*/
|
11482
|
-
|
11483
|
-
function log(...args) {
|
11484
|
-
return process.stderr.write(util.format(...args) + '\n');
|
11485
|
-
}
|
11486
|
-
|
11487
|
-
/**
|
11488
|
-
* Save `namespaces`.
|
11489
|
-
*
|
11490
|
-
* @param {String} namespaces
|
11491
|
-
* @api private
|
11492
|
-
*/
|
11493
|
-
function save(namespaces) {
|
11494
|
-
if (namespaces) {
|
11495
|
-
process.env.DEBUG = namespaces;
|
11496
|
-
} else {
|
11497
|
-
// If you set a process.env field to null or undefined, it gets cast to the
|
11498
|
-
// string 'null' or 'undefined'. Just delete instead.
|
11499
|
-
delete process.env.DEBUG;
|
11500
|
-
}
|
11501
|
-
}
|
11502
|
-
|
11503
|
-
/**
|
11504
|
-
* Load `namespaces`.
|
11505
|
-
*
|
11506
|
-
* @return {String} returns the previously persisted debug modes
|
11507
|
-
* @api private
|
11508
|
-
*/
|
11509
|
-
|
11510
|
-
function load() {
|
11511
|
-
return process.env.DEBUG;
|
11512
|
-
}
|
11513
|
-
|
11514
|
-
/**
|
11515
|
-
* Init logic for `debug` instances.
|
11516
|
-
*
|
11517
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
11518
|
-
* differently for a particular `debug` instance.
|
11519
|
-
*/
|
11520
|
-
|
11521
|
-
function init(debug) {
|
11522
|
-
debug.inspectOpts = {};
|
11523
|
-
|
11524
|
-
const keys = Object.keys(exports.inspectOpts);
|
11525
|
-
for (let i = 0; i < keys.length; i++) {
|
11526
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
11527
|
-
}
|
11528
|
-
}
|
11529
|
-
|
11530
|
-
module.exports = requireCommon()(exports);
|
11531
|
-
|
11532
|
-
const {formatters} = module.exports;
|
11533
|
-
|
11534
|
-
/**
|
11535
|
-
* Map %o to `util.inspect()`, all on a single line.
|
11536
|
-
*/
|
11537
|
-
|
11538
|
-
formatters.o = function (v) {
|
11539
|
-
this.inspectOpts.colors = this.useColors;
|
11540
|
-
return util.inspect(v, this.inspectOpts)
|
11541
|
-
.split('\n')
|
11542
|
-
.map(str => str.trim())
|
11543
|
-
.join(' ');
|
11544
|
-
};
|
11545
|
-
|
11546
|
-
/**
|
11547
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
11548
|
-
*/
|
11549
|
-
|
11550
|
-
formatters.O = function (v) {
|
11551
|
-
this.inspectOpts.colors = this.useColors;
|
11552
|
-
return util.inspect(v, this.inspectOpts);
|
11553
|
-
};
|
11554
|
-
} (node$1, node$1.exports));
|
11555
|
-
return node$1.exports;
|
11556
|
-
}
|
11557
|
-
|
11558
|
-
var browser$3 = {exports: {}};
|
11559
|
-
|
11560
11285
|
/* eslint-env browser */
|
11561
11286
|
|
11562
11287
|
var hasRequiredBrowser$1;
|
@@ -11836,6 +11561,281 @@ function requireBrowser$1 () {
|
|
11836
11561
|
return browser$3.exports;
|
11837
11562
|
}
|
11838
11563
|
|
11564
|
+
var node$1 = {exports: {}};
|
11565
|
+
|
11566
|
+
/**
|
11567
|
+
* Module dependencies.
|
11568
|
+
*/
|
11569
|
+
|
11570
|
+
var hasRequiredNode$1;
|
11571
|
+
|
11572
|
+
function requireNode$1 () {
|
11573
|
+
if (hasRequiredNode$1) return node$1.exports;
|
11574
|
+
hasRequiredNode$1 = 1;
|
11575
|
+
(function (module, exports) {
|
11576
|
+
const tty = require$$0$3;
|
11577
|
+
const util = require$$0$6;
|
11578
|
+
|
11579
|
+
/**
|
11580
|
+
* This is the Node.js implementation of `debug()`.
|
11581
|
+
*/
|
11582
|
+
|
11583
|
+
exports.init = init;
|
11584
|
+
exports.log = log;
|
11585
|
+
exports.formatArgs = formatArgs;
|
11586
|
+
exports.save = save;
|
11587
|
+
exports.load = load;
|
11588
|
+
exports.useColors = useColors;
|
11589
|
+
exports.destroy = util.deprecate(
|
11590
|
+
() => {},
|
11591
|
+
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
11592
|
+
);
|
11593
|
+
|
11594
|
+
/**
|
11595
|
+
* Colors.
|
11596
|
+
*/
|
11597
|
+
|
11598
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
11599
|
+
|
11600
|
+
try {
|
11601
|
+
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
11602
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
11603
|
+
const supportsColor = require('supports-color');
|
11604
|
+
|
11605
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
11606
|
+
exports.colors = [
|
11607
|
+
20,
|
11608
|
+
21,
|
11609
|
+
26,
|
11610
|
+
27,
|
11611
|
+
32,
|
11612
|
+
33,
|
11613
|
+
38,
|
11614
|
+
39,
|
11615
|
+
40,
|
11616
|
+
41,
|
11617
|
+
42,
|
11618
|
+
43,
|
11619
|
+
44,
|
11620
|
+
45,
|
11621
|
+
56,
|
11622
|
+
57,
|
11623
|
+
62,
|
11624
|
+
63,
|
11625
|
+
68,
|
11626
|
+
69,
|
11627
|
+
74,
|
11628
|
+
75,
|
11629
|
+
76,
|
11630
|
+
77,
|
11631
|
+
78,
|
11632
|
+
79,
|
11633
|
+
80,
|
11634
|
+
81,
|
11635
|
+
92,
|
11636
|
+
93,
|
11637
|
+
98,
|
11638
|
+
99,
|
11639
|
+
112,
|
11640
|
+
113,
|
11641
|
+
128,
|
11642
|
+
129,
|
11643
|
+
134,
|
11644
|
+
135,
|
11645
|
+
148,
|
11646
|
+
149,
|
11647
|
+
160,
|
11648
|
+
161,
|
11649
|
+
162,
|
11650
|
+
163,
|
11651
|
+
164,
|
11652
|
+
165,
|
11653
|
+
166,
|
11654
|
+
167,
|
11655
|
+
168,
|
11656
|
+
169,
|
11657
|
+
170,
|
11658
|
+
171,
|
11659
|
+
172,
|
11660
|
+
173,
|
11661
|
+
178,
|
11662
|
+
179,
|
11663
|
+
184,
|
11664
|
+
185,
|
11665
|
+
196,
|
11666
|
+
197,
|
11667
|
+
198,
|
11668
|
+
199,
|
11669
|
+
200,
|
11670
|
+
201,
|
11671
|
+
202,
|
11672
|
+
203,
|
11673
|
+
204,
|
11674
|
+
205,
|
11675
|
+
206,
|
11676
|
+
207,
|
11677
|
+
208,
|
11678
|
+
209,
|
11679
|
+
214,
|
11680
|
+
215,
|
11681
|
+
220,
|
11682
|
+
221
|
11683
|
+
];
|
11684
|
+
}
|
11685
|
+
} catch (error) {
|
11686
|
+
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
11687
|
+
}
|
11688
|
+
|
11689
|
+
/**
|
11690
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
11691
|
+
*
|
11692
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
11693
|
+
*/
|
11694
|
+
|
11695
|
+
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
11696
|
+
return /^debug_/i.test(key);
|
11697
|
+
}).reduce((obj, key) => {
|
11698
|
+
// Camel-case
|
11699
|
+
const prop = key
|
11700
|
+
.substring(6)
|
11701
|
+
.toLowerCase()
|
11702
|
+
.replace(/_([a-z])/g, (_, k) => {
|
11703
|
+
return k.toUpperCase();
|
11704
|
+
});
|
11705
|
+
|
11706
|
+
// Coerce string value into JS value
|
11707
|
+
let val = process.env[key];
|
11708
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
11709
|
+
val = true;
|
11710
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
11711
|
+
val = false;
|
11712
|
+
} else if (val === 'null') {
|
11713
|
+
val = null;
|
11714
|
+
} else {
|
11715
|
+
val = Number(val);
|
11716
|
+
}
|
11717
|
+
|
11718
|
+
obj[prop] = val;
|
11719
|
+
return obj;
|
11720
|
+
}, {});
|
11721
|
+
|
11722
|
+
/**
|
11723
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
11724
|
+
*/
|
11725
|
+
|
11726
|
+
function useColors() {
|
11727
|
+
return 'colors' in exports.inspectOpts ?
|
11728
|
+
Boolean(exports.inspectOpts.colors) :
|
11729
|
+
tty.isatty(process.stderr.fd);
|
11730
|
+
}
|
11731
|
+
|
11732
|
+
/**
|
11733
|
+
* Adds ANSI color escape codes if enabled.
|
11734
|
+
*
|
11735
|
+
* @api public
|
11736
|
+
*/
|
11737
|
+
|
11738
|
+
function formatArgs(args) {
|
11739
|
+
const {namespace: name, useColors} = this;
|
11740
|
+
|
11741
|
+
if (useColors) {
|
11742
|
+
const c = this.color;
|
11743
|
+
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
11744
|
+
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
11745
|
+
|
11746
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
11747
|
+
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
11748
|
+
} else {
|
11749
|
+
args[0] = getDate() + name + ' ' + args[0];
|
11750
|
+
}
|
11751
|
+
}
|
11752
|
+
|
11753
|
+
function getDate() {
|
11754
|
+
if (exports.inspectOpts.hideDate) {
|
11755
|
+
return '';
|
11756
|
+
}
|
11757
|
+
return new Date().toISOString() + ' ';
|
11758
|
+
}
|
11759
|
+
|
11760
|
+
/**
|
11761
|
+
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
11762
|
+
*/
|
11763
|
+
|
11764
|
+
function log(...args) {
|
11765
|
+
return process.stderr.write(util.format(...args) + '\n');
|
11766
|
+
}
|
11767
|
+
|
11768
|
+
/**
|
11769
|
+
* Save `namespaces`.
|
11770
|
+
*
|
11771
|
+
* @param {String} namespaces
|
11772
|
+
* @api private
|
11773
|
+
*/
|
11774
|
+
function save(namespaces) {
|
11775
|
+
if (namespaces) {
|
11776
|
+
process.env.DEBUG = namespaces;
|
11777
|
+
} else {
|
11778
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
11779
|
+
// string 'null' or 'undefined'. Just delete instead.
|
11780
|
+
delete process.env.DEBUG;
|
11781
|
+
}
|
11782
|
+
}
|
11783
|
+
|
11784
|
+
/**
|
11785
|
+
* Load `namespaces`.
|
11786
|
+
*
|
11787
|
+
* @return {String} returns the previously persisted debug modes
|
11788
|
+
* @api private
|
11789
|
+
*/
|
11790
|
+
|
11791
|
+
function load() {
|
11792
|
+
return process.env.DEBUG;
|
11793
|
+
}
|
11794
|
+
|
11795
|
+
/**
|
11796
|
+
* Init logic for `debug` instances.
|
11797
|
+
*
|
11798
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
11799
|
+
* differently for a particular `debug` instance.
|
11800
|
+
*/
|
11801
|
+
|
11802
|
+
function init(debug) {
|
11803
|
+
debug.inspectOpts = {};
|
11804
|
+
|
11805
|
+
const keys = Object.keys(exports.inspectOpts);
|
11806
|
+
for (let i = 0; i < keys.length; i++) {
|
11807
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
11808
|
+
}
|
11809
|
+
}
|
11810
|
+
|
11811
|
+
module.exports = requireCommon()(exports);
|
11812
|
+
|
11813
|
+
const {formatters} = module.exports;
|
11814
|
+
|
11815
|
+
/**
|
11816
|
+
* Map %o to `util.inspect()`, all on a single line.
|
11817
|
+
*/
|
11818
|
+
|
11819
|
+
formatters.o = function (v) {
|
11820
|
+
this.inspectOpts.colors = this.useColors;
|
11821
|
+
return util.inspect(v, this.inspectOpts)
|
11822
|
+
.split('\n')
|
11823
|
+
.map(str => str.trim())
|
11824
|
+
.join(' ');
|
11825
|
+
};
|
11826
|
+
|
11827
|
+
/**
|
11828
|
+
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
11829
|
+
*/
|
11830
|
+
|
11831
|
+
formatters.O = function (v) {
|
11832
|
+
this.inspectOpts.colors = this.useColors;
|
11833
|
+
return util.inspect(v, this.inspectOpts);
|
11834
|
+
};
|
11835
|
+
} (node$1, node$1.exports));
|
11836
|
+
return node$1.exports;
|
11837
|
+
}
|
11838
|
+
|
11839
11839
|
/**
|
11840
11840
|
* Detect Electron renderer / nwjs process, which is node, but we should
|
11841
11841
|
* treat as a browser.
|
@@ -11858,7 +11858,7 @@ if (process.versions.pnp) {
|
|
11858
11858
|
catch { }
|
11859
11859
|
}
|
11860
11860
|
function invalidatePackageData(packageCache, pkgPath) {
|
11861
|
-
const pkgDir = path$o.dirname(pkgPath);
|
11861
|
+
const pkgDir = normalizePath$3(path$o.dirname(pkgPath));
|
11862
11862
|
packageCache.forEach((pkg, cacheKey) => {
|
11863
11863
|
if (pkg.dir === pkgDir) {
|
11864
11864
|
packageCache.delete(cacheKey);
|
@@ -11946,27 +11946,34 @@ function findNearestMainPackageData(basedir, packageCache) {
|
|
11946
11946
|
}
|
11947
11947
|
function loadPackageData(pkgPath) {
|
11948
11948
|
const data = JSON.parse(fs$l.readFileSync(pkgPath, 'utf-8'));
|
11949
|
-
const pkgDir = path$o.dirname(pkgPath);
|
11949
|
+
const pkgDir = normalizePath$3(path$o.dirname(pkgPath));
|
11950
11950
|
const { sideEffects } = data;
|
11951
11951
|
let hasSideEffects;
|
11952
11952
|
if (typeof sideEffects === 'boolean') {
|
11953
11953
|
hasSideEffects = () => sideEffects;
|
11954
11954
|
}
|
11955
11955
|
else if (Array.isArray(sideEffects)) {
|
11956
|
-
|
11957
|
-
|
11958
|
-
|
11959
|
-
|
11960
|
-
|
11961
|
-
|
11962
|
-
|
11963
|
-
|
11964
|
-
|
11965
|
-
|
11966
|
-
|
11967
|
-
|
11968
|
-
|
11969
|
-
|
11956
|
+
if (sideEffects.length <= 0) {
|
11957
|
+
// createFilter always returns true if `includes` is an empty array
|
11958
|
+
// but here we want it to always return false
|
11959
|
+
hasSideEffects = () => false;
|
11960
|
+
}
|
11961
|
+
else {
|
11962
|
+
const finalPackageSideEffects = sideEffects.map((sideEffect) => {
|
11963
|
+
/*
|
11964
|
+
* The array accepts simple glob patterns to the relevant files... Patterns like *.css, which do not include a /, will be treated like **\/*.css.
|
11965
|
+
* https://webpack.js.org/guides/tree-shaking/
|
11966
|
+
* https://github.com/vitejs/vite/pull/11807
|
11967
|
+
*/
|
11968
|
+
if (sideEffect.includes('/')) {
|
11969
|
+
return sideEffect;
|
11970
|
+
}
|
11971
|
+
return `**/${sideEffect}`;
|
11972
|
+
});
|
11973
|
+
hasSideEffects = createFilter(finalPackageSideEffects, null, {
|
11974
|
+
resolve: pkgDir,
|
11975
|
+
});
|
11976
|
+
}
|
11970
11977
|
}
|
11971
11978
|
else {
|
11972
11979
|
hasSideEffects = () => null;
|
@@ -12638,6 +12645,8 @@ function joinSrcset(ret) {
|
|
12638
12645
|
.map(({ url, descriptor }) => url + (descriptor ? ` ${descriptor}` : ''))
|
12639
12646
|
.join(', ');
|
12640
12647
|
}
|
12648
|
+
// NOTE: The returned `url` should perhaps be decoded so all handled URLs within Vite are consistently decoded.
|
12649
|
+
// However, this may also require a refactor for `cssReplacer` to accept decoded URLs instead.
|
12641
12650
|
function splitSrcSetDescriptor(srcs) {
|
12642
12651
|
return splitSrcSet(srcs)
|
12643
12652
|
.map((s) => {
|
@@ -13162,6 +13171,13 @@ function displayTime(time) {
|
|
13162
13171
|
// display: {X}m {Y}s
|
13163
13172
|
return `${mins}m${seconds < 1 ? '' : ` ${seconds.toFixed(0)}s`}`;
|
13164
13173
|
}
|
13174
|
+
/**
|
13175
|
+
* Like `encodeURI`, but only replacing `%` as `%25`. This is useful for environments
|
13176
|
+
* that can handle un-encoded URIs, where `%` is the only ambiguous character.
|
13177
|
+
*/
|
13178
|
+
function partialEncodeURI(uri) {
|
13179
|
+
return uri.replaceAll('%', '%25');
|
13180
|
+
}
|
13165
13181
|
|
13166
13182
|
/* eslint no-console: 0 */
|
13167
13183
|
const LogLevels = {
|
@@ -14607,6 +14623,13 @@ const debug$h = createDebugger('vite:esbuild');
|
|
14607
14623
|
const IIFE_BEGIN_RE = /(const|var)\s+\S+\s*=\s*function\([^()]*\)\s*\{\s*"use strict";/;
|
14608
14624
|
const validExtensionRE = /\.\w+$/;
|
14609
14625
|
const jsxExtensionsRE = /\.(?:j|t)sx\b/;
|
14626
|
+
// the final build should always support dynamic import and import.meta.
|
14627
|
+
// if they need to be polyfilled, plugin-legacy should be used.
|
14628
|
+
// plugin-legacy detects these two features when checking for modern code.
|
14629
|
+
const defaultEsbuildSupported = {
|
14630
|
+
'dynamic-import': true,
|
14631
|
+
'import-meta': true,
|
14632
|
+
};
|
14610
14633
|
let server;
|
14611
14634
|
async function transformWithEsbuild(code, filename, options, inMap) {
|
14612
14635
|
let loader = options?.loader;
|
@@ -14755,6 +14778,10 @@ function esbuildPlugin(config) {
|
|
14755
14778
|
// Also transforming multiple times with keepNames enabled breaks
|
14756
14779
|
// tree-shaking. (#9164)
|
14757
14780
|
keepNames: false,
|
14781
|
+
supported: {
|
14782
|
+
...defaultEsbuildSupported,
|
14783
|
+
...esbuildTransformOptions.supported,
|
14784
|
+
},
|
14758
14785
|
};
|
14759
14786
|
return {
|
14760
14787
|
name: 'vite:esbuild',
|
@@ -14860,12 +14887,8 @@ function resolveEsbuildTranspileOptions(config, format) {
|
|
14860
14887
|
loader: 'js',
|
14861
14888
|
target: target || undefined,
|
14862
14889
|
format: rollupToEsbuildFormatMap[format],
|
14863
|
-
// the final build should always support dynamic import and import.meta.
|
14864
|
-
// if they need to be polyfilled, plugin-legacy should be used.
|
14865
|
-
// plugin-legacy detects these two features when checking for modern code.
|
14866
14890
|
supported: {
|
14867
|
-
|
14868
|
-
'import-meta': true,
|
14891
|
+
...defaultEsbuildSupported,
|
14869
14892
|
...esbuildOptions.supported,
|
14870
14893
|
},
|
14871
14894
|
};
|
@@ -15281,7 +15304,7 @@ function terserPlugin(config) {
|
|
15281
15304
|
};
|
15282
15305
|
}
|
15283
15306
|
|
15284
|
-
const mimes
|
15307
|
+
const mimes = {
|
15285
15308
|
"3g2": "video/3gpp2",
|
15286
15309
|
"3gp": "video/3gpp",
|
15287
15310
|
"3gpp": "video/3gpp",
|
@@ -15721,7 +15744,7 @@ const mimes$1 = {
|
|
15721
15744
|
function lookup(extn) {
|
15722
15745
|
let tmp = ('' + extn).trim().toLowerCase();
|
15723
15746
|
let idx = tmp.lastIndexOf('.');
|
15724
|
-
return mimes
|
15747
|
+
return mimes[!~idx ? tmp : tmp.substring(++idx)];
|
15725
15748
|
}
|
15726
15749
|
|
15727
15750
|
const publicFilesMap = new WeakMap();
|
@@ -15774,11 +15797,11 @@ const generatedAssets = new WeakMap();
|
|
15774
15797
|
// add own dictionary entry by directly assigning mrmime
|
15775
15798
|
function registerCustomMime() {
|
15776
15799
|
// https://github.com/lukeed/mrmime/issues/3
|
15777
|
-
mimes
|
15800
|
+
mimes['ico'] = 'image/x-icon';
|
15778
15801
|
// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#flac
|
15779
|
-
mimes
|
15802
|
+
mimes['flac'] = 'audio/flac';
|
15780
15803
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
15781
|
-
mimes
|
15804
|
+
mimes['eot'] = 'application/vnd.ms-fontobject';
|
15782
15805
|
}
|
15783
15806
|
function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
15784
15807
|
const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(opts.format, config.isWorker);
|
@@ -15798,7 +15821,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
|
15798
15821
|
const filename = file + postfix;
|
15799
15822
|
const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
|
15800
15823
|
const replacementString = typeof replacement === 'string'
|
15801
|
-
? JSON.stringify(replacement).slice(1, -1)
|
15824
|
+
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
15802
15825
|
: `"+${replacement.runtime}+"`;
|
15803
15826
|
s.update(match.index, match.index + full.length, replacementString);
|
15804
15827
|
}
|
@@ -15811,7 +15834,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
|
15811
15834
|
const publicUrl = publicAssetUrlMap.get(hash).slice(1);
|
15812
15835
|
const replacement = toOutputFilePathInJS(publicUrl, 'public', chunk.fileName, 'js', config, toRelativeRuntime);
|
15813
15836
|
const replacementString = typeof replacement === 'string'
|
15814
|
-
? JSON.stringify(replacement).slice(1, -1)
|
15837
|
+
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
15815
15838
|
: `"+${replacement.runtime}+"`;
|
15816
15839
|
s.update(match.index, match.index + full.length, replacementString);
|
15817
15840
|
}
|
@@ -15876,7 +15899,14 @@ function assetPlugin(config) {
|
|
15876
15899
|
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
15877
15900
|
}
|
15878
15901
|
}
|
15879
|
-
return
|
15902
|
+
return {
|
15903
|
+
code: `export default ${JSON.stringify(url.startsWith('data:') ? url : encodeURI(url))}`,
|
15904
|
+
// Force rollup to keep this module from being shared between other entry points if it's an entrypoint.
|
15905
|
+
// If the resulting chunk is empty, it will be removed in generateBundle.
|
15906
|
+
moduleSideEffects: config.command === 'build' && this.getModuleInfo(id)?.isEntry
|
15907
|
+
? 'no-treeshake'
|
15908
|
+
: false,
|
15909
|
+
};
|
15880
15910
|
},
|
15881
15911
|
renderChunk(code, chunk, opts) {
|
15882
15912
|
const s = renderAssetUrlInJS(this, config, chunk, opts, code);
|
@@ -15893,6 +15923,16 @@ function assetPlugin(config) {
|
|
15893
15923
|
}
|
15894
15924
|
},
|
15895
15925
|
generateBundle(_, bundle) {
|
15926
|
+
// Remove empty entry point file
|
15927
|
+
for (const file in bundle) {
|
15928
|
+
const chunk = bundle[file];
|
15929
|
+
if (chunk.type === 'chunk' &&
|
15930
|
+
chunk.isEntry &&
|
15931
|
+
chunk.moduleIds.length === 1 &&
|
15932
|
+
config.assetsInclude(chunk.moduleIds[0])) {
|
15933
|
+
delete bundle[file];
|
15934
|
+
}
|
15935
|
+
}
|
15896
15936
|
// do not emit assets for SSR build
|
15897
15937
|
if (config.command === 'build' &&
|
15898
15938
|
config.build.ssr &&
|
@@ -15978,7 +16018,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
15978
16018
|
const file = cleanUrl(id);
|
15979
16019
|
const content = await fsp.readFile(file);
|
15980
16020
|
let url;
|
15981
|
-
if (shouldInline(config, file, id, content, forceInline)) {
|
16021
|
+
if (shouldInline(config, file, id, content, pluginContext, forceInline)) {
|
15982
16022
|
if (config.build.lib && isGitLfsPlaceholder(content)) {
|
15983
16023
|
config.logger.warn(colors$1.yellow(`Inlined file ${id} was not downloaded via Git LFS`));
|
15984
16024
|
}
|
@@ -16019,9 +16059,11 @@ async function urlToBuiltUrl(url, importer, config, pluginContext, forceInline)
|
|
16019
16059
|
// skip public check since we just did it above
|
16020
16060
|
true, forceInline);
|
16021
16061
|
}
|
16022
|
-
const shouldInline = (config, file, id, content, forceInline) => {
|
16062
|
+
const shouldInline = (config, file, id, content, pluginContext, forceInline) => {
|
16023
16063
|
if (config.build.lib)
|
16024
16064
|
return true;
|
16065
|
+
if (pluginContext.getModuleInfo(id)?.isEntry)
|
16066
|
+
return false;
|
16025
16067
|
if (forceInline !== undefined)
|
16026
16068
|
return forceInline;
|
16027
16069
|
let limit;
|
@@ -16095,6 +16137,7 @@ function manifestPlugin(config) {
|
|
16095
16137
|
function createChunk(chunk) {
|
16096
16138
|
const manifestChunk = {
|
16097
16139
|
file: chunk.fileName,
|
16140
|
+
name: chunk.name,
|
16098
16141
|
};
|
16099
16142
|
if (chunk.facadeModuleId) {
|
16100
16143
|
manifestChunk.src = getChunkName(chunk);
|
@@ -19877,8 +19920,8 @@ function fastqueue (context, worker, concurrency) {
|
|
19877
19920
|
|
19878
19921
|
var self = {
|
19879
19922
|
push: push,
|
19880
|
-
drain: noop$
|
19881
|
-
saturated: noop$
|
19923
|
+
drain: noop$3,
|
19924
|
+
saturated: noop$3,
|
19882
19925
|
pause: pause,
|
19883
19926
|
paused: false,
|
19884
19927
|
concurrency: concurrency,
|
@@ -19888,7 +19931,7 @@ function fastqueue (context, worker, concurrency) {
|
|
19888
19931
|
length: length,
|
19889
19932
|
getQueue: getQueue,
|
19890
19933
|
unshift: unshift,
|
19891
|
-
empty: noop$
|
19934
|
+
empty: noop$3,
|
19892
19935
|
kill: kill,
|
19893
19936
|
killAndDrain: killAndDrain,
|
19894
19937
|
error: error
|
@@ -19947,7 +19990,7 @@ function fastqueue (context, worker, concurrency) {
|
|
19947
19990
|
current.context = context;
|
19948
19991
|
current.release = release;
|
19949
19992
|
current.value = value;
|
19950
|
-
current.callback = done || noop$
|
19993
|
+
current.callback = done || noop$3;
|
19951
19994
|
current.errorHandler = errorHandler;
|
19952
19995
|
|
19953
19996
|
if (_running === self.concurrency || self.paused) {
|
@@ -19971,7 +20014,7 @@ function fastqueue (context, worker, concurrency) {
|
|
19971
20014
|
current.context = context;
|
19972
20015
|
current.release = release;
|
19973
20016
|
current.value = value;
|
19974
|
-
current.callback = done || noop$
|
20017
|
+
current.callback = done || noop$3;
|
19975
20018
|
|
19976
20019
|
if (_running === self.concurrency || self.paused) {
|
19977
20020
|
if (queueHead) {
|
@@ -20015,14 +20058,14 @@ function fastqueue (context, worker, concurrency) {
|
|
20015
20058
|
function kill () {
|
20016
20059
|
queueHead = null;
|
20017
20060
|
queueTail = null;
|
20018
|
-
self.drain = noop$
|
20061
|
+
self.drain = noop$3;
|
20019
20062
|
}
|
20020
20063
|
|
20021
20064
|
function killAndDrain () {
|
20022
20065
|
queueHead = null;
|
20023
20066
|
queueTail = null;
|
20024
20067
|
self.drain();
|
20025
|
-
self.drain = noop$
|
20068
|
+
self.drain = noop$3;
|
20026
20069
|
}
|
20027
20070
|
|
20028
20071
|
function error (handler) {
|
@@ -20030,13 +20073,13 @@ function fastqueue (context, worker, concurrency) {
|
|
20030
20073
|
}
|
20031
20074
|
}
|
20032
20075
|
|
20033
|
-
function noop$
|
20076
|
+
function noop$3 () {}
|
20034
20077
|
|
20035
20078
|
function Task () {
|
20036
20079
|
this.value = null;
|
20037
|
-
this.callback = noop$
|
20080
|
+
this.callback = noop$3;
|
20038
20081
|
this.next = null;
|
20039
|
-
this.release = noop$
|
20082
|
+
this.release = noop$3;
|
20040
20083
|
this.context = null;
|
20041
20084
|
this.errorHandler = null;
|
20042
20085
|
|
@@ -20047,7 +20090,7 @@ function Task () {
|
|
20047
20090
|
var errorHandler = self.errorHandler;
|
20048
20091
|
var val = self.value;
|
20049
20092
|
self.value = null;
|
20050
|
-
self.callback = noop$
|
20093
|
+
self.callback = noop$3;
|
20051
20094
|
if (self.errorHandler) {
|
20052
20095
|
errorHandler(err, val);
|
20053
20096
|
}
|
@@ -20095,7 +20138,7 @@ function queueAsPromised (context, worker, concurrency) {
|
|
20095
20138
|
// Let's fork the promise chain to
|
20096
20139
|
// make the error bubble up to the user but
|
20097
20140
|
// not lead to a unhandledRejection
|
20098
|
-
p.catch(noop$
|
20141
|
+
p.catch(noop$3);
|
20099
20142
|
|
20100
20143
|
return p
|
20101
20144
|
}
|
@@ -20114,7 +20157,7 @@ function queueAsPromised (context, worker, concurrency) {
|
|
20114
20157
|
// Let's fork the promise chain to
|
20115
20158
|
// make the error bubble up to the user but
|
20116
20159
|
// not lead to a unhandledRejection
|
20117
|
-
p.catch(noop$
|
20160
|
+
p.catch(noop$3);
|
20118
20161
|
|
20119
20162
|
return p
|
20120
20163
|
}
|
@@ -29760,7 +29803,7 @@ var require$$4 = {
|
|
29760
29803
|
const fs$9 = require$$0__default;
|
29761
29804
|
const path$9 = require$$0$4;
|
29762
29805
|
const os$2 = require$$2;
|
29763
|
-
const crypto$1 = require$$
|
29806
|
+
const crypto$1 = require$$3$1;
|
29764
29807
|
const packageJson = require$$4;
|
29765
29808
|
|
29766
29809
|
const version$1 = packageJson.version;
|
@@ -30428,7 +30471,7 @@ function traverseNodes(node, visitor) {
|
|
30428
30471
|
}
|
30429
30472
|
async function traverseHtml(html, filePath, visitor) {
|
30430
30473
|
// lazy load compiler
|
30431
|
-
const { parse } = await import('./dep-
|
30474
|
+
const { parse } = await import('./dep-CrWVpuYf.js');
|
30432
30475
|
const ast = parse(html, {
|
30433
30476
|
scriptingEnabled: false,
|
30434
30477
|
sourceCodeLocationInfo: true,
|
@@ -30516,8 +30559,10 @@ function handleParseError(parserError, html, filePath) {
|
|
30516
30559
|
*/
|
30517
30560
|
function buildHtmlPlugin(config) {
|
30518
30561
|
const [preHooks, normalHooks, postHooks] = resolveHtmlTransforms(config.plugins, config.logger);
|
30562
|
+
preHooks.unshift(injectCspNonceMetaTagHook(config));
|
30519
30563
|
preHooks.unshift(preImportMapHook(config));
|
30520
30564
|
preHooks.push(htmlEnvHook(config));
|
30565
|
+
postHooks.push(injectNonceAttributeTagHook(config));
|
30521
30566
|
postHooks.push(postImportMapHook());
|
30522
30567
|
const processedHtml = new Map();
|
30523
30568
|
const isExcludedUrl = (url) => url[0] === '#' || isExternalUrl(url) || isDataUrl(url);
|
@@ -30610,7 +30655,7 @@ function buildHtmlPlugin(config) {
|
|
30610
30655
|
const isPublicFile = !!(url && checkPublicFile(url, config));
|
30611
30656
|
if (isPublicFile) {
|
30612
30657
|
// referencing public dir url, prefix with base
|
30613
|
-
overwriteAttrValue(s, sourceCodeLocation, toOutputPublicFilePath(url));
|
30658
|
+
overwriteAttrValue(s, sourceCodeLocation, partialEncodeURI(toOutputPublicFilePath(url)));
|
30614
30659
|
}
|
30615
30660
|
if (isModule) {
|
30616
30661
|
inlineModuleIndex++;
|
@@ -30654,23 +30699,25 @@ function buildHtmlPlugin(config) {
|
|
30654
30699
|
if (p.value && assetAttrs.includes(attrKey)) {
|
30655
30700
|
if (attrKey === 'srcset') {
|
30656
30701
|
assetUrlsPromises.push((async () => {
|
30657
|
-
const
|
30702
|
+
const processedEncodedUrl = await processSrcSet(p.value, async ({ url }) => {
|
30658
30703
|
const decodedUrl = decodeURI(url);
|
30659
30704
|
if (!isExcludedUrl(decodedUrl)) {
|
30660
30705
|
const result = await processAssetUrl(url);
|
30661
|
-
return result !== decodedUrl
|
30706
|
+
return result !== decodedUrl
|
30707
|
+
? encodeURI(result)
|
30708
|
+
: url;
|
30662
30709
|
}
|
30663
30710
|
return url;
|
30664
30711
|
});
|
30665
|
-
if (
|
30666
|
-
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey),
|
30712
|
+
if (processedEncodedUrl !== p.value) {
|
30713
|
+
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), processedEncodedUrl);
|
30667
30714
|
}
|
30668
30715
|
})());
|
30669
30716
|
}
|
30670
30717
|
else {
|
30671
30718
|
const url = decodeURI(p.value);
|
30672
30719
|
if (checkPublicFile(url, config)) {
|
30673
|
-
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), toOutputPublicFilePath(url));
|
30720
|
+
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURI(toOutputPublicFilePath(url)));
|
30674
30721
|
}
|
30675
30722
|
else if (!isExcludedUrl(url)) {
|
30676
30723
|
if (node.nodeName === 'link' &&
|
@@ -30692,14 +30739,12 @@ function buildHtmlPlugin(config) {
|
|
30692
30739
|
// to `false` to force no inline. If `undefined`, it leaves to the default heuristics.
|
30693
30740
|
const isNoInlineLink = node.nodeName === 'link' &&
|
30694
30741
|
node.attrs.some((p) => p.name === 'rel' &&
|
30695
|
-
p.value
|
30696
|
-
.split(spaceRe)
|
30697
|
-
.some((v) => noInlineLinkRels.has(v.toLowerCase())));
|
30742
|
+
parseRelAttr(p.value).some((v) => noInlineLinkRels.has(v)));
|
30698
30743
|
const shouldInline = isNoInlineLink ? false : undefined;
|
30699
30744
|
assetUrlsPromises.push((async () => {
|
30700
30745
|
const processedUrl = await processAssetUrl(url, shouldInline);
|
30701
30746
|
if (processedUrl !== url) {
|
30702
|
-
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), processedUrl);
|
30747
|
+
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURI(processedUrl));
|
30703
30748
|
}
|
30704
30749
|
})());
|
30705
30750
|
}
|
@@ -30749,10 +30794,10 @@ function buildHtmlPlugin(config) {
|
|
30749
30794
|
// emit <script>import("./aaa")</script> asset
|
30750
30795
|
for (const { start, end, url } of scriptUrls) {
|
30751
30796
|
if (checkPublicFile(url, config)) {
|
30752
|
-
s.update(start, end, toOutputPublicFilePath(url));
|
30797
|
+
s.update(start, end, partialEncodeURI(toOutputPublicFilePath(url)));
|
30753
30798
|
}
|
30754
30799
|
else if (!isExcludedUrl(url)) {
|
30755
|
-
s.update(start, end, await urlToBuiltUrl(url, id, config, this));
|
30800
|
+
s.update(start, end, partialEncodeURI(await urlToBuiltUrl(url, id, config, this)));
|
30756
30801
|
}
|
30757
30802
|
}
|
30758
30803
|
// ignore <link rel="stylesheet"> if its url can't be resolved
|
@@ -30943,13 +30988,13 @@ function buildHtmlPlugin(config) {
|
|
30943
30988
|
if (chunk) {
|
30944
30989
|
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
30945
30990
|
}
|
30946
|
-
return toOutputAssetFilePath(file) + postfix;
|
30991
|
+
return encodeURI(toOutputAssetFilePath(file)) + postfix;
|
30947
30992
|
});
|
30948
30993
|
result = result.replace(publicAssetUrlRE, (_, fileHash) => {
|
30949
30994
|
const publicAssetPath = toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config));
|
30950
|
-
return urlCanParse(publicAssetPath)
|
30995
|
+
return encodeURI(urlCanParse(publicAssetPath)
|
30951
30996
|
? publicAssetPath
|
30952
|
-
: normalizePath$3(publicAssetPath);
|
30997
|
+
: normalizePath$3(publicAssetPath));
|
30953
30998
|
});
|
30954
30999
|
if (chunk && canInlineEntry) {
|
30955
31000
|
inlineEntryChunk.add(chunk.fileName);
|
@@ -30968,6 +31013,9 @@ function buildHtmlPlugin(config) {
|
|
30968
31013
|
},
|
30969
31014
|
};
|
30970
31015
|
}
|
31016
|
+
function parseRelAttr(attr) {
|
31017
|
+
return attr.split(spaceRe).map((v) => v.toLowerCase());
|
31018
|
+
}
|
30971
31019
|
// <tag style="... url(...) or image-set(...) ..."></tag>
|
30972
31020
|
// extract inline styles as virtual css
|
30973
31021
|
function findNeedTransformStyleAttribute(node) {
|
@@ -31030,6 +31078,21 @@ function postImportMapHook() {
|
|
31030
31078
|
return html;
|
31031
31079
|
};
|
31032
31080
|
}
|
31081
|
+
function injectCspNonceMetaTagHook(config) {
|
31082
|
+
return () => {
|
31083
|
+
if (!config.html?.cspNonce)
|
31084
|
+
return;
|
31085
|
+
return [
|
31086
|
+
{
|
31087
|
+
tag: 'meta',
|
31088
|
+
injectTo: 'head',
|
31089
|
+
// use nonce attribute so that it's hidden
|
31090
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce#accessing_nonces_and_nonce_hiding
|
31091
|
+
attrs: { property: 'csp-nonce', nonce: config.html.cspNonce },
|
31092
|
+
},
|
31093
|
+
];
|
31094
|
+
};
|
31095
|
+
}
|
31033
31096
|
/**
|
31034
31097
|
* Support `%ENV_NAME%` syntax in html files
|
31035
31098
|
*/
|
@@ -31071,6 +31134,27 @@ function htmlEnvHook(config) {
|
|
31071
31134
|
});
|
31072
31135
|
};
|
31073
31136
|
}
|
31137
|
+
function injectNonceAttributeTagHook(config) {
|
31138
|
+
const processRelType = new Set(['stylesheet', 'modulepreload', 'preload']);
|
31139
|
+
return async (html, { filename }) => {
|
31140
|
+
const nonce = config.html?.cspNonce;
|
31141
|
+
if (!nonce)
|
31142
|
+
return;
|
31143
|
+
const s = new MagicString(html);
|
31144
|
+
await traverseHtml(html, filename, (node) => {
|
31145
|
+
if (!nodeIsElement(node)) {
|
31146
|
+
return;
|
31147
|
+
}
|
31148
|
+
if (node.nodeName === 'script' ||
|
31149
|
+
(node.nodeName === 'link' &&
|
31150
|
+
node.attrs.some((attr) => attr.name === 'rel' &&
|
31151
|
+
parseRelAttr(attr.value).some((a) => processRelType.has(a))))) {
|
31152
|
+
s.appendRight(node.sourceCodeLocation.startTag.endOffset - 1, ` nonce="${nonce}"`);
|
31153
|
+
}
|
31154
|
+
});
|
31155
|
+
return s.toString();
|
31156
|
+
};
|
31157
|
+
}
|
31074
31158
|
function resolveHtmlTransforms(plugins, logger) {
|
31075
31159
|
const preHooks = [];
|
31076
31160
|
const normalHooks = [];
|
@@ -31539,7 +31623,7 @@ function cssPostPlugin(config) {
|
|
31539
31623
|
map: { mappings: '' },
|
31540
31624
|
// avoid the css module from being tree-shaken so that we can retrieve
|
31541
31625
|
// it in renderChunk()
|
31542
|
-
moduleSideEffects: inlined ? false : 'no-treeshake',
|
31626
|
+
moduleSideEffects: modulesCode || inlined ? false : 'no-treeshake',
|
31543
31627
|
};
|
31544
31628
|
},
|
31545
31629
|
async renderChunk(code, chunk, opts) {
|
@@ -31581,14 +31665,14 @@ function cssPostPlugin(config) {
|
|
31581
31665
|
chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
31582
31666
|
const filename = this.getFileName(fileHash) + postfix;
|
31583
31667
|
chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
|
31584
|
-
return toOutputFilePathInCss(filename, 'asset', cssAssetName, 'css', config, toRelative);
|
31668
|
+
return encodeURI(toOutputFilePathInCss(filename, 'asset', cssAssetName, 'css', config, toRelative));
|
31585
31669
|
});
|
31586
31670
|
// resolve public URL from CSS paths
|
31587
31671
|
if (encodedPublicUrls) {
|
31588
31672
|
const relativePathToPublicFromCSS = path$o.posix.relative(cssAssetDirname, '');
|
31589
31673
|
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
|
31590
31674
|
const publicUrl = publicAssetUrlMap.get(hash).slice(1);
|
31591
|
-
return toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`);
|
31675
|
+
return encodeURI(toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`));
|
31592
31676
|
});
|
31593
31677
|
}
|
31594
31678
|
return chunkCSS;
|
@@ -31639,7 +31723,7 @@ function cssPostPlugin(config) {
|
|
31639
31723
|
.set(referenceId, { originalName: originalFilename });
|
31640
31724
|
const replacement = toOutputFilePathInJS(this.getFileName(referenceId), 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
|
31641
31725
|
const replacementString = typeof replacement === 'string'
|
31642
|
-
? JSON.stringify(replacement).slice(1, -1)
|
31726
|
+
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
31643
31727
|
: `"+${replacement.runtime}+"`;
|
31644
31728
|
s.update(start, end, replacementString);
|
31645
31729
|
}
|
@@ -32173,8 +32257,8 @@ function createCachedImport(imp) {
|
|
32173
32257
|
return cached;
|
32174
32258
|
};
|
32175
32259
|
}
|
32176
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
32177
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
32260
|
+
const importPostcssImport = createCachedImport(() => import('./dep-Q9IC80br.js').then(function (n) { return n.i; }));
|
32261
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BC11CTkQ.js').then(function (n) { return n.i; }));
|
32178
32262
|
const importPostcss = createCachedImport(() => import('postcss'));
|
32179
32263
|
const preprocessorWorkerControllerCache = new WeakMap();
|
32180
32264
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -40470,7 +40554,7 @@ function isVirtualModule(id) {
|
|
40470
40554
|
|
40471
40555
|
var src = {exports: {}};
|
40472
40556
|
|
40473
|
-
var
|
40557
|
+
var browser = {exports: {}};
|
40474
40558
|
|
40475
40559
|
var debug$f = {exports: {}};
|
40476
40560
|
|
@@ -40846,266 +40930,6 @@ function requireDebug () {
|
|
40846
40930
|
return debug$f.exports;
|
40847
40931
|
}
|
40848
40932
|
|
40849
|
-
/**
|
40850
|
-
* Module dependencies.
|
40851
|
-
*/
|
40852
|
-
|
40853
|
-
var hasRequiredNode;
|
40854
|
-
|
40855
|
-
function requireNode () {
|
40856
|
-
if (hasRequiredNode) return node.exports;
|
40857
|
-
hasRequiredNode = 1;
|
40858
|
-
(function (module, exports) {
|
40859
|
-
var tty = require$$0$3;
|
40860
|
-
var util = require$$0$6;
|
40861
|
-
|
40862
|
-
/**
|
40863
|
-
* This is the Node.js implementation of `debug()`.
|
40864
|
-
*
|
40865
|
-
* Expose `debug()` as the module.
|
40866
|
-
*/
|
40867
|
-
|
40868
|
-
exports = module.exports = requireDebug();
|
40869
|
-
exports.init = init;
|
40870
|
-
exports.log = log;
|
40871
|
-
exports.formatArgs = formatArgs;
|
40872
|
-
exports.save = save;
|
40873
|
-
exports.load = load;
|
40874
|
-
exports.useColors = useColors;
|
40875
|
-
|
40876
|
-
/**
|
40877
|
-
* Colors.
|
40878
|
-
*/
|
40879
|
-
|
40880
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
40881
|
-
|
40882
|
-
/**
|
40883
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
40884
|
-
*
|
40885
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
40886
|
-
*/
|
40887
|
-
|
40888
|
-
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
40889
|
-
return /^debug_/i.test(key);
|
40890
|
-
}).reduce(function (obj, key) {
|
40891
|
-
// camel-case
|
40892
|
-
var prop = key
|
40893
|
-
.substring(6)
|
40894
|
-
.toLowerCase()
|
40895
|
-
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
40896
|
-
|
40897
|
-
// coerce string value into JS value
|
40898
|
-
var val = process.env[key];
|
40899
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
40900
|
-
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
40901
|
-
else if (val === 'null') val = null;
|
40902
|
-
else val = Number(val);
|
40903
|
-
|
40904
|
-
obj[prop] = val;
|
40905
|
-
return obj;
|
40906
|
-
}, {});
|
40907
|
-
|
40908
|
-
/**
|
40909
|
-
* The file descriptor to write the `debug()` calls to.
|
40910
|
-
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
40911
|
-
*
|
40912
|
-
* $ DEBUG_FD=3 node script.js 3>debug.log
|
40913
|
-
*/
|
40914
|
-
|
40915
|
-
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
40916
|
-
|
40917
|
-
if (1 !== fd && 2 !== fd) {
|
40918
|
-
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
|
40919
|
-
}
|
40920
|
-
|
40921
|
-
var stream = 1 === fd ? process.stdout :
|
40922
|
-
2 === fd ? process.stderr :
|
40923
|
-
createWritableStdioStream(fd);
|
40924
|
-
|
40925
|
-
/**
|
40926
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
40927
|
-
*/
|
40928
|
-
|
40929
|
-
function useColors() {
|
40930
|
-
return 'colors' in exports.inspectOpts
|
40931
|
-
? Boolean(exports.inspectOpts.colors)
|
40932
|
-
: tty.isatty(fd);
|
40933
|
-
}
|
40934
|
-
|
40935
|
-
/**
|
40936
|
-
* Map %o to `util.inspect()`, all on a single line.
|
40937
|
-
*/
|
40938
|
-
|
40939
|
-
exports.formatters.o = function(v) {
|
40940
|
-
this.inspectOpts.colors = this.useColors;
|
40941
|
-
return util.inspect(v, this.inspectOpts)
|
40942
|
-
.split('\n').map(function(str) {
|
40943
|
-
return str.trim()
|
40944
|
-
}).join(' ');
|
40945
|
-
};
|
40946
|
-
|
40947
|
-
/**
|
40948
|
-
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
40949
|
-
*/
|
40950
|
-
|
40951
|
-
exports.formatters.O = function(v) {
|
40952
|
-
this.inspectOpts.colors = this.useColors;
|
40953
|
-
return util.inspect(v, this.inspectOpts);
|
40954
|
-
};
|
40955
|
-
|
40956
|
-
/**
|
40957
|
-
* Adds ANSI color escape codes if enabled.
|
40958
|
-
*
|
40959
|
-
* @api public
|
40960
|
-
*/
|
40961
|
-
|
40962
|
-
function formatArgs(args) {
|
40963
|
-
var name = this.namespace;
|
40964
|
-
var useColors = this.useColors;
|
40965
|
-
|
40966
|
-
if (useColors) {
|
40967
|
-
var c = this.color;
|
40968
|
-
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
|
40969
|
-
|
40970
|
-
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
40971
|
-
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
40972
|
-
} else {
|
40973
|
-
args[0] = new Date().toUTCString()
|
40974
|
-
+ ' ' + name + ' ' + args[0];
|
40975
|
-
}
|
40976
|
-
}
|
40977
|
-
|
40978
|
-
/**
|
40979
|
-
* Invokes `util.format()` with the specified arguments and writes to `stream`.
|
40980
|
-
*/
|
40981
|
-
|
40982
|
-
function log() {
|
40983
|
-
return stream.write(util.format.apply(util, arguments) + '\n');
|
40984
|
-
}
|
40985
|
-
|
40986
|
-
/**
|
40987
|
-
* Save `namespaces`.
|
40988
|
-
*
|
40989
|
-
* @param {String} namespaces
|
40990
|
-
* @api private
|
40991
|
-
*/
|
40992
|
-
|
40993
|
-
function save(namespaces) {
|
40994
|
-
if (null == namespaces) {
|
40995
|
-
// If you set a process.env field to null or undefined, it gets cast to the
|
40996
|
-
// string 'null' or 'undefined'. Just delete instead.
|
40997
|
-
delete process.env.DEBUG;
|
40998
|
-
} else {
|
40999
|
-
process.env.DEBUG = namespaces;
|
41000
|
-
}
|
41001
|
-
}
|
41002
|
-
|
41003
|
-
/**
|
41004
|
-
* Load `namespaces`.
|
41005
|
-
*
|
41006
|
-
* @return {String} returns the previously persisted debug modes
|
41007
|
-
* @api private
|
41008
|
-
*/
|
41009
|
-
|
41010
|
-
function load() {
|
41011
|
-
return process.env.DEBUG;
|
41012
|
-
}
|
41013
|
-
|
41014
|
-
/**
|
41015
|
-
* Copied from `node/src/node.js`.
|
41016
|
-
*
|
41017
|
-
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
41018
|
-
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
41019
|
-
*/
|
41020
|
-
|
41021
|
-
function createWritableStdioStream (fd) {
|
41022
|
-
var stream;
|
41023
|
-
var tty_wrap = process.binding('tty_wrap');
|
41024
|
-
|
41025
|
-
// Note stream._type is used for test-module-load-list.js
|
41026
|
-
|
41027
|
-
switch (tty_wrap.guessHandleType(fd)) {
|
41028
|
-
case 'TTY':
|
41029
|
-
stream = new tty.WriteStream(fd);
|
41030
|
-
stream._type = 'tty';
|
41031
|
-
|
41032
|
-
// Hack to have stream not keep the event loop alive.
|
41033
|
-
// See https://github.com/joyent/node/issues/1726
|
41034
|
-
if (stream._handle && stream._handle.unref) {
|
41035
|
-
stream._handle.unref();
|
41036
|
-
}
|
41037
|
-
break;
|
41038
|
-
|
41039
|
-
case 'FILE':
|
41040
|
-
var fs = require$$0__default;
|
41041
|
-
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
41042
|
-
stream._type = 'fs';
|
41043
|
-
break;
|
41044
|
-
|
41045
|
-
case 'PIPE':
|
41046
|
-
case 'TCP':
|
41047
|
-
var net = require$$4$1;
|
41048
|
-
stream = new net.Socket({
|
41049
|
-
fd: fd,
|
41050
|
-
readable: false,
|
41051
|
-
writable: true
|
41052
|
-
});
|
41053
|
-
|
41054
|
-
// FIXME Should probably have an option in net.Socket to create a
|
41055
|
-
// stream from an existing fd which is writable only. But for now
|
41056
|
-
// we'll just add this hack and set the `readable` member to false.
|
41057
|
-
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
41058
|
-
stream.readable = false;
|
41059
|
-
stream.read = null;
|
41060
|
-
stream._type = 'pipe';
|
41061
|
-
|
41062
|
-
// FIXME Hack to have stream not keep the event loop alive.
|
41063
|
-
// See https://github.com/joyent/node/issues/1726
|
41064
|
-
if (stream._handle && stream._handle.unref) {
|
41065
|
-
stream._handle.unref();
|
41066
|
-
}
|
41067
|
-
break;
|
41068
|
-
|
41069
|
-
default:
|
41070
|
-
// Probably an error on in uv_guess_handle()
|
41071
|
-
throw new Error('Implement me. Unknown stream file type!');
|
41072
|
-
}
|
41073
|
-
|
41074
|
-
// For supporting legacy API we put the FD here.
|
41075
|
-
stream.fd = fd;
|
41076
|
-
|
41077
|
-
stream._isStdio = true;
|
41078
|
-
|
41079
|
-
return stream;
|
41080
|
-
}
|
41081
|
-
|
41082
|
-
/**
|
41083
|
-
* Init logic for `debug` instances.
|
41084
|
-
*
|
41085
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
41086
|
-
* differently for a particular `debug` instance.
|
41087
|
-
*/
|
41088
|
-
|
41089
|
-
function init (debug) {
|
41090
|
-
debug.inspectOpts = {};
|
41091
|
-
|
41092
|
-
var keys = Object.keys(exports.inspectOpts);
|
41093
|
-
for (var i = 0; i < keys.length; i++) {
|
41094
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
41095
|
-
}
|
41096
|
-
}
|
41097
|
-
|
41098
|
-
/**
|
41099
|
-
* Enable namespaces listed in `process.env.DEBUG` initially.
|
41100
|
-
*/
|
41101
|
-
|
41102
|
-
exports.enable(load());
|
41103
|
-
} (node, node.exports));
|
41104
|
-
return node.exports;
|
41105
|
-
}
|
41106
|
-
|
41107
|
-
var browser = {exports: {}};
|
41108
|
-
|
41109
40933
|
/**
|
41110
40934
|
* This is the web browser implementation of `debug()`.
|
41111
40935
|
*
|
@@ -41301,6 +41125,266 @@ function requireBrowser () {
|
|
41301
41125
|
return browser.exports;
|
41302
41126
|
}
|
41303
41127
|
|
41128
|
+
var node = {exports: {}};
|
41129
|
+
|
41130
|
+
/**
|
41131
|
+
* Module dependencies.
|
41132
|
+
*/
|
41133
|
+
|
41134
|
+
var hasRequiredNode;
|
41135
|
+
|
41136
|
+
function requireNode () {
|
41137
|
+
if (hasRequiredNode) return node.exports;
|
41138
|
+
hasRequiredNode = 1;
|
41139
|
+
(function (module, exports) {
|
41140
|
+
var tty = require$$0$3;
|
41141
|
+
var util = require$$0$6;
|
41142
|
+
|
41143
|
+
/**
|
41144
|
+
* This is the Node.js implementation of `debug()`.
|
41145
|
+
*
|
41146
|
+
* Expose `debug()` as the module.
|
41147
|
+
*/
|
41148
|
+
|
41149
|
+
exports = module.exports = requireDebug();
|
41150
|
+
exports.init = init;
|
41151
|
+
exports.log = log;
|
41152
|
+
exports.formatArgs = formatArgs;
|
41153
|
+
exports.save = save;
|
41154
|
+
exports.load = load;
|
41155
|
+
exports.useColors = useColors;
|
41156
|
+
|
41157
|
+
/**
|
41158
|
+
* Colors.
|
41159
|
+
*/
|
41160
|
+
|
41161
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
41162
|
+
|
41163
|
+
/**
|
41164
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
41165
|
+
*
|
41166
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
41167
|
+
*/
|
41168
|
+
|
41169
|
+
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
41170
|
+
return /^debug_/i.test(key);
|
41171
|
+
}).reduce(function (obj, key) {
|
41172
|
+
// camel-case
|
41173
|
+
var prop = key
|
41174
|
+
.substring(6)
|
41175
|
+
.toLowerCase()
|
41176
|
+
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
41177
|
+
|
41178
|
+
// coerce string value into JS value
|
41179
|
+
var val = process.env[key];
|
41180
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
41181
|
+
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
41182
|
+
else if (val === 'null') val = null;
|
41183
|
+
else val = Number(val);
|
41184
|
+
|
41185
|
+
obj[prop] = val;
|
41186
|
+
return obj;
|
41187
|
+
}, {});
|
41188
|
+
|
41189
|
+
/**
|
41190
|
+
* The file descriptor to write the `debug()` calls to.
|
41191
|
+
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
41192
|
+
*
|
41193
|
+
* $ DEBUG_FD=3 node script.js 3>debug.log
|
41194
|
+
*/
|
41195
|
+
|
41196
|
+
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
41197
|
+
|
41198
|
+
if (1 !== fd && 2 !== fd) {
|
41199
|
+
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
|
41200
|
+
}
|
41201
|
+
|
41202
|
+
var stream = 1 === fd ? process.stdout :
|
41203
|
+
2 === fd ? process.stderr :
|
41204
|
+
createWritableStdioStream(fd);
|
41205
|
+
|
41206
|
+
/**
|
41207
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
41208
|
+
*/
|
41209
|
+
|
41210
|
+
function useColors() {
|
41211
|
+
return 'colors' in exports.inspectOpts
|
41212
|
+
? Boolean(exports.inspectOpts.colors)
|
41213
|
+
: tty.isatty(fd);
|
41214
|
+
}
|
41215
|
+
|
41216
|
+
/**
|
41217
|
+
* Map %o to `util.inspect()`, all on a single line.
|
41218
|
+
*/
|
41219
|
+
|
41220
|
+
exports.formatters.o = function(v) {
|
41221
|
+
this.inspectOpts.colors = this.useColors;
|
41222
|
+
return util.inspect(v, this.inspectOpts)
|
41223
|
+
.split('\n').map(function(str) {
|
41224
|
+
return str.trim()
|
41225
|
+
}).join(' ');
|
41226
|
+
};
|
41227
|
+
|
41228
|
+
/**
|
41229
|
+
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
41230
|
+
*/
|
41231
|
+
|
41232
|
+
exports.formatters.O = function(v) {
|
41233
|
+
this.inspectOpts.colors = this.useColors;
|
41234
|
+
return util.inspect(v, this.inspectOpts);
|
41235
|
+
};
|
41236
|
+
|
41237
|
+
/**
|
41238
|
+
* Adds ANSI color escape codes if enabled.
|
41239
|
+
*
|
41240
|
+
* @api public
|
41241
|
+
*/
|
41242
|
+
|
41243
|
+
function formatArgs(args) {
|
41244
|
+
var name = this.namespace;
|
41245
|
+
var useColors = this.useColors;
|
41246
|
+
|
41247
|
+
if (useColors) {
|
41248
|
+
var c = this.color;
|
41249
|
+
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
|
41250
|
+
|
41251
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
41252
|
+
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
41253
|
+
} else {
|
41254
|
+
args[0] = new Date().toUTCString()
|
41255
|
+
+ ' ' + name + ' ' + args[0];
|
41256
|
+
}
|
41257
|
+
}
|
41258
|
+
|
41259
|
+
/**
|
41260
|
+
* Invokes `util.format()` with the specified arguments and writes to `stream`.
|
41261
|
+
*/
|
41262
|
+
|
41263
|
+
function log() {
|
41264
|
+
return stream.write(util.format.apply(util, arguments) + '\n');
|
41265
|
+
}
|
41266
|
+
|
41267
|
+
/**
|
41268
|
+
* Save `namespaces`.
|
41269
|
+
*
|
41270
|
+
* @param {String} namespaces
|
41271
|
+
* @api private
|
41272
|
+
*/
|
41273
|
+
|
41274
|
+
function save(namespaces) {
|
41275
|
+
if (null == namespaces) {
|
41276
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
41277
|
+
// string 'null' or 'undefined'. Just delete instead.
|
41278
|
+
delete process.env.DEBUG;
|
41279
|
+
} else {
|
41280
|
+
process.env.DEBUG = namespaces;
|
41281
|
+
}
|
41282
|
+
}
|
41283
|
+
|
41284
|
+
/**
|
41285
|
+
* Load `namespaces`.
|
41286
|
+
*
|
41287
|
+
* @return {String} returns the previously persisted debug modes
|
41288
|
+
* @api private
|
41289
|
+
*/
|
41290
|
+
|
41291
|
+
function load() {
|
41292
|
+
return process.env.DEBUG;
|
41293
|
+
}
|
41294
|
+
|
41295
|
+
/**
|
41296
|
+
* Copied from `node/src/node.js`.
|
41297
|
+
*
|
41298
|
+
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
41299
|
+
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
41300
|
+
*/
|
41301
|
+
|
41302
|
+
function createWritableStdioStream (fd) {
|
41303
|
+
var stream;
|
41304
|
+
var tty_wrap = process.binding('tty_wrap');
|
41305
|
+
|
41306
|
+
// Note stream._type is used for test-module-load-list.js
|
41307
|
+
|
41308
|
+
switch (tty_wrap.guessHandleType(fd)) {
|
41309
|
+
case 'TTY':
|
41310
|
+
stream = new tty.WriteStream(fd);
|
41311
|
+
stream._type = 'tty';
|
41312
|
+
|
41313
|
+
// Hack to have stream not keep the event loop alive.
|
41314
|
+
// See https://github.com/joyent/node/issues/1726
|
41315
|
+
if (stream._handle && stream._handle.unref) {
|
41316
|
+
stream._handle.unref();
|
41317
|
+
}
|
41318
|
+
break;
|
41319
|
+
|
41320
|
+
case 'FILE':
|
41321
|
+
var fs = require$$0__default;
|
41322
|
+
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
41323
|
+
stream._type = 'fs';
|
41324
|
+
break;
|
41325
|
+
|
41326
|
+
case 'PIPE':
|
41327
|
+
case 'TCP':
|
41328
|
+
var net = require$$4$1;
|
41329
|
+
stream = new net.Socket({
|
41330
|
+
fd: fd,
|
41331
|
+
readable: false,
|
41332
|
+
writable: true
|
41333
|
+
});
|
41334
|
+
|
41335
|
+
// FIXME Should probably have an option in net.Socket to create a
|
41336
|
+
// stream from an existing fd which is writable only. But for now
|
41337
|
+
// we'll just add this hack and set the `readable` member to false.
|
41338
|
+
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
41339
|
+
stream.readable = false;
|
41340
|
+
stream.read = null;
|
41341
|
+
stream._type = 'pipe';
|
41342
|
+
|
41343
|
+
// FIXME Hack to have stream not keep the event loop alive.
|
41344
|
+
// See https://github.com/joyent/node/issues/1726
|
41345
|
+
if (stream._handle && stream._handle.unref) {
|
41346
|
+
stream._handle.unref();
|
41347
|
+
}
|
41348
|
+
break;
|
41349
|
+
|
41350
|
+
default:
|
41351
|
+
// Probably an error on in uv_guess_handle()
|
41352
|
+
throw new Error('Implement me. Unknown stream file type!');
|
41353
|
+
}
|
41354
|
+
|
41355
|
+
// For supporting legacy API we put the FD here.
|
41356
|
+
stream.fd = fd;
|
41357
|
+
|
41358
|
+
stream._isStdio = true;
|
41359
|
+
|
41360
|
+
return stream;
|
41361
|
+
}
|
41362
|
+
|
41363
|
+
/**
|
41364
|
+
* Init logic for `debug` instances.
|
41365
|
+
*
|
41366
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
41367
|
+
* differently for a particular `debug` instance.
|
41368
|
+
*/
|
41369
|
+
|
41370
|
+
function init (debug) {
|
41371
|
+
debug.inspectOpts = {};
|
41372
|
+
|
41373
|
+
var keys = Object.keys(exports.inspectOpts);
|
41374
|
+
for (var i = 0; i < keys.length; i++) {
|
41375
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
41376
|
+
}
|
41377
|
+
}
|
41378
|
+
|
41379
|
+
/**
|
41380
|
+
* Enable namespaces listed in `process.env.DEBUG` initially.
|
41381
|
+
*/
|
41382
|
+
|
41383
|
+
exports.enable(load());
|
41384
|
+
} (node, node.exports));
|
41385
|
+
return node.exports;
|
41386
|
+
}
|
41387
|
+
|
41304
41388
|
/**
|
41305
41389
|
* Detect Electron renderer process, which is node, but we should
|
41306
41390
|
* treat as a browser.
|
@@ -47348,7 +47432,7 @@ var etag_1 = etag;
|
|
47348
47432
|
* @private
|
47349
47433
|
*/
|
47350
47434
|
|
47351
|
-
var crypto = require$$
|
47435
|
+
var crypto = require$$3$1;
|
47352
47436
|
var Stats = require$$0__default.Stats;
|
47353
47437
|
|
47354
47438
|
/**
|
@@ -47653,7 +47737,8 @@ function resolvePlugin(resolveOptions) {
|
|
47653
47737
|
// externalize if building for SSR, otherwise redirect to empty module
|
47654
47738
|
if (isBuiltin(id)) {
|
47655
47739
|
if (ssr) {
|
47656
|
-
if (
|
47740
|
+
if (targetWeb &&
|
47741
|
+
ssrNoExternal === true &&
|
47657
47742
|
// if both noExternal and external are true, noExternal will take the higher priority and bundle it.
|
47658
47743
|
// only if the id is explicitly listed in external, we will externalize it and skip this error.
|
47659
47744
|
(ssrExternal === true || !ssrExternal?.includes(id))) {
|
@@ -47859,7 +47944,17 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
47859
47944
|
else {
|
47860
47945
|
basedir = root;
|
47861
47946
|
}
|
47862
|
-
|
47947
|
+
let selfPkg = null;
|
47948
|
+
if (!isBuiltin(id) && !id.includes('\0') && bareImportRE.test(id)) {
|
47949
|
+
// check if it's a self reference dep.
|
47950
|
+
const selfPackageData = findNearestPackageData(basedir, packageCache);
|
47951
|
+
selfPkg =
|
47952
|
+
selfPackageData?.data.exports && selfPackageData?.data.name === pkgId
|
47953
|
+
? selfPackageData
|
47954
|
+
: null;
|
47955
|
+
}
|
47956
|
+
const pkg = selfPkg ||
|
47957
|
+
resolvePackageData(pkgId, basedir, preserveSymlinks, packageCache);
|
47863
47958
|
if (!pkg) {
|
47864
47959
|
// if import can't be found, check if it's an optional peer dep.
|
47865
47960
|
// if so, we can resolve to a special id that errors only when imported.
|
@@ -48713,6 +48808,7 @@ function extractJsonErrorPosition(errorMessage, inputLength) {
|
|
48713
48808
|
|
48714
48809
|
const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = 'ERR_OPTIMIZE_DEPS_PROCESSING_ERROR';
|
48715
48810
|
const ERR_OUTDATED_OPTIMIZED_DEP = 'ERR_OUTDATED_OPTIMIZED_DEP';
|
48811
|
+
const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = 'ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR';
|
48716
48812
|
const debug$a = createDebugger('vite:optimize-deps');
|
48717
48813
|
function optimizedDepsPlugin(config) {
|
48718
48814
|
return {
|
@@ -48767,8 +48863,12 @@ function optimizedDepsPlugin(config) {
|
|
48767
48863
|
return await fsp.readFile(file, 'utf-8');
|
48768
48864
|
}
|
48769
48865
|
catch (e) {
|
48770
|
-
|
48771
|
-
|
48866
|
+
const newMetadata = depsOptimizer.metadata;
|
48867
|
+
if (optimizedDepInfoFromFile(newMetadata, file)) {
|
48868
|
+
// Outdated non-entry points (CHUNK), loaded after a rerun
|
48869
|
+
throwOutdatedRequest(id);
|
48870
|
+
}
|
48871
|
+
throwFileNotFoundInOptimizedDep(id);
|
48772
48872
|
}
|
48773
48873
|
}
|
48774
48874
|
},
|
@@ -48790,6 +48890,15 @@ function throwOutdatedRequest(id) {
|
|
48790
48890
|
// send a 504 status code request timeout
|
48791
48891
|
throw err;
|
48792
48892
|
}
|
48893
|
+
function throwFileNotFoundInOptimizedDep(id) {
|
48894
|
+
const err = new Error(`The file does not exist at "${id}" which is in the optimize deps directory. ` +
|
48895
|
+
`The dependency might be incompatible with the dep optimizer. ` +
|
48896
|
+
`Try adding it to \`optimizeDeps.exclude\`.`);
|
48897
|
+
err.code = ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR;
|
48898
|
+
// This error will be caught by the transform middleware that will
|
48899
|
+
// send a 404 status code not found
|
48900
|
+
throw err;
|
48901
|
+
}
|
48793
48902
|
|
48794
48903
|
const nonJsRe = /\.json(?:$|\?)/;
|
48795
48904
|
const isNonJsRequest = (request) => nonJsRe.test(request);
|
@@ -49444,7 +49553,7 @@ function webWorkerPlugin(config) {
|
|
49444
49553
|
const filename = fileNameHash.get(hash);
|
49445
49554
|
const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
|
49446
49555
|
const replacementString = typeof replacement === 'string'
|
49447
|
-
? JSON.stringify(replacement).slice(1, -1)
|
49556
|
+
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
49448
49557
|
: `"+${replacement.runtime}+"`;
|
49449
49558
|
s.update(match.index, match.index + full.length, replacementString);
|
49450
49559
|
}
|
@@ -49577,6 +49686,10 @@ function getAliasPatterns(entries) {
|
|
49577
49686
|
}
|
49578
49687
|
return Object.entries(entries).map(([find]) => find);
|
49579
49688
|
}
|
49689
|
+
function getAliasPatternMatcher(entries) {
|
49690
|
+
const patterns = getAliasPatterns(entries);
|
49691
|
+
return (importee) => patterns.some((pattern) => matches(pattern, importee));
|
49692
|
+
}
|
49580
49693
|
|
49581
49694
|
function err(e, pos) {
|
49582
49695
|
const error = new Error(e);
|
@@ -50441,7 +50554,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
50441
50554
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
50442
50555
|
SOFTWARE.
|
50443
50556
|
*/
|
50444
|
-
const noop$
|
50557
|
+
const noop$2 = () => { };
|
50445
50558
|
const ERR_CLOSED_SERVER = 'ERR_CLOSED_SERVER';
|
50446
50559
|
function throwClosedServerError() {
|
50447
50560
|
const err = new Error('The server is being restarted or closed. Request is outdated');
|
@@ -50474,11 +50587,11 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
50474
50587
|
rollupVersion,
|
50475
50588
|
watchMode: true,
|
50476
50589
|
},
|
50477
|
-
debug: noop$
|
50478
|
-
info: noop$
|
50479
|
-
warn: noop$
|
50590
|
+
debug: noop$2,
|
50591
|
+
info: noop$2,
|
50592
|
+
warn: noop$2,
|
50480
50593
|
// @ts-expect-error noop
|
50481
|
-
error: noop$
|
50594
|
+
error: noop$2,
|
50482
50595
|
};
|
50483
50596
|
function warnIncompatibleMethod(method, plugin) {
|
50484
50597
|
logger.warn(colors$1.cyan(`[plugin:${plugin}] `) +
|
@@ -50640,8 +50753,8 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
50640
50753
|
// the the error middleware.
|
50641
50754
|
throw formatError(e, position, this);
|
50642
50755
|
}
|
50643
|
-
debug = noop$
|
50644
|
-
info = noop$
|
50756
|
+
debug = noop$2;
|
50757
|
+
info = noop$2;
|
50645
50758
|
}
|
50646
50759
|
function formatError(e, position, ctx) {
|
50647
50760
|
const err = (typeof e === 'string' ? new Error(e) : e);
|
@@ -51731,7 +51844,6 @@ async function createDepsOptimizer(config, server) {
|
|
51731
51844
|
isOptimizedDepFile: createIsOptimizedDepFile(config),
|
51732
51845
|
isOptimizedDepUrl: createIsOptimizedDepUrl(config),
|
51733
51846
|
getOptimizedDepId: (depInfo) => `${depInfo.file}?v=${depInfo.browserHash}`,
|
51734
|
-
delayDepsOptimizerUntil,
|
51735
51847
|
close,
|
51736
51848
|
options,
|
51737
51849
|
};
|
@@ -51773,15 +51885,15 @@ async function createDepsOptimizer(config, server) {
|
|
51773
51885
|
// from the first request before resolving to minimize full page reloads.
|
51774
51886
|
// On warm start or after the first optimization is run, we use a simpler
|
51775
51887
|
// debounce strategy each time a new dep is discovered.
|
51776
|
-
let
|
51888
|
+
let waitingForCrawlEnd = false;
|
51777
51889
|
if (!cachedMetadata) {
|
51778
|
-
|
51890
|
+
server._onCrawlEnd(onCrawlEnd);
|
51891
|
+
waitingForCrawlEnd = true;
|
51779
51892
|
}
|
51780
51893
|
let optimizationResult;
|
51781
51894
|
let discover;
|
51782
51895
|
async function close() {
|
51783
51896
|
closed = true;
|
51784
|
-
crawlEndFinder?.cancel();
|
51785
51897
|
await Promise.allSettled([
|
51786
51898
|
discover?.cancel(),
|
51787
51899
|
depsOptimizer.scanProcessing,
|
@@ -51843,7 +51955,7 @@ async function createDepsOptimizer(config, server) {
|
|
51843
51955
|
optimizationResult.result.then((result) => {
|
51844
51956
|
// Check if the crawling of static imports has already finished. In that
|
51845
51957
|
// case, the result is handled by the onCrawlEnd callback
|
51846
|
-
if (!
|
51958
|
+
if (!waitingForCrawlEnd)
|
51847
51959
|
return;
|
51848
51960
|
optimizationResult = undefined; // signal that we'll be using the result
|
51849
51961
|
runOptimizer(result);
|
@@ -52038,16 +52150,14 @@ async function createDepsOptimizer(config, server) {
|
|
52038
52150
|
enqueuedRerun?.();
|
52039
52151
|
}
|
52040
52152
|
function fullReload() {
|
52041
|
-
|
52042
|
-
|
52043
|
-
|
52044
|
-
|
52045
|
-
|
52046
|
-
|
52047
|
-
|
52048
|
-
|
52049
|
-
});
|
52050
|
-
}
|
52153
|
+
// Cached transform results have stale imports (resolved to
|
52154
|
+
// old locations) so they need to be invalidated before the page is
|
52155
|
+
// reloaded.
|
52156
|
+
server.moduleGraph.invalidateAll();
|
52157
|
+
server.hot.send({
|
52158
|
+
type: 'full-reload',
|
52159
|
+
path: '*',
|
52160
|
+
});
|
52051
52161
|
}
|
52052
52162
|
async function rerun() {
|
52053
52163
|
// debounce time to wait for new missing deps finished, issue a new
|
@@ -52081,7 +52191,7 @@ async function createDepsOptimizer(config, server) {
|
|
52081
52191
|
// We'll wait until the user codebase is eagerly processed by Vite so
|
52082
52192
|
// we can get a list of every missing dependency before giving to the
|
52083
52193
|
// browser a dependency that may be outdated, thus avoiding full page reloads
|
52084
|
-
if (!
|
52194
|
+
if (!waitingForCrawlEnd) {
|
52085
52195
|
// Debounced rerun, let other missing dependencies be discovered before
|
52086
52196
|
// the running next optimizeDeps
|
52087
52197
|
debouncedProcessing();
|
@@ -52129,7 +52239,7 @@ async function createDepsOptimizer(config, server) {
|
|
52129
52239
|
// be crawled if the browser requests them right away).
|
52130
52240
|
async function onCrawlEnd() {
|
52131
52241
|
// switch after this point to a simple debounce strategy
|
52132
|
-
|
52242
|
+
waitingForCrawlEnd = false;
|
52133
52243
|
debug$8?.(colors$1.green(`✨ static imports crawl ended`));
|
52134
52244
|
if (closed) {
|
52135
52245
|
return;
|
@@ -52205,57 +52315,6 @@ async function createDepsOptimizer(config, server) {
|
|
52205
52315
|
debouncedProcessing(0);
|
52206
52316
|
}
|
52207
52317
|
}
|
52208
|
-
function delayDepsOptimizerUntil(id, done) {
|
52209
|
-
if (crawlEndFinder && !depsOptimizer.isOptimizedDepFile(id)) {
|
52210
|
-
crawlEndFinder.delayDepsOptimizerUntil(id, done);
|
52211
|
-
}
|
52212
|
-
}
|
52213
|
-
}
|
52214
|
-
const callCrawlEndIfIdleAfterMs = 50;
|
52215
|
-
function setupOnCrawlEnd(onCrawlEnd) {
|
52216
|
-
const registeredIds = new Set();
|
52217
|
-
const seenIds = new Set();
|
52218
|
-
let timeoutHandle;
|
52219
|
-
let cancelled = false;
|
52220
|
-
function cancel() {
|
52221
|
-
cancelled = true;
|
52222
|
-
}
|
52223
|
-
let crawlEndCalled = false;
|
52224
|
-
function callOnCrawlEnd() {
|
52225
|
-
if (!cancelled && !crawlEndCalled) {
|
52226
|
-
crawlEndCalled = true;
|
52227
|
-
onCrawlEnd();
|
52228
|
-
}
|
52229
|
-
}
|
52230
|
-
function delayDepsOptimizerUntil(id, done) {
|
52231
|
-
if (!seenIds.has(id)) {
|
52232
|
-
seenIds.add(id);
|
52233
|
-
registeredIds.add(id);
|
52234
|
-
done()
|
52235
|
-
.catch(() => { })
|
52236
|
-
.finally(() => markIdAsDone(id));
|
52237
|
-
}
|
52238
|
-
}
|
52239
|
-
function markIdAsDone(id) {
|
52240
|
-
registeredIds.delete(id);
|
52241
|
-
checkIfCrawlEndAfterTimeout();
|
52242
|
-
}
|
52243
|
-
function checkIfCrawlEndAfterTimeout() {
|
52244
|
-
if (cancelled || registeredIds.size > 0)
|
52245
|
-
return;
|
52246
|
-
if (timeoutHandle)
|
52247
|
-
clearTimeout(timeoutHandle);
|
52248
|
-
timeoutHandle = setTimeout(callOnCrawlEndWhenIdle, callCrawlEndIfIdleAfterMs);
|
52249
|
-
}
|
52250
|
-
async function callOnCrawlEndWhenIdle() {
|
52251
|
-
if (cancelled || registeredIds.size > 0)
|
52252
|
-
return;
|
52253
|
-
callOnCrawlEnd();
|
52254
|
-
}
|
52255
|
-
return {
|
52256
|
-
delayDepsOptimizerUntil,
|
52257
|
-
cancel,
|
52258
|
-
};
|
52259
52318
|
}
|
52260
52319
|
async function createDevSsrDepsOptimizer(config) {
|
52261
52320
|
const metadata = await optimizeServerSsrDeps(config);
|
@@ -52270,7 +52329,6 @@ async function createDevSsrDepsOptimizer(config) {
|
|
52270
52329
|
// noop, there is no scanning during dev SSR
|
52271
52330
|
// the optimizer blocks the server start
|
52272
52331
|
run: () => { },
|
52273
|
-
delayDepsOptimizerUntil: (id, done) => { },
|
52274
52332
|
close: async () => { },
|
52275
52333
|
options: config.ssr.optimizeDeps,
|
52276
52334
|
};
|
@@ -52680,8 +52738,7 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
|
|
52680
52738
|
charset: 'utf8',
|
52681
52739
|
...esbuildOptions,
|
52682
52740
|
supported: {
|
52683
|
-
|
52684
|
-
'import-meta': true,
|
52741
|
+
...defaultEsbuildSupported,
|
52685
52742
|
...esbuildOptions.supported,
|
52686
52743
|
},
|
52687
52744
|
});
|
@@ -53164,7 +53221,7 @@ function parse$5(req) {
|
|
53164
53221
|
return req._parsedUrl = { pathname, search, query, raw };
|
53165
53222
|
}
|
53166
53223
|
|
53167
|
-
const noop$
|
53224
|
+
const noop$1 = () => {};
|
53168
53225
|
|
53169
53226
|
function isMatch(uri, arr) {
|
53170
53227
|
for (let i=0; i < arr.length; i++) {
|
@@ -53280,7 +53337,7 @@ function sirv (dir, opts={}) {
|
|
53280
53337
|
dir = resolve$3(dir || '.');
|
53281
53338
|
|
53282
53339
|
let isNotFound = opts.onNoMatch || is404;
|
53283
|
-
let setHeaders = opts.setHeaders || noop$
|
53340
|
+
let setHeaders = opts.setHeaders || noop$1;
|
53284
53341
|
|
53285
53342
|
let extensions = opts.extensions || ['html', 'htm'];
|
53286
53343
|
let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz');
|
@@ -53637,7 +53694,10 @@ async function doTransform(url, server, options, timestamp) {
|
|
53637
53694
|
return cached;
|
53638
53695
|
}
|
53639
53696
|
const result = loadAndTransform(id, url, server, options, timestamp, module, resolved);
|
53640
|
-
getDepsOptimizer(config, ssr)
|
53697
|
+
const depsOptimizer = getDepsOptimizer(config, ssr);
|
53698
|
+
if (!depsOptimizer?.isOptimizedDepFile(id)) {
|
53699
|
+
server._registerRequestProcessing(id, () => result);
|
53700
|
+
}
|
53641
53701
|
return result;
|
53642
53702
|
}
|
53643
53703
|
async function getCachedTransformResult(url, module, server, ssr, timestamp) {
|
@@ -54260,7 +54320,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
54260
54320
|
const declaredConst = new Set();
|
54261
54321
|
// hoist at the start of the file, after the hashbang
|
54262
54322
|
const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0;
|
54263
|
-
function defineImport(source, metadata) {
|
54323
|
+
function defineImport(index, source, metadata) {
|
54264
54324
|
deps.add(source);
|
54265
54325
|
const importId = `__vite_ssr_import_${uid++}__`;
|
54266
54326
|
// Reduce metadata to undefined if it's all default values
|
@@ -54271,7 +54331,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
54271
54331
|
const metadataStr = metadata ? `, ${JSON.stringify(metadata)}` : '';
|
54272
54332
|
// There will be an error if the module is called before it is imported,
|
54273
54333
|
// so the module import statement is hoisted to the top
|
54274
|
-
s.appendLeft(
|
54334
|
+
s.appendLeft(index, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)}${metadataStr});\n`);
|
54275
54335
|
return importId;
|
54276
54336
|
}
|
54277
54337
|
function defineExport(position, name, local = name) {
|
@@ -54284,7 +54344,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
54284
54344
|
// import { baz } from 'foo' --> baz -> __import_foo__.baz
|
54285
54345
|
// import * as ok from 'foo' --> ok -> __import_foo__
|
54286
54346
|
if (node.type === 'ImportDeclaration') {
|
54287
|
-
const importId = defineImport(node.source.value, {
|
54347
|
+
const importId = defineImport(hoistIndex, node.source.value, {
|
54288
54348
|
importedNames: node.specifiers
|
54289
54349
|
.map((s) => {
|
54290
54350
|
if (s.type === 'ImportSpecifier')
|
@@ -54334,12 +54394,11 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
54334
54394
|
s.remove(node.start, node.end);
|
54335
54395
|
if (node.source) {
|
54336
54396
|
// export { foo, bar } from './foo'
|
54337
|
-
const importId = defineImport(node.source.value, {
|
54397
|
+
const importId = defineImport(node.start, node.source.value, {
|
54338
54398
|
importedNames: node.specifiers.map((s) => s.local.name),
|
54339
54399
|
});
|
54340
|
-
// hoist re-exports near the defined import so they are immediately exported
|
54341
54400
|
for (const spec of node.specifiers) {
|
54342
|
-
defineExport(
|
54401
|
+
defineExport(node.start, spec.exported.name, `${importId}.${spec.local.name}`);
|
54343
54402
|
}
|
54344
54403
|
}
|
54345
54404
|
else {
|
@@ -54374,13 +54433,12 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
54374
54433
|
// export * from './foo'
|
54375
54434
|
if (node.type === 'ExportAllDeclaration') {
|
54376
54435
|
s.remove(node.start, node.end);
|
54377
|
-
const importId = defineImport(node.source.value);
|
54378
|
-
// hoist re-exports near the defined import so they are immediately exported
|
54436
|
+
const importId = defineImport(node.start, node.source.value);
|
54379
54437
|
if (node.exported) {
|
54380
|
-
defineExport(
|
54438
|
+
defineExport(node.start, node.exported.name, `${importId}`);
|
54381
54439
|
}
|
54382
54440
|
else {
|
54383
|
-
s.appendLeft(
|
54441
|
+
s.appendLeft(node.start, `${ssrExportAllKey}(${importId});\n`);
|
54384
54442
|
}
|
54385
54443
|
}
|
54386
54444
|
}
|
@@ -54806,7 +54864,11 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
54806
54864
|
// Tolerate circular imports by ensuring the module can be
|
54807
54865
|
// referenced before it's been instantiated.
|
54808
54866
|
mod.ssrModule = ssrModule;
|
54867
|
+
// replace '/' with '\\' on Windows to match Node.js
|
54868
|
+
const osNormalizedFilename = isWindows$5 ? path$o.resolve(mod.file) : mod.file;
|
54809
54869
|
const ssrImportMeta = {
|
54870
|
+
dirname: path$o.dirname(osNormalizedFilename),
|
54871
|
+
filename: osNormalizedFilename,
|
54810
54872
|
// The filesystem URL, matching native Node.js modules
|
54811
54873
|
url: pathToFileURL(mod.file).toString(),
|
54812
54874
|
};
|
@@ -55392,56 +55454,6 @@ var open$1 = /*@__PURE__*/getDefaultExportFromCjs(open_1);
|
|
55392
55454
|
|
55393
55455
|
var crossSpawn = {exports: {}};
|
55394
55456
|
|
55395
|
-
var mode;
|
55396
|
-
var hasRequiredMode;
|
55397
|
-
|
55398
|
-
function requireMode () {
|
55399
|
-
if (hasRequiredMode) return mode;
|
55400
|
-
hasRequiredMode = 1;
|
55401
|
-
mode = isexe;
|
55402
|
-
isexe.sync = sync;
|
55403
|
-
|
55404
|
-
var fs = require$$0__default;
|
55405
|
-
|
55406
|
-
function isexe (path, options, cb) {
|
55407
|
-
fs.stat(path, function (er, stat) {
|
55408
|
-
cb(er, er ? false : checkStat(stat, options));
|
55409
|
-
});
|
55410
|
-
}
|
55411
|
-
|
55412
|
-
function sync (path, options) {
|
55413
|
-
return checkStat(fs.statSync(path), options)
|
55414
|
-
}
|
55415
|
-
|
55416
|
-
function checkStat (stat, options) {
|
55417
|
-
return stat.isFile() && checkMode(stat, options)
|
55418
|
-
}
|
55419
|
-
|
55420
|
-
function checkMode (stat, options) {
|
55421
|
-
var mod = stat.mode;
|
55422
|
-
var uid = stat.uid;
|
55423
|
-
var gid = stat.gid;
|
55424
|
-
|
55425
|
-
var myUid = options.uid !== undefined ?
|
55426
|
-
options.uid : process.getuid && process.getuid();
|
55427
|
-
var myGid = options.gid !== undefined ?
|
55428
|
-
options.gid : process.getgid && process.getgid();
|
55429
|
-
|
55430
|
-
var u = parseInt('100', 8);
|
55431
|
-
var g = parseInt('010', 8);
|
55432
|
-
var o = parseInt('001', 8);
|
55433
|
-
var ug = u | g;
|
55434
|
-
|
55435
|
-
var ret = (mod & o) ||
|
55436
|
-
(mod & g) && gid === myGid ||
|
55437
|
-
(mod & u) && uid === myUid ||
|
55438
|
-
(mod & ug) && myUid === 0;
|
55439
|
-
|
55440
|
-
return ret
|
55441
|
-
}
|
55442
|
-
return mode;
|
55443
|
-
}
|
55444
|
-
|
55445
55457
|
var windows;
|
55446
55458
|
var hasRequiredWindows;
|
55447
55459
|
|
@@ -55493,6 +55505,56 @@ function requireWindows () {
|
|
55493
55505
|
return windows;
|
55494
55506
|
}
|
55495
55507
|
|
55508
|
+
var mode;
|
55509
|
+
var hasRequiredMode;
|
55510
|
+
|
55511
|
+
function requireMode () {
|
55512
|
+
if (hasRequiredMode) return mode;
|
55513
|
+
hasRequiredMode = 1;
|
55514
|
+
mode = isexe;
|
55515
|
+
isexe.sync = sync;
|
55516
|
+
|
55517
|
+
var fs = require$$0__default;
|
55518
|
+
|
55519
|
+
function isexe (path, options, cb) {
|
55520
|
+
fs.stat(path, function (er, stat) {
|
55521
|
+
cb(er, er ? false : checkStat(stat, options));
|
55522
|
+
});
|
55523
|
+
}
|
55524
|
+
|
55525
|
+
function sync (path, options) {
|
55526
|
+
return checkStat(fs.statSync(path), options)
|
55527
|
+
}
|
55528
|
+
|
55529
|
+
function checkStat (stat, options) {
|
55530
|
+
return stat.isFile() && checkMode(stat, options)
|
55531
|
+
}
|
55532
|
+
|
55533
|
+
function checkMode (stat, options) {
|
55534
|
+
var mod = stat.mode;
|
55535
|
+
var uid = stat.uid;
|
55536
|
+
var gid = stat.gid;
|
55537
|
+
|
55538
|
+
var myUid = options.uid !== undefined ?
|
55539
|
+
options.uid : process.getuid && process.getuid();
|
55540
|
+
var myGid = options.gid !== undefined ?
|
55541
|
+
options.gid : process.getgid && process.getgid();
|
55542
|
+
|
55543
|
+
var u = parseInt('100', 8);
|
55544
|
+
var g = parseInt('010', 8);
|
55545
|
+
var o = parseInt('001', 8);
|
55546
|
+
var ug = u | g;
|
55547
|
+
|
55548
|
+
var ret = (mod & o) ||
|
55549
|
+
(mod & g) && gid === myGid ||
|
55550
|
+
(mod & u) && uid === myUid ||
|
55551
|
+
(mod & ug) && myUid === 0;
|
55552
|
+
|
55553
|
+
return ret
|
55554
|
+
}
|
55555
|
+
return mode;
|
55556
|
+
}
|
55557
|
+
|
55496
55558
|
var core;
|
55497
55559
|
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
|
55498
55560
|
core = requireWindows();
|
@@ -56578,7 +56640,7 @@ let Limiter$1 = class Limiter {
|
|
56578
56640
|
|
56579
56641
|
var limiter = Limiter$1;
|
56580
56642
|
|
56581
|
-
const zlib =
|
56643
|
+
const zlib = zlib$1;
|
56582
56644
|
|
56583
56645
|
const bufferUtil = bufferUtilExports;
|
56584
56646
|
const Limiter = limiter;
|
@@ -57093,7 +57155,7 @@ function inflateOnError(err) {
|
|
57093
57155
|
|
57094
57156
|
var validation = {exports: {}};
|
57095
57157
|
|
57096
|
-
const { isUtf8 } = require$$0$
|
57158
|
+
const { isUtf8 } = require$$0$a;
|
57097
57159
|
|
57098
57160
|
//
|
57099
57161
|
// Allowed token characters:
|
@@ -57966,7 +58028,7 @@ function throwErrorNextTick(err) {
|
|
57966
58028
|
}
|
57967
58029
|
|
57968
58030
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */
|
57969
|
-
const { randomFillSync } = require$$
|
58031
|
+
const { randomFillSync } = require$$3$1;
|
57970
58032
|
|
57971
58033
|
const PerMessageDeflate$2 = permessageDeflate;
|
57972
58034
|
const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants;
|
@@ -58939,7 +59001,7 @@ const https$2 = require$$1$1;
|
|
58939
59001
|
const http$3 = require$$1;
|
58940
59002
|
const net = require$$4$1;
|
58941
59003
|
const tls = require$$4$2;
|
58942
|
-
const { randomBytes, createHash: createHash$1 } = require$$
|
59004
|
+
const { randomBytes, createHash: createHash$1 } = require$$3$1;
|
58943
59005
|
const { URL: URL$2 } = require$$0$9;
|
58944
59006
|
|
58945
59007
|
const PerMessageDeflate$1 = permessageDeflate;
|
@@ -58953,7 +59015,7 @@ const {
|
|
58953
59015
|
kListener,
|
58954
59016
|
kStatusCode,
|
58955
59017
|
kWebSocket: kWebSocket$1,
|
58956
|
-
NOOP
|
59018
|
+
NOOP: NOOP$1
|
58957
59019
|
} = constants;
|
58958
59020
|
const {
|
58959
59021
|
EventTarget: { addEventListener, removeEventListener }
|
@@ -60149,7 +60211,7 @@ function receiverOnMessage(data, isBinary) {
|
|
60149
60211
|
function receiverOnPing(data) {
|
60150
60212
|
const websocket = this[kWebSocket$1];
|
60151
60213
|
|
60152
|
-
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
|
60214
|
+
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP$1);
|
60153
60215
|
websocket.emit('ping', data);
|
60154
60216
|
}
|
60155
60217
|
|
@@ -60258,7 +60320,7 @@ function socketOnError$1() {
|
|
60258
60320
|
const websocket = this[kWebSocket$1];
|
60259
60321
|
|
60260
60322
|
this.removeListener('error', socketOnError$1);
|
60261
|
-
this.on('error', NOOP);
|
60323
|
+
this.on('error', NOOP$1);
|
60262
60324
|
|
60263
60325
|
if (websocket) {
|
60264
60326
|
websocket._readyState = WebSocket$1.CLOSING;
|
@@ -60331,7 +60393,7 @@ var subprotocol$1 = { parse };
|
|
60331
60393
|
|
60332
60394
|
const EventEmitter = require$$0$5;
|
60333
60395
|
const http$2 = require$$1;
|
60334
|
-
const { createHash } = require$$
|
60396
|
+
const { createHash } = require$$3$1;
|
60335
60397
|
|
60336
60398
|
const extension = extension$1;
|
60337
60399
|
const PerMessageDeflate = permessageDeflate;
|
@@ -62458,7 +62520,7 @@ function wrap(protocols) {
|
|
62458
62520
|
}
|
62459
62521
|
|
62460
62522
|
/* istanbul ignore next */
|
62461
|
-
function noop
|
62523
|
+
function noop() { /* empty */ }
|
62462
62524
|
|
62463
62525
|
// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
62464
62526
|
function urlToOptions(urlObject) {
|
@@ -62514,7 +62576,7 @@ function abortRequest(request) {
|
|
62514
62576
|
for (var e = 0; e < events.length; e++) {
|
62515
62577
|
request.removeListener(events[e], eventHandlers[events[e]]);
|
62516
62578
|
}
|
62517
|
-
request.on("error", noop
|
62579
|
+
request.on("error", noop);
|
62518
62580
|
request.abort();
|
62519
62581
|
}
|
62520
62582
|
|
@@ -63578,6 +63640,15 @@ function transformMiddleware(server) {
|
|
63578
63640
|
// error but a normal part of the missing deps discovery flow
|
63579
63641
|
return;
|
63580
63642
|
}
|
63643
|
+
if (e?.code === ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR) {
|
63644
|
+
// Skip if response has already been sent
|
63645
|
+
if (!res.writableEnded) {
|
63646
|
+
res.statusCode = 404;
|
63647
|
+
res.end();
|
63648
|
+
}
|
63649
|
+
server.config.logger.warn(colors$1.yellow(e.message));
|
63650
|
+
return;
|
63651
|
+
}
|
63581
63652
|
if (e?.code === ERR_LOAD_URL) {
|
63582
63653
|
// Let other middleware handle if we can't load the url via transformRequest
|
63583
63654
|
return next();
|
@@ -63615,11 +63686,13 @@ function createDevHtmlTransformFn(config) {
|
|
63615
63686
|
const [preHooks, normalHooks, postHooks] = resolveHtmlTransforms(config.plugins, config.logger);
|
63616
63687
|
const transformHooks = [
|
63617
63688
|
preImportMapHook(config),
|
63689
|
+
injectCspNonceMetaTagHook(config),
|
63618
63690
|
...preHooks,
|
63619
63691
|
htmlEnvHook(config),
|
63620
63692
|
devHtmlHook,
|
63621
63693
|
...normalHooks,
|
63622
63694
|
...postHooks,
|
63695
|
+
injectNonceAttributeTagHook(config),
|
63623
63696
|
postImportMapHook(),
|
63624
63697
|
];
|
63625
63698
|
return (server, url, html, originalUrl) => {
|
@@ -64406,6 +64479,19 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64406
64479
|
const closeHttpServer = createServerCloseFn(httpServer);
|
64407
64480
|
let exitProcess;
|
64408
64481
|
const devHtmlTransformFn = createDevHtmlTransformFn(config);
|
64482
|
+
const onCrawlEndCallbacks = [];
|
64483
|
+
const crawlEndFinder = setupOnCrawlEnd(() => {
|
64484
|
+
onCrawlEndCallbacks.forEach((cb) => cb());
|
64485
|
+
});
|
64486
|
+
function waitForRequestsIdle(ignoredId) {
|
64487
|
+
return crawlEndFinder.waitForRequestsIdle(ignoredId);
|
64488
|
+
}
|
64489
|
+
function _registerRequestProcessing(id, done) {
|
64490
|
+
crawlEndFinder.registerRequestProcessing(id, done);
|
64491
|
+
}
|
64492
|
+
function _onCrawlEnd(cb) {
|
64493
|
+
onCrawlEndCallbacks.push(cb);
|
64494
|
+
}
|
64409
64495
|
let server = {
|
64410
64496
|
config,
|
64411
64497
|
middlewares,
|
@@ -64513,6 +64599,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64513
64599
|
watcher.close(),
|
64514
64600
|
hot.close(),
|
64515
64601
|
container.close(),
|
64602
|
+
crawlEndFinder?.cancel(),
|
64516
64603
|
getDepsOptimizer(server.config)?.close(),
|
64517
64604
|
getDepsOptimizer(server.config, true)?.close(),
|
64518
64605
|
closeHttpServer(),
|
@@ -64552,6 +64639,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64552
64639
|
}
|
64553
64640
|
return server._restartPromise;
|
64554
64641
|
},
|
64642
|
+
waitForRequestsIdle,
|
64643
|
+
_registerRequestProcessing,
|
64644
|
+
_onCrawlEnd,
|
64555
64645
|
_setInternalServer(_server) {
|
64556
64646
|
// Rebind internal the server variable so functions reference the user
|
64557
64647
|
// server instance after a restart
|
@@ -64840,6 +64930,22 @@ function resolveServerOptions(root, raw, logger) {
|
|
64840
64930
|
if (!allowDirs) {
|
64841
64931
|
allowDirs = [searchForWorkspaceRoot(root)];
|
64842
64932
|
}
|
64933
|
+
if (process.versions.pnp) {
|
64934
|
+
try {
|
64935
|
+
const enableGlobalCache = execSync('yarn config get enableGlobalCache', { cwd: root })
|
64936
|
+
.toString()
|
64937
|
+
.trim() === 'true';
|
64938
|
+
const yarnCacheDir = execSync(`yarn config get ${enableGlobalCache ? 'globalFolder' : 'cacheFolder'}`, { cwd: root })
|
64939
|
+
.toString()
|
64940
|
+
.trim();
|
64941
|
+
allowDirs.push(yarnCacheDir);
|
64942
|
+
}
|
64943
|
+
catch (e) {
|
64944
|
+
logger.warn(`Get yarn cache dir error: ${e.message}`, {
|
64945
|
+
timestamp: true,
|
64946
|
+
});
|
64947
|
+
}
|
64948
|
+
}
|
64843
64949
|
allowDirs = allowDirs.map((i) => resolvedAllowDir(root, i));
|
64844
64950
|
// only push client dir when vite itself is outside-of-root
|
64845
64951
|
const resolvedClientDir = resolvedAllowDir(root, CLIENT_DIR);
|
@@ -64932,6 +65038,64 @@ async function restartServerWithUrls(server) {
|
|
64932
65038
|
server.printUrls();
|
64933
65039
|
}
|
64934
65040
|
}
|
65041
|
+
const callCrawlEndIfIdleAfterMs = 50;
|
65042
|
+
function setupOnCrawlEnd(onCrawlEnd) {
|
65043
|
+
const registeredIds = new Set();
|
65044
|
+
const seenIds = new Set();
|
65045
|
+
const onCrawlEndPromiseWithResolvers = promiseWithResolvers();
|
65046
|
+
let timeoutHandle;
|
65047
|
+
let cancelled = false;
|
65048
|
+
function cancel() {
|
65049
|
+
cancelled = true;
|
65050
|
+
}
|
65051
|
+
let crawlEndCalled = false;
|
65052
|
+
function callOnCrawlEnd() {
|
65053
|
+
if (!cancelled && !crawlEndCalled) {
|
65054
|
+
crawlEndCalled = true;
|
65055
|
+
onCrawlEnd();
|
65056
|
+
}
|
65057
|
+
onCrawlEndPromiseWithResolvers.resolve();
|
65058
|
+
}
|
65059
|
+
function registerRequestProcessing(id, done) {
|
65060
|
+
if (!seenIds.has(id)) {
|
65061
|
+
seenIds.add(id);
|
65062
|
+
registeredIds.add(id);
|
65063
|
+
done()
|
65064
|
+
.catch(() => { })
|
65065
|
+
.finally(() => markIdAsDone(id));
|
65066
|
+
}
|
65067
|
+
}
|
65068
|
+
function waitForRequestsIdle(ignoredId) {
|
65069
|
+
if (ignoredId) {
|
65070
|
+
seenIds.add(ignoredId);
|
65071
|
+
markIdAsDone(ignoredId);
|
65072
|
+
}
|
65073
|
+
return onCrawlEndPromiseWithResolvers.promise;
|
65074
|
+
}
|
65075
|
+
function markIdAsDone(id) {
|
65076
|
+
if (registeredIds.has(id)) {
|
65077
|
+
registeredIds.delete(id);
|
65078
|
+
checkIfCrawlEndAfterTimeout();
|
65079
|
+
}
|
65080
|
+
}
|
65081
|
+
function checkIfCrawlEndAfterTimeout() {
|
65082
|
+
if (cancelled || registeredIds.size > 0)
|
65083
|
+
return;
|
65084
|
+
if (timeoutHandle)
|
65085
|
+
clearTimeout(timeoutHandle);
|
65086
|
+
timeoutHandle = setTimeout(callOnCrawlEndWhenIdle, callCrawlEndIfIdleAfterMs);
|
65087
|
+
}
|
65088
|
+
async function callOnCrawlEndWhenIdle() {
|
65089
|
+
if (cancelled || registeredIds.size > 0)
|
65090
|
+
return;
|
65091
|
+
callOnCrawlEnd();
|
65092
|
+
}
|
65093
|
+
return {
|
65094
|
+
registerRequestProcessing,
|
65095
|
+
waitForRequestsIdle,
|
65096
|
+
cancel,
|
65097
|
+
};
|
65098
|
+
}
|
64935
65099
|
|
64936
65100
|
var index = {
|
64937
65101
|
__proto__: null,
|
@@ -65591,6 +65755,7 @@ function importAnalysisPlugin(config) {
|
|
65591
65755
|
const fsUtils = getFsUtils(config);
|
65592
65756
|
const clientPublicPath = path$o.posix.join(base, CLIENT_PUBLIC_PATH);
|
65593
65757
|
const enablePartialAccept = config.experimental?.hmrPartialAccept;
|
65758
|
+
const matchAlias = getAliasPatternMatcher(config.resolve.alias);
|
65594
65759
|
let server;
|
65595
65760
|
let _env;
|
65596
65761
|
let _ssrEnv;
|
@@ -65834,7 +65999,7 @@ function importAnalysisPlugin(config) {
|
|
65834
65999
|
return;
|
65835
66000
|
}
|
65836
66001
|
// skip ssr external
|
65837
|
-
if (ssr) {
|
66002
|
+
if (ssr && !matchAlias(specifier)) {
|
65838
66003
|
if (shouldExternalizeForSSR(specifier, importer, config)) {
|
65839
66004
|
return;
|
65840
66005
|
}
|
@@ -65895,7 +66060,7 @@ function importAnalysisPlugin(config) {
|
|
65895
66060
|
rewriteDone = true;
|
65896
66061
|
}
|
65897
66062
|
if (!rewriteDone) {
|
65898
|
-
const rewrittenUrl = JSON.stringify(url);
|
66063
|
+
const rewrittenUrl = JSON.stringify(partialEncodeURI(url));
|
65899
66064
|
const s = isDynamicImport ? start : start - 1;
|
65900
66065
|
const e = isDynamicImport ? end : end + 1;
|
65901
66066
|
str().overwrite(s, e, rewrittenUrl, {
|
@@ -66229,6 +66394,11 @@ function preload(baseModule, deps, importerUrl) {
|
|
66229
66394
|
// @ts-expect-error __VITE_IS_MODERN__ will be replaced with boolean later
|
66230
66395
|
if (__VITE_IS_MODERN__ && deps && deps.length > 0) {
|
66231
66396
|
const links = document.getElementsByTagName('link');
|
66397
|
+
const cspNonceMeta = document.querySelector('meta[property=csp-nonce]');
|
66398
|
+
// `.nonce` should be used to get along with nonce hiding (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce#accessing_nonces_and_nonce_hiding)
|
66399
|
+
// Firefox 67-74 uses modern chunks and supports CSP nonce, but does not support `.nonce`
|
66400
|
+
// in that case fallback to getAttribute
|
66401
|
+
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute('nonce');
|
66232
66402
|
promise = Promise.all(deps.map((dep) => {
|
66233
66403
|
// @ts-expect-error assetsURL is declared before preload.toString()
|
66234
66404
|
dep = assetsURL(dep, importerUrl);
|
@@ -66261,6 +66431,9 @@ function preload(baseModule, deps, importerUrl) {
|
|
66261
66431
|
link.crossOrigin = '';
|
66262
66432
|
}
|
66263
66433
|
link.href = dep;
|
66434
|
+
if (cspNonce) {
|
66435
|
+
link.setAttribute('nonce', cspNonce);
|
66436
|
+
}
|
66264
66437
|
document.head.appendChild(link);
|
66265
66438
|
if (isCss) {
|
66266
66439
|
return new Promise((res, rej) => {
|
@@ -67322,7 +67495,7 @@ function escapeId(id) {
|
|
67322
67495
|
return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
|
67323
67496
|
}
|
67324
67497
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
67325
|
-
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
67498
|
+
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
67326
67499
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
67327
67500
|
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
|
67328
67501
|
const relativeUrlMechanisms = {
|
@@ -67332,16 +67505,16 @@ const relativeUrlMechanisms = {
|
|
67332
67505
|
return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
|
67333
67506
|
},
|
67334
67507
|
cjs: (relativePath) => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
|
67335
|
-
es: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', import.meta.url`),
|
67508
|
+
es: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', import.meta.url`),
|
67336
67509
|
iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
|
67337
67510
|
// NOTE: make sure rollup generate `module` params
|
67338
|
-
system: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', module.meta.url`),
|
67511
|
+
system: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', module.meta.url`),
|
67339
67512
|
umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
|
67340
67513
|
};
|
67341
67514
|
/* end of copy */
|
67342
67515
|
const customRelativeUrlMechanisms = {
|
67343
67516
|
...relativeUrlMechanisms,
|
67344
|
-
'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', self.location.href`),
|
67517
|
+
'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', self.location.href`),
|
67345
67518
|
};
|
67346
67519
|
function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
|
67347
67520
|
const { renderBuiltUrl } = config.experimental;
|
@@ -67432,111 +67605,119 @@ var build$1 = {
|
|
67432
67605
|
toOutputFilePathWithoutRuntime: toOutputFilePathWithoutRuntime
|
67433
67606
|
};
|
67434
67607
|
|
67435
|
-
|
67436
|
-
|
67437
|
-
|
67438
|
-
|
67439
|
-
|
67440
|
-
|
67441
|
-
|
67442
|
-
|
67443
|
-
|
67444
|
-
|
67445
|
-
|
67446
|
-
|
67447
|
-
|
67448
|
-
|
67449
|
-
|
67450
|
-
|
67451
|
-
|
67452
|
-
|
67453
|
-
|
67454
|
-
|
67455
|
-
|
67456
|
-
|
67457
|
-
|
67458
|
-
|
67459
|
-
|
67460
|
-
|
67461
|
-
|
67462
|
-
|
67463
|
-
|
67464
|
-
|
67465
|
-
|
67466
|
-
|
67467
|
-
|
67468
|
-
|
67469
|
-
|
67470
|
-
|
67471
|
-
|
67472
|
-
|
67473
|
-
|
67474
|
-
|
67475
|
-
|
67476
|
-
|
67477
|
-
|
67478
|
-
|
67479
|
-
|
67480
|
-
|
67481
|
-
|
67482
|
-
|
67483
|
-
|
67484
|
-
|
67485
|
-
|
67486
|
-
|
67487
|
-
|
67488
|
-
|
67489
|
-
|
67490
|
-
|
67491
|
-
|
67492
|
-
|
67493
|
-
|
67494
|
-
|
67495
|
-
|
67496
|
-
|
67497
|
-
|
67498
|
-
|
67499
|
-
|
67500
|
-
|
67501
|
-
|
67502
|
-
|
67503
|
-
|
67504
|
-
|
67505
|
-
|
67506
|
-
|
67507
|
-
|
67508
|
-
|
67509
|
-
|
67510
|
-
|
67511
|
-
|
67512
|
-
|
67513
|
-
|
67514
|
-
|
67515
|
-
|
67516
|
-
|
67517
|
-
|
67518
|
-
|
67519
|
-
|
67520
|
-
|
67521
|
-
|
67522
|
-
|
67523
|
-
|
67524
|
-
|
67525
|
-
|
67526
|
-
|
67527
|
-
|
67528
|
-
|
67529
|
-
|
67530
|
-
|
67531
|
-
|
67532
|
-
|
67533
|
-
|
67534
|
-
|
67535
|
-
|
67536
|
-
|
67537
|
-
|
67538
|
-
|
67539
|
-
|
67608
|
+
// NOTE: supports Node 6.x
|
67609
|
+
|
67610
|
+
|
67611
|
+
const NOOP = () => {};
|
67612
|
+
const MIMES = /text|javascript|\/json|xml/i;
|
67613
|
+
|
67614
|
+
/**
|
67615
|
+
* @param {any} chunk
|
67616
|
+
* @param {BufferEncoding} enc
|
67617
|
+
* @returns {number}
|
67618
|
+
*/
|
67619
|
+
function getChunkSize(chunk, enc) {
|
67620
|
+
return chunk ? Buffer.byteLength(chunk, enc) : 0;
|
67621
|
+
}
|
67622
|
+
|
67623
|
+
/**
|
67624
|
+
* @param {import('./index.d.mts').Options} [options]
|
67625
|
+
* @returns {import('./index.d.mts').Middleware}
|
67626
|
+
*/
|
67627
|
+
function compression ({ threshold = 1024, level = -1, brotli = false, gzip = true, mimes = MIMES } = {}) {
|
67628
|
+
const brotliOpts = (typeof brotli === 'object' && brotli) || {};
|
67629
|
+
const gzipOpts = (typeof gzip === 'object' && gzip) || {};
|
67630
|
+
|
67631
|
+
// disable Brotli on Node<12.7 where it is unsupported:
|
67632
|
+
if (!zlib$1.createBrotliCompress) brotli = false;
|
67633
|
+
|
67634
|
+
return (req, res, next = NOOP) => {
|
67635
|
+
const accept = req.headers['accept-encoding'] + '';
|
67636
|
+
const encoding = ((brotli && accept.match(/\bbr\b/)) || (gzip && accept.match(/\bgzip\b/)) || [])[0];
|
67637
|
+
|
67638
|
+
// skip if no response body or no supported encoding:
|
67639
|
+
if (req.method === 'HEAD' || !encoding) return next();
|
67640
|
+
|
67641
|
+
/** @type {zlib.Gzip | zlib.BrotliCompress} */
|
67642
|
+
let compress;
|
67643
|
+
/** @type {Array<[string, function]>?} */
|
67644
|
+
let pendingListeners = [];
|
67645
|
+
let pendingStatus = 0;
|
67646
|
+
let started = false;
|
67647
|
+
let size = 0;
|
67648
|
+
|
67649
|
+
function start() {
|
67650
|
+
started = true;
|
67651
|
+
// @ts-ignore
|
67652
|
+
size = res.getHeader('Content-Length') | 0 || size;
|
67653
|
+
const compressible = mimes.test(
|
67654
|
+
String(res.getHeader('Content-Type') || 'text/plain')
|
67655
|
+
);
|
67656
|
+
const cleartext = !res.getHeader('Content-Encoding');
|
67657
|
+
const listeners = pendingListeners || [];
|
67658
|
+
|
67659
|
+
if (compressible && cleartext && size >= threshold) {
|
67660
|
+
res.setHeader('Content-Encoding', encoding);
|
67661
|
+
res.removeHeader('Content-Length');
|
67662
|
+
if (encoding === 'br') {
|
67663
|
+
compress = zlib$1.createBrotliCompress({
|
67664
|
+
params: Object.assign({
|
67665
|
+
[zlib$1.constants.BROTLI_PARAM_QUALITY]: level,
|
67666
|
+
[zlib$1.constants.BROTLI_PARAM_SIZE_HINT]: size,
|
67667
|
+
}, brotliOpts)
|
67668
|
+
});
|
67669
|
+
} else {
|
67670
|
+
compress = zlib$1.createGzip(
|
67671
|
+
Object.assign({ level }, gzipOpts)
|
67672
|
+
);
|
67673
|
+
}
|
67674
|
+
// backpressure
|
67675
|
+
compress.on('data', chunk => write.call(res, chunk) || compress.pause());
|
67676
|
+
on.call(res, 'drain', () => compress.resume());
|
67677
|
+
compress.on('end', () => end.call(res));
|
67678
|
+
listeners.forEach(p => compress.on.apply(compress, p));
|
67679
|
+
} else {
|
67680
|
+
pendingListeners = null;
|
67681
|
+
listeners.forEach(p => on.apply(res, p));
|
67682
|
+
}
|
67683
|
+
|
67684
|
+
writeHead.call(res, pendingStatus || res.statusCode);
|
67685
|
+
}
|
67686
|
+
|
67687
|
+
const { end, write, on, writeHead } = res;
|
67688
|
+
|
67689
|
+
res.writeHead = function (status, reason, headers) {
|
67690
|
+
if (typeof reason !== 'string') [headers, reason] = [reason, headers];
|
67691
|
+
if (headers) for (let k in headers) res.setHeader(k, headers[k]);
|
67692
|
+
pendingStatus = status;
|
67693
|
+
return this;
|
67694
|
+
};
|
67695
|
+
|
67696
|
+
res.write = function (chunk, enc) {
|
67697
|
+
size += getChunkSize(chunk, enc);
|
67698
|
+
if (!started) start();
|
67699
|
+
if (!compress) return write.apply(this, arguments);
|
67700
|
+
return compress.write.apply(compress, arguments);
|
67701
|
+
};
|
67702
|
+
|
67703
|
+
res.end = function (chunk, enc) {
|
67704
|
+
if (arguments.length > 0 && typeof chunk !== 'function') {
|
67705
|
+
size += getChunkSize(chunk, enc);
|
67706
|
+
}
|
67707
|
+
if (!started) start();
|
67708
|
+
if (!compress) return end.apply(this, arguments);
|
67709
|
+
return compress.end.apply(compress, arguments);
|
67710
|
+
};
|
67711
|
+
|
67712
|
+
res.on = function (type, listener) {
|
67713
|
+
if (!pendingListeners) on.call(this, type, listener);
|
67714
|
+
else if (compress) compress.on(type, listener);
|
67715
|
+
else pendingListeners.push([type, listener]);
|
67716
|
+
return this;
|
67717
|
+
};
|
67718
|
+
|
67719
|
+
next();
|
67720
|
+
};
|
67540
67721
|
}
|
67541
67722
|
|
67542
67723
|
function resolvePreviewOptions(preview, server) {
|
@@ -68158,6 +68339,8 @@ async function bundleConfigFile(fileName, isESM) {
|
|
68158
68339
|
__dirname: dirnameVarName,
|
68159
68340
|
__filename: filenameVarName,
|
68160
68341
|
'import.meta.url': importMetaUrlVarName,
|
68342
|
+
'import.meta.dirname': dirnameVarName,
|
68343
|
+
'import.meta.filename': filenameVarName,
|
68161
68344
|
},
|
68162
68345
|
plugins: [
|
68163
68346
|
{
|