opfs-worker 1.2.0 → 1.2.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-CLvhwwfc.js.map → worker-BuPeqKqw.js.map} +1 -1
- package/dist/facade.d.ts +22 -24
- package/dist/facade.d.ts.map +1 -1
- package/dist/index.cjs +72 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +164 -147
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +121 -122
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +1 -3
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { wrap as
|
|
2
|
-
import { i as
|
|
3
|
-
import { E, D as
|
|
4
|
-
const
|
|
1
|
+
import { wrap as u } from "comlink";
|
|
2
|
+
import { i as c, d as l, e as h } from "./helpers-CkNHswLp.js";
|
|
3
|
+
import { E as x, D as S, F as P, O as F, b as O, a as A, P as T, c as I, S as R, T as $, h as _, v as C, u as N, B as D, g as z, x as k, t as M, f as L, C as j, k as W, q as U, p as H, j as B, m as G, o as q, l as V, n as Y, y as X, r as Z, A as J, s as K, z as Q, w as nn } from "./helpers-CkNHswLp.js";
|
|
4
|
+
const f = `/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
7
7
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -15,7 +15,7 @@ const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol
|
|
|
15
15
|
deserialize(s) {
|
|
16
16
|
return s.start(), Rt(s);
|
|
17
17
|
}
|
|
18
|
-
},
|
|
18
|
+
}, It = {
|
|
19
19
|
canHandle: (s) => gt(s) && z in s,
|
|
20
20
|
serialize({ value: s }) {
|
|
21
21
|
let t;
|
|
@@ -33,9 +33,9 @@ const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol
|
|
|
33
33
|
}
|
|
34
34
|
}, wt = /* @__PURE__ */ new Map([
|
|
35
35
|
["proxy", Mt],
|
|
36
|
-
["throw",
|
|
36
|
+
["throw", It]
|
|
37
37
|
]);
|
|
38
|
-
function
|
|
38
|
+
function Pt(s, t) {
|
|
39
39
|
for (const e of s)
|
|
40
40
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
41
41
|
return !0;
|
|
@@ -45,7 +45,7 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
45
45
|
t.addEventListener("message", function n(i) {
|
|
46
46
|
if (!i || !i.data)
|
|
47
47
|
return;
|
|
48
|
-
if (!
|
|
48
|
+
if (!Pt(e, i.origin)) {
|
|
49
49
|
console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -85,10 +85,10 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
85
85
|
h = { value: c, [z]: 0 };
|
|
86
86
|
}
|
|
87
87
|
Promise.resolve(h).catch((c) => ({ value: c, [z]: 0 })).then((c) => {
|
|
88
|
-
const [f, u] =
|
|
89
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
88
|
+
const [f, u] = U(c);
|
|
89
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), mt(t), q in s && typeof s[q] == "function" && s[q]());
|
|
90
90
|
}).catch((c) => {
|
|
91
|
-
const [f, u] =
|
|
91
|
+
const [f, u] = U({
|
|
92
92
|
value: new TypeError("Unserializable return value"),
|
|
93
93
|
[z]: 0
|
|
94
94
|
});
|
|
@@ -99,7 +99,7 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
99
99
|
function kt(s) {
|
|
100
100
|
return s.constructor.name === "MessagePort";
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function mt(s) {
|
|
103
103
|
kt(s) && s.close();
|
|
104
104
|
}
|
|
105
105
|
function Rt(s, t) {
|
|
@@ -121,16 +121,16 @@ function k(s) {
|
|
|
121
121
|
if (s)
|
|
122
122
|
throw new Error("Proxy has been released and is not useable");
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function yt(s) {
|
|
125
125
|
return N(s, /* @__PURE__ */ new Map(), {
|
|
126
126
|
type: "RELEASE"
|
|
127
127
|
}).then(() => {
|
|
128
|
-
|
|
128
|
+
mt(s);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
const _ = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
132
132
|
const t = (_.get(s) || 0) - 1;
|
|
133
|
-
_.set(s, t), t === 0 &&
|
|
133
|
+
_.set(s, t), t === 0 && yt(s);
|
|
134
134
|
});
|
|
135
135
|
function Lt(s, t) {
|
|
136
136
|
const e = (_.get(t) || 0) + 1;
|
|
@@ -146,7 +146,7 @@ function Z(s, t, e = [], n = function() {
|
|
|
146
146
|
get(o, a) {
|
|
147
147
|
if (k(i), a === Tt)
|
|
148
148
|
return () => {
|
|
149
|
-
zt(r),
|
|
149
|
+
zt(r), yt(s), t.clear(), i = !0;
|
|
150
150
|
};
|
|
151
151
|
if (a === "then") {
|
|
152
152
|
if (e.length === 0)
|
|
@@ -161,7 +161,7 @@ function Z(s, t, e = [], n = function() {
|
|
|
161
161
|
},
|
|
162
162
|
set(o, a, l) {
|
|
163
163
|
k(i);
|
|
164
|
-
const [h, c] =
|
|
164
|
+
const [h, c] = U(l);
|
|
165
165
|
return N(s, t, {
|
|
166
166
|
type: "SET",
|
|
167
167
|
path: [...e, a].map((f) => f.toString()),
|
|
@@ -200,7 +200,7 @@ function Ht(s) {
|
|
|
200
200
|
return Array.prototype.concat.apply([], s);
|
|
201
201
|
}
|
|
202
202
|
function st(s) {
|
|
203
|
-
const t = s.map(
|
|
203
|
+
const t = s.map(U);
|
|
204
204
|
return [t.map((e) => e[0]), Ht(t.map((e) => e[1]))];
|
|
205
205
|
}
|
|
206
206
|
const Et = /* @__PURE__ */ new WeakMap();
|
|
@@ -210,7 +210,7 @@ function H(s, t) {
|
|
|
210
210
|
function Wt(s) {
|
|
211
211
|
return Object.assign(s, { [pt]: !0 });
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function U(s) {
|
|
214
214
|
for (const [t, e] of wt)
|
|
215
215
|
if (e.canHandle(s)) {
|
|
216
216
|
const [n, i] = e.serialize(s);
|
|
@@ -258,7 +258,7 @@ class jt extends p {
|
|
|
258
258
|
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
class
|
|
261
|
+
class Ut extends p {
|
|
262
262
|
constructor(t, e, n) {
|
|
263
263
|
super(t, "INVALID_PATH", e, n);
|
|
264
264
|
}
|
|
@@ -272,7 +272,7 @@ function R(s, t, e, n) {
|
|
|
272
272
|
const i = \`\${s.toUpperCase()}_FAILED\`;
|
|
273
273
|
return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Bt(s, t) {
|
|
276
276
|
const e = t?.path;
|
|
277
277
|
switch (s.name) {
|
|
278
278
|
case "InvalidStateError":
|
|
@@ -391,17 +391,17 @@ function T(s, t) {
|
|
|
391
391
|
const O = c.some(oe);
|
|
392
392
|
f = [];
|
|
393
393
|
for (let x = u; S(x, d); x += g) {
|
|
394
|
-
let
|
|
394
|
+
let m;
|
|
395
395
|
if (a)
|
|
396
|
-
|
|
397
|
-
else if (
|
|
398
|
-
const $ = w -
|
|
396
|
+
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
397
|
+
else if (m = String(x), O) {
|
|
398
|
+
const $ = w - m.length;
|
|
399
399
|
if ($ > 0) {
|
|
400
|
-
const
|
|
401
|
-
x < 0 ?
|
|
400
|
+
const P = new Array($ + 1).join("0");
|
|
401
|
+
x < 0 ? m = "-" + P + m.slice(1) : m = P + m;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
f.push(
|
|
404
|
+
f.push(m);
|
|
405
405
|
}
|
|
406
406
|
} else {
|
|
407
407
|
f = [];
|
|
@@ -416,7 +416,7 @@ function T(s, t) {
|
|
|
416
416
|
}
|
|
417
417
|
return e;
|
|
418
418
|
}
|
|
419
|
-
const le = 1024 * 64,
|
|
419
|
+
const le = 1024 * 64, B = (s) => {
|
|
420
420
|
if (typeof s != "string")
|
|
421
421
|
throw new TypeError("invalid pattern");
|
|
422
422
|
if (s.length > le)
|
|
@@ -489,7 +489,7 @@ const le = 1024 * 64, U = (s) => {
|
|
|
489
489
|
}
|
|
490
490
|
const u = "[" + (h ? "^" : "") + rt(n) + "]", d = "[" + (h ? "" : "^") + rt(i) + "]";
|
|
491
491
|
return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
492
|
-
}, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), de = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), ot = (s) => de.has(s), pe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ge = /* @__PURE__ */ new Set(["[", "."]), we = /* @__PURE__ */ new Set(["..", "."]),
|
|
492
|
+
}, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), de = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), ot = (s) => de.has(s), pe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ge = /* @__PURE__ */ new Set(["[", "."]), we = /* @__PURE__ */ new Set(["..", "."]), me = new Set("().*{}+?[]^$\\\\!"), ye = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), tt = "[^/]", at = tt + "*?", ct = tt + "+?";
|
|
493
493
|
class E {
|
|
494
494
|
type;
|
|
495
495
|
#s;
|
|
@@ -801,7 +801,7 @@ class E {
|
|
|
801
801
|
for (let a = 0; a < t.length; a++) {
|
|
802
802
|
const l = t.charAt(a);
|
|
803
803
|
if (i) {
|
|
804
|
-
i = !1, r += (
|
|
804
|
+
i = !1, r += (me.has(l) ? "\\\\" : "") + l;
|
|
805
805
|
continue;
|
|
806
806
|
}
|
|
807
807
|
if (l === "\\\\") {
|
|
@@ -823,12 +823,12 @@ class E {
|
|
|
823
823
|
r += tt, e = !0;
|
|
824
824
|
continue;
|
|
825
825
|
}
|
|
826
|
-
r +=
|
|
826
|
+
r += ye(l);
|
|
827
827
|
}
|
|
828
828
|
return [r, M(t), !!e, o];
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
|
-
const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"),
|
|
831
|
+
const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (B(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new G(t, e).match(s)), Se = /^\\*+([^+@!?\\*\\[\\(]*)$/, xe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), be = (s) => (t) => t.endsWith(s), ve = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ae = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Fe = /^\\*+\\.\\*+$/, Ne = (s) => !s.startsWith(".") && s.includes("."), De = (s) => s !== "." && s !== ".." && s.includes("."), Oe = /^\\.\\*+$/, $e = (s) => s !== "." && s !== ".." && s.startsWith("."), Ce = /^\\*+$/, Te = (s) => s.length !== 0 && !s.startsWith("."), Me = (s) => s.length !== 0 && s !== "." && s !== "..", Ie = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Pe = ([s, t = ""]) => {
|
|
832
832
|
const e = Nt([s]);
|
|
833
833
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
834
834
|
}, ke = ([s, t = ""]) => {
|
|
@@ -850,15 +850,15 @@ const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
|
|
|
850
850
|
win32: { sep: "\\\\" },
|
|
851
851
|
posix: { sep: "/" }
|
|
852
852
|
}, ze = Ot === "win32" ? lt.win32.sep : lt.posix.sep;
|
|
853
|
-
|
|
853
|
+
y.sep = ze;
|
|
854
854
|
const v = Symbol("globstar **");
|
|
855
|
-
|
|
856
|
-
const He = "[^/]", We = He + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", je = "(?:(?!(?:\\\\/|^)\\\\.).)*?",
|
|
857
|
-
|
|
858
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
855
|
+
y.GLOBSTAR = v;
|
|
856
|
+
const He = "[^/]", We = He + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", je = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Ue = (s, t = {}) => (e) => y(e, s, t);
|
|
857
|
+
y.filter = Ue;
|
|
858
|
+
const b = (s, t = {}) => Object.assign({}, s, t), Be = (s) => {
|
|
859
859
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
860
|
-
return
|
|
861
|
-
const t =
|
|
860
|
+
return y;
|
|
861
|
+
const t = y;
|
|
862
862
|
return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
|
|
863
863
|
Minimatch: class extends t.Minimatch {
|
|
864
864
|
constructor(i, r = {}) {
|
|
@@ -889,16 +889,16 @@ const b = (s, t = {}) => Object.assign({}, s, t), Ue = (s) => {
|
|
|
889
889
|
GLOBSTAR: v
|
|
890
890
|
});
|
|
891
891
|
};
|
|
892
|
-
|
|
893
|
-
const $t = (s, t = {}) => (
|
|
894
|
-
|
|
892
|
+
y.defaults = Be;
|
|
893
|
+
const $t = (s, t = {}) => (B(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ie(s));
|
|
894
|
+
y.braceExpand = $t;
|
|
895
895
|
const Ge = (s, t = {}) => new G(s, t).makeRe();
|
|
896
|
-
|
|
896
|
+
y.makeRe = Ge;
|
|
897
897
|
const qe = (s, t, e = {}) => {
|
|
898
898
|
const n = new G(t, e);
|
|
899
899
|
return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
|
|
900
900
|
};
|
|
901
|
-
|
|
901
|
+
y.match = qe;
|
|
902
902
|
const ht = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
903
903
|
class G {
|
|
904
904
|
options;
|
|
@@ -919,7 +919,7 @@ class G {
|
|
|
919
919
|
windowsNoMagicRoot;
|
|
920
920
|
regexp;
|
|
921
921
|
constructor(t, e = {}) {
|
|
922
|
-
|
|
922
|
+
B(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ot, 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();
|
|
923
923
|
}
|
|
924
924
|
hasMagic() {
|
|
925
925
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -1127,10 +1127,10 @@ class G {
|
|
|
1127
1127
|
matchOne(t, e, n = !1) {
|
|
1128
1128
|
const i = this.options;
|
|
1129
1129
|
if (this.isWindows) {
|
|
1130
|
-
const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), O = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0,
|
|
1131
|
-
if (typeof x == "number" && typeof
|
|
1132
|
-
const [$,
|
|
1133
|
-
$.toLowerCase() ===
|
|
1130
|
+
const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), O = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = O ? 3 : A ? 0 : void 0;
|
|
1131
|
+
if (typeof x == "number" && typeof m == "number") {
|
|
1132
|
+
const [$, P] = [t[x], e[m]];
|
|
1133
|
+
$.toLowerCase() === P.toLowerCase() && (e[m] = $, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
const { optimizationLevel: r = 1 } = this.options;
|
|
@@ -1179,14 +1179,14 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1179
1179
|
return $t(this.pattern, this.options);
|
|
1180
1180
|
}
|
|
1181
1181
|
parse(t) {
|
|
1182
|
-
|
|
1182
|
+
B(t);
|
|
1183
1183
|
const e = this.options;
|
|
1184
1184
|
if (t === "**")
|
|
1185
1185
|
return v;
|
|
1186
1186
|
if (t === "")
|
|
1187
1187
|
return "";
|
|
1188
1188
|
let n, i = null;
|
|
1189
|
-
(n = t.match(Ce)) ? i = e.dot ? Me : Te : (n = t.match(Se)) ? i = (e.nocase ? e.dot ? Ae : ve : e.dot ? be : xe)(n[1]) : (n = t.match(
|
|
1189
|
+
(n = t.match(Ce)) ? i = e.dot ? Me : Te : (n = t.match(Se)) ? i = (e.nocase ? e.dot ? Ae : ve : e.dot ? be : xe)(n[1]) : (n = t.match(Ie)) ? i = (e.nocase ? e.dot ? ke : Pe : e.dot ? Re : Le)(n) : (n = t.match(Fe)) ? i = e.dot ? De : Ne : (n = t.match(Oe)) && (i = $e);
|
|
1190
1190
|
const r = E.fromGlob(t, this.options).toMMPattern();
|
|
1191
1191
|
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
1192
1192
|
}
|
|
@@ -1247,18 +1247,18 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1247
1247
|
return n.flipNegate ? !1 : this.negate;
|
|
1248
1248
|
}
|
|
1249
1249
|
static defaults(t) {
|
|
1250
|
-
return
|
|
1250
|
+
return y.defaults(t).Minimatch;
|
|
1251
1251
|
}
|
|
1252
1252
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1253
|
+
y.AST = E;
|
|
1254
|
+
y.Minimatch = G;
|
|
1255
|
+
y.escape = Ee;
|
|
1256
|
+
y.unescape = M;
|
|
1257
1257
|
function Xe() {
|
|
1258
1258
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1259
1259
|
throw new jt();
|
|
1260
1260
|
}
|
|
1261
|
-
async function
|
|
1261
|
+
async function I(s, t, e) {
|
|
1262
1262
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1263
1263
|
}
|
|
1264
1264
|
function D(s) {
|
|
@@ -1282,7 +1282,7 @@ function Ye(s, t = !1) {
|
|
|
1282
1282
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1283
1283
|
}
|
|
1284
1284
|
function Y(s, t) {
|
|
1285
|
-
return
|
|
1285
|
+
return y(s, t, {
|
|
1286
1286
|
dot: !0,
|
|
1287
1287
|
matchBase: !0
|
|
1288
1288
|
});
|
|
@@ -1311,7 +1311,7 @@ async function Je(s) {
|
|
|
1311
1311
|
}
|
|
1312
1312
|
async function Ke(s, t, e = {}) {
|
|
1313
1313
|
const n = J(t);
|
|
1314
|
-
return
|
|
1314
|
+
return I(t, "exclusive", async () => {
|
|
1315
1315
|
const i = e.recursive ?? !1, r = e.force ?? !1;
|
|
1316
1316
|
e.useTrash;
|
|
1317
1317
|
try {
|
|
@@ -1351,7 +1351,7 @@ async function ts(s, t) {
|
|
|
1351
1351
|
try {
|
|
1352
1352
|
return await s.createSyncAccessHandle();
|
|
1353
1353
|
} catch (e) {
|
|
1354
|
-
throw
|
|
1354
|
+
throw Bt(e, { path: t });
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
1357
|
class es {
|
|
@@ -1526,7 +1526,7 @@ class es {
|
|
|
1526
1526
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1527
1527
|
const i = D(t);
|
|
1528
1528
|
if (i.length === 0)
|
|
1529
|
-
throw new
|
|
1529
|
+
throw new Ut("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1530
1530
|
const r = i.pop();
|
|
1531
1531
|
return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
|
|
1532
1532
|
}
|
|
@@ -1593,7 +1593,7 @@ class es {
|
|
|
1593
1593
|
async readFile(t) {
|
|
1594
1594
|
await this.mount();
|
|
1595
1595
|
try {
|
|
1596
|
-
return await
|
|
1596
|
+
return await I(t, "shared", async () => {
|
|
1597
1597
|
const e = await this.open(t);
|
|
1598
1598
|
try {
|
|
1599
1599
|
const { size: n } = await this.fstat(e), i = new Uint8Array(n);
|
|
@@ -1631,7 +1631,7 @@ class es {
|
|
|
1631
1631
|
async writeFile(t, e) {
|
|
1632
1632
|
await this.mount();
|
|
1633
1633
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1634
|
-
await
|
|
1634
|
+
await I(t, "exclusive", async () => {
|
|
1635
1635
|
const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
|
|
1636
1636
|
try {
|
|
1637
1637
|
await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
|
|
@@ -1666,7 +1666,7 @@ class es {
|
|
|
1666
1666
|
async appendFile(t, e) {
|
|
1667
1667
|
await this.mount();
|
|
1668
1668
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1669
|
-
await
|
|
1669
|
+
await I(t, "exclusive", async () => {
|
|
1670
1670
|
const i = await this.open(t, { create: !0 });
|
|
1671
1671
|
try {
|
|
1672
1672
|
const { size: r } = await this.fstat(i);
|
|
@@ -2103,7 +2103,7 @@ class es {
|
|
|
2103
2103
|
await this.mount();
|
|
2104
2104
|
const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = W(ut(t));
|
|
2105
2105
|
try {
|
|
2106
|
-
return n && i ? await
|
|
2106
|
+
return n && i ? await I(o, "exclusive", async () => {
|
|
2107
2107
|
if (await this.exists(o))
|
|
2108
2108
|
throw new p(\`File already exists: \${o}\`, "EEXIST", o);
|
|
2109
2109
|
return this._openFile(o, n, r);
|
|
@@ -2329,48 +2329,50 @@ class es {
|
|
|
2329
2329
|
* await fs.sync(entries, { cleanBefore: true });
|
|
2330
2330
|
* \`\`\`
|
|
2331
2331
|
*/
|
|
2332
|
-
async
|
|
2332
|
+
async createIndex(t) {
|
|
2333
2333
|
await this.mount();
|
|
2334
2334
|
try {
|
|
2335
|
-
(e
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
r instanceof Blob ? a = await Je(r) : typeof r == "string" ? a = new TextEncoder().encode(r) : a = r, await this.writeFile(o, a);
|
|
2335
|
+
for (const [e, n] of t) {
|
|
2336
|
+
const i = W(e);
|
|
2337
|
+
let r;
|
|
2338
|
+
n instanceof Blob ? r = await Je(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
|
|
2340
2339
|
}
|
|
2341
|
-
} catch (
|
|
2342
|
-
throw
|
|
2340
|
+
} catch (e) {
|
|
2341
|
+
throw e instanceof p ? e : new p("Failed to sync file system", "SYNC_FAILED", void 0, e);
|
|
2343
2342
|
}
|
|
2344
2343
|
}
|
|
2345
2344
|
}
|
|
2346
2345
|
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
|
|
2347
|
-
//# sourceMappingURL=worker-
|
|
2348
|
-
`,
|
|
2349
|
-
function
|
|
2346
|
+
//# sourceMappingURL=worker-BuPeqKqw.js.map
|
|
2347
|
+
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2348
|
+
function m(a) {
|
|
2350
2349
|
let n;
|
|
2351
2350
|
try {
|
|
2352
|
-
if (n =
|
|
2351
|
+
if (n = p && (self.URL || self.webkitURL).createObjectURL(p), !n) throw "";
|
|
2353
2352
|
const t = new Worker(n, {
|
|
2354
2353
|
type: "module",
|
|
2355
|
-
name:
|
|
2354
|
+
name: a?.name
|
|
2356
2355
|
});
|
|
2357
2356
|
return t.addEventListener("error", () => {
|
|
2358
2357
|
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
2359
2358
|
}), t;
|
|
2360
2359
|
} catch {
|
|
2361
2360
|
return new Worker(
|
|
2362
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
2361
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(f),
|
|
2363
2362
|
{
|
|
2364
2363
|
type: "module",
|
|
2365
|
-
name:
|
|
2364
|
+
name: a?.name
|
|
2366
2365
|
}
|
|
2367
2366
|
);
|
|
2368
2367
|
}
|
|
2369
2368
|
}
|
|
2369
|
+
function s(a) {
|
|
2370
|
+
return a instanceof URL ? a.pathname : a;
|
|
2371
|
+
}
|
|
2370
2372
|
class w {
|
|
2371
2373
|
#n;
|
|
2372
2374
|
constructor(n) {
|
|
2373
|
-
const t =
|
|
2375
|
+
const t = u(new m());
|
|
2374
2376
|
this.#n = t, n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
|
|
2375
2377
|
}
|
|
2376
2378
|
/**
|
|
@@ -2386,96 +2388,110 @@ class w {
|
|
|
2386
2388
|
return this.#n.index();
|
|
2387
2389
|
}
|
|
2388
2390
|
async readFile(n, t) {
|
|
2389
|
-
const e = await this.#n.readFile(
|
|
2390
|
-
return t || (t =
|
|
2391
|
+
const e = s(n), r = await this.#n.readFile(e);
|
|
2392
|
+
return t || (t = c(e) ? "binary" : "utf-8"), t === "binary" ? r : l(r, t);
|
|
2391
2393
|
}
|
|
2392
2394
|
/**
|
|
2393
2395
|
* Write data to a file
|
|
2394
2396
|
*/
|
|
2395
2397
|
async writeFile(n, t, e) {
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2398
|
+
const r = s(n);
|
|
2399
|
+
e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
|
|
2400
|
+
const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2401
|
+
return this.#n.writeFile(r, i);
|
|
2399
2402
|
}
|
|
2400
2403
|
/**
|
|
2401
2404
|
* Append data to a file
|
|
2402
2405
|
*/
|
|
2403
2406
|
async appendFile(n, t, e) {
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
+
const r = s(n);
|
|
2408
|
+
e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
|
|
2409
|
+
const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2410
|
+
return this.#n.appendFile(r, i);
|
|
2407
2411
|
}
|
|
2408
2412
|
/**
|
|
2409
2413
|
* Create a directory
|
|
2410
2414
|
*/
|
|
2411
2415
|
async mkdir(n, t) {
|
|
2412
|
-
|
|
2416
|
+
const e = s(n);
|
|
2417
|
+
return this.#n.mkdir(e, t);
|
|
2413
2418
|
}
|
|
2414
2419
|
/**
|
|
2415
2420
|
* Get file or directory statistics
|
|
2416
2421
|
*/
|
|
2417
2422
|
async stat(n) {
|
|
2418
|
-
|
|
2423
|
+
const t = s(n);
|
|
2424
|
+
return this.#n.stat(t);
|
|
2419
2425
|
}
|
|
2420
2426
|
/**
|
|
2421
2427
|
* Read a directory's contents
|
|
2422
2428
|
*/
|
|
2423
2429
|
async readDir(n) {
|
|
2424
|
-
|
|
2430
|
+
const t = s(n);
|
|
2431
|
+
return this.#n.readDir(t);
|
|
2425
2432
|
}
|
|
2426
2433
|
/**
|
|
2427
2434
|
* Check if a file or directory exists
|
|
2428
2435
|
*/
|
|
2429
2436
|
async exists(n) {
|
|
2430
|
-
|
|
2437
|
+
const t = s(n);
|
|
2438
|
+
return this.#n.exists(t);
|
|
2431
2439
|
}
|
|
2432
2440
|
/**
|
|
2433
2441
|
* Clear all contents of a directory without removing the directory itself
|
|
2434
2442
|
*/
|
|
2435
2443
|
async clear(n) {
|
|
2436
|
-
|
|
2444
|
+
const t = n ? s(n) : void 0;
|
|
2445
|
+
return this.#n.clear(t);
|
|
2437
2446
|
}
|
|
2438
2447
|
/**
|
|
2439
2448
|
* Remove files and directories
|
|
2440
2449
|
*/
|
|
2441
2450
|
async remove(n, t) {
|
|
2442
|
-
|
|
2451
|
+
const e = s(n);
|
|
2452
|
+
return this.#n.remove(e, t);
|
|
2443
2453
|
}
|
|
2444
2454
|
/**
|
|
2445
2455
|
* Resolve a path to an absolute path
|
|
2446
2456
|
*/
|
|
2447
2457
|
async realpath(n) {
|
|
2448
|
-
|
|
2458
|
+
const t = s(n);
|
|
2459
|
+
return this.#n.realpath(t);
|
|
2449
2460
|
}
|
|
2450
2461
|
/**
|
|
2451
2462
|
* Rename a file or directory
|
|
2452
2463
|
*/
|
|
2453
2464
|
async rename(n, t, e) {
|
|
2454
|
-
|
|
2465
|
+
const r = s(n), i = s(t);
|
|
2466
|
+
return this.#n.rename(r, i, e);
|
|
2455
2467
|
}
|
|
2456
2468
|
/**
|
|
2457
2469
|
* Copy files and directories
|
|
2458
2470
|
*/
|
|
2459
2471
|
async copy(n, t, e) {
|
|
2460
|
-
|
|
2472
|
+
const r = s(n), i = s(t);
|
|
2473
|
+
return this.#n.copy(r, i, e);
|
|
2461
2474
|
}
|
|
2462
2475
|
/**
|
|
2463
2476
|
* Start watching a file or directory for changes
|
|
2464
2477
|
*/
|
|
2465
2478
|
watch(n, t) {
|
|
2466
|
-
|
|
2479
|
+
const e = s(n);
|
|
2480
|
+
return this.#n.watch(e, t), () => this.unwatch(e);
|
|
2467
2481
|
}
|
|
2468
2482
|
/**
|
|
2469
2483
|
* Stop watching a previously watched path
|
|
2470
2484
|
*/
|
|
2471
2485
|
unwatch(n) {
|
|
2472
|
-
|
|
2486
|
+
const t = s(n);
|
|
2487
|
+
this.#n.unwatch(t);
|
|
2473
2488
|
}
|
|
2474
2489
|
/**
|
|
2475
2490
|
* Open a file and return a file descriptor
|
|
2476
2491
|
*/
|
|
2477
2492
|
async open(n, t) {
|
|
2478
|
-
|
|
2493
|
+
const e = s(n);
|
|
2494
|
+
return this.#n.open(e, t);
|
|
2479
2495
|
}
|
|
2480
2496
|
/**
|
|
2481
2497
|
* Close a file descriptor
|
|
@@ -2490,22 +2506,22 @@ class w {
|
|
|
2490
2506
|
* The buffer is transferred to the worker and back, so the original buffer
|
|
2491
2507
|
* becomes unusable after the call.
|
|
2492
2508
|
*/
|
|
2493
|
-
async read(n, t, e, r,
|
|
2494
|
-
const { bytesRead:
|
|
2509
|
+
async read(n, t, e, r, i) {
|
|
2510
|
+
const { bytesRead: o, buffer: d } = await this.#n.read(
|
|
2495
2511
|
n,
|
|
2496
2512
|
// Temp buffer to preserve the original buffer
|
|
2497
2513
|
new Uint8Array(r),
|
|
2498
2514
|
0,
|
|
2499
2515
|
r,
|
|
2500
|
-
|
|
2516
|
+
i
|
|
2501
2517
|
);
|
|
2502
|
-
return
|
|
2518
|
+
return o > 0 && t.set(d.subarray(0, o), e), { bytesRead: o, buffer: t };
|
|
2503
2519
|
}
|
|
2504
2520
|
/**
|
|
2505
2521
|
* Write data to a file descriptor
|
|
2506
2522
|
*/
|
|
2507
|
-
async write(n, t, e, r,
|
|
2508
|
-
return this.#n.write(n, t, e, r,
|
|
2523
|
+
async write(n, t, e, r, i, o) {
|
|
2524
|
+
return this.#n.write(n, t, e, r, i, o);
|
|
2509
2525
|
}
|
|
2510
2526
|
/**
|
|
2511
2527
|
* Get file status information by file descriptor
|
|
@@ -2534,72 +2550,73 @@ class w {
|
|
|
2534
2550
|
/**
|
|
2535
2551
|
* Synchronize the file system with external data
|
|
2536
2552
|
*/
|
|
2537
|
-
async
|
|
2538
|
-
|
|
2553
|
+
async createIndex(n) {
|
|
2554
|
+
const t = n.map(([e, r]) => [s(e), r]);
|
|
2555
|
+
return this.#n.createIndex(t);
|
|
2539
2556
|
}
|
|
2540
2557
|
/**
|
|
2541
2558
|
* Read a file as text with automatic encoding detection
|
|
2542
2559
|
*/
|
|
2543
2560
|
async readText(n, t = "utf-8") {
|
|
2544
|
-
const e = await this.#n.readFile(
|
|
2545
|
-
return
|
|
2561
|
+
const e = s(n), r = await this.#n.readFile(e);
|
|
2562
|
+
return l(r, t);
|
|
2546
2563
|
}
|
|
2547
2564
|
/**
|
|
2548
2565
|
* Write text to a file with specified encoding
|
|
2549
2566
|
*/
|
|
2550
2567
|
async writeText(n, t, e = "utf-8") {
|
|
2551
|
-
const r =
|
|
2552
|
-
return this.#n.writeFile(
|
|
2568
|
+
const r = s(n), i = h(t, e);
|
|
2569
|
+
return this.#n.writeFile(r, i);
|
|
2553
2570
|
}
|
|
2554
2571
|
/**
|
|
2555
2572
|
* Append text to a file with specified encoding
|
|
2556
2573
|
*/
|
|
2557
2574
|
async appendText(n, t, e = "utf-8") {
|
|
2558
|
-
const r =
|
|
2559
|
-
return this.#n.appendFile(
|
|
2575
|
+
const r = s(n), i = h(t, e);
|
|
2576
|
+
return this.#n.appendFile(r, i);
|
|
2560
2577
|
}
|
|
2561
2578
|
}
|
|
2562
|
-
function
|
|
2563
|
-
return new w(
|
|
2579
|
+
function b(a) {
|
|
2580
|
+
return new w(a);
|
|
2564
2581
|
}
|
|
2565
2582
|
export {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2583
|
+
x as BINARY_FILE_EXTENSIONS,
|
|
2584
|
+
S as DirectoryNotFoundError,
|
|
2585
|
+
P as FileNotFoundError,
|
|
2569
2586
|
F as OPFSError,
|
|
2570
2587
|
w as OPFSFileSystem,
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2588
|
+
O as OPFSNotMountedError,
|
|
2589
|
+
A as OPFSNotSupportedError,
|
|
2590
|
+
T as PathError,
|
|
2591
|
+
I as PermissionError,
|
|
2592
|
+
R as StorageError,
|
|
2576
2593
|
$ as TimeoutError,
|
|
2577
|
-
|
|
2594
|
+
_ as basename,
|
|
2578
2595
|
C as buffersEqual,
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2596
|
+
N as calculateFileHash,
|
|
2597
|
+
D as calculateReadLength,
|
|
2598
|
+
z as checkOPFSSupport,
|
|
2582
2599
|
k as convertBlobToUint8Array,
|
|
2583
2600
|
M as createBuffer,
|
|
2584
2601
|
L as createFDError,
|
|
2585
2602
|
j as createSyncHandleSafe,
|
|
2586
|
-
|
|
2587
|
-
|
|
2603
|
+
b as createWorker,
|
|
2604
|
+
l as decodeBuffer,
|
|
2588
2605
|
W as dirname,
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2606
|
+
h as encodeString,
|
|
2607
|
+
U as extname,
|
|
2608
|
+
c as isBinaryFileExtension,
|
|
2609
|
+
H as isPathExcluded,
|
|
2610
|
+
B as joinPath,
|
|
2611
|
+
G as mapDomError,
|
|
2612
|
+
q as matchMinimatch,
|
|
2613
|
+
V as normalizeMinimatch,
|
|
2614
|
+
Y as normalizePath,
|
|
2615
|
+
X as removeEntry,
|
|
2616
|
+
Z as resolvePath,
|
|
2617
|
+
J as safeCloseSyncHandle,
|
|
2618
|
+
K as splitPath,
|
|
2619
|
+
Q as validateReadWriteArgs,
|
|
2620
|
+
nn as withLock
|
|
2604
2621
|
};
|
|
2605
2622
|
//# sourceMappingURL=index.js.map
|