@dxos/plugin-wnfs 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41

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.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/browser/chunk-4D4K5JCC.mjs +66 -0
  3. package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-NCTUASHL.mjs → chunk-7KFJ6LYH.mjs} +36 -19
  5. package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-DK62NQ5T.mjs +71 -0
  7. package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  9. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  10. package/dist/lib/browser/create-QRLX4IMZ.mjs +25 -0
  11. package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
  12. package/dist/lib/browser/create-file-INAT56PX.mjs +42 -0
  13. package/dist/lib/browser/create-file-INAT56PX.mjs.map +7 -0
  14. package/dist/lib/browser/helpers/index.mjs +26 -0
  15. package/dist/lib/browser/helpers/index.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +22 -109
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/operations/index.mjs +14 -0
  20. package/dist/lib/browser/operations/index.mjs.map +7 -0
  21. package/dist/lib/browser/translations.mjs +30 -0
  22. package/dist/lib/browser/translations.mjs.map +7 -0
  23. package/dist/lib/browser/types/index.mjs +4 -5
  24. package/dist/lib/browser/upload-ZQI66T4Y.mjs +35 -0
  25. package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
  26. package/dist/types/src/WnfsPlugin.d.ts +1 -0
  27. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  28. package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
  29. package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
  30. package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
  31. package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
  32. package/dist/types/src/blockstore.d.ts.map +1 -1
  33. package/dist/types/src/capabilities/blockstore.d.ts +5 -0
  34. package/dist/types/src/capabilities/blockstore.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  36. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/file-uploader.d.ts +6 -0
  38. package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/index.d.ts +13 -5
  40. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/markdown.d.ts +6 -0
  42. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  44. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  46. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  47. package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
  48. package/dist/types/src/components/FileInput/index.d.ts +2 -0
  49. package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
  50. package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
  51. package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
  52. package/dist/types/src/components/FilePreview/index.d.ts +2 -0
  53. package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
  54. package/dist/types/src/components/index.d.ts +1 -1
  55. package/dist/types/src/components/index.d.ts.map +1 -1
  56. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  57. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  58. package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
  59. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  60. package/dist/types/src/containers/index.d.ts +3 -0
  61. package/dist/types/src/containers/index.d.ts.map +1 -0
  62. package/dist/types/src/extensions/image.d.ts +1 -1
  63. package/dist/types/src/extensions/image.d.ts.map +1 -1
  64. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  65. package/dist/types/src/helpers/common.d.ts.map +1 -1
  66. package/dist/types/src/helpers/load.d.ts +1 -1
  67. package/dist/types/src/helpers/load.d.ts.map +1 -1
  68. package/dist/types/src/helpers/upload.d.ts +1 -1
  69. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  70. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  71. package/dist/types/src/index.d.ts +3 -2
  72. package/dist/types/src/index.d.ts.map +1 -1
  73. package/dist/types/src/operations/create-file.d.ts +5 -0
  74. package/dist/types/src/operations/create-file.d.ts.map +1 -0
  75. package/dist/types/src/operations/create.d.ts +5 -0
  76. package/dist/types/src/operations/create.d.ts.map +1 -0
  77. package/dist/types/src/operations/definitions.d.ts +38 -0
  78. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  79. package/dist/types/src/operations/index.d.ts +4 -0
  80. package/dist/types/src/operations/index.d.ts.map +1 -0
  81. package/dist/types/src/operations/upload.d.ts +5 -0
  82. package/dist/types/src/operations/upload.d.ts.map +1 -0
  83. package/dist/types/src/translations.d.ts +24 -15
  84. package/dist/types/src/translations.d.ts.map +1 -1
  85. package/dist/types/src/types/File.d.ts +1 -1
  86. package/dist/types/src/types/File.d.ts.map +1 -1
  87. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  88. package/dist/types/src/types/types.d.ts +1 -104
  89. package/dist/types/src/types/types.d.ts.map +1 -1
  90. package/dist/types/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +63 -39
  92. package/src/WnfsPlugin.node.ts +19 -0
  93. package/src/WnfsPlugin.test.ts +27 -0
  94. package/src/WnfsPlugin.tsx +10 -36
  95. package/src/blockstore.ts +1 -1
  96. package/src/capabilities/{blockstore/blockstore.ts → blockstore.ts} +4 -3
  97. package/src/capabilities/create-object.ts +33 -0
  98. package/src/capabilities/{file-uploader/file-uploader.ts → file-uploader.ts} +2 -2
  99. package/src/capabilities/index.ts +12 -5
  100. package/src/capabilities/markdown.ts +38 -0
  101. package/src/capabilities/operation-handler.ts +16 -0
  102. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +23 -13
  103. package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
  104. package/src/components/FileInput/index.ts +5 -0
  105. package/src/components/FilePreview/FilePreview.tsx +43 -0
  106. package/src/components/FilePreview/index.ts +5 -0
  107. package/src/components/index.ts +1 -4
  108. package/src/{components → containers/FileContainer}/FileContainer.tsx +11 -11
  109. package/src/containers/FileContainer/index.ts +5 -0
  110. package/src/containers/index.ts +7 -0
  111. package/src/extensions/image.stories.tsx +8 -9
  112. package/src/extensions/image.tsx +2 -1
  113. package/src/helpers/load.ts +6 -6
  114. package/src/helpers/upload.ts +3 -3
  115. package/src/index.ts +8 -2
  116. package/src/meta.ts +1 -1
  117. package/src/operations/create-file.ts +31 -0
  118. package/src/operations/create.ts +22 -0
  119. package/src/operations/definitions.ts +41 -0
  120. package/src/operations/index.ts +13 -0
  121. package/src/operations/upload.ts +29 -0
  122. package/src/translations.ts +13 -12
  123. package/src/types/File.ts +6 -2
  124. package/src/types/capabilities.ts +3 -3
  125. package/src/types/types.ts +3 -60
  126. package/dist/lib/browser/FileContainer-FUAINNAS.mjs +0 -91
  127. package/dist/lib/browser/FileContainer-FUAINNAS.mjs.map +0 -7
  128. package/dist/lib/browser/blockstore-U42RF6KA.mjs +0 -191
  129. package/dist/lib/browser/blockstore-U42RF6KA.mjs.map +0 -7
  130. package/dist/lib/browser/chunk-NCTUASHL.mjs.map +0 -7
  131. package/dist/lib/browser/chunk-PCYQNMXS.mjs +0 -155
  132. package/dist/lib/browser/chunk-PCYQNMXS.mjs.map +0 -7
  133. package/dist/lib/browser/file-uploader-VBBUS2GG.mjs +0 -35
  134. package/dist/lib/browser/file-uploader-VBBUS2GG.mjs.map +0 -7
  135. package/dist/lib/browser/markdown-ZLOS5HZU.mjs +0 -201
  136. package/dist/lib/browser/markdown-ZLOS5HZU.mjs.map +0 -7
  137. package/dist/lib/browser/operation-resolver-7TLMWGST.mjs +0 -99
  138. package/dist/lib/browser/operation-resolver-7TLMWGST.mjs.map +0 -7
  139. package/dist/lib/browser/react-surface-YTIVVF2C.mjs +0 -82
  140. package/dist/lib/browser/react-surface-YTIVVF2C.mjs.map +0 -7
  141. package/dist/types/src/capabilities/blockstore/blockstore.d.ts +0 -5
  142. package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +0 -1
  143. package/dist/types/src/capabilities/blockstore/index.d.ts +0 -3
  144. package/dist/types/src/capabilities/blockstore/index.d.ts.map +0 -1
  145. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +0 -6
  146. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +0 -1
  147. package/dist/types/src/capabilities/file-uploader/index.d.ts +0 -3
  148. package/dist/types/src/capabilities/file-uploader/index.d.ts.map +0 -1
  149. package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
  150. package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
  151. package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
  152. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
  153. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  154. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  155. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  156. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  157. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  158. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  159. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  160. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  161. package/dist/types/src/components/FileContainer.d.ts +0 -7
  162. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  163. package/dist/types/src/components/FileInput.d.ts.map +0 -1
  164. package/dist/types/src/components/FilePreview.d.ts +0 -11
  165. package/dist/types/src/components/FilePreview.d.ts.map +0 -1
  166. package/src/capabilities/blockstore/index.ts +0 -7
  167. package/src/capabilities/file-uploader/index.ts +0 -7
  168. package/src/capabilities/markdown/index.ts +0 -7
  169. package/src/capabilities/markdown/markdown.ts +0 -33
  170. package/src/capabilities/operation-resolver/index.ts +0 -7
  171. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -62
  172. package/src/capabilities/react-surface/index.ts +0 -7
  173. package/src/components/FilePreview.tsx +0 -23
  174. /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-wnfs",
