@dxos/plugin-wnfs 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae

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 (151) hide show
  1. package/dist/lib/browser/FileContainer-EILNV5LV.mjs +74 -0
  2. package/dist/lib/browser/FileContainer-EILNV5LV.mjs.map +7 -0
  3. package/dist/lib/browser/{blockstore-KQO2NTVM.mjs → blockstore-Q66HQJ4Q.mjs} +19 -19
  4. package/dist/lib/browser/blockstore-Q66HQJ4Q.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-BXGCJRL2.mjs +155 -0
  6. package/dist/lib/browser/chunk-BXGCJRL2.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-HXVPBJ3A.mjs +56 -0
  8. package/dist/lib/browser/chunk-HXVPBJ3A.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-VRRXG6IB.mjs → chunk-UC4HMNZZ.mjs} +24 -14
  10. package/dist/lib/browser/chunk-UC4HMNZZ.mjs.map +7 -0
  11. package/dist/lib/browser/file-uploader-QL4DTOMM.mjs +35 -0
  12. package/dist/lib/browser/file-uploader-QL4DTOMM.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +85 -86
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/{markdown-6VH477GB.mjs → markdown-AYCVG6TJ.mjs} +31 -26
  16. package/dist/lib/browser/markdown-AYCVG6TJ.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/operation-resolver-YYWUF6EY.mjs +99 -0
  19. package/dist/lib/browser/operation-resolver-YYWUF6EY.mjs.map +7 -0
  20. package/dist/lib/browser/react-surface-3LKVDPH7.mjs +60 -0
  21. package/dist/lib/browser/react-surface-3LKVDPH7.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +9 -6
  23. package/dist/types/src/WnfsPlugin.d.ts +2 -1
  24. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/blockstore/blockstore.d.ts +5 -0
  26. package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
  28. package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +6 -0
  30. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
  31. package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
  32. package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
  33. package/dist/types/src/capabilities/index.d.ts +5 -6
  34. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  36. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  38. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  40. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  42. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  44. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  46. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  47. package/dist/types/src/components/FileInput.d.ts +1 -1
  48. package/dist/types/src/components/FileInput.d.ts.map +1 -1
  49. package/dist/types/src/components/index.d.ts +1 -1
  50. package/dist/types/src/components/index.d.ts.map +1 -1
  51. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  52. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  53. package/dist/types/src/containers/FileContainer/index.d.ts +3 -0
  54. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  55. package/dist/types/src/containers/index.d.ts +3 -0
  56. package/dist/types/src/containers/index.d.ts.map +1 -0
  57. package/dist/types/src/extensions/image.d.ts +1 -1
  58. package/dist/types/src/extensions/image.d.ts.map +1 -1
  59. package/dist/types/src/extensions/image.stories.d.ts +5 -4
  60. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  61. package/dist/types/src/helpers/load.d.ts +2 -2
  62. package/dist/types/src/helpers/load.d.ts.map +1 -1
  63. package/dist/types/src/helpers/upload.d.ts +1 -1
  64. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  65. package/dist/types/src/index.d.ts +1 -1
  66. package/dist/types/src/index.d.ts.map +1 -1
  67. package/dist/types/src/meta.d.ts +2 -3
  68. package/dist/types/src/meta.d.ts.map +1 -1
  69. package/dist/types/src/translations.d.ts +6 -3
  70. package/dist/types/src/translations.d.ts.map +1 -1
  71. package/dist/types/src/types/File.d.ts +16 -0
  72. package/dist/types/src/types/File.d.ts.map +1 -0
  73. package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
  74. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  75. package/dist/types/src/types/index.d.ts +2 -1
  76. package/dist/types/src/types/index.d.ts.map +1 -1
  77. package/dist/types/src/types/types.d.ts +108 -47
  78. package/dist/types/src/types/types.d.ts.map +1 -1
  79. package/dist/types/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +48 -40
  81. package/src/WnfsPlugin.tsx +63 -80
  82. package/src/blockstore.ts +2 -2
  83. package/src/capabilities/blockstore/blockstore.ts +22 -0
  84. package/src/capabilities/blockstore/index.ts +7 -0
  85. package/src/capabilities/file-uploader/file-uploader.ts +34 -0
  86. package/src/capabilities/file-uploader/index.ts +7 -0
  87. package/src/capabilities/index.ts +5 -9
  88. package/src/capabilities/markdown/index.ts +7 -0
  89. package/src/capabilities/markdown/markdown.ts +33 -0
  90. package/src/capabilities/operation-resolver/index.ts +7 -0
  91. package/src/capabilities/operation-resolver/operation-resolver.ts +62 -0
  92. package/src/capabilities/react-surface/index.ts +7 -0
  93. package/src/capabilities/react-surface/react-surface.tsx +51 -0
  94. package/src/components/FileInput.tsx +6 -6
  95. package/src/components/FilePreview.tsx +1 -1
  96. package/src/components/index.ts +1 -4
  97. package/src/containers/FileContainer/FileContainer.tsx +58 -0
  98. package/src/containers/FileContainer/index.ts +7 -0
  99. package/src/containers/index.ts +7 -0
  100. package/src/extensions/image.stories.tsx +18 -14
  101. package/src/extensions/image.tsx +9 -9
  102. package/src/helpers/load.ts +14 -8
  103. package/src/helpers/upload.ts +6 -2
  104. package/src/index.ts +1 -1
  105. package/src/meta.ts +9 -6
  106. package/src/translations.ts +6 -3
  107. package/src/types/File.ts +24 -0
  108. package/src/{capabilities → types}/capabilities.ts +4 -4
  109. package/src/types/index.ts +2 -1
  110. package/src/types/types.ts +58 -17
  111. package/dist/lib/browser/FileContainer-6P2SYTVH.mjs +0 -105
  112. package/dist/lib/browser/FileContainer-6P2SYTVH.mjs.map +0 -7
  113. package/dist/lib/browser/blockstore-KQO2NTVM.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-GVBV2QWA.mjs +0 -64
  115. package/dist/lib/browser/chunk-GVBV2QWA.mjs.map +0 -7
  116. package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
  117. package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
  118. package/dist/lib/browser/chunk-VDDGZWAY.mjs +0 -15
  119. package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
  120. package/dist/lib/browser/chunk-VRRXG6IB.mjs.map +0 -7
  121. package/dist/lib/browser/chunk-WTYTESSC.mjs +0 -16
  122. package/dist/lib/browser/chunk-WTYTESSC.mjs.map +0 -7
  123. package/dist/lib/browser/file-uploader-JA55DPMW.mjs +0 -29
  124. package/dist/lib/browser/file-uploader-JA55DPMW.mjs.map +0 -7
  125. package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs +0 -49
  126. package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs.map +0 -7
  127. package/dist/lib/browser/markdown-6VH477GB.mjs.map +0 -7
  128. package/dist/lib/browser/react-surface-NOSB5MZ2.mjs +0 -88
  129. package/dist/lib/browser/react-surface-NOSB5MZ2.mjs.map +0 -7
  130. package/dist/types/src/capabilities/blockstore.d.ts +0 -4
  131. package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
  132. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  133. package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
  134. package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
  135. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  136. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  137. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  138. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  139. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  140. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  141. package/dist/types/src/components/FileContainer.d.ts +0 -9
  142. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  143. package/dist/types/src/types/file.d.ts +0 -16
  144. package/dist/types/src/types/file.d.ts.map +0 -1
  145. package/src/capabilities/blockstore.ts +0 -18
  146. package/src/capabilities/file-uploader.ts +0 -24
  147. package/src/capabilities/intent-resolver.ts +0 -32
  148. package/src/capabilities/markdown.ts +0 -25
  149. package/src/capabilities/react-surface.tsx +0 -45
  150. package/src/components/FileContainer.tsx +0 -51
  151. package/src/types/file.ts +0 -17
