opfs-worker 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -27
- package/dist/{BaseOPFS-Cylz6ijk.js → BaseOPFS-BusBkyJX.js} +436 -358
- package/dist/BaseOPFS-BusBkyJX.js.map +1 -0
- package/dist/{BaseOPFS-BPw9AIQ-.cjs → BaseOPFS-CYwrD7-q.cjs} +4 -4
- package/dist/BaseOPFS-CYwrD7-q.cjs.map +1 -0
- package/dist/{OPFSAsync-s2P7y3sw.cjs → OPFSAsync-B2dR-2VR.cjs} +2 -2
- package/dist/{OPFSAsync-s2P7y3sw.cjs.map → OPFSAsync-B2dR-2VR.cjs.map} +1 -1
- package/dist/{OPFSAsync-BKSAJJeh.js → OPFSAsync-CO44W23e.js} +2 -2
- package/dist/{OPFSAsync-BKSAJJeh.js.map → OPFSAsync-CO44W23e.js.map} +1 -1
- package/dist/OPFSFacade-CEaSqTut.js +308 -0
- package/dist/OPFSFacade-CEaSqTut.js.map +1 -0
- package/dist/OPFSFacade-hrNXCn6w.cjs +2 -0
- package/dist/OPFSFacade-hrNXCn6w.cjs.map +1 -0
- package/dist/{OPFSSync-C7KBepe_.cjs → OPFSSync-BPrNtvFS.cjs} +2 -2
- package/dist/{OPFSSync-C7KBepe_.cjs.map → OPFSSync-BPrNtvFS.cjs.map} +1 -1
- package/dist/{OPFSSync-CsSQkpk5.js → OPFSSync-D7obTsl3.js} +2 -2
- package/dist/{OPFSSync-CsSQkpk5.js.map → OPFSSync-D7obTsl3.js.map} +1 -1
- package/dist/assets/dedicated.worker-DW6UqFo0.js.map +1 -0
- package/dist/core/BaseOPFS.d.ts +38 -7
- package/dist/core/BaseOPFS.d.ts.map +1 -1
- package/dist/createOPFSAsync-DdhJYoC0.js +10 -0
- package/dist/{createOPFSAsync-Y4Mg6qte.js.map → createOPFSAsync-DdhJYoC0.js.map} +1 -1
- package/dist/createOPFSAsync-DyWpvmL-.cjs +2 -0
- package/dist/{createOPFSAsync-BwKDmHsy.cjs.map → createOPFSAsync-DyWpvmL-.cjs.map} +1 -1
- package/dist/{createOPFSDedicated-CsnV6MLP.js → createOPFSDedicated-BwTc0NV5.js} +289 -215
- package/dist/{createOPFSDedicated-CsnV6MLP.js.map → createOPFSDedicated-BwTc0NV5.js.map} +1 -1
- package/dist/{createOPFSDedicated-pKTRWLdz.cjs → createOPFSDedicated-CEeRexom.cjs} +286 -212
- package/dist/{createOPFSDedicated-pKTRWLdz.cjs.map → createOPFSDedicated-CEeRexom.cjs.map} +1 -1
- package/dist/{createOPFSShared-CGdd__PH.js → createOPFSShared-BSFWsoLe.js} +2 -2
- package/dist/{createOPFSShared-CGdd__PH.js.map → createOPFSShared-BSFWsoLe.js.map} +1 -1
- package/dist/{createOPFSShared-CskROt7U.cjs → createOPFSShared-BoCft_BS.cjs} +2 -2
- package/dist/{createOPFSShared-CskROt7U.cjs.map → createOPFSShared-BoCft_BS.cjs.map} +1 -1
- package/dist/dedicated.worker.js +282 -208
- package/dist/dedicated.worker.js.map +1 -1
- package/dist/facade/OPFSFacade.d.ts +21 -3
- package/dist/facade/OPFSFacade.d.ts.map +1 -1
- package/dist/index.async.cjs +1 -1
- package/dist/index.async.js +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/index.pure.cjs +1 -1
- package/dist/index.pure.js +3 -3
- package/dist/index.sharedworker.cjs +1 -1
- package/dist/index.sharedworker.js +4 -4
- package/dist/index.sync.cjs +1 -1
- package/dist/index.sync.js +4 -4
- package/dist/shared.worker.js +430 -356
- package/dist/shared.worker.js.map +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/api/backend.md +3 -3
- package/docs/api/create.md +1 -1
- package/docs/api/facade.md +28 -27
- package/docs/choosing-a-mode.md +6 -6
- package/docs/file-descriptors.md +46 -604
- package/docs/guides/async.md +2 -2
- package/docs/guides/dedicated.md +5 -5
- package/docs/guides/hashing.md +2 -2
- package/docs/guides/pure.md +3 -3
- package/docs/guides/sharedworker.md +1 -1
- package/docs/guides/streaming.md +145 -11
- package/docs/guides/watching.md +3 -3
- package/docs/migration.md +3 -3
- package/docs/types.md +92 -154
- package/package.json +12 -2
- package/src/core/BaseOPFS.ts +148 -25
- package/src/facade/OPFSFacade.ts +51 -4
- package/src/types.ts +37 -0
- package/dist/BaseOPFS-BPw9AIQ-.cjs.map +0 -1
- package/dist/BaseOPFS-Cylz6ijk.js.map +0 -1
- package/dist/OPFSFacade-DePnNRgt.cjs +0 -2
- package/dist/OPFSFacade-DePnNRgt.cjs.map +0 -1
- package/dist/OPFSFacade-XohWlHuu.js +0 -281
- package/dist/OPFSFacade-XohWlHuu.js.map +0 -1
- package/dist/assets/dedicated.worker-nY3tK4zi.js.map +0 -1
- package/dist/createOPFSAsync-BwKDmHsy.cjs +0 -2
- package/dist/createOPFSAsync-Y4Mg6qte.js +0 -10
- package/docs/README.md +0 -30
package/dist/shared.worker.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
canHandle: (s) =>
|
|
6
|
+
const St = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), Lt = Symbol("Comlink.releaseProxy"), Y = Symbol("Comlink.finalizer"), H = Symbol("Comlink.thrown"), bt = (s) => typeof s == "object" && s !== null || typeof s == "function", _t = {
|
|
7
|
+
canHandle: (s) => bt(s) && s[St],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
10
10
|
return rt(s, t), [e, [e]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(s) {
|
|
13
|
-
return s.start(),
|
|
13
|
+
return s.start(), Bt(s);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (s) =>
|
|
15
|
+
}, Wt = {
|
|
16
|
+
canHandle: (s) => bt(s) && H in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
19
19
|
return s instanceof Error ? t = {
|
|
@@ -29,10 +29,10 @@ const Et = Symbol("Comlink.proxy"), It = Symbol("Comlink.endpoint"), zt = Symbol
|
|
|
29
29
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
30
30
|
}
|
|
31
31
|
}, xt = /* @__PURE__ */ new Map([
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
32
|
+
["proxy", _t],
|
|
33
|
+
["throw", Wt]
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
35
|
+
function Ht(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;
|
|
@@ -42,34 +42,34 @@ function rt(s, t = globalThis, e = ["*"]) {
|
|
|
42
42
|
t.addEventListener("message", function n(r) {
|
|
43
43
|
if (!r || !r.data)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
45
|
+
if (!Ht(e, r.origin)) {
|
|
46
46
|
console.warn(`Invalid origin '${r.origin}' for comlink proxy`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id: i, type: o, path:
|
|
49
|
+
const { id: i, type: o, path: c } = Object.assign({ path: [] }, r.data), a = (r.data.argumentList || []).map(M);
|
|
50
50
|
let h;
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
52
|
+
const l = c.slice(0, -1).reduce((u, d) => u[d], s), f = c.reduce((u, d) => u[d], s);
|
|
53
53
|
switch (o) {
|
|
54
54
|
case "GET":
|
|
55
55
|
h = f;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
c
|
|
58
|
+
l[c.slice(-1)[0]] = M(r.data.value), h = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
|
-
h = f.apply(
|
|
61
|
+
h = f.apply(l, a);
|
|
62
62
|
break;
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
|
-
const u = new f(...
|
|
66
|
-
h =
|
|
65
|
+
const u = new f(...a);
|
|
66
|
+
h = Vt(u);
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: u, port2: d } = new MessageChannel();
|
|
72
|
-
rt(s, d), h =
|
|
72
|
+
rt(s, d), h = vt(u, [u]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -78,13 +78,13 @@ function rt(s, t = globalThis, e = ["*"]) {
|
|
|
78
78
|
default:
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
} catch (
|
|
82
|
-
h = { value:
|
|
81
|
+
} catch (l) {
|
|
82
|
+
h = { value: l, [H]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((
|
|
85
|
-
const [f, u] = G(
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
87
|
-
}).catch((
|
|
84
|
+
Promise.resolve(h).catch((l) => ({ value: l, [H]: 0 })).then((l) => {
|
|
85
|
+
const [f, u] = G(l);
|
|
86
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), Ot(t), Y in s && typeof s[Y] == "function" && s[Y]());
|
|
87
|
+
}).catch((l) => {
|
|
88
88
|
const [f, u] = G({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
90
|
[H]: 0
|
|
@@ -93,13 +93,13 @@ function rt(s, t = globalThis, e = ["*"]) {
|
|
|
93
93
|
});
|
|
94
94
|
}), t.start && t.start();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function jt(s) {
|
|
97
97
|
return s.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function Ot(s) {
|
|
100
|
+
jt(s) && s.close();
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Bt(s, t) {
|
|
103
103
|
const e = /* @__PURE__ */ new Map();
|
|
104
104
|
return s.addEventListener("message", function(r) {
|
|
105
105
|
const { data: i } = r;
|
|
@@ -118,94 +118,94 @@ function _(s) {
|
|
|
118
118
|
if (s)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function Dt(s) {
|
|
122
122
|
return C(s, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
Ot(s);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
128
|
+
const B = /* @__PURE__ */ new WeakMap(), U = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
129
|
+
const t = (B.get(s) || 0) - 1;
|
|
130
|
+
B.set(s, t), t === 0 && Dt(s);
|
|
131
131
|
});
|
|
132
132
|
function Ut(s, t) {
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
133
|
+
const e = (B.get(t) || 0) + 1;
|
|
134
|
+
B.set(t, e), U && U.register(s, t, s);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function Gt(s) {
|
|
137
|
+
U && U.unregister(s);
|
|
138
138
|
}
|
|
139
139
|
function K(s, t, e = [], n = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let r = !1;
|
|
142
142
|
const i = new Proxy(n, {
|
|
143
|
-
get(o,
|
|
144
|
-
if (_(r),
|
|
143
|
+
get(o, c) {
|
|
144
|
+
if (_(r), c === Lt)
|
|
145
145
|
return () => {
|
|
146
|
-
|
|
146
|
+
Gt(i), Dt(s), t.clear(), r = !0;
|
|
147
147
|
};
|
|
148
|
-
if (
|
|
148
|
+
if (c === "then") {
|
|
149
149
|
if (e.length === 0)
|
|
150
150
|
return { then: () => i };
|
|
151
|
-
const
|
|
151
|
+
const a = C(s, t, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: e.map((h) => h.toString())
|
|
154
154
|
}).then(M);
|
|
155
|
-
return
|
|
155
|
+
return a.then.bind(a);
|
|
156
156
|
}
|
|
157
|
-
return K(s, t, [...e,
|
|
157
|
+
return K(s, t, [...e, c]);
|
|
158
158
|
},
|
|
159
|
-
set(o,
|
|
159
|
+
set(o, c, a) {
|
|
160
160
|
_(r);
|
|
161
|
-
const [h,
|
|
161
|
+
const [h, l] = G(a);
|
|
162
162
|
return C(s, t, {
|
|
163
163
|
type: "SET",
|
|
164
|
-
path: [...e,
|
|
164
|
+
path: [...e, c].map((f) => f.toString()),
|
|
165
165
|
value: h
|
|
166
|
-
},
|
|
166
|
+
}, l).then(M);
|
|
167
167
|
},
|
|
168
|
-
apply(o,
|
|
168
|
+
apply(o, c, a) {
|
|
169
169
|
_(r);
|
|
170
170
|
const h = e[e.length - 1];
|
|
171
|
-
if (h ===
|
|
171
|
+
if (h === zt)
|
|
172
172
|
return C(s, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
174
|
}).then(M);
|
|
175
175
|
if (h === "bind")
|
|
176
176
|
return K(s, t, e.slice(0, -1));
|
|
177
|
-
const [
|
|
177
|
+
const [l, f] = ct(a);
|
|
178
178
|
return C(s, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: e.map((u) => u.toString()),
|
|
181
|
-
argumentList:
|
|
181
|
+
argumentList: l
|
|
182
182
|
}, f).then(M);
|
|
183
183
|
},
|
|
184
|
-
construct(o,
|
|
184
|
+
construct(o, c) {
|
|
185
185
|
_(r);
|
|
186
|
-
const [
|
|
186
|
+
const [a, h] = ct(c);
|
|
187
187
|
return C(s, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
|
-
path: e.map((
|
|
190
|
-
argumentList:
|
|
189
|
+
path: e.map((l) => l.toString()),
|
|
190
|
+
argumentList: a
|
|
191
191
|
}, h).then(M);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
return Ut(i, s), i;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function qt(s) {
|
|
197
197
|
return Array.prototype.concat.apply([], s);
|
|
198
198
|
}
|
|
199
199
|
function ct(s) {
|
|
200
200
|
const t = s.map(G);
|
|
201
|
-
return [t.map((e) => e[0]),
|
|
201
|
+
return [t.map((e) => e[0]), qt(t.map((e) => e[1]))];
|
|
202
202
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
203
|
+
const At = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function vt(s, t) {
|
|
205
|
+
return At.set(s, t), s;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(s, { [
|
|
207
|
+
function Vt(s) {
|
|
208
|
+
return Object.assign(s, { [St]: !0 });
|
|
209
209
|
}
|
|
210
210
|
function G(s) {
|
|
211
211
|
for (const [t, e] of xt)
|
|
@@ -225,7 +225,7 @@ function G(s) {
|
|
|
225
225
|
type: "RAW",
|
|
226
226
|
value: s
|
|
227
227
|
},
|
|
228
|
-
|
|
228
|
+
At.get(s) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
231
|
function M(s) {
|
|
@@ -238,15 +238,15 @@ function M(s) {
|
|
|
238
238
|
}
|
|
239
239
|
function C(s, t, e, n) {
|
|
240
240
|
return new Promise((r) => {
|
|
241
|
-
const i =
|
|
241
|
+
const i = Yt();
|
|
242
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 Yt() {
|
|
246
246
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
247
|
}
|
|
248
248
|
var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
|
|
249
|
-
const
|
|
249
|
+
const Zt = {
|
|
250
250
|
ENOENT: -2,
|
|
251
251
|
// No such file or directory
|
|
252
252
|
EISDIR: -21,
|
|
@@ -283,15 +283,15 @@ class w extends Error {
|
|
|
283
283
|
syscall;
|
|
284
284
|
path;
|
|
285
285
|
constructor(t, e, n, r, i) {
|
|
286
|
-
super(t, { cause: i }), this.name = e, this.errno =
|
|
286
|
+
super(t, { cause: i }), this.name = e, this.errno = Zt[e] || -1, this.path = n, this.syscall = r;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
class
|
|
289
|
+
class Xt extends w {
|
|
290
290
|
constructor(t) {
|
|
291
291
|
super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class Jt extends w {
|
|
295
295
|
constructor(t, e, n) {
|
|
296
296
|
super(t, "INVALID_PATH", e, "access", n);
|
|
297
297
|
}
|
|
@@ -306,17 +306,17 @@ class j extends w {
|
|
|
306
306
|
super(r[t], "ENOENT", e, "access", n);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
class
|
|
309
|
+
class Qt extends w {
|
|
310
310
|
constructor(t, e, n) {
|
|
311
311
|
super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e, n);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
class
|
|
314
|
+
class Kt extends w {
|
|
315
315
|
constructor(t, e, n) {
|
|
316
316
|
super(t, "ENOSPC", e, "write", n);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
class
|
|
319
|
+
class te extends w {
|
|
320
320
|
constructor(t, e) {
|
|
321
321
|
super(`File is busy: ${t}`, "EBUSY", t, "open", e);
|
|
322
322
|
}
|
|
@@ -338,7 +338,7 @@ class lt extends w {
|
|
|
338
338
|
super(e, i[t], n, "validate", r);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
class
|
|
341
|
+
class ee extends w {
|
|
342
342
|
constructor(t, e) {
|
|
343
343
|
super(`Operation aborted: ${t}`, "EINTR", t, "interrupt", e);
|
|
344
344
|
}
|
|
@@ -363,7 +363,7 @@ class et extends w {
|
|
|
363
363
|
super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink", n);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
class
|
|
366
|
+
class se extends w {
|
|
367
367
|
constructor(t, e) {
|
|
368
368
|
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
369
369
|
}
|
|
@@ -378,24 +378,24 @@ class ut extends w {
|
|
|
378
378
|
super(`Destination already exists: ${t}`, "EEXIST", t, "open", e);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function x(s, t) {
|
|
382
382
|
const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
|
|
383
383
|
switch (s.name) {
|
|
384
384
|
case "InvalidStateError":
|
|
385
|
-
return new
|
|
385
|
+
return new te(e || "unknown", s);
|
|
386
386
|
case "QuotaExceededError":
|
|
387
|
-
return new
|
|
387
|
+
return new Kt(`No space left on device: ${e || "unknown"}`, e, s);
|
|
388
388
|
case "NotFoundError":
|
|
389
389
|
return new j(r, e, s);
|
|
390
390
|
case "TypeMismatchError":
|
|
391
391
|
return n !== void 0 ? n ? new tt("directory", e || "unknown", s) : new tt("file", e || "unknown", s) : new lt("argument", `Type mismatch: ${e || "unknown"}`, e, s);
|
|
392
392
|
case "NotAllowedError":
|
|
393
393
|
case "SecurityError":
|
|
394
|
-
return new
|
|
394
|
+
return new Qt(e, "unknown", s);
|
|
395
395
|
case "InvalidModificationError":
|
|
396
396
|
return i === "remove" ? new et("ENOTEMPTY", e, s) : new lt("argument", `Invalid modification: ${e || "unknown"}`, e, s);
|
|
397
397
|
case "AbortError":
|
|
398
|
-
return new
|
|
398
|
+
return new ee(e || "unknown", s);
|
|
399
399
|
case "OperationError":
|
|
400
400
|
return new ht(`Operation failed: ${e || "unknown"}`, e, s);
|
|
401
401
|
case "TypeError":
|
|
@@ -404,8 +404,8 @@ function D(s, t) {
|
|
|
404
404
|
return i === "remove" ? new et("RM_FAILED", e, s) : new ht(`I/O error: ${e || "unknown"}`, e, s);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
const
|
|
408
|
-
const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null &&
|
|
407
|
+
const Nt = (s, t, e) => {
|
|
408
|
+
const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ne(n, r, e);
|
|
409
409
|
return i && {
|
|
410
410
|
start: i[0],
|
|
411
411
|
end: i[1],
|
|
@@ -416,116 +416,116 @@ const vt = (s, t, e) => {
|
|
|
416
416
|
}, ft = (s, t) => {
|
|
417
417
|
const e = t.match(s);
|
|
418
418
|
return e ? e[0] : null;
|
|
419
|
-
},
|
|
420
|
-
let n, r, i, o,
|
|
421
|
-
if (
|
|
419
|
+
}, ne = (s, t, e) => {
|
|
420
|
+
let n, r, i, o, c, a = e.indexOf(s), h = e.indexOf(t, a + 1), l = a;
|
|
421
|
+
if (a >= 0 && h > 0) {
|
|
422
422
|
if (s === t)
|
|
423
|
-
return [
|
|
424
|
-
for (n = [], i = e.length;
|
|
425
|
-
if (
|
|
426
|
-
n.push(
|
|
423
|
+
return [a, h];
|
|
424
|
+
for (n = [], i = e.length; l >= 0 && !c; ) {
|
|
425
|
+
if (l === a)
|
|
426
|
+
n.push(l), a = e.indexOf(s, l + 1);
|
|
427
427
|
else if (n.length === 1) {
|
|
428
428
|
const f = n.pop();
|
|
429
|
-
f !== void 0 && (
|
|
429
|
+
f !== void 0 && (c = [f, h]);
|
|
430
430
|
} else
|
|
431
|
-
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t,
|
|
432
|
-
|
|
431
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
|
|
432
|
+
l = a < h && a >= 0 ? a : h;
|
|
433
433
|
}
|
|
434
|
-
n.length && o !== void 0 && (
|
|
434
|
+
n.length && o !== void 0 && (c = [i, o]);
|
|
435
435
|
}
|
|
436
|
-
return
|
|
437
|
-
},
|
|
436
|
+
return c;
|
|
437
|
+
}, Tt = "\0SLASH" + Math.random() + "\0", Mt = "\0OPEN" + Math.random() + "\0", it = "\0CLOSE" + Math.random() + "\0", Ct = "\0COMMA" + Math.random() + "\0", $t = "\0PERIOD" + Math.random() + "\0", re = new RegExp(Tt, "g"), ie = new RegExp(Mt, "g"), oe = new RegExp(it, "g"), ae = new RegExp(Ct, "g"), ce = new RegExp($t, "g"), le = /\\\\/g, he = /\\{/g, ue = /\\}/g, fe = /\\,/g, de = /\\./g;
|
|
438
438
|
function X(s) {
|
|
439
439
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
440
440
|
}
|
|
441
|
-
function de(s) {
|
|
442
|
-
return s.replace(ce, Nt).replace(le, Tt).replace(he, it).replace(ue, Mt).replace(fe, Ct);
|
|
443
|
-
}
|
|
444
441
|
function pe(s) {
|
|
445
|
-
return s.replace(
|
|
442
|
+
return s.replace(le, Tt).replace(he, Mt).replace(ue, it).replace(fe, Ct).replace(de, $t);
|
|
443
|
+
}
|
|
444
|
+
function ge(s) {
|
|
445
|
+
return s.replace(re, "\\").replace(ie, "{").replace(oe, "}").replace(ae, ",").replace(ce, ".");
|
|
446
446
|
}
|
|
447
447
|
function Pt(s) {
|
|
448
448
|
if (!s)
|
|
449
449
|
return [""];
|
|
450
|
-
const t = [], e =
|
|
450
|
+
const t = [], e = Nt("{", "}", s);
|
|
451
451
|
if (!e)
|
|
452
452
|
return s.split(",");
|
|
453
453
|
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
454
454
|
o[o.length - 1] += "{" + r + "}";
|
|
455
|
-
const
|
|
456
|
-
return i.length && (o[o.length - 1] +=
|
|
457
|
-
}
|
|
458
|
-
function ge(s) {
|
|
459
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), F(de(s), !0).map(pe)) : [];
|
|
455
|
+
const c = Pt(i);
|
|
456
|
+
return i.length && (o[o.length - 1] += c.shift(), o.push.apply(o, c)), t.push.apply(t, o), t;
|
|
460
457
|
}
|
|
461
458
|
function we(s) {
|
|
462
|
-
return "{"
|
|
459
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), F(pe(s), !0).map(ge)) : [];
|
|
463
460
|
}
|
|
464
461
|
function me(s) {
|
|
462
|
+
return "{" + s + "}";
|
|
463
|
+
}
|
|
464
|
+
function ye(s) {
|
|
465
465
|
return /^-?0\d/.test(s);
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Ee(s, t) {
|
|
468
468
|
return s <= t;
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function Se(s, t) {
|
|
471
471
|
return s >= t;
|
|
472
472
|
}
|
|
473
473
|
function F(s, t) {
|
|
474
|
-
const e = [], n =
|
|
474
|
+
const e = [], n = Nt("{", "}", s);
|
|
475
475
|
if (!n)
|
|
476
476
|
return [s];
|
|
477
477
|
const r = n.pre, i = n.post.length ? F(n.post, !1) : [""];
|
|
478
478
|
if (/\$$/.test(n.pre))
|
|
479
479
|
for (let o = 0; o < i.length; o++) {
|
|
480
|
-
const
|
|
481
|
-
e.push(
|
|
480
|
+
const c = r + "{" + n.body + "}" + i[o];
|
|
481
|
+
e.push(c);
|
|
482
482
|
}
|
|
483
483
|
else {
|
|
484
|
-
const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),
|
|
485
|
-
if (!
|
|
484
|
+
const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), c = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), a = o || c, h = n.body.indexOf(",") >= 0;
|
|
485
|
+
if (!a && !h)
|
|
486
486
|
return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + it + n.post, F(s)) : [s];
|
|
487
|
-
let
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
else if (
|
|
491
|
-
return i.map((u) => n.pre +
|
|
487
|
+
let l;
|
|
488
|
+
if (a)
|
|
489
|
+
l = n.body.split(/\.\./);
|
|
490
|
+
else if (l = Pt(n.body), l.length === 1 && l[0] !== void 0 && (l = F(l[0], !1).map(me), l.length === 1))
|
|
491
|
+
return i.map((u) => n.pre + l[0] + u);
|
|
492
492
|
let f;
|
|
493
|
-
if (
|
|
494
|
-
const u = X(
|
|
495
|
-
let p =
|
|
496
|
-
d < u && (p *= -1, S =
|
|
497
|
-
const
|
|
493
|
+
if (a && l[0] !== void 0 && l[1] !== void 0) {
|
|
494
|
+
const u = X(l[0]), d = X(l[1]), g = Math.max(l[0].length, l[1].length);
|
|
495
|
+
let p = l.length === 3 && l[2] !== void 0 ? Math.abs(X(l[2])) : 1, S = Ee;
|
|
496
|
+
d < u && (p *= -1, S = Se);
|
|
497
|
+
const P = l.some(ye);
|
|
498
498
|
f = [];
|
|
499
|
-
for (let
|
|
499
|
+
for (let b = u; S(b, d); b += p) {
|
|
500
500
|
let m;
|
|
501
|
-
if (
|
|
502
|
-
m = String.fromCharCode(
|
|
503
|
-
else if (m = String(
|
|
501
|
+
if (c)
|
|
502
|
+
m = String.fromCharCode(b), m === "\\" && (m = "");
|
|
503
|
+
else if (m = String(b), P) {
|
|
504
504
|
const k = g - m.length;
|
|
505
505
|
if (k > 0) {
|
|
506
506
|
const L = new Array(k + 1).join("0");
|
|
507
|
-
|
|
507
|
+
b < 0 ? m = "-" + L + m.slice(1) : m = L + m;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
f.push(m);
|
|
511
511
|
}
|
|
512
512
|
} else {
|
|
513
513
|
f = [];
|
|
514
|
-
for (let u = 0; u <
|
|
515
|
-
f.push.apply(f, F(
|
|
514
|
+
for (let u = 0; u < l.length; u++)
|
|
515
|
+
f.push.apply(f, F(l[u], !1));
|
|
516
516
|
}
|
|
517
517
|
for (let u = 0; u < f.length; u++)
|
|
518
518
|
for (let d = 0; d < i.length; d++) {
|
|
519
519
|
const g = r + f[u] + i[d];
|
|
520
|
-
(!t ||
|
|
520
|
+
(!t || a || g) && e.push(g);
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
return e;
|
|
524
524
|
}
|
|
525
|
-
const
|
|
525
|
+
const be = 1024 * 64, q = (s) => {
|
|
526
526
|
if (typeof s != "string")
|
|
527
527
|
throw new TypeError("invalid pattern");
|
|
528
|
-
if (s.length >
|
|
528
|
+
if (s.length > be)
|
|
529
529
|
throw new TypeError("pattern is too long");
|
|
530
530
|
}, xe = {
|
|
531
531
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
@@ -542,36 +542,36 @@ const Se = 1024 * 64, q = (s) => {
|
|
|
542
542
|
"[:upper:]": ["\\p{Lu}", !0],
|
|
543
543
|
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
|
|
544
544
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
545
|
-
}, R = (s) => s.replace(/[[\]\\-]/g, "\\$&"),
|
|
545
|
+
}, R = (s) => s.replace(/[[\]\\-]/g, "\\$&"), Oe = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), dt = (s) => s.join(""), De = (s, t) => {
|
|
546
546
|
const e = t;
|
|
547
547
|
if (s.charAt(e) !== "[")
|
|
548
548
|
throw new Error("not in a brace expression");
|
|
549
549
|
const n = [], r = [];
|
|
550
|
-
let i = e + 1, o = !1,
|
|
550
|
+
let i = e + 1, o = !1, c = !1, a = !1, h = !1, l = e, f = "";
|
|
551
551
|
t: for (; i < s.length; ) {
|
|
552
552
|
const p = s.charAt(i);
|
|
553
553
|
if ((p === "!" || p === "^") && i === e + 1) {
|
|
554
554
|
h = !0, i++;
|
|
555
555
|
continue;
|
|
556
556
|
}
|
|
557
|
-
if (p === "]" && o && !
|
|
558
|
-
|
|
557
|
+
if (p === "]" && o && !a) {
|
|
558
|
+
l = i + 1;
|
|
559
559
|
break;
|
|
560
560
|
}
|
|
561
|
-
if (o = !0, p === "\\" && !
|
|
562
|
-
|
|
561
|
+
if (o = !0, p === "\\" && !a) {
|
|
562
|
+
a = !0, i++;
|
|
563
563
|
continue;
|
|
564
564
|
}
|
|
565
|
-
if (p === "[" && !
|
|
566
|
-
for (const [S, [N,
|
|
565
|
+
if (p === "[" && !a) {
|
|
566
|
+
for (const [S, [N, P, b]] of Object.entries(xe))
|
|
567
567
|
if (s.startsWith(S, i)) {
|
|
568
568
|
if (f)
|
|
569
569
|
return ["$.", !1, s.length - e, !0];
|
|
570
|
-
i += S.length,
|
|
570
|
+
i += S.length, b ? r.push(N) : n.push(N), c = c || P;
|
|
571
571
|
continue t;
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
if (
|
|
574
|
+
if (a = !1, f) {
|
|
575
575
|
p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
|
|
576
576
|
continue;
|
|
577
577
|
}
|
|
@@ -585,17 +585,17 @@ const Se = 1024 * 64, q = (s) => {
|
|
|
585
585
|
}
|
|
586
586
|
n.push(R(p)), i++;
|
|
587
587
|
}
|
|
588
|
-
if (
|
|
588
|
+
if (l < i)
|
|
589
589
|
return ["", !1, 0, !1];
|
|
590
590
|
if (!n.length && !r.length)
|
|
591
591
|
return ["$.", !1, s.length - e, !0];
|
|
592
592
|
if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !h) {
|
|
593
593
|
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
594
|
-
return [
|
|
594
|
+
return [Oe(p), !1, l - e, !1];
|
|
595
595
|
}
|
|
596
596
|
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
597
|
-
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d,
|
|
598
|
-
}, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"),
|
|
597
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, c, l - e, !0];
|
|
598
|
+
}, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), Ae = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ae.has(s), ve = "(?!(?:^|/)\\.\\.?(?:$|/))", W = "(?!\\.)", Ne = /* @__PURE__ */ new Set(["[", "."]), Te = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\!"), Ce = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), ot = "[^/]", gt = ot + "*?", wt = ot + "+?";
|
|
599
599
|
class E {
|
|
600
600
|
type;
|
|
601
601
|
#s;
|
|
@@ -696,7 +696,7 @@ class E {
|
|
|
696
696
|
return e;
|
|
697
697
|
}
|
|
698
698
|
static #h(t, e, n, r) {
|
|
699
|
-
let i = !1, o = !1,
|
|
699
|
+
let i = !1, o = !1, c = -1, a = !1;
|
|
700
700
|
if (e.type === null) {
|
|
701
701
|
let d = n, g = "";
|
|
702
702
|
for (; d < t.length; ) {
|
|
@@ -706,10 +706,10 @@ class E {
|
|
|
706
706
|
continue;
|
|
707
707
|
}
|
|
708
708
|
if (o) {
|
|
709
|
-
d ===
|
|
709
|
+
d === c + 1 ? (p === "^" || p === "!") && (a = !0) : p === "]" && !(d === c + 2 && a) && (o = !1), g += p;
|
|
710
710
|
continue;
|
|
711
711
|
} else if (p === "[") {
|
|
712
|
-
o = !0,
|
|
712
|
+
o = !0, c = d, a = !1, g += p;
|
|
713
713
|
continue;
|
|
714
714
|
}
|
|
715
715
|
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
@@ -722,7 +722,7 @@ class E {
|
|
|
722
722
|
}
|
|
723
723
|
return e.push(g), d;
|
|
724
724
|
}
|
|
725
|
-
let h = n + 1,
|
|
725
|
+
let h = n + 1, l = new E(null, e);
|
|
726
726
|
const f = [];
|
|
727
727
|
let u = "";
|
|
728
728
|
for (; h < t.length; ) {
|
|
@@ -732,24 +732,24 @@ class E {
|
|
|
732
732
|
continue;
|
|
733
733
|
}
|
|
734
734
|
if (o) {
|
|
735
|
-
h ===
|
|
735
|
+
h === c + 1 ? (d === "^" || d === "!") && (a = !0) : d === "]" && !(h === c + 2 && a) && (o = !1), u += d;
|
|
736
736
|
continue;
|
|
737
737
|
} else if (d === "[") {
|
|
738
|
-
o = !0,
|
|
738
|
+
o = !0, c = h, a = !1, u += d;
|
|
739
739
|
continue;
|
|
740
740
|
}
|
|
741
741
|
if (pt(d) && t.charAt(h) === "(") {
|
|
742
|
-
|
|
743
|
-
const g = new E(d,
|
|
744
|
-
|
|
742
|
+
l.push(u), u = "";
|
|
743
|
+
const g = new E(d, l);
|
|
744
|
+
l.push(g), h = E.#h(t, g, h, r);
|
|
745
745
|
continue;
|
|
746
746
|
}
|
|
747
747
|
if (d === "|") {
|
|
748
|
-
|
|
748
|
+
l.push(u), u = "", f.push(l), l = new E(null, e);
|
|
749
749
|
continue;
|
|
750
750
|
}
|
|
751
751
|
if (d === ")")
|
|
752
|
-
return u === "" && e.#t.length === 0 && (e.#u = !0),
|
|
752
|
+
return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
|
|
753
753
|
u += d;
|
|
754
754
|
}
|
|
755
755
|
return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
|
|
@@ -766,8 +766,8 @@ class E {
|
|
|
766
766
|
const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
|
|
767
767
|
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
768
768
|
return n;
|
|
769
|
-
const
|
|
770
|
-
return Object.assign(new RegExp(`^${e}$`,
|
|
769
|
+
const c = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
770
|
+
return Object.assign(new RegExp(`^${e}$`, c), {
|
|
771
771
|
_src: e,
|
|
772
772
|
_glob: t
|
|
773
773
|
});
|
|
@@ -847,23 +847,23 @@ class E {
|
|
|
847
847
|
toRegExpSource(t) {
|
|
848
848
|
const e = t ?? !!this.#r.dot;
|
|
849
849
|
if (this.#s === this && this.#d(), !this.type) {
|
|
850
|
-
const
|
|
851
|
-
const [g, p, S, N] = typeof d == "string" ? E.#p(d, this.#n,
|
|
850
|
+
const a = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
851
|
+
const [g, p, S, N] = typeof d == "string" ? E.#p(d, this.#n, a) : d.toRegExpSource(t);
|
|
852
852
|
return this.#n = this.#n || S, this.#i = this.#i || N, g;
|
|
853
853
|
}).join("");
|
|
854
|
-
let
|
|
855
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
856
|
-
const g =
|
|
854
|
+
let l = "";
|
|
855
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Te.has(this.#t[0]))) {
|
|
856
|
+
const g = Ne, p = (
|
|
857
857
|
// dots are allowed, and the pattern starts with [ or .
|
|
858
858
|
e && g.has(h.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
859
859
|
h.startsWith("\\.") && g.has(h.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
860
860
|
h.startsWith("\\.\\.") && g.has(h.charAt(4))
|
|
861
861
|
), S = !e && !t && g.has(h.charAt(0));
|
|
862
|
-
|
|
862
|
+
l = p ? ve : S ? W : "";
|
|
863
863
|
}
|
|
864
864
|
let f = "";
|
|
865
865
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\/)"), [
|
|
866
|
-
|
|
866
|
+
l + h + f,
|
|
867
867
|
I(h),
|
|
868
868
|
this.#n = !!this.#n,
|
|
869
869
|
this.#i
|
|
@@ -872,23 +872,23 @@ class E {
|
|
|
872
872
|
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
873
873
|
let i = this.#f(e);
|
|
874
874
|
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
875
|
-
const
|
|
876
|
-
return this.#t = [
|
|
875
|
+
const a = this.toString();
|
|
876
|
+
return this.#t = [a], this.type = null, this.#n = void 0, [a, I(this.toString()), !1, !1];
|
|
877
877
|
}
|
|
878
878
|
let o = !n || t || e || !W ? "" : this.#f(!0);
|
|
879
879
|
o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
|
|
880
|
-
let
|
|
880
|
+
let c = "";
|
|
881
881
|
if (this.type === "!" && this.#u)
|
|
882
|
-
|
|
882
|
+
c = (this.isStart() && !e ? W : "") + wt;
|
|
883
883
|
else {
|
|
884
|
-
const
|
|
884
|
+
const a = this.type === "!" ? (
|
|
885
885
|
// !() must match something,but !(x) can match ''
|
|
886
886
|
"))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
|
|
887
887
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
888
|
-
|
|
888
|
+
c = r + i + a;
|
|
889
889
|
}
|
|
890
890
|
return [
|
|
891
|
-
|
|
891
|
+
c,
|
|
892
892
|
I(i),
|
|
893
893
|
this.#n = !!this.#n,
|
|
894
894
|
this.#i
|
|
@@ -904,108 +904,108 @@ class E {
|
|
|
904
904
|
}
|
|
905
905
|
static #p(t, e, n = !1) {
|
|
906
906
|
let r = !1, i = "", o = !1;
|
|
907
|
-
for (let
|
|
908
|
-
const
|
|
907
|
+
for (let c = 0; c < t.length; c++) {
|
|
908
|
+
const a = t.charAt(c);
|
|
909
909
|
if (r) {
|
|
910
|
-
r = !1, i += (
|
|
910
|
+
r = !1, i += (Me.has(a) ? "\\" : "") + a;
|
|
911
911
|
continue;
|
|
912
912
|
}
|
|
913
|
-
if (
|
|
914
|
-
|
|
913
|
+
if (a === "\\") {
|
|
914
|
+
c === t.length - 1 ? i += "\\\\" : r = !0;
|
|
915
915
|
continue;
|
|
916
916
|
}
|
|
917
|
-
if (
|
|
918
|
-
const [h,
|
|
917
|
+
if (a === "[") {
|
|
918
|
+
const [h, l, f, u] = De(t, c);
|
|
919
919
|
if (f) {
|
|
920
|
-
i += h, o = o ||
|
|
920
|
+
i += h, o = o || l, c += f - 1, e = e || u;
|
|
921
921
|
continue;
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
-
if (
|
|
924
|
+
if (a === "*") {
|
|
925
925
|
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
926
926
|
continue;
|
|
927
927
|
}
|
|
928
|
-
if (
|
|
928
|
+
if (a === "?") {
|
|
929
929
|
i += ot, e = !0;
|
|
930
930
|
continue;
|
|
931
931
|
}
|
|
932
|
-
i +=
|
|
932
|
+
i += Ce(a);
|
|
933
933
|
}
|
|
934
934
|
return [i, I(t), !!e, o];
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
|
-
const
|
|
938
|
-
const e = $t([s]);
|
|
939
|
-
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
940
|
-
}, qe = ([s, t = ""]) => {
|
|
937
|
+
const $e = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), y = (s, t, e = {}) => (q(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new V(t, e).match(s)), Pe = /^\*+([^+@!?\*\[\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Re = (s) => (t) => t.endsWith(s), Fe = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ie = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), ze = /^\*+\.\*+$/, Le = (s) => !s.startsWith(".") && s.includes("."), _e = (s) => s !== "." && s !== ".." && s.includes("."), We = /^\.\*+$/, He = (s) => s !== "." && s !== ".." && s.startsWith("."), je = /^\*+$/, Be = (s) => s.length !== 0 && !s.startsWith("."), Ue = (s) => s.length !== 0 && s !== "." && s !== "..", Ge = /^\?+([^+@!?\*\[\(]*)?$/, qe = ([s, t = ""]) => {
|
|
941
938
|
const e = kt([s]);
|
|
942
939
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
943
940
|
}, Ve = ([s, t = ""]) => {
|
|
944
|
-
const e =
|
|
945
|
-
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
941
|
+
const e = Rt([s]);
|
|
942
|
+
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
946
943
|
}, Ye = ([s, t = ""]) => {
|
|
947
|
-
const e =
|
|
944
|
+
const e = Rt([s]);
|
|
948
945
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
949
|
-
},
|
|
946
|
+
}, Ze = ([s, t = ""]) => {
|
|
947
|
+
const e = kt([s]);
|
|
948
|
+
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
949
|
+
}, kt = ([s]) => {
|
|
950
950
|
const t = s.length;
|
|
951
951
|
return (e) => e.length === t && !e.startsWith(".");
|
|
952
|
-
},
|
|
952
|
+
}, Rt = ([s]) => {
|
|
953
953
|
const t = s.length;
|
|
954
954
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
955
|
-
},
|
|
955
|
+
}, Ft = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
956
956
|
win32: { sep: "\\" },
|
|
957
957
|
posix: { sep: "/" }
|
|
958
|
-
},
|
|
959
|
-
y.sep =
|
|
960
|
-
const
|
|
961
|
-
y.GLOBSTAR =
|
|
962
|
-
const
|
|
963
|
-
y.filter =
|
|
964
|
-
const
|
|
958
|
+
}, Xe = Ft === "win32" ? mt.win32.sep : mt.posix.sep;
|
|
959
|
+
y.sep = Xe;
|
|
960
|
+
const D = Symbol("globstar **");
|
|
961
|
+
y.GLOBSTAR = D;
|
|
962
|
+
const Je = "[^/]", Qe = Je + "*?", Ke = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", ts = "(?:(?!(?:\\/|^)\\.).)*?", es = (s, t = {}) => (e) => y(e, s, t);
|
|
963
|
+
y.filter = es;
|
|
964
|
+
const O = (s, t = {}) => Object.assign({}, s, t), ss = (s) => {
|
|
965
965
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
966
966
|
return y;
|
|
967
967
|
const t = y;
|
|
968
|
-
return Object.assign((n, r, i = {}) => t(n, r,
|
|
968
|
+
return Object.assign((n, r, i = {}) => t(n, r, O(s, i)), {
|
|
969
969
|
Minimatch: class extends t.Minimatch {
|
|
970
970
|
constructor(r, i = {}) {
|
|
971
|
-
super(r,
|
|
971
|
+
super(r, O(s, i));
|
|
972
972
|
}
|
|
973
973
|
static defaults(r) {
|
|
974
|
-
return t.defaults(
|
|
974
|
+
return t.defaults(O(s, r)).Minimatch;
|
|
975
975
|
}
|
|
976
976
|
},
|
|
977
977
|
AST: class extends t.AST {
|
|
978
978
|
/* c8 ignore start */
|
|
979
979
|
constructor(r, i, o = {}) {
|
|
980
|
-
super(r, i,
|
|
980
|
+
super(r, i, O(s, o));
|
|
981
981
|
}
|
|
982
982
|
/* c8 ignore stop */
|
|
983
983
|
static fromGlob(r, i = {}) {
|
|
984
|
-
return t.AST.fromGlob(r,
|
|
984
|
+
return t.AST.fromGlob(r, O(s, i));
|
|
985
985
|
}
|
|
986
986
|
},
|
|
987
|
-
unescape: (n, r = {}) => t.unescape(n,
|
|
988
|
-
escape: (n, r = {}) => t.escape(n,
|
|
989
|
-
filter: (n, r = {}) => t.filter(n,
|
|
990
|
-
defaults: (n) => t.defaults(
|
|
991
|
-
makeRe: (n, r = {}) => t.makeRe(n,
|
|
992
|
-
braceExpand: (n, r = {}) => t.braceExpand(n,
|
|
993
|
-
match: (n, r, i = {}) => t.match(n, r,
|
|
987
|
+
unescape: (n, r = {}) => t.unescape(n, O(s, r)),
|
|
988
|
+
escape: (n, r = {}) => t.escape(n, O(s, r)),
|
|
989
|
+
filter: (n, r = {}) => t.filter(n, O(s, r)),
|
|
990
|
+
defaults: (n) => t.defaults(O(s, n)),
|
|
991
|
+
makeRe: (n, r = {}) => t.makeRe(n, O(s, r)),
|
|
992
|
+
braceExpand: (n, r = {}) => t.braceExpand(n, O(s, r)),
|
|
993
|
+
match: (n, r, i = {}) => t.match(n, r, O(s, i)),
|
|
994
994
|
sep: t.sep,
|
|
995
|
-
GLOBSTAR:
|
|
995
|
+
GLOBSTAR: D
|
|
996
996
|
});
|
|
997
997
|
};
|
|
998
|
-
y.defaults =
|
|
999
|
-
const
|
|
1000
|
-
y.braceExpand =
|
|
1001
|
-
const
|
|
1002
|
-
y.makeRe =
|
|
1003
|
-
const
|
|
998
|
+
y.defaults = ss;
|
|
999
|
+
const It = (s, t = {}) => (q(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : we(s));
|
|
1000
|
+
y.braceExpand = It;
|
|
1001
|
+
const ns = (s, t = {}) => new V(s, t).makeRe();
|
|
1002
|
+
y.makeRe = ns;
|
|
1003
|
+
const rs = (s, t, e = {}) => {
|
|
1004
1004
|
const n = new V(t, e);
|
|
1005
1005
|
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
1006
1006
|
};
|
|
1007
|
-
y.match =
|
|
1008
|
-
const yt = /[?*]|[+@!]\(.*?\)|\[|\]/,
|
|
1007
|
+
y.match = rs;
|
|
1008
|
+
const yt = /[?*]|[+@!]\(.*?\)|\[|\]/, is = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1009
1009
|
class V {
|
|
1010
1010
|
options;
|
|
1011
1011
|
set;
|
|
@@ -1025,7 +1025,7 @@ class V {
|
|
|
1025
1025
|
windowsNoMagicRoot;
|
|
1026
1026
|
regexp;
|
|
1027
1027
|
constructor(t, e = {}) {
|
|
1028
|
-
q(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform ||
|
|
1028
|
+
q(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ft, 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();
|
|
1029
1029
|
}
|
|
1030
1030
|
hasMagic() {
|
|
1031
1031
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -1051,15 +1051,15 @@ class V {
|
|
|
1051
1051
|
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1052
1052
|
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
1053
1053
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
1054
|
-
let r = this.globParts.map((i, o,
|
|
1054
|
+
let r = this.globParts.map((i, o, c) => {
|
|
1055
1055
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
return [...i.slice(0, 4), ...i.slice(4).map((
|
|
1056
|
+
const a = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
1057
|
+
if (a)
|
|
1058
|
+
return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
|
|
1059
1059
|
if (h)
|
|
1060
|
-
return [i[0], ...i.slice(1).map((
|
|
1060
|
+
return [i[0], ...i.slice(1).map((l) => this.parse(l))];
|
|
1061
1061
|
}
|
|
1062
|
-
return i.map((
|
|
1062
|
+
return i.map((a) => this.parse(a));
|
|
1063
1063
|
});
|
|
1064
1064
|
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1065
1065
|
for (let i = 0; i < this.set.length; i++) {
|
|
@@ -1149,18 +1149,18 @@ class V {
|
|
|
1149
1149
|
for (; n[o + 1] === "**"; )
|
|
1150
1150
|
o++;
|
|
1151
1151
|
o > r && n.splice(r + 1, o - r);
|
|
1152
|
-
let
|
|
1153
|
-
const
|
|
1154
|
-
if (
|
|
1152
|
+
let c = n[r + 1];
|
|
1153
|
+
const a = n[r + 2], h = n[r + 3];
|
|
1154
|
+
if (c !== ".." || !a || a === "." || a === ".." || !h || h === "." || h === "..")
|
|
1155
1155
|
continue;
|
|
1156
1156
|
e = !0, n.splice(r, 1);
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1157
|
+
const l = n.slice(0);
|
|
1158
|
+
l[r] = "**", t.push(l), r--;
|
|
1159
1159
|
}
|
|
1160
1160
|
if (!this.preserveMultipleSlashes) {
|
|
1161
1161
|
for (let o = 1; o < n.length - 1; o++) {
|
|
1162
|
-
const
|
|
1163
|
-
o === 1 &&
|
|
1162
|
+
const c = n[o];
|
|
1163
|
+
o === 1 && c === "" && n[0] === "" || (c === "." || c === "") && (e = !0, n.splice(o, 1), o--);
|
|
1164
1164
|
}
|
|
1165
1165
|
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
|
|
1166
1166
|
}
|
|
@@ -1169,8 +1169,8 @@ class V {
|
|
|
1169
1169
|
const o = n[i - 1];
|
|
1170
1170
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1171
1171
|
e = !0;
|
|
1172
|
-
const
|
|
1173
|
-
n.splice(i - 1, 2, ...
|
|
1172
|
+
const a = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1173
|
+
n.splice(i - 1, 2, ...a), n.length === 0 && n.push(""), i -= 2;
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
@@ -1196,22 +1196,22 @@ class V {
|
|
|
1196
1196
|
return t.filter((e) => e.length);
|
|
1197
1197
|
}
|
|
1198
1198
|
partsMatch(t, e, n = !1) {
|
|
1199
|
-
let r = 0, i = 0, o = [],
|
|
1199
|
+
let r = 0, i = 0, o = [], c = "";
|
|
1200
1200
|
for (; r < t.length && i < e.length; )
|
|
1201
1201
|
if (t[r] === e[i])
|
|
1202
|
-
o.push(
|
|
1202
|
+
o.push(c === "b" ? e[i] : t[r]), r++, i++;
|
|
1203
1203
|
else if (n && t[r] === "**" && e[i] === t[r + 1])
|
|
1204
1204
|
o.push(t[r]), r++;
|
|
1205
1205
|
else if (n && e[i] === "**" && t[r] === e[i + 1])
|
|
1206
1206
|
o.push(e[i]), i++;
|
|
1207
1207
|
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1208
|
-
if (
|
|
1208
|
+
if (c === "b")
|
|
1209
1209
|
return !1;
|
|
1210
|
-
|
|
1210
|
+
c = "a", o.push(t[r]), r++, i++;
|
|
1211
1211
|
} else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
|
|
1212
|
-
if (
|
|
1212
|
+
if (c === "a")
|
|
1213
1213
|
return !1;
|
|
1214
|
-
|
|
1214
|
+
c = "b", o.push(e[i]), r++, i++;
|
|
1215
1215
|
} else
|
|
1216
1216
|
return !1;
|
|
1217
1217
|
return t.length === e.length && o;
|
|
@@ -1233,33 +1233,33 @@ class V {
|
|
|
1233
1233
|
matchOne(t, e, n = !1) {
|
|
1234
1234
|
const r = this.options;
|
|
1235
1235
|
if (this.isWindows) {
|
|
1236
|
-
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]), N = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]),
|
|
1237
|
-
if (typeof
|
|
1238
|
-
const [k, L] = [t[
|
|
1239
|
-
k.toLowerCase() === L.toLowerCase() && (e[m] = k, m >
|
|
1236
|
+
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]), N = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), P = !N && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), b = S ? 3 : p ? 0 : void 0, m = P ? 3 : N ? 0 : void 0;
|
|
1237
|
+
if (typeof b == "number" && typeof m == "number") {
|
|
1238
|
+
const [k, L] = [t[b], e[m]];
|
|
1239
|
+
k.toLowerCase() === L.toLowerCase() && (e[m] = k, m > b ? e = e.slice(m) : b > m && (t = t.slice(b)));
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
1242
|
const { optimizationLevel: i = 1 } = this.options;
|
|
1243
1243
|
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1244
|
-
for (var o = 0,
|
|
1244
|
+
for (var o = 0, c = 0, a = t.length, h = e.length; o < a && c < h; o++, c++) {
|
|
1245
1245
|
this.debug("matchOne loop");
|
|
1246
|
-
var
|
|
1247
|
-
if (this.debug(e,
|
|
1246
|
+
var l = e[c], f = t[o];
|
|
1247
|
+
if (this.debug(e, l, f), l === !1)
|
|
1248
1248
|
return !1;
|
|
1249
|
-
if (
|
|
1250
|
-
this.debug("GLOBSTAR", [e,
|
|
1251
|
-
var u = o, d =
|
|
1249
|
+
if (l === D) {
|
|
1250
|
+
this.debug("GLOBSTAR", [e, l, f]);
|
|
1251
|
+
var u = o, d = c + 1;
|
|
1252
1252
|
if (d === h) {
|
|
1253
|
-
for (this.debug("** at the end"); o <
|
|
1253
|
+
for (this.debug("** at the end"); o < a; o++)
|
|
1254
1254
|
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1255
1255
|
return !1;
|
|
1256
1256
|
return !0;
|
|
1257
1257
|
}
|
|
1258
|
-
for (; u <
|
|
1258
|
+
for (; u < a; ) {
|
|
1259
1259
|
var g = t[u];
|
|
1260
1260
|
if (this.debug(`
|
|
1261
1261
|
globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1262
|
-
return this.debug("globstar found match!", u,
|
|
1262
|
+
return this.debug("globstar found match!", u, a, g), !0;
|
|
1263
1263
|
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1264
1264
|
this.debug("dot detected!", t, u, e, d);
|
|
1265
1265
|
break;
|
|
@@ -1267,32 +1267,32 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1267
1267
|
this.debug("globstar swallow a segment, and continue"), u++;
|
|
1268
1268
|
}
|
|
1269
1269
|
return !!(n && (this.debug(`
|
|
1270
|
-
>>> no match, partial?`, t, u, e, d), u ===
|
|
1270
|
+
>>> no match, partial?`, t, u, e, d), u === a));
|
|
1271
1271
|
}
|
|
1272
1272
|
let p;
|
|
1273
|
-
if (typeof
|
|
1273
|
+
if (typeof l == "string" ? (p = f === l, this.debug("string match", l, f, p)) : (p = l.test(f), this.debug("pattern match", l, f, p)), !p)
|
|
1274
1274
|
return !1;
|
|
1275
1275
|
}
|
|
1276
|
-
if (o ===
|
|
1276
|
+
if (o === a && c === h)
|
|
1277
1277
|
return !0;
|
|
1278
|
-
if (o ===
|
|
1278
|
+
if (o === a)
|
|
1279
1279
|
return n;
|
|
1280
|
-
if (
|
|
1281
|
-
return o ===
|
|
1280
|
+
if (c === h)
|
|
1281
|
+
return o === a - 1 && t[o] === "";
|
|
1282
1282
|
throw new Error("wtf?");
|
|
1283
1283
|
}
|
|
1284
1284
|
braceExpand() {
|
|
1285
|
-
return
|
|
1285
|
+
return It(this.pattern, this.options);
|
|
1286
1286
|
}
|
|
1287
1287
|
parse(t) {
|
|
1288
1288
|
q(t);
|
|
1289
1289
|
const e = this.options;
|
|
1290
1290
|
if (t === "**")
|
|
1291
|
-
return
|
|
1291
|
+
return D;
|
|
1292
1292
|
if (t === "")
|
|
1293
1293
|
return "";
|
|
1294
1294
|
let n, r = null;
|
|
1295
|
-
(n = t.match(
|
|
1295
|
+
(n = t.match(je)) ? r = e.dot ? Ue : Be : (n = t.match(Pe)) ? r = (e.nocase ? e.dot ? Ie : Fe : e.dot ? Re : ke)(n[1]) : (n = t.match(Ge)) ? r = (e.nocase ? e.dot ? Ve : qe : e.dot ? Ye : Ze)(n) : (n = t.match(ze)) ? r = e.dot ? _e : Le : (n = t.match(We)) && (r = He);
|
|
1296
1296
|
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1297
1297
|
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1298
1298
|
}
|
|
@@ -1302,21 +1302,21 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1302
1302
|
const t = this.set;
|
|
1303
1303
|
if (!t.length)
|
|
1304
1304
|
return this.regexp = !1, this.regexp;
|
|
1305
|
-
const e = this.options, n = e.noglobstar ?
|
|
1306
|
-
let i = t.map((
|
|
1307
|
-
const h =
|
|
1308
|
-
if (
|
|
1309
|
-
for (const f of
|
|
1305
|
+
const e = this.options, n = e.noglobstar ? Qe : e.dot ? Ke : ts, r = new Set(e.nocase ? ["i"] : []);
|
|
1306
|
+
let i = t.map((a) => {
|
|
1307
|
+
const h = a.map((l) => {
|
|
1308
|
+
if (l instanceof RegExp)
|
|
1309
|
+
for (const f of l.flags.split(""))
|
|
1310
1310
|
r.add(f);
|
|
1311
|
-
return typeof
|
|
1311
|
+
return typeof l == "string" ? is(l) : l === D ? D : l._src;
|
|
1312
1312
|
});
|
|
1313
|
-
return h.forEach((
|
|
1313
|
+
return h.forEach((l, f) => {
|
|
1314
1314
|
const u = h[f + 1], d = h[f - 1];
|
|
1315
|
-
|
|
1316
|
-
}), h.filter((
|
|
1315
|
+
l !== D || d === D || (d === void 0 ? u !== void 0 && u !== D ? h[f + 1] = "(?:\\/|" + n + "\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\/|" + n + ")?" : u !== D && (h[f - 1] = d + "(?:\\/|\\/" + n + "\\/)" + u, h[f + 1] = D));
|
|
1316
|
+
}), h.filter((l) => l !== D).join("/");
|
|
1317
1317
|
}).join("|");
|
|
1318
|
-
const [o,
|
|
1319
|
-
i = "^" + o + i +
|
|
1318
|
+
const [o, c] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1319
|
+
i = "^" + o + i + c + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1320
1320
|
try {
|
|
1321
1321
|
this.regexp = new RegExp(i, [...r].join(""));
|
|
1322
1322
|
} catch {
|
|
@@ -1342,12 +1342,12 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1342
1342
|
this.debug(this.pattern, "set", i);
|
|
1343
1343
|
let o = r[r.length - 1];
|
|
1344
1344
|
if (!o)
|
|
1345
|
-
for (let
|
|
1346
|
-
o = r[
|
|
1347
|
-
for (let
|
|
1348
|
-
const
|
|
1345
|
+
for (let c = r.length - 2; !o && c >= 0; c--)
|
|
1346
|
+
o = r[c];
|
|
1347
|
+
for (let c = 0; c < i.length; c++) {
|
|
1348
|
+
const a = i[c];
|
|
1349
1349
|
let h = r;
|
|
1350
|
-
if (n.matchBase &&
|
|
1350
|
+
if (n.matchBase && a.length === 1 && (h = [o]), this.matchOne(h, a, e))
|
|
1351
1351
|
return n.flipNegate ? !0 : !this.negate;
|
|
1352
1352
|
}
|
|
1353
1353
|
return n.flipNegate ? !1 : this.negate;
|
|
@@ -1358,33 +1358,33 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1358
1358
|
}
|
|
1359
1359
|
y.AST = E;
|
|
1360
1360
|
y.Minimatch = V;
|
|
1361
|
-
y.escape =
|
|
1361
|
+
y.escape = $e;
|
|
1362
1362
|
y.unescape = I;
|
|
1363
|
-
function
|
|
1363
|
+
function os() {
|
|
1364
1364
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1365
|
-
throw new
|
|
1365
|
+
throw new Xt();
|
|
1366
1366
|
}
|
|
1367
1367
|
async function z(s, t) {
|
|
1368
1368
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: "exclusive" }, t) : t();
|
|
1369
1369
|
}
|
|
1370
|
-
function
|
|
1370
|
+
function $(s) {
|
|
1371
1371
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1372
1372
|
}
|
|
1373
1373
|
function at(s) {
|
|
1374
1374
|
return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
|
|
1375
1375
|
}
|
|
1376
1376
|
function st(s) {
|
|
1377
|
-
const t =
|
|
1377
|
+
const t = $(s);
|
|
1378
1378
|
return t[t.length - 1] || "";
|
|
1379
1379
|
}
|
|
1380
1380
|
function J(s) {
|
|
1381
|
-
const t =
|
|
1381
|
+
const t = $(s);
|
|
1382
1382
|
return t.pop(), at(t);
|
|
1383
1383
|
}
|
|
1384
1384
|
function nt(s) {
|
|
1385
1385
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
|
|
1386
1386
|
}
|
|
1387
|
-
function
|
|
1387
|
+
function as(s, t = !1) {
|
|
1388
1388
|
return s = s.replace(/\/$/, ""), t && !s.includes("*") ? `${s}/**` : s;
|
|
1389
1389
|
}
|
|
1390
1390
|
function Q(s, t) {
|
|
@@ -1393,8 +1393,8 @@ function Q(s, t) {
|
|
|
1393
1393
|
matchBase: !0
|
|
1394
1394
|
});
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1397
|
-
const t = nt(s), e =
|
|
1396
|
+
function cs(s) {
|
|
1397
|
+
const t = nt(s), e = $(t), n = [];
|
|
1398
1398
|
for (const r of e)
|
|
1399
1399
|
if (!(r === "." || r === ""))
|
|
1400
1400
|
if (r === "..") {
|
|
@@ -1405,16 +1405,12 @@ function as(s) {
|
|
|
1405
1405
|
n.push(r);
|
|
1406
1406
|
return at(n);
|
|
1407
1407
|
}
|
|
1408
|
-
async function
|
|
1408
|
+
async function ls(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1409
1409
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1410
1410
|
throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
|
|
1411
1411
|
const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
|
|
1412
1412
|
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1413
1413
|
}
|
|
1414
|
-
async function ls(s) {
|
|
1415
|
-
const t = await s.arrayBuffer();
|
|
1416
|
-
return new Uint8Array(t);
|
|
1417
|
-
}
|
|
1418
1414
|
async function hs(s, t, e = {}) {
|
|
1419
1415
|
const n = st(t);
|
|
1420
1416
|
return z(t, async () => {
|
|
@@ -1424,11 +1420,11 @@ async function hs(s, t, e = {}) {
|
|
|
1424
1420
|
} catch (o) {
|
|
1425
1421
|
if (o.name === "NotFoundError" && i)
|
|
1426
1422
|
return;
|
|
1427
|
-
const
|
|
1428
|
-
throw
|
|
1423
|
+
const c = o.name === "TypeMismatchError" && !r;
|
|
1424
|
+
throw x(o, {
|
|
1429
1425
|
path: t,
|
|
1430
1426
|
operation: "remove",
|
|
1431
|
-
isDirectory:
|
|
1427
|
+
isDirectory: c
|
|
1432
1428
|
});
|
|
1433
1429
|
}
|
|
1434
1430
|
});
|
|
@@ -1484,7 +1480,7 @@ class us {
|
|
|
1484
1480
|
}
|
|
1485
1481
|
}
|
|
1486
1482
|
constructor(t) {
|
|
1487
|
-
|
|
1483
|
+
os(), t && this.setOptions(t);
|
|
1488
1484
|
}
|
|
1489
1485
|
/**
|
|
1490
1486
|
* Initialize the file system within a given directory.
|
|
@@ -1497,7 +1493,7 @@ class us {
|
|
|
1497
1493
|
const r = await navigator.storage.getDirectory();
|
|
1498
1494
|
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1499
1495
|
} catch (r) {
|
|
1500
|
-
n(new
|
|
1496
|
+
n(new se(t, r));
|
|
1501
1497
|
} finally {
|
|
1502
1498
|
this.mountingPromise = null;
|
|
1503
1499
|
}
|
|
@@ -1535,7 +1531,7 @@ class us {
|
|
|
1535
1531
|
* ```
|
|
1536
1532
|
*/
|
|
1537
1533
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1538
|
-
const r = Array.isArray(t) ? t :
|
|
1534
|
+
const r = Array.isArray(t) ? t : $(t);
|
|
1539
1535
|
let i = n;
|
|
1540
1536
|
for (const o of r)
|
|
1541
1537
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
@@ -1561,9 +1557,9 @@ class us {
|
|
|
1561
1557
|
* ```
|
|
1562
1558
|
*/
|
|
1563
1559
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1564
|
-
const r =
|
|
1560
|
+
const r = $(t);
|
|
1565
1561
|
if (r.length === 0)
|
|
1566
|
-
throw new
|
|
1562
|
+
throw new Jt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1567
1563
|
const i = r.pop();
|
|
1568
1564
|
return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
|
|
1569
1565
|
}
|
|
@@ -1592,10 +1588,10 @@ class us {
|
|
|
1592
1588
|
for (const i of r) {
|
|
1593
1589
|
const o = `${n === "/" ? "" : n}/${i.name}`;
|
|
1594
1590
|
try {
|
|
1595
|
-
const
|
|
1596
|
-
t.set(o,
|
|
1597
|
-
} catch (
|
|
1598
|
-
console.warn(`Skipping broken entry: ${o}`,
|
|
1591
|
+
const c = await this.stat(o);
|
|
1592
|
+
t.set(o, c), c.isDirectory && await e(o);
|
|
1593
|
+
} catch (c) {
|
|
1594
|
+
console.warn(`Skipping broken entry: ${o}`, c);
|
|
1599
1595
|
}
|
|
1600
1596
|
}
|
|
1601
1597
|
};
|
|
@@ -1631,17 +1627,17 @@ class us {
|
|
|
1631
1627
|
*/
|
|
1632
1628
|
async mkdir(t, e) {
|
|
1633
1629
|
await this.mount();
|
|
1634
|
-
const n = e?.recursive ?? !1, r =
|
|
1630
|
+
const n = e?.recursive ?? !1, r = $(t);
|
|
1635
1631
|
let i = this.root;
|
|
1636
1632
|
for (let o = 0; o < r.length; o++) {
|
|
1637
|
-
const
|
|
1633
|
+
const c = r[o];
|
|
1638
1634
|
try {
|
|
1639
|
-
i = await i.getDirectoryHandle(
|
|
1640
|
-
} catch (
|
|
1641
|
-
throw
|
|
1635
|
+
i = await i.getDirectoryHandle(c, { create: n || o === r.length - 1 });
|
|
1636
|
+
} catch (a) {
|
|
1637
|
+
throw a.name === "NotFoundError" ? x(a, {
|
|
1642
1638
|
path: at(r.slice(0, o + 1)),
|
|
1643
1639
|
existenceType: "directory"
|
|
1644
|
-
}) :
|
|
1640
|
+
}) : a.name === "TypeMismatchError" ? x(a, { path: c, isDirectory: !1 }) : new Z("create directory", c, a);
|
|
1645
1641
|
}
|
|
1646
1642
|
}
|
|
1647
1643
|
await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
|
|
@@ -1682,7 +1678,7 @@ class us {
|
|
|
1682
1678
|
let n;
|
|
1683
1679
|
try {
|
|
1684
1680
|
n = await this.getDirectoryHandle(J(t), !1);
|
|
1685
|
-
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(),
|
|
1681
|
+
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), c = {
|
|
1686
1682
|
kind: "file",
|
|
1687
1683
|
size: o.size,
|
|
1688
1684
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1691,15 +1687,15 @@ class us {
|
|
|
1691
1687
|
isDirectory: !1
|
|
1692
1688
|
};
|
|
1693
1689
|
if (r === "etag")
|
|
1694
|
-
|
|
1690
|
+
c.hash = `${o.lastModified.toString(36)}-${o.size.toString(36)}`;
|
|
1695
1691
|
else if (typeof r == "string")
|
|
1696
1692
|
try {
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
} catch (
|
|
1700
|
-
console.warn(`Failed to calculate hash for ${t}:`,
|
|
1693
|
+
const a = await ls(o, r, this.options.maxFileSize);
|
|
1694
|
+
c.hash = a;
|
|
1695
|
+
} catch (a) {
|
|
1696
|
+
console.warn(`Failed to calculate hash for ${t}:`, a);
|
|
1701
1697
|
}
|
|
1702
|
-
return
|
|
1698
|
+
return c;
|
|
1703
1699
|
} catch (r) {
|
|
1704
1700
|
if (r.name === "NotFoundError")
|
|
1705
1701
|
throw new j("file", t, r);
|
|
@@ -1821,7 +1817,7 @@ class us {
|
|
|
1821
1817
|
}
|
|
1822
1818
|
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
|
|
1823
1819
|
} catch (e) {
|
|
1824
|
-
throw e instanceof w ? e :
|
|
1820
|
+
throw e instanceof w ? e : x(e, { path: t, isDirectory: !0 });
|
|
1825
1821
|
}
|
|
1826
1822
|
}
|
|
1827
1823
|
/**
|
|
@@ -1875,12 +1871,12 @@ class us {
|
|
|
1875
1871
|
async realpath(t) {
|
|
1876
1872
|
await this.mount();
|
|
1877
1873
|
try {
|
|
1878
|
-
const e =
|
|
1874
|
+
const e = cs(t);
|
|
1879
1875
|
if (!await this.exists(e))
|
|
1880
1876
|
throw new j("file", e);
|
|
1881
1877
|
return e;
|
|
1882
1878
|
} catch (e) {
|
|
1883
|
-
throw e instanceof w ? e :
|
|
1879
|
+
throw e instanceof w ? e : x(e, { path: t });
|
|
1884
1880
|
}
|
|
1885
1881
|
}
|
|
1886
1882
|
/**
|
|
@@ -1913,7 +1909,7 @@ class us {
|
|
|
1913
1909
|
throw new ut(e);
|
|
1914
1910
|
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: i.isDirectory });
|
|
1915
1911
|
} catch (r) {
|
|
1916
|
-
throw r instanceof w ? r :
|
|
1912
|
+
throw r instanceof w ? r : x(r, { path: t });
|
|
1917
1913
|
}
|
|
1918
1914
|
}
|
|
1919
1915
|
/**
|
|
@@ -1957,13 +1953,13 @@ class us {
|
|
|
1957
1953
|
throw new tt("directory", t);
|
|
1958
1954
|
await this.mkdir(e, { recursive: !0 });
|
|
1959
1955
|
const h = await this.readDir(t);
|
|
1960
|
-
for (const
|
|
1961
|
-
const f = `${t}/${
|
|
1956
|
+
for (const l of h) {
|
|
1957
|
+
const f = `${t}/${l.name}`, u = `${e}/${l.name}`;
|
|
1962
1958
|
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
1963
1959
|
}
|
|
1964
1960
|
}
|
|
1965
1961
|
} catch (r) {
|
|
1966
|
-
throw r instanceof w ? r :
|
|
1962
|
+
throw r instanceof w ? r : x(r, { path: t });
|
|
1967
1963
|
}
|
|
1968
1964
|
}
|
|
1969
1965
|
/**
|
|
@@ -1995,7 +1991,7 @@ class us {
|
|
|
1995
1991
|
if (!this.options.broadcastChannel)
|
|
1996
1992
|
throw new v("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
1997
1993
|
const n = {
|
|
1998
|
-
pattern:
|
|
1994
|
+
pattern: as(t, e?.recursive ?? !0),
|
|
1999
1995
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2000
1996
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2001
1997
|
};
|
|
@@ -2008,32 +2004,90 @@ class us {
|
|
|
2008
2004
|
this.watchers.delete(t);
|
|
2009
2005
|
}
|
|
2010
2006
|
/**
|
|
2011
|
-
*
|
|
2007
|
+
* Read a file as a `Blob` without copying its bytes into memory.
|
|
2008
|
+
*
|
|
2009
|
+
* OPFS hands back a disk-backed `File`, so the browser can stream it on
|
|
2010
|
+
* demand — pass it to `URL.createObjectURL()` for `<video>` / `<audio>` /
|
|
2011
|
+
* `<img>` and only the played range is actually read. Structured clone keeps
|
|
2012
|
+
* the reference intact when the file system runs in a worker.
|
|
2013
|
+
*
|
|
2014
|
+
* @param path - Path to the file
|
|
2015
|
+
* @returns Lazy `File` handle backed by OPFS storage
|
|
2016
|
+
* @throws {OPFSError} If the path is missing or is a directory
|
|
2012
2017
|
*
|
|
2013
|
-
* @
|
|
2018
|
+
* @example
|
|
2019
|
+
* ```typescript
|
|
2020
|
+
* const blob = await fs.readBlob('/media/clip.mp4');
|
|
2021
|
+
* video.src = URL.createObjectURL(blob);
|
|
2022
|
+
* ```
|
|
2023
|
+
*/
|
|
2024
|
+
async readBlob(t) {
|
|
2025
|
+
await this.mount();
|
|
2026
|
+
try {
|
|
2027
|
+
return await (await this.getFileHandle(t, !1)).getFile();
|
|
2028
|
+
} catch (e) {
|
|
2029
|
+
throw e instanceof w ? e : x(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Bulk-import files from `[path, data]` entries (strings, bytes, Blobs, or Files).
|
|
2034
|
+
* Each entry is written via {@link writeStream} so large Blobs/Files are not
|
|
2035
|
+
* fully buffered in memory.
|
|
2036
|
+
*
|
|
2037
|
+
* Accepts an array of tuples, a `Map`, or any iterable of `[path, data]` pairs.
|
|
2038
|
+
*
|
|
2039
|
+
* @param entries - Files to write
|
|
2040
|
+
* @param onProgress - Per-chunk progress with path, index, and byte counts
|
|
2041
|
+
* @returns Written paths, count, and total bytes
|
|
2014
2042
|
* @throws {OPFSError} If a write fails
|
|
2015
2043
|
*
|
|
2016
2044
|
* @example
|
|
2017
2045
|
* ```typescript
|
|
2018
|
-
* await fs.
|
|
2046
|
+
* const result = await fs.importFiles([
|
|
2019
2047
|
* ['/config.json', JSON.stringify({ theme: 'dark' })],
|
|
2020
2048
|
* ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
|
|
2021
|
-
* ['/upload.txt',
|
|
2022
|
-
* ]);
|
|
2049
|
+
* ['/upload.txt', fileFromInput],
|
|
2050
|
+
* ], (p) => console.log(`${p.path}: ${p.bytesWritten}/${p.bytesTotal}`));
|
|
2051
|
+
*
|
|
2052
|
+
* console.log(result.count, result.bytesWritten, result.paths);
|
|
2023
2053
|
* ```
|
|
2024
2054
|
*/
|
|
2025
|
-
async
|
|
2055
|
+
async importFiles(t, e) {
|
|
2026
2056
|
await this.mount();
|
|
2057
|
+
const n = [...t].map(([a, h]) => [nt(a), h]), r = n.length, i = n.map(([a]) => a), o = n.reduce((a, [, h]) => a + fs(h), 0);
|
|
2058
|
+
let c = 0;
|
|
2027
2059
|
try {
|
|
2028
|
-
for (
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2031
|
-
|
|
2060
|
+
for (let a = 0; a < r; a++) {
|
|
2061
|
+
const [h, l] = n[a], { stream: f, size: u } = ds(l), d = c, g = await this.writeStream(
|
|
2062
|
+
h,
|
|
2063
|
+
f,
|
|
2064
|
+
e ? (p) => e({
|
|
2065
|
+
path: h,
|
|
2066
|
+
index: a,
|
|
2067
|
+
count: r,
|
|
2068
|
+
bytesWritten: p,
|
|
2069
|
+
bytesTotal: u,
|
|
2070
|
+
totalBytesWritten: d + p,
|
|
2071
|
+
totalBytes: o
|
|
2072
|
+
}) : void 0
|
|
2073
|
+
);
|
|
2074
|
+
c += g;
|
|
2032
2075
|
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2076
|
+
return {
|
|
2077
|
+
paths: i,
|
|
2078
|
+
count: r,
|
|
2079
|
+
bytesWritten: c
|
|
2080
|
+
};
|
|
2081
|
+
} catch (a) {
|
|
2082
|
+
throw a instanceof w ? a : x(a);
|
|
2035
2083
|
}
|
|
2036
2084
|
}
|
|
2085
|
+
/**
|
|
2086
|
+
* @deprecated Use {@link importFiles} instead.
|
|
2087
|
+
*/
|
|
2088
|
+
async createIndex(t) {
|
|
2089
|
+
ps(), await this.importFiles(t);
|
|
2090
|
+
}
|
|
2037
2091
|
/**
|
|
2038
2092
|
* Dispose of resources and clean up the file system instance
|
|
2039
2093
|
*/
|
|
@@ -2041,17 +2095,37 @@ class us {
|
|
|
2041
2095
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2042
2096
|
}
|
|
2043
2097
|
}
|
|
2098
|
+
function fs(s) {
|
|
2099
|
+
return typeof s == "string" ? new TextEncoder().encode(s).byteLength : s instanceof Blob ? s.size : s.byteLength;
|
|
2100
|
+
}
|
|
2101
|
+
function ds(s) {
|
|
2102
|
+
if (s instanceof Blob)
|
|
2103
|
+
return { stream: s.stream(), size: s.size };
|
|
2104
|
+
const t = typeof s == "string" ? new TextEncoder().encode(s) : s;
|
|
2105
|
+
return {
|
|
2106
|
+
size: t.byteLength,
|
|
2107
|
+
stream: new ReadableStream({
|
|
2108
|
+
start(e) {
|
|
2109
|
+
e.enqueue(t), e.close();
|
|
2110
|
+
}
|
|
2111
|
+
})
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
let Et = !1;
|
|
2115
|
+
function ps() {
|
|
2116
|
+
Et || (Et = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
|
|
2117
|
+
}
|
|
2044
2118
|
const T = "file descriptors are not available in the async backend, use the dedicated worker backend (`createOPFSDedicated`) for positional I/O";
|
|
2045
|
-
class
|
|
2119
|
+
class gs extends us {
|
|
2046
2120
|
async readFile(t) {
|
|
2047
2121
|
await this.mount();
|
|
2048
2122
|
try {
|
|
2049
2123
|
return await z(t, async () => {
|
|
2050
2124
|
const n = await (await this.getFileHandle(t, !1)).getFile(), r = new Uint8Array(await n.arrayBuffer());
|
|
2051
|
-
return
|
|
2125
|
+
return vt(r, [r.buffer]);
|
|
2052
2126
|
});
|
|
2053
2127
|
} catch (e) {
|
|
2054
|
-
throw e instanceof w ? e :
|
|
2128
|
+
throw e instanceof w ? e : x(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
|
|
2055
2129
|
}
|
|
2056
2130
|
}
|
|
2057
2131
|
async writeFile(t, e) {
|
|
@@ -2063,7 +2137,7 @@ class fs extends us {
|
|
|
2063
2137
|
await this._writeStream(i, async (o) => o.write(n)), await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
|
|
2064
2138
|
});
|
|
2065
2139
|
} catch (r) {
|
|
2066
|
-
throw r instanceof w ? r :
|
|
2140
|
+
throw r instanceof w ? r : x(r, { path: t, isDirectory: r?.name === "TypeMismatchError" });
|
|
2067
2141
|
}
|
|
2068
2142
|
}
|
|
2069
2143
|
async appendFile(t, e) {
|
|
@@ -2079,7 +2153,7 @@ class fs extends us {
|
|
|
2079
2153
|
), await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
|
|
2080
2154
|
});
|
|
2081
2155
|
} catch (r) {
|
|
2082
|
-
throw r instanceof w ? r :
|
|
2156
|
+
throw r instanceof w ? r : x(r, { path: t, isDirectory: r?.name === "TypeMismatchError" });
|
|
2083
2157
|
}
|
|
2084
2158
|
}
|
|
2085
2159
|
async writeStream(t, e, n) {
|
|
@@ -2087,19 +2161,19 @@ class fs extends us {
|
|
|
2087
2161
|
try {
|
|
2088
2162
|
return await z(t, async () => {
|
|
2089
2163
|
const r = await this.exists(t), i = await this.getFileHandle(t, !0), o = e.getReader();
|
|
2090
|
-
let
|
|
2164
|
+
let c = 0;
|
|
2091
2165
|
try {
|
|
2092
|
-
await this._writeStream(i, async (
|
|
2166
|
+
await this._writeStream(i, async (a) => {
|
|
2093
2167
|
for (; ; ) {
|
|
2094
|
-
const { done: h, value:
|
|
2168
|
+
const { done: h, value: l } = await o.read();
|
|
2095
2169
|
if (h)
|
|
2096
2170
|
break;
|
|
2097
|
-
await
|
|
2171
|
+
await a.write(l), c += l.byteLength, await n?.(c);
|
|
2098
2172
|
}
|
|
2099
2173
|
});
|
|
2100
|
-
} catch (
|
|
2101
|
-
throw await o.cancel(
|
|
2102
|
-
}),
|
|
2174
|
+
} catch (a) {
|
|
2175
|
+
throw await o.cancel(a).catch(() => {
|
|
2176
|
+
}), a;
|
|
2103
2177
|
} finally {
|
|
2104
2178
|
o.releaseLock();
|
|
2105
2179
|
}
|
|
@@ -2107,10 +2181,10 @@ class fs extends us {
|
|
|
2107
2181
|
path: t,
|
|
2108
2182
|
type: r ? A.Changed : A.Added,
|
|
2109
2183
|
isDirectory: !1
|
|
2110
|
-
}),
|
|
2184
|
+
}), c;
|
|
2111
2185
|
});
|
|
2112
2186
|
} catch (r) {
|
|
2113
|
-
throw r instanceof w ? r :
|
|
2187
|
+
throw r instanceof w ? r : x(r, { path: t, isDirectory: r?.name === "TypeMismatchError" });
|
|
2114
2188
|
}
|
|
2115
2189
|
}
|
|
2116
2190
|
/**
|
|
@@ -2159,8 +2233,8 @@ class fs extends us {
|
|
|
2159
2233
|
throw new v(T);
|
|
2160
2234
|
}
|
|
2161
2235
|
}
|
|
2162
|
-
const
|
|
2236
|
+
const ws = new gs();
|
|
2163
2237
|
globalThis.onconnect = (s) => {
|
|
2164
|
-
rt(
|
|
2238
|
+
rt(ws, s.ports[0]);
|
|
2165
2239
|
};
|
|
2166
2240
|
//# sourceMappingURL=shared.worker.js.map
|