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