opfs-worker 1.3.1 → 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} +26 -9
- package/dist/OPFSFacade.d.ts.map +1 -0
- package/dist/{worker.d.ts → OPFSWorker.d.ts} +11 -11
- 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-CKOebsbw.js → helpers-WY2jfbOT.js} +257 -253
- package/dist/helpers-WY2jfbOT.js.map +1 -0
- package/dist/index.cjs +349 -329
- 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 +428 -382
- 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} +248 -188
- 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/errors.d.ts +14 -6
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +15 -3
- 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 +15 -9
- 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/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.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-CKOebsbw.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 $, f as D, g as _, P as N, b as z, S as k, 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 q, k as V, L as Y, p as J, x as X, u as Z, 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-CKOebsbw.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] =
|
|
89
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
90
|
-
}).catch((
|
|
91
|
-
const [f, u] =
|
|
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
|
+
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) {
|
|
@@ -115,82 +115,82 @@ function Gt(s, t) {
|
|
|
115
115
|
} finally {
|
|
116
116
|
e.delete(i.id);
|
|
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
|
|
124
|
+
function vt(s) {
|
|
125
125
|
return $(s, /* @__PURE__ */ new Map(), {
|
|
126
126
|
type: "RELEASE"
|
|
127
127
|
}).then(() => {
|
|
128
|
-
|
|
128
|
+
At(s);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
132
|
-
const t = (
|
|
133
|
-
|
|
131
|
+
const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
132
|
+
const t = (G.get(s) || 0) - 1;
|
|
133
|
+
G.set(s, t), t === 0 && vt(s);
|
|
134
134
|
});
|
|
135
135
|
function qt(s, t) {
|
|
136
|
-
const e = (
|
|
137
|
-
|
|
136
|
+
const e = (G.get(t) || 0) + 1;
|
|
137
|
+
G.set(t, e), q && q.register(s, t, s);
|
|
138
138
|
}
|
|
139
139
|
function Vt(s) {
|
|
140
|
-
|
|
140
|
+
q && q.unregister(s);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function st(s, t, e = [], n = function() {
|
|
143
143
|
}) {
|
|
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
|
-
return
|
|
160
|
+
return st(s, t, [...e, a]);
|
|
161
161
|
},
|
|
162
|
-
set(o, a,
|
|
163
|
-
|
|
164
|
-
const [h,
|
|
162
|
+
set(o, a, c) {
|
|
163
|
+
L(r);
|
|
164
|
+
const [h, l] = V(c);
|
|
165
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 ===
|
|
174
|
+
if (h === zt)
|
|
175
175
|
return $(s, t, {
|
|
176
176
|
type: "ENDPOINT"
|
|
177
177
|
}).then(C);
|
|
178
178
|
if (h === "bind")
|
|
179
|
-
return
|
|
180
|
-
const [
|
|
179
|
+
return st(s, t, e.slice(0, -1));
|
|
180
|
+
const [l, f] = ht(c);
|
|
181
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 [
|
|
188
|
+
L(r);
|
|
189
|
+
const [c, h] = ht(a);
|
|
190
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
|
});
|
|
@@ -200,17 +200,17 @@ function Yt(s) {
|
|
|
200
200
|
return Array.prototype.concat.apply([], s);
|
|
201
201
|
}
|
|
202
202
|
function ht(s) {
|
|
203
|
-
const t = s.map(
|
|
203
|
+
const t = s.map(V);
|
|
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) {
|
|
211
211
|
return Object.assign(s, { [bt]: !0 });
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function V(s) {
|
|
214
214
|
for (const [t, e] of Dt)
|
|
215
215
|
if (e.canHandle(s)) {
|
|
216
216
|
const [n, r] = e.serialize(s);
|
|
@@ -248,7 +248,7 @@ function $(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}\`,
|
|
@@ -324,7 +324,7 @@ class se extends w {
|
|
|
324
324
|
super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
class
|
|
327
|
+
class nt extends w {
|
|
328
328
|
constructor(t, e, n) {
|
|
329
329
|
const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
330
330
|
super(r, i, e, "access", n);
|
|
@@ -371,36 +371,36 @@ class re extends w {
|
|
|
371
371
|
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
class
|
|
374
|
+
class J extends w {
|
|
375
375
|
constructor(t, e, n) {
|
|
376
376
|
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
class
|
|
379
|
+
class Q extends w {
|
|
380
380
|
constructor(t, e) {
|
|
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
|
|
389
|
-
const e = t?.path, n = t?.isDirectory;
|
|
388
|
+
function O(s, t) {
|
|
389
|
+
const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
|
|
390
390
|
switch (s.name) {
|
|
391
391
|
case "InvalidStateError":
|
|
392
392
|
return new se(e || "unknown", s);
|
|
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
|
-
return n !== void 0 ? n ? new
|
|
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":
|
|
400
400
|
case "SecurityError":
|
|
401
401
|
return new te(e, "unknown", s);
|
|
402
402
|
case "InvalidModificationError":
|
|
403
|
-
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
403
|
+
return i === "remove" ? new rt("ENOTEMPTY", e, s) : new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
404
404
|
case "AbortError":
|
|
405
405
|
return new ne(e || "unknown", s);
|
|
406
406
|
case "OperationError":
|
|
@@ -408,10 +408,10 @@ function A(s, t) {
|
|
|
408
408
|
case "TypeError":
|
|
409
409
|
return new Ct(e || "unknown", s);
|
|
410
410
|
default:
|
|
411
|
-
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
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
|
-
},
|
|
445
|
-
function
|
|
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
|
+
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,59 +477,59 @@ 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 =
|
|
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
|
|
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
513
|
const H = new Array(T + 1).join("0");
|
|
514
|
-
x < 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;
|
|
531
531
|
}
|
|
532
|
-
const Oe = 1024 * 64,
|
|
532
|
+
const Oe = 1024 * 64, Y = (s) => {
|
|
533
533
|
if (typeof s != "string")
|
|
534
534
|
throw new TypeError("invalid pattern");
|
|
535
535
|
if (s.length > Oe)
|
|
@@ -549,60 +549,60 @@ const Oe = 1024 * 64, Z = (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
|
-
},
|
|
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, [v,
|
|
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(v) : n.push(v), a = a ||
|
|
577
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || M;
|
|
578
578
|
continue t;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
if (
|
|
582
|
-
p > f ? n.push(
|
|
581
|
+
if (c = !1, f) {
|
|
582
|
+
p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
|
|
583
583
|
continue;
|
|
584
584
|
}
|
|
585
585
|
if (s.startsWith("-]", i + 1)) {
|
|
586
|
-
n.push(
|
|
586
|
+
n.push(P(p + "-")), i += 2;
|
|
587
587
|
continue;
|
|
588
588
|
}
|
|
589
589
|
if (s.startsWith("-", i + 1)) {
|
|
590
590
|
f = p, i += 2;
|
|
591
591
|
continue;
|
|
592
592
|
}
|
|
593
|
-
n.push(
|
|
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
|
-
}, 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))",
|
|
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,23 +854,23 @@ 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, v] = typeof d == "string" ? E.#p(d, this.#n,
|
|
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
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
|
-
|
|
873
|
+
l + h + f,
|
|
874
874
|
k(h),
|
|
875
875
|
this.#n = !!this.#n,
|
|
876
876
|
this.#i
|
|
@@ -879,20 +879,20 @@ 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,
|
|
@@ -912,66 +912,66 @@ 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 +=
|
|
939
|
+
i += Te(c);
|
|
940
940
|
}
|
|
941
941
|
return [i, k(t), !!e, o];
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
const
|
|
945
|
-
const e =
|
|
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
|
+
const e = kt([s]);
|
|
946
946
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
947
947
|
}, Ze = ([s, t = ""]) => {
|
|
948
|
-
const e =
|
|
948
|
+
const e = It([s]);
|
|
949
949
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
950
950
|
}, Xe = ([s, t = ""]) => {
|
|
951
|
-
const e =
|
|
951
|
+
const e = It([s]);
|
|
952
952
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
953
953
|
}, Je = ([s, t = ""]) => {
|
|
954
|
-
const e =
|
|
954
|
+
const e = kt([s]);
|
|
955
955
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
956
|
-
},
|
|
956
|
+
}, kt = ([s]) => {
|
|
957
957
|
const t = s.length;
|
|
958
958
|
return (e) => e.length === t && !e.startsWith(".");
|
|
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,21 +999,21 @@ 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
|
-
|
|
1008
|
-
const is = (s, t = {}) => new
|
|
1009
|
-
|
|
1005
|
+
m.defaults = rs;
|
|
1006
|
+
const Lt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : me(s));
|
|
1007
|
+
m.braceExpand = Lt;
|
|
1008
|
+
const is = (s, t = {}) => new Z(s, t).makeRe();
|
|
1009
|
+
m.makeRe = is;
|
|
1010
1010
|
const os = (s, t, e = {}) => {
|
|
1011
|
-
const n = new
|
|
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
|
|
1016
|
-
class
|
|
1014
|
+
m.match = os;
|
|
1015
|
+
const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1016
|
+
class Z {
|
|
1017
1017
|
options;
|
|
1018
1018
|
set;
|
|
1019
1019
|
pattern;
|
|
@@ -1032,7 +1032,7 @@ class X {
|
|
|
1032
1032
|
windowsNoMagicRoot;
|
|
1033
1033
|
regexp;
|
|
1034
1034
|
constructor(t, e = {}) {
|
|
1035
|
-
|
|
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 X {
|
|
|
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 X {
|
|
|
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 X {
|
|
|
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 X {
|
|
|
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]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]),
|
|
1244
|
-
if (typeof x == "number" && typeof
|
|
1245
|
-
const [T, H] = [t[x], e[
|
|
1246
|
-
T.toLowerCase() === H.toLowerCase() && (e[
|
|
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,56 +1352,56 @@ 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
|
-
function
|
|
1388
|
-
const t =
|
|
1387
|
+
function tt(s) {
|
|
1388
|
+
const t = F(s);
|
|
1389
1389
|
return t.pop(), lt(t);
|
|
1390
1390
|
}
|
|
1391
|
-
function
|
|
1391
|
+
function B(s) {
|
|
1392
1392
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1393
1393
|
}
|
|
1394
1394
|
function ls(s, t = !1) {
|
|
1395
1395
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1396
1396
|
}
|
|
1397
|
-
function
|
|
1398
|
-
return
|
|
1397
|
+
function et(s, t) {
|
|
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 =
|
|
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,15 +1424,19 @@ 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 });
|
|
1431
1431
|
} catch (o) {
|
|
1432
|
-
if (o.name === "NotFoundError")
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1432
|
+
if (o.name === "NotFoundError" && i)
|
|
1433
|
+
return;
|
|
1434
|
+
const a = o.name === "TypeMismatchError" && !r;
|
|
1435
|
+
throw O(o, {
|
|
1436
|
+
path: t,
|
|
1437
|
+
operation: "remove",
|
|
1438
|
+
isDirectory: a
|
|
1439
|
+
});
|
|
1436
1440
|
}
|
|
1437
1441
|
});
|
|
1438
1442
|
}
|
|
@@ -1463,7 +1467,7 @@ async function ps(s, t) {
|
|
|
1463
1467
|
try {
|
|
1464
1468
|
return await s.createSyncAccessHandle();
|
|
1465
1469
|
} catch (e) {
|
|
1466
|
-
throw
|
|
1470
|
+
throw O(e, { path: t, isDirectory: !1 });
|
|
1467
1471
|
}
|
|
1468
1472
|
}
|
|
1469
1473
|
class gs {
|
|
@@ -1483,6 +1487,8 @@ class gs {
|
|
|
1483
1487
|
hashAlgorithm: "etag",
|
|
1484
1488
|
broadcastChannel: "opfs-worker"
|
|
1485
1489
|
};
|
|
1490
|
+
/** Shared sync handles per path (OPFS allows only one handle per file) */
|
|
1491
|
+
openHandles = /* @__PURE__ */ new Map();
|
|
1486
1492
|
/** Map of open file descriptors to their metadata */
|
|
1487
1493
|
openFiles = /* @__PURE__ */ new Map();
|
|
1488
1494
|
/** Next available file descriptor number */
|
|
@@ -1503,14 +1509,13 @@ class gs {
|
|
|
1503
1509
|
* This method is called by internal operations to notify clients about
|
|
1504
1510
|
* changes, even when no specific paths are being watched.
|
|
1505
1511
|
*
|
|
1506
|
-
* @param
|
|
1507
|
-
* @param type - The type of change (create, change, delete)
|
|
1512
|
+
* @param event - The event describing the change
|
|
1508
1513
|
*/
|
|
1509
1514
|
async notifyChange(t) {
|
|
1510
1515
|
if (!this.options.broadcastChannel)
|
|
1511
1516
|
return;
|
|
1512
1517
|
const e = t.path;
|
|
1513
|
-
if (![...this.watchers.values()].some((i) =>
|
|
1518
|
+
if (![...this.watchers.values()].some((i) => et(e, i.pattern) && i.include.some((o) => o && et(e, o)) && !i.exclude.some((o) => o && et(e, o))))
|
|
1514
1519
|
return;
|
|
1515
1520
|
let r;
|
|
1516
1521
|
if (this.options.hashAlgorithm)
|
|
@@ -1532,7 +1537,7 @@ class gs {
|
|
|
1532
1537
|
}
|
|
1533
1538
|
}
|
|
1534
1539
|
/**
|
|
1535
|
-
* Creates a new
|
|
1540
|
+
* Creates a new OPFSWorker instance
|
|
1536
1541
|
*
|
|
1537
1542
|
* @param options - Optional configuration options
|
|
1538
1543
|
* @param options.root - Root path for the file system (default: '/')
|
|
@@ -1550,13 +1555,12 @@ class gs {
|
|
|
1550
1555
|
* This method sets up the root directory for all subsequent operations.
|
|
1551
1556
|
* If no root is specified, it will use the OPFS root directory.
|
|
1552
1557
|
*
|
|
1553
|
-
* @param root - The root path for the file system (default: '/')
|
|
1554
1558
|
* @returns Promise that resolves to true if initialization was successful
|
|
1555
1559
|
* @throws {OPFSError} If initialization fails
|
|
1556
1560
|
*
|
|
1557
1561
|
* @example
|
|
1558
1562
|
* \`\`\`typescript
|
|
1559
|
-
* const fs = new
|
|
1563
|
+
* const fs = new OPFSWorker();
|
|
1560
1564
|
*
|
|
1561
1565
|
* // Use OPFS root (default)
|
|
1562
1566
|
* await fs.mount();
|
|
@@ -1589,7 +1593,7 @@ class gs {
|
|
|
1589
1593
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1590
1594
|
*/
|
|
1591
1595
|
async setOptions(t) {
|
|
1592
|
-
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root =
|
|
1596
|
+
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = B(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1593
1597
|
}
|
|
1594
1598
|
/**
|
|
1595
1599
|
* Get a directory handle from a path
|
|
@@ -1610,7 +1614,7 @@ class gs {
|
|
|
1610
1614
|
* \`\`\`
|
|
1611
1615
|
*/
|
|
1612
1616
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1613
|
-
const r = Array.isArray(t) ? t :
|
|
1617
|
+
const r = Array.isArray(t) ? t : F(t);
|
|
1614
1618
|
let i = n;
|
|
1615
1619
|
for (const o of r)
|
|
1616
1620
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
@@ -1636,7 +1640,7 @@ class gs {
|
|
|
1636
1640
|
* \`\`\`
|
|
1637
1641
|
*/
|
|
1638
1642
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1639
|
-
const r =
|
|
1643
|
+
const r = F(t);
|
|
1640
1644
|
if (r.length === 0)
|
|
1641
1645
|
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1642
1646
|
const i = r.pop();
|
|
@@ -1705,17 +1709,17 @@ class gs {
|
|
|
1705
1709
|
async readFile(t) {
|
|
1706
1710
|
await this.mount();
|
|
1707
1711
|
try {
|
|
1708
|
-
return await
|
|
1712
|
+
return await I(t, async () => {
|
|
1709
1713
|
const e = await this.open(t);
|
|
1710
1714
|
try {
|
|
1711
1715
|
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1712
|
-
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]);
|
|
1713
1717
|
} finally {
|
|
1714
1718
|
await this.close(e);
|
|
1715
1719
|
}
|
|
1716
1720
|
});
|
|
1717
1721
|
} catch (e) {
|
|
1718
|
-
throw
|
|
1722
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
|
|
1719
1723
|
}
|
|
1720
1724
|
}
|
|
1721
1725
|
/**
|
|
@@ -1743,14 +1747,14 @@ class gs {
|
|
|
1743
1747
|
async writeFile(t, e) {
|
|
1744
1748
|
await this.mount();
|
|
1745
1749
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1746
|
-
await
|
|
1750
|
+
await I(t, async () => {
|
|
1747
1751
|
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1748
1752
|
try {
|
|
1749
1753
|
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1750
1754
|
} finally {
|
|
1751
1755
|
await this.close(i);
|
|
1752
1756
|
}
|
|
1753
|
-
await this.notifyChange({ path: t, type: r ?
|
|
1757
|
+
await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
|
|
1754
1758
|
});
|
|
1755
1759
|
}
|
|
1756
1760
|
/**
|
|
@@ -1778,7 +1782,7 @@ class gs {
|
|
|
1778
1782
|
async appendFile(t, e) {
|
|
1779
1783
|
await this.mount();
|
|
1780
1784
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1781
|
-
await
|
|
1785
|
+
await I(t, async () => {
|
|
1782
1786
|
const r = await this.open(t, { create: !0 });
|
|
1783
1787
|
try {
|
|
1784
1788
|
const { size: i } = await this.fstat(r);
|
|
@@ -1786,7 +1790,7 @@ class gs {
|
|
|
1786
1790
|
} finally {
|
|
1787
1791
|
await this.close(r);
|
|
1788
1792
|
}
|
|
1789
|
-
await this.notifyChange({ path: t, type:
|
|
1793
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
|
|
1790
1794
|
});
|
|
1791
1795
|
}
|
|
1792
1796
|
/**
|
|
@@ -1812,17 +1816,20 @@ class gs {
|
|
|
1812
1816
|
*/
|
|
1813
1817
|
async mkdir(t, e) {
|
|
1814
1818
|
await this.mount();
|
|
1815
|
-
const n = e?.recursive ?? !1, r =
|
|
1819
|
+
const n = e?.recursive ?? !1, r = F(t);
|
|
1816
1820
|
let i = this.root;
|
|
1817
1821
|
for (let o = 0; o < r.length; o++) {
|
|
1818
1822
|
const a = r[o];
|
|
1819
1823
|
try {
|
|
1820
1824
|
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1821
|
-
} catch (
|
|
1822
|
-
throw
|
|
1825
|
+
} catch (c) {
|
|
1826
|
+
throw c.name === "NotFoundError" ? O(c, {
|
|
1827
|
+
path: lt(r.slice(0, o + 1)),
|
|
1828
|
+
existenceType: "directory"
|
|
1829
|
+
}) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
|
|
1823
1830
|
}
|
|
1824
1831
|
}
|
|
1825
|
-
await this.notifyChange({ path: t, type:
|
|
1832
|
+
await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
|
|
1826
1833
|
}
|
|
1827
1834
|
/**
|
|
1828
1835
|
* Get file or directory statistics
|
|
@@ -1859,7 +1866,7 @@ class gs {
|
|
|
1859
1866
|
const e = it(t);
|
|
1860
1867
|
let n;
|
|
1861
1868
|
try {
|
|
1862
|
-
n = await this.getDirectoryHandle(
|
|
1869
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1863
1870
|
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1864
1871
|
kind: "file",
|
|
1865
1872
|
size: o.size,
|
|
@@ -1872,17 +1879,17 @@ class gs {
|
|
|
1872
1879
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1873
1880
|
else if (typeof r == "string")
|
|
1874
1881
|
try {
|
|
1875
|
-
const
|
|
1876
|
-
a.hash =
|
|
1877
|
-
} catch (
|
|
1878
|
-
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);
|
|
1879
1886
|
}
|
|
1880
1887
|
return a;
|
|
1881
1888
|
} catch (r) {
|
|
1882
1889
|
if (r.name === "NotFoundError")
|
|
1883
|
-
throw new
|
|
1890
|
+
throw new U("file", t, r);
|
|
1884
1891
|
if (r.name !== "TypeMismatchError")
|
|
1885
|
-
throw new
|
|
1892
|
+
throw new J("stat", t, r);
|
|
1886
1893
|
}
|
|
1887
1894
|
try {
|
|
1888
1895
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1894,7 +1901,7 @@ class gs {
|
|
|
1894
1901
|
isDirectory: !0
|
|
1895
1902
|
};
|
|
1896
1903
|
} catch (r) {
|
|
1897
|
-
throw new
|
|
1904
|
+
throw new J("stat", t, r);
|
|
1898
1905
|
}
|
|
1899
1906
|
}
|
|
1900
1907
|
/**
|
|
@@ -1949,7 +1956,7 @@ class gs {
|
|
|
1949
1956
|
const e = it(t);
|
|
1950
1957
|
let n = null;
|
|
1951
1958
|
try {
|
|
1952
|
-
n = await this.getDirectoryHandle(
|
|
1959
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1953
1960
|
} catch (r) {
|
|
1954
1961
|
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1955
1962
|
throw r;
|
|
@@ -1997,9 +2004,9 @@ class gs {
|
|
|
1997
2004
|
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1998
2005
|
await this.remove(r, { recursive: !0 });
|
|
1999
2006
|
}
|
|
2000
|
-
await this.notifyChange({ path: t, type:
|
|
2007
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
|
|
2001
2008
|
} catch (e) {
|
|
2002
|
-
throw e instanceof w ? e :
|
|
2009
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
|
|
2003
2010
|
}
|
|
2004
2011
|
}
|
|
2005
2012
|
/**
|
|
@@ -2029,8 +2036,8 @@ class gs {
|
|
|
2029
2036
|
async remove(t, e) {
|
|
2030
2037
|
if (await this.mount(), t === "/")
|
|
2031
2038
|
throw new rt("EROOT", t);
|
|
2032
|
-
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(
|
|
2033
|
-
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type:
|
|
2039
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
|
|
2040
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
|
|
2034
2041
|
}
|
|
2035
2042
|
/**
|
|
2036
2043
|
* Resolve a path to an absolute path
|
|
@@ -2055,10 +2062,10 @@ class gs {
|
|
|
2055
2062
|
try {
|
|
2056
2063
|
const e = Et(t);
|
|
2057
2064
|
if (!await this.exists(e))
|
|
2058
|
-
throw new
|
|
2065
|
+
throw new U("file", e);
|
|
2059
2066
|
return e;
|
|
2060
2067
|
} catch (e) {
|
|
2061
|
-
throw e instanceof w ? e :
|
|
2068
|
+
throw e instanceof w ? e : O(e, { path: t });
|
|
2062
2069
|
}
|
|
2063
2070
|
}
|
|
2064
2071
|
/**
|
|
@@ -2088,10 +2095,10 @@ class gs {
|
|
|
2088
2095
|
try {
|
|
2089
2096
|
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2090
2097
|
if (await this.exists(e) && !r)
|
|
2091
|
-
throw new
|
|
2092
|
-
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type:
|
|
2098
|
+
throw new Q(e);
|
|
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 });
|
|
2093
2100
|
} catch (r) {
|
|
2094
|
-
throw r instanceof w ? r :
|
|
2101
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2095
2102
|
}
|
|
2096
2103
|
}
|
|
2097
2104
|
/**
|
|
@@ -2124,24 +2131,24 @@ class gs {
|
|
|
2124
2131
|
try {
|
|
2125
2132
|
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2126
2133
|
if (!await this.exists(t))
|
|
2127
|
-
throw new
|
|
2134
|
+
throw new U("source", t);
|
|
2128
2135
|
if (await this.exists(e) && !i)
|
|
2129
|
-
throw new
|
|
2136
|
+
throw new Q(e);
|
|
2130
2137
|
if ((await this.stat(t)).isFile) {
|
|
2131
2138
|
const h = await this.readFile(t);
|
|
2132
2139
|
await this.writeFile(e, h);
|
|
2133
2140
|
} else {
|
|
2134
2141
|
if (!r)
|
|
2135
|
-
throw new
|
|
2142
|
+
throw new nt("directory", t);
|
|
2136
2143
|
await this.mkdir(e, { recursive: !0 });
|
|
2137
2144
|
const h = await this.readDir(t);
|
|
2138
|
-
for (const
|
|
2139
|
-
const f = \`\${t}/\${
|
|
2145
|
+
for (const l of h) {
|
|
2146
|
+
const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
|
|
2140
2147
|
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2141
2148
|
}
|
|
2142
2149
|
}
|
|
2143
2150
|
} catch (r) {
|
|
2144
|
-
throw r instanceof w ? r :
|
|
2151
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2145
2152
|
}
|
|
2146
2153
|
}
|
|
2147
2154
|
/**
|
|
@@ -2214,37 +2221,50 @@ class gs {
|
|
|
2214
2221
|
*/
|
|
2215
2222
|
async open(t, e) {
|
|
2216
2223
|
await this.mount();
|
|
2217
|
-
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o =
|
|
2224
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
|
|
2218
2225
|
try {
|
|
2219
|
-
return n && r ? await
|
|
2226
|
+
return n && r ? await I(o, async () => {
|
|
2220
2227
|
if (await this.exists(o))
|
|
2221
|
-
throw new
|
|
2228
|
+
throw new Q(o);
|
|
2222
2229
|
return this._openFile(o, n, i);
|
|
2223
2230
|
}) : await this._openFile(o, n, i);
|
|
2224
2231
|
} catch (a) {
|
|
2225
|
-
|
|
2232
|
+
if (a instanceof w)
|
|
2233
|
+
throw a;
|
|
2234
|
+
const c = a && a.name === "TypeMismatchError";
|
|
2235
|
+
throw O(a, {
|
|
2236
|
+
path: o,
|
|
2237
|
+
isDirectory: !!c
|
|
2238
|
+
});
|
|
2226
2239
|
}
|
|
2227
2240
|
}
|
|
2228
2241
|
/**
|
|
2229
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.
|
|
2230
2246
|
* @private
|
|
2231
2247
|
*/
|
|
2232
2248
|
async _openFile(t, e, n) {
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
await
|
|
2236
|
-
|
|
2237
|
-
|
|
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);
|
|
2238
2259
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
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, {
|
|
2243
2263
|
path: t,
|
|
2244
|
-
fileHandle: r,
|
|
2245
|
-
syncHandle:
|
|
2264
|
+
fileHandle: r.fileHandle,
|
|
2265
|
+
syncHandle: r.syncHandle,
|
|
2246
2266
|
position: 0
|
|
2247
|
-
}),
|
|
2267
|
+
}), i;
|
|
2248
2268
|
}
|
|
2249
2269
|
/**
|
|
2250
2270
|
* Close a file descriptor
|
|
@@ -2262,7 +2282,9 @@ class gs {
|
|
|
2262
2282
|
*/
|
|
2263
2283
|
async close(t) {
|
|
2264
2284
|
const e = this._getFileDescriptor(t);
|
|
2265
|
-
|
|
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)));
|
|
2266
2288
|
}
|
|
2267
2289
|
/**
|
|
2268
2290
|
* Read data from a file descriptor
|
|
@@ -2292,13 +2314,13 @@ class gs {
|
|
|
2292
2314
|
const o = this._getFileDescriptor(t);
|
|
2293
2315
|
St(e.length, n, r, i);
|
|
2294
2316
|
try {
|
|
2295
|
-
const a = i ?? o.position,
|
|
2317
|
+
const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
|
|
2296
2318
|
if (h)
|
|
2297
|
-
return
|
|
2298
|
-
const f = e.subarray(n, n +
|
|
2299
|
-
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]);
|
|
2300
2322
|
} catch (a) {
|
|
2301
|
-
throw
|
|
2323
|
+
throw z("read", t, o.path, a);
|
|
2302
2324
|
}
|
|
2303
2325
|
}
|
|
2304
2326
|
/**
|
|
@@ -2323,13 +2345,13 @@ class gs {
|
|
|
2323
2345
|
* \`\`\`
|
|
2324
2346
|
*/
|
|
2325
2347
|
async write(t, e, n = 0, r, i, o = !0) {
|
|
2326
|
-
const a = this._getFileDescriptor(t),
|
|
2327
|
-
St(e.length, n,
|
|
2348
|
+
const a = this._getFileDescriptor(t), c = r ?? e.length - n;
|
|
2349
|
+
St(e.length, n, c, i);
|
|
2328
2350
|
try {
|
|
2329
|
-
const h = i ?? a.position,
|
|
2330
|
-
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;
|
|
2331
2353
|
} catch (h) {
|
|
2332
|
-
throw
|
|
2354
|
+
throw z("write", t, a.path, h);
|
|
2333
2355
|
}
|
|
2334
2356
|
}
|
|
2335
2357
|
/**
|
|
@@ -2375,9 +2397,9 @@ class gs {
|
|
|
2375
2397
|
if (e < 0 || !Number.isInteger(e))
|
|
2376
2398
|
throw new N("argument", "Invalid size");
|
|
2377
2399
|
try {
|
|
2378
|
-
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 });
|
|
2379
2401
|
} catch (r) {
|
|
2380
|
-
throw
|
|
2402
|
+
throw z("truncate", t, n.path, r);
|
|
2381
2403
|
}
|
|
2382
2404
|
}
|
|
2383
2405
|
/**
|
|
@@ -2399,7 +2421,7 @@ class gs {
|
|
|
2399
2421
|
try {
|
|
2400
2422
|
e.syncHandle.flush();
|
|
2401
2423
|
} catch (n) {
|
|
2402
|
-
throw
|
|
2424
|
+
throw z("sync", t, e.path, n);
|
|
2403
2425
|
}
|
|
2404
2426
|
}
|
|
2405
2427
|
/**
|
|
@@ -2410,9 +2432,9 @@ class gs {
|
|
|
2410
2432
|
*/
|
|
2411
2433
|
dispose() {
|
|
2412
2434
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2413
|
-
for (const [t, e] of this.
|
|
2414
|
-
xt(
|
|
2415
|
-
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;
|
|
2416
2438
|
}
|
|
2417
2439
|
/**
|
|
2418
2440
|
* Synchronize the file system with external data
|
|
@@ -2421,8 +2443,6 @@ class gs {
|
|
|
2421
2443
|
* This is useful for importing data from external sources or syncing with remote data.
|
|
2422
2444
|
*
|
|
2423
2445
|
* @param entries - Array of [path, data] tuples to sync
|
|
2424
|
-
* @param options - Options for synchronization
|
|
2425
|
-
* @param options.cleanBefore - Whether to clear the file system before syncing (default: false)
|
|
2426
2446
|
* @returns Promise that resolves when synchronization is complete
|
|
2427
2447
|
* @throws {OPFSError} If the synchronization fails
|
|
2428
2448
|
*
|
|
@@ -2446,17 +2466,17 @@ class gs {
|
|
|
2446
2466
|
await this.mount();
|
|
2447
2467
|
try {
|
|
2448
2468
|
for (const [e, n] of t) {
|
|
2449
|
-
const r =
|
|
2469
|
+
const r = B(e);
|
|
2450
2470
|
let i;
|
|
2451
2471
|
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2452
2472
|
}
|
|
2453
2473
|
} catch (e) {
|
|
2454
|
-
throw e instanceof w ? e :
|
|
2474
|
+
throw e instanceof w ? e : O(e);
|
|
2455
2475
|
}
|
|
2456
2476
|
}
|
|
2457
2477
|
}
|
|
2458
|
-
|
|
2459
|
-
//# sourceMappingURL=worker-
|
|
2478
|
+
ot(new gs());
|
|
2479
|
+
//# sourceMappingURL=worker.entry-DUlEoroc.js.map
|
|
2460
2480
|
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2461
2481
|
function m(a) {
|
|
2462
2482
|
let n;
|
|
@@ -2479,14 +2499,36 @@ function m(a) {
|
|
|
2479
2499
|
);
|
|
2480
2500
|
}
|
|
2481
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
|
+
}
|
|
2482
2522
|
function i(a) {
|
|
2483
2523
|
return a instanceof URL ? a.pathname : a;
|
|
2484
2524
|
}
|
|
2485
|
-
class
|
|
2525
|
+
class b {
|
|
2486
2526
|
#n;
|
|
2527
|
+
#t;
|
|
2487
2528
|
promises = this;
|
|
2488
2529
|
constructor(n) {
|
|
2489
|
-
|
|
2530
|
+
const t = g(n);
|
|
2531
|
+
this.#n = t.fs, this.#t = t.dispose;
|
|
2490
2532
|
}
|
|
2491
2533
|
/**
|
|
2492
2534
|
* Start watching a file or directory for changes
|
|
@@ -2696,12 +2738,6 @@ class y {
|
|
|
2696
2738
|
async fsync(n) {
|
|
2697
2739
|
return this.#n.fsync(n);
|
|
2698
2740
|
}
|
|
2699
|
-
/**
|
|
2700
|
-
* Dispose of resources and clean up the file system instance
|
|
2701
|
-
*/
|
|
2702
|
-
dispose() {
|
|
2703
|
-
this.#n.dispose();
|
|
2704
|
-
}
|
|
2705
2741
|
/**
|
|
2706
2742
|
* Synchronize the file system with external data
|
|
2707
2743
|
*/
|
|
@@ -2730,56 +2766,66 @@ class y {
|
|
|
2730
2766
|
const r = i(n), s = c(t, e);
|
|
2731
2767
|
return this.#n.appendFile(r, s);
|
|
2732
2768
|
}
|
|
2769
|
+
/**
|
|
2770
|
+
* Dispose of resources, detach the worker and clean up the file system instance
|
|
2771
|
+
*/
|
|
2772
|
+
dispose() {
|
|
2773
|
+
this.#t();
|
|
2774
|
+
}
|
|
2733
2775
|
}
|
|
2734
|
-
function
|
|
2735
|
-
return new
|
|
2776
|
+
function v(a) {
|
|
2777
|
+
return new b(a);
|
|
2736
2778
|
}
|
|
2779
|
+
const S = v;
|
|
2737
2780
|
export {
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
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,
|
|
2767
2813
|
l as decodeBuffer,
|
|
2768
|
-
|
|
2814
|
+
Q as dirname,
|
|
2769
2815
|
c as encodeString,
|
|
2770
|
-
|
|
2816
|
+
nn as extname,
|
|
2771
2817
|
h as isBinaryFileExtension,
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
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
|
|
2784
2830
|
};
|
|
2785
2831
|
//# sourceMappingURL=index.js.map
|