@elaraai/e3-web 0.0.0-stage → 1.0.85
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/LICENSE.md +54 -0
- package/README.md +395 -2
- package/dist/src/app.d.ts +91 -0
- package/dist/src/app.d.ts.map +1 -0
- package/dist/src/app.js +112 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/bridge/bridge.spec.d.ts +6 -0
- package/dist/src/bridge/bridge.spec.d.ts.map +1 -0
- package/dist/src/bridge/bridge.spec.js +56 -0
- package/dist/src/bridge/bridge.spec.js.map +1 -0
- package/dist/src/bridge/page.d.ts +149 -0
- package/dist/src/bridge/page.d.ts.map +1 -0
- package/dist/src/bridge/page.js +328 -0
- package/dist/src/bridge/page.js.map +1 -0
- package/dist/src/bridge/protocol.d.ts +181 -0
- package/dist/src/bridge/protocol.d.ts.map +1 -0
- package/dist/src/bridge/protocol.js +113 -0
- package/dist/src/bridge/protocol.js.map +1 -0
- package/dist/src/bridge/worker.d.ts +124 -0
- package/dist/src/bridge/worker.d.ts.map +1 -0
- package/dist/src/bridge/worker.js +185 -0
- package/dist/src/bridge/worker.js.map +1 -0
- package/dist/src/browser/bridge.page.d.ts +12 -0
- package/dist/src/browser/bridge.page.d.ts.map +1 -0
- package/dist/src/browser/bridge.page.js +79 -0
- package/dist/src/browser/bridge.page.js.map +1 -0
- package/dist/src/browser/bridge.spec.d.ts +6 -0
- package/dist/src/browser/bridge.spec.d.ts.map +1 -0
- package/dist/src/browser/bridge.spec.js +105 -0
- package/dist/src/browser/bridge.spec.js.map +1 -0
- package/dist/src/browser/bridge.worker.d.ts +6 -0
- package/dist/src/browser/bridge.worker.d.ts.map +1 -0
- package/dist/src/browser/bridge.worker.js +35 -0
- package/dist/src/browser/bridge.worker.js.map +1 -0
- package/dist/src/browser/compliance.d.ts +68 -0
- package/dist/src/browser/compliance.d.ts.map +1 -0
- package/dist/src/browser/compliance.js +30 -0
- package/dist/src/browser/compliance.js.map +1 -0
- package/dist/src/browser/compliance.page.d.ts +6 -0
- package/dist/src/browser/compliance.page.d.ts.map +1 -0
- package/dist/src/browser/compliance.page.js +204 -0
- package/dist/src/browser/compliance.page.js.map +1 -0
- package/dist/src/browser/compliance.spec.d.ts +6 -0
- package/dist/src/browser/compliance.spec.d.ts.map +1 -0
- package/dist/src/browser/compliance.spec.js +147 -0
- package/dist/src/browser/compliance.spec.js.map +1 -0
- package/dist/src/browser/e3-api-1.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-1.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-1.spec.js +12 -0
- package/dist/src/browser/e3-api-1.spec.js.map +1 -0
- package/dist/src/browser/e3-api-2.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-2.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-2.spec.js +12 -0
- package/dist/src/browser/e3-api-2.spec.js.map +1 -0
- package/dist/src/browser/e3-api-3.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-3.spec.js +12 -0
- package/dist/src/browser/e3-api-3.spec.js.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.js +45 -0
- package/dist/src/browser/e3-api-parts.spec.js.map +1 -0
- package/dist/src/browser/e3-api.d.ts +28 -0
- package/dist/src/browser/e3-api.d.ts.map +1 -0
- package/dist/src/browser/e3-api.js +144 -0
- package/dist/src/browser/e3-api.js.map +1 -0
- package/dist/src/browser/e3-client.worker.d.ts +6 -0
- package/dist/src/browser/e3-client.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-client.worker.js +19 -0
- package/dist/src/browser/e3-client.worker.js.map +1 -0
- package/dist/src/browser/e3-forward.d.ts +27 -0
- package/dist/src/browser/e3-forward.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.js +81 -0
- package/dist/src/browser/e3-forward.js.map +1 -0
- package/dist/src/browser/e3-forward.spec.d.ts +6 -0
- package/dist/src/browser/e3-forward.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.spec.js +84 -0
- package/dist/src/browser/e3-forward.spec.js.map +1 -0
- package/dist/src/browser/e3-port.worker.d.ts +6 -0
- package/dist/src/browser/e3-port.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-port.worker.js +21 -0
- package/dist/src/browser/e3-port.worker.js.map +1 -0
- package/dist/src/browser/e3-unit.worker.d.ts +6 -0
- package/dist/src/browser/e3-unit.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-unit.worker.js +18 -0
- package/dist/src/browser/e3-unit.worker.js.map +1 -0
- package/dist/src/browser/e3-wire.d.ts +43 -0
- package/dist/src/browser/e3-wire.d.ts.map +1 -0
- package/dist/src/browser/e3-wire.js +32 -0
- package/dist/src/browser/e3-wire.js.map +1 -0
- package/dist/src/browser/e3.page.d.ts +21 -0
- package/dist/src/browser/e3.page.d.ts.map +1 -0
- package/dist/src/browser/e3.page.js +119 -0
- package/dist/src/browser/e3.page.js.map +1 -0
- package/dist/src/browser/e3.spec.d.ts +6 -0
- package/dist/src/browser/e3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3.spec.js +358 -0
- package/dist/src/browser/e3.spec.js.map +1 -0
- package/dist/src/browser/e3.worker.d.ts +6 -0
- package/dist/src/browser/e3.worker.d.ts.map +1 -0
- package/dist/src/browser/e3.worker.js +38 -0
- package/dist/src/browser/e3.worker.js.map +1 -0
- package/dist/src/browser/harness.d.ts +175 -0
- package/dist/src/browser/harness.d.ts.map +1 -0
- package/dist/src/browser/harness.js +375 -0
- package/dist/src/browser/harness.js.map +1 -0
- package/dist/src/browser/page.d.ts +47 -0
- package/dist/src/browser/page.d.ts.map +1 -0
- package/dist/src/browser/page.js +47 -0
- package/dist/src/browser/page.js.map +1 -0
- package/dist/src/browser/repository.page.d.ts +85 -0
- package/dist/src/browser/repository.page.d.ts.map +1 -0
- package/dist/src/browser/repository.page.js +271 -0
- package/dist/src/browser/repository.page.js.map +1 -0
- package/dist/src/browser/runner.page.d.ts +6 -0
- package/dist/src/browser/runner.page.d.ts.map +1 -0
- package/dist/src/browser/runner.page.js +62 -0
- package/dist/src/browser/runner.page.js.map +1 -0
- package/dist/src/browser/runner.spec.d.ts +6 -0
- package/dist/src/browser/runner.spec.d.ts.map +1 -0
- package/dist/src/browser/runner.spec.js +46 -0
- package/dist/src/browser/runner.spec.js.map +1 -0
- package/dist/src/browser/storage.page.d.ts +6 -0
- package/dist/src/browser/storage.page.d.ts.map +1 -0
- package/dist/src/browser/storage.page.js +289 -0
- package/dist/src/browser/storage.page.js.map +1 -0
- package/dist/src/browser/storage.spec.d.ts +6 -0
- package/dist/src/browser/storage.spec.d.ts.map +1 -0
- package/dist/src/browser/storage.spec.js +211 -0
- package/dist/src/browser/storage.spec.js.map +1 -0
- package/dist/src/browser/unit.worker.d.ts +6 -0
- package/dist/src/browser/unit.worker.d.ts.map +1 -0
- package/dist/src/browser/unit.worker.js +17 -0
- package/dist/src/browser/unit.worker.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.d.ts +159 -0
- package/dist/src/execution/WebTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.js +581 -0
- package/dist/src/execution/WebTaskRunner.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts +6 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.js +91 -0
- package/dist/src/execution/WebTaskRunner.spec.js.map +1 -0
- package/dist/src/execution/e3-platform.d.ts +41 -0
- package/dist/src/execution/e3-platform.d.ts.map +1 -0
- package/dist/src/execution/e3-platform.js +52 -0
- package/dist/src/execution/e3-platform.js.map +1 -0
- package/dist/src/execution/in-process.d.ts +32 -0
- package/dist/src/execution/in-process.d.ts.map +1 -0
- package/dist/src/execution/in-process.js +89 -0
- package/dist/src/execution/in-process.js.map +1 -0
- package/dist/src/execution/pool.d.ts +172 -0
- package/dist/src/execution/pool.d.ts.map +1 -0
- package/dist/src/execution/pool.js +352 -0
- package/dist/src/execution/pool.js.map +1 -0
- package/dist/src/execution/pool.spec.d.ts +6 -0
- package/dist/src/execution/pool.spec.d.ts.map +1 -0
- package/dist/src/execution/pool.spec.js +252 -0
- package/dist/src/execution/pool.spec.js.map +1 -0
- package/dist/src/execution/protocol.d.ts +108 -0
- package/dist/src/execution/protocol.d.ts.map +1 -0
- package/dist/src/execution/protocol.js +27 -0
- package/dist/src/execution/protocol.js.map +1 -0
- package/dist/src/execution/unit-server.d.ts +131 -0
- package/dist/src/execution/unit-server.d.ts.map +1 -0
- package/dist/src/execution/unit-server.js +142 -0
- package/dist/src/execution/unit-server.js.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.spec.d.ts +6 -0
- package/dist/src/index.spec.d.ts.map +1 -0
- package/dist/src/index.spec.js +212 -0
- package/dist/src/index.spec.js.map +1 -0
- package/dist/src/node.d.ts +12 -0
- package/dist/src/node.d.ts.map +1 -0
- package/dist/src/node.js +12 -0
- package/dist/src/node.js.map +1 -0
- package/dist/src/storage/WebStateStore.d.ts +64 -0
- package/dist/src/storage/WebStateStore.d.ts.map +1 -0
- package/dist/src/storage/WebStateStore.js +237 -0
- package/dist/src/storage/WebStateStore.js.map +1 -0
- package/dist/src/storage/WebStorage.d.ts +225 -0
- package/dist/src/storage/WebStorage.d.ts.map +1 -0
- package/dist/src/storage/WebStorage.js +1462 -0
- package/dist/src/storage/WebStorage.js.map +1 -0
- package/dist/src/storage/adapters.d.ts +610 -0
- package/dist/src/storage/adapters.d.ts.map +1 -0
- package/dist/src/storage/adapters.js +246 -0
- package/dist/src/storage/adapters.js.map +1 -0
- package/dist/src/storage/indexeddb.d.ts +93 -0
- package/dist/src/storage/indexeddb.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.js +384 -0
- package/dist/src/storage/indexeddb.js.map +1 -0
- package/dist/src/storage/indexeddb.spec.d.ts +6 -0
- package/dist/src/storage/indexeddb.spec.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.spec.js +77 -0
- package/dist/src/storage/indexeddb.spec.js.map +1 -0
- package/dist/src/storage/memory.d.ts +275 -0
- package/dist/src/storage/memory.d.ts.map +1 -0
- package/dist/src/storage/memory.js +724 -0
- package/dist/src/storage/memory.js.map +1 -0
- package/dist/src/storage/memory.spec.d.ts +6 -0
- package/dist/src/storage/memory.spec.d.ts.map +1 -0
- package/dist/src/storage/memory.spec.js +71 -0
- package/dist/src/storage/memory.spec.js.map +1 -0
- package/dist/src/storage/node-files.d.ts +38 -0
- package/dist/src/storage/node-files.d.ts.map +1 -0
- package/dist/src/storage/node-files.js +148 -0
- package/dist/src/storage/node-files.js.map +1 -0
- package/dist/src/storage/node-files.spec.d.ts +6 -0
- package/dist/src/storage/node-files.spec.d.ts.map +1 -0
- package/dist/src/storage/node-files.spec.js +40 -0
- package/dist/src/storage/node-files.spec.js.map +1 -0
- package/dist/src/storage/opfs.d.ts +145 -0
- package/dist/src/storage/opfs.d.ts.map +1 -0
- package/dist/src/storage/opfs.js +514 -0
- package/dist/src/storage/opfs.js.map +1 -0
- package/dist/src/storage/opfs.spec.d.ts +6 -0
- package/dist/src/storage/opfs.spec.d.ts.map +1 -0
- package/dist/src/storage/opfs.spec.js +51 -0
- package/dist/src/storage/opfs.spec.js.map +1 -0
- package/dist/src/storage/record-keys.d.ts +78 -0
- package/dist/src/storage/record-keys.d.ts.map +1 -0
- package/dist/src/storage/record-keys.js +71 -0
- package/dist/src/storage/record-keys.js.map +1 -0
- package/dist/src/storage/stores.spec.d.ts +6 -0
- package/dist/src/storage/stores.spec.d.ts.map +1 -0
- package/dist/src/storage/stores.spec.js +326 -0
- package/dist/src/storage/stores.spec.js.map +1 -0
- package/dist/src/storage/web-locks.d.ts +103 -0
- package/dist/src/storage/web-locks.d.ts.map +1 -0
- package/dist/src/storage/web-locks.js +228 -0
- package/dist/src/storage/web-locks.js.map +1 -0
- package/dist/src/testing/adapter-contract.d.ts +116 -0
- package/dist/src/testing/adapter-contract.d.ts.map +1 -0
- package/dist/src/testing/adapter-contract.js +769 -0
- package/dist/src/testing/adapter-contract.js.map +1 -0
- package/dist/src/testing/assert.d.ts +75 -0
- package/dist/src/testing/assert.d.ts.map +1 -0
- package/dist/src/testing/assert.js +146 -0
- package/dist/src/testing/assert.js.map +1 -0
- package/dist/src/testing/assert.spec.d.ts +6 -0
- package/dist/src/testing/assert.spec.d.ts.map +1 -0
- package/dist/src/testing/assert.spec.js +62 -0
- package/dist/src/testing/assert.spec.js.map +1 -0
- package/dist/src/testing/bridge-contract.d.ts +55 -0
- package/dist/src/testing/bridge-contract.d.ts.map +1 -0
- package/dist/src/testing/bridge-contract.js +376 -0
- package/dist/src/testing/bridge-contract.js.map +1 -0
- package/dist/src/testing/bridge-handler.d.ts +35 -0
- package/dist/src/testing/bridge-handler.d.ts.map +1 -0
- package/dist/src/testing/bridge-handler.js +108 -0
- package/dist/src/testing/bridge-handler.js.map +1 -0
- package/dist/src/testing/callers.d.ts +29 -0
- package/dist/src/testing/callers.d.ts.map +1 -0
- package/dist/src/testing/callers.js +24 -0
- package/dist/src/testing/callers.js.map +1 -0
- package/dist/src/testing/e3-fixtures.d.ts +38 -0
- package/dist/src/testing/e3-fixtures.d.ts.map +1 -0
- package/dist/src/testing/e3-fixtures.js +126 -0
- package/dist/src/testing/e3-fixtures.js.map +1 -0
- package/dist/src/testing/hold-platform.d.ts +33 -0
- package/dist/src/testing/hold-platform.d.ts.map +1 -0
- package/dist/src/testing/hold-platform.js +41 -0
- package/dist/src/testing/hold-platform.js.map +1 -0
- package/dist/src/testing/runner-cases.d.ts +112 -0
- package/dist/src/testing/runner-cases.d.ts.map +1 -0
- package/dist/src/testing/runner-cases.js +959 -0
- package/dist/src/testing/runner-cases.js.map +1 -0
- package/dist/src/testing/runner-fixtures.d.ts +13 -0
- package/dist/src/testing/runner-fixtures.d.ts.map +1 -0
- package/dist/src/testing/runner-fixtures.js +173 -0
- package/dist/src/testing/runner-fixtures.js.map +1 -0
- package/dist/src/testing/test-platform.d.ts +73 -0
- package/dist/src/testing/test-platform.d.ts.map +1 -0
- package/dist/src/testing/test-platform.js +143 -0
- package/dist/src/testing/test-platform.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.d.ts +780 -0
- package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.js +1140 -0
- package/dist/src/transfer/WebTransferBackend.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts +6 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.js +582 -0
- package/dist/src/transfer/WebTransferBackend.spec.js.map +1 -0
- package/dist/src/transfer/endpoints.d.ts +46 -0
- package/dist/src/transfer/endpoints.d.ts.map +1 -0
- package/dist/src/transfer/endpoints.js +157 -0
- package/dist/src/transfer/endpoints.js.map +1 -0
- package/dist/src/units.d.ts +51 -0
- package/dist/src/units.d.ts.map +1 -0
- package/dist/src/units.js +74 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/worker.d.ts +126 -0
- package/dist/src/worker.d.ts.map +1 -0
- package/dist/src/worker.js +186 -0
- package/dist/src/worker.js.map +1 -0
- package/dist/src/worker.spec.d.ts +6 -0
- package/dist/src/worker.spec.d.ts.map +1 -0
- package/dist/src/worker.spec.js +195 -0
- package/dist/src/worker.spec.js.map +1 -0
- package/package.json +76 -3
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Blobs and files in the origin private file system (OPFS).
|
|
7
|
+
*
|
|
8
|
+
* A blob is an OPFS file: its key's parts name the directories it is in and
|
|
9
|
+
* the file itself. A file named by a path is the OPFS file at that path. Both
|
|
10
|
+
* write a file whole in a staging directory and move it into place, so a
|
|
11
|
+
* reader sees a file before its write or after it, never an empty or a torn
|
|
12
|
+
* one, and a write that fails leaves the file as it was.
|
|
13
|
+
*
|
|
14
|
+
* Every name is escaped on its way to OPFS, so any string is a key's part or
|
|
15
|
+
* a path's name, and two that differ only in case never meet: a lowercase
|
|
16
|
+
* letter, a digit, `_`, `-` and a `.` after the first character are kept,
|
|
17
|
+
* and every other character becomes `%` and the hex of each of its UTF-8
|
|
18
|
+
* bytes.
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
import { FileNotFoundError, checkBlobKey, checkBlobPrefix, checkRange, chunksOf, compareKeys, readChunkOf, } from './adapters.js';
|
|
23
|
+
import { pathNames } from './memory.js';
|
|
24
|
+
/** The directory a write stages its file in: no escaped name begins with
|
|
25
|
+
* `.`, so no key's part or path's name meets it. */
|
|
26
|
+
const STAGING = '.staging';
|
|
27
|
+
/** What a blob's file name ends with: no escaped name ends with `~`, so a
|
|
28
|
+
* blob and a directory of blobs under the same key's part keep apart. */
|
|
29
|
+
const BLOB_SUFFIX = '~';
|
|
30
|
+
/**
|
|
31
|
+
* Escapes a key's part or a path's name as an OPFS name.
|
|
32
|
+
*
|
|
33
|
+
* @param part - The part or name: a non-empty, well-formed string
|
|
34
|
+
* @returns Its OPFS name
|
|
35
|
+
* @throws {TypeError} When it is empty, or holds a lone surrogate
|
|
36
|
+
*/
|
|
37
|
+
export function escapeName(part) {
|
|
38
|
+
if (part.length === 0)
|
|
39
|
+
throw new TypeError('an OPFS name is not empty');
|
|
40
|
+
let escaped = '';
|
|
41
|
+
for (const char of part) {
|
|
42
|
+
if (/^[a-z0-9_-]$/.test(char) || (char === '.' && escaped.length > 0)) {
|
|
43
|
+
escaped += char;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
let bytes;
|
|
47
|
+
try {
|
|
48
|
+
bytes = encodeURIComponent(char);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new TypeError(`an OPFS name is well-formed UTF-16: ${JSON.stringify(part)} holds a lone surrogate`);
|
|
52
|
+
}
|
|
53
|
+
// encodeURIComponent leaves ASCII letters and !'()*.~ as they are.
|
|
54
|
+
escaped += bytes.startsWith('%') ? bytes : `%${char.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0')}`;
|
|
55
|
+
}
|
|
56
|
+
return escaped;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The key's part or path's name an OPFS name escapes.
|
|
60
|
+
*
|
|
61
|
+
* @param name - The OPFS name
|
|
62
|
+
* @returns What it escapes, or `null` for a name {@link escapeName} never
|
|
63
|
+
* gives
|
|
64
|
+
*/
|
|
65
|
+
export function unescapeName(name) {
|
|
66
|
+
let part;
|
|
67
|
+
try {
|
|
68
|
+
part = decodeURIComponent(name);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return part.length > 0 && escapeName(part) === name ? part : null;
|
|
74
|
+
}
|
|
75
|
+
/** Whether an error is the DOMException of a name. */
|
|
76
|
+
function isNamed(err, ...names) {
|
|
77
|
+
return typeof err === 'object' && err !== null && names.includes(err.name);
|
|
78
|
+
}
|
|
79
|
+
/** Whether an error says an entry is not there as what it was asked for:
|
|
80
|
+
* missing, or a file where a directory was asked for, or the reverse. */
|
|
81
|
+
function isMissing(err) {
|
|
82
|
+
return isNamed(err, 'NotFoundError', 'TypeMismatchError');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The directory the escaped names name under a directory.
|
|
86
|
+
*
|
|
87
|
+
* @param dir - Where the names start
|
|
88
|
+
* @param names - The escaped names, outermost first
|
|
89
|
+
* @param create - Whether to make the directories that are not there
|
|
90
|
+
* @returns The directory, or `null` when one is not there and not made
|
|
91
|
+
*/
|
|
92
|
+
async function directoryAt(dir, names, create) {
|
|
93
|
+
let at = dir;
|
|
94
|
+
for (const name of names) {
|
|
95
|
+
try {
|
|
96
|
+
at = await at.getDirectoryHandle(name, { create });
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
if (!create && isMissing(err))
|
|
100
|
+
return null;
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return at;
|
|
105
|
+
}
|
|
106
|
+
/** The file of a name in a directory, or `null` when there is none. */
|
|
107
|
+
async function fileIn(dir, name) {
|
|
108
|
+
if (dir === null)
|
|
109
|
+
return null;
|
|
110
|
+
try {
|
|
111
|
+
return await dir.getFileHandle(name);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (isMissing(err))
|
|
115
|
+
return null;
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reads a file's contents through `use`, or answers `null` when it is not
|
|
121
|
+
* there — once more when the file was replaced as it was read, since a
|
|
122
|
+
* `File` a replaced file gave no longer reads.
|
|
123
|
+
*/
|
|
124
|
+
async function readFile(find, use) {
|
|
125
|
+
for (let attempt = 0;; attempt++) {
|
|
126
|
+
const handle = await find();
|
|
127
|
+
if (handle === null)
|
|
128
|
+
return null;
|
|
129
|
+
try {
|
|
130
|
+
return await use(await handle.getFile());
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
if (isNamed(err, 'NotFoundError'))
|
|
134
|
+
return null;
|
|
135
|
+
if (isNamed(err, 'NotReadableError') && attempt === 0)
|
|
136
|
+
continue;
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Writes a file whole in a staging directory, and moves it to a name in a
|
|
143
|
+
* directory, replacing what is there.
|
|
144
|
+
*
|
|
145
|
+
* @param staging - The directory to stage the file in
|
|
146
|
+
* @param place - The directory the file goes to, found once it is written
|
|
147
|
+
* @param name - The file's name there
|
|
148
|
+
* @param data - Its bytes
|
|
149
|
+
* @returns Its size in bytes
|
|
150
|
+
*/
|
|
151
|
+
async function stageAndMove(staging, place, name, data) {
|
|
152
|
+
const stagedName = crypto.randomUUID();
|
|
153
|
+
const staged = await staging.getFileHandle(stagedName, { create: true });
|
|
154
|
+
try {
|
|
155
|
+
let size = 0;
|
|
156
|
+
const writable = await staged.createWritable();
|
|
157
|
+
try {
|
|
158
|
+
for await (const chunk of chunksOf(data)) {
|
|
159
|
+
// A file takes bytes of an ArrayBuffer: a view of shared memory is
|
|
160
|
+
// copied.
|
|
161
|
+
await writable.write(chunk.buffer instanceof ArrayBuffer ? chunk : chunk.slice());
|
|
162
|
+
size += chunk.length;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
await writable.abort().catch(() => undefined);
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
await writable.close();
|
|
170
|
+
const movable = staged;
|
|
171
|
+
if (typeof movable.move !== 'function') {
|
|
172
|
+
throw new Error('this browser\'s OPFS cannot move a file (FileSystemHandle.move), which e3-web writes every file by');
|
|
173
|
+
}
|
|
174
|
+
await movable.move(await place(), name);
|
|
175
|
+
return size;
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
await staging.removeEntry(stagedName).catch(() => undefined);
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Opens the OPFS directory at a path, making it and every directory above it
|
|
184
|
+
* that is not there.
|
|
185
|
+
*
|
|
186
|
+
* @param path - An absolute `/`-separated path, its names escaped as
|
|
187
|
+
* {@link OpfsFiles} escapes them
|
|
188
|
+
* @param root - Where the path starts: the origin's OPFS root unless given
|
|
189
|
+
* @returns The directory
|
|
190
|
+
*/
|
|
191
|
+
export async function opfsDirectory(path, root) {
|
|
192
|
+
const start = root ?? await navigator.storage.getDirectory();
|
|
193
|
+
return (await directoryAt(start, pathNames(path).map(escapeName), true));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Blobs as OPFS files, under a directory of their own.
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* A write stages its file in the directory's `.staging` and moves it into
|
|
200
|
+
* place once it is whole. A tab closed mid-write leaves its staged file
|
|
201
|
+
* behind, which {@link sweep} removes once it is older than the age gate.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const blobs = new OpfsBlobs(await opfsDirectory('/e3/blobs'));
|
|
206
|
+
* await blobs.write(['repo', 'objects', hash], bytes);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export class OpfsBlobs {
|
|
210
|
+
root;
|
|
211
|
+
/**
|
|
212
|
+
* @param root - The directory the blobs are kept in, which nothing else
|
|
213
|
+
* writes to
|
|
214
|
+
*/
|
|
215
|
+
constructor(root) {
|
|
216
|
+
this.root = root;
|
|
217
|
+
}
|
|
218
|
+
/** The directory a key's blob is in, made when asked. */
|
|
219
|
+
parentOf(key, create) {
|
|
220
|
+
return directoryAt(this.root, key.slice(0, -1).map(escapeName), create);
|
|
221
|
+
}
|
|
222
|
+
/** The file of a key's blob, or `null` when there is none. */
|
|
223
|
+
async fileOf(key) {
|
|
224
|
+
return fileIn(await this.parentOf(key, false), blobName(key[key.length - 1]));
|
|
225
|
+
}
|
|
226
|
+
async read(key) {
|
|
227
|
+
checkBlobKey(key);
|
|
228
|
+
return await readFile(() => this.fileOf(key), async (file) => new Uint8Array(await file.arrayBuffer()));
|
|
229
|
+
}
|
|
230
|
+
async readRange(key, offset, length) {
|
|
231
|
+
checkBlobKey(key);
|
|
232
|
+
checkRange(offset, length);
|
|
233
|
+
return await readFile(() => this.fileOf(key), async (file) => new Uint8Array(await file.slice(offset, offset + length).arrayBuffer()));
|
|
234
|
+
}
|
|
235
|
+
async stat(key) {
|
|
236
|
+
checkBlobKey(key);
|
|
237
|
+
return await readFile(() => this.fileOf(key), (file) => Promise.resolve({ size: file.size, lastModified: file.lastModified }));
|
|
238
|
+
}
|
|
239
|
+
async write(key, data) {
|
|
240
|
+
checkBlobKey(key);
|
|
241
|
+
const staging = await this.root.getDirectoryHandle(STAGING, { create: true });
|
|
242
|
+
return stageAndMove(staging, async () => (await this.parentOf(key, true)), blobName(key[key.length - 1]), data);
|
|
243
|
+
}
|
|
244
|
+
async delete(key) {
|
|
245
|
+
checkBlobKey(key);
|
|
246
|
+
const parent = await this.parentOf(key, false);
|
|
247
|
+
if (parent === null)
|
|
248
|
+
return false;
|
|
249
|
+
try {
|
|
250
|
+
await parent.removeEntry(blobName(key[key.length - 1]));
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
if (isMissing(err))
|
|
255
|
+
return false;
|
|
256
|
+
throw err;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async deletePrefix(prefix) {
|
|
260
|
+
checkBlobPrefix(prefix);
|
|
261
|
+
if (prefix.length === 0) {
|
|
262
|
+
// Listed first: a directory changed as it is iterated may skip entries.
|
|
263
|
+
const names = [];
|
|
264
|
+
for await (const name of this.root.keys())
|
|
265
|
+
if (name !== STAGING)
|
|
266
|
+
names.push(name);
|
|
267
|
+
for (const name of names)
|
|
268
|
+
await removeQuietly(this.root, name, true);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const parent = await this.parentOf(prefix, false);
|
|
272
|
+
if (parent === null)
|
|
273
|
+
return;
|
|
274
|
+
const last = escapeName(prefix[prefix.length - 1]);
|
|
275
|
+
await removeQuietly(parent, `${last}${BLOB_SUFFIX}`, false);
|
|
276
|
+
await removeQuietly(parent, last, true);
|
|
277
|
+
}
|
|
278
|
+
async list(prefix) {
|
|
279
|
+
checkBlobPrefix(prefix);
|
|
280
|
+
const found = [];
|
|
281
|
+
if (prefix.length === 0) {
|
|
282
|
+
await walk(this.root, [], found, true);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
const parent = await this.parentOf(prefix, false);
|
|
286
|
+
if (parent !== null) {
|
|
287
|
+
const last = escapeName(prefix[prefix.length - 1]);
|
|
288
|
+
const own = await fileIn(parent, `${last}${BLOB_SUFFIX}`);
|
|
289
|
+
if (own !== null) {
|
|
290
|
+
const file = await own.getFile().catch((err) => (isNamed(err, 'NotFoundError') ? null : Promise.reject(err)));
|
|
291
|
+
if (file !== null)
|
|
292
|
+
found.push({ key: [...prefix], size: file.size, lastModified: file.lastModified });
|
|
293
|
+
}
|
|
294
|
+
const dir = await directoryAt(parent, [last], false);
|
|
295
|
+
if (dir !== null)
|
|
296
|
+
await walk(dir, [...prefix], found, false);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return found.sort((a, b) => compareKeys(a.key, b.key));
|
|
300
|
+
}
|
|
301
|
+
async sweep(options) {
|
|
302
|
+
return sweepStaging(await directoryAt(this.root, [STAGING], false), options);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/** A blob's file name. */
|
|
306
|
+
function blobName(part) {
|
|
307
|
+
return `${escapeName(part)}${BLOB_SUFFIX}`;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Lists the blobs under a directory, whose key's parts so far are `parts`.
|
|
311
|
+
*
|
|
312
|
+
* @param skipStaging - Whether the directory is the blobs' root, whose
|
|
313
|
+
* staging directory holds no blob
|
|
314
|
+
*/
|
|
315
|
+
async function walk(dir, parts, found, skipStaging) {
|
|
316
|
+
for await (const [name, handle] of dir.entries()) {
|
|
317
|
+
if (skipStaging && name === STAGING)
|
|
318
|
+
continue;
|
|
319
|
+
if (handle.kind === 'file') {
|
|
320
|
+
if (!name.endsWith(BLOB_SUFFIX))
|
|
321
|
+
continue;
|
|
322
|
+
const part = unescapeName(name.slice(0, -BLOB_SUFFIX.length));
|
|
323
|
+
if (part === null)
|
|
324
|
+
continue;
|
|
325
|
+
const file = await handle.getFile().catch((err) => (isNamed(err, 'NotFoundError') ? null : Promise.reject(err)));
|
|
326
|
+
if (file !== null)
|
|
327
|
+
found.push({ key: [...parts, part], size: file.size, lastModified: file.lastModified });
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
const part = unescapeName(name);
|
|
331
|
+
if (part !== null)
|
|
332
|
+
await walk(handle, [...parts, part], found, false);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** Removes an entry of a directory, if it is there. */
|
|
337
|
+
async function removeQuietly(dir, name, recursive) {
|
|
338
|
+
try {
|
|
339
|
+
await dir.removeEntry(name, { recursive });
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
if (!isMissing(err))
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Removes the files writes that never finished left in a staging directory,
|
|
348
|
+
* as {@link BlobsAdapter.sweep} does.
|
|
349
|
+
*/
|
|
350
|
+
async function sweepStaging(staging, { minAge, dryRun }) {
|
|
351
|
+
let deleted = 0;
|
|
352
|
+
let skippedYoung = 0;
|
|
353
|
+
if (staging === null)
|
|
354
|
+
return { deleted, skippedYoung };
|
|
355
|
+
const now = Date.now();
|
|
356
|
+
// Listed first: a directory changed as it is iterated may skip entries.
|
|
357
|
+
const entries = [];
|
|
358
|
+
for await (const entry of staging.entries())
|
|
359
|
+
entries.push(entry);
|
|
360
|
+
for (const [name, handle] of entries) {
|
|
361
|
+
if (handle.kind !== 'file')
|
|
362
|
+
continue;
|
|
363
|
+
let file;
|
|
364
|
+
try {
|
|
365
|
+
file = await handle.getFile();
|
|
366
|
+
}
|
|
367
|
+
catch (err) {
|
|
368
|
+
if (isNamed(err, 'NotFoundError'))
|
|
369
|
+
continue;
|
|
370
|
+
throw err;
|
|
371
|
+
}
|
|
372
|
+
if (minAge > 0 && now - file.lastModified < minAge) {
|
|
373
|
+
skippedYoung++;
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (!dryRun) {
|
|
377
|
+
try {
|
|
378
|
+
await staging.removeEntry(name);
|
|
379
|
+
}
|
|
380
|
+
catch (err) {
|
|
381
|
+
if (isNamed(err, 'NotFoundError'))
|
|
382
|
+
continue;
|
|
383
|
+
// A write still has it open: in flight, whatever its age.
|
|
384
|
+
if (isNamed(err, 'NoModificationAllowedError')) {
|
|
385
|
+
skippedYoung++;
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
deleted++;
|
|
392
|
+
}
|
|
393
|
+
return { deleted, skippedYoung };
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Files in OPFS, named by absolute `/`-separated paths from a root
|
|
397
|
+
* directory: the origin's OPFS root unless given.
|
|
398
|
+
*
|
|
399
|
+
* @remarks
|
|
400
|
+
* A path's names are escaped as blob keys' parts are. A write stages its file
|
|
401
|
+
* in the root's `.staging`, and moves it into place once it is whole. A read
|
|
402
|
+
* yields the file as it was when the read began, in slices of the adapter's
|
|
403
|
+
* read size, never in the chunks a stream of it hands over: those are the
|
|
404
|
+
* browser's choice, and as large as the whole file.
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```ts
|
|
408
|
+
* const files = await OpfsFiles.open();
|
|
409
|
+
* await files.mkdir('/uploads');
|
|
410
|
+
* await files.write('/uploads/delivery.beast2', chunks);
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export class OpfsFiles {
|
|
414
|
+
root;
|
|
415
|
+
/** How many bytes a read yields at a time */
|
|
416
|
+
readChunk;
|
|
417
|
+
/**
|
|
418
|
+
* @param root - The directory paths start at
|
|
419
|
+
* @param options - How many bytes a read yields at a time
|
|
420
|
+
* @throws {RangeError} When the read size is not a whole number of bytes
|
|
421
|
+
* greater than zero
|
|
422
|
+
*/
|
|
423
|
+
constructor(root, options = {}) {
|
|
424
|
+
this.root = root;
|
|
425
|
+
this.readChunk = readChunkOf(options);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Opens files at the origin's OPFS root.
|
|
429
|
+
*
|
|
430
|
+
* @param options - How many bytes a read yields at a time
|
|
431
|
+
* @returns The adapter
|
|
432
|
+
* @throws {RangeError} When the read size is not a whole number of bytes
|
|
433
|
+
* greater than zero
|
|
434
|
+
*/
|
|
435
|
+
static async open(options = {}) {
|
|
436
|
+
return new OpfsFiles(await navigator.storage.getDirectory(), options);
|
|
437
|
+
}
|
|
438
|
+
/** The directory a path's file is in, or `null` when it is not there. */
|
|
439
|
+
parentOf(names) {
|
|
440
|
+
return directoryAt(this.root, names.slice(0, -1).map(escapeName), false);
|
|
441
|
+
}
|
|
442
|
+
/** The file at a path, or `null` when there is none. */
|
|
443
|
+
async fileAt(path) {
|
|
444
|
+
const names = pathNames(path);
|
|
445
|
+
if (names.length === 0)
|
|
446
|
+
return null;
|
|
447
|
+
return fileIn(await this.parentOf(names), escapeName(names[names.length - 1]));
|
|
448
|
+
}
|
|
449
|
+
async stat(path) {
|
|
450
|
+
return await readFile(() => this.fileAt(path), (file) => Promise.resolve({ size: file.size, lastModified: file.lastModified }));
|
|
451
|
+
}
|
|
452
|
+
async *read(path) {
|
|
453
|
+
const handle = await this.fileAt(path);
|
|
454
|
+
if (handle === null)
|
|
455
|
+
throw new FileNotFoundError(path);
|
|
456
|
+
let file;
|
|
457
|
+
try {
|
|
458
|
+
file = await handle.getFile();
|
|
459
|
+
}
|
|
460
|
+
catch (err) {
|
|
461
|
+
if (isNamed(err, 'NotFoundError'))
|
|
462
|
+
throw new FileNotFoundError(path);
|
|
463
|
+
throw err;
|
|
464
|
+
}
|
|
465
|
+
// The file as it was when the read began, a slice of the adapter's at a
|
|
466
|
+
// time: a stream of it hands it over in chunks of the browser's choosing,
|
|
467
|
+
// the whole file among them.
|
|
468
|
+
for (let offset = 0; offset < file.size; offset += this.readChunk) {
|
|
469
|
+
yield new Uint8Array(await file.slice(offset, offset + this.readChunk).arrayBuffer());
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async write(path, data) {
|
|
473
|
+
const names = pathNames(path);
|
|
474
|
+
if (names.length === 0)
|
|
475
|
+
throw new TypeError('/ is a directory, not a file');
|
|
476
|
+
const parent = await this.parentOf(names);
|
|
477
|
+
if (parent === null)
|
|
478
|
+
throw new FileNotFoundError(names.length === 1 ? '/' : `/${names.slice(0, -1).join('/')}`);
|
|
479
|
+
const staging = await this.root.getDirectoryHandle(STAGING, { create: true });
|
|
480
|
+
return stageAndMove(staging, () => Promise.resolve(parent), escapeName(names[names.length - 1]), data);
|
|
481
|
+
}
|
|
482
|
+
async remove(path) {
|
|
483
|
+
const names = pathNames(path);
|
|
484
|
+
if (names.length === 0)
|
|
485
|
+
return false;
|
|
486
|
+
const parent = await this.parentOf(names);
|
|
487
|
+
const name = escapeName(names[names.length - 1]);
|
|
488
|
+
if ((await fileIn(parent, name)) === null)
|
|
489
|
+
return false;
|
|
490
|
+
try {
|
|
491
|
+
await parent.removeEntry(name);
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
catch (err) {
|
|
495
|
+
if (isMissing(err))
|
|
496
|
+
return false;
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
async mkdir(path) {
|
|
501
|
+
await directoryAt(this.root, pathNames(path).map(escapeName), true);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Removes what writes that never finished left in the root's staging
|
|
505
|
+
* directory, as {@link BlobsAdapter.sweep} does for blobs.
|
|
506
|
+
*
|
|
507
|
+
* @param options - The age gate, and whether this is a dry run
|
|
508
|
+
* @returns What it removed, or in a dry run would, and what it left
|
|
509
|
+
*/
|
|
510
|
+
async sweep(options) {
|
|
511
|
+
return sweepStaging(await directoryAt(this.root, [STAGING], false), options);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
//# sourceMappingURL=opfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opfs.js","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+1 @@
|
|
|
1
|
+
{"version":3,"file":"opfs.spec.d.ts","sourceRoot":"","sources":["../../../src/storage/opfs.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The names OPFS files are given: every key's part and path's name escaped to
|
|
7
|
+
* one no other escapes to, whatever case the file system folds. The adapters
|
|
8
|
+
* themselves are held to their contract in Chromium, by
|
|
9
|
+
* `browser/storage.spec.ts`.
|
|
10
|
+
*/
|
|
11
|
+
import { describe, it } from 'node:test';
|
|
12
|
+
import assert from 'node:assert/strict';
|
|
13
|
+
import { escapeName, unescapeName } from './opfs.js';
|
|
14
|
+
describe('the names of OPFS files', () => {
|
|
15
|
+
it('keeps lowercase letters, digits, underscores, hyphens and a dot after the first character', () => {
|
|
16
|
+
assert.equal(escapeName('abc-012_xyz.beast2'), 'abc-012_xyz.beast2');
|
|
17
|
+
assert.equal(escapeName('a.b..c'), 'a.b..c');
|
|
18
|
+
});
|
|
19
|
+
it('escapes every other character as the hex of its UTF-8 bytes', () => {
|
|
20
|
+
assert.equal(escapeName('Case'), '%43ase');
|
|
21
|
+
assert.equal(escapeName('.'), '%2E');
|
|
22
|
+
assert.equal(escapeName('..'), '%2E.');
|
|
23
|
+
assert.equal(escapeName('.hidden'), '%2Ehidden');
|
|
24
|
+
assert.equal(escapeName('%41'), '%2541');
|
|
25
|
+
assert.equal(escapeName('~'), '%7E');
|
|
26
|
+
assert.equal(escapeName('a/b\\c'), 'a%2Fb%5Cc');
|
|
27
|
+
assert.equal(escapeName("!'()*"), '%21%27%28%29%2A');
|
|
28
|
+
assert.equal(escapeName('é'), '%C3%A9');
|
|
29
|
+
assert.equal(escapeName('😀'), '%F0%9F%98%80');
|
|
30
|
+
assert.equal(escapeName('nul\u0000'), 'nul%00');
|
|
31
|
+
});
|
|
32
|
+
it('gives names that differ even where a file system folds case', () => {
|
|
33
|
+
const parts = ['Case', 'case', 'CASE', 'J', 'j', '%4A', '%4a', 'é', 'É', 'ß', 'SS'];
|
|
34
|
+
const folded = parts.map((part) => escapeName(part).toLowerCase());
|
|
35
|
+
assert.equal(new Set(folded).size, parts.length, folded.join(' '));
|
|
36
|
+
});
|
|
37
|
+
it('unescapes every name it gives, and no other', () => {
|
|
38
|
+
for (const part of ['abc', 'Case', '.', '..', '%41', '~', 'a/b', 'é', '日本', 'emoji 😀', 'nul\u0000']) {
|
|
39
|
+
assert.equal(unescapeName(escapeName(part)), part);
|
|
40
|
+
}
|
|
41
|
+
assert.equal(unescapeName('%41'), 'A');
|
|
42
|
+
for (const name of ['A', '%4a', '.x', '~', 'a~', '%', '%E0%A4%A', '']) {
|
|
43
|
+
assert.equal(unescapeName(name), null, `'${name}' is no name escapeName gives`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
it('refuses an empty part, and one holding a lone surrogate', () => {
|
|
47
|
+
assert.throws(() => escapeName(''), TypeError);
|
|
48
|
+
assert.throws(() => escapeName('a\uD83D'), TypeError);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=opfs.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opfs.spec.js","sourceRoot":"","sources":["../../../src/storage/opfs.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAErD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,2FAA2F,EAAE,GAAG,EAAE;QACnG,MAAM,CAAC,KAAK,CAAC,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