opfs-worker 1.3.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -106
- package/dist/{facade.d.ts → OPFSFacade.d.ts} +26 -9
- package/dist/OPFSFacade.d.ts.map +1 -0
- package/dist/{worker.d.ts → OPFSWorker.d.ts} +11 -11
- package/dist/OPFSWorker.d.ts.map +1 -0
- package/dist/assets/worker.entry-DUlEoroc.js.map +1 -0
- package/dist/createOPFSWorker.d.ts +17 -0
- package/dist/createOPFSWorker.d.ts.map +1 -0
- package/dist/helpers-DNj8ZoMu.cjs +4 -0
- package/dist/helpers-DNj8ZoMu.cjs.map +1 -0
- package/dist/{helpers-CKOebsbw.js → helpers-WY2jfbOT.js} +257 -253
- package/dist/helpers-WY2jfbOT.js.map +1 -0
- package/dist/index.cjs +349 -329
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +428 -382
- package/dist/index.js.map +1 -1
- package/dist/index.pure.cjs +2 -0
- package/dist/index.pure.cjs.map +1 -0
- package/dist/index.pure.d.ts +6 -0
- package/dist/index.pure.d.ts.map +1 -0
- package/dist/{raw.js → index.pure.js} +248 -188
- package/dist/index.pure.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +14 -6
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +15 -3
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.entry.d.ts +2 -0
- package/dist/worker.entry.d.ts.map +1 -0
- package/docs/api-reference.md +815 -0
- package/docs/file-descriptors.md +696 -0
- package/docs/types.md +232 -0
- package/package.json +15 -9
- package/src/OPFSFacade.ts +460 -0
- package/src/OPFSWorker.ts +1544 -0
- package/src/createOPFSWorker.ts +57 -0
- package/src/index.pure.ts +7 -0
- package/src/index.ts +15 -0
- package/src/types.ts +99 -0
- package/src/utils/encoder.ts +205 -0
- package/src/utils/errors.ts +297 -0
- package/src/utils/helpers.ts +465 -0
- package/src/worker.entry.ts +6 -0
- package/dist/assets/worker-1Wh1cr7P.js.map +0 -1
- package/dist/assets/worker-BeJaVyBV.js.map +0 -1
- package/dist/facade.d.ts.map +0 -1
- package/dist/helpers-BuGfPAg0.js +0 -1439
- package/dist/helpers-BuGfPAg0.js.map +0 -1
- package/dist/helpers-CF7A2WQG.cjs +0 -4
- package/dist/helpers-CF7A2WQG.cjs.map +0 -1
- package/dist/helpers-CIiblZ8d.cjs +0 -4
- package/dist/helpers-CIiblZ8d.cjs.map +0 -1
- package/dist/helpers-CKOebsbw.js.map +0 -1
- package/dist/raw.cjs +0 -2
- package/dist/raw.cjs.map +0 -1
- package/dist/raw.d.ts +0 -13
- package/dist/raw.d.ts.map +0 -1
- package/dist/raw.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./helpers-DNj8ZoMu.cjs"),m=require("comlink"),p=`/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const bt = Symbol("Comlink.proxy"),
|
|
6
|
+
const bt = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
|
|
7
7
|
canHandle: (s) => Ot(s) && s[bt],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
@@ -13,7 +13,7 @@ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol
|
|
|
13
13
|
return s.start(), Gt(s);
|
|
14
14
|
}
|
|
15
15
|
}, _t = {
|
|
16
|
-
canHandle: (s) => Ot(s) &&
|
|
16
|
+
canHandle: (s) => Ot(s) && j in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
19
19
|
return s instanceof Error ? t = {
|
|
@@ -46,30 +46,30 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
46
46
|
console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data),
|
|
49
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(C);
|
|
50
50
|
let h;
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
52
|
+
const l = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
53
53
|
switch (o) {
|
|
54
54
|
case "GET":
|
|
55
55
|
h = f;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
|
|
58
|
+
l[a.slice(-1)[0]] = C(r.data.value), h = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
|
-
h = f.apply(
|
|
61
|
+
h = f.apply(l, c);
|
|
62
62
|
break;
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
|
-
const u = new f(...
|
|
65
|
+
const u = new f(...c);
|
|
66
66
|
h = Zt(u);
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: u, port2: d } = new MessageChannel();
|
|
72
|
-
ot(s, d), h =
|
|
72
|
+
ot(s, d), h = _(u, [u]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -78,16 +78,16 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
78
78
|
default:
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
} catch (
|
|
82
|
-
h = { value:
|
|
81
|
+
} catch (l) {
|
|
82
|
+
h = { value: l, [j]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((
|
|
85
|
-
const [f, u] =
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
87
|
-
}).catch((
|
|
88
|
-
const [f, u] =
|
|
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
89
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
90
|
+
[j]: 0
|
|
91
91
|
});
|
|
92
92
|
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
93
93
|
});
|
|
@@ -96,7 +96,7 @@ function ot(s, t = globalThis, e = ["*"]) {
|
|
|
96
96
|
function Bt(s) {
|
|
97
97
|
return s.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function At(s) {
|
|
100
100
|
Bt(s) && s.close();
|
|
101
101
|
}
|
|
102
102
|
function Gt(s, t) {
|
|
@@ -112,82 +112,82 @@ function Gt(s, t) {
|
|
|
112
112
|
} finally {
|
|
113
113
|
e.delete(i.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), st(s, e, [], t);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function L(s) {
|
|
118
118
|
if (s)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function vt(s) {
|
|
122
122
|
return $(s, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
At(s);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
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
131
|
});
|
|
132
132
|
function qt(s, t) {
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
133
|
+
const e = (G.get(t) || 0) + 1;
|
|
134
|
+
G.set(t, e), q && q.register(s, t, s);
|
|
135
135
|
}
|
|
136
136
|
function Vt(s) {
|
|
137
|
-
|
|
137
|
+
q && q.unregister(s);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function st(s, t, e = [], n = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let r = !1;
|
|
142
142
|
const i = new Proxy(n, {
|
|
143
143
|
get(o, a) {
|
|
144
|
-
if (
|
|
144
|
+
if (L(r), a === Wt)
|
|
145
145
|
return () => {
|
|
146
|
-
Vt(i),
|
|
146
|
+
Vt(i), vt(s), t.clear(), r = !0;
|
|
147
147
|
};
|
|
148
148
|
if (a === "then") {
|
|
149
149
|
if (e.length === 0)
|
|
150
150
|
return { then: () => i };
|
|
151
|
-
const
|
|
151
|
+
const c = $(s, t, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: e.map((h) => h.toString())
|
|
154
154
|
}).then(C);
|
|
155
|
-
return
|
|
155
|
+
return c.then.bind(c);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return st(s, t, [...e, a]);
|
|
158
158
|
},
|
|
159
|
-
set(o, a,
|
|
160
|
-
|
|
161
|
-
const [h,
|
|
159
|
+
set(o, a, c) {
|
|
160
|
+
L(r);
|
|
161
|
+
const [h, l] = V(c);
|
|
162
162
|
return $(s, t, {
|
|
163
163
|
type: "SET",
|
|
164
164
|
path: [...e, a].map((f) => f.toString()),
|
|
165
165
|
value: h
|
|
166
|
-
},
|
|
166
|
+
}, l).then(C);
|
|
167
167
|
},
|
|
168
|
-
apply(o, a,
|
|
169
|
-
|
|
168
|
+
apply(o, a, c) {
|
|
169
|
+
L(r);
|
|
170
170
|
const h = e[e.length - 1];
|
|
171
|
-
if (h ===
|
|
171
|
+
if (h === zt)
|
|
172
172
|
return $(s, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
174
|
}).then(C);
|
|
175
175
|
if (h === "bind")
|
|
176
|
-
return
|
|
177
|
-
const [
|
|
176
|
+
return st(s, t, e.slice(0, -1));
|
|
177
|
+
const [l, f] = ht(c);
|
|
178
178
|
return $(s, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: e.map((u) => u.toString()),
|
|
181
|
-
argumentList:
|
|
181
|
+
argumentList: l
|
|
182
182
|
}, f).then(C);
|
|
183
183
|
},
|
|
184
184
|
construct(o, a) {
|
|
185
|
-
|
|
186
|
-
const [
|
|
185
|
+
L(r);
|
|
186
|
+
const [c, h] = ht(a);
|
|
187
187
|
return $(s, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
|
-
path: e.map((
|
|
190
|
-
argumentList:
|
|
189
|
+
path: e.map((l) => l.toString()),
|
|
190
|
+
argumentList: c
|
|
191
191
|
}, h).then(C);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
@@ -197,17 +197,17 @@ function Yt(s) {
|
|
|
197
197
|
return Array.prototype.concat.apply([], s);
|
|
198
198
|
}
|
|
199
199
|
function ht(s) {
|
|
200
|
-
const t = s.map(
|
|
200
|
+
const t = s.map(V);
|
|
201
201
|
return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
|
|
202
202
|
}
|
|
203
203
|
const Nt = /* @__PURE__ */ new WeakMap();
|
|
204
|
-
function
|
|
204
|
+
function _(s, t) {
|
|
205
205
|
return Nt.set(s, t), s;
|
|
206
206
|
}
|
|
207
207
|
function Zt(s) {
|
|
208
208
|
return Object.assign(s, { [bt]: !0 });
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function V(s) {
|
|
211
211
|
for (const [t, e] of Dt)
|
|
212
212
|
if (e.canHandle(s)) {
|
|
213
213
|
const [n, r] = e.serialize(s);
|
|
@@ -245,7 +245,7 @@ function $(s, t, e, n) {
|
|
|
245
245
|
function Xt() {
|
|
246
246
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
247
|
}
|
|
248
|
-
var
|
|
248
|
+
var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
|
|
249
249
|
const Jt = {
|
|
250
250
|
ENOENT: -2,
|
|
251
251
|
// No such file or directory
|
|
@@ -296,7 +296,7 @@ class Kt extends w {
|
|
|
296
296
|
super(t, "INVALID_PATH", e, "access", n);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
class
|
|
299
|
+
class U extends w {
|
|
300
300
|
constructor(t, e, n) {
|
|
301
301
|
const r = {
|
|
302
302
|
file: \`File not found: \${e}\`,
|
|
@@ -321,7 +321,7 @@ class se extends w {
|
|
|
321
321
|
super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
class
|
|
324
|
+
class nt extends w {
|
|
325
325
|
constructor(t, e, n) {
|
|
326
326
|
const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
327
327
|
super(r, i, e, "access", n);
|
|
@@ -368,36 +368,36 @@ class re extends w {
|
|
|
368
368
|
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
class
|
|
371
|
+
class J extends w {
|
|
372
372
|
constructor(t, e, n) {
|
|
373
373
|
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
class
|
|
376
|
+
class Q extends w {
|
|
377
377
|
constructor(t, e) {
|
|
378
378
|
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function z(s, t, e, n) {
|
|
382
382
|
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
383
383
|
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
const e = t?.path, n = t?.isDirectory;
|
|
385
|
+
function O(s, t) {
|
|
386
|
+
const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
|
|
387
387
|
switch (s.name) {
|
|
388
388
|
case "InvalidStateError":
|
|
389
389
|
return new se(e || "unknown", s);
|
|
390
390
|
case "QuotaExceededError":
|
|
391
391
|
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
392
392
|
case "NotFoundError":
|
|
393
|
-
return new
|
|
393
|
+
return new U(r, e, s);
|
|
394
394
|
case "TypeMismatchError":
|
|
395
|
-
return n !== void 0 ? n ? new
|
|
395
|
+
return n !== void 0 ? n ? new nt("directory", e || "unknown", s) : new nt("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
396
396
|
case "NotAllowedError":
|
|
397
397
|
case "SecurityError":
|
|
398
398
|
return new te(e, "unknown", s);
|
|
399
399
|
case "InvalidModificationError":
|
|
400
|
-
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
400
|
+
return i === "remove" ? new rt("ENOTEMPTY", e, s) : new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
401
401
|
case "AbortError":
|
|
402
402
|
return new ne(e || "unknown", s);
|
|
403
403
|
case "OperationError":
|
|
@@ -405,10 +405,10 @@ function A(s, t) {
|
|
|
405
405
|
case "TypeError":
|
|
406
406
|
return new Ct(e || "unknown", s);
|
|
407
407
|
default:
|
|
408
|
-
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
408
|
+
return i === "remove" ? new rt("RM_FAILED", e, s) : new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
-
const
|
|
411
|
+
const $t = (s, t, e) => {
|
|
412
412
|
const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
|
|
413
413
|
return i && {
|
|
414
414
|
start: i[0],
|
|
@@ -421,37 +421,37 @@ const Ft = (s, t, e) => {
|
|
|
421
421
|
const e = t.match(s);
|
|
422
422
|
return e ? e[0] : null;
|
|
423
423
|
}, ie = (s, t, e) => {
|
|
424
|
-
let n, r, i, o, a,
|
|
425
|
-
if (
|
|
424
|
+
let n, r, i, o, a, c = e.indexOf(s), h = e.indexOf(t, c + 1), l = c;
|
|
425
|
+
if (c >= 0 && h > 0) {
|
|
426
426
|
if (s === t)
|
|
427
|
-
return [
|
|
428
|
-
for (n = [], i = e.length;
|
|
429
|
-
if (
|
|
430
|
-
n.push(
|
|
427
|
+
return [c, h];
|
|
428
|
+
for (n = [], i = e.length; l >= 0 && !a; ) {
|
|
429
|
+
if (l === c)
|
|
430
|
+
n.push(l), c = e.indexOf(s, l + 1);
|
|
431
431
|
else if (n.length === 1) {
|
|
432
432
|
const f = n.pop();
|
|
433
433
|
f !== void 0 && (a = [f, h]);
|
|
434
434
|
} else
|
|
435
|
-
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t,
|
|
436
|
-
|
|
435
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
|
|
436
|
+
l = c < h && c >= 0 ? c : h;
|
|
437
437
|
}
|
|
438
438
|
n.length && o !== void 0 && (a = [i, o]);
|
|
439
439
|
}
|
|
440
440
|
return a;
|
|
441
|
-
},
|
|
442
|
-
function
|
|
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
443
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
444
444
|
}
|
|
445
445
|
function we(s) {
|
|
446
|
-
return s.replace(ue,
|
|
446
|
+
return s.replace(ue, Ft).replace(fe, Mt).replace(de, at).replace(pe, Tt).replace(ge, Pt);
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function ye(s) {
|
|
449
449
|
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
450
450
|
}
|
|
451
451
|
function Rt(s) {
|
|
452
452
|
if (!s)
|
|
453
453
|
return [""];
|
|
454
|
-
const t = [], e =
|
|
454
|
+
const t = [], e = $t("{", "}", s);
|
|
455
455
|
if (!e)
|
|
456
456
|
return s.split(",");
|
|
457
457
|
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
@@ -459,8 +459,8 @@ function Rt(s) {
|
|
|
459
459
|
const a = Rt(i);
|
|
460
460
|
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
461
461
|
}
|
|
462
|
-
function
|
|
463
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)),
|
|
462
|
+
function me(s) {
|
|
463
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), R(we(s), !0).map(ye)) : [];
|
|
464
464
|
}
|
|
465
465
|
function Ee(s) {
|
|
466
466
|
return "{" + s + "}";
|
|
@@ -474,59 +474,59 @@ function xe(s, t) {
|
|
|
474
474
|
function be(s, t) {
|
|
475
475
|
return s >= t;
|
|
476
476
|
}
|
|
477
|
-
function
|
|
478
|
-
const e = [], n =
|
|
477
|
+
function R(s, t) {
|
|
478
|
+
const e = [], n = $t("{", "}", s);
|
|
479
479
|
if (!n)
|
|
480
480
|
return [s];
|
|
481
|
-
const r = n.pre, i = n.post.length ?
|
|
481
|
+
const r = n.pre, i = n.post.length ? R(n.post, !1) : [""];
|
|
482
482
|
if (/\\$$/.test(n.pre))
|
|
483
483
|
for (let o = 0; o < i.length; o++) {
|
|
484
484
|
const a = r + "{" + n.body + "}" + i[o];
|
|
485
485
|
e.push(a);
|
|
486
486
|
}
|
|
487
487
|
else {
|
|
488
|
-
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body),
|
|
489
|
-
if (!
|
|
490
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post,
|
|
491
|
-
let
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
else if (
|
|
495
|
-
return i.map((u) => n.pre +
|
|
488
|
+
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), c = o || a, h = n.body.indexOf(",") >= 0;
|
|
489
|
+
if (!c && !h)
|
|
490
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, R(s)) : [s];
|
|
491
|
+
let l;
|
|
492
|
+
if (c)
|
|
493
|
+
l = n.body.split(/\\.\\./);
|
|
494
|
+
else if (l = Rt(n.body), l.length === 1 && l[0] !== void 0 && (l = R(l[0], !1).map(Ee), l.length === 1))
|
|
495
|
+
return i.map((u) => n.pre + l[0] + u);
|
|
496
496
|
let f;
|
|
497
|
-
if (
|
|
498
|
-
const u =
|
|
499
|
-
let p =
|
|
497
|
+
if (c && l[0] !== void 0 && l[1] !== void 0) {
|
|
498
|
+
const u = K(l[0]), d = K(l[1]), g = Math.max(l[0].length, l[1].length);
|
|
499
|
+
let p = l.length === 3 && l[2] !== void 0 ? Math.abs(K(l[2])) : 1, S = xe;
|
|
500
500
|
d < u && (p *= -1, S = be);
|
|
501
|
-
const
|
|
501
|
+
const M = l.some(Se);
|
|
502
502
|
f = [];
|
|
503
503
|
for (let x = u; S(x, d); x += p) {
|
|
504
|
-
let
|
|
504
|
+
let y;
|
|
505
505
|
if (a)
|
|
506
|
-
|
|
507
|
-
else if (
|
|
508
|
-
const T = g -
|
|
506
|
+
y = String.fromCharCode(x), y === "\\\\" && (y = "");
|
|
507
|
+
else if (y = String(x), M) {
|
|
508
|
+
const T = g - y.length;
|
|
509
509
|
if (T > 0) {
|
|
510
510
|
const H = new Array(T + 1).join("0");
|
|
511
|
-
x < 0 ?
|
|
511
|
+
x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
f.push(
|
|
514
|
+
f.push(y);
|
|
515
515
|
}
|
|
516
516
|
} else {
|
|
517
517
|
f = [];
|
|
518
|
-
for (let u = 0; u <
|
|
519
|
-
f.push.apply(f,
|
|
518
|
+
for (let u = 0; u < l.length; u++)
|
|
519
|
+
f.push.apply(f, R(l[u], !1));
|
|
520
520
|
}
|
|
521
521
|
for (let u = 0; u < f.length; u++)
|
|
522
522
|
for (let d = 0; d < i.length; d++) {
|
|
523
523
|
const g = r + f[u] + i[d];
|
|
524
|
-
(!t ||
|
|
524
|
+
(!t || c || g) && e.push(g);
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
return e;
|
|
528
528
|
}
|
|
529
|
-
const Oe = 1024 * 64,
|
|
529
|
+
const Oe = 1024 * 64, Y = (s) => {
|
|
530
530
|
if (typeof s != "string")
|
|
531
531
|
throw new TypeError("invalid pattern");
|
|
532
532
|
if (s.length > Oe)
|
|
@@ -546,60 +546,60 @@ const Oe = 1024 * 64, Z = (s) => {
|
|
|
546
546
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
547
547
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
548
548
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
549
|
-
},
|
|
549
|
+
}, P = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), Ae = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), ve = (s, t) => {
|
|
550
550
|
const e = t;
|
|
551
551
|
if (s.charAt(e) !== "[")
|
|
552
552
|
throw new Error("not in a brace expression");
|
|
553
553
|
const n = [], r = [];
|
|
554
|
-
let i = e + 1, o = !1, a = !1,
|
|
554
|
+
let i = e + 1, o = !1, a = !1, c = !1, h = !1, l = e, f = "";
|
|
555
555
|
t: for (; i < s.length; ) {
|
|
556
556
|
const p = s.charAt(i);
|
|
557
557
|
if ((p === "!" || p === "^") && i === e + 1) {
|
|
558
558
|
h = !0, i++;
|
|
559
559
|
continue;
|
|
560
560
|
}
|
|
561
|
-
if (p === "]" && o && !
|
|
562
|
-
|
|
561
|
+
if (p === "]" && o && !c) {
|
|
562
|
+
l = i + 1;
|
|
563
563
|
break;
|
|
564
564
|
}
|
|
565
|
-
if (o = !0, p === "\\\\" && !
|
|
566
|
-
|
|
565
|
+
if (o = !0, p === "\\\\" && !c) {
|
|
566
|
+
c = !0, i++;
|
|
567
567
|
continue;
|
|
568
568
|
}
|
|
569
|
-
if (p === "[" && !
|
|
570
|
-
for (const [S, [v,
|
|
569
|
+
if (p === "[" && !c) {
|
|
570
|
+
for (const [S, [v, M, x]] of Object.entries(De))
|
|
571
571
|
if (s.startsWith(S, i)) {
|
|
572
572
|
if (f)
|
|
573
573
|
return ["$.", !1, s.length - e, !0];
|
|
574
|
-
i += S.length, x ? r.push(v) : n.push(v), a = a ||
|
|
574
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || M;
|
|
575
575
|
continue t;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
if (
|
|
579
|
-
p > f ? n.push(
|
|
578
|
+
if (c = !1, f) {
|
|
579
|
+
p > f ? n.push(P(f) + "-" + P(p)) : p === f && n.push(P(p)), f = "", i++;
|
|
580
580
|
continue;
|
|
581
581
|
}
|
|
582
582
|
if (s.startsWith("-]", i + 1)) {
|
|
583
|
-
n.push(
|
|
583
|
+
n.push(P(p + "-")), i += 2;
|
|
584
584
|
continue;
|
|
585
585
|
}
|
|
586
586
|
if (s.startsWith("-", i + 1)) {
|
|
587
587
|
f = p, i += 2;
|
|
588
588
|
continue;
|
|
589
589
|
}
|
|
590
|
-
n.push(
|
|
590
|
+
n.push(P(p)), i++;
|
|
591
591
|
}
|
|
592
|
-
if (
|
|
592
|
+
if (l < i)
|
|
593
593
|
return ["", !1, 0, !1];
|
|
594
594
|
if (!n.length && !r.length)
|
|
595
595
|
return ["$.", !1, s.length - e, !0];
|
|
596
596
|
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
597
597
|
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
598
|
-
return [
|
|
598
|
+
return [Ae(p), !1, l - e, !1];
|
|
599
599
|
}
|
|
600
600
|
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
601
|
-
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a,
|
|
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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))",
|
|
601
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, l - e, !0];
|
|
602
|
+
}, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", W = "(?!\\\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Fe = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Te = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
603
603
|
class E {
|
|
604
604
|
type;
|
|
605
605
|
#s;
|
|
@@ -700,7 +700,7 @@ class E {
|
|
|
700
700
|
return e;
|
|
701
701
|
}
|
|
702
702
|
static #h(t, e, n, r) {
|
|
703
|
-
let i = !1, o = !1, a = -1,
|
|
703
|
+
let i = !1, o = !1, a = -1, c = !1;
|
|
704
704
|
if (e.type === null) {
|
|
705
705
|
let d = n, g = "";
|
|
706
706
|
for (; d < t.length; ) {
|
|
@@ -710,10 +710,10 @@ class E {
|
|
|
710
710
|
continue;
|
|
711
711
|
}
|
|
712
712
|
if (o) {
|
|
713
|
-
d === a + 1 ? (p === "^" || p === "!") && (
|
|
713
|
+
d === a + 1 ? (p === "^" || p === "!") && (c = !0) : p === "]" && !(d === a + 2 && c) && (o = !1), g += p;
|
|
714
714
|
continue;
|
|
715
715
|
} else if (p === "[") {
|
|
716
|
-
o = !0, a = d,
|
|
716
|
+
o = !0, a = d, c = !1, g += p;
|
|
717
717
|
continue;
|
|
718
718
|
}
|
|
719
719
|
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
@@ -726,7 +726,7 @@ class E {
|
|
|
726
726
|
}
|
|
727
727
|
return e.push(g), d;
|
|
728
728
|
}
|
|
729
|
-
let h = n + 1,
|
|
729
|
+
let h = n + 1, l = new E(null, e);
|
|
730
730
|
const f = [];
|
|
731
731
|
let u = "";
|
|
732
732
|
for (; h < t.length; ) {
|
|
@@ -736,24 +736,24 @@ class E {
|
|
|
736
736
|
continue;
|
|
737
737
|
}
|
|
738
738
|
if (o) {
|
|
739
|
-
h === a + 1 ? (d === "^" || d === "!") && (
|
|
739
|
+
h === a + 1 ? (d === "^" || d === "!") && (c = !0) : d === "]" && !(h === a + 2 && c) && (o = !1), u += d;
|
|
740
740
|
continue;
|
|
741
741
|
} else if (d === "[") {
|
|
742
|
-
o = !0, a = h,
|
|
742
|
+
o = !0, a = h, c = !1, u += d;
|
|
743
743
|
continue;
|
|
744
744
|
}
|
|
745
745
|
if (pt(d) && t.charAt(h) === "(") {
|
|
746
|
-
|
|
747
|
-
const g = new E(d,
|
|
748
|
-
|
|
746
|
+
l.push(u), u = "";
|
|
747
|
+
const g = new E(d, l);
|
|
748
|
+
l.push(g), h = E.#h(t, g, h, r);
|
|
749
749
|
continue;
|
|
750
750
|
}
|
|
751
751
|
if (d === "|") {
|
|
752
|
-
|
|
752
|
+
l.push(u), u = "", f.push(l), l = new E(null, e);
|
|
753
753
|
continue;
|
|
754
754
|
}
|
|
755
755
|
if (d === ")")
|
|
756
|
-
return u === "" && e.#t.length === 0 && (e.#u = !0),
|
|
756
|
+
return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...f, l), h;
|
|
757
757
|
u += d;
|
|
758
758
|
}
|
|
759
759
|
return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
|
|
@@ -851,23 +851,23 @@ class E {
|
|
|
851
851
|
toRegExpSource(t) {
|
|
852
852
|
const e = t ?? !!this.#r.dot;
|
|
853
853
|
if (this.#s === this && this.#d(), !this.type) {
|
|
854
|
-
const
|
|
855
|
-
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n,
|
|
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
856
|
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
857
857
|
}).join("");
|
|
858
|
-
let
|
|
859
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
860
|
-
const g =
|
|
858
|
+
let l = "";
|
|
859
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Fe.has(this.#t[0]))) {
|
|
860
|
+
const g = $e, p = (
|
|
861
861
|
// dots are allowed, and the pattern starts with [ or .
|
|
862
862
|
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
863
863
|
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
864
864
|
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
865
865
|
), S = !e && !t && g.has(h.charAt(0));
|
|
866
|
-
|
|
866
|
+
l = p ? Ce : S ? W : "";
|
|
867
867
|
}
|
|
868
868
|
let f = "";
|
|
869
869
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
870
|
-
|
|
870
|
+
l + h + f,
|
|
871
871
|
k(h),
|
|
872
872
|
this.#n = !!this.#n,
|
|
873
873
|
this.#i
|
|
@@ -876,20 +876,20 @@ class E {
|
|
|
876
876
|
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
877
877
|
let i = this.#f(e);
|
|
878
878
|
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
879
|
-
const
|
|
880
|
-
return this.#t = [
|
|
879
|
+
const c = this.toString();
|
|
880
|
+
return this.#t = [c], this.type = null, this.#n = void 0, [c, k(this.toString()), !1, !1];
|
|
881
881
|
}
|
|
882
|
-
let o = !n || t || e || !
|
|
882
|
+
let o = !n || t || e || !W ? "" : this.#f(!0);
|
|
883
883
|
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
884
884
|
let a = "";
|
|
885
885
|
if (this.type === "!" && this.#u)
|
|
886
|
-
a = (this.isStart() && !e ?
|
|
886
|
+
a = (this.isStart() && !e ? W : "") + wt;
|
|
887
887
|
else {
|
|
888
|
-
const
|
|
888
|
+
const c = this.type === "!" ? (
|
|
889
889
|
// !() must match something,but !(x) can match ''
|
|
890
|
-
"))" + (this.isStart() && !e && !t ?
|
|
890
|
+
"))" + (this.isStart() && !e && !t ? W : "") + gt + ")"
|
|
891
891
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
892
|
-
a = r + i +
|
|
892
|
+
a = r + i + c;
|
|
893
893
|
}
|
|
894
894
|
return [
|
|
895
895
|
a,
|
|
@@ -909,66 +909,66 @@ class E {
|
|
|
909
909
|
static #p(t, e, n = !1) {
|
|
910
910
|
let r = !1, i = "", o = !1;
|
|
911
911
|
for (let a = 0; a < t.length; a++) {
|
|
912
|
-
const
|
|
912
|
+
const c = t.charAt(a);
|
|
913
913
|
if (r) {
|
|
914
|
-
r = !1, i += (Me.has(
|
|
914
|
+
r = !1, i += (Me.has(c) ? "\\\\" : "") + c;
|
|
915
915
|
continue;
|
|
916
916
|
}
|
|
917
|
-
if (
|
|
917
|
+
if (c === "\\\\") {
|
|
918
918
|
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
919
919
|
continue;
|
|
920
920
|
}
|
|
921
|
-
if (
|
|
922
|
-
const [h,
|
|
921
|
+
if (c === "[") {
|
|
922
|
+
const [h, l, f, u] = ve(t, a);
|
|
923
923
|
if (f) {
|
|
924
|
-
i += h, o = o ||
|
|
924
|
+
i += h, o = o || l, a += f - 1, e = e || u;
|
|
925
925
|
continue;
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
-
if (
|
|
928
|
+
if (c === "*") {
|
|
929
929
|
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
930
930
|
continue;
|
|
931
931
|
}
|
|
932
|
-
if (
|
|
932
|
+
if (c === "?") {
|
|
933
933
|
i += ct, e = !0;
|
|
934
934
|
continue;
|
|
935
935
|
}
|
|
936
|
-
i +=
|
|
936
|
+
i += Te(c);
|
|
937
937
|
}
|
|
938
938
|
return [i, k(t), !!e, o];
|
|
939
939
|
}
|
|
940
940
|
}
|
|
941
|
-
const
|
|
942
|
-
const e =
|
|
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
943
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
944
944
|
}, Ze = ([s, t = ""]) => {
|
|
945
|
-
const e =
|
|
945
|
+
const e = It([s]);
|
|
946
946
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
947
947
|
}, Xe = ([s, t = ""]) => {
|
|
948
|
-
const e =
|
|
948
|
+
const e = It([s]);
|
|
949
949
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
950
950
|
}, Je = ([s, t = ""]) => {
|
|
951
|
-
const e =
|
|
951
|
+
const e = kt([s]);
|
|
952
952
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
953
|
-
},
|
|
953
|
+
}, kt = ([s]) => {
|
|
954
954
|
const t = s.length;
|
|
955
955
|
return (e) => e.length === t && !e.startsWith(".");
|
|
956
|
-
},
|
|
956
|
+
}, It = ([s]) => {
|
|
957
957
|
const t = s.length;
|
|
958
958
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
959
|
-
},
|
|
959
|
+
}, Ht = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", yt = {
|
|
960
960
|
win32: { sep: "\\\\" },
|
|
961
961
|
posix: { sep: "/" }
|
|
962
|
-
}, Qe =
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) =>
|
|
967
|
-
|
|
962
|
+
}, Qe = Ht === "win32" ? yt.win32.sep : yt.posix.sep;
|
|
963
|
+
m.sep = Qe;
|
|
964
|
+
const D = Symbol("globstar **");
|
|
965
|
+
m.GLOBSTAR = D;
|
|
966
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => m(e, s, t);
|
|
967
|
+
m.filter = ns;
|
|
968
968
|
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
969
969
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
970
|
-
return
|
|
971
|
-
const t =
|
|
970
|
+
return m;
|
|
971
|
+
const t = m;
|
|
972
972
|
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
973
973
|
Minimatch: class extends t.Minimatch {
|
|
974
974
|
constructor(r, i = {}) {
|
|
@@ -996,21 +996,21 @@ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
|
996
996
|
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
997
997
|
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
998
998
|
sep: t.sep,
|
|
999
|
-
GLOBSTAR:
|
|
999
|
+
GLOBSTAR: D
|
|
1000
1000
|
});
|
|
1001
1001
|
};
|
|
1002
|
-
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
const is = (s, t = {}) => new
|
|
1006
|
-
|
|
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
1007
|
const os = (s, t, e = {}) => {
|
|
1008
|
-
const n = new
|
|
1008
|
+
const n = new Z(t, e);
|
|
1009
1009
|
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
1010
1010
|
};
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
class
|
|
1011
|
+
m.match = os;
|
|
1012
|
+
const mt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1013
|
+
class Z {
|
|
1014
1014
|
options;
|
|
1015
1015
|
set;
|
|
1016
1016
|
pattern;
|
|
@@ -1029,7 +1029,7 @@ class X {
|
|
|
1029
1029
|
windowsNoMagicRoot;
|
|
1030
1030
|
regexp;
|
|
1031
1031
|
constructor(t, e = {}) {
|
|
1032
|
-
|
|
1032
|
+
Y(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ht, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
1033
1033
|
}
|
|
1034
1034
|
hasMagic() {
|
|
1035
1035
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -1057,13 +1057,13 @@ class X {
|
|
|
1057
1057
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
1058
1058
|
let r = this.globParts.map((i, o, a) => {
|
|
1059
1059
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1060
|
-
const
|
|
1061
|
-
if (
|
|
1062
|
-
return [...i.slice(0, 4), ...i.slice(4).map((
|
|
1060
|
+
const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !mt.test(i[2])) && !mt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
1061
|
+
if (c)
|
|
1062
|
+
return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
|
|
1063
1063
|
if (h)
|
|
1064
|
-
return [i[0], ...i.slice(1).map((
|
|
1064
|
+
return [i[0], ...i.slice(1).map((l) => this.parse(l))];
|
|
1065
1065
|
}
|
|
1066
|
-
return i.map((
|
|
1066
|
+
return i.map((c) => this.parse(c));
|
|
1067
1067
|
});
|
|
1068
1068
|
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1069
1069
|
for (let i = 0; i < this.set.length; i++) {
|
|
@@ -1154,12 +1154,12 @@ class X {
|
|
|
1154
1154
|
o++;
|
|
1155
1155
|
o > r && n.splice(r + 1, o - r);
|
|
1156
1156
|
let a = n[r + 1];
|
|
1157
|
-
const
|
|
1158
|
-
if (a !== ".." || !
|
|
1157
|
+
const c = n[r + 2], h = n[r + 3];
|
|
1158
|
+
if (a !== ".." || !c || c === "." || c === ".." || !h || h === "." || h === "..")
|
|
1159
1159
|
continue;
|
|
1160
1160
|
e = !0, n.splice(r, 1);
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1161
|
+
const l = n.slice(0);
|
|
1162
|
+
l[r] = "**", t.push(l), r--;
|
|
1163
1163
|
}
|
|
1164
1164
|
if (!this.preserveMultipleSlashes) {
|
|
1165
1165
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1173,8 +1173,8 @@ class X {
|
|
|
1173
1173
|
const o = n[i - 1];
|
|
1174
1174
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1175
1175
|
e = !0;
|
|
1176
|
-
const
|
|
1177
|
-
n.splice(i - 1, 2, ...
|
|
1176
|
+
const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1177
|
+
n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
|
|
1178
1178
|
}
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
@@ -1237,33 +1237,33 @@ class X {
|
|
|
1237
1237
|
matchOne(t, e, n = !1) {
|
|
1238
1238
|
const r = this.options;
|
|
1239
1239
|
if (this.isWindows) {
|
|
1240
|
-
const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]),
|
|
1241
|
-
if (typeof x == "number" && typeof
|
|
1242
|
-
const [T, H] = [t[x], e[
|
|
1243
|
-
T.toLowerCase() === H.toLowerCase() && (e[
|
|
1240
|
+
const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), M = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, y = M ? 3 : v ? 0 : void 0;
|
|
1241
|
+
if (typeof x == "number" && typeof y == "number") {
|
|
1242
|
+
const [T, H] = [t[x], e[y]];
|
|
1243
|
+
T.toLowerCase() === H.toLowerCase() && (e[y] = T, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
1246
|
const { optimizationLevel: i = 1 } = this.options;
|
|
1247
1247
|
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1248
|
-
for (var o = 0, a = 0,
|
|
1248
|
+
for (var o = 0, a = 0, c = t.length, h = e.length; o < c && a < h; o++, a++) {
|
|
1249
1249
|
this.debug("matchOne loop");
|
|
1250
|
-
var
|
|
1251
|
-
if (this.debug(e,
|
|
1250
|
+
var l = e[a], f = t[o];
|
|
1251
|
+
if (this.debug(e, l, f), l === !1)
|
|
1252
1252
|
return !1;
|
|
1253
|
-
if (
|
|
1254
|
-
this.debug("GLOBSTAR", [e,
|
|
1253
|
+
if (l === D) {
|
|
1254
|
+
this.debug("GLOBSTAR", [e, l, f]);
|
|
1255
1255
|
var u = o, d = a + 1;
|
|
1256
1256
|
if (d === h) {
|
|
1257
|
-
for (this.debug("** at the end"); o <
|
|
1257
|
+
for (this.debug("** at the end"); o < c; o++)
|
|
1258
1258
|
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1259
1259
|
return !1;
|
|
1260
1260
|
return !0;
|
|
1261
1261
|
}
|
|
1262
|
-
for (; u <
|
|
1262
|
+
for (; u < c; ) {
|
|
1263
1263
|
var g = t[u];
|
|
1264
1264
|
if (this.debug(\`
|
|
1265
1265
|
globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1266
|
-
return this.debug("globstar found match!", u,
|
|
1266
|
+
return this.debug("globstar found match!", u, c, g), !0;
|
|
1267
1267
|
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1268
1268
|
this.debug("dot detected!", t, u, e, d);
|
|
1269
1269
|
break;
|
|
@@ -1271,32 +1271,32 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1271
1271
|
this.debug("globstar swallow a segment, and continue"), u++;
|
|
1272
1272
|
}
|
|
1273
1273
|
return !!(n && (this.debug(\`
|
|
1274
|
-
>>> no match, partial?\`, t, u, e, d), u ===
|
|
1274
|
+
>>> no match, partial?\`, t, u, e, d), u === c));
|
|
1275
1275
|
}
|
|
1276
1276
|
let p;
|
|
1277
|
-
if (typeof
|
|
1277
|
+
if (typeof l == "string" ? (p = f === l, this.debug("string match", l, f, p)) : (p = l.test(f), this.debug("pattern match", l, f, p)), !p)
|
|
1278
1278
|
return !1;
|
|
1279
1279
|
}
|
|
1280
|
-
if (o ===
|
|
1280
|
+
if (o === c && a === h)
|
|
1281
1281
|
return !0;
|
|
1282
|
-
if (o ===
|
|
1282
|
+
if (o === c)
|
|
1283
1283
|
return n;
|
|
1284
1284
|
if (a === h)
|
|
1285
|
-
return o ===
|
|
1285
|
+
return o === c - 1 && t[o] === "";
|
|
1286
1286
|
throw new Error("wtf?");
|
|
1287
1287
|
}
|
|
1288
1288
|
braceExpand() {
|
|
1289
|
-
return
|
|
1289
|
+
return Lt(this.pattern, this.options);
|
|
1290
1290
|
}
|
|
1291
1291
|
parse(t) {
|
|
1292
|
-
|
|
1292
|
+
Y(t);
|
|
1293
1293
|
const e = this.options;
|
|
1294
1294
|
if (t === "**")
|
|
1295
|
-
return
|
|
1295
|
+
return D;
|
|
1296
1296
|
if (t === "")
|
|
1297
1297
|
return "";
|
|
1298
1298
|
let n, r = null;
|
|
1299
|
-
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ?
|
|
1299
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : He : e.dot ? Ie : ke)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(ze)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
|
|
1300
1300
|
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1301
1301
|
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1302
1302
|
}
|
|
@@ -1307,17 +1307,17 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1307
1307
|
if (!t.length)
|
|
1308
1308
|
return this.regexp = !1, this.regexp;
|
|
1309
1309
|
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1310
|
-
let i = t.map((
|
|
1311
|
-
const h =
|
|
1312
|
-
if (
|
|
1313
|
-
for (const f of
|
|
1310
|
+
let i = t.map((c) => {
|
|
1311
|
+
const h = c.map((l) => {
|
|
1312
|
+
if (l instanceof RegExp)
|
|
1313
|
+
for (const f of l.flags.split(""))
|
|
1314
1314
|
r.add(f);
|
|
1315
|
-
return typeof
|
|
1315
|
+
return typeof l == "string" ? as(l) : l === D ? D : l._src;
|
|
1316
1316
|
});
|
|
1317
|
-
return h.forEach((
|
|
1317
|
+
return h.forEach((l, f) => {
|
|
1318
1318
|
const u = h[f + 1], d = h[f - 1];
|
|
1319
|
-
|
|
1320
|
-
}), h.filter((
|
|
1319
|
+
l !== D || d === D || (d === void 0 ? u !== void 0 && u !== D ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== D && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = D));
|
|
1320
|
+
}), h.filter((l) => l !== D).join("/");
|
|
1321
1321
|
}).join("|");
|
|
1322
1322
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1323
1323
|
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
@@ -1349,56 +1349,56 @@ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1349
1349
|
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1350
1350
|
o = r[a];
|
|
1351
1351
|
for (let a = 0; a < i.length; a++) {
|
|
1352
|
-
const
|
|
1352
|
+
const c = i[a];
|
|
1353
1353
|
let h = r;
|
|
1354
|
-
if (n.matchBase &&
|
|
1354
|
+
if (n.matchBase && c.length === 1 && (h = [o]), this.matchOne(h, c, e))
|
|
1355
1355
|
return n.flipNegate ? !0 : !this.negate;
|
|
1356
1356
|
}
|
|
1357
1357
|
return n.flipNegate ? !1 : this.negate;
|
|
1358
1358
|
}
|
|
1359
1359
|
static defaults(t) {
|
|
1360
|
-
return
|
|
1360
|
+
return m.defaults(t).Minimatch;
|
|
1361
1361
|
}
|
|
1362
1362
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1363
|
+
m.AST = E;
|
|
1364
|
+
m.Minimatch = Z;
|
|
1365
|
+
m.escape = Pe;
|
|
1366
|
+
m.unescape = k;
|
|
1367
1367
|
function cs() {
|
|
1368
1368
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1369
1369
|
throw new Qt();
|
|
1370
1370
|
}
|
|
1371
|
-
async function
|
|
1372
|
-
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode:
|
|
1371
|
+
async function I(s, t) {
|
|
1372
|
+
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: "exclusive" }, t) : t();
|
|
1373
1373
|
}
|
|
1374
|
-
function
|
|
1374
|
+
function F(s) {
|
|
1375
1375
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1376
1376
|
}
|
|
1377
1377
|
function lt(s) {
|
|
1378
1378
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1379
1379
|
}
|
|
1380
1380
|
function it(s) {
|
|
1381
|
-
const t =
|
|
1381
|
+
const t = F(s);
|
|
1382
1382
|
return t[t.length - 1] || "";
|
|
1383
1383
|
}
|
|
1384
|
-
function
|
|
1385
|
-
const t =
|
|
1384
|
+
function tt(s) {
|
|
1385
|
+
const t = F(s);
|
|
1386
1386
|
return t.pop(), lt(t);
|
|
1387
1387
|
}
|
|
1388
|
-
function
|
|
1388
|
+
function B(s) {
|
|
1389
1389
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1390
1390
|
}
|
|
1391
1391
|
function ls(s, t = !1) {
|
|
1392
1392
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1393
1393
|
}
|
|
1394
|
-
function
|
|
1395
|
-
return
|
|
1394
|
+
function et(s, t) {
|
|
1395
|
+
return m(s, t, {
|
|
1396
1396
|
dot: !0,
|
|
1397
1397
|
matchBase: !0
|
|
1398
1398
|
});
|
|
1399
1399
|
}
|
|
1400
1400
|
function Et(s) {
|
|
1401
|
-
const t =
|
|
1401
|
+
const t = B(s), e = F(t), n = [];
|
|
1402
1402
|
for (const r of e)
|
|
1403
1403
|
if (!(r === "." || r === ""))
|
|
1404
1404
|
if (r === "..") {
|
|
@@ -1421,15 +1421,19 @@ async function us(s) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
async function fs(s, t, e = {}) {
|
|
1423
1423
|
const n = it(t);
|
|
1424
|
-
return
|
|
1424
|
+
return I(t, async () => {
|
|
1425
1425
|
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1426
1426
|
try {
|
|
1427
1427
|
await s.removeEntry(n, { recursive: r });
|
|
1428
1428
|
} catch (o) {
|
|
1429
|
-
if (o.name === "NotFoundError")
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
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
|
+
});
|
|
1433
1437
|
}
|
|
1434
1438
|
});
|
|
1435
1439
|
}
|
|
@@ -1460,7 +1464,7 @@ async function ps(s, t) {
|
|
|
1460
1464
|
try {
|
|
1461
1465
|
return await s.createSyncAccessHandle();
|
|
1462
1466
|
} catch (e) {
|
|
1463
|
-
throw
|
|
1467
|
+
throw O(e, { path: t, isDirectory: !1 });
|
|
1464
1468
|
}
|
|
1465
1469
|
}
|
|
1466
1470
|
class gs {
|
|
@@ -1480,6 +1484,8 @@ class gs {
|
|
|
1480
1484
|
hashAlgorithm: "etag",
|
|
1481
1485
|
broadcastChannel: "opfs-worker"
|
|
1482
1486
|
};
|
|
1487
|
+
/** Shared sync handles per path (OPFS allows only one handle per file) */
|
|
1488
|
+
openHandles = /* @__PURE__ */ new Map();
|
|
1483
1489
|
/** Map of open file descriptors to their metadata */
|
|
1484
1490
|
openFiles = /* @__PURE__ */ new Map();
|
|
1485
1491
|
/** Next available file descriptor number */
|
|
@@ -1500,14 +1506,13 @@ class gs {
|
|
|
1500
1506
|
* This method is called by internal operations to notify clients about
|
|
1501
1507
|
* changes, even when no specific paths are being watched.
|
|
1502
1508
|
*
|
|
1503
|
-
* @param
|
|
1504
|
-
* @param type - The type of change (create, change, delete)
|
|
1509
|
+
* @param event - The event describing the change
|
|
1505
1510
|
*/
|
|
1506
1511
|
async notifyChange(t) {
|
|
1507
1512
|
if (!this.options.broadcastChannel)
|
|
1508
1513
|
return;
|
|
1509
1514
|
const e = t.path;
|
|
1510
|
-
if (![...this.watchers.values()].some((i) =>
|
|
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))))
|
|
1511
1516
|
return;
|
|
1512
1517
|
let r;
|
|
1513
1518
|
if (this.options.hashAlgorithm)
|
|
@@ -1529,7 +1534,7 @@ class gs {
|
|
|
1529
1534
|
}
|
|
1530
1535
|
}
|
|
1531
1536
|
/**
|
|
1532
|
-
* Creates a new
|
|
1537
|
+
* Creates a new OPFSWorker instance
|
|
1533
1538
|
*
|
|
1534
1539
|
* @param options - Optional configuration options
|
|
1535
1540
|
* @param options.root - Root path for the file system (default: '/')
|
|
@@ -1547,13 +1552,12 @@ class gs {
|
|
|
1547
1552
|
* This method sets up the root directory for all subsequent operations.
|
|
1548
1553
|
* If no root is specified, it will use the OPFS root directory.
|
|
1549
1554
|
*
|
|
1550
|
-
* @param root - The root path for the file system (default: '/')
|
|
1551
1555
|
* @returns Promise that resolves to true if initialization was successful
|
|
1552
1556
|
* @throws {OPFSError} If initialization fails
|
|
1553
1557
|
*
|
|
1554
1558
|
* @example
|
|
1555
1559
|
* \`\`\`typescript
|
|
1556
|
-
* const fs = new
|
|
1560
|
+
* const fs = new OPFSWorker();
|
|
1557
1561
|
*
|
|
1558
1562
|
* // Use OPFS root (default)
|
|
1559
1563
|
* await fs.mount();
|
|
@@ -1586,7 +1590,7 @@ class gs {
|
|
|
1586
1590
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1587
1591
|
*/
|
|
1588
1592
|
async setOptions(t) {
|
|
1589
|
-
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 =
|
|
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());
|
|
1590
1594
|
}
|
|
1591
1595
|
/**
|
|
1592
1596
|
* Get a directory handle from a path
|
|
@@ -1607,7 +1611,7 @@ class gs {
|
|
|
1607
1611
|
* \`\`\`
|
|
1608
1612
|
*/
|
|
1609
1613
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1610
|
-
const r = Array.isArray(t) ? t :
|
|
1614
|
+
const r = Array.isArray(t) ? t : F(t);
|
|
1611
1615
|
let i = n;
|
|
1612
1616
|
for (const o of r)
|
|
1613
1617
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
@@ -1633,7 +1637,7 @@ class gs {
|
|
|
1633
1637
|
* \`\`\`
|
|
1634
1638
|
*/
|
|
1635
1639
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1636
|
-
const r =
|
|
1640
|
+
const r = F(t);
|
|
1637
1641
|
if (r.length === 0)
|
|
1638
1642
|
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1639
1643
|
const i = r.pop();
|
|
@@ -1702,17 +1706,17 @@ class gs {
|
|
|
1702
1706
|
async readFile(t) {
|
|
1703
1707
|
await this.mount();
|
|
1704
1708
|
try {
|
|
1705
|
-
return await
|
|
1709
|
+
return await I(t, async () => {
|
|
1706
1710
|
const e = await this.open(t);
|
|
1707
1711
|
try {
|
|
1708
1712
|
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1709
|
-
return n > 0 && await this.read(e, r, 0, n, 0),
|
|
1713
|
+
return n > 0 && await this.read(e, r, 0, n, 0), _(r, [r.buffer]);
|
|
1710
1714
|
} finally {
|
|
1711
1715
|
await this.close(e);
|
|
1712
1716
|
}
|
|
1713
1717
|
});
|
|
1714
1718
|
} catch (e) {
|
|
1715
|
-
throw
|
|
1719
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !1 });
|
|
1716
1720
|
}
|
|
1717
1721
|
}
|
|
1718
1722
|
/**
|
|
@@ -1740,14 +1744,14 @@ class gs {
|
|
|
1740
1744
|
async writeFile(t, e) {
|
|
1741
1745
|
await this.mount();
|
|
1742
1746
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1743
|
-
await
|
|
1747
|
+
await I(t, async () => {
|
|
1744
1748
|
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1745
1749
|
try {
|
|
1746
1750
|
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1747
1751
|
} finally {
|
|
1748
1752
|
await this.close(i);
|
|
1749
1753
|
}
|
|
1750
|
-
await this.notifyChange({ path: t, type: r ?
|
|
1754
|
+
await this.notifyChange({ path: t, type: r ? A.Changed : A.Added, isDirectory: !1 });
|
|
1751
1755
|
});
|
|
1752
1756
|
}
|
|
1753
1757
|
/**
|
|
@@ -1775,7 +1779,7 @@ class gs {
|
|
|
1775
1779
|
async appendFile(t, e) {
|
|
1776
1780
|
await this.mount();
|
|
1777
1781
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1778
|
-
await
|
|
1782
|
+
await I(t, async () => {
|
|
1779
1783
|
const r = await this.open(t, { create: !0 });
|
|
1780
1784
|
try {
|
|
1781
1785
|
const { size: i } = await this.fstat(r);
|
|
@@ -1783,7 +1787,7 @@ class gs {
|
|
|
1783
1787
|
} finally {
|
|
1784
1788
|
await this.close(r);
|
|
1785
1789
|
}
|
|
1786
|
-
await this.notifyChange({ path: t, type:
|
|
1790
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
|
|
1787
1791
|
});
|
|
1788
1792
|
}
|
|
1789
1793
|
/**
|
|
@@ -1809,17 +1813,20 @@ class gs {
|
|
|
1809
1813
|
*/
|
|
1810
1814
|
async mkdir(t, e) {
|
|
1811
1815
|
await this.mount();
|
|
1812
|
-
const n = e?.recursive ?? !1, r =
|
|
1816
|
+
const n = e?.recursive ?? !1, r = F(t);
|
|
1813
1817
|
let i = this.root;
|
|
1814
1818
|
for (let o = 0; o < r.length; o++) {
|
|
1815
1819
|
const a = r[o];
|
|
1816
1820
|
try {
|
|
1817
1821
|
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1818
|
-
} catch (
|
|
1819
|
-
throw
|
|
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);
|
|
1820
1827
|
}
|
|
1821
1828
|
}
|
|
1822
|
-
await this.notifyChange({ path: t, type:
|
|
1829
|
+
await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
|
|
1823
1830
|
}
|
|
1824
1831
|
/**
|
|
1825
1832
|
* Get file or directory statistics
|
|
@@ -1856,7 +1863,7 @@ class gs {
|
|
|
1856
1863
|
const e = it(t);
|
|
1857
1864
|
let n;
|
|
1858
1865
|
try {
|
|
1859
|
-
n = await this.getDirectoryHandle(
|
|
1866
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1860
1867
|
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1861
1868
|
kind: "file",
|
|
1862
1869
|
size: o.size,
|
|
@@ -1869,17 +1876,17 @@ class gs {
|
|
|
1869
1876
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1870
1877
|
else if (typeof r == "string")
|
|
1871
1878
|
try {
|
|
1872
|
-
const
|
|
1873
|
-
a.hash =
|
|
1874
|
-
} catch (
|
|
1875
|
-
console.warn(\`Failed to calculate hash for \${t}:\`,
|
|
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);
|
|
1876
1883
|
}
|
|
1877
1884
|
return a;
|
|
1878
1885
|
} catch (r) {
|
|
1879
1886
|
if (r.name === "NotFoundError")
|
|
1880
|
-
throw new
|
|
1887
|
+
throw new U("file", t, r);
|
|
1881
1888
|
if (r.name !== "TypeMismatchError")
|
|
1882
|
-
throw new
|
|
1889
|
+
throw new J("stat", t, r);
|
|
1883
1890
|
}
|
|
1884
1891
|
try {
|
|
1885
1892
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1891,7 +1898,7 @@ class gs {
|
|
|
1891
1898
|
isDirectory: !0
|
|
1892
1899
|
};
|
|
1893
1900
|
} catch (r) {
|
|
1894
|
-
throw new
|
|
1901
|
+
throw new J("stat", t, r);
|
|
1895
1902
|
}
|
|
1896
1903
|
}
|
|
1897
1904
|
/**
|
|
@@ -1946,7 +1953,7 @@ class gs {
|
|
|
1946
1953
|
const e = it(t);
|
|
1947
1954
|
let n = null;
|
|
1948
1955
|
try {
|
|
1949
|
-
n = await this.getDirectoryHandle(
|
|
1956
|
+
n = await this.getDirectoryHandle(tt(t), !1);
|
|
1950
1957
|
} catch (r) {
|
|
1951
1958
|
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1952
1959
|
throw r;
|
|
@@ -1994,9 +2001,9 @@ class gs {
|
|
|
1994
2001
|
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1995
2002
|
await this.remove(r, { recursive: !0 });
|
|
1996
2003
|
}
|
|
1997
|
-
await this.notifyChange({ path: t, type:
|
|
2004
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
|
|
1998
2005
|
} catch (e) {
|
|
1999
|
-
throw e instanceof w ? e :
|
|
2006
|
+
throw e instanceof w ? e : O(e, { path: t, isDirectory: !0 });
|
|
2000
2007
|
}
|
|
2001
2008
|
}
|
|
2002
2009
|
/**
|
|
@@ -2026,8 +2033,8 @@ class gs {
|
|
|
2026
2033
|
async remove(t, e) {
|
|
2027
2034
|
if (await this.mount(), t === "/")
|
|
2028
2035
|
throw new rt("EROOT", t);
|
|
2029
|
-
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(
|
|
2030
|
-
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type:
|
|
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 });
|
|
2031
2038
|
}
|
|
2032
2039
|
/**
|
|
2033
2040
|
* Resolve a path to an absolute path
|
|
@@ -2052,10 +2059,10 @@ class gs {
|
|
|
2052
2059
|
try {
|
|
2053
2060
|
const e = Et(t);
|
|
2054
2061
|
if (!await this.exists(e))
|
|
2055
|
-
throw new
|
|
2062
|
+
throw new U("file", e);
|
|
2056
2063
|
return e;
|
|
2057
2064
|
} catch (e) {
|
|
2058
|
-
throw e instanceof w ? e :
|
|
2065
|
+
throw e instanceof w ? e : O(e, { path: t });
|
|
2059
2066
|
}
|
|
2060
2067
|
}
|
|
2061
2068
|
/**
|
|
@@ -2085,10 +2092,10 @@ class gs {
|
|
|
2085
2092
|
try {
|
|
2086
2093
|
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2087
2094
|
if (await this.exists(e) && !r)
|
|
2088
|
-
throw new
|
|
2089
|
-
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type:
|
|
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 });
|
|
2090
2097
|
} catch (r) {
|
|
2091
|
-
throw r instanceof w ? r :
|
|
2098
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2092
2099
|
}
|
|
2093
2100
|
}
|
|
2094
2101
|
/**
|
|
@@ -2121,24 +2128,24 @@ class gs {
|
|
|
2121
2128
|
try {
|
|
2122
2129
|
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2123
2130
|
if (!await this.exists(t))
|
|
2124
|
-
throw new
|
|
2131
|
+
throw new U("source", t);
|
|
2125
2132
|
if (await this.exists(e) && !i)
|
|
2126
|
-
throw new
|
|
2133
|
+
throw new Q(e);
|
|
2127
2134
|
if ((await this.stat(t)).isFile) {
|
|
2128
2135
|
const h = await this.readFile(t);
|
|
2129
2136
|
await this.writeFile(e, h);
|
|
2130
2137
|
} else {
|
|
2131
2138
|
if (!r)
|
|
2132
|
-
throw new
|
|
2139
|
+
throw new nt("directory", t);
|
|
2133
2140
|
await this.mkdir(e, { recursive: !0 });
|
|
2134
2141
|
const h = await this.readDir(t);
|
|
2135
|
-
for (const
|
|
2136
|
-
const f = \`\${t}/\${
|
|
2142
|
+
for (const l of h) {
|
|
2143
|
+
const f = \`\${t}/\${l.name}\`, u = \`\${e}/\${l.name}\`;
|
|
2137
2144
|
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2138
2145
|
}
|
|
2139
2146
|
}
|
|
2140
2147
|
} catch (r) {
|
|
2141
|
-
throw r instanceof w ? r :
|
|
2148
|
+
throw r instanceof w ? r : O(r, { path: t });
|
|
2142
2149
|
}
|
|
2143
2150
|
}
|
|
2144
2151
|
/**
|
|
@@ -2211,37 +2218,50 @@ class gs {
|
|
|
2211
2218
|
*/
|
|
2212
2219
|
async open(t, e) {
|
|
2213
2220
|
await this.mount();
|
|
2214
|
-
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o =
|
|
2221
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = B(Et(t));
|
|
2215
2222
|
try {
|
|
2216
|
-
return n && r ? await
|
|
2223
|
+
return n && r ? await I(o, async () => {
|
|
2217
2224
|
if (await this.exists(o))
|
|
2218
|
-
throw new
|
|
2225
|
+
throw new Q(o);
|
|
2219
2226
|
return this._openFile(o, n, i);
|
|
2220
2227
|
}) : await this._openFile(o, n, i);
|
|
2221
2228
|
} catch (a) {
|
|
2222
|
-
|
|
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
|
+
});
|
|
2223
2236
|
}
|
|
2224
2237
|
}
|
|
2225
2238
|
/**
|
|
2226
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.
|
|
2227
2243
|
* @private
|
|
2228
2244
|
*/
|
|
2229
2245
|
async _openFile(t, e, n) {
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
await
|
|
2233
|
-
|
|
2234
|
-
|
|
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);
|
|
2235
2256
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
return this.openFiles.set(o, {
|
|
2257
|
+
r.refCount++, n && (r.syncHandle.truncate(0), r.syncHandle.flush());
|
|
2258
|
+
const i = this.nextFd++;
|
|
2259
|
+
return this.openFiles.set(i, {
|
|
2240
2260
|
path: t,
|
|
2241
|
-
fileHandle: r,
|
|
2242
|
-
syncHandle:
|
|
2261
|
+
fileHandle: r.fileHandle,
|
|
2262
|
+
syncHandle: r.syncHandle,
|
|
2243
2263
|
position: 0
|
|
2244
|
-
}),
|
|
2264
|
+
}), i;
|
|
2245
2265
|
}
|
|
2246
2266
|
/**
|
|
2247
2267
|
* Close a file descriptor
|
|
@@ -2259,7 +2279,9 @@ class gs {
|
|
|
2259
2279
|
*/
|
|
2260
2280
|
async close(t) {
|
|
2261
2281
|
const e = this._getFileDescriptor(t);
|
|
2262
|
-
|
|
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)));
|
|
2263
2285
|
}
|
|
2264
2286
|
/**
|
|
2265
2287
|
* Read data from a file descriptor
|
|
@@ -2289,13 +2311,13 @@ class gs {
|
|
|
2289
2311
|
const o = this._getFileDescriptor(t);
|
|
2290
2312
|
St(e.length, n, r, i);
|
|
2291
2313
|
try {
|
|
2292
|
-
const a = i ?? o.position,
|
|
2314
|
+
const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: h, actualLength: l } = ds(a, r, c);
|
|
2293
2315
|
if (h)
|
|
2294
|
-
return
|
|
2295
|
-
const f = e.subarray(n, n +
|
|
2296
|
-
return i == null && (o.position = a + u),
|
|
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]);
|
|
2297
2319
|
} catch (a) {
|
|
2298
|
-
throw
|
|
2320
|
+
throw z("read", t, o.path, a);
|
|
2299
2321
|
}
|
|
2300
2322
|
}
|
|
2301
2323
|
/**
|
|
@@ -2320,13 +2342,13 @@ class gs {
|
|
|
2320
2342
|
* \`\`\`
|
|
2321
2343
|
*/
|
|
2322
2344
|
async write(t, e, n = 0, r, i, o = !0) {
|
|
2323
|
-
const a = this._getFileDescriptor(t),
|
|
2324
|
-
St(e.length, n,
|
|
2345
|
+
const a = this._getFileDescriptor(t), c = r ?? e.length - n;
|
|
2346
|
+
St(e.length, n, c, i);
|
|
2325
2347
|
try {
|
|
2326
|
-
const h = i ?? a.position,
|
|
2327
|
-
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type:
|
|
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;
|
|
2328
2350
|
} catch (h) {
|
|
2329
|
-
throw
|
|
2351
|
+
throw z("write", t, a.path, h);
|
|
2330
2352
|
}
|
|
2331
2353
|
}
|
|
2332
2354
|
/**
|
|
@@ -2372,9 +2394,9 @@ class gs {
|
|
|
2372
2394
|
if (e < 0 || !Number.isInteger(e))
|
|
2373
2395
|
throw new N("argument", "Invalid size");
|
|
2374
2396
|
try {
|
|
2375
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
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 });
|
|
2376
2398
|
} catch (r) {
|
|
2377
|
-
throw
|
|
2399
|
+
throw z("truncate", t, n.path, r);
|
|
2378
2400
|
}
|
|
2379
2401
|
}
|
|
2380
2402
|
/**
|
|
@@ -2396,7 +2418,7 @@ class gs {
|
|
|
2396
2418
|
try {
|
|
2397
2419
|
e.syncHandle.flush();
|
|
2398
2420
|
} catch (n) {
|
|
2399
|
-
throw
|
|
2421
|
+
throw z("sync", t, e.path, n);
|
|
2400
2422
|
}
|
|
2401
2423
|
}
|
|
2402
2424
|
/**
|
|
@@ -2407,9 +2429,9 @@ class gs {
|
|
|
2407
2429
|
*/
|
|
2408
2430
|
dispose() {
|
|
2409
2431
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2410
|
-
for (const [t, e] of this.
|
|
2411
|
-
xt(
|
|
2412
|
-
this.openFiles.clear(), this.nextFd = 1;
|
|
2432
|
+
for (const [t, e] of this.openHandles)
|
|
2433
|
+
xt(-1, e.syncHandle, t);
|
|
2434
|
+
this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1;
|
|
2413
2435
|
}
|
|
2414
2436
|
/**
|
|
2415
2437
|
* Synchronize the file system with external data
|
|
@@ -2418,8 +2440,6 @@ class gs {
|
|
|
2418
2440
|
* This is useful for importing data from external sources or syncing with remote data.
|
|
2419
2441
|
*
|
|
2420
2442
|
* @param entries - Array of [path, data] tuples to sync
|
|
2421
|
-
* @param options - Options for synchronization
|
|
2422
|
-
* @param options.cleanBefore - Whether to clear the file system before syncing (default: false)
|
|
2423
2443
|
* @returns Promise that resolves when synchronization is complete
|
|
2424
2444
|
* @throws {OPFSError} If the synchronization fails
|
|
2425
2445
|
*
|
|
@@ -2443,16 +2463,16 @@ class gs {
|
|
|
2443
2463
|
await this.mount();
|
|
2444
2464
|
try {
|
|
2445
2465
|
for (const [e, n] of t) {
|
|
2446
|
-
const r =
|
|
2466
|
+
const r = B(e);
|
|
2447
2467
|
let i;
|
|
2448
2468
|
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2449
2469
|
}
|
|
2450
2470
|
} catch (e) {
|
|
2451
|
-
throw e instanceof w ? e :
|
|
2471
|
+
throw e instanceof w ? e : O(e);
|
|
2452
2472
|
}
|
|
2453
2473
|
}
|
|
2454
2474
|
}
|
|
2455
|
-
|
|
2456
|
-
//# sourceMappingURL=worker-
|
|
2457
|
-
`,
|
|
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;
|
|
2458
2478
|
//# sourceMappingURL=index.cjs.map
|