opfs-worker 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/worker-DYYLzR1Y.js.map +1 -0
- package/dist/facade.d.ts +4 -4
- package/dist/facade.d.ts.map +1 -1
- package/dist/helpers-Ca2c767K.js +1427 -0
- package/dist/helpers-Ca2c767K.js.map +1 -0
- package/dist/helpers-Dwc92hv9.cjs +4 -0
- package/dist/helpers-Dwc92hv9.cjs.map +1 -0
- package/dist/index.cjs +164 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +189 -172
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +46 -41
- package/dist/raw.js.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 +4 -2
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts +1 -5
- package/dist/worker.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { wrap as u } from "comlink";
|
|
2
|
-
import { i as h, d as l, e as c } from "./helpers-
|
|
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
|
|
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"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"),
|
|
9
|
+
const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), _ = 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) && _ in s,
|
|
20
20
|
serialize({ value: s }) {
|
|
21
21
|
let t;
|
|
22
22
|
return s instanceof Error ? t = {
|
|
@@ -72,7 +72,7 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
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, [u]);
|
|
76
76
|
}
|
|
77
77
|
break;
|
|
78
78
|
case "RELEASE":
|
|
@@ -82,15 +82,15 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
} catch (c) {
|
|
85
|
-
h = { value: c, [
|
|
85
|
+
h = { value: c, [_]: 0 };
|
|
86
86
|
}
|
|
87
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
88
|
-
const [f, u] =
|
|
89
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t),
|
|
87
|
+
Promise.resolve(h).catch((c) => ({ value: c, [_]: 0 })).then((c) => {
|
|
88
|
+
const [f, u] = V(c);
|
|
89
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), X in s && typeof s[X] == "function" && s[X]());
|
|
90
90
|
}).catch((c) => {
|
|
91
|
-
const [f, u] =
|
|
91
|
+
const [f, u] = V({
|
|
92
92
|
value: new TypeError("Unserializable return value"),
|
|
93
|
-
[
|
|
93
|
+
[_]: 0
|
|
94
94
|
});
|
|
95
95
|
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
96
96
|
});
|
|
@@ -115,79 +115,79 @@ 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 H(s) {
|
|
121
121
|
if (s)
|
|
122
122
|
throw new Error("Proxy has been released and is not useable");
|
|
123
123
|
}
|
|
124
124
|
function At(s) {
|
|
125
|
-
return
|
|
125
|
+
return F(s, /* @__PURE__ */ new Map(), {
|
|
126
126
|
type: "RELEASE"
|
|
127
127
|
}).then(() => {
|
|
128
128
|
vt(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 && At(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 (H(r), a === Wt)
|
|
148
148
|
return () => {
|
|
149
149
|
Vt(i), At(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 l =
|
|
154
|
+
const l = F(s, t, {
|
|
155
155
|
type: "GET",
|
|
156
156
|
path: e.map((h) => h.toString())
|
|
157
157
|
}).then(C);
|
|
158
158
|
return l.then.bind(l);
|
|
159
159
|
}
|
|
160
|
-
return
|
|
160
|
+
return st(s, t, [...e, a]);
|
|
161
161
|
},
|
|
162
162
|
set(o, a, l) {
|
|
163
|
-
|
|
164
|
-
const [h, c] =
|
|
165
|
-
return
|
|
163
|
+
H(r);
|
|
164
|
+
const [h, c] = V(l);
|
|
165
|
+
return F(s, t, {
|
|
166
166
|
type: "SET",
|
|
167
167
|
path: [...e, a].map((f) => f.toString()),
|
|
168
168
|
value: h
|
|
169
169
|
}, c).then(C);
|
|
170
170
|
},
|
|
171
171
|
apply(o, a, l) {
|
|
172
|
-
|
|
172
|
+
H(r);
|
|
173
173
|
const h = e[e.length - 1];
|
|
174
174
|
if (h === Ht)
|
|
175
|
-
return
|
|
175
|
+
return F(s, t, {
|
|
176
176
|
type: "ENDPOINT"
|
|
177
177
|
}).then(C);
|
|
178
178
|
if (h === "bind")
|
|
179
|
-
return
|
|
179
|
+
return st(s, t, e.slice(0, -1));
|
|
180
180
|
const [c, f] = ht(l);
|
|
181
|
-
return
|
|
181
|
+
return F(s, t, {
|
|
182
182
|
type: "APPLY",
|
|
183
183
|
path: e.map((u) => u.toString()),
|
|
184
184
|
argumentList: c
|
|
185
185
|
}, f).then(C);
|
|
186
186
|
},
|
|
187
187
|
construct(o, a) {
|
|
188
|
-
|
|
188
|
+
H(r);
|
|
189
189
|
const [l, h] = ht(a);
|
|
190
|
-
return
|
|
190
|
+
return F(s, t, {
|
|
191
191
|
type: "CONSTRUCT",
|
|
192
192
|
path: e.map((c) => c.toString()),
|
|
193
193
|
argumentList: l
|
|
@@ -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 U(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);
|
|
@@ -239,7 +239,7 @@ function C(s) {
|
|
|
239
239
|
return s.value;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function F(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);
|
|
@@ -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 R 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 W(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 v(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 R(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,7 +408,7 @@ 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
414
|
const Ft = (s, t, e) => {
|
|
@@ -441,12 +441,12 @@ const Ft = (s, t, e) => {
|
|
|
441
441
|
n.length && o !== void 0 && (a = [i, o]);
|
|
442
442
|
}
|
|
443
443
|
return a;
|
|
444
|
-
}, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0",
|
|
445
|
-
function
|
|
444
|
+
}, $t = "\\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($t, "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, $t).replace(fe, Mt).replace(de, at).replace(pe,
|
|
449
|
+
return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
|
|
450
450
|
}
|
|
451
451
|
function me(s) {
|
|
452
452
|
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
@@ -463,7 +463,7 @@ function Rt(s) {
|
|
|
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
465
|
function ye(s) {
|
|
466
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)),
|
|
466
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), k(we(s), !0).map(me)) : [];
|
|
467
467
|
}
|
|
468
468
|
function Ee(s) {
|
|
469
469
|
return "{" + s + "}";
|
|
@@ -477,11 +477,11 @@ function xe(s, t) {
|
|
|
477
477
|
function be(s, t) {
|
|
478
478
|
return s >= t;
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function k(s, t) {
|
|
481
481
|
const e = [], n = Ft("{", "}", 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 ? k(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];
|
|
@@ -490,28 +490,28 @@ function I(s, t) {
|
|
|
490
490
|
else {
|
|
491
491
|
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
|
|
492
492
|
if (!l && !h)
|
|
493
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post,
|
|
493
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, k(s)) : [s];
|
|
494
494
|
let c;
|
|
495
495
|
if (l)
|
|
496
496
|
c = n.body.split(/\\.\\./);
|
|
497
|
-
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c =
|
|
497
|
+
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = k(c[0], !1).map(Ee), c.length === 1))
|
|
498
498
|
return i.map((u) => n.pre + c[0] + u);
|
|
499
499
|
let f;
|
|
500
500
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
501
|
-
const u =
|
|
502
|
-
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(
|
|
501
|
+
const u = K(c[0]), d = K(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
502
|
+
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(K(c[2])) : 1, S = xe;
|
|
503
503
|
d < u && (p *= -1, S = be);
|
|
504
|
-
const
|
|
504
|
+
const M = c.some(Se);
|
|
505
505
|
f = [];
|
|
506
506
|
for (let x = u; S(x, d); x += p) {
|
|
507
507
|
let m;
|
|
508
508
|
if (a)
|
|
509
509
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
510
|
-
else if (m = String(x),
|
|
510
|
+
else if (m = String(x), M) {
|
|
511
511
|
const T = g - m.length;
|
|
512
512
|
if (T > 0) {
|
|
513
|
-
const
|
|
514
|
-
x < 0 ? m = "-" +
|
|
513
|
+
const z = new Array(T + 1).join("0");
|
|
514
|
+
x < 0 ? m = "-" + z + m.slice(1) : m = z + m;
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
f.push(m);
|
|
@@ -519,7 +519,7 @@ function I(s, t) {
|
|
|
519
519
|
} else {
|
|
520
520
|
f = [];
|
|
521
521
|
for (let u = 0; u < c.length; u++)
|
|
522
|
-
f.push.apply(f,
|
|
522
|
+
f.push.apply(f, k(c[u], !1));
|
|
523
523
|
}
|
|
524
524
|
for (let u = 0; u < f.length; u++)
|
|
525
525
|
for (let d = 0; d < i.length; d++) {
|
|
@@ -529,7 +529,7 @@ function I(s, t) {
|
|
|
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,7 +549,7 @@ 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, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
|
|
553
553
|
const e = t;
|
|
554
554
|
if (s.charAt(e) !== "[")
|
|
555
555
|
throw new Error("not in a brace expression");
|
|
@@ -570,27 +570,27 @@ const Oe = 1024 * 64, Z = (s) => {
|
|
|
570
570
|
continue;
|
|
571
571
|
}
|
|
572
572
|
if (p === "[" && !l) {
|
|
573
|
-
for (const [S, [
|
|
573
|
+
for (const [S, [A, 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(A) : n.push(A), a = a || M;
|
|
578
578
|
continue t;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
if (l = !1, f) {
|
|
582
|
-
p > f ? n.push(
|
|
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
595
|
if (c < i)
|
|
596
596
|
return ["", !1, 0, !1];
|
|
@@ -602,7 +602,7 @@ const Oe = 1024 * 64, Z = (s) => {
|
|
|
602
602
|
}
|
|
603
603
|
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
604
604
|
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
605
|
-
},
|
|
605
|
+
}, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
606
606
|
class E {
|
|
607
607
|
type;
|
|
608
608
|
#s;
|
|
@@ -855,8 +855,8 @@ class E {
|
|
|
855
855
|
const e = t ?? !!this.#r.dot;
|
|
856
856
|
if (this.#s === this && this.#d(), !this.type) {
|
|
857
857
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
858
|
-
const [g, p, S,
|
|
859
|
-
return this.#n = this.#n || S, this.#i = this.#i ||
|
|
858
|
+
const [g, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
859
|
+
return this.#n = this.#n || S, this.#i = this.#i || A, g;
|
|
860
860
|
}).join("");
|
|
861
861
|
let c = "";
|
|
862
862
|
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
|
|
@@ -866,12 +866,12 @@ class E {
|
|
|
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
|
-
c = p ? Ce : S ?
|
|
869
|
+
c = p ? Ce : S ? j : "";
|
|
870
870
|
}
|
|
871
871
|
let f = "";
|
|
872
872
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
873
873
|
c + h + f,
|
|
874
|
-
|
|
874
|
+
I(h),
|
|
875
875
|
this.#n = !!this.#n,
|
|
876
876
|
this.#i
|
|
877
877
|
];
|
|
@@ -880,23 +880,23 @@ class E {
|
|
|
880
880
|
let i = this.#f(e);
|
|
881
881
|
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
882
882
|
const l = this.toString();
|
|
883
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
883
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, I(this.toString()), !1, !1];
|
|
884
884
|
}
|
|
885
|
-
let o = !n || t || e || !
|
|
885
|
+
let o = !n || t || e || !j ? "" : 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 ? j : "") + wt;
|
|
890
890
|
else {
|
|
891
891
|
const l = this.type === "!" ? (
|
|
892
892
|
// !() must match something,but !(x) can match ''
|
|
893
|
-
"))" + (this.isStart() && !e && !t ?
|
|
893
|
+
"))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
|
|
894
894
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
895
895
|
a = r + i + l;
|
|
896
896
|
}
|
|
897
897
|
return [
|
|
898
898
|
a,
|
|
899
|
-
|
|
899
|
+
I(i),
|
|
900
900
|
this.#n = !!this.#n,
|
|
901
901
|
this.#i
|
|
902
902
|
];
|
|
@@ -936,27 +936,27 @@ class E {
|
|
|
936
936
|
i += ct, e = !0;
|
|
937
937
|
continue;
|
|
938
938
|
}
|
|
939
|
-
i +=
|
|
939
|
+
i += Te(l);
|
|
940
940
|
}
|
|
941
|
-
return [i,
|
|
941
|
+
return [i, I(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, "\\\\$&"), y = (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), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, 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
|
}, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
@@ -1003,17 +1003,17 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
|
1003
1003
|
});
|
|
1004
1004
|
};
|
|
1005
1005
|
y.defaults = rs;
|
|
1006
|
-
const zt = (s, t = {}) => (
|
|
1006
|
+
const zt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
|
|
1007
1007
|
y.braceExpand = zt;
|
|
1008
|
-
const is = (s, t = {}) => new
|
|
1008
|
+
const is = (s, t = {}) => new Z(s, t).makeRe();
|
|
1009
1009
|
y.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
1014
|
y.match = os;
|
|
1015
1015
|
const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1016
|
-
class
|
|
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 || Lt, 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)
|
|
@@ -1240,10 +1240,10 @@ 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]),
|
|
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]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = M ? 3 : A ? 0 : void 0;
|
|
1244
1244
|
if (typeof x == "number" && typeof m == "number") {
|
|
1245
|
-
const [T,
|
|
1246
|
-
T.toLowerCase() ===
|
|
1245
|
+
const [T, z] = [t[x], e[m]];
|
|
1246
|
+
T.toLowerCase() === z.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
const { optimizationLevel: i = 1 } = this.options;
|
|
@@ -1292,14 +1292,14 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1292
1292
|
return zt(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
1298
|
return O;
|
|
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 ? ze : Le : e.dot ?
|
|
1302
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : 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(He)) ? 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
|
}
|
|
@@ -1364,9 +1364,9 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
y.AST = E;
|
|
1367
|
-
y.Minimatch =
|
|
1368
|
-
y.escape =
|
|
1369
|
-
y.unescape =
|
|
1367
|
+
y.Minimatch = Z;
|
|
1368
|
+
y.escape = Pe;
|
|
1369
|
+
y.unescape = I;
|
|
1370
1370
|
function cs() {
|
|
1371
1371
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1372
1372
|
throw new Qt();
|
|
@@ -1374,34 +1374,34 @@ function cs() {
|
|
|
1374
1374
|
async function L(s, t, e) {
|
|
1375
1375
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1377
|
+
function $(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 = $(s);
|
|
1385
1385
|
return t[t.length - 1] || "";
|
|
1386
1386
|
}
|
|
1387
|
-
function
|
|
1388
|
-
const t =
|
|
1387
|
+
function tt(s) {
|
|
1388
|
+
const t = $(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
|
|
1397
|
+
function et(s, t) {
|
|
1398
1398
|
return y(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 = $(t), n = [];
|
|
1405
1405
|
for (const r of e)
|
|
1406
1406
|
if (!(r === "." || r === ""))
|
|
1407
1407
|
if (r === "..") {
|
|
@@ -1429,10 +1429,14 @@ async function fs(s, t, e = {}) {
|
|
|
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 v(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 v(e, { path: t, isDirectory: !1 });
|
|
1467
1471
|
}
|
|
1468
1472
|
}
|
|
1469
1473
|
class gs {
|
|
@@ -1503,14 +1507,13 @@ class gs {
|
|
|
1503
1507
|
* This method is called by internal operations to notify clients about
|
|
1504
1508
|
* changes, even when no specific paths are being watched.
|
|
1505
1509
|
*
|
|
1506
|
-
* @param
|
|
1507
|
-
* @param type - The type of change (create, change, delete)
|
|
1510
|
+
* @param event - The event describing the change
|
|
1508
1511
|
*/
|
|
1509
1512
|
async notifyChange(t) {
|
|
1510
1513
|
if (!this.options.broadcastChannel)
|
|
1511
1514
|
return;
|
|
1512
1515
|
const e = t.path;
|
|
1513
|
-
if (![...this.watchers.values()].some((i) =>
|
|
1516
|
+
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
1517
|
return;
|
|
1515
1518
|
let r;
|
|
1516
1519
|
if (this.options.hashAlgorithm)
|
|
@@ -1550,7 +1553,6 @@ class gs {
|
|
|
1550
1553
|
* This method sets up the root directory for all subsequent operations.
|
|
1551
1554
|
* If no root is specified, it will use the OPFS root directory.
|
|
1552
1555
|
*
|
|
1553
|
-
* @param root - The root path for the file system (default: '/')
|
|
1554
1556
|
* @returns Promise that resolves to true if initialization was successful
|
|
1555
1557
|
* @throws {OPFSError} If initialization fails
|
|
1556
1558
|
*
|
|
@@ -1589,7 +1591,7 @@ class gs {
|
|
|
1589
1591
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1590
1592
|
*/
|
|
1591
1593
|
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 =
|
|
1594
|
+
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
1595
|
}
|
|
1594
1596
|
/**
|
|
1595
1597
|
* Get a directory handle from a path
|
|
@@ -1610,7 +1612,7 @@ class gs {
|
|
|
1610
1612
|
* \`\`\`
|
|
1611
1613
|
*/
|
|
1612
1614
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1613
|
-
const r = Array.isArray(t) ? t :
|
|
1615
|
+
const r = Array.isArray(t) ? t : $(t);
|
|
1614
1616
|
let i = n;
|
|
1615
1617
|
for (const o of r)
|
|
1616
1618
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
@@ -1636,7 +1638,7 @@ class gs {
|
|
|
1636
1638
|
* \`\`\`
|
|
1637
1639
|
*/
|
|
1638
1640
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1639
|
-
const r =
|
|
1641
|
+
const r = $(t);
|
|
1640
1642
|
if (r.length === 0)
|
|
1641
1643
|
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1642
1644
|
const i = r.pop();
|
|
@@ -1709,13 +1711,13 @@ class gs {
|
|
|
1709
1711
|
const e = await this.open(t);
|
|
1710
1712
|
try {
|
|
1711
1713
|
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1712
|
-
return n > 0 && await this.read(e, r, 0, n, 0),
|
|
1714
|
+
return n > 0 && await this.read(e, r, 0, n, 0), U(r, [r.buffer]);
|
|
1713
1715
|
} finally {
|
|
1714
1716
|
await this.close(e);
|
|
1715
1717
|
}
|
|
1716
1718
|
});
|
|
1717
1719
|
} catch (e) {
|
|
1718
|
-
throw new
|
|
1720
|
+
throw new R("file", t, e);
|
|
1719
1721
|
}
|
|
1720
1722
|
}
|
|
1721
1723
|
/**
|
|
@@ -1812,14 +1814,17 @@ class gs {
|
|
|
1812
1814
|
*/
|
|
1813
1815
|
async mkdir(t, e) {
|
|
1814
1816
|
await this.mount();
|
|
1815
|
-
const n = e?.recursive ?? !1, r =
|
|
1817
|
+
const n = e?.recursive ?? !1, r = $(t);
|
|
1816
1818
|
let i = this.root;
|
|
1817
1819
|
for (let o = 0; o < r.length; o++) {
|
|
1818
1820
|
const a = r[o];
|
|
1819
1821
|
try {
|
|
1820
1822
|
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1821
1823
|
} catch (l) {
|
|
1822
|
-
throw l.name === "NotFoundError" ?
|
|
1824
|
+
throw l.name === "NotFoundError" ? v(l, {
|
|
1825
|
+
path: lt(r.slice(0, o + 1)),
|
|
1826
|
+
existenceType: "directory"
|
|
1827
|
+
}) : l.name === "TypeMismatchError" ? v(l, { path: a, isDirectory: !1 }) : new J("create directory", a, l);
|
|
1823
1828
|
}
|
|
1824
1829
|
}
|
|
1825
1830
|
await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
|
|
@@ -1859,7 +1864,7 @@ class gs {
|
|
|
1859
1864
|
const e = it(t);
|
|
1860
1865
|
let n;
|
|
1861
1866
|
try {
|
|
1862
|
-
n = await this.getDirectoryHandle(
|
|
1867
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1863
1868
|
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1864
1869
|
kind: "file",
|
|
1865
1870
|
size: o.size,
|
|
@@ -1880,9 +1885,9 @@ class gs {
|
|
|
1880
1885
|
return a;
|
|
1881
1886
|
} catch (r) {
|
|
1882
1887
|
if (r.name === "NotFoundError")
|
|
1883
|
-
throw new
|
|
1888
|
+
throw new R("file", t, r);
|
|
1884
1889
|
if (r.name !== "TypeMismatchError")
|
|
1885
|
-
throw new
|
|
1890
|
+
throw new J("stat", t, r);
|
|
1886
1891
|
}
|
|
1887
1892
|
try {
|
|
1888
1893
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1894,7 +1899,7 @@ class gs {
|
|
|
1894
1899
|
isDirectory: !0
|
|
1895
1900
|
};
|
|
1896
1901
|
} catch (r) {
|
|
1897
|
-
throw new
|
|
1902
|
+
throw new J("stat", t, r);
|
|
1898
1903
|
}
|
|
1899
1904
|
}
|
|
1900
1905
|
/**
|
|
@@ -1949,7 +1954,7 @@ class gs {
|
|
|
1949
1954
|
const e = it(t);
|
|
1950
1955
|
let n = null;
|
|
1951
1956
|
try {
|
|
1952
|
-
n = await this.getDirectoryHandle(
|
|
1957
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1953
1958
|
} catch (r) {
|
|
1954
1959
|
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1955
1960
|
throw r;
|
|
@@ -1999,7 +2004,7 @@ class gs {
|
|
|
1999
2004
|
}
|
|
2000
2005
|
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
|
|
2001
2006
|
} catch (e) {
|
|
2002
|
-
throw e instanceof w ? e :
|
|
2007
|
+
throw e instanceof w ? e : v(e, { path: t, isDirectory: !0 });
|
|
2003
2008
|
}
|
|
2004
2009
|
}
|
|
2005
2010
|
/**
|
|
@@ -2029,7 +2034,7 @@ class gs {
|
|
|
2029
2034
|
async remove(t, e) {
|
|
2030
2035
|
if (await this.mount(), t === "/")
|
|
2031
2036
|
throw new rt("EROOT", t);
|
|
2032
|
-
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(
|
|
2037
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
|
|
2033
2038
|
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
|
|
2034
2039
|
}
|
|
2035
2040
|
/**
|
|
@@ -2055,10 +2060,10 @@ class gs {
|
|
|
2055
2060
|
try {
|
|
2056
2061
|
const e = Et(t);
|
|
2057
2062
|
if (!await this.exists(e))
|
|
2058
|
-
throw new
|
|
2063
|
+
throw new R("file", e);
|
|
2059
2064
|
return e;
|
|
2060
2065
|
} catch (e) {
|
|
2061
|
-
throw e instanceof w ? e :
|
|
2066
|
+
throw e instanceof w ? e : v(e, { path: t });
|
|
2062
2067
|
}
|
|
2063
2068
|
}
|
|
2064
2069
|
/**
|
|
@@ -2088,10 +2093,10 @@ class gs {
|
|
|
2088
2093
|
try {
|
|
2089
2094
|
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2090
2095
|
if (await this.exists(e) && !r)
|
|
2091
|
-
throw new
|
|
2096
|
+
throw new Q(e);
|
|
2092
2097
|
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
|
|
2093
2098
|
} catch (r) {
|
|
2094
|
-
throw r instanceof w ? r :
|
|
2099
|
+
throw r instanceof w ? r : v(r, { path: t });
|
|
2095
2100
|
}
|
|
2096
2101
|
}
|
|
2097
2102
|
/**
|
|
@@ -2124,15 +2129,15 @@ class gs {
|
|
|
2124
2129
|
try {
|
|
2125
2130
|
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2126
2131
|
if (!await this.exists(t))
|
|
2127
|
-
throw new
|
|
2132
|
+
throw new R("source", t);
|
|
2128
2133
|
if (await this.exists(e) && !i)
|
|
2129
|
-
throw new
|
|
2134
|
+
throw new Q(e);
|
|
2130
2135
|
if ((await this.stat(t)).isFile) {
|
|
2131
2136
|
const h = await this.readFile(t);
|
|
2132
2137
|
await this.writeFile(e, h);
|
|
2133
2138
|
} else {
|
|
2134
2139
|
if (!r)
|
|
2135
|
-
throw new
|
|
2140
|
+
throw new nt("directory", t);
|
|
2136
2141
|
await this.mkdir(e, { recursive: !0 });
|
|
2137
2142
|
const h = await this.readDir(t);
|
|
2138
2143
|
for (const c of h) {
|
|
@@ -2141,7 +2146,7 @@ class gs {
|
|
|
2141
2146
|
}
|
|
2142
2147
|
}
|
|
2143
2148
|
} catch (r) {
|
|
2144
|
-
throw r instanceof w ? r :
|
|
2149
|
+
throw r instanceof w ? r : v(r, { path: t });
|
|
2145
2150
|
}
|
|
2146
2151
|
}
|
|
2147
2152
|
/**
|
|
@@ -2214,15 +2219,21 @@ class gs {
|
|
|
2214
2219
|
*/
|
|
2215
2220
|
async open(t, e) {
|
|
2216
2221
|
await this.mount();
|
|
2217
|
-
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o =
|
|
2222
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
|
|
2218
2223
|
try {
|
|
2219
2224
|
return n && r ? await L(o, "exclusive", async () => {
|
|
2220
2225
|
if (await this.exists(o))
|
|
2221
|
-
throw new
|
|
2226
|
+
throw new Q(o);
|
|
2222
2227
|
return this._openFile(o, n, i);
|
|
2223
2228
|
}) : await this._openFile(o, n, i);
|
|
2224
2229
|
} catch (a) {
|
|
2225
|
-
|
|
2230
|
+
if (a instanceof w)
|
|
2231
|
+
throw a;
|
|
2232
|
+
const l = a && a.name === "TypeMismatchError";
|
|
2233
|
+
throw v(a, {
|
|
2234
|
+
path: o,
|
|
2235
|
+
isDirectory: !!l
|
|
2236
|
+
});
|
|
2226
2237
|
}
|
|
2227
2238
|
}
|
|
2228
2239
|
/**
|
|
@@ -2234,7 +2245,7 @@ class gs {
|
|
|
2234
2245
|
try {
|
|
2235
2246
|
await r.getFile();
|
|
2236
2247
|
} catch (a) {
|
|
2237
|
-
throw
|
|
2248
|
+
throw v(a, { path: t, isDirectory: !0 });
|
|
2238
2249
|
}
|
|
2239
2250
|
const i = await ps(r, t);
|
|
2240
2251
|
n && (i.truncate(0), i.flush());
|
|
@@ -2294,11 +2305,11 @@ class gs {
|
|
|
2294
2305
|
try {
|
|
2295
2306
|
const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
|
|
2296
2307
|
if (h)
|
|
2297
|
-
return
|
|
2308
|
+
return U({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2298
2309
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2299
|
-
return i == null && (o.position = a + u),
|
|
2310
|
+
return i == null && (o.position = a + u), U({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2300
2311
|
} catch (a) {
|
|
2301
|
-
throw
|
|
2312
|
+
throw W("read", t, o.path, a);
|
|
2302
2313
|
}
|
|
2303
2314
|
}
|
|
2304
2315
|
/**
|
|
@@ -2329,7 +2340,7 @@ class gs {
|
|
|
2329
2340
|
const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2330
2341
|
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
|
|
2331
2342
|
} catch (h) {
|
|
2332
|
-
throw
|
|
2343
|
+
throw W("write", t, a.path, h);
|
|
2333
2344
|
}
|
|
2334
2345
|
}
|
|
2335
2346
|
/**
|
|
@@ -2377,7 +2388,7 @@ class gs {
|
|
|
2377
2388
|
try {
|
|
2378
2389
|
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
|
|
2379
2390
|
} catch (r) {
|
|
2380
|
-
throw
|
|
2391
|
+
throw W("truncate", t, n.path, r);
|
|
2381
2392
|
}
|
|
2382
2393
|
}
|
|
2383
2394
|
/**
|
|
@@ -2399,7 +2410,7 @@ class gs {
|
|
|
2399
2410
|
try {
|
|
2400
2411
|
e.syncHandle.flush();
|
|
2401
2412
|
} catch (n) {
|
|
2402
|
-
throw
|
|
2413
|
+
throw W("sync", t, e.path, n);
|
|
2403
2414
|
}
|
|
2404
2415
|
}
|
|
2405
2416
|
/**
|
|
@@ -2421,8 +2432,6 @@ class gs {
|
|
|
2421
2432
|
* This is useful for importing data from external sources or syncing with remote data.
|
|
2422
2433
|
*
|
|
2423
2434
|
* @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
2435
|
* @returns Promise that resolves when synchronization is complete
|
|
2427
2436
|
* @throws {OPFSError} If the synchronization fails
|
|
2428
2437
|
*
|
|
@@ -2446,17 +2455,17 @@ class gs {
|
|
|
2446
2455
|
await this.mount();
|
|
2447
2456
|
try {
|
|
2448
2457
|
for (const [e, n] of t) {
|
|
2449
|
-
const r =
|
|
2458
|
+
const r = B(e);
|
|
2450
2459
|
let i;
|
|
2451
2460
|
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2452
2461
|
}
|
|
2453
2462
|
} catch (e) {
|
|
2454
|
-
throw e instanceof w ? e :
|
|
2463
|
+
throw e instanceof w ? e : v(e);
|
|
2455
2464
|
}
|
|
2456
2465
|
}
|
|
2457
2466
|
}
|
|
2458
2467
|
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
|
|
2459
|
-
//# sourceMappingURL=worker-
|
|
2468
|
+
//# sourceMappingURL=worker-DYYLzR1Y.js.map
|
|
2460
2469
|
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2461
2470
|
function m(a) {
|
|
2462
2471
|
let n;
|
|
@@ -2484,9 +2493,10 @@ function i(a) {
|
|
|
2484
2493
|
}
|
|
2485
2494
|
class y {
|
|
2486
2495
|
#n;
|
|
2496
|
+
#t;
|
|
2487
2497
|
promises = this;
|
|
2488
2498
|
constructor(n) {
|
|
2489
|
-
this.#
|
|
2499
|
+
this.#t = new m(), this.#n = u(this.#t), n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
|
|
2490
2500
|
}
|
|
2491
2501
|
/**
|
|
2492
2502
|
* Start watching a file or directory for changes
|
|
@@ -2696,12 +2706,6 @@ class y {
|
|
|
2696
2706
|
async fsync(n) {
|
|
2697
2707
|
return this.#n.fsync(n);
|
|
2698
2708
|
}
|
|
2699
|
-
/**
|
|
2700
|
-
* Dispose of resources and clean up the file system instance
|
|
2701
|
-
*/
|
|
2702
|
-
dispose() {
|
|
2703
|
-
this.#n.dispose();
|
|
2704
|
-
}
|
|
2705
2709
|
/**
|
|
2706
2710
|
* Synchronize the file system with external data
|
|
2707
2711
|
*/
|
|
@@ -2730,6 +2734,19 @@ class y {
|
|
|
2730
2734
|
const r = i(n), s = c(t, e);
|
|
2731
2735
|
return this.#n.appendFile(r, s);
|
|
2732
2736
|
}
|
|
2737
|
+
/**
|
|
2738
|
+
* Dispose of resources, detach the worker and clean up the file system instance
|
|
2739
|
+
*/
|
|
2740
|
+
dispose() {
|
|
2741
|
+
const n = this.#n, t = this.#t;
|
|
2742
|
+
(async () => {
|
|
2743
|
+
try {
|
|
2744
|
+
await n.dispose();
|
|
2745
|
+
} finally {
|
|
2746
|
+
t.terminate();
|
|
2747
|
+
}
|
|
2748
|
+
})();
|
|
2749
|
+
}
|
|
2733
2750
|
}
|
|
2734
2751
|
function b(a) {
|
|
2735
2752
|
return new y(a);
|
|
@@ -2746,12 +2763,12 @@ export {
|
|
|
2746
2763
|
C as InitializationFailedError,
|
|
2747
2764
|
I as OPFSError,
|
|
2748
2765
|
y as OPFSFileSystem,
|
|
2749
|
-
|
|
2750
|
-
|
|
2766
|
+
D as OPFSNotSupportedError,
|
|
2767
|
+
$ as OperationAbortedError,
|
|
2751
2768
|
_ as OperationNotSupportedError,
|
|
2752
2769
|
N as PathError,
|
|
2753
|
-
|
|
2754
|
-
|
|
2770
|
+
k as PermissionError,
|
|
2771
|
+
z as StorageError,
|
|
2755
2772
|
M as ValidationError,
|
|
2756
2773
|
j as WatchEventType,
|
|
2757
2774
|
L as basename,
|
|
@@ -2760,16 +2777,16 @@ export {
|
|
|
2760
2777
|
H as calculateReadLength,
|
|
2761
2778
|
B as checkOPFSSupport,
|
|
2762
2779
|
G as convertBlobToUint8Array,
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2780
|
+
Y as createBuffer,
|
|
2781
|
+
q as createFDError,
|
|
2782
|
+
V as createSyncHandleSafe,
|
|
2766
2783
|
b as createWorker,
|
|
2767
2784
|
l as decodeBuffer,
|
|
2768
|
-
|
|
2785
|
+
Z as dirname,
|
|
2769
2786
|
c as encodeString,
|
|
2770
|
-
|
|
2787
|
+
J as extname,
|
|
2771
2788
|
h as isBinaryFileExtension,
|
|
2772
|
-
|
|
2789
|
+
X as isPathExcluded,
|
|
2773
2790
|
K as joinPath,
|
|
2774
2791
|
Q as mapDomError,
|
|
2775
2792
|
nn as matchMinimatch,
|