@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.937b3ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +91 -0
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-2JFU4NBU.mjs → blockstore-KKFOALUH.mjs} +12 -12
- package/dist/lib/browser/blockstore-KKFOALUH.mjs.map +7 -0
- package/dist/lib/browser/chunk-GXXEH7H6.mjs +154 -0
- package/dist/lib/browser/chunk-GXXEH7H6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D6VTEQIE.mjs → chunk-NCTUASHL.mjs} +17 -9
- package/dist/lib/browser/chunk-NCTUASHL.mjs.map +7 -0
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs +34 -0
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +83 -83
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{markdown-WYQDCVFQ.mjs → markdown-BRT2MN6C.mjs} +28 -25
- package/dist/lib/browser/markdown-BRT2MN6C.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs +99 -0
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs.map +7 -0
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs +81 -0
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- 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/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +5 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/FileContainer.d.ts +3 -5
- package/dist/types/src/components/FileContainer.d.ts.map +1 -1
- 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/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.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/translations.d.ts +4 -1
- 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 +106 -49
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -35
- package/src/WnfsPlugin.tsx +48 -68
- package/src/capabilities/blockstore/blockstore.ts +22 -0
- package/src/capabilities/blockstore/index.ts +7 -0
- package/src/capabilities/file-uploader/file-uploader.ts +33 -0
- package/src/capabilities/file-uploader/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +33 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +62 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +49 -0
- package/src/components/FileContainer.tsx +7 -10
- package/src/components/FileInput.tsx +1 -1
- package/src/components/FilePreview.tsx +1 -1
- package/src/extensions/image.stories.tsx +2 -2
- package/src/extensions/image.tsx +3 -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 +2 -2
- package/src/translations.ts +4 -1
- package/src/types/File.ts +5 -5
- package/src/{capabilities → types}/capabilities.ts +3 -3
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +51 -12
- 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.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.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/blockstore.d.ts +0 -4
- package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
- package/dist/types/src/capabilities/file-uploader.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/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/src/capabilities/blockstore.ts +0 -19
- package/src/capabilities/file-uploader.ts +0 -27
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/capabilities/markdown.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -45
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.937b3ca",
|
|
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",
|
|
10
14
|
"exports": {
|
|
11
15
|
".": {
|
|
16
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
12
17
|
"source": "./src/index.ts",
|
|
13
|
-
"types": "./dist/types/src/index.d.ts"
|
|
14
|
-
"browser": "./dist/lib/browser/index.mjs"
|
|
18
|
+
"types": "./dist/types/src/index.d.ts"
|
|
15
19
|
},
|
|
16
20
|
"./types": {
|
|
21
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
17
22
|
"source": "./src/types/index.ts",
|
|
18
|
-
"types": "./dist/types/src/types/index.d.ts"
|
|
19
|
-
"browser": "./dist/lib/browser/types/index.mjs"
|
|
23
|
+
"types": "./dist/types/src/types/index.d.ts"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -36,11 +40,10 @@
|
|
|
36
40
|
"@codemirror/state": "^6.5.2",
|
|
37
41
|
"@codemirror/view": "^6.38.4",
|
|
38
42
|
"@ipld/car": "^5.3.3",
|
|
39
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
40
43
|
"blockstore-core": "^5.0.1",
|
|
41
44
|
"blockstore-idb": "^2.0.0",
|
|
42
45
|
"debounce": "^2.2.0",
|
|
43
|
-
"effect": "3.
|
|
46
|
+
"effect": "3.19.11",
|
|
44
47
|
"idb-keyval": "^6.2.1",
|
|
45
48
|
"interface-blockstore": "^5.2.10",
|
|
46
49
|
"it-all": "^3.0.6",
|
|
@@ -48,39 +51,42 @@
|
|
|
48
51
|
"react-dropzone": "^14.2.3",
|
|
49
52
|
"uint8arrays": "^5.1.0",
|
|
50
53
|
"wnfs": "0.2.2",
|
|
51
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
52
|
-
"@dxos/crypto": "0.8.4-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/log": "0.8.4-main.
|
|
57
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/plugin-
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/react-
|
|
62
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/react-ui
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/react-ui-
|
|
54
|
+
"@dxos/app-framework": "0.8.4-main.937b3ca",
|
|
55
|
+
"@dxos/crypto": "0.8.4-main.937b3ca",
|
|
56
|
+
"@dxos/effect": "0.8.4-main.937b3ca",
|
|
57
|
+
"@dxos/echo": "0.8.4-main.937b3ca",
|
|
58
|
+
"@dxos/invariant": "0.8.4-main.937b3ca",
|
|
59
|
+
"@dxos/log": "0.8.4-main.937b3ca",
|
|
60
|
+
"@dxos/plugin-client": "0.8.4-main.937b3ca",
|
|
61
|
+
"@dxos/operation": "0.8.4-main.937b3ca",
|
|
62
|
+
"@dxos/plugin-markdown": "0.8.4-main.937b3ca",
|
|
63
|
+
"@dxos/plugin-space": "0.8.4-main.937b3ca",
|
|
64
|
+
"@dxos/react-client": "0.8.4-main.937b3ca",
|
|
65
|
+
"@dxos/react-ui-editor": "0.8.4-main.937b3ca",
|
|
66
|
+
"@dxos/react-ui-form": "0.8.4-main.937b3ca",
|
|
67
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca",
|
|
68
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.937b3ca",
|
|
69
|
+
"@dxos/react-ui-stack": "0.8.4-main.937b3ca",
|
|
70
|
+
"@dxos/schema": "0.8.4-main.937b3ca",
|
|
71
|
+
"@dxos/util": "0.8.4-main.937b3ca",
|
|
72
|
+
"@dxos/ui-editor": "0.8.4-main.937b3ca"
|
|
67
73
|
},
|
|
68
74
|
"devDependencies": {
|
|
69
|
-
"@types/react": "~19.2.
|
|
70
|
-
"@types/react-dom": "~19.2.
|
|
71
|
-
"react": "~19.2.
|
|
72
|
-
"react-dom": "~19.2.
|
|
75
|
+
"@types/react": "~19.2.7",
|
|
76
|
+
"@types/react-dom": "~19.2.3",
|
|
77
|
+
"react": "~19.2.3",
|
|
78
|
+
"react-dom": "~19.2.3",
|
|
73
79
|
"vite": "7.1.9",
|
|
74
|
-
"@dxos/random": "0.8.4-main.
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
80
|
+
"@dxos/random": "0.8.4-main.937b3ca",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.937b3ca",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca"
|
|
77
83
|
},
|
|
78
84
|
"peerDependencies": {
|
|
79
|
-
"effect": "
|
|
80
|
-
"react": "
|
|
81
|
-
"react-dom": "
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/react-ui
|
|
85
|
+
"effect": "3.19.11",
|
|
86
|
+
"react": "~19.2.3",
|
|
87
|
+
"react-dom": "~19.2.3",
|
|
88
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca",
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca"
|
|
84
90
|
},
|
|
85
91
|
"publishConfig": {
|
|
86
92
|
"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
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
Events,
|
|
10
|
-
chain,
|
|
11
|
-
contributes,
|
|
12
|
-
createIntent,
|
|
13
|
-
defineModule,
|
|
14
|
-
definePlugin,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
7
|
+
import { Capability, Common, Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
16
9
|
import { ClientEvents } from '@dxos/plugin-client';
|
|
17
10
|
import { MarkdownEvents } from '@dxos/plugin-markdown';
|
|
18
|
-
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
19
|
-
import {
|
|
11
|
+
import { SpaceCapabilities, SpaceEvents } from '@dxos/plugin-space';
|
|
12
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
20
13
|
|
|
21
|
-
import { Blockstore, FileUploader,
|
|
14
|
+
import { Blockstore, FileUploader, Markdown, OperationResolver, ReactSurface } from './capabilities';
|
|
22
15
|
import { meta } from './meta';
|
|
23
16
|
import { translations } from './translations';
|
|
24
|
-
import { WnfsAction, WnfsFile } from './types';
|
|
17
|
+
import { WnfsAction, WnfsCapabilities, WnfsFile, WnfsOperation } from './types';
|
|
25
18
|
|
|
26
|
-
export const WnfsPlugin =
|
|
27
|
-
|
|
28
|
-
id:
|
|
19
|
+
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
id: 'blockstore',
|
|
29
22
|
activatesOn: ClientEvents.ClientReady,
|
|
30
23
|
activate: Blockstore,
|
|
31
24
|
}),
|
|
32
|
-
|
|
33
|
-
id:
|
|
25
|
+
Plugin.addModule({
|
|
26
|
+
id: 'instances',
|
|
34
27
|
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
28
|
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
|
-
},
|
|
29
|
+
Effect.sync(() => {
|
|
30
|
+
const instances: WnfsCapabilities.Instances = {};
|
|
31
|
+
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
56
32
|
}),
|
|
57
33
|
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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,
|
|
61
55
|
activate: () =>
|
|
62
|
-
|
|
63
|
-
SpaceCapabilities.
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
}),
|
|
56
|
+
Effect.succeed(
|
|
57
|
+
Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) =>
|
|
58
|
+
Operation.invoke(WnfsOperation.OnCreateSpace, params),
|
|
59
|
+
),
|
|
73
60
|
),
|
|
74
61
|
}),
|
|
75
|
-
|
|
76
|
-
id:
|
|
62
|
+
Plugin.addModule({
|
|
63
|
+
id: 'file-uploader',
|
|
77
64
|
activatesOn: ClientEvents.ClientReady,
|
|
78
65
|
activate: FileUploader,
|
|
79
66
|
}),
|
|
80
|
-
|
|
81
|
-
id:
|
|
67
|
+
Plugin.addModule({
|
|
68
|
+
id: 'markdown',
|
|
82
69
|
activatesOn: MarkdownEvents.SetupExtensions,
|
|
83
70
|
activate: Markdown,
|
|
84
71
|
}),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}),
|
|
90
|
-
defineModule({
|
|
91
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
92
|
-
activatesOn: Events.SetupIntentResolver,
|
|
93
|
-
activate: IntentResolver,
|
|
94
|
-
}),
|
|
95
|
-
]);
|
|
72
|
+
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
73
|
+
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
74
|
+
Plugin.make,
|
|
75
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { ClientCapabilities } from '@dxos/plugin-client';
|
|
9
|
+
|
|
10
|
+
import * as Blockstore from '../../blockstore';
|
|
11
|
+
import { WnfsCapabilities } from '../../types';
|
|
12
|
+
|
|
13
|
+
export default Capability.makeModule(
|
|
14
|
+
Effect.fnUntraced(function* () {
|
|
15
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
16
|
+
const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';
|
|
17
|
+
const blockstore = Blockstore.create(apiHost);
|
|
18
|
+
yield* Effect.tryPromise(() => blockstore.open());
|
|
19
|
+
|
|
20
|
+
return Capability.contributes(WnfsCapabilities.Blockstore, blockstore);
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
8
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
9
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
10
|
+
|
|
11
|
+
import { WnfsOperation } from '../../types';
|
|
12
|
+
|
|
13
|
+
export default Capability.makeModule(
|
|
14
|
+
Effect.fnUntraced(function* () {
|
|
15
|
+
// Get context for lazy capability access in callbacks.
|
|
16
|
+
const capabilities = yield* Capability.Service;
|
|
17
|
+
|
|
18
|
+
return Capability.contributes(Common.Capability.FileUploader, (db, file) => {
|
|
19
|
+
const { invoke } = capabilities.get(Common.Capability.OperationInvoker);
|
|
20
|
+
const program = Effect.gen(function* () {
|
|
21
|
+
const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });
|
|
22
|
+
const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
|
|
23
|
+
if (createResult?.object) {
|
|
24
|
+
yield* invoke(SpaceOperation.AddObject, { target: db, object: createResult.object });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return fileInfo;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return runAndForwardErrors(program);
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export const Markdown = lazy(() => import('./markdown'));
|
|
11
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
12
|
-
|
|
13
|
-
export * from './capabilities';
|
|
5
|
+
export * from './blockstore';
|
|
6
|
+
export * from './file-uploader';
|
|
7
|
+
export * from './markdown';
|
|
8
|
+
export * from './operation-resolver';
|
|
9
|
+
export * from './react-surface';
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
9
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
+
|
|
11
|
+
import { image } from '../../extensions';
|
|
12
|
+
import { WnfsCapabilities } from '../../types';
|
|
13
|
+
|
|
14
|
+
export default Capability.makeModule(
|
|
15
|
+
Effect.fnUntraced(function* () {
|
|
16
|
+
// Get context for lazy capability access in callbacks.
|
|
17
|
+
const capabilities = yield* Capability.Service;
|
|
18
|
+
|
|
19
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
20
|
+
({ document }: { document?: any }) => {
|
|
21
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
22
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
23
|
+
|
|
24
|
+
if (document) {
|
|
25
|
+
const space = getSpace(document);
|
|
26
|
+
return space ? [image({ blockstore, instances, space })] : [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return [];
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
8
|
+
import { Obj, Ref, Type } from '@dxos/echo';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { OperationResolver } from '@dxos/operation';
|
|
11
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
+
import { Collection } from '@dxos/schema';
|
|
13
|
+
|
|
14
|
+
import { upload } from '../../helpers';
|
|
15
|
+
import { WnfsCapabilities, WnfsFile, WnfsOperation } from '../../types';
|
|
16
|
+
|
|
17
|
+
export default Capability.makeModule(
|
|
18
|
+
Effect.fnUntraced(function* () {
|
|
19
|
+
return Capability.contributes(Common.Capability.OperationResolver, [
|
|
20
|
+
OperationResolver.make({
|
|
21
|
+
operation: WnfsOperation.OnCreateSpace,
|
|
22
|
+
handler: Effect.fnUntraced(function* ({ rootCollection }) {
|
|
23
|
+
const collection = Collection.makeManaged({ key: Type.getTypename(WnfsFile.File) });
|
|
24
|
+
Obj.change(rootCollection, (c) => {
|
|
25
|
+
c.objects.push(Ref.make(collection));
|
|
26
|
+
});
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
OperationResolver.make({
|
|
30
|
+
operation: WnfsOperation.Create,
|
|
31
|
+
handler: ({ name, type, cid }) =>
|
|
32
|
+
Effect.succeed({
|
|
33
|
+
object: WnfsFile.make({ name, type, cid }),
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
OperationResolver.make({
|
|
37
|
+
operation: WnfsOperation.Upload,
|
|
38
|
+
handler: Effect.fnUntraced(function* ({ file, db }) {
|
|
39
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
40
|
+
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
41
|
+
const space = client.spaces.get(db.spaceId);
|
|
42
|
+
invariant(space, 'Space not found');
|
|
43
|
+
const info = yield* Effect.promise(() => upload({ file, blockstore, space }));
|
|
44
|
+
return info;
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
OperationResolver.make({
|
|
48
|
+
operation: WnfsOperation.CreateFile,
|
|
49
|
+
handler: Effect.fnUntraced(function* ({ file, db }) {
|
|
50
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
51
|
+
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
52
|
+
const space = client.spaces.get(db.spaceId);
|
|
53
|
+
invariant(space, 'Space not found');
|
|
54
|
+
const info = yield* Effect.promise(() => upload({ file, blockstore, space }));
|
|
55
|
+
return {
|
|
56
|
+
object: WnfsFile.make({ name: info.name, type: info.type, cid: info.cid }),
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
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 React, { useCallback } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { findAnnotation } from '@dxos/effect';
|
|
12
|
+
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
13
|
+
|
|
14
|
+
import { FileContainer, FileInput } from '../../components';
|
|
15
|
+
import { meta } from '../../meta';
|
|
16
|
+
import { WnfsAction, WnfsFile } from '../../types';
|
|
17
|
+
|
|
18
|
+
export default Capability.makeModule(() =>
|
|
19
|
+
Effect.succeed(
|
|
20
|
+
Capability.contributes(Common.Capability.ReactSurface, [
|
|
21
|
+
Common.createSurface({
|
|
22
|
+
id: `${meta.id}/article`,
|
|
23
|
+
role: ['article', 'section', 'slide'],
|
|
24
|
+
filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),
|
|
25
|
+
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
26
|
+
}),
|
|
27
|
+
Common.createSurface({
|
|
28
|
+
id: `${meta.id}/create-form`,
|
|
29
|
+
role: 'form-input',
|
|
30
|
+
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
31
|
+
const annotation = findAnnotation<boolean>(
|
|
32
|
+
(data.schema as Schema.Schema.All).ast,
|
|
33
|
+
WnfsAction.UploadAnnotationId,
|
|
34
|
+
);
|
|
35
|
+
return !!annotation;
|
|
36
|
+
},
|
|
37
|
+
component: ({ data: { schema }, ...props }) => {
|
|
38
|
+
const inputProps = props as unknown as FormFieldComponentProps;
|
|
39
|
+
const handleChange = useCallback(
|
|
40
|
+
(file: File) => inputProps.onValueChange?.(inputProps.type, file),
|
|
41
|
+
[inputProps.type, inputProps.onValueChange],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return <FileInput schema={schema} onChange={handleChange} />;
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
]),
|
|
48
|
+
),
|
|
49
|
+
);
|
|
@@ -4,24 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useCapability } from '@dxos/app-framework/react';
|
|
7
|
+
import { type SurfaceComponentProps, useCapability } from '@dxos/app-framework/react';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { getSpace } from '@dxos/react-client/echo';
|
|
10
10
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
11
|
-
import {
|
|
11
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
12
12
|
|
|
13
|
-
import { WnfsCapabilities } from '../capabilities';
|
|
14
13
|
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
|
|
14
|
+
import { WnfsCapabilities } from '../types';
|
|
15
15
|
import { type WnfsFile } from '../types';
|
|
16
16
|
|
|
17
17
|
import { FilePreview } from './FilePreview';
|
|
18
18
|
|
|
19
|
-
export type FileContainerProps =
|
|
20
|
-
role: string;
|
|
21
|
-
file: WnfsFile.File;
|
|
22
|
-
};
|
|
19
|
+
export type FileContainerProps = SurfaceComponentProps<WnfsFile.File>;
|
|
23
20
|
|
|
24
|
-
export const FileContainer = ({ file }: FileContainerProps) => {
|
|
21
|
+
export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
|
|
25
22
|
const blockstore = useCapability(WnfsCapabilities.Blockstore);
|
|
26
23
|
const instances = useCapability(WnfsCapabilities.Instances);
|
|
27
24
|
const [blobUrl, setBlobUrl] = useState<string>();
|
|
@@ -50,9 +47,9 @@ export const FileContainer = ({ file }: FileContainerProps) => {
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
return (
|
|
53
|
-
<
|
|
50
|
+
<Layout.Main role={role}>
|
|
54
51
|
<FilePreview type={file.type} url={blobUrl} />
|
|
55
|
-
</
|
|
52
|
+
</Layout.Main>
|
|
56
53
|
);
|
|
57
54
|
};
|
|
58
55
|
|
|
@@ -8,7 +8,7 @@ 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
13
|
import { meta } from '../meta';
|
|
14
14
|
import { WnfsAction } from '../types';
|
|
@@ -11,14 +11,14 @@ import { useSpace } from '@dxos/react-client/echo';
|
|
|
11
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
12
|
import { useThemeContext } from '@dxos/react-ui';
|
|
13
13
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
|
+
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
14
15
|
import {
|
|
15
16
|
createBasicExtensions,
|
|
16
17
|
createMarkdownExtensions,
|
|
17
18
|
createThemeExtensions,
|
|
18
19
|
decorateMarkdown,
|
|
19
20
|
processEditorPayload,
|
|
20
|
-
|
|
21
|
-
} from '@dxos/react-ui-editor';
|
|
21
|
+
} from '@dxos/ui-editor';
|
|
22
22
|
|
|
23
23
|
import { create as createBlockstore } from '../blockstore';
|
|
24
24
|
import { upload } from '../helpers';
|
package/src/extensions/image.tsx
CHANGED
|
@@ -11,12 +11,12 @@ import { createRoot } from 'react-dom/client';
|
|
|
11
11
|
|
|
12
12
|
import { type Space } from '@dxos/react-client/echo';
|
|
13
13
|
import { Status, ThemeProvider } from '@dxos/react-ui';
|
|
14
|
-
import { focusField } from '@dxos/
|
|
15
|
-
import { defaultTx } from '@dxos/
|
|
14
|
+
import { focusField } from '@dxos/ui-editor';
|
|
15
|
+
import { defaultTx } from '@dxos/ui-theme';
|
|
16
16
|
import { type MaybePromise } from '@dxos/util';
|
|
17
17
|
|
|
18
|
-
import { type WnfsCapabilities } from '../capabilities';
|
|
19
18
|
import { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';
|
|
19
|
+
import { type WnfsCapabilities } from '../types';
|
|
20
20
|
|
|
21
21
|
const WAIT_UNTIL_LOADER = 1500;
|
|
22
22
|
|