opfs-worker 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +62 -439
  2. package/dist/BaseOPFS-BPw9AIQ-.cjs +4 -0
  3. package/dist/BaseOPFS-BPw9AIQ-.cjs.map +1 -0
  4. package/dist/BaseOPFS-Cylz6ijk.js +2036 -0
  5. package/dist/BaseOPFS-Cylz6ijk.js.map +1 -0
  6. package/dist/OPFSAsync-BKSAJJeh.js +124 -0
  7. package/dist/OPFSAsync-BKSAJJeh.js.map +1 -0
  8. package/dist/OPFSAsync-s2P7y3sw.cjs +2 -0
  9. package/dist/OPFSAsync-s2P7y3sw.cjs.map +1 -0
  10. package/dist/OPFSFacade-DePnNRgt.cjs +2 -0
  11. package/dist/OPFSFacade-DePnNRgt.cjs.map +1 -0
  12. package/dist/OPFSFacade-XohWlHuu.js +281 -0
  13. package/dist/OPFSFacade-XohWlHuu.js.map +1 -0
  14. package/dist/OPFSSync-C7KBepe_.cjs +2 -0
  15. package/dist/OPFSSync-C7KBepe_.cjs.map +1 -0
  16. package/dist/OPFSSync-CsSQkpk5.js +208 -0
  17. package/dist/OPFSSync-CsSQkpk5.js.map +1 -0
  18. package/dist/assets/dedicated.worker-nY3tK4zi.js.map +1 -0
  19. package/dist/{OPFSWorker.d.ts → core/BaseOPFS.d.ts} +34 -304
  20. package/dist/core/BaseOPFS.d.ts.map +1 -0
  21. package/dist/core/OPFSAsync.d.ts +55 -0
  22. package/dist/core/OPFSAsync.d.ts.map +1 -0
  23. package/dist/core/OPFSSync.d.ts +54 -0
  24. package/dist/core/OPFSSync.d.ts.map +1 -0
  25. package/dist/createOPFSAsync-BwKDmHsy.cjs +2 -0
  26. package/dist/createOPFSAsync-BwKDmHsy.cjs.map +1 -0
  27. package/dist/createOPFSAsync-Y4Mg6qte.js +10 -0
  28. package/dist/createOPFSAsync-Y4Mg6qte.js.map +1 -0
  29. package/dist/createOPFSDedicated-CsnV6MLP.js +2333 -0
  30. package/dist/createOPFSDedicated-CsnV6MLP.js.map +1 -0
  31. package/dist/createOPFSDedicated-pKTRWLdz.cjs +2283 -0
  32. package/dist/createOPFSDedicated-pKTRWLdz.cjs.map +1 -0
  33. package/dist/createOPFSShared-CGdd__PH.js +23 -0
  34. package/dist/createOPFSShared-CGdd__PH.js.map +1 -0
  35. package/dist/createOPFSShared-CskROt7U.cjs +2 -0
  36. package/dist/createOPFSShared-CskROt7U.cjs.map +1 -0
  37. package/dist/dedicated.worker.js +2281 -0
  38. package/dist/dedicated.worker.js.map +1 -0
  39. package/dist/{OPFSFacade.d.ts → facade/OPFSFacade.d.ts} +31 -23
  40. package/dist/facade/OPFSFacade.d.ts.map +1 -0
  41. package/dist/facade/createOPFSAsync.d.ts +16 -0
  42. package/dist/facade/createOPFSAsync.d.ts.map +1 -0
  43. package/dist/facade/createOPFSDedicated.d.ts +17 -0
  44. package/dist/facade/createOPFSDedicated.d.ts.map +1 -0
  45. package/dist/facade/createOPFSShared.d.ts +24 -0
  46. package/dist/facade/createOPFSShared.d.ts.map +1 -0
  47. package/dist/index.async.cjs +2 -0
  48. package/dist/index.async.cjs.map +1 -0
  49. package/dist/index.async.d.ts +10 -0
  50. package/dist/index.async.d.ts.map +1 -0
  51. package/dist/index.async.js +55 -0
  52. package/dist/index.async.js.map +1 -0
  53. package/dist/index.cjs +1 -2477
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.ts +17 -3
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +61 -2828
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.pure.cjs +1 -1
  60. package/dist/index.pure.cjs.map +1 -1
  61. package/dist/index.pure.d.ts +3 -1
  62. package/dist/index.pure.d.ts.map +1 -1
  63. package/dist/index.pure.js +50 -1053
  64. package/dist/index.pure.js.map +1 -1
  65. package/dist/index.sharedworker.cjs +2 -0
  66. package/dist/index.sharedworker.cjs.map +1 -0
  67. package/dist/index.sharedworker.d.ts +11 -0
  68. package/dist/index.sharedworker.d.ts.map +1 -0
  69. package/dist/index.sharedworker.js +55 -0
  70. package/dist/index.sharedworker.js.map +1 -0
  71. package/dist/index.sync.cjs +2 -0
  72. package/dist/index.sync.cjs.map +1 -0
  73. package/dist/index.sync.d.ts +11 -0
  74. package/dist/index.sync.d.ts.map +1 -0
  75. package/dist/index.sync.js +55 -0
  76. package/dist/index.sync.js.map +1 -0
  77. package/dist/shared.worker.js +2166 -0
  78. package/dist/shared.worker.js.map +1 -0
  79. package/dist/types.d.ts +9 -4
  80. package/dist/types.d.ts.map +1 -1
  81. package/dist/worker/createDedicatedWorker.d.ts +30 -0
  82. package/dist/worker/createDedicatedWorker.d.ts.map +1 -0
  83. package/dist/worker/createSharedWorker.d.ts +37 -0
  84. package/dist/worker/createSharedWorker.d.ts.map +1 -0
  85. package/dist/worker/dedicated.worker.d.ts +2 -0
  86. package/dist/worker/dedicated.worker.d.ts.map +1 -0
  87. package/dist/worker/shared.worker.d.ts +2 -0
  88. package/dist/worker/shared.worker.d.ts.map +1 -0
  89. package/docs/README.md +30 -0
  90. package/docs/api/backend.md +36 -0
  91. package/docs/api/create.md +82 -0
  92. package/docs/api/facade.md +52 -0
  93. package/docs/choosing-a-mode.md +41 -0
  94. package/docs/file-descriptors.md +8 -9
  95. package/docs/guides/async.md +36 -0
  96. package/docs/guides/dedicated.md +76 -0
  97. package/docs/guides/hashing.md +34 -0
  98. package/docs/guides/pure.md +46 -0
  99. package/docs/guides/sharedworker.md +57 -0
  100. package/docs/guides/streaming.md +51 -0
  101. package/docs/guides/watching.md +35 -0
  102. package/docs/migration.md +41 -0
  103. package/docs/types.md +20 -6
  104. package/package.json +42 -3
  105. package/src/{OPFSWorker.ts → core/BaseOPFS.ts} +54 -647
  106. package/src/core/OPFSAsync.ts +248 -0
  107. package/src/core/OPFSSync.ts +460 -0
  108. package/src/{OPFSFacade.ts → facade/OPFSFacade.ts} +83 -54
  109. package/src/facade/createOPFSAsync.ts +22 -0
  110. package/src/facade/createOPFSDedicated.ts +23 -0
  111. package/src/facade/createOPFSShared.ts +30 -0
  112. package/src/index.async.ts +11 -0
  113. package/src/index.pure.ts +3 -2
  114. package/src/index.sharedworker.ts +12 -0
  115. package/src/index.sync.ts +12 -0
  116. package/src/index.ts +37 -8
  117. package/src/types.ts +8 -4
  118. package/src/worker/createDedicatedWorker.ts +74 -0
  119. package/src/worker/createSharedWorker.ts +67 -0
  120. package/src/worker/dedicated.worker.ts +13 -0
  121. package/src/worker/shared.worker.ts +17 -0
  122. package/dist/OPFSFacade.d.ts.map +0 -1
  123. package/dist/OPFSWorker.d.ts.map +0 -1
  124. package/dist/assets/worker.entry-DUlEoroc.js.map +0 -1
  125. package/dist/createOPFSWorker.d.ts +0 -17
  126. package/dist/createOPFSWorker.d.ts.map +0 -1
  127. package/dist/helpers-DNj8ZoMu.cjs +0 -4
  128. package/dist/helpers-DNj8ZoMu.cjs.map +0 -1
  129. package/dist/helpers-WY2jfbOT.js +0 -1427
  130. package/dist/helpers-WY2jfbOT.js.map +0 -1
  131. package/dist/worker.entry.d.ts +0 -2
  132. package/dist/worker.entry.d.ts.map +0 -1
  133. package/docs/api-reference.md +0 -815
  134. package/src/createOPFSWorker.ts +0 -57
  135. package/src/worker.entry.ts +0 -6
