@e280/quay 0.0.0-17 → 0.0.0-18
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/package.json +6 -4
- package/s/cellar/cask.ts +0 -18
- package/s/cellar/cellar.test.ts +19 -38
- 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/genius/parts/hy-tree.ts +10 -9
- package/s/logic/presets/media/library.ts +57 -12
- package/s/logic/presets/media/schema.ts +6 -0
- package/x/cellar/cask.d.ts +0 -2
- package/x/cellar/cask.js +0 -13
- 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 +19 -35
- 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.min.js +43 -43
- package/x/demo/main.bundle.min.js.map +4 -4
- package/x/genius/parts/hy-tree.js +9 -8
- package/x/genius/parts/hy-tree.js.map +1 -1
- package/x/index.html +2 -2
- package/x/logic/presets/media/library.d.ts +3 -2
- package/x/logic/presets/media/library.js +46 -9
- package/x/logic/presets/media/library.js.map +1 -1
- package/x/logic/presets/media/schema.d.ts +6 -0
- package/s/cellar/forklift.ts +0 -9
- package/s/cellar/memory-forklift.ts +0 -30
- package/s/cellar/opfs-forklift.ts +0 -47
- 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 -22
- 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 -42
- package/x/cellar/opfs-forklift.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { collect } from "@e280/
|
|
1
|
+
import { collect } from "@e280/stz";
|
|
2
2
|
/**
|
|
3
3
|
* Async hierarchy of nestable items.
|
|
4
4
|
* - items can have multiple children.
|
|
@@ -21,7 +21,7 @@ export class HyTree {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
async gets(...ids) {
|
|
24
|
-
const records = await this.records.
|
|
24
|
+
const records = await this.records.getMany(ids);
|
|
25
25
|
return records.map(r => {
|
|
26
26
|
if (!r)
|
|
27
27
|
return undefined;
|
|
@@ -30,12 +30,12 @@ export class HyTree {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
async require(id) {
|
|
33
|
-
const record = await this.records.
|
|
33
|
+
const record = await this.records.need(id);
|
|
34
34
|
const [parent, children] = record;
|
|
35
35
|
return { parent, children };
|
|
36
36
|
}
|
|
37
37
|
async requires(...ids) {
|
|
38
|
-
const records = await this.records.
|
|
38
|
+
const records = await this.records.needMany(ids);
|
|
39
39
|
return records.map(([parent, children]) => ({ parent, children }));
|
|
40
40
|
}
|
|
41
41
|
/** establish an id as a root with no parents, but ready to accept children */
|
|
@@ -61,9 +61,10 @@ export class HyTree {
|
|
|
61
61
|
siblings.add(id);
|
|
62
62
|
}
|
|
63
63
|
// save all new children
|
|
64
|
-
await this.records.
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
await this.records.commit([
|
|
65
|
+
...newcomers.map(([id, record]) => this.records.op.set(id, record)),
|
|
66
|
+
this.records.op.set(parent, [parentItem.parent, [...siblings]]),
|
|
67
|
+
]);
|
|
67
68
|
}
|
|
68
69
|
/** detach this id from its parent in the hierarchy */
|
|
69
70
|
async detach(id) {
|
|
@@ -85,7 +86,7 @@ export class HyTree {
|
|
|
85
86
|
await this.detach(id);
|
|
86
87
|
const tree = await collect(this.crawl(id));
|
|
87
88
|
const ids = tree.map(({ id }) => id);
|
|
88
|
-
await this.records.
|
|
89
|
+
await this.records.commit(ids.map(id => this.records.op.delete(id)));
|
|
89
90
|
}
|
|
90
91
|
/** delete absolutely everything */
|
|
91
92
|
async clear() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hy-tree.js","sourceRoot":"","sources":["../../../s/genius/parts/hy-tree.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"hy-tree.js","sourceRoot":"","sources":["../../../s/genius/parts/hy-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAOjC;;;;;GAKG;AACH,MAAM,OAAO,MAAM;IACE;IAApB,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAE7C,KAAK,CAAC,GAAG,CAAC,EAAQ;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAQ;QACjB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACzC,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAA;YACjC,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,CAAA;QAC1B,CAAC;IACF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,GAAW;QACxB,MAAM,OAAO,GAAG,MAAM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AE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAClE,IAAI,MAAM,KAAK,IAAI;gBAClB,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,EAAC,MAAM,EAAE,QAAQ,EAAC,EAA6B,CAAA;IACnE,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,CAAC,KAAK,CACV,EAAQ,EACR,YAA0D,KAAK,IAAG,EAAE,CAAC,IAAI;QAG1E,MAAM,IAAI,GAAiC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAQ,CAAA;QAE5B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAG,CAAA;YAChC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC;gBAAE,SAAQ;YACxD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAEZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACnC,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAA2C,CAAA;YAEhE,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ;gBAClC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QACrC,CAAC;IACF,CAAC;CACD"}
|
package/x/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
<link rel="stylesheet" href="demo/main.css?v=c15dc8e40513"/>
|
|
21
|
-
<script type="module" src="demo/main.bundle.min.js?v=
|
|
21
|
+
<script type="module" src="demo/main.bundle.min.js?v=070c4ac9ec8b"></script>
|
|
22
22
|
|
|
23
23
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.20.0/cdn/themes/dark.css"/>
|
|
24
24
|
<!-- loading every shoelace component for now (should be cherry picked instead) -->
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<img alt="" src="/assets/favicon.png"/>
|
|
30
30
|
<div>
|
|
31
31
|
<h1>Quay</h1>
|
|
32
|
-
<span class=version>v0.0.0-
|
|
32
|
+
<span class=version>v0.0.0-18</span>
|
|
33
33
|
</div>
|
|
34
34
|
</header>
|
|
35
35
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MediaGroup } from "./group.js";
|
|
2
2
|
import { Cellar } from "../../../cellar/cellar.js";
|
|
3
|
-
import { MediaFormat } from "./schema.js";
|
|
3
|
+
import { MediaFormat, MediaProgress } from "./schema.js";
|
|
4
4
|
import { CodexItem } from "../../aspects/codex/parts/codex-item.js";
|
|
5
5
|
export type MediaRecord = {
|
|
6
6
|
hash: string;
|
|
@@ -14,6 +14,7 @@ export type MediaRecord = {
|
|
|
14
14
|
export declare class MediaLibrary extends MediaGroup {
|
|
15
15
|
#private;
|
|
16
16
|
static open(scope?: string): Promise<MediaLibrary>;
|
|
17
|
+
progress: import("@e280/stz").Sub<[MediaProgress]>;
|
|
17
18
|
cellar: Cellar;
|
|
18
19
|
constructor();
|
|
19
20
|
records(): AsyncGenerator<MediaRecord, void, unknown>;
|
|
@@ -34,7 +35,7 @@ export declare class MediaLibrary extends MediaGroup {
|
|
|
34
35
|
size?: number;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
|
-
}, "
|
|
38
|
+
}, "folder" | "file"> & CodexItem<{
|
|
38
39
|
taxon: {
|
|
39
40
|
icon: import("@e280/sly").Content;
|
|
40
41
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sub } from "@e280/stz";
|
|
2
|
+
import { Kv, StorageMagazine } from "@e280/kv";
|
|
2
3
|
import { MediaGroup } from "./group.js";
|
|
3
4
|
import { Cellar } from "../../../cellar/cellar.js";
|
|
4
5
|
export class MediaLibrary extends MediaGroup {
|
|
@@ -11,6 +12,7 @@ export class MediaLibrary extends MediaGroup {
|
|
|
11
12
|
}
|
|
12
13
|
#objectUrls = new Map();
|
|
13
14
|
#index;
|
|
15
|
+
progress = sub();
|
|
14
16
|
cellar = new Cellar();
|
|
15
17
|
constructor() {
|
|
16
18
|
super();
|
|
@@ -38,11 +40,37 @@ export class MediaLibrary extends MediaGroup {
|
|
|
38
40
|
await Promise.all(files.map(file => this.#storeFile(file, parent)));
|
|
39
41
|
}
|
|
40
42
|
async #storeFile(file, parent) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
+
const item = this.#attachPending(file, parent);
|
|
44
|
+
try {
|
|
45
|
+
const hash = await this.cellar.write(trackProgress(file.stream(), loaded => this.progress.pub({ item, loaded, total: file.size })));
|
|
46
|
+
const record = await this.#saveRecord(file, hash);
|
|
47
|
+
item.destroy();
|
|
48
|
+
this.#attachRecord(record, parent);
|
|
49
|
+
return record;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
item.destroy();
|
|
53
|
+
this.on.refresh.pub({});
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
#attachPending(file, parent) {
|
|
58
|
+
const item = this.config.codex.create("file", {
|
|
59
|
+
label: file.name,
|
|
60
|
+
format: mediaFormat(file.type),
|
|
61
|
+
mime: file.type,
|
|
62
|
+
size: file.size,
|
|
63
|
+
previewUrl: null,
|
|
64
|
+
});
|
|
65
|
+
parent.attach(item);
|
|
66
|
+
this.on.refresh.pub({});
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
async #saveRecord(file, hash) {
|
|
70
|
+
const existing = await this.#index.get(hash);
|
|
43
71
|
const now = Date.now();
|
|
44
72
|
const record = {
|
|
45
|
-
hash
|
|
73
|
+
hash,
|
|
46
74
|
label: existing?.label ?? file.name,
|
|
47
75
|
format: mediaFormat(file.type),
|
|
48
76
|
mime: file.type,
|
|
@@ -50,10 +78,9 @@ export class MediaLibrary extends MediaGroup {
|
|
|
50
78
|
createdAt: existing?.createdAt ?? now,
|
|
51
79
|
updatedAt: now,
|
|
52
80
|
};
|
|
53
|
-
await this.#index.set(
|
|
81
|
+
await this.#index.set(hash, record);
|
|
54
82
|
if (record.format === "image")
|
|
55
|
-
this.#setPreview(
|
|
56
|
-
this.#attachRecord(record, parent);
|
|
83
|
+
this.#setPreview(hash, URL.createObjectURL(file));
|
|
57
84
|
return record;
|
|
58
85
|
}
|
|
59
86
|
#hashes(items) {
|
|
@@ -63,7 +90,7 @@ export class MediaLibrary extends MediaGroup {
|
|
|
63
90
|
}
|
|
64
91
|
async #delete(hashes) {
|
|
65
92
|
for (const hash of hashes) {
|
|
66
|
-
await this.#index.
|
|
93
|
+
await this.#index.delete(hash);
|
|
67
94
|
await this.cellar.delete(hash);
|
|
68
95
|
this.#revokePreview(hash);
|
|
69
96
|
}
|
|
@@ -121,7 +148,7 @@ function mediaFormat(mime) {
|
|
|
121
148
|
function mediaIndex(scope) {
|
|
122
149
|
const storage = globalThis.localStorage;
|
|
123
150
|
if (storage)
|
|
124
|
-
return new Kv(new
|
|
151
|
+
return new Kv(new StorageMagazine(storage))
|
|
125
152
|
.scope("quay.media")
|
|
126
153
|
.scope(scope);
|
|
127
154
|
const existing = memoryIndexes.get(scope);
|
|
@@ -131,4 +158,14 @@ function mediaIndex(scope) {
|
|
|
131
158
|
memoryIndexes.set(scope, index);
|
|
132
159
|
return index;
|
|
133
160
|
}
|
|
161
|
+
function trackProgress(readable, onProgress) {
|
|
162
|
+
let loaded = 0;
|
|
163
|
+
return readable.pipeThrough(new TransformStream({
|
|
164
|
+
transform(chunk, controller) {
|
|
165
|
+
loaded += chunk.byteLength;
|
|
166
|
+
onProgress(loaded);
|
|
167
|
+
controller.enqueue(chunk);
|
|
168
|
+
},
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
134
171
|
//# sourceMappingURL=library.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../s/logic/presets/media/library.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../s/logic/presets/media/library.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,EAAE,EAAE,eAAe,EAAC,MAAM,UAAU,CAAA;AAE5C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAA;AAchD,MAAM,OAAO,YAAa,SAAQ,UAAU;IAC3C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS;QAClC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAA;QACxB,KAAK,CAAC,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;QAChC,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;QACnB,OAAO,KAAK,CAAA;IACb,CAAC;IAED,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,MAAM,CAAiB;IAEvB,QAAQ,GAAG,GAAG,EAAmB,CAAA;IACjC,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;IAErB;QACC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;QACnC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,MAAM,EAAC,EAAE,EAAE;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,E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AK,CAAc,YAAY,CAAC;aAChC,KAAK,CAAc,KAAK,CAAC,CAAA;IAE5B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACzC,IAAI,QAAQ;QACX,OAAO,QAAQ,CAAA;IAEhB,MAAM,KAAK,GAAG,IAAI,EAAE,EAAe,CAAA;IACnC,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/B,OAAO,KAAK,CAAA;AACb,CAAC;AAED,SAAS,aAAa,CACpB,QAAoC,EACpC,UAAoC;IAErC,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,eAAe,CAAC;QAC/C,SAAS,CAAC,KAAK,EAAE,UAAU;YAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAA;YAC1B,UAAU,CAAC,MAAM,CAAC,CAAA;YAClB,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;KACD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Content } from "@e280/sly";
|
|
2
2
|
import { AsSchema } from "../../aspects/codex/parts/types.js";
|
|
3
|
+
import { CodexItem } from "../../aspects/codex/parts/codex-item.js";
|
|
3
4
|
export type MediaFormat = "video" | "image" | "audio" | "other";
|
|
4
5
|
export type MediaSchema = AsSchema<{
|
|
5
6
|
taxon: {
|
|
@@ -19,3 +20,8 @@ export type MediaSchema = AsSchema<{
|
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
}>;
|
|
23
|
+
export type MediaProgress = {
|
|
24
|
+
item: CodexItem<MediaSchema>;
|
|
25
|
+
loaded: number;
|
|
26
|
+
total: number;
|
|
27
|
+
};
|
package/s/cellar/forklift.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {MapG} from "@e280/stz"
|
|
3
|
-
import {Forklift} from "./forklift.js"
|
|
4
|
-
|
|
5
|
-
export class MemoryForklift implements Forklift {
|
|
6
|
-
#map = new MapG<string, Uint8Array>()
|
|
7
|
-
|
|
8
|
-
async *list(): AsyncIterable<string> {
|
|
9
|
-
for (const label of this.#map.keys())
|
|
10
|
-
yield label
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async has(label: string): Promise<boolean> {
|
|
14
|
-
return this.#map.has(label)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async save(label: string, file: Blob): Promise<void> {
|
|
18
|
-
const bytes = new Uint8Array(await file.arrayBuffer())
|
|
19
|
-
this.#map.set(label, bytes)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async load(label: string): Promise<Blob> {
|
|
23
|
-
return new Blob([this.#map.require(label)])
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async delete(label: string) {
|
|
27
|
-
this.#map.delete(label)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Forklift} from "./forklift.js"
|
|
3
|
-
|
|
4
|
-
export class OpfsForklift implements Forklift {
|
|
5
|
-
static async setup(dirname: string) {
|
|
6
|
-
const root = await navigator.storage.getDirectory()
|
|
7
|
-
const directory = await root.getDirectoryHandle(dirname, {create: true})
|
|
8
|
-
return new this(directory)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
constructor(private directory: FileSystemDirectoryHandle) {}
|
|
12
|
-
|
|
13
|
-
async *list(): AsyncIterable<string> {
|
|
14
|
-
for await (const [name, handle] of this.directory.entries()) {
|
|
15
|
-
if (handle.kind === "file")
|
|
16
|
-
yield name
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async has(label: string): Promise<boolean> {
|
|
21
|
-
try {
|
|
22
|
-
await this.directory.getFileHandle(label)
|
|
23
|
-
return true
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
if ((err as DOMException).name === "NotFoundError") return false
|
|
27
|
-
throw err
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async save(label: string, file: Blob): Promise<void> {
|
|
32
|
-
const fileHandle = await this.directory.getFileHandle(label, {create: true})
|
|
33
|
-
const writable = await fileHandle.createWritable()
|
|
34
|
-
await writable.write(file)
|
|
35
|
-
await writable.close()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async load(label: string): Promise<Blob> {
|
|
39
|
-
const fileHandle = await this.directory.getFileHandle(label)
|
|
40
|
-
return await fileHandle.getFile()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async delete(label: string) {
|
|
44
|
-
await this.directory.removeEntry(label)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
package/x/cellar/forklift.d.ts
DELETED
package/x/cellar/forklift.js
DELETED
package/x/cellar/forklift.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"forklift.js","sourceRoot":"","sources":["../../s/cellar/forklift.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Forklift } from "./forklift.js";
|
|
2
|
-
export declare class MemoryForklift implements Forklift {
|
|
3
|
-
#private;
|
|
4
|
-
list(): AsyncIterable<string>;
|
|
5
|
-
has(label: string): Promise<boolean>;
|
|
6
|
-
save(label: string, file: Blob): Promise<void>;
|
|
7
|
-
load(label: string): Promise<Blob>;
|
|
8
|
-
delete(label: string): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MapG } from "@e280/stz";
|
|
2
|
-
export class MemoryForklift {
|
|
3
|
-
#map = new MapG();
|
|
4
|
-
async *list() {
|
|
5
|
-
for (const label of this.#map.keys())
|
|
6
|
-
yield label;
|
|
7
|
-
}
|
|
8
|
-
async has(label) {
|
|
9
|
-
return this.#map.has(label);
|
|
10
|
-
}
|
|
11
|
-
async save(label, file) {
|
|
12
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
13
|
-
this.#map.set(label, bytes);
|
|
14
|
-
}
|
|
15
|
-
async load(label) {
|
|
16
|
-
return new Blob([this.#map.require(label)]);
|
|
17
|
-
}
|
|
18
|
-
async delete(label) {
|
|
19
|
-
this.#map.delete(label);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=memory-forklift.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-forklift.js","sourceRoot":"","sources":["../../s/cellar/memory-forklift.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAG9B,MAAM,OAAO,cAAc;IAC1B,IAAI,GAAG,IAAI,IAAI,EAAsB,CAAA;IAErC,KAAK,CAAC,CAAC,IAAI;QACV,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACnC,MAAM,KAAK,CAAA;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,IAAU;QACnC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa;QACvB,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;CACD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Forklift } from "./forklift.js";
|
|
2
|
-
export declare class OpfsForklift implements Forklift {
|
|
3
|
-
private directory;
|
|
4
|
-
static setup(dirname: string): Promise<OpfsForklift>;
|
|
5
|
-
constructor(directory: FileSystemDirectoryHandle);
|
|
6
|
-
list(): AsyncIterable<string>;
|
|
7
|
-
has(label: string): Promise<boolean>;
|
|
8
|
-
save(label: string, file: Blob): Promise<void>;
|
|
9
|
-
load(label: string): Promise<Blob>;
|
|
10
|
-
delete(label: string): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export class OpfsForklift {
|
|
2
|
-
directory;
|
|
3
|
-
static async setup(dirname) {
|
|
4
|
-
const root = await navigator.storage.getDirectory();
|
|
5
|
-
const directory = await root.getDirectoryHandle(dirname, { create: true });
|
|
6
|
-
return new this(directory);
|
|
7
|
-
}
|
|
8
|
-
constructor(directory) {
|
|
9
|
-
this.directory = directory;
|
|
10
|
-
}
|
|
11
|
-
async *list() {
|
|
12
|
-
for await (const [name, handle] of this.directory.entries()) {
|
|
13
|
-
if (handle.kind === "file")
|
|
14
|
-
yield name;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async has(label) {
|
|
18
|
-
try {
|
|
19
|
-
await this.directory.getFileHandle(label);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
if (err.name === "NotFoundError")
|
|
24
|
-
return false;
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async save(label, file) {
|
|
29
|
-
const fileHandle = await this.directory.getFileHandle(label, { create: true });
|
|
30
|
-
const writable = await fileHandle.createWritable();
|
|
31
|
-
await writable.write(file);
|
|
32
|
-
await writable.close();
|
|
33
|
-
}
|
|
34
|
-
async load(label) {
|
|
35
|
-
const fileHandle = await this.directory.getFileHandle(label);
|
|
36
|
-
return await fileHandle.getFile();
|
|
37
|
-
}
|
|
38
|
-
async delete(label) {
|
|
39
|
-
await this.directory.removeEntry(label);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=opfs-forklift.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opfs-forklift.js","sourceRoot":"","sources":["../../s/cellar/opfs-forklift.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IAOJ;IANpB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAe;QACjC,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,CAAA;QACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAA;QACxE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC;IAED,YAAoB,SAAoC;QAApC,cAAS,GAAT,SAAS,CAA2B;IAAG,CAAC;IAE5D,KAAK,CAAC,CAAC,IAAI;QACV,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7D,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;gBACzB,MAAM,IAAI,CAAA;QACZ,CAAC;IACF,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa;QACtB,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YACzC,OAAO,IAAI,CAAA;QACZ,CAAC;QACD,OAAO,GAAG,EAAE,CAAC;YACZ,IAAK,GAAoB,CAAC,IAAI,KAAK,eAAe;gBAAE,OAAO,KAAK,CAAA;YAChE,MAAM,GAAG,CAAA;QACV,CAAC;IACF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,IAAU;QACnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,SAAS,C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