@opendaw/lib-fusion 0.0.26 → 0.0.28
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/dist/opfs/OpfsWorker.d.ts.map +1 -1
- package/dist/opfs/OpfsWorker.js +14 -12
- package/package.json +7 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAW,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,UAAU,CAAA;AAEjB,yBAAiB,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAW,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,UAAU,CAAA;AAEjB,yBAAiB,UAAU,CAAC;IAGjB,MAAM,IAAI,GAAI,WAAW,SAAS;oBAEf,MAAM,QAAQ,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;mBAYzC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;qBAa1B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBAOxB,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;iBAWrD,OAAO,CAAC,IAAI,CAAC;2BAWH,MAAM,YAAY,6BAA6B,GAAG,OAAO,CAAC,0BAA0B,CAAC;iCAO/E,aAAa,CAAC,MAAM,CAAC,YACrB,6BAA6B,GAAG,OAAO,CAAC,yBAAyB,CAAC;MAKnG,CAAA;CAMT"}
|
package/dist/opfs/OpfsWorker.js
CHANGED
@@ -4,33 +4,35 @@ import "../types";
|
|
4
4
|
export var OpfsWorker;
|
5
5
|
(function (OpfsWorker) {
|
6
6
|
const DEBUG = true;
|
7
|
-
const readLimiter = new Promises.Limit(1);
|
8
|
-
const writeLimiter = new Promises.Limit(1);
|
9
7
|
OpfsWorker.init = (messenger) => Communicator.executor(messenger.channel("opfs"), new class {
|
10
8
|
async write(path, data) {
|
11
9
|
if (DEBUG) {
|
12
10
|
console.debug(`write ${data.length}b to ${path}`);
|
13
11
|
}
|
14
|
-
|
15
|
-
|
12
|
+
const handle = await this.#resolveFile(path, { create: true });
|
13
|
+
try {
|
16
14
|
handle.truncate(data.length);
|
17
15
|
handle.write(data.buffer, { at: 0 });
|
18
16
|
handle.flush();
|
17
|
+
}
|
18
|
+
finally {
|
19
19
|
handle.close();
|
20
|
-
}
|
20
|
+
}
|
21
21
|
}
|
22
22
|
async read(path) {
|
23
23
|
if (DEBUG) {
|
24
24
|
console.debug(`read ${path}`);
|
25
25
|
}
|
26
|
-
|
27
|
-
|
26
|
+
const handle = await this.#resolveFile(path);
|
27
|
+
try {
|
28
28
|
const size = handle.getSize();
|
29
29
|
const buffer = new Uint8Array(size);
|
30
30
|
handle.read(buffer);
|
31
|
-
handle.close();
|
32
31
|
return buffer;
|
33
|
-
}
|
32
|
+
}
|
33
|
+
finally {
|
34
|
+
handle.close();
|
35
|
+
}
|
34
36
|
}
|
35
37
|
async delete(path) {
|
36
38
|
const segments = pathToSegments(path);
|
@@ -65,9 +67,9 @@ export var OpfsWorker;
|
|
65
67
|
}
|
66
68
|
async #resolveFile(path, options) {
|
67
69
|
const segments = pathToSegments(path);
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
const folder = await this.#resolveFolder(segments.slice(0, -1), options);
|
71
|
+
const fileHandle = await folder.getFileHandle(asDefined(segments.at(-1)), options);
|
72
|
+
return await fileHandle.createSyncAccessHandle();
|
71
73
|
}
|
72
74
|
async #resolveFolder(segments, options) {
|
73
75
|
let folder = await navigator.storage.getDirectory();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opendaw/lib-fusion",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.28",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"license": "LGPL-3.0-or-later",
|
@@ -22,13 +22,13 @@
|
|
22
22
|
"test": "echo \"No tests to run\""
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@opendaw/lib-box": "^0.0.
|
26
|
-
"@opendaw/lib-runtime": "^0.0.
|
27
|
-
"@opendaw/lib-std": "^0.0.
|
25
|
+
"@opendaw/lib-box": "^0.0.28",
|
26
|
+
"@opendaw/lib-runtime": "^0.0.28",
|
27
|
+
"@opendaw/lib-std": "^0.0.28"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@opendaw/eslint-config": "^0.0.
|
31
|
-
"@opendaw/typescript-config": "^0.0.
|
30
|
+
"@opendaw/eslint-config": "^0.0.19",
|
31
|
+
"@opendaw/typescript-config": "^0.0.20"
|
32
32
|
},
|
33
|
-
"gitHead": "
|
33
|
+
"gitHead": "ef80742a992e09362277ff87ec1b79ded515f9e5"
|
34
34
|
}
|