opfs-worker 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -6
- package/dist/assets/worker-CLvhwwfc.js.map +1 -0
- package/dist/facade.d.ts +141 -0
- package/dist/facade.d.ts.map +1 -0
- package/dist/{helpers-CTCvNFs1.js → helpers-CkNHswLp.js} +412 -373
- package/dist/helpers-CkNHswLp.js.map +1 -0
- package/dist/helpers-TAynP0fb.cjs +4 -0
- package/dist/helpers-TAynP0fb.cjs.map +1 -0
- package/dist/index.cjs +641 -474
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +886 -522
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.d.ts +13 -0
- package/dist/raw.d.ts.map +1 -0
- package/dist/raw.js +331 -59
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/encoder.d.ts +20 -2
- package/dist/utils/encoder.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +23 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +42 -40
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts +178 -31
- package/dist/worker.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/assets/worker-CccfxYdr.js.map +0 -1
- package/dist/helpers-CTCvNFs1.js.map +0 -1
- package/dist/helpers-Cvjm0f_r.cjs +0 -4
- package/dist/helpers-Cvjm0f_r.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { wrap as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { wrap as d } from "comlink";
|
|
2
|
+
import { i as h, d as c, e as a } from "./helpers-CkNHswLp.js";
|
|
3
|
+
import { E, D as x, F as S, O as F, b as P, a as O, P as A, c as T, S as I, T as $, h as R, v as C, u as _, B as N, g as D, x as k, t as M, f as L, C as j, k as W, q as z, p as U, j as H, m as B, o as G, l as q, n as V, y as Y, r as X, A as Z, s as J, z as K, w as Q } from "./helpers-CkNHswLp.js";
|
|
4
|
+
const p = `/**
|
|
4
5
|
* @license
|
|
5
6
|
* Copyright 2019 Google LLC
|
|
6
7
|
* SPDX-License-Identifier: Apache-2.0
|
|
7
8
|
*/
|
|
8
|
-
const
|
|
9
|
-
canHandle: (s) =>
|
|
9
|
+
const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), z = Symbol("Comlink.thrown"), gt = (s) => typeof s == "object" && s !== null || typeof s == "function", Mt = {
|
|
10
|
+
canHandle: (s) => gt(s) && s[pt],
|
|
10
11
|
serialize(s) {
|
|
11
12
|
const { port1: t, port2: e } = new MessageChannel();
|
|
12
|
-
return
|
|
13
|
+
return K(s, t), [e, [e]];
|
|
13
14
|
},
|
|
14
15
|
deserialize(s) {
|
|
15
|
-
return s.start(),
|
|
16
|
+
return s.start(), Rt(s);
|
|
16
17
|
}
|
|
17
|
-
},
|
|
18
|
-
canHandle: (s) =>
|
|
18
|
+
}, Pt = {
|
|
19
|
+
canHandle: (s) => gt(s) && z in s,
|
|
19
20
|
serialize({ value: s }) {
|
|
20
21
|
let t;
|
|
21
22
|
return s instanceof Error ? t = {
|
|
@@ -30,25 +31,25 @@ const ut = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Nt = Symbol
|
|
|
30
31
|
deserialize(s) {
|
|
31
32
|
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
32
33
|
}
|
|
33
|
-
},
|
|
34
|
-
["proxy",
|
|
35
|
-
["throw",
|
|
34
|
+
}, wt = /* @__PURE__ */ new Map([
|
|
35
|
+
["proxy", Mt],
|
|
36
|
+
["throw", Pt]
|
|
36
37
|
]);
|
|
37
|
-
function
|
|
38
|
+
function It(s, t) {
|
|
38
39
|
for (const e of s)
|
|
39
40
|
if (t === e || e === "*" || e instanceof RegExp && e.test(t))
|
|
40
41
|
return !0;
|
|
41
42
|
return !1;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function K(s, t = globalThis, e = ["*"]) {
|
|
44
45
|
t.addEventListener("message", function n(i) {
|
|
45
46
|
if (!i || !i.data)
|
|
46
47
|
return;
|
|
47
|
-
if (!
|
|
48
|
+
if (!It(e, i.origin)) {
|
|
48
49
|
console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(
|
|
52
|
+
const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(F);
|
|
52
53
|
let h;
|
|
53
54
|
try {
|
|
54
55
|
const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
|
|
@@ -57,7 +58,7 @@ function J(s, t = globalThis, e = ["*"]) {
|
|
|
57
58
|
h = f;
|
|
58
59
|
break;
|
|
59
60
|
case "SET":
|
|
60
|
-
c[a.slice(-1)[0]] =
|
|
61
|
+
c[a.slice(-1)[0]] = F(i.data.value), h = !0;
|
|
61
62
|
break;
|
|
62
63
|
case "APPLY":
|
|
63
64
|
h = f.apply(c, l);
|
|
@@ -65,13 +66,13 @@ function J(s, t = globalThis, e = ["*"]) {
|
|
|
65
66
|
case "CONSTRUCT":
|
|
66
67
|
{
|
|
67
68
|
const u = new f(...l);
|
|
68
|
-
h =
|
|
69
|
+
h = Wt(u);
|
|
69
70
|
}
|
|
70
71
|
break;
|
|
71
72
|
case "ENDPOINT":
|
|
72
73
|
{
|
|
73
74
|
const { port1: u, port2: d } = new MessageChannel();
|
|
74
|
-
|
|
75
|
+
K(s, d), h = H(u, [u]);
|
|
75
76
|
}
|
|
76
77
|
break;
|
|
77
78
|
case "RELEASE":
|
|
@@ -81,27 +82,27 @@ function J(s, t = globalThis, e = ["*"]) {
|
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
} catch (c) {
|
|
84
|
-
h = { value: c, [
|
|
85
|
+
h = { value: c, [z]: 0 };
|
|
85
86
|
}
|
|
86
|
-
Promise.resolve(h).catch((c) => ({ value: c, [
|
|
87
|
-
const [f, u] =
|
|
88
|
-
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n),
|
|
87
|
+
Promise.resolve(h).catch((c) => ({ value: c, [z]: 0 })).then((c) => {
|
|
88
|
+
const [f, u] = B(c);
|
|
89
|
+
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), yt(t), q in s && typeof s[q] == "function" && s[q]());
|
|
89
90
|
}).catch((c) => {
|
|
90
|
-
const [f, u] =
|
|
91
|
+
const [f, u] = B({
|
|
91
92
|
value: new TypeError("Unserializable return value"),
|
|
92
|
-
[
|
|
93
|
+
[z]: 0
|
|
93
94
|
});
|
|
94
95
|
t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
|
|
95
96
|
});
|
|
96
97
|
}), t.start && t.start();
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
+
function kt(s) {
|
|
99
100
|
return s.constructor.name === "MessagePort";
|
|
100
101
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
102
|
+
function yt(s) {
|
|
103
|
+
kt(s) && s.close();
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
+
function Rt(s, t) {
|
|
105
106
|
const e = /* @__PURE__ */ new Map();
|
|
106
107
|
return s.addEventListener("message", function(i) {
|
|
107
108
|
const { data: r } = i;
|
|
@@ -114,103 +115,103 @@ function Pt(s, t) {
|
|
|
114
115
|
} finally {
|
|
115
116
|
e.delete(r.id);
|
|
116
117
|
}
|
|
117
|
-
}),
|
|
118
|
+
}), Z(s, e, [], t);
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
+
function k(s) {
|
|
120
121
|
if (s)
|
|
121
122
|
throw new Error("Proxy has been released and is not useable");
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
-
return
|
|
124
|
+
function mt(s) {
|
|
125
|
+
return N(s, /* @__PURE__ */ new Map(), {
|
|
125
126
|
type: "RELEASE"
|
|
126
127
|
}).then(() => {
|
|
127
|
-
|
|
128
|
+
yt(s);
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
|
-
const
|
|
131
|
-
const t = (
|
|
132
|
-
|
|
131
|
+
const _ = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
132
|
+
const t = (_.get(s) || 0) - 1;
|
|
133
|
+
_.set(s, t), t === 0 && mt(s);
|
|
133
134
|
});
|
|
134
|
-
function
|
|
135
|
-
const e = (
|
|
136
|
-
|
|
135
|
+
function Lt(s, t) {
|
|
136
|
+
const e = (_.get(t) || 0) + 1;
|
|
137
|
+
_.set(t, e), j && j.register(s, t, s);
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
139
|
+
function zt(s) {
|
|
140
|
+
j && j.unregister(s);
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function Z(s, t, e = [], n = function() {
|
|
142
143
|
}) {
|
|
143
144
|
let i = !1;
|
|
144
145
|
const r = new Proxy(n, {
|
|
145
146
|
get(o, a) {
|
|
146
|
-
if (
|
|
147
|
+
if (k(i), a === Tt)
|
|
147
148
|
return () => {
|
|
148
|
-
|
|
149
|
+
zt(r), mt(s), t.clear(), i = !0;
|
|
149
150
|
};
|
|
150
151
|
if (a === "then") {
|
|
151
152
|
if (e.length === 0)
|
|
152
153
|
return { then: () => r };
|
|
153
|
-
const l =
|
|
154
|
+
const l = N(s, t, {
|
|
154
155
|
type: "GET",
|
|
155
156
|
path: e.map((h) => h.toString())
|
|
156
|
-
}).then(
|
|
157
|
+
}).then(F);
|
|
157
158
|
return l.then.bind(l);
|
|
158
159
|
}
|
|
159
|
-
return
|
|
160
|
+
return Z(s, t, [...e, a]);
|
|
160
161
|
},
|
|
161
162
|
set(o, a, l) {
|
|
162
|
-
|
|
163
|
-
const [h, c] =
|
|
164
|
-
return
|
|
163
|
+
k(i);
|
|
164
|
+
const [h, c] = B(l);
|
|
165
|
+
return N(s, t, {
|
|
165
166
|
type: "SET",
|
|
166
167
|
path: [...e, a].map((f) => f.toString()),
|
|
167
168
|
value: h
|
|
168
|
-
}, c).then(
|
|
169
|
+
}, c).then(F);
|
|
169
170
|
},
|
|
170
171
|
apply(o, a, l) {
|
|
171
|
-
|
|
172
|
+
k(i);
|
|
172
173
|
const h = e[e.length - 1];
|
|
173
|
-
if (h ===
|
|
174
|
-
return
|
|
174
|
+
if (h === Ct)
|
|
175
|
+
return N(s, t, {
|
|
175
176
|
type: "ENDPOINT"
|
|
176
|
-
}).then(
|
|
177
|
+
}).then(F);
|
|
177
178
|
if (h === "bind")
|
|
178
|
-
return
|
|
179
|
+
return Z(s, t, e.slice(0, -1));
|
|
179
180
|
const [c, f] = st(l);
|
|
180
|
-
return
|
|
181
|
+
return N(s, t, {
|
|
181
182
|
type: "APPLY",
|
|
182
183
|
path: e.map((u) => u.toString()),
|
|
183
184
|
argumentList: c
|
|
184
|
-
}, f).then(
|
|
185
|
+
}, f).then(F);
|
|
185
186
|
},
|
|
186
187
|
construct(o, a) {
|
|
187
|
-
|
|
188
|
+
k(i);
|
|
188
189
|
const [l, h] = st(a);
|
|
189
|
-
return
|
|
190
|
+
return N(s, t, {
|
|
190
191
|
type: "CONSTRUCT",
|
|
191
192
|
path: e.map((c) => c.toString()),
|
|
192
193
|
argumentList: l
|
|
193
|
-
}, h).then(
|
|
194
|
+
}, h).then(F);
|
|
194
195
|
}
|
|
195
196
|
});
|
|
196
|
-
return
|
|
197
|
+
return Lt(r, s), r;
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
+
function Ht(s) {
|
|
199
200
|
return Array.prototype.concat.apply([], s);
|
|
200
201
|
}
|
|
201
202
|
function st(s) {
|
|
202
|
-
const t = s.map(
|
|
203
|
-
return [t.map((e) => e[0]),
|
|
203
|
+
const t = s.map(B);
|
|
204
|
+
return [t.map((e) => e[0]), Ht(t.map((e) => e[1]))];
|
|
204
205
|
}
|
|
205
|
-
const
|
|
206
|
-
function
|
|
207
|
-
return
|
|
206
|
+
const Et = /* @__PURE__ */ new WeakMap();
|
|
207
|
+
function H(s, t) {
|
|
208
|
+
return Et.set(s, t), s;
|
|
208
209
|
}
|
|
209
|
-
function
|
|
210
|
-
return Object.assign(s, { [
|
|
210
|
+
function Wt(s) {
|
|
211
|
+
return Object.assign(s, { [pt]: !0 });
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
-
for (const [t, e] of
|
|
213
|
+
function B(s) {
|
|
214
|
+
for (const [t, e] of wt)
|
|
214
215
|
if (e.canHandle(s)) {
|
|
215
216
|
const [n, i] = e.serialize(s);
|
|
216
217
|
return [
|
|
@@ -227,120 +228,78 @@ function H(s) {
|
|
|
227
228
|
type: "RAW",
|
|
228
229
|
value: s
|
|
229
230
|
},
|
|
230
|
-
|
|
231
|
+
Et.get(s) || []
|
|
231
232
|
];
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
+
function F(s) {
|
|
234
235
|
switch (s.type) {
|
|
235
236
|
case "HANDLER":
|
|
236
|
-
return
|
|
237
|
+
return wt.get(s.name).deserialize(s.value);
|
|
237
238
|
case "RAW":
|
|
238
239
|
return s.value;
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function N(s, t, e, n) {
|
|
242
243
|
return new Promise((i) => {
|
|
243
|
-
const r =
|
|
244
|
+
const r = _t();
|
|
244
245
|
t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
+
function _t() {
|
|
248
249
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
249
250
|
}
|
|
250
|
-
class
|
|
251
|
+
class p extends Error {
|
|
251
252
|
constructor(t, e, n, i) {
|
|
252
253
|
super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
|
-
class
|
|
256
|
+
class jt extends p {
|
|
256
257
|
constructor(t) {
|
|
257
258
|
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
|
-
class
|
|
261
|
+
class Bt extends p {
|
|
261
262
|
constructor(t, e, n) {
|
|
262
263
|
super(t, "INVALID_PATH", e, n);
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
|
-
class
|
|
266
|
+
class nt extends p {
|
|
266
267
|
constructor(t, e) {
|
|
267
268
|
super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
function
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
case "utf-8":
|
|
274
|
-
return new TextEncoder().encode(s);
|
|
275
|
-
case "utf16le":
|
|
276
|
-
case "ucs2":
|
|
277
|
-
case "ucs-2":
|
|
278
|
-
return Bt(s);
|
|
279
|
-
case "ascii":
|
|
280
|
-
return Vt(s);
|
|
281
|
-
case "latin1":
|
|
282
|
-
return qt(s);
|
|
283
|
-
case "binary":
|
|
284
|
-
return Uint8Array.from(s, (e) => e.charCodeAt(0));
|
|
285
|
-
case "base64":
|
|
286
|
-
return Uint8Array.from(atob(s), (e) => e.charCodeAt(0));
|
|
287
|
-
case "hex":
|
|
288
|
-
if (!/^[\\da-f]+$/i.test(s) || s.length % 2 !== 0)
|
|
289
|
-
throw new g("Invalid hex string", "INVALID_HEX_FORMAT");
|
|
290
|
-
return Uint8Array.from(s.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
|
|
291
|
-
default:
|
|
292
|
-
return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
|
|
293
|
-
}
|
|
271
|
+
function R(s, t, e, n) {
|
|
272
|
+
const i = \`\${s.toUpperCase()}_FAILED\`;
|
|
273
|
+
return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
|
|
294
274
|
}
|
|
295
|
-
function
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
case "
|
|
299
|
-
return new
|
|
300
|
-
case "
|
|
301
|
-
|
|
302
|
-
case "
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
case "
|
|
308
|
-
return
|
|
309
|
-
case "
|
|
310
|
-
return
|
|
311
|
-
case "
|
|
312
|
-
return
|
|
275
|
+
function Ut(s, t) {
|
|
276
|
+
const e = t?.path;
|
|
277
|
+
switch (s.name) {
|
|
278
|
+
case "InvalidStateError":
|
|
279
|
+
return new p(\`File is busy: \${e || "unknown"}\`, "EBUSY", e, s);
|
|
280
|
+
case "QuotaExceededError":
|
|
281
|
+
return new p(\`No space left on device: \${e || "unknown"}\`, "ENOSPC", e, s);
|
|
282
|
+
case "NotFoundError":
|
|
283
|
+
return new p(\`No such file or directory: \${e || "unknown"}\`, "ENOENT", e, s);
|
|
284
|
+
case "TypeMismatchError":
|
|
285
|
+
return new p(\`Is a directory: \${e || "unknown"}\`, "EISDIR", e, s);
|
|
286
|
+
case "NotAllowedError":
|
|
287
|
+
case "SecurityError":
|
|
288
|
+
return new p(\`Permission denied: \${e || "unknown"}\`, "EACCES", e, s);
|
|
289
|
+
case "InvalidModificationError":
|
|
290
|
+
return new p(\`Invalid modification: \${e || "unknown"}\`, "EINVAL", e, s);
|
|
291
|
+
case "AbortError":
|
|
292
|
+
return new p(\`Operation aborted: \${e || "unknown"}\`, "EINTR", e, s);
|
|
293
|
+
case "OperationError":
|
|
294
|
+
return new p(\`Operation failed: \${e || "unknown"}\`, "EIO", e, s);
|
|
295
|
+
case "TypeError":
|
|
296
|
+
return new p(\`Operation not supported: \${e || "unknown"}\`, "ENOTSUP", e, s);
|
|
313
297
|
default:
|
|
314
|
-
return
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
function Bt(s) {
|
|
318
|
-
const t = new Uint8Array(s.length * 2);
|
|
319
|
-
for (let e = 0; e < s.length; e++) {
|
|
320
|
-
const n = s.charCodeAt(e);
|
|
321
|
-
t[e * 2] = n & 255, t[e * 2 + 1] = n >> 8;
|
|
298
|
+
return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
|
|
322
299
|
}
|
|
323
|
-
return t;
|
|
324
300
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
|
|
328
|
-
return String.fromCharCode(...t);
|
|
329
|
-
}
|
|
330
|
-
function qt(s) {
|
|
331
|
-
const t = new Uint8Array(s.length);
|
|
332
|
-
for (let e = 0; e < s.length; e++)
|
|
333
|
-
t[e] = s.charCodeAt(e) & 255;
|
|
334
|
-
return t;
|
|
335
|
-
}
|
|
336
|
-
function Vt(s) {
|
|
337
|
-
const t = new Uint8Array(s.length);
|
|
338
|
-
for (let e = 0; e < s.length; e++)
|
|
339
|
-
t[e] = s.charCodeAt(e) & 127;
|
|
340
|
-
return t;
|
|
341
|
-
}
|
|
342
|
-
const wt = (s, t, e) => {
|
|
343
|
-
const n = s instanceof RegExp ? nt(s, e) : s, i = t instanceof RegExp ? nt(t, e) : t, r = n !== null && i != null && Xt(n, i, e);
|
|
301
|
+
const St = (s, t, e) => {
|
|
302
|
+
const n = s instanceof RegExp ? it(s, e) : s, i = t instanceof RegExp ? it(t, e) : t, r = n !== null && i != null && Gt(n, i, e);
|
|
344
303
|
return r && {
|
|
345
304
|
start: r[0],
|
|
346
305
|
end: r[1],
|
|
@@ -348,10 +307,10 @@ const wt = (s, t, e) => {
|
|
|
348
307
|
body: e.slice(r[0] + n.length, r[1]),
|
|
349
308
|
post: e.slice(r[1] + i.length)
|
|
350
309
|
};
|
|
351
|
-
},
|
|
310
|
+
}, it = (s, t) => {
|
|
352
311
|
const e = t.match(s);
|
|
353
312
|
return e ? e[0] : null;
|
|
354
|
-
},
|
|
313
|
+
}, Gt = (s, t, e) => {
|
|
355
314
|
let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
|
|
356
315
|
if (l >= 0 && h > 0) {
|
|
357
316
|
if (s === t)
|
|
@@ -369,47 +328,47 @@ const wt = (s, t, e) => {
|
|
|
369
328
|
n.length && o !== void 0 && (a = [r, o]);
|
|
370
329
|
}
|
|
371
330
|
return a;
|
|
372
|
-
},
|
|
373
|
-
function
|
|
331
|
+
}, xt = "\\0SLASH" + Math.random() + "\\0", bt = "\\0OPEN" + Math.random() + "\\0", Q = "\\0CLOSE" + Math.random() + "\\0", vt = "\\0COMMA" + Math.random() + "\\0", At = "\\0PERIOD" + Math.random() + "\\0", qt = new RegExp(xt, "g"), Vt = new RegExp(bt, "g"), Xt = new RegExp(Q, "g"), Yt = new RegExp(vt, "g"), Zt = new RegExp(At, "g"), Jt = /\\\\\\\\/g, Kt = /\\\\{/g, Qt = /\\\\}/g, te = /\\\\,/g, ee = /\\\\./g;
|
|
332
|
+
function V(s) {
|
|
374
333
|
return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
|
|
375
334
|
}
|
|
376
|
-
function
|
|
377
|
-
return s.replace(
|
|
335
|
+
function se(s) {
|
|
336
|
+
return s.replace(Jt, xt).replace(Kt, bt).replace(Qt, Q).replace(te, vt).replace(ee, At);
|
|
378
337
|
}
|
|
379
|
-
function
|
|
380
|
-
return s.replace(
|
|
338
|
+
function ne(s) {
|
|
339
|
+
return s.replace(qt, "\\\\").replace(Vt, "{").replace(Xt, "}").replace(Yt, ",").replace(Zt, ".");
|
|
381
340
|
}
|
|
382
|
-
function
|
|
341
|
+
function Ft(s) {
|
|
383
342
|
if (!s)
|
|
384
343
|
return [""];
|
|
385
|
-
const t = [], e =
|
|
344
|
+
const t = [], e = St("{", "}", s);
|
|
386
345
|
if (!e)
|
|
387
346
|
return s.split(",");
|
|
388
347
|
const { pre: n, body: i, post: r } = e, o = n.split(",");
|
|
389
348
|
o[o.length - 1] += "{" + i + "}";
|
|
390
|
-
const a =
|
|
349
|
+
const a = Ft(r);
|
|
391
350
|
return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
|
|
392
351
|
}
|
|
393
|
-
function
|
|
394
|
-
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)),
|
|
352
|
+
function ie(s) {
|
|
353
|
+
return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), T(se(s), !0).map(ne)) : [];
|
|
395
354
|
}
|
|
396
|
-
function
|
|
355
|
+
function re(s) {
|
|
397
356
|
return "{" + s + "}";
|
|
398
357
|
}
|
|
399
|
-
function
|
|
358
|
+
function oe(s) {
|
|
400
359
|
return /^-?0\\d/.test(s);
|
|
401
360
|
}
|
|
402
|
-
function
|
|
361
|
+
function ae(s, t) {
|
|
403
362
|
return s <= t;
|
|
404
363
|
}
|
|
405
|
-
function
|
|
364
|
+
function ce(s, t) {
|
|
406
365
|
return s >= t;
|
|
407
366
|
}
|
|
408
|
-
function
|
|
409
|
-
const e = [], n =
|
|
367
|
+
function T(s, t) {
|
|
368
|
+
const e = [], n = St("{", "}", s);
|
|
410
369
|
if (!n)
|
|
411
370
|
return [s];
|
|
412
|
-
const i = n.pre, r = n.post.length ?
|
|
371
|
+
const i = n.pre, r = n.post.length ? T(n.post, !1) : [""];
|
|
413
372
|
if (/\\$$/.test(n.pre))
|
|
414
373
|
for (let o = 0; o < r.length; o++) {
|
|
415
374
|
const a = i + "{" + n.body + "}" + r[o];
|
|
@@ -418,51 +377,51 @@ function M(s, t) {
|
|
|
418
377
|
else {
|
|
419
378
|
const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
|
|
420
379
|
if (!l && !h)
|
|
421
|
-
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body +
|
|
380
|
+
return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + Q + n.post, T(s)) : [s];
|
|
422
381
|
let c;
|
|
423
382
|
if (l)
|
|
424
383
|
c = n.body.split(/\\.\\./);
|
|
425
|
-
else if (c =
|
|
384
|
+
else if (c = Ft(n.body), c.length === 1 && c[0] !== void 0 && (c = T(c[0], !1).map(re), c.length === 1))
|
|
426
385
|
return r.map((u) => n.pre + c[0] + u);
|
|
427
386
|
let f;
|
|
428
387
|
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
429
|
-
const u =
|
|
430
|
-
let
|
|
431
|
-
d < u && (
|
|
432
|
-
const
|
|
388
|
+
const u = V(c[0]), d = V(c[1]), w = Math.max(c[0].length, c[1].length);
|
|
389
|
+
let g = c.length === 3 && c[2] !== void 0 ? Math.abs(V(c[2])) : 1, S = ae;
|
|
390
|
+
d < u && (g *= -1, S = ce);
|
|
391
|
+
const O = c.some(oe);
|
|
433
392
|
f = [];
|
|
434
|
-
for (let x = u; S(x, d); x +=
|
|
435
|
-
let
|
|
393
|
+
for (let x = u; S(x, d); x += g) {
|
|
394
|
+
let y;
|
|
436
395
|
if (a)
|
|
437
|
-
|
|
438
|
-
else if (
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
x < 0 ?
|
|
396
|
+
y = String.fromCharCode(x), y === "\\\\" && (y = "");
|
|
397
|
+
else if (y = String(x), O) {
|
|
398
|
+
const $ = w - y.length;
|
|
399
|
+
if ($ > 0) {
|
|
400
|
+
const I = new Array($ + 1).join("0");
|
|
401
|
+
x < 0 ? y = "-" + I + y.slice(1) : y = I + y;
|
|
443
402
|
}
|
|
444
403
|
}
|
|
445
|
-
f.push(
|
|
404
|
+
f.push(y);
|
|
446
405
|
}
|
|
447
406
|
} else {
|
|
448
407
|
f = [];
|
|
449
408
|
for (let u = 0; u < c.length; u++)
|
|
450
|
-
f.push.apply(f,
|
|
409
|
+
f.push.apply(f, T(c[u], !1));
|
|
451
410
|
}
|
|
452
411
|
for (let u = 0; u < f.length; u++)
|
|
453
412
|
for (let d = 0; d < r.length; d++) {
|
|
454
|
-
const
|
|
455
|
-
(!t || l ||
|
|
413
|
+
const w = i + f[u] + r[d];
|
|
414
|
+
(!t || l || w) && e.push(w);
|
|
456
415
|
}
|
|
457
416
|
}
|
|
458
417
|
return e;
|
|
459
418
|
}
|
|
460
|
-
const
|
|
419
|
+
const le = 1024 * 64, U = (s) => {
|
|
461
420
|
if (typeof s != "string")
|
|
462
421
|
throw new TypeError("invalid pattern");
|
|
463
|
-
if (s.length >
|
|
422
|
+
if (s.length > le)
|
|
464
423
|
throw new TypeError("pattern is too long");
|
|
465
|
-
},
|
|
424
|
+
}, he = {
|
|
466
425
|
"[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
|
|
467
426
|
"[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
|
|
468
427
|
"[:ascii:]": ["\\\\x00-\\\\x7f", !1],
|
|
@@ -477,60 +436,60 @@ const fe = 1024 * 64, W = (s) => {
|
|
|
477
436
|
"[:upper:]": ["\\\\p{Lu}", !0],
|
|
478
437
|
"[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
|
|
479
438
|
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
480
|
-
},
|
|
439
|
+
}, C = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ue = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), rt = (s) => s.join(""), fe = (s, t) => {
|
|
481
440
|
const e = t;
|
|
482
441
|
if (s.charAt(e) !== "[")
|
|
483
442
|
throw new Error("not in a brace expression");
|
|
484
443
|
const n = [], i = [];
|
|
485
444
|
let r = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
|
|
486
445
|
t: for (; r < s.length; ) {
|
|
487
|
-
const
|
|
488
|
-
if ((
|
|
446
|
+
const g = s.charAt(r);
|
|
447
|
+
if ((g === "!" || g === "^") && r === e + 1) {
|
|
489
448
|
h = !0, r++;
|
|
490
449
|
continue;
|
|
491
450
|
}
|
|
492
|
-
if (
|
|
451
|
+
if (g === "]" && o && !l) {
|
|
493
452
|
c = r + 1;
|
|
494
453
|
break;
|
|
495
454
|
}
|
|
496
|
-
if (o = !0,
|
|
455
|
+
if (o = !0, g === "\\\\" && !l) {
|
|
497
456
|
l = !0, r++;
|
|
498
457
|
continue;
|
|
499
458
|
}
|
|
500
|
-
if (
|
|
501
|
-
for (const [S, [A,
|
|
459
|
+
if (g === "[" && !l) {
|
|
460
|
+
for (const [S, [A, O, x]] of Object.entries(he))
|
|
502
461
|
if (s.startsWith(S, r)) {
|
|
503
462
|
if (f)
|
|
504
463
|
return ["$.", !1, s.length - e, !0];
|
|
505
|
-
r += S.length, x ? i.push(A) : n.push(A), a = a ||
|
|
464
|
+
r += S.length, x ? i.push(A) : n.push(A), a = a || O;
|
|
506
465
|
continue t;
|
|
507
466
|
}
|
|
508
467
|
}
|
|
509
468
|
if (l = !1, f) {
|
|
510
|
-
|
|
469
|
+
g > f ? n.push(C(f) + "-" + C(g)) : g === f && n.push(C(g)), f = "", r++;
|
|
511
470
|
continue;
|
|
512
471
|
}
|
|
513
472
|
if (s.startsWith("-]", r + 1)) {
|
|
514
|
-
n.push(
|
|
473
|
+
n.push(C(g + "-")), r += 2;
|
|
515
474
|
continue;
|
|
516
475
|
}
|
|
517
476
|
if (s.startsWith("-", r + 1)) {
|
|
518
|
-
f =
|
|
477
|
+
f = g, r += 2;
|
|
519
478
|
continue;
|
|
520
479
|
}
|
|
521
|
-
n.push(
|
|
480
|
+
n.push(C(g)), r++;
|
|
522
481
|
}
|
|
523
482
|
if (c < r)
|
|
524
483
|
return ["", !1, 0, !1];
|
|
525
484
|
if (!n.length && !i.length)
|
|
526
485
|
return ["$.", !1, s.length - e, !0];
|
|
527
486
|
if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
|
|
528
|
-
const
|
|
529
|
-
return [
|
|
487
|
+
const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
|
|
488
|
+
return [ue(g), !1, c - e, !1];
|
|
530
489
|
}
|
|
531
|
-
const u = "[" + (h ? "^" : "") +
|
|
490
|
+
const u = "[" + (h ? "^" : "") + rt(n) + "]", d = "[" + (h ? "" : "^") + rt(i) + "]";
|
|
532
491
|
return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
|
|
533
|
-
},
|
|
492
|
+
}, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), de = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), ot = (s) => de.has(s), pe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ge = /* @__PURE__ */ new Set(["[", "."]), we = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), me = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), tt = "[^/]", at = tt + "*?", ct = tt + "+?";
|
|
534
493
|
class E {
|
|
535
494
|
type;
|
|
536
495
|
#s;
|
|
@@ -633,29 +592,29 @@ class E {
|
|
|
633
592
|
static #h(t, e, n, i) {
|
|
634
593
|
let r = !1, o = !1, a = -1, l = !1;
|
|
635
594
|
if (e.type === null) {
|
|
636
|
-
let d = n,
|
|
595
|
+
let d = n, w = "";
|
|
637
596
|
for (; d < t.length; ) {
|
|
638
|
-
const
|
|
639
|
-
if (r ||
|
|
640
|
-
r = !r,
|
|
597
|
+
const g = t.charAt(d++);
|
|
598
|
+
if (r || g === "\\\\") {
|
|
599
|
+
r = !r, w += g;
|
|
641
600
|
continue;
|
|
642
601
|
}
|
|
643
602
|
if (o) {
|
|
644
|
-
d === a + 1 ? (
|
|
603
|
+
d === a + 1 ? (g === "^" || g === "!") && (l = !0) : g === "]" && !(d === a + 2 && l) && (o = !1), w += g;
|
|
645
604
|
continue;
|
|
646
|
-
} else if (
|
|
647
|
-
o = !0, a = d, l = !1,
|
|
605
|
+
} else if (g === "[") {
|
|
606
|
+
o = !0, a = d, l = !1, w += g;
|
|
648
607
|
continue;
|
|
649
608
|
}
|
|
650
|
-
if (!i.noext &&
|
|
651
|
-
e.push(
|
|
652
|
-
const S = new E(
|
|
609
|
+
if (!i.noext && ot(g) && t.charAt(d) === "(") {
|
|
610
|
+
e.push(w), w = "";
|
|
611
|
+
const S = new E(g, e);
|
|
653
612
|
d = E.#h(t, S, d, i), e.push(S);
|
|
654
613
|
continue;
|
|
655
614
|
}
|
|
656
|
-
|
|
615
|
+
w += g;
|
|
657
616
|
}
|
|
658
|
-
return e.push(
|
|
617
|
+
return e.push(w), d;
|
|
659
618
|
}
|
|
660
619
|
let h = n + 1, c = new E(null, e);
|
|
661
620
|
const f = [];
|
|
@@ -673,10 +632,10 @@ class E {
|
|
|
673
632
|
o = !0, a = h, l = !1, u += d;
|
|
674
633
|
continue;
|
|
675
634
|
}
|
|
676
|
-
if (
|
|
635
|
+
if (ot(d) && t.charAt(h) === "(") {
|
|
677
636
|
c.push(u), u = "";
|
|
678
|
-
const
|
|
679
|
-
c.push(
|
|
637
|
+
const w = new E(d, c);
|
|
638
|
+
c.push(w), h = E.#h(t, w, h, i);
|
|
680
639
|
continue;
|
|
681
640
|
}
|
|
682
641
|
if (d === "|") {
|
|
@@ -783,23 +742,23 @@ class E {
|
|
|
783
742
|
const e = t ?? !!this.#i.dot;
|
|
784
743
|
if (this.#s === this && this.#d(), !this.type) {
|
|
785
744
|
const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
|
|
786
|
-
const [
|
|
787
|
-
return this.#n = this.#n || S, this.#r = this.#r || A,
|
|
745
|
+
const [w, g, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
|
|
746
|
+
return this.#n = this.#n || S, this.#r = this.#r || A, w;
|
|
788
747
|
}).join("");
|
|
789
748
|
let c = "";
|
|
790
|
-
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 &&
|
|
791
|
-
const
|
|
749
|
+
if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && we.has(this.#t[0]))) {
|
|
750
|
+
const w = ge, g = (
|
|
792
751
|
// dots are allowed, and the pattern starts with [ or .
|
|
793
|
-
e &&
|
|
794
|
-
h.startsWith("\\\\.") &&
|
|
795
|
-
h.startsWith("\\\\.\\\\.") &&
|
|
796
|
-
), S = !e && !t &&
|
|
797
|
-
c =
|
|
752
|
+
e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
|
|
753
|
+
h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
|
|
754
|
+
h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
|
|
755
|
+
), S = !e && !t && w.has(h.charAt(0));
|
|
756
|
+
c = g ? pe : S ? L : "";
|
|
798
757
|
}
|
|
799
758
|
let f = "";
|
|
800
759
|
return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
|
|
801
760
|
c + h + f,
|
|
802
|
-
|
|
761
|
+
M(h),
|
|
803
762
|
this.#n = !!this.#n,
|
|
804
763
|
this.#r
|
|
805
764
|
];
|
|
@@ -808,23 +767,23 @@ class E {
|
|
|
808
767
|
let r = this.#f(e);
|
|
809
768
|
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
|
|
810
769
|
const l = this.toString();
|
|
811
|
-
return this.#t = [l], this.type = null, this.#n = void 0, [l,
|
|
770
|
+
return this.#t = [l], this.type = null, this.#n = void 0, [l, M(this.toString()), !1, !1];
|
|
812
771
|
}
|
|
813
|
-
let o = !n || t || e || !
|
|
772
|
+
let o = !n || t || e || !L ? "" : this.#f(!0);
|
|
814
773
|
o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
|
|
815
774
|
let a = "";
|
|
816
775
|
if (this.type === "!" && this.#u)
|
|
817
|
-
a = (this.isStart() && !e ?
|
|
776
|
+
a = (this.isStart() && !e ? L : "") + ct;
|
|
818
777
|
else {
|
|
819
778
|
const l = this.type === "!" ? (
|
|
820
779
|
// !() must match something,but !(x) can match ''
|
|
821
|
-
"))" + (this.isStart() && !e && !t ?
|
|
780
|
+
"))" + (this.isStart() && !e && !t ? L : "") + at + ")"
|
|
822
781
|
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
|
|
823
782
|
a = i + r + l;
|
|
824
783
|
}
|
|
825
784
|
return [
|
|
826
785
|
a,
|
|
827
|
-
|
|
786
|
+
M(r),
|
|
828
787
|
this.#n = !!this.#n,
|
|
829
788
|
this.#r
|
|
830
789
|
];
|
|
@@ -842,7 +801,7 @@ class E {
|
|
|
842
801
|
for (let a = 0; a < t.length; a++) {
|
|
843
802
|
const l = t.charAt(a);
|
|
844
803
|
if (i) {
|
|
845
|
-
i = !1, r += (
|
|
804
|
+
i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
|
|
846
805
|
continue;
|
|
847
806
|
}
|
|
848
807
|
if (l === "\\\\") {
|
|
@@ -850,56 +809,56 @@ class E {
|
|
|
850
809
|
continue;
|
|
851
810
|
}
|
|
852
811
|
if (l === "[") {
|
|
853
|
-
const [h, c, f, u] =
|
|
812
|
+
const [h, c, f, u] = fe(t, a);
|
|
854
813
|
if (f) {
|
|
855
814
|
r += h, o = o || c, a += f - 1, e = e || u;
|
|
856
815
|
continue;
|
|
857
816
|
}
|
|
858
817
|
}
|
|
859
818
|
if (l === "*") {
|
|
860
|
-
n && t === "*" ? r +=
|
|
819
|
+
n && t === "*" ? r += ct : r += at, e = !0;
|
|
861
820
|
continue;
|
|
862
821
|
}
|
|
863
822
|
if (l === "?") {
|
|
864
|
-
r +=
|
|
823
|
+
r += tt, e = !0;
|
|
865
824
|
continue;
|
|
866
825
|
}
|
|
867
|
-
r +=
|
|
826
|
+
r += me(l);
|
|
868
827
|
}
|
|
869
|
-
return [r,
|
|
828
|
+
return [r, M(t), !!e, o];
|
|
870
829
|
}
|
|
871
830
|
}
|
|
872
|
-
const
|
|
873
|
-
const e =
|
|
831
|
+
const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (s, t, e = {}) => (U(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new G(t, e).match(s)), Se = /^\\*+([^+@!?\\*\\[\\(]*)$/, xe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), be = (s) => (t) => t.endsWith(s), ve = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ae = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Fe = /^\\*+\\.\\*+$/, Ne = (s) => !s.startsWith(".") && s.includes("."), De = (s) => s !== "." && s !== ".." && s.includes("."), Oe = /^\\.\\*+$/, $e = (s) => s !== "." && s !== ".." && s.startsWith("."), Ce = /^\\*+$/, Te = (s) => s.length !== 0 && !s.startsWith("."), Me = (s) => s.length !== 0 && s !== "." && s !== "..", Pe = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ie = ([s, t = ""]) => {
|
|
832
|
+
const e = Nt([s]);
|
|
874
833
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
875
|
-
},
|
|
876
|
-
const e =
|
|
834
|
+
}, ke = ([s, t = ""]) => {
|
|
835
|
+
const e = Dt([s]);
|
|
877
836
|
return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
|
|
878
|
-
},
|
|
879
|
-
const e =
|
|
837
|
+
}, Re = ([s, t = ""]) => {
|
|
838
|
+
const e = Dt([s]);
|
|
880
839
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
881
|
-
},
|
|
882
|
-
const e =
|
|
840
|
+
}, Le = ([s, t = ""]) => {
|
|
841
|
+
const e = Nt([s]);
|
|
883
842
|
return t ? (n) => e(n) && n.endsWith(t) : e;
|
|
884
|
-
},
|
|
843
|
+
}, Nt = ([s]) => {
|
|
885
844
|
const t = s.length;
|
|
886
845
|
return (e) => e.length === t && !e.startsWith(".");
|
|
887
|
-
},
|
|
846
|
+
}, Dt = ([s]) => {
|
|
888
847
|
const t = s.length;
|
|
889
848
|
return (e) => e.length === t && e !== "." && e !== "..";
|
|
890
|
-
},
|
|
849
|
+
}, Ot = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", lt = {
|
|
891
850
|
win32: { sep: "\\\\" },
|
|
892
851
|
posix: { sep: "/" }
|
|
893
|
-
},
|
|
894
|
-
|
|
852
|
+
}, ze = Ot === "win32" ? lt.win32.sep : lt.posix.sep;
|
|
853
|
+
m.sep = ze;
|
|
895
854
|
const v = Symbol("globstar **");
|
|
896
|
-
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
const b = (s, t = {}) => Object.assign({}, s, t),
|
|
855
|
+
m.GLOBSTAR = v;
|
|
856
|
+
const He = "[^/]", We = He + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", je = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => m(e, s, t);
|
|
857
|
+
m.filter = Be;
|
|
858
|
+
const b = (s, t = {}) => Object.assign({}, s, t), Ue = (s) => {
|
|
900
859
|
if (!s || typeof s != "object" || !Object.keys(s).length)
|
|
901
|
-
return
|
|
902
|
-
const t =
|
|
860
|
+
return m;
|
|
861
|
+
const t = m;
|
|
903
862
|
return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
|
|
904
863
|
Minimatch: class extends t.Minimatch {
|
|
905
864
|
constructor(i, r = {}) {
|
|
@@ -930,18 +889,18 @@ const b = (s, t = {}) => Object.assign({}, s, t), Ve = (s) => {
|
|
|
930
889
|
GLOBSTAR: v
|
|
931
890
|
});
|
|
932
891
|
};
|
|
933
|
-
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
const
|
|
939
|
-
const n = new
|
|
892
|
+
m.defaults = Ue;
|
|
893
|
+
const $t = (s, t = {}) => (U(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ie(s));
|
|
894
|
+
m.braceExpand = $t;
|
|
895
|
+
const Ge = (s, t = {}) => new G(s, t).makeRe();
|
|
896
|
+
m.makeRe = Ge;
|
|
897
|
+
const qe = (s, t, e = {}) => {
|
|
898
|
+
const n = new G(t, e);
|
|
940
899
|
return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
|
|
941
900
|
};
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
class
|
|
901
|
+
m.match = qe;
|
|
902
|
+
const ht = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
|
|
903
|
+
class G {
|
|
945
904
|
options;
|
|
946
905
|
set;
|
|
947
906
|
pattern;
|
|
@@ -960,7 +919,7 @@ class j {
|
|
|
960
919
|
windowsNoMagicRoot;
|
|
961
920
|
regexp;
|
|
962
921
|
constructor(t, e = {}) {
|
|
963
|
-
|
|
922
|
+
U(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ot, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
964
923
|
}
|
|
965
924
|
hasMagic() {
|
|
966
925
|
if (this.options.magicalBraces && this.set.length > 1)
|
|
@@ -988,7 +947,7 @@ class j {
|
|
|
988
947
|
this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
|
|
989
948
|
let i = this.globParts.map((r, o, a) => {
|
|
990
949
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
991
|
-
const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !
|
|
950
|
+
const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ht.test(r[2])) && !ht.test(r[3]), h = /^[a-z]:/i.test(r[0]);
|
|
992
951
|
if (l)
|
|
993
952
|
return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
|
|
994
953
|
if (h)
|
|
@@ -1168,10 +1127,10 @@ class j {
|
|
|
1168
1127
|
matchOne(t, e, n = !1) {
|
|
1169
1128
|
const i = this.options;
|
|
1170
1129
|
if (this.isWindows) {
|
|
1171
|
-
const
|
|
1172
|
-
if (typeof x == "number" && typeof
|
|
1173
|
-
const [
|
|
1174
|
-
|
|
1130
|
+
const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), O = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, y = O ? 3 : A ? 0 : void 0;
|
|
1131
|
+
if (typeof x == "number" && typeof y == "number") {
|
|
1132
|
+
const [$, I] = [t[x], e[y]];
|
|
1133
|
+
$.toLowerCase() === I.toLowerCase() && (e[y] = $, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
|
|
1175
1134
|
}
|
|
1176
1135
|
}
|
|
1177
1136
|
const { optimizationLevel: r = 1 } = this.options;
|
|
@@ -1191,11 +1150,11 @@ class j {
|
|
|
1191
1150
|
return !0;
|
|
1192
1151
|
}
|
|
1193
1152
|
for (; u < l; ) {
|
|
1194
|
-
var
|
|
1153
|
+
var w = t[u];
|
|
1195
1154
|
if (this.debug(\`
|
|
1196
|
-
globstar while\`, t, u, e, d,
|
|
1197
|
-
return this.debug("globstar found match!", u, l,
|
|
1198
|
-
if (
|
|
1155
|
+
globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
|
|
1156
|
+
return this.debug("globstar found match!", u, l, w), !0;
|
|
1157
|
+
if (w === "." || w === ".." || !i.dot && w.charAt(0) === ".") {
|
|
1199
1158
|
this.debug("dot detected!", t, u, e, d);
|
|
1200
1159
|
break;
|
|
1201
1160
|
}
|
|
@@ -1204,8 +1163,8 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1204
1163
|
return !!(n && (this.debug(\`
|
|
1205
1164
|
>>> no match, partial?\`, t, u, e, d), u === l));
|
|
1206
1165
|
}
|
|
1207
|
-
let
|
|
1208
|
-
if (typeof c == "string" ? (
|
|
1166
|
+
let g;
|
|
1167
|
+
if (typeof c == "string" ? (g = f === c, this.debug("string match", c, f, g)) : (g = c.test(f), this.debug("pattern match", c, f, g)), !g)
|
|
1209
1168
|
return !1;
|
|
1210
1169
|
}
|
|
1211
1170
|
if (o === l && a === h)
|
|
@@ -1217,17 +1176,17 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1217
1176
|
throw new Error("wtf?");
|
|
1218
1177
|
}
|
|
1219
1178
|
braceExpand() {
|
|
1220
|
-
return
|
|
1179
|
+
return $t(this.pattern, this.options);
|
|
1221
1180
|
}
|
|
1222
1181
|
parse(t) {
|
|
1223
|
-
|
|
1182
|
+
U(t);
|
|
1224
1183
|
const e = this.options;
|
|
1225
1184
|
if (t === "**")
|
|
1226
1185
|
return v;
|
|
1227
1186
|
if (t === "")
|
|
1228
1187
|
return "";
|
|
1229
1188
|
let n, i = null;
|
|
1230
|
-
(n = t.match(
|
|
1189
|
+
(n = t.match(Ce)) ? i = e.dot ? Me : Te : (n = t.match(Se)) ? i = (e.nocase ? e.dot ? Ae : ve : e.dot ? be : xe)(n[1]) : (n = t.match(Pe)) ? i = (e.nocase ? e.dot ? ke : Ie : e.dot ? Re : Le)(n) : (n = t.match(Fe)) ? i = e.dot ? De : Ne : (n = t.match(Oe)) && (i = $e);
|
|
1231
1190
|
const r = E.fromGlob(t, this.options).toMMPattern();
|
|
1232
1191
|
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
1233
1192
|
}
|
|
@@ -1237,13 +1196,13 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1237
1196
|
const t = this.set;
|
|
1238
1197
|
if (!t.length)
|
|
1239
1198
|
return this.regexp = !1, this.regexp;
|
|
1240
|
-
const e = this.options, n = e.noglobstar ?
|
|
1199
|
+
const e = this.options, n = e.noglobstar ? We : e.dot ? _e : je, i = new Set(e.nocase ? ["i"] : []);
|
|
1241
1200
|
let r = t.map((l) => {
|
|
1242
1201
|
const h = l.map((c) => {
|
|
1243
1202
|
if (c instanceof RegExp)
|
|
1244
1203
|
for (const f of c.flags.split(""))
|
|
1245
1204
|
i.add(f);
|
|
1246
|
-
return typeof c == "string" ?
|
|
1205
|
+
return typeof c == "string" ? Ve(c) : c === v ? v : c._src;
|
|
1247
1206
|
});
|
|
1248
1207
|
return h.forEach((c, f) => {
|
|
1249
1208
|
const u = h[f + 1], d = h[f - 1];
|
|
@@ -1288,82 +1247,19 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
|
|
|
1288
1247
|
return n.flipNegate ? !1 : this.negate;
|
|
1289
1248
|
}
|
|
1290
1249
|
static defaults(t) {
|
|
1291
|
-
return
|
|
1250
|
+
return m.defaults(t).Minimatch;
|
|
1292
1251
|
}
|
|
1293
1252
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
// Images
|
|
1300
|
-
".jpg",
|
|
1301
|
-
".jpeg",
|
|
1302
|
-
".png",
|
|
1303
|
-
".gif",
|
|
1304
|
-
".bmp",
|
|
1305
|
-
".webp",
|
|
1306
|
-
".svg",
|
|
1307
|
-
".ico",
|
|
1308
|
-
".tiff",
|
|
1309
|
-
".tga",
|
|
1310
|
-
// Audio
|
|
1311
|
-
".mp3",
|
|
1312
|
-
".wav",
|
|
1313
|
-
".ogg",
|
|
1314
|
-
".flac",
|
|
1315
|
-
".aac",
|
|
1316
|
-
".wma",
|
|
1317
|
-
".m4a",
|
|
1318
|
-
// Video
|
|
1319
|
-
".mp4",
|
|
1320
|
-
".avi",
|
|
1321
|
-
".mov",
|
|
1322
|
-
".wmv",
|
|
1323
|
-
".flv",
|
|
1324
|
-
".webm",
|
|
1325
|
-
".mkv",
|
|
1326
|
-
".m4v",
|
|
1327
|
-
// Documents
|
|
1328
|
-
".pdf",
|
|
1329
|
-
".doc",
|
|
1330
|
-
".docx",
|
|
1331
|
-
".xls",
|
|
1332
|
-
".xlsx",
|
|
1333
|
-
".ppt",
|
|
1334
|
-
".pptx",
|
|
1335
|
-
// Archives
|
|
1336
|
-
".zip",
|
|
1337
|
-
".rar",
|
|
1338
|
-
".7z",
|
|
1339
|
-
".tar",
|
|
1340
|
-
".gz",
|
|
1341
|
-
".bz2",
|
|
1342
|
-
// Executables
|
|
1343
|
-
".exe",
|
|
1344
|
-
".dll",
|
|
1345
|
-
".so",
|
|
1346
|
-
".dylib",
|
|
1347
|
-
".bin",
|
|
1348
|
-
// Other binary formats
|
|
1349
|
-
".dat",
|
|
1350
|
-
".db",
|
|
1351
|
-
".sqlite",
|
|
1352
|
-
".bin",
|
|
1353
|
-
".obj",
|
|
1354
|
-
".fbx",
|
|
1355
|
-
".3ds"
|
|
1356
|
-
];
|
|
1357
|
-
function G(s) {
|
|
1358
|
-
const t = s.toLowerCase().substring(s.lastIndexOf("."));
|
|
1359
|
-
return Je.includes(t);
|
|
1360
|
-
}
|
|
1361
|
-
function Ke() {
|
|
1253
|
+
m.AST = E;
|
|
1254
|
+
m.Minimatch = G;
|
|
1255
|
+
m.escape = Ee;
|
|
1256
|
+
m.unescape = M;
|
|
1257
|
+
function Xe() {
|
|
1362
1258
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
1363
|
-
throw new
|
|
1259
|
+
throw new jt();
|
|
1364
1260
|
}
|
|
1365
|
-
async function
|
|
1366
|
-
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")
|
|
1261
|
+
async function P(s, t, e) {
|
|
1262
|
+
return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
|
|
1367
1263
|
}
|
|
1368
1264
|
function D(s) {
|
|
1369
1265
|
return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
|
|
@@ -1371,28 +1267,28 @@ function D(s) {
|
|
|
1371
1267
|
function et(s) {
|
|
1372
1268
|
return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
|
|
1373
1269
|
}
|
|
1374
|
-
function
|
|
1270
|
+
function J(s) {
|
|
1375
1271
|
const t = D(s);
|
|
1376
1272
|
return t[t.length - 1] || "";
|
|
1377
1273
|
}
|
|
1378
|
-
function
|
|
1274
|
+
function X(s) {
|
|
1379
1275
|
const t = D(s);
|
|
1380
1276
|
return t.pop(), et(t);
|
|
1381
1277
|
}
|
|
1382
|
-
function
|
|
1278
|
+
function W(s) {
|
|
1383
1279
|
return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
|
|
1384
1280
|
}
|
|
1385
|
-
function
|
|
1281
|
+
function Ye(s, t = !1) {
|
|
1386
1282
|
return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
|
|
1387
1283
|
}
|
|
1388
|
-
function
|
|
1389
|
-
return
|
|
1284
|
+
function Y(s, t) {
|
|
1285
|
+
return m(s, t, {
|
|
1390
1286
|
dot: !0,
|
|
1391
1287
|
matchBase: !0
|
|
1392
1288
|
});
|
|
1393
1289
|
}
|
|
1394
|
-
function
|
|
1395
|
-
const t =
|
|
1290
|
+
function ut(s) {
|
|
1291
|
+
const t = W(s), e = D(t), n = [];
|
|
1396
1292
|
for (const i of e)
|
|
1397
1293
|
if (!(i === "." || i === ""))
|
|
1398
1294
|
if (i === "..") {
|
|
@@ -1403,49 +1299,19 @@ function ts(s) {
|
|
|
1403
1299
|
n.push(i);
|
|
1404
1300
|
return et(n);
|
|
1405
1301
|
}
|
|
1406
|
-
function
|
|
1407
|
-
return typeof s == "string" ? Ut(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
|
|
1408
|
-
}
|
|
1409
|
-
async function ss(s, t) {
|
|
1410
|
-
return tt(t, "shared", async () => {
|
|
1411
|
-
const n = await (await s.getFile()).arrayBuffer();
|
|
1412
|
-
return new Uint8Array(n);
|
|
1413
|
-
});
|
|
1414
|
-
}
|
|
1415
|
-
async function ht(s, t, e, n, i = {}) {
|
|
1416
|
-
const r = async () => {
|
|
1417
|
-
let o = null;
|
|
1418
|
-
const a = i.append || !1, l = !a && (i.truncate ?? !0);
|
|
1419
|
-
try {
|
|
1420
|
-
o = await s.createSyncAccessHandle();
|
|
1421
|
-
const h = es(t, e), c = a ? o.getSize() : 0;
|
|
1422
|
-
o.write(h, { at: c }), l && o.truncate(h.byteLength), o.flush();
|
|
1423
|
-
} catch (h) {
|
|
1424
|
-
console.error(h);
|
|
1425
|
-
const c = a ? "append" : "write";
|
|
1426
|
-
throw new g(\`Failed to \${c} file\`, \`\${c.toUpperCase()}_FAILED\`, void 0, h);
|
|
1427
|
-
} finally {
|
|
1428
|
-
try {
|
|
1429
|
-
o?.close();
|
|
1430
|
-
} catch {
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
};
|
|
1434
|
-
return n ? tt(n, "exclusive", r) : r();
|
|
1435
|
-
}
|
|
1436
|
-
async function ns(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1302
|
+
async function Ze(s, t = "SHA-1", e = 50 * 1024 * 1024) {
|
|
1437
1303
|
if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
|
|
1438
1304
|
throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
|
|
1439
1305
|
const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
|
|
1440
1306
|
return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
1441
1307
|
}
|
|
1442
|
-
async function
|
|
1308
|
+
async function Je(s) {
|
|
1443
1309
|
const t = await s.arrayBuffer();
|
|
1444
1310
|
return new Uint8Array(t);
|
|
1445
1311
|
}
|
|
1446
|
-
async function
|
|
1447
|
-
const n =
|
|
1448
|
-
return
|
|
1312
|
+
async function Ke(s, t, e = {}) {
|
|
1313
|
+
const n = J(t);
|
|
1314
|
+
return P(t, "exclusive", async () => {
|
|
1449
1315
|
const i = e.recursive ?? !1, r = e.force ?? !1;
|
|
1450
1316
|
e.useTrash;
|
|
1451
1317
|
try {
|
|
@@ -1453,12 +1319,42 @@ async function rs(s, t, e = {}) {
|
|
|
1453
1319
|
} catch (o) {
|
|
1454
1320
|
if (o.name === "NotFoundError") {
|
|
1455
1321
|
if (!r)
|
|
1456
|
-
throw new
|
|
1457
|
-
} else throw o.name === "InvalidModificationError" ? new
|
|
1322
|
+
throw new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, o);
|
|
1323
|
+
} else throw o.name === "InvalidModificationError" ? new p(\`Directory not empty: \${t}. Use recursive option to force removal.\`, "ENOTEMPTY", void 0, o) : o.name === "TypeMismatchError" && !i ? new p(\`Cannot remove directory without recursive option: \${t}\`, "EISDIR", void 0, o) : new p(\`Failed to remove entry: \${t}\`, "RM_FAILED", void 0, o);
|
|
1458
1324
|
}
|
|
1459
1325
|
});
|
|
1460
1326
|
}
|
|
1461
|
-
|
|
1327
|
+
function ft(s, t, e, n) {
|
|
1328
|
+
if (!Number.isInteger(t) || !Number.isInteger(e))
|
|
1329
|
+
throw new p("Invalid offset or length", "EINVAL");
|
|
1330
|
+
if (t < 0 || e < 0)
|
|
1331
|
+
throw new p("Negative offset or length not allowed", "EINVAL");
|
|
1332
|
+
if (t + e > s)
|
|
1333
|
+
throw new p("Operation would overflow buffer", "ERANGE");
|
|
1334
|
+
if (n != null && (!Number.isInteger(n) || n < 0))
|
|
1335
|
+
throw new p("Invalid position", "EINVAL");
|
|
1336
|
+
}
|
|
1337
|
+
function dt(s, t, e) {
|
|
1338
|
+
try {
|
|
1339
|
+
t.flush(), t.close();
|
|
1340
|
+
} catch (n) {
|
|
1341
|
+
console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
function Qe(s, t, e) {
|
|
1345
|
+
if (s >= e)
|
|
1346
|
+
return { isEOF: !0, actualLength: 0 };
|
|
1347
|
+
const n = Math.min(t, e - s);
|
|
1348
|
+
return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
|
|
1349
|
+
}
|
|
1350
|
+
async function ts(s, t) {
|
|
1351
|
+
try {
|
|
1352
|
+
return await s.createSyncAccessHandle();
|
|
1353
|
+
} catch (e) {
|
|
1354
|
+
throw Ut(e, { path: t });
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
class es {
|
|
1462
1358
|
/** Root directory handle for the file system */
|
|
1463
1359
|
root;
|
|
1464
1360
|
/** Map of watched paths and options */
|
|
@@ -1472,9 +1368,23 @@ class os {
|
|
|
1472
1368
|
root: "/",
|
|
1473
1369
|
namespace: "",
|
|
1474
1370
|
maxFileSize: 50 * 1024 * 1024,
|
|
1475
|
-
hashAlgorithm:
|
|
1371
|
+
hashAlgorithm: !1,
|
|
1476
1372
|
broadcastChannel: "opfs-worker"
|
|
1477
1373
|
};
|
|
1374
|
+
/** Map of open file descriptors to their metadata */
|
|
1375
|
+
openFiles = /* @__PURE__ */ new Map();
|
|
1376
|
+
/** Next available file descriptor number */
|
|
1377
|
+
nextFd = 1;
|
|
1378
|
+
/**
|
|
1379
|
+
* Get file info by descriptor with validation
|
|
1380
|
+
* @private
|
|
1381
|
+
*/
|
|
1382
|
+
_getFileDescriptor(t) {
|
|
1383
|
+
const e = this.openFiles.get(t);
|
|
1384
|
+
if (!e)
|
|
1385
|
+
throw new p(\`Invalid file descriptor: \${t}\`, "EBADF");
|
|
1386
|
+
return e;
|
|
1387
|
+
}
|
|
1478
1388
|
/**
|
|
1479
1389
|
* Notify about internal changes to the file system
|
|
1480
1390
|
*
|
|
@@ -1488,7 +1398,7 @@ class os {
|
|
|
1488
1398
|
if (!this.options.broadcastChannel)
|
|
1489
1399
|
return;
|
|
1490
1400
|
const e = t.path;
|
|
1491
|
-
if (![...this.watchers.values()].some((r) =>
|
|
1401
|
+
if (![...this.watchers.values()].some((r) => Y(e, r.pattern) && r.include.some((o) => o && Y(e, o)) && !r.exclude.some((o) => o && Y(e, o))))
|
|
1492
1402
|
return;
|
|
1493
1403
|
let i;
|
|
1494
1404
|
if (this.options.hashAlgorithm)
|
|
@@ -1520,7 +1430,7 @@ class os {
|
|
|
1520
1430
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
1521
1431
|
*/
|
|
1522
1432
|
constructor(t) {
|
|
1523
|
-
|
|
1433
|
+
Xe(), t && this.setOptions(t);
|
|
1524
1434
|
}
|
|
1525
1435
|
/**
|
|
1526
1436
|
* Initialize the file system within a given directory
|
|
@@ -1550,7 +1460,7 @@ class os {
|
|
|
1550
1460
|
const i = await navigator.storage.getDirectory();
|
|
1551
1461
|
this.root = t === "/" ? i : await this.getDirectoryHandle(t, !0, i), e(!0);
|
|
1552
1462
|
} catch (i) {
|
|
1553
|
-
n(new
|
|
1463
|
+
n(new p("Failed to initialize OPFS", "INIT_FAILED", t, i));
|
|
1554
1464
|
} finally {
|
|
1555
1465
|
this.mountingPromise = null;
|
|
1556
1466
|
}
|
|
@@ -1567,7 +1477,7 @@ class os {
|
|
|
1567
1477
|
* @param options.broadcastChannel - Custom name for the broadcast channel
|
|
1568
1478
|
*/
|
|
1569
1479
|
async setOptions(t) {
|
|
1570
|
-
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 =
|
|
1480
|
+
t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = W(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
|
|
1571
1481
|
}
|
|
1572
1482
|
/**
|
|
1573
1483
|
* Get a directory handle from a path
|
|
@@ -1616,7 +1526,7 @@ class os {
|
|
|
1616
1526
|
async getFileHandle(t, e = !1, n = this.root) {
|
|
1617
1527
|
const i = D(t);
|
|
1618
1528
|
if (i.length === 0)
|
|
1619
|
-
throw new
|
|
1529
|
+
throw new Bt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
1620
1530
|
const r = i.pop();
|
|
1621
1531
|
return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
|
|
1622
1532
|
}
|
|
@@ -1661,71 +1571,111 @@ class os {
|
|
|
1661
1571
|
isDirectory: !0
|
|
1662
1572
|
}), await e("/"), t;
|
|
1663
1573
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1574
|
+
/**
|
|
1575
|
+
* Read a file from the file system
|
|
1576
|
+
*
|
|
1577
|
+
* Reads the contents of a file and returns it as binary data.
|
|
1578
|
+
*
|
|
1579
|
+
* @param path - The path to the file to read
|
|
1580
|
+
* @returns Promise that resolves to the file contents as Uint8Array
|
|
1581
|
+
* @throws {FileNotFoundError} If the file does not exist
|
|
1582
|
+
* @throws {OPFSError} If reading the file fails
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* \`\`\`typescript
|
|
1586
|
+
* // Read as binary data
|
|
1587
|
+
* const content = await fs.readFile('/config/settings.json');
|
|
1588
|
+
*
|
|
1589
|
+
* // Read binary file
|
|
1590
|
+
* const binaryData = await fs.readFile('/images/logo.png');
|
|
1591
|
+
* \`\`\`
|
|
1592
|
+
*/
|
|
1593
|
+
async readFile(t) {
|
|
1594
|
+
await this.mount();
|
|
1666
1595
|
try {
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1596
|
+
return await P(t, "shared", async () => {
|
|
1597
|
+
const e = await this.open(t);
|
|
1598
|
+
try {
|
|
1599
|
+
const { size: n } = await this.fstat(e), i = new Uint8Array(n);
|
|
1600
|
+
return n > 0 && await this.read(e, i, 0, n, 0), H(i, [i.buffer]);
|
|
1601
|
+
} finally {
|
|
1602
|
+
await this.close(e);
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
} catch (e) {
|
|
1606
|
+
throw new nt(t, e);
|
|
1671
1607
|
}
|
|
1672
1608
|
}
|
|
1673
1609
|
/**
|
|
1674
1610
|
* Write data to a file
|
|
1675
1611
|
*
|
|
1676
|
-
* Creates or overwrites a file with the specified data. If the file already
|
|
1612
|
+
* Creates or overwrites a file with the specified binary data. If the file already
|
|
1677
1613
|
* exists, it will be truncated before writing.
|
|
1678
1614
|
*
|
|
1679
1615
|
* @param path - The path to the file to write
|
|
1680
|
-
* @param data - The data to write to the file (
|
|
1681
|
-
* @param encoding - The encoding to use when writing string data (default: 'utf-8')
|
|
1616
|
+
* @param data - The binary data to write to the file (Uint8Array or ArrayBuffer)
|
|
1682
1617
|
* @returns Promise that resolves when the write operation is complete
|
|
1683
1618
|
* @throws {OPFSError} If writing the file fails
|
|
1684
1619
|
*
|
|
1685
1620
|
* @example
|
|
1686
1621
|
* \`\`\`typescript
|
|
1687
|
-
* // Write text data
|
|
1688
|
-
* await fs.writeFile('/config/settings.json', JSON.stringify({ theme: 'dark' }));
|
|
1689
|
-
*
|
|
1690
1622
|
* // Write binary data
|
|
1691
1623
|
* const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
1692
1624
|
* await fs.writeFile('/data/binary.dat', binaryData);
|
|
1693
1625
|
*
|
|
1694
|
-
* // Write
|
|
1695
|
-
*
|
|
1626
|
+
* // Write from ArrayBuffer
|
|
1627
|
+
* const arrayBuffer = new ArrayBuffer(10);
|
|
1628
|
+
* await fs.writeFile('/data/buffer.dat', arrayBuffer);
|
|
1696
1629
|
* \`\`\`
|
|
1697
1630
|
*/
|
|
1698
|
-
async writeFile(t, e
|
|
1631
|
+
async writeFile(t, e) {
|
|
1699
1632
|
await this.mount();
|
|
1700
|
-
const
|
|
1701
|
-
|
|
1633
|
+
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1634
|
+
await P(t, "exclusive", async () => {
|
|
1635
|
+
const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
|
|
1636
|
+
try {
|
|
1637
|
+
await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
|
|
1638
|
+
} finally {
|
|
1639
|
+
await this.close(r);
|
|
1640
|
+
}
|
|
1641
|
+
await this.notifyChange({ path: t, type: i ? "changed" : "added", isDirectory: !1 });
|
|
1642
|
+
});
|
|
1702
1643
|
}
|
|
1703
1644
|
/**
|
|
1704
1645
|
* Append data to a file
|
|
1705
1646
|
*
|
|
1706
|
-
* Adds data to the end of an existing file. If the file doesn't exist,
|
|
1647
|
+
* Adds binary data to the end of an existing file. If the file doesn't exist,
|
|
1707
1648
|
* it will be created.
|
|
1708
1649
|
*
|
|
1709
1650
|
* @param path - The path to the file to append to
|
|
1710
|
-
* @param data - The data to append to the file (
|
|
1711
|
-
* @param encoding - The encoding to use when appending string data (default: 'utf-8')
|
|
1651
|
+
* @param data - The binary data to append to the file (Uint8Array or ArrayBuffer)
|
|
1712
1652
|
* @returns Promise that resolves when the append operation is complete
|
|
1713
1653
|
* @throws {OPFSError} If appending to the file fails
|
|
1714
1654
|
*
|
|
1715
1655
|
* @example
|
|
1716
1656
|
* \`\`\`typescript
|
|
1717
|
-
* // Append text to a log file
|
|
1718
|
-
* await fs.appendFile('/logs/app.log', \`[\${new Date().toISOString()}] User logged in\\n\`);
|
|
1719
|
-
*
|
|
1720
1657
|
* // Append binary data
|
|
1721
1658
|
* const additionalData = new Uint8Array([6, 7, 8]);
|
|
1722
1659
|
* await fs.appendFile('/data/binary.dat', additionalData);
|
|
1660
|
+
*
|
|
1661
|
+
* // Append from ArrayBuffer
|
|
1662
|
+
* const arrayBuffer = new ArrayBuffer(5);
|
|
1663
|
+
* await fs.appendFile('/data/buffer.dat', arrayBuffer);
|
|
1723
1664
|
* \`\`\`
|
|
1724
1665
|
*/
|
|
1725
|
-
async appendFile(t, e
|
|
1666
|
+
async appendFile(t, e) {
|
|
1726
1667
|
await this.mount();
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1668
|
+
const n = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1669
|
+
await P(t, "exclusive", async () => {
|
|
1670
|
+
const i = await this.open(t, { create: !0 });
|
|
1671
|
+
try {
|
|
1672
|
+
const { size: r } = await this.fstat(i);
|
|
1673
|
+
await this.write(i, n, 0, n.length, r, !1), await this.fsync(i);
|
|
1674
|
+
} finally {
|
|
1675
|
+
await this.close(i);
|
|
1676
|
+
}
|
|
1677
|
+
await this.notifyChange({ path: t, type: "changed", isDirectory: !1 });
|
|
1678
|
+
});
|
|
1729
1679
|
}
|
|
1730
1680
|
/**
|
|
1731
1681
|
* Create a directory
|
|
@@ -1757,12 +1707,12 @@ class os {
|
|
|
1757
1707
|
try {
|
|
1758
1708
|
r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
|
|
1759
1709
|
} catch (l) {
|
|
1760
|
-
throw l.name === "NotFoundError" ? new
|
|
1710
|
+
throw l.name === "NotFoundError" ? new p(
|
|
1761
1711
|
\`Parent directory does not exist: \${et(i.slice(0, o + 1))}\`,
|
|
1762
1712
|
"ENOENT",
|
|
1763
1713
|
void 0,
|
|
1764
1714
|
l
|
|
1765
|
-
) : l.name === "TypeMismatchError" ? new
|
|
1715
|
+
) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
|
|
1766
1716
|
}
|
|
1767
1717
|
}
|
|
1768
1718
|
await this.notifyChange({ path: t, type: "added", isDirectory: !0 });
|
|
@@ -1799,7 +1749,7 @@ class os {
|
|
|
1799
1749
|
isFile: !1,
|
|
1800
1750
|
isDirectory: !0
|
|
1801
1751
|
};
|
|
1802
|
-
const e =
|
|
1752
|
+
const e = J(t), n = await this.getDirectoryHandle(X(t), !1), i = this.options.hashAlgorithm !== null;
|
|
1803
1753
|
try {
|
|
1804
1754
|
const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
|
|
1805
1755
|
kind: "file",
|
|
@@ -1811,7 +1761,7 @@ class os {
|
|
|
1811
1761
|
};
|
|
1812
1762
|
if (i && this.options.hashAlgorithm)
|
|
1813
1763
|
try {
|
|
1814
|
-
const l = await
|
|
1764
|
+
const l = await Ze(o, this.options.hashAlgorithm, this.options.maxFileSize);
|
|
1815
1765
|
a.hash = l;
|
|
1816
1766
|
} catch (l) {
|
|
1817
1767
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
@@ -1819,7 +1769,7 @@ class os {
|
|
|
1819
1769
|
return a;
|
|
1820
1770
|
} catch (r) {
|
|
1821
1771
|
if (r.name !== "TypeMismatchError" && r.name !== "NotFoundError")
|
|
1822
|
-
throw new
|
|
1772
|
+
throw new p("Failed to stat (file)", "STAT_FAILED", void 0, r);
|
|
1823
1773
|
}
|
|
1824
1774
|
try {
|
|
1825
1775
|
return await n.getDirectoryHandle(e, { create: !1 }), {
|
|
@@ -1831,7 +1781,7 @@ class os {
|
|
|
1831
1781
|
isDirectory: !0
|
|
1832
1782
|
};
|
|
1833
1783
|
} catch (r) {
|
|
1834
|
-
throw r.name === "NotFoundError" ? new
|
|
1784
|
+
throw r.name === "NotFoundError" ? new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, r) : new p("Failed to stat (directory)", "STAT_FAILED", void 0, r);
|
|
1835
1785
|
}
|
|
1836
1786
|
}
|
|
1837
1787
|
/**
|
|
@@ -1883,10 +1833,10 @@ class os {
|
|
|
1883
1833
|
async exists(t) {
|
|
1884
1834
|
if (await this.mount(), t === "/")
|
|
1885
1835
|
return !0;
|
|
1886
|
-
const e =
|
|
1836
|
+
const e = J(t);
|
|
1887
1837
|
let n = null;
|
|
1888
1838
|
try {
|
|
1889
|
-
n = await this.getDirectoryHandle(
|
|
1839
|
+
n = await this.getDirectoryHandle(X(t), !1);
|
|
1890
1840
|
} catch (i) {
|
|
1891
1841
|
if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
|
|
1892
1842
|
throw i;
|
|
@@ -1936,7 +1886,7 @@ class os {
|
|
|
1936
1886
|
}
|
|
1937
1887
|
await this.notifyChange({ path: t, type: "changed", isDirectory: !0 });
|
|
1938
1888
|
} catch (e) {
|
|
1939
|
-
throw e instanceof
|
|
1889
|
+
throw e instanceof p ? e : new p(\`Failed to clear directory: \${t}\`, "CLEAR_FAILED", void 0, e);
|
|
1940
1890
|
}
|
|
1941
1891
|
}
|
|
1942
1892
|
/**
|
|
@@ -1965,9 +1915,9 @@ class os {
|
|
|
1965
1915
|
*/
|
|
1966
1916
|
async remove(t, e) {
|
|
1967
1917
|
if (await this.mount(), t === "/")
|
|
1968
|
-
throw new
|
|
1969
|
-
const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(
|
|
1970
|
-
await
|
|
1918
|
+
throw new p("Cannot remove root directory", "EROOT");
|
|
1919
|
+
const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(X(t), !1), o = await this.stat(t);
|
|
1920
|
+
await Ke(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: "removed", isDirectory: o.isDirectory });
|
|
1971
1921
|
}
|
|
1972
1922
|
/**
|
|
1973
1923
|
* Resolve a path to an absolute path
|
|
@@ -1990,12 +1940,12 @@ class os {
|
|
|
1990
1940
|
async realpath(t) {
|
|
1991
1941
|
await this.mount();
|
|
1992
1942
|
try {
|
|
1993
|
-
const e =
|
|
1943
|
+
const e = ut(t);
|
|
1994
1944
|
if (!await this.exists(e))
|
|
1995
|
-
throw new
|
|
1945
|
+
throw new nt(e);
|
|
1996
1946
|
return e;
|
|
1997
1947
|
} catch (e) {
|
|
1998
|
-
throw e instanceof
|
|
1948
|
+
throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
|
|
1999
1949
|
}
|
|
2000
1950
|
}
|
|
2001
1951
|
/**
|
|
@@ -2023,14 +1973,12 @@ class os {
|
|
|
2023
1973
|
async rename(t, e, n) {
|
|
2024
1974
|
await this.mount();
|
|
2025
1975
|
try {
|
|
2026
|
-
const i = n?.overwrite ?? !1;
|
|
2027
|
-
if (!await this.exists(t))
|
|
2028
|
-
throw new _(t);
|
|
1976
|
+
const i = n?.overwrite ?? !1, r = await this.stat(t);
|
|
2029
1977
|
if (await this.exists(e) && !i)
|
|
2030
|
-
throw new
|
|
2031
|
-
await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory:
|
|
1978
|
+
throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
|
|
1979
|
+
await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: "added", isDirectory: r.isDirectory });
|
|
2032
1980
|
} catch (i) {
|
|
2033
|
-
throw i instanceof
|
|
1981
|
+
throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
|
|
2034
1982
|
}
|
|
2035
1983
|
}
|
|
2036
1984
|
/**
|
|
@@ -2063,15 +2011,15 @@ class os {
|
|
|
2063
2011
|
try {
|
|
2064
2012
|
const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
|
|
2065
2013
|
if (!await this.exists(t))
|
|
2066
|
-
throw new
|
|
2014
|
+
throw new p(\`Source does not exist: \${t}\`, "ENOENT", void 0);
|
|
2067
2015
|
if (await this.exists(e) && !r)
|
|
2068
|
-
throw new
|
|
2016
|
+
throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
|
|
2069
2017
|
if ((await this.stat(t)).isFile) {
|
|
2070
|
-
const h = await this.readFile(t
|
|
2018
|
+
const h = await this.readFile(t);
|
|
2071
2019
|
await this.writeFile(e, h);
|
|
2072
2020
|
} else {
|
|
2073
2021
|
if (!i)
|
|
2074
|
-
throw new
|
|
2022
|
+
throw new p(\`Cannot copy directory without recursive option: \${t}\`, "EISDIR", void 0);
|
|
2075
2023
|
await this.mkdir(e, { recursive: !0 });
|
|
2076
2024
|
const h = await this.readDir(t);
|
|
2077
2025
|
for (const c of h) {
|
|
@@ -2080,7 +2028,7 @@ class os {
|
|
|
2080
2028
|
}
|
|
2081
2029
|
}
|
|
2082
2030
|
} catch (i) {
|
|
2083
|
-
throw i instanceof
|
|
2031
|
+
throw i instanceof p ? i : new p(\`Failed to copy from \${t} to \${e}\`, "CP_FAILED", void 0, i);
|
|
2084
2032
|
}
|
|
2085
2033
|
}
|
|
2086
2034
|
/**
|
|
@@ -2110,9 +2058,9 @@ class os {
|
|
|
2110
2058
|
*/
|
|
2111
2059
|
async watch(t, e) {
|
|
2112
2060
|
if (!this.options.broadcastChannel)
|
|
2113
|
-
throw new
|
|
2061
|
+
throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
|
|
2114
2062
|
const n = {
|
|
2115
|
-
pattern:
|
|
2063
|
+
pattern: Ye(t, e?.recursive ?? !0),
|
|
2116
2064
|
include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
|
|
2117
2065
|
exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
|
|
2118
2066
|
};
|
|
@@ -2124,6 +2072,223 @@ class os {
|
|
|
2124
2072
|
unwatch(t) {
|
|
2125
2073
|
this.watchers.delete(t);
|
|
2126
2074
|
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Open a file and return a file descriptor
|
|
2077
|
+
*
|
|
2078
|
+
* @param path - The path to the file to open
|
|
2079
|
+
* @param options - Options for opening the file
|
|
2080
|
+
* @param options.create - Whether to create the file if it doesn't exist (default: false)
|
|
2081
|
+
* @param options.exclusive - If true and create is true, fails if file already exists (default: false)
|
|
2082
|
+
* Note: This is best-effort in OPFS, not fully atomic due to browser limitations
|
|
2083
|
+
* @param options.truncate - Whether to truncate the file to zero length (default: false)
|
|
2084
|
+
* @returns Promise that resolves to a file descriptor number
|
|
2085
|
+
* @throws {OPFSError} If opening the file fails
|
|
2086
|
+
*
|
|
2087
|
+
* @example
|
|
2088
|
+
* \`\`\`typescript
|
|
2089
|
+
* // Open existing file for reading
|
|
2090
|
+
* const fd = await fs.open('/data/config.json');
|
|
2091
|
+
*
|
|
2092
|
+
* // Create new file for writing
|
|
2093
|
+
* const fd = await fs.open('/data/new.txt', { create: true });
|
|
2094
|
+
*
|
|
2095
|
+
* // Create file exclusively (fails if exists)
|
|
2096
|
+
* const fd = await fs.open('/data/unique.txt', { create: true, exclusive: true });
|
|
2097
|
+
*
|
|
2098
|
+
* // Open and truncate file
|
|
2099
|
+
* const fd = await fs.open('/data/log.txt', { create: true, truncate: true });
|
|
2100
|
+
* \`\`\`
|
|
2101
|
+
*/
|
|
2102
|
+
async open(t, e) {
|
|
2103
|
+
await this.mount();
|
|
2104
|
+
const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = W(ut(t));
|
|
2105
|
+
try {
|
|
2106
|
+
return n && i ? await P(o, "exclusive", async () => {
|
|
2107
|
+
if (await this.exists(o))
|
|
2108
|
+
throw new p(\`File already exists: \${o}\`, "EEXIST", o);
|
|
2109
|
+
return this._openFile(o, n, r);
|
|
2110
|
+
}) : await this._openFile(o, n, r);
|
|
2111
|
+
} catch (a) {
|
|
2112
|
+
throw a instanceof p ? a : new p(\`Failed to open file: \${o}\`, "OPEN_FAILED", o, a);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Internal method to open a file (without locking)
|
|
2117
|
+
* @private
|
|
2118
|
+
*/
|
|
2119
|
+
async _openFile(t, e, n) {
|
|
2120
|
+
const i = await this.getFileHandle(t, e);
|
|
2121
|
+
try {
|
|
2122
|
+
await i.getFile();
|
|
2123
|
+
} catch (a) {
|
|
2124
|
+
throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
|
|
2125
|
+
}
|
|
2126
|
+
const r = await ts(i, t);
|
|
2127
|
+
n && (r.truncate(0), r.flush());
|
|
2128
|
+
const o = this.nextFd++;
|
|
2129
|
+
return this.openFiles.set(o, {
|
|
2130
|
+
path: t,
|
|
2131
|
+
fileHandle: i,
|
|
2132
|
+
syncHandle: r,
|
|
2133
|
+
position: 0
|
|
2134
|
+
}), o;
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Close a file descriptor
|
|
2138
|
+
*
|
|
2139
|
+
* @param fd - The file descriptor to close
|
|
2140
|
+
* @returns Promise that resolves when the file descriptor is closed
|
|
2141
|
+
* @throws {OPFSError} If the file descriptor is invalid or closing fails
|
|
2142
|
+
*
|
|
2143
|
+
* @example
|
|
2144
|
+
* \`\`\`typescript
|
|
2145
|
+
* const fd = await fs.open('/data/file.txt');
|
|
2146
|
+
* // ... use the file descriptor ...
|
|
2147
|
+
* await fs.close(fd);
|
|
2148
|
+
* \`\`\`
|
|
2149
|
+
*/
|
|
2150
|
+
async close(t) {
|
|
2151
|
+
const e = this._getFileDescriptor(t);
|
|
2152
|
+
dt(t, e.syncHandle, e.path), this.openFiles.delete(t);
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Read data from a file descriptor
|
|
2156
|
+
*
|
|
2157
|
+
* @param fd - The file descriptor to read from
|
|
2158
|
+
* @param buffer - The buffer to read data into
|
|
2159
|
+
* @param offset - The offset in the buffer to start writing at
|
|
2160
|
+
* @param length - The number of bytes to read
|
|
2161
|
+
* @param position - The position in the file to read from (null for current position)
|
|
2162
|
+
* @returns Promise that resolves to the number of bytes read and the modified buffer
|
|
2163
|
+
* @throws {OPFSError} If the file descriptor is invalid or reading fails
|
|
2164
|
+
*
|
|
2165
|
+
* @note This method uses Comlink.transfer() to efficiently pass the buffer as a Transferable Object,
|
|
2166
|
+
* ensuring zero-copy performance across Web Worker boundaries.
|
|
2167
|
+
*
|
|
2168
|
+
* @example
|
|
2169
|
+
* \`\`\`typescript
|
|
2170
|
+
* const fd = await fs.open('/data/file.txt');
|
|
2171
|
+
* const buffer = new Uint8Array(1024);
|
|
2172
|
+
* const { bytesRead, buffer: modifiedBuffer } = await fs.read(fd, buffer, 0, 1024, null);
|
|
2173
|
+
* console.log(\`Read \${bytesRead} bytes\`);
|
|
2174
|
+
* // Use modifiedBuffer which contains the actual data
|
|
2175
|
+
* await fs.close(fd);
|
|
2176
|
+
* \`\`\`
|
|
2177
|
+
*/
|
|
2178
|
+
async read(t, e, n, i, r) {
|
|
2179
|
+
const o = this._getFileDescriptor(t);
|
|
2180
|
+
ft(e.length, n, i, r);
|
|
2181
|
+
try {
|
|
2182
|
+
const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = Qe(a, i, l);
|
|
2183
|
+
if (h)
|
|
2184
|
+
return H({ bytesRead: 0, buffer: e }, [e.buffer]);
|
|
2185
|
+
const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
|
|
2186
|
+
return r == null && (o.position = a + u), H({ bytesRead: u, buffer: e }, [e.buffer]);
|
|
2187
|
+
} catch (a) {
|
|
2188
|
+
throw R("read", t, o.path, a);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Write data to a file descriptor
|
|
2193
|
+
*
|
|
2194
|
+
* @param fd - The file descriptor to write to
|
|
2195
|
+
* @param buffer - The buffer containing data to write
|
|
2196
|
+
* @param offset - The offset in the buffer to start reading from (default: 0)
|
|
2197
|
+
* @param length - The number of bytes to write (default: entire buffer)
|
|
2198
|
+
* @param position - The position in the file to write to (null/undefined for current position)
|
|
2199
|
+
* @param emitEvent - Whether to emit a change event (default: true)
|
|
2200
|
+
* @returns Promise that resolves to the number of bytes written
|
|
2201
|
+
* @throws {OPFSError} If the file descriptor is invalid or writing fails
|
|
2202
|
+
*
|
|
2203
|
+
* @example
|
|
2204
|
+
* \`\`\`typescript
|
|
2205
|
+
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
2206
|
+
* const data = new TextEncoder().encode('Hello, World!');
|
|
2207
|
+
* const bytesWritten = await fs.write(fd, data, 0, data.length, null);
|
|
2208
|
+
* console.log(\`Wrote \${bytesWritten} bytes\`);
|
|
2209
|
+
* await fs.close(fd);
|
|
2210
|
+
* \`\`\`
|
|
2211
|
+
*/
|
|
2212
|
+
async write(t, e, n = 0, i, r, o = !0) {
|
|
2213
|
+
const a = this._getFileDescriptor(t), l = i ?? e.length - n;
|
|
2214
|
+
ft(e.length, n, l, r);
|
|
2215
|
+
try {
|
|
2216
|
+
const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
|
|
2217
|
+
return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: "changed", isDirectory: !1 }), f;
|
|
2218
|
+
} catch (h) {
|
|
2219
|
+
throw R("write", t, a.path, h);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* Get file status information by file descriptor
|
|
2224
|
+
*
|
|
2225
|
+
* @param fd - The file descriptor
|
|
2226
|
+
* @returns Promise that resolves to FileStat object
|
|
2227
|
+
* @throws {OPFSError} If the file descriptor is invalid
|
|
2228
|
+
*
|
|
2229
|
+
* @example
|
|
2230
|
+
* \`\`\`typescript
|
|
2231
|
+
* const fd = await fs.open('/data/file.txt');
|
|
2232
|
+
* const stats = await fs.fstat(fd);
|
|
2233
|
+
* console.log(\`File size: \${stats.size} bytes\`);
|
|
2234
|
+
* console.log(\`Last modified: \${stats.mtime}\`);
|
|
2235
|
+
*
|
|
2236
|
+
* // If hashing is enabled, hash will be included
|
|
2237
|
+
* if (stats.hash) {
|
|
2238
|
+
* console.log(\`Hash: \${stats.hash}\`);
|
|
2239
|
+
* }
|
|
2240
|
+
* \`\`\`
|
|
2241
|
+
*/
|
|
2242
|
+
async fstat(t) {
|
|
2243
|
+
const e = this._getFileDescriptor(t);
|
|
2244
|
+
return this.stat(e.path);
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Truncate file to specified size
|
|
2248
|
+
*
|
|
2249
|
+
* @param fd - The file descriptor
|
|
2250
|
+
* @param size - The new size of the file (default: 0)
|
|
2251
|
+
* @returns Promise that resolves when truncation is complete
|
|
2252
|
+
* @throws {OPFSError} If the file descriptor is invalid or truncation fails
|
|
2253
|
+
*
|
|
2254
|
+
* @example
|
|
2255
|
+
* \`\`\`typescript
|
|
2256
|
+
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
2257
|
+
* await fs.truncate(fd, 100); // Truncate to 100 bytes
|
|
2258
|
+
* \`\`\`
|
|
2259
|
+
*/
|
|
2260
|
+
async ftruncate(t, e = 0) {
|
|
2261
|
+
const n = this._getFileDescriptor(t);
|
|
2262
|
+
if (e < 0 || !Number.isInteger(e))
|
|
2263
|
+
throw new p("Invalid size", "EINVAL");
|
|
2264
|
+
try {
|
|
2265
|
+
n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: "changed", isDirectory: !1 });
|
|
2266
|
+
} catch (i) {
|
|
2267
|
+
throw R("truncate", t, n.path, i);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Synchronize file data to storage (fsync equivalent)
|
|
2272
|
+
*
|
|
2273
|
+
* @param fd - The file descriptor
|
|
2274
|
+
* @returns Promise that resolves when synchronization is complete
|
|
2275
|
+
* @throws {OPFSError} If the file descriptor is invalid or sync fails
|
|
2276
|
+
*
|
|
2277
|
+
* @example
|
|
2278
|
+
* \`\`\`typescript
|
|
2279
|
+
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
2280
|
+
* await fs.write(fd, data);
|
|
2281
|
+
* await fs.fsync(fd); // Ensure data is written to storage
|
|
2282
|
+
* \`\`\`
|
|
2283
|
+
*/
|
|
2284
|
+
async fsync(t) {
|
|
2285
|
+
const e = this._getFileDescriptor(t);
|
|
2286
|
+
try {
|
|
2287
|
+
e.syncHandle.flush();
|
|
2288
|
+
} catch (n) {
|
|
2289
|
+
throw R("sync", t, e.path, n);
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2127
2292
|
/**
|
|
2128
2293
|
* Dispose of resources and clean up the file system instance
|
|
2129
2294
|
*
|
|
@@ -2132,6 +2297,9 @@ class os {
|
|
|
2132
2297
|
*/
|
|
2133
2298
|
dispose() {
|
|
2134
2299
|
this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
|
|
2300
|
+
for (const [t, e] of this.openFiles)
|
|
2301
|
+
dt(t, e.syncHandle, e.path);
|
|
2302
|
+
this.openFiles.clear(), this.nextFd = 1;
|
|
2135
2303
|
}
|
|
2136
2304
|
/**
|
|
2137
2305
|
* Synchronize the file system with external data
|
|
@@ -2166,76 +2334,272 @@ class os {
|
|
|
2166
2334
|
try {
|
|
2167
2335
|
(e?.cleanBefore ?? !1) && await this.clear("/");
|
|
2168
2336
|
for (const [i, r] of t) {
|
|
2169
|
-
const o =
|
|
2337
|
+
const o = W(i);
|
|
2170
2338
|
let a;
|
|
2171
|
-
r instanceof Blob ? a = await
|
|
2339
|
+
r instanceof Blob ? a = await Je(r) : typeof r == "string" ? a = new TextEncoder().encode(r) : a = r, await this.writeFile(o, a);
|
|
2172
2340
|
}
|
|
2173
2341
|
} catch (n) {
|
|
2174
|
-
throw n instanceof
|
|
2342
|
+
throw n instanceof p ? n : new p("Failed to sync file system", "SYNC_FAILED", void 0, n);
|
|
2175
2343
|
}
|
|
2176
2344
|
}
|
|
2177
2345
|
}
|
|
2178
|
-
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
2179
|
-
//# sourceMappingURL=worker-
|
|
2180
|
-
`,
|
|
2181
|
-
function
|
|
2182
|
-
let
|
|
2346
|
+
typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
|
|
2347
|
+
//# sourceMappingURL=worker-CLvhwwfc.js.map
|
|
2348
|
+
`, l = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", p], { type: "text/javascript;charset=utf-8" });
|
|
2349
|
+
function u(s) {
|
|
2350
|
+
let n;
|
|
2183
2351
|
try {
|
|
2184
|
-
if (
|
|
2185
|
-
const
|
|
2352
|
+
if (n = l && (self.URL || self.webkitURL).createObjectURL(l), !n) throw "";
|
|
2353
|
+
const t = new Worker(n, {
|
|
2186
2354
|
type: "module",
|
|
2187
|
-
name:
|
|
2355
|
+
name: s?.name
|
|
2188
2356
|
});
|
|
2189
|
-
return
|
|
2190
|
-
(self.URL || self.webkitURL).revokeObjectURL(
|
|
2191
|
-
}),
|
|
2357
|
+
return t.addEventListener("error", () => {
|
|
2358
|
+
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
2359
|
+
}), t;
|
|
2192
2360
|
} catch {
|
|
2193
2361
|
return new Worker(
|
|
2194
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
2362
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(p),
|
|
2195
2363
|
{
|
|
2196
2364
|
type: "module",
|
|
2197
|
-
name:
|
|
2365
|
+
name: s?.name
|
|
2198
2366
|
}
|
|
2199
2367
|
);
|
|
2200
2368
|
}
|
|
2201
2369
|
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2370
|
+
class w {
|
|
2371
|
+
#n;
|
|
2372
|
+
constructor(n) {
|
|
2373
|
+
const t = d(new u());
|
|
2374
|
+
this.#n = t, n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Update configuration options
|
|
2378
|
+
*/
|
|
2379
|
+
async setOptions(n) {
|
|
2380
|
+
return this.#n.setOptions(n);
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Get a complete index of all files and directories in the file system
|
|
2384
|
+
*/
|
|
2385
|
+
async index() {
|
|
2386
|
+
return this.#n.index();
|
|
2387
|
+
}
|
|
2388
|
+
async readFile(n, t) {
|
|
2389
|
+
const e = await this.#n.readFile(n);
|
|
2390
|
+
return t || (t = h(n) ? "binary" : "utf-8"), t === "binary" ? e : c(e, t);
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Write data to a file
|
|
2394
|
+
*/
|
|
2395
|
+
async writeFile(n, t, e) {
|
|
2396
|
+
e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
|
|
2397
|
+
const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2398
|
+
return this.#n.writeFile(n, r);
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Append data to a file
|
|
2402
|
+
*/
|
|
2403
|
+
async appendFile(n, t, e) {
|
|
2404
|
+
e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
|
|
2405
|
+
const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
2406
|
+
return this.#n.appendFile(n, r);
|
|
2407
|
+
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Create a directory
|
|
2410
|
+
*/
|
|
2411
|
+
async mkdir(n, t) {
|
|
2412
|
+
return this.#n.mkdir(n, t);
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* Get file or directory statistics
|
|
2416
|
+
*/
|
|
2417
|
+
async stat(n) {
|
|
2418
|
+
return this.#n.stat(n);
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* Read a directory's contents
|
|
2422
|
+
*/
|
|
2423
|
+
async readDir(n) {
|
|
2424
|
+
return this.#n.readDir(n);
|
|
2425
|
+
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Check if a file or directory exists
|
|
2428
|
+
*/
|
|
2429
|
+
async exists(n) {
|
|
2430
|
+
return this.#n.exists(n);
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Clear all contents of a directory without removing the directory itself
|
|
2434
|
+
*/
|
|
2435
|
+
async clear(n) {
|
|
2436
|
+
return this.#n.clear(n);
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Remove files and directories
|
|
2440
|
+
*/
|
|
2441
|
+
async remove(n, t) {
|
|
2442
|
+
return this.#n.remove(n, t);
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Resolve a path to an absolute path
|
|
2446
|
+
*/
|
|
2447
|
+
async realpath(n) {
|
|
2448
|
+
return this.#n.realpath(n);
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Rename a file or directory
|
|
2452
|
+
*/
|
|
2453
|
+
async rename(n, t, e) {
|
|
2454
|
+
return this.#n.rename(n, t, e);
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Copy files and directories
|
|
2458
|
+
*/
|
|
2459
|
+
async copy(n, t, e) {
|
|
2460
|
+
return this.#n.copy(n, t, e);
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Start watching a file or directory for changes
|
|
2464
|
+
*/
|
|
2465
|
+
watch(n, t) {
|
|
2466
|
+
return this.#n.watch(n, t), () => this.unwatch(n);
|
|
2467
|
+
}
|
|
2468
|
+
/**
|
|
2469
|
+
* Stop watching a previously watched path
|
|
2470
|
+
*/
|
|
2471
|
+
unwatch(n) {
|
|
2472
|
+
this.#n.unwatch(n);
|
|
2473
|
+
}
|
|
2474
|
+
/**
|
|
2475
|
+
* Open a file and return a file descriptor
|
|
2476
|
+
*/
|
|
2477
|
+
async open(n, t) {
|
|
2478
|
+
return this.#n.open(n, t);
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* Close a file descriptor
|
|
2482
|
+
*/
|
|
2483
|
+
async close(n) {
|
|
2484
|
+
return this.#n.close(n);
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Read data from a file descriptor
|
|
2488
|
+
*
|
|
2489
|
+
* This method requires special handling due to Comlink transfer requirements.
|
|
2490
|
+
* The buffer is transferred to the worker and back, so the original buffer
|
|
2491
|
+
* becomes unusable after the call.
|
|
2492
|
+
*/
|
|
2493
|
+
async read(n, t, e, r, o) {
|
|
2494
|
+
const { bytesRead: i, buffer: f } = await this.#n.read(
|
|
2495
|
+
n,
|
|
2496
|
+
// Temp buffer to preserve the original buffer
|
|
2497
|
+
new Uint8Array(r),
|
|
2498
|
+
0,
|
|
2499
|
+
r,
|
|
2500
|
+
o
|
|
2501
|
+
);
|
|
2502
|
+
return i > 0 && t.set(f.subarray(0, i), e), { bytesRead: i, buffer: t };
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Write data to a file descriptor
|
|
2506
|
+
*/
|
|
2507
|
+
async write(n, t, e, r, o, i) {
|
|
2508
|
+
return this.#n.write(n, t, e, r, o, i);
|
|
2509
|
+
}
|
|
2510
|
+
/**
|
|
2511
|
+
* Get file status information by file descriptor
|
|
2512
|
+
*/
|
|
2513
|
+
async fstat(n) {
|
|
2514
|
+
return this.#n.fstat(n);
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Truncate file to specified size
|
|
2518
|
+
*/
|
|
2519
|
+
async ftruncate(n, t) {
|
|
2520
|
+
return this.#n.ftruncate(n, t);
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Synchronize file data to storage (fsync equivalent)
|
|
2524
|
+
*/
|
|
2525
|
+
async fsync(n) {
|
|
2526
|
+
return this.#n.fsync(n);
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Dispose of resources and clean up the file system instance
|
|
2530
|
+
*/
|
|
2531
|
+
dispose() {
|
|
2532
|
+
this.#n.dispose();
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* Synchronize the file system with external data
|
|
2536
|
+
*/
|
|
2537
|
+
async sync(n, t) {
|
|
2538
|
+
return this.#n.sync(n, t);
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Read a file as text with automatic encoding detection
|
|
2542
|
+
*/
|
|
2543
|
+
async readText(n, t = "utf-8") {
|
|
2544
|
+
const e = await this.#n.readFile(n);
|
|
2545
|
+
return c(e, t);
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Write text to a file with specified encoding
|
|
2549
|
+
*/
|
|
2550
|
+
async writeText(n, t, e = "utf-8") {
|
|
2551
|
+
const r = a(t, e);
|
|
2552
|
+
return this.#n.writeFile(n, r);
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Append text to a file with specified encoding
|
|
2556
|
+
*/
|
|
2557
|
+
async appendText(n, t, e = "utf-8") {
|
|
2558
|
+
const r = a(t, e);
|
|
2559
|
+
return this.#n.appendFile(n, r);
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
function g(s) {
|
|
2563
|
+
return new w(s);
|
|
2205
2564
|
}
|
|
2206
2565
|
export {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2566
|
+
E as BINARY_FILE_EXTENSIONS,
|
|
2567
|
+
x as DirectoryNotFoundError,
|
|
2568
|
+
S as FileNotFoundError,
|
|
2569
|
+
F as OPFSError,
|
|
2570
|
+
w as OPFSFileSystem,
|
|
2571
|
+
P as OPFSNotMountedError,
|
|
2572
|
+
O as OPFSNotSupportedError,
|
|
2573
|
+
A as PathError,
|
|
2574
|
+
T as PermissionError,
|
|
2575
|
+
I as StorageError,
|
|
2576
|
+
$ as TimeoutError,
|
|
2577
|
+
R as basename,
|
|
2578
|
+
C as buffersEqual,
|
|
2579
|
+
_ as calculateFileHash,
|
|
2580
|
+
N as calculateReadLength,
|
|
2581
|
+
D as checkOPFSSupport,
|
|
2582
|
+
k as convertBlobToUint8Array,
|
|
2583
|
+
M as createBuffer,
|
|
2584
|
+
L as createFDError,
|
|
2585
|
+
j as createSyncHandleSafe,
|
|
2586
|
+
g as createWorker,
|
|
2587
|
+
c as decodeBuffer,
|
|
2588
|
+
W as dirname,
|
|
2589
|
+
a as encodeString,
|
|
2590
|
+
z as extname,
|
|
2591
|
+
h as isBinaryFileExtension,
|
|
2592
|
+
U as isPathExcluded,
|
|
2593
|
+
H as joinPath,
|
|
2594
|
+
B as mapDomError,
|
|
2595
|
+
G as matchMinimatch,
|
|
2596
|
+
q as normalizeMinimatch,
|
|
2597
|
+
V as normalizePath,
|
|
2598
|
+
Y as removeEntry,
|
|
2599
|
+
X as resolvePath,
|
|
2600
|
+
Z as safeCloseSyncHandle,
|
|
2601
|
+
J as splitPath,
|
|
2602
|
+
K as validateReadWriteArgs,
|
|
2603
|
+
Q as withLock
|
|
2240
2604
|
};
|
|
2241
2605
|
//# sourceMappingURL=index.js.map
|