opfs-worker 1.3.2 → 2.0.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/README.md +89 -106
- package/dist/{facade.d.ts → OPFSFacade.d.ts} +22 -5
- package/dist/OPFSFacade.d.ts.map +1 -0
- package/dist/{worker.d.ts → OPFSWorker.d.ts} +10 -6
- package/dist/OPFSWorker.d.ts.map +1 -0
- package/dist/assets/worker.entry-DUlEoroc.js.map +1 -0
- package/dist/createOPFSWorker.d.ts +17 -0
- package/dist/createOPFSWorker.d.ts.map +1 -0
- package/dist/helpers-DNj8ZoMu.cjs +4 -0
- package/dist/helpers-DNj8ZoMu.cjs.map +1 -0
- package/dist/{helpers-Ca2c767K.js → helpers-WY2jfbOT.js} +221 -221
- package/dist/helpers-WY2jfbOT.js.map +1 -0
- package/dist/index.cjs +296 -285
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +369 -340
- package/dist/index.js.map +1 -1
- package/dist/index.pure.cjs +2 -0
- package/dist/index.pure.cjs.map +1 -0
- package/dist/index.pure.d.ts +6 -0
- package/dist/index.pure.d.ts.map +1 -0
- package/dist/{raw.js → index.pure.js} +241 -186
- package/dist/index.pure.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +11 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.entry.d.ts +2 -0
- package/dist/worker.entry.d.ts.map +1 -0
- package/docs/api-reference.md +815 -0
- package/docs/file-descriptors.md +696 -0
- package/docs/types.md +232 -0
- package/package.json +14 -8
- package/src/OPFSFacade.ts +460 -0
- package/src/OPFSWorker.ts +1544 -0
- package/src/createOPFSWorker.ts +57 -0
- package/src/index.pure.ts +7 -0
- package/src/index.ts +15 -0
- package/src/types.ts +99 -0
- package/src/utils/encoder.ts +205 -0
- package/src/utils/errors.ts +297 -0
- package/src/utils/helpers.ts +465 -0
- package/src/worker.entry.ts +6 -0
- package/dist/assets/worker-1Wh1cr7P.js.map +0 -1
- package/dist/assets/worker-BeJaVyBV.js.map +0 -1
- package/dist/assets/worker-DYYLzR1Y.js.map +0 -1
- package/dist/facade.d.ts.map +0 -1
- package/dist/helpers-BuGfPAg0.js +0 -1439
- package/dist/helpers-BuGfPAg0.js.map +0 -1
- package/dist/helpers-CF7A2WQG.cjs +0 -4
- package/dist/helpers-CF7A2WQG.cjs.map +0 -1
- package/dist/helpers-CIiblZ8d.cjs +0 -4
- package/dist/helpers-CIiblZ8d.cjs.map +0 -1
- package/dist/helpers-CKOebsbw.js +0 -1423
- package/dist/helpers-CKOebsbw.js.map +0 -1
- package/dist/helpers-Ca2c767K.js.map +0 -1
- package/dist/helpers-Dwc92hv9.cjs +0 -4
- package/dist/helpers-Dwc92hv9.cjs.map +0 -1
- package/dist/raw.cjs +0 -2
- package/dist/raw.cjs.map +0 -1
- package/dist/raw.d.ts +0 -13
- package/dist/raw.d.ts.map +0 -1
- package/dist/raw.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { i as h, d as l, e as c } from "./helpers-WY2jfbOT.js";
|
|
2
|
+
import { A as F, M as A, D as T, E as R, F as C, j as I, c as D, I as $, h as _, O as N, a as k, f as z, g as M, P as j, b as W, S as L, V as U, W as H, o as B, B as G, z as q, K as Y, l as V, C as Z, y as J, k as X, L as K, p as Q, x as nn, u as tn, n as en, m as rn, t as sn, r as an, q as on, G as cn, v as hn, J as ln, s as pn, H as fn, w as dn } from "./helpers-WY2jfbOT.js";
|
|
1
3
|
import { wrap as u } from "comlink";
|
|
2
|
-
import { i as h, d as l, e as c } from "./helpers-Ca2c767K.js";
|
|
3
|
-
import { A as E, M as S, D as P, E as O, F, j as A, c as T, I as R, h as C, O as I, a as D, f as $, g as _, P as N, b as k, S as z, V as M, W as j, o as L, B as W, z as U, K as H, l as B, C as G, y as Y, k as q, L as V, p as Z, x as J, u as X, n as K, m as Q, t as nn, r as tn, q as en, G as rn, v as sn, J as an, s as on, H as cn, w as hn } from "./helpers-Ca2c767K.js";
|
|
4
4
|
const f = `/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
7
7
|
* SPDX-License-Identifier: Apache-2.0
|
|
8
8
|
*/
|
|
9
|
-
const bt = Symbol("Comlink.proxy"),
|
|
9
|
+
const bt = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
|
|
10
10
|
canHandle: (s) => Ot(s) && s[bt],
|
|
11
11
|
serialize(s) {
|
|
12
12
|
const { port1: t, port2: e } = new MessageChannel();
|
|
@@ -16,7 +16,7 @@ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol
|
|
|
16
16
|
return s.start(), Gt(s);
|
|
17
17
|
}
|
|
18
18
|
}, _t = {
|
|
19
|
-
canHandle: (s) => Ot(s) &&
|
|
19
|
+
canHandle: (s) => Ot(s) && j in s,
|
|
20
20
|
serialize({ value: s }) {
|
|
21
21
|
let t;
|
|
22
22
|
return s instanceof Error ? t = {
|
|
@@ -49,30 +49,30 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
49
49
|
console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data),
|
|
52
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(C);
|
|
53
53
|
let h;
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
55
|
+
const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
56
56
|
switch (o) {
|
|
57
57
|
case "GET":
|
|
58
58
|
h = f;
|
|
59
59
|
break;
|
|
60
60
|
case "SET":
|
|
61
|
-
|
|
61
|
+
l[a.slice(-1)[0]] = C(r.data.value), h = !0;
|
|
62
62
|
break;
|
|
63
63
|
case "APPLY":
|
|
64
|
-
h = f.apply(
|
|
64
|
+
h = f.apply(l, c);
|
|
65
65
|
break;
|
|
66
66
|
case "CONSTRUCT":
|
|
67
67
|
{
|
|
68
|
-
const u = new f(...
|
|
68
|
+
const u = new f(...c);
|
|
69
69
|
h = Zt(u);
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
72
|
case "ENDPOINT":
|
|
73
73
|
{
|
|
74
74
|
const { port1: u, port2: d } = new MessageChannel();
|
|
75
|
-
ot(s, d), h =
|
|
75
|
+
ot(s, d), h = _(u, [u]);
|
|
76
76
|
}
|
|
77
77
|
break;
|
|
78
78
|
case "RELEASE":
|
|
@@ -81,16 +81,16 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
81
81
|
default:
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
} catch (
|
|
85
|
-
h = { value:
|
|
84
|
+
} catch (l) {
|
|
85
|
+
h = { value: l, [j]: 0 };
|
|
86
86
|
}
|
|
87
|
-
Promise.resolve(h).catch((
|
|
88
|
-
const [f, u] = V(
|
|
89
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
90
|
-
}).catch((
|
|
87
|
+
Promise.resolve(h).catch((l) => ({ value: l, [j]: 0 })).then((l) => {
|
|
88
|
+
const [f, u] = V(l);
|
|
89
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), At(t), X in s && typeof s[X] == "function" && s[X]());
|
|
90
|
+
}).catch((l) => {
|
|
91
91
|
const [f, u] = V({
|
|
92
92
|
value: new TypeError("Unserializable return value"),
|
|
93
|
-
[
|
|
93
|
+
[j]: 0
|
|
94
94
|
});
|
|
95
95
|
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
96
96
|
});
|
|
@@ -99,7 +99,7 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
99
99
|
function Bt(s) {
|
|
100
100
|
return s.constructor.name === "MessagePort";
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function At(s) {
|
|
103
103
|
Bt(s) && s.close();
|
|
104
104
|
}
|
|
105
105
|
function Gt(s, t) {
|
|
@@ -117,20 +117,20 @@ function Gt(s, t) {
|
|
|
117
117
|
}
|
|
118
118
|
}), st(s, e, [], t);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function L(s) {
|
|
121
121
|
if (s)
|
|
122
122
|
throw new Error("Proxy has been released and is not useable");
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
124
|
+
function vt(s) {
|
|
125
|
+
return $(s, /* @__PURE__ */ new Map(), {
|
|
126
126
|
type: "RELEASE"
|
|
127
127
|
}).then(() => {
|
|
128
|
-
|
|
128
|
+
At(s);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
132
132
|
const t = (G.get(s) || 0) - 1;
|
|
133
|
-
G.set(s, t), t === 0 &&
|
|
133
|
+
G.set(s, t), t === 0 && vt(s);
|
|
134
134
|
});
|
|
135
135
|
function qt(s, t) {
|
|
136
136
|
const e = (G.get(t) || 0) + 1;
|
|
@@ -144,53 +144,53 @@ function st(s, t, e = [], n = function() {
|
|
|
144
144
|
let r = !1;
|
|
145
145
|
const i = new Proxy(n, {
|
|
146
146
|
get(o, a) {
|
|
147
|
-
if (
|
|
147
|
+
if (L(r), a === Wt)
|
|
148
148
|
return () => {
|
|
149
|
-
Vt(i),
|
|
149
|
+
Vt(i), vt(s), t.clear(), r = !0;
|
|
150
150
|
};
|
|
151
151
|
if (a === "then") {
|
|
152
152
|
if (e.length === 0)
|
|
153
153
|
return { then: () => i };
|
|
154
|
-
const
|
|
154
|
+
const c = $(s, t, {
|
|
155
155
|
type: "GET",
|
|
156
156
|
path: e.map((h) => h.toString())
|
|
157
157
|
}).then(C);
|
|
158
|
-
return
|
|
158
|
+
return c.then.bind(c);
|
|
159
159
|
}
|
|
160
160
|
return st(s, t, [...e, a]);
|
|
161
161
|
},
|
|
162
|
-
set(o, a,
|
|
163
|
-
|
|
164
|
-
const [h,
|
|
165
|
-
return
|
|
162
|
+
set(o, a, c) {
|
|
163
|
+
L(r);
|
|
164
|
+
const [h, l] = V(c);
|
|
165
|
+
return $(s, t, {
|
|
166
166
|
type: "SET",
|
|
167
167
|
path: [...e, a].map((f) => f.toString()),
|
|
168
168
|
value: h
|
|
169
|
-
},
|
|
169
|
+
}, l).then(C);
|
|
170
170
|
},
|
|
171
|
-
apply(o, a,
|
|
172
|
-
|
|
171
|
+
apply(o, a, c) {
|
|
172
|
+
L(r);
|
|
173
173
|
const h = e[e.length - 1];
|
|
174
|
-
if (h ===
|
|
175
|
-
return
|
|
174
|
+
if (h === zt)
|
|
175
|
+
return $(s, t, {
|
|
176
176
|
type: "ENDPOINT"
|
|
177
177
|
}).then(C);
|
|
178
178
|
if (h === "bind")
|
|
179
179
|
return st(s, t, e.slice(0, -1));
|
|
180
|
-
const [
|
|
181
|
-
return
|
|
180
|
+
const [l, f] = ht(c);
|
|
181
|
+
return $(s, t, {
|
|
182
182
|
type: "APPLY",
|
|
183
183
|
path: e.map((u) => u.toString()),
|
|
184
|
-
argumentList:
|
|
184
|
+
argumentList: l
|
|
185
185
|
}, f).then(C);
|
|
186
186
|
},
|
|
187
187
|
construct(o, a) {
|
|
188
|
-
|
|
189
|
-
const [
|
|
190
|
-
return
|
|
188
|
+
L(r);
|
|
189
|
+
const [c, h] = ht(a);
|
|
190
|
+
return $(s, t, {
|
|
191
191
|
type: "CONSTRUCT",
|
|
192
|
-
path: e.map((
|
|
193
|
-
argumentList:
|
|
192
|
+
path: e.map((l) => l.toString()),
|
|
193
|
+
argumentList: c
|
|
194
194
|
}, h).then(C);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
@@ -204,7 +204,7 @@ function ht(s) {
|
|
|
204
204
|
return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
|
|
205
205
|
}
|
|
206
206
|
const Nt = /* @__PURE__ */ new WeakMap();
|
|
207
|
-
function
|
|
207
|
+
function _(s, t) {
|
|
208
208
|
return Nt.set(s, t), s;
|
|
209
209
|
}
|
|
210
210
|
function Zt(s) {
|
|
@@ -239,7 +239,7 @@ function C(s) {
|
|
|
239
239
|
return s.value;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function $(s, t, e, n) {
|
|
243
243
|
return new Promise((r) => {
|
|
244
244
|
const i = Xt();
|
|
245
245
|
t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
|
|
@@ -248,7 +248,7 @@ function F(s, t, e, n) {
|
|
|
248
248
|
function Xt() {
|
|
249
249
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
250
250
|
}
|
|
251
|
-
var
|
|
251
|
+
var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
|
|
252
252
|
const Jt = {
|
|
253
253
|
ENOENT: -2,
|
|
254
254
|
// No such file or directory
|
|
@@ -299,7 +299,7 @@ class Kt extends w {
|
|
|
299
299
|
super(t, "INVALID_PATH", e, "access", n);
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
class
|
|
302
|
+
class U extends w {
|
|
303
303
|
constructor(t, e, n) {
|
|
304
304
|
const r = {
|
|
305
305
|
file: \`File not found: \${e}\`,
|
|
@@ -381,11 +381,11 @@ class Q extends w {
|
|
|
381
381
|
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function z(s, t, e, n) {
|
|
385
385
|
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
386
386
|
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function O(s, t) {
|
|
389
389
|
const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
|
|
390
390
|
switch (s.name) {
|
|
391
391
|
case "InvalidStateError":
|
|
@@ -393,7 +393,7 @@ function v(s, t) {
|
|
|
393
393
|
case "QuotaExceededError":
|
|
394
394
|
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
395
395
|
case "NotFoundError":
|
|
396
|
-
return new
|
|
396
|
+
return new U(r, e, s);
|
|
397
397
|
case "TypeMismatchError":
|
|
398
398
|
return n !== void 0 ? n ? new nt("directory", e || "unknown", s) : new nt("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
399
399
|
case "NotAllowedError":
|
|
@@ -411,7 +411,7 @@ function v(s, t) {
|
|
|
411
411
|
return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const
|
|
414
|
+
const $t = (s, t, e) => {
|
|
415
415
|
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);
|
|
416
416
|
return i && {
|
|
417
417
|
start: i[0],
|
|
@@ -424,37 +424,37 @@ const Ft = (s, t, e) => {
|
|
|
424
424
|
const e = t.match(s);
|
|
425
425
|
return e ? e[0] : null;
|
|
426
426
|
}, ie = (s, t, e) => {
|
|
427
|
-
let n, r, i, o, a,
|
|
428
|
-
if (
|
|
427
|
+
let n, r, i, o, a, c = e.indexOf(s), h = e.indexOf(t, c + 1), l = c;
|
|
428
|
+
if (c >= 0 && h > 0) {
|
|
429
429
|
if (s === t)
|
|
430
|
-
return [
|
|
431
|
-
for (n = [], i = e.length;
|
|
432
|
-
if (
|
|
433
|
-
n.push(
|
|
430
|
+
return [c, h];
|
|
431
|
+
for (n = [], i = e.length; l >= 0 && !a; ) {
|
|
432
|
+
if (l === c)
|
|
433
|
+
n.push(l), c = e.indexOf(s, l + 1);
|
|
434
434
|
else if (n.length === 1) {
|
|
435
435
|
const f = n.pop();
|
|
436
436
|
f !== void 0 && (a = [f, h]);
|
|
437
437
|
} else
|
|
438
|
-
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t,
|
|
439
|
-
|
|
438
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
|
|
439
|
+
l = c < h && c >= 0 ? c : h;
|
|
440
440
|
}
|
|
441
441
|
n.length && o !== void 0 && (a = [i, o]);
|
|
442
442
|
}
|
|
443
443
|
return a;
|
|
444
|
-
},
|
|
444
|
+
}, Ft = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Tt = "\\0COMMA" + Math.random() + "\\0", Pt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp(Ft, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Tt, "g"), he = new RegExp(Pt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
|
|
445
445
|
function K(s) {
|
|
446
446
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
447
447
|
}
|
|
448
448
|
function we(s) {
|
|
449
|
-
return s.replace(ue,
|
|
449
|
+
return s.replace(ue, Ft).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function ye(s) {
|
|
452
452
|
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
453
453
|
}
|
|
454
454
|
function Rt(s) {
|
|
455
455
|
if (!s)
|
|
456
456
|
return [""];
|
|
457
|
-
const t = [], e =
|
|
457
|
+
const t = [], e = $t("{", "}", s);
|
|
458
458
|
if (!e)
|
|
459
459
|
return s.split(",");
|
|
460
460
|
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
@@ -462,8 +462,8 @@ function Rt(s) {
|
|
|
462
462
|
const a = Rt(i);
|
|
463
463
|
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
464
464
|
}
|
|
465
|
-
function
|
|
466
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)),
|
|
465
|
+
function me(s) {
|
|
466
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), R(we(s), !0).map(ye)) : [];
|
|
467
467
|
}
|
|
468
468
|
function Ee(s) {
|
|
469
469
|
return "{" + s + "}";
|
|
@@ -477,54 +477,54 @@ function xe(s, t) {
|
|
|
477
477
|
function be(s, t) {
|
|
478
478
|
return s >= t;
|
|
479
479
|
}
|
|
480
|
-
function
|
|
481
|
-
const e = [], n =
|
|
480
|
+
function R(s, t) {
|
|
481
|
+
const e = [], n = $t("{", "}", s);
|
|
482
482
|
if (!n)
|
|
483
483
|
return [s];
|
|
484
|
-
const r = n.pre, i = n.post.length ?
|
|
484
|
+
const r = n.pre, i = n.post.length ? R(n.post, !1) : [""];
|
|
485
485
|
if (/\\$$/.test(n.pre))
|
|
486
486
|
for (let o = 0; o < i.length; o++) {
|
|
487
487
|
const a = r + "{" + n.body + "}" + i[o];
|
|
488
488
|
e.push(a);
|
|
489
489
|
}
|
|
490
490
|
else {
|
|
491
|
-
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body),
|
|
492
|
-
if (!
|
|
493
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post,
|
|
494
|
-
let
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
else if (
|
|
498
|
-
return i.map((u) => n.pre +
|
|
491
|
+
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), c = o || a, h = n.body.indexOf(",") >= 0;
|
|
492
|
+
if (!c && !h)
|
|
493
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, R(s)) : [s];
|
|
494
|
+
let l;
|
|
495
|
+
if (c)
|
|
496
|
+
l = n.body.split(/\\.\\./);
|
|
497
|
+
else if (l = Rt(n.body), l.length === 1 && l[0] !== void 0 && (l = R(l[0], !1).map(Ee), l.length === 1))
|
|
498
|
+
return i.map((u) => n.pre + l[0] + u);
|
|
499
499
|
let f;
|
|
500
|
-
if (
|
|
501
|
-
const u = K(
|
|
502
|
-
let p =
|
|
500
|
+
if (c && l[0] !== void 0 && l[1] !== void 0) {
|
|
501
|
+
const u = K(l[0]), d = K(l[1]), g = Math.max(l[0].length, l[1].length);
|
|
502
|
+
let p = l.length === 3 && l[2] !== void 0 ? Math.abs(K(l[2])) : 1, S = xe;
|
|
503
503
|
d < u && (p *= -1, S = be);
|
|
504
|
-
const M =
|
|
504
|
+
const M = l.some(Se);
|
|
505
505
|
f = [];
|
|
506
506
|
for (let x = u; S(x, d); x += p) {
|
|
507
|
-
let
|
|
507
|
+
let y;
|
|
508
508
|
if (a)
|
|
509
|
-
|
|
510
|
-
else if (
|
|
511
|
-
const T = g -
|
|
509
|
+
y = String.fromCharCode(x), y === "\\\\" && (y = "");
|
|
510
|
+
else if (y = String(x), M) {
|
|
511
|
+
const T = g - y.length;
|
|
512
512
|
if (T > 0) {
|
|
513
|
-
const
|
|
514
|
-
x < 0 ?
|
|
513
|
+
const H = new Array(T + 1).join("0");
|
|
514
|
+
x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
f.push(
|
|
517
|
+
f.push(y);
|
|
518
518
|
}
|
|
519
519
|
} else {
|
|
520
520
|
f = [];
|
|
521
|
-
for (let u = 0; u <
|
|
522
|
-
f.push.apply(f,
|
|
521
|
+
for (let u = 0; u < l.length; u++)
|
|
522
|
+
f.push.apply(f, R(l[u], !1));
|
|
523
523
|
}
|
|
524
524
|
for (let u = 0; u < f.length; u++)
|
|
525
525
|
for (let d = 0; d < i.length; d++) {
|
|
526
526
|
const g = r + f[u] + i[d];
|
|
527
|
-
(!t ||
|
|
527
|
+
(!t || c || g) && e.push(g);
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
530
|
return e;
|
|
@@ -549,36 +549,36 @@ const Oe = 1024 * 64, Y = (s) => {
|
|
|
549
549
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
550
550
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
551
551
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
552
|
-
}, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"),
|
|
552
|
+
}, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), ve = (s, t) => {
|
|
553
553
|
const e = t;
|
|
554
554
|
if (s.charAt(e) !== "[")
|
|
555
555
|
throw new Error("not in a brace expression");
|
|
556
556
|
const n = [], r = [];
|
|
557
|
-
let i = e + 1, o = !1, a = !1,
|
|
557
|
+
let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
|
|
558
558
|
t: for (; i < s.length; ) {
|
|
559
559
|
const p = s.charAt(i);
|
|
560
560
|
if ((p === "!" || p === "^") && i === e + 1) {
|
|
561
561
|
h = !0, i++;
|
|
562
562
|
continue;
|
|
563
563
|
}
|
|
564
|
-
if (p === "]" && o && !
|
|
565
|
-
|
|
564
|
+
if (p === "]" && o && !c) {
|
|
565
|
+
l = i + 1;
|
|
566
566
|
break;
|
|
567
567
|
}
|
|
568
|
-
if (o = !0, p === "\\\\" && !
|
|
569
|
-
|
|
568
|
+
if (o = !0, p === "\\\\" && !c) {
|
|
569
|
+
c = !0, i++;
|
|
570
570
|
continue;
|
|
571
571
|
}
|
|
572
|
-
if (p === "[" && !
|
|
573
|
-
for (const [S, [
|
|
572
|
+
if (p === "[" && !c) {
|
|
573
|
+
for (const [S, [v, M, x]] of Object.entries(De))
|
|
574
574
|
if (s.startsWith(S, i)) {
|
|
575
575
|
if (f)
|
|
576
576
|
return ["$.", !1, s.length - e, !0];
|
|
577
|
-
i += S.length, x ? r.push(
|
|
577
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || M;
|
|
578
578
|
continue t;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
if (
|
|
581
|
+
if (c = !1, f) {
|
|
582
582
|
p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
|
|
583
583
|
continue;
|
|
584
584
|
}
|
|
@@ -592,17 +592,17 @@ const Oe = 1024 * 64, Y = (s) => {
|
|
|
592
592
|
}
|
|
593
593
|
n.push(P(p)), i++;
|
|
594
594
|
}
|
|
595
|
-
if (
|
|
595
|
+
if (l < i)
|
|
596
596
|
return ["", !1, 0, !1];
|
|
597
597
|
if (!n.length && !r.length)
|
|
598
598
|
return ["$.", !1, s.length - e, !0];
|
|
599
599
|
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
600
600
|
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
601
|
-
return [
|
|
601
|
+
return [Ae(p), !1, l - e, !1];
|
|
602
602
|
}
|
|
603
603
|
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
604
|
-
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a,
|
|
605
|
-
},
|
|
604
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, l - e, !0];
|
|
605
|
+
}, 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Fe = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
606
606
|
class E {
|
|
607
607
|
type;
|
|
608
608
|
#s;
|
|
@@ -703,7 +703,7 @@ class E {
|
|
|
703
703
|
return e;
|
|
704
704
|
}
|
|
705
705
|
static #h(t, e, n, r) {
|
|
706
|
-
let i = !1, o = !1, a = -1,
|
|
706
|
+
let i = !1, o = !1, a = -1, c = !1;
|
|
707
707
|
if (e.type === null) {
|
|
708
708
|
let d = n, g = "";
|
|
709
709
|
for (; d < t.length; ) {
|
|
@@ -713,10 +713,10 @@ class E {
|
|
|
713
713
|
continue;
|
|
714
714
|
}
|
|
715
715
|
if (o) {
|
|
716
|
-
d === a + 1 ? (p === "^" || p === "!") && (
|
|
716
|
+
d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
|
|
717
717
|
continue;
|
|
718
718
|
} else if (p === "[") {
|
|
719
|
-
o = !0, a = d,
|
|
719
|
+
o = !0, a = d, c = !1, g += p;
|
|
720
720
|
continue;
|
|
721
721
|
}
|
|
722
722
|
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
@@ -729,7 +729,7 @@ class E {
|
|
|
729
729
|
}
|
|
730
730
|
return e.push(g), d;
|
|
731
731
|
}
|
|
732
|
-
let h = n + 1,
|
|
732
|
+
let h = n + 1, l = new E(null, e);
|
|
733
733
|
const f = [];
|
|
734
734
|
let u = "";
|
|
735
735
|
for (; h < t.length; ) {
|
|
@@ -739,24 +739,24 @@ class E {
|
|
|
739
739
|
continue;
|
|
740
740
|
}
|
|
741
741
|
if (o) {
|
|
742
|
-
h === a + 1 ? (d === "^" || d === "!") && (
|
|
742
|
+
h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
|
|
743
743
|
continue;
|
|
744
744
|
} else if (d === "[") {
|
|
745
|
-
o = !0, a = h,
|
|
745
|
+
o = !0, a = h, c = !1, u += d;
|
|
746
746
|
continue;
|
|
747
747
|
}
|
|
748
748
|
if (pt(d) && t.charAt(h) === "(") {
|
|
749
|
-
|
|
750
|
-
const g = new E(d,
|
|
751
|
-
|
|
749
|
+
l.push(u), u = "";
|
|
750
|
+
const g = new E(d, l);
|
|
751
|
+
l.push(g), h = E.#h(t, g, h, r);
|
|
752
752
|
continue;
|
|
753
753
|
}
|
|
754
754
|
if (d === "|") {
|
|
755
|
-
|
|
755
|
+
l.push(u), u = "", f.push(l), l = new E(null, e);
|
|
756
756
|
continue;
|
|
757
757
|
}
|
|
758
758
|
if (d === ")")
|
|
759
|
-
return u === "" && e.#t.length === 0 && (e.#u = !0),
|
|
759
|
+
return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
|
|
760
760
|
u += d;
|
|
761
761
|
}
|
|
762
762
|
return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
|
|
@@ -854,24 +854,24 @@ class E {
|
|
|
854
854
|
toRegExpSource(t) {
|
|
855
855
|
const e = t ?? !!this.#r.dot;
|
|
856
856
|
if (this.#s === this && this.#d(), !this.type) {
|
|
857
|
-
const
|
|
858
|
-
const [g, p, S,
|
|
859
|
-
return this.#n = this.#n || S, this.#i = this.#i ||
|
|
857
|
+
const c = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
858
|
+
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, c) : d.toRegExpSource(t);
|
|
859
|
+
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
860
860
|
}).join("");
|
|
861
|
-
let
|
|
862
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
863
|
-
const g =
|
|
861
|
+
let l = "";
|
|
862
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Fe.has(this.#t[0]))) {
|
|
863
|
+
const g = $e, p = (
|
|
864
864
|
// dots are allowed, and the pattern starts with [ or .
|
|
865
865
|
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
866
866
|
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
867
867
|
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
868
868
|
), S = !e && !t && g.has(h.charAt(0));
|
|
869
|
-
|
|
869
|
+
l = p ? Ce : S ? W : "";
|
|
870
870
|
}
|
|
871
871
|
let f = "";
|
|
872
872
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
873
|
-
|
|
874
|
-
|
|
873
|
+
l + h + f,
|
|
874
|
+
k(h),
|
|
875
875
|
this.#n = !!this.#n,
|
|
876
876
|
this.#i
|
|
877
877
|
];
|
|
@@ -879,24 +879,24 @@ class E {
|
|
|
879
879
|
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
880
880
|
let i = this.#f(e);
|
|
881
881
|
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
882
|
-
const
|
|
883
|
-
return this.#t = [
|
|
882
|
+
const c = this.toString();
|
|
883
|
+
return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
|
|
884
884
|
}
|
|
885
|
-
let o = !n || t || e || !
|
|
885
|
+
let o = !n || t || e || !W ? "" : this.#f(!0);
|
|
886
886
|
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
887
887
|
let a = "";
|
|
888
888
|
if (this.type === "!" && this.#u)
|
|
889
|
-
a = (this.isStart() && !e ?
|
|
889
|
+
a = (this.isStart() && !e ? W : "") + wt;
|
|
890
890
|
else {
|
|
891
|
-
const
|
|
891
|
+
const c = this.type === "!" ? (
|
|
892
892
|
// !() must match something,but !(x) can match ''
|
|
893
|
-
"))" + (this.isStart() && !e && !t ?
|
|
893
|
+
"))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
|
|
894
894
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
895
|
-
a = r + i +
|
|
895
|
+
a = r + i + c;
|
|
896
896
|
}
|
|
897
897
|
return [
|
|
898
898
|
a,
|
|
899
|
-
|
|
899
|
+
k(i),
|
|
900
900
|
this.#n = !!this.#n,
|
|
901
901
|
this.#i
|
|
902
902
|
];
|
|
@@ -912,36 +912,36 @@ class E {
|
|
|
912
912
|
static #p(t, e, n = !1) {
|
|
913
913
|
let r = !1, i = "", o = !1;
|
|
914
914
|
for (let a = 0; a < t.length; a++) {
|
|
915
|
-
const
|
|
915
|
+
const c = t.charAt(a);
|
|
916
916
|
if (r) {
|
|
917
|
-
r = !1, i += (Me.has(
|
|
917
|
+
r = !1, i += (Me.has(c) ? "\\\\" : "") + c;
|
|
918
918
|
continue;
|
|
919
919
|
}
|
|
920
|
-
if (
|
|
920
|
+
if (c === "\\\\") {
|
|
921
921
|
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
922
922
|
continue;
|
|
923
923
|
}
|
|
924
|
-
if (
|
|
925
|
-
const [h,
|
|
924
|
+
if (c === "[") {
|
|
925
|
+
const [h, l, f, u] = ve(t, a);
|
|
926
926
|
if (f) {
|
|
927
|
-
i += h, o = o ||
|
|
927
|
+
i += h, o = o || l, a += f - 1, e = e || u;
|
|
928
928
|
continue;
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
|
-
if (
|
|
931
|
+
if (c === "*") {
|
|
932
932
|
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
933
933
|
continue;
|
|
934
934
|
}
|
|
935
|
-
if (
|
|
935
|
+
if (c === "?") {
|
|
936
936
|
i += ct, e = !0;
|
|
937
937
|
continue;
|
|
938
938
|
}
|
|
939
|
-
i += Te(
|
|
939
|
+
i += Te(c);
|
|
940
940
|
}
|
|
941
|
-
return [i,
|
|
941
|
+
return [i, k(t), !!e, o];
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"),
|
|
944
|
+
const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (s, t, e = {}) => (Y(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new Z(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Ie = (s) => (t) => t.endsWith(s), He = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), ze = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, 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 = ""]) => {
|
|
945
945
|
const e = kt([s]);
|
|
946
946
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
947
947
|
}, Ze = ([s, t = ""]) => {
|
|
@@ -959,19 +959,19 @@ const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
|
|
|
959
959
|
}, It = ([s]) => {
|
|
960
960
|
const t = s.length;
|
|
961
961
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
962
|
-
},
|
|
962
|
+
}, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
|
|
963
963
|
win32: { sep: "\\\\" },
|
|
964
964
|
posix: { sep: "/" }
|
|
965
|
-
}, Qe =
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) =>
|
|
970
|
-
|
|
965
|
+
}, Qe = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
|
|
966
|
+
m.sep = Qe;
|
|
967
|
+
const D = Symbol("globstar **");
|
|
968
|
+
m.GLOBSTAR = D;
|
|
969
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => m(e, s, t);
|
|
970
|
+
m.filter = ns;
|
|
971
971
|
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
972
972
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
973
|
-
return
|
|
974
|
-
const t =
|
|
973
|
+
return m;
|
|
974
|
+
const t = m;
|
|
975
975
|
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
976
976
|
Minimatch: class extends t.Minimatch {
|
|
977
977
|
constructor(r, i = {}) {
|
|
@@ -999,20 +999,20 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
|
999
999
|
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
1000
1000
|
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
1001
1001
|
sep: t.sep,
|
|
1002
|
-
GLOBSTAR:
|
|
1002
|
+
GLOBSTAR: D
|
|
1003
1003
|
});
|
|
1004
1004
|
};
|
|
1005
|
-
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1005
|
+
m.defaults = rs;
|
|
1006
|
+
const Lt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : me(s));
|
|
1007
|
+
m.braceExpand = Lt;
|
|
1008
1008
|
const is = (s, t = {}) => new Z(s, t).makeRe();
|
|
1009
|
-
|
|
1009
|
+
m.makeRe = is;
|
|
1010
1010
|
const os = (s, t, e = {}) => {
|
|
1011
1011
|
const n = new Z(t, e);
|
|
1012
1012
|
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
1013
1013
|
};
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1014
|
+
m.match = os;
|
|
1015
|
+
const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1016
1016
|
class Z {
|
|
1017
1017
|
options;
|
|
1018
1018
|
set;
|
|
@@ -1032,7 +1032,7 @@ class Z {
|
|
|
1032
1032
|
windowsNoMagicRoot;
|
|
1033
1033
|
regexp;
|
|
1034
1034
|
constructor(t, e = {}) {
|
|
1035
|
-
Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform ||
|
|
1035
|
+
Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ht, 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();
|
|
1036
1036
|
}
|
|
1037
1037
|
hasMagic() {
|
|
1038
1038
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -1060,13 +1060,13 @@ class Z {
|
|
|
1060
1060
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
1061
1061
|
let r = this.globParts.map((i, o, a) => {
|
|
1062
1062
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1065
|
-
return [...i.slice(0, 4), ...i.slice(4).map((
|
|
1063
|
+
const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
1064
|
+
if (c)
|
|
1065
|
+
return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
|
|
1066
1066
|
if (h)
|
|
1067
|
-
return [i[0], ...i.slice(1).map((
|
|
1067
|
+
return [i[0], ...i.slice(1).map((l) => this.parse(l))];
|
|
1068
1068
|
}
|
|
1069
|
-
return i.map((
|
|
1069
|
+
return i.map((c) => this.parse(c));
|
|
1070
1070
|
});
|
|
1071
1071
|
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1072
1072
|
for (let i = 0; i < this.set.length; i++) {
|
|
@@ -1157,12 +1157,12 @@ class Z {
|
|
|
1157
1157
|
o++;
|
|
1158
1158
|
o > r && n.splice(r + 1, o - r);
|
|
1159
1159
|
let a = n[r + 1];
|
|
1160
|
-
const
|
|
1161
|
-
if (a !== ".." || !
|
|
1160
|
+
const c = n[r + 2], h = n[r + 3];
|
|
1161
|
+
if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
|
|
1162
1162
|
continue;
|
|
1163
1163
|
e = !0, n.splice(r, 1);
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1164
|
+
const l = n.slice(0);
|
|
1165
|
+
l[r] = "**", t.push(l), r--;
|
|
1166
1166
|
}
|
|
1167
1167
|
if (!this.preserveMultipleSlashes) {
|
|
1168
1168
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1176,8 +1176,8 @@ class Z {
|
|
|
1176
1176
|
const o = n[i - 1];
|
|
1177
1177
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1178
1178
|
e = !0;
|
|
1179
|
-
const
|
|
1180
|
-
n.splice(i - 1, 2, ...
|
|
1179
|
+
const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1180
|
+
n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
@@ -1240,33 +1240,33 @@ class Z {
|
|
|
1240
1240
|
matchOne(t, e, n = !1) {
|
|
1241
1241
|
const r = this.options;
|
|
1242
1242
|
if (this.isWindows) {
|
|
1243
|
-
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]),
|
|
1244
|
-
if (typeof x == "number" && typeof
|
|
1245
|
-
const [T,
|
|
1246
|
-
T.toLowerCase() ===
|
|
1243
|
+
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]), M = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, y = M ? 3 : v ? 0 : void 0;
|
|
1244
|
+
if (typeof x == "number" && typeof y == "number") {
|
|
1245
|
+
const [T, H] = [t[x], e[y]];
|
|
1246
|
+
T.toLowerCase() === H.toLowerCase() && (e[y] = T, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
const { optimizationLevel: i = 1 } = this.options;
|
|
1250
1250
|
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1251
|
-
for (var o = 0, a = 0,
|
|
1251
|
+
for (var o = 0, a = 0, c = t.length, h = e.length; o < c && a < h; o++, a++) {
|
|
1252
1252
|
this.debug("matchOne loop");
|
|
1253
|
-
var
|
|
1254
|
-
if (this.debug(e,
|
|
1253
|
+
var l = e[a], f = t[o];
|
|
1254
|
+
if (this.debug(e, l, f), l === !1)
|
|
1255
1255
|
return !1;
|
|
1256
|
-
if (
|
|
1257
|
-
this.debug("GLOBSTAR", [e,
|
|
1256
|
+
if (l === D) {
|
|
1257
|
+
this.debug("GLOBSTAR", [e, l, f]);
|
|
1258
1258
|
var u = o, d = a + 1;
|
|
1259
1259
|
if (d === h) {
|
|
1260
|
-
for (this.debug("** at the end"); o <
|
|
1260
|
+
for (this.debug("** at the end"); o < c; o++)
|
|
1261
1261
|
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1262
1262
|
return !1;
|
|
1263
1263
|
return !0;
|
|
1264
1264
|
}
|
|
1265
|
-
for (; u <
|
|
1265
|
+
for (; u < c; ) {
|
|
1266
1266
|
var g = t[u];
|
|
1267
1267
|
if (this.debug(\`
|
|
1268
1268
|
globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1269
|
-
return this.debug("globstar found match!", u,
|
|
1269
|
+
return this.debug("globstar found match!", u, c, g), !0;
|
|
1270
1270
|
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1271
1271
|
this.debug("dot detected!", t, u, e, d);
|
|
1272
1272
|
break;
|
|
@@ -1274,32 +1274,32 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1274
1274
|
this.debug("globstar swallow a segment, and continue"), u++;
|
|
1275
1275
|
}
|
|
1276
1276
|
return !!(n && (this.debug(\`
|
|
1277
|
-
>>> no match, partial?\`, t, u, e, d), u ===
|
|
1277
|
+
>>> no match, partial?\`, t, u, e, d), u === c));
|
|
1278
1278
|
}
|
|
1279
1279
|
let p;
|
|
1280
|
-
if (typeof
|
|
1280
|
+
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)
|
|
1281
1281
|
return !1;
|
|
1282
1282
|
}
|
|
1283
|
-
if (o ===
|
|
1283
|
+
if (o === c && a === h)
|
|
1284
1284
|
return !0;
|
|
1285
|
-
if (o ===
|
|
1285
|
+
if (o === c)
|
|
1286
1286
|
return n;
|
|
1287
1287
|
if (a === h)
|
|
1288
|
-
return o ===
|
|
1288
|
+
return o === c - 1 && t[o] === "";
|
|
1289
1289
|
throw new Error("wtf?");
|
|
1290
1290
|
}
|
|
1291
1291
|
braceExpand() {
|
|
1292
|
-
return
|
|
1292
|
+
return Lt(this.pattern, this.options);
|
|
1293
1293
|
}
|
|
1294
1294
|
parse(t) {
|
|
1295
1295
|
Y(t);
|
|
1296
1296
|
const e = this.options;
|
|
1297
1297
|
if (t === "**")
|
|
1298
|
-
return
|
|
1298
|
+
return D;
|
|
1299
1299
|
if (t === "")
|
|
1300
1300
|
return "";
|
|
1301
1301
|
let n, r = null;
|
|
1302
|
-
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ?
|
|
1302
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : He : e.dot ? Ie : ke)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(ze)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
|
|
1303
1303
|
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1304
1304
|
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1305
1305
|
}
|
|
@@ -1310,17 +1310,17 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1310
1310
|
if (!t.length)
|
|
1311
1311
|
return this.regexp = !1, this.regexp;
|
|
1312
1312
|
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1313
|
-
let i = t.map((
|
|
1314
|
-
const h =
|
|
1315
|
-
if (
|
|
1316
|
-
for (const f of
|
|
1313
|
+
let i = t.map((c) => {
|
|
1314
|
+
const h = c.map((l) => {
|
|
1315
|
+
if (l instanceof RegExp)
|
|
1316
|
+
for (const f of l.flags.split(""))
|
|
1317
1317
|
r.add(f);
|
|
1318
|
-
return typeof
|
|
1318
|
+
return typeof l == "string" ? as(l) : l === D ? D : l._src;
|
|
1319
1319
|
});
|
|
1320
|
-
return h.forEach((
|
|
1320
|
+
return h.forEach((l, f) => {
|
|
1321
1321
|
const u = h[f + 1], d = h[f - 1];
|
|
1322
|
-
|
|
1323
|
-
}), h.filter((
|
|
1322
|
+
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));
|
|
1323
|
+
}), h.filter((l) => l !== D).join("/");
|
|
1324
1324
|
}).join("|");
|
|
1325
1325
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1326
1326
|
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
@@ -1352,40 +1352,40 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1352
1352
|
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1353
1353
|
o = r[a];
|
|
1354
1354
|
for (let a = 0; a < i.length; a++) {
|
|
1355
|
-
const
|
|
1355
|
+
const c = i[a];
|
|
1356
1356
|
let h = r;
|
|
1357
|
-
if (n.matchBase &&
|
|
1357
|
+
if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
|
|
1358
1358
|
return n.flipNegate ? !0 : !this.negate;
|
|
1359
1359
|
}
|
|
1360
1360
|
return n.flipNegate ? !1 : this.negate;
|
|
1361
1361
|
}
|
|
1362
1362
|
static defaults(t) {
|
|
1363
|
-
return
|
|
1363
|
+
return m.defaults(t).Minimatch;
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1366
|
+
m.AST = E;
|
|
1367
|
+
m.Minimatch = Z;
|
|
1368
|
+
m.escape = Pe;
|
|
1369
|
+
m.unescape = k;
|
|
1370
1370
|
function cs() {
|
|
1371
1371
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1372
1372
|
throw new Qt();
|
|
1373
1373
|
}
|
|
1374
|
-
async function
|
|
1375
|
-
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode:
|
|
1374
|
+
async function I(s, t) {
|
|
1375
|
+
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1377
|
+
function F(s) {
|
|
1378
1378
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1379
1379
|
}
|
|
1380
1380
|
function lt(s) {
|
|
1381
1381
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1382
1382
|
}
|
|
1383
1383
|
function it(s) {
|
|
1384
|
-
const t =
|
|
1384
|
+
const t = F(s);
|
|
1385
1385
|
return t[t.length - 1] || "";
|
|
1386
1386
|
}
|
|
1387
1387
|
function tt(s) {
|
|
1388
|
-
const t =
|
|
1388
|
+
const t = F(s);
|
|
1389
1389
|
return t.pop(), lt(t);
|
|
1390
1390
|
}
|
|
1391
1391
|
function B(s) {
|
|
@@ -1395,13 +1395,13 @@ function ls(s, t = !1) {
|
|
|
1395
1395
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1396
1396
|
}
|
|
1397
1397
|
function et(s, t) {
|
|
1398
|
-
return
|
|
1398
|
+
return m(s, t, {
|
|
1399
1399
|
dot: !0,
|
|
1400
1400
|
matchBase: !0
|
|
1401
1401
|
});
|
|
1402
1402
|
}
|
|
1403
1403
|
function Et(s) {
|
|
1404
|
-
const t = B(s), e =
|
|
1404
|
+
const t = B(s), e = F(t), n = [];
|
|
1405
1405
|
for (const r of e)
|
|
1406
1406
|
if (!(r === "." || r === ""))
|
|
1407
1407
|
if (r === "..") {
|
|
@@ -1424,7 +1424,7 @@ async function us(s) {
|
|
|
1424
1424
|
}
|
|
1425
1425
|
async function fs(s, t, e = {}) {
|
|
1426
1426
|
const n = it(t);
|
|
1427
|
-
return
|
|
1427
|
+
return I(t, async () => {
|
|
1428
1428
|
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1429
1429
|
try {
|
|
1430
1430
|
await s.removeEntry(n, { recursive: r });
|
|
@@ -1432,7 +1432,7 @@ async function fs(s, t, e = {}) {
|
|
|
1432
1432
|
if (o.name === "NotFoundError" && i)
|
|
1433
1433
|
return;
|
|
1434
1434
|
const a = o.name === "TypeMismatchError" && !r;
|
|
1435
|
-
throw
|
|
1435
|
+
throw O(o, {
|
|
1436
1436
|
path: t,
|
|
1437
1437
|
operation: "remove",
|
|
1438
1438
|
isDirectory: a
|
|
@@ -1467,7 +1467,7 @@ async function ps(s, t) {
|
|
|
1467
1467
|
try {
|
|
1468
1468
|
return await s.createSyncAccessHandle();
|
|
1469
1469
|
} catch (e) {
|
|
1470
|
-
throw
|
|
1470
|
+
throw O(e, { path: t, isDirectory: !1 });
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
class gs {
|
|
@@ -1487,6 +1487,8 @@ class gs {
|
|
|
1487
1487
|
hashAlgorithm: "etag",
|
|
1488
1488
|
broadcastChannel: "opfs-worker"
|
|
1489
1489
|
};
|
|
1490
|
+
/** Shared sync handles per path (OPFS allows only one handle per file) */
|
|
1491
|
+
openHandles = /* @__PURE__ */ new Map();
|
|
1490
1492
|
/** Map of open file descriptors to their metadata */
|
|
1491
1493
|
openFiles = /* @__PURE__ */ new Map();
|
|
1492
1494
|
/** Next available file descriptor number */
|
|
@@ -1535,7 +1537,7 @@ class gs {
|
|
|
1535
1537
|
}
|
|
1536
1538
|
}
|
|
1537
1539
|
/**
|
|
1538
|
-
* Creates a new
|
|
1540
|
+
* Creates a new OPFSWorker instance
|
|
1539
1541
|
*
|
|
1540
1542
|
* @param options - Optional configuration options
|
|
1541
1543
|
* @param options.root - Root path for the file system (default: '/')
|
|
@@ -1558,7 +1560,7 @@ class gs {
|
|
|
1558
1560
|
*
|
|
1559
1561
|
* @example
|
|
1560
1562
|
* \`\`\`typescript
|
|
1561
|
-
* const fs = new
|
|
1563
|
+
* const fs = new OPFSWorker();
|
|
1562
1564
|
*
|
|
1563
1565
|
* // Use OPFS root (default)
|
|
1564
1566
|
* await fs.mount();
|
|
@@ -1612,7 +1614,7 @@ class gs {
|
|
|
1612
1614
|
* \`\`\`
|
|
1613
1615
|
*/
|
|
1614
1616
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1615
|
-
const r = Array.isArray(t) ? t :
|
|
1617
|
+
const r = Array.isArray(t) ? t : F(t);
|
|
1616
1618
|
let i = n;
|
|
1617
1619
|
for (const o of r)
|
|
1618
1620
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
@@ -1638,7 +1640,7 @@ class gs {
|
|
|
1638
1640
|
* \`\`\`
|
|
1639
1641
|
*/
|
|
1640
1642
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1641
|
-
const r =
|
|
1643
|
+
const r = F(t);
|
|
1642
1644
|
if (r.length === 0)
|
|
1643
1645
|
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1644
1646
|
const i = r.pop();
|
|
@@ -1707,17 +1709,17 @@ class gs {
|
|
|
1707
1709
|
async readFile(t) {
|
|
1708
1710
|
await this.mount();
|
|
1709
1711
|
try {
|
|
1710
|
-
return await
|
|
1712
|
+
return await I(t, async () => {
|
|
1711
1713
|
const e = await this.open(t);
|
|
1712
1714
|
try {
|
|
1713
1715
|
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1714
|
-
return n > 0 && await this.read(e, r, 0, n, 0),
|
|
1716
|
+
return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
|
|
1715
1717
|
} finally {
|
|
1716
1718
|
await this.close(e);
|
|
1717
1719
|
}
|
|
1718
1720
|
});
|
|
1719
1721
|
} catch (e) {
|
|
1720
|
-
throw
|
|
1722
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
|
|
1721
1723
|
}
|
|
1722
1724
|
}
|
|
1723
1725
|
/**
|
|
@@ -1745,14 +1747,14 @@ class gs {
|
|
|
1745
1747
|
async writeFile(t, e) {
|
|
1746
1748
|
await this.mount();
|
|
1747
1749
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1748
|
-
await
|
|
1750
|
+
await I(t, async () => {
|
|
1749
1751
|
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1750
1752
|
try {
|
|
1751
1753
|
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1752
1754
|
} finally {
|
|
1753
1755
|
await this.close(i);
|
|
1754
1756
|
}
|
|
1755
|
-
await this.notifyChange({ path: t, type: r ?
|
|
1757
|
+
await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
|
|
1756
1758
|
});
|
|
1757
1759
|
}
|
|
1758
1760
|
/**
|
|
@@ -1780,7 +1782,7 @@ class gs {
|
|
|
1780
1782
|
async appendFile(t, e) {
|
|
1781
1783
|
await this.mount();
|
|
1782
1784
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1783
|
-
await
|
|
1785
|
+
await I(t, async () => {
|
|
1784
1786
|
const r = await this.open(t, { create: !0 });
|
|
1785
1787
|
try {
|
|
1786
1788
|
const { size: i } = await this.fstat(r);
|
|
@@ -1788,7 +1790,7 @@ class gs {
|
|
|
1788
1790
|
} finally {
|
|
1789
1791
|
await this.close(r);
|
|
1790
1792
|
}
|
|
1791
|
-
await this.notifyChange({ path: t, type:
|
|
1793
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
|
|
1792
1794
|
});
|
|
1793
1795
|
}
|
|
1794
1796
|
/**
|
|
@@ -1814,20 +1816,20 @@ class gs {
|
|
|
1814
1816
|
*/
|
|
1815
1817
|
async mkdir(t, e) {
|
|
1816
1818
|
await this.mount();
|
|
1817
|
-
const n = e?.recursive ?? !1, r =
|
|
1819
|
+
const n = e?.recursive ?? !1, r = F(t);
|
|
1818
1820
|
let i = this.root;
|
|
1819
1821
|
for (let o = 0; o < r.length; o++) {
|
|
1820
1822
|
const a = r[o];
|
|
1821
1823
|
try {
|
|
1822
1824
|
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1823
|
-
} catch (
|
|
1824
|
-
throw
|
|
1825
|
+
} catch (c) {
|
|
1826
|
+
throw c.name === "NotFoundError" ? O(c, {
|
|
1825
1827
|
path: lt(r.slice(0, o + 1)),
|
|
1826
1828
|
existenceType: "directory"
|
|
1827
|
-
}) :
|
|
1829
|
+
}) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
|
|
1828
1830
|
}
|
|
1829
1831
|
}
|
|
1830
|
-
await this.notifyChange({ path: t, type:
|
|
1832
|
+
await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
|
|
1831
1833
|
}
|
|
1832
1834
|
/**
|
|
1833
1835
|
* Get file or directory statistics
|
|
@@ -1877,15 +1879,15 @@ class gs {
|
|
|
1877
1879
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1878
1880
|
else if (typeof r == "string")
|
|
1879
1881
|
try {
|
|
1880
|
-
const
|
|
1881
|
-
a.hash =
|
|
1882
|
-
} catch (
|
|
1883
|
-
console.warn(\`Failed to calculate hash for \${t}:\`,
|
|
1882
|
+
const c = await hs(o, r, this.options.maxFileSize);
|
|
1883
|
+
a.hash = c;
|
|
1884
|
+
} catch (c) {
|
|
1885
|
+
console.warn(\`Failed to calculate hash for \${t}:\`, c);
|
|
1884
1886
|
}
|
|
1885
1887
|
return a;
|
|
1886
1888
|
} catch (r) {
|
|
1887
1889
|
if (r.name === "NotFoundError")
|
|
1888
|
-
throw new
|
|
1890
|
+
throw new U("file", t, r);
|
|
1889
1891
|
if (r.name !== "TypeMismatchError")
|
|
1890
1892
|
throw new J("stat", t, r);
|
|
1891
1893
|
}
|
|
@@ -2002,9 +2004,9 @@ class gs {
|
|
|
2002
2004
|
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
2003
2005
|
await this.remove(r, { recursive: !0 });
|
|
2004
2006
|
}
|
|
2005
|
-
await this.notifyChange({ path: t, type:
|
|
2007
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
|
|
2006
2008
|
} catch (e) {
|
|
2007
|
-
throw e instanceof w ? e :
|
|
2009
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
|
|
2008
2010
|
}
|
|
2009
2011
|
}
|
|
2010
2012
|
/**
|
|
@@ -2035,7 +2037,7 @@ class gs {
|
|
|
2035
2037
|
if (await this.mount(), t === "/")
|
|
2036
2038
|
throw new rt("EROOT", t);
|
|
2037
2039
|
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
|
|
2038
|
-
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type:
|
|
2040
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
|
|
2039
2041
|
}
|
|
2040
2042
|
/**
|
|
2041
2043
|
* Resolve a path to an absolute path
|
|
@@ -2060,10 +2062,10 @@ class gs {
|
|
|
2060
2062
|
try {
|
|
2061
2063
|
const e = Et(t);
|
|
2062
2064
|
if (!await this.exists(e))
|
|
2063
|
-
throw new
|
|
2065
|
+
throw new U("file", e);
|
|
2064
2066
|
return e;
|
|
2065
2067
|
} catch (e) {
|
|
2066
|
-
throw e instanceof w ? e :
|
|
2068
|
+
throw e instanceof w ? e : O(e, { path: t });
|
|
2067
2069
|
}
|
|
2068
2070
|
}
|
|
2069
2071
|
/**
|
|
@@ -2094,9 +2096,9 @@ class gs {
|
|
|
2094
2096
|
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2095
2097
|
if (await this.exists(e) && !r)
|
|
2096
2098
|
throw new Q(e);
|
|
2097
|
-
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type:
|
|
2099
|
+
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 });
|
|
2098
2100
|
} catch (r) {
|
|
2099
|
-
throw r instanceof w ? r :
|
|
2101
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2100
2102
|
}
|
|
2101
2103
|
}
|
|
2102
2104
|
/**
|
|
@@ -2129,7 +2131,7 @@ class gs {
|
|
|
2129
2131
|
try {
|
|
2130
2132
|
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2131
2133
|
if (!await this.exists(t))
|
|
2132
|
-
throw new
|
|
2134
|
+
throw new U("source", t);
|
|
2133
2135
|
if (await this.exists(e) && !i)
|
|
2134
2136
|
throw new Q(e);
|
|
2135
2137
|
if ((await this.stat(t)).isFile) {
|
|
@@ -2140,13 +2142,13 @@ class gs {
|
|
|
2140
2142
|
throw new nt("directory", t);
|
|
2141
2143
|
await this.mkdir(e, { recursive: !0 });
|
|
2142
2144
|
const h = await this.readDir(t);
|
|
2143
|
-
for (const
|
|
2144
|
-
const f = \`\${t}/\${
|
|
2145
|
+
for (const l of h) {
|
|
2146
|
+
const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
|
|
2145
2147
|
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2146
2148
|
}
|
|
2147
2149
|
}
|
|
2148
2150
|
} catch (r) {
|
|
2149
|
-
throw r instanceof w ? r :
|
|
2151
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2150
2152
|
}
|
|
2151
2153
|
}
|
|
2152
2154
|
/**
|
|
@@ -2221,7 +2223,7 @@ class gs {
|
|
|
2221
2223
|
await this.mount();
|
|
2222
2224
|
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
|
|
2223
2225
|
try {
|
|
2224
|
-
return n && r ? await
|
|
2226
|
+
return n && r ? await I(o, async () => {
|
|
2225
2227
|
if (await this.exists(o))
|
|
2226
2228
|
throw new Q(o);
|
|
2227
2229
|
return this._openFile(o, n, i);
|
|
@@ -2229,33 +2231,40 @@ class gs {
|
|
|
2229
2231
|
} catch (a) {
|
|
2230
2232
|
if (a instanceof w)
|
|
2231
2233
|
throw a;
|
|
2232
|
-
const
|
|
2233
|
-
throw
|
|
2234
|
+
const c = a && a.name === "TypeMismatchError";
|
|
2235
|
+
throw O(a, {
|
|
2234
2236
|
path: o,
|
|
2235
|
-
isDirectory: !!
|
|
2237
|
+
isDirectory: !!c
|
|
2236
2238
|
});
|
|
2237
2239
|
}
|
|
2238
2240
|
}
|
|
2239
2241
|
/**
|
|
2240
2242
|
* Internal method to open a file (without locking)
|
|
2243
|
+
*
|
|
2244
|
+
* Multiple FDs for the same path share one sync access handle (OPFS limit),
|
|
2245
|
+
* with independent per-FD positions — similar to Node.js.
|
|
2241
2246
|
* @private
|
|
2242
2247
|
*/
|
|
2243
2248
|
async _openFile(t, e, n) {
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
await
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
+
let r = this.openHandles.get(t);
|
|
2250
|
+
if (!r) {
|
|
2251
|
+
const o = await this.getFileHandle(t, e);
|
|
2252
|
+
try {
|
|
2253
|
+
await o.getFile();
|
|
2254
|
+
} catch (c) {
|
|
2255
|
+
throw O(c, { path: t, isDirectory: !0 });
|
|
2256
|
+
}
|
|
2257
|
+
const a = await ps(o, t);
|
|
2258
|
+
r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
|
|
2249
2259
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
return this.openFiles.set(o, {
|
|
2260
|
+
r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
|
|
2261
|
+
const i = this.nextFd++;
|
|
2262
|
+
return this.openFiles.set(i, {
|
|
2254
2263
|
path: t,
|
|
2255
|
-
fileHandle: r,
|
|
2256
|
-
syncHandle:
|
|
2264
|
+
fileHandle: r.fileHandle,
|
|
2265
|
+
syncHandle: r.syncHandle,
|
|
2257
2266
|
position: 0
|
|
2258
|
-
}),
|
|
2267
|
+
}), i;
|
|
2259
2268
|
}
|
|
2260
2269
|
/**
|
|
2261
2270
|
* Close a file descriptor
|
|
@@ -2273,7 +2282,9 @@ class gs {
|
|
|
2273
2282
|
*/
|
|
2274
2283
|
async close(t) {
|
|
2275
2284
|
const e = this._getFileDescriptor(t);
|
|
2276
|
-
|
|
2285
|
+
this.openFiles.delete(t);
|
|
2286
|
+
const n = this.openHandles.get(e.path);
|
|
2287
|
+
n && (n.refCount--, n.refCount <= 0 && (xt(t, n.syncHandle, e.path), this.openHandles.delete(e.path)));
|
|
2277
2288
|
}
|
|
2278
2289
|
/**
|
|
2279
2290
|
* Read data from a file descriptor
|
|
@@ -2303,13 +2314,13 @@ class gs {
|
|
|
2303
2314
|
const o = this._getFileDescriptor(t);
|
|
2304
2315
|
St(e.length, n, r, i);
|
|
2305
2316
|
try {
|
|
2306
|
-
const a = i ?? o.position,
|
|
2317
|
+
const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
|
|
2307
2318
|
if (h)
|
|
2308
|
-
return
|
|
2309
|
-
const f = e.subarray(n, n +
|
|
2310
|
-
return i == null && (o.position = a + u),
|
|
2319
|
+
return _({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2320
|
+
const f = e.subarray(n, n + l), u = o.syncHandle.read(f, { at: a });
|
|
2321
|
+
return i == null && (o.position = a + u), _({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2311
2322
|
} catch (a) {
|
|
2312
|
-
throw
|
|
2323
|
+
throw z("read", t, o.path, a);
|
|
2313
2324
|
}
|
|
2314
2325
|
}
|
|
2315
2326
|
/**
|
|
@@ -2334,13 +2345,13 @@ class gs {
|
|
|
2334
2345
|
* \`\`\`
|
|
2335
2346
|
*/
|
|
2336
2347
|
async write(t, e, n = 0, r, i, o = !0) {
|
|
2337
|
-
const a = this._getFileDescriptor(t),
|
|
2338
|
-
St(e.length, n,
|
|
2348
|
+
const a = this._getFileDescriptor(t), c = r ?? e.length - n;
|
|
2349
|
+
St(e.length, n, c, i);
|
|
2339
2350
|
try {
|
|
2340
|
-
const h = i ?? a.position,
|
|
2341
|
-
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type:
|
|
2351
|
+
const h = i ?? a.position, l = e.subarray(n, n + c), f = a.syncHandle.write(l, { at: h });
|
|
2352
|
+
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
|
|
2342
2353
|
} catch (h) {
|
|
2343
|
-
throw
|
|
2354
|
+
throw z("write", t, a.path, h);
|
|
2344
2355
|
}
|
|
2345
2356
|
}
|
|
2346
2357
|
/**
|
|
@@ -2386,9 +2397,9 @@ class gs {
|
|
|
2386
2397
|
if (e < 0 || !Number.isInteger(e))
|
|
2387
2398
|
throw new N("argument", "Invalid size");
|
|
2388
2399
|
try {
|
|
2389
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2400
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
|
|
2390
2401
|
} catch (r) {
|
|
2391
|
-
throw
|
|
2402
|
+
throw z("truncate", t, n.path, r);
|
|
2392
2403
|
}
|
|
2393
2404
|
}
|
|
2394
2405
|
/**
|
|
@@ -2410,7 +2421,7 @@ class gs {
|
|
|
2410
2421
|
try {
|
|
2411
2422
|
e.syncHandle.flush();
|
|
2412
2423
|
} catch (n) {
|
|
2413
|
-
throw
|
|
2424
|
+
throw z("sync", t, e.path, n);
|
|
2414
2425
|
}
|
|
2415
2426
|
}
|
|
2416
2427
|
/**
|
|
@@ -2421,9 +2432,9 @@ class gs {
|
|
|
2421
2432
|
*/
|
|
2422
2433
|
dispose() {
|
|
2423
2434
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2424
|
-
for (const [t, e] of this.
|
|
2425
|
-
xt(
|
|
2426
|
-
this.openFiles.clear(), this.nextFd = 1;
|
|
2435
|
+
for (const [t, e] of this.openHandles)
|
|
2436
|
+
xt(-1, e.syncHandle, t);
|
|
2437
|
+
this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1;
|
|
2427
2438
|
}
|
|
2428
2439
|
/**
|
|
2429
2440
|
* Synchronize the file system with external data
|
|
@@ -2460,12 +2471,12 @@ class gs {
|
|
|
2460
2471
|
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2461
2472
|
}
|
|
2462
2473
|
} catch (e) {
|
|
2463
|
-
throw e instanceof w ? e :
|
|
2474
|
+
throw e instanceof w ? e : O(e);
|
|
2464
2475
|
}
|
|
2465
2476
|
}
|
|
2466
2477
|
}
|
|
2467
|
-
|
|
2468
|
-
//# sourceMappingURL=worker-
|
|
2478
|
+
ot(new gs());
|
|
2479
|
+
//# sourceMappingURL=worker.entry-DUlEoroc.js.map
|
|
2469
2480
|
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2470
2481
|
function m(a) {
|
|
2471
2482
|
let n;
|
|
@@ -2488,15 +2499,36 @@ function m(a) {
|
|
|
2488
2499
|
);
|
|
2489
2500
|
}
|
|
2490
2501
|
}
|
|
2502
|
+
const y = m;
|
|
2503
|
+
function w(a, n) {
|
|
2504
|
+
n && (n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), a.setOptions(n));
|
|
2505
|
+
}
|
|
2506
|
+
function g(a) {
|
|
2507
|
+
const n = new y(), t = u(n);
|
|
2508
|
+
return w(t, a), {
|
|
2509
|
+
fs: t,
|
|
2510
|
+
worker: n,
|
|
2511
|
+
dispose() {
|
|
2512
|
+
(async () => {
|
|
2513
|
+
try {
|
|
2514
|
+
await t.dispose();
|
|
2515
|
+
} finally {
|
|
2516
|
+
n.terminate();
|
|
2517
|
+
}
|
|
2518
|
+
})();
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2491
2522
|
function i(a) {
|
|
2492
2523
|
return a instanceof URL ? a.pathname : a;
|
|
2493
2524
|
}
|
|
2494
|
-
class
|
|
2525
|
+
class b {
|
|
2495
2526
|
#n;
|
|
2496
2527
|
#t;
|
|
2497
2528
|
promises = this;
|
|
2498
2529
|
constructor(n) {
|
|
2499
|
-
|
|
2530
|
+
const t = g(n);
|
|
2531
|
+
this.#n = t.fs, this.#t = t.dispose;
|
|
2500
2532
|
}
|
|
2501
2533
|
/**
|
|
2502
2534
|
* Start watching a file or directory for changes
|
|
@@ -2738,65 +2770,62 @@ class y {
|
|
|
2738
2770
|
* Dispose of resources, detach the worker and clean up the file system instance
|
|
2739
2771
|
*/
|
|
2740
2772
|
dispose() {
|
|
2741
|
-
|
|
2742
|
-
(async () => {
|
|
2743
|
-
try {
|
|
2744
|
-
await n.dispose();
|
|
2745
|
-
} finally {
|
|
2746
|
-
t.terminate();
|
|
2747
|
-
}
|
|
2748
|
-
})();
|
|
2773
|
+
this.#t();
|
|
2749
2774
|
}
|
|
2750
2775
|
}
|
|
2751
|
-
function
|
|
2752
|
-
return new
|
|
2776
|
+
function v(a) {
|
|
2777
|
+
return new b(a);
|
|
2753
2778
|
}
|
|
2779
|
+
const S = v;
|
|
2754
2780
|
export {
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2781
|
+
F as AlreadyExistsError,
|
|
2782
|
+
A as BINARY_FILE_EXTENSIONS,
|
|
2783
|
+
T as DirectoryOperationError,
|
|
2784
|
+
R as ExistenceError,
|
|
2785
|
+
C as FileBusyError,
|
|
2786
|
+
I as FileSystemOperationError,
|
|
2787
|
+
D as FileTypeError,
|
|
2788
|
+
$ as IOError,
|
|
2789
|
+
_ as InitializationFailedError,
|
|
2790
|
+
N as OPFSError,
|
|
2791
|
+
b as OPFSFacade,
|
|
2792
|
+
b as OPFSFileSystem,
|
|
2793
|
+
k as OPFSNotSupportedError,
|
|
2794
|
+
z as OperationAbortedError,
|
|
2795
|
+
M as OperationNotSupportedError,
|
|
2796
|
+
j as PathError,
|
|
2797
|
+
W as PermissionError,
|
|
2798
|
+
L as StorageError,
|
|
2799
|
+
U as ValidationError,
|
|
2800
|
+
H as WatchEventType,
|
|
2801
|
+
B as basename,
|
|
2802
|
+
G as buffersEqual,
|
|
2803
|
+
q as calculateFileHash,
|
|
2804
|
+
Y as calculateReadLength,
|
|
2805
|
+
V as checkOPFSSupport,
|
|
2806
|
+
Z as convertBlobToUint8Array,
|
|
2807
|
+
J as createBuffer,
|
|
2808
|
+
X as createFDError,
|
|
2809
|
+
v as createOPFS,
|
|
2810
|
+
g as createOPFSWorker,
|
|
2811
|
+
K as createSyncHandleSafe,
|
|
2812
|
+
S as createWorker,
|
|
2784
2813
|
l as decodeBuffer,
|
|
2785
|
-
|
|
2814
|
+
Q as dirname,
|
|
2786
2815
|
c as encodeString,
|
|
2787
|
-
|
|
2816
|
+
nn as extname,
|
|
2788
2817
|
h as isBinaryFileExtension,
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2818
|
+
tn as isPathExcluded,
|
|
2819
|
+
en as joinPath,
|
|
2820
|
+
rn as mapDomError,
|
|
2821
|
+
sn as matchMinimatch,
|
|
2822
|
+
an as normalizeMinimatch,
|
|
2823
|
+
on as normalizePath,
|
|
2824
|
+
cn as removeEntry,
|
|
2825
|
+
hn as resolvePath,
|
|
2826
|
+
ln as safeCloseSyncHandle,
|
|
2827
|
+
pn as splitPath,
|
|
2828
|
+
fn as validateReadWriteArgs,
|
|
2829
|
+
dn as withLock
|
|
2801
2830
|
};
|
|
2802
2831
|
//# sourceMappingURL=index.js.map
|