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.cjs CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-Dwc92hv9.cjs"),l=`/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./helpers-DNj8ZoMu.cjs"),m=require("comlink"),p=`/**
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"), X = Symbol("Comlink.finalizer"), _ = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
6
+ 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 = {
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) && _ in s,
16
+ canHandle: (s) => Ot(s) && j in s,
17
17
  serialize({ value: s }) {
18
18
  let t;
19
19
  return s instanceof Error ? t = {
@@ -46,30 +46,30 @@ function ot(s, t = globalThis, e = ["*"]) {
46
46
  console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
47
47
  return;
48
48
  }
49
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
49
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(C);
50
50
  let h;
51
51
  try {
52
- const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
52
+ const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
53
53
  switch (o) {
54
54
  case "GET":
55
55
  h = f;
56
56
  break;
57
57
  case "SET":
58
- c[a.slice(-1)[0]] = C(r.data.value), h = !0;
58
+ l[a.slice(-1)[0]] = C(r.data.value), h = !0;
59
59
  break;
60
60
  case "APPLY":
61
- h = f.apply(c, l);
61
+ h = f.apply(l, c);
62
62
  break;
63
63
  case "CONSTRUCT":
64
64
  {
65
- const u = new f(...l);
65
+ const u = new f(...c);
66
66
  h = Zt(u);
67
67
  }
68
68
  break;
69
69
  case "ENDPOINT":
70
70
  {
71
71
  const { port1: u, port2: d } = new MessageChannel();
72
- ot(s, d), h = U(u, [u]);
72
+ ot(s, d), h = _(u, [u]);
73
73
  }
74
74
  break;
75
75
  case "RELEASE":
@@ -78,16 +78,16 @@ function ot(s, t = globalThis, e = ["*"]) {
78
78
  default:
79
79
  return;
80
80
  }
81
- } catch (c) {
82
- h = { value: c, [_]: 0 };
81
+ } catch (l) {
82
+ h = { value: l, [j]: 0 };
83
83
  }
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
- }).catch((c) => {
84
+ Promise.resolve(h).catch((l) => ({ value: l, [j]: 0 })).then((l) => {
85
+ const [f, u] = V(l);
86
+ 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]());
87
+ }).catch((l) => {
88
88
  const [f, u] = V({
89
89
  value: new TypeError("Unserializable return value"),
90
- [_]: 0
90
+ [j]: 0
91
91
  });
92
92
  t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
93
93
  });
@@ -96,7 +96,7 @@ function ot(s, t = globalThis, e = ["*"]) {
96
96
  function Bt(s) {
97
97
  return s.constructor.name === "MessagePort";
98
98
  }
99
- function vt(s) {
99
+ function At(s) {
100
100
  Bt(s) && s.close();
101
101
  }
102
102
  function Gt(s, t) {
@@ -114,20 +114,20 @@ function Gt(s, t) {
114
114
  }
115
115
  }), st(s, e, [], t);
116
116
  }
117
- function H(s) {
117
+ function L(s) {
118
118
  if (s)
119
119
  throw new Error("Proxy has been released and is not useable");
120
120
  }
121
- function At(s) {
122
- return F(s, /* @__PURE__ */ new Map(), {
121
+ function vt(s) {
122
+ return $(s, /* @__PURE__ */ new Map(), {
123
123
  type: "RELEASE"
124
124
  }).then(() => {
125
- vt(s);
125
+ At(s);
126
126
  });
127
127
  }
128
128
  const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
129
  const t = (G.get(s) || 0) - 1;
130
- G.set(s, t), t === 0 && At(s);
130
+ G.set(s, t), t === 0 && vt(s);
131
131
  });
132
132
  function qt(s, t) {
133
133
  const e = (G.get(t) || 0) + 1;
@@ -141,53 +141,53 @@ function st(s, t, e = [], n = function() {
141
141
  let r = !1;
142
142
  const i = new Proxy(n, {
143
143
  get(o, a) {
144
- if (H(r), a === Wt)
144
+ if (L(r), a === Wt)
145
145
  return () => {
146
- Vt(i), At(s), t.clear(), r = !0;
146
+ Vt(i), vt(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 = F(s, t, {
151
+ const c = $(s, t, {
152
152
  type: "GET",
153
153
  path: e.map((h) => h.toString())
154
154
  }).then(C);
155
- return l.then.bind(l);
155
+ return c.then.bind(c);
156
156
  }
157
157
  return st(s, t, [...e, a]);
158
158
  },
159
- set(o, a, l) {
160
- H(r);
161
- const [h, c] = V(l);
162
- return F(s, t, {
159
+ set(o, a, c) {
160
+ L(r);
161
+ const [h, l] = V(c);
162
+ return $(s, t, {
163
163
  type: "SET",
164
164
  path: [...e, a].map((f) => f.toString()),
165
165
  value: h
166
- }, c).then(C);
166
+ }, l).then(C);
167
167
  },
168
- apply(o, a, l) {
169
- H(r);
168
+ apply(o, a, c) {
169
+ L(r);
170
170
  const h = e[e.length - 1];
171
- if (h === Ht)
172
- return F(s, t, {
171
+ if (h === zt)
172
+ return $(s, t, {
173
173
  type: "ENDPOINT"
174
174
  }).then(C);
175
175
  if (h === "bind")
176
176
  return st(s, t, e.slice(0, -1));
177
- const [c, f] = ht(l);
178
- return F(s, t, {
177
+ const [l, f] = ht(c);
178
+ return $(s, t, {
179
179
  type: "APPLY",
180
180
  path: e.map((u) => u.toString()),
181
- argumentList: c
181
+ argumentList: l
182
182
  }, f).then(C);
183
183
  },
184
184
  construct(o, a) {
185
- H(r);
186
- const [l, h] = ht(a);
187
- return F(s, t, {
185
+ L(r);
186
+ const [c, h] = ht(a);
187
+ return $(s, t, {
188
188
  type: "CONSTRUCT",
189
- path: e.map((c) => c.toString()),
190
- argumentList: l
189
+ path: e.map((l) => l.toString()),
190
+ argumentList: c
191
191
  }, h).then(C);
192
192
  }
193
193
  });
@@ -201,7 +201,7 @@ function ht(s) {
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 U(s, t) {
204
+ function _(s, t) {
205
205
  return Nt.set(s, t), s;
206
206
  }
207
207
  function Zt(s) {
@@ -236,7 +236,7 @@ function C(s) {
236
236
  return s.value;
237
237
  }
238
238
  }
239
- function F(s, t, e, n) {
239
+ function $(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);
@@ -245,7 +245,7 @@ function F(s, t, e, n) {
245
245
  function Xt() {
246
246
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
247
  }
248
- var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
248
+ var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
249
249
  const Jt = {
250
250
  ENOENT: -2,
251
251
  // No such file or directory
@@ -296,7 +296,7 @@ class Kt extends w {
296
296
  super(t, "INVALID_PATH", e, "access", n);
297
297
  }
298
298
  }
299
- class R extends w {
299
+ class U extends w {
300
300
  constructor(t, e, n) {
301
301
  const r = {
302
302
  file: \`File not found: \${e}\`,
@@ -378,11 +378,11 @@ class Q extends w {
378
378
  super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
379
379
  }
380
380
  }
381
- function W(s, t, e, n) {
381
+ function z(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 v(s, t) {
385
+ function O(s, t) {
386
386
  const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
387
387
  switch (s.name) {
388
388
  case "InvalidStateError":
@@ -390,7 +390,7 @@ function v(s, t) {
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 R(r, e, s);
393
+ return new U(r, e, s);
394
394
  case "TypeMismatchError":
395
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":
@@ -408,7 +408,7 @@ function v(s, t) {
408
408
  return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
409
409
  }
410
410
  }
411
- const Ft = (s, t, e) => {
411
+ const $t = (s, t, e) => {
412
412
  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);
413
413
  return i && {
414
414
  start: i[0],
@@ -421,37 +421,37 @@ const Ft = (s, t, e) => {
421
421
  const e = t.match(s);
422
422
  return e ? e[0] : null;
423
423
  }, ie = (s, t, e) => {
424
- let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
425
- if (l >= 0 && h > 0) {
424
+ let n, r, i, o, a, c = e.indexOf(s), h = e.indexOf(t, c + 1), l = c;
425
+ if (c >= 0 && h > 0) {
426
426
  if (s === t)
427
- return [l, h];
428
- for (n = [], i = e.length; c >= 0 && !a; ) {
429
- if (c === l)
430
- n.push(c), l = e.indexOf(s, c + 1);
427
+ return [c, h];
428
+ for (n = [], i = e.length; l >= 0 && !a; ) {
429
+ if (l === c)
430
+ n.push(l), c = e.indexOf(s, l + 1);
431
431
  else if (n.length === 1) {
432
432
  const f = n.pop();
433
433
  f !== void 0 && (a = [f, h]);
434
434
  } else
435
- r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
436
- c = l < h && l >= 0 ? l : h;
435
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
436
+ l = c < h && c >= 0 ? c : h;
437
437
  }
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", 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;
441
+ }, 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;
442
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, Tt).replace(ge, Pt);
446
+ return s.replace(ue, Ft).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
447
447
  }
448
- function me(s) {
448
+ function ye(s) {
449
449
  return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
450
450
  }
451
451
  function Rt(s) {
452
452
  if (!s)
453
453
  return [""];
454
- const t = [], e = Ft("{", "}", s);
454
+ const t = [], e = $t("{", "}", s);
455
455
  if (!e)
456
456
  return s.split(",");
457
457
  const { pre: n, body: r, post: i } = e, o = n.split(",");
@@ -459,8 +459,8 @@ function Rt(s) {
459
459
  const a = Rt(i);
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
- function ye(s) {
463
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), k(we(s), !0).map(me)) : [];
462
+ function me(s) {
463
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), R(we(s), !0).map(ye)) : [];
464
464
  }
465
465
  function Ee(s) {
466
466
  return "{" + s + "}";
@@ -474,54 +474,54 @@ function xe(s, t) {
474
474
  function be(s, t) {
475
475
  return s >= t;
476
476
  }
477
- function k(s, t) {
478
- const e = [], n = Ft("{", "}", s);
477
+ function R(s, t) {
478
+ const e = [], n = $t("{", "}", s);
479
479
  if (!n)
480
480
  return [s];
481
- const r = n.pre, i = n.post.length ? k(n.post, !1) : [""];
481
+ const r = n.pre, i = n.post.length ? R(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];
485
485
  e.push(a);
486
486
  }
487
487
  else {
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
- if (!l && !h)
490
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, k(s)) : [s];
491
- let c;
492
- if (l)
493
- c = n.body.split(/\\.\\./);
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
- return i.map((u) => n.pre + c[0] + u);
488
+ 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;
489
+ if (!c && !h)
490
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, R(s)) : [s];
491
+ let l;
492
+ if (c)
493
+ l = n.body.split(/\\.\\./);
494
+ else if (l = Rt(n.body), l.length === 1 && l[0] !== void 0 && (l = R(l[0], !1).map(Ee), l.length === 1))
495
+ return i.map((u) => n.pre + l[0] + u);
496
496
  let f;
497
- if (l && c[0] !== void 0 && c[1] !== void 0) {
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;
497
+ if (c && l[0] !== void 0 && l[1] !== void 0) {
498
+ const u = K(l[0]), d = K(l[1]), g = Math.max(l[0].length, l[1].length);
499
+ let p = l.length === 3 && l[2] !== void 0 ? Math.abs(K(l[2])) : 1, S = xe;
500
500
  d < u && (p *= -1, S = be);
501
- const M = c.some(Se);
501
+ const M = l.some(Se);
502
502
  f = [];
503
503
  for (let x = u; S(x, d); x += p) {
504
- let m;
504
+ let y;
505
505
  if (a)
506
- m = String.fromCharCode(x), m === "\\\\" && (m = "");
507
- else if (m = String(x), M) {
508
- const T = g - m.length;
506
+ y = String.fromCharCode(x), y === "\\\\" && (y = "");
507
+ else if (y = String(x), M) {
508
+ const T = g - y.length;
509
509
  if (T > 0) {
510
- const z = new Array(T + 1).join("0");
511
- x < 0 ? m = "-" + z + m.slice(1) : m = z + m;
510
+ const H = new Array(T + 1).join("0");
511
+ x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
512
512
  }
513
513
  }
514
- f.push(m);
514
+ f.push(y);
515
515
  }
516
516
  } else {
517
517
  f = [];
518
- for (let u = 0; u < c.length; u++)
519
- f.push.apply(f, k(c[u], !1));
518
+ for (let u = 0; u < l.length; u++)
519
+ f.push.apply(f, R(l[u], !1));
520
520
  }
521
521
  for (let u = 0; u < f.length; u++)
522
522
  for (let d = 0; d < i.length; d++) {
523
523
  const g = r + f[u] + i[d];
524
- (!t || l || g) && e.push(g);
524
+ (!t || c || g) && e.push(g);
525
525
  }
526
526
  }
527
527
  return e;
@@ -546,36 +546,36 @@ const Oe = 1024 * 64, Y = (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
- }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
549
+ }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), ve = (s, t) => {
550
550
  const e = t;
551
551
  if (s.charAt(e) !== "[")
552
552
  throw new Error("not in a brace expression");
553
553
  const n = [], r = [];
554
- let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
554
+ let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
555
555
  t: for (; i < s.length; ) {
556
556
  const p = s.charAt(i);
557
557
  if ((p === "!" || p === "^") && i === e + 1) {
558
558
  h = !0, i++;
559
559
  continue;
560
560
  }
561
- if (p === "]" && o && !l) {
562
- c = i + 1;
561
+ if (p === "]" && o && !c) {
562
+ l = i + 1;
563
563
  break;
564
564
  }
565
- if (o = !0, p === "\\\\" && !l) {
566
- l = !0, i++;
565
+ if (o = !0, p === "\\\\" && !c) {
566
+ c = !0, i++;
567
567
  continue;
568
568
  }
569
- if (p === "[" && !l) {
570
- for (const [S, [A, M, x]] of Object.entries(De))
569
+ if (p === "[" && !c) {
570
+ for (const [S, [v, 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(A) : n.push(A), a = a || M;
574
+ i += S.length, x ? r.push(v) : n.push(v), a = a || M;
575
575
  continue t;
576
576
  }
577
577
  }
578
- if (l = !1, f) {
578
+ if (c = !1, f) {
579
579
  p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
580
580
  continue;
581
581
  }
@@ -589,17 +589,17 @@ const Oe = 1024 * 64, Y = (s) => {
589
589
  }
590
590
  n.push(P(p)), i++;
591
591
  }
592
- if (c < i)
592
+ if (l < i)
593
593
  return ["", !1, 0, !1];
594
594
  if (!n.length && !r.length)
595
595
  return ["$.", !1, s.length - e, !0];
596
596
  if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
597
597
  const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
598
- return [ve(p), !1, c - e, !1];
598
+ return [Ae(p), !1, l - e, !1];
599
599
  }
600
600
  const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
601
- return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
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 + "+?";
601
+ return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, l - 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Fe = /* @__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;
@@ -700,7 +700,7 @@ class E {
700
700
  return e;
701
701
  }
702
702
  static #h(t, e, n, r) {
703
- let i = !1, o = !1, a = -1, l = !1;
703
+ let i = !1, o = !1, a = -1, c = !1;
704
704
  if (e.type === null) {
705
705
  let d = n, g = "";
706
706
  for (; d < t.length; ) {
@@ -710,10 +710,10 @@ class E {
710
710
  continue;
711
711
  }
712
712
  if (o) {
713
- d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
713
+ d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
714
714
  continue;
715
715
  } else if (p === "[") {
716
- o = !0, a = d, l = !1, g += p;
716
+ o = !0, a = d, c = !1, g += p;
717
717
  continue;
718
718
  }
719
719
  if (!r.noext && pt(p) && t.charAt(d) === "(") {
@@ -726,7 +726,7 @@ class E {
726
726
  }
727
727
  return e.push(g), d;
728
728
  }
729
- let h = n + 1, c = new E(null, e);
729
+ let h = n + 1, l = new E(null, e);
730
730
  const f = [];
731
731
  let u = "";
732
732
  for (; h < t.length; ) {
@@ -736,24 +736,24 @@ class E {
736
736
  continue;
737
737
  }
738
738
  if (o) {
739
- h === a + 1 ? (d === "^" || d === "!") && (l = !0) : d === "]" && !(h === a + 2 && l) && (o = !1), u += d;
739
+ h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
740
740
  continue;
741
741
  } else if (d === "[") {
742
- o = !0, a = h, l = !1, u += d;
742
+ o = !0, a = h, c = !1, u += d;
743
743
  continue;
744
744
  }
745
745
  if (pt(d) && t.charAt(h) === "(") {
746
- c.push(u), u = "";
747
- const g = new E(d, c);
748
- c.push(g), h = E.#h(t, g, h, r);
746
+ l.push(u), u = "";
747
+ const g = new E(d, l);
748
+ l.push(g), h = E.#h(t, g, h, r);
749
749
  continue;
750
750
  }
751
751
  if (d === "|") {
752
- c.push(u), u = "", f.push(c), c = new E(null, e);
752
+ l.push(u), u = "", f.push(l), l = new E(null, e);
753
753
  continue;
754
754
  }
755
755
  if (d === ")")
756
- return u === "" && e.#t.length === 0 && (e.#u = !0), c.push(u), u = "", e.push(...f, c), h;
756
+ return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
757
757
  u += d;
758
758
  }
759
759
  return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
@@ -851,24 +851,24 @@ class E {
851
851
  toRegExpSource(t) {
852
852
  const e = t ?? !!this.#r.dot;
853
853
  if (this.#s === this && this.#d(), !this.type) {
854
- const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
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;
854
+ const c = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
855
+ const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, c) : d.toRegExpSource(t);
856
+ return this.#n = this.#n || S, this.#i = this.#i || v, g;
857
857
  }).join("");
858
- let c = "";
859
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
860
- const g = Fe, p = (
858
+ let l = "";
859
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Fe.has(this.#t[0]))) {
860
+ const g = $e, p = (
861
861
  // dots are allowed, and the pattern starts with [ or .
862
862
  e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
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 ? j : "";
866
+ l = p ? Ce : S ? W : "";
867
867
  }
868
868
  let f = "";
869
869
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
870
- c + h + f,
871
- I(h),
870
+ l + h + f,
871
+ k(h),
872
872
  this.#n = !!this.#n,
873
873
  this.#i
874
874
  ];
@@ -876,24 +876,24 @@ class E {
876
876
  const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
877
877
  let i = this.#f(e);
878
878
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
879
- const l = this.toString();
880
- return this.#t = [l], this.type = null, this.#n = void 0, [l, I(this.toString()), !1, !1];
879
+ const c = this.toString();
880
+ return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
881
881
  }
882
- let o = !n || t || e || !j ? "" : this.#f(!0);
882
+ let o = !n || t || e || !W ? "" : 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 ? j : "") + wt;
886
+ a = (this.isStart() && !e ? W : "") + wt;
887
887
  else {
888
- const l = this.type === "!" ? (
888
+ const c = this.type === "!" ? (
889
889
  // !() must match something,but !(x) can match ''
890
- "))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
890
+ "))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
891
891
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
892
- a = r + i + l;
892
+ a = r + i + c;
893
893
  }
894
894
  return [
895
895
  a,
896
- I(i),
896
+ k(i),
897
897
  this.#n = !!this.#n,
898
898
  this.#i
899
899
  ];
@@ -909,36 +909,36 @@ class E {
909
909
  static #p(t, e, n = !1) {
910
910
  let r = !1, i = "", o = !1;
911
911
  for (let a = 0; a < t.length; a++) {
912
- const l = t.charAt(a);
912
+ const c = t.charAt(a);
913
913
  if (r) {
914
- r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
914
+ r = !1, i += (Me.has(c) ? "\\\\" : "") + c;
915
915
  continue;
916
916
  }
917
- if (l === "\\\\") {
917
+ if (c === "\\\\") {
918
918
  a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
919
919
  continue;
920
920
  }
921
- if (l === "[") {
922
- const [h, c, f, u] = Ae(t, a);
921
+ if (c === "[") {
922
+ const [h, l, f, u] = ve(t, a);
923
923
  if (f) {
924
- i += h, o = o || c, a += f - 1, e = e || u;
924
+ i += h, o = o || l, a += f - 1, e = e || u;
925
925
  continue;
926
926
  }
927
927
  }
928
- if (l === "*") {
928
+ if (c === "*") {
929
929
  n && t === "*" ? i += wt : i += gt, e = !0;
930
930
  continue;
931
931
  }
932
- if (l === "?") {
932
+ if (c === "?") {
933
933
  i += ct, e = !0;
934
934
  continue;
935
935
  }
936
- i += Te(l);
936
+ i += Te(c);
937
937
  }
938
- return [i, I(t), !!e, o];
938
+ return [i, k(t), !!e, o];
939
939
  }
940
940
  }
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 = ""]) => {
941
+ 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 = ""]) => {
942
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 = ""]) => {
@@ -956,19 +956,19 @@ const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\
956
956
  }, It = ([s]) => {
957
957
  const t = s.length;
958
958
  return (e) => e.length === t && e !== "." && e !== "..";
959
- }, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
959
+ }, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
960
960
  win32: { sep: "\\\\" },
961
961
  posix: { sep: "/" }
962
- }, Qe = Lt === "win32" ? mt.win32.sep : mt.posix.sep;
963
- y.sep = Qe;
964
- const O = Symbol("globstar **");
965
- y.GLOBSTAR = O;
966
- const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
967
- y.filter = ns;
962
+ }, Qe = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
963
+ m.sep = Qe;
964
+ const D = Symbol("globstar **");
965
+ m.GLOBSTAR = D;
966
+ const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => m(e, s, t);
967
+ m.filter = ns;
968
968
  const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
969
969
  if (!s || typeof s != "object" || !Object.keys(s).length)
970
- return y;
971
- const t = y;
970
+ return m;
971
+ const t = m;
972
972
  return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
973
973
  Minimatch: class extends t.Minimatch {
974
974
  constructor(r, i = {}) {
@@ -996,20 +996,20 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
996
996
  braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
997
997
  match: (n, r, i = {}) => t.match(n, r, b(s, i)),
998
998
  sep: t.sep,
999
- GLOBSTAR: O
999
+ GLOBSTAR: D
1000
1000
  });
1001
1001
  };
1002
- y.defaults = rs;
1003
- const zt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1004
- y.braceExpand = zt;
1002
+ m.defaults = rs;
1003
+ const Lt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : me(s));
1004
+ m.braceExpand = Lt;
1005
1005
  const is = (s, t = {}) => new Z(s, t).makeRe();
1006
- y.makeRe = is;
1006
+ m.makeRe = is;
1007
1007
  const os = (s, t, e = {}) => {
1008
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
- y.match = os;
1012
- const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1011
+ m.match = os;
1012
+ const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1013
1013
  class Z {
1014
1014
  options;
1015
1015
  set;
@@ -1029,7 +1029,7 @@ class Z {
1029
1029
  windowsNoMagicRoot;
1030
1030
  regexp;
1031
1031
  constructor(t, e = {}) {
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();
1032
+ 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();
1033
1033
  }
1034
1034
  hasMagic() {
1035
1035
  if (this.options.magicalBraces && this.set.length > 1)
@@ -1057,13 +1057,13 @@ class Z {
1057
1057
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
1058
1058
  let r = this.globParts.map((i, o, a) => {
1059
1059
  if (this.isWindows && this.windowsNoMagicRoot) {
1060
- const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1061
- if (l)
1062
- return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
1060
+ const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1061
+ if (c)
1062
+ return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
1063
1063
  if (h)
1064
- return [i[0], ...i.slice(1).map((c) => this.parse(c))];
1064
+ return [i[0], ...i.slice(1).map((l) => this.parse(l))];
1065
1065
  }
1066
- return i.map((l) => this.parse(l));
1066
+ return i.map((c) => this.parse(c));
1067
1067
  });
1068
1068
  if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1069
1069
  for (let i = 0; i < this.set.length; i++) {
@@ -1154,12 +1154,12 @@ class Z {
1154
1154
  o++;
1155
1155
  o > r && n.splice(r + 1, o - r);
1156
1156
  let a = n[r + 1];
1157
- const l = n[r + 2], h = n[r + 3];
1158
- if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1157
+ const c = n[r + 2], h = n[r + 3];
1158
+ if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
1159
1159
  continue;
1160
1160
  e = !0, n.splice(r, 1);
1161
- const c = n.slice(0);
1162
- c[r] = "**", t.push(c), r--;
1161
+ const l = n.slice(0);
1162
+ l[r] = "**", t.push(l), r--;
1163
1163
  }
1164
1164
  if (!this.preserveMultipleSlashes) {
1165
1165
  for (let o = 1; o < n.length - 1; o++) {
@@ -1173,8 +1173,8 @@ class Z {
1173
1173
  const o = n[i - 1];
1174
1174
  if (o && o !== "." && o !== ".." && o !== "**") {
1175
1175
  e = !0;
1176
- const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
1177
- n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
1176
+ const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
1177
+ n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
1178
1178
  }
1179
1179
  }
1180
1180
  }
@@ -1237,33 +1237,33 @@ class Z {
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]), 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
- if (typeof x == "number" && typeof m == "number") {
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)));
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]), 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;
1241
+ if (typeof x == "number" && typeof y == "number") {
1242
+ const [T, H] = [t[x], e[y]];
1243
+ T.toLowerCase() === H.toLowerCase() && (e[y] = T, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
1244
1244
  }
1245
1245
  }
1246
1246
  const { optimizationLevel: i = 1 } = this.options;
1247
1247
  i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1248
- for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1248
+ for (var o = 0, a = 0, c = t.length, h = e.length; o < c && a < h; o++, a++) {
1249
1249
  this.debug("matchOne loop");
1250
- var c = e[a], f = t[o];
1251
- if (this.debug(e, c, f), c === !1)
1250
+ var l = e[a], f = t[o];
1251
+ if (this.debug(e, l, f), l === !1)
1252
1252
  return !1;
1253
- if (c === O) {
1254
- this.debug("GLOBSTAR", [e, c, f]);
1253
+ if (l === D) {
1254
+ this.debug("GLOBSTAR", [e, l, f]);
1255
1255
  var u = o, d = a + 1;
1256
1256
  if (d === h) {
1257
- for (this.debug("** at the end"); o < l; o++)
1257
+ for (this.debug("** at the end"); o < c; o++)
1258
1258
  if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1259
1259
  return !1;
1260
1260
  return !0;
1261
1261
  }
1262
- for (; u < l; ) {
1262
+ for (; u < c; ) {
1263
1263
  var g = t[u];
1264
1264
  if (this.debug(\`
1265
1265
  globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1266
- return this.debug("globstar found match!", u, l, g), !0;
1266
+ return this.debug("globstar found match!", u, c, g), !0;
1267
1267
  if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1268
1268
  this.debug("dot detected!", t, u, e, d);
1269
1269
  break;
@@ -1271,32 +1271,32 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1271
1271
  this.debug("globstar swallow a segment, and continue"), u++;
1272
1272
  }
1273
1273
  return !!(n && (this.debug(\`
1274
- >>> no match, partial?\`, t, u, e, d), u === l));
1274
+ >>> no match, partial?\`, t, u, e, d), u === c));
1275
1275
  }
1276
1276
  let p;
1277
- 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)
1277
+ 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)
1278
1278
  return !1;
1279
1279
  }
1280
- if (o === l && a === h)
1280
+ if (o === c && a === h)
1281
1281
  return !0;
1282
- if (o === l)
1282
+ if (o === c)
1283
1283
  return n;
1284
1284
  if (a === h)
1285
- return o === l - 1 && t[o] === "";
1285
+ return o === c - 1 && t[o] === "";
1286
1286
  throw new Error("wtf?");
1287
1287
  }
1288
1288
  braceExpand() {
1289
- return zt(this.pattern, this.options);
1289
+ return Lt(this.pattern, this.options);
1290
1290
  }
1291
1291
  parse(t) {
1292
1292
  Y(t);
1293
1293
  const e = this.options;
1294
1294
  if (t === "**")
1295
- return O;
1295
+ return D;
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 ? 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);
1299
+ (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);
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
  }
@@ -1307,17 +1307,17 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1307
1307
  if (!t.length)
1308
1308
  return this.regexp = !1, this.regexp;
1309
1309
  const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
1310
- let i = t.map((l) => {
1311
- const h = l.map((c) => {
1312
- if (c instanceof RegExp)
1313
- for (const f of c.flags.split(""))
1310
+ let i = t.map((c) => {
1311
+ const h = c.map((l) => {
1312
+ if (l instanceof RegExp)
1313
+ for (const f of l.flags.split(""))
1314
1314
  r.add(f);
1315
- return typeof c == "string" ? as(c) : c === O ? O : c._src;
1315
+ return typeof l == "string" ? as(l) : l === D ? D : l._src;
1316
1316
  });
1317
- return h.forEach((c, f) => {
1317
+ return h.forEach((l, f) => {
1318
1318
  const u = h[f + 1], d = h[f - 1];
1319
- 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));
1320
- }), h.filter((c) => c !== O).join("/");
1319
+ 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));
1320
+ }), h.filter((l) => l !== D).join("/");
1321
1321
  }).join("|");
1322
1322
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1323
1323
  i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
@@ -1349,40 +1349,40 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1349
1349
  for (let a = r.length - 2; !o && a >= 0; a--)
1350
1350
  o = r[a];
1351
1351
  for (let a = 0; a < i.length; a++) {
1352
- const l = i[a];
1352
+ const c = i[a];
1353
1353
  let h = r;
1354
- if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1354
+ if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
1355
1355
  return n.flipNegate ? !0 : !this.negate;
1356
1356
  }
1357
1357
  return n.flipNegate ? !1 : this.negate;
1358
1358
  }
1359
1359
  static defaults(t) {
1360
- return y.defaults(t).Minimatch;
1360
+ return m.defaults(t).Minimatch;
1361
1361
  }
1362
1362
  }
1363
- y.AST = E;
1364
- y.Minimatch = Z;
1365
- y.escape = Pe;
1366
- y.unescape = I;
1363
+ m.AST = E;
1364
+ m.Minimatch = Z;
1365
+ m.escape = Pe;
1366
+ m.unescape = k;
1367
1367
  function cs() {
1368
1368
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1369
1369
  throw new Qt();
1370
1370
  }
1371
- async function L(s, t, e) {
1372
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1371
+ async function I(s, t) {
1372
+ return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
1373
1373
  }
1374
- function $(s) {
1374
+ function F(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 = $(s);
1381
+ const t = F(s);
1382
1382
  return t[t.length - 1] || "";
1383
1383
  }
1384
1384
  function tt(s) {
1385
- const t = $(s);
1385
+ const t = F(s);
1386
1386
  return t.pop(), lt(t);
1387
1387
  }
1388
1388
  function B(s) {
@@ -1392,13 +1392,13 @@ function ls(s, t = !1) {
1392
1392
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1393
1393
  }
1394
1394
  function et(s, t) {
1395
- return y(s, t, {
1395
+ return m(s, t, {
1396
1396
  dot: !0,
1397
1397
  matchBase: !0
1398
1398
  });
1399
1399
  }
1400
1400
  function Et(s) {
1401
- const t = B(s), e = $(t), n = [];
1401
+ const t = B(s), e = F(t), n = [];
1402
1402
  for (const r of e)
1403
1403
  if (!(r === "." || r === ""))
1404
1404
  if (r === "..") {
@@ -1421,7 +1421,7 @@ async function us(s) {
1421
1421
  }
1422
1422
  async function fs(s, t, e = {}) {
1423
1423
  const n = it(t);
1424
- return L(t, "exclusive", async () => {
1424
+ return I(t, async () => {
1425
1425
  const r = e.recursive ?? !1, i = e.force ?? !1;
1426
1426
  try {
1427
1427
  await s.removeEntry(n, { recursive: r });
@@ -1429,7 +1429,7 @@ async function fs(s, t, e = {}) {
1429
1429
  if (o.name === "NotFoundError" && i)
1430
1430
  return;
1431
1431
  const a = o.name === "TypeMismatchError" && !r;
1432
- throw v(o, {
1432
+ throw O(o, {
1433
1433
  path: t,
1434
1434
  operation: "remove",
1435
1435
  isDirectory: a
@@ -1464,7 +1464,7 @@ async function ps(s, t) {
1464
1464
  try {
1465
1465
  return await s.createSyncAccessHandle();
1466
1466
  } catch (e) {
1467
- throw v(e, { path: t, isDirectory: !1 });
1467
+ throw O(e, { path: t, isDirectory: !1 });
1468
1468
  }
1469
1469
  }
1470
1470
  class gs {
@@ -1484,6 +1484,8 @@ class gs {
1484
1484
  hashAlgorithm: "etag",
1485
1485
  broadcastChannel: "opfs-worker"
1486
1486
  };
1487
+ /** Shared sync handles per path (OPFS allows only one handle per file) */
1488
+ openHandles = /* @__PURE__ */ new Map();
1487
1489
  /** Map of open file descriptors to their metadata */
1488
1490
  openFiles = /* @__PURE__ */ new Map();
1489
1491
  /** Next available file descriptor number */
@@ -1532,7 +1534,7 @@ class gs {
1532
1534
  }
1533
1535
  }
1534
1536
  /**
1535
- * Creates a new OPFSFileSystem instance
1537
+ * Creates a new OPFSWorker instance
1536
1538
  *
1537
1539
  * @param options - Optional configuration options
1538
1540
  * @param options.root - Root path for the file system (default: '/')
@@ -1555,7 +1557,7 @@ class gs {
1555
1557
  *
1556
1558
  * @example
1557
1559
  * \`\`\`typescript
1558
- * const fs = new OPFSFileSystem();
1560
+ * const fs = new OPFSWorker();
1559
1561
  *
1560
1562
  * // Use OPFS root (default)
1561
1563
  * await fs.mount();
@@ -1609,7 +1611,7 @@ class gs {
1609
1611
  * \`\`\`
1610
1612
  */
1611
1613
  async getDirectoryHandle(t, e = !1, n = this.root) {
1612
- const r = Array.isArray(t) ? t : $(t);
1614
+ const r = Array.isArray(t) ? t : F(t);
1613
1615
  let i = n;
1614
1616
  for (const o of r)
1615
1617
  i = await i.getDirectoryHandle(o, { create: e });
@@ -1635,7 +1637,7 @@ class gs {
1635
1637
  * \`\`\`
1636
1638
  */
1637
1639
  async getFileHandle(t, e = !1, n = this.root) {
1638
- const r = $(t);
1640
+ const r = F(t);
1639
1641
  if (r.length === 0)
1640
1642
  throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1641
1643
  const i = r.pop();
@@ -1704,17 +1706,17 @@ class gs {
1704
1706
  async readFile(t) {
1705
1707
  await this.mount();
1706
1708
  try {
1707
- return await L(t, "shared", async () => {
1709
+ return await I(t, async () => {
1708
1710
  const e = await this.open(t);
1709
1711
  try {
1710
1712
  const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1711
- return n > 0 && await this.read(e, r, 0, n, 0), U(r, [r.buffer]);
1713
+ return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
1712
1714
  } finally {
1713
1715
  await this.close(e);
1714
1716
  }
1715
1717
  });
1716
1718
  } catch (e) {
1717
- throw new R("file", t, e);
1719
+ throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
1718
1720
  }
1719
1721
  }
1720
1722
  /**
@@ -1742,14 +1744,14 @@ class gs {
1742
1744
  async writeFile(t, e) {
1743
1745
  await this.mount();
1744
1746
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1745
- await L(t, "exclusive", async () => {
1747
+ await I(t, async () => {
1746
1748
  const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
1747
1749
  try {
1748
1750
  await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
1749
1751
  } finally {
1750
1752
  await this.close(i);
1751
1753
  }
1752
- await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
1754
+ await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
1753
1755
  });
1754
1756
  }
1755
1757
  /**
@@ -1777,7 +1779,7 @@ class gs {
1777
1779
  async appendFile(t, e) {
1778
1780
  await this.mount();
1779
1781
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1780
- await L(t, "exclusive", async () => {
1782
+ await I(t, async () => {
1781
1783
  const r = await this.open(t, { create: !0 });
1782
1784
  try {
1783
1785
  const { size: i } = await this.fstat(r);
@@ -1785,7 +1787,7 @@ class gs {
1785
1787
  } finally {
1786
1788
  await this.close(r);
1787
1789
  }
1788
- await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
1790
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1789
1791
  });
1790
1792
  }
1791
1793
  /**
@@ -1811,20 +1813,20 @@ class gs {
1811
1813
  */
1812
1814
  async mkdir(t, e) {
1813
1815
  await this.mount();
1814
- const n = e?.recursive ?? !1, r = $(t);
1816
+ const n = e?.recursive ?? !1, r = F(t);
1815
1817
  let i = this.root;
1816
1818
  for (let o = 0; o < r.length; o++) {
1817
1819
  const a = r[o];
1818
1820
  try {
1819
1821
  i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1820
- } catch (l) {
1821
- throw l.name === "NotFoundError" ? v(l, {
1822
+ } catch (c) {
1823
+ throw c.name === "NotFoundError" ? O(c, {
1822
1824
  path: lt(r.slice(0, o + 1)),
1823
1825
  existenceType: "directory"
1824
- }) : l.name === "TypeMismatchError" ? v(l, { path: a, isDirectory: !1 }) : new J("create directory", a, l);
1826
+ }) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
1825
1827
  }
1826
1828
  }
1827
- await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
1829
+ await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1828
1830
  }
1829
1831
  /**
1830
1832
  * Get file or directory statistics
@@ -1874,15 +1876,15 @@ class gs {
1874
1876
  a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1875
1877
  else if (typeof r == "string")
1876
1878
  try {
1877
- const l = await hs(o, r, this.options.maxFileSize);
1878
- a.hash = l;
1879
- } catch (l) {
1880
- console.warn(\`Failed to calculate hash for \${t}:\`, l);
1879
+ const c = await hs(o, r, this.options.maxFileSize);
1880
+ a.hash = c;
1881
+ } catch (c) {
1882
+ console.warn(\`Failed to calculate hash for \${t}:\`, c);
1881
1883
  }
1882
1884
  return a;
1883
1885
  } catch (r) {
1884
1886
  if (r.name === "NotFoundError")
1885
- throw new R("file", t, r);
1887
+ throw new U("file", t, r);
1886
1888
  if (r.name !== "TypeMismatchError")
1887
1889
  throw new J("stat", t, r);
1888
1890
  }
@@ -1999,9 +2001,9 @@ class gs {
1999
2001
  const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
2000
2002
  await this.remove(r, { recursive: !0 });
2001
2003
  }
2002
- await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
2004
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
2003
2005
  } catch (e) {
2004
- throw e instanceof w ? e : v(e, { path: t, isDirectory: !0 });
2006
+ throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
2005
2007
  }
2006
2008
  }
2007
2009
  /**
@@ -2032,7 +2034,7 @@ class gs {
2032
2034
  if (await this.mount(), t === "/")
2033
2035
  throw new rt("EROOT", t);
2034
2036
  const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
2035
- await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
2037
+ await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
2036
2038
  }
2037
2039
  /**
2038
2040
  * Resolve a path to an absolute path
@@ -2057,10 +2059,10 @@ class gs {
2057
2059
  try {
2058
2060
  const e = Et(t);
2059
2061
  if (!await this.exists(e))
2060
- throw new R("file", e);
2062
+ throw new U("file", e);
2061
2063
  return e;
2062
2064
  } catch (e) {
2063
- throw e instanceof w ? e : v(e, { path: t });
2065
+ throw e instanceof w ? e : O(e, { path: t });
2064
2066
  }
2065
2067
  }
2066
2068
  /**
@@ -2091,9 +2093,9 @@ class gs {
2091
2093
  const r = n?.overwrite ?? !1, i = await this.stat(t);
2092
2094
  if (await this.exists(e) && !r)
2093
2095
  throw new Q(e);
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 });
2096
+ 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 });
2095
2097
  } catch (r) {
2096
- throw r instanceof w ? r : v(r, { path: t });
2098
+ throw r instanceof w ? r : O(r, { path: t });
2097
2099
  }
2098
2100
  }
2099
2101
  /**
@@ -2126,7 +2128,7 @@ class gs {
2126
2128
  try {
2127
2129
  const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2128
2130
  if (!await this.exists(t))
2129
- throw new R("source", t);
2131
+ throw new U("source", t);
2130
2132
  if (await this.exists(e) && !i)
2131
2133
  throw new Q(e);
2132
2134
  if ((await this.stat(t)).isFile) {
@@ -2137,13 +2139,13 @@ class gs {
2137
2139
  throw new nt("directory", t);
2138
2140
  await this.mkdir(e, { recursive: !0 });
2139
2141
  const h = await this.readDir(t);
2140
- for (const c of h) {
2141
- const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2142
+ for (const l of h) {
2143
+ const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
2142
2144
  await this.copy(f, u, { recursive: !0, overwrite: i });
2143
2145
  }
2144
2146
  }
2145
2147
  } catch (r) {
2146
- throw r instanceof w ? r : v(r, { path: t });
2148
+ throw r instanceof w ? r : O(r, { path: t });
2147
2149
  }
2148
2150
  }
2149
2151
  /**
@@ -2218,7 +2220,7 @@ class gs {
2218
2220
  await this.mount();
2219
2221
  const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
2220
2222
  try {
2221
- return n && r ? await L(o, "exclusive", async () => {
2223
+ return n && r ? await I(o, async () => {
2222
2224
  if (await this.exists(o))
2223
2225
  throw new Q(o);
2224
2226
  return this._openFile(o, n, i);
@@ -2226,33 +2228,40 @@ class gs {
2226
2228
  } catch (a) {
2227
2229
  if (a instanceof w)
2228
2230
  throw a;
2229
- const l = a && a.name === "TypeMismatchError";
2230
- throw v(a, {
2231
+ const c = a && a.name === "TypeMismatchError";
2232
+ throw O(a, {
2231
2233
  path: o,
2232
- isDirectory: !!l
2234
+ isDirectory: !!c
2233
2235
  });
2234
2236
  }
2235
2237
  }
2236
2238
  /**
2237
2239
  * Internal method to open a file (without locking)
2240
+ *
2241
+ * Multiple FDs for the same path share one sync access handle (OPFS limit),
2242
+ * with independent per-FD positions — similar to Node.js.
2238
2243
  * @private
2239
2244
  */
2240
2245
  async _openFile(t, e, n) {
2241
- const r = await this.getFileHandle(t, e);
2242
- try {
2243
- await r.getFile();
2244
- } catch (a) {
2245
- throw v(a, { path: t, isDirectory: !0 });
2246
+ let r = this.openHandles.get(t);
2247
+ if (!r) {
2248
+ const o = await this.getFileHandle(t, e);
2249
+ try {
2250
+ await o.getFile();
2251
+ } catch (c) {
2252
+ throw O(c, { path: t, isDirectory: !0 });
2253
+ }
2254
+ const a = await ps(o, t);
2255
+ r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
2246
2256
  }
2247
- const i = await ps(r, t);
2248
- n && (i.truncate(0), i.flush());
2249
- const o = this.nextFd++;
2250
- return this.openFiles.set(o, {
2257
+ r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
2258
+ const i = this.nextFd++;
2259
+ return this.openFiles.set(i, {
2251
2260
  path: t,
2252
- fileHandle: r,
2253
- syncHandle: i,
2261
+ fileHandle: r.fileHandle,
2262
+ syncHandle: r.syncHandle,
2254
2263
  position: 0
2255
- }), o;
2264
+ }), i;
2256
2265
  }
2257
2266
  /**
2258
2267
  * Close a file descriptor
@@ -2270,7 +2279,9 @@ class gs {
2270
2279
  */
2271
2280
  async close(t) {
2272
2281
  const e = this._getFileDescriptor(t);
2273
- xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2282
+ this.openFiles.delete(t);
2283
+ const n = this.openHandles.get(e.path);
2284
+ n && (n.refCount--, n.refCount <= 0 && (xt(t, n.syncHandle, e.path), this.openHandles.delete(e.path)));
2274
2285
  }
2275
2286
  /**
2276
2287
  * Read data from a file descriptor
@@ -2300,13 +2311,13 @@ class gs {
2300
2311
  const o = this._getFileDescriptor(t);
2301
2312
  St(e.length, n, r, i);
2302
2313
  try {
2303
- const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
2314
+ const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
2304
2315
  if (h)
2305
- return U({ bytesRead: 0, buffer: e }, [e.buffer]);
2306
- const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2307
- return i == null && (o.position = a + u), U({ bytesRead: u, buffer: e }, [e.buffer]);
2316
+ return _({ bytesRead: 0, buffer: e }, [e.buffer]);
2317
+ const f = e.subarray(n, n + l), u = o.syncHandle.read(f, { at: a });
2318
+ return i == null && (o.position = a + u), _({ bytesRead: u, buffer: e }, [e.buffer]);
2308
2319
  } catch (a) {
2309
- throw W("read", t, o.path, a);
2320
+ throw z("read", t, o.path, a);
2310
2321
  }
2311
2322
  }
2312
2323
  /**
@@ -2331,13 +2342,13 @@ class gs {
2331
2342
  * \`\`\`
2332
2343
  */
2333
2344
  async write(t, e, n = 0, r, i, o = !0) {
2334
- const a = this._getFileDescriptor(t), l = r ?? e.length - n;
2335
- St(e.length, n, l, i);
2345
+ const a = this._getFileDescriptor(t), c = r ?? e.length - n;
2346
+ St(e.length, n, c, i);
2336
2347
  try {
2337
- const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2338
- return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
2348
+ const h = i ?? a.position, l = e.subarray(n, n + c), f = a.syncHandle.write(l, { at: h });
2349
+ return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2339
2350
  } catch (h) {
2340
- throw W("write", t, a.path, h);
2351
+ throw z("write", t, a.path, h);
2341
2352
  }
2342
2353
  }
2343
2354
  /**
@@ -2383,9 +2394,9 @@ class gs {
2383
2394
  if (e < 0 || !Number.isInteger(e))
2384
2395
  throw new N("argument", "Invalid size");
2385
2396
  try {
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 });
2397
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2387
2398
  } catch (r) {
2388
- throw W("truncate", t, n.path, r);
2399
+ throw z("truncate", t, n.path, r);
2389
2400
  }
2390
2401
  }
2391
2402
  /**
@@ -2407,7 +2418,7 @@ class gs {
2407
2418
  try {
2408
2419
  e.syncHandle.flush();
2409
2420
  } catch (n) {
2410
- throw W("sync", t, e.path, n);
2421
+ throw z("sync", t, e.path, n);
2411
2422
  }
2412
2423
  }
2413
2424
  /**
@@ -2418,9 +2429,9 @@ class gs {
2418
2429
  */
2419
2430
  dispose() {
2420
2431
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2421
- for (const [t, e] of this.openFiles)
2422
- xt(t, e.syncHandle, e.path);
2423
- this.openFiles.clear(), this.nextFd = 1;
2432
+ for (const [t, e] of this.openHandles)
2433
+ xt(-1, e.syncHandle, t);
2434
+ this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1;
2424
2435
  }
2425
2436
  /**
2426
2437
  * Synchronize the file system with external data
@@ -2457,11 +2468,11 @@ class gs {
2457
2468
  n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2458
2469
  }
2459
2470
  } catch (e) {
2460
- throw e instanceof w ? e : v(e);
2471
+ throw e instanceof w ? e : O(e);
2461
2472
  }
2462
2473
  }
2463
2474
  }
2464
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
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;
2475
+ ot(new gs());
2476
+ //# sourceMappingURL=worker.entry-DUlEoroc.js.map
2477
+ `,l=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",p],{type:"text/javascript;charset=utf-8"});function y(o){let n;try{if(n=l&&(self.URL||self.webkitURL).createObjectURL(l),!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(p),{type:"module",name:o?.name})}}const w=y;function g(o,n){n&&(n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),o.setOptions(n))}function f(o){const n=new w,t=m.wrap(n);return g(t,o),{fs:t,worker:n,dispose(){(async()=>{try{await t.dispose()}finally{n.terminate()}})()}}}function a(o){return o instanceof URL?o.pathname:o}class h{#n;#t;promises=this;constructor(n){const t=f(n);this.#n=t.fs,this.#t=t.dispose}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:u}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(u.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(){this.#t()}}function d(o){return new h(o)}const b=d;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.OPFSFacade=h;exports.OPFSFileSystem=h;exports.createOPFS=d;exports.createOPFSWorker=f;exports.createWorker=b;
2467
2478
  //# sourceMappingURL=index.cjs.map