@dxos/plugin-wnfs 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (162) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +371 -0
  3. package/README.md +2 -2
  4. package/dist/lib/neutral/WnfsPlugin.mjs +51 -0
  5. package/dist/lib/neutral/WnfsPlugin.mjs.map +7 -0
  6. package/dist/lib/neutral/WnfsPlugin.node.mjs +12 -0
  7. package/dist/lib/neutral/WnfsPlugin.node.mjs.map +7 -0
  8. package/dist/lib/neutral/WnfsPlugin.workerd.mjs +12 -0
  9. package/dist/lib/neutral/WnfsPlugin.workerd.mjs.map +7 -0
  10. package/dist/lib/neutral/backend-4HPTHS33.mjs +47 -0
  11. package/dist/lib/neutral/backend-4HPTHS33.mjs.map +7 -0
  12. package/dist/lib/{browser/blockstore-PSYZCC2O.mjs → neutral/blockstore-U6SPNL2C.mjs} +12 -13
  13. package/dist/lib/neutral/blockstore-U6SPNL2C.mjs.map +7 -0
  14. package/dist/lib/neutral/capabilities/index.mjs +13 -0
  15. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  17. package/dist/lib/neutral/chunk-KUQHRT52.mjs +39 -0
  18. package/dist/lib/neutral/chunk-KUQHRT52.mjs.map +7 -0
  19. package/dist/lib/{browser/chunk-D6VTEQIE.mjs → neutral/chunk-L33MOD23.mjs} +85 -25
  20. package/dist/lib/neutral/chunk-L33MOD23.mjs.map +7 -0
  21. package/dist/lib/neutral/chunk-QODCKFTY.mjs +19 -0
  22. package/dist/lib/neutral/chunk-QODCKFTY.mjs.map +7 -0
  23. package/dist/lib/neutral/helpers/index.mjs +26 -0
  24. package/dist/lib/neutral/helpers/index.mjs.map +7 -0
  25. package/dist/lib/neutral/index.mjs +36 -0
  26. package/dist/lib/neutral/index.mjs.map +7 -0
  27. package/dist/lib/neutral/meta.json +1 -0
  28. package/dist/lib/neutral/meta.mjs +8 -0
  29. package/dist/lib/neutral/meta.mjs.map +7 -0
  30. package/dist/lib/neutral/plugin.mjs +12 -0
  31. package/dist/lib/neutral/plugin.mjs.map +7 -0
  32. package/dist/lib/neutral/translations.mjs +17 -0
  33. package/dist/lib/neutral/translations.mjs.map +7 -0
  34. package/dist/lib/neutral/types/index.mjs +8 -0
  35. package/dist/lib/neutral/types/index.mjs.map +7 -0
  36. package/dist/lib/neutral/url-resolver-BIRH7WHL.mjs +47 -0
  37. package/dist/lib/neutral/url-resolver-BIRH7WHL.mjs.map +7 -0
  38. package/dist/types/src/WnfsPlugin.d.ts +3 -1
  39. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  40. package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
  41. package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
  42. package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
  43. package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
  44. package/dist/types/src/WnfsPlugin.workerd.d.ts +4 -0
  45. package/dist/types/src/WnfsPlugin.workerd.d.ts.map +1 -0
  46. package/dist/types/src/annotations.d.ts +7 -0
  47. package/dist/types/src/annotations.d.ts.map +1 -0
  48. package/dist/types/src/blockstore.d.ts.map +1 -1
  49. package/dist/types/src/capabilities/backend.d.ts +7 -0
  50. package/dist/types/src/capabilities/backend.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/blockstore.d.ts +3 -2
  52. package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
  53. package/dist/types/src/capabilities/index.d.ts +5 -6
  54. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  55. package/dist/types/src/capabilities/url-resolver.d.ts +7 -0
  56. package/dist/types/src/capabilities/url-resolver.d.ts.map +1 -0
  57. package/dist/types/src/helpers/common.d.ts.map +1 -1
  58. package/dist/types/src/helpers/load.d.ts +1 -1
  59. package/dist/types/src/helpers/load.d.ts.map +1 -1
  60. package/dist/types/src/helpers/upload.d.ts +1 -1
  61. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  62. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  63. package/dist/types/src/index.d.ts +3 -2
  64. package/dist/types/src/index.d.ts.map +1 -1
  65. package/dist/types/src/meta.d.ts +2 -3
  66. package/dist/types/src/meta.d.ts.map +1 -1
  67. package/dist/types/src/plugin.d.ts +3 -0
  68. package/dist/types/src/plugin.d.ts.map +1 -0
  69. package/dist/types/src/translations.d.ts +2 -12
  70. package/dist/types/src/translations.d.ts.map +1 -1
  71. package/dist/types/src/types/WnfsCapabilities.d.ts +11 -0
  72. package/dist/types/src/types/WnfsCapabilities.d.ts.map +1 -0
  73. package/dist/types/src/types/index.d.ts +1 -2
  74. package/dist/types/src/types/index.d.ts.map +1 -1
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +86 -51
  77. package/src/WnfsPlugin.node.ts +11 -0
  78. package/src/WnfsPlugin.test.ts +20 -0
  79. package/src/WnfsPlugin.tsx +42 -84
  80. package/src/WnfsPlugin.workerd.ts +11 -0
  81. package/src/annotations.ts +16 -0
  82. package/src/blockstore.ts +1 -1
  83. package/src/capabilities/backend.ts +43 -0
  84. package/src/capabilities/blockstore.ts +14 -10
  85. package/src/capabilities/index.ts +12 -7
  86. package/src/capabilities/url-resolver.ts +44 -0
  87. package/src/helpers/load.ts +37 -18
  88. package/src/helpers/upload.ts +14 -2
  89. package/src/index.ts +3 -2
  90. package/src/meta.ts +26 -7
  91. package/src/plugin.ts +9 -0
  92. package/src/translations.ts +2 -11
  93. package/src/types/WnfsCapabilities.ts +18 -0
  94. package/src/types/index.ts +1 -2
  95. package/src/vite-env.d.ts +10 -0
  96. package/dist/lib/browser/FileContainer-LTKYOYSO.mjs +0 -105
  97. package/dist/lib/browser/FileContainer-LTKYOYSO.mjs.map +0 -7
  98. package/dist/lib/browser/blockstore-PSYZCC2O.mjs.map +0 -7
  99. package/dist/lib/browser/chunk-CW4BENRQ.mjs +0 -64
  100. package/dist/lib/browser/chunk-CW4BENRQ.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
  103. package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
  104. package/dist/lib/browser/chunk-VDDGZWAY.mjs +0 -15
  105. package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
  106. package/dist/lib/browser/chunk-ZMH2OULB.mjs +0 -16
  107. package/dist/lib/browser/chunk-ZMH2OULB.mjs.map +0 -7
  108. package/dist/lib/browser/file-uploader-YRZPRETS.mjs +0 -29
  109. package/dist/lib/browser/file-uploader-YRZPRETS.mjs.map +0 -7
  110. package/dist/lib/browser/index.mjs +0 -118
  111. package/dist/lib/browser/index.mjs.map +0 -7
  112. package/dist/lib/browser/intent-resolver-CKGJNE6P.mjs +0 -49
  113. package/dist/lib/browser/intent-resolver-CKGJNE6P.mjs.map +0 -7
  114. package/dist/lib/browser/markdown-RAGCVYGE.mjs +0 -198
  115. package/dist/lib/browser/markdown-RAGCVYGE.mjs.map +0 -7
  116. package/dist/lib/browser/meta.json +0 -1
  117. package/dist/lib/browser/react-surface-HGWZDLP2.mjs +0 -88
  118. package/dist/lib/browser/react-surface-HGWZDLP2.mjs.map +0 -7
  119. package/dist/lib/browser/types/index.mjs +0 -10
  120. package/dist/types/src/capabilities/capabilities.d.ts +0 -12
  121. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  122. package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
  123. package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
  124. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  125. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  126. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  127. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  128. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  129. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  130. package/dist/types/src/components/FileContainer.d.ts +0 -9
  131. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  132. package/dist/types/src/components/FileInput.d.ts +0 -8
  133. package/dist/types/src/components/FileInput.d.ts.map +0 -1
  134. package/dist/types/src/components/FilePreview.d.ts +0 -11
  135. package/dist/types/src/components/FilePreview.d.ts.map +0 -1
  136. package/dist/types/src/components/index.d.ts +0 -3
  137. package/dist/types/src/components/index.d.ts.map +0 -1
  138. package/dist/types/src/extensions/image.d.ts +0 -14
  139. package/dist/types/src/extensions/image.d.ts.map +0 -1
  140. package/dist/types/src/extensions/image.stories.d.ts +0 -10
  141. package/dist/types/src/extensions/image.stories.d.ts.map +0 -1
  142. package/dist/types/src/extensions/index.d.ts +0 -2
  143. package/dist/types/src/extensions/index.d.ts.map +0 -1
  144. package/dist/types/src/types/file.d.ts +0 -16
  145. package/dist/types/src/types/file.d.ts.map +0 -1
  146. package/dist/types/src/types/types.d.ts +0 -51
  147. package/dist/types/src/types/types.d.ts.map +0 -1
  148. package/src/capabilities/capabilities.ts +0 -18
  149. package/src/capabilities/file-uploader.ts +0 -24
  150. package/src/capabilities/intent-resolver.ts +0 -33
  151. package/src/capabilities/markdown.ts +0 -26
  152. package/src/capabilities/react-surface.tsx +0 -45
  153. package/src/components/FileContainer.tsx +0 -52
  154. package/src/components/FileInput.tsx +0 -47
  155. package/src/components/FilePreview.tsx +0 -23
  156. package/src/components/index.ts +0 -9
  157. package/src/extensions/image.stories.tsx +0 -101
  158. package/src/extensions/image.tsx +0 -203
  159. package/src/extensions/index.ts +0 -5
  160. package/src/types/file.ts +0 -17
  161. package/src/types/types.ts +0 -41
  162. /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
