opfs-worker 0.5.1 → 1.0.1

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/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { wrap as i } from "comlink";
2
- import { B as p, D as f, F as d, O as u, b as g, a as m, P as w, c as y, S as b, T as v, e as x, t as S, q as E, d as A, u as P, l as F, y as O, f as C, x as T, k as R, i as $, h as _, j as D, m as I, g as j, n as N, o as M, v as k, r as L, s as z, w as U, p as W } from "./helpers-DcIl7KL0.js";
2
+ import { B as p, D as f, F as d, O as u, b as g, a as m, P as w, c as y, S as b, T as v, e as x, t as S, q as E, d as P, u as A, l as F, y as O, f as C, x as T, k as R, i as $, h as _, j as D, m as I, g as j, n as N, o as M, v as k, r as L, s as z, w as W, p as U } from "./helpers-CTCvNFs1.js";
3
3
  const r = `/**
4
4
  * @license
5
5
  * Copyright 2019 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
- 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", Ft = {
8
+ 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 = {
9
9
  canHandle: (s) => ft(s) && s[ut],
10
10
  serialize(s) {
11
11
  const { port1: t, port2: e } = new MessageChannel();
@@ -14,7 +14,7 @@ const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol
14
14
  deserialize(s) {
15
15
  return s.start(), Pt(s);
16
16
  }
17
- }, Tt = {
17
+ }, Ft = {
18
18
  canHandle: (s) => ft(s) && L in s,
19
19
  serialize({ value: s }) {
20
20
  let t;
@@ -31,8 +31,8 @@ const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol
31
31
  throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
32
32
  }
33
33
  }, dt = /* @__PURE__ */ new Map([
34
- ["proxy", Ft],
35
- ["throw", Tt]
34
+ ["proxy", Tt],
35
+ ["throw", Ft]
36
36
  ]);
37
37
  function Mt(s, t) {
38
38
  for (const e of s)
@@ -298,13 +298,12 @@ function _t(s, t = "utf-8") {
298
298
  case "utf-8":
299
299
  return new TextDecoder().decode(s);
300
300
  case "utf16le":
301
+ case "utf-16le":
301
302
  case "ucs2":
302
303
  case "ucs-2":
303
304
  return Gt(s);
304
305
  case "latin1":
305
306
  return String.fromCharCode(...s);
306
- case "binary":
307
- return String.fromCharCode(...s);
308
307
  case "ascii":
309
308
  return String.fromCharCode(...s.map((e) => e & 127));
310
309
  case "base64":
@@ -370,17 +369,17 @@ const wt = (s, t, e) => {
370
369
  n.length && o !== void 0 && (a = [r, o]);
371
370
  }
372
371
  return a;
373
- }, yt = "\\0SLASH" + Math.random() + "\\0", Et = "\\0OPEN" + Math.random() + "\\0", K = "\\0CLOSE" + Math.random() + "\\0", St = "\\0COMMA" + Math.random() + "\\0", bt = "\\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(bt, "g"), te = /\\\\\\\\/g, ee = /\\\\{/g, se = /\\\\}/g, ne = /\\\\,/g, ie = /\\\\./g;
372
+ }, 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;
374
373
  function B(s) {
375
374
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
376
375
  }
377
376
  function re(s) {
378
- return s.replace(te, yt).replace(ee, Et).replace(se, K).replace(ne, St).replace(ie, bt);
377
+ return s.replace(te, yt).replace(ee, Et).replace(se, K).replace(ne, St).replace(ie, xt);
379
378
  }
380
379
  function oe(s) {
381
380
  return s.replace(Yt, "\\\\").replace(Zt, "{").replace(Jt, "}").replace(Kt, ",").replace(Qt, ".");
382
381
  }
383
- function xt(s) {
382
+ function bt(s) {
384
383
  if (!s)
385
384
  return [""];
386
385
  const t = [], e = wt("{", "}", s);
@@ -388,7 +387,7 @@ function xt(s) {
388
387
  return s.split(",");
389
388
  const { pre: n, body: i, post: r } = e, o = n.split(",");
390
389
  o[o.length - 1] += "{" + i + "}";
391
- const a = xt(r);
390
+ const a = bt(r);
392
391
  return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
393
392
  }
394
393
  function ae(s) {
@@ -423,7 +422,7 @@ function M(s, t) {
423
422
  let c;
424
423
  if (l)
425
424
  c = n.body.split(/\\.\\./);
426
- else if (c = xt(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(ce), c.length === 1))
425
+ else if (c = bt(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(ce), c.length === 1))
427
426
  return r.map((u) => n.pre + c[0] + u);
428
427
  let f;
429
428
  if (l && c[0] !== void 0 && c[1] !== void 0) {
@@ -432,15 +431,15 @@ function M(s, t) {
432
431
  d < u && (p *= -1, S = ue);
433
432
  const N = c.some(le);
434
433
  f = [];
435
- for (let b = u; S(b, d); b += p) {
434
+ for (let x = u; S(x, d); x += p) {
436
435
  let w;
437
436
  if (a)
438
- w = String.fromCharCode(b), w === "\\\\" && (w = "");
439
- else if (w = String(b), N) {
440
- const F = m - w.length;
441
- if (F > 0) {
442
- const P = new Array(F + 1).join("0");
443
- b < 0 ? w = "-" + P + w.slice(1) : w = P + w;
437
+ w = String.fromCharCode(x), w === "\\\\" && (w = "");
438
+ else if (w = String(x), N) {
439
+ const T = m - w.length;
440
+ if (T > 0) {
441
+ const P = new Array(T + 1).join("0");
442
+ x < 0 ? w = "-" + P + w.slice(1) : w = P + w;
444
443
  }
445
444
  }
446
445
  f.push(w);
@@ -478,7 +477,7 @@ const fe = 1024 * 64, W = (s) => {
478
477
  "[:upper:]": ["\\\\p{Lu}", !0],
479
478
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
480
479
  "[:xdigit:]": ["A-Fa-f0-9", !1]
481
- }, T = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), it = (s) => s.join(""), ge = (s, t) => {
480
+ }, F = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), it = (s) => s.join(""), ge = (s, t) => {
482
481
  const e = t;
483
482
  if (s.charAt(e) !== "[")
484
483
  throw new Error("not in a brace expression");
@@ -499,27 +498,27 @@ const fe = 1024 * 64, W = (s) => {
499
498
  continue;
500
499
  }
501
500
  if (p === "[" && !l) {
502
- for (const [S, [v, N, b]] of Object.entries(de))
501
+ for (const [S, [A, N, x]] of Object.entries(de))
503
502
  if (s.startsWith(S, r)) {
504
503
  if (f)
505
504
  return ["$.", !1, s.length - e, !0];
506
- r += S.length, b ? i.push(v) : n.push(v), a = a || N;
505
+ r += S.length, x ? i.push(A) : n.push(A), a = a || N;
507
506
  continue t;
508
507
  }
509
508
  }
510
509
  if (l = !1, f) {
511
- p > f ? n.push(T(f) + "-" + T(p)) : p === f && n.push(T(p)), f = "", r++;
510
+ p > f ? n.push(F(f) + "-" + F(p)) : p === f && n.push(F(p)), f = "", r++;
512
511
  continue;
513
512
  }
514
513
  if (s.startsWith("-]", r + 1)) {
515
- n.push(T(p + "-")), r += 2;
514
+ n.push(F(p + "-")), r += 2;
516
515
  continue;
517
516
  }
518
517
  if (s.startsWith("-", r + 1)) {
519
518
  f = p, r += 2;
520
519
  continue;
521
520
  }
522
- n.push(T(p)), r++;
521
+ n.push(F(p)), r++;
523
522
  }
524
523
  if (c < r)
525
524
  return ["", !1, 0, !1];
@@ -531,7 +530,7 @@ const fe = 1024 * 64, W = (s) => {
531
530
  }
532
531
  const u = "[" + (h ? "^" : "") + it(n) + "]", d = "[" + (h ? "" : "^") + it(i) + "]";
533
532
  return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
534
- }, $ = (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("().*{}+?[]^$\\\\!"), be = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), Q = "[^/]", ot = Q + "*?", at = Q + "+?";
533
+ }, $ = (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 + "+?";
535
534
  class E {
536
535
  type;
537
536
  #s;
@@ -784,8 +783,8 @@ class E {
784
783
  const e = t ?? !!this.#i.dot;
785
784
  if (this.#s === this && this.#d(), !this.type) {
786
785
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
787
- const [m, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
788
- return this.#n = this.#n || S, this.#r = this.#r || v, m;
786
+ const [m, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
787
+ return this.#n = this.#n || S, this.#r = this.#r || A, m;
789
788
  }).join("");
790
789
  let c = "";
791
790
  if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Ee.has(this.#t[0]))) {
@@ -865,27 +864,27 @@ class E {
865
864
  r += Q, e = !0;
866
865
  continue;
867
866
  }
868
- r += be(l);
867
+ r += xe(l);
869
868
  }
870
869
  return [r, $(t), !!e, o];
871
870
  }
872
871
  }
873
- const xe = (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)), Ae = /^\\*+([^+@!?\\*\\[\\(]*)$/, ve = (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 = /^\\*+\\.\\*+$/, Fe = (s) => !s.startsWith(".") && s.includes("."), Te = (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 = ""]) => {
874
- const e = At([s]);
872
+ 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 = ""]) => {
873
+ const e = vt([s]);
875
874
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
876
875
  }, ze = ([s, t = ""]) => {
877
- const e = vt([s]);
876
+ const e = At([s]);
878
877
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
879
878
  }, He = ([s, t = ""]) => {
880
- const e = vt([s]);
879
+ const e = At([s]);
881
880
  return t ? (n) => e(n) && n.endsWith(t) : e;
882
881
  }, We = ([s, t = ""]) => {
883
- const e = At([s]);
882
+ const e = vt([s]);
884
883
  return t ? (n) => e(n) && n.endsWith(t) : e;
885
- }, At = ([s]) => {
884
+ }, vt = ([s]) => {
886
885
  const t = s.length;
887
886
  return (e) => e.length === t && !e.startsWith(".");
888
- }, vt = ([s]) => {
887
+ }, At = ([s]) => {
889
888
  const t = s.length;
890
889
  return (e) => e.length === t && e !== "." && e !== "..";
891
890
  }, Ct = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ct = {
@@ -893,42 +892,42 @@ const xe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
893
892
  posix: { sep: "/" }
894
893
  }, je = Ct === "win32" ? ct.win32.sep : ct.posix.sep;
895
894
  y.sep = je;
896
- const A = Symbol("globstar **");
897
- y.GLOBSTAR = A;
895
+ const v = Symbol("globstar **");
896
+ y.GLOBSTAR = v;
898
897
  const Ue = "[^/]", _e = Ue + "*?", Be = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ge = "(?:(?!(?:\\\\/|^)\\\\.).)*?", qe = (s, t = {}) => (e) => y(e, s, t);
899
898
  y.filter = qe;
900
- const x = (s, t = {}) => Object.assign({}, s, t), Ve = (s) => {
899
+ const b = (s, t = {}) => Object.assign({}, s, t), Ve = (s) => {
901
900
  if (!s || typeof s != "object" || !Object.keys(s).length)
902
901
  return y;
903
902
  const t = y;
904
- return Object.assign((n, i, r = {}) => t(n, i, x(s, r)), {
903
+ return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
905
904
  Minimatch: class extends t.Minimatch {
906
905
  constructor(i, r = {}) {
907
- super(i, x(s, r));
906
+ super(i, b(s, r));
908
907
  }
909
908
  static defaults(i) {
910
- return t.defaults(x(s, i)).Minimatch;
909
+ return t.defaults(b(s, i)).Minimatch;
911
910
  }
912
911
  },
913
912
  AST: class extends t.AST {
914
913
  /* c8 ignore start */
915
914
  constructor(i, r, o = {}) {
916
- super(i, r, x(s, o));
915
+ super(i, r, b(s, o));
917
916
  }
918
917
  /* c8 ignore stop */
919
918
  static fromGlob(i, r = {}) {
920
- return t.AST.fromGlob(i, x(s, r));
919
+ return t.AST.fromGlob(i, b(s, r));
921
920
  }
922
921
  },
923
- unescape: (n, i = {}) => t.unescape(n, x(s, i)),
924
- escape: (n, i = {}) => t.escape(n, x(s, i)),
925
- filter: (n, i = {}) => t.filter(n, x(s, i)),
926
- defaults: (n) => t.defaults(x(s, n)),
927
- makeRe: (n, i = {}) => t.makeRe(n, x(s, i)),
928
- braceExpand: (n, i = {}) => t.braceExpand(n, x(s, i)),
929
- match: (n, i, r = {}) => t.match(n, i, x(s, r)),
922
+ unescape: (n, i = {}) => t.unescape(n, b(s, i)),
923
+ escape: (n, i = {}) => t.escape(n, b(s, i)),
924
+ filter: (n, i = {}) => t.filter(n, b(s, i)),
925
+ defaults: (n) => t.defaults(b(s, n)),
926
+ makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
927
+ braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
928
+ match: (n, i, r = {}) => t.match(n, i, b(s, r)),
930
929
  sep: t.sep,
931
- GLOBSTAR: A
930
+ GLOBSTAR: v
932
931
  });
933
932
  };
934
933
  y.defaults = Ve;
@@ -1169,10 +1168,10 @@ class j {
1169
1168
  matchOne(t, e, n = !1) {
1170
1169
  const i = this.options;
1171
1170
  if (this.isWindows) {
1172
- const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), N = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), b = S ? 3 : p ? 0 : void 0, w = N ? 3 : v ? 0 : void 0;
1173
- if (typeof b == "number" && typeof w == "number") {
1174
- const [F, P] = [t[b], e[w]];
1175
- F.toLowerCase() === P.toLowerCase() && (e[w] = F, w > b ? e = e.slice(w) : b > w && (t = t.slice(b)));
1171
+ 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;
1172
+ if (typeof x == "number" && typeof w == "number") {
1173
+ const [T, P] = [t[x], e[w]];
1174
+ T.toLowerCase() === P.toLowerCase() && (e[w] = T, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
1176
1175
  }
1177
1176
  }
1178
1177
  const { optimizationLevel: r = 1 } = this.options;
@@ -1182,7 +1181,7 @@ class j {
1182
1181
  var c = e[a], f = t[o];
1183
1182
  if (this.debug(e, c, f), c === !1)
1184
1183
  return !1;
1185
- if (c === A) {
1184
+ if (c === v) {
1186
1185
  this.debug("GLOBSTAR", [e, c, f]);
1187
1186
  var u = o, d = a + 1;
1188
1187
  if (d === h) {
@@ -1224,11 +1223,11 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1224
1223
  W(t);
1225
1224
  const e = this.options;
1226
1225
  if (t === "**")
1227
- return A;
1226
+ return v;
1228
1227
  if (t === "")
1229
1228
  return "";
1230
1229
  let n, i = null;
1231
- (n = t.match(Pe)) ? i = e.dot ? ke : Re : (n = t.match(Ae)) ? i = (e.nocase ? e.dot ? De : Oe : e.dot ? Ce : ve)(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 ? Te : Fe : (n = t.match(Me)) && (i = $e);
1230
+ (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);
1232
1231
  const r = E.fromGlob(t, this.options).toMMPattern();
1233
1232
  return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1234
1233
  }
@@ -1244,12 +1243,12 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1244
1243
  if (c instanceof RegExp)
1245
1244
  for (const f of c.flags.split(""))
1246
1245
  i.add(f);
1247
- return typeof c == "string" ? Ze(c) : c === A ? A : c._src;
1246
+ return typeof c == "string" ? Ze(c) : c === v ? v : c._src;
1248
1247
  });
1249
1248
  return h.forEach((c, f) => {
1250
1249
  const u = h[f + 1], d = h[f - 1];
1251
- c !== A || d === A || (d === void 0 ? u !== void 0 && u !== A ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== A && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = A));
1252
- }), h.filter((c) => c !== A).join("/");
1250
+ 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));
1251
+ }), h.filter((c) => c !== v).join("/");
1253
1252
  }).join("|");
1254
1253
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1255
1254
  r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
@@ -1294,7 +1293,7 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1294
1293
  }
1295
1294
  y.AST = E;
1296
1295
  y.Minimatch = j;
1297
- y.escape = xe;
1296
+ y.escape = be;
1298
1297
  y.unescape = $;
1299
1298
  const Je = [
1300
1299
  // Images
@@ -1448,6 +1447,7 @@ async function rs(s, t, e = {}) {
1448
1447
  const n = Y(t);
1449
1448
  return tt(t, "exclusive", async () => {
1450
1449
  const i = e.recursive ?? !1, r = e.force ?? !1;
1450
+ e.useTrash;
1451
1451
  try {
1452
1452
  await s.removeEntry(n, { recursive: i });
1453
1453
  } catch (o) {
@@ -1460,7 +1460,7 @@ async function rs(s, t, e = {}) {
1460
1460
  }
1461
1461
  class os {
1462
1462
  /** Root directory handle for the file system */
1463
- root = null;
1463
+ root;
1464
1464
  /** Map of watched paths and options */
1465
1465
  watchers = /* @__PURE__ */ new Map();
1466
1466
  /** Promise to prevent concurrent mount operations */
@@ -1543,13 +1543,14 @@ class os {
1543
1543
  * await fs.mount('/my-app');
1544
1544
  * \`\`\`
1545
1545
  */
1546
- async mount(t = this.options.root) {
1547
- return this.mountingPromise && await this.mountingPromise, t = Z(t), this.mountingPromise = new Promise(async (e, n) => {
1546
+ async mount() {
1547
+ const t = this.options.root;
1548
+ return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1548
1549
  try {
1549
1550
  const i = await navigator.storage.getDirectory();
1550
- t === "/" ? this.root = i : this.root = await this.getDirectoryHandle(t, !0, i), e(!0);
1551
- } catch {
1552
- n(new g("Failed to initialize OPFS", "INIT_FAILED"));
1551
+ this.root = t === "/" ? i : await this.getDirectoryHandle(t, !0, i), e(!0);
1552
+ } catch (i) {
1553
+ n(new g("Failed to initialize OPFS", "INIT_FAILED", t, i));
1553
1554
  } finally {
1554
1555
  this.mountingPromise = null;
1555
1556
  }
@@ -1566,7 +1567,7 @@ class os {
1566
1567
  * @param options.broadcastChannel - Custom name for the broadcast channel
1567
1568
  */
1568
1569
  async setOptions(t) {
1569
- 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(this.options.root));
1570
+ 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());
1570
1571
  }
1571
1572
  /**
1572
1573
  * Get a directory handle from a path
@@ -1601,7 +1602,7 @@ class os {
1601
1602
  *
1602
1603
  * @param path - The path to the file (string or array of segments)
1603
1604
  * @param create - Whether to create the file if it doesn't exist (default: false)
1604
- * @param from - The directory to start from (default: root directory)
1605
+ * @param _from - The directory to start from (default: root directory)
1605
1606
  * @returns Promise that resolves to the file handle
1606
1607
  * @throws {PathError} If the path is empty
1607
1608
  * @throws {OPFSError} If the file cannot be accessed or created
@@ -1663,7 +1664,7 @@ class os {
1663
1664
  async readFile(t, e) {
1664
1665
  await this.mount(), e || (e = G(t) ? "binary" : "utf-8");
1665
1666
  try {
1666
- const n = await this.getFileHandle(t, !1), i = await ss(n, t);
1667
+ const n = await this.getFileHandle(t, !1, this.root), i = await ss(n, t);
1667
1668
  return e === "binary" ? i : _t(i, e);
1668
1669
  } catch (n) {
1669
1670
  throw new _(t, n);
@@ -1887,7 +1888,8 @@ class os {
1887
1888
  try {
1888
1889
  n = await this.getDirectoryHandle(q(t), !1);
1889
1890
  } catch (i) {
1890
- throw (i.name === "NotFoundError" || i.name === "TypeMismatchError") && (n = null), i;
1891
+ if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1892
+ throw i;
1891
1893
  }
1892
1894
  if (!n || !e)
1893
1895
  return !1;
@@ -1964,8 +1966,8 @@ class os {
1964
1966
  async remove(t, e) {
1965
1967
  if (await this.mount(), t === "/")
1966
1968
  throw new g("Cannot remove root directory", "EROOT");
1967
- const n = await this.getDirectoryHandle(q(t), !1);
1968
- await rs(n, t, e), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
1969
+ const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(q(t), !1);
1970
+ await rs(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
1969
1971
  }
1970
1972
  /**
1971
1973
  * Resolve a path to an absolute path
@@ -2000,26 +2002,35 @@ class os {
2000
2002
  * Rename a file or directory
2001
2003
  *
2002
2004
  * Changes the name of a file or directory. If the target path already exists,
2003
- * it will be replaced.
2005
+ * it will be replaced only if overwrite option is enabled.
2004
2006
  *
2005
2007
  * @param oldPath - The current path of the file or directory
2006
2008
  * @param newPath - The new path for the file or directory
2009
+ * @param options - Options for renaming
2010
+ * @param options.overwrite - Whether to overwrite existing files (default: false)
2007
2011
  * @returns Promise that resolves when the rename operation is complete
2008
2012
  * @throws {OPFSError} If the rename operation fails
2009
2013
  *
2010
2014
  * @example
2011
2015
  * \`\`\`typescript
2016
+ * // Basic rename (fails if target exists)
2012
2017
  * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt');
2018
+ *
2019
+ * // Rename with overwrite
2020
+ * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
2013
2021
  * \`\`\`
2014
2022
  */
2015
- async rename(t, e) {
2023
+ async rename(t, e, n) {
2016
2024
  await this.mount();
2017
2025
  try {
2026
+ const i = n?.overwrite ?? !1;
2018
2027
  if (!await this.exists(t))
2019
2028
  throw new _(t);
2020
- await this.copy(t, e, { recursive: !0 }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 }), await this.notifyChange({ path: e, type: "added", isDirectory: !1 });
2021
- } catch (n) {
2022
- throw n instanceof g ? n : new g(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, n);
2029
+ if (await this.exists(e) && !i)
2030
+ throw new g(\`Destination already exists: \${e}\`, "EEXIST", void 0);
2031
+ 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 });
2032
+ } catch (i) {
2033
+ throw i instanceof g ? i : new g(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
2023
2034
  }
2024
2035
  }
2025
2036
  /**
@@ -2031,7 +2042,7 @@ class os {
2031
2042
  * @param destination - The destination path to copy to
2032
2043
  * @param options - Options for copying
2033
2044
  * @param options.recursive - Whether to copy directories recursively (default: false)
2034
- * @param options.force - Whether to overwrite existing files (default: true)
2045
+ * @param options.overwrite - Whether to overwrite existing files (default: true)
2035
2046
  * @returns Promise that resolves when the copy operation is complete
2036
2047
  * @throws {OPFSError} If the copy operation fails
2037
2048
  *
@@ -2044,13 +2055,13 @@ class os {
2044
2055
  * await fs.copy('/source/dir', '/dest/dir', { recursive: true });
2045
2056
  *
2046
2057
  * // Copy without overwriting existing files
2047
- * await fs.copy('/source', '/dest', { recursive: true, force: false });
2058
+ * await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
2048
2059
  * \`\`\`
2049
2060
  */
2050
2061
  async copy(t, e, n) {
2051
2062
  await this.mount();
2052
2063
  try {
2053
- const i = n?.recursive ?? !1, r = n?.force ?? !0;
2064
+ const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
2054
2065
  if (!await this.exists(t))
2055
2066
  throw new g(\`Source does not exist: \${t}\`, "ENOENT", void 0);
2056
2067
  if (await this.exists(e) && !r)
@@ -2065,7 +2076,7 @@ class os {
2065
2076
  const h = await this.readDir(t);
2066
2077
  for (const c of h) {
2067
2078
  const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2068
- await this.copy(f, u, { recursive: !0, force: r });
2079
+ await this.copy(f, u, { recursive: !0, overwrite: r });
2069
2080
  }
2070
2081
  }
2071
2082
  } catch (i) {
@@ -2165,7 +2176,7 @@ class os {
2165
2176
  }
2166
2177
  }
2167
2178
  typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && J(new os());
2168
- //# sourceMappingURL=worker-DYhMhDRt.js.map
2179
+ //# sourceMappingURL=worker-CccfxYdr.js.map
2169
2180
  `, s = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", r], { type: "text/javascript;charset=utf-8" });
