@e280/quay 0.0.0-2 → 0.0.0-20
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 +98 -0
- package/package.json +17 -11
- package/s/cellar/cask.ts +1 -13
- package/s/cellar/cellar.test.ts +25 -42
- package/s/cellar/cellar.ts +16 -20
- package/s/cellar/index.ts +0 -4
- package/s/cellar/mammoth.ts +50 -0
- package/s/cellar/mammoth.worker.bundle.ts +30 -0
- package/s/demo/main.bundle.ts +2 -3
- package/s/dom/components/breadcrumb/component.ts +6 -5
- package/s/dom/components/browser/component.ts +11 -7
- package/s/dom/components/browser/style.css.ts +31 -31
- package/s/dom/components/dropzone/component.ts +6 -4
- package/s/dom/components/dropzone/style.css.ts +12 -13
- package/s/dom/components/filter/component.ts +13 -8
- package/s/dom/components/outliner/component.ts +8 -5
- package/s/dom/components/searchbar/component.ts +13 -7
- package/s/dom/components/sort/component.ts +13 -9
- package/s/dom/theme.css.ts +66 -2
- package/s/dom/views/tree/component.ts +10 -8
- package/s/dom/views/tree/style.css.ts +10 -10
- package/s/genius/parts/hy-tree.ts +10 -9
- package/s/index.html.ts +68 -73
- package/s/index.ts +6 -1
- package/s/logic/aspects/codex/codex.ts +3 -3
- package/s/logic/aspects/codex/example.ts +1 -4
- package/s/logic/aspects/codex/parts/codex-item.ts +4 -4
- package/s/logic/aspects/codex/parts/hierarchy.ts +1 -0
- package/s/logic/aspects/codex/parts/types.ts +1 -1
- package/s/logic/aspects/dropzone.ts +20 -16
- package/s/logic/aspects/tree-trail.ts +5 -4
- package/s/logic/brain.ts +5 -3
- package/s/logic/group.ts +13 -10
- package/s/logic/presets/media/group.ts +5 -4
- package/s/logic/presets/media/library.test.ts +82 -0
- package/s/logic/presets/media/library.ts +249 -0
- package/s/logic/presets/media/schema.ts +10 -1
- package/s/logic/presets/opfs/schema.ts +1 -1
- package/s/logic/presets/plain/group.ts +2 -2
- package/s/logic/presets/plain/schema.ts +1 -1
- package/s/logic/types.ts +1 -1
- package/s/tests.test.ts +2 -0
- package/x/cellar/cask.d.ts +2 -4
- package/x/cellar/cask.js +3 -12
- package/x/cellar/cask.js.map +1 -1
- package/x/cellar/cellar.d.ts +9 -7
- package/x/cellar/cellar.js +17 -22
- package/x/cellar/cellar.js.map +1 -1
- package/x/cellar/cellar.test.d.ts +2 -3
- package/x/cellar/cellar.test.js +24 -39
- package/x/cellar/cellar.test.js.map +1 -1
- package/x/cellar/index.d.ts +0 -3
- package/x/cellar/index.js +0 -3
- package/x/cellar/index.js.map +1 -1
- package/x/cellar/mammoth.d.ts +23 -0
- package/x/cellar/mammoth.js +34 -0
- package/x/cellar/mammoth.js.map +1 -0
- package/x/cellar/mammoth.worker.bundle.d.ts +1 -0
- package/x/cellar/mammoth.worker.bundle.js +20 -0
- package/x/cellar/mammoth.worker.bundle.js.map +1 -0
- package/x/cellar/mammoth.worker.bundle.min.js +8 -0
- package/x/cellar/mammoth.worker.bundle.min.js.map +7 -0
- package/x/demo/main.bundle.js +2 -2
- package/x/demo/main.bundle.js.map +1 -1
- package/x/demo/main.bundle.min.js +229 -197
- package/x/demo/main.bundle.min.js.LEGAL.txt +33 -0
- package/x/demo/main.bundle.min.js.map +7 -0
- package/x/dom/components/breadcrumb/component.d.ts +1 -1
- package/x/dom/components/breadcrumb/component.js +6 -5
- package/x/dom/components/breadcrumb/component.js.map +1 -1
- package/x/dom/components/browser/component.d.ts +1 -1
- package/x/dom/components/browser/component.js +10 -7
- package/x/dom/components/browser/component.js.map +1 -1
- package/x/dom/components/browser/style.css.d.ts +1 -1
- package/x/dom/components/browser/style.css.js +31 -30
- package/x/dom/components/browser/style.css.js.map +1 -1
- package/x/dom/components/dropzone/component.d.ts +1 -1
- package/x/dom/components/dropzone/component.js +6 -4
- package/x/dom/components/dropzone/component.js.map +1 -1
- package/x/dom/components/dropzone/style.css.d.ts +1 -1
- package/x/dom/components/dropzone/style.css.js +12 -12
- package/x/dom/components/dropzone/style.css.js.map +1 -1
- package/x/dom/components/filter/component.d.ts +1 -1
- package/x/dom/components/filter/component.js +10 -8
- package/x/dom/components/filter/component.js.map +1 -1
- package/x/dom/components/outliner/component.d.ts +1 -1
- package/x/dom/components/outliner/component.js +7 -5
- package/x/dom/components/outliner/component.js.map +1 -1
- package/x/dom/components/searchbar/component.d.ts +1 -1
- package/x/dom/components/searchbar/component.js +12 -6
- package/x/dom/components/searchbar/component.js.map +1 -1
- package/x/dom/components/sort/component.d.ts +1 -1
- package/x/dom/components/sort/component.js +11 -9
- package/x/dom/components/sort/component.js.map +1 -1
- package/x/dom/components.d.ts +7 -7
- package/x/dom/theme.css.d.ts +1 -1
- package/x/dom/theme.css.js +65 -1
- package/x/dom/theme.css.js.map +1 -1
- package/x/dom/views/tree/component.d.ts +1 -6
- package/x/dom/views/tree/component.js +10 -8
- package/x/dom/views/tree/component.js.map +1 -1
- package/x/dom/views/tree/style.css.d.ts +1 -1
- package/x/dom/views/tree/style.css.js +10 -10
- package/x/dom/views/tree/style.css.js.map +1 -1
- package/x/genius/parts/hy-tree.js +9 -8
- package/x/genius/parts/hy-tree.js.map +1 -1
- package/x/index.d.ts +6 -1
- package/x/index.html +70 -167
- package/x/index.html.d.ts +1 -2
- package/x/index.html.js +67 -73
- package/x/index.html.js.map +1 -1
- package/x/index.js +6 -1
- package/x/index.js.map +1 -1
- package/x/logic/aspects/codex/codex.js +3 -3
- package/x/logic/aspects/codex/codex.js.map +1 -1
- package/x/logic/aspects/codex/example.d.ts +0 -1
- package/x/logic/aspects/codex/example.js +1 -3
- package/x/logic/aspects/codex/example.js.map +1 -1
- package/x/logic/aspects/codex/parts/codex-item.d.ts +1 -1
- package/x/logic/aspects/codex/parts/codex-item.js +4 -4
- package/x/logic/aspects/codex/parts/codex-item.js.map +1 -1
- package/x/logic/aspects/codex/parts/hierarchy.js +1 -0
- package/x/logic/aspects/codex/parts/hierarchy.js.map +1 -1
- package/x/logic/aspects/codex/parts/types.d.ts +1 -1
- package/x/logic/aspects/dropzone.d.ts +1 -1
- package/x/logic/aspects/dropzone.js +19 -15
- package/x/logic/aspects/dropzone.js.map +1 -1
- package/x/logic/aspects/tree-trail.d.ts +1 -1
- package/x/logic/aspects/tree-trail.js +4 -4
- package/x/logic/aspects/tree-trail.js.map +1 -1
- package/x/logic/brain.d.ts +4 -2
- package/x/logic/brain.js.map +1 -1
- package/x/logic/group.d.ts +7 -7
- package/x/logic/group.js +10 -8
- package/x/logic/group.js.map +1 -1
- package/x/logic/presets/media/group.d.ts +1 -1
- package/x/logic/presets/media/group.js +3 -3
- package/x/logic/presets/media/group.js.map +1 -1
- package/x/logic/presets/media/library.d.ts +59 -0
- package/x/logic/presets/media/library.js +201 -0
- package/x/logic/presets/media/library.js.map +1 -0
- package/x/logic/presets/media/library.test.d.ts +9 -0
- package/x/logic/presets/media/library.test.js +62 -0
- package/x/logic/presets/media/library.test.js.map +1 -0
- package/x/logic/presets/media/schema.d.ts +10 -1
- package/x/logic/presets/opfs/schema.d.ts +1 -1
- package/x/logic/presets/plain/group.js +2 -2
- package/x/logic/presets/plain/group.js.map +1 -1
- package/x/logic/presets/plain/schema.d.ts +1 -1
- package/x/logic/types.d.ts +1 -1
- package/x/tests.test.js +2 -0
- package/x/tests.test.js.map +1 -1
- package/s/cellar/forklift.ts +0 -9
- package/s/cellar/memory-forklift.ts +0 -29
- package/s/cellar/opfs-forklift.ts +0 -49
- package/x/cellar/forklift.d.ts +0 -7
- package/x/cellar/forklift.js +0 -2
- package/x/cellar/forklift.js.map +0 -1
- package/x/cellar/memory-forklift.d.ts +0 -9
- package/x/cellar/memory-forklift.js +0 -21
- package/x/cellar/memory-forklift.js.map +0 -1
- package/x/cellar/opfs-forklift.d.ts +0 -11
- package/x/cellar/opfs-forklift.js +0 -44
- package/x/cellar/opfs-forklift.js.map +0 -1
- package/x/genius/folio.md +0 -29
- package/x/genius/quay.md +0 -13
- package/x/genius/turbo.md +0 -21
- package/x/importmap.json +0 -47
package/s/logic/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
+
import {Content} from "@e280/sly"
|
|
2
3
|
import {Permission} from "./permissions.js"
|
|
3
4
|
import {Codex} from "./aspects/codex/codex.js"
|
|
4
5
|
import {Schema} from "./aspects/codex/parts/types.js"
|
|
5
6
|
import {CodexItem} from "./aspects/codex/parts/codex-item.js"
|
|
6
|
-
import { Content } from "@benev/slate"
|
|
7
7
|
|
|
8
8
|
export type SearchFn<Sc extends Schema> = (item: CodexItem<Sc>) => boolean
|
|
9
9
|
export type SortFn<Sc extends Schema> = (a: CodexItem<Sc>, b: CodexItem<Sc>) => number
|
package/s/tests.test.ts
CHANGED
package/x/cellar/cask.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/** File with a hash label */
|
|
2
2
|
export declare class Cask {
|
|
3
3
|
hash: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
static make(bytes: Uint8Array): Promise<Cask>;
|
|
7
|
-
constructor(hash: string, bytes: Uint8Array);
|
|
4
|
+
file: Blob;
|
|
5
|
+
constructor(hash: string, file: Blob);
|
|
8
6
|
}
|
package/x/cellar/cask.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { Hex } from "@e280/stz";
|
|
2
1
|
/** File with a hash label */
|
|
3
2
|
export class Cask {
|
|
4
3
|
hash;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
|
|
8
|
-
return Hex.fromBytes(new Uint8Array(hashBuffer));
|
|
9
|
-
}
|
|
10
|
-
static async make(bytes) {
|
|
11
|
-
const hash = await this.hash(bytes);
|
|
12
|
-
return new this(hash, bytes);
|
|
13
|
-
}
|
|
14
|
-
constructor(hash, bytes) {
|
|
4
|
+
file;
|
|
5
|
+
constructor(hash, file) {
|
|
15
6
|
this.hash = hash;
|
|
16
|
-
this.
|
|
7
|
+
this.file = file;
|
|
17
8
|
}
|
|
18
9
|
}
|
|
19
10
|
//# sourceMappingURL=cask.js.map
|
package/x/cellar/cask.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cask.js","sourceRoot":"","sources":["../../s/cellar/cask.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"cask.js","sourceRoot":"","sources":["../../s/cellar/cask.ts"],"names":[],"mappings":"AACA,6BAA6B;AAC7B,MAAM,OAAO,IAAI;IACG;IAAqB;IAAxC,YAAmB,IAAY,EAAS,IAAU;QAA/B,SAAI,GAAJ,IAAI,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;CACtD"}
|
package/x/cellar/cellar.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import { Mammoth } from "@e280/mammoth";
|
|
1
2
|
import { Cask } from "./cask.js";
|
|
2
|
-
import {
|
|
3
|
+
import { MammothOpfs } from "./mammoth.js";
|
|
3
4
|
/**
|
|
4
5
|
* Cellar is an immutable content-addressable file store
|
|
5
6
|
* - files are identified by their hashes (duplicates are impossible)
|
|
6
7
|
* - files cannot be modified (delete it and save another)
|
|
7
8
|
* - no filenames or metadata (store those somewhere else)
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* - new Cellar uses Mammoth's in-memory backend by default
|
|
10
|
+
* - Cellar.opfs creates MammothOpfs for persistent browser storage
|
|
11
|
+
* - pass in a Mammoth to use a different backend
|
|
12
|
+
* - most likely you want to use Cellar.opfs for storing files in the browser
|
|
11
13
|
*/
|
|
12
14
|
export declare class Cellar {
|
|
13
|
-
private
|
|
15
|
+
private mammoth;
|
|
14
16
|
static opfs(dirname?: string): Promise<Cellar>;
|
|
15
|
-
constructor(
|
|
17
|
+
constructor(mammoth?: Mammoth | MammothOpfs);
|
|
16
18
|
list(): AsyncIterable<string>;
|
|
17
19
|
has(hash: string): Promise<boolean>;
|
|
18
|
-
|
|
20
|
+
write(readable: ReadableStream<Uint8Array>): Promise<string>;
|
|
19
21
|
load(hash: string): Promise<Cask>;
|
|
20
22
|
delete(hash: string): Promise<void>;
|
|
21
23
|
clear(): Promise<void>;
|
package/x/cellar/cellar.js
CHANGED
|
@@ -1,44 +1,39 @@
|
|
|
1
|
+
import { Mammoth } from "@e280/mammoth";
|
|
1
2
|
import { Cask } from "./cask.js";
|
|
2
|
-
import {
|
|
3
|
-
import { MemoryForklift } from "./memory-forklift.js";
|
|
3
|
+
import { MammothOpfs } from "./mammoth.js";
|
|
4
4
|
/**
|
|
5
5
|
* Cellar is an immutable content-addressable file store
|
|
6
6
|
* - files are identified by their hashes (duplicates are impossible)
|
|
7
7
|
* - files cannot be modified (delete it and save another)
|
|
8
8
|
* - no filenames or metadata (store those somewhere else)
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* - new Cellar uses Mammoth's in-memory backend by default
|
|
10
|
+
* - Cellar.opfs creates MammothOpfs for persistent browser storage
|
|
11
|
+
* - pass in a Mammoth to use a different backend
|
|
12
|
+
* - most likely you want to use Cellar.opfs for storing files in the browser
|
|
12
13
|
*/
|
|
13
14
|
export class Cellar {
|
|
14
|
-
|
|
15
|
+
mammoth;
|
|
15
16
|
static async opfs(dirname = "cellar") {
|
|
16
|
-
return new this(await
|
|
17
|
+
return new this(await MammothOpfs.setup(dirname));
|
|
17
18
|
}
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
19
|
+
constructor(mammoth = new Mammoth()) {
|
|
20
|
+
this.mammoth = mammoth;
|
|
20
21
|
}
|
|
21
22
|
async *list() {
|
|
22
|
-
|
|
23
|
+
for await (const [hash] of this.mammoth.entries())
|
|
24
|
+
yield hash;
|
|
23
25
|
}
|
|
24
26
|
async has(hash) {
|
|
25
|
-
return this.
|
|
27
|
+
return this.mammoth.has(hash);
|
|
26
28
|
}
|
|
27
|
-
async
|
|
28
|
-
|
|
29
|
-
if (!await this.forklift.has(cask.hash))
|
|
30
|
-
await this.forklift.save(cask.hash, cask.bytes);
|
|
31
|
-
return cask;
|
|
29
|
+
async write(readable) {
|
|
30
|
+
return this.mammoth.write(readable);
|
|
32
31
|
}
|
|
33
32
|
async load(hash) {
|
|
34
|
-
|
|
35
|
-
const cask = await Cask.make(bytes);
|
|
36
|
-
if (cask.hash !== hash)
|
|
37
|
-
throw new Error(`corruption error, hash mismatch (requested ${hash}) (got ${cask.hash})`);
|
|
38
|
-
return cask;
|
|
33
|
+
return new Cask(hash, await this.mammoth.read(hash));
|
|
39
34
|
}
|
|
40
35
|
async delete(hash) {
|
|
41
|
-
await this.
|
|
36
|
+
await this.mammoth.delete(hash);
|
|
42
37
|
}
|
|
43
38
|
async clear() {
|
|
44
39
|
for await (const hash of this.list())
|
package/x/cellar/cellar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellar.js","sourceRoot":"","sources":["../../s/cellar/cellar.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"cellar.js","sourceRoot":"","sources":["../../s/cellar/cellar.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AAExC;;;;;;;;;GASG;AACH,MAAM,OAAO,MAAM;IAKE;IAJpB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ;QACnC,OAAO,IAAI,IAAI,CAAC,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,YAAoB,UAAiC,IAAI,OAAO,EAAE;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAEtE,KAAK,CAAC,CAAC,IAAI;QACV,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAChD,MAAM,IAAI,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,QAAoC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY;QACtB,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,KAAK;QACV,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;YACnC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Science } from "@e280/science";
|
|
2
2
|
declare const _default: {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"throws on corruption": Science.Test;
|
|
3
|
+
"write + load roundtrip": Science.Test;
|
|
4
|
+
"write is idempotent": Science.Test;
|
|
6
5
|
"delete removes file": Science.Test;
|
|
7
6
|
"load missing throws": Science.Test;
|
|
8
7
|
"list returns saved hashes": Science.Test;
|
package/x/cellar/cellar.test.js
CHANGED
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
import { Txt } from "@e280/stz";
|
|
2
2
|
import { expect, Science, test } from "@e280/science";
|
|
3
|
-
import { Cask } from "./cask.js";
|
|
4
3
|
import { Cellar } from "./cellar.js";
|
|
5
|
-
|
|
4
|
+
const blob = (text) => new Blob([Txt.toBytes(text)]);
|
|
6
5
|
export default Science.suite({
|
|
7
|
-
"
|
|
6
|
+
"write + load roundtrip": test(async () => {
|
|
8
7
|
const cellar = new Cellar();
|
|
9
8
|
const text = "hello world";
|
|
10
|
-
const
|
|
11
|
-
await cellar.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
expect(loaded.
|
|
16
|
-
expect(Txt.fromBytes(loaded.bytes)).is(text);
|
|
9
|
+
const file = blob(text);
|
|
10
|
+
const digest = await cellar.write(file.stream());
|
|
11
|
+
expect(await cellar.has(digest)).is(true);
|
|
12
|
+
const loaded = await cellar.load(digest);
|
|
13
|
+
expect(loaded.hash).is(digest);
|
|
14
|
+
expect(await loaded.file.text()).is(text);
|
|
17
15
|
}),
|
|
18
|
-
"
|
|
16
|
+
"write is idempotent": test(async () => {
|
|
19
17
|
const cellar = new Cellar();
|
|
20
|
-
const
|
|
21
|
-
await cellar.
|
|
22
|
-
await cellar.
|
|
23
|
-
|
|
24
|
-
expect(await cellar.has(hash)).is(true);
|
|
25
|
-
}),
|
|
26
|
-
"throws on corruption": test(async () => {
|
|
27
|
-
const forklift = new MemoryForklift();
|
|
28
|
-
const cellar = new Cellar(forklift);
|
|
29
|
-
const good = new TextEncoder().encode("valid data");
|
|
30
|
-
const bad = new TextEncoder().encode("corrupt data");
|
|
31
|
-
const hash = await Cask.hash(good);
|
|
32
|
-
await forklift.save(hash, bad);
|
|
33
|
-
await expect(async () => cellar.load(hash)).throwsAsync();
|
|
18
|
+
const file = blob("foo bar");
|
|
19
|
+
const digest = await cellar.write(file.stream());
|
|
20
|
+
expect(await cellar.write(file.stream())).is(digest);
|
|
21
|
+
expect(await cellar.has(digest)).is(true);
|
|
34
22
|
}),
|
|
35
23
|
"delete removes file": test(async () => {
|
|
36
24
|
const cellar = new Cellar();
|
|
37
|
-
const
|
|
38
|
-
await cellar.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
await cellar.
|
|
42
|
-
expect(await cellar.has(hash)).is(false);
|
|
25
|
+
const file = blob("temporary data");
|
|
26
|
+
const digest = await cellar.write(file.stream());
|
|
27
|
+
expect(await cellar.has(digest)).is(true);
|
|
28
|
+
await cellar.delete(digest);
|
|
29
|
+
expect(await cellar.has(digest)).is(false);
|
|
43
30
|
}),
|
|
44
31
|
"load missing throws": test(async () => {
|
|
45
32
|
const cellar = new Cellar();
|
|
@@ -50,21 +37,19 @@ export default Science.suite({
|
|
|
50
37
|
const cellar = new Cellar();
|
|
51
38
|
const texts = ["a", "b", "c"];
|
|
52
39
|
for (const t of texts)
|
|
53
|
-
await cellar.
|
|
40
|
+
await cellar.write(blob(t).stream());
|
|
54
41
|
const hashes = [];
|
|
55
42
|
for await (const hash of cellar.list())
|
|
56
43
|
hashes.push(hash);
|
|
57
44
|
expect(hashes.length).is(3);
|
|
58
|
-
for (const
|
|
59
|
-
|
|
60
|
-
expect(hashes.includes(h)).is(true);
|
|
61
|
-
}
|
|
45
|
+
for (const text of texts)
|
|
46
|
+
expect(hashes.includes(await cellar.write(blob(text).stream()))).is(true);
|
|
62
47
|
}),
|
|
63
48
|
"clear removes all entries": test(async () => {
|
|
64
49
|
const cellar = new Cellar();
|
|
65
|
-
await cellar.
|
|
66
|
-
await cellar.
|
|
67
|
-
await cellar.
|
|
50
|
+
await cellar.write(blob("one").stream());
|
|
51
|
+
await cellar.write(blob("two").stream());
|
|
52
|
+
await cellar.write(blob("three").stream());
|
|
68
53
|
let count = 0;
|
|
69
54
|
for await (const _ of cellar.list())
|
|
70
55
|
count++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellar.test.js","sourceRoot":"","sources":["../../s/cellar/cellar.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"cellar.test.js","sourceRoot":"","sources":["../../s/cellar/cellar.test.ts"],"names":[],"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A;QACtB,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE;YAAE,cAAc,EAAE,CAAA;QACrD,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC,CAAC;CACF,CAAC,CAAA"}
|
package/x/cellar/index.d.ts
CHANGED
package/x/cellar/index.js
CHANGED
package/x/cellar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/cellar/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/cellar/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Thread, AsSchematic } from "@e280/comrade";
|
|
2
|
+
export type MammothSchematic = AsSchematic<{
|
|
3
|
+
work: {
|
|
4
|
+
setup(dirname: string): Promise<void>;
|
|
5
|
+
write(readable: ReadableStream<Uint8Array>): Promise<string>;
|
|
6
|
+
has(hash: string): Promise<boolean>;
|
|
7
|
+
read(hash: string): Promise<Blob>;
|
|
8
|
+
delete(hash: string): Promise<void>;
|
|
9
|
+
hashes(): Promise<string[]>;
|
|
10
|
+
};
|
|
11
|
+
host: {};
|
|
12
|
+
}>;
|
|
13
|
+
/** Worker proxy for Mammoth using an OPFS bucket and IndexedDB manifest. */
|
|
14
|
+
export declare class MammothOpfs {
|
|
15
|
+
private thread;
|
|
16
|
+
static setup(dirname: string): Promise<MammothOpfs>;
|
|
17
|
+
constructor(thread: Thread<MammothSchematic>);
|
|
18
|
+
write(readable: ReadableStream<Uint8Array>): Promise<string>;
|
|
19
|
+
has(hash: string): Promise<boolean>;
|
|
20
|
+
read(hash: string): Promise<Blob>;
|
|
21
|
+
delete(hash: string): Promise<void>;
|
|
22
|
+
entries(): AsyncIterable<[string, unknown]>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Comrade, tune } from "@e280/comrade";
|
|
2
|
+
/** Worker proxy for Mammoth using an OPFS bucket and IndexedDB manifest. */
|
|
3
|
+
export class MammothOpfs {
|
|
4
|
+
thread;
|
|
5
|
+
static async setup(dirname) {
|
|
6
|
+
const thread = await Comrade.thread({
|
|
7
|
+
workerUrl: "/node_modules/@e280/quay/x/cellar/mammoth.worker.bundle.min.js",
|
|
8
|
+
setupHost: () => ({}),
|
|
9
|
+
});
|
|
10
|
+
const mammoth = new this(thread);
|
|
11
|
+
await mammoth.thread.work.setup(dirname);
|
|
12
|
+
return mammoth;
|
|
13
|
+
}
|
|
14
|
+
constructor(thread) {
|
|
15
|
+
this.thread = thread;
|
|
16
|
+
}
|
|
17
|
+
async write(readable) {
|
|
18
|
+
return this.thread.work.write[tune]({ transfer: [readable] })(readable);
|
|
19
|
+
}
|
|
20
|
+
async has(hash) {
|
|
21
|
+
return this.thread.work.has(hash);
|
|
22
|
+
}
|
|
23
|
+
async read(hash) {
|
|
24
|
+
return this.thread.work.read(hash);
|
|
25
|
+
}
|
|
26
|
+
async delete(hash) {
|
|
27
|
+
return this.thread.work.delete(hash);
|
|
28
|
+
}
|
|
29
|
+
async *entries() {
|
|
30
|
+
for (const hash of await this.thread.work.hashes())
|
|
31
|
+
yield [hash, undefined];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=mammoth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mammoth.js","sourceRoot":"","sources":["../../s/cellar/mammoth.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAU,IAAI,EAAc,MAAM,eAAe,CAAA;AAchE,4EAA4E;AAC5E,MAAM,OAAO,WAAW;IAWH;IAVpB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAe;QACjC,MAAM,MAAM,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|
2
|
+
import { Comrade } from "@e280/comrade";
|
|
3
|
+
import { Mammoth, OpfsBucket } from "@e280/mammoth";
|
|
4
|
+
import { idbOpen, IdbMagazine, Kv } from "@e280/kv";
|
|
5
|
+
let mammoth;
|
|
6
|
+
await Comrade.worker(() => ({
|
|
7
|
+
async setup(dirname) {
|
|
8
|
+
const root = await navigator.storage.getDirectory();
|
|
9
|
+
const directory = await root.getDirectoryHandle(dirname, { create: true });
|
|
10
|
+
mammoth = new Mammoth(new OpfsBucket(directory), new Kv(new IdbMagazine(await idbOpen(`quay.mammoth:${dirname}`))));
|
|
11
|
+
},
|
|
12
|
+
write: readable => mammoth.write(readable),
|
|
13
|
+
has: hash => mammoth.has(hash),
|
|
14
|
+
read: hash => mammoth.read(hash),
|
|
15
|
+
delete: hash => mammoth.delete(hash),
|
|
16
|
+
async hashes() {
|
|
17
|
+
return (await collect(mammoth.entries())).map(([hash]) => hash);
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
//# sourceMappingURL=mammoth.worker.bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mammoth.worker.bundle.js","sourceRoot":"","sources":["../../s/cellar/mammoth.worker.bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AACjD,OAAO,EAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAC,MAAM,UAAU,CAAA;AAIjD,IAAI,OAAgB,CAAA;AAEpB,MAAM,OAAO,CAAC,MAAM,CAAmB,GAAG,EAAE,CAAC,CAAC;IAC7C,KAAK,CAAC,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,CAAA;QACnD,MAAM,SAAS,GAAG,MAAM,IAAI,C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