@@ -1,12 +0,0 @@
1
- import { type Blockstore } from 'interface-blockstore';
2
- import { type PrivateDirectory, type PrivateForest } from 'wnfs';
3
- import { type SpaceId } from '@dxos/keys';
4
- export declare namespace WnfsCapabilities {
5
- const Blockstore: import("@dxos/app-framework").InterfaceDef<Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>>;
6
- type Instances = Record<SpaceId, {
7
- directory: PrivateDirectory;
8
- forest: PrivateForest;
9
- }>;
10
- const Instances: import("@dxos/app-framework").InterfaceDef<Instances>;
11
- }
12
- //# sourceMappingURL=capabilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGjE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,yBAAiB,gBAAgB,CAAC;IACzB,MAAM,UAAU,wFAAuE,CAAC;IAE/F,KAAY,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACzF,MAAM,SAAS,uDAAqE,CAAC;CAC7F"}
@@ -1,4 +0,0 @@
1
- import { Capabilities, type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<Capabilities.FileUploader>;
3
- export default _default;
4
- //# sourceMappingURL=file-uploader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/file-uploader.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAoC,MAAM,qBAAqB,CAAC;yBAKzF,SAAS,aAAa;AAAtC,wBAYE"}
@@ -1,4 +0,0 @@
1
- import { Capabilities, type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<Capabilities.IntentResolver>;
3
- export default _default;
4
- //# sourceMappingURL=intent-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAA+B,MAAM,qBAAqB,CAAC;yBAQpF,SAAS,aAAa;AAAtC,wBAoBK"}
@@ -1,4 +0,0 @@
1
- import { type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>;
3
- export default _default;
4
- //# sourceMappingURL=markdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/markdown.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,qBAAqB,CAAC;yBAQtD,SAAS,aAAa;AAAtC,wBAaK"}
@@ -1,4 +0,0 @@
1
- import { Capabilities } from '@dxos/app-framework';
2
- declare const _default: () => import("@dxos/app-framework").Capability<Capabilities.ReactSurface>;
3
- export default _default;
4
- //# sourceMappingURL=react-surface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAA8B,MAAM,qBAAqB,CAAC;;AAS/E,wBA4BK"}
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { type FileType } from '../types';
3
- export type FileContainerProps = {
4
- role: string;
5
- file: FileType;
6
- };
7
- export declare const FileContainer: ({ file }: FileContainerProps) => React.JSX.Element | null;
8
- export default FileContainer;
9
- //# sourceMappingURL=FileContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/FileContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,kBAAkB,6BA2BzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,8 +0,0 @@
1
- import { type Schema } from 'effect';
2
- import React from 'react';
3
- export type FileInputProps = {
4
- schema: Schema.Schema.Any;
5
- onChange: (file: File) => void;
6
- };
7
- export declare const FileInput: ({ schema, onChange }: FileInputProps) => React.JSX.Element;
8
- //# sourceMappingURL=FileInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../src/components/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAsB,MAAM,OAAO,CAAC;AAU3C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,cAAc,sBA0B7D,CAAC"}
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { type ThemedClassName } from '@dxos/react-ui';
3
- export type FilePreviewProps = ThemedClassName<{
4
- type: string;
5
- url: string;
6
- }>;
7
- /**
8
- * File/content preview iframe.
9
- */
10
- export declare const FilePreview: ({ type, url, classNames }: FilePreviewProps) => React.JSX.Element;
11
- //# sourceMappingURL=FilePreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/FilePreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,2BAA2B,gBAAgB,sBAQtE,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const FileContainer: import("react").LazyExoticComponent<({ file }: import("./FileContainer").FileContainerProps) => import("react").JSX.Element | null>;
2
- export * from './FileInput';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,qIAAwC,CAAC;AAEnE,cAAc,aAAa,CAAC"}
@@ -1,14 +0,0 @@
1
- import { type Extension } from '@codemirror/state';
2
- import type { Blockstore } from 'interface-blockstore';
3
- import { type Space } from '@dxos/react-client/echo';
4
- import { type WnfsCapabilities } from '../capabilities';
5
- export type ImageOptions = {
6
- blockstore: Blockstore;
7
- instances: WnfsCapabilities.Instances;
8
- space: Space;
9
- };
10
- /**
11
- * Create WNFS image decorations.
12
- */
13
- export declare const image: (options: ImageOptions) => Extension[];
14
- //# sourceMappingURL=image.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAA0B,MAAM,mBAAmB,CAAC;AAE7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAMrD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKxD,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,YAAY,KAAG,SAAS,EAgDtD,CAAC"}
@@ -1,10 +0,0 @@
1
- import '@dxos-theme';
2
- import React from 'react';
3
- declare const _default: {
4
- title: string;
5
- render: () => React.JSX.Element;
6
- decorators: import("@storybook/react").Decorator[];
7
- };
8
- export default _default;
9
- export declare const Default: {};
10
- //# sourceMappingURL=image.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAgD,MAAM,OAAO,CAAC;;;;;;AAuFrE,wBAIE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './image';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC"}
@@ -1,16 +0,0 @@
1
- import { Schema } from 'effect';
2
- declare const FileType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<{
3
- name: Schema.optional<typeof Schema.String>;
4
- type: typeof Schema.String;
5
- cid: typeof Schema.String;
6
- timestamp: Schema.optional<typeof Schema.String>;
7
- }, import("@dxos/echo-schema").TypedObjectOptions>, Schema.Struct.Encoded<{
8
- name: Schema.optional<typeof Schema.String>;
9
- type: typeof Schema.String;
10
- cid: typeof Schema.String;
11
- timestamp: Schema.optional<typeof Schema.String>;
12
- }>>;
13
- export declare class FileType extends FileType_base {
14
- }
15
- export {};
16
- //# sourceMappingURL=file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../src/types/file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;AAIhC,qBAAa,QAAS,SAAQ,aAQ5B;CAAG"}
@@ -1,51 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { FileType } from './file';
3
- export declare namespace WnfsAction {
4
- const Create_base: Schema.TaggedClass<Create, "dxos.org/plugin/wnfs/action/create", {
5
- readonly _tag: Schema.tag<"dxos.org/plugin/wnfs/action/create">;
6
- } & {
7
- input: Schema.SchemaClass<{
8
- readonly name: string;
9
- readonly type: string;
10
- readonly cid: string;
11
- }, {
12
- readonly name: string;
13
- readonly type: string;
14
- readonly cid: string;
15
- }, never>;
16
- output: Schema.Struct<{
17
- object: typeof FileType;
18
- }>;
19
- }>;
20
- export class Create extends Create_base {
21
- }
22
- export const UploadAnnotationId: unique symbol;
23
- export const UploadFileSchema: Schema.Struct<{
24
- file: Schema.instanceOf<File>;
25
- }>;
26
- export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
27
- const Upload_base: Schema.TaggedClass<Upload, "dxos.org/plugin/wnfs/action/upload", {
28
- readonly _tag: Schema.tag<"dxos.org/plugin/wnfs/action/upload">;
29
- } & {
30
- input: Schema.extend<Schema.Struct<{
31
- file: Schema.instanceOf<File>;
32
- }>, Schema.Struct<{
33
- space: Schema.Schema<import("@dxos/client-protocol").Space, import("@dxos/client-protocol").Space, never>;
34
- }>>;
35
- output: Schema.SchemaClass<{
36
- readonly name: string;
37
- readonly type: string;
38
- readonly cid: string;
39
- readonly url: string;
40
- }, {
41
- readonly name: string;
42
- readonly type: string;
43
- readonly cid: string;
44
- readonly url: string;
45
- }, never>;
46
- }>;
47
- export class Upload extends Upload_base {
48
- }
49
- export {};
50
- }
51
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,yBAAiB,UAAU,CAAC;;;;;;;;;;;;;;;;;IAC1B,MAAM,OAAO,MAAO,SAAQ,WAK1B;KAAG;IAEL,MAAM,CAAC,MAAM,kBAAkB,eAAiD,CAAC;IAEjF,MAAM,CAAC,MAAM,gBAAgB;;MAS3B,CAAC;IAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;IAEzE,MAAM,OAAO,MAAO,SAAQ,WAG1B;KAAG;;CACN"}
@@ -1,18 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Blockstore } from 'interface-blockstore';
6
- import { type PrivateDirectory, type PrivateForest } from 'wnfs';
7
-
8
- import { defineCapability } from '@dxos/app-framework';
9
- import { type SpaceId } from '@dxos/keys';
10
-
11
- import { WNFS_PLUGIN } from '../meta';
12
-
13
- export namespace WnfsCapabilities {
14
- export const Blockstore = defineCapability<Blockstore>(`${WNFS_PLUGIN}/capability/blockstore`);
15
-
16
- export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;
17
- export const Instances = defineCapability<Instances>(`${WNFS_PLUGIN}/capability/instances`);
18
- }
@@ -1,24 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Effect, pipe } from 'effect';
6
-
7
- import { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';
8
- import { SpaceAction } from '@dxos/plugin-space/types';
9
-
10
- import { WnfsAction } from '../types';
11
-
12
- export default (context: PluginContext) => {
13
- return contributes(Capabilities.FileUploader, (file, space) => {
14
- const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
15
-
16
- const program = Effect.gen(function* () {
17
- const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));
18
- yield* dispatch(pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })));
19
- return fileInfo;
20
- });
21
-
22
- return Effect.runPromise(program);
23
- });
24
- };
@@ -1,33 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
6
- import { Obj } from '@dxos/echo';
7
-
8
- import { upload } from '../helpers';
9
- import { FileType, WnfsAction } from '../types';
10
-
11
- import { WnfsCapabilities } from './capabilities';
12
-
13
- export default (context: PluginContext) =>
14
- contributes(Capabilities.IntentResolver, [
15
- // TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
16
- // Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
17
- createResolver({
18
- intent: WnfsAction.Create,
19
- resolve: ({ name, type, cid }) => ({
20
- data: {
21
- object: Obj.make(FileType, { name, type, cid }),
22
- },
23
- }),
24
- }),
25
- createResolver({
26
- intent: WnfsAction.Upload,
27
- resolve: async ({ file, space }) => {
28
- const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
29
- const info = await upload({ file, blockstore, space });
30
- return { data: info };
31
- },
32
- }),
33
- ]);
@@ -1,26 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type PluginContext, contributes } from '@dxos/app-framework';
6
- import { MarkdownCapabilities } from '@dxos/plugin-markdown';
7
- import { getSpace } from '@dxos/react-client/echo';
8
-
9
- import { image } from '../extensions';
10
-
11
- import { WnfsCapabilities } from './capabilities';
12
-
13
- export default (context: PluginContext) =>
14
- contributes(MarkdownCapabilities.Extensions, [
15
- ({ document }) => {
16
- const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
17
- const instances = context.getCapability(WnfsCapabilities.Instances);
18
-
19
- if (document) {
20
- const space = getSpace(document);
21
- return space ? [image({ blockstore, instances, space })] : [];
22
- }
23
-
24
- return [];
25
- },
26
- ]);
@@ -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 { Capabilities, contributes, 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,52 +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 { WnfsCapabilities } from '../capabilities';
13
- import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
14
- import { type FileType } from '../types';
15
-
16
- import { FilePreview } from './FilePreview';
17
-
18
- export type FileContainerProps = {
19
- role: string;
20
- file: FileType;
21
- };
22
-
23
- export const FileContainer = ({ file }: FileContainerProps) => {
24
- const blockstore = useCapability(WnfsCapabilities.Blockstore);
25
- const instances = useCapability(WnfsCapabilities.Instances);
26
- const [blobUrl, setBlobUrl] = useState<string>();
27
-
28
- useEffect(() => {
29
- const timeout = setTimeout(async () => {
30
- const space = getSpace(file);
31
- invariant(space);
32
- const { directory, forest } = await loadWnfs({ blockstore, instances, space });
33
- const path = filePath(file.cid.toString(), space);
34
- const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
35
- setBlobUrl(url);
36
- });
37
-
38
- return () => clearTimeout(timeout);
39
- }, [file]);
40
-
41
- if (!blobUrl) {
42
- return null;
43
- }
44
-
45
- return (
46
- <StackItem.Content>
47
- <FilePreview type={file.type} url={blobUrl} />
48
- </StackItem.Content>
49
- );
50
- };
51
-
52
- export default FileContainer;
@@ -1,47 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
- import React, { useCallback } from 'react';
7
- import { useDropzone } from 'react-dropzone';
8
-
9
- import { findAnnotation } from '@dxos/effect';
10
- import { useTranslation } from '@dxos/react-ui';
11
- import { mx } from '@dxos/react-ui-theme';
12
-
13
- import { WNFS_PLUGIN } from '../meta';
14
- import { WnfsAction } from '../types';
15
-
16
- export type FileInputProps = {
17
- schema: Schema.Schema.Any;
18
- onChange: (file: File) => void;
19
- };
20
-
21
- export const FileInput = ({ schema, onChange }: FileInputProps) => {
22
- const { t } = useTranslation(WNFS_PLUGIN);
23
- const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);
24
-
25
- const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);
26
-
27
- const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
28
- multiple: false,
29
- accept,
30
- onDropAccepted,
31
- });
32
-
33
- return (
34
- <div
35
- {...getRootProps()}
36
- className={mx(
37
- 'flex flex-col items-center p-8 border border-separator',
38
- isFocused && 'focus-ring',
39
- isDragAccept && 'bg-attention',
40
- isDragReject && 'border-error',
41
- )}
42
- >
43
- <input {...getInputProps()} />
44
- {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}
45
- </div>
46
- );
47
- };
@@ -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
- };
@@ -1,9 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { lazy } from 'react';
6
-
7
- export const FileContainer = lazy(() => import('./FileContainer'));
8
-
9
- export * from './FileInput';
@@ -1,101 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import type { Blockstore } from 'interface-blockstore';
8
- import React, { type ChangeEvent, useEffect, useState } from 'react';
9
-
10
- import { faker } from '@dxos/random';
11
- import { useSpace } from '@dxos/react-client/echo';
12
- import { withClientProvider } from '@dxos/react-client/testing';
13
- import { useThemeContext } from '@dxos/react-ui';
14
- import {
15
- createBasicExtensions,
16
- createMarkdownExtensions,
17
- createThemeExtensions,
18
- decorateMarkdown,
19
- processEditorPayload,
20
- useTextEditor,
21
- } from '@dxos/react-ui-editor';
22
- import { withLayout, withTheme } from '@dxos/storybook-utils';
23
-
24
- import { create as createBlockstore } from '../blockstore';
25
- import { upload } from '../helpers';
26
-
27
- import { image } from './image';
28
-
29
- faker.seed(1);
30
- const initialValue = faker.lorem.paragraphs(100);
31
- const instances = {};
32
-
33
- const Story = () => {
34
- const { themeMode } = useThemeContext();
35
- const space = useSpace();
36
- const [blockstore, setBlockstore] = useState<Blockstore>();
37
-
38
- useEffect(() => {
39
- if (space) {
40
- console.log('SPACE ID', space.id);
41
- }
42
-
43
- const create = async () => {
44
- // NOTE: We don't pass in the URL of the Blob service, so we don't use it.
45
- const bs = createBlockstore();
46
- await bs.open();
47
- setBlockstore(bs);
48
- };
49
-
50
- create().catch(console.error);
51
- }, [space]);
52
-
53
- const { parentRef, view, focusAttributes } = useTextEditor(
54
- () => ({
55
- initialValue,
56
- extensions: [
57
- createBasicExtensions(),
58
- createMarkdownExtensions({ themeMode }),
59
- createThemeExtensions({ themeMode, syntaxHighlighting: true }),
60
- blockstore && space ? [image({ blockstore, instances, space })] : [],
61
- decorateMarkdown(),
62
- ],
63
- }),
64
- [themeMode, blockstore, space],
65
- );
66
-
67
- const onFileChange = async (event: ChangeEvent<HTMLInputElement>) => {
68
- const file = event.target.files?.[0];
69
- if (file) {
70
- if (blockstore) {
71
- if (space) {
72
- const info = await upload({ blockstore, file, space });
73
- if (info && view) {
74
- processEditorPayload(view, { type: 'image', data: info.url });
75
- }
76
- } else {
77
- console.warn('Space is undefined.');
78
- }
79
- } else {
80
- console.warn("Blockstore hasn't been initialised yet.");
81
- }
82
- }
83
- };
84
-
85
- return (
86
- <>
87
- <div className='mb-2'>
88
- <input type='file' accept='image/*' onChange={onFileChange} />
89
- </div>
90
- <div className='w-[50rem]' ref={parentRef} {...focusAttributes} />
91
- </>
92
- );
93
- };
94
-
95
- export default {
96
- title: 'plugins/plugin-wnfs/image',
97
- render: Story,
98
- decorators: [withClientProvider({ createIdentity: true, createSpace: true }), withTheme, withLayout()],
99
- };
100
-
101
- export const Default = {};