opfs-worker 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +89 -106
  2. package/dist/{facade.d.ts → OPFSFacade.d.ts} +22 -5
  3. package/dist/OPFSFacade.d.ts.map +1 -0
  4. package/dist/{worker.d.ts → OPFSWorker.d.ts} +10 -6
  5. package/dist/OPFSWorker.d.ts.map +1 -0
  6. package/dist/assets/worker.entry-DUlEoroc.js.map +1 -0
  7. package/dist/createOPFSWorker.d.ts +17 -0
  8. package/dist/createOPFSWorker.d.ts.map +1 -0
  9. package/dist/helpers-DNj8ZoMu.cjs +4 -0
  10. package/dist/helpers-DNj8ZoMu.cjs.map +1 -0
  11. package/dist/{helpers-Ca2c767K.js → helpers-WY2jfbOT.js} +221 -221
  12. package/dist/helpers-WY2jfbOT.js.map +1 -0
  13. package/dist/index.cjs +296 -285
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +3 -9
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +369 -340
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.pure.cjs +2 -0
  20. package/dist/index.pure.cjs.map +1 -0
  21. package/dist/index.pure.d.ts +6 -0
  22. package/dist/index.pure.d.ts.map +1 -0
  23. package/dist/{raw.js → index.pure.js} +241 -186
  24. package/dist/index.pure.js.map +1 -0
  25. package/dist/types.d.ts +1 -1
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/utils/helpers.d.ts +11 -1
  28. package/dist/utils/helpers.d.ts.map +1 -1
  29. package/dist/worker.entry.d.ts +2 -0
  30. package/dist/worker.entry.d.ts.map +1 -0
  31. package/docs/api-reference.md +815 -0
  32. package/docs/file-descriptors.md +696 -0
  33. package/docs/types.md +232 -0
  34. package/package.json +14 -8
  35. package/src/OPFSFacade.ts +460 -0
  36. package/src/OPFSWorker.ts +1544 -0
  37. package/src/createOPFSWorker.ts +57 -0
  38. package/src/index.pure.ts +7 -0
  39. package/src/index.ts +15 -0
  40. package/src/types.ts +99 -0
  41. package/src/utils/encoder.ts +205 -0
  42. package/src/utils/errors.ts +297 -0
  43. package/src/utils/helpers.ts +465 -0
  44. package/src/worker.entry.ts +6 -0
  45. package/dist/assets/worker-1Wh1cr7P.js.map +0 -1
  46. package/dist/assets/worker-BeJaVyBV.js.map +0 -1
  47. package/dist/assets/worker-DYYLzR1Y.js.map +0 -1
  48. package/dist/facade.d.ts.map +0 -1
  49. package/dist/helpers-BuGfPAg0.js +0 -1439
  50. package/dist/helpers-BuGfPAg0.js.map +0 -1
  51. package/dist/helpers-CF7A2WQG.cjs +0 -4
  52. package/dist/helpers-CF7A2WQG.cjs.map +0 -1
  53. package/dist/helpers-CIiblZ8d.cjs +0 -4
  54. package/dist/helpers-CIiblZ8d.cjs.map +0 -1
  55. package/dist/helpers-CKOebsbw.js +0 -1423
  56. package/dist/helpers-CKOebsbw.js.map +0 -1
  57. package/dist/helpers-Ca2c767K.js.map +0 -1
  58. package/dist/helpers-Dwc92hv9.cjs +0 -4
  59. package/dist/helpers-Dwc92hv9.cjs.map +0 -1
  60. package/dist/raw.cjs +0 -2
  61. package/dist/raw.cjs.map +0 -1
  62. package/dist/raw.d.ts +0 -13
  63. package/dist/raw.d.ts.map +0 -1
  64. package/dist/raw.js.map +0 -1
  65. package/dist/worker.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
+ import { i as h, d as l, e as c } from "./helpers-WY2jfbOT.js";
2
+ import { A as F, M as A, D as T, E as R, F as C, j as I, c as D, I as $, h as _, O as N, a as k, f as z, g as M, P as j, b as W, S as L, V as U, W as H, o as B, B as G, z as q, K as Y, l as V, C as Z, y as J, k as X, L as K, p as Q, x as nn, u as tn, n as en, m as rn, t as sn, r as an, q as on, G as cn, v as hn, J as ln, s as pn, H as fn, w as dn } from "./helpers-WY2jfbOT.js";
1
3
  import { wrap as u } from "comlink";
