opfs-worker 1.2.4 → 1.3.1
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-1Wh1cr7P.js.map +1 -0
- package/dist/assets/worker-BeJaVyBV.js.map +1 -0
- package/dist/helpers-BuGfPAg0.js +1439 -0
- package/dist/helpers-BuGfPAg0.js.map +1 -0
- package/dist/helpers-CF7A2WQG.cjs +4 -0
- package/dist/helpers-CF7A2WQG.cjs.map +1 -0
- package/dist/helpers-CIiblZ8d.cjs +4 -0
- package/dist/helpers-CIiblZ8d.cjs.map +1 -0
- package/dist/{helpers-BXhw_-Ar.js → helpers-CKOebsbw.js} +573 -480
- package/dist/helpers-CKOebsbw.js.map +1 -0
- package/dist/index.cjs +711 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +768 -650
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +88 -89
- package/dist/raw.js.map +1 -1
- package/dist/utils/errors.d.ts +65 -22
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-BEh95XuP.js.map +0 -1
- package/dist/assets/worker-CS9nvwsF.js.map +0 -1
- package/dist/assets/worker-Dy3EFYv_.js.map +0 -1
- package/dist/helpers-04x7UBul.cjs +0 -4
- package/dist/helpers-04x7UBul.cjs.map +0 -1
- package/dist/helpers-BXhw_-Ar.js.map +0 -1
- package/dist/helpers-BwklIUit.js +0 -1329
- package/dist/helpers-BwklIUit.js.map +0 -1
- package/dist/helpers-ppMRzIAJ.cjs +0 -4
- package/dist/helpers-ppMRzIAJ.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-CIiblZ8d.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 bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), J = Symbol("Comlink.finalizer"), U = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
|
|
7
|
+
canHandle: (s) => Ot(s) && s[bt],
|
|
8
8
|
serialize(s) {
|
|
9
9
|
const { port1: t, port2: e } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return ot(s, t), [e, [e]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(s) {
|
|
13
|
-
return s.start(),
|
|
13
|
+
return s.start(), Gt(s);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (s) =>
|
|
15
|
+
}, _t = {
|
|
16
|
+
canHandle: (s) => Ot(s) && U in s,
|
|
17
17
|
serialize({ value: s }) {
|
|
18
18
|
let t;
|
|
19
19
|
return s instanceof Error ? t = {
|
|
@@ -28,25 +28,25 @@ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = 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
|
+
}, Dt = /* @__PURE__ */ new Map([
|
|
32
|
+
["proxy", jt],
|
|
33
|
+
["throw", _t]
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
35
|
+
function Ut(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
|
|
42
|
-
t.addEventListener("message", function n(
|
|
43
|
-
if (!
|
|
41
|
+
function ot(s, t = globalThis, e = ["*"]) {
|
|
42
|
+
t.addEventListener("message", function n(r) {
|
|
43
|
+
if (!r || !r.data)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
46
|
-
console.warn(\`Invalid origin '\${
|
|
45
|
+
if (!Ut(e, r.origin)) {
|
|
46
|
+
console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id:
|
|
49
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
|
|
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 Q(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]] = C(r.data.value), h = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
61
|
h = f.apply(c, l);
|
|
@@ -63,13 +63,13 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
65
|
const u = new f(...l);
|
|
66
|
-
h =
|
|
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
|
-
|
|
72
|
+
ot(s, d), h = B(u, [u]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -79,145 +79,145 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
} catch (c) {
|
|
82
|
-
h = { value: c, [
|
|
82
|
+
h = { value: c, [U]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
85
|
-
const [f, u] =
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
84
|
+
Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
|
|
85
|
+
const [f, u] = Y(c);
|
|
86
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), J in s && typeof s[J] == "function" && s[J]());
|
|
87
87
|
}).catch((c) => {
|
|
88
|
-
const [f, u] =
|
|
88
|
+
const [f, u] = Y({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
90
|
+
[U]: 0
|
|
91
91
|
});
|
|
92
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
92
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
93
93
|
});
|
|
94
94
|
}), t.start && t.start();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function Bt(s) {
|
|
97
97
|
return s.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function vt(s) {
|
|
100
|
+
Bt(s) && s.close();
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Gt(s, t) {
|
|
103
103
|
const e = /* @__PURE__ */ new Map();
|
|
104
|
-
return s.addEventListener("message", function(
|
|
105
|
-
const { data:
|
|
106
|
-
if (!
|
|
104
|
+
return s.addEventListener("message", function(r) {
|
|
105
|
+
const { data: i } = r;
|
|
106
|
+
if (!i || !i.id)
|
|
107
107
|
return;
|
|
108
|
-
const o = e.get(
|
|
108
|
+
const o = e.get(i.id);
|
|
109
109
|
if (o)
|
|
110
110
|
try {
|
|
111
|
-
o(
|
|
111
|
+
o(i);
|
|
112
112
|
} finally {
|
|
113
|
-
e.delete(
|
|
113
|
+
e.delete(i.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), nt(s, e, [], t);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function W(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 At(s) {
|
|
122
|
+
return $(s, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
vt(s);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
128
|
+
const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
129
|
+
const t = (q.get(s) || 0) - 1;
|
|
130
|
+
q.set(s, t), t === 0 && At(s);
|
|
131
131
|
});
|
|
132
|
-
function
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
132
|
+
function qt(s, t) {
|
|
133
|
+
const e = (q.get(t) || 0) + 1;
|
|
134
|
+
q.set(t, e), V && V.register(s, t, s);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function Vt(s) {
|
|
137
|
+
V && V.unregister(s);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function nt(s, t, e = [], n = function() {
|
|
140
140
|
}) {
|
|
141
|
-
let
|
|
142
|
-
const
|
|
141
|
+
let r = !1;
|
|
142
|
+
const i = new Proxy(n, {
|
|
143
143
|
get(o, a) {
|
|
144
|
-
if (
|
|
144
|
+
if (W(r), a === Wt)
|
|
145
145
|
return () => {
|
|
146
|
-
|
|
146
|
+
Vt(i), At(s), t.clear(), r = !0;
|
|
147
147
|
};
|
|
148
148
|
if (a === "then") {
|
|
149
149
|
if (e.length === 0)
|
|
150
|
-
return { then: () =>
|
|
151
|
-
const l =
|
|
150
|
+
return { then: () => i };
|
|
151
|
+
const l = $(s, t, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: e.map((h) => h.toString())
|
|
154
|
-
}).then(
|
|
154
|
+
}).then(C);
|
|
155
155
|
return l.then.bind(l);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return nt(s, t, [...e, a]);
|
|
158
158
|
},
|
|
159
159
|
set(o, a, l) {
|
|
160
|
-
|
|
161
|
-
const [h, c] =
|
|
162
|
-
return
|
|
160
|
+
W(r);
|
|
161
|
+
const [h, c] = Y(l);
|
|
162
|
+
return $(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(C);
|
|
167
167
|
},
|
|
168
168
|
apply(o, a, l) {
|
|
169
|
-
|
|
169
|
+
W(r);
|
|
170
170
|
const h = e[e.length - 1];
|
|
171
|
-
if (h ===
|
|
172
|
-
return
|
|
171
|
+
if (h === Ht)
|
|
172
|
+
return $(s, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
174
|
+
}).then(C);
|
|
175
175
|
if (h === "bind")
|
|
176
|
-
return
|
|
177
|
-
const [c, f] =
|
|
178
|
-
return
|
|
176
|
+
return nt(s, t, e.slice(0, -1));
|
|
177
|
+
const [c, f] = ht(l);
|
|
178
|
+
return $(s, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: e.map((u) => u.toString()),
|
|
181
181
|
argumentList: c
|
|
182
|
-
}, f).then(
|
|
182
|
+
}, f).then(C);
|
|
183
183
|
},
|
|
184
184
|
construct(o, a) {
|
|
185
|
-
|
|
186
|
-
const [l, h] =
|
|
187
|
-
return
|
|
185
|
+
W(r);
|
|
186
|
+
const [l, h] = ht(a);
|
|
187
|
+
return $(s, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
189
|
path: e.map((c) => c.toString()),
|
|
190
190
|
argumentList: l
|
|
191
|
-
}, h).then(
|
|
191
|
+
}, h).then(C);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
return
|
|
194
|
+
return qt(i, s), i;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Yt(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 ht(s) {
|
|
200
|
+
const t = s.map(Y);
|
|
201
|
+
return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
|
|
202
202
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
203
|
+
const Nt = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function B(s, t) {
|
|
205
|
+
return Nt.set(s, t), s;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(s, { [
|
|
207
|
+
function Zt(s) {
|
|
208
|
+
return Object.assign(s, { [bt]: !0 });
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (const [t, e] of
|
|
210
|
+
function Y(s) {
|
|
211
|
+
for (const [t, e] of Dt)
|
|
212
212
|
if (e.canHandle(s)) {
|
|
213
|
-
const [n,
|
|
213
|
+
const [n, r] = e.serialize(s);
|
|
214
214
|
return [
|
|
215
215
|
{
|
|
216
216
|
type: "HANDLER",
|
|
217
217
|
name: t,
|
|
218
218
|
value: n
|
|
219
219
|
},
|
|
220
|
-
|
|
220
|
+
r
|
|
221
221
|
];
|
|
222
222
|
}
|
|
223
223
|
return [
|
|
@@ -225,178 +225,290 @@ function B(s) {
|
|
|
225
225
|
type: "RAW",
|
|
226
226
|
value: s
|
|
227
227
|
},
|
|
228
|
-
|
|
228
|
+
Nt.get(s) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function C(s) {
|
|
232
232
|
switch (s.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
|
-
return
|
|
234
|
+
return Dt.get(s.name).deserialize(s.value);
|
|
235
235
|
case "RAW":
|
|
236
236
|
return s.value;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return new Promise((
|
|
241
|
-
const
|
|
242
|
-
t.set(
|
|
239
|
+
function $(s, t, e, n) {
|
|
240
|
+
return new Promise((r) => {
|
|
241
|
+
const i = Xt();
|
|
242
|
+
t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
function
|
|
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
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
|
|
249
|
+
const Jt = {
|
|
250
|
+
ENOENT: -2,
|
|
251
|
+
// No such file or directory
|
|
252
|
+
EISDIR: -21,
|
|
253
|
+
// Is a directory
|
|
254
|
+
ENOTDIR: -20,
|
|
255
|
+
// Not a directory
|
|
256
|
+
EACCES: -13,
|
|
257
|
+
// Permission denied
|
|
258
|
+
EEXIST: -17,
|
|
259
|
+
// File exists
|
|
260
|
+
ENOTEMPTY: -39,
|
|
261
|
+
// Directory not empty
|
|
262
|
+
EINVAL: -22,
|
|
263
|
+
// Invalid argument
|
|
264
|
+
EIO: -5,
|
|
265
|
+
// I/O error
|
|
266
|
+
ENOSPC: -28,
|
|
267
|
+
// No space left on device
|
|
268
|
+
EBUSY: -16,
|
|
269
|
+
// Device or resource busy
|
|
270
|
+
EINTR: -4,
|
|
271
|
+
// Interrupted system call
|
|
272
|
+
ENOTSUP: -95,
|
|
273
|
+
// Operation not supported
|
|
274
|
+
ERANGE: -34,
|
|
275
|
+
// Result too large
|
|
276
|
+
EBADF: -9,
|
|
277
|
+
// Bad file descriptor
|
|
278
|
+
EROOT: -1
|
|
279
|
+
// Custom: Cannot remove root directory
|
|
280
|
+
};
|
|
281
|
+
class w extends Error {
|
|
282
|
+
errno;
|
|
283
|
+
syscall;
|
|
284
|
+
path;
|
|
285
|
+
constructor(t, e, n, r, i) {
|
|
286
|
+
super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
|
|
252
287
|
}
|
|
253
288
|
}
|
|
254
|
-
class
|
|
289
|
+
class Qt extends w {
|
|
255
290
|
constructor(t) {
|
|
256
|
-
super("OPFS is not supported in this browser", "
|
|
291
|
+
super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
class Kt extends w {
|
|
295
|
+
constructor(t, e, n) {
|
|
296
|
+
super(t, "INVALID_PATH", e, "access", n);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
class F extends w {
|
|
300
|
+
constructor(t, e, n) {
|
|
301
|
+
const r = {
|
|
302
|
+
file: \`File not found: \${e}\`,
|
|
303
|
+
directory: \`Directory not found: \${e}\`,
|
|
304
|
+
source: \`Source does not exist: \${e}\`
|
|
305
|
+
};
|
|
306
|
+
super(r[t], "ENOENT", e, "access", n);
|
|
257
307
|
}
|
|
258
308
|
}
|
|
259
|
-
class
|
|
309
|
+
class te extends w {
|
|
260
310
|
constructor(t, e, n) {
|
|
261
|
-
super(t
|
|
311
|
+
super(\`Permission denied for \${e} on: \${t}\`, "EACCES", t, e, n);
|
|
262
312
|
}
|
|
263
313
|
}
|
|
264
|
-
class
|
|
314
|
+
class ee extends w {
|
|
315
|
+
constructor(t, e, n) {
|
|
316
|
+
super(t, "ENOSPC", e, "write", n);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
class se extends w {
|
|
265
320
|
constructor(t, e) {
|
|
266
|
-
super(\`File
|
|
321
|
+
super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
class z extends w {
|
|
325
|
+
constructor(t, e, n) {
|
|
326
|
+
const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
327
|
+
super(r, i, e, "access", n);
|
|
267
328
|
}
|
|
268
329
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
330
|
+
class N extends w {
|
|
331
|
+
constructor(t, e, n, r) {
|
|
332
|
+
const i = {
|
|
333
|
+
argument: "EINVAL",
|
|
334
|
+
format: "INVALID_FORMAT",
|
|
335
|
+
descriptor: "EBADF",
|
|
336
|
+
overflow: "ERANGE"
|
|
337
|
+
};
|
|
338
|
+
super(e, i[t], n, "validate", r);
|
|
339
|
+
}
|
|
272
340
|
}
|
|
273
|
-
|
|
274
|
-
|
|
341
|
+
class ne extends w {
|
|
342
|
+
constructor(t, e) {
|
|
343
|
+
super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
class ut extends w {
|
|
347
|
+
constructor(t, e, n) {
|
|
348
|
+
super(t, "EIO", e, "io", n);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
class Ct extends w {
|
|
352
|
+
constructor(t, e) {
|
|
353
|
+
super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class rt extends w {
|
|
357
|
+
constructor(t, e, n) {
|
|
358
|
+
const r = {
|
|
359
|
+
RM_FAILED: \`Failed to remove entry: \${e}\`,
|
|
360
|
+
ENOTEMPTY: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
|
|
361
|
+
EROOT: "Cannot remove root directory"
|
|
362
|
+
};
|
|
363
|
+
super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", n);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
class re extends w {
|
|
367
|
+
constructor(t, e) {
|
|
368
|
+
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
class Q extends w {
|
|
372
|
+
constructor(t, e, n) {
|
|
373
|
+
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
class K extends w {
|
|
377
|
+
constructor(t, e) {
|
|
378
|
+
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function j(s, t, e, n) {
|
|
382
|
+
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
383
|
+
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
384
|
+
}
|
|
385
|
+
function A(s, t) {
|
|
386
|
+
const e = t?.path, n = t?.isDirectory;
|
|
275
387
|
switch (s.name) {
|
|
276
388
|
case "InvalidStateError":
|
|
277
|
-
return new
|
|
389
|
+
return new se(e || "unknown", s);
|
|
278
390
|
case "QuotaExceededError":
|
|
279
|
-
return new
|
|
391
|
+
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
280
392
|
case "NotFoundError":
|
|
281
|
-
return new
|
|
393
|
+
return new F("file", e, s);
|
|
282
394
|
case "TypeMismatchError":
|
|
283
|
-
return new
|
|
395
|
+
return n !== void 0 ? n ? new z("directory", e || "unknown", s) : new z("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
284
396
|
case "NotAllowedError":
|
|
285
397
|
case "SecurityError":
|
|
286
|
-
return new
|
|
398
|
+
return new te(e, "unknown", s);
|
|
287
399
|
case "InvalidModificationError":
|
|
288
|
-
return new
|
|
400
|
+
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
289
401
|
case "AbortError":
|
|
290
|
-
return new
|
|
402
|
+
return new ne(e || "unknown", s);
|
|
291
403
|
case "OperationError":
|
|
292
|
-
return new
|
|
404
|
+
return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
|
|
293
405
|
case "TypeError":
|
|
294
|
-
return new
|
|
406
|
+
return new Ct(e || "unknown", s);
|
|
295
407
|
default:
|
|
296
|
-
return new
|
|
408
|
+
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
297
409
|
}
|
|
298
410
|
}
|
|
299
|
-
const
|
|
300
|
-
const n = s instanceof RegExp ?
|
|
301
|
-
return
|
|
302
|
-
start:
|
|
303
|
-
end:
|
|
304
|
-
pre: e.slice(0,
|
|
305
|
-
body: e.slice(
|
|
306
|
-
post: e.slice(
|
|
411
|
+
const Ft = (s, t, e) => {
|
|
412
|
+
const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
|
|
413
|
+
return i && {
|
|
414
|
+
start: i[0],
|
|
415
|
+
end: i[1],
|
|
416
|
+
pre: e.slice(0, i[0]),
|
|
417
|
+
body: e.slice(i[0] + n.length, i[1]),
|
|
418
|
+
post: e.slice(i[1] + r.length)
|
|
307
419
|
};
|
|
308
|
-
},
|
|
420
|
+
}, ft = (s, t) => {
|
|
309
421
|
const e = t.match(s);
|
|
310
422
|
return e ? e[0] : null;
|
|
311
|
-
},
|
|
312
|
-
let n,
|
|
423
|
+
}, ie = (s, t, e) => {
|
|
424
|
+
let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
313
425
|
if (l >= 0 && h > 0) {
|
|
314
426
|
if (s === t)
|
|
315
427
|
return [l, h];
|
|
316
|
-
for (n = [],
|
|
428
|
+
for (n = [], i = e.length; c >= 0 && !a; ) {
|
|
317
429
|
if (c === l)
|
|
318
430
|
n.push(c), l = e.indexOf(s, c + 1);
|
|
319
431
|
else if (n.length === 1) {
|
|
320
432
|
const f = n.pop();
|
|
321
433
|
f !== void 0 && (a = [f, h]);
|
|
322
434
|
} else
|
|
323
|
-
|
|
435
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
|
|
324
436
|
c = l < h && l >= 0 ? l : h;
|
|
325
437
|
}
|
|
326
|
-
n.length && o !== void 0 && (a = [
|
|
438
|
+
n.length && o !== void 0 && (a = [i, o]);
|
|
327
439
|
}
|
|
328
440
|
return a;
|
|
329
|
-
},
|
|
330
|
-
function
|
|
441
|
+
}, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Pt = "\\0COMMA" + Math.random() + "\\0", Tt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Pt, "g"), he = new RegExp(Tt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
|
|
442
|
+
function tt(s) {
|
|
331
443
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
332
444
|
}
|
|
333
|
-
function
|
|
334
|
-
return s.replace(
|
|
445
|
+
function we(s) {
|
|
446
|
+
return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
|
|
335
447
|
}
|
|
336
|
-
function
|
|
337
|
-
return s.replace(
|
|
448
|
+
function me(s) {
|
|
449
|
+
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
338
450
|
}
|
|
339
|
-
function
|
|
451
|
+
function Rt(s) {
|
|
340
452
|
if (!s)
|
|
341
453
|
return [""];
|
|
342
|
-
const t = [], e =
|
|
454
|
+
const t = [], e = Ft("{", "}", s);
|
|
343
455
|
if (!e)
|
|
344
456
|
return s.split(",");
|
|
345
|
-
const { pre: n, body:
|
|
346
|
-
o[o.length - 1] += "{" +
|
|
347
|
-
const a =
|
|
348
|
-
return
|
|
457
|
+
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
458
|
+
o[o.length - 1] += "{" + r + "}";
|
|
459
|
+
const a = Rt(i);
|
|
460
|
+
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
349
461
|
}
|
|
350
|
-
function
|
|
351
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(
|
|
462
|
+
function ye(s) {
|
|
463
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
|
|
352
464
|
}
|
|
353
|
-
function
|
|
465
|
+
function Ee(s) {
|
|
354
466
|
return "{" + s + "}";
|
|
355
467
|
}
|
|
356
|
-
function
|
|
468
|
+
function Se(s) {
|
|
357
469
|
return /^-?0\\d/.test(s);
|
|
358
470
|
}
|
|
359
|
-
function
|
|
471
|
+
function xe(s, t) {
|
|
360
472
|
return s <= t;
|
|
361
473
|
}
|
|
362
|
-
function
|
|
474
|
+
function be(s, t) {
|
|
363
475
|
return s >= t;
|
|
364
476
|
}
|
|
365
477
|
function I(s, t) {
|
|
366
|
-
const e = [], n =
|
|
478
|
+
const e = [], n = Ft("{", "}", s);
|
|
367
479
|
if (!n)
|
|
368
480
|
return [s];
|
|
369
|
-
const
|
|
481
|
+
const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
|
|
370
482
|
if (/\\$$/.test(n.pre))
|
|
371
|
-
for (let o = 0; o <
|
|
372
|
-
const a =
|
|
483
|
+
for (let o = 0; o < i.length; o++) {
|
|
484
|
+
const a = r + "{" + n.body + "}" + i[o];
|
|
373
485
|
e.push(a);
|
|
374
486
|
}
|
|
375
487
|
else {
|
|
376
488
|
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;
|
|
377
489
|
if (!l && !h)
|
|
378
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
490
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
|
|
379
491
|
let c;
|
|
380
492
|
if (l)
|
|
381
493
|
c = n.body.split(/\\.\\./);
|
|
382
|
-
else if (c =
|
|
383
|
-
return
|
|
494
|
+
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
|
|
495
|
+
return i.map((u) => n.pre + c[0] + u);
|
|
384
496
|
let f;
|
|
385
497
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
386
|
-
const u =
|
|
387
|
-
let
|
|
388
|
-
d < u && (
|
|
389
|
-
const
|
|
498
|
+
const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
499
|
+
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
|
|
500
|
+
d < u && (p *= -1, S = be);
|
|
501
|
+
const P = c.some(Se);
|
|
390
502
|
f = [];
|
|
391
|
-
for (let x = u; S(x, d); x +=
|
|
503
|
+
for (let x = u; S(x, d); x += p) {
|
|
392
504
|
let m;
|
|
393
505
|
if (a)
|
|
394
506
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
395
|
-
else if (m = String(x),
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
const
|
|
399
|
-
x < 0 ? m = "-" +
|
|
507
|
+
else if (m = String(x), P) {
|
|
508
|
+
const T = g - m.length;
|
|
509
|
+
if (T > 0) {
|
|
510
|
+
const H = new Array(T + 1).join("0");
|
|
511
|
+
x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
|
|
400
512
|
}
|
|
401
513
|
}
|
|
402
514
|
f.push(m);
|
|
@@ -407,19 +519,19 @@ function I(s, t) {
|
|
|
407
519
|
f.push.apply(f, I(c[u], !1));
|
|
408
520
|
}
|
|
409
521
|
for (let u = 0; u < f.length; u++)
|
|
410
|
-
for (let d = 0; d <
|
|
411
|
-
const
|
|
412
|
-
(!t || l ||
|
|
522
|
+
for (let d = 0; d < i.length; d++) {
|
|
523
|
+
const g = r + f[u] + i[d];
|
|
524
|
+
(!t || l || g) && e.push(g);
|
|
413
525
|
}
|
|
414
526
|
}
|
|
415
527
|
return e;
|
|
416
528
|
}
|
|
417
|
-
const
|
|
529
|
+
const Oe = 1024 * 64, Z = (s) => {
|
|
418
530
|
if (typeof s != "string")
|
|
419
531
|
throw new TypeError("invalid pattern");
|
|
420
|
-
if (s.length >
|
|
532
|
+
if (s.length > Oe)
|
|
421
533
|
throw new TypeError("pattern is too long");
|
|
422
|
-
},
|
|
534
|
+
}, De = {
|
|
423
535
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
424
536
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
425
537
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -434,77 +546,77 @@ const he = 1024 * 64, G = (s) => {
|
|
|
434
546
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
435
547
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
436
548
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
437
|
-
},
|
|
549
|
+
}, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
|
|
438
550
|
const e = t;
|
|
439
551
|
if (s.charAt(e) !== "[")
|
|
440
552
|
throw new Error("not in a brace expression");
|
|
441
|
-
const n = [],
|
|
442
|
-
let
|
|
443
|
-
t: for (;
|
|
444
|
-
const
|
|
445
|
-
if ((
|
|
446
|
-
h = !0,
|
|
553
|
+
const n = [], r = [];
|
|
554
|
+
let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
|
|
555
|
+
t: for (; i < s.length; ) {
|
|
556
|
+
const p = s.charAt(i);
|
|
557
|
+
if ((p === "!" || p === "^") && i === e + 1) {
|
|
558
|
+
h = !0, i++;
|
|
447
559
|
continue;
|
|
448
560
|
}
|
|
449
|
-
if (
|
|
450
|
-
c =
|
|
561
|
+
if (p === "]" && o && !l) {
|
|
562
|
+
c = i + 1;
|
|
451
563
|
break;
|
|
452
564
|
}
|
|
453
|
-
if (o = !0,
|
|
454
|
-
l = !0,
|
|
565
|
+
if (o = !0, p === "\\\\" && !l) {
|
|
566
|
+
l = !0, i++;
|
|
455
567
|
continue;
|
|
456
568
|
}
|
|
457
|
-
if (
|
|
458
|
-
for (const [S, [
|
|
459
|
-
if (s.startsWith(S,
|
|
569
|
+
if (p === "[" && !l) {
|
|
570
|
+
for (const [S, [v, P, x]] of Object.entries(De))
|
|
571
|
+
if (s.startsWith(S, i)) {
|
|
460
572
|
if (f)
|
|
461
573
|
return ["$.", !1, s.length - e, !0];
|
|
462
|
-
|
|
574
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || P;
|
|
463
575
|
continue t;
|
|
464
576
|
}
|
|
465
577
|
}
|
|
466
578
|
if (l = !1, f) {
|
|
467
|
-
|
|
579
|
+
p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
|
|
468
580
|
continue;
|
|
469
581
|
}
|
|
470
|
-
if (s.startsWith("-]",
|
|
471
|
-
n.push(
|
|
582
|
+
if (s.startsWith("-]", i + 1)) {
|
|
583
|
+
n.push(R(p + "-")), i += 2;
|
|
472
584
|
continue;
|
|
473
585
|
}
|
|
474
|
-
if (s.startsWith("-",
|
|
475
|
-
f =
|
|
586
|
+
if (s.startsWith("-", i + 1)) {
|
|
587
|
+
f = p, i += 2;
|
|
476
588
|
continue;
|
|
477
589
|
}
|
|
478
|
-
n.push(
|
|
590
|
+
n.push(R(p)), i++;
|
|
479
591
|
}
|
|
480
|
-
if (c <
|
|
592
|
+
if (c < i)
|
|
481
593
|
return ["", !1, 0, !1];
|
|
482
|
-
if (!n.length && !
|
|
594
|
+
if (!n.length && !r.length)
|
|
483
595
|
return ["$.", !1, s.length - e, !0];
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
486
|
-
return [
|
|
596
|
+
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
597
|
+
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
598
|
+
return [ve(p), !1, c - e, !1];
|
|
487
599
|
}
|
|
488
|
-
const u = "[" + (h ? "^" : "") +
|
|
489
|
-
return [n.length &&
|
|
490
|
-
},
|
|
600
|
+
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
601
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", _ = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
491
603
|
class E {
|
|
492
604
|
type;
|
|
493
605
|
#s;
|
|
494
606
|
#n;
|
|
495
|
-
#
|
|
607
|
+
#i = !1;
|
|
496
608
|
#t = [];
|
|
497
609
|
#e;
|
|
498
610
|
#o;
|
|
499
611
|
#c;
|
|
500
612
|
#a = !1;
|
|
501
|
-
#
|
|
613
|
+
#r;
|
|
502
614
|
#l;
|
|
503
615
|
// set to true if it's an extglob with no children
|
|
504
616
|
// (which really means one child of '')
|
|
505
617
|
#u = !1;
|
|
506
618
|
constructor(t, e, n = {}) {
|
|
507
|
-
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#
|
|
619
|
+
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
|
|
508
620
|
}
|
|
509
621
|
get hasMagic() {
|
|
510
622
|
if (this.#n !== void 0)
|
|
@@ -530,11 +642,11 @@ class E {
|
|
|
530
642
|
continue;
|
|
531
643
|
let e = t, n = e.#e;
|
|
532
644
|
for (; n; ) {
|
|
533
|
-
for (let
|
|
534
|
-
for (const
|
|
535
|
-
if (typeof
|
|
645
|
+
for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
|
|
646
|
+
for (const i of t.#t) {
|
|
647
|
+
if (typeof i == "string")
|
|
536
648
|
throw new Error("string part in extglob AST??");
|
|
537
|
-
|
|
649
|
+
i.copyIn(n.#t[r]);
|
|
538
650
|
}
|
|
539
651
|
e = n, n = e.#e;
|
|
540
652
|
}
|
|
@@ -587,40 +699,40 @@ class E {
|
|
|
587
699
|
e.copyIn(n);
|
|
588
700
|
return e;
|
|
589
701
|
}
|
|
590
|
-
static #h(t, e, n,
|
|
591
|
-
let
|
|
702
|
+
static #h(t, e, n, r) {
|
|
703
|
+
let i = !1, o = !1, a = -1, l = !1;
|
|
592
704
|
if (e.type === null) {
|
|
593
|
-
let d = n,
|
|
705
|
+
let d = n, g = "";
|
|
594
706
|
for (; d < t.length; ) {
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
597
|
-
|
|
707
|
+
const p = t.charAt(d++);
|
|
708
|
+
if (i || p === "\\\\") {
|
|
709
|
+
i = !i, g += p;
|
|
598
710
|
continue;
|
|
599
711
|
}
|
|
600
712
|
if (o) {
|
|
601
|
-
d === a + 1 ? (
|
|
713
|
+
d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
|
|
602
714
|
continue;
|
|
603
|
-
} else if (
|
|
604
|
-
o = !0, a = d, l = !1,
|
|
715
|
+
} else if (p === "[") {
|
|
716
|
+
o = !0, a = d, l = !1, g += p;
|
|
605
717
|
continue;
|
|
606
718
|
}
|
|
607
|
-
if (!
|
|
608
|
-
e.push(
|
|
609
|
-
const S = new E(
|
|
610
|
-
d = E.#h(t, S, d,
|
|
719
|
+
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
720
|
+
e.push(g), g = "";
|
|
721
|
+
const S = new E(p, e);
|
|
722
|
+
d = E.#h(t, S, d, r), e.push(S);
|
|
611
723
|
continue;
|
|
612
724
|
}
|
|
613
|
-
|
|
725
|
+
g += p;
|
|
614
726
|
}
|
|
615
|
-
return e.push(
|
|
727
|
+
return e.push(g), d;
|
|
616
728
|
}
|
|
617
729
|
let h = n + 1, c = new E(null, e);
|
|
618
730
|
const f = [];
|
|
619
731
|
let u = "";
|
|
620
732
|
for (; h < t.length; ) {
|
|
621
733
|
const d = t.charAt(h++);
|
|
622
|
-
if (
|
|
623
|
-
|
|
734
|
+
if (i || d === "\\\\") {
|
|
735
|
+
i = !i, u += d;
|
|
624
736
|
continue;
|
|
625
737
|
}
|
|
626
738
|
if (o) {
|
|
@@ -630,10 +742,10 @@ class E {
|
|
|
630
742
|
o = !0, a = h, l = !1, u += d;
|
|
631
743
|
continue;
|
|
632
744
|
}
|
|
633
|
-
if (
|
|
745
|
+
if (pt(d) && t.charAt(h) === "(") {
|
|
634
746
|
c.push(u), u = "";
|
|
635
|
-
const
|
|
636
|
-
c.push(
|
|
747
|
+
const g = new E(d, c);
|
|
748
|
+
c.push(g), h = E.#h(t, g, h, r);
|
|
637
749
|
continue;
|
|
638
750
|
}
|
|
639
751
|
if (d === "|") {
|
|
@@ -655,17 +767,17 @@ class E {
|
|
|
655
767
|
toMMPattern() {
|
|
656
768
|
if (this !== this.#s)
|
|
657
769
|
return this.#s.toMMPattern();
|
|
658
|
-
const t = this.toString(), [e, n,
|
|
659
|
-
if (!(
|
|
770
|
+
const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
|
|
771
|
+
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
660
772
|
return n;
|
|
661
|
-
const a = (this.#
|
|
773
|
+
const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
662
774
|
return Object.assign(new RegExp(\`^\${e}$\`, a), {
|
|
663
775
|
_src: e,
|
|
664
776
|
_glob: t
|
|
665
777
|
});
|
|
666
778
|
}
|
|
667
779
|
get options() {
|
|
668
|
-
return this.#
|
|
780
|
+
return this.#r;
|
|
669
781
|
}
|
|
670
782
|
// returns the string match, the regexp source, whether there's magic
|
|
671
783
|
// in the regexp (so a regular expression is required) and whether or
|
|
@@ -737,168 +849,168 @@ class E {
|
|
|
737
849
|
// is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
|
|
738
850
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
739
851
|
toRegExpSource(t) {
|
|
740
|
-
const e = t ?? !!this.#
|
|
852
|
+
const e = t ?? !!this.#r.dot;
|
|
741
853
|
if (this.#s === this && this.#d(), !this.type) {
|
|
742
854
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
743
|
-
const [
|
|
744
|
-
return this.#n = this.#n || S, this.#
|
|
855
|
+
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
856
|
+
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
745
857
|
}).join("");
|
|
746
858
|
let c = "";
|
|
747
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
748
|
-
const
|
|
859
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
|
|
860
|
+
const g = Fe, p = (
|
|
749
861
|
// dots are allowed, and the pattern starts with [ or .
|
|
750
|
-
e &&
|
|
751
|
-
h.startsWith("\\\\.") &&
|
|
752
|
-
h.startsWith("\\\\.\\\\.") &&
|
|
753
|
-
), S = !e && !t &&
|
|
754
|
-
c =
|
|
862
|
+
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
863
|
+
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
864
|
+
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
865
|
+
), S = !e && !t && g.has(h.charAt(0));
|
|
866
|
+
c = p ? Ce : S ? _ : "";
|
|
755
867
|
}
|
|
756
868
|
let f = "";
|
|
757
869
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
758
870
|
c + h + f,
|
|
759
|
-
|
|
871
|
+
k(h),
|
|
760
872
|
this.#n = !!this.#n,
|
|
761
|
-
this.#
|
|
873
|
+
this.#i
|
|
762
874
|
];
|
|
763
875
|
}
|
|
764
|
-
const n = this.type === "*" || this.type === "+",
|
|
765
|
-
let
|
|
766
|
-
if (this.isStart() && this.isEnd() && !
|
|
876
|
+
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
877
|
+
let i = this.#f(e);
|
|
878
|
+
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
767
879
|
const l = this.toString();
|
|
768
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
880
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
|
|
769
881
|
}
|
|
770
|
-
let o = !n || t || e || !
|
|
771
|
-
o ===
|
|
882
|
+
let o = !n || t || e || !_ ? "" : this.#f(!0);
|
|
883
|
+
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
772
884
|
let a = "";
|
|
773
885
|
if (this.type === "!" && this.#u)
|
|
774
|
-
a = (this.isStart() && !e ?
|
|
886
|
+
a = (this.isStart() && !e ? _ : "") + wt;
|
|
775
887
|
else {
|
|
776
888
|
const l = this.type === "!" ? (
|
|
777
889
|
// !() must match something,but !(x) can match ''
|
|
778
|
-
"))" + (this.isStart() && !e && !t ?
|
|
890
|
+
"))" + (this.isStart() && !e && !t ? _ : "") + gt + ")"
|
|
779
891
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
780
|
-
a =
|
|
892
|
+
a = r + i + l;
|
|
781
893
|
}
|
|
782
894
|
return [
|
|
783
895
|
a,
|
|
784
|
-
|
|
896
|
+
k(i),
|
|
785
897
|
this.#n = !!this.#n,
|
|
786
|
-
this.#
|
|
898
|
+
this.#i
|
|
787
899
|
];
|
|
788
900
|
}
|
|
789
901
|
#f(t) {
|
|
790
902
|
return this.#t.map((e) => {
|
|
791
903
|
if (typeof e == "string")
|
|
792
904
|
throw new Error("string type in extglob ast??");
|
|
793
|
-
const [n,
|
|
794
|
-
return this.#
|
|
905
|
+
const [n, r, i, o] = e.toRegExpSource(t);
|
|
906
|
+
return this.#i = this.#i || o, n;
|
|
795
907
|
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
796
908
|
}
|
|
797
909
|
static #p(t, e, n = !1) {
|
|
798
|
-
let
|
|
910
|
+
let r = !1, i = "", o = !1;
|
|
799
911
|
for (let a = 0; a < t.length; a++) {
|
|
800
912
|
const l = t.charAt(a);
|
|
801
|
-
if (
|
|
802
|
-
|
|
913
|
+
if (r) {
|
|
914
|
+
r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
|
|
803
915
|
continue;
|
|
804
916
|
}
|
|
805
917
|
if (l === "\\\\") {
|
|
806
|
-
a === t.length - 1 ?
|
|
918
|
+
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
807
919
|
continue;
|
|
808
920
|
}
|
|
809
921
|
if (l === "[") {
|
|
810
|
-
const [h, c, f, u] =
|
|
922
|
+
const [h, c, f, u] = Ae(t, a);
|
|
811
923
|
if (f) {
|
|
812
|
-
|
|
924
|
+
i += h, o = o || c, a += f - 1, e = e || u;
|
|
813
925
|
continue;
|
|
814
926
|
}
|
|
815
927
|
}
|
|
816
928
|
if (l === "*") {
|
|
817
|
-
n && t === "*" ?
|
|
929
|
+
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
818
930
|
continue;
|
|
819
931
|
}
|
|
820
932
|
if (l === "?") {
|
|
821
|
-
|
|
933
|
+
i += ct, e = !0;
|
|
822
934
|
continue;
|
|
823
935
|
}
|
|
824
|
-
|
|
936
|
+
i += Pe(l);
|
|
825
937
|
}
|
|
826
|
-
return [
|
|
938
|
+
return [i, k(t), !!e, o];
|
|
827
939
|
}
|
|
828
940
|
}
|
|
829
|
-
const
|
|
830
|
-
const e =
|
|
941
|
+
const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, 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 = It([s]);
|
|
831
943
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
832
|
-
},
|
|
833
|
-
const e =
|
|
944
|
+
}, Ze = ([s, t = ""]) => {
|
|
945
|
+
const e = kt([s]);
|
|
834
946
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
835
|
-
},
|
|
836
|
-
const e =
|
|
947
|
+
}, Xe = ([s, t = ""]) => {
|
|
948
|
+
const e = kt([s]);
|
|
837
949
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
838
|
-
},
|
|
839
|
-
const e =
|
|
950
|
+
}, Je = ([s, t = ""]) => {
|
|
951
|
+
const e = It([s]);
|
|
840
952
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
841
|
-
},
|
|
953
|
+
}, It = ([s]) => {
|
|
842
954
|
const t = s.length;
|
|
843
955
|
return (e) => e.length === t && !e.startsWith(".");
|
|
844
|
-
},
|
|
956
|
+
}, kt = ([s]) => {
|
|
845
957
|
const t = s.length;
|
|
846
958
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
847
|
-
},
|
|
959
|
+
}, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
848
960
|
win32: { sep: "\\\\" },
|
|
849
961
|
posix: { sep: "/" }
|
|
850
|
-
},
|
|
851
|
-
y.sep =
|
|
852
|
-
const
|
|
853
|
-
y.GLOBSTAR =
|
|
854
|
-
const
|
|
855
|
-
y.filter =
|
|
856
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
962
|
+
}, Qe = Lt === "win32" ? mt.win32.sep : mt.posix.sep;
|
|
963
|
+
y.sep = Qe;
|
|
964
|
+
const O = Symbol("globstar **");
|
|
965
|
+
y.GLOBSTAR = O;
|
|
966
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
|
|
967
|
+
y.filter = ns;
|
|
968
|
+
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
857
969
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
858
970
|
return y;
|
|
859
971
|
const t = y;
|
|
860
|
-
return Object.assign((n,
|
|
972
|
+
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
861
973
|
Minimatch: class extends t.Minimatch {
|
|
862
|
-
constructor(
|
|
863
|
-
super(
|
|
974
|
+
constructor(r, i = {}) {
|
|
975
|
+
super(r, b(s, i));
|
|
864
976
|
}
|
|
865
|
-
static defaults(
|
|
866
|
-
return t.defaults(b(s,
|
|
977
|
+
static defaults(r) {
|
|
978
|
+
return t.defaults(b(s, r)).Minimatch;
|
|
867
979
|
}
|
|
868
980
|
},
|
|
869
981
|
AST: class extends t.AST {
|
|
870
982
|
/* c8 ignore start */
|
|
871
|
-
constructor(
|
|
872
|
-
super(
|
|
983
|
+
constructor(r, i, o = {}) {
|
|
984
|
+
super(r, i, b(s, o));
|
|
873
985
|
}
|
|
874
986
|
/* c8 ignore stop */
|
|
875
|
-
static fromGlob(
|
|
876
|
-
return t.AST.fromGlob(
|
|
987
|
+
static fromGlob(r, i = {}) {
|
|
988
|
+
return t.AST.fromGlob(r, b(s, i));
|
|
877
989
|
}
|
|
878
990
|
},
|
|
879
|
-
unescape: (n,
|
|
880
|
-
escape: (n,
|
|
881
|
-
filter: (n,
|
|
991
|
+
unescape: (n, r = {}) => t.unescape(n, b(s, r)),
|
|
992
|
+
escape: (n, r = {}) => t.escape(n, b(s, r)),
|
|
993
|
+
filter: (n, r = {}) => t.filter(n, b(s, r)),
|
|
882
994
|
defaults: (n) => t.defaults(b(s, n)),
|
|
883
|
-
makeRe: (n,
|
|
884
|
-
braceExpand: (n,
|
|
885
|
-
match: (n,
|
|
995
|
+
makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
|
|
996
|
+
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
997
|
+
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
886
998
|
sep: t.sep,
|
|
887
|
-
GLOBSTAR:
|
|
999
|
+
GLOBSTAR: O
|
|
888
1000
|
});
|
|
889
1001
|
};
|
|
890
|
-
y.defaults =
|
|
891
|
-
const
|
|
892
|
-
y.braceExpand =
|
|
893
|
-
const
|
|
894
|
-
y.makeRe =
|
|
895
|
-
const
|
|
896
|
-
const n = new
|
|
897
|
-
return s = s.filter((
|
|
1002
|
+
y.defaults = rs;
|
|
1003
|
+
const zt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
|
|
1004
|
+
y.braceExpand = zt;
|
|
1005
|
+
const is = (s, t = {}) => new X(s, t).makeRe();
|
|
1006
|
+
y.makeRe = is;
|
|
1007
|
+
const os = (s, t, e = {}) => {
|
|
1008
|
+
const n = new X(t, e);
|
|
1009
|
+
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
898
1010
|
};
|
|
899
|
-
y.match =
|
|
900
|
-
const
|
|
901
|
-
class
|
|
1011
|
+
y.match = os;
|
|
1012
|
+
const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1013
|
+
class X {
|
|
902
1014
|
options;
|
|
903
1015
|
set;
|
|
904
1016
|
pattern;
|
|
@@ -917,7 +1029,7 @@ class q {
|
|
|
917
1029
|
windowsNoMagicRoot;
|
|
918
1030
|
regexp;
|
|
919
1031
|
constructor(t, e = {}) {
|
|
920
|
-
|
|
1032
|
+
Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, 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();
|
|
921
1033
|
}
|
|
922
1034
|
hasMagic() {
|
|
923
1035
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -940,23 +1052,23 @@ class q {
|
|
|
940
1052
|
this.empty = !0;
|
|
941
1053
|
return;
|
|
942
1054
|
}
|
|
943
|
-
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...
|
|
944
|
-
const n = this.globSet.map((
|
|
1055
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1056
|
+
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
945
1057
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
946
|
-
let
|
|
1058
|
+
let r = this.globParts.map((i, o, a) => {
|
|
947
1059
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
948
|
-
const l =
|
|
1060
|
+
const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
949
1061
|
if (l)
|
|
950
|
-
return [...
|
|
1062
|
+
return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
|
|
951
1063
|
if (h)
|
|
952
|
-
return [
|
|
1064
|
+
return [i[0], ...i.slice(1).map((c) => this.parse(c))];
|
|
953
1065
|
}
|
|
954
|
-
return
|
|
1066
|
+
return i.map((l) => this.parse(l));
|
|
955
1067
|
});
|
|
956
|
-
if (this.debug(this.pattern,
|
|
957
|
-
for (let
|
|
958
|
-
const o = this.set[
|
|
959
|
-
o[0] === "" && o[1] === "" && this.globParts[
|
|
1068
|
+
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1069
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1070
|
+
const o = this.set[i];
|
|
1071
|
+
o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
960
1072
|
}
|
|
961
1073
|
this.debug(this.pattern, this.set);
|
|
962
1074
|
}
|
|
@@ -968,8 +1080,8 @@ class q {
|
|
|
968
1080
|
preprocess(t) {
|
|
969
1081
|
if (this.options.noglobstar)
|
|
970
1082
|
for (let n = 0; n < t.length; n++)
|
|
971
|
-
for (let
|
|
972
|
-
t[n][
|
|
1083
|
+
for (let r = 0; r < t[n].length; r++)
|
|
1084
|
+
t[n][r] === "**" && (t[n][r] = "*");
|
|
973
1085
|
const { optimizationLevel: e = 1 } = this.options;
|
|
974
1086
|
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
975
1087
|
}
|
|
@@ -978,19 +1090,19 @@ class q {
|
|
|
978
1090
|
return t.map((e) => {
|
|
979
1091
|
let n = -1;
|
|
980
1092
|
for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
|
|
981
|
-
let
|
|
982
|
-
for (; e[
|
|
983
|
-
|
|
984
|
-
|
|
1093
|
+
let r = n;
|
|
1094
|
+
for (; e[r + 1] === "**"; )
|
|
1095
|
+
r++;
|
|
1096
|
+
r !== n && e.splice(n, r - n);
|
|
985
1097
|
}
|
|
986
1098
|
return e;
|
|
987
1099
|
});
|
|
988
1100
|
}
|
|
989
1101
|
// get rid of adjascent ** and resolve .. portions
|
|
990
1102
|
levelOneOptimize(t) {
|
|
991
|
-
return t.map((e) => (e = e.reduce((n,
|
|
992
|
-
const
|
|
993
|
-
return
|
|
1103
|
+
return t.map((e) => (e = e.reduce((n, r) => {
|
|
1104
|
+
const i = n[n.length - 1];
|
|
1105
|
+
return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
|
|
994
1106
|
}, []), e.length === 0 ? [""] : e));
|
|
995
1107
|
}
|
|
996
1108
|
levelTwoFileOptimize(t) {
|
|
@@ -998,16 +1110,16 @@ class q {
|
|
|
998
1110
|
let e = !1;
|
|
999
1111
|
do {
|
|
1000
1112
|
if (e = !1, !this.preserveMultipleSlashes) {
|
|
1001
|
-
for (let
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1113
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
1114
|
+
const i = t[r];
|
|
1115
|
+
r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
|
|
1004
1116
|
}
|
|
1005
1117
|
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
1006
1118
|
}
|
|
1007
1119
|
let n = 0;
|
|
1008
1120
|
for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1121
|
+
const r = t[n - 1];
|
|
1122
|
+
r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
|
|
1011
1123
|
}
|
|
1012
1124
|
} while (e);
|
|
1013
1125
|
return t.length === 0 ? [""] : t;
|
|
@@ -1035,19 +1147,19 @@ class q {
|
|
|
1035
1147
|
do {
|
|
1036
1148
|
e = !1;
|
|
1037
1149
|
for (let n of t) {
|
|
1038
|
-
let
|
|
1039
|
-
for (; (
|
|
1040
|
-
let o =
|
|
1150
|
+
let r = -1;
|
|
1151
|
+
for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
|
|
1152
|
+
let o = r;
|
|
1041
1153
|
for (; n[o + 1] === "**"; )
|
|
1042
1154
|
o++;
|
|
1043
|
-
o >
|
|
1044
|
-
let a = n[
|
|
1045
|
-
const l = n[
|
|
1155
|
+
o > r && n.splice(r + 1, o - r);
|
|
1156
|
+
let a = n[r + 1];
|
|
1157
|
+
const l = n[r + 2], h = n[r + 3];
|
|
1046
1158
|
if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
|
|
1047
1159
|
continue;
|
|
1048
|
-
e = !0, n.splice(
|
|
1160
|
+
e = !0, n.splice(r, 1);
|
|
1049
1161
|
const c = n.slice(0);
|
|
1050
|
-
c[
|
|
1162
|
+
c[r] = "**", t.push(c), r--;
|
|
1051
1163
|
}
|
|
1052
1164
|
if (!this.preserveMultipleSlashes) {
|
|
1053
1165
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1056,13 +1168,13 @@ class q {
|
|
|
1056
1168
|
}
|
|
1057
1169
|
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
|
|
1058
1170
|
}
|
|
1059
|
-
let
|
|
1060
|
-
for (; (
|
|
1061
|
-
const o = n[
|
|
1171
|
+
let i = 0;
|
|
1172
|
+
for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
|
|
1173
|
+
const o = n[i - 1];
|
|
1062
1174
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1063
1175
|
e = !0;
|
|
1064
|
-
const l =
|
|
1065
|
-
n.splice(
|
|
1176
|
+
const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1177
|
+
n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
|
|
1066
1178
|
}
|
|
1067
1179
|
}
|
|
1068
1180
|
}
|
|
@@ -1079,31 +1191,31 @@ class q {
|
|
|
1079
1191
|
secondPhasePreProcess(t) {
|
|
1080
1192
|
for (let e = 0; e < t.length - 1; e++)
|
|
1081
1193
|
for (let n = e + 1; n < t.length; n++) {
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
t[e] = [], t[n] =
|
|
1194
|
+
const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
|
|
1195
|
+
if (r) {
|
|
1196
|
+
t[e] = [], t[n] = r;
|
|
1085
1197
|
break;
|
|
1086
1198
|
}
|
|
1087
1199
|
}
|
|
1088
1200
|
return t.filter((e) => e.length);
|
|
1089
1201
|
}
|
|
1090
1202
|
partsMatch(t, e, n = !1) {
|
|
1091
|
-
let
|
|
1092
|
-
for (;
|
|
1093
|
-
if (t[
|
|
1094
|
-
o.push(a === "b" ? e[
|
|
1095
|
-
else if (n && t[
|
|
1096
|
-
o.push(t[
|
|
1097
|
-
else if (n && e[
|
|
1098
|
-
o.push(e[
|
|
1099
|
-
else if (t[
|
|
1203
|
+
let r = 0, i = 0, o = [], a = "";
|
|
1204
|
+
for (; r < t.length && i < e.length; )
|
|
1205
|
+
if (t[r] === e[i])
|
|
1206
|
+
o.push(a === "b" ? e[i] : t[r]), r++, i++;
|
|
1207
|
+
else if (n && t[r] === "**" && e[i] === t[r + 1])
|
|
1208
|
+
o.push(t[r]), r++;
|
|
1209
|
+
else if (n && e[i] === "**" && t[r] === e[i + 1])
|
|
1210
|
+
o.push(e[i]), i++;
|
|
1211
|
+
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1100
1212
|
if (a === "b")
|
|
1101
1213
|
return !1;
|
|
1102
|
-
a = "a", o.push(t[
|
|
1103
|
-
} else if (e[
|
|
1214
|
+
a = "a", o.push(t[r]), r++, i++;
|
|
1215
|
+
} else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
|
|
1104
1216
|
if (a === "a")
|
|
1105
1217
|
return !1;
|
|
1106
|
-
a = "b", o.push(e[
|
|
1218
|
+
a = "b", o.push(e[i]), r++, i++;
|
|
1107
1219
|
} else
|
|
1108
1220
|
return !1;
|
|
1109
1221
|
return t.length === e.length && o;
|
|
@@ -1113,7 +1225,7 @@ class q {
|
|
|
1113
1225
|
return;
|
|
1114
1226
|
const t = this.pattern;
|
|
1115
1227
|
let e = !1, n = 0;
|
|
1116
|
-
for (let
|
|
1228
|
+
for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
|
|
1117
1229
|
e = !e, n++;
|
|
1118
1230
|
n && (this.pattern = t.slice(n)), this.negate = e;
|
|
1119
1231
|
}
|
|
@@ -1123,36 +1235,36 @@ class q {
|
|
|
1123
1235
|
// out of pattern, then that's fine, as long as all
|
|
1124
1236
|
// the parts match.
|
|
1125
1237
|
matchOne(t, e, n = !1) {
|
|
1126
|
-
const
|
|
1238
|
+
const r = this.options;
|
|
1127
1239
|
if (this.isWindows) {
|
|
1128
|
-
const
|
|
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]), P = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = P ? 3 : v ? 0 : void 0;
|
|
1129
1241
|
if (typeof x == "number" && typeof m == "number") {
|
|
1130
|
-
const [
|
|
1131
|
-
|
|
1242
|
+
const [T, H] = [t[x], e[m]];
|
|
1243
|
+
T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1132
1244
|
}
|
|
1133
1245
|
}
|
|
1134
|
-
const { optimizationLevel:
|
|
1135
|
-
|
|
1246
|
+
const { optimizationLevel: i = 1 } = this.options;
|
|
1247
|
+
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1136
1248
|
for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
|
|
1137
1249
|
this.debug("matchOne loop");
|
|
1138
1250
|
var c = e[a], f = t[o];
|
|
1139
1251
|
if (this.debug(e, c, f), c === !1)
|
|
1140
1252
|
return !1;
|
|
1141
|
-
if (c ===
|
|
1253
|
+
if (c === O) {
|
|
1142
1254
|
this.debug("GLOBSTAR", [e, c, f]);
|
|
1143
1255
|
var u = o, d = a + 1;
|
|
1144
1256
|
if (d === h) {
|
|
1145
1257
|
for (this.debug("** at the end"); o < l; o++)
|
|
1146
|
-
if (t[o] === "." || t[o] === ".." || !
|
|
1258
|
+
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1147
1259
|
return !1;
|
|
1148
1260
|
return !0;
|
|
1149
1261
|
}
|
|
1150
1262
|
for (; u < l; ) {
|
|
1151
|
-
var
|
|
1263
|
+
var g = t[u];
|
|
1152
1264
|
if (this.debug(\`
|
|
1153
|
-
globstar while\`, t, u, e, d,
|
|
1154
|
-
return this.debug("globstar found match!", u, l,
|
|
1155
|
-
if (
|
|
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, l, g), !0;
|
|
1267
|
+
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1156
1268
|
this.debug("dot detected!", t, u, e, d);
|
|
1157
1269
|
break;
|
|
1158
1270
|
}
|
|
@@ -1161,8 +1273,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1161
1273
|
return !!(n && (this.debug(\`
|
|
1162
1274
|
>>> no match, partial?\`, t, u, e, d), u === l));
|
|
1163
1275
|
}
|
|
1164
|
-
let
|
|
1165
|
-
if (typeof c == "string" ? (
|
|
1276
|
+
let p;
|
|
1277
|
+
if (typeof c == "string" ? (p = f === c, this.debug("string match", c, f, p)) : (p = c.test(f), this.debug("pattern match", c, f, p)), !p)
|
|
1166
1278
|
return !1;
|
|
1167
1279
|
}
|
|
1168
1280
|
if (o === l && a === h)
|
|
@@ -1174,19 +1286,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1174
1286
|
throw new Error("wtf?");
|
|
1175
1287
|
}
|
|
1176
1288
|
braceExpand() {
|
|
1177
|
-
return
|
|
1289
|
+
return zt(this.pattern, this.options);
|
|
1178
1290
|
}
|
|
1179
1291
|
parse(t) {
|
|
1180
|
-
|
|
1292
|
+
Z(t);
|
|
1181
1293
|
const e = this.options;
|
|
1182
1294
|
if (t === "**")
|
|
1183
|
-
return
|
|
1295
|
+
return O;
|
|
1184
1296
|
if (t === "")
|
|
1185
1297
|
return "";
|
|
1186
|
-
let n,
|
|
1187
|
-
(n = t.match(
|
|
1188
|
-
const
|
|
1189
|
-
return
|
|
1298
|
+
let n, r = null;
|
|
1299
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
|
|
1300
|
+
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1301
|
+
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1190
1302
|
}
|
|
1191
1303
|
makeRe() {
|
|
1192
1304
|
if (this.regexp || this.regexp === !1)
|
|
@@ -1194,23 +1306,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1194
1306
|
const t = this.set;
|
|
1195
1307
|
if (!t.length)
|
|
1196
1308
|
return this.regexp = !1, this.regexp;
|
|
1197
|
-
const e = this.options, n = e.noglobstar ?
|
|
1198
|
-
let
|
|
1309
|
+
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1310
|
+
let i = t.map((l) => {
|
|
1199
1311
|
const h = l.map((c) => {
|
|
1200
1312
|
if (c instanceof RegExp)
|
|
1201
1313
|
for (const f of c.flags.split(""))
|
|
1202
|
-
|
|
1203
|
-
return typeof c == "string" ?
|
|
1314
|
+
r.add(f);
|
|
1315
|
+
return typeof c == "string" ? as(c) : c === O ? O : c._src;
|
|
1204
1316
|
});
|
|
1205
1317
|
return h.forEach((c, f) => {
|
|
1206
1318
|
const u = h[f + 1], d = h[f - 1];
|
|
1207
|
-
c !==
|
|
1208
|
-
}), h.filter((c) => c !==
|
|
1319
|
+
c !== O || d === O || (d === void 0 ? u !== void 0 && u !== O ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== O && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = O));
|
|
1320
|
+
}), h.filter((c) => c !== O).join("/");
|
|
1209
1321
|
}).join("|");
|
|
1210
1322
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1211
|
-
|
|
1323
|
+
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1212
1324
|
try {
|
|
1213
|
-
this.regexp = new RegExp(
|
|
1325
|
+
this.regexp = new RegExp(i, [...r].join(""));
|
|
1214
1326
|
} catch {
|
|
1215
1327
|
this.regexp = !1;
|
|
1216
1328
|
}
|
|
@@ -1228,17 +1340,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1228
1340
|
return !0;
|
|
1229
1341
|
const n = this.options;
|
|
1230
1342
|
this.isWindows && (t = t.split("\\\\").join("/"));
|
|
1231
|
-
const
|
|
1232
|
-
this.debug(this.pattern, "split",
|
|
1233
|
-
const
|
|
1234
|
-
this.debug(this.pattern, "set",
|
|
1235
|
-
let o =
|
|
1343
|
+
const r = this.slashSplit(t);
|
|
1344
|
+
this.debug(this.pattern, "split", r);
|
|
1345
|
+
const i = this.set;
|
|
1346
|
+
this.debug(this.pattern, "set", i);
|
|
1347
|
+
let o = r[r.length - 1];
|
|
1236
1348
|
if (!o)
|
|
1237
|
-
for (let a =
|
|
1238
|
-
o =
|
|
1239
|
-
for (let a = 0; a <
|
|
1240
|
-
const l =
|
|
1241
|
-
let h =
|
|
1349
|
+
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1350
|
+
o = r[a];
|
|
1351
|
+
for (let a = 0; a < i.length; a++) {
|
|
1352
|
+
const l = i[a];
|
|
1353
|
+
let h = r;
|
|
1242
1354
|
if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
|
|
1243
1355
|
return n.flipNegate ? !0 : !this.negate;
|
|
1244
1356
|
}
|
|
@@ -1249,109 +1361,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1249
1361
|
}
|
|
1250
1362
|
}
|
|
1251
1363
|
y.AST = E;
|
|
1252
|
-
y.Minimatch =
|
|
1253
|
-
y.escape =
|
|
1254
|
-
y.unescape =
|
|
1255
|
-
function
|
|
1364
|
+
y.Minimatch = X;
|
|
1365
|
+
y.escape = Te;
|
|
1366
|
+
y.unescape = k;
|
|
1367
|
+
function cs() {
|
|
1256
1368
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1257
|
-
throw new
|
|
1369
|
+
throw new Qt();
|
|
1258
1370
|
}
|
|
1259
|
-
async function
|
|
1371
|
+
async function L(s, t, e) {
|
|
1260
1372
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1261
1373
|
}
|
|
1262
|
-
function
|
|
1374
|
+
function M(s) {
|
|
1263
1375
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1264
1376
|
}
|
|
1265
|
-
function
|
|
1377
|
+
function lt(s) {
|
|
1266
1378
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1267
1379
|
}
|
|
1268
|
-
function
|
|
1269
|
-
const t =
|
|
1380
|
+
function it(s) {
|
|
1381
|
+
const t = M(s);
|
|
1270
1382
|
return t[t.length - 1] || "";
|
|
1271
1383
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const t =
|
|
1274
|
-
return t.pop(),
|
|
1384
|
+
function et(s) {
|
|
1385
|
+
const t = M(s);
|
|
1386
|
+
return t.pop(), lt(t);
|
|
1275
1387
|
}
|
|
1276
|
-
function
|
|
1388
|
+
function G(s) {
|
|
1277
1389
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1278
1390
|
}
|
|
1279
|
-
function
|
|
1391
|
+
function ls(s, t = !1) {
|
|
1280
1392
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1281
1393
|
}
|
|
1282
|
-
function
|
|
1394
|
+
function st(s, t) {
|
|
1283
1395
|
return y(s, t, {
|
|
1284
1396
|
dot: !0,
|
|
1285
1397
|
matchBase: !0
|
|
1286
1398
|
});
|
|
1287
1399
|
}
|
|
1288
|
-
function
|
|
1289
|
-
const t =
|
|
1290
|
-
for (const
|
|
1291
|
-
if (!(
|
|
1292
|
-
if (
|
|
1400
|
+
function Et(s) {
|
|
1401
|
+
const t = G(s), e = M(t), n = [];
|
|
1402
|
+
for (const r of e)
|
|
1403
|
+
if (!(r === "." || r === ""))
|
|
1404
|
+
if (r === "..") {
|
|
1293
1405
|
if (n.length === 0)
|
|
1294
1406
|
continue;
|
|
1295
1407
|
n.pop();
|
|
1296
1408
|
} else
|
|
1297
|
-
n.push(
|
|
1298
|
-
return
|
|
1409
|
+
n.push(r);
|
|
1410
|
+
return lt(n);
|
|
1299
1411
|
}
|
|
1300
|
-
async function
|
|
1412
|
+
async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1301
1413
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1302
1414
|
throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
|
|
1303
|
-
const n = new Uint8Array(s),
|
|
1304
|
-
return Array.from(new Uint8Array(
|
|
1415
|
+
const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
|
|
1416
|
+
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1305
1417
|
}
|
|
1306
|
-
async function
|
|
1418
|
+
async function us(s) {
|
|
1307
1419
|
const t = await s.arrayBuffer();
|
|
1308
1420
|
return new Uint8Array(t);
|
|
1309
1421
|
}
|
|
1310
|
-
async function
|
|
1311
|
-
const n =
|
|
1312
|
-
return
|
|
1313
|
-
const
|
|
1422
|
+
async function fs(s, t, e = {}) {
|
|
1423
|
+
const n = it(t);
|
|
1424
|
+
return L(t, "exclusive", async () => {
|
|
1425
|
+
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1314
1426
|
try {
|
|
1315
|
-
await s.removeEntry(n, { recursive:
|
|
1427
|
+
await s.removeEntry(n, { recursive: r });
|
|
1316
1428
|
} catch (o) {
|
|
1317
1429
|
if (o.name === "NotFoundError") {
|
|
1318
|
-
if (!
|
|
1319
|
-
throw new
|
|
1320
|
-
} else throw o.name === "InvalidModificationError" ? new
|
|
1430
|
+
if (!i)
|
|
1431
|
+
throw new F("file", t, o);
|
|
1432
|
+
} else throw o.name === "InvalidModificationError" ? new rt("ENOTEMPTY", t, o) : o.name === "TypeMismatchError" && !r ? new z("directory", t, o) : new rt("RM_FAILED", t, o);
|
|
1321
1433
|
}
|
|
1322
1434
|
});
|
|
1323
1435
|
}
|
|
1324
|
-
function
|
|
1436
|
+
function St(s, t, e, n) {
|
|
1325
1437
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1326
|
-
throw new
|
|
1438
|
+
throw new N("argument", "Invalid offset or length");
|
|
1327
1439
|
if (t < 0 || e < 0)
|
|
1328
|
-
throw new
|
|
1440
|
+
throw new N("argument", "Negative offset or length not allowed");
|
|
1329
1441
|
if (t + e > s)
|
|
1330
|
-
throw new
|
|
1442
|
+
throw new N("overflow", "Operation would overflow buffer");
|
|
1331
1443
|
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1332
|
-
throw new
|
|
1444
|
+
throw new N("argument", "Invalid position");
|
|
1333
1445
|
}
|
|
1334
|
-
function
|
|
1446
|
+
function xt(s, t, e) {
|
|
1335
1447
|
try {
|
|
1336
1448
|
t.flush(), t.close();
|
|
1337
1449
|
} catch (n) {
|
|
1338
1450
|
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1339
1451
|
}
|
|
1340
1452
|
}
|
|
1341
|
-
function
|
|
1453
|
+
function ds(s, t, e) {
|
|
1342
1454
|
if (s >= e)
|
|
1343
1455
|
return { isEOF: !0, actualLength: 0 };
|
|
1344
1456
|
const n = Math.min(t, e - s);
|
|
1345
1457
|
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1346
1458
|
}
|
|
1347
|
-
async function
|
|
1459
|
+
async function ps(s, t) {
|
|
1348
1460
|
try {
|
|
1349
1461
|
return await s.createSyncAccessHandle();
|
|
1350
1462
|
} catch (e) {
|
|
1351
|
-
throw
|
|
1463
|
+
throw A(e, { path: t, isDirectory: !1 });
|
|
1352
1464
|
}
|
|
1353
1465
|
}
|
|
1354
|
-
class
|
|
1466
|
+
class gs {
|
|
1355
1467
|
/** Root directory handle for the file system */
|
|
1356
1468
|
root;
|
|
1357
1469
|
/** Map of watched paths and options */
|
|
@@ -1379,7 +1491,7 @@ class ss {
|
|
|
1379
1491
|
_getFileDescriptor(t) {
|
|
1380
1492
|
const e = this.openFiles.get(t);
|
|
1381
1493
|
if (!e)
|
|
1382
|
-
throw new
|
|
1494
|
+
throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
|
|
1383
1495
|
return e;
|
|
1384
1496
|
}
|
|
1385
1497
|
/**
|
|
@@ -1395,25 +1507,25 @@ class ss {
|
|
|
1395
1507
|
if (!this.options.broadcastChannel)
|
|
1396
1508
|
return;
|
|
1397
1509
|
const e = t.path;
|
|
1398
|
-
if (![...this.watchers.values()].some((
|
|
1510
|
+
if (![...this.watchers.values()].some((i) => st(e, i.pattern) && i.include.some((o) => o && st(e, o)) && !i.exclude.some((o) => o && st(e, o))))
|
|
1399
1511
|
return;
|
|
1400
|
-
let
|
|
1512
|
+
let r;
|
|
1401
1513
|
if (this.options.hashAlgorithm)
|
|
1402
1514
|
try {
|
|
1403
|
-
|
|
1515
|
+
r = (await this.stat(e)).hash;
|
|
1404
1516
|
} catch {
|
|
1405
1517
|
}
|
|
1406
1518
|
try {
|
|
1407
1519
|
this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
|
|
1408
|
-
const
|
|
1520
|
+
const i = {
|
|
1409
1521
|
namespace: this.options.namespace,
|
|
1410
1522
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1411
1523
|
...t,
|
|
1412
|
-
...
|
|
1524
|
+
...r && { hash: r }
|
|
1413
1525
|
};
|
|
1414
|
-
this.broadcastChannel.postMessage(
|
|
1415
|
-
} catch (
|
|
1416
|
-
console.warn("Failed to send event via BroadcastChannel:",
|
|
1526
|
+
this.broadcastChannel.postMessage(i);
|
|
1527
|
+
} catch (i) {
|
|
1528
|
+
console.warn("Failed to send event via BroadcastChannel:", i);
|
|
1417
1529
|
}
|
|
1418
1530
|
}
|
|
1419
1531
|
/**
|
|
@@ -1427,7 +1539,7 @@ class ss {
|
|
|
1427
1539
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1428
1540
|
*/
|
|
1429
1541
|
constructor(t) {
|
|
1430
|
-
|
|
1542
|
+
cs(), t && this.setOptions(t);
|
|
1431
1543
|
}
|
|
1432
1544
|
/**
|
|
1433
1545
|
* Initialize the file system within a given directory
|
|
@@ -1454,10 +1566,10 @@ class ss {
|
|
|
1454
1566
|
const t = this.options.root;
|
|
1455
1567
|
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
|
|
1456
1568
|
try {
|
|
1457
|
-
const
|
|
1458
|
-
this.root = t === "/" ?
|
|
1459
|
-
} catch (
|
|
1460
|
-
n(new
|
|
1569
|
+
const r = await navigator.storage.getDirectory();
|
|
1570
|
+
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1571
|
+
} catch (r) {
|
|
1572
|
+
n(new re(t, r));
|
|
1461
1573
|
} finally {
|
|
1462
1574
|
this.mountingPromise = null;
|
|
1463
1575
|
}
|
|
@@ -1474,7 +1586,7 @@ class ss {
|
|
|
1474
1586
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1475
1587
|
*/
|
|
1476
1588
|
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 =
|
|
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 = G(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1478
1590
|
}
|
|
1479
1591
|
/**
|
|
1480
1592
|
* Get a directory handle from a path
|
|
@@ -1495,11 +1607,11 @@ class ss {
|
|
|
1495
1607
|
* \`\`\`
|
|
1496
1608
|
*/
|
|
1497
1609
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1498
|
-
const
|
|
1499
|
-
let
|
|
1500
|
-
for (const o of
|
|
1501
|
-
|
|
1502
|
-
return
|
|
1610
|
+
const r = Array.isArray(t) ? t : M(t);
|
|
1611
|
+
let i = n;
|
|
1612
|
+
for (const o of r)
|
|
1613
|
+
i = await i.getDirectoryHandle(o, { create: e });
|
|
1614
|
+
return i;
|
|
1503
1615
|
}
|
|
1504
1616
|
/**
|
|
1505
1617
|
* Get a file handle from a path
|
|
@@ -1521,11 +1633,11 @@ class ss {
|
|
|
1521
1633
|
* \`\`\`
|
|
1522
1634
|
*/
|
|
1523
1635
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1524
|
-
const
|
|
1525
|
-
if (
|
|
1526
|
-
throw new
|
|
1527
|
-
const
|
|
1528
|
-
return (await this.getDirectoryHandle(
|
|
1636
|
+
const r = M(t);
|
|
1637
|
+
if (r.length === 0)
|
|
1638
|
+
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1639
|
+
const i = r.pop();
|
|
1640
|
+
return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
|
|
1529
1641
|
}
|
|
1530
1642
|
/**
|
|
1531
1643
|
* Get a complete index of all files and directories in the file system
|
|
@@ -1548,9 +1660,9 @@ class ss {
|
|
|
1548
1660
|
*/
|
|
1549
1661
|
async index() {
|
|
1550
1662
|
const t = /* @__PURE__ */ new Map(), e = async (n) => {
|
|
1551
|
-
const
|
|
1552
|
-
for (const
|
|
1553
|
-
const o = \`\${n === "/" ? "" : n}/\${
|
|
1663
|
+
const r = await this.readDir(n);
|
|
1664
|
+
for (const i of r) {
|
|
1665
|
+
const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
|
|
1554
1666
|
try {
|
|
1555
1667
|
const a = await this.stat(o);
|
|
1556
1668
|
t.set(o, a), a.isDirectory && await e(o);
|
|
@@ -1590,17 +1702,17 @@ class ss {
|
|
|
1590
1702
|
async readFile(t) {
|
|
1591
1703
|
await this.mount();
|
|
1592
1704
|
try {
|
|
1593
|
-
return await
|
|
1705
|
+
return await L(t, "shared", async () => {
|
|
1594
1706
|
const e = await this.open(t);
|
|
1595
1707
|
try {
|
|
1596
|
-
const { size: n } = await this.fstat(e),
|
|
1597
|
-
return n > 0 && await this.read(e,
|
|
1708
|
+
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1709
|
+
return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
|
|
1598
1710
|
} finally {
|
|
1599
1711
|
await this.close(e);
|
|
1600
1712
|
}
|
|
1601
1713
|
});
|
|
1602
1714
|
} catch (e) {
|
|
1603
|
-
throw new
|
|
1715
|
+
throw new F("file", t, e);
|
|
1604
1716
|
}
|
|
1605
1717
|
}
|
|
1606
1718
|
/**
|
|
@@ -1628,14 +1740,14 @@ class ss {
|
|
|
1628
1740
|
async writeFile(t, e) {
|
|
1629
1741
|
await this.mount();
|
|
1630
1742
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1631
|
-
await
|
|
1632
|
-
const
|
|
1743
|
+
await L(t, "exclusive", async () => {
|
|
1744
|
+
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1633
1745
|
try {
|
|
1634
|
-
await this.write(
|
|
1746
|
+
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1635
1747
|
} finally {
|
|
1636
|
-
await this.close(
|
|
1748
|
+
await this.close(i);
|
|
1637
1749
|
}
|
|
1638
|
-
await this.notifyChange({ path: t, type:
|
|
1750
|
+
await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
|
|
1639
1751
|
});
|
|
1640
1752
|
}
|
|
1641
1753
|
/**
|
|
@@ -1663,15 +1775,15 @@ class ss {
|
|
|
1663
1775
|
async appendFile(t, e) {
|
|
1664
1776
|
await this.mount();
|
|
1665
1777
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1666
|
-
await
|
|
1667
|
-
const
|
|
1778
|
+
await L(t, "exclusive", async () => {
|
|
1779
|
+
const r = await this.open(t, { create: !0 });
|
|
1668
1780
|
try {
|
|
1669
|
-
const { size:
|
|
1670
|
-
await this.write(
|
|
1781
|
+
const { size: i } = await this.fstat(r);
|
|
1782
|
+
await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
|
|
1671
1783
|
} finally {
|
|
1672
|
-
await this.close(
|
|
1784
|
+
await this.close(r);
|
|
1673
1785
|
}
|
|
1674
|
-
await this.notifyChange({ path: t, type:
|
|
1786
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
|
|
1675
1787
|
});
|
|
1676
1788
|
}
|
|
1677
1789
|
/**
|
|
@@ -1697,22 +1809,17 @@ class ss {
|
|
|
1697
1809
|
*/
|
|
1698
1810
|
async mkdir(t, e) {
|
|
1699
1811
|
await this.mount();
|
|
1700
|
-
const n = e?.recursive ?? !1,
|
|
1701
|
-
let
|
|
1702
|
-
for (let o = 0; o <
|
|
1703
|
-
const a =
|
|
1812
|
+
const n = e?.recursive ?? !1, r = M(t);
|
|
1813
|
+
let i = this.root;
|
|
1814
|
+
for (let o = 0; o < r.length; o++) {
|
|
1815
|
+
const a = r[o];
|
|
1704
1816
|
try {
|
|
1705
|
-
|
|
1817
|
+
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1706
1818
|
} catch (l) {
|
|
1707
|
-
throw l.name === "NotFoundError" ? new
|
|
1708
|
-
\`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
|
|
1709
|
-
"ENOENT",
|
|
1710
|
-
void 0,
|
|
1711
|
-
l
|
|
1712
|
-
) : 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);
|
|
1819
|
+
throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new z("file", a, l) : new Q("create directory", a, l);
|
|
1713
1820
|
}
|
|
1714
1821
|
}
|
|
1715
|
-
await this.notifyChange({ path: t, type:
|
|
1822
|
+
await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
|
|
1716
1823
|
}
|
|
1717
1824
|
/**
|
|
1718
1825
|
* Get file or directory statistics
|
|
@@ -1746,9 +1853,11 @@ class ss {
|
|
|
1746
1853
|
isFile: !1,
|
|
1747
1854
|
isDirectory: !0
|
|
1748
1855
|
};
|
|
1749
|
-
const e =
|
|
1856
|
+
const e = it(t);
|
|
1857
|
+
let n;
|
|
1750
1858
|
try {
|
|
1751
|
-
|
|
1859
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1860
|
+
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1752
1861
|
kind: "file",
|
|
1753
1862
|
size: o.size,
|
|
1754
1863
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1756,19 +1865,21 @@ class ss {
|
|
|
1756
1865
|
isFile: !0,
|
|
1757
1866
|
isDirectory: !1
|
|
1758
1867
|
};
|
|
1759
|
-
if (
|
|
1868
|
+
if (r === "etag")
|
|
1760
1869
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1761
|
-
else if (typeof
|
|
1870
|
+
else if (typeof r == "string")
|
|
1762
1871
|
try {
|
|
1763
|
-
const l = await
|
|
1872
|
+
const l = await hs(o, r, this.options.maxFileSize);
|
|
1764
1873
|
a.hash = l;
|
|
1765
1874
|
} catch (l) {
|
|
1766
1875
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
1767
1876
|
}
|
|
1768
1877
|
return a;
|
|
1769
1878
|
} catch (r) {
|
|
1770
|
-
if (r.name
|
|
1771
|
-
throw new
|
|
1879
|
+
if (r.name === "NotFoundError")
|
|
1880
|
+
throw new F("file", t, r);
|
|
1881
|
+
if (r.name !== "TypeMismatchError")
|
|
1882
|
+
throw new Q("stat", t, r);
|
|
1772
1883
|
}
|
|
1773
1884
|
try {
|
|
1774
1885
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1780,7 +1891,7 @@ class ss {
|
|
|
1780
1891
|
isDirectory: !0
|
|
1781
1892
|
};
|
|
1782
1893
|
} catch (r) {
|
|
1783
|
-
throw
|
|
1894
|
+
throw new Q("stat", t, r);
|
|
1784
1895
|
}
|
|
1785
1896
|
}
|
|
1786
1897
|
/**
|
|
@@ -1804,11 +1915,11 @@ class ss {
|
|
|
1804
1915
|
async readDir(t) {
|
|
1805
1916
|
await this.mount();
|
|
1806
1917
|
const e = await this.getDirectoryHandle(t, !1), n = [];
|
|
1807
|
-
for await (const [
|
|
1808
|
-
const o =
|
|
1918
|
+
for await (const [r, i] of e.entries()) {
|
|
1919
|
+
const o = i.kind === "file";
|
|
1809
1920
|
n.push({
|
|
1810
|
-
name:
|
|
1811
|
-
kind:
|
|
1921
|
+
name: r,
|
|
1922
|
+
kind: i.kind,
|
|
1812
1923
|
isFile: o,
|
|
1813
1924
|
isDirectory: !o
|
|
1814
1925
|
});
|
|
@@ -1832,26 +1943,26 @@ class ss {
|
|
|
1832
1943
|
async exists(t) {
|
|
1833
1944
|
if (await this.mount(), t === "/")
|
|
1834
1945
|
return !0;
|
|
1835
|
-
const e =
|
|
1946
|
+
const e = it(t);
|
|
1836
1947
|
let n = null;
|
|
1837
1948
|
try {
|
|
1838
|
-
n = await this.getDirectoryHandle(
|
|
1839
|
-
} catch (
|
|
1840
|
-
if (n = null,
|
|
1841
|
-
throw
|
|
1949
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1950
|
+
} catch (r) {
|
|
1951
|
+
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1952
|
+
throw r;
|
|
1842
1953
|
}
|
|
1843
1954
|
if (!n || !e)
|
|
1844
1955
|
return !1;
|
|
1845
1956
|
try {
|
|
1846
1957
|
return await n.getFileHandle(e, { create: !1 }), !0;
|
|
1847
|
-
} catch (
|
|
1848
|
-
if (
|
|
1849
|
-
throw
|
|
1958
|
+
} catch (r) {
|
|
1959
|
+
if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1960
|
+
throw r;
|
|
1850
1961
|
try {
|
|
1851
1962
|
return await n.getDirectoryHandle(e, { create: !1 }), !0;
|
|
1852
|
-
} catch (
|
|
1853
|
-
if (
|
|
1854
|
-
throw
|
|
1963
|
+
} catch (i) {
|
|
1964
|
+
if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1965
|
+
throw i;
|
|
1855
1966
|
return !1;
|
|
1856
1967
|
}
|
|
1857
1968
|
}
|
|
@@ -1880,12 +1991,12 @@ class ss {
|
|
|
1880
1991
|
try {
|
|
1881
1992
|
const e = await this.readDir(t);
|
|
1882
1993
|
for (const n of e) {
|
|
1883
|
-
const
|
|
1884
|
-
await this.remove(
|
|
1994
|
+
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1995
|
+
await this.remove(r, { recursive: !0 });
|
|
1885
1996
|
}
|
|
1886
|
-
await this.notifyChange({ path: t, type:
|
|
1997
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
|
|
1887
1998
|
} catch (e) {
|
|
1888
|
-
throw e instanceof
|
|
1999
|
+
throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
|
|
1889
2000
|
}
|
|
1890
2001
|
}
|
|
1891
2002
|
/**
|
|
@@ -1914,9 +2025,9 @@ class ss {
|
|
|
1914
2025
|
*/
|
|
1915
2026
|
async remove(t, e) {
|
|
1916
2027
|
if (await this.mount(), t === "/")
|
|
1917
|
-
throw new
|
|
1918
|
-
const { recursive: n = !1, force:
|
|
1919
|
-
await
|
|
2028
|
+
throw new rt("EROOT", t);
|
|
2029
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
|
|
2030
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
|
|
1920
2031
|
}
|
|
1921
2032
|
/**
|
|
1922
2033
|
* Resolve a path to an absolute path
|
|
@@ -1939,12 +2050,12 @@ class ss {
|
|
|
1939
2050
|
async realpath(t) {
|
|
1940
2051
|
await this.mount();
|
|
1941
2052
|
try {
|
|
1942
|
-
const e =
|
|
2053
|
+
const e = Et(t);
|
|
1943
2054
|
if (!await this.exists(e))
|
|
1944
|
-
throw new
|
|
2055
|
+
throw new F("file", e);
|
|
1945
2056
|
return e;
|
|
1946
2057
|
} catch (e) {
|
|
1947
|
-
throw e instanceof
|
|
2058
|
+
throw e instanceof w ? e : A(e, { path: t });
|
|
1948
2059
|
}
|
|
1949
2060
|
}
|
|
1950
2061
|
/**
|
|
@@ -1972,12 +2083,12 @@ class ss {
|
|
|
1972
2083
|
async rename(t, e, n) {
|
|
1973
2084
|
await this.mount();
|
|
1974
2085
|
try {
|
|
1975
|
-
const
|
|
1976
|
-
if (await this.exists(e) && !
|
|
1977
|
-
throw new
|
|
1978
|
-
await this.copy(t, e, { recursive: !0, overwrite:
|
|
1979
|
-
} catch (
|
|
1980
|
-
throw
|
|
2086
|
+
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2087
|
+
if (await this.exists(e) && !r)
|
|
2088
|
+
throw new K(e);
|
|
2089
|
+
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
|
|
2090
|
+
} catch (r) {
|
|
2091
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
1981
2092
|
}
|
|
1982
2093
|
}
|
|
1983
2094
|
/**
|
|
@@ -2008,26 +2119,26 @@ class ss {
|
|
|
2008
2119
|
async copy(t, e, n) {
|
|
2009
2120
|
await this.mount();
|
|
2010
2121
|
try {
|
|
2011
|
-
const
|
|
2122
|
+
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2012
2123
|
if (!await this.exists(t))
|
|
2013
|
-
throw new
|
|
2014
|
-
if (await this.exists(e) && !
|
|
2015
|
-
throw new
|
|
2124
|
+
throw new F("source", t);
|
|
2125
|
+
if (await this.exists(e) && !i)
|
|
2126
|
+
throw new K(e);
|
|
2016
2127
|
if ((await this.stat(t)).isFile) {
|
|
2017
2128
|
const h = await this.readFile(t);
|
|
2018
2129
|
await this.writeFile(e, h);
|
|
2019
2130
|
} else {
|
|
2020
|
-
if (!
|
|
2021
|
-
throw new
|
|
2131
|
+
if (!r)
|
|
2132
|
+
throw new z("directory", t);
|
|
2022
2133
|
await this.mkdir(e, { recursive: !0 });
|
|
2023
2134
|
const h = await this.readDir(t);
|
|
2024
2135
|
for (const c of h) {
|
|
2025
2136
|
const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
|
|
2026
|
-
await this.copy(f, u, { recursive: !0, overwrite:
|
|
2137
|
+
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2027
2138
|
}
|
|
2028
2139
|
}
|
|
2029
|
-
} catch (
|
|
2030
|
-
throw
|
|
2140
|
+
} catch (r) {
|
|
2141
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
2031
2142
|
}
|
|
2032
2143
|
}
|
|
2033
2144
|
/**
|
|
@@ -2057,9 +2168,9 @@ class ss {
|
|
|
2057
2168
|
*/
|
|
2058
2169
|
async watch(t, e) {
|
|
2059
2170
|
if (!this.options.broadcastChannel)
|
|
2060
|
-
throw new
|
|
2171
|
+
throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
2061
2172
|
const n = {
|
|
2062
|
-
pattern:
|
|
2173
|
+
pattern: ls(t, e?.recursive ?? !0),
|
|
2063
2174
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2064
2175
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2065
2176
|
};
|
|
@@ -2100,15 +2211,15 @@ class ss {
|
|
|
2100
2211
|
*/
|
|
2101
2212
|
async open(t, e) {
|
|
2102
2213
|
await this.mount();
|
|
2103
|
-
const { create: n = !1, exclusive:
|
|
2214
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
|
|
2104
2215
|
try {
|
|
2105
|
-
return n &&
|
|
2216
|
+
return n && r ? await L(o, "exclusive", async () => {
|
|
2106
2217
|
if (await this.exists(o))
|
|
2107
|
-
throw new
|
|
2108
|
-
return this._openFile(o, n,
|
|
2109
|
-
}) : await this._openFile(o, n,
|
|
2218
|
+
throw new K(o);
|
|
2219
|
+
return this._openFile(o, n, i);
|
|
2220
|
+
}) : await this._openFile(o, n, i);
|
|
2110
2221
|
} catch (a) {
|
|
2111
|
-
throw a instanceof
|
|
2222
|
+
throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
|
|
2112
2223
|
}
|
|
2113
2224
|
}
|
|
2114
2225
|
/**
|
|
@@ -2116,19 +2227,19 @@ class ss {
|
|
|
2116
2227
|
* @private
|
|
2117
2228
|
*/
|
|
2118
2229
|
async _openFile(t, e, n) {
|
|
2119
|
-
const
|
|
2230
|
+
const r = await this.getFileHandle(t, e);
|
|
2120
2231
|
try {
|
|
2121
|
-
await
|
|
2232
|
+
await r.getFile();
|
|
2122
2233
|
} catch (a) {
|
|
2123
|
-
throw a
|
|
2234
|
+
throw A(a, { path: t, isDirectory: !0 });
|
|
2124
2235
|
}
|
|
2125
|
-
const
|
|
2126
|
-
n && (
|
|
2236
|
+
const i = await ps(r, t);
|
|
2237
|
+
n && (i.truncate(0), i.flush());
|
|
2127
2238
|
const o = this.nextFd++;
|
|
2128
2239
|
return this.openFiles.set(o, {
|
|
2129
2240
|
path: t,
|
|
2130
|
-
fileHandle:
|
|
2131
|
-
syncHandle:
|
|
2241
|
+
fileHandle: r,
|
|
2242
|
+
syncHandle: i,
|
|
2132
2243
|
position: 0
|
|
2133
2244
|
}), o;
|
|
2134
2245
|
}
|
|
@@ -2148,7 +2259,7 @@ class ss {
|
|
|
2148
2259
|
*/
|
|
2149
2260
|
async close(t) {
|
|
2150
2261
|
const e = this._getFileDescriptor(t);
|
|
2151
|
-
|
|
2262
|
+
xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2152
2263
|
}
|
|
2153
2264
|
/**
|
|
2154
2265
|
* Read data from a file descriptor
|
|
@@ -2174,17 +2285,17 @@ class ss {
|
|
|
2174
2285
|
* await fs.close(fd);
|
|
2175
2286
|
* \`\`\`
|
|
2176
2287
|
*/
|
|
2177
|
-
async read(t, e, n,
|
|
2288
|
+
async read(t, e, n, r, i) {
|
|
2178
2289
|
const o = this._getFileDescriptor(t);
|
|
2179
|
-
|
|
2290
|
+
St(e.length, n, r, i);
|
|
2180
2291
|
try {
|
|
2181
|
-
const a =
|
|
2292
|
+
const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
|
|
2182
2293
|
if (h)
|
|
2183
|
-
return
|
|
2294
|
+
return B({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2184
2295
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2185
|
-
return
|
|
2296
|
+
return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2186
2297
|
} catch (a) {
|
|
2187
|
-
throw
|
|
2298
|
+
throw j("read", t, o.path, a);
|
|
2188
2299
|
}
|
|
2189
2300
|
}
|
|
2190
2301
|
/**
|
|
@@ -2208,14 +2319,14 @@ class ss {
|
|
|
2208
2319
|
* await fs.close(fd);
|
|
2209
2320
|
* \`\`\`
|
|
2210
2321
|
*/
|
|
2211
|
-
async write(t, e, n = 0,
|
|
2212
|
-
const a = this._getFileDescriptor(t), l =
|
|
2213
|
-
|
|
2322
|
+
async write(t, e, n = 0, r, i, o = !0) {
|
|
2323
|
+
const a = this._getFileDescriptor(t), l = r ?? e.length - n;
|
|
2324
|
+
St(e.length, n, l, i);
|
|
2214
2325
|
try {
|
|
2215
|
-
const h =
|
|
2216
|
-
return (
|
|
2326
|
+
const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2327
|
+
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
|
|
2217
2328
|
} catch (h) {
|
|
2218
|
-
throw
|
|
2329
|
+
throw j("write", t, a.path, h);
|
|
2219
2330
|
}
|
|
2220
2331
|
}
|
|
2221
2332
|
/**
|
|
@@ -2259,11 +2370,11 @@ class ss {
|
|
|
2259
2370
|
async ftruncate(t, e = 0) {
|
|
2260
2371
|
const n = this._getFileDescriptor(t);
|
|
2261
2372
|
if (e < 0 || !Number.isInteger(e))
|
|
2262
|
-
throw new
|
|
2373
|
+
throw new N("argument", "Invalid size");
|
|
2263
2374
|
try {
|
|
2264
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2265
|
-
} catch (
|
|
2266
|
-
throw
|
|
2375
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
|
|
2376
|
+
} catch (r) {
|
|
2377
|
+
throw j("truncate", t, n.path, r);
|
|
2267
2378
|
}
|
|
2268
2379
|
}
|
|
2269
2380
|
/**
|
|
@@ -2285,7 +2396,7 @@ class ss {
|
|
|
2285
2396
|
try {
|
|
2286
2397
|
e.syncHandle.flush();
|
|
2287
2398
|
} catch (n) {
|
|
2288
|
-
throw
|
|
2399
|
+
throw j("sync", t, e.path, n);
|
|
2289
2400
|
}
|
|
2290
2401
|
}
|
|
2291
2402
|
/**
|
|
@@ -2297,7 +2408,7 @@ class ss {
|
|
|
2297
2408
|
dispose() {
|
|
2298
2409
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2299
2410
|
for (const [t, e] of this.openFiles)
|
|
2300
|
-
|
|
2411
|
+
xt(t, e.syncHandle, e.path);
|
|
2301
2412
|
this.openFiles.clear(), this.nextFd = 1;
|
|
2302
2413
|
}
|
|
2303
2414
|
/**
|
|
@@ -2332,16 +2443,16 @@ class ss {
|
|
|
2332
2443
|
await this.mount();
|
|
2333
2444
|
try {
|
|
2334
2445
|
for (const [e, n] of t) {
|
|
2335
|
-
const
|
|
2336
|
-
let
|
|
2337
|
-
n instanceof Blob ?
|
|
2446
|
+
const r = G(e);
|
|
2447
|
+
let i;
|
|
2448
|
+
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2338
2449
|
}
|
|
2339
2450
|
} catch (e) {
|
|
2340
|
-
throw e instanceof
|
|
2451
|
+
throw e instanceof w ? e : A(e);
|
|
2341
2452
|
}
|
|
2342
2453
|
}
|
|
2343
2454
|
}
|
|
2344
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2345
|
-
//# sourceMappingURL=worker-
|
|
2346
|
-
`,
|
|
2455
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
|
|
2456
|
+
//# sourceMappingURL=worker-BeJaVyBV.js.map
|
|
2457
|
+
`,h=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=h&&(self.URL||self.webkitURL).createObjectURL(h),!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 p{#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 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:f}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(f.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)}dispose(){this.#n.dispose()}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)}}function m(o){return new p(o)}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.OPFSFileSystem=p;exports.createWorker=m;
|
|
2347
2458
|
//# sourceMappingURL=index.cjs.map
|