3
- "version": "0.8.4-main.1068cf700f",
3
+ "version": "0.8.4-main.1c7ec43d41",
4
4
  "description": "WNFS file management plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -11,26 +11,49 @@
11
11
  "license": "MIT",
12
12
  "author": "DXOS.org",
13
13
  "type": "module",
14
+ "imports": {
15
+ "#capabilities": "./src/capabilities/index.ts",
16
+ "#components": "./src/components/index.ts",
17
+ "#containers": "./src/containers/index.ts",
18
+ "#meta": "./src/meta.ts",
19
+ "#operations": "./src/operations/index.ts",
20
+ "#plugin": {
21
+ "browser": "./src/WnfsPlugin.tsx",
22
+ "node": "./src/WnfsPlugin.node.ts",
23
+ "default": "./src/WnfsPlugin.tsx"
24
+ },
25
+ "#translations": "./src/translations.ts",
26
+ "#types": "./src/types/index.ts"
27
+ },
14
28
  "exports": {
15
29
  ".": {
16
- "browser": "./dist/lib/browser/index.mjs",
17
30
  "source": "./src/index.ts",
31
+ "browser": "./dist/lib/browser/index.mjs",
18
32
  "types": "./dist/types/src/index.d.ts"
19
33
  },
34
+ "./helpers": {
35
+ "source": "./src/helpers/index.ts",
36
+ "browser": "./dist/lib/browser/helpers/index.mjs",
37
+ "types": "./dist/types/src/helpers/index.d.ts"
38
+ },
39
+ "./operations": {
40
+ "source": "./src/operations/index.ts",
41
+ "browser": "./dist/lib/browser/operations/index.mjs",
42
+ "types": "./dist/types/src/operations/index.d.ts"
43
+ },
44
+ "./translations": {
45
+ "source": "./src/translations.ts",
46
+ "types": "./dist/types/src/translations.d.ts",
47
+ "browser": "./dist/lib/browser/translations.mjs",
48
+ "node": "./dist/lib/node-esm/translations.mjs"
49
+ },
20
50
  "./types": {
21
- "browser": "./dist/lib/browser/types/index.mjs",
22
51
  "source": "./src/types/index.ts",
52
+ "browser": "./dist/lib/browser/types/index.mjs",
23
53
  "types": "./dist/types/src/types/index.d.ts"
24
54
  }
25
55
  },