2
- import { i as h, d as l, e as c } from "./helpers-Ca2c767K.js";
3
- import { A as E, M as S, D as P, E as O, F, j as A, c as T, I as R, h as C, O as I, a as D, f as $, g as _, P as N, b as k, S as z, V as M, W as j, o as L, B as W, z as U, K as H, l as B, C as G, y as Y, k as q, L as V, p as Z, x as J, u as X, n as K, m as Q, t as nn, r as tn, q as en, G as rn, v as sn, J as an, s as on, H as cn, w as hn } from "./helpers-Ca2c767K.js";
4
4
  const f = `/**
5
5
  * @license
6
6
  * Copyright 2019 Google LLC
7
7
  * SPDX-License-Identifier: Apache-2.0
8
8
  */
9
- const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), _ = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
9
+ const bt = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
10
10
  canHandle: (s) => Ot(s) && s[bt],
11
11
  serialize(s) {
12
12
  const { port1: t, port2: e } = new MessageChannel();
@@ -16,7 +16,7 @@ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol
16
16
  return s.start(), Gt(s);
17
17
  }
18
18
  }, _t = {
19
- canHandle: (s) => Ot(s) && _ in s,
19
+ canHandle: (s) => Ot(s) && j in s,
20
20
  serialize({ value: s }) {
21
21
  let t;
22
22
  return s instanceof Error ? t = {
@@ -49,30 +49,30 @@ function ot(s, t = globalThis, e = ["*"]) {
49
49
  console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
50
50
  return;
51
51
  }
52
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
52
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(C);
53
53
  let h;
54
54
  try {
55
- const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
55
+ const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
56
56
  switch (o) {
57
57
  case "GET":
58
58
  h = f;
59
59
  break;
60
60
  case "SET":
61
- c[a.slice(-1)[0]] = C(r.data.value), h = !0;
61
+ l[a.slice(-1)[0]] = C(r.data.value), h = !0;
62
62
  break;
63
63
  case "APPLY":
64
- h = f.apply(c, l);
64
+ h = f.apply(l, c);
65
65
  break;
66
66
  case "CONSTRUCT":
67
67
  {
68
- const u = new f(...l);
68
+ const u = new f(...c);
69
69
  h = Zt(u);
70
70
  }
71
71
  break;
72
72
  case "ENDPOINT":
73
73
  {
74
74
  const { port1: u, port2: d } = new MessageChannel();
75
- ot(s, d), h = U(u, [u]);
75
+ ot(s, d), h = _(u, [u]);
76
76
  }
77
77
  break;
78
78
  case "RELEASE":
@@ -81,16 +81,16 @@ function ot(s, t = globalThis, e = ["*"]) {
81
81
  default:
82
82
  return;
83
83
  }
84
- } catch (c) {
85
- h = { value: c, [_]: 0 };
84
+ } catch (l) {
85
+ h = { value: l, [j]: 0 };
86
86
  }
87
- Promise.resolve(h).catch((c) => ({ value: c, [_]: 0 })).then((c) => {
88
- const [f, u] = V(c);
89
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), X in s && typeof s[X] == "function" && s[X]());
90
- }).catch((c) => {
87
+ Promise.resolve(h).catch((l) => ({ value: l, [j]: 0 })).then((l) => {
88
+ const [f, u] = V(l);
89
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), At(t), X in s && typeof s[X] == "function" && s[X]());
90
+ }).catch((l) => {
91
91
  const [f, u] = V({
92
92
  value: new TypeError("Unserializable return value"),
93
- [_]: 0
93
+ [j]: 0
94
94
  });
95
95
  t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
96
96
  });
@@ -99,7 +99,7 @@ function ot(s, t = globalThis, e = ["*"]) {
99
99
  function Bt(s) {
100
100
  return s.constructor.name === "MessagePort";
101
101
  }
102
- function vt(s) {
102
+ function At(s) {
103
103
  Bt(s) && s.close();
104
104
  }
105
105
  function Gt(s, t) {
@@ -117,20 +117,20 @@ function Gt(s, t) {
117
117
  }
118
118
  }), st(s, e, [], t);
119
119
  }
120
- function H(s) {
120
+ function L(s) {
121
121
  if (s)
122
122
  throw new Error("Proxy has been released and is not useable");
123
123
  }
124
- function At(s) {
125
- return F(s, /* @__PURE__ */ new Map(), {
124
+ function vt(s) {
125
+ return $(s, /* @__PURE__ */ new Map(), {
126
126
  type: "RELEASE"
127
127
  }).then(() => {
128
- vt(s);
128
+ At(s);
129
129
  });
130
130
  }
131
131
  const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
132
  const t = (G.get(s) || 0) - 1;
133
- G.set(s, t), t === 0 && At(s);
133
+ G.set(s, t), t === 0 && vt(s);
134
134
  });
135
135
  function qt(s, t) {
136
136
  const e = (G.get(t) || 0) + 1;
@@ -144,53 +144,53 @@ function st(s, t, e = [], n = function() {
144
144
  let r = !1;
145
145
  const i = new Proxy(n, {
146
146
  get(o, a) {
147
- if (H(r), a === Wt)
147
+ if (L(r), a === Wt)
148
148
  return () => {
149
- Vt(i), At(s), t.clear(), r = !0;
149
+ Vt(i), vt(s), t.clear(), r = !0;
150
150
  };
151
151
  if (a === "then") {
152
152
  if (e.length === 0)
153
153
  return { then: () => i };
154
- const l = F(s, t, {
154
+ const c = $(s, t, {
155
155
  type: "GET",
156
156
  path: e.map((h) => h.toString())
157
157
  }).then(C);
158
- return l.then.bind(l);
158
+ return c.then.bind(c);
159
159
  }
160
160
  return st(s, t, [...e, a]);
161
161
  },
162
- set(o, a, l) {
163
- H(r);
164
- const [h, c] = V(l);
165
- return F(s, t, {
162
+ set(o, a, c) {
163
+ L(r);
164
+ const [h, l] = V(c);
165
+ return $(s, t, {
166
166
  type: "SET",
167
167
  path: [...e, a].map((f) => f.toString()),
168
168
  value: h
169
- }, c).then(C);
169
+ }, l).then(C);
170
170
  },
171
- apply(o, a, l) {
172
- H(r);
171
+ apply(o, a, c) {
172
+ L(r);
173
173
  const h = e[e.length - 1];
174
- if (h === Ht)
175
- return F(s, t, {
174
+ if (h === zt)
175
+ return $(s, t, {
176
176
  type: "ENDPOINT"
177
177
  }).then(C);
178
178
  if (h === "bind")
179
179
  return st(s, t, e.slice(0, -1));
180
- const [c, f] = ht(l);
181
- return F(s, t, {
180
+ const [l, f] = ht(c);
181
+ return $(s, t, {
182
182
  type: "APPLY",
183
183
  path: e.map((u) => u.toString()),
184
- argumentList: c
184
+ argumentList: l
185
185
  }, f).then(C);
186
186
  },
187
187
  construct(o, a) {
188
- H(r);
189
- const [l, h] = ht(a);
190
- return F(s, t, {
188
+ L(r);
189
+ const [c, h] = ht(a);
190
+ return $(s, t, {
191
191
  type: "CONSTRUCT",
192
- path: e.map((c) => c.toString()),
193
- argumentList: l
192
+ path: e.map((l) => l.toString()),
193
+ argumentList: c
194
194
  }, h).then(C);
195
195
  }
196
196
  });
@@ -204,7 +204,7 @@ function ht(s) {
204
204
  return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
205
205
  }
206
206
  const Nt = /* @__PURE__ */ new WeakMap();
207
- function U(s, t) {
207
+ function _(s, t) {
208
208
  return Nt.set(s, t), s;
209
209
  }
210
210
  function Zt(s) {
@@ -239,7 +239,7 @@ function C(s) {
239
239
  return s.value;
240
240
  }
241
241
  }
242
- function F(s, t, e, n) {
242
+ function $(s, t, e, n) {
243
243
  return new Promise((r) => {
244
244
  const i = Xt();
245
245
  t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
@@ -248,7 +248,7 @@ function F(s, t, e, n) {
248
248
  function Xt() {
249
249
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
250
250
  }
251
- var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
251
+ var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
252
252
  const Jt = {
253
253
  ENOENT: -2,
254
254
  // No such file or directory
@@ -299,7 +299,7 @@ class Kt extends w {
299
299
  super(t, "INVALID_PATH", e, "access", n);
300
300
  }
301
301
  }
302
- class R extends w {
302
+ class U extends w {
303
303
  constructor(t, e, n) {
304
304
  const r = {
305
305
  file: \`File not found: \${e}\`,
@@ -381,11 +381,11 @@ class Q extends w {
381
381
  super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
382
382
  }
383
383
  }
384
- function W(s, t, e, n) {
384
+ function z(s, t, e, n) {
385
385
  const r = \`\${s.toUpperCase()}_FAILED\`;
386
386
  return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
387
387
  }
388
- function v(s, t) {
388
+ function O(s, t) {
389
389
  const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
390
390
  switch (s.name) {
391
391
  case "InvalidStateError":
@@ -393,7 +393,7 @@ function v(s, t) {
393
393
  case "QuotaExceededError":
394
394
  return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
395
395
  case "NotFoundError":
396
- return new R(r, e, s);
396
+ return new U(r, e, s);
397
397
  case "TypeMismatchError":
398
398
  return n !== void 0 ? n ? new nt("directory", e || "unknown", s) : new nt("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
399
399
  case "NotAllowedError":
@@ -411,7 +411,7 @@ function v(s, t) {
411
411
  return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
412
412
  }
413
413
  }
414
- const Ft = (s, t, e) => {
414
+ const $t = (s, t, e) => {
415
415
  const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
416
416
  return i && {
417
417
  start: i[0],
@@ -424,37 +424,37 @@ const Ft = (s, t, e) => {
424
424
  const e = t.match(s);
425
425
  return e ? e[0] : null;
426
426
  }, ie = (s, t, e) => {
427
- let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
428
- if (l >= 0 && h > 0) {
427
+ let n, r, i, o, a, c = e.indexOf(s), h = e.indexOf(t, c + 1), l = c;
428
+ if (c >= 0 && h > 0) {
429
429
  if (s === t)
430
- return [l, h];
431
- for (n = [], i = e.length; c >= 0 && !a; ) {
432
- if (c === l)
433
- n.push(c), l = e.indexOf(s, c + 1);
430
+ return [c, h];
431
+ for (n = [], i = e.length; l >= 0 && !a; ) {
432
+ if (l === c)
433
+ n.push(l), c = e.indexOf(s, l + 1);
434
434
  else if (n.length === 1) {
435
435
  const f = n.pop();
436
436
  f !== void 0 && (a = [f, h]);
437
437
  } else
438
- r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
439
- c = l < h && l >= 0 ? l : h;
438
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
439
+ l = c < h && c >= 0 ? c : h;
440
440
  }
441
441
  n.length && o !== void 0 && (a = [i, o]);
442
442
  }
443
443
  return a;
444
- }, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", 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;
444
+ }, Ft = "\\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(Ft, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Tt, "g"), he = new RegExp(Pt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
445
445
  function K(s) {
446
446
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
447
447
  }
448
448
  function we(s) {
449
- return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
449
+ return s.replace(ue, Ft).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
450
450
  }
451
- function me(s) {
451
+ function ye(s) {
452
452
  return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
453
453
  }
454
454
  function Rt(s) {
455
455
  if (!s)
456
456
  return [""];
457
- const t = [], e = Ft("{", "}", s);
457
+ const t = [], e = $t("{", "}", s);
458
458
  if (!e)
459
459
  return s.split(",");
460
460
  const { pre: n, body: r, post: i } = e, o = n.split(",");
@@ -462,8 +462,8 @@ function Rt(s) {
462
462
  const a = Rt(i);
463
463
  return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
464
464
  }
465
- function ye(s) {
466
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), k(we(s), !0).map(me)) : [];
465
+ function me(s) {
466
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), R(we(s), !0).map(ye)) : [];
467
467
  }
468
468
  function Ee(s) {
469
469
  return "{" + s + "}";
@@ -477,54 +477,54 @@ function xe(s, t) {
477
477
  function be(s, t) {
478
478
  return s >= t;
479
479
  }
480
- function k(s, t) {
481
- const e = [], n = Ft("{", "}", s);
480
+ function R(s, t) {
481
+ const e = [], n = $t("{", "}", s);
482
482
  if (!n)
483
483
  return [s];
484
- const r = n.pre, i = n.post.length ? k(n.post, !1) : [""];
484
+ const r = n.pre, i = n.post.length ? R(n.post, !1) : [""];
485
485
  if (/\\$$/.test(n.pre))
486
486
  for (let o = 0; o < i.length; o++) {
487
487
  const a = r + "{" + n.body + "}" + i[o];
488
488
  e.push(a);
489
489
  }
490
490
  else {
491
- const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
492
- if (!l && !h)
493
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, k(s)) : [s];
494
- let c;
495
- if (l)
496
- c = n.body.split(/\\.\\./);
497
- else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = k(c[0], !1).map(Ee), c.length === 1))
498
- return i.map((u) => n.pre + c[0] + u);
491
+ const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), c = o || a, h = n.body.indexOf(",") >= 0;
492
+ if (!c && !h)
493
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, R(s)) : [s];
494
+ let l;
495
+ if (c)
496
+ l = n.body.split(/\\.\\./);
497
+ else if (l = Rt(n.body), l.length === 1 && l[0] !== void 0 && (l = R(l[0], !1).map(Ee), l.length === 1))
498
+ return i.map((u) => n.pre + l[0] + u);
499
499
  let f;
500
- if (l && c[0] !== void 0 && c[1] !== void 0) {
501
- const u = K(c[0]), d = K(c[1]), g = Math.max(c[0].length, c[1].length);
502
- let p = c.length === 3 && c[2] !== void 0 ? Math.abs(K(c[2])) : 1, S = xe;
500
+ if (c && l[0] !== void 0 && l[1] !== void 0) {
501
+ const u = K(l[0]), d = K(l[1]), g = Math.max(l[0].length, l[1].length);
502
+ let p = l.length === 3 && l[2] !== void 0 ? Math.abs(K(l[2])) : 1, S = xe;
503
503
  d < u && (p *= -1, S = be);
504
- const M = c.some(Se);
504
+ const M = l.some(Se);
505
505
  f = [];
506
506
  for (let x = u; S(x, d); x += p) {
507
- let m;
507
+ let y;
508
508
  if (a)
509
- m = String.fromCharCode(x), m === "\\\\" && (m = "");
510
- else if (m = String(x), M) {
511
- const T = g - m.length;
509
+ y = String.fromCharCode(x), y === "\\\\" && (y = "");
510
+ else if (y = String(x), M) {
511
+ const T = g - y.length;
512
512
  if (T > 0) {
513
- const z = new Array(T + 1).join("0");
514
- x < 0 ? m = "-" + z + m.slice(1) : m = z + m;
513
+ const H = new Array(T + 1).join("0");
514
+ x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
515
515
  }
516
516
  }
517
- f.push(m);
517
+ f.push(y);
518
518
  }
519
519
  } else {
520
520
  f = [];
521
- for (let u = 0; u < c.length; u++)
522
- f.push.apply(f, k(c[u], !1));
521
+ for (let u = 0; u < l.length; u++)
522
+ f.push.apply(f, R(l[u], !1));
523
523
  }
524
524
  for (let u = 0; u < f.length; u++)
525
525
  for (let d = 0; d < i.length; d++) {
526
526
  const g = r + f[u] + i[d];
527
- (!t || l || g) && e.push(g);
527
+ (!t || c || g) && e.push(g);
528
528
  }
529
529
  }
530
530
  return e;
@@ -549,36 +549,36 @@ const Oe = 1024 * 64, Y = (s) => {
549
549
  "[:upper:]": ["\\\\p{Lu}", !0],
550
550
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
551
551
  "[:xdigit:]": ["A-Fa-f0-9", !1]
552
- }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
552
+ }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), ve = (s, t) => {
553
553
  const e = t;
554
554
  if (s.charAt(e) !== "[")
555
555
  throw new Error("not in a brace expression");
556
556
  const n = [], r = [];
557
- let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
557
+ let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
558
558
  t: for (; i < s.length; ) {
559
559
  const p = s.charAt(i);
560
560
  if ((p === "!" || p === "^") && i === e + 1) {
561
561
  h = !0, i++;
562
562
  continue;
563
563
  }
564
- if (p === "]" && o && !l) {
565
- c = i + 1;
564
+ if (p === "]" && o && !c) {
565
+ l = i + 1;
566
566
  break;
567
567
  }
568
- if (o = !0, p === "\\\\" && !l) {
569
- l = !0, i++;
568
+ if (o = !0, p === "\\\\" && !c) {
569
+ c = !0, i++;
570
570
  continue;
571
571
  }
572
- if (p === "[" && !l) {
573
- for (const [S, [A, M, x]] of Object.entries(De))
572
+ if (p === "[" && !c) {
573
+ for (const [S, [v, M, x]] of Object.entries(De))
574
574
  if (s.startsWith(S, i)) {
575
575
  if (f)
576
576
  return ["$.", !1, s.length - e, !0];
577
- i += S.length, x ? r.push(A) : n.push(A), a = a || M;
577
+ i += S.length, x ? r.push(v) : n.push(v), a = a || M;
578
578
  continue t;
579
579
  }
580
580
  }
581
- if (l = !1, f) {
581
+ if (c = !1, f) {
582
582
  p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
583
583
  continue;
584
584
  }
@@ -592,17 +592,17 @@ const Oe = 1024 * 64, Y = (s) => {
592
592
  }
593
593
  n.push(P(p)), i++;
594
594
  }
595
- if (c < i)
595
+ if (l < i)
596
596
  return ["", !1, 0, !1];
597
597
  if (!n.length && !r.length)
598
598
  return ["$.", !1, s.length - e, !0];
599
599
  if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
600
600
  const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
601
- return [ve(p), !1, c - e, !1];
601
+ return [Ae(p), !1, l - e, !1];
602
602
  }
603
603
  const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
604
- return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
605
- }, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
604
+ return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, l - e, !0];
605
+ }, 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Fe = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
606
606
  class E {
607
607
  type;
608
608
  #s;
@@ -703,7 +703,7 @@ class E {
703
703
  return e;
704
704
  }
705
705
  static #h(t, e, n, r) {
706
- let i = !1, o = !1, a = -1, l = !1;
706
+ let i = !1, o = !1, a = -1, c = !1;
707
707
  if (e.type === null) {
708
708
  let d = n, g = "";
709
709
  for (; d < t.length; ) {
@@ -713,10 +713,10 @@ class E {
713
713
  continue;
714
714
  }
715
715
  if (o) {
716
- d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
716
+ d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
717
717
  continue;
718
718
  } else if (p === "[") {
719
- o = !0, a = d, l = !1, g += p;
719
+ o = !0, a = d, c = !1, g += p;
720
720
  continue;
721
721
  }
722
722
  if (!r.noext && pt(p) && t.charAt(d) === "(") {
@@ -729,7 +729,7 @@ class E {
729
729
  }
730
730
  return e.push(g), d;
731
731
  }
732
- let h = n + 1, c = new E(null, e);
732
+ let h = n + 1, l = new E(null, e);
733
733
  const f = [];
734
734
  let u = "";
735
735
  for (; h < t.length; ) {
@@ -739,24 +739,24 @@ class E {
739
739
  continue;
740
740
  }
741
741
  if (o) {
742
- h === a + 1 ? (d === "^" || d === "!") && (l = !0) : d === "]" && !(h === a + 2 && l) && (o = !1), u += d;
742
+ h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
743
743
  continue;
744
744
  } else if (d === "[") {
745
- o = !0, a = h, l = !1, u += d;
745
+ o = !0, a = h, c = !1, u += d;
746
746
  continue;
747
747
  }
748
748
  if (pt(d) && t.charAt(h) === "(") {
749
- c.push(u), u = "";
750
- const g = new E(d, c);
751
- c.push(g), h = E.#h(t, g, h, r);
749
+ l.push(u), u = "";
750
+ const g = new E(d, l);
751
+ l.push(g), h = E.#h(t, g, h, r);
752
752
  continue;
753
753
  }
754
754
  if (d === "|") {
755
- c.push(u), u = "", f.push(c), c = new E(null, e);
755
+ l.push(u), u = "", f.push(l), l = new E(null, e);
756
756
  continue;
757
757
  }
758
758
  if (d === ")")
759
- return u === "" && e.#t.length === 0 && (e.#u = !0), c.push(u), u = "", e.push(...f, c), h;
759
+ return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
760
760
  u += d;
761
761
  }
762
762
  return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
@@ -854,24 +854,24 @@ class E {
854
854
  toRegExpSource(t) {
855
855
  const e = t ?? !!this.#r.dot;
856
856
  if (this.#s === this && this.#d(), !this.type) {
857
- const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
858
- const [g, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
859
- return this.#n = this.#n || S, this.#i = this.#i || A, g;
857
+ const c = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
858
+ const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, c) : d.toRegExpSource(t);
859
+ return this.#n = this.#n || S, this.#i = this.#i || v, g;
860
860
  }).join("");
861
- let c = "";
862
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
863
- const g = Fe, p = (
861
+ let l = "";
862
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Fe.has(this.#t[0]))) {
863
+ const g = $e, p = (
864
864
  // dots are allowed, and the pattern starts with [ or .
865
865
  e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
866
866
  h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
867
867
  h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
868
868
  ), S = !e && !t && g.has(h.charAt(0));
869
- c = p ? Ce : S ? j : "";
869
+ l = p ? Ce : S ? W : "";
870
870
  }
871
871
  let f = "";
872
872
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
873
- c + h + f,
874
- I(h),
873
+ l + h + f,
874
+ k(h),
875
875
  this.#n = !!this.#n,
876
876
  this.#i
877
877
  ];
@@ -879,24 +879,24 @@ class E {
879
879
  const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
880
880
  let i = this.#f(e);
881
881
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
882
- const l = this.toString();
883
- return this.#t = [l], this.type = null, this.#n = void 0, [l, I(this.toString()), !1, !1];
882
+ const c = this.toString();
883
+ return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
884
884
  }
885
- let o = !n || t || e || !j ? "" : this.#f(!0);
885
+ let o = !n || t || e || !W ? "" : this.#f(!0);
886
886
  o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
887
887
  let a = "";
888
888
  if (this.type === "!" && this.#u)
889
- a = (this.isStart() && !e ? j : "") + wt;
889
+ a = (this.isStart() && !e ? W : "") + wt;
890
890
  else {
891
- const l = this.type === "!" ? (
891
+ const c = this.type === "!" ? (
892
892
  // !() must match something,but !(x) can match ''
893
- "))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
893
+ "))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
894
894
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
895
- a = r + i + l;
895
+ a = r + i + c;
896
896
  }
897
897
  return [
898
898
  a,
899
- I(i),
899
+ k(i),
900
900
  this.#n = !!this.#n,
901
901
  this.#i
902
902
  ];
@@ -912,36 +912,36 @@ class E {
912
912
  static #p(t, e, n = !1) {
913
913
  let r = !1, i = "", o = !1;
914
914
  for (let a = 0; a < t.length; a++) {
915
- const l = t.charAt(a);
915
+ const c = t.charAt(a);
916
916
  if (r) {
917
- r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
917
+ r = !1, i += (Me.has(c) ? "\\\\" : "") + c;
918
918
  continue;
919
919
  }
920
- if (l === "\\\\") {
920
+ if (c === "\\\\") {
921
921
  a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
922
922
  continue;
923
923
  }
924
- if (l === "[") {
925
- const [h, c, f, u] = Ae(t, a);
924
+ if (c === "[") {
925
+ const [h, l, f, u] = ve(t, a);
926
926
  if (f) {
927
- i += h, o = o || c, a += f - 1, e = e || u;
927
+ i += h, o = o || l, a += f - 1, e = e || u;
928
928
  continue;
929
929
  }
930
930
  }
931
- if (l === "*") {
931
+ if (c === "*") {
932
932
  n && t === "*" ? i += wt : i += gt, e = !0;
933
933
  continue;
934
934
  }
935
- if (l === "?") {
935
+ if (c === "?") {
936
936
  i += ct, e = !0;
937
937
  continue;
938
938
  }
939
- i += Te(l);
939
+ i += Te(c);
940
940
  }
941
- return [i, I(t), !!e, o];
941
+ return [i, k(t), !!e, o];
942
942
  }
943
943
  }
944
- const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Y(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new Z(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Ie = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
944
+ const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (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), He = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), ze = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
945
945
  const e = kt([s]);
946
946
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
947
947
  }, Ze = ([s, t = ""]) => {
@@ -959,19 +959,19 @@ const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
959
959
  }, It = ([s]) => {
960
960
  const t = s.length;
961
961
  return (e) => e.length === t && e !== "." && e !== "..";
962
- }, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
962
+ }, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
963
963
  win32: { sep: "\\\\" },
964
964
  posix: { sep: "/" }
965
- }, Qe = Lt === "win32" ? mt.win32.sep : mt.posix.sep;
966
- y.sep = Qe;
967
- const O = Symbol("globstar **");
968
- y.GLOBSTAR = O;
969
- const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
970
- y.filter = ns;
965
+ }, Qe = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
966
+ m.sep = Qe;
967
+ const D = Symbol("globstar **");
968
+ m.GLOBSTAR = D;
969
+ const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => m(e, s, t);
970
+ m.filter = ns;
971
971
  const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
972
972
  if (!s || typeof s != "object" || !Object.keys(s).length)
973
- return y;
974
- const t = y;
973
+ return m;
974
+ const t = m;
975
975
  return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
976
976
  Minimatch: class extends t.Minimatch {
977
977
  constructor(r, i = {}) {
@@ -999,20 +999,20 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
999
999
  braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
1000
1000
  match: (n, r, i = {}) => t.match(n, r, b(s, i)),
1001
1001
  sep: t.sep,
1002
- GLOBSTAR: O
1002
+ GLOBSTAR: D
1003
1003
  });
1004
1004
  };
1005
- y.defaults = rs;
1006
- const zt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1007
- y.braceExpand = zt;
1005
+ m.defaults = rs;
1006
+ const Lt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : me(s));
1007
+ m.braceExpand = Lt;
1008
1008
  const is = (s, t = {}) => new Z(s, t).makeRe();
1009
- y.makeRe = is;
1009
+ m.makeRe = is;
1010
1010
  const os = (s, t, e = {}) => {
1011
1011
  const n = new Z(t, e);
1012
1012
  return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
1013
1013
  };
1014
- y.match = os;
1015
- const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1014
+ m.match = os;
1015
+ const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1016
1016
  class Z {
1017
1017
  options;
1018
1018
  set;
@@ -1032,7 +1032,7 @@ class Z {
1032
1032
  windowsNoMagicRoot;
1033
1033
  regexp;
1034
1034
  constructor(t, e = {}) {
1035
- Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1035
+ Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ht, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1036
1036
  }
1037
1037
  hasMagic() {
1038
1038
  if (this.options.magicalBraces && this.set.length > 1)
@@ -1060,13 +1060,13 @@ class Z {
1060
1060
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
1061
1061
  let r = this.globParts.map((i, o, a) => {
1062
1062
  if (this.isWindows && this.windowsNoMagicRoot) {
1063
- const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1064
- if (l)
1065
- return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
1063
+ const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1064
+ if (c)
1065
+ return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
1066
1066
  if (h)
1067
- return [i[0], ...i.slice(1).map((c) => this.parse(c))];
1067
+ return [i[0], ...i.slice(1).map((l) => this.parse(l))];
1068
1068
  }
1069
- return i.map((l) => this.parse(l));
1069
+ return i.map((c) => this.parse(c));
1070
1070
  });
1071
1071
  if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1072
1072
  for (let i = 0; i < this.set.length; i++) {
@@ -1157,12 +1157,12 @@ class Z {
1157
1157
  o++;
1158
1158
  o > r && n.splice(r + 1, o - r);
1159
1159
  let a = n[r + 1];
1160
- const l = n[r + 2], h = n[r + 3];
1161
- if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1160
+ const c = n[r + 2], h = n[r + 3];
1161
+ if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
1162
1162
  continue;
1163
1163
  e = !0, n.splice(r, 1);
1164
- const c = n.slice(0);
1165
- c[r] = "**", t.push(c), r--;
1164
+ const l = n.slice(0);
1165
+ l[r] = "**", t.push(l), r--;
1166
1166
  }
1167
1167
  if (!this.preserveMultipleSlashes) {
1168
1168
  for (let o = 1; o < n.length - 1; o++) {
@@ -1176,8 +1176,8 @@ class Z {
1176
1176
  const o = n[i - 1];
1177
1177
  if (o && o !== "." && o !== ".." && o !== "**") {
1178
1178
  e = !0;
1179
- const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
1180
- n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
1179
+ const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
1180
+ n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
1181
1181
  }
1182
1182
  }
1183
1183
  }
@@ -1240,33 +1240,33 @@ class Z {
1240
1240
  matchOne(t, e, n = !1) {
1241
1241
  const r = this.options;
1242
1242
  if (this.isWindows) {
1243
- const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = M ? 3 : A ? 0 : void 0;
1244
- if (typeof x == "number" && typeof m == "number") {
1245
- const [T, z] = [t[x], e[m]];
1246
- T.toLowerCase() === z.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1243
+ const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, y = M ? 3 : v ? 0 : void 0;
1244
+ if (typeof x == "number" && typeof y == "number") {
1245
+ const [T, H] = [t[x], e[y]];
1246
+ T.toLowerCase() === H.toLowerCase() && (e[y] = T, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
1247
1247
  }
1248
1248
  }
1249
1249
  const { optimizationLevel: i = 1 } = this.options;
1250
1250
  i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1251
- for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1251
+ for (var o = 0, a = 0, c = t.length, h = e.length; o < c && a < h; o++, a++) {
1252
1252
  this.debug("matchOne loop");
1253
- var c = e[a], f = t[o];
1254
- if (this.debug(e, c, f), c === !1)
1253
+ var l = e[a], f = t[o];
1254
+ if (this.debug(e, l, f), l === !1)
1255
1255
  return !1;
1256
- if (c === O) {
1257
- this.debug("GLOBSTAR", [e, c, f]);
1256
+ if (l === D) {
1257
+ this.debug("GLOBSTAR", [e, l, f]);
1258
1258
  var u = o, d = a + 1;
1259
1259
  if (d === h) {
1260
- for (this.debug("** at the end"); o < l; o++)
1260
+ for (this.debug("** at the end"); o < c; o++)
1261
1261
  if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1262
1262
  return !1;
1263
1263
  return !0;
1264
1264
  }
1265
- for (; u < l; ) {
1265
+ for (; u < c; ) {
1266
1266
  var g = t[u];
1267
1267
  if (this.debug(\`
1268
1268
  globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1269
- return this.debug("globstar found match!", u, l, g), !0;
1269
+ return this.debug("globstar found match!", u, c, g), !0;
1270
1270
  if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1271
1271
  this.debug("dot detected!", t, u, e, d);
1272
1272
  break;
@@ -1274,32 +1274,32 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1274
1274
  this.debug("globstar swallow a segment, and continue"), u++;
1275
1275
  }
1276
1276
  return !!(n && (this.debug(\`
1277
- >>> no match, partial?\`, t, u, e, d), u === l));
1277
+ >>> no match, partial?\`, t, u, e, d), u === c));
1278
1278
  }
1279
1279
  let p;
1280
- if (typeof c == "string" ? (p = f === c, this.debug("string match", c, f, p)) : (p = c.test(f), this.debug("pattern match", c, f, p)), !p)
1280
+ if (typeof l == "string" ? (p = f === l, this.debug("string match", l, f, p)) : (p = l.test(f), this.debug("pattern match", l, f, p)), !p)
1281
1281
  return !1;
1282
1282
  }
1283
- if (o === l && a === h)
1283
+ if (o === c && a === h)
1284
1284
  return !0;
1285
- if (o === l)
1285
+ if (o === c)
1286
1286
  return n;
1287
1287
  if (a === h)
1288
- return o === l - 1 && t[o] === "";
1288
+ return o === c - 1 && t[o] === "";
1289
1289
  throw new Error("wtf?");
1290
1290
  }
1291
1291
  braceExpand() {
1292
- return zt(this.pattern, this.options);
1292
+ return Lt(this.pattern, this.options);
1293
1293
  }
1294
1294
  parse(t) {
1295
1295
  Y(t);
1296
1296
  const e = this.options;
1297
1297
  if (t === "**")
1298
- return O;
1298
+ return D;
1299
1299
  if (t === "")
1300
1300
  return "";
1301
1301
  let n, r = null;
1302
- (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? 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);
1302
+ (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : He : 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(ze)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
1303
1303
  const i = E.fromGlob(t, this.options).toMMPattern();
1304
1304
  return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1305
1305
  }
@@ -1310,17 +1310,17 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1310
1310
  if (!t.length)
1311
1311
  return this.regexp = !1, this.regexp;
1312
1312
  const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
1313
- let i = t.map((l) => {
1314
- const h = l.map((c) => {
1315
- if (c instanceof RegExp)
1316
- for (const f of c.flags.split(""))
1313
+ let i = t.map((c) => {
1314
+ const h = c.map((l) => {
1315
+ if (l instanceof RegExp)
1316
+ for (const f of l.flags.split(""))
1317
1317
  r.add(f);
1318
- return typeof c == "string" ? as(c) : c === O ? O : c._src;
1318
+ return typeof l == "string" ? as(l) : l === D ? D : l._src;
1319
1319
  });
1320
- return h.forEach((c, f) => {
1320
+ return h.forEach((l, f) => {
1321
1321
  const u = h[f + 1], d = h[f - 1];
1322
- c !== O || d === O || (d === void 0 ? u !== void 0 && u !== O ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== O && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = O));
1323
- }), h.filter((c) => c !== O).join("/");
1322
+ l !== D || d === D || (d === void 0 ? u !== void 0 && u !== D ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== D && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = D));
1323
+ }), h.filter((l) => l !== D).join("/");
1324
1324
  }).join("|");
1325
1325
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1326
1326
  i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
@@ -1352,40 +1352,40 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1352
1352
  for (let a = r.length - 2; !o && a >= 0; a--)
1353
1353
  o = r[a];
1354
1354
  for (let a = 0; a < i.length; a++) {
1355
- const l = i[a];
1355
+ const c = i[a];
1356
1356
  let h = r;
1357
- if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1357
+ if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
1358
1358
  return n.flipNegate ? !0 : !this.negate;
1359
1359
  }
1360
1360
  return n.flipNegate ? !1 : this.negate;
1361
1361
  }
1362
1362
  static defaults(t) {
1363
- return y.defaults(t).Minimatch;
1363
+ return m.defaults(t).Minimatch;
1364
1364
  }
1365
1365
  }
1366
- y.AST = E;
1367
- y.Minimatch = Z;
1368
- y.escape = Pe;
1369
- y.unescape = I;
1366
+ m.AST = E;
1367
+ m.Minimatch = Z;
1368
+ m.escape = Pe;
1369
+ m.unescape = k;
1370
1370
  function cs() {
1371
1371
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1372
1372
  throw new Qt();
1373
1373
  }
1374
- async function L(s, t, e) {
1375
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1374
+ async function I(s, t) {
1375
+ return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
1376
1376
  }
1377
- function $(s) {
1377
+ function F(s) {
1378
1378
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1379
1379
  }
1380
1380
  function lt(s) {
1381
1381
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1382
1382
  }
1383
1383
  function it(s) {
1384
- const t = $(s);
1384
+ const t = F(s);
1385
1385
  return t[t.length - 1] || "";
1386
1386
  }
1387
1387
  function tt(s) {
1388
- const t = $(s);
1388
+ const t = F(s);
1389
1389
  return t.pop(), lt(t);
1390
1390
  }
1391
1391
  function B(s) {
@@ -1395,13 +1395,13 @@ function ls(s, t = !1) {
1395
1395
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1396
1396
  }
1397
1397
  function et(s, t) {
1398
- return y(s, t, {
1398
+ return m(s, t, {
1399
1399
  dot: !0,
1400
1400
  matchBase: !0
1401
1401
  });
1402
1402
  }
1403
1403
  function Et(s) {
1404
- const t = B(s), e = $(t), n = [];
1404
+ const t = B(s), e = F(t), n = [];
1405
1405
  for (const r of e)
1406
1406
  if (!(r === "." || r === ""))
1407
1407
  if (r === "..") {
@@ -1424,7 +1424,7 @@ async function us(s) {
1424
1424
  }
1425
1425
  async function fs(s, t, e = {}) {
1426
1426
  const n = it(t);
1427
- return L(t, "exclusive", async () => {
1427
+ return I(t, async () => {
1428
1428
  const r = e.recursive ?? !1, i = e.force ?? !1;
1429
1429
  try {
1430
1430
  await s.removeEntry(n, { recursive: r });
@@ -1432,7 +1432,7 @@ async function fs(s, t, e = {}) {
1432
1432
  if (o.name === "NotFoundError" && i)
1433
1433
  return;
1434
1434
  const a = o.name === "TypeMismatchError" && !r;
1435
- throw v(o, {
1435
+ throw O(o, {
1436
1436
  path: t,
1437
1437
  operation: "remove",
1438
1438
  isDirectory: a
@@ -1467,7 +1467,7 @@ async function ps(s, t) {
1467
1467
  try {
1468
1468
  return await s.createSyncAccessHandle();
1469
1469
  } catch (e) {
1470
- throw v(e, { path: t, isDirectory: !1 });
1470
+ throw O(e, { path: t, isDirectory: !1 });
1471
1471
  }
1472
1472
  }
1473
1473
  class gs {
@@ -1487,6 +1487,8 @@ class gs {
1487
1487
  hashAlgorithm: "etag",
1488
1488
  broadcastChannel: "opfs-worker"
1489
1489
  };
1490
+ /** Shared sync handles per path (OPFS allows only one handle per file) */
1491
+ openHandles = /* @__PURE__ */ new Map();
1490
1492
  /** Map of open file descriptors to their metadata */
1491
1493
  openFiles = /* @__PURE__ */ new Map();
1492
1494
  /** Next available file descriptor number */
@@ -1535,7 +1537,7 @@ class gs {
1535
1537
  }
1536
1538
  }
1537
1539
  /**
1538
- * Creates a new OPFSFileSystem instance
1540
+ * Creates a new OPFSWorker instance
1539
1541
  *
1540
1542
  * @param options - Optional configuration options
1541
1543
  * @param options.root - Root path for the file system (default: '/')
@@ -1558,7 +1560,7 @@ class gs {
1558
1560
  *
1559
1561
  * @example
1560
1562
  * \`\`\`typescript
1561
- * const fs = new OPFSFileSystem();
1563
+ * const fs = new OPFSWorker();
1562
1564
  *
1563
1565
  * // Use OPFS root (default)
1564
1566
  * await fs.mount();
@@ -1612,7 +1614,7 @@ class gs {
1612
1614
  * \`\`\`
1613
1615
  */
1614
1616
  async getDirectoryHandle(t, e = !1, n = this.root) {
1615
- const r = Array.isArray(t) ? t : $(t);
1617
+ const r = Array.isArray(t) ? t : F(t);
1616
1618
  let i = n;
1617
1619
  for (const o of r)
1618
1620
  i = await i.getDirectoryHandle(o, { create: e });
@@ -1638,7 +1640,7 @@ class gs {
1638
1640
  * \`\`\`
1639
1641
  */
1640
1642
  async getFileHandle(t, e = !1, n = this.root) {
1641
- const r = $(t);
1643
+ const r = F(t);
1642
1644
  if (r.length === 0)
1643
1645
  throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1644
1646
  const i = r.pop();
@@ -1707,17 +1709,17 @@ class gs {
1707
1709
  async readFile(t) {
1708
1710
  await this.mount();
1709
1711
  try {
1710
- return await L(t, "shared", async () => {
1712
+ return await I(t, async () => {
1711
1713
  const e = await this.open(t);
1712
1714
  try {
1713
1715
  const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1714
- return n > 0 && await this.read(e, r, 0, n, 0), U(r, [r.buffer]);
1716
+ return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
1715
1717
  } finally {
1716
1718
  await this.close(e);
1717
1719
  }
1718
1720
  });
1719
1721
  } catch (e) {
1720
- throw new R("file", t, e);
1722
+ throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
1721
1723
  }
1722
1724
  }
1723
1725
  /**
@@ -1745,14 +1747,14 @@ class gs {
1745
1747
  async writeFile(t, e) {
1746
1748
  await this.mount();
1747
1749
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1748
- await L(t, "exclusive", async () => {
1750
+ await I(t, async () => {
1749
1751
  const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
1750
1752
  try {
1751
1753
  await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
1752
1754
  } finally {
1753
1755
  await this.close(i);
1754
1756
  }
1755
- await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
1757
+ await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
1756
1758
  });
1757
1759
  }
1758
1760
  /**
@@ -1780,7 +1782,7 @@ class gs {
1780
1782
  async appendFile(t, e) {
1781
1783
  await this.mount();
1782
1784
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1783
- await L(t, "exclusive", async () => {
1785
+ await I(t, async () => {
1784
1786
  const r = await this.open(t, { create: !0 });
1785
1787
  try {
1786
1788
  const { size: i } = await this.fstat(r);
@@ -1788,7 +1790,7 @@ class gs {
1788
1790
  } finally {
1789
1791
  await this.close(r);
1790
1792
  }
1791
- await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
1793
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1792
1794
  });
1793
1795
  }
1794
1796
  /**
@@ -1814,20 +1816,20 @@ class gs {
1814
1816
  */
1815
1817
  async mkdir(t, e) {
1816
1818
  await this.mount();
1817
- const n = e?.recursive ?? !1, r = $(t);
1819
+ const n = e?.recursive ?? !1, r = F(t);
1818
1820
  let i = this.root;
1819
1821
  for (let o = 0; o < r.length; o++) {
1820
1822
  const a = r[o];
1821
1823
  try {
1822
1824
  i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1823
- } catch (l) {
1824
- throw l.name === "NotFoundError" ? v(l, {
1825
+ } catch (c) {
1826
+ throw c.name === "NotFoundError" ? O(c, {
1825
1827
  path: lt(r.slice(0, o + 1)),
1826
1828
  existenceType: "directory"
1827
- }) : l.name === "TypeMismatchError" ? v(l, { path: a, isDirectory: !1 }) : new J("create directory", a, l);
1829
+ }) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
1828
1830
  }
1829
1831
  }
1830
- await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
1832
+ await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1831
1833
  }
1832
1834
  /**
1833
1835
  * Get file or directory statistics
@@ -1877,15 +1879,15 @@ class gs {
1877
1879
  a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1878
1880
  else if (typeof r == "string")
1879
1881
  try {
1880
- const l = await hs(o, r, this.options.maxFileSize);
1881
- a.hash = l;
1882
- } catch (l) {
1883
- console.warn(\`Failed to calculate hash for \${t}:\`, l);
1882
+ const c = await hs(o, r, this.options.maxFileSize);
1883
+ a.hash = c;
1884
+ } catch (c) {
1885
+ console.warn(\`Failed to calculate hash for \${t}:\`, c);
1884
1886
  }
1885
1887
  return a;
1886
1888
  } catch (r) {
1887
1889
  if (r.name === "NotFoundError")
1888
- throw new R("file", t, r);
1890
+ throw new U("file", t, r);
1889
1891
  if (r.name !== "TypeMismatchError")
1890
1892
  throw new J("stat", t, r);
1891
1893
  }
@@ -2002,9 +2004,9 @@ class gs {
2002
2004
  const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
2003
2005
  await this.remove(r, { recursive: !0 });
2004
2006
  }
2005
- await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
2007
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
2006
2008
  } catch (e) {
2007
- throw e instanceof w ? e : v(e, { path: t, isDirectory: !0 });
2009
+ throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
2008
2010
  }
2009
2011
  }
2010
2012
  /**
@@ -2035,7 +2037,7 @@ class gs {
2035
2037
  if (await this.mount(), t === "/")
2036
2038
  throw new rt("EROOT", t);
2037
2039
  const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
2038
- await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
2040
+ await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
2039
2041
  }
2040
2042
  /**
2041
2043
  * Resolve a path to an absolute path
@@ -2060,10 +2062,10 @@ class gs {
2060
2062
  try {
2061
2063
  const e = Et(t);
2062
2064
  if (!await this.exists(e))
2063
- throw new R("file", e);
2065
+ throw new U("file", e);
2064
2066
  return e;
2065
2067
  } catch (e) {
2066
- throw e instanceof w ? e : v(e, { path: t });
2068
+ throw e instanceof w ? e : O(e, { path: t });
2067
2069
  }
2068
2070
  }
2069
2071
  /**
@@ -2094,9 +2096,9 @@ class gs {
2094
2096
  const r = n?.overwrite ?? !1, i = await this.stat(t);
2095
2097
  if (await this.exists(e) && !r)
2096
2098
  throw new Q(e);
2097
- await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
2099
+ await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: i.isDirectory });
2098
2100
  } catch (r) {
2099
- throw r instanceof w ? r : v(r, { path: t });
2101
+ throw r instanceof w ? r : O(r, { path: t });
2100
2102
  }
2101
2103
  }
2102
2104
  /**
@@ -2129,7 +2131,7 @@ class gs {
2129
2131
  try {
2130
2132
  const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2131
2133
  if (!await this.exists(t))
2132
- throw new R("source", t);
2134
+ throw new U("source", t);
2133
2135
  if (await this.exists(e) && !i)
2134
2136
  throw new Q(e);
2135
2137
  if ((await this.stat(t)).isFile) {
@@ -2140,13 +2142,13 @@ class gs {
2140
2142
  throw new nt("directory", t);
2141
2143
  await this.mkdir(e, { recursive: !0 });
2142
2144
  const h = await this.readDir(t);
2143
- for (const c of h) {
2144
- const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2145
+ for (const l of h) {
2146
+ const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
2145
2147
  await this.copy(f, u, { recursive: !0, overwrite: i });
2146
2148
  }
2147
2149
  }
2148
2150
  } catch (r) {
2149
- throw r instanceof w ? r : v(r, { path: t });
2151
+ throw r instanceof w ? r : O(r, { path: t });
2150
2152
  }
2151
2153
  }
2152
2154
  /**
@@ -2221,7 +2223,7 @@ class gs {
2221
2223
  await this.mount();
2222
2224
  const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
2223
2225
  try {
2224
- return n && r ? await L(o, "exclusive", async () => {
2226
+ return n && r ? await I(o, async () => {
2225
2227
  if (await this.exists(o))
2226
2228
  throw new Q(o);
2227
2229
  return this._openFile(o, n, i);
@@ -2229,33 +2231,40 @@ class gs {
2229
2231
  } catch (a) {
2230
2232
  if (a instanceof w)
2231
2233
  throw a;
2232
- const l = a && a.name === "TypeMismatchError";
2233
- throw v(a, {
2234
+ const c = a && a.name === "TypeMismatchError";
2235
+ throw O(a, {
2234
2236
  path: o,
2235
- isDirectory: !!l
2237
+ isDirectory: !!c
2236
2238
  });
2237
2239
  }
2238
2240
  }
2239
2241
  /**
2240
2242
  * Internal method to open a file (without locking)
2243
+ *
2244
+ * Multiple FDs for the same path share one sync access handle (OPFS limit),
2245
+ * with independent per-FD positions — similar to Node.js.
2241
2246
  * @private
2242
2247
  */
2243
2248
  async _openFile(t, e, n) {
2244
- const r = await this.getFileHandle(t, e);
2245
- try {
2246
- await r.getFile();
2247
- } catch (a) {
2248
- throw v(a, { path: t, isDirectory: !0 });
2249
+ let r = this.openHandles.get(t);
2250
+ if (!r) {
2251
+ const o = await this.getFileHandle(t, e);
2252
+ try {
2253
+ await o.getFile();
2254
+ } catch (c) {
2255
+ throw O(c, { path: t, isDirectory: !0 });
2256
+ }
2257
+ const a = await ps(o, t);
2258
+ r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
2249
2259
  }
2250
- const i = await ps(r, t);
2251
- n && (i.truncate(0), i.flush());
2252
- const o = this.nextFd++;
2253
- return this.openFiles.set(o, {
2260
+ r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
2261
+ const i = this.nextFd++;
2262
+ return this.openFiles.set(i, {
2254
2263
  path: t,
2255
- fileHandle: r,
2256
- syncHandle: i,
2264
+ fileHandle: r.fileHandle,
2265
+ syncHandle: r.syncHandle,
2257
2266
  position: 0
2258
- }), o;
2267
+ }), i;
2259
2268
  }
2260
2269
  /**
2261
2270
  * Close a file descriptor
@@ -2273,7 +2282,9 @@ class gs {
2273
2282
  */
2274
2283
  async close(t) {
2275
2284
  const e = this._getFileDescriptor(t);
2276
- xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2285
+ this.openFiles.delete(t);
2286
+ const n = this.openHandles.get(e.path);
2287
+ n && (n.refCount--, n.refCount <= 0 && (xt(t, n.syncHandle, e.path), this.openHandles.delete(e.path)));
2277
2288
  }
2278
2289
  /**
2279
2290
  * Read data from a file descriptor
@@ -2303,13 +2314,13 @@ class gs {
2303
2314
  const o = this._getFileDescriptor(t);
2304
2315
  St(e.length, n, r, i);
2305
2316
  try {
2306
- const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
2317
+ const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
2307
2318
  if (h)
2308
- return U({ bytesRead: 0, buffer: e }, [e.buffer]);
2309
- const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2310
- return i == null && (o.position = a + u), U({ bytesRead: u, buffer: e }, [e.buffer]);
2319
+ return _({ bytesRead: 0, buffer: e }, [e.buffer]);
2320
+ const f = e.subarray(n, n + l), u = o.syncHandle.read(f, { at: a });
2321
+ return i == null && (o.position = a + u), _({ bytesRead: u, buffer: e }, [e.buffer]);
2311
2322
  } catch (a) {
2312
- throw W("read", t, o.path, a);
2323
+ throw z("read", t, o.path, a);
2313
2324
  }
2314
2325
  }
2315
2326
  /**
@@ -2334,13 +2345,13 @@ class gs {
2334
2345
  * \`\`\`
2335
2346
  */
2336
2347
  async write(t, e, n = 0, r, i, o = !0) {
2337
- const a = this._getFileDescriptor(t), l = r ?? e.length - n;
2338
- St(e.length, n, l, i);
2348
+ const a = this._getFileDescriptor(t), c = r ?? e.length - n;
2349
+ St(e.length, n, c, i);
2339
2350
  try {
2340
- const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2341
- return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
2351
+ const h = i ?? a.position, l = e.subarray(n, n + c), f = a.syncHandle.write(l, { at: h });
2352
+ return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2342
2353
  } catch (h) {
2343
- throw W("write", t, a.path, h);
2354
+ throw z("write", t, a.path, h);
2344
2355
  }
2345
2356
  }
2346
2357
  /**
@@ -2386,9 +2397,9 @@ class gs {
2386
2397
  if (e < 0 || !Number.isInteger(e))
2387
2398
  throw new N("argument", "Invalid size");
2388
2399
  try {
2389
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
2400
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2390
2401
  } catch (r) {
2391
- throw W("truncate", t, n.path, r);
2402
+ throw z("truncate", t, n.path, r);
2392
2403
  }
2393
2404
  }
2394
2405
  /**
@@ -2410,7 +2421,7 @@ class gs {
2410
2421
  try {
2411
2422
  e.syncHandle.flush();
2412
2423
  } catch (n) {
2413
- throw W("sync", t, e.path, n);
2424
+ throw z("sync", t, e.path, n);
2414
2425
  }
2415
2426
  }
2416
2427
  /**
@@ -2421,9 +2432,9 @@ class gs {
2421
2432
  */
2422
2433
  dispose() {
2423
2434
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2424
- for (const [t, e] of this.openFiles)
2425
- xt(t, e.syncHandle, e.path);
2426
- this.openFiles.clear(), this.nextFd = 1;
2435
+ for (const [t, e] of this.openHandles)
2436
+ xt(-1, e.syncHandle, t);
2437
+ this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1;
2427
2438
  }
2428
2439
  /**
2429
2440
  * Synchronize the file system with external data
@@ -2460,12 +2471,12 @@ class gs {
2460
2471
  n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2461
2472
  }
2462
2473
  } catch (e) {
2463
- throw e instanceof w ? e : v(e);
2474
+ throw e instanceof w ? e : O(e);
2464
2475
  }
2465
2476
  }
2466
2477
  }
2467
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
2468
- //# sourceMappingURL=worker-DYYLzR1Y.js.map
2478
+ ot(new gs());
2479
+ //# sourceMappingURL=worker.entry-DUlEoroc.js.map
2469
2480
  `, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
