opfs-worker 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +21 -20
  2. package/dist/BaseOPFS-Bu7FZtCb.cjs +2 -0
  3. package/dist/BaseOPFS-Bu7FZtCb.cjs.map +1 -0
  4. package/dist/{BaseOPFS-BusBkyJX.js → BaseOPFS-C3NE4BKr.js} +790 -548
  5. package/dist/BaseOPFS-C3NE4BKr.js.map +1 -0
  6. package/dist/OPFSAsync-C0RsxCX5.cjs +2 -0
  7. package/dist/OPFSAsync-C0RsxCX5.cjs.map +1 -0
  8. package/dist/{OPFSAsync-CO44W23e.js → OPFSAsync-aeLUdIqd.js} +19 -19
  9. package/dist/OPFSAsync-aeLUdIqd.js.map +1 -0
  10. package/dist/{OPFSFacade-hrNXCn6w.cjs → OPFSFacade-BJv2yuWU.cjs} +2 -2
  11. package/dist/{OPFSFacade-hrNXCn6w.cjs.map → OPFSFacade-BJv2yuWU.cjs.map} +1 -1
  12. package/dist/{OPFSFacade-CEaSqTut.js → OPFSFacade-DiogtQoq.js} +2 -2
  13. package/dist/{OPFSFacade-CEaSqTut.js.map → OPFSFacade-DiogtQoq.js.map} +1 -1
  14. package/dist/OPFSSync-3qlSBYmz.cjs +2 -0
  15. package/dist/OPFSSync-3qlSBYmz.cjs.map +1 -0
  16. package/dist/{OPFSSync-D7obTsl3.js → OPFSSync-CvSOswhW.js} +57 -57
  17. package/dist/OPFSSync-CvSOswhW.js.map +1 -0
  18. package/dist/assets/dedicated.worker-Bqqr9UBA.js.map +1 -0
  19. package/dist/core/BaseOPFS.d.ts +23 -3
  20. package/dist/core/BaseOPFS.d.ts.map +1 -1
  21. package/dist/core/OPFSAsync.d.ts.map +1 -1
  22. package/dist/core/OPFSSync.d.ts.map +1 -1
  23. package/dist/createOPFSAsync-B611B63X.js +10 -0
  24. package/dist/{createOPFSAsync-DdhJYoC0.js.map → createOPFSAsync-B611B63X.js.map} +1 -1
  25. package/dist/createOPFSAsync-BATjJg8k.cjs +2 -0
  26. package/dist/{createOPFSAsync-DyWpvmL-.cjs.map → createOPFSAsync-BATjJg8k.cjs.map} +1 -1
  27. package/dist/{createOPFSDedicated-BwTc0NV5.js → createOPFSDedicated-DgudPTB8.js} +1086 -817
  28. package/dist/createOPFSDedicated-DgudPTB8.js.map +1 -0
  29. package/dist/{createOPFSDedicated-CEeRexom.cjs → createOPFSDedicated-EmIwluQo.cjs} +1037 -797
  30. package/dist/createOPFSDedicated-EmIwluQo.cjs.map +1 -0
  31. package/dist/{createOPFSShared-BSFWsoLe.js → createOPFSShared-BWYln8jJ.js} +2 -2
  32. package/dist/{createOPFSShared-BSFWsoLe.js.map → createOPFSShared-BWYln8jJ.js.map} +1 -1
  33. package/dist/{createOPFSShared-BoCft_BS.cjs → createOPFSShared-DPJpCd7z.cjs} +2 -2
  34. package/dist/{createOPFSShared-BoCft_BS.cjs.map → createOPFSShared-DPJpCd7z.cjs.map} +1 -1
  35. package/dist/dedicated.worker.js +1034 -794
  36. package/dist/dedicated.worker.js.map +1 -1
  37. package/dist/facade/createOPFSDedicated.d.ts +4 -2
  38. package/dist/facade/createOPFSDedicated.d.ts.map +1 -1
  39. package/dist/index.async.cjs +1 -1
  40. package/dist/index.async.js +33 -32
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.d.ts +1 -5
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +44 -43
  45. package/dist/index.pure.cjs +1 -1
  46. package/dist/index.pure.js +38 -37
  47. package/dist/index.sharedworker.cjs +1 -1
  48. package/dist/index.sharedworker.js +34 -33
  49. package/dist/index.sync.cjs +1 -1
  50. package/dist/index.sync.d.ts +2 -0
  51. package/dist/index.sync.d.ts.map +1 -1
  52. package/dist/index.sync.js +34 -32
  53. package/dist/shared.worker.js +1056 -820
  54. package/dist/shared.worker.js.map +1 -1
  55. package/dist/types.d.ts +5 -5
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/utils/helpers.d.ts +13 -3
  58. package/dist/utils/helpers.d.ts.map +1 -1
  59. package/dist/worker/createDedicatedWorker.d.ts +8 -3
  60. package/dist/worker/createDedicatedWorker.d.ts.map +1 -1
  61. package/docs/README.md +18 -0
  62. package/docs/api/README.md +221 -0
  63. package/docs/{file-descriptors.md → api/file-descriptors.md} +13 -13
  64. package/docs/guides/async.md +2 -2
  65. package/docs/guides/dedicated.md +6 -4
  66. package/docs/guides/hashing.md +1 -1
  67. package/docs/guides/pure.md +1 -1
  68. package/docs/guides/sharedworker.md +1 -1
  69. package/docs/guides/streaming.md +2 -2
  70. package/docs/migration.md +8 -9
  71. package/docs/types.md +4 -4
  72. package/package.json +10 -9
  73. package/src/core/BaseOPFS.ts +46 -4
  74. package/src/core/OPFSAsync.ts +4 -5
  75. package/src/core/OPFSSync.ts +6 -7
  76. package/src/facade/createOPFSDedicated.ts +4 -2
  77. package/src/index.sync.ts +2 -0
  78. package/src/index.ts +1 -5
  79. package/src/types.ts +5 -3
  80. package/src/utils/helpers.ts +32 -6
  81. package/src/worker/createDedicatedWorker.ts +85 -7
  82. package/src/worker/dedicated.worker.ts +12 -1
  83. package/dist/BaseOPFS-BusBkyJX.js.map +0 -1
  84. package/dist/BaseOPFS-CYwrD7-q.cjs +0 -4
  85. package/dist/BaseOPFS-CYwrD7-q.cjs.map +0 -1
  86. package/dist/OPFSAsync-B2dR-2VR.cjs +0 -2
  87. package/dist/OPFSAsync-B2dR-2VR.cjs.map +0 -1
  88. package/dist/OPFSAsync-CO44W23e.js.map +0 -1
  89. package/dist/OPFSSync-BPrNtvFS.cjs +0 -2
  90. package/dist/OPFSSync-BPrNtvFS.cjs.map +0 -1
  91. package/dist/OPFSSync-D7obTsl3.js.map +0 -1
  92. package/dist/assets/dedicated.worker-DW6UqFo0.js.map +0 -1
  93. package/dist/createOPFSAsync-DdhJYoC0.js +0 -10
  94. package/dist/createOPFSAsync-DyWpvmL-.cjs +0 -2
  95. package/dist/createOPFSDedicated-BwTc0NV5.js.map +0 -1
  96. package/dist/createOPFSDedicated-CEeRexom.cjs.map +0 -1
  97. package/docs/api/backend.md +0 -36
  98. package/docs/api/create.md +0 -82
  99. package/docs/api/facade.md +0 -53
  100. package/docs/choosing-a-mode.md +0 -41
