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