opfs-worker 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -20
- package/dist/BaseOPFS-Bu7FZtCb.cjs +2 -0
- package/dist/BaseOPFS-Bu7FZtCb.cjs.map +1 -0
- package/dist/{BaseOPFS-BusBkyJX.js → BaseOPFS-C3NE4BKr.js} +790 -548
- package/dist/BaseOPFS-C3NE4BKr.js.map +1 -0
- package/dist/OPFSAsync-C0RsxCX5.cjs +2 -0
- package/dist/OPFSAsync-C0RsxCX5.cjs.map +1 -0
- package/dist/{OPFSAsync-CO44W23e.js → OPFSAsync-aeLUdIqd.js} +19 -19
- package/dist/OPFSAsync-aeLUdIqd.js.map +1 -0
- package/dist/{OPFSFacade-hrNXCn6w.cjs → OPFSFacade-BJv2yuWU.cjs} +2 -2
- package/dist/{OPFSFacade-hrNXCn6w.cjs.map → OPFSFacade-BJv2yuWU.cjs.map} +1 -1
- package/dist/{OPFSFacade-CEaSqTut.js → OPFSFacade-DiogtQoq.js} +2 -2
- package/dist/{OPFSFacade-CEaSqTut.js.map → OPFSFacade-DiogtQoq.js.map} +1 -1
- package/dist/OPFSSync-3qlSBYmz.cjs +2 -0
- package/dist/OPFSSync-3qlSBYmz.cjs.map +1 -0
- package/dist/{OPFSSync-D7obTsl3.js → OPFSSync-CvSOswhW.js} +57 -57
- package/dist/OPFSSync-CvSOswhW.js.map +1 -0
- package/dist/assets/dedicated.worker-Bqqr9UBA.js.map +1 -0
- package/dist/core/BaseOPFS.d.ts +23 -3
- package/dist/core/BaseOPFS.d.ts.map +1 -1
- package/dist/core/OPFSAsync.d.ts.map +1 -1
- package/dist/core/OPFSSync.d.ts.map +1 -1
- package/dist/createOPFSAsync-B611B63X.js +10 -0
- package/dist/{createOPFSAsync-DdhJYoC0.js.map → createOPFSAsync-B611B63X.js.map} +1 -1
- package/dist/createOPFSAsync-BATjJg8k.cjs +2 -0
- package/dist/{createOPFSAsync-DyWpvmL-.cjs.map → createOPFSAsync-BATjJg8k.cjs.map} +1 -1
- package/dist/{createOPFSDedicated-BwTc0NV5.js → createOPFSDedicated-DgudPTB8.js} +1086 -817
- package/dist/createOPFSDedicated-DgudPTB8.js.map +1 -0
- package/dist/{createOPFSDedicated-CEeRexom.cjs → createOPFSDedicated-EmIwluQo.cjs} +1037 -797
- package/dist/createOPFSDedicated-EmIwluQo.cjs.map +1 -0
- package/dist/{createOPFSShared-BSFWsoLe.js → createOPFSShared-BWYln8jJ.js} +2 -2
- package/dist/{createOPFSShared-BSFWsoLe.js.map → createOPFSShared-BWYln8jJ.js.map} +1 -1
- package/dist/{createOPFSShared-BoCft_BS.cjs → createOPFSShared-DPJpCd7z.cjs} +2 -2
- package/dist/{createOPFSShared-BoCft_BS.cjs.map → createOPFSShared-DPJpCd7z.cjs.map} +1 -1
- package/dist/dedicated.worker.js +1034 -794
- package/dist/dedicated.worker.js.map +1 -1
- package/dist/facade/createOPFSDedicated.d.ts +4 -2
- package/dist/facade/createOPFSDedicated.d.ts.map +1 -1
- package/dist/index.async.cjs +1 -1
- package/dist/index.async.js +33 -32
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -43
- package/dist/index.pure.cjs +1 -1
- package/dist/index.pure.js +38 -37
- package/dist/index.sharedworker.cjs +1 -1
- package/dist/index.sharedworker.js +34 -33
- package/dist/index.sync.cjs +1 -1
- package/dist/index.sync.d.ts +2 -0
- package/dist/index.sync.d.ts.map +1 -1
- package/dist/index.sync.js +34 -32
- package/dist/shared.worker.js +1056 -820
- package/dist/shared.worker.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +13 -3
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker/createDedicatedWorker.d.ts +8 -3
- package/dist/worker/createDedicatedWorker.d.ts.map +1 -1
- package/docs/README.md +18 -0
- package/docs/api/README.md +221 -0
- package/docs/{file-descriptors.md → api/file-descriptors.md} +13 -13
- package/docs/guides/async.md +2 -2
- package/docs/guides/dedicated.md +6 -4
- package/docs/guides/hashing.md +1 -1
- package/docs/guides/pure.md +1 -1
- package/docs/guides/sharedworker.md +1 -1
- package/docs/guides/streaming.md +2 -2
- package/docs/migration.md +8 -9
- package/docs/types.md +4 -4
- package/package.json +10 -9
- package/src/core/BaseOPFS.ts +46 -4
- package/src/core/OPFSAsync.ts +4 -5
- package/src/core/OPFSSync.ts +6 -7
- package/src/facade/createOPFSDedicated.ts +4 -2
- package/src/index.sync.ts +2 -0
- package/src/index.ts +1 -5
- package/src/types.ts +5 -3
- package/src/utils/helpers.ts +32 -6
- package/src/worker/createDedicatedWorker.ts +85 -7
- package/src/worker/dedicated.worker.ts +12 -1
- package/dist/BaseOPFS-BusBkyJX.js.map +0 -1
- package/dist/BaseOPFS-CYwrD7-q.cjs +0 -4
- package/dist/BaseOPFS-CYwrD7-q.cjs.map +0 -1
- package/dist/OPFSAsync-B2dR-2VR.cjs +0 -2
- package/dist/OPFSAsync-B2dR-2VR.cjs.map +0 -1
- package/dist/OPFSAsync-CO44W23e.js.map +0 -1
- package/dist/OPFSSync-BPrNtvFS.cjs +0 -2
- package/dist/OPFSSync-BPrNtvFS.cjs.map +0 -1
- package/dist/OPFSSync-D7obTsl3.js.map +0 -1
- package/dist/assets/dedicated.worker-DW6UqFo0.js.map +0 -1
- package/dist/createOPFSAsync-DdhJYoC0.js +0 -10
- package/dist/createOPFSAsync-DyWpvmL-.cjs +0 -2
- package/dist/createOPFSDedicated-BwTc0NV5.js.map +0 -1
- package/dist/createOPFSDedicated-CEeRexom.cjs.map +0 -1
- package/docs/api/backend.md +0 -36
- package/docs/api/create.md +0 -82
- package/docs/api/facade.md +0 -53
- package/docs/choosing-a-mode.md +0 -41
package/dist/dedicated.worker.js
CHANGED
|
@@ -1,107 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
const bt = Symbol("Comlink.proxy"), Wt = Symbol("Comlink.endpoint"), jt = Symbol("Comlink.releaseProxy"), X = Symbol("Comlink.finalizer"), j = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", _t = {
|
|
7
|
-
canHandle: (s) => Ot(s) && s[bt],
|
|
8
|
-
serialize(s) {
|
|
1
|
+
const Ot = /* @__PURE__ */ Symbol("Comlink.proxy"), Bt = /* @__PURE__ */ Symbol("Comlink.endpoint"), Gt = /* @__PURE__ */ Symbol("Comlink.releaseProxy"), X = /* @__PURE__ */ Symbol("Comlink.finalizer"), H = /* @__PURE__ */ Symbol("Comlink.thrown"), Dt = (n) => typeof n == "object" && n !== null || typeof n == "function", Ut = {
|
|
2
|
+
canHandle: (n) => Dt(n) && n[Ot],
|
|
3
|
+
serialize(n) {
|
|
9
4
|
const { port1: t, port2: e } = new MessageChannel();
|
|
10
|
-
return
|
|
5
|
+
return U(n, t), [e, [e]];
|
|
11
6
|
},
|
|
12
|
-
deserialize(
|
|
13
|
-
return
|
|
7
|
+
deserialize(n) {
|
|
8
|
+
return n.start(), Yt(n);
|
|
14
9
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (
|
|
17
|
-
serialize({ value:
|
|
10
|
+
}, qt = {
|
|
11
|
+
canHandle: (n) => Dt(n) && H in n,
|
|
12
|
+
serialize({ value: n }) {
|
|
18
13
|
let t;
|
|
19
|
-
return
|
|
14
|
+
return n instanceof Error ? t = {
|
|
20
15
|
isError: !0,
|
|
21
16
|
value: {
|
|
22
|
-
message:
|
|
23
|
-
name:
|
|
24
|
-
stack:
|
|
17
|
+
message: n.message,
|
|
18
|
+
name: n.name,
|
|
19
|
+
stack: n.stack
|
|
25
20
|
}
|
|
26
|
-
} : t = { isError: !1, value:
|
|
21
|
+
} : t = { isError: !1, value: n }, [t, []];
|
|
27
22
|
},
|
|
28
|
-
deserialize(
|
|
29
|
-
throw
|
|
23
|
+
deserialize(n) {
|
|
24
|
+
throw n.isError ? Object.assign(new Error(n.value.message), n.value) : n.value;
|
|
30
25
|
}
|
|
31
|
-
},
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
26
|
+
}, Mt = /* @__PURE__ */ new Map([
|
|
27
|
+
["proxy", Ut],
|
|
28
|
+
["throw", qt]
|
|
34
29
|
]);
|
|
35
|
-
function
|
|
36
|
-
for (const e of
|
|
30
|
+
function Vt(n, t) {
|
|
31
|
+
for (const e of n)
|
|
37
32
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
38
33
|
return !0;
|
|
39
34
|
return !1;
|
|
40
35
|
}
|
|
41
|
-
function
|
|
42
|
-
t.addEventListener("message", function
|
|
36
|
+
function U(n, t = globalThis, e = ["*"]) {
|
|
37
|
+
t.addEventListener("message", function s(r) {
|
|
43
38
|
if (!r || !r.data)
|
|
44
39
|
return;
|
|
45
|
-
if (!
|
|
40
|
+
if (!Vt(e, r.origin)) {
|
|
46
41
|
console.warn(`Invalid origin '${r.origin}' for comlink proxy`);
|
|
47
42
|
return;
|
|
48
43
|
}
|
|
49
|
-
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(
|
|
50
|
-
let
|
|
44
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), c = (r.data.argumentList || []).map(T);
|
|
45
|
+
let l;
|
|
51
46
|
try {
|
|
52
|
-
const
|
|
47
|
+
const h = a.slice(0, -1).reduce((f, p) => f[p], n), u = a.reduce((f, p) => f[p], n);
|
|
53
48
|
switch (o) {
|
|
54
49
|
case "GET":
|
|
55
|
-
|
|
50
|
+
l = u;
|
|
56
51
|
break;
|
|
57
52
|
case "SET":
|
|
58
|
-
|
|
53
|
+
h[a.slice(-1)[0]] = T(r.data.value), l = !0;
|
|
59
54
|
break;
|
|
60
55
|
case "APPLY":
|
|
61
|
-
|
|
56
|
+
l = u.apply(h, c);
|
|
62
57
|
break;
|
|
63
58
|
case "CONSTRUCT":
|
|
64
59
|
{
|
|
65
|
-
const
|
|
66
|
-
|
|
60
|
+
const f = new u(...c);
|
|
61
|
+
l = Kt(f);
|
|
67
62
|
}
|
|
68
63
|
break;
|
|
69
64
|
case "ENDPOINT":
|
|
70
65
|
{
|
|
71
|
-
const { port1:
|
|
72
|
-
|
|
66
|
+
const { port1: f, port2: p } = new MessageChannel();
|
|
67
|
+
U(n, p), l = z(f, [f]);
|
|
73
68
|
}
|
|
74
69
|
break;
|
|
75
70
|
case "RELEASE":
|
|
76
|
-
|
|
71
|
+
l = void 0;
|
|
77
72
|
break;
|
|
78
73
|
default:
|
|
79
74
|
return;
|
|
80
75
|
}
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
76
|
+
} catch (h) {
|
|
77
|
+
l = { value: h, [H]: 0 };
|
|
83
78
|
}
|
|
84
|
-
Promise.resolve(
|
|
85
|
-
const [
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({},
|
|
87
|
-
}).catch((
|
|
88
|
-
const [
|
|
79
|
+
Promise.resolve(l).catch((h) => ({ value: h, [H]: 0 })).then((h) => {
|
|
80
|
+
const [u, f] = B(h);
|
|
81
|
+
t.postMessage(Object.assign(Object.assign({}, u), { id: i }), f), o === "RELEASE" && (t.removeEventListener("message", s), $t(t), X in n && typeof n[X] == "function" && n[X]());
|
|
82
|
+
}).catch((h) => {
|
|
83
|
+
const [u, f] = B({
|
|
89
84
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
85
|
+
[H]: 0
|
|
91
86
|
});
|
|
92
|
-
t.postMessage(Object.assign(Object.assign({},
|
|
87
|
+
t.postMessage(Object.assign(Object.assign({}, u), { id: i }), f);
|
|
93
88
|
});
|
|
94
89
|
}), t.start && t.start();
|
|
95
90
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
91
|
+
function Xt(n) {
|
|
92
|
+
return n.constructor.name === "MessagePort";
|
|
98
93
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
94
|
+
function $t(n) {
|
|
95
|
+
Xt(n) && n.close();
|
|
101
96
|
}
|
|
102
|
-
function
|
|
97
|
+
function Yt(n, t) {
|
|
103
98
|
const e = /* @__PURE__ */ new Map();
|
|
104
|
-
return
|
|
99
|
+
return n.addEventListener("message", function(r) {
|
|
105
100
|
const { data: i } = r;
|
|
106
101
|
if (!i || !i.id)
|
|
107
102
|
return;
|
|
@@ -112,110 +107,110 @@ function qt(s, t) {
|
|
|
112
107
|
} finally {
|
|
113
108
|
e.delete(i.id);
|
|
114
109
|
}
|
|
115
|
-
}),
|
|
110
|
+
}), K(n, e, [], t);
|
|
116
111
|
}
|
|
117
|
-
function
|
|
118
|
-
if (
|
|
112
|
+
function k(n) {
|
|
113
|
+
if (n)
|
|
119
114
|
throw new Error("Proxy has been released and is not useable");
|
|
120
115
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
116
|
+
function Tt(n) {
|
|
117
|
+
return N(n, /* @__PURE__ */ new Map(), {
|
|
123
118
|
type: "RELEASE"
|
|
124
119
|
}).then(() => {
|
|
125
|
-
|
|
120
|
+
$t(n);
|
|
126
121
|
});
|
|
127
122
|
}
|
|
128
|
-
const
|
|
129
|
-
const t = (
|
|
130
|
-
|
|
123
|
+
const W = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((n) => {
|
|
124
|
+
const t = (W.get(n) || 0) - 1;
|
|
125
|
+
W.set(n, t), t === 0 && Tt(n);
|
|
131
126
|
});
|
|
132
|
-
function
|
|
133
|
-
const e = (
|
|
134
|
-
|
|
127
|
+
function Zt(n, t) {
|
|
128
|
+
const e = (W.get(t) || 0) + 1;
|
|
129
|
+
W.set(t, e), j && j.register(n, t, n);
|
|
135
130
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
131
|
+
function Jt(n) {
|
|
132
|
+
j && j.unregister(n);
|
|
138
133
|
}
|
|
139
|
-
function
|
|
134
|
+
function K(n, t, e = [], s = function() {
|
|
140
135
|
}) {
|
|
141
136
|
let r = !1;
|
|
142
|
-
const i = new Proxy(
|
|
137
|
+
const i = new Proxy(s, {
|
|
143
138
|
get(o, a) {
|
|
144
|
-
if (
|
|
139
|
+
if (k(r), a === Gt)
|
|
145
140
|
return () => {
|
|
146
|
-
|
|
141
|
+
Jt(i), Tt(n), t.clear(), r = !0;
|
|
147
142
|
};
|
|
148
143
|
if (a === "then") {
|
|
149
144
|
if (e.length === 0)
|
|
150
145
|
return { then: () => i };
|
|
151
|
-
const c =
|
|
146
|
+
const c = N(n, t, {
|
|
152
147
|
type: "GET",
|
|
153
|
-
path: e.map((
|
|
154
|
-
}).then(
|
|
148
|
+
path: e.map((l) => l.toString())
|
|
149
|
+
}).then(T);
|
|
155
150
|
return c.then.bind(c);
|
|
156
151
|
}
|
|
157
|
-
return
|
|
152
|
+
return K(n, t, [...e, a]);
|
|
158
153
|
},
|
|
159
154
|
set(o, a, c) {
|
|
160
|
-
|
|
161
|
-
const [
|
|
162
|
-
return
|
|
155
|
+
k(r);
|
|
156
|
+
const [l, h] = B(c);
|
|
157
|
+
return N(n, t, {
|
|
163
158
|
type: "SET",
|
|
164
|
-
path: [...e, a].map((
|
|
165
|
-
value:
|
|
166
|
-
},
|
|
159
|
+
path: [...e, a].map((u) => u.toString()),
|
|
160
|
+
value: l
|
|
161
|
+
}, h).then(T);
|
|
167
162
|
},
|
|
168
163
|
apply(o, a, c) {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
164
|
+
k(r);
|
|
165
|
+
const l = e[e.length - 1];
|
|
166
|
+
if (l === Bt)
|
|
167
|
+
return N(n, t, {
|
|
173
168
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
const [
|
|
178
|
-
return
|
|
169
|
+
}).then(T);
|
|
170
|
+
if (l === "bind")
|
|
171
|
+
return K(n, t, e.slice(0, -1));
|
|
172
|
+
const [h, u] = ut(c);
|
|
173
|
+
return N(n, t, {
|
|
179
174
|
type: "APPLY",
|
|
180
|
-
path: e.map((
|
|
181
|
-
argumentList:
|
|
182
|
-
},
|
|
175
|
+
path: e.map((f) => f.toString()),
|
|
176
|
+
argumentList: h
|
|
177
|
+
}, u).then(T);
|
|
183
178
|
},
|
|
184
179
|
construct(o, a) {
|
|
185
|
-
|
|
186
|
-
const [c,
|
|
187
|
-
return
|
|
180
|
+
k(r);
|
|
181
|
+
const [c, l] = ut(a);
|
|
182
|
+
return N(n, t, {
|
|
188
183
|
type: "CONSTRUCT",
|
|
189
|
-
path: e.map((
|
|
184
|
+
path: e.map((h) => h.toString()),
|
|
190
185
|
argumentList: c
|
|
191
|
-
},
|
|
186
|
+
}, l).then(T);
|
|
192
187
|
}
|
|
193
188
|
});
|
|
194
|
-
return
|
|
189
|
+
return Zt(i, n), i;
|
|
195
190
|
}
|
|
196
|
-
function
|
|
197
|
-
return Array.prototype.concat.apply([],
|
|
191
|
+
function Qt(n) {
|
|
192
|
+
return Array.prototype.concat.apply([], n);
|
|
198
193
|
}
|
|
199
|
-
function
|
|
200
|
-
const t =
|
|
201
|
-
return [t.map((e) => e[0]),
|
|
194
|
+
function ut(n) {
|
|
195
|
+
const t = n.map(B);
|
|
196
|
+
return [t.map((e) => e[0]), Qt(t.map((e) => e[1]))];
|
|
202
197
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
198
|
+
const Nt = /* @__PURE__ */ new WeakMap();
|
|
199
|
+
function z(n, t) {
|
|
200
|
+
return Nt.set(n, t), n;
|
|
206
201
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(
|
|
202
|
+
function Kt(n) {
|
|
203
|
+
return Object.assign(n, { [Ot]: !0 });
|
|
209
204
|
}
|
|
210
|
-
function
|
|
211
|
-
for (const [t, e] of
|
|
212
|
-
if (e.canHandle(
|
|
213
|
-
const [
|
|
205
|
+
function B(n) {
|
|
206
|
+
for (const [t, e] of Mt)
|
|
207
|
+
if (e.canHandle(n)) {
|
|
208
|
+
const [s, r] = e.serialize(n);
|
|
214
209
|
return [
|
|
215
210
|
{
|
|
216
211
|
type: "HANDLER",
|
|
217
212
|
name: t,
|
|
218
|
-
value:
|
|
213
|
+
value: s
|
|
219
214
|
},
|
|
220
215
|
r
|
|
221
216
|
];
|
|
@@ -223,30 +218,30 @@ function q(s) {
|
|
|
223
218
|
return [
|
|
224
219
|
{
|
|
225
220
|
type: "RAW",
|
|
226
|
-
value:
|
|
221
|
+
value: n
|
|
227
222
|
},
|
|
228
|
-
|
|
223
|
+
Nt.get(n) || []
|
|
229
224
|
];
|
|
230
225
|
}
|
|
231
|
-
function
|
|
232
|
-
switch (
|
|
226
|
+
function T(n) {
|
|
227
|
+
switch (n.type) {
|
|
233
228
|
case "HANDLER":
|
|
234
|
-
return
|
|
229
|
+
return Mt.get(n.name).deserialize(n.value);
|
|
235
230
|
case "RAW":
|
|
236
|
-
return
|
|
231
|
+
return n.value;
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
|
-
function
|
|
234
|
+
function N(n, t, e, s) {
|
|
240
235
|
return new Promise((r) => {
|
|
241
|
-
const i =
|
|
242
|
-
t.set(i, r),
|
|
236
|
+
const i = te();
|
|
237
|
+
t.set(i, r), n.start && n.start(), n.postMessage(Object.assign({ id: i }, e), s);
|
|
243
238
|
});
|
|
244
239
|
}
|
|
245
|
-
function
|
|
240
|
+
function te() {
|
|
246
241
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
242
|
}
|
|
248
|
-
var O = /* @__PURE__ */ ((
|
|
249
|
-
const
|
|
243
|
+
var O = /* @__PURE__ */ ((n) => (n.Added = "added", n.Changed = "changed", n.Removed = "removed", n))(O || {});
|
|
244
|
+
const ee = {
|
|
250
245
|
ENOENT: -2,
|
|
251
246
|
// No such file or directory
|
|
252
247
|
EISDIR: -21,
|
|
@@ -278,258 +273,291 @@ const Qt = {
|
|
|
278
273
|
EROOT: -1
|
|
279
274
|
// Custom: Cannot remove root directory
|
|
280
275
|
};
|
|
281
|
-
class
|
|
276
|
+
class y extends Error {
|
|
282
277
|
errno;
|
|
283
278
|
syscall;
|
|
284
279
|
path;
|
|
285
|
-
constructor(t, e,
|
|
286
|
-
super(t, { cause: i }), this.name = e, this.errno =
|
|
280
|
+
constructor(t, e, s, r, i) {
|
|
281
|
+
super(t, { cause: i }), this.name = e, this.errno = ee[e] || -1, this.path = s, this.syscall = r;
|
|
287
282
|
}
|
|
288
283
|
}
|
|
289
|
-
class
|
|
284
|
+
class se extends y {
|
|
290
285
|
constructor(t) {
|
|
291
286
|
super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
|
|
292
287
|
}
|
|
293
288
|
}
|
|
294
|
-
class
|
|
295
|
-
constructor(t, e,
|
|
296
|
-
super(t, "INVALID_PATH", e, "access",
|
|
289
|
+
class ne extends y {
|
|
290
|
+
constructor(t, e, s) {
|
|
291
|
+
super(t, "INVALID_PATH", e, "access", s);
|
|
297
292
|
}
|
|
298
293
|
}
|
|
299
|
-
class
|
|
300
|
-
constructor(t, e,
|
|
294
|
+
class _ extends y {
|
|
295
|
+
constructor(t, e, s) {
|
|
301
296
|
const r = {
|
|
302
297
|
file: `File not found: ${e}`,
|
|
303
298
|
directory: `Directory not found: ${e}`,
|
|
304
299
|
source: `Source does not exist: ${e}`
|
|
305
300
|
};
|
|
306
|
-
super(r[t], "ENOENT", e, "access",
|
|
301
|
+
super(r[t], "ENOENT", e, "access", s);
|
|
307
302
|
}
|
|
308
303
|
}
|
|
309
|
-
class
|
|
310
|
-
constructor(t, e,
|
|
311
|
-
super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e,
|
|
304
|
+
class re extends y {
|
|
305
|
+
constructor(t, e, s) {
|
|
306
|
+
super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e, s);
|
|
312
307
|
}
|
|
313
308
|
}
|
|
314
|
-
class
|
|
315
|
-
constructor(t, e,
|
|
316
|
-
super(t, "ENOSPC", e, "write",
|
|
309
|
+
class ie extends y {
|
|
310
|
+
constructor(t, e, s) {
|
|
311
|
+
super(t, "ENOSPC", e, "write", s);
|
|
317
312
|
}
|
|
318
313
|
}
|
|
319
|
-
class
|
|
314
|
+
class oe extends y {
|
|
320
315
|
constructor(t, e) {
|
|
321
316
|
super(`File is busy: ${t}`, "EBUSY", t, "open", e);
|
|
322
317
|
}
|
|
323
318
|
}
|
|
324
|
-
class
|
|
325
|
-
constructor(t, e,
|
|
319
|
+
class tt extends y {
|
|
320
|
+
constructor(t, e, s) {
|
|
326
321
|
const r = t === "directory" ? `Is a directory: ${e}` : `Not a directory: ${e}`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
|
|
327
|
-
super(r, i, e, "access",
|
|
322
|
+
super(r, i, e, "access", s);
|
|
328
323
|
}
|
|
329
324
|
}
|
|
330
|
-
class
|
|
331
|
-
constructor(t, e,
|
|
325
|
+
class $ extends y {
|
|
326
|
+
constructor(t, e, s, r) {
|
|
332
327
|
const i = {
|
|
333
328
|
argument: "EINVAL",
|
|
334
329
|
format: "INVALID_FORMAT",
|
|
335
330
|
descriptor: "EBADF",
|
|
336
331
|
overflow: "ERANGE"
|
|
337
332
|
};
|
|
338
|
-
super(e, i[t],
|
|
333
|
+
super(e, i[t], s, "validate", r);
|
|
339
334
|
}
|
|
340
335
|
}
|
|
341
|
-
class
|
|
336
|
+
class ae extends y {
|
|
342
337
|
constructor(t, e) {
|
|
343
338
|
super(`Operation aborted: ${t}`, "EINTR", t, "interrupt", e);
|
|
344
339
|
}
|
|
345
340
|
}
|
|
346
|
-
class
|
|
347
|
-
constructor(t, e,
|
|
348
|
-
super(t, "EIO", e, "io",
|
|
341
|
+
class ft extends y {
|
|
342
|
+
constructor(t, e, s) {
|
|
343
|
+
super(t, "EIO", e, "io", s);
|
|
349
344
|
}
|
|
350
345
|
}
|
|
351
|
-
class
|
|
346
|
+
class Ct extends y {
|
|
352
347
|
constructor(t, e) {
|
|
353
348
|
super(`Operation not supported: ${t}`, "ENOTSUP", t, "operation", e);
|
|
354
349
|
}
|
|
355
350
|
}
|
|
356
|
-
class
|
|
357
|
-
constructor(t, e,
|
|
351
|
+
class et extends y {
|
|
352
|
+
constructor(t, e, s) {
|
|
358
353
|
const r = {
|
|
359
354
|
RM_FAILED: `Failed to remove entry: ${e}`,
|
|
360
355
|
ENOTEMPTY: `Directory not empty: ${e}. Use recursive option to force removal.`,
|
|
361
356
|
EROOT: "Cannot remove root directory"
|
|
362
357
|
};
|
|
363
|
-
super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink",
|
|
358
|
+
super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink", s);
|
|
364
359
|
}
|
|
365
360
|
}
|
|
366
|
-
class
|
|
361
|
+
class ce extends y {
|
|
367
362
|
constructor(t, e) {
|
|
368
363
|
super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
|
|
369
364
|
}
|
|
370
365
|
}
|
|
371
|
-
class
|
|
372
|
-
constructor(t, e,
|
|
373
|
-
super(`Failed to ${t}: ${e}`, `${t.toUpperCase()}_FAILED`, e, t,
|
|
366
|
+
class Y extends y {
|
|
367
|
+
constructor(t, e, s) {
|
|
368
|
+
super(`Failed to ${t}: ${e}`, `${t.toUpperCase()}_FAILED`, e, t, s);
|
|
374
369
|
}
|
|
375
370
|
}
|
|
376
|
-
class
|
|
371
|
+
class st extends y {
|
|
377
372
|
constructor(t, e) {
|
|
378
373
|
super(`Destination already exists: ${t}`, "EEXIST", t, "open", e);
|
|
379
374
|
}
|
|
380
375
|
}
|
|
381
|
-
function
|
|
382
|
-
const r = `${
|
|
383
|
-
return new
|
|
376
|
+
function I(n, t, e, s) {
|
|
377
|
+
const r = `${n.toUpperCase()}_FAILED`;
|
|
378
|
+
return new y(`Failed to ${n} file descriptor: ${t}`, r, e, n, s);
|
|
384
379
|
}
|
|
385
|
-
function
|
|
386
|
-
const e = t?.path,
|
|
387
|
-
switch (
|
|
380
|
+
function A(n, t) {
|
|
381
|
+
const e = t?.path, s = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
|
|
382
|
+
switch (n.name) {
|
|
388
383
|
case "InvalidStateError":
|
|
389
|
-
return new
|
|
384
|
+
return new oe(e || "unknown", n);
|
|
390
385
|
case "QuotaExceededError":
|
|
391
|
-
return new
|
|
386
|
+
return new ie(`No space left on device: ${e || "unknown"}`, e, n);
|
|
392
387
|
case "NotFoundError":
|
|
393
|
-
return new
|
|
388
|
+
return new _(r, e, n);
|
|
394
389
|
case "TypeMismatchError":
|
|
395
|
-
return
|
|
390
|
+
return s !== void 0 ? s ? new tt("directory", e || "unknown", n) : new tt("file", e || "unknown", n) : new $("argument", `Type mismatch: ${e || "unknown"}`, e, n);
|
|
396
391
|
case "NotAllowedError":
|
|
397
392
|
case "SecurityError":
|
|
398
|
-
return new
|
|
393
|
+
return new re(e, "unknown", n);
|
|
399
394
|
case "InvalidModificationError":
|
|
400
|
-
return i === "remove" ? new
|
|
395
|
+
return i === "remove" ? new et("ENOTEMPTY", e, n) : new $("argument", `Invalid modification: ${e || "unknown"}`, e, n);
|
|
401
396
|
case "AbortError":
|
|
402
|
-
return new
|
|
397
|
+
return new ae(e || "unknown", n);
|
|
403
398
|
case "OperationError":
|
|
404
|
-
return new
|
|
399
|
+
return new ft(`Operation failed: ${e || "unknown"}`, e, n);
|
|
405
400
|
case "TypeError":
|
|
406
|
-
return new
|
|
401
|
+
return new Ct(e || "unknown", n);
|
|
407
402
|
default:
|
|
408
|
-
return i === "remove" ? new
|
|
403
|
+
return i === "remove" ? new et("RM_FAILED", e, n) : new ft(`I/O error: ${e || "unknown"}`, e, n);
|
|
409
404
|
}
|
|
410
405
|
}
|
|
411
|
-
const
|
|
412
|
-
const
|
|
406
|
+
const vt = (n, t, e) => {
|
|
407
|
+
const s = n instanceof RegExp ? pt(n, e) : n, r = t instanceof RegExp ? pt(t, e) : t, i = s !== null && r != null && le(s, r, e);
|
|
413
408
|
return i && {
|
|
414
409
|
start: i[0],
|
|
415
410
|
end: i[1],
|
|
416
411
|
pre: e.slice(0, i[0]),
|
|
417
|
-
body: e.slice(i[0] +
|
|
412
|
+
body: e.slice(i[0] + s.length, i[1]),
|
|
418
413
|
post: e.slice(i[1] + r.length)
|
|
419
414
|
};
|
|
420
|
-
},
|
|
421
|
-
const e = t.match(
|
|
415
|
+
}, pt = (n, t) => {
|
|
416
|
+
const e = t.match(n);
|
|
422
417
|
return e ? e[0] : null;
|
|
423
|
-
},
|
|
424
|
-
let
|
|
425
|
-
if (c >= 0 &&
|
|
426
|
-
if (
|
|
427
|
-
return [c,
|
|
428
|
-
for (
|
|
429
|
-
if (
|
|
430
|
-
|
|
431
|
-
else if (
|
|
432
|
-
const
|
|
433
|
-
|
|
418
|
+
}, le = (n, t, e) => {
|
|
419
|
+
let s, r, i, o, a, c = e.indexOf(n), l = e.indexOf(t, c + 1), h = c;
|
|
420
|
+
if (c >= 0 && l > 0) {
|
|
421
|
+
if (n === t)
|
|
422
|
+
return [c, l];
|
|
423
|
+
for (s = [], i = e.length; h >= 0 && !a; ) {
|
|
424
|
+
if (h === c)
|
|
425
|
+
s.push(h), c = e.indexOf(n, h + 1);
|
|
426
|
+
else if (s.length === 1) {
|
|
427
|
+
const u = s.pop();
|
|
428
|
+
u !== void 0 && (a = [u, l]);
|
|
434
429
|
} else
|
|
435
|
-
r =
|
|
436
|
-
|
|
430
|
+
r = s.pop(), r !== void 0 && r < i && (i = r, o = l), l = e.indexOf(t, h + 1);
|
|
431
|
+
h = c < l && c >= 0 ? c : l;
|
|
437
432
|
}
|
|
438
|
-
|
|
433
|
+
s.length && o !== void 0 && (a = [i, o]);
|
|
439
434
|
}
|
|
440
435
|
return a;
|
|
441
|
-
},
|
|
442
|
-
function
|
|
443
|
-
return isNaN(
|
|
436
|
+
}, Ft = "\0SLASH" + Math.random() + "\0", Pt = "\0OPEN" + Math.random() + "\0", ot = "\0CLOSE" + Math.random() + "\0", Rt = "\0COMMA" + Math.random() + "\0", kt = "\0PERIOD" + Math.random() + "\0", he = new RegExp(Ft, "g"), ue = new RegExp(Pt, "g"), fe = new RegExp(ot, "g"), pe = new RegExp(Rt, "g"), de = new RegExp(kt, "g"), ge = /\\\\/g, ye = /\\{/g, we = /\\}/g, me = /\\,/g, Ee = /\\\./g, Se = 1e5, be = 4e6;
|
|
437
|
+
function Z(n) {
|
|
438
|
+
return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
|
|
444
439
|
}
|
|
445
|
-
function
|
|
446
|
-
return
|
|
440
|
+
function xe(n) {
|
|
441
|
+
return n.replace(ge, Ft).replace(ye, Pt).replace(we, ot).replace(me, Rt).replace(Ee, kt);
|
|
447
442
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
443
|
+
function Ae(n) {
|
|
444
|
+
return n.replace(he, "\\").replace(ue, "{").replace(fe, "}").replace(pe, ",").replace(de, ".");
|
|
450
445
|
}
|
|
451
|
-
function
|
|
452
|
-
if (!
|
|
446
|
+
function It(n) {
|
|
447
|
+
if (!n)
|
|
453
448
|
return [""];
|
|
454
|
-
const t = [], e =
|
|
449
|
+
const t = [], e = vt("{", "}", n);
|
|
455
450
|
if (!e)
|
|
456
|
-
return
|
|
457
|
-
const { pre:
|
|
451
|
+
return n.split(",");
|
|
452
|
+
const { pre: s, body: r, post: i } = e, o = s.split(",");
|
|
458
453
|
o[o.length - 1] += "{" + r + "}";
|
|
459
|
-
const a =
|
|
454
|
+
const a = It(i);
|
|
460
455
|
return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
461
456
|
}
|
|
462
|
-
function
|
|
463
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), I(ye(s), !0).map(me)) : [];
|
|
464
|
-
}
|
|
465
|
-
function Se(s) {
|
|
466
|
-
return "{" + s + "}";
|
|
467
|
-
}
|
|
468
|
-
function xe(s) {
|
|
469
|
-
return /^-?0\d/.test(s);
|
|
470
|
-
}
|
|
471
|
-
function be(s, t) {
|
|
472
|
-
return s <= t;
|
|
473
|
-
}
|
|
474
|
-
function Oe(s, t) {
|
|
475
|
-
return s >= t;
|
|
476
|
-
}
|
|
477
|
-
function I(s, t) {
|
|
478
|
-
const e = [], n = Ft("{", "}", s);
|
|
457
|
+
function Oe(n, t = {}) {
|
|
479
458
|
if (!n)
|
|
480
|
-
return [
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
459
|
+
return [];
|
|
460
|
+
const { max: e = Se, maxLength: s = be } = t;
|
|
461
|
+
return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), nt(xe(n), e, s, !0).map(Ae);
|
|
462
|
+
}
|
|
463
|
+
function De(n) {
|
|
464
|
+
return "{" + n + "}";
|
|
465
|
+
}
|
|
466
|
+
function Me(n) {
|
|
467
|
+
return /^-?0\d/.test(n);
|
|
468
|
+
}
|
|
469
|
+
function $e(n, t) {
|
|
470
|
+
return n <= t;
|
|
471
|
+
}
|
|
472
|
+
function Te(n, t) {
|
|
473
|
+
return n >= t;
|
|
474
|
+
}
|
|
475
|
+
function F(n, t, e, s, r, i) {
|
|
476
|
+
const o = [];
|
|
477
|
+
let a = 0;
|
|
478
|
+
for (let c = 0; c < n.length; c++)
|
|
479
|
+
for (let l = 0; l < e.length; l++) {
|
|
480
|
+
if (o.length >= s)
|
|
481
|
+
return o;
|
|
482
|
+
const h = n[c] + t + e[l];
|
|
483
|
+
if (!(i && !h)) {
|
|
484
|
+
if (a + h.length > r)
|
|
485
|
+
return o;
|
|
486
|
+
o.push(h), a += h.length;
|
|
487
|
+
}
|
|
486
488
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
y = String.fromCharCode(x), y === "\\" && (y = "");
|
|
507
|
-
else if (y = String(x), T) {
|
|
508
|
-
const P = g - y.length;
|
|
509
|
-
if (P > 0) {
|
|
510
|
-
const H = new Array(P + 1).join("0");
|
|
511
|
-
x < 0 ? y = "-" + H + y.slice(1) : y = H + y;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
f.push(y);
|
|
489
|
+
return o;
|
|
490
|
+
}
|
|
491
|
+
function Ne(n, t, e) {
|
|
492
|
+
const s = n.split(/\.\./), r = [];
|
|
493
|
+
if (s[0] === void 0 || s[1] === void 0)
|
|
494
|
+
return r;
|
|
495
|
+
const i = Z(s[0]), o = Z(s[1]), a = Math.max(s[0].length, s[1].length);
|
|
496
|
+
let c = s.length === 3 && s[2] !== void 0 ? Math.max(Math.abs(Z(s[2])), 1) : 1, l = $e;
|
|
497
|
+
o < i && (c *= -1, l = Te);
|
|
498
|
+
const u = s.some(Me);
|
|
499
|
+
for (let f = i; l(f, o) && r.length < e; f += c) {
|
|
500
|
+
let p;
|
|
501
|
+
if (t)
|
|
502
|
+
p = String.fromCharCode(f), p === "\\" && (p = "");
|
|
503
|
+
else if (p = String(f), u) {
|
|
504
|
+
const g = a - p.length;
|
|
505
|
+
if (g > 0) {
|
|
506
|
+
const d = new Array(g + 1).join("0");
|
|
507
|
+
f < 0 ? p = "-" + d + p.slice(1) : p = d + p;
|
|
515
508
|
}
|
|
516
|
-
} else {
|
|
517
|
-
f = [];
|
|
518
|
-
for (let u = 0; u < l.length; u++)
|
|
519
|
-
f.push.apply(f, I(l[u], !1));
|
|
520
509
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
510
|
+
r.push(p);
|
|
511
|
+
}
|
|
512
|
+
return r;
|
|
513
|
+
}
|
|
514
|
+
function nt(n, t, e, s) {
|
|
515
|
+
let r = [""], i = !1, o = !0;
|
|
516
|
+
for (; ; ) {
|
|
517
|
+
const a = vt("{", "}", n);
|
|
518
|
+
if (!a)
|
|
519
|
+
return F(r, n, [""], t, e, i);
|
|
520
|
+
const c = a.pre;
|
|
521
|
+
if (/\$$/.test(c)) {
|
|
522
|
+
if (r = F(r, c + "{" + a.body + "}", [""], t, e, i && !a.post.length), o = !1, !a.post.length)
|
|
523
|
+
break;
|
|
524
|
+
n = a.post;
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
const l = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body), h = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body), u = l || h, f = a.body.indexOf(",") >= 0;
|
|
528
|
+
if (!u && !f) {
|
|
529
|
+
if (a.post.match(/,(?!,).*\}/)) {
|
|
530
|
+
n = a.pre + "{" + a.body + ot + a.post, s = !0;
|
|
531
|
+
continue;
|
|
525
532
|
}
|
|
533
|
+
return F(r, c + "{" + a.body + "}" + a.post, [""], t, e, i);
|
|
534
|
+
}
|
|
535
|
+
o && (i = s && !u, o = !1);
|
|
536
|
+
let p;
|
|
537
|
+
if (u)
|
|
538
|
+
p = Ne(a.body, h, t);
|
|
539
|
+
else {
|
|
540
|
+
let g = It(a.body);
|
|
541
|
+
if (g.length === 1 && g[0] !== void 0 && (g = nt(g[0], t, e, !1).map(De), g.length === 1)) {
|
|
542
|
+
if (r = F(r, c + g[0], [""], t, e, i && !a.post.length), !a.post.length)
|
|
543
|
+
break;
|
|
544
|
+
n = a.post;
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
p = [];
|
|
548
|
+
for (let d = 0; d < g.length; d++)
|
|
549
|
+
p.push.apply(p, nt(g[d], t, e, !1));
|
|
550
|
+
}
|
|
551
|
+
if (r = F(r, c, p, t, e, i && !a.post.length), !a.post.length)
|
|
552
|
+
break;
|
|
553
|
+
n = a.post;
|
|
526
554
|
}
|
|
527
|
-
return
|
|
555
|
+
return r;
|
|
528
556
|
}
|
|
529
|
-
const
|
|
530
|
-
if (typeof
|
|
557
|
+
const Ce = 1024 * 64, G = (n) => {
|
|
558
|
+
if (typeof n != "string")
|
|
531
559
|
throw new TypeError("invalid pattern");
|
|
532
|
-
if (
|
|
560
|
+
if (n.length > Ce)
|
|
533
561
|
throw new TypeError("pattern is too long");
|
|
534
562
|
}, ve = {
|
|
535
563
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
@@ -546,77 +574,138 @@ const De = 1024 * 64, V = (s) => {
|
|
|
546
574
|
"[:upper:]": ["\\p{Lu}", !0],
|
|
547
575
|
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
|
|
548
576
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
549
|
-
},
|
|
577
|
+
}, P = (n) => n.replace(/[[\]\\-]/g, "\\$&"), Fe = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), dt = (n) => n.join(""), Pe = (n, t) => {
|
|
550
578
|
const e = t;
|
|
551
|
-
if (
|
|
579
|
+
if (n.charAt(e) !== "[")
|
|
552
580
|
throw new Error("not in a brace expression");
|
|
553
|
-
const
|
|
554
|
-
let i = e + 1, o = !1, a = !1, c = !1,
|
|
555
|
-
t: for (; i <
|
|
556
|
-
const
|
|
557
|
-
if ((
|
|
558
|
-
|
|
581
|
+
const s = [], r = [];
|
|
582
|
+
let i = e + 1, o = !1, a = !1, c = !1, l = !1, h = e, u = "";
|
|
583
|
+
t: for (; i < n.length; ) {
|
|
584
|
+
const d = n.charAt(i);
|
|
585
|
+
if ((d === "!" || d === "^") && i === e + 1) {
|
|
586
|
+
l = !0, i++;
|
|
559
587
|
continue;
|
|
560
588
|
}
|
|
561
|
-
if (
|
|
562
|
-
|
|
589
|
+
if (d === "]" && o && !c) {
|
|
590
|
+
h = i + 1;
|
|
563
591
|
break;
|
|
564
592
|
}
|
|
565
|
-
if (o = !0,
|
|
593
|
+
if (o = !0, d === "\\" && !c) {
|
|
566
594
|
c = !0, i++;
|
|
567
595
|
continue;
|
|
568
596
|
}
|
|
569
|
-
if (
|
|
570
|
-
for (const [
|
|
571
|
-
if (
|
|
572
|
-
if (
|
|
573
|
-
return ["$.", !1,
|
|
574
|
-
i +=
|
|
597
|
+
if (d === "[" && !c) {
|
|
598
|
+
for (const [E, [w, m, M]] of Object.entries(ve))
|
|
599
|
+
if (n.startsWith(E, i)) {
|
|
600
|
+
if (u)
|
|
601
|
+
return ["$.", !1, n.length - e, !0];
|
|
602
|
+
i += E.length, M ? r.push(w) : s.push(w), a = a || m;
|
|
575
603
|
continue t;
|
|
576
604
|
}
|
|
577
605
|
}
|
|
578
|
-
if (c = !1,
|
|
579
|
-
|
|
606
|
+
if (c = !1, u) {
|
|
607
|
+
d > u ? s.push(P(u) + "-" + P(d)) : d === u && s.push(P(d)), u = "", i++;
|
|
580
608
|
continue;
|
|
581
609
|
}
|
|
582
|
-
if (
|
|
583
|
-
|
|
610
|
+
if (n.startsWith("-]", i + 1)) {
|
|
611
|
+
s.push(P(d + "-")), i += 2;
|
|
584
612
|
continue;
|
|
585
613
|
}
|
|
586
|
-
if (
|
|
587
|
-
|
|
614
|
+
if (n.startsWith("-", i + 1)) {
|
|
615
|
+
u = d, i += 2;
|
|
588
616
|
continue;
|
|
589
617
|
}
|
|
590
|
-
|
|
618
|
+
s.push(P(d)), i++;
|
|
591
619
|
}
|
|
592
|
-
if (
|
|
620
|
+
if (h < i)
|
|
593
621
|
return ["", !1, 0, !1];
|
|
594
|
-
if (!
|
|
595
|
-
return ["$.", !1,
|
|
596
|
-
if (r.length === 0 &&
|
|
597
|
-
const
|
|
598
|
-
return [
|
|
599
|
-
}
|
|
600
|
-
const
|
|
601
|
-
return [
|
|
602
|
-
},
|
|
603
|
-
|
|
622
|
+
if (!s.length && !r.length)
|
|
623
|
+
return ["$.", !1, n.length - e, !0];
|
|
624
|
+
if (r.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
|
|
625
|
+
const d = s[0].length === 2 ? s[0].slice(-1) : s[0];
|
|
626
|
+
return [Fe(d), !1, h - e, !1];
|
|
627
|
+
}
|
|
628
|
+
const f = "[" + (l ? "^" : "") + dt(s) + "]", p = "[" + (l ? "" : "^") + dt(r) + "]";
|
|
629
|
+
return [s.length && r.length ? "(" + f + "|" + p + ")" : s.length ? f : p, a, h - e, !0];
|
|
630
|
+
}, R = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? n.replace(/\[([^/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? n.replace(/\[([^/\\{}])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
631
|
+
var x;
|
|
632
|
+
const Re = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), rt = (n) => Re.has(n), gt = (n) => rt(n.type), ke = /* @__PURE__ */ new Map([
|
|
633
|
+
["!", ["@"]],
|
|
634
|
+
["?", ["?", "@"]],
|
|
635
|
+
["@", ["@"]],
|
|
636
|
+
["*", ["*", "+", "?", "@"]],
|
|
637
|
+
["+", ["+", "@"]]
|
|
638
|
+
]), Ie = /* @__PURE__ */ new Map([
|
|
639
|
+
["!", ["?"]],
|
|
640
|
+
["@", ["?"]],
|
|
641
|
+
["+", ["?", "*"]]
|
|
642
|
+
]), Le = /* @__PURE__ */ new Map([
|
|
643
|
+
["!", ["?", "@"]],
|
|
644
|
+
["?", ["?", "@"]],
|
|
645
|
+
["@", ["?", "@"]],
|
|
646
|
+
["*", ["*", "+", "?", "@"]],
|
|
647
|
+
["+", ["+", "@", "?", "*"]]
|
|
648
|
+
]), yt = /* @__PURE__ */ new Map([
|
|
649
|
+
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
650
|
+
[
|
|
651
|
+
"?",
|
|
652
|
+
/* @__PURE__ */ new Map([
|
|
653
|
+
["*", "*"],
|
|
654
|
+
["+", "*"]
|
|
655
|
+
])
|
|
656
|
+
],
|
|
657
|
+
[
|
|
658
|
+
"@",
|
|
659
|
+
/* @__PURE__ */ new Map([
|
|
660
|
+
["!", "!"],
|
|
661
|
+
["?", "?"],
|
|
662
|
+
["@", "@"],
|
|
663
|
+
["*", "*"],
|
|
664
|
+
["+", "+"]
|
|
665
|
+
])
|
|
666
|
+
],
|
|
667
|
+
[
|
|
668
|
+
"+",
|
|
669
|
+
/* @__PURE__ */ new Map([
|
|
670
|
+
["?", "*"],
|
|
671
|
+
["*", "*"]
|
|
672
|
+
])
|
|
673
|
+
]
|
|
674
|
+
]), He = "(?!(?:^|/)\\.\\.?(?:$|/))", L = "(?!\\.)", ze = /* @__PURE__ */ new Set(["[", "."]), _e = /* @__PURE__ */ new Set(["..", "."]), We = new Set("().*{}+?[]^$\\!"), je = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), at = "[^/]", wt = at + "*?", mt = at + "+?";
|
|
675
|
+
let Be = 0;
|
|
676
|
+
class ct {
|
|
604
677
|
type;
|
|
605
678
|
#s;
|
|
606
679
|
#n;
|
|
607
|
-
#
|
|
680
|
+
#r = !1;
|
|
608
681
|
#t = [];
|
|
609
682
|
#e;
|
|
610
|
-
#
|
|
611
|
-
#c;
|
|
612
|
-
#a = !1;
|
|
613
|
-
#r;
|
|
683
|
+
#a;
|
|
614
684
|
#l;
|
|
685
|
+
#c = !1;
|
|
686
|
+
#i;
|
|
687
|
+
#o;
|
|
615
688
|
// set to true if it's an extglob with no children
|
|
616
689
|
// (which really means one child of '')
|
|
617
|
-
#
|
|
618
|
-
|
|
619
|
-
|
|
690
|
+
#h = !1;
|
|
691
|
+
id = ++Be;
|
|
692
|
+
get depth() {
|
|
693
|
+
return (this.#e?.depth ?? -1) + 1;
|
|
694
|
+
}
|
|
695
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
696
|
+
return {
|
|
697
|
+
"@@type": "AST",
|
|
698
|
+
id: this.id,
|
|
699
|
+
type: this.type,
|
|
700
|
+
root: this.#s.id,
|
|
701
|
+
parent: this.#e?.id,
|
|
702
|
+
depth: this.depth,
|
|
703
|
+
partsLength: this.#t.length,
|
|
704
|
+
parts: this.#t
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
constructor(t, e, s = {}) {
|
|
708
|
+
this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? s : this.#s.#i, this.#l = this.#s === this ? [] : this.#s.#l, t === "!" && !this.#s.#c && this.#l.push(this), this.#a = this.#e ? this.#e.#t.length : 0;
|
|
620
709
|
}
|
|
621
710
|
get hasMagic() {
|
|
622
711
|
if (this.#n !== void 0)
|
|
@@ -628,27 +717,27 @@ class E {
|
|
|
628
717
|
}
|
|
629
718
|
// reconstructs the pattern
|
|
630
719
|
toString() {
|
|
631
|
-
return this.#
|
|
720
|
+
return this.#o !== void 0 ? this.#o : this.type ? this.#o = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#o = this.#t.map((t) => String(t)).join("");
|
|
632
721
|
}
|
|
633
|
-
#
|
|
722
|
+
#w() {
|
|
634
723
|
if (this !== this.#s)
|
|
635
724
|
throw new Error("should only call on root");
|
|
636
|
-
if (this.#
|
|
725
|
+
if (this.#c)
|
|
637
726
|
return this;
|
|
638
|
-
this.toString(), this.#
|
|
727
|
+
this.toString(), this.#c = !0;
|
|
639
728
|
let t;
|
|
640
|
-
for (; t = this.#
|
|
729
|
+
for (; t = this.#l.pop(); ) {
|
|
641
730
|
if (t.type !== "!")
|
|
642
731
|
continue;
|
|
643
|
-
let e = t,
|
|
644
|
-
for (;
|
|
645
|
-
for (let r = e.#
|
|
732
|
+
let e = t, s = e.#e;
|
|
733
|
+
for (; s; ) {
|
|
734
|
+
for (let r = e.#a + 1; !s.type && r < s.#t.length; r++)
|
|
646
735
|
for (const i of t.#t) {
|
|
647
736
|
if (typeof i == "string")
|
|
648
737
|
throw new Error("string part in extglob AST??");
|
|
649
|
-
i.copyIn(
|
|
738
|
+
i.copyIn(s.#t[r]);
|
|
650
739
|
}
|
|
651
|
-
e =
|
|
740
|
+
e = s, s = e.#e;
|
|
652
741
|
}
|
|
653
742
|
}
|
|
654
743
|
return this;
|
|
@@ -656,26 +745,26 @@ class E {
|
|
|
656
745
|
push(...t) {
|
|
657
746
|
for (const e of t)
|
|
658
747
|
if (e !== "") {
|
|
659
|
-
if (typeof e != "string" && !(e instanceof
|
|
748
|
+
if (typeof e != "string" && !(e instanceof x && e.#e === this))
|
|
660
749
|
throw new Error("invalid part: " + e);
|
|
661
750
|
this.#t.push(e);
|
|
662
751
|
}
|
|
663
752
|
}
|
|
664
753
|
toJSON() {
|
|
665
754
|
const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
|
|
666
|
-
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#
|
|
755
|
+
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
|
|
667
756
|
}
|
|
668
757
|
isStart() {
|
|
669
758
|
if (this.#s === this)
|
|
670
759
|
return !0;
|
|
671
760
|
if (!this.#e?.isStart())
|
|
672
761
|
return !1;
|
|
673
|
-
if (this.#
|
|
762
|
+
if (this.#a === 0)
|
|
674
763
|
return !0;
|
|
675
764
|
const t = this.#e;
|
|
676
|
-
for (let e = 0; e < this.#
|
|
677
|
-
const
|
|
678
|
-
if (!(
|
|
765
|
+
for (let e = 0; e < this.#a; e++) {
|
|
766
|
+
const s = t.#t[e];
|
|
767
|
+
if (!(s instanceof x && s.type === "!"))
|
|
679
768
|
return !1;
|
|
680
769
|
}
|
|
681
770
|
return !0;
|
|
@@ -688,96 +777,140 @@ class E {
|
|
|
688
777
|
if (!this.type)
|
|
689
778
|
return this.#e?.isEnd();
|
|
690
779
|
const t = this.#e ? this.#e.#t.length : 0;
|
|
691
|
-
return this.#
|
|
780
|
+
return this.#a === t - 1;
|
|
692
781
|
}
|
|
693
782
|
copyIn(t) {
|
|
694
783
|
typeof t == "string" ? this.push(t) : this.push(t.clone(this));
|
|
695
784
|
}
|
|
696
785
|
clone(t) {
|
|
697
|
-
const e = new
|
|
698
|
-
for (const
|
|
699
|
-
e.copyIn(
|
|
786
|
+
const e = new x(this.type, t);
|
|
787
|
+
for (const s of this.#t)
|
|
788
|
+
e.copyIn(s);
|
|
700
789
|
return e;
|
|
701
790
|
}
|
|
702
|
-
static #
|
|
703
|
-
|
|
791
|
+
static #u(t, e, s, r, i) {
|
|
792
|
+
const o = r.maxExtglobRecursion ?? 2;
|
|
793
|
+
let a = !1, c = !1, l = -1, h = !1;
|
|
704
794
|
if (e.type === null) {
|
|
705
|
-
let d =
|
|
795
|
+
let d = s, E = "";
|
|
706
796
|
for (; d < t.length; ) {
|
|
707
|
-
const
|
|
708
|
-
if (
|
|
709
|
-
|
|
797
|
+
const w = t.charAt(d++);
|
|
798
|
+
if (a || w === "\\") {
|
|
799
|
+
a = !a, E += w;
|
|
710
800
|
continue;
|
|
711
801
|
}
|
|
712
|
-
if (
|
|
713
|
-
d ===
|
|
802
|
+
if (c) {
|
|
803
|
+
d === l + 1 ? (w === "^" || w === "!") && (h = !0) : w === "]" && !(d === l + 2 && h) && (c = !1), E += w;
|
|
714
804
|
continue;
|
|
715
|
-
} else if (
|
|
716
|
-
|
|
805
|
+
} else if (w === "[") {
|
|
806
|
+
c = !0, l = d, h = !1, E += w;
|
|
717
807
|
continue;
|
|
718
808
|
}
|
|
719
|
-
if (!r.noext &&
|
|
720
|
-
e.push(
|
|
721
|
-
const
|
|
722
|
-
d =
|
|
809
|
+
if (!r.noext && rt(w) && t.charAt(d) === "(" && i <= o) {
|
|
810
|
+
e.push(E), E = "";
|
|
811
|
+
const M = new x(w, e);
|
|
812
|
+
d = x.#u(t, M, d, r, i + 1), e.push(M);
|
|
723
813
|
continue;
|
|
724
814
|
}
|
|
725
|
-
|
|
815
|
+
E += w;
|
|
726
816
|
}
|
|
727
|
-
return e.push(
|
|
817
|
+
return e.push(E), d;
|
|
728
818
|
}
|
|
729
|
-
let
|
|
730
|
-
const
|
|
731
|
-
let
|
|
732
|
-
for (;
|
|
733
|
-
const d = t.charAt(
|
|
734
|
-
if (
|
|
735
|
-
|
|
819
|
+
let u = s + 1, f = new x(null, e);
|
|
820
|
+
const p = [];
|
|
821
|
+
let g = "";
|
|
822
|
+
for (; u < t.length; ) {
|
|
823
|
+
const d = t.charAt(u++);
|
|
824
|
+
if (a || d === "\\") {
|
|
825
|
+
a = !a, g += d;
|
|
736
826
|
continue;
|
|
737
827
|
}
|
|
738
|
-
if (
|
|
739
|
-
|
|
828
|
+
if (c) {
|
|
829
|
+
u === l + 1 ? (d === "^" || d === "!") && (h = !0) : d === "]" && !(u === l + 2 && h) && (c = !1), g += d;
|
|
740
830
|
continue;
|
|
741
831
|
} else if (d === "[") {
|
|
742
|
-
|
|
832
|
+
c = !0, l = u, h = !1, g += d;
|
|
743
833
|
continue;
|
|
744
834
|
}
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
const
|
|
748
|
-
|
|
835
|
+
if (!r.noext && rt(d) && t.charAt(u) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
|
|
836
|
+
(i <= o || e && e.#f(d))) {
|
|
837
|
+
const w = e && e.#f(d) ? 0 : 1;
|
|
838
|
+
f.push(g), g = "";
|
|
839
|
+
const m = new x(d, f);
|
|
840
|
+
f.push(m), u = x.#u(t, m, u, r, i + w);
|
|
749
841
|
continue;
|
|
750
842
|
}
|
|
751
843
|
if (d === "|") {
|
|
752
|
-
|
|
844
|
+
f.push(g), g = "", p.push(f), f = new x(null, e);
|
|
753
845
|
continue;
|
|
754
846
|
}
|
|
755
847
|
if (d === ")")
|
|
756
|
-
return
|
|
757
|
-
|
|
848
|
+
return g === "" && e.#t.length === 0 && (e.#h = !0), f.push(g), g = "", e.push(...p, f), u;
|
|
849
|
+
g += d;
|
|
758
850
|
}
|
|
759
|
-
return e.type = null, e.#n = void 0, e.#t = [t.substring(
|
|
851
|
+
return e.type = null, e.#n = void 0, e.#t = [t.substring(s - 1)], u;
|
|
852
|
+
}
|
|
853
|
+
#m(t) {
|
|
854
|
+
return this.#d(t, Ie);
|
|
855
|
+
}
|
|
856
|
+
#d(t, e = ke) {
|
|
857
|
+
if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null)
|
|
858
|
+
return !1;
|
|
859
|
+
const s = t.#t[0];
|
|
860
|
+
return !s || typeof s != "object" || s.type === null ? !1 : this.#f(s.type, e);
|
|
861
|
+
}
|
|
862
|
+
#f(t, e = Le) {
|
|
863
|
+
return !!e.get(this.type)?.includes(t);
|
|
864
|
+
}
|
|
865
|
+
#E(t, e) {
|
|
866
|
+
const s = t.#t[0], r = new x(null, s, this.options);
|
|
867
|
+
r.#t.push(""), s.push(r), this.#g(t, e);
|
|
868
|
+
}
|
|
869
|
+
#g(t, e) {
|
|
870
|
+
const s = t.#t[0];
|
|
871
|
+
this.#t.splice(e, 1, ...s.#t);
|
|
872
|
+
for (const r of s.#t)
|
|
873
|
+
typeof r == "object" && (r.#e = this);
|
|
874
|
+
this.#o = void 0;
|
|
875
|
+
}
|
|
876
|
+
#S(t) {
|
|
877
|
+
return !!yt.get(this.type)?.has(t);
|
|
878
|
+
}
|
|
879
|
+
#b(t) {
|
|
880
|
+
if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null || this.#t.length !== 1)
|
|
881
|
+
return !1;
|
|
882
|
+
const e = t.#t[0];
|
|
883
|
+
return !e || typeof e != "object" || e.type === null ? !1 : this.#S(e.type);
|
|
884
|
+
}
|
|
885
|
+
#x(t) {
|
|
886
|
+
const e = yt.get(this.type), s = t.#t[0], r = e?.get(s.type);
|
|
887
|
+
if (!r)
|
|
888
|
+
return !1;
|
|
889
|
+
this.#t = s.#t;
|
|
890
|
+
for (const i of this.#t)
|
|
891
|
+
typeof i == "object" && (i.#e = this);
|
|
892
|
+
this.type = r, this.#o = void 0, this.#h = !1;
|
|
760
893
|
}
|
|
761
894
|
static fromGlob(t, e = {}) {
|
|
762
|
-
const
|
|
763
|
-
return
|
|
895
|
+
const s = new x(null, void 0, e);
|
|
896
|
+
return x.#u(t, s, 0, e, 0), s;
|
|
764
897
|
}
|
|
765
898
|
// returns the regular expression if there's magic, or the unescaped
|
|
766
899
|
// string if not.
|
|
767
900
|
toMMPattern() {
|
|
768
901
|
if (this !== this.#s)
|
|
769
902
|
return this.#s.toMMPattern();
|
|
770
|
-
const t = this.toString(), [e,
|
|
771
|
-
if (!(r || this.#n || this.#
|
|
772
|
-
return
|
|
773
|
-
const a = (this.#
|
|
903
|
+
const t = this.toString(), [e, s, r, i] = this.toRegExpSource();
|
|
904
|
+
if (!(r || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
905
|
+
return s;
|
|
906
|
+
const a = (this.#i.nocase ? "i" : "") + (i ? "u" : "");
|
|
774
907
|
return Object.assign(new RegExp(`^${e}$`, a), {
|
|
775
908
|
_src: e,
|
|
776
909
|
_glob: t
|
|
777
910
|
});
|
|
778
911
|
}
|
|
779
912
|
get options() {
|
|
780
|
-
return this.#
|
|
913
|
+
return this.#i;
|
|
781
914
|
}
|
|
782
915
|
// returns the string match, the regexp source, whether there's magic
|
|
783
916
|
// in the regexp (so a regular expression is required) and whether or
|
|
@@ -849,168 +982,187 @@ class E {
|
|
|
849
982
|
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
850
983
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
851
984
|
toRegExpSource(t) {
|
|
852
|
-
const e = t ?? !!this.#
|
|
853
|
-
if (this.#s === this && this.#
|
|
854
|
-
const c = this.isStart() && this.isEnd(),
|
|
855
|
-
const [g,
|
|
856
|
-
return this.#n = this.#n ||
|
|
985
|
+
const e = t ?? !!this.#i.dot;
|
|
986
|
+
if (this.#s === this && (this.#p(), this.#w()), !gt(this)) {
|
|
987
|
+
const c = this.isStart() && this.isEnd() && !this.#t.some((p) => typeof p != "string"), l = this.#t.map((p) => {
|
|
988
|
+
const [g, d, E, w] = typeof p == "string" ? x.#A(p, this.#n, c) : p.toRegExpSource(t);
|
|
989
|
+
return this.#n = this.#n || E, this.#r = this.#r || w, g;
|
|
857
990
|
}).join("");
|
|
858
|
-
let
|
|
859
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
860
|
-
const g =
|
|
991
|
+
let h = "";
|
|
992
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && _e.has(this.#t[0]))) {
|
|
993
|
+
const g = ze, d = (
|
|
861
994
|
// dots are allowed, and the pattern starts with [ or .
|
|
862
|
-
e && g.has(
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
),
|
|
866
|
-
|
|
995
|
+
e && g.has(l.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
996
|
+
l.startsWith("\\.") && g.has(l.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
997
|
+
l.startsWith("\\.\\.") && g.has(l.charAt(4))
|
|
998
|
+
), E = !e && !t && g.has(l.charAt(0));
|
|
999
|
+
h = d ? He : E ? L : "";
|
|
867
1000
|
}
|
|
868
|
-
let
|
|
869
|
-
return this.isEnd() && this.#s.#
|
|
870
|
-
|
|
871
|
-
|
|
1001
|
+
let u = "";
|
|
1002
|
+
return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (u = "(?:$|\\/)"), [
|
|
1003
|
+
h + l + u,
|
|
1004
|
+
R(l),
|
|
872
1005
|
this.#n = !!this.#n,
|
|
873
|
-
this.#
|
|
1006
|
+
this.#r
|
|
874
1007
|
];
|
|
875
1008
|
}
|
|
876
|
-
const
|
|
877
|
-
let i = this.#
|
|
1009
|
+
const s = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1010
|
+
let i = this.#y(e);
|
|
878
1011
|
if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
|
|
879
|
-
const c = this.toString();
|
|
880
|
-
return
|
|
1012
|
+
const c = this.toString(), l = this;
|
|
1013
|
+
return l.#t = [c], l.type = null, l.#n = void 0, [c, R(this.toString()), !1, !1];
|
|
881
1014
|
}
|
|
882
|
-
let o = !
|
|
1015
|
+
let o = !s || t || e || !L ? "" : this.#y(!0);
|
|
883
1016
|
o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
|
|
884
1017
|
let a = "";
|
|
885
|
-
if (this.type === "!" && this.#
|
|
886
|
-
a = (this.isStart() && !e ?
|
|
1018
|
+
if (this.type === "!" && this.#h)
|
|
1019
|
+
a = (this.isStart() && !e ? L : "") + mt;
|
|
887
1020
|
else {
|
|
888
1021
|
const c = this.type === "!" ? (
|
|
889
1022
|
// !() must match something,but !(x) can match ''
|
|
890
|
-
"))" + (this.isStart() && !e && !t ?
|
|
1023
|
+
"))" + (this.isStart() && !e && !t ? L : "") + wt + ")"
|
|
891
1024
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
892
1025
|
a = r + i + c;
|
|
893
1026
|
}
|
|
894
1027
|
return [
|
|
895
1028
|
a,
|
|
896
|
-
|
|
1029
|
+
R(i),
|
|
897
1030
|
this.#n = !!this.#n,
|
|
898
|
-
this.#
|
|
1031
|
+
this.#r
|
|
899
1032
|
];
|
|
900
1033
|
}
|
|
901
|
-
#
|
|
1034
|
+
#p() {
|
|
1035
|
+
if (gt(this)) {
|
|
1036
|
+
let t = 0, e = !1;
|
|
1037
|
+
do {
|
|
1038
|
+
e = !0;
|
|
1039
|
+
for (let s = 0; s < this.#t.length; s++) {
|
|
1040
|
+
const r = this.#t[s];
|
|
1041
|
+
typeof r == "object" && (r.#p(), this.#d(r) ? (e = !1, this.#g(r, s)) : this.#m(r) ? (e = !1, this.#E(r, s)) : this.#b(r) && (e = !1, this.#x(r)));
|
|
1042
|
+
}
|
|
1043
|
+
} while (!e && ++t < 10);
|
|
1044
|
+
} else
|
|
1045
|
+
for (const t of this.#t)
|
|
1046
|
+
typeof t == "object" && t.#p();
|
|
1047
|
+
this.#o = void 0;
|
|
1048
|
+
}
|
|
1049
|
+
#y(t) {
|
|
902
1050
|
return this.#t.map((e) => {
|
|
903
1051
|
if (typeof e == "string")
|
|
904
1052
|
throw new Error("string type in extglob ast??");
|
|
905
|
-
const [
|
|
906
|
-
return this.#
|
|
1053
|
+
const [s, r, i, o] = e.toRegExpSource(t);
|
|
1054
|
+
return this.#r = this.#r || o, s;
|
|
907
1055
|
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
908
1056
|
}
|
|
909
|
-
static #
|
|
910
|
-
let r = !1, i = "", o = !1;
|
|
911
|
-
for (let
|
|
912
|
-
const
|
|
1057
|
+
static #A(t, e, s = !1) {
|
|
1058
|
+
let r = !1, i = "", o = !1, a = !1;
|
|
1059
|
+
for (let c = 0; c < t.length; c++) {
|
|
1060
|
+
const l = t.charAt(c);
|
|
913
1061
|
if (r) {
|
|
914
|
-
r = !1, i += (
|
|
1062
|
+
r = !1, i += (We.has(l) ? "\\" : "") + l;
|
|
915
1063
|
continue;
|
|
916
1064
|
}
|
|
917
|
-
if (
|
|
918
|
-
a
|
|
1065
|
+
if (l === "*") {
|
|
1066
|
+
if (a)
|
|
1067
|
+
continue;
|
|
1068
|
+
a = !0, i += s && /^[*]+$/.test(t) ? mt : wt, e = !0;
|
|
1069
|
+
continue;
|
|
1070
|
+
} else
|
|
1071
|
+
a = !1;
|
|
1072
|
+
if (l === "\\") {
|
|
1073
|
+
c === t.length - 1 ? i += "\\\\" : r = !0;
|
|
919
1074
|
continue;
|
|
920
1075
|
}
|
|
921
|
-
if (
|
|
922
|
-
const [h,
|
|
1076
|
+
if (l === "[") {
|
|
1077
|
+
const [h, u, f, p] = Pe(t, c);
|
|
923
1078
|
if (f) {
|
|
924
|
-
i += h, o = o ||
|
|
1079
|
+
i += h, o = o || u, c += f - 1, e = e || p;
|
|
925
1080
|
continue;
|
|
926
1081
|
}
|
|
927
1082
|
}
|
|
928
|
-
if (
|
|
929
|
-
|
|
930
|
-
continue;
|
|
931
|
-
}
|
|
932
|
-
if (c === "?") {
|
|
933
|
-
i += ct, e = !0;
|
|
1083
|
+
if (l === "?") {
|
|
1084
|
+
i += at, e = !0;
|
|
934
1085
|
continue;
|
|
935
1086
|
}
|
|
936
|
-
i +=
|
|
1087
|
+
i += je(l);
|
|
937
1088
|
}
|
|
938
|
-
return [i,
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1089
|
+
return [i, R(t), !!e, o];
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
x = ct;
|
|
1093
|
+
const Ge = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? n.replace(/[?*()[\]{}]/g, "[$&]") : n.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n.replace(/[?*()[\]]/g, "[$&]") : n.replace(/[?*()[\]\\]/g, "\\$&"), b = (n, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(n)), Ue = /^\*+([^+@!?*[(]*)$/, qe = (n) => (t) => !t.startsWith(".") && t.endsWith(n), Ve = (n) => (t) => t.endsWith(n), Xe = (n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n)), Ye = (n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n)), Ze = /^\*+\.\*+$/, Je = (n) => !n.startsWith(".") && n.includes("."), Qe = (n) => n !== "." && n !== ".." && n.includes("."), Ke = /^\.\*+$/, ts = (n) => n !== "." && n !== ".." && n.startsWith("."), es = /^\*+$/, ss = (n) => n.length !== 0 && !n.startsWith("."), ns = (n) => n.length !== 0 && n !== "." && n !== "..", rs = /^\?+([^+@!?*[(]*)?$/, is = ([n, t = ""]) => {
|
|
1094
|
+
const e = Lt([n]);
|
|
1095
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
1096
|
+
}, os = ([n, t = ""]) => {
|
|
1097
|
+
const e = Ht([n]);
|
|
1098
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
1099
|
+
}, as = ([n, t = ""]) => {
|
|
1100
|
+
const e = Ht([n]);
|
|
1101
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
1102
|
+
}, cs = ([n, t = ""]) => {
|
|
1103
|
+
const e = Lt([n]);
|
|
1104
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
1105
|
+
}, Lt = ([n]) => {
|
|
1106
|
+
const t = n.length;
|
|
955
1107
|
return (e) => e.length === t && !e.startsWith(".");
|
|
956
|
-
},
|
|
957
|
-
const t =
|
|
1108
|
+
}, Ht = ([n]) => {
|
|
1109
|
+
const t = n.length;
|
|
958
1110
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
959
|
-
},
|
|
1111
|
+
}, zt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", Et = {
|
|
960
1112
|
win32: { sep: "\\" },
|
|
961
1113
|
posix: { sep: "/" }
|
|
962
|
-
},
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
const D = (
|
|
969
|
-
if (!
|
|
970
|
-
return
|
|
971
|
-
const t =
|
|
972
|
-
return Object.assign((
|
|
1114
|
+
}, ls = zt === "win32" ? Et.win32.sep : Et.posix.sep;
|
|
1115
|
+
b.sep = ls;
|
|
1116
|
+
const S = /* @__PURE__ */ Symbol("globstar **");
|
|
1117
|
+
b.GLOBSTAR = S;
|
|
1118
|
+
const hs = "[^/]", us = hs + "*?", fs = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", ps = "(?:(?!(?:\\/|^)\\.).)*?", ds = (n, t = {}) => (e) => b(e, n, t);
|
|
1119
|
+
b.filter = ds;
|
|
1120
|
+
const D = (n, t = {}) => Object.assign({}, n, t), gs = (n) => {
|
|
1121
|
+
if (!n || typeof n != "object" || !Object.keys(n).length)
|
|
1122
|
+
return b;
|
|
1123
|
+
const t = b;
|
|
1124
|
+
return Object.assign((s, r, i = {}) => t(s, r, D(n, i)), {
|
|
973
1125
|
Minimatch: class extends t.Minimatch {
|
|
974
1126
|
constructor(r, i = {}) {
|
|
975
|
-
super(r, D(
|
|
1127
|
+
super(r, D(n, i));
|
|
976
1128
|
}
|
|
977
1129
|
static defaults(r) {
|
|
978
|
-
return t.defaults(D(
|
|
1130
|
+
return t.defaults(D(n, r)).Minimatch;
|
|
979
1131
|
}
|
|
980
1132
|
},
|
|
981
1133
|
AST: class extends t.AST {
|
|
982
1134
|
/* c8 ignore start */
|
|
983
1135
|
constructor(r, i, o = {}) {
|
|
984
|
-
super(r, i, D(
|
|
1136
|
+
super(r, i, D(n, o));
|
|
985
1137
|
}
|
|
986
1138
|
/* c8 ignore stop */
|
|
987
1139
|
static fromGlob(r, i = {}) {
|
|
988
|
-
return t.AST.fromGlob(r, D(
|
|
1140
|
+
return t.AST.fromGlob(r, D(n, i));
|
|
989
1141
|
}
|
|
990
1142
|
},
|
|
991
|
-
unescape: (
|
|
992
|
-
escape: (
|
|
993
|
-
filter: (
|
|
994
|
-
defaults: (
|
|
995
|
-
makeRe: (
|
|
996
|
-
braceExpand: (
|
|
997
|
-
match: (
|
|
1143
|
+
unescape: (s, r = {}) => t.unescape(s, D(n, r)),
|
|
1144
|
+
escape: (s, r = {}) => t.escape(s, D(n, r)),
|
|
1145
|
+
filter: (s, r = {}) => t.filter(s, D(n, r)),
|
|
1146
|
+
defaults: (s) => t.defaults(D(n, s)),
|
|
1147
|
+
makeRe: (s, r = {}) => t.makeRe(s, D(n, r)),
|
|
1148
|
+
braceExpand: (s, r = {}) => t.braceExpand(s, D(n, r)),
|
|
1149
|
+
match: (s, r, i = {}) => t.match(s, r, D(n, i)),
|
|
998
1150
|
sep: t.sep,
|
|
999
|
-
GLOBSTAR:
|
|
1151
|
+
GLOBSTAR: S
|
|
1000
1152
|
});
|
|
1001
1153
|
};
|
|
1002
|
-
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1007
|
-
const
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1154
|
+
b.defaults = gs;
|
|
1155
|
+
const _t = (n, t = {}) => (G(n), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n) ? [n] : Oe(n, { max: t.braceExpandMax }));
|
|
1156
|
+
b.braceExpand = _t;
|
|
1157
|
+
const ys = (n, t = {}) => new q(n, t).makeRe();
|
|
1158
|
+
b.makeRe = ys;
|
|
1159
|
+
const ws = (n, t, e = {}) => {
|
|
1160
|
+
const s = new q(t, e);
|
|
1161
|
+
return n = n.filter((r) => s.match(r)), s.options.nonull && !n.length && n.push(t), n;
|
|
1010
1162
|
};
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
class
|
|
1163
|
+
b.match = ws;
|
|
1164
|
+
const St = /[?*]|[+@!]\(.*?\)|\[|\]/, ms = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1165
|
+
class q {
|
|
1014
1166
|
options;
|
|
1015
1167
|
set;
|
|
1016
1168
|
pattern;
|
|
@@ -1027,9 +1179,12 @@ class Z {
|
|
|
1027
1179
|
isWindows;
|
|
1028
1180
|
platform;
|
|
1029
1181
|
windowsNoMagicRoot;
|
|
1182
|
+
maxGlobstarRecursion;
|
|
1030
1183
|
regexp;
|
|
1031
1184
|
constructor(t, e = {}) {
|
|
1032
|
-
|
|
1185
|
+
G(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || zt, this.isWindows = this.platform === "win32";
|
|
1186
|
+
const s = "allowWindowsEscape";
|
|
1187
|
+
this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
1033
1188
|
}
|
|
1034
1189
|
hasMagic() {
|
|
1035
1190
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -1053,15 +1208,18 @@ class Z {
|
|
|
1053
1208
|
return;
|
|
1054
1209
|
}
|
|
1055
1210
|
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
|
|
1056
|
-
const
|
|
1057
|
-
this.globParts = this.preprocess(
|
|
1211
|
+
const s = this.globSet.map((i) => this.slashSplit(i));
|
|
1212
|
+
this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
|
|
1058
1213
|
let r = this.globParts.map((i, o, a) => {
|
|
1059
1214
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1060
|
-
const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !
|
|
1215
|
+
const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !St.test(i[2])) && !St.test(i[3]), l = /^[a-z]:/i.test(i[0]);
|
|
1061
1216
|
if (c)
|
|
1062
|
-
return [
|
|
1063
|
-
|
|
1064
|
-
|
|
1217
|
+
return [
|
|
1218
|
+
...i.slice(0, 4),
|
|
1219
|
+
...i.slice(4).map((h) => this.parse(h))
|
|
1220
|
+
];
|
|
1221
|
+
if (l)
|
|
1222
|
+
return [i[0], ...i.slice(1).map((h) => this.parse(h))];
|
|
1065
1223
|
}
|
|
1066
1224
|
return i.map((c) => this.parse(c));
|
|
1067
1225
|
});
|
|
@@ -1079,30 +1237,30 @@ class Z {
|
|
|
1079
1237
|
// of patterns that we have to process.
|
|
1080
1238
|
preprocess(t) {
|
|
1081
1239
|
if (this.options.noglobstar)
|
|
1082
|
-
for (
|
|
1083
|
-
for (let r = 0; r <
|
|
1084
|
-
|
|
1240
|
+
for (const s of t)
|
|
1241
|
+
for (let r = 0; r < s.length; r++)
|
|
1242
|
+
s[r] === "**" && (s[r] = "*");
|
|
1085
1243
|
const { optimizationLevel: e = 1 } = this.options;
|
|
1086
1244
|
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
1087
1245
|
}
|
|
1088
1246
|
// just get rid of adjascent ** portions
|
|
1089
1247
|
adjascentGlobstarOptimize(t) {
|
|
1090
1248
|
return t.map((e) => {
|
|
1091
|
-
let
|
|
1092
|
-
for (; (
|
|
1093
|
-
let r =
|
|
1249
|
+
let s = -1;
|
|
1250
|
+
for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
|
|
1251
|
+
let r = s;
|
|
1094
1252
|
for (; e[r + 1] === "**"; )
|
|
1095
1253
|
r++;
|
|
1096
|
-
r !==
|
|
1254
|
+
r !== s && e.splice(s, r - s);
|
|
1097
1255
|
}
|
|
1098
1256
|
return e;
|
|
1099
1257
|
});
|
|
1100
1258
|
}
|
|
1101
1259
|
// get rid of adjascent ** and resolve .. portions
|
|
1102
1260
|
levelOneOptimize(t) {
|
|
1103
|
-
return t.map((e) => (e = e.reduce((
|
|
1104
|
-
const i =
|
|
1105
|
-
return r === "**" && i === "**" ?
|
|
1261
|
+
return t.map((e) => (e = e.reduce((s, r) => {
|
|
1262
|
+
const i = s[s.length - 1];
|
|
1263
|
+
return r === "**" && i === "**" ? s : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (s.pop(), s) : (s.push(r), s);
|
|
1106
1264
|
}, []), e.length === 0 ? [""] : e));
|
|
1107
1265
|
}
|
|
1108
1266
|
levelTwoFileOptimize(t) {
|
|
@@ -1116,10 +1274,10 @@ class Z {
|
|
|
1116
1274
|
}
|
|
1117
1275
|
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
1118
1276
|
}
|
|
1119
|
-
let
|
|
1120
|
-
for (; (
|
|
1121
|
-
const r = t[
|
|
1122
|
-
r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(
|
|
1277
|
+
let s = 0;
|
|
1278
|
+
for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
|
|
1279
|
+
const r = t[s - 1];
|
|
1280
|
+
r && r !== "." && r !== ".." && r !== "**" && !(this.isWindows && /^[a-z]:$/i.test(r)) && (e = !0, t.splice(s - 1, 2), s -= 2);
|
|
1123
1281
|
}
|
|
1124
1282
|
} while (e);
|
|
1125
1283
|
return t.length === 0 ? [""] : t;
|
|
@@ -1146,35 +1304,35 @@ class Z {
|
|
|
1146
1304
|
let e = !1;
|
|
1147
1305
|
do {
|
|
1148
1306
|
e = !1;
|
|
1149
|
-
for (let
|
|
1307
|
+
for (let s of t) {
|
|
1150
1308
|
let r = -1;
|
|
1151
|
-
for (; (r =
|
|
1309
|
+
for (; (r = s.indexOf("**", r + 1)) !== -1; ) {
|
|
1152
1310
|
let o = r;
|
|
1153
|
-
for (;
|
|
1311
|
+
for (; s[o + 1] === "**"; )
|
|
1154
1312
|
o++;
|
|
1155
|
-
o > r &&
|
|
1156
|
-
let a =
|
|
1157
|
-
const c =
|
|
1158
|
-
if (a !== ".." || !c || c === "." || c === ".." || !
|
|
1313
|
+
o > r && s.splice(r + 1, o - r);
|
|
1314
|
+
let a = s[r + 1];
|
|
1315
|
+
const c = s[r + 2], l = s[r + 3];
|
|
1316
|
+
if (a !== ".." || !c || c === "." || c === ".." || !l || l === "." || l === "..")
|
|
1159
1317
|
continue;
|
|
1160
|
-
e = !0,
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1318
|
+
e = !0, s.splice(r, 1);
|
|
1319
|
+
const h = s.slice(0);
|
|
1320
|
+
h[r] = "**", t.push(h), r--;
|
|
1163
1321
|
}
|
|
1164
1322
|
if (!this.preserveMultipleSlashes) {
|
|
1165
|
-
for (let o = 1; o <
|
|
1166
|
-
const a =
|
|
1167
|
-
o === 1 && a === "" &&
|
|
1323
|
+
for (let o = 1; o < s.length - 1; o++) {
|
|
1324
|
+
const a = s[o];
|
|
1325
|
+
o === 1 && a === "" && s[0] === "" || (a === "." || a === "") && (e = !0, s.splice(o, 1), o--);
|
|
1168
1326
|
}
|
|
1169
|
-
|
|
1327
|
+
s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
|
|
1170
1328
|
}
|
|
1171
1329
|
let i = 0;
|
|
1172
|
-
for (; (i =
|
|
1173
|
-
const o =
|
|
1330
|
+
for (; (i = s.indexOf("..", i + 1)) !== -1; ) {
|
|
1331
|
+
const o = s[i - 1];
|
|
1174
1332
|
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
1175
1333
|
e = !0;
|
|
1176
|
-
const c = i === 1 &&
|
|
1177
|
-
|
|
1334
|
+
const c = i === 1 && s[i + 1] === "**" ? ["."] : [];
|
|
1335
|
+
s.splice(i - 1, 2, ...c), s.length === 0 && s.push(""), i -= 2;
|
|
1178
1336
|
}
|
|
1179
1337
|
}
|
|
1180
1338
|
}
|
|
@@ -1190,23 +1348,23 @@ class Z {
|
|
|
1190
1348
|
// ^-- not valid because ** doens't follow symlinks
|
|
1191
1349
|
secondPhasePreProcess(t) {
|
|
1192
1350
|
for (let e = 0; e < t.length - 1; e++)
|
|
1193
|
-
for (let
|
|
1194
|
-
const r = this.partsMatch(t[e], t[
|
|
1351
|
+
for (let s = e + 1; s < t.length; s++) {
|
|
1352
|
+
const r = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
|
|
1195
1353
|
if (r) {
|
|
1196
|
-
t[e] = [], t[
|
|
1354
|
+
t[e] = [], t[s] = r;
|
|
1197
1355
|
break;
|
|
1198
1356
|
}
|
|
1199
1357
|
}
|
|
1200
1358
|
return t.filter((e) => e.length);
|
|
1201
1359
|
}
|
|
1202
|
-
partsMatch(t, e,
|
|
1360
|
+
partsMatch(t, e, s = !1) {
|
|
1203
1361
|
let r = 0, i = 0, o = [], a = "";
|
|
1204
1362
|
for (; r < t.length && i < e.length; )
|
|
1205
1363
|
if (t[r] === e[i])
|
|
1206
1364
|
o.push(a === "b" ? e[i] : t[r]), r++, i++;
|
|
1207
|
-
else if (
|
|
1365
|
+
else if (s && t[r] === "**" && e[i] === t[r + 1])
|
|
1208
1366
|
o.push(t[r]), r++;
|
|
1209
|
-
else if (
|
|
1367
|
+
else if (s && e[i] === "**" && t[r] === e[i + 1])
|
|
1210
1368
|
o.push(e[i]), i++;
|
|
1211
1369
|
else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
|
|
1212
1370
|
if (a === "b")
|
|
@@ -1224,80 +1382,139 @@ class Z {
|
|
|
1224
1382
|
if (this.nonegate)
|
|
1225
1383
|
return;
|
|
1226
1384
|
const t = this.pattern;
|
|
1227
|
-
let e = !1,
|
|
1385
|
+
let e = !1, s = 0;
|
|
1228
1386
|
for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
|
|
1229
|
-
e = !e,
|
|
1230
|
-
|
|
1387
|
+
e = !e, s++;
|
|
1388
|
+
s && (this.pattern = t.slice(s)), this.negate = e;
|
|
1231
1389
|
}
|
|
1232
1390
|
// set partial to true to test if, for example,
|
|
1233
1391
|
// "/a/b" matches the start of "/*/b/*/d"
|
|
1234
1392
|
// Partial means, if you run out of file before you run
|
|
1235
1393
|
// out of pattern, then that's fine, as long as all
|
|
1236
1394
|
// the parts match.
|
|
1237
|
-
matchOne(t, e,
|
|
1238
|
-
|
|
1395
|
+
matchOne(t, e, s = !1) {
|
|
1396
|
+
let r = 0, i = 0;
|
|
1239
1397
|
if (this.isWindows) {
|
|
1240
|
-
const
|
|
1241
|
-
if (typeof
|
|
1242
|
-
const [
|
|
1243
|
-
|
|
1398
|
+
const a = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), c = !a && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), l = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), h = !l && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), u = c ? 3 : a ? 0 : void 0, f = h ? 3 : l ? 0 : void 0;
|
|
1399
|
+
if (typeof u == "number" && typeof f == "number") {
|
|
1400
|
+
const [p, g] = [
|
|
1401
|
+
t[u],
|
|
1402
|
+
e[f]
|
|
1403
|
+
];
|
|
1404
|
+
p.toLowerCase() === g.toLowerCase() && (e[f] = p, i = f, r = u);
|
|
1244
1405
|
}
|
|
1245
1406
|
}
|
|
1246
|
-
const { optimizationLevel:
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1407
|
+
const { optimizationLevel: o = 1 } = this.options;
|
|
1408
|
+
return o >= 2 && (t = this.levelTwoFileOptimize(t)), e.includes(S) ? this.#s(t, e, s, r, i) : this.#r(t, e, s, r, i);
|
|
1409
|
+
}
|
|
1410
|
+
#s(t, e, s, r, i) {
|
|
1411
|
+
const o = e.indexOf(S, i), a = e.lastIndexOf(S), [c, l, h] = s ? [
|
|
1412
|
+
e.slice(i, o),
|
|
1413
|
+
e.slice(o + 1),
|
|
1414
|
+
[]
|
|
1415
|
+
] : [
|
|
1416
|
+
e.slice(i, o),
|
|
1417
|
+
e.slice(o + 1, a),
|
|
1418
|
+
e.slice(a + 1)
|
|
1419
|
+
];
|
|
1420
|
+
if (c.length) {
|
|
1421
|
+
const m = t.slice(r, r + c.length);
|
|
1422
|
+
if (!this.#r(m, c, s, 0, 0))
|
|
1252
1423
|
return !1;
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
return this.debug("globstar found match!", u, c, g), !0;
|
|
1267
|
-
if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
|
|
1268
|
-
this.debug("dot detected!", t, u, e, d);
|
|
1269
|
-
break;
|
|
1270
|
-
}
|
|
1271
|
-
this.debug("globstar swallow a segment, and continue"), u++;
|
|
1272
|
-
}
|
|
1273
|
-
return !!(n && (this.debug(`
|
|
1274
|
-
>>> no match, partial?`, t, u, e, d), u === c));
|
|
1424
|
+
r += c.length, i += c.length;
|
|
1425
|
+
}
|
|
1426
|
+
let u = 0;
|
|
1427
|
+
if (h.length) {
|
|
1428
|
+
if (h.length + r > t.length)
|
|
1429
|
+
return !1;
|
|
1430
|
+
let m = t.length - h.length;
|
|
1431
|
+
if (this.#r(t, h, s, m, 0))
|
|
1432
|
+
u = h.length;
|
|
1433
|
+
else {
|
|
1434
|
+
if (t[t.length - 1] !== "" || r + h.length === t.length || (m--, !this.#r(t, h, s, m, 0)))
|
|
1435
|
+
return !1;
|
|
1436
|
+
u = h.length + 1;
|
|
1275
1437
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1438
|
+
}
|
|
1439
|
+
if (!l.length) {
|
|
1440
|
+
let m = !!u;
|
|
1441
|
+
for (let M = r; M < t.length - u; M++) {
|
|
1442
|
+
const V = String(t[M]);
|
|
1443
|
+
if (m = !0, V === "." || V === ".." || !this.options.dot && V.startsWith("."))
|
|
1444
|
+
return !1;
|
|
1445
|
+
}
|
|
1446
|
+
return s || m;
|
|
1447
|
+
}
|
|
1448
|
+
const f = [[[], 0]];
|
|
1449
|
+
let p = f[0], g = 0;
|
|
1450
|
+
const d = [0];
|
|
1451
|
+
for (const m of l)
|
|
1452
|
+
m === S ? (d.push(g), p = [[], 0], f.push(p)) : (p[0].push(m), g++);
|
|
1453
|
+
let E = f.length - 1;
|
|
1454
|
+
const w = t.length - u;
|
|
1455
|
+
for (const m of f)
|
|
1456
|
+
m[1] = w - (d[E--] + m[0].length);
|
|
1457
|
+
return !!this.#n(t, f, r, 0, s, 0, !!u);
|
|
1458
|
+
}
|
|
1459
|
+
// return false for "nope, not matching"
|
|
1460
|
+
// return null for "not matching, cannot keep trying"
|
|
1461
|
+
#n(t, e, s, r, i, o, a) {
|
|
1462
|
+
const c = e[r];
|
|
1463
|
+
if (!c) {
|
|
1464
|
+
for (let u = s; u < t.length; u++) {
|
|
1465
|
+
a = !0;
|
|
1466
|
+
const f = t[u];
|
|
1467
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
|
|
1468
|
+
return !1;
|
|
1469
|
+
}
|
|
1470
|
+
return a;
|
|
1471
|
+
}
|
|
1472
|
+
const [l, h] = c;
|
|
1473
|
+
for (; s <= h; ) {
|
|
1474
|
+
if (this.#r(t.slice(0, s + l.length), l, i, s, 0) && o < this.maxGlobstarRecursion) {
|
|
1475
|
+
const p = this.#n(t, e, s + l.length, r + 1, i, o + 1, a);
|
|
1476
|
+
if (p !== !1)
|
|
1477
|
+
return p;
|
|
1478
|
+
}
|
|
1479
|
+
const f = t[s];
|
|
1480
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
|
|
1481
|
+
return !1;
|
|
1482
|
+
s++;
|
|
1483
|
+
}
|
|
1484
|
+
return i || null;
|
|
1485
|
+
}
|
|
1486
|
+
#r(t, e, s, r, i) {
|
|
1487
|
+
let o, a, c, l;
|
|
1488
|
+
for (o = r, a = i, l = t.length, c = e.length; o < l && a < c; o++, a++) {
|
|
1489
|
+
this.debug("matchOne loop");
|
|
1490
|
+
let h = e[a], u = t[o];
|
|
1491
|
+
if (this.debug(e, h, u), h === !1 || h === S)
|
|
1492
|
+
return !1;
|
|
1493
|
+
let f;
|
|
1494
|
+
if (typeof h == "string" ? (f = u === h, this.debug("string match", h, u, f)) : (f = h.test(u), this.debug("pattern match", h, u, f)), !f)
|
|
1278
1495
|
return !1;
|
|
1279
1496
|
}
|
|
1280
|
-
if (o ===
|
|
1497
|
+
if (o === l && a === c)
|
|
1281
1498
|
return !0;
|
|
1282
|
-
if (o ===
|
|
1283
|
-
return
|
|
1284
|
-
if (a ===
|
|
1285
|
-
return o ===
|
|
1499
|
+
if (o === l)
|
|
1500
|
+
return s;
|
|
1501
|
+
if (a === c)
|
|
1502
|
+
return o === l - 1 && t[o] === "";
|
|
1286
1503
|
throw new Error("wtf?");
|
|
1287
1504
|
}
|
|
1288
1505
|
braceExpand() {
|
|
1289
|
-
return
|
|
1506
|
+
return _t(this.pattern, this.options);
|
|
1290
1507
|
}
|
|
1291
1508
|
parse(t) {
|
|
1292
|
-
|
|
1509
|
+
G(t);
|
|
1293
1510
|
const e = this.options;
|
|
1294
1511
|
if (t === "**")
|
|
1295
|
-
return
|
|
1512
|
+
return S;
|
|
1296
1513
|
if (t === "")
|
|
1297
1514
|
return "";
|
|
1298
|
-
let
|
|
1299
|
-
(
|
|
1300
|
-
const i =
|
|
1515
|
+
let s, r = null;
|
|
1516
|
+
(s = t.match(es)) ? r = e.dot ? ns : ss : (s = t.match(Ue)) ? r = (e.nocase ? e.dot ? Ye : Xe : e.dot ? Ve : qe)(s[1]) : (s = t.match(rs)) ? r = (e.nocase ? e.dot ? os : is : e.dot ? as : cs)(s) : (s = t.match(Ze)) ? r = e.dot ? Qe : Je : (s = t.match(Ke)) && (r = ts);
|
|
1517
|
+
const i = ct.fromGlob(t, this.options).toMMPattern();
|
|
1301
1518
|
return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
|
|
1302
1519
|
}
|
|
1303
1520
|
makeRe() {
|
|
@@ -1306,21 +1523,29 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1306
1523
|
const t = this.set;
|
|
1307
1524
|
if (!t.length)
|
|
1308
1525
|
return this.regexp = !1, this.regexp;
|
|
1309
|
-
const e = this.options,
|
|
1526
|
+
const e = this.options, s = e.noglobstar ? us : e.dot ? fs : ps, r = new Set(e.nocase ? ["i"] : []);
|
|
1310
1527
|
let i = t.map((c) => {
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1313
|
-
for (const f of
|
|
1528
|
+
const l = c.map((u) => {
|
|
1529
|
+
if (u instanceof RegExp)
|
|
1530
|
+
for (const f of u.flags.split(""))
|
|
1314
1531
|
r.add(f);
|
|
1315
|
-
return typeof
|
|
1532
|
+
return typeof u == "string" ? ms(u) : u === S ? S : u._src;
|
|
1533
|
+
});
|
|
1534
|
+
l.forEach((u, f) => {
|
|
1535
|
+
const p = l[f + 1], g = l[f - 1];
|
|
1536
|
+
u !== S || g === S || (g === void 0 ? p !== void 0 && p !== S ? l[f + 1] = "(?:\\/|" + s + "\\/)?" + p : l[f] = s : p === void 0 ? l[f - 1] = g + "(?:\\/|\\/" + s + ")?" : p !== S && (l[f - 1] = g + "(?:\\/|\\/" + s + "\\/)" + p, l[f + 1] = S));
|
|
1316
1537
|
});
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1538
|
+
const h = l.filter((u) => u !== S);
|
|
1539
|
+
if (this.partial && h.length >= 1) {
|
|
1540
|
+
const u = [];
|
|
1541
|
+
for (let f = 1; f <= h.length; f++)
|
|
1542
|
+
u.push(h.slice(0, f).join("/"));
|
|
1543
|
+
return "(?:" + u.join("|") + ")";
|
|
1544
|
+
}
|
|
1545
|
+
return h.join("/");
|
|
1321
1546
|
}).join("|");
|
|
1322
1547
|
const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1323
|
-
i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
|
|
1548
|
+
i = "^" + o + i + a + "$", this.partial && (i = "^(?:\\/|" + o + i.slice(1, -1) + a + ")$"), this.negate && (i = "^(?!" + i + ").+$");
|
|
1324
1549
|
try {
|
|
1325
1550
|
this.regexp = new RegExp(i, [...r].join(""));
|
|
1326
1551
|
} catch {
|
|
@@ -1329,7 +1554,7 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1329
1554
|
return this.regexp;
|
|
1330
1555
|
}
|
|
1331
1556
|
slashSplit(t) {
|
|
1332
|
-
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[
|
|
1557
|
+
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
|
|
1333
1558
|
}
|
|
1334
1559
|
match(t, e = this.partial) {
|
|
1335
1560
|
if (this.debug("match", t, this.pattern), this.comment)
|
|
@@ -1338,7 +1563,7 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1338
1563
|
return t === "";
|
|
1339
1564
|
if (t === "/" && e)
|
|
1340
1565
|
return !0;
|
|
1341
|
-
const
|
|
1566
|
+
const s = this.options;
|
|
1342
1567
|
this.isWindows && (t = t.split("\\").join("/"));
|
|
1343
1568
|
const r = this.slashSplit(t);
|
|
1344
1569
|
this.debug(this.pattern, "split", r);
|
|
@@ -1348,122 +1573,129 @@ globstar while`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1348
1573
|
if (!o)
|
|
1349
1574
|
for (let a = r.length - 2; !o && a >= 0; a--)
|
|
1350
1575
|
o = r[a];
|
|
1351
|
-
for (
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
return n.flipNegate ? !0 : !this.negate;
|
|
1576
|
+
for (const a of i) {
|
|
1577
|
+
let c = r;
|
|
1578
|
+
if (s.matchBase && a.length === 1 && (c = [o]), this.matchOne(c, a, e))
|
|
1579
|
+
return s.flipNegate ? !0 : !this.negate;
|
|
1356
1580
|
}
|
|
1357
|
-
return
|
|
1581
|
+
return s.flipNegate ? !1 : this.negate;
|
|
1358
1582
|
}
|
|
1359
1583
|
static defaults(t) {
|
|
1360
|
-
return
|
|
1584
|
+
return b.defaults(t).Minimatch;
|
|
1361
1585
|
}
|
|
1362
1586
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
function
|
|
1587
|
+
b.AST = ct;
|
|
1588
|
+
b.Minimatch = q;
|
|
1589
|
+
b.escape = Ge;
|
|
1590
|
+
b.unescape = R;
|
|
1591
|
+
function Es() {
|
|
1368
1592
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1369
|
-
throw new
|
|
1593
|
+
throw new se();
|
|
1594
|
+
}
|
|
1595
|
+
function Ss(n, t) {
|
|
1596
|
+
const e = v(n || "/"), s = v(ht(t));
|
|
1597
|
+
return e === "/" ? s : s === "/" ? e : `${e.replace(/\/$/, "")}${s}`;
|
|
1370
1598
|
}
|
|
1371
|
-
async function
|
|
1372
|
-
|
|
1599
|
+
async function Wt(n, t, e = "/") {
|
|
1600
|
+
if (typeof navigator < "u" && navigator.locks?.request) {
|
|
1601
|
+
const s = Ss(e, n).replace(/\/+/g, "/");
|
|
1602
|
+
return navigator.locks.request(`opfs:${s}`, { mode: "exclusive" }, t);
|
|
1603
|
+
}
|
|
1604
|
+
return t();
|
|
1373
1605
|
}
|
|
1374
|
-
function
|
|
1375
|
-
return Array.isArray(
|
|
1606
|
+
function C(n) {
|
|
1607
|
+
return Array.isArray(n) ? n : (n.startsWith("~/") ? n.slice(2) : n).split("/").filter(Boolean);
|
|
1376
1608
|
}
|
|
1377
|
-
function lt(
|
|
1378
|
-
return typeof
|
|
1609
|
+
function lt(n) {
|
|
1610
|
+
return typeof n == "string" ? n ?? "/" : `/${n.join("/")}`;
|
|
1379
1611
|
}
|
|
1380
|
-
function it(
|
|
1381
|
-
const t =
|
|
1612
|
+
function it(n) {
|
|
1613
|
+
const t = C(n);
|
|
1382
1614
|
return t[t.length - 1] || "";
|
|
1383
1615
|
}
|
|
1384
|
-
function
|
|
1385
|
-
const t =
|
|
1616
|
+
function J(n) {
|
|
1617
|
+
const t = C(n);
|
|
1386
1618
|
return t.pop(), lt(t);
|
|
1387
1619
|
}
|
|
1388
|
-
function
|
|
1389
|
-
return !
|
|
1620
|
+
function v(n) {
|
|
1621
|
+
return !n || n === "/" ? "/" : n.startsWith("~/") ? `/${n.slice(2)}` : n.startsWith("/") ? n : `/${n}`;
|
|
1390
1622
|
}
|
|
1391
|
-
function
|
|
1392
|
-
return
|
|
1623
|
+
function bs(n, t = !1) {
|
|
1624
|
+
return n = n.replace(/\/$/, ""), t && !n.includes("*") ? `${n}/**` : n;
|
|
1393
1625
|
}
|
|
1394
|
-
function
|
|
1395
|
-
return
|
|
1626
|
+
function Q(n, t) {
|
|
1627
|
+
return b(n, t, {
|
|
1396
1628
|
dot: !0,
|
|
1397
1629
|
matchBase: !0
|
|
1398
1630
|
});
|
|
1399
1631
|
}
|
|
1400
|
-
function
|
|
1401
|
-
const t =
|
|
1632
|
+
function ht(n) {
|
|
1633
|
+
const t = v(n), e = C(t), s = [];
|
|
1402
1634
|
for (const r of e)
|
|
1403
1635
|
if (!(r === "." || r === ""))
|
|
1404
1636
|
if (r === "..") {
|
|
1405
|
-
if (
|
|
1637
|
+
if (s.length === 0)
|
|
1406
1638
|
continue;
|
|
1407
|
-
|
|
1639
|
+
s.pop();
|
|
1408
1640
|
} else
|
|
1409
|
-
|
|
1410
|
-
return lt(
|
|
1641
|
+
s.push(r);
|
|
1642
|
+
return lt(s);
|
|
1411
1643
|
}
|
|
1412
|
-
async function
|
|
1413
|
-
if (
|
|
1414
|
-
throw new Error(`File size ${
|
|
1415
|
-
const
|
|
1644
|
+
async function xs(n, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1645
|
+
if (n instanceof File && (n = await n.arrayBuffer()), n.byteLength > e)
|
|
1646
|
+
throw new Error(`File size ${n.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
|
|
1647
|
+
const s = new Uint8Array(n), r = await crypto.subtle.digest(t, s);
|
|
1416
1648
|
return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1417
1649
|
}
|
|
1418
|
-
async function
|
|
1419
|
-
const
|
|
1420
|
-
return
|
|
1650
|
+
async function As(n, t, e = {}) {
|
|
1651
|
+
const s = it(t);
|
|
1652
|
+
return Wt(t, async () => {
|
|
1421
1653
|
const r = e.recursive ?? !1, i = e.force ?? !1;
|
|
1422
1654
|
try {
|
|
1423
|
-
await
|
|
1655
|
+
await n.removeEntry(s, { recursive: r });
|
|
1424
1656
|
} catch (o) {
|
|
1425
1657
|
if (o.name === "NotFoundError" && i)
|
|
1426
1658
|
return;
|
|
1427
1659
|
const a = o.name === "TypeMismatchError" && !r;
|
|
1428
|
-
throw
|
|
1660
|
+
throw A(o, {
|
|
1429
1661
|
path: t,
|
|
1430
1662
|
operation: "remove",
|
|
1431
1663
|
isDirectory: a
|
|
1432
1664
|
});
|
|
1433
1665
|
}
|
|
1434
|
-
});
|
|
1666
|
+
}, e.root ?? "/");
|
|
1435
1667
|
}
|
|
1436
|
-
function
|
|
1668
|
+
function bt(n, t, e, s) {
|
|
1437
1669
|
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1438
|
-
throw new
|
|
1670
|
+
throw new $("argument", "Invalid offset or length");
|
|
1439
1671
|
if (t < 0 || e < 0)
|
|
1440
|
-
throw new
|
|
1441
|
-
if (t + e >
|
|
1442
|
-
throw new
|
|
1443
|
-
if (
|
|
1444
|
-
throw new
|
|
1672
|
+
throw new $("argument", "Negative offset or length not allowed");
|
|
1673
|
+
if (t + e > n)
|
|
1674
|
+
throw new $("overflow", "Operation would overflow buffer");
|
|
1675
|
+
if (s != null && (!Number.isInteger(s) || s < 0))
|
|
1676
|
+
throw new $("argument", "Invalid position");
|
|
1445
1677
|
}
|
|
1446
|
-
function
|
|
1678
|
+
function xt(n, t, e) {
|
|
1447
1679
|
try {
|
|
1448
1680
|
t.flush(), t.close();
|
|
1449
|
-
} catch (
|
|
1450
|
-
console.warn(`Warning: Failed to properly close file descriptor ${
|
|
1681
|
+
} catch (s) {
|
|
1682
|
+
console.warn(`Warning: Failed to properly close file descriptor ${n} (${e}):`, s);
|
|
1451
1683
|
}
|
|
1452
1684
|
}
|
|
1453
|
-
function
|
|
1454
|
-
if (
|
|
1685
|
+
function Os(n, t, e) {
|
|
1686
|
+
if (n >= e)
|
|
1455
1687
|
return { isEOF: !0, actualLength: 0 };
|
|
1456
|
-
const
|
|
1457
|
-
return
|
|
1688
|
+
const s = Math.min(t, e - n);
|
|
1689
|
+
return s <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: s };
|
|
1458
1690
|
}
|
|
1459
|
-
async function
|
|
1691
|
+
async function Ds(n, t) {
|
|
1460
1692
|
try {
|
|
1461
|
-
return await
|
|
1693
|
+
return await n.createSyncAccessHandle();
|
|
1462
1694
|
} catch (e) {
|
|
1463
|
-
throw
|
|
1695
|
+
throw A(e, { path: t, isDirectory: !1 });
|
|
1464
1696
|
}
|
|
1465
1697
|
}
|
|
1466
|
-
class
|
|
1698
|
+
class Ms {
|
|
1467
1699
|
/** Root directory handle for the file system */
|
|
1468
1700
|
root;
|
|
1469
1701
|
/** Map of watched paths and options */
|
|
@@ -1492,7 +1724,7 @@ class gs {
|
|
|
1492
1724
|
if (!this.options.broadcastChannel)
|
|
1493
1725
|
return;
|
|
1494
1726
|
const e = t.path;
|
|
1495
|
-
if (![...this.watchers.values()].some((i) =>
|
|
1727
|
+
if (![...this.watchers.values()].some((i) => Q(e, i.pattern) && i.include.some((o) => o && Q(e, o)) && !i.exclude.some((o) => o && Q(e, o))))
|
|
1496
1728
|
return;
|
|
1497
1729
|
let r;
|
|
1498
1730
|
if (this.options.hashAlgorithm)
|
|
@@ -1514,7 +1746,11 @@ class gs {
|
|
|
1514
1746
|
}
|
|
1515
1747
|
}
|
|
1516
1748
|
constructor(t) {
|
|
1517
|
-
|
|
1749
|
+
Es(), t && this.setOptions(t);
|
|
1750
|
+
}
|
|
1751
|
+
/** Exclusive path lock keyed by absolute OPFS path (`root` + API path). */
|
|
1752
|
+
async withPathLock(t, e) {
|
|
1753
|
+
return Wt(t, e, this.options.root);
|
|
1518
1754
|
}
|
|
1519
1755
|
/**
|
|
1520
1756
|
* Initialize the file system within a given directory.
|
|
@@ -1522,12 +1758,12 @@ class gs {
|
|
|
1522
1758
|
*/
|
|
1523
1759
|
async mount() {
|
|
1524
1760
|
const t = this.options.root;
|
|
1525
|
-
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e,
|
|
1761
|
+
return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, s) => {
|
|
1526
1762
|
try {
|
|
1527
1763
|
const r = await navigator.storage.getDirectory();
|
|
1528
1764
|
this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
|
|
1529
1765
|
} catch (r) {
|
|
1530
|
-
|
|
1766
|
+
s(new ce(t, r));
|
|
1531
1767
|
} finally {
|
|
1532
1768
|
this.mountingPromise = null;
|
|
1533
1769
|
}
|
|
@@ -1544,7 +1780,7 @@ class gs {
|
|
|
1544
1780
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1545
1781
|
*/
|
|
1546
1782
|
async setOptions(t) {
|
|
1547
|
-
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 =
|
|
1783
|
+
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 = v(t.root), this.options.namespace || (this.options.namespace = `opfs-worker:${this.options.root}`), await this.mount());
|
|
1548
1784
|
}
|
|
1549
1785
|
/**
|
|
1550
1786
|
* Get a directory handle from a path
|
|
@@ -1564,9 +1800,9 @@ class gs {
|
|
|
1564
1800
|
* const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
|
|
1565
1801
|
* ```
|
|
1566
1802
|
*/
|
|
1567
|
-
async getDirectoryHandle(t, e = !1,
|
|
1568
|
-
const r = Array.isArray(t) ? t :
|
|
1569
|
-
let i =
|
|
1803
|
+
async getDirectoryHandle(t, e = !1, s = this.root) {
|
|
1804
|
+
const r = Array.isArray(t) ? t : C(t);
|
|
1805
|
+
let i = s;
|
|
1570
1806
|
for (const o of r)
|
|
1571
1807
|
i = await i.getDirectoryHandle(o, { create: e });
|
|
1572
1808
|
return i;
|
|
@@ -1590,12 +1826,12 @@ class gs {
|
|
|
1590
1826
|
* const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
|
|
1591
1827
|
* ```
|
|
1592
1828
|
*/
|
|
1593
|
-
async getFileHandle(t, e = !1,
|
|
1594
|
-
const r =
|
|
1829
|
+
async getFileHandle(t, e = !1, s = this.root) {
|
|
1830
|
+
const r = C(t);
|
|
1595
1831
|
if (r.length === 0)
|
|
1596
|
-
throw new
|
|
1832
|
+
throw new ne("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1597
1833
|
const i = r.pop();
|
|
1598
|
-
return (await this.getDirectoryHandle(r, e,
|
|
1834
|
+
return (await this.getDirectoryHandle(r, e, s)).getFileHandle(i, { create: e });
|
|
1599
1835
|
}
|
|
1600
1836
|
/**
|
|
1601
1837
|
* Get a complete index of all files and directories in the file system
|
|
@@ -1617,10 +1853,10 @@ class gs {
|
|
|
1617
1853
|
* ```
|
|
1618
1854
|
*/
|
|
1619
1855
|
async index() {
|
|
1620
|
-
const t = /* @__PURE__ */ new Map(), e = async (
|
|
1621
|
-
const r = await this.readDir(
|
|
1856
|
+
const t = /* @__PURE__ */ new Map(), e = async (s) => {
|
|
1857
|
+
const r = await this.readDir(s);
|
|
1622
1858
|
for (const i of r) {
|
|
1623
|
-
const o = `${
|
|
1859
|
+
const o = `${s === "/" ? "" : s}/${i.name}`;
|
|
1624
1860
|
try {
|
|
1625
1861
|
const a = await this.stat(o);
|
|
1626
1862
|
t.set(o, a), a.isDirectory && await e(o);
|
|
@@ -1661,17 +1897,17 @@ class gs {
|
|
|
1661
1897
|
*/
|
|
1662
1898
|
async mkdir(t, e) {
|
|
1663
1899
|
await this.mount();
|
|
1664
|
-
const
|
|
1900
|
+
const s = e?.recursive ?? !1, r = C(t);
|
|
1665
1901
|
let i = this.root;
|
|
1666
1902
|
for (let o = 0; o < r.length; o++) {
|
|
1667
1903
|
const a = r[o];
|
|
1668
1904
|
try {
|
|
1669
|
-
i = await i.getDirectoryHandle(a, { create:
|
|
1905
|
+
i = await i.getDirectoryHandle(a, { create: s || o === r.length - 1 });
|
|
1670
1906
|
} catch (c) {
|
|
1671
|
-
throw c.name === "NotFoundError" ?
|
|
1907
|
+
throw c.name === "NotFoundError" ? A(c, {
|
|
1672
1908
|
path: lt(r.slice(0, o + 1)),
|
|
1673
1909
|
existenceType: "directory"
|
|
1674
|
-
}) : c.name === "TypeMismatchError" ?
|
|
1910
|
+
}) : c.name === "TypeMismatchError" ? A(c, { path: a, isDirectory: !1 }) : new Y("create directory", a, c);
|
|
1675
1911
|
}
|
|
1676
1912
|
}
|
|
1677
1913
|
await this.notifyChange({ path: t, type: O.Added, isDirectory: !0 });
|
|
@@ -1709,10 +1945,10 @@ class gs {
|
|
|
1709
1945
|
isDirectory: !0
|
|
1710
1946
|
};
|
|
1711
1947
|
const e = it(t);
|
|
1712
|
-
let
|
|
1948
|
+
let s;
|
|
1713
1949
|
try {
|
|
1714
|
-
|
|
1715
|
-
const r = this.options.hashAlgorithm, o = await (await
|
|
1950
|
+
s = await this.getDirectoryHandle(J(t), !1);
|
|
1951
|
+
const r = this.options.hashAlgorithm, o = await (await s.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1716
1952
|
kind: "file",
|
|
1717
1953
|
size: o.size,
|
|
1718
1954
|
mtime: new Date(o.lastModified).toISOString(),
|
|
@@ -1724,7 +1960,7 @@ class gs {
|
|
|
1724
1960
|
a.hash = `${o.lastModified.toString(36)}-${o.size.toString(36)}`;
|
|
1725
1961
|
else if (typeof r == "string")
|
|
1726
1962
|
try {
|
|
1727
|
-
const c = await
|
|
1963
|
+
const c = await xs(o, r, this.options.maxFileSize);
|
|
1728
1964
|
a.hash = c;
|
|
1729
1965
|
} catch (c) {
|
|
1730
1966
|
console.warn(`Failed to calculate hash for ${t}:`, c);
|
|
@@ -1732,12 +1968,12 @@ class gs {
|
|
|
1732
1968
|
return a;
|
|
1733
1969
|
} catch (r) {
|
|
1734
1970
|
if (r.name === "NotFoundError")
|
|
1735
|
-
throw new
|
|
1971
|
+
throw new _("file", t, r);
|
|
1736
1972
|
if (r.name !== "TypeMismatchError")
|
|
1737
|
-
throw new
|
|
1973
|
+
throw new Y("stat", t, r);
|
|
1738
1974
|
}
|
|
1739
1975
|
try {
|
|
1740
|
-
return await
|
|
1976
|
+
return await s.getDirectoryHandle(e, { create: !1 }), {
|
|
1741
1977
|
kind: "directory",
|
|
1742
1978
|
size: 0,
|
|
1743
1979
|
mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
@@ -1746,7 +1982,7 @@ class gs {
|
|
|
1746
1982
|
isDirectory: !0
|
|
1747
1983
|
};
|
|
1748
1984
|
} catch (r) {
|
|
1749
|
-
throw new
|
|
1985
|
+
throw new Y("stat", t, r);
|
|
1750
1986
|
}
|
|
1751
1987
|
}
|
|
1752
1988
|
/**
|
|
@@ -1769,17 +2005,17 @@ class gs {
|
|
|
1769
2005
|
*/
|
|
1770
2006
|
async readDir(t) {
|
|
1771
2007
|
await this.mount();
|
|
1772
|
-
const e = await this.getDirectoryHandle(t, !1),
|
|
2008
|
+
const e = await this.getDirectoryHandle(t, !1), s = [];
|
|
1773
2009
|
for await (const [r, i] of e.entries()) {
|
|
1774
2010
|
const o = i.kind === "file";
|
|
1775
|
-
|
|
2011
|
+
s.push({
|
|
1776
2012
|
name: r,
|
|
1777
2013
|
kind: i.kind,
|
|
1778
2014
|
isFile: o,
|
|
1779
2015
|
isDirectory: !o
|
|
1780
2016
|
});
|
|
1781
2017
|
}
|
|
1782
|
-
return
|
|
2018
|
+
return s;
|
|
1783
2019
|
}
|
|
1784
2020
|
/**
|
|
1785
2021
|
* Check if a file or directory exists
|
|
@@ -1799,22 +2035,22 @@ class gs {
|
|
|
1799
2035
|
if (await this.mount(), t === "/")
|
|
1800
2036
|
return !0;
|
|
1801
2037
|
const e = it(t);
|
|
1802
|
-
let
|
|
2038
|
+
let s = null;
|
|
1803
2039
|
try {
|
|
1804
|
-
|
|
2040
|
+
s = await this.getDirectoryHandle(J(t), !1);
|
|
1805
2041
|
} catch (r) {
|
|
1806
|
-
if (
|
|
2042
|
+
if (s = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1807
2043
|
throw r;
|
|
1808
2044
|
}
|
|
1809
|
-
if (!
|
|
2045
|
+
if (!s || !e)
|
|
1810
2046
|
return !1;
|
|
1811
2047
|
try {
|
|
1812
|
-
return await
|
|
2048
|
+
return await s.getFileHandle(e, { create: !1 }), !0;
|
|
1813
2049
|
} catch (r) {
|
|
1814
2050
|
if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
|
|
1815
2051
|
throw r;
|
|
1816
2052
|
try {
|
|
1817
|
-
return await
|
|
2053
|
+
return await s.getDirectoryHandle(e, { create: !1 }), !0;
|
|
1818
2054
|
} catch (i) {
|
|
1819
2055
|
if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1820
2056
|
throw i;
|
|
@@ -1845,13 +2081,13 @@ class gs {
|
|
|
1845
2081
|
await this.mount();
|
|
1846
2082
|
try {
|
|
1847
2083
|
const e = await this.readDir(t);
|
|
1848
|
-
for (const
|
|
1849
|
-
const r = `${t === "/" ? "" : t}/${
|
|
2084
|
+
for (const s of e) {
|
|
2085
|
+
const r = `${t === "/" ? "" : t}/${s.name}`;
|
|
1850
2086
|
await this.remove(r, { recursive: !0 });
|
|
1851
2087
|
}
|
|
1852
2088
|
await this.notifyChange({ path: t, type: O.Changed, isDirectory: !0 });
|
|
1853
2089
|
} catch (e) {
|
|
1854
|
-
throw e instanceof
|
|
2090
|
+
throw e instanceof y ? e : A(e, { path: t, isDirectory: !0 });
|
|
1855
2091
|
}
|
|
1856
2092
|
}
|
|
1857
2093
|
/**
|
|
@@ -1880,9 +2116,9 @@ class gs {
|
|
|
1880
2116
|
*/
|
|
1881
2117
|
async remove(t, e) {
|
|
1882
2118
|
if (await this.mount(), t === "/")
|
|
1883
|
-
throw new
|
|
1884
|
-
const { recursive:
|
|
1885
|
-
await
|
|
2119
|
+
throw new et("EROOT", t);
|
|
2120
|
+
const { recursive: s = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(J(t), !1), o = await this.stat(t);
|
|
2121
|
+
await As(i, t, { recursive: s, force: r, root: this.options.root }), await this.notifyChange({ path: t, type: O.Removed, isDirectory: o.isDirectory });
|
|
1886
2122
|
}
|
|
1887
2123
|
/**
|
|
1888
2124
|
* Resolve a path to an absolute path
|
|
@@ -1905,12 +2141,12 @@ class gs {
|
|
|
1905
2141
|
async realpath(t) {
|
|
1906
2142
|
await this.mount();
|
|
1907
2143
|
try {
|
|
1908
|
-
const e =
|
|
2144
|
+
const e = ht(t);
|
|
1909
2145
|
if (!await this.exists(e))
|
|
1910
|
-
throw new
|
|
2146
|
+
throw new _("file", e);
|
|
1911
2147
|
return e;
|
|
1912
2148
|
} catch (e) {
|
|
1913
|
-
throw e instanceof
|
|
2149
|
+
throw e instanceof y ? e : A(e, { path: t });
|
|
1914
2150
|
}
|
|
1915
2151
|
}
|
|
1916
2152
|
/**
|
|
@@ -1935,15 +2171,15 @@ class gs {
|
|
|
1935
2171
|
* await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
|
|
1936
2172
|
* ```
|
|
1937
2173
|
*/
|
|
1938
|
-
async rename(t, e,
|
|
2174
|
+
async rename(t, e, s) {
|
|
1939
2175
|
await this.mount();
|
|
1940
2176
|
try {
|
|
1941
|
-
const r =
|
|
2177
|
+
const r = s?.overwrite ?? !1, i = await this.stat(t);
|
|
1942
2178
|
if (await this.exists(e) && !r)
|
|
1943
|
-
throw new
|
|
2179
|
+
throw new st(e);
|
|
1944
2180
|
await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: O.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: O.Added, isDirectory: i.isDirectory });
|
|
1945
2181
|
} catch (r) {
|
|
1946
|
-
throw r instanceof
|
|
2182
|
+
throw r instanceof y ? r : A(r, { path: t });
|
|
1947
2183
|
}
|
|
1948
2184
|
}
|
|
1949
2185
|
/**
|
|
@@ -1971,29 +2207,29 @@ class gs {
|
|
|
1971
2207
|
* await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
|
|
1972
2208
|
* ```
|
|
1973
2209
|
*/
|
|
1974
|
-
async copy(t, e,
|
|
2210
|
+
async copy(t, e, s) {
|
|
1975
2211
|
await this.mount();
|
|
1976
2212
|
try {
|
|
1977
|
-
const r =
|
|
2213
|
+
const r = s?.recursive ?? !1, i = s?.overwrite ?? !0;
|
|
1978
2214
|
if (!await this.exists(t))
|
|
1979
|
-
throw new
|
|
2215
|
+
throw new _("source", t);
|
|
1980
2216
|
if (await this.exists(e) && !i)
|
|
1981
|
-
throw new
|
|
2217
|
+
throw new st(e);
|
|
1982
2218
|
if ((await this.stat(t)).isFile) {
|
|
1983
|
-
const
|
|
1984
|
-
await this.writeFile(e,
|
|
2219
|
+
const l = await this.readFile(t);
|
|
2220
|
+
await this.writeFile(e, l);
|
|
1985
2221
|
} else {
|
|
1986
2222
|
if (!r)
|
|
1987
|
-
throw new
|
|
2223
|
+
throw new tt("directory", t);
|
|
1988
2224
|
await this.mkdir(e, { recursive: !0 });
|
|
1989
|
-
const
|
|
1990
|
-
for (const
|
|
1991
|
-
const
|
|
1992
|
-
await this.copy(
|
|
2225
|
+
const l = await this.readDir(t);
|
|
2226
|
+
for (const h of l) {
|
|
2227
|
+
const u = `${t}/${h.name}`, f = `${e}/${h.name}`;
|
|
2228
|
+
await this.copy(u, f, { recursive: !0, overwrite: i });
|
|
1993
2229
|
}
|
|
1994
2230
|
}
|
|
1995
2231
|
} catch (r) {
|
|
1996
|
-
throw r instanceof
|
|
2232
|
+
throw r instanceof y ? r : A(r, { path: t });
|
|
1997
2233
|
}
|
|
1998
2234
|
}
|
|
1999
2235
|
/**
|
|
@@ -2023,13 +2259,13 @@ class gs {
|
|
|
2023
2259
|
*/
|
|
2024
2260
|
async watch(t, e) {
|
|
2025
2261
|
if (!this.options.broadcastChannel)
|
|
2026
|
-
throw new
|
|
2027
|
-
const
|
|
2028
|
-
pattern:
|
|
2262
|
+
throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
|
|
2263
|
+
const s = {
|
|
2264
|
+
pattern: bs(t, e?.recursive ?? !0),
|
|
2029
2265
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2030
2266
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2031
2267
|
};
|
|
2032
|
-
this.watchers.set(t,
|
|
2268
|
+
this.watchers.set(t, s);
|
|
2033
2269
|
}
|
|
2034
2270
|
/**
|
|
2035
2271
|
* Stop watching a previously watched path
|
|
@@ -2060,7 +2296,7 @@ class gs {
|
|
|
2060
2296
|
try {
|
|
2061
2297
|
return await (await this.getFileHandle(t, !1)).getFile();
|
|
2062
2298
|
} catch (e) {
|
|
2063
|
-
throw e instanceof
|
|
2299
|
+
throw e instanceof y ? e : A(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
|
|
2064
2300
|
}
|
|
2065
2301
|
}
|
|
2066
2302
|
/**
|
|
@@ -2088,20 +2324,20 @@ class gs {
|
|
|
2088
2324
|
*/
|
|
2089
2325
|
async importFiles(t, e) {
|
|
2090
2326
|
await this.mount();
|
|
2091
|
-
const
|
|
2327
|
+
const s = [...t].map(([c, l]) => [v(c), l]), r = s.length, i = s.map(([c]) => c), o = s.reduce((c, [, l]) => c + $s(l), 0);
|
|
2092
2328
|
let a = 0;
|
|
2093
2329
|
try {
|
|
2094
2330
|
for (let c = 0; c < r; c++) {
|
|
2095
|
-
const [
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
e ? (
|
|
2099
|
-
path:
|
|
2331
|
+
const [l, h] = s[c], { stream: u, size: f } = Ts(h), p = a, g = await this.writeStream(
|
|
2332
|
+
l,
|
|
2333
|
+
u,
|
|
2334
|
+
e ? (d) => e({
|
|
2335
|
+
path: l,
|
|
2100
2336
|
index: c,
|
|
2101
2337
|
count: r,
|
|
2102
|
-
bytesWritten:
|
|
2103
|
-
bytesTotal:
|
|
2104
|
-
totalBytesWritten:
|
|
2338
|
+
bytesWritten: d,
|
|
2339
|
+
bytesTotal: f,
|
|
2340
|
+
totalBytesWritten: p + d,
|
|
2105
2341
|
totalBytes: o
|
|
2106
2342
|
}) : void 0
|
|
2107
2343
|
);
|
|
@@ -2113,14 +2349,14 @@ class gs {
|
|
|
2113
2349
|
bytesWritten: a
|
|
2114
2350
|
};
|
|
2115
2351
|
} catch (c) {
|
|
2116
|
-
throw c instanceof
|
|
2352
|
+
throw c instanceof y ? c : A(c);
|
|
2117
2353
|
}
|
|
2118
2354
|
}
|
|
2119
2355
|
/**
|
|
2120
2356
|
* @deprecated Use {@link importFiles} instead.
|
|
2121
2357
|
*/
|
|
2122
2358
|
async createIndex(t) {
|
|
2123
|
-
|
|
2359
|
+
Ns(), await this.importFiles(t);
|
|
2124
2360
|
}
|
|
2125
2361
|
/**
|
|
2126
2362
|
* Dispose of resources and clean up the file system instance
|
|
@@ -2129,13 +2365,13 @@ class gs {
|
|
|
2129
2365
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2130
2366
|
}
|
|
2131
2367
|
}
|
|
2132
|
-
function
|
|
2133
|
-
return typeof
|
|
2368
|
+
function $s(n) {
|
|
2369
|
+
return typeof n == "string" ? new TextEncoder().encode(n).byteLength : n instanceof Blob ? n.size : n.byteLength;
|
|
2134
2370
|
}
|
|
2135
|
-
function
|
|
2136
|
-
if (
|
|
2137
|
-
return { stream:
|
|
2138
|
-
const t = typeof
|
|
2371
|
+
function Ts(n) {
|
|
2372
|
+
if (n instanceof Blob)
|
|
2373
|
+
return { stream: n.stream(), size: n.size };
|
|
2374
|
+
const t = typeof n == "string" ? new TextEncoder().encode(n) : n;
|
|
2139
2375
|
return {
|
|
2140
2376
|
size: t.byteLength,
|
|
2141
2377
|
stream: new ReadableStream({
|
|
@@ -2145,11 +2381,11 @@ function ys(s) {
|
|
|
2145
2381
|
})
|
|
2146
2382
|
};
|
|
2147
2383
|
}
|
|
2148
|
-
let
|
|
2149
|
-
function
|
|
2150
|
-
|
|
2384
|
+
let At = !1;
|
|
2385
|
+
function Ns() {
|
|
2386
|
+
At || (At = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
|
|
2151
2387
|
}
|
|
2152
|
-
class
|
|
2388
|
+
class Cs extends Ms {
|
|
2153
2389
|
/** Shared sync handles per path (OPFS allows only one handle per file) */
|
|
2154
2390
|
openHandles = /* @__PURE__ */ new Map();
|
|
2155
2391
|
/** Map of open file descriptors to their metadata */
|
|
@@ -2166,32 +2402,32 @@ class Es extends gs {
|
|
|
2166
2402
|
_getFileDescriptor(t) {
|
|
2167
2403
|
const e = this.openFiles.get(t);
|
|
2168
2404
|
if (!e)
|
|
2169
|
-
throw new
|
|
2405
|
+
throw new $("descriptor", `Invalid file descriptor: ${t}`);
|
|
2170
2406
|
return e;
|
|
2171
2407
|
}
|
|
2172
2408
|
async readFile(t) {
|
|
2173
2409
|
await this.mount();
|
|
2174
2410
|
try {
|
|
2175
|
-
return await
|
|
2411
|
+
return await this.withPathLock(t, async () => {
|
|
2176
2412
|
const e = await this.open(t);
|
|
2177
2413
|
try {
|
|
2178
|
-
const { size:
|
|
2179
|
-
return
|
|
2414
|
+
const { size: s } = await this.fstat(e), r = new Uint8Array(s);
|
|
2415
|
+
return s > 0 && await this.read(e, r, 0, s, 0), z(r, [r.buffer]);
|
|
2180
2416
|
} finally {
|
|
2181
2417
|
await this.close(e);
|
|
2182
2418
|
}
|
|
2183
2419
|
});
|
|
2184
2420
|
} catch (e) {
|
|
2185
|
-
throw e instanceof
|
|
2421
|
+
throw e instanceof y ? e : A(e, { path: t, isDirectory: !1 });
|
|
2186
2422
|
}
|
|
2187
2423
|
}
|
|
2188
2424
|
async writeFile(t, e) {
|
|
2189
2425
|
await this.mount();
|
|
2190
|
-
const
|
|
2191
|
-
await
|
|
2426
|
+
const s = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2427
|
+
await this.withPathLock(t, async () => {
|
|
2192
2428
|
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
|
|
2193
2429
|
try {
|
|
2194
|
-
await this.write(i,
|
|
2430
|
+
await this.write(i, s, 0, s.length, null, !1), await this.fsync(i);
|
|
2195
2431
|
} finally {
|
|
2196
2432
|
await this.close(i);
|
|
2197
2433
|
}
|
|
@@ -2200,38 +2436,38 @@ class Es extends gs {
|
|
|
2200
2436
|
}
|
|
2201
2437
|
async appendFile(t, e) {
|
|
2202
2438
|
await this.mount();
|
|
2203
|
-
const
|
|
2204
|
-
await
|
|
2439
|
+
const s = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2440
|
+
await this.withPathLock(t, async () => {
|
|
2205
2441
|
const r = await this.open(t, { create: !0 });
|
|
2206
2442
|
try {
|
|
2207
2443
|
const { size: i } = await this.fstat(r);
|
|
2208
|
-
await this.write(r,
|
|
2444
|
+
await this.write(r, s, 0, s.length, i, !1), await this.fsync(r);
|
|
2209
2445
|
} finally {
|
|
2210
2446
|
await this.close(r);
|
|
2211
2447
|
}
|
|
2212
2448
|
await this.notifyChange({ path: t, type: O.Changed, isDirectory: !1 });
|
|
2213
2449
|
});
|
|
2214
2450
|
}
|
|
2215
|
-
async writeStream(t, e,
|
|
2216
|
-
return await this.mount(),
|
|
2451
|
+
async writeStream(t, e, s) {
|
|
2452
|
+
return await this.mount(), this.withPathLock(t, async () => {
|
|
2217
2453
|
const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 }), o = e.getReader();
|
|
2218
2454
|
let a = 0;
|
|
2219
2455
|
try {
|
|
2220
2456
|
for (; ; ) {
|
|
2221
|
-
const { done: c, value:
|
|
2457
|
+
const { done: c, value: l } = await o.read();
|
|
2222
2458
|
if (c)
|
|
2223
2459
|
break;
|
|
2224
|
-
let
|
|
2225
|
-
for (;
|
|
2226
|
-
|
|
2460
|
+
let h = 0;
|
|
2461
|
+
for (; h < l.byteLength; )
|
|
2462
|
+
h += await this.write(
|
|
2227
2463
|
i,
|
|
2228
|
-
h,
|
|
2229
2464
|
l,
|
|
2230
|
-
h
|
|
2465
|
+
h,
|
|
2466
|
+
l.byteLength - h,
|
|
2231
2467
|
null,
|
|
2232
2468
|
!1
|
|
2233
2469
|
);
|
|
2234
|
-
a +=
|
|
2470
|
+
a += l.byteLength, await s?.(a);
|
|
2235
2471
|
}
|
|
2236
2472
|
await this.fsync(i);
|
|
2237
2473
|
} catch (c) {
|
|
@@ -2249,18 +2485,18 @@ class Es extends gs {
|
|
|
2249
2485
|
}
|
|
2250
2486
|
async open(t, e) {
|
|
2251
2487
|
await this.mount();
|
|
2252
|
-
const { create:
|
|
2488
|
+
const { create: s = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = v(ht(t));
|
|
2253
2489
|
try {
|
|
2254
|
-
return
|
|
2490
|
+
return s && r ? await this.withPathLock(o, async () => {
|
|
2255
2491
|
if (await this.exists(o))
|
|
2256
|
-
throw new
|
|
2257
|
-
return this._openFile(o,
|
|
2258
|
-
}) : await this._openFile(o,
|
|
2492
|
+
throw new st(o);
|
|
2493
|
+
return this._openFile(o, s, i);
|
|
2494
|
+
}) : await this._openFile(o, s, i);
|
|
2259
2495
|
} catch (a) {
|
|
2260
|
-
if (a instanceof
|
|
2496
|
+
if (a instanceof y)
|
|
2261
2497
|
throw a;
|
|
2262
2498
|
const c = a && a.name === "TypeMismatchError";
|
|
2263
|
-
throw
|
|
2499
|
+
throw A(a, {
|
|
2264
2500
|
path: o,
|
|
2265
2501
|
isDirectory: !!c
|
|
2266
2502
|
});
|
|
@@ -2273,19 +2509,19 @@ class Es extends gs {
|
|
|
2273
2509
|
* with independent per-FD positions — similar to Node.js.
|
|
2274
2510
|
* @private
|
|
2275
2511
|
*/
|
|
2276
|
-
async _openFile(t, e,
|
|
2512
|
+
async _openFile(t, e, s) {
|
|
2277
2513
|
let r = this.openHandles.get(t);
|
|
2278
2514
|
if (!r) {
|
|
2279
2515
|
const o = await this.getFileHandle(t, e);
|
|
2280
2516
|
try {
|
|
2281
2517
|
await o.getFile();
|
|
2282
2518
|
} catch (c) {
|
|
2283
|
-
throw
|
|
2519
|
+
throw A(c, { path: t, isDirectory: !0 });
|
|
2284
2520
|
}
|
|
2285
|
-
const a = await
|
|
2521
|
+
const a = await Ds(o, t);
|
|
2286
2522
|
r = { fileHandle: o, syncHandle: a, refCount: 0 }, this.openHandles.set(t, r);
|
|
2287
2523
|
}
|
|
2288
|
-
r.refCount++,
|
|
2524
|
+
r.refCount++, s && (r.syncHandle.truncate(0), r.syncHandle.flush());
|
|
2289
2525
|
const i = this.nextFd++;
|
|
2290
2526
|
return this.openFiles.set(i, {
|
|
2291
2527
|
path: t,
|
|
@@ -2297,30 +2533,30 @@ class Es extends gs {
|
|
|
2297
2533
|
async close(t) {
|
|
2298
2534
|
const e = this._getFileDescriptor(t);
|
|
2299
2535
|
this.openFiles.delete(t);
|
|
2300
|
-
const
|
|
2301
|
-
|
|
2536
|
+
const s = this.openHandles.get(e.path);
|
|
2537
|
+
s && (s.refCount--, s.refCount <= 0 && (xt(t, s.syncHandle, e.path), this.openHandles.delete(e.path)));
|
|
2302
2538
|
}
|
|
2303
|
-
async read(t, e,
|
|
2539
|
+
async read(t, e, s, r, i) {
|
|
2304
2540
|
const o = this._getFileDescriptor(t);
|
|
2305
|
-
|
|
2541
|
+
bt(e.length, s, r, i);
|
|
2306
2542
|
try {
|
|
2307
|
-
const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF:
|
|
2308
|
-
if (
|
|
2309
|
-
return
|
|
2310
|
-
const
|
|
2311
|
-
return i == null && (o.position = a +
|
|
2543
|
+
const a = i ?? o.position, c = o.syncHandle.getSize(), { isEOF: l, actualLength: h } = Os(a, r, c);
|
|
2544
|
+
if (l)
|
|
2545
|
+
return z({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2546
|
+
const u = e.subarray(s, s + h), f = o.syncHandle.read(u, { at: a });
|
|
2547
|
+
return i == null && (o.position = a + f), z({ bytesRead: f, buffer: e }, [e.buffer]);
|
|
2312
2548
|
} catch (a) {
|
|
2313
|
-
throw
|
|
2549
|
+
throw I("read", t, o.path, a);
|
|
2314
2550
|
}
|
|
2315
2551
|
}
|
|
2316
|
-
async write(t, e,
|
|
2317
|
-
const a = this._getFileDescriptor(t), c = r ?? e.length -
|
|
2318
|
-
|
|
2552
|
+
async write(t, e, s = 0, r, i, o = !0) {
|
|
2553
|
+
const a = this._getFileDescriptor(t), c = r ?? e.length - s;
|
|
2554
|
+
bt(e.length, s, c, i);
|
|
2319
2555
|
try {
|
|
2320
|
-
const
|
|
2321
|
-
return (i == null || i === a.position) && (a.position =
|
|
2322
|
-
} catch (
|
|
2323
|
-
throw
|
|
2556
|
+
const l = i ?? a.position, h = e.subarray(s, s + c), u = a.syncHandle.write(h, { at: l });
|
|
2557
|
+
return (i == null || i === a.position) && (a.position = l + u), o && await this.notifyChange({ path: a.path, type: O.Changed, isDirectory: !1 }), u;
|
|
2558
|
+
} catch (l) {
|
|
2559
|
+
throw I("write", t, a.path, l);
|
|
2324
2560
|
}
|
|
2325
2561
|
}
|
|
2326
2562
|
async fstat(t) {
|
|
@@ -2328,28 +2564,32 @@ class Es extends gs {
|
|
|
2328
2564
|
return this.stat(e.path);
|
|
2329
2565
|
}
|
|
2330
2566
|
async ftruncate(t, e = 0) {
|
|
2331
|
-
const
|
|
2567
|
+
const s = this._getFileDescriptor(t);
|
|
2332
2568
|
if (e < 0 || !Number.isInteger(e))
|
|
2333
|
-
throw new
|
|
2569
|
+
throw new $("argument", "Invalid size");
|
|
2334
2570
|
try {
|
|
2335
|
-
|
|
2571
|
+
s.syncHandle.truncate(e), s.syncHandle.flush(), s.position > e && (s.position = e), await this.notifyChange({ path: s.path, type: O.Changed, isDirectory: !1 });
|
|
2336
2572
|
} catch (r) {
|
|
2337
|
-
throw
|
|
2573
|
+
throw I("truncate", t, s.path, r);
|
|
2338
2574
|
}
|
|
2339
2575
|
}
|
|
2340
2576
|
async fsync(t) {
|
|
2341
2577
|
const e = this._getFileDescriptor(t);
|
|
2342
2578
|
try {
|
|
2343
2579
|
e.syncHandle.flush();
|
|
2344
|
-
} catch (
|
|
2345
|
-
throw
|
|
2580
|
+
} catch (s) {
|
|
2581
|
+
throw I("sync", t, e.path, s);
|
|
2346
2582
|
}
|
|
2347
2583
|
}
|
|
2348
2584
|
dispose() {
|
|
2349
2585
|
for (const [t, e] of this.openHandles)
|
|
2350
|
-
|
|
2586
|
+
xt(-1, e.syncHandle, t);
|
|
2351
2587
|
this.openHandles.clear(), this.openFiles.clear(), this.nextFd = 1, super.dispose();
|
|
2352
2588
|
}
|
|
2353
2589
|
}
|
|
2354
|
-
|
|
2590
|
+
const jt = new Cs();
|
|
2591
|
+
U(jt);
|
|
2592
|
+
addEventListener("message", (n) => {
|
|
2593
|
+
n.data?.type === "opfs-connect" && n.data.port instanceof MessagePort && U(jt, n.data.port);
|
|
2594
|
+
});
|
|
2355
2595
|
//# sourceMappingURL=dedicated.worker.js.map
|