vite 3.0.0-alpha.0 → 3.0.0-alpha.3

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.
Files changed (92) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin/vite.js +5 -5
  3. package/client.d.ts +4 -2
  4. package/dist/client/client.mjs +23 -19
  5. package/dist/client/client.mjs.map +1 -1
  6. package/dist/node/build.d.ts +178 -0
  7. package/dist/node/certificate.d.ts +2 -0
  8. package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
  9. package/dist/node/chunks/{dep-dfbd0b0c.js → dep-5eede05c.js} +40 -37
  10. package/dist/node/chunks/{dep-fafc4143.js → dep-6f5ac69c.js} +1681 -1636
  11. package/dist/node/chunks/{dep-2d9eaf08.js → dep-b1fc04c1.js} +27 -29
  12. package/dist/node/chunks/{dep-63fe0f22.js → dep-da8244f4.js} +12 -6
  13. package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
  14. package/dist/node/cli.d.ts +1 -0
  15. package/dist/node/cli.js +43 -48
  16. package/dist/node/config.d.ts +240 -0
  17. package/dist/node/constants.d.ts +35 -0
  18. package/dist/node/constants.js +82 -0
  19. package/dist/node/env.d.ts +3 -0
  20. package/dist/node/http.d.ts +88 -0
  21. package/dist/node/index.d.ts +12 -4
  22. package/dist/node/index.js +37 -60
  23. package/dist/node/logger.d.ts +31 -0
  24. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  25. package/dist/node/optimizer/index.d.ts +154 -0
  26. package/dist/node/optimizer/registerMissing.d.ts +3 -0
  27. package/dist/node/optimizer/scan.d.ts +8 -0
  28. package/dist/node/packages.d.ts +27 -0
  29. package/dist/node/plugin.d.ts +129 -0
  30. package/dist/node/plugins/asset.d.ts +68 -0
  31. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  32. package/dist/node/plugins/clientInjections.d.ts +7 -0
  33. package/dist/node/plugins/css.d.ts +86 -0
  34. package/dist/node/plugins/dataUri.d.ts +5 -0
  35. package/dist/node/plugins/define.d.ts +3 -0
  36. package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
  37. package/dist/node/plugins/ensureWatch.d.ts +5 -0
  38. package/dist/node/plugins/esbuild.d.ts +15 -0
  39. package/dist/node/plugins/html.d.ts +120 -0
  40. package/dist/node/plugins/importAnalysis.d.ts +47 -0
  41. package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
  42. package/dist/node/plugins/importMetaGlob.d.ts +34 -0
  43. package/dist/node/plugins/index.d.ts +3 -0
  44. package/dist/node/plugins/json.d.ts +23 -0
  45. package/dist/node/plugins/loadFallback.d.ts +5 -0
  46. package/dist/node/plugins/manifest.d.ts +14 -0
  47. package/dist/node/plugins/metadata.d.ts +9 -0
  48. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  49. package/dist/node/plugins/optimizedDeps.d.ts +4 -0
  50. package/dist/node/plugins/preAlias.d.ts +5 -0
  51. package/dist/node/plugins/reporter.d.ts +3 -0
  52. package/dist/node/plugins/resolve.d.ts +39 -0
  53. package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
  54. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  55. package/dist/node/plugins/terser.d.ts +3 -0
  56. package/dist/node/plugins/wasm.d.ts +4 -0
  57. package/dist/node/plugins/worker.d.ts +9 -0
  58. package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
  59. package/dist/node/preview.d.ts +33 -0
  60. package/dist/node/publicUtils.d.ts +11 -0
  61. package/dist/node/server/hmr.d.ts +39 -0
  62. package/dist/node/server/index.d.ts +198 -0
  63. package/dist/node/server/middlewares/base.d.ts +3 -0
  64. package/dist/node/server/middlewares/compression.d.ts +1 -0
  65. package/dist/node/server/middlewares/error.d.ts +8 -0
  66. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  67. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  68. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  69. package/dist/node/server/middlewares/static.d.ts +6 -0
  70. package/dist/node/server/middlewares/time.d.ts +2 -0
  71. package/dist/node/server/middlewares/transform.d.ts +3 -0
  72. package/dist/node/server/moduleGraph.d.ts +55 -0
  73. package/dist/node/server/openBrowser.d.ts +15 -0
  74. package/dist/node/server/pluginContainer.d.ts +41 -0
  75. package/dist/node/server/searchRoot.d.ts +8 -0
  76. package/dist/node/server/send.d.ts +10 -0
  77. package/dist/node/server/sourcemap.d.ts +11 -0
  78. package/dist/node/server/transformRequest.d.ts +14 -0
  79. package/dist/node/server/ws.d.ts +55 -0
  80. package/dist/node/ssr/ssrExternal.d.ts +11 -0
  81. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  82. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  83. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  84. package/dist/node/ssr/ssrTransform.d.ts +14 -0
  85. package/dist/node/utils.d.ts +144 -0
  86. package/dist/node-cjs/publicUtils.cjs +2047 -0
  87. package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
  88. package/index.cjs +33 -0
  89. package/package.json +23 -6
  90. package/src/client/client.ts +22 -16
  91. package/src/client/tsconfig.json +1 -1
  92. package/types/importGlob.d.ts +1 -3
