@dxos/plugin-wnfs 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d

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 (82) hide show
  1. package/dist/lib/browser/{FileContainer-LTKYOYSO.mjs → FileContainer-LLNI7WXR.mjs} +34 -36
  2. package/dist/lib/browser/FileContainer-LLNI7WXR.mjs.map +7 -0
  3. package/dist/lib/browser/{blockstore-PSYZCC2O.mjs → blockstore-2JFU4NBU.mjs} +5 -5
  4. package/dist/lib/browser/{blockstore-PSYZCC2O.mjs.map → blockstore-2JFU4NBU.mjs.map} +1 -1
  5. package/dist/lib/browser/{chunk-CW4BENRQ.mjs → chunk-CWMKN2F6.mjs} +27 -20
  6. package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-F4QHZWQD.mjs +16 -0
  8. package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-OGPGLJCV.mjs +25 -0
  10. package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-ZFPJA5F4.mjs +16 -0
  12. package/dist/lib/browser/{file-uploader-YRZPRETS.mjs → file-uploader-W6TJLAAK.mjs} +11 -10
  13. package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +7 -0
  14. package/dist/lib/browser/index.mjs +13 -15
  15. package/dist/lib/browser/index.mjs.map +3 -3
  16. package/dist/lib/browser/{intent-resolver-CKGJNE6P.mjs → intent-resolver-FSW2EQF4.mjs} +8 -9
  17. package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +7 -0
  18. package/dist/lib/browser/{markdown-RAGCVYGE.mjs → markdown-WYQDCVFQ.mjs} +6 -6
  19. package/dist/lib/browser/{markdown-RAGCVYGE.mjs.map → markdown-WYQDCVFQ.mjs.map} +2 -2
  20. package/dist/lib/browser/meta.json +1 -1
  21. package/dist/lib/browser/{react-surface-HGWZDLP2.mjs → react-surface-DMU47U3X.mjs} +13 -13
  22. package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +7 -0
  23. package/dist/lib/browser/types/index.mjs +5 -5
  24. package/dist/types/src/WnfsPlugin.d.ts +1 -1
  25. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  26. package/dist/types/src/capabilities/blockstore.d.ts +1 -1
  27. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  28. package/dist/types/src/capabilities/file-uploader.d.ts +1 -1
  29. package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/index.d.ts +5 -5
  31. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  32. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  33. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  34. package/dist/types/src/capabilities/markdown.d.ts +1 -1
  35. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  36. package/dist/types/src/components/FileContainer.d.ts +2 -2
  37. package/dist/types/src/components/FileContainer.d.ts.map +1 -1
  38. package/dist/types/src/components/FileInput.d.ts +1 -1
  39. package/dist/types/src/components/FileInput.d.ts.map +1 -1
  40. package/dist/types/src/extensions/image.stories.d.ts +5 -4
  41. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  42. package/dist/types/src/meta.d.ts +0 -1
  43. package/dist/types/src/meta.d.ts.map +1 -1
  44. package/dist/types/src/translations.d.ts +2 -2
  45. package/dist/types/src/translations.d.ts.map +1 -1
  46. package/dist/types/src/types/File.d.ts +16 -0
  47. package/dist/types/src/types/File.d.ts.map +1 -0
  48. package/dist/types/src/types/index.d.ts +1 -1
  49. package/dist/types/src/types/index.d.ts.map +1 -1
  50. package/dist/types/src/types/types.d.ts +13 -9
  51. package/dist/types/src/types/types.d.ts.map +1 -1
  52. package/dist/types/tsconfig.tsbuildinfo +1 -1
  53. package/package.json +33 -34
  54. package/src/WnfsPlugin.tsx +71 -69
  55. package/src/capabilities/capabilities.ts +3 -3
  56. package/src/capabilities/file-uploader.ts +8 -5
  57. package/src/capabilities/intent-resolver.ts +2 -3
  58. package/src/capabilities/react-surface.tsx +6 -6
  59. package/src/components/FileContainer.tsx +21 -14
  60. package/src/components/FileInput.tsx +4 -4
  61. package/src/components/FilePreview.tsx +3 -3
  62. package/src/extensions/image.stories.tsx +14 -11
  63. package/src/extensions/image.tsx +5 -5
  64. package/src/meta.ts +7 -4
  65. package/src/translations.ts +2 -2
  66. package/src/types/File.ts +24 -0
  67. package/src/types/index.ts +1 -1
  68. package/src/types/types.ts +8 -8
  69. package/dist/lib/browser/FileContainer-LTKYOYSO.mjs.map +0 -7
  70. package/dist/lib/browser/chunk-CW4BENRQ.mjs.map +0 -7
  71. package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
  72. package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
  73. package/dist/lib/browser/chunk-VDDGZWAY.mjs +0 -15
  74. package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
  75. package/dist/lib/browser/chunk-ZMH2OULB.mjs +0 -16
  76. package/dist/lib/browser/file-uploader-YRZPRETS.mjs.map +0 -7
  77. package/dist/lib/browser/intent-resolver-CKGJNE6P.mjs.map +0 -7
  78. package/dist/lib/browser/react-surface-HGWZDLP2.mjs.map +0 -7
  79. package/dist/types/src/types/file.d.ts +0 -16
  80. package/dist/types/src/types/file.d.ts.map +0 -1
  81. package/src/types/file.ts +0 -17
  82. /package/dist/lib/browser/{chunk-ZMH2OULB.mjs.map → chunk-ZFPJA5F4.mjs.map} +0 -0
