opfs-worker 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { wrap as u } from "comlink";
2
- import { i as c, d as l, e as h } from "./helpers-CkNHswLp.js";
3
- import { E as x, D as S, F as P, O as F, b as O, a as A, P as T, c as I, S as R, T as $, h as _, v as C, u as N, B as D, g as z, x as k, t as M, f as L, C as j, k as W, q as U, p as H, j as B, m as G, o as q, l as V, n as Y, y as X, r as Z, A as J, s as K, z as Q, w as nn } from "./helpers-CkNHswLp.js";
4
- const f = `/**
2
+ import { i as c, d as l, e as h } from "./helpers-BwklIUit.js";
3
+ import { E as x, D as S, F as P, O as F, b as O, a as A, P as T, c as I, S as R, T as $, W as _, h as C, v as N, u as D, B as z, g as k, x as M, t as j, f as L, C as W, k as U, q as H, p as B, j as G, m as q, o as Y, l as V, n as X, y as Z, r as J, A as K, s as Q, z as nn, w as tn } from "./helpers-BwklIUit.js";
4
+ const p = `/**
5
5
  * @license
6
6
  * Copyright 2019 Google LLC
7
7
  * SPDX-License-Identifier: Apache-2.0
8
8
  */
9
- const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), z = Symbol("Comlink.thrown"), gt = (s) => typeof s == "object" && s !== null || typeof s == "function", Mt = {
10
- canHandle: (s) => gt(s) && s[pt],
9
+ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol("Comlink.releaseProxy"), V = Symbol("Comlink.finalizer"), H = Symbol("Comlink.thrown"), wt = (s) => typeof s == "object" && s !== null || typeof s == "function", Pt = {
10
+ canHandle: (s) => wt(s) && s[gt],
11
11
  serialize(s) {
12
12
  const { port1: t, port2: e } = new MessageChannel();
13
- return K(s, t), [e, [e]];
13
+ return Q(s, t), [e, [e]];
14
14
  },
15
15
  deserialize(s) {
16
- return s.start(), Rt(s);
16
+ return s.start(), Lt(s);
17
17
  }
18
- }, It = {
19
- canHandle: (s) => gt(s) && z in s,
18
+ }, Tt = {
19
+ canHandle: (s) => wt(s) && H in s,
20
20
  serialize({ value: s }) {
21
21
  let t;
22
22
  return s instanceof Error ? t = {
@@ -31,25 +31,25 @@ const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol
31
31
  deserialize(s) {
32
32
  throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
33
33
  }
34
- }, wt = /* @__PURE__ */ new Map([
35
- ["proxy", Mt],
36
- ["throw", It]
34
+ }, mt = /* @__PURE__ */ new Map([
35
+ ["proxy", Pt],
36
+ ["throw", Tt]
37
37
  ]);
38
- function Pt(s, t) {
38
+ function Rt(s, t) {
39
39
  for (const e of s)
40
40
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
41
41
  return !0;
42
42
  return !1;
43
43
  }
44
- function K(s, t = globalThis, e = ["*"]) {
44
+ function Q(s, t = globalThis, e = ["*"]) {
45
45
  t.addEventListener("message", function n(i) {
46
46
  if (!i || !i.data)
47
47
  return;
48
- if (!Pt(e, i.origin)) {
48
+ if (!Rt(e, i.origin)) {
49
49
  console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
50
50
  return;
51
51
  }
52
- const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(F);
52
+ const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(N);
53
53
  let h;
54
54
  try {
55
55
  const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
@@ -58,7 +58,7 @@ function K(s, t = globalThis, e = ["*"]) {
58
58
  h = f;
59
59
  break;
60
60
  case "SET":
61
- c[a.slice(-1)[0]] = F(i.data.value), h = !0;
61
+ c[a.slice(-1)[0]] = N(i.data.value), h = !0;
62
62
  break;
63
63
  case "APPLY":
64
64
  h = f.apply(c, l);
@@ -66,13 +66,13 @@ function K(s, t = globalThis, e = ["*"]) {
66
66
  case "CONSTRUCT":
67
67
  {
68
68
  const u = new f(...l);
69
- h = Wt(u);
69
+ h = _t(u);
70
70
  }
71
71
  break;
72
72
  case "ENDPOINT":
73
73
  {
74
74
  const { port1: u, port2: d } = new MessageChannel();
75
- K(s, d), h = H(u, [u]);
75
+ Q(s, d), h = W(u, [u]);
76
76
  }
77
77
  break;
78
78
  case "RELEASE":
@@ -82,15 +82,15 @@ function K(s, t = globalThis, e = ["*"]) {
82
82
  return;
83
83
  }
84
84
  } catch (c) {
85
- h = { value: c, [z]: 0 };
85
+ h = { value: c, [H]: 0 };
86
86
  }
87
- Promise.resolve(h).catch((c) => ({ value: c, [z]: 0 })).then((c) => {
88
- const [f, u] = U(c);
89
- t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), mt(t), q in s && typeof s[q] == "function" && s[q]());
87
+ Promise.resolve(h).catch((c) => ({ value: c, [H]: 0 })).then((c) => {
88
+ const [f, u] = B(c);
89
+ t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), yt(t), V in s && typeof s[V] == "function" && s[V]());
90
90
  }).catch((c) => {
91
- const [f, u] = U({
91
+ const [f, u] = B({
92
92
  value: new TypeError("Unserializable return value"),
93
- [z]: 0
93
+ [H]: 0
94
94
  });
95
95
  t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
96
96
  });
@@ -99,10 +99,10 @@ function K(s, t = globalThis, e = ["*"]) {
99
99
  function kt(s) {
100
100
  return s.constructor.name === "MessagePort";
101
101
  }
102
- function mt(s) {
102
+ function yt(s) {
103
103
  kt(s) && s.close();
104
104
  }
105
- function Rt(s, t) {
105
+ function Lt(s, t) {
106
106
  const e = /* @__PURE__ */ new Map();
107
107
  return s.addEventListener("message", function(i) {
108
108
  const { data: r } = i;
@@ -115,103 +115,103 @@ function Rt(s, t) {
115
115
  } finally {
116
116
  e.delete(r.id);
117
117
  }
118
- }), Z(s, e, [], t);
118
+ }), J(s, e, [], t);
119
119
  }
120
120
  function k(s) {
121
121
  if (s)
122
122
  throw new Error("Proxy has been released and is not useable");
123
123
  }
124
- function yt(s) {
125
- return N(s, /* @__PURE__ */ new Map(), {
124
+ function Et(s) {
125
+ return D(s, /* @__PURE__ */ new Map(), {
126
126
  type: "RELEASE"
127
127
  }).then(() => {
128
- mt(s);
128
+ yt(s);
129
129
  });
130
130
  }
131
- const _ = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
- const t = (_.get(s) || 0) - 1;
133
- _.set(s, t), t === 0 && yt(s);
131
+ const j = /* @__PURE__ */ new WeakMap(), U = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
+ const t = (j.get(s) || 0) - 1;
133
+ j.set(s, t), t === 0 && Et(s);
134
134
  });
135
- function Lt(s, t) {
136
- const e = (_.get(t) || 0) + 1;
137
- _.set(t, e), j && j.register(s, t, s);
135
+ function zt(s, t) {
136
+ const e = (j.get(t) || 0) + 1;
137
+ j.set(t, e), U && U.register(s, t, s);
138
138
  }
139
- function zt(s) {
140
- j && j.unregister(s);
139
+ function Ht(s) {
140
+ U && U.unregister(s);
141
141
  }
142
- function Z(s, t, e = [], n = function() {
142
+ function J(s, t, e = [], n = function() {
143
143
  }) {
144
144
  let i = !1;
145
145
  const r = new Proxy(n, {
146
146
  get(o, a) {
147
- if (k(i), a === Tt)
147
+ if (k(i), a === It)
148
148
  return () => {
149
- zt(r), yt(s), t.clear(), i = !0;
149
+ Ht(r), Et(s), t.clear(), i = !0;
150
150
  };
151
151
  if (a === "then") {
152
152
  if (e.length === 0)
153
153
  return { then: () => r };
154
- const l = N(s, t, {
154
+ const l = D(s, t, {
155
155
  type: "GET",
156
156
  path: e.map((h) => h.toString())
157
- }).then(F);
157
+ }).then(N);
158
158
  return l.then.bind(l);
159
159
  }
160
- return Z(s, t, [...e, a]);
160
+ return J(s, t, [...e, a]);
161
161
  },
162
162
  set(o, a, l) {
163
163
  k(i);
164
- const [h, c] = U(l);
165
- return N(s, t, {
164
+ const [h, c] = B(l);
165
+ return D(s, t, {
166
166
  type: "SET",
167
167
  path: [...e, a].map((f) => f.toString()),
168
168
  value: h
169
- }, c).then(F);
169
+ }, c).then(N);
170
170
  },
171
171
  apply(o, a, l) {
172
172
  k(i);
173
173
  const h = e[e.length - 1];
174
- if (h === Ct)
175
- return N(s, t, {
174
+ if (h === Mt)
175
+ return D(s, t, {
176
176
  type: "ENDPOINT"
177
- }).then(F);
177
+ }).then(N);
178
178
  if (h === "bind")
179
- return Z(s, t, e.slice(0, -1));
180
- const [c, f] = st(l);
181
- return N(s, t, {
179
+ return J(s, t, e.slice(0, -1));
180
+ const [c, f] = nt(l);
181
+ return D(s, t, {
182
182
  type: "APPLY",
183
183
  path: e.map((u) => u.toString()),
184
184
  argumentList: c
185
- }, f).then(F);
185
+ }, f).then(N);
186
186
  },
187
187
  construct(o, a) {
188
188
  k(i);
189
- const [l, h] = st(a);
190
- return N(s, t, {
189
+ const [l, h] = nt(a);
190
+ return D(s, t, {
191
191
  type: "CONSTRUCT",
192
192
  path: e.map((c) => c.toString()),
193
193
  argumentList: l
194
- }, h).then(F);
194
+ }, h).then(N);
195
195
  }
196
196
  });
197
- return Lt(r, s), r;
197
+ return zt(r, s), r;
198
198
  }
199
- function Ht(s) {
199
+ function Wt(s) {
200
200
  return Array.prototype.concat.apply([], s);
201
201
  }
202
- function st(s) {
203
- const t = s.map(U);
204
- return [t.map((e) => e[0]), Ht(t.map((e) => e[1]))];
202
+ function nt(s) {
203
+ const t = s.map(B);
204
+ return [t.map((e) => e[0]), Wt(t.map((e) => e[1]))];
205
205
  }
206
- const Et = /* @__PURE__ */ new WeakMap();
207
- function H(s, t) {
208
- return Et.set(s, t), s;
206
+ const St = /* @__PURE__ */ new WeakMap();
207
+ function W(s, t) {
208
+ return St.set(s, t), s;
209
209
  }
210
- function Wt(s) {
211
- return Object.assign(s, { [pt]: !0 });
210
+ function _t(s) {
211
+ return Object.assign(s, { [gt]: !0 });
212
212
  }
213
- function U(s) {
214
- for (const [t, e] of wt)
213
+ function B(s) {
214
+ for (const [t, e] of mt)
215
215
  if (e.canHandle(s)) {
216
216
  const [n, i] = e.serialize(s);
217
217
  return [
@@ -228,51 +228,52 @@ function U(s) {
228
228
  type: "RAW",
229
229
  value: s
230
230
  },
231
- Et.get(s) || []
231
+ St.get(s) || []
232
232
  ];
233
233
  }
234
- function F(s) {
234
+ function N(s) {
235
235
  switch (s.type) {
236
236
  case "HANDLER":
237
- return wt.get(s.name).deserialize(s.value);
237
+ return mt.get(s.name).deserialize(s.value);
238
238
  case "RAW":
239
239
  return s.value;
240
240
  }
241
241
  }
242
- function N(s, t, e, n) {
242
+ function D(s, t, e, n) {
243
243
  return new Promise((i) => {
244
- const r = _t();
244
+ const r = jt();
245
245
  t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
246
246
  });
247
247
  }
248
- function _t() {
248
+ function jt() {
249
249
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
250
250
  }
251
+ var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
251
252
  class p extends Error {
252
253
  constructor(t, e, n, i) {
253
254
  super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
254
255
  }
255
256
  }
256
- class jt extends p {
257
+ class Ut extends p {
257
258
  constructor(t) {
258
259
  super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
259
260
  }
260
261
  }
261
- class Ut extends p {
262
+ class Bt extends p {
262
263
  constructor(t, e, n) {
263
264
  super(t, "INVALID_PATH", e, n);
264
265
  }
265
266
  }
266
- class nt extends p {
267
+ class it extends p {
267
268
  constructor(t, e) {
268
269
  super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
269
270
  }
270
271
  }
271
- function R(s, t, e, n) {
272
+ function L(s, t, e, n) {
272
273
  const i = \`\${s.toUpperCase()}_FAILED\`;
273
274
  return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
274
275
  }
275
- function Bt(s, t) {
276
+ function Gt(s, t) {
276
277
  const e = t?.path;
277
278
  switch (s.name) {
278
279
  case "InvalidStateError":
@@ -298,8 +299,8 @@ function Bt(s, t) {
298
299
  return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
299
300
  }
300
301
  }
301
- const St = (s, t, e) => {
302
- const n = s instanceof RegExp ? it(s, e) : s, i = t instanceof RegExp ? it(t, e) : t, r = n !== null && i != null && Gt(n, i, e);
302
+ const xt = (s, t, e) => {
303
+ const n = s instanceof RegExp ? rt(s, e) : s, i = t instanceof RegExp ? rt(t, e) : t, r = n !== null && i != null && qt(n, i, e);
303
304
  return r && {
304
305
  start: r[0],
305
306
  end: r[1],
@@ -307,10 +308,10 @@ const St = (s, t, e) => {
307
308
  body: e.slice(r[0] + n.length, r[1]),
308
309
  post: e.slice(r[1] + i.length)
309
310
  };
310
- }, it = (s, t) => {
311
+ }, rt = (s, t) => {
311
312
  const e = t.match(s);
312
313
  return e ? e[0] : null;
313
- }, Gt = (s, t, e) => {
314
+ }, qt = (s, t, e) => {
314
315
  let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
315
316
  if (l >= 0 && h > 0) {
316
317
  if (s === t)
@@ -328,47 +329,47 @@ const St = (s, t, e) => {
328
329
  n.length && o !== void 0 && (a = [r, o]);
329
330
  }
330
331
  return a;
331
- }, xt = "\\0SLASH" + Math.random() + "\\0", bt = "\\0OPEN" + Math.random() + "\\0", Q = "\\0CLOSE" + Math.random() + "\\0", vt = "\\0COMMA" + Math.random() + "\\0", At = "\\0PERIOD" + Math.random() + "\\0", qt = new RegExp(xt, "g"), Vt = new RegExp(bt, "g"), Xt = new RegExp(Q, "g"), Yt = new RegExp(vt, "g"), Zt = new RegExp(At, "g"), Jt = /\\\\\\\\/g, Kt = /\\\\{/g, Qt = /\\\\}/g, te = /\\\\,/g, ee = /\\\\./g;
332
- function V(s) {
332
+ }, bt = "\\0SLASH" + Math.random() + "\\0", vt = "\\0OPEN" + Math.random() + "\\0", tt = "\\0CLOSE" + Math.random() + "\\0", At = "\\0COMMA" + Math.random() + "\\0", Ft = "\\0PERIOD" + Math.random() + "\\0", Vt = new RegExp(bt, "g"), Xt = new RegExp(vt, "g"), Yt = new RegExp(tt, "g"), Zt = new RegExp(At, "g"), Jt = new RegExp(Ft, "g"), Kt = /\\\\\\\\/g, Qt = /\\\\{/g, te = /\\\\}/g, ee = /\\\\,/g, se = /\\\\./g;
333
+ function X(s) {
333
334
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
334
335
  }
335
- function se(s) {
336
- return s.replace(Jt, xt).replace(Kt, bt).replace(Qt, Q).replace(te, vt).replace(ee, At);
337
- }
338
336
  function ne(s) {
339
- return s.replace(qt, "\\\\").replace(Vt, "{").replace(Xt, "}").replace(Yt, ",").replace(Zt, ".");
337
+ return s.replace(Kt, bt).replace(Qt, vt).replace(te, tt).replace(ee, At).replace(se, Ft);
340
338
  }
341
- function Ft(s) {
339
+ function ie(s) {
340
+ return s.replace(Vt, "\\\\").replace(Xt, "{").replace(Yt, "}").replace(Zt, ",").replace(Jt, ".");
341
+ }
342
+ function Nt(s) {
342
343
  if (!s)
343
344
  return [""];
344
- const t = [], e = St("{", "}", s);
345
+ const t = [], e = xt("{", "}", s);
345
346
  if (!e)
346
347
  return s.split(",");
347
348
  const { pre: n, body: i, post: r } = e, o = n.split(",");
348
349
  o[o.length - 1] += "{" + i + "}";
349
- const a = Ft(r);
350
+ const a = Nt(r);
350
351
  return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
351
352
  }
352
- function ie(s) {
353
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), T(se(s), !0).map(ne)) : [];
354
- }
355
353
  function re(s) {
356
- return "{" + s + "}";
354
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(ne(s), !0).map(ie)) : [];
357
355
  }
358
356
  function oe(s) {
357
+ return "{" + s + "}";
358
+ }
359
+ function ae(s) {
359
360
  return /^-?0\\d/.test(s);
360
361
  }
361
- function ae(s, t) {
362
+ function ce(s, t) {
362
363
  return s <= t;
363
364
  }
364
- function ce(s, t) {
365
+ function le(s, t) {
365
366
  return s >= t;
366
367
  }
367
- function T(s, t) {
368
- const e = [], n = St("{", "}", s);
368
+ function I(s, t) {
369
+ const e = [], n = xt("{", "}", s);
369
370
  if (!n)
370
371
  return [s];
371
- const i = n.pre, r = n.post.length ? T(n.post, !1) : [""];
372
+ const i = n.pre, r = n.post.length ? I(n.post, !1) : [""];
372
373
  if (/\\$$/.test(n.pre))
373
374
  for (let o = 0; o < r.length; o++) {
374
375
  const a = i + "{" + n.body + "}" + r[o];
@@ -377,28 +378,28 @@ function T(s, t) {
377
378
  else {
378
379
  const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
379
380
  if (!l && !h)
380
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + Q + n.post, T(s)) : [s];
381
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + tt + n.post, I(s)) : [s];
381
382
  let c;
382
383
  if (l)
383
384
  c = n.body.split(/\\.\\./);
384
- else if (c = Ft(n.body), c.length === 1 && c[0] !== void 0 && (c = T(c[0], !1).map(re), c.length === 1))
385
+ else if (c = Nt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(oe), c.length === 1))
385
386
  return r.map((u) => n.pre + c[0] + u);
386
387
  let f;
387
388
  if (l && c[0] !== void 0 && c[1] !== void 0) {
388
- const u = V(c[0]), d = V(c[1]), w = Math.max(c[0].length, c[1].length);
389
- let g = c.length === 3 && c[2] !== void 0 ? Math.abs(V(c[2])) : 1, S = ae;
390
- d < u && (g *= -1, S = ce);
391
- const O = c.some(oe);
389
+ const u = X(c[0]), d = X(c[1]), w = Math.max(c[0].length, c[1].length);
390
+ let g = c.length === 3 && c[2] !== void 0 ? Math.abs(X(c[2])) : 1, S = ce;
391
+ d < u && (g *= -1, S = le);
392
+ const $ = c.some(ae);
392
393
  f = [];
393
394
  for (let x = u; S(x, d); x += g) {
394
395
  let m;
395
396
  if (a)
396
397
  m = String.fromCharCode(x), m === "\\\\" && (m = "");
397
- else if (m = String(x), O) {
398
- const $ = w - m.length;
399
- if ($ > 0) {
400
- const P = new Array($ + 1).join("0");
401
- x < 0 ? m = "-" + P + m.slice(1) : m = P + m;
398
+ else if (m = String(x), $) {
399
+ const C = w - m.length;
400
+ if (C > 0) {
401
+ const R = new Array(C + 1).join("0");
402
+ x < 0 ? m = "-" + R + m.slice(1) : m = R + m;
402
403
  }
403
404
  }
404
405
  f.push(m);
@@ -406,7 +407,7 @@ function T(s, t) {
406
407
  } else {
407
408
  f = [];
408
409
  for (let u = 0; u < c.length; u++)
409
- f.push.apply(f, T(c[u], !1));
410
+ f.push.apply(f, I(c[u], !1));
410
411
  }
411
412
  for (let u = 0; u < f.length; u++)
412
413
  for (let d = 0; d < r.length; d++) {
@@ -416,12 +417,12 @@ function T(s, t) {
416
417
  }
417
418
  return e;
418
419
  }
419
- const le = 1024 * 64, B = (s) => {
420
+ const he = 1024 * 64, G = (s) => {
420
421
  if (typeof s != "string")
421
422
  throw new TypeError("invalid pattern");
422
- if (s.length > le)
423
+ if (s.length > he)
423
424
  throw new TypeError("pattern is too long");
424
- }, he = {
425
+ }, ue = {
425
426
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
426
427
  "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
427
428
  "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
@@ -436,7 +437,7 @@ const le = 1024 * 64, B = (s) => {
436
437
  "[:upper:]": ["\\\\p{Lu}", !0],
437
438
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
438
439
  "[:xdigit:]": ["A-Fa-f0-9", !1]
439
- }, C = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ue = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), rt = (s) => s.join(""), fe = (s, t) => {
440
+ }, M = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), fe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ot = (s) => s.join(""), de = (s, t) => {
440
441
  const e = t;
441
442
  if (s.charAt(e) !== "[")
442
443
  throw new Error("not in a brace expression");
@@ -457,27 +458,27 @@ const le = 1024 * 64, B = (s) => {
457
458
  continue;
458
459
  }
459
460
  if (g === "[" && !l) {
460
- for (const [S, [A, O, x]] of Object.entries(he))
461
+ for (const [S, [F, $, x]] of Object.entries(ue))
461
462
  if (s.startsWith(S, r)) {
462
463
  if (f)
463
464
  return ["$.", !1, s.length - e, !0];
464
- r += S.length, x ? i.push(A) : n.push(A), a = a || O;
465
+ r += S.length, x ? i.push(F) : n.push(F), a = a || $;
465
466
  continue t;
466
467
  }
467
468
  }
468
469
  if (l = !1, f) {
469
- g > f ? n.push(C(f) + "-" + C(g)) : g === f && n.push(C(g)), f = "", r++;
470
+ g > f ? n.push(M(f) + "-" + M(g)) : g === f && n.push(M(g)), f = "", r++;
470
471
  continue;
471
472
  }
472
473
  if (s.startsWith("-]", r + 1)) {
473
- n.push(C(g + "-")), r += 2;
474
+ n.push(M(g + "-")), r += 2;
474
475
  continue;
475
476
  }
476
477
  if (s.startsWith("-", r + 1)) {
477
478
  f = g, r += 2;
478
479
  continue;
479
480
  }
480
- n.push(C(g)), r++;
481
+ n.push(M(g)), r++;
481
482
  }
482
483
  if (c < r)
483
484
  return ["", !1, 0, !1];
@@ -485,11 +486,11 @@ const le = 1024 * 64, B = (s) => {
485
486
  return ["$.", !1, s.length - e, !0];
486
487
  if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
487
488
  const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
488
- return [ue(g), !1, c - e, !1];
489
+ return [fe(g), !1, c - e, !1];
489
490
  }
490
- const u = "[" + (h ? "^" : "") + rt(n) + "]", d = "[" + (h ? "" : "^") + rt(i) + "]";
491
+ const u = "[" + (h ? "^" : "") + ot(n) + "]", d = "[" + (h ? "" : "^") + ot(i) + "]";
491
492
  return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
492
- }, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), de = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), ot = (s) => de.has(s), pe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ge = /* @__PURE__ */ new Set(["[", "."]), we = /* @__PURE__ */ new Set(["..", "."]), me = new Set("().*{}+?[]^$\\\\!"), ye = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), tt = "[^/]", at = tt + "*?", ct = tt + "+?";
493
+ }, P = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), pe = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (s) => pe.has(s), ge = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", z = "(?!\\\\.)", we = /* @__PURE__ */ new Set(["[", "."]), me = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), Ee = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), et = "[^/]", ct = et + "*?", lt = et + "+?";
493
494
  class E {
494
495
  type;
495
496
  #s;
@@ -606,7 +607,7 @@ class E {
606
607
  o = !0, a = d, l = !1, w += g;
607
608
  continue;
608
609
  }
609
- if (!i.noext && ot(g) && t.charAt(d) === "(") {
610
+ if (!i.noext && at(g) && t.charAt(d) === "(") {
610
611
  e.push(w), w = "";
611
612
  const S = new E(g, e);
612
613
  d = E.#h(t, S, d, i), e.push(S);
@@ -632,7 +633,7 @@ class E {
632
633
  o = !0, a = h, l = !1, u += d;
633
634
  continue;
634
635
  }
635
- if (ot(d) && t.charAt(h) === "(") {
636
+ if (at(d) && t.charAt(h) === "(") {
636
637
  c.push(u), u = "";
637
638
  const w = new E(d, c);
638
639
  c.push(w), h = E.#h(t, w, h, i);
@@ -742,23 +743,23 @@ class E {
742
743
  const e = t ?? !!this.#i.dot;
743
744
  if (this.#s === this && this.#d(), !this.type) {
744
745
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
745
- const [w, g, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
746
- return this.#n = this.#n || S, this.#r = this.#r || A, w;
746
+ const [w, g, S, F] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
747
+ return this.#n = this.#n || S, this.#r = this.#r || F, w;
747
748
  }).join("");
748
749
  let c = "";
749
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && we.has(this.#t[0]))) {
750
- const w = ge, g = (
750
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && me.has(this.#t[0]))) {
751
+ const w = we, g = (
751
752
  // dots are allowed, and the pattern starts with [ or .
752
753
  e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
753
754
  h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
754
755
  h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
755
756
  ), S = !e && !t && w.has(h.charAt(0));
756
- c = g ? pe : S ? L : "";
757
+ c = g ? ge : S ? z : "";
757
758
  }
758
759
  let f = "";
759
760
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
760
761
  c + h + f,
761
- M(h),
762
+ P(h),
762
763
  this.#n = !!this.#n,
763
764
  this.#r
764
765
  ];
@@ -767,23 +768,23 @@ class E {
767
768
  let r = this.#f(e);
768
769
  if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
769
770
  const l = this.toString();
770
- return this.#t = [l], this.type = null, this.#n = void 0, [l, M(this.toString()), !1, !1];
771
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, P(this.toString()), !1, !1];
771
772
  }
772
- let o = !n || t || e || !L ? "" : this.#f(!0);
773
+ let o = !n || t || e || !z ? "" : this.#f(!0);
773
774
  o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
774
775
  let a = "";
775
776
  if (this.type === "!" && this.#u)
776
- a = (this.isStart() && !e ? L : "") + ct;
777
+ a = (this.isStart() && !e ? z : "") + lt;
777
778
  else {
778
779
  const l = this.type === "!" ? (
779
780
  // !() must match something,but !(x) can match ''
780
- "))" + (this.isStart() && !e && !t ? L : "") + at + ")"
781
+ "))" + (this.isStart() && !e && !t ? z : "") + ct + ")"
781
782
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
782
783
  a = i + r + l;
783
784
  }
784
785
  return [
785
786
  a,
786
- M(r),
787
+ P(r),
787
788
  this.#n = !!this.#n,
788
789
  this.#r
789
790
  ];
@@ -801,7 +802,7 @@ class E {
801
802
  for (let a = 0; a < t.length; a++) {
802
803
  const l = t.charAt(a);
803
804
  if (i) {
804
- i = !1, r += (me.has(l) ? "\\\\" : "") + l;
805
+ i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
805
806
  continue;
806
807
  }
807
808
  if (l === "\\\\") {
@@ -809,53 +810,53 @@ class E {
809
810
  continue;
810
811
  }
811
812
  if (l === "[") {
812
- const [h, c, f, u] = fe(t, a);
813
+ const [h, c, f, u] = de(t, a);
813
814
  if (f) {
814
815
  r += h, o = o || c, a += f - 1, e = e || u;
815
816
  continue;
816
817
  }
817
818
  }
818
819
  if (l === "*") {
819
- n && t === "*" ? r += ct : r += at, e = !0;
820
+ n && t === "*" ? r += lt : r += ct, e = !0;
820
821
  continue;
821
822
  }
822
823
  if (l === "?") {
823
- r += tt, e = !0;
824
+ r += et, e = !0;
824
825
  continue;
825
826
  }
826
- r += ye(l);
827
+ r += Ee(l);
827
828
  }
828
- return [r, M(t), !!e, o];
829
+ return [r, P(t), !!e, o];
829
830
  }
830
831
  }
831
- const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (B(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new G(t, e).match(s)), Se = /^\\*+([^+@!?\\*\\[\\(]*)$/, xe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), be = (s) => (t) => t.endsWith(s), ve = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ae = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Fe = /^\\*+\\.\\*+$/, Ne = (s) => !s.startsWith(".") && s.includes("."), De = (s) => s !== "." && s !== ".." && s.includes("."), Oe = /^\\.\\*+$/, $e = (s) => s !== "." && s !== ".." && s.startsWith("."), Ce = /^\\*+$/, Te = (s) => s.length !== 0 && !s.startsWith("."), Me = (s) => s.length !== 0 && s !== "." && s !== "..", Ie = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Pe = ([s, t = ""]) => {
832
- const e = Nt([s]);
832
+ const Se = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(s)), xe = /^\\*+([^+@!?\\*\\[\\(]*)$/, be = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ve = (s) => (t) => t.endsWith(s), Ae = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Fe = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Ne = /^\\*+\\.\\*+$/, De = (s) => !s.startsWith(".") && s.includes("."), Oe = (s) => s !== "." && s !== ".." && s.includes("."), $e = /^\\.\\*+$/, Ce = (s) => s !== "." && s !== ".." && s.startsWith("."), Me = /^\\*+$/, Ie = (s) => s.length !== 0 && !s.startsWith("."), Pe = (s) => s.length !== 0 && s !== "." && s !== "..", Te = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Re = ([s, t = ""]) => {
833
+ const e = Dt([s]);
833
834
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
834
835
  }, ke = ([s, t = ""]) => {
835
- const e = Dt([s]);
836
+ const e = Ot([s]);
836
837
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
837
- }, Re = ([s, t = ""]) => {
838
- const e = Dt([s]);
839
- return t ? (n) => e(n) && n.endsWith(t) : e;
840
838
  }, Le = ([s, t = ""]) => {
841
- const e = Nt([s]);
839
+ const e = Ot([s]);
840
+ return t ? (n) => e(n) && n.endsWith(t) : e;
841
+ }, ze = ([s, t = ""]) => {
842
+ const e = Dt([s]);
842
843
  return t ? (n) => e(n) && n.endsWith(t) : e;
843
- }, Nt = ([s]) => {
844
+ }, Dt = ([s]) => {
844
845
  const t = s.length;
845
846
  return (e) => e.length === t && !e.startsWith(".");
846
- }, Dt = ([s]) => {
847
+ }, Ot = ([s]) => {
847
848
  const t = s.length;
848
849
  return (e) => e.length === t && e !== "." && e !== "..";
849
- }, Ot = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", lt = {
850
+ }, $t = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ht = {
850
851
  win32: { sep: "\\\\" },
851
852
  posix: { sep: "/" }
852
- }, ze = Ot === "win32" ? lt.win32.sep : lt.posix.sep;
853
- y.sep = ze;
853
+ }, He = $t === "win32" ? ht.win32.sep : ht.posix.sep;
854
+ y.sep = He;
854
855
  const v = Symbol("globstar **");
855
856
  y.GLOBSTAR = v;
856
- const He = "[^/]", We = He + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", je = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Ue = (s, t = {}) => (e) => y(e, s, t);
857
- y.filter = Ue;
858
- const b = (s, t = {}) => Object.assign({}, s, t), Be = (s) => {
857
+ const We = "[^/]", _e = We + "*?", je = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ue = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => y(e, s, t);
858
+ y.filter = Be;
859
+ const b = (s, t = {}) => Object.assign({}, s, t), Ge = (s) => {
859
860
  if (!s || typeof s != "object" || !Object.keys(s).length)
860
861
  return y;
861
862
  const t = y;
@@ -889,18 +890,18 @@ const b = (s, t = {}) => Object.assign({}, s, t), Be = (s) => {
889
890
  GLOBSTAR: v
890
891
  });
891
892
  };
892
- y.defaults = Be;
893
- const $t = (s, t = {}) => (B(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ie(s));
894
- y.braceExpand = $t;
895
- const Ge = (s, t = {}) => new G(s, t).makeRe();
896
- y.makeRe = Ge;
897
- const qe = (s, t, e = {}) => {
898
- const n = new G(t, e);
893
+ y.defaults = Ge;
894
+ const Ct = (s, t = {}) => (G(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : re(s));
895
+ y.braceExpand = Ct;
896
+ const qe = (s, t = {}) => new q(s, t).makeRe();
897
+ y.makeRe = qe;
898
+ const Ve = (s, t, e = {}) => {
899
+ const n = new q(t, e);
899
900
  return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
900
901
  };
901
- y.match = qe;
902
- const ht = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
903
- class G {
902
+ y.match = Ve;
903
+ const ut = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
904
+ class q {
904
905
  options;
905
906
  set;
906
907
  pattern;
@@ -919,7 +920,7 @@ class G {
919
920
  windowsNoMagicRoot;
920
921
  regexp;
921
922
  constructor(t, e = {}) {
922
- B(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ot, 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();
923
+ G(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || $t, 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();
923
924
  }
924
925
  hasMagic() {
925
926
  if (this.options.magicalBraces && this.set.length > 1)
@@ -947,7 +948,7 @@ class G {
947
948
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
948
949
  let i = this.globParts.map((r, o, a) => {
949
950
  if (this.isWindows && this.windowsNoMagicRoot) {
950
- const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ht.test(r[2])) && !ht.test(r[3]), h = /^[a-z]:/i.test(r[0]);
951
+ const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ut.test(r[2])) && !ut.test(r[3]), h = /^[a-z]:/i.test(r[0]);
951
952
  if (l)
952
953
  return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
953
954
  if (h)
@@ -1127,10 +1128,10 @@ class G {
1127
1128
  matchOne(t, e, n = !1) {
1128
1129
  const i = this.options;
1129
1130
  if (this.isWindows) {
1130
- const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), O = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = O ? 3 : A ? 0 : void 0;
1131
+ const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), F = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), $ = !F && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = $ ? 3 : F ? 0 : void 0;
1131
1132
  if (typeof x == "number" && typeof m == "number") {
1132
- const [$, P] = [t[x], e[m]];
1133
- $.toLowerCase() === P.toLowerCase() && (e[m] = $, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1133
+ const [C, R] = [t[x], e[m]];
1134
+ C.toLowerCase() === R.toLowerCase() && (e[m] = C, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1134
1135
  }
1135
1136
  }
1136
1137
  const { optimizationLevel: r = 1 } = this.options;
@@ -1176,17 +1177,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1176
1177
  throw new Error("wtf?");
1177
1178
  }
1178
1179
  braceExpand() {
1179
- return $t(this.pattern, this.options);
1180
+ return Ct(this.pattern, this.options);
1180
1181
  }
1181
1182
  parse(t) {
1182
- B(t);
1183
+ G(t);
1183
1184
  const e = this.options;
1184
1185
  if (t === "**")
1185
1186
  return v;
1186
1187
  if (t === "")
1187
1188
  return "";
1188
1189
  let n, i = null;
1189
- (n = t.match(Ce)) ? i = e.dot ? Me : Te : (n = t.match(Se)) ? i = (e.nocase ? e.dot ? Ae : ve : e.dot ? be : xe)(n[1]) : (n = t.match(Ie)) ? i = (e.nocase ? e.dot ? ke : Pe : e.dot ? Re : Le)(n) : (n = t.match(Fe)) ? i = e.dot ? De : Ne : (n = t.match(Oe)) && (i = $e);
1190
+ (n = t.match(Me)) ? i = e.dot ? Pe : Ie : (n = t.match(xe)) ? i = (e.nocase ? e.dot ? Fe : Ae : e.dot ? ve : be)(n[1]) : (n = t.match(Te)) ? i = (e.nocase ? e.dot ? ke : Re : e.dot ? Le : ze)(n) : (n = t.match(Ne)) ? i = e.dot ? Oe : De : (n = t.match($e)) && (i = Ce);
1190
1191
  const r = E.fromGlob(t, this.options).toMMPattern();
1191
1192
  return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1192
1193
  }
@@ -1196,13 +1197,13 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1196
1197
  const t = this.set;
1197
1198
  if (!t.length)
1198
1199
  return this.regexp = !1, this.regexp;
1199
- const e = this.options, n = e.noglobstar ? We : e.dot ? _e : je, i = new Set(e.nocase ? ["i"] : []);
1200
+ const e = this.options, n = e.noglobstar ? _e : e.dot ? je : Ue, i = new Set(e.nocase ? ["i"] : []);
1200
1201
  let r = t.map((l) => {
1201
1202
  const h = l.map((c) => {
1202
1203
  if (c instanceof RegExp)
1203
1204
  for (const f of c.flags.split(""))
1204
1205
  i.add(f);
1205
- return typeof c == "string" ? Ve(c) : c === v ? v : c._src;
1206
+ return typeof c == "string" ? Xe(c) : c === v ? v : c._src;
1206
1207
  });
1207
1208
  return h.forEach((c, f) => {
1208
1209
  const u = h[f + 1], d = h[f - 1];
@@ -1251,44 +1252,44 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1251
1252
  }
1252
1253
  }
1253
1254
  y.AST = E;
1254
- y.Minimatch = G;
1255
- y.escape = Ee;
1256
- y.unescape = M;
1257
- function Xe() {
1255
+ y.Minimatch = q;
1256
+ y.escape = Se;
1257
+ y.unescape = P;
1258
+ function Ye() {
1258
1259
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1259
- throw new jt();
1260
+ throw new Ut();
1260
1261
  }
1261
- async function I(s, t, e) {
1262
+ async function T(s, t, e) {
1262
1263
  return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1263
1264
  }
1264
- function D(s) {
1265
+ function O(s) {
1265
1266
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1266
1267
  }
1267
- function et(s) {
1268
+ function st(s) {
1268
1269
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1269
1270
  }
1270
- function J(s) {
1271
- const t = D(s);
1271
+ function K(s) {
1272
+ const t = O(s);
1272
1273
  return t[t.length - 1] || "";
1273
1274
  }
1274
- function X(s) {
1275
- const t = D(s);
1276
- return t.pop(), et(t);
1275
+ function Y(s) {
1276
+ const t = O(s);
1277
+ return t.pop(), st(t);
1277
1278
  }
1278
- function W(s) {
1279
+ function _(s) {
1279
1280
  return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1280
1281
  }
1281
- function Ye(s, t = !1) {
1282
+ function Ze(s, t = !1) {
1282
1283
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1283
1284
  }
1284
- function Y(s, t) {
1285
+ function Z(s, t) {
1285
1286
  return y(s, t, {
1286
1287
  dot: !0,
1287
1288
  matchBase: !0
1288
1289
  });
1289
1290
  }
1290
- function ut(s) {
1291
- const t = W(s), e = D(t), n = [];
1291
+ function ft(s) {
1292
+ const t = _(s), e = O(t), n = [];
1292
1293
  for (const i of e)
1293
1294
  if (!(i === "." || i === ""))
1294
1295
  if (i === "..") {
@@ -1297,23 +1298,22 @@ function ut(s) {
1297
1298
  n.pop();
1298
1299
  } else
1299
1300
  n.push(i);
1300
- return et(n);
1301
+ return st(n);
1301
1302
  }
1302
- async function Ze(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1303
+ async function Je(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1303
1304
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1304
1305
  throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1305
1306
  const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1306
1307
  return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1307
1308
  }
1308
- async function Je(s) {
1309
+ async function Ke(s) {
1309
1310
  const t = await s.arrayBuffer();
1310
1311
  return new Uint8Array(t);
1311
1312
  }
1312
- async function Ke(s, t, e = {}) {
1313
- const n = J(t);
1314
- return I(t, "exclusive", async () => {
1313
+ async function Qe(s, t, e = {}) {
1314
+ const n = K(t);
1315
+ return T(t, "exclusive", async () => {
1315
1316
  const i = e.recursive ?? !1, r = e.force ?? !1;
1316
- e.useTrash;
1317
1317
  try {
1318
1318
  await s.removeEntry(n, { recursive: i });
1319
1319
  } catch (o) {
@@ -1324,7 +1324,7 @@ async function Ke(s, t, e = {}) {
1324
1324
  }
1325
1325
  });
1326
1326
  }
1327
- function ft(s, t, e, n) {
1327
+ function dt(s, t, e, n) {
1328
1328
  if (!Number.isInteger(t) || !Number.isInteger(e))
1329
1329
  throw new p("Invalid offset or length", "EINVAL");
1330
1330
  if (t < 0 || e < 0)
@@ -1334,27 +1334,27 @@ function ft(s, t, e, n) {
1334
1334
  if (n != null && (!Number.isInteger(n) || n < 0))
1335
1335
  throw new p("Invalid position", "EINVAL");
1336
1336
  }
1337
- function dt(s, t, e) {
1337
+ function pt(s, t, e) {
1338
1338
  try {
1339
1339
  t.flush(), t.close();
1340
1340
  } catch (n) {
1341
1341
  console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1342
1342
  }
1343
1343
  }
1344
- function Qe(s, t, e) {
1344
+ function ts(s, t, e) {
1345
1345
  if (s >= e)
1346
1346
  return { isEOF: !0, actualLength: 0 };
1347
1347
  const n = Math.min(t, e - s);
1348
1348
  return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1349
1349
  }
1350
- async function ts(s, t) {
1350
+ async function es(s, t) {
1351
1351
  try {
1352
1352
  return await s.createSyncAccessHandle();
1353
1353
  } catch (e) {
1354
- throw Bt(e, { path: t });
1354
+ throw Gt(e, { path: t });
1355
1355
  }
1356
1356
  }
1357
- class es {
1357
+ class ss {
1358
1358
  /** Root directory handle for the file system */
1359
1359
  root;
1360
1360
  /** Map of watched paths and options */
@@ -1368,7 +1368,7 @@ class es {
1368
1368
  root: "/",
1369
1369
  namespace: "",
1370
1370
  maxFileSize: 50 * 1024 * 1024,
1371
- hashAlgorithm: !1,
1371
+ hashAlgorithm: "etag",
1372
1372
  broadcastChannel: "opfs-worker"
1373
1373
  };
1374
1374
  /** Map of open file descriptors to their metadata */
@@ -1398,7 +1398,7 @@ class es {
1398
1398
  if (!this.options.broadcastChannel)
1399
1399
  return;
1400
1400
  const e = t.path;
1401
- if (![...this.watchers.values()].some((r) => Y(e, r.pattern) && r.include.some((o) => o && Y(e, o)) && !r.exclude.some((o) => o && Y(e, o))))
1401
+ if (![...this.watchers.values()].some((r) => Z(e, r.pattern) && r.include.some((o) => o && Z(e, o)) && !r.exclude.some((o) => o && Z(e, o))))
1402
1402
  return;
1403
1403
  let i;
1404
1404
  if (this.options.hashAlgorithm)
@@ -1430,7 +1430,7 @@ class es {
1430
1430
  * @throws {OPFSError} If OPFS is not supported in the current browser
1431
1431
  */
1432
1432
  constructor(t) {
1433
- Xe(), t && this.setOptions(t);
1433
+ Ye(), t && this.setOptions(t);
1434
1434
  }
1435
1435
  /**
1436
1436
  * Initialize the file system within a given directory
@@ -1477,7 +1477,7 @@ class es {
1477
1477
  * @param options.broadcastChannel - Custom name for the broadcast channel
1478
1478
  */
1479
1479
  async setOptions(t) {
1480
- 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 = W(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1480
+ t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = _(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1481
1481
  }
1482
1482
  /**
1483
1483
  * Get a directory handle from a path
@@ -1498,7 +1498,7 @@ class es {
1498
1498
  * \`\`\`
1499
1499
  */
1500
1500
  async getDirectoryHandle(t, e = !1, n = this.root) {
1501
- const i = Array.isArray(t) ? t : D(t);
1501
+ const i = Array.isArray(t) ? t : O(t);
1502
1502
  let r = n;
1503
1503
  for (const o of i)
1504
1504
  r = await r.getDirectoryHandle(o, { create: e });
@@ -1524,9 +1524,9 @@ class es {
1524
1524
  * \`\`\`
1525
1525
  */
1526
1526
  async getFileHandle(t, e = !1, n = this.root) {
1527
- const i = D(t);
1527
+ const i = O(t);
1528
1528
  if (i.length === 0)
1529
- throw new Ut("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1529
+ throw new Bt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1530
1530
  const r = i.pop();
1531
1531
  return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
1532
1532
  }
@@ -1593,17 +1593,17 @@ class es {
1593
1593
  async readFile(t) {
1594
1594
  await this.mount();
1595
1595
  try {
1596
- return await I(t, "shared", async () => {
1596
+ return await T(t, "shared", async () => {
1597
1597
  const e = await this.open(t);
1598
1598
  try {
1599
1599
  const { size: n } = await this.fstat(e), i = new Uint8Array(n);
1600
- return n > 0 && await this.read(e, i, 0, n, 0), H(i, [i.buffer]);
1600
+ return n > 0 && await this.read(e, i, 0, n, 0), W(i, [i.buffer]);
1601
1601
  } finally {
1602
1602
  await this.close(e);
1603
1603
  }
1604
1604
  });
1605
1605
  } catch (e) {
1606
- throw new nt(t, e);
1606
+ throw new it(t, e);
1607
1607
  }
1608
1608
  }
1609
1609
  /**
@@ -1631,14 +1631,14 @@ class es {
1631
1631
  async writeFile(t, e) {
1632
1632
  await this.mount();
1633
1633
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1634
- await I(t, "exclusive", async () => {
1634
+ await T(t, "exclusive", async () => {
1635
1635
  const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
1636
1636
  try {
1637
1637
  await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
1638
1638
  } finally {
1639
1639
  await this.close(r);
1640
1640
  }
1641
- await this.notifyChange({ path: t, type: i ? "changed" : "added", isDirectory: !1 });
1641
+ await this.notifyChange({ path: t, type: i ? A.Changed : A.Added, isDirectory: !1 });
1642
1642
  });
1643
1643
  }
1644
1644
  /**
@@ -1666,7 +1666,7 @@ class es {
1666
1666
  async appendFile(t, e) {
1667
1667
  await this.mount();
1668
1668
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1669
- await I(t, "exclusive", async () => {
1669
+ await T(t, "exclusive", async () => {
1670
1670
  const i = await this.open(t, { create: !0 });
1671
1671
  try {
1672
1672
  const { size: r } = await this.fstat(i);
@@ -1674,7 +1674,7 @@ class es {
1674
1674
  } finally {
1675
1675
  await this.close(i);
1676
1676
  }
1677
- await this.notifyChange({ path: t, type: "changed", isDirectory: !1 });
1677
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1678
1678
  });
1679
1679
  }
1680
1680
  /**
@@ -1700,7 +1700,7 @@ class es {
1700
1700
  */
1701
1701
  async mkdir(t, e) {
1702
1702
  await this.mount();
1703
- const n = e?.recursive ?? !1, i = D(t);
1703
+ const n = e?.recursive ?? !1, i = O(t);
1704
1704
  let r = this.root;
1705
1705
  for (let o = 0; o < i.length; o++) {
1706
1706
  const a = i[o];
@@ -1708,14 +1708,14 @@ class es {
1708
1708
  r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
1709
1709
  } catch (l) {
1710
1710
  throw l.name === "NotFoundError" ? new p(
1711
- \`Parent directory does not exist: \${et(i.slice(0, o + 1))}\`,
1711
+ \`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
1712
1712
  "ENOENT",
1713
1713
  void 0,
1714
1714
  l
1715
1715
  ) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
1716
1716
  }
1717
1717
  }
1718
- await this.notifyChange({ path: t, type: "added", isDirectory: !0 });
1718
+ await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1719
1719
  }
1720
1720
  /**
1721
1721
  * Get file or directory statistics
@@ -1749,7 +1749,7 @@ class es {
1749
1749
  isFile: !1,
1750
1750
  isDirectory: !0
1751
1751
  };
1752
- const e = J(t), n = await this.getDirectoryHandle(X(t), !1), i = this.options.hashAlgorithm !== null;
1752
+ const e = K(t), n = await this.getDirectoryHandle(Y(t), !1), i = this.options.hashAlgorithm;
1753
1753
  try {
1754
1754
  const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1755
1755
  kind: "file",
@@ -1759,9 +1759,11 @@ class es {
1759
1759
  isFile: !0,
1760
1760
  isDirectory: !1
1761
1761
  };
1762
- if (i && this.options.hashAlgorithm)
1762
+ if (i === "etag")
1763
+ a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1764
+ else if (typeof i == "string")
1763
1765
  try {
1764
- const l = await Ze(o, this.options.hashAlgorithm, this.options.maxFileSize);
1766
+ const l = await Je(o, i, this.options.maxFileSize);
1765
1767
  a.hash = l;
1766
1768
  } catch (l) {
1767
1769
  console.warn(\`Failed to calculate hash for \${t}:\`, l);
@@ -1833,10 +1835,10 @@ class es {
1833
1835
  async exists(t) {
1834
1836
  if (await this.mount(), t === "/")
1835
1837
  return !0;
1836
- const e = J(t);
1838
+ const e = K(t);
1837
1839
  let n = null;
1838
1840
  try {
1839
- n = await this.getDirectoryHandle(X(t), !1);
1841
+ n = await this.getDirectoryHandle(Y(t), !1);
1840
1842
  } catch (i) {
1841
1843
  if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1842
1844
  throw i;
@@ -1884,7 +1886,7 @@ class es {
1884
1886
  const i = \`\${t === "/" ? "" : t}/\${n.name}\`;
1885
1887
  await this.remove(i, { recursive: !0 });
1886
1888
  }
1887
- await this.notifyChange({ path: t, type: "changed", isDirectory: !0 });
1889
+ await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
1888
1890
  } catch (e) {
1889
1891
  throw e instanceof p ? e : new p(\`Failed to clear directory: \${t}\`, "CLEAR_FAILED", void 0, e);
1890
1892
  }
@@ -1916,8 +1918,8 @@ class es {
1916
1918
  async remove(t, e) {
1917
1919
  if (await this.mount(), t === "/")
1918
1920
  throw new p("Cannot remove root directory", "EROOT");
1919
- const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(X(t), !1), o = await this.stat(t);
1920
- await Ke(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: "removed", isDirectory: o.isDirectory });
1921
+ const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(Y(t), !1), o = await this.stat(t);
1922
+ await Qe(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
1921
1923
  }
1922
1924
  /**
1923
1925
  * Resolve a path to an absolute path
@@ -1940,9 +1942,9 @@ class es {
1940
1942
  async realpath(t) {
1941
1943
  await this.mount();
1942
1944
  try {
1943
- const e = ut(t);
1945
+ const e = ft(t);
1944
1946
  if (!await this.exists(e))
1945
- throw new nt(e);
1947
+ throw new it(e);
1946
1948
  return e;
1947
1949
  } catch (e) {
1948
1950
  throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
@@ -1976,7 +1978,7 @@ class es {
1976
1978
  const i = n?.overwrite ?? !1, r = await this.stat(t);
1977
1979
  if (await this.exists(e) && !i)
1978
1980
  throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
1979
- await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: "added", isDirectory: r.isDirectory });
1981
+ await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: r.isDirectory });
1980
1982
  } catch (i) {
1981
1983
  throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
1982
1984
  }
@@ -2060,7 +2062,7 @@ class es {
2060
2062
  if (!this.options.broadcastChannel)
2061
2063
  throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
2062
2064
  const n = {
2063
- pattern: Ye(t, e?.recursive ?? !0),
2065
+ pattern: Ze(t, e?.recursive ?? !0),
2064
2066
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2065
2067
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2066
2068
  };
@@ -2101,9 +2103,9 @@ class es {
2101
2103
  */
2102
2104
  async open(t, e) {
2103
2105
  await this.mount();
2104
- const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = W(ut(t));
2106
+ const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = _(ft(t));
2105
2107
  try {
2106
- return n && i ? await I(o, "exclusive", async () => {
2108
+ return n && i ? await T(o, "exclusive", async () => {
2107
2109
  if (await this.exists(o))
2108
2110
  throw new p(\`File already exists: \${o}\`, "EEXIST", o);
2109
2111
  return this._openFile(o, n, r);
@@ -2123,7 +2125,7 @@ class es {
2123
2125
  } catch (a) {
2124
2126
  throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
2125
2127
  }
2126
- const r = await ts(i, t);
2128
+ const r = await es(i, t);
2127
2129
  n && (r.truncate(0), r.flush());
2128
2130
  const o = this.nextFd++;
2129
2131
  return this.openFiles.set(o, {
@@ -2149,7 +2151,7 @@ class es {
2149
2151
  */
2150
2152
  async close(t) {
2151
2153
  const e = this._getFileDescriptor(t);
2152
- dt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2154
+ pt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2153
2155
  }
2154
2156
  /**
2155
2157
  * Read data from a file descriptor
@@ -2177,15 +2179,15 @@ class es {
2177
2179
  */
2178
2180
  async read(t, e, n, i, r) {
2179
2181
  const o = this._getFileDescriptor(t);
2180
- ft(e.length, n, i, r);
2182
+ dt(e.length, n, i, r);
2181
2183
  try {
2182
- const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = Qe(a, i, l);
2184
+ const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ts(a, i, l);
2183
2185
  if (h)
2184
- return H({ bytesRead: 0, buffer: e }, [e.buffer]);
2186
+ return W({ bytesRead: 0, buffer: e }, [e.buffer]);
2185
2187
  const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2186
- return r == null && (o.position = a + u), H({ bytesRead: u, buffer: e }, [e.buffer]);
2188
+ return r == null && (o.position = a + u), W({ bytesRead: u, buffer: e }, [e.buffer]);
2187
2189
  } catch (a) {
2188
- throw R("read", t, o.path, a);
2190
+ throw L("read", t, o.path, a);
2189
2191
  }
2190
2192
  }
2191
2193
  /**
@@ -2211,12 +2213,12 @@ class es {
2211
2213
  */
2212
2214
  async write(t, e, n = 0, i, r, o = !0) {
2213
2215
  const a = this._getFileDescriptor(t), l = i ?? e.length - n;
2214
- ft(e.length, n, l, r);
2216
+ dt(e.length, n, l, r);
2215
2217
  try {
2216
2218
  const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2217
- return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: "changed", isDirectory: !1 }), f;
2219
+ return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2218
2220
  } catch (h) {
2219
- throw R("write", t, a.path, h);
2221
+ throw L("write", t, a.path, h);
2220
2222
  }
2221
2223
  }
2222
2224
  /**
@@ -2262,9 +2264,9 @@ class es {
2262
2264
  if (e < 0 || !Number.isInteger(e))
2263
2265
  throw new p("Invalid size", "EINVAL");
2264
2266
  try {
2265
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: "changed", isDirectory: !1 });
2267
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2266
2268
  } catch (i) {
2267
- throw R("truncate", t, n.path, i);
2269
+ throw L("truncate", t, n.path, i);
2268
2270
  }
2269
2271
  }
2270
2272
  /**
@@ -2286,7 +2288,7 @@ class es {
2286
2288
  try {
2287
2289
  e.syncHandle.flush();
2288
2290
  } catch (n) {
2289
- throw R("sync", t, e.path, n);
2291
+ throw L("sync", t, e.path, n);
2290
2292
  }
2291
2293
  }
2292
2294
  /**
@@ -2298,7 +2300,7 @@ class es {
2298
2300
  dispose() {
2299
2301
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2300
2302
  for (const [t, e] of this.openFiles)
2301
- dt(t, e.syncHandle, e.path);
2303
+ pt(t, e.syncHandle, e.path);
2302
2304
  this.openFiles.clear(), this.nextFd = 1;
2303
2305
  }
2304
2306
  /**
@@ -2333,22 +2335,22 @@ class es {
2333
2335
  await this.mount();
2334
2336
  try {
2335
2337
  for (const [e, n] of t) {
2336
- const i = W(e);
2338
+ const i = _(e);
2337
2339
  let r;
2338
- n instanceof Blob ? r = await Je(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
2340
+ n instanceof Blob ? r = await Ke(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
2339
2341
  }
2340
2342
  } catch (e) {
2341
2343
  throw e instanceof p ? e : new p("Failed to sync file system", "SYNC_FAILED", void 0, e);
2342
2344
  }
2343
2345
  }
2344
2346
  }
2345
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
2346
- //# sourceMappingURL=worker-BuPeqKqw.js.map
2347
- `, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
2347
+ typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && Q(new ss());
2348
+ //# sourceMappingURL=worker-Dy3EFYv_.js.map
2349
+ `, f = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", p], { type: "text/javascript;charset=utf-8" });
2348
2350
  function m(a) {
2349
2351
  let n;
2350
2352
  try {
2351
- if (n = p && (self.URL || self.webkitURL).createObjectURL(p), !n) throw "";
2353
+ if (n = f && (self.URL || self.webkitURL).createObjectURL(f), !n) throw "";
2352
2354
  const t = new Worker(n, {
2353
2355
  type: "module",
2354
2356
  name: a?.name
@@ -2358,7 +2360,7 @@ function m(a) {
2358
2360
  }), t;
2359
2361
  } catch {
2360
2362
  return new Worker(
2361
- "data:text/javascript;charset=utf-8," + encodeURIComponent(f),
2363
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(p),
2362
2364
  {
2363
2365
  type: "module",
2364
2366
  name: a?.name
@@ -2366,14 +2368,28 @@ function m(a) {
2366
2368
  );
2367
2369
  }
2368
2370
  }
2369
- function s(a) {
2371
+ function i(a) {
2370
2372
  return a instanceof URL ? a.pathname : a;
2371
2373
  }
2372
2374
  class w {
2373
2375
  #n;
2376
+ promises = this;
2374
2377
  constructor(n) {
2375
- const t = u(new m());
2376
- this.#n = t, n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
2378
+ this.#n = u(new m()), n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
2379
+ }
2380
+ /**
2381
+ * Start watching a file or directory for changes
2382
+ */
2383
+ watch(n, t) {
2384
+ const e = i(n);
2385
+ return this.#n.watch(e, t), () => this.unwatch(e);
2386
+ }
2387
+ /**
2388
+ * Stop watching a previously watched path
2389
+ */
2390
+ unwatch(n) {
2391
+ const t = i(n);
2392
+ this.#n.unwatch(t);
2377
2393
  }
2378
2394
  /**
2379
2395
  * Update configuration options
@@ -2387,110 +2403,138 @@ class w {
2387
2403
  async index() {
2388
2404
  return this.#n.index();
2389
2405
  }
2406
+ // Implementation
2390
2407
  async readFile(n, t) {
2391
- const e = s(n), r = await this.#n.readFile(e);
2392
- return t || (t = c(e) ? "binary" : "utf-8"), t === "binary" ? r : l(r, t);
2408
+ const e = i(n);
2409
+ let r;
2410
+ typeof t == "string" ? r = t : t && typeof t == "object" && (r = t.encoding);
2411
+ const s = await this.#n.readFile(e);
2412
+ return r || (r = c(e) ? "binary" : "utf-8"), r === "binary" ? s : l(s, r);
2393
2413
  }
2394
2414
  /**
2395
2415
  * Write data to a file
2396
2416
  */
2397
2417
  async writeFile(n, t, e) {
2398
- const r = s(n);
2399
- e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
2400
- const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2401
- return this.#n.writeFile(r, i);
2418
+ const r = i(n);
2419
+ let s;
2420
+ typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" || c(r) ? "binary" : "utf-8");
2421
+ const o = typeof t == "string" ? h(t, s) : t instanceof Uint8Array ? t : new Uint8Array(t);
2422
+ return this.#n.writeFile(r, o);
2402
2423
  }
2403
2424
  /**
2404
2425
  * Append data to a file
2405
2426
  */
2406
2427
  async appendFile(n, t, e) {
2407
- const r = s(n);
2428
+ const r = i(n);
2408
2429
  e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
2409
- const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2410
- return this.#n.appendFile(r, i);
2430
+ const s = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2431
+ return this.#n.appendFile(r, s);
2411
2432
  }
2412
2433
  /**
2413
2434
  * Create a directory
2414
2435
  */
2415
2436
  async mkdir(n, t) {
2416
- const e = s(n);
2417
- return this.#n.mkdir(e, t);
2437
+ const e = i(n);
2438
+ let r;
2439
+ return typeof t == "number" ? r = { recursive: !1 } : r = t, this.#n.mkdir(e, r);
2418
2440
  }
2419
2441
  /**
2420
2442
  * Get file or directory statistics
2421
2443
  */
2422
2444
  async stat(n) {
2423
- const t = s(n);
2445
+ const t = i(n);
2424
2446
  return this.#n.stat(t);
2425
2447
  }
2426
2448
  /**
2427
2449
  * Read a directory's contents
2428
2450
  */
2429
2451
  async readDir(n) {
2430
- const t = s(n);
2452
+ const t = i(n);
2431
2453
  return this.#n.readDir(t);
2432
2454
  }
2433
2455
  /**
2434
2456
  * Check if a file or directory exists
2435
2457
  */
2436
2458
  async exists(n) {
2437
- const t = s(n);
2459
+ const t = i(n);
2438
2460
  return this.#n.exists(t);
2439
2461
  }
2440
2462
  /**
2441
2463
  * Clear all contents of a directory without removing the directory itself
2442
2464
  */
2443
2465
  async clear(n) {
2444
- const t = n ? s(n) : void 0;
2466
+ const t = n ? i(n) : void 0;
2445
2467
  return this.#n.clear(t);
2446
2468
  }
2447
2469
  /**
2448
2470
  * Remove files and directories
2449
2471
  */
2450
2472
  async remove(n, t) {
2451
- const e = s(n);
2473
+ const e = i(n);
2452
2474
  return this.#n.remove(e, t);
2453
2475
  }
2476
+ /**
2477
+ * Alias for remove() for NodeJS like API compatibility
2478
+ */
2479
+ async unlink(n) {
2480
+ return this.remove(n);
2481
+ }
2482
+ /**
2483
+ * Alias for remove() for NodeJS like API compatibility
2484
+ */
2485
+ async rm(n, t) {
2486
+ return this.remove(n, t);
2487
+ }
2488
+ /**
2489
+ * Alias for remove() for NodeJS like API compatibility
2490
+ */
2491
+ async rmdir(n) {
2492
+ return this.remove(n);
2493
+ }
2494
+ /**
2495
+ * Alias for readDir() for NodeJS like API compatibility
2496
+ */
2497
+ async readdir(n, t) {
2498
+ return this.readDir(n);
2499
+ }
2500
+ /**
2501
+ * Alias for stat() for NodeJS like API compatibility
2502
+ */
2503
+ async lstat(n) {
2504
+ return this.stat(n);
2505
+ }
2506
+ /**
2507
+ * Note: OPFS doesn't support file modes, so this is a no-op and exists only for compatibility with tools like isomorphic-git
2508
+ */
2509
+ async chmod(n, t) {
2510
+ return Promise.resolve();
2511
+ }
2454
2512
  /**
2455
2513
  * Resolve a path to an absolute path
2456
2514
  */
2457
2515
  async realpath(n) {
2458
- const t = s(n);
2516
+ const t = i(n);
2459
2517
  return this.#n.realpath(t);
2460
2518
  }
2461
2519
  /**
2462
2520
  * Rename a file or directory
2463
2521
  */
2464
2522
  async rename(n, t, e) {
2465
- const r = s(n), i = s(t);
2466
- return this.#n.rename(r, i, e);
2523
+ const r = i(n), s = i(t);
2524
+ return this.#n.rename(r, s, e);
2467
2525
  }
2468
2526
  /**
2469
2527
  * Copy files and directories
2470
2528
  */
2471
2529
  async copy(n, t, e) {
2472
- const r = s(n), i = s(t);
2473
- return this.#n.copy(r, i, e);
2474
- }
2475
- /**
2476
- * Start watching a file or directory for changes
2477
- */
2478
- watch(n, t) {
2479
- const e = s(n);
2480
- return this.#n.watch(e, t), () => this.unwatch(e);
2481
- }
2482
- /**
2483
- * Stop watching a previously watched path
2484
- */
2485
- unwatch(n) {
2486
- const t = s(n);
2487
- this.#n.unwatch(t);
2530
+ const r = i(n), s = i(t);
2531
+ return this.#n.copy(r, s, e);
2488
2532
  }
2489
2533
  /**
2490
2534
  * Open a file and return a file descriptor
2491
2535
  */
2492
2536
  async open(n, t) {
2493
- const e = s(n);
2537
+ const e = i(n);
2494
2538
  return this.#n.open(e, t);
2495
2539
  }
2496
2540
  /**
@@ -2506,22 +2550,22 @@ class w {
2506
2550
  * The buffer is transferred to the worker and back, so the original buffer
2507
2551
  * becomes unusable after the call.
2508
2552
  */
2509
- async read(n, t, e, r, i) {
2553
+ async read(n, t, e, r, s) {
2510
2554
  const { bytesRead: o, buffer: d } = await this.#n.read(
2511
2555
  n,
2512
2556
  // Temp buffer to preserve the original buffer
2513
2557
  new Uint8Array(r),
2514
2558
  0,
2515
2559
  r,
2516
- i
2560
+ s
2517
2561
  );
2518
2562
  return o > 0 && t.set(d.subarray(0, o), e), { bytesRead: o, buffer: t };
2519
2563
  }
2520
2564
  /**
2521
2565
  * Write data to a file descriptor
2522
2566
  */
2523
- async write(n, t, e, r, i, o) {
2524
- return this.#n.write(n, t, e, r, i, o);
2567
+ async write(n, t, e, r, s, o) {
2568
+ return this.#n.write(n, t, e, r, s, o);
2525
2569
  }
2526
2570
  /**
2527
2571
  * Get file status information by file descriptor
@@ -2551,29 +2595,29 @@ class w {
2551
2595
  * Synchronize the file system with external data
2552
2596
  */
2553
2597
  async createIndex(n) {
2554
- const t = n.map(([e, r]) => [s(e), r]);
2598
+ const t = n.map(([e, r]) => [i(e), r]);
2555
2599
  return this.#n.createIndex(t);
2556
2600
  }
2557
2601
  /**
2558
2602
  * Read a file as text with automatic encoding detection
2559
2603
  */
2560
2604
  async readText(n, t = "utf-8") {
2561
- const e = s(n), r = await this.#n.readFile(e);
2605
+ const e = i(n), r = await this.#n.readFile(e);
2562
2606
  return l(r, t);
2563
2607
  }
2564
2608
  /**
2565
2609
  * Write text to a file with specified encoding
2566
2610
  */
2567
2611
  async writeText(n, t, e = "utf-8") {
2568
- const r = s(n), i = h(t, e);
2569
- return this.#n.writeFile(r, i);
2612
+ const r = i(n), s = h(t, e);
2613
+ return this.#n.writeFile(r, s);
2570
2614
  }
2571
2615
  /**
2572
2616
  * Append text to a file with specified encoding
2573
2617
  */
2574
2618
  async appendText(n, t, e = "utf-8") {
2575
- const r = s(n), i = h(t, e);
2576
- return this.#n.appendFile(r, i);
2619
+ const r = i(n), s = h(t, e);
2620
+ return this.#n.appendFile(r, s);
2577
2621
  }
2578
2622
  }
2579
2623
  function b(a) {
@@ -2591,32 +2635,33 @@ export {
2591
2635
  I as PermissionError,
2592
2636
  R as StorageError,
2593
2637
  $ as TimeoutError,
2594
- _ as basename,
2595
- C as buffersEqual,
2596
- N as calculateFileHash,
2597
- D as calculateReadLength,
2598
- z as checkOPFSSupport,
2599
- k as convertBlobToUint8Array,
2600
- M as createBuffer,
2638
+ _ as WatchEventType,
2639
+ C as basename,
2640
+ N as buffersEqual,
2641
+ D as calculateFileHash,
2642
+ z as calculateReadLength,
2643
+ k as checkOPFSSupport,
2644
+ M as convertBlobToUint8Array,
2645
+ j as createBuffer,
2601
2646
  L as createFDError,
2602
- j as createSyncHandleSafe,
2647
+ W as createSyncHandleSafe,
2603
2648
  b as createWorker,
2604
2649
  l as decodeBuffer,
2605
- W as dirname,
2650
+ U as dirname,
2606
2651
  h as encodeString,
2607
- U as extname,
2652
+ H as extname,
2608
2653
  c as isBinaryFileExtension,
2609
- H as isPathExcluded,
2610
- B as joinPath,
2611
- G as mapDomError,
2612
- q as matchMinimatch,
2654
+ B as isPathExcluded,
2655
+ G as joinPath,
2656
+ q as mapDomError,
2657
+ Y as matchMinimatch,
2613
2658
  V as normalizeMinimatch,
2614
- Y as normalizePath,
2615
- X as removeEntry,
2616
- Z as resolvePath,
2617
- J as safeCloseSyncHandle,
2618
- K as splitPath,
2619
- Q as validateReadWriteArgs,
2620
- nn as withLock
2659
+ X as normalizePath,
2660
+ Z as removeEntry,
2661
+ J as resolvePath,
2662
+ K as safeCloseSyncHandle,
2663
+ Q as splitPath,
2664
+ nn as validateReadWriteArgs,
2665
+ tn as withLock
2621
2666
  };
2622
2667
  //# sourceMappingURL=index.js.map