26
56
  "types": "dist/types/src/index.d.ts",
27
- "typesVersions": {
28
- "*": {
29
- "types": [
30
- "dist/types/src/types/index.d.ts"
31
- ]
32
- }
33
- },
34
57
  "files": [
35
58
  "dist",
36
59
  "src"
@@ -38,12 +61,12 @@
38
61
  "dependencies": {
39
62
  "@codemirror/language": "^6.11.3",
40
63
  "@codemirror/state": "^6.5.2",
41
- "@codemirror/view": "^6.38.4",
64
+ "@codemirror/view": "^6.38.5",
42
65
  "@ipld/car": "^5.3.3",
43
66
  "blockstore-core": "^5.0.1",
44
67
  "blockstore-idb": "^2.0.0",
45
68
  "debounce": "^2.2.0",
46
- "effect": "3.19.16",
69
+ "effect": "3.20.0",
47
70
  "idb-keyval": "^6.2.1",
48
71
  "interface-blockstore": "^5.2.10",
49
72
  "it-all": "^3.0.6",
@@ -51,43 +74,44 @@
51
74
  "react-dropzone": "^14.2.3",
52
75
  "uint8arrays": "^5.1.0",
53
76
  "wnfs": "0.2.2",
54
- "@dxos/app-toolkit": "0.8.4-main.1068cf700f",
55
- "@dxos/app-framework": "0.8.4-main.1068cf700f",
56
- "@dxos/echo": "0.8.4-main.1068cf700f",
57
- "@dxos/crypto": "0.8.4-main.1068cf700f",
58
- "@dxos/log": "0.8.4-main.1068cf700f",
59
- "@dxos/invariant": "0.8.4-main.1068cf700f",
60
- "@dxos/effect": "0.8.4-main.1068cf700f",
61
- "@dxos/operation": "0.8.4-main.1068cf700f",
62
- "@dxos/plugin-client": "0.8.4-main.1068cf700f",
63
- "@dxos/plugin-markdown": "0.8.4-main.1068cf700f",
64
- "@dxos/react-ui": "0.8.4-main.1068cf700f",
65
- "@dxos/plugin-space": "0.8.4-main.1068cf700f",
66
- "@dxos/react-client": "0.8.4-main.1068cf700f",
67
- "@dxos/react-ui-editor": "0.8.4-main.1068cf700f",
68
- "@dxos/react-ui-form": "0.8.4-main.1068cf700f",
69
- "@dxos/react-ui-mosaic": "0.8.4-main.1068cf700f",
70
- "@dxos/react-ui-stack": "0.8.4-main.1068cf700f",
71
- "@dxos/schema": "0.8.4-main.1068cf700f",
72
- "@dxos/util": "0.8.4-main.1068cf700f",
73
- "@dxos/ui-editor": "0.8.4-main.1068cf700f"
77
+ "@dxos/app-toolkit": "0.8.4-main.1c7ec43d41",
78
+ "@dxos/app-framework": "0.8.4-main.1c7ec43d41",
79
+ "@dxos/compute": "0.8.4-main.1c7ec43d41",
80
+ "@dxos/echo": "0.8.4-main.1c7ec43d41",
81
+ "@dxos/effect": "0.8.4-main.1c7ec43d41",
82
+ "@dxos/invariant": "0.8.4-main.1c7ec43d41",
83
+ "@dxos/crypto": "0.8.4-main.1c7ec43d41",
84
+ "@dxos/log": "0.8.4-main.1c7ec43d41",
85
+ "@dxos/plugin-client": "0.8.4-main.1c7ec43d41",
86
+ "@dxos/plugin-markdown": "0.8.4-main.1c7ec43d41",
87
+ "@dxos/plugin-space": "0.8.4-main.1c7ec43d41",
88
+ "@dxos/react-client": "0.8.4-main.1c7ec43d41",
89
+ "@dxos/react-ui": "0.8.4-main.1c7ec43d41",
90
+ "@dxos/react-ui-editor": "0.8.4-main.1c7ec43d41",
91
+ "@dxos/schema": "0.8.4-main.1c7ec43d41",
92
+ "@dxos/react-ui-mosaic": "0.8.4-main.1c7ec43d41",
93
+ "@dxos/react-ui-form": "0.8.4-main.1c7ec43d41",
94
+ "@dxos/react-ui-stack": "0.8.4-main.1c7ec43d41",
95
+ "@dxos/ui-editor": "0.8.4-main.1c7ec43d41",
96
+ "@dxos/util": "0.8.4-main.1c7ec43d41"
74
97
  },
75
98
  "devDependencies": {
76
99
  "@types/react": "~19.2.7",
77
100
  "@types/react-dom": "~19.2.3",
78
101
  "react": "~19.2.3",
79
102
  "react-dom": "~19.2.3",
80
- "vite": "7.1.9",
81
- "@dxos/random": "0.8.4-main.1068cf700f",
82
- "@dxos/storybook-utils": "0.8.4-main.1068cf700f",
83
- "@dxos/ui-theme": "0.8.4-main.1068cf700f"
103
+ "vite": "^8.0.10",
104
+ "@dxos/storybook-utils": "0.8.4-main.1c7ec43d41",
105
+ "@dxos/plugin-testing": "0.8.4-main.1c7ec43d41",
106
+ "@dxos/ui-theme": "0.8.4-main.1c7ec43d41",
107
+ "@dxos/random": "0.8.4-main.1c7ec43d41"
84
108
  },
85
109
  "peerDependencies": {
86
- "effect": "3.19.16",
110
+ "effect": "3.20.0",
87
111
  "react": "~19.2.3",
88
112
  "react-dom": "~19.2.3",
89
- "@dxos/react-ui": "0.8.4-main.1068cf700f",
90
- "@dxos/ui-theme": "0.8.4-main.1068cf700f"
113
+ "@dxos/react-ui": "0.8.4-main.1c7ec43d41",
114
+ "@dxos/ui-theme": "0.8.4-main.1c7ec43d41"
91
115
  },
92
116
  "publishConfig": {
93
117
  "access": "public"
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+
8
+ import { CreateObject, OperationHandler } from '#capabilities';
9
+ import { meta } from '#meta';
10
+ import { WnfsFile } from '#types';
11
+
12
+ export const WnfsPlugin = Plugin.define(meta).pipe(
13
+ AppPlugin.addCreateObjectModule({ activate: CreateObject }),
14
+ AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
15
+ AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
16
+ Plugin.make,
17
+ );
18
+
19
+ export default WnfsPlugin;
@@ -0,0 +1,27 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import { ClientPlugin } from '@dxos/plugin-client';
8
+ import { createComposerTestApp } from '@dxos/plugin-testing/harness';
9
+
10
+ import { WnfsPlugin } from '#plugin';
11
+
12
+ import { meta } from './meta';
13
+
14
+ const moduleId = (name: string) => `${meta.id}.module.${name}`;
15
+
16
+ describe('WnfsPlugin', () => {
17
+ test('modules activate on the expected events', async ({ expect }) => {
18
+ await using harness = await createComposerTestApp({
19
+ plugins: [ClientPlugin({}), WnfsPlugin()],
20
+ });
21
+
22
+ // After autoStart: CreateObject, schema, and OperationHandler all auto-cascade.
23
+ expect(harness.manager.getActive()).toEqual(
24
+ expect.arrayContaining([moduleId('CreateObject'), moduleId('schema'), moduleId('OperationHandler')]),
25
+ );
26
+ });
27
+ });
@@ -6,35 +6,17 @@ import * as Effect from 'effect/Effect';
6
6
 
7
7
  import { Capability, Plugin } from '@dxos/app-framework';
8
8
  import { AppPlugin } from '@dxos/app-toolkit';
9
- import { Operation } from '@dxos/operation';
10
- import { ClientEvents } from '@dxos/plugin-client';
11
- import { MarkdownEvents } from '@dxos/plugin-markdown';
12
- import { SpaceCapabilities, SpaceEvents } from '@dxos/plugin-space';
13
- import { type CreateObject } from '@dxos/plugin-space/types';
9
+ import { ClientEvents } from '@dxos/plugin-client/types';
10
+ import { MarkdownEvents } from '@dxos/plugin-markdown/types';
14
11
 
15
- import { Blockstore, FileUploader, Markdown, OperationResolver, ReactSurface } from './capabilities';
16
- import { meta } from './meta';
17
- import { translations } from './translations';
18
- import { WnfsAction, WnfsCapabilities, WnfsFile, WnfsOperation } from './types';
12
+ import { Blockstore, CreateObject, FileUploader, Markdown, OperationHandler, ReactSurface } from '#capabilities';
13
+ import { meta } from '#meta';
14
+ import { translations } from '#translations';
15
+ import { WnfsCapabilities, WnfsFile } from '#types';
19
16
 
20
17
  export const WnfsPlugin = Plugin.define(meta).pipe(
21
- AppPlugin.addMetadataModule({
22
- metadata: {
23
- id: WnfsFile.File.typename,
24
- metadata: {
25
- // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
26
- icon: 'ph--file--regular',
27
- iconHue: 'teal',
28
- inputSchema: WnfsAction.UploadFileSchema,
29
- createObject: ((props, { db }) =>
30
- Effect.gen(function* () {
31
- const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db });
32
- return object;
33
- })) satisfies CreateObject,
34
- },
35
- },
36
- }),
37
- AppPlugin.addOperationResolverModule({ activate: OperationResolver }),
18
+ AppPlugin.addCreateObjectModule({ activate: CreateObject }),
19
+ AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
38
20
  AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
39
21
  AppPlugin.addSurfaceModule({ activate: ReactSurface }),
40
22
  AppPlugin.addTranslationsModule({ translations }),
@@ -52,16 +34,6 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
52
34
  return Capability.contributes(WnfsCapabilities.Instances, instances);
53
35
  }),
