opfs-worker 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-CIiblZ8d.cjs"),l=`/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-Dwc92hv9.cjs"),l=`/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), J = Symbol("Comlink.finalizer"), U = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
6
+ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), _ = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
7
7
  canHandle: (s) => Ot(s) && s[bt],
8
8
  serialize(s) {
9
9
  const { port1: t, port2: e } = new MessageChannel();
@@ -13,7 +13,7 @@ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol
13
13
  return s.start(), Gt(s);
14
14
  }
15
15
  }, _t = {
16
- canHandle: (s) => Ot(s) && U in s,
16
+ canHandle: (s) => Ot(s) && _ in s,
17
17
  serialize({ value: s }) {
18
18
  let t;
19
19
  return s instanceof Error ? t = {
@@ -69,7 +69,7 @@ function ot(s, t = globalThis, e = ["*"]) {
69
69
  case "ENDPOINT":
70
70
  {
71
71
  const { port1: u, port2: d } = new MessageChannel();
72
- ot(s, d), h = B(u, [u]);
72
+ ot(s, d), h = U(u, [u]);
73
73
  }
74
74
  break;
75
75
  case "RELEASE":
@@ -79,15 +79,15 @@ function ot(s, t = globalThis, e = ["*"]) {
79
79
  return;
80
80
  }
81
81
  } catch (c) {
82
- h = { value: c, [U]: 0 };
82
+ h = { value: c, [_]: 0 };
83
83
  }
84
- Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
85
- const [f, u] = Y(c);
86
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), J in s && typeof s[J] == "function" && s[J]());
84
+ Promise.resolve(h).catch((c) => ({ value: c, [_]: 0 })).then((c) => {
85
+ const [f, u] = V(c);
86
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), X in s && typeof s[X] == "function" && s[X]());
87
87
  }).catch((c) => {
88
- const [f, u] = Y({
88
+ const [f, u] = V({
89
89
  value: new TypeError("Unserializable return value"),
90
- [U]: 0
90
+ [_]: 0
91
91
  });
92
92
  t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
93
93
  });
@@ -112,79 +112,79 @@ function Gt(s, t) {
112
112
  } finally {
113
113
  e.delete(i.id);
114
114
  }
115
- }), nt(s, e, [], t);
115
+ }), st(s, e, [], t);
116
116
  }
117
- function W(s) {
117
+ function H(s) {
118
118
  if (s)
119
119
  throw new Error("Proxy has been released and is not useable");
120
120
  }
121
121
  function At(s) {
122
- return $(s, /* @__PURE__ */ new Map(), {
122
+ return F(s, /* @__PURE__ */ new Map(), {
123
123
  type: "RELEASE"
124
124
  }).then(() => {
125
125
  vt(s);
126
126
  });
127
127
  }
128
- const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
- const t = (q.get(s) || 0) - 1;
130
- q.set(s, t), t === 0 && At(s);
128
+ const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
+ const t = (G.get(s) || 0) - 1;
130
+ G.set(s, t), t === 0 && At(s);
131
131
  });
132
132
  function qt(s, t) {
133
- const e = (q.get(t) || 0) + 1;
134
- q.set(t, e), V && V.register(s, t, s);
133
+ const e = (G.get(t) || 0) + 1;
134
+ G.set(t, e), q && q.register(s, t, s);
135
135
  }
136
136
  function Vt(s) {
137
- V && V.unregister(s);
137
+ q && q.unregister(s);
138
138
  }
139
- function nt(s, t, e = [], n = function() {
139
+ function st(s, t, e = [], n = function() {
140
140
  }) {
141
141
  let r = !1;
142
142
  const i = new Proxy(n, {
143
143
  get(o, a) {
144
- if (W(r), a === Wt)
144
+ if (H(r), a === Wt)
145
145
  return () => {
146
146
  Vt(i), At(s), t.clear(), r = !0;
147
147
  };
148
148
  if (a === "then") {
149
149
  if (e.length === 0)
150
150
  return { then: () => i };
151
- const l = $(s, t, {
151
+ const l = F(s, t, {
152
152
  type: "GET",
153
153
  path: e.map((h) => h.toString())
154
154
  }).then(C);
155
155
  return l.then.bind(l);
156
156
  }
157
- return nt(s, t, [...e, a]);
157
+ return st(s, t, [...e, a]);
158
158
  },
159
159
  set(o, a, l) {
160
- W(r);
161
- const [h, c] = Y(l);
162
- return $(s, t, {
160
+ H(r);
161
+ const [h, c] = V(l);
162
+ return F(s, t, {
163
163
  type: "SET",
164
164
  path: [...e, a].map((f) => f.toString()),
165
165
  value: h
166
166
  }, c).then(C);
167
167
  },
168
168
  apply(o, a, l) {
169
- W(r);
169
+ H(r);
170
170
  const h = e[e.length - 1];
171
171
  if (h === Ht)
172
- return $(s, t, {
172
+ return F(s, t, {
173
173
  type: "ENDPOINT"
174
174
  }).then(C);
175
175
  if (h === "bind")
176
- return nt(s, t, e.slice(0, -1));
176
+ return st(s, t, e.slice(0, -1));
177
177
  const [c, f] = ht(l);
178
- return $(s, t, {
178
+ return F(s, t, {
179
179
  type: "APPLY",
180
180
  path: e.map((u) => u.toString()),
181
181
  argumentList: c
182
182
  }, f).then(C);
183
183
  },
184
184
  construct(o, a) {
185
- W(r);
185
+ H(r);
186
186
  const [l, h] = ht(a);
187
- return $(s, t, {
187
+ return F(s, t, {
188
188
  type: "CONSTRUCT",
189
189
  path: e.map((c) => c.toString()),
190
190
  argumentList: l
@@ -197,17 +197,17 @@ function Yt(s) {
197
197
  return Array.prototype.concat.apply([], s);
198
198
  }
199
199
  function ht(s) {
200
- const t = s.map(Y);
200
+ const t = s.map(V);
201
201
  return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
202
202
  }
203
203
  const Nt = /* @__PURE__ */ new WeakMap();
204
- function B(s, t) {
204
+ function U(s, t) {
205
205
  return Nt.set(s, t), s;
206
206
  }
207
207
  function Zt(s) {
208
208
  return Object.assign(s, { [bt]: !0 });
209
209
  }
210
- function Y(s) {
210
+ function V(s) {
211
211
  for (const [t, e] of Dt)
212
212
  if (e.canHandle(s)) {
213
213
  const [n, r] = e.serialize(s);
@@ -236,7 +236,7 @@ function C(s) {
236
236
  return s.value;
237
237
  }
238
238
  }
239
- function $(s, t, e, n) {
239
+ function F(s, t, e, n) {
240
240
  return new Promise((r) => {
241
241
  const i = Xt();
242
242
  t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
@@ -296,7 +296,7 @@ class Kt extends w {
296
296
  super(t, "INVALID_PATH", e, "access", n);
297
297
  }
298
298
  }
299
- class F extends w {
299
+ class R extends w {
300
300
  constructor(t, e, n) {
301
301
  const r = {
302
302
  file: \`File not found: \${e}\`,
@@ -321,7 +321,7 @@ class se extends w {
321
321
  super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
322
322
  }
323
323
  }
324
- class z extends w {
324
+ class nt extends w {
325
325
  constructor(t, e, n) {
326
326
  const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
327
327
  super(r, i, e, "access", n);
@@ -368,36 +368,36 @@ class re extends w {
368
368
  super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
369
369
  }
370
370
  }
371
- class Q extends w {
371
+ class J extends w {
372
372
  constructor(t, e, n) {
373
373
  super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
374
374
  }
375
375
  }
376
- class K extends w {
376
+ class Q extends w {
377
377
  constructor(t, e) {
378
378
  super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
379
379
  }
380
380
  }
381
- function j(s, t, e, n) {
381
+ function W(s, t, e, n) {
382
382
  const r = \`\${s.toUpperCase()}_FAILED\`;
383
383
  return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
384
384
  }
385
- function A(s, t) {
386
- const e = t?.path, n = t?.isDirectory;
385
+ function v(s, t) {
386
+ const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
387
387
  switch (s.name) {
388
388
  case "InvalidStateError":
389
389
  return new se(e || "unknown", s);
390
390
  case "QuotaExceededError":
391
391
  return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
392
392
  case "NotFoundError":
393
- return new F("file", e, s);
393
+ return new R(r, e, s);
394
394
  case "TypeMismatchError":
395
- return n !== void 0 ? n ? new z("directory", e || "unknown", s) : new z("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
395
+ return n !== void 0 ? n ? new nt("directory", e || "unknown", s) : new nt("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
396
396
  case "NotAllowedError":
397
397
  case "SecurityError":
398
398
  return new te(e, "unknown", s);
399
399
  case "InvalidModificationError":
400
- return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
400
+ return i === "remove" ? new rt("ENOTEMPTY", e, s) : new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
401
401
  case "AbortError":
402
402
  return new ne(e || "unknown", s);
403
403
  case "OperationError":
@@ -405,7 +405,7 @@ function A(s, t) {
405
405
  case "TypeError":
406
406
  return new Ct(e || "unknown", s);
407
407
  default:
408
- return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
408
+ return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
409
409
  }
410
410
  }
411
411
  const Ft = (s, t, e) => {
@@ -438,12 +438,12 @@ const Ft = (s, t, e) => {
438
438
  n.length && o !== void 0 && (a = [i, o]);
439
439
  }
440
440
  return a;
441
- }, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Pt = "\\0COMMA" + Math.random() + "\\0", Tt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Pt, "g"), he = new RegExp(Tt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
442
- function tt(s) {
441
+ }, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Tt = "\\0COMMA" + Math.random() + "\\0", Pt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Tt, "g"), he = new RegExp(Pt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
442
+ function K(s) {
443
443
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
444
444
  }
445
445
  function we(s) {
446
- return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
446
+ return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
447
447
  }
448
448
  function me(s) {
449
449
  return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
@@ -460,7 +460,7 @@ function Rt(s) {
460
460
  return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
461
461
  }
462
462
  function ye(s) {
463
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
463
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), k(we(s), !0).map(me)) : [];
464
464
  }
465
465
  function Ee(s) {
466
466
  return "{" + s + "}";
@@ -474,11 +474,11 @@ function xe(s, t) {
474
474
  function be(s, t) {
475
475
  return s >= t;
476
476
  }
477
- function I(s, t) {
477
+ function k(s, t) {
478
478
  const e = [], n = Ft("{", "}", s);
479
479
  if (!n)
480
480
  return [s];
481
- const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
481
+ const r = n.pre, i = n.post.length ? k(n.post, !1) : [""];
482
482
  if (/\\$$/.test(n.pre))
483
483
  for (let o = 0; o < i.length; o++) {
484
484
  const a = r + "{" + n.body + "}" + i[o];
@@ -487,28 +487,28 @@ function I(s, t) {
487
487
  else {
488
488
  const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
489
489
  if (!l && !h)
490
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
490
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, k(s)) : [s];
491
491
  let c;
492
492
  if (l)
493
493
  c = n.body.split(/\\.\\./);
494
- else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
494
+ else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = k(c[0], !1).map(Ee), c.length === 1))
495
495
  return i.map((u) => n.pre + c[0] + u);
496
496
  let f;
497
497
  if (l && c[0] !== void 0 && c[1] !== void 0) {
498
- const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
499
- let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
498
+ const u = K(c[0]), d = K(c[1]), g = Math.max(c[0].length, c[1].length);
499
+ let p = c.length === 3 && c[2] !== void 0 ? Math.abs(K(c[2])) : 1, S = xe;
500
500
  d < u && (p *= -1, S = be);
501
- const P = c.some(Se);
501
+ const M = c.some(Se);
502
502
  f = [];
503
503
  for (let x = u; S(x, d); x += p) {
504
504
  let m;
505
505
  if (a)
506
506
  m = String.fromCharCode(x), m === "\\\\" && (m = "");
507
- else if (m = String(x), P) {
507
+ else if (m = String(x), M) {
508
508
  const T = g - m.length;
509
509
  if (T > 0) {
510
- const H = new Array(T + 1).join("0");
511
- x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
510
+ const z = new Array(T + 1).join("0");
511
+ x < 0 ? m = "-" + z + m.slice(1) : m = z + m;
512
512
  }
513
513
  }
514
514
  f.push(m);
@@ -516,7 +516,7 @@ function I(s, t) {
516
516
  } else {
517
517
  f = [];
518
518
  for (let u = 0; u < c.length; u++)
519
- f.push.apply(f, I(c[u], !1));
519
+ f.push.apply(f, k(c[u], !1));
520
520
  }
521
521
  for (let u = 0; u < f.length; u++)
522
522
  for (let d = 0; d < i.length; d++) {
@@ -526,7 +526,7 @@ function I(s, t) {
526
526
  }
527
527
  return e;
528
528
  }
529
- const Oe = 1024 * 64, Z = (s) => {
529
+ const Oe = 1024 * 64, Y = (s) => {
530
530
  if (typeof s != "string")
531
531
  throw new TypeError("invalid pattern");
532
532
  if (s.length > Oe)
@@ -546,7 +546,7 @@ const Oe = 1024 * 64, Z = (s) => {
546
546
  "[:upper:]": ["\\\\p{Lu}", !0],
547
547
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
548
548
  "[:xdigit:]": ["A-Fa-f0-9", !1]
549
- }, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
549
+ }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
550
550
  const e = t;
551
551
  if (s.charAt(e) !== "[")
552
552
  throw new Error("not in a brace expression");
@@ -567,27 +567,27 @@ const Oe = 1024 * 64, Z = (s) => {
567
567
  continue;
568
568
  }
569
569
  if (p === "[" && !l) {
570
- for (const [S, [v, P, x]] of Object.entries(De))
570
+ for (const [S, [A, M, x]] of Object.entries(De))
571
571
  if (s.startsWith(S, i)) {
572
572
  if (f)
573
573
  return ["$.", !1, s.length - e, !0];
574
- i += S.length, x ? r.push(v) : n.push(v), a = a || P;
574
+ i += S.length, x ? r.push(A) : n.push(A), a = a || M;
575
575
  continue t;
576
576
  }
577
577
  }
578
578
  if (l = !1, f) {
579
- p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
579
+ p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
580
580
  continue;
581
581
  }
582
582
  if (s.startsWith("-]", i + 1)) {
583
- n.push(R(p + "-")), i += 2;
583
+ n.push(P(p + "-")), i += 2;
584
584
  continue;
585
585
  }
586
586
  if (s.startsWith("-", i + 1)) {
587
587
  f = p, i += 2;
588
588
  continue;
589
589
  }
590
- n.push(R(p)), i++;
590
+ n.push(P(p)), i++;
591
591
  }
592
592
  if (c < i)
593
593
  return ["", !1, 0, !1];
@@ -599,7 +599,7 @@ const Oe = 1024 * 64, Z = (s) => {
599
599
  }
600
600
  const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
601
601
  return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
602
- }, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", _ = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
602
+ }, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
603
603
  class E {
604
604
  type;
605
605
  #s;
@@ -852,8 +852,8 @@ class E {
852
852
  const e = t ?? !!this.#r.dot;
853
853
  if (this.#s === this && this.#d(), !this.type) {
854
854
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
855
- const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
856
- return this.#n = this.#n || S, this.#i = this.#i || v, g;
855
+ const [g, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
856
+ return this.#n = this.#n || S, this.#i = this.#i || A, g;
857
857
  }).join("");
858
858
  let c = "";
859
859
  if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
@@ -863,12 +863,12 @@ class E {
863
863
  h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
864
864
  h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
865
865
  ), S = !e && !t && g.has(h.charAt(0));
866
- c = p ? Ce : S ? _ : "";
866
+ c = p ? Ce : S ? j : "";
867
867
  }
868
868
  let f = "";
869
869
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
870
870
  c + h + f,
871
- k(h),
871
+ I(h),
872
872
  this.#n = !!this.#n,
873
873
  this.#i
874
874
  ];
@@ -877,23 +877,23 @@ class E {
877
877
  let i = this.#f(e);
878
878
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
879
879
  const l = this.toString();
880
- return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
880
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, I(this.toString()), !1, !1];
881
881
  }
882
- let o = !n || t || e || !_ ? "" : this.#f(!0);
882
+ let o = !n || t || e || !j ? "" : this.#f(!0);
883
883
  o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
884
884
  let a = "";
885
885
  if (this.type === "!" && this.#u)
886
- a = (this.isStart() && !e ? _ : "") + wt;
886
+ a = (this.isStart() && !e ? j : "") + wt;
887
887
  else {
888
888
  const l = this.type === "!" ? (
889
889
  // !() must match something,but !(x) can match ''
890
- "))" + (this.isStart() && !e && !t ? _ : "") + gt + ")"
890
+ "))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
891
891
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
892
892
  a = r + i + l;
893
893
  }
894
894
  return [
895
895
  a,
896
- k(i),
896
+ I(i),
897
897
  this.#n = !!this.#n,
898
898
  this.#i
899
899
  ];
@@ -933,27 +933,27 @@ class E {
933
933
  i += ct, e = !0;
934
934
  continue;
935
935
  }
936
- i += Pe(l);
936
+ i += Te(l);
937
937
  }
938
- return [i, k(t), !!e, o];
938
+ return [i, I(t), !!e, o];
939
939
  }
940
940
  }
941
- const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
942
- const e = It([s]);
941
+ const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Y(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new Z(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Ie = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
942
+ const e = kt([s]);
943
943
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
944
944
  }, Ze = ([s, t = ""]) => {
945
- const e = kt([s]);
945
+ const e = It([s]);
946
946
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
947
947
  }, Xe = ([s, t = ""]) => {
948
- const e = kt([s]);
948
+ const e = It([s]);
949
949
  return t ? (n) => e(n) && n.endsWith(t) : e;
950
950
  }, Je = ([s, t = ""]) => {
951
- const e = It([s]);
951
+ const e = kt([s]);
952
952
  return t ? (n) => e(n) && n.endsWith(t) : e;
953
- }, It = ([s]) => {
953
+ }, kt = ([s]) => {
954
954
  const t = s.length;
955
955
  return (e) => e.length === t && !e.startsWith(".");
956
- }, kt = ([s]) => {
956
+ }, It = ([s]) => {
957
957
  const t = s.length;
958
958
  return (e) => e.length === t && e !== "." && e !== "..";
959
959
  }, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
@@ -1000,17 +1000,17 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
1000
1000
  });
1001
1001
  };
1002
1002
  y.defaults = rs;
1003
- const zt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1003
+ const zt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1004
1004
  y.braceExpand = zt;
1005
- const is = (s, t = {}) => new X(s, t).makeRe();
1005
+ const is = (s, t = {}) => new Z(s, t).makeRe();
1006
1006
  y.makeRe = is;
1007
1007
  const os = (s, t, e = {}) => {
1008
- const n = new X(t, e);
1008
+ const n = new Z(t, e);
1009
1009
  return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
1010
1010
  };
1011
1011
  y.match = os;
1012
1012
  const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1013
- class X {
1013
+ class Z {
1014
1014
  options;
1015
1015
  set;
1016
1016
  pattern;
@@ -1029,7 +1029,7 @@ class X {
1029
1029
  windowsNoMagicRoot;
1030
1030
  regexp;
1031
1031
  constructor(t, e = {}) {
1032
- Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1032
+ Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1033
1033
  }
1034
1034
  hasMagic() {
1035
1035
  if (this.options.magicalBraces && this.set.length > 1)
@@ -1237,10 +1237,10 @@ class X {
1237
1237
  matchOne(t, e, n = !1) {
1238
1238
  const r = this.options;
1239
1239
  if (this.isWindows) {
1240
- 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]), P = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = P ? 3 : v ? 0 : void 0;
1240
+ const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = M ? 3 : A ? 0 : void 0;
1241
1241
  if (typeof x == "number" && typeof m == "number") {
1242
- const [T, H] = [t[x], e[m]];
1243
- T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1242
+ const [T, z] = [t[x], e[m]];
1243
+ T.toLowerCase() === z.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1244
1244
  }
1245
1245
  }
1246
1246
  const { optimizationLevel: i = 1 } = this.options;
@@ -1289,14 +1289,14 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1289
1289
  return zt(this.pattern, this.options);
1290
1290
  }
1291
1291
  parse(t) {
1292
- Z(t);
1292
+ Y(t);
1293
1293
  const e = this.options;
1294
1294
  if (t === "**")
1295
1295
  return O;
1296
1296
  if (t === "")
1297
1297
  return "";
1298
1298
  let n, r = null;
1299
- (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
1299
+ (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? Ie : ke)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
1300
1300
  const i = E.fromGlob(t, this.options).toMMPattern();
1301
1301
  return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1302
1302
  }
@@ -1361,9 +1361,9 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1361
1361
  }
1362
1362
  }
1363
1363
  y.AST = E;
1364
- y.Minimatch = X;
1365
- y.escape = Te;
1366
- y.unescape = k;
1364
+ y.Minimatch = Z;
1365
+ y.escape = Pe;
1366
+ y.unescape = I;
1367
1367
  function cs() {
1368
1368
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1369
1369
  throw new Qt();
@@ -1371,34 +1371,34 @@ function cs() {
1371
1371
  async function L(s, t, e) {
1372
1372
  return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1373
1373
  }
1374
- function M(s) {
1374
+ function $(s) {
1375
1375
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1376
1376
  }
1377
1377
  function lt(s) {
1378
1378
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1379
1379
  }
1380
1380
  function it(s) {
1381
- const t = M(s);
1381
+ const t = $(s);
1382
1382
  return t[t.length - 1] || "";
1383
1383
  }
1384
- function et(s) {
1385
- const t = M(s);
1384
+ function tt(s) {
1385
+ const t = $(s);
1386
1386
  return t.pop(), lt(t);
1387
1387
  }
1388
- function G(s) {
1388
+ function B(s) {
1389
1389
  return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1390
1390
  }
1391
1391
  function ls(s, t = !1) {
1392
1392
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1393
1393
  }
1394
- function st(s, t) {
1394
+ function et(s, t) {
1395
1395
  return y(s, t, {
1396
1396
  dot: !0,
1397
1397
  matchBase: !0
1398
1398
  });
1399
1399
  }
1400
1400
  function Et(s) {
1401
- const t = G(s), e = M(t), n = [];
1401
+ const t = B(s), e = $(t), n = [];
1402
1402
  for (const r of e)
1403
1403
  if (!(r === "." || r === ""))
1404
1404
  if (r === "..") {
@@ -1426,10 +1426,14 @@ async function fs(s, t, e = {}) {
1426
1426
  try {
1427
1427
  await s.removeEntry(n, { recursive: r });
1428
1428
  } catch (o) {
1429
- if (o.name === "NotFoundError") {
1430
- if (!i)
1431
- throw new F("file", t, o);
1432
- } else throw o.name === "InvalidModificationError" ? new rt("ENOTEMPTY", t, o) : o.name === "TypeMismatchError" && !r ? new z("directory", t, o) : new rt("RM_FAILED", t, o);
1429
+ if (o.name === "NotFoundError" && i)
1430
+ return;
1431
+ const a = o.name === "TypeMismatchError" && !r;
1432
+ throw v(o, {
1433
+ path: t,
1434
+ operation: "remove",
1435
+ isDirectory: a
1436
+ });
1433
1437
  }
1434
1438
  });
1435
1439
  }
@@ -1460,7 +1464,7 @@ async function ps(s, t) {
1460
1464
  try {
1461
1465
  return await s.createSyncAccessHandle();
1462
1466
  } catch (e) {
1463
- throw A(e, { path: t, isDirectory: !1 });
1467
+ throw v(e, { path: t, isDirectory: !1 });
1464
1468
  }
1465
1469
  }
1466
1470
  class gs {
@@ -1500,14 +1504,13 @@ class gs {
1500
1504
  * This method is called by internal operations to notify clients about
1501
1505
  * changes, even when no specific paths are being watched.
1502
1506
  *
1503
- * @param path - The path that was changed
1504
- * @param type - The type of change (create, change, delete)
1507
+ * @param event - The event describing the change
1505
1508
  */
1506
1509
  async notifyChange(t) {
1507
1510
  if (!this.options.broadcastChannel)
1508
1511
  return;
1509
1512
  const e = t.path;
1510
- if (![...this.watchers.values()].some((i) => st(e, i.pattern) && i.include.some((o) => o && st(e, o)) && !i.exclude.some((o) => o && st(e, o))))
1513
+ if (![...this.watchers.values()].some((i) => et(e, i.pattern) && i.include.some((o) => o && et(e, o)) && !i.exclude.some((o) => o && et(e, o))))
1511
1514
  return;
1512
1515
  let r;
1513
1516
  if (this.options.hashAlgorithm)
@@ -1547,7 +1550,6 @@ class gs {
1547
1550
  * This method sets up the root directory for all subsequent operations.
1548
1551
  * If no root is specified, it will use the OPFS root directory.
1549
1552
  *
1550
- * @param root - The root path for the file system (default: '/')
1551
1553
  * @returns Promise that resolves to true if initialization was successful
1552
1554
  * @throws {OPFSError} If initialization fails
1553
1555
  *
@@ -1586,7 +1588,7 @@ class gs {
1586
1588
  * @param options.broadcastChannel - Custom name for the broadcast channel
1587
1589
  */
1588
1590
  async setOptions(t) {
1589
- 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 = G(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1591
+ t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = B(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1590
1592
  }
1591
1593
  /**
1592
1594
  * Get a directory handle from a path
@@ -1607,7 +1609,7 @@ class gs {
1607
1609
  * \`\`\`
1608
1610
  */
1609
1611
  async getDirectoryHandle(t, e = !1, n = this.root) {
1610
- const r = Array.isArray(t) ? t : M(t);
1612
+ const r = Array.isArray(t) ? t : $(t);
1611
1613
  let i = n;
1612
1614
  for (const o of r)
1613
1615
  i = await i.getDirectoryHandle(o, { create: e });
@@ -1633,7 +1635,7 @@ class gs {
1633
1635
  * \`\`\`
1634
1636
  */
1635
1637
  async getFileHandle(t, e = !1, n = this.root) {
1636
- const r = M(t);
1638
+ const r = $(t);
1637
1639
  if (r.length === 0)
1638
1640
  throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1639
1641
  const i = r.pop();
@@ -1706,13 +1708,13 @@ class gs {
1706
1708
  const e = await this.open(t);
1707
1709
  try {
1708
1710
  const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1709
- return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
1711
+ return n > 0 && await this.read(e, r, 0, n, 0), U(r, [r.buffer]);
1710
1712
  } finally {
1711
1713
  await this.close(e);
1712
1714
  }
1713
1715
  });
1714
1716
  } catch (e) {
1715
- throw new F("file", t, e);
1717
+ throw new R("file", t, e);
1716
1718
  }
1717
1719
  }
1718
1720
  /**
@@ -1809,14 +1811,17 @@ class gs {
1809
1811
  */
1810
1812
  async mkdir(t, e) {
1811
1813
  await this.mount();
1812
- const n = e?.recursive ?? !1, r = M(t);
1814
+ const n = e?.recursive ?? !1, r = $(t);
1813
1815
  let i = this.root;
1814
1816
  for (let o = 0; o < r.length; o++) {
1815
1817
  const a = r[o];
1816
1818
  try {
1817
1819
  i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1818
1820
  } catch (l) {
1819
- throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new z("file", a, l) : new Q("create directory", a, l);
1821
+ throw l.name === "NotFoundError" ? v(l, {
1822
+ path: lt(r.slice(0, o + 1)),
1823
+ existenceType: "directory"
1824
+ }) : l.name === "TypeMismatchError" ? v(l, { path: a, isDirectory: !1 }) : new J("create directory", a, l);
1820
1825
  }
1821
1826
  }
1822
1827
  await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
@@ -1856,7 +1861,7 @@ class gs {
1856
1861
  const e = it(t);
1857
1862
  let n;
1858
1863
  try {
1859
- n = await this.getDirectoryHandle(et(t), !1);
1864
+ n = await this.getDirectoryHandle(tt(t), !1);
1860
1865
  const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1861
1866
  kind: "file",
1862
1867
  size: o.size,
@@ -1877,9 +1882,9 @@ class gs {
1877
1882
  return a;
1878
1883
  } catch (r) {
1879
1884
  if (r.name === "NotFoundError")
1880
- throw new F("file", t, r);
1885
+ throw new R("file", t, r);
1881
1886
  if (r.name !== "TypeMismatchError")
1882
- throw new Q("stat", t, r);
1887
+ throw new J("stat", t, r);
1883
1888
  }
1884
1889
  try {
1885
1890
  return await n.getDirectoryHandle(e, { create: !1 }), {
@@ -1891,7 +1896,7 @@ class gs {
1891
1896
  isDirectory: !0
1892
1897
  };
1893
1898
  } catch (r) {
1894
- throw new Q("stat", t, r);
1899
+ throw new J("stat", t, r);
1895
1900
  }
1896
1901
  }
1897
1902
  /**
@@ -1946,7 +1951,7 @@ class gs {
1946
1951
  const e = it(t);
1947
1952
  let n = null;
1948
1953
  try {
1949
- n = await this.getDirectoryHandle(et(t), !1);
1954
+ n = await this.getDirectoryHandle(tt(t), !1);
1950
1955
  } catch (r) {
1951
1956
  if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1952
1957
  throw r;
@@ -1996,7 +2001,7 @@ class gs {
1996
2001
  }
1997
2002
  await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
1998
2003
  } catch (e) {
1999
- throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
2004
+ throw e instanceof w ? e : v(e, { path: t, isDirectory: !0 });
2000
2005
  }
2001
2006
  }
2002
2007
  /**
@@ -2026,7 +2031,7 @@ class gs {
2026
2031
  async remove(t, e) {
2027
2032
  if (await this.mount(), t === "/")
2028
2033
  throw new rt("EROOT", t);
2029
- const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
2034
+ const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
2030
2035
  await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
2031
2036
  }
2032
2037
  /**
@@ -2052,10 +2057,10 @@ class gs {
2052
2057
  try {
2053
2058
  const e = Et(t);
2054
2059
  if (!await this.exists(e))
2055
- throw new F("file", e);
2060
+ throw new R("file", e);
2056
2061
  return e;
2057
2062
  } catch (e) {
2058
- throw e instanceof w ? e : A(e, { path: t });
2063
+ throw e instanceof w ? e : v(e, { path: t });
2059
2064
  }
2060
2065
  }
2061
2066
  /**
@@ -2085,10 +2090,10 @@ class gs {
2085
2090
  try {
2086
2091
  const r = n?.overwrite ?? !1, i = await this.stat(t);
2087
2092
  if (await this.exists(e) && !r)
2088
- throw new K(e);
2093
+ throw new Q(e);
2089
2094
  await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
2090
2095
  } catch (r) {
2091
- throw r instanceof w ? r : A(r, { path: t });
2096
+ throw r instanceof w ? r : v(r, { path: t });
2092
2097
  }
2093
2098
  }
2094
2099
  /**
@@ -2121,15 +2126,15 @@ class gs {
2121
2126
  try {
2122
2127
  const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2123
2128
  if (!await this.exists(t))
2124
- throw new F("source", t);
2129
+ throw new R("source", t);
2125
2130
  if (await this.exists(e) && !i)
2126
- throw new K(e);
2131
+ throw new Q(e);
2127
2132
  if ((await this.stat(t)).isFile) {
2128
2133
  const h = await this.readFile(t);
2129
2134
  await this.writeFile(e, h);
2130
2135
  } else {
2131
2136
  if (!r)
2132
- throw new z("directory", t);
2137
+ throw new nt("directory", t);
2133
2138
  await this.mkdir(e, { recursive: !0 });
2134
2139
  const h = await this.readDir(t);
2135
2140
  for (const c of h) {
@@ -2138,7 +2143,7 @@ class gs {
2138
2143
  }
2139
2144
  }
2140
2145
  } catch (r) {
2141
- throw r instanceof w ? r : A(r, { path: t });
2146
+ throw r instanceof w ? r : v(r, { path: t });
2142
2147
  }
2143
2148
  }
2144
2149
  /**
@@ -2211,15 +2216,21 @@ class gs {
2211
2216
  */
2212
2217
  async open(t, e) {
2213
2218
  await this.mount();
2214
- const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
2219
+ const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
2215
2220
  try {
2216
2221
  return n && r ? await L(o, "exclusive", async () => {
2217
2222
  if (await this.exists(o))
2218
- throw new K(o);
2223
+ throw new Q(o);
2219
2224
  return this._openFile(o, n, i);
2220
2225
  }) : await this._openFile(o, n, i);
2221
2226
  } catch (a) {
2222
- throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
2227
+ if (a instanceof w)
2228
+ throw a;
2229
+ const l = a && a.name === "TypeMismatchError";
2230
+ throw v(a, {
2231
+ path: o,
2232
+ isDirectory: !!l
2233
+ });
2223
2234
  }
2224
2235
  }
2225
2236
  /**
@@ -2231,7 +2242,7 @@ class gs {
2231
2242
  try {
2232
2243
  await r.getFile();
2233
2244
  } catch (a) {
2234
- throw A(a, { path: t, isDirectory: !0 });
2245
+ throw v(a, { path: t, isDirectory: !0 });
2235
2246
  }
2236
2247
  const i = await ps(r, t);
2237
2248
  n && (i.truncate(0), i.flush());
@@ -2291,11 +2302,11 @@ class gs {
2291
2302
  try {
2292
2303
  const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
2293
2304
  if (h)
2294
- return B({ bytesRead: 0, buffer: e }, [e.buffer]);
2305
+ return U({ bytesRead: 0, buffer: e }, [e.buffer]);
2295
2306
  const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2296
- return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
2307
+ return i == null && (o.position = a + u), U({ bytesRead: u, buffer: e }, [e.buffer]);
2297
2308
  } catch (a) {
2298
- throw j("read", t, o.path, a);
2309
+ throw W("read", t, o.path, a);
2299
2310
  }
2300
2311
  }
2301
2312
  /**
@@ -2326,7 +2337,7 @@ class gs {
2326
2337
  const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2327
2338
  return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
2328
2339
  } catch (h) {
2329
- throw j("write", t, a.path, h);
2340
+ throw W("write", t, a.path, h);
2330
2341
  }
2331
2342
  }
2332
2343
  /**
@@ -2374,7 +2385,7 @@ class gs {
2374
2385
  try {
2375
2386
  n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
2376
2387
  } catch (r) {
2377
- throw j("truncate", t, n.path, r);
2388
+ throw W("truncate", t, n.path, r);
2378
2389
  }
2379
2390
  }
2380
2391
  /**
@@ -2396,7 +2407,7 @@ class gs {
2396
2407
  try {
2397
2408
  e.syncHandle.flush();
2398
2409
  } catch (n) {
2399
- throw j("sync", t, e.path, n);
2410
+ throw W("sync", t, e.path, n);
2400
2411
  }
2401
2412
  }
2402
2413
  /**
@@ -2418,8 +2429,6 @@ class gs {
2418
2429
  * This is useful for importing data from external sources or syncing with remote data.
2419
2430
  *
2420
2431
  * @param entries - Array of [path, data] tuples to sync
2421
- * @param options - Options for synchronization
2422
- * @param options.cleanBefore - Whether to clear the file system before syncing (default: false)
2423
2432
  * @returns Promise that resolves when synchronization is complete
2424
2433
  * @throws {OPFSError} If the synchronization fails
2425
2434
  *
@@ -2443,16 +2452,16 @@ class gs {
2443
2452
  await this.mount();
2444
2453
  try {
2445
2454
  for (const [e, n] of t) {
2446
- const r = G(e);
2455
+ const r = B(e);
2447
2456
  let i;
2448
2457
  n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2449
2458
  }
2450
2459
  } catch (e) {
2451
- throw e instanceof w ? e : A(e);
2460
+ throw e instanceof w ? e : v(e);
2452
2461
  }
2453
2462
  }
2454
2463
  }
2455
2464
  typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
2456
- //# sourceMappingURL=worker-BeJaVyBV.js.map
2457
- `,h=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=h&&(self.URL||self.webkitURL).createObjectURL(h),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class p{#n;promises=this;constructor(n){this.#n=d.wrap(new u),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let s;typeof t=="string"?s=t:t&&typeof t=="object"&&(s=t.encoding);const i=await this.#n.readFile(r);return s||(s=e.isBinaryFileExtension(r)?"binary":"utf-8"),s==="binary"?i:e.decodeBuffer(i,s)}async writeFile(n,t,r){const s=a(n);let i;typeof r=="string"?i=r:r&&typeof r=="object"&&(i=r.encoding),i||(i=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const c=typeof t=="string"?e.encodeString(t,i):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(s,c)}async appendFile(n,t,r){const s=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(s,i)}async mkdir(n,t){const r=a(n);let s;return typeof t=="number"?s={recursive:!1}:s=t,this.#n.mkdir(r,s)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const s=a(n),i=a(t);return this.#n.rename(s,i,r)}async copy(n,t,r){const s=a(n),i=a(t);return this.#n.copy(s,i,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,s,i){const{bytesRead:c,buffer:f}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(f.subarray(0,c),r),{bytesRead:c,buffer:t}}async write(n,t,r,s,i,c){return this.#n.write(n,t,r,s,i,c)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async createIndex(n){const t=n.map(([r,s])=>[a(r),s]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),s=await this.#n.readFile(r);return e.decodeBuffer(s,t)}async writeText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.writeFile(s,i)}async appendText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.appendFile(s,i)}}function m(o){return new p(o)}exports.AlreadyExistsError=e.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryOperationError=e.DirectoryOperationError;exports.ExistenceError=e.ExistenceError;exports.FileBusyError=e.FileBusyError;exports.FileSystemOperationError=e.FileSystemOperationError;exports.FileTypeError=e.FileTypeError;exports.IOError=e.IOError;exports.InitializationFailedError=e.InitializationFailedError;exports.OPFSError=e.OPFSError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.OperationAbortedError=e.OperationAbortedError;exports.OperationNotSupportedError=e.OperationNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.ValidationError=e.ValidationError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=p;exports.createWorker=m;
2465
+ //# sourceMappingURL=worker-DYYLzR1Y.js.map
2466
+ `,h=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=h&&(self.URL||self.webkitURL).createObjectURL(h),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class p{#n;#t;promises=this;constructor(n){this.#t=new u,this.#n=d.wrap(this.#t),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let s;typeof t=="string"?s=t:t&&typeof t=="object"&&(s=t.encoding);const i=await this.#n.readFile(r);return s||(s=e.isBinaryFileExtension(r)?"binary":"utf-8"),s==="binary"?i:e.decodeBuffer(i,s)}async writeFile(n,t,r){const s=a(n);let i;typeof r=="string"?i=r:r&&typeof r=="object"&&(i=r.encoding),i||(i=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const c=typeof t=="string"?e.encodeString(t,i):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(s,c)}async appendFile(n,t,r){const s=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(s,i)}async mkdir(n,t){const r=a(n);let s;return typeof t=="number"?s={recursive:!1}:s=t,this.#n.mkdir(r,s)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const s=a(n),i=a(t);return this.#n.rename(s,i,r)}async copy(n,t,r){const s=a(n),i=a(t);return this.#n.copy(s,i,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,s,i){const{bytesRead:c,buffer:f}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(f.subarray(0,c),r),{bytesRead:c,buffer:t}}async write(n,t,r,s,i,c){return this.#n.write(n,t,r,s,i,c)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}async createIndex(n){const t=n.map(([r,s])=>[a(r),s]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),s=await this.#n.readFile(r);return e.decodeBuffer(s,t)}async writeText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.writeFile(s,i)}async appendText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.appendFile(s,i)}dispose(){const n=this.#n,t=this.#t;(async()=>{try{await n.dispose()}finally{t.terminate()}})()}}function m(o){return new p(o)}exports.AlreadyExistsError=e.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryOperationError=e.DirectoryOperationError;exports.ExistenceError=e.ExistenceError;exports.FileBusyError=e.FileBusyError;exports.FileSystemOperationError=e.FileSystemOperationError;exports.FileTypeError=e.FileTypeError;exports.IOError=e.IOError;exports.InitializationFailedError=e.InitializationFailedError;exports.OPFSError=e.OPFSError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.OperationAbortedError=e.OperationAbortedError;exports.OperationNotSupportedError=e.OperationNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.ValidationError=e.ValidationError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=p;exports.createWorker=m;
2458
2467
  //# sourceMappingURL=index.cjs.map