opfs-worker 2.1.0 → 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 (111) hide show
  1. package/README.md +51 -37
  2. package/dist/BaseOPFS-Bu7FZtCb.cjs +2 -0
  3. package/dist/BaseOPFS-Bu7FZtCb.cjs.map +1 -0
  4. package/dist/{BaseOPFS-Cylz6ijk.js → BaseOPFS-C3NE4BKr.js} +804 -484
  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-BKSAJJeh.js → OPFSAsync-aeLUdIqd.js} +19 -19
  9. package/dist/OPFSAsync-aeLUdIqd.js.map +1 -0
  10. package/dist/OPFSFacade-BJv2yuWU.cjs +2 -0
  11. package/dist/OPFSFacade-BJv2yuWU.cjs.map +1 -0
  12. package/dist/OPFSFacade-DiogtQoq.js +308 -0
  13. package/dist/OPFSFacade-DiogtQoq.js.map +1 -0
  14. package/dist/OPFSSync-3qlSBYmz.cjs +2 -0
  15. package/dist/OPFSSync-3qlSBYmz.cjs.map +1 -0
  16. package/dist/{OPFSSync-CsSQkpk5.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 +60 -9
  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-Y4Mg6qte.js.map → createOPFSAsync-B611B63X.js.map} +1 -1
  25. package/dist/createOPFSAsync-BATjJg8k.cjs +2 -0
  26. package/dist/{createOPFSAsync-BwKDmHsy.cjs.map → createOPFSAsync-BATjJg8k.cjs.map} +1 -1
  27. package/dist/createOPFSDedicated-DgudPTB8.js +2676 -0
  28. package/dist/createOPFSDedicated-DgudPTB8.js.map +1 -0
  29. package/dist/createOPFSDedicated-EmIwluQo.cjs +2597 -0
  30. package/dist/createOPFSDedicated-EmIwluQo.cjs.map +1 -0
  31. package/dist/{createOPFSShared-CGdd__PH.js → createOPFSShared-BWYln8jJ.js} +2 -2
  32. package/dist/{createOPFSShared-CGdd__PH.js.map → createOPFSShared-BWYln8jJ.js.map} +1 -1
  33. package/dist/{createOPFSShared-CskROt7U.cjs → createOPFSShared-DPJpCd7z.cjs} +2 -2
  34. package/dist/{createOPFSShared-CskROt7U.cjs.map → createOPFSShared-DPJpCd7z.cjs.map} +1 -1
  35. package/dist/dedicated.worker.js +1104 -790
  36. package/dist/dedicated.worker.js.map +1 -1
  37. package/dist/facade/OPFSFacade.d.ts +21 -3
  38. package/dist/facade/OPFSFacade.d.ts.map +1 -1
  39. package/dist/facade/createOPFSDedicated.d.ts +4 -2
  40. package/dist/facade/createOPFSDedicated.d.ts.map +1 -1
  41. package/dist/index.async.cjs +1 -1
  42. package/dist/index.async.js +33 -32
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.ts +1 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +44 -43
  47. package/dist/index.pure.cjs +1 -1
  48. package/dist/index.pure.js +38 -37
  49. package/dist/index.sharedworker.cjs +1 -1
  50. package/dist/index.sharedworker.js +34 -33
  51. package/dist/index.sync.cjs +1 -1
  52. package/dist/index.sync.d.ts +2 -0
  53. package/dist/index.sync.d.ts.map +1 -1
  54. package/dist/index.sync.js +34 -32
  55. package/dist/shared.worker.js +1101 -791
  56. package/dist/shared.worker.js.map +1 -1
  57. package/dist/types.d.ts +38 -5
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/utils/helpers.d.ts +13 -3
  60. package/dist/utils/helpers.d.ts.map +1 -1
  61. package/dist/worker/createDedicatedWorker.d.ts +8 -3
  62. package/dist/worker/createDedicatedWorker.d.ts.map +1 -1
  63. package/docs/README.md +13 -25
  64. package/docs/api/README.md +221 -0
  65. package/docs/api/file-descriptors.md +137 -0
  66. package/docs/guides/async.md +4 -4
  67. package/docs/guides/dedicated.md +10 -8
  68. package/docs/guides/hashing.md +3 -3
  69. package/docs/guides/pure.md +4 -4
  70. package/docs/guides/sharedworker.md +2 -2
  71. package/docs/guides/streaming.md +146 -12
  72. package/docs/guides/watching.md +3 -3
  73. package/docs/migration.md +10 -11
  74. package/docs/types.md +93 -155
  75. package/package.json +20 -9
  76. package/src/core/BaseOPFS.ts +194 -29
  77. package/src/core/OPFSAsync.ts +4 -5
  78. package/src/core/OPFSSync.ts +6 -7
  79. package/src/facade/OPFSFacade.ts +51 -4
  80. package/src/facade/createOPFSDedicated.ts +4 -2
  81. package/src/index.sync.ts +2 -0
  82. package/src/index.ts +1 -5
  83. package/src/types.ts +42 -3
  84. package/src/utils/helpers.ts +32 -6
  85. package/src/worker/createDedicatedWorker.ts +85 -7
  86. package/src/worker/dedicated.worker.ts +12 -1
  87. package/dist/BaseOPFS-BPw9AIQ-.cjs +0 -4
  88. package/dist/BaseOPFS-BPw9AIQ-.cjs.map +0 -1
  89. package/dist/BaseOPFS-Cylz6ijk.js.map +0 -1
  90. package/dist/OPFSAsync-BKSAJJeh.js.map +0 -1
  91. package/dist/OPFSAsync-s2P7y3sw.cjs +0 -2
  92. package/dist/OPFSAsync-s2P7y3sw.cjs.map +0 -1
  93. package/dist/OPFSFacade-DePnNRgt.cjs +0 -2
  94. package/dist/OPFSFacade-DePnNRgt.cjs.map +0 -1
  95. package/dist/OPFSFacade-XohWlHuu.js +0 -281
  96. package/dist/OPFSFacade-XohWlHuu.js.map +0 -1
  97. package/dist/OPFSSync-C7KBepe_.cjs +0 -2
  98. package/dist/OPFSSync-C7KBepe_.cjs.map +0 -1
  99. package/dist/OPFSSync-CsSQkpk5.js.map +0 -1
  100. package/dist/assets/dedicated.worker-nY3tK4zi.js.map +0 -1
  101. package/dist/createOPFSAsync-BwKDmHsy.cjs +0 -2
  102. package/dist/createOPFSAsync-Y4Mg6qte.js +0 -10
  103. package/dist/createOPFSDedicated-CsnV6MLP.js +0 -2333
  104. package/dist/createOPFSDedicated-CsnV6MLP.js.map +0 -1
  105. package/dist/createOPFSDedicated-pKTRWLdz.cjs +0 -2283
  106. package/dist/createOPFSDedicated-pKTRWLdz.cjs.map +0 -1
  107. package/docs/api/backend.md +0 -36
  108. package/docs/api/create.md +0 -82
  109. package/docs/api/facade.md +0 -52
  110. package/docs/choosing-a-mode.md +0 -41
  111. package/docs/file-descriptors.md +0 -695
@@ -1,5 +1,5 @@
1
1
  var N = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(N || {});
