@dxos/plugin-wnfs 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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-TI75RSXW.mjs +72 -0
- package/dist/lib/browser/FileContainer-TI75RSXW.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-KKFOALUH.mjs → blockstore-3GWACM5O.mjs} +4 -4
- package/dist/lib/browser/{blockstore-KKFOALUH.mjs.map → blockstore-3GWACM5O.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-GXXEH7H6.mjs → chunk-4TGMSAOM.mjs} +18 -33
- package/dist/lib/browser/chunk-4TGMSAOM.mjs.map +7 -0
- package/dist/lib/browser/chunk-D7BMRINF.mjs +56 -0
- package/dist/lib/browser/chunk-D7BMRINF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NCTUASHL.mjs → chunk-UC4HMNZZ.mjs} +8 -6
- package/dist/lib/browser/chunk-UC4HMNZZ.mjs.map +7 -0
- package/dist/lib/browser/{file-uploader-BUHAXRSV.mjs → file-uploader-TSZWW7S7.mjs} +6 -5
- package/dist/lib/browser/file-uploader-TSZWW7S7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +31 -32
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{markdown-BRT2MN6C.mjs → markdown-JGZQQERR.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-F6GUL54A.mjs → operation-resolver-AUNGHUOQ.mjs} +7 -20
- package/dist/lib/browser/operation-resolver-AUNGHUOQ.mjs.map +7 -0
- package/dist/lib/browser/react-surface-5XF3LK5B.mjs +60 -0
- package/dist/lib/browser/react-surface-5XF3LK5B.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +1 -1
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +3 -2
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader/index.d.ts +1 -1
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/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.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/{components → containers/FileContainer}/FileContainer.d.ts +2 -2
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +3 -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/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +1 -1
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -23
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -30
- package/src/WnfsPlugin.tsx +22 -30
- package/src/blockstore.ts +1 -1
- package/src/capabilities/file-uploader/file-uploader.ts +4 -3
- package/src/capabilities/operation-resolver/operation-resolver.ts +2 -13
- package/src/capabilities/react-surface/react-surface.tsx +9 -7
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +4 -4
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/{FilePreview.tsx → FilePreview/FilePreview.tsx} +3 -3
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/{components → containers/FileContainer}/FileContainer.tsx +11 -11
- package/src/containers/FileContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +3 -3
- package/src/meta.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/File.ts +6 -2
- package/src/types/capabilities.ts +2 -2
- package/src/types/types.ts +9 -23
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +0 -91
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +0 -7
- 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.map +0 -7
- 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/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.map +0 -1
- /package/dist/lib/browser/{markdown-BRT2MN6C.mjs.map → markdown-JGZQQERR.mjs.map} +0 -0
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
- /package/dist/types/src/components/{FilePreview.d.ts → FilePreview/FilePreview.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.c351d160a8",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"browser": "./dist/lib/browser/index.mjs",
|
|
17
16
|
"source": "./src/index.ts",
|
|
17
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
18
18
|
"types": "./dist/types/src/index.d.ts"
|
|
19
19
|
},
|
|
20
20
|
"./types": {
|
|
21
|
-
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
21
|
"source": "./src/types/index.ts",
|
|
22
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
23
23
|
"types": "./dist/types/src/types/index.d.ts"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"blockstore-core": "^5.0.1",
|
|
44
44
|
"blockstore-idb": "^2.0.0",
|
|
45
45
|
"debounce": "^2.2.0",
|
|
46
|
-
"effect": "3.19.
|
|
46
|
+
"effect": "3.19.16",
|
|
47
47
|
"idb-keyval": "^6.2.1",
|
|
48
48
|
"interface-blockstore": "^5.2.10",
|
|
49
49
|
"it-all": "^3.0.6",
|
|
@@ -51,42 +51,43 @@
|
|
|
51
51
|
"react-dropzone": "^14.2.3",
|
|
52
52
|
"uint8arrays": "^5.1.0",
|
|
53
53
|
"wnfs": "0.2.2",
|
|
54
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/plugin-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/react-
|
|
66
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
67
|
-
"@dxos/react-ui-
|
|
68
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
69
|
-
"@dxos/ui-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/util": "0.8.4-main.
|
|
72
|
-
"@dxos/
|
|
54
|
+
"@dxos/app-framework": "0.8.4-main.c351d160a8",
|
|
55
|
+
"@dxos/app-toolkit": "0.8.4-main.c351d160a8",
|
|
56
|
+
"@dxos/crypto": "0.8.4-main.c351d160a8",
|
|
57
|
+
"@dxos/echo": "0.8.4-main.c351d160a8",
|
|
58
|
+
"@dxos/effect": "0.8.4-main.c351d160a8",
|
|
59
|
+
"@dxos/invariant": "0.8.4-main.c351d160a8",
|
|
60
|
+
"@dxos/log": "0.8.4-main.c351d160a8",
|
|
61
|
+
"@dxos/plugin-client": "0.8.4-main.c351d160a8",
|
|
62
|
+
"@dxos/operation": "0.8.4-main.c351d160a8",
|
|
63
|
+
"@dxos/plugin-markdown": "0.8.4-main.c351d160a8",
|
|
64
|
+
"@dxos/plugin-space": "0.8.4-main.c351d160a8",
|
|
65
|
+
"@dxos/react-client": "0.8.4-main.c351d160a8",
|
|
66
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
67
|
+
"@dxos/react-ui-editor": "0.8.4-main.c351d160a8",
|
|
68
|
+
"@dxos/react-ui-form": "0.8.4-main.c351d160a8",
|
|
69
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.c351d160a8",
|
|
70
|
+
"@dxos/react-ui-stack": "0.8.4-main.c351d160a8",
|
|
71
|
+
"@dxos/util": "0.8.4-main.c351d160a8",
|
|
72
|
+
"@dxos/ui-editor": "0.8.4-main.c351d160a8",
|
|
73
|
+
"@dxos/schema": "0.8.4-main.c351d160a8"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@types/react": "~19.2.7",
|
|
76
77
|
"@types/react-dom": "~19.2.3",
|
|
77
78
|
"react": "~19.2.3",
|
|
78
79
|
"react-dom": "~19.2.3",
|
|
79
|
-
"vite": "7.1.
|
|
80
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
81
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
82
|
-
"@dxos/random": "0.8.4-main.
|
|
80
|
+
"vite": "^7.1.11",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.c351d160a8",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8",
|
|
83
|
+
"@dxos/random": "0.8.4-main.c351d160a8"
|
|
83
84
|
},
|
|
84
85
|
"peerDependencies": {
|
|
85
|
-
"effect": "3.19.
|
|
86
|
+
"effect": "3.19.16",
|
|
86
87
|
"react": "~19.2.3",
|
|
87
88
|
"react-dom": "~19.2.3",
|
|
88
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
89
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
90
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8"
|
|
90
91
|
},
|
|
91
92
|
"publishConfig": {
|
|
92
93
|
"access": "public"
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
6
7
|
|
|
7
|
-
import { Capability,
|
|
8
|
+
import { Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Annotation } from '@dxos/echo';
|
|
8
11
|
import { Operation } from '@dxos/operation';
|
|
9
12
|
import { ClientEvents } from '@dxos/plugin-client';
|
|
10
13
|
import { MarkdownEvents } from '@dxos/plugin-markdown';
|
|
11
|
-
import { SpaceCapabilities, SpaceEvents } from '@dxos/plugin-space';
|
|
12
14
|
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
13
15
|
|
|
14
16
|
import { Blockstore, FileUploader, Markdown, OperationResolver, ReactSurface } from './capabilities';
|
|
@@ -17,28 +19,13 @@ import { translations } from './translations';
|
|
|
17
19
|
import { WnfsAction, WnfsCapabilities, WnfsFile, WnfsOperation } from './types';
|
|
18
20
|
|
|
19
21
|
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
20
|
-
|
|
21
|
-
id: 'blockstore',
|
|
22
|
-
activatesOn: ClientEvents.ClientReady,
|
|
23
|
-
activate: Blockstore,
|
|
24
|
-
}),
|
|
25
|
-
Plugin.addModule({
|
|
26
|
-
id: 'instances',
|
|
27
|
-
activatesOn: ClientEvents.ClientReady,
|
|
28
|
-
activate: () =>
|
|
29
|
-
Effect.sync(() => {
|
|
30
|
-
const instances: WnfsCapabilities.Instances = {};
|
|
31
|
-
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
34
|
-
Common.Plugin.addTranslationsModule({ translations }),
|
|
35
|
-
Common.Plugin.addMetadataModule({
|
|
22
|
+
AppPlugin.addMetadataModule({
|
|
36
23
|
metadata: {
|
|
37
24
|
id: WnfsFile.File.typename,
|
|
38
25
|
metadata: {
|
|
39
26
|
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
40
|
-
icon:
|
|
41
|
-
iconHue: '
|
|
27
|
+
icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,
|
|
28
|
+
iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',
|
|
42
29
|
inputSchema: WnfsAction.UploadFileSchema,
|
|
43
30
|
createObject: ((props, { db }) =>
|
|
44
31
|
Effect.gen(function* () {
|
|
@@ -48,16 +35,23 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
48
35
|
},
|
|
49
36
|
},
|
|
50
37
|
}),
|
|
51
|
-
|
|
38
|
+
AppPlugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
39
|
+
AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
40
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
41
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
42
|
+
Plugin.addModule({
|
|
43
|
+
id: 'blockstore',
|
|
44
|
+
activatesOn: ClientEvents.ClientReady,
|
|
45
|
+
activate: Blockstore,
|
|
46
|
+
}),
|
|
52
47
|
Plugin.addModule({
|
|
53
|
-
id: '
|
|
54
|
-
activatesOn:
|
|
48
|
+
id: 'instances',
|
|
49
|
+
activatesOn: ClientEvents.ClientReady,
|
|
55
50
|
activate: () =>
|
|
56
|
-
Effect.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
),
|
|
51
|
+
Effect.sync(() => {
|
|
52
|
+
const instances: WnfsCapabilities.Instances = {};
|
|
53
|
+
return Capability.contributes(WnfsCapabilities.Instances, instances);
|
|
54
|
+
}),
|
|
61
55
|
}),
|
|
62
56
|
Plugin.addModule({
|
|
63
57
|
id: 'file-uploader',
|
|
@@ -69,7 +63,5 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
69
63
|
activatesOn: MarkdownEvents.SetupExtensions,
|
|
70
64
|
activate: Markdown,
|
|
71
65
|
}),
|
|
72
|
-
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
73
|
-
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
74
66
|
Plugin.make,
|
|
75
67
|
);
|
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()]);
|
|
@@ -4,7 +4,8 @@
|
|
|
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
10
|
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
10
11
|
|
|
@@ -15,8 +16,8 @@ export default Capability.makeModule(
|
|
|
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);
|
|
@@ -4,28 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
8
|
import { invariant } from '@dxos/invariant';
|
|
10
9
|
import { OperationResolver } from '@dxos/operation';
|
|
11
10
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
-
import { Collection } from '@dxos/schema';
|
|
13
11
|
|
|
14
12
|
import { upload } from '../../helpers';
|
|
15
13
|
import { WnfsCapabilities, WnfsFile, WnfsOperation } from '../../types';
|
|
16
14
|
|
|
17
15
|
export default Capability.makeModule(
|
|
18
16
|
Effect.fnUntraced(function* () {
|
|
19
|
-
return Capability.contributes(
|
|
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
|
-
}),
|
|
17
|
+
return Capability.contributes(Capabilities.OperationResolver, [
|
|
29
18
|
OperationResolver.make({
|
|
30
19
|
operation: WnfsOperation.Create,
|
|
31
20
|
handler: ({ name, type, cid }) =>
|
|
@@ -6,26 +6,28 @@ import * as Effect from 'effect/Effect';
|
|
|
6
6
|
import type * as Schema from 'effect/Schema';
|
|
7
7
|
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
10
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
11
|
import { Obj } from '@dxos/echo';
|
|
11
12
|
import { findAnnotation } from '@dxos/effect';
|
|
12
13
|
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
13
14
|
|
|
14
|
-
import {
|
|
15
|
+
import { FileInput } from '../../components';
|
|
16
|
+
import { FileContainer } from '../../containers';
|
|
15
17
|
import { meta } from '../../meta';
|
|
16
18
|
import { WnfsAction, WnfsFile } from '../../types';
|
|
17
19
|
|
|
18
20
|
export default Capability.makeModule(() =>
|
|
19
21
|
Effect.succeed(
|
|
20
|
-
Capability.contributes(
|
|
21
|
-
|
|
22
|
-
id: `${meta.id}
|
|
22
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
23
|
+
Surface.create({
|
|
24
|
+
id: `${meta.id}.article`,
|
|
23
25
|
role: ['article', 'section', 'slide'],
|
|
24
26
|
filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),
|
|
25
27
|
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
26
28
|
}),
|
|
27
|
-
|
|
28
|
-
id: `${meta.id}
|
|
29
|
+
Surface.create({
|
|
30
|
+
id: `${meta.id}.create-form`,
|
|
29
31
|
role: 'form-input',
|
|
30
32
|
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
31
33
|
const annotation = findAnnotation<boolean>(
|
|
@@ -10,8 +10,8 @@ import { findAnnotation } from '@dxos/effect';
|
|
|
10
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
import { meta } from '
|
|
14
|
-
import { WnfsAction } from '
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
|
+
import { WnfsAction } from '../../types';
|
|
15
15
|
|
|
16
16
|
export type FileInputProps = {
|
|
17
17
|
schema: Schema.Schema.Any;
|
|
@@ -36,8 +36,8 @@ 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()} />
|
|
@@ -14,10 +14,10 @@ export type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;
|
|
|
14
14
|
*/
|
|
15
15
|
export const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {
|
|
16
16
|
if (type.startsWith('image/')) {
|
|
17
|
-
return <img className={mx('
|
|
17
|
+
return <img className={mx('w-full h-full object-contain', classNames)} src={url} />;
|
|
18
18
|
} else if (type.startsWith('video/')) {
|
|
19
|
-
return <video className={mx('
|
|
19
|
+
return <video className={mx('w-full h-full object-contain', classNames)} src={url} controls />;
|
|
20
20
|
} else {
|
|
21
|
-
return <iframe className={mx('
|
|
21
|
+
return <iframe className={mx('w-full h-full overflow-auto', classNames)} src={url} />;
|
|
22
22
|
}
|
|
23
23
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type SurfaceComponentProps } 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 {
|
|
15
|
-
import { type WnfsFile } from '
|
|
16
|
-
|
|
17
|
-
import { FilePreview } from './FilePreview';
|
|
13
|
+
import { FilePreview } from '../../components';
|
|
14
|
+
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../../helpers';
|
|
15
|
+
import { WnfsCapabilities, type WnfsFile } from '../../types';
|
|
18
16
|
|
|
19
17
|
export type FileContainerProps = SurfaceComponentProps<WnfsFile.File>;
|
|
20
18
|
|
|
@@ -47,9 +45,11 @@ export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
return (
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
48
|
+
<Panel.Root role={role} className='dx-document'>
|
|
49
|
+
<Panel.Content asChild>
|
|
50
|
+
<FilePreview type={file.type} url={blobUrl} />
|
|
51
|
+
</Panel.Content>
|
|
52
|
+
</Panel.Root>
|
|
53
53
|
);
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -86,15 +86,15 @@ const DefaultStory = () => {
|
|
|
86
86
|
<div className='mb-2'>
|
|
87
87
|
<input type='file' accept='image/*' onChange={onFileChange} />
|
|
88
88
|
</div>
|
|
89
|
-
<div className='
|
|
89
|
+
<div className='w-[50rem]' ref={parentRef} {...focusAttributes} />
|
|
90
90
|
</>
|
|
91
91
|
);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const meta = {
|
|
95
|
-
title: 'plugins/plugin-wnfs/image',
|
|
95
|
+
title: 'plugins/plugin-wnfs/extensions/image',
|
|
96
96
|
render: DefaultStory,
|
|
97
|
-
decorators: [withTheme, withClientProvider({ createIdentity: true, createSpace: true })],
|
|
97
|
+
decorators: [withTheme(), withClientProvider({ createIdentity: true, createSpace: true })],
|
|
98
98
|
} satisfies Meta<typeof DefaultStory>;
|
|
99
99
|
|
|
100
100
|
export default meta;
|
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.wnfs',
|
|
10
10
|
name: 'WNFS',
|
|
11
11
|
description: trim`
|
|
12
12
|
Decentralized file storage using the Web Native File System protocol.
|
package/src/translations.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const translations = [
|
|
|
16
16
|
'typename label_one': 'File',
|
|
17
17
|
'typename label_other': 'Files',
|
|
18
18
|
'object name placeholder': 'New file',
|
|
19
|
+
'add object label': 'Add file',
|
|
19
20
|
'rename object label': 'Rename file',
|
|
20
21
|
'delete object label': 'Delete file',
|
|
21
22
|
'object deleted label': 'File deleted',
|
package/src/types/File.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Obj, Type } from '@dxos/echo';
|
|
7
|
+
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
8
8
|
import { FormInputAnnotation } from '@dxos/echo/internal';
|
|
9
9
|
|
|
10
10
|
export const File = Schema.Struct({
|
|
@@ -14,9 +14,13 @@ export const File = Schema.Struct({
|
|
|
14
14
|
timestamp: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
15
15
|
}).pipe(
|
|
16
16
|
Type.object({
|
|
17
|
-
typename: 'dxos.
|
|
17
|
+
typename: 'org.dxos.type.file',
|
|
18
18
|
version: '0.1.0',
|
|
19
19
|
}),
|
|
20
|
+
Annotation.IconAnnotation.set({
|
|
21
|
+
icon: 'ph--file--regular',
|
|
22
|
+
hue: 'teal',
|
|
23
|
+
}),
|
|
20
24
|
);
|
|
21
25
|
|
|
22
26
|
export type File = Schema.Schema.Type<typeof File>;
|
|
@@ -11,8 +11,8 @@ import { type SpaceId } from '@dxos/keys';
|
|
|
11
11
|
import { meta } from '../meta';
|
|
12
12
|
|
|
13
13
|
export namespace WnfsCapabilities {
|
|
14
|
-
export const Blockstore = Capability.make<Blockstore>(`${meta.id}
|
|
14
|
+
export const Blockstore = Capability.make<Blockstore>(`${meta.id}.capability.blockstore`);
|
|
15
15
|
|
|
16
16
|
export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;
|
|
17
|
-
export const Instances = Capability.make<Instances>(`${meta.id}
|
|
17
|
+
export const Instances = Capability.make<Instances>(`${meta.id}.capability.instances`);
|
|
18
18
|
}
|
package/src/types/types.ts
CHANGED
|
@@ -4,18 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Capability
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { FileInfoSchema } from '@dxos/app-toolkit';
|
|
8
9
|
import { Database } from '@dxos/echo';
|
|
9
10
|
import { Operation } from '@dxos/operation';
|
|
10
|
-
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
11
|
-
import { Collection } from '@dxos/schema';
|
|
12
11
|
|
|
13
12
|
import { meta } from '../meta';
|
|
14
13
|
|
|
15
14
|
import * as File from './File';
|
|
16
15
|
|
|
17
16
|
export namespace WnfsAction {
|
|
18
|
-
export const UploadAnnotationId = Symbol.for(`${meta.id}
|
|
17
|
+
export const UploadAnnotationId = Symbol.for(`${meta.id}.annotation.upload`);
|
|
19
18
|
|
|
20
19
|
export const UploadFileSchema = Schema.Struct({
|
|
21
20
|
file: Schema.instanceOf(File.File).annotations({
|
|
@@ -31,27 +30,14 @@ export namespace WnfsAction {
|
|
|
31
30
|
export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const WNFS_OPERATION = `${meta.id}
|
|
33
|
+
const WNFS_OPERATION = `${meta.id}.operation`;
|
|
35
34
|
|
|
36
35
|
export namespace WnfsOperation {
|
|
37
|
-
export const OnCreateSpace = Operation.make({
|
|
38
|
-
meta: { key: `${WNFS_OPERATION}/on-create-space`, name: 'On Create Space' },
|
|
39
|
-
services: [Capability.Service],
|
|
40
|
-
schema: {
|
|
41
|
-
input: Schema.Struct({
|
|
42
|
-
space: SpaceSchema,
|
|
43
|
-
rootCollection: Collection.Collection,
|
|
44
|
-
isDefault: Schema.optional(Schema.Boolean),
|
|
45
|
-
}),
|
|
46
|
-
output: Schema.Void,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
36
|
export const Create = Operation.make({
|
|
51
|
-
meta: { key: `${WNFS_OPERATION}
|
|
37
|
+
meta: { key: `${WNFS_OPERATION}.create`, name: 'Create WNFS File' },
|
|
52
38
|
services: [Capability.Service],
|
|
53
39
|
schema: {
|
|
54
|
-
input:
|
|
40
|
+
input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),
|
|
55
41
|
output: Schema.Struct({
|
|
56
42
|
object: File.File,
|
|
57
43
|
}),
|
|
@@ -59,16 +45,16 @@ export namespace WnfsOperation {
|
|
|
59
45
|
});
|
|
60
46
|
|
|
61
47
|
export const Upload = Operation.make({
|
|
62
|
-
meta: { key: `${WNFS_OPERATION}
|
|
48
|
+
meta: { key: `${WNFS_OPERATION}.upload`, name: 'Upload File' },
|
|
63
49
|
services: [Capability.Service],
|
|
64
50
|
schema: {
|
|
65
51
|
input: Schema.extend(WnfsAction.UploadFileSchema, Schema.Struct({ db: Database.Database })),
|
|
66
|
-
output: Schema.required(
|
|
52
|
+
output: Schema.required(FileInfoSchema),
|
|
67
53
|
},
|
|
68
54
|
});
|
|
69
55
|
|
|
70
56
|
export const CreateFile = Operation.make({
|
|
71
|
-
meta: { key: `${WNFS_OPERATION}
|
|
57
|
+
meta: { key: `${WNFS_OPERATION}.create-file`, name: 'Create File' },
|
|
72
58
|
services: [Capability.Service],
|
|
73
59
|
schema: {
|
|
74
60
|
input: Schema.extend(WnfsAction.UploadFileSchema, Schema.Struct({ db: Database.Database })),
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
filePath,
|
|
3
|
-
getBlobUrl,
|
|
4
|
-
loadWnfs,
|
|
5
|
-
wnfsUrl
|
|
6
|
-
} from "./chunk-NCTUASHL.mjs";
|
|
7
|
-
import {
|
|
8
|
-
WnfsCapabilities
|
|
9
|
-
} from "./chunk-GXXEH7H6.mjs";
|
|
10
|
-
|
|
11
|
-
// src/components/FileContainer.tsx
|
|
12
|
-
import React2, { useState } from "react";
|
|
13
|
-
import { useCapability } from "@dxos/app-framework/react";
|
|
14
|
-
import { invariant } from "@dxos/invariant";
|
|
15
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
16
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
17
|
-
import { Layout } from "@dxos/react-ui-mosaic";
|
|
18
|
-
|
|
19
|
-
// src/components/FilePreview.tsx
|
|
20
|
-
import React from "react";
|
|
21
|
-
import { mx } from "@dxos/ui-theme";
|
|
22
|
-
var FilePreview = ({ type, url, classNames }) => {
|
|
23
|
-
if (type.startsWith("image/")) {
|
|
24
|
-
return /* @__PURE__ */ React.createElement("img", {
|
|
25
|
-
className: mx("is-full bs-full object-contain", classNames),
|
|
26
|
-
src: url
|
|
27
|
-
});
|
|
28
|
-
} else if (type.startsWith("video/")) {
|
|
29
|
-
return /* @__PURE__ */ React.createElement("video", {
|
|
30
|
-
className: mx("is-full bs-full object-contain", classNames),
|
|
31
|
-
src: url,
|
|
32
|
-
controls: true
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
return /* @__PURE__ */ React.createElement("iframe", {
|
|
36
|
-
className: mx("is-full bs-full overflow-auto", classNames),
|
|
37
|
-
src: url
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/components/FileContainer.tsx
|
|
43
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/components/FileContainer.tsx";
|
|
44
|
-
var FileContainer = ({ role, subject: file }) => {
|
|
45
|
-
const blockstore = useCapability(WnfsCapabilities.Blockstore);
|
|
46
|
-
const instances = useCapability(WnfsCapabilities.Instances);
|
|
47
|
-
const [blobUrl, setBlobUrl] = useState();
|
|
48
|
-
useAsyncEffect(async () => {
|
|
49
|
-
const space = getSpace(file);
|
|
50
|
-
invariant(space, void 0, {
|
|
51
|
-
F: __dxlog_file,
|
|
52
|
-
L: 28,
|
|
53
|
-
S: void 0,
|
|
54
|
-
A: [
|
|
55
|
-
"space",
|
|
56
|
-
""
|
|
57
|
-
]
|
|
58
|
-
});
|
|
59
|
-
const { directory, forest } = await loadWnfs({
|
|
60
|
-
blockstore,
|
|
61
|
-
instances,
|
|
62
|
-
space
|
|
63
|
-
});
|
|
64
|
-
const path = filePath(file.cid.toString(), space);
|
|
65
|
-
const url = await getBlobUrl({
|
|
66
|
-
wnfsUrl: wnfsUrl(path),
|
|
67
|
-
blockstore,
|
|
68
|
-
directory,
|
|
69
|
-
forest,
|
|
70
|
-
type: file.type
|
|
71
|
-
});
|
|
72
|
-
setBlobUrl(url);
|
|
73
|
-
}, [
|
|
74
|
-
file
|
|
75
|
-
]);
|
|
76
|
-
if (!blobUrl) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
return /* @__PURE__ */ React2.createElement(Layout.Main, {
|
|
80
|
-
role
|
|
81
|
-
}, /* @__PURE__ */ React2.createElement(FilePreview, {
|
|
82
|
-
type: file.type,
|
|
83
|
-
url: blobUrl
|
|
84
|
-
}));
|
|
85
|
-
};
|
|
86
|
-
var FileContainer_default = FileContainer;
|
|
87
|
-
export {
|
|
88
|
-
FileContainer,
|
|
89
|
-
FileContainer_default as default
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=FileContainer-O5YFSIWV.mjs.map
|