54
36
  }),
55
- Plugin.addModule({
56
- id: 'on-space-created',
57
- activatesOn: SpaceEvents.SpaceCreated,
58
- activate: () =>
59
- Effect.succeed(
60
- Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) =>
61
- Operation.invoke(WnfsOperation.OnCreateSpace, params),
62
- ),
63
- ),
64
- }),
65
37
  Plugin.addModule({
66
38
  id: 'file-uploader',
67
39
  activatesOn: ClientEvents.ClientReady,
@@ -74,3 +46,5 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
74
46
  }),
75
47
  Plugin.make,
76
48
  );
49
+
50
+ export default WnfsPlugin;
package/src/blockstore.ts CHANGED
@@ -145,7 +145,7 @@ export class MixedBlockstore extends BaseBlockstore {
145
145
 
146
146
  // QUEUE
147
147
 
148
- readonly queueCacheName = `${storeName()}/state/queue`;
148
+ readonly queueCacheName = `${storeName()}.state.queue`;
149
149
 
150
150
  async #addToQueue(key: CID): Promise<void> {
151
151
  await this.#saveQueue([...this.#queue, key.toString()]);
@@ -5,10 +5,11 @@
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
7
  import { Capability } from '@dxos/app-framework';
8
- import { ClientCapabilities } from '@dxos/plugin-client';
8
+ import { ClientCapabilities } from '@dxos/plugin-client/types';
9
9
 
10
- import * as Blockstore from '../../blockstore';
11
- import { WnfsCapabilities } from '../../types';
10
+ import { WnfsCapabilities } from '#types';
11
+
12
+ import * as Blockstore from '../blockstore';
12
13
 
13
14
  export default Capability.makeModule(
14
15
  Effect.fnUntraced(function* () {
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { Operation } from '@dxos/compute';
9
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
10
+ import { SpaceCapabilities } from '@dxos/plugin-space/types';
11
+
12
+ import { WnfsOperation } from '#operations';
13
+ import { WnfsAction, WnfsFile } from '#types';
14
+
15
+ export default Capability.makeModule(
16
+ Effect.fnUntraced(function* () {
17
+ return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
18
+ id: WnfsFile.File.typename,
19
+ inputSchema: WnfsAction.UploadFileSchema,
20
+ // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
21
+ createObject: (props, options) =>
22
+ Effect.gen(function* () {
23
+ const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });
24
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
25
+ object,
26
+ target: options.target,
27
+ hidden: true,
28
+ targetNodeId: options.targetNodeId,
29
+ });
30
+ }),
31
+ });
32
+ }),
33
+ );
@@ -7,9 +7,9 @@ import * as Effect from 'effect/Effect';
7
7
  import { Capabilities, Capability } from '@dxos/app-framework';