package/dist/index.cjs CHANGED
@@ -1,2478 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./helpers-DNj8ZoMu.cjs"),m=require("comlink"),p=`/**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- const bt = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
7
- canHandle: (s) => Ot(s) && s[bt],
8
- serialize(s) {
9
- const { port1: t, port2: e } = new MessageChannel();
10
- return ot(s, t), [e, [e]];
11
- },
12
- deserialize(s) {
13
- return s.start(), Gt(s);
14
- }
15
- }, _t = {
16
- canHandle: (s) => Ot(s) && j in s,
17
- serialize({ value: s }) {
18
- let t;
19
- return s instanceof Error ? t = {
20
- isError: !0,
21
- value: {
22
- message: s.message,
23
- name: s.name,
24
- stack: s.stack
25
- }
26
- } : t = { isError: !1, value: s }, [t, []];
27
- },
28
- deserialize(s) {
29
- throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
30
- }
31
- }, Dt = /* @__PURE__ */ new Map([
32
- ["proxy", jt],
33
- ["throw", _t]
34
- ]);
35
- function Ut(s, t) {
36
- for (const e of s)
37
- if (t === e || e === "*" || e instanceof RegExp && e.test(t))
38
- return !0;
39
- return !1;
40
- }
41
- function ot(s, t = globalThis, e = ["*"]) {
42
- t.addEventListener("message", function n(r) {
43
- if (!r || !r.data)
44
- return;
45
- if (!Ut(e, r.origin)) {
46
- console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
47
- return;
48
- }
49
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(C);
50
- let h;
51
- try {
52
- const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
53
- switch (o) {
54
- case "GET":
55
- h = f;
56
- break;
57
- case "SET":
58
- l[a.slice(-1)[0]] = C(r.data.value), h = !0;
59
- break;
60
- case "APPLY":
61
- h = f.apply(l, c);
62
- break;
63
- case "CONSTRUCT":
64
- {
65
- const u = new f(...c);
66
- h = Zt(u);
67
- }
68
- break;
69
- case "ENDPOINT":
70
- {
71
- const { port1: u, port2: d } = new MessageChannel();
72
- ot(s, d), h = _(u, [u]);
73
- }
74
- break;
75
- case "RELEASE":
76
- h = void 0;
77
- break;
78
- default:
79
- return;
80
- }
81
- } catch (l) {
82
- h = { value: l, [j]: 0 };
83
- }
84
- Promise.resolve(h).catch((l) => ({ value: l, [j]: 0 })).then((l) => {
85
- const [f, u] = V(l);
86
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), At(t), X in s && typeof s[X] == "function" && s[X]());
87
- }).catch((l) => {
88
- const [f, u] = V({
89
- value: new TypeError("Unserializable return value"),
90
- [j]: 0
91
- });
92
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
93
- });
94
- }), t.start && t.start();
95
- }
96
- function Bt(s) {
97
- return s.constructor.name === "MessagePort";
98
- }
99
- function At(s) {
100
- Bt(s) && s.close();
101
- }
102
- function Gt(s, t) {
103
- const e = /* @__PURE__ */ new Map();
104
- return s.addEventListener("message", function(r) {
105
- const { data: i } = r;
106
- if (!i || !i.id)
107
- return;
108
- const o = e.get(i.id);
109
- if (o)
110
- try {
111
- o(i);
112
- } finally {
113
- e.delete(i.id);
114
- }
115
- }), st(s, e, [], t);
116
- }
117
- function L(s) {
118
- if (s)
119
- throw new Error("Proxy has been released and is not useable");
120
- }
121
- function vt(s) {
122
- return $(s, /* @__PURE__ */ new Map(), {
123
- type: "RELEASE"
124
- }).then(() => {
125
- At(s);
126
- });
127
- }
128
- const G = /* @__PURE__ */ new WeakMap(), q = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
- const t = (G.get(s) || 0) - 1;
130
- G.set(s, t), t === 0 && vt(s);
131
- });
132
- function qt(s, t) {
133
- const e = (G.get(t) || 0) + 1;
134
- G.set(t, e), q && q.register(s, t, s);
135
- }
136
- function Vt(s) {
137
- q && q.unregister(s);
138
- }
139
- function st(s, t, e = [], n = function() {
140
- }) {
141
- let r = !1;
142
- const i = new Proxy(n, {
143
- get(o, a) {
144
- if (L(r), a === Wt)
145
- return () => {
146
- Vt(i), vt(s), t.clear(), r = !0;
147
- };
148
- if (a === "then") {
149
- if (e.length === 0)
150
- return { then: () => i };
151
- const c = $(s, t, {
152
- type: "GET",
153
- path: e.map((h) => h.toString())
154
- }).then(C);
155
- return c.then.bind(c);
156
- }
157
- return st(s, t, [...e, a]);
158
- },
159
- set(o, a, c) {
160
- L(r);
161
- const [h, l] = V(c);
162
- return $(s, t, {
163
- type: "SET",
164
- path: [...e, a].map((f) => f.toString()),
165
- value: h
166
- }, l).then(C);
167
- },
168
- apply(o, a, c) {
169
- L(r);
170
- const h = e[e.length - 1];
171
- if (h === zt)
172
- return $(s, t, {
173
- type: "ENDPOINT"
174
- }).then(C);
175
- if (h === "bind")
176
- return st(s, t, e.slice(0, -1));
177
- const [l, f] = ht(c);
178
- return $(s, t, {
179
- type: "APPLY",
180
- path: e.map((u) => u.toString()),
181
- argumentList: l
182
- }, f).then(C);
183
- },
184
- construct(o, a) {
185
- L(r);
186
- const [c, h] = ht(a);
187
- return $(s, t, {
188
- type: "CONSTRUCT",
189
- path: e.map((l) => l.toString()),
190
- argumentList: c
191
- }, h).then(C);
192
- }
193
- });
194
- return qt(i, s), i;
195
- }
196
- function Yt(s) {
197
- return Array.prototype.concat.apply([], s);
198
- }
199
- function ht(s) {
200
- const t = s.map(V);
201
- return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
202
- }
203
- const Nt = /* @__PURE__ */ new WeakMap();
204
- function _(s, t) {
205
- return Nt.set(s, t), s;
206
- }
207
- function Zt(s) {
208
- return Object.assign(s, { [bt]: !0 });
209
- }
210
- function V(s) {
211
- for (const [t, e] of Dt)
212
- if (e.canHandle(s)) {
213
- const [n, r] = e.serialize(s);
214
- return [
215
- {
216
- type: "HANDLER",
217
- name: t,
218
- value: n
219
- },
220
- r
221
- ];
222
- }
223
- return [
224
- {
225
- type: "RAW",
226
- value: s
227
- },
228
- Nt.get(s) || []
229
- ];
230
- }
231
- function C(s) {
232
- switch (s.type) {
233
- case "HANDLER":
234
- return Dt.get(s.name).deserialize(s.value);
235
- case "RAW":
236
- return s.value;
237
- }
238
- }
239
- function $(s, t, e, n) {
240
- return new Promise((r) => {
241
- const i = Xt();
242
- t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
243
- });
244
- }
245
- function Xt() {
246
- return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
- }
248
- var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
249
- const Jt = {
250
- ENOENT: -2,
251
- // No such file or directory
252
- EISDIR: -21,
253
- // Is a directory
254
- ENOTDIR: -20,
255
- // Not a directory
256
- EACCES: -13,
257
- // Permission denied
258
- EEXIST: -17,
259
- // File exists
260
- ENOTEMPTY: -39,
261
- // Directory not empty
262
- EINVAL: -22,
263
- // Invalid argument
264
- EIO: -5,
265
- // I/O error
266
- ENOSPC: -28,
267
- // No space left on device
268
- EBUSY: -16,
269
- // Device or resource busy
270
- EINTR: -4,
271
- // Interrupted system call
272
- ENOTSUP: -95,
273
- // Operation not supported
274
- ERANGE: -34,
275
- // Result too large
276
- EBADF: -9,
277
- // Bad file descriptor
278
- EROOT: -1
279
- // Custom: Cannot remove root directory
280
- };
281
- class w extends Error {
282
- errno;
283
- syscall;
284
- path;
285
- constructor(t, e, n, r, i) {
286
- super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
287
- }
288
- }
289
- class Qt extends w {
290
- constructor(t) {
291
- super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
292
- }
293
- }
294
- class Kt extends w {
295
- constructor(t, e, n) {
296
- super(t, "INVALID_PATH", e, "access", n);
297
- }
298
- }
299
- class U extends w {
300
- constructor(t, e, n) {
301
- const r = {
302
- file: \`File not found: \${e}\`,
303
- directory: \`Directory not found: \${e}\`,
304
- source: \`Source does not exist: \${e}\`
305
- };
306
- super(r[t], "ENOENT", e, "access", n);
307
- }
308
- }
309
- class te extends w {
310
- constructor(t, e, n) {
311
- super(\`Permission denied for \${e} on: \${t}\`, "EACCES", t, e, n);
312
- }
313
- }
314
- class ee extends w {
315
- constructor(t, e, n) {
316
- super(t, "ENOSPC", e, "write", n);
317
- }
318
- }
319
- class se extends w {
320
- constructor(t, e) {
321
- super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
322
- }
323
- }
324
- class nt extends w {
325
- constructor(t, e, n) {
326
- const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
327
- super(r, i, e, "access", n);
328
- }
329
- }
330
- class N extends w {
331
- constructor(t, e, n, r) {
332
- const i = {
333
- argument: "EINVAL",
334
- format: "INVALID_FORMAT",
335
- descriptor: "EBADF",
336
- overflow: "ERANGE"
337
- };
338
- super(e, i[t], n, "validate", r);
339
- }
340
- }
341
- class ne extends w {
342
- constructor(t, e) {
343
- super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
344
- }
345
- }
346
- class ut extends w {
347
- constructor(t, e, n) {
348
- super(t, "EIO", e, "io", n);
349
- }
350
- }
351
- class Ct extends w {
352
- constructor(t, e) {
353
- super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
354
- }
355
- }
356
- class rt extends w {
357
- constructor(t, e, n) {
358
- const r = {
359
- RM_FAILED: \`Failed to remove entry: \${e}\`,
360
- ENOTEMPTY: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
361
- EROOT: "Cannot remove root directory"
362
- };
363
- super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", n);
364
- }
365
- }
366
- class re extends w {
367
- constructor(t, e) {
368
- super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
369
- }
370
- }
371
- class J extends w {
372
- constructor(t, e, n) {
373
- super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
374
- }
375
- }
376
- class Q extends w {
377
- constructor(t, e) {
378
- super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
379
- }
380
- }
381
- function z(s, t, e, n) {
382
- const r = \`\${s.toUpperCase()}_FAILED\`;
383
- return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
384
- }
385
- function O(s, t) {
386
- const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
387
- switch (s.name) {
388
- case "InvalidStateError":
389
- return new se(e || "unknown", s);
390
- case "QuotaExceededError":
391
- return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
392
- case "NotFoundError":
393
- return new U(r, e, s);
394
- case "TypeMismatchError":
395
- return n !== void 0 ? n ? new nt("directory", e || "unknown", s) : new nt("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
396
- case "NotAllowedError":
397
- case "SecurityError":
398
- return new te(e, "unknown", s);
399
- case "InvalidModificationError":
400
- return i === "remove" ? new rt("ENOTEMPTY", e, s) : new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
401
- case "AbortError":
402
- return new ne(e || "unknown", s);
403
- case "OperationError":
404
- return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
405
- case "TypeError":
406
- return new Ct(e || "unknown", s);
407
- default:
408
- return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
409
- }
410
- }
411
- const $t = (s, t, e) => {
412
- const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
413
- return i && {
414
- start: i[0],
415
- end: i[1],
416
- pre: e.slice(0, i[0]),
417
- body: e.slice(i[0] + n.length, i[1]),
418
- post: e.slice(i[1] + r.length)
419
- };
420
- }, ft = (s, t) => {
421
- const e = t.match(s);
422
- return e ? e[0] : null;
423
- }, ie = (s, t, e) => {
424
- let n, r, i, o, a, c = e.indexOf(s), h = e.indexOf(t, c + 1), l = c;
425
- if (c >= 0 && h > 0) {
426
- if (s === t)
427
- return [c, h];
428
- for (n = [], i = e.length; l >= 0 && !a; ) {
429
- if (l === c)
430
- n.push(l), c = e.indexOf(s, l + 1);
431
- else if (n.length === 1) {
432
- const f = n.pop();
433
- f !== void 0 && (a = [f, h]);
434
- } else
435
- r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
436
- l = c < h && c >= 0 ? c : h;
437
- }
438
- n.length && o !== void 0 && (a = [i, o]);
439
- }
440
- return a;
441
- }, Ft = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Tt = "\\0COMMA" + Math.random() + "\\0", Pt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp(Ft, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Tt, "g"), he = new RegExp(Pt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
442
- function K(s) {
443
- return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
444
- }
445
- function we(s) {
446
- return s.replace(ue, Ft).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
447
- }
448
- function ye(s) {
449
- return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
450
- }
451
- function Rt(s) {
452
- if (!s)
453
- return [""];
454
- const t = [], e = $t("{", "}", s);
455
- if (!e)
456
- return s.split(",");
457
- const { pre: n, body: r, post: i } = e, o = n.split(",");
458
- o[o.length - 1] += "{" + r + "}";
459
- const a = Rt(i);
460
- return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
461
- }
462
- function me(s) {
463
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), R(we(s), !0).map(ye)) : [];
464
- }
465
- function Ee(s) {
466
- return "{" + s + "}";
467
- }
468
- function Se(s) {
469
- return /^-?0\\d/.test(s);
470
- }
471
- function xe(s, t) {
472
- return s <= t;
473
- }
474
- function be(s, t) {
475
- return s >= t;
476
- }
477
- function R(s, t) {
478
- const e = [], n = $t("{", "}", s);
479
- if (!n)
480
- return [s];
481
- const r = n.pre, i = n.post.length ? R(n.post, !1) : [""];
482
- if (/\\$$/.test(n.pre))
483
- for (let o = 0; o < i.length; o++) {
484
- const a = r + "{" + n.body + "}" + i[o];
485
- e.push(a);
486
- }
487
- else {
488
- const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), c = o || a, h = n.body.indexOf(",") >= 0;
489
- if (!c && !h)
490
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, R(s)) : [s];
491
- let l;
492
- if (c)
493
- l = n.body.split(/\\.\\./);
494
- else if (l = Rt(n.body), l.length === 1 && l[0] !== void 0 && (l = R(l[0], !1).map(Ee), l.length === 1))
495
- return i.map((u) => n.pre + l[0] + u);
496
- let f;
497
- if (c && l[0] !== void 0 && l[1] !== void 0) {
498
- const u = K(l[0]), d = K(l[1]), g = Math.max(l[0].length, l[1].length);
499
- let p = l.length === 3 && l[2] !== void 0 ? Math.abs(K(l[2])) : 1, S = xe;
500
- d < u && (p *= -1, S = be);
501
- const M = l.some(Se);
502
- f = [];
503
- for (let x = u; S(x, d); x += p) {
504
- let y;
505
- if (a)
506
- y = String.fromCharCode(x), y === "\\\\" && (y = "");
507
- else if (y = String(x), M) {
508
- const T = g - y.length;
509
- if (T > 0) {
510
- const H = new Array(T + 1).join("0");
511
- x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
512
- }
513
- }
514
- f.push(y);
515
- }
516
- } else {
517
- f = [];
518
- for (let u = 0; u < l.length; u++)
519
- f.push.apply(f, R(l[u], !1));
520
- }
521
- for (let u = 0; u < f.length; u++)
522
- for (let d = 0; d < i.length; d++) {
523
- const g = r + f[u] + i[d];
524
- (!t || c || g) && e.push(g);
525
- }
526
- }
527
- return e;
528
- }
529
- const Oe = 1024 * 64, Y = (s) => {
530
- if (typeof s != "string")
531
- throw new TypeError("invalid pattern");
532
- if (s.length > Oe)
533
- throw new TypeError("pattern is too long");
534
- }, De = {
535
- "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
536
- "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
537
- "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
538
- "[:blank:]": ["\\\\p{Zs}\\\\t", !0],
539
- "[:cntrl:]": ["\\\\p{Cc}", !0],
540
- "[:digit:]": ["\\\\p{Nd}", !0],
541
- "[:graph:]": ["\\\\p{Z}\\\\p{C}", !0, !0],
542
- "[:lower:]": ["\\\\p{Ll}", !0],
543
- "[:print:]": ["\\\\p{C}", !0],
544
- "[:punct:]": ["\\\\p{P}", !0],
545
- "[:space:]": ["\\\\p{Z}\\\\t\\\\r\\\\n\\\\v\\\\f", !0],
546
- "[:upper:]": ["\\\\p{Lu}", !0],
547
- "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
548
- "[:xdigit:]": ["A-Fa-f0-9", !1]
549
- }, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), ve = (s, t) => {
550
- const e = t;
551
- if (s.charAt(e) !== "[")
552
- throw new Error("not in a brace expression");
553
- const n = [], r = [];
554
- let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
555
- t: for (; i < s.length; ) {
556
- const p = s.charAt(i);
557
- if ((p === "!" || p === "^") && i === e + 1) {
558
- h = !0, i++;
559
- continue;
560
- }
561
- if (p === "]" && o && !c) {
562
- l = i + 1;
563
- break;
564
- }
565
- if (o = !0, p === "\\\\" && !c) {
566
- c = !0, i++;
567
- continue;
568
- }
569
- if (p === "[" && !c) {
570
- for (const [S, [v, M, x]] of Object.entries(De))
571
- if (s.startsWith(S, i)) {
572
- if (f)
573
- return ["$.", !1, s.length - e, !0];
574
- i += S.length, x ? r.push(v) : n.push(v), a = a || M;
575
- continue t;
576
- }
577
- }
578
- if (c = !1, f) {
579
- p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
580
- continue;
581
- }
582
- if (s.startsWith("-]", i + 1)) {
583
- n.push(P(p + "-")), i += 2;
584
- continue;
585
- }
586
- if (s.startsWith("-", i + 1)) {
587
- f = p, i += 2;
588
- continue;
589
- }
590
- n.push(P(p)), i++;
591
- }
592
- if (l < i)
593
- return ["", !1, 0, !1];
594
- if (!n.length && !r.length)
595
- return ["$.", !1, s.length - e, !0];
596
- if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
597
- const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
598
- return [Ae(p), !1, l - e, !1];
599
- }
600
- const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
601
- return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, l - e, !0];
602
- }, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Fe = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
603
- class E {
604
- type;
605
- #s;
606
- #n;
607
- #i = !1;
608
- #t = [];
609
- #e;
610
- #o;
611
- #c;
612
- #a = !1;
613
- #r;
614
- #l;
615
- // set to true if it's an extglob with no children
616
- // (which really means one child of '')
617
- #u = !1;
618
- constructor(t, e, n = {}) {
619
- this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
620
- }
621
- get hasMagic() {
622
- if (this.#n !== void 0)
623
- return this.#n;
624
- for (const t of this.#t)
625
- if (typeof t != "string" && (t.type || t.hasMagic))
626
- return this.#n = !0;
627
- return this.#n;
628
- }
629
- // reconstructs the pattern
630
- toString() {
631
- return this.#l !== void 0 ? this.#l : this.type ? this.#l = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#l = this.#t.map((t) => String(t)).join("");
632
- }
633
- #d() {
634
- if (this !== this.#s)
635
- throw new Error("should only call on root");
636
- if (this.#a)
637
- return this;
638
- this.toString(), this.#a = !0;
639
- let t;
640
- for (; t = this.#c.pop(); ) {
641
- if (t.type !== "!")
642
- continue;
643
- let e = t, n = e.#e;
644
- for (; n; ) {
645
- for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
646
- for (const i of t.#t) {
647
- if (typeof i == "string")
648
- throw new Error("string part in extglob AST??");
649
- i.copyIn(n.#t[r]);
650
- }
651
- e = n, n = e.#e;
652
- }
653
- }
654
- return this;
655
- }
656
- push(...t) {
657
- for (const e of t)
658
- if (e !== "") {
659
- if (typeof e != "string" && !(e instanceof E && e.#e === this))
660
- throw new Error("invalid part: " + e);
661
- this.#t.push(e);
662
- }
663
- }
664
- toJSON() {
665
- const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
666
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#a && this.#e?.type === "!") && t.push({}), t;
667
- }
668
- isStart() {
669
- if (this.#s === this)
670
- return !0;
671
- if (!this.#e?.isStart())
672
- return !1;
673
- if (this.#o === 0)
674
- return !0;
675
- const t = this.#e;
676
- for (let e = 0; e < this.#o; e++) {
677
- const n = t.#t[e];
678
- if (!(n instanceof E && n.type === "!"))
679
- return !1;
680
- }
681
- return !0;
682
- }
683
- isEnd() {
684
- if (this.#s === this || this.#e?.type === "!")
685
- return !0;
686
- if (!this.#e?.isEnd())
687
- return !1;
688
- if (!this.type)
689
- return this.#e?.isEnd();
690
- const t = this.#e ? this.#e.#t.length : 0;
691
- return this.#o === t - 1;
692
- }
693
- copyIn(t) {
694
- typeof t == "string" ? this.push(t) : this.push(t.clone(this));
695
- }
696
- clone(t) {
697
- const e = new E(this.type, t);
698
- for (const n of this.#t)
699
- e.copyIn(n);
700
- return e;
701
- }
702
- static #h(t, e, n, r) {
703
- let i = !1, o = !1, a = -1, c = !1;
704
- if (e.type === null) {
705
- let d = n, g = "";
706
- for (; d < t.length; ) {
707
- const p = t.charAt(d++);
708
- if (i || p === "\\\\") {
709
- i = !i, g += p;
710
- continue;
711
- }
712
- if (o) {
713
- d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
714
- continue;
715
- } else if (p === "[") {
716
- o = !0, a = d, c = !1, g += p;
717
- continue;
718
- }
719
- if (!r.noext && pt(p) && t.charAt(d) === "(") {
720
- e.push(g), g = "";
721
- const S = new E(p, e);
722
- d = E.#h(t, S, d, r), e.push(S);
723
- continue;
724
- }
725
- g += p;
726
- }
727
- return e.push(g), d;
728
- }
729
- let h = n + 1, l = new E(null, e);
730
- const f = [];
731
- let u = "";
732
- for (; h < t.length; ) {
733
- const d = t.charAt(h++);
734
- if (i || d === "\\\\") {
735
- i = !i, u += d;
736
- continue;
737
- }
738
- if (o) {
739
- h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
740
- continue;
741
- } else if (d === "[") {
742
- o = !0, a = h, c = !1, u += d;
743
- continue;
744
- }
745
- if (pt(d) && t.charAt(h) === "(") {
746
- l.push(u), u = "";
747
- const g = new E(d, l);
748
- l.push(g), h = E.#h(t, g, h, r);
749
- continue;
750
- }
751
- if (d === "|") {
752
- l.push(u), u = "", f.push(l), l = new E(null, e);
753
- continue;
754
- }
755
- if (d === ")")
756
- return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
757
- u += d;
758
- }
759
- return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
760
- }
761
- static fromGlob(t, e = {}) {
762
- const n = new E(null, void 0, e);
763
- return E.#h(t, n, 0, e), n;
764
- }
765
- // returns the regular expression if there's magic, or the unescaped
766
- // string if not.
767
- toMMPattern() {
768
- if (this !== this.#s)
769
- return this.#s.toMMPattern();
770
- const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
771
- if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
772
- return n;
773
- const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
774
- return Object.assign(new RegExp(\`^\${e}$\`, a), {
775
- _src: e,
776
- _glob: t
777
- });
778
- }
779
- get options() {
780
- return this.#r;
781
- }
782
- // returns the string match, the regexp source, whether there's magic
783
- // in the regexp (so a regular expression is required) and whether or
784
- // not the uflag is needed for the regular expression (for posix classes)
785
- // TODO: instead of injecting the start/end at this point, just return
786
- // the BODY of the regexp, along with the start/end portions suitable
787
- // for binding the start/end in either a joined full-path makeRe context
788
- // (where we bind to (^|/), or a standalone matchPart context (where
789
- // we bind to ^, and not /). Otherwise slashes get duped!
790
- //
791
- // In part-matching mode, the start is:
792
- // - if not isStart: nothing
793
- // - if traversal possible, but not allowed: ^(?!\\.\\.?$)
794
- // - if dots allowed or not possible: ^
795
- // - if dots possible and not allowed: ^(?!\\.)
796
- // end is:
797
- // - if not isEnd(): nothing
798
- // - else: $
799
- //
800
- // In full-path matching mode, we put the slash at the START of the
801
- // pattern, so start is:
802
- // - if first pattern: same as part-matching mode
803
- // - if not isStart(): nothing
804
- // - if traversal possible, but not allowed: /(?!\\.\\.?(?:$|/))
805
- // - if dots allowed or not possible: /
806
- // - if dots possible and not allowed: /(?!\\.)
807
- // end is:
808
- // - if last pattern, same as part-matching mode
809
- // - else nothing
810
- //
811
- // Always put the (?:$|/) on negated tails, though, because that has to be
812
- // there to bind the end of the negated pattern portion, and it's easier to
813
- // just stick it in now rather than try to inject it later in the middle of
814
- // the pattern.
815
- //
816
- // We can just always return the same end, and leave it up to the caller
817
- // to know whether it's going to be used joined or in parts.
818
- // And, if the start is adjusted slightly, can do the same there:
819
- // - if not isStart: nothing
820
- // - if traversal possible, but not allowed: (?:/|^)(?!\\.\\.?$)
821
- // - if dots allowed or not possible: (?:/|^)
822
- // - if dots possible and not allowed: (?:/|^)(?!\\.)
823
- //
824
- // But it's better to have a simpler binding without a conditional, for
825
- // performance, so probably better to return both start options.
826
- //
827
- // Then the caller just ignores the end if it's not the first pattern,
828
- // and the start always gets applied.
829
- //
830
- // But that's always going to be $ if it's the ending pattern, or nothing,
831
- // so the caller can just attach $ at the end of the pattern when building.
832
- //
833
- // So the todo is:
834
- // - better detect what kind of start is needed
835
- // - return both flavors of starting pattern
836
- // - attach $ at the end of the pattern when creating the actual RegExp
837
- //
838
- // Ah, but wait, no, that all only applies to the root when the first pattern
839
- // is not an extglob. If the first pattern IS an extglob, then we need all
840
- // that dot prevention biz to live in the extglob portions, because eg
841
- // +(*|.x*) can match .xy but not .yx.
842
- //
843
- // So, return the two flavors if it's #root and the first child is not an
844
- // AST, otherwise leave it to the child AST to handle it, and there,
845
- // use the (?:^|/) style of start binding.
846
- //
847
- // Even simplified further:
848
- // - Since the start for a join is eg /(?!\\.) and the start for a part
849
- // is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
850
- // or start or whatever) and prepend ^ or / at the Regexp construction.
851
- toRegExpSource(t) {
852
- const e = t ?? !!this.#r.dot;
853
- if (this.#s === this && this.#d(), !this.type) {
854
- const c = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
855
- const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, c) : d.toRegExpSource(t);
856
- return this.#n = this.#n || S, this.#i = this.#i || v, g;
857
- }).join("");
858
- let l = "";
859
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Fe.has(this.#t[0]))) {
860
- const g = $e, p = (
861
- // dots are allowed, and the pattern starts with [ or .
862
- e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
863
- h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
864
- h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
865
- ), S = !e && !t && g.has(h.charAt(0));
866
- l = p ? Ce : S ? W : "";
867
- }
868
- let f = "";
869
- return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
870
- l + h + f,
871
- k(h),
872
- this.#n = !!this.#n,
873
- this.#i
874
- ];
875
- }
876
- const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
877
- let i = this.#f(e);
878
- if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
879
- const c = this.toString();
880
- return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
881
- }
882
- let o = !n || t || e || !W ? "" : this.#f(!0);
883
- o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
884
- let a = "";
885
- if (this.type === "!" && this.#u)
886
- a = (this.isStart() && !e ? W : "") + wt;
887
- else {
888
- const c = this.type === "!" ? (
889
- // !() must match something,but !(x) can match ''
890
- "))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
891
- ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
892
- a = r + i + c;
893
- }
894
- return [
895
- a,
896
- k(i),
897
- this.#n = !!this.#n,
898
- this.#i
899
- ];
900
- }
901
- #f(t) {
902
- return this.#t.map((e) => {
903
- if (typeof e == "string")
904
- throw new Error("string type in extglob ast??");
905
- const [n, r, i, o] = e.toRegExpSource(t);
906
- return this.#i = this.#i || o, n;
907
- }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
908
- }
909
- static #p(t, e, n = !1) {
910
- let r = !1, i = "", o = !1;
911
- for (let a = 0; a < t.length; a++) {
912
- const c = t.charAt(a);
913
- if (r) {
914
- r = !1, i += (Me.has(c) ? "\\\\" : "") + c;
915
- continue;
916
- }
917
- if (c === "\\\\") {
918
- a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
919
- continue;
920
- }
921
- if (c === "[") {
922
- const [h, l, f, u] = ve(t, a);
923
- if (f) {
924
- i += h, o = o || l, a += f - 1, e = e || u;
925
- continue;
926
- }
927
- }
928
- if (c === "*") {
929
- n && t === "*" ? i += wt : i += gt, e = !0;
930
- continue;
931
- }
932
- if (c === "?") {
933
- i += ct, e = !0;
934
- continue;
935
- }
936
- i += Te(c);
937
- }
938
- return [i, k(t), !!e, o];
939
- }
940
- }
941
- const Pe = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (s, t, e = {}) => (Y(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new Z(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, ke = (s) => (t) => !t.startsWith(".") && t.endsWith(s), Ie = (s) => (t) => t.endsWith(s), He = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), ze = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
942
- const e = kt([s]);
943
- return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
944
- }, Ze = ([s, t = ""]) => {
945
- const e = It([s]);
946
- return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
947
- }, Xe = ([s, t = ""]) => {
948
- const e = It([s]);
949
- return t ? (n) => e(n) && n.endsWith(t) : e;
950
- }, Je = ([s, t = ""]) => {
951
- const e = kt([s]);
952
- return t ? (n) => e(n) && n.endsWith(t) : e;
953
- }, kt = ([s]) => {
954
- const t = s.length;
955
- return (e) => e.length === t && !e.startsWith(".");
956
- }, It = ([s]) => {
957
- const t = s.length;
958
- return (e) => e.length === t && e !== "." && e !== "..";
959
- }, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
960
- win32: { sep: "\\\\" },
961
- posix: { sep: "/" }
962
- }, Qe = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
963
- m.sep = Qe;
964
- const D = Symbol("globstar **");
965
- m.GLOBSTAR = D;
966
- const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => m(e, s, t);
967
- m.filter = ns;
968
- const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
969
- if (!s || typeof s != "object" || !Object.keys(s).length)
970
- return m;
971
- const t = m;
972
- return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
973
- Minimatch: class extends t.Minimatch {
974
- constructor(r, i = {}) {
975
- super(r, b(s, i));
976
- }
977
- static defaults(r) {
978
- return t.defaults(b(s, r)).Minimatch;
979
- }
980
- },
981
- AST: class extends t.AST {
982
- /* c8 ignore start */
983
- constructor(r, i, o = {}) {
984
- super(r, i, b(s, o));
985
- }
986
- /* c8 ignore stop */
987
- static fromGlob(r, i = {}) {
988
- return t.AST.fromGlob(r, b(s, i));
989
- }
990
- },
991
- unescape: (n, r = {}) => t.unescape(n, b(s, r)),
992
- escape: (n, r = {}) => t.escape(n, b(s, r)),
993
- filter: (n, r = {}) => t.filter(n, b(s, r)),
994
- defaults: (n) => t.defaults(b(s, n)),
995
- makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
996
- braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
997
- match: (n, r, i = {}) => t.match(n, r, b(s, i)),
998
- sep: t.sep,
999
- GLOBSTAR: D
1000
- });
1001
- };
1002
- m.defaults = rs;
1003
- const Lt = (s, t = {}) => (Y(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : me(s));
1004
- m.braceExpand = Lt;
1005
- const is = (s, t = {}) => new Z(s, t).makeRe();
1006
- m.makeRe = is;
1007
- const os = (s, t, e = {}) => {
1008
- const n = new Z(t, e);
1009
- return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
1010
- };
1011
- m.match = os;
1012
- const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1013
- class Z {
1014
- options;
1015
- set;
1016
- pattern;
1017
- windowsPathsNoEscape;
1018
- nonegate;
1019
- negate;
1020
- comment;
1021
- empty;
1022
- preserveMultipleSlashes;
1023
- partial;
1024
- globSet;
1025
- globParts;
1026
- nocase;
1027
- isWindows;
1028
- platform;
1029
- windowsNoMagicRoot;
1030
- regexp;
1031
- constructor(t, e = {}) {
1032
- Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ht, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1033
- }
1034
- hasMagic() {
1035
- if (this.options.magicalBraces && this.set.length > 1)
1036
- return !0;
1037
- for (const t of this.set)
1038
- for (const e of t)
1039
- if (typeof e != "string")
1040
- return !0;
1041
- return !1;
1042
- }
1043
- debug(...t) {
1044
- }
1045
- make() {
1046
- const t = this.pattern, e = this.options;
1047
- if (!e.nocomment && t.charAt(0) === "#") {
1048
- this.comment = !0;
1049
- return;
1050
- }
1051
- if (!t) {
1052
- this.empty = !0;
1053
- return;
1054
- }
1055
- this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
1056
- const n = this.globSet.map((i) => this.slashSplit(i));
1057
- this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
1058
- let r = this.globParts.map((i, o, a) => {
1059
- if (this.isWindows && this.windowsNoMagicRoot) {
1060
- const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
1061
- if (c)
1062
- return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
1063
- if (h)
1064
- return [i[0], ...i.slice(1).map((l) => this.parse(l))];
1065
- }
1066
- return i.map((c) => this.parse(c));
1067
- });
1068
- if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1069
- for (let i = 0; i < this.set.length; i++) {
1070
- const o = this.set[i];
1071
- o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
1072
- }
1073
- this.debug(this.pattern, this.set);
1074
- }
1075
- // various transforms to equivalent pattern sets that are
1076
- // faster to process in a filesystem walk. The goal is to
1077
- // eliminate what we can, and push all ** patterns as far
1078
- // to the right as possible, even if it increases the number
1079
- // of patterns that we have to process.
1080
- preprocess(t) {
1081
- if (this.options.noglobstar)
1082
- for (let n = 0; n < t.length; n++)
1083
- for (let r = 0; r < t[n].length; r++)
1084
- t[n][r] === "**" && (t[n][r] = "*");
1085
- const { optimizationLevel: e = 1 } = this.options;
1086
- return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
1087
- }
1088
- // just get rid of adjascent ** portions
1089
- adjascentGlobstarOptimize(t) {
1090
- return t.map((e) => {
1091
- let n = -1;
1092
- for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
1093
- let r = n;
1094
- for (; e[r + 1] === "**"; )
1095
- r++;
1096
- r !== n && e.splice(n, r - n);
1097
- }
1098
- return e;
1099
- });
1100
- }
1101
- // get rid of adjascent ** and resolve .. portions
1102
- levelOneOptimize(t) {
1103
- return t.map((e) => (e = e.reduce((n, r) => {
1104
- const i = n[n.length - 1];
1105
- return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
1106
- }, []), e.length === 0 ? [""] : e));
1107
- }
1108
- levelTwoFileOptimize(t) {
1109
- Array.isArray(t) || (t = this.slashSplit(t));
1110
- let e = !1;
1111
- do {
1112
- if (e = !1, !this.preserveMultipleSlashes) {
1113
- for (let r = 1; r < t.length - 1; r++) {
1114
- const i = t[r];
1115
- r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
1116
- }
1117
- t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1118
- }
1119
- let n = 0;
1120
- for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1121
- const r = t[n - 1];
1122
- r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1123
- }
1124
- } while (e);
1125
- return t.length === 0 ? [""] : t;
1126
- }
1127
- // First phase: single-pattern processing
1128
- // <pre> is 1 or more portions
1129
- // <rest> is 1 or more portions
1130
- // <p> is any portion other than ., .., '', or **
1131
- // <e> is . or ''
1132
- //
1133
- // **/.. is *brutal* for filesystem walking performance, because
1134
- // it effectively resets the recursive walk each time it occurs,
1135
- // and ** cannot be reduced out by a .. pattern part like a regexp
1136
- // or most strings (other than .., ., and '') can be.
1137
- //
1138
- // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1139
- // <pre>/<e>/<rest> -> <pre>/<rest>
1140
- // <pre>/<p>/../<rest> -> <pre>/<rest>
1141
- // **/**/<rest> -> **/<rest>
1142
- //
1143
- // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1144
- // this WOULD be allowed if ** did follow symlinks, or * didn't
1145
- firstPhasePreProcess(t) {
1146
- let e = !1;
1147
- do {
1148
- e = !1;
1149
- for (let n of t) {
1150
- let r = -1;
1151
- for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
1152
- let o = r;
1153
- for (; n[o + 1] === "**"; )
1154
- o++;
1155
- o > r && n.splice(r + 1, o - r);
1156
- let a = n[r + 1];
1157
- const c = n[r + 2], h = n[r + 3];
1158
- if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
1159
- continue;
1160
- e = !0, n.splice(r, 1);
1161
- const l = n.slice(0);
1162
- l[r] = "**", t.push(l), r--;
1163
- }
1164
- if (!this.preserveMultipleSlashes) {
1165
- for (let o = 1; o < n.length - 1; o++) {
1166
- const a = n[o];
1167
- o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
1168
- }
1169
- n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1170
- }
1171
- let i = 0;
1172
- for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
1173
- const o = n[i - 1];
1174
- if (o && o !== "." && o !== ".." && o !== "**") {
1175
- e = !0;
1176
- const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
1177
- n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
1178
- }
1179
- }
1180
- }
1181
- } while (e);
1182
- return t;
1183
- }
1184
- // second phase: multi-pattern dedupes
1185
- // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1186
- // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1187
- // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1188
- //
1189
- // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1190
- // ^-- not valid because ** doens't follow symlinks
1191
- secondPhasePreProcess(t) {
1192
- for (let e = 0; e < t.length - 1; e++)
1193
- for (let n = e + 1; n < t.length; n++) {
1194
- const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1195
- if (r) {
1196
- t[e] = [], t[n] = r;
1197
- break;
1198
- }
1199
- }
1200
- return t.filter((e) => e.length);
1201
- }
1202
- partsMatch(t, e, n = !1) {
1203
- let r = 0, i = 0, o = [], a = "";
1204
- for (; r < t.length && i < e.length; )
1205
- if (t[r] === e[i])
1206
- o.push(a === "b" ? e[i] : t[r]), r++, i++;
1207
- else if (n && t[r] === "**" && e[i] === t[r + 1])
1208
- o.push(t[r]), r++;
1209
- else if (n && e[i] === "**" && t[r] === e[i + 1])
1210
- o.push(e[i]), i++;
1211
- else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1212
- if (a === "b")
1213
- return !1;
1214
- a = "a", o.push(t[r]), r++, i++;
1215
- } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
1216
- if (a === "a")
1217
- return !1;
1218
- a = "b", o.push(e[i]), r++, i++;
1219
- } else
1220
- return !1;
1221
- return t.length === e.length && o;
1222
- }
1223
- parseNegate() {
1224
- if (this.nonegate)
1225
- return;
1226
- const t = this.pattern;
1227
- let e = !1, n = 0;
1228
- for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1229
- e = !e, n++;
1230
- n && (this.pattern = t.slice(n)), this.negate = e;
1231
- }
1232
- // set partial to true to test if, for example,
1233
- // "/a/b" matches the start of "/*/b/*/d"
1234
- // Partial means, if you run out of file before you run
1235
- // out of pattern, then that's fine, as long as all
1236
- // the parts match.
1237
- matchOne(t, e, n = !1) {
1238
- const r = this.options;
1239
- if (this.isWindows) {
1240
- const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, y = M ? 3 : v ? 0 : void 0;
1241
- if (typeof x == "number" && typeof y == "number") {
1242
- const [T, H] = [t[x], e[y]];
1243
- T.toLowerCase() === H.toLowerCase() && (e[y] = T, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
1244
- }
1245
- }
1246
- const { optimizationLevel: i = 1 } = this.options;
1247
- i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1248
- for (var o = 0, a = 0, c = t.length, h = e.length; o < c && a < h; o++, a++) {
1249
- this.debug("matchOne loop");
1250
- var l = e[a], f = t[o];
1251
- if (this.debug(e, l, f), l === !1)
1252
- return !1;
1253
- if (l === D) {
1254
- this.debug("GLOBSTAR", [e, l, f]);
1255
- var u = o, d = a + 1;
1256
- if (d === h) {
1257
- for (this.debug("** at the end"); o < c; o++)
1258
- if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1259
- return !1;
1260
- return !0;
1261
- }
1262
- for (; u < c; ) {
1263
- var g = t[u];
1264
- if (this.debug(\`
1265
- globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1266
- return this.debug("globstar found match!", u, c, g), !0;
1267
- if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1268
- this.debug("dot detected!", t, u, e, d);
1269
- break;
1270
- }
1271
- this.debug("globstar swallow a segment, and continue"), u++;
1272
- }
1273
- return !!(n && (this.debug(\`
1274
- >>> no match, partial?\`, t, u, e, d), u === c));
1275
- }
1276
- let p;
1277
- if (typeof l == "string" ? (p = f === l, this.debug("string match", l, f, p)) : (p = l.test(f), this.debug("pattern match", l, f, p)), !p)
1278
- return !1;
1279
- }
1280
- if (o === c && a === h)
1281
- return !0;
1282
- if (o === c)
1283
- return n;
1284
- if (a === h)
1285
- return o === c - 1 && t[o] === "";
1286
- throw new Error("wtf?");
1287
- }
1288
- braceExpand() {
1289
- return Lt(this.pattern, this.options);
1290
- }
1291
- parse(t) {
1292
- Y(t);
1293
- const e = this.options;
1294
- if (t === "**")
1295
- return D;
1296
- if (t === "")
1297
- return "";
1298
- let n, r = null;
1299
- (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : He : e.dot ? Ie : ke)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(ze)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
1300
- const i = E.fromGlob(t, this.options).toMMPattern();
1301
- return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1302
- }
1303
- makeRe() {
1304
- if (this.regexp || this.regexp === !1)
1305
- return this.regexp;
1306
- const t = this.set;
1307
- if (!t.length)
1308
- return this.regexp = !1, this.regexp;
1309
- const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
1310
- let i = t.map((c) => {
1311
- const h = c.map((l) => {
1312
- if (l instanceof RegExp)
1313
- for (const f of l.flags.split(""))
1314
- r.add(f);
1315
- return typeof l == "string" ? as(l) : l === D ? D : l._src;
1316
- });
1317
- return h.forEach((l, f) => {
1318
- const u = h[f + 1], d = h[f - 1];
1319
- l !== D || d === D || (d === void 0 ? u !== void 0 && u !== D ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== D && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = D));
1320
- }), h.filter((l) => l !== D).join("/");
1321
- }).join("|");
1322
- const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1323
- i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1324
- try {
1325
- this.regexp = new RegExp(i, [...r].join(""));
1326
- } catch {
1327
- this.regexp = !1;
1328
- }
1329
- return this.regexp;
1330
- }
1331
- slashSplit(t) {
1332
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\\/\\/[^\\/]+/.test(t) ? ["", ...t.split(/\\/+/)] : t.split(/\\/+/);
1333
- }
1334
- match(t, e = this.partial) {
1335
- if (this.debug("match", t, this.pattern), this.comment)
1336
- return !1;
1337
- if (this.empty)
1338
- return t === "";
1339
- if (t === "/" && e)
1340
- return !0;
1341
- const n = this.options;
1342
- this.isWindows && (t = t.split("\\\\").join("/"));
1343
- const r = this.slashSplit(t);
1344
- this.debug(this.pattern, "split", r);
1345
- const i = this.set;
1346
- this.debug(this.pattern, "set", i);
1347
- let o = r[r.length - 1];
1348
- if (!o)
1349
- for (let a = r.length - 2; !o && a >= 0; a--)
1350
- o = r[a];
1351
- for (let a = 0; a < i.length; a++) {
1352
- const c = i[a];
1353
- let h = r;
1354
- if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
1355
- return n.flipNegate ? !0 : !this.negate;
1356
- }
1357
- return n.flipNegate ? !1 : this.negate;
1358
- }
1359
- static defaults(t) {
1360
- return m.defaults(t).Minimatch;
1361
- }
1362
- }
1363
- m.AST = E;
1364
- m.Minimatch = Z;
1365
- m.escape = Pe;
1366
- m.unescape = k;
1367
- function cs() {
1368
- if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1369
- throw new Qt();
1370
- }
1371
- async function I(s, t) {
1372
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
1373
- }
1374
- function F(s) {
1375
- return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1376
- }
1377
- function lt(s) {
1378
- return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1379
- }
1380
- function it(s) {
1381
- const t = F(s);
1382
- return t[t.length - 1] || "";
1383
- }
1384
- function tt(s) {
1385
- const t = F(s);
1386
- return t.pop(), lt(t);
1387
- }
1388
- function B(s) {
1389
- return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1390
- }
1391
- function ls(s, t = !1) {
1392
- return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1393
- }
1394
- function et(s, t) {
1395
- return m(s, t, {
1396
- dot: !0,
1397
- matchBase: !0
1398
- });
1399
- }
1400
- function Et(s) {
1401
- const t = B(s), e = F(t), n = [];
1402
- for (const r of e)
1403
- if (!(r === "." || r === ""))
1404
- if (r === "..") {
1405
- if (n.length === 0)
1406
- continue;
1407
- n.pop();
1408
- } else
1409
- n.push(r);
1410
- return lt(n);
1411
- }
1412
- async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1413
- if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1414
- throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1415
- const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1416
- return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1417
- }
1418
- async function us(s) {
1419
- const t = await s.arrayBuffer();
1420
- return new Uint8Array(t);
1421
- }
1422
- async function fs(s, t, e = {}) {
1423
- const n = it(t);
1424
- return I(t, async () => {
1425
- const r = e.recursive ?? !1, i = e.force ?? !1;
1426
- try {
1427
- await s.removeEntry(n, { recursive: r });
1428
- } catch (o) {
1429
- if (o.name === "NotFoundError" && i)
1430
- return;
1431
- const a = o.name === "TypeMismatchError" && !r;
1432
- throw O(o, {
1433
- path: t,
1434
- operation: "remove",
1435
- isDirectory: a
1436
- });
1437
- }
1438
- });
1439
- }
1440
- function St(s, t, e, n) {
1441
- if (!Number.isInteger(t) || !Number.isInteger(e))
1442
- throw new N("argument", "Invalid offset or length");
1443
- if (t < 0 || e < 0)
1444
- throw new N("argument", "Negative offset or length not allowed");
1445
- if (t + e > s)
1446
- throw new N("overflow", "Operation would overflow buffer");
1447
- if (n != null && (!Number.isInteger(n) || n < 0))
1448
- throw new N("argument", "Invalid position");
1449
- }
1450
- function xt(s, t, e) {
1451
- try {
1452
- t.flush(), t.close();
1453
- } catch (n) {
1454
- console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1455
- }
1456
- }
1457
- function ds(s, t, e) {
1458
- if (s >= e)
1459
- return { isEOF: !0, actualLength: 0 };
1460
- const n = Math.min(t, e - s);
1461
- return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1462
- }
1463
- async function ps(s, t) {
1464
- try {
1465
- return await s.createSyncAccessHandle();
1466
- } catch (e) {
1467
- throw O(e, { path: t, isDirectory: !1 });
1468
- }
1469
- }
1470
- class gs {
1471
- /** Root directory handle for the file system */
1472
- root;
1473
- /** Map of watched paths and options */
1474
- watchers = /* @__PURE__ */ new Map();
1475
- /** Promise to prevent concurrent mount operations */
1476
- mountingPromise = null;
1477
- /** BroadcastChannel instance for sending events */
1478
- broadcastChannel = null;
1479
- /** Configuration options */
1480
- options = {
1481
- root: "/",
1482
- namespace: "",
1483
- maxFileSize: 50 * 1024 * 1024,
1484
- hashAlgorithm: "etag",
1485
- broadcastChannel: "opfs-worker"
1486
- };
1487
- /** Shared sync handles per path (OPFS allows only one handle per file) */
1488
- openHandles = /* @__PURE__ */ new Map();
1489
- /** Map of open file descriptors to their metadata */
1490
- openFiles = /* @__PURE__ */ new Map();
1491
- /** Next available file descriptor number */
1492
- nextFd = 1;
1493
- /**
1494
- * Get file info by descriptor with validation
1495
- * @private
1496
- */
1497
- _getFileDescriptor(t) {
1498
- const e = this.openFiles.get(t);
1499
- if (!e)
1500
- throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
1501
- return e;
1502
- }
1503
- /**
1504
- * Notify about internal changes to the file system
1505
- *
1506
- * This method is called by internal operations to notify clients about
1507
- * changes, even when no specific paths are being watched.
1508
- *
1509
- * @param event - The event describing the change
1510
- */
1511
- async notifyChange(t) {
1512
- if (!this.options.broadcastChannel)
1513
- return;
1514
- const e = t.path;
1515
- if (![...this.watchers.values()].some((i) => et(e, i.pattern) && i.include.some((o) => o && et(e, o)) && !i.exclude.some((o) => o && et(e, o))))
1516
- return;
1517
- let r;
1518
- if (this.options.hashAlgorithm)
1519
- try {
1520
- r = (await this.stat(e)).hash;
1521
- } catch {
1522
- }
1523
- try {
1524
- this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
1525
- const i = {
1526
- namespace: this.options.namespace,
1527
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1528
- ...t,
1529
- ...r && { hash: r }
1530
- };
1531
- this.broadcastChannel.postMessage(i);
1532
- } catch (i) {
1533
- console.warn("Failed to send event via BroadcastChannel:", i);
1534
- }
1535
- }
1536
- /**
1537
- * Creates a new OPFSWorker instance
1538
- *
1539
- * @param options - Optional configuration options
1540
- * @param options.root - Root path for the file system (default: '/')
1541
- * @param options.watchInterval - Polling interval in milliseconds for file watching
1542
- * @param options.hashAlgorithm - Hash algorithm for file hashing
1543
- * @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)
1544
- * @throws {OPFSError} If OPFS is not supported in the current browser
1545
- */
1546
- constructor(t) {
1547
- cs(), t && this.setOptions(t);
1548
- }
1549
- /**
1550
- * Initialize the file system within a given directory
1551
- *
1552
- * This method sets up the root directory for all subsequent operations.
1553
- * If no root is specified, it will use the OPFS root directory.
1554
- *
1555
- * @returns Promise that resolves to true if initialization was successful
1556
- * @throws {OPFSError} If initialization fails
1557
- *
1558
- * @example
1559
- * \`\`\`typescript
1560
- * const fs = new OPFSWorker();
1561
- *
1562
- * // Use OPFS root (default)
1563
- * await fs.mount();
1564
- *
1565
- * // Use custom directory
1566
- * await fs.mount('/my-app');
1567
- * \`\`\`
1568
- */
1569
- async mount() {
1570
- const t = this.options.root;
1571
- return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1572
- try {
1573
- const r = await navigator.storage.getDirectory();
1574
- this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1575
- } catch (r) {
1576
- n(new re(t, r));
1577
- } finally {
1578
- this.mountingPromise = null;
1579
- }
1580
- }), this.mountingPromise;
1581
- }
1582
- /**
1583
- * Update configuration options
1584
- *
1585
- * @param options - Configuration options to update
1586
- * @param options.root - Root path for the file system
1587
- * @param options.watchInterval - Polling interval in milliseconds for file watching
1588
- * @param options.hashAlgorithm - Hash algorithm for file hashing
1589
- * @param options.maxFileSize - Maximum file size for hashing in bytes
1590
- * @param options.broadcastChannel - Custom name for the broadcast channel
1591
- */
1592
- async setOptions(t) {
1593
- 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 = B(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1594
- }
1595
- /**
1596
- * Get a directory handle from a path
1597
- *
1598
- * Navigates through the directory structure to find or create a directory
1599
- * at the specified path.
1600
- *
1601
- * @param path - The path to the directory (string or array of segments)
1602
- * @param create - Whether to create the directory if it doesn't exist (default: false)
1603
- * @param from - The directory to start from (default: root directory)
1604
- * @returns Promise that resolves to the directory handle
1605
- * @throws {OPFSError} If the directory cannot be accessed or created
1606
- *
1607
- * @example
1608
- * \`\`\`typescript
1609
- * const docsDir = await fs.getDirectoryHandle('/users/john/documents', true);
1610
- * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
1611
- * \`\`\`
1612
- */
1613
- async getDirectoryHandle(t, e = !1, n = this.root) {
1614
- const r = Array.isArray(t) ? t : F(t);
1615
- let i = n;
1616
- for (const o of r)
1617
- i = await i.getDirectoryHandle(o, { create: e });
1618
- return i;
1619
- }
1620
- /**
1621
- * Get a file handle from a path
1622
- *
1623
- * Navigates to the parent directory and retrieves or creates a file handle
1624
- * for the specified file path.
1625
- *
1626
- * @param path - The path to the file (string or array of segments)
1627
- * @param create - Whether to create the file if it doesn't exist (default: false)
1628
- * @param _from - The directory to start from (default: root directory)
1629
- * @returns Promise that resolves to the file handle
1630
- * @throws {PathError} If the path is empty
1631
- * @throws {OPFSError} If the file cannot be accessed or created
1632
- *
1633
- * @example
1634
- * \`\`\`typescript
1635
- * const fileHandle = await fs.getFileHandle('/config/settings.json', true);
1636
- * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
1637
- * \`\`\`
1638
- */
1639
- async getFileHandle(t, e = !1, n = this.root) {
1640
- const r = F(t);
1641
- if (r.length === 0)
1642
- throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1643
- const i = r.pop();
1644
- return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1645
- }
1646
- /**
1647
- * Get a complete index of all files and directories in the file system
1648
- *
1649
- * This method recursively traverses the entire file system and returns
1650
- * a Map containing FileStat objects for every file and directory.
1651
- *
1652
- * @returns Promise that resolves to a Map of paths to FileStat objects
1653
- * @throws {OPFSError} If the file system is not mounted
1654
- *
1655
- * @example
1656
- * \`\`\`typescript
1657
- * const index = await fs.index();
1658
- * const fileStats = index.get('/data/config.json');
1659
- * if (fileStats) {
1660
- * console.log(\`File size: \${fileStats.size} bytes\`);
1661
- * if (fileStats.hash) console.log(\`Hash: \${fileStats.hash}\`);
1662
- * }
1663
- * \`\`\`
1664
- */
1665
- async index() {
1666
- const t = /* @__PURE__ */ new Map(), e = async (n) => {
1667
- const r = await this.readDir(n);
1668
- for (const i of r) {
1669
- const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
1670
- try {
1671
- const a = await this.stat(o);
1672
- t.set(o, a), a.isDirectory && await e(o);
1673
- } catch (a) {
1674
- console.warn(\`Skipping broken entry: \${o}\`, a);
1675
- }
1676
- }
1677
- };
1678
- return t.set("/", {
1679
- kind: "directory",
1680
- size: 0,
1681
- mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
1682
- ctime: (/* @__PURE__ */ new Date(0)).toISOString(),
1683
- isFile: !1,
1684
- isDirectory: !0
1685
- }), await e("/"), t;
1686
- }
1687
- /**
1688
- * Read a file from the file system
1689
- *
1690
- * Reads the contents of a file and returns it as binary data.
1691
- *
1692
- * @param path - The path to the file to read
1693
- * @returns Promise that resolves to the file contents as Uint8Array
1694
- * @throws {FileNotFoundError} If the file does not exist
1695
- * @throws {OPFSError} If reading the file fails
1696
- *
1697
- * @example
1698
- * \`\`\`typescript
1699
- * // Read as binary data
1700
- * const content = await fs.readFile('/config/settings.json');
1701
- *
1702
- * // Read binary file
1703
- * const binaryData = await fs.readFile('/images/logo.png');
1704
- * \`\`\`
1705
- */
1706
- async readFile(t) {
1707
- await this.mount();
1708
- try {
1709
- return await I(t, async () => {
1710
- const e = await this.open(t);
1711
- try {
1712
- const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1713
- return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
1714
- } finally {
1715
- await this.close(e);
1716
- }
1717
- });
1718
- } catch (e) {
1719
- throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
1720
- }
1721
- }
1722
- /**
1723
- * Write data to a file
1724
- *
1725
- * Creates or overwrites a file with the specified binary data. If the file already
1726
- * exists, it will be truncated before writing.
1727
- *
1728
- * @param path - The path to the file to write
1729
- * @param data - The binary data to write to the file (Uint8Array or ArrayBuffer)
1730
- * @returns Promise that resolves when the write operation is complete
1731
- * @throws {OPFSError} If writing the file fails
1732
- *
1733
- * @example
1734
- * \`\`\`typescript
1735
- * // Write binary data
1736
- * const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
1737
- * await fs.writeFile('/data/binary.dat', binaryData);
1738
- *
1739
- * // Write from ArrayBuffer
1740
- * const arrayBuffer = new ArrayBuffer(10);
1741
- * await fs.writeFile('/data/buffer.dat', arrayBuffer);
1742
- * \`\`\`
1743
- */
1744
- async writeFile(t, e) {
1745
- await this.mount();
1746
- const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1747
- await I(t, async () => {
1748
- const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
1749
- try {
1750
- await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
1751
- } finally {
1752
- await this.close(i);
1753
- }
1754
- await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
1755
- });
1756
- }
1757
- /**
1758
- * Append data to a file
1759
- *
1760
- * Adds binary data to the end of an existing file. If the file doesn't exist,
1761
- * it will be created.
1762
- *
1763
- * @param path - The path to the file to append to
1764
- * @param data - The binary data to append to the file (Uint8Array or ArrayBuffer)
1765
- * @returns Promise that resolves when the append operation is complete
1766
- * @throws {OPFSError} If appending to the file fails
1767
- *
1768
- * @example
1769
- * \`\`\`typescript
1770
- * // Append binary data
1771
- * const additionalData = new Uint8Array([6, 7, 8]);
1772
- * await fs.appendFile('/data/binary.dat', additionalData);
1773
- *
1774
- * // Append from ArrayBuffer
1775
- * const arrayBuffer = new ArrayBuffer(5);
1776
- * await fs.appendFile('/data/buffer.dat', arrayBuffer);
1777
- * \`\`\`
1778
- */
1779
- async appendFile(t, e) {
1780
- await this.mount();
1781
- const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1782
- await I(t, async () => {
1783
- const r = await this.open(t, { create: !0 });
1784
- try {
1785
- const { size: i } = await this.fstat(r);
1786
- await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
1787
- } finally {
1788
- await this.close(r);
1789
- }
1790
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1791
- });
1792
- }
1793
- /**
1794
- * Create a directory
1795
- *
1796
- * Creates a new directory at the specified path. If the recursive option
1797
- * is enabled, parent directories will be created as needed.
1798
- *
1799
- * @param path - The path where the directory should be created
1800
- * @param options - Options for directory creation
1801
- * @param options.recursive - Whether to create parent directories if they don't exist (default: false)
1802
- * @returns Promise that resolves when the directory is created
1803
- * @throws {OPFSError} If the directory cannot be created
1804
- *
1805
- * @example
1806
- * \`\`\`typescript
1807
- * // Create a single directory
1808
- * await fs.mkdir('/users/john');
1809
- *
1810
- * // Create nested directories
1811
- * await fs.mkdir('/users/john/documents/projects', { recursive: true });
1812
- * \`\`\`
1813
- */
1814
- async mkdir(t, e) {
1815
- await this.mount();
1816
- const n = e?.recursive ?? !1, r = F(t);
1817
- let i = this.root;
1818
- for (let o = 0; o < r.length; o++) {
1819
- const a = r[o];
1820
- try {
1821
- i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1822
- } catch (c) {
1823
- throw c.name === "NotFoundError" ? O(c, {
1824
- path: lt(r.slice(0, o + 1)),
1825
- existenceType: "directory"
1826
- }) : c.name === "TypeMismatchError" ? O(c, { path: a, isDirectory: !1 }) : new J("create directory", a, c);
1827
- }
1828
- }
1829
- await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1830
- }
1831
- /**
1832
- * Get file or directory statistics
1833
- *
1834
- * Returns detailed information about a file or directory, including
1835
- * size, modification time, and optionally a hash of the file content.
1836
- *
1837
- * @param path - The path to the file or directory
1838
- * @returns Promise that resolves to FileStat object
1839
- * @throws {OPFSError} If the path does not exist or cannot be accessed
1840
- *
1841
- * @example
1842
- * \`\`\`typescript
1843
- * const stats = await fs.stat('/data/config.json');
1844
- * console.log(\`File size: \${stats.size} bytes\`);
1845
- * console.log(\`Last modified: \${stats.mtime}\`);
1846
- *
1847
- * // If hashing is enabled, hash will be included
1848
- * if (stats.hash) {
1849
- * console.log(\`Hash: \${stats.hash}\`);
1850
- * }
1851
- * \`\`\`
1852
- */
1853
- async stat(t) {
1854
- if (await this.mount(), t === "/")
1855
- return {
1856
- kind: "directory",
1857
- size: 0,
1858
- mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
1859
- ctime: (/* @__PURE__ */ new Date(0)).toISOString(),
1860
- isFile: !1,
1861
- isDirectory: !0
1862
- };
1863
- const e = it(t);
1864
- let n;
1865
- try {
1866
- n = await this.getDirectoryHandle(tt(t), !1);
1867
- const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1868
- kind: "file",
1869
- size: o.size,
1870
- mtime: new Date(o.lastModified).toISOString(),
1871
- ctime: new Date(o.lastModified).toISOString(),
1872
- isFile: !0,
1873
- isDirectory: !1
1874
- };
1875
- if (r === "etag")
1876
- a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1877
- else if (typeof r == "string")
1878
- try {
1879
- const c = await hs(o, r, this.options.maxFileSize);
1880
- a.hash = c;
1881
- } catch (c) {
1882
- console.warn(\`Failed to calculate hash for \${t}:\`, c);
1883
- }
1884
- return a;
1885
- } catch (r) {
1886
- if (r.name === "NotFoundError")
1887
- throw new U("file", t, r);
1888
- if (r.name !== "TypeMismatchError")
1889
- throw new J("stat", t, r);
1890
- }
1891
- try {
1892
- return await n.getDirectoryHandle(e, { create: !1 }), {
1893
- kind: "directory",
1894
- size: 0,
1895
- mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
1896
- ctime: (/* @__PURE__ */ new Date(0)).toISOString(),
1897
- isFile: !1,
1898
- isDirectory: !0
1899
- };
1900
- } catch (r) {
1901
- throw new J("stat", t, r);
1902
- }
1903
- }
1904
- /**
1905
- * Read a directory's contents
1906
- *
1907
- * Lists all files and subdirectories within the specified directory.
1908
- *
1909
- * @param path - The path to the directory to read
1910
- * @returns Promise that resolves to an array of detailed file/directory information
1911
- * @throws {OPFSError} If the directory does not exist or cannot be accessed
1912
- *
1913
- * @example
1914
- * \`\`\`typescript
1915
- * // Get detailed information about files and directories
1916
- * const detailed = await fs.readDir('/users/john/documents');
1917
- * detailed.forEach(item => {
1918
- * console.log(\`\${item.name} - \${item.isFile ? 'file' : 'directory'}\`);
1919
- * });
1920
- * \`\`\`
1921
- */
1922
- async readDir(t) {
1923
- await this.mount();
1924
- const e = await this.getDirectoryHandle(t, !1), n = [];
1925
- for await (const [r, i] of e.entries()) {
1926
- const o = i.kind === "file";
1927
- n.push({
1928
- name: r,
1929
- kind: i.kind,
1930
- isFile: o,
1931
- isDirectory: !o
1932
- });
1933
- }
1934
- return n;
1935
- }
1936
- /**
1937
- * Check if a file or directory exists
1938
- *
1939
- * Verifies if a file or directory exists at the specified path.
1940
- *
1941
- * @param path - The path to check
1942
- * @returns Promise that resolves to true if the file or directory exists, false otherwise
1943
- *
1944
- * @example
1945
- * \`\`\`typescript
1946
- * const exists = await fs.exists('/config/settings.json');
1947
- * console.log(\`File exists: \${exists}\`);
1948
- * \`\`\`
1949
- */
1950
- async exists(t) {
1951
- if (await this.mount(), t === "/")
1952
- return !0;
1953
- const e = it(t);
1954
- let n = null;
1955
- try {
1956
- n = await this.getDirectoryHandle(tt(t), !1);
1957
- } catch (r) {
1958
- if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1959
- throw r;
1960
- }
1961
- if (!n || !e)
1962
- return !1;
1963
- try {
1964
- return await n.getFileHandle(e, { create: !1 }), !0;
1965
- } catch (r) {
1966
- if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1967
- throw r;
1968
- try {
1969
- return await n.getDirectoryHandle(e, { create: !1 }), !0;
1970
- } catch (i) {
1971
- if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1972
- throw i;
1973
- return !1;
1974
- }
1975
- }
1976
- }
1977
- /**
1978
- * Clear all contents of a directory without removing the directory itself
1979
- *
1980
- * Removes all files and subdirectories within the specified directory,
1981
- * but keeps the directory itself.
1982
- *
1983
- * @param path - The path to the directory to clear (default: '/')
1984
- * @returns Promise that resolves when all contents are removed
1985
- * @throws {OPFSError} If the operation fails
1986
- *
1987
- * @example
1988
- * \`\`\`typescript
1989
- * // Clear root directory contents
1990
- * await fs.clear('/');
1991
- *
1992
- * // Clear specific directory contents
1993
- * await fs.clear('/data');
1994
- * \`\`\`
1995
- */
1996
- async clear(t = "/") {
1997
- await this.mount();
1998
- try {
1999
- const e = await this.readDir(t);
2000
- for (const n of e) {
2001
- const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
2002
- await this.remove(r, { recursive: !0 });
2003
- }
2004
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
2005
- } catch (e) {
2006
- throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
2007
- }
2008
- }
2009
- /**
2010
- * Remove files and directories
2011
- *
2012
- * Removes files and directories. Similar to Node.js fs.rm().
2013
- *
2014
- * @param path - The path to remove
2015
- * @param options - Options for removal
2016
- * @param options.recursive - Whether to remove directories and their contents recursively (default: false)
2017
- * @param options.force - Whether to ignore errors if the path doesn't exist (default: false)
2018
- * @returns Promise that resolves when the removal is complete
2019
- * @throws {OPFSError} If the removal fails
2020
- *
2021
- * @example
2022
- * \`\`\`typescript
2023
- * // Remove a file
2024
- * await fs.rm('/path/to/file.txt');
2025
- *
2026
- * // Remove a directory and all its contents
2027
- * await fs.rm('/path/to/directory', { recursive: true });
2028
- *
2029
- * // Remove with force (ignore if doesn't exist)
2030
- * await fs.rm('/maybe/exists', { force: true });
2031
- * \`\`\`
2032
- */
2033
- async remove(t, e) {
2034
- if (await this.mount(), t === "/")
2035
- throw new rt("EROOT", t);
2036
- const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(tt(t), !1), o = await this.stat(t);
2037
- await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
2038
- }
2039
- /**
2040
- * Resolve a path to an absolute path
2041
- *
2042
- * Resolves relative paths and normalizes path segments (like '..' and '.').
2043
- * Similar to Node.js fs.realpath() but without symlink resolution since OPFS doesn't support symlinks.
2044
- *
2045
- * @param path - The path to resolve
2046
- * @returns Promise that resolves to the absolute normalized path
2047
- * @throws {FileNotFoundError} If the path does not exist
2048
- * @throws {OPFSError} If path resolution fails
2049
- *
2050
- * @example
2051
- * \`\`\`typescript
2052
- * // Resolve relative path
2053
- * const absolute = await fs.realpath('./config/../data/file.txt');
2054
- * console.log(absolute); // '/data/file.txt'
2055
- * \`\`\`
2056
- */
2057
- async realpath(t) {
2058
- await this.mount();
2059
- try {
2060
- const e = Et(t);
2061
- if (!await this.exists(e))
2062
- throw new U("file", e);
2063
- return e;
2064
- } catch (e) {
2065
- throw e instanceof w ? e : O(e, { path: t });
2066
- }
2067
- }
2068
- /**
2069
- * Rename a file or directory
2070
- *
2071
- * Changes the name of a file or directory. If the target path already exists,
2072
- * it will be replaced only if overwrite option is enabled.
2073
- *
2074
- * @param oldPath - The current path of the file or directory
2075
- * @param newPath - The new path for the file or directory
2076
- * @param options - Options for renaming
2077
- * @param options.overwrite - Whether to overwrite existing files (default: false)
2078
- * @returns Promise that resolves when the rename operation is complete
2079
- * @throws {OPFSError} If the rename operation fails
2080
- *
2081
- * @example
2082
- * \`\`\`typescript
2083
- * // Basic rename (fails if target exists)
2084
- * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt');
2085
- *
2086
- * // Rename with overwrite
2087
- * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
2088
- * \`\`\`
2089
- */
2090
- async rename(t, e, n) {
2091
- await this.mount();
2092
- try {
2093
- const r = n?.overwrite ?? !1, i = await this.stat(t);
2094
- if (await this.exists(e) && !r)
2095
- throw new Q(e);
2096
- await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: i.isDirectory });
2097
- } catch (r) {
2098
- throw r instanceof w ? r : O(r, { path: t });
2099
- }
2100
- }
2101
- /**
2102
- * Copy files and directories
2103
- *
2104
- * Copies files and directories. Similar to Node.js fs.cp().
2105
- *
2106
- * @param source - The source path to copy from
2107
- * @param destination - The destination path to copy to
2108
- * @param options - Options for copying
2109
- * @param options.recursive - Whether to copy directories recursively (default: false)
2110
- * @param options.overwrite - Whether to overwrite existing files (default: true)
2111
- * @returns Promise that resolves when the copy operation is complete
2112
- * @throws {OPFSError} If the copy operation fails
2113
- *
2114
- * @example
2115
- * \`\`\`typescript
2116
- * // Copy a file
2117
- * await fs.copy('/source/file.txt', '/dest/file.txt');
2118
- *
2119
- * // Copy a directory and all its contents
2120
- * await fs.copy('/source/dir', '/dest/dir', { recursive: true });
2121
- *
2122
- * // Copy without overwriting existing files
2123
- * await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
2124
- * \`\`\`
2125
- */
2126
- async copy(t, e, n) {
2127
- await this.mount();
2128
- try {
2129
- const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2130
- if (!await this.exists(t))
2131
- throw new U("source", t);
2132
- if (await this.exists(e) && !i)
2133
- throw new Q(e);
2134
- if ((await this.stat(t)).isFile) {
2135
- const h = await this.readFile(t);
2136
- await this.writeFile(e, h);
2137
- } else {
2138
- if (!r)
2139
- throw new nt("directory", t);
2140
- await this.mkdir(e, { recursive: !0 });
2141
- const h = await this.readDir(t);
2142
- for (const l of h) {
2143
- const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
2144
- await this.copy(f, u, { recursive: !0, overwrite: i });
2145
- }
2146
- }
2147
- } catch (r) {
2148
- throw r instanceof w ? r : O(r, { path: t });
2149
- }
2150
- }
2151
- /**
2152
- * Start watching a file or directory for changes
2153
- *
2154
- * @param path - The path to watch (minimatch syntax allowed)
2155
- * @param options - Watch options
2156
- * @param options.recursive - Whether to watch recursively (default: true)
2157
- * @param options.exclude - Glob pattern(s) to exclude (minimatch).
2158
- * @returns Promise that resolves when watching starts
2159
- *
2160
- * @example
2161
- * \`\`\`typescript
2162
- * // Watch entire directory tree recursively (default)
2163
- * await fs.watch('/data');
2164
- *
2165
- * // Watch only immediate children (shallow)
2166
- * await fs.watch('/data', { recursive: false });
2167
- *
2168
- * // Watch a single file
2169
- * await fs.watch('/config.json', { recursive: false });
2170
- *
2171
- * // Watch all json files but not in dist directory
2172
- * await fs.watch('/**\\/*.json', { recursive: false, exclude: ['dist/**'] });
2173
- *
2174
- * \`\`\`
2175
- */
2176
- async watch(t, e) {
2177
- if (!this.options.broadcastChannel)
2178
- throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2179
- const n = {
2180
- pattern: ls(t, e?.recursive ?? !0),
2181
- include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2182
- exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2183
- };
2184
- this.watchers.set(t, n);
2185
- }
2186
- /**
2187
- * Stop watching a previously watched path
2188
- */
2189
- unwatch(t) {
2190
- this.watchers.delete(t);
2191
- }
2192
- /**
2193
- * Open a file and return a file descriptor
2194
- *
2195
- * @param path - The path to the file to open
2196
- * @param options - Options for opening the file
2197
- * @param options.create - Whether to create the file if it doesn't exist (default: false)
2198
- * @param options.exclusive - If true and create is true, fails if file already exists (default: false)
2199
- * Note: This is best-effort in OPFS, not fully atomic due to browser limitations
2200
- * @param options.truncate - Whether to truncate the file to zero length (default: false)
2201
- * @returns Promise that resolves to a file descriptor number
2202
- * @throws {OPFSError} If opening the file fails
2203
- *
2204
- * @example
2205
- * \`\`\`typescript
2206
- * // Open existing file for reading
2207
- * const fd = await fs.open('/data/config.json');
2208
- *
2209
- * // Create new file for writing
2210
- * const fd = await fs.open('/data/new.txt', { create: true });
2211
- *
2212
- * // Create file exclusively (fails if exists)
2213
- * const fd = await fs.open('/data/unique.txt', { create: true, exclusive: true });
2214
- *
2215
- * // Open and truncate file
2216
- * const fd = await fs.open('/data/log.txt', { create: true, truncate: true });
2217
- * \`\`\`
2218
- */
2219
- async open(t, e) {
2220
- await this.mount();
2221
- const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
2222
- try {
2223
- return n && r ? await I(o, async () => {
2224
- if (await this.exists(o))
2225
- throw new Q(o);
2226
- return this._openFile(o, n, i);
2227
- }) : await this._openFile(o, n, i);
2228
- } catch (a) {
2229
- if (a instanceof w)
2230
- throw a;
2231
- const c = a && a.name === "TypeMismatchError";
2232
- throw O(a, {
2233
- path: o,
2234
- isDirectory: !!c
2235
- });
2236
- }
2237
- }
2238
- /**
2239
- * Internal method to open a file (without locking)
2240
- *
2241
- * Multiple FDs for the same path share one sync access handle (OPFS limit),
2242
- * with independent per-FD positions — similar to Node.js.
2243
- * @private
2244
- */
2245
- async _openFile(t, e, n) {
2246
- let r = this.openHandles.get(t);
2247
- if (!r) {
2248
- const o = await this.getFileHandle(t, e);
2249
- try {
2250
- await o.getFile();
2251
- } catch (c) {
2252
- throw O(c, { path: t, isDirectory: !0 });
2253
- }
2254
- const a = await ps(o, t);
2255
- r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
2256
- }
2257
- r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
2258
- const i = this.nextFd++;
2259
- return this.openFiles.set(i, {
2260
- path: t,
2261
- fileHandle: r.fileHandle,
2262
- syncHandle: r.syncHandle,
2263
- position: 0
2264
- }), i;
2265
- }
2266
- /**
2267
- * Close a file descriptor
2268
- *
2269
- * @param fd - The file descriptor to close
2270
- * @returns Promise that resolves when the file descriptor is closed
2271
- * @throws {OPFSError} If the file descriptor is invalid or closing fails
2272
- *
2273
- * @example
2274
- * \`\`\`typescript
2275
- * const fd = await fs.open('/data/file.txt');
2276
- * // ... use the file descriptor ...
2277
- * await fs.close(fd);
2278
- * \`\`\`
2279
- */
2280
- async close(t) {
2281
- const e = this._getFileDescriptor(t);
2282
- this.openFiles.delete(t);
2283
- const n = this.openHandles.get(e.path);
2284
- n && (n.refCount--, n.refCount <= 0 && (xt(t, n.syncHandle, e.path), this.openHandles.delete(e.path)));
2285
- }
2286
- /**
2287
- * Read data from a file descriptor
2288
- *
2289
- * @param fd - The file descriptor to read from
2290
- * @param buffer - The buffer to read data into
2291
- * @param offset - The offset in the buffer to start writing at
2292
- * @param length - The number of bytes to read
2293
- * @param position - The position in the file to read from (null for current position)
2294
- * @returns Promise that resolves to the number of bytes read and the modified buffer
2295
- * @throws {OPFSError} If the file descriptor is invalid or reading fails
2296
- *
2297
- * @note This method uses Comlink.transfer() to efficiently pass the buffer as a Transferable Object,
2298
- * ensuring zero-copy performance across Web Worker boundaries.
2299
- *
2300
- * @example
2301
- * \`\`\`typescript
2302
- * const fd = await fs.open('/data/file.txt');
2303
- * const buffer = new Uint8Array(1024);
2304
- * const { bytesRead, buffer: modifiedBuffer } = await fs.read(fd, buffer, 0, 1024, null);
2305
- * console.log(\`Read \${bytesRead} bytes\`);
2306
- * // Use modifiedBuffer which contains the actual data
2307
- * await fs.close(fd);
2308
- * \`\`\`
2309
- */
2310
- async read(t, e, n, r, i) {
2311
- const o = this._getFileDescriptor(t);
2312
- St(e.length, n, r, i);
2313
- try {
2314
- const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
2315
- if (h)
2316
- return _({ bytesRead: 0, buffer: e }, [e.buffer]);
2317
- const f = e.subarray(n, n + l), u = o.syncHandle.read(f, { at: a });
2318
- return i == null && (o.position = a + u), _({ bytesRead: u, buffer: e }, [e.buffer]);
2319
- } catch (a) {
2320
- throw z("read", t, o.path, a);
2321
- }
2322
- }
2323
- /**
2324
- * Write data to a file descriptor
2325
- *
2326
- * @param fd - The file descriptor to write to
2327
- * @param buffer - The buffer containing data to write
2328
- * @param offset - The offset in the buffer to start reading from (default: 0)
2329
- * @param length - The number of bytes to write (default: entire buffer)
2330
- * @param position - The position in the file to write to (null/undefined for current position)
2331
- * @param emitEvent - Whether to emit a change event (default: true)
2332
- * @returns Promise that resolves to the number of bytes written
2333
- * @throws {OPFSError} If the file descriptor is invalid or writing fails
2334
- *
2335
- * @example
2336
- * \`\`\`typescript
2337
- * const fd = await fs.open('/data/file.txt', { create: true });
2338
- * const data = new TextEncoder().encode('Hello, World!');
2339
- * const bytesWritten = await fs.write(fd, data, 0, data.length, null);
2340
- * console.log(\`Wrote \${bytesWritten} bytes\`);
2341
- * await fs.close(fd);
2342
- * \`\`\`
2343
- */
2344
- async write(t, e, n = 0, r, i, o = !0) {
2345
- const a = this._getFileDescriptor(t), c = r ?? e.length - n;
2346
- St(e.length, n, c, i);
2347
- try {
2348
- const h = i ?? a.position, l = e.subarray(n, n + c), f = a.syncHandle.write(l, { at: h });
2349
- return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2350
- } catch (h) {
2351
- throw z("write", t, a.path, h);
2352
- }
2353
- }
2354
- /**
2355
- * Get file status information by file descriptor
2356
- *
2357
- * @param fd - The file descriptor
2358
- * @returns Promise that resolves to FileStat object
2359
- * @throws {OPFSError} If the file descriptor is invalid
2360
- *
2361
- * @example
2362
- * \`\`\`typescript
2363
- * const fd = await fs.open('/data/file.txt');
2364
- * const stats = await fs.fstat(fd);
2365
- * console.log(\`File size: \${stats.size} bytes\`);
2366
- * console.log(\`Last modified: \${stats.mtime}\`);
2367
- *
2368
- * // If hashing is enabled, hash will be included
2369
- * if (stats.hash) {
2370
- * console.log(\`Hash: \${stats.hash}\`);
2371
- * }
2372
- * \`\`\`
2373
- */
2374
- async fstat(t) {
2375
- const e = this._getFileDescriptor(t);
2376
- return this.stat(e.path);
2377
- }
2378
- /**
2379
- * Truncate file to specified size
2380
- *
2381
- * @param fd - The file descriptor
2382
- * @param size - The new size of the file (default: 0)
2383
- * @returns Promise that resolves when truncation is complete
2384
- * @throws {OPFSError} If the file descriptor is invalid or truncation fails
2385
- *
2386
- * @example
2387
- * \`\`\`typescript
2388
- * const fd = await fs.open('/data/file.txt', { create: true });
2389
- * await fs.truncate(fd, 100); // Truncate to 100 bytes
2390
- * \`\`\`
2391
- */
2392
- async ftruncate(t, e = 0) {
2393
- const n = this._getFileDescriptor(t);
2394
- if (e < 0 || !Number.isInteger(e))
2395
- throw new N("argument", "Invalid size");
2396
- try {
2397
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2398
- } catch (r) {
2399
- throw z("truncate", t, n.path, r);
2400
- }
2401
- }
2402
- /**
2403
- * Synchronize file data to storage (fsync equivalent)
2404
- *
2405
- * @param fd - The file descriptor
2406
- * @returns Promise that resolves when synchronization is complete
2407
- * @throws {OPFSError} If the file descriptor is invalid or sync fails
2408
- *
2409
- * @example
2410
- * \`\`\`typescript
2411
- * const fd = await fs.open('/data/file.txt', { create: true });
2412
- * await fs.write(fd, data);
2413
- * await fs.fsync(fd); // Ensure data is written to storage
2414
- * \`\`\`
2415
- */
2416
- async fsync(t) {
2417
- const e = this._getFileDescriptor(t);
2418
- try {
2419
- e.syncHandle.flush();
2420
- } catch (n) {
2421
- throw z("sync", t, e.path, n);
2422
- }
2423
- }
2424
- /**
2425
- * Dispose of resources and clean up the file system instance
2426
- *
2427
- * This method should be called when the file system instance is no longer needed
2428
- * to properly clean up resources like the broadcast channel and watch timers.
2429
- */
2430
- dispose() {
2431
- this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2432
- for (const [t, e] of this.openHandles)
2433
- xt(-1, e.syncHandle, t);
2434
- this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1;
2435
- }
2436
- /**
2437
- * Synchronize the file system with external data
2438
- *
2439
- * Syncs the file system with an array of entries containing paths and data.
2440
- * This is useful for importing data from external sources or syncing with remote data.
2441
- *
2442
- * @param entries - Array of [path, data] tuples to sync
2443
- * @returns Promise that resolves when synchronization is complete
2444
- * @throws {OPFSError} If the synchronization fails
2445
- *
2446
- * @example
2447
- * \`\`\`typescript
2448
- * // Sync with external data
2449
- * const entries: [string, string | Uint8Array | Blob][] = [
2450
- * ['/config.json', JSON.stringify({ theme: 'dark' })],
2451
- * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
2452
- * ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })]
2453
- * ];
2454
- *
2455
- * // Sync without clearing existing files
2456
- * await fs.sync(entries);
2457
- *
2458
- * // Clean file system and then sync
2459
- * await fs.sync(entries, { cleanBefore: true });
2460
- * \`\`\`
2461
- */
2462
- async createIndex(t) {
2463
- await this.mount();
2464
- try {
2465
- for (const [e, n] of t) {
2466
- const r = B(e);
2467
- let i;
2468
- n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2469
- }
2470
- } catch (e) {
2471
- throw e instanceof w ? e : O(e);
2472
- }
2473
- }
2474
- }
2475
- ot(new gs());
2476
- //# sourceMappingURL=worker.entry-DUlEoroc.js.map
2477
- `,l=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",p],{type:"text/javascript;charset=utf-8"});function y(o){let n;try{if(n=l&&(self.URL||self.webkitURL).createObjectURL(l),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(p),{type:"module",name:o?.name})}}const w=y;function g(o,n){n&&(n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),o.setOptions(n))}function f(o){const n=new w,t=m.wrap(n);return g(t,o),{fs:t,worker:n,dispose(){(async()=>{try{await t.dispose()}finally{n.terminate()}})()}}}function a(o){return o instanceof URL?o.pathname:o}class h{#n;#t;promises=this;constructor(n){const t=f(n);this.#n=t.fs,this.#t=t.dispose}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let s;typeof t=="string"?s=t:t&&typeof t=="object"&&(s=t.encoding);const i=await this.#n.readFile(r);return s||(s=e.isBinaryFileExtension(r)?"binary":"utf-8"),s==="binary"?i:e.decodeBuffer(i,s)}async writeFile(n,t,r){const s=a(n);let i;typeof r=="string"?i=r:r&&typeof r=="object"&&(i=r.encoding),i||(i=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const c=typeof t=="string"?e.encodeString(t,i):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(s,c)}async appendFile(n,t,r){const s=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(s,i)}async mkdir(n,t){const r=a(n);let s;return typeof t=="number"?s={recursive:!1}:s=t,this.#n.mkdir(r,s)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const s=a(n),i=a(t);return this.#n.rename(s,i,r)}async copy(n,t,r){const s=a(n),i=a(t);return this.#n.copy(s,i,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,s,i){const{bytesRead:c,buffer:u}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(u.subarray(0,c),r),{bytesRead:c,buffer:t}}async write(n,t,r,s,i,c){return this.#n.write(n,t,r,s,i,c)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}async createIndex(n){const t=n.map(([r,s])=>[a(r),s]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),s=await this.#n.readFile(r);return e.decodeBuffer(s,t)}async writeText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.writeFile(s,i)}async appendText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.appendFile(s,i)}dispose(){this.#t()}}function d(o){return new h(o)}const b=d;exports.AlreadyExistsError=e.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryOperationError=e.DirectoryOperationError;exports.ExistenceError=e.ExistenceError;exports.FileBusyError=e.FileBusyError;exports.FileSystemOperationError=e.FileSystemOperationError;exports.FileTypeError=e.FileTypeError;exports.IOError=e.IOError;exports.InitializationFailedError=e.InitializationFailedError;exports.OPFSError=e.OPFSError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.OperationAbortedError=e.OperationAbortedError;exports.OperationNotSupportedError=e.OperationNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.ValidationError=e.ValidationError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFacade=h;exports.OPFSFileSystem=h;exports.createOPFS=d;exports.createOPFSWorker=f;exports.createWorker=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./BaseOPFS-BPw9AIQ-.cjs"),t=require("./OPFSSync-C7KBepe_.cjs"),a=require("./OPFSFacade-DePnNRgt.cjs"),e=require("./createOPFSDedicated-pKTRWLdz.cjs"),o=require("./OPFSAsync-s2P7y3sw.cjs"),i=require("./createOPFSAsync-BwKDmHsy.cjs"),c=require("./createOPFSShared-CskROt7U.cjs");exports.AlreadyExistsError=r.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=r.BINARY_FILE_EXTENSIONS;exports.BaseOPFS=r.BaseOPFS;exports.DirectoryOperationError=r.DirectoryOperationError;exports.ExistenceError=r.ExistenceError;exports.FileBusyError=r.FileBusyError;exports.FileSystemOperationError=r.FileSystemOperationError;exports.FileTypeError=r.FileTypeError;exports.IOError=r.IOError;exports.InitializationFailedError=r.InitializationFailedError;exports.OPFSError=r.OPFSError;exports.OPFSNotSupportedError=r.OPFSNotSupportedError;exports.OperationAbortedError=r.OperationAbortedError;exports.OperationNotSupportedError=r.OperationNotSupportedError;exports.PathError=r.PathError;exports.PermissionError=r.PermissionError;exports.StorageError=r.StorageError;exports.ValidationError=r.ValidationError;exports.WatchEventType=r.WatchEventType;exports.basename=r.basename;exports.buffersEqual=r.buffersEqual;exports.calculateFileHash=r.calculateFileHash;exports.calculateReadLength=r.calculateReadLength;exports.checkOPFSSupport=r.checkOPFSSupport;exports.convertBlobToUint8Array=r.convertBlobToUint8Array;exports.createBuffer=r.createBuffer;exports.createFDError=r.createFDError;exports.createSyncHandleSafe=r.createSyncHandleSafe;exports.decodeBuffer=r.decodeBuffer;exports.dirname=r.dirname;exports.encodeString=r.encodeString;exports.extname=r.extname;exports.isBinaryFileExtension=r.isBinaryFileExtension;exports.isPathExcluded=r.isPathExcluded;exports.joinPath=r.joinPath;exports.mapDomError=r.mapDomError;exports.matchMinimatch=r.matchMinimatch;exports.normalizeMinimatch=r.normalizeMinimatch;exports.normalizePath=r.normalizePath;exports.removeEntry=r.removeEntry;exports.resolvePath=r.resolvePath;exports.safeCloseSyncHandle=r.safeCloseSyncHandle;exports.splitPath=r.splitPath;exports.validateReadWriteArgs=r.validateReadWriteArgs;exports.withLock=r.withLock;exports.OPFSSync=t.OPFSSync;exports.OPFSFacade=a.OPFSFacade;exports.OPFSFileSystem=a.OPFSFacade;exports.createOPFS=e.createOPFSDedicated;exports.createOPFSDedicated=e.createOPFSDedicated;exports.createWorker=e.createOPFSDedicated;exports.OPFSAsync=o.OPFSAsync;exports.createOPFSAsync=i.createOPFSAsync;exports.createOPFSShared=c.createOPFSShared;
2478
2
  //# sourceMappingURL=index.cjs.map