@dxos/plugin-wnfs 0.8.4-main.ead640a → 0.8.4-main.effb148878

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 (158) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +2 -2
  3. package/dist/lib/neutral/WnfsPlugin.mjs +39 -0
  4. package/dist/lib/neutral/WnfsPlugin.mjs.map +7 -0
  5. package/dist/lib/neutral/WnfsPlugin.node.mjs +12 -0
  6. package/dist/lib/neutral/WnfsPlugin.node.mjs.map +7 -0
  7. package/dist/lib/neutral/WnfsPlugin.workerd.mjs +12 -0
  8. package/dist/lib/neutral/WnfsPlugin.workerd.mjs.map +7 -0
  9. package/dist/lib/neutral/backend-DHBQUTPC.mjs +47 -0
  10. package/dist/lib/neutral/backend-DHBQUTPC.mjs.map +7 -0
  11. package/dist/lib/neutral/blockstore-3NLSWC7Z.mjs +190 -0
  12. package/dist/lib/neutral/blockstore-3NLSWC7Z.mjs.map +7 -0
  13. package/dist/lib/neutral/capabilities/index.mjs +13 -0
  14. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  15. package/dist/lib/{browser/chunk-D6VTEQIE.mjs → neutral/chunk-7KFJ6LYH.mjs} +43 -18
  16. package/dist/lib/neutral/chunk-7KFJ6LYH.mjs.map +7 -0
  17. package/dist/lib/neutral/chunk-IY6VOJSQ.mjs +37 -0
  18. package/dist/lib/neutral/chunk-IY6VOJSQ.mjs.map +7 -0
  19. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  20. package/dist/lib/neutral/chunk-QODCKFTY.mjs +19 -0
  21. package/dist/lib/neutral/chunk-QODCKFTY.mjs.map +7 -0
  22. package/dist/lib/neutral/helpers/index.mjs +26 -0
  23. package/dist/lib/neutral/helpers/index.mjs.map +7 -0
  24. package/dist/lib/neutral/index.mjs +34 -0
  25. package/dist/lib/neutral/index.mjs.map +7 -0
  26. package/dist/lib/neutral/meta.json +1 -0
  27. package/dist/lib/neutral/meta.mjs +8 -0
  28. package/dist/lib/neutral/meta.mjs.map +7 -0
  29. package/dist/lib/neutral/plugin.mjs +12 -0
  30. package/dist/lib/neutral/plugin.mjs.map +7 -0
  31. package/dist/lib/neutral/translations.mjs +17 -0
  32. package/dist/lib/neutral/translations.mjs.map +7 -0
  33. package/dist/lib/neutral/types/index.mjs +8 -0
  34. package/dist/lib/neutral/types/index.mjs.map +7 -0
  35. package/dist/lib/neutral/url-resolver-UD3ZP77Y.mjs +47 -0
  36. package/dist/lib/neutral/url-resolver-UD3ZP77Y.mjs.map +7 -0
  37. package/dist/types/src/WnfsPlugin.d.ts +3 -1
  38. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  39. package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
  40. package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
  41. package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
  42. package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
  43. package/dist/types/src/WnfsPlugin.workerd.d.ts +4 -0
  44. package/dist/types/src/WnfsPlugin.workerd.d.ts.map +1 -0
  45. package/dist/types/src/blockstore.d.ts.map +1 -1
  46. package/dist/types/src/capabilities/backend.d.ts +7 -0
  47. package/dist/types/src/capabilities/backend.d.ts.map +1 -0
  48. package/dist/types/src/capabilities/blockstore.d.ts +3 -2
  49. package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
  50. package/dist/types/src/capabilities/index.d.ts +5 -6
  51. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  52. package/dist/types/src/capabilities/url-resolver.d.ts +7 -0
  53. package/dist/types/src/capabilities/url-resolver.d.ts.map +1 -0
  54. package/dist/types/src/helpers/common.d.ts.map +1 -1
  55. package/dist/types/src/helpers/load.d.ts +1 -1
  56. package/dist/types/src/helpers/load.d.ts.map +1 -1
  57. package/dist/types/src/helpers/upload.d.ts +1 -1
  58. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  59. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  60. package/dist/types/src/index.d.ts +2 -2
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/meta.d.ts +2 -2
  63. package/dist/types/src/meta.d.ts.map +1 -1
  64. package/dist/types/src/plugin.d.ts +3 -0
  65. package/dist/types/src/plugin.d.ts.map +1 -0
  66. package/dist/types/src/translations.d.ts +2 -12
  67. package/dist/types/src/translations.d.ts.map +1 -1
  68. package/dist/types/src/types/WnfsCapabilities.d.ts +11 -0
  69. package/dist/types/src/types/WnfsCapabilities.d.ts.map +1 -0
  70. package/dist/types/src/types/index.d.ts +1 -2
  71. package/dist/types/src/types/index.d.ts.map +1 -1
  72. package/dist/types/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +95 -48
  74. package/src/WnfsPlugin.node.ts +11 -0
  75. package/src/WnfsPlugin.test.ts +20 -0
  76. package/src/WnfsPlugin.tsx +27 -78
  77. package/src/WnfsPlugin.workerd.ts +11 -0
  78. package/src/blockstore.ts +1 -1
  79. package/src/capabilities/backend.ts +43 -0
  80. package/src/capabilities/blockstore.ts +14 -10
  81. package/src/capabilities/index.ts +12 -7
  82. package/src/capabilities/url-resolver.ts +44 -0
  83. package/src/helpers/load.ts +12 -7
  84. package/src/helpers/upload.ts +5 -2
  85. package/src/index.ts +2 -2
  86. package/src/meta.ts +24 -4
  87. package/src/plugin.ts +9 -0
  88. package/src/translations.ts +2 -11
  89. package/src/types/WnfsCapabilities.ts +18 -0
  90. package/src/types/index.ts +1 -2
  91. package/dist/lib/browser/FileContainer-A4OJVMVS.mjs +0 -103
  92. package/dist/lib/browser/FileContainer-A4OJVMVS.mjs.map +0 -7
  93. package/dist/lib/browser/blockstore-HK4IYHJJ.mjs +0 -273
  94. package/dist/lib/browser/blockstore-HK4IYHJJ.mjs.map +0 -7
  95. package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
  96. package/dist/lib/browser/chunk-FYRZOKHG.mjs +0 -13
  97. package/dist/lib/browser/chunk-FYRZOKHG.mjs.map +0 -7
  98. package/dist/lib/browser/chunk-PAIK4SJ3.mjs +0 -16
  99. package/dist/lib/browser/chunk-PAIK4SJ3.mjs.map +0 -7
  100. package/dist/lib/browser/chunk-QQB5IBX7.mjs +0 -64
  101. package/dist/lib/browser/chunk-QQB5IBX7.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-Y5JMTQ74.mjs +0 -16
  103. package/dist/lib/browser/chunk-Y5JMTQ74.mjs.map +0 -7
  104. package/dist/lib/browser/file-uploader-5S37ZZCW.mjs +0 -30
  105. package/dist/lib/browser/file-uploader-5S37ZZCW.mjs.map +0 -7
  106. package/dist/lib/browser/index.mjs +0 -117
  107. package/dist/lib/browser/index.mjs.map +0 -7
  108. package/dist/lib/browser/intent-resolver-3KMIEDBO.mjs +0 -49
  109. package/dist/lib/browser/intent-resolver-3KMIEDBO.mjs.map +0 -7
  110. package/dist/lib/browser/markdown-5XD3I2NQ.mjs +0 -209
  111. package/dist/lib/browser/markdown-5XD3I2NQ.mjs.map +0 -7
  112. package/dist/lib/browser/meta.json +0 -1
  113. package/dist/lib/browser/react-surface-5D7M3Y4W.mjs +0 -88
  114. package/dist/lib/browser/react-surface-5D7M3Y4W.mjs.map +0 -7
  115. package/dist/lib/browser/types/index.mjs +0 -10
  116. package/dist/types/src/capabilities/capabilities.d.ts +0 -12
  117. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  118. package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
  119. package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
  120. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  121. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  122. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  123. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  124. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  125. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  126. package/dist/types/src/components/FileContainer.d.ts +0 -9
  127. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  128. package/dist/types/src/components/FileInput.d.ts +0 -8
  129. package/dist/types/src/components/FileInput.d.ts.map +0 -1
  130. package/dist/types/src/components/FilePreview.d.ts +0 -11
  131. package/dist/types/src/components/FilePreview.d.ts.map +0 -1
  132. package/dist/types/src/components/index.d.ts +0 -3
  133. package/dist/types/src/components/index.d.ts.map +0 -1
  134. package/dist/types/src/extensions/image.d.ts +0 -14
  135. package/dist/types/src/extensions/image.d.ts.map +0 -1
  136. package/dist/types/src/extensions/image.stories.d.ts +0 -11
  137. package/dist/types/src/extensions/image.stories.d.ts.map +0 -1
  138. package/dist/types/src/extensions/index.d.ts +0 -2
  139. package/dist/types/src/extensions/index.d.ts.map +0 -1
  140. package/dist/types/src/types/file.d.ts +0 -16
  141. package/dist/types/src/types/file.d.ts.map +0 -1
  142. package/dist/types/src/types/types.d.ts +0 -51
  143. package/dist/types/src/types/types.d.ts.map +0 -1
  144. package/src/capabilities/capabilities.ts +0 -18
  145. package/src/capabilities/file-uploader.ts +0 -27
  146. package/src/capabilities/intent-resolver.ts +0 -33
  147. package/src/capabilities/markdown.ts +0 -26
  148. package/src/capabilities/react-surface.tsx +0 -45
  149. package/src/components/FileContainer.tsx +0 -49
  150. package/src/components/FileInput.tsx +0 -47
  151. package/src/components/FilePreview.tsx +0 -23
  152. package/src/components/index.ts +0 -9
  153. package/src/extensions/image.stories.tsx +0 -104
  154. package/src/extensions/image.tsx +0 -203
  155. package/src/extensions/index.ts +0 -5
  156. package/src/types/file.ts +0 -17
  157. package/src/types/types.ts +0 -41
  158. /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
