@dxos/plugin-wnfs 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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/README.md +1 -1
- package/dist/lib/browser/chunk-4D4K5JCC.mjs +66 -0
- package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NCTUASHL.mjs → chunk-7KFJ6LYH.mjs} +36 -19
- package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs +71 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs +25 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs +42 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs.map +7 -0
- package/dist/lib/browser/helpers/index.mjs +26 -0
- package/dist/lib/browser/helpers/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -108
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +30 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -5
- package/dist/lib/browser/upload-ZQI66T4Y.mjs +35 -0
- package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +1 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
- package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
- package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blockstore.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 +6 -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/common.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/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.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 +24 -15
- 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/capabilities.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 +62 -37
- package/src/WnfsPlugin.node.ts +47 -0
- package/src/WnfsPlugin.test.ts +27 -0
- package/src/WnfsPlugin.tsx +40 -39
- 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.ts +38 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +60 -0
- 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/index.ts +8 -2
- 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/markdown/markdown.ts +0 -33
- 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/capabilities/react-surface/react-surface.tsx +0 -49
- 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.abd8ff62ef",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -11,26 +11,49 @@
|
|
|
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
|
+
"#plugin": {
|
|
21
|
+
"browser": "./src/WnfsPlugin.tsx",
|
|
22
|
+
"node": "./src/WnfsPlugin.node.ts",
|
|
23
|
+
"default": "./src/WnfsPlugin.tsx"
|
|
24
|
+
},
|
|
25
|
+
"#translations": "./src/translations.ts",
|
|
26
|
+
"#types": "./src/types/index.ts"
|
|
27
|
+
},
|
|
14
28
|
"exports": {
|
|
15
29
|
".": {
|
|
16
|
-
"browser": "./dist/lib/browser/index.mjs",
|
|
17
30
|
"source": "./src/index.ts",
|
|
31
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
18
32
|
"types": "./dist/types/src/index.d.ts"
|
|
19
33
|
},
|
|
34
|
+
"./helpers": {
|
|
35
|
+
"source": "./src/helpers/index.ts",
|
|
36
|
+
"browser": "./dist/lib/browser/helpers/index.mjs",
|
|
37
|
+
"types": "./dist/types/src/helpers/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./operations": {
|
|
40
|
+
"source": "./src/operations/index.ts",
|
|
41
|
+
"browser": "./dist/lib/browser/operations/index.mjs",
|
|
42
|
+
"types": "./dist/types/src/operations/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./translations": {
|
|
45
|
+
"source": "./src/translations.ts",
|
|
46
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
47
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
48
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
49
|
+
},
|
|
20
50
|
"./types": {
|
|
21
|
-
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
51
|
"source": "./src/types/index.ts",
|
|
52
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
23
53
|
"types": "./dist/types/src/types/index.d.ts"
|
|
24
54
|
}
|
|
25
55
|
},
|
|
26
56
|
"types": "dist/types/src/index.d.ts",
|
|
27
|
-
"typesVersions": {
|
|
28
|
-
"*": {
|
|
29
|
-
"types": [
|
|
30
|
-
"dist/types/src/types/index.d.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
57
|
"files": [
|
|
35
58
|
"dist",
|
|
36
59
|
"src"
|
|
@@ -43,7 +66,7 @@
|
|
|
43
66
|
"blockstore-core": "^5.0.1",
|
|
44
67
|
"blockstore-idb": "^2.0.0",
|
|
45
68
|
"debounce": "^2.2.0",
|
|
46
|
-
"effect": "3.
|
|
69
|
+
"effect": "3.20.0",
|
|
47
70
|
"idb-keyval": "^6.2.1",
|
|
48
71
|
"interface-blockstore": "^5.2.10",
|
|
49
72
|
"it-all": "^3.0.6",
|
|
@@ -51,42 +74,44 @@
|
|
|
51
74
|
"react-dropzone": "^14.2.3",
|
|
52
75
|
"uint8arrays": "^5.1.0",
|
|
53
76
|
"wnfs": "0.2.2",
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/plugin-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/plugin-markdown": "0.8.4-main.
|
|
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/react-ui-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/util": "0.8.4-main.
|
|
77
|
+
"@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
|
|
78
|
+
"@dxos/compute": "0.8.4-main.abd8ff62ef",
|
|
79
|
+
"@dxos/app-framework": "0.8.4-main.abd8ff62ef",
|
|
80
|
+
"@dxos/crypto": "0.8.4-main.abd8ff62ef",
|
|
81
|
+
"@dxos/echo": "0.8.4-main.abd8ff62ef",
|
|
82
|
+
"@dxos/invariant": "0.8.4-main.abd8ff62ef",
|
|
83
|
+
"@dxos/plugin-client": "0.8.4-main.abd8ff62ef",
|
|
84
|
+
"@dxos/plugin-space": "0.8.4-main.abd8ff62ef",
|
|
85
|
+
"@dxos/log": "0.8.4-main.abd8ff62ef",
|
|
86
|
+
"@dxos/plugin-markdown": "0.8.4-main.abd8ff62ef",
|
|
87
|
+
"@dxos/react-client": "0.8.4-main.abd8ff62ef",
|
|
88
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
89
|
+
"@dxos/react-ui-editor": "0.8.4-main.abd8ff62ef",
|
|
90
|
+
"@dxos/effect": "0.8.4-main.abd8ff62ef",
|
|
91
|
+
"@dxos/react-ui-form": "0.8.4-main.abd8ff62ef",
|
|
92
|
+
"@dxos/react-ui-stack": "0.8.4-main.abd8ff62ef",
|
|
93
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
|
|
94
|
+
"@dxos/schema": "0.8.4-main.abd8ff62ef",
|
|
95
|
+
"@dxos/util": "0.8.4-main.abd8ff62ef",
|
|
96
|
+
"@dxos/ui-editor": "0.8.4-main.abd8ff62ef"
|
|
73
97
|
},
|
|
74
98
|
"devDependencies": {
|
|
75
99
|
"@types/react": "~19.2.7",
|
|
76
100
|
"@types/react-dom": "~19.2.3",
|
|
77
101
|
"react": "~19.2.3",
|
|
78
102
|
"react-dom": "~19.2.3",
|
|
79
|
-
"vite": "
|
|
80
|
-
"@dxos/random": "0.8.4-main.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
103
|
+
"vite": "^8.0.10",
|
|
104
|
+
"@dxos/random": "0.8.4-main.abd8ff62ef",
|
|
105
|
+
"@dxos/plugin-testing": "0.8.4-main.abd8ff62ef",
|
|
106
|
+
"@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
|
|
107
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
83
108
|
},
|
|
84
109
|
"peerDependencies": {
|
|
85
|
-
"effect": "3.
|
|
110
|
+
"effect": "3.20.0",
|
|
86
111
|
"react": "~19.2.3",
|
|
87
112
|
"react-dom": "~19.2.3",
|
|
88
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
89
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
113
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
114
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
90
115
|
},
|
|
91
116
|
"publishConfig": {
|
|
92
117
|
"access": "public"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
|
|
8
|
+
import { Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Annotation } from '@dxos/echo';
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
13
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
14
|
+
|
|
15
|
+
import { OperationHandler } from '#capabilities';
|
|
16
|
+
import { meta } from '#meta';
|
|
17
|
+
import { WnfsOperation } from '#operations';
|
|
18
|
+
import { WnfsAction, WnfsFile } from '#types';
|
|
19
|
+
|
|
20
|
+
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
21
|
+
AppPlugin.addMetadataModule({
|
|
22
|
+
metadata: {
|
|
23
|
+
id: WnfsFile.File.typename,
|
|
24
|
+
metadata: {
|
|
25
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
26
|
+
icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,
|
|
27
|
+
iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',
|
|
28
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
29
|
+
createObject: ((props, options) =>
|
|
30
|
+
Effect.gen(function* () {
|
|
31
|
+
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });
|
|
32
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
33
|
+
object,
|
|
34
|
+
target: options.target,
|
|
35
|
+
hidden: true,
|
|
36
|
+
targetNodeId: options.targetNodeId,
|
|
37
|
+
});
|
|
38
|
+
})) satisfies CreateObject,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
43
|
+
AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
44
|
+
Plugin.make,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default WnfsPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
8
|
+
import { createComposerTestApp } from '@dxos/plugin-testing/harness';
|
|
9
|
+
|
|
10
|
+
import { WnfsPlugin } from '#plugin';
|
|
11
|
+
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
|
|
14
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
15
|
+
|
|
16
|
+
describe('WnfsPlugin', () => {
|
|
17
|
+
test('modules activate on the expected events', async ({ expect }) => {
|
|
18
|
+
await using harness = await createComposerTestApp({
|
|
19
|
+
plugins: [ClientPlugin({}), WnfsPlugin()],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// After autoStart: metadata, schema, and OperationHandler all auto-cascade.
|
|
23
|
+
expect(harness.manager.getActive()).toEqual(
|
|
24
|
+
expect.arrayContaining([moduleId('metadata'), moduleId('schema'), moduleId('OperationHandler')]),
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -3,20 +3,49 @@
|
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Annotation } from '@dxos/echo';
|
|
12
|
+
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
13
|
+
import { MarkdownEvents } from '@dxos/plugin-markdown/types';
|
|
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 '
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
17
|
+
import { Blockstore, FileUploader, Markdown, OperationHandler, ReactSurface } from '#capabilities';
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { WnfsOperation } from '#operations';
|
|
20
|
+
import { translations } from '#translations';
|
|
21
|
+
import { WnfsAction, WnfsCapabilities, WnfsFile } from '#types';
|
|
18
22
|
|
|
19
23
|
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
24
|
+
AppPlugin.addMetadataModule({
|
|
25
|
+
metadata: {
|
|
26
|
+
id: WnfsFile.File.typename,
|
|
27
|
+
metadata: {
|
|
28
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
29
|
+
icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,
|
|
30
|
+
iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',
|
|
31
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
32
|
+
createObject: ((props, options) =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });
|
|
35
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
36
|
+
object,
|
|
37
|
+
target: options.target,
|
|
38
|
+
hidden: true,
|
|
39
|
+
targetNodeId: options.targetNodeId,
|
|
40
|
+
});
|
|
41
|
+
})) satisfies CreateObject,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
46
|
+
AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
47
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
48
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
20
49
|
Plugin.addModule({
|
|
21
50
|
id: 'blockstore',
|
|
22
51
|
activatesOn: ClientEvents.ClientReady,
|
|
@@ -31,34 +60,6 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
31
60
|
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
32
61
|
}),
|
|
33
62
|
}),
|
|
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
63
|
Plugin.addModule({
|
|
63
64
|
id: 'file-uploader',
|
|
64
65
|
activatesOn: ClientEvents.ClientReady,
|
|
@@ -69,7 +70,7 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
69
70
|
activatesOn: MarkdownEvents.SetupExtensions,
|
|
70
71
|
activate: Markdown,
|
|
71
72
|
}),
|
|
72
|
-
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
73
|
-
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
74
73
|
Plugin.make,
|
|
75
74
|
);
|
|
75
|
+
|
|
76
|
+
export default WnfsPlugin;
|
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/compute';
|
|
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'));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { type MarkdownExtensionProvider, MarkdownCapabilities } from '@dxos/plugin-markdown/types';
|
|
9
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
+
|
|
11
|
+
import { WnfsCapabilities } from '#types';
|
|
12
|
+
|
|
13
|
+
import { image } from '../extensions';
|
|
14
|
+
|
|
15
|
+
export default Capability.makeModule(
|
|
16
|
+
Effect.fnUntraced(function* () {
|
|
17
|
+
// Get context for lazy capability access in callbacks.
|
|
18
|
+
const capabilities = yield* Capability.Service;
|
|
19
|
+
|
|
20
|
+
const provider: MarkdownExtensionProvider = ({ document, viewMode }) => {
|
|
21
|
+
if (viewMode === 'source') {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
26
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
27
|
+
|
|
28
|
+
if (document) {
|
|
29
|
+
const space = getSpace(document);
|
|
30
|
+
return space ? [image({ blockstore, instances, space })] : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [provider]);
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
@@ -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/compute';
|
|
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
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import type * as Schema from 'effect/Schema';
|
|
7
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
8
|
+
import React, { useCallback } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
11
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
12
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
13
|
+
import { findAnnotation } from '@dxos/effect';
|
|
14
|
+
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
15
|
+
|
|
16
|
+
import { FileInput } from '#components';
|
|
17
|
+
import { FileContainer } from '#containers';
|
|
18
|
+
import { WnfsAction, WnfsFile } from '#types';
|
|
19
|
+
|
|
20
|
+
export default Capability.makeModule(() =>
|
|
21
|
+
Effect.succeed(
|
|
22
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
23
|
+
Surface.create({
|
|
24
|
+
id: 'article',
|
|
25
|
+
// TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
|
|
26
|
+
filter: AppSurface.oneOf(
|
|
27
|
+
AppSurface.object(AppSurface.Article, WnfsFile.File),
|
|
28
|
+
AppSurface.object(AppSurface.Section, WnfsFile.File),
|
|
29
|
+
AppSurface.object(AppSurface.Slide, WnfsFile.File),
|
|
30
|
+
),
|
|
31
|
+
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
32
|
+
}),
|
|
33
|
+
Surface.create({
|
|
34
|
+
id: 'create-form',
|
|
35
|
+
role: 'form-input',
|
|
36
|
+
filter: (data): data is { prop: string; schema: Schema.Schema.Any; fieldPropertyAst?: SchemaAST.AST } => {
|
|
37
|
+
const annotation = findAnnotation<boolean>(
|
|
38
|
+
(data.schema as Schema.Schema.All).ast,
|
|
39
|
+
WnfsAction.UploadAnnotationId,
|
|
40
|
+
);
|
|
41
|
+
return !!annotation;
|
|
42
|
+
},
|
|
43
|
+
component: ({ data: { schema, fieldPropertyAst }, ...props }) => {
|
|
44
|
+
const ast = fieldPropertyAst;
|
|
45
|
+
if (!ast) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const inputProps = { ...props, type: ast } as unknown as FormFieldComponentProps;
|
|
50
|
+
const handleChange = useCallback(
|
|
51
|
+
(file: File) => inputProps.onValueChange?.(ast, file),
|
|
52
|
+
[ast, inputProps.onValueChange],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return <FileInput schema={schema} onChange={handleChange} />;
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
]),
|
|
59
|
+
),
|
|
60
|
+
);
|
|
@@ -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
|
|