opfs-worker 1.2.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/worker-1Wh1cr7P.js.map +1 -0
- package/dist/assets/worker-BeJaVyBV.js.map +1 -0
- package/dist/helpers-BuGfPAg0.js +1439 -0
- package/dist/helpers-BuGfPAg0.js.map +1 -0
- package/dist/helpers-CF7A2WQG.cjs +4 -0
- package/dist/helpers-CF7A2WQG.cjs.map +1 -0
- package/dist/helpers-CIiblZ8d.cjs +4 -0
- package/dist/helpers-CIiblZ8d.cjs.map +1 -0
- package/dist/{helpers-BXhw_-Ar.js → helpers-CKOebsbw.js} +573 -480
- package/dist/helpers-CKOebsbw.js.map +1 -0
- package/dist/index.cjs +711 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +768 -650
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +88 -89
- package/dist/raw.js.map +1 -1
- package/dist/utils/errors.d.ts +65 -22
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-BEh95XuP.js.map +0 -1
- package/dist/assets/worker-CS9nvwsF.js.map +0 -1
- package/dist/assets/worker-Dy3EFYv_.js.map +0 -1
- package/dist/helpers-04x7UBul.cjs +0 -4
- package/dist/helpers-04x7UBul.cjs.map +0 -1
- package/dist/helpers-BXhw_-Ar.js.map +0 -1
- package/dist/helpers-BwklIUit.js +0 -1329
- package/dist/helpers-BwklIUit.js.map +0 -1
- package/dist/helpers-ppMRzIAJ.cjs +0 -4
- package/dist/helpers-ppMRzIAJ.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { wrap as u } from "comlink";
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
2
|
+
import { i as h, d as l, e as c } from "./helpers-CKOebsbw.js";
|
|
3
|
+
import { A as E, M as S, D as P, E as O, F, j as A, c as T, I as R, h as C, O as I, a as $, f as D, g as _, P as N, b as z, S as k, V as M, W as j, o as L, B as W, z as U, K as H, l as B, C as G, y as q, k as V, L as Y, p as J, x as X, u as Z, n as K, m as Q, t as nn, r as tn, q as en, G as rn, v as sn, J as an, s as on, H as cn, w as hn } from "./helpers-CKOebsbw.js";
|
|
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", jt = {
|
|
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
|
+
}, _t = {
|
|
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", jt],
|
|
36
|
+
["throw", _t]
|
|
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,290 @@ 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", "
|
|
294
|
+
super("OPFS is not supported in this browser", "ENOTSUP", 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}\`, "EACCES", 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 z extends w {
|
|
328
|
+
constructor(t, e, n) {
|
|
329
|
+
const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
330
|
+
super(r, i, e, "access", n);
|
|
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
|
+
RM_FAILED: \`Failed to remove entry: \${e}\`,
|
|
363
|
+
ENOTEMPTY: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
|
|
364
|
+
EROOT: "Cannot remove root directory"
|
|
365
|
+
};
|
|
366
|
+
super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", n);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
class re extends w {
|
|
370
|
+
constructor(t, e) {
|
|
371
|
+
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
class Q extends w {
|
|
375
|
+
constructor(t, e, n) {
|
|
376
|
+
super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
class K extends w {
|
|
380
|
+
constructor(t, e) {
|
|
381
|
+
super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function j(s, t, e, n) {
|
|
385
|
+
const r = \`\${s.toUpperCase()}_FAILED\`;
|
|
386
|
+
return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
|
|
387
|
+
}
|
|
388
|
+
function A(s, t) {
|
|
389
|
+
const e = t?.path, n = t?.isDirectory;
|
|
278
390
|
switch (s.name) {
|
|
279
391
|
case "InvalidStateError":
|
|
280
|
-
return new
|
|
392
|
+
return new se(e || "unknown", s);
|
|
281
393
|
case "QuotaExceededError":
|
|
282
|
-
return new
|
|
394
|
+
return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
|
|
283
395
|
case "NotFoundError":
|
|
284
|
-
return new
|
|
396
|
+
return new F("file", e, s);
|
|
285
397
|
case "TypeMismatchError":
|
|
286
|
-
return new
|
|
398
|
+
return n !== void 0 ? n ? new z("directory", e || "unknown", s) : new z("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
|
|
287
399
|
case "NotAllowedError":
|
|
288
400
|
case "SecurityError":
|
|
289
|
-
return new
|
|
401
|
+
return new te(e, "unknown", s);
|
|
290
402
|
case "InvalidModificationError":
|
|
291
|
-
return new
|
|
403
|
+
return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
|
|
292
404
|
case "AbortError":
|
|
293
|
-
return new
|
|
405
|
+
return new ne(e || "unknown", s);
|
|
294
406
|
case "OperationError":
|
|
295
|
-
return new
|
|
407
|
+
return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
|
|
296
408
|
case "TypeError":
|
|
297
|
-
return new
|
|
409
|
+
return new Ct(e || "unknown", s);
|
|
298
410
|
default:
|
|
299
|
-
return new
|
|
411
|
+
return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
|
|
300
412
|
}
|
|
301
413
|
}
|
|
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(
|
|
414
|
+
const Ft = (s, t, e) => {
|
|
415
|
+
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);
|
|
416
|
+
return i && {
|
|
417
|
+
start: i[0],
|
|
418
|
+
end: i[1],
|
|
419
|
+
pre: e.slice(0, i[0]),
|
|
420
|
+
body: e.slice(i[0] + n.length, i[1]),
|
|
421
|
+
post: e.slice(i[1] + r.length)
|
|
310
422
|
};
|
|
311
|
-
},
|
|
423
|
+
}, ft = (s, t) => {
|
|
312
424
|
const e = t.match(s);
|
|
313
425
|
return e ? e[0] : null;
|
|
314
|
-
},
|
|
315
|
-
let n,
|
|
426
|
+
}, ie = (s, t, e) => {
|
|
427
|
+
let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
316
428
|
if (l >= 0 && h > 0) {
|
|
317
429
|
if (s === t)
|
|
318
430
|
return [l, h];
|
|
319
|
-
for (n = [],
|
|
431
|
+
for (n = [], i = e.length; c >= 0 && !a; ) {
|
|
320
432
|
if (c === l)
|
|
321
433
|
n.push(c), l = e.indexOf(s, c + 1);
|
|
322
434
|
else if (n.length === 1) {
|
|
323
435
|
const f = n.pop();
|
|
324
436
|
f !== void 0 && (a = [f, h]);
|
|
325
437
|
} else
|
|
326
|
-
|
|
438
|
+
r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
|
|
327
439
|
c = l < h && l >= 0 ? l : h;
|
|
328
440
|
}
|
|
329
|
-
n.length && o !== void 0 && (a = [
|
|
441
|
+
n.length && o !== void 0 && (a = [i, o]);
|
|
330
442
|
}
|
|
331
443
|
return a;
|
|
332
|
-
},
|
|
333
|
-
function
|
|
444
|
+
}, $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;
|
|
445
|
+
function tt(s) {
|
|
334
446
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
335
447
|
}
|
|
336
|
-
function
|
|
337
|
-
return s.replace(
|
|
448
|
+
function we(s) {
|
|
449
|
+
return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
|
|
338
450
|
}
|
|
339
|
-
function
|
|
340
|
-
return s.replace(
|
|
451
|
+
function me(s) {
|
|
452
|
+
return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
|
|
341
453
|
}
|
|
342
|
-
function
|
|
454
|
+
function Rt(s) {
|
|
343
455
|
if (!s)
|
|
344
456
|
return [""];
|
|
345
|
-
const t = [], e =
|
|
457
|
+
const t = [], e = Ft("{", "}", s);
|
|
346
458
|
if (!e)
|
|
347
459
|
return s.split(",");
|
|
348
|
-
const { pre: n, body:
|
|
349
|
-
o[o.length - 1] += "{" +
|
|
350
|
-
const a =
|
|
351
|
-
return
|
|
460
|
+
const { pre: n, body: r, post: i } = e, o = n.split(",");
|
|
461
|
+
o[o.length - 1] += "{" + r + "}";
|
|
462
|
+
const a = Rt(i);
|
|
463
|
+
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
352
464
|
}
|
|
353
|
-
function
|
|
354
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(
|
|
465
|
+
function ye(s) {
|
|
466
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
|
|
355
467
|
}
|
|
356
|
-
function
|
|
468
|
+
function Ee(s) {
|
|
357
469
|
return "{" + s + "}";
|
|
358
470
|
}
|
|
359
|
-
function
|
|
471
|
+
function Se(s) {
|
|
360
472
|
return /^-?0\\d/.test(s);
|
|
361
473
|
}
|
|
362
|
-
function
|
|
474
|
+
function xe(s, t) {
|
|
363
475
|
return s <= t;
|
|
364
476
|
}
|
|
365
|
-
function
|
|
477
|
+
function be(s, t) {
|
|
366
478
|
return s >= t;
|
|
367
479
|
}
|
|
368
480
|
function I(s, t) {
|
|
369
|
-
const e = [], n =
|
|
481
|
+
const e = [], n = Ft("{", "}", s);
|
|
370
482
|
if (!n)
|
|
371
483
|
return [s];
|
|
372
|
-
const
|
|
484
|
+
const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
|
|
373
485
|
if (/\\$$/.test(n.pre))
|
|
374
|
-
for (let o = 0; o <
|
|
375
|
-
const a =
|
|
486
|
+
for (let o = 0; o < i.length; o++) {
|
|
487
|
+
const a = r + "{" + n.body + "}" + i[o];
|
|
376
488
|
e.push(a);
|
|
377
489
|
}
|
|
378
490
|
else {
|
|
379
491
|
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
492
|
if (!l && !h)
|
|
381
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
493
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
|
|
382
494
|
let c;
|
|
383
495
|
if (l)
|
|
384
496
|
c = n.body.split(/\\.\\./);
|
|
385
|
-
else if (c =
|
|
386
|
-
return
|
|
497
|
+
else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
|
|
498
|
+
return i.map((u) => n.pre + c[0] + u);
|
|
387
499
|
let f;
|
|
388
500
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
389
|
-
const u =
|
|
390
|
-
let
|
|
391
|
-
d < u && (
|
|
392
|
-
const
|
|
501
|
+
const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
|
|
502
|
+
let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
|
|
503
|
+
d < u && (p *= -1, S = be);
|
|
504
|
+
const P = c.some(Se);
|
|
393
505
|
f = [];
|
|
394
|
-
for (let x = u; S(x, d); x +=
|
|
506
|
+
for (let x = u; S(x, d); x += p) {
|
|
395
507
|
let m;
|
|
396
508
|
if (a)
|
|
397
509
|
m = String.fromCharCode(x), m === "\\\\" && (m = "");
|
|
398
|
-
else if (m = String(x),
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
const
|
|
402
|
-
x < 0 ? m = "-" +
|
|
510
|
+
else if (m = String(x), P) {
|
|
511
|
+
const T = g - m.length;
|
|
512
|
+
if (T > 0) {
|
|
513
|
+
const H = new Array(T + 1).join("0");
|
|
514
|
+
x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
|
|
403
515
|
}
|
|
404
516
|
}
|
|
405
517
|
f.push(m);
|
|
@@ -410,19 +522,19 @@ function I(s, t) {
|
|
|
410
522
|
f.push.apply(f, I(c[u], !1));
|
|
411
523
|
}
|
|
412
524
|
for (let u = 0; u < f.length; u++)
|
|
413
|
-
for (let d = 0; d <
|
|
414
|
-
const
|
|
415
|
-
(!t || l ||
|
|
525
|
+
for (let d = 0; d < i.length; d++) {
|
|
526
|
+
const g = r + f[u] + i[d];
|
|
527
|
+
(!t || l || g) && e.push(g);
|
|
416
528
|
}
|
|
417
529
|
}
|
|
418
530
|
return e;
|
|
419
531
|
}
|
|
420
|
-
const
|
|
532
|
+
const Oe = 1024 * 64, Z = (s) => {
|
|
421
533
|
if (typeof s != "string")
|
|
422
534
|
throw new TypeError("invalid pattern");
|
|
423
|
-
if (s.length >
|
|
535
|
+
if (s.length > Oe)
|
|
424
536
|
throw new TypeError("pattern is too long");
|
|
425
|
-
},
|
|
537
|
+
}, De = {
|
|
426
538
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
427
539
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
428
540
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -437,77 +549,77 @@ const he = 1024 * 64, G = (s) => {
|
|
|
437
549
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
438
550
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
439
551
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
440
|
-
},
|
|
552
|
+
}, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
|
|
441
553
|
const e = t;
|
|
442
554
|
if (s.charAt(e) !== "[")
|
|
443
555
|
throw new Error("not in a brace expression");
|
|
444
|
-
const n = [],
|
|
445
|
-
let
|
|
446
|
-
t: for (;
|
|
447
|
-
const
|
|
448
|
-
if ((
|
|
449
|
-
h = !0,
|
|
556
|
+
const n = [], r = [];
|
|
557
|
+
let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
|
|
558
|
+
t: for (; i < s.length; ) {
|
|
559
|
+
const p = s.charAt(i);
|
|
560
|
+
if ((p === "!" || p === "^") && i === e + 1) {
|
|
561
|
+
h = !0, i++;
|
|
450
562
|
continue;
|
|
451
563
|
}
|
|
452
|
-
if (
|
|
453
|
-
c =
|
|
564
|
+
if (p === "]" && o && !l) {
|
|
565
|
+
c = i + 1;
|
|
454
566
|
break;
|
|
455
567
|
}
|
|
456
|
-
if (o = !0,
|
|
457
|
-
l = !0,
|
|
568
|
+
if (o = !0, p === "\\\\" && !l) {
|
|
569
|
+
l = !0, i++;
|
|
458
570
|
continue;
|
|
459
571
|
}
|
|
460
|
-
if (
|
|
461
|
-
for (const [S, [
|
|
462
|
-
if (s.startsWith(S,
|
|
572
|
+
if (p === "[" && !l) {
|
|
573
|
+
for (const [S, [v, P, x]] of Object.entries(De))
|
|
574
|
+
if (s.startsWith(S, i)) {
|
|
463
575
|
if (f)
|
|
464
576
|
return ["$.", !1, s.length - e, !0];
|
|
465
|
-
|
|
577
|
+
i += S.length, x ? r.push(v) : n.push(v), a = a || P;
|
|
466
578
|
continue t;
|
|
467
579
|
}
|
|
468
580
|
}
|
|
469
581
|
if (l = !1, f) {
|
|
470
|
-
|
|
582
|
+
p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
|
|
471
583
|
continue;
|
|
472
584
|
}
|
|
473
|
-
if (s.startsWith("-]",
|
|
474
|
-
n.push(
|
|
585
|
+
if (s.startsWith("-]", i + 1)) {
|
|
586
|
+
n.push(R(p + "-")), i += 2;
|
|
475
587
|
continue;
|
|
476
588
|
}
|
|
477
|
-
if (s.startsWith("-",
|
|
478
|
-
f =
|
|
589
|
+
if (s.startsWith("-", i + 1)) {
|
|
590
|
+
f = p, i += 2;
|
|
479
591
|
continue;
|
|
480
592
|
}
|
|
481
|
-
n.push(
|
|
593
|
+
n.push(R(p)), i++;
|
|
482
594
|
}
|
|
483
|
-
if (c <
|
|
595
|
+
if (c < i)
|
|
484
596
|
return ["", !1, 0, !1];
|
|
485
|
-
if (!n.length && !
|
|
597
|
+
if (!n.length && !r.length)
|
|
486
598
|
return ["$.", !1, s.length - e, !0];
|
|
487
|
-
if (
|
|
488
|
-
const
|
|
489
|
-
return [
|
|
599
|
+
if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
600
|
+
const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
601
|
+
return [ve(p), !1, c - e, !1];
|
|
490
602
|
}
|
|
491
|
-
const u = "[" + (h ? "^" : "") +
|
|
492
|
-
return [n.length &&
|
|
493
|
-
},
|
|
603
|
+
const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
|
|
604
|
+
return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
605
|
+
}, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", _ = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
|
|
494
606
|
class E {
|
|
495
607
|
type;
|
|
496
608
|
#s;
|
|
497
609
|
#n;
|
|
498
|
-
#
|
|
610
|
+
#i = !1;
|
|
499
611
|
#t = [];
|
|
500
612
|
#e;
|
|
501
613
|
#o;
|
|
502
614
|
#c;
|
|
503
615
|
#a = !1;
|
|
504
|
-
#
|
|
616
|
+
#r;
|
|
505
617
|
#l;
|
|
506
618
|
// set to true if it's an extglob with no children
|
|
507
619
|
// (which really means one child of '')
|
|
508
620
|
#u = !1;
|
|
509
621
|
constructor(t, e, n = {}) {
|
|
510
|
-
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#
|
|
622
|
+
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
623
|
}
|
|
512
624
|
get hasMagic() {
|
|
513
625
|
if (this.#n !== void 0)
|
|
@@ -533,11 +645,11 @@ class E {
|
|
|
533
645
|
continue;
|
|
534
646
|
let e = t, n = e.#e;
|
|
535
647
|
for (; n; ) {
|
|
536
|
-
for (let
|
|
537
|
-
for (const
|
|
538
|
-
if (typeof
|
|
648
|
+
for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
|
|
649
|
+
for (const i of t.#t) {
|
|
650
|
+
if (typeof i == "string")
|
|
539
651
|
throw new Error("string part in extglob AST??");
|
|
540
|
-
|
|
652
|
+
i.copyIn(n.#t[r]);
|
|
541
653
|
}
|
|
542
654
|
e = n, n = e.#e;
|
|
543
655
|
}
|
|
@@ -590,40 +702,40 @@ class E {
|
|
|
590
702
|
e.copyIn(n);
|
|
591
703
|
return e;
|
|
592
704
|
}
|
|
593
|
-
static #h(t, e, n,
|
|
594
|
-
let
|
|
705
|
+
static #h(t, e, n, r) {
|
|
706
|
+
let i = !1, o = !1, a = -1, l = !1;
|
|
595
707
|
if (e.type === null) {
|
|
596
|
-
let d = n,
|
|
708
|
+
let d = n, g = "";
|
|
597
709
|
for (; d < t.length; ) {
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
|
|
710
|
+
const p = t.charAt(d++);
|
|
711
|
+
if (i || p === "\\\\") {
|
|
712
|
+
i = !i, g += p;
|
|
601
713
|
continue;
|
|
602
714
|
}
|
|
603
715
|
if (o) {
|
|
604
|
-
d === a + 1 ? (
|
|
716
|
+
d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
|
|
605
717
|
continue;
|
|
606
|
-
} else if (
|
|
607
|
-
o = !0, a = d, l = !1,
|
|
718
|
+
} else if (p === "[") {
|
|
719
|
+
o = !0, a = d, l = !1, g += p;
|
|
608
720
|
continue;
|
|
609
721
|
}
|
|
610
|
-
if (!
|
|
611
|
-
e.push(
|
|
612
|
-
const S = new E(
|
|
613
|
-
d = E.#h(t, S, d,
|
|
722
|
+
if (!r.noext && pt(p) && t.charAt(d) === "(") {
|
|
723
|
+
e.push(g), g = "";
|
|
724
|
+
const S = new E(p, e);
|
|
725
|
+
d = E.#h(t, S, d, r), e.push(S);
|
|
614
726
|
continue;
|
|
615
727
|
}
|
|
616
|
-
|
|
728
|
+
g += p;
|
|
617
729
|
}
|
|
618
|
-
return e.push(
|
|
730
|
+
return e.push(g), d;
|
|
619
731
|
}
|
|
620
732
|
let h = n + 1, c = new E(null, e);
|
|
621
733
|
const f = [];
|
|
622
734
|
let u = "";
|
|
623
735
|
for (; h < t.length; ) {
|
|
624
736
|
const d = t.charAt(h++);
|
|
625
|
-
if (
|
|
626
|
-
|
|
737
|
+
if (i || d === "\\\\") {
|
|
738
|
+
i = !i, u += d;
|
|
627
739
|
continue;
|
|
628
740
|
}
|
|
629
741
|
if (o) {
|
|
@@ -633,10 +745,10 @@ class E {
|
|
|
633
745
|
o = !0, a = h, l = !1, u += d;
|
|
634
746
|
continue;
|
|
635
747
|
}
|
|
636
|
-
if (
|
|
748
|
+
if (pt(d) && t.charAt(h) === "(") {
|
|
637
749
|
c.push(u), u = "";
|
|
638
|
-
const
|
|
639
|
-
c.push(
|
|
750
|
+
const g = new E(d, c);
|
|
751
|
+
c.push(g), h = E.#h(t, g, h, r);
|
|
640
752
|
continue;
|
|
641
753
|
}
|
|
642
754
|
if (d === "|") {
|
|
@@ -658,17 +770,17 @@ class E {
|
|
|
658
770
|
toMMPattern() {
|
|
659
771
|
if (this !== this.#s)
|
|
660
772
|
return this.#s.toMMPattern();
|
|
661
|
-
const t = this.toString(), [e, n,
|
|
662
|
-
if (!(
|
|
773
|
+
const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
|
|
774
|
+
if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
663
775
|
return n;
|
|
664
|
-
const a = (this.#
|
|
776
|
+
const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
|
|
665
777
|
return Object.assign(new RegExp(\`^\${e}$\`, a), {
|
|
666
778
|
_src: e,
|
|
667
779
|
_glob: t
|
|
668
780
|
});
|
|
669
781
|
}
|
|
670
782
|
get options() {
|
|
671
|
-
return this.#
|
|
783
|
+
return this.#r;
|
|
672
784
|
}
|
|
673
785
|
// returns the string match, the regexp source, whether there's magic
|
|
674
786
|
// in the regexp (so a regular expression is required) and whether or
|
|
@@ -740,168 +852,168 @@ class E {
|
|
|
740
852
|
// is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
|
|
741
853
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
742
854
|
toRegExpSource(t) {
|
|
743
|
-
const e = t ?? !!this.#
|
|
855
|
+
const e = t ?? !!this.#r.dot;
|
|
744
856
|
if (this.#s === this && this.#d(), !this.type) {
|
|
745
857
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
746
|
-
const [
|
|
747
|
-
return this.#n = this.#n || S, this.#
|
|
858
|
+
const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
859
|
+
return this.#n = this.#n || S, this.#i = this.#i || v, g;
|
|
748
860
|
}).join("");
|
|
749
861
|
let c = "";
|
|
750
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
751
|
-
const
|
|
862
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
|
|
863
|
+
const g = Fe, p = (
|
|
752
864
|
// dots are allowed, and the pattern starts with [ or .
|
|
753
|
-
e &&
|
|
754
|
-
h.startsWith("\\\\.") &&
|
|
755
|
-
h.startsWith("\\\\.\\\\.") &&
|
|
756
|
-
), S = !e && !t &&
|
|
757
|
-
c =
|
|
865
|
+
e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
866
|
+
h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
867
|
+
h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
|
|
868
|
+
), S = !e && !t && g.has(h.charAt(0));
|
|
869
|
+
c = p ? Ce : S ? _ : "";
|
|
758
870
|
}
|
|
759
871
|
let f = "";
|
|
760
872
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
761
873
|
c + h + f,
|
|
762
|
-
|
|
874
|
+
k(h),
|
|
763
875
|
this.#n = !!this.#n,
|
|
764
|
-
this.#
|
|
876
|
+
this.#i
|
|
765
877
|
];
|
|
766
878
|
}
|
|
767
|
-
const n = this.type === "*" || this.type === "+",
|
|
768
|
-
let
|
|
769
|
-
if (this.isStart() && this.isEnd() && !
|
|
879
|
+
const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
880
|
+
let i = this.#f(e);
|
|
881
|
+
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
770
882
|
const l = this.toString();
|
|
771
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
883
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
|
|
772
884
|
}
|
|
773
|
-
let o = !n || t || e || !
|
|
774
|
-
o ===
|
|
885
|
+
let o = !n || t || e || !_ ? "" : this.#f(!0);
|
|
886
|
+
o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
|
|
775
887
|
let a = "";
|
|
776
888
|
if (this.type === "!" && this.#u)
|
|
777
|
-
a = (this.isStart() && !e ?
|
|
889
|
+
a = (this.isStart() && !e ? _ : "") + wt;
|
|
778
890
|
else {
|
|
779
891
|
const l = this.type === "!" ? (
|
|
780
892
|
// !() must match something,but !(x) can match ''
|
|
781
|
-
"))" + (this.isStart() && !e && !t ?
|
|
893
|
+
"))" + (this.isStart() && !e && !t ? _ : "") + gt + ")"
|
|
782
894
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
783
|
-
a =
|
|
895
|
+
a = r + i + l;
|
|
784
896
|
}
|
|
785
897
|
return [
|
|
786
898
|
a,
|
|
787
|
-
|
|
899
|
+
k(i),
|
|
788
900
|
this.#n = !!this.#n,
|
|
789
|
-
this.#
|
|
901
|
+
this.#i
|
|
790
902
|
];
|
|
791
903
|
}
|
|
792
904
|
#f(t) {
|
|
793
905
|
return this.#t.map((e) => {
|
|
794
906
|
if (typeof e == "string")
|
|
795
907
|
throw new Error("string type in extglob ast??");
|
|
796
|
-
const [n,
|
|
797
|
-
return this.#
|
|
908
|
+
const [n, r, i, o] = e.toRegExpSource(t);
|
|
909
|
+
return this.#i = this.#i || o, n;
|
|
798
910
|
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
799
911
|
}
|
|
800
912
|
static #p(t, e, n = !1) {
|
|
801
|
-
let
|
|
913
|
+
let r = !1, i = "", o = !1;
|
|
802
914
|
for (let a = 0; a < t.length; a++) {
|
|
803
915
|
const l = t.charAt(a);
|
|
804
|
-
if (
|
|
805
|
-
|
|
916
|
+
if (r) {
|
|
917
|
+
r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
|
|
806
918
|
continue;
|
|
807
919
|
}
|
|
808
920
|
if (l === "\\\\") {
|
|
809
|
-
a === t.length - 1 ?
|
|
921
|
+
a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
|
|
810
922
|
continue;
|
|
811
923
|
}
|
|
812
924
|
if (l === "[") {
|
|
813
|
-
const [h, c, f, u] =
|
|
925
|
+
const [h, c, f, u] = Ae(t, a);
|
|
814
926
|
if (f) {
|
|
815
|
-
|
|
927
|
+
i += h, o = o || c, a += f - 1, e = e || u;
|
|
816
928
|
continue;
|
|
817
929
|
}
|
|
818
930
|
}
|
|
819
931
|
if (l === "*") {
|
|
820
|
-
n && t === "*" ?
|
|
932
|
+
n && t === "*" ? i += wt : i += gt, e = !0;
|
|
821
933
|
continue;
|
|
822
934
|
}
|
|
823
935
|
if (l === "?") {
|
|
824
|
-
|
|
936
|
+
i += ct, e = !0;
|
|
825
937
|
continue;
|
|
826
938
|
}
|
|
827
|
-
|
|
939
|
+
i += Pe(l);
|
|
828
940
|
}
|
|
829
|
-
return [
|
|
941
|
+
return [i, k(t), !!e, o];
|
|
830
942
|
}
|
|
831
943
|
}
|
|
832
|
-
const
|
|
833
|
-
const e =
|
|
944
|
+
const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
|
|
945
|
+
const e = It([s]);
|
|
834
946
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
835
|
-
},
|
|
836
|
-
const e =
|
|
947
|
+
}, Ze = ([s, t = ""]) => {
|
|
948
|
+
const e = kt([s]);
|
|
837
949
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
838
|
-
},
|
|
839
|
-
const e =
|
|
950
|
+
}, Xe = ([s, t = ""]) => {
|
|
951
|
+
const e = kt([s]);
|
|
840
952
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
841
|
-
},
|
|
842
|
-
const e =
|
|
953
|
+
}, Je = ([s, t = ""]) => {
|
|
954
|
+
const e = It([s]);
|
|
843
955
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
844
|
-
},
|
|
956
|
+
}, It = ([s]) => {
|
|
845
957
|
const t = s.length;
|
|
846
958
|
return (e) => e.length === t && !e.startsWith(".");
|
|
847
|
-
},
|
|
959
|
+
}, kt = ([s]) => {
|
|
848
960
|
const t = s.length;
|
|
849
961
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
850
|
-
},
|
|
962
|
+
}, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
|
|
851
963
|
win32: { sep: "\\\\" },
|
|
852
964
|
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),
|
|
965
|
+
}, Qe = Lt === "win32" ? mt.win32.sep : mt.posix.sep;
|
|
966
|
+
y.sep = Qe;
|
|
967
|
+
const O = Symbol("globstar **");
|
|
968
|
+
y.GLOBSTAR = O;
|
|
969
|
+
const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
|
|
970
|
+
y.filter = ns;
|
|
971
|
+
const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
|
|
860
972
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
861
973
|
return y;
|
|
862
974
|
const t = y;
|
|
863
|
-
return Object.assign((n,
|
|
975
|
+
return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
|
|
864
976
|
Minimatch: class extends t.Minimatch {
|
|
865
|
-
constructor(
|
|
866
|
-
super(
|
|
977
|
+
constructor(r, i = {}) {
|
|
978
|
+
super(r, b(s, i));
|
|
867
979
|
}
|
|
868
|
-
static defaults(
|
|
869
|
-
return t.defaults(b(s,
|
|
980
|
+
static defaults(r) {
|
|
981
|
+
return t.defaults(b(s, r)).Minimatch;
|
|
870
982
|
}
|
|
871
983
|
},
|
|
872
984
|
AST: class extends t.AST {
|
|
873
985
|
/* c8 ignore start */
|
|
874
|
-
constructor(
|
|
875
|
-
super(
|
|
986
|
+
constructor(r, i, o = {}) {
|
|
987
|
+
super(r, i, b(s, o));
|
|
876
988
|
}
|
|
877
989
|
/* c8 ignore stop */
|
|
878
|
-
static fromGlob(
|
|
879
|
-
return t.AST.fromGlob(
|
|
990
|
+
static fromGlob(r, i = {}) {
|
|
991
|
+
return t.AST.fromGlob(r, b(s, i));
|
|
880
992
|
}
|
|
881
993
|
},
|
|
882
|
-
unescape: (n,
|
|
883
|
-
escape: (n,
|
|
884
|
-
filter: (n,
|
|
994
|
+
unescape: (n, r = {}) => t.unescape(n, b(s, r)),
|
|
995
|
+
escape: (n, r = {}) => t.escape(n, b(s, r)),
|
|
996
|
+
filter: (n, r = {}) => t.filter(n, b(s, r)),
|
|
885
997
|
defaults: (n) => t.defaults(b(s, n)),
|
|
886
|
-
makeRe: (n,
|
|
887
|
-
braceExpand: (n,
|
|
888
|
-
match: (n,
|
|
998
|
+
makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
|
|
999
|
+
braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
|
|
1000
|
+
match: (n, r, i = {}) => t.match(n, r, b(s, i)),
|
|
889
1001
|
sep: t.sep,
|
|
890
|
-
GLOBSTAR:
|
|
1002
|
+
GLOBSTAR: O
|
|
891
1003
|
});
|
|
892
1004
|
};
|
|
893
|
-
y.defaults =
|
|
894
|
-
const
|
|
895
|
-
y.braceExpand =
|
|
896
|
-
const
|
|
897
|
-
y.makeRe =
|
|
898
|
-
const
|
|
899
|
-
const n = new
|
|
900
|
-
return s = s.filter((
|
|
1005
|
+
y.defaults = rs;
|
|
1006
|
+
const zt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
|
|
1007
|
+
y.braceExpand = zt;
|
|
1008
|
+
const is = (s, t = {}) => new X(s, t).makeRe();
|
|
1009
|
+
y.makeRe = is;
|
|
1010
|
+
const os = (s, t, e = {}) => {
|
|
1011
|
+
const n = new X(t, e);
|
|
1012
|
+
return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
|
|
901
1013
|
};
|
|
902
|
-
y.match =
|
|
903
|
-
const
|
|
904
|
-
class
|
|
1014
|
+
y.match = os;
|
|
1015
|
+
const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
1016
|
+
class X {
|
|
905
1017
|
options;
|
|
906
1018
|
set;
|
|
907
1019
|
pattern;
|
|
@@ -920,7 +1032,7 @@ class q {
|
|
|
920
1032
|
windowsNoMagicRoot;
|
|
921
1033
|
regexp;
|
|
922
1034
|
constructor(t, e = {}) {
|
|
923
|
-
|
|
1035
|
+
Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
924
1036
|
}
|
|
925
1037
|
hasMagic() {
|
|
926
1038
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -943,23 +1055,23 @@ class q {
|
|
|
943
1055
|
this.empty = !0;
|
|
944
1056
|
return;
|
|
945
1057
|
}
|
|
946
|
-
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...
|
|
947
|
-
const n = this.globSet.map((
|
|
1058
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1059
|
+
const n = this.globSet.map((i) => this.slashSplit(i));
|
|
948
1060
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
949
|
-
let
|
|
1061
|
+
let r = this.globParts.map((i, o, a) => {
|
|
950
1062
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
951
|
-
const l =
|
|
1063
|
+
const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
|
|
952
1064
|
if (l)
|
|
953
|
-
return [...
|
|
1065
|
+
return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
|
|
954
1066
|
if (h)
|
|
955
|
-
return [
|
|
1067
|
+
return [i[0], ...i.slice(1).map((c) => this.parse(c))];
|
|
956
1068
|
}
|
|
957
|
-
return
|
|
1069
|
+
return i.map((l) => this.parse(l));
|
|
958
1070
|
});
|
|
959
|
-
if (this.debug(this.pattern,
|
|
960
|
-
for (let
|
|
961
|
-
const o = this.set[
|
|
962
|
-
o[0] === "" && o[1] === "" && this.globParts[
|
|
1071
|
+
if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
|
|
1072
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1073
|
+
const o = this.set[i];
|
|
1074
|
+
o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
963
1075
|
}
|
|
964
1076
|
this.debug(this.pattern, this.set);
|
|
965
1077
|
}
|
|
@@ -971,8 +1083,8 @@ class q {
|
|
|
971
1083
|
preprocess(t) {
|
|
972
1084
|
if (this.options.noglobstar)
|
|
973
1085
|
for (let n = 0; n < t.length; n++)
|
|
974
|
-
for (let
|
|
975
|
-
t[n][
|
|
1086
|
+
for (let r = 0; r < t[n].length; r++)
|
|
1087
|
+
t[n][r] === "**" && (t[n][r] = "*");
|
|
976
1088
|
const { optimizationLevel: e = 1 } = this.options;
|
|
977
1089
|
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
978
1090
|
}
|
|
@@ -981,19 +1093,19 @@ class q {
|
|
|
981
1093
|
return t.map((e) => {
|
|
982
1094
|
let n = -1;
|
|
983
1095
|
for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
|
|
984
|
-
let
|
|
985
|
-
for (; e[
|
|
986
|
-
|
|
987
|
-
|
|
1096
|
+
let r = n;
|
|
1097
|
+
for (; e[r + 1] === "**"; )
|
|
1098
|
+
r++;
|
|
1099
|
+
r !== n && e.splice(n, r - n);
|
|
988
1100
|
}
|
|
989
1101
|
return e;
|
|
990
1102
|
});
|
|
991
1103
|
}
|
|
992
1104
|
// get rid of adjascent ** and resolve .. portions
|
|
993
1105
|
levelOneOptimize(t) {
|
|
994
|
-
return t.map((e) => (e = e.reduce((n,
|
|
995
|
-
const
|
|
996
|
-
return
|
|
1106
|
+
return t.map((e) => (e = e.reduce((n, r) => {
|
|
1107
|
+
const i = n[n.length - 1];
|
|
1108
|
+
return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
|
|
997
1109
|
}, []), e.length === 0 ? [""] : e));
|
|
998
1110
|
}
|
|
999
1111
|
levelTwoFileOptimize(t) {
|
|
@@ -1001,16 +1113,16 @@ class q {
|
|
|
1001
1113
|
let e = !1;
|
|
1002
1114
|
do {
|
|
1003
1115
|
if (e = !1, !this.preserveMultipleSlashes) {
|
|
1004
|
-
for (let
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1116
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
1117
|
+
const i = t[r];
|
|
1118
|
+
r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
|
|
1007
1119
|
}
|
|
1008
1120
|
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
1009
1121
|
}
|
|
1010
1122
|
let n = 0;
|
|
1011
1123
|
for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1124
|
+
const r = t[n - 1];
|
|
1125
|
+
r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
|
|
1014
1126
|
}
|
|
1015
1127
|
} while (e);
|
|
1016
1128
|
return t.length === 0 ? [""] : t;
|
|
@@ -1038,19 +1150,19 @@ class q {
|
|
|
1038
1150
|
do {
|
|
1039
1151
|
e = !1;
|
|
1040
1152
|
for (let n of t) {
|
|
1041
|
-
let
|
|
1042
|
-
for (; (
|
|
1043
|
-
let o =
|
|
1153
|
+
let r = -1;
|
|
1154
|
+
for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
|
|
1155
|
+
let o = r;
|
|
1044
1156
|
for (; n[o + 1] === "**"; )
|
|
1045
1157
|
o++;
|
|
1046
|
-
o >
|
|
1047
|
-
let a = n[
|
|
1048
|
-
const l = n[
|
|
1158
|
+
o > r && n.splice(r + 1, o - r);
|
|
1159
|
+
let a = n[r + 1];
|
|
1160
|
+
const l = n[r + 2], h = n[r + 3];
|
|
1049
1161
|
if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
|
|
1050
1162
|
continue;
|
|
1051
|
-
e = !0, n.splice(
|
|
1163
|
+
e = !0, n.splice(r, 1);
|
|
1052
1164
|
const c = n.slice(0);
|
|
1053
|
-
c[
|
|
1165
|
+
c[r] = "**", t.push(c), r--;
|
|
1054
1166
|
}
|
|
1055
1167
|
if (!this.preserveMultipleSlashes) {
|
|
1056
1168
|
for (let o = 1; o < n.length - 1; o++) {
|
|
@@ -1059,13 +1171,13 @@ class q {
|
|
|
1059
1171
|
}
|
|
1060
1172
|
n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
|
|
1061
1173
|
}
|
|
1062
|
-
let
|
|
1063
|
-
for (; (
|
|
1064
|
-
const o = n[
|
|
1174
|
+
let i = 0;
|
|
1175
|
+
for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
|
|
1176
|
+
const o = n[i - 1];
|
|
1065
1177
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1066
1178
|
e = !0;
|
|
1067
|
-
const l =
|
|
1068
|
-
n.splice(
|
|
1179
|
+
const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
|
|
1180
|
+
n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
|
|
1069
1181
|
}
|
|
1070
1182
|
}
|
|
1071
1183
|
}
|
|
@@ -1082,31 +1194,31 @@ class q {
|
|
|
1082
1194
|
secondPhasePreProcess(t) {
|
|
1083
1195
|
for (let e = 0; e < t.length - 1; e++)
|
|
1084
1196
|
for (let n = e + 1; n < t.length; n++) {
|
|
1085
|
-
const
|
|
1086
|
-
if (
|
|
1087
|
-
t[e] = [], t[n] =
|
|
1197
|
+
const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
|
|
1198
|
+
if (r) {
|
|
1199
|
+
t[e] = [], t[n] = r;
|
|
1088
1200
|
break;
|
|
1089
1201
|
}
|
|
1090
1202
|
}
|
|
1091
1203
|
return t.filter((e) => e.length);
|
|
1092
1204
|
}
|
|
1093
1205
|
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[
|
|
1206
|
+
let r = 0, i = 0, o = [], a = "";
|
|
1207
|
+
for (; r < t.length && i < e.length; )
|
|
1208
|
+
if (t[r] === e[i])
|
|
1209
|
+
o.push(a === "b" ? e[i] : t[r]), r++, i++;
|
|
1210
|
+
else if (n && t[r] === "**" && e[i] === t[r + 1])
|
|
1211
|
+
o.push(t[r]), r++;
|
|
1212
|
+
else if (n && e[i] === "**" && t[r] === e[i + 1])
|
|
1213
|
+
o.push(e[i]), i++;
|
|
1214
|
+
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1103
1215
|
if (a === "b")
|
|
1104
1216
|
return !1;
|
|
1105
|
-
a = "a", o.push(t[
|
|
1106
|
-
} else if (e[
|
|
1217
|
+
a = "a", o.push(t[r]), r++, i++;
|
|
1218
|
+
} else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
|
|
1107
1219
|
if (a === "a")
|
|
1108
1220
|
return !1;
|
|
1109
|
-
a = "b", o.push(e[
|
|
1221
|
+
a = "b", o.push(e[i]), r++, i++;
|
|
1110
1222
|
} else
|
|
1111
1223
|
return !1;
|
|
1112
1224
|
return t.length === e.length && o;
|
|
@@ -1116,7 +1228,7 @@ class q {
|
|
|
1116
1228
|
return;
|
|
1117
1229
|
const t = this.pattern;
|
|
1118
1230
|
let e = !1, n = 0;
|
|
1119
|
-
for (let
|
|
1231
|
+
for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
|
|
1120
1232
|
e = !e, n++;
|
|
1121
1233
|
n && (this.pattern = t.slice(n)), this.negate = e;
|
|
1122
1234
|
}
|
|
@@ -1126,36 +1238,36 @@ class q {
|
|
|
1126
1238
|
// out of pattern, then that's fine, as long as all
|
|
1127
1239
|
// the parts match.
|
|
1128
1240
|
matchOne(t, e, n = !1) {
|
|
1129
|
-
const
|
|
1241
|
+
const r = this.options;
|
|
1130
1242
|
if (this.isWindows) {
|
|
1131
|
-
const
|
|
1243
|
+
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
1244
|
if (typeof x == "number" && typeof m == "number") {
|
|
1133
|
-
const [
|
|
1134
|
-
|
|
1245
|
+
const [T, H] = [t[x], e[m]];
|
|
1246
|
+
T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
|
|
1135
1247
|
}
|
|
1136
1248
|
}
|
|
1137
|
-
const { optimizationLevel:
|
|
1138
|
-
|
|
1249
|
+
const { optimizationLevel: i = 1 } = this.options;
|
|
1250
|
+
i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
1139
1251
|
for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
|
|
1140
1252
|
this.debug("matchOne loop");
|
|
1141
1253
|
var c = e[a], f = t[o];
|
|
1142
1254
|
if (this.debug(e, c, f), c === !1)
|
|
1143
1255
|
return !1;
|
|
1144
|
-
if (c ===
|
|
1256
|
+
if (c === O) {
|
|
1145
1257
|
this.debug("GLOBSTAR", [e, c, f]);
|
|
1146
1258
|
var u = o, d = a + 1;
|
|
1147
1259
|
if (d === h) {
|
|
1148
1260
|
for (this.debug("** at the end"); o < l; o++)
|
|
1149
|
-
if (t[o] === "." || t[o] === ".." || !
|
|
1261
|
+
if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
|
|
1150
1262
|
return !1;
|
|
1151
1263
|
return !0;
|
|
1152
1264
|
}
|
|
1153
1265
|
for (; u < l; ) {
|
|
1154
|
-
var
|
|
1266
|
+
var g = t[u];
|
|
1155
1267
|
if (this.debug(\`
|
|
1156
|
-
globstar while\`, t, u, e, d,
|
|
1157
|
-
return this.debug("globstar found match!", u, l,
|
|
1158
|
-
if (
|
|
1268
|
+
globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1269
|
+
return this.debug("globstar found match!", u, l, g), !0;
|
|
1270
|
+
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1159
1271
|
this.debug("dot detected!", t, u, e, d);
|
|
1160
1272
|
break;
|
|
1161
1273
|
}
|
|
@@ -1164,8 +1276,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1164
1276
|
return !!(n && (this.debug(\`
|
|
1165
1277
|
>>> no match, partial?\`, t, u, e, d), u === l));
|
|
1166
1278
|
}
|
|
1167
|
-
let
|
|
1168
|
-
if (typeof c == "string" ? (
|
|
1279
|
+
let p;
|
|
1280
|
+
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
1281
|
return !1;
|
|
1170
1282
|
}
|
|
1171
1283
|
if (o === l && a === h)
|
|
@@ -1177,19 +1289,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1177
1289
|
throw new Error("wtf?");
|
|
1178
1290
|
}
|
|
1179
1291
|
braceExpand() {
|
|
1180
|
-
return
|
|
1292
|
+
return zt(this.pattern, this.options);
|
|
1181
1293
|
}
|
|
1182
1294
|
parse(t) {
|
|
1183
|
-
|
|
1295
|
+
Z(t);
|
|
1184
1296
|
const e = this.options;
|
|
1185
1297
|
if (t === "**")
|
|
1186
|
-
return
|
|
1298
|
+
return O;
|
|
1187
1299
|
if (t === "")
|
|
1188
1300
|
return "";
|
|
1189
|
-
let n,
|
|
1190
|
-
(n = t.match(
|
|
1191
|
-
const
|
|
1192
|
-
return
|
|
1301
|
+
let n, r = null;
|
|
1302
|
+
(n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
|
|
1303
|
+
const i = E.fromGlob(t, this.options).toMMPattern();
|
|
1304
|
+
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1193
1305
|
}
|
|
1194
1306
|
makeRe() {
|
|
1195
1307
|
if (this.regexp || this.regexp === !1)
|
|
@@ -1197,23 +1309,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1197
1309
|
const t = this.set;
|
|
1198
1310
|
if (!t.length)
|
|
1199
1311
|
return this.regexp = !1, this.regexp;
|
|
1200
|
-
const e = this.options, n = e.noglobstar ?
|
|
1201
|
-
let
|
|
1312
|
+
const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
|
|
1313
|
+
let i = t.map((l) => {
|
|
1202
1314
|
const h = l.map((c) => {
|
|
1203
1315
|
if (c instanceof RegExp)
|
|
1204
1316
|
for (const f of c.flags.split(""))
|
|
1205
|
-
|
|
1206
|
-
return typeof c == "string" ?
|
|
1317
|
+
r.add(f);
|
|
1318
|
+
return typeof c == "string" ? as(c) : c === O ? O : c._src;
|
|
1207
1319
|
});
|
|
1208
1320
|
return h.forEach((c, f) => {
|
|
1209
1321
|
const u = h[f + 1], d = h[f - 1];
|
|
1210
|
-
c !==
|
|
1211
|
-
}), h.filter((c) => c !==
|
|
1322
|
+
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));
|
|
1323
|
+
}), h.filter((c) => c !== O).join("/");
|
|
1212
1324
|
}).join("|");
|
|
1213
1325
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1214
|
-
|
|
1326
|
+
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1215
1327
|
try {
|
|
1216
|
-
this.regexp = new RegExp(
|
|
1328
|
+
this.regexp = new RegExp(i, [...r].join(""));
|
|
1217
1329
|
} catch {
|
|
1218
1330
|
this.regexp = !1;
|
|
1219
1331
|
}
|
|
@@ -1231,17 +1343,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1231
1343
|
return !0;
|
|
1232
1344
|
const n = this.options;
|
|
1233
1345
|
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 =
|
|
1346
|
+
const r = this.slashSplit(t);
|
|
1347
|
+
this.debug(this.pattern, "split", r);
|
|
1348
|
+
const i = this.set;
|
|
1349
|
+
this.debug(this.pattern, "set", i);
|
|
1350
|
+
let o = r[r.length - 1];
|
|
1239
1351
|
if (!o)
|
|
1240
|
-
for (let a =
|
|
1241
|
-
o =
|
|
1242
|
-
for (let a = 0; a <
|
|
1243
|
-
const l =
|
|
1244
|
-
let h =
|
|
1352
|
+
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1353
|
+
o = r[a];
|
|
1354
|
+
for (let a = 0; a < i.length; a++) {
|
|
1355
|
+
const l = i[a];
|
|
1356
|
+
let h = r;
|
|
1245
1357
|
if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
|
|
1246
1358
|
return n.flipNegate ? !0 : !this.negate;
|
|
1247
1359
|
}
|
|
@@ -1252,109 +1364,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1252
1364
|
}
|
|
1253
1365
|
}
|
|
1254
1366
|
y.AST = E;
|
|
1255
|
-
y.Minimatch =
|
|
1256
|
-
y.escape =
|
|
1257
|
-
y.unescape =
|
|
1258
|
-
function
|
|
1367
|
+
y.Minimatch = X;
|
|
1368
|
+
y.escape = Te;
|
|
1369
|
+
y.unescape = k;
|
|
1370
|
+
function cs() {
|
|
1259
1371
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1260
|
-
throw new
|
|
1372
|
+
throw new Qt();
|
|
1261
1373
|
}
|
|
1262
|
-
async function
|
|
1374
|
+
async function L(s, t, e) {
|
|
1263
1375
|
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1264
1376
|
}
|
|
1265
|
-
function
|
|
1377
|
+
function M(s) {
|
|
1266
1378
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
1267
1379
|
}
|
|
1268
|
-
function
|
|
1380
|
+
function lt(s) {
|
|
1269
1381
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1270
1382
|
}
|
|
1271
|
-
function
|
|
1272
|
-
const t =
|
|
1383
|
+
function it(s) {
|
|
1384
|
+
const t = M(s);
|
|
1273
1385
|
return t[t.length - 1] || "";
|
|
1274
1386
|
}
|
|
1275
|
-
function
|
|
1276
|
-
const t =
|
|
1277
|
-
return t.pop(),
|
|
1387
|
+
function et(s) {
|
|
1388
|
+
const t = M(s);
|
|
1389
|
+
return t.pop(), lt(t);
|
|
1278
1390
|
}
|
|
1279
|
-
function
|
|
1391
|
+
function G(s) {
|
|
1280
1392
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1281
1393
|
}
|
|
1282
|
-
function
|
|
1394
|
+
function ls(s, t = !1) {
|
|
1283
1395
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1284
1396
|
}
|
|
1285
|
-
function
|
|
1397
|
+
function st(s, t) {
|
|
1286
1398
|
return y(s, t, {
|
|
1287
1399
|
dot: !0,
|
|
1288
1400
|
matchBase: !0
|
|
1289
1401
|
});
|
|
1290
1402
|
}
|
|
1291
|
-
function
|
|
1292
|
-
const t =
|
|
1293
|
-
for (const
|
|
1294
|
-
if (!(
|
|
1295
|
-
if (
|
|
1403
|
+
function Et(s) {
|
|
1404
|
+
const t = G(s), e = M(t), n = [];
|
|
1405
|
+
for (const r of e)
|
|
1406
|
+
if (!(r === "." || r === ""))
|
|
1407
|
+
if (r === "..") {
|
|
1296
1408
|
if (n.length === 0)
|
|
1297
1409
|
continue;
|
|
1298
1410
|
n.pop();
|
|
1299
1411
|
} else
|
|
1300
|
-
n.push(
|
|
1301
|
-
return
|
|
1412
|
+
n.push(r);
|
|
1413
|
+
return lt(n);
|
|
1302
1414
|
}
|
|
1303
|
-
async function
|
|
1415
|
+
async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1304
1416
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1305
1417
|
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(
|
|
1418
|
+
const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
|
|
1419
|
+
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1308
1420
|
}
|
|
1309
|
-
async function
|
|
1421
|
+
async function us(s) {
|
|
1310
1422
|
const t = await s.arrayBuffer();
|
|
1311
1423
|
return new Uint8Array(t);
|
|
1312
1424
|
}
|
|
1313
|
-
async function
|
|
1314
|
-
const n =
|
|
1315
|
-
return
|
|
1316
|
-
const
|
|
1425
|
+
async function fs(s, t, e = {}) {
|
|
1426
|
+
const n = it(t);
|
|
1427
|
+
return L(t, "exclusive", async () => {
|
|
1428
|
+
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1317
1429
|
try {
|
|
1318
|
-
await s.removeEntry(n, { recursive:
|
|
1430
|
+
await s.removeEntry(n, { recursive: r });
|
|
1319
1431
|
} catch (o) {
|
|
1320
1432
|
if (o.name === "NotFoundError") {
|
|
1321
|
-
if (!
|
|
1322
|
-
throw new
|
|
1323
|
-
} else throw o.name === "InvalidModificationError" ? new
|
|
1433
|
+
if (!i)
|
|
1434
|
+
throw new F("file", t, o);
|
|
1435
|
+
} else throw o.name === "InvalidModificationError" ? new rt("ENOTEMPTY", t, o) : o.name === "TypeMismatchError" && !r ? new z("directory", t, o) : new rt("RM_FAILED", t, o);
|
|
1324
1436
|
}
|
|
1325
1437
|
});
|
|
1326
1438
|
}
|
|
1327
|
-
function
|
|
1439
|
+
function St(s, t, e, n) {
|
|
1328
1440
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1329
|
-
throw new
|
|
1441
|
+
throw new N("argument", "Invalid offset or length");
|
|
1330
1442
|
if (t < 0 || e < 0)
|
|
1331
|
-
throw new
|
|
1443
|
+
throw new N("argument", "Negative offset or length not allowed");
|
|
1332
1444
|
if (t + e > s)
|
|
1333
|
-
throw new
|
|
1445
|
+
throw new N("overflow", "Operation would overflow buffer");
|
|
1334
1446
|
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1335
|
-
throw new
|
|
1447
|
+
throw new N("argument", "Invalid position");
|
|
1336
1448
|
}
|
|
1337
|
-
function
|
|
1449
|
+
function xt(s, t, e) {
|
|
1338
1450
|
try {
|
|
1339
1451
|
t.flush(), t.close();
|
|
1340
1452
|
} catch (n) {
|
|
1341
1453
|
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1342
1454
|
}
|
|
1343
1455
|
}
|
|
1344
|
-
function
|
|
1456
|
+
function ds(s, t, e) {
|
|
1345
1457
|
if (s >= e)
|
|
1346
1458
|
return { isEOF: !0, actualLength: 0 };
|
|
1347
1459
|
const n = Math.min(t, e - s);
|
|
1348
1460
|
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1349
1461
|
}
|
|
1350
|
-
async function
|
|
1462
|
+
async function ps(s, t) {
|
|
1351
1463
|
try {
|
|
1352
1464
|
return await s.createSyncAccessHandle();
|
|
1353
1465
|
} catch (e) {
|
|
1354
|
-
throw
|
|
1466
|
+
throw A(e, { path: t, isDirectory: !1 });
|
|
1355
1467
|
}
|
|
1356
1468
|
}
|
|
1357
|
-
class
|
|
1469
|
+
class gs {
|
|
1358
1470
|
/** Root directory handle for the file system */
|
|
1359
1471
|
root;
|
|
1360
1472
|
/** Map of watched paths and options */
|
|
@@ -1382,7 +1494,7 @@ class ss {
|
|
|
1382
1494
|
_getFileDescriptor(t) {
|
|
1383
1495
|
const e = this.openFiles.get(t);
|
|
1384
1496
|
if (!e)
|
|
1385
|
-
throw new
|
|
1497
|
+
throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
|
|
1386
1498
|
return e;
|
|
1387
1499
|
}
|
|
1388
1500
|
/**
|
|
@@ -1398,25 +1510,25 @@ class ss {
|
|
|
1398
1510
|
if (!this.options.broadcastChannel)
|
|
1399
1511
|
return;
|
|
1400
1512
|
const e = t.path;
|
|
1401
|
-
if (![...this.watchers.values()].some((
|
|
1513
|
+
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))))
|
|
1402
1514
|
return;
|
|
1403
|
-
let
|
|
1515
|
+
let r;
|
|
1404
1516
|
if (this.options.hashAlgorithm)
|
|
1405
1517
|
try {
|
|
1406
|
-
|
|
1518
|
+
r = (await this.stat(e)).hash;
|
|
1407
1519
|
} catch {
|
|
1408
1520
|
}
|
|
1409
1521
|
try {
|
|
1410
1522
|
this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
|
|
1411
|
-
const
|
|
1523
|
+
const i = {
|
|
1412
1524
|
namespace: this.options.namespace,
|
|
1413
1525
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1414
1526
|
...t,
|
|
1415
|
-
...
|
|
1527
|
+
...r && { hash: r }
|
|
1416
1528
|
};
|
|
1417
|
-
this.broadcastChannel.postMessage(
|
|
1418
|
-
} catch (
|
|
1419
|
-
console.warn("Failed to send event via BroadcastChannel:",
|
|
1529
|
+
this.broadcastChannel.postMessage(i);
|
|
1530
|
+
} catch (i) {
|
|
1531
|
+
console.warn("Failed to send event via BroadcastChannel:", i);
|
|
1420
1532
|
}
|
|
1421
1533
|
}
|
|
1422
1534
|
/**
|
|
@@ -1430,7 +1542,7 @@ class ss {
|
|
|
1430
1542
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1431
1543
|
*/
|
|
1432
1544
|
constructor(t) {
|
|
1433
|
-
|
|
1545
|
+
cs(), t && this.setOptions(t);
|
|
1434
1546
|
}
|
|
1435
1547
|
/**
|
|
1436
1548
|
* Initialize the file system within a given directory
|
|
@@ -1457,10 +1569,10 @@ class ss {
|
|
|
1457
1569
|
const t = this.options.root;
|
|
1458
1570
|
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
|
|
1459
1571
|
try {
|
|
1460
|
-
const
|
|
1461
|
-
this.root = t === "/" ?
|
|
1462
|
-
} catch (
|
|
1463
|
-
n(new
|
|
1572
|
+
const r = await navigator.storage.getDirectory();
|
|
1573
|
+
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1574
|
+
} catch (r) {
|
|
1575
|
+
n(new re(t, r));
|
|
1464
1576
|
} finally {
|
|
1465
1577
|
this.mountingPromise = null;
|
|
1466
1578
|
}
|
|
@@ -1477,7 +1589,7 @@ class ss {
|
|
|
1477
1589
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1478
1590
|
*/
|
|
1479
1591
|
async setOptions(t) {
|
|
1480
|
-
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 =
|
|
1592
|
+
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());
|
|
1481
1593
|
}
|
|
1482
1594
|
/**
|
|
1483
1595
|
* Get a directory handle from a path
|
|
@@ -1498,11 +1610,11 @@ class ss {
|
|
|
1498
1610
|
* \`\`\`
|
|
1499
1611
|
*/
|
|
1500
1612
|
async getDirectoryHandle(t, e = !1, n = this.root) {
|
|
1501
|
-
const
|
|
1502
|
-
let
|
|
1503
|
-
for (const o of
|
|
1504
|
-
|
|
1505
|
-
return
|
|
1613
|
+
const r = Array.isArray(t) ? t : M(t);
|
|
1614
|
+
let i = n;
|
|
1615
|
+
for (const o of r)
|
|
1616
|
+
i = await i.getDirectoryHandle(o, { create: e });
|
|
1617
|
+
return i;
|
|
1506
1618
|
}
|
|
1507
1619
|
/**
|
|
1508
1620
|
* Get a file handle from a path
|
|
@@ -1524,11 +1636,11 @@ class ss {
|
|
|
1524
1636
|
* \`\`\`
|
|
1525
1637
|
*/
|
|
1526
1638
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1529
|
-
throw new
|
|
1530
|
-
const
|
|
1531
|
-
return (await this.getDirectoryHandle(
|
|
1639
|
+
const r = M(t);
|
|
1640
|
+
if (r.length === 0)
|
|
1641
|
+
throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1642
|
+
const i = r.pop();
|
|
1643
|
+
return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
|
|
1532
1644
|
}
|
|
1533
1645
|
/**
|
|
1534
1646
|
* Get a complete index of all files and directories in the file system
|
|
@@ -1551,9 +1663,9 @@ class ss {
|
|
|
1551
1663
|
*/
|
|
1552
1664
|
async index() {
|
|
1553
1665
|
const t = /* @__PURE__ */ new Map(), e = async (n) => {
|
|
1554
|
-
const
|
|
1555
|
-
for (const
|
|
1556
|
-
const o = \`\${n === "/" ? "" : n}/\${
|
|
1666
|
+
const r = await this.readDir(n);
|
|
1667
|
+
for (const i of r) {
|
|
1668
|
+
const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
|
|
1557
1669
|
try {
|
|
1558
1670
|
const a = await this.stat(o);
|
|
1559
1671
|
t.set(o, a), a.isDirectory && await e(o);
|
|
@@ -1593,17 +1705,17 @@ class ss {
|
|
|
1593
1705
|
async readFile(t) {
|
|
1594
1706
|
await this.mount();
|
|
1595
1707
|
try {
|
|
1596
|
-
return await
|
|
1708
|
+
return await L(t, "shared", async () => {
|
|
1597
1709
|
const e = await this.open(t);
|
|
1598
1710
|
try {
|
|
1599
|
-
const { size: n } = await this.fstat(e),
|
|
1600
|
-
return n > 0 && await this.read(e,
|
|
1711
|
+
const { size: n } = await this.fstat(e), r = new Uint8Array(n);
|
|
1712
|
+
return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
|
|
1601
1713
|
} finally {
|
|
1602
1714
|
await this.close(e);
|
|
1603
1715
|
}
|
|
1604
1716
|
});
|
|
1605
1717
|
} catch (e) {
|
|
1606
|
-
throw new
|
|
1718
|
+
throw new F("file", t, e);
|
|
1607
1719
|
}
|
|
1608
1720
|
}
|
|
1609
1721
|
/**
|
|
@@ -1631,14 +1743,14 @@ class ss {
|
|
|
1631
1743
|
async writeFile(t, e) {
|
|
1632
1744
|
await this.mount();
|
|
1633
1745
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1634
|
-
await
|
|
1635
|
-
const
|
|
1746
|
+
await L(t, "exclusive", async () => {
|
|
1747
|
+
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
1636
1748
|
try {
|
|
1637
|
-
await this.write(
|
|
1749
|
+
await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
|
|
1638
1750
|
} finally {
|
|
1639
|
-
await this.close(
|
|
1751
|
+
await this.close(i);
|
|
1640
1752
|
}
|
|
1641
|
-
await this.notifyChange({ path: t, type:
|
|
1753
|
+
await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
|
|
1642
1754
|
});
|
|
1643
1755
|
}
|
|
1644
1756
|
/**
|
|
@@ -1666,15 +1778,15 @@ class ss {
|
|
|
1666
1778
|
async appendFile(t, e) {
|
|
1667
1779
|
await this.mount();
|
|
1668
1780
|
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1669
|
-
await
|
|
1670
|
-
const
|
|
1781
|
+
await L(t, "exclusive", async () => {
|
|
1782
|
+
const r = await this.open(t, { create: !0 });
|
|
1671
1783
|
try {
|
|
1672
|
-
const { size:
|
|
1673
|
-
await this.write(
|
|
1784
|
+
const { size: i } = await this.fstat(r);
|
|
1785
|
+
await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
|
|
1674
1786
|
} finally {
|
|
1675
|
-
await this.close(
|
|
1787
|
+
await this.close(r);
|
|
1676
1788
|
}
|
|
1677
|
-
await this.notifyChange({ path: t, type:
|
|
1789
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
|
|
1678
1790
|
});
|
|
1679
1791
|
}
|
|
1680
1792
|
/**
|
|
@@ -1700,22 +1812,17 @@ class ss {
|
|
|
1700
1812
|
*/
|
|
1701
1813
|
async mkdir(t, e) {
|
|
1702
1814
|
await this.mount();
|
|
1703
|
-
const n = e?.recursive ?? !1,
|
|
1704
|
-
let
|
|
1705
|
-
for (let o = 0; o <
|
|
1706
|
-
const a =
|
|
1815
|
+
const n = e?.recursive ?? !1, r = M(t);
|
|
1816
|
+
let i = this.root;
|
|
1817
|
+
for (let o = 0; o < r.length; o++) {
|
|
1818
|
+
const a = r[o];
|
|
1707
1819
|
try {
|
|
1708
|
-
|
|
1820
|
+
i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
|
|
1709
1821
|
} catch (l) {
|
|
1710
|
-
throw l.name === "NotFoundError" ? new
|
|
1711
|
-
\`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
|
|
1712
|
-
"ENOENT",
|
|
1713
|
-
void 0,
|
|
1714
|
-
l
|
|
1715
|
-
) : 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);
|
|
1822
|
+
throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new z("file", a, l) : new Q("create directory", a, l);
|
|
1716
1823
|
}
|
|
1717
1824
|
}
|
|
1718
|
-
await this.notifyChange({ path: t, type:
|
|
1825
|
+
await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
|
|
1719
1826
|
}
|
|
1720
1827
|
/**
|
|
1721
1828
|
* Get file or directory statistics
|
|
@@ -1749,9 +1856,11 @@ class ss {
|
|
|
1749
1856
|
isFile: !1,
|
|
1750
1857
|
isDirectory: !0
|
|
1751
1858
|
};
|
|
1752
|
-
const e =
|
|
1859
|
+
const e = it(t);
|
|
1860
|
+
let n;
|
|
1753
1861
|
try {
|
|
1754
|
-
|
|
1862
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1863
|
+
const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1755
1864
|
kind: "file",
|
|
1756
1865
|
size: o.size,
|
|
1757
1866
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1759,19 +1868,21 @@ class ss {
|
|
|
1759
1868
|
isFile: !0,
|
|
1760
1869
|
isDirectory: !1
|
|
1761
1870
|
};
|
|
1762
|
-
if (
|
|
1871
|
+
if (r === "etag")
|
|
1763
1872
|
a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
|
|
1764
|
-
else if (typeof
|
|
1873
|
+
else if (typeof r == "string")
|
|
1765
1874
|
try {
|
|
1766
|
-
const l = await
|
|
1875
|
+
const l = await hs(o, r, this.options.maxFileSize);
|
|
1767
1876
|
a.hash = l;
|
|
1768
1877
|
} catch (l) {
|
|
1769
1878
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
1770
1879
|
}
|
|
1771
1880
|
return a;
|
|
1772
1881
|
} catch (r) {
|
|
1773
|
-
if (r.name
|
|
1774
|
-
throw new
|
|
1882
|
+
if (r.name === "NotFoundError")
|
|
1883
|
+
throw new F("file", t, r);
|
|
1884
|
+
if (r.name !== "TypeMismatchError")
|
|
1885
|
+
throw new Q("stat", t, r);
|
|
1775
1886
|
}
|
|
1776
1887
|
try {
|
|
1777
1888
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1783,7 +1894,7 @@ class ss {
|
|
|
1783
1894
|
isDirectory: !0
|
|
1784
1895
|
};
|
|
1785
1896
|
} catch (r) {
|
|
1786
|
-
throw
|
|
1897
|
+
throw new Q("stat", t, r);
|
|
1787
1898
|
}
|
|
1788
1899
|
}
|
|
1789
1900
|
/**
|
|
@@ -1807,11 +1918,11 @@ class ss {
|
|
|
1807
1918
|
async readDir(t) {
|
|
1808
1919
|
await this.mount();
|
|
1809
1920
|
const e = await this.getDirectoryHandle(t, !1), n = [];
|
|
1810
|
-
for await (const [
|
|
1811
|
-
const o =
|
|
1921
|
+
for await (const [r, i] of e.entries()) {
|
|
1922
|
+
const o = i.kind === "file";
|
|
1812
1923
|
n.push({
|
|
1813
|
-
name:
|
|
1814
|
-
kind:
|
|
1924
|
+
name: r,
|
|
1925
|
+
kind: i.kind,
|
|
1815
1926
|
isFile: o,
|
|
1816
1927
|
isDirectory: !o
|
|
1817
1928
|
});
|
|
@@ -1835,26 +1946,26 @@ class ss {
|
|
|
1835
1946
|
async exists(t) {
|
|
1836
1947
|
if (await this.mount(), t === "/")
|
|
1837
1948
|
return !0;
|
|
1838
|
-
const e =
|
|
1949
|
+
const e = it(t);
|
|
1839
1950
|
let n = null;
|
|
1840
1951
|
try {
|
|
1841
|
-
n = await this.getDirectoryHandle(
|
|
1842
|
-
} catch (
|
|
1843
|
-
if (n = null,
|
|
1844
|
-
throw
|
|
1952
|
+
n = await this.getDirectoryHandle(et(t), !1);
|
|
1953
|
+
} catch (r) {
|
|
1954
|
+
if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1955
|
+
throw r;
|
|
1845
1956
|
}
|
|
1846
1957
|
if (!n || !e)
|
|
1847
1958
|
return !1;
|
|
1848
1959
|
try {
|
|
1849
1960
|
return await n.getFileHandle(e, { create: !1 }), !0;
|
|
1850
|
-
} catch (
|
|
1851
|
-
if (
|
|
1852
|
-
throw
|
|
1961
|
+
} catch (r) {
|
|
1962
|
+
if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1963
|
+
throw r;
|
|
1853
1964
|
try {
|
|
1854
1965
|
return await n.getDirectoryHandle(e, { create: !1 }), !0;
|
|
1855
|
-
} catch (
|
|
1856
|
-
if (
|
|
1857
|
-
throw
|
|
1966
|
+
} catch (i) {
|
|
1967
|
+
if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1968
|
+
throw i;
|
|
1858
1969
|
return !1;
|
|
1859
1970
|
}
|
|
1860
1971
|
}
|
|
@@ -1883,12 +1994,12 @@ class ss {
|
|
|
1883
1994
|
try {
|
|
1884
1995
|
const e = await this.readDir(t);
|
|
1885
1996
|
for (const n of e) {
|
|
1886
|
-
const
|
|
1887
|
-
await this.remove(
|
|
1997
|
+
const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
|
|
1998
|
+
await this.remove(r, { recursive: !0 });
|
|
1888
1999
|
}
|
|
1889
|
-
await this.notifyChange({ path: t, type:
|
|
2000
|
+
await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
|
|
1890
2001
|
} catch (e) {
|
|
1891
|
-
throw e instanceof
|
|
2002
|
+
throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
|
|
1892
2003
|
}
|
|
1893
2004
|
}
|
|
1894
2005
|
/**
|
|
@@ -1917,9 +2028,9 @@ class ss {
|
|
|
1917
2028
|
*/
|
|
1918
2029
|
async remove(t, e) {
|
|
1919
2030
|
if (await this.mount(), t === "/")
|
|
1920
|
-
throw new
|
|
1921
|
-
const { recursive: n = !1, force:
|
|
1922
|
-
await
|
|
2031
|
+
throw new rt("EROOT", t);
|
|
2032
|
+
const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
|
|
2033
|
+
await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
|
|
1923
2034
|
}
|
|
1924
2035
|
/**
|
|
1925
2036
|
* Resolve a path to an absolute path
|
|
@@ -1942,12 +2053,12 @@ class ss {
|
|
|
1942
2053
|
async realpath(t) {
|
|
1943
2054
|
await this.mount();
|
|
1944
2055
|
try {
|
|
1945
|
-
const e =
|
|
2056
|
+
const e = Et(t);
|
|
1946
2057
|
if (!await this.exists(e))
|
|
1947
|
-
throw new
|
|
2058
|
+
throw new F("file", e);
|
|
1948
2059
|
return e;
|
|
1949
2060
|
} catch (e) {
|
|
1950
|
-
throw e instanceof
|
|
2061
|
+
throw e instanceof w ? e : A(e, { path: t });
|
|
1951
2062
|
}
|
|
1952
2063
|
}
|
|
1953
2064
|
/**
|
|
@@ -1975,12 +2086,12 @@ class ss {
|
|
|
1975
2086
|
async rename(t, e, n) {
|
|
1976
2087
|
await this.mount();
|
|
1977
2088
|
try {
|
|
1978
|
-
const
|
|
1979
|
-
if (await this.exists(e) && !
|
|
1980
|
-
throw new
|
|
1981
|
-
await this.copy(t, e, { recursive: !0, overwrite:
|
|
1982
|
-
} catch (
|
|
1983
|
-
throw
|
|
2089
|
+
const r = n?.overwrite ?? !1, i = await this.stat(t);
|
|
2090
|
+
if (await this.exists(e) && !r)
|
|
2091
|
+
throw new K(e);
|
|
2092
|
+
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 });
|
|
2093
|
+
} catch (r) {
|
|
2094
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
1984
2095
|
}
|
|
1985
2096
|
}
|
|
1986
2097
|
/**
|
|
@@ -2011,26 +2122,26 @@ class ss {
|
|
|
2011
2122
|
async copy(t, e, n) {
|
|
2012
2123
|
await this.mount();
|
|
2013
2124
|
try {
|
|
2014
|
-
const
|
|
2125
|
+
const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
|
|
2015
2126
|
if (!await this.exists(t))
|
|
2016
|
-
throw new
|
|
2017
|
-
if (await this.exists(e) && !
|
|
2018
|
-
throw new
|
|
2127
|
+
throw new F("source", t);
|
|
2128
|
+
if (await this.exists(e) && !i)
|
|
2129
|
+
throw new K(e);
|
|
2019
2130
|
if ((await this.stat(t)).isFile) {
|
|
2020
2131
|
const h = await this.readFile(t);
|
|
2021
2132
|
await this.writeFile(e, h);
|
|
2022
2133
|
} else {
|
|
2023
|
-
if (!
|
|
2024
|
-
throw new
|
|
2134
|
+
if (!r)
|
|
2135
|
+
throw new z("directory", t);
|
|
2025
2136
|
await this.mkdir(e, { recursive: !0 });
|
|
2026
2137
|
const h = await this.readDir(t);
|
|
2027
2138
|
for (const c of h) {
|
|
2028
2139
|
const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
|
|
2029
|
-
await this.copy(f, u, { recursive: !0, overwrite:
|
|
2140
|
+
await this.copy(f, u, { recursive: !0, overwrite: i });
|
|
2030
2141
|
}
|
|
2031
2142
|
}
|
|
2032
|
-
} catch (
|
|
2033
|
-
throw
|
|
2143
|
+
} catch (r) {
|
|
2144
|
+
throw r instanceof w ? r : A(r, { path: t });
|
|
2034
2145
|
}
|
|
2035
2146
|
}
|
|
2036
2147
|
/**
|
|
@@ -2060,9 +2171,9 @@ class ss {
|
|
|
2060
2171
|
*/
|
|
2061
2172
|
async watch(t, e) {
|
|
2062
2173
|
if (!this.options.broadcastChannel)
|
|
2063
|
-
throw new
|
|
2174
|
+
throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
2064
2175
|
const n = {
|
|
2065
|
-
pattern:
|
|
2176
|
+
pattern: ls(t, e?.recursive ?? !0),
|
|
2066
2177
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2067
2178
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2068
2179
|
};
|
|
@@ -2103,15 +2214,15 @@ class ss {
|
|
|
2103
2214
|
*/
|
|
2104
2215
|
async open(t, e) {
|
|
2105
2216
|
await this.mount();
|
|
2106
|
-
const { create: n = !1, exclusive:
|
|
2217
|
+
const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
|
|
2107
2218
|
try {
|
|
2108
|
-
return n &&
|
|
2219
|
+
return n && r ? await L(o, "exclusive", async () => {
|
|
2109
2220
|
if (await this.exists(o))
|
|
2110
|
-
throw new
|
|
2111
|
-
return this._openFile(o, n,
|
|
2112
|
-
}) : await this._openFile(o, n,
|
|
2221
|
+
throw new K(o);
|
|
2222
|
+
return this._openFile(o, n, i);
|
|
2223
|
+
}) : await this._openFile(o, n, i);
|
|
2113
2224
|
} catch (a) {
|
|
2114
|
-
throw a instanceof
|
|
2225
|
+
throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
|
|
2115
2226
|
}
|
|
2116
2227
|
}
|
|
2117
2228
|
/**
|
|
@@ -2119,19 +2230,19 @@ class ss {
|
|
|
2119
2230
|
* @private
|
|
2120
2231
|
*/
|
|
2121
2232
|
async _openFile(t, e, n) {
|
|
2122
|
-
const
|
|
2233
|
+
const r = await this.getFileHandle(t, e);
|
|
2123
2234
|
try {
|
|
2124
|
-
await
|
|
2235
|
+
await r.getFile();
|
|
2125
2236
|
} catch (a) {
|
|
2126
|
-
throw a
|
|
2237
|
+
throw A(a, { path: t, isDirectory: !0 });
|
|
2127
2238
|
}
|
|
2128
|
-
const
|
|
2129
|
-
n && (
|
|
2239
|
+
const i = await ps(r, t);
|
|
2240
|
+
n && (i.truncate(0), i.flush());
|
|
2130
2241
|
const o = this.nextFd++;
|
|
2131
2242
|
return this.openFiles.set(o, {
|
|
2132
2243
|
path: t,
|
|
2133
|
-
fileHandle:
|
|
2134
|
-
syncHandle:
|
|
2244
|
+
fileHandle: r,
|
|
2245
|
+
syncHandle: i,
|
|
2135
2246
|
position: 0
|
|
2136
2247
|
}), o;
|
|
2137
2248
|
}
|
|
@@ -2151,7 +2262,7 @@ class ss {
|
|
|
2151
2262
|
*/
|
|
2152
2263
|
async close(t) {
|
|
2153
2264
|
const e = this._getFileDescriptor(t);
|
|
2154
|
-
|
|
2265
|
+
xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2155
2266
|
}
|
|
2156
2267
|
/**
|
|
2157
2268
|
* Read data from a file descriptor
|
|
@@ -2177,17 +2288,17 @@ class ss {
|
|
|
2177
2288
|
* await fs.close(fd);
|
|
2178
2289
|
* \`\`\`
|
|
2179
2290
|
*/
|
|
2180
|
-
async read(t, e, n,
|
|
2291
|
+
async read(t, e, n, r, i) {
|
|
2181
2292
|
const o = this._getFileDescriptor(t);
|
|
2182
|
-
|
|
2293
|
+
St(e.length, n, r, i);
|
|
2183
2294
|
try {
|
|
2184
|
-
const a =
|
|
2295
|
+
const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
|
|
2185
2296
|
if (h)
|
|
2186
|
-
return
|
|
2297
|
+
return B({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2187
2298
|
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2188
|
-
return
|
|
2299
|
+
return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2189
2300
|
} catch (a) {
|
|
2190
|
-
throw
|
|
2301
|
+
throw j("read", t, o.path, a);
|
|
2191
2302
|
}
|
|
2192
2303
|
}
|
|
2193
2304
|
/**
|
|
@@ -2211,14 +2322,14 @@ class ss {
|
|
|
2211
2322
|
* await fs.close(fd);
|
|
2212
2323
|
* \`\`\`
|
|
2213
2324
|
*/
|
|
2214
|
-
async write(t, e, n = 0,
|
|
2215
|
-
const a = this._getFileDescriptor(t), l =
|
|
2216
|
-
|
|
2325
|
+
async write(t, e, n = 0, r, i, o = !0) {
|
|
2326
|
+
const a = this._getFileDescriptor(t), l = r ?? e.length - n;
|
|
2327
|
+
St(e.length, n, l, i);
|
|
2217
2328
|
try {
|
|
2218
|
-
const h =
|
|
2219
|
-
return (
|
|
2329
|
+
const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2330
|
+
return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
|
|
2220
2331
|
} catch (h) {
|
|
2221
|
-
throw
|
|
2332
|
+
throw j("write", t, a.path, h);
|
|
2222
2333
|
}
|
|
2223
2334
|
}
|
|
2224
2335
|
/**
|
|
@@ -2262,11 +2373,11 @@ class ss {
|
|
|
2262
2373
|
async ftruncate(t, e = 0) {
|
|
2263
2374
|
const n = this._getFileDescriptor(t);
|
|
2264
2375
|
if (e < 0 || !Number.isInteger(e))
|
|
2265
|
-
throw new
|
|
2376
|
+
throw new N("argument", "Invalid size");
|
|
2266
2377
|
try {
|
|
2267
|
-
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type:
|
|
2268
|
-
} catch (
|
|
2269
|
-
throw
|
|
2378
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
|
|
2379
|
+
} catch (r) {
|
|
2380
|
+
throw j("truncate", t, n.path, r);
|
|
2270
2381
|
}
|
|
2271
2382
|
}
|
|
2272
2383
|
/**
|
|
@@ -2288,7 +2399,7 @@ class ss {
|
|
|
2288
2399
|
try {
|
|
2289
2400
|
e.syncHandle.flush();
|
|
2290
2401
|
} catch (n) {
|
|
2291
|
-
throw
|
|
2402
|
+
throw j("sync", t, e.path, n);
|
|
2292
2403
|
}
|
|
2293
2404
|
}
|
|
2294
2405
|
/**
|
|
@@ -2300,7 +2411,7 @@ class ss {
|
|
|
2300
2411
|
dispose() {
|
|
2301
2412
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2302
2413
|
for (const [t, e] of this.openFiles)
|
|
2303
|
-
|
|
2414
|
+
xt(t, e.syncHandle, e.path);
|
|
2304
2415
|
this.openFiles.clear(), this.nextFd = 1;
|
|
2305
2416
|
}
|
|
2306
2417
|
/**
|
|
@@ -2335,22 +2446,22 @@ class ss {
|
|
|
2335
2446
|
await this.mount();
|
|
2336
2447
|
try {
|
|
2337
2448
|
for (const [e, n] of t) {
|
|
2338
|
-
const
|
|
2339
|
-
let
|
|
2340
|
-
n instanceof Blob ?
|
|
2449
|
+
const r = G(e);
|
|
2450
|
+
let i;
|
|
2451
|
+
n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
|
|
2341
2452
|
}
|
|
2342
2453
|
} catch (e) {
|
|
2343
|
-
throw e instanceof
|
|
2454
|
+
throw e instanceof w ? e : A(e);
|
|
2344
2455
|
}
|
|
2345
2456
|
}
|
|
2346
2457
|
}
|
|
2347
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2348
|
-
//# sourceMappingURL=worker-
|
|
2349
|
-
`,
|
|
2458
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
|
|
2459
|
+
//# sourceMappingURL=worker-BeJaVyBV.js.map
|
|
2460
|
+
`, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
|
|
2350
2461
|
function m(a) {
|
|
2351
2462
|
let n;
|
|
2352
2463
|
try {
|
|
2353
|
-
if (n =
|
|
2464
|
+
if (n = p && (self.URL || self.webkitURL).createObjectURL(p), !n) throw "";
|
|
2354
2465
|
const t = new Worker(n, {
|
|
2355
2466
|
type: "module",
|
|
2356
2467
|
name: a?.name
|
|
@@ -2360,7 +2471,7 @@ function m(a) {
|
|
|
2360
2471
|
}), t;
|
|
2361
2472
|
} catch {
|
|
2362
2473
|
return new Worker(
|
|
2363
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
2474
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(f),
|
|
2364
2475
|
{
|
|
2365
2476
|
type: "module",
|
|
2366
2477
|
name: a?.name
|
|
@@ -2371,7 +2482,7 @@ function m(a) {
|
|
|
2371
2482
|
function i(a) {
|
|
2372
2483
|
return a instanceof URL ? a.pathname : a;
|
|
2373
2484
|
}
|
|
2374
|
-
class
|
|
2485
|
+
class y {
|
|
2375
2486
|
#n;
|
|
2376
2487
|
promises = this;
|
|
2377
2488
|
constructor(n) {
|
|
@@ -2409,7 +2520,7 @@ class w {
|
|
|
2409
2520
|
let r;
|
|
2410
2521
|
typeof t == "string" ? r = t : t && typeof t == "object" && (r = t.encoding);
|
|
2411
2522
|
const s = await this.#n.readFile(e);
|
|
2412
|
-
return r || (r =
|
|
2523
|
+
return r || (r = h(e) ? "binary" : "utf-8"), r === "binary" ? s : l(s, r);
|
|
2413
2524
|
}
|
|
2414
2525
|
/**
|
|
2415
2526
|
* Write data to a file
|
|
@@ -2417,8 +2528,8 @@ class w {
|
|
|
2417
2528
|
async writeFile(n, t, e) {
|
|
2418
2529
|
const r = i(n);
|
|
2419
2530
|
let s;
|
|
2420
|
-
typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" ||
|
|
2421
|
-
const o = typeof t == "string" ?
|
|
2531
|
+
typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" || h(r) ? "binary" : "utf-8");
|
|
2532
|
+
const o = typeof t == "string" ? c(t, s) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2422
2533
|
return this.#n.writeFile(r, o);
|
|
2423
2534
|
}
|
|
2424
2535
|
/**
|
|
@@ -2426,8 +2537,8 @@ class w {
|
|
|
2426
2537
|
*/
|
|
2427
2538
|
async appendFile(n, t, e) {
|
|
2428
2539
|
const r = i(n);
|
|
2429
|
-
e || (e = typeof t != "string" ||
|
|
2430
|
-
const s = typeof t == "string" ?
|
|
2540
|
+
e || (e = typeof t != "string" || h(r) ? "binary" : "utf-8");
|
|
2541
|
+
const s = typeof t == "string" ? c(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2431
2542
|
return this.#n.appendFile(r, s);
|
|
2432
2543
|
}
|
|
2433
2544
|
/**
|
|
@@ -2609,59 +2720,66 @@ class w {
|
|
|
2609
2720
|
* Write text to a file with specified encoding
|
|
2610
2721
|
*/
|
|
2611
2722
|
async writeText(n, t, e = "utf-8") {
|
|
2612
|
-
const r = i(n), s =
|
|
2723
|
+
const r = i(n), s = c(t, e);
|
|
2613
2724
|
return this.#n.writeFile(r, s);
|
|
2614
2725
|
}
|
|
2615
2726
|
/**
|
|
2616
2727
|
* Append text to a file with specified encoding
|
|
2617
2728
|
*/
|
|
2618
2729
|
async appendText(n, t, e = "utf-8") {
|
|
2619
|
-
const r = i(n), s =
|
|
2730
|
+
const r = i(n), s = c(t, e);
|
|
2620
2731
|
return this.#n.appendFile(r, s);
|
|
2621
2732
|
}
|
|
2622
2733
|
}
|
|
2623
2734
|
function b(a) {
|
|
2624
|
-
return new
|
|
2735
|
+
return new y(a);
|
|
2625
2736
|
}
|
|
2626
2737
|
export {
|
|
2627
|
-
|
|
2628
|
-
S as
|
|
2629
|
-
P as
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
z as
|
|
2643
|
-
k as
|
|
2644
|
-
M as
|
|
2645
|
-
j as
|
|
2646
|
-
L as
|
|
2647
|
-
W as
|
|
2738
|
+
E as AlreadyExistsError,
|
|
2739
|
+
S as BINARY_FILE_EXTENSIONS,
|
|
2740
|
+
P as DirectoryOperationError,
|
|
2741
|
+
O as ExistenceError,
|
|
2742
|
+
F as FileBusyError,
|
|
2743
|
+
A as FileSystemOperationError,
|
|
2744
|
+
T as FileTypeError,
|
|
2745
|
+
R as IOError,
|
|
2746
|
+
C as InitializationFailedError,
|
|
2747
|
+
I as OPFSError,
|
|
2748
|
+
y as OPFSFileSystem,
|
|
2749
|
+
$ as OPFSNotSupportedError,
|
|
2750
|
+
D as OperationAbortedError,
|
|
2751
|
+
_ as OperationNotSupportedError,
|
|
2752
|
+
N as PathError,
|
|
2753
|
+
z as PermissionError,
|
|
2754
|
+
k as StorageError,
|
|
2755
|
+
M as ValidationError,
|
|
2756
|
+
j as WatchEventType,
|
|
2757
|
+
L as basename,
|
|
2758
|
+
W as buffersEqual,
|
|
2759
|
+
U as calculateFileHash,
|
|
2760
|
+
H as calculateReadLength,
|
|
2761
|
+
B as checkOPFSSupport,
|
|
2762
|
+
G as convertBlobToUint8Array,
|
|
2763
|
+
q as createBuffer,
|
|
2764
|
+
V as createFDError,
|
|
2765
|
+
Y as createSyncHandleSafe,
|
|
2648
2766
|
b as createWorker,
|
|
2649
2767
|
l as decodeBuffer,
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2768
|
+
J as dirname,
|
|
2769
|
+
c as encodeString,
|
|
2770
|
+
X as extname,
|
|
2771
|
+
h as isBinaryFileExtension,
|
|
2772
|
+
Z as isPathExcluded,
|
|
2773
|
+
K as joinPath,
|
|
2774
|
+
Q as mapDomError,
|
|
2775
|
+
nn as matchMinimatch,
|
|
2776
|
+
tn as normalizeMinimatch,
|
|
2777
|
+
en as normalizePath,
|
|
2778
|
+
rn as removeEntry,
|
|
2779
|
+
sn as resolvePath,
|
|
2780
|
+
an as safeCloseSyncHandle,
|
|
2781
|
+
on as splitPath,
|
|
2782
|
+
cn as validateReadWriteArgs,
|
|
2783
|
+
hn as withLock
|
|
2666
2784
|
};
|
|
2667
2785
|
//# sourceMappingURL=index.js.map
|