@dxos/plugin-wnfs 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
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/chunk-BM3MEFES.mjs +69 -0
- package/dist/lib/browser/chunk-BM3MEFES.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NCTUASHL.mjs → chunk-N6Y4QPNF.mjs} +15 -32
- package/dist/lib/browser/chunk-N6Y4QPNF.mjs.map +7 -0
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs +69 -0
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs.map +7 -0
- package/dist/lib/browser/create-NOHKWE67.mjs +24 -0
- package/dist/lib/browser/create-NOHKWE67.mjs.map +7 -0
- package/dist/lib/browser/create-file-N7ADCFOF.mjs +49 -0
- package/dist/lib/browser/create-file-N7ADCFOF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/browser/upload-DA7GBOXF.mjs +42 -0
- package/dist/lib/browser/upload-DA7GBOXF.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader.d.ts +6 -0
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +13 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +1 -1
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -104
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -30
- package/src/WnfsPlugin.tsx +36 -36
- package/src/blockstore.ts +1 -1
- package/src/capabilities/{blockstore/blockstore.ts → blockstore.ts} +4 -3
- package/src/capabilities/{file-uploader/file-uploader.ts → file-uploader.ts} +6 -5
- package/src/capabilities/index.ts +11 -5
- package/src/capabilities/{markdown/markdown.ts → markdown.ts} +3 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +13 -11
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/{components → containers/FileContainer}/FileContainer.tsx +12 -11
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +9 -10
- package/src/extensions/image.tsx +2 -1
- package/src/helpers/load.ts +6 -6
- package/src/helpers/upload.ts +3 -3
- package/src/meta.ts +1 -1
- package/src/operations/create-file.ts +31 -0
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +41 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +29 -0
- package/src/translations.ts +13 -12
- package/src/types/File.ts +6 -2
- package/src/types/capabilities.ts +3 -3
- package/src/types/types.ts +3 -59
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +0 -91
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KKFOALUH.mjs +0 -191
- package/dist/lib/browser/blockstore-KKFOALUH.mjs.map +0 -7
- package/dist/lib/browser/chunk-GXXEH7H6.mjs +0 -154
- package/dist/lib/browser/chunk-GXXEH7H6.mjs.map +0 -7
- package/dist/lib/browser/chunk-NCTUASHL.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs +0 -34
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs.map +0 -7
- package/dist/lib/browser/markdown-BRT2MN6C.mjs +0 -201
- package/dist/lib/browser/markdown-BRT2MN6C.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs +0 -99
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs +0 -81
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs.map +0 -7
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +0 -5
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/blockstore/index.d.ts +0 -3
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +0 -5
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader/index.d.ts +0 -3
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -7
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/src/capabilities/blockstore/index.ts +0 -7
- package/src/capabilities/file-uploader/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -62
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/components/FilePreview.tsx +0 -23
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +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.9be5663bfe",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -11,15 +11,28 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
16
|
+
"#components": "./src/components/index.ts",
|
|
17
|
+
"#containers": "./src/containers/index.ts",
|
|
18
|
+
"#meta": "./src/meta.ts",
|
|
19
|
+
"#operations": "./src/operations/index.ts",
|
|
20
|
+
"#types": "./src/types/index.ts"
|
|
21
|
+
},
|
|
14
22
|
"exports": {
|
|
15
23
|
".": {
|
|
16
|
-
"browser": "./dist/lib/browser/index.mjs",
|
|
17
24
|
"source": "./src/index.ts",
|
|
25
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
18
26
|
"types": "./dist/types/src/index.d.ts"
|
|
19
27
|
},
|
|
28
|
+
"./operations": {
|
|
29
|
+
"source": "./src/operations/index.ts",
|
|
30
|
+
"browser": "./dist/lib/browser/operations/index.mjs",
|
|
31
|
+
"types": "./dist/types/src/operations/index.d.ts"
|
|
32
|
+
},
|
|
20
33
|
"./types": {
|
|
21
|
-
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
34
|
"source": "./src/types/index.ts",
|
|
35
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
23
36
|
"types": "./dist/types/src/types/index.d.ts"
|
|
24
37
|
}
|
|
25
38
|
},
|
|
@@ -28,6 +41,9 @@
|
|
|
28
41
|
"*": {
|
|
29
42
|
"types": [
|
|
30
43
|
"dist/types/src/types/index.d.ts"
|
|
44
|
+
],
|
|
45
|
+
"operations": [
|
|
46
|
+
"dist/types/src/operations/index.d.ts"
|
|
31
47
|
]
|
|
32
48
|
}
|
|
33
49
|
},
|
|
@@ -43,7 +59,7 @@
|
|
|
43
59
|
"blockstore-core": "^5.0.1",
|
|
44
60
|
"blockstore-idb": "^2.0.0",
|
|
45
61
|
"debounce": "^2.2.0",
|
|
46
|
-
"effect": "3.
|
|
62
|
+
"effect": "3.20.0",
|
|
47
63
|
"idb-keyval": "^6.2.1",
|
|
48
64
|
"interface-blockstore": "^5.2.10",
|
|
49
65
|
"it-all": "^3.0.6",
|
|
@@ -51,42 +67,43 @@
|
|
|
51
67
|
"react-dropzone": "^14.2.3",
|
|
52
68
|
"uint8arrays": "^5.1.0",
|
|
53
69
|
"wnfs": "0.2.2",
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/invariant": "0.8.4-main.
|
|
59
|
-
"@dxos/log": "0.8.4-main.
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/plugin-
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/react-client": "0.8.4-main.
|
|
65
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
66
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/react-ui-
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/ui-
|
|
72
|
-
"@dxos/util": "0.8.4-main.
|
|
70
|
+
"@dxos/app-toolkit": "0.8.4-main.9be5663bfe",
|
|
71
|
+
"@dxos/crypto": "0.8.4-main.9be5663bfe",
|
|
72
|
+
"@dxos/effect": "0.8.4-main.9be5663bfe",
|
|
73
|
+
"@dxos/echo": "0.8.4-main.9be5663bfe",
|
|
74
|
+
"@dxos/invariant": "0.8.4-main.9be5663bfe",
|
|
75
|
+
"@dxos/log": "0.8.4-main.9be5663bfe",
|
|
76
|
+
"@dxos/app-framework": "0.8.4-main.9be5663bfe",
|
|
77
|
+
"@dxos/operation": "0.8.4-main.9be5663bfe",
|
|
78
|
+
"@dxos/plugin-markdown": "0.8.4-main.9be5663bfe",
|
|
79
|
+
"@dxos/plugin-space": "0.8.4-main.9be5663bfe",
|
|
80
|
+
"@dxos/react-client": "0.8.4-main.9be5663bfe",
|
|
81
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe",
|
|
82
|
+
"@dxos/react-ui-editor": "0.8.4-main.9be5663bfe",
|
|
83
|
+
"@dxos/plugin-client": "0.8.4-main.9be5663bfe",
|
|
84
|
+
"@dxos/react-ui-form": "0.8.4-main.9be5663bfe",
|
|
85
|
+
"@dxos/schema": "0.8.4-main.9be5663bfe",
|
|
86
|
+
"@dxos/ui-editor": "0.8.4-main.9be5663bfe",
|
|
87
|
+
"@dxos/react-ui-stack": "0.8.4-main.9be5663bfe",
|
|
88
|
+
"@dxos/util": "0.8.4-main.9be5663bfe",
|
|
89
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.9be5663bfe"
|
|
73
90
|
},
|
|
74
91
|
"devDependencies": {
|
|
75
92
|
"@types/react": "~19.2.7",
|
|
76
93
|
"@types/react-dom": "~19.2.3",
|
|
77
94
|
"react": "~19.2.3",
|
|
78
95
|
"react-dom": "~19.2.3",
|
|
79
|
-
"vite": "7.1.
|
|
80
|
-
"@dxos/random": "0.8.4-main.
|
|
81
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
82
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
96
|
+
"vite": "^7.1.11",
|
|
97
|
+
"@dxos/random": "0.8.4-main.9be5663bfe",
|
|
98
|
+
"@dxos/storybook-utils": "0.8.4-main.9be5663bfe",
|
|
99
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe"
|
|
83
100
|
},
|
|
84
101
|
"peerDependencies": {
|
|
85
|
-
"effect": "3.
|
|
102
|
+
"effect": "3.20.0",
|
|
86
103
|
"react": "~19.2.3",
|
|
87
104
|
"react-dom": "~19.2.3",
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/ui
|
|
105
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe",
|
|
106
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe"
|
|
90
107
|
},
|
|
91
108
|
"publishConfig": {
|
|
92
109
|
"access": "public"
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -3,20 +3,50 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
6
7
|
|
|
7
|
-
import { Capability,
|
|
8
|
+
import { Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Annotation } from '@dxos/echo';
|
|
8
11
|
import { Operation } from '@dxos/operation';
|
|
9
|
-
import { ClientEvents } from '@dxos/plugin-client';
|
|
12
|
+
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
10
13
|
import { MarkdownEvents } from '@dxos/plugin-markdown';
|
|
11
|
-
import {
|
|
14
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
12
15
|
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
13
16
|
|
|
14
|
-
import { Blockstore, FileUploader, Markdown,
|
|
15
|
-
import { meta } from '
|
|
17
|
+
import { Blockstore, FileUploader, Markdown, OperationHandler, ReactSurface } from '#capabilities';
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { WnfsOperation } from '#operations';
|
|
20
|
+
import { WnfsAction, WnfsCapabilities, WnfsFile } from '#types';
|
|
21
|
+
|
|
16
22
|
import { translations } from './translations';
|
|
17
|
-
import { WnfsAction, WnfsCapabilities, WnfsFile, WnfsOperation } from './types';
|
|
18
23
|
|
|
19
24
|
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
25
|
+
AppPlugin.addMetadataModule({
|
|
26
|
+
metadata: {
|
|
27
|
+
id: WnfsFile.File.typename,
|
|
28
|
+
metadata: {
|
|
29
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
30
|
+
icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,
|
|
31
|
+
iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',
|
|
32
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
33
|
+
createObject: ((props, options) =>
|
|
34
|
+
Effect.gen(function* () {
|
|
35
|
+
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });
|
|
36
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
37
|
+
object,
|
|
38
|
+
target: options.target,
|
|
39
|
+
hidden: true,
|
|
40
|
+
targetNodeId: options.targetNodeId,
|
|
41
|
+
});
|
|
42
|
+
})) satisfies CreateObject,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
47
|
+
AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
48
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
49
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
20
50
|
Plugin.addModule({
|
|
21
51
|
id: 'blockstore',
|
|
22
52
|
activatesOn: ClientEvents.ClientReady,
|
|
@@ -31,34 +61,6 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
31
61
|
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
32
62
|
}),
|
|
33
63
|
}),
|
|
34
|
-
Common.Plugin.addTranslationsModule({ translations }),
|
|
35
|
-
Common.Plugin.addMetadataModule({
|
|
36
|
-
metadata: {
|
|
37
|
-
id: WnfsFile.File.typename,
|
|
38
|
-
metadata: {
|
|
39
|
-
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
40
|
-
icon: 'ph--file--regular',
|
|
41
|
-
iconHue: 'teal',
|
|
42
|
-
inputSchema: WnfsAction.UploadFileSchema,
|
|
43
|
-
createObject: ((props, { db }) =>
|
|
44
|
-
Effect.gen(function* () {
|
|
45
|
-
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db });
|
|
46
|
-
return object;
|
|
47
|
-
})) satisfies CreateObject,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
}),
|
|
51
|
-
Common.Plugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
52
|
-
Plugin.addModule({
|
|
53
|
-
id: 'on-space-created',
|
|
54
|
-
activatesOn: SpaceEvents.SpaceCreated,
|
|
55
|
-
activate: () =>
|
|
56
|
-
Effect.succeed(
|
|
57
|
-
Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) =>
|
|
58
|
-
Operation.invoke(WnfsOperation.OnCreateSpace, params),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
}),
|
|
62
64
|
Plugin.addModule({
|
|
63
65
|
id: 'file-uploader',
|
|
64
66
|
activatesOn: ClientEvents.ClientReady,
|
|
@@ -69,7 +71,5 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
69
71
|
activatesOn: MarkdownEvents.SetupExtensions,
|
|
70
72
|
activate: Markdown,
|
|
71
73
|
}),
|
|
72
|
-
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
73
|
-
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
74
74
|
Plugin.make,
|
|
75
75
|
);
|
package/src/blockstore.ts
CHANGED
|
@@ -145,7 +145,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
145
145
|
|
|
146
146
|
// QUEUE
|
|
147
147
|
|
|
148
|
-
readonly queueCacheName = `${storeName()}
|
|
148
|
+
readonly queueCacheName = `${storeName()}.state.queue`;
|
|
149
149
|
|
|
150
150
|
async #addToQueue(key: CID): Promise<void> {
|
|
151
151
|
await this.#saveQueue([...this.#queue, key.toString()]);
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
8
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
|
|
10
|
+
import { WnfsCapabilities } from '#types';
|
|
11
|
+
|
|
12
|
+
import * as Blockstore from '../blockstore';
|
|
12
13
|
|
|
13
14
|
export default Capability.makeModule(
|
|
14
15
|
Effect.fnUntraced(function* () {
|
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
9
|
-
import { SpaceOperation } from '@dxos/plugin-space/
|
|
10
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
10
11
|
|
|
11
|
-
import { WnfsOperation } from '
|
|
12
|
+
import { WnfsOperation } from '#operations';
|
|
12
13
|
|
|
13
14
|
export default Capability.makeModule(
|
|
14
15
|
Effect.fnUntraced(function* () {
|
|
15
16
|
// Get context for lazy capability access in callbacks.
|
|
16
17
|
const capabilities = yield* Capability.Service;
|
|
17
18
|
|
|
18
|
-
return Capability.contributes(
|
|
19
|
-
const { invoke } = capabilities.get(
|
|
19
|
+
return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {
|
|
20
|
+
const { invoke } = capabilities.get(Capabilities.OperationInvoker);
|
|
20
21
|
const program = Effect.gen(function* () {
|
|
21
22
|
const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });
|
|
22
23
|
const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
export const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));
|
|
9
|
+
export const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));
|
|
10
|
+
export const Markdown = Capability.lazy('Markdown', () => import('./markdown'));
|
|
11
|
+
export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
|
|
12
|
+
'OperationHandler',
|
|
13
|
+
() => import('./operation-handler'),
|
|
14
|
+
);
|
|
15
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -8,8 +8,9 @@ import { Capability } from '@dxos/app-framework';
|
|
|
8
8
|
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
9
9
|
import { getSpace } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import { WnfsCapabilities } from '#types';
|
|
12
|
+
|
|
13
|
+
import { image } from '../extensions';
|
|
13
14
|
|
|
14
15
|
export default Capability.makeModule(
|
|
15
16
|
Effect.fnUntraced(function* () {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import type { OperationHandlerSet } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { WnfsOperationHandlerSet } from '#operations';
|
|
11
|
+
|
|
12
|
+
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
13
|
+
Effect.fnUntraced(function* () {
|
|
14
|
+
return Capability.contributes(Capabilities.OperationHandler, WnfsOperationHandlerSet);
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
@@ -6,26 +6,28 @@ import * as Effect from 'effect/Effect';
|
|
|
6
6
|
import type * as Schema from 'effect/Schema';
|
|
7
7
|
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
10
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
11
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
12
|
import { findAnnotation } from '@dxos/effect';
|
|
12
13
|
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
13
14
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { WnfsAction, WnfsFile } from '
|
|
15
|
+
import { FileInput } from '#components';
|
|
16
|
+
import { FileContainer } from '#containers';
|
|
17
|
+
import { WnfsAction, WnfsFile } from '#types';
|
|
17
18
|
|
|
18
19
|
export default Capability.makeModule(() =>
|
|
19
20
|
Effect.succeed(
|
|
20
|
-
Capability.contributes(
|
|
21
|
-
|
|
22
|
-
id:
|
|
21
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
22
|
+
Surface.create({
|
|
23
|
+
id: 'article',
|
|
24
|
+
// TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
|
|
23
25
|
role: ['article', 'section', 'slide'],
|
|
24
|
-
filter:
|
|
26
|
+
filter: AppSurface.objectArticle(WnfsFile.File),
|
|
25
27
|
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
26
28
|
}),
|
|
27
|
-
|
|
28
|
-
id:
|
|
29
|
+
Surface.create({
|
|
30
|
+
id: 'create-form',
|
|
29
31
|
role: 'form-input',
|
|
30
32
|
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
31
33
|
const annotation = findAnnotation<boolean>(
|
|
@@ -10,8 +10,8 @@ import { findAnnotation } from '@dxos/effect';
|
|
|
10
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
import { meta } from '
|
|
14
|
-
import { WnfsAction } from '
|
|
13
|
+
import { meta } from '#meta';
|
|
14
|
+
import { WnfsAction } from '#types';
|
|
15
15
|
|
|
16
16
|
export type FileInputProps = {
|
|
17
17
|
schema: Schema.Schema.Any;
|
|
@@ -36,12 +36,12 @@ export const FileInput = ({ schema, onChange }: FileInputProps) => {
|
|
|
36
36
|
className={mx(
|
|
37
37
|
'flex flex-col items-center p-8 border border-separator',
|
|
38
38
|
isFocused && 'focus-ring',
|
|
39
|
-
isDragAccept && 'bg-attention',
|
|
40
|
-
isDragReject && 'border-
|
|
39
|
+
isDragAccept && 'bg-attention-surface',
|
|
40
|
+
isDragReject && 'border-rose-fill',
|
|
41
41
|
)}
|
|
42
42
|
>
|
|
43
43
|
<input {...getInputProps()} />
|
|
44
|
-
{acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file
|
|
44
|
+
{acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file-input.placeholder')}</p>}
|
|
45
45
|
</div>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { ForwardedRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
8
|
+
|
|
9
|
+
export type FilePreviewProps = { type: string; url: string };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* File/content preview iframe.
|
|
13
|
+
*/
|
|
14
|
+
export const FilePreview = composable<HTMLElement, FilePreviewProps>(
|
|
15
|
+
({ type, url, children, ...props }, forwardedRef) => {
|
|
16
|
+
if (type.startsWith('image/')) {
|
|
17
|
+
return (
|
|
18
|
+
<img
|
|
19
|
+
{...composableProps(props, { classNames: 'h-full w-full object-contain' })}
|
|
20
|
+
src={url}
|
|
21
|
+
ref={forwardedRef as ForwardedRef<HTMLImageElement>}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
} else if (type.startsWith('video/')) {
|
|
25
|
+
return (
|
|
26
|
+
<video
|
|
27
|
+
{...composableProps(props, { classNames: 'h-full w-full object-contain' })}
|
|
28
|
+
src={url}
|
|
29
|
+
controls
|
|
30
|
+
ref={forwardedRef as ForwardedRef<HTMLVideoElement>}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
} else {
|
|
34
|
+
return (
|
|
35
|
+
<iframe
|
|
36
|
+
{...composableProps(props, { classNames: 'h-full w-full overflow-auto' })}
|
|
37
|
+
src={url}
|
|
38
|
+
ref={forwardedRef as ForwardedRef<HTMLIFrameElement>}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -4,19 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
10
|
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
-
import { useAsyncEffect } from '@dxos/react-ui';
|
|
11
|
-
import { Layout } from '@dxos/react-ui-mosaic';
|
|
11
|
+
import { Panel, useAsyncEffect } from '@dxos/react-ui';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import { WnfsCapabilities } from '
|
|
15
|
-
import { type WnfsFile } from '../types';
|
|
13
|
+
import { FilePreview } from '#components';
|
|
14
|
+
import { WnfsCapabilities, type WnfsFile } from '#types';
|
|
16
15
|
|
|
17
|
-
import {
|
|
16
|
+
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../../helpers';
|
|
18
17
|
|
|
19
|
-
export type FileContainerProps =
|
|
18
|
+
export type FileContainerProps = AppSurface.ObjectArticleProps<WnfsFile.File>;
|
|
20
19
|
|
|
21
20
|
export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
|
|
22
21
|
const blockstore = useCapability(WnfsCapabilities.Blockstore);
|
|
@@ -47,9 +46,11 @@ export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
return (
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
49
|
+
<Panel.Root role={role} className='dx-document'>
|
|
50
|
+
<Panel.Content asChild>
|
|
51
|
+
<FilePreview type={file.type} url={blobUrl} />
|
|
52
|
+
</Panel.Content>
|
|
53
|
+
</Panel.Root>
|
|
53
54
|
);
|
|
54
55
|
};
|
|
55
56
|
|
|
@@ -6,12 +6,12 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import type { Blockstore } from 'interface-blockstore';
|
|
7
7
|
import React, { type ChangeEvent, useEffect, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { random } from '@dxos/random';
|
|
10
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
11
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
12
|
import { useThemeContext } from '@dxos/react-ui';
|
|
13
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
13
|
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
15
|
import {
|
|
16
16
|
createBasicExtensions,
|
|
17
17
|
createMarkdownExtensions,
|
|
@@ -22,16 +22,15 @@ import {
|
|
|
22
22
|
|
|
23
23
|
import { create as createBlockstore } from '../blockstore';
|
|
24
24
|
import { upload } from '../helpers';
|
|
25
|
-
|
|
26
25
|
import { image } from './image';
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
const initialValue =
|
|
27
|
+
random.seed(1);
|
|
28
|
+
const initialValue = random.lorem.paragraphs(100);
|
|
30
29
|
const instances = {};
|
|
31
30
|
|
|
32
31
|
const DefaultStory = () => {
|
|
33
32
|
const { themeMode } = useThemeContext();
|
|
34
|
-
const space =
|
|
33
|
+
const [space] = useSpaces();
|
|
35
34
|
const [blockstore, setBlockstore] = useState<Blockstore>();
|
|
36
35
|
|
|
37
36
|
useEffect(() => {
|
|
@@ -86,15 +85,15 @@ const DefaultStory = () => {
|
|
|
86
85
|
<div className='mb-2'>
|
|
87
86
|
<input type='file' accept='image/*' onChange={onFileChange} />
|
|
88
87
|
</div>
|
|
89
|
-
<div className='
|
|
88
|
+
<div className='w-[50rem]' ref={parentRef} {...focusAttributes} />
|
|
90
89
|
</>
|
|
91
90
|
);
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
const meta = {
|
|
95
|
-
title: 'plugins/plugin-wnfs/image',
|
|
94
|
+
title: 'plugins/plugin-wnfs/extensions/image',
|
|
96
95
|
render: DefaultStory,
|
|
97
|
-
decorators: [withTheme, withClientProvider({ createIdentity: true, createSpace: true })],
|
|
96
|
+
decorators: [withTheme(), withClientProvider({ createIdentity: true, createSpace: true })],
|
|
98
97
|
} satisfies Meta<typeof DefaultStory>;
|
|
99
98
|
|
|
100
99
|
export default meta;
|
package/src/extensions/image.tsx
CHANGED
|
@@ -15,8 +15,9 @@ import { focusField } from '@dxos/ui-editor';
|
|
|
15
15
|
import { defaultTx } from '@dxos/ui-theme';
|
|
16
16
|
import { type MaybePromise } from '@dxos/util';
|
|
17
17
|
|
|
18
|
+
import { type WnfsCapabilities } from '#types';
|
|
19
|
+
|
|
18
20
|
import { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';
|
|
19
|
-
import { type WnfsCapabilities } from '../types';
|
|
20
21
|
|
|
21
22
|
const WAIT_UNTIL_LOADER = 1500;
|
|
22
23
|
|
package/src/helpers/load.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from 'wnfs';
|
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
11
|
import { type Space } from '@dxos/react-client/echo';
|
|
12
12
|
|
|
13
|
-
import { type WnfsCapabilities } from '
|
|
13
|
+
import { type WnfsCapabilities } from '#types';
|
|
14
14
|
|
|
15
15
|
import { Rng, store } from './common';
|
|
16
16
|
|
|
@@ -30,9 +30,9 @@ export const loadWnfs = async ({
|
|
|
30
30
|
// TODO(wittjosiah): Remove.
|
|
31
31
|
// Delete old properties if they exist.
|
|
32
32
|
if (space.properties.wnfs_access_key !== undefined && space.properties.wnfs_private_forest_cid !== undefined) {
|
|
33
|
-
Obj.change(space.properties, (
|
|
34
|
-
delete
|
|
35
|
-
delete
|
|
33
|
+
Obj.change(space.properties, (obj) => {
|
|
34
|
+
delete obj['wnfs_access_key'];
|
|
35
|
+
delete obj['wnfs_private_forest_cid'];
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -68,8 +68,8 @@ const createWnfsDir = async (blockstore: Blockstore, space: Space) => {
|
|
|
68
68
|
|
|
69
69
|
const cidBytes = await newForest.store(wnfsStore);
|
|
70
70
|
|
|
71
|
-
Obj.change(space.properties, (
|
|
72
|
-
|
|
71
|
+
Obj.change(space.properties, (obj) => {
|
|
72
|
+
obj.wnfs = {
|
|
73
73
|
accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),
|
|
74
74
|
privateForestCid: CID.decode(cidBytes).toString(),
|
|
75
75
|
};
|
package/src/helpers/upload.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Space } from '@dxos/client/echo';
|
|
|
11
11
|
import { Obj } from '@dxos/echo';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
|
|
14
|
-
import { type WnfsCapabilities } from '
|
|
14
|
+
import { type WnfsCapabilities } from '#types';
|
|
15
15
|
|
|
16
16
|
import { Rng, filePath, store } from './common';
|
|
17
17
|
import { loadWnfs } from './load';
|
|
@@ -47,8 +47,8 @@ export const upload = async ({
|
|
|
47
47
|
const cidBytes = await updatedForest.store(wnfsStore);
|
|
48
48
|
|
|
49
49
|
// Update the forest pointer on the associated space.
|
|
50
|
-
Obj.change(space.properties, (
|
|
51
|
-
|
|
50
|
+
Obj.change(space.properties, (obj) => {
|
|
51
|
+
obj.wnfs.privateForestCid = CID.decode(cidBytes).toString();
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
// Generate `wnfs://` URL & return the info.
|