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
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-CF7A2WQG.cjs"),l=`/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
canHandle: (s) =>
|
|
6
|
+
const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), J = Symbol("Comlink.finalizer"), U = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", _t = {
|
|
7
|
+
canHandle: (s) => Ot(s) && s[bt],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return ot(s, t), [e, [e]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(s) {
|
|
13
|
-
return s.start(),
|
|
13
|
+
return s.start(), Gt(s);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (s) =>
|
|
15
|
+
}, jt = {
|
|
16
|
+
canHandle: (s) => Ot(s) && U in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
19
19
|
return s instanceof Error ? t = {
|
|
@@ -28,25 +28,25 @@ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol
|
|
|
28
28
|
deserialize(s) {
|
|
29
29
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
31
|
+
}, Dt = /* @__PURE__ */ new Map([
|
|
32
|
+
["proxy", _t],
|
|
33
|
+
["throw", jt]
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
35
|
+
function Ut(s, t) {
|
|
36
36
|
for (const e of s)
|
|
37
37
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
38
38
|
return !0;
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
t.addEventListener("message", function n(
|
|
43
|
-
if (!
|
|
41
|
+
function ot(s, t = globalThis, e = ["*"]) {
|
|
42
|
+
t.addEventListener("message", function n(r) {
|
|
43
|
+
if (!r || !r.data)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
46
|
-
console.warn(\`Invalid origin '\${
|
|
45
|
+
if (!Ut(e, r.origin)) {
|
|
46
|
+
console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id:
|
|
49
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
|
|
50
50
|
let h;
|
|
51
51
|
try {
|
|
52
52
|
const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
@@ -55,7 +55,7 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
55
55
|
h = f;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
c[a.slice(-1)[0]] =
|
|
58
|
+
c[a.slice(-1)[0]] = C(r.data.value), h = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
61
|
h = f.apply(c, l);
|
|
@@ -63,13 +63,13 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
65
|
const u = new f(...l);
|
|
66
|
-
h =
|
|
66
|
+
h = Zt(u);
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: u, port2: d } = new MessageChannel();
|
|
72
|
-
|
|
72
|
+
ot(s, d), h = B(u, [u]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -79,145 +79,145 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
} catch (c) {
|
|
82
|
-
h = { value: c, [
|
|
82
|
+
h = { value: c, [U]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
85
|
-
const [f, u] =
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
84
|
+
Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
|
|
85
|
+
const [f, u] = Y(c);
|
|
86
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), J in s && typeof s[J] == "function" && s[J]());
|
|
87
87
|
}).catch((c) => {
|
|
88
|
-
const [f, u] =
|
|
88
|
+
const [f, u] = Y({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
90
|
+
[U]: 0
|
|
91
91
|
});
|
|
92
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
92
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
93
93
|
});
|
|
94
94
|
}), t.start && t.start();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function Bt(s) {
|
|
97
97
|
return s.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function vt(s) {
|
|
100
|
+
Bt(s) && s.close();
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Gt(s, t) {
|
|
103
103
|
const e = /* @__PURE__ */ new Map();
|
|
104
|
-
return s.addEventListener("message", function(
|
|
105
|
-
const { data:
|
|
106
|
-
if (!
|
|
104
|
+
return s.addEventListener("message", function(r) {
|
|
105
|
+
const { data: i } = r;
|
|
106
|
+
if (!i || !i.id)
|
|
107
107
|
return;
|
|
108
|
-
const o = e.get(
|
|
108
|
+
const o = e.get(i.id);
|
|
109
109
|
if (o)
|
|
110
110
|
try {
|
|
111
|
-
o(
|
|
111
|
+
o(i);
|
|
112
112
|
} finally {
|
|
113
|
-
e.delete(
|
|
113
|
+
e.delete(i.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), nt(s, e, [], t);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function W(s) {
|
|
118
118
|
if (s)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function At(s) {
|
|
122
|
+
return $(s, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
vt(s);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
128
|
+
const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
129
|
+
const t = (q.get(s) || 0) - 1;
|
|
130
|
+
q.set(s, t), t === 0 && At(s);
|
|
131
131
|
});
|
|
132
|
-
function
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
132
|
+
function qt(s, t) {
|
|
133
|
+
const e = (q.get(t) || 0) + 1;
|
|
134
|
+
q.set(t, e), V && V.register(s, t, s);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function Vt(s) {
|
|
137
|
+
V && V.unregister(s);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function nt(s, t, e = [], n = function() {
|
|
140
140
|
}) {
|
|
141
|
-
let
|
|
142
|
-
const
|
|
141
|
+
let r = !1;
|
|
142
|
+
const i = new Proxy(n, {
|
|
143
143
|
get(o, a) {
|
|
144
|
-
if (
|
|
144
|
+
if (W(r), a === Wt)
|
|
145
145
|
return () => {
|
|
146
|
-
|
|
146
|
+
Vt(i), At(s), t.clear(), r = !0;
|
|
147
147
|
};
|
|
148
148
|
if (a === "then") {
|
|
149
149
|
if (e.length === 0)
|
|
150
|
-
return { then: () =>
|
|
151
|
-
const l =
|
|
150
|
+
return { then: () => i };
|
|
151
|
+
const l = $(s, t, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: e.map((h) => h.toString())
|
|
154
|
-
}).then(
|
|
154
|
+
}).then(C);
|
|
155
155
|
return l.then.bind(l);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return nt(s, t, [...e, a]);
|
|
158
158
|
},
|
|
159
159
|
set(o, a, l) {
|
|
160
|
-
|
|
161
|
-
const [h, c] =
|
|
162
|
-
return
|
|
160
|
+
W(r);
|
|
161
|
+
const [h, c] = Y(l);
|
|
162
|
+
return $(s, t, {
|
|
163
163
|
type: "SET",
|
|
164
164
|
path: [...e, a].map((f) => f.toString()),
|
|
165
165
|
value: h
|
|
166
|
-
}, c).then(
|
|
166
|
+
}, c).then(C);
|
|
167
167
|
},
|
|
168
168
|
apply(o, a, l) {
|
|
169
|
-
|
|
169
|
+
W(r);
|
|
170
170
|
const h = e[e.length - 1];
|
|
171
|
-
if (h ===
|
|
172
|
-
return
|
|
171
|
+
if (h === Ht)
|
|
172
|
+
return $(s, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
174
|
+
}).then(C);
|
|
175
175
|
if (h === "bind")
|
|
176
|
-
return
|
|
177
|
-
const [c, f] =
|
|
178
|
-
return
|
|
176
|
+
return nt(s, t, e.slice(0, -1));
|
|
177
|
+
const [c, f] = ht(l);
|
|
178
|
+
return $(s, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: e.map((u) => u.toString()),
|
|
181
181
|
argumentList: c
|
|
182
|
-
}, f).then(
|
|
182
|
+
}, f).then(C);
|
|
183
183
|
},
|
|
184
184
|
construct(o, a) {
|
|
185
|
-
|
|
186
|
-
const [l, h] =
|
|
187
|
-
return
|
|
185
|
+
W(r);
|
|
186
|
+
const [l, h] = ht(a);
|
|
187
|
+
return $(s, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
189
|
path: e.map((c) => c.toString()),
|
|
190
190
|
argumentList: l
|
|
191
|
-
}, h).then(
|
|
191
|
+
}, h).then(C);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
return
|
|
194
|
+
return qt(i, s), i;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Yt(s) {
|
|
197
197
|
return Array.prototype.concat.apply([], s);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const t = s.map(
|
|
201
|
-
return [t.map((e) => e[0]),
|
|
199
|
+
function ht(s) {
|
|
200
|
+
const t = s.map(Y);
|
|
201
|
+
return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
|
|
202
202
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
203
|
+
const Nt = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function B(s, t) {
|
|
205
|
+
return Nt.set(s, t), s;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(s, { [
|
|
207
|
+
function Zt(s) {
|
|
208
|
+
return Object.assign(s, { [bt]: !0 });
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (const [t, e] of
|
|
210
|
+
function Y(s) {
|
|
211
|
+
for (const [t, e] of Dt)
|
|
212
212
|
if (e.canHandle(s)) {
|
|
213
|
-
const [n,
|
|
213
|
+
const [n, r] = e.serialize(s);
|
|
214
214
|
return [
|
|
215
215
|
{
|
|
216
216
|
type: "HANDLER",
|
|
217
217
|
name: t,
|
|
218
218
|
value: n
|
|
219
219
|
},
|
|
220
|
-
|
|
220
|
+
r
|
|
221
221
|
];
|
|
222
222
|
}
|
|
223
223
|
return [
|
|
@@ -225,178 +225,294 @@ function B(s) {
|
|
|
225
225
|
type: "RAW",
|
|
226
226
|
value: s
|
|
227
227
|
},
|
|
228
|
-
|
|
228
|
+
Nt.get(s) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function C(s) {
|
|
232
232
|
switch (s.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
|
-
return
|
|
234
|
+
return Dt.get(s.name).deserialize(s.value);
|
|
235
235
|
case "RAW":
|
|
236
236
|
return s.value;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return new Promise((
|
|
241
|
-
const
|
|
242
|
-
t.set(
|
|
239
|
+
function $(s, t, e, n) {
|
|
240
|
+
return new Promise((r) => {
|
|
241
|
+
const i = Xt();
|
|
242
|
+
t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Xt() {
|
|
246
246
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
247
|
}
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
|
|
249
|
+
const Jt = {
|
|
250
|
+
ENOENT: -2,
|
|
251
|
+
// No such file or directory
|
|
252
|
+
EISDIR: -21,
|
|
253
|
+
// Is a directory
|
|
254
|
+
ENOTDIR: -20,
|
|
255
|
+
// Not a directory
|
|
256
|
+
EACCES: -13,
|
|
257
|
+
// Permission denied
|
|
258
|
+
EEXIST: -17,
|
|
259
|
+
// File exists
|
|
260
|
+
ENOTEMPTY: -39,
|
|
261
|
+
// Directory not empty
|
|
262
|
+
EINVAL: -22,
|
|
263
|
+
// Invalid argument
|
|
264
|
+
EIO: -5,
|
|
265
|
+
// I/O error
|
|
266
|
+
ENOSPC: -28,
|
|
267
|
+
// No space left on device
|
|
268
|
+
EBUSY: -16,
|
|
269
|
+
// Device or resource busy
|
|
270
|
+
EINTR: -4,
|
|
271
|
+
// Interrupted system call
|
|
272
|
+
ENOTSUP: -95,
|
|
273
|
+
// Operation not supported
|
|
274
|
+
ERANGE: -34,
|
|
275
|
+
// Result too large
|
|
276
|
+
EBADF: -9,
|
|
277
|
+
// Bad file descriptor
|
|
278
|
+
EROOT: -1
|
|
279
|
+
// Custom: Cannot remove root directory
|
|
280
|
+
};
|
|
281
|
+
class w extends Error {
|
|
282
|
+
errno;
|
|
283
|
+
syscall;
|
|
284
|
+
path;
|
|
285
|
+
constructor(t, e, n, r, i) {
|
|
286
|
+
super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
|
|
252
287
|
}
|
|
253
288
|
}
|
|
254
|
-
class
|
|
289
|
+
class Qt extends w {
|
|
255
290
|
constructor(t) {
|
|
256
|
-
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
|
|
291
|
+
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, void 0, t);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
class Kt extends w {
|
|
295
|
+
constructor(t, e, n) {
|
|
296
|
+
super(t, "INVALID_PATH", e, "access", n);
|
|
257
297
|
}
|
|
258
298
|
}
|
|
259
|
-
class
|
|
299
|
+
class F extends w {
|
|
260
300
|
constructor(t, e, n) {
|
|
261
|
-
|
|
301
|
+
const r = {
|
|
302
|
+
file: \`File not found: \${e}\`,
|
|
303
|
+
directory: \`Directory not found: \${e}\`,
|
|
304
|
+
source: \`Source does not exist: \${e}\`
|
|
305
|
+
};
|
|
306
|
+
super(r[t], "ENOENT", e, "access", n);
|
|
262
307
|
}
|
|
263
308
|
}
|
|
264
|
-
class
|
|
309
|
+
class te extends w {
|
|
310
|
+
constructor(t, e, n) {
|
|
311
|
+
super(\`Permission denied for \${e} on: \${t}\`, "PERMISSION_DENIED", t, e, n);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
class ee extends w {
|
|
315
|
+
constructor(t, e, n) {
|
|
316
|
+
super(t, "ENOSPC", e, "write", n);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
class se extends w {
|
|
265
320
|
constructor(t, e) {
|
|
266
|
-
super(\`File
|
|
321
|
+
super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
|
|
267
322
|
}
|
|
268
323
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
324
|
+
class L extends w {
|
|
325
|
+
constructor(t, e, n, r) {
|
|
326
|
+
const i = e === "directory" ? \`Is a directory: \${n}\` : \`Not a directory: \${n}\`, o = e === "directory" ? "EISDIR" : "ENOTDIR";
|
|
327
|
+
super(i, o, n, "access", r);
|
|
328
|
+
}
|
|
272
329
|
}
|
|
273
|
-
|
|
274
|
-
|
|
330
|
+
class N extends w {
|
|
331
|
+
constructor(t, e, n, r) {
|
|
332
|
+
const i = {
|
|
333
|
+
argument: "EINVAL",
|
|
334
|
+
format: "INVALID_FORMAT",
|
|
335
|
+
descriptor: "EBADF",
|
|
336
|
+
overflow: "ERANGE"
|
|
337
|
+
};
|
|
338
|
+
super(e, i[t], n, "validate", r);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class ne extends w {
|
|
342
|
+
constructor(t, e) {
|
|
343
|
+
super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
class ut extends w {
|
|
347
|
+
constructor(t, e, n) {
|
|
348
|
+
super(t, "EIO", e, "io", n);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
class Ct extends w {
|
|
352
|
+
constructor(t, e) {
|
|
353
|
+
super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class rt extends w {
|
|
357
|
+
constructor(t, e, n) {
|
|
358
|
+
const r = {
|
|
359
|
+
remove: \`Failed to remove entry: \${e}\`,
|
|
360
|
+
clear: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
|
|
361
|
+
root: "Cannot remove root directory"
|
|
362
|
+
}, i = {
|
|
363
|
+
remove: "RM_FAILED",
|
|
364
|
+
clear: "ENOTEMPTY",
|
|
365
|
+
root: "EROOT"
|
|
366
|
+
};
|
|
367
|
+
super(r[t], i[t], e, "unlink", n);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
class re extends w {
|
|
371
|
+
constructor(t, e) {
|
|
372
|
+
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
class Q extends w {
|
|
376
|
+
constructor(t, e, n) {
|
|
377
|
+
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
class K extends w {
|
|
381
|
+
constructor(t, e) {
|
|
382
|
+
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function _(s, t, e, n) {
|
|
386
|
+
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
387
|
+
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
388
|
+
}
|
|
389
|
+
function A(s, t) {
|
|
390
|
+
const e = t?.path, n = t?.isDirectory;
|
|
275
391
|
switch (s.name) {
|
|
276
392
|
case "InvalidStateError":
|
|
277
|
-
return new
|
|
393
|
+
return new se(e || "unknown", s);
|
|
278
394
|
case "QuotaExceededError":
|
|
279
|
-
return new
|
|
395
|
+
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
280
396
|
case "NotFoundError":
|
|
281
|
-
return new
|
|
397
|
+
return new F("file", e, s);
|
|
282
398
|
case "TypeMismatchError":
|
|
283
|
-
return new
|
|
399
|
+
return n !== void 0 ? n ? new L("file", "directory", e || "unknown", s) : new L("directory", "file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
284
400
|
case "NotAllowedError":
|
|
285
401
|
case "SecurityError":
|
|
286
|
-
return new
|
|
402
|
+
return new te(e, "unknown", s);
|
|
287
403
|
case "InvalidModificationError":
|
|
288
|
-
return new
|
|
404
|
+
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
289
405
|
case "AbortError":
|
|
290
|
-
return new
|
|
406
|
+
return new ne(e || "unknown", s);
|
|
291
407
|
case "OperationError":
|
|
292
|
-
return new
|
|
408
|
+
return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
|
|
293
409
|
case "TypeError":
|
|
294
|
-
return new
|
|
410
|
+
return new Ct(e || "unknown", s);
|
|
295
411
|
default:
|
|
296
|
-
return new
|
|
412
|
+
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
297
413
|
}
|
|
298
414
|
}
|
|
299
|
-
const
|
|
300
|
-
const n = s instanceof RegExp ?
|
|
301
|
-
return
|
|
302
|
-
start:
|
|
303
|
-
end:
|
|
304
|
-
pre: e.slice(0,
|
|
305
|
-
body: e.slice(
|
|
306
|
-
post: e.slice(
|
|
415
|
+
const Ft = (s, t, e) => {
|
|
416
|
+
const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
|
|
417
|
+
return i && {
|
|
418
|
+
start: i[0],
|
|
419
|
+
end: i[1],
|
|
420
|
+
pre: e.slice(0, i[0]),
|
|
421
|
+
body: e.slice(i[0] + n.length, i[1]),
|
|
422
|
+
post: e.slice(i[1] + r.length)
|
|
307
423
|
};
|
|
308
|
-
},
|
|
424
|
+
}, ft = (s, t) => {
|
|
309
425
|
const e = t.match(s);
|
|
310
426
|
return e ? e[0] : null;
|
|
311
|
-
},
|
|
312
|
-
let n,
|
|
427
|
+
}, ie = (s, t, e) => {
|
|
428
|
+
let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
313
429
|
if (l >= 0 && h > 0) {
|
|
314
430
|
if (s === t)
|
|
315
431
|
return [l, h];
|
|
316
|
-
for (n = [],
|
|
432
|
+
for (n = [], i = e.length; c >= 0 && !a; ) {
|
|
317
433
|
if (c === l)
|
|
318
434
|
n.push(c), l = e.indexOf(s, c + 1);
|
|
319
435
|
else if (n.length === 1) {
|
|
320
436
|
const f = n.pop();
|
|
321
437
|
f !== void 0 && (a = [f, h]);
|
|
322
438
|
} else
|
|
323
|
-
|
|
439
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
|
|
324
440
|
c = l < h && l >= 0 ? l : h;
|
|
325
441
|
}
|
|
326
|
-
n.length && o !== void 0 && (a = [
|
|
442
|
+
n.length && o !== void 0 && (a = [i, o]);
|
|
327
443
|
}
|
|
328
444
|
return a;
|
|
329
|
-
},
|
|
330
|
-
function
|
|
445
|
+
}, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Pt = "\\0COMMA" + Math.random() + "\\0", Tt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Pt, "g"), he = new RegExp(Tt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
|
|
446
|
+
function tt(s) {
|
|
331
447
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
332
448
|
}
|
|
333
|
-
function
|
|
334
|
-
return s.replace(
|
|
449
|
+
function we(s) {
|
|
450
|
+
return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
|
|
335
451
|
}
|
|
336
|
-
function
|
|
337
|
-
return s.replace(
|
|
452
|
+
function me(s) {
|
|
453
|
+
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
338
454
|
}
|
|
339
|
-
function
|
|
455
|
+
function Rt(s) {
|
|
340
456
|
if (!s)
|
|
341
457
|
return [""];
|
|
342
|
-
const t = [], e =
|
|
458
|
+
const t = [], e = Ft("{", "}", s);
|
|
343
459
|
if (!e)
|
|
344
460
|
return s.split(",");
|
|
345
|
-
const { pre: n, body:
|
|
346
|
-
o[o.length - 1] += "{" +
|
|
347
|
-
const a =
|
|
348
|
-
return
|
|
461
|
+
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
462
|
+
o[o.length - 1] += "{" + r + "}";
|
|
463
|
+
const a = Rt(i);
|
|
464
|
+
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
349
465
|
}
|
|
350
|
-
function
|
|
351
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(
|
|
466
|
+
function ye(s) {
|
|
467
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
|
|
352
468
|
}
|
|
353
|
-
function
|
|
469
|
+
function Ee(s) {
|
|
354
470
|
return "{" + s + "}";
|
|
355
471
|
}
|
|
356
|
-
function
|
|
472
|
+
function Se(s) {
|
|
357
473
|
return /^-?0\\d/.test(s);
|
|
358
474
|
}
|
|
359
|
-
function
|
|
475
|
+
function xe(s, t) {
|
|
360
476
|
return s <= t;
|
|
361
477
|
}
|
|
362
|
-
function
|
|
478
|
+
function be(s, t) {
|
|
363
479
|
return s >= t;
|
|
364
480
|
}
|
|
365
481
|
function I(s, t) {
|
|
366
|
-
const e = [], n =
|
|
482
|
+
const e = [], n = Ft("{", "}", s);
|
|
367
483
|
if (!n)
|
|
368
484
|
return [s];
|
|
369
|
-
const
|
|
485
|
+
const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
|
|
370
486
|
if (/\\$$/.test(n.pre))
|
|
371
|
-
for (let o = 0; o <
|
|
372
|
-
const a =
|
|
487
|
+
for (let o = 0; o < i.length; o++) {
|
|
488
|
+
const a = r + "{" + n.body + "}" + i[o];
|
|
373
489
|
e.push(a);
|
|
374
490
|
}
|
|
375
491
|
else {
|
|
376
492
|
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;
|
|
377
493
|
if (!l && !h)
|
|
378
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
494
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
|
|
379
495
|
let c;
|
|
380
496
|
if (l)
|
|
381
497
|
c = n.body.split(/\\.\\./);
|
|
382
|
-
else if (c =
|
|
383
|
-
return
|
|
498
|
+
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
|
|
499
|
+
return i.map((u) => n.pre + c[0] + u);
|
|
384
500
|
let f;
|
|
385
501
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
386
|
-
const u =
|
|
387
|
-
let
|
|
388
|
-
d < u && (
|
|
389
|
-
const
|
|
502
|
+
const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
503
|
+
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
|
|
504
|
+
d < u && (p *= -1, S = be);
|
|
505
|
+
const P = c.some(Se);
|
|
390
506
|
f = [];
|
|
391
|
-
for (let x = u; S(x, d); x +=
|
|
507
|
+
for (let x = u; S(x, d); x += p) {
|
|
392
508
|
let m;
|
|
393
509
|
if (a)
|
|
394
510
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
395
|
-
else if (m = String(x),
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
const
|
|
399
|
-
x < 0 ? m = "-" +
|
|
511
|
+
else if (m = String(x), P) {
|
|
512
|
+
const T = g - m.length;
|
|
513
|
+
if (T > 0) {
|
|
514
|
+
const H = new Array(T + 1).join("0");
|
|
515
|
+
x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
|
|
400
516
|
}
|
|
401
517
|
}
|
|
402
518
|
f.push(m);
|
|
@@ -407,19 +523,19 @@ function I(s, t) {
|
|
|
407
523
|
f.push.apply(f, I(c[u], !1));
|
|
408
524
|
}
|
|
409
525
|
for (let u = 0; u < f.length; u++)
|
|
410
|
-
for (let d = 0; d <
|
|
411
|
-
const
|
|
412
|
-
(!t || l ||
|
|
526
|
+
for (let d = 0; d < i.length; d++) {
|
|
527
|
+
const g = r + f[u] + i[d];
|
|
528
|
+
(!t || l || g) && e.push(g);
|
|
413
529
|
}
|
|
414
530
|
}
|
|
415
531
|
return e;
|
|
416
532
|
}
|
|
417
|
-
const
|
|
533
|
+
const Oe = 1024 * 64, Z = (s) => {
|
|
418
534
|
if (typeof s != "string")
|
|
419
535
|
throw new TypeError("invalid pattern");
|
|
420
|
-
if (s.length >
|
|
536
|
+
if (s.length > Oe)
|
|
421
537
|
throw new TypeError("pattern is too long");
|
|
422
|
-
},
|
|
538
|
+
}, De = {
|
|
423
539
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
424
540
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
425
541
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -434,77 +550,77 @@ const he = 1024 * 64, G = (s) => {
|
|
|
434
550
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
435
551
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
436
552
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
437
|
-
},
|
|
553
|
+
}, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
|
|
438
554
|
const e = t;
|
|
439
555
|
if (s.charAt(e) !== "[")
|
|
440
556
|
throw new Error("not in a brace expression");
|
|
441
|
-
const n = [],
|
|
442
|
-
let
|
|
443
|
-
t: for (;
|
|
444
|
-
const
|
|
445
|
-
if ((
|
|
446
|
-
h = !0,
|
|
557
|
+
const n = [], r = [];
|
|
558
|
+
let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
|
|
559
|
+
t: for (; i < s.length; ) {
|
|
560
|
+
const p = s.charAt(i);
|
|
561
|
+
if ((p === "!" || p === "^") && i === e + 1) {
|
|
562
|
+
h = !0, i++;
|
|
447
563
|
continue;
|
|
448
564
|
}
|
|
449
|
-
if (
|
|
450
|
-
c =
|
|
565
|
+
if (p === "]" && o && !l) {
|
|
566
|
+
c = i + 1;
|
|
451
567
|
break;
|
|
452
568
|
}
|
|
453
|
-
if (o = !0,
|
|
454
|
-
l = !0,
|
|
569
|
+
if (o = !0, p === "\\\\" && !l) {
|
|
570
|
+
l = !0, i++;
|
|
455
571
|
continue;
|
|
456
572
|
}
|
|
457
|
-
if (
|
|
458
|
-
for (const [S, [
|
|
459
|
-
if (s.startsWith(S,
|
|
573
|
+
if (p === "[" && !l) {
|
|
574
|
+
for (const [S, [v, P, x]] of Object.entries(De))
|
|
575
|
+
if (s.startsWith(S, i)) {
|
|
460
576
|
if (f)
|
|
461
577
|
return ["$.", !1, s.length - e, !0];
|
|
462
|
-
|
|
578
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || P;
|
|
463
579
|
continue t;
|
|
464
580
|
}
|
|
465
581
|
}
|
|
466
582
|
if (l = !1, f) {
|
|
467
|
-
|
|
583
|
+
p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
|
|
468
584
|
continue;
|
|
469
585
|
}
|
|
470
|
-
if (s.startsWith("-]",
|
|
471
|
-
n.push(
|
|
586
|
+
if (s.startsWith("-]", i + 1)) {
|
|
587
|
+
n.push(R(p + "-")), i += 2;
|
|
472
588
|
continue;
|
|
473
589
|
}
|
|
474
|
-
if (s.startsWith("-",
|
|
475
|
-
f =
|
|
590
|
+
if (s.startsWith("-", i + 1)) {
|
|
591
|
+
f = p, i += 2;
|
|
476
592
|
continue;
|
|
477
593
|
}
|
|
478
|
-
n.push(
|
|
594
|
+
n.push(R(p)), i++;
|
|
479
595
|
}
|
|
480
|
-
if (c <
|
|
596
|
+
if (c < i)
|
|
481
597
|
return ["", !1, 0, !1];
|
|
482
|
-
if (!n.length && !
|
|
598
|
+
if (!n.length && !r.length)
|
|
483
599
|
return ["$.", !1, s.length - e, !0];
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
486
|
-
return [
|
|
600
|
+
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
601
|
+
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
602
|
+
return [ve(p), !1, c - e, !1];
|
|
487
603
|
}
|
|
488
|
-
const u = "[" + (h ? "^" : "") +
|
|
489
|
-
return [n.length &&
|
|
490
|
-
},
|
|
604
|
+
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
605
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
606
|
+
}, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
491
607
|
class E {
|
|
492
608
|
type;
|
|
493
609
|
#s;
|
|
494
610
|
#n;
|
|
495
|
-
#
|
|
611
|
+
#i = !1;
|
|
496
612
|
#t = [];
|
|
497
613
|
#e;
|
|
498
614
|
#o;
|
|
499
615
|
#c;
|
|
500
616
|
#a = !1;
|
|
501
|
-
#
|
|
617
|
+
#r;
|
|
502
618
|
#l;
|
|
503
619
|
// set to true if it's an extglob with no children
|
|
504
620
|
// (which really means one child of '')
|
|
505
621
|
#u = !1;
|
|
506
622
|
constructor(t, e, n = {}) {
|
|
507
|
-
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#
|
|
623
|
+
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
|
|
508
624
|
}
|
|
509
625
|
get hasMagic() {
|
|
510
626
|
if (this.#n !== void 0)
|
|
@@ -530,11 +646,11 @@ class E {
|
|
|
530
646
|
continue;
|
|
531
647
|
let e = t, n = e.#e;
|
|
532
648
|
for (; n; ) {
|
|
533
|
-
for (let
|
|
534
|
-
for (const
|
|
535
|
-
if (typeof
|
|
649
|
+
for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
|
|
650
|
+
for (const i of t.#t) {
|
|
651
|
+
if (typeof i == "string")
|
|
536
652
|
throw new Error("string part in extglob AST??");
|
|
537
|
-
|
|
653
|
+
i.copyIn(n.#t[r]);
|
|
538
654
|
}
|
|
539
655
|
e = n, n = e.#e;
|
|
540
656
|
}
|
|
@@ -587,40 +703,40 @@ class E {
|
|
|
587
703
|
e.copyIn(n);
|
|
588
704
|
return e;
|
|
589
705
|
}
|
|
590
|
-
static #h(t, e, n,
|
|
591
|
-
let
|
|
706
|
+
static #h(t, e, n, r) {
|
|
707
|
+
let i = !1, o = !1, a = -1, l = !1;
|
|
592
708
|
if (e.type === null) {
|
|
593
|
-
let d = n,
|
|
709
|
+
let d = n, g = "";
|
|
594
710
|
for (; d < t.length; ) {
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
597
|
-
|
|
711
|
+
const p = t.charAt(d++);
|
|
712
|
+
if (i || p === "\\\\") {
|
|
713
|
+
i = !i, g += p;
|
|
598
714
|
continue;
|
|
599
715
|
}
|
|
600
716
|
if (o) {
|
|
601
|
-
d === a + 1 ? (
|
|
717
|
+
d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
|
|
602
718
|
continue;
|
|
603
|
-
} else if (
|
|
604
|
-
o = !0, a = d, l = !1,
|
|
719
|
+
} else if (p === "[") {
|
|
720
|
+
o = !0, a = d, l = !1, g += p;
|
|
605
721
|
continue;
|
|
606
722
|
}
|
|
607
|
-
if (!
|
|
608
|
-
e.push(
|
|
609
|
-
const S = new E(
|
|
610
|
-
d = E.#h(t, S, d,
|
|
723
|
+
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
724
|
+
e.push(g), g = "";
|
|
725
|
+
const S = new E(p, e);
|
|
726
|
+
d = E.#h(t, S, d, r), e.push(S);
|
|
611
727
|
continue;
|
|
612
728
|
}
|
|
613
|
-
|
|
729
|
+
g += p;
|
|
614
730
|
}
|
|
615
|
-
return e.push(
|
|
731
|
+
return e.push(g), d;
|
|
616
732
|
}
|
|
617
733
|
let h = n + 1, c = new E(null, e);
|
|
618
734
|
const f = [];
|
|
619
735
|
let u = "";
|
|
620
736
|
for (; h < t.length; ) {
|
|
621
737
|
const d = t.charAt(h++);
|
|
622
|
-
if (
|
|
623
|
-
|
|
738
|
+
if (i || d === "\\\\") {
|
|
739
|
+
i = !i, u += d;
|
|
624
740
|
continue;
|
|
625
741
|
}
|
|
626
742
|
if (o) {
|
|
@@ -630,10 +746,10 @@ class E {
|
|
|
630
746
|
o = !0, a = h, l = !1, u += d;
|
|
631
747
|
continue;
|
|
632
748
|
}
|
|
633
|
-
if (
|
|
749
|
+
if (pt(d) && t.charAt(h) === "(") {
|
|
634
750
|
c.push(u), u = "";
|
|
635
|
-
const
|
|
636
|
-
c.push(
|
|
751
|
+
const g = new E(d, c);
|
|
752
|
+
c.push(g), h = E.#h(t, g, h, r);
|
|
637
753
|
continue;
|
|
638
754
|
}
|
|
639
755
|
if (d === "|") {
|
|
@@ -655,17 +771,17 @@ class E {
|
|
|
655
771
|
toMMPattern() {
|
|
656
772
|
if (this !== this.#s)
|
|
657
773
|
return this.#s.toMMPattern();
|
|
658
|
-
const t = this.toString(), [e, n,
|
|
659
|
-
if (!(
|
|
774
|
+
const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
|
|
775
|
+
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
660
776
|
return n;
|
|
661
|
-
const a = (this.#
|
|
777
|
+
const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
662
778
|
return Object.assign(new RegExp(\`^\${e}$\`, a), {
|
|
663
779
|
_src: e,
|
|
664
780
|
_glob: t
|
|
665
781
|
});
|
|
666
782
|
}
|
|
667
783
|
get options() {
|
|
668
|
-
return this.#
|
|
784
|
+
return this.#r;
|
|
669
785
|
}
|
|
670
786
|
// returns the string match, the regexp source, whether there's magic
|
|
671
787
|
// in the regexp (so a regular expression is required) and whether or
|
|
@@ -737,168 +853,168 @@ class E {
|
|
|
737
853
|
// is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
|
|
738
854
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
739
855
|
toRegExpSource(t) {
|
|
740
|
-
const e = t ?? !!this.#
|
|
856
|
+
const e = t ?? !!this.#r.dot;
|
|
741
857
|
if (this.#s === this && this.#d(), !this.type) {
|
|
742
858
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
743
|
-
const [
|
|
744
|
-
return this.#n = this.#n || S, this.#
|
|
859
|
+
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
860
|
+
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
745
861
|
}).join("");
|
|
746
862
|
let c = "";
|
|
747
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
748
|
-
const
|
|
863
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
|
|
864
|
+
const g = Fe, p = (
|
|
749
865
|
// dots are allowed, and the pattern starts with [ or .
|
|
750
|
-
e &&
|
|
751
|
-
h.startsWith("\\\\.") &&
|
|
752
|
-
h.startsWith("\\\\.\\\\.") &&
|
|
753
|
-
), S = !e && !t &&
|
|
754
|
-
c =
|
|
866
|
+
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
867
|
+
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
868
|
+
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
869
|
+
), S = !e && !t && g.has(h.charAt(0));
|
|
870
|
+
c = p ? Ce : S ? j : "";
|
|
755
871
|
}
|
|
756
872
|
let f = "";
|
|
757
873
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
758
874
|
c + h + f,
|
|
759
|
-
|
|
875
|
+
k(h),
|
|
760
876
|
this.#n = !!this.#n,
|
|
761
|
-
this.#
|
|
877
|
+
this.#i
|
|
762
878
|
];
|
|
763
879
|
}
|
|
764
|
-
const n = this.type === "*" || this.type === "+",
|
|
765
|
-
let
|
|
766
|
-
if (this.isStart() && this.isEnd() && !
|
|
880
|
+
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
881
|
+
let i = this.#f(e);
|
|
882
|
+
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
767
883
|
const l = this.toString();
|
|
768
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
884
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
|
|
769
885
|
}
|
|
770
|
-
let o = !n || t || e || !
|
|
771
|
-
o ===
|
|
886
|
+
let o = !n || t || e || !j ? "" : this.#f(!0);
|
|
887
|
+
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
772
888
|
let a = "";
|
|
773
889
|
if (this.type === "!" && this.#u)
|
|
774
|
-
a = (this.isStart() && !e ?
|
|
890
|
+
a = (this.isStart() && !e ? j : "") + wt;
|
|
775
891
|
else {
|
|
776
892
|
const l = this.type === "!" ? (
|
|
777
893
|
// !() must match something,but !(x) can match ''
|
|
778
|
-
"))" + (this.isStart() && !e && !t ?
|
|
894
|
+
"))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
|
|
779
895
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
780
|
-
a =
|
|
896
|
+
a = r + i + l;
|
|
781
897
|
}
|
|
782
898
|
return [
|
|
783
899
|
a,
|
|
784
|
-
|
|
900
|
+
k(i),
|
|
785
901
|
this.#n = !!this.#n,
|
|
786
|
-
this.#
|
|
902
|
+
this.#i
|
|
787
903
|
];
|
|
788
904
|
}
|
|
789
905
|
#f(t) {
|
|
790
906
|
return this.#t.map((e) => {
|
|
791
907
|
if (typeof e == "string")
|
|
792
908
|
throw new Error("string type in extglob ast??");
|
|
793
|
-
const [n,
|
|
794
|
-
return this.#
|
|
909
|
+
const [n, r, i, o] = e.toRegExpSource(t);
|
|
910
|
+
return this.#i = this.#i || o, n;
|
|
795
911
|
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
796
912
|
}
|
|
797
913
|
static #p(t, e, n = !1) {
|
|
798
|
-
let
|
|
914
|
+
let r = !1, i = "", o = !1;
|
|
799
915
|
for (let a = 0; a < t.length; a++) {
|
|
800
916
|
const l = t.charAt(a);
|
|
801
|
-
if (
|
|
802
|
-
|
|
917
|
+
if (r) {
|
|
918
|
+
r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
|
|
803
919
|
continue;
|
|
804
920
|
}
|
|
805
921
|
if (l === "\\\\") {
|
|
806
|
-
a === t.length - 1 ?
|
|
922
|
+
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
807
923
|
continue;
|
|
808
924
|
}
|
|
809
925
|
if (l === "[") {
|
|
810
|
-
const [h, c, f, u] =
|
|
926
|
+
const [h, c, f, u] = Ae(t, a);
|
|
811
927
|
if (f) {
|
|
812
|
-
|
|
928
|
+
i += h, o = o || c, a += f - 1, e = e || u;
|
|
813
929
|
continue;
|
|
814
930
|
}
|
|
815
931
|
}
|
|
816
932
|
if (l === "*") {
|
|
817
|
-
n && t === "*" ?
|
|
933
|
+
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
818
934
|
continue;
|
|
819
935
|
}
|
|
820
936
|
if (l === "?") {
|
|
821
|
-
|
|
937
|
+
i += ct, e = !0;
|
|
822
938
|
continue;
|
|
823
939
|
}
|
|
824
|
-
|
|
940
|
+
i += Pe(l);
|
|
825
941
|
}
|
|
826
|
-
return [
|
|
942
|
+
return [i, k(t), !!e, o];
|
|
827
943
|
}
|
|
828
944
|
}
|
|
829
|
-
const
|
|
830
|
-
const e =
|
|
945
|
+
const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), ze = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), _e = (s) => s !== "." && s !== ".." && s.includes("."), je = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
|
|
946
|
+
const e = It([s]);
|
|
831
947
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
832
|
-
},
|
|
833
|
-
const e =
|
|
948
|
+
}, Ze = ([s, t = ""]) => {
|
|
949
|
+
const e = kt([s]);
|
|
834
950
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
835
|
-
},
|
|
836
|
-
const e =
|
|
951
|
+
}, Xe = ([s, t = ""]) => {
|
|
952
|
+
const e = kt([s]);
|
|
837
953
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
838
|
-
},
|
|
839
|
-
const e =
|
|
954
|
+
}, Je = ([s, t = ""]) => {
|
|
955
|
+
const e = It([s]);
|
|
840
956
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
841
|
-
},
|
|
957
|
+
}, It = ([s]) => {
|
|
842
958
|
const t = s.length;
|
|
843
959
|
return (e) => e.length === t && !e.startsWith(".");
|
|
844
|
-
},
|
|
960
|
+
}, kt = ([s]) => {
|
|
845
961
|
const t = s.length;
|
|
846
962
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
847
|
-
},
|
|
963
|
+
}, zt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
848
964
|
win32: { sep: "\\\\" },
|
|
849
965
|
posix: { sep: "/" }
|
|
850
|
-
},
|
|
851
|
-
y.sep =
|
|
852
|
-
const
|
|
853
|
-
y.GLOBSTAR =
|
|
854
|
-
const
|
|
855
|
-
y.filter =
|
|
856
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
966
|
+
}, Qe = zt === "win32" ? mt.win32.sep : mt.posix.sep;
|
|
967
|
+
y.sep = Qe;
|
|
968
|
+
const O = Symbol("globstar **");
|
|
969
|
+
y.GLOBSTAR = O;
|
|
970
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
|
|
971
|
+
y.filter = ns;
|
|
972
|
+
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
857
973
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
858
974
|
return y;
|
|
859
975
|
const t = y;
|
|
860
|
-
return Object.assign((n,
|
|
976
|
+
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
861
977
|
Minimatch: class extends t.Minimatch {
|
|
862
|
-
constructor(
|
|
863
|
-
super(
|
|
978
|
+
constructor(r, i = {}) {
|
|
979
|
+
super(r, b(s, i));
|
|
864
980
|
}
|
|
865
|
-
static defaults(
|
|
866
|
-
return t.defaults(b(s,
|
|
981
|
+
static defaults(r) {
|
|
982
|
+
return t.defaults(b(s, r)).Minimatch;
|
|
867
983
|
}
|
|
868
984
|
},
|
|
869
985
|
AST: class extends t.AST {
|
|
870
986
|
/* c8 ignore start */
|
|
871
|
-
constructor(
|
|
872
|
-
super(
|
|
987
|
+
constructor(r, i, o = {}) {
|
|
988
|
+
super(r, i, b(s, o));
|
|
873
989
|
}
|
|
874
990
|
/* c8 ignore stop */
|
|
875
|
-
static fromGlob(
|
|
876
|
-
return t.AST.fromGlob(
|
|
991
|
+
static fromGlob(r, i = {}) {
|
|
992
|
+
return t.AST.fromGlob(r, b(s, i));
|
|
877
993
|
}
|
|
878
994
|
},
|
|
879
|
-
unescape: (n,
|
|
880
|
-
escape: (n,
|
|
881
|
-
filter: (n,
|
|
995
|
+
unescape: (n, r = {}) => t.unescape(n, b(s, r)),
|
|
996
|
+
escape: (n, r = {}) => t.escape(n, b(s, r)),
|
|
997
|
+
filter: (n, r = {}) => t.filter(n, b(s, r)),
|
|
882
998
|
defaults: (n) => t.defaults(b(s, n)),
|
|
883
|
-
makeRe: (n,
|
|
884
|
-
braceExpand: (n,
|
|
885
|
-
match: (n,
|
|
999
|
+
makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
|
|
1000
|
+
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
1001
|
+
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
886
1002
|
sep: t.sep,
|
|
887
|
-
GLOBSTAR:
|
|
1003
|
+
GLOBSTAR: O
|
|
888
1004
|
});
|
|
889
1005
|
};
|
|
890
|
-
y.defaults =
|
|
891
|
-
const
|
|
892
|
-
y.braceExpand =
|
|
893
|
-
const
|
|
894
|
-
y.makeRe =
|
|
895
|
-
const
|
|
896
|
-
const n = new
|
|
897
|
-
return s = s.filter((
|
|
1006
|
+
y.defaults = rs;
|
|
1007
|
+
const Lt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
|
|
1008
|
+
y.braceExpand = Lt;
|
|
1009
|
+
const is = (s, t = {}) => new X(s, t).makeRe();
|
|
1010
|
+
y.makeRe = is;
|
|
1011
|
+
const os = (s, t, e = {}) => {
|
|
1012
|
+
const n = new X(t, e);
|
|
1013
|
+
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
898
1014
|
};
|
|
899
|
-
y.match =
|
|
900
|
-
const
|
|
901
|
-
class
|
|
1015
|
+
y.match = os;
|
|
1016
|
+
const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1017
|
+
class X {
|
|
902
1018
|
options;
|
|
903
1019
|
set;
|
|
904
1020
|
pattern;
|
|
@@ -917,7 +1033,7 @@ class q {
|
|
|
917
1033
|
windowsNoMagicRoot;
|
|
918
1034
|
regexp;
|
|
919
1035
|
constructor(t, e = {}) {
|
|
920
|
-
|
|
1036
|
+
Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || zt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
921
1037
|
}
|
|
922
1038
|
hasMagic() {
|
|
923
1039
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -940,23 +1056,23 @@ class q {
|
|
|
940
1056
|
this.empty = !0;
|
|
941
1057
|
return;
|
|
942
1058
|
}
|
|
943
|
-
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...
|
|
944
|
-
const n = this.globSet.map((
|
|
1059
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1060
|
+
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
945
1061
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
946
|
-
let
|
|
1062
|
+
let r = this.globParts.map((i, o, a) => {
|
|
947
1063
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
948
|
-
const l =
|
|
1064
|
+
const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
949
1065
|
if (l)
|
|
950
|
-
return [...
|
|
1066
|
+
return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
|
|
951
1067
|
if (h)
|
|
952
|
-
return [
|
|
1068
|
+
return [i[0], ...i.slice(1).map((c) => this.parse(c))];
|
|
953
1069
|
}
|
|
954
|
-
return
|
|
1070
|
+
return i.map((l) => this.parse(l));
|
|
955
1071
|
});
|
|
956
|
-
if (this.debug(this.pattern,
|
|
957
|
-
for (let
|
|
958
|
-
const o = this.set[
|
|
959
|
-
o[0] === "" && o[1] === "" && this.globParts[
|
|
1072
|
+
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1073
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1074
|
+
const o = this.set[i];
|
|
1075
|
+
o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
960
1076
|
}
|
|
961
1077
|
this.debug(this.pattern, this.set);
|
|
962
1078
|
}
|
|
@@ -968,8 +1084,8 @@ class q {
|
|
|
968
1084
|
preprocess(t) {
|
|
969
1085
|
if (this.options.noglobstar)
|
|
970
1086
|
for (let n = 0; n < t.length; n++)
|
|
971
|
-
for (let
|
|
972
|
-
t[n][
|
|
1087
|
+
for (let r = 0; r < t[n].length; r++)
|
|
1088
|
+
t[n][r] === "**" && (t[n][r] = "*");
|
|
973
1089
|
const { optimizationLevel: e = 1 } = this.options;
|
|
974
1090
|
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
975
1091
|
}
|
|
@@ -978,19 +1094,19 @@ class q {
|
|
|
978
1094
|
return t.map((e) => {
|
|
979
1095
|
let n = -1;
|
|
980
1096
|
for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
|
|
981
|
-
let
|
|
982
|
-
for (; e[
|
|
983
|
-
|
|
984
|
-
|
|
1097
|
+
let r = n;
|
|
1098
|
+
for (; e[r + 1] === "**"; )
|
|
1099
|
+
r++;
|
|
1100
|
+
r !== n && e.splice(n, r - n);
|
|
985
1101
|
}
|
|
986
1102
|
return e;
|
|
987
1103
|
});
|
|
988
1104
|
}
|
|
989
1105
|
// get rid of adjascent ** and resolve .. portions
|
|
990
1106
|
levelOneOptimize(t) {
|
|
991
|
-
return t.map((e) => (e = e.reduce((n,
|
|
992
|
-
const
|
|
993
|
-
return
|
|
1107
|
+
return t.map((e) => (e = e.reduce((n, r) => {
|
|
1108
|
+
const i = n[n.length - 1];
|
|
1109
|
+
return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
|
|
994
1110
|
}, []), e.length === 0 ? [""] : e));
|
|
995
1111
|
}
|
|
996
1112
|
levelTwoFileOptimize(t) {
|
|
@@ -998,16 +1114,16 @@ class q {
|
|
|
998
1114
|
let e = !1;
|
|
999
1115
|
do {
|
|
1000
1116
|
if (e = !1, !this.preserveMultipleSlashes) {
|
|
1001
|
-
for (let
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1117
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
1118
|
+
const i = t[r];
|
|
1119
|
+
r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
|
|
1004
1120
|
}
|
|
1005
1121
|
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
1006
1122
|
}
|
|
1007
1123
|
let n = 0;
|
|
1008
1124
|
for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1125
|
+
const r = t[n - 1];
|
|
1126
|
+
r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
|
|
1011
1127
|
}
|
|
1012
1128
|
} while (e);
|
|
1013
1129
|
return t.length === 0 ? [""] : t;
|
|
@@ -1035,19 +1151,19 @@ class q {
|
|
|
1035
1151
|
do {
|
|
1036
1152
|
e = !1;
|
|
1037
1153
|
for (let n of t) {
|
|
1038
|
-
let
|
|
1039
|
-
for (; (
|
|
1040
|
-
let o =
|
|
1154
|
+
let r = -1;
|
|
1155
|
+
for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
|
|
1156
|
+
let o = r;
|
|
1041
1157
|
for (; n[o + 1] === "**"; )
|
|
1042
1158
|
o++;
|
|
1043
|
-
o >
|
|
1044
|
-
let a = n[
|
|
1045
|
-
const l = n[
|
|
1159
|
+
o > r && n.splice(r + 1, o - r);
|
|
1160
|
+
let a = n[r + 1];
|
|
1161
|
+
const l = n[r + 2], h = n[r + 3];
|
|
1046
1162
|
if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
|
|
1047
1163
|
continue;
|
|
1048
|
-
e = !0, n.splice(
|
|
1164
|
+
e = !0, n.splice(r, 1);
|
|
1049
1165
|
const c = n.slice(0);
|
|
1050
|
-
c[
|
|
1166
|
+
c[r] = "**", t.push(c), r--;
|
|
1051
1167
|
}
|
|
1052
1168
|
if (!this.preserveMultipleSlashes) {
|
|
1053
1169
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1056,13 +1172,13 @@ class q {
|
|
|
1056
1172
|
}
|
|
1057
1173
|
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
|
|
1058
1174
|
}
|
|
1059
|
-
let
|
|
1060
|
-
for (; (
|
|
1061
|
-
const o = n[
|
|
1175
|
+
let i = 0;
|
|
1176
|
+
for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
|
|
1177
|
+
const o = n[i - 1];
|
|
1062
1178
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1063
1179
|
e = !0;
|
|
1064
|
-
const l =
|
|
1065
|
-
n.splice(
|
|
1180
|
+
const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1181
|
+
n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
|
|
1066
1182
|
}
|
|
1067
1183
|
}
|
|
1068
1184
|
}
|
|
@@ -1079,31 +1195,31 @@ class q {
|
|
|
1079
1195
|
secondPhasePreProcess(t) {
|
|
1080
1196
|
for (let e = 0; e < t.length - 1; e++)
|
|
1081
1197
|
for (let n = e + 1; n < t.length; n++) {
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
t[e] = [], t[n] =
|
|
1198
|
+
const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
|
|
1199
|
+
if (r) {
|
|
1200
|
+
t[e] = [], t[n] = r;
|
|
1085
1201
|
break;
|
|
1086
1202
|
}
|
|
1087
1203
|
}
|
|
1088
1204
|
return t.filter((e) => e.length);
|
|
1089
1205
|
}
|
|
1090
1206
|
partsMatch(t, e, n = !1) {
|
|
1091
|
-
let
|
|
1092
|
-
for (;
|
|
1093
|
-
if (t[
|
|
1094
|
-
o.push(a === "b" ? e[
|
|
1095
|
-
else if (n && t[
|
|
1096
|
-
o.push(t[
|
|
1097
|
-
else if (n && e[
|
|
1098
|
-
o.push(e[
|
|
1099
|
-
else if (t[
|
|
1207
|
+
let r = 0, i = 0, o = [], a = "";
|
|
1208
|
+
for (; r < t.length && i < e.length; )
|
|
1209
|
+
if (t[r] === e[i])
|
|
1210
|
+
o.push(a === "b" ? e[i] : t[r]), r++, i++;
|
|
1211
|
+
else if (n && t[r] === "**" && e[i] === t[r + 1])
|
|
1212
|
+
o.push(t[r]), r++;
|
|
1213
|
+
else if (n && e[i] === "**" && t[r] === e[i + 1])
|
|
1214
|
+
o.push(e[i]), i++;
|
|
1215
|
+
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1100
1216
|
if (a === "b")
|
|
1101
1217
|
return !1;
|
|
1102
|
-
a = "a", o.push(t[
|
|
1103
|
-
} else if (e[
|
|
1218
|
+
a = "a", o.push(t[r]), r++, i++;
|
|
1219
|
+
} else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
|
|
1104
1220
|
if (a === "a")
|
|
1105
1221
|
return !1;
|
|
1106
|
-
a = "b", o.push(e[
|
|
1222
|
+
a = "b", o.push(e[i]), r++, i++;
|
|
1107
1223
|
} else
|
|
1108
1224
|
return !1;
|
|
1109
1225
|
return t.length === e.length && o;
|
|
@@ -1113,7 +1229,7 @@ class q {
|
|
|
1113
1229
|
return;
|
|
1114
1230
|
const t = this.pattern;
|
|
1115
1231
|
let e = !1, n = 0;
|
|
1116
|
-
for (let
|
|
1232
|
+
for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
|
|
1117
1233
|
e = !e, n++;
|
|
1118
1234
|
n && (this.pattern = t.slice(n)), this.negate = e;
|
|
1119
1235
|
}
|
|
@@ -1123,36 +1239,36 @@ class q {
|
|
|
1123
1239
|
// out of pattern, then that's fine, as long as all
|
|
1124
1240
|
// the parts match.
|
|
1125
1241
|
matchOne(t, e, n = !1) {
|
|
1126
|
-
const
|
|
1242
|
+
const r = this.options;
|
|
1127
1243
|
if (this.isWindows) {
|
|
1128
|
-
const
|
|
1244
|
+
const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), P = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = P ? 3 : v ? 0 : void 0;
|
|
1129
1245
|
if (typeof x == "number" && typeof m == "number") {
|
|
1130
|
-
const [
|
|
1131
|
-
|
|
1246
|
+
const [T, H] = [t[x], e[m]];
|
|
1247
|
+
T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1132
1248
|
}
|
|
1133
1249
|
}
|
|
1134
|
-
const { optimizationLevel:
|
|
1135
|
-
|
|
1250
|
+
const { optimizationLevel: i = 1 } = this.options;
|
|
1251
|
+
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1136
1252
|
for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
|
|
1137
1253
|
this.debug("matchOne loop");
|
|
1138
1254
|
var c = e[a], f = t[o];
|
|
1139
1255
|
if (this.debug(e, c, f), c === !1)
|
|
1140
1256
|
return !1;
|
|
1141
|
-
if (c ===
|
|
1257
|
+
if (c === O) {
|
|
1142
1258
|
this.debug("GLOBSTAR", [e, c, f]);
|
|
1143
1259
|
var u = o, d = a + 1;
|
|
1144
1260
|
if (d === h) {
|
|
1145
1261
|
for (this.debug("** at the end"); o < l; o++)
|
|
1146
|
-
if (t[o] === "." || t[o] === ".." || !
|
|
1262
|
+
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1147
1263
|
return !1;
|
|
1148
1264
|
return !0;
|
|
1149
1265
|
}
|
|
1150
1266
|
for (; u < l; ) {
|
|
1151
|
-
var
|
|
1267
|
+
var g = t[u];
|
|
1152
1268
|
if (this.debug(\`
|
|
1153
|
-
globstar while\`, t, u, e, d,
|
|
1154
|
-
return this.debug("globstar found match!", u, l,
|
|
1155
|
-
if (
|
|
1269
|
+
globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1270
|
+
return this.debug("globstar found match!", u, l, g), !0;
|
|
1271
|
+
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1156
1272
|
this.debug("dot detected!", t, u, e, d);
|
|
1157
1273
|
break;
|
|
1158
1274
|
}
|
|
@@ -1161,8 +1277,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1161
1277
|
return !!(n && (this.debug(\`
|
|
1162
1278
|
>>> no match, partial?\`, t, u, e, d), u === l));
|
|
1163
1279
|
}
|
|
1164
|
-
let
|
|
1165
|
-
if (typeof c == "string" ? (
|
|
1280
|
+
let p;
|
|
1281
|
+
if (typeof c == "string" ? (p = f === c, this.debug("string match", c, f, p)) : (p = c.test(f), this.debug("pattern match", c, f, p)), !p)
|
|
1166
1282
|
return !1;
|
|
1167
1283
|
}
|
|
1168
1284
|
if (o === l && a === h)
|
|
@@ -1174,19 +1290,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1174
1290
|
throw new Error("wtf?");
|
|
1175
1291
|
}
|
|
1176
1292
|
braceExpand() {
|
|
1177
|
-
return
|
|
1293
|
+
return Lt(this.pattern, this.options);
|
|
1178
1294
|
}
|
|
1179
1295
|
parse(t) {
|
|
1180
|
-
|
|
1296
|
+
Z(t);
|
|
1181
1297
|
const e = this.options;
|
|
1182
1298
|
if (t === "**")
|
|
1183
|
-
return
|
|
1299
|
+
return O;
|
|
1184
1300
|
if (t === "")
|
|
1185
1301
|
return "";
|
|
1186
|
-
let n,
|
|
1187
|
-
(n = t.match(
|
|
1188
|
-
const
|
|
1189
|
-
return
|
|
1302
|
+
let n, r = null;
|
|
1303
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : ze : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? _e : We : (n = t.match(je)) && (r = Ue);
|
|
1304
|
+
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1305
|
+
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1190
1306
|
}
|
|
1191
1307
|
makeRe() {
|
|
1192
1308
|
if (this.regexp || this.regexp === !1)
|
|
@@ -1194,23 +1310,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1194
1310
|
const t = this.set;
|
|
1195
1311
|
if (!t.length)
|
|
1196
1312
|
return this.regexp = !1, this.regexp;
|
|
1197
|
-
const e = this.options, n = e.noglobstar ?
|
|
1198
|
-
let
|
|
1313
|
+
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1314
|
+
let i = t.map((l) => {
|
|
1199
1315
|
const h = l.map((c) => {
|
|
1200
1316
|
if (c instanceof RegExp)
|
|
1201
1317
|
for (const f of c.flags.split(""))
|
|
1202
|
-
|
|
1203
|
-
return typeof c == "string" ?
|
|
1318
|
+
r.add(f);
|
|
1319
|
+
return typeof c == "string" ? as(c) : c === O ? O : c._src;
|
|
1204
1320
|
});
|
|
1205
1321
|
return h.forEach((c, f) => {
|
|
1206
1322
|
const u = h[f + 1], d = h[f - 1];
|
|
1207
|
-
c !==
|
|
1208
|
-
}), h.filter((c) => c !==
|
|
1323
|
+
c !== O || d === O || (d === void 0 ? u !== void 0 && u !== O ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== O && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = O));
|
|
1324
|
+
}), h.filter((c) => c !== O).join("/");
|
|
1209
1325
|
}).join("|");
|
|
1210
1326
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1211
|
-
|
|
1327
|
+
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1212
1328
|
try {
|
|
1213
|
-
this.regexp = new RegExp(
|
|
1329
|
+
this.regexp = new RegExp(i, [...r].join(""));
|
|
1214
1330
|
} catch {
|
|
1215
1331
|
this.regexp = !1;
|
|
1216
1332
|
}
|
|
@@ -1228,17 +1344,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1228
1344
|
return !0;
|
|
1229
1345
|
const n = this.options;
|
|
1230
1346
|
this.isWindows && (t = t.split("\\\\").join("/"));
|
|
1231
|
-
const
|
|
1232
|
-
this.debug(this.pattern, "split",
|
|
1233
|
-
const
|
|
1234
|
-
this.debug(this.pattern, "set",
|
|
1235
|
-
let o =
|
|
1347
|
+
const r = this.slashSplit(t);
|
|
1348
|
+
this.debug(this.pattern, "split", r);
|
|
1349
|
+
const i = this.set;
|
|
1350
|
+
this.debug(this.pattern, "set", i);
|
|
1351
|
+
let o = r[r.length - 1];
|
|
1236
1352
|
if (!o)
|
|
1237
|
-
for (let a =
|
|
1238
|
-
o =
|
|
1239
|
-
for (let a = 0; a <
|
|
1240
|
-
const l =
|
|
1241
|
-
let h =
|
|
1353
|
+
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1354
|
+
o = r[a];
|
|
1355
|
+
for (let a = 0; a < i.length; a++) {
|
|
1356
|
+
const l = i[a];
|
|
1357
|
+
let h = r;
|
|
1242
1358
|
if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
|
|
1243
1359
|
return n.flipNegate ? !0 : !this.negate;
|
|
1244
1360
|
}
|
|
@@ -1249,109 +1365,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1249
1365
|
}
|
|
1250
1366
|
}
|
|
1251
1367
|
y.AST = E;
|
|
1252
|
-
y.Minimatch =
|
|
1253
|
-
y.escape =
|
|
1254
|
-
y.unescape =
|
|
1255
|
-
function
|
|
1368
|
+
y.Minimatch = X;
|
|
1369
|
+
y.escape = Te;
|
|
1370
|
+
y.unescape = k;
|
|
1371
|
+
function cs() {
|
|
1256
1372
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1257
|
-
throw new
|
|
1373
|
+
throw new Qt();
|
|
1258
1374
|
}
|
|
1259
|
-
async function
|
|
1375
|
+
async function z(s, t, e) {
|
|
1260
1376
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1261
1377
|
}
|
|
1262
|
-
function
|
|
1378
|
+
function M(s) {
|
|
1263
1379
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1264
1380
|
}
|
|
1265
|
-
function
|
|
1381
|
+
function lt(s) {
|
|
1266
1382
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1267
1383
|
}
|
|
1268
|
-
function
|
|
1269
|
-
const t =
|
|
1384
|
+
function it(s) {
|
|
1385
|
+
const t = M(s);
|
|
1270
1386
|
return t[t.length - 1] || "";
|
|
1271
1387
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const t =
|
|
1274
|
-
return t.pop(),
|
|
1388
|
+
function et(s) {
|
|
1389
|
+
const t = M(s);
|
|
1390
|
+
return t.pop(), lt(t);
|
|
1275
1391
|
}
|
|
1276
|
-
function
|
|
1392
|
+
function G(s) {
|
|
1277
1393
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1278
1394
|
}
|
|
1279
|
-
function
|
|
1395
|
+
function ls(s, t = !1) {
|
|
1280
1396
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1281
1397
|
}
|
|
1282
|
-
function
|
|
1398
|
+
function st(s, t) {
|
|
1283
1399
|
return y(s, t, {
|
|
1284
1400
|
dot: !0,
|
|
1285
1401
|
matchBase: !0
|
|
1286
1402
|
});
|
|
1287
1403
|
}
|
|
1288
|
-
function
|
|
1289
|
-
const t =
|
|
1290
|
-
for (const
|
|
1291
|
-
if (!(
|
|
1292
|
-
if (
|
|
1404
|
+
function Et(s) {
|
|
1405
|
+
const t = G(s), e = M(t), n = [];
|
|
1406
|
+
for (const r of e)
|
|
1407
|
+
if (!(r === "." || r === ""))
|
|
1408
|
+
if (r === "..") {
|
|
1293
1409
|
if (n.length === 0)
|
|
1294
1410
|
continue;
|
|
1295
1411
|
n.pop();
|
|
1296
1412
|
} else
|
|
1297
|
-
n.push(
|
|
1298
|
-
return
|
|
1413
|
+
n.push(r);
|
|
1414
|
+
return lt(n);
|
|
1299
1415
|
}
|
|
1300
|
-
async function
|
|
1416
|
+
async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1301
1417
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1302
1418
|
throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
|
|
1303
|
-
const n = new Uint8Array(s),
|
|
1304
|
-
return Array.from(new Uint8Array(
|
|
1419
|
+
const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
|
|
1420
|
+
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1305
1421
|
}
|
|
1306
|
-
async function
|
|
1422
|
+
async function us(s) {
|
|
1307
1423
|
const t = await s.arrayBuffer();
|
|
1308
1424
|
return new Uint8Array(t);
|
|
1309
1425
|
}
|
|
1310
|
-
async function
|
|
1311
|
-
const n =
|
|
1312
|
-
return
|
|
1313
|
-
const
|
|
1426
|
+
async function fs(s, t, e = {}) {
|
|
1427
|
+
const n = it(t);
|
|
1428
|
+
return z(t, "exclusive", async () => {
|
|
1429
|
+
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1314
1430
|
try {
|
|
1315
|
-
await s.removeEntry(n, { recursive:
|
|
1431
|
+
await s.removeEntry(n, { recursive: r });
|
|
1316
1432
|
} catch (o) {
|
|
1317
1433
|
if (o.name === "NotFoundError") {
|
|
1318
|
-
if (!
|
|
1319
|
-
throw new
|
|
1320
|
-
} else throw o.name === "InvalidModificationError" ? new
|
|
1434
|
+
if (!i)
|
|
1435
|
+
throw new F("file", t, o);
|
|
1436
|
+
} else throw o.name === "InvalidModificationError" ? new rt("clear", t, o) : o.name === "TypeMismatchError" && !r ? new L("file", "directory", t, o) : new rt("remove", t, o);
|
|
1321
1437
|
}
|
|
1322
1438
|
});
|
|
1323
1439
|
}
|
|
1324
|
-
function
|
|
1440
|
+
function St(s, t, e, n) {
|
|
1325
1441
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1326
|
-
throw new
|
|
1442
|
+
throw new N("argument", "Invalid offset or length");
|
|
1327
1443
|
if (t < 0 || e < 0)
|
|
1328
|
-
throw new
|
|
1444
|
+
throw new N("argument", "Negative offset or length not allowed");
|
|
1329
1445
|
if (t + e > s)
|
|
1330
|
-
throw new
|
|
1446
|
+
throw new N("overflow", "Operation would overflow buffer");
|
|
1331
1447
|
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1332
|
-
throw new
|
|
1448
|
+
throw new N("argument", "Invalid position");
|
|
1333
1449
|
}
|
|
1334
|
-
function
|
|
1450
|
+
function xt(s, t, e) {
|
|
1335
1451
|
try {
|
|
1336
1452
|
t.flush(), t.close();
|
|
1337
1453
|
} catch (n) {
|
|
1338
1454
|
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1339
1455
|
}
|
|
1340
1456
|
}
|
|
1341
|
-
function
|
|
1457
|
+
function ds(s, t, e) {
|
|
1342
1458
|
if (s >= e)
|
|
1343
1459
|
return { isEOF: !0, actualLength: 0 };
|
|
1344
1460
|
const n = Math.min(t, e - s);
|
|
1345
1461
|
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1346
1462
|
}
|
|
1347
|
-
async function
|
|
1463
|
+
async function ps(s, t) {
|
|
1348
1464
|
try {
|
|
1349
1465
|
return await s.createSyncAccessHandle();
|
|
1350
1466
|
} catch (e) {
|
|
1351
|
-
throw
|
|
1467
|
+
throw A(e, { path: t, isDirectory: !1 });
|
|
1352
1468
|
}
|
|
1353
1469
|
}
|
|
1354
|
-
class
|
|
1470
|
+
class gs {
|
|
1355
1471
|
/** Root directory handle for the file system */
|
|
1356
1472
|
root;
|
|
1357
1473
|
/** Map of watched paths and options */
|
|
@@ -1379,7 +1495,7 @@ class ss {
|
|
|
1379
1495
|
_getFileDescriptor(t) {
|
|
1380
1496
|
const e = this.openFiles.get(t);
|
|
1381
1497
|
if (!e)
|
|
1382
|
-
throw new
|
|
1498
|
+
throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
|
|
1383
1499
|
return e;
|
|
1384
1500
|
}
|
|
1385
1501
|
/**
|
|
@@ -1395,25 +1511,25 @@ class ss {
|
|
|
1395
1511
|
if (!this.options.broadcastChannel)
|
|
1396
1512
|
return;
|
|
1397
1513
|
const e = t.path;
|
|
1398
|
-
if (![...this.watchers.values()].some((
|
|
1514
|
+
if (![...this.watchers.values()].some((i) => st(e, i.pattern) && i.include.some((o) => o && st(e, o)) && !i.exclude.some((o) => o && st(e, o))))
|
|
1399
1515
|
return;
|
|
1400
|
-
let
|
|
1516
|
+
let r;
|
|
1401
1517
|
if (this.options.hashAlgorithm)
|
|
1402
1518
|
try {
|
|
1403
|
-
|
|
1519
|
+
r = (await this.stat(e)).hash;
|
|
1404
1520
|
} catch {
|
|
1405
1521
|
}
|
|
1406
1522
|
try {
|
|
1407
1523
|
this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
|
|
1408
|
-
const
|
|
1524
|
+
const i = {
|
|
1409
1525
|
namespace: this.options.namespace,
|
|
1410
1526
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1411
1527
|
...t,
|
|
1412
|
-
...
|
|
1528
|
+
...r && { hash: r }
|
|
1413
1529
|
};
|
|
1414
|
-
this.broadcastChannel.postMessage(
|
|
1415
|
-
} catch (
|
|
1416
|
-
console.warn("Failed to send event via BroadcastChannel:",
|
|
1530
|
+
this.broadcastChannel.postMessage(i);
|
|
1531
|
+
} catch (i) {
|
|
1532
|
+
console.warn("Failed to send event via BroadcastChannel:", i);
|
|
1417
1533
|
}
|
|
1418
1534
|
}
|
|
1419
1535
|
/**
|
|
@@ -1427,7 +1543,7 @@ class ss {
|
|
|
1427
1543
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1428
1544
|
*/
|
|
1429
1545
|
constructor(t) {
|
|
1430
|
-
|
|
1546
|
+
cs(), t && this.setOptions(t);
|
|
1431
1547
|
}
|
|
1432
1548
|
/**
|
|
1433
1549
|
* Initialize the file system within a given directory
|
|
@@ -1454,10 +1570,10 @@ class ss {
|
|
|
1454
1570
|
const t = this.options.root;
|
|
1455
1571
|
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
|
|
1456
1572
|
try {
|
|
1457
|
-
const
|
|
1458
|
-
this.root = t === "/" ?
|
|
1459
|
-
} catch (
|
|
1460
|
-
n(new
|
|
1573
|
+
const r = await navigator.storage.getDirectory();
|
|
1574
|
+
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1575
|
+
} catch (r) {
|
|
1576
|
+
n(new re(t, r));
|
|
1461
1577
|
} finally {
|
|
1462
1578
|
this.mountingPromise = null;
|
|
1463
1579
|
}
|
|
@@ -1474,7 +1590,7 @@ class ss {
|
|
|
1474
1590
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1475
1591
|
*/
|
|
1476
1592
|
async setOptions(t) {
|
|
1477
|
-
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root =
|
|
1593
|
+
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = G(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1478
1594
|
}
|
|
1479
1595
|
/**
|
|
1480
1596
|
* Get a directory handle from a path
|
|
@@ -1495,11 +1611,11 @@ class ss {
|
|
|
1495
1611
|
* \`\`\`
|
|
1496
1612
|
*/
|
|
1497
1613
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1498
|
-
const
|
|
1499
|
-
let
|
|
1500
|
-
for (const o of
|
|
1501
|
-
|
|
1502
|
-
return
|
|
1614
|
+
const r = Array.isArray(t) ? t : M(t);
|
|
1615
|
+
let i = n;
|
|
1616
|
+
for (const o of r)
|
|
1617
|
+
i = await i.getDirectoryHandle(o, { create: e });
|
|
1618
|
+
return i;
|
|
1503
1619
|
}
|
|
1504
1620
|
/**
|
|
1505
1621
|
* Get a file handle from a path
|
|
@@ -1521,11 +1637,11 @@ class ss {
|
|
|
1521
1637
|
* \`\`\`
|
|
1522
1638
|
*/
|
|
1523
1639
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1524
|
-
const
|
|
1525
|
-
if (
|
|
1526
|
-
throw new
|
|
1527
|
-
const
|
|
1528
|
-
return (await this.getDirectoryHandle(
|
|
1640
|
+
const r = M(t);
|
|
1641
|
+
if (r.length === 0)
|
|
1642
|
+
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1643
|
+
const i = r.pop();
|
|
1644
|
+
return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
|
|
1529
1645
|
}
|
|
1530
1646
|
/**
|
|
1531
1647
|
* Get a complete index of all files and directories in the file system
|
|
@@ -1548,9 +1664,9 @@ class ss {
|
|
|
1548
1664
|
*/
|
|
1549
1665
|
async index() {
|
|
1550
1666
|
const t = /* @__PURE__ */ new Map(), e = async (n) => {
|
|
1551
|
-
const
|
|
1552
|
-
for (const
|
|
1553
|
-
const o = \`\${n === "/" ? "" : n}/\${
|
|
1667
|
+
const r = await this.readDir(n);
|
|
1668
|
+
for (const i of r) {
|
|
1669
|
+
const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
|
|
1554
1670
|
try {
|
|
1555
1671
|
const a = await this.stat(o);
|
|
1556
1672
|
t.set(o, a), a.isDirectory && await e(o);
|
|
@@ -1590,17 +1706,17 @@ class ss {
|
|
|
1590
1706
|
async readFile(t) {
|
|
1591
1707
|
await this.mount();
|
|
1592
1708
|
try {
|
|
1593
|
-
return await
|
|
1709
|
+
return await z(t, "shared", async () => {
|
|
1594
1710
|
const e = await this.open(t);
|
|
1595
1711
|
try {
|
|
1596
|
-
const { size: n } = await this.fstat(e),
|
|
1597
|
-
return n > 0 && await this.read(e,
|
|
1712
|
+
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1713
|
+
return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
|
|
1598
1714
|
} finally {
|
|
1599
1715
|
await this.close(e);
|
|
1600
1716
|
}
|
|
1601
1717
|
});
|
|
1602
1718
|
} catch (e) {
|
|
1603
|
-
throw new
|
|
1719
|
+
throw new F("file", t, e);
|
|
1604
1720
|
}
|
|
1605
1721
|
}
|
|
1606
1722
|
/**
|
|
@@ -1628,14 +1744,14 @@ class ss {
|
|
|
1628
1744
|
async writeFile(t, e) {
|
|
1629
1745
|
await this.mount();
|
|
1630
1746
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1631
|
-
await
|
|
1632
|
-
const
|
|
1747
|
+
await z(t, "exclusive", async () => {
|
|
1748
|
+
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1633
1749
|
try {
|
|
1634
|
-
await this.write(
|
|
1750
|
+
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1635
1751
|
} finally {
|
|
1636
|
-
await this.close(
|
|
1752
|
+
await this.close(i);
|
|
1637
1753
|
}
|
|
1638
|
-
await this.notifyChange({ path: t, type:
|
|
1754
|
+
await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
|
|
1639
1755
|
});
|
|
1640
1756
|
}
|
|
1641
1757
|
/**
|
|
@@ -1663,15 +1779,15 @@ class ss {
|
|
|
1663
1779
|
async appendFile(t, e) {
|
|
1664
1780
|
await this.mount();
|
|
1665
1781
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1666
|
-
await
|
|
1667
|
-
const
|
|
1782
|
+
await z(t, "exclusive", async () => {
|
|
1783
|
+
const r = await this.open(t, { create: !0 });
|
|
1668
1784
|
try {
|
|
1669
|
-
const { size:
|
|
1670
|
-
await this.write(
|
|
1785
|
+
const { size: i } = await this.fstat(r);
|
|
1786
|
+
await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
|
|
1671
1787
|
} finally {
|
|
1672
|
-
await this.close(
|
|
1788
|
+
await this.close(r);
|
|
1673
1789
|
}
|
|
1674
|
-
await this.notifyChange({ path: t, type:
|
|
1790
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
|
|
1675
1791
|
});
|
|
1676
1792
|
}
|
|
1677
1793
|
/**
|
|
@@ -1697,22 +1813,17 @@ class ss {
|
|
|
1697
1813
|
*/
|
|
1698
1814
|
async mkdir(t, e) {
|
|
1699
1815
|
await this.mount();
|
|
1700
|
-
const n = e?.recursive ?? !1,
|
|
1701
|
-
let
|
|
1702
|
-
for (let o = 0; o <
|
|
1703
|
-
const a =
|
|
1816
|
+
const n = e?.recursive ?? !1, r = M(t);
|
|
1817
|
+
let i = this.root;
|
|
1818
|
+
for (let o = 0; o < r.length; o++) {
|
|
1819
|
+
const a = r[o];
|
|
1704
1820
|
try {
|
|
1705
|
-
|
|
1821
|
+
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1706
1822
|
} catch (l) {
|
|
1707
|
-
throw l.name === "NotFoundError" ? new
|
|
1708
|
-
\`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
|
|
1709
|
-
"ENOENT",
|
|
1710
|
-
void 0,
|
|
1711
|
-
l
|
|
1712
|
-
) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
|
|
1823
|
+
throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new L("directory", "file", a, l) : new Q("create directory", a, l);
|
|
1713
1824
|
}
|
|
1714
1825
|
}
|
|
1715
|
-
await this.notifyChange({ path: t, type:
|
|
1826
|
+
await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
|
|
1716
1827
|
}
|
|
1717
1828
|
/**
|
|
1718
1829
|
* Get file or directory statistics
|
|
@@ -1746,9 +1857,11 @@ class ss {
|
|
|
1746
1857
|
isFile: !1,
|
|
1747
1858
|
isDirectory: !0
|
|
1748
1859
|
};
|
|
1749
|
-
const e =
|
|
1860
|
+
const e = it(t);
|
|
1861
|
+
let n;
|
|
1750
1862
|
try {
|
|
1751
|
-
|
|
1863
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1864
|
+
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1752
1865
|
kind: "file",
|
|
1753
1866
|
size: o.size,
|
|
1754
1867
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1756,19 +1869,21 @@ class ss {
|
|
|
1756
1869
|
isFile: !0,
|
|
1757
1870
|
isDirectory: !1
|
|
1758
1871
|
};
|
|
1759
|
-
if (
|
|
1872
|
+
if (r === "etag")
|
|
1760
1873
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1761
|
-
else if (typeof
|
|
1874
|
+
else if (typeof r == "string")
|
|
1762
1875
|
try {
|
|
1763
|
-
const l = await
|
|
1876
|
+
const l = await hs(o, r, this.options.maxFileSize);
|
|
1764
1877
|
a.hash = l;
|
|
1765
1878
|
} catch (l) {
|
|
1766
1879
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
1767
1880
|
}
|
|
1768
1881
|
return a;
|
|
1769
1882
|
} catch (r) {
|
|
1770
|
-
if (r.name
|
|
1771
|
-
throw new
|
|
1883
|
+
if (r.name === "NotFoundError")
|
|
1884
|
+
throw new F("file", t, r);
|
|
1885
|
+
if (r.name !== "TypeMismatchError")
|
|
1886
|
+
throw new Q("stat", t, r);
|
|
1772
1887
|
}
|
|
1773
1888
|
try {
|
|
1774
1889
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1780,7 +1895,7 @@ class ss {
|
|
|
1780
1895
|
isDirectory: !0
|
|
1781
1896
|
};
|
|
1782
1897
|
} catch (r) {
|
|
1783
|
-
throw
|
|
1898
|
+
throw new Q("stat", t, r);
|
|
1784
1899
|
}
|
|
1785
1900
|
}
|
|
1786
1901
|
/**
|
|
@@ -1804,11 +1919,11 @@ class ss {
|
|
|
1804
1919
|
async readDir(t) {
|
|
1805
1920
|
await this.mount();
|
|
1806
1921
|
const e = await this.getDirectoryHandle(t, !1), n = [];
|
|
1807
|
-
for await (const [
|
|
1808
|
-
const o =
|
|
1922
|
+
for await (const [r, i] of e.entries()) {
|
|
1923
|
+
const o = i.kind === "file";
|
|
1809
1924
|
n.push({
|
|
1810
|
-
name:
|
|
1811
|
-
kind:
|
|
1925
|
+
name: r,
|
|
1926
|
+
kind: i.kind,
|
|
1812
1927
|
isFile: o,
|
|
1813
1928
|
isDirectory: !o
|
|
1814
1929
|
});
|
|
@@ -1832,26 +1947,26 @@ class ss {
|
|
|
1832
1947
|
async exists(t) {
|
|
1833
1948
|
if (await this.mount(), t === "/")
|
|
1834
1949
|
return !0;
|
|
1835
|
-
const e =
|
|
1950
|
+
const e = it(t);
|
|
1836
1951
|
let n = null;
|
|
1837
1952
|
try {
|
|
1838
|
-
n = await this.getDirectoryHandle(
|
|
1839
|
-
} catch (
|
|
1840
|
-
if (n = null,
|
|
1841
|
-
throw
|
|
1953
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1954
|
+
} catch (r) {
|
|
1955
|
+
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1956
|
+
throw r;
|
|
1842
1957
|
}
|
|
1843
1958
|
if (!n || !e)
|
|
1844
1959
|
return !1;
|
|
1845
1960
|
try {
|
|
1846
1961
|
return await n.getFileHandle(e, { create: !1 }), !0;
|
|
1847
|
-
} catch (
|
|
1848
|
-
if (
|
|
1849
|
-
throw
|
|
1962
|
+
} catch (r) {
|
|
1963
|
+
if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1964
|
+
throw r;
|
|
1850
1965
|
try {
|
|
1851
1966
|
return await n.getDirectoryHandle(e, { create: !1 }), !0;
|
|
1852
|
-
} catch (
|
|
1853
|
-
if (
|
|
1854
|
-
throw
|
|
1967
|
+
} catch (i) {
|
|
1968
|
+
if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1969
|
+
throw i;
|
|
1855
1970
|
return !1;
|
|
1856
1971
|
}
|
|
1857
1972
|
}
|
|
@@ -1880,12 +1995,12 @@ class ss {
|
|
|
1880
1995
|
try {
|
|
1881
1996
|
const e = await this.readDir(t);
|
|
1882
1997
|
for (const n of e) {
|
|
1883
|
-
const
|
|
1884
|
-
await this.remove(
|
|
1998
|
+
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1999
|
+
await this.remove(r, { recursive: !0 });
|
|
1885
2000
|
}
|
|
1886
|
-
await this.notifyChange({ path: t, type:
|
|
2001
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
|
|
1887
2002
|
} catch (e) {
|
|
1888
|
-
throw e instanceof
|
|
2003
|
+
throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
|
|
1889
2004
|
}
|
|
1890
2005
|
}
|
|
1891
2006
|
/**
|
|
@@ -1914,9 +2029,9 @@ class ss {
|
|
|
1914
2029
|
*/
|
|
1915
2030
|
async remove(t, e) {
|
|
1916
2031
|
if (await this.mount(), t === "/")
|
|
1917
|
-
throw new
|
|
1918
|
-
const { recursive: n = !1, force:
|
|
1919
|
-
await
|
|
2032
|
+
throw new rt("root", t);
|
|
2033
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
|
|
2034
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
|
|
1920
2035
|
}
|
|
1921
2036
|
/**
|
|
1922
2037
|
* Resolve a path to an absolute path
|
|
@@ -1939,12 +2054,12 @@ class ss {
|
|
|
1939
2054
|
async realpath(t) {
|
|
1940
2055
|
await this.mount();
|
|
1941
2056
|
try {
|
|
1942
|
-
const e =
|
|
2057
|
+
const e = Et(t);
|
|
1943
2058
|
if (!await this.exists(e))
|
|
1944
|
-
throw new
|
|
2059
|
+
throw new F("file", e);
|
|
1945
2060
|
return e;
|
|
1946
2061
|
} catch (e) {
|
|
1947
|
-
throw e instanceof
|
|
2062
|
+
throw e instanceof w ? e : A(e, { path: t });
|
|
1948
2063
|
}
|
|
1949
2064
|
}
|
|
1950
2065
|
/**
|
|
@@ -1972,12 +2087,12 @@ class ss {
|
|
|
1972
2087
|
async rename(t, e, n) {
|
|
1973
2088
|
await this.mount();
|
|
1974
2089
|
try {
|
|
1975
|
-
const
|
|
1976
|
-
if (await this.exists(e) && !
|
|
1977
|
-
throw new
|
|
1978
|
-
await this.copy(t, e, { recursive: !0, overwrite:
|
|
1979
|
-
} catch (
|
|
1980
|
-
throw
|
|
2090
|
+
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2091
|
+
if (await this.exists(e) && !r)
|
|
2092
|
+
throw new K(e);
|
|
2093
|
+
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
|
|
2094
|
+
} catch (r) {
|
|
2095
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
1981
2096
|
}
|
|
1982
2097
|
}
|
|
1983
2098
|
/**
|
|
@@ -2008,26 +2123,26 @@ class ss {
|
|
|
2008
2123
|
async copy(t, e, n) {
|
|
2009
2124
|
await this.mount();
|
|
2010
2125
|
try {
|
|
2011
|
-
const
|
|
2126
|
+
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2012
2127
|
if (!await this.exists(t))
|
|
2013
|
-
throw new
|
|
2014
|
-
if (await this.exists(e) && !
|
|
2015
|
-
throw new
|
|
2128
|
+
throw new F("source", t);
|
|
2129
|
+
if (await this.exists(e) && !i)
|
|
2130
|
+
throw new K(e);
|
|
2016
2131
|
if ((await this.stat(t)).isFile) {
|
|
2017
2132
|
const h = await this.readFile(t);
|
|
2018
2133
|
await this.writeFile(e, h);
|
|
2019
2134
|
} else {
|
|
2020
|
-
if (!
|
|
2021
|
-
throw new
|
|
2135
|
+
if (!r)
|
|
2136
|
+
throw new L("file", "directory", t);
|
|
2022
2137
|
await this.mkdir(e, { recursive: !0 });
|
|
2023
2138
|
const h = await this.readDir(t);
|
|
2024
2139
|
for (const c of h) {
|
|
2025
2140
|
const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
|
|
2026
|
-
await this.copy(f, u, { recursive: !0, overwrite:
|
|
2141
|
+
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2027
2142
|
}
|
|
2028
2143
|
}
|
|
2029
|
-
} catch (
|
|
2030
|
-
throw
|
|
2144
|
+
} catch (r) {
|
|
2145
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
2031
2146
|
}
|
|
2032
2147
|
}
|
|
2033
2148
|
/**
|
|
@@ -2057,9 +2172,9 @@ class ss {
|
|
|
2057
2172
|
*/
|
|
2058
2173
|
async watch(t, e) {
|
|
2059
2174
|
if (!this.options.broadcastChannel)
|
|
2060
|
-
throw new
|
|
2175
|
+
throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
2061
2176
|
const n = {
|
|
2062
|
-
pattern:
|
|
2177
|
+
pattern: ls(t, e?.recursive ?? !0),
|
|
2063
2178
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2064
2179
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2065
2180
|
};
|
|
@@ -2100,15 +2215,15 @@ class ss {
|
|
|
2100
2215
|
*/
|
|
2101
2216
|
async open(t, e) {
|
|
2102
2217
|
await this.mount();
|
|
2103
|
-
const { create: n = !1, exclusive:
|
|
2218
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
|
|
2104
2219
|
try {
|
|
2105
|
-
return n &&
|
|
2220
|
+
return n && r ? await z(o, "exclusive", async () => {
|
|
2106
2221
|
if (await this.exists(o))
|
|
2107
|
-
throw new
|
|
2108
|
-
return this._openFile(o, n,
|
|
2109
|
-
}) : await this._openFile(o, n,
|
|
2222
|
+
throw new K(o);
|
|
2223
|
+
return this._openFile(o, n, i);
|
|
2224
|
+
}) : await this._openFile(o, n, i);
|
|
2110
2225
|
} catch (a) {
|
|
2111
|
-
throw a instanceof
|
|
2226
|
+
throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
|
|
2112
2227
|
}
|
|
2113
2228
|
}
|
|
2114
2229
|
/**
|
|
@@ -2116,19 +2231,19 @@ class ss {
|
|
|
2116
2231
|
* @private
|
|
2117
2232
|
*/
|
|
2118
2233
|
async _openFile(t, e, n) {
|
|
2119
|
-
const
|
|
2234
|
+
const r = await this.getFileHandle(t, e);
|
|
2120
2235
|
try {
|
|
2121
|
-
await
|
|
2236
|
+
await r.getFile();
|
|
2122
2237
|
} catch (a) {
|
|
2123
|
-
throw a
|
|
2238
|
+
throw A(a, { path: t, isDirectory: !0 });
|
|
2124
2239
|
}
|
|
2125
|
-
const
|
|
2126
|
-
n && (
|
|
2240
|
+
const i = await ps(r, t);
|
|
2241
|
+
n && (i.truncate(0), i.flush());
|
|
2127
2242
|
const o = this.nextFd++;
|
|
2128
2243
|
return this.openFiles.set(o, {
|
|
2129
2244
|
path: t,
|
|
2130
|
-
fileHandle:
|
|
2131
|
-
syncHandle:
|
|
2245
|
+
fileHandle: r,
|
|
2246
|
+
syncHandle: i,
|
|
2132
2247
|
position: 0
|
|
2133
2248
|
}), o;
|
|
2134
2249
|
}
|
|
@@ -2148,7 +2263,7 @@ class ss {
|
|
|
2148
2263
|
*/
|
|
2149
2264
|
async close(t) {
|
|
2150
2265
|
const e = this._getFileDescriptor(t);
|
|
2151
|
-
|
|
2266
|
+
xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2152
2267
|
}
|
|
2153
2268
|
/**
|
|
2154
2269
|
* Read data from a file descriptor
|
|
@@ -2174,17 +2289,17 @@ class ss {
|
|
|
2174
2289
|
* await fs.close(fd);
|
|
2175
2290
|
* \`\`\`
|
|
2176
2291
|
*/
|
|
2177
|
-
async read(t, e, n,
|
|
2292
|
+
async read(t, e, n, r, i) {
|
|
2178
2293
|
const o = this._getFileDescriptor(t);
|
|
2179
|
-
|
|
2294
|
+
St(e.length, n, r, i);
|
|
2180
2295
|
try {
|
|
2181
|
-
const a =
|
|
2296
|
+
const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
|
|
2182
2297
|
if (h)
|
|
2183
|
-
return
|
|
2298
|
+
return B({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2184
2299
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2185
|
-
return
|
|
2300
|
+
return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2186
2301
|
} catch (a) {
|
|
2187
|
-
throw
|
|
2302
|
+
throw _("read", t, o.path, a);
|
|
2188
2303
|
}
|
|
2189
2304
|
}
|
|
2190
2305
|
/**
|
|
@@ -2208,14 +2323,14 @@ class ss {
|
|
|
2208
2323
|
* await fs.close(fd);
|
|
2209
2324
|
* \`\`\`
|
|
2210
2325
|
*/
|
|
2211
|
-
async write(t, e, n = 0,
|
|
2212
|
-
const a = this._getFileDescriptor(t), l =
|
|
2213
|
-
|
|
2326
|
+
async write(t, e, n = 0, r, i, o = !0) {
|
|
2327
|
+
const a = this._getFileDescriptor(t), l = r ?? e.length - n;
|
|
2328
|
+
St(e.length, n, l, i);
|
|
2214
2329
|
try {
|
|
2215
|
-
const h =
|
|
2216
|
-
return (
|
|
2330
|
+
const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2331
|
+
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
|
|
2217
2332
|
} catch (h) {
|
|
2218
|
-
throw
|
|
2333
|
+
throw _("write", t, a.path, h);
|
|
2219
2334
|
}
|
|
2220
2335
|
}
|
|
2221
2336
|
/**
|
|
@@ -2259,11 +2374,11 @@ class ss {
|
|
|
2259
2374
|
async ftruncate(t, e = 0) {
|
|
2260
2375
|
const n = this._getFileDescriptor(t);
|
|
2261
2376
|
if (e < 0 || !Number.isInteger(e))
|
|
2262
|
-
throw new
|
|
2377
|
+
throw new N("argument", "Invalid size");
|
|
2263
2378
|
try {
|
|
2264
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2265
|
-
} catch (
|
|
2266
|
-
throw
|
|
2379
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
|
|
2380
|
+
} catch (r) {
|
|
2381
|
+
throw _("truncate", t, n.path, r);
|
|
2267
2382
|
}
|
|
2268
2383
|
}
|
|
2269
2384
|
/**
|
|
@@ -2285,7 +2400,7 @@ class ss {
|
|
|
2285
2400
|
try {
|
|
2286
2401
|
e.syncHandle.flush();
|
|
2287
2402
|
} catch (n) {
|
|
2288
|
-
throw
|
|
2403
|
+
throw _("sync", t, e.path, n);
|
|
2289
2404
|
}
|
|
2290
2405
|
}
|
|
2291
2406
|
/**
|
|
@@ -2297,7 +2412,7 @@ class ss {
|
|
|
2297
2412
|
dispose() {
|
|
2298
2413
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2299
2414
|
for (const [t, e] of this.openFiles)
|
|
2300
|
-
|
|
2415
|
+
xt(t, e.syncHandle, e.path);
|
|
2301
2416
|
this.openFiles.clear(), this.nextFd = 1;
|
|
2302
2417
|
}
|
|
2303
2418
|
/**
|
|
@@ -2332,16 +2447,16 @@ class ss {
|
|
|
2332
2447
|
await this.mount();
|
|
2333
2448
|
try {
|
|
2334
2449
|
for (const [e, n] of t) {
|
|
2335
|
-
const
|
|
2336
|
-
let
|
|
2337
|
-
n instanceof Blob ?
|
|
2450
|
+
const r = G(e);
|
|
2451
|
+
let i;
|
|
2452
|
+
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2338
2453
|
}
|
|
2339
2454
|
} catch (e) {
|
|
2340
|
-
throw e instanceof
|
|
2455
|
+
throw e instanceof w ? e : A(e);
|
|
2341
2456
|
}
|
|
2342
2457
|
}
|
|
2343
2458
|
}
|
|
2344
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2345
|
-
//# sourceMappingURL=worker-
|
|
2346
|
-
`,
|
|
2459
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
|
|
2460
|
+
//# sourceMappingURL=worker-1Wh1cr7P.js.map
|
|
2461
|
+
`,h=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=h&&(self.URL||self.webkitURL).createObjectURL(h),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class p{#n;promises=this;constructor(n){this.#n=d.wrap(new u),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let s;typeof t=="string"?s=t:t&&typeof t=="object"&&(s=t.encoding);const i=await this.#n.readFile(r);return s||(s=e.isBinaryFileExtension(r)?"binary":"utf-8"),s==="binary"?i:e.decodeBuffer(i,s)}async writeFile(n,t,r){const s=a(n);let i;typeof r=="string"?i=r:r&&typeof r=="object"&&(i=r.encoding),i||(i=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const c=typeof t=="string"?e.encodeString(t,i):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(s,c)}async appendFile(n,t,r){const s=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(s,i)}async mkdir(n,t){const r=a(n);let s;return typeof t=="number"?s={recursive:!1}:s=t,this.#n.mkdir(r,s)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const s=a(n),i=a(t);return this.#n.rename(s,i,r)}async copy(n,t,r){const s=a(n),i=a(t);return this.#n.copy(s,i,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,s,i){const{bytesRead:c,buffer:f}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(f.subarray(0,c),r),{bytesRead:c,buffer:t}}async write(n,t,r,s,i,c){return this.#n.write(n,t,r,s,i,c)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async createIndex(n){const t=n.map(([r,s])=>[a(r),s]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),s=await this.#n.readFile(r);return e.decodeBuffer(s,t)}async writeText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.writeFile(s,i)}async appendText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.appendFile(s,i)}}function m(o){return new p(o)}exports.AlreadyExistsError=e.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryOperationError=e.DirectoryOperationError;exports.ExistenceError=e.ExistenceError;exports.FileBusyError=e.FileBusyError;exports.FileSystemOperationError=e.FileSystemOperationError;exports.FileTypeError=e.FileTypeError;exports.IOError=e.IOError;exports.InitializationFailedError=e.InitializationFailedError;exports.OPFSError=e.OPFSError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.OperationAbortedError=e.OperationAbortedError;exports.OperationNotSupportedError=e.OperationNotSupportedError;exports.PathError=e.PathError;exports.PathResolutionFailedError=e.PathResolutionFailedError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.TimeoutError=e.TimeoutError;exports.ValidationError=e.ValidationError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=p;exports.createWorker=m;
|
|
2347
2462
|
//# sourceMappingURL=index.cjs.map
|