8
8
  import { AppCapabilities } from '@dxos/app-toolkit';
9
9
  import { runAndForwardErrors } from '@dxos/effect';
10
- import { SpaceOperation } from '@dxos/plugin-space/types';
10
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
11
11
 
12
- import { WnfsOperation } from '../../types';
12
+ import { WnfsOperation } from '#operations';
13
13
 
14
14
  export default Capability.makeModule(
15
15
  Effect.fnUntraced(function* () {
@@ -2,8 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './blockstore';
6
- export * from './file-uploader';
7
- export * from './markdown';
8
- export * from './operation-resolver';
9
- export * from './react-surface';
5
+ import { Capability } from '@dxos/app-framework';
6
+ import { OperationHandlerSet } from '@dxos/compute';
7
+
8
+ export const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));
9
+ export const CreateObject = Capability.lazy('CreateObject', () => import('./create-object'));
10
+ export const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));
11
+ export const Markdown = Capability.lazy('Markdown', () => import('./markdown'));
12
+ export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
13
+ 'OperationHandler',
14
+ () => import('./operation-handler'),
15
+ );
16
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -0,0 +1,38 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { type MarkdownExtensionProvider, MarkdownCapabilities } from '@dxos/plugin-markdown/types';
9
+ import { getSpace } from '@dxos/react-client/echo';
10
+
11
+ import { WnfsCapabilities } from '#types';
12
+
13
+ import { image } from '../extensions';
14
+
15
+ export default Capability.makeModule(
16
+ Effect.fnUntraced(function* () {
17
+ // Get context for lazy capability access in callbacks.
18
+ const capabilities = yield* Capability.Service;
19
+
20
+ const provider: MarkdownExtensionProvider = ({ document, viewMode }) => {
21
+ if (viewMode === 'source') {
22
+ return undefined;
23
+ }
24
+
25
+ const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
26
+ const instances = capabilities.get(WnfsCapabilities.Instances);
27
+
28
+ if (document) {
29
+ const space = getSpace(document);
30
+ return space ? [image({ blockstore, instances, space })] : undefined;
31
+ }
32
+
33
+ return undefined;
34
+ };
35
+
36
+ return Capability.contributes(MarkdownCapabilities.Extensions, [provider]);
37
+ }),
38
+ );
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import type { OperationHandlerSet } from '@dxos/compute';
9
+
10
+ import { WnfsOperationHandlerSet } from '#operations';
11
+
12
+ export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
13
+ Effect.fnUntraced(function* () {
14
+ return Capability.contributes(Capabilities.OperationHandler, WnfsOperationHandlerSet);
15
+ }),
16
+ );
@@ -4,42 +4,52 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
  import type * as Schema from 'effect/Schema';