@@ -2,27 +2,27 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { FileInfoSchema } from '@dxos/app-framework';
8
8
  import { SpaceSchema } from '@dxos/react-client/echo';
9
9
 
10
- import { WNFS_PLUGIN } from '../meta';
10
+ import { meta } from '../meta';
11
11
 
12
- import { FileType } from './file';
12
+ import * as File from './File';
13
13
 
14
14
  export namespace WnfsAction {
15
- export class Create extends Schema.TaggedClass<Create>()(`${WNFS_PLUGIN}/action/create`, {
15
+ export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
16
16
  input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),
17
17
  output: Schema.Struct({
18
- object: FileType,
18
+ object: File.File,
19
19
  }),
20
20
  }) {}
21
21
 
22
- export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);
22
+ export const UploadAnnotationId = Symbol.for(`${meta.id}/annotation/upload`);
23
23
 
24
24
  export const UploadFileSchema = Schema.Struct({
25
- file: Schema.instanceOf(File).annotations({
25
+ file: Schema.instanceOf(File.File).annotations({
26
26
  [UploadAnnotationId]: {
27
27
  // Accept file types.
28
28
  'image/*': ['.jpg', '.jpeg', '.png', '.gif'],
@@ -34,7 +34,7 @@ export namespace WnfsAction {
34
34
 
35
35
  export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
36
36
 
37
- export class Upload extends Schema.TaggedClass<Upload>()(`${WNFS_PLUGIN}/action/upload`, {
37
+ export class Upload extends Schema.TaggedClass<Upload>()(`${meta.id}/action/upload`, {
38
38
  input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),
39
39
  output: Schema.required(FileInfoSchema),
40
40
  }) {}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/FileContainer.tsx", "../../../src/components/FilePreview.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { useCapability } from '@dxos/app-framework';\nimport { invariant } from '@dxos/invariant';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { WnfsCapabilities } from '../capabilities';\nimport { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';\nimport { type FileType } from '../types';\n\nimport { FilePreview } from './FilePreview';\n\nexport type FileContainerProps = {\n role: string;\n file: FileType;\n};\n\nexport const FileContainer = ({ file }: FileContainerProps) => {\n const blockstore = useCapability(WnfsCapabilities.Blockstore);\n const instances = useCapability(WnfsCapabilities.Instances);\n const [blobUrl, setBlobUrl] = useState<string>();\n\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const space = getSpace(file);\n invariant(space);\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const path = filePath(file.cid.toString(), space);\n const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });\n setBlobUrl(url);\n });\n\n return () => clearTimeout(timeout);\n }, [file]);\n\n if (!blobUrl) {\n return null;\n }\n\n return (\n <StackItem.Content>\n <FilePreview type={file.type} url={blobUrl} />\n </StackItem.Content>\n );\n};\n\nexport default FileContainer;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;\n\n/**\n * File/content preview iframe.\n */\nexport const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {\n if (type.startsWith('image/')) {\n return <img className={mx('w-full h-full object-contain', classNames)} src={url} />;\n } else if (type.startsWith('video/')) {\n return <video className={mx('w-full h-full object-contain', classNames)} src={url} controls />;\n } else {\n return <iframe className={mx('w-full h-full overflow-auto', classNames)} src={url} />;\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;AAIA,OAAOA,UAASC,WAAWC,gBAAgB;AAE3C,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;;;;ACL1B,OAAOC,WAAW;AAGlB,SAASC,UAAU;AAOZ,IAAMC,cAAc,CAAC,EAAEC,MAAMC,KAAKC,WAAU,MAAoB;;;AACrE,QAAIF,KAAKG,WAAW,QAAA,GAA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useEffect", "useState", "useCapability", "invariant", "getSpace", "StackItem", "React", "mx", "FilePreview", "type", "url", "classNames", "startsWith", "img", "className", "mx", "src", "video", "controls", "iframe", "FileContainer", "file", "blockstore", "useCapability", "WnfsCapabilities", "Blockstore", "instances", "Instances", "blobUrl", "setBlobUrl", "useState", "useEffect", "timeout", "setTimeout", "space", "getSpace", "invariant", "directory", "forest", "loadWnfs", "path", "filePath", "cid", "toString", "url", "getBlobUrl", "wnfsUrl", "type", "clearTimeout", "React", "StackItem", "Content", "FilePreview"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/file.ts", "../../../src/types/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { TypedObject } from '@dxos/echo-schema';\n\nexport class FileType extends TypedObject({\n typename: 'dxos.org/type/File',\n version: '0.1.0',\n})({\n name: Schema.optional(Schema.String),\n type: Schema.String,\n cid: Schema.String,\n timestamp: Schema.optional(Schema.String),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { FileInfoSchema } from '@dxos/app-framework';\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { WNFS_PLUGIN } from '../meta';\n\nimport { FileType } from './file';\n\nexport namespace WnfsAction {\n export class Create extends Schema.TaggedClass<Create>()(`${WNFS_PLUGIN}/action/create`, {\n input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),\n output: Schema.Struct({\n object: FileType,\n }),\n }) {}\n\n export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);\n\n export const UploadFileSchema = Schema.Struct({\n file: Schema.instanceOf(File).annotations({\n [UploadAnnotationId]: {\n // Accept file types.\n 'image/*': ['.jpg', '.jpeg', '.png', '.gif'],\n 'application/pdf': ['.pdf'],\n // TODO(wittjosiah): Add more file types.\n },\n }),\n });\n\n export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;\n\n export class Upload extends Schema.TaggedClass<Upload>()(`${WNFS_PLUGIN}/action/upload`, {\n input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),\n output: Schema.required(FileInfoSchema),\n }) {}\n}\n"],
5
- "mappings": ";;;;;AAIA,SAASA,cAAc;AAEvB,SAASC,mBAAmB;AAErB,IAAMC,WAAN,cAAuBC,YAAY;EACxCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,OAAOC,SAASD,OAAOE,MAAM;EACnCC,MAAMH,OAAOE;EACbE,KAAKJ,OAAOE;EACZG,WAAWL,OAAOC,SAASD,OAAOE,MAAM;AAC1C,CAAA,EAAA;AAAI;;;ACZJ,SAASI,UAAAA,eAAc;AAEvB,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;UAMXC,aAAAA;EACR,MAAMC,eAAeC,QAAOC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IACvFC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAKN,QAAOO,QAAQ;IACtEC,QAAQR,QAAOS,OAAO;MACpBC,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;cALSZ,SAAAA;cAOAa,qBAAqBC,OAAOC,IAAI,GAAGZ,WAAAA,oBAA+B;cAElEa,mBAAmBf,QAAOS,OAAO;IAC5CO,MAAMhB,QAAOiB,WAAWC,IAAAA,EAAMC,YAAY;MACxC,CAAArB,YAACc,kBAAAA,GAAqB;;QAEpB,WAAW;UAAC;UAAQ;UAAS;UAAQ;;QACrC,mBAAmB;UAAC;;MAEtB;IACF,CAAA;EACF,CAAA;EAIO,MAAMQ,eAAepB,QAAOC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IACvFC,OAAOH,QAAOqB,OAAMvB,YAACiB,kBAAkBf,QAAOS,OAAO;MAAEa,OAAOC;IAAY,CAAA,CAAA;IAC1Ef,QAAQR,QAAOO,SAASH,cAAAA;EAC1B,CAAA,EAAA;EAAI;cAHSgB,SAAAA;AAIf,GA3BiBtB,eAAAA,aAAAA,CAAAA,EAAAA;;",
6
- "names": ["Schema", "TypedObject", "FileType", "TypedObject", "typename", "version", "name", "Schema", "optional", "String", "type", "cid", "timestamp", "Schema", "FileInfoSchema", "SpaceSchema", "WnfsAction", "Create", "Schema", "TaggedClass", "WNFS_PLUGIN", "input", "FileInfoSchema", "pick", "pipe", "required", "output", "Struct", "object", "FileType", "UploadAnnotationId", "Symbol", "for", "UploadFileSchema", "file", "instanceOf", "File", "annotations", "Upload", "extend", "space", "SpaceSchema"]
7
- }
@@ -1,16 +0,0 @@
1
- import {
2
- WNFS_PLUGIN
3
- } from "./chunk-VDDGZWAY.mjs";
4
-
5
- // src/capabilities/capabilities.ts
6
- import { defineCapability } from "@dxos/app-framework";
7
- (function(WnfsCapabilities2) {
8
- WnfsCapabilities2.Blockstore = defineCapability(`${WNFS_PLUGIN}/capability/blockstore`);
9
- WnfsCapabilities2.Instances = defineCapability(`${WNFS_PLUGIN}/capability/instances`);
10
- })(WnfsCapabilities || (WnfsCapabilities = {}));
11
- var WnfsCapabilities;
12
-
13
- export {
14
- WnfsCapabilities
15
- };
16
- //# sourceMappingURL=chunk-KZANQHJY.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/capabilities.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Blockstore } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { defineCapability } from '@dxos/app-framework';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { WNFS_PLUGIN } from '../meta';\n\nexport namespace WnfsCapabilities {\n export const Blockstore = defineCapability<Blockstore>(`${WNFS_PLUGIN}/capability/blockstore`);\n\n export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;\n export const Instances = defineCapability<Instances>(`${WNFS_PLUGIN}/capability/instances`);\n}\n"],
5
- "mappings": ";;;;;AAOA,SAASA,wBAAwB;UAKhBC,mBAAAA;oBACFC,aAAaC,iBAA6B,GAAGC,WAAAA,wBAAmC;oBAGhFC,YAAYF,iBAA4B,GAAGC,WAAAA,uBAAkC;AAC5F,GALiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;;",
6
- "names": ["defineCapability", "WnfsCapabilities", "Blockstore", "defineCapability", "WNFS_PLUGIN", "Instances"]
7
- }
@@ -1,15 +0,0 @@
1
- // src/meta.ts
2
- var WNFS_PLUGIN = "dxos.org/plugin/wnfs";
3
- var meta = {
4
- id: WNFS_PLUGIN,
5
- name: "WNFS",
6
- description: "Manage and view files with via the Web Native File System (WNFS).",
7
- icon: "ph--file-cloud--regular",
8
- source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs"
9
- };
10
-
11
- export {
12
- WNFS_PLUGIN,
13
- meta
14
- };
15
- //# sourceMappingURL=chunk-VDDGZWAY.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const WNFS_PLUGIN = 'dxos.org/plugin/wnfs';\n\nexport const meta: PluginMeta = {\n id: WNFS_PLUGIN,\n name: 'WNFS',\n description: 'Manage and view files with via the Web Native File System (WNFS).',\n icon: 'ph--file-cloud--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs',\n};\n"],
5
- "mappings": ";AAMO,IAAMA,cAAc;AAEpB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;AACV;",
6
- "names": ["WNFS_PLUGIN", "meta", "id", "name", "description", "icon", "source"]
7
- }
@@ -1,16 +0,0 @@
1
- // src/capabilities/index.ts
2
- import { lazy } from "@dxos/app-framework";
3
- var Blockstore = lazy(() => import("./blockstore-PSYZCC2O.mjs"));
4
- var FileUploader = lazy(() => import("./file-uploader-YRZPRETS.mjs"));
5
- var IntentResolver = lazy(() => import("./intent-resolver-CKGJNE6P.mjs"));
6
- var Markdown = lazy(() => import("./markdown-RAGCVYGE.mjs"));
7
- var ReactSurface = lazy(() => import("./react-surface-HGWZDLP2.mjs"));
8
-
9
- export {
10
- Blockstore,
11
- FileUploader,
12
- IntentResolver,
13
- Markdown,
14
- ReactSurface
15
- };
16
- //# sourceMappingURL=chunk-ZMH2OULB.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/file-uploader.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, pipe } from 'effect';\n\nimport { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';\nimport { SpaceAction } from '@dxos/plugin-space/types';\n\nimport { WnfsAction } from '../types';\n\nexport default (context: PluginContext) => {\n return contributes(Capabilities.FileUploader, (file, space) => {\n const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n\n const program = Effect.gen(function* () {\n const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));\n yield* dispatch(pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })));\n return fileInfo;\n });\n\n return Effect.runPromise(program);\n });\n};\n"],
5
- "mappings": ";;;;;;AAIA,SAASA,QAAQC,YAAY;AAE7B,SAASC,cAAkCC,OAAOC,aAAaC,oBAAoB;AACnF,SAASC,mBAAmB;AAI5B,IAAA,wBAAe,CAACC,YAAAA;AACd,SAAOC,YAAYC,aAAaC,cAAc,CAACC,MAAMC,UAAAA;AACnD,UAAM,EAAEC,SAAQ,IAAKN,QAAQO,cAAcL,aAAaM,gBAAgB;AAExE,UAAMC,UAAUC,OAAOC,IAAI,aAAA;AACzB,YAAMC,WAAW,OAAON,SAASO,aAAaC,WAAWC,QAAQ;QAAEX;QAAMC;MAAM,CAAA,CAAA;AAC/E,aAAOC,SAASU,KAAKH,aAAaC,WAAWG,QAAQL,QAAAA,GAAWM,MAAMC,YAAYC,WAAW;QAAEC,QAAQhB;MAAM,CAAA,CAAA,CAAA;AAC7G,aAAOO;IACT,CAAA;AAEA,WAAOF,OAAOY,WAAWb,OAAAA;EAC3B,CAAA;AACF;",
6
- "names": ["Effect", "pipe", "Capabilities", "chain", "contributes", "createIntent", "SpaceAction", "context", "contributes", "Capabilities", "FileUploader", "file", "space", "dispatch", "getCapability", "IntentDispatcher", "program", "Effect", "gen", "fileInfo", "createIntent", "WnfsAction", "Upload", "pipe", "Create", "chain", "SpaceAction", "AddObject", "target", "runPromise"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/intent-resolver.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { upload } from '../helpers';\nimport { FileType, WnfsAction } from '../types';\n\nimport { WnfsCapabilities } from './capabilities';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.IntentResolver, [\n // TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.\n // Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.\n createResolver({\n intent: WnfsAction.Create,\n resolve: ({ name, type, cid }) => ({\n data: {\n object: Obj.make(FileType, { name, type, cid }),\n },\n }),\n }),\n createResolver({\n intent: WnfsAction.Upload,\n resolve: async ({ file, space }) => {\n const blockstore = context.getCapability(WnfsCapabilities.Blockstore);\n const info = await upload({ file, blockstore, space });\n return { data: info };\n },\n }),\n ]);\n"],
5
- "mappings": ";;;;;;;;;;;;;AAIA,SAASA,cAAkCC,aAAaC,sBAAsB;AAC9E,SAASC,WAAW;AAOpB,IAAA,0BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;;;EAGvCC,eAAe;IACbC,QAAQC,WAAWC;IACnBC,SAAS,CAAC,EAAEC,MAAMC,MAAMC,IAAG,OAAQ;MACjCC,MAAM;QACJC,QAAQC,IAAIC,KAAKC,UAAU;UAAEP;UAAMC;UAAMC;QAAI,CAAA;MAC/C;IACF;EACF,CAAA;EACAP,eAAe;IACbC,QAAQC,WAAWW;IACnBT,SAAS,OAAO,EAAEU,MAAMC,MAAK,MAAE;AAC7B,YAAMC,aAAapB,QAAQqB,cAAcC,iBAAiBC,UAAU;AACpE,YAAMC,OAAO,MAAMC,OAAO;QAAEP;QAAME;QAAYD;MAAM,CAAA;AACpD,aAAO;QAAEP,MAAMY;MAAK;IACtB;EACF,CAAA;CACD;",
6
- "names": ["Capabilities", "contributes", "createResolver", "Obj", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "WnfsAction", "Create", "resolve", "name", "type", "cid", "data", "object", "Obj", "make", "FileType", "Upload", "file", "space", "blockstore", "getCapability", "WnfsCapabilities", "Blockstore", "info", "upload"]
7
- }
@@ -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 Schema } from 'effect';\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 { WNFS_PLUGIN } from '../meta';\nimport { FileType, WnfsAction } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${WNFS_PLUGIN}/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: `${WNFS_PLUGIN}/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 Schema } from 'effect';\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 { WNFS_PLUGIN } 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(WNFS_PLUGIN);\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,q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AT,cAAc;IACZC,IAAI,GAAGC,WAAAA;IACPC,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", "WNFS_PLUGIN", "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", "WNFS_PLUGIN", "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,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"}
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
- }) {}