2170
2181
  function o(n) {
2171
2182
  let t;
@@ -2206,8 +2217,8 @@ export {
2206
2217
  x as basename,
2207
2218
  S as buffersEqual,
2208
2219
  E as calculateFileHash,
2209
- A as checkOPFSSupport,
2210
- P as convertBlobToUint8Array,
2220
+ P as checkOPFSSupport,
2221
+ A as convertBlobToUint8Array,
2211
2222
  F as createBuffer,
2212
2223
  h as createWorker,
2213
2224
  O as decodeBuffer,
@@ -2224,7 +2235,7 @@ export {
2224
2235
  k as removeEntry,
2225
2236
  L as resolvePath,
2226
2237
  z as splitPath,
2227
- U as withLock,
2228
- W as writeFileData
2238
+ W as withLock,
2239
+ U as writeFileData
2229
2240
  };
2230
2241
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,eAAsBA,EAClBC,GACyB;AACzB,QAAMC,IAAUC,EAAiB,IAAIC,GAAY;AAGjD,SAAIH,MAEIA,EAAQ,oBAAoBA,EAAQ,4BAA4B,qBAChEA,EAAQ,mBAAmBA,EAAQ,iBAAiB,OAGxD,MAAMC,EAAQ,WAAWD,CAAO,IAG7BC;AACX;"}
1
+ {"version":3,"file":"index.js","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,eAAsBA,EAClBC,GACyB;AACzB,QAAMC,IAAUC,EAAiB,IAAIC,GAAY;AAGjD,SAAIH,MAEIA,EAAQ,oBAAoBA,EAAQ,4BAA4B,qBAChEA,EAAQ,mBAAmBA,EAAQ,iBAAiB,OAGxD,MAAMC,EAAQ,WAAWD,CAAO,IAG7BC;AACX;"}
package/dist/raw.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("comlink"),i=require("./helpers-BfBe8lFJ.cjs");class w{root=null;watchers=new Map;mountingPromise=null;broadcastChannel=null;options={root:"/",namespace:"",maxFileSize:50*1024*1024,hashAlgorithm:null,broadcastChannel:"opfs-worker"};async notifyChange(t){if(!this.options.broadcastChannel)return;const e=t.path;if(![...this.watchers.values()].some(s=>i.matchMinimatch(e,s.pattern)&&s.include.some(o=>o&&i.matchMinimatch(e,o))&&!s.exclude.some(o=>o&&i.matchMinimatch(e,o))))return;let a;if(this.options.hashAlgorithm)try{a=(await this.stat(e)).hash}catch{}try{this.broadcastChannel||(this.broadcastChannel=new BroadcastChannel(this.options.broadcastChannel));const s={namespace:this.options.namespace,timestamp:new Date().toISOString(),...t,...a&&{hash:a}};this.broadcastChannel.postMessage(s)}catch(s){console.warn("Failed to send event via BroadcastChannel:",s)}}constructor(t){i.checkOPFSSupport(),t&&this.setOptions(t)}async mount(t=this.options.root){return this.mountingPromise&&await this.mountingPromise,t=i.normalizePath(t),this.mountingPromise=new Promise(async(e,r)=>{try{const a=await navigator.storage.getDirectory();t==="/"?this.root=a:this.root=await this.getDirectoryHandle(t,!0,a),e(!0)}catch{r(new i.OPFSError("Failed to initialize OPFS","INIT_FAILED"))}finally{this.mountingPromise=null}}),this.mountingPromise}async setOptions(t){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(this.options.root))}async getDirectoryHandle(t,e=!1,r=this.root){const a=Array.isArray(t)?t:i.splitPath(t);let s=r;for(const o of a)s=await s.getDirectoryHandle(o,{create:e});return s}async getFileHandle(t,e=!1,r=this.root){const a=i.splitPath(t);if(a.length===0)throw new i.PathError("Path must not be empty",Array.isArray(t)?t.join("/"):t);const s=a.pop();return(await this.getDirectoryHandle(a,e,r)).getFileHandle(s,{create:e})}async index(){const t=new Map,e=async r=>{const a=await this.readDir(r);for(const s of a){const o=`${r==="/"?"":r}/${s.name}`;try{const n=await this.stat(o);t.set(o,n),n.isDirectory&&await e(o)}catch(n){console.warn(`Skipping broken entry: ${o}`,n)}}};return t.set("/",{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}),await e("/"),t}async readFile(t,e){await this.mount(),e||(e=i.isBinaryFileExtension(t)?"binary":"utf-8");try{const r=await this.getFileHandle(t,!1),a=await i.readFileData(r,t);return e==="binary"?a:i.decodeBuffer(a,e)}catch(r){throw new i.FileNotFoundError(t,r)}}async writeFile(t,e,r){await this.mount();const a=await this.exists(t),s=await this.getFileHandle(t,!0);r||(r=typeof e!="string"||i.isBinaryFileExtension(t)?"binary":"utf-8"),await i.writeFileData(s,e,r,t),a?await this.notifyChange({path:t,type:"changed",isDirectory:!1}):await this.notifyChange({path:t,type:"added",isDirectory:!1})}async appendFile(t,e,r){await this.mount();const a=await this.getFileHandle(t,!0);r||(r=typeof e!="string"||i.isBinaryFileExtension(t)?"binary":"utf-8"),await i.writeFileData(a,e,r,t,{append:!0}),await this.notifyChange({path:t,type:"changed",isDirectory:!1})}async mkdir(t,e){await this.mount();const r=e?.recursive??!1,a=i.splitPath(t);let s=this.root;for(let o=0;o<a.length;o++){const n=a[o];try{s=await s.getDirectoryHandle(n,{create:r||o===a.length-1})}catch(c){throw c.name==="NotFoundError"?new i.OPFSError(`Parent directory does not exist: ${i.joinPath(a.slice(0,o+1))}`,"ENOENT",void 0,c):c.name==="TypeMismatchError"?new i.OPFSError(`Path segment is not a directory: ${n}`,"ENOTDIR",void 0,c):new i.OPFSError("Failed to create directory","MKDIR_FAILED",void 0,c)}}await this.notifyChange({path:t,type:"added",isDirectory:!0})}async stat(t){if(await this.mount(),t==="/")return{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0};const e=i.basename(t),r=await this.getDirectoryHandle(i.dirname(t),!1),a=this.options.hashAlgorithm!==null;try{const o=await(await r.getFileHandle(e,{create:!1})).getFile(),n={kind:"file",size:o.size,mtime:new Date(o.lastModified).toISOString(),ctime:new Date(o.lastModified).toISOString(),isFile:!0,isDirectory:!1};if(a&&this.options.hashAlgorithm)try{const c=await i.calculateFileHash(o,this.options.hashAlgorithm,this.options.maxFileSize);n.hash=c}catch(c){console.warn(`Failed to calculate hash for ${t}:`,c)}return n}catch(s){if(s.name!=="TypeMismatchError"&&s.name!=="NotFoundError")throw new i.OPFSError("Failed to stat (file)","STAT_FAILED",void 0,s)}try{return await r.getDirectoryHandle(e,{create:!1}),{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}}catch(s){throw s.name==="NotFoundError"?new i.OPFSError(`No such file or directory: ${t}`,"ENOENT",void 0,s):new i.OPFSError("Failed to stat (directory)","STAT_FAILED",void 0,s)}}async readDir(t){await this.mount();const e=await this.getDirectoryHandle(t,!1),r=[];for await(const[a,s]of e.entries()){const o=s.kind==="file";r.push({name:a,kind:s.kind,isFile:o,isDirectory:!o})}return r}async exists(t){if(await this.mount(),t==="/")return!0;const e=i.basename(t);let r=null;try{r=await this.getDirectoryHandle(i.dirname(t),!1)}catch(a){throw(a.name==="NotFoundError"||a.name==="TypeMismatchError")&&(r=null),a}if(!r||!e)return!1;try{return await r.getFileHandle(e,{create:!1}),!0}catch(a){if(a.name!=="NotFoundError"&&a.name!=="TypeMismatchError")throw a;try{return await r.getDirectoryHandle(e,{create:!1}),!0}catch(s){if(s.name!=="NotFoundError"&&s.name!=="TypeMismatchError")throw s;return!1}}}async clear(t="/"){await this.mount();try{const e=await this.readDir(t);for(const r of e){const a=`${t==="/"?"":t}/${r.name}`;await this.remove(a,{recursive:!0})}await this.notifyChange({path:t,type:"changed",isDirectory:!0})}catch(e){throw e instanceof i.OPFSError?e:new i.OPFSError(`Failed to clear directory: ${t}`,"CLEAR_FAILED",void 0,e)}}async remove(t,e){if(await this.mount(),t==="/")throw new i.OPFSError("Cannot remove root directory","EROOT");const r=await this.getDirectoryHandle(i.dirname(t),!1);await i.removeEntry(r,t,e),await this.notifyChange({path:t,type:"removed",isDirectory:!1})}async realpath(t){await this.mount();try{const e=i.resolvePath(t);if(!await this.exists(e))throw new i.FileNotFoundError(e);return e}catch(e){throw e instanceof i.OPFSError?e:new i.OPFSError(`Failed to resolve path: ${t}`,"REALPATH_FAILED",void 0,e)}}async rename(t,e){await this.mount();try{if(!await this.exists(t))throw new i.FileNotFoundError(t);await this.copy(t,e,{recursive:!0}),await this.remove(t,{recursive:!0}),await this.notifyChange({path:t,type:"removed",isDirectory:!1}),await this.notifyChange({path:e,type:"added",isDirectory:!1})}catch(r){throw r instanceof i.OPFSError?r:new i.OPFSError(`Failed to rename from ${t} to ${e}`,"RENAME_FAILED",void 0,r)}}async copy(t,e,r){await this.mount();try{const a=r?.recursive??!1,s=r?.force??!0;if(!await this.exists(t))throw new i.OPFSError(`Source does not exist: ${t}`,"ENOENT",void 0);if(await this.exists(e)&&!s)throw new i.OPFSError(`Destination already exists: ${e}`,"EEXIST",void 0);if((await this.stat(t)).isFile){const l=await this.readFile(t,"binary");await this.writeFile(e,l)}else{if(!a)throw new i.OPFSError(`Cannot copy directory without recursive option: ${t}`,"EISDIR",void 0);await this.mkdir(e,{recursive:!0});const l=await this.readDir(t);for(const h of l){const d=`${t}/${h.name}`,f=`${e}/${h.name}`;await this.copy(d,f,{recursive:!0,force:s})}}}catch(a){throw a instanceof i.OPFSError?a:new i.OPFSError(`Failed to copy from ${t} to ${e}`,"CP_FAILED",void 0,a)}}async watch(t,e){if(!this.options.broadcastChannel)throw new i.OPFSError("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.","ENOENT");const r={pattern:i.normalizeMinimatch(t,e?.recursive??!0),include:Array.isArray(e?.include)?e.include:[e?.include??"**"],exclude:Array.isArray(e?.exclude)?e.exclude:[e?.exclude??""]};this.watchers.set(t,r)}unwatch(t){this.watchers.delete(t)}dispose(){this.broadcastChannel&&(this.broadcastChannel.close(),this.broadcastChannel=null),this.watchers.clear()}async sync(t,e){await this.mount();try{(e?.cleanBefore??!1)&&await this.clear("/");for(const[a,s]of t){const o=i.normalizePath(a);let n;s instanceof Blob?n=await i.convertBlobToUint8Array(s):n=s,await this.writeFile(o,n)}}catch(r){throw r instanceof i.OPFSError?r:new i.OPFSError("Failed to sync file system","SYNC_FAILED",void 0,r)}}}typeof globalThis<"u"&&globalThis.constructor.name==="DedicatedWorkerGlobalScope"&&m.expose(new w);exports.OPFSWorker=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("comlink"),i=require("./helpers-Cvjm0f_r.cjs");class w{root;watchers=new Map;mountingPromise=null;broadcastChannel=null;options={root:"/",namespace:"",maxFileSize:50*1024*1024,hashAlgorithm:null,broadcastChannel:"opfs-worker"};async notifyChange(t){if(!this.options.broadcastChannel)return;const e=t.path;if(![...this.watchers.values()].some(s=>i.matchMinimatch(e,s.pattern)&&s.include.some(o=>o&&i.matchMinimatch(e,o))&&!s.exclude.some(o=>o&&i.matchMinimatch(e,o))))return;let r;if(this.options.hashAlgorithm)try{r=(await this.stat(e)).hash}catch{}try{this.broadcastChannel||(this.broadcastChannel=new BroadcastChannel(this.options.broadcastChannel));const s={namespace:this.options.namespace,timestamp:new Date().toISOString(),...t,...r&&{hash:r}};this.broadcastChannel.postMessage(s)}catch(s){console.warn("Failed to send event via BroadcastChannel:",s)}}constructor(t){i.checkOPFSSupport(),t&&this.setOptions(t)}async mount(){const t=this.options.root;return this.mountingPromise&&await this.mountingPromise,this.mountingPromise=new Promise(async(e,a)=>{try{const r=await navigator.storage.getDirectory();this.root=t==="/"?r:await this.getDirectoryHandle(t,!0,r),e(!0)}catch(r){a(new i.OPFSError("Failed to initialize OPFS","INIT_FAILED",t,r))}finally{this.mountingPromise=null}}),this.mountingPromise}async setOptions(t){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=i.normalizePath(t.root),this.options.namespace||(this.options.namespace=`opfs-worker:${this.options.root}`),await this.mount())}async getDirectoryHandle(t,e=!1,a=this.root){const r=Array.isArray(t)?t:i.splitPath(t);let s=a;for(const o of r)s=await s.getDirectoryHandle(o,{create:e});return s}async getFileHandle(t,e=!1,a=this.root){const r=i.splitPath(t);if(r.length===0)throw new i.PathError("Path must not be empty",Array.isArray(t)?t.join("/"):t);const s=r.pop();return(await this.getDirectoryHandle(r,e,a)).getFileHandle(s,{create:e})}async index(){const t=new Map,e=async a=>{const r=await this.readDir(a);for(const s of r){const o=`${a==="/"?"":a}/${s.name}`;try{const n=await this.stat(o);t.set(o,n),n.isDirectory&&await e(o)}catch(n){console.warn(`Skipping broken entry: ${o}`,n)}}};return t.set("/",{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}),await e("/"),t}async readFile(t,e){await this.mount(),e||(e=i.isBinaryFileExtension(t)?"binary":"utf-8");try{const a=await this.getFileHandle(t,!1,this.root),r=await i.readFileData(a,t);return e==="binary"?r:i.decodeBuffer(r,e)}catch(a){throw new i.FileNotFoundError(t,a)}}async writeFile(t,e,a){await this.mount();const r=await this.exists(t),s=await this.getFileHandle(t,!0);a||(a=typeof e!="string"||i.isBinaryFileExtension(t)?"binary":"utf-8"),await i.writeFileData(s,e,a,t),r?await this.notifyChange({path:t,type:"changed",isDirectory:!1}):await this.notifyChange({path:t,type:"added",isDirectory:!1})}async appendFile(t,e,a){await this.mount();const r=await this.getFileHandle(t,!0);a||(a=typeof e!="string"||i.isBinaryFileExtension(t)?"binary":"utf-8"),await i.writeFileData(r,e,a,t,{append:!0}),await this.notifyChange({path:t,type:"changed",isDirectory:!1})}async mkdir(t,e){await this.mount();const a=e?.recursive??!1,r=i.splitPath(t);let s=this.root;for(let o=0;o<r.length;o++){const n=r[o];try{s=await s.getDirectoryHandle(n,{create:a||o===r.length-1})}catch(c){throw c.name==="NotFoundError"?new i.OPFSError(`Parent directory does not exist: ${i.joinPath(r.slice(0,o+1))}`,"ENOENT",void 0,c):c.name==="TypeMismatchError"?new i.OPFSError(`Path segment is not a directory: ${n}`,"ENOTDIR",void 0,c):new i.OPFSError("Failed to create directory","MKDIR_FAILED",void 0,c)}}await this.notifyChange({path:t,type:"added",isDirectory:!0})}async stat(t){if(await this.mount(),t==="/")return{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0};const e=i.basename(t),a=await this.getDirectoryHandle(i.dirname(t),!1),r=this.options.hashAlgorithm!==null;try{const o=await(await a.getFileHandle(e,{create:!1})).getFile(),n={kind:"file",size:o.size,mtime:new Date(o.lastModified).toISOString(),ctime:new Date(o.lastModified).toISOString(),isFile:!0,isDirectory:!1};if(r&&this.options.hashAlgorithm)try{const c=await i.calculateFileHash(o,this.options.hashAlgorithm,this.options.maxFileSize);n.hash=c}catch(c){console.warn(`Failed to calculate hash for ${t}:`,c)}return n}catch(s){if(s.name!=="TypeMismatchError"&&s.name!=="NotFoundError")throw new i.OPFSError("Failed to stat (file)","STAT_FAILED",void 0,s)}try{return await a.getDirectoryHandle(e,{create:!1}),{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}}catch(s){throw s.name==="NotFoundError"?new i.OPFSError(`No such file or directory: ${t}`,"ENOENT",void 0,s):new i.OPFSError("Failed to stat (directory)","STAT_FAILED",void 0,s)}}async readDir(t){await this.mount();const e=await this.getDirectoryHandle(t,!1),a=[];for await(const[r,s]of e.entries()){const o=s.kind==="file";a.push({name:r,kind:s.kind,isFile:o,isDirectory:!o})}return a}async exists(t){if(await this.mount(),t==="/")return!0;const e=i.basename(t);let a=null;try{a=await this.getDirectoryHandle(i.dirname(t),!1)}catch(r){if(a=null,r.name!=="NotFoundError"&&r.name!=="TypeMismatchError")throw r}if(!a||!e)return!1;try{return await a.getFileHandle(e,{create:!1}),!0}catch(r){if(r.name!=="NotFoundError"&&r.name!=="TypeMismatchError")throw r;try{return await a.getDirectoryHandle(e,{create:!1}),!0}catch(s){if(s.name!=="NotFoundError"&&s.name!=="TypeMismatchError")throw s;return!1}}}async clear(t="/"){await this.mount();try{const e=await this.readDir(t);for(const a of e){const r=`${t==="/"?"":t}/${a.name}`;await this.remove(r,{recursive:!0})}await this.notifyChange({path:t,type:"changed",isDirectory:!0})}catch(e){throw e instanceof i.OPFSError?e:new i.OPFSError(`Failed to clear directory: ${t}`,"CLEAR_FAILED",void 0,e)}}async remove(t,e){if(await this.mount(),t==="/")throw new i.OPFSError("Cannot remove root directory","EROOT");const{recursive:a=!1,force:r=!1}=e||{},s=await this.getDirectoryHandle(i.dirname(t),!1);await i.removeEntry(s,t,{recursive:a,force:r}),await this.notifyChange({path:t,type:"removed",isDirectory:!1})}async realpath(t){await this.mount();try{const e=i.resolvePath(t);if(!await this.exists(e))throw new i.FileNotFoundError(e);return e}catch(e){throw e instanceof i.OPFSError?e:new i.OPFSError(`Failed to resolve path: ${t}`,"REALPATH_FAILED",void 0,e)}}async rename(t,e,a){await this.mount();try{const r=a?.overwrite??!1;if(!await this.exists(t))throw new i.FileNotFoundError(t);if(await this.exists(e)&&!r)throw new i.OPFSError(`Destination already exists: ${e}`,"EEXIST",void 0);await this.copy(t,e,{recursive:!0,overwrite:r}),await this.remove(t,{recursive:!0}),await this.notifyChange({path:t,type:"removed",isDirectory:!1}),await this.notifyChange({path:e,type:"added",isDirectory:!1})}catch(r){throw r instanceof i.OPFSError?r:new i.OPFSError(`Failed to rename from ${t} to ${e}`,"RENAME_FAILED",void 0,r)}}async copy(t,e,a){await this.mount();try{const r=a?.recursive??!1,s=a?.overwrite??!0;if(!await this.exists(t))throw new i.OPFSError(`Source does not exist: ${t}`,"ENOENT",void 0);if(await this.exists(e)&&!s)throw new i.OPFSError(`Destination already exists: ${e}`,"EEXIST",void 0);if((await this.stat(t)).isFile){const l=await this.readFile(t,"binary");await this.writeFile(e,l)}else{if(!r)throw new i.OPFSError(`Cannot copy directory without recursive option: ${t}`,"EISDIR",void 0);await this.mkdir(e,{recursive:!0});const l=await this.readDir(t);for(const h of l){const d=`${t}/${h.name}`,f=`${e}/${h.name}`;await this.copy(d,f,{recursive:!0,overwrite:s})}}}catch(r){throw r instanceof i.OPFSError?r:new i.OPFSError(`Failed to copy from ${t} to ${e}`,"CP_FAILED",void 0,r)}}async watch(t,e){if(!this.options.broadcastChannel)throw new i.OPFSError("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.","ENOENT");const a={pattern:i.normalizeMinimatch(t,e?.recursive??!0),include:Array.isArray(e?.include)?e.include:[e?.include??"**"],exclude:Array.isArray(e?.exclude)?e.exclude:[e?.exclude??""]};this.watchers.set(t,a)}unwatch(t){this.watchers.delete(t)}dispose(){this.broadcastChannel&&(this.broadcastChannel.close(),this.broadcastChannel=null),this.watchers.clear()}async sync(t,e){await this.mount();try{(e?.cleanBefore??!1)&&await this.clear("/");for(const[r,s]of t){const o=i.normalizePath(r);let n;s instanceof Blob?n=await i.convertBlobToUint8Array(s):n=s,await this.writeFile(o,n)}}catch(a){throw a instanceof i.OPFSError?a:new i.OPFSError("Failed to sync file system","SYNC_FAILED",void 0,a)}}}typeof globalThis<"u"&&globalThis.constructor.name==="DedicatedWorkerGlobalScope"&&m.expose(new w);exports.OPFSWorker=w;
2
2
  //# sourceMappingURL=raw.cjs.map