opfs-worker 1.2.4 → 1.3.0
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/dist/assets/worker-1Wh1cr7P.js.map +1 -0
- package/dist/helpers-BuGfPAg0.js +1439 -0
- package/dist/helpers-BuGfPAg0.js.map +1 -0
- package/dist/helpers-CF7A2WQG.cjs +4 -0
- package/dist/helpers-CF7A2WQG.cjs.map +1 -0
- package/dist/index.cjs +715 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +774 -650
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +88 -89
- package/dist/raw.js.map +1 -1
- package/dist/utils/errors.d.ts +74 -19
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-BEh95XuP.js.map +0 -1
- package/dist/assets/worker-CS9nvwsF.js.map +0 -1
- package/dist/assets/worker-Dy3EFYv_.js.map +0 -1
- package/dist/helpers-04x7UBul.cjs +0 -4
- package/dist/helpers-04x7UBul.cjs.map +0 -1
- package/dist/helpers-BXhw_-Ar.js +0 -1330
- package/dist/helpers-BXhw_-Ar.js.map +0 -1
- package/dist/helpers-BwklIUit.js +0 -1329
- package/dist/helpers-BwklIUit.js.map +0 -1
- package/dist/helpers-ppMRzIAJ.cjs +0 -4
- package/dist/helpers-ppMRzIAJ.cjs.map +0 -1
|
@@ -0,0 +1,1439 @@
|
|
|
1
|
+
const le = {
|
|
2
|
+
ENOENT: -2,
|
|
3
|
+
// No such file or directory
|
|
4
|
+
EISDIR: -21,
|
|
5
|
+
// Is a directory
|
|
6
|
+
ENOTDIR: -20,
|
|
7
|
+
// Not a directory
|
|
8
|
+
EACCES: -13,
|
|
9
|
+
// Permission denied
|
|
10
|
+
EEXIST: -17,
|
|
11
|
+
// File exists
|
|
12
|
+
ENOTEMPTY: -39,
|
|
13
|
+
// Directory not empty
|
|
14
|
+
EINVAL: -22,
|
|
15
|
+
// Invalid argument
|
|
16
|
+
EIO: -5,
|
|
17
|
+
// I/O error
|
|
18
|
+
ENOSPC: -28,
|
|
19
|
+
// No space left on device
|
|
20
|
+
EBUSY: -16,
|
|
21
|
+
// Device or resource busy
|
|
22
|
+
EINTR: -4,
|
|
23
|
+
// Interrupted system call
|
|
24
|
+
ENOTSUP: -95,
|
|
25
|
+
// Operation not supported
|
|
26
|
+
ERANGE: -34,
|
|
27
|
+
// Result too large
|
|
28
|
+
EBADF: -9,
|
|
29
|
+
// Bad file descriptor
|
|
30
|
+
EROOT: -1
|
|
31
|
+
// Custom: Cannot remove root directory
|
|
32
|
+
};
|
|
33
|
+
class m extends Error {
|
|
34
|
+
errno;
|
|
35
|
+
syscall;
|
|
36
|
+
path;
|
|
37
|
+
constructor(e, t, n, r, i) {
|
|
38
|
+
super(e, { cause: i }), this.name = t, this.errno = le[t] || -1, this.path = n, this.syscall = r;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class he extends m {
|
|
42
|
+
constructor(e) {
|
|
43
|
+
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, void 0, e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class Tt extends m {
|
|
47
|
+
constructor(e, t, n) {
|
|
48
|
+
super(e, "INVALID_PATH", t, "access", n);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class Z extends m {
|
|
52
|
+
constructor(e, t, n) {
|
|
53
|
+
const r = {
|
|
54
|
+
file: `File not found: ${t}`,
|
|
55
|
+
directory: `Directory not found: ${t}`,
|
|
56
|
+
source: `Source does not exist: ${t}`
|
|
57
|
+
};
|
|
58
|
+
super(r[e], "ENOENT", t, "access", n);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class ue extends m {
|
|
62
|
+
constructor(e, t, n) {
|
|
63
|
+
super(`Permission denied for ${t} on: ${e}`, "PERMISSION_DENIED", e, t, n);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class fe extends m {
|
|
67
|
+
constructor(e, t, n) {
|
|
68
|
+
super(e, "ENOSPC", t, "write", n);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class Rt extends m {
|
|
72
|
+
constructor(e, t, n) {
|
|
73
|
+
super(`Operation timed out: ${e}`, "TIMEOUT_ERROR", t, e, n);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class pe extends m {
|
|
77
|
+
constructor(e, t) {
|
|
78
|
+
super(`File is busy: ${e}`, "EBUSY", e, "open", t);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class F extends m {
|
|
82
|
+
constructor(e, t, n, r) {
|
|
83
|
+
const i = t === "directory" ? `Is a directory: ${n}` : `Not a directory: ${n}`, o = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
84
|
+
super(i, o, n, "access", r);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class b extends m {
|
|
88
|
+
constructor(e, t, n, r) {
|
|
89
|
+
const i = {
|
|
90
|
+
argument: "EINVAL",
|
|
91
|
+
format: "INVALID_FORMAT",
|
|
92
|
+
descriptor: "EBADF",
|
|
93
|
+
overflow: "ERANGE"
|
|
94
|
+
};
|
|
95
|
+
super(t, i[e], n, "validate", r);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class de extends m {
|
|
99
|
+
constructor(e, t) {
|
|
100
|
+
super(`Operation aborted: ${e}`, "EINTR", e, "interrupt", t);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class W extends m {
|
|
104
|
+
constructor(e, t, n) {
|
|
105
|
+
super(e, "EIO", t, "io", n);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class ge extends m {
|
|
109
|
+
constructor(e, t) {
|
|
110
|
+
super(`Operation not supported: ${e}`, "ENOTSUP", e, "operation", t);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
class z extends m {
|
|
114
|
+
constructor(e, t, n) {
|
|
115
|
+
const r = {
|
|
116
|
+
remove: `Failed to remove entry: ${t}`,
|
|
117
|
+
clear: `Directory not empty: ${t}. Use recursive option to force removal.`,
|
|
118
|
+
root: "Cannot remove root directory"
|
|
119
|
+
}, i = {
|
|
120
|
+
remove: "RM_FAILED",
|
|
121
|
+
clear: "ENOTEMPTY",
|
|
122
|
+
root: "EROOT"
|
|
123
|
+
};
|
|
124
|
+
super(r[e], i[e], t, "unlink", n);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class Pt extends m {
|
|
128
|
+
constructor(e, t) {
|
|
129
|
+
super("Failed to initialize OPFS", "INIT_FAILED", e, "init", t);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
class It extends m {
|
|
133
|
+
constructor(e, t, n) {
|
|
134
|
+
super(`Failed to ${e}: ${t}`, `${e.toUpperCase()}_FAILED`, t, e, n);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
class Mt extends m {
|
|
138
|
+
constructor(e, t) {
|
|
139
|
+
super(`Failed to resolve path: ${e}`, "REALPATH_FAILED", e, "realpath", t);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class Ct extends m {
|
|
143
|
+
constructor(e, t) {
|
|
144
|
+
super(`Destination already exists: ${e}`, "EEXIST", e, "open", t);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function Dt(s, e, t, n) {
|
|
148
|
+
const r = `${s.toUpperCase()}_FAILED`;
|
|
149
|
+
return new m(`Failed to ${s} file descriptor: ${e}`, r, t, s, n);
|
|
150
|
+
}
|
|
151
|
+
function me(s, e) {
|
|
152
|
+
const t = e?.path, n = e?.isDirectory;
|
|
153
|
+
switch (s.name) {
|
|
154
|
+
case "InvalidStateError":
|
|
155
|
+
return new pe(t || "unknown", s);
|
|
156
|
+
case "QuotaExceededError":
|
|
157
|
+
return new fe(`No space left on device: ${t || "unknown"}`, t, s);
|
|
158
|
+
case "NotFoundError":
|
|
159
|
+
return new Z("file", t, s);
|
|
160
|
+
case "TypeMismatchError":
|
|
161
|
+
return n !== void 0 ? n ? new F("file", "directory", t || "unknown", s) : new F("directory", "file", t || "unknown", s) : new b("argument", `Type mismatch: ${t || "unknown"}`, t, s);
|
|
162
|
+
case "NotAllowedError":
|
|
163
|
+
case "SecurityError":
|
|
164
|
+
return new ue(t, "unknown", s);
|
|
165
|
+
case "InvalidModificationError":
|
|
166
|
+
return new b("argument", `Invalid modification: ${t || "unknown"}`, t, s);
|
|
167
|
+
case "AbortError":
|
|
168
|
+
return new de(t || "unknown", s);
|
|
169
|
+
case "OperationError":
|
|
170
|
+
return new W(`Operation failed: ${t || "unknown"}`, t, s);
|
|
171
|
+
case "TypeError":
|
|
172
|
+
return new ge(t || "unknown", s);
|
|
173
|
+
default:
|
|
174
|
+
return new W(`I/O error: ${t || "unknown"}`, t, s);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const we = [
|
|
178
|
+
// Images
|
|
179
|
+
".jpg",
|
|
180
|
+
".jpeg",
|
|
181
|
+
".png",
|
|
182
|
+
".gif",
|
|
183
|
+
".bmp",
|
|
184
|
+
".webp",
|
|
185
|
+
".ico",
|
|
186
|
+
".tiff",
|
|
187
|
+
".tga",
|
|
188
|
+
// Audio
|
|
189
|
+
".mp3",
|
|
190
|
+
".wav",
|
|
191
|
+
".ogg",
|
|
192
|
+
".flac",
|
|
193
|
+
".aac",
|
|
194
|
+
".wma",
|
|
195
|
+
".m4a",
|
|
196
|
+
// Video
|
|
197
|
+
".mp4",
|
|
198
|
+
".avi",
|
|
199
|
+
".mov",
|
|
200
|
+
".wmv",
|
|
201
|
+
".flv",
|
|
202
|
+
".webm",
|
|
203
|
+
".mkv",
|
|
204
|
+
".m4v",
|
|
205
|
+
// Documents
|
|
206
|
+
".pdf",
|
|
207
|
+
".doc",
|
|
208
|
+
".docx",
|
|
209
|
+
".xls",
|
|
210
|
+
".xlsx",
|
|
211
|
+
".ppt",
|
|
212
|
+
".pptx",
|
|
213
|
+
// Archives
|
|
214
|
+
".zip",
|
|
215
|
+
".rar",
|
|
216
|
+
".7z",
|
|
217
|
+
".tar",
|
|
218
|
+
".gz",
|
|
219
|
+
".bz2",
|
|
220
|
+
// Executables
|
|
221
|
+
".exe",
|
|
222
|
+
".dll",
|
|
223
|
+
".so",
|
|
224
|
+
".dylib",
|
|
225
|
+
// Other binary formats
|
|
226
|
+
".dat",
|
|
227
|
+
".db",
|
|
228
|
+
".sqlite",
|
|
229
|
+
".bin",
|
|
230
|
+
".obj",
|
|
231
|
+
".fbx",
|
|
232
|
+
".3ds"
|
|
233
|
+
];
|
|
234
|
+
function Lt(s) {
|
|
235
|
+
const e = s.lastIndexOf(".");
|
|
236
|
+
if (e <= 0)
|
|
237
|
+
return !0;
|
|
238
|
+
const t = s.slice(e).toLowerCase();
|
|
239
|
+
return we.includes(t);
|
|
240
|
+
}
|
|
241
|
+
function Ee(s, e = "utf-8") {
|
|
242
|
+
switch (e) {
|
|
243
|
+
case "utf8":
|
|
244
|
+
case "utf-8":
|
|
245
|
+
return new TextEncoder().encode(s);
|
|
246
|
+
case "utf16le":
|
|
247
|
+
case "utf-16le":
|
|
248
|
+
case "ucs2":
|
|
249
|
+
case "ucs-2":
|
|
250
|
+
return ye(s);
|
|
251
|
+
case "ascii":
|
|
252
|
+
return Oe(s);
|
|
253
|
+
case "latin1":
|
|
254
|
+
return Se(s);
|
|
255
|
+
case "binary":
|
|
256
|
+
return Uint8Array.from(s, (t) => t.charCodeAt(0));
|
|
257
|
+
case "base64":
|
|
258
|
+
return Uint8Array.from(atob(s), (t) => t.charCodeAt(0));
|
|
259
|
+
case "hex":
|
|
260
|
+
if (!/^[\da-f]+$/i.test(s) || s.length % 2 !== 0)
|
|
261
|
+
throw new b("format", "Invalid hex string");
|
|
262
|
+
return Uint8Array.from(s.match(/.{1,2}/g).map((t) => parseInt(t, 16)));
|
|
263
|
+
default:
|
|
264
|
+
return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function Ft(s, e = "utf-8") {
|
|
268
|
+
switch (e) {
|
|
269
|
+
case "utf8":
|
|
270
|
+
case "utf-8":
|
|
271
|
+
return new TextDecoder().decode(s);
|
|
272
|
+
case "utf16le":
|
|
273
|
+
case "utf-16le":
|
|
274
|
+
case "ucs2":
|
|
275
|
+
case "ucs-2":
|
|
276
|
+
return xe(s);
|
|
277
|
+
case "latin1":
|
|
278
|
+
return String.fromCharCode(...s);
|
|
279
|
+
case "ascii":
|
|
280
|
+
return String.fromCharCode(...s.map((t) => t & 127));
|
|
281
|
+
case "base64":
|
|
282
|
+
return btoa(String.fromCharCode(...s));
|
|
283
|
+
case "hex":
|
|
284
|
+
return Array.from(s).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
285
|
+
default:
|
|
286
|
+
return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function ye(s) {
|
|
290
|
+
const e = new Uint8Array(s.length * 2);
|
|
291
|
+
for (let t = 0; t < s.length; t++) {
|
|
292
|
+
const n = s.charCodeAt(t);
|
|
293
|
+
e[t * 2] = n & 255, e[t * 2 + 1] = n >> 8;
|
|
294
|
+
}
|
|
295
|
+
return e;
|
|
296
|
+
}
|
|
297
|
+
function xe(s) {
|
|
298
|
+
s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
|
|
299
|
+
const e = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
|
|
300
|
+
return String.fromCharCode(...e);
|
|
301
|
+
}
|
|
302
|
+
function Se(s) {
|
|
303
|
+
const e = new Uint8Array(s.length);
|
|
304
|
+
for (let t = 0; t < s.length; t++)
|
|
305
|
+
e[t] = s.charCodeAt(t) & 255;
|
|
306
|
+
return e;
|
|
307
|
+
}
|
|
308
|
+
function Oe(s) {
|
|
309
|
+
const e = new Uint8Array(s.length);
|
|
310
|
+
for (let t = 0; t < s.length; t++)
|
|
311
|
+
e[t] = s.charCodeAt(t) & 127;
|
|
312
|
+
return e;
|
|
313
|
+
}
|
|
314
|
+
var Ae = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(Ae || {});
|
|
315
|
+
const J = (s, e, t) => {
|
|
316
|
+
const n = s instanceof RegExp ? B(s, t) : s, r = e instanceof RegExp ? B(e, t) : e, i = n !== null && r != null && Ne(n, r, t);
|
|
317
|
+
return i && {
|
|
318
|
+
start: i[0],
|
|
319
|
+
end: i[1],
|
|
320
|
+
pre: t.slice(0, i[0]),
|
|
321
|
+
body: t.slice(i[0] + n.length, i[1]),
|
|
322
|
+
post: t.slice(i[1] + r.length)
|
|
323
|
+
};
|
|
324
|
+
}, B = (s, e) => {
|
|
325
|
+
const t = e.match(s);
|
|
326
|
+
return t ? t[0] : null;
|
|
327
|
+
}, Ne = (s, e, t) => {
|
|
328
|
+
let n, r, i, o, a, l = t.indexOf(s), h = t.indexOf(e, l + 1), c = l;
|
|
329
|
+
if (l >= 0 && h > 0) {
|
|
330
|
+
if (s === e)
|
|
331
|
+
return [l, h];
|
|
332
|
+
for (n = [], i = t.length; c >= 0 && !a; ) {
|
|
333
|
+
if (c === l)
|
|
334
|
+
n.push(c), l = t.indexOf(s, c + 1);
|
|
335
|
+
else if (n.length === 1) {
|
|
336
|
+
const p = n.pop();
|
|
337
|
+
p !== void 0 && (a = [p, h]);
|
|
338
|
+
} else
|
|
339
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = t.indexOf(e, c + 1);
|
|
340
|
+
c = l < h && l >= 0 ? l : h;
|
|
341
|
+
}
|
|
342
|
+
n.length && o !== void 0 && (a = [i, o]);
|
|
343
|
+
}
|
|
344
|
+
return a;
|
|
345
|
+
}, X = "\0SLASH" + Math.random() + "\0", K = "\0OPEN" + Math.random() + "\0", k = "\0CLOSE" + Math.random() + "\0", Q = "\0COMMA" + Math.random() + "\0", ee = "\0PERIOD" + Math.random() + "\0", be = new RegExp(X, "g"), ve = new RegExp(K, "g"), $e = new RegExp(k, "g"), Te = new RegExp(Q, "g"), Re = new RegExp(ee, "g"), Pe = /\\\\/g, Ie = /\\{/g, Me = /\\}/g, Ce = /\\,/g, De = /\\./g;
|
|
346
|
+
function L(s) {
|
|
347
|
+
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
348
|
+
}
|
|
349
|
+
function Le(s) {
|
|
350
|
+
return s.replace(Pe, X).replace(Ie, K).replace(Me, k).replace(Ce, Q).replace(De, ee);
|
|
351
|
+
}
|
|
352
|
+
function Fe(s) {
|
|
353
|
+
return s.replace(be, "\\").replace(ve, "{").replace($e, "}").replace(Te, ",").replace(Re, ".");
|
|
354
|
+
}
|
|
355
|
+
function te(s) {
|
|
356
|
+
if (!s)
|
|
357
|
+
return [""];
|
|
358
|
+
const e = [], t = J("{", "}", s);
|
|
359
|
+
if (!t)
|
|
360
|
+
return s.split(",");
|
|
361
|
+
const { pre: n, body: r, post: i } = t, o = n.split(",");
|
|
362
|
+
o[o.length - 1] += "{" + r + "}";
|
|
363
|
+
const a = te(i);
|
|
364
|
+
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), e.push.apply(e, o), e;
|
|
365
|
+
}
|
|
366
|
+
function ke(s) {
|
|
367
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), R(Le(s), !0).map(Fe)) : [];
|
|
368
|
+
}
|
|
369
|
+
function je(s) {
|
|
370
|
+
return "{" + s + "}";
|
|
371
|
+
}
|
|
372
|
+
function Ue(s) {
|
|
373
|
+
return /^-?0\d/.test(s);
|
|
374
|
+
}
|
|
375
|
+
function We(s, e) {
|
|
376
|
+
return s <= e;
|
|
377
|
+
}
|
|
378
|
+
function ze(s, e) {
|
|
379
|
+
return s >= e;
|
|
380
|
+
}
|
|
381
|
+
function R(s, e) {
|
|
382
|
+
const t = [], n = J("{", "}", s);
|
|
383
|
+
if (!n)
|
|
384
|
+
return [s];
|
|
385
|
+
const r = n.pre, i = n.post.length ? R(n.post, !1) : [""];
|
|
386
|
+
if (/\$$/.test(n.pre))
|
|
387
|
+
for (let o = 0; o < i.length; o++) {
|
|
388
|
+
const a = r + "{" + n.body + "}" + i[o];
|
|
389
|
+
t.push(a);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
|
|
393
|
+
if (!l && !h)
|
|
394
|
+
return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + k + n.post, R(s)) : [s];
|
|
395
|
+
let c;
|
|
396
|
+
if (l)
|
|
397
|
+
c = n.body.split(/\.\./);
|
|
398
|
+
else if (c = te(n.body), c.length === 1 && c[0] !== void 0 && (c = R(c[0], !1).map(je), c.length === 1))
|
|
399
|
+
return i.map((f) => n.pre + c[0] + f);
|
|
400
|
+
let p;
|
|
401
|
+
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
402
|
+
const f = L(c[0]), u = L(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
403
|
+
let d = c.length === 3 && c[2] !== void 0 ? Math.abs(L(c[2])) : 1, x = We;
|
|
404
|
+
u < f && (d *= -1, x = ze);
|
|
405
|
+
const v = c.some(Ue);
|
|
406
|
+
p = [];
|
|
407
|
+
for (let S = f; x(S, u); S += d) {
|
|
408
|
+
let w;
|
|
409
|
+
if (a)
|
|
410
|
+
w = String.fromCharCode(S), w === "\\" && (w = "");
|
|
411
|
+
else if (w = String(S), v) {
|
|
412
|
+
const $ = g - w.length;
|
|
413
|
+
if ($ > 0) {
|
|
414
|
+
const I = new Array($ + 1).join("0");
|
|
415
|
+
S < 0 ? w = "-" + I + w.slice(1) : w = I + w;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
p.push(w);
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
p = [];
|
|
422
|
+
for (let f = 0; f < c.length; f++)
|
|
423
|
+
p.push.apply(p, R(c[f], !1));
|
|
424
|
+
}
|
|
425
|
+
for (let f = 0; f < p.length; f++)
|
|
426
|
+
for (let u = 0; u < i.length; u++) {
|
|
427
|
+
const g = r + p[f] + i[u];
|
|
428
|
+
(!e || l || g) && t.push(g);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return t;
|
|
432
|
+
}
|
|
433
|
+
const Be = 1024 * 64, C = (s) => {
|
|
434
|
+
if (typeof s != "string")
|
|
435
|
+
throw new TypeError("invalid pattern");
|
|
436
|
+
if (s.length > Be)
|
|
437
|
+
throw new TypeError("pattern is too long");
|
|
438
|
+
}, _e = {
|
|
439
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
440
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
|
|
441
|
+
"[:ascii:]": ["\\x00-\\x7f", !1],
|
|
442
|
+
"[:blank:]": ["\\p{Zs}\\t", !0],
|
|
443
|
+
"[:cntrl:]": ["\\p{Cc}", !0],
|
|
444
|
+
"[:digit:]": ["\\p{Nd}", !0],
|
|
445
|
+
"[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
|
|
446
|
+
"[:lower:]": ["\\p{Ll}", !0],
|
|
447
|
+
"[:print:]": ["\\p{C}", !0],
|
|
448
|
+
"[:punct:]": ["\\p{P}", !0],
|
|
449
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
|
|
450
|
+
"[:upper:]": ["\\p{Lu}", !0],
|
|
451
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
|
|
452
|
+
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
453
|
+
}, T = (s) => s.replace(/[[\]\\-]/g, "\\$&"), qe = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), _ = (s) => s.join(""), Ge = (s, e) => {
|
|
454
|
+
const t = e;
|
|
455
|
+
if (s.charAt(t) !== "[")
|
|
456
|
+
throw new Error("not in a brace expression");
|
|
457
|
+
const n = [], r = [];
|
|
458
|
+
let i = t + 1, o = !1, a = !1, l = !1, h = !1, c = t, p = "";
|
|
459
|
+
e: for (; i < s.length; ) {
|
|
460
|
+
const d = s.charAt(i);
|
|
461
|
+
if ((d === "!" || d === "^") && i === t + 1) {
|
|
462
|
+
h = !0, i++;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (d === "]" && o && !l) {
|
|
466
|
+
c = i + 1;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
if (o = !0, d === "\\" && !l) {
|
|
470
|
+
l = !0, i++;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (d === "[" && !l) {
|
|
474
|
+
for (const [x, [N, v, S]] of Object.entries(_e))
|
|
475
|
+
if (s.startsWith(x, i)) {
|
|
476
|
+
if (p)
|
|
477
|
+
return ["$.", !1, s.length - t, !0];
|
|
478
|
+
i += x.length, S ? r.push(N) : n.push(N), a = a || v;
|
|
479
|
+
continue e;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (l = !1, p) {
|
|
483
|
+
d > p ? n.push(T(p) + "-" + T(d)) : d === p && n.push(T(d)), p = "", i++;
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (s.startsWith("-]", i + 1)) {
|
|
487
|
+
n.push(T(d + "-")), i += 2;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (s.startsWith("-", i + 1)) {
|
|
491
|
+
p = d, i += 2;
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
n.push(T(d)), i++;
|
|
495
|
+
}
|
|
496
|
+
if (c < i)
|
|
497
|
+
return ["", !1, 0, !1];
|
|
498
|
+
if (!n.length && !r.length)
|
|
499
|
+
return ["$.", !1, s.length - t, !0];
|
|
500
|
+
if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !h) {
|
|
501
|
+
const d = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
502
|
+
return [qe(d), !1, c - t, !1];
|
|
503
|
+
}
|
|
504
|
+
const f = "[" + (h ? "^" : "") + _(n) + "]", u = "[" + (h ? "" : "^") + _(r) + "]";
|
|
505
|
+
return [n.length && r.length ? "(" + f + "|" + u + ")" : n.length ? f : u, a, c - t, !0];
|
|
506
|
+
}, P = (s, { windowsPathsNoEscape: e = !1 } = {}) => e ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), He = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), q = (s) => He.has(s), Ve = "(?!(?:^|/)\\.\\.?(?:$|/))", M = "(?!\\.)", Ye = /* @__PURE__ */ new Set(["[", "."]), Ze = /* @__PURE__ */ new Set(["..", "."]), Je = new Set("().*{}+?[]^$\\!"), Xe = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), j = "[^/]", G = j + "*?", H = j + "+?";
|
|
507
|
+
class y {
|
|
508
|
+
type;
|
|
509
|
+
#s;
|
|
510
|
+
#n;
|
|
511
|
+
#i = !1;
|
|
512
|
+
#e = [];
|
|
513
|
+
#t;
|
|
514
|
+
#o;
|
|
515
|
+
#a;
|
|
516
|
+
#c = !1;
|
|
517
|
+
#r;
|
|
518
|
+
#l;
|
|
519
|
+
// set to true if it's an extglob with no children
|
|
520
|
+
// (which really means one child of '')
|
|
521
|
+
#u = !1;
|
|
522
|
+
constructor(e, t, n = {}) {
|
|
523
|
+
this.type = e, e && (this.#n = !0), this.#t = t, this.#s = this.#t ? this.#t.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#a = this.#s === this ? [] : this.#s.#a, e === "!" && !this.#s.#c && this.#a.push(this), this.#o = this.#t ? this.#t.#e.length : 0;
|
|
524
|
+
}
|
|
525
|
+
get hasMagic() {
|
|
526
|
+
if (this.#n !== void 0)
|
|
527
|
+
return this.#n;
|
|
528
|
+
for (const e of this.#e)
|
|
529
|
+
if (typeof e != "string" && (e.type || e.hasMagic))
|
|
530
|
+
return this.#n = !0;
|
|
531
|
+
return this.#n;
|
|
532
|
+
}
|
|
533
|
+
// reconstructs the pattern
|
|
534
|
+
toString() {
|
|
535
|
+
return this.#l !== void 0 ? this.#l : this.type ? this.#l = this.type + "(" + this.#e.map((e) => String(e)).join("|") + ")" : this.#l = this.#e.map((e) => String(e)).join("");
|
|
536
|
+
}
|
|
537
|
+
#p() {
|
|
538
|
+
if (this !== this.#s)
|
|
539
|
+
throw new Error("should only call on root");
|
|
540
|
+
if (this.#c)
|
|
541
|
+
return this;
|
|
542
|
+
this.toString(), this.#c = !0;
|
|
543
|
+
let e;
|
|
544
|
+
for (; e = this.#a.pop(); ) {
|
|
545
|
+
if (e.type !== "!")
|
|
546
|
+
continue;
|
|
547
|
+
let t = e, n = t.#t;
|
|
548
|
+
for (; n; ) {
|
|
549
|
+
for (let r = t.#o + 1; !n.type && r < n.#e.length; r++)
|
|
550
|
+
for (const i of e.#e) {
|
|
551
|
+
if (typeof i == "string")
|
|
552
|
+
throw new Error("string part in extglob AST??");
|
|
553
|
+
i.copyIn(n.#e[r]);
|
|
554
|
+
}
|
|
555
|
+
t = n, n = t.#t;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return this;
|
|
559
|
+
}
|
|
560
|
+
push(...e) {
|
|
561
|
+
for (const t of e)
|
|
562
|
+
if (t !== "") {
|
|
563
|
+
if (typeof t != "string" && !(t instanceof y && t.#t === this))
|
|
564
|
+
throw new Error("invalid part: " + t);
|
|
565
|
+
this.#e.push(t);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
toJSON() {
|
|
569
|
+
const e = this.type === null ? this.#e.slice().map((t) => typeof t == "string" ? t : t.toJSON()) : [this.type, ...this.#e.map((t) => t.toJSON())];
|
|
570
|
+
return this.isStart() && !this.type && e.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#t?.type === "!") && e.push({}), e;
|
|
571
|
+
}
|
|
572
|
+
isStart() {
|
|
573
|
+
if (this.#s === this)
|
|
574
|
+
return !0;
|
|
575
|
+
if (!this.#t?.isStart())
|
|
576
|
+
return !1;
|
|
577
|
+
if (this.#o === 0)
|
|
578
|
+
return !0;
|
|
579
|
+
const e = this.#t;
|
|
580
|
+
for (let t = 0; t < this.#o; t++) {
|
|
581
|
+
const n = e.#e[t];
|
|
582
|
+
if (!(n instanceof y && n.type === "!"))
|
|
583
|
+
return !1;
|
|
584
|
+
}
|
|
585
|
+
return !0;
|
|
586
|
+
}
|
|
587
|
+
isEnd() {
|
|
588
|
+
if (this.#s === this || this.#t?.type === "!")
|
|
589
|
+
return !0;
|
|
590
|
+
if (!this.#t?.isEnd())
|
|
591
|
+
return !1;
|
|
592
|
+
if (!this.type)
|
|
593
|
+
return this.#t?.isEnd();
|
|
594
|
+
const e = this.#t ? this.#t.#e.length : 0;
|
|
595
|
+
return this.#o === e - 1;
|
|
596
|
+
}
|
|
597
|
+
copyIn(e) {
|
|
598
|
+
typeof e == "string" ? this.push(e) : this.push(e.clone(this));
|
|
599
|
+
}
|
|
600
|
+
clone(e) {
|
|
601
|
+
const t = new y(this.type, e);
|
|
602
|
+
for (const n of this.#e)
|
|
603
|
+
t.copyIn(n);
|
|
604
|
+
return t;
|
|
605
|
+
}
|
|
606
|
+
static #h(e, t, n, r) {
|
|
607
|
+
let i = !1, o = !1, a = -1, l = !1;
|
|
608
|
+
if (t.type === null) {
|
|
609
|
+
let u = n, g = "";
|
|
610
|
+
for (; u < e.length; ) {
|
|
611
|
+
const d = e.charAt(u++);
|
|
612
|
+
if (i || d === "\\") {
|
|
613
|
+
i = !i, g += d;
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if (o) {
|
|
617
|
+
u === a + 1 ? (d === "^" || d === "!") && (l = !0) : d === "]" && !(u === a + 2 && l) && (o = !1), g += d;
|
|
618
|
+
continue;
|
|
619
|
+
} else if (d === "[") {
|
|
620
|
+
o = !0, a = u, l = !1, g += d;
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (!r.noext && q(d) && e.charAt(u) === "(") {
|
|
624
|
+
t.push(g), g = "";
|
|
625
|
+
const x = new y(d, t);
|
|
626
|
+
u = y.#h(e, x, u, r), t.push(x);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
g += d;
|
|
630
|
+
}
|
|
631
|
+
return t.push(g), u;
|
|
632
|
+
}
|
|
633
|
+
let h = n + 1, c = new y(null, t);
|
|
634
|
+
const p = [];
|
|
635
|
+
let f = "";
|
|
636
|
+
for (; h < e.length; ) {
|
|
637
|
+
const u = e.charAt(h++);
|
|
638
|
+
if (i || u === "\\") {
|
|
639
|
+
i = !i, f += u;
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
if (o) {
|
|
643
|
+
h === a + 1 ? (u === "^" || u === "!") && (l = !0) : u === "]" && !(h === a + 2 && l) && (o = !1), f += u;
|
|
644
|
+
continue;
|
|
645
|
+
} else if (u === "[") {
|
|
646
|
+
o = !0, a = h, l = !1, f += u;
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (q(u) && e.charAt(h) === "(") {
|
|
650
|
+
c.push(f), f = "";
|
|
651
|
+
const g = new y(u, c);
|
|
652
|
+
c.push(g), h = y.#h(e, g, h, r);
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (u === "|") {
|
|
656
|
+
c.push(f), f = "", p.push(c), c = new y(null, t);
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (u === ")")
|
|
660
|
+
return f === "" && t.#e.length === 0 && (t.#u = !0), c.push(f), f = "", t.push(...p, c), h;
|
|
661
|
+
f += u;
|
|
662
|
+
}
|
|
663
|
+
return t.type = null, t.#n = void 0, t.#e = [e.substring(n - 1)], h;
|
|
664
|
+
}
|
|
665
|
+
static fromGlob(e, t = {}) {
|
|
666
|
+
const n = new y(null, void 0, t);
|
|
667
|
+
return y.#h(e, n, 0, t), n;
|
|
668
|
+
}
|
|
669
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
670
|
+
// string if not.
|
|
671
|
+
toMMPattern() {
|
|
672
|
+
if (this !== this.#s)
|
|
673
|
+
return this.#s.toMMPattern();
|
|
674
|
+
const e = this.toString(), [t, n, r, i] = this.toRegExpSource();
|
|
675
|
+
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && e.toUpperCase() !== e.toLowerCase()))
|
|
676
|
+
return n;
|
|
677
|
+
const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
678
|
+
return Object.assign(new RegExp(`^${t}$`, a), {
|
|
679
|
+
_src: t,
|
|
680
|
+
_glob: e
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
get options() {
|
|
684
|
+
return this.#r;
|
|
685
|
+
}
|
|
686
|
+
// returns the string match, the regexp source, whether there's magic
|
|
687
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
688
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
689
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
690
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
691
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
692
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
693
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
694
|
+
//
|
|
695
|
+
// In part-matching mode, the start is:
|
|
696
|
+
// - if not isStart: nothing
|
|
697
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
698
|
+
// - if dots allowed or not possible: ^
|
|
699
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
700
|
+
// end is:
|
|
701
|
+
// - if not isEnd(): nothing
|
|
702
|
+
// - else: $
|
|
703
|
+
//
|
|
704
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
705
|
+
// pattern, so start is:
|
|
706
|
+
// - if first pattern: same as part-matching mode
|
|
707
|
+
// - if not isStart(): nothing
|
|
708
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
709
|
+
// - if dots allowed or not possible: /
|
|
710
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
711
|
+
// end is:
|
|
712
|
+
// - if last pattern, same as part-matching mode
|
|
713
|
+
// - else nothing
|
|
714
|
+
//
|
|
715
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
716
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
717
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
718
|
+
// the pattern.
|
|
719
|
+
//
|
|
720
|
+
// We can just always return the same end, and leave it up to the caller
|
|
721
|
+
// to know whether it's going to be used joined or in parts.
|
|
722
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
723
|
+
// - if not isStart: nothing
|
|
724
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
725
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
726
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
727
|
+
//
|
|
728
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
729
|
+
// performance, so probably better to return both start options.
|
|
730
|
+
//
|
|
731
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
732
|
+
// and the start always gets applied.
|
|
733
|
+
//
|
|
734
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
735
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
736
|
+
//
|
|
737
|
+
// So the todo is:
|
|
738
|
+
// - better detect what kind of start is needed
|
|
739
|
+
// - return both flavors of starting pattern
|
|
740
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
741
|
+
//
|
|
742
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
743
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
744
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
745
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
746
|
+
//
|
|
747
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
748
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
749
|
+
// use the (?:^|/) style of start binding.
|
|
750
|
+
//
|
|
751
|
+
// Even simplified further:
|
|
752
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
753
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
754
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
755
|
+
toRegExpSource(e) {
|
|
756
|
+
const t = e ?? !!this.#r.dot;
|
|
757
|
+
if (this.#s === this && this.#p(), !this.type) {
|
|
758
|
+
const l = this.isStart() && this.isEnd(), h = this.#e.map((u) => {
|
|
759
|
+
const [g, d, x, N] = typeof u == "string" ? y.#d(u, this.#n, l) : u.toRegExpSource(e);
|
|
760
|
+
return this.#n = this.#n || x, this.#i = this.#i || N, g;
|
|
761
|
+
}).join("");
|
|
762
|
+
let c = "";
|
|
763
|
+
if (this.isStart() && typeof this.#e[0] == "string" && !(this.#e.length === 1 && Ze.has(this.#e[0]))) {
|
|
764
|
+
const g = Ye, d = (
|
|
765
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
766
|
+
t && g.has(h.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
767
|
+
h.startsWith("\\.") && g.has(h.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
768
|
+
h.startsWith("\\.\\.") && g.has(h.charAt(4))
|
|
769
|
+
), x = !t && !e && g.has(h.charAt(0));
|
|
770
|
+
c = d ? Ve : x ? M : "";
|
|
771
|
+
}
|
|
772
|
+
let p = "";
|
|
773
|
+
return this.isEnd() && this.#s.#c && this.#t?.type === "!" && (p = "(?:$|\\/)"), [
|
|
774
|
+
c + h + p,
|
|
775
|
+
P(h),
|
|
776
|
+
this.#n = !!this.#n,
|
|
777
|
+
this.#i
|
|
778
|
+
];
|
|
779
|
+
}
|
|
780
|
+
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
781
|
+
let i = this.#f(t);
|
|
782
|
+
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
783
|
+
const l = this.toString();
|
|
784
|
+
return this.#e = [l], this.type = null, this.#n = void 0, [l, P(this.toString()), !1, !1];
|
|
785
|
+
}
|
|
786
|
+
let o = !n || e || t || !M ? "" : this.#f(!0);
|
|
787
|
+
o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
|
|
788
|
+
let a = "";
|
|
789
|
+
if (this.type === "!" && this.#u)
|
|
790
|
+
a = (this.isStart() && !t ? M : "") + H;
|
|
791
|
+
else {
|
|
792
|
+
const l = this.type === "!" ? (
|
|
793
|
+
// !() must match something,but !(x) can match ''
|
|
794
|
+
"))" + (this.isStart() && !t && !e ? M : "") + G + ")"
|
|
795
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
796
|
+
a = r + i + l;
|
|
797
|
+
}
|
|
798
|
+
return [
|
|
799
|
+
a,
|
|
800
|
+
P(i),
|
|
801
|
+
this.#n = !!this.#n,
|
|
802
|
+
this.#i
|
|
803
|
+
];
|
|
804
|
+
}
|
|
805
|
+
#f(e) {
|
|
806
|
+
return this.#e.map((t) => {
|
|
807
|
+
if (typeof t == "string")
|
|
808
|
+
throw new Error("string type in extglob ast??");
|
|
809
|
+
const [n, r, i, o] = t.toRegExpSource(e);
|
|
810
|
+
return this.#i = this.#i || o, n;
|
|
811
|
+
}).filter((t) => !(this.isStart() && this.isEnd()) || !!t).join("|");
|
|
812
|
+
}
|
|
813
|
+
static #d(e, t, n = !1) {
|
|
814
|
+
let r = !1, i = "", o = !1;
|
|
815
|
+
for (let a = 0; a < e.length; a++) {
|
|
816
|
+
const l = e.charAt(a);
|
|
817
|
+
if (r) {
|
|
818
|
+
r = !1, i += (Je.has(l) ? "\\" : "") + l;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (l === "\\") {
|
|
822
|
+
a === e.length - 1 ? i += "\\\\" : r = !0;
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
if (l === "[") {
|
|
826
|
+
const [h, c, p, f] = Ge(e, a);
|
|
827
|
+
if (p) {
|
|
828
|
+
i += h, o = o || c, a += p - 1, t = t || f;
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (l === "*") {
|
|
833
|
+
n && e === "*" ? i += H : i += G, t = !0;
|
|
834
|
+
continue;
|
|
835
|
+
}
|
|
836
|
+
if (l === "?") {
|
|
837
|
+
i += j, t = !0;
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
i += Xe(l);
|
|
841
|
+
}
|
|
842
|
+
return [i, P(e), !!t, o];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const Ke = (s, { windowsPathsNoEscape: e = !1 } = {}) => e ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), E = (s, e, t = {}) => (C(e), !t.nocomment && e.charAt(0) === "#" ? !1 : new D(e, t).match(s)), Qe = /^\*+([^+@!?\*\[\(]*)$/, et = (s) => (e) => !e.startsWith(".") && e.endsWith(s), tt = (s) => (e) => e.endsWith(s), st = (s) => (s = s.toLowerCase(), (e) => !e.startsWith(".") && e.toLowerCase().endsWith(s)), nt = (s) => (s = s.toLowerCase(), (e) => e.toLowerCase().endsWith(s)), rt = /^\*+\.\*+$/, it = (s) => !s.startsWith(".") && s.includes("."), ot = (s) => s !== "." && s !== ".." && s.includes("."), ct = /^\.\*+$/, at = (s) => s !== "." && s !== ".." && s.startsWith("."), lt = /^\*+$/, ht = (s) => s.length !== 0 && !s.startsWith("."), ut = (s) => s.length !== 0 && s !== "." && s !== "..", ft = /^\?+([^+@!?\*\[\(]*)?$/, pt = ([s, e = ""]) => {
|
|
846
|
+
const t = se([s]);
|
|
847
|
+
return e ? (e = e.toLowerCase(), (n) => t(n) && n.toLowerCase().endsWith(e)) : t;
|
|
848
|
+
}, dt = ([s, e = ""]) => {
|
|
849
|
+
const t = ne([s]);
|
|
850
|
+
return e ? (e = e.toLowerCase(), (n) => t(n) && n.toLowerCase().endsWith(e)) : t;
|
|
851
|
+
}, gt = ([s, e = ""]) => {
|
|
852
|
+
const t = ne([s]);
|
|
853
|
+
return e ? (n) => t(n) && n.endsWith(e) : t;
|
|
854
|
+
}, mt = ([s, e = ""]) => {
|
|
855
|
+
const t = se([s]);
|
|
856
|
+
return e ? (n) => t(n) && n.endsWith(e) : t;
|
|
857
|
+
}, se = ([s]) => {
|
|
858
|
+
const e = s.length;
|
|
859
|
+
return (t) => t.length === e && !t.startsWith(".");
|
|
860
|
+
}, ne = ([s]) => {
|
|
861
|
+
const e = s.length;
|
|
862
|
+
return (t) => t.length === e && t !== "." && t !== "..";
|
|
863
|
+
}, re = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", V = {
|
|
864
|
+
win32: { sep: "\\" },
|
|
865
|
+
posix: { sep: "/" }
|
|
866
|
+
}, wt = re === "win32" ? V.win32.sep : V.posix.sep;
|
|
867
|
+
E.sep = wt;
|
|
868
|
+
const A = Symbol("globstar **");
|
|
869
|
+
E.GLOBSTAR = A;
|
|
870
|
+
const Et = "[^/]", yt = Et + "*?", xt = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", St = "(?:(?!(?:\\/|^)\\.).)*?", Ot = (s, e = {}) => (t) => E(t, s, e);
|
|
871
|
+
E.filter = Ot;
|
|
872
|
+
const O = (s, e = {}) => Object.assign({}, s, e), At = (s) => {
|
|
873
|
+
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
874
|
+
return E;
|
|
875
|
+
const e = E;
|
|
876
|
+
return Object.assign((n, r, i = {}) => e(n, r, O(s, i)), {
|
|
877
|
+
Minimatch: class extends e.Minimatch {
|
|
878
|
+
constructor(r, i = {}) {
|
|
879
|
+
super(r, O(s, i));
|
|
880
|
+
}
|
|
881
|
+
static defaults(r) {
|
|
882
|
+
return e.defaults(O(s, r)).Minimatch;
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
AST: class extends e.AST {
|
|
886
|
+
/* c8 ignore start */
|
|
887
|
+
constructor(r, i, o = {}) {
|
|
888
|
+
super(r, i, O(s, o));
|
|
889
|
+
}
|
|
890
|
+
/* c8 ignore stop */
|
|
891
|
+
static fromGlob(r, i = {}) {
|
|
892
|
+
return e.AST.fromGlob(r, O(s, i));
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
unescape: (n, r = {}) => e.unescape(n, O(s, r)),
|
|
896
|
+
escape: (n, r = {}) => e.escape(n, O(s, r)),
|
|
897
|
+
filter: (n, r = {}) => e.filter(n, O(s, r)),
|
|
898
|
+
defaults: (n) => e.defaults(O(s, n)),
|
|
899
|
+
makeRe: (n, r = {}) => e.makeRe(n, O(s, r)),
|
|
900
|
+
braceExpand: (n, r = {}) => e.braceExpand(n, O(s, r)),
|
|
901
|
+
match: (n, r, i = {}) => e.match(n, r, O(s, i)),
|
|
902
|
+
sep: e.sep,
|
|
903
|
+
GLOBSTAR: A
|
|
904
|
+
});
|
|
905
|
+
};
|
|
906
|
+
E.defaults = At;
|
|
907
|
+
const ie = (s, e = {}) => (C(s), e.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : ke(s));
|
|
908
|
+
E.braceExpand = ie;
|
|
909
|
+
const Nt = (s, e = {}) => new D(s, e).makeRe();
|
|
910
|
+
E.makeRe = Nt;
|
|
911
|
+
const bt = (s, e, t = {}) => {
|
|
912
|
+
const n = new D(e, t);
|
|
913
|
+
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(e), s;
|
|
914
|
+
};
|
|
915
|
+
E.match = bt;
|
|
916
|
+
const Y = /[?*]|[+@!]\(.*?\)|\[|\]/, vt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
917
|
+
class D {
|
|
918
|
+
options;
|
|
919
|
+
set;
|
|
920
|
+
pattern;
|
|
921
|
+
windowsPathsNoEscape;
|
|
922
|
+
nonegate;
|
|
923
|
+
negate;
|
|
924
|
+
comment;
|
|
925
|
+
empty;
|
|
926
|
+
preserveMultipleSlashes;
|
|
927
|
+
partial;
|
|
928
|
+
globSet;
|
|
929
|
+
globParts;
|
|
930
|
+
nocase;
|
|
931
|
+
isWindows;
|
|
932
|
+
platform;
|
|
933
|
+
windowsNoMagicRoot;
|
|
934
|
+
regexp;
|
|
935
|
+
constructor(e, t = {}) {
|
|
936
|
+
C(e), t = t || {}, this.options = t, this.pattern = e, this.platform = t.platform || re, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!t.windowsPathsNoEscape || t.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!t.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!t.nonegate, this.comment = !1, this.empty = !1, this.partial = !!t.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = t.windowsNoMagicRoot !== void 0 ? t.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
937
|
+
}
|
|
938
|
+
hasMagic() {
|
|
939
|
+
if (this.options.magicalBraces && this.set.length > 1)
|
|
940
|
+
return !0;
|
|
941
|
+
for (const e of this.set)
|
|
942
|
+
for (const t of e)
|
|
943
|
+
if (typeof t != "string")
|
|
944
|
+
return !0;
|
|
945
|
+
return !1;
|
|
946
|
+
}
|
|
947
|
+
debug(...e) {
|
|
948
|
+
}
|
|
949
|
+
make() {
|
|
950
|
+
const e = this.pattern, t = this.options;
|
|
951
|
+
if (!t.nocomment && e.charAt(0) === "#") {
|
|
952
|
+
this.comment = !0;
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
if (!e) {
|
|
956
|
+
this.empty = !0;
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], t.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
960
|
+
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
961
|
+
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
962
|
+
let r = this.globParts.map((i, o, a) => {
|
|
963
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
964
|
+
const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !Y.test(i[2])) && !Y.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
965
|
+
if (l)
|
|
966
|
+
return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
|
|
967
|
+
if (h)
|
|
968
|
+
return [i[0], ...i.slice(1).map((c) => this.parse(c))];
|
|
969
|
+
}
|
|
970
|
+
return i.map((l) => this.parse(l));
|
|
971
|
+
});
|
|
972
|
+
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
973
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
974
|
+
const o = this.set[i];
|
|
975
|
+
o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
976
|
+
}
|
|
977
|
+
this.debug(this.pattern, this.set);
|
|
978
|
+
}
|
|
979
|
+
// various transforms to equivalent pattern sets that are
|
|
980
|
+
// faster to process in a filesystem walk. The goal is to
|
|
981
|
+
// eliminate what we can, and push all ** patterns as far
|
|
982
|
+
// to the right as possible, even if it increases the number
|
|
983
|
+
// of patterns that we have to process.
|
|
984
|
+
preprocess(e) {
|
|
985
|
+
if (this.options.noglobstar)
|
|
986
|
+
for (let n = 0; n < e.length; n++)
|
|
987
|
+
for (let r = 0; r < e[n].length; r++)
|
|
988
|
+
e[n][r] === "**" && (e[n][r] = "*");
|
|
989
|
+
const { optimizationLevel: t = 1 } = this.options;
|
|
990
|
+
return t >= 2 ? (e = this.firstPhasePreProcess(e), e = this.secondPhasePreProcess(e)) : t >= 1 ? e = this.levelOneOptimize(e) : e = this.adjascentGlobstarOptimize(e), e;
|
|
991
|
+
}
|
|
992
|
+
// just get rid of adjascent ** portions
|
|
993
|
+
adjascentGlobstarOptimize(e) {
|
|
994
|
+
return e.map((t) => {
|
|
995
|
+
let n = -1;
|
|
996
|
+
for (; (n = t.indexOf("**", n + 1)) !== -1; ) {
|
|
997
|
+
let r = n;
|
|
998
|
+
for (; t[r + 1] === "**"; )
|
|
999
|
+
r++;
|
|
1000
|
+
r !== n && t.splice(n, r - n);
|
|
1001
|
+
}
|
|
1002
|
+
return t;
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
// get rid of adjascent ** and resolve .. portions
|
|
1006
|
+
levelOneOptimize(e) {
|
|
1007
|
+
return e.map((t) => (t = t.reduce((n, r) => {
|
|
1008
|
+
const i = n[n.length - 1];
|
|
1009
|
+
return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
|
|
1010
|
+
}, []), t.length === 0 ? [""] : t));
|
|
1011
|
+
}
|
|
1012
|
+
levelTwoFileOptimize(e) {
|
|
1013
|
+
Array.isArray(e) || (e = this.slashSplit(e));
|
|
1014
|
+
let t = !1;
|
|
1015
|
+
do {
|
|
1016
|
+
if (t = !1, !this.preserveMultipleSlashes) {
|
|
1017
|
+
for (let r = 1; r < e.length - 1; r++) {
|
|
1018
|
+
const i = e[r];
|
|
1019
|
+
r === 1 && i === "" && e[0] === "" || (i === "." || i === "") && (t = !0, e.splice(r, 1), r--);
|
|
1020
|
+
}
|
|
1021
|
+
e[0] === "." && e.length === 2 && (e[1] === "." || e[1] === "") && (t = !0, e.pop());
|
|
1022
|
+
}
|
|
1023
|
+
let n = 0;
|
|
1024
|
+
for (; (n = e.indexOf("..", n + 1)) !== -1; ) {
|
|
1025
|
+
const r = e[n - 1];
|
|
1026
|
+
r && r !== "." && r !== ".." && r !== "**" && (t = !0, e.splice(n - 1, 2), n -= 2);
|
|
1027
|
+
}
|
|
1028
|
+
} while (t);
|
|
1029
|
+
return e.length === 0 ? [""] : e;
|
|
1030
|
+
}
|
|
1031
|
+
// First phase: single-pattern processing
|
|
1032
|
+
// <pre> is 1 or more portions
|
|
1033
|
+
// <rest> is 1 or more portions
|
|
1034
|
+
// <p> is any portion other than ., .., '', or **
|
|
1035
|
+
// <e> is . or ''
|
|
1036
|
+
//
|
|
1037
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
1038
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
1039
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
1040
|
+
// or most strings (other than .., ., and '') can be.
|
|
1041
|
+
//
|
|
1042
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
1043
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
1044
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
1045
|
+
// **/**/<rest> -> **/<rest>
|
|
1046
|
+
//
|
|
1047
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
1048
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
1049
|
+
firstPhasePreProcess(e) {
|
|
1050
|
+
let t = !1;
|
|
1051
|
+
do {
|
|
1052
|
+
t = !1;
|
|
1053
|
+
for (let n of e) {
|
|
1054
|
+
let r = -1;
|
|
1055
|
+
for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
|
|
1056
|
+
let o = r;
|
|
1057
|
+
for (; n[o + 1] === "**"; )
|
|
1058
|
+
o++;
|
|
1059
|
+
o > r && n.splice(r + 1, o - r);
|
|
1060
|
+
let a = n[r + 1];
|
|
1061
|
+
const l = n[r + 2], h = n[r + 3];
|
|
1062
|
+
if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
|
|
1063
|
+
continue;
|
|
1064
|
+
t = !0, n.splice(r, 1);
|
|
1065
|
+
const c = n.slice(0);
|
|
1066
|
+
c[r] = "**", e.push(c), r--;
|
|
1067
|
+
}
|
|
1068
|
+
if (!this.preserveMultipleSlashes) {
|
|
1069
|
+
for (let o = 1; o < n.length - 1; o++) {
|
|
1070
|
+
const a = n[o];
|
|
1071
|
+
o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (t = !0, n.splice(o, 1), o--);
|
|
1072
|
+
}
|
|
1073
|
+
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (t = !0, n.pop());
|
|
1074
|
+
}
|
|
1075
|
+
let i = 0;
|
|
1076
|
+
for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
|
|
1077
|
+
const o = n[i - 1];
|
|
1078
|
+
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1079
|
+
t = !0;
|
|
1080
|
+
const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1081
|
+
n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
} while (t);
|
|
1086
|
+
return e;
|
|
1087
|
+
}
|
|
1088
|
+
// second phase: multi-pattern dedupes
|
|
1089
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
1090
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
1091
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
1092
|
+
//
|
|
1093
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
1094
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
1095
|
+
secondPhasePreProcess(e) {
|
|
1096
|
+
for (let t = 0; t < e.length - 1; t++)
|
|
1097
|
+
for (let n = t + 1; n < e.length; n++) {
|
|
1098
|
+
const r = this.partsMatch(e[t], e[n], !this.preserveMultipleSlashes);
|
|
1099
|
+
if (r) {
|
|
1100
|
+
e[t] = [], e[n] = r;
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
return e.filter((t) => t.length);
|
|
1105
|
+
}
|
|
1106
|
+
partsMatch(e, t, n = !1) {
|
|
1107
|
+
let r = 0, i = 0, o = [], a = "";
|
|
1108
|
+
for (; r < e.length && i < t.length; )
|
|
1109
|
+
if (e[r] === t[i])
|
|
1110
|
+
o.push(a === "b" ? t[i] : e[r]), r++, i++;
|
|
1111
|
+
else if (n && e[r] === "**" && t[i] === e[r + 1])
|
|
1112
|
+
o.push(e[r]), r++;
|
|
1113
|
+
else if (n && t[i] === "**" && e[r] === t[i + 1])
|
|
1114
|
+
o.push(t[i]), i++;
|
|
1115
|
+
else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
|
|
1116
|
+
if (a === "b")
|
|
1117
|
+
return !1;
|
|
1118
|
+
a = "a", o.push(e[r]), r++, i++;
|
|
1119
|
+
} else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
|
|
1120
|
+
if (a === "a")
|
|
1121
|
+
return !1;
|
|
1122
|
+
a = "b", o.push(t[i]), r++, i++;
|
|
1123
|
+
} else
|
|
1124
|
+
return !1;
|
|
1125
|
+
return e.length === t.length && o;
|
|
1126
|
+
}
|
|
1127
|
+
parseNegate() {
|
|
1128
|
+
if (this.nonegate)
|
|
1129
|
+
return;
|
|
1130
|
+
const e = this.pattern;
|
|
1131
|
+
let t = !1, n = 0;
|
|
1132
|
+
for (let r = 0; r < e.length && e.charAt(r) === "!"; r++)
|
|
1133
|
+
t = !t, n++;
|
|
1134
|
+
n && (this.pattern = e.slice(n)), this.negate = t;
|
|
1135
|
+
}
|
|
1136
|
+
// set partial to true to test if, for example,
|
|
1137
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
1138
|
+
// Partial means, if you run out of file before you run
|
|
1139
|
+
// out of pattern, then that's fine, as long as all
|
|
1140
|
+
// the parts match.
|
|
1141
|
+
matchOne(e, t, n = !1) {
|
|
1142
|
+
const r = this.options;
|
|
1143
|
+
if (this.isWindows) {
|
|
1144
|
+
const d = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), x = !d && e[0] === "" && e[1] === "" && e[2] === "?" && /^[a-z]:$/i.test(e[3]), N = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), v = !N && t[0] === "" && t[1] === "" && t[2] === "?" && typeof t[3] == "string" && /^[a-z]:$/i.test(t[3]), S = x ? 3 : d ? 0 : void 0, w = v ? 3 : N ? 0 : void 0;
|
|
1145
|
+
if (typeof S == "number" && typeof w == "number") {
|
|
1146
|
+
const [$, I] = [e[S], t[w]];
|
|
1147
|
+
$.toLowerCase() === I.toLowerCase() && (t[w] = $, w > S ? t = t.slice(w) : S > w && (e = e.slice(S)));
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const { optimizationLevel: i = 1 } = this.options;
|
|
1151
|
+
i >= 2 && (e = this.levelTwoFileOptimize(e)), this.debug("matchOne", this, { file: e, pattern: t }), this.debug("matchOne", e.length, t.length);
|
|
1152
|
+
for (var o = 0, a = 0, l = e.length, h = t.length; o < l && a < h; o++, a++) {
|
|
1153
|
+
this.debug("matchOne loop");
|
|
1154
|
+
var c = t[a], p = e[o];
|
|
1155
|
+
if (this.debug(t, c, p), c === !1)
|
|
1156
|
+
return !1;
|
|
1157
|
+
if (c === A) {
|
|
1158
|
+
this.debug("GLOBSTAR", [t, c, p]);
|
|
1159
|
+
var f = o, u = a + 1;
|
|
1160
|
+
if (u === h) {
|
|
1161
|
+
for (this.debug("** at the end"); o < l; o++)
|
|
1162
|
+
if (e[o] === "." || e[o] === ".." || !r.dot && e[o].charAt(0) === ".")
|
|
1163
|
+
return !1;
|
|
1164
|
+
return !0;
|
|
1165
|
+
}
|
|
1166
|
+
for (; f < l; ) {
|
|
1167
|
+
var g = e[f];
|
|
1168
|
+
if (this.debug(`
|
|
1169
|
+
globstar while`, e, f, t, u, g), this.matchOne(e.slice(f), t.slice(u), n))
|
|
1170
|
+
return this.debug("globstar found match!", f, l, g), !0;
|
|
1171
|
+
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1172
|
+
this.debug("dot detected!", e, f, t, u);
|
|
1173
|
+
break;
|
|
1174
|
+
}
|
|
1175
|
+
this.debug("globstar swallow a segment, and continue"), f++;
|
|
1176
|
+
}
|
|
1177
|
+
return !!(n && (this.debug(`
|
|
1178
|
+
>>> no match, partial?`, e, f, t, u), f === l));
|
|
1179
|
+
}
|
|
1180
|
+
let d;
|
|
1181
|
+
if (typeof c == "string" ? (d = p === c, this.debug("string match", c, p, d)) : (d = c.test(p), this.debug("pattern match", c, p, d)), !d)
|
|
1182
|
+
return !1;
|
|
1183
|
+
}
|
|
1184
|
+
if (o === l && a === h)
|
|
1185
|
+
return !0;
|
|
1186
|
+
if (o === l)
|
|
1187
|
+
return n;
|
|
1188
|
+
if (a === h)
|
|
1189
|
+
return o === l - 1 && e[o] === "";
|
|
1190
|
+
throw new Error("wtf?");
|
|
1191
|
+
}
|
|
1192
|
+
braceExpand() {
|
|
1193
|
+
return ie(this.pattern, this.options);
|
|
1194
|
+
}
|
|
1195
|
+
parse(e) {
|
|
1196
|
+
C(e);
|
|
1197
|
+
const t = this.options;
|
|
1198
|
+
if (e === "**")
|
|
1199
|
+
return A;
|
|
1200
|
+
if (e === "")
|
|
1201
|
+
return "";
|
|
1202
|
+
let n, r = null;
|
|
1203
|
+
(n = e.match(lt)) ? r = t.dot ? ut : ht : (n = e.match(Qe)) ? r = (t.nocase ? t.dot ? nt : st : t.dot ? tt : et)(n[1]) : (n = e.match(ft)) ? r = (t.nocase ? t.dot ? dt : pt : t.dot ? gt : mt)(n) : (n = e.match(rt)) ? r = t.dot ? ot : it : (n = e.match(ct)) && (r = at);
|
|
1204
|
+
const i = y.fromGlob(e, this.options).toMMPattern();
|
|
1205
|
+
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1206
|
+
}
|
|
1207
|
+
makeRe() {
|
|
1208
|
+
if (this.regexp || this.regexp === !1)
|
|
1209
|
+
return this.regexp;
|
|
1210
|
+
const e = this.set;
|
|
1211
|
+
if (!e.length)
|
|
1212
|
+
return this.regexp = !1, this.regexp;
|
|
1213
|
+
const t = this.options, n = t.noglobstar ? yt : t.dot ? xt : St, r = new Set(t.nocase ? ["i"] : []);
|
|
1214
|
+
let i = e.map((l) => {
|
|
1215
|
+
const h = l.map((c) => {
|
|
1216
|
+
if (c instanceof RegExp)
|
|
1217
|
+
for (const p of c.flags.split(""))
|
|
1218
|
+
r.add(p);
|
|
1219
|
+
return typeof c == "string" ? vt(c) : c === A ? A : c._src;
|
|
1220
|
+
});
|
|
1221
|
+
return h.forEach((c, p) => {
|
|
1222
|
+
const f = h[p + 1], u = h[p - 1];
|
|
1223
|
+
c !== A || u === A || (u === void 0 ? f !== void 0 && f !== A ? h[p + 1] = "(?:\\/|" + n + "\\/)?" + f : h[p] = n : f === void 0 ? h[p - 1] = u + "(?:\\/|" + n + ")?" : f !== A && (h[p - 1] = u + "(?:\\/|\\/" + n + "\\/)" + f, h[p + 1] = A));
|
|
1224
|
+
}), h.filter((c) => c !== A).join("/");
|
|
1225
|
+
}).join("|");
|
|
1226
|
+
const [o, a] = e.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1227
|
+
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1228
|
+
try {
|
|
1229
|
+
this.regexp = new RegExp(i, [...r].join(""));
|
|
1230
|
+
} catch {
|
|
1231
|
+
this.regexp = !1;
|
|
1232
|
+
}
|
|
1233
|
+
return this.regexp;
|
|
1234
|
+
}
|
|
1235
|
+
slashSplit(e) {
|
|
1236
|
+
return this.preserveMultipleSlashes ? e.split("/") : this.isWindows && /^\/\/[^\/]+/.test(e) ? ["", ...e.split(/\/+/)] : e.split(/\/+/);
|
|
1237
|
+
}
|
|
1238
|
+
match(e, t = this.partial) {
|
|
1239
|
+
if (this.debug("match", e, this.pattern), this.comment)
|
|
1240
|
+
return !1;
|
|
1241
|
+
if (this.empty)
|
|
1242
|
+
return e === "";
|
|
1243
|
+
if (e === "/" && t)
|
|
1244
|
+
return !0;
|
|
1245
|
+
const n = this.options;
|
|
1246
|
+
this.isWindows && (e = e.split("\\").join("/"));
|
|
1247
|
+
const r = this.slashSplit(e);
|
|
1248
|
+
this.debug(this.pattern, "split", r);
|
|
1249
|
+
const i = this.set;
|
|
1250
|
+
this.debug(this.pattern, "set", i);
|
|
1251
|
+
let o = r[r.length - 1];
|
|
1252
|
+
if (!o)
|
|
1253
|
+
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1254
|
+
o = r[a];
|
|
1255
|
+
for (let a = 0; a < i.length; a++) {
|
|
1256
|
+
const l = i[a];
|
|
1257
|
+
let h = r;
|
|
1258
|
+
if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, t))
|
|
1259
|
+
return n.flipNegate ? !0 : !this.negate;
|
|
1260
|
+
}
|
|
1261
|
+
return n.flipNegate ? !1 : this.negate;
|
|
1262
|
+
}
|
|
1263
|
+
static defaults(e) {
|
|
1264
|
+
return E.defaults(e).Minimatch;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
E.AST = y;
|
|
1268
|
+
E.Minimatch = D;
|
|
1269
|
+
E.escape = Ke;
|
|
1270
|
+
E.unescape = P;
|
|
1271
|
+
function Ut() {
|
|
1272
|
+
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1273
|
+
throw new he();
|
|
1274
|
+
}
|
|
1275
|
+
async function $t(s, e, t) {
|
|
1276
|
+
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: e }, t) : t();
|
|
1277
|
+
}
|
|
1278
|
+
function U(s) {
|
|
1279
|
+
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1280
|
+
}
|
|
1281
|
+
function oe(s) {
|
|
1282
|
+
return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
|
|
1283
|
+
}
|
|
1284
|
+
function ce(s) {
|
|
1285
|
+
const e = U(s);
|
|
1286
|
+
return e[e.length - 1] || "";
|
|
1287
|
+
}
|
|
1288
|
+
function Wt(s) {
|
|
1289
|
+
const e = U(s);
|
|
1290
|
+
return e.pop(), oe(e);
|
|
1291
|
+
}
|
|
1292
|
+
function ae(s) {
|
|
1293
|
+
return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
|
|
1294
|
+
}
|
|
1295
|
+
function zt(s, e = !1) {
|
|
1296
|
+
return s = s.replace(/\/$/, ""), e && !s.includes("*") ? `${s}/**` : s;
|
|
1297
|
+
}
|
|
1298
|
+
function Bt(s, e) {
|
|
1299
|
+
return E(s, e, {
|
|
1300
|
+
dot: !0,
|
|
1301
|
+
matchBase: !0
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
function _t(s, e) {
|
|
1305
|
+
if (!e || Array.isArray(e) && e.length === 0)
|
|
1306
|
+
return !1;
|
|
1307
|
+
const t = ae(s);
|
|
1308
|
+
return (Array.isArray(e) ? e : [e]).some((r) => E(t, r, { dot: !0 }));
|
|
1309
|
+
}
|
|
1310
|
+
function qt(s) {
|
|
1311
|
+
const e = ae(s), t = U(e), n = [];
|
|
1312
|
+
for (const r of t)
|
|
1313
|
+
if (!(r === "." || r === ""))
|
|
1314
|
+
if (r === "..") {
|
|
1315
|
+
if (n.length === 0)
|
|
1316
|
+
continue;
|
|
1317
|
+
n.pop();
|
|
1318
|
+
} else
|
|
1319
|
+
n.push(r);
|
|
1320
|
+
return oe(n);
|
|
1321
|
+
}
|
|
1322
|
+
function Gt(s) {
|
|
1323
|
+
const e = ce(s), t = e.lastIndexOf(".");
|
|
1324
|
+
return t <= 0 || t === e.length - 1 ? "" : e.slice(t);
|
|
1325
|
+
}
|
|
1326
|
+
function Ht(s, e = "utf-8") {
|
|
1327
|
+
return typeof s == "string" ? Ee(s, e) : s instanceof Uint8Array ? s : new Uint8Array(s);
|
|
1328
|
+
}
|
|
1329
|
+
async function Vt(s, e = "SHA-1", t = 50 * 1024 * 1024) {
|
|
1330
|
+
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > t)
|
|
1331
|
+
throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${t} bytes`);
|
|
1332
|
+
const n = new Uint8Array(s), r = await crypto.subtle.digest(e, n);
|
|
1333
|
+
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1334
|
+
}
|
|
1335
|
+
function Yt(s, e) {
|
|
1336
|
+
if (s.length !== e.length)
|
|
1337
|
+
return !1;
|
|
1338
|
+
for (let t = 0; t < s.length; t++)
|
|
1339
|
+
if (s[t] !== e[t])
|
|
1340
|
+
return !1;
|
|
1341
|
+
return !0;
|
|
1342
|
+
}
|
|
1343
|
+
async function Zt(s) {
|
|
1344
|
+
const e = await s.arrayBuffer();
|
|
1345
|
+
return new Uint8Array(e);
|
|
1346
|
+
}
|
|
1347
|
+
async function Jt(s, e, t = {}) {
|
|
1348
|
+
const n = ce(e);
|
|
1349
|
+
return $t(e, "exclusive", async () => {
|
|
1350
|
+
const r = t.recursive ?? !1, i = t.force ?? !1;
|
|
1351
|
+
try {
|
|
1352
|
+
await s.removeEntry(n, { recursive: r });
|
|
1353
|
+
} catch (o) {
|
|
1354
|
+
if (o.name === "NotFoundError") {
|
|
1355
|
+
if (!i)
|
|
1356
|
+
throw new Z("file", e, o);
|
|
1357
|
+
} else throw o.name === "InvalidModificationError" ? new z("clear", e, o) : o.name === "TypeMismatchError" && !r ? new F("file", "directory", e, o) : new z("remove", e, o);
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
function Xt(s, e, t, n) {
|
|
1362
|
+
if (!Number.isInteger(e) || !Number.isInteger(t))
|
|
1363
|
+
throw new b("argument", "Invalid offset or length");
|
|
1364
|
+
if (e < 0 || t < 0)
|
|
1365
|
+
throw new b("argument", "Negative offset or length not allowed");
|
|
1366
|
+
if (e + t > s)
|
|
1367
|
+
throw new b("overflow", "Operation would overflow buffer");
|
|
1368
|
+
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1369
|
+
throw new b("argument", "Invalid position");
|
|
1370
|
+
}
|
|
1371
|
+
function Kt(s, e, t) {
|
|
1372
|
+
try {
|
|
1373
|
+
e.flush(), e.close();
|
|
1374
|
+
} catch (n) {
|
|
1375
|
+
console.warn(`Warning: Failed to properly close file descriptor ${s} (${t}):`, n);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function Qt(s, e, t) {
|
|
1379
|
+
if (s >= t)
|
|
1380
|
+
return { isEOF: !0, actualLength: 0 };
|
|
1381
|
+
const n = Math.min(e, t - s);
|
|
1382
|
+
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1383
|
+
}
|
|
1384
|
+
async function es(s, e) {
|
|
1385
|
+
try {
|
|
1386
|
+
return await s.createSyncAccessHandle();
|
|
1387
|
+
} catch (t) {
|
|
1388
|
+
throw me(t, { path: e, isDirectory: !1 });
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
export {
|
|
1392
|
+
Ct as A,
|
|
1393
|
+
Vt as B,
|
|
1394
|
+
Yt as C,
|
|
1395
|
+
z as D,
|
|
1396
|
+
Z as E,
|
|
1397
|
+
pe as F,
|
|
1398
|
+
Zt as G,
|
|
1399
|
+
Jt as H,
|
|
1400
|
+
W as I,
|
|
1401
|
+
Xt as J,
|
|
1402
|
+
Kt as K,
|
|
1403
|
+
Qt as L,
|
|
1404
|
+
es as M,
|
|
1405
|
+
we as N,
|
|
1406
|
+
m as O,
|
|
1407
|
+
Tt as P,
|
|
1408
|
+
fe as S,
|
|
1409
|
+
Rt as T,
|
|
1410
|
+
b as V,
|
|
1411
|
+
Ae as W,
|
|
1412
|
+
he as a,
|
|
1413
|
+
ue as b,
|
|
1414
|
+
F as c,
|
|
1415
|
+
Ft as d,
|
|
1416
|
+
Ee as e,
|
|
1417
|
+
de as f,
|
|
1418
|
+
ge as g,
|
|
1419
|
+
Pt as h,
|
|
1420
|
+
Lt as i,
|
|
1421
|
+
It as j,
|
|
1422
|
+
Mt as k,
|
|
1423
|
+
Dt as l,
|
|
1424
|
+
me as m,
|
|
1425
|
+
Ut as n,
|
|
1426
|
+
oe as o,
|
|
1427
|
+
ce as p,
|
|
1428
|
+
Wt as q,
|
|
1429
|
+
ae as r,
|
|
1430
|
+
U as s,
|
|
1431
|
+
zt as t,
|
|
1432
|
+
Bt as u,
|
|
1433
|
+
_t as v,
|
|
1434
|
+
$t as w,
|
|
1435
|
+
qt as x,
|
|
1436
|
+
Gt as y,
|
|
1437
|
+
Ht as z
|
|
1438
|
+
};
|
|
1439
|
+
//# sourceMappingURL=helpers-BuGfPAg0.js.map
|