2
- const mt = {
2
+ const bt = {
3
3
  ENOENT: -2,
4
4
  // No such file or directory
5
5
  EISDIR: -21,
@@ -36,20 +36,20 @@ class m extends Error {
36
36
  syscall;
37
37
  path;
38
38
  constructor(t, e, n, r, i) {
39
- super(t, { cause: i }), this.name = e, this.errno = mt[e] || -1, this.path = n, this.syscall = r;
39
+ super(t, { cause: i }), this.name = e, this.errno = bt[e] || -1, this.path = n, this.syscall = r;
40
40
  }
41
41
  }
42
- class wt extends m {
42
+ class xt extends m {
43
43
  constructor(t) {
44
44
  super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
45
45
  }
46
46
  }
47
- class yt extends m {
47
+ class At extends m {
48
48
  constructor(t, e, n) {
49
49
  super(t, "INVALID_PATH", e, "access", n);
50
50
  }
51
51
  }
52
- class k extends m {
52
+ class P extends m {
53
53
  constructor(t, e, n) {
54
54
  const r = {
55
55
  file: `File not found: ${e}`,
@@ -59,28 +59,28 @@ class k extends m {
59
59
  super(r[t], "ENOENT", e, "access", n);
60
60
  }
61
61
  }
62
- class Et extends m {
62
+ class vt extends m {
63
63
  constructor(t, e, n) {
64
64
  super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e, n);
65
65
  }
66
66
  }
67
- class St extends m {
67
+ class Ot extends m {
68
68
  constructor(t, e, n) {
69
69
  super(t, "ENOSPC", e, "write", n);
70
70
  }
71
71
  }
72
- class xt extends m {
72
+ class $t extends m {
73
73
  constructor(t, e) {
74
74
  super(`File is busy: ${t}`, "EBUSY", t, "open", e);
75
75
  }
76
76
  }
77
- class q extends m {
77
+ class U extends m {
78
78
  constructor(t, e, n) {
79
79
  const r = t === "directory" ? `Is a directory: ${e}` : `Not a directory: ${e}`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
80
80
  super(r, i, e, "access", n);
81
81
  }
82
82
  }
83
- class D extends m {
83
+ class $ extends m {
84
84
  constructor(t, e, n, r) {
85
85
  const i = {
86
86
  argument: "EINVAL",
@@ -91,7 +91,7 @@ class D extends m {
91
91
  super(e, i[t], n, "validate", r);
92
92
  }
93
93
  }
94
- class vt extends m {
94
+ class Nt extends m {
95
95
  constructor(t, e) {
96
96
  super(`Operation aborted: ${t}`, "EINTR", t, "interrupt", e);
97
97
  }
@@ -101,12 +101,12 @@ class J extends m {
101
101
  super(t, "EIO", e, "io", n);
102
102
  }
103
103
  }
104
- class it extends m {
104
+ class ct extends m {
105
105
  constructor(t, e) {
106
106
  super(`Operation not supported: ${t}`, "ENOTSUP", t, "operation", e);
107
107
  }
108
108
  }
109
- class G extends m {
109
+ class H extends m {
110
110
  constructor(t, e, n) {
111
111
  const r = {
112
112
  RM_FAILED: `Failed to remove entry: ${e}`,
@@ -116,53 +116,53 @@ class G extends m {
116
116
  super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink", n);
117
117
  }
118
118
  }
119
- class bt extends m {
119
+ class Dt extends m {
120
120
  constructor(t, e) {
121
121
  super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
122
122
  }
123
123
  }
124
- class U extends m {
124
+ class j extends m {
125
125
  constructor(t, e, n) {
126
126
  super(`Failed to ${t}: ${e}`, `${t.toUpperCase()}_FAILED`, e, t, n);
127
127
  }
128
128
  }
129
- class X extends m {
129
+ class Q extends m {
130
130
  constructor(t, e) {
131
131
  super(`Destination already exists: ${t}`, "EEXIST", t, "open", e);
132
132
  }
133
133
  }
134
- function We(s, t, e, n) {
134
+ function Ke(s, t, e, n) {
135
135
  const r = `${s.toUpperCase()}_FAILED`;
136
136
  return new m(`Failed to ${s} file descriptor: ${t}`, r, e, s, n);
137
137
  }
138
- function O(s, t) {
138
+ function v(s, t) {
139
139
  const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
140
140
  switch (s.name) {
141
141
  case "InvalidStateError":
142
- return new xt(e || "unknown", s);
142
+ return new $t(e || "unknown", s);
143
143
  case "QuotaExceededError":
144
- return new St(`No space left on device: ${e || "unknown"}`, e, s);
144
+ return new Ot(`No space left on device: ${e || "unknown"}`, e, s);
145
145
  case "NotFoundError":
146
- return new k(r, e, s);
146
+ return new P(r, e, s);
147
147
  case "TypeMismatchError":
148
- return n !== void 0 ? n ? new q("directory", e || "unknown", s) : new q("file", e || "unknown", s) : new D("argument", `Type mismatch: ${e || "unknown"}`, e, s);
148
+ return n !== void 0 ? n ? new U("directory", e || "unknown", s) : new U("file", e || "unknown", s) : new $("argument", `Type mismatch: ${e || "unknown"}`, e, s);
149
149
  case "NotAllowedError":
150
150
  case "SecurityError":
151
- return new Et(e, "unknown", s);
151
+ return new vt(e, "unknown", s);
152
152
  case "InvalidModificationError":
153
- return i === "remove" ? new G("ENOTEMPTY", e, s) : new D("argument", `Invalid modification: ${e || "unknown"}`, e, s);
153
+ return i === "remove" ? new H("ENOTEMPTY", e, s) : new $("argument", `Invalid modification: ${e || "unknown"}`, e, s);
154
154
  case "AbortError":
155
- return new vt(e || "unknown", s);
155
+ return new Nt(e || "unknown", s);
156
156
  case "OperationError":
157
157
  return new J(`Operation failed: ${e || "unknown"}`, e, s);
158
158
  case "TypeError":
159
- return new it(e || "unknown", s);
159
+ return new ct(e || "unknown", s);
160
160
  default:
161
- return i === "remove" ? new G("RM_FAILED", e, s) : new J(`I/O error: ${e || "unknown"}`, e, s);
161
+ return i === "remove" ? new H("RM_FAILED", e, s) : new J(`I/O error: ${e || "unknown"}`, e, s);
162
162
  }
163
163
  }
164
- const ot = (s, t, e) => {
165
- const n = s instanceof RegExp ? K(s, e) : s, r = t instanceof RegExp ? K(t, e) : t, i = n !== null && r != null && Ot(n, r, e);
164
+ const lt = (s, t, e) => {
165
+ const n = s instanceof RegExp ? K(s, e) : s, r = t instanceof RegExp ? K(t, e) : t, i = n !== null && r != null && Tt(n, r, e);
166
166
  return i && {
167
167
  start: i[0],
168
168
  end: i[1],
@@ -173,118 +173,151 @@ const ot = (s, t, e) => {
173
173
  }, K = (s, t) => {
174
174
  const e = t.match(s);
175
175
  return e ? e[0] : null;
176
- }, Ot = (s, t, e) => {
177
- let n, r, i, o, a, c = e.indexOf(s), l = e.indexOf(t, c + 1), h = c;
176
+ }, Tt = (s, t, e) => {
177
+ let n, r, i, o, a, c = e.indexOf(s), l = e.indexOf(t, c + 1), u = c;
178
178
  if (c >= 0 && l > 0) {
179
179
  if (s === t)
180
180
  return [c, l];
181
- for (n = [], i = e.length; h >= 0 && !a; ) {
182
- if (h === c)
183
- n.push(h), c = e.indexOf(s, h + 1);
181
+ for (n = [], i = e.length; u >= 0 && !a; ) {
182
+ if (u === c)
183
+ n.push(u), c = e.indexOf(s, u + 1);
184
184
  else if (n.length === 1) {
185
- const d = n.pop();
186
- d !== void 0 && (a = [d, l]);
185
+ const h = n.pop();
186
+ h !== void 0 && (a = [h, l]);
187
187
  } else
188
- r = n.pop(), r !== void 0 && r < i && (i = r, o = l), l = e.indexOf(t, h + 1);
189
- h = c < l && c >= 0 ? c : l;
188
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = l), l = e.indexOf(t, u + 1);
189
+ u = c < l && c >= 0 ? c : l;
190
190
  }
191
191
  n.length && o !== void 0 && (a = [i, o]);
192
192
  }
193
193
  return a;
194
- }, at = "\0SLASH" + Math.random() + "\0", ct = "\0OPEN" + Math.random() + "\0", V = "\0CLOSE" + Math.random() + "\0", ht = "\0COMMA" + Math.random() + "\0", lt = "\0PERIOD" + Math.random() + "\0", At = new RegExp(at, "g"), Dt = new RegExp(ct, "g"), Nt = new RegExp(V, "g"), $t = new RegExp(ht, "g"), Ct = new RegExp(lt, "g"), Tt = /\\\\/g, Mt = /\\{/g, Ft = /\\}/g, It = /\\,/g, Pt = /\\./g;
195
- function B(s) {
194
+ }, ht = "\0SLASH" + Math.random() + "\0", ut = "\0OPEN" + Math.random() + "\0", X = "\0CLOSE" + Math.random() + "\0", ft = "\0COMMA" + Math.random() + "\0", pt = "\0PERIOD" + Math.random() + "\0", Ct = new RegExp(ht, "g"), Mt = new RegExp(ut, "g"), Ft = new RegExp(X, "g"), Rt = new RegExp(ft, "g"), Pt = new RegExp(pt, "g"), kt = /\\\\/g, It = /\\{/g, Lt = /\\}/g, zt = /\\,/g, jt = /\\\./g, Wt = 1e5, _t = 4e6;
195
+ function W(s) {
196
196
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
197
197
  }
198
- function Rt(s) {
199
- return s.replace(Tt, at).replace(Mt, ct).replace(Ft, V).replace(It, ht).replace(Pt, lt);
198
+ function Bt(s) {
199
+ return s.replace(kt, ht).replace(It, ut).replace(Lt, X).replace(zt, ft).replace(jt, pt);
200
200
  }
201
- function kt(s) {
202
- return s.replace(At, "\\").replace(Dt, "{").replace(Nt, "}").replace($t, ",").replace(Ct, ".");
201
+ function Ut(s) {
202
+ return s.replace(Ct, "\\").replace(Mt, "{").replace(Ft, "}").replace(Rt, ",").replace(Pt, ".");
203
203
  }
204
- function ut(s) {
204
+ function dt(s) {
205
205
  if (!s)
206
206
  return [""];
207
- const t = [], e = ot("{", "}", s);
207
+ const t = [], e = lt("{", "}", s);
208
208
  if (!e)
209
209
  return s.split(",");
210
210
  const { pre: n, body: r, post: i } = e, o = n.split(",");
211
211
  o[o.length - 1] += "{" + r + "}";
212
- const a = ut(i);
212
+ const a = dt(i);
213
213
  return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
214
214
  }
215
- function Lt(s) {
216
- return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), F(Rt(s), !0).map(kt)) : [];
215
+ function Ht(s, t = {}) {
216
+ if (!s)
217
+ return [];
218
+ const { max: e = Wt, maxLength: n = _t } = t;
219
+ return s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), G(Bt(s), e, n, !0).map(Ut);
217
220
  }
218
- function zt(s) {
221
+ function Gt(s) {
219
222
  return "{" + s + "}";
220
223
  }
221
- function jt(s) {
224
+ function qt(s) {
222
225
  return /^-?0\d/.test(s);
223
226
  }
224
- function Wt(s, t) {
227
+ function Xt(s, t) {
225
228
  return s <= t;
226
229
  }
227
- function Ut(s, t) {
230
+ function Vt(s, t) {
228
231
  return s >= t;
229
232
  }
230
- function F(s, t) {
231
- const e = [], n = ot("{", "}", s);
232
- if (!n)
233
- return [s];
234
- const r = n.pre, i = n.post.length ? F(n.post, !1) : [""];
235
- if (/\$$/.test(n.pre))
236
- for (let o = 0; o < i.length; o++) {
237
- const a = r + "{" + n.body + "}" + i[o];
238
- e.push(a);
233
+ function C(s, t, e, n, r, i) {
234
+ const o = [];
235
+ let a = 0;
236
+ for (let c = 0; c < s.length; c++)
237
+ for (let l = 0; l < e.length; l++) {
238
+ if (o.length >= n)
239
+ return o;
240
+ const u = s[c] + t + e[l];
241
+ if (!(i && !u)) {
242
+ if (a + u.length > r)
243
+ return o;
244
+ o.push(u), a += u.length;
245
+ }
239
246
  }
240
- else {
241
- const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), c = o || a, l = n.body.indexOf(",") >= 0;
242
- if (!c && !l)
243
- return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + V + n.post, F(s)) : [s];
244
- let h;
245
- if (c)
246
- h = n.body.split(/\.\./);
247
- else if (h = ut(n.body), h.length === 1 && h[0] !== void 0 && (h = F(h[0], !1).map(zt), h.length === 1))
248
- return i.map((u) => n.pre + h[0] + u);
247
+ return o;
248
+ }
249
+ function Yt(s, t, e) {
250
+ const n = s.split(/\.\./), r = [];
251
+ if (n[0] === void 0 || n[1] === void 0)
252
+ return r;
253
+ const i = W(n[0]), o = W(n[1]), a = Math.max(n[0].length, n[1].length);
254
+ let c = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(W(n[2])), 1) : 1, l = Xt;
255
+ o < i && (c *= -1, l = Vt);
256
+ const h = n.some(qt);
257
+ for (let f = i; l(f, o) && r.length < e; f += c) {
249
258
  let d;
250
- if (c && h[0] !== void 0 && h[1] !== void 0) {
251
- const u = B(h[0]), f = B(h[1]), g = Math.max(h[0].length, h[1].length);
252
- let p = h.length === 3 && h[2] !== void 0 ? Math.abs(B(h[2])) : 1, S = Wt;
253
- f < u && (p *= -1, S = Ut);
254
- const C = h.some(jt);
255
- d = [];
256
- for (let x = u; S(x, f); x += p) {
257
- let w;
258
- if (a)
259
- w = String.fromCharCode(x), w === "\\" && (w = "");
260
- else if (w = String(x), C) {
261
- const T = g - w.length;
262
- if (T > 0) {
263
- const P = new Array(T + 1).join("0");
264
- x < 0 ? w = "-" + P + w.slice(1) : w = P + w;
265
- }
266
- }
267
- d.push(w);
259
+ if (t)
260
+ d = String.fromCharCode(f), d === "\\" && (d = "");
261
+ else if (d = String(f), h) {
262
+ const g = a - d.length;
263
+ if (g > 0) {
264
+ const p = new Array(g + 1).join("0");
265
+ f < 0 ? d = "-" + p + d.slice(1) : d = p + d;
268
266
  }
269
- } else {
270
- d = [];
271
- for (let u = 0; u < h.length; u++)
272
- d.push.apply(d, F(h[u], !1));
273
267
  }
274
- for (let u = 0; u < d.length; u++)
275
- for (let f = 0; f < i.length; f++) {
276
- const g = r + d[u] + i[f];
277
- (!t || c || g) && e.push(g);
268
+ r.push(d);
269
+ }
270
+ return r;
271
+ }
272
+ function G(s, t, e, n) {
273
+ let r = [""], i = !1, o = !0;
274
+ for (; ; ) {
275
+ const a = lt("{", "}", s);
276
+ if (!a)
277
+ return C(r, s, [""], t, e, i);
278
+ const c = a.pre;
279
+ if (/\$$/.test(c)) {
280
+ if (r = C(r, c + "{" + a.body + "}", [""], t, e, i && !a.post.length), o = !1, !a.post.length)
281
+ break;
282
+ s = a.post;
283
+ continue;
284
+ }
285
+ const l = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body), u = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body), h = l || u, f = a.body.indexOf(",") >= 0;
286
+ if (!h && !f) {
287
+ if (a.post.match(/,(?!,).*\}/)) {
288
+ s = a.pre + "{" + a.body + X + a.post, n = !0;
289
+ continue;
290
+ }
291
+ return C(r, c + "{" + a.body + "}" + a.post, [""], t, e, i);
292
+ }
293
+ o && (i = n && !h, o = !1);
294
+ let d;
295
+ if (h)
296
+ d = Yt(a.body, u, t);
297
+ else {
298
+ let g = dt(a.body);
299
+ if (g.length === 1 && g[0] !== void 0 && (g = G(g[0], t, e, !1).map(Gt), g.length === 1)) {
300
+ if (r = C(r, c + g[0], [""], t, e, i && !a.post.length), !a.post.length)
301
+ break;
302
+ s = a.post;
303
+ continue;
278
304
  }
305
+ d = [];
306
+ for (let p = 0; p < g.length; p++)
307
+ d.push.apply(d, G(g[p], t, e, !1));
308
+ }
309
+ if (r = C(r, c, d, t, e, i && !a.post.length), !a.post.length)
310
+ break;
311
+ s = a.post;
279
312
  }
280
- return e;
313
+ return r;
281
314
  }
282
- const Bt = 1024 * 64, L = (s) => {
315
+ const Zt = 1024 * 64, k = (s) => {
283
316
  if (typeof s != "string")
284
317
  throw new TypeError("invalid pattern");
285
- if (s.length > Bt)
318
+ if (s.length > Zt)
286
319
  throw new TypeError("pattern is too long");
287
- }, Ht = {
320
+ }, Jt = {
288
321
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
289
322
  "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
290
323
  "[:ascii:]": ["\\x00-\\x7f", !1],
@@ -299,12 +332,12 @@ const Bt = 1024 * 64, L = (s) => {
299
332
  "[:upper:]": ["\\p{Lu}", !0],
300
333
  "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
301
334
  "[:xdigit:]": ["A-Fa-f0-9", !1]
302
- }, M = (s) => s.replace(/[[\]\\-]/g, "\\$&"), _t = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Q = (s) => s.join(""), qt = (s, t) => {
335
+ }, M = (s) => s.replace(/[[\]\\-]/g, "\\$&"), Qt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), tt = (s) => s.join(""), Kt = (s, t) => {
303
336
  const e = t;
304
337
  if (s.charAt(e) !== "[")
305
338
  throw new Error("not in a brace expression");
306
339
  const n = [], r = [];
307
- let i = e + 1, o = !1, a = !1, c = !1, l = !1, h = e, d = "";
340
+ let i = e + 1, o = !1, a = !1, c = !1, l = !1, u = e, h = "";
308
341
  t: for (; i < s.length; ) {
309
342
  const p = s.charAt(i);
310
343
  if ((p === "!" || p === "^") && i === e + 1) {
@@ -312,7 +345,7 @@ const Bt = 1024 * 64, L = (s) => {
312
345
  continue;
313
346
  }
314
347
  if (p === "]" && o && !c) {
315
- h = i + 1;
348
+ u = i + 1;
316
349
  break;
317
350
  }
318
351
  if (o = !0, p === "\\" && !c) {
@@ -320,16 +353,16 @@ const Bt = 1024 * 64, L = (s) => {
320
353
  continue;
321
354
  }
322
355
  if (p === "[" && !c) {
323
- for (const [S, [A, C, x]] of Object.entries(Ht))
324
- if (s.startsWith(S, i)) {
325
- if (d)
356
+ for (const [E, [w, y, O]] of Object.entries(Jt))
357
+ if (s.startsWith(E, i)) {
358
+ if (h)
326
359
  return ["$.", !1, s.length - e, !0];
327
- i += S.length, x ? r.push(A) : n.push(A), a = a || C;
360
+ i += E.length, O ? r.push(w) : n.push(w), a = a || y;
328
361
  continue t;
329
362
  }
330
363
  }
331
- if (c = !1, d) {
332
- p > d ? n.push(M(d) + "-" + M(p)) : p === d && n.push(M(p)), d = "", i++;
364
+ if (c = !1, h) {
365
+ p > h ? n.push(M(h) + "-" + M(p)) : p === h && n.push(M(p)), h = "", i++;
333
366
  continue;
334
367
  }
335
368
  if (s.startsWith("-]", i + 1)) {
@@ -337,39 +370,100 @@ const Bt = 1024 * 64, L = (s) => {
337
370
  continue;
338
371
  }
339
372
  if (s.startsWith("-", i + 1)) {
340
- d = p, i += 2;
373
+ h = p, i += 2;
341
374
  continue;
342
375
  }
343
376
  n.push(M(p)), i++;
344
377
  }
345
- if (h < i)
378
+ if (u < i)
346
379
  return ["", !1, 0, !1];
347
380
  if (!n.length && !r.length)
348
381
  return ["$.", !1, s.length - e, !0];
349
382
  if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !l) {
350
383
  const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
351
- return [_t(p), !1, h - e, !1];
352
- }
353
- const u = "[" + (l ? "^" : "") + Q(n) + "]", f = "[" + (l ? "" : "^") + Q(r) + "]";
354
- return [n.length && r.length ? "(" + u + "|" + f + ")" : n.length ? u : f, a, h - e, !0];
355
- }, I = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), Gt = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), tt = (s) => Gt.has(s), Vt = "(?!(?:^|/)\\.\\.?(?:$|/))", R = "(?!\\.)", Yt = /* @__PURE__ */ new Set(["[", "."]), Zt = /* @__PURE__ */ new Set(["..", "."]), Jt = new Set("().*{}+?[]^$\\!"), Xt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Y = "[^/]", et = Y + "*?", st = Y + "+?";
356
- class E {
384
+ return [Qt(p), !1, u - e, !1];
385
+ }
386
+ const f = "[" + (l ? "^" : "") + tt(n) + "]", d = "[" + (l ? "" : "^") + tt(r) + "]";
387
+ return [n.length && r.length ? "(" + f + "|" + d + ")" : n.length ? f : d, a, u - e, !0];
388
+ }, F = (s, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
389
+ var x;
390
+ const te = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), q = (s) => te.has(s), et = (s) => q(s.type), ee = /* @__PURE__ */ new Map([
391
+ ["!", ["@"]],
392
+ ["?", ["?", "@"]],
393
+ ["@", ["@"]],
394
+ ["*", ["*", "+", "?", "@"]],
395
+ ["+", ["+", "@"]]
396
+ ]), se = /* @__PURE__ */ new Map([
397
+ ["!", ["?"]],
398
+ ["@", ["?"]],
399
+ ["+", ["?", "*"]]
400
+ ]), ne = /* @__PURE__ */ new Map([
401
+ ["!", ["?", "@"]],
402
+ ["?", ["?", "@"]],
403
+ ["@", ["?", "@"]],
404
+ ["*", ["*", "+", "?", "@"]],
405
+ ["+", ["+", "@", "?", "*"]]
406
+ ]), st = /* @__PURE__ */ new Map([
407
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
408
+ [
409
+ "?",
410
+ /* @__PURE__ */ new Map([
411
+ ["*", "*"],
412
+ ["+", "*"]
413
+ ])
414
+ ],
415
+ [
416
+ "@",
417
+ /* @__PURE__ */ new Map([
418
+ ["!", "!"],
419
+ ["?", "?"],
420
+ ["@", "@"],
421
+ ["*", "*"],
422
+ ["+", "+"]
423
+ ])
424
+ ],
425
+ [
426
+ "+",
427
+ /* @__PURE__ */ new Map([
428
+ ["?", "*"],
429
+ ["*", "*"]
430
+ ])
431
+ ]
432
+ ]), re = "(?!(?:^|/)\\.\\.?(?:$|/))", R = "(?!\\.)", ie = /* @__PURE__ */ new Set(["[", "."]), oe = /* @__PURE__ */ new Set(["..", "."]), ae = new Set("().*{}+?[]^$\\!"), ce = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), V = "[^/]", nt = V + "*?", rt = V + "+?";
433
+ let le = 0;
434
+ class Y {
357
435
  type;
358
436
  #s;
359
437
  #n;
360
- #i = !1;
438
+ #r = !1;
361
439
  #t = [];
362
440
  #e;
441
+ #a;
442
+ #l;
443
+ #c = !1;
444
+ #i;
363
445
  #o;
364
- #c;
365
- #a = !1;
366
- #r;
367
- #h;
368
446
  // set to true if it's an extglob with no children
369
447
  // (which really means one child of '')
370
- #u = !1;
448
+ #h = !1;
449
+ id = ++le;
450
+ get depth() {
451
+ return (this.#e?.depth ?? -1) + 1;
452
+ }
453
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
454
+ return {
455
+ "@@type": "AST",
456
+ id: this.id,
457
+ type: this.type,
458
+ root: this.#s.id,
459
+ parent: this.#e?.id,
460
+ depth: this.depth,
461
+ partsLength: this.#t.length,
462
+ parts: this.#t
463
+ };
464
+ }
371
465
  constructor(t, e, n = {}) {
372
- 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;
466
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? n : 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;
373
467
  }
374
468
  get hasMagic() {
375
469
  if (this.#n !== void 0)
@@ -381,21 +475,21 @@ class E {
381
475
  }
382
476
  // reconstructs the pattern
383
477
  toString() {
384
- return this.#h !== void 0 ? this.#h : this.type ? this.#h = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#h = this.#t.map((t) => String(t)).join("");
478
+ 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("");
385
479
  }
386
- #d() {
480
+ #w() {
387
481
  if (this !== this.#s)
388
482
  throw new Error("should only call on root");
389
- if (this.#a)
483
+ if (this.#c)
390
484
  return this;
391
- this.toString(), this.#a = !0;
485
+ this.toString(), this.#c = !0;
392
486
  let t;
393
- for (; t = this.#c.pop(); ) {
487
+ for (; t = this.#l.pop(); ) {
394
488
  if (t.type !== "!")
395
489
  continue;
396
490
  let e = t, n = e.#e;
397
491
  for (; n; ) {
398
- for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
492
+ for (let r = e.#a + 1; !n.type && r < n.#t.length; r++)
399
493
  for (const i of t.#t) {
400
494
  if (typeof i == "string")
401
495
  throw new Error("string part in extglob AST??");
@@ -409,26 +503,26 @@ class E {
409
503
  push(...t) {
410
504
  for (const e of t)
411
505
  if (e !== "") {
412
- if (typeof e != "string" && !(e instanceof E && e.#e === this))
506
+ if (typeof e != "string" && !(e instanceof x && e.#e === this))
413
507
  throw new Error("invalid part: " + e);
414
508
  this.#t.push(e);
415
509
  }
416
510
  }
417
511
  toJSON() {
418
512
  const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
419
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#a && this.#e?.type === "!") && t.push({}), t;
513
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
420
514
  }
421
515
  isStart() {
422
516
  if (this.#s === this)
423
517
  return !0;
424
518
  if (!this.#e?.isStart())
425
519
  return !1;
426
- if (this.#o === 0)
520
+ if (this.#a === 0)
427
521
  return !0;
428
522
  const t = this.#e;
429
- for (let e = 0; e < this.#o; e++) {
523
+ for (let e = 0; e < this.#a; e++) {
430
524
  const n = t.#t[e];
431
- if (!(n instanceof E && n.type === "!"))
525
+ if (!(n instanceof x && n.type === "!"))
432
526
  return !1;
433
527
  }
434
528
  return !0;
@@ -441,79 +535,123 @@ class E {
441
535
  if (!this.type)
442
536
  return this.#e?.isEnd();
443
537
  const t = this.#e ? this.#e.#t.length : 0;
444
- return this.#o === t - 1;
538
+ return this.#a === t - 1;
445
539
  }
446
540
  copyIn(t) {
447
541
  typeof t == "string" ? this.push(t) : this.push(t.clone(this));
448
542
  }
449
543
  clone(t) {
450
- const e = new E(this.type, t);
544
+ const e = new x(this.type, t);
451
545
  for (const n of this.#t)
452
546
  e.copyIn(n);
453
547
  return e;
454
548
  }
455
- static #l(t, e, n, r) {
456
- let i = !1, o = !1, a = -1, c = !1;
549
+ static #u(t, e, n, r, i) {
550
+ const o = r.maxExtglobRecursion ?? 2;
551
+ let a = !1, c = !1, l = -1, u = !1;
457
552
  if (e.type === null) {
458
- let f = n, g = "";
459
- for (; f < t.length; ) {
460
- const p = t.charAt(f++);
461
- if (i || p === "\\") {
462
- i = !i, g += p;
553
+ let p = n, E = "";
554
+ for (; p < t.length; ) {
555
+ const w = t.charAt(p++);
556
+ if (a || w === "\\") {
557
+ a = !a, E += w;
463
558
  continue;
464
559
  }
465
- if (o) {
466
- f === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(f === a + 2 && c) && (o = !1), g += p;
560
+ if (c) {
561
+ p === l + 1 ? (w === "^" || w === "!") && (u = !0) : w === "]" && !(p === l + 2 && u) && (c = !1), E += w;
467
562
  continue;
468
- } else if (p === "[") {
469
- o = !0, a = f, c = !1, g += p;
563
+ } else if (w === "[") {
564
+ c = !0, l = p, u = !1, E += w;
470
565
  continue;
471
566
  }
472
- if (!r.noext && tt(p) && t.charAt(f) === "(") {
473
- e.push(g), g = "";
474
- const S = new E(p, e);
475
- f = E.#l(t, S, f, r), e.push(S);
567
+ if (!r.noext && q(w) && t.charAt(p) === "(" && i <= o) {
568
+ e.push(E), E = "";
569
+ const O = new x(w, e);
570
+ p = x.#u(t, O, p, r, i + 1), e.push(O);
476
571
  continue;
477
572
  }
478
- g += p;
573
+ E += w;
479
574
  }
480
- return e.push(g), f;
575
+ return e.push(E), p;
481
576
  }
482
- let l = n + 1, h = new E(null, e);
577
+ let h = n + 1, f = new x(null, e);
483
578
  const d = [];
484
- let u = "";
485
- for (; l < t.length; ) {
486
- const f = t.charAt(l++);
487
- if (i || f === "\\") {
488
- i = !i, u += f;
579
+ let g = "";
580
+ for (; h < t.length; ) {
581
+ const p = t.charAt(h++);
582
+ if (a || p === "\\") {
583
+ a = !a, g += p;
489
584
  continue;
490
585
  }
491
- if (o) {
492
- l === a + 1 ? (f === "^" || f === "!") && (c = !0) : f === "]" && !(l === a + 2 && c) && (o = !1), u += f;
586
+ if (c) {
587
+ h === l + 1 ? (p === "^" || p === "!") && (u = !0) : p === "]" && !(h === l + 2 && u) && (c = !1), g += p;
493
588
  continue;
494
- } else if (f === "[") {
495
- o = !0, a = l, c = !1, u += f;
589
+ } else if (p === "[") {
590
+ c = !0, l = h, u = !1, g += p;
496
591
  continue;
497
592
  }
498
- if (tt(f) && t.charAt(l) === "(") {
499
- h.push(u), u = "";
500
- const g = new E(f, h);
501
- h.push(g), l = E.#l(t, g, l, r);
593
+ if (!r.noext && q(p) && t.charAt(h) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
594
+ (i <= o || e && e.#f(p))) {
595
+ const w = e && e.#f(p) ? 0 : 1;
596
+ f.push(g), g = "";
597
+ const y = new x(p, f);
598
+ f.push(y), h = x.#u(t, y, h, r, i + w);
502
599
  continue;
503
600
  }
504
- if (f === "|") {
505
- h.push(u), u = "", d.push(h), h = new E(null, e);
601
+ if (p === "|") {
602
+ f.push(g), g = "", d.push(f), f = new x(null, e);
506
603
  continue;
507
604
  }
508
- if (f === ")")
509
- return u === "" && e.#t.length === 0 && (e.#u = !0), h.push(u), u = "", e.push(...d, h), l;
510
- u += f;
605
+ if (p === ")")
606
+ return g === "" && e.#t.length === 0 && (e.#h = !0), f.push(g), g = "", e.push(...d, f), h;
607
+ g += p;
511
608
  }
512
- return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], l;
609
+ return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
610
+ }
611
+ #y(t) {
612
+ return this.#d(t, se);
613
+ }
614
+ #d(t, e = ee) {
615
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null)
616
+ return !1;
617
+ const n = t.#t[0];
618
+ return !n || typeof n != "object" || n.type === null ? !1 : this.#f(n.type, e);
619
+ }
620
+ #f(t, e = ne) {
621
+ return !!e.get(this.type)?.includes(t);
622
+ }
623
+ #E(t, e) {
624
+ const n = t.#t[0], r = new x(null, n, this.options);
625
+ r.#t.push(""), n.push(r), this.#g(t, e);
626
+ }
627
+ #g(t, e) {
628
+ const n = t.#t[0];
629
+ this.#t.splice(e, 1, ...n.#t);
630
+ for (const r of n.#t)
631
+ typeof r == "object" && (r.#e = this);
632
+ this.#o = void 0;
633
+ }
634
+ #S(t) {
635
+ return !!st.get(this.type)?.has(t);
636
+ }
637
+ #b(t) {
638
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null || this.#t.length !== 1)
639
+ return !1;
640
+ const e = t.#t[0];
641
+ return !e || typeof e != "object" || e.type === null ? !1 : this.#S(e.type);
642
+ }
643
+ #x(t) {
644
+ const e = st.get(this.type), n = t.#t[0], r = e?.get(n.type);
645
+ if (!r)
646
+ return !1;
647
+ this.#t = n.#t;
648
+ for (const i of this.#t)
649
+ typeof i == "object" && (i.#e = this);
650
+ this.type = r, this.#o = void 0, this.#h = !1;
513
651
  }
514
652
  static fromGlob(t, e = {}) {
515
- const n = new E(null, void 0, e);
516
- return E.#l(t, n, 0, e), n;
653
+ const n = new x(null, void 0, e);
654
+ return x.#u(t, n, 0, e, 0), n;
517
655
  }
518
656
  // returns the regular expression if there's magic, or the unescaped
519
657
  // string if not.
@@ -521,16 +659,16 @@ class E {
521
659
  if (this !== this.#s)
522
660
  return this.#s.toMMPattern();
523
661
  const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
524
- if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
662
+ if (!(r || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
525
663
  return n;
526
- const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
664
+ const a = (this.#i.nocase ? "i" : "") + (i ? "u" : "");
527
665
  return Object.assign(new RegExp(`^${e}$`, a), {
528
666
  _src: e,
529
667
  _glob: t
530
668
  });
531
669
  }
532
670
  get options() {
533
- return this.#r;
671
+ return this.#i;
534
672
  }
535
673
  // returns the string match, the regexp source, whether there's magic
536
674
  // in the regexp (so a regular expression is required) and whether or
@@ -602,168 +740,187 @@ class E {
602
740
  // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
603
741
  // or start or whatever) and prepend ^ or / at the Regexp construction.
604
742
  toRegExpSource(t) {
605
- const e = t ?? !!this.#r.dot;
606
- if (this.#s === this && this.#d(), !this.type) {
607
- const c = this.isStart() && this.isEnd(), l = this.#t.map((f) => {
608
- const [g, p, S, A] = typeof f == "string" ? E.#p(f, this.#n, c) : f.toRegExpSource(t);
609
- return this.#n = this.#n || S, this.#i = this.#i || A, g;
743
+ const e = t ?? !!this.#i.dot;
744
+ if (this.#s === this && (this.#p(), this.#w()), !et(this)) {
745
+ const c = this.isStart() && this.isEnd() && !this.#t.some((d) => typeof d != "string"), l = this.#t.map((d) => {
746
+ const [g, p, E, w] = typeof d == "string" ? x.#A(d, this.#n, c) : d.toRegExpSource(t);
747
+ return this.#n = this.#n || E, this.#r = this.#r || w, g;
610
748
  }).join("");
611
- let h = "";
612
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Zt.has(this.#t[0]))) {
613
- const g = Yt, p = (
749
+ let u = "";
750
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && oe.has(this.#t[0]))) {
751
+ const g = ie, p = (
614
752
  // dots are allowed, and the pattern starts with [ or .
615
753
  e && g.has(l.charAt(0)) || // the pattern starts with \., and then [ or .
616
754
  l.startsWith("\\.") && g.has(l.charAt(2)) || // the pattern starts with \.\., and then [ or .
617
755
  l.startsWith("\\.\\.") && g.has(l.charAt(4))
618
- ), S = !e && !t && g.has(l.charAt(0));
619
- h = p ? Vt : S ? R : "";
756
+ ), E = !e && !t && g.has(l.charAt(0));
757
+ u = p ? re : E ? R : "";
620
758
  }
621
- let d = "";
622
- return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (d = "(?:$|\\/)"), [
623
- h + l + d,
624
- I(l),
759
+ let h = "";
760
+ return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (h = "(?:$|\\/)"), [
761
+ u + l + h,
762
+ F(l),
625
763
  this.#n = !!this.#n,
626
- this.#i
764
+ this.#r
627
765
  ];
628
766
  }
629
767
  const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
630
- let i = this.#f(e);
768
+ let i = this.#m(e);
631
769
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
632
- const c = this.toString();
633
- return this.#t = [c], this.type = null, this.#n = void 0, [c, I(this.toString()), !1, !1];
770
+ const c = this.toString(), l = this;
771
+ return l.#t = [c], l.type = null, l.#n = void 0, [c, F(this.toString()), !1, !1];
634
772
  }
635
- let o = !n || t || e || !R ? "" : this.#f(!0);
773
+ let o = !n || t || e || !R ? "" : this.#m(!0);
636
774
  o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
637
775
  let a = "";
638
- if (this.type === "!" && this.#u)
639
- a = (this.isStart() && !e ? R : "") + st;
776
+ if (this.type === "!" && this.#h)
777
+ a = (this.isStart() && !e ? R : "") + rt;
640
778
  else {
641
779
  const c = this.type === "!" ? (
642
780
  // !() must match something,but !(x) can match ''
643
- "))" + (this.isStart() && !e && !t ? R : "") + et + ")"
781
+ "))" + (this.isStart() && !e && !t ? R : "") + nt + ")"
644
782
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
645
783
  a = r + i + c;
646
784
  }
647
785
  return [
648
786
  a,
649
- I(i),
787
+ F(i),
650
788
  this.#n = !!this.#n,
651
- this.#i
789
+ this.#r
652
790
  ];
653
791
  }
654
- #f(t) {
792
+ #p() {
793
+ if (et(this)) {
794
+ let t = 0, e = !1;
795
+ do {
796
+ e = !0;
797
+ for (let n = 0; n < this.#t.length; n++) {
798
+ const r = this.#t[n];
799
+ typeof r == "object" && (r.#p(), this.#d(r) ? (e = !1, this.#g(r, n)) : this.#y(r) ? (e = !1, this.#E(r, n)) : this.#b(r) && (e = !1, this.#x(r)));
800
+ }
801
+ } while (!e && ++t < 10);
802
+ } else
803
+ for (const t of this.#t)
804
+ typeof t == "object" && t.#p();
805
+ this.#o = void 0;
806
+ }
807
+ #m(t) {
655
808
  return this.#t.map((e) => {
656
809
  if (typeof e == "string")
657
810
  throw new Error("string type in extglob ast??");
658
811
  const [n, r, i, o] = e.toRegExpSource(t);
659
- return this.#i = this.#i || o, n;
812
+ return this.#r = this.#r || o, n;
660
813
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
661
814
  }
662
- static #p(t, e, n = !1) {
663
- let r = !1, i = "", o = !1;
664
- for (let a = 0; a < t.length; a++) {
665
- const c = t.charAt(a);
815
+ static #A(t, e, n = !1) {
816
+ let r = !1, i = "", o = !1, a = !1;
817
+ for (let c = 0; c < t.length; c++) {
818
+ const l = t.charAt(c);
666
819
  if (r) {
667
- r = !1, i += (Jt.has(c) ? "\\" : "") + c;
820
+ r = !1, i += (ae.has(l) ? "\\" : "") + l;
668
821
  continue;
669
822
  }
670
- if (c === "\\") {
671
- a === t.length - 1 ? i += "\\\\" : r = !0;
823
+ if (l === "*") {
824
+ if (a)
825
+ continue;
826
+ a = !0, i += n && /^[*]+$/.test(t) ? rt : nt, e = !0;
827
+ continue;
828
+ } else
829
+ a = !1;
830
+ if (l === "\\") {
831
+ c === t.length - 1 ? i += "\\\\" : r = !0;
672
832
  continue;
673
833
  }
674
- if (c === "[") {
675
- const [l, h, d, u] = qt(t, a);
676
- if (d) {
677
- i += l, o = o || h, a += d - 1, e = e || u;
834
+ if (l === "[") {
835
+ const [u, h, f, d] = Kt(t, c);
836
+ if (f) {
837
+ i += u, o = o || h, c += f - 1, e = e || d;
678
838
  continue;
679
839
  }
680
840
  }
681
- if (c === "*") {
682
- n && t === "*" ? i += st : i += et, e = !0;
841
+ if (l === "?") {
842
+ i += V, e = !0;
683
843
  continue;
684
844
  }
685
- if (c === "?") {
686
- i += Y, e = !0;
687
- continue;
688
- }
689
- i += Xt(c);
845
+ i += ce(l);
690
846
  }
691
- return [i, I(t), !!e, o];
847
+ return [i, F(t), !!e, o];
692
848
  }
693
849
  }
694
- const Kt = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), y = (s, t, e = {}) => (L(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new W(t, e).match(s)), Qt = /^\*+([^+@!?\*\[\(]*)$/, te = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ee = (s) => (t) => t.endsWith(s), se = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ne = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), re = /^\*+\.\*+$/, ie = (s) => !s.startsWith(".") && s.includes("."), oe = (s) => s !== "." && s !== ".." && s.includes("."), ae = /^\.\*+$/, ce = (s) => s !== "." && s !== ".." && s.startsWith("."), he = /^\*+$/, le = (s) => s.length !== 0 && !s.startsWith("."), ue = (s) => s.length !== 0 && s !== "." && s !== "..", fe = /^\?+([^+@!?\*\[\(]*)?$/, de = ([s, t = ""]) => {
695
- const e = ft([s]);
850
+ x = Y;
851
+ const he = (s, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), S = (s, t, e = {}) => (k(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new L(t, e).match(s)), ue = /^\*+([^+@!?*[(]*)$/, fe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), pe = (s) => (t) => t.endsWith(s), de = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ge = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), me = /^\*+\.\*+$/, we = (s) => !s.startsWith(".") && s.includes("."), ye = (s) => s !== "." && s !== ".." && s.includes("."), Ee = /^\.\*+$/, Se = (s) => s !== "." && s !== ".." && s.startsWith("."), be = /^\*+$/, xe = (s) => s.length !== 0 && !s.startsWith("."), Ae = (s) => s.length !== 0 && s !== "." && s !== "..", ve = /^\?+([^+@!?*[(]*)?$/, Oe = ([s, t = ""]) => {
852
+ const e = gt([s]);
696
853
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
697
- }, pe = ([s, t = ""]) => {
698
- const e = dt([s]);
854
+ }, $e = ([s, t = ""]) => {
855
+ const e = mt([s]);
699
856
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
700
- }, ge = ([s, t = ""]) => {
701
- const e = dt([s]);
857
+ }, Ne = ([s, t = ""]) => {
858
+ const e = mt([s]);
702
859
  return t ? (n) => e(n) && n.endsWith(t) : e;
703
- }, me = ([s, t = ""]) => {
704
- const e = ft([s]);
860
+ }, De = ([s, t = ""]) => {
861
+ const e = gt([s]);
705
862
  return t ? (n) => e(n) && n.endsWith(t) : e;
706
- }, ft = ([s]) => {
863
+ }, gt = ([s]) => {
707
864
  const t = s.length;
708
865
  return (e) => e.length === t && !e.startsWith(".");
709
- }, dt = ([s]) => {
866
+ }, mt = ([s]) => {
710
867
  const t = s.length;
711
868
  return (e) => e.length === t && e !== "." && e !== "..";
712
- }, pt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", nt = {
869
+ }, wt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", it = {
713
870
  win32: { sep: "\\" },
714
871
  posix: { sep: "/" }
715
- }, we = pt === "win32" ? nt.win32.sep : nt.posix.sep;
716
- y.sep = we;
717
- const b = Symbol("globstar **");
718
- y.GLOBSTAR = b;
719
- const ye = "[^/]", Ee = ye + "*?", Se = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", xe = "(?:(?!(?:\\/|^)\\.).)*?", ve = (s, t = {}) => (e) => y(e, s, t);
720
- y.filter = ve;
721
- const v = (s, t = {}) => Object.assign({}, s, t), be = (s) => {
872
+ }, Te = wt === "win32" ? it.win32.sep : it.posix.sep;
873
+ S.sep = Te;
874
+ const b = /* @__PURE__ */ Symbol("globstar **");
875
+ S.GLOBSTAR = b;
876
+ const Ce = "[^/]", Me = Ce + "*?", Fe = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", Re = "(?:(?!(?:\\/|^)\\.).)*?", Pe = (s, t = {}) => (e) => S(e, s, t);
877
+ S.filter = Pe;
878
+ const A = (s, t = {}) => Object.assign({}, s, t), ke = (s) => {
722
879
  if (!s || typeof s != "object" || !Object.keys(s).length)
723
- return y;
724
- const t = y;
725
- return Object.assign((n, r, i = {}) => t(n, r, v(s, i)), {
880
+ return S;
881
+ const t = S;
882
+ return Object.assign((n, r, i = {}) => t(n, r, A(s, i)), {
726
883
  Minimatch: class extends t.Minimatch {
727
884
  constructor(r, i = {}) {
728
- super(r, v(s, i));
885
+ super(r, A(s, i));
729
886
  }
730
887
  static defaults(r) {
731
- return t.defaults(v(s, r)).Minimatch;
888
+ return t.defaults(A(s, r)).Minimatch;
732
889
  }
733
890
  },
734
891
  AST: class extends t.AST {
735
892
  /* c8 ignore start */
736
893
  constructor(r, i, o = {}) {
737
- super(r, i, v(s, o));
894
+ super(r, i, A(s, o));
738
895
  }
739
896
  /* c8 ignore stop */
740
897
  static fromGlob(r, i = {}) {
741
- return t.AST.fromGlob(r, v(s, i));
898
+ return t.AST.fromGlob(r, A(s, i));
742
899
  }
743
900
  },
744
- unescape: (n, r = {}) => t.unescape(n, v(s, r)),
745
- escape: (n, r = {}) => t.escape(n, v(s, r)),
746
- filter: (n, r = {}) => t.filter(n, v(s, r)),
747
- defaults: (n) => t.defaults(v(s, n)),
748
- makeRe: (n, r = {}) => t.makeRe(n, v(s, r)),
749
- braceExpand: (n, r = {}) => t.braceExpand(n, v(s, r)),
750
- match: (n, r, i = {}) => t.match(n, r, v(s, i)),
901
+ unescape: (n, r = {}) => t.unescape(n, A(s, r)),
902
+ escape: (n, r = {}) => t.escape(n, A(s, r)),
903
+ filter: (n, r = {}) => t.filter(n, A(s, r)),
904
+ defaults: (n) => t.defaults(A(s, n)),
905
+ makeRe: (n, r = {}) => t.makeRe(n, A(s, r)),
906
+ braceExpand: (n, r = {}) => t.braceExpand(n, A(s, r)),
907
+ match: (n, r, i = {}) => t.match(n, r, A(s, i)),
751
908
  sep: t.sep,
752
909
  GLOBSTAR: b
753
910
  });
754
911
  };
755
- y.defaults = be;
756
- const gt = (s, t = {}) => (L(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : Lt(s));
757
- y.braceExpand = gt;
758
- const Oe = (s, t = {}) => new W(s, t).makeRe();
759
- y.makeRe = Oe;
760
- const Ae = (s, t, e = {}) => {
761
- const n = new W(t, e);
912
+ S.defaults = ke;
913
+ const yt = (s, t = {}) => (k(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : Ht(s, { max: t.braceExpandMax }));
914
+ S.braceExpand = yt;
915
+ const Ie = (s, t = {}) => new L(s, t).makeRe();
916
+ S.makeRe = Ie;
917
+ const Le = (s, t, e = {}) => {
918
+ const n = new L(t, e);
762
919
  return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
763
920
  };
764
- y.match = Ae;
765
- const rt = /[?*]|[+@!]\(.*?\)|\[|\]/, De = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
766
- class W {
921
+ S.match = Le;
922
+ const ot = /[?*]|[+@!]\(.*?\)|\[|\]/, ze = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
923
+ class L {
767
924
  options;
768
925
  set;
769
926
  pattern;
@@ -780,9 +937,12 @@ class W {
780
937
  isWindows;
781
938
  platform;
782
939
  windowsNoMagicRoot;
940
+ maxGlobstarRecursion;
783
941
  regexp;
784
942
  constructor(t, e = {}) {
785
- L(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || pt, 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();
943
+ k(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || wt, this.isWindows = this.platform === "win32";
944
+ const n = "allowWindowsEscape";
945
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[n] === !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();
786
946
  }
787
947
  hasMagic() {
788
948
  if (this.options.magicalBraces && this.set.length > 1)
@@ -810,11 +970,14 @@ class W {
810
970
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
811
971
  let r = this.globParts.map((i, o, a) => {
812
972
  if (this.isWindows && this.windowsNoMagicRoot) {
813
- const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !rt.test(i[2])) && !rt.test(i[3]), l = /^[a-z]:/i.test(i[0]);
973
+ const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !ot.test(i[2])) && !ot.test(i[3]), l = /^[a-z]:/i.test(i[0]);
814
974
  if (c)
815
- return [...i.slice(0, 4), ...i.slice(4).map((h) => this.parse(h))];
975
+ return [
976
+ ...i.slice(0, 4),
977
+ ...i.slice(4).map((u) => this.parse(u))
978
+ ];
816
979
  if (l)
817
- return [i[0], ...i.slice(1).map((h) => this.parse(h))];
980
+ return [i[0], ...i.slice(1).map((u) => this.parse(u))];
818
981
  }
819
982
  return i.map((c) => this.parse(c));
820
983
  });
@@ -832,9 +995,9 @@ class W {
832
995
  // of patterns that we have to process.
833
996
  preprocess(t) {
834
997
  if (this.options.noglobstar)
835
- for (let n = 0; n < t.length; n++)
836
- for (let r = 0; r < t[n].length; r++)
837
- t[n][r] === "**" && (t[n][r] = "*");
998
+ for (const n of t)
999
+ for (let r = 0; r < n.length; r++)
1000
+ n[r] === "**" && (n[r] = "*");
838
1001
  const { optimizationLevel: e = 1 } = this.options;
839
1002
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
840
1003
  }
@@ -872,7 +1035,7 @@ class W {
872
1035
  let n = 0;
873
1036
  for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
874
1037
  const r = t[n - 1];
875
- r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1038
+ r && r !== "." && r !== ".." && r !== "**" && !(this.isWindows && /^[a-z]:$/i.test(r)) && (e = !0, t.splice(n - 1, 2), n -= 2);
876
1039
  }
877
1040
  } while (e);
878
1041
  return t.length === 0 ? [""] : t;
@@ -911,8 +1074,8 @@ class W {
911
1074
  if (a !== ".." || !c || c === "." || c === ".." || !l || l === "." || l === "..")
912
1075
  continue;
913
1076
  e = !0, n.splice(r, 1);
914
- const h = n.slice(0);
915
- h[r] = "**", t.push(h), r--;
1077
+ const u = n.slice(0);
1078
+ u[r] = "**", t.push(u), r--;
916
1079
  }
917
1080
  if (!this.preserveMultipleSlashes) {
918
1081
  for (let o = 1; o < n.length - 1; o++) {
@@ -988,69 +1151,128 @@ class W {
988
1151
  // out of pattern, then that's fine, as long as all
989
1152
  // the parts match.
990
1153
  matchOne(t, e, n = !1) {
991
- const r = this.options;
1154
+ let r = 0, i = 0;
992
1155
  if (this.isWindows) {
993
- 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]), C = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, w = C ? 3 : A ? 0 : void 0;
994
- if (typeof x == "number" && typeof w == "number") {
995
- const [T, P] = [t[x], e[w]];
996
- T.toLowerCase() === P.toLowerCase() && (e[w] = T, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
1156
+ 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]), u = !l && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), h = c ? 3 : a ? 0 : void 0, f = u ? 3 : l ? 0 : void 0;
1157
+ if (typeof h == "number" && typeof f == "number") {
1158
+ const [d, g] = [
1159
+ t[h],
1160
+ e[f]
1161
+ ];
1162
+ d.toLowerCase() === g.toLowerCase() && (e[f] = d, i = f, r = h);
997
1163
  }
998
1164
  }
999
- const { optimizationLevel: i = 1 } = this.options;
1000
- i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1001
- for (var o = 0, a = 0, c = t.length, l = e.length; o < c && a < l; o++, a++) {
1002
- this.debug("matchOne loop");
1003
- var h = e[a], d = t[o];
1004
- if (this.debug(e, h, d), h === !1)
1165
+ const { optimizationLevel: o = 1 } = this.options;
1166
+ return o >= 2 && (t = this.levelTwoFileOptimize(t)), e.includes(b) ? this.#s(t, e, n, r, i) : this.#r(t, e, n, r, i);
1167
+ }
1168
+ #s(t, e, n, r, i) {
1169
+ const o = e.indexOf(b, i), a = e.lastIndexOf(b), [c, l, u] = n ? [
1170
+ e.slice(i, o),
1171
+ e.slice(o + 1),
1172
+ []
1173
+ ] : [
1174
+ e.slice(i, o),
1175
+ e.slice(o + 1, a),
1176
+ e.slice(a + 1)
1177
+ ];
1178
+ if (c.length) {
1179
+ const y = t.slice(r, r + c.length);
1180
+ if (!this.#r(y, c, n, 0, 0))
1005
1181
  return !1;
1006
- if (h === b) {
1007
- this.debug("GLOBSTAR", [e, h, d]);
1008
- var u = o, f = a + 1;
1009
- if (f === l) {
1010
- for (this.debug("** at the end"); o < c; o++)
1011
- if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1012
- return !1;
1013
- return !0;
1014
- }
1015
- for (; u < c; ) {
1016
- var g = t[u];
1017
- if (this.debug(`
1018
- globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1019
- return this.debug("globstar found match!", u, c, g), !0;
1020
- if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1021
- this.debug("dot detected!", t, u, e, f);
1022
- break;
1023
- }
1024
- this.debug("globstar swallow a segment, and continue"), u++;
1025
- }
1026
- return !!(n && (this.debug(`
1027
- >>> no match, partial?`, t, u, e, f), u === c));
1182
+ r += c.length, i += c.length;
1183
+ }
1184
+ let h = 0;
1185
+ if (u.length) {
1186
+ if (u.length + r > t.length)
1187
+ return !1;
1188
+ let y = t.length - u.length;
1189
+ if (this.#r(t, u, n, y, 0))
1190
+ h = u.length;
1191
+ else {
1192
+ if (t[t.length - 1] !== "" || r + u.length === t.length || (y--, !this.#r(t, u, n, y, 0)))
1193
+ return !1;
1194
+ h = u.length + 1;
1195
+ }
1196
+ }
1197
+ if (!l.length) {
1198
+ let y = !!h;
1199
+ for (let O = r; O < t.length - h; O++) {
1200
+ const z = String(t[O]);
1201
+ if (y = !0, z === "." || z === ".." || !this.options.dot && z.startsWith("."))
1202
+ return !1;
1028
1203
  }
1029
- let p;
1030
- if (typeof h == "string" ? (p = d === h, this.debug("string match", h, d, p)) : (p = h.test(d), this.debug("pattern match", h, d, p)), !p)
1204
+ return n || y;
1205
+ }
1206
+ const f = [[[], 0]];
1207
+ let d = f[0], g = 0;
1208
+ const p = [0];
1209
+ for (const y of l)
1210
+ y === b ? (p.push(g), d = [[], 0], f.push(d)) : (d[0].push(y), g++);
1211
+ let E = f.length - 1;
1212
+ const w = t.length - h;
1213
+ for (const y of f)
1214
+ y[1] = w - (p[E--] + y[0].length);
1215
+ return !!this.#n(t, f, r, 0, n, 0, !!h);
1216
+ }
1217
+ // return false for "nope, not matching"
1218
+ // return null for "not matching, cannot keep trying"
1219
+ #n(t, e, n, r, i, o, a) {
1220
+ const c = e[r];
1221
+ if (!c) {
1222
+ for (let h = n; h < t.length; h++) {
1223
+ a = !0;
1224
+ const f = t[h];
1225
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1226
+ return !1;
1227
+ }
1228
+ return a;
1229
+ }
1230
+ const [l, u] = c;
1231
+ for (; n <= u; ) {
1232
+ if (this.#r(t.slice(0, n + l.length), l, i, n, 0) && o < this.maxGlobstarRecursion) {
1233
+ const d = this.#n(t, e, n + l.length, r + 1, i, o + 1, a);
1234
+ if (d !== !1)
1235
+ return d;
1236
+ }
1237
+ const f = t[n];
1238
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1239
+ return !1;
1240
+ n++;
1241
+ }
1242
+ return i || null;
1243
+ }
1244
+ #r(t, e, n, r, i) {
1245
+ let o, a, c, l;
1246
+ for (o = r, a = i, l = t.length, c = e.length; o < l && a < c; o++, a++) {
1247
+ this.debug("matchOne loop");
1248
+ let u = e[a], h = t[o];
1249
+ if (this.debug(e, u, h), u === !1 || u === b)
1250
+ return !1;
1251
+ let f;
1252
+ if (typeof u == "string" ? (f = h === u, this.debug("string match", u, h, f)) : (f = u.test(h), this.debug("pattern match", u, h, f)), !f)
1031
1253
  return !1;
1032
1254
  }
1033
- if (o === c && a === l)
1255
+ if (o === l && a === c)
1034
1256
  return !0;
1035
- if (o === c)
1257
+ if (o === l)
1036
1258
  return n;
1037
- if (a === l)
1038
- return o === c - 1 && t[o] === "";
1259
+ if (a === c)
1260
+ return o === l - 1 && t[o] === "";
1039
1261
  throw new Error("wtf?");
1040
1262
  }
1041
1263
  braceExpand() {
1042
- return gt(this.pattern, this.options);
1264
+ return yt(this.pattern, this.options);
1043
1265
  }
1044
1266
  parse(t) {
1045
- L(t);
1267
+ k(t);
1046
1268
  const e = this.options;
1047
1269
  if (t === "**")
1048
1270
  return b;
1049
1271
  if (t === "")
1050
1272
  return "";
1051
1273
  let n, r = null;
1052
- (n = t.match(he)) ? r = e.dot ? ue : le : (n = t.match(Qt)) ? r = (e.nocase ? e.dot ? ne : se : e.dot ? ee : te)(n[1]) : (n = t.match(fe)) ? r = (e.nocase ? e.dot ? pe : de : e.dot ? ge : me)(n) : (n = t.match(re)) ? r = e.dot ? oe : ie : (n = t.match(ae)) && (r = ce);
1053
- const i = E.fromGlob(t, this.options).toMMPattern();
1274
+ (n = t.match(be)) ? r = e.dot ? Ae : xe : (n = t.match(ue)) ? r = (e.nocase ? e.dot ? ge : de : e.dot ? pe : fe)(n[1]) : (n = t.match(ve)) ? r = (e.nocase ? e.dot ? $e : Oe : e.dot ? Ne : De)(n) : (n = t.match(me)) ? r = e.dot ? ye : we : (n = t.match(Ee)) && (r = Se);
1275
+ const i = Y.fromGlob(t, this.options).toMMPattern();
1054
1276
  return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1055
1277
  }
1056
1278
  makeRe() {
@@ -1059,21 +1281,29 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1059
1281
  const t = this.set;
1060
1282
  if (!t.length)
1061
1283
  return this.regexp = !1, this.regexp;
1062
- const e = this.options, n = e.noglobstar ? Ee : e.dot ? Se : xe, r = new Set(e.nocase ? ["i"] : []);
1284
+ const e = this.options, n = e.noglobstar ? Me : e.dot ? Fe : Re, r = new Set(e.nocase ? ["i"] : []);
1063
1285
  let i = t.map((c) => {
1064
1286
  const l = c.map((h) => {
1065
1287
  if (h instanceof RegExp)
1066
- for (const d of h.flags.split(""))
1067
- r.add(d);
1068
- return typeof h == "string" ? De(h) : h === b ? b : h._src;
1288
+ for (const f of h.flags.split(""))
1289
+ r.add(f);
1290
+ return typeof h == "string" ? ze(h) : h === b ? b : h._src;
1069
1291
  });
1070
- return l.forEach((h, d) => {
1071
- const u = l[d + 1], f = l[d - 1];
1072
- h !== b || f === b || (f === void 0 ? u !== void 0 && u !== b ? l[d + 1] = "(?:\\/|" + n + "\\/)?" + u : l[d] = n : u === void 0 ? l[d - 1] = f + "(?:\\/|" + n + ")?" : u !== b && (l[d - 1] = f + "(?:\\/|\\/" + n + "\\/)" + u, l[d + 1] = b));
1073
- }), l.filter((h) => h !== b).join("/");
1292
+ l.forEach((h, f) => {
1293
+ const d = l[f + 1], g = l[f - 1];
1294
+ h !== b || g === b || (g === void 0 ? d !== void 0 && d !== b ? l[f + 1] = "(?:\\/|" + n + "\\/)?" + d : l[f] = n : d === void 0 ? l[f - 1] = g + "(?:\\/|\\/" + n + ")?" : d !== b && (l[f - 1] = g + "(?:\\/|\\/" + n + "\\/)" + d, l[f + 1] = b));
1295
+ });
1296
+ const u = l.filter((h) => h !== b);
1297
+ if (this.partial && u.length >= 1) {
1298
+ const h = [];
1299
+ for (let f = 1; f <= u.length; f++)
1300
+ h.push(u.slice(0, f).join("/"));
1301
+ return "(?:" + h.join("|") + ")";
1302
+ }
1303
+ return u.join("/");
1074
1304
  }).join("|");
1075
1305
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1076
- i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1306
+ i = "^" + o + i + a + "$", this.partial && (i = "^(?:\\/|" + o + i.slice(1, -1) + a + ")$"), this.negate && (i = "^(?!" + i + ").+$");
1077
1307
  try {
1078
1308
  this.regexp = new RegExp(i, [...r].join(""));
1079
1309
  } catch {
@@ -1082,7 +1312,7 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1082
1312
  return this.regexp;
1083
1313
  }
1084
1314
  slashSplit(t) {
1085
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1315
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1086
1316
  }
1087
1317
  match(t, e = this.partial) {
1088
1318
  if (this.debug("match", t, this.pattern), this.comment)
@@ -1101,23 +1331,22 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1101
1331
  if (!o)
1102
1332
  for (let a = r.length - 2; !o && a >= 0; a--)
1103
1333
  o = r[a];
1104
- for (let a = 0; a < i.length; a++) {
1105
- const c = i[a];
1106
- let l = r;
1107
- if (n.matchBase && c.length === 1 && (l = [o]), this.matchOne(l, c, e))
1334
+ for (const a of i) {
1335
+ let c = r;
1336
+ if (n.matchBase && a.length === 1 && (c = [o]), this.matchOne(c, a, e))
1108
1337
  return n.flipNegate ? !0 : !this.negate;
1109
1338
  }
1110
1339
  return n.flipNegate ? !1 : this.negate;
1111
1340
  }
1112
1341
  static defaults(t) {
1113
- return y.defaults(t).Minimatch;
1342
+ return S.defaults(t).Minimatch;
1114
1343
  }
1115
1344
  }
1116
- y.AST = E;
1117
- y.Minimatch = W;
1118
- y.escape = Kt;
1119
- y.unescape = I;
1120
- const Ne = [
1345
+ S.AST = Y;
1346
+ S.Minimatch = L;
1347
+ S.escape = he;
1348
+ S.unescape = F;
1349
+ const je = [
1121
1350
  // Images
1122
1351
  ".jpg",
1123
1352
  ".jpeg",
@@ -1174,14 +1403,14 @@ const Ne = [
1174
1403
  ".fbx",
1175
1404
  ".3ds"
1176
1405
  ];
1177
- function He(s) {
1406
+ function ss(s) {
1178
1407
  const t = s.lastIndexOf(".");
1179
1408
  if (t <= 0)
1180
1409
  return !0;
1181
1410
  const e = s.slice(t).toLowerCase();
1182
- return Ne.includes(e);
1411
+ return je.includes(e);
1183
1412
  }
1184
- function $e(s, t = "utf-8") {
1413
+ function We(s, t = "utf-8") {
1185
1414
  switch (t) {
1186
1415
  case "utf8":
1187
1416
  case "utf-8":
@@ -1190,24 +1419,24 @@ function $e(s, t = "utf-8") {
1190
1419
  case "utf-16le":
1191
1420
  case "ucs2":
1192
1421
  case "ucs-2":
1193
- return Ce(s);
1422
+ return _e(s);
1194
1423
  case "ascii":
1195
- return Fe(s);
1424
+ return He(s);
1196
1425
  case "latin1":
1197
- return Me(s);
1426
+ return Ue(s);
1198
1427
  case "binary":
1199
1428
  return Uint8Array.from(s, (e) => e.charCodeAt(0));
1200
1429
  case "base64":
1201
1430
  return Uint8Array.from(atob(s), (e) => e.charCodeAt(0));
1202
1431
  case "hex":
1203
1432
  if (!/^[\da-f]+$/i.test(s) || s.length % 2 !== 0)
1204
- throw new D("format", "Invalid hex string");
1433
+ throw new $("format", "Invalid hex string");
1205
1434
  return Uint8Array.from(s.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
1206
1435
  default:
1207
1436
  return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
1208
1437
  }
1209
1438
  }
1210
- function _e(s, t = "utf-8") {
1439
+ function ns(s, t = "utf-8") {
1211
1440
  switch (t) {
1212
1441
  case "utf8":
1213
1442
  case "utf-8":
@@ -1216,7 +1445,7 @@ function _e(s, t = "utf-8") {
1216
1445
  case "utf-16le":
1217
1446
  case "ucs2":
1218
1447
  case "ucs-2":
1219
- return Te(s);
1448
+ return Be(s);
1220
1449
  case "latin1":
1221
1450
  return String.fromCharCode(...s);
1222
1451
  case "ascii":
@@ -1229,7 +1458,7 @@ function _e(s, t = "utf-8") {
1229
1458
  return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
1230
1459
  }
1231
1460
  }
1232
- function Ce(s) {
1461
+ function _e(s) {
1233
1462
  const t = new Uint8Array(s.length * 2);
1234
1463
  for (let e = 0; e < s.length; e++) {
1235
1464
  const n = s.charCodeAt(e);
@@ -1237,64 +1466,72 @@ function Ce(s) {
1237
1466
  }
1238
1467
  return t;
1239
1468
  }
1240
- function Te(s) {
1469
+ function Be(s) {
1241
1470
  s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
1242
1471
  const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
1243
1472
  return String.fromCharCode(...t);
1244
1473
  }
1245
- function Me(s) {
1474
+ function Ue(s) {
1246
1475
  const t = new Uint8Array(s.length);
1247
1476
  for (let e = 0; e < s.length; e++)
1248
1477
  t[e] = s.charCodeAt(e) & 255;
1249
1478
  return t;
1250
1479
  }
1251
- function Fe(s) {
1480
+ function He(s) {
1252
1481
  const t = new Uint8Array(s.length);
1253
1482
  for (let e = 0; e < s.length; e++)
1254
1483
  t[e] = s.charCodeAt(e) & 127;
1255
1484
  return t;
1256
1485
  }
1257
- function Ie() {
1486
+ function Ge() {
1258
1487
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1259
- throw new wt();
1488
+ throw new xt();
1489
+ }
1490
+ function qe(s, t) {
1491
+ const e = T(s || "/"), n = T(St(t));
1492
+ return e === "/" ? n : n === "/" ? e : `${e.replace(/\/$/, "")}${n}`;
1260
1493
  }
1261
- async function Pe(s, t) {
1262
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: "exclusive" }, t) : t();
1494
+ async function Et(s, t, e = "/") {
1495
+ if (typeof navigator < "u" && navigator.locks?.request) {
1496
+ const n = qe(e, s).replace(/\/+/g, "/");
1497
+ return navigator.locks.request(`opfs:${n}`, { mode: "exclusive" }, t);
1498
+ }
1499
+ return t();
1263
1500
  }
1264
- function $(s) {
1501
+ function D(s) {
1265
1502
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1266
1503
  }
1267
1504
  function Z(s) {
1268
1505
  return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
1269
1506
  }
1270
- function z(s) {
1271
- const t = $(s);
1507
+ function I(s) {
1508
+ const t = D(s);
1272
1509
  return t[t.length - 1] || "";
1273
1510
  }
1274
- function H(s) {
1275
- const t = $(s);
1511
+ function _(s) {
1512
+ const t = D(s);
1276
1513
  return t.pop(), Z(t);
1277
1514
  }
1278
- function j(s) {
1515
+ function T(s) {
1279
1516
  return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
1280
1517
  }
1281
- function Re(s, t = !1) {
1518
+ function Xe(s, t = !1) {
1282
1519
  return s = s.replace(/\/$/, ""), t && !s.includes("*") ? `${s}/**` : s;
1283
1520
  }
1284
- function _(s, t) {
1285
- return y(s, t, {
1521
+ function B(s, t) {
1522
+ return S(s, t, {
1286
1523
  dot: !0,
1287
1524
  matchBase: !0
1288
1525
  });
1289
1526
  }
1290
- function qe(s, t) {
1527
+ function rs(s, t) {
1291
1528
  if (!t || Array.isArray(t) && t.length === 0)
1292
1529
  return !1;
1293
- const e = j(s);
1294
- return (Array.isArray(t) ? t : [t]).some((r) => y(e, r, { dot: !0 }));
1530
+ const e = T(s);
1531
+ return (Array.isArray(t) ? t : [t]).some((r) => S(e, r, { dot: !0 }));
1295
1532
  }
1296
- function ke(s) {
1297
- const t = j(s), e = $(t), n = [];
1533
+ function St(s) {
1534
+ const t = T(s), e = D(t), n = [];
1298
1535
  for (const r of e)
1299
1536
  if (!(r === "." || r === ""))
1300
1537
  if (r === "..") {
@@ -1305,20 +1542,20 @@ function ke(s) {
1305
1542
  n.push(r);
1306
1543
  return Z(n);
1307
1544
  }
1308
- function Ge(s) {
1309
- const t = z(s), e = t.lastIndexOf(".");
1545
+ function is(s) {
1546
+ const t = I(s), e = t.lastIndexOf(".");
1310
1547
  return e <= 0 || e === t.length - 1 ? "" : t.slice(e);
1311
1548
  }
1312
- function Ve(s, t = "utf-8") {
1313
- return typeof s == "string" ? $e(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1549
+ function os(s, t = "utf-8") {
1550
+ return typeof s == "string" ? We(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1314
1551
  }
1315
- async function Le(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1552
+ async function Ve(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1316
1553
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1317
1554
  throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
1318
1555
  const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1319
1556
  return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1320
1557
  }
1321
- function Ye(s, t) {
1558
+ function as(s, t) {
1322
1559
  if (s.length !== t.length)
1323
1560
  return !1;
1324
1561
  for (let e = 0; e < s.length; e++)
@@ -1326,13 +1563,13 @@ function Ye(s, t) {
1326
1563
  return !1;
1327
1564
  return !0;
1328
1565
  }
1329
- async function ze(s) {
1566
+ async function cs(s) {
1330
1567
  const t = await s.arrayBuffer();
1331
1568
  return new Uint8Array(t);
1332
1569
  }
1333
- async function je(s, t, e = {}) {
1334
- const n = z(t);
1335
- return Pe(t, async () => {
1570
+ async function Ye(s, t, e = {}) {
1571
+ const n = I(t);
1572
+ return Et(t, async () => {
1336
1573
  const r = e.recursive ?? !1, i = e.force ?? !1;
1337
1574
  try {
1338
1575
  await s.removeEntry(n, { recursive: r });
@@ -1340,45 +1577,45 @@ async function je(s, t, e = {}) {
1340
1577
  if (o.name === "NotFoundError" && i)
1341
1578
  return;
1342
1579
  const a = o.name === "TypeMismatchError" && !r;
1343
- throw O(o, {
1580
+ throw v(o, {
1344
1581
  path: t,
1345
1582
  operation: "remove",
1346
1583
  isDirectory: a
1347
1584
  });
1348
1585
  }
1349
- });
1586
+ }, e.root ?? "/");
1350
1587
  }
1351
- function Ze(s, t, e, n) {
1588
+ function ls(s, t, e, n) {
1352
1589
  if (!Number.isInteger(t) || !Number.isInteger(e))
1353
- throw new D("argument", "Invalid offset or length");
1590
+ throw new $("argument", "Invalid offset or length");
1354
1591
  if (t < 0 || e < 0)
1355
- throw new D("argument", "Negative offset or length not allowed");
1592
+ throw new $("argument", "Negative offset or length not allowed");
1356
1593
  if (t + e > s)
1357
- throw new D("overflow", "Operation would overflow buffer");
1594
+ throw new $("overflow", "Operation would overflow buffer");
1358
1595
  if (n != null && (!Number.isInteger(n) || n < 0))
1359
- throw new D("argument", "Invalid position");
1596
+ throw new $("argument", "Invalid position");
1360
1597
  }
1361
- function Je(s, t, e) {
1598
+ function hs(s, t, e) {
1362
1599
  try {
1363
1600
  t.flush(), t.close();
1364
1601
  } catch (n) {
1365
1602
  console.warn(`Warning: Failed to properly close file descriptor ${s} (${e}):`, n);
1366
1603
  }
1367
1604
  }
1368
- function Xe(s, t, e) {
1605
+ function us(s, t, e) {
1369
1606
  if (s >= e)
1370
1607
  return { isEOF: !0, actualLength: 0 };
1371
1608
  const n = Math.min(t, e - s);
1372
1609
  return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1373
1610
  }
1374
- async function Ke(s, t) {
1611
+ async function fs(s, t) {
1375
1612
  try {
1376
1613
  return await s.createSyncAccessHandle();
1377
1614
  } catch (e) {
1378
- throw O(e, { path: t, isDirectory: !1 });
1615
+ throw v(e, { path: t, isDirectory: !1 });
1379
1616
  }
1380
1617
  }
1381
- class Qe {
1618
+ class ps {
1382
1619
  /** Root directory handle for the file system */
1383
1620
  root;
1384
1621
  /** Map of watched paths and options */
@@ -1407,7 +1644,7 @@ class Qe {
1407
1644
  if (!this.options.broadcastChannel)
1408
1645
  return;
1409
1646
  const e = t.path;
1410
- if (![...this.watchers.values()].some((i) => _(e, i.pattern) && i.include.some((o) => o && _(e, o)) && !i.exclude.some((o) => o && _(e, o))))
1647
+ if (![...this.watchers.values()].some((i) => B(e, i.pattern) && i.include.some((o) => o && B(e, o)) && !i.exclude.some((o) => o && B(e, o))))
1411
1648
  return;
1412
1649
  let r;
1413
1650
  if (this.options.hashAlgorithm)
@@ -1429,7 +1666,11 @@ class Qe {
1429
1666
  }
1430
1667
  }
1431
1668
  constructor(t) {
1432
- Ie(), t && this.setOptions(t);
1669
+ Ge(), t && this.setOptions(t);
1670
+ }
1671
+ /** Exclusive path lock keyed by absolute OPFS path (`root` + API path). */
1672
+ async withPathLock(t, e) {
1673
+ return Et(t, e, this.options.root);
1433
1674
  }
1434
1675
  /**
1435
1676
  * Initialize the file system within a given directory.
@@ -1442,7 +1683,7 @@ class Qe {
1442
1683
  const r = await navigator.storage.getDirectory();
1443
1684
  this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1444
1685
  } catch (r) {
1445
- n(new bt(t, r));
1686
+ n(new Dt(t, r));
1446
1687
  } finally {
1447
1688
  this.mountingPromise = null;
1448
1689
  }
@@ -1459,7 +1700,7 @@ class Qe {
1459
1700
  * @param options.broadcastChannel - Custom name for the broadcast channel
1460
1701
  */
1461
1702
  async setOptions(t) {
1462
- 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 = j(t.root), this.options.namespace || (this.options.namespace = `opfs-worker:${this.options.root}`), await this.mount());
1703
+ 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(t.root), this.options.namespace || (this.options.namespace = `opfs-worker:${this.options.root}`), await this.mount());
1463
1704
  }
1464
1705
  /**
1465
1706
  * Get a directory handle from a path
@@ -1480,7 +1721,7 @@ class Qe {
1480
1721
  * ```
1481
1722
  */
1482
1723
  async getDirectoryHandle(t, e = !1, n = this.root) {
1483
- const r = Array.isArray(t) ? t : $(t);
1724
+ const r = Array.isArray(t) ? t : D(t);
1484
1725
  let i = n;
1485
1726
  for (const o of r)
1486
1727
  i = await i.getDirectoryHandle(o, { create: e });
@@ -1506,9 +1747,9 @@ class Qe {
1506
1747
  * ```
1507
1748
  */
1508
1749
  async getFileHandle(t, e = !1, n = this.root) {
1509
- const r = $(t);
1750
+ const r = D(t);
1510
1751
  if (r.length === 0)
1511
- throw new yt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1752
+ throw new At("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1512
1753
  const i = r.pop();
1513
1754
  return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1514
1755
  }
@@ -1576,17 +1817,17 @@ class Qe {
1576
1817
  */
1577
1818
  async mkdir(t, e) {
1578
1819
  await this.mount();
1579
- const n = e?.recursive ?? !1, r = $(t);
1820
+ const n = e?.recursive ?? !1, r = D(t);
1580
1821
  let i = this.root;
1581
1822
  for (let o = 0; o < r.length; o++) {
1582
1823
  const a = r[o];
1583
1824
  try {
1584
1825
  i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1585
1826
  } catch (c) {
1586
- throw c.name === "NotFoundError" ? O(c, {
1827
+ throw c.name === "NotFoundError" ? v(c, {
1587
1828
  path: Z(r.slice(0, o + 1)),
1588
1829
  existenceType: "directory"
1589
- }) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new U("create directory", a, c);
1830
+ }) : c.name === "TypeMismatchError" ? v(c, { path: a, isDirectory: !1 }) : new j("create directory", a, c);
1590
1831
  }
1591
1832
  }
1592
1833
  await this.notifyChange({ path: t, type: N.Added, isDirectory: !0 });
@@ -1623,10 +1864,10 @@ class Qe {
1623
1864
  isFile: !1,
1624
1865
  isDirectory: !0
1625
1866
  };
1626
- const e = z(t);
1867
+ const e = I(t);
1627
1868
  let n;
1628
1869
  try {
1629
- n = await this.getDirectoryHandle(H(t), !1);
1870
+ n = await this.getDirectoryHandle(_(t), !1);
1630
1871
  const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1631
1872
  kind: "file",
1632
1873
  size: o.size,
@@ -1639,7 +1880,7 @@ class Qe {
1639
1880
  a.hash = `${o.lastModified.toString(36)}-${o.size.toString(36)}`;
1640
1881
  else if (typeof r == "string")
1641
1882
  try {
1642
- const c = await Le(o, r, this.options.maxFileSize);
1883
+ const c = await Ve(o, r, this.options.maxFileSize);
1643
1884
  a.hash = c;
1644
1885
  } catch (c) {
1645
1886
  console.warn(`Failed to calculate hash for ${t}:`, c);
@@ -1647,9 +1888,9 @@ class Qe {
1647
1888
  return a;
1648
1889
  } catch (r) {
1649
1890
  if (r.name === "NotFoundError")
1650
- throw new k("file", t, r);
1891
+ throw new P("file", t, r);
1651
1892
  if (r.name !== "TypeMismatchError")
1652
- throw new U("stat", t, r);
1893
+ throw new j("stat", t, r);
1653
1894
  }
1654
1895
  try {
1655
1896
  return await n.getDirectoryHandle(e, { create: !1 }), {
@@ -1661,7 +1902,7 @@ class Qe {
1661
1902
  isDirectory: !0
1662
1903
  };
1663
1904
  } catch (r) {
1664
- throw new U("stat", t, r);
1905
+ throw new j("stat", t, r);
1665
1906
  }
1666
1907
  }
1667
1908
  /**
@@ -1713,10 +1954,10 @@ class Qe {
1713
1954
  async exists(t) {
1714
1955
  if (await this.mount(), t === "/")
1715
1956
  return !0;
1716
- const e = z(t);
1957
+ const e = I(t);
1717
1958
  let n = null;
1718
1959
  try {
1719
- n = await this.getDirectoryHandle(H(t), !1);
1960
+ n = await this.getDirectoryHandle(_(t), !1);
1720
1961
  } catch (r) {
1721
1962
  if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1722
1963
  throw r;
@@ -1766,7 +2007,7 @@ class Qe {
1766
2007
  }
1767
2008
  await this.notifyChange({ path: t, type: N.Changed, isDirectory: !0 });
1768
2009
  } catch (e) {
1769
- throw e instanceof m ? e : O(e, { path: t, isDirectory: !0 });
2010
+ throw e instanceof m ? e : v(e, { path: t, isDirectory: !0 });
1770
2011
  }
1771
2012
  }
1772
2013
  /**
@@ -1795,9 +2036,9 @@ class Qe {
1795
2036
  */
1796
2037
  async remove(t, e) {
1797
2038
  if (await this.mount(), t === "/")
1798
- throw new G("EROOT", t);
1799
- const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(H(t), !1), o = await this.stat(t);
1800
- await je(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: o.isDirectory });
2039
+ throw new H("EROOT", t);
2040
+ const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(_(t), !1), o = await this.stat(t);
2041
+ await Ye(i, t, { recursive: n, force: r, root: this.options.root }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: o.isDirectory });
1801
2042
  }
1802
2043
  /**
1803
2044
  * Resolve a path to an absolute path
@@ -1820,12 +2061,12 @@ class Qe {
1820
2061
  async realpath(t) {
1821
2062
  await this.mount();
1822
2063
  try {
1823
- const e = ke(t);
2064
+ const e = St(t);
1824
2065
  if (!await this.exists(e))
1825
- throw new k("file", e);
2066
+ throw new P("file", e);
1826
2067
  return e;
1827
2068
  } catch (e) {
1828
- throw e instanceof m ? e : O(e, { path: t });
2069
+ throw e instanceof m ? e : v(e, { path: t });
1829
2070
  }
1830
2071
  }
1831
2072
  /**
@@ -1855,10 +2096,10 @@ class Qe {
1855
2096
  try {
1856
2097
  const r = n?.overwrite ?? !1, i = await this.stat(t);
1857
2098
  if (await this.exists(e) && !r)
1858
- throw new X(e);
2099
+ throw new Q(e);
1859
2100
  await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: N.Added, isDirectory: i.isDirectory });
1860
2101
  } catch (r) {
1861
- throw r instanceof m ? r : O(r, { path: t });
2102
+ throw r instanceof m ? r : v(r, { path: t });
1862
2103
  }
1863
2104
  }
1864
2105
  /**
@@ -1891,24 +2132,24 @@ class Qe {
1891
2132
  try {
1892
2133
  const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
1893
2134
  if (!await this.exists(t))
1894
- throw new k("source", t);
2135
+ throw new P("source", t);
1895
2136
  if (await this.exists(e) && !i)
1896
- throw new X(e);
2137
+ throw new Q(e);
1897
2138
  if ((await this.stat(t)).isFile) {
1898
2139
  const l = await this.readFile(t);
1899
2140
  await this.writeFile(e, l);
1900
2141
  } else {
1901
2142
  if (!r)
1902
- throw new q("directory", t);
2143
+ throw new U("directory", t);
1903
2144
  await this.mkdir(e, { recursive: !0 });
1904
2145
  const l = await this.readDir(t);
1905
- for (const h of l) {
1906
- const d = `${t}/${h.name}`, u = `${e}/${h.name}`;
1907
- await this.copy(d, u, { recursive: !0, overwrite: i });
2146
+ for (const u of l) {
2147
+ const h = `${t}/${u.name}`, f = `${e}/${u.name}`;
2148
+ await this.copy(h, f, { recursive: !0, overwrite: i });
1908
2149
  }
1909
2150
  }
1910
2151
  } catch (r) {
1911
- throw r instanceof m ? r : O(r, { path: t });
2152
+ throw r instanceof m ? r : v(r, { path: t });
1912
2153
  }
1913
2154
  }
1914
2155
  /**
@@ -1938,9 +2179,9 @@ class Qe {
1938
2179
  */
1939
2180
  async watch(t, e) {
1940
2181
  if (!this.options.broadcastChannel)
1941
- throw new it("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2182
+ throw new ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
1942
2183
  const n = {
1943
- pattern: Re(t, e?.recursive ?? !0),
2184
+ pattern: Xe(t, e?.recursive ?? !0),
1944
2185
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
1945
2186
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
1946
2187
  };
@@ -1953,32 +2194,90 @@ class Qe {
1953
2194
  this.watchers.delete(t);
1954
2195
  }
1955
2196
  /**
1956
- * Bulk-create files from `[path, data]` entries (strings, bytes, or Blobs).
2197
+ * Read a file as a `Blob` without copying its bytes into memory.
1957
2198
  *
1958
- * @param entries - Array of `[path, data]` tuples
2199
+ * OPFS hands back a disk-backed `File`, so the browser can stream it on
2200
+ * demand — pass it to `URL.createObjectURL()` for `<video>` / `<audio>` /
2201
+ * `<img>` and only the played range is actually read. Structured clone keeps
2202
+ * the reference intact when the file system runs in a worker.
2203
+ *
2204
+ * @param path - Path to the file
2205
+ * @returns Lazy `File` handle backed by OPFS storage
2206
+ * @throws {OPFSError} If the path is missing or is a directory
2207
+ *
2208
+ * @example
2209
+ * ```typescript
2210
+ * const blob = await fs.readBlob('/media/clip.mp4');
2211
+ * video.src = URL.createObjectURL(blob);
2212
+ * ```
2213
+ */
2214
+ async readBlob(t) {
2215
+ await this.mount();
2216
+ try {
2217
+ return await (await this.getFileHandle(t, !1)).getFile();
2218
+ } catch (e) {
2219
+ throw e instanceof m ? e : v(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
2220
+ }
2221
+ }
2222
+ /**
2223
+ * Bulk-import files from `[path, data]` entries (strings, bytes, Blobs, or Files).
2224
+ * Each entry is written via {@link writeStream} so large Blobs/Files are not
2225
+ * fully buffered in memory.
2226
+ *
2227
+ * Accepts an array of tuples, a `Map`, or any iterable of `[path, data]` pairs.
2228
+ *
2229
+ * @param entries - Files to write
2230
+ * @param onProgress - Per-chunk progress with path, index, and byte counts
2231
+ * @returns Written paths, count, and total bytes
1959
2232
  * @throws {OPFSError} If a write fails
1960
2233
  *
1961
2234
  * @example
1962
2235
  * ```typescript
1963
- * await fs.createIndex([
2236
+ * const result = await fs.importFiles([
1964
2237
  * ['/config.json', JSON.stringify({ theme: 'dark' })],
1965
2238
  * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
1966
- * ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })],
1967
- * ]);
2239
+ * ['/upload.txt', fileFromInput],
2240
+ * ], (p) => console.log(`${p.path}: ${p.bytesWritten}/${p.bytesTotal}`));
2241
+ *
2242
+ * console.log(result.count, result.bytesWritten, result.paths);
1968
2243
  * ```
1969
2244
  */
1970
- async createIndex(t) {
2245
+ async importFiles(t, e) {
1971
2246
  await this.mount();
2247
+ const n = [...t].map(([c, l]) => [T(c), l]), r = n.length, i = n.map(([c]) => c), o = n.reduce((c, [, l]) => c + Ze(l), 0);
2248
+ let a = 0;
1972
2249
  try {
1973
- for (const [e, n] of t) {
1974
- const r = j(e);
1975
- let i;
1976
- n instanceof Blob ? i = await ze(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2250
+ for (let c = 0; c < r; c++) {
2251
+ const [l, u] = n[c], { stream: h, size: f } = Je(u), d = a, g = await this.writeStream(
2252
+ l,
2253
+ h,
2254
+ e ? (p) => e({
2255
+ path: l,
2256
+ index: c,
2257
+ count: r,
2258
+ bytesWritten: p,
2259
+ bytesTotal: f,
2260
+ totalBytesWritten: d + p,
2261
+ totalBytes: o
2262
+ }) : void 0
2263
+ );
2264
+ a += g;
1977
2265
  }
1978
- } catch (e) {
1979
- throw e instanceof m ? e : O(e);
2266
+ return {
2267
+ paths: i,
2268
+ count: r,
2269
+ bytesWritten: a
2270
+ };
2271
+ } catch (c) {
2272
+ throw c instanceof m ? c : v(c);
1980
2273
  }
1981
2274
  }
2275
+ /**
2276
+ * @deprecated Use {@link importFiles} instead.
2277
+ */
2278
+ async createIndex(t) {
2279
+ Qe(), await this.importFiles(t);
2280
+ }
1982
2281
  /**
1983
2282
  * Dispose of resources and clean up the file system instance
1984
2283
  */
@@ -1986,51 +2285,72 @@ class Qe {
1986
2285
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
1987
2286
  }
1988
2287
  }
2288
+ function Ze(s) {
2289
+ return typeof s == "string" ? new TextEncoder().encode(s).byteLength : s instanceof Blob ? s.size : s.byteLength;
2290
+ }
2291
+ function Je(s) {
2292
+ if (s instanceof Blob)
2293
+ return { stream: s.stream(), size: s.size };
2294
+ const t = typeof s == "string" ? new TextEncoder().encode(s) : s;
2295
+ return {
2296
+ size: t.byteLength,
2297
+ stream: new ReadableStream({
2298
+ start(e) {
2299
+ e.enqueue(t), e.close();
2300
+ }
2301
+ })
2302
+ };
2303
+ }
2304
+ let at = !1;
2305
+ function Qe() {
2306
+ at || (at = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
2307
+ }
1989
2308
  export {
1990
- X as A,
1991
- Qe as B,
1992
- Ze as C,
1993
- G as D,
1994
- k as E,
1995
- xt as F,
1996
- Je as G,
1997
- Xe as H,
2309
+ Q as A,
2310
+ ps as B,
2311
+ Ye as C,
2312
+ H as D,
2313
+ P as E,
2314
+ $t as F,
2315
+ ls as G,
2316
+ hs as H,
1998
2317
  J as I,
1999
- Ke as J,
2000
- Ne as K,
2001
- He as L,
2002
- $e as M,
2003
- _e as N,
2318
+ us as J,
2319
+ fs as K,
2320
+ je as L,
2321
+ ss as M,
2322
+ We as N,
2004
2323
  m as O,
2005
- yt as P,
2006
- St as S,
2007
- D as V,
2324
+ At as P,
2325
+ ns as Q,
2326
+ Ot as S,
2327
+ $ as V,
2008
2328
  N as W,
2009
- wt as a,
2010
- Et as b,
2011
- q as c,
2012
- vt as d,
2013
- it as e,
2014
- bt as f,
2015
- U as g,
2016
- We as h,
2017
- Ie as i,
2018
- Z as j,
2019
- z as k,
2020
- H as l,
2021
- O as m,
2022
- j as n,
2023
- Re as o,
2024
- _ as p,
2025
- qe as q,
2026
- ke as r,
2027
- $ as s,
2028
- Ge as t,
2029
- Ve as u,
2030
- Le as v,
2031
- Pe as w,
2032
- Ye as x,
2033
- ze as y,
2034
- je as z
2329
+ xt as a,
2330
+ vt as b,
2331
+ U as c,
2332
+ Nt as d,
2333
+ ct as e,
2334
+ Dt as f,
2335
+ j as g,
2336
+ Ke as h,
2337
+ Ge as i,
2338
+ qe as j,
2339
+ Z as k,
2340
+ I as l,
2341
+ v as m,
2342
+ _ as n,
2343
+ T as o,
2344
+ Xe as p,
2345
+ B as q,
2346
+ rs as r,
2347
+ D as s,
2348
+ St as t,
2349
+ is as u,
2350
+ os as v,
2351
+ Et as w,
2352
+ Ve as x,
2353
+ as as y,
2354
+ cs as z
2035
2355
  };
2036
- //# sourceMappingURL=BaseOPFS-Cylz6ijk.js.map
2356
+ //# sourceMappingURL=BaseOPFS-C3NE4BKr.js.map