@dxos/plugin-wnfs 0.8.4-main.c1de068 → 0.8.4-main.c4373fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{FileContainer-6P2SYTVH.mjs → FileContainer-A4OJVMVS.mjs} +31 -33
- package/dist/lib/browser/FileContainer-A4OJVMVS.mjs.map +7 -0
- package/dist/lib/browser/blockstore-HK4IYHJJ.mjs +273 -0
- package/dist/lib/browser/blockstore-HK4IYHJJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VRRXG6IB.mjs → chunk-D6VTEQIE.mjs} +3 -3
- package/dist/lib/browser/{chunk-VRRXG6IB.mjs.map → chunk-D6VTEQIE.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-VDDGZWAY.mjs → chunk-FYRZOKHG.mjs} +2 -4
- package/dist/lib/browser/chunk-FYRZOKHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-PAIK4SJ3.mjs +16 -0
- package/dist/lib/browser/chunk-PAIK4SJ3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GVBV2QWA.mjs → chunk-QQB5IBX7.mjs} +9 -9
- package/dist/lib/browser/chunk-QQB5IBX7.mjs.map +7 -0
- package/dist/lib/browser/chunk-Y5JMTQ74.mjs +16 -0
- package/dist/lib/browser/{file-uploader-JA55DPMW.mjs → file-uploader-5S37ZZCW.mjs} +8 -7
- package/dist/lib/browser/file-uploader-5S37ZZCW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -9
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-YM6QRFIH.mjs → intent-resolver-3KMIEDBO.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-3KMIEDBO.mjs.map +7 -0
- package/dist/lib/browser/{markdown-6VH477GB.mjs → markdown-5XD3I2NQ.mjs} +23 -10
- package/dist/lib/browser/markdown-5XD3I2NQ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-NOSB5MZ2.mjs → react-surface-5D7M3Y4W.mjs} +11 -11
- package/dist/lib/browser/react-surface-5D7M3Y4W.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/types/src/WnfsPlugin.d.ts +1 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileContainer.d.ts.map +1 -1
- package/dist/types/src/components/FileInput.d.ts +1 -1
- package/dist/types/src/components/FileInput.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts +5 -4
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +1 -1
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/file.d.ts +3 -3
- package/dist/types/src/types/file.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +5 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -34
- package/src/WnfsPlugin.tsx +70 -68
- package/src/blockstore.ts +2 -2
- package/src/capabilities/blockstore.ts +3 -2
- package/src/capabilities/capabilities.ts +3 -3
- package/src/capabilities/file-uploader.ts +6 -3
- package/src/capabilities/intent-resolver.ts +3 -2
- package/src/capabilities/markdown.ts +3 -2
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/components/FileContainer.tsx +11 -13
- package/src/components/FileInput.tsx +3 -3
- package/src/extensions/image.stories.tsx +15 -11
- package/src/extensions/image.tsx +3 -3
- package/src/helpers/load.ts +3 -2
- package/src/helpers/upload.ts +2 -1
- package/src/meta.ts +1 -3
- package/src/types/file.ts +2 -2
- package/src/types/types.ts +6 -5
- package/dist/lib/browser/FileContainer-6P2SYTVH.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs +0 -191
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs.map +0 -7
- package/dist/lib/browser/chunk-GVBV2QWA.mjs.map +0 -7
- package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
- package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-WTYTESSC.mjs +0 -16
- package/dist/lib/browser/file-uploader-JA55DPMW.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs.map +0 -7
- package/dist/lib/browser/markdown-6VH477GB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-NOSB5MZ2.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-WTYTESSC.mjs.map → chunk-Y5JMTQ74.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.c4373fc",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs"
|
|
14
15
|
},
|
|
15
16
|
"./types": {
|
|
17
|
+
"source": "./src/types/index.ts",
|
|
16
18
|
"types": "./dist/types/src/types/index.d.ts",
|
|
17
19
|
"browser": "./dist/lib/browser/types/index.mjs"
|
|
18
20
|
}
|
|
@@ -30,15 +32,15 @@
|
|
|
30
32
|
"src"
|
|
31
33
|
],
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@codemirror/language": "^6.
|
|
34
|
-
"@codemirror/state": "^6.
|
|
35
|
-
"@codemirror/view": "^6.
|
|
35
|
+
"@codemirror/language": "^6.11.3",
|
|
36
|
+
"@codemirror/state": "^6.5.2",
|
|
37
|
+
"@codemirror/view": "^6.38.4",
|
|
36
38
|
"@ipld/car": "^5.3.3",
|
|
37
39
|
"@preact-signals/safe-react": "^0.9.0",
|
|
38
40
|
"blockstore-core": "^5.0.1",
|
|
39
41
|
"blockstore-idb": "^2.0.0",
|
|
40
42
|
"debounce": "^2.2.0",
|
|
41
|
-
"effect": "3.
|
|
43
|
+
"effect": "3.18.3",
|
|
42
44
|
"idb-keyval": "^6.2.1",
|
|
43
45
|
"interface-blockstore": "^5.2.10",
|
|
44
46
|
"it-all": "^3.0.6",
|
|
@@ -46,40 +48,39 @@
|
|
|
46
48
|
"react-dropzone": "^14.2.3",
|
|
47
49
|
"uint8arrays": "^5.1.0",
|
|
48
50
|
"wnfs": "0.2.2",
|
|
49
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/local-storage": "0.8.4-main.
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/plugin-
|
|
58
|
-
"@dxos/plugin-markdown": "0.8.4-main.
|
|
59
|
-
"@dxos/react-
|
|
60
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/react-ui-
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/react-
|
|
65
|
-
"@dxos/util": "0.8.4-main.c1de068"
|
|
51
|
+
"@dxos/app-framework": "0.8.4-main.c4373fc",
|
|
52
|
+
"@dxos/crypto": "0.8.4-main.c4373fc",
|
|
53
|
+
"@dxos/echo": "0.8.4-main.c4373fc",
|
|
54
|
+
"@dxos/effect": "0.8.4-main.c4373fc",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.c4373fc",
|
|
56
|
+
"@dxos/log": "0.8.4-main.c4373fc",
|
|
57
|
+
"@dxos/local-storage": "0.8.4-main.c4373fc",
|
|
58
|
+
"@dxos/plugin-client": "0.8.4-main.c4373fc",
|
|
59
|
+
"@dxos/plugin-space": "0.8.4-main.c4373fc",
|
|
60
|
+
"@dxos/plugin-markdown": "0.8.4-main.c4373fc",
|
|
61
|
+
"@dxos/react-ui-editor": "0.8.4-main.c4373fc",
|
|
62
|
+
"@dxos/react-ui-form": "0.8.4-main.c4373fc",
|
|
63
|
+
"@dxos/react-ui": "0.8.4-main.c4373fc",
|
|
64
|
+
"@dxos/react-ui-stack": "0.8.4-main.c4373fc",
|
|
65
|
+
"@dxos/util": "0.8.4-main.c4373fc",
|
|
66
|
+
"@dxos/react-client": "0.8.4-main.c4373fc"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@types/react": "~
|
|
69
|
-
"@types/react-dom": "~
|
|
70
|
-
"react": "~
|
|
71
|
-
"react-dom": "~
|
|
72
|
-
"vite": "
|
|
73
|
-
"@dxos/random": "0.8.4-main.
|
|
74
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
75
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
69
|
+
"@types/react": "~19.2.2",
|
|
70
|
+
"@types/react-dom": "~19.2.1",
|
|
71
|
+
"react": "~19.2.0",
|
|
72
|
+
"react-dom": "~19.2.0",
|
|
73
|
+
"vite": "7.1.9",
|
|
74
|
+
"@dxos/random": "0.8.4-main.c4373fc",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.4-main.c4373fc",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.c4373fc"
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"effect": "^3.13.3",
|
|
79
|
-
"react": "
|
|
80
|
-
"react-dom": "
|
|
81
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
82
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
80
|
+
"react": "^19.0.0",
|
|
81
|
+
"react-dom": "^19.0.0",
|
|
82
|
+
"@dxos/react-ui": "0.8.4-main.c4373fc",
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.4-main.c4373fc"
|
|
83
84
|
},
|
|
84
85
|
"publishConfig": {
|
|
85
86
|
"access": "public"
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
Capabilities,
|
|
@@ -23,71 +23,73 @@ import { meta } from './meta';
|
|
|
23
23
|
import { translations } from './translations';
|
|
24
24
|
import { FileType, WnfsAction } from './types';
|
|
25
25
|
|
|
26
|
-
export const WnfsPlugin = () =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
26
|
+
export const WnfsPlugin = definePlugin(meta, () => [
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/blockstore`,
|
|
29
|
+
activatesOn: ClientEvents.ClientReady,
|
|
30
|
+
activate: Blockstore,
|
|
31
|
+
}),
|
|
32
|
+
defineModule({
|
|
33
|
+
id: `${meta.id}/module/instances`,
|
|
34
|
+
activatesOn: ClientEvents.ClientReady,
|
|
35
|
+
activate: () => {
|
|
36
|
+
const instances: WnfsCapabilities.Instances = {};
|
|
37
|
+
return contributes(WnfsCapabilities.Instances, instances);
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
defineModule({
|
|
41
|
+
id: `${meta.id}/module/translations`,
|
|
42
|
+
activatesOn: Events.SetupTranslations,
|
|
43
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
44
|
+
}),
|
|
45
|
+
defineModule({
|
|
46
|
+
id: `${meta.id}/module/metadata`,
|
|
47
|
+
activatesOn: Events.SetupMetadata,
|
|
48
|
+
activate: () =>
|
|
49
|
+
contributes(Capabilities.Metadata, {
|
|
50
|
+
id: FileType.typename,
|
|
51
|
+
metadata: {
|
|
52
|
+
label: (object: any) => (object instanceof FileType ? object.name : undefined),
|
|
53
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
54
|
+
icon: 'ph--file--regular',
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
}),
|
|
58
|
+
defineModule({
|
|
59
|
+
id: `${meta.id}/module/object-form`,
|
|
60
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
61
|
+
activate: () =>
|
|
62
|
+
contributes(
|
|
63
|
+
SpaceCapabilities.ObjectForm,
|
|
64
|
+
defineObjectForm({
|
|
65
|
+
objectSchema: FileType,
|
|
66
|
+
formSchema: WnfsAction.UploadFileSchema,
|
|
67
|
+
getIntent: (props, options) =>
|
|
68
|
+
Function.pipe(
|
|
69
|
+
createIntent(WnfsAction.Upload, { ...props, space: options.space }),
|
|
70
|
+
chain(WnfsAction.Create, {}),
|
|
71
|
+
),
|
|
57
72
|
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
activate: Markdown,
|
|
82
|
-
}),
|
|
83
|
-
defineModule({
|
|
84
|
-
id: `${meta.id}/module/react-surface`,
|
|
85
|
-
activatesOn: Events.SetupReactSurface,
|
|
86
|
-
activate: ReactSurface,
|
|
87
|
-
}),
|
|
88
|
-
defineModule({
|
|
89
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
90
|
-
activatesOn: Events.SetupIntentResolver,
|
|
91
|
-
activate: IntentResolver,
|
|
92
|
-
}),
|
|
93
|
-
]);
|
|
73
|
+
),
|
|
74
|
+
}),
|
|
75
|
+
defineModule({
|
|
76
|
+
id: `${meta.id}/module/file-uploader`,
|
|
77
|
+
activatesOn: ClientEvents.ClientReady,
|
|
78
|
+
activate: FileUploader,
|
|
79
|
+
}),
|
|
80
|
+
defineModule({
|
|
81
|
+
id: `${meta.id}/module/markdown`,
|
|
82
|
+
activatesOn: MarkdownEvents.SetupExtensions,
|
|
83
|
+
activate: Markdown,
|
|
84
|
+
}),
|
|
85
|
+
defineModule({
|
|
86
|
+
id: `${meta.id}/module/react-surface`,
|
|
87
|
+
activatesOn: Events.SetupReactSurface,
|
|
88
|
+
activate: ReactSurface,
|
|
89
|
+
}),
|
|
90
|
+
defineModule({
|
|
91
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
92
|
+
activatesOn: Events.SetupIntentResolver,
|
|
93
|
+
activate: IntentResolver,
|
|
94
|
+
}),
|
|
95
|
+
]);
|
package/src/blockstore.ts
CHANGED
|
@@ -126,7 +126,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
126
126
|
if (this.#apiHost) {
|
|
127
127
|
await fetch(this.url(this.#apiHost, key), {
|
|
128
128
|
method: 'POST',
|
|
129
|
-
body: val
|
|
129
|
+
body: val as Uint8Array<ArrayBuffer>,
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -138,7 +138,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
138
138
|
headers: {
|
|
139
139
|
'Content-Type': 'application/vnd.ipld.car',
|
|
140
140
|
},
|
|
141
|
-
body: car
|
|
141
|
+
body: car as Uint8Array<ArrayBuffer>,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type PluginContext, contributes } from '@dxos/app-framework';
|
|
6
6
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
7
|
|
|
8
|
-
import { WnfsCapabilities } from './capabilities';
|
|
9
8
|
import * as Blockstore from '../blockstore';
|
|
10
9
|
|
|
10
|
+
import { WnfsCapabilities } from './capabilities';
|
|
11
|
+
|
|
11
12
|
export default async (context: PluginContext) => {
|
|
12
13
|
const client = context.getCapability(ClientCapabilities.Client);
|
|
13
14
|
const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';
|
|
@@ -8,11 +8,11 @@ import { type PrivateDirectory, type PrivateForest } from 'wnfs';
|
|
|
8
8
|
import { defineCapability } from '@dxos/app-framework';
|
|
9
9
|
import { type SpaceId } from '@dxos/keys';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { meta } from '../meta';
|
|
12
12
|
|
|
13
13
|
export namespace WnfsCapabilities {
|
|
14
|
-
export const Blockstore = defineCapability<Blockstore>(`${
|
|
14
|
+
export const Blockstore = defineCapability<Blockstore>(`${meta.id}/capability/blockstore`);
|
|
15
15
|
|
|
16
16
|
export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;
|
|
17
|
-
export const Instances = defineCapability<Instances>(`${
|
|
17
|
+
export const Instances = defineCapability<Instances>(`${meta.id}/capability/instances`);
|
|
18
18
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
6
7
|
|
|
7
|
-
import { Capabilities, chain, contributes, createIntent
|
|
8
|
+
import { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';
|
|
8
9
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
9
10
|
|
|
10
11
|
import { WnfsAction } from '../types';
|
|
@@ -15,7 +16,9 @@ export default (context: PluginContext) => {
|
|
|
15
16
|
|
|
16
17
|
const program = Effect.gen(function* () {
|
|
17
18
|
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));
|
|
18
|
-
yield* dispatch(
|
|
19
|
+
yield* dispatch(
|
|
20
|
+
Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })),
|
|
21
|
+
);
|
|
19
22
|
return fileInfo;
|
|
20
23
|
});
|
|
21
24
|
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
|
|
6
6
|
import { Obj } from '@dxos/echo';
|
|
7
7
|
|
|
8
|
-
import { WnfsCapabilities } from './capabilities';
|
|
9
8
|
import { upload } from '../helpers';
|
|
10
9
|
import { FileType, WnfsAction } from '../types';
|
|
11
10
|
|
|
11
|
+
import { WnfsCapabilities } from './capabilities';
|
|
12
|
+
|
|
12
13
|
export default (context: PluginContext) =>
|
|
13
14
|
contributes(Capabilities.IntentResolver, [
|
|
14
15
|
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type PluginContext, contributes } from '@dxos/app-framework';
|
|
6
6
|
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
7
7
|
import { getSpace } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
|
-
import { WnfsCapabilities } from './capabilities';
|
|
10
9
|
import { image } from '../extensions';
|
|
11
10
|
|
|
11
|
+
import { WnfsCapabilities } from './capabilities';
|
|
12
|
+
|
|
12
13
|
export default (context: PluginContext) =>
|
|
13
14
|
contributes(MarkdownCapabilities.Extensions, [
|
|
14
15
|
({ document }) => {
|
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { findAnnotation } from '@dxos/effect';
|
|
11
11
|
import { type InputProps } from '@dxos/react-ui-form';
|
|
12
12
|
|
|
13
13
|
import { FileContainer, FileInput } from '../components';
|
|
14
|
-
import {
|
|
14
|
+
import { meta } from '../meta';
|
|
15
15
|
import { FileType, WnfsAction } from '../types';
|
|
16
16
|
|
|
17
17
|
export default () =>
|
|
18
18
|
contributes(Capabilities.ReactSurface, [
|
|
19
19
|
createSurface({
|
|
20
|
-
id: `${
|
|
20
|
+
id: `${meta.id}/article`,
|
|
21
21
|
role: ['article', 'section', 'slide'],
|
|
22
22
|
filter: (data): data is { subject: FileType } => Obj.instanceOf(FileType, data.subject),
|
|
23
23
|
component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,
|
|
24
24
|
}),
|
|
25
25
|
createSurface({
|
|
26
|
-
id: `${
|
|
26
|
+
id: `${meta.id}/create-form`,
|
|
27
27
|
role: 'form-input',
|
|
28
28
|
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
29
29
|
const annotation = findAnnotation<boolean>(
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { useCapability } from '@dxos/app-framework';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
10
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
12
|
|
|
12
|
-
import { FilePreview } from './FilePreview';
|
|
13
13
|
import { WnfsCapabilities } from '../capabilities';
|
|
14
14
|
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
|
|
15
15
|
import { type FileType } from '../types';
|
|
16
16
|
|
|
17
|
+
import { FilePreview } from './FilePreview';
|
|
18
|
+
|
|
17
19
|
export type FileContainerProps = {
|
|
18
20
|
role: string;
|
|
19
21
|
file: FileType;
|
|
@@ -24,17 +26,13 @@ export const FileContainer = ({ file }: FileContainerProps) => {
|
|
|
24
26
|
const instances = useCapability(WnfsCapabilities.Instances);
|
|
25
27
|
const [blobUrl, setBlobUrl] = useState<string>();
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setBlobUrl(url);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => clearTimeout(timeout);
|
|
29
|
+
useAsyncEffect(async () => {
|
|
30
|
+
const space = getSpace(file);
|
|
31
|
+
invariant(space);
|
|
32
|
+
const { directory, forest } = await loadWnfs({ blockstore, instances, space });
|
|
33
|
+
const path = filePath(file.cid.toString(), space);
|
|
34
|
+
const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
|
|
35
|
+
setBlobUrl(url);
|
|
38
36
|
}, [file]);
|
|
39
37
|
|
|
40
38
|
if (!blobUrl) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
import { useDropzone } from 'react-dropzone';
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ import { findAnnotation } from '@dxos/effect';
|
|
|
10
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../meta';
|
|
14
14
|
import { WnfsAction } from '../types';
|
|
15
15
|
|
|
16
16
|
export type FileInputProps = {
|
|
@@ -19,7 +19,7 @@ export type FileInputProps = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const FileInput = ({ schema, onChange }: FileInputProps) => {
|
|
22
|
-
const { t } = useTranslation(
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
23
|
const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);
|
|
24
24
|
|
|
25
25
|
const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
6
|
import type { Blockstore } from 'interface-blockstore';
|
|
8
7
|
import React, { type ChangeEvent, useEffect, useState } from 'react';
|
|
9
8
|
|
|
@@ -11,6 +10,7 @@ import { faker } from '@dxos/random';
|
|
|
11
10
|
import { useSpace } from '@dxos/react-client/echo';
|
|
12
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
12
|
import { useThemeContext } from '@dxos/react-ui';
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
14
|
import {
|
|
15
15
|
createBasicExtensions,
|
|
16
16
|
createMarkdownExtensions,
|
|
@@ -19,17 +19,17 @@ import {
|
|
|
19
19
|
processEditorPayload,
|
|
20
20
|
useTextEditor,
|
|
21
21
|
} from '@dxos/react-ui-editor';
|
|
22
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
23
22
|
|
|
24
|
-
import { image } from './image';
|
|
25
23
|
import { create as createBlockstore } from '../blockstore';
|
|
26
24
|
import { upload } from '../helpers';
|
|
27
25
|
|
|
26
|
+
import { image } from './image';
|
|
27
|
+
|
|
28
28
|
faker.seed(1);
|
|
29
29
|
const initialValue = faker.lorem.paragraphs(100);
|
|
30
30
|
const instances = {};
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const DefaultStory = () => {
|
|
33
33
|
const { themeMode } = useThemeContext();
|
|
34
34
|
const space = useSpace();
|
|
35
35
|
const [blockstore, setBlockstore] = useState<Blockstore>();
|
|
@@ -54,7 +54,7 @@ const Story = () => {
|
|
|
54
54
|
initialValue,
|
|
55
55
|
extensions: [
|
|
56
56
|
createBasicExtensions(),
|
|
57
|
-
createMarkdownExtensions(
|
|
57
|
+
createMarkdownExtensions(),
|
|
58
58
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
59
59
|
blockstore && space ? [image({ blockstore, instances, space })] : [],
|
|
60
60
|
decorateMarkdown(),
|
|
@@ -91,10 +91,14 @@ const Story = () => {
|
|
|
91
91
|
);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
const meta = {
|
|
95
95
|
title: 'plugins/plugin-wnfs/image',
|
|
96
|
-
render:
|
|
97
|
-
decorators: [withClientProvider({ createIdentity: true, createSpace: true })
|
|
98
|
-
}
|
|
96
|
+
render: DefaultStory,
|
|
97
|
+
decorators: [withTheme, withClientProvider({ createIdentity: true, createSpace: true })],
|
|
98
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
99
|
+
|
|
100
|
+
export default meta;
|
|
101
|
+
|
|
102
|
+
type Story = StoryObj<typeof meta>;
|
|
99
103
|
|
|
100
|
-
export const Default = {};
|
|
104
|
+
export const Default: Story = {};
|
package/src/extensions/image.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { syntaxTree } from '@codemirror/language';
|
|
6
|
-
import { type EditorState, type Extension,
|
|
6
|
+
import { type EditorState, type Extension, type Range, StateField } from '@codemirror/state';
|
|
7
7
|
import { Decoration, EditorView, WidgetType } from '@codemirror/view';
|
|
8
8
|
import type { Blockstore } from 'interface-blockstore';
|
|
9
9
|
import React from 'react';
|
|
@@ -80,16 +80,16 @@ export const image = (options: ImageOptions): Extension[] => {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const buildDecorations = ({
|
|
83
|
+
state,
|
|
83
84
|
from,
|
|
84
85
|
to,
|
|
85
|
-
state,
|
|
86
86
|
blobUrlCache,
|
|
87
87
|
preload,
|
|
88
88
|
options: { blockstore, instances, space },
|
|
89
89
|
}: {
|
|
90
|
+
state: EditorState;
|
|
90
91
|
from: number;
|
|
91
92
|
to: number;
|
|
92
|
-
state: EditorState;
|
|
93
93
|
blobUrlCache: Record<string, string>;
|
|
94
94
|
preload: (url: string) => void;
|
|
95
95
|
options: ImageOptions;
|
package/src/helpers/load.ts
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
import type { Blockstore } from 'interface-blockstore';
|
|
6
6
|
import { CID } from 'multiformats';
|
|
7
7
|
import * as Uint8Arrays from 'uint8arrays';
|
|
8
|
-
import { AccessKey,
|
|
8
|
+
import { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from 'wnfs';
|
|
9
9
|
|
|
10
10
|
import { type Space } from '@dxos/react-client/echo';
|
|
11
11
|
|
|
12
|
-
import { Rng, store } from './common';
|
|
13
12
|
import { type WnfsCapabilities } from '../capabilities';
|
|
14
13
|
|
|
14
|
+
import { Rng, store } from './common';
|
|
15
|
+
|
|
15
16
|
//
|
|
16
17
|
// LOAD
|
|
17
18
|
//
|
package/src/helpers/upload.ts
CHANGED
|
@@ -10,10 +10,11 @@ import { sha256 } from 'multiformats/hashes/sha2';
|
|
|
10
10
|
import type { Space } from '@dxos/client/echo';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
|
|
13
|
+
import { type WnfsCapabilities } from '../capabilities';
|
|
14
|
+
|
|
13
15
|
import { Rng, filePath, store } from './common';
|
|
14
16
|
import { loadWnfs } from './load';
|
|
15
17
|
import { wnfsUrl } from './wnfs-url';
|
|
16
|
-
import { type WnfsCapabilities } from '../capabilities';
|
|
17
18
|
|
|
18
19
|
export const upload = async ({
|
|
19
20
|
file,
|
package/src/meta.ts
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const WNFS_PLUGIN = 'dxos.org/plugin/wnfs';
|
|
8
|
-
|
|
9
7
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
8
|
+
id: 'dxos.org/plugin/wnfs',
|
|
11
9
|
name: 'WNFS',
|
|
12
10
|
description: 'Manage and view files with via the Web Native File System (WNFS).',
|
|
13
11
|
icon: 'ph--file-cloud--regular',
|
package/src/types/file.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { TypedObject } from '@dxos/echo
|
|
7
|
+
import { TypedObject } from '@dxos/echo/internal';
|
|
8
8
|
|
|
9
9
|
export class FileType extends TypedObject({
|
|
10
10
|
typename: 'dxos.org/type/File',
|