@@ -1,25 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { contributes, type PluginContext } from '@dxos/app-framework';
6
- import { MarkdownCapabilities } from '@dxos/plugin-markdown';
7
- import { getSpace } from '@dxos/react-client/echo';
8
-
9
- import { WnfsCapabilities } from './capabilities';
10
- import { image } from '../extensions';
11
-
12
- export default (context: PluginContext) =>
13
- contributes(MarkdownCapabilities.Extensions, [
14
- ({ document }) => {
15
- const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
16
- const instances = context.getCapability(WnfsCapabilities.Instances);
17
-
18
- if (document) {
19
- const space = getSpace(document);
20
- return space ? [image({ blockstore, instances, space })] : [];
21
- }
22
-
23
- return [];
24
- },
25
- ]);
@@ -1,45 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
- import React, { useCallback } from 'react';
7
-
8
- import { contributes, Capabilities, createSurface } from '@dxos/app-framework';
9
- import { Obj } from '@dxos/echo';
10
- import { findAnnotation } from '@dxos/effect';
11
- import { type InputProps } from '@dxos/react-ui-form';
12
-
13
- import { FileContainer, FileInput } from '../components';
14
- import { WNFS_PLUGIN } from '../meta';
15
- import { FileType, WnfsAction } from '../types';
16
-
17
- export default () =>
18
- contributes(Capabilities.ReactSurface, [
19
- createSurface({
20
- id: `${WNFS_PLUGIN}/article`,
21
- role: ['article', 'section', 'slide'],
22
- filter: (data): data is { subject: FileType } => Obj.instanceOf(FileType, data.subject),
23
- component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,
24
- }),
25
- createSurface({
26
- id: `${WNFS_PLUGIN}/create-form`,
27
- role: 'form-input',
28
- filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
29
- const annotation = findAnnotation<boolean>(
30
- (data.schema as Schema.Schema.All).ast,
31
- WnfsAction.UploadAnnotationId,
32
- );
33
- return !!annotation;
34
- },
35
- component: ({ data: { prop, schema }, ...props }) => {
36
- const inputProps = props as unknown as InputProps;
37
- const handleChange = useCallback(
38
- (file: File) => inputProps.onValueChange?.('object', file),
39
- [prop, inputProps.onValueChange],
40
- );
41
-
42
- return <FileInput schema={schema} onChange={handleChange} />;
43
- },
44
- }),
45
- ]);
@@ -1,51 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useEffect, useState } from 'react';
6
-
7
- import { useCapability } from '@dxos/app-framework';
8
- import { invariant } from '@dxos/invariant';
9
- import { getSpace } from '@dxos/react-client/echo';
10
- import { StackItem } from '@dxos/react-ui-stack';
11
-
12
- import { FilePreview } from './FilePreview';
13
- import { WnfsCapabilities } from '../capabilities';
14
- import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
15
- import { type FileType } from '../types';
16
-
17
- export type FileContainerProps = {
18
- role: string;
19
- file: FileType;
20
- };
21
-
22
- export const FileContainer = ({ file }: FileContainerProps) => {
23
- const blockstore = useCapability(WnfsCapabilities.Blockstore);
24
- const instances = useCapability(WnfsCapabilities.Instances);
25
- const [blobUrl, setBlobUrl] = useState<string>();
26
-
27
- useEffect(() => {
28
- const timeout = setTimeout(async () => {
29
- const space = getSpace(file);
30
- invariant(space);
31
- const { directory, forest } = await loadWnfs({ blockstore, instances, space });
32
- const path = filePath(file.cid.toString(), space);
33
- const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
34
- setBlobUrl(url);
35
- });
36
-
37
- return () => clearTimeout(timeout);
38
- }, [file]);
39
-
40
- if (!blobUrl) {
41
- return null;
42
- }
43
-
44
- return (
45
- <StackItem.Content>
46
- <FilePreview type={file.type} url={blobUrl} />
47
- </StackItem.Content>
48
- );
49
- };
50
-
51
- export default FileContainer;
package/src/types/file.ts DELETED
@@ -1,17 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { TypedObject } from '@dxos/echo-schema';
8
-
9
- export class FileType extends TypedObject({
10
- typename: 'dxos.org/type/File',
11
- version: '0.1.0',
12
- })({
13
- name: Schema.optional(Schema.String),
14
- type: Schema.String,
15
- cid: Schema.String,
16
- timestamp: Schema.optional(Schema.String),
17
- }) {}