@@ -1,88 +0,0 @@
1
- import {
2
- FileType,
3
- WnfsAction
4
- } from "./chunk-QQB5IBX7.mjs";
5
- import {
6
- meta
7
- } from "./chunk-FYRZOKHG.mjs";
8
-
9
- // src/capabilities/react-surface.tsx
10
- import React2, { useCallback as useCallback2 } from "react";
11
- import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
12
- import { Obj } from "@dxos/echo";
13
- import { findAnnotation as findAnnotation2 } from "@dxos/effect";
14
-
15
- // src/components/index.ts
16
- import { lazy } from "react";
17
-
18
- // src/components/FileInput.tsx
19
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
20
- import React, { useCallback } from "react";
21
- import { useDropzone } from "react-dropzone";
22
- import { findAnnotation } from "@dxos/effect";
23
- import { useTranslation } from "@dxos/react-ui";
24
- import { mx } from "@dxos/react-ui-theme";
25
- var FileInput = ({ schema, onChange }) => {
26
- var _effect = _useSignals();
27
- try {
28
- const { t } = useTranslation(meta.id);
29
- const accept = findAnnotation(schema.ast, WnfsAction.UploadAnnotationId);
30
- const onDropAccepted = useCallback((files) => onChange?.(files[0]), [
31
- onChange
32
- ]);
33
- const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
34
- multiple: false,
35
- accept,
36
- onDropAccepted
37
- });
38
- return /* @__PURE__ */ React.createElement("div", {
39
- ...getRootProps(),
40
- className: mx("flex flex-col items-center p-8 border border-separator", isFocused && "focus-ring", isDragAccept && "bg-attention", isDragReject && "border-error")
41
- }, /* @__PURE__ */ React.createElement("input", getInputProps()), acceptedFiles[0] ? /* @__PURE__ */ React.createElement("p", null, acceptedFiles[0].name) : /* @__PURE__ */ React.createElement("p", null, t("file input placeholder")));
42
- } finally {
43
- _effect.f();
44
- }
45
- };
46
-
47
- // src/components/index.ts
48
- var FileContainer = lazy(() => import("./FileContainer-A4OJVMVS.mjs"));
49
-
50
- // src/capabilities/react-surface.tsx
51
- var react_surface_default = (() => contributes(Capabilities.ReactSurface, [
52
- createSurface({
53
- id: `${meta.id}/article`,
54
- role: [
55
- "article",
56
- "section",
57
- "slide"
58
- ],
59
- filter: (data) => Obj.instanceOf(FileType, data.subject),
60
- component: ({ data, role }) => /* @__PURE__ */ React2.createElement(FileContainer, {
61
- role,
62
- file: data.subject
63
- })
64
- }),
65
- createSurface({
66
- id: `${meta.id}/create-form`,
67
- role: "form-input",
68
- filter: (data) => {
69
- const annotation = findAnnotation2(data.schema.ast, WnfsAction.UploadAnnotationId);
70
- return !!annotation;
71
- },
72
- component: ({ data: { prop, schema }, ...props }) => {
73
- const inputProps = props;
74
- const handleChange = useCallback2((file) => inputProps.onValueChange?.("object", file), [
75
- prop,
76
- inputProps.onValueChange
77
- ]);
78
- return /* @__PURE__ */ React2.createElement(FileInput, {
79
- schema,
80
- onChange: handleChange
81
- });
82
- }
83
- })
84
- ]));
85
- export {
86
- react_surface_default as default
87
- };
88
- //# sourceMappingURL=react-surface-5D7M3Y4W.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useCallback } from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { findAnnotation } from '@dxos/effect';\nimport { type InputProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../components';\nimport { meta } from '../meta';\nimport { FileType, WnfsAction } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${meta.id}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: FileType } => Obj.instanceOf(FileType, data.subject),\n component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,\n }),\n createSurface({\n id: `${meta.id}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {\n const annotation = findAnnotation<boolean>(\n (data.schema as Schema.Schema.All).ast,\n WnfsAction.UploadAnnotationId,\n );\n return !!annotation;\n },\n component: ({ data: { prop, schema }, ...props }) => {\n const inputProps = props as unknown as InputProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.('object', file),\n [prop, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport const FileContainer = lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useCallback } from 'react';\nimport { useDropzone } from 'react-dropzone';\n\nimport { findAnnotation } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\nimport { WnfsAction } from '../types';\n\nexport type FileInputProps = {\n schema: Schema.Schema.Any;\n onChange: (file: File) => void;\n};\n\nexport const FileInput = ({ schema, onChange }: FileInputProps) => {\n const { t } = useTranslation(meta.id);\n const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);\n\n const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);\n\n const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({\n multiple: false,\n accept,\n onDropAccepted,\n });\n\n return (\n <div\n {...getRootProps()}\n className={mx(\n 'flex flex-col items-center p-8 border border-separator',\n isFocused && 'focus-ring',\n isDragAccept && 'bg-attention',\n isDragReject && 'border-error',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;;;;;AAKA,OAAOA,UAASC,eAAAA,oBAAmB;AAEnC,SAASC,cAAcC,aAAaC,qBAAqB;AACzD,SAASC,WAAW;AACpB,SAASC,kBAAAA,uBAAsB;;;ACL/B,SAASC,YAAY;;;;ACCrB,OAAOC,SAASC,mBAAmB;AACnC,SAASC,mBAAmB;AAE5B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,UAAU;AAUZ,IAAMC,YAAY,CAAC,EAAEC,QAAQC,SAAQ,MAAkB;;;AAC5D,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAMC,SAASC,eAAyCP,OAAOQ,KAAKC,WAAWC,kBAAkB;AAEjG,UAAMC,iBAAiBC,YAAY,CAACC,UAAkBZ,WAAWY,MAAM,CAAA,CAAE,GAAG;MAACZ;KAAS;AAEtF,UAAM,EAAEa,eAAeC,cAAcC,eAAeC,WAAWC,cAAcC,aAAY,IAAKC,YAAY;MACxGC,UAAU;MACVf;MACAK;IACF,CAAA;AAEA,WACE,sBAAA,cAACW,OAAAA;MACE,GAAGP,aAAAA;MACJQ,WAAWC,GACT,0DACAP,aAAa,cACbC,gBAAgB,gBAChBC,gBAAgB,cAAA;OAGlB,sBAAA,cAACM,SAAUT,cAAAA,CAAAA,GACVF,cAAc,CAAA,IAAK,sBAAA,cAACY,KAAAA,MAAGZ,cAAc,CAAA,EAAGa,IAAI,IAAQ,sBAAA,cAACD,KAAAA,MAAGxB,EAAE,wBAAA,CAAA,CAAA;;;;AAGjE;;;ADxCO,IAAM0B,gBAAgBC,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ADU/C,IAAA,yBAAe,MACbC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;MAAC;MAAW;MAAW;;IAC7BC,QAAQ,CAACC,SAAwCC,IAAIC,WAAWC,UAAUH,KAAKI,OAAO;IACtFC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAO,gBAAAQ,OAAA,cAACC,eAAAA;MAAcT;MAAYU,MAAMR,KAAKI;;EACvE,CAAA;EACAT,cAAc;IACZC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SAAAA;AACP,YAAMS,aAAaC,gBAChBV,KAAKW,OAA6BC,KACnCC,WAAWC,kBAAkB;AAE/B,aAAO,CAAC,CAACL;IACX;IACAJ,WAAW,CAAC,EAAEL,MAAM,EAAEe,MAAMJ,OAAM,GAAI,GAAGK,MAAAA,MAAO;AAC9C,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACX,SAAeS,WAAWG,gBAAgB,UAAUZ,IAAAA,GACrD;QAACO;QAAME,WAAWG;OAAc;AAGlC,aAAO,gBAAAd,OAAA,cAACe,WAAAA;QAAUV;QAAgBW,UAAUJ;;IAC9C;EACF,CAAA;CACD;",
6
- "names": ["React", "useCallback", "Capabilities", "contributes", "createSurface", "Obj", "findAnnotation", "lazy", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "meta", "id", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "lazy", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "FileType", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
7
- }
@@ -1,10 +0,0 @@
1
- import {
2
- FileType,
3
- WnfsAction
4
- } from "../chunk-QQB5IBX7.mjs";
5
- import "../chunk-FYRZOKHG.mjs";
6
- export {
7
- FileType,
8
- WnfsAction
9
- };
10
- //# sourceMappingURL=index.mjs.map
@@ -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,wFAAmE,CAAC;IAE3F,KAAY,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACzF,MAAM,SAAS,uDAAiE,CAAC;CACzF"}
@@ -1,4 +0,0 @@
1
- import { Capabilities, type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<import("@dxos/app-framework").InterfaceDef<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":"AAOA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAoC,MAAM,qBAAqB,CAAC;yBAKzF,SAAS,aAAa;AAAtC,wBAcE"}
@@ -1,4 +0,0 @@
1
- import { Capabilities, type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<import("@dxos/app-framework").InterfaceDef<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/app-framework").InterfaceDef<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<import("@dxos/app-framework").InterfaceDef<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,KAAmB,MAAM,OAAO,CAAC;AAUxC,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,6BAuBzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,8 +0,0 @@
1
- import type * as Schema from 'effect/Schema';
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,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,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,11 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- declare const meta: {
4
- title: string;
5
- render: () => React.JSX.Element;
6
- decorators: import("@storybook/react").Decorator[];
7
- };
8
- export default meta;
9
- type Story = StoryObj<typeof meta>;
10
- export declare const Default: Story;
11
- //# 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,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAgD,MAAM,OAAO,CAAC;AAuFrE,QAAA,MAAM,IAAI;;;;CAI2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,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 * as Schema from 'effect/Schema';
2
- declare const FileType_base: import("@dxos/echo/internal").TypedObjectPrototype<import("@dxos/echo/internal").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/internal").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,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;;;AAIxC,qBAAa,QAAS,SAAQ,aAQ5B;CAAG"}
@@ -1,51 +0,0 @@
1
- import * as Schema from 'effect/Schema';
2
- import { FileType } from './file';
3
- export declare namespace WnfsAction {
4
- const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
5
- readonly _tag: Schema.tag<`${string}/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, `${string}/action/upload`, {
28
- readonly _tag: Schema.tag<`${string}/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,KAAK,MAAM,MAAM,eAAe,CAAC;AAOxC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,yBAAiB,UAAU,CAAC;;;;;;;;;;;;;;;;;IAC1B,MAAM,OAAO,MAAO,SAAQ,WAK1B;KAAG;IAEL,MAAM,CAAC,MAAM,kBAAkB,eAA6C,CAAC;IAE7E,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 { meta } from '../meta';
12
-
13
- export namespace WnfsCapabilities {
14
- export const Blockstore = defineCapability<Blockstore>(`${meta.id}/capability/blockstore`);
15
-
16
- export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;
17
- export const Instances = defineCapability<Instances>(`${meta.id}/capability/instances`);
18
- }
@@ -1,27 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Effect from 'effect/Effect';
6
- import * as Function from 'effect/Function';
7
-
8
- import { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';
9
- import { SpaceAction } from '@dxos/plugin-space/types';
10
-
11
- import { WnfsAction } from '../types';
12
-
13
- export default (context: PluginContext) => {
14
- return contributes(Capabilities.FileUploader, (file, space) => {
15
- const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
16
-
17
- const program = Effect.gen(function* () {
18
- const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));
19
- yield* dispatch(
20
- Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })),
21
- );
22
- return fileInfo;
23
- });
24
-
25
- return Effect.runPromise(program);
26
- });
27
- };
@@ -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 * as Schema from 'effect/Schema';
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 { meta } from '../meta';
15
- import { FileType, WnfsAction } from '../types';
16
-
17
- export default () =>
18
- contributes(Capabilities.ReactSurface, [
19
- createSurface({
20
- id: `${meta.id}/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: `${meta.id}/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,49 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { 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 { useAsyncEffect } from '@dxos/react-ui';
11
- import { StackItem } from '@dxos/react-ui-stack';
12
-
13
- import { WnfsCapabilities } from '../capabilities';
14
- import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
15
- import { type FileType } from '../types';
16
-
17
- import { FilePreview } from './FilePreview';
18
-
19
- export type FileContainerProps = {
20
- role: string;
21
- file: FileType;
22
- };
23
-
24
- export const FileContainer = ({ file }: FileContainerProps) => {
25
- const blockstore = useCapability(WnfsCapabilities.Blockstore);
26
- const instances = useCapability(WnfsCapabilities.Instances);
27
- const [blobUrl, setBlobUrl] = useState<string>();
28
-
29
- useAsyncEffect(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
- }, [file]);
37
-
38
- if (!blobUrl) {
39
- return null;
40
- }
41
-
42
- return (
43
- <StackItem.Content>
44
- <FilePreview type={file.type} url={blobUrl} />
45
- </StackItem.Content>
46
- );
47
- };
48
-
49
- export default FileContainer;
@@ -1,47 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import type * as Schema from 'effect/Schema';
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 { meta } 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(meta.id);
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';