@dxos/plugin-wnfs 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) 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 -108
  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/file-uploader.d.ts +6 -0
  36. package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/index.d.ts +7 -5
  38. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/markdown.d.ts +6 -0
  40. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  42. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  44. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  45. package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
  46. package/dist/types/src/components/FileInput/index.d.ts +2 -0
  47. package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
  48. package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
  49. package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
  50. package/dist/types/src/components/FilePreview/index.d.ts +2 -0
  51. package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
  52. package/dist/types/src/components/index.d.ts +1 -1
  53. package/dist/types/src/components/index.d.ts.map +1 -1
  54. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  55. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  56. package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
  57. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  58. package/dist/types/src/containers/index.d.ts +3 -0
  59. package/dist/types/src/containers/index.d.ts.map +1 -0
  60. package/dist/types/src/extensions/image.d.ts +1 -1
  61. package/dist/types/src/extensions/image.d.ts.map +1 -1
  62. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  63. package/dist/types/src/helpers/common.d.ts.map +1 -1
  64. package/dist/types/src/helpers/load.d.ts +1 -1
  65. package/dist/types/src/helpers/load.d.ts.map +1 -1
  66. package/dist/types/src/helpers/upload.d.ts +1 -1
  67. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  68. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  69. package/dist/types/src/index.d.ts +3 -2
  70. package/dist/types/src/index.d.ts.map +1 -1
  71. package/dist/types/src/operations/create-file.d.ts +5 -0
  72. package/dist/types/src/operations/create-file.d.ts.map +1 -0
  73. package/dist/types/src/operations/create.d.ts +5 -0
  74. package/dist/types/src/operations/create.d.ts.map +1 -0
  75. package/dist/types/src/operations/definitions.d.ts +38 -0
  76. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  77. package/dist/types/src/operations/index.d.ts +4 -0
  78. package/dist/types/src/operations/index.d.ts.map +1 -0
  79. package/dist/types/src/operations/upload.d.ts +5 -0
  80. package/dist/types/src/operations/upload.d.ts.map +1 -0
  81. package/dist/types/src/translations.d.ts +24 -15
  82. package/dist/types/src/translations.d.ts.map +1 -1
  83. package/dist/types/src/types/File.d.ts +1 -1
  84. package/dist/types/src/types/File.d.ts.map +1 -1
  85. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  86. package/dist/types/src/types/types.d.ts +1 -104
  87. package/dist/types/src/types/types.d.ts.map +1 -1
  88. package/dist/types/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +62 -37
  90. package/src/WnfsPlugin.node.ts +47 -0
  91. package/src/WnfsPlugin.test.ts +27 -0
  92. package/src/WnfsPlugin.tsx +40 -39
  93. package/src/blockstore.ts +1 -1
  94. package/src/capabilities/{blockstore/blockstore.ts → blockstore.ts} +4 -3
  95. package/src/capabilities/{file-uploader/file-uploader.ts → file-uploader.ts} +6 -5
  96. package/src/capabilities/index.ts +11 -5
  97. package/src/capabilities/markdown.ts +38 -0
  98. package/src/capabilities/operation-handler.ts +16 -0
  99. package/src/capabilities/react-surface.tsx +60 -0
  100. package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
  101. package/src/components/FileInput/index.ts +5 -0
  102. package/src/components/FilePreview/FilePreview.tsx +43 -0
  103. package/src/components/FilePreview/index.ts +5 -0
  104. package/src/components/index.ts +1 -4
  105. package/src/{components → containers/FileContainer}/FileContainer.tsx +12 -11
  106. package/src/containers/FileContainer/index.ts +5 -0
  107. package/src/containers/index.ts +7 -0
  108. package/src/extensions/image.stories.tsx +9 -10
  109. package/src/extensions/image.tsx +2 -1
  110. package/src/helpers/load.ts +6 -6
  111. package/src/helpers/upload.ts +3 -3
  112. package/src/index.ts +8 -2
  113. package/src/meta.ts +1 -1
  114. package/src/operations/create-file.ts +31 -0
  115. package/src/operations/create.ts +22 -0
  116. package/src/operations/definitions.ts +41 -0
  117. package/src/operations/index.ts +13 -0
  118. package/src/operations/upload.ts +29 -0
  119. package/src/translations.ts +13 -12
  120. package/src/types/File.ts +6 -2
  121. package/src/types/capabilities.ts +3 -3
  122. package/src/types/types.ts +3 -59
  123. package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +0 -91
  124. package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +0 -7
  125. package/dist/lib/browser/blockstore-KKFOALUH.mjs +0 -191
  126. package/dist/lib/browser/blockstore-KKFOALUH.mjs.map +0 -7
  127. package/dist/lib/browser/chunk-GXXEH7H6.mjs +0 -154
  128. package/dist/lib/browser/chunk-GXXEH7H6.mjs.map +0 -7
  129. package/dist/lib/browser/chunk-NCTUASHL.mjs.map +0 -7
  130. package/dist/lib/browser/file-uploader-BUHAXRSV.mjs +0 -34
  131. package/dist/lib/browser/file-uploader-BUHAXRSV.mjs.map +0 -7
  132. package/dist/lib/browser/markdown-BRT2MN6C.mjs +0 -201
  133. package/dist/lib/browser/markdown-BRT2MN6C.mjs.map +0 -7
  134. package/dist/lib/browser/operation-resolver-F6GUL54A.mjs +0 -99
  135. package/dist/lib/browser/operation-resolver-F6GUL54A.mjs.map +0 -7
  136. package/dist/lib/browser/react-surface-UNAYSIAC.mjs +0 -81
  137. package/dist/lib/browser/react-surface-UNAYSIAC.mjs.map +0 -7
  138. package/dist/types/src/capabilities/blockstore/blockstore.d.ts +0 -5
  139. package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +0 -1
  140. package/dist/types/src/capabilities/blockstore/index.d.ts +0 -3
  141. package/dist/types/src/capabilities/blockstore/index.d.ts.map +0 -1
  142. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +0 -5
  143. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +0 -1
  144. package/dist/types/src/capabilities/file-uploader/index.d.ts +0 -3
  145. package/dist/types/src/capabilities/file-uploader/index.d.ts.map +0 -1
  146. package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
  147. package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
  148. package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
  149. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
  150. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  151. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  152. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  153. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  154. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  155. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  157. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  158. package/dist/types/src/components/FileContainer.d.ts +0 -7
  159. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  160. package/dist/types/src/components/FileInput.d.ts.map +0 -1
  161. package/dist/types/src/components/FilePreview.d.ts +0 -11
  162. package/dist/types/src/components/FilePreview.d.ts.map +0 -1
  163. package/src/capabilities/blockstore/index.ts +0 -7
  164. package/src/capabilities/file-uploader/index.ts +0 -7
  165. package/src/capabilities/markdown/index.ts +0 -7
  166. package/src/capabilities/markdown/markdown.ts +0 -33
  167. package/src/capabilities/operation-resolver/index.ts +0 -7
  168. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -62
  169. package/src/capabilities/react-surface/index.ts +0 -7
  170. package/src/capabilities/react-surface/react-surface.tsx +0 -49
  171. package/src/components/FilePreview.tsx +0 -23
  172. /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
@@ -1,33 +0,0 @@
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
- );
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const OperationResolver = Capability.lazy('OperationResolver', () => import('./operation-resolver'));
@@ -1,62 +0,0 @@
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
- );
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -1,49 +0,0 @@
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
- );
@@ -1,23 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type ThemedClassName } from '@dxos/react-ui';
8
- import { mx } from '@dxos/ui-theme';
9
-
10
- export type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;
11
-
12
- /**
13
- * File/content preview iframe.
14
- */
15
- export const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {
16
- if (type.startsWith('image/')) {
17
- return <img className={mx('is-full bs-full object-contain', classNames)} src={url} />;
18
- } else if (type.startsWith('video/')) {
19
- return <video className={mx('is-full bs-full object-contain', classNames)} src={url} controls />;
20
- } else {
21
- return <iframe className={mx('is-full bs-full overflow-auto', classNames)} src={url} />;
22
- }
23
- };