opfs-worker 0.2.5 → 0.2.6
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 +150 -35
- package/dist/assets/worker-CHy3JxL1.js.map +1 -0
- package/dist/{helpers-3TGPHd1h.js → helpers-C0nyU6hv.js} +58 -61
- package/dist/{helpers-3TGPHd1h.js.map → helpers-C0nyU6hv.js.map} +1 -1
- package/dist/helpers-FvdHLObV.cjs +2 -0
- package/dist/{helpers-DjY2OR7f.cjs.map → helpers-FvdHLObV.cjs.map} +1 -1
- package/dist/index.cjs +60 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -64
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +22 -18
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +4 -2
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts +8 -14
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-BL3varjN.js.map +0 -1
- package/dist/helpers-DjY2OR7f.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("comlink"),n=require("./helpers-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("comlink"),n=require("./helpers-FvdHLObV.cjs"),o=`/**
|
|
2
2
|
* @license
|
|
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"), D = Symbol("Comlink.finalizer"),
|
|
6
|
+
const H = Symbol("Comlink.proxy"), R = Symbol("Comlink.endpoint"), B = Symbol("Comlink.releaseProxy"), D = Symbol("Comlink.finalizer"), E = Symbol("Comlink.thrown"), $ = (e) => typeof e == "object" && e !== null || typeof e == "function", W = {
|
|
7
7
|
canHandle: (e) => $(e) && e[H],
|
|
8
8
|
serialize(e) {
|
|
9
9
|
const { port1: t, port2: r } = new MessageChannel();
|
|
10
|
-
return
|
|
10
|
+
return I(e, t), [r, [r]];
|
|
11
11
|
},
|
|
12
12
|
deserialize(e) {
|
|
13
13
|
return e.start(), Y(e);
|
|
14
14
|
}
|
|
15
15
|
}, j = {
|
|
16
|
-
canHandle: (e) => $(e) &&
|
|
16
|
+
canHandle: (e) => $(e) && E in e,
|
|
17
17
|
serialize({ value: e }) {
|
|
18
18
|
let t;
|
|
19
19
|
return e instanceof Error ? t = {
|
|
@@ -28,7 +28,7 @@ const H = Symbol("Comlink.proxy"), R = Symbol("Comlink.endpoint"), B = 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
|
-
},
|
|
31
|
+
}, z = /* @__PURE__ */ new Map([
|
|
32
32
|
["proxy", W],
|
|
33
33
|
["throw", j]
|
|
34
34
|
]);
|
|
@@ -38,7 +38,7 @@ function V(e, t) {
|
|
|
38
38
|
return !0;
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function I(e, t = globalThis, r = ["*"]) {
|
|
42
42
|
t.addEventListener("message", function n(i) {
|
|
43
43
|
if (!i || !i.data)
|
|
44
44
|
return;
|
|
@@ -69,7 +69,7 @@ function P(e, t = globalThis, r = ["*"]) {
|
|
|
69
69
|
case "ENDPOINT":
|
|
70
70
|
{
|
|
71
71
|
const { port1: f, port2: g } = new MessageChannel();
|
|
72
|
-
|
|
72
|
+
I(e, g), h = J(f, [f]);
|
|
73
73
|
}
|
|
74
74
|
break;
|
|
75
75
|
case "RELEASE":
|
|
@@ -79,15 +79,15 @@ function P(e, t = globalThis, r = ["*"]) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
} catch (u) {
|
|
82
|
-
h = { value: u, [
|
|
82
|
+
h = { value: u, [E]: 0 };
|
|
83
83
|
}
|
|
84
|
-
Promise.resolve(h).catch((u) => ({ value: u, [
|
|
84
|
+
Promise.resolve(h).catch((u) => ({ value: u, [E]: 0 })).then((u) => {
|
|
85
85
|
const [w, f] = A(u);
|
|
86
86
|
t.postMessage(Object.assign(Object.assign({}, w), { id: a }), f), s === "RELEASE" && (t.removeEventListener("message", n), L(t), D in e && typeof e[D] == "function" && e[D]());
|
|
87
87
|
}).catch((u) => {
|
|
88
88
|
const [w, f] = A({
|
|
89
89
|
value: new TypeError("Unserializable return value"),
|
|
90
|
-
[
|
|
90
|
+
[E]: 0
|
|
91
91
|
});
|
|
92
92
|
t.postMessage(Object.assign(Object.assign({}, w), { id: a }), f);
|
|
93
93
|
});
|
|
@@ -112,13 +112,13 @@ function Y(e, t) {
|
|
|
112
112
|
} finally {
|
|
113
113
|
r.delete(a.id);
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), M(e, r, [], t);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function p(e) {
|
|
118
118
|
if (e)
|
|
119
119
|
throw new Error("Proxy has been released and is not useable");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function U(e) {
|
|
122
122
|
return d(e, /* @__PURE__ */ new Map(), {
|
|
123
123
|
type: "RELEASE"
|
|
124
124
|
}).then(() => {
|
|
@@ -127,7 +127,7 @@ function z(e) {
|
|
|
127
127
|
}
|
|
128
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 && U(e);
|
|
131
131
|
});
|
|
132
132
|
function X(e, t) {
|
|
133
133
|
const r = (F.get(t) || 0) + 1;
|
|
@@ -136,14 +136,14 @@ function X(e, t) {
|
|
|
136
136
|
function q(e) {
|
|
137
137
|
S && S.unregister(e);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function M(e, t, r = [], n = function() {
|
|
140
140
|
}) {
|
|
141
141
|
let i = !1;
|
|
142
142
|
const a = new Proxy(n, {
|
|
143
143
|
get(s, o) {
|
|
144
|
-
if (
|
|
144
|
+
if (p(i), o === B)
|
|
145
145
|
return () => {
|
|
146
|
-
q(a),
|
|
146
|
+
q(a), U(e), t.clear(), i = !0;
|
|
147
147
|
};
|
|
148
148
|
if (o === "then") {
|
|
149
149
|
if (r.length === 0)
|
|
@@ -154,10 +154,10 @@ function I(e, t, r = [], n = function() {
|
|
|
154
154
|
}).then(y);
|
|
155
155
|
return l.then.bind(l);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return M(e, t, [...r, o]);
|
|
158
158
|
},
|
|
159
159
|
set(s, o, l) {
|
|
160
|
-
|
|
160
|
+
p(i);
|
|
161
161
|
const [h, u] = A(l);
|
|
162
162
|
return d(e, t, {
|
|
163
163
|
type: "SET",
|
|
@@ -166,14 +166,14 @@ function I(e, t, r = [], n = function() {
|
|
|
166
166
|
}, u).then(y);
|
|
167
167
|
},
|
|
168
168
|
apply(s, o, l) {
|
|
169
|
-
|
|
169
|
+
p(i);
|
|
170
170
|
const h = r[r.length - 1];
|
|
171
171
|
if (h === R)
|
|
172
172
|
return d(e, t, {
|
|
173
173
|
type: "ENDPOINT"
|
|
174
174
|
}).then(y);
|
|
175
175
|
if (h === "bind")
|
|
176
|
-
return
|
|
176
|
+
return M(e, t, r.slice(0, -1));
|
|
177
177
|
const [u, w] = N(l);
|
|
178
178
|
return d(e, t, {
|
|
179
179
|
type: "APPLY",
|
|
@@ -182,7 +182,7 @@ function I(e, t, r = [], n = function() {
|
|
|
182
182
|
}, w).then(y);
|
|
183
183
|
},
|
|
184
184
|
construct(s, o) {
|
|
185
|
-
|
|
185
|
+
p(i);
|
|
186
186
|
const [l, h] = N(o);
|
|
187
187
|
return d(e, t, {
|
|
188
188
|
type: "CONSTRUCT",
|
|
@@ -208,7 +208,7 @@ function Q(e) {
|
|
|
208
208
|
return Object.assign(e, { [H]: !0 });
|
|
209
209
|
}
|
|
210
210
|
function A(e) {
|
|
211
|
-
for (const [t, r] of
|
|
211
|
+
for (const [t, r] of z)
|
|
212
212
|
if (r.canHandle(e)) {
|
|
213
213
|
const [n, i] = r.serialize(e);
|
|
214
214
|
return [
|
|
@@ -231,7 +231,7 @@ function A(e) {
|
|
|
231
231
|
function y(e) {
|
|
232
232
|
switch (e.type) {
|
|
233
233
|
case "HANDLER":
|
|
234
|
-
return
|
|
234
|
+
return z.get(e.name).deserialize(e.value);
|
|
235
235
|
case "RAW":
|
|
236
236
|
return e.value;
|
|
237
237
|
}
|
|
@@ -350,18 +350,18 @@ function ot() {
|
|
|
350
350
|
function m(e) {
|
|
351
351
|
return Array.isArray(e) ? e : e.split("/").filter(Boolean);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function P(e) {
|
|
354
354
|
return typeof e == "string" ? e ?? "/" : \`/\${e.join("/")}\`;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function b(e) {
|
|
357
357
|
const t = m(e);
|
|
358
358
|
return t[t.length - 1] || "";
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function x(e) {
|
|
361
361
|
const t = m(e);
|
|
362
|
-
return t.pop(),
|
|
362
|
+
return t.pop(), P(t);
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function C(e) {
|
|
365
365
|
return !e || e === "/" ? "/" : e.startsWith("/") ? e : \`/\${e}\`;
|
|
366
366
|
}
|
|
367
367
|
function ct(e) {
|
|
@@ -374,7 +374,7 @@ function ct(e) {
|
|
|
374
374
|
r.pop();
|
|
375
375
|
} else
|
|
376
376
|
r.push(n);
|
|
377
|
-
return
|
|
377
|
+
return P(r);
|
|
378
378
|
}
|
|
379
379
|
function lt(e, t = "utf-8") {
|
|
380
380
|
return typeof e == "string" ? et(e, t) : e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
@@ -406,14 +406,11 @@ async function v(e, t, r, n = {}) {
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
async function ut(e, t = "SHA-1") {
|
|
410
|
-
e instanceof File && (e = await e.arrayBuffer())
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
} catch (r) {
|
|
415
|
-
throw console.warn(\`Failed to calculate \${t} hash:\`, r), r;
|
|
416
|
-
}
|
|
409
|
+
async function ut(e, t = "SHA-1", r = 50 * 1024 * 1024) {
|
|
410
|
+
if (e instanceof File && (e = await e.arrayBuffer()), e.byteLength > r)
|
|
411
|
+
throw new Error(\`File size \${e.byteLength} bytes exceeds maximum allowed size \${r} bytes\`);
|
|
412
|
+
const n = new Uint8Array(e), i = await crypto.subtle.digest(t, n);
|
|
413
|
+
return Array.from(new Uint8Array(i)).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
417
414
|
}
|
|
418
415
|
async function ft(e) {
|
|
419
416
|
const t = await e.arrayBuffer();
|
|
@@ -428,14 +425,16 @@ class wt {
|
|
|
428
425
|
watchers = /* @__PURE__ */ new Map();
|
|
429
426
|
/** Interval handle for polling watched paths */
|
|
430
427
|
watchTimer = null;
|
|
431
|
-
/** Polling interval in milliseconds */
|
|
432
|
-
watchInterval = 1e3;
|
|
433
428
|
/** Flag to avoid concurrent scans */
|
|
434
429
|
scanning = !1;
|
|
435
430
|
/** Promise to prevent concurrent mount operations */
|
|
436
431
|
mountingPromise = null;
|
|
437
|
-
/**
|
|
438
|
-
|
|
432
|
+
/** Configuration options */
|
|
433
|
+
options = {
|
|
434
|
+
watchInterval: 1e3,
|
|
435
|
+
maxFileSize: 50 * 1024 * 1024,
|
|
436
|
+
hashAlgorithm: null
|
|
437
|
+
};
|
|
439
438
|
/**
|
|
440
439
|
* Notify about internal changes to the file system
|
|
441
440
|
*
|
|
@@ -449,7 +448,7 @@ class wt {
|
|
|
449
448
|
if (!this.watchCallback)
|
|
450
449
|
return;
|
|
451
450
|
let r;
|
|
452
|
-
if (this.hashAlgorithm && !t.isDirectory && t.type !== "removed")
|
|
451
|
+
if (this.options.hashAlgorithm && !t.isDirectory && t.type !== "removed")
|
|
453
452
|
try {
|
|
454
453
|
const n = await this.stat(t.path);
|
|
455
454
|
n.isFile && n.hash && (r = n.hash);
|
|
@@ -469,6 +468,7 @@ class wt {
|
|
|
469
468
|
* @param options - Optional configuration options
|
|
470
469
|
* @param options.watchInterval - Polling interval in milliseconds for file watching
|
|
471
470
|
* @param options.hashAlgorithm - Hash algorithm for file hashing
|
|
471
|
+
* @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)
|
|
472
472
|
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
473
473
|
*/
|
|
474
474
|
constructor(t, r) {
|
|
@@ -517,14 +517,15 @@ class wt {
|
|
|
517
517
|
this.watchCallback = t;
|
|
518
518
|
}
|
|
519
519
|
/**
|
|
520
|
-
*
|
|
520
|
+
* Update configuration options
|
|
521
521
|
*
|
|
522
522
|
* @param options - Configuration options to update
|
|
523
523
|
* @param options.watchInterval - Polling interval in milliseconds for file watching
|
|
524
524
|
* @param options.hashAlgorithm - Hash algorithm for file hashing
|
|
525
|
+
* @param options.maxFileSize - Maximum file size for hashing in bytes
|
|
525
526
|
*/
|
|
526
527
|
setOptions(t) {
|
|
527
|
-
t.watchInterval !== void 0 && (this.watchInterval = t.watchInterval), t.hashAlgorithm !== void 0 && (this.hashAlgorithm = t.hashAlgorithm);
|
|
528
|
+
t.watchInterval !== void 0 && (this.options.watchInterval = t.watchInterval), t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize);
|
|
528
529
|
}
|
|
529
530
|
/**
|
|
530
531
|
* Automatically mount the OPFS root if not already mounted
|
|
@@ -738,7 +739,7 @@ class wt {
|
|
|
738
739
|
a = await a.getDirectoryHandle(o, { create: n || s === i.length - 1 });
|
|
739
740
|
} catch (l) {
|
|
740
741
|
throw l.name === "NotFoundError" ? new c(
|
|
741
|
-
\`Parent directory does not exist: \${
|
|
742
|
+
\`Parent directory does not exist: \${P(i.slice(0, s + 1))}\`,
|
|
742
743
|
"ENOENT"
|
|
743
744
|
) : l.name === "TypeMismatchError" ? new c(\`Path segment is not a directory: \${o}\`, "ENOTDIR") : new c("Failed to create directory", "MKDIR_FAILED");
|
|
744
745
|
}
|
|
@@ -777,7 +778,7 @@ class wt {
|
|
|
777
778
|
isFile: !1,
|
|
778
779
|
isDirectory: !0
|
|
779
780
|
};
|
|
780
|
-
const r =
|
|
781
|
+
const r = b(t), n = await this.getDirectoryHandle(x(t), !1), i = this.options.hashAlgorithm !== null;
|
|
781
782
|
try {
|
|
782
783
|
const s = await (await n.getFileHandle(r, { create: !1 })).getFile(), o = {
|
|
783
784
|
kind: "file",
|
|
@@ -787,9 +788,9 @@ class wt {
|
|
|
787
788
|
isFile: !0,
|
|
788
789
|
isDirectory: !1
|
|
789
790
|
};
|
|
790
|
-
if (i && this.hashAlgorithm)
|
|
791
|
+
if (i && this.options.hashAlgorithm)
|
|
791
792
|
try {
|
|
792
|
-
const l = await ut(s, this.hashAlgorithm);
|
|
793
|
+
const l = await ut(s, this.options.hashAlgorithm, this.options.maxFileSize);
|
|
793
794
|
o.hash = l;
|
|
794
795
|
} catch (l) {
|
|
795
796
|
console.warn(\`Failed to calculate hash for \${t}:\`, l);
|
|
@@ -851,10 +852,10 @@ class wt {
|
|
|
851
852
|
async exists(t) {
|
|
852
853
|
if (await this.ensureMounted(), t === "/")
|
|
853
854
|
return !0;
|
|
854
|
-
const r =
|
|
855
|
+
const r = b(t);
|
|
855
856
|
let n = null;
|
|
856
857
|
try {
|
|
857
|
-
n = await this.getDirectoryHandle(
|
|
858
|
+
n = await this.getDirectoryHandle(x(t), !1);
|
|
858
859
|
} catch (i) {
|
|
859
860
|
throw (i.name === "NotFoundError" || i.name === "TypeMismatchError") && (n = null), i;
|
|
860
861
|
}
|
|
@@ -935,10 +936,10 @@ class wt {
|
|
|
935
936
|
const n = r?.recursive ?? !1, i = r?.force ?? !1;
|
|
936
937
|
if (t === "/")
|
|
937
938
|
throw new c("Cannot remove root directory", "EROOT");
|
|
938
|
-
const a =
|
|
939
|
+
const a = b(t);
|
|
939
940
|
if (!a)
|
|
940
941
|
throw new k("Invalid path", t);
|
|
941
|
-
const s = await this.getDirectoryHandle(
|
|
942
|
+
const s = await this.getDirectoryHandle(x(t), !1);
|
|
942
943
|
try {
|
|
943
944
|
await s.removeEntry(a, { recursive: n });
|
|
944
945
|
} catch (o) {
|
|
@@ -1060,16 +1061,16 @@ class wt {
|
|
|
1060
1061
|
*/
|
|
1061
1062
|
async watch(t) {
|
|
1062
1063
|
await this.ensureMounted();
|
|
1063
|
-
const r =
|
|
1064
|
+
const r = C(t), n = await this.buildSnapshot(r);
|
|
1064
1065
|
this.watchers.set(r, n), this.watchTimer || (this.watchTimer = setInterval(() => {
|
|
1065
1066
|
this.scanWatches();
|
|
1066
|
-
}, this.watchInterval));
|
|
1067
|
+
}, this.options.watchInterval));
|
|
1067
1068
|
}
|
|
1068
1069
|
/**
|
|
1069
1070
|
* Stop watching a previously watched path
|
|
1070
1071
|
*/
|
|
1071
1072
|
unwatch(t) {
|
|
1072
|
-
const r =
|
|
1073
|
+
const r = C(t);
|
|
1073
1074
|
this.watchers.delete(r), this.watchers.size === 0 && this.watchTimer && (clearInterval(this.watchTimer), this.watchTimer = null);
|
|
1074
1075
|
}
|
|
1075
1076
|
async buildSnapshot(t) {
|
|
@@ -1144,7 +1145,7 @@ class wt {
|
|
|
1144
1145
|
try {
|
|
1145
1146
|
(r?.cleanBefore ?? !1) && await this.clear("/");
|
|
1146
1147
|
for (const [i, a] of t) {
|
|
1147
|
-
const s =
|
|
1148
|
+
const s = C(i);
|
|
1148
1149
|
let o;
|
|
1149
1150
|
a instanceof Blob ? o = await ft(a) : o = a, await this.writeFile(s, o);
|
|
1150
1151
|
}
|
|
@@ -1154,7 +1155,7 @@ class wt {
|
|
|
1154
1155
|
}
|
|
1155
1156
|
}
|
|
1156
1157
|
}
|
|
1157
|
-
typeof self < "u" && self.constructor.name === "DedicatedWorkerGlobalScope" &&
|
|
1158
|
-
//# sourceMappingURL=worker-
|
|
1158
|
+
typeof self < "u" && self.constructor.name === "DedicatedWorkerGlobalScope" && I(new wt());
|
|
1159
|
+
//# sourceMappingURL=worker-CHy3JxL1.js.map
|
|
1159
1160
|
`,i=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",o],{type:"text/javascript;charset=utf-8"});function s(r){let t;try{if(t=i&&(self.URL||self.webkitURL).createObjectURL(i),!t)throw"";const e=new Worker(t,{type:"module",name:r?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(o),{type:"module",name:r?.name})}}function c(r,t){const e=a.wrap(new s);return r&&e.setWatchCallback(r?a.proxy(r):()=>{}),t&&e.setOptions(t),e}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;
|
|
1160
1161
|
//# 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 options - Optional configuration options\n * @
|
|
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, OPFSOptions } 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 options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n watchCallback?: (event: WatchEvent) => void,\n options?: OPFSOptions\n): RemoteOPFSWorker {\n const wrapped = wrap<OPFSWorker>(new WorkerCtor());\n \n // Set up watch callback and options if provided\n if (watchCallback) {\n wrapped.setWatchCallback(\n watchCallback ? proxy(watchCallback) : () => {}, \n );\n }\n \n if (options) {\n wrapped.setOptions(options);\n }\n \n return wrapped;\n}\n"],"names":["createWorker","watchCallback","options","wrapped","wrap","WorkerCtor","proxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qdAiBO,SAASA,EACZC,EACAC,EACgB,CAChB,MAAMC,EAAUC,EAAAA,KAAiB,IAAIC,CAAY,EAGjD,OAAIJ,GACAE,EAAQ,iBACJF,EAAgBK,EAAAA,MAAML,CAAa,EAAI,IAAM,CAAC,CAAA,EAIlDC,GACAC,EAAQ,WAAWD,CAAO,EAGvBC,CACX"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RemoteOPFSWorker, WatchEvent } from './types';
|
|
1
|
+
import type { RemoteOPFSWorker, WatchEvent, OPFSOptions } from './types';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './utils/errors';
|
|
4
4
|
export * from './utils/helpers';
|
|
@@ -7,12 +7,7 @@ export * from './utils/encoder';
|
|
|
7
7
|
* Creates a new file system instance with inline worker
|
|
8
8
|
* @param watchCallback - Optional callback for file change events
|
|
9
9
|
* @param options - Optional configuration options
|
|
10
|
-
* @param options.watchInterval - Polling interval in milliseconds for file watching
|
|
11
|
-
* @param options.hashAlgorithm - Hash algorithm for file hashing
|
|
12
10
|
* @returns Promise resolving to the file system interface
|
|
13
11
|
*/
|
|
14
|
-
export declare function createWorker(watchCallback?: (event: WatchEvent) => void, options?:
|
|
15
|
-
watchInterval?: number;
|
|
16
|
-
hashAlgorithm?: 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
17
|
-
}): RemoteOPFSWorker;
|
|
12
|
+
export declare function createWorker(watchCallback?: (event: WatchEvent) => void, options?: OPFSOptions): RemoteOPFSWorker;
|
|
18
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAErF,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAEhC;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EAC3C,OAAO,CAAC,EAAE,WAAW,GACtB,gBAAgB,CAelB"}
|