opfs-worker 0.5.1 → 1.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/dist/assets/worker-XHCzp1qX.js.map +1 -0
- package/dist/{helpers-DcIl7KL0.js → helpers-CTCvNFs1.js} +42 -42
- package/dist/{helpers-DcIl7KL0.js.map → helpers-CTCvNFs1.js.map} +1 -1
- package/dist/{helpers-BfBe8lFJ.cjs → helpers-Cvjm0f_r.cjs} +3 -3
- package/dist/{helpers-BfBe8lFJ.cjs.map → helpers-Cvjm0f_r.cjs.map} +1 -1
- package/dist/index.cjs +93 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +97 -87
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +97 -87
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/encoder.d.ts +2 -1
- package/dist/utils/encoder.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts +14 -7
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-DYhMhDRt.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),n=require("./helpers-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),n=require("./helpers-Cvjm0f_r.cjs"),i=`/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol("Comlink.releaseProxy"), U = Symbol("Comlink.finalizer"), L = Symbol("Comlink.thrown"), ft = (s) => typeof s == "object" && s !== null || typeof s == "function",
|
|
6
|
+
const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol("Comlink.releaseProxy"), U = Symbol("Comlink.finalizer"), L = Symbol("Comlink.thrown"), ft = (s) => typeof s == "object" && s !== null || typeof s == "function", Tt = {
|
|
7
7
|
canHandle: (s) => ft(s) && s[ut],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
@@ -12,7 +12,7 @@ const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol
|
|
|
12
12
|
deserialize(s) {
|
|
13
13
|
return s.start(), Pt(s);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
15
|
+
}, Ft = {
|
|
16
16
|
canHandle: (s) => ft(s) && L in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
@@ -29,8 +29,8 @@ const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol
|
|
|
29
29
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
30
30
|
}
|
|
31
31
|
}, dt = /* @__PURE__ */ new Map([
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
32
|
+
["proxy", Tt],
|
|
33
|
+
["throw", Ft]
|
|
34
34
|
]);
|
|
35
35
|
function Mt(s, t) {
|
|
36
36
|
for (const e of s)
|
|
@@ -296,13 +296,12 @@ function _t(s, t = "utf-8") {
|
|
|
296
296
|
case "utf-8":
|
|
297
297
|
return new TextDecoder().decode(s);
|
|
298
298
|
case "utf16le":
|
|
299
|
+
case "utf-16le":
|
|
299
300
|
case "ucs2":
|
|
300
301
|
case "ucs-2":
|
|
301
302
|
return Gt(s);
|
|
302
303
|
case "latin1":
|
|
303
304
|
return String.fromCharCode(...s);
|
|
304
|
-
case "binary":
|
|
305
|
-
return String.fromCharCode(...s);
|
|
306
305
|
case "ascii":
|
|
307
306
|
return String.fromCharCode(...s.map((e) => e & 127));
|
|
308
307
|
case "base64":
|
|
@@ -368,17 +367,17 @@ const wt = (s, t, e) => {
|
|
|
368
367
|
n.length && o !== void 0 && (a = [r, o]);
|
|
369
368
|
}
|
|
370
369
|
return a;
|
|
371
|
-
}, yt = "\\0SLASH" + Math.random() + "\\0", Et = "\\0OPEN" + Math.random() + "\\0", K = "\\0CLOSE" + Math.random() + "\\0", St = "\\0COMMA" + Math.random() + "\\0",
|
|
370
|
+
}, yt = "\\0SLASH" + Math.random() + "\\0", Et = "\\0OPEN" + Math.random() + "\\0", K = "\\0CLOSE" + Math.random() + "\\0", St = "\\0COMMA" + Math.random() + "\\0", xt = "\\0PERIOD" + Math.random() + "\\0", Yt = new RegExp(yt, "g"), Zt = new RegExp(Et, "g"), Jt = new RegExp(K, "g"), Kt = new RegExp(St, "g"), Qt = new RegExp(xt, "g"), te = /\\\\\\\\/g, ee = /\\\\{/g, se = /\\\\}/g, ne = /\\\\,/g, ie = /\\\\./g;
|
|
372
371
|
function B(s) {
|
|
373
372
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
374
373
|
}
|
|
375
374
|
function re(s) {
|
|
376
|
-
return s.replace(te, yt).replace(ee, Et).replace(se, K).replace(ne, St).replace(ie,
|
|
375
|
+
return s.replace(te, yt).replace(ee, Et).replace(se, K).replace(ne, St).replace(ie, xt);
|
|
377
376
|
}
|
|
378
377
|
function oe(s) {
|
|
379
378
|
return s.replace(Yt, "\\\\").replace(Zt, "{").replace(Jt, "}").replace(Kt, ",").replace(Qt, ".");
|
|
380
379
|
}
|
|
381
|
-
function
|
|
380
|
+
function bt(s) {
|
|
382
381
|
if (!s)
|
|
383
382
|
return [""];
|
|
384
383
|
const t = [], e = wt("{", "}", s);
|
|
@@ -386,7 +385,7 @@ function xt(s) {
|
|
|
386
385
|
return s.split(",");
|
|
387
386
|
const { pre: n, body: i, post: r } = e, o = n.split(",");
|
|
388
387
|
o[o.length - 1] += "{" + i + "}";
|
|
389
|
-
const a =
|
|
388
|
+
const a = bt(r);
|
|
390
389
|
return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
391
390
|
}
|
|
392
391
|
function ae(s) {
|
|
@@ -421,7 +420,7 @@ function M(s, t) {
|
|
|
421
420
|
let c;
|
|
422
421
|
if (l)
|
|
423
422
|
c = n.body.split(/\\.\\./);
|
|
424
|
-
else if (c =
|
|
423
|
+
else if (c = bt(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(ce), c.length === 1))
|
|
425
424
|
return r.map((u) => n.pre + c[0] + u);
|
|
426
425
|
let f;
|
|
427
426
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
@@ -430,15 +429,15 @@ function M(s, t) {
|
|
|
430
429
|
d < u && (p *= -1, S = ue);
|
|
431
430
|
const N = c.some(le);
|
|
432
431
|
f = [];
|
|
433
|
-
for (let
|
|
432
|
+
for (let x = u; S(x, d); x += p) {
|
|
434
433
|
let w;
|
|
435
434
|
if (a)
|
|
436
|
-
w = String.fromCharCode(
|
|
437
|
-
else if (w = String(
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
const P = new Array(
|
|
441
|
-
|
|
435
|
+
w = String.fromCharCode(x), w === "\\\\" && (w = "");
|
|
436
|
+
else if (w = String(x), N) {
|
|
437
|
+
const T = m - w.length;
|
|
438
|
+
if (T > 0) {
|
|
439
|
+
const P = new Array(T + 1).join("0");
|
|
440
|
+
x < 0 ? w = "-" + P + w.slice(1) : w = P + w;
|
|
442
441
|
}
|
|
443
442
|
}
|
|
444
443
|
f.push(w);
|
|
@@ -476,7 +475,7 @@ const fe = 1024 * 64, W = (s) => {
|
|
|
476
475
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
477
476
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
478
477
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
479
|
-
},
|
|
478
|
+
}, F = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), it = (s) => s.join(""), ge = (s, t) => {
|
|
480
479
|
const e = t;
|
|
481
480
|
if (s.charAt(e) !== "[")
|
|
482
481
|
throw new Error("not in a brace expression");
|
|
@@ -497,27 +496,27 @@ const fe = 1024 * 64, W = (s) => {
|
|
|
497
496
|
continue;
|
|
498
497
|
}
|
|
499
498
|
if (p === "[" && !l) {
|
|
500
|
-
for (const [S, [
|
|
499
|
+
for (const [S, [A, N, x]] of Object.entries(de))
|
|
501
500
|
if (s.startsWith(S, r)) {
|
|
502
501
|
if (f)
|
|
503
502
|
return ["$.", !1, s.length - e, !0];
|
|
504
|
-
r += S.length,
|
|
503
|
+
r += S.length, x ? i.push(A) : n.push(A), a = a || N;
|
|
505
504
|
continue t;
|
|
506
505
|
}
|
|
507
506
|
}
|
|
508
507
|
if (l = !1, f) {
|
|
509
|
-
p > f ? n.push(
|
|
508
|
+
p > f ? n.push(F(f) + "-" + F(p)) : p === f && n.push(F(p)), f = "", r++;
|
|
510
509
|
continue;
|
|
511
510
|
}
|
|
512
511
|
if (s.startsWith("-]", r + 1)) {
|
|
513
|
-
n.push(
|
|
512
|
+
n.push(F(p + "-")), r += 2;
|
|
514
513
|
continue;
|
|
515
514
|
}
|
|
516
515
|
if (s.startsWith("-", r + 1)) {
|
|
517
516
|
f = p, r += 2;
|
|
518
517
|
continue;
|
|
519
518
|
}
|
|
520
|
-
n.push(
|
|
519
|
+
n.push(F(p)), r++;
|
|
521
520
|
}
|
|
522
521
|
if (c < r)
|
|
523
522
|
return ["", !1, 0, !1];
|
|
@@ -529,7 +528,7 @@ const fe = 1024 * 64, W = (s) => {
|
|
|
529
528
|
}
|
|
530
529
|
const u = "[" + (h ? "^" : "") + it(n) + "]", d = "[" + (h ? "" : "^") + it(i) + "]";
|
|
531
530
|
return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
532
|
-
}, $ = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), me = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), rt = (s) => me.has(s), we = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", k = "(?!\\\\.)", ye = /* @__PURE__ */ new Set(["[", "."]), Ee = /* @__PURE__ */ new Set(["..", "."]), Se = new Set("().*{}+?[]^$\\\\!"),
|
|
531
|
+
}, $ = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), me = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), rt = (s) => me.has(s), we = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", k = "(?!\\\\.)", ye = /* @__PURE__ */ new Set(["[", "."]), Ee = /* @__PURE__ */ new Set(["..", "."]), Se = new Set("().*{}+?[]^$\\\\!"), xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), Q = "[^/]", ot = Q + "*?", at = Q + "+?";
|
|
533
532
|
class E {
|
|
534
533
|
type;
|
|
535
534
|
#s;
|
|
@@ -782,8 +781,8 @@ class E {
|
|
|
782
781
|
const e = t ?? !!this.#i.dot;
|
|
783
782
|
if (this.#s === this && this.#d(), !this.type) {
|
|
784
783
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
785
|
-
const [m, p, S,
|
|
786
|
-
return this.#n = this.#n || S, this.#r = this.#r ||
|
|
784
|
+
const [m, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
785
|
+
return this.#n = this.#n || S, this.#r = this.#r || A, m;
|
|
787
786
|
}).join("");
|
|
788
787
|
let c = "";
|
|
789
788
|
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Ee.has(this.#t[0]))) {
|
|
@@ -863,27 +862,27 @@ class E {
|
|
|
863
862
|
r += Q, e = !0;
|
|
864
863
|
continue;
|
|
865
864
|
}
|
|
866
|
-
r +=
|
|
865
|
+
r += xe(l);
|
|
867
866
|
}
|
|
868
867
|
return [r, $(t), !!e, o];
|
|
869
868
|
}
|
|
870
869
|
}
|
|
871
|
-
const
|
|
872
|
-
const e =
|
|
870
|
+
const be = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (W(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new j(t, e).match(s)), ve = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ae = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Ce = (s) => (t) => t.endsWith(s), Oe = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), De = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Ne = /^\\*+\\.\\*+$/, Te = (s) => !s.startsWith(".") && s.includes("."), Fe = (s) => s !== "." && s !== ".." && s.includes("."), Me = /^\\.\\*+$/, $e = (s) => s !== "." && s !== ".." && s.startsWith("."), Pe = /^\\*+$/, Re = (s) => s.length !== 0 && !s.startsWith("."), ke = (s) => s.length !== 0 && s !== "." && s !== "..", Le = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ie = ([s, t = ""]) => {
|
|
871
|
+
const e = vt([s]);
|
|
873
872
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
874
873
|
}, ze = ([s, t = ""]) => {
|
|
875
|
-
const e =
|
|
874
|
+
const e = At([s]);
|
|
876
875
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
877
876
|
}, He = ([s, t = ""]) => {
|
|
878
|
-
const e =
|
|
877
|
+
const e = At([s]);
|
|
879
878
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
880
879
|
}, We = ([s, t = ""]) => {
|
|
881
|
-
const e =
|
|
880
|
+
const e = vt([s]);
|
|
882
881
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
883
|
-
},
|
|
882
|
+
}, vt = ([s]) => {
|
|
884
883
|
const t = s.length;
|
|
885
884
|
return (e) => e.length === t && !e.startsWith(".");
|
|
886
|
-
},
|
|
885
|
+
}, At = ([s]) => {
|
|
887
886
|
const t = s.length;
|
|
888
887
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
889
888
|
}, Ct = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ct = {
|
|
@@ -891,42 +890,42 @@ const xe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
|
|
|
891
890
|
posix: { sep: "/" }
|
|
892
891
|
}, je = Ct === "win32" ? ct.win32.sep : ct.posix.sep;
|
|
893
892
|
y.sep = je;
|
|
894
|
-
const
|
|
895
|
-
y.GLOBSTAR =
|
|
893
|
+
const v = Symbol("globstar **");
|
|
894
|
+
y.GLOBSTAR = v;
|
|
896
895
|
const Ue = "[^/]", _e = Ue + "*?", Be = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ge = "(?:(?!(?:\\\\/|^)\\\\.).)*?", qe = (s, t = {}) => (e) => y(e, s, t);
|
|
897
896
|
y.filter = qe;
|
|
898
|
-
const
|
|
897
|
+
const b = (s, t = {}) => Object.assign({}, s, t), Ve = (s) => {
|
|
899
898
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
900
899
|
return y;
|
|
901
900
|
const t = y;
|
|
902
|
-
return Object.assign((n, i, r = {}) => t(n, i,
|
|
901
|
+
return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
|
|
903
902
|
Minimatch: class extends t.Minimatch {
|
|
904
903
|
constructor(i, r = {}) {
|
|
905
|
-
super(i,
|
|
904
|
+
super(i, b(s, r));
|
|
906
905
|
}
|
|
907
906
|
static defaults(i) {
|
|
908
|
-
return t.defaults(
|
|
907
|
+
return t.defaults(b(s, i)).Minimatch;
|
|
909
908
|
}
|
|
910
909
|
},
|
|
911
910
|
AST: class extends t.AST {
|
|
912
911
|
/* c8 ignore start */
|
|
913
912
|
constructor(i, r, o = {}) {
|
|
914
|
-
super(i, r,
|
|
913
|
+
super(i, r, b(s, o));
|
|
915
914
|
}
|
|
916
915
|
/* c8 ignore stop */
|
|
917
916
|
static fromGlob(i, r = {}) {
|
|
918
|
-
return t.AST.fromGlob(i,
|
|
917
|
+
return t.AST.fromGlob(i, b(s, r));
|
|
919
918
|
}
|
|
920
919
|
},
|
|
921
|
-
unescape: (n, i = {}) => t.unescape(n,
|
|
922
|
-
escape: (n, i = {}) => t.escape(n,
|
|
923
|
-
filter: (n, i = {}) => t.filter(n,
|
|
924
|
-
defaults: (n) => t.defaults(
|
|
925
|
-
makeRe: (n, i = {}) => t.makeRe(n,
|
|
926
|
-
braceExpand: (n, i = {}) => t.braceExpand(n,
|
|
927
|
-
match: (n, i, r = {}) => t.match(n, i,
|
|
920
|
+
unescape: (n, i = {}) => t.unescape(n, b(s, i)),
|
|
921
|
+
escape: (n, i = {}) => t.escape(n, b(s, i)),
|
|
922
|
+
filter: (n, i = {}) => t.filter(n, b(s, i)),
|
|
923
|
+
defaults: (n) => t.defaults(b(s, n)),
|
|
924
|
+
makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
|
|
925
|
+
braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
|
|
926
|
+
match: (n, i, r = {}) => t.match(n, i, b(s, r)),
|
|
928
927
|
sep: t.sep,
|
|
929
|
-
GLOBSTAR:
|
|
928
|
+
GLOBSTAR: v
|
|
930
929
|
});
|
|
931
930
|
};
|
|
932
931
|
y.defaults = Ve;
|
|
@@ -1167,10 +1166,10 @@ class j {
|
|
|
1167
1166
|
matchOne(t, e, n = !1) {
|
|
1168
1167
|
const i = this.options;
|
|
1169
1168
|
if (this.isWindows) {
|
|
1170
|
-
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]),
|
|
1171
|
-
if (typeof
|
|
1172
|
-
const [
|
|
1173
|
-
|
|
1169
|
+
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]), N = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, w = N ? 3 : A ? 0 : void 0;
|
|
1170
|
+
if (typeof x == "number" && typeof w == "number") {
|
|
1171
|
+
const [T, P] = [t[x], e[w]];
|
|
1172
|
+
T.toLowerCase() === P.toLowerCase() && (e[w] = T, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
|
|
1174
1173
|
}
|
|
1175
1174
|
}
|
|
1176
1175
|
const { optimizationLevel: r = 1 } = this.options;
|
|
@@ -1180,7 +1179,7 @@ class j {
|
|
|
1180
1179
|
var c = e[a], f = t[o];
|
|
1181
1180
|
if (this.debug(e, c, f), c === !1)
|
|
1182
1181
|
return !1;
|
|
1183
|
-
if (c ===
|
|
1182
|
+
if (c === v) {
|
|
1184
1183
|
this.debug("GLOBSTAR", [e, c, f]);
|
|
1185
1184
|
var u = o, d = a + 1;
|
|
1186
1185
|
if (d === h) {
|
|
@@ -1222,11 +1221,11 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1222
1221
|
W(t);
|
|
1223
1222
|
const e = this.options;
|
|
1224
1223
|
if (t === "**")
|
|
1225
|
-
return
|
|
1224
|
+
return v;
|
|
1226
1225
|
if (t === "")
|
|
1227
1226
|
return "";
|
|
1228
1227
|
let n, i = null;
|
|
1229
|
-
(n = t.match(Pe)) ? i = e.dot ? ke : Re : (n = t.match(
|
|
1228
|
+
(n = t.match(Pe)) ? i = e.dot ? ke : Re : (n = t.match(ve)) ? i = (e.nocase ? e.dot ? De : Oe : e.dot ? Ce : Ae)(n[1]) : (n = t.match(Le)) ? i = (e.nocase ? e.dot ? ze : Ie : e.dot ? He : We)(n) : (n = t.match(Ne)) ? i = e.dot ? Fe : Te : (n = t.match(Me)) && (i = $e);
|
|
1230
1229
|
const r = E.fromGlob(t, this.options).toMMPattern();
|
|
1231
1230
|
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
1232
1231
|
}
|
|
@@ -1242,12 +1241,12 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1242
1241
|
if (c instanceof RegExp)
|
|
1243
1242
|
for (const f of c.flags.split(""))
|
|
1244
1243
|
i.add(f);
|
|
1245
|
-
return typeof c == "string" ? Ze(c) : c ===
|
|
1244
|
+
return typeof c == "string" ? Ze(c) : c === v ? v : c._src;
|
|
1246
1245
|
});
|
|
1247
1246
|
return h.forEach((c, f) => {
|
|
1248
1247
|
const u = h[f + 1], d = h[f - 1];
|
|
1249
|
-
c !==
|
|
1250
|
-
}), h.filter((c) => c !==
|
|
1248
|
+
c !== v || d === v || (d === void 0 ? u !== void 0 && u !== v ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== v && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = v));
|
|
1249
|
+
}), h.filter((c) => c !== v).join("/");
|
|
1251
1250
|
}).join("|");
|
|
1252
1251
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1253
1252
|
r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
|
|
@@ -1292,7 +1291,7 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1292
1291
|
}
|
|
1293
1292
|
y.AST = E;
|
|
1294
1293
|
y.Minimatch = j;
|
|
1295
|
-
y.escape =
|
|
1294
|
+
y.escape = be;
|
|
1296
1295
|
y.unescape = $;
|
|
1297
1296
|
const Je = [
|
|
1298
1297
|
// Images
|
|
@@ -1446,6 +1445,7 @@ async function rs(s, t, e = {}) {
|
|
|
1446
1445
|
const n = Y(t);
|
|
1447
1446
|
return tt(t, "exclusive", async () => {
|
|
1448
1447
|
const i = e.recursive ?? !1, r = e.force ?? !1;
|
|
1448
|
+
e.useTrash;
|
|
1449
1449
|
try {
|
|
1450
1450
|
await s.removeEntry(n, { recursive: i });
|
|
1451
1451
|
} catch (o) {
|
|
@@ -1458,7 +1458,7 @@ async function rs(s, t, e = {}) {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
class os {
|
|
1460
1460
|
/** Root directory handle for the file system */
|
|
1461
|
-
root
|
|
1461
|
+
root;
|
|
1462
1462
|
/** Map of watched paths and options */
|
|
1463
1463
|
watchers = /* @__PURE__ */ new Map();
|
|
1464
1464
|
/** Promise to prevent concurrent mount operations */
|
|
@@ -1541,13 +1541,14 @@ class os {
|
|
|
1541
1541
|
* await fs.mount('/my-app');
|
|
1542
1542
|
* \`\`\`
|
|
1543
1543
|
*/
|
|
1544
|
-
async mount(
|
|
1545
|
-
|
|
1544
|
+
async mount() {
|
|
1545
|
+
const t = this.options.root;
|
|
1546
|
+
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
|
|
1546
1547
|
try {
|
|
1547
1548
|
const i = await navigator.storage.getDirectory();
|
|
1548
|
-
t === "/" ?
|
|
1549
|
-
} catch {
|
|
1550
|
-
n(new g("Failed to initialize OPFS", "INIT_FAILED"));
|
|
1549
|
+
this.root = t === "/" ? i : await this.getDirectoryHandle(t, !0, i), e(!0);
|
|
1550
|
+
} catch (i) {
|
|
1551
|
+
n(new g("Failed to initialize OPFS", "INIT_FAILED", t, i));
|
|
1551
1552
|
} finally {
|
|
1552
1553
|
this.mountingPromise = null;
|
|
1553
1554
|
}
|
|
@@ -1564,7 +1565,7 @@ class os {
|
|
|
1564
1565
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1565
1566
|
*/
|
|
1566
1567
|
async setOptions(t) {
|
|
1567
|
-
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 = t.root, this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount(
|
|
1568
|
+
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 = Z(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1568
1569
|
}
|
|
1569
1570
|
/**
|
|
1570
1571
|
* Get a directory handle from a path
|
|
@@ -1661,7 +1662,7 @@ class os {
|
|
|
1661
1662
|
async readFile(t, e) {
|
|
1662
1663
|
await this.mount(), e || (e = G(t) ? "binary" : "utf-8");
|
|
1663
1664
|
try {
|
|
1664
|
-
const n = await this.getFileHandle(t, !1), i = await ss(n, t);
|
|
1665
|
+
const n = await this.getFileHandle(t, !1, this.root), i = await ss(n, t);
|
|
1665
1666
|
return e === "binary" ? i : _t(i, e);
|
|
1666
1667
|
} catch (n) {
|
|
1667
1668
|
throw new _(t, n);
|
|
@@ -1962,8 +1963,8 @@ class os {
|
|
|
1962
1963
|
async remove(t, e) {
|
|
1963
1964
|
if (await this.mount(), t === "/")
|
|
1964
1965
|
throw new g("Cannot remove root directory", "EROOT");
|
|
1965
|
-
const n = await this.getDirectoryHandle(q(t), !1);
|
|
1966
|
-
await rs(
|
|
1966
|
+
const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(q(t), !1);
|
|
1967
|
+
await rs(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
|
|
1967
1968
|
}
|
|
1968
1969
|
/**
|
|
1969
1970
|
* Resolve a path to an absolute path
|
|
@@ -1998,26 +1999,35 @@ class os {
|
|
|
1998
1999
|
* Rename a file or directory
|
|
1999
2000
|
*
|
|
2000
2001
|
* Changes the name of a file or directory. If the target path already exists,
|
|
2001
|
-
* it will be replaced.
|
|
2002
|
+
* it will be replaced only if overwrite option is enabled.
|
|
2002
2003
|
*
|
|
2003
2004
|
* @param oldPath - The current path of the file or directory
|
|
2004
2005
|
* @param newPath - The new path for the file or directory
|
|
2006
|
+
* @param options - Options for renaming
|
|
2007
|
+
* @param options.overwrite - Whether to overwrite existing files (default: false)
|
|
2005
2008
|
* @returns Promise that resolves when the rename operation is complete
|
|
2006
2009
|
* @throws {OPFSError} If the rename operation fails
|
|
2007
2010
|
*
|
|
2008
2011
|
* @example
|
|
2009
2012
|
* \`\`\`typescript
|
|
2013
|
+
* // Basic rename (fails if target exists)
|
|
2010
2014
|
* await fs.rename('/old/path/file.txt', '/new/path/renamed.txt');
|
|
2015
|
+
*
|
|
2016
|
+
* // Rename with overwrite
|
|
2017
|
+
* await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
|
|
2011
2018
|
* \`\`\`
|
|
2012
2019
|
*/
|
|
2013
|
-
async rename(t, e) {
|
|
2020
|
+
async rename(t, e, n) {
|
|
2014
2021
|
await this.mount();
|
|
2015
2022
|
try {
|
|
2023
|
+
const i = n?.overwrite ?? !1;
|
|
2016
2024
|
if (!await this.exists(t))
|
|
2017
2025
|
throw new _(t);
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2026
|
+
if (await this.exists(e) && !i)
|
|
2027
|
+
throw new g(\`Destination already exists: \${e}\`, "EEXIST", void 0);
|
|
2028
|
+
await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 }), await this.notifyChange({ path: e, type: "added", isDirectory: !1 });
|
|
2029
|
+
} catch (i) {
|
|
2030
|
+
throw i instanceof g ? i : new g(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
|
|
2021
2031
|
}
|
|
2022
2032
|
}
|
|
2023
2033
|
/**
|
|
@@ -2029,7 +2039,7 @@ class os {
|
|
|
2029
2039
|
* @param destination - The destination path to copy to
|
|
2030
2040
|
* @param options - Options for copying
|
|
2031
2041
|
* @param options.recursive - Whether to copy directories recursively (default: false)
|
|
2032
|
-
* @param options.
|
|
2042
|
+
* @param options.overwrite - Whether to overwrite existing files (default: true)
|
|
2033
2043
|
* @returns Promise that resolves when the copy operation is complete
|
|
2034
2044
|
* @throws {OPFSError} If the copy operation fails
|
|
2035
2045
|
*
|
|
@@ -2042,13 +2052,13 @@ class os {
|
|
|
2042
2052
|
* await fs.copy('/source/dir', '/dest/dir', { recursive: true });
|
|
2043
2053
|
*
|
|
2044
2054
|
* // Copy without overwriting existing files
|
|
2045
|
-
* await fs.copy('/source', '/dest', { recursive: true,
|
|
2055
|
+
* await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
|
|
2046
2056
|
* \`\`\`
|
|
2047
2057
|
*/
|
|
2048
2058
|
async copy(t, e, n) {
|
|
2049
2059
|
await this.mount();
|
|
2050
2060
|
try {
|
|
2051
|
-
const i = n?.recursive ?? !1, r = n?.
|
|
2061
|
+
const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
|
|
2052
2062
|
if (!await this.exists(t))
|
|
2053
2063
|
throw new g(\`Source does not exist: \${t}\`, "ENOENT", void 0);
|
|
2054
2064
|
if (await this.exists(e) && !r)
|
|
@@ -2063,7 +2073,7 @@ class os {
|
|
|
2063
2073
|
const h = await this.readDir(t);
|
|
2064
2074
|
for (const c of h) {
|
|
2065
2075
|
const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
|
|
2066
|
-
await this.copy(f, u, { recursive: !0,
|
|
2076
|
+
await this.copy(f, u, { recursive: !0, overwrite: r });
|
|
2067
2077
|
}
|
|
2068
2078
|
}
|
|
2069
2079
|
} catch (i) {
|
|
@@ -2163,6 +2173,6 @@ class os {
|
|
|
2163
2173
|
}
|
|
2164
2174
|
}
|
|
2165
2175
|
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && J(new os());
|
|
2166
|
-
//# sourceMappingURL=worker-
|
|
2176
|
+
//# sourceMappingURL=worker-XHCzp1qX.js.map
|
|
2167
2177
|
`,r=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",i],{type:"text/javascript;charset=utf-8"});function a(t){let e;try{if(e=r&&(self.URL||self.webkitURL).createObjectURL(r),!e)throw"";const s=new Worker(e,{type:"module",name:t?.name});return s.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),s}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(i),{type:"module",name:t?.name})}}async function h(t){const e=o.wrap(new a);return t&&(t.broadcastChannel&&t.broadcastChannel instanceof BroadcastChannel&&(t.broadcastChannel=t.broadcastChannel.name),await e.setOptions(t)),e}exports.BINARY_FILE_EXTENSIONS=n.BINARY_FILE_EXTENSIONS;exports.DirectoryNotFoundError=n.DirectoryNotFoundError;exports.FileNotFoundError=n.FileNotFoundError;exports.OPFSError=n.OPFSError;exports.OPFSNotMountedError=n.OPFSNotMountedError;exports.OPFSNotSupportedError=n.OPFSNotSupportedError;exports.PathError=n.PathError;exports.PermissionError=n.PermissionError;exports.StorageError=n.StorageError;exports.TimeoutError=n.TimeoutError;exports.basename=n.basename;exports.buffersEqual=n.buffersEqual;exports.calculateFileHash=n.calculateFileHash;exports.checkOPFSSupport=n.checkOPFSSupport;exports.convertBlobToUint8Array=n.convertBlobToUint8Array;exports.createBuffer=n.createBuffer;exports.decodeBuffer=n.decodeBuffer;exports.dirname=n.dirname;exports.encodeString=n.encodeString;exports.extname=n.extname;exports.isBinaryFileExtension=n.isBinaryFileExtension;exports.isPathExcluded=n.isPathExcluded;exports.joinPath=n.joinPath;exports.matchMinimatch=n.matchMinimatch;exports.normalizeMinimatch=n.normalizeMinimatch;exports.normalizePath=n.normalizePath;exports.readFileData=n.readFileData;exports.removeEntry=n.removeEntry;exports.resolvePath=n.resolvePath;exports.splitPath=n.splitPath;exports.withLock=n.withLock;exports.writeFileData=n.writeFileData;exports.createWorker=h;
|
|
2168
2178
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport WorkerCtor from './worker?worker&inline';\n\nimport type { OPFSOptions, OPFSWorker, RemoteOPFSWorker } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport async function createWorker(\n options?: OPFSOptions\n): Promise<RemoteOPFSWorker> {\n const wrapped = wrap<OPFSWorker>(new WorkerCtor());\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n await wrapped.setOptions(options);\n }\n\n return wrapped;\n}\n"],"names":["createWorker","options","wrapped","wrap","WorkerCtor"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport WorkerCtor from './worker?worker&inline';\n\nimport type { OPFSOptions, OPFSWorker, RemoteOPFSWorker } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport async function createWorker(\n options?: OPFSOptions\n): Promise<RemoteOPFSWorker> {\n const wrapped = wrap<OPFSWorker>(new WorkerCtor());\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n await wrapped.setOptions(options);\n }\n\n return wrapped;\n}\n"],"names":["createWorker","options","wrapped","wrap","WorkerCtor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qdAgBA,eAAsBA,EAClBC,EACyB,CACzB,MAAMC,EAAUC,EAAAA,KAAiB,IAAIC,CAAY,EAGjD,OAAIH,IAEIA,EAAQ,kBAAoBA,EAAQ,4BAA4B,mBAChEA,EAAQ,iBAAmBA,EAAQ,iBAAiB,MAGxD,MAAMC,EAAQ,WAAWD,CAAO,GAG7BC,CACX"}
|