@@ -0,0 +1,2047 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fs$1 = require('fs');
6
+ var os$1 = require('os');
7
+ var path$1 = require('path');
8
+ var require$$1 = require('util');
9
+ var module$1 = require('module');
10
+ var require$$0 = require('tty');
11
+ var url = require('url');
12
+ var require$$0$1 = require('crypto');
13
+ var readline = require('readline');
14
+
15
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
16
+
17
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
18
+ var os__default = /*#__PURE__*/_interopDefaultLegacy(os$1);
19
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
20
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
21
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
22
+ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
23
+ var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
24
+
25
+ // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
26
+ const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
27
+ const cssLangRE = new RegExp(cssLangs);
28
+ const isCSSRequest = (request) => cssLangRE.test(request);
29
+ // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
30
+ // We don't recommend using this strategy as a general solution moving forward
31
+ // splitVendorChunk is a simple index/vendor strategy that was used in Vite
32
+ // until v2.8. It is exposed to let people continue to use it in case it was
33
+ // working well for their setups.
34
+ // The cache needs to be reset on buildStart for watch mode to work correctly
35
+ // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
36
+ class SplitVendorChunkCache {
37
+ constructor() {
38
+ this.cache = new Map();
39
+ }
40
+ reset() {
41
+ this.cache = new Map();
42
+ }
43
+ }
44
+ function splitVendorChunk(options = {}) {
45
+ const cache = options.cache ?? new SplitVendorChunkCache();
46
+ return (id, { getModuleInfo }) => {
47
+ if (id.includes('node_modules') &&
48
+ !isCSSRequest(id) &&
49
+ staticImportedByEntry(id, getModuleInfo, cache.cache)) {
50
+ return 'vendor';
51
+ }
52
+ };
53
+ }
54
+ function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
55
+ if (cache.has(id)) {
56
+ return cache.get(id);
57
+ }
58
+ if (importStack.includes(id)) {
59
+ // circular deps!
60
+ cache.set(id, false);
61
+ return false;
62
+ }
63
+ const mod = getModuleInfo(id);
64
+ if (!mod) {
65
+ cache.set(id, false);
66
+ return false;
67
+ }
68
+ if (mod.isEntry) {
69
+ cache.set(id, true);
70
+ return true;
71
+ }
72
+ const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
73
+ cache.set(id, someImporterIs);
74
+ return someImporterIs;
75
+ }
76
+ function splitVendorChunkPlugin() {
77
+ const caches = [];
78
+ function createSplitVendorChunk(output, config) {
79
+ const cache = new SplitVendorChunkCache();
80
+ caches.push(cache);
81
+ const build = config.build ?? {};
82
+ const format = output?.format;
83
+ if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
84
+ return splitVendorChunk({ cache });
85
+ }
86
+ }
87
+ return {
88
+ name: 'vite:split-vendor-chunk',
89
+ config(config) {
90
+ let outputs = config?.build?.rollupOptions?.output;
91
+ if (outputs) {
92
+ outputs = Array.isArray(outputs) ? outputs : [outputs];
93
+ for (const output of outputs) {
94
+ const viteManualChunks = createSplitVendorChunk(output, config);
95
+ if (viteManualChunks) {
96
+ if (output.manualChunks) {
97
+ if (typeof output.manualChunks === 'function') {
98
+ const userManualChunks = output.manualChunks;
99
+ output.manualChunks = (id, api) => {
100
+ return userManualChunks(id, api) ?? viteManualChunks(id, api);
101
+ };
102
+ }
103
+ // else, leave the object form of manualChunks untouched, as
104
+ // we can't safely replicate rollup handling.
105
+ }
106
+ else {
107
+ output.manualChunks = viteManualChunks;
108
+ }
109
+ }
110
+ }
111
+ }
112
+ else {
113
+ return {
114
+ build: {
115
+ rollupOptions: {
116
+ output: {
117
+ manualChunks: createSplitVendorChunk({}, config)
118
+ }
119
+ }
120
+ }
121
+ };
122
+ }
123
+ },
124
+ buildStart() {
125
+ caches.forEach((cache) => cache.reset());
126
+ }
127
+ };
128
+ }
129
+
130
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
131
+ const intToChar = new Uint8Array(64); // 64 possible chars.
132
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
133
+ for (let i = 0; i < chars.length; i++) {
134
+ const c = chars.charCodeAt(i);
135
+ intToChar[i] = c;
136
+ charToInt[c] = i;
137
+ }
138
+
139
+ Object.freeze({
140
+ source: null,
141
+ line: null,
142
+ column: null,
143
+ name: null,
144
+ });
145
+ Object.freeze({
146
+ line: null,
147
+ column: null,
148
+ });
149
+
150
+ var picocolors = {exports: {}};
151
+
152
+ let tty = require$$0__default;
153
+
154
+ let isColorSupported =
155
+ !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
156
+ ("FORCE_COLOR" in process.env ||
157
+ process.argv.includes("--color") ||
158
+ process.platform === "win32" ||
159
+ (tty.isatty(1) && process.env.TERM !== "dumb") ||
160
+ "CI" in process.env);
161
+
162
+ let formatter =
163
+ (open, close, replace = open) =>
164
+ input => {
165
+ let string = "" + input;
166
+ let index = string.indexOf(close, open.length);
167
+ return ~index
168
+ ? open + replaceClose(string, close, replace, index) + close
169
+ : open + string + close
170
+ };
171
+
172
+ let replaceClose = (string, close, replace, index) => {
173
+ let start = string.substring(0, index) + replace;
174
+ let end = string.substring(index + close.length);
175
+ let nextIndex = end.indexOf(close);
176
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
177
+ };
178
+
179
+ let createColors = (enabled = isColorSupported) => ({
180
+ isColorSupported: enabled,
181
+ reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
182
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
183
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
184
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
185
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
186
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
187
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
188
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
189
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
190
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
191
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
192
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
193
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
194
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
195
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
196
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
197
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
198
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
199
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
200
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
201
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
202
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
203
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
204
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
205
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
206
+ });
207
+
208
+ picocolors.exports = createColors();
209
+ picocolors.exports.createColors = createColors;
210
+
211
+ var colors = picocolors.exports;
212
+
213
+ var src = {exports: {}};
214
+
215
+ var browser = {exports: {}};
216
+
217
+ /**
218
+ * Helpers.
219
+ */
220
+
221
+ var s = 1000;
222
+ var m = s * 60;
223
+ var h = m * 60;
224
+ var d = h * 24;
225
+ var w = d * 7;
226
+ var y = d * 365.25;
227
+
228
+ /**
229
+ * Parse or format the given `val`.
230
+ *
231
+ * Options:
232
+ *
233
+ * - `long` verbose formatting [false]
234
+ *
235
+ * @param {String|Number} val
236
+ * @param {Object} [options]
237
+ * @throws {Error} throw an error if val is not a non-empty string or a number
238
+ * @return {String|Number}
239
+ * @api public
240
+ */
241
+
242
+ var ms = function(val, options) {
243
+ options = options || {};
244
+ var type = typeof val;
245
+ if (type === 'string' && val.length > 0) {
246
+ return parse$1(val);
247
+ } else if (type === 'number' && isFinite(val)) {
248
+ return options.long ? fmtLong(val) : fmtShort(val);
249
+ }
250
+ throw new Error(
251
+ 'val is not a non-empty string or a valid number. val=' +
252
+ JSON.stringify(val)
253
+ );
254
+ };
255
+
256
+ /**
257
+ * Parse the given `str` and return milliseconds.
258
+ *
259
+ * @param {String} str
260
+ * @return {Number}
261
+ * @api private
262
+ */
263
+
264
+ function parse$1(str) {
265
+ str = String(str);
266
+ if (str.length > 100) {
267
+ return;
268
+ }
269
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
270
+ str
271
+ );
272
+ if (!match) {
273
+ return;
274
+ }
275
+ var n = parseFloat(match[1]);
276
+ var type = (match[2] || 'ms').toLowerCase();
277
+ switch (type) {
278
+ case 'years':
279
+ case 'year':
280
+ case 'yrs':
281
+ case 'yr':
282
+ case 'y':
283
+ return n * y;
284
+ case 'weeks':
285
+ case 'week':
286
+ case 'w':
287
+ return n * w;
288
+ case 'days':
289
+ case 'day':
290
+ case 'd':
291
+ return n * d;
292
+ case 'hours':
293
+ case 'hour':
294
+ case 'hrs':
295
+ case 'hr':
296
+ case 'h':
297
+ return n * h;
298
+ case 'minutes':
299
+ case 'minute':
300
+ case 'mins':
301
+ case 'min':
302
+ case 'm':
303
+ return n * m;
304
+ case 'seconds':
305
+ case 'second':
306
+ case 'secs':
307
+ case 'sec':
308
+ case 's':
309
+ return n * s;
310
+ case 'milliseconds':
311
+ case 'millisecond':
312
+ case 'msecs':
313
+ case 'msec':
314
+ case 'ms':
315
+ return n;
316
+ default:
317
+ return undefined;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Short format for `ms`.
323
+ *
324
+ * @param {Number} ms
325
+ * @return {String}
326
+ * @api private
327
+ */
328
+
329
+ function fmtShort(ms) {
330
+ var msAbs = Math.abs(ms);
331
+ if (msAbs >= d) {
332
+ return Math.round(ms / d) + 'd';
333
+ }
334
+ if (msAbs >= h) {
335
+ return Math.round(ms / h) + 'h';
336
+ }
337
+ if (msAbs >= m) {
338
+ return Math.round(ms / m) + 'm';
339
+ }
340
+ if (msAbs >= s) {
341
+ return Math.round(ms / s) + 's';
342
+ }
343
+ return ms + 'ms';
344
+ }
345
+
346
+ /**
347
+ * Long format for `ms`.
348
+ *
349
+ * @param {Number} ms
350
+ * @return {String}
351
+ * @api private
352
+ */
353
+
354
+ function fmtLong(ms) {
355
+ var msAbs = Math.abs(ms);
356
+ if (msAbs >= d) {
357
+ return plural(ms, msAbs, d, 'day');
358
+ }
359
+ if (msAbs >= h) {
360
+ return plural(ms, msAbs, h, 'hour');
361
+ }
362
+ if (msAbs >= m) {
363
+ return plural(ms, msAbs, m, 'minute');
364
+ }
365
+ if (msAbs >= s) {
366
+ return plural(ms, msAbs, s, 'second');
367
+ }
368
+ return ms + ' ms';
369
+ }
370
+
371
+ /**
372
+ * Pluralization helper.
373
+ */
374
+
375
+ function plural(ms, msAbs, n, name) {
376
+ var isPlural = msAbs >= n * 1.5;
377
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
378
+ }
379
+
380
+ /**
381
+ * This is the common logic for both the Node.js and web browser
382
+ * implementations of `debug()`.
383
+ */
384
+
385
+ function setup(env) {
386
+ createDebug.debug = createDebug;
387
+ createDebug.default = createDebug;
388
+ createDebug.coerce = coerce;
389
+ createDebug.disable = disable;
390
+ createDebug.enable = enable;
391
+ createDebug.enabled = enabled;
392
+ createDebug.humanize = ms;
393
+ createDebug.destroy = destroy;
394
+
395
+ Object.keys(env).forEach(key => {
396
+ createDebug[key] = env[key];
397
+ });
398
+
399
+ /**
400
+ * The currently active debug mode names, and names to skip.
401
+ */
402
+
403
+ createDebug.names = [];
404
+ createDebug.skips = [];
405
+
406
+ /**
407
+ * Map of special "%n" handling functions, for the debug "format" argument.
408
+ *
409
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
410
+ */
411
+ createDebug.formatters = {};
412
+
413
+ /**
414
+ * Selects a color for a debug namespace
415
+ * @param {String} namespace The namespace string for the debug instance to be colored
416
+ * @return {Number|String} An ANSI color code for the given namespace
417
+ * @api private
418
+ */
419
+ function selectColor(namespace) {
420
+ let hash = 0;
421
+
422
+ for (let i = 0; i < namespace.length; i++) {
423
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
424
+ hash |= 0; // Convert to 32bit integer
425
+ }
426
+
427
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
428
+ }
429
+ createDebug.selectColor = selectColor;
430
+
431
+ /**
432
+ * Create a debugger with the given `namespace`.
433
+ *
434
+ * @param {String} namespace
435
+ * @return {Function}
436
+ * @api public
437
+ */
438
+ function createDebug(namespace) {
439
+ let prevTime;
440
+ let enableOverride = null;
441
+ let namespacesCache;
442
+ let enabledCache;
443
+
444
+ function debug(...args) {
445
+ // Disabled?
446
+ if (!debug.enabled) {
447
+ return;
448
+ }
449
+
450
+ const self = debug;
451
+
452
+ // Set `diff` timestamp
453
+ const curr = Number(new Date());
454
+ const ms = curr - (prevTime || curr);
455
+ self.diff = ms;
456
+ self.prev = prevTime;
457
+ self.curr = curr;
458
+ prevTime = curr;
459
+
460
+ args[0] = createDebug.coerce(args[0]);
461
+
462
+ if (typeof args[0] !== 'string') {
463
+ // Anything else let's inspect with %O
464
+ args.unshift('%O');
465
+ }
466
+
467
+ // Apply any `formatters` transformations
468
+ let index = 0;
469
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
470
+ // If we encounter an escaped % then don't increase the array index
471
+ if (match === '%%') {
472
+ return '%';
473
+ }
474
+ index++;
475
+ const formatter = createDebug.formatters[format];
476
+ if (typeof formatter === 'function') {
477
+ const val = args[index];
478
+ match = formatter.call(self, val);
479
+
480
+ // Now we need to remove `args[index]` since it's inlined in the `format`
481
+ args.splice(index, 1);
482
+ index--;
483
+ }
484
+ return match;
485
+ });
486
+
487
+ // Apply env-specific formatting (colors, etc.)
488
+ createDebug.formatArgs.call(self, args);
489
+
490
+ const logFn = self.log || createDebug.log;
491
+ logFn.apply(self, args);
492
+ }
493
+
494
+ debug.namespace = namespace;
495
+ debug.useColors = createDebug.useColors();
496
+ debug.color = createDebug.selectColor(namespace);
497
+ debug.extend = extend;
498
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
499
+
500
+ Object.defineProperty(debug, 'enabled', {
501
+ enumerable: true,
502
+ configurable: false,
503
+ get: () => {
504
+ if (enableOverride !== null) {
505
+ return enableOverride;
506
+ }
507
+ if (namespacesCache !== createDebug.namespaces) {
508
+ namespacesCache = createDebug.namespaces;
509
+ enabledCache = createDebug.enabled(namespace);
510
+ }
511
+
512
+ return enabledCache;
513
+ },
514
+ set: v => {
515
+ enableOverride = v;
516
+ }
517
+ });
518
+
519
+ // Env-specific initialization logic for debug instances
520
+ if (typeof createDebug.init === 'function') {
521
+ createDebug.init(debug);
522
+ }
523
+
524
+ return debug;
525
+ }
526
+
527
+ function extend(namespace, delimiter) {
528
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
529
+ newDebug.log = this.log;
530
+ return newDebug;
531
+ }
532
+
533
+ /**
534
+ * Enables a debug mode by namespaces. This can include modes
535
+ * separated by a colon and wildcards.
536
+ *
537
+ * @param {String} namespaces
538
+ * @api public
539
+ */
540
+ function enable(namespaces) {
541
+ createDebug.save(namespaces);
542
+ createDebug.namespaces = namespaces;
543
+
544
+ createDebug.names = [];
545
+ createDebug.skips = [];
546
+
547
+ let i;
548
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
549
+ const len = split.length;
550
+
551
+ for (i = 0; i < len; i++) {
552
+ if (!split[i]) {
553
+ // ignore empty strings
554
+ continue;
555
+ }
556
+
557
+ namespaces = split[i].replace(/\*/g, '.*?');
558
+
559
+ if (namespaces[0] === '-') {
560
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
561
+ } else {
562
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
563
+ }
564
+ }
565
+ }
566
+
567
+ /**
568
+ * Disable debug output.
569
+ *
570
+ * @return {String} namespaces
571
+ * @api public
572
+ */
573
+ function disable() {
574
+ const namespaces = [
575
+ ...createDebug.names.map(toNamespace),
576
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
577
+ ].join(',');
578
+ createDebug.enable('');
579
+ return namespaces;
580
+ }
581
+
582
+ /**
583
+ * Returns true if the given mode name is enabled, false otherwise.
584
+ *
585
+ * @param {String} name
586
+ * @return {Boolean}
587
+ * @api public
588
+ */
589
+ function enabled(name) {
590
+ if (name[name.length - 1] === '*') {
591
+ return true;
592
+ }
593
+
594
+ let i;
595
+ let len;
596
+
597
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
598
+ if (createDebug.skips[i].test(name)) {
599
+ return false;
600
+ }
601
+ }
602
+
603
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
604
+ if (createDebug.names[i].test(name)) {
605
+ return true;
606
+ }
607
+ }
608
+
609
+ return false;
610
+ }
611
+
612
+ /**
613
+ * Convert regexp to namespace
614
+ *
615
+ * @param {RegExp} regxep
616
+ * @return {String} namespace
617
+ * @api private
618
+ */
619
+ function toNamespace(regexp) {
620
+ return regexp.toString()
621
+ .substring(2, regexp.toString().length - 2)
622
+ .replace(/\.\*\?$/, '*');
623
+ }
624
+
625
+ /**
626
+ * Coerce `val`.
627
+ *
628
+ * @param {Mixed} val
629
+ * @return {Mixed}
630
+ * @api private
631
+ */
632
+ function coerce(val) {
633
+ if (val instanceof Error) {
634
+ return val.stack || val.message;
635
+ }
636
+ return val;
637
+ }
638
+
639
+ /**
640
+ * XXX DO NOT USE. This is a temporary stub function.
641
+ * XXX It WILL be removed in the next major release.
642
+ */
643
+ function destroy() {
644
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
645
+ }
646
+
647
+ createDebug.enable(createDebug.load());
648
+
649
+ return createDebug;
650
+ }
651
+
652
+ var common = setup;
653
+
654
+ /* eslint-env browser */
655
+
656
+ (function (module, exports) {
657
+ /**
658
+ * This is the web browser implementation of `debug()`.
659
+ */
660
+
661
+ exports.formatArgs = formatArgs;
662
+ exports.save = save;
663
+ exports.load = load;
664
+ exports.useColors = useColors;
665
+ exports.storage = localstorage();
666
+ exports.destroy = (() => {
667
+ let warned = false;
668
+
669
+ return () => {
670
+ if (!warned) {
671
+ warned = true;
672
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
673
+ }
674
+ };
675
+ })();
676
+
677
+ /**
678
+ * Colors.
679
+ */
680
+
681
+ exports.colors = [
682
+ '#0000CC',
683
+ '#0000FF',
684
+ '#0033CC',
685
+ '#0033FF',
686
+ '#0066CC',
687
+ '#0066FF',
688
+ '#0099CC',
689
+ '#0099FF',
690
+ '#00CC00',
691
+ '#00CC33',
692
+ '#00CC66',
693
+ '#00CC99',
694
+ '#00CCCC',
695
+ '#00CCFF',
696
+ '#3300CC',
697
+ '#3300FF',
698
+ '#3333CC',
699
+ '#3333FF',
700
+ '#3366CC',
701
+ '#3366FF',
702
+ '#3399CC',
703
+ '#3399FF',
704
+ '#33CC00',
705
+ '#33CC33',
706
+ '#33CC66',
707
+ '#33CC99',
708
+ '#33CCCC',
709
+ '#33CCFF',
710
+ '#6600CC',
711
+ '#6600FF',
712
+ '#6633CC',
713
+ '#6633FF',
714
+ '#66CC00',
715
+ '#66CC33',
716
+ '#9900CC',
717
+ '#9900FF',
718
+ '#9933CC',
719
+ '#9933FF',
720
+ '#99CC00',
721
+ '#99CC33',
722
+ '#CC0000',
723
+ '#CC0033',
724
+ '#CC0066',
725
+ '#CC0099',
726
+ '#CC00CC',
727
+ '#CC00FF',
728
+ '#CC3300',
729
+ '#CC3333',
730
+ '#CC3366',
731
+ '#CC3399',
732
+ '#CC33CC',
733
+ '#CC33FF',
734
+ '#CC6600',
735
+ '#CC6633',
736
+ '#CC9900',
737
+ '#CC9933',
738
+ '#CCCC00',
739
+ '#CCCC33',
740
+ '#FF0000',
741
+ '#FF0033',
742
+ '#FF0066',
743
+ '#FF0099',
744
+ '#FF00CC',
745
+ '#FF00FF',
746
+ '#FF3300',
747
+ '#FF3333',
748
+ '#FF3366',
749
+ '#FF3399',
750
+ '#FF33CC',
751
+ '#FF33FF',
752
+ '#FF6600',
753
+ '#FF6633',
754
+ '#FF9900',
755
+ '#FF9933',
756
+ '#FFCC00',
757
+ '#FFCC33'
758
+ ];
759
+
760
+ /**
761
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
762
+ * and the Firebug extension (any Firefox version) are known
763
+ * to support "%c" CSS customizations.
764
+ *
765
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
766
+ */
767
+
768
+ // eslint-disable-next-line complexity
769
+ function useColors() {
770
+ // NB: In an Electron preload script, document will be defined but not fully
771
+ // initialized. Since we know we're in Chrome, we'll just detect this case
772
+ // explicitly
773
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
774
+ return true;
775
+ }
776
+
777
+ // Internet Explorer and Edge do not support colors.
778
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
779
+ return false;
780
+ }
781
+
782
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
783
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
784
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
785
+ // Is firebug? http://stackoverflow.com/a/398120/376773
786
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
787
+ // Is firefox >= v31?
788
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
789
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
790
+ // Double check webkit in userAgent just in case we are in a worker
791
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
792
+ }
793
+
794
+ /**
795
+ * Colorize log arguments if enabled.
796
+ *
797
+ * @api public
798
+ */
799
+
800
+ function formatArgs(args) {
801
+ args[0] = (this.useColors ? '%c' : '') +
802
+ this.namespace +
803
+ (this.useColors ? ' %c' : ' ') +
804
+ args[0] +
805
+ (this.useColors ? '%c ' : ' ') +
806
+ '+' + module.exports.humanize(this.diff);
807
+
808
+ if (!this.useColors) {
809
+ return;
810
+ }
811
+
812
+ const c = 'color: ' + this.color;
813
+ args.splice(1, 0, c, 'color: inherit');
814
+
815
+ // The final "%c" is somewhat tricky, because there could be other
816
+ // arguments passed either before or after the %c, so we need to
817
+ // figure out the correct index to insert the CSS into
818
+ let index = 0;
819
+ let lastC = 0;
820
+ args[0].replace(/%[a-zA-Z%]/g, match => {
821
+ if (match === '%%') {
822
+ return;
823
+ }
824
+ index++;
825
+ if (match === '%c') {
826
+ // We only are interested in the *last* %c
827
+ // (the user may have provided their own)
828
+ lastC = index;
829
+ }
830
+ });
831
+
832
+ args.splice(lastC, 0, c);
833
+ }
834
+
835
+ /**
836
+ * Invokes `console.debug()` when available.
837
+ * No-op when `console.debug` is not a "function".
838
+ * If `console.debug` is not available, falls back
839
+ * to `console.log`.
840
+ *
841
+ * @api public
842
+ */
843
+ exports.log = console.debug || console.log || (() => {});
844
+
845
+ /**
846
+ * Save `namespaces`.
847
+ *
848
+ * @param {String} namespaces
849
+ * @api private
850
+ */
851
+ function save(namespaces) {
852
+ try {
853
+ if (namespaces) {
854
+ exports.storage.setItem('debug', namespaces);
855
+ } else {
856
+ exports.storage.removeItem('debug');
857
+ }
858
+ } catch (error) {
859
+ // Swallow
860
+ // XXX (@Qix-) should we be logging these?
861
+ }
862
+ }
863
+
864
+ /**
865
+ * Load `namespaces`.
866
+ *
867
+ * @return {String} returns the previously persisted debug modes
868
+ * @api private
869
+ */
870
+ function load() {
871
+ let r;
872
+ try {
873
+ r = exports.storage.getItem('debug');
874
+ } catch (error) {
875
+ // Swallow
876
+ // XXX (@Qix-) should we be logging these?
877
+ }
878
+
879
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
880
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
881
+ r = process.env.DEBUG;
882
+ }
883
+
884
+ return r;
885
+ }
886
+
887
+ /**
888
+ * Localstorage attempts to return the localstorage.
889
+ *
890
+ * This is necessary because safari throws
891
+ * when a user disables cookies/localstorage
892
+ * and you attempt to access it.
893
+ *
894
+ * @return {LocalStorage}
895
+ * @api private
896
+ */
897
+
898
+ function localstorage() {
899
+ try {
900
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
901
+ // The Browser also has localStorage in the global context.
902
+ return localStorage;
903
+ } catch (error) {
904
+ // Swallow
905
+ // XXX (@Qix-) should we be logging these?
906
+ }
907
+ }
908
+
909
+ module.exports = common(exports);
910
+
911
+ const {formatters} = module.exports;
912
+
913
+ /**
914
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
915
+ */
916
+
917
+ formatters.j = function (v) {
918
+ try {
919
+ return JSON.stringify(v);
920
+ } catch (error) {
921
+ return '[UnexpectedJSONParseError]: ' + error.message;
922
+ }
923
+ };
924
+ }(browser, browser.exports));
925
+
926
+ var node = {exports: {}};
927
+
928
+ /**
929
+ * Module dependencies.
930
+ */
931
+
932
+ (function (module, exports) {
933
+ const tty = require$$0__default;
934
+ const util = require$$1__default;
935
+
936
+ /**
937
+ * This is the Node.js implementation of `debug()`.
938
+ */
939
+
940
+ exports.init = init;
941
+ exports.log = log;
942
+ exports.formatArgs = formatArgs;
943
+ exports.save = save;
944
+ exports.load = load;
945
+ exports.useColors = useColors;
946
+ exports.destroy = util.deprecate(
947
+ () => {},
948
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
949
+ );
950
+
951
+ /**
952
+ * Colors.
953
+ */
954
+
955
+ exports.colors = [6, 2, 3, 4, 5, 1];
956
+
957
+ try {
958
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
959
+ // eslint-disable-next-line import/no-extraneous-dependencies
960
+ const supportsColor = require('supports-color');
961
+
962
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
963
+ exports.colors = [
964
+ 20,
965
+ 21,
966
+ 26,
967
+ 27,
968
+ 32,
969
+ 33,
970
+ 38,
971
+ 39,
972
+ 40,
973
+ 41,
974
+ 42,
975
+ 43,
976
+ 44,
977
+ 45,
978
+ 56,
979
+ 57,
980
+ 62,
981
+ 63,
982
+ 68,
983
+ 69,
984
+ 74,
985
+ 75,
986
+ 76,
987
+ 77,
988
+ 78,
989
+ 79,
990
+ 80,
991
+ 81,
992
+ 92,
993
+ 93,
994
+ 98,
995
+ 99,
996
+ 112,
997
+ 113,
998
+ 128,
999
+ 129,
1000
+ 134,
1001
+ 135,
1002
+ 148,
1003
+ 149,
1004
+ 160,
1005
+ 161,
1006
+ 162,
1007
+ 163,
1008
+ 164,
1009
+ 165,
1010
+ 166,
1011
+ 167,
1012
+ 168,
1013
+ 169,
1014
+ 170,
1015
+ 171,
1016
+ 172,
1017
+ 173,
1018
+ 178,
1019
+ 179,
1020
+ 184,
1021
+ 185,
1022
+ 196,
1023
+ 197,
1024
+ 198,
1025
+ 199,
1026
+ 200,
1027
+ 201,
1028
+ 202,
1029
+ 203,
1030
+ 204,
1031
+ 205,
1032
+ 206,
1033
+ 207,
1034
+ 208,
1035
+ 209,
1036
+ 214,
1037
+ 215,
1038
+ 220,
1039
+ 221
1040
+ ];
1041
+ }
1042
+ } catch (error) {
1043
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
1044
+ }
1045
+
1046
+ /**
1047
+ * Build up the default `inspectOpts` object from the environment variables.
1048
+ *
1049
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1050
+ */
1051
+
1052
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
1053
+ return /^debug_/i.test(key);
1054
+ }).reduce((obj, key) => {
1055
+ // Camel-case
1056
+ const prop = key
1057
+ .substring(6)
1058
+ .toLowerCase()
1059
+ .replace(/_([a-z])/g, (_, k) => {
1060
+ return k.toUpperCase();
1061
+ });
1062
+
1063
+ // Coerce string value into JS value
1064
+ let val = process.env[key];
1065
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
1066
+ val = true;
1067
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
1068
+ val = false;
1069
+ } else if (val === 'null') {
1070
+ val = null;
1071
+ } else {
1072
+ val = Number(val);
1073
+ }
1074
+
1075
+ obj[prop] = val;
1076
+ return obj;
1077
+ }, {});
1078
+
1079
+ /**
1080
+ * Is stdout a TTY? Colored output is enabled when `true`.
1081
+ */
1082
+
1083
+ function useColors() {
1084
+ return 'colors' in exports.inspectOpts ?
1085
+ Boolean(exports.inspectOpts.colors) :
1086
+ tty.isatty(process.stderr.fd);
1087
+ }
1088
+
1089
+ /**
1090
+ * Adds ANSI color escape codes if enabled.
1091
+ *
1092
+ * @api public
1093
+ */
1094
+
1095
+ function formatArgs(args) {
1096
+ const {namespace: name, useColors} = this;
1097
+
1098
+ if (useColors) {
1099
+ const c = this.color;
1100
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
1101
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
1102
+
1103
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
1104
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
1105
+ } else {
1106
+ args[0] = getDate() + name + ' ' + args[0];
1107
+ }
1108
+ }
1109
+
1110
+ function getDate() {
1111
+ if (exports.inspectOpts.hideDate) {
1112
+ return '';
1113
+ }
1114
+ return new Date().toISOString() + ' ';
1115
+ }
1116
+
1117
+ /**
1118
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
1119
+ */
1120
+
1121
+ function log(...args) {
1122
+ return process.stderr.write(util.format(...args) + '\n');
1123
+ }
1124
+
1125
+ /**
1126
+ * Save `namespaces`.
1127
+ *
1128
+ * @param {String} namespaces
1129
+ * @api private
1130
+ */
1131
+ function save(namespaces) {
1132
+ if (namespaces) {
1133
+ process.env.DEBUG = namespaces;
1134
+ } else {
1135
+ // If you set a process.env field to null or undefined, it gets cast to the
1136
+ // string 'null' or 'undefined'. Just delete instead.
1137
+ delete process.env.DEBUG;
1138
+ }
1139
+ }
1140
+
1141
+ /**
1142
+ * Load `namespaces`.
1143
+ *
1144
+ * @return {String} returns the previously persisted debug modes
1145
+ * @api private
1146
+ */
1147
+
1148
+ function load() {
1149
+ return process.env.DEBUG;
1150
+ }
1151
+
1152
+ /**
1153
+ * Init logic for `debug` instances.
1154
+ *
1155
+ * Create a new `inspectOpts` object in case `useColors` is set
1156
+ * differently for a particular `debug` instance.
1157
+ */
1158
+
1159
+ function init(debug) {
1160
+ debug.inspectOpts = {};
1161
+
1162
+ const keys = Object.keys(exports.inspectOpts);
1163
+ for (let i = 0; i < keys.length; i++) {
1164
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1165
+ }
1166
+ }
1167
+
1168
+ module.exports = common(exports);
1169
+
1170
+ const {formatters} = module.exports;
1171
+
1172
+ /**
1173
+ * Map %o to `util.inspect()`, all on a single line.
1174
+ */
1175
+
1176
+ formatters.o = function (v) {
1177
+ this.inspectOpts.colors = this.useColors;
1178
+ return util.inspect(v, this.inspectOpts)
1179
+ .split('\n')
1180
+ .map(str => str.trim())
1181
+ .join(' ');
1182
+ };
1183
+
1184
+ /**
1185
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
1186
+ */
1187
+
1188
+ formatters.O = function (v) {
1189
+ this.inspectOpts.colors = this.useColors;
1190
+ return util.inspect(v, this.inspectOpts);
1191
+ };
1192
+ }(node, node.exports));
1193
+
1194
+ /**
1195
+ * Detect Electron renderer / nwjs process, which is node, but we should
1196
+ * treat as a browser.
1197
+ */
1198
+
1199
+ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
1200
+ src.exports = browser.exports;
1201
+ } else {
1202
+ src.exports = node.exports;
1203
+ }
1204
+
1205
+ var debug = src.exports;
1206
+
1207
+ const VITE_PACKAGE_DIR = path$1.resolve(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
1208
+ const CLIENT_ENTRY = path$1.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
1209
+ path$1.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
1210
+ path__default.dirname(CLIENT_ENTRY);
1211
+
1212
+ function slash(p) {
1213
+ return p.replace(/\\/g, '/');
1214
+ }
1215
+ // TODO: use import()
1216
+ const _require = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
1217
+ try {
1218
+ Boolean(_require('pnpapi'));
1219
+ }
1220
+ catch { }
1221
+ // set in bin/vite.js
1222
+ const filter = process.env.VITE_DEBUG_FILTER;
1223
+ const DEBUG = process.env.DEBUG;
1224
+ function createDebugger(namespace, options = {}) {
1225
+ const log = debug(namespace);
1226
+ const { onlyWhenFocused } = options;
1227
+ const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : namespace;
1228
+ return (msg, ...args) => {
1229
+ if (filter && !msg.includes(filter)) {
1230
+ return;
1231
+ }
1232
+ if (onlyWhenFocused && !DEBUG?.includes(focus)) {
1233
+ return;
1234
+ }
1235
+ log(msg, ...args);
1236
+ };
1237
+ }
1238
+ function testCaseInsensitiveFS() {
1239
+ if (!CLIENT_ENTRY.endsWith('client.mjs')) {
1240
+ throw new Error(`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`);
1241
+ }
1242
+ if (!fs__default.existsSync(CLIENT_ENTRY)) {
1243
+ throw new Error('cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: ' +
1244
+ CLIENT_ENTRY);
1245
+ }
1246
+ return fs__default.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
1247
+ }
1248
+ testCaseInsensitiveFS();
1249
+ const isWindows = os__default.platform() === 'win32';
1250
+ function normalizePath(id) {
1251
+ return path__default.posix.normalize(isWindows ? slash(id) : id);
1252
+ }
1253
+ function isObject(value) {
1254
+ return Object.prototype.toString.call(value) === '[object Object]';
1255
+ }
1256
+ function lookupFile(dir, formats, options) {
1257
+ for (const format of formats) {
1258
+ const fullPath = path__default.join(dir, format);
1259
+ if (fs__default.existsSync(fullPath) && fs__default.statSync(fullPath).isFile()) {
1260
+ return options?.pathOnly ? fullPath : fs__default.readFileSync(fullPath, 'utf-8');
1261
+ }
1262
+ }
1263
+ const parentDir = path__default.dirname(dir);
1264
+ if (parentDir !== dir &&
1265
+ (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
1266
+ return lookupFile(parentDir, formats, options);
1267
+ }
1268
+ }
1269
+ /**
1270
+ * Use instead of fs.existsSync(filename)
1271
+ * #2051 if we don't have read permission on a directory, existsSync() still
1272
+ * works and will result in massively slow subsequent checks (which are
1273
+ * unnecessary in the first place)
1274
+ */
1275
+ function isFileReadable(filename) {
1276
+ try {
1277
+ const stat = fs__default.statSync(filename, { throwIfNoEntry: false });
1278
+ return !!stat;
1279
+ }
1280
+ catch {
1281
+ return false;
1282
+ }
1283
+ }
1284
+ isWindows
1285
+ ? require$$1.promisify(gracefulRemoveDir)
1286
+ : function removeDirSync(dir) {
1287
+ fs__default.rmSync(dir, { recursive: true, force: true });
1288
+ };
1289
+ isWindows ? require$$1.promisify(gracefulRename) : fs__default.renameSync;
1290
+ function arraify(target) {
1291
+ return Array.isArray(target) ? target : [target];
1292
+ }
1293
+ // @ts-expect-error
1294
+ const usingDynamicImport = typeof jest === 'undefined';
1295
+ /**
1296
+ * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
1297
+ *
1298
+ * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
1299
+ * if we're in a Jest environment.
1300
+ * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
1301
+ *
1302
+ * @param file File path to import.
1303
+ */
1304
+ usingDynamicImport
1305
+ ? new Function('file', 'return import(file)')
1306
+ : _require;
1307
+ // Based on node-graceful-fs
1308
+ // The ISC License
1309
+ // Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
1310
+ // https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE
1311
+ // On Windows, A/V software can lock the directory, causing this
1312
+ // to fail with an EACCES or EPERM if the directory contains newly
1313
+ // created files. The original tried for up to 60 seconds, we only
1314
+ // wait for 5 seconds, as a longer time would be seen as an error
1315
+ const GRACEFUL_RENAME_TIMEOUT = 5000;
1316
+ function gracefulRename(from, to, cb) {
1317
+ const start = Date.now();
1318
+ let backoff = 0;
1319
+ fs__default.rename(from, to, function CB(er) {
1320
+ if (er &&
1321
+ (er.code === 'EACCES' || er.code === 'EPERM') &&
1322
+ Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
1323
+ setTimeout(function () {
1324
+ fs__default.stat(to, function (stater, st) {
1325
+ if (stater && stater.code === 'ENOENT')
1326
+ fs__default.rename(from, to, CB);
1327
+ else
1328
+ CB(er);
1329
+ });
1330
+ }, backoff);
1331
+ if (backoff < 100)
1332
+ backoff += 10;
1333
+ return;
1334
+ }
1335
+ if (cb)
1336
+ cb(er);
1337
+ });
1338
+ }
1339
+ const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
1340
+ function gracefulRemoveDir(dir, cb) {
1341
+ const start = Date.now();
1342
+ let backoff = 0;
1343
+ fs__default.rm(dir, { recursive: true }, function CB(er) {
1344
+ if (er) {
1345
+ if ((er.code === 'ENOTEMPTY' ||
1346
+ er.code === 'EACCES' ||
1347
+ er.code === 'EPERM') &&
1348
+ Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
1349
+ setTimeout(function () {
1350
+ fs__default.rm(dir, { recursive: true }, CB);
1351
+ }, backoff);
1352
+ if (backoff < 100)
1353
+ backoff += 10;
1354
+ return;
1355
+ }
1356
+ if (er.code === 'ENOENT') {
1357
+ er = null;
1358
+ }
1359
+ }
1360
+ if (cb)
1361
+ cb(er);
1362
+ });
1363
+ }
1364
+ function mergeConfigRecursively(defaults, overrides, rootPath) {
1365
+ const merged = { ...defaults };
1366
+ for (const key in overrides) {
1367
+ const value = overrides[key];
1368
+ if (value == null) {
1369
+ continue;
1370
+ }
1371
+ const existing = merged[key];
1372
+ if (existing == null) {
1373
+ merged[key] = value;
1374
+ continue;
1375
+ }
1376
+ // fields that require special handling
1377
+ if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
1378
+ merged[key] = mergeAlias(existing, value);
1379
+ continue;
1380
+ }
1381
+ else if (key === 'assetsInclude' && rootPath === '') {
1382
+ merged[key] = [].concat(existing, value);
1383
+ continue;
1384
+ }
1385
+ else if (key === 'noExternal' &&
1386
+ rootPath === 'ssr' &&
1387
+ (existing === true || value === true)) {
1388
+ merged[key] = true;
1389
+ continue;
1390
+ }
1391
+ if (Array.isArray(existing) || Array.isArray(value)) {
1392
+ merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
1393
+ continue;
1394
+ }
1395
+ if (isObject(existing) && isObject(value)) {
1396
+ merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
1397
+ continue;
1398
+ }
1399
+ merged[key] = value;
1400
+ }
1401
+ return merged;
1402
+ }
1403
+ function mergeConfig(defaults, overrides, isRoot = true) {
1404
+ return mergeConfigRecursively(defaults, overrides, isRoot ? '' : '.');
1405
+ }
1406
+ function mergeAlias(a, b) {
1407
+ if (!a)
1408
+ return b;
1409
+ if (!b)
1410
+ return a;
1411
+ if (isObject(a) && isObject(b)) {
1412
+ return { ...a, ...b };
1413
+ }
1414
+ // the order is flipped because the alias is resolved from top-down,
1415
+ // where the later should have higher priority
1416
+ return [...normalizeAlias(b), ...normalizeAlias(a)];
1417
+ }
1418
+ function normalizeAlias(o = []) {
1419
+ return Array.isArray(o)
1420
+ ? o.map(normalizeSingleAlias)
1421
+ : Object.keys(o).map((find) => normalizeSingleAlias({
1422
+ find,
1423
+ replacement: o[find]
1424
+ }));
1425
+ }
1426
+ // https://github.com/vitejs/vite/issues/1363
1427
+ // work around https://github.com/rollup/plugins/issues/759
1428
+ function normalizeSingleAlias({ find, replacement, customResolver }) {
1429
+ if (typeof find === 'string' &&
1430
+ find.endsWith('/') &&
1431
+ replacement.endsWith('/')) {
1432
+ find = find.slice(0, find.length - 1);
1433
+ replacement = replacement.slice(0, replacement.length - 1);
1434
+ }
1435
+ const alias = {
1436
+ find,
1437
+ replacement
1438
+ };
1439
+ if (customResolver) {
1440
+ alias.customResolver = customResolver;
1441
+ }
1442
+ return alias;
1443
+ }
1444
+
1445
+ /*!
1446
+ * etag
1447
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
1448
+ * MIT Licensed
1449
+ */
1450
+
1451
+ /**
1452
+ * Module exports.
1453
+ * @public
1454
+ */
1455
+
1456
+ var etag_1 = etag;
1457
+
1458
+ /**
1459
+ * Module dependencies.
1460
+ * @private
1461
+ */
1462
+
1463
+ var crypto = require$$0__default$1;
1464
+ var Stats = fs__default.Stats;
1465
+
1466
+ /**
1467
+ * Module variables.
1468
+ * @private
1469
+ */
1470
+
1471
+ var toString = Object.prototype.toString;
1472
+
1473
+ /**
1474
+ * Generate an entity tag.
1475
+ *
1476
+ * @param {Buffer|string} entity
1477
+ * @return {string}
1478
+ * @private
1479
+ */
1480
+
1481
+ function entitytag (entity) {
1482
+ if (entity.length === 0) {
1483
+ // fast-path empty
1484
+ return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
1485
+ }
1486
+
1487
+ // compute hash of entity
1488
+ var hash = crypto
1489
+ .createHash('sha1')
1490
+ .update(entity, 'utf8')
1491
+ .digest('base64')
1492
+ .substring(0, 27);
1493
+
1494
+ // compute length of entity
1495
+ var len = typeof entity === 'string'
1496
+ ? Buffer.byteLength(entity, 'utf8')
1497
+ : entity.length;
1498
+
1499
+ return '"' + len.toString(16) + '-' + hash + '"'
1500
+ }
1501
+
1502
+ /**
1503
+ * Create a simple ETag.
1504
+ *
1505
+ * @param {string|Buffer|Stats} entity
1506
+ * @param {object} [options]
1507
+ * @param {boolean} [options.weak]
1508
+ * @return {String}
1509
+ * @public
1510
+ */
1511
+
1512
+ function etag (entity, options) {
1513
+ if (entity == null) {
1514
+ throw new TypeError('argument entity is required')
1515
+ }
1516
+
1517
+ // support fs.Stats object
1518
+ var isStats = isstats(entity);
1519
+ var weak = options && typeof options.weak === 'boolean'
1520
+ ? options.weak
1521
+ : isStats;
1522
+
1523
+ // validate argument
1524
+ if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
1525
+ throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
1526
+ }
1527
+
1528
+ // generate entity tag
1529
+ var tag = isStats
1530
+ ? stattag(entity)
1531
+ : entitytag(entity);
1532
+
1533
+ return weak
1534
+ ? 'W/' + tag
1535
+ : tag
1536
+ }
1537
+
1538
+ /**
1539
+ * Determine if object is a Stats object.
1540
+ *
1541
+ * @param {object} obj
1542
+ * @return {boolean}
1543
+ * @api private
1544
+ */
1545
+
1546
+ function isstats (obj) {
1547
+ // genuine fs.Stats
1548
+ if (typeof Stats === 'function' && obj instanceof Stats) {
1549
+ return true
1550
+ }
1551
+
1552
+ // quack quack
1553
+ return obj && typeof obj === 'object' &&
1554
+ 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' &&
1555
+ 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' &&
1556
+ 'ino' in obj && typeof obj.ino === 'number' &&
1557
+ 'size' in obj && typeof obj.size === 'number'
1558
+ }
1559
+
1560
+ /**
1561
+ * Generate a tag for a stat.
1562
+ *
1563
+ * @param {object} stat
1564
+ * @return {string}
1565
+ * @private
1566
+ */
1567
+
1568
+ function stattag (stat) {
1569
+ var mtime = stat.mtime.getTime().toString(16);
1570
+ var size = stat.size.toString(16);
1571
+
1572
+ return '"' + size + '-' + mtime + '"'
1573
+ }
1574
+
1575
+ const isDebug = !!process.env.DEBUG;
1576
+ createDebugger('vite:sourcemap', {
1577
+ onlyWhenFocused: true
1578
+ });
1579
+ function genSourceMapUrl(map) {
1580
+ if (typeof map !== 'string') {
1581
+ map = JSON.stringify(map);
1582
+ }
1583
+ return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
1584
+ }
1585
+ function getCodeWithSourcemap(type, code, map) {
1586
+ if (isDebug) {
1587
+ code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
1588
+ }
1589
+ if (type === 'js') {
1590
+ code += `\n//# sourceMappingURL=${genSourceMapUrl(map ?? undefined)}`;
1591
+ }
1592
+ else if (type === 'css') {
1593
+ code += `\n/*# sourceMappingURL=${genSourceMapUrl(map ?? undefined)} */`;
1594
+ }
1595
+ return code;
1596
+ }
1597
+
1598
+ const alias = {
1599
+ js: 'application/javascript',
1600
+ css: 'text/css',
1601
+ html: 'text/html',
1602
+ json: 'application/json'
1603
+ };
1604
+ function send(req, res, content, type, options) {
1605
+ const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map } = options;
1606
+ if (res.writableEnded) {
1607
+ return;
1608
+ }
1609
+ if (req.headers['if-none-match'] === etag) {
1610
+ res.statusCode = 304;
1611
+ res.end();
1612
+ return;
1613
+ }
1614
+ res.setHeader('Content-Type', alias[type] || type);
1615
+ res.setHeader('Cache-Control', cacheControl);
1616
+ res.setHeader('Etag', etag);
1617
+ if (headers) {
1618
+ for (const name in headers) {
1619
+ res.setHeader(name, headers[name]);
1620
+ }
1621
+ }
1622
+ // inject source map reference
1623
+ if (map && map.mappings) {
1624
+ if (type === 'js' || type === 'css') {
1625
+ content = getCodeWithSourcemap(type, content.toString(), map);
1626
+ }
1627
+ }
1628
+ res.statusCode = 200;
1629
+ res.end(content);
1630
+ return;
1631
+ }
1632
+
1633
+ /* eslint no-console: 0 */
1634
+ const LogLevels = {
1635
+ silent: 0,
1636
+ error: 1,
1637
+ warn: 2,
1638
+ info: 3
1639
+ };
1640
+ let lastType;
1641
+ let lastMsg;
1642
+ let sameCount = 0;
1643
+ function clearScreen() {
1644
+ const repeatCount = process.stdout.rows - 2;
1645
+ const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
1646
+ console.log(blank);
1647
+ readline__default.cursorTo(process.stdout, 0, 0);
1648
+ readline__default.clearScreenDown(process.stdout);
1649
+ }
1650
+ function createLogger(level = 'info', options = {}) {
1651
+ if (options.customLogger) {
1652
+ return options.customLogger;
1653
+ }
1654
+ const loggedErrors = new WeakSet();
1655
+ const { prefix = '[vite]', allowClearScreen = true } = options;
1656
+ const thresh = LogLevels[level];
1657
+ const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
1658
+ const clear = canClearScreen ? clearScreen : () => { };
1659
+ function output(type, msg, options = {}) {
1660
+ if (thresh >= LogLevels[type]) {
1661
+ const method = type === 'info' ? 'log' : type;
1662
+ const format = () => {
1663
+ if (options.timestamp) {
1664
+ const tag = type === 'info'
1665
+ ? colors.cyan(colors.bold(prefix))
1666
+ : type === 'warn'
1667
+ ? colors.yellow(colors.bold(prefix))
1668
+ : colors.red(colors.bold(prefix));
1669
+ return `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`;
1670
+ }
1671
+ else {
1672
+ return msg;
1673
+ }
1674
+ };
1675
+ if (options.error) {
1676
+ loggedErrors.add(options.error);
1677
+ }
1678
+ if (canClearScreen) {
1679
+ if (type === lastType && msg === lastMsg) {
1680
+ sameCount++;
1681
+ clear();
1682
+ console[method](format(), colors.yellow(`(x${sameCount + 1})`));
1683
+ }
1684
+ else {
1685
+ sameCount = 0;
1686
+ lastMsg = msg;
1687
+ lastType = type;
1688
+ if (options.clear) {
1689
+ clear();
1690
+ }
1691
+ console[method](format());
1692
+ }
1693
+ }
1694
+ else {
1695
+ console[method](format());
1696
+ }
1697
+ }
1698
+ }
1699
+ const warnedMessages = new Set();
1700
+ const logger = {
1701
+ hasWarned: false,
1702
+ info(msg, opts) {
1703
+ output('info', msg, opts);
1704
+ },
1705
+ warn(msg, opts) {
1706
+ logger.hasWarned = true;
1707
+ output('warn', msg, opts);
1708
+ },
1709
+ warnOnce(msg, opts) {
1710
+ if (warnedMessages.has(msg))
1711
+ return;
1712
+ logger.hasWarned = true;
1713
+ output('warn', msg, opts);
1714
+ warnedMessages.add(msg);
1715
+ },
1716
+ error(msg, opts) {
1717
+ logger.hasWarned = true;
1718
+ output('error', msg, opts);
1719
+ },
1720
+ clearScreen(type) {
1721
+ if (thresh >= LogLevels[type]) {
1722
+ clear();
1723
+ }
1724
+ },
1725
+ hasErrorLogged(error) {
1726
+ return loggedErrors.has(error);
1727
+ }
1728
+ };
1729
+ return logger;
1730
+ }
1731
+
1732
+ // https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
1733
+ const ROOT_FILES = [
1734
+ // '.git',
1735
+ // https://pnpm.js.org/workspaces/
1736
+ 'pnpm-workspace.yaml',
1737
+ // https://rushjs.io/pages/advanced/config_files/
1738
+ // 'rush.json',
1739
+ // https://nx.dev/latest/react/getting-started/nx-setup
1740
+ // 'workspace.json',
1741
+ // 'nx.json',
1742
+ // https://github.com/lerna/lerna#lernajson
1743
+ 'lerna.json'
1744
+ ];
1745
+ // npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
1746
+ // yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
1747
+ function hasWorkspacePackageJSON(root) {
1748
+ const path = path$1.join(root, 'package.json');
1749
+ if (!isFileReadable(path)) {
1750
+ return false;
1751
+ }
1752
+ const content = JSON.parse(fs__default.readFileSync(path, 'utf-8')) || {};
1753
+ return !!content.workspaces;
1754
+ }
1755
+ function hasRootFile(root) {
1756
+ return ROOT_FILES.some((file) => fs__default.existsSync(path$1.join(root, file)));
1757
+ }
1758
+ function hasPackageJSON(root) {
1759
+ const path = path$1.join(root, 'package.json');
1760
+ return fs__default.existsSync(path);
1761
+ }
1762
+ /**
1763
+ * Search up for the nearest `package.json`
1764
+ */
1765
+ function searchForPackageRoot(current, root = current) {
1766
+ if (hasPackageJSON(current))
1767
+ return current;
1768
+ const dir = path$1.dirname(current);
1769
+ // reach the fs root
1770
+ if (!dir || dir === current)
1771
+ return root;
1772
+ return searchForPackageRoot(dir, root);
1773
+ }
1774
+ /**
1775
+ * Search up for the nearest workspace root
1776
+ */
1777
+ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
1778
+ if (hasRootFile(current))
1779
+ return current;
1780
+ if (hasWorkspacePackageJSON(current))
1781
+ return current;
1782
+ const dir = path$1.dirname(current);
1783
+ // reach the fs root
1784
+ if (!dir || dir === current)
1785
+ return root;
1786
+ return searchForWorkspaceRoot(dir, root);
1787
+ }
1788
+
1789
+ var main$1 = {exports: {}};
1790
+
1791
+ const fs = fs__default;
1792
+ const path = path__default;
1793
+ const os = os__default;
1794
+
1795
+ function log (message) {
1796
+ console.log(`[dotenv][DEBUG] ${message}`);
1797
+ }
1798
+
1799
+ const NEWLINE = '\n';
1800
+ const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*("[^"]*"|'[^']*'|.*?)(\s+#.*)?$/;
1801
+ const RE_NEWLINES = /\\n/g;
1802
+ const NEWLINES_MATCH = /\r\n|\n|\r/;
1803
+
1804
+ // Parses src into an Object
1805
+ function parse (src, options) {
1806
+ const debug = Boolean(options && options.debug);
1807
+ const multiline = Boolean(options && options.multiline);
1808
+ const obj = {};
1809
+
1810
+ // convert Buffers before splitting into lines and processing
1811
+ const lines = src.toString().split(NEWLINES_MATCH);
1812
+
1813
+ for (let idx = 0; idx < lines.length; idx++) {
1814
+ let line = lines[idx];
1815
+
1816
+ // matching "KEY' and 'VAL' in 'KEY=VAL'
1817
+ const keyValueArr = line.match(RE_INI_KEY_VAL);
1818
+ // matched?
1819
+ if (keyValueArr != null) {
1820
+ const key = keyValueArr[1];
1821
+ // default undefined or missing values to empty string
1822
+ let val = (keyValueArr[2] || '');
1823
+ let end = val.length - 1;
1824
+ const isDoubleQuoted = val[0] === '"' && val[end] === '"';
1825
+ const isSingleQuoted = val[0] === "'" && val[end] === "'";
1826
+
1827
+ const isMultilineDoubleQuoted = val[0] === '"' && val[end] !== '"';
1828
+ const isMultilineSingleQuoted = val[0] === "'" && val[end] !== "'";
1829
+
1830
+ // if parsing line breaks and the value starts with a quote
1831
+ if (multiline && (isMultilineDoubleQuoted || isMultilineSingleQuoted)) {
1832
+ const quoteChar = isMultilineDoubleQuoted ? '"' : "'";
1833
+
1834
+ val = val.substring(1);
1835
+
1836
+ while (idx++ < lines.length - 1) {
1837
+ line = lines[idx];
1838
+ end = line.length - 1;
1839
+ if (line[end] === quoteChar) {
1840
+ val += NEWLINE + line.substring(0, end);
1841
+ break
1842
+ }
1843
+ val += NEWLINE + line;
1844
+ }
1845
+ // if single or double quoted, remove quotes
1846
+ } else if (isSingleQuoted || isDoubleQuoted) {
1847
+ val = val.substring(1, end);
1848
+
1849
+ // if double quoted, expand newlines
1850
+ if (isDoubleQuoted) {
1851
+ val = val.replace(RE_NEWLINES, NEWLINE);
1852
+ }
1853
+ } else {
1854
+ // remove surrounding whitespace
1855
+ val = val.trim();
1856
+ }
1857
+
1858
+ obj[key] = val;
1859
+ } else if (debug) {
1860
+ const trimmedLine = line.trim();
1861
+
1862
+ // ignore empty and commented lines
1863
+ if (trimmedLine.length && trimmedLine[0] !== '#') {
1864
+ log(`Failed to match key and value when parsing line ${idx + 1}: ${line}`);
1865
+ }
1866
+ }
1867
+ }
1868
+
1869
+ return obj
1870
+ }
1871
+
1872
+ function resolveHome (envPath) {
1873
+ return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
1874
+ }
1875
+
1876
+ // Populates process.env from .env file
1877
+ function config (options) {
1878
+ let dotenvPath = path.resolve(process.cwd(), '.env');
1879
+ let encoding = 'utf8';
1880
+ const debug = Boolean(options && options.debug);
1881
+ const override = Boolean(options && options.override);
1882
+ const multiline = Boolean(options && options.multiline);
1883
+
1884
+ if (options) {
1885
+ if (options.path != null) {
1886
+ dotenvPath = resolveHome(options.path);
1887
+ }
1888
+ if (options.encoding != null) {
1889
+ encoding = options.encoding;
1890
+ }
1891
+ }
1892
+
1893
+ try {
1894
+ // specifying an encoding returns a string instead of a buffer
1895
+ const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }), { debug, multiline });
1896
+
1897
+ Object.keys(parsed).forEach(function (key) {
1898
+ if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
1899
+ process.env[key] = parsed[key];
1900
+ } else {
1901
+ if (override === true) {
1902
+ process.env[key] = parsed[key];
1903
+ }
1904
+
1905
+ if (debug) {
1906
+ if (override === true) {
1907
+ log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
1908
+ } else {
1909
+ log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
1910
+ }
1911
+ }
1912
+ }
1913
+ });
1914
+
1915
+ return { parsed }
1916
+ } catch (e) {
1917
+ if (debug) {
1918
+ log(`Failed to load ${dotenvPath} ${e.message}`);
1919
+ }
1920
+
1921
+ return { error: e }
1922
+ }
1923
+ }
1924
+
1925
+ const DotenvModule = {
1926
+ config,
1927
+ parse
1928
+ };
1929
+
1930
+ main$1.exports.config = DotenvModule.config;
1931
+ main$1.exports.parse = DotenvModule.parse;
1932
+ main$1.exports = DotenvModule;
1933
+
1934
+ var dotenv = main$1.exports;
1935
+
1936
+ var dotenvExpand = function (config) {
1937
+ // if ignoring process.env, use a blank object
1938
+ var environment = config.ignoreProcessEnv ? {} : process.env;
1939
+
1940
+ var interpolate = function (envValue) {
1941
+ var matches = envValue.match(/(.?\${?(?:[a-zA-Z0-9_]+)?}?)/g) || [];
1942
+
1943
+ return matches.reduce(function (newEnv, match) {
1944
+ var parts = /(.?)\${?([a-zA-Z0-9_]+)?}?/g.exec(match);
1945
+ var prefix = parts[1];
1946
+
1947
+ var value, replacePart;
1948
+
1949
+ if (prefix === '\\') {
1950
+ replacePart = parts[0];
1951
+ value = replacePart.replace('\\$', '$');
1952
+ } else {
1953
+ var key = parts[2];
1954
+ replacePart = parts[0].substring(prefix.length);
1955
+ // process.env value 'wins' over .env file's value
1956
+ value = environment.hasOwnProperty(key) ? environment[key] : (config.parsed[key] || '');
1957
+
1958
+ // Resolve recursive interpolations
1959
+ value = interpolate(value);
1960
+ }
1961
+
1962
+ return newEnv.replace(replacePart, value)
1963
+ }, envValue)
1964
+ };
1965
+
1966
+ for (var configKey in config.parsed) {
1967
+ var value = environment.hasOwnProperty(configKey) ? environment[configKey] : config.parsed[configKey];
1968
+
1969
+ config.parsed[configKey] = interpolate(value);
1970
+ }
1971
+
1972
+ for (var processKey in config.parsed) {
1973
+ environment[processKey] = config.parsed[processKey];
1974
+ }
1975
+
1976
+ return config
1977
+ };
1978
+
1979
+ var main = dotenvExpand;
1980
+
1981
+ function loadEnv(mode, envDir, prefixes = 'VITE_') {
1982
+ if (mode === 'local') {
1983
+ throw new Error(`"local" cannot be used as a mode name because it conflicts with ` +
1984
+ `the .local postfix for .env files.`);
1985
+ }
1986
+ prefixes = arraify(prefixes);
1987
+ const env = {};
1988
+ const envFiles = [
1989
+ /** mode local file */ `.env.${mode}.local`,
1990
+ /** mode file */ `.env.${mode}`,
1991
+ /** local file */ `.env.local`,
1992
+ /** default file */ `.env`
1993
+ ];
1994
+ // check if there are actual env variables starting with VITE_*
1995
+ // these are typically provided inline and should be prioritized
1996
+ for (const key in process.env) {
1997
+ if (prefixes.some((prefix) => key.startsWith(prefix)) &&
1998
+ env[key] === undefined) {
1999
+ env[key] = process.env[key];
2000
+ }
2001
+ }
2002
+ for (const file of envFiles) {
2003
+ const path = lookupFile(envDir, [file], { pathOnly: true, rootDir: envDir });
2004
+ if (path) {
2005
+ const parsed = dotenv.parse(fs__default.readFileSync(path), {
2006
+ debug: process.env.DEBUG?.includes('vite:dotenv') || undefined
2007
+ });
2008
+ // let environment variables use each other
2009
+ main({
2010
+ parsed,
2011
+ // prevent process.env mutation
2012
+ ignoreProcessEnv: true
2013
+ });
2014
+ // only keys that start with prefix are exposed to client
2015
+ for (const [key, value] of Object.entries(parsed)) {
2016
+ if (prefixes.some((prefix) => key.startsWith(prefix)) &&
2017
+ env[key] === undefined) {
2018
+ env[key] = value;
2019
+ }
2020
+ else if (key === 'NODE_ENV' &&
2021
+ process.env.VITE_USER_NODE_ENV === undefined) {
2022
+ // NODE_ENV override in .env file
2023
+ process.env.VITE_USER_NODE_ENV = value;
2024
+ }
2025
+ }
2026
+ }
2027
+ }
2028
+ return env;
2029
+ }
2030
+ function resolveEnvPrefix({ envPrefix = 'VITE_' }) {
2031
+ envPrefix = arraify(envPrefix);
2032
+ if (envPrefix.some((prefix) => prefix === '')) {
2033
+ throw new Error(`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`);
2034
+ }
2035
+ return envPrefix;
2036
+ }
2037
+
2038
+ exports.createLogger = createLogger;
2039
+ exports.loadEnv = loadEnv;
2040
+ exports.mergeAlias = mergeAlias;
2041
+ exports.mergeConfig = mergeConfig;
2042
+ exports.normalizePath = normalizePath;
2043
+ exports.resolveEnvPrefix = resolveEnvPrefix;
2044
+ exports.searchForWorkspaceRoot = searchForWorkspaceRoot;
2045
+ exports.send = send;
2046
+ exports.splitVendorChunk = splitVendorChunk;
2047
+ exports.splitVendorChunkPlugin = splitVendorChunkPlugin;