@dxos/plugin-wnfs 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea
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-KTD63EBQ.mjs → FileContainer-4U23PNBL.mjs} +4 -4
- package/dist/lib/browser/{FileContainer-KTD63EBQ.mjs.map → FileContainer-4U23PNBL.mjs.map} +1 -1
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs +191 -0
- package/dist/lib/browser/{blockstore-7ZSJRK6J.mjs.map → blockstore-2JFU4NBU.mjs.map} +2 -2
- package/dist/lib/browser/chunk-7MEFQJWE.mjs +16 -0
- package/dist/lib/browser/{chunk-CW4BENRQ.mjs → chunk-CWMKN2F6.mjs} +27 -20
- package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +7 -0
- package/dist/lib/browser/chunk-F4QHZWQD.mjs +16 -0
- package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +7 -0
- package/dist/lib/browser/chunk-OGPGLJCV.mjs +25 -0
- package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +7 -0
- package/dist/lib/browser/{file-uploader-YRZPRETS.mjs → file-uploader-W6TJLAAK.mjs} +11 -10
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-CKGJNE6P.mjs → intent-resolver-FSW2EQF4.mjs} +8 -9
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +7 -0
- package/dist/lib/browser/{markdown-5FPQ3X4O.mjs → markdown-3ZLVJIGT.mjs} +11 -22
- package/dist/lib/browser/{markdown-5FPQ3X4O.mjs.map → markdown-3ZLVJIGT.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-J7EAO24E.mjs → react-surface-SLRIZ3UR.mjs} +12 -12
- package/dist/lib/browser/react-surface-SLRIZ3UR.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +5 -5
- package/dist/types/src/WnfsPlugin.d.ts +1 -1
- package/dist/types/src/WnfsPlugin.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.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/components/FileContainer.d.ts +2 -2
- 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 +0 -1
- package/dist/types/src/extensions/image.stories.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/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +16 -0
- package/dist/types/src/types/File.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +13 -9
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -34
- package/src/WnfsPlugin.tsx +71 -69
- package/src/capabilities/capabilities.ts +3 -3
- package/src/capabilities/file-uploader.ts +8 -5
- package/src/capabilities/intent-resolver.ts +2 -3
- package/src/capabilities/react-surface.tsx +6 -6
- package/src/components/FileContainer.tsx +2 -2
- package/src/components/FileInput.tsx +3 -3
- package/src/extensions/image.stories.tsx +3 -5
- package/src/extensions/image.tsx +2 -2
- package/src/meta.ts +7 -4
- package/src/translations.ts +2 -2
- package/src/types/File.ts +24 -0
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +8 -8
- package/dist/lib/browser/blockstore-7ZSJRK6J.mjs +0 -273
- package/dist/lib/browser/chunk-7X2PSKY2.mjs +0 -16
- package/dist/lib/browser/chunk-CW4BENRQ.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 +0 -15
- package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-YRZPRETS.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-CKGJNE6P.mjs.map +0 -7
- package/dist/lib/browser/react-surface-J7EAO24E.mjs.map +0 -7
- package/dist/types/src/types/file.d.ts +0 -16
- package/dist/types/src/types/file.d.ts.map +0 -1
- package/src/types/file.ts +0 -17
- /package/dist/lib/browser/{chunk-7X2PSKY2.mjs.map → chunk-7MEFQJWE.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.ae835ea",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@codemirror/language": "^6.
|
|
36
|
-
"@codemirror/state": "^6.
|
|
37
|
-
"@codemirror/view": "^6.
|
|
35
|
+
"@codemirror/language": "^6.11.3",
|
|
36
|
+
"@codemirror/state": "^6.5.2",
|
|
37
|
+
"@codemirror/view": "^6.38.4",
|
|
38
38
|
"@ipld/car": "^5.3.3",
|
|
39
39
|
"@preact-signals/safe-react": "^0.9.0",
|
|
40
40
|
"blockstore-core": "^5.0.1",
|
|
41
41
|
"blockstore-idb": "^2.0.0",
|
|
42
42
|
"debounce": "^2.2.0",
|
|
43
|
-
"effect": "3.
|
|
43
|
+
"effect": "3.18.3",
|
|
44
44
|
"idb-keyval": "^6.2.1",
|
|
45
45
|
"interface-blockstore": "^5.2.10",
|
|
46
46
|
"it-all": "^3.0.6",
|
|
@@ -48,40 +48,39 @@
|
|
|
48
48
|
"react-dropzone": "^14.2.3",
|
|
49
49
|
"uint8arrays": "^5.1.0",
|
|
50
50
|
"wnfs": "0.2.2",
|
|
51
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/echo": "0.8.4-main.
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/plugin-
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/react-
|
|
63
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
64
|
-
"@dxos/react-ui-
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/util": "0.8.4-main.
|
|
67
|
-
"@dxos/react-ui-stack": "0.8.4-main.5ea62a8"
|
|
51
|
+
"@dxos/app-framework": "0.8.4-main.ae835ea",
|
|
52
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
53
|
+
"@dxos/echo": "0.8.4-main.ae835ea",
|
|
54
|
+
"@dxos/local-storage": "0.8.4-main.ae835ea",
|
|
55
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
56
|
+
"@dxos/crypto": "0.8.4-main.ae835ea",
|
|
57
|
+
"@dxos/plugin-client": "0.8.4-main.ae835ea",
|
|
58
|
+
"@dxos/plugin-markdown": "0.8.4-main.ae835ea",
|
|
59
|
+
"@dxos/plugin-space": "0.8.4-main.ae835ea",
|
|
60
|
+
"@dxos/react-client": "0.8.4-main.ae835ea",
|
|
61
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
62
|
+
"@dxos/react-ui-editor": "0.8.4-main.ae835ea",
|
|
63
|
+
"@dxos/react-ui-form": "0.8.4-main.ae835ea",
|
|
64
|
+
"@dxos/react-ui-stack": "0.8.4-main.ae835ea",
|
|
65
|
+
"@dxos/effect": "0.8.4-main.ae835ea",
|
|
66
|
+
"@dxos/util": "0.8.4-main.ae835ea"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|
|
70
|
-
"@types/react": "~
|
|
71
|
-
"@types/react-dom": "~
|
|
72
|
-
"react": "~
|
|
73
|
-
"react-dom": "~
|
|
74
|
-
"vite": "7.1.
|
|
75
|
-
"@dxos/random": "0.8.4-main.
|
|
76
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
77
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
69
|
+
"@types/react": "~19.2.2",
|
|
70
|
+
"@types/react-dom": "~19.2.2",
|
|
71
|
+
"react": "~19.2.0",
|
|
72
|
+
"react-dom": "~19.2.0",
|
|
73
|
+
"vite": "7.1.9",
|
|
74
|
+
"@dxos/random": "0.8.4-main.ae835ea",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.ae835ea"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
80
79
|
"effect": "^3.13.3",
|
|
81
|
-
"react": "
|
|
82
|
-
"react-dom": "
|
|
83
|
-
"@dxos/react-ui
|
|
84
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
80
|
+
"react": "^19.0.0",
|
|
81
|
+
"react-dom": "^19.0.0",
|
|
82
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea"
|
|
85
84
|
},
|
|
86
85
|
"publishConfig": {
|
|
87
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,
|
|
@@ -21,73 +21,75 @@ import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
|
21
21
|
import { Blockstore, FileUploader, IntentResolver, Markdown, ReactSurface, WnfsCapabilities } from './capabilities';
|
|
22
22
|
import { meta } from './meta';
|
|
23
23
|
import { translations } from './translations';
|
|
24
|
-
import {
|
|
24
|
+
import { WnfsAction, WnfsFile } 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: WnfsFile.File.typename,
|
|
51
|
+
metadata: {
|
|
52
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
53
|
+
icon: 'ph--file--regular',
|
|
54
|
+
iconHue: 'teal',
|
|
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: WnfsFile.File,
|
|
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
|
+
]);
|
|
@@ -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,7 +2,8 @@
|
|
|
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
8
|
import { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';
|
|
8
9
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
@@ -10,12 +11,14 @@ import { SpaceAction } from '@dxos/plugin-space/types';
|
|
|
10
11
|
import { WnfsAction } from '../types';
|
|
11
12
|
|
|
12
13
|
export default (context: PluginContext) => {
|
|
13
|
-
return contributes(Capabilities.FileUploader, (
|
|
14
|
+
return contributes(Capabilities.FileUploader, (space, file) => {
|
|
14
15
|
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
15
|
-
|
|
16
16
|
const program = Effect.gen(function* () {
|
|
17
|
-
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, {
|
|
18
|
-
yield* dispatch(
|
|
17
|
+
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { space, file }));
|
|
18
|
+
yield* dispatch(
|
|
19
|
+
Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })),
|
|
20
|
+
);
|
|
21
|
+
|
|
19
22
|
return fileInfo;
|
|
20
23
|
});
|
|
21
24
|
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
import { Obj } from '@dxos/echo';
|
|
7
6
|
|
|
8
7
|
import { upload } from '../helpers';
|
|
9
|
-
import {
|
|
8
|
+
import { WnfsAction, WnfsFile } from '../types';
|
|
10
9
|
|
|
11
10
|
import { WnfsCapabilities } from './capabilities';
|
|
12
11
|
|
|
@@ -18,7 +17,7 @@ export default (context: PluginContext) =>
|
|
|
18
17
|
intent: WnfsAction.Create,
|
|
19
18
|
resolve: ({ name, type, cid }) => ({
|
|
20
19
|
data: {
|
|
21
|
-
object:
|
|
20
|
+
object: WnfsFile.make({ name, type, cid }),
|
|
22
21
|
},
|
|
23
22
|
}),
|
|
24
23
|
}),
|
|
@@ -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
|
|
|
8
8
|
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
@@ -11,19 +11,19 @@ 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 {
|
|
15
|
-
import {
|
|
14
|
+
import { meta } from '../meta';
|
|
15
|
+
import { WnfsAction, WnfsFile } 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
|
-
filter: (data): data is { subject:
|
|
22
|
+
filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, 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>(
|
|
@@ -12,13 +12,13 @@ import { StackItem } from '@dxos/react-ui-stack';
|
|
|
12
12
|
|
|
13
13
|
import { WnfsCapabilities } from '../capabilities';
|
|
14
14
|
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
|
|
15
|
-
import { type
|
|
15
|
+
import { type WnfsFile } from '../types';
|
|
16
16
|
|
|
17
17
|
import { FilePreview } from './FilePreview';
|
|
18
18
|
|
|
19
19
|
export type FileContainerProps = {
|
|
20
20
|
role: string;
|
|
21
|
-
file:
|
|
21
|
+
file: WnfsFile.File;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const FileContainer = ({ file }: FileContainerProps) => {
|
|
@@ -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,6 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import type { Blockstore } from 'interface-blockstore';
|
|
9
7
|
import React, { type ChangeEvent, useEffect, useState } from 'react';
|
|
@@ -12,6 +10,7 @@ import { faker } from '@dxos/random';
|
|
|
12
10
|
import { useSpace } from '@dxos/react-client/echo';
|
|
13
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
12
|
import { useThemeContext } from '@dxos/react-ui';
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
14
|
import {
|
|
16
15
|
createBasicExtensions,
|
|
17
16
|
createMarkdownExtensions,
|
|
@@ -20,7 +19,6 @@ import {
|
|
|
20
19
|
processEditorPayload,
|
|
21
20
|
useTextEditor,
|
|
22
21
|
} from '@dxos/react-ui-editor';
|
|
23
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
24
22
|
|
|
25
23
|
import { create as createBlockstore } from '../blockstore';
|
|
26
24
|
import { upload } from '../helpers';
|
|
@@ -56,7 +54,7 @@ const DefaultStory = () => {
|
|
|
56
54
|
initialValue,
|
|
57
55
|
extensions: [
|
|
58
56
|
createBasicExtensions(),
|
|
59
|
-
createMarkdownExtensions(
|
|
57
|
+
createMarkdownExtensions(),
|
|
60
58
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
61
59
|
blockstore && space ? [image({ blockstore, instances, space })] : [],
|
|
62
60
|
decorateMarkdown(),
|
|
@@ -96,7 +94,7 @@ const DefaultStory = () => {
|
|
|
96
94
|
const meta = {
|
|
97
95
|
title: 'plugins/plugin-wnfs/image',
|
|
98
96
|
render: DefaultStory,
|
|
99
|
-
decorators: [withClientProvider({ createIdentity: true, createSpace: true })
|
|
97
|
+
decorators: [withTheme, withClientProvider({ createIdentity: true, createSpace: true })],
|
|
100
98
|
} satisfies Meta<typeof DefaultStory>;
|
|
101
99
|
|
|
102
100
|
export default meta;
|
package/src/extensions/image.tsx
CHANGED
|
@@ -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/meta.ts
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
export const WNFS_PLUGIN = 'dxos.org/plugin/wnfs';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
8
7
|
|
|
9
8
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
9
|
+
id: 'dxos.org/plugin/wnfs',
|
|
11
10
|
name: 'WNFS',
|
|
12
|
-
description:
|
|
11
|
+
description: trim`
|
|
12
|
+
Decentralized file storage using the Web Native File System protocol.
|
|
13
|
+
Store and sync files with end-to-end encryption across devices without central servers.
|
|
14
|
+
`,
|
|
13
15
|
icon: 'ph--file-cloud--regular',
|
|
16
|
+
iconHue: 'teal',
|
|
14
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs',
|
|
15
18
|
};
|
package/src/translations.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
7
|
import { meta } from './meta';
|
|
8
|
-
import {
|
|
8
|
+
import { WnfsFile } from './types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[
|
|
13
|
+
[WnfsFile.File.typename]: {
|
|
14
14
|
'typename label': 'File',
|
|
15
15
|
'object name placeholder': 'New file',
|
|
16
16
|
'rename object label': 'Rename file',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Obj, Type } from '@dxos/echo';
|
|
8
|
+
import { FormAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
|
|
10
|
+
export const File = Schema.Struct({
|
|
11
|
+
name: Schema.String.pipe(Schema.optional),
|
|
12
|
+
type: Schema.String.pipe(FormAnnotation.set(false)),
|
|
13
|
+
cid: Schema.String.pipe(FormAnnotation.set(false)),
|
|
14
|
+
timestamp: Schema.String.pipe(FormAnnotation.set(false), Schema.optional),
|
|
15
|
+
}).pipe(
|
|
16
|
+
Type.Obj({
|
|
17
|
+
typename: 'dxos.org/type/File',
|
|
18
|
+
version: '0.1.0',
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type File = Schema.Schema.Type<typeof File>;
|
|
23
|
+
|
|
24
|
+
export const make = (props: Obj.MakeProps<typeof File>) => Obj.make(File, props);
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { FileInfoSchema } from '@dxos/app-framework';
|
|
8
8
|
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../meta';
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import * as File from './File';
|
|
13
13
|
|
|
14
14
|
export namespace WnfsAction {
|
|
15
|
-
export class Create extends Schema.TaggedClass<Create>()(`${
|
|
15
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
16
16
|
input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),
|
|
17
17
|
output: Schema.Struct({
|
|
18
|
-
object:
|
|
18
|
+
object: File.File,
|
|
19
19
|
}),
|
|
20
20
|
}) {}
|
|
21
21
|
|
|
22
|
-
export const UploadAnnotationId = Symbol.for(`${
|
|
22
|
+
export const UploadAnnotationId = Symbol.for(`${meta.id}/annotation/upload`);
|
|
23
23
|
|
|
24
24
|
export const UploadFileSchema = Schema.Struct({
|
|
25
|
-
file: Schema.instanceOf(File).annotations({
|
|
25
|
+
file: Schema.instanceOf(File.File).annotations({
|
|
26
26
|
[UploadAnnotationId]: {
|
|
27
27
|
// Accept file types.
|
|
28
28
|
'image/*': ['.jpg', '.jpeg', '.png', '.gif'],
|
|
@@ -34,7 +34,7 @@ export namespace WnfsAction {
|
|
|
34
34
|
|
|
35
35
|
export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
36
36
|
|
|
37
|
-
export class Upload extends Schema.TaggedClass<Upload>()(`${
|
|
37
|
+
export class Upload extends Schema.TaggedClass<Upload>()(`${meta.id}/action/upload`, {
|
|
38
38
|
input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),
|
|
39
39
|
output: Schema.required(FileInfoSchema),
|
|
40
40
|
}) {}
|