2470
2481
  function m(a) {
2471
2482
  let n;
@@ -2488,15 +2499,36 @@ function m(a) {
2488
2499
  );
2489
2500
  }
2490
2501
  }
2502
+ const y = m;
2503
+ function w(a, n) {
2504
+ n && (n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), a.setOptions(n));
2505
+ }
2506
+ function g(a) {
2507
+ const n = new y(), t = u(n);
2508
+ return w(t, a), {
2509
+ fs: t,
2510
+ worker: n,
2511
+ dispose() {
2512
+ (async () => {
2513
+ try {
2514
+ await t.dispose();
2515
+ } finally {
2516
+ n.terminate();
2517
+ }
2518
+ })();
2519
+ }
2520
+ };
2521
+ }
2491
2522
  function i(a) {
2492
2523
  return a instanceof URL ? a.pathname : a;
2493
2524
  }
2494
- class y {
2525
+ class b {
2495
2526
  #n;
2496
2527
  #t;
2497
2528
  promises = this;
2498
2529
  constructor(n) {
2499
- this.#t = new m(), this.#n = u(this.#t), n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
2530
+ const t = g(n);
2531
+ this.#n = t.fs, this.#t = t.dispose;
2500
2532
  }
2501
2533
  /**
2502
2534
  * Start watching a file or directory for changes
@@ -2738,65 +2770,62 @@ class y {
2738
2770
  * Dispose of resources, detach the worker and clean up the file system instance
2739
2771
  */
2740
2772
  dispose() {
2741
- const n = this.#n, t = this.#t;
2742
- (async () => {
2743
- try {
2744
- await n.dispose();
2745
- } finally {
2746
- t.terminate();
2747
- }
2748
- })();
2773
+ this.#t();
2749
2774
  }
2750
2775
  }
2751
- function b(a) {
2752
- return new y(a);
2776
+ function v(a) {
2777
+ return new b(a);
2753
2778
  }
2779
+ const S = v;
2754
2780
  export {
2755
- E as AlreadyExistsError,
2756
- S as BINARY_FILE_EXTENSIONS,
2757
- P as DirectoryOperationError,
2758
- O as ExistenceError,
2759
- F as FileBusyError,
2760
- A as FileSystemOperationError,
2761
- T as FileTypeError,
2762
- R as IOError,
2763
- C as InitializationFailedError,
2764
- I as OPFSError,
2765
- y as OPFSFileSystem,
2766
- D as OPFSNotSupportedError,
2767
- $ as OperationAbortedError,
2768
- _ as OperationNotSupportedError,
2769
- N as PathError,
2770
- k as PermissionError,
2771
- z as StorageError,
2772
- M as ValidationError,
2773
- j as WatchEventType,
2774
- L as basename,
2775
- W as buffersEqual,
2776
- U as calculateFileHash,
2777
- H as calculateReadLength,
2778
- B as checkOPFSSupport,
2779
- G as convertBlobToUint8Array,
2780
- Y as createBuffer,
2781
- q as createFDError,
2782
- V as createSyncHandleSafe,
2783
- b as createWorker,
2781
+ F as AlreadyExistsError,
2782
+ A as BINARY_FILE_EXTENSIONS,
2783
+ T as DirectoryOperationError,
2784
+ R as ExistenceError,
2785
+ C as FileBusyError,
2786
+ I as FileSystemOperationError,
2787
+ D as FileTypeError,
2788
+ $ as IOError,
2789
+ _ as InitializationFailedError,
2790
+ N as OPFSError,
2791
+ b as OPFSFacade,
2792
+ b as OPFSFileSystem,
2793
+ k as OPFSNotSupportedError,
2794
+ z as OperationAbortedError,
2795
+ M as OperationNotSupportedError,
2796
+ j as PathError,
2797
+ W as PermissionError,
2798
+ L as StorageError,
2799
+ U as ValidationError,
2800
+ H as WatchEventType,
2801
+ B as basename,
2802
+ G as buffersEqual,
2803
+ q as calculateFileHash,
2804
+ Y as calculateReadLength,
2805
+ V as checkOPFSSupport,
2806
+ Z as convertBlobToUint8Array,
2807
+ J as createBuffer,
2808
+ X as createFDError,
2809
+ v as createOPFS,
2810
+ g as createOPFSWorker,
2811
+ K as createSyncHandleSafe,
2812
+ S as createWorker,
2784
2813
  l as decodeBuffer,
2785
- Z as dirname,
2814
+ Q as dirname,
2786
2815
  c as encodeString,
2787
- J as extname,
2816
+ nn as extname,
2788
2817
  h as isBinaryFileExtension,
2789
- X as isPathExcluded,
2790
- K as joinPath,
2791
- Q as mapDomError,
2792
- nn as matchMinimatch,
2793
- tn as normalizeMinimatch,
2794
- en as normalizePath,
2795
- rn as removeEntry,
2796
- sn as resolvePath,
2797
- an as safeCloseSyncHandle,
2798
- on as splitPath,
2799
- cn as validateReadWriteArgs,
2800
- hn as withLock
2818
+ tn as isPathExcluded,
2819
+ en as joinPath,
2820
+ rn as mapDomError,
2821
+ sn as matchMinimatch,
2822
+ an as normalizeMinimatch,
2823
+ on as normalizePath,
2824
+ cn as removeEntry,
2825
+ hn as resolvePath,
2826
+ ln as safeCloseSyncHandle,
2827
+ pn as splitPath,
2828
+ fn as validateReadWriteArgs,
2829
+ dn as withLock
2801
2830
  };
2802
2831
  //# sourceMappingURL=index.js.map