@dxos/plugin-wnfs 0.9.1-staging.ee54ba693a → 0.11.0
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/PLUGIN.mdl +92 -46
- package/dist/lib/WnfsPlugin.mjs +28 -0
- package/dist/lib/WnfsPlugin.mjs.map +1 -0
- package/dist/lib/WnfsPlugin.node.mjs +8 -0
- package/dist/lib/WnfsPlugin.node.mjs.map +1 -0
- package/dist/lib/WnfsPlugin.workerd.mjs +8 -0
- package/dist/lib/WnfsPlugin.workerd.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +8 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-blob-backend.mjs +118 -0
- package/dist/lib/chunk-blob-backend.mjs.map +1 -0
- package/dist/lib/chunk-dependencies.mjs +146 -0
- package/dist/lib/chunk-dependencies.mjs.map +1 -0
- package/dist/lib/chunk-helpers.mjs +198 -0
- package/dist/lib/chunk-helpers.mjs.map +1 -0
- package/dist/lib/chunk-meta.mjs +38 -0
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +46 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/helpers.mjs +2 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/plugin.mjs +8 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/translations.mjs +7 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blob-backend.d.ts +22 -0
- package/dist/types/src/capabilities/blob-backend.d.ts.map +1 -0
- package/dist/types/src/capabilities/blob-backend.test.d.ts +2 -0
- package/dist/types/src/capabilities/blob-backend.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/dependencies.d.ts +5 -0
- package/dist/types/src/capabilities/dependencies.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +2 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/helpers/wnfs-url.d.ts +6 -0
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/types/WnfsCapabilities.d.ts +7 -0
- package/dist/types/src/types/WnfsCapabilities.d.ts.map +1 -1
- package/dist/types/src/types/WnfsEvents.d.ts +11 -0
- package/dist/types/src/types/WnfsEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +4 -4
- package/package.json +34 -32
- package/src/WnfsPlugin.tsx +9 -24
- package/src/capabilities/blob-backend.test.ts +108 -0
- package/src/capabilities/blob-backend.ts +104 -0
- package/src/capabilities/{blockstore.ts → dependencies.ts} +6 -1
- package/src/capabilities/index.ts +2 -4
- package/src/helpers/wnfs-url.ts +22 -4
- package/src/types/WnfsCapabilities.ts +9 -0
- package/src/types/WnfsEvents.ts +19 -0
- package/src/types/index.ts +1 -0
- package/dist/lib/neutral/WnfsPlugin.mjs +0 -51
- package/dist/lib/neutral/WnfsPlugin.mjs.map +0 -7
- package/dist/lib/neutral/WnfsPlugin.node.mjs +0 -12
- package/dist/lib/neutral/WnfsPlugin.node.mjs.map +0 -7
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs +0 -12
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs.map +0 -7
- package/dist/lib/neutral/backend-4HPTHS33.mjs +0 -47
- package/dist/lib/neutral/backend-4HPTHS33.mjs.map +0 -7
- package/dist/lib/neutral/blockstore-U6SPNL2C.mjs +0 -190
- package/dist/lib/neutral/blockstore-U6SPNL2C.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/index.mjs +0 -13
- package/dist/lib/neutral/capabilities/index.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2WLTMUHV.mjs +0 -19
- package/dist/lib/neutral/chunk-2WLTMUHV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-H2YCLSRI.mjs +0 -47
- package/dist/lib/neutral/chunk-H2YCLSRI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-L33MOD23.mjs +0 -219
- package/dist/lib/neutral/chunk-L33MOD23.mjs.map +0 -7
- package/dist/lib/neutral/helpers/index.mjs +0 -26
- package/dist/lib/neutral/helpers/index.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -36
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -8
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -12
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/translations.mjs +0 -17
- package/dist/lib/neutral/translations.mjs.map +0 -7
- package/dist/lib/neutral/types/index.mjs +0 -8
- package/dist/lib/neutral/types/index.mjs.map +0 -7
- package/dist/lib/neutral/url-resolver-BIRH7WHL.mjs +0 -47
- package/dist/lib/neutral/url-resolver-BIRH7WHL.mjs.map +0 -7
- package/dist/types/src/capabilities/backend.d.ts +0 -6
- package/dist/types/src/capabilities/backend.d.ts.map +0 -1
- package/dist/types/src/capabilities/blockstore.d.ts +0 -5
- package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-resolver.d.ts +0 -6
- package/dist/types/src/capabilities/url-resolver.d.ts.map +0 -1
- package/src/capabilities/backend.ts +0 -43
- package/src/capabilities/url-resolver.ts +0 -44
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// src/helpers/common.ts
|
|
2
|
-
import { CID } from "multiformats/cid";
|
|
3
|
-
import { sha256 } from "multiformats/hashes/sha2";
|
|
4
|
-
import * as crypto from "@dxos/crypto";
|
|
5
|
-
var filePath = (fileName, space) => {
|
|
6
|
-
return [
|
|
7
|
-
"spaces",
|
|
8
|
-
space.id,
|
|
9
|
-
"files",
|
|
10
|
-
fileName
|
|
11
|
-
];
|
|
12
|
-
};
|
|
13
|
-
var Rng = class {
|
|
14
|
-
randomBytes(count) {
|
|
15
|
-
return new Uint8Array(crypto.randomBytes(count));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var store = (blockstore) => {
|
|
19
|
-
const getBlock = async (cid) => {
|
|
20
|
-
const decodedCid = CID.decode(cid);
|
|
21
|
-
return await blockstore.get(decodedCid);
|
|
22
|
-
};
|
|
23
|
-
const hasBlock = async (cid) => {
|
|
24
|
-
const decodedCid = CID.decode(cid);
|
|
25
|
-
return await blockstore.has(decodedCid);
|
|
26
|
-
};
|
|
27
|
-
const putBlockKeyed = async (cid, bytes) => {
|
|
28
|
-
const decodedCid = CID.decode(cid);
|
|
29
|
-
await blockstore.put(decodedCid, bytes);
|
|
30
|
-
};
|
|
31
|
-
const putBlock = async (bytes, codec) => {
|
|
32
|
-
const hash = await sha256.digest(bytes);
|
|
33
|
-
const cid = CID.create(1, codec, hash);
|
|
34
|
-
await blockstore.put(cid, bytes);
|
|
35
|
-
return cid.bytes;
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
getBlock,
|
|
39
|
-
hasBlock,
|
|
40
|
-
putBlockKeyed,
|
|
41
|
-
putBlock
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var storeName = () => "dxos/wnfs";
|
|
45
|
-
var readFile = (file) => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
const reader = new FileReader();
|
|
48
|
-
reader.onload = (event) => {
|
|
49
|
-
const result = event.target?.result;
|
|
50
|
-
if (result === null || result === void 0 || typeof result === "string") {
|
|
51
|
-
reject(new Error("Expected an ArrayBuffer"));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
resolve(new Uint8Array(result));
|
|
55
|
-
};
|
|
56
|
-
reader.onerror = (err) => {
|
|
57
|
-
reject(err);
|
|
58
|
-
};
|
|
59
|
-
reader.readAsArrayBuffer(file);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// src/helpers/load.ts
|
|
64
|
-
import * as Option from "effect/Option";
|
|
65
|
-
import { CID as CID2 } from "multiformats";
|
|
66
|
-
import * as Uint8Arrays from "uint8arrays";
|
|
67
|
-
import { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from "wnfs";
|
|
68
|
-
import { Annotation as Annotation2, Obj } from "@dxos/echo";
|
|
69
|
-
|
|
70
|
-
// src/annotations.ts
|
|
71
|
-
import * as Schema from "effect/Schema";
|
|
72
|
-
import { Annotation } from "@dxos/echo";
|
|
73
|
-
var WnfsStateAnnotation = Annotation.make({
|
|
74
|
-
id: "org.dxos.plugin.wnfs.state",
|
|
75
|
-
schema: Schema.Struct({
|
|
76
|
-
accessKey: Schema.String,
|
|
77
|
-
privateForestCid: Schema.String
|
|
78
|
-
})
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// src/helpers/load.ts
|
|
82
|
-
var loadWnfs = async ({ space, blockstore, instances }) => {
|
|
83
|
-
const propsAny = space.properties;
|
|
84
|
-
if (propsAny.wnfs_access_key !== void 0 && propsAny.wnfs_private_forest_cid !== void 0) {
|
|
85
|
-
Obj.update(space.properties, (obj) => {
|
|
86
|
-
delete obj["wnfs_access_key"];
|
|
87
|
-
delete obj["wnfs_private_forest_cid"];
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
if (propsAny.wnfs !== void 0 && Option.isNone(Annotation2.get(space.properties, WnfsStateAnnotation))) {
|
|
91
|
-
Obj.update(space.properties, (properties) => {
|
|
92
|
-
Annotation2.set(properties, WnfsStateAnnotation, propsAny.wnfs);
|
|
93
|
-
delete properties["wnfs"];
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
const wnfsState = Annotation2.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined);
|
|
97
|
-
const cacheKey = wnfsState?.privateForestCid;
|
|
98
|
-
if (cacheKey && instances?.[cacheKey]) {
|
|
99
|
-
return instances[cacheKey];
|
|
100
|
-
}
|
|
101
|
-
const exists = !!wnfsState;
|
|
102
|
-
const instance = exists ? await loadWnfsDir(blockstore, space) : await createWnfsDir(blockstore, space);
|
|
103
|
-
if (instances) {
|
|
104
|
-
const newCacheKey = Annotation2.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined)?.privateForestCid;
|
|
105
|
-
if (newCacheKey) {
|
|
106
|
-
instances[newCacheKey] = instance;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return instance;
|
|
110
|
-
};
|
|
111
|
-
var createWnfsDir = async (blockstore, space) => {
|
|
112
|
-
const wnfsStore = store(blockstore);
|
|
113
|
-
const rng = new Rng();
|
|
114
|
-
const forest = new PrivateForest(rng);
|
|
115
|
-
const dirResult = await PrivateDirectory.newAndStore(forest.emptyName(), /* @__PURE__ */ new Date(), forest, wnfsStore, rng);
|
|
116
|
-
const dir = dirResult.rootDir;
|
|
117
|
-
const [accessKeyRaw, newForest] = await dir.asNode().store(dirResult.forest, wnfsStore, rng);
|
|
118
|
-
const cidBytes = await newForest.store(wnfsStore);
|
|
119
|
-
Obj.update(space.properties, (properties) => {
|
|
120
|
-
Annotation2.set(properties, WnfsStateAnnotation, {
|
|
121
|
-
accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), "base64"),
|
|
122
|
-
privateForestCid: CID2.decode(cidBytes).toString()
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
return {
|
|
126
|
-
directory: dir,
|
|
127
|
-
forest: newForest
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
var loadWnfsDir = async (blockstore, space) => {
|
|
131
|
-
const wnfsStore = store(blockstore);
|
|
132
|
-
const wnfsState = Annotation2.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined);
|
|
133
|
-
const accessKey = AccessKey.fromBytes(Uint8Arrays.fromString(wnfsState.accessKey, "base64"));
|
|
134
|
-
const forest = await PrivateForest.load(CID2.parse(wnfsState.privateForestCid).bytes, wnfsStore);
|
|
135
|
-
const node = await PrivateNode.load(accessKey, forest, wnfsStore);
|
|
136
|
-
return {
|
|
137
|
-
directory: node.asDir(),
|
|
138
|
-
forest
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/helpers/upload.ts
|
|
143
|
-
import * as Option2 from "effect/Option";
|
|
144
|
-
import { CID as CID3 } from "multiformats";
|
|
145
|
-
import * as Raw from "multiformats/codecs/raw";
|
|
146
|
-
import { sha256 as sha2562 } from "multiformats/hashes/sha2";
|
|
147
|
-
import { Annotation as Annotation3, Obj as Obj2 } from "@dxos/echo";
|
|
148
|
-
import { log } from "@dxos/log";
|
|
149
|
-
|
|
150
|
-
// src/helpers/wnfs-url.ts
|
|
151
|
-
var wnfsUrl = (filePath2) => {
|
|
152
|
-
return "wnfs://" + filePath2.map((f) => encodeURIComponent(f)).join("/");
|
|
153
|
-
};
|
|
154
|
-
var getPathFromUrl = (wnfsUrl2) => wnfsUrl2.replace(/^wnfs:\/\//, "").split("/").map((p) => decodeURIComponent(p));
|
|
155
|
-
var getBlobUrl = async ({ wnfsUrl: wnfsUrl2, blockstore, forest, directory, type }) => {
|
|
156
|
-
const path = getPathFromUrl(wnfsUrl2);
|
|
157
|
-
const wnfsStore = store(blockstore);
|
|
158
|
-
const { result } = await directory.read(path, true, forest, wnfsStore);
|
|
159
|
-
const blob = new Blob([
|
|
160
|
-
result
|
|
161
|
-
], {
|
|
162
|
-
type
|
|
163
|
-
});
|
|
164
|
-
return URL.createObjectURL(blob);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// src/helpers/upload.ts
|
|
168
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/helpers/upload.ts";
|
|
169
|
-
var upload = async ({ file, blockstore, instances, space }) => {
|
|
170
|
-
const { directory, forest } = await loadWnfs({
|
|
171
|
-
blockstore,
|
|
172
|
-
instances,
|
|
173
|
-
space
|
|
174
|
-
});
|
|
175
|
-
const wnfsStore = store(blockstore);
|
|
176
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
177
|
-
const hash = await sha2562.digest(bytes);
|
|
178
|
-
const cid = CID3.create(1, Raw.code, hash);
|
|
179
|
-
const path = filePath(cid.toString(), space);
|
|
180
|
-
const result = await directory.write(path, true, bytes, /* @__PURE__ */ new Date(), forest, wnfsStore, new Rng());
|
|
181
|
-
const [_, updatedForest] = await result.rootDir.store(result.forest, wnfsStore, new Rng());
|
|
182
|
-
const cidBytes = await updatedForest.store(wnfsStore);
|
|
183
|
-
const currentState = Annotation3.get(space.properties, WnfsStateAnnotation).pipe(Option2.getOrUndefined);
|
|
184
|
-
if (!currentState) {
|
|
185
|
-
throw new Error("WnfsStateAnnotation missing after loadWnfs; cannot persist forest CID.");
|
|
186
|
-
}
|
|
187
|
-
Obj2.update(space.properties, (properties) => {
|
|
188
|
-
Annotation3.set(properties, WnfsStateAnnotation, {
|
|
189
|
-
...currentState,
|
|
190
|
-
privateForestCid: CID3.decode(cidBytes).toString()
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
const info = {
|
|
194
|
-
name: file.name,
|
|
195
|
-
type: file.type,
|
|
196
|
-
url: wnfsUrl(path),
|
|
197
|
-
cid: cid.toString()
|
|
198
|
-
};
|
|
199
|
-
log("upload", {
|
|
200
|
-
file,
|
|
201
|
-
info
|
|
202
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 50, S: void 0 });
|
|
203
|
-
return info;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export {
|
|
207
|
-
WnfsStateAnnotation,
|
|
208
|
-
filePath,
|
|
209
|
-
Rng,
|
|
210
|
-
store,
|
|
211
|
-
storeName,
|
|
212
|
-
readFile,
|
|
213
|
-
loadWnfs,
|
|
214
|
-
wnfsUrl,
|
|
215
|
-
getPathFromUrl,
|
|
216
|
-
getBlobUrl,
|
|
217
|
-
upload
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=chunk-L33MOD23.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/common.ts", "../../../src/helpers/load.ts", "../../../src/annotations.ts", "../../../src/helpers/upload.ts", "../../../src/helpers/wnfs-url.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats/cid';\nimport { sha256 } from 'multiformats/hashes/sha2';\nimport { type BlockStore as WnfsBlockStore } from 'wnfs';\n\nimport * as crypto from '@dxos/crypto';\nimport { type Space } from '@dxos/react-client/echo';\n\n//\n// PATH\n//\n\nexport const filePath = (fileName: string, space: Space) => {\n return ['spaces', space.id, 'files', fileName];\n};\n\n//\n// RNG\n//\n\nexport class Rng {\n randomBytes(count: number): Uint8Array {\n return new Uint8Array(crypto.randomBytes(count));\n }\n}\n\n//\n// STORE\n//\n\nexport const store = (blockstore: Blockstore): WnfsBlockStore => {\n const getBlock = async (cid: Uint8Array): Promise<Uint8Array | undefined> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.get(decodedCid);\n };\n\n const hasBlock = async (cid: Uint8Array): Promise<boolean> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.has(decodedCid);\n };\n\n const putBlockKeyed = async (cid: Uint8Array, bytes: Uint8Array): Promise<void> => {\n const decodedCid = CID.decode(cid);\n await blockstore.put(decodedCid, bytes);\n };\n\n // Don't hash blocks with the rs-wnfs default Blake 3, sha256 has better support.\n const putBlock = async (bytes: Uint8Array, codec: number): Promise<Uint8Array> => {\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, codec, hash);\n await blockstore.put(cid, bytes);\n return cid.bytes;\n };\n\n return { getBlock, hasBlock, putBlockKeyed, putBlock };\n};\n\nexport const storeName = () => 'dxos/wnfs';\n\n//\n// OTHER\n//\n\nexport const readFile = (file: File): Promise<Uint8Array> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (event) => {\n const result = event.target?.result;\n if (result === null || result === undefined || typeof result === 'string') {\n reject(new Error('Expected an ArrayBuffer'));\n return;\n }\n resolve(new Uint8Array(result));\n };\n reader.onerror = (err) => {\n reject(err);\n };\n reader.readAsArrayBuffer(file);\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Uint8Arrays from 'uint8arrays';\nimport { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from 'wnfs';\n\nimport { Annotation, Obj } from '@dxos/echo';\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { type WnfsCapabilities } from '#types';\n\nimport { WnfsStateAnnotation } from '../annotations';\nimport { Rng, store } from './common';\n\n//\n// LOAD\n//\n\nexport const loadWnfs = async ({\n space,\n blockstore,\n instances,\n}: {\n space: Space;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n}) => {\n // TODO(wittjosiah): Remove.\n // Delete old properties if they exist (pre-DX-971 migration cleanup).\n const propsAny = space.properties as any;\n if (propsAny.wnfs_access_key !== undefined && propsAny.wnfs_private_forest_cid !== undefined) {\n Obj.update(space.properties, (obj) => {\n delete (obj as any)['wnfs_access_key'];\n delete (obj as any)['wnfs_private_forest_cid'];\n });\n }\n // Migrate legacy wnfs data key to annotation.\n if (propsAny.wnfs !== undefined && Option.isNone(Annotation.get(space.properties, WnfsStateAnnotation))) {\n Obj.update(space.properties, (properties) => {\n Annotation.set(properties, WnfsStateAnnotation, propsAny.wnfs);\n delete (properties as any)['wnfs'];\n });\n }\n\n const wnfsState = Annotation.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined);\n const cacheKey = wnfsState?.privateForestCid as any;\n if (cacheKey && instances?.[cacheKey]) {\n return instances[cacheKey];\n }\n\n const exists = !!wnfsState;\n const instance = exists ? await loadWnfsDir(blockstore, space) : await createWnfsDir(blockstore, space);\n if (instances) {\n // Re-read after createWnfsDir so newly created instances are cached under the real CID.\n const newCacheKey = Annotation.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined)\n ?.privateForestCid as any;\n if (newCacheKey) {\n instances[newCacheKey] = instance;\n }\n }\n\n return instance;\n};\n\n//\n// PRIVATE\n//\n\nconst createWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n const rng = new Rng();\n const forest = new PrivateForest(rng);\n\n const dirResult = await PrivateDirectory.newAndStore(forest.emptyName(), new Date(), forest, wnfsStore, rng);\n const dir = dirResult.rootDir as PrivateDirectory;\n\n const [accessKeyRaw, newForest]: [AccessKey, PrivateForest] = await dir\n .asNode()\n .store(dirResult.forest as PrivateForest, wnfsStore, rng);\n\n const cidBytes = await newForest.store(wnfsStore);\n\n Obj.update(space.properties, (properties) => {\n Annotation.set(properties, WnfsStateAnnotation, {\n accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),\n privateForestCid: CID.decode(cidBytes).toString(),\n });\n });\n\n return {\n directory: dir,\n forest: newForest,\n };\n};\n\nconst loadWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n\n const wnfsState = Annotation.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined)!;\n const accessKey = AccessKey.fromBytes(Uint8Arrays.fromString(wnfsState.accessKey, 'base64'));\n const forest: PrivateForest = await PrivateForest.load(CID.parse(wnfsState.privateForestCid).bytes, wnfsStore);\n const node: PrivateNode = await PrivateNode.load(accessKey, forest, wnfsStore);\n\n return {\n directory: node.asDir(),\n forest,\n };\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation } from '@dxos/echo';\n\n/** WNFS filesystem state stored on space properties meta. */\nexport const WnfsStateAnnotation = Annotation.make({\n id: 'org.dxos.plugin.wnfs.state',\n schema: Schema.Struct({\n accessKey: Schema.String,\n privateForestCid: Schema.String,\n }),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Raw from 'multiformats/codecs/raw';\nimport { sha256 } from 'multiformats/hashes/sha2';\n\nimport type { Space } from '@dxos/client/echo';\nimport { Annotation, Obj } from '@dxos/echo';\nimport { log } from '@dxos/log';\n\nimport { type WnfsCapabilities } from '#types';\n\nimport { WnfsStateAnnotation } from '../annotations';\nimport { Rng, filePath, store } from './common';\nimport { loadWnfs } from './load';\nimport { wnfsUrl } from './wnfs-url';\n\nexport const upload = async ({\n file,\n blockstore,\n instances,\n space,\n}: {\n file: File;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n space: Space;\n}) => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const wnfsStore = store(blockstore);\n\n const bytes = new Uint8Array(await file.arrayBuffer());\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, Raw.code, hash);\n\n const path = filePath(cid.toString(), space);\n\n // Given the root directory of the private file system,\n // write the file contents to `path` in said directory.\n const result = await directory.write(path, true, bytes, new Date(), forest, wnfsStore, new Rng());\n\n // Given the new immutable instance of the root directory after writing to it,\n // **store** the changes in the \"dark forest\" and the associated (block) store.\n const [_, updatedForest] = await result.rootDir.store(result.forest, wnfsStore, new Rng());\n const cidBytes = await updatedForest.store(wnfsStore);\n\n // Update the forest pointer on the associated space.\n const currentState = Annotation.get(space.properties, WnfsStateAnnotation).pipe(Option.getOrUndefined);\n if (!currentState) {\n throw new Error('WnfsStateAnnotation missing after loadWnfs; cannot persist forest CID.');\n }\n Obj.update(space.properties, (properties) => {\n Annotation.set(properties, WnfsStateAnnotation, {\n ...currentState,\n privateForestCid: CID.decode(cidBytes).toString(),\n });\n });\n\n // Generate `wnfs://` URL & return the info.\n const info = {\n name: file.name,\n type: file.type,\n url: wnfsUrl(path),\n cid: cid.toString(),\n };\n\n log('upload', { file, info });\n return info;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { store } from './common';\n\nexport const wnfsUrl = (filePath: string[]) => {\n return 'wnfs://' + filePath.map((f) => encodeURIComponent(f)).join('/');\n};\n\nexport const getPathFromUrl = (wnfsUrl: string) =>\n wnfsUrl\n .replace(/^wnfs:\\/\\//, '')\n .split('/')\n .map((p) => decodeURIComponent(p));\n\nexport const getBlobUrl = async ({\n wnfsUrl,\n blockstore,\n forest,\n directory,\n type,\n}: {\n wnfsUrl: string;\n blockstore: Blockstore;\n forest: PrivateForest;\n directory: PrivateDirectory;\n type?: string;\n}) => {\n const path = getPathFromUrl(wnfsUrl);\n const wnfsStore = store(blockstore);\n const { result } = await directory.read(path, true, forest, wnfsStore);\n const blob = new Blob([result], { type });\n return URL.createObjectURL(blob);\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,WAAW;AACpB,SAASC,cAAc;AAGvB,YAAYC,YAAY;AAOjB,IAAMC,WAAW,CAACC,UAAkBC,UAAAA;AACzC,SAAO;IAAC;IAAUA,MAAMC;IAAI;IAASF;;AACvC;AAMO,IAAMG,MAAN,MAAMA;EACXC,YAAYC,OAA2B;AACrC,WAAO,IAAIC,WAAkBF,mBAAYC,KAAAA,CAAAA;EAC3C;AACF;AAMO,IAAME,QAAQ,CAACC,eAAAA;AACpB,QAAMC,WAAW,OAAOC,QAAAA;AACtB,UAAMC,aAAaf,IAAIgB,OAAOF,GAAAA;AAC9B,WAAO,MAAMF,WAAWK,IAAIF,UAAAA;EAC9B;AAEA,QAAMG,WAAW,OAAOJ,QAAAA;AACtB,UAAMC,aAAaf,IAAIgB,OAAOF,GAAAA;AAC9B,WAAO,MAAMF,WAAWO,IAAIJ,UAAAA;EAC9B;AAEA,QAAMK,gBAAgB,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AAAA,YAAY,CAAA,eAAA;gBACfI,IAAAA,YAAsBC,qBAAiBN;MACzC,GAAA;MACF,kBAAAL,KAAA,OAAA,QAAA,EAAA,SAAA;IAEA,CAAA;EACA,CAAA;QAEEY,OAAMC;IACNC,MAAKC,KAAAA;IACLhB,MAAKA,KAAIM;IACX,KAAA,QAAA,IAAA;IAEI,KAAA,IAAA,SAAU;;MAAQW,UAAAA;IAAK;IAC3B;EACA,GAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;;;",
|
|
6
|
-
"names": ["CID", "sha256", "crypto", "filePath", "fileName", "space", "id", "Rng", "randomBytes", "count", "Uint8Array", "store", "blockstore", "getBlock", "cid", "decodedCid", "decode", "get", "hasBlock", "has", "putBlockKeyed", "bytes", "put", "putBlock", "codec", "hash", "digest", "create", "storeName", "readFile", "file", "Promise", "resolve", "reject", "reader", "FileReader", "onload", "event", "result", "target", "undefined", "Error", "onerror", "err", "readAsArrayBuffer", "Option", "CID", "Uint8Arrays", "AccessKey", "PrivateDirectory", "PrivateForest", "PrivateNode", "Annotation", "Obj", "Schema", "Annotation", "WnfsStateAnnotation", "make", "id", "schema", "Struct", "accessKey", "String", "privateForestCid", "loadWnfs", "space", "blockstore", "instances", "propsAny", "properties", "wnfs_access_key", "undefined", "wnfs_private_forest_cid", "Obj", "update", "obj", "wnfs", "isNone", "Annotation", "get", "WnfsStateAnnotation", "set", "wnfsState", "pipe", "getOrUndefined", "cacheKey", "privateForestCid", "exists", "instance", "loadWnfsDir", "createWnfsDir", "newCacheKey", "wnfsStore", "store", "rng", "Rng", "forest", "PrivateForest", "dirResult", "PrivateDirectory", "newAndStore", "emptyName", "Date", "dir", "rootDir", "accessKeyRaw", "newForest", "asNode", "cidBytes", "accessKey", "toString", "toBytes", "CID", "decode", "directory", "AccessKey", "fromBytes", "fromString", "load", "parse", "bytes", "node", "PrivateNode", "asDir", "Option", "CID", "Raw", "sha256", "Annotation", "Obj", "log", "wnfsUrl", "filePath", "map", "f", "encodeURIComponent", "join", "getPathFromUrl", "replace", "split", "p", "decodeURIComponent", "getBlobUrl", "blockstore", "forest", "directory", "type", "path", "wnfsStore", "store", "result", "read", "blob", "Blob", "URL", "createObjectURL", "upload", "blockstore", "instances", "space", "hash", "sha256", "bytes", "cid", "CID", "create", "Raw", "path", "filePath", "toString", "currentState", "Annotation", "properties", "update", "privateForestCid", "decode", "type", "file", "url", "wnfsUrl", "info"]
|
|
7
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Rng,
|
|
3
|
-
filePath,
|
|
4
|
-
getBlobUrl,
|
|
5
|
-
getPathFromUrl,
|
|
6
|
-
loadWnfs,
|
|
7
|
-
readFile,
|
|
8
|
-
store,
|
|
9
|
-
storeName,
|
|
10
|
-
upload,
|
|
11
|
-
wnfsUrl
|
|
12
|
-
} from "../chunk-L33MOD23.mjs";
|
|
13
|
-
import "../chunk-J5LGTIGS.mjs";
|
|
14
|
-
export {
|
|
15
|
-
Rng,
|
|
16
|
-
filePath,
|
|
17
|
-
getBlobUrl,
|
|
18
|
-
getPathFromUrl,
|
|
19
|
-
loadWnfs,
|
|
20
|
-
readFile,
|
|
21
|
-
store,
|
|
22
|
-
storeName,
|
|
23
|
-
upload,
|
|
24
|
-
wnfsUrl
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WnfsCapabilities_exports
|
|
3
|
-
} from "./chunk-2WLTMUHV.mjs";
|
|
4
|
-
import {
|
|
5
|
-
Rng,
|
|
6
|
-
WnfsStateAnnotation,
|
|
7
|
-
filePath,
|
|
8
|
-
getBlobUrl,
|
|
9
|
-
getPathFromUrl,
|
|
10
|
-
loadWnfs,
|
|
11
|
-
readFile,
|
|
12
|
-
store,
|
|
13
|
-
storeName,
|
|
14
|
-
upload,
|
|
15
|
-
wnfsUrl
|
|
16
|
-
} from "./chunk-L33MOD23.mjs";
|
|
17
|
-
import {
|
|
18
|
-
meta
|
|
19
|
-
} from "./chunk-H2YCLSRI.mjs";
|
|
20
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
21
|
-
export {
|
|
22
|
-
Rng,
|
|
23
|
-
WnfsCapabilities_exports as WnfsCapabilities,
|
|
24
|
-
WnfsStateAnnotation,
|
|
25
|
-
filePath,
|
|
26
|
-
getBlobUrl,
|
|
27
|
-
getPathFromUrl,
|
|
28
|
-
loadWnfs,
|
|
29
|
-
meta,
|
|
30
|
-
readFile,
|
|
31
|
-
store,
|
|
32
|
-
storeName,
|
|
33
|
-
upload,
|
|
34
|
-
wnfsUrl
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/annotations.ts":{"bytes":1544,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/helpers/common.ts":{"bytes":7514,"imports":[{"path":"multiformats/cid","kind":"import-statement","external":true},{"path":"multiformats/hashes/sha2","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true}],"format":"esm"},"src/helpers/load.ts":{"bytes":12561,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"uint8arrays","kind":"import-statement","external":true},{"path":"wnfs","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/annotations.ts","kind":"import-statement","original":"../annotations"},{"path":"src/helpers/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"},"src/helpers/wnfs-url.ts":{"bytes":3235,"imports":[{"path":"src/helpers/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"},"src/helpers/upload.ts":{"bytes":8379,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"multiformats/codecs/raw","kind":"import-statement","external":true},{"path":"multiformats/hashes/sha2","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/annotations.ts","kind":"import-statement","original":"../annotations"},{"path":"src/helpers/common.ts","kind":"import-statement","original":"./common"},{"path":"src/helpers/load.ts","kind":"import-statement","original":"./load"},{"path":"src/helpers/wnfs-url.ts","kind":"import-statement","original":"./wnfs-url"}],"format":"esm"},"src/helpers/index.ts":{"bytes":620,"imports":[{"path":"src/helpers/common.ts","kind":"import-statement","original":"./common"},{"path":"src/helpers/load.ts","kind":"import-statement","original":"./load"},{"path":"src/helpers/upload.ts","kind":"import-statement","original":"./upload"},{"path":"src/helpers/wnfs-url.ts","kind":"import-statement","original":"./wnfs-url"}],"format":"esm"},"dx.config.ts":{"bytes":4516,"imports":[{"path":"@dxos/app-framework/config","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/meta.ts":{"bytes":799,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"dx.config.ts","kind":"import-statement","original":"../dx.config"}],"format":"esm"},"src/types/WnfsCapabilities.ts":{"bytes":1818,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"},"src/types/index.ts":{"bytes":492,"imports":[{"path":"src/types/WnfsCapabilities.ts","kind":"import-statement","original":"./WnfsCapabilities"}],"format":"esm"},"src/index.ts":{"bytes":631,"imports":[{"path":"src/annotations.ts","kind":"import-statement","original":"./annotations"},{"path":"src/helpers/index.ts","kind":"import-statement","original":"./helpers"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-wnfs/PLUGIN.mdl":{"bytes":11144,"imports":[]},"src/WnfsPlugin.tsx":{"bytes":5451,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true},{"path":"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-wnfs/PLUGIN.mdl","kind":"import-statement","original":"../PLUGIN.mdl?raw"}],"format":"esm"},"src/WnfsPlugin.node.ts":{"bytes":968,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"},"src/WnfsPlugin.workerd.ts":{"bytes":972,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"},"src/capabilities/backend.ts":{"bytes":5528,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-file/types","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true},{"path":"src/helpers/index.ts","kind":"import-statement","original":"../helpers"}],"format":"esm"},"src/blockstore.ts":{"bytes":19231,"imports":[{"path":"@ipld/car","kind":"import-statement","external":true},{"path":"blockstore-core","kind":"import-statement","external":true},{"path":"blockstore-idb","kind":"import-statement","external":true},{"path":"debounce","kind":"import-statement","external":true},{"path":"idb-keyval","kind":"import-statement","external":true},{"path":"it-all","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"uint8arrays","kind":"import-statement","external":true},{"path":"src/helpers/index.ts","kind":"import-statement","original":"./helpers"}],"format":"esm"},"src/capabilities/blockstore.ts":{"bytes":2806,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true},{"path":"src/blockstore.ts","kind":"import-statement","original":"../blockstore"}],"format":"esm"},"src/capabilities/url-resolver.ts":{"bytes":4741,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-file/types","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true},{"path":"src/helpers/index.ts","kind":"import-statement","original":"../helpers"}],"format":"esm"},"src/capabilities/index.ts":{"bytes":1384,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/capabilities/backend.ts","kind":"dynamic-import","original":"./backend"},{"path":"src/capabilities/blockstore.ts","kind":"dynamic-import","original":"./blockstore"},{"path":"src/capabilities/url-resolver.ts","kind":"dynamic-import","original":"./url-resolver"}],"format":"esm"},"src/plugin.ts":{"bytes":849,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"#plugin","kind":"dynamic-import","external":true}],"format":"esm"},"src/translations.ts":{"bytes":1074,"imports":[{"path":"#meta","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/lib/neutral/translations.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":570},"dist/lib/neutral/translations.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"#meta","kind":"import-statement","external":true}],"exports":["translations"],"entryPoint":"src/translations.ts","inputs":{"src/translations.ts":{"bytesInOutput":149}},"bytes":273},"dist/lib/neutral/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/types/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-2WLTMUHV.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["WnfsCapabilities"],"entryPoint":"src/types/index.ts","inputs":{},"bytes":194},"dist/lib/neutral/backend-4HPTHS33.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2734},"dist/lib/neutral/backend-4HPTHS33.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L33MOD23.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-file/types","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true}],"exports":["WNFS_BACKEND_ID","default"],"entryPoint":"src/capabilities/backend.ts","inputs":{"src/capabilities/backend.ts":{"bytesInOutput":1490}},"bytes":1708},"dist/lib/neutral/blockstore-U6SPNL2C.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11033},"dist/lib/neutral/blockstore-U6SPNL2C.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L33MOD23.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true},{"path":"@ipld/car","kind":"import-statement","external":true},{"path":"blockstore-core","kind":"import-statement","external":true},{"path":"blockstore-idb","kind":"import-statement","external":true},{"path":"debounce","kind":"import-statement","external":true},{"path":"idb-keyval","kind":"import-statement","external":true},{"path":"it-all","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"uint8arrays","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/blockstore.ts","inputs":{"src/capabilities/blockstore.ts":{"bytesInOutput":605},"src/blockstore.ts":{"bytesInOutput":4264}},"bytes":5137},"dist/lib/neutral/url-resolver-BIRH7WHL.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2456},"dist/lib/neutral/url-resolver-BIRH7WHL.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L33MOD23.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-file/types","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true}],"exports":["WNFS_URL_RESOLVER_ID","default"],"entryPoint":"src/capabilities/url-resolver.ts","inputs":{"src/capabilities/url-resolver.ts":{"bytesInOutput":1099}},"bytes":1353},"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-2WLTMUHV.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-L33MOD23.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-H2YCLSRI.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["Rng","WnfsCapabilities","WnfsStateAnnotation","filePath","getBlobUrl","getPathFromUrl","loadWnfs","meta","readFile","store","storeName","upload","wnfsUrl"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":568},"dist/lib/neutral/chunk-2WLTMUHV.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1028},"dist/lib/neutral/chunk-2WLTMUHV.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["WnfsCapabilities_exports"],"inputs":{"src/types/WnfsCapabilities.ts":{"bytesInOutput":373},"src/types/index.ts":{"bytesInOutput":0}},"bytes":542},"dist/lib/neutral/WnfsPlugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14575},"dist/lib/neutral/WnfsPlugin.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"#types","kind":"import-statement","external":true}],"exports":["WnfsPlugin","default"],"entryPoint":"src/WnfsPlugin.tsx","inputs":{"src/WnfsPlugin.tsx":{"bytesInOutput":1244},"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-wnfs/PLUGIN.mdl":{"bytesInOutput":11554}},"bytes":13043},"dist/lib/neutral/WnfsPlugin.node.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":512},"dist/lib/neutral/WnfsPlugin.node.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["WnfsPlugin","default"],"entryPoint":"src/WnfsPlugin.node.ts","inputs":{"src/WnfsPlugin.node.ts":{"bytesInOutput":174}},"bytes":340},"dist/lib/neutral/WnfsPlugin.workerd.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":515},"dist/lib/neutral/WnfsPlugin.workerd.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["WnfsPlugin","default"],"entryPoint":"src/WnfsPlugin.workerd.ts","inputs":{"src/WnfsPlugin.workerd.ts":{"bytesInOutput":177}},"bytes":352},"dist/lib/neutral/capabilities/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":734},"dist/lib/neutral/capabilities/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"dist/lib/neutral/backend-4HPTHS33.mjs","kind":"dynamic-import"},{"path":"dist/lib/neutral/blockstore-U6SPNL2C.mjs","kind":"dynamic-import"},{"path":"dist/lib/neutral/url-resolver-BIRH7WHL.mjs","kind":"dynamic-import"}],"exports":["Backend","Blockstore","UrlResolver"],"entryPoint":"src/capabilities/index.ts","inputs":{"src/capabilities/index.ts":{"bytesInOutput":321}},"bytes":469},"dist/lib/neutral/helpers/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/helpers/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L33MOD23.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["Rng","filePath","getBlobUrl","getPathFromUrl","loadWnfs","readFile","store","storeName","upload","wnfsUrl"],"entryPoint":"src/helpers/index.ts","inputs":{},"bytes":354},"dist/lib/neutral/chunk-L33MOD23.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17086},"dist/lib/neutral/chunk-L33MOD23.mjs":{"imports":[{"path":"multiformats/cid","kind":"import-statement","external":true},{"path":"multiformats/hashes/sha2","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"uint8arrays","kind":"import-statement","external":true},{"path":"wnfs","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"multiformats","kind":"import-statement","external":true},{"path":"multiformats/codecs/raw","kind":"import-statement","external":true},{"path":"multiformats/hashes/sha2","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["Rng","WnfsStateAnnotation","filePath","getBlobUrl","getPathFromUrl","loadWnfs","readFile","store","storeName","upload","wnfsUrl"],"inputs":{"src/helpers/common.ts":{"bytesInOutput":1568},"src/helpers/index.ts":{"bytesInOutput":0},"src/helpers/load.ts":{"bytesInOutput":2772},"src/annotations.ts":{"bytesInOutput":263},"src/helpers/upload.ts":{"bytesInOutput":1715},"src/helpers/wnfs-url.ts":{"bytesInOutput":567}},"bytes":7258},"dist/lib/neutral/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/meta.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-H2YCLSRI.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["meta"],"entryPoint":"src/meta.ts","inputs":{},"bytes":131},"dist/lib/neutral/plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":436},"dist/lib/neutral/plugin.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-H2YCLSRI.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#plugin","kind":"dynamic-import","external":true}],"exports":["WnfsPlugin"],"entryPoint":"src/plugin.ts","inputs":{"src/plugin.ts":{"bytesInOutput":107}},"bytes":264},"dist/lib/neutral/chunk-H2YCLSRI.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2400},"dist/lib/neutral/chunk-H2YCLSRI.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-framework/config","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["meta"],"inputs":{"src/meta.ts":{"bytesInOutput":102},"dx.config.ts":{"bytesInOutput":1549}},"bytes":1763},"dist/lib/neutral/chunk-J5LGTIGS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/chunk-J5LGTIGS.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":235}}}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-H2YCLSRI.mjs";
|
|
4
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
5
|
-
|
|
6
|
-
// src/plugin.ts
|
|
7
|
-
import { Plugin } from "@dxos/app-framework";
|
|
8
|
-
var WnfsPlugin = Plugin.lazy(meta, () => import("#plugin"));
|
|
9
|
-
export {
|
|
10
|
-
WnfsPlugin
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport const WnfsPlugin = Plugin.lazy(meta, () => import('#plugin'));\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,cAAc;AAIhB,IAAMC,aAAaC,OAAOC,KAAKC,MAAM,MAAM,OAAO,SAAA,CAAA;",
|
|
6
|
-
"names": ["Plugin", "WnfsPlugin", "Plugin", "lazy", "meta"]
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/translations.ts
|
|
4
|
-
import { meta } from "#meta";
|
|
5
|
-
var translations = [
|
|
6
|
-
{
|
|
7
|
-
"en-US": {
|
|
8
|
-
[meta.profile.key]: {
|
|
9
|
-
"plugin.name": "WNFS"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
];
|
|
14
|
-
export {
|
|
15
|
-
translations
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=translations.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from '#meta';\n\nexport const translations = [\n {\n 'en-US': {\n [meta.profile.key]: {\n 'plugin.name': 'WNFS',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";;;AAMA,SAASA,YAAY;AAEd,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,KAAKE,QAAQC,GAAG,GAAG;QAClB,eAAe;MACjB;IACF;EACF;;",
|
|
6
|
-
"names": ["meta", "translations", "profile", "key"]
|
|
7
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getBlobUrl,
|
|
3
|
-
loadWnfs
|
|
4
|
-
} from "./chunk-L33MOD23.mjs";
|
|
5
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/url-resolver.ts
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
|
-
import { Capability } from "@dxos/app-framework";
|
|
10
|
-
import { FileCapabilities } from "@dxos/plugin-file/types";
|
|
11
|
-
import { WnfsCapabilities } from "#types";
|
|
12
|
-
var WNFS_URL_RESOLVER_ID = "wnfs";
|
|
13
|
-
var url_resolver_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
14
|
-
const capabilities = yield* Capability.Service;
|
|
15
|
-
return Capability.contributes(FileCapabilities.UrlResolver, {
|
|
16
|
-
id: WNFS_URL_RESOLVER_ID,
|
|
17
|
-
test: (url) => url.startsWith("wnfs://"),
|
|
18
|
-
resolve: async (wnfsUrl, file, space) => {
|
|
19
|
-
if (!space) {
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
24
|
-
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
25
|
-
const { directory, forest } = await loadWnfs({
|
|
26
|
-
blockstore,
|
|
27
|
-
instances,
|
|
28
|
-
space
|
|
29
|
-
});
|
|
30
|
-
return await getBlobUrl({
|
|
31
|
-
wnfsUrl,
|
|
32
|
-
blockstore,
|
|
33
|
-
directory,
|
|
34
|
-
forest,
|
|
35
|
-
type: file.type
|
|
36
|
-
});
|
|
37
|
-
} catch {
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}));
|
|
43
|
-
export {
|
|
44
|
-
WNFS_URL_RESOLVER_ID,
|
|
45
|
-
url_resolver_default as default
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=url-resolver-BIRH7WHL.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/url-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { FileCapabilities } from '@dxos/plugin-file/types';\n\nimport { WnfsCapabilities } from '#types';\n\nimport { getBlobUrl, loadWnfs } from '../helpers';\n\nexport const WNFS_URL_RESOLVER_ID = 'wnfs';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const capabilities = yield* Capability.Service;\n\n return Capability.contributes(FileCapabilities.UrlResolver, {\n id: WNFS_URL_RESOLVER_ID,\n test: (url) => url.startsWith('wnfs://'),\n resolve: async (wnfsUrl, file, space) => {\n if (!space) {\n return undefined;\n }\n try {\n const blockstore = capabilities.get(WnfsCapabilities.Blockstore);\n const instances = capabilities.get(WnfsCapabilities.Instances);\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n return await getBlobUrl({\n wnfsUrl,\n blockstore,\n directory,\n forest,\n type: file.type,\n });\n } catch {\n return undefined;\n }\n },\n });\n }),\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,wBAAwB;AAEjC,SAASC,wBAAwB;AAI1B,IAAMC,uBAAuB;AAEpC,IAAA,uBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,SAAOJ,WAAWK,YAAYC,iBAAiBC,aAAa;IAC1DC,IAAIT;IACJU,MAAM,CAACC,QAAQA,IAAIC,WAAW,SAAA;IAC9BC,SAAS,OAAOC,SAASC,MAAMC,UAAAA;AAC7B,UAAI,CAACA,OAAO;AACV,eAAOC;MACT;AACA,UAAI;AACF,cAAMC,aAAad,aAAae,IAAIC,iBAAiBC,UAAU;AAC/D,cAAMC,YAAYlB,aAAae,IAAIC,iBAAiBG,SAAS;AAC7D,cAAM,EAAEC,WAAWC,OAAM,IAAK,MAAMC,SAAS;UAAER;UAAYI;UAAWN;QAAM,CAAA;AAC5E,eAAO,MAAMW,WAAW;UACtBb;UACAI;UACAM;UACAC;UACAG,MAAMb,KAAKa;QACb,CAAA;MACF,QAAQ;AACN,eAAOX;MACT;IACF;EACF,CAAA;AACF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "Capability", "FileCapabilities", "WnfsCapabilities", "WNFS_URL_RESOLVER_ID", "Capability", "makeModule", "fnUntraced", "capabilities", "Service", "contributes", "FileCapabilities", "UrlResolver", "id", "test", "url", "startsWith", "resolve", "wnfsUrl", "file", "space", "undefined", "blockstore", "get", "WnfsCapabilities", "Blockstore", "instances", "Instances", "directory", "forest", "loadWnfs", "getBlobUrl", "type"]
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
export declare const WNFS_BACKEND_ID = "wnfs";
|
|
4
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Any, never, Capability.Service>;
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAUjD,eAAO,MAAM,eAAe,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blockstore.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/blockstore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
export declare const WNFS_URL_RESOLVER_ID = "wnfs";
|
|
4
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Any, never, Capability.Service>;
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=url-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/url-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOjD,eAAO,MAAM,oBAAoB,SAAS,CAAC"}
|