7
+ import * as SchemaAST from 'effect/SchemaAST';
7
8
  import React, { useCallback } from 'react';
8
9
 
9
10
  import { Capabilities, Capability } from '@dxos/app-framework';
10
11
  import { Surface } from '@dxos/app-framework/ui';
11
- import { Obj } from '@dxos/echo';
12
+ import { AppSurface } from '@dxos/app-toolkit/ui';
12
13
  import { findAnnotation } from '@dxos/effect';
13
14
  import { type FormFieldComponentProps } from '@dxos/react-ui-form';
14
15
 
15
- import { FileContainer, FileInput } from '../../components';
16
- import { meta } from '../../meta';
17
- import { WnfsAction, WnfsFile } from '../../types';
16
+ import { FileInput } from '#components';
17
+ import { FileContainer } from '#containers';
18
+ import { WnfsAction, WnfsFile } from '#types';
18
19
 
19
20
  export default Capability.makeModule(() =>
20
21
  Effect.succeed(
21
22
  Capability.contributes(Capabilities.ReactSurface, [
22
23
  Surface.create({
23
- id: `${meta.id}/article`,
24
- role: ['article', 'section', 'slide'],
25
- filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),
24
+ id: 'article',
25
+ // TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
26
+ filter: AppSurface.oneOf(
27
+ AppSurface.object(AppSurface.Article, WnfsFile.File),
28
+ AppSurface.object(AppSurface.Section, WnfsFile.File),
29
+ AppSurface.object(AppSurface.Slide, WnfsFile.File),
30
+ ),
26
31
  component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
27
32
  }),
28
33
  Surface.create({
29
- id: `${meta.id}/create-form`,
34
+ id: 'create-form',
30
35
  role: 'form-input',
31
- filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
36
+ filter: (data): data is { prop: string; schema: Schema.Schema.Any; fieldPropertyAst?: SchemaAST.AST } => {
32
37
  const annotation = findAnnotation<boolean>(
33
38
  (data.schema as Schema.Schema.All).ast,
34
39
  WnfsAction.UploadAnnotationId,
35
40
  );
36
41
  return !!annotation;
37
42
  },
38
- component: ({ data: { schema }, ...props }) => {
39
- const inputProps = props as unknown as FormFieldComponentProps;
43
+ component: ({ data: { schema, fieldPropertyAst }, ...props }) => {
44
+ const ast = fieldPropertyAst;
45
+ if (!ast) {
46
+ return null;
47
+ }
48
+
49
+ const inputProps = { ...props, type: ast } as unknown as FormFieldComponentProps;
40
50
  const handleChange = useCallback(
41
- (file: File) => inputProps.onValueChange?.(inputProps.type, file),
42
- [inputProps.type, inputProps.onValueChange],
51
+ (file: File) => inputProps.onValueChange?.(ast, file),
52
+ [ast, inputProps.onValueChange],
43
53
  );
44
54
 
45
55
  return <FileInput schema={schema} onChange={handleChange} />;
@@ -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 '../meta';
14
- import { WnfsAction } from '../types';
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-roseFill',
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 input placeholder')}</p>}
44
+ {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file-input.placeholder')}</p>}
45
45
  </div>
46
46
  );
47
47
  };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './FileInput';
@@ -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
+ );
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './FilePreview';
@@ -2,8 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from 'react';
6
-
7
- export const FileContainer = lazy(() => import('./FileContainer'));
8
-
9
5
  export * from './FileInput';
6
+ export * from './FilePreview';
@@ -5,19 +5,17 @@
5
5
  import React, { useState } from 'react';
6
6
 
7
7
  import { useCapability } from '@dxos/app-framework/ui';
8
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
9
  import { invariant } from '@dxos/invariant';
10
10
  import { getSpace } from '@dxos/react-client/echo';
11
- import { useAsyncEffect } from '@dxos/react-ui';
12
- import { Layout } from '@dxos/react-ui';
11
+ import { Panel, useAsyncEffect } from '@dxos/react-ui';
13
12
 
14
- import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
15
- import { WnfsCapabilities } from '../types';
16
- import { type WnfsFile } from '../types';
13
+ import { FilePreview } from '#components';
14
+ import { WnfsCapabilities, type WnfsFile } from '#types';
17
15
 
18
- import { FilePreview } from './FilePreview';
16
+ import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../../helpers';
19
17
 
20
- export type FileContainerProps = SurfaceComponentProps<WnfsFile.File>;
18
+ export type FileContainerProps = AppSurface.ObjectArticleProps<WnfsFile.File>;
21
19
 
22
20
  export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
23
21
  const blockstore = useCapability(WnfsCapabilities.Blockstore);
@@ -48,9 +46,11 @@ export const FileContainer = ({ role, subject: file }: FileContainerProps) => {
48
46
  }
49
47
 
50
48
  return (
51
- <Layout.Main role={role}>
52
- <FilePreview type={file.type} url={blobUrl} />
53
- </Layout.Main>
49
+ <Panel.Root role={role} className='dx-document'>
50
+ <Panel.Content asChild>
51
+ <FilePreview type={file.type} url={blobUrl} />
52
+ </Panel.Content>
53
+ </Panel.Root>
54
54
  );
55
55
  };
56
56
 
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export { FileContainer as default } from './FileContainer';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type ComponentType, lazy } from 'react';
6
+
7
+ export const FileContainer: ComponentType<any> = lazy(() => import('./FileContainer'));