opfs-worker 0.2.3 → 0.2.4
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 +5 -3
- package/dist/assets/worker-DCm4BiWM.js.map +1 -0
- package/dist/index.cjs +79 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +99 -79
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +48 -28
- package/dist/raw.js.map +1 -1
- package/dist/worker.d.ts +10 -0
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-CRHhlrlS.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
const H = Symbol("Comlink.proxy"), R = Symbol("Comlink.endpoint"), B = Symbol("Comlink.releaseProxy"),
|
|
6
|
+
const H = Symbol("Comlink.proxy"), R = Symbol("Comlink.endpoint"), B = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), p = Symbol("Comlink.thrown"), $ = (t) => typeof t == "object" && t !== null || typeof t == "function", W = {
|
|
7
7
|
canHandle: (t) => $(t) && t[H],
|
|
8
8
|
serialize(t) {
|
|
9
9
|
const { port1: e, port2: r } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return O(t, e), [r, [r]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(t) {
|
|
13
13
|
return t.start(), Y(t);
|
|
@@ -38,7 +38,7 @@ function V(t, e) {
|
|
|
38
38
|
return !0;
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function O(t, e = globalThis, r = ["*"]) {
|
|
42
42
|
e.addEventListener("message", function a(n) {
|
|
43
43
|
if (!n || !n.data)
|
|
44
44
|
return;
|
|
@@ -46,7 +46,7 @@ function x(t, e = globalThis, r = ["*"]) {
|
|
|
46
46
|
console.warn(\`Invalid origin '\${n.origin}' for comlink proxy\`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const { id: i, type: o, path: s } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(
|
|
49
|
+
const { id: i, type: o, path: s } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(y);
|
|
50
50
|
let u;
|
|
51
51
|
try {
|
|
52
52
|
const f = s.slice(0, -1).reduce((h, g) => h[g], t), w = s.reduce((h, g) => h[g], t);
|
|
@@ -55,7 +55,7 @@ function x(t, e = globalThis, r = ["*"]) {
|
|
|
55
55
|
u = w;
|
|
56
56
|
break;
|
|
57
57
|
case "SET":
|
|
58
|
-
f[s.slice(-1)[0]] =
|
|
58
|
+
f[s.slice(-1)[0]] = y(n.data.value), u = !0;
|
|
59
59
|
break;
|
|
60
60
|
case "APPLY":
|
|
61
61
|
u = w.apply(f, l);
|
|
@@ -69,7 +69,7 @@ function x(t, e = globalThis, r = ["*"]) {
|
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: h, port2: g } = new MessageChannel();
|
|
72
|
-
|
|
72
|
+
O(t, g), u = J(h, [h]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -83,7 +83,7 @@ function x(t, e = globalThis, r = ["*"]) {
|
|
|
83
83
|
}
|
|
84
84
|
Promise.resolve(u).catch((f) => ({ value: f, [p]: 0 })).then((f) => {
|
|
85
85
|
const [w, h] = A(f);
|
|
86
|
-
e.postMessage(Object.assign(Object.assign({}, w), { id: i }), h), o === "RELEASE" && (e.removeEventListener("message", a), L(e),
|
|
86
|
+
e.postMessage(Object.assign(Object.assign({}, w), { id: i }), h), o === "RELEASE" && (e.removeEventListener("message", a), L(e), I in t && typeof t[I] == "function" && t[I]());
|
|
87
87
|
}).catch((f) => {
|
|
88
88
|
const [w, h] = A({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
@@ -112,14 +112,14 @@ function Y(t, e) {
|
|
|
112
112
|
} finally {
|
|
113
113
|
r.delete(i.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), P(t, r, [], e);
|
|
116
116
|
}
|
|
117
117
|
function E(t) {
|
|
118
118
|
if (t)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
121
|
function z(t) {
|
|
122
|
-
return
|
|
122
|
+
return d(t, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
125
125
|
L(t);
|
|
@@ -136,7 +136,7 @@ function X(t, e) {
|
|
|
136
136
|
function q(t) {
|
|
137
137
|
S && S.unregister(t);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function P(t, e, r = [], a = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let n = !1;
|
|
142
142
|
const i = new Proxy(a, {
|
|
@@ -148,47 +148,47 @@ function O(t, e, r = [], a = function() {
|
|
|
148
148
|
if (s === "then") {
|
|
149
149
|
if (r.length === 0)
|
|
150
150
|
return { then: () => i };
|
|
151
|
-
const l =
|
|
151
|
+
const l = d(t, e, {
|
|
152
152
|
type: "GET",
|
|
153
153
|
path: r.map((u) => u.toString())
|
|
154
|
-
}).then(
|
|
154
|
+
}).then(y);
|
|
155
155
|
return l.then.bind(l);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return P(t, e, [...r, s]);
|
|
158
158
|
},
|
|
159
159
|
set(o, s, l) {
|
|
160
160
|
E(n);
|
|
161
161
|
const [u, f] = A(l);
|
|
162
|
-
return
|
|
162
|
+
return d(t, e, {
|
|
163
163
|
type: "SET",
|
|
164
164
|
path: [...r, s].map((w) => w.toString()),
|
|
165
165
|
value: u
|
|
166
|
-
}, f).then(
|
|
166
|
+
}, f).then(y);
|
|
167
167
|
},
|
|
168
168
|
apply(o, s, l) {
|
|
169
169
|
E(n);
|
|
170
170
|
const u = r[r.length - 1];
|
|
171
171
|
if (u === R)
|
|
172
|
-
return
|
|
172
|
+
return d(t, e, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
|
-
}).then(
|
|
174
|
+
}).then(y);
|
|
175
175
|
if (u === "bind")
|
|
176
|
-
return
|
|
177
|
-
const [f, w] =
|
|
178
|
-
return
|
|
176
|
+
return P(t, e, r.slice(0, -1));
|
|
177
|
+
const [f, w] = k(l);
|
|
178
|
+
return d(t, e, {
|
|
179
179
|
type: "APPLY",
|
|
180
180
|
path: r.map((h) => h.toString()),
|
|
181
181
|
argumentList: f
|
|
182
|
-
}, w).then(
|
|
182
|
+
}, w).then(y);
|
|
183
183
|
},
|
|
184
184
|
construct(o, s) {
|
|
185
185
|
E(n);
|
|
186
|
-
const [l, u] =
|
|
187
|
-
return
|
|
186
|
+
const [l, u] = k(s);
|
|
187
|
+
return d(t, e, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
189
189
|
path: r.map((f) => f.toString()),
|
|
190
190
|
argumentList: l
|
|
191
|
-
}, u).then(
|
|
191
|
+
}, u).then(y);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
return X(i, t), i;
|
|
@@ -196,7 +196,7 @@ function O(t, e, r = [], a = function() {
|
|
|
196
196
|
function K(t) {
|
|
197
197
|
return Array.prototype.concat.apply([], t);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function k(t) {
|
|
200
200
|
const e = t.map(A);
|
|
201
201
|
return [e.map((r) => r[0]), K(e.map((r) => r[1]))];
|
|
202
202
|
}
|
|
@@ -228,7 +228,7 @@ function A(t) {
|
|
|
228
228
|
_.get(t) || []
|
|
229
229
|
];
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function y(t) {
|
|
232
232
|
switch (t.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
234
|
return U.get(t.name).deserialize(t.value);
|
|
@@ -236,7 +236,7 @@ function d(t) {
|
|
|
236
236
|
return t.value;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function d(t, e, r, a) {
|
|
240
240
|
return new Promise((n) => {
|
|
241
241
|
const i = Z();
|
|
242
242
|
e.set(i, n), t.start && t.start(), t.postMessage(Object.assign({ id: i }, r), a);
|
|
@@ -255,17 +255,17 @@ class ee extends c {
|
|
|
255
255
|
super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED");
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
class
|
|
258
|
+
class T extends c {
|
|
259
259
|
constructor() {
|
|
260
260
|
super("OPFS is not mounted", "OPFS_NOT_MOUNTED");
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
class
|
|
263
|
+
class v extends c {
|
|
264
264
|
constructor(e, r) {
|
|
265
265
|
super(e, "INVALID_PATH", r);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
class
|
|
268
|
+
class D extends c {
|
|
269
269
|
constructor(e) {
|
|
270
270
|
super(\`File not found: \${e}\`, "FILE_NOT_FOUND", e);
|
|
271
271
|
}
|
|
@@ -350,18 +350,18 @@ function oe() {
|
|
|
350
350
|
function m(t) {
|
|
351
351
|
return Array.isArray(t) ? t : t.split("/").filter(Boolean);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function x(t) {
|
|
354
354
|
return typeof t == "string" ? t ?? "/" : \`/\${t.join("/")}\`;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function b(t) {
|
|
357
357
|
const e = m(t);
|
|
358
358
|
return e[e.length - 1] || "";
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function M(t) {
|
|
361
361
|
const e = m(t);
|
|
362
|
-
return e.pop(),
|
|
362
|
+
return e.pop(), x(e);
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function C(t) {
|
|
365
365
|
return !t || t === "/" ? "/" : t.startsWith("/") ? t : \`/\${t}\`;
|
|
366
366
|
}
|
|
367
367
|
function ce(t) {
|
|
@@ -374,7 +374,7 @@ function ce(t) {
|
|
|
374
374
|
r.pop();
|
|
375
375
|
} else
|
|
376
376
|
r.push(a);
|
|
377
|
-
return
|
|
377
|
+
return x(r);
|
|
378
378
|
}
|
|
379
379
|
function le(t, e = "utf-8") {
|
|
380
380
|
return typeof t == "string" ? te(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
@@ -388,7 +388,7 @@ async function ue(t) {
|
|
|
388
388
|
e.close();
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
async function
|
|
391
|
+
async function N(t, e, r, a = {}) {
|
|
392
392
|
let n = null;
|
|
393
393
|
try {
|
|
394
394
|
n = await t.createSyncAccessHandle();
|
|
@@ -433,6 +433,21 @@ class we {
|
|
|
433
433
|
scanning = !1;
|
|
434
434
|
/** Promise to prevent concurrent mount operations */
|
|
435
435
|
mountingPromise = null;
|
|
436
|
+
/**
|
|
437
|
+
* Notify about internal changes to the file system
|
|
438
|
+
*
|
|
439
|
+
* This method is called by internal operations to notify clients about
|
|
440
|
+
* changes, even when no specific paths are being watched.
|
|
441
|
+
*
|
|
442
|
+
* @param path - The path that was changed
|
|
443
|
+
* @param type - The type of change (create, change, delete)
|
|
444
|
+
*/
|
|
445
|
+
notifyInternalChange(e, r) {
|
|
446
|
+
this.watchCallback && this.watchCallback({
|
|
447
|
+
path: e,
|
|
448
|
+
type: r
|
|
449
|
+
});
|
|
450
|
+
}
|
|
436
451
|
/**
|
|
437
452
|
* Creates a new OPFSFileSystem instance
|
|
438
453
|
*
|
|
@@ -524,7 +539,7 @@ class we {
|
|
|
524
539
|
*/
|
|
525
540
|
async getDirectoryHandle(e, r = !1, a = this.root) {
|
|
526
541
|
if (!a)
|
|
527
|
-
throw new
|
|
542
|
+
throw new T();
|
|
528
543
|
const n = Array.isArray(e) ? e : m(e);
|
|
529
544
|
let i = a;
|
|
530
545
|
for (const o of n)
|
|
@@ -552,10 +567,10 @@ class we {
|
|
|
552
567
|
*/
|
|
553
568
|
async getFileHandle(e, r = !1, a = this.root) {
|
|
554
569
|
if (!a)
|
|
555
|
-
throw new
|
|
570
|
+
throw new T();
|
|
556
571
|
const n = m(e);
|
|
557
572
|
if (n.length === 0)
|
|
558
|
-
throw new
|
|
573
|
+
throw new v("Path must not be empty", Array.isArray(e) ? e.join("/") : e);
|
|
559
574
|
const i = n.pop();
|
|
560
575
|
return (await this.getDirectoryHandle(n, r, a)).getFileHandle(i, { create: r });
|
|
561
576
|
}
|
|
@@ -624,7 +639,7 @@ class we {
|
|
|
624
639
|
const a = await this.getFileHandle(e, !1), n = await ue(a);
|
|
625
640
|
return r === "binary" ? n : re(n, r);
|
|
626
641
|
} catch (a) {
|
|
627
|
-
throw console.error(a), new
|
|
642
|
+
throw console.error(a), new D(e);
|
|
628
643
|
}
|
|
629
644
|
}
|
|
630
645
|
/**
|
|
@@ -655,7 +670,7 @@ class we {
|
|
|
655
670
|
async writeFile(e, r, a) {
|
|
656
671
|
await this.ensureMounted();
|
|
657
672
|
const n = await this.getFileHandle(e, !0);
|
|
658
|
-
await
|
|
673
|
+
await N(n, r, a, { truncate: !0 }), this.notifyInternalChange(e, "change");
|
|
659
674
|
}
|
|
660
675
|
/**
|
|
661
676
|
* Append data to a file
|
|
@@ -682,7 +697,7 @@ class we {
|
|
|
682
697
|
async appendFile(e, r, a) {
|
|
683
698
|
await this.ensureMounted();
|
|
684
699
|
const n = await this.getFileHandle(e, !0);
|
|
685
|
-
await
|
|
700
|
+
await N(n, r, a, { append: !0 }), this.notifyInternalChange(e, "change");
|
|
686
701
|
}
|
|
687
702
|
/**
|
|
688
703
|
* Create a directory
|
|
@@ -707,7 +722,7 @@ class we {
|
|
|
707
722
|
*/
|
|
708
723
|
async mkdir(e, r) {
|
|
709
724
|
if (await this.ensureMounted(), !this.root)
|
|
710
|
-
throw new
|
|
725
|
+
throw new T();
|
|
711
726
|
const a = r?.recursive ?? !1, n = m(e);
|
|
712
727
|
let i = this.root;
|
|
713
728
|
for (let o = 0; o < n.length; o++) {
|
|
@@ -716,11 +731,12 @@ class we {
|
|
|
716
731
|
i = await i.getDirectoryHandle(s, { create: a || o === n.length - 1 });
|
|
717
732
|
} catch (l) {
|
|
718
733
|
throw l.name === "NotFoundError" ? new c(
|
|
719
|
-
\`Parent directory does not exist: \${
|
|
734
|
+
\`Parent directory does not exist: \${x(n.slice(0, o + 1))}\`,
|
|
720
735
|
"ENOENT"
|
|
721
736
|
) : l.name === "TypeMismatchError" ? new c(\`Path segment is not a directory: \${s}\`, "ENOTDIR") : new c("Failed to create directory", "MKDIR_FAILED");
|
|
722
737
|
}
|
|
723
738
|
}
|
|
739
|
+
this.notifyInternalChange(e, "create");
|
|
724
740
|
}
|
|
725
741
|
/**
|
|
726
742
|
* Get file or directory stats
|
|
@@ -761,7 +777,7 @@ class we {
|
|
|
761
777
|
isFile: !1,
|
|
762
778
|
isDirectory: !0
|
|
763
779
|
};
|
|
764
|
-
const a =
|
|
780
|
+
const a = b(e), n = await this.getDirectoryHandle(M(e), !1), i = r?.includeHash ?? !1, o = r?.hashAlgorithm ?? "SHA-1";
|
|
765
781
|
try {
|
|
766
782
|
const l = await (await n.getFileHandle(a, { create: !1 })).getFile(), u = {
|
|
767
783
|
kind: "file",
|
|
@@ -835,10 +851,10 @@ class we {
|
|
|
835
851
|
async exists(e) {
|
|
836
852
|
if (await this.ensureMounted(), e === "/")
|
|
837
853
|
return !0;
|
|
838
|
-
const r =
|
|
854
|
+
const r = b(e);
|
|
839
855
|
let a = null;
|
|
840
856
|
try {
|
|
841
|
-
a = await this.getDirectoryHandle(
|
|
857
|
+
a = await this.getDirectoryHandle(M(e), !1);
|
|
842
858
|
} catch (n) {
|
|
843
859
|
throw (n.name === "NotFoundError" || n.name === "TypeMismatchError") && (a = null), n;
|
|
844
860
|
}
|
|
@@ -885,6 +901,7 @@ class we {
|
|
|
885
901
|
const n = \`\${e === "/" ? "" : e}/\${a.name}\`;
|
|
886
902
|
await this.remove(n, { recursive: !0 });
|
|
887
903
|
}
|
|
904
|
+
this.notifyInternalChange(e, "change");
|
|
888
905
|
} catch (r) {
|
|
889
906
|
throw r instanceof c ? r : new c(\`Failed to clear directory: \${e}\`, "CLEAR_FAILED");
|
|
890
907
|
}
|
|
@@ -918,10 +935,10 @@ class we {
|
|
|
918
935
|
const a = r?.recursive ?? !1, n = r?.force ?? !1;
|
|
919
936
|
if (e === "/")
|
|
920
937
|
throw new c("Cannot remove root directory", "EROOT");
|
|
921
|
-
const i =
|
|
938
|
+
const i = b(e);
|
|
922
939
|
if (!i)
|
|
923
|
-
throw new
|
|
924
|
-
const o = await this.getDirectoryHandle(
|
|
940
|
+
throw new v("Invalid path", e);
|
|
941
|
+
const o = await this.getDirectoryHandle(M(e), !1);
|
|
925
942
|
try {
|
|
926
943
|
await o.removeEntry(i, { recursive: a });
|
|
927
944
|
} catch (s) {
|
|
@@ -930,6 +947,7 @@ class we {
|
|
|
930
947
|
throw new c(\`No such file or directory: \${e}\`, "ENOENT");
|
|
931
948
|
} else throw s.name === "InvalidModificationError" ? new c(\`Directory not empty: \${e}. Use recursive option to force removal.\`, "ENOTEMPTY") : s.name === "TypeMismatchError" && !a ? new c(\`Cannot remove directory without recursive option: \${e}\`, "EISDIR") : new c(\`Failed to remove path: \${e}\`, "RM_FAILED");
|
|
932
949
|
}
|
|
950
|
+
this.notifyInternalChange(e, "delete");
|
|
933
951
|
}
|
|
934
952
|
/**
|
|
935
953
|
* Resolve a path to an absolute path
|
|
@@ -954,7 +972,7 @@ class we {
|
|
|
954
972
|
try {
|
|
955
973
|
const r = ce(e);
|
|
956
974
|
if (!await this.exists(r))
|
|
957
|
-
throw new
|
|
975
|
+
throw new D(r);
|
|
958
976
|
return r;
|
|
959
977
|
} catch (r) {
|
|
960
978
|
throw r instanceof c ? r : new c(\`Failed to resolve path: \${e}\`, "REALPATH_FAILED");
|
|
@@ -980,8 +998,8 @@ class we {
|
|
|
980
998
|
await this.ensureMounted();
|
|
981
999
|
try {
|
|
982
1000
|
if (!await this.exists(e))
|
|
983
|
-
throw new
|
|
984
|
-
await this.copy(e, r, { recursive: !0 }), await this.remove(e, { recursive: !0 });
|
|
1001
|
+
throw new D(e);
|
|
1002
|
+
await this.copy(e, r, { recursive: !0 }), await this.remove(e, { recursive: !0 }), this.notifyInternalChange(e, "delete"), this.notifyInternalChange(r, "create");
|
|
985
1003
|
} catch (a) {
|
|
986
1004
|
throw a instanceof c ? a : new c(\`Failed to rename from \${e} to \${r}\`, "RENAME_FAILED");
|
|
987
1005
|
}
|
|
@@ -1032,6 +1050,7 @@ class we {
|
|
|
1032
1050
|
await this.copy(w, h, { recursive: !0, force: i });
|
|
1033
1051
|
}
|
|
1034
1052
|
}
|
|
1053
|
+
this.notifyInternalChange(r, "create");
|
|
1035
1054
|
} catch (n) {
|
|
1036
1055
|
throw n instanceof c ? n : new c(\`Failed to copy from \${e} to \${r}\`, "CP_FAILED");
|
|
1037
1056
|
}
|
|
@@ -1041,7 +1060,7 @@ class we {
|
|
|
1041
1060
|
*/
|
|
1042
1061
|
async watch(e) {
|
|
1043
1062
|
await this.ensureMounted();
|
|
1044
|
-
const r =
|
|
1063
|
+
const r = C(e), a = await this.buildSnapshot(r);
|
|
1045
1064
|
this.watchers.set(r, a), this.watchTimer || (this.watchTimer = setInterval(() => {
|
|
1046
1065
|
this.scanWatches();
|
|
1047
1066
|
}, this.watchInterval));
|
|
@@ -1050,7 +1069,7 @@ class we {
|
|
|
1050
1069
|
* Stop watching a previously watched path
|
|
1051
1070
|
*/
|
|
1052
1071
|
unwatch(e) {
|
|
1053
|
-
const r =
|
|
1072
|
+
const r = C(e);
|
|
1054
1073
|
this.watchers.delete(r), this.watchers.size === 0 && this.watchTimer && (clearInterval(this.watchTimer), this.watchTimer = null);
|
|
1055
1074
|
}
|
|
1056
1075
|
async buildSnapshot(e) {
|
|
@@ -1129,16 +1148,17 @@ class we {
|
|
|
1129
1148
|
try {
|
|
1130
1149
|
(r?.cleanBefore ?? !1) && await this.clear("/");
|
|
1131
1150
|
for (const [n, i] of e) {
|
|
1132
|
-
const o =
|
|
1151
|
+
const o = C(n);
|
|
1133
1152
|
let s;
|
|
1134
1153
|
i instanceof Blob ? s = await he(i) : s = i, await this.writeFile(o, s);
|
|
1135
1154
|
}
|
|
1155
|
+
this.notifyInternalChange("/", "change");
|
|
1136
1156
|
} catch (a) {
|
|
1137
1157
|
throw a instanceof c ? a : new c("Failed to sync file system", "SYNC_FAILED");
|
|
1138
1158
|
}
|
|
1139
1159
|
}
|
|
1140
1160
|
}
|
|
1141
|
-
typeof self < "u" && self.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
1142
|
-
//# sourceMappingURL=worker-
|
|
1161
|
+
typeof self < "u" && self.constructor.name === "DedicatedWorkerGlobalScope" && O(new we());
|
|
1162
|
+
//# sourceMappingURL=worker-DCm4BiWM.js.map
|
|
1143
1163
|
`,i=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",o],{type:"text/javascript;charset=utf-8"});function s(r){let e;try{if(e=i&&(self.URL||self.webkitURL).createObjectURL(i),!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(o),{type:"module",name:r?.name})}}function c(r,e){const t=a.wrap(new s);return r&&t.setWatchCallback(a.proxy(r),e),t}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;
|
|
1144
1164
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { wrap, proxy } from 'comlink';\n\nimport WorkerCtor from './worker?worker&inline';\n\nimport type { OPFSWorker, RemoteOPFSWorker, WatchEvent } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\n\n/**\n * Creates a new file system instance with inline worker\n * @param watchCallback - Optional callback for file change events\n * @param watchOptions - Optional configuration for watching\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n watchCallback?: (event: WatchEvent) => void,\n watchOptions?: { watchInterval?: number }\n): RemoteOPFSWorker {\n const wrapped = wrap<OPFSWorker>(new WorkerCtor());\n \n // Set up watch callback if provided\n if (watchCallback) {\n wrapped.setWatchCallback(proxy(watchCallback), watchOptions);\n }\n \n return wrapped;\n}\n"],"names":["createWorker","watchCallback","watchOptions","wrapped","wrap","WorkerCtor","proxy"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { wrap, proxy } from 'comlink';\n\nimport WorkerCtor from './worker?worker&inline';\n\nimport type { OPFSWorker, RemoteOPFSWorker, WatchEvent } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\n\n/**\n * Creates a new file system instance with inline worker\n * @param watchCallback - Optional callback for file change events\n * @param watchOptions - Optional configuration for watching\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n watchCallback?: (event: WatchEvent) => void,\n watchOptions?: { watchInterval?: number }\n): RemoteOPFSWorker {\n const wrapped = wrap<OPFSWorker>(new WorkerCtor());\n \n // Set up watch callback if provided\n if (watchCallback) {\n wrapped.setWatchCallback(proxy(watchCallback), watchOptions);\n }\n \n return wrapped;\n}\n"],"names":["createWorker","watchCallback","watchOptions","wrapped","wrap","WorkerCtor","proxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qdAiBO,SAASA,EACZC,EACAC,EACgB,CAChB,MAAMC,EAAUC,EAAAA,KAAiB,IAAIC,CAAY,EAGjD,OAAIJ,GACAE,EAAQ,iBAAiBG,EAAAA,MAAML,CAAa,EAAGC,CAAY,EAGxDC,CACX"}
|