@wix/cli-app 1.1.38 → 1.1.40
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/build/CreateVersionCommand-O5BVX2VS.js +4 -0
- package/build/CreateVersionCommand-O5BVX2VS.js.map +1 -0
- package/build/DevCommand-CRZL2PKO.js +4 -0
- package/build/DevCommand-CRZL2PKO.js.map +1 -0
- package/build/{GenerateCommand-7ZGIGNPF.js → GenerateCommand-SMG3IJQB.js} +19 -19
- package/build/GenerateCommand-SMG3IJQB.js.map +1 -0
- package/build/LogsCommand-M66KGJ6O.js +4 -0
- package/build/LogsCommand-M66KGJ6O.js.map +1 -0
- package/build/PreviewCommand-QQUEB3JU.js +4 -0
- package/build/{ServeCommand-T5PQKB57.js → ServeCommand-INMICJZO.js} +2 -2
- package/build/build-IIIEPXQV.js +4 -0
- package/build/build-IIIEPXQV.js.map +1 -0
- package/build/{chunk-BW3SDDV3.js → chunk-3YJCDGCN.js} +2 -2
- package/build/{chunk-6QCQALVT.js → chunk-5SA2INZ4.js} +2 -2
- package/build/chunk-GDSAERE7.js +10 -0
- package/build/chunk-GDSAERE7.js.map +1 -0
- package/build/{chunk-IBNMP32R.js → chunk-I5NQ52AS.js} +2 -2
- package/build/{chunk-4YU6J2EW.js → chunk-K3TY5EJT.js} +2 -2
- package/build/{chunk-KLTGX7JQ.js → chunk-L3ID3ZSB.js} +2 -2
- package/build/{chunk-RCIAHQJ5.js → chunk-LORL7RCM.js} +2 -2
- package/build/chunk-LORL7RCM.js.map +1 -0
- package/build/{chunk-GK5AZX2F.js → chunk-N5J27JBU.js} +2 -2
- package/build/{chunk-TRE6G7GA.js → chunk-NEJZ2NNG.js} +2 -2
- package/build/{chunk-35BUZ7CK.js → chunk-NQAHAISJ.js} +2 -2
- package/build/{chunk-3Q7TAN43.js → chunk-OU5XEMIQ.js} +2 -2
- package/build/chunk-P3SK6O7I.js +100 -0
- package/build/chunk-P3SK6O7I.js.map +1 -0
- package/build/chunk-R6BWGOF7.js +116 -0
- package/build/chunk-R6BWGOF7.js.map +1 -0
- package/build/{chunk-QT3P4FJP.js → chunk-RPKQITNR.js} +2 -2
- package/build/{chunk-PBBKM3Z3.js → chunk-VC3QC6IA.js} +51 -51
- package/build/chunk-VC3QC6IA.js.map +1 -0
- package/build/{chunk-7OVUUUVH.js → chunk-WOVDKZ5J.js} +2 -2
- package/build/chunk-X3PZHSTL.js +4 -0
- package/build/chunk-X3PZHSTL.js.map +1 -0
- package/build/{chunk-I2Z6OIJW.js → chunk-YUHF6CTW.js} +2 -2
- package/build/chunk-YUHF6CTW.js.map +1 -0
- package/build/chunk-Z7XO554G.js +4 -0
- package/build/chunk-Z7XO554G.js.map +1 -0
- package/build/cloudflare-runtime/entry.js +365 -0
- package/build/cloudflare-runtime/getRegisteredExtensions.js +166 -0
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/miniflare/worker-entry.js +2767 -0
- package/build/platform-sdk/chunk-DGX4CFXG.js +2 -0
- package/build/platform-sdk/chunk-DGX4CFXG.js.map +1 -0
- package/build/platform-sdk/chunk-UZ376HBX.js +2 -0
- package/build/platform-sdk/chunk-UZ376HBX.js.map +1 -0
- package/build/platform-sdk/dashboard.js +1 -1
- package/build/platform-sdk/dashboard.js.map +1 -1
- package/build/platform-sdk/editor.js +1 -1
- package/build/platform-sdk/site.js +1 -1
- package/build/platform-sdk/site.js.map +1 -1
- package/build/{preview-HS2NEMQI.js → preview-D53ROXPK.js} +2 -2
- package/build/{render-command-QGD6AYTF.js → render-command-JAWSRO4L.js} +2 -2
- package/package.json +9 -6
- package/build/CreateVersionCommand-C6UP5ORQ.js +0 -4
- package/build/CreateVersionCommand-C6UP5ORQ.js.map +0 -1
- package/build/DevCommand-BO6KQHRP.js +0 -4
- package/build/DevCommand-BO6KQHRP.js.map +0 -1
- package/build/GenerateCommand-7ZGIGNPF.js.map +0 -1
- package/build/LogsCommand-W5CRI6WA.js +0 -4
- package/build/LogsCommand-W5CRI6WA.js.map +0 -1
- package/build/PreviewCommand-DWQCCBBZ.js +0 -4
- package/build/build-CNTVWU2X.js +0 -4
- package/build/build-CNTVWU2X.js.map +0 -1
- package/build/chunk-I2Z6OIJW.js.map +0 -1
- package/build/chunk-MIBBNKYS.js +0 -116
- package/build/chunk-MIBBNKYS.js.map +0 -1
- package/build/chunk-PBBKM3Z3.js.map +0 -1
- package/build/chunk-QDPEZ5A2.js +0 -4
- package/build/chunk-QDPEZ5A2.js.map +0 -1
- package/build/chunk-R3JUFM5X.js +0 -100
- package/build/chunk-R3JUFM5X.js.map +0 -1
- package/build/chunk-RCIAHQJ5.js.map +0 -1
- package/build/chunk-RZI5OJAA.js +0 -10
- package/build/chunk-RZI5OJAA.js.map +0 -1
- package/build/chunk-VAOLKVA2.js +0 -4
- package/build/chunk-VAOLKVA2.js.map +0 -1
- package/build/platform-sdk/chunk-OSR2I5MY.js +0 -2
- package/build/platform-sdk/chunk-OSR2I5MY.js.map +0 -1
- package/build/platform-sdk/chunk-SHVQ4QZG.js +0 -2
- package/build/platform-sdk/chunk-SHVQ4QZG.js.map +0 -1
- /package/build/{PreviewCommand-DWQCCBBZ.js.map → PreviewCommand-QQUEB3JU.js.map} +0 -0
- /package/build/{ServeCommand-T5PQKB57.js.map → ServeCommand-INMICJZO.js.map} +0 -0
- /package/build/{chunk-BW3SDDV3.js.map → chunk-3YJCDGCN.js.map} +0 -0
- /package/build/{chunk-6QCQALVT.js.map → chunk-5SA2INZ4.js.map} +0 -0
- /package/build/{chunk-IBNMP32R.js.map → chunk-I5NQ52AS.js.map} +0 -0
- /package/build/{chunk-4YU6J2EW.js.map → chunk-K3TY5EJT.js.map} +0 -0
- /package/build/{chunk-KLTGX7JQ.js.map → chunk-L3ID3ZSB.js.map} +0 -0
- /package/build/{chunk-GK5AZX2F.js.map → chunk-N5J27JBU.js.map} +0 -0
- /package/build/{chunk-TRE6G7GA.js.map → chunk-NEJZ2NNG.js.map} +0 -0
- /package/build/{chunk-35BUZ7CK.js.map → chunk-NQAHAISJ.js.map} +0 -0
- /package/build/{chunk-3Q7TAN43.js.map → chunk-OU5XEMIQ.js.map} +0 -0
- /package/build/{chunk-QT3P4FJP.js.map → chunk-RPKQITNR.js.map} +0 -0
- /package/build/{chunk-7OVUUUVH.js.map → chunk-WOVDKZ5J.js.map} +0 -0
- /package/build/{preview-HS2NEMQI.js.map → preview-D53ROXPK.js.map} +0 -0
- /package/build/{render-command-QGD6AYTF.js.map → render-command-JAWSRO4L.js.map} +0 -0
|
@@ -0,0 +1,2767 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/balanced-match/index.js
|
|
28
|
+
var require_balanced_match = __commonJS({
|
|
29
|
+
"../../node_modules/balanced-match/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
module.exports = balanced;
|
|
32
|
+
function balanced(a, b, str) {
|
|
33
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
34
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
35
|
+
var r = range(a, b, str);
|
|
36
|
+
return r && {
|
|
37
|
+
start: r[0],
|
|
38
|
+
end: r[1],
|
|
39
|
+
pre: str.slice(0, r[0]),
|
|
40
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
41
|
+
post: str.slice(r[1] + b.length)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function maybeMatch(reg, str) {
|
|
45
|
+
var m = str.match(reg);
|
|
46
|
+
return m ? m[0] : null;
|
|
47
|
+
}
|
|
48
|
+
balanced.range = range;
|
|
49
|
+
function range(a, b, str) {
|
|
50
|
+
var begs, beg, left, right, result;
|
|
51
|
+
var ai = str.indexOf(a);
|
|
52
|
+
var bi = str.indexOf(b, ai + 1);
|
|
53
|
+
var i = ai;
|
|
54
|
+
if (ai >= 0 && bi > 0) {
|
|
55
|
+
if (a === b) {
|
|
56
|
+
return [ai, bi];
|
|
57
|
+
}
|
|
58
|
+
begs = [];
|
|
59
|
+
left = str.length;
|
|
60
|
+
while (i >= 0 && !result) {
|
|
61
|
+
if (i == ai) {
|
|
62
|
+
begs.push(i);
|
|
63
|
+
ai = str.indexOf(a, i + 1);
|
|
64
|
+
} else if (begs.length == 1) {
|
|
65
|
+
result = [begs.pop(), bi];
|
|
66
|
+
} else {
|
|
67
|
+
beg = begs.pop();
|
|
68
|
+
if (beg < left) {
|
|
69
|
+
left = beg;
|
|
70
|
+
right = bi;
|
|
71
|
+
}
|
|
72
|
+
bi = str.indexOf(b, i + 1);
|
|
73
|
+
}
|
|
74
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
75
|
+
}
|
|
76
|
+
if (begs.length) {
|
|
77
|
+
result = [left, right];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// ../../node_modules/brace-expansion/index.js
|
|
86
|
+
var require_brace_expansion = __commonJS({
|
|
87
|
+
"../../node_modules/brace-expansion/index.js"(exports, module) {
|
|
88
|
+
"use strict";
|
|
89
|
+
var balanced = require_balanced_match();
|
|
90
|
+
module.exports = expandTop;
|
|
91
|
+
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
92
|
+
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
93
|
+
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
94
|
+
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
95
|
+
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
96
|
+
function numeric(str) {
|
|
97
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
98
|
+
}
|
|
99
|
+
function escapeBraces(str) {
|
|
100
|
+
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
|
|
101
|
+
}
|
|
102
|
+
function unescapeBraces(str) {
|
|
103
|
+
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
104
|
+
}
|
|
105
|
+
function parseCommaParts(str) {
|
|
106
|
+
if (!str)
|
|
107
|
+
return [""];
|
|
108
|
+
var parts = [];
|
|
109
|
+
var m = balanced("{", "}", str);
|
|
110
|
+
if (!m)
|
|
111
|
+
return str.split(",");
|
|
112
|
+
var pre = m.pre;
|
|
113
|
+
var body = m.body;
|
|
114
|
+
var post = m.post;
|
|
115
|
+
var p = pre.split(",");
|
|
116
|
+
p[p.length - 1] += "{" + body + "}";
|
|
117
|
+
var postParts = parseCommaParts(post);
|
|
118
|
+
if (post.length) {
|
|
119
|
+
p[p.length - 1] += postParts.shift();
|
|
120
|
+
p.push.apply(p, postParts);
|
|
121
|
+
}
|
|
122
|
+
parts.push.apply(parts, p);
|
|
123
|
+
return parts;
|
|
124
|
+
}
|
|
125
|
+
function expandTop(str) {
|
|
126
|
+
if (!str)
|
|
127
|
+
return [];
|
|
128
|
+
if (str.substr(0, 2) === "{}") {
|
|
129
|
+
str = "\\{\\}" + str.substr(2);
|
|
130
|
+
}
|
|
131
|
+
return expand2(escapeBraces(str), true).map(unescapeBraces);
|
|
132
|
+
}
|
|
133
|
+
function embrace(str) {
|
|
134
|
+
return "{" + str + "}";
|
|
135
|
+
}
|
|
136
|
+
function isPadded(el) {
|
|
137
|
+
return /^-?0\d/.test(el);
|
|
138
|
+
}
|
|
139
|
+
function lte(i, y) {
|
|
140
|
+
return i <= y;
|
|
141
|
+
}
|
|
142
|
+
function gte(i, y) {
|
|
143
|
+
return i >= y;
|
|
144
|
+
}
|
|
145
|
+
function expand2(str, isTop) {
|
|
146
|
+
var expansions = [];
|
|
147
|
+
var m = balanced("{", "}", str);
|
|
148
|
+
if (!m) return [str];
|
|
149
|
+
var pre = m.pre;
|
|
150
|
+
var post = m.post.length ? expand2(m.post, false) : [""];
|
|
151
|
+
if (/\$$/.test(m.pre)) {
|
|
152
|
+
for (var k = 0; k < post.length; k++) {
|
|
153
|
+
var expansion = pre + "{" + m.body + "}" + post[k];
|
|
154
|
+
expansions.push(expansion);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
158
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
159
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
160
|
+
var isOptions = m.body.indexOf(",") >= 0;
|
|
161
|
+
if (!isSequence && !isOptions) {
|
|
162
|
+
if (m.post.match(/,.*\}/)) {
|
|
163
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
164
|
+
return expand2(str);
|
|
165
|
+
}
|
|
166
|
+
return [str];
|
|
167
|
+
}
|
|
168
|
+
var n;
|
|
169
|
+
if (isSequence) {
|
|
170
|
+
n = m.body.split(/\.\./);
|
|
171
|
+
} else {
|
|
172
|
+
n = parseCommaParts(m.body);
|
|
173
|
+
if (n.length === 1) {
|
|
174
|
+
n = expand2(n[0], false).map(embrace);
|
|
175
|
+
if (n.length === 1) {
|
|
176
|
+
return post.map(function(p) {
|
|
177
|
+
return m.pre + n[0] + p;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var N;
|
|
183
|
+
if (isSequence) {
|
|
184
|
+
var x = numeric(n[0]);
|
|
185
|
+
var y = numeric(n[1]);
|
|
186
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
187
|
+
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
188
|
+
var test = lte;
|
|
189
|
+
var reverse = y < x;
|
|
190
|
+
if (reverse) {
|
|
191
|
+
incr *= -1;
|
|
192
|
+
test = gte;
|
|
193
|
+
}
|
|
194
|
+
var pad = n.some(isPadded);
|
|
195
|
+
N = [];
|
|
196
|
+
for (var i = x; test(i, y); i += incr) {
|
|
197
|
+
var c;
|
|
198
|
+
if (isAlphaSequence) {
|
|
199
|
+
c = String.fromCharCode(i);
|
|
200
|
+
if (c === "\\")
|
|
201
|
+
c = "";
|
|
202
|
+
} else {
|
|
203
|
+
c = String(i);
|
|
204
|
+
if (pad) {
|
|
205
|
+
var need = width - c.length;
|
|
206
|
+
if (need > 0) {
|
|
207
|
+
var z = new Array(need + 1).join("0");
|
|
208
|
+
if (i < 0)
|
|
209
|
+
c = "-" + z + c.slice(1);
|
|
210
|
+
else
|
|
211
|
+
c = z + c;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
N.push(c);
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
N = [];
|
|
219
|
+
for (var j = 0; j < n.length; j++) {
|
|
220
|
+
N.push.apply(N, expand2(n[j], false));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
for (var j = 0; j < N.length; j++) {
|
|
224
|
+
for (var k = 0; k < post.length; k++) {
|
|
225
|
+
var expansion = pre + N[j] + post[k];
|
|
226
|
+
if (!isTop || isSequence || expansion)
|
|
227
|
+
expansions.push(expansion);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return expansions;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// ../cli-test-overrides/src/constants.ts
|
|
237
|
+
var TEST_OVERRIDES_ENV_VAR = "WIX_CLI_TEST_OVERRIDES";
|
|
238
|
+
|
|
239
|
+
// ../../node_modules/vite/dist/node/runtime.js
|
|
240
|
+
var VALID_ID_PREFIX = "/@id/";
|
|
241
|
+
var NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
242
|
+
var SOURCEMAPPING_URL = "sourceMa";
|
|
243
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
244
|
+
var isWindows = typeof process < "u" && process.platform === "win32";
|
|
245
|
+
function wrapId(id) {
|
|
246
|
+
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
247
|
+
}
|
|
248
|
+
function unwrapId(id) {
|
|
249
|
+
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
|
|
250
|
+
}
|
|
251
|
+
var windowsSlashRE = /\\/g;
|
|
252
|
+
function slash(p) {
|
|
253
|
+
return p.replace(windowsSlashRE, "/");
|
|
254
|
+
}
|
|
255
|
+
var postfixRE = /[?#].*$/;
|
|
256
|
+
function cleanUrl(url) {
|
|
257
|
+
return url.replace(postfixRE, "");
|
|
258
|
+
}
|
|
259
|
+
function isPrimitive(value) {
|
|
260
|
+
return !value || typeof value != "object" && typeof value != "function";
|
|
261
|
+
}
|
|
262
|
+
function withTrailingSlash(path2) {
|
|
263
|
+
return path2[path2.length - 1] !== "/" ? `${path2}/` : path2;
|
|
264
|
+
}
|
|
265
|
+
var AsyncFunction = async function() {
|
|
266
|
+
}.constructor;
|
|
267
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
268
|
+
function normalizeWindowsPath(input = "") {
|
|
269
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
270
|
+
}
|
|
271
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
272
|
+
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
273
|
+
function cwd() {
|
|
274
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
275
|
+
}
|
|
276
|
+
var resolve = function(...arguments_) {
|
|
277
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
278
|
+
let resolvedPath = "", resolvedAbsolute = false;
|
|
279
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
280
|
+
const path2 = index >= 0 ? arguments_[index] : cwd();
|
|
281
|
+
!path2 || path2.length === 0 || (resolvedPath = `${path2}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path2));
|
|
282
|
+
}
|
|
283
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
284
|
+
};
|
|
285
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
286
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
287
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
288
|
+
if (index < path2.length)
|
|
289
|
+
char = path2[index];
|
|
290
|
+
else {
|
|
291
|
+
if (char === "/")
|
|
292
|
+
break;
|
|
293
|
+
char = "/";
|
|
294
|
+
}
|
|
295
|
+
if (char === "/") {
|
|
296
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
297
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
298
|
+
if (res.length > 2) {
|
|
299
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
300
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
301
|
+
continue;
|
|
302
|
+
} else if (res.length > 0) {
|
|
303
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
308
|
+
} else
|
|
309
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
310
|
+
lastSlash = index, dots = 0;
|
|
311
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
312
|
+
}
|
|
313
|
+
return res;
|
|
314
|
+
}
|
|
315
|
+
var isAbsolute = function(p) {
|
|
316
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
317
|
+
};
|
|
318
|
+
var dirname = function(p) {
|
|
319
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
320
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
321
|
+
};
|
|
322
|
+
var decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8");
|
|
323
|
+
var CHAR_FORWARD_SLASH = 47;
|
|
324
|
+
var CHAR_BACKWARD_SLASH = 92;
|
|
325
|
+
var percentRegEx = /%/g;
|
|
326
|
+
var backslashRegEx = /\\/g;
|
|
327
|
+
var newlineRegEx = /\n/g;
|
|
328
|
+
var carriageReturnRegEx = /\r/g;
|
|
329
|
+
var tabRegEx = /\t/g;
|
|
330
|
+
var questionRegex = /\?/g;
|
|
331
|
+
var hashRegex = /#/g;
|
|
332
|
+
function encodePathChars(filepath) {
|
|
333
|
+
return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf(`
|
|
334
|
+
`) !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
|
335
|
+
}
|
|
336
|
+
var posixDirname = dirname;
|
|
337
|
+
var posixResolve = resolve;
|
|
338
|
+
function posixPathToFileHref(posixPath) {
|
|
339
|
+
let resolved = posixResolve(posixPath);
|
|
340
|
+
const filePathLast = posixPath.charCodeAt(posixPath.length - 1);
|
|
341
|
+
return (filePathLast === CHAR_FORWARD_SLASH || isWindows && filePathLast === CHAR_BACKWARD_SLASH) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.indexOf("?") !== -1 && (resolved = resolved.replace(questionRegex, "%3F")), resolved.indexOf("#") !== -1 && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
|
|
342
|
+
}
|
|
343
|
+
function toWindowsPath(path2) {
|
|
344
|
+
return path2.replace(/\//g, "\\");
|
|
345
|
+
}
|
|
346
|
+
var comma = 44;
|
|
347
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
348
|
+
var intToChar = new Uint8Array(64);
|
|
349
|
+
var charToInt = new Uint8Array(128);
|
|
350
|
+
for (let i = 0; i < chars.length; i++) {
|
|
351
|
+
const c = chars.charCodeAt(i);
|
|
352
|
+
intToChar[i] = c, charToInt[c] = i;
|
|
353
|
+
}
|
|
354
|
+
function decodeInteger(reader, relative2) {
|
|
355
|
+
let value = 0, shift = 0, integer = 0;
|
|
356
|
+
do {
|
|
357
|
+
const c = reader.next();
|
|
358
|
+
integer = charToInt[c], value |= (integer & 31) << shift, shift += 5;
|
|
359
|
+
} while (integer & 32);
|
|
360
|
+
const shouldNegate = value & 1;
|
|
361
|
+
return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative2 + value;
|
|
362
|
+
}
|
|
363
|
+
function hasMoreVlq(reader, max) {
|
|
364
|
+
return reader.pos >= max ? false : reader.peek() !== comma;
|
|
365
|
+
}
|
|
366
|
+
var StringReader = class {
|
|
367
|
+
constructor(buffer) {
|
|
368
|
+
this.pos = 0, this.buffer = buffer;
|
|
369
|
+
}
|
|
370
|
+
next() {
|
|
371
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
372
|
+
}
|
|
373
|
+
peek() {
|
|
374
|
+
return this.buffer.charCodeAt(this.pos);
|
|
375
|
+
}
|
|
376
|
+
indexOf(char) {
|
|
377
|
+
const { buffer, pos } = this, idx = buffer.indexOf(char, pos);
|
|
378
|
+
return idx === -1 ? buffer.length : idx;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
function decode(mappings) {
|
|
382
|
+
const { length } = mappings, reader = new StringReader(mappings), decoded = [];
|
|
383
|
+
let genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
|
|
384
|
+
do {
|
|
385
|
+
const semi = reader.indexOf(";"), line = [];
|
|
386
|
+
let sorted = true, lastCol = 0;
|
|
387
|
+
for (genColumn = 0; reader.pos < semi; ) {
|
|
388
|
+
let seg;
|
|
389
|
+
genColumn = decodeInteger(reader, genColumn), genColumn < lastCol && (sorted = false), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex = decodeInteger(reader, sourcesIndex), sourceLine = decodeInteger(reader, sourceLine), sourceColumn = decodeInteger(reader, sourceColumn), hasMoreVlq(reader, semi) ? (namesIndex = decodeInteger(reader, namesIndex), seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]) : seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]) : seg = [genColumn], line.push(seg), reader.pos++;
|
|
390
|
+
}
|
|
391
|
+
sorted || sort(line), decoded.push(line), reader.pos = semi + 1;
|
|
392
|
+
} while (reader.pos <= length);
|
|
393
|
+
return decoded;
|
|
394
|
+
}
|
|
395
|
+
function sort(line) {
|
|
396
|
+
line.sort(sortComparator);
|
|
397
|
+
}
|
|
398
|
+
function sortComparator(a, b) {
|
|
399
|
+
return a[0] - b[0];
|
|
400
|
+
}
|
|
401
|
+
var COLUMN = 0;
|
|
402
|
+
var SOURCES_INDEX = 1;
|
|
403
|
+
var SOURCE_LINE = 2;
|
|
404
|
+
var SOURCE_COLUMN = 3;
|
|
405
|
+
var NAMES_INDEX = 4;
|
|
406
|
+
var found = false;
|
|
407
|
+
function binarySearch(haystack, needle, low, high) {
|
|
408
|
+
for (; low <= high; ) {
|
|
409
|
+
const mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;
|
|
410
|
+
if (cmp === 0)
|
|
411
|
+
return found = true, mid;
|
|
412
|
+
cmp < 0 ? low = mid + 1 : high = mid - 1;
|
|
413
|
+
}
|
|
414
|
+
return found = false, low - 1;
|
|
415
|
+
}
|
|
416
|
+
function upperBound(haystack, needle, index) {
|
|
417
|
+
for (let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++)
|
|
418
|
+
;
|
|
419
|
+
return index;
|
|
420
|
+
}
|
|
421
|
+
function lowerBound(haystack, needle, index) {
|
|
422
|
+
for (let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--)
|
|
423
|
+
;
|
|
424
|
+
return index;
|
|
425
|
+
}
|
|
426
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
427
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
428
|
+
let low = 0, high = haystack.length - 1;
|
|
429
|
+
if (key === lastKey) {
|
|
430
|
+
if (needle === lastNeedle)
|
|
431
|
+
return found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle, lastIndex;
|
|
432
|
+
needle >= lastNeedle ? low = lastIndex === -1 ? 0 : lastIndex : high = lastIndex;
|
|
433
|
+
}
|
|
434
|
+
return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
435
|
+
}
|
|
436
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
437
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
438
|
+
var LEAST_UPPER_BOUND = -1;
|
|
439
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
440
|
+
function decodedMappings(map) {
|
|
441
|
+
var _a;
|
|
442
|
+
return (_a = map)._decoded || (_a._decoded = decode(map._encoded));
|
|
443
|
+
}
|
|
444
|
+
function originalPositionFor(map, needle) {
|
|
445
|
+
let { line, column, bias } = needle;
|
|
446
|
+
if (line--, line < 0)
|
|
447
|
+
throw new Error(LINE_GTR_ZERO);
|
|
448
|
+
if (column < 0)
|
|
449
|
+
throw new Error(COL_GTR_EQ_ZERO);
|
|
450
|
+
const decoded = decodedMappings(map);
|
|
451
|
+
if (line >= decoded.length)
|
|
452
|
+
return OMapping(null, null, null, null);
|
|
453
|
+
const segments = decoded[line], index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
|
454
|
+
if (index === -1)
|
|
455
|
+
return OMapping(null, null, null, null);
|
|
456
|
+
const segment = segments[index];
|
|
457
|
+
if (segment.length === 1)
|
|
458
|
+
return OMapping(null, null, null, null);
|
|
459
|
+
const { names, resolvedSources } = map;
|
|
460
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
461
|
+
}
|
|
462
|
+
function OMapping(source, line, column, name) {
|
|
463
|
+
return { source, line, column, name };
|
|
464
|
+
}
|
|
465
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
466
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
467
|
+
return found ? index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index) : bias === LEAST_UPPER_BOUND && index++, index === -1 || index === segments.length ? -1 : index;
|
|
468
|
+
}
|
|
469
|
+
var DecodedMap = class {
|
|
470
|
+
constructor(map, from) {
|
|
471
|
+
this.map = map;
|
|
472
|
+
const { mappings, names, sources } = map;
|
|
473
|
+
this.version = map.version, this.names = names || [], this._encoded = mappings || "", this._decodedMemo = memoizedState(), this.url = from, this.resolvedSources = (sources || []).map(
|
|
474
|
+
(s) => posixResolve(s || "", from)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
_encoded;
|
|
478
|
+
_decoded;
|
|
479
|
+
_decodedMemo;
|
|
480
|
+
url;
|
|
481
|
+
version;
|
|
482
|
+
names = [];
|
|
483
|
+
resolvedSources;
|
|
484
|
+
};
|
|
485
|
+
function memoizedState() {
|
|
486
|
+
return {
|
|
487
|
+
lastKey: -1,
|
|
488
|
+
lastNeedle: -1,
|
|
489
|
+
lastIndex: -1
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function getOriginalPosition(map, needle) {
|
|
493
|
+
const result = originalPositionFor(map, needle);
|
|
494
|
+
return result.column == null ? null : result;
|
|
495
|
+
}
|
|
496
|
+
var VITE_RUNTIME_SOURCEMAPPING_REGEXP = new RegExp(
|
|
497
|
+
`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`
|
|
498
|
+
);
|
|
499
|
+
var ModuleCacheMap = class extends Map {
|
|
500
|
+
root;
|
|
501
|
+
constructor(root, entries) {
|
|
502
|
+
super(entries), this.root = withTrailingSlash(root);
|
|
503
|
+
}
|
|
504
|
+
normalize(fsPath) {
|
|
505
|
+
return normalizeModuleId(fsPath, this.root);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Assign partial data to the map
|
|
509
|
+
*/
|
|
510
|
+
update(fsPath, mod) {
|
|
511
|
+
return fsPath = this.normalize(fsPath), super.has(fsPath) ? Object.assign(super.get(fsPath), mod) : this.setByModuleId(fsPath, mod), this;
|
|
512
|
+
}
|
|
513
|
+
setByModuleId(modulePath, mod) {
|
|
514
|
+
return super.set(modulePath, mod);
|
|
515
|
+
}
|
|
516
|
+
set(fsPath, mod) {
|
|
517
|
+
return this.setByModuleId(this.normalize(fsPath), mod);
|
|
518
|
+
}
|
|
519
|
+
getByModuleId(modulePath) {
|
|
520
|
+
super.has(modulePath) || this.setByModuleId(modulePath, {});
|
|
521
|
+
const mod = super.get(modulePath);
|
|
522
|
+
return mod.imports || Object.assign(mod, {
|
|
523
|
+
imports: /* @__PURE__ */ new Set(),
|
|
524
|
+
importers: /* @__PURE__ */ new Set()
|
|
525
|
+
}), mod;
|
|
526
|
+
}
|
|
527
|
+
get(fsPath) {
|
|
528
|
+
return this.getByModuleId(this.normalize(fsPath));
|
|
529
|
+
}
|
|
530
|
+
deleteByModuleId(modulePath) {
|
|
531
|
+
return super.delete(modulePath);
|
|
532
|
+
}
|
|
533
|
+
delete(fsPath) {
|
|
534
|
+
return this.deleteByModuleId(this.normalize(fsPath));
|
|
535
|
+
}
|
|
536
|
+
invalidate(id) {
|
|
537
|
+
const module = this.get(id);
|
|
538
|
+
module.evaluated = false, module.meta = void 0, module.map = void 0, module.promise = void 0, module.exports = void 0, module.imports?.clear();
|
|
539
|
+
}
|
|
540
|
+
isImported({
|
|
541
|
+
importedId,
|
|
542
|
+
importedBy
|
|
543
|
+
}, seen = /* @__PURE__ */ new Set()) {
|
|
544
|
+
if (importedId = this.normalize(importedId), importedBy = this.normalize(importedBy), importedBy === importedId) return true;
|
|
545
|
+
if (seen.has(importedId)) return false;
|
|
546
|
+
seen.add(importedId);
|
|
547
|
+
const importers = this.getByModuleId(importedId)?.importers;
|
|
548
|
+
if (!importers) return false;
|
|
549
|
+
if (importers.has(importedBy)) return true;
|
|
550
|
+
for (const importer of importers)
|
|
551
|
+
if (this.isImported({
|
|
552
|
+
importedBy,
|
|
553
|
+
importedId: importer
|
|
554
|
+
}))
|
|
555
|
+
return true;
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
560
|
+
*/
|
|
561
|
+
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
562
|
+
for (const _id of ids) {
|
|
563
|
+
const id = this.normalize(_id);
|
|
564
|
+
if (invalidated.has(id)) continue;
|
|
565
|
+
invalidated.add(id);
|
|
566
|
+
const mod = super.get(id);
|
|
567
|
+
mod?.importers && this.invalidateDepTree(mod.importers, invalidated), super.delete(id);
|
|
568
|
+
}
|
|
569
|
+
return invalidated;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
573
|
+
*/
|
|
574
|
+
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
575
|
+
for (const _id of ids) {
|
|
576
|
+
const id = this.normalize(_id);
|
|
577
|
+
if (invalidated.has(id)) continue;
|
|
578
|
+
invalidated.add(id);
|
|
579
|
+
const subIds = Array.from(super.entries()).filter(([, mod]) => mod.importers?.has(id)).map(([key]) => key);
|
|
580
|
+
subIds.length && this.invalidateSubDepTree(subIds, invalidated), super.delete(id);
|
|
581
|
+
}
|
|
582
|
+
return invalidated;
|
|
583
|
+
}
|
|
584
|
+
getSourceMap(moduleId) {
|
|
585
|
+
const mod = this.get(moduleId);
|
|
586
|
+
if (mod.map) return mod.map;
|
|
587
|
+
if (!mod.meta || !("code" in mod.meta)) return null;
|
|
588
|
+
const mapString = VITE_RUNTIME_SOURCEMAPPING_REGEXP.exec(mod.meta.code)?.[1];
|
|
589
|
+
if (!mapString) return null;
|
|
590
|
+
const baseFile = mod.meta.file || moduleId.split("?")[0];
|
|
591
|
+
return mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), baseFile), mod.map;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
var prefixedBuiltins = /* @__PURE__ */ new Set(["node:test"]);
|
|
595
|
+
function normalizeModuleId(file, root) {
|
|
596
|
+
if (prefixedBuiltins.has(file)) return file;
|
|
597
|
+
let unixFile = slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
598
|
+
return unixFile.startsWith(root) && (unixFile = unixFile.slice(root.length - 1)), unixFile.replace(/^file:\//, "/");
|
|
599
|
+
}
|
|
600
|
+
var HMRContext = class {
|
|
601
|
+
constructor(hmrClient, ownerPath) {
|
|
602
|
+
this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
|
|
603
|
+
const mod = hmrClient.hotModulesMap.get(ownerPath);
|
|
604
|
+
mod && (mod.callbacks = []);
|
|
605
|
+
const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
|
|
606
|
+
if (staleListeners)
|
|
607
|
+
for (const [event, staleFns] of staleListeners) {
|
|
608
|
+
const listeners = hmrClient.customListenersMap.get(event);
|
|
609
|
+
listeners && hmrClient.customListenersMap.set(
|
|
610
|
+
event,
|
|
611
|
+
listeners.filter((l) => !staleFns.includes(l))
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
this.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
|
|
615
|
+
}
|
|
616
|
+
newListeners;
|
|
617
|
+
get data() {
|
|
618
|
+
return this.hmrClient.dataMap.get(this.ownerPath);
|
|
619
|
+
}
|
|
620
|
+
accept(deps, callback) {
|
|
621
|
+
if (typeof deps == "function" || !deps)
|
|
622
|
+
this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
|
623
|
+
else if (typeof deps == "string")
|
|
624
|
+
this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
|
625
|
+
else if (Array.isArray(deps))
|
|
626
|
+
this.acceptDeps(deps, callback);
|
|
627
|
+
else
|
|
628
|
+
throw new Error("invalid hot.accept() usage.");
|
|
629
|
+
}
|
|
630
|
+
// export names (first arg) are irrelevant on the client side, they're
|
|
631
|
+
// extracted in the server for propagation
|
|
632
|
+
acceptExports(_, callback) {
|
|
633
|
+
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
|
634
|
+
}
|
|
635
|
+
dispose(cb) {
|
|
636
|
+
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
|
637
|
+
}
|
|
638
|
+
prune(cb) {
|
|
639
|
+
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
|
640
|
+
}
|
|
641
|
+
// Kept for backward compatibility (#11036)
|
|
642
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
643
|
+
decline() {
|
|
644
|
+
}
|
|
645
|
+
invalidate(message) {
|
|
646
|
+
this.hmrClient.notifyListeners("vite:invalidate", {
|
|
647
|
+
path: this.ownerPath,
|
|
648
|
+
message
|
|
649
|
+
}), this.send("vite:invalidate", { path: this.ownerPath, message }), this.hmrClient.logger.debug(
|
|
650
|
+
`[vite] invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
on(event, cb) {
|
|
654
|
+
const addToMap = (map) => {
|
|
655
|
+
const existing = map.get(event) || [];
|
|
656
|
+
existing.push(cb), map.set(event, existing);
|
|
657
|
+
};
|
|
658
|
+
addToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);
|
|
659
|
+
}
|
|
660
|
+
off(event, cb) {
|
|
661
|
+
const removeFromMap = (map) => {
|
|
662
|
+
const existing = map.get(event);
|
|
663
|
+
if (existing === void 0)
|
|
664
|
+
return;
|
|
665
|
+
const pruned = existing.filter((l) => l !== cb);
|
|
666
|
+
if (pruned.length === 0) {
|
|
667
|
+
map.delete(event);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
map.set(event, pruned);
|
|
671
|
+
};
|
|
672
|
+
removeFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);
|
|
673
|
+
}
|
|
674
|
+
send(event, data) {
|
|
675
|
+
this.hmrClient.messenger.send(
|
|
676
|
+
JSON.stringify({ type: "custom", event, data })
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
acceptDeps(deps, callback = () => {
|
|
680
|
+
}) {
|
|
681
|
+
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
|
682
|
+
id: this.ownerPath,
|
|
683
|
+
callbacks: []
|
|
684
|
+
};
|
|
685
|
+
mod.callbacks.push({
|
|
686
|
+
deps,
|
|
687
|
+
fn: callback
|
|
688
|
+
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
var HMRMessenger = class {
|
|
692
|
+
constructor(connection) {
|
|
693
|
+
this.connection = connection;
|
|
694
|
+
}
|
|
695
|
+
queue = [];
|
|
696
|
+
send(message) {
|
|
697
|
+
this.queue.push(message), this.flush();
|
|
698
|
+
}
|
|
699
|
+
flush() {
|
|
700
|
+
this.connection.isReady() && (this.queue.forEach((msg) => this.connection.send(msg)), this.queue = []);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var HMRClient = class {
|
|
704
|
+
constructor(logger, connection, importUpdatedModule) {
|
|
705
|
+
this.logger = logger, this.importUpdatedModule = importUpdatedModule, this.messenger = new HMRMessenger(connection);
|
|
706
|
+
}
|
|
707
|
+
hotModulesMap = /* @__PURE__ */ new Map();
|
|
708
|
+
disposeMap = /* @__PURE__ */ new Map();
|
|
709
|
+
pruneMap = /* @__PURE__ */ new Map();
|
|
710
|
+
dataMap = /* @__PURE__ */ new Map();
|
|
711
|
+
customListenersMap = /* @__PURE__ */ new Map();
|
|
712
|
+
ctxToListenersMap = /* @__PURE__ */ new Map();
|
|
713
|
+
messenger;
|
|
714
|
+
async notifyListeners(event, data) {
|
|
715
|
+
const cbs = this.customListenersMap.get(event);
|
|
716
|
+
cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
|
|
717
|
+
}
|
|
718
|
+
clear() {
|
|
719
|
+
this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
|
|
720
|
+
}
|
|
721
|
+
// After an HMR update, some modules are no longer imported on the page
|
|
722
|
+
// but they may have left behind side effects that need to be cleaned up
|
|
723
|
+
// (.e.g style injections)
|
|
724
|
+
async prunePaths(paths) {
|
|
725
|
+
await Promise.all(
|
|
726
|
+
paths.map((path2) => {
|
|
727
|
+
const disposer = this.disposeMap.get(path2);
|
|
728
|
+
if (disposer) return disposer(this.dataMap.get(path2));
|
|
729
|
+
})
|
|
730
|
+
), paths.forEach((path2) => {
|
|
731
|
+
const fn = this.pruneMap.get(path2);
|
|
732
|
+
fn && fn(this.dataMap.get(path2));
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
warnFailedUpdate(err, path2) {
|
|
736
|
+
err.message.includes("fetch") || this.logger.error(err), this.logger.error(
|
|
737
|
+
`[hmr] Failed to reload ${path2}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
updateQueue = [];
|
|
741
|
+
pendingUpdateQueue = false;
|
|
742
|
+
/**
|
|
743
|
+
* buffer multiple hot updates triggered by the same src change
|
|
744
|
+
* so that they are invoked in the same order they were sent.
|
|
745
|
+
* (otherwise the order may be inconsistent because of the http request round trip)
|
|
746
|
+
*/
|
|
747
|
+
async queueUpdate(payload) {
|
|
748
|
+
if (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {
|
|
749
|
+
this.pendingUpdateQueue = true, await Promise.resolve(), this.pendingUpdateQueue = false;
|
|
750
|
+
const loading = [...this.updateQueue];
|
|
751
|
+
this.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
async fetchUpdate(update) {
|
|
755
|
+
const { path: path2, acceptedPath } = update, mod = this.hotModulesMap.get(path2);
|
|
756
|
+
if (!mod)
|
|
757
|
+
return;
|
|
758
|
+
let fetchedModule;
|
|
759
|
+
const isSelfUpdate = path2 === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(
|
|
760
|
+
({ deps }) => deps.includes(acceptedPath)
|
|
761
|
+
);
|
|
762
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
|
763
|
+
const disposer = this.disposeMap.get(acceptedPath);
|
|
764
|
+
disposer && await disposer(this.dataMap.get(acceptedPath));
|
|
765
|
+
try {
|
|
766
|
+
fetchedModule = await this.importUpdatedModule(update);
|
|
767
|
+
} catch (e) {
|
|
768
|
+
this.warnFailedUpdate(e, acceptedPath);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return () => {
|
|
772
|
+
for (const { deps, fn } of qualifiedCallbacks)
|
|
773
|
+
fn(
|
|
774
|
+
deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0)
|
|
775
|
+
);
|
|
776
|
+
const loggedPath = isSelfUpdate ? path2 : `${acceptedPath} via ${path2}`;
|
|
777
|
+
this.logger.debug(`[vite] hot updated: ${loggedPath}`);
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
|
782
|
+
if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
|
|
783
|
+
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
|
784
|
+
if (missingBindings.length) {
|
|
785
|
+
const lastBinding = missingBindings[missingBindings.length - 1];
|
|
786
|
+
throw moduleType === "module" ? new SyntaxError(
|
|
787
|
+
`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`
|
|
788
|
+
) : new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
|
789
|
+
CommonJS modules can always be imported via the default export, for example using:
|
|
790
|
+
|
|
791
|
+
import pkg from '${rawId}';
|
|
792
|
+
const {${missingBindings.join(", ")}} = pkg;
|
|
793
|
+
`);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
var ssrModuleExportsKey = "__vite_ssr_exports__";
|
|
798
|
+
var ssrImportKey = "__vite_ssr_import__";
|
|
799
|
+
var ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
|
|
800
|
+
var ssrExportAllKey = "__vite_ssr_exportAll__";
|
|
801
|
+
var ssrImportMetaKey = "__vite_ssr_import_meta__";
|
|
802
|
+
var noop = () => {
|
|
803
|
+
};
|
|
804
|
+
var silentConsole = {
|
|
805
|
+
debug: noop,
|
|
806
|
+
error: noop
|
|
807
|
+
};
|
|
808
|
+
function createHMRHandler(runtime2) {
|
|
809
|
+
const queue = new Queue();
|
|
810
|
+
return (payload) => queue.enqueue(() => handleHMRPayload(runtime2, payload));
|
|
811
|
+
}
|
|
812
|
+
async function handleHMRPayload(runtime2, payload) {
|
|
813
|
+
const hmrClient = runtime2.hmrClient;
|
|
814
|
+
if (!(!hmrClient || runtime2.isDestroyed()))
|
|
815
|
+
switch (payload.type) {
|
|
816
|
+
case "connected":
|
|
817
|
+
hmrClient.logger.debug("[vite] connected."), hmrClient.messenger.flush();
|
|
818
|
+
break;
|
|
819
|
+
case "update":
|
|
820
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(
|
|
821
|
+
payload.updates.map(async (update) => {
|
|
822
|
+
if (update.type === "js-update")
|
|
823
|
+
return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
|
824
|
+
hmrClient.logger.error(
|
|
825
|
+
"[vite] css hmr is not supported in runtime mode."
|
|
826
|
+
);
|
|
827
|
+
})
|
|
828
|
+
), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
|
829
|
+
break;
|
|
830
|
+
case "custom": {
|
|
831
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
case "full-reload": {
|
|
835
|
+
const { triggeredBy } = payload, clearEntrypoints = triggeredBy ? [...runtime2.entrypoints].filter(
|
|
836
|
+
(entrypoint) => runtime2.moduleCache.isImported({
|
|
837
|
+
importedId: triggeredBy,
|
|
838
|
+
importedBy: entrypoint
|
|
839
|
+
})
|
|
840
|
+
) : [...runtime2.entrypoints];
|
|
841
|
+
if (!clearEntrypoints.length) break;
|
|
842
|
+
hmrClient.logger.debug("[vite] program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runtime2.moduleCache.clear();
|
|
843
|
+
for (const id of clearEntrypoints)
|
|
844
|
+
await runtime2.executeUrl(id);
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
case "prune":
|
|
848
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
|
849
|
+
break;
|
|
850
|
+
case "error": {
|
|
851
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
|
852
|
+
const err = payload.err;
|
|
853
|
+
hmrClient.logger.error(
|
|
854
|
+
`[vite] Internal Server Error
|
|
855
|
+
${err.message}
|
|
856
|
+
${err.stack}`
|
|
857
|
+
);
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
default:
|
|
861
|
+
return payload;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
var Queue = class {
|
|
865
|
+
queue = [];
|
|
866
|
+
pending = false;
|
|
867
|
+
enqueue(promise) {
|
|
868
|
+
return new Promise((resolve2, reject) => {
|
|
869
|
+
this.queue.push({
|
|
870
|
+
promise,
|
|
871
|
+
resolve: resolve2,
|
|
872
|
+
reject
|
|
873
|
+
}), this.dequeue();
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
dequeue() {
|
|
877
|
+
if (this.pending)
|
|
878
|
+
return false;
|
|
879
|
+
const item = this.queue.shift();
|
|
880
|
+
return item ? (this.pending = true, item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
|
881
|
+
this.pending = false, this.dequeue();
|
|
882
|
+
}), true) : false;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
var sourceMapCache = {};
|
|
886
|
+
var fileContentsCache = {};
|
|
887
|
+
var moduleGraphs = /* @__PURE__ */ new Set();
|
|
888
|
+
var retrieveFileHandlers = /* @__PURE__ */ new Set();
|
|
889
|
+
var retrieveSourceMapHandlers = /* @__PURE__ */ new Set();
|
|
890
|
+
var createExecHandlers = (handlers) => (...args) => {
|
|
891
|
+
for (const handler of handlers) {
|
|
892
|
+
const result = handler(...args);
|
|
893
|
+
if (result) return result;
|
|
894
|
+
}
|
|
895
|
+
return null;
|
|
896
|
+
};
|
|
897
|
+
var retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers);
|
|
898
|
+
var retrieveSourceMapFromHandlers = createExecHandlers(
|
|
899
|
+
retrieveSourceMapHandlers
|
|
900
|
+
);
|
|
901
|
+
var overridden = false;
|
|
902
|
+
var originalPrepare = Error.prepareStackTrace;
|
|
903
|
+
function resetInterceptor(runtime2, options) {
|
|
904
|
+
moduleGraphs.delete(runtime2.moduleCache), options.retrieveFile && retrieveFileHandlers.delete(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.delete(options.retrieveSourceMap), moduleGraphs.size === 0 && (Error.prepareStackTrace = originalPrepare, overridden = false);
|
|
905
|
+
}
|
|
906
|
+
function interceptStackTrace(runtime2, options = {}) {
|
|
907
|
+
return overridden || (Error.prepareStackTrace = prepareStackTrace, overridden = true), moduleGraphs.add(runtime2.moduleCache), options.retrieveFile && retrieveFileHandlers.add(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.add(options.retrieveSourceMap), () => resetInterceptor(runtime2, options);
|
|
908
|
+
}
|
|
909
|
+
function supportRelativeURL(file, url) {
|
|
910
|
+
if (!file) return url;
|
|
911
|
+
const dir = posixDirname(slash(file)), match2 = /^\w+:\/\/[^/]*/.exec(dir);
|
|
912
|
+
let protocol = match2 ? match2[0] : "";
|
|
913
|
+
const startPath = dir.slice(protocol.length);
|
|
914
|
+
return protocol && /^\/\w:/.test(startPath) ? (protocol += "/", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);
|
|
915
|
+
}
|
|
916
|
+
function getRuntimeSourceMap(position) {
|
|
917
|
+
for (const moduleCache of moduleGraphs) {
|
|
918
|
+
const sourceMap = moduleCache.getSourceMap(position.source);
|
|
919
|
+
if (sourceMap)
|
|
920
|
+
return {
|
|
921
|
+
url: position.source,
|
|
922
|
+
map: sourceMap,
|
|
923
|
+
vite: true
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
function retrieveFile(path2) {
|
|
929
|
+
if (path2 in fileContentsCache) return fileContentsCache[path2];
|
|
930
|
+
const content = retrieveFileFromHandlers(path2);
|
|
931
|
+
return typeof content == "string" ? (fileContentsCache[path2] = content, content) : null;
|
|
932
|
+
}
|
|
933
|
+
function retrieveSourceMapURL(source) {
|
|
934
|
+
const fileData = retrieveFile(source);
|
|
935
|
+
if (!fileData) return null;
|
|
936
|
+
const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
|
|
937
|
+
let lastMatch, match2;
|
|
938
|
+
for (; match2 = re.exec(fileData); ) lastMatch = match2;
|
|
939
|
+
return lastMatch ? lastMatch[1] : null;
|
|
940
|
+
}
|
|
941
|
+
var reSourceMap = /^data:application\/json[^,]+base64,/;
|
|
942
|
+
function retrieveSourceMap(source) {
|
|
943
|
+
const urlAndMap = retrieveSourceMapFromHandlers(source);
|
|
944
|
+
if (urlAndMap) return urlAndMap;
|
|
945
|
+
let sourceMappingURL = retrieveSourceMapURL(source);
|
|
946
|
+
if (!sourceMappingURL) return null;
|
|
947
|
+
let sourceMapData;
|
|
948
|
+
if (reSourceMap.test(sourceMappingURL)) {
|
|
949
|
+
const rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
|
|
950
|
+
sourceMapData = Buffer.from(rawData, "base64").toString(), sourceMappingURL = source;
|
|
951
|
+
} else
|
|
952
|
+
sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);
|
|
953
|
+
return sourceMapData ? {
|
|
954
|
+
url: sourceMappingURL,
|
|
955
|
+
map: sourceMapData
|
|
956
|
+
} : null;
|
|
957
|
+
}
|
|
958
|
+
function mapSourcePosition(position) {
|
|
959
|
+
if (!position.source) return position;
|
|
960
|
+
let sourceMap = getRuntimeSourceMap(position);
|
|
961
|
+
if (sourceMap || (sourceMap = sourceMapCache[position.source]), !sourceMap) {
|
|
962
|
+
const urlAndMap = retrieveSourceMap(position.source);
|
|
963
|
+
if (urlAndMap && urlAndMap.map) {
|
|
964
|
+
const url = urlAndMap.url;
|
|
965
|
+
sourceMap = sourceMapCache[position.source] = {
|
|
966
|
+
url,
|
|
967
|
+
map: new DecodedMap(
|
|
968
|
+
typeof urlAndMap.map == "string" ? JSON.parse(urlAndMap.map) : urlAndMap.map,
|
|
969
|
+
url
|
|
970
|
+
)
|
|
971
|
+
};
|
|
972
|
+
const contents = sourceMap.map?.map.sourcesContent;
|
|
973
|
+
sourceMap.map && contents && sourceMap.map.resolvedSources.forEach((source, i) => {
|
|
974
|
+
const content = contents[i];
|
|
975
|
+
if (content && source && url) {
|
|
976
|
+
const contentUrl = supportRelativeURL(url, source);
|
|
977
|
+
fileContentsCache[contentUrl] = content;
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
} else
|
|
981
|
+
sourceMap = sourceMapCache[position.source] = {
|
|
982
|
+
url: null,
|
|
983
|
+
map: null
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
if (sourceMap && sourceMap.map && sourceMap.url) {
|
|
987
|
+
const originalPosition = getOriginalPosition(sourceMap.map, position);
|
|
988
|
+
if (originalPosition && originalPosition.source != null)
|
|
989
|
+
return originalPosition.source = supportRelativeURL(
|
|
990
|
+
sourceMap.url,
|
|
991
|
+
originalPosition.source
|
|
992
|
+
), sourceMap.vite && (originalPosition._vite = true), originalPosition;
|
|
993
|
+
}
|
|
994
|
+
return position;
|
|
995
|
+
}
|
|
996
|
+
function mapEvalOrigin(origin) {
|
|
997
|
+
let match2 = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
|
|
998
|
+
if (match2) {
|
|
999
|
+
const position = mapSourcePosition({
|
|
1000
|
+
name: null,
|
|
1001
|
+
source: match2[2],
|
|
1002
|
+
line: +match2[3],
|
|
1003
|
+
column: +match2[4] - 1
|
|
1004
|
+
});
|
|
1005
|
+
return `eval at ${match2[1]} (${position.source}:${position.line}:${position.column + 1})`;
|
|
1006
|
+
}
|
|
1007
|
+
return match2 = /^eval at ([^(]+) \((.+)\)$/.exec(origin), match2 ? `eval at ${match2[1]} (${mapEvalOrigin(match2[2])})` : origin;
|
|
1008
|
+
}
|
|
1009
|
+
function CallSiteToString() {
|
|
1010
|
+
let fileName, fileLocation = "";
|
|
1011
|
+
if (this.isNative())
|
|
1012
|
+
fileLocation = "native";
|
|
1013
|
+
else {
|
|
1014
|
+
fileName = this.getScriptNameOrSourceURL(), !fileName && this.isEval() && (fileLocation = this.getEvalOrigin(), fileLocation += ", "), fileName ? fileLocation += fileName : fileLocation += "<anonymous>";
|
|
1015
|
+
const lineNumber = this.getLineNumber();
|
|
1016
|
+
if (lineNumber != null) {
|
|
1017
|
+
fileLocation += `:${lineNumber}`;
|
|
1018
|
+
const columnNumber = this.getColumnNumber();
|
|
1019
|
+
columnNumber && (fileLocation += `:${columnNumber}`);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
let line = "";
|
|
1023
|
+
const functionName = this.getFunctionName();
|
|
1024
|
+
let addSuffix = true;
|
|
1025
|
+
const isConstructor = this.isConstructor();
|
|
1026
|
+
if (this.isToplevel() || isConstructor)
|
|
1027
|
+
isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = false);
|
|
1028
|
+
else {
|
|
1029
|
+
let typeName = this.getTypeName();
|
|
1030
|
+
typeName === "[object Object]" && (typeName = "null");
|
|
1031
|
+
const methodName = this.getMethodName();
|
|
1032
|
+
functionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || "<anonymous>"}`;
|
|
1033
|
+
}
|
|
1034
|
+
return addSuffix && (line += ` (${fileLocation})`), line;
|
|
1035
|
+
}
|
|
1036
|
+
function cloneCallSite(frame) {
|
|
1037
|
+
const object = {};
|
|
1038
|
+
return Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {
|
|
1039
|
+
const key = name;
|
|
1040
|
+
object[key] = /^(?:is|get)/.test(name) ? function() {
|
|
1041
|
+
return frame[key].call(frame);
|
|
1042
|
+
} : frame[key];
|
|
1043
|
+
}), object.toString = CallSiteToString, object;
|
|
1044
|
+
}
|
|
1045
|
+
function wrapCallSite(frame, state) {
|
|
1046
|
+
if (state === void 0 && (state = { nextPosition: null, curPosition: null }), frame.isNative())
|
|
1047
|
+
return state.curPosition = null, frame;
|
|
1048
|
+
const source = frame.getFileName() || frame.getScriptNameOrSourceURL();
|
|
1049
|
+
if (source) {
|
|
1050
|
+
const line = frame.getLineNumber();
|
|
1051
|
+
let column = frame.getColumnNumber() - 1;
|
|
1052
|
+
const headerLength = 62;
|
|
1053
|
+
line === 1 && column > headerLength && !frame.isEval() && (column -= headerLength);
|
|
1054
|
+
const position = mapSourcePosition({
|
|
1055
|
+
name: null,
|
|
1056
|
+
source,
|
|
1057
|
+
line,
|
|
1058
|
+
column
|
|
1059
|
+
});
|
|
1060
|
+
state.curPosition = position, frame = cloneCallSite(frame);
|
|
1061
|
+
const originalFunctionName = frame.getFunctionName;
|
|
1062
|
+
return frame.getFunctionName = function() {
|
|
1063
|
+
const name = state.nextPosition == null ? originalFunctionName() : state.nextPosition.name || originalFunctionName();
|
|
1064
|
+
return name === "eval" && "_vite" in position ? null : name;
|
|
1065
|
+
}, frame.getFileName = function() {
|
|
1066
|
+
return position.source ?? void 0;
|
|
1067
|
+
}, frame.getLineNumber = function() {
|
|
1068
|
+
return position.line;
|
|
1069
|
+
}, frame.getColumnNumber = function() {
|
|
1070
|
+
return position.column + 1;
|
|
1071
|
+
}, frame.getScriptNameOrSourceURL = function() {
|
|
1072
|
+
return position.source;
|
|
1073
|
+
}, frame;
|
|
1074
|
+
}
|
|
1075
|
+
let origin = frame.isEval() && frame.getEvalOrigin();
|
|
1076
|
+
return origin && (origin = mapEvalOrigin(origin), frame = cloneCallSite(frame), frame.getEvalOrigin = function() {
|
|
1077
|
+
return origin || void 0;
|
|
1078
|
+
}), frame;
|
|
1079
|
+
}
|
|
1080
|
+
function prepareStackTrace(error, stack) {
|
|
1081
|
+
const name = error.name || "Error", message = error.message || "", errorString = `${name}: ${message}`, state = { nextPosition: null, curPosition: null }, processedStack = [];
|
|
1082
|
+
for (let i = stack.length - 1; i >= 0; i--)
|
|
1083
|
+
processedStack.push(`
|
|
1084
|
+
at ${wrapCallSite(stack[i], state)}`), state.nextPosition = state.curPosition;
|
|
1085
|
+
return state.curPosition = state.nextPosition = null, errorString + processedStack.reverse().join("");
|
|
1086
|
+
}
|
|
1087
|
+
function enableSourceMapSupport(runtime2) {
|
|
1088
|
+
if (runtime2.options.sourcemapInterceptor === "node") {
|
|
1089
|
+
if (typeof process > "u")
|
|
1090
|
+
throw new TypeError(
|
|
1091
|
+
`Cannot use "sourcemapInterceptor: 'node'" because global "process" variable is not available.`
|
|
1092
|
+
);
|
|
1093
|
+
if (typeof process.setSourceMapsEnabled != "function")
|
|
1094
|
+
throw new TypeError(
|
|
1095
|
+
`Cannot use "sourcemapInterceptor: 'node'" because "process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.`
|
|
1096
|
+
);
|
|
1097
|
+
const isEnabledAlready = process.sourceMapsEnabled ?? false;
|
|
1098
|
+
return process.setSourceMapsEnabled(true), () => !isEnabledAlready && process.setSourceMapsEnabled(false);
|
|
1099
|
+
}
|
|
1100
|
+
return interceptStackTrace(
|
|
1101
|
+
runtime2,
|
|
1102
|
+
typeof runtime2.options.sourcemapInterceptor == "object" ? runtime2.options.sourcemapInterceptor : void 0
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
var ViteRuntime = class {
|
|
1106
|
+
constructor(options, runner, debug) {
|
|
1107
|
+
this.options = options, this.runner = runner, this.debug = debug, this.moduleCache = options.moduleCache ?? new ModuleCacheMap(options.root), typeof options.hmr == "object" && (this.hmrClient = new HMRClient(
|
|
1108
|
+
options.hmr.logger === false ? silentConsole : options.hmr.logger || console,
|
|
1109
|
+
options.hmr.connection,
|
|
1110
|
+
({ acceptedPath, ssrInvalidates }) => (this.moduleCache.invalidate(acceptedPath), ssrInvalidates && this.invalidateFiles(ssrInvalidates), this.executeUrl(acceptedPath))
|
|
1111
|
+
), options.hmr.connection.onUpdate(createHMRHandler(this))), options.sourcemapInterceptor !== false && (this._resetSourceMapSupport = enableSourceMapSupport(this));
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Holds the cache of modules
|
|
1115
|
+
* Keys of the map are ids
|
|
1116
|
+
*/
|
|
1117
|
+
moduleCache;
|
|
1118
|
+
hmrClient;
|
|
1119
|
+
entrypoints = /* @__PURE__ */ new Set();
|
|
1120
|
+
idToUrlMap = /* @__PURE__ */ new Map();
|
|
1121
|
+
fileToIdMap = /* @__PURE__ */ new Map();
|
|
1122
|
+
envProxy = new Proxy({}, {
|
|
1123
|
+
get(_, p) {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`[vite-runtime] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
_destroyed = false;
|
|
1130
|
+
_resetSourceMapSupport;
|
|
1131
|
+
/**
|
|
1132
|
+
* URL to execute. Accepts file path, server path or id relative to the root.
|
|
1133
|
+
*/
|
|
1134
|
+
async executeUrl(url) {
|
|
1135
|
+
url = this.normalizeEntryUrl(url);
|
|
1136
|
+
const fetchedModule = await this.cachedModule(url);
|
|
1137
|
+
return await this.cachedRequest(url, fetchedModule);
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Entrypoint URL to execute. Accepts file path, server path or id relative to the root.
|
|
1141
|
+
* In the case of a full reload triggered by HMR, this is the module that will be reloaded.
|
|
1142
|
+
* If this method is called multiple times, all entrypoints will be reloaded one at a time.
|
|
1143
|
+
*/
|
|
1144
|
+
async executeEntrypoint(url) {
|
|
1145
|
+
url = this.normalizeEntryUrl(url);
|
|
1146
|
+
const fetchedModule = await this.cachedModule(url);
|
|
1147
|
+
return await this.cachedRequest(url, fetchedModule, [], {
|
|
1148
|
+
entrypoint: true
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Clear all caches including HMR listeners.
|
|
1153
|
+
*/
|
|
1154
|
+
clearCache() {
|
|
1155
|
+
this.moduleCache.clear(), this.idToUrlMap.clear(), this.entrypoints.clear(), this.hmrClient?.clear();
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Clears all caches, removes all HMR listeners, and resets source map support.
|
|
1159
|
+
* This method doesn't stop the HMR connection.
|
|
1160
|
+
*/
|
|
1161
|
+
async destroy() {
|
|
1162
|
+
this._resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this._destroyed = true;
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Returns `true` if the runtime has been destroyed by calling `destroy()` method.
|
|
1166
|
+
*/
|
|
1167
|
+
isDestroyed() {
|
|
1168
|
+
return this._destroyed;
|
|
1169
|
+
}
|
|
1170
|
+
invalidateFiles(files) {
|
|
1171
|
+
files.forEach((file) => {
|
|
1172
|
+
const ids = this.fileToIdMap.get(file);
|
|
1173
|
+
ids && ids.forEach((id) => this.moduleCache.invalidate(id));
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
// we don't use moduleCache.normalize because this URL doesn't have to follow the same rules
|
|
1177
|
+
// this URL is something that user passes down manually, and is later resolved by fetchModule
|
|
1178
|
+
// moduleCache.normalize is used on resolved "file" property
|
|
1179
|
+
normalizeEntryUrl(url) {
|
|
1180
|
+
if (url[0] === ".")
|
|
1181
|
+
return url;
|
|
1182
|
+
url.startsWith("file://") && (url = url.slice(isWindows ? 8 : 7)), url = slash(url);
|
|
1183
|
+
const _root = this.options.root, root = _root[_root.length - 1] === "/" ? _root : `${_root}/`;
|
|
1184
|
+
return url.startsWith(root) ? url.slice(root.length - 1) : url[0] === "/" ? url : wrapId(url);
|
|
1185
|
+
}
|
|
1186
|
+
processImport(exports, fetchResult, metadata) {
|
|
1187
|
+
if (!("externalize" in fetchResult))
|
|
1188
|
+
return exports;
|
|
1189
|
+
const { id, type } = fetchResult;
|
|
1190
|
+
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, id, type, metadata), exports;
|
|
1191
|
+
}
|
|
1192
|
+
async cachedRequest(id, fetchedModule, callstack = [], metadata) {
|
|
1193
|
+
const moduleId = fetchedModule.id;
|
|
1194
|
+
metadata?.entrypoint && this.entrypoints.add(moduleId);
|
|
1195
|
+
const mod = this.moduleCache.getByModuleId(moduleId), { imports, importers } = mod, importee = callstack[callstack.length - 1];
|
|
1196
|
+
if (importee && importers.add(importee), (callstack.includes(moduleId) || Array.from(imports.values()).some((i) => importers.has(i))) && mod.exports)
|
|
1197
|
+
return this.processImport(mod.exports, fetchedModule, metadata);
|
|
1198
|
+
let debugTimer;
|
|
1199
|
+
this.debug && (debugTimer = setTimeout(() => {
|
|
1200
|
+
const getStack = () => `stack:
|
|
1201
|
+
${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join(`
|
|
1202
|
+
`)}`;
|
|
1203
|
+
this.debug(
|
|
1204
|
+
`[vite-runtime] module ${moduleId} takes over 2s to load.
|
|
1205
|
+
${getStack()}`
|
|
1206
|
+
);
|
|
1207
|
+
}, 2e3));
|
|
1208
|
+
try {
|
|
1209
|
+
if (mod.promise)
|
|
1210
|
+
return this.processImport(await mod.promise, fetchedModule, metadata);
|
|
1211
|
+
const promise = this.directRequest(id, fetchedModule, callstack);
|
|
1212
|
+
return mod.promise = promise, mod.evaluated = false, this.processImport(await promise, fetchedModule, metadata);
|
|
1213
|
+
} finally {
|
|
1214
|
+
mod.evaluated = true, debugTimer && clearTimeout(debugTimer);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
async cachedModule(id, importer) {
|
|
1218
|
+
if (this._destroyed)
|
|
1219
|
+
throw new Error("[vite] Vite runtime has been destroyed.");
|
|
1220
|
+
const normalized = this.idToUrlMap.get(id);
|
|
1221
|
+
if (normalized) {
|
|
1222
|
+
const mod2 = this.moduleCache.getByModuleId(normalized);
|
|
1223
|
+
if (mod2.meta)
|
|
1224
|
+
return mod2.meta;
|
|
1225
|
+
}
|
|
1226
|
+
this.debug?.("[vite-runtime] fetching", id);
|
|
1227
|
+
const fetchedModule = id.startsWith("data:") ? { externalize: id, type: "builtin" } : await this.options.fetchModule(id, importer), idQuery = id.split("?")[1], query = idQuery ? `?${idQuery}` : "", file = "file" in fetchedModule ? fetchedModule.file : void 0, fullFile = file ? `${file}${query}` : id, moduleId = this.moduleCache.normalize(fullFile), mod = this.moduleCache.getByModuleId(moduleId);
|
|
1228
|
+
if (fetchedModule.id = moduleId, mod.meta = fetchedModule, file) {
|
|
1229
|
+
const fileModules = this.fileToIdMap.get(file) || [];
|
|
1230
|
+
fileModules.push(moduleId), this.fileToIdMap.set(file, fileModules);
|
|
1231
|
+
}
|
|
1232
|
+
return this.idToUrlMap.set(id, moduleId), this.idToUrlMap.set(unwrapId(id), moduleId), fetchedModule;
|
|
1233
|
+
}
|
|
1234
|
+
// override is allowed, consider this a public API
|
|
1235
|
+
async directRequest(id, fetchResult, _callstack) {
|
|
1236
|
+
const moduleId = fetchResult.id, callstack = [..._callstack, moduleId], mod = this.moduleCache.getByModuleId(moduleId), request = async (dep, metadata) => {
|
|
1237
|
+
const fetchedModule = await this.cachedModule(dep, moduleId);
|
|
1238
|
+
return this.moduleCache.getByModuleId(fetchedModule.id).importers.add(moduleId), mod.imports.add(fetchedModule.id), this.cachedRequest(dep, fetchedModule, callstack, metadata);
|
|
1239
|
+
}, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === "." && (dep = posixResolve(posixDirname(id), dep)), request(dep, { isDynamicImport: true }));
|
|
1240
|
+
if ("externalize" in fetchResult) {
|
|
1241
|
+
const { externalize } = fetchResult;
|
|
1242
|
+
this.debug?.("[vite-runtime] externalizing", externalize);
|
|
1243
|
+
const exports2 = await this.runner.runExternalModule(externalize);
|
|
1244
|
+
return mod.exports = exports2, exports2;
|
|
1245
|
+
}
|
|
1246
|
+
const { code, file } = fetchResult;
|
|
1247
|
+
if (code == null) {
|
|
1248
|
+
const importer = callstack[callstack.length - 2];
|
|
1249
|
+
throw new Error(
|
|
1250
|
+
`[vite-runtime] Failed to load "${id}"${importer ? ` imported from ${importer}` : ""}`
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
const modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), filename = modulePath, dirname2 = posixDirname(modulePath), meta = {
|
|
1254
|
+
filename: isWindows ? toWindowsPath(filename) : filename,
|
|
1255
|
+
dirname: isWindows ? toWindowsPath(dirname2) : dirname2,
|
|
1256
|
+
url: href,
|
|
1257
|
+
env: this.envProxy,
|
|
1258
|
+
resolve(id2, parent) {
|
|
1259
|
+
throw new Error(
|
|
1260
|
+
'[vite-runtime] "import.meta.resolve" is not supported.'
|
|
1261
|
+
);
|
|
1262
|
+
},
|
|
1263
|
+
// should be replaced during transformation
|
|
1264
|
+
glob() {
|
|
1265
|
+
throw new Error('[vite-runtime] "import.meta.glob" is not supported.');
|
|
1266
|
+
}
|
|
1267
|
+
}, exports = /* @__PURE__ */ Object.create(null);
|
|
1268
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
1269
|
+
value: "Module",
|
|
1270
|
+
enumerable: false,
|
|
1271
|
+
configurable: false
|
|
1272
|
+
}), mod.exports = exports;
|
|
1273
|
+
let hotContext;
|
|
1274
|
+
this.hmrClient && Object.defineProperty(meta, "hot", {
|
|
1275
|
+
enumerable: true,
|
|
1276
|
+
get: () => {
|
|
1277
|
+
if (!this.hmrClient)
|
|
1278
|
+
throw new Error("[vite-runtime] HMR client was destroyed.");
|
|
1279
|
+
return this.debug?.("[vite-runtime] creating hmr context for", moduleId), hotContext ||= new HMRContext(this.hmrClient, moduleId), hotContext;
|
|
1280
|
+
},
|
|
1281
|
+
set: (value) => {
|
|
1282
|
+
hotContext = value;
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
const context = {
|
|
1286
|
+
[ssrImportKey]: request,
|
|
1287
|
+
[ssrDynamicImportKey]: dynamicRequest,
|
|
1288
|
+
[ssrModuleExportsKey]: exports,
|
|
1289
|
+
[ssrExportAllKey]: (obj) => exportAll(exports, obj),
|
|
1290
|
+
[ssrImportMetaKey]: meta
|
|
1291
|
+
};
|
|
1292
|
+
return this.debug?.("[vite-runtime] executing", href), await this.runner.runViteModule(context, code, id), exports;
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
function exportAll(exports, sourceModule) {
|
|
1296
|
+
if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
|
|
1297
|
+
for (const key in sourceModule)
|
|
1298
|
+
if (key !== "default" && key !== "__esModule")
|
|
1299
|
+
try {
|
|
1300
|
+
Object.defineProperty(exports, key, {
|
|
1301
|
+
enumerable: true,
|
|
1302
|
+
configurable: true,
|
|
1303
|
+
get: () => sourceModule[key]
|
|
1304
|
+
});
|
|
1305
|
+
} catch {
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/worker-entry.ts
|
|
1311
|
+
import process2 from "node:process";
|
|
1312
|
+
|
|
1313
|
+
// ../../node_modules/minimatch/dist/esm/index.js
|
|
1314
|
+
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
1315
|
+
|
|
1316
|
+
// ../../node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
1317
|
+
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
1318
|
+
var assertValidPattern = (pattern) => {
|
|
1319
|
+
if (typeof pattern !== "string") {
|
|
1320
|
+
throw new TypeError("invalid pattern");
|
|
1321
|
+
}
|
|
1322
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
1323
|
+
throw new TypeError("pattern is too long");
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
// ../../node_modules/minimatch/dist/esm/brace-expressions.js
|
|
1328
|
+
var posixClasses = {
|
|
1329
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
1330
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
1331
|
+
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
1332
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
1333
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
1334
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
1335
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
1336
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
1337
|
+
"[:print:]": ["\\p{C}", true],
|
|
1338
|
+
"[:punct:]": ["\\p{P}", true],
|
|
1339
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
1340
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
1341
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
1342
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
1343
|
+
};
|
|
1344
|
+
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
1345
|
+
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1346
|
+
var rangesToString = (ranges) => ranges.join("");
|
|
1347
|
+
var parseClass = (glob, position) => {
|
|
1348
|
+
const pos = position;
|
|
1349
|
+
if (glob.charAt(pos) !== "[") {
|
|
1350
|
+
throw new Error("not in a brace expression");
|
|
1351
|
+
}
|
|
1352
|
+
const ranges = [];
|
|
1353
|
+
const negs = [];
|
|
1354
|
+
let i = pos + 1;
|
|
1355
|
+
let sawStart = false;
|
|
1356
|
+
let uflag = false;
|
|
1357
|
+
let escaping = false;
|
|
1358
|
+
let negate = false;
|
|
1359
|
+
let endPos = pos;
|
|
1360
|
+
let rangeStart = "";
|
|
1361
|
+
WHILE: while (i < glob.length) {
|
|
1362
|
+
const c = glob.charAt(i);
|
|
1363
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
1364
|
+
negate = true;
|
|
1365
|
+
i++;
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
if (c === "]" && sawStart && !escaping) {
|
|
1369
|
+
endPos = i + 1;
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1372
|
+
sawStart = true;
|
|
1373
|
+
if (c === "\\") {
|
|
1374
|
+
if (!escaping) {
|
|
1375
|
+
escaping = true;
|
|
1376
|
+
i++;
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
if (c === "[" && !escaping) {
|
|
1381
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
1382
|
+
if (glob.startsWith(cls, i)) {
|
|
1383
|
+
if (rangeStart) {
|
|
1384
|
+
return ["$.", false, glob.length - pos, true];
|
|
1385
|
+
}
|
|
1386
|
+
i += cls.length;
|
|
1387
|
+
if (neg)
|
|
1388
|
+
negs.push(unip);
|
|
1389
|
+
else
|
|
1390
|
+
ranges.push(unip);
|
|
1391
|
+
uflag = uflag || u;
|
|
1392
|
+
continue WHILE;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
escaping = false;
|
|
1397
|
+
if (rangeStart) {
|
|
1398
|
+
if (c > rangeStart) {
|
|
1399
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
1400
|
+
} else if (c === rangeStart) {
|
|
1401
|
+
ranges.push(braceEscape(c));
|
|
1402
|
+
}
|
|
1403
|
+
rangeStart = "";
|
|
1404
|
+
i++;
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
if (glob.startsWith("-]", i + 1)) {
|
|
1408
|
+
ranges.push(braceEscape(c + "-"));
|
|
1409
|
+
i += 2;
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1412
|
+
if (glob.startsWith("-", i + 1)) {
|
|
1413
|
+
rangeStart = c;
|
|
1414
|
+
i += 2;
|
|
1415
|
+
continue;
|
|
1416
|
+
}
|
|
1417
|
+
ranges.push(braceEscape(c));
|
|
1418
|
+
i++;
|
|
1419
|
+
}
|
|
1420
|
+
if (endPos < i) {
|
|
1421
|
+
return ["", false, 0, false];
|
|
1422
|
+
}
|
|
1423
|
+
if (!ranges.length && !negs.length) {
|
|
1424
|
+
return ["$.", false, glob.length - pos, true];
|
|
1425
|
+
}
|
|
1426
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
1427
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
1428
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
1429
|
+
}
|
|
1430
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
1431
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
1432
|
+
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
1433
|
+
return [comb, uflag, endPos - pos, true];
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
// ../../node_modules/minimatch/dist/esm/unescape.js
|
|
1437
|
+
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
1438
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
// ../../node_modules/minimatch/dist/esm/ast.js
|
|
1442
|
+
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
1443
|
+
var isExtglobType = (c) => types.has(c);
|
|
1444
|
+
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
1445
|
+
var startNoDot = "(?!\\.)";
|
|
1446
|
+
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
1447
|
+
var justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
1448
|
+
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
1449
|
+
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1450
|
+
var qmark = "[^/]";
|
|
1451
|
+
var star = qmark + "*?";
|
|
1452
|
+
var starNoEmpty = qmark + "+?";
|
|
1453
|
+
var AST = class _AST {
|
|
1454
|
+
type;
|
|
1455
|
+
#root;
|
|
1456
|
+
#hasMagic;
|
|
1457
|
+
#uflag = false;
|
|
1458
|
+
#parts = [];
|
|
1459
|
+
#parent;
|
|
1460
|
+
#parentIndex;
|
|
1461
|
+
#negs;
|
|
1462
|
+
#filledNegs = false;
|
|
1463
|
+
#options;
|
|
1464
|
+
#toString;
|
|
1465
|
+
// set to true if it's an extglob with no children
|
|
1466
|
+
// (which really means one child of '')
|
|
1467
|
+
#emptyExt = false;
|
|
1468
|
+
constructor(type, parent, options = {}) {
|
|
1469
|
+
this.type = type;
|
|
1470
|
+
if (type)
|
|
1471
|
+
this.#hasMagic = true;
|
|
1472
|
+
this.#parent = parent;
|
|
1473
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
1474
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
1475
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
1476
|
+
if (type === "!" && !this.#root.#filledNegs)
|
|
1477
|
+
this.#negs.push(this);
|
|
1478
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
1479
|
+
}
|
|
1480
|
+
get hasMagic() {
|
|
1481
|
+
if (this.#hasMagic !== void 0)
|
|
1482
|
+
return this.#hasMagic;
|
|
1483
|
+
for (const p of this.#parts) {
|
|
1484
|
+
if (typeof p === "string")
|
|
1485
|
+
continue;
|
|
1486
|
+
if (p.type || p.hasMagic)
|
|
1487
|
+
return this.#hasMagic = true;
|
|
1488
|
+
}
|
|
1489
|
+
return this.#hasMagic;
|
|
1490
|
+
}
|
|
1491
|
+
// reconstructs the pattern
|
|
1492
|
+
toString() {
|
|
1493
|
+
if (this.#toString !== void 0)
|
|
1494
|
+
return this.#toString;
|
|
1495
|
+
if (!this.type) {
|
|
1496
|
+
return this.#toString = this.#parts.map((p) => String(p)).join("");
|
|
1497
|
+
} else {
|
|
1498
|
+
return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
#fillNegs() {
|
|
1502
|
+
if (this !== this.#root)
|
|
1503
|
+
throw new Error("should only call on root");
|
|
1504
|
+
if (this.#filledNegs)
|
|
1505
|
+
return this;
|
|
1506
|
+
this.toString();
|
|
1507
|
+
this.#filledNegs = true;
|
|
1508
|
+
let n;
|
|
1509
|
+
while (n = this.#negs.pop()) {
|
|
1510
|
+
if (n.type !== "!")
|
|
1511
|
+
continue;
|
|
1512
|
+
let p = n;
|
|
1513
|
+
let pp = p.#parent;
|
|
1514
|
+
while (pp) {
|
|
1515
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
1516
|
+
for (const part of n.#parts) {
|
|
1517
|
+
if (typeof part === "string") {
|
|
1518
|
+
throw new Error("string part in extglob AST??");
|
|
1519
|
+
}
|
|
1520
|
+
part.copyIn(pp.#parts[i]);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
p = pp;
|
|
1524
|
+
pp = p.#parent;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
return this;
|
|
1528
|
+
}
|
|
1529
|
+
push(...parts) {
|
|
1530
|
+
for (const p of parts) {
|
|
1531
|
+
if (p === "")
|
|
1532
|
+
continue;
|
|
1533
|
+
if (typeof p !== "string" && !(p instanceof _AST && p.#parent === this)) {
|
|
1534
|
+
throw new Error("invalid part: " + p);
|
|
1535
|
+
}
|
|
1536
|
+
this.#parts.push(p);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
toJSON() {
|
|
1540
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
1541
|
+
if (this.isStart() && !this.type)
|
|
1542
|
+
ret.unshift([]);
|
|
1543
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
1544
|
+
ret.push({});
|
|
1545
|
+
}
|
|
1546
|
+
return ret;
|
|
1547
|
+
}
|
|
1548
|
+
isStart() {
|
|
1549
|
+
if (this.#root === this)
|
|
1550
|
+
return true;
|
|
1551
|
+
if (!this.#parent?.isStart())
|
|
1552
|
+
return false;
|
|
1553
|
+
if (this.#parentIndex === 0)
|
|
1554
|
+
return true;
|
|
1555
|
+
const p = this.#parent;
|
|
1556
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
|
1557
|
+
const pp = p.#parts[i];
|
|
1558
|
+
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
1559
|
+
return false;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
return true;
|
|
1563
|
+
}
|
|
1564
|
+
isEnd() {
|
|
1565
|
+
if (this.#root === this)
|
|
1566
|
+
return true;
|
|
1567
|
+
if (this.#parent?.type === "!")
|
|
1568
|
+
return true;
|
|
1569
|
+
if (!this.#parent?.isEnd())
|
|
1570
|
+
return false;
|
|
1571
|
+
if (!this.type)
|
|
1572
|
+
return this.#parent?.isEnd();
|
|
1573
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
1574
|
+
return this.#parentIndex === pl - 1;
|
|
1575
|
+
}
|
|
1576
|
+
copyIn(part) {
|
|
1577
|
+
if (typeof part === "string")
|
|
1578
|
+
this.push(part);
|
|
1579
|
+
else
|
|
1580
|
+
this.push(part.clone(this));
|
|
1581
|
+
}
|
|
1582
|
+
clone(parent) {
|
|
1583
|
+
const c = new _AST(this.type, parent);
|
|
1584
|
+
for (const p of this.#parts) {
|
|
1585
|
+
c.copyIn(p);
|
|
1586
|
+
}
|
|
1587
|
+
return c;
|
|
1588
|
+
}
|
|
1589
|
+
static #parseAST(str, ast, pos, opt) {
|
|
1590
|
+
let escaping = false;
|
|
1591
|
+
let inBrace = false;
|
|
1592
|
+
let braceStart = -1;
|
|
1593
|
+
let braceNeg = false;
|
|
1594
|
+
if (ast.type === null) {
|
|
1595
|
+
let i2 = pos;
|
|
1596
|
+
let acc2 = "";
|
|
1597
|
+
while (i2 < str.length) {
|
|
1598
|
+
const c = str.charAt(i2++);
|
|
1599
|
+
if (escaping || c === "\\") {
|
|
1600
|
+
escaping = !escaping;
|
|
1601
|
+
acc2 += c;
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
if (inBrace) {
|
|
1605
|
+
if (i2 === braceStart + 1) {
|
|
1606
|
+
if (c === "^" || c === "!") {
|
|
1607
|
+
braceNeg = true;
|
|
1608
|
+
}
|
|
1609
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
1610
|
+
inBrace = false;
|
|
1611
|
+
}
|
|
1612
|
+
acc2 += c;
|
|
1613
|
+
continue;
|
|
1614
|
+
} else if (c === "[") {
|
|
1615
|
+
inBrace = true;
|
|
1616
|
+
braceStart = i2;
|
|
1617
|
+
braceNeg = false;
|
|
1618
|
+
acc2 += c;
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
1622
|
+
ast.push(acc2);
|
|
1623
|
+
acc2 = "";
|
|
1624
|
+
const ext2 = new _AST(c, ast);
|
|
1625
|
+
i2 = _AST.#parseAST(str, ext2, i2, opt);
|
|
1626
|
+
ast.push(ext2);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
acc2 += c;
|
|
1630
|
+
}
|
|
1631
|
+
ast.push(acc2);
|
|
1632
|
+
return i2;
|
|
1633
|
+
}
|
|
1634
|
+
let i = pos + 1;
|
|
1635
|
+
let part = new _AST(null, ast);
|
|
1636
|
+
const parts = [];
|
|
1637
|
+
let acc = "";
|
|
1638
|
+
while (i < str.length) {
|
|
1639
|
+
const c = str.charAt(i++);
|
|
1640
|
+
if (escaping || c === "\\") {
|
|
1641
|
+
escaping = !escaping;
|
|
1642
|
+
acc += c;
|
|
1643
|
+
continue;
|
|
1644
|
+
}
|
|
1645
|
+
if (inBrace) {
|
|
1646
|
+
if (i === braceStart + 1) {
|
|
1647
|
+
if (c === "^" || c === "!") {
|
|
1648
|
+
braceNeg = true;
|
|
1649
|
+
}
|
|
1650
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
1651
|
+
inBrace = false;
|
|
1652
|
+
}
|
|
1653
|
+
acc += c;
|
|
1654
|
+
continue;
|
|
1655
|
+
} else if (c === "[") {
|
|
1656
|
+
inBrace = true;
|
|
1657
|
+
braceStart = i;
|
|
1658
|
+
braceNeg = false;
|
|
1659
|
+
acc += c;
|
|
1660
|
+
continue;
|
|
1661
|
+
}
|
|
1662
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
1663
|
+
part.push(acc);
|
|
1664
|
+
acc = "";
|
|
1665
|
+
const ext2 = new _AST(c, part);
|
|
1666
|
+
part.push(ext2);
|
|
1667
|
+
i = _AST.#parseAST(str, ext2, i, opt);
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (c === "|") {
|
|
1671
|
+
part.push(acc);
|
|
1672
|
+
acc = "";
|
|
1673
|
+
parts.push(part);
|
|
1674
|
+
part = new _AST(null, ast);
|
|
1675
|
+
continue;
|
|
1676
|
+
}
|
|
1677
|
+
if (c === ")") {
|
|
1678
|
+
if (acc === "" && ast.#parts.length === 0) {
|
|
1679
|
+
ast.#emptyExt = true;
|
|
1680
|
+
}
|
|
1681
|
+
part.push(acc);
|
|
1682
|
+
acc = "";
|
|
1683
|
+
ast.push(...parts, part);
|
|
1684
|
+
return i;
|
|
1685
|
+
}
|
|
1686
|
+
acc += c;
|
|
1687
|
+
}
|
|
1688
|
+
ast.type = null;
|
|
1689
|
+
ast.#hasMagic = void 0;
|
|
1690
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
1691
|
+
return i;
|
|
1692
|
+
}
|
|
1693
|
+
static fromGlob(pattern, options = {}) {
|
|
1694
|
+
const ast = new _AST(null, void 0, options);
|
|
1695
|
+
_AST.#parseAST(pattern, ast, 0, options);
|
|
1696
|
+
return ast;
|
|
1697
|
+
}
|
|
1698
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
1699
|
+
// string if not.
|
|
1700
|
+
toMMPattern() {
|
|
1701
|
+
if (this !== this.#root)
|
|
1702
|
+
return this.#root.toMMPattern();
|
|
1703
|
+
const glob = this.toString();
|
|
1704
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
1705
|
+
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
1706
|
+
if (!anyMagic) {
|
|
1707
|
+
return body;
|
|
1708
|
+
}
|
|
1709
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
1710
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
1711
|
+
_src: re,
|
|
1712
|
+
_glob: glob
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
get options() {
|
|
1716
|
+
return this.#options;
|
|
1717
|
+
}
|
|
1718
|
+
// returns the string match, the regexp source, whether there's magic
|
|
1719
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
1720
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
1721
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
1722
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
1723
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
1724
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
1725
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
1726
|
+
//
|
|
1727
|
+
// In part-matching mode, the start is:
|
|
1728
|
+
// - if not isStart: nothing
|
|
1729
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
1730
|
+
// - if dots allowed or not possible: ^
|
|
1731
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
1732
|
+
// end is:
|
|
1733
|
+
// - if not isEnd(): nothing
|
|
1734
|
+
// - else: $
|
|
1735
|
+
//
|
|
1736
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
1737
|
+
// pattern, so start is:
|
|
1738
|
+
// - if first pattern: same as part-matching mode
|
|
1739
|
+
// - if not isStart(): nothing
|
|
1740
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
1741
|
+
// - if dots allowed or not possible: /
|
|
1742
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
1743
|
+
// end is:
|
|
1744
|
+
// - if last pattern, same as part-matching mode
|
|
1745
|
+
// - else nothing
|
|
1746
|
+
//
|
|
1747
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
1748
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
1749
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
1750
|
+
// the pattern.
|
|
1751
|
+
//
|
|
1752
|
+
// We can just always return the same end, and leave it up to the caller
|
|
1753
|
+
// to know whether it's going to be used joined or in parts.
|
|
1754
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
1755
|
+
// - if not isStart: nothing
|
|
1756
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
1757
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
1758
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
1759
|
+
//
|
|
1760
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
1761
|
+
// performance, so probably better to return both start options.
|
|
1762
|
+
//
|
|
1763
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
1764
|
+
// and the start always gets applied.
|
|
1765
|
+
//
|
|
1766
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
1767
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
1768
|
+
//
|
|
1769
|
+
// So the todo is:
|
|
1770
|
+
// - better detect what kind of start is needed
|
|
1771
|
+
// - return both flavors of starting pattern
|
|
1772
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
1773
|
+
//
|
|
1774
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
1775
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
1776
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
1777
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
1778
|
+
//
|
|
1779
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
1780
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
1781
|
+
// use the (?:^|/) style of start binding.
|
|
1782
|
+
//
|
|
1783
|
+
// Even simplified further:
|
|
1784
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
1785
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
1786
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
1787
|
+
toRegExpSource(allowDot) {
|
|
1788
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
1789
|
+
if (this.#root === this)
|
|
1790
|
+
this.#fillNegs();
|
|
1791
|
+
if (!this.type) {
|
|
1792
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
1793
|
+
const src = this.#parts.map((p) => {
|
|
1794
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
1795
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
1796
|
+
this.#uflag = this.#uflag || uflag;
|
|
1797
|
+
return re;
|
|
1798
|
+
}).join("");
|
|
1799
|
+
let start2 = "";
|
|
1800
|
+
if (this.isStart()) {
|
|
1801
|
+
if (typeof this.#parts[0] === "string") {
|
|
1802
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
1803
|
+
if (!dotTravAllowed) {
|
|
1804
|
+
const aps = addPatternStart;
|
|
1805
|
+
const needNoTrav = (
|
|
1806
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
1807
|
+
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
1808
|
+
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
1809
|
+
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
1810
|
+
);
|
|
1811
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
1812
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
let end = "";
|
|
1817
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
1818
|
+
end = "(?:$|\\/)";
|
|
1819
|
+
}
|
|
1820
|
+
const final2 = start2 + src + end;
|
|
1821
|
+
return [
|
|
1822
|
+
final2,
|
|
1823
|
+
unescape(src),
|
|
1824
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
1825
|
+
this.#uflag
|
|
1826
|
+
];
|
|
1827
|
+
}
|
|
1828
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
1829
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1830
|
+
let body = this.#partsToRegExp(dot);
|
|
1831
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
1832
|
+
const s = this.toString();
|
|
1833
|
+
this.#parts = [s];
|
|
1834
|
+
this.type = null;
|
|
1835
|
+
this.#hasMagic = void 0;
|
|
1836
|
+
return [s, unescape(this.toString()), false, false];
|
|
1837
|
+
}
|
|
1838
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
1839
|
+
if (bodyDotAllowed === body) {
|
|
1840
|
+
bodyDotAllowed = "";
|
|
1841
|
+
}
|
|
1842
|
+
if (bodyDotAllowed) {
|
|
1843
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
1844
|
+
}
|
|
1845
|
+
let final = "";
|
|
1846
|
+
if (this.type === "!" && this.#emptyExt) {
|
|
1847
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
1848
|
+
} else {
|
|
1849
|
+
const close = this.type === "!" ? (
|
|
1850
|
+
// !() must match something,but !(x) can match ''
|
|
1851
|
+
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
|
|
1852
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
1853
|
+
final = start + body + close;
|
|
1854
|
+
}
|
|
1855
|
+
return [
|
|
1856
|
+
final,
|
|
1857
|
+
unescape(body),
|
|
1858
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
1859
|
+
this.#uflag
|
|
1860
|
+
];
|
|
1861
|
+
}
|
|
1862
|
+
#partsToRegExp(dot) {
|
|
1863
|
+
return this.#parts.map((p) => {
|
|
1864
|
+
if (typeof p === "string") {
|
|
1865
|
+
throw new Error("string type in extglob ast??");
|
|
1866
|
+
}
|
|
1867
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
1868
|
+
this.#uflag = this.#uflag || uflag;
|
|
1869
|
+
return re;
|
|
1870
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
1871
|
+
}
|
|
1872
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
1873
|
+
let escaping = false;
|
|
1874
|
+
let re = "";
|
|
1875
|
+
let uflag = false;
|
|
1876
|
+
for (let i = 0; i < glob.length; i++) {
|
|
1877
|
+
const c = glob.charAt(i);
|
|
1878
|
+
if (escaping) {
|
|
1879
|
+
escaping = false;
|
|
1880
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
1881
|
+
continue;
|
|
1882
|
+
}
|
|
1883
|
+
if (c === "\\") {
|
|
1884
|
+
if (i === glob.length - 1) {
|
|
1885
|
+
re += "\\\\";
|
|
1886
|
+
} else {
|
|
1887
|
+
escaping = true;
|
|
1888
|
+
}
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
if (c === "[") {
|
|
1892
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
1893
|
+
if (consumed) {
|
|
1894
|
+
re += src;
|
|
1895
|
+
uflag = uflag || needUflag;
|
|
1896
|
+
i += consumed - 1;
|
|
1897
|
+
hasMagic = hasMagic || magic;
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
if (c === "*") {
|
|
1902
|
+
if (noEmpty && glob === "*")
|
|
1903
|
+
re += starNoEmpty;
|
|
1904
|
+
else
|
|
1905
|
+
re += star;
|
|
1906
|
+
hasMagic = true;
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
if (c === "?") {
|
|
1910
|
+
re += qmark;
|
|
1911
|
+
hasMagic = true;
|
|
1912
|
+
continue;
|
|
1913
|
+
}
|
|
1914
|
+
re += regExpEscape(c);
|
|
1915
|
+
}
|
|
1916
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// ../../node_modules/minimatch/dist/esm/escape.js
|
|
1921
|
+
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
1922
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
// ../../node_modules/minimatch/dist/esm/index.js
|
|
1926
|
+
var minimatch = (p, pattern, options = {}) => {
|
|
1927
|
+
assertValidPattern(pattern);
|
|
1928
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1929
|
+
return false;
|
|
1930
|
+
}
|
|
1931
|
+
return new Minimatch(pattern, options).match(p);
|
|
1932
|
+
};
|
|
1933
|
+
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
1934
|
+
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
1935
|
+
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
1936
|
+
var starDotExtTestNocase = (ext2) => {
|
|
1937
|
+
ext2 = ext2.toLowerCase();
|
|
1938
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
1939
|
+
};
|
|
1940
|
+
var starDotExtTestNocaseDot = (ext2) => {
|
|
1941
|
+
ext2 = ext2.toLowerCase();
|
|
1942
|
+
return (f) => f.toLowerCase().endsWith(ext2);
|
|
1943
|
+
};
|
|
1944
|
+
var starDotStarRE = /^\*+\.\*+$/;
|
|
1945
|
+
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
1946
|
+
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
1947
|
+
var dotStarRE = /^\.\*+$/;
|
|
1948
|
+
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
1949
|
+
var starRE = /^\*+$/;
|
|
1950
|
+
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
1951
|
+
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
1952
|
+
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
1953
|
+
var qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
1954
|
+
const noext = qmarksTestNoExt([$0]);
|
|
1955
|
+
if (!ext2)
|
|
1956
|
+
return noext;
|
|
1957
|
+
ext2 = ext2.toLowerCase();
|
|
1958
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1959
|
+
};
|
|
1960
|
+
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
1961
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
1962
|
+
if (!ext2)
|
|
1963
|
+
return noext;
|
|
1964
|
+
ext2 = ext2.toLowerCase();
|
|
1965
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1966
|
+
};
|
|
1967
|
+
var qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
1968
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
1969
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1970
|
+
};
|
|
1971
|
+
var qmarksTest = ([$0, ext2 = ""]) => {
|
|
1972
|
+
const noext = qmarksTestNoExt([$0]);
|
|
1973
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1974
|
+
};
|
|
1975
|
+
var qmarksTestNoExt = ([$0]) => {
|
|
1976
|
+
const len = $0.length;
|
|
1977
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
1978
|
+
};
|
|
1979
|
+
var qmarksTestNoExtDot = ([$0]) => {
|
|
1980
|
+
const len = $0.length;
|
|
1981
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1982
|
+
};
|
|
1983
|
+
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1984
|
+
var path = {
|
|
1985
|
+
win32: { sep: "\\" },
|
|
1986
|
+
posix: { sep: "/" }
|
|
1987
|
+
};
|
|
1988
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
1989
|
+
minimatch.sep = sep;
|
|
1990
|
+
var GLOBSTAR = Symbol("globstar **");
|
|
1991
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
1992
|
+
var qmark2 = "[^/]";
|
|
1993
|
+
var star2 = qmark2 + "*?";
|
|
1994
|
+
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
1995
|
+
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
1996
|
+
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
1997
|
+
minimatch.filter = filter;
|
|
1998
|
+
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
1999
|
+
var defaults = (def) => {
|
|
2000
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
2001
|
+
return minimatch;
|
|
2002
|
+
}
|
|
2003
|
+
const orig = minimatch;
|
|
2004
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
2005
|
+
return Object.assign(m, {
|
|
2006
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
2007
|
+
constructor(pattern, options = {}) {
|
|
2008
|
+
super(pattern, ext(def, options));
|
|
2009
|
+
}
|
|
2010
|
+
static defaults(options) {
|
|
2011
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
2012
|
+
}
|
|
2013
|
+
},
|
|
2014
|
+
AST: class AST extends orig.AST {
|
|
2015
|
+
/* c8 ignore start */
|
|
2016
|
+
constructor(type, parent, options = {}) {
|
|
2017
|
+
super(type, parent, ext(def, options));
|
|
2018
|
+
}
|
|
2019
|
+
/* c8 ignore stop */
|
|
2020
|
+
static fromGlob(pattern, options = {}) {
|
|
2021
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
2025
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
2026
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
2027
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
2028
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
2029
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
2030
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
2031
|
+
sep: orig.sep,
|
|
2032
|
+
GLOBSTAR
|
|
2033
|
+
});
|
|
2034
|
+
};
|
|
2035
|
+
minimatch.defaults = defaults;
|
|
2036
|
+
var braceExpand = (pattern, options = {}) => {
|
|
2037
|
+
assertValidPattern(pattern);
|
|
2038
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
2039
|
+
return [pattern];
|
|
2040
|
+
}
|
|
2041
|
+
return (0, import_brace_expansion.default)(pattern);
|
|
2042
|
+
};
|
|
2043
|
+
minimatch.braceExpand = braceExpand;
|
|
2044
|
+
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
2045
|
+
minimatch.makeRe = makeRe;
|
|
2046
|
+
var match = (list, pattern, options = {}) => {
|
|
2047
|
+
const mm = new Minimatch(pattern, options);
|
|
2048
|
+
list = list.filter((f) => mm.match(f));
|
|
2049
|
+
if (mm.options.nonull && !list.length) {
|
|
2050
|
+
list.push(pattern);
|
|
2051
|
+
}
|
|
2052
|
+
return list;
|
|
2053
|
+
};
|
|
2054
|
+
minimatch.match = match;
|
|
2055
|
+
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2056
|
+
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2057
|
+
var Minimatch = class {
|
|
2058
|
+
options;
|
|
2059
|
+
set;
|
|
2060
|
+
pattern;
|
|
2061
|
+
windowsPathsNoEscape;
|
|
2062
|
+
nonegate;
|
|
2063
|
+
negate;
|
|
2064
|
+
comment;
|
|
2065
|
+
empty;
|
|
2066
|
+
preserveMultipleSlashes;
|
|
2067
|
+
partial;
|
|
2068
|
+
globSet;
|
|
2069
|
+
globParts;
|
|
2070
|
+
nocase;
|
|
2071
|
+
isWindows;
|
|
2072
|
+
platform;
|
|
2073
|
+
windowsNoMagicRoot;
|
|
2074
|
+
regexp;
|
|
2075
|
+
constructor(pattern, options = {}) {
|
|
2076
|
+
assertValidPattern(pattern);
|
|
2077
|
+
options = options || {};
|
|
2078
|
+
this.options = options;
|
|
2079
|
+
this.pattern = pattern;
|
|
2080
|
+
this.platform = options.platform || defaultPlatform;
|
|
2081
|
+
this.isWindows = this.platform === "win32";
|
|
2082
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
2083
|
+
if (this.windowsPathsNoEscape) {
|
|
2084
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
2085
|
+
}
|
|
2086
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
2087
|
+
this.regexp = null;
|
|
2088
|
+
this.negate = false;
|
|
2089
|
+
this.nonegate = !!options.nonegate;
|
|
2090
|
+
this.comment = false;
|
|
2091
|
+
this.empty = false;
|
|
2092
|
+
this.partial = !!options.partial;
|
|
2093
|
+
this.nocase = !!this.options.nocase;
|
|
2094
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
2095
|
+
this.globSet = [];
|
|
2096
|
+
this.globParts = [];
|
|
2097
|
+
this.set = [];
|
|
2098
|
+
this.make();
|
|
2099
|
+
}
|
|
2100
|
+
hasMagic() {
|
|
2101
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
2102
|
+
return true;
|
|
2103
|
+
}
|
|
2104
|
+
for (const pattern of this.set) {
|
|
2105
|
+
for (const part of pattern) {
|
|
2106
|
+
if (typeof part !== "string")
|
|
2107
|
+
return true;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
debug(..._) {
|
|
2113
|
+
}
|
|
2114
|
+
make() {
|
|
2115
|
+
const pattern = this.pattern;
|
|
2116
|
+
const options = this.options;
|
|
2117
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
2118
|
+
this.comment = true;
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
if (!pattern) {
|
|
2122
|
+
this.empty = true;
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
this.parseNegate();
|
|
2126
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
2127
|
+
if (options.debug) {
|
|
2128
|
+
this.debug = (...args) => console.error(...args);
|
|
2129
|
+
}
|
|
2130
|
+
this.debug(this.pattern, this.globSet);
|
|
2131
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
2132
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
2133
|
+
this.debug(this.pattern, this.globParts);
|
|
2134
|
+
let set = this.globParts.map((s, _, __) => {
|
|
2135
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2136
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
2137
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
2138
|
+
if (isUNC) {
|
|
2139
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
2140
|
+
} else if (isDrive) {
|
|
2141
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
return s.map((ss) => this.parse(ss));
|
|
2145
|
+
});
|
|
2146
|
+
this.debug(this.pattern, set);
|
|
2147
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
2148
|
+
if (this.isWindows) {
|
|
2149
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
2150
|
+
const p = this.set[i];
|
|
2151
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
2152
|
+
p[2] = "?";
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
this.debug(this.pattern, this.set);
|
|
2157
|
+
}
|
|
2158
|
+
// various transforms to equivalent pattern sets that are
|
|
2159
|
+
// faster to process in a filesystem walk. The goal is to
|
|
2160
|
+
// eliminate what we can, and push all ** patterns as far
|
|
2161
|
+
// to the right as possible, even if it increases the number
|
|
2162
|
+
// of patterns that we have to process.
|
|
2163
|
+
preprocess(globParts) {
|
|
2164
|
+
if (this.options.noglobstar) {
|
|
2165
|
+
for (let i = 0; i < globParts.length; i++) {
|
|
2166
|
+
for (let j = 0; j < globParts[i].length; j++) {
|
|
2167
|
+
if (globParts[i][j] === "**") {
|
|
2168
|
+
globParts[i][j] = "*";
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
const { optimizationLevel = 1 } = this.options;
|
|
2174
|
+
if (optimizationLevel >= 2) {
|
|
2175
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
2176
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
2177
|
+
} else if (optimizationLevel >= 1) {
|
|
2178
|
+
globParts = this.levelOneOptimize(globParts);
|
|
2179
|
+
} else {
|
|
2180
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
2181
|
+
}
|
|
2182
|
+
return globParts;
|
|
2183
|
+
}
|
|
2184
|
+
// just get rid of adjascent ** portions
|
|
2185
|
+
adjascentGlobstarOptimize(globParts) {
|
|
2186
|
+
return globParts.map((parts) => {
|
|
2187
|
+
let gs = -1;
|
|
2188
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
2189
|
+
let i = gs;
|
|
2190
|
+
while (parts[i + 1] === "**") {
|
|
2191
|
+
i++;
|
|
2192
|
+
}
|
|
2193
|
+
if (i !== gs) {
|
|
2194
|
+
parts.splice(gs, i - gs);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
return parts;
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
// get rid of adjascent ** and resolve .. portions
|
|
2201
|
+
levelOneOptimize(globParts) {
|
|
2202
|
+
return globParts.map((parts) => {
|
|
2203
|
+
parts = parts.reduce((set, part) => {
|
|
2204
|
+
const prev = set[set.length - 1];
|
|
2205
|
+
if (part === "**" && prev === "**") {
|
|
2206
|
+
return set;
|
|
2207
|
+
}
|
|
2208
|
+
if (part === "..") {
|
|
2209
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2210
|
+
set.pop();
|
|
2211
|
+
return set;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
set.push(part);
|
|
2215
|
+
return set;
|
|
2216
|
+
}, []);
|
|
2217
|
+
return parts.length === 0 ? [""] : parts;
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
levelTwoFileOptimize(parts) {
|
|
2221
|
+
if (!Array.isArray(parts)) {
|
|
2222
|
+
parts = this.slashSplit(parts);
|
|
2223
|
+
}
|
|
2224
|
+
let didSomething = false;
|
|
2225
|
+
do {
|
|
2226
|
+
didSomething = false;
|
|
2227
|
+
if (!this.preserveMultipleSlashes) {
|
|
2228
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
2229
|
+
const p = parts[i];
|
|
2230
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
2231
|
+
continue;
|
|
2232
|
+
if (p === "." || p === "") {
|
|
2233
|
+
didSomething = true;
|
|
2234
|
+
parts.splice(i, 1);
|
|
2235
|
+
i--;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
2239
|
+
didSomething = true;
|
|
2240
|
+
parts.pop();
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
let dd = 0;
|
|
2244
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2245
|
+
const p = parts[dd - 1];
|
|
2246
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
2247
|
+
didSomething = true;
|
|
2248
|
+
parts.splice(dd - 1, 2);
|
|
2249
|
+
dd -= 2;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
} while (didSomething);
|
|
2253
|
+
return parts.length === 0 ? [""] : parts;
|
|
2254
|
+
}
|
|
2255
|
+
// First phase: single-pattern processing
|
|
2256
|
+
// <pre> is 1 or more portions
|
|
2257
|
+
// <rest> is 1 or more portions
|
|
2258
|
+
// <p> is any portion other than ., .., '', or **
|
|
2259
|
+
// <e> is . or ''
|
|
2260
|
+
//
|
|
2261
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
2262
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
2263
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
2264
|
+
// or most strings (other than .., ., and '') can be.
|
|
2265
|
+
//
|
|
2266
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
2267
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
2268
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
2269
|
+
// **/**/<rest> -> **/<rest>
|
|
2270
|
+
//
|
|
2271
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
2272
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
2273
|
+
firstPhasePreProcess(globParts) {
|
|
2274
|
+
let didSomething = false;
|
|
2275
|
+
do {
|
|
2276
|
+
didSomething = false;
|
|
2277
|
+
for (let parts of globParts) {
|
|
2278
|
+
let gs = -1;
|
|
2279
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
2280
|
+
let gss = gs;
|
|
2281
|
+
while (parts[gss + 1] === "**") {
|
|
2282
|
+
gss++;
|
|
2283
|
+
}
|
|
2284
|
+
if (gss > gs) {
|
|
2285
|
+
parts.splice(gs + 1, gss - gs);
|
|
2286
|
+
}
|
|
2287
|
+
let next = parts[gs + 1];
|
|
2288
|
+
const p = parts[gs + 2];
|
|
2289
|
+
const p2 = parts[gs + 3];
|
|
2290
|
+
if (next !== "..")
|
|
2291
|
+
continue;
|
|
2292
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
didSomething = true;
|
|
2296
|
+
parts.splice(gs, 1);
|
|
2297
|
+
const other = parts.slice(0);
|
|
2298
|
+
other[gs] = "**";
|
|
2299
|
+
globParts.push(other);
|
|
2300
|
+
gs--;
|
|
2301
|
+
}
|
|
2302
|
+
if (!this.preserveMultipleSlashes) {
|
|
2303
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
2304
|
+
const p = parts[i];
|
|
2305
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
2306
|
+
continue;
|
|
2307
|
+
if (p === "." || p === "") {
|
|
2308
|
+
didSomething = true;
|
|
2309
|
+
parts.splice(i, 1);
|
|
2310
|
+
i--;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
2314
|
+
didSomething = true;
|
|
2315
|
+
parts.pop();
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
let dd = 0;
|
|
2319
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2320
|
+
const p = parts[dd - 1];
|
|
2321
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
2322
|
+
didSomething = true;
|
|
2323
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
2324
|
+
const splin = needDot ? ["."] : [];
|
|
2325
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
2326
|
+
if (parts.length === 0)
|
|
2327
|
+
parts.push("");
|
|
2328
|
+
dd -= 2;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
} while (didSomething);
|
|
2333
|
+
return globParts;
|
|
2334
|
+
}
|
|
2335
|
+
// second phase: multi-pattern dedupes
|
|
2336
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
2337
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
2338
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
2339
|
+
//
|
|
2340
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
2341
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
2342
|
+
secondPhasePreProcess(globParts) {
|
|
2343
|
+
for (let i = 0; i < globParts.length - 1; i++) {
|
|
2344
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
2345
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
2346
|
+
if (matched) {
|
|
2347
|
+
globParts[i] = [];
|
|
2348
|
+
globParts[j] = matched;
|
|
2349
|
+
break;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
return globParts.filter((gs) => gs.length);
|
|
2354
|
+
}
|
|
2355
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
2356
|
+
let ai = 0;
|
|
2357
|
+
let bi = 0;
|
|
2358
|
+
let result = [];
|
|
2359
|
+
let which = "";
|
|
2360
|
+
while (ai < a.length && bi < b.length) {
|
|
2361
|
+
if (a[ai] === b[bi]) {
|
|
2362
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
2363
|
+
ai++;
|
|
2364
|
+
bi++;
|
|
2365
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
2366
|
+
result.push(a[ai]);
|
|
2367
|
+
ai++;
|
|
2368
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
2369
|
+
result.push(b[bi]);
|
|
2370
|
+
bi++;
|
|
2371
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
2372
|
+
if (which === "b")
|
|
2373
|
+
return false;
|
|
2374
|
+
which = "a";
|
|
2375
|
+
result.push(a[ai]);
|
|
2376
|
+
ai++;
|
|
2377
|
+
bi++;
|
|
2378
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
2379
|
+
if (which === "a")
|
|
2380
|
+
return false;
|
|
2381
|
+
which = "b";
|
|
2382
|
+
result.push(b[bi]);
|
|
2383
|
+
ai++;
|
|
2384
|
+
bi++;
|
|
2385
|
+
} else {
|
|
2386
|
+
return false;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
return a.length === b.length && result;
|
|
2390
|
+
}
|
|
2391
|
+
parseNegate() {
|
|
2392
|
+
if (this.nonegate)
|
|
2393
|
+
return;
|
|
2394
|
+
const pattern = this.pattern;
|
|
2395
|
+
let negate = false;
|
|
2396
|
+
let negateOffset = 0;
|
|
2397
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
2398
|
+
negate = !negate;
|
|
2399
|
+
negateOffset++;
|
|
2400
|
+
}
|
|
2401
|
+
if (negateOffset)
|
|
2402
|
+
this.pattern = pattern.slice(negateOffset);
|
|
2403
|
+
this.negate = negate;
|
|
2404
|
+
}
|
|
2405
|
+
// set partial to true to test if, for example,
|
|
2406
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
2407
|
+
// Partial means, if you run out of file before you run
|
|
2408
|
+
// out of pattern, then that's fine, as long as all
|
|
2409
|
+
// the parts match.
|
|
2410
|
+
matchOne(file, pattern, partial = false) {
|
|
2411
|
+
const options = this.options;
|
|
2412
|
+
if (this.isWindows) {
|
|
2413
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
2414
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
2415
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
2416
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
2417
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
2418
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
2419
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
2420
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
2421
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
2422
|
+
pattern[pdi] = fd;
|
|
2423
|
+
if (pdi > fdi) {
|
|
2424
|
+
pattern = pattern.slice(pdi);
|
|
2425
|
+
} else if (fdi > pdi) {
|
|
2426
|
+
file = file.slice(fdi);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
const { optimizationLevel = 1 } = this.options;
|
|
2432
|
+
if (optimizationLevel >= 2) {
|
|
2433
|
+
file = this.levelTwoFileOptimize(file);
|
|
2434
|
+
}
|
|
2435
|
+
this.debug("matchOne", this, { file, pattern });
|
|
2436
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
2437
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2438
|
+
this.debug("matchOne loop");
|
|
2439
|
+
var p = pattern[pi];
|
|
2440
|
+
var f = file[fi];
|
|
2441
|
+
this.debug(pattern, p, f);
|
|
2442
|
+
if (p === false) {
|
|
2443
|
+
return false;
|
|
2444
|
+
}
|
|
2445
|
+
if (p === GLOBSTAR) {
|
|
2446
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
2447
|
+
var fr = fi;
|
|
2448
|
+
var pr = pi + 1;
|
|
2449
|
+
if (pr === pl) {
|
|
2450
|
+
this.debug("** at the end");
|
|
2451
|
+
for (; fi < fl; fi++) {
|
|
2452
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
2453
|
+
return false;
|
|
2454
|
+
}
|
|
2455
|
+
return true;
|
|
2456
|
+
}
|
|
2457
|
+
while (fr < fl) {
|
|
2458
|
+
var swallowee = file[fr];
|
|
2459
|
+
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
2460
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
2461
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
2462
|
+
return true;
|
|
2463
|
+
} else {
|
|
2464
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
2465
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
2466
|
+
break;
|
|
2467
|
+
}
|
|
2468
|
+
this.debug("globstar swallow a segment, and continue");
|
|
2469
|
+
fr++;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
if (partial) {
|
|
2473
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
2474
|
+
if (fr === fl) {
|
|
2475
|
+
return true;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return false;
|
|
2479
|
+
}
|
|
2480
|
+
let hit;
|
|
2481
|
+
if (typeof p === "string") {
|
|
2482
|
+
hit = f === p;
|
|
2483
|
+
this.debug("string match", p, f, hit);
|
|
2484
|
+
} else {
|
|
2485
|
+
hit = p.test(f);
|
|
2486
|
+
this.debug("pattern match", p, f, hit);
|
|
2487
|
+
}
|
|
2488
|
+
if (!hit)
|
|
2489
|
+
return false;
|
|
2490
|
+
}
|
|
2491
|
+
if (fi === fl && pi === pl) {
|
|
2492
|
+
return true;
|
|
2493
|
+
} else if (fi === fl) {
|
|
2494
|
+
return partial;
|
|
2495
|
+
} else if (pi === pl) {
|
|
2496
|
+
return fi === fl - 1 && file[fi] === "";
|
|
2497
|
+
} else {
|
|
2498
|
+
throw new Error("wtf?");
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
braceExpand() {
|
|
2502
|
+
return braceExpand(this.pattern, this.options);
|
|
2503
|
+
}
|
|
2504
|
+
parse(pattern) {
|
|
2505
|
+
assertValidPattern(pattern);
|
|
2506
|
+
const options = this.options;
|
|
2507
|
+
if (pattern === "**")
|
|
2508
|
+
return GLOBSTAR;
|
|
2509
|
+
if (pattern === "")
|
|
2510
|
+
return "";
|
|
2511
|
+
let m;
|
|
2512
|
+
let fastTest = null;
|
|
2513
|
+
if (m = pattern.match(starRE)) {
|
|
2514
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
2515
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
2516
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
2517
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
2518
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
2519
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
2520
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
2521
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
2522
|
+
fastTest = dotStarTest;
|
|
2523
|
+
}
|
|
2524
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
2525
|
+
if (fastTest && typeof re === "object") {
|
|
2526
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
2527
|
+
}
|
|
2528
|
+
return re;
|
|
2529
|
+
}
|
|
2530
|
+
makeRe() {
|
|
2531
|
+
if (this.regexp || this.regexp === false)
|
|
2532
|
+
return this.regexp;
|
|
2533
|
+
const set = this.set;
|
|
2534
|
+
if (!set.length) {
|
|
2535
|
+
this.regexp = false;
|
|
2536
|
+
return this.regexp;
|
|
2537
|
+
}
|
|
2538
|
+
const options = this.options;
|
|
2539
|
+
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
2540
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
2541
|
+
let re = set.map((pattern) => {
|
|
2542
|
+
const pp = pattern.map((p) => {
|
|
2543
|
+
if (p instanceof RegExp) {
|
|
2544
|
+
for (const f of p.flags.split(""))
|
|
2545
|
+
flags.add(f);
|
|
2546
|
+
}
|
|
2547
|
+
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
2548
|
+
});
|
|
2549
|
+
pp.forEach((p, i) => {
|
|
2550
|
+
const next = pp[i + 1];
|
|
2551
|
+
const prev = pp[i - 1];
|
|
2552
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
2553
|
+
return;
|
|
2554
|
+
}
|
|
2555
|
+
if (prev === void 0) {
|
|
2556
|
+
if (next !== void 0 && next !== GLOBSTAR) {
|
|
2557
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
2558
|
+
} else {
|
|
2559
|
+
pp[i] = twoStar;
|
|
2560
|
+
}
|
|
2561
|
+
} else if (next === void 0) {
|
|
2562
|
+
pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
2563
|
+
} else if (next !== GLOBSTAR) {
|
|
2564
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
2565
|
+
pp[i + 1] = GLOBSTAR;
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
return pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
2569
|
+
}).join("|");
|
|
2570
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
2571
|
+
re = "^" + open + re + close + "$";
|
|
2572
|
+
if (this.negate)
|
|
2573
|
+
re = "^(?!" + re + ").+$";
|
|
2574
|
+
try {
|
|
2575
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
2576
|
+
} catch (ex) {
|
|
2577
|
+
this.regexp = false;
|
|
2578
|
+
}
|
|
2579
|
+
return this.regexp;
|
|
2580
|
+
}
|
|
2581
|
+
slashSplit(p) {
|
|
2582
|
+
if (this.preserveMultipleSlashes) {
|
|
2583
|
+
return p.split("/");
|
|
2584
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
2585
|
+
return ["", ...p.split(/\/+/)];
|
|
2586
|
+
} else {
|
|
2587
|
+
return p.split(/\/+/);
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
match(f, partial = this.partial) {
|
|
2591
|
+
this.debug("match", f, this.pattern);
|
|
2592
|
+
if (this.comment) {
|
|
2593
|
+
return false;
|
|
2594
|
+
}
|
|
2595
|
+
if (this.empty) {
|
|
2596
|
+
return f === "";
|
|
2597
|
+
}
|
|
2598
|
+
if (f === "/" && partial) {
|
|
2599
|
+
return true;
|
|
2600
|
+
}
|
|
2601
|
+
const options = this.options;
|
|
2602
|
+
if (this.isWindows) {
|
|
2603
|
+
f = f.split("\\").join("/");
|
|
2604
|
+
}
|
|
2605
|
+
const ff = this.slashSplit(f);
|
|
2606
|
+
this.debug(this.pattern, "split", ff);
|
|
2607
|
+
const set = this.set;
|
|
2608
|
+
this.debug(this.pattern, "set", set);
|
|
2609
|
+
let filename = ff[ff.length - 1];
|
|
2610
|
+
if (!filename) {
|
|
2611
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
2612
|
+
filename = ff[i];
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
for (let i = 0; i < set.length; i++) {
|
|
2616
|
+
const pattern = set[i];
|
|
2617
|
+
let file = ff;
|
|
2618
|
+
if (options.matchBase && pattern.length === 1) {
|
|
2619
|
+
file = [filename];
|
|
2620
|
+
}
|
|
2621
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
2622
|
+
if (hit) {
|
|
2623
|
+
if (options.flipNegate) {
|
|
2624
|
+
return true;
|
|
2625
|
+
}
|
|
2626
|
+
return !this.negate;
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
if (options.flipNegate) {
|
|
2630
|
+
return false;
|
|
2631
|
+
}
|
|
2632
|
+
return this.negate;
|
|
2633
|
+
}
|
|
2634
|
+
static defaults(def) {
|
|
2635
|
+
return minimatch.defaults(def).Minimatch;
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
minimatch.AST = AST;
|
|
2639
|
+
minimatch.Minimatch = Minimatch;
|
|
2640
|
+
minimatch.escape = escape;
|
|
2641
|
+
minimatch.unescape = unescape;
|
|
2642
|
+
|
|
2643
|
+
// src/worker-entry.ts
|
|
2644
|
+
import { relative } from "node:path";
|
|
2645
|
+
var exportedHandler = {
|
|
2646
|
+
async fetch(request, env, context) {
|
|
2647
|
+
if (typeof env.__CLI_TEST_OVERRIDES === "string") {
|
|
2648
|
+
Object.assign(process2.env, {
|
|
2649
|
+
[TEST_OVERRIDES_ENV_VAR]: env.__CLI_TEST_OVERRIDES
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
try {
|
|
2653
|
+
const module = await fetchEntryModule(env);
|
|
2654
|
+
return await module.default.fetch(request, env, context);
|
|
2655
|
+
} catch (error) {
|
|
2656
|
+
console.error(error);
|
|
2657
|
+
throw error;
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
var worker_entry_default = exportedHandler;
|
|
2662
|
+
var runtime;
|
|
2663
|
+
function fetchEntryModule(env) {
|
|
2664
|
+
if (!runtime) {
|
|
2665
|
+
let isHmrReady = false;
|
|
2666
|
+
let onHmrReceive;
|
|
2667
|
+
connectHmrWsClient(env).then((socket) => {
|
|
2668
|
+
isHmrReady = true;
|
|
2669
|
+
socket.addEventListener("message", async (message) => {
|
|
2670
|
+
if (!message.data) {
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
const data = JSON.parse(
|
|
2674
|
+
message.data.toString()
|
|
2675
|
+
);
|
|
2676
|
+
if (data?.type === "update" && runtime) {
|
|
2677
|
+
const needsInvalidate = data.updates.flatMap((update) => update.ssrInvalidates ?? []).map((filepath) => relative(env.__VITE_ROOT, filepath)).some((filepath) => {
|
|
2678
|
+
return env.__INVALIDATE_GLOB_PATTERNS.some(
|
|
2679
|
+
(pattern) => minimatch(filepath, pattern)
|
|
2680
|
+
);
|
|
2681
|
+
});
|
|
2682
|
+
if (needsInvalidate) {
|
|
2683
|
+
const entriesToInvalidate = [
|
|
2684
|
+
...runtime.moduleCache.keys()
|
|
2685
|
+
].filter((filepath) => {
|
|
2686
|
+
return env.__INVALIDATE_GLOB_PATTERNS.some(
|
|
2687
|
+
(pattern) => minimatch(filepath.replace(/^\//, ""), pattern)
|
|
2688
|
+
);
|
|
2689
|
+
});
|
|
2690
|
+
runtime.moduleCache.invalidateSubDepTree(entriesToInvalidate);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (data) {
|
|
2694
|
+
await onHmrReceive?.(data);
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2697
|
+
}).catch((error) => console.error(error));
|
|
2698
|
+
runtime = new ViteRuntime(
|
|
2699
|
+
{
|
|
2700
|
+
root: env.__VITE_ROOT,
|
|
2701
|
+
sourcemapInterceptor: "prepareStackTrace",
|
|
2702
|
+
fetchModule: async (id, importer) => {
|
|
2703
|
+
const url = new URL(
|
|
2704
|
+
env.__VITE_FETCH_MODULE_PATHNAME,
|
|
2705
|
+
env.__VITE_DEV_SERVER_URL
|
|
2706
|
+
);
|
|
2707
|
+
url.searchParams.set("id", id);
|
|
2708
|
+
if (importer) {
|
|
2709
|
+
url.searchParams.set("importer", importer);
|
|
2710
|
+
}
|
|
2711
|
+
const response = await fetch(url);
|
|
2712
|
+
if (!response.ok) {
|
|
2713
|
+
throw new Error(await response.text());
|
|
2714
|
+
}
|
|
2715
|
+
return response.json();
|
|
2716
|
+
},
|
|
2717
|
+
hmr: {
|
|
2718
|
+
connection: {
|
|
2719
|
+
isReady: () => isHmrReady,
|
|
2720
|
+
send: () => {
|
|
2721
|
+
},
|
|
2722
|
+
onUpdate(receiver) {
|
|
2723
|
+
onHmrReceive = receiver;
|
|
2724
|
+
return () => {
|
|
2725
|
+
onHmrReceive = void 0;
|
|
2726
|
+
};
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
},
|
|
2731
|
+
{
|
|
2732
|
+
runExternalModule(file) {
|
|
2733
|
+
if (env.__VITE_NODE_BUILTINS.includes(file)) {
|
|
2734
|
+
return import(file);
|
|
2735
|
+
}
|
|
2736
|
+
throw new Error(`External module not supported: "${file}"`);
|
|
2737
|
+
},
|
|
2738
|
+
async runViteModule(context, code, id) {
|
|
2739
|
+
const initModule = env.__VITE_UNSAFE_EVAL.eval(
|
|
2740
|
+
`'use strict';async (${Object.keys(context).join(
|
|
2741
|
+
","
|
|
2742
|
+
)})=>{{${code}
|
|
2743
|
+
}}`,
|
|
2744
|
+
id
|
|
2745
|
+
);
|
|
2746
|
+
await initModule(...Object.values(context));
|
|
2747
|
+
Object.freeze(context[ssrModuleExportsKey]);
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
return runtime.executeEntrypoint(env.__VITE_RUNTIME_EXECUTE_URL);
|
|
2753
|
+
}
|
|
2754
|
+
async function connectHmrWsClient(env) {
|
|
2755
|
+
const hmrUrl = env.__VITE_DEV_SERVER_URL;
|
|
2756
|
+
const { webSocket } = await fetch(hmrUrl, {
|
|
2757
|
+
headers: { Upgrade: "websocket", "sec-websocket-protocol": "vite-hmr" }
|
|
2758
|
+
});
|
|
2759
|
+
if (!webSocket) {
|
|
2760
|
+
throw new Error(`Failed to connect to HMR server`);
|
|
2761
|
+
}
|
|
2762
|
+
webSocket.accept();
|
|
2763
|
+
return webSocket;
|
|
2764
|
+
}
|
|
2765
|
+
export {
|
|
2766
|
+
worker_entry_default as default
|
|
2767
|
+
};
|