@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0
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-D6VTEQIE.mjs → chunk-N6Y4QPNF.mjs} +23 -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 +92 -91
- 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 +4 -3
- 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 +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +3 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +4 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +3 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +16 -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/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.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 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +11 -11
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -50
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -36
- package/src/WnfsPlugin.tsx +53 -73
- package/src/blockstore.ts +1 -1
- package/src/capabilities/blockstore.ts +15 -11
- package/src/capabilities/file-uploader.ts +24 -17
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/markdown.ts +22 -14
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +40 -34
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +6 -6
- 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 +13 -15
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +8 -9
- package/src/extensions/image.tsx +4 -3
- package/src/helpers/load.ts +12 -7
- package/src/helpers/upload.ts +5 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +3 -3
- 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 -9
- package/src/types/File.ts +11 -7
- package/src/{capabilities → types}/capabilities.ts +4 -4
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +3 -20
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs +0 -103
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs.map +0 -7
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs +0 -191
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs.map +0 -7
- package/dist/lib/browser/chunk-CWMKN2F6.mjs +0 -71
- package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +0 -7
- package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
- package/dist/lib/browser/chunk-F4QHZWQD.mjs +0 -16
- package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGPGLJCV.mjs +0 -25
- package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs +0 -16
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs +0 -30
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs +0 -48
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +0 -7
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs +0 -198
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DMU47U3X.mjs +0 -88
- package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- 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/intent-resolver.ts +0 -32
- 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,22 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.74a063c4e0",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
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
|
+
},
|
|
10
22
|
"exports": {
|
|
11
23
|
".": {
|
|
12
24
|
"source": "./src/index.ts",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
25
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
26
|
+
"types": "./dist/types/src/index.d.ts"
|
|
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"
|
|
15
32
|
},
|
|
16
33
|
"./types": {
|
|
17
34
|
"source": "./src/types/index.ts",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
35
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
36
|
+
"types": "./dist/types/src/types/index.d.ts"
|
|
20
37
|
}
|
|
21
38
|
},
|
|
22
39
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -24,6 +41,9 @@
|
|
|
24
41
|
"*": {
|
|
25
42
|
"types": [
|
|
26
43
|
"dist/types/src/types/index.d.ts"
|
|
44
|
+
],
|
|
45
|
+
"operations": [
|
|
46
|
+
"dist/types/src/operations/index.d.ts"
|
|
27
47
|
]
|
|
28
48
|
}
|
|
29
49
|
},
|
|
@@ -36,11 +56,10 @@
|
|
|
36
56
|
"@codemirror/state": "^6.5.2",
|
|
37
57
|
"@codemirror/view": "^6.38.4",
|
|
38
58
|
"@ipld/car": "^5.3.3",
|
|
39
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
40
59
|
"blockstore-core": "^5.0.1",
|
|
41
60
|
"blockstore-idb": "^2.0.0",
|
|
42
61
|
"debounce": "^2.2.0",
|
|
43
|
-
"effect": "3.
|
|
62
|
+
"effect": "3.20.0",
|
|
44
63
|
"idb-keyval": "^6.2.1",
|
|
45
64
|
"interface-blockstore": "^5.2.10",
|
|
46
65
|
"it-all": "^3.0.6",
|
|
@@ -48,39 +67,43 @@
|
|
|
48
67
|
"react-dropzone": "^14.2.3",
|
|
49
68
|
"uint8arrays": "^5.1.0",
|
|
50
69
|
"wnfs": "0.2.2",
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/log": "0.8.4-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/plugin-
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/react-client": "0.8.4-main.
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/react-ui
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/react-ui-
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/react-ui-
|
|
70
|
+
"@dxos/crypto": "0.8.4-main.74a063c4e0",
|
|
71
|
+
"@dxos/app-toolkit": "0.8.4-main.74a063c4e0",
|
|
72
|
+
"@dxos/app-framework": "0.8.4-main.74a063c4e0",
|
|
73
|
+
"@dxos/echo": "0.8.4-main.74a063c4e0",
|
|
74
|
+
"@dxos/invariant": "0.8.4-main.74a063c4e0",
|
|
75
|
+
"@dxos/log": "0.8.4-main.74a063c4e0",
|
|
76
|
+
"@dxos/operation": "0.8.4-main.74a063c4e0",
|
|
77
|
+
"@dxos/plugin-client": "0.8.4-main.74a063c4e0",
|
|
78
|
+
"@dxos/effect": "0.8.4-main.74a063c4e0",
|
|
79
|
+
"@dxos/react-client": "0.8.4-main.74a063c4e0",
|
|
80
|
+
"@dxos/plugin-space": "0.8.4-main.74a063c4e0",
|
|
81
|
+
"@dxos/react-ui": "0.8.4-main.74a063c4e0",
|
|
82
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.74a063c4e0",
|
|
83
|
+
"@dxos/react-ui-editor": "0.8.4-main.74a063c4e0",
|
|
84
|
+
"@dxos/react-ui-form": "0.8.4-main.74a063c4e0",
|
|
85
|
+
"@dxos/react-ui-stack": "0.8.4-main.74a063c4e0",
|
|
86
|
+
"@dxos/ui-editor": "0.8.4-main.74a063c4e0",
|
|
87
|
+
"@dxos/schema": "0.8.4-main.74a063c4e0",
|
|
88
|
+
"@dxos/util": "0.8.4-main.74a063c4e0",
|
|
89
|
+
"@dxos/plugin-markdown": "0.8.4-main.74a063c4e0"
|
|
67
90
|
},
|
|
68
91
|
"devDependencies": {
|
|
69
|
-
"@types/react": "~19.2.
|
|
70
|
-
"@types/react-dom": "~19.2.
|
|
71
|
-
"react": "~19.2.
|
|
72
|
-
"react-dom": "~19.2.
|
|
73
|
-
"vite": "7.1.
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
92
|
+
"@types/react": "~19.2.7",
|
|
93
|
+
"@types/react-dom": "~19.2.3",
|
|
94
|
+
"react": "~19.2.3",
|
|
95
|
+
"react-dom": "~19.2.3",
|
|
96
|
+
"vite": "^7.1.11",
|
|
97
|
+
"@dxos/storybook-utils": "0.8.4-main.74a063c4e0",
|
|
98
|
+
"@dxos/ui-theme": "0.8.4-main.74a063c4e0",
|
|
99
|
+
"@dxos/random": "0.8.4-main.74a063c4e0"
|
|
77
100
|
},
|
|
78
101
|
"peerDependencies": {
|
|
79
|
-
"effect": "
|
|
80
|
-
"react": "
|
|
81
|
-
"react-dom": "
|
|
82
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
83
|
-
"@dxos/
|
|
102
|
+
"effect": "3.20.0",
|
|
103
|
+
"react": "~19.2.3",
|
|
104
|
+
"react-dom": "~19.2.3",
|
|
105
|
+
"@dxos/react-ui": "0.8.4-main.74a063c4e0",
|
|
106
|
+
"@dxos/ui-theme": "0.8.4-main.74a063c4e0"
|
|
84
107
|
},
|
|
85
108
|
"publishConfig": {
|
|
86
109
|
"access": "public"
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -2,94 +2,74 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createIntent,
|
|
13
|
-
defineModule,
|
|
14
|
-
definePlugin,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
16
|
-
import { ClientEvents } from '@dxos/plugin-client';
|
|
8
|
+
import { Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Annotation } from '@dxos/echo';
|
|
11
|
+
import { Operation } from '@dxos/operation';
|
|
12
|
+
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
17
13
|
import { MarkdownEvents } from '@dxos/plugin-markdown';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
14
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
15
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
16
|
+
|
|
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';
|
|
20
21
|
|
|
21
|
-
import { Blockstore, FileUploader, IntentResolver, Markdown, ReactSurface, WnfsCapabilities } from './capabilities';
|
|
22
|
-
import { meta } from './meta';
|
|
23
22
|
import { translations } from './translations';
|
|
24
|
-
import { WnfsAction, WnfsFile } from './types';
|
|
25
23
|
|
|
26
|
-
export const WnfsPlugin =
|
|
27
|
-
|
|
28
|
-
|
|
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 }),
|
|
50
|
+
Plugin.addModule({
|
|
51
|
+
id: 'blockstore',
|
|
29
52
|
activatesOn: ClientEvents.ClientReady,
|
|
30
53
|
activate: Blockstore,
|
|
31
54
|
}),
|
|
32
|
-
|
|
33
|
-
id:
|
|
55
|
+
Plugin.addModule({
|
|
56
|
+
id: 'instances',
|
|
34
57
|
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
58
|
activate: () =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
},
|
|
59
|
+
Effect.sync(() => {
|
|
60
|
+
const instances: WnfsCapabilities.Instances = {};
|
|
61
|
+
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
56
62
|
}),
|
|
57
63
|
}),
|
|
58
|
-
|
|
59
|
-
id:
|
|
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
|
-
),
|
|
72
|
-
}),
|
|
73
|
-
),
|
|
74
|
-
}),
|
|
75
|
-
defineModule({
|
|
76
|
-
id: `${meta.id}/module/file-uploader`,
|
|
64
|
+
Plugin.addModule({
|
|
65
|
+
id: 'file-uploader',
|
|
77
66
|
activatesOn: ClientEvents.ClientReady,
|
|
78
67
|
activate: FileUploader,
|
|
79
68
|
}),
|
|
80
|
-
|
|
81
|
-
id:
|
|
69
|
+
Plugin.addModule({
|
|
70
|
+
id: 'markdown',
|
|
82
71
|
activatesOn: MarkdownEvents.SetupExtensions,
|
|
83
72
|
activate: Markdown,
|
|
84
73
|
}),
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
]);
|
|
74
|
+
Plugin.make,
|
|
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()]);
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
7
6
|
|
|
8
|
-
import
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
9
|
+
|
|
10
|
+
import { WnfsCapabilities } from '#types';
|
|
9
11
|
|
|
10
|
-
import
|
|
12
|
+
import * as Blockstore from '../blockstore';
|
|
11
13
|
|
|
12
|
-
export default
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export default Capability.makeModule(
|
|
15
|
+
Effect.fnUntraced(function* () {
|
|
16
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
17
|
+
const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';
|
|
18
|
+
const blockstore = Blockstore.create(apiHost);
|
|
19
|
+
yield* Effect.tryPromise(() => blockstore.open());
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
}
|
|
21
|
+
return Capability.contributes(WnfsCapabilities.Blockstore, blockstore);
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
@@ -3,25 +3,32 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
-
import * as Function from 'effect/Function';
|
|
7
6
|
|
|
8
|
-
import { Capabilities,
|
|
9
|
-
import {
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
9
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
10
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
+
import { WnfsOperation } from '#operations';
|
|
12
13
|
|
|
13
|
-
export default (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
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
|
-
);
|
|
14
|
+
export default Capability.makeModule(
|
|
15
|
+
Effect.fnUntraced(function* () {
|
|
16
|
+
// Get context for lazy capability access in callbacks.
|
|
17
|
+
const capabilities = yield* Capability.Service;
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {
|
|
20
|
+
const { invoke } = capabilities.get(Capabilities.OperationInvoker);
|
|
21
|
+
const program = Effect.gen(function* () {
|
|
22
|
+
const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });
|
|
23
|
+
const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
|
|
24
|
+
if (createResult?.object) {
|
|
25
|
+
yield* invoke(SpaceOperation.AddObject, { target: db, object: createResult.object });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fileInfo;
|
|
29
|
+
});
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
31
|
+
return runAndForwardErrors(program);
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
7
|
|
|
7
|
-
export const Blockstore = lazy(() => import('./blockstore'));
|
|
8
|
-
export const FileUploader = lazy(() => import('./file-uploader'));
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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'));
|
|
@@ -2,25 +2,33 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
8
|
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
7
9
|
import { getSpace } from '@dxos/react-client/echo';
|
|
8
10
|
|
|
11
|
+
import { WnfsCapabilities } from '#types';
|
|
12
|
+
|
|
9
13
|
import { image } from '../extensions';
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
export default Capability.makeModule(
|
|
16
|
+
Effect.fnUntraced(function* () {
|
|
17
|
+
// Get context for lazy capability access in callbacks.
|
|
18
|
+
const capabilities = yield* Capability.Service;
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const instances = context.getCapability(WnfsCapabilities.Instances);
|
|
20
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
21
|
+
({ document }: { document?: any }) => {
|
|
22
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
23
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
if (document) {
|
|
26
|
+
const space = getSpace(document);
|
|
27
|
+
return space ? [image({ blockstore, instances, space })] : [];
|
|
28
|
+
}
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
return [];
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
@@ -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
|
+
);
|
|
@@ -2,44 +2,50 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import type * as Schema from 'effect/Schema';
|
|
6
7
|
import React, { useCallback } from 'react';
|
|
7
8
|
|
|
8
|
-
import { Capabilities,
|
|
9
|
-
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';
|
|
10
12
|
import { findAnnotation } from '@dxos/effect';
|
|
11
|
-
import { type
|
|
13
|
+
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
12
14
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { WnfsAction, WnfsFile } from '
|
|
15
|
+
import { FileInput } from '#components';
|
|
16
|
+
import { FileContainer } from '#containers';
|
|
17
|
+
import { WnfsAction, WnfsFile } from '#types';
|
|
16
18
|
|
|
17
|
-
export default () =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
export default Capability.makeModule(() =>
|
|
20
|
+
Effect.succeed(
|
|
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.
|
|
25
|
+
role: ['article', 'section', 'slide'],
|
|
26
|
+
filter: AppSurface.objectArticle(WnfsFile.File),
|
|
27
|
+
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
28
|
+
}),
|
|
29
|
+
Surface.create({
|
|
30
|
+
id: 'create-form',
|
|
31
|
+
role: 'form-input',
|
|
32
|
+
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
33
|
+
const annotation = findAnnotation<boolean>(
|
|
34
|
+
(data.schema as Schema.Schema.All).ast,
|
|
35
|
+
WnfsAction.UploadAnnotationId,
|
|
36
|
+
);
|
|
37
|
+
return !!annotation;
|
|
38
|
+
},
|
|
39
|
+
component: ({ data: { schema }, ...props }) => {
|
|
40
|
+
const inputProps = props as unknown as FormFieldComponentProps;
|
|
41
|
+
const handleChange = useCallback(
|
|
42
|
+
(file: File) => inputProps.onValueChange?.(inputProps.type, file),
|
|
43
|
+
[inputProps.type, inputProps.onValueChange],
|
|
44
|
+
);
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
return <FileInput schema={schema} onChange={handleChange} />;
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
]),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
@@ -8,10 +8,10 @@ import { useDropzone } from 'react-dropzone';
|
|
|
8
8
|
|
|
9
9
|
import { findAnnotation } from '@dxos/effect';
|
|
10
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { mx } from '@dxos/
|
|
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
|
+
);
|