@dxos/plugin-wnfs 0.8.3 → 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 (168) 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-YYAW4U6J.mjs → chunk-7KFJ6LYH.mjs} +49 -24
  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 +19 -105
  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 +8 -6
  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 +3 -1
  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 +3 -2
  34. package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
  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 +4 -2
  38. package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/index.d.ts +13 -6
  40. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/markdown.d.ts +4 -2
  42. package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
  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 +3 -2
  46. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  47. package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +1 -1
  48. package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
  49. package/dist/types/src/components/FileInput/index.d.ts +2 -0
  50. package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
  51. package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
  52. package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
  53. package/dist/types/src/components/FilePreview/index.d.ts +2 -0
  54. package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
  55. package/dist/types/src/components/index.d.ts +1 -4
  56. package/dist/types/src/components/index.d.ts.map +1 -1
  57. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  58. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  59. package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
  60. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  61. package/dist/types/src/containers/index.d.ts +3 -0
  62. package/dist/types/src/containers/index.d.ts.map +1 -0
  63. package/dist/types/src/extensions/image.d.ts +1 -1
  64. package/dist/types/src/extensions/image.d.ts.map +1 -1
  65. package/dist/types/src/extensions/image.stories.d.ts +5 -4
  66. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  67. package/dist/types/src/helpers/common.d.ts.map +1 -1
  68. package/dist/types/src/helpers/load.d.ts +2 -2
  69. package/dist/types/src/helpers/load.d.ts.map +1 -1
  70. package/dist/types/src/helpers/upload.d.ts +1 -1
  71. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  72. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  73. package/dist/types/src/index.d.ts +3 -2
  74. package/dist/types/src/index.d.ts.map +1 -1
  75. package/dist/types/src/meta.d.ts +2 -3
  76. package/dist/types/src/meta.d.ts.map +1 -1
  77. package/dist/types/src/operations/create-file.d.ts +5 -0
  78. package/dist/types/src/operations/create-file.d.ts.map +1 -0
  79. package/dist/types/src/operations/create.d.ts +5 -0
  80. package/dist/types/src/operations/create.d.ts.map +1 -0
  81. package/dist/types/src/operations/definitions.d.ts +38 -0
  82. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  83. package/dist/types/src/operations/index.d.ts +4 -0
  84. package/dist/types/src/operations/index.d.ts.map +1 -0
  85. package/dist/types/src/operations/upload.d.ts +5 -0
  86. package/dist/types/src/operations/upload.d.ts.map +1 -0
  87. package/dist/types/src/translations.d.ts +27 -13
  88. package/dist/types/src/translations.d.ts.map +1 -1
  89. package/dist/types/src/types/File.d.ts +16 -0
  90. package/dist/types/src/types/File.d.ts.map +1 -0
  91. package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
  92. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  93. package/dist/types/src/types/index.d.ts +2 -1
  94. package/dist/types/src/types/index.d.ts.map +1 -1
  95. package/dist/types/src/types/types.d.ts +4 -46
  96. package/dist/types/src/types/types.d.ts.map +1 -1
  97. package/dist/types/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +79 -49
  99. package/src/WnfsPlugin.node.ts +19 -0
  100. package/src/WnfsPlugin.test.ts +27 -0
  101. package/src/WnfsPlugin.tsx +42 -85
  102. package/src/blockstore.ts +3 -3
  103. package/src/capabilities/blockstore.ts +15 -10
  104. package/src/capabilities/create-object.ts +33 -0
  105. package/src/capabilities/file-uploader.ts +25 -15
  106. package/src/capabilities/index.ts +11 -8
  107. package/src/capabilities/markdown.ts +25 -12
  108. package/src/capabilities/operation-handler.ts +16 -0
  109. package/src/capabilities/react-surface.tsx +50 -35
  110. package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +8 -8
  111. package/src/components/FileInput/index.ts +5 -0
  112. package/src/components/FilePreview/FilePreview.tsx +43 -0
  113. package/src/components/FilePreview/index.ts +5 -0
  114. package/src/components/index.ts +1 -4
  115. package/src/containers/FileContainer/FileContainer.tsx +57 -0
  116. package/src/containers/FileContainer/index.ts +5 -0
  117. package/src/containers/index.ts +7 -0
  118. package/src/extensions/image.stories.tsx +22 -19
  119. package/src/extensions/image.tsx +10 -9
  120. package/src/helpers/load.ts +14 -8
  121. package/src/helpers/upload.ts +6 -2
  122. package/src/index.ts +8 -2
  123. package/src/meta.ts +9 -6
  124. package/src/operations/create-file.ts +31 -0
  125. package/src/operations/create.ts +22 -0
  126. package/src/operations/definitions.ts +41 -0
  127. package/src/operations/index.ts +13 -0
  128. package/src/operations/upload.ts +29 -0
  129. package/src/translations.ts +19 -11
  130. package/src/types/File.ts +28 -0
  131. package/src/{capabilities → types}/capabilities.ts +4 -4
  132. package/src/types/index.ts +2 -1
  133. package/src/types/types.ts +3 -19
  134. package/dist/lib/browser/FileContainer-7YOCEQ6P.mjs +0 -106
  135. package/dist/lib/browser/FileContainer-7YOCEQ6P.mjs.map +0 -7
  136. package/dist/lib/browser/blockstore-UT7233RJ.mjs +0 -191
  137. package/dist/lib/browser/blockstore-UT7233RJ.mjs.map +0 -7
  138. package/dist/lib/browser/chunk-DL7BBH57.mjs +0 -16
  139. package/dist/lib/browser/chunk-DL7BBH57.mjs.map +0 -7
  140. package/dist/lib/browser/chunk-PHTWWADN.mjs +0 -15
  141. package/dist/lib/browser/chunk-PHTWWADN.mjs.map +0 -7
  142. package/dist/lib/browser/chunk-SCL6PT4P.mjs +0 -64
  143. package/dist/lib/browser/chunk-SCL6PT4P.mjs.map +0 -7
  144. package/dist/lib/browser/chunk-WJVYRUYQ.mjs +0 -16
  145. package/dist/lib/browser/chunk-WJVYRUYQ.mjs.map +0 -7
  146. package/dist/lib/browser/chunk-YYAW4U6J.mjs.map +0 -7
  147. package/dist/lib/browser/file-uploader-RHINBPDQ.mjs +0 -29
  148. package/dist/lib/browser/file-uploader-RHINBPDQ.mjs.map +0 -7
  149. package/dist/lib/browser/intent-resolver-JDRRPIZC.mjs +0 -49
  150. package/dist/lib/browser/intent-resolver-JDRRPIZC.mjs.map +0 -7
  151. package/dist/lib/browser/markdown-BWBHUHHH.mjs +0 -196
  152. package/dist/lib/browser/markdown-BWBHUHHH.mjs.map +0 -7
  153. package/dist/lib/browser/react-surface-6GM4J4YG.mjs +0 -88
  154. package/dist/lib/browser/react-surface-6GM4J4YG.mjs.map +0 -7
  155. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  157. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  158. package/dist/types/src/components/FileContainer.d.ts +0 -8
  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/dist/types/src/types/file.d.ts +0 -16
  164. package/dist/types/src/types/file.d.ts.map +0 -1
  165. package/src/capabilities/intent-resolver.ts +0 -32
  166. package/src/components/FileContainer.tsx +0 -46
  167. package/src/components/FilePreview.tsx +0 -23
  168. package/src/types/file.ts +0 -17
@@ -1,46 +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
- const FileContainer = ({ file, role }: { file: FileType; role: string }) => {
18
- const blockstore = useCapability(WnfsCapabilities.Blockstore);
19
- const instances = useCapability(WnfsCapabilities.Instances);
20
- const [blobUrl, setBlobUrl] = useState<string>();
21
-
22
- useEffect(() => {
23
- const timeout = setTimeout(async () => {
24
- const space = getSpace(file);
25
- invariant(space);
26
- const { directory, forest } = await loadWnfs({ blockstore, instances, space });
27
- const path = filePath(file.cid.toString(), space);
28
- const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
29
- setBlobUrl(url);
30
- });
31
-
32
- return () => clearTimeout(timeout);
33
- }, [file]);
34
-
35
- if (!blobUrl) {
36
- return null;
37
- }
38
-
39
- return (
40
- <StackItem.Content role={role}>
41
- <FilePreview type={file.type} url={blobUrl} />
42
- </StackItem.Content>
43
- );
44
- };
45
-
46
- export default FileContainer;
@@ -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/react-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('w-full h-full object-contain', classNames)} src={url} />;
18
- } else if (type.startsWith('video/')) {
19
- return <video className={mx('w-full h-full object-contain', classNames)} src={url} controls />;
20
- } else {
21
- return <iframe className={mx('w-full h-full overflow-auto', classNames)} src={url} />;
22
- }
23
- };
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
- }) {}