opfs-worker 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/worker-1Wh1cr7P.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/index.cjs +717 -601
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +772 -647
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +165 -164
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +74 -19
- 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 +2 -3
- package/dist/assets/worker-CS9nvwsF.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 +0 -1330
- package/dist/helpers-BXhw_-Ar.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { wrap as u } from "comlink";
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
2
|
+
import { i as h, d as l, e as c } from "./helpers-BuGfPAg0.js";
|
|
3
|
+
import { A as E, N as S, D as P, E as O, F, j as A, c as T, I as R, h as I, O as C, a as $, f as D, g as _, P as N, k as z, b as k, S as M, T as j, V as W, W as L, p as U, C as H, B, L as G, n as q, G as Y, z as V, l as X, M as Z, q as J, y as K, v as Q, o as nn, m as tn, u as en, t as rn, r as sn, H as an, x as on, K as cn, s as hn, J as ln, w as pn } from "./helpers-BuGfPAg0.js";
|
|
4
4
|
const f = `/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
7
7
|
* SPDX-License-Identifier: Apache-2.0
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
10
|
-
canHandle: (s) =>
|
|
9
|
+
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", _t = {
|
|
10
|
+
canHandle: (s) => Ot(s) && s[bt],
|
|
11
11
|
serialize(s) {
|
|
12
12
|
const { port1: t, port2: e } = new MessageChannel();
|
|
13
|
-
return
|
|
13
|
+
return ot(s, t), [e, [e]];
|
|
14
14
|
},
|
|
15
15
|
deserialize(s) {
|
|
16
|
-
return s.start(),
|
|
16
|
+
return s.start(), Gt(s);
|
|
17
17
|
}
|
|
18
|
-
},
|
|
19
|
-
canHandle: (s) =>
|
|
18
|
+
}, jt = {
|
|
19
|
+
canHandle: (s) => Ot(s) && U in s,
|
|
20
20
|
serialize({ value: s }) {
|
|
21
21
|
let t;
|
|
22
22
|
return s instanceof Error ? t = {
|
|
@@ -31,25 +31,25 @@ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol
|
|
|
31
31
|
deserialize(s) {
|
|
32
32
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
33
33
|
}
|
|
34
|
-
},
|
|
35
|
-
["proxy",
|
|
36
|
-
["throw",
|
|
34
|
+
}, Dt = /* @__PURE__ */ new Map([
|
|
35
|
+
["proxy", _t],
|
|
36
|
+
["throw", jt]
|
|
37
37
|
]);
|
|
38
|
-
function
|
|
38
|
+
function Ut(s, t) {
|
|
39
39
|
for (const e of s)
|
|
40
40
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
41
41
|
return !0;
|
|
42
42
|
return !1;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
t.addEventListener("message", function n(
|
|
46
|
-
if (!
|
|
44
|
+
function ot(s, t = globalThis, e = ["*"]) {
|
|
45
|
+
t.addEventListener("message", function n(r) {
|
|
46
|
+
if (!r || !r.data)
|
|
47
47
|
return;
|
|
48
|
-
if (!
|
|
49
|
-
console.warn(\`Invalid origin '\${
|
|
48
|
+
if (!Ut(e, r.origin)) {
|
|
49
|
+
console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const { id:
|
|
52
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
|
|
53
53
|
let h;
|
|
54
54
|
try {
|
|
55
55
|
const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
@@ -58,7 +58,7 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
58
58
|
h = f;
|
|
59
59
|
break;
|
|
60
60
|
case "SET":
|
|
61
|
-
c[a.slice(-1)[0]] =
|
|
61
|
+
c[a.slice(-1)[0]] = C(r.data.value), h = !0;
|
|
62
62
|
break;
|
|
63
63
|
case "APPLY":
|
|
64
64
|
h = f.apply(c, l);
|
|
@@ -66,13 +66,13 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
66
66
|
case "CONSTRUCT":
|
|
67
67
|
{
|
|
68
68
|
const u = new f(...l);
|
|
69
|
-
h =
|
|
69
|
+
h = Zt(u);
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
72
|
case "ENDPOINT":
|
|
73
73
|
{
|
|
74
74
|
const { port1: u, port2: d } = new MessageChannel();
|
|
75
|
-
|
|
75
|
+
ot(s, d), h = B(u, [u]);
|
|
76
76
|
}
|
|
77
77
|
break;
|
|
78
78
|
case "RELEASE":
|
|
@@ -82,145 +82,145 @@ function Q(s, t = globalThis, e = ["*"]) {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
} catch (c) {
|
|
85
|
-
h = { value: c, [
|
|
85
|
+
h = { value: c, [U]: 0 };
|
|
86
86
|
}
|
|
87
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
88
|
-
const [f, u] =
|
|
89
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
87
|
+
Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
|
|
88
|
+
const [f, u] = Y(c);
|
|
89
|
+
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]());
|
|
90
90
|
}).catch((c) => {
|
|
91
|
-
const [f, u] =
|
|
91
|
+
const [f, u] = Y({
|
|
92
92
|
value: new TypeError("Unserializable return value"),
|
|
93
|
-
[
|
|
93
|
+
[U]: 0
|
|
94
94
|
});
|
|
95
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id:
|
|
95
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
|
|
96
96
|
});
|
|
97
97
|
}), t.start && t.start();
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function Bt(s) {
|
|
100
100
|
return s.constructor.name === "MessagePort";
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
102
|
+
function vt(s) {
|
|
103
|
+
Bt(s) && s.close();
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function Gt(s, t) {
|
|
106
106
|
const e = /* @__PURE__ */ new Map();
|
|
107
|
-
return s.addEventListener("message", function(
|
|
108
|
-
const { data:
|
|
109
|
-
if (!
|
|
107
|
+
return s.addEventListener("message", function(r) {
|
|
108
|
+
const { data: i } = r;
|
|
109
|
+
if (!i || !i.id)
|
|
110
110
|
return;
|
|
111
|
-
const o = e.get(
|
|
111
|
+
const o = e.get(i.id);
|
|
112
112
|
if (o)
|
|
113
113
|
try {
|
|
114
|
-
o(
|
|
114
|
+
o(i);
|
|
115
115
|
} finally {
|
|
116
|
-
e.delete(
|
|
116
|
+
e.delete(i.id);
|
|
117
117
|
}
|
|
118
|
-
}),
|
|
118
|
+
}), nt(s, e, [], t);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function W(s) {
|
|
121
121
|
if (s)
|
|
122
122
|
throw new Error("Proxy has been released and is not useable");
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
124
|
+
function At(s) {
|
|
125
|
+
return $(s, /* @__PURE__ */ new Map(), {
|
|
126
126
|
type: "RELEASE"
|
|
127
127
|
}).then(() => {
|
|
128
|
-
|
|
128
|
+
vt(s);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
132
|
-
const t = (
|
|
133
|
-
|
|
131
|
+
const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
132
|
+
const t = (q.get(s) || 0) - 1;
|
|
133
|
+
q.set(s, t), t === 0 && At(s);
|
|
134
134
|
});
|
|
135
|
-
function
|
|
136
|
-
const e = (
|
|
137
|
-
|
|
135
|
+
function qt(s, t) {
|
|
136
|
+
const e = (q.get(t) || 0) + 1;
|
|
137
|
+
q.set(t, e), V && V.register(s, t, s);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
139
|
+
function Vt(s) {
|
|
140
|
+
V && V.unregister(s);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function nt(s, t, e = [], n = function() {
|
|
143
143
|
}) {
|
|
144
|
-
let
|
|
145
|
-
const
|
|
144
|
+
let r = !1;
|
|
145
|
+
const i = new Proxy(n, {
|
|
146
146
|
get(o, a) {
|
|
147
|
-
if (
|
|
147
|
+
if (W(r), a === Wt)
|
|
148
148
|
return () => {
|
|
149
|
-
|
|
149
|
+
Vt(i), At(s), t.clear(), r = !0;
|
|
150
150
|
};
|
|
151
151
|
if (a === "then") {
|
|
152
152
|
if (e.length === 0)
|
|
153
|
-
return { then: () =>
|
|
154
|
-
const l =
|
|
153
|
+
return { then: () => i };
|
|
154
|
+
const l = $(s, t, {
|
|
155
155
|
type: "GET",
|
|
156
156
|
path: e.map((h) => h.toString())
|
|
157
|
-
}).then(
|
|
157
|
+
}).then(C);
|
|
158
158
|
return l.then.bind(l);
|
|
159
159
|
}
|
|
160
|
-
return
|
|
160
|
+
return nt(s, t, [...e, a]);
|
|
161
161
|
},
|
|
162
162
|
set(o, a, l) {
|
|
163
|
-
|
|
164
|
-
const [h, c] =
|
|
165
|
-
return
|
|
163
|
+
W(r);
|
|
164
|
+
const [h, c] = Y(l);
|
|
165
|
+
return $(s, t, {
|
|
166
166
|
type: "SET",
|
|
167
167
|
path: [...e, a].map((f) => f.toString()),
|
|
168
168
|
value: h
|
|
169
|
-
}, c).then(
|
|
169
|
+
}, c).then(C);
|
|
170
170
|
},
|
|
171
171
|
apply(o, a, l) {
|
|
172
|
-
|
|
172
|
+
W(r);
|
|
173
173
|
const h = e[e.length - 1];
|
|
174
|
-
if (h ===
|
|
175
|
-
return
|
|
174
|
+
if (h === Ht)
|
|
175
|
+
return $(s, t, {
|
|
176
176
|
type: "ENDPOINT"
|
|
177
|
-
}).then(
|
|
177
|
+
}).then(C);
|
|
178
178
|
if (h === "bind")
|
|
179
|
-
return
|
|
180
|
-
const [c, f] =
|
|
181
|
-
return
|
|
179
|
+
return nt(s, t, e.slice(0, -1));
|
|
180
|
+
const [c, f] = ht(l);
|
|
181
|
+
return $(s, t, {
|
|
182
182
|
type: "APPLY",
|
|
183
183
|
path: e.map((u) => u.toString()),
|
|
184
184
|
argumentList: c
|
|
185
|
-
}, f).then(
|
|
185
|
+
}, f).then(C);
|
|
186
186
|
},
|
|
187
187
|
construct(o, a) {
|
|
188
|
-
|
|
189
|
-
const [l, h] =
|
|
190
|
-
return
|
|
188
|
+
W(r);
|
|
189
|
+
const [l, h] = ht(a);
|
|
190
|
+
return $(s, t, {
|
|
191
191
|
type: "CONSTRUCT",
|
|
192
192
|
path: e.map((c) => c.toString()),
|
|
193
193
|
argumentList: l
|
|
194
|
-
}, h).then(
|
|
194
|
+
}, h).then(C);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
|
-
return
|
|
197
|
+
return qt(i, s), i;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Yt(s) {
|
|
200
200
|
return Array.prototype.concat.apply([], s);
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
const t = s.map(
|
|
204
|
-
return [t.map((e) => e[0]),
|
|
202
|
+
function ht(s) {
|
|
203
|
+
const t = s.map(Y);
|
|
204
|
+
return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
function
|
|
208
|
-
return
|
|
206
|
+
const Nt = /* @__PURE__ */ new WeakMap();
|
|
207
|
+
function B(s, t) {
|
|
208
|
+
return Nt.set(s, t), s;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
return Object.assign(s, { [
|
|
210
|
+
function Zt(s) {
|
|
211
|
+
return Object.assign(s, { [bt]: !0 });
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
for (const [t, e] of
|
|
213
|
+
function Y(s) {
|
|
214
|
+
for (const [t, e] of Dt)
|
|
215
215
|
if (e.canHandle(s)) {
|
|
216
|
-
const [n,
|
|
216
|
+
const [n, r] = e.serialize(s);
|
|
217
217
|
return [
|
|
218
218
|
{
|
|
219
219
|
type: "HANDLER",
|
|
220
220
|
name: t,
|
|
221
221
|
value: n
|
|
222
222
|
},
|
|
223
|
-
|
|
223
|
+
r
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
226
|
return [
|
|
@@ -228,178 +228,294 @@ function B(s) {
|
|
|
228
228
|
type: "RAW",
|
|
229
229
|
value: s
|
|
230
230
|
},
|
|
231
|
-
|
|
231
|
+
Nt.get(s) || []
|
|
232
232
|
];
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function C(s) {
|
|
235
235
|
switch (s.type) {
|
|
236
236
|
case "HANDLER":
|
|
237
|
-
return
|
|
237
|
+
return Dt.get(s.name).deserialize(s.value);
|
|
238
238
|
case "RAW":
|
|
239
239
|
return s.value;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
return new Promise((
|
|
244
|
-
const
|
|
245
|
-
t.set(
|
|
242
|
+
function $(s, t, e, n) {
|
|
243
|
+
return new Promise((r) => {
|
|
244
|
+
const i = Xt();
|
|
245
|
+
t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function Xt() {
|
|
249
249
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
250
250
|
}
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
|
|
252
|
+
const Jt = {
|
|
253
|
+
ENOENT: -2,
|
|
254
|
+
// No such file or directory
|
|
255
|
+
EISDIR: -21,
|
|
256
|
+
// Is a directory
|
|
257
|
+
ENOTDIR: -20,
|
|
258
|
+
// Not a directory
|
|
259
|
+
EACCES: -13,
|
|
260
|
+
// Permission denied
|
|
261
|
+
EEXIST: -17,
|
|
262
|
+
// File exists
|
|
263
|
+
ENOTEMPTY: -39,
|
|
264
|
+
// Directory not empty
|
|
265
|
+
EINVAL: -22,
|
|
266
|
+
// Invalid argument
|
|
267
|
+
EIO: -5,
|
|
268
|
+
// I/O error
|
|
269
|
+
ENOSPC: -28,
|
|
270
|
+
// No space left on device
|
|
271
|
+
EBUSY: -16,
|
|
272
|
+
// Device or resource busy
|
|
273
|
+
EINTR: -4,
|
|
274
|
+
// Interrupted system call
|
|
275
|
+
ENOTSUP: -95,
|
|
276
|
+
// Operation not supported
|
|
277
|
+
ERANGE: -34,
|
|
278
|
+
// Result too large
|
|
279
|
+
EBADF: -9,
|
|
280
|
+
// Bad file descriptor
|
|
281
|
+
EROOT: -1
|
|
282
|
+
// Custom: Cannot remove root directory
|
|
283
|
+
};
|
|
284
|
+
class w extends Error {
|
|
285
|
+
errno;
|
|
286
|
+
syscall;
|
|
287
|
+
path;
|
|
288
|
+
constructor(t, e, n, r, i) {
|
|
289
|
+
super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
|
|
255
290
|
}
|
|
256
291
|
}
|
|
257
|
-
class
|
|
292
|
+
class Qt extends w {
|
|
258
293
|
constructor(t) {
|
|
259
|
-
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
|
|
294
|
+
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, void 0, t);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
class Kt extends w {
|
|
298
|
+
constructor(t, e, n) {
|
|
299
|
+
super(t, "INVALID_PATH", e, "access", n);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
class F extends w {
|
|
303
|
+
constructor(t, e, n) {
|
|
304
|
+
const r = {
|
|
305
|
+
file: \`File not found: \${e}\`,
|
|
306
|
+
directory: \`Directory not found: \${e}\`,
|
|
307
|
+
source: \`Source does not exist: \${e}\`
|
|
308
|
+
};
|
|
309
|
+
super(r[t], "ENOENT", e, "access", n);
|
|
260
310
|
}
|
|
261
311
|
}
|
|
262
|
-
class
|
|
312
|
+
class te extends w {
|
|
263
313
|
constructor(t, e, n) {
|
|
264
|
-
super(t
|
|
314
|
+
super(\`Permission denied for \${e} on: \${t}\`, "PERMISSION_DENIED", t, e, n);
|
|
265
315
|
}
|
|
266
316
|
}
|
|
267
|
-
class
|
|
317
|
+
class ee extends w {
|
|
318
|
+
constructor(t, e, n) {
|
|
319
|
+
super(t, "ENOSPC", e, "write", n);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
class se extends w {
|
|
268
323
|
constructor(t, e) {
|
|
269
|
-
super(\`File
|
|
324
|
+
super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
class L extends w {
|
|
328
|
+
constructor(t, e, n, r) {
|
|
329
|
+
const i = e === "directory" ? \`Is a directory: \${n}\` : \`Not a directory: \${n}\`, o = e === "directory" ? "EISDIR" : "ENOTDIR";
|
|
330
|
+
super(i, o, n, "access", r);
|
|
270
331
|
}
|
|
271
332
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
333
|
+
class N extends w {
|
|
334
|
+
constructor(t, e, n, r) {
|
|
335
|
+
const i = {
|
|
336
|
+
argument: "EINVAL",
|
|
337
|
+
format: "INVALID_FORMAT",
|
|
338
|
+
descriptor: "EBADF",
|
|
339
|
+
overflow: "ERANGE"
|
|
340
|
+
};
|
|
341
|
+
super(e, i[t], n, "validate", r);
|
|
342
|
+
}
|
|
275
343
|
}
|
|
276
|
-
|
|
277
|
-
|
|
344
|
+
class ne extends w {
|
|
345
|
+
constructor(t, e) {
|
|
346
|
+
super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
class ut extends w {
|
|
350
|
+
constructor(t, e, n) {
|
|
351
|
+
super(t, "EIO", e, "io", n);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
class Ct extends w {
|
|
355
|
+
constructor(t, e) {
|
|
356
|
+
super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
class rt extends w {
|
|
360
|
+
constructor(t, e, n) {
|
|
361
|
+
const r = {
|
|
362
|
+
remove: \`Failed to remove entry: \${e}\`,
|
|
363
|
+
clear: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
|
|
364
|
+
root: "Cannot remove root directory"
|
|
365
|
+
}, i = {
|
|
366
|
+
remove: "RM_FAILED",
|
|
367
|
+
clear: "ENOTEMPTY",
|
|
368
|
+
root: "EROOT"
|
|
369
|
+
};
|
|
370
|
+
super(r[t], i[t], e, "unlink", n);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class re extends w {
|
|
374
|
+
constructor(t, e) {
|
|
375
|
+
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
class Q extends w {
|
|
379
|
+
constructor(t, e, n) {
|
|
380
|
+
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
class K extends w {
|
|
384
|
+
constructor(t, e) {
|
|
385
|
+
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function _(s, t, e, n) {
|
|
389
|
+
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
390
|
+
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
391
|
+
}
|
|
392
|
+
function A(s, t) {
|
|
393
|
+
const e = t?.path, n = t?.isDirectory;
|
|
278
394
|
switch (s.name) {
|
|
279
395
|
case "InvalidStateError":
|
|
280
|
-
return new
|
|
396
|
+
return new se(e || "unknown", s);
|
|
281
397
|
case "QuotaExceededError":
|
|
282
|
-
return new
|
|
398
|
+
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
283
399
|
case "NotFoundError":
|
|
284
|
-
return new
|
|
400
|
+
return new F("file", e, s);
|
|
285
401
|
case "TypeMismatchError":
|
|
286
|
-
return new
|
|
402
|
+
return n !== void 0 ? n ? new L("file", "directory", e || "unknown", s) : new L("directory", "file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
287
403
|
case "NotAllowedError":
|
|
288
404
|
case "SecurityError":
|
|
289
|
-
return new
|
|
405
|
+
return new te(e, "unknown", s);
|
|
290
406
|
case "InvalidModificationError":
|
|
291
|
-
return new
|
|
407
|
+
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
292
408
|
case "AbortError":
|
|
293
|
-
return new
|
|
409
|
+
return new ne(e || "unknown", s);
|
|
294
410
|
case "OperationError":
|
|
295
|
-
return new
|
|
411
|
+
return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
|
|
296
412
|
case "TypeError":
|
|
297
|
-
return new
|
|
413
|
+
return new Ct(e || "unknown", s);
|
|
298
414
|
default:
|
|
299
|
-
return new
|
|
415
|
+
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
300
416
|
}
|
|
301
417
|
}
|
|
302
|
-
const
|
|
303
|
-
const n = s instanceof RegExp ?
|
|
304
|
-
return
|
|
305
|
-
start:
|
|
306
|
-
end:
|
|
307
|
-
pre: e.slice(0,
|
|
308
|
-
body: e.slice(
|
|
309
|
-
post: e.slice(
|
|
418
|
+
const Ft = (s, t, e) => {
|
|
419
|
+
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);
|
|
420
|
+
return i && {
|
|
421
|
+
start: i[0],
|
|
422
|
+
end: i[1],
|
|
423
|
+
pre: e.slice(0, i[0]),
|
|
424
|
+
body: e.slice(i[0] + n.length, i[1]),
|
|
425
|
+
post: e.slice(i[1] + r.length)
|
|
310
426
|
};
|
|
311
|
-
},
|
|
427
|
+
}, ft = (s, t) => {
|
|
312
428
|
const e = t.match(s);
|
|
313
429
|
return e ? e[0] : null;
|
|
314
|
-
},
|
|
315
|
-
let n,
|
|
430
|
+
}, ie = (s, t, e) => {
|
|
431
|
+
let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
316
432
|
if (l >= 0 && h > 0) {
|
|
317
433
|
if (s === t)
|
|
318
434
|
return [l, h];
|
|
319
|
-
for (n = [],
|
|
435
|
+
for (n = [], i = e.length; c >= 0 && !a; ) {
|
|
320
436
|
if (c === l)
|
|
321
437
|
n.push(c), l = e.indexOf(s, c + 1);
|
|
322
438
|
else if (n.length === 1) {
|
|
323
439
|
const f = n.pop();
|
|
324
440
|
f !== void 0 && (a = [f, h]);
|
|
325
441
|
} else
|
|
326
|
-
|
|
442
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
|
|
327
443
|
c = l < h && l >= 0 ? l : h;
|
|
328
444
|
}
|
|
329
|
-
n.length && o !== void 0 && (a = [
|
|
445
|
+
n.length && o !== void 0 && (a = [i, o]);
|
|
330
446
|
}
|
|
331
447
|
return a;
|
|
332
|
-
},
|
|
333
|
-
function
|
|
448
|
+
}, $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;
|
|
449
|
+
function tt(s) {
|
|
334
450
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
335
451
|
}
|
|
336
|
-
function
|
|
337
|
-
return s.replace(
|
|
452
|
+
function we(s) {
|
|
453
|
+
return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
|
|
338
454
|
}
|
|
339
|
-
function
|
|
340
|
-
return s.replace(
|
|
455
|
+
function me(s) {
|
|
456
|
+
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
341
457
|
}
|
|
342
|
-
function
|
|
458
|
+
function Rt(s) {
|
|
343
459
|
if (!s)
|
|
344
460
|
return [""];
|
|
345
|
-
const t = [], e =
|
|
461
|
+
const t = [], e = Ft("{", "}", s);
|
|
346
462
|
if (!e)
|
|
347
463
|
return s.split(",");
|
|
348
|
-
const { pre: n, body:
|
|
349
|
-
o[o.length - 1] += "{" +
|
|
350
|
-
const a =
|
|
351
|
-
return
|
|
464
|
+
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
465
|
+
o[o.length - 1] += "{" + r + "}";
|
|
466
|
+
const a = Rt(i);
|
|
467
|
+
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
352
468
|
}
|
|
353
|
-
function
|
|
354
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(
|
|
469
|
+
function ye(s) {
|
|
470
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
|
|
355
471
|
}
|
|
356
|
-
function
|
|
472
|
+
function Ee(s) {
|
|
357
473
|
return "{" + s + "}";
|
|
358
474
|
}
|
|
359
|
-
function
|
|
475
|
+
function Se(s) {
|
|
360
476
|
return /^-?0\\d/.test(s);
|
|
361
477
|
}
|
|
362
|
-
function
|
|
478
|
+
function xe(s, t) {
|
|
363
479
|
return s <= t;
|
|
364
480
|
}
|
|
365
|
-
function
|
|
481
|
+
function be(s, t) {
|
|
366
482
|
return s >= t;
|
|
367
483
|
}
|
|
368
484
|
function I(s, t) {
|
|
369
|
-
const e = [], n =
|
|
485
|
+
const e = [], n = Ft("{", "}", s);
|
|
370
486
|
if (!n)
|
|
371
487
|
return [s];
|
|
372
|
-
const
|
|
488
|
+
const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
|
|
373
489
|
if (/\\$$/.test(n.pre))
|
|
374
|
-
for (let o = 0; o <
|
|
375
|
-
const a =
|
|
490
|
+
for (let o = 0; o < i.length; o++) {
|
|
491
|
+
const a = r + "{" + n.body + "}" + i[o];
|
|
376
492
|
e.push(a);
|
|
377
493
|
}
|
|
378
494
|
else {
|
|
379
495
|
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;
|
|
380
496
|
if (!l && !h)
|
|
381
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
497
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
|
|
382
498
|
let c;
|
|
383
499
|
if (l)
|
|
384
500
|
c = n.body.split(/\\.\\./);
|
|
385
|
-
else if (c =
|
|
386
|
-
return
|
|
501
|
+
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
|
|
502
|
+
return i.map((u) => n.pre + c[0] + u);
|
|
387
503
|
let f;
|
|
388
504
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
389
|
-
const u =
|
|
390
|
-
let
|
|
391
|
-
d < u && (
|
|
392
|
-
const
|
|
505
|
+
const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
506
|
+
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
|
|
507
|
+
d < u && (p *= -1, S = be);
|
|
508
|
+
const P = c.some(Se);
|
|
393
509
|
f = [];
|
|
394
|
-
for (let x = u; S(x, d); x +=
|
|
510
|
+
for (let x = u; S(x, d); x += p) {
|
|
395
511
|
let m;
|
|
396
512
|
if (a)
|
|
397
513
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
398
|
-
else if (m = String(x),
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
const
|
|
402
|
-
x < 0 ? m = "-" +
|
|
514
|
+
else if (m = String(x), P) {
|
|
515
|
+
const T = g - m.length;
|
|
516
|
+
if (T > 0) {
|
|
517
|
+
const H = new Array(T + 1).join("0");
|
|
518
|
+
x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
|
|
403
519
|
}
|
|
404
520
|
}
|
|
405
521
|
f.push(m);
|
|
@@ -410,19 +526,19 @@ function I(s, t) {
|
|
|
410
526
|
f.push.apply(f, I(c[u], !1));
|
|
411
527
|
}
|
|
412
528
|
for (let u = 0; u < f.length; u++)
|
|
413
|
-
for (let d = 0; d <
|
|
414
|
-
const
|
|
415
|
-
(!t || l ||
|
|
529
|
+
for (let d = 0; d < i.length; d++) {
|
|
530
|
+
const g = r + f[u] + i[d];
|
|
531
|
+
(!t || l || g) && e.push(g);
|
|
416
532
|
}
|
|
417
533
|
}
|
|
418
534
|
return e;
|
|
419
535
|
}
|
|
420
|
-
const
|
|
536
|
+
const Oe = 1024 * 64, Z = (s) => {
|
|
421
537
|
if (typeof s != "string")
|
|
422
538
|
throw new TypeError("invalid pattern");
|
|
423
|
-
if (s.length >
|
|
539
|
+
if (s.length > Oe)
|
|
424
540
|
throw new TypeError("pattern is too long");
|
|
425
|
-
},
|
|
541
|
+
}, De = {
|
|
426
542
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
427
543
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
428
544
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -437,77 +553,77 @@ const he = 1024 * 64, G = (s) => {
|
|
|
437
553
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
438
554
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
439
555
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
440
|
-
},
|
|
556
|
+
}, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
|
|
441
557
|
const e = t;
|
|
442
558
|
if (s.charAt(e) !== "[")
|
|
443
559
|
throw new Error("not in a brace expression");
|
|
444
|
-
const n = [],
|
|
445
|
-
let
|
|
446
|
-
t: for (;
|
|
447
|
-
const
|
|
448
|
-
if ((
|
|
449
|
-
h = !0,
|
|
560
|
+
const n = [], r = [];
|
|
561
|
+
let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
|
|
562
|
+
t: for (; i < s.length; ) {
|
|
563
|
+
const p = s.charAt(i);
|
|
564
|
+
if ((p === "!" || p === "^") && i === e + 1) {
|
|
565
|
+
h = !0, i++;
|
|
450
566
|
continue;
|
|
451
567
|
}
|
|
452
|
-
if (
|
|
453
|
-
c =
|
|
568
|
+
if (p === "]" && o && !l) {
|
|
569
|
+
c = i + 1;
|
|
454
570
|
break;
|
|
455
571
|
}
|
|
456
|
-
if (o = !0,
|
|
457
|
-
l = !0,
|
|
572
|
+
if (o = !0, p === "\\\\" && !l) {
|
|
573
|
+
l = !0, i++;
|
|
458
574
|
continue;
|
|
459
575
|
}
|
|
460
|
-
if (
|
|
461
|
-
for (const [S, [
|
|
462
|
-
if (s.startsWith(S,
|
|
576
|
+
if (p === "[" && !l) {
|
|
577
|
+
for (const [S, [v, P, x]] of Object.entries(De))
|
|
578
|
+
if (s.startsWith(S, i)) {
|
|
463
579
|
if (f)
|
|
464
580
|
return ["$.", !1, s.length - e, !0];
|
|
465
|
-
|
|
581
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || P;
|
|
466
582
|
continue t;
|
|
467
583
|
}
|
|
468
584
|
}
|
|
469
585
|
if (l = !1, f) {
|
|
470
|
-
|
|
586
|
+
p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
|
|
471
587
|
continue;
|
|
472
588
|
}
|
|
473
|
-
if (s.startsWith("-]",
|
|
474
|
-
n.push(
|
|
589
|
+
if (s.startsWith("-]", i + 1)) {
|
|
590
|
+
n.push(R(p + "-")), i += 2;
|
|
475
591
|
continue;
|
|
476
592
|
}
|
|
477
|
-
if (s.startsWith("-",
|
|
478
|
-
f =
|
|
593
|
+
if (s.startsWith("-", i + 1)) {
|
|
594
|
+
f = p, i += 2;
|
|
479
595
|
continue;
|
|
480
596
|
}
|
|
481
|
-
n.push(
|
|
597
|
+
n.push(R(p)), i++;
|
|
482
598
|
}
|
|
483
|
-
if (c <
|
|
599
|
+
if (c < i)
|
|
484
600
|
return ["", !1, 0, !1];
|
|
485
|
-
if (!n.length && !
|
|
601
|
+
if (!n.length && !r.length)
|
|
486
602
|
return ["$.", !1, s.length - e, !0];
|
|
487
|
-
if (
|
|
488
|
-
const
|
|
489
|
-
return [
|
|
603
|
+
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
604
|
+
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
605
|
+
return [ve(p), !1, c - e, !1];
|
|
490
606
|
}
|
|
491
|
-
const u = "[" + (h ? "^" : "") +
|
|
492
|
-
return [n.length &&
|
|
493
|
-
},
|
|
607
|
+
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
608
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
609
|
+
}, 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 = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
494
610
|
class E {
|
|
495
611
|
type;
|
|
496
612
|
#s;
|
|
497
613
|
#n;
|
|
498
|
-
#
|
|
614
|
+
#i = !1;
|
|
499
615
|
#t = [];
|
|
500
616
|
#e;
|
|
501
617
|
#o;
|
|
502
618
|
#c;
|
|
503
619
|
#a = !1;
|
|
504
|
-
#
|
|
620
|
+
#r;
|
|
505
621
|
#l;
|
|
506
622
|
// set to true if it's an extglob with no children
|
|
507
623
|
// (which really means one child of '')
|
|
508
624
|
#u = !1;
|
|
509
625
|
constructor(t, e, n = {}) {
|
|
510
|
-
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#
|
|
626
|
+
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;
|
|
511
627
|
}
|
|
512
628
|
get hasMagic() {
|
|
513
629
|
if (this.#n !== void 0)
|
|
@@ -533,11 +649,11 @@ class E {
|
|
|
533
649
|
continue;
|
|
534
650
|
let e = t, n = e.#e;
|
|
535
651
|
for (; n; ) {
|
|
536
|
-
for (let
|
|
537
|
-
for (const
|
|
538
|
-
if (typeof
|
|
652
|
+
for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
|
|
653
|
+
for (const i of t.#t) {
|
|
654
|
+
if (typeof i == "string")
|
|
539
655
|
throw new Error("string part in extglob AST??");
|
|
540
|
-
|
|
656
|
+
i.copyIn(n.#t[r]);
|
|
541
657
|
}
|
|
542
658
|
e = n, n = e.#e;
|
|
543
659
|
}
|
|
@@ -590,40 +706,40 @@ class E {
|
|
|
590
706
|
e.copyIn(n);
|
|
591
707
|
return e;
|
|
592
708
|
}
|
|
593
|
-
static #h(t, e, n,
|
|
594
|
-
let
|
|
709
|
+
static #h(t, e, n, r) {
|
|
710
|
+
let i = !1, o = !1, a = -1, l = !1;
|
|
595
711
|
if (e.type === null) {
|
|
596
|
-
let d = n,
|
|
712
|
+
let d = n, g = "";
|
|
597
713
|
for (; d < t.length; ) {
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
|
|
714
|
+
const p = t.charAt(d++);
|
|
715
|
+
if (i || p === "\\\\") {
|
|
716
|
+
i = !i, g += p;
|
|
601
717
|
continue;
|
|
602
718
|
}
|
|
603
719
|
if (o) {
|
|
604
|
-
d === a + 1 ? (
|
|
720
|
+
d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
|
|
605
721
|
continue;
|
|
606
|
-
} else if (
|
|
607
|
-
o = !0, a = d, l = !1,
|
|
722
|
+
} else if (p === "[") {
|
|
723
|
+
o = !0, a = d, l = !1, g += p;
|
|
608
724
|
continue;
|
|
609
725
|
}
|
|
610
|
-
if (!
|
|
611
|
-
e.push(
|
|
612
|
-
const S = new E(
|
|
613
|
-
d = E.#h(t, S, d,
|
|
726
|
+
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
727
|
+
e.push(g), g = "";
|
|
728
|
+
const S = new E(p, e);
|
|
729
|
+
d = E.#h(t, S, d, r), e.push(S);
|
|
614
730
|
continue;
|
|
615
731
|
}
|
|
616
|
-
|
|
732
|
+
g += p;
|
|
617
733
|
}
|
|
618
|
-
return e.push(
|
|
734
|
+
return e.push(g), d;
|
|
619
735
|
}
|
|
620
736
|
let h = n + 1, c = new E(null, e);
|
|
621
737
|
const f = [];
|
|
622
738
|
let u = "";
|
|
623
739
|
for (; h < t.length; ) {
|
|
624
740
|
const d = t.charAt(h++);
|
|
625
|
-
if (
|
|
626
|
-
|
|
741
|
+
if (i || d === "\\\\") {
|
|
742
|
+
i = !i, u += d;
|
|
627
743
|
continue;
|
|
628
744
|
}
|
|
629
745
|
if (o) {
|
|
@@ -633,10 +749,10 @@ class E {
|
|
|
633
749
|
o = !0, a = h, l = !1, u += d;
|
|
634
750
|
continue;
|
|
635
751
|
}
|
|
636
|
-
if (
|
|
752
|
+
if (pt(d) && t.charAt(h) === "(") {
|
|
637
753
|
c.push(u), u = "";
|
|
638
|
-
const
|
|
639
|
-
c.push(
|
|
754
|
+
const g = new E(d, c);
|
|
755
|
+
c.push(g), h = E.#h(t, g, h, r);
|
|
640
756
|
continue;
|
|
641
757
|
}
|
|
642
758
|
if (d === "|") {
|
|
@@ -658,17 +774,17 @@ class E {
|
|
|
658
774
|
toMMPattern() {
|
|
659
775
|
if (this !== this.#s)
|
|
660
776
|
return this.#s.toMMPattern();
|
|
661
|
-
const t = this.toString(), [e, n,
|
|
662
|
-
if (!(
|
|
777
|
+
const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
|
|
778
|
+
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
663
779
|
return n;
|
|
664
|
-
const a = (this.#
|
|
780
|
+
const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
665
781
|
return Object.assign(new RegExp(\`^\${e}$\`, a), {
|
|
666
782
|
_src: e,
|
|
667
783
|
_glob: t
|
|
668
784
|
});
|
|
669
785
|
}
|
|
670
786
|
get options() {
|
|
671
|
-
return this.#
|
|
787
|
+
return this.#r;
|
|
672
788
|
}
|
|
673
789
|
// returns the string match, the regexp source, whether there's magic
|
|
674
790
|
// in the regexp (so a regular expression is required) and whether or
|
|
@@ -740,168 +856,168 @@ class E {
|
|
|
740
856
|
// is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
|
|
741
857
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
742
858
|
toRegExpSource(t) {
|
|
743
|
-
const e = t ?? !!this.#
|
|
859
|
+
const e = t ?? !!this.#r.dot;
|
|
744
860
|
if (this.#s === this && this.#d(), !this.type) {
|
|
745
861
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
746
|
-
const [
|
|
747
|
-
return this.#n = this.#n || S, this.#
|
|
862
|
+
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
863
|
+
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
748
864
|
}).join("");
|
|
749
865
|
let c = "";
|
|
750
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
751
|
-
const
|
|
866
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
|
|
867
|
+
const g = Fe, p = (
|
|
752
868
|
// dots are allowed, and the pattern starts with [ or .
|
|
753
|
-
e &&
|
|
754
|
-
h.startsWith("\\\\.") &&
|
|
755
|
-
h.startsWith("\\\\.\\\\.") &&
|
|
756
|
-
), S = !e && !t &&
|
|
757
|
-
c =
|
|
869
|
+
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
870
|
+
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
871
|
+
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
872
|
+
), S = !e && !t && g.has(h.charAt(0));
|
|
873
|
+
c = p ? Ce : S ? j : "";
|
|
758
874
|
}
|
|
759
875
|
let f = "";
|
|
760
876
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
761
877
|
c + h + f,
|
|
762
|
-
|
|
878
|
+
k(h),
|
|
763
879
|
this.#n = !!this.#n,
|
|
764
|
-
this.#
|
|
880
|
+
this.#i
|
|
765
881
|
];
|
|
766
882
|
}
|
|
767
|
-
const n = this.type === "*" || this.type === "+",
|
|
768
|
-
let
|
|
769
|
-
if (this.isStart() && this.isEnd() && !
|
|
883
|
+
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
884
|
+
let i = this.#f(e);
|
|
885
|
+
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
770
886
|
const l = this.toString();
|
|
771
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
887
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
|
|
772
888
|
}
|
|
773
|
-
let o = !n || t || e || !
|
|
774
|
-
o ===
|
|
889
|
+
let o = !n || t || e || !j ? "" : this.#f(!0);
|
|
890
|
+
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
775
891
|
let a = "";
|
|
776
892
|
if (this.type === "!" && this.#u)
|
|
777
|
-
a = (this.isStart() && !e ?
|
|
893
|
+
a = (this.isStart() && !e ? j : "") + wt;
|
|
778
894
|
else {
|
|
779
895
|
const l = this.type === "!" ? (
|
|
780
896
|
// !() must match something,but !(x) can match ''
|
|
781
|
-
"))" + (this.isStart() && !e && !t ?
|
|
897
|
+
"))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
|
|
782
898
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
783
|
-
a =
|
|
899
|
+
a = r + i + l;
|
|
784
900
|
}
|
|
785
901
|
return [
|
|
786
902
|
a,
|
|
787
|
-
|
|
903
|
+
k(i),
|
|
788
904
|
this.#n = !!this.#n,
|
|
789
|
-
this.#
|
|
905
|
+
this.#i
|
|
790
906
|
];
|
|
791
907
|
}
|
|
792
908
|
#f(t) {
|
|
793
909
|
return this.#t.map((e) => {
|
|
794
910
|
if (typeof e == "string")
|
|
795
911
|
throw new Error("string type in extglob ast??");
|
|
796
|
-
const [n,
|
|
797
|
-
return this.#
|
|
912
|
+
const [n, r, i, o] = e.toRegExpSource(t);
|
|
913
|
+
return this.#i = this.#i || o, n;
|
|
798
914
|
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
799
915
|
}
|
|
800
916
|
static #p(t, e, n = !1) {
|
|
801
|
-
let
|
|
917
|
+
let r = !1, i = "", o = !1;
|
|
802
918
|
for (let a = 0; a < t.length; a++) {
|
|
803
919
|
const l = t.charAt(a);
|
|
804
|
-
if (
|
|
805
|
-
|
|
920
|
+
if (r) {
|
|
921
|
+
r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
|
|
806
922
|
continue;
|
|
807
923
|
}
|
|
808
924
|
if (l === "\\\\") {
|
|
809
|
-
a === t.length - 1 ?
|
|
925
|
+
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
810
926
|
continue;
|
|
811
927
|
}
|
|
812
928
|
if (l === "[") {
|
|
813
|
-
const [h, c, f, u] =
|
|
929
|
+
const [h, c, f, u] = Ae(t, a);
|
|
814
930
|
if (f) {
|
|
815
|
-
|
|
931
|
+
i += h, o = o || c, a += f - 1, e = e || u;
|
|
816
932
|
continue;
|
|
817
933
|
}
|
|
818
934
|
}
|
|
819
935
|
if (l === "*") {
|
|
820
|
-
n && t === "*" ?
|
|
936
|
+
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
821
937
|
continue;
|
|
822
938
|
}
|
|
823
939
|
if (l === "?") {
|
|
824
|
-
|
|
940
|
+
i += ct, e = !0;
|
|
825
941
|
continue;
|
|
826
942
|
}
|
|
827
|
-
|
|
943
|
+
i += Pe(l);
|
|
828
944
|
}
|
|
829
|
-
return [
|
|
945
|
+
return [i, k(t), !!e, o];
|
|
830
946
|
}
|
|
831
947
|
}
|
|
832
|
-
const
|
|
833
|
-
const e =
|
|
948
|
+
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), ze = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), _e = (s) => s !== "." && s !== ".." && s.includes("."), je = /^\\.\\*+$/, 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 = ""]) => {
|
|
949
|
+
const e = It([s]);
|
|
834
950
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
835
|
-
},
|
|
836
|
-
const e =
|
|
951
|
+
}, Ze = ([s, t = ""]) => {
|
|
952
|
+
const e = kt([s]);
|
|
837
953
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
838
|
-
},
|
|
839
|
-
const e =
|
|
954
|
+
}, Xe = ([s, t = ""]) => {
|
|
955
|
+
const e = kt([s]);
|
|
840
956
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
841
|
-
},
|
|
842
|
-
const e =
|
|
957
|
+
}, Je = ([s, t = ""]) => {
|
|
958
|
+
const e = It([s]);
|
|
843
959
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
844
|
-
},
|
|
960
|
+
}, It = ([s]) => {
|
|
845
961
|
const t = s.length;
|
|
846
962
|
return (e) => e.length === t && !e.startsWith(".");
|
|
847
|
-
},
|
|
963
|
+
}, kt = ([s]) => {
|
|
848
964
|
const t = s.length;
|
|
849
965
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
850
|
-
},
|
|
966
|
+
}, zt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
851
967
|
win32: { sep: "\\\\" },
|
|
852
968
|
posix: { sep: "/" }
|
|
853
|
-
},
|
|
854
|
-
y.sep =
|
|
855
|
-
const
|
|
856
|
-
y.GLOBSTAR =
|
|
857
|
-
const
|
|
858
|
-
y.filter =
|
|
859
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
969
|
+
}, Qe = zt === "win32" ? mt.win32.sep : mt.posix.sep;
|
|
970
|
+
y.sep = Qe;
|
|
971
|
+
const O = Symbol("globstar **");
|
|
972
|
+
y.GLOBSTAR = O;
|
|
973
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
|
|
974
|
+
y.filter = ns;
|
|
975
|
+
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
860
976
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
861
977
|
return y;
|
|
862
978
|
const t = y;
|
|
863
|
-
return Object.assign((n,
|
|
979
|
+
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
864
980
|
Minimatch: class extends t.Minimatch {
|
|
865
|
-
constructor(
|
|
866
|
-
super(
|
|
981
|
+
constructor(r, i = {}) {
|
|
982
|
+
super(r, b(s, i));
|
|
867
983
|
}
|
|
868
|
-
static defaults(
|
|
869
|
-
return t.defaults(b(s,
|
|
984
|
+
static defaults(r) {
|
|
985
|
+
return t.defaults(b(s, r)).Minimatch;
|
|
870
986
|
}
|
|
871
987
|
},
|
|
872
988
|
AST: class extends t.AST {
|
|
873
989
|
/* c8 ignore start */
|
|
874
|
-
constructor(
|
|
875
|
-
super(
|
|
990
|
+
constructor(r, i, o = {}) {
|
|
991
|
+
super(r, i, b(s, o));
|
|
876
992
|
}
|
|
877
993
|
/* c8 ignore stop */
|
|
878
|
-
static fromGlob(
|
|
879
|
-
return t.AST.fromGlob(
|
|
994
|
+
static fromGlob(r, i = {}) {
|
|
995
|
+
return t.AST.fromGlob(r, b(s, i));
|
|
880
996
|
}
|
|
881
997
|
},
|
|
882
|
-
unescape: (n,
|
|
883
|
-
escape: (n,
|
|
884
|
-
filter: (n,
|
|
998
|
+
unescape: (n, r = {}) => t.unescape(n, b(s, r)),
|
|
999
|
+
escape: (n, r = {}) => t.escape(n, b(s, r)),
|
|
1000
|
+
filter: (n, r = {}) => t.filter(n, b(s, r)),
|
|
885
1001
|
defaults: (n) => t.defaults(b(s, n)),
|
|
886
|
-
makeRe: (n,
|
|
887
|
-
braceExpand: (n,
|
|
888
|
-
match: (n,
|
|
1002
|
+
makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
|
|
1003
|
+
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
1004
|
+
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
889
1005
|
sep: t.sep,
|
|
890
|
-
GLOBSTAR:
|
|
1006
|
+
GLOBSTAR: O
|
|
891
1007
|
});
|
|
892
1008
|
};
|
|
893
|
-
y.defaults =
|
|
894
|
-
const
|
|
895
|
-
y.braceExpand =
|
|
896
|
-
const
|
|
897
|
-
y.makeRe =
|
|
898
|
-
const
|
|
899
|
-
const n = new
|
|
900
|
-
return s = s.filter((
|
|
1009
|
+
y.defaults = rs;
|
|
1010
|
+
const Lt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
|
|
1011
|
+
y.braceExpand = Lt;
|
|
1012
|
+
const is = (s, t = {}) => new X(s, t).makeRe();
|
|
1013
|
+
y.makeRe = is;
|
|
1014
|
+
const os = (s, t, e = {}) => {
|
|
1015
|
+
const n = new X(t, e);
|
|
1016
|
+
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
901
1017
|
};
|
|
902
|
-
y.match =
|
|
903
|
-
const
|
|
904
|
-
class
|
|
1018
|
+
y.match = os;
|
|
1019
|
+
const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1020
|
+
class X {
|
|
905
1021
|
options;
|
|
906
1022
|
set;
|
|
907
1023
|
pattern;
|
|
@@ -920,7 +1036,7 @@ class q {
|
|
|
920
1036
|
windowsNoMagicRoot;
|
|
921
1037
|
regexp;
|
|
922
1038
|
constructor(t, e = {}) {
|
|
923
|
-
|
|
1039
|
+
Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || zt, 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();
|
|
924
1040
|
}
|
|
925
1041
|
hasMagic() {
|
|
926
1042
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -943,23 +1059,23 @@ class q {
|
|
|
943
1059
|
this.empty = !0;
|
|
944
1060
|
return;
|
|
945
1061
|
}
|
|
946
|
-
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...
|
|
947
|
-
const n = this.globSet.map((
|
|
1062
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1063
|
+
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
948
1064
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
949
|
-
let
|
|
1065
|
+
let r = this.globParts.map((i, o, a) => {
|
|
950
1066
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
951
|
-
const l =
|
|
1067
|
+
const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
952
1068
|
if (l)
|
|
953
|
-
return [...
|
|
1069
|
+
return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
|
|
954
1070
|
if (h)
|
|
955
|
-
return [
|
|
1071
|
+
return [i[0], ...i.slice(1).map((c) => this.parse(c))];
|
|
956
1072
|
}
|
|
957
|
-
return
|
|
1073
|
+
return i.map((l) => this.parse(l));
|
|
958
1074
|
});
|
|
959
|
-
if (this.debug(this.pattern,
|
|
960
|
-
for (let
|
|
961
|
-
const o = this.set[
|
|
962
|
-
o[0] === "" && o[1] === "" && this.globParts[
|
|
1075
|
+
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1076
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1077
|
+
const o = this.set[i];
|
|
1078
|
+
o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
963
1079
|
}
|
|
964
1080
|
this.debug(this.pattern, this.set);
|
|
965
1081
|
}
|
|
@@ -971,8 +1087,8 @@ class q {
|
|
|
971
1087
|
preprocess(t) {
|
|
972
1088
|
if (this.options.noglobstar)
|
|
973
1089
|
for (let n = 0; n < t.length; n++)
|
|
974
|
-
for (let
|
|
975
|
-
t[n][
|
|
1090
|
+
for (let r = 0; r < t[n].length; r++)
|
|
1091
|
+
t[n][r] === "**" && (t[n][r] = "*");
|
|
976
1092
|
const { optimizationLevel: e = 1 } = this.options;
|
|
977
1093
|
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
978
1094
|
}
|
|
@@ -981,19 +1097,19 @@ class q {
|
|
|
981
1097
|
return t.map((e) => {
|
|
982
1098
|
let n = -1;
|
|
983
1099
|
for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
|
|
984
|
-
let
|
|
985
|
-
for (; e[
|
|
986
|
-
|
|
987
|
-
|
|
1100
|
+
let r = n;
|
|
1101
|
+
for (; e[r + 1] === "**"; )
|
|
1102
|
+
r++;
|
|
1103
|
+
r !== n && e.splice(n, r - n);
|
|
988
1104
|
}
|
|
989
1105
|
return e;
|
|
990
1106
|
});
|
|
991
1107
|
}
|
|
992
1108
|
// get rid of adjascent ** and resolve .. portions
|
|
993
1109
|
levelOneOptimize(t) {
|
|
994
|
-
return t.map((e) => (e = e.reduce((n,
|
|
995
|
-
const
|
|
996
|
-
return
|
|
1110
|
+
return t.map((e) => (e = e.reduce((n, r) => {
|
|
1111
|
+
const i = n[n.length - 1];
|
|
1112
|
+
return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
|
|
997
1113
|
}, []), e.length === 0 ? [""] : e));
|
|
998
1114
|
}
|
|
999
1115
|
levelTwoFileOptimize(t) {
|
|
@@ -1001,16 +1117,16 @@ class q {
|
|
|
1001
1117
|
let e = !1;
|
|
1002
1118
|
do {
|
|
1003
1119
|
if (e = !1, !this.preserveMultipleSlashes) {
|
|
1004
|
-
for (let
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1120
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
1121
|
+
const i = t[r];
|
|
1122
|
+
r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
|
|
1007
1123
|
}
|
|
1008
1124
|
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
1009
1125
|
}
|
|
1010
1126
|
let n = 0;
|
|
1011
1127
|
for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1128
|
+
const r = t[n - 1];
|
|
1129
|
+
r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
|
|
1014
1130
|
}
|
|
1015
1131
|
} while (e);
|
|
1016
1132
|
return t.length === 0 ? [""] : t;
|
|
@@ -1038,19 +1154,19 @@ class q {
|
|
|
1038
1154
|
do {
|
|
1039
1155
|
e = !1;
|
|
1040
1156
|
for (let n of t) {
|
|
1041
|
-
let
|
|
1042
|
-
for (; (
|
|
1043
|
-
let o =
|
|
1157
|
+
let r = -1;
|
|
1158
|
+
for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
|
|
1159
|
+
let o = r;
|
|
1044
1160
|
for (; n[o + 1] === "**"; )
|
|
1045
1161
|
o++;
|
|
1046
|
-
o >
|
|
1047
|
-
let a = n[
|
|
1048
|
-
const l = n[
|
|
1162
|
+
o > r && n.splice(r + 1, o - r);
|
|
1163
|
+
let a = n[r + 1];
|
|
1164
|
+
const l = n[r + 2], h = n[r + 3];
|
|
1049
1165
|
if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
|
|
1050
1166
|
continue;
|
|
1051
|
-
e = !0, n.splice(
|
|
1167
|
+
e = !0, n.splice(r, 1);
|
|
1052
1168
|
const c = n.slice(0);
|
|
1053
|
-
c[
|
|
1169
|
+
c[r] = "**", t.push(c), r--;
|
|
1054
1170
|
}
|
|
1055
1171
|
if (!this.preserveMultipleSlashes) {
|
|
1056
1172
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1059,13 +1175,13 @@ class q {
|
|
|
1059
1175
|
}
|
|
1060
1176
|
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
|
|
1061
1177
|
}
|
|
1062
|
-
let
|
|
1063
|
-
for (; (
|
|
1064
|
-
const o = n[
|
|
1178
|
+
let i = 0;
|
|
1179
|
+
for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
|
|
1180
|
+
const o = n[i - 1];
|
|
1065
1181
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1066
1182
|
e = !0;
|
|
1067
|
-
const l =
|
|
1068
|
-
n.splice(
|
|
1183
|
+
const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1184
|
+
n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
|
|
1069
1185
|
}
|
|
1070
1186
|
}
|
|
1071
1187
|
}
|
|
@@ -1082,31 +1198,31 @@ class q {
|
|
|
1082
1198
|
secondPhasePreProcess(t) {
|
|
1083
1199
|
for (let e = 0; e < t.length - 1; e++)
|
|
1084
1200
|
for (let n = e + 1; n < t.length; n++) {
|
|
1085
|
-
const
|
|
1086
|
-
if (
|
|
1087
|
-
t[e] = [], t[n] =
|
|
1201
|
+
const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
|
|
1202
|
+
if (r) {
|
|
1203
|
+
t[e] = [], t[n] = r;
|
|
1088
1204
|
break;
|
|
1089
1205
|
}
|
|
1090
1206
|
}
|
|
1091
1207
|
return t.filter((e) => e.length);
|
|
1092
1208
|
}
|
|
1093
1209
|
partsMatch(t, e, n = !1) {
|
|
1094
|
-
let
|
|
1095
|
-
for (;
|
|
1096
|
-
if (t[
|
|
1097
|
-
o.push(a === "b" ? e[
|
|
1098
|
-
else if (n && t[
|
|
1099
|
-
o.push(t[
|
|
1100
|
-
else if (n && e[
|
|
1101
|
-
o.push(e[
|
|
1102
|
-
else if (t[
|
|
1210
|
+
let r = 0, i = 0, o = [], a = "";
|
|
1211
|
+
for (; r < t.length && i < e.length; )
|
|
1212
|
+
if (t[r] === e[i])
|
|
1213
|
+
o.push(a === "b" ? e[i] : t[r]), r++, i++;
|
|
1214
|
+
else if (n && t[r] === "**" && e[i] === t[r + 1])
|
|
1215
|
+
o.push(t[r]), r++;
|
|
1216
|
+
else if (n && e[i] === "**" && t[r] === e[i + 1])
|
|
1217
|
+
o.push(e[i]), i++;
|
|
1218
|
+
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1103
1219
|
if (a === "b")
|
|
1104
1220
|
return !1;
|
|
1105
|
-
a = "a", o.push(t[
|
|
1106
|
-
} else if (e[
|
|
1221
|
+
a = "a", o.push(t[r]), r++, i++;
|
|
1222
|
+
} else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
|
|
1107
1223
|
if (a === "a")
|
|
1108
1224
|
return !1;
|
|
1109
|
-
a = "b", o.push(e[
|
|
1225
|
+
a = "b", o.push(e[i]), r++, i++;
|
|
1110
1226
|
} else
|
|
1111
1227
|
return !1;
|
|
1112
1228
|
return t.length === e.length && o;
|
|
@@ -1116,7 +1232,7 @@ class q {
|
|
|
1116
1232
|
return;
|
|
1117
1233
|
const t = this.pattern;
|
|
1118
1234
|
let e = !1, n = 0;
|
|
1119
|
-
for (let
|
|
1235
|
+
for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
|
|
1120
1236
|
e = !e, n++;
|
|
1121
1237
|
n && (this.pattern = t.slice(n)), this.negate = e;
|
|
1122
1238
|
}
|
|
@@ -1126,36 +1242,36 @@ class q {
|
|
|
1126
1242
|
// out of pattern, then that's fine, as long as all
|
|
1127
1243
|
// the parts match.
|
|
1128
1244
|
matchOne(t, e, n = !1) {
|
|
1129
|
-
const
|
|
1245
|
+
const r = this.options;
|
|
1130
1246
|
if (this.isWindows) {
|
|
1131
|
-
const
|
|
1247
|
+
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;
|
|
1132
1248
|
if (typeof x == "number" && typeof m == "number") {
|
|
1133
|
-
const [
|
|
1134
|
-
|
|
1249
|
+
const [T, H] = [t[x], e[m]];
|
|
1250
|
+
T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1135
1251
|
}
|
|
1136
1252
|
}
|
|
1137
|
-
const { optimizationLevel:
|
|
1138
|
-
|
|
1253
|
+
const { optimizationLevel: i = 1 } = this.options;
|
|
1254
|
+
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1139
1255
|
for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
|
|
1140
1256
|
this.debug("matchOne loop");
|
|
1141
1257
|
var c = e[a], f = t[o];
|
|
1142
1258
|
if (this.debug(e, c, f), c === !1)
|
|
1143
1259
|
return !1;
|
|
1144
|
-
if (c ===
|
|
1260
|
+
if (c === O) {
|
|
1145
1261
|
this.debug("GLOBSTAR", [e, c, f]);
|
|
1146
1262
|
var u = o, d = a + 1;
|
|
1147
1263
|
if (d === h) {
|
|
1148
1264
|
for (this.debug("** at the end"); o < l; o++)
|
|
1149
|
-
if (t[o] === "." || t[o] === ".." || !
|
|
1265
|
+
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1150
1266
|
return !1;
|
|
1151
1267
|
return !0;
|
|
1152
1268
|
}
|
|
1153
1269
|
for (; u < l; ) {
|
|
1154
|
-
var
|
|
1270
|
+
var g = t[u];
|
|
1155
1271
|
if (this.debug(\`
|
|
1156
|
-
globstar while\`, t, u, e, d,
|
|
1157
|
-
return this.debug("globstar found match!", u, l,
|
|
1158
|
-
if (
|
|
1272
|
+
globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1273
|
+
return this.debug("globstar found match!", u, l, g), !0;
|
|
1274
|
+
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1159
1275
|
this.debug("dot detected!", t, u, e, d);
|
|
1160
1276
|
break;
|
|
1161
1277
|
}
|
|
@@ -1164,8 +1280,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1164
1280
|
return !!(n && (this.debug(\`
|
|
1165
1281
|
>>> no match, partial?\`, t, u, e, d), u === l));
|
|
1166
1282
|
}
|
|
1167
|
-
let
|
|
1168
|
-
if (typeof c == "string" ? (
|
|
1283
|
+
let p;
|
|
1284
|
+
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)
|
|
1169
1285
|
return !1;
|
|
1170
1286
|
}
|
|
1171
1287
|
if (o === l && a === h)
|
|
@@ -1177,19 +1293,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1177
1293
|
throw new Error("wtf?");
|
|
1178
1294
|
}
|
|
1179
1295
|
braceExpand() {
|
|
1180
|
-
return
|
|
1296
|
+
return Lt(this.pattern, this.options);
|
|
1181
1297
|
}
|
|
1182
1298
|
parse(t) {
|
|
1183
|
-
|
|
1299
|
+
Z(t);
|
|
1184
1300
|
const e = this.options;
|
|
1185
1301
|
if (t === "**")
|
|
1186
|
-
return
|
|
1302
|
+
return O;
|
|
1187
1303
|
if (t === "")
|
|
1188
1304
|
return "";
|
|
1189
|
-
let n,
|
|
1190
|
-
(n = t.match(
|
|
1191
|
-
const
|
|
1192
|
-
return
|
|
1305
|
+
let n, r = null;
|
|
1306
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : ze : 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 ? _e : We : (n = t.match(je)) && (r = Ue);
|
|
1307
|
+
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1308
|
+
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1193
1309
|
}
|
|
1194
1310
|
makeRe() {
|
|
1195
1311
|
if (this.regexp || this.regexp === !1)
|
|
@@ -1197,23 +1313,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1197
1313
|
const t = this.set;
|
|
1198
1314
|
if (!t.length)
|
|
1199
1315
|
return this.regexp = !1, this.regexp;
|
|
1200
|
-
const e = this.options, n = e.noglobstar ?
|
|
1201
|
-
let
|
|
1316
|
+
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1317
|
+
let i = t.map((l) => {
|
|
1202
1318
|
const h = l.map((c) => {
|
|
1203
1319
|
if (c instanceof RegExp)
|
|
1204
1320
|
for (const f of c.flags.split(""))
|
|
1205
|
-
|
|
1206
|
-
return typeof c == "string" ?
|
|
1321
|
+
r.add(f);
|
|
1322
|
+
return typeof c == "string" ? as(c) : c === O ? O : c._src;
|
|
1207
1323
|
});
|
|
1208
1324
|
return h.forEach((c, f) => {
|
|
1209
1325
|
const u = h[f + 1], d = h[f - 1];
|
|
1210
|
-
c !==
|
|
1211
|
-
}), h.filter((c) => c !==
|
|
1326
|
+
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));
|
|
1327
|
+
}), h.filter((c) => c !== O).join("/");
|
|
1212
1328
|
}).join("|");
|
|
1213
1329
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1214
|
-
|
|
1330
|
+
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1215
1331
|
try {
|
|
1216
|
-
this.regexp = new RegExp(
|
|
1332
|
+
this.regexp = new RegExp(i, [...r].join(""));
|
|
1217
1333
|
} catch {
|
|
1218
1334
|
this.regexp = !1;
|
|
1219
1335
|
}
|
|
@@ -1231,17 +1347,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1231
1347
|
return !0;
|
|
1232
1348
|
const n = this.options;
|
|
1233
1349
|
this.isWindows && (t = t.split("\\\\").join("/"));
|
|
1234
|
-
const
|
|
1235
|
-
this.debug(this.pattern, "split",
|
|
1236
|
-
const
|
|
1237
|
-
this.debug(this.pattern, "set",
|
|
1238
|
-
let o =
|
|
1350
|
+
const r = this.slashSplit(t);
|
|
1351
|
+
this.debug(this.pattern, "split", r);
|
|
1352
|
+
const i = this.set;
|
|
1353
|
+
this.debug(this.pattern, "set", i);
|
|
1354
|
+
let o = r[r.length - 1];
|
|
1239
1355
|
if (!o)
|
|
1240
|
-
for (let a =
|
|
1241
|
-
o =
|
|
1242
|
-
for (let a = 0; a <
|
|
1243
|
-
const l =
|
|
1244
|
-
let h =
|
|
1356
|
+
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1357
|
+
o = r[a];
|
|
1358
|
+
for (let a = 0; a < i.length; a++) {
|
|
1359
|
+
const l = i[a];
|
|
1360
|
+
let h = r;
|
|
1245
1361
|
if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
|
|
1246
1362
|
return n.flipNegate ? !0 : !this.negate;
|
|
1247
1363
|
}
|
|
@@ -1252,110 +1368,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1252
1368
|
}
|
|
1253
1369
|
}
|
|
1254
1370
|
y.AST = E;
|
|
1255
|
-
y.Minimatch =
|
|
1256
|
-
y.escape =
|
|
1257
|
-
y.unescape =
|
|
1258
|
-
function
|
|
1371
|
+
y.Minimatch = X;
|
|
1372
|
+
y.escape = Te;
|
|
1373
|
+
y.unescape = k;
|
|
1374
|
+
function cs() {
|
|
1259
1375
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1260
|
-
throw new
|
|
1376
|
+
throw new Qt();
|
|
1261
1377
|
}
|
|
1262
|
-
async function
|
|
1378
|
+
async function z(s, t, e) {
|
|
1263
1379
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1264
1380
|
}
|
|
1265
|
-
function
|
|
1381
|
+
function M(s) {
|
|
1266
1382
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1267
1383
|
}
|
|
1268
|
-
function
|
|
1384
|
+
function lt(s) {
|
|
1269
1385
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1270
1386
|
}
|
|
1271
|
-
function
|
|
1272
|
-
const t =
|
|
1387
|
+
function it(s) {
|
|
1388
|
+
const t = M(s);
|
|
1273
1389
|
return t[t.length - 1] || "";
|
|
1274
1390
|
}
|
|
1275
|
-
function
|
|
1276
|
-
const t =
|
|
1277
|
-
return t.pop(),
|
|
1391
|
+
function et(s) {
|
|
1392
|
+
const t = M(s);
|
|
1393
|
+
return t.pop(), lt(t);
|
|
1278
1394
|
}
|
|
1279
|
-
function
|
|
1395
|
+
function G(s) {
|
|
1280
1396
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1281
1397
|
}
|
|
1282
|
-
function
|
|
1398
|
+
function ls(s, t = !1) {
|
|
1283
1399
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1284
1400
|
}
|
|
1285
|
-
function
|
|
1401
|
+
function st(s, t) {
|
|
1286
1402
|
return y(s, t, {
|
|
1287
1403
|
dot: !0,
|
|
1288
1404
|
matchBase: !0
|
|
1289
1405
|
});
|
|
1290
1406
|
}
|
|
1291
|
-
function
|
|
1292
|
-
const t =
|
|
1293
|
-
for (const
|
|
1294
|
-
if (!(
|
|
1295
|
-
if (
|
|
1407
|
+
function Et(s) {
|
|
1408
|
+
const t = G(s), e = M(t), n = [];
|
|
1409
|
+
for (const r of e)
|
|
1410
|
+
if (!(r === "." || r === ""))
|
|
1411
|
+
if (r === "..") {
|
|
1296
1412
|
if (n.length === 0)
|
|
1297
1413
|
continue;
|
|
1298
1414
|
n.pop();
|
|
1299
1415
|
} else
|
|
1300
|
-
n.push(
|
|
1301
|
-
return
|
|
1416
|
+
n.push(r);
|
|
1417
|
+
return lt(n);
|
|
1302
1418
|
}
|
|
1303
|
-
async function
|
|
1419
|
+
async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1304
1420
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1305
1421
|
throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
|
|
1306
|
-
const n = new Uint8Array(s),
|
|
1307
|
-
return Array.from(new Uint8Array(
|
|
1422
|
+
const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
|
|
1423
|
+
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1308
1424
|
}
|
|
1309
|
-
async function
|
|
1425
|
+
async function us(s) {
|
|
1310
1426
|
const t = await s.arrayBuffer();
|
|
1311
1427
|
return new Uint8Array(t);
|
|
1312
1428
|
}
|
|
1313
|
-
async function
|
|
1314
|
-
const n =
|
|
1315
|
-
return
|
|
1316
|
-
const
|
|
1317
|
-
e.useTrash;
|
|
1429
|
+
async function fs(s, t, e = {}) {
|
|
1430
|
+
const n = it(t);
|
|
1431
|
+
return z(t, "exclusive", async () => {
|
|
1432
|
+
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1318
1433
|
try {
|
|
1319
|
-
await s.removeEntry(n, { recursive:
|
|
1434
|
+
await s.removeEntry(n, { recursive: r });
|
|
1320
1435
|
} catch (o) {
|
|
1321
1436
|
if (o.name === "NotFoundError") {
|
|
1322
|
-
if (!
|
|
1323
|
-
throw new
|
|
1324
|
-
} else throw o.name === "InvalidModificationError" ? new
|
|
1437
|
+
if (!i)
|
|
1438
|
+
throw new F("file", t, o);
|
|
1439
|
+
} else throw o.name === "InvalidModificationError" ? new rt("clear", t, o) : o.name === "TypeMismatchError" && !r ? new L("file", "directory", t, o) : new rt("remove", t, o);
|
|
1325
1440
|
}
|
|
1326
1441
|
});
|
|
1327
1442
|
}
|
|
1328
|
-
function
|
|
1443
|
+
function St(s, t, e, n) {
|
|
1329
1444
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1330
|
-
throw new
|
|
1445
|
+
throw new N("argument", "Invalid offset or length");
|
|
1331
1446
|
if (t < 0 || e < 0)
|
|
1332
|
-
throw new
|
|
1447
|
+
throw new N("argument", "Negative offset or length not allowed");
|
|
1333
1448
|
if (t + e > s)
|
|
1334
|
-
throw new
|
|
1449
|
+
throw new N("overflow", "Operation would overflow buffer");
|
|
1335
1450
|
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1336
|
-
throw new
|
|
1451
|
+
throw new N("argument", "Invalid position");
|
|
1337
1452
|
}
|
|
1338
|
-
function
|
|
1453
|
+
function xt(s, t, e) {
|
|
1339
1454
|
try {
|
|
1340
1455
|
t.flush(), t.close();
|
|
1341
1456
|
} catch (n) {
|
|
1342
1457
|
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1343
1458
|
}
|
|
1344
1459
|
}
|
|
1345
|
-
function
|
|
1460
|
+
function ds(s, t, e) {
|
|
1346
1461
|
if (s >= e)
|
|
1347
1462
|
return { isEOF: !0, actualLength: 0 };
|
|
1348
1463
|
const n = Math.min(t, e - s);
|
|
1349
1464
|
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1350
1465
|
}
|
|
1351
|
-
async function
|
|
1466
|
+
async function ps(s, t) {
|
|
1352
1467
|
try {
|
|
1353
1468
|
return await s.createSyncAccessHandle();
|
|
1354
1469
|
} catch (e) {
|
|
1355
|
-
throw
|
|
1470
|
+
throw A(e, { path: t, isDirectory: !1 });
|
|
1356
1471
|
}
|
|
1357
1472
|
}
|
|
1358
|
-
class
|
|
1473
|
+
class gs {
|
|
1359
1474
|
/** Root directory handle for the file system */
|
|
1360
1475
|
root;
|
|
1361
1476
|
/** Map of watched paths and options */
|
|
@@ -1369,7 +1484,7 @@ class ss {
|
|
|
1369
1484
|
root: "/",
|
|
1370
1485
|
namespace: "",
|
|
1371
1486
|
maxFileSize: 50 * 1024 * 1024,
|
|
1372
|
-
hashAlgorithm:
|
|
1487
|
+
hashAlgorithm: "etag",
|
|
1373
1488
|
broadcastChannel: "opfs-worker"
|
|
1374
1489
|
};
|
|
1375
1490
|
/** Map of open file descriptors to their metadata */
|
|
@@ -1383,7 +1498,7 @@ class ss {
|
|
|
1383
1498
|
_getFileDescriptor(t) {
|
|
1384
1499
|
const e = this.openFiles.get(t);
|
|
1385
1500
|
if (!e)
|
|
1386
|
-
throw new
|
|
1501
|
+
throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
|
|
1387
1502
|
return e;
|
|
1388
1503
|
}
|
|
1389
1504
|
/**
|
|
@@ -1399,25 +1514,25 @@ class ss {
|
|
|
1399
1514
|
if (!this.options.broadcastChannel)
|
|
1400
1515
|
return;
|
|
1401
1516
|
const e = t.path;
|
|
1402
|
-
if (![...this.watchers.values()].some((
|
|
1517
|
+
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))))
|
|
1403
1518
|
return;
|
|
1404
|
-
let
|
|
1519
|
+
let r;
|
|
1405
1520
|
if (this.options.hashAlgorithm)
|
|
1406
1521
|
try {
|
|
1407
|
-
|
|
1522
|
+
r = (await this.stat(e)).hash;
|
|
1408
1523
|
} catch {
|
|
1409
1524
|
}
|
|
1410
1525
|
try {
|
|
1411
1526
|
this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
|
|
1412
|
-
const
|
|
1527
|
+
const i = {
|
|
1413
1528
|
namespace: this.options.namespace,
|
|
1414
1529
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1415
1530
|
...t,
|
|
1416
|
-
...
|
|
1531
|
+
...r && { hash: r }
|
|
1417
1532
|
};
|
|
1418
|
-
this.broadcastChannel.postMessage(
|
|
1419
|
-
} catch (
|
|
1420
|
-
console.warn("Failed to send event via BroadcastChannel:",
|
|
1533
|
+
this.broadcastChannel.postMessage(i);
|
|
1534
|
+
} catch (i) {
|
|
1535
|
+
console.warn("Failed to send event via BroadcastChannel:", i);
|
|
1421
1536
|
}
|
|
1422
1537
|
}
|
|
1423
1538
|
/**
|
|
@@ -1431,7 +1546,7 @@ class ss {
|
|
|
1431
1546
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1432
1547
|
*/
|
|
1433
1548
|
constructor(t) {
|
|
1434
|
-
|
|
1549
|
+
cs(), t && this.setOptions(t);
|
|
1435
1550
|
}
|
|
1436
1551
|
/**
|
|
1437
1552
|
* Initialize the file system within a given directory
|
|
@@ -1458,10 +1573,10 @@ class ss {
|
|
|
1458
1573
|
const t = this.options.root;
|
|
1459
1574
|
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
|
|
1460
1575
|
try {
|
|
1461
|
-
const
|
|
1462
|
-
this.root = t === "/" ?
|
|
1463
|
-
} catch (
|
|
1464
|
-
n(new
|
|
1576
|
+
const r = await navigator.storage.getDirectory();
|
|
1577
|
+
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1578
|
+
} catch (r) {
|
|
1579
|
+
n(new re(t, r));
|
|
1465
1580
|
} finally {
|
|
1466
1581
|
this.mountingPromise = null;
|
|
1467
1582
|
}
|
|
@@ -1478,7 +1593,7 @@ class ss {
|
|
|
1478
1593
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1479
1594
|
*/
|
|
1480
1595
|
async setOptions(t) {
|
|
1481
|
-
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 =
|
|
1596
|
+
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());
|
|
1482
1597
|
}
|
|
1483
1598
|
/**
|
|
1484
1599
|
* Get a directory handle from a path
|
|
@@ -1499,11 +1614,11 @@ class ss {
|
|
|
1499
1614
|
* \`\`\`
|
|
1500
1615
|
*/
|
|
1501
1616
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1502
|
-
const
|
|
1503
|
-
let
|
|
1504
|
-
for (const o of
|
|
1505
|
-
|
|
1506
|
-
return
|
|
1617
|
+
const r = Array.isArray(t) ? t : M(t);
|
|
1618
|
+
let i = n;
|
|
1619
|
+
for (const o of r)
|
|
1620
|
+
i = await i.getDirectoryHandle(o, { create: e });
|
|
1621
|
+
return i;
|
|
1507
1622
|
}
|
|
1508
1623
|
/**
|
|
1509
1624
|
* Get a file handle from a path
|
|
@@ -1525,11 +1640,11 @@ class ss {
|
|
|
1525
1640
|
* \`\`\`
|
|
1526
1641
|
*/
|
|
1527
1642
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1528
|
-
const
|
|
1529
|
-
if (
|
|
1530
|
-
throw new
|
|
1531
|
-
const
|
|
1532
|
-
return (await this.getDirectoryHandle(
|
|
1643
|
+
const r = M(t);
|
|
1644
|
+
if (r.length === 0)
|
|
1645
|
+
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1646
|
+
const i = r.pop();
|
|
1647
|
+
return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
|
|
1533
1648
|
}
|
|
1534
1649
|
/**
|
|
1535
1650
|
* Get a complete index of all files and directories in the file system
|
|
@@ -1552,9 +1667,9 @@ class ss {
|
|
|
1552
1667
|
*/
|
|
1553
1668
|
async index() {
|
|
1554
1669
|
const t = /* @__PURE__ */ new Map(), e = async (n) => {
|
|
1555
|
-
const
|
|
1556
|
-
for (const
|
|
1557
|
-
const o = \`\${n === "/" ? "" : n}/\${
|
|
1670
|
+
const r = await this.readDir(n);
|
|
1671
|
+
for (const i of r) {
|
|
1672
|
+
const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
|
|
1558
1673
|
try {
|
|
1559
1674
|
const a = await this.stat(o);
|
|
1560
1675
|
t.set(o, a), a.isDirectory && await e(o);
|
|
@@ -1594,17 +1709,17 @@ class ss {
|
|
|
1594
1709
|
async readFile(t) {
|
|
1595
1710
|
await this.mount();
|
|
1596
1711
|
try {
|
|
1597
|
-
return await
|
|
1712
|
+
return await z(t, "shared", async () => {
|
|
1598
1713
|
const e = await this.open(t);
|
|
1599
1714
|
try {
|
|
1600
|
-
const { size: n } = await this.fstat(e),
|
|
1601
|
-
return n > 0 && await this.read(e,
|
|
1715
|
+
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1716
|
+
return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
|
|
1602
1717
|
} finally {
|
|
1603
1718
|
await this.close(e);
|
|
1604
1719
|
}
|
|
1605
1720
|
});
|
|
1606
1721
|
} catch (e) {
|
|
1607
|
-
throw new
|
|
1722
|
+
throw new F("file", t, e);
|
|
1608
1723
|
}
|
|
1609
1724
|
}
|
|
1610
1725
|
/**
|
|
@@ -1632,14 +1747,14 @@ class ss {
|
|
|
1632
1747
|
async writeFile(t, e) {
|
|
1633
1748
|
await this.mount();
|
|
1634
1749
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1635
|
-
await
|
|
1636
|
-
const
|
|
1750
|
+
await z(t, "exclusive", async () => {
|
|
1751
|
+
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1637
1752
|
try {
|
|
1638
|
-
await this.write(
|
|
1753
|
+
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1639
1754
|
} finally {
|
|
1640
|
-
await this.close(
|
|
1755
|
+
await this.close(i);
|
|
1641
1756
|
}
|
|
1642
|
-
await this.notifyChange({ path: t, type:
|
|
1757
|
+
await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
|
|
1643
1758
|
});
|
|
1644
1759
|
}
|
|
1645
1760
|
/**
|
|
@@ -1667,15 +1782,15 @@ class ss {
|
|
|
1667
1782
|
async appendFile(t, e) {
|
|
1668
1783
|
await this.mount();
|
|
1669
1784
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1670
|
-
await
|
|
1671
|
-
const
|
|
1785
|
+
await z(t, "exclusive", async () => {
|
|
1786
|
+
const r = await this.open(t, { create: !0 });
|
|
1672
1787
|
try {
|
|
1673
|
-
const { size:
|
|
1674
|
-
await this.write(
|
|
1788
|
+
const { size: i } = await this.fstat(r);
|
|
1789
|
+
await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
|
|
1675
1790
|
} finally {
|
|
1676
|
-
await this.close(
|
|
1791
|
+
await this.close(r);
|
|
1677
1792
|
}
|
|
1678
|
-
await this.notifyChange({ path: t, type:
|
|
1793
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
|
|
1679
1794
|
});
|
|
1680
1795
|
}
|
|
1681
1796
|
/**
|
|
@@ -1701,22 +1816,17 @@ class ss {
|
|
|
1701
1816
|
*/
|
|
1702
1817
|
async mkdir(t, e) {
|
|
1703
1818
|
await this.mount();
|
|
1704
|
-
const n = e?.recursive ?? !1,
|
|
1705
|
-
let
|
|
1706
|
-
for (let o = 0; o <
|
|
1707
|
-
const a =
|
|
1819
|
+
const n = e?.recursive ?? !1, r = M(t);
|
|
1820
|
+
let i = this.root;
|
|
1821
|
+
for (let o = 0; o < r.length; o++) {
|
|
1822
|
+
const a = r[o];
|
|
1708
1823
|
try {
|
|
1709
|
-
|
|
1824
|
+
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1710
1825
|
} catch (l) {
|
|
1711
|
-
throw l.name === "NotFoundError" ? new
|
|
1712
|
-
\`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
|
|
1713
|
-
"ENOENT",
|
|
1714
|
-
void 0,
|
|
1715
|
-
l
|
|
1716
|
-
) : 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);
|
|
1826
|
+
throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new L("directory", "file", a, l) : new Q("create directory", a, l);
|
|
1717
1827
|
}
|
|
1718
1828
|
}
|
|
1719
|
-
await this.notifyChange({ path: t, type:
|
|
1829
|
+
await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
|
|
1720
1830
|
}
|
|
1721
1831
|
/**
|
|
1722
1832
|
* Get file or directory statistics
|
|
@@ -1750,9 +1860,11 @@ class ss {
|
|
|
1750
1860
|
isFile: !1,
|
|
1751
1861
|
isDirectory: !0
|
|
1752
1862
|
};
|
|
1753
|
-
const e =
|
|
1863
|
+
const e = it(t);
|
|
1864
|
+
let n;
|
|
1754
1865
|
try {
|
|
1755
|
-
|
|
1866
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1867
|
+
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1756
1868
|
kind: "file",
|
|
1757
1869
|
size: o.size,
|
|
1758
1870
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1760,17 +1872,21 @@ class ss {
|
|
|
1760
1872
|
isFile: !0,
|
|
1761
1873
|
isDirectory: !1
|
|
1762
1874
|
};
|
|
1763
|
-
if (
|
|
1875
|
+
if (r === "etag")
|
|
1876
|
+
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1877
|
+
else if (typeof r == "string")
|
|
1764
1878
|
try {
|
|
1765
|
-
const l = await
|
|
1879
|
+
const l = await hs(o, r, this.options.maxFileSize);
|
|
1766
1880
|
a.hash = l;
|
|
1767
1881
|
} catch (l) {
|
|
1768
1882
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
1769
1883
|
}
|
|
1770
1884
|
return a;
|
|
1771
1885
|
} catch (r) {
|
|
1772
|
-
if (r.name
|
|
1773
|
-
throw new
|
|
1886
|
+
if (r.name === "NotFoundError")
|
|
1887
|
+
throw new F("file", t, r);
|
|
1888
|
+
if (r.name !== "TypeMismatchError")
|
|
1889
|
+
throw new Q("stat", t, r);
|
|
1774
1890
|
}
|
|
1775
1891
|
try {
|
|
1776
1892
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1782,7 +1898,7 @@ class ss {
|
|
|
1782
1898
|
isDirectory: !0
|
|
1783
1899
|
};
|
|
1784
1900
|
} catch (r) {
|
|
1785
|
-
throw
|
|
1901
|
+
throw new Q("stat", t, r);
|
|
1786
1902
|
}
|
|
1787
1903
|
}
|
|
1788
1904
|
/**
|
|
@@ -1806,11 +1922,11 @@ class ss {
|
|
|
1806
1922
|
async readDir(t) {
|
|
1807
1923
|
await this.mount();
|
|
1808
1924
|
const e = await this.getDirectoryHandle(t, !1), n = [];
|
|
1809
|
-
for await (const [
|
|
1810
|
-
const o =
|
|
1925
|
+
for await (const [r, i] of e.entries()) {
|
|
1926
|
+
const o = i.kind === "file";
|
|
1811
1927
|
n.push({
|
|
1812
|
-
name:
|
|
1813
|
-
kind:
|
|
1928
|
+
name: r,
|
|
1929
|
+
kind: i.kind,
|
|
1814
1930
|
isFile: o,
|
|
1815
1931
|
isDirectory: !o
|
|
1816
1932
|
});
|
|
@@ -1834,26 +1950,26 @@ class ss {
|
|
|
1834
1950
|
async exists(t) {
|
|
1835
1951
|
if (await this.mount(), t === "/")
|
|
1836
1952
|
return !0;
|
|
1837
|
-
const e =
|
|
1953
|
+
const e = it(t);
|
|
1838
1954
|
let n = null;
|
|
1839
1955
|
try {
|
|
1840
|
-
n = await this.getDirectoryHandle(
|
|
1841
|
-
} catch (
|
|
1842
|
-
if (n = null,
|
|
1843
|
-
throw
|
|
1956
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1957
|
+
} catch (r) {
|
|
1958
|
+
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1959
|
+
throw r;
|
|
1844
1960
|
}
|
|
1845
1961
|
if (!n || !e)
|
|
1846
1962
|
return !1;
|
|
1847
1963
|
try {
|
|
1848
1964
|
return await n.getFileHandle(e, { create: !1 }), !0;
|
|
1849
|
-
} catch (
|
|
1850
|
-
if (
|
|
1851
|
-
throw
|
|
1965
|
+
} catch (r) {
|
|
1966
|
+
if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1967
|
+
throw r;
|
|
1852
1968
|
try {
|
|
1853
1969
|
return await n.getDirectoryHandle(e, { create: !1 }), !0;
|
|
1854
|
-
} catch (
|
|
1855
|
-
if (
|
|
1856
|
-
throw
|
|
1970
|
+
} catch (i) {
|
|
1971
|
+
if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1972
|
+
throw i;
|
|
1857
1973
|
return !1;
|
|
1858
1974
|
}
|
|
1859
1975
|
}
|
|
@@ -1882,12 +1998,12 @@ class ss {
|
|
|
1882
1998
|
try {
|
|
1883
1999
|
const e = await this.readDir(t);
|
|
1884
2000
|
for (const n of e) {
|
|
1885
|
-
const
|
|
1886
|
-
await this.remove(
|
|
2001
|
+
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
2002
|
+
await this.remove(r, { recursive: !0 });
|
|
1887
2003
|
}
|
|
1888
|
-
await this.notifyChange({ path: t, type:
|
|
2004
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
|
|
1889
2005
|
} catch (e) {
|
|
1890
|
-
throw e instanceof
|
|
2006
|
+
throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
|
|
1891
2007
|
}
|
|
1892
2008
|
}
|
|
1893
2009
|
/**
|
|
@@ -1916,9 +2032,9 @@ class ss {
|
|
|
1916
2032
|
*/
|
|
1917
2033
|
async remove(t, e) {
|
|
1918
2034
|
if (await this.mount(), t === "/")
|
|
1919
|
-
throw new
|
|
1920
|
-
const { recursive: n = !1, force:
|
|
1921
|
-
await
|
|
2035
|
+
throw new rt("root", t);
|
|
2036
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
|
|
2037
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
|
|
1922
2038
|
}
|
|
1923
2039
|
/**
|
|
1924
2040
|
* Resolve a path to an absolute path
|
|
@@ -1941,12 +2057,12 @@ class ss {
|
|
|
1941
2057
|
async realpath(t) {
|
|
1942
2058
|
await this.mount();
|
|
1943
2059
|
try {
|
|
1944
|
-
const e =
|
|
2060
|
+
const e = Et(t);
|
|
1945
2061
|
if (!await this.exists(e))
|
|
1946
|
-
throw new
|
|
2062
|
+
throw new F("file", e);
|
|
1947
2063
|
return e;
|
|
1948
2064
|
} catch (e) {
|
|
1949
|
-
throw e instanceof
|
|
2065
|
+
throw e instanceof w ? e : A(e, { path: t });
|
|
1950
2066
|
}
|
|
1951
2067
|
}
|
|
1952
2068
|
/**
|
|
@@ -1974,12 +2090,12 @@ class ss {
|
|
|
1974
2090
|
async rename(t, e, n) {
|
|
1975
2091
|
await this.mount();
|
|
1976
2092
|
try {
|
|
1977
|
-
const
|
|
1978
|
-
if (await this.exists(e) && !
|
|
1979
|
-
throw new
|
|
1980
|
-
await this.copy(t, e, { recursive: !0, overwrite:
|
|
1981
|
-
} catch (
|
|
1982
|
-
throw
|
|
2093
|
+
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2094
|
+
if (await this.exists(e) && !r)
|
|
2095
|
+
throw new K(e);
|
|
2096
|
+
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 });
|
|
2097
|
+
} catch (r) {
|
|
2098
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
1983
2099
|
}
|
|
1984
2100
|
}
|
|
1985
2101
|
/**
|
|
@@ -2010,26 +2126,26 @@ class ss {
|
|
|
2010
2126
|
async copy(t, e, n) {
|
|
2011
2127
|
await this.mount();
|
|
2012
2128
|
try {
|
|
2013
|
-
const
|
|
2129
|
+
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2014
2130
|
if (!await this.exists(t))
|
|
2015
|
-
throw new
|
|
2016
|
-
if (await this.exists(e) && !
|
|
2017
|
-
throw new
|
|
2131
|
+
throw new F("source", t);
|
|
2132
|
+
if (await this.exists(e) && !i)
|
|
2133
|
+
throw new K(e);
|
|
2018
2134
|
if ((await this.stat(t)).isFile) {
|
|
2019
2135
|
const h = await this.readFile(t);
|
|
2020
2136
|
await this.writeFile(e, h);
|
|
2021
2137
|
} else {
|
|
2022
|
-
if (!
|
|
2023
|
-
throw new
|
|
2138
|
+
if (!r)
|
|
2139
|
+
throw new L("file", "directory", t);
|
|
2024
2140
|
await this.mkdir(e, { recursive: !0 });
|
|
2025
2141
|
const h = await this.readDir(t);
|
|
2026
2142
|
for (const c of h) {
|
|
2027
2143
|
const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
|
|
2028
|
-
await this.copy(f, u, { recursive: !0, overwrite:
|
|
2144
|
+
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2029
2145
|
}
|
|
2030
2146
|
}
|
|
2031
|
-
} catch (
|
|
2032
|
-
throw
|
|
2147
|
+
} catch (r) {
|
|
2148
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
2033
2149
|
}
|
|
2034
2150
|
}
|
|
2035
2151
|
/**
|
|
@@ -2059,9 +2175,9 @@ class ss {
|
|
|
2059
2175
|
*/
|
|
2060
2176
|
async watch(t, e) {
|
|
2061
2177
|
if (!this.options.broadcastChannel)
|
|
2062
|
-
throw new
|
|
2178
|
+
throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
2063
2179
|
const n = {
|
|
2064
|
-
pattern:
|
|
2180
|
+
pattern: ls(t, e?.recursive ?? !0),
|
|
2065
2181
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2066
2182
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2067
2183
|
};
|
|
@@ -2102,15 +2218,15 @@ class ss {
|
|
|
2102
2218
|
*/
|
|
2103
2219
|
async open(t, e) {
|
|
2104
2220
|
await this.mount();
|
|
2105
|
-
const { create: n = !1, exclusive:
|
|
2221
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
|
|
2106
2222
|
try {
|
|
2107
|
-
return n &&
|
|
2223
|
+
return n && r ? await z(o, "exclusive", async () => {
|
|
2108
2224
|
if (await this.exists(o))
|
|
2109
|
-
throw new
|
|
2110
|
-
return this._openFile(o, n,
|
|
2111
|
-
}) : await this._openFile(o, n,
|
|
2225
|
+
throw new K(o);
|
|
2226
|
+
return this._openFile(o, n, i);
|
|
2227
|
+
}) : await this._openFile(o, n, i);
|
|
2112
2228
|
} catch (a) {
|
|
2113
|
-
throw a instanceof
|
|
2229
|
+
throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
|
|
2114
2230
|
}
|
|
2115
2231
|
}
|
|
2116
2232
|
/**
|
|
@@ -2118,19 +2234,19 @@ class ss {
|
|
|
2118
2234
|
* @private
|
|
2119
2235
|
*/
|
|
2120
2236
|
async _openFile(t, e, n) {
|
|
2121
|
-
const
|
|
2237
|
+
const r = await this.getFileHandle(t, e);
|
|
2122
2238
|
try {
|
|
2123
|
-
await
|
|
2239
|
+
await r.getFile();
|
|
2124
2240
|
} catch (a) {
|
|
2125
|
-
throw a
|
|
2241
|
+
throw A(a, { path: t, isDirectory: !0 });
|
|
2126
2242
|
}
|
|
2127
|
-
const
|
|
2128
|
-
n && (
|
|
2243
|
+
const i = await ps(r, t);
|
|
2244
|
+
n && (i.truncate(0), i.flush());
|
|
2129
2245
|
const o = this.nextFd++;
|
|
2130
2246
|
return this.openFiles.set(o, {
|
|
2131
2247
|
path: t,
|
|
2132
|
-
fileHandle:
|
|
2133
|
-
syncHandle:
|
|
2248
|
+
fileHandle: r,
|
|
2249
|
+
syncHandle: i,
|
|
2134
2250
|
position: 0
|
|
2135
2251
|
}), o;
|
|
2136
2252
|
}
|
|
@@ -2150,7 +2266,7 @@ class ss {
|
|
|
2150
2266
|
*/
|
|
2151
2267
|
async close(t) {
|
|
2152
2268
|
const e = this._getFileDescriptor(t);
|
|
2153
|
-
|
|
2269
|
+
xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2154
2270
|
}
|
|
2155
2271
|
/**
|
|
2156
2272
|
* Read data from a file descriptor
|
|
@@ -2176,17 +2292,17 @@ class ss {
|
|
|
2176
2292
|
* await fs.close(fd);
|
|
2177
2293
|
* \`\`\`
|
|
2178
2294
|
*/
|
|
2179
|
-
async read(t, e, n,
|
|
2295
|
+
async read(t, e, n, r, i) {
|
|
2180
2296
|
const o = this._getFileDescriptor(t);
|
|
2181
|
-
|
|
2297
|
+
St(e.length, n, r, i);
|
|
2182
2298
|
try {
|
|
2183
|
-
const a =
|
|
2299
|
+
const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
|
|
2184
2300
|
if (h)
|
|
2185
|
-
return
|
|
2301
|
+
return B({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2186
2302
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2187
|
-
return
|
|
2303
|
+
return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2188
2304
|
} catch (a) {
|
|
2189
|
-
throw
|
|
2305
|
+
throw _("read", t, o.path, a);
|
|
2190
2306
|
}
|
|
2191
2307
|
}
|
|
2192
2308
|
/**
|
|
@@ -2210,14 +2326,14 @@ class ss {
|
|
|
2210
2326
|
* await fs.close(fd);
|
|
2211
2327
|
* \`\`\`
|
|
2212
2328
|
*/
|
|
2213
|
-
async write(t, e, n = 0,
|
|
2214
|
-
const a = this._getFileDescriptor(t), l =
|
|
2215
|
-
|
|
2329
|
+
async write(t, e, n = 0, r, i, o = !0) {
|
|
2330
|
+
const a = this._getFileDescriptor(t), l = r ?? e.length - n;
|
|
2331
|
+
St(e.length, n, l, i);
|
|
2216
2332
|
try {
|
|
2217
|
-
const h =
|
|
2218
|
-
return (
|
|
2333
|
+
const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2334
|
+
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
|
|
2219
2335
|
} catch (h) {
|
|
2220
|
-
throw
|
|
2336
|
+
throw _("write", t, a.path, h);
|
|
2221
2337
|
}
|
|
2222
2338
|
}
|
|
2223
2339
|
/**
|
|
@@ -2261,11 +2377,11 @@ class ss {
|
|
|
2261
2377
|
async ftruncate(t, e = 0) {
|
|
2262
2378
|
const n = this._getFileDescriptor(t);
|
|
2263
2379
|
if (e < 0 || !Number.isInteger(e))
|
|
2264
|
-
throw new
|
|
2380
|
+
throw new N("argument", "Invalid size");
|
|
2265
2381
|
try {
|
|
2266
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2267
|
-
} catch (
|
|
2268
|
-
throw
|
|
2382
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
|
|
2383
|
+
} catch (r) {
|
|
2384
|
+
throw _("truncate", t, n.path, r);
|
|
2269
2385
|
}
|
|
2270
2386
|
}
|
|
2271
2387
|
/**
|
|
@@ -2287,7 +2403,7 @@ class ss {
|
|
|
2287
2403
|
try {
|
|
2288
2404
|
e.syncHandle.flush();
|
|
2289
2405
|
} catch (n) {
|
|
2290
|
-
throw
|
|
2406
|
+
throw _("sync", t, e.path, n);
|
|
2291
2407
|
}
|
|
2292
2408
|
}
|
|
2293
2409
|
/**
|
|
@@ -2299,7 +2415,7 @@ class ss {
|
|
|
2299
2415
|
dispose() {
|
|
2300
2416
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2301
2417
|
for (const [t, e] of this.openFiles)
|
|
2302
|
-
|
|
2418
|
+
xt(t, e.syncHandle, e.path);
|
|
2303
2419
|
this.openFiles.clear(), this.nextFd = 1;
|
|
2304
2420
|
}
|
|
2305
2421
|
/**
|
|
@@ -2334,17 +2450,17 @@ class ss {
|
|
|
2334
2450
|
await this.mount();
|
|
2335
2451
|
try {
|
|
2336
2452
|
for (const [e, n] of t) {
|
|
2337
|
-
const
|
|
2338
|
-
let
|
|
2339
|
-
n instanceof Blob ?
|
|
2453
|
+
const r = G(e);
|
|
2454
|
+
let i;
|
|
2455
|
+
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2340
2456
|
}
|
|
2341
2457
|
} catch (e) {
|
|
2342
|
-
throw e instanceof
|
|
2458
|
+
throw e instanceof w ? e : A(e);
|
|
2343
2459
|
}
|
|
2344
2460
|
}
|
|
2345
2461
|
}
|
|
2346
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2347
|
-
//# sourceMappingURL=worker-
|
|
2462
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
|
|
2463
|
+
//# sourceMappingURL=worker-1Wh1cr7P.js.map
|
|
2348
2464
|
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2349
2465
|
function m(a) {
|
|
2350
2466
|
let n;
|
|
@@ -2370,7 +2486,7 @@ function m(a) {
|
|
|
2370
2486
|
function i(a) {
|
|
2371
2487
|
return a instanceof URL ? a.pathname : a;
|
|
2372
2488
|
}
|
|
2373
|
-
class
|
|
2489
|
+
class y {
|
|
2374
2490
|
#n;
|
|
2375
2491
|
promises = this;
|
|
2376
2492
|
constructor(n) {
|
|
@@ -2408,7 +2524,7 @@ class w {
|
|
|
2408
2524
|
let r;
|
|
2409
2525
|
typeof t == "string" ? r = t : t && typeof t == "object" && (r = t.encoding);
|
|
2410
2526
|
const s = await this.#n.readFile(e);
|
|
2411
|
-
return r || (r =
|
|
2527
|
+
return r || (r = h(e) ? "binary" : "utf-8"), r === "binary" ? s : l(s, r);
|
|
2412
2528
|
}
|
|
2413
2529
|
/**
|
|
2414
2530
|
* Write data to a file
|
|
@@ -2416,8 +2532,8 @@ class w {
|
|
|
2416
2532
|
async writeFile(n, t, e) {
|
|
2417
2533
|
const r = i(n);
|
|
2418
2534
|
let s;
|
|
2419
|
-
typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" ||
|
|
2420
|
-
const o = typeof t == "string" ?
|
|
2535
|
+
typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" || h(r) ? "binary" : "utf-8");
|
|
2536
|
+
const o = typeof t == "string" ? c(t, s) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2421
2537
|
return this.#n.writeFile(r, o);
|
|
2422
2538
|
}
|
|
2423
2539
|
/**
|
|
@@ -2425,8 +2541,8 @@ class w {
|
|
|
2425
2541
|
*/
|
|
2426
2542
|
async appendFile(n, t, e) {
|
|
2427
2543
|
const r = i(n);
|
|
2428
|
-
e || (e = typeof t != "string" ||
|
|
2429
|
-
const s = typeof t == "string" ?
|
|
2544
|
+
e || (e = typeof t != "string" || h(r) ? "binary" : "utf-8");
|
|
2545
|
+
const s = typeof t == "string" ? c(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2430
2546
|
return this.#n.appendFile(r, s);
|
|
2431
2547
|
}
|
|
2432
2548
|
/**
|
|
@@ -2608,59 +2724,68 @@ class w {
|
|
|
2608
2724
|
* Write text to a file with specified encoding
|
|
2609
2725
|
*/
|
|
2610
2726
|
async writeText(n, t, e = "utf-8") {
|
|
2611
|
-
const r = i(n), s =
|
|
2727
|
+
const r = i(n), s = c(t, e);
|
|
2612
2728
|
return this.#n.writeFile(r, s);
|
|
2613
2729
|
}
|
|
2614
2730
|
/**
|
|
2615
2731
|
* Append text to a file with specified encoding
|
|
2616
2732
|
*/
|
|
2617
2733
|
async appendText(n, t, e = "utf-8") {
|
|
2618
|
-
const r = i(n), s =
|
|
2734
|
+
const r = i(n), s = c(t, e);
|
|
2619
2735
|
return this.#n.appendFile(r, s);
|
|
2620
2736
|
}
|
|
2621
2737
|
}
|
|
2622
2738
|
function b(a) {
|
|
2623
|
-
return new
|
|
2739
|
+
return new y(a);
|
|
2624
2740
|
}
|
|
2625
2741
|
export {
|
|
2626
|
-
|
|
2627
|
-
S as
|
|
2628
|
-
P as
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
I as
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
z as
|
|
2642
|
-
k as
|
|
2643
|
-
M as
|
|
2644
|
-
j as
|
|
2645
|
-
|
|
2646
|
-
|
|
2742
|
+
E as AlreadyExistsError,
|
|
2743
|
+
S as BINARY_FILE_EXTENSIONS,
|
|
2744
|
+
P as DirectoryOperationError,
|
|
2745
|
+
O as ExistenceError,
|
|
2746
|
+
F as FileBusyError,
|
|
2747
|
+
A as FileSystemOperationError,
|
|
2748
|
+
T as FileTypeError,
|
|
2749
|
+
R as IOError,
|
|
2750
|
+
I as InitializationFailedError,
|
|
2751
|
+
C as OPFSError,
|
|
2752
|
+
y as OPFSFileSystem,
|
|
2753
|
+
$ as OPFSNotSupportedError,
|
|
2754
|
+
D as OperationAbortedError,
|
|
2755
|
+
_ as OperationNotSupportedError,
|
|
2756
|
+
N as PathError,
|
|
2757
|
+
z as PathResolutionFailedError,
|
|
2758
|
+
k as PermissionError,
|
|
2759
|
+
M as StorageError,
|
|
2760
|
+
j as TimeoutError,
|
|
2761
|
+
W as ValidationError,
|
|
2762
|
+
L as WatchEventType,
|
|
2763
|
+
U as basename,
|
|
2764
|
+
H as buffersEqual,
|
|
2765
|
+
B as calculateFileHash,
|
|
2766
|
+
G as calculateReadLength,
|
|
2767
|
+
q as checkOPFSSupport,
|
|
2768
|
+
Y as convertBlobToUint8Array,
|
|
2769
|
+
V as createBuffer,
|
|
2770
|
+
X as createFDError,
|
|
2771
|
+
Z as createSyncHandleSafe,
|
|
2647
2772
|
b as createWorker,
|
|
2648
2773
|
l as decodeBuffer,
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2774
|
+
J as dirname,
|
|
2775
|
+
c as encodeString,
|
|
2776
|
+
K as extname,
|
|
2777
|
+
h as isBinaryFileExtension,
|
|
2778
|
+
Q as isPathExcluded,
|
|
2779
|
+
nn as joinPath,
|
|
2780
|
+
tn as mapDomError,
|
|
2781
|
+
en as matchMinimatch,
|
|
2782
|
+
rn as normalizeMinimatch,
|
|
2783
|
+
sn as normalizePath,
|
|
2784
|
+
an as removeEntry,
|
|
2785
|
+
on as resolvePath,
|
|
2786
|
+
cn as safeCloseSyncHandle,
|
|
2787
|
+
hn as splitPath,
|
|
2788
|
+
ln as validateReadWriteArgs,
|
|
2789
|
+
pn as withLock
|
|
2665
2790
|
};
|
|
2666
2791
|
//# sourceMappingURL=index.js.map
|