@@ -1,107 +1,102 @@
1
- "use strict";const c=require("./OPFSFacade-hrNXCn6w.cjs"),h=require("comlink"),a=`/**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- const bt = Symbol("Comlink.proxy"), Wt = Symbol("Comlink.endpoint"), jt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", _t = {
7
- canHandle: (s) => Ot(s) && s[bt],
8
- serialize(s) {
1
+ "use strict";const b=require("./OPFSFacade-BJv2yuWU.cjs"),v=require("comlink"),g=require("./BaseOPFS-Bu7FZtCb.cjs"),y=`const Ot = /* @__PURE__ */ Symbol("Comlink.proxy"), Bt = /* @__PURE__ */ Symbol("Comlink.endpoint"), Gt = /* @__PURE__ */ Symbol("Comlink.releaseProxy"), X = /* @__PURE__ */ Symbol("Comlink.finalizer"), H = /* @__PURE__ */ Symbol("Comlink.thrown"), Dt = (n) => typeof n == "object" && n !== null || typeof n == "function", Ut = {
2
+ canHandle: (n) => Dt(n) && n[Ot],
3
+ serialize(n) {
9
4
  const { port1: t, port2: e } = new MessageChannel();
10
- return ot(s, t), [e, [e]];
5
+ return U(n, t), [e, [e]];
11
6
  },
12
- deserialize(s) {
13
- return s.start(), qt(s);
7
+ deserialize(n) {
8
+ return n.start(), Yt(n);
14
9
  }
15
- }, Bt = {
16
- canHandle: (s) => Ot(s) && j in s,
17
- serialize({ value: s }) {
10
+ }, qt = {
11
+ canHandle: (n) => Dt(n) && H in n,
12
+ serialize({ value: n }) {
18
13
  let t;
19
- return s instanceof Error ? t = {
14
+ return n instanceof Error ? t = {
20
15
  isError: !0,
21
16
  value: {
22
- message: s.message,
23
- name: s.name,
24
- stack: s.stack
17
+ message: n.message,
18
+ name: n.name,
19
+ stack: n.stack
25
20
  }
26
- } : t = { isError: !1, value: s }, [t, []];
21
+ } : t = { isError: !1, value: n }, [t, []];
27
22
  },
28
- deserialize(s) {
29
- throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
23
+ deserialize(n) {
24
+ throw n.isError ? Object.assign(new Error(n.value.message), n.value) : n.value;
30
25
  }
31
- }, Dt = /* @__PURE__ */ new Map([
32
- ["proxy", _t],
33
- ["throw", Bt]
26
+ }, Mt = /* @__PURE__ */ new Map([
27
+ ["proxy", Ut],
28
+ ["throw", qt]
34
29
  ]);
35
- function Ut(s, t) {
36
- for (const e of s)
30
+ function Vt(n, t) {
31
+ for (const e of n)
37
32
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
38
33
  return !0;
39
34
  return !1;
40
35
  }
41
- function ot(s, t = globalThis, e = ["*"]) {
42
- t.addEventListener("message", function n(r) {
36
+ function U(n, t = globalThis, e = ["*"]) {
37
+ t.addEventListener("message", function s(r) {
43
38
  if (!r || !r.data)
44
39
  return;
45
- if (!Ut(e, r.origin)) {
40
+ if (!Vt(e, r.origin)) {
46
41
  console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
47
42
  return;
48
43
  }
49
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(N);
50
- let h;
44
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(T);
45
+ let l;
51
46
  try {
52
- const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
47
+ const h = a.slice(0, -1).reduce((f, p) => f[p], n), u = a.reduce((f, p) => f[p], n);
53
48
  switch (o) {
54
49
  case "GET":
55
- h = f;
50
+ l = u;
56
51
  break;
57
52
  case "SET":
58
- l[a.slice(-1)[0]] = N(r.data.value), h = !0;
53
+ h[a.slice(-1)[0]] = T(r.data.value), l = !0;
59
54
  break;
60
55
  case "APPLY":
61
- h = f.apply(l, c);
56
+ l = u.apply(h, c);
62
57
  break;
63
58
  case "CONSTRUCT":
64
59
  {
65
- const u = new f(...c);
66
- h = Xt(u);
60
+ const f = new u(...c);
61
+ l = Kt(f);
67
62
  }
68
63
  break;
69
64
  case "ENDPOINT":
70
65
  {
71
- const { port1: u, port2: d } = new MessageChannel();
72
- ot(s, d), h = _(u, [u]);
66
+ const { port1: f, port2: p } = new MessageChannel();
67
+ U(n, p), l = z(f, [f]);
73
68
  }
74
69
  break;
75
70
  case "RELEASE":
76
- h = void 0;
71
+ l = void 0;
77
72
  break;
78
73
  default:
79
74
  return;
80
75
  }
81
- } catch (l) {
82
- h = { value: l, [j]: 0 };
76
+ } catch (h) {
77
+ l = { value: h, [H]: 0 };
83
78
  }
84
- Promise.resolve(h).catch((l) => ({ value: l, [j]: 0 })).then((l) => {
85
- const [f, u] = q(l);
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((l) => {
88
- const [f, u] = q({
79
+ Promise.resolve(l).catch((h) => ({ value: h, [H]: 0 })).then((h) => {
80
+ const [u, f] = B(h);
81
+ t.postMessage(Object.assign(Object.assign({}, u), { id: i }), f), o === "RELEASE" && (t.removeEventListener("message", s), $t(t), X in n && typeof n[X] == "function" && n[X]());
82
+ }).catch((h) => {
83
+ const [u, f] = B({
89
84
  value: new TypeError("Unserializable return value"),
90
- [j]: 0
85
+ [H]: 0
91
86
  });
92
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
87
+ t.postMessage(Object.assign(Object.assign({}, u), { id: i }), f);
93
88
  });
94
89
  }), t.start && t.start();
95
90
  }
96
- function Gt(s) {
97
- return s.constructor.name === "MessagePort";
91
+ function Xt(n) {
92
+ return n.constructor.name === "MessagePort";
98
93
  }
99
- function vt(s) {
100
- Gt(s) && s.close();
94
+ function $t(n) {
95
+ Xt(n) && n.close();
101
96
  }
102
- function qt(s, t) {
97
+ function Yt(n, t) {
103
98
  const e = /* @__PURE__ */ new Map();
104
- return s.addEventListener("message", function(r) {
99
+ return n.addEventListener("message", function(r) {
105
100
  const { data: i } = r;
106
101
  if (!i || !i.id)
107
102
  return;
@@ -112,110 +107,110 @@ function qt(s, t) {
112
107
  } finally {
113
108
  e.delete(i.id);
114
109
  }
115
- }), et(s, e, [], t);
110
+ }), K(n, e, [], t);
116
111
  }
117
- function L(s) {
118
- if (s)
112
+ function k(n) {
113
+ if (n)
119
114
  throw new Error("Proxy has been released and is not useable");
120
115
  }
121
- function At(s) {
122
- return F(s, /* @__PURE__ */ new Map(), {
116
+ function Tt(n) {
117
+ return N(n, /* @__PURE__ */ new Map(), {
123
118
  type: "RELEASE"
124
119
  }).then(() => {
125
- vt(s);
120
+ $t(n);
126
121
  });
127
122
  }
128
- const U = /* @__PURE__ */ new WeakMap(), G = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
- const t = (U.get(s) || 0) - 1;
130
- U.set(s, t), t === 0 && At(s);
123
+ const W = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((n) => {
124
+ const t = (W.get(n) || 0) - 1;
125
+ W.set(n, t), t === 0 && Tt(n);
131
126
  });
132
- function Vt(s, t) {
133
- const e = (U.get(t) || 0) + 1;
134
- U.set(t, e), G && G.register(s, t, s);
127
+ function Zt(n, t) {
128
+ const e = (W.get(t) || 0) + 1;
129
+ W.set(t, e), j && j.register(n, t, n);
135
130
  }
136
- function Yt(s) {
137
- G && G.unregister(s);
131
+ function Jt(n) {
132
+ j && j.unregister(n);
138
133
  }
139
- function et(s, t, e = [], n = function() {
134
+ function K(n, t, e = [], s = function() {
140
135
  }) {
141
136
  let r = !1;
142
- const i = new Proxy(n, {
137
+ const i = new Proxy(s, {
143
138
  get(o, a) {
144
- if (L(r), a === jt)
139
+ if (k(r), a === Gt)
145
140
  return () => {
146
- Yt(i), At(s), t.clear(), r = !0;
141
+ Jt(i), Tt(n), t.clear(), r = !0;
147
142
  };
148
143
  if (a === "then") {
149
144
  if (e.length === 0)
150
145
  return { then: () => i };
151
- const c = F(s, t, {
146
+ const c = N(n, t, {
152
147
  type: "GET",
153
- path: e.map((h) => h.toString())
154
- }).then(N);
148
+ path: e.map((l) => l.toString())
149
+ }).then(T);
155
150
  return c.then.bind(c);
156
151
  }
157
- return et(s, t, [...e, a]);
152
+ return K(n, t, [...e, a]);
158
153
  },
159
154
  set(o, a, c) {
160
- L(r);
161
- const [h, l] = q(c);
162
- return F(s, t, {
155
+ k(r);
156
+ const [l, h] = B(c);
157
+ return N(n, t, {
163
158
  type: "SET",
164
- path: [...e, a].map((f) => f.toString()),
165
- value: h
166
- }, l).then(N);
159
+ path: [...e, a].map((u) => u.toString()),
160
+ value: l
161
+ }, h).then(T);
167
162
  },
168
163
  apply(o, a, c) {
169
- L(r);
170
- const h = e[e.length - 1];
171
- if (h === Wt)
172
- return F(s, t, {
164
+ k(r);
165
+ const l = e[e.length - 1];
166
+ if (l === Bt)
167
+ return N(n, t, {
173
168
  type: "ENDPOINT"
174
- }).then(N);
175
- if (h === "bind")
176
- return et(s, t, e.slice(0, -1));
177
- const [l, f] = ht(c);
178
- return F(s, t, {
169
+ }).then(T);
170
+ if (l === "bind")
171
+ return K(n, t, e.slice(0, -1));
172
+ const [h, u] = ut(c);
173
+ return N(n, t, {
179
174
  type: "APPLY",
180
- path: e.map((u) => u.toString()),
181
- argumentList: l
182
- }, f).then(N);
175
+ path: e.map((f) => f.toString()),
176
+ argumentList: h
177
+ }, u).then(T);
183
178
  },
184
179
  construct(o, a) {
185
- L(r);
186
- const [c, h] = ht(a);
187
- return F(s, t, {
180
+ k(r);
181
+ const [c, l] = ut(a);
182
+ return N(n, t, {
188
183
  type: "CONSTRUCT",
189
- path: e.map((l) => l.toString()),
184
+ path: e.map((h) => h.toString()),
190
185
  argumentList: c
191
- }, h).then(N);
186
+ }, l).then(T);
192
187
  }
193
188
  });
194
- return Vt(i, s), i;
189
+ return Zt(i, n), i;
195
190
  }
196
- function Zt(s) {
197
- return Array.prototype.concat.apply([], s);
191
+ function Qt(n) {
192
+ return Array.prototype.concat.apply([], n);
198
193
  }
199
- function ht(s) {
200
- const t = s.map(q);
201
- return [t.map((e) => e[0]), Zt(t.map((e) => e[1]))];
194
+ function ut(n) {
195
+ const t = n.map(B);
196
+ return [t.map((e) => e[0]), Qt(t.map((e) => e[1]))];
202
197
  }
203
- const Ct = /* @__PURE__ */ new WeakMap();
204
- function _(s, t) {
205
- return Ct.set(s, t), s;
198
+ const Nt = /* @__PURE__ */ new WeakMap();
199
+ function z(n, t) {
200
+ return Nt.set(n, t), n;
206
201
  }
207
- function Xt(s) {
208
- return Object.assign(s, { [bt]: !0 });
202
+ function Kt(n) {
203
+ return Object.assign(n, { [Ot]: !0 });
209
204
  }
210
- function q(s) {
211
- for (const [t, e] of Dt)
212
- if (e.canHandle(s)) {
213
- const [n, r] = e.serialize(s);
205
+ function B(n) {
206
+ for (const [t, e] of Mt)
207
+ if (e.canHandle(n)) {
208
+ const [s, r] = e.serialize(n);
214
209
  return [
215
210
  {
216
211
  type: "HANDLER",
217
212
  name: t,
218
- value: n
213
+ value: s
219
214
  },
220
215
  r
221
216
  ];
@@ -223,30 +218,30 @@ function q(s) {
223
218
  return [
224
219
  {
225
220
  type: "RAW",
226
- value: s
221
+ value: n
227
222
  },
228
- Ct.get(s) || []
223
+ Nt.get(n) || []
229
224
  ];
230
225
  }
231
- function N(s) {
232
- switch (s.type) {
226
+ function T(n) {
227
+ switch (n.type) {
233
228
  case "HANDLER":
234
- return Dt.get(s.name).deserialize(s.value);
229
+ return Mt.get(n.name).deserialize(n.value);
235
230
  case "RAW":
236
- return s.value;
231
+ return n.value;
237
232
  }
238
233
  }
239
- function F(s, t, e, n) {
234
+ function N(n, t, e, s) {
240
235
  return new Promise((r) => {
241
- const i = Jt();
242
- t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
236
+ const i = te();
237
+ t.set(i, r), n.start && n.start(), n.postMessage(Object.assign({ id: i }, e), s);
243
238
  });
244
239
  }
245
- function Jt() {
240
+ function te() {
246
241
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
242
  }
248
- var O = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(O || {});
249
- const Qt = {
243
+ var O = /* @__PURE__ */ ((n) => (n.Added = "added", n.Changed = "changed", n.Removed = "removed", n))(O || {});
244
+ const ee = {
250
245
  ENOENT: -2,
251
246
  // No such file or directory
252
247
  EISDIR: -21,
@@ -278,258 +273,291 @@ const Qt = {
278
273
  EROOT: -1
279
274
  // Custom: Cannot remove root directory
280
275
  };
281
- class w extends Error {
276
+ class y extends Error {
282
277
  errno;
283
278
  syscall;
284
279
  path;
285
- constructor(t, e, n, r, i) {
286
- super(t, { cause: i }), this.name = e, this.errno = Qt[e] || -1, this.path = n, this.syscall = r;
280
+ constructor(t, e, s, r, i) {
281
+ super(t, { cause: i }), this.name = e, this.errno = ee[e] || -1, this.path = s, this.syscall = r;
287
282
  }
288
283
  }
289
- class Kt extends w {
284
+ class se extends y {
290
285
  constructor(t) {
291
286
  super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
292
287
  }
293
288
  }
294
- class te extends w {
295
- constructor(t, e, n) {
296
- super(t, "INVALID_PATH", e, "access", n);
289
+ class ne extends y {
290
+ constructor(t, e, s) {
291
+ super(t, "INVALID_PATH", e, "access", s);
297
292
  }
298
293
  }
299
- class B extends w {
300
- constructor(t, e, n) {
294
+ class _ extends y {
295
+ constructor(t, e, s) {
301
296
  const r = {
302
297
  file: \`File not found: \${e}\`,
303
298
  directory: \`Directory not found: \${e}\`,
304
299
  source: \`Source does not exist: \${e}\`
305
300
  };
306
- super(r[t], "ENOENT", e, "access", n);
301
+ super(r[t], "ENOENT", e, "access", s);
307
302
  }
308
303
  }
309
- class ee extends w {
310
- constructor(t, e, n) {
311
- super(\`Permission denied for \${e} on: \${t}\`, "EACCES", t, e, n);
304
+ class re extends y {
305
+ constructor(t, e, s) {
306
+ super(\`Permission denied for \${e} on: \${t}\`, "EACCES", t, e, s);
312
307
  }
313
308
  }
314
- class se extends w {
315
- constructor(t, e, n) {
316
- super(t, "ENOSPC", e, "write", n);
309
+ class ie extends y {
310
+ constructor(t, e, s) {
311
+ super(t, "ENOSPC", e, "write", s);
317
312
  }
318
313
  }
319
- class ne extends w {
314
+ class oe extends y {
320
315
  constructor(t, e) {
321
316
  super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
322
317
  }
323
318
  }
324
- class st extends w {
325
- constructor(t, e, n) {
319
+ class tt extends y {
320
+ constructor(t, e, s) {
326
321
  const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
327
- super(r, i, e, "access", n);
322
+ super(r, i, e, "access", s);
328
323
  }
329
324
  }
330
- class C extends w {
331
- constructor(t, e, n, r) {
325
+ class $ extends y {
326
+ constructor(t, e, s, r) {
332
327
  const i = {
333
328
  argument: "EINVAL",
334
329
  format: "INVALID_FORMAT",
335
330
  descriptor: "EBADF",
336
331
  overflow: "ERANGE"
337
332
  };
338
- super(e, i[t], n, "validate", r);
333
+ super(e, i[t], s, "validate", r);
339
334
  }
340
335
  }
341
- class re extends w {
336
+ class ae extends y {
342
337
  constructor(t, e) {
343
338
  super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
344
339
  }
345
340
  }
346
- class ut extends w {
347
- constructor(t, e, n) {
348
- super(t, "EIO", e, "io", n);
341
+ class ft extends y {
342
+ constructor(t, e, s) {
343
+ super(t, "EIO", e, "io", s);
349
344
  }
350
345
  }
351
- class Nt extends w {
346
+ class Ct extends y {
352
347
  constructor(t, e) {
353
348
  super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
354
349
  }
355
350
  }
356
- class nt extends w {
357
- constructor(t, e, n) {
351
+ class et extends y {
352
+ constructor(t, e, s) {
358
353
  const r = {
359
354
  RM_FAILED: \`Failed to remove entry: \${e}\`,
360
355
  ENOTEMPTY: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
361
356
  EROOT: "Cannot remove root directory"
362
357
  };
363
- super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", n);
358
+ super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", s);
364
359
  }
365
360
  }
366
- class ie extends w {
361
+ class ce extends y {
367
362
  constructor(t, e) {
368
363
  super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
369
364
  }
370
365
  }
371
- class J extends w {
372
- constructor(t, e, n) {
373
- super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
366
+ class Y extends y {
367
+ constructor(t, e, s) {
368
+ super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, s);
374
369
  }
375
370
  }
376
- class rt extends w {
371
+ class st extends y {
377
372
  constructor(t, e) {
378
373
  super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
379
374
  }
380
375
  }
381
- function z(s, t, e, n) {
382
- const r = \`\${s.toUpperCase()}_FAILED\`;
383
- return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
376
+ function I(n, t, e, s) {
377
+ const r = \`\${n.toUpperCase()}_FAILED\`;
378
+ return new y(\`Failed to \${n} file descriptor: \${t}\`, r, e, n, s);
384
379
  }
385
- function b(s, t) {
386
- const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
387
- switch (s.name) {
380
+ function A(n, t) {
381
+ const e = t?.path, s = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
382
+ switch (n.name) {
388
383
  case "InvalidStateError":
389
- return new ne(e || "unknown", s);
384
+ return new oe(e || "unknown", n);
390
385
  case "QuotaExceededError":
391
- return new se(\`No space left on device: \${e || "unknown"}\`, e, s);
386
+ return new ie(\`No space left on device: \${e || "unknown"}\`, e, n);
392
387
  case "NotFoundError":
393
- return new B(r, e, s);
388
+ return new _(r, e, n);
394
389
  case "TypeMismatchError":
395
- return n !== void 0 ? n ? new st("directory", e || "unknown", s) : new st("file", e || "unknown", s) : new C("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
390
+ return s !== void 0 ? s ? new tt("directory", e || "unknown", n) : new tt("file", e || "unknown", n) : new $("argument", \`Type mismatch: \${e || "unknown"}\`, e, n);
396
391
  case "NotAllowedError":
397
392
  case "SecurityError":
398
- return new ee(e, "unknown", s);
393
+ return new re(e, "unknown", n);
399
394
  case "InvalidModificationError":
400
- return i === "remove" ? new nt("ENOTEMPTY", e, s) : new C("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
395
+ return i === "remove" ? new et("ENOTEMPTY", e, n) : new $("argument", \`Invalid modification: \${e || "unknown"}\`, e, n);
401
396
  case "AbortError":
402
- return new re(e || "unknown", s);
397
+ return new ae(e || "unknown", n);
403
398
  case "OperationError":
404
- return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
399
+ return new ft(\`Operation failed: \${e || "unknown"}\`, e, n);
405
400
  case "TypeError":
406
- return new Nt(e || "unknown", s);
401
+ return new Ct(e || "unknown", n);
407
402
  default:
408
- return i === "remove" ? new nt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
403
+ return i === "remove" ? new et("RM_FAILED", e, n) : new ft(\`I/O error: \${e || "unknown"}\`, e, n);
409
404
  }
410
405
  }
411
- const Ft = (s, t, e) => {
412
- const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && oe(n, r, e);
406
+ const vt = (n, t, e) => {
407
+ const s = n instanceof RegExp ? pt(n, e) : n, r = t instanceof RegExp ? pt(t, e) : t, i = s !== null && r != null && le(s, r, e);
413
408
  return i && {
414
409
  start: i[0],
415
410
  end: i[1],
416
411
  pre: e.slice(0, i[0]),
417
- body: e.slice(i[0] + n.length, i[1]),
412
+ body: e.slice(i[0] + s.length, i[1]),
418
413
  post: e.slice(i[1] + r.length)
419
414
  };
420
- }, ft = (s, t) => {
421
- const e = t.match(s);
415
+ }, pt = (n, t) => {
416
+ const e = t.match(n);
422
417
  return e ? e[0] : null;
423
- }, oe = (s, t, e) => {
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
- if (s === t)
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
- else if (n.length === 1) {
432
- const f = n.pop();
433
- f !== void 0 && (a = [f, h]);
418
+ }, le = (n, t, e) => {
419
+ let s, r, i, o, a, c = e.indexOf(n), l = e.indexOf(t, c + 1), h = c;
420
+ if (c >= 0 && l > 0) {
421
+ if (n === t)
422
+ return [c, l];
423
+ for (s = [], i = e.length; h >= 0 && !a; ) {
424
+ if (h === c)
425
+ s.push(h), c = e.indexOf(n, h + 1);
426
+ else if (s.length === 1) {
427
+ const u = s.pop();
428
+ u !== void 0 && (a = [u, l]);
434
429
  } else
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;
430
+ r = s.pop(), r !== void 0 && r < i && (i = r, o = l), l = e.indexOf(t, h + 1);
431
+ h = c < l && c >= 0 ? c : l;
437
432
  }
438
- n.length && o !== void 0 && (a = [i, o]);
433
+ s.length && o !== void 0 && (a = [i, o]);
439
434
  }
440
435
  return a;
441
- }, Mt = "\\0SLASH" + Math.random() + "\\0", $t = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Tt = "\\0COMMA" + Math.random() + "\\0", Pt = "\\0PERIOD" + Math.random() + "\\0", ae = new RegExp(Mt, "g"), ce = new RegExp($t, "g"), le = new RegExp(at, "g"), he = new RegExp(Tt, "g"), ue = new RegExp(Pt, "g"), fe = /\\\\\\\\/g, de = /\\\\{/g, pe = /\\\\}/g, ge = /\\\\,/g, we = /\\\\./g;
442
- function Q(s) {
443
- return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
436
+ }, Ft = "\\0SLASH" + Math.random() + "\\0", Pt = "\\0OPEN" + Math.random() + "\\0", ot = "\\0CLOSE" + Math.random() + "\\0", Rt = "\\0COMMA" + Math.random() + "\\0", kt = "\\0PERIOD" + Math.random() + "\\0", he = new RegExp(Ft, "g"), ue = new RegExp(Pt, "g"), fe = new RegExp(ot, "g"), pe = new RegExp(Rt, "g"), de = new RegExp(kt, "g"), ge = /\\\\\\\\/g, ye = /\\\\{/g, we = /\\\\}/g, me = /\\\\,/g, Ee = /\\\\\\./g, Se = 1e5, be = 4e6;
437
+ function Z(n) {
438
+ return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
444
439
  }
445
- function ye(s) {
446
- return s.replace(fe, Mt).replace(de, $t).replace(pe, at).replace(ge, Tt).replace(we, Pt);
440
+ function xe(n) {
441
+ return n.replace(ge, Ft).replace(ye, Pt).replace(we, ot).replace(me, Rt).replace(Ee, kt);
447
442
  }
448
- function me(s) {
449
- return s.replace(ae, "\\\\").replace(ce, "{").replace(le, "}").replace(he, ",").replace(ue, ".");
443
+ function Ae(n) {
444
+ return n.replace(he, "\\\\").replace(ue, "{").replace(fe, "}").replace(pe, ",").replace(de, ".");
450
445
  }
451
- function Rt(s) {
452
- if (!s)
446
+ function It(n) {
447
+ if (!n)
453
448
  return [""];
454
- const t = [], e = Ft("{", "}", s);
449
+ const t = [], e = vt("{", "}", n);
455
450
  if (!e)
456
- return s.split(",");
457
- const { pre: n, body: r, post: i } = e, o = n.split(",");
451
+ return n.split(",");
452
+ const { pre: s, body: r, post: i } = e, o = s.split(",");
458
453
  o[o.length - 1] += "{" + r + "}";
459
- const a = Rt(i);
454
+ const a = It(i);
460
455
  return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
461
456
  }
462
- function Ee(s) {
463
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(ye(s), !0).map(me)) : [];
464
- }
465
- function Se(s) {
466
- return "{" + s + "}";
467
- }
468
- function xe(s) {
469
- return /^-?0\\d/.test(s);
470
- }
471
- function be(s, t) {
472
- return s <= t;
473
- }
474
- function Oe(s, t) {
475
- return s >= t;
476
- }
477
- function I(s, t) {
478
- const e = [], n = Ft("{", "}", s);
457
+ function Oe(n, t = {}) {
479
458
  if (!n)
480
- return [s];
481
- const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
482
- if (/\\$$/.test(n.pre))
483
- for (let o = 0; o < i.length; o++) {
484
- const a = r + "{" + n.body + "}" + i[o];
485
- e.push(a);
459
+ return [];
460
+ const { max: e = Se, maxLength: s = be } = t;
461
+ return n.slice(0, 2) === "{}" && (n = "\\\\{\\\\}" + n.slice(2)), nt(xe(n), e, s, !0).map(Ae);
462
+ }
463
+ function De(n) {
464
+ return "{" + n + "}";
465
+ }
466
+ function Me(n) {
467
+ return /^-?0\\d/.test(n);
468
+ }
469
+ function $e(n, t) {
470
+ return n <= t;
471
+ }
472
+ function Te(n, t) {
473
+ return n >= t;
474
+ }
475
+ function F(n, t, e, s, r, i) {
476
+ const o = [];
477
+ let a = 0;
478
+ for (let c = 0; c < n.length; c++)
479
+ for (let l = 0; l < e.length; l++) {
480
+ if (o.length >= s)
481
+ return o;
482
+ const h = n[c] + t + e[l];
483
+ if (!(i && !h)) {
484
+ if (a + h.length > r)
485
+ return o;
486
+ o.push(h), a += h.length;
487
+ }
486
488
  }
487
- else {
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, I(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 = I(l[0], !1).map(Se), l.length === 1))
495
- return i.map((u) => n.pre + l[0] + u);
496
- let f;
497
- if (c && l[0] !== void 0 && l[1] !== void 0) {
498
- const u = Q(l[0]), d = Q(l[1]), g = Math.max(l[0].length, l[1].length);
499
- let p = l.length === 3 && l[2] !== void 0 ? Math.abs(Q(l[2])) : 1, S = be;
500
- d < u && (p *= -1, S = Oe);
501
- const T = l.some(xe);
502
- f = [];
503
- for (let x = u; S(x, d); x += p) {
504
- let y;
505
- if (a)
506
- y = String.fromCharCode(x), y === "\\\\" && (y = "");
507
- else if (y = String(x), T) {
508
- const P = g - y.length;
509
- if (P > 0) {
510
- const H = new Array(P + 1).join("0");
511
- x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
512
- }
513
- }
514
- f.push(y);
489
+ return o;
490
+ }
491
+ function Ne(n, t, e) {
492
+ const s = n.split(/\\.\\./), r = [];
493
+ if (s[0] === void 0 || s[1] === void 0)
494
+ return r;
495
+ const i = Z(s[0]), o = Z(s[1]), a = Math.max(s[0].length, s[1].length);
496
+ let c = s.length === 3 && s[2] !== void 0 ? Math.max(Math.abs(Z(s[2])), 1) : 1, l = $e;
497
+ o < i && (c *= -1, l = Te);
498
+ const u = s.some(Me);
499
+ for (let f = i; l(f, o) && r.length < e; f += c) {
500
+ let p;
501
+ if (t)
502
+ p = String.fromCharCode(f), p === "\\\\" && (p = "");
503
+ else if (p = String(f), u) {
504
+ const g = a - p.length;
505
+ if (g > 0) {
506
+ const d = new Array(g + 1).join("0");
507
+ f < 0 ? p = "-" + d + p.slice(1) : p = d + p;
515
508
  }
516
- } else {
517
- f = [];
518
- for (let u = 0; u < l.length; u++)
519
- f.push.apply(f, I(l[u], !1));
520
509
  }
521
- for (let u = 0; u < f.length; u++)
522
- for (let d = 0; d < i.length; d++) {
523
- const g = r + f[u] + i[d];
524
- (!t || c || g) && e.push(g);
510
+ r.push(p);
511
+ }
512
+ return r;
513
+ }
514
+ function nt(n, t, e, s) {
515
+ let r = [""], i = !1, o = !0;
516
+ for (; ; ) {
517
+ const a = vt("{", "}", n);
518
+ if (!a)
519
+ return F(r, n, [""], t, e, i);
520
+ const c = a.pre;
521
+ if (/\\$$/.test(c)) {
522
+ if (r = F(r, c + "{" + a.body + "}", [""], t, e, i && !a.post.length), o = !1, !a.post.length)
523
+ break;
524
+ n = a.post;
525
+ continue;
526
+ }
527
+ const l = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(a.body), h = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(a.body), u = l || h, f = a.body.indexOf(",") >= 0;
528
+ if (!u && !f) {
529
+ if (a.post.match(/,(?!,).*\\}/)) {
530
+ n = a.pre + "{" + a.body + ot + a.post, s = !0;
531
+ continue;
525
532
  }
533
+ return F(r, c + "{" + a.body + "}" + a.post, [""], t, e, i);
534
+ }
535
+ o && (i = s && !u, o = !1);
536
+ let p;
537
+ if (u)
538
+ p = Ne(a.body, h, t);
539
+ else {
540
+ let g = It(a.body);
541
+ if (g.length === 1 && g[0] !== void 0 && (g = nt(g[0], t, e, !1).map(De), g.length === 1)) {
542
+ if (r = F(r, c + g[0], [""], t, e, i && !a.post.length), !a.post.length)
543
+ break;
544
+ n = a.post;
545
+ continue;
546
+ }
547
+ p = [];
548
+ for (let d = 0; d < g.length; d++)
549
+ p.push.apply(p, nt(g[d], t, e, !1));
550
+ }
551
+ if (r = F(r, c, p, t, e, i && !a.post.length), !a.post.length)
552
+ break;
553
+ n = a.post;
526
554
  }
527
- return e;
555
+ return r;
528
556
  }
529
- const De = 1024 * 64, V = (s) => {
530
- if (typeof s != "string")
557
+ const Ce = 1024 * 64, G = (n) => {
558
+ if (typeof n != "string")
531
559
  throw new TypeError("invalid pattern");
532
- if (s.length > De)
560
+ if (n.length > Ce)
533
561
  throw new TypeError("pattern is too long");
534
562
  }, ve = {
535
563
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
@@ -546,77 +574,138 @@ const De = 1024 * 64, V = (s) => {
546
574
  "[:upper:]": ["\\\\p{Lu}", !0],
547
575
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
548
576
  "[:xdigit:]": ["A-Fa-f0-9", !1]
549
- }, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ce = (s, t) => {
577
+ }, P = (n) => n.replace(/[[\\]\\\\-]/g, "\\\\$&"), Fe = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (n) => n.join(""), Pe = (n, t) => {
550
578
  const e = t;
551
- if (s.charAt(e) !== "[")
579
+ if (n.charAt(e) !== "[")
552
580
  throw new Error("not in a brace expression");
553
- const n = [], r = [];
554
- let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
555
- t: for (; i < s.length; ) {
556
- const p = s.charAt(i);
557
- if ((p === "!" || p === "^") && i === e + 1) {
558
- h = !0, i++;
581
+ const s = [], r = [];
582
+ let i = e + 1, o = !1, a = !1, c = !1, l = !1, h = e, u = "";
583
+ t: for (; i < n.length; ) {
584
+ const d = n.charAt(i);
585
+ if ((d === "!" || d === "^") && i === e + 1) {
586
+ l = !0, i++;
559
587
  continue;
560
588
  }
561
- if (p === "]" && o && !c) {
562
- l = i + 1;
589
+ if (d === "]" && o && !c) {
590
+ h = i + 1;
563
591
  break;
564
592
  }
565
- if (o = !0, p === "\\\\" && !c) {
593
+ if (o = !0, d === "\\\\" && !c) {
566
594
  c = !0, i++;
567
595
  continue;
568
596
  }
569
- if (p === "[" && !c) {
570
- for (const [S, [A, T, x]] of Object.entries(ve))
571
- if (s.startsWith(S, i)) {
572
- if (f)
573
- return ["$.", !1, s.length - e, !0];
574
- i += S.length, x ? r.push(A) : n.push(A), a = a || T;
597
+ if (d === "[" && !c) {
598
+ for (const [E, [w, m, M]] of Object.entries(ve))
599
+ if (n.startsWith(E, i)) {
600
+ if (u)
601
+ return ["$.", !1, n.length - e, !0];
602
+ i += E.length, M ? r.push(w) : s.push(w), a = a || m;
575
603
  continue t;
576
604
  }
577
605
  }
578
- if (c = !1, f) {
579
- p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
606
+ if (c = !1, u) {
607
+ d > u ? s.push(P(u) + "-" + P(d)) : d === u && s.push(P(d)), u = "", i++;
580
608
  continue;
581
609
  }
582
- if (s.startsWith("-]", i + 1)) {
583
- n.push(R(p + "-")), i += 2;
610
+ if (n.startsWith("-]", i + 1)) {
611
+ s.push(P(d + "-")), i += 2;
584
612
  continue;
585
613
  }
586
- if (s.startsWith("-", i + 1)) {
587
- f = p, i += 2;
614
+ if (n.startsWith("-", i + 1)) {
615
+ u = d, i += 2;
588
616
  continue;
589
617
  }
590
- n.push(R(p)), i++;
618
+ s.push(P(d)), i++;
591
619
  }
592
- if (l < i)
620
+ if (h < i)
593
621
  return ["", !1, 0, !1];
594
- if (!n.length && !r.length)
595
- return ["$.", !1, s.length - e, !0];
596
- if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
597
- const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
598
- return [Ae(p), !1, l - e, !1];
599
- }
600
- const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
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), Fe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", Me = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Te = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
603
- class E {
622
+ if (!s.length && !r.length)
623
+ return ["$.", !1, n.length - e, !0];
624
+ if (r.length === 0 && s.length === 1 && /^\\\\?.$/.test(s[0]) && !l) {
625
+ const d = s[0].length === 2 ? s[0].slice(-1) : s[0];
626
+ return [Fe(d), !1, h - e, !1];
627
+ }
628
+ const f = "[" + (l ? "^" : "") + dt(s) + "]", p = "[" + (l ? "" : "^") + dt(r) + "]";
629
+ return [s.length && r.length ? "(" + f + "|" + p + ")" : s.length ? f : p, a, h - e, !0];
630
+ }, R = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? n.replace(/\\[([^/\\\\])\\]/g, "$1") : n.replace(/((?!\\\\).|^)\\[([^/\\\\])\\]/g, "$1$2").replace(/\\\\([^/])/g, "$1") : t ? n.replace(/\\[([^/\\\\{}])\\]/g, "$1") : n.replace(/((?!\\\\).|^)\\[([^/\\\\{}])\\]/g, "$1$2").replace(/\\\\([^/{}])/g, "$1");
631
+ var x;
632
+ const Re = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), rt = (n) => Re.has(n), gt = (n) => rt(n.type), ke = /* @__PURE__ */ new Map([
633
+ ["!", ["@"]],
634
+ ["?", ["?", "@"]],
635
+ ["@", ["@"]],
636
+ ["*", ["*", "+", "?", "@"]],
637
+ ["+", ["+", "@"]]
638
+ ]), Ie = /* @__PURE__ */ new Map([
639
+ ["!", ["?"]],
640
+ ["@", ["?"]],
641
+ ["+", ["?", "*"]]
642
+ ]), Le = /* @__PURE__ */ new Map([
643
+ ["!", ["?", "@"]],
644
+ ["?", ["?", "@"]],
645
+ ["@", ["?", "@"]],
646
+ ["*", ["*", "+", "?", "@"]],
647
+ ["+", ["+", "@", "?", "*"]]
648
+ ]), yt = /* @__PURE__ */ new Map([
649
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
650
+ [
651
+ "?",
652
+ /* @__PURE__ */ new Map([
653
+ ["*", "*"],
654
+ ["+", "*"]
655
+ ])
656
+ ],
657
+ [
658
+ "@",
659
+ /* @__PURE__ */ new Map([
660
+ ["!", "!"],
661
+ ["?", "?"],
662
+ ["@", "@"],
663
+ ["*", "*"],
664
+ ["+", "+"]
665
+ ])
666
+ ],
667
+ [
668
+ "+",
669
+ /* @__PURE__ */ new Map([
670
+ ["?", "*"],
671
+ ["*", "*"]
672
+ ])
673
+ ]
674
+ ]), He = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ze = /* @__PURE__ */ new Set(["[", "."]), _e = /* @__PURE__ */ new Set(["..", "."]), We = new Set("().*{}+?[]^$\\\\!"), je = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), at = "[^/]", wt = at + "*?", mt = at + "+?";
675
+ let Be = 0;
676
+ class ct {
604
677
  type;
605
678
  #s;
606
679
  #n;
607
- #i = !1;
680
+ #r = !1;
608
681
  #t = [];
609
682
  #e;
610
- #o;
611
- #c;
612
- #a = !1;
613
- #r;
683
+ #a;
614
684
  #l;
685
+ #c = !1;
686
+ #i;
687
+ #o;
615
688
  // set to true if it's an extglob with no children
616
689
  // (which really means one child of '')
617
- #u = !1;
618
- constructor(t, e, n = {}) {
619
- this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
690
+ #h = !1;
691
+ id = ++Be;
692
+ get depth() {
693
+ return (this.#e?.depth ?? -1) + 1;
694
+ }
695
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
696
+ return {
697
+ "@@type": "AST",
698
+ id: this.id,
699
+ type: this.type,
700
+ root: this.#s.id,
701
+ parent: this.#e?.id,
702
+ depth: this.depth,
703
+ partsLength: this.#t.length,
704
+ parts: this.#t
705
+ };
706
+ }
707
+ constructor(t, e, s = {}) {
708
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? s : this.#s.#i, this.#l = this.#s === this ? [] : this.#s.#l, t === "!" && !this.#s.#c && this.#l.push(this), this.#a = this.#e ? this.#e.#t.length : 0;
620
709
  }
621
710
  get hasMagic() {
622
711
  if (this.#n !== void 0)
@@ -628,27 +717,27 @@ class E {
628
717
  }
629
718
  // reconstructs the pattern
630
719
  toString() {
631
- return this.#l !== void 0 ? this.#l : this.type ? this.#l = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#l = this.#t.map((t) => String(t)).join("");
720
+ return this.#o !== void 0 ? this.#o : this.type ? this.#o = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#o = this.#t.map((t) => String(t)).join("");
632
721
  }
633
- #d() {
722
+ #w() {
634
723
  if (this !== this.#s)
635
724
  throw new Error("should only call on root");
636
- if (this.#a)
725
+ if (this.#c)
637
726
  return this;
638
- this.toString(), this.#a = !0;
727
+ this.toString(), this.#c = !0;
639
728
  let t;
640
- for (; t = this.#c.pop(); ) {
729
+ for (; t = this.#l.pop(); ) {
641
730
  if (t.type !== "!")
642
731
  continue;
643
- let e = t, n = e.#e;
644
- for (; n; ) {
645
- for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
732
+ let e = t, s = e.#e;
733
+ for (; s; ) {
734
+ for (let r = e.#a + 1; !s.type && r < s.#t.length; r++)
646
735
  for (const i of t.#t) {
647
736
  if (typeof i == "string")
648
737
  throw new Error("string part in extglob AST??");
649
- i.copyIn(n.#t[r]);
738
+ i.copyIn(s.#t[r]);
650
739
  }
651
- e = n, n = e.#e;
740
+ e = s, s = e.#e;
652
741
  }
653
742
  }
654
743
  return this;
@@ -656,26 +745,26 @@ class E {
656
745
  push(...t) {
657
746
  for (const e of t)
658
747
  if (e !== "") {
659
- if (typeof e != "string" && !(e instanceof E && e.#e === this))
748
+ if (typeof e != "string" && !(e instanceof x && e.#e === this))
660
749
  throw new Error("invalid part: " + e);
661
750
  this.#t.push(e);
662
751
  }
663
752
  }
664
753
  toJSON() {
665
754
  const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
666
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#a && this.#e?.type === "!") && t.push({}), t;
755
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
667
756
  }
668
757
  isStart() {
669
758
  if (this.#s === this)
670
759
  return !0;
671
760
  if (!this.#e?.isStart())
672
761
  return !1;
673
- if (this.#o === 0)
762
+ if (this.#a === 0)
674
763
  return !0;
675
764
  const t = this.#e;
676
- for (let e = 0; e < this.#o; e++) {
677
- const n = t.#t[e];
678
- if (!(n instanceof E && n.type === "!"))
765
+ for (let e = 0; e < this.#a; e++) {
766
+ const s = t.#t[e];
767
+ if (!(s instanceof x && s.type === "!"))
679
768
  return !1;
680
769
  }
681
770
  return !0;
@@ -688,96 +777,140 @@ class E {
688
777
  if (!this.type)
689
778
  return this.#e?.isEnd();
690
779
  const t = this.#e ? this.#e.#t.length : 0;
691
- return this.#o === t - 1;
780
+ return this.#a === t - 1;
692
781
  }
693
782
  copyIn(t) {
694
783
  typeof t == "string" ? this.push(t) : this.push(t.clone(this));
695
784
  }
696
785
  clone(t) {
697
- const e = new E(this.type, t);
698
- for (const n of this.#t)
699
- e.copyIn(n);
786
+ const e = new x(this.type, t);
787
+ for (const s of this.#t)
788
+ e.copyIn(s);
700
789
  return e;
701
790
  }
702
- static #h(t, e, n, r) {
703
- let i = !1, o = !1, a = -1, c = !1;
791
+ static #u(t, e, s, r, i) {
792
+ const o = r.maxExtglobRecursion ?? 2;
793
+ let a = !1, c = !1, l = -1, h = !1;
704
794
  if (e.type === null) {
705
- let d = n, g = "";
795
+ let d = s, E = "";
706
796
  for (; d < t.length; ) {
707
- const p = t.charAt(d++);
708
- if (i || p === "\\\\") {
709
- i = !i, g += p;
797
+ const w = t.charAt(d++);
798
+ if (a || w === "\\\\") {
799
+ a = !a, E += w;
710
800
  continue;
711
801
  }
712
- if (o) {
713
- d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
802
+ if (c) {
803
+ d === l + 1 ? (w === "^" || w === "!") && (h = !0) : w === "]" && !(d === l + 2 && h) && (c = !1), E += w;
714
804
  continue;
715
- } else if (p === "[") {
716
- o = !0, a = d, c = !1, g += p;
805
+ } else if (w === "[") {
806
+ c = !0, l = d, h = !1, E += w;
717
807
  continue;
718
808
  }
719
- if (!r.noext && pt(p) && t.charAt(d) === "(") {
720
- e.push(g), g = "";
721
- const S = new E(p, e);
722
- d = E.#h(t, S, d, r), e.push(S);
809
+ if (!r.noext && rt(w) && t.charAt(d) === "(" && i <= o) {
810
+ e.push(E), E = "";
811
+ const M = new x(w, e);
812
+ d = x.#u(t, M, d, r, i + 1), e.push(M);
723
813
  continue;
724
814
  }
725
- g += p;
815
+ E += w;
726
816
  }
727
- return e.push(g), d;
817
+ return e.push(E), d;
728
818
  }
729
- let h = n + 1, l = new E(null, e);
730
- const f = [];
731
- let u = "";
732
- for (; h < t.length; ) {
733
- const d = t.charAt(h++);
734
- if (i || d === "\\\\") {
735
- i = !i, u += d;
819
+ let u = s + 1, f = new x(null, e);
820
+ const p = [];
821
+ let g = "";
822
+ for (; u < t.length; ) {
823
+ const d = t.charAt(u++);
824
+ if (a || d === "\\\\") {
825
+ a = !a, g += d;
736
826
  continue;
737
827
  }
738
- if (o) {
739
- h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
828
+ if (c) {
829
+ u === l + 1 ? (d === "^" || d === "!") && (h = !0) : d === "]" && !(u === l + 2 && h) && (c = !1), g += d;
740
830
  continue;
741
831
  } else if (d === "[") {
742
- o = !0, a = h, c = !1, u += d;
832
+ c = !0, l = u, h = !1, g += d;
743
833
  continue;
744
834
  }
745
- if (pt(d) && t.charAt(h) === "(") {
746
- l.push(u), u = "";
747
- const g = new E(d, l);
748
- l.push(g), h = E.#h(t, g, h, r);
835
+ if (!r.noext && rt(d) && t.charAt(u) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
836
+ (i <= o || e && e.#f(d))) {
837
+ const w = e && e.#f(d) ? 0 : 1;
838
+ f.push(g), g = "";
839
+ const m = new x(d, f);
840
+ f.push(m), u = x.#u(t, m, u, r, i + w);
749
841
  continue;
750
842
  }
751
843
  if (d === "|") {
752
- l.push(u), u = "", f.push(l), l = new E(null, e);
844
+ f.push(g), g = "", p.push(f), f = new x(null, e);
753
845
  continue;
754
846
  }
755
847
  if (d === ")")
756
- return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
757
- u += d;
848
+ return g === "" && e.#t.length === 0 && (e.#h = !0), f.push(g), g = "", e.push(...p, f), u;
849
+ g += d;
758
850
  }
759
- return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
851
+ return e.type = null, e.#n = void 0, e.#t = [t.substring(s - 1)], u;
852
+ }
853
+ #m(t) {
854
+ return this.#d(t, Ie);
855
+ }
856
+ #d(t, e = ke) {
857
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null)
858
+ return !1;
859
+ const s = t.#t[0];
860
+ return !s || typeof s != "object" || s.type === null ? !1 : this.#f(s.type, e);
861
+ }
862
+ #f(t, e = Le) {
863
+ return !!e.get(this.type)?.includes(t);
864
+ }
865
+ #E(t, e) {
866
+ const s = t.#t[0], r = new x(null, s, this.options);
867
+ r.#t.push(""), s.push(r), this.#g(t, e);
868
+ }
869
+ #g(t, e) {
870
+ const s = t.#t[0];
871
+ this.#t.splice(e, 1, ...s.#t);
872
+ for (const r of s.#t)
873
+ typeof r == "object" && (r.#e = this);
874
+ this.#o = void 0;
875
+ }
876
+ #S(t) {
877
+ return !!yt.get(this.type)?.has(t);
878
+ }
879
+ #b(t) {
880
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null || this.#t.length !== 1)
881
+ return !1;
882
+ const e = t.#t[0];
883
+ return !e || typeof e != "object" || e.type === null ? !1 : this.#S(e.type);
884
+ }
885
+ #x(t) {
886
+ const e = yt.get(this.type), s = t.#t[0], r = e?.get(s.type);
887
+ if (!r)
888
+ return !1;
889
+ this.#t = s.#t;
890
+ for (const i of this.#t)
891
+ typeof i == "object" && (i.#e = this);
892
+ this.type = r, this.#o = void 0, this.#h = !1;
760
893
  }
761
894
  static fromGlob(t, e = {}) {
762
- const n = new E(null, void 0, e);
763
- return E.#h(t, n, 0, e), n;
895
+ const s = new x(null, void 0, e);
896
+ return x.#u(t, s, 0, e, 0), s;
764
897
  }
765
898
  // returns the regular expression if there's magic, or the unescaped
766
899
  // string if not.
767
900
  toMMPattern() {
768
901
  if (this !== this.#s)
769
902
  return this.#s.toMMPattern();
770
- const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
771
- if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
772
- return n;
773
- const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
903
+ const t = this.toString(), [e, s, r, i] = this.toRegExpSource();
904
+ if (!(r || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
905
+ return s;
906
+ const a = (this.#i.nocase ? "i" : "") + (i ? "u" : "");
774
907
  return Object.assign(new RegExp(\`^\${e}$\`, a), {
775
908
  _src: e,
776
909
  _glob: t
777
910
  });
778
911
  }
779
912
  get options() {
780
- return this.#r;
913
+ return this.#i;
781
914
  }
782
915
  // returns the string match, the regexp source, whether there's magic
783
916
  // in the regexp (so a regular expression is required) and whether or
@@ -849,168 +982,187 @@ class E {
849
982
  // is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
850
983
  // or start or whatever) and prepend ^ or / at the Regexp construction.
851
984
  toRegExpSource(t) {
852
- const e = t ?? !!this.#r.dot;
853
- if (this.#s === this && this.#d(), !this.type) {
854
- const c = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
855
- const [g, p, S, A] = typeof d == "string" ? E.#p(d, this.#n, c) : d.toRegExpSource(t);
856
- return this.#n = this.#n || S, this.#i = this.#i || A, g;
985
+ const e = t ?? !!this.#i.dot;
986
+ if (this.#s === this && (this.#p(), this.#w()), !gt(this)) {
987
+ const c = this.isStart() && this.isEnd() && !this.#t.some((p) => typeof p != "string"), l = this.#t.map((p) => {
988
+ const [g, d, E, w] = typeof p == "string" ? x.#A(p, this.#n, c) : p.toRegExpSource(t);
989
+ return this.#n = this.#n || E, this.#r = this.#r || w, g;
857
990
  }).join("");
858
- let l = "";
859
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
860
- const g = Me, p = (
991
+ let h = "";
992
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && _e.has(this.#t[0]))) {
993
+ const g = ze, d = (
861
994
  // dots are allowed, and the pattern starts with [ or .
862
- e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
863
- h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
864
- h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
865
- ), S = !e && !t && g.has(h.charAt(0));
866
- l = p ? Fe : S ? W : "";
995
+ e && g.has(l.charAt(0)) || // the pattern starts with \\., and then [ or .
996
+ l.startsWith("\\\\.") && g.has(l.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
997
+ l.startsWith("\\\\.\\\\.") && g.has(l.charAt(4))
998
+ ), E = !e && !t && g.has(l.charAt(0));
999
+ h = d ? He : E ? L : "";
867
1000
  }
868
- let f = "";
869
- return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
870
- l + h + f,
871
- k(h),
1001
+ let u = "";
1002
+ return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (u = "(?:$|\\\\/)"), [
1003
+ h + l + u,
1004
+ R(l),
872
1005
  this.#n = !!this.#n,
873
- this.#i
1006
+ this.#r
874
1007
  ];
875
1008
  }
876
- const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
877
- let i = this.#f(e);
1009
+ const s = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
1010
+ let i = this.#y(e);
878
1011
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
879
- const c = this.toString();
880
- return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
1012
+ const c = this.toString(), l = this;
1013
+ return l.#t = [c], l.type = null, l.#n = void 0, [c, R(this.toString()), !1, !1];
881
1014
  }
882
- let o = !n || t || e || !W ? "" : this.#f(!0);
1015
+ let o = !s || t || e || !L ? "" : this.#y(!0);
883
1016
  o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
884
1017
  let a = "";
885
- if (this.type === "!" && this.#u)
886
- a = (this.isStart() && !e ? W : "") + wt;
1018
+ if (this.type === "!" && this.#h)
1019
+ a = (this.isStart() && !e ? L : "") + mt;
887
1020
  else {
888
1021
  const c = this.type === "!" ? (
889
1022
  // !() must match something,but !(x) can match ''
890
- "))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
1023
+ "))" + (this.isStart() && !e && !t ? L : "") + wt + ")"
891
1024
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
892
1025
  a = r + i + c;
893
1026
  }
894
1027
  return [
895
1028
  a,
896
- k(i),
1029
+ R(i),
897
1030
  this.#n = !!this.#n,
898
- this.#i
1031
+ this.#r
899
1032
  ];
900
1033
  }
901
- #f(t) {
1034
+ #p() {
1035
+ if (gt(this)) {
1036
+ let t = 0, e = !1;
1037
+ do {
1038
+ e = !0;
1039
+ for (let s = 0; s < this.#t.length; s++) {
1040
+ const r = this.#t[s];
1041
+ typeof r == "object" && (r.#p(), this.#d(r) ? (e = !1, this.#g(r, s)) : this.#m(r) ? (e = !1, this.#E(r, s)) : this.#b(r) && (e = !1, this.#x(r)));
1042
+ }
1043
+ } while (!e && ++t < 10);
1044
+ } else
1045
+ for (const t of this.#t)
1046
+ typeof t == "object" && t.#p();
1047
+ this.#o = void 0;
1048
+ }
1049
+ #y(t) {
902
1050
  return this.#t.map((e) => {
903
1051
  if (typeof e == "string")
904
1052
  throw new Error("string type in extglob ast??");
905
- const [n, r, i, o] = e.toRegExpSource(t);
906
- return this.#i = this.#i || o, n;
1053
+ const [s, r, i, o] = e.toRegExpSource(t);
1054
+ return this.#r = this.#r || o, s;
907
1055
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
908
1056
  }
909
- static #p(t, e, n = !1) {
910
- let r = !1, i = "", o = !1;
911
- for (let a = 0; a < t.length; a++) {
912
- const c = t.charAt(a);
1057
+ static #A(t, e, s = !1) {
1058
+ let r = !1, i = "", o = !1, a = !1;
1059
+ for (let c = 0; c < t.length; c++) {
1060
+ const l = t.charAt(c);
913
1061
  if (r) {
914
- r = !1, i += (Te.has(c) ? "\\\\" : "") + c;
1062
+ r = !1, i += (We.has(l) ? "\\\\" : "") + l;
915
1063
  continue;
916
1064
  }
917
- if (c === "\\\\") {
918
- a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
1065
+ if (l === "*") {
1066
+ if (a)
1067
+ continue;
1068
+ a = !0, i += s && /^[*]+$/.test(t) ? mt : wt, e = !0;
1069
+ continue;
1070
+ } else
1071
+ a = !1;
1072
+ if (l === "\\\\") {
1073
+ c === t.length - 1 ? i += "\\\\\\\\" : r = !0;
919
1074
  continue;
920
1075
  }
921
- if (c === "[") {
922
- const [h, l, f, u] = Ce(t, a);
1076
+ if (l === "[") {
1077
+ const [h, u, f, p] = Pe(t, c);
923
1078
  if (f) {
924
- i += h, o = o || l, a += f - 1, e = e || u;
1079
+ i += h, o = o || u, c += f - 1, e = e || p;
925
1080
  continue;
926
1081
  }
927
1082
  }
928
- if (c === "*") {
929
- n && t === "*" ? i += wt : i += gt, e = !0;
930
- continue;
931
- }
932
- if (c === "?") {
933
- i += ct, e = !0;
1083
+ if (l === "?") {
1084
+ i += at, e = !0;
934
1085
  continue;
935
1086
  }
936
- i += Pe(c);
1087
+ i += je(l);
937
1088
  }
938
- return [i, k(t), !!e, o];
939
- }
940
- }
941
- const Re = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (s, t, e = {}) => (V(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new Z(t, e).match(s)), Ie = /^\\*+([^+@!?\\*\\[\\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), He = (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)), We = /^\\*+\\.\\*+$/, je = (s) => !s.startsWith(".") && s.includes("."), _e = (s) => s !== "." && s !== ".." && s.includes("."), Be = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Ge = /^\\*+$/, qe = (s) => s.length !== 0 && !s.startsWith("."), Ve = (s) => s.length !== 0 && s !== "." && s !== "..", Ye = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ze = ([s, t = ""]) => {
942
- const e = It([s]);
943
- return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
944
- }, Xe = ([s, t = ""]) => {
945
- const e = kt([s]);
946
- return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
947
- }, Je = ([s, t = ""]) => {
948
- const e = kt([s]);
949
- return t ? (n) => e(n) && n.endsWith(t) : e;
950
- }, Qe = ([s, t = ""]) => {
951
- const e = It([s]);
952
- return t ? (n) => e(n) && n.endsWith(t) : e;
953
- }, It = ([s]) => {
954
- const t = s.length;
1089
+ return [i, R(t), !!e, o];
1090
+ }
1091
+ }
1092
+ x = ct;
1093
+ const Ge = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? n.replace(/[?*()[\\]{}]/g, "[$&]") : n.replace(/[?*()[\\]\\\\{}]/g, "\\\\$&") : t ? n.replace(/[?*()[\\]]/g, "[$&]") : n.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), b = (n, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(n)), Ue = /^\\*+([^+@!?*[(]*)$/, qe = (n) => (t) => !t.startsWith(".") && t.endsWith(n), Ve = (n) => (t) => t.endsWith(n), Xe = (n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n)), Ye = (n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n)), Ze = /^\\*+\\.\\*+$/, Je = (n) => !n.startsWith(".") && n.includes("."), Qe = (n) => n !== "." && n !== ".." && n.includes("."), Ke = /^\\.\\*+$/, ts = (n) => n !== "." && n !== ".." && n.startsWith("."), es = /^\\*+$/, ss = (n) => n.length !== 0 && !n.startsWith("."), ns = (n) => n.length !== 0 && n !== "." && n !== "..", rs = /^\\?+([^+@!?*[(]*)?$/, is = ([n, t = ""]) => {
1094
+ const e = Lt([n]);
1095
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
1096
+ }, os = ([n, t = ""]) => {
1097
+ const e = Ht([n]);
1098
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
1099
+ }, as = ([n, t = ""]) => {
1100
+ const e = Ht([n]);
1101
+ return t ? (s) => e(s) && s.endsWith(t) : e;
1102
+ }, cs = ([n, t = ""]) => {
1103
+ const e = Lt([n]);
1104
+ return t ? (s) => e(s) && s.endsWith(t) : e;
1105
+ }, Lt = ([n]) => {
1106
+ const t = n.length;
955
1107
  return (e) => e.length === t && !e.startsWith(".");
956
- }, kt = ([s]) => {
957
- const t = s.length;
1108
+ }, Ht = ([n]) => {
1109
+ const t = n.length;
958
1110
  return (e) => e.length === t && e !== "." && e !== "..";
959
- }, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
1111
+ }, zt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", Et = {
960
1112
  win32: { sep: "\\\\" },
961
1113
  posix: { sep: "/" }
962
- }, Ke = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
963
- m.sep = Ke;
964
- const v = Symbol("globstar **");
965
- m.GLOBSTAR = v;
966
- const ts = "[^/]", es = ts + "*?", ss = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ns = "(?:(?!(?:\\\\/|^)\\\\.).)*?", rs = (s, t = {}) => (e) => m(e, s, t);
967
- m.filter = rs;
968
- const D = (s, t = {}) => Object.assign({}, s, t), is = (s) => {
969
- if (!s || typeof s != "object" || !Object.keys(s).length)
970
- return m;
971
- const t = m;
972
- return Object.assign((n, r, i = {}) => t(n, r, D(s, i)), {
1114
+ }, ls = zt === "win32" ? Et.win32.sep : Et.posix.sep;
1115
+ b.sep = ls;
1116
+ const S = /* @__PURE__ */ Symbol("globstar **");
1117
+ b.GLOBSTAR = S;
1118
+ const hs = "[^/]", us = hs + "*?", fs = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ps = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ds = (n, t = {}) => (e) => b(e, n, t);
1119
+ b.filter = ds;
1120
+ const D = (n, t = {}) => Object.assign({}, n, t), gs = (n) => {
1121
+ if (!n || typeof n != "object" || !Object.keys(n).length)
1122
+ return b;
1123
+ const t = b;
1124
+ return Object.assign((s, r, i = {}) => t(s, r, D(n, i)), {
973
1125
  Minimatch: class extends t.Minimatch {
974
1126
  constructor(r, i = {}) {
975
- super(r, D(s, i));
1127
+ super(r, D(n, i));
976
1128
  }
977
1129
  static defaults(r) {
978
- return t.defaults(D(s, r)).Minimatch;
1130
+ return t.defaults(D(n, r)).Minimatch;
979
1131
  }
980
1132
  },
981
1133
  AST: class extends t.AST {
982
1134
  /* c8 ignore start */
983
1135
  constructor(r, i, o = {}) {
984
- super(r, i, D(s, o));
1136
+ super(r, i, D(n, o));
985
1137
  }
986
1138
  /* c8 ignore stop */
987
1139
  static fromGlob(r, i = {}) {
988
- return t.AST.fromGlob(r, D(s, i));
1140
+ return t.AST.fromGlob(r, D(n, i));
989
1141
  }
990
1142
  },
991
- unescape: (n, r = {}) => t.unescape(n, D(s, r)),
992
- escape: (n, r = {}) => t.escape(n, D(s, r)),
993
- filter: (n, r = {}) => t.filter(n, D(s, r)),
994
- defaults: (n) => t.defaults(D(s, n)),
995
- makeRe: (n, r = {}) => t.makeRe(n, D(s, r)),
996
- braceExpand: (n, r = {}) => t.braceExpand(n, D(s, r)),
997
- match: (n, r, i = {}) => t.match(n, r, D(s, i)),
1143
+ unescape: (s, r = {}) => t.unescape(s, D(n, r)),
1144
+ escape: (s, r = {}) => t.escape(s, D(n, r)),
1145
+ filter: (s, r = {}) => t.filter(s, D(n, r)),
1146
+ defaults: (s) => t.defaults(D(n, s)),
1147
+ makeRe: (s, r = {}) => t.makeRe(s, D(n, r)),
1148
+ braceExpand: (s, r = {}) => t.braceExpand(s, D(n, r)),
1149
+ match: (s, r, i = {}) => t.match(s, r, D(n, i)),
998
1150
  sep: t.sep,
999
- GLOBSTAR: v
1151
+ GLOBSTAR: S
1000
1152
  });
1001
1153
  };
1002
- m.defaults = is;
1003
- const Lt = (s, t = {}) => (V(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : Ee(s));
1004
- m.braceExpand = Lt;
1005
- const os = (s, t = {}) => new Z(s, t).makeRe();
1006
- m.makeRe = os;
1007
- const as = (s, t, e = {}) => {
1008
- const n = new Z(t, e);
1009
- return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
1154
+ b.defaults = gs;
1155
+ const _t = (n, t = {}) => (G(n), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(n) ? [n] : Oe(n, { max: t.braceExpandMax }));
1156
+ b.braceExpand = _t;
1157
+ const ys = (n, t = {}) => new q(n, t).makeRe();
1158
+ b.makeRe = ys;
1159
+ const ws = (n, t, e = {}) => {
1160
+ const s = new q(t, e);
1161
+ return n = n.filter((r) => s.match(r)), s.options.nonull && !n.length && n.push(t), n;
1010
1162
  };
1011
- m.match = as;
1012
- const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, cs = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1013
- class Z {
1163
+ b.match = ws;
1164
+ const St = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, ms = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1165
+ class q {
1014
1166
  options;
1015
1167
  set;
1016
1168
  pattern;
@@ -1027,9 +1179,12 @@ class Z {
1027
1179
  isWindows;
1028
1180
  platform;
1029
1181
  windowsNoMagicRoot;
1182
+ maxGlobstarRecursion;
1030
1183
  regexp;
1031
1184
  constructor(t, e = {}) {
1032
- V(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();
1185
+ G(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || zt, this.isWindows = this.platform === "win32";
1186
+ const s = "allowWindowsEscape";
1187
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !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
1188
  }
1034
1189
  hasMagic() {
1035
1190
  if (this.options.magicalBraces && this.set.length > 1)
@@ -1053,15 +1208,18 @@ class Z {
1053
1208
  return;
1054
1209
  }
1055
1210
  this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
1056
- const n = this.globSet.map((i) => this.slashSplit(i));
1057
- this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
1211
+ const s = this.globSet.map((i) => this.slashSplit(i));
1212
+ this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
1058
1213
  let r = this.globParts.map((i, o, a) => {
1059
1214
  if (this.isWindows && this.windowsNoMagicRoot) {
1060
- const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1215
+ const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !St.test(i[2])) && !St.test(i[3]), l = /^[a-z]:/i.test(i[0]);
1061
1216
  if (c)
1062
- return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
1063
- if (h)
1064
- return [i[0], ...i.slice(1).map((l) => this.parse(l))];
1217
+ return [
1218
+ ...i.slice(0, 4),
1219
+ ...i.slice(4).map((h) => this.parse(h))
1220
+ ];
1221
+ if (l)
1222
+ return [i[0], ...i.slice(1).map((h) => this.parse(h))];
1065
1223
  }
1066
1224
  return i.map((c) => this.parse(c));
1067
1225
  });
@@ -1079,30 +1237,30 @@ class Z {
1079
1237
  // of patterns that we have to process.
1080
1238
  preprocess(t) {
1081
1239
  if (this.options.noglobstar)
1082
- for (let n = 0; n < t.length; n++)
1083
- for (let r = 0; r < t[n].length; r++)
1084
- t[n][r] === "**" && (t[n][r] = "*");
1240
+ for (const s of t)
1241
+ for (let r = 0; r < s.length; r++)
1242
+ s[r] === "**" && (s[r] = "*");
1085
1243
  const { optimizationLevel: e = 1 } = this.options;
1086
1244
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
1087
1245
  }
1088
1246
  // just get rid of adjascent ** portions
1089
1247
  adjascentGlobstarOptimize(t) {
1090
1248
  return t.map((e) => {
1091
- let n = -1;
1092
- for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
1093
- let r = n;
1249
+ let s = -1;
1250
+ for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
1251
+ let r = s;
1094
1252
  for (; e[r + 1] === "**"; )
1095
1253
  r++;
1096
- r !== n && e.splice(n, r - n);
1254
+ r !== s && e.splice(s, r - s);
1097
1255
  }
1098
1256
  return e;
1099
1257
  });
1100
1258
  }
1101
1259
  // get rid of adjascent ** and resolve .. portions
1102
1260
  levelOneOptimize(t) {
1103
- return t.map((e) => (e = e.reduce((n, r) => {
1104
- const i = n[n.length - 1];
1105
- return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
1261
+ return t.map((e) => (e = e.reduce((s, r) => {
1262
+ const i = s[s.length - 1];
1263
+ return r === "**" && i === "**" ? s : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (s.pop(), s) : (s.push(r), s);
1106
1264
  }, []), e.length === 0 ? [""] : e));
1107
1265
  }
1108
1266
  levelTwoFileOptimize(t) {
@@ -1116,10 +1274,10 @@ class Z {
1116
1274
  }
1117
1275
  t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1118
1276
  }
1119
- let n = 0;
1120
- for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1121
- const r = t[n - 1];
1122
- r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1277
+ let s = 0;
1278
+ for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
1279
+ const r = t[s - 1];
1280
+ r && r !== "." && r !== ".." && r !== "**" && !(this.isWindows && /^[a-z]:$/i.test(r)) && (e = !0, t.splice(s - 1, 2), s -= 2);
1123
1281
  }
1124
1282
  } while (e);
1125
1283
  return t.length === 0 ? [""] : t;
@@ -1146,35 +1304,35 @@ class Z {
1146
1304
  let e = !1;
1147
1305
  do {
1148
1306
  e = !1;
1149
- for (let n of t) {
1307
+ for (let s of t) {
1150
1308
  let r = -1;
1151
- for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
1309
+ for (; (r = s.indexOf("**", r + 1)) !== -1; ) {
1152
1310
  let o = r;
1153
- for (; n[o + 1] === "**"; )
1311
+ for (; s[o + 1] === "**"; )
1154
1312
  o++;
1155
- o > r && n.splice(r + 1, o - r);
1156
- let a = n[r + 1];
1157
- const c = n[r + 2], h = n[r + 3];
1158
- if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
1313
+ o > r && s.splice(r + 1, o - r);
1314
+ let a = s[r + 1];
1315
+ const c = s[r + 2], l = s[r + 3];
1316
+ if (a !== ".." || !c || c === "." || c === ".." || !l || l === "." || l === "..")
1159
1317
  continue;
1160
- e = !0, n.splice(r, 1);
1161
- const l = n.slice(0);
1162
- l[r] = "**", t.push(l), r--;
1318
+ e = !0, s.splice(r, 1);
1319
+ const h = s.slice(0);
1320
+ h[r] = "**", t.push(h), r--;
1163
1321
  }
1164
1322
  if (!this.preserveMultipleSlashes) {
1165
- for (let o = 1; o < n.length - 1; o++) {
1166
- const a = n[o];
1167
- o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
1323
+ for (let o = 1; o < s.length - 1; o++) {
1324
+ const a = s[o];
1325
+ o === 1 && a === "" && s[0] === "" || (a === "." || a === "") && (e = !0, s.splice(o, 1), o--);
1168
1326
  }
1169
- n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1327
+ s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
1170
1328
  }
1171
1329
  let i = 0;
1172
- for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
1173
- const o = n[i - 1];
1330
+ for (; (i = s.indexOf("..", i + 1)) !== -1; ) {
1331
+ const o = s[i - 1];
1174
1332
  if (o && o !== "." && o !== ".." && o !== "**") {
1175
1333
  e = !0;
1176
- const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
1177
- n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
1334
+ const c = i === 1 && s[i + 1] === "**" ? ["."] : [];
1335
+ s.splice(i - 1, 2, ...c), s.length === 0 && s.push(""), i -= 2;
1178
1336
  }
1179
1337
  }
1180
1338
  }
@@ -1190,23 +1348,23 @@ class Z {
1190
1348
  // ^-- not valid because ** doens't follow symlinks
1191
1349
  secondPhasePreProcess(t) {
1192
1350
  for (let e = 0; e < t.length - 1; e++)
1193
- for (let n = e + 1; n < t.length; n++) {
1194
- const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1351
+ for (let s = e + 1; s < t.length; s++) {
1352
+ const r = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
1195
1353
  if (r) {
1196
- t[e] = [], t[n] = r;
1354
+ t[e] = [], t[s] = r;
1197
1355
  break;
1198
1356
  }
1199
1357
  }
1200
1358
  return t.filter((e) => e.length);
1201
1359
  }
1202
- partsMatch(t, e, n = !1) {
1360
+ partsMatch(t, e, s = !1) {
1203
1361
  let r = 0, i = 0, o = [], a = "";
1204
1362
  for (; r < t.length && i < e.length; )
1205
1363
  if (t[r] === e[i])
1206
1364
  o.push(a === "b" ? e[i] : t[r]), r++, i++;
1207
- else if (n && t[r] === "**" && e[i] === t[r + 1])
1365
+ else if (s && t[r] === "**" && e[i] === t[r + 1])
1208
1366
  o.push(t[r]), r++;
1209
- else if (n && e[i] === "**" && t[r] === e[i + 1])
1367
+ else if (s && e[i] === "**" && t[r] === e[i + 1])
1210
1368
  o.push(e[i]), i++;
1211
1369
  else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1212
1370
  if (a === "b")
@@ -1224,80 +1382,139 @@ class Z {
1224
1382
  if (this.nonegate)
1225
1383
  return;
1226
1384
  const t = this.pattern;
1227
- let e = !1, n = 0;
1385
+ let e = !1, s = 0;
1228
1386
  for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1229
- e = !e, n++;
1230
- n && (this.pattern = t.slice(n)), this.negate = e;
1387
+ e = !e, s++;
1388
+ s && (this.pattern = t.slice(s)), this.negate = e;
1231
1389
  }
1232
1390
  // set partial to true to test if, for example,
1233
1391
  // "/a/b" matches the start of "/*/b/*/d"
1234
1392
  // Partial means, if you run out of file before you run
1235
1393
  // out of pattern, then that's fine, as long as all
1236
1394
  // the parts match.
1237
- matchOne(t, e, n = !1) {
1238
- const r = this.options;
1395
+ matchOne(t, e, s = !1) {
1396
+ let r = 0, i = 0;
1239
1397
  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]), T = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, y = T ? 3 : A ? 0 : void 0;
1241
- if (typeof x == "number" && typeof y == "number") {
1242
- const [P, H] = [t[x], e[y]];
1243
- P.toLowerCase() === H.toLowerCase() && (e[y] = P, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
1398
+ const a = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), c = !a && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), l = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), h = !l && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), u = c ? 3 : a ? 0 : void 0, f = h ? 3 : l ? 0 : void 0;
1399
+ if (typeof u == "number" && typeof f == "number") {
1400
+ const [p, g] = [
1401
+ t[u],
1402
+ e[f]
1403
+ ];
1404
+ p.toLowerCase() === g.toLowerCase() && (e[f] = p, i = f, r = u);
1244
1405
  }
1245
1406
  }
1246
- const { optimizationLevel: i = 1 } = this.options;
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, c = t.length, h = e.length; o < c && a < h; o++, a++) {
1249
- this.debug("matchOne loop");
1250
- var l = e[a], f = t[o];
1251
- if (this.debug(e, l, f), l === !1)
1407
+ const { optimizationLevel: o = 1 } = this.options;
1408
+ return o >= 2 && (t = this.levelTwoFileOptimize(t)), e.includes(S) ? this.#s(t, e, s, r, i) : this.#r(t, e, s, r, i);
1409
+ }
1410
+ #s(t, e, s, r, i) {
1411
+ const o = e.indexOf(S, i), a = e.lastIndexOf(S), [c, l, h] = s ? [
1412
+ e.slice(i, o),
1413
+ e.slice(o + 1),
1414
+ []
1415
+ ] : [
1416
+ e.slice(i, o),
1417
+ e.slice(o + 1, a),
1418
+ e.slice(a + 1)
1419
+ ];
1420
+ if (c.length) {
1421
+ const m = t.slice(r, r + c.length);
1422
+ if (!this.#r(m, c, s, 0, 0))
1252
1423
  return !1;
1253
- if (l === v) {
1254
- this.debug("GLOBSTAR", [e, l, f]);
1255
- var u = o, d = a + 1;
1256
- if (d === h) {
1257
- for (this.debug("** at the end"); o < c; o++)
1258
- if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1259
- return !1;
1260
- return !0;
1261
- }
1262
- for (; u < c; ) {
1263
- var g = t[u];
1264
- if (this.debug(\`
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, c, g), !0;
1267
- if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1268
- this.debug("dot detected!", t, u, e, d);
1269
- break;
1270
- }
1271
- this.debug("globstar swallow a segment, and continue"), u++;
1272
- }
1273
- return !!(n && (this.debug(\`
1274
- >>> no match, partial?\`, t, u, e, d), u === c));
1424
+ r += c.length, i += c.length;
1425
+ }
1426
+ let u = 0;
1427
+ if (h.length) {
1428
+ if (h.length + r > t.length)
1429
+ return !1;
1430
+ let m = t.length - h.length;
1431
+ if (this.#r(t, h, s, m, 0))
1432
+ u = h.length;
1433
+ else {
1434
+ if (t[t.length - 1] !== "" || r + h.length === t.length || (m--, !this.#r(t, h, s, m, 0)))
1435
+ return !1;
1436
+ u = h.length + 1;
1275
1437
  }
1276
- let 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)
1438
+ }
1439
+ if (!l.length) {
1440
+ let m = !!u;
1441
+ for (let M = r; M < t.length - u; M++) {
1442
+ const V = String(t[M]);
1443
+ if (m = !0, V === "." || V === ".." || !this.options.dot && V.startsWith("."))
1444
+ return !1;
1445
+ }
1446
+ return s || m;
1447
+ }
1448
+ const f = [[[], 0]];
1449
+ let p = f[0], g = 0;
1450
+ const d = [0];
1451
+ for (const m of l)
1452
+ m === S ? (d.push(g), p = [[], 0], f.push(p)) : (p[0].push(m), g++);
1453
+ let E = f.length - 1;
1454
+ const w = t.length - u;
1455
+ for (const m of f)
1456
+ m[1] = w - (d[E--] + m[0].length);
1457
+ return !!this.#n(t, f, r, 0, s, 0, !!u);
1458
+ }
1459
+ // return false for "nope, not matching"
1460
+ // return null for "not matching, cannot keep trying"
1461
+ #n(t, e, s, r, i, o, a) {
1462
+ const c = e[r];
1463
+ if (!c) {
1464
+ for (let u = s; u < t.length; u++) {
1465
+ a = !0;
1466
+ const f = t[u];
1467
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1468
+ return !1;
1469
+ }
1470
+ return a;
1471
+ }
1472
+ const [l, h] = c;
1473
+ for (; s <= h; ) {
1474
+ if (this.#r(t.slice(0, s + l.length), l, i, s, 0) && o < this.maxGlobstarRecursion) {
1475
+ const p = this.#n(t, e, s + l.length, r + 1, i, o + 1, a);
1476
+ if (p !== !1)
1477
+ return p;
1478
+ }
1479
+ const f = t[s];
1480
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1481
+ return !1;
1482
+ s++;
1483
+ }
1484
+ return i || null;
1485
+ }
1486
+ #r(t, e, s, r, i) {
1487
+ let o, a, c, l;
1488
+ for (o = r, a = i, l = t.length, c = e.length; o < l && a < c; o++, a++) {
1489
+ this.debug("matchOne loop");
1490
+ let h = e[a], u = t[o];
1491
+ if (this.debug(e, h, u), h === !1 || h === S)
1492
+ return !1;
1493
+ let f;
1494
+ if (typeof h == "string" ? (f = u === h, this.debug("string match", h, u, f)) : (f = h.test(u), this.debug("pattern match", h, u, f)), !f)
1278
1495
  return !1;
1279
1496
  }
1280
- if (o === c && a === h)
1497
+ if (o === l && a === c)
1281
1498
  return !0;
1282
- if (o === c)
1283
- return n;
1284
- if (a === h)
1285
- return o === c - 1 && t[o] === "";
1499
+ if (o === l)
1500
+ return s;
1501
+ if (a === c)
1502
+ return o === l - 1 && t[o] === "";
1286
1503
  throw new Error("wtf?");
1287
1504
  }
1288
1505
  braceExpand() {
1289
- return Lt(this.pattern, this.options);
1506
+ return _t(this.pattern, this.options);
1290
1507
  }
1291
1508
  parse(t) {
1292
- V(t);
1509
+ G(t);
1293
1510
  const e = this.options;
1294
1511
  if (t === "**")
1295
- return v;
1512
+ return S;
1296
1513
  if (t === "")
1297
1514
  return "";
1298
- let n, r = null;
1299
- (n = t.match(Ge)) ? r = e.dot ? Ve : qe : (n = t.match(Ie)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? He : ke)(n[1]) : (n = t.match(Ye)) ? r = (e.nocase ? e.dot ? Xe : Ze : e.dot ? Je : Qe)(n) : (n = t.match(We)) ? r = e.dot ? _e : je : (n = t.match(Be)) && (r = Ue);
1300
- const i = E.fromGlob(t, this.options).toMMPattern();
1515
+ let s, r = null;
1516
+ (s = t.match(es)) ? r = e.dot ? ns : ss : (s = t.match(Ue)) ? r = (e.nocase ? e.dot ? Ye : Xe : e.dot ? Ve : qe)(s[1]) : (s = t.match(rs)) ? r = (e.nocase ? e.dot ? os : is : e.dot ? as : cs)(s) : (s = t.match(Ze)) ? r = e.dot ? Qe : Je : (s = t.match(Ke)) && (r = ts);
1517
+ const i = ct.fromGlob(t, this.options).toMMPattern();
1301
1518
  return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1302
1519
  }
1303
1520
  makeRe() {
@@ -1306,21 +1523,29 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1306
1523
  const t = this.set;
1307
1524
  if (!t.length)
1308
1525
  return this.regexp = !1, this.regexp;
1309
- const e = this.options, n = e.noglobstar ? es : e.dot ? ss : ns, r = new Set(e.nocase ? ["i"] : []);
1526
+ const e = this.options, s = e.noglobstar ? us : e.dot ? fs : ps, r = new Set(e.nocase ? ["i"] : []);
1310
1527
  let i = t.map((c) => {
1311
- const h = c.map((l) => {
1312
- if (l instanceof RegExp)
1313
- for (const f of l.flags.split(""))
1528
+ const l = c.map((u) => {
1529
+ if (u instanceof RegExp)
1530
+ for (const f of u.flags.split(""))
1314
1531
  r.add(f);
1315
- return typeof l == "string" ? cs(l) : l === v ? v : l._src;
1532
+ return typeof u == "string" ? ms(u) : u === S ? S : u._src;
1533
+ });
1534
+ l.forEach((u, f) => {
1535
+ const p = l[f + 1], g = l[f - 1];
1536
+ u !== S || g === S || (g === void 0 ? p !== void 0 && p !== S ? l[f + 1] = "(?:\\\\/|" + s + "\\\\/)?" + p : l[f] = s : p === void 0 ? l[f - 1] = g + "(?:\\\\/|\\\\/" + s + ")?" : p !== S && (l[f - 1] = g + "(?:\\\\/|\\\\/" + s + "\\\\/)" + p, l[f + 1] = S));
1316
1537
  });
1317
- return h.forEach((l, f) => {
1318
- const u = h[f + 1], d = h[f - 1];
1319
- l !== v || d === v || (d === void 0 ? u !== void 0 && u !== v ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== v && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = v));
1320
- }), h.filter((l) => l !== v).join("/");
1538
+ const h = l.filter((u) => u !== S);
1539
+ if (this.partial && h.length >= 1) {
1540
+ const u = [];
1541
+ for (let f = 1; f <= h.length; f++)
1542
+ u.push(h.slice(0, f).join("/"));
1543
+ return "(?:" + u.join("|") + ")";
1544
+ }
1545
+ return h.join("/");
1321
1546
  }).join("|");
1322
1547
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1323
- i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1548
+ i = "^" + o + i + a + "$", this.partial && (i = "^(?:\\\\/|" + o + i.slice(1, -1) + a + ")$"), this.negate && (i = "^(?!" + i + ").+$");
1324
1549
  try {
1325
1550
  this.regexp = new RegExp(i, [...r].join(""));
1326
1551
  } catch {
@@ -1329,7 +1554,7 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1329
1554
  return this.regexp;
1330
1555
  }
1331
1556
  slashSplit(t) {
1332
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\\/\\/[^\\/]+/.test(t) ? ["", ...t.split(/\\/+/)] : t.split(/\\/+/);
1557
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\\/\\/[^/]+/.test(t) ? ["", ...t.split(/\\/+/)] : t.split(/\\/+/);
1333
1558
  }
1334
1559
  match(t, e = this.partial) {
1335
1560
  if (this.debug("match", t, this.pattern), this.comment)
@@ -1338,7 +1563,7 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1338
1563
  return t === "";
1339
1564
  if (t === "/" && e)
1340
1565
  return !0;
1341
- const n = this.options;
1566
+ const s = this.options;
1342
1567
  this.isWindows && (t = t.split("\\\\").join("/"));
1343
1568
  const r = this.slashSplit(t);
1344
1569
  this.debug(this.pattern, "split", r);
@@ -1348,122 +1573,129 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1348
1573
  if (!o)
1349
1574
  for (let a = r.length - 2; !o && a >= 0; a--)
1350
1575
  o = r[a];
1351
- for (let a = 0; a < i.length; a++) {
1352
- const c = i[a];
1353
- let h = r;
1354
- if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
1355
- return n.flipNegate ? !0 : !this.negate;
1576
+ for (const a of i) {
1577
+ let c = r;
1578
+ if (s.matchBase && a.length === 1 && (c = [o]), this.matchOne(c, a, e))
1579
+ return s.flipNegate ? !0 : !this.negate;
1356
1580
  }
1357
- return n.flipNegate ? !1 : this.negate;
1581
+ return s.flipNegate ? !1 : this.negate;
1358
1582
  }
1359
1583
  static defaults(t) {
1360
- return m.defaults(t).Minimatch;
1584
+ return b.defaults(t).Minimatch;
1361
1585
  }
1362
1586
  }
1363
- m.AST = E;
1364
- m.Minimatch = Z;
1365
- m.escape = Re;
1366
- m.unescape = k;
1367
- function ls() {
1587
+ b.AST = ct;
1588
+ b.Minimatch = q;
1589
+ b.escape = Ge;
1590
+ b.unescape = R;
1591
+ function Es() {
1368
1592
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1369
- throw new Kt();
1593
+ throw new se();
1594
+ }
1595
+ function Ss(n, t) {
1596
+ const e = v(n || "/"), s = v(ht(t));
1597
+ return e === "/" ? s : s === "/" ? e : \`\${e.replace(/\\/$/, "")}\${s}\`;
1370
1598
  }
1371
- async function M(s, t) {
1372
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
1599
+ async function Wt(n, t, e = "/") {
1600
+ if (typeof navigator < "u" && navigator.locks?.request) {
1601
+ const s = Ss(e, n).replace(/\\/+/g, "/");
1602
+ return navigator.locks.request(\`opfs:\${s}\`, { mode: "exclusive" }, t);
1603
+ }
1604
+ return t();
1373
1605
  }
1374
- function $(s) {
1375
- return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1606
+ function C(n) {
1607
+ return Array.isArray(n) ? n : (n.startsWith("~/") ? n.slice(2) : n).split("/").filter(Boolean);
1376
1608
  }
1377
- function lt(s) {
1378
- return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1609
+ function lt(n) {
1610
+ return typeof n == "string" ? n ?? "/" : \`/\${n.join("/")}\`;
1379
1611
  }
1380
- function it(s) {
1381
- const t = $(s);
1612
+ function it(n) {
1613
+ const t = C(n);
1382
1614
  return t[t.length - 1] || "";
1383
1615
  }
1384
- function K(s) {
1385
- const t = $(s);
1616
+ function J(n) {
1617
+ const t = C(n);
1386
1618
  return t.pop(), lt(t);
1387
1619
  }
1388
- function Y(s) {
1389
- return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1620
+ function v(n) {
1621
+ return !n || n === "/" ? "/" : n.startsWith("~/") ? \`/\${n.slice(2)}\` : n.startsWith("/") ? n : \`/\${n}\`;
1390
1622
  }
1391
- function hs(s, t = !1) {
1392
- return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1623
+ function bs(n, t = !1) {
1624
+ return n = n.replace(/\\/$/, ""), t && !n.includes("*") ? \`\${n}/**\` : n;
1393
1625
  }
1394
- function tt(s, t) {
1395
- return m(s, t, {
1626
+ function Q(n, t) {
1627
+ return b(n, t, {
1396
1628
  dot: !0,
1397
1629
  matchBase: !0
1398
1630
  });
1399
1631
  }
1400
- function zt(s) {
1401
- const t = Y(s), e = $(t), n = [];
1632
+ function ht(n) {
1633
+ const t = v(n), e = C(t), s = [];
1402
1634
  for (const r of e)
1403
1635
  if (!(r === "." || r === ""))
1404
1636
  if (r === "..") {
1405
- if (n.length === 0)
1637
+ if (s.length === 0)
1406
1638
  continue;
1407
- n.pop();
1639
+ s.pop();
1408
1640
  } else
1409
- n.push(r);
1410
- return lt(n);
1641
+ s.push(r);
1642
+ return lt(s);
1411
1643
  }
1412
- async function us(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1413
- if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1414
- throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1415
- const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1644
+ async function xs(n, t = "SHA-1", e = 50 * 1024 * 1024) {
1645
+ if (n instanceof File && (n = await n.arrayBuffer()), n.byteLength > e)
1646
+ throw new Error(\`File size \${n.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1647
+ const s = new Uint8Array(n), r = await crypto.subtle.digest(t, s);
1416
1648
  return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1417
1649
  }
1418
- async function fs(s, t, e = {}) {
1419
- const n = it(t);
1420
- return M(t, async () => {
1650
+ async function As(n, t, e = {}) {
1651
+ const s = it(t);
1652
+ return Wt(t, async () => {
1421
1653
  const r = e.recursive ?? !1, i = e.force ?? !1;
1422
1654
  try {
1423
- await s.removeEntry(n, { recursive: r });
1655
+ await n.removeEntry(s, { recursive: r });
1424
1656
  } catch (o) {
1425
1657
  if (o.name === "NotFoundError" && i)
1426
1658
  return;
1427
1659
  const a = o.name === "TypeMismatchError" && !r;
1428
- throw b(o, {
1660
+ throw A(o, {
1429
1661
  path: t,
1430
1662
  operation: "remove",
1431
1663
  isDirectory: a
1432
1664
  });
1433
1665
  }
1434
- });
1666
+ }, e.root ?? "/");
1435
1667
  }
1436
- function Et(s, t, e, n) {
1668
+ function bt(n, t, e, s) {
1437
1669
  if (!Number.isInteger(t) || !Number.isInteger(e))
1438
- throw new C("argument", "Invalid offset or length");
1670
+ throw new $("argument", "Invalid offset or length");
1439
1671
  if (t < 0 || e < 0)
1440
- throw new C("argument", "Negative offset or length not allowed");
1441
- if (t + e > s)
1442
- throw new C("overflow", "Operation would overflow buffer");
1443
- if (n != null && (!Number.isInteger(n) || n < 0))
1444
- throw new C("argument", "Invalid position");
1672
+ throw new $("argument", "Negative offset or length not allowed");
1673
+ if (t + e > n)
1674
+ throw new $("overflow", "Operation would overflow buffer");
1675
+ if (s != null && (!Number.isInteger(s) || s < 0))
1676
+ throw new $("argument", "Invalid position");
1445
1677
  }
1446
- function St(s, t, e) {
1678
+ function xt(n, t, e) {
1447
1679
  try {
1448
1680
  t.flush(), t.close();
1449
- } catch (n) {
1450
- console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1681
+ } catch (s) {
1682
+ console.warn(\`Warning: Failed to properly close file descriptor \${n} (\${e}):\`, s);
1451
1683
  }
1452
1684
  }
1453
- function ds(s, t, e) {
1454
- if (s >= e)
1685
+ function Os(n, t, e) {
1686
+ if (n >= e)
1455
1687
  return { isEOF: !0, actualLength: 0 };
1456
- const n = Math.min(t, e - s);
1457
- return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1688
+ const s = Math.min(t, e - n);
1689
+ return s <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: s };
1458
1690
  }
1459
- async function ps(s, t) {
1691
+ async function Ds(n, t) {
1460
1692
  try {
1461
- return await s.createSyncAccessHandle();
1693
+ return await n.createSyncAccessHandle();
1462
1694
  } catch (e) {
1463
- throw b(e, { path: t, isDirectory: !1 });
1695
+ throw A(e, { path: t, isDirectory: !1 });
1464
1696
  }
1465
1697
  }
1466
- class gs {
1698
+ class Ms {
1467
1699
  /** Root directory handle for the file system */
1468
1700
  root;
1469
1701
  /** Map of watched paths and options */
@@ -1492,7 +1724,7 @@ class gs {
1492
1724
  if (!this.options.broadcastChannel)
1493
1725
  return;
1494
1726
  const e = t.path;
1495
- if (![...this.watchers.values()].some((i) => tt(e, i.pattern) && i.include.some((o) => o && tt(e, o)) && !i.exclude.some((o) => o && tt(e, o))))
1727
+ if (![...this.watchers.values()].some((i) => Q(e, i.pattern) && i.include.some((o) => o && Q(e, o)) && !i.exclude.some((o) => o && Q(e, o))))
1496
1728
  return;
1497
1729
  let r;
1498
1730
  if (this.options.hashAlgorithm)
@@ -1514,7 +1746,11 @@ class gs {
1514
1746
  }
1515
1747
  }
1516
1748
  constructor(t) {
1517
- ls(), t && this.setOptions(t);
1749
+ Es(), t && this.setOptions(t);
1750
+ }
1751
+ /** Exclusive path lock keyed by absolute OPFS path (\`root\` + API path). */
1752
+ async withPathLock(t, e) {
1753
+ return Wt(t, e, this.options.root);
1518
1754
  }
1519
1755
  /**
1520
1756
  * Initialize the file system within a given directory.
@@ -1522,12 +1758,12 @@ class gs {
1522
1758
  */
1523
1759
  async mount() {
1524
1760
  const t = this.options.root;
1525
- return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1761
+ return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, s) => {
1526
1762
  try {
1527
1763
  const r = await navigator.storage.getDirectory();
1528
1764
  this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1529
1765
  } catch (r) {
1530
- n(new ie(t, r));
1766
+ s(new ce(t, r));
1531
1767
  } finally {
1532
1768
  this.mountingPromise = null;
1533
1769
  }
@@ -1544,7 +1780,7 @@ class gs {
1544
1780
  * @param options.broadcastChannel - Custom name for the broadcast channel
1545
1781
  */
1546
1782
  async setOptions(t) {
1547
- t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = Y(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1783
+ t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = v(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1548
1784
  }
1549
1785
  /**
1550
1786
  * Get a directory handle from a path
@@ -1564,9 +1800,9 @@ class gs {
1564
1800
  * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
1565
1801
  * \`\`\`
1566
1802
  */
1567
- async getDirectoryHandle(t, e = !1, n = this.root) {
1568
- const r = Array.isArray(t) ? t : $(t);
1569
- let i = n;
1803
+ async getDirectoryHandle(t, e = !1, s = this.root) {
1804
+ const r = Array.isArray(t) ? t : C(t);
1805
+ let i = s;
1570
1806
  for (const o of r)
1571
1807
  i = await i.getDirectoryHandle(o, { create: e });
1572
1808
  return i;
@@ -1590,12 +1826,12 @@ class gs {
1590
1826
  * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
1591
1827
  * \`\`\`
1592
1828
  */
1593
- async getFileHandle(t, e = !1, n = this.root) {
1594
- const r = $(t);
1829
+ async getFileHandle(t, e = !1, s = this.root) {
1830
+ const r = C(t);
1595
1831
  if (r.length === 0)
1596
- throw new te("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1832
+ throw new ne("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1597
1833
  const i = r.pop();
1598
- return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1834
+ return (await this.getDirectoryHandle(r, e, s)).getFileHandle(i, { create: e });
1599
1835
  }
1600
1836
  /**
1601
1837
  * Get a complete index of all files and directories in the file system
@@ -1617,10 +1853,10 @@ class gs {
1617
1853
  * \`\`\`
1618
1854
  */
1619
1855
  async index() {
1620
- const t = /* @__PURE__ */ new Map(), e = async (n) => {
1621
- const r = await this.readDir(n);
1856
+ const t = /* @__PURE__ */ new Map(), e = async (s) => {
1857
+ const r = await this.readDir(s);
1622
1858
  for (const i of r) {
1623
- const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
1859
+ const o = \`\${s === "/" ? "" : s}/\${i.name}\`;
1624
1860
  try {
1625
1861
  const a = await this.stat(o);
1626
1862
  t.set(o, a), a.isDirectory && await e(o);
@@ -1661,17 +1897,17 @@ class gs {
1661
1897
  */
1662
1898
  async mkdir(t, e) {
1663
1899
  await this.mount();
1664
- const n = e?.recursive ?? !1, r = $(t);
1900
+ const s = e?.recursive ?? !1, r = C(t);
1665
1901
  let i = this.root;
1666
1902
  for (let o = 0; o < r.length; o++) {
1667
1903
  const a = r[o];
1668
1904
  try {
1669
- i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1905
+ i = await i.getDirectoryHandle(a, { create: s || o === r.length - 1 });
1670
1906
  } catch (c) {
1671
- throw c.name === "NotFoundError" ? b(c, {
1907
+ throw c.name === "NotFoundError" ? A(c, {
1672
1908
  path: lt(r.slice(0, o + 1)),
1673
1909
  existenceType: "directory"
1674
- }) : c.name === "TypeMismatchError" ? b(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
1910
+ }) : c.name === "TypeMismatchError" ? A(c, { path: a, isDirectory: !1 }) : new Y("create directory", a, c);
1675
1911
  }
1676
1912
  }
1677
1913
  await this.notifyChange({ path: t, type: O.Added, isDirectory: !0 });
@@ -1709,10 +1945,10 @@ class gs {
1709
1945
  isDirectory: !0
1710
1946
  };
1711
1947
  const e = it(t);
1712
- let n;
1948
+ let s;
1713
1949
  try {
1714
- n = await this.getDirectoryHandle(K(t), !1);
1715
- const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1950
+ s = await this.getDirectoryHandle(J(t), !1);
1951
+ const r = this.options.hashAlgorithm, o = await (await s.getFileHandle(e, { create: !1 })).getFile(), a = {
1716
1952
  kind: "file",
1717
1953
  size: o.size,
1718
1954
  mtime: new Date(o.lastModified).toISOString(),
@@ -1724,7 +1960,7 @@ class gs {
1724
1960
  a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1725
1961
  else if (typeof r == "string")
1726
1962
  try {
1727
- const c = await us(o, r, this.options.maxFileSize);
1963
+ const c = await xs(o, r, this.options.maxFileSize);
1728
1964
  a.hash = c;
1729
1965
  } catch (c) {
1730
1966
  console.warn(\`Failed to calculate hash for \${t}:\`, c);
@@ -1732,12 +1968,12 @@ class gs {
1732
1968
  return a;
1733
1969
  } catch (r) {
1734
1970
  if (r.name === "NotFoundError")
1735
- throw new B("file", t, r);
1971
+ throw new _("file", t, r);
1736
1972
  if (r.name !== "TypeMismatchError")
1737
- throw new J("stat", t, r);
1973
+ throw new Y("stat", t, r);
1738
1974
  }
1739
1975
  try {
1740
- return await n.getDirectoryHandle(e, { create: !1 }), {
1976
+ return await s.getDirectoryHandle(e, { create: !1 }), {
1741
1977
  kind: "directory",
1742
1978
  size: 0,
1743
1979
  mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
@@ -1746,7 +1982,7 @@ class gs {
1746
1982
  isDirectory: !0
1747
1983
  };
1748
1984
  } catch (r) {
1749
- throw new J("stat", t, r);
1985
+ throw new Y("stat", t, r);
1750
1986
  }
1751
1987
  }
1752
1988
  /**
@@ -1769,17 +2005,17 @@ class gs {
1769
2005
  */
1770
2006
  async readDir(t) {
1771
2007
  await this.mount();
1772
- const e = await this.getDirectoryHandle(t, !1), n = [];
2008
+ const e = await this.getDirectoryHandle(t, !1), s = [];
1773
2009
  for await (const [r, i] of e.entries()) {
1774
2010
  const o = i.kind === "file";
1775
- n.push({
2011
+ s.push({
1776
2012
  name: r,
1777
2013
  kind: i.kind,
1778
2014
  isFile: o,
1779
2015
  isDirectory: !o
1780
2016
  });
1781
2017
  }
1782
- return n;
2018
+ return s;
1783
2019
  }
1784
2020
  /**
1785
2021
  * Check if a file or directory exists
@@ -1799,22 +2035,22 @@ class gs {
1799
2035
  if (await this.mount(), t === "/")
1800
2036
  return !0;
1801
2037
  const e = it(t);
1802
- let n = null;
2038
+ let s = null;
1803
2039
  try {
1804
- n = await this.getDirectoryHandle(K(t), !1);
2040
+ s = await this.getDirectoryHandle(J(t), !1);
1805
2041
  } catch (r) {
1806
- if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
2042
+ if (s = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1807
2043
  throw r;
1808
2044
  }
1809
- if (!n || !e)
2045
+ if (!s || !e)
1810
2046
  return !1;
1811
2047
  try {
1812
- return await n.getFileHandle(e, { create: !1 }), !0;
2048
+ return await s.getFileHandle(e, { create: !1 }), !0;
1813
2049
  } catch (r) {
1814
2050
  if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1815
2051
  throw r;
1816
2052
  try {
1817
- return await n.getDirectoryHandle(e, { create: !1 }), !0;
2053
+ return await s.getDirectoryHandle(e, { create: !1 }), !0;
1818
2054
  } catch (i) {
1819
2055
  if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1820
2056
  throw i;
@@ -1845,13 +2081,13 @@ class gs {
1845
2081
  await this.mount();
1846
2082
  try {
1847
2083
  const e = await this.readDir(t);
1848
- for (const n of e) {
1849
- const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
2084
+ for (const s of e) {
2085
+ const r = \`\${t === "/" ? "" : t}/\${s.name}\`;
1850
2086
  await this.remove(r, { recursive: !0 });
1851
2087
  }
1852
2088
  await this.notifyChange({ path: t, type: O.Changed, isDirectory: !0 });
1853
2089
  } catch (e) {
1854
- throw e instanceof w ? e : b(e, { path: t, isDirectory: !0 });
2090
+ throw e instanceof y ? e : A(e, { path: t, isDirectory: !0 });
1855
2091
  }
1856
2092
  }
1857
2093
  /**
@@ -1880,9 +2116,9 @@ class gs {
1880
2116
  */
1881
2117
  async remove(t, e) {
1882
2118
  if (await this.mount(), t === "/")
1883
- throw new nt("EROOT", t);
1884
- const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(K(t), !1), o = await this.stat(t);
1885
- await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: O.Removed, isDirectory: o.isDirectory });
2119
+ throw new et("EROOT", t);
2120
+ const { recursive: s = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(J(t), !1), o = await this.stat(t);
2121
+ await As(i, t, { recursive: s, force: r, root: this.options.root }), await this.notifyChange({ path: t, type: O.Removed, isDirectory: o.isDirectory });
1886
2122
  }
1887
2123
  /**
1888
2124
  * Resolve a path to an absolute path
@@ -1905,12 +2141,12 @@ class gs {
1905
2141
  async realpath(t) {
1906
2142
  await this.mount();
1907
2143
  try {
1908
- const e = zt(t);
2144
+ const e = ht(t);
1909
2145
  if (!await this.exists(e))
1910
- throw new B("file", e);
2146
+ throw new _("file", e);
1911
2147
  return e;
1912
2148
  } catch (e) {
1913
- throw e instanceof w ? e : b(e, { path: t });
2149
+ throw e instanceof y ? e : A(e, { path: t });
1914
2150
  }
1915
2151
  }
1916
2152
  /**
@@ -1935,15 +2171,15 @@ class gs {
1935
2171
  * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
1936
2172
  * \`\`\`
1937
2173
  */
1938
- async rename(t, e, n) {
2174
+ async rename(t, e, s) {
1939
2175
  await this.mount();
1940
2176
  try {
1941
- const r = n?.overwrite ?? !1, i = await this.stat(t);
2177
+ const r = s?.overwrite ?? !1, i = await this.stat(t);
1942
2178
  if (await this.exists(e) && !r)
1943
- throw new rt(e);
2179
+ throw new st(e);
1944
2180
  await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: O.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: O.Added, isDirectory: i.isDirectory });
1945
2181
  } catch (r) {
1946
- throw r instanceof w ? r : b(r, { path: t });
2182
+ throw r instanceof y ? r : A(r, { path: t });
1947
2183
  }
1948
2184
  }
1949
2185
  /**
@@ -1971,29 +2207,29 @@ class gs {
1971
2207
  * await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
1972
2208
  * \`\`\`
1973
2209
  */
1974
- async copy(t, e, n) {
2210
+ async copy(t, e, s) {
1975
2211
  await this.mount();
1976
2212
  try {
1977
- const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2213
+ const r = s?.recursive ?? !1, i = s?.overwrite ?? !0;
1978
2214
  if (!await this.exists(t))
1979
- throw new B("source", t);
2215
+ throw new _("source", t);
1980
2216
  if (await this.exists(e) && !i)
1981
- throw new rt(e);
2217
+ throw new st(e);
1982
2218
  if ((await this.stat(t)).isFile) {
1983
- const h = await this.readFile(t);
1984
- await this.writeFile(e, h);
2219
+ const l = await this.readFile(t);
2220
+ await this.writeFile(e, l);
1985
2221
  } else {
1986
2222
  if (!r)
1987
- throw new st("directory", t);
2223
+ throw new tt("directory", t);
1988
2224
  await this.mkdir(e, { recursive: !0 });
1989
- const h = await this.readDir(t);
1990
- for (const l of h) {
1991
- const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
1992
- await this.copy(f, u, { recursive: !0, overwrite: i });
2225
+ const l = await this.readDir(t);
2226
+ for (const h of l) {
2227
+ const u = \`\${t}/\${h.name}\`, f = \`\${e}/\${h.name}\`;
2228
+ await this.copy(u, f, { recursive: !0, overwrite: i });
1993
2229
  }
1994
2230
  }
1995
2231
  } catch (r) {
1996
- throw r instanceof w ? r : b(r, { path: t });
2232
+ throw r instanceof y ? r : A(r, { path: t });
1997
2233
  }
1998
2234
  }
1999
2235
  /**
@@ -2023,13 +2259,13 @@ class gs {
2023
2259
  */
2024
2260
  async watch(t, e) {
2025
2261
  if (!this.options.broadcastChannel)
2026
- throw new Nt("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2027
- const n = {
2028
- pattern: hs(t, e?.recursive ?? !0),
2262
+ throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2263
+ const s = {
2264
+ pattern: bs(t, e?.recursive ?? !0),
2029
2265
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2030
2266
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2031
2267
  };
2032
- this.watchers.set(t, n);
2268
+ this.watchers.set(t, s);
2033
2269
  }
2034
2270
  /**
2035
2271
  * Stop watching a previously watched path
@@ -2060,7 +2296,7 @@ class gs {
2060
2296
  try {
2061
2297
  return await (await this.getFileHandle(t, !1)).getFile();
2062
2298
  } catch (e) {
2063
- throw e instanceof w ? e : b(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
2299
+ throw e instanceof y ? e : A(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
2064
2300
  }
2065
2301
  }
2066
2302
  /**
@@ -2088,20 +2324,20 @@ class gs {
2088
2324
  */
2089
2325
  async importFiles(t, e) {
2090
2326
  await this.mount();
2091
- const n = [...t].map(([c, h]) => [Y(c), h]), r = n.length, i = n.map(([c]) => c), o = n.reduce((c, [, h]) => c + ws(h), 0);
2327
+ const s = [...t].map(([c, l]) => [v(c), l]), r = s.length, i = s.map(([c]) => c), o = s.reduce((c, [, l]) => c + $s(l), 0);
2092
2328
  let a = 0;
2093
2329
  try {
2094
2330
  for (let c = 0; c < r; c++) {
2095
- const [h, l] = n[c], { stream: f, size: u } = ys(l), d = a, g = await this.writeStream(
2096
- h,
2097
- f,
2098
- e ? (p) => e({
2099
- path: h,
2331
+ const [l, h] = s[c], { stream: u, size: f } = Ts(h), p = a, g = await this.writeStream(
2332
+ l,
2333
+ u,
2334
+ e ? (d) => e({
2335
+ path: l,
2100
2336
  index: c,
2101
2337
  count: r,
2102
- bytesWritten: p,
2103
- bytesTotal: u,
2104
- totalBytesWritten: d + p,
2338
+ bytesWritten: d,
2339
+ bytesTotal: f,
2340
+ totalBytesWritten: p + d,
2105
2341
  totalBytes: o
2106
2342
  }) : void 0
2107
2343
  );
@@ -2113,14 +2349,14 @@ class gs {
2113
2349
  bytesWritten: a
2114
2350
  };
2115
2351
  } catch (c) {
2116
- throw c instanceof w ? c : b(c);
2352
+ throw c instanceof y ? c : A(c);
2117
2353
  }
2118
2354
  }
2119
2355
  /**
2120
2356
  * @deprecated Use {@link importFiles} instead.
2121
2357
  */
2122
2358
  async createIndex(t) {
2123
- ms(), await this.importFiles(t);
2359
+ Ns(), await this.importFiles(t);
2124
2360
  }
2125
2361
  /**
2126
2362
  * Dispose of resources and clean up the file system instance
@@ -2129,13 +2365,13 @@ class gs {
2129
2365
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2130
2366
  }
2131
2367
  }
2132
- function ws(s) {
2133
- return typeof s == "string" ? new TextEncoder().encode(s).byteLength : s instanceof Blob ? s.size : s.byteLength;
2368
+ function $s(n) {
2369
+ return typeof n == "string" ? new TextEncoder().encode(n).byteLength : n instanceof Blob ? n.size : n.byteLength;
2134
2370
  }
2135
- function ys(s) {
2136
- if (s instanceof Blob)
2137
- return { stream: s.stream(), size: s.size };
2138
- const t = typeof s == "string" ? new TextEncoder().encode(s) : s;
2371
+ function Ts(n) {
2372
+ if (n instanceof Blob)
2373
+ return { stream: n.stream(), size: n.size };
2374
+ const t = typeof n == "string" ? new TextEncoder().encode(n) : n;
2139
2375
  return {
2140
2376
  size: t.byteLength,
2141
2377
  stream: new ReadableStream({
@@ -2145,11 +2381,11 @@ function ys(s) {
2145
2381
  })
2146
2382
  };
2147
2383
  }
2148
- let xt = !1;
2149
- function ms() {
2150
- xt || (xt = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
2384
+ let At = !1;
2385
+ function Ns() {
2386
+ At || (At = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
2151
2387
  }
2152
- class Es extends gs {
2388
+ class Cs extends Ms {
2153
2389
  /** Shared sync handles per path (OPFS allows only one handle per file) */
2154
2390
  openHandles = /* @__PURE__ */ new Map();
2155
2391
  /** Map of open file descriptors to their metadata */
@@ -2166,32 +2402,32 @@ class Es extends gs {
2166
2402
  _getFileDescriptor(t) {
2167
2403
  const e = this.openFiles.get(t);
2168
2404
  if (!e)
2169
- throw new C("descriptor", \`Invalid file descriptor: \${t}\`);
2405
+ throw new $("descriptor", \`Invalid file descriptor: \${t}\`);
2170
2406
  return e;
2171
2407
  }
2172
2408
  async readFile(t) {
2173
2409
  await this.mount();
2174
2410
  try {
2175
- return await M(t, async () => {
2411
+ return await this.withPathLock(t, async () => {
2176
2412
  const e = await this.open(t);
2177
2413
  try {
2178
- const { size: n } = await this.fstat(e), r = new Uint8Array(n);
2179
- return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
2414
+ const { size: s } = await this.fstat(e), r = new Uint8Array(s);
2415
+ return s > 0 && await this.read(e, r, 0, s, 0), z(r, [r.buffer]);
2180
2416
  } finally {
2181
2417
  await this.close(e);
2182
2418
  }
2183
2419
  });
2184
2420
  } catch (e) {
2185
- throw e instanceof w ? e : b(e, { path: t, isDirectory: !1 });
2421
+ throw e instanceof y ? e : A(e, { path: t, isDirectory: !1 });
2186
2422
  }
2187
2423
  }
2188
2424
  async writeFile(t, e) {
2189
2425
  await this.mount();
2190
- const n = e instanceof Uint8Array ? e : new Uint8Array(e);
2191
- await M(t, async () => {
2426
+ const s = e instanceof Uint8Array ? e : new Uint8Array(e);
2427
+ await this.withPathLock(t, async () => {
2192
2428
  const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
2193
2429
  try {
2194
- await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
2430
+ await this.write(i, s, 0, s.length, null, !1), await this.fsync(i);
2195
2431
  } finally {
2196
2432
  await this.close(i);
2197
2433
  }
@@ -2200,38 +2436,38 @@ class Es extends gs {
2200
2436
  }
2201
2437
  async appendFile(t, e) {
2202
2438
  await this.mount();
2203
- const n = e instanceof Uint8Array ? e : new Uint8Array(e);
2204
- await M(t, async () => {
2439
+ const s = e instanceof Uint8Array ? e : new Uint8Array(e);
2440
+ await this.withPathLock(t, async () => {
2205
2441
  const r = await this.open(t, { create: !0 });
2206
2442
  try {
2207
2443
  const { size: i } = await this.fstat(r);
2208
- await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
2444
+ await this.write(r, s, 0, s.length, i, !1), await this.fsync(r);
2209
2445
  } finally {
2210
2446
  await this.close(r);
2211
2447
  }
2212
2448
  await this.notifyChange({ path: t, type: O.Changed, isDirectory: !1 });
2213
2449
  });
2214
2450
  }
2215
- async writeStream(t, e, n) {
2216
- return await this.mount(), M(t, async () => {
2451
+ async writeStream(t, e, s) {
2452
+ return await this.mount(), this.withPathLock(t, async () => {
2217
2453
  const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 }), o = e.getReader();
2218
2454
  let a = 0;
2219
2455
  try {
2220
2456
  for (; ; ) {
2221
- const { done: c, value: h } = await o.read();
2457
+ const { done: c, value: l } = await o.read();
2222
2458
  if (c)
2223
2459
  break;
2224
- let l = 0;
2225
- for (; l < h.byteLength; )
2226
- l += await this.write(
2460
+ let h = 0;
2461
+ for (; h < l.byteLength; )
2462
+ h += await this.write(
2227
2463
  i,
2228
- h,
2229
2464
  l,
2230
- h.byteLength - l,
2465
+ h,
2466
+ l.byteLength - h,
2231
2467
  null,
2232
2468
  !1
2233
2469
  );
2234
- a += h.byteLength, await n?.(a);
2470
+ a += l.byteLength, await s?.(a);
2235
2471
  }
2236
2472
  await this.fsync(i);
2237
2473
  } catch (c) {
@@ -2249,18 +2485,18 @@ class Es extends gs {
2249
2485
  }
2250
2486
  async open(t, e) {
2251
2487
  await this.mount();
2252
- const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = Y(zt(t));
2488
+ const { create: s = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = v(ht(t));
2253
2489
  try {
2254
- return n && r ? await M(o, async () => {
2490
+ return s && r ? await this.withPathLock(o, async () => {
2255
2491
  if (await this.exists(o))
2256
- throw new rt(o);
2257
- return this._openFile(o, n, i);
2258
- }) : await this._openFile(o, n, i);
2492
+ throw new st(o);
2493
+ return this._openFile(o, s, i);
2494
+ }) : await this._openFile(o, s, i);
2259
2495
  } catch (a) {
2260
- if (a instanceof w)
2496
+ if (a instanceof y)
2261
2497
  throw a;
2262
2498
  const c = a && a.name === "TypeMismatchError";
2263
- throw b(a, {
2499
+ throw A(a, {
2264
2500
  path: o,
2265
2501
  isDirectory: !!c
2266
2502
  });
@@ -2273,19 +2509,19 @@ class Es extends gs {
2273
2509
  * with independent per-FD positions — similar to Node.js.
2274
2510
  * @private
2275
2511
  */
2276
- async _openFile(t, e, n) {
2512
+ async _openFile(t, e, s) {
2277
2513
  let r = this.openHandles.get(t);
2278
2514
  if (!r) {
2279
2515
  const o = await this.getFileHandle(t, e);
2280
2516
  try {
2281
2517
  await o.getFile();
2282
2518
  } catch (c) {
2283
- throw b(c, { path: t, isDirectory: !0 });
2519
+ throw A(c, { path: t, isDirectory: !0 });
2284
2520
  }
2285
- const a = await ps(o, t);
2521
+ const a = await Ds(o, t);
2286
2522
  r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
2287
2523
  }
2288
- r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
2524
+ r.refCount++, s && (r.syncHandle.truncate(0), r.syncHandle.flush());
2289
2525
  const i = this.nextFd++;
2290
2526
  return this.openFiles.set(i, {
2291
2527
  path: t,
@@ -2297,30 +2533,30 @@ class Es extends gs {
2297
2533
  async close(t) {
2298
2534
  const e = this._getFileDescriptor(t);
2299
2535
  this.openFiles.delete(t);
2300
- const n = this.openHandles.get(e.path);
2301
- n && (n.refCount--, n.refCount <= 0 && (St(t, n.syncHandle, e.path), this.openHandles.delete(e.path)));
2536
+ const s = this.openHandles.get(e.path);
2537
+ s && (s.refCount--, s.refCount <= 0 && (xt(t, s.syncHandle, e.path), this.openHandles.delete(e.path)));
2302
2538
  }
2303
- async read(t, e, n, r, i) {
2539
+ async read(t, e, s, r, i) {
2304
2540
  const o = this._getFileDescriptor(t);
2305
- Et(e.length, n, r, i);
2541
+ bt(e.length, s, r, i);
2306
2542
  try {
2307
- const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
2308
- if (h)
2309
- return _({ bytesRead: 0, buffer: e }, [e.buffer]);
2310
- const f = e.subarray(n, n + l), u = o.syncHandle.read(f, { at: a });
2311
- return i == null && (o.position = a + u), _({ bytesRead: u, buffer: e }, [e.buffer]);
2543
+ const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: l, actualLength: h } = Os(a, r, c);
2544
+ if (l)
2545
+ return z({ bytesRead: 0, buffer: e }, [e.buffer]);
2546
+ const u = e.subarray(s, s + h), f = o.syncHandle.read(u, { at: a });
2547
+ return i == null && (o.position = a + f), z({ bytesRead: f, buffer: e }, [e.buffer]);
2312
2548
  } catch (a) {
2313
- throw z("read", t, o.path, a);
2549
+ throw I("read", t, o.path, a);
2314
2550
  }
2315
2551
  }
2316
- async write(t, e, n = 0, r, i, o = !0) {
2317
- const a = this._getFileDescriptor(t), c = r ?? e.length - n;
2318
- Et(e.length, n, c, i);
2552
+ async write(t, e, s = 0, r, i, o = !0) {
2553
+ const a = this._getFileDescriptor(t), c = r ?? e.length - s;
2554
+ bt(e.length, s, c, i);
2319
2555
  try {
2320
- const h = i ?? a.position, l = e.subarray(n, n + c), f = a.syncHandle.write(l, { at: h });
2321
- return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: O.Changed, isDirectory: !1 }), f;
2322
- } catch (h) {
2323
- throw z("write", t, a.path, h);
2556
+ const l = i ?? a.position, h = e.subarray(s, s + c), u = a.syncHandle.write(h, { at: l });
2557
+ return (i == null || i === a.position) && (a.position = l + u), o && await this.notifyChange({ path: a.path, type: O.Changed, isDirectory: !1 }), u;
2558
+ } catch (l) {
2559
+ throw I("write", t, a.path, l);
2324
2560
  }
2325
2561
  }
2326
2562
  async fstat(t) {
@@ -2328,30 +2564,34 @@ class Es extends gs {
2328
2564
  return this.stat(e.path);
2329
2565
  }
2330
2566
  async ftruncate(t, e = 0) {
2331
- const n = this._getFileDescriptor(t);
2567
+ const s = this._getFileDescriptor(t);
2332
2568
  if (e < 0 || !Number.isInteger(e))
2333
- throw new C("argument", "Invalid size");
2569
+ throw new $("argument", "Invalid size");
2334
2570
  try {
2335
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: O.Changed, isDirectory: !1 });
2571
+ s.syncHandle.truncate(e), s.syncHandle.flush(), s.position > e && (s.position = e), await this.notifyChange({ path: s.path, type: O.Changed, isDirectory: !1 });
2336
2572
  } catch (r) {
2337
- throw z("truncate", t, n.path, r);
2573
+ throw I("truncate", t, s.path, r);
2338
2574
  }
2339
2575
  }
2340
2576
  async fsync(t) {
2341
2577
  const e = this._getFileDescriptor(t);
2342
2578
  try {
2343
2579
  e.syncHandle.flush();
2344
- } catch (n) {
2345
- throw z("sync", t, e.path, n);
2580
+ } catch (s) {
2581
+ throw I("sync", t, e.path, s);
2346
2582
  }
2347
2583
  }
2348
2584
  dispose() {
2349
2585
  for (const [t, e] of this.openHandles)
2350
- St(-1, e.syncHandle, t);
2586
+ xt(-1, e.syncHandle, t);
2351
2587
  this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1, super.dispose();
2352
2588
  }
2353
2589
  }
2354
- ot(new Es());
2355
- //# sourceMappingURL=dedicated.worker-DW6UqFo0.js.map
2356
- `,o=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",a],{type:"text/javascript;charset=utf-8"});function l(t){let n;try{if(n=o&&(self.URL||self.webkitURL).createObjectURL(o),!n)throw"";const e=new Worker(n,{type:"module",name:t?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(a),{type:"module",name:t?.name})}}const p=l;function d(t,n){n&&(n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),t.setOptions(n))}function u(t={}){const{url:n,worker:e,...s}=t,r=e??(n?new Worker(n,{type:"module"}):new p),i=h.wrap(r);return d(i,s),{fs:i,worker:r,dispose(){(async()=>{try{await i.dispose()}finally{r.terminate()}})()}}}function f(t){const{fs:n,worker:e,dispose:s}=u(t);return new c.OPFSFacade({fs:n,worker:e,dispose:s})}exports.createOPFSDedicated=f;
2357
- //# sourceMappingURL=createOPFSDedicated-CEeRexom.cjs.map
2590
+ const jt = new Cs();
2591
+ U(jt);
2592
+ addEventListener("message", (n) => {
2593
+ n.data?.type === "opfs-connect" && n.data.port instanceof MessagePort && U(jt, n.data.port);
2594
+ });
2595
+ //# sourceMappingURL=dedicated.worker-Bqqr9UBA.js.map
2596
+ `,f=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",y],{type:"text/javascript;charset=utf-8"});function E(t){let n;try{if(n=f&&(self.URL||self.webkitURL).createObjectURL(f),!n)throw"";const e=new Worker(n,{type:"module",name:t?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(y),{type:"module",name:t?.name})}}const x=E,c=new Map;function S(t,n){return`${g.normalizePath(t)}\0${n?.toString()??"inline"}`}function u(t,n){n&&(n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),t.setOptions(n))}function d(t){const{port1:n,port2:e}=new MessageChannel;return t.postMessage({type:"opfs-connect",port:e},[e]),{fs:v.wrap(n),port:n}}function _(t={}){const{url:n,worker:e,...r}=t,w=g.normalizePath(r.root??"/");if(e){const{fs:s,port:l}=d(e);return u(s,r),{fs:s,worker:e,dispose(){l.close()}}}const a=S(w,n);let i=c.get(a);i||(i={worker:n?new Worker(n,{type:"module"}):new x,refs:0},c.set(a,i)),i.refs+=1;const{worker:o}=i,{fs:h,port:m}=d(o);u(h,r);let p=!1;return{fs:h,worker:o,dispose(){p||(p=!0,(async()=>{const s=c.get(a),l=!!s&&s.worker===o&&s.refs<=1;try{l&&await h.dispose()}finally{m.close()}!s||s.worker!==o||(s.refs-=1,s.refs<=0&&(c.delete(a),o.terminate()))})())}}}function P(t){const{fs:n,worker:e,dispose:r}=_(t);return new b.OPFSFacade({fs:n,worker:e,dispose:r})}exports.createOPFSDedicated=P;
2597
+ //# sourceMappingURL=createOPFSDedicated-EmIwluQo.cjs.map