opfs-worker 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/worker-CS9nvwsF.js.map +1 -0
- package/dist/facade.d.ts +50 -14
- package/dist/facade.d.ts.map +1 -1
- package/dist/helpers-04x7UBul.cjs +4 -0
- package/dist/helpers-04x7UBul.cjs.map +1 -0
- package/dist/{helpers-CkNHswLp.js → helpers-BXhw_-Ar.js} +112 -110
- package/dist/helpers-BXhw_-Ar.js.map +1 -0
- package/dist/index.cjs +258 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +371 -327
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +55 -55
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +9 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-BuPeqKqw.js.map +0 -1
- package/dist/helpers-CkNHswLp.js.map +0 -1
- package/dist/helpers-TAynP0fb.cjs +0 -4
- package/dist/helpers-TAynP0fb.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-04x7UBul.cjs"),l=`/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
canHandle: (s) =>
|
|
6
|
+
const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol("Comlink.releaseProxy"), V = Symbol("Comlink.finalizer"), H = Symbol("Comlink.thrown"), wt = (s) => typeof s == "object" && s !== null || typeof s == "function", Pt = {
|
|
7
|
+
canHandle: (s) => wt(s) && s[gt],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return Q(s, t), [e, [e]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(s) {
|
|
13
|
-
return s.start(),
|
|
13
|
+
return s.start(), Lt(s);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (s) =>
|
|
15
|
+
}, Tt = {
|
|
16
|
+
canHandle: (s) => wt(s) && H in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
19
19
|
return s instanceof Error ? t = {
|
|
@@ -28,25 +28,25 @@ const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol
|
|
|
28
28
|
deserialize(s) {
|
|
29
29
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
31
|
+
}, mt = /* @__PURE__ */ new Map([
|
|
32
|
+
["proxy", Pt],
|
|
33
|
+
["throw", Tt]
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
35
|
+
function Rt(s, t) {
|
|
36
36
|
for (const e of s)
|
|
37
37
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
38
38
|
return !0;
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Q(s, t = globalThis, e = ["*"]) {
|
|
42
42
|
t.addEventListener("message", function n(i) {
|
|
43
43
|
if (!i || !i.data)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
45
|
+
if (!Rt(e, i.origin)) {
|
|
46
46
|
console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(
|
|
49
|
+
const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(N);
|
|
50
50
|
let h;
|
|
51
51
|
try {
|
|
52
52
|
const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
@@ -55,7 +55,7 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
55
55
|
h = f;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
c[a.slice(-1)[0]] =
|
|
58
|
+
c[a.slice(-1)[0]] = N(i.data.value), h = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
61
|
h = f.apply(c, l);
|
|
@@ -63,13 +63,13 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
65
|
const u = new f(...l);
|
|
66
|
-
h =
|
|
66
|
+
h = _t(u);
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: u, port2: d } = new MessageChannel();
|
|
72
|
-
|
|
72
|
+
Q(s, d), h = W(u, [u]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -79,15 +79,15 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
} catch (c) {
|
|
82
|
-
h = { value: c, [
|
|
82
|
+
h = { value: c, [H]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
85
|
-
const [f, u] =
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
84
|
+
Promise.resolve(h).catch((c) => ({ value: c, [H]: 0 })).then((c) => {
|
|
85
|
+
const [f, u] = B(c);
|
|
86
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), yt(t), V in s && typeof s[V] == "function" && s[V]());
|
|
87
87
|
}).catch((c) => {
|
|
88
|
-
const [f, u] =
|
|
88
|
+
const [f, u] = B({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
90
|
+
[H]: 0
|
|
91
91
|
});
|
|
92
92
|
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
|
|
93
93
|
});
|
|
@@ -96,10 +96,10 @@ function K(s, t = globalThis, e = ["*"]) {
|
|
|
96
96
|
function kt(s) {
|
|
97
97
|
return s.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function yt(s) {
|
|
100
100
|
kt(s) && s.close();
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Lt(s, t) {
|
|
103
103
|
const e = /* @__PURE__ */ new Map();
|
|
104
104
|
return s.addEventListener("message", function(i) {
|
|
105
105
|
const { data: r } = i;
|
|
@@ -112,103 +112,103 @@ function Rt(s, t) {
|
|
|
112
112
|
} finally {
|
|
113
113
|
e.delete(r.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), J(s, e, [], t);
|
|
116
116
|
}
|
|
117
117
|
function k(s) {
|
|
118
118
|
if (s)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function Et(s) {
|
|
122
|
+
return D(s, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
yt(s);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
128
|
+
const j = /* @__PURE__ */ new WeakMap(), U = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
129
|
+
const t = (j.get(s) || 0) - 1;
|
|
130
|
+
j.set(s, t), t === 0 && Et(s);
|
|
131
131
|
});
|
|
132
|
-
function
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
132
|
+
function zt(s, t) {
|
|
133
|
+
const e = (j.get(t) || 0) + 1;
|
|
134
|
+
j.set(t, e), U && U.register(s, t, s);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function Ht(s) {
|
|
137
|
+
U && U.unregister(s);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function J(s, t, e = [], n = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let i = !1;
|
|
142
142
|
const r = new Proxy(n, {
|
|
143
143
|
get(o, a) {
|
|
144
|
-
if (k(i), a ===
|
|
144
|
+
if (k(i), a === It)
|
|
145
145
|
return () => {
|
|
146
|
-
|
|
146
|
+
Ht(r), Et(s), t.clear(), i = !0;
|
|
147
147
|
};
|
|
148
148
|
if (a === "then") {
|
|
149
149
|
if (e.length === 0)
|
|
150
150
|
return { then: () => r };
|
|
151
|
-
const l =
|
|
151
|
+
const l = D(s, t, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: e.map((h) => h.toString())
|
|
154
|
-
}).then(
|
|
154
|
+
}).then(N);
|
|
155
155
|
return l.then.bind(l);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return J(s, t, [...e, a]);
|
|
158
158
|
},
|
|
159
159
|
set(o, a, l) {
|
|
160
160
|
k(i);
|
|
161
|
-
const [h, c] =
|
|
162
|
-
return
|
|
161
|
+
const [h, c] = B(l);
|
|
162
|
+
return D(s, t, {
|
|
163
163
|
type: "SET",
|
|
164
164
|
path: [...e, a].map((f) => f.toString()),
|
|
165
165
|
value: h
|
|
166
|
-
}, c).then(
|
|
166
|
+
}, c).then(N);
|
|
167
167
|
},
|
|
168
168
|
apply(o, a, l) {
|
|
169
169
|
k(i);
|
|
170
170
|
const h = e[e.length - 1];
|
|
171
|
-
if (h ===
|
|
172
|
-
return
|
|
171
|
+
if (h === Mt)
|
|
172
|
+
return D(s, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
174
|
+
}).then(N);
|
|
175
175
|
if (h === "bind")
|
|
176
|
-
return
|
|
177
|
-
const [c, f] =
|
|
178
|
-
return
|
|
176
|
+
return J(s, t, e.slice(0, -1));
|
|
177
|
+
const [c, f] = nt(l);
|
|
178
|
+
return D(s, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: e.map((u) => u.toString()),
|
|
181
181
|
argumentList: c
|
|
182
|
-
}, f).then(
|
|
182
|
+
}, f).then(N);
|
|
183
183
|
},
|
|
184
184
|
construct(o, a) {
|
|
185
185
|
k(i);
|
|
186
|
-
const [l, h] =
|
|
187
|
-
return
|
|
186
|
+
const [l, h] = nt(a);
|
|
187
|
+
return D(s, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
189
|
path: e.map((c) => c.toString()),
|
|
190
190
|
argumentList: l
|
|
191
|
-
}, h).then(
|
|
191
|
+
}, h).then(N);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
return
|
|
194
|
+
return zt(r, s), r;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Wt(s) {
|
|
197
197
|
return Array.prototype.concat.apply([], s);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const t = s.map(
|
|
201
|
-
return [t.map((e) => e[0]),
|
|
199
|
+
function nt(s) {
|
|
200
|
+
const t = s.map(B);
|
|
201
|
+
return [t.map((e) => e[0]), Wt(t.map((e) => e[1]))];
|
|
202
202
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
203
|
+
const St = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function W(s, t) {
|
|
205
|
+
return St.set(s, t), s;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(s, { [
|
|
207
|
+
function _t(s) {
|
|
208
|
+
return Object.assign(s, { [gt]: !0 });
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (const [t, e] of
|
|
210
|
+
function B(s) {
|
|
211
|
+
for (const [t, e] of mt)
|
|
212
212
|
if (e.canHandle(s)) {
|
|
213
213
|
const [n, i] = e.serialize(s);
|
|
214
214
|
return [
|
|
@@ -225,51 +225,52 @@ function U(s) {
|
|
|
225
225
|
type: "RAW",
|
|
226
226
|
value: s
|
|
227
227
|
},
|
|
228
|
-
|
|
228
|
+
St.get(s) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function N(s) {
|
|
232
232
|
switch (s.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
|
-
return
|
|
234
|
+
return mt.get(s.name).deserialize(s.value);
|
|
235
235
|
case "RAW":
|
|
236
236
|
return s.value;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function D(s, t, e, n) {
|
|
240
240
|
return new Promise((i) => {
|
|
241
|
-
const r =
|
|
241
|
+
const r = jt();
|
|
242
242
|
t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function jt() {
|
|
246
246
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
247
|
}
|
|
248
|
+
var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
|
|
248
249
|
class p extends Error {
|
|
249
250
|
constructor(t, e, n, i) {
|
|
250
251
|
super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
|
-
class
|
|
254
|
+
class Ut extends p {
|
|
254
255
|
constructor(t) {
|
|
255
256
|
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
class
|
|
259
|
+
class Bt extends p {
|
|
259
260
|
constructor(t, e, n) {
|
|
260
261
|
super(t, "INVALID_PATH", e, n);
|
|
261
262
|
}
|
|
262
263
|
}
|
|
263
|
-
class
|
|
264
|
+
class it extends p {
|
|
264
265
|
constructor(t, e) {
|
|
265
266
|
super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
|
-
function
|
|
269
|
+
function L(s, t, e, n) {
|
|
269
270
|
const i = \`\${s.toUpperCase()}_FAILED\`;
|
|
270
271
|
return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function Gt(s, t) {
|
|
273
274
|
const e = t?.path;
|
|
274
275
|
switch (s.name) {
|
|
275
276
|
case "InvalidStateError":
|
|
@@ -295,8 +296,8 @@ function Bt(s, t) {
|
|
|
295
296
|
return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
|
-
const
|
|
299
|
-
const n = s instanceof RegExp ?
|
|
299
|
+
const xt = (s, t, e) => {
|
|
300
|
+
const n = s instanceof RegExp ? rt(s, e) : s, i = t instanceof RegExp ? rt(t, e) : t, r = n !== null && i != null && qt(n, i, e);
|
|
300
301
|
return r && {
|
|
301
302
|
start: r[0],
|
|
302
303
|
end: r[1],
|
|
@@ -304,10 +305,10 @@ const St = (s, t, e) => {
|
|
|
304
305
|
body: e.slice(r[0] + n.length, r[1]),
|
|
305
306
|
post: e.slice(r[1] + i.length)
|
|
306
307
|
};
|
|
307
|
-
},
|
|
308
|
+
}, rt = (s, t) => {
|
|
308
309
|
const e = t.match(s);
|
|
309
310
|
return e ? e[0] : null;
|
|
310
|
-
},
|
|
311
|
+
}, qt = (s, t, e) => {
|
|
311
312
|
let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
312
313
|
if (l >= 0 && h > 0) {
|
|
313
314
|
if (s === t)
|
|
@@ -325,47 +326,47 @@ const St = (s, t, e) => {
|
|
|
325
326
|
n.length && o !== void 0 && (a = [r, o]);
|
|
326
327
|
}
|
|
327
328
|
return a;
|
|
328
|
-
},
|
|
329
|
-
function
|
|
329
|
+
}, bt = "\\0SLASH" + Math.random() + "\\0", vt = "\\0OPEN" + Math.random() + "\\0", tt = "\\0CLOSE" + Math.random() + "\\0", At = "\\0COMMA" + Math.random() + "\\0", Ft = "\\0PERIOD" + Math.random() + "\\0", Vt = new RegExp(bt, "g"), Xt = new RegExp(vt, "g"), Yt = new RegExp(tt, "g"), Zt = new RegExp(At, "g"), Jt = new RegExp(Ft, "g"), Kt = /\\\\\\\\/g, Qt = /\\\\{/g, te = /\\\\}/g, ee = /\\\\,/g, se = /\\\\./g;
|
|
330
|
+
function X(s) {
|
|
330
331
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
331
332
|
}
|
|
332
|
-
function se(s) {
|
|
333
|
-
return s.replace(Jt, xt).replace(Kt, bt).replace(Qt, Q).replace(te, vt).replace(ee, At);
|
|
334
|
-
}
|
|
335
333
|
function ne(s) {
|
|
336
|
-
return s.replace(
|
|
334
|
+
return s.replace(Kt, bt).replace(Qt, vt).replace(te, tt).replace(ee, At).replace(se, Ft);
|
|
335
|
+
}
|
|
336
|
+
function ie(s) {
|
|
337
|
+
return s.replace(Vt, "\\\\").replace(Xt, "{").replace(Yt, "}").replace(Zt, ",").replace(Jt, ".");
|
|
337
338
|
}
|
|
338
|
-
function
|
|
339
|
+
function Nt(s) {
|
|
339
340
|
if (!s)
|
|
340
341
|
return [""];
|
|
341
|
-
const t = [], e =
|
|
342
|
+
const t = [], e = xt("{", "}", s);
|
|
342
343
|
if (!e)
|
|
343
344
|
return s.split(",");
|
|
344
345
|
const { pre: n, body: i, post: r } = e, o = n.split(",");
|
|
345
346
|
o[o.length - 1] += "{" + i + "}";
|
|
346
|
-
const a =
|
|
347
|
+
const a = Nt(r);
|
|
347
348
|
return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
348
349
|
}
|
|
349
|
-
function ie(s) {
|
|
350
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), T(se(s), !0).map(ne)) : [];
|
|
351
|
-
}
|
|
352
350
|
function re(s) {
|
|
353
|
-
return "{"
|
|
351
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(ne(s), !0).map(ie)) : [];
|
|
354
352
|
}
|
|
355
353
|
function oe(s) {
|
|
354
|
+
return "{" + s + "}";
|
|
355
|
+
}
|
|
356
|
+
function ae(s) {
|
|
356
357
|
return /^-?0\\d/.test(s);
|
|
357
358
|
}
|
|
358
|
-
function
|
|
359
|
+
function ce(s, t) {
|
|
359
360
|
return s <= t;
|
|
360
361
|
}
|
|
361
|
-
function
|
|
362
|
+
function le(s, t) {
|
|
362
363
|
return s >= t;
|
|
363
364
|
}
|
|
364
|
-
function
|
|
365
|
-
const e = [], n =
|
|
365
|
+
function I(s, t) {
|
|
366
|
+
const e = [], n = xt("{", "}", s);
|
|
366
367
|
if (!n)
|
|
367
368
|
return [s];
|
|
368
|
-
const i = n.pre, r = n.post.length ?
|
|
369
|
+
const i = n.pre, r = n.post.length ? I(n.post, !1) : [""];
|
|
369
370
|
if (/\\$$/.test(n.pre))
|
|
370
371
|
for (let o = 0; o < r.length; o++) {
|
|
371
372
|
const a = i + "{" + n.body + "}" + r[o];
|
|
@@ -374,28 +375,28 @@ function T(s, t) {
|
|
|
374
375
|
else {
|
|
375
376
|
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
|
|
376
377
|
if (!l && !h)
|
|
377
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
378
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + tt + n.post, I(s)) : [s];
|
|
378
379
|
let c;
|
|
379
380
|
if (l)
|
|
380
381
|
c = n.body.split(/\\.\\./);
|
|
381
|
-
else if (c =
|
|
382
|
+
else if (c = Nt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(oe), c.length === 1))
|
|
382
383
|
return r.map((u) => n.pre + c[0] + u);
|
|
383
384
|
let f;
|
|
384
385
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
385
|
-
const u =
|
|
386
|
-
let g = c.length === 3 && c[2] !== void 0 ? Math.abs(
|
|
387
|
-
d < u && (g *= -1, S =
|
|
388
|
-
const
|
|
386
|
+
const u = X(c[0]), d = X(c[1]), w = Math.max(c[0].length, c[1].length);
|
|
387
|
+
let g = c.length === 3 && c[2] !== void 0 ? Math.abs(X(c[2])) : 1, S = ce;
|
|
388
|
+
d < u && (g *= -1, S = le);
|
|
389
|
+
const $ = c.some(ae);
|
|
389
390
|
f = [];
|
|
390
391
|
for (let x = u; S(x, d); x += g) {
|
|
391
392
|
let m;
|
|
392
393
|
if (a)
|
|
393
394
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
394
|
-
else if (m = String(x),
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
x < 0 ? m = "-" +
|
|
395
|
+
else if (m = String(x), $) {
|
|
396
|
+
const C = w - m.length;
|
|
397
|
+
if (C > 0) {
|
|
398
|
+
const R = new Array(C + 1).join("0");
|
|
399
|
+
x < 0 ? m = "-" + R + m.slice(1) : m = R + m;
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
f.push(m);
|
|
@@ -403,7 +404,7 @@ function T(s, t) {
|
|
|
403
404
|
} else {
|
|
404
405
|
f = [];
|
|
405
406
|
for (let u = 0; u < c.length; u++)
|
|
406
|
-
f.push.apply(f,
|
|
407
|
+
f.push.apply(f, I(c[u], !1));
|
|
407
408
|
}
|
|
408
409
|
for (let u = 0; u < f.length; u++)
|
|
409
410
|
for (let d = 0; d < r.length; d++) {
|
|
@@ -413,12 +414,12 @@ function T(s, t) {
|
|
|
413
414
|
}
|
|
414
415
|
return e;
|
|
415
416
|
}
|
|
416
|
-
const
|
|
417
|
+
const he = 1024 * 64, G = (s) => {
|
|
417
418
|
if (typeof s != "string")
|
|
418
419
|
throw new TypeError("invalid pattern");
|
|
419
|
-
if (s.length >
|
|
420
|
+
if (s.length > he)
|
|
420
421
|
throw new TypeError("pattern is too long");
|
|
421
|
-
},
|
|
422
|
+
}, ue = {
|
|
422
423
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
423
424
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
424
425
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -433,7 +434,7 @@ const le = 1024 * 64, B = (s) => {
|
|
|
433
434
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
434
435
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
435
436
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
436
|
-
},
|
|
437
|
+
}, M = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), fe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ot = (s) => s.join(""), de = (s, t) => {
|
|
437
438
|
const e = t;
|
|
438
439
|
if (s.charAt(e) !== "[")
|
|
439
440
|
throw new Error("not in a brace expression");
|
|
@@ -454,27 +455,27 @@ const le = 1024 * 64, B = (s) => {
|
|
|
454
455
|
continue;
|
|
455
456
|
}
|
|
456
457
|
if (g === "[" && !l) {
|
|
457
|
-
for (const [S, [
|
|
458
|
+
for (const [S, [F, $, x]] of Object.entries(ue))
|
|
458
459
|
if (s.startsWith(S, r)) {
|
|
459
460
|
if (f)
|
|
460
461
|
return ["$.", !1, s.length - e, !0];
|
|
461
|
-
r += S.length, x ? i.push(
|
|
462
|
+
r += S.length, x ? i.push(F) : n.push(F), a = a || $;
|
|
462
463
|
continue t;
|
|
463
464
|
}
|
|
464
465
|
}
|
|
465
466
|
if (l = !1, f) {
|
|
466
|
-
g > f ? n.push(
|
|
467
|
+
g > f ? n.push(M(f) + "-" + M(g)) : g === f && n.push(M(g)), f = "", r++;
|
|
467
468
|
continue;
|
|
468
469
|
}
|
|
469
470
|
if (s.startsWith("-]", r + 1)) {
|
|
470
|
-
n.push(
|
|
471
|
+
n.push(M(g + "-")), r += 2;
|
|
471
472
|
continue;
|
|
472
473
|
}
|
|
473
474
|
if (s.startsWith("-", r + 1)) {
|
|
474
475
|
f = g, r += 2;
|
|
475
476
|
continue;
|
|
476
477
|
}
|
|
477
|
-
n.push(
|
|
478
|
+
n.push(M(g)), r++;
|
|
478
479
|
}
|
|
479
480
|
if (c < r)
|
|
480
481
|
return ["", !1, 0, !1];
|
|
@@ -482,11 +483,11 @@ const le = 1024 * 64, B = (s) => {
|
|
|
482
483
|
return ["$.", !1, s.length - e, !0];
|
|
483
484
|
if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
484
485
|
const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
485
|
-
return [
|
|
486
|
+
return [fe(g), !1, c - e, !1];
|
|
486
487
|
}
|
|
487
|
-
const u = "[" + (h ? "^" : "") +
|
|
488
|
+
const u = "[" + (h ? "^" : "") + ot(n) + "]", d = "[" + (h ? "" : "^") + ot(i) + "]";
|
|
488
489
|
return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
489
|
-
},
|
|
490
|
+
}, P = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), pe = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (s) => pe.has(s), ge = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", z = "(?!\\\\.)", we = /* @__PURE__ */ new Set(["[", "."]), me = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), Ee = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), et = "[^/]", ct = et + "*?", lt = et + "+?";
|
|
490
491
|
class E {
|
|
491
492
|
type;
|
|
492
493
|
#s;
|
|
@@ -603,7 +604,7 @@ class E {
|
|
|
603
604
|
o = !0, a = d, l = !1, w += g;
|
|
604
605
|
continue;
|
|
605
606
|
}
|
|
606
|
-
if (!i.noext &&
|
|
607
|
+
if (!i.noext && at(g) && t.charAt(d) === "(") {
|
|
607
608
|
e.push(w), w = "";
|
|
608
609
|
const S = new E(g, e);
|
|
609
610
|
d = E.#h(t, S, d, i), e.push(S);
|
|
@@ -629,7 +630,7 @@ class E {
|
|
|
629
630
|
o = !0, a = h, l = !1, u += d;
|
|
630
631
|
continue;
|
|
631
632
|
}
|
|
632
|
-
if (
|
|
633
|
+
if (at(d) && t.charAt(h) === "(") {
|
|
633
634
|
c.push(u), u = "";
|
|
634
635
|
const w = new E(d, c);
|
|
635
636
|
c.push(w), h = E.#h(t, w, h, i);
|
|
@@ -739,23 +740,23 @@ class E {
|
|
|
739
740
|
const e = t ?? !!this.#i.dot;
|
|
740
741
|
if (this.#s === this && this.#d(), !this.type) {
|
|
741
742
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
742
|
-
const [w, g, S,
|
|
743
|
-
return this.#n = this.#n || S, this.#r = this.#r ||
|
|
743
|
+
const [w, g, S, F] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
744
|
+
return this.#n = this.#n || S, this.#r = this.#r || F, w;
|
|
744
745
|
}).join("");
|
|
745
746
|
let c = "";
|
|
746
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
747
|
-
const w =
|
|
747
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && me.has(this.#t[0]))) {
|
|
748
|
+
const w = we, g = (
|
|
748
749
|
// dots are allowed, and the pattern starts with [ or .
|
|
749
750
|
e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
750
751
|
h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
751
752
|
h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
|
|
752
753
|
), S = !e && !t && w.has(h.charAt(0));
|
|
753
|
-
c = g ?
|
|
754
|
+
c = g ? ge : S ? z : "";
|
|
754
755
|
}
|
|
755
756
|
let f = "";
|
|
756
757
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
757
758
|
c + h + f,
|
|
758
|
-
|
|
759
|
+
P(h),
|
|
759
760
|
this.#n = !!this.#n,
|
|
760
761
|
this.#r
|
|
761
762
|
];
|
|
@@ -764,23 +765,23 @@ class E {
|
|
|
764
765
|
let r = this.#f(e);
|
|
765
766
|
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
|
|
766
767
|
const l = this.toString();
|
|
767
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
768
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, P(this.toString()), !1, !1];
|
|
768
769
|
}
|
|
769
|
-
let o = !n || t || e || !
|
|
770
|
+
let o = !n || t || e || !z ? "" : this.#f(!0);
|
|
770
771
|
o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
|
|
771
772
|
let a = "";
|
|
772
773
|
if (this.type === "!" && this.#u)
|
|
773
|
-
a = (this.isStart() && !e ?
|
|
774
|
+
a = (this.isStart() && !e ? z : "") + lt;
|
|
774
775
|
else {
|
|
775
776
|
const l = this.type === "!" ? (
|
|
776
777
|
// !() must match something,but !(x) can match ''
|
|
777
|
-
"))" + (this.isStart() && !e && !t ?
|
|
778
|
+
"))" + (this.isStart() && !e && !t ? z : "") + ct + ")"
|
|
778
779
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
779
780
|
a = i + r + l;
|
|
780
781
|
}
|
|
781
782
|
return [
|
|
782
783
|
a,
|
|
783
|
-
|
|
784
|
+
P(r),
|
|
784
785
|
this.#n = !!this.#n,
|
|
785
786
|
this.#r
|
|
786
787
|
];
|
|
@@ -798,7 +799,7 @@ class E {
|
|
|
798
799
|
for (let a = 0; a < t.length; a++) {
|
|
799
800
|
const l = t.charAt(a);
|
|
800
801
|
if (i) {
|
|
801
|
-
i = !1, r += (
|
|
802
|
+
i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
|
|
802
803
|
continue;
|
|
803
804
|
}
|
|
804
805
|
if (l === "\\\\") {
|
|
@@ -806,53 +807,53 @@ class E {
|
|
|
806
807
|
continue;
|
|
807
808
|
}
|
|
808
809
|
if (l === "[") {
|
|
809
|
-
const [h, c, f, u] =
|
|
810
|
+
const [h, c, f, u] = de(t, a);
|
|
810
811
|
if (f) {
|
|
811
812
|
r += h, o = o || c, a += f - 1, e = e || u;
|
|
812
813
|
continue;
|
|
813
814
|
}
|
|
814
815
|
}
|
|
815
816
|
if (l === "*") {
|
|
816
|
-
n && t === "*" ? r +=
|
|
817
|
+
n && t === "*" ? r += lt : r += ct, e = !0;
|
|
817
818
|
continue;
|
|
818
819
|
}
|
|
819
820
|
if (l === "?") {
|
|
820
|
-
r +=
|
|
821
|
+
r += et, e = !0;
|
|
821
822
|
continue;
|
|
822
823
|
}
|
|
823
|
-
r +=
|
|
824
|
+
r += Ee(l);
|
|
824
825
|
}
|
|
825
|
-
return [r,
|
|
826
|
+
return [r, P(t), !!e, o];
|
|
826
827
|
}
|
|
827
828
|
}
|
|
828
|
-
const
|
|
829
|
-
const e =
|
|
829
|
+
const Se = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(s)), xe = /^\\*+([^+@!?\\*\\[\\(]*)$/, be = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ve = (s) => (t) => t.endsWith(s), Ae = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Fe = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Ne = /^\\*+\\.\\*+$/, De = (s) => !s.startsWith(".") && s.includes("."), Oe = (s) => s !== "." && s !== ".." && s.includes("."), $e = /^\\.\\*+$/, Ce = (s) => s !== "." && s !== ".." && s.startsWith("."), Me = /^\\*+$/, Ie = (s) => s.length !== 0 && !s.startsWith("."), Pe = (s) => s.length !== 0 && s !== "." && s !== "..", Te = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Re = ([s, t = ""]) => {
|
|
830
|
+
const e = Dt([s]);
|
|
830
831
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
831
832
|
}, ke = ([s, t = ""]) => {
|
|
832
|
-
const e =
|
|
833
|
+
const e = Ot([s]);
|
|
833
834
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
834
|
-
}, Re = ([s, t = ""]) => {
|
|
835
|
-
const e = Dt([s]);
|
|
836
|
-
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
837
835
|
}, Le = ([s, t = ""]) => {
|
|
838
|
-
const e =
|
|
836
|
+
const e = Ot([s]);
|
|
837
|
+
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
838
|
+
}, ze = ([s, t = ""]) => {
|
|
839
|
+
const e = Dt([s]);
|
|
839
840
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
840
|
-
},
|
|
841
|
+
}, Dt = ([s]) => {
|
|
841
842
|
const t = s.length;
|
|
842
843
|
return (e) => e.length === t && !e.startsWith(".");
|
|
843
|
-
},
|
|
844
|
+
}, Ot = ([s]) => {
|
|
844
845
|
const t = s.length;
|
|
845
846
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
846
|
-
},
|
|
847
|
+
}, $t = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ht = {
|
|
847
848
|
win32: { sep: "\\\\" },
|
|
848
849
|
posix: { sep: "/" }
|
|
849
|
-
},
|
|
850
|
-
y.sep =
|
|
850
|
+
}, He = $t === "win32" ? ht.win32.sep : ht.posix.sep;
|
|
851
|
+
y.sep = He;
|
|
851
852
|
const v = Symbol("globstar **");
|
|
852
853
|
y.GLOBSTAR = v;
|
|
853
|
-
const
|
|
854
|
-
y.filter =
|
|
855
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
854
|
+
const We = "[^/]", _e = We + "*?", je = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ue = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => y(e, s, t);
|
|
855
|
+
y.filter = Be;
|
|
856
|
+
const b = (s, t = {}) => Object.assign({}, s, t), Ge = (s) => {
|
|
856
857
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
857
858
|
return y;
|
|
858
859
|
const t = y;
|
|
@@ -886,18 +887,18 @@ const b = (s, t = {}) => Object.assign({}, s, t), Be = (s) => {
|
|
|
886
887
|
GLOBSTAR: v
|
|
887
888
|
});
|
|
888
889
|
};
|
|
889
|
-
y.defaults =
|
|
890
|
-
const
|
|
891
|
-
y.braceExpand =
|
|
892
|
-
const
|
|
893
|
-
y.makeRe =
|
|
894
|
-
const
|
|
895
|
-
const n = new
|
|
890
|
+
y.defaults = Ge;
|
|
891
|
+
const Ct = (s, t = {}) => (G(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : re(s));
|
|
892
|
+
y.braceExpand = Ct;
|
|
893
|
+
const qe = (s, t = {}) => new q(s, t).makeRe();
|
|
894
|
+
y.makeRe = qe;
|
|
895
|
+
const Ve = (s, t, e = {}) => {
|
|
896
|
+
const n = new q(t, e);
|
|
896
897
|
return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
|
|
897
898
|
};
|
|
898
|
-
y.match =
|
|
899
|
-
const
|
|
900
|
-
class
|
|
899
|
+
y.match = Ve;
|
|
900
|
+
const ut = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
901
|
+
class q {
|
|
901
902
|
options;
|
|
902
903
|
set;
|
|
903
904
|
pattern;
|
|
@@ -916,7 +917,7 @@ class G {
|
|
|
916
917
|
windowsNoMagicRoot;
|
|
917
918
|
regexp;
|
|
918
919
|
constructor(t, e = {}) {
|
|
919
|
-
|
|
920
|
+
G(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || $t, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
920
921
|
}
|
|
921
922
|
hasMagic() {
|
|
922
923
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -944,7 +945,7 @@ class G {
|
|
|
944
945
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
945
946
|
let i = this.globParts.map((r, o, a) => {
|
|
946
947
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
947
|
-
const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !
|
|
948
|
+
const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ut.test(r[2])) && !ut.test(r[3]), h = /^[a-z]:/i.test(r[0]);
|
|
948
949
|
if (l)
|
|
949
950
|
return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
|
|
950
951
|
if (h)
|
|
@@ -1124,10 +1125,10 @@ class G {
|
|
|
1124
1125
|
matchOne(t, e, n = !1) {
|
|
1125
1126
|
const i = this.options;
|
|
1126
1127
|
if (this.isWindows) {
|
|
1127
|
-
const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]),
|
|
1128
|
+
const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), F = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), $ = !F && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = $ ? 3 : F ? 0 : void 0;
|
|
1128
1129
|
if (typeof x == "number" && typeof m == "number") {
|
|
1129
|
-
const [
|
|
1130
|
-
|
|
1130
|
+
const [C, R] = [t[x], e[m]];
|
|
1131
|
+
C.toLowerCase() === R.toLowerCase() && (e[m] = C, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1131
1132
|
}
|
|
1132
1133
|
}
|
|
1133
1134
|
const { optimizationLevel: r = 1 } = this.options;
|
|
@@ -1173,17 +1174,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1173
1174
|
throw new Error("wtf?");
|
|
1174
1175
|
}
|
|
1175
1176
|
braceExpand() {
|
|
1176
|
-
return
|
|
1177
|
+
return Ct(this.pattern, this.options);
|
|
1177
1178
|
}
|
|
1178
1179
|
parse(t) {
|
|
1179
|
-
|
|
1180
|
+
G(t);
|
|
1180
1181
|
const e = this.options;
|
|
1181
1182
|
if (t === "**")
|
|
1182
1183
|
return v;
|
|
1183
1184
|
if (t === "")
|
|
1184
1185
|
return "";
|
|
1185
1186
|
let n, i = null;
|
|
1186
|
-
(n = t.match(
|
|
1187
|
+
(n = t.match(Me)) ? i = e.dot ? Pe : Ie : (n = t.match(xe)) ? i = (e.nocase ? e.dot ? Fe : Ae : e.dot ? ve : be)(n[1]) : (n = t.match(Te)) ? i = (e.nocase ? e.dot ? ke : Re : e.dot ? Le : ze)(n) : (n = t.match(Ne)) ? i = e.dot ? Oe : De : (n = t.match($e)) && (i = Ce);
|
|
1187
1188
|
const r = E.fromGlob(t, this.options).toMMPattern();
|
|
1188
1189
|
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
1189
1190
|
}
|
|
@@ -1193,13 +1194,13 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1193
1194
|
const t = this.set;
|
|
1194
1195
|
if (!t.length)
|
|
1195
1196
|
return this.regexp = !1, this.regexp;
|
|
1196
|
-
const e = this.options, n = e.noglobstar ?
|
|
1197
|
+
const e = this.options, n = e.noglobstar ? _e : e.dot ? je : Ue, i = new Set(e.nocase ? ["i"] : []);
|
|
1197
1198
|
let r = t.map((l) => {
|
|
1198
1199
|
const h = l.map((c) => {
|
|
1199
1200
|
if (c instanceof RegExp)
|
|
1200
1201
|
for (const f of c.flags.split(""))
|
|
1201
1202
|
i.add(f);
|
|
1202
|
-
return typeof c == "string" ?
|
|
1203
|
+
return typeof c == "string" ? Xe(c) : c === v ? v : c._src;
|
|
1203
1204
|
});
|
|
1204
1205
|
return h.forEach((c, f) => {
|
|
1205
1206
|
const u = h[f + 1], d = h[f - 1];
|
|
@@ -1248,44 +1249,44 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1248
1249
|
}
|
|
1249
1250
|
}
|
|
1250
1251
|
y.AST = E;
|
|
1251
|
-
y.Minimatch =
|
|
1252
|
-
y.escape =
|
|
1253
|
-
y.unescape =
|
|
1254
|
-
function
|
|
1252
|
+
y.Minimatch = q;
|
|
1253
|
+
y.escape = Se;
|
|
1254
|
+
y.unescape = P;
|
|
1255
|
+
function Ye() {
|
|
1255
1256
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1256
|
-
throw new
|
|
1257
|
+
throw new Ut();
|
|
1257
1258
|
}
|
|
1258
|
-
async function
|
|
1259
|
+
async function T(s, t, e) {
|
|
1259
1260
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1260
1261
|
}
|
|
1261
|
-
function
|
|
1262
|
+
function O(s) {
|
|
1262
1263
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1263
1264
|
}
|
|
1264
|
-
function
|
|
1265
|
+
function st(s) {
|
|
1265
1266
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1266
1267
|
}
|
|
1267
|
-
function
|
|
1268
|
-
const t =
|
|
1268
|
+
function K(s) {
|
|
1269
|
+
const t = O(s);
|
|
1269
1270
|
return t[t.length - 1] || "";
|
|
1270
1271
|
}
|
|
1271
|
-
function
|
|
1272
|
-
const t =
|
|
1273
|
-
return t.pop(),
|
|
1272
|
+
function Y(s) {
|
|
1273
|
+
const t = O(s);
|
|
1274
|
+
return t.pop(), st(t);
|
|
1274
1275
|
}
|
|
1275
|
-
function
|
|
1276
|
+
function _(s) {
|
|
1276
1277
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1277
1278
|
}
|
|
1278
|
-
function
|
|
1279
|
+
function Ze(s, t = !1) {
|
|
1279
1280
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1280
1281
|
}
|
|
1281
|
-
function
|
|
1282
|
+
function Z(s, t) {
|
|
1282
1283
|
return y(s, t, {
|
|
1283
1284
|
dot: !0,
|
|
1284
1285
|
matchBase: !0
|
|
1285
1286
|
});
|
|
1286
1287
|
}
|
|
1287
|
-
function
|
|
1288
|
-
const t =
|
|
1288
|
+
function ft(s) {
|
|
1289
|
+
const t = _(s), e = O(t), n = [];
|
|
1289
1290
|
for (const i of e)
|
|
1290
1291
|
if (!(i === "." || i === ""))
|
|
1291
1292
|
if (i === "..") {
|
|
@@ -1294,21 +1295,21 @@ function ut(s) {
|
|
|
1294
1295
|
n.pop();
|
|
1295
1296
|
} else
|
|
1296
1297
|
n.push(i);
|
|
1297
|
-
return
|
|
1298
|
+
return st(n);
|
|
1298
1299
|
}
|
|
1299
|
-
async function
|
|
1300
|
+
async function Je(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1300
1301
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1301
1302
|
throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
|
|
1302
1303
|
const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
|
|
1303
1304
|
return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1304
1305
|
}
|
|
1305
|
-
async function
|
|
1306
|
+
async function Ke(s) {
|
|
1306
1307
|
const t = await s.arrayBuffer();
|
|
1307
1308
|
return new Uint8Array(t);
|
|
1308
1309
|
}
|
|
1309
|
-
async function
|
|
1310
|
-
const n =
|
|
1311
|
-
return
|
|
1310
|
+
async function Qe(s, t, e = {}) {
|
|
1311
|
+
const n = K(t);
|
|
1312
|
+
return T(t, "exclusive", async () => {
|
|
1312
1313
|
const i = e.recursive ?? !1, r = e.force ?? !1;
|
|
1313
1314
|
e.useTrash;
|
|
1314
1315
|
try {
|
|
@@ -1321,7 +1322,7 @@ async function Ke(s, t, e = {}) {
|
|
|
1321
1322
|
}
|
|
1322
1323
|
});
|
|
1323
1324
|
}
|
|
1324
|
-
function
|
|
1325
|
+
function dt(s, t, e, n) {
|
|
1325
1326
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1326
1327
|
throw new p("Invalid offset or length", "EINVAL");
|
|
1327
1328
|
if (t < 0 || e < 0)
|
|
@@ -1331,27 +1332,27 @@ function ft(s, t, e, n) {
|
|
|
1331
1332
|
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1332
1333
|
throw new p("Invalid position", "EINVAL");
|
|
1333
1334
|
}
|
|
1334
|
-
function
|
|
1335
|
+
function pt(s, t, e) {
|
|
1335
1336
|
try {
|
|
1336
1337
|
t.flush(), t.close();
|
|
1337
1338
|
} catch (n) {
|
|
1338
1339
|
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1339
1340
|
}
|
|
1340
1341
|
}
|
|
1341
|
-
function
|
|
1342
|
+
function ts(s, t, e) {
|
|
1342
1343
|
if (s >= e)
|
|
1343
1344
|
return { isEOF: !0, actualLength: 0 };
|
|
1344
1345
|
const n = Math.min(t, e - s);
|
|
1345
1346
|
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1346
1347
|
}
|
|
1347
|
-
async function
|
|
1348
|
+
async function es(s, t) {
|
|
1348
1349
|
try {
|
|
1349
1350
|
return await s.createSyncAccessHandle();
|
|
1350
1351
|
} catch (e) {
|
|
1351
|
-
throw
|
|
1352
|
+
throw Gt(e, { path: t });
|
|
1352
1353
|
}
|
|
1353
1354
|
}
|
|
1354
|
-
class
|
|
1355
|
+
class ss {
|
|
1355
1356
|
/** Root directory handle for the file system */
|
|
1356
1357
|
root;
|
|
1357
1358
|
/** Map of watched paths and options */
|
|
@@ -1395,7 +1396,7 @@ class es {
|
|
|
1395
1396
|
if (!this.options.broadcastChannel)
|
|
1396
1397
|
return;
|
|
1397
1398
|
const e = t.path;
|
|
1398
|
-
if (![...this.watchers.values()].some((r) =>
|
|
1399
|
+
if (![...this.watchers.values()].some((r) => Z(e, r.pattern) && r.include.some((o) => o && Z(e, o)) && !r.exclude.some((o) => o && Z(e, o))))
|
|
1399
1400
|
return;
|
|
1400
1401
|
let i;
|
|
1401
1402
|
if (this.options.hashAlgorithm)
|
|
@@ -1427,7 +1428,7 @@ class es {
|
|
|
1427
1428
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1428
1429
|
*/
|
|
1429
1430
|
constructor(t) {
|
|
1430
|
-
|
|
1431
|
+
Ye(), t && this.setOptions(t);
|
|
1431
1432
|
}
|
|
1432
1433
|
/**
|
|
1433
1434
|
* Initialize the file system within a given directory
|
|
@@ -1474,7 +1475,7 @@ class es {
|
|
|
1474
1475
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1475
1476
|
*/
|
|
1476
1477
|
async setOptions(t) {
|
|
1477
|
-
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 =
|
|
1478
|
+
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = _(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1478
1479
|
}
|
|
1479
1480
|
/**
|
|
1480
1481
|
* Get a directory handle from a path
|
|
@@ -1495,7 +1496,7 @@ class es {
|
|
|
1495
1496
|
* \`\`\`
|
|
1496
1497
|
*/
|
|
1497
1498
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1498
|
-
const i = Array.isArray(t) ? t :
|
|
1499
|
+
const i = Array.isArray(t) ? t : O(t);
|
|
1499
1500
|
let r = n;
|
|
1500
1501
|
for (const o of i)
|
|
1501
1502
|
r = await r.getDirectoryHandle(o, { create: e });
|
|
@@ -1521,9 +1522,9 @@ class es {
|
|
|
1521
1522
|
* \`\`\`
|
|
1522
1523
|
*/
|
|
1523
1524
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1524
|
-
const i =
|
|
1525
|
+
const i = O(t);
|
|
1525
1526
|
if (i.length === 0)
|
|
1526
|
-
throw new
|
|
1527
|
+
throw new Bt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1527
1528
|
const r = i.pop();
|
|
1528
1529
|
return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
|
|
1529
1530
|
}
|
|
@@ -1590,17 +1591,17 @@ class es {
|
|
|
1590
1591
|
async readFile(t) {
|
|
1591
1592
|
await this.mount();
|
|
1592
1593
|
try {
|
|
1593
|
-
return await
|
|
1594
|
+
return await T(t, "shared", async () => {
|
|
1594
1595
|
const e = await this.open(t);
|
|
1595
1596
|
try {
|
|
1596
1597
|
const { size: n } = await this.fstat(e), i = new Uint8Array(n);
|
|
1597
|
-
return n > 0 && await this.read(e, i, 0, n, 0),
|
|
1598
|
+
return n > 0 && await this.read(e, i, 0, n, 0), W(i, [i.buffer]);
|
|
1598
1599
|
} finally {
|
|
1599
1600
|
await this.close(e);
|
|
1600
1601
|
}
|
|
1601
1602
|
});
|
|
1602
1603
|
} catch (e) {
|
|
1603
|
-
throw new
|
|
1604
|
+
throw new it(t, e);
|
|
1604
1605
|
}
|
|
1605
1606
|
}
|
|
1606
1607
|
/**
|
|
@@ -1628,14 +1629,14 @@ class es {
|
|
|
1628
1629
|
async writeFile(t, e) {
|
|
1629
1630
|
await this.mount();
|
|
1630
1631
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1631
|
-
await
|
|
1632
|
+
await T(t, "exclusive", async () => {
|
|
1632
1633
|
const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
|
|
1633
1634
|
try {
|
|
1634
1635
|
await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
|
|
1635
1636
|
} finally {
|
|
1636
1637
|
await this.close(r);
|
|
1637
1638
|
}
|
|
1638
|
-
await this.notifyChange({ path: t, type: i ?
|
|
1639
|
+
await this.notifyChange({ path: t, type: i ? A.Changed : A.Added, isDirectory: !1 });
|
|
1639
1640
|
});
|
|
1640
1641
|
}
|
|
1641
1642
|
/**
|
|
@@ -1663,7 +1664,7 @@ class es {
|
|
|
1663
1664
|
async appendFile(t, e) {
|
|
1664
1665
|
await this.mount();
|
|
1665
1666
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1666
|
-
await
|
|
1667
|
+
await T(t, "exclusive", async () => {
|
|
1667
1668
|
const i = await this.open(t, { create: !0 });
|
|
1668
1669
|
try {
|
|
1669
1670
|
const { size: r } = await this.fstat(i);
|
|
@@ -1671,7 +1672,7 @@ class es {
|
|
|
1671
1672
|
} finally {
|
|
1672
1673
|
await this.close(i);
|
|
1673
1674
|
}
|
|
1674
|
-
await this.notifyChange({ path: t, type:
|
|
1675
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
|
|
1675
1676
|
});
|
|
1676
1677
|
}
|
|
1677
1678
|
/**
|
|
@@ -1697,7 +1698,7 @@ class es {
|
|
|
1697
1698
|
*/
|
|
1698
1699
|
async mkdir(t, e) {
|
|
1699
1700
|
await this.mount();
|
|
1700
|
-
const n = e?.recursive ?? !1, i =
|
|
1701
|
+
const n = e?.recursive ?? !1, i = O(t);
|
|
1701
1702
|
let r = this.root;
|
|
1702
1703
|
for (let o = 0; o < i.length; o++) {
|
|
1703
1704
|
const a = i[o];
|
|
@@ -1705,14 +1706,14 @@ class es {
|
|
|
1705
1706
|
r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
|
|
1706
1707
|
} catch (l) {
|
|
1707
1708
|
throw l.name === "NotFoundError" ? new p(
|
|
1708
|
-
\`Parent directory does not exist: \${
|
|
1709
|
+
\`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
|
|
1709
1710
|
"ENOENT",
|
|
1710
1711
|
void 0,
|
|
1711
1712
|
l
|
|
1712
1713
|
) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
|
|
1713
1714
|
}
|
|
1714
1715
|
}
|
|
1715
|
-
await this.notifyChange({ path: t, type:
|
|
1716
|
+
await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
|
|
1716
1717
|
}
|
|
1717
1718
|
/**
|
|
1718
1719
|
* Get file or directory statistics
|
|
@@ -1746,7 +1747,7 @@ class es {
|
|
|
1746
1747
|
isFile: !1,
|
|
1747
1748
|
isDirectory: !0
|
|
1748
1749
|
};
|
|
1749
|
-
const e =
|
|
1750
|
+
const e = K(t), n = await this.getDirectoryHandle(Y(t), !1), i = this.options.hashAlgorithm !== null;
|
|
1750
1751
|
try {
|
|
1751
1752
|
const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1752
1753
|
kind: "file",
|
|
@@ -1758,7 +1759,7 @@ class es {
|
|
|
1758
1759
|
};
|
|
1759
1760
|
if (i && this.options.hashAlgorithm)
|
|
1760
1761
|
try {
|
|
1761
|
-
const l = await
|
|
1762
|
+
const l = await Je(o, this.options.hashAlgorithm, this.options.maxFileSize);
|
|
1762
1763
|
a.hash = l;
|
|
1763
1764
|
} catch (l) {
|
|
1764
1765
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
@@ -1830,10 +1831,10 @@ class es {
|
|
|
1830
1831
|
async exists(t) {
|
|
1831
1832
|
if (await this.mount(), t === "/")
|
|
1832
1833
|
return !0;
|
|
1833
|
-
const e =
|
|
1834
|
+
const e = K(t);
|
|
1834
1835
|
let n = null;
|
|
1835
1836
|
try {
|
|
1836
|
-
n = await this.getDirectoryHandle(
|
|
1837
|
+
n = await this.getDirectoryHandle(Y(t), !1);
|
|
1837
1838
|
} catch (i) {
|
|
1838
1839
|
if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1839
1840
|
throw i;
|
|
@@ -1881,7 +1882,7 @@ class es {
|
|
|
1881
1882
|
const i = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1882
1883
|
await this.remove(i, { recursive: !0 });
|
|
1883
1884
|
}
|
|
1884
|
-
await this.notifyChange({ path: t, type:
|
|
1885
|
+
await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
|
|
1885
1886
|
} catch (e) {
|
|
1886
1887
|
throw e instanceof p ? e : new p(\`Failed to clear directory: \${t}\`, "CLEAR_FAILED", void 0, e);
|
|
1887
1888
|
}
|
|
@@ -1913,8 +1914,8 @@ class es {
|
|
|
1913
1914
|
async remove(t, e) {
|
|
1914
1915
|
if (await this.mount(), t === "/")
|
|
1915
1916
|
throw new p("Cannot remove root directory", "EROOT");
|
|
1916
|
-
const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(
|
|
1917
|
-
await
|
|
1917
|
+
const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(Y(t), !1), o = await this.stat(t);
|
|
1918
|
+
await Qe(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
|
|
1918
1919
|
}
|
|
1919
1920
|
/**
|
|
1920
1921
|
* Resolve a path to an absolute path
|
|
@@ -1937,9 +1938,9 @@ class es {
|
|
|
1937
1938
|
async realpath(t) {
|
|
1938
1939
|
await this.mount();
|
|
1939
1940
|
try {
|
|
1940
|
-
const e =
|
|
1941
|
+
const e = ft(t);
|
|
1941
1942
|
if (!await this.exists(e))
|
|
1942
|
-
throw new
|
|
1943
|
+
throw new it(e);
|
|
1943
1944
|
return e;
|
|
1944
1945
|
} catch (e) {
|
|
1945
1946
|
throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
|
|
@@ -1973,7 +1974,7 @@ class es {
|
|
|
1973
1974
|
const i = n?.overwrite ?? !1, r = await this.stat(t);
|
|
1974
1975
|
if (await this.exists(e) && !i)
|
|
1975
1976
|
throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
|
|
1976
|
-
await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type:
|
|
1977
|
+
await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: r.isDirectory });
|
|
1977
1978
|
} catch (i) {
|
|
1978
1979
|
throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
|
|
1979
1980
|
}
|
|
@@ -2057,7 +2058,7 @@ class es {
|
|
|
2057
2058
|
if (!this.options.broadcastChannel)
|
|
2058
2059
|
throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
|
|
2059
2060
|
const n = {
|
|
2060
|
-
pattern:
|
|
2061
|
+
pattern: Ze(t, e?.recursive ?? !0),
|
|
2061
2062
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2062
2063
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2063
2064
|
};
|
|
@@ -2098,9 +2099,9 @@ class es {
|
|
|
2098
2099
|
*/
|
|
2099
2100
|
async open(t, e) {
|
|
2100
2101
|
await this.mount();
|
|
2101
|
-
const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o =
|
|
2102
|
+
const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = _(ft(t));
|
|
2102
2103
|
try {
|
|
2103
|
-
return n && i ? await
|
|
2104
|
+
return n && i ? await T(o, "exclusive", async () => {
|
|
2104
2105
|
if (await this.exists(o))
|
|
2105
2106
|
throw new p(\`File already exists: \${o}\`, "EEXIST", o);
|
|
2106
2107
|
return this._openFile(o, n, r);
|
|
@@ -2120,7 +2121,7 @@ class es {
|
|
|
2120
2121
|
} catch (a) {
|
|
2121
2122
|
throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
|
|
2122
2123
|
}
|
|
2123
|
-
const r = await
|
|
2124
|
+
const r = await es(i, t);
|
|
2124
2125
|
n && (r.truncate(0), r.flush());
|
|
2125
2126
|
const o = this.nextFd++;
|
|
2126
2127
|
return this.openFiles.set(o, {
|
|
@@ -2146,7 +2147,7 @@ class es {
|
|
|
2146
2147
|
*/
|
|
2147
2148
|
async close(t) {
|
|
2148
2149
|
const e = this._getFileDescriptor(t);
|
|
2149
|
-
|
|
2150
|
+
pt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2150
2151
|
}
|
|
2151
2152
|
/**
|
|
2152
2153
|
* Read data from a file descriptor
|
|
@@ -2174,15 +2175,15 @@ class es {
|
|
|
2174
2175
|
*/
|
|
2175
2176
|
async read(t, e, n, i, r) {
|
|
2176
2177
|
const o = this._getFileDescriptor(t);
|
|
2177
|
-
|
|
2178
|
+
dt(e.length, n, i, r);
|
|
2178
2179
|
try {
|
|
2179
|
-
const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } =
|
|
2180
|
+
const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ts(a, i, l);
|
|
2180
2181
|
if (h)
|
|
2181
|
-
return
|
|
2182
|
+
return W({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2182
2183
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2183
|
-
return r == null && (o.position = a + u),
|
|
2184
|
+
return r == null && (o.position = a + u), W({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2184
2185
|
} catch (a) {
|
|
2185
|
-
throw
|
|
2186
|
+
throw L("read", t, o.path, a);
|
|
2186
2187
|
}
|
|
2187
2188
|
}
|
|
2188
2189
|
/**
|
|
@@ -2208,12 +2209,12 @@ class es {
|
|
|
2208
2209
|
*/
|
|
2209
2210
|
async write(t, e, n = 0, i, r, o = !0) {
|
|
2210
2211
|
const a = this._getFileDescriptor(t), l = i ?? e.length - n;
|
|
2211
|
-
|
|
2212
|
+
dt(e.length, n, l, r);
|
|
2212
2213
|
try {
|
|
2213
2214
|
const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2214
|
-
return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type:
|
|
2215
|
+
return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
|
|
2215
2216
|
} catch (h) {
|
|
2216
|
-
throw
|
|
2217
|
+
throw L("write", t, a.path, h);
|
|
2217
2218
|
}
|
|
2218
2219
|
}
|
|
2219
2220
|
/**
|
|
@@ -2259,9 +2260,9 @@ class es {
|
|
|
2259
2260
|
if (e < 0 || !Number.isInteger(e))
|
|
2260
2261
|
throw new p("Invalid size", "EINVAL");
|
|
2261
2262
|
try {
|
|
2262
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2263
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
|
|
2263
2264
|
} catch (i) {
|
|
2264
|
-
throw
|
|
2265
|
+
throw L("truncate", t, n.path, i);
|
|
2265
2266
|
}
|
|
2266
2267
|
}
|
|
2267
2268
|
/**
|
|
@@ -2283,7 +2284,7 @@ class es {
|
|
|
2283
2284
|
try {
|
|
2284
2285
|
e.syncHandle.flush();
|
|
2285
2286
|
} catch (n) {
|
|
2286
|
-
throw
|
|
2287
|
+
throw L("sync", t, e.path, n);
|
|
2287
2288
|
}
|
|
2288
2289
|
}
|
|
2289
2290
|
/**
|
|
@@ -2295,7 +2296,7 @@ class es {
|
|
|
2295
2296
|
dispose() {
|
|
2296
2297
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2297
2298
|
for (const [t, e] of this.openFiles)
|
|
2298
|
-
|
|
2299
|
+
pt(t, e.syncHandle, e.path);
|
|
2299
2300
|
this.openFiles.clear(), this.nextFd = 1;
|
|
2300
2301
|
}
|
|
2301
2302
|
/**
|
|
@@ -2330,16 +2331,16 @@ class es {
|
|
|
2330
2331
|
await this.mount();
|
|
2331
2332
|
try {
|
|
2332
2333
|
for (const [e, n] of t) {
|
|
2333
|
-
const i =
|
|
2334
|
+
const i = _(e);
|
|
2334
2335
|
let r;
|
|
2335
|
-
n instanceof Blob ? r = await
|
|
2336
|
+
n instanceof Blob ? r = await Ke(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
|
|
2336
2337
|
}
|
|
2337
2338
|
} catch (e) {
|
|
2338
2339
|
throw e instanceof p ? e : new p("Failed to sync file system", "SYNC_FAILED", void 0, e);
|
|
2339
2340
|
}
|
|
2340
2341
|
}
|
|
2341
2342
|
}
|
|
2342
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2343
|
-
//# sourceMappingURL=worker-
|
|
2344
|
-
`,c=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=c&&(self.URL||self.webkitURL).createObjectURL(c),!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(l),{type:"module",name:o?.name})}}function
|
|
2343
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && Q(new ss());
|
|
2344
|
+
//# sourceMappingURL=worker-CS9nvwsF.js.map
|
|
2345
|
+
`,c=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=c&&(self.URL||self.webkitURL).createObjectURL(c),!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(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class f{#n;promises=this;constructor(n){this.#n=d.wrap(new u),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}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 i;typeof t=="string"?i=t:t&&typeof t=="object"&&(i=t.encoding);const s=await this.#n.readFile(r);return i||(i=e.isBinaryFileExtension(r)?"binary":"utf-8"),i==="binary"?s:e.decodeBuffer(s,i)}async writeFile(n,t,r){const i=a(n);let s;typeof r=="string"?s=r:r&&typeof r=="object"&&(s=r.encoding),s||(s=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const h=typeof t=="string"?e.encodeString(t,s):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(i,h)}async appendFile(n,t,r){const i=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const s=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(i,s)}async mkdir(n,t){const r=a(n);let i;return typeof t=="number"?i={recursive:!1}:i=t,this.#n.mkdir(r,i)}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 i=a(n),s=a(t);return this.#n.rename(i,s,r)}async copy(n,t,r){const i=a(n),s=a(t);return this.#n.copy(i,s,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,i,s){const{bytesRead:h,buffer:p}=await this.#n.read(n,new Uint8Array(i),0,i,s);return h>0&&t.set(p.subarray(0,h),r),{bytesRead:h,buffer:t}}async write(n,t,r,i,s,h){return this.#n.write(n,t,r,i,s,h)}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)}dispose(){this.#n.dispose()}async createIndex(n){const t=n.map(([r,i])=>[a(r),i]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),i=await this.#n.readFile(r);return e.decodeBuffer(i,t)}async writeText(n,t,r="utf-8"){const i=a(n),s=e.encodeString(t,r);return this.#n.writeFile(i,s)}async appendText(n,t,r="utf-8"){const i=a(n),s=e.encodeString(t,r);return this.#n.appendFile(i,s)}}function m(o){return new f(o)}exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryNotFoundError=e.DirectoryNotFoundError;exports.FileNotFoundError=e.FileNotFoundError;exports.OPFSError=e.OPFSError;exports.OPFSNotMountedError=e.OPFSNotMountedError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.TimeoutError=e.TimeoutError;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.OPFSFileSystem=f;exports.createWorker=m;
|
|
2345
2346
|
//# sourceMappingURL=index.cjs.map
|