opfs-worker 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -6
- package/dist/assets/worker-ChfzBM-o.js.map +1 -0
- package/dist/helpers-Co-qCBmA.js +224 -0
- package/dist/helpers-Co-qCBmA.js.map +1 -0
- package/dist/helpers-hEpet7x7.cjs +2 -0
- package/dist/helpers-hEpet7x7.cjs.map +1 -0
- package/dist/index.cjs +333 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -16
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +223 -314
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/encoder.d.ts.map +1 -1
- package/dist/utils/encoder.js +0 -3
- package/dist/utils/helpers.d.ts +108 -0
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +151 -1
- package/dist/worker.d.ts +24 -2
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +112 -59
- package/package.json +9 -9
- package/dist/assets/worker-BiWuxhcz.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),n=require("./helpers-hEpet7x7.cjs"),i=`/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
canHandle: (e) =>
|
|
6
|
+
const M = Symbol("Comlink.proxy"), R = Symbol("Comlink.endpoint"), B = Symbol("Comlink.releaseProxy"), T = Symbol("Comlink.finalizer"), p = Symbol("Comlink.thrown"), $ = (e) => typeof e == "object" && e !== null || typeof e == "function", W = {
|
|
7
|
+
canHandle: (e) => $(e) && e[M],
|
|
8
8
|
serialize(e) {
|
|
9
9
|
const { port1: t, port2: r } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return N(e, t), [r, [r]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(e) {
|
|
13
|
-
return e.start(),
|
|
13
|
+
return e.start(), Y(e);
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
canHandle: (e) =>
|
|
15
|
+
}, j = {
|
|
16
|
+
canHandle: (e) => $(e) && p in e,
|
|
17
17
|
serialize({ value: e }) {
|
|
18
18
|
let t;
|
|
19
19
|
return e instanceof Error ? t = {
|
|
@@ -28,187 +28,187 @@ const C = Symbol("Comlink.proxy"), v = Symbol("Comlink.endpoint"), _ = Symbol("C
|
|
|
28
28
|
deserialize(e) {
|
|
29
29
|
throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
["proxy",
|
|
33
|
-
["throw",
|
|
31
|
+
}, U = /* @__PURE__ */ new Map([
|
|
32
|
+
["proxy", W],
|
|
33
|
+
["throw", j]
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
35
|
+
function V(e, t) {
|
|
36
36
|
for (const r of e)
|
|
37
37
|
if (t === r || r === "*" || r instanceof RegExp && r.test(t))
|
|
38
38
|
return !0;
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function N(e, t = globalThis, r = ["*"]) {
|
|
42
42
|
t.addEventListener("message", function a(n) {
|
|
43
43
|
if (!n || !n.data)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
45
|
+
if (!V(r, n.origin)) {
|
|
46
46
|
console.warn(\`Invalid origin '\${n.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id:
|
|
50
|
-
let
|
|
49
|
+
const { id: s, type: o, path: i } = Object.assign({ path: [] }, n.data), c = (n.data.argumentList || []).map(y);
|
|
50
|
+
let f;
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
53
|
-
switch (
|
|
52
|
+
const u = i.slice(0, -1).reduce((h, g) => h[g], e), w = i.reduce((h, g) => h[g], e);
|
|
53
|
+
switch (o) {
|
|
54
54
|
case "GET":
|
|
55
|
-
|
|
55
|
+
f = w;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
|
|
58
|
+
u[i.slice(-1)[0]] = y(n.data.value), f = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
|
-
|
|
61
|
+
f = w.apply(u, c);
|
|
62
62
|
break;
|
|
63
63
|
case "CONSTRUCT":
|
|
64
64
|
{
|
|
65
|
-
const h = new w(...
|
|
66
|
-
|
|
65
|
+
const h = new w(...c);
|
|
66
|
+
f = Q(h);
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: h, port2: g } = new MessageChannel();
|
|
72
|
-
|
|
72
|
+
N(e, g), f = J(h, [h]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
76
|
-
|
|
76
|
+
f = void 0;
|
|
77
77
|
break;
|
|
78
78
|
default:
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
81
|
+
} catch (u) {
|
|
82
|
+
f = { value: u, [p]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(
|
|
85
|
-
const [w, h] =
|
|
86
|
-
t.postMessage(Object.assign(Object.assign({}, w), { id:
|
|
87
|
-
}).catch((
|
|
88
|
-
const [w, h] =
|
|
84
|
+
Promise.resolve(f).catch((u) => ({ value: u, [p]: 0 })).then((u) => {
|
|
85
|
+
const [w, h] = A(u);
|
|
86
|
+
t.postMessage(Object.assign(Object.assign({}, w), { id: s }), h), o === "RELEASE" && (t.removeEventListener("message", a), L(t), T in e && typeof e[T] == "function" && e[T]());
|
|
87
|
+
}).catch((u) => {
|
|
88
|
+
const [w, h] = A({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
90
|
[p]: 0
|
|
91
91
|
});
|
|
92
|
-
t.postMessage(Object.assign(Object.assign({}, w), { id:
|
|
92
|
+
t.postMessage(Object.assign(Object.assign({}, w), { id: s }), h);
|
|
93
93
|
});
|
|
94
94
|
}), t.start && t.start();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function G(e) {
|
|
97
97
|
return e.constructor.name === "MessagePort";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function L(e) {
|
|
100
|
+
G(e) && e.close();
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Y(e, t) {
|
|
103
103
|
const r = /* @__PURE__ */ new Map();
|
|
104
104
|
return e.addEventListener("message", function(n) {
|
|
105
|
-
const { data:
|
|
106
|
-
if (!
|
|
105
|
+
const { data: s } = n;
|
|
106
|
+
if (!s || !s.id)
|
|
107
107
|
return;
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
108
|
+
const o = r.get(s.id);
|
|
109
|
+
if (o)
|
|
110
110
|
try {
|
|
111
|
-
s
|
|
111
|
+
o(s);
|
|
112
112
|
} finally {
|
|
113
|
-
r.delete(
|
|
113
|
+
r.delete(s.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), P(e, r, [], t);
|
|
116
116
|
}
|
|
117
117
|
function E(e) {
|
|
118
118
|
if (e)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function z(e) {
|
|
122
|
+
return d(e, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
|
-
|
|
125
|
+
L(e);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const F = /* @__PURE__ */ new WeakMap(),
|
|
128
|
+
const F = /* @__PURE__ */ new WeakMap(), S = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
|
|
129
129
|
const t = (F.get(e) || 0) - 1;
|
|
130
|
-
F.set(e, t), t === 0 &&
|
|
130
|
+
F.set(e, t), t === 0 && z(e);
|
|
131
131
|
});
|
|
132
|
-
function
|
|
132
|
+
function X(e, t) {
|
|
133
133
|
const r = (F.get(t) || 0) + 1;
|
|
134
|
-
F.set(t, r),
|
|
134
|
+
F.set(t, r), S && S.register(e, t, e);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function q(e) {
|
|
137
|
+
S && S.unregister(e);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function P(e, t, r = [], a = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let n = !1;
|
|
142
|
-
const
|
|
143
|
-
get(
|
|
144
|
-
if (E(n),
|
|
142
|
+
const s = new Proxy(a, {
|
|
143
|
+
get(o, i) {
|
|
144
|
+
if (E(n), i === B)
|
|
145
145
|
return () => {
|
|
146
|
-
|
|
146
|
+
q(s), z(e), t.clear(), n = !0;
|
|
147
147
|
};
|
|
148
|
-
if (
|
|
148
|
+
if (i === "then") {
|
|
149
149
|
if (r.length === 0)
|
|
150
|
-
return { then: () =>
|
|
151
|
-
const
|
|
150
|
+
return { then: () => s };
|
|
151
|
+
const c = d(e, t, {
|
|
152
152
|
type: "GET",
|
|
153
|
-
path: r.map((
|
|
154
|
-
}).then(
|
|
155
|
-
return
|
|
153
|
+
path: r.map((f) => f.toString())
|
|
154
|
+
}).then(y);
|
|
155
|
+
return c.then.bind(c);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return P(e, t, [...r, i]);
|
|
158
158
|
},
|
|
159
|
-
set(
|
|
159
|
+
set(o, i, c) {
|
|
160
160
|
E(n);
|
|
161
|
-
const [
|
|
162
|
-
return
|
|
161
|
+
const [f, u] = A(c);
|
|
162
|
+
return d(e, t, {
|
|
163
163
|
type: "SET",
|
|
164
|
-
path: [...r,
|
|
165
|
-
value:
|
|
166
|
-
},
|
|
164
|
+
path: [...r, i].map((w) => w.toString()),
|
|
165
|
+
value: f
|
|
166
|
+
}, u).then(y);
|
|
167
167
|
},
|
|
168
|
-
apply(
|
|
168
|
+
apply(o, i, c) {
|
|
169
169
|
E(n);
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
170
|
+
const f = r[r.length - 1];
|
|
171
|
+
if (f === R)
|
|
172
|
+
return d(e, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
const [
|
|
178
|
-
return
|
|
174
|
+
}).then(y);
|
|
175
|
+
if (f === "bind")
|
|
176
|
+
return P(e, t, r.slice(0, -1));
|
|
177
|
+
const [u, w] = k(c);
|
|
178
|
+
return d(e, t, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: r.map((h) => h.toString()),
|
|
181
|
-
argumentList:
|
|
182
|
-
}, w).then(
|
|
181
|
+
argumentList: u
|
|
182
|
+
}, w).then(y);
|
|
183
183
|
},
|
|
184
|
-
construct(
|
|
184
|
+
construct(o, i) {
|
|
185
185
|
E(n);
|
|
186
|
-
const [
|
|
187
|
-
return
|
|
186
|
+
const [c, f] = k(i);
|
|
187
|
+
return d(e, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
|
-
path: r.map((
|
|
190
|
-
argumentList:
|
|
191
|
-
},
|
|
189
|
+
path: r.map((u) => u.toString()),
|
|
190
|
+
argumentList: c
|
|
191
|
+
}, f).then(y);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
return
|
|
194
|
+
return X(s, e), s;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function K(e) {
|
|
197
197
|
return Array.prototype.concat.apply([], e);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const t = e.map(
|
|
201
|
-
return [t.map((r) => r[0]),
|
|
199
|
+
function k(e) {
|
|
200
|
+
const t = e.map(A);
|
|
201
|
+
return [t.map((r) => r[0]), K(t.map((r) => r[1]))];
|
|
202
202
|
}
|
|
203
|
-
const
|
|
204
|
-
function
|
|
205
|
-
return
|
|
203
|
+
const _ = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function J(e, t) {
|
|
205
|
+
return _.set(e, t), e;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return Object.assign(e, { [
|
|
207
|
+
function Q(e) {
|
|
208
|
+
return Object.assign(e, { [M]: !0 });
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (const [t, r] of
|
|
210
|
+
function A(e) {
|
|
211
|
+
for (const [t, r] of U)
|
|
212
212
|
if (r.canHandle(e)) {
|
|
213
213
|
const [a, n] = r.serialize(e);
|
|
214
214
|
return [
|
|
@@ -225,24 +225,24 @@ function S(e) {
|
|
|
225
225
|
type: "RAW",
|
|
226
226
|
value: e
|
|
227
227
|
},
|
|
228
|
-
|
|
228
|
+
_.get(e) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function y(e) {
|
|
232
232
|
switch (e.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
|
-
return
|
|
234
|
+
return U.get(e.name).deserialize(e.value);
|
|
235
235
|
case "RAW":
|
|
236
236
|
return e.value;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function d(e, t, r, a) {
|
|
240
240
|
return new Promise((n) => {
|
|
241
|
-
const
|
|
242
|
-
t.set(
|
|
241
|
+
const s = Z();
|
|
242
|
+
t.set(s, n), e.start && e.start(), e.postMessage(Object.assign({ id: s }, r), a);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Z() {
|
|
246
246
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
247
|
}
|
|
248
248
|
class l extends Error {
|
|
@@ -250,27 +250,27 @@ class l extends Error {
|
|
|
250
250
|
super(t), this.code = r, this.path = a, this.name = "OPFSError";
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
class
|
|
253
|
+
class ee extends l {
|
|
254
254
|
constructor() {
|
|
255
255
|
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED");
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
class
|
|
258
|
+
class D extends l {
|
|
259
259
|
constructor() {
|
|
260
260
|
super("OPFS is not mounted", "OPFS_NOT_MOUNTED");
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
class
|
|
263
|
+
class v extends l {
|
|
264
264
|
constructor(t, r) {
|
|
265
265
|
super(t, "INVALID_PATH", r);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
class
|
|
268
|
+
class b extends l {
|
|
269
269
|
constructor(t) {
|
|
270
270
|
super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function te(e, t = "utf-8") {
|
|
274
274
|
switch (t) {
|
|
275
275
|
case "utf8":
|
|
276
276
|
case "utf-8":
|
|
@@ -278,11 +278,11 @@ function Q(e, t = "utf-8") {
|
|
|
278
278
|
case "utf16le":
|
|
279
279
|
case "ucs2":
|
|
280
280
|
case "ucs-2":
|
|
281
|
-
return ee(e);
|
|
282
|
-
case "ascii":
|
|
283
281
|
return ne(e);
|
|
282
|
+
case "ascii":
|
|
283
|
+
return ie(e);
|
|
284
284
|
case "latin1":
|
|
285
|
-
return
|
|
285
|
+
return se(e);
|
|
286
286
|
case "binary":
|
|
287
287
|
return Uint8Array.from(e, (r) => r.charCodeAt(0));
|
|
288
288
|
case "base64":
|
|
@@ -295,7 +295,7 @@ function Q(e, t = "utf-8") {
|
|
|
295
295
|
return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(e);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function re(e, t = "utf-8") {
|
|
299
299
|
switch (t) {
|
|
300
300
|
case "utf8":
|
|
301
301
|
case "utf-8":
|
|
@@ -303,7 +303,7 @@ function Z(e, t = "utf-8") {
|
|
|
303
303
|
case "utf16le":
|
|
304
304
|
case "ucs2":
|
|
305
305
|
case "ucs-2":
|
|
306
|
-
return
|
|
306
|
+
return ae(e);
|
|
307
307
|
case "latin1":
|
|
308
308
|
return String.fromCharCode(...e);
|
|
309
309
|
case "binary":
|
|
@@ -318,7 +318,7 @@ function Z(e, t = "utf-8") {
|
|
|
318
318
|
return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(e);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function ne(e) {
|
|
322
322
|
const t = new Uint8Array(e.length * 2);
|
|
323
323
|
for (let r = 0; r < e.length; r++) {
|
|
324
324
|
const a = e.charCodeAt(r);
|
|
@@ -326,37 +326,60 @@ function ee(e) {
|
|
|
326
326
|
}
|
|
327
327
|
return t;
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function ae(e) {
|
|
330
330
|
e.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), e = e.slice(0, e.length - 1));
|
|
331
331
|
const t = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
|
|
332
332
|
return String.fromCharCode(...t);
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function se(e) {
|
|
335
335
|
const t = new Uint8Array(e.length);
|
|
336
336
|
for (let r = 0; r < e.length; r++)
|
|
337
337
|
t[r] = e.charCodeAt(r) & 255;
|
|
338
338
|
return t;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function ie(e) {
|
|
341
341
|
const t = new Uint8Array(e.length);
|
|
342
342
|
for (let r = 0; r < e.length; r++)
|
|
343
343
|
t[r] = e.charCodeAt(r) & 127;
|
|
344
344
|
return t;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function oe() {
|
|
347
347
|
if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
|
|
348
|
-
throw new
|
|
348
|
+
throw new ee();
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function m(e) {
|
|
351
351
|
return Array.isArray(e) ? e : e.split("/").filter(Boolean);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function H(e) {
|
|
354
354
|
return typeof e == "string" ? e ?? "/" : \`/\${e.join("/")}\`;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
356
|
+
function I(e) {
|
|
357
|
+
const t = m(e);
|
|
358
|
+
return t[t.length - 1] || "";
|
|
359
|
+
}
|
|
360
|
+
function x(e) {
|
|
361
|
+
const t = m(e);
|
|
362
|
+
return t.pop(), H(t);
|
|
363
|
+
}
|
|
364
|
+
function O(e) {
|
|
365
|
+
return !e || e === "/" ? "/" : e.startsWith("/") ? e : \`/\${e}\`;
|
|
366
|
+
}
|
|
367
|
+
function ce(e) {
|
|
368
|
+
const t = m(e), r = [];
|
|
369
|
+
for (const a of t)
|
|
370
|
+
if (!(a === "." || a === ""))
|
|
371
|
+
if (a === "..") {
|
|
372
|
+
if (r.length === 0)
|
|
373
|
+
continue;
|
|
374
|
+
r.pop();
|
|
375
|
+
} else
|
|
376
|
+
r.push(a);
|
|
377
|
+
return H(r);
|
|
378
|
+
}
|
|
379
|
+
function le(e, t = "utf-8") {
|
|
380
|
+
return typeof e == "string" ? te(e, t) : e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
358
381
|
}
|
|
359
|
-
async function
|
|
382
|
+
async function fe(e) {
|
|
360
383
|
const t = await e.createSyncAccessHandle();
|
|
361
384
|
try {
|
|
362
385
|
const r = t.getSize(), a = new Uint8Array(r);
|
|
@@ -365,16 +388,16 @@ async function se(e) {
|
|
|
365
388
|
t.close();
|
|
366
389
|
}
|
|
367
390
|
}
|
|
368
|
-
async function
|
|
391
|
+
async function C(e, t, r, a = {}) {
|
|
369
392
|
let n = null;
|
|
370
393
|
try {
|
|
371
394
|
n = await e.createSyncAccessHandle();
|
|
372
|
-
const
|
|
373
|
-
n.write(
|
|
374
|
-
} catch (
|
|
375
|
-
console.error(
|
|
376
|
-
const
|
|
377
|
-
throw new l(\`Failed to \${
|
|
395
|
+
const s = le(t, r), o = a.append ? n.getSize() : 0;
|
|
396
|
+
n.write(s, { at: o }), a.truncate && !a.append && n.truncate(s.byteLength), n.flush();
|
|
397
|
+
} catch (s) {
|
|
398
|
+
console.error(s);
|
|
399
|
+
const o = a.append ? "append" : "write";
|
|
400
|
+
throw new l(\`Failed to \${o} file\`, \`\${o.toUpperCase()}_FAILED\`);
|
|
378
401
|
} finally {
|
|
379
402
|
if (n)
|
|
380
403
|
try {
|
|
@@ -383,24 +406,38 @@ async function H(e, t, r, a = {}) {
|
|
|
383
406
|
}
|
|
384
407
|
}
|
|
385
408
|
}
|
|
386
|
-
async function
|
|
409
|
+
async function ue(e, t = "SHA-1") {
|
|
387
410
|
try {
|
|
388
411
|
const r = new Uint8Array(e), a = await crypto.subtle.digest(t, r);
|
|
389
|
-
return Array.from(new Uint8Array(a)).map((
|
|
412
|
+
return Array.from(new Uint8Array(a)).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
390
413
|
} catch (r) {
|
|
391
414
|
throw console.warn(\`Failed to calculate \${t} hash:\`, r), r;
|
|
392
415
|
}
|
|
393
416
|
}
|
|
394
|
-
|
|
417
|
+
async function he(e) {
|
|
418
|
+
const t = await e.arrayBuffer();
|
|
419
|
+
return new Uint8Array(t);
|
|
420
|
+
}
|
|
421
|
+
class we {
|
|
395
422
|
/** Root directory handle for the file system */
|
|
396
423
|
root = null;
|
|
424
|
+
/** Watch event callback */
|
|
425
|
+
watchCallback = null;
|
|
426
|
+
/** Map of watched paths to their last known state */
|
|
427
|
+
watchers = /* @__PURE__ */ new Map();
|
|
428
|
+
/** Interval handle for polling watched paths */
|
|
429
|
+
watchTimer = null;
|
|
430
|
+
/** Polling interval in milliseconds */
|
|
431
|
+
watchInterval = 1e3;
|
|
432
|
+
/** Flag to avoid concurrent scans */
|
|
433
|
+
scanning = !1;
|
|
397
434
|
/**
|
|
398
435
|
* Creates a new OPFSFileSystem instance
|
|
399
436
|
*
|
|
400
437
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
401
438
|
*/
|
|
402
439
|
constructor() {
|
|
403
|
-
|
|
440
|
+
oe();
|
|
404
441
|
}
|
|
405
442
|
/**
|
|
406
443
|
* Initialize the file system within a given directory
|
|
@@ -418,12 +455,12 @@ class ce {
|
|
|
418
455
|
* const success = await fs.init('/my-app');
|
|
419
456
|
* \`\`\`
|
|
420
457
|
*/
|
|
421
|
-
async mount(t = "/") {
|
|
458
|
+
async mount(t = "/", r, a) {
|
|
422
459
|
try {
|
|
423
|
-
const
|
|
424
|
-
return this.root = await this.getDirectoryHandle(t, !0, r), !0;
|
|
425
|
-
} catch (
|
|
426
|
-
throw console.error(
|
|
460
|
+
const n = await navigator.storage.getDirectory();
|
|
461
|
+
return this.root = await this.getDirectoryHandle(t, !0, n), r && (this.watchCallback = r, a?.watchInterval && (this.watchInterval = a.watchInterval)), !0;
|
|
462
|
+
} catch (n) {
|
|
463
|
+
throw console.error(n), new l("Failed to initialize OPFS", "INIT_FAILED");
|
|
427
464
|
}
|
|
428
465
|
}
|
|
429
466
|
/**
|
|
@@ -446,12 +483,12 @@ class ce {
|
|
|
446
483
|
*/
|
|
447
484
|
async getDirectoryHandle(t, r = !1, a = this.root) {
|
|
448
485
|
if (!a)
|
|
449
|
-
throw new
|
|
450
|
-
const n = Array.isArray(t) ? t :
|
|
451
|
-
let
|
|
452
|
-
for (const
|
|
453
|
-
|
|
454
|
-
return
|
|
486
|
+
throw new D();
|
|
487
|
+
const n = Array.isArray(t) ? t : m(t);
|
|
488
|
+
let s = a;
|
|
489
|
+
for (const o of n)
|
|
490
|
+
s = await s.getDirectoryHandle(o, { create: r });
|
|
491
|
+
return s;
|
|
455
492
|
}
|
|
456
493
|
/**
|
|
457
494
|
* Get a file handle from a path
|
|
@@ -474,12 +511,12 @@ class ce {
|
|
|
474
511
|
*/
|
|
475
512
|
async getFileHandle(t, r = !1, a = this.root) {
|
|
476
513
|
if (!a)
|
|
477
|
-
throw new
|
|
478
|
-
const n =
|
|
514
|
+
throw new D();
|
|
515
|
+
const n = m(t);
|
|
479
516
|
if (n.length === 0)
|
|
480
|
-
throw new
|
|
481
|
-
const
|
|
482
|
-
return (await this.getDirectoryHandle(n, r, a)).getFileHandle(
|
|
517
|
+
throw new v("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
|
|
518
|
+
const s = n.pop();
|
|
519
|
+
return (await this.getDirectoryHandle(n, r, a)).getFileHandle(s, { create: r });
|
|
483
520
|
}
|
|
484
521
|
/**
|
|
485
522
|
* Recursively list all files and directories with their stats
|
|
@@ -520,14 +557,14 @@ class ce {
|
|
|
520
557
|
*/
|
|
521
558
|
async index(t) {
|
|
522
559
|
const r = /* @__PURE__ */ new Map(), a = async (n) => {
|
|
523
|
-
const
|
|
524
|
-
for (const
|
|
525
|
-
const
|
|
560
|
+
const s = await this.readdir(n, { withFileTypes: !0 });
|
|
561
|
+
for (const o of s) {
|
|
562
|
+
const i = \`\${n === "/" ? "" : n}/\${o.name}\`;
|
|
526
563
|
try {
|
|
527
|
-
const
|
|
528
|
-
r.set(
|
|
529
|
-
} catch (
|
|
530
|
-
console.warn(\`Skipping broken entry: \${
|
|
564
|
+
const c = await this.stat(i, t);
|
|
565
|
+
r.set(i, c), c.isDirectory && await a(i);
|
|
566
|
+
} catch (c) {
|
|
567
|
+
console.warn(\`Skipping broken entry: \${i}\`, c);
|
|
531
568
|
}
|
|
532
569
|
}
|
|
533
570
|
};
|
|
@@ -542,10 +579,10 @@ class ce {
|
|
|
542
579
|
}
|
|
543
580
|
async readFile(t, r = "utf-8") {
|
|
544
581
|
try {
|
|
545
|
-
const a = await this.getFileHandle(t, !1), n = await
|
|
546
|
-
return r === "binary" ? n :
|
|
582
|
+
const a = await this.getFileHandle(t, !1), n = await fe(a);
|
|
583
|
+
return r === "binary" ? n : re(n, r);
|
|
547
584
|
} catch (a) {
|
|
548
|
-
throw console.error(a), new
|
|
585
|
+
throw console.error(a), new b(t);
|
|
549
586
|
}
|
|
550
587
|
}
|
|
551
588
|
/**
|
|
@@ -575,7 +612,7 @@ class ce {
|
|
|
575
612
|
*/
|
|
576
613
|
async writeFile(t, r, a) {
|
|
577
614
|
const n = await this.getFileHandle(t, !0);
|
|
578
|
-
await
|
|
615
|
+
await C(n, r, a, { truncate: !0 });
|
|
579
616
|
}
|
|
580
617
|
/**
|
|
581
618
|
* Append data to a file
|
|
@@ -601,7 +638,7 @@ class ce {
|
|
|
601
638
|
*/
|
|
602
639
|
async appendFile(t, r, a) {
|
|
603
640
|
const n = await this.getFileHandle(t, !0);
|
|
604
|
-
await
|
|
641
|
+
await C(n, r, a, { append: !0 });
|
|
605
642
|
}
|
|
606
643
|
/**
|
|
607
644
|
* Create a directory
|
|
@@ -626,18 +663,18 @@ class ce {
|
|
|
626
663
|
*/
|
|
627
664
|
async mkdir(t, r) {
|
|
628
665
|
if (!this.root)
|
|
629
|
-
throw new
|
|
630
|
-
const a = r?.recursive ?? !1, n =
|
|
631
|
-
let
|
|
632
|
-
for (let
|
|
633
|
-
const
|
|
666
|
+
throw new D();
|
|
667
|
+
const a = r?.recursive ?? !1, n = m(t);
|
|
668
|
+
let s = this.root;
|
|
669
|
+
for (let o = 0; o < n.length; o++) {
|
|
670
|
+
const i = n[o];
|
|
634
671
|
try {
|
|
635
|
-
|
|
636
|
-
} catch (
|
|
637
|
-
throw
|
|
638
|
-
\`Parent directory does not exist: \${
|
|
672
|
+
s = await s.getDirectoryHandle(i, { create: a || o === n.length - 1 });
|
|
673
|
+
} catch (c) {
|
|
674
|
+
throw c.name === "NotFoundError" ? new l(
|
|
675
|
+
\`Parent directory does not exist: \${H(n.slice(0, o + 1))}\`,
|
|
639
676
|
"ENOENT"
|
|
640
|
-
) :
|
|
677
|
+
) : c.name === "TypeMismatchError" ? new l(\`Path segment is not a directory: \${i}\`, "ENOTDIR") : new l("Failed to create directory", "MKDIR_FAILED");
|
|
641
678
|
}
|
|
642
679
|
}
|
|
643
680
|
}
|
|
@@ -671,22 +708,22 @@ class ce {
|
|
|
671
708
|
* \`\`\`
|
|
672
709
|
*/
|
|
673
710
|
async stat(t, r) {
|
|
674
|
-
const a =
|
|
711
|
+
const a = I(t), n = await this.getDirectoryHandle(x(t), !1), s = r?.includeHash ?? !1, o = r?.hashAlgorithm ?? "SHA-1";
|
|
675
712
|
try {
|
|
676
|
-
const
|
|
713
|
+
const c = await (await n.getFileHandle(a, { create: !1 })).getFile(), f = {
|
|
677
714
|
kind: "file",
|
|
678
|
-
size:
|
|
679
|
-
mtime: new Date(
|
|
680
|
-
ctime: new Date(
|
|
715
|
+
size: c.size,
|
|
716
|
+
mtime: new Date(c.lastModified).toISOString(),
|
|
717
|
+
ctime: new Date(c.lastModified).toISOString(),
|
|
681
718
|
isFile: !0,
|
|
682
719
|
isDirectory: !1
|
|
683
720
|
};
|
|
684
721
|
if (s)
|
|
685
722
|
try {
|
|
686
|
-
const
|
|
687
|
-
f.hash =
|
|
688
|
-
} catch (
|
|
689
|
-
console.warn(\`Failed to calculate hash for \${t}:\`,
|
|
723
|
+
const u = new Uint8Array(await c.arrayBuffer()), w = await ue(u, o);
|
|
724
|
+
f.hash = w;
|
|
725
|
+
} catch (u) {
|
|
726
|
+
console.warn(\`Failed to calculate hash for \${t}:\`, u);
|
|
690
727
|
}
|
|
691
728
|
return f;
|
|
692
729
|
} catch (i) {
|
|
@@ -694,14 +731,13 @@ class ce {
|
|
|
694
731
|
throw new l("Failed to stat (file)", "STAT_FAILED");
|
|
695
732
|
}
|
|
696
733
|
try {
|
|
697
|
-
return await
|
|
734
|
+
return await n.getDirectoryHandle(a, { create: !1 }), {
|
|
698
735
|
kind: "directory",
|
|
699
736
|
size: 0,
|
|
700
737
|
mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
701
738
|
ctime: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
702
739
|
isFile: !1,
|
|
703
740
|
isDirectory: !0
|
|
704
|
-
// Directories don't have hashes
|
|
705
741
|
};
|
|
706
742
|
} catch (i) {
|
|
707
743
|
throw i.name === "NotFoundError" ? new l(\`No such file or directory: \${t}\`, "ENOENT") : new l("Failed to stat (directory)", "STAT_FAILED");
|
|
@@ -710,22 +746,22 @@ class ce {
|
|
|
710
746
|
async readdir(t, r) {
|
|
711
747
|
const a = r?.withFileTypes ?? !1, n = await this.getDirectoryHandle(t, !1);
|
|
712
748
|
if (a) {
|
|
713
|
-
const
|
|
714
|
-
for await (const [
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
name:
|
|
718
|
-
kind:
|
|
719
|
-
isFile:
|
|
720
|
-
isDirectory: !
|
|
749
|
+
const s = [];
|
|
750
|
+
for await (const [o, i] of n.entries()) {
|
|
751
|
+
const c = i.kind === "file";
|
|
752
|
+
s.push({
|
|
753
|
+
name: o,
|
|
754
|
+
kind: i.kind,
|
|
755
|
+
isFile: c,
|
|
756
|
+
isDirectory: !c
|
|
721
757
|
});
|
|
722
758
|
}
|
|
723
|
-
return
|
|
759
|
+
return s;
|
|
724
760
|
} else {
|
|
725
|
-
const
|
|
726
|
-
for await (const [
|
|
727
|
-
|
|
728
|
-
return
|
|
761
|
+
const s = [];
|
|
762
|
+
for await (const [o] of n.entries())
|
|
763
|
+
s.push(o);
|
|
764
|
+
return s;
|
|
729
765
|
}
|
|
730
766
|
}
|
|
731
767
|
/**
|
|
@@ -743,26 +779,26 @@ class ce {
|
|
|
743
779
|
* \`\`\`
|
|
744
780
|
*/
|
|
745
781
|
async exists(t) {
|
|
746
|
-
const r =
|
|
747
|
-
let
|
|
782
|
+
const r = I(t);
|
|
783
|
+
let a = null;
|
|
748
784
|
try {
|
|
749
|
-
|
|
750
|
-
} catch (
|
|
751
|
-
throw (
|
|
785
|
+
a = await this.getDirectoryHandle(x(t), !1);
|
|
786
|
+
} catch (n) {
|
|
787
|
+
throw (n.name === "NotFoundError" || n.name === "TypeMismatchError") && (a = null), n;
|
|
752
788
|
}
|
|
753
|
-
if (!
|
|
789
|
+
if (!a || !r)
|
|
754
790
|
return !1;
|
|
755
791
|
try {
|
|
756
|
-
return await
|
|
757
|
-
} catch (
|
|
758
|
-
if (
|
|
759
|
-
throw
|
|
792
|
+
return await a.getFileHandle(r, { create: !1 }), !0;
|
|
793
|
+
} catch (n) {
|
|
794
|
+
if (n.name !== "NotFoundError" && n.name !== "TypeMismatchError")
|
|
795
|
+
throw n;
|
|
760
796
|
}
|
|
761
797
|
try {
|
|
762
|
-
return await
|
|
763
|
-
} catch (
|
|
764
|
-
if (
|
|
765
|
-
throw
|
|
798
|
+
return await a.getDirectoryHandle(r, { create: !1 }), !0;
|
|
799
|
+
} catch (n) {
|
|
800
|
+
if (n.name !== "NotFoundError" && n.name !== "TypeMismatchError")
|
|
801
|
+
throw n;
|
|
766
802
|
}
|
|
767
803
|
return !1;
|
|
768
804
|
}
|
|
@@ -821,12 +857,12 @@ class ce {
|
|
|
821
857
|
* \`\`\`
|
|
822
858
|
*/
|
|
823
859
|
async remove(t, r) {
|
|
824
|
-
const a = r?.recursive ?? !1, n = r?.force ?? !1,
|
|
860
|
+
const a = r?.recursive ?? !1, n = r?.force ?? !1, s = I(t);
|
|
825
861
|
if (!s)
|
|
826
|
-
throw new
|
|
827
|
-
const
|
|
862
|
+
throw new v("Invalid path", t);
|
|
863
|
+
const o = await this.getDirectoryHandle(x(t), !1);
|
|
828
864
|
try {
|
|
829
|
-
await
|
|
865
|
+
await o.removeEntry(s, { recursive: a });
|
|
830
866
|
} catch (i) {
|
|
831
867
|
if (i.name === "NotFoundError") {
|
|
832
868
|
if (!n)
|
|
@@ -854,19 +890,10 @@ class ce {
|
|
|
854
890
|
*/
|
|
855
891
|
async realpath(t) {
|
|
856
892
|
try {
|
|
857
|
-
const r =
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (a.length === 0)
|
|
862
|
-
throw new l("Path escapes root", "EINVAL");
|
|
863
|
-
a.length > 0 && a.pop();
|
|
864
|
-
} else
|
|
865
|
-
a.push(s);
|
|
866
|
-
const n = P(a);
|
|
867
|
-
if (!await this.exists(n))
|
|
868
|
-
throw new x(n);
|
|
869
|
-
return n;
|
|
893
|
+
const r = ce(t);
|
|
894
|
+
if (!await this.exists(r))
|
|
895
|
+
throw new b(r);
|
|
896
|
+
return r;
|
|
870
897
|
} catch (r) {
|
|
871
898
|
throw r instanceof l ? r : new l(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED");
|
|
872
899
|
}
|
|
@@ -890,7 +917,7 @@ class ce {
|
|
|
890
917
|
async rename(t, r) {
|
|
891
918
|
try {
|
|
892
919
|
if (!await this.exists(t))
|
|
893
|
-
throw new
|
|
920
|
+
throw new b(t);
|
|
894
921
|
await this.copy(t, r, { recursive: !0 }), await this.remove(t, { recursive: !0 });
|
|
895
922
|
} catch (a) {
|
|
896
923
|
throw a instanceof l ? a : new l(\`Failed to rename from \${t} to \${r}\`, "RENAME_FAILED");
|
|
@@ -923,28 +950,87 @@ class ce {
|
|
|
923
950
|
*/
|
|
924
951
|
async copy(t, r, a) {
|
|
925
952
|
try {
|
|
926
|
-
const n = a?.recursive ?? !1,
|
|
953
|
+
const n = a?.recursive ?? !1, s = a?.force ?? !0;
|
|
927
954
|
if (!await this.exists(t))
|
|
928
955
|
throw new l(\`Source does not exist: \${t}\`, "ENOENT");
|
|
929
|
-
if (await this.exists(r) && !
|
|
956
|
+
if (await this.exists(r) && !s)
|
|
930
957
|
throw new l(\`Destination already exists: \${r}\`, "EEXIST");
|
|
931
958
|
if ((await this.stat(t)).isFile) {
|
|
932
|
-
const
|
|
933
|
-
await this.writeFile(r,
|
|
959
|
+
const f = await this.readFile(t, "binary");
|
|
960
|
+
await this.writeFile(r, f);
|
|
934
961
|
} else {
|
|
935
962
|
if (!n)
|
|
936
963
|
throw new l(\`Cannot copy directory without recursive option: \${t}\`, "EISDIR");
|
|
937
964
|
await this.mkdir(r, { recursive: !0 });
|
|
938
|
-
const
|
|
939
|
-
for (const
|
|
940
|
-
const w = \`\${t}/\${
|
|
941
|
-
await this.copy(w, h, { recursive: !0, force:
|
|
965
|
+
const f = await this.readdir(t, { withFileTypes: !0 });
|
|
966
|
+
for (const u of f) {
|
|
967
|
+
const w = \`\${t}/\${u.name}\`, h = \`\${r}/\${u.name}\`;
|
|
968
|
+
await this.copy(w, h, { recursive: !0, force: s });
|
|
942
969
|
}
|
|
943
970
|
}
|
|
944
971
|
} catch (n) {
|
|
945
972
|
throw n instanceof l ? n : new l(\`Failed to copy from \${t} to \${r}\`, "CP_FAILED");
|
|
946
973
|
}
|
|
947
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* Start watching a file or directory for changes
|
|
977
|
+
*/
|
|
978
|
+
async watch(t) {
|
|
979
|
+
const r = O(t), a = await this.buildSnapshot(r);
|
|
980
|
+
this.watchers.set(r, a), this.watchTimer || (this.watchTimer = setInterval(() => {
|
|
981
|
+
this.scanWatches();
|
|
982
|
+
}, this.watchInterval));
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Stop watching a previously watched path
|
|
986
|
+
*/
|
|
987
|
+
unwatch(t) {
|
|
988
|
+
const r = O(t);
|
|
989
|
+
this.watchers.delete(r), this.watchers.size === 0 && this.watchTimer && (clearInterval(this.watchTimer), this.watchTimer = null);
|
|
990
|
+
}
|
|
991
|
+
async buildSnapshot(t) {
|
|
992
|
+
const r = /* @__PURE__ */ new Map(), a = async (n) => {
|
|
993
|
+
const s = await this.stat(n);
|
|
994
|
+
if (r.set(n, s), s.isDirectory) {
|
|
995
|
+
const o = await this.readdir(n, { withFileTypes: !0 });
|
|
996
|
+
for (const i of o) {
|
|
997
|
+
const c = \`\${n === "/" ? "" : n}/\${i.name}\`;
|
|
998
|
+
await a(c);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
return await a(t), r;
|
|
1003
|
+
}
|
|
1004
|
+
async scanWatches() {
|
|
1005
|
+
if (!this.scanning) {
|
|
1006
|
+
this.scanning = !0;
|
|
1007
|
+
try {
|
|
1008
|
+
await Promise.all(
|
|
1009
|
+
[...this.watchers.entries()].map(async ([t, r]) => {
|
|
1010
|
+
let a;
|
|
1011
|
+
try {
|
|
1012
|
+
a = await this.buildSnapshot(t);
|
|
1013
|
+
} catch {
|
|
1014
|
+
a = /* @__PURE__ */ new Map();
|
|
1015
|
+
}
|
|
1016
|
+
const n = [];
|
|
1017
|
+
for (const [s, o] of a) {
|
|
1018
|
+
const i = r.get(s);
|
|
1019
|
+
i ? (i.mtime !== o.mtime || i.size !== o.size) && n.push({ path: s, type: "change" }) : n.push({ path: s, type: "create" });
|
|
1020
|
+
}
|
|
1021
|
+
for (const s of r.keys())
|
|
1022
|
+
a.has(s) || n.push({ path: s, type: "delete" });
|
|
1023
|
+
if (n.length && this.watchCallback)
|
|
1024
|
+
for (const s of n)
|
|
1025
|
+
this.watchCallback(s);
|
|
1026
|
+
this.watchers.set(t, a);
|
|
1027
|
+
})
|
|
1028
|
+
);
|
|
1029
|
+
} finally {
|
|
1030
|
+
this.scanning = !1;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
948
1034
|
/**
|
|
949
1035
|
* Synchronize the file system with external data
|
|
950
1036
|
*
|
|
@@ -976,22 +1062,17 @@ class ce {
|
|
|
976
1062
|
async sync(t, r) {
|
|
977
1063
|
try {
|
|
978
1064
|
(r?.cleanBefore ?? !1) && await this.clear("/");
|
|
979
|
-
for (const [n,
|
|
980
|
-
const
|
|
981
|
-
let
|
|
982
|
-
|
|
983
|
-
const i = await o.arrayBuffer();
|
|
984
|
-
c = new Uint8Array(i);
|
|
985
|
-
} else
|
|
986
|
-
c = o;
|
|
987
|
-
await this.writeFile(s, c);
|
|
1065
|
+
for (const [n, s] of t) {
|
|
1066
|
+
const o = O(n);
|
|
1067
|
+
let i;
|
|
1068
|
+
s instanceof Blob ? i = await he(s) : i = s, await this.writeFile(o, i);
|
|
988
1069
|
}
|
|
989
1070
|
} catch (a) {
|
|
990
1071
|
throw a instanceof l ? a : new l("Failed to sync file system", "SYNC_FAILED");
|
|
991
1072
|
}
|
|
992
1073
|
}
|
|
993
1074
|
}
|
|
994
|
-
|
|
995
|
-
//# sourceMappingURL=worker-
|
|
996
|
-
`,
|
|
1075
|
+
typeof self < "u" && self.constructor.name === "DedicatedWorkerGlobalScope" && N(new we());
|
|
1076
|
+
//# sourceMappingURL=worker-ChfzBM-o.js.map
|
|
1077
|
+
`,a=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",i],{type:"text/javascript;charset=utf-8"});function s(r){let e;try{if(e=a&&(self.URL||self.webkitURL).createObjectURL(a),!e)throw"";const t=new Worker(e,{type:"module",name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(i),{type:"module",name:r?.name})}}function c(){return o.wrap(new s)}exports.DirectoryNotFoundError=n.DirectoryNotFoundError;exports.FileNotFoundError=n.FileNotFoundError;exports.OPFSError=n.OPFSError;exports.OPFSNotMountedError=n.OPFSNotMountedError;exports.OPFSNotSupportedError=n.OPFSNotSupportedError;exports.PathError=n.PathError;exports.PermissionError=n.PermissionError;exports.StorageError=n.StorageError;exports.TimeoutError=n.TimeoutError;exports.basename=n.basename;exports.calculateFileHash=n.calculateFileHash;exports.checkOPFSSupport=n.checkOPFSSupport;exports.convertBlobToUint8Array=n.convertBlobToUint8Array;exports.createBuffer=n.createBuffer;exports.decodeBuffer=n.decodeBuffer;exports.dirname=n.dirname;exports.encodeString=n.encodeString;exports.extname=n.extname;exports.joinPath=n.joinPath;exports.normalizePath=n.normalizePath;exports.readFileData=n.readFileData;exports.resolvePath=n.resolvePath;exports.splitPath=n.splitPath;exports.writeFileData=n.writeFileData;exports.createWorker=c;
|
|
997
1078
|
//# sourceMappingURL=index.cjs.map
|