@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
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.
- package/dist/lib/browser/FileContainer-TFENLFD5.mjs +72 -0
- package/dist/lib/browser/FileContainer-TFENLFD5.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-2JFU4NBU.mjs → blockstore-TUV5YIC5.mjs} +13 -13
- package/dist/lib/browser/blockstore-TUV5YIC5.mjs.map +7 -0
- package/dist/lib/browser/chunk-3I3QQNA3.mjs +84 -0
- package/dist/lib/browser/chunk-3I3QQNA3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D6VTEQIE.mjs → chunk-A7ETWNGC.mjs} +23 -13
- package/dist/lib/browser/chunk-A7ETWNGC.mjs.map +7 -0
- package/dist/lib/browser/chunk-CXWUR7YI.mjs +8 -0
- package/dist/lib/browser/chunk-CXWUR7YI.mjs.map +7 -0
- package/dist/lib/browser/chunk-HXGK35WW.mjs +65 -0
- package/dist/lib/browser/chunk-HXGK35WW.mjs.map +7 -0
- package/dist/lib/browser/chunk-QE7ZSOYG.mjs +69 -0
- package/dist/lib/browser/chunk-QE7ZSOYG.mjs.map +7 -0
- package/dist/lib/browser/create-WQ6CUUDN.mjs +24 -0
- package/dist/lib/browser/create-WQ6CUUDN.mjs.map +7 -0
- package/dist/lib/browser/create-file-NGKX6CFL.mjs +49 -0
- package/dist/lib/browser/create-file-NGKX6CFL.mjs.map +7 -0
- package/dist/lib/browser/file-uploader-THECEDM2.mjs +37 -0
- package/dist/lib/browser/file-uploader-THECEDM2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +89 -81
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{markdown-WYQDCVFQ.mjs → markdown-IEDBXCLX.mjs} +28 -25
- package/dist/lib/browser/markdown-IEDBXCLX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-handler-YAYDKG7R.mjs +16 -0
- package/dist/lib/browser/operation-handler-YAYDKG7R.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +12 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/react-surface-UGRUPU56.mjs +60 -0
- package/dist/lib/browser/react-surface-UGRUPU56.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -3
- package/dist/lib/browser/upload-42ZL2AE4.mjs +42 -0
- package/dist/lib/browser/upload-42ZL2AE4.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +6 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +16 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +3 -0
- package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +1 -1
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +11 -11
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -50
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -36
- package/src/WnfsPlugin.tsx +50 -71
- package/src/blockstore.ts +1 -1
- package/src/capabilities/blockstore/blockstore.ts +22 -0
- package/src/capabilities/blockstore/index.ts +7 -0
- package/src/capabilities/file-uploader/file-uploader.ts +34 -0
- package/src/capabilities/file-uploader/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +33 -0
- package/src/capabilities/operation-handler/index.ts +11 -0
- package/src/capabilities/operation-handler/operation-handler.ts +16 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +51 -0
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/{components → containers/FileContainer}/FileContainer.tsx +13 -16
- package/src/containers/FileContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +5 -5
- package/src/extensions/image.tsx +3 -3
- package/src/helpers/load.ts +12 -7
- package/src/helpers/upload.ts +5 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +3 -3
- package/src/operations/create-file.ts +32 -0
- package/src/operations/create.ts +23 -0
- package/src/operations/definitions.ts +40 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +30 -0
- package/src/translations.ts +5 -1
- package/src/types/File.ts +11 -7
- package/src/{capabilities → types}/capabilities.ts +3 -3
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +2 -19
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs +0 -103
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs.map +0 -7
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs.map +0 -7
- package/dist/lib/browser/chunk-CWMKN2F6.mjs +0 -71
- package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +0 -7
- package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
- package/dist/lib/browser/chunk-F4QHZWQD.mjs +0 -16
- package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGPGLJCV.mjs +0 -25
- package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs +0 -16
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs +0 -30
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs +0 -48
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +0 -7
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DMU47U3X.mjs +0 -88
- package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +0 -7
- package/dist/types/src/capabilities/blockstore.d.ts +0 -4
- package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
- package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/src/capabilities/blockstore.ts +0 -19
- package/src/capabilities/file-uploader.ts +0 -27
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/capabilities/markdown.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/components/FilePreview.tsx +0 -23
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
|
@@ -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 * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { FormAnnotation } from '@dxos/echo/internal';\n\nexport const File = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n type: Schema.String.pipe(FormAnnotation.set(false)),\n cid: Schema.String.pipe(FormAnnotation.set(false)),\n timestamp: Schema.String.pipe(FormAnnotation.set(false), Schema.optional),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/File',\n version: '0.1.0',\n }),\n);\n\nexport type File = Schema.Schema.Type<typeof File>;\n\nexport const make = (props: Obj.MakeProps<typeof File>) => Obj.make(File, props);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { FileInfoSchema } from '@dxos/app-framework';\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { meta } from '../meta';\n\nimport * as File from './File';\n\nexport namespace WnfsAction {\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),\n output: Schema.Struct({\n object: File.File,\n }),\n }) {}\n\n export const UploadAnnotationId = Symbol.for(`${meta.id}/annotation/upload`);\n\n export const UploadFileSchema = Schema.Struct({\n file: Schema.instanceOf(File.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>()(`${meta.id}/action/upload`, {\n input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),\n output: Schema.required(FileInfoSchema),\n }) {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;AAAA;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,KAAKC,YAAY;AAC1B,SAASC,sBAAsB;AAExB,IAAMC,OAAcC,cAAO;EAChCC,MAAaC,cAAOC,KAAYC,eAAQ;EACxCC,MAAaH,cAAOC,KAAKG,eAAeC,IAAI,KAAA,CAAA;EAC5CC,KAAYN,cAAOC,KAAKG,eAAeC,IAAI,KAAA,CAAA;EAC3CE,WAAkBP,cAAOC,KAAKG,eAAeC,IAAI,KAAA,GAAeH,eAAQ;AAC1E,CAAA,EAAGD,KACDO,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;AAKK,IAAMC,OAAO,CAACC,UAAsCJ,IAAIG,KAAKf,MAAMgB,KAAAA;;;ACnB1E,YAAYC,aAAY;AAExB,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;UAMXC,aAAAA;EACR,MAAMC,eAAsBC,oBAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAYC,gBAAQ;IACtEC,QAAeC,eAAO;MACpBC,QAAaC;IACf,CAAA;EACF,CAAA,EAAA;EAAI;cALSZ,SAAAA;cAOAa,qBAAqBC,OAAOC,IAAI,GAAGb,KAAKC,EAAE,oBAAoB;cAE9Da,mBAA0BN,eAAO;IAC5CO,MAAaC,mBAAgBN,IAAI,EAAEO,YAAY;MAC7C,CAAApB,YAACc,kBAAAA,GAAqB;;QAEpB,WAAW;UAAC;UAAQ;UAAS;UAAQ;;QACrC,mBAAmB;UAAC;;MAEtB;IACF,CAAA;EACF,CAAA;EAIO,MAAMO,eAAsBnB,oBAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAciB,eAAMtB,YAACiB,kBAAyBN,eAAO;MAAEY,OAAOC;IAAY,CAAA,CAAA;IAC1Ed,QAAeD,iBAASH,cAAAA;EAC1B,CAAA,EAAA;EAAI;cAHSe,SAAAA;AAIf,GA3BiBrB,eAAAA,aAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Obj", "Type", "FormAnnotation", "File", "Struct", "name", "String", "pipe", "optional", "type", "FormAnnotation", "set", "cid", "timestamp", "Type", "Obj", "typename", "version", "make", "props", "Schema", "FileInfoSchema", "SpaceSchema", "WnfsAction", "Create", "TaggedClass", "meta", "id", "input", "FileInfoSchema", "pick", "pipe", "required", "output", "Struct", "object", "File", "UploadAnnotationId", "Symbol", "for", "UploadFileSchema", "file", "instanceOf", "annotations", "Upload", "extend", "space", "SpaceSchema"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/common.ts", "../../../src/helpers/load.ts", "../../../src/helpers/wnfs-url.ts", "../../../src/helpers/upload.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats/cid';\nimport { sha256 } from 'multiformats/hashes/sha2';\nimport { type BlockStore as WnfsBlockStore } from 'wnfs';\n\nimport * as crypto from '@dxos/crypto';\nimport { type Space } from '@dxos/react-client/echo';\n\n//\n// PATH\n//\n\nexport const filePath = (fileName: string, space: Space) => {\n return ['spaces', space.id, 'files', fileName];\n};\n\n//\n// RNG\n//\n\nexport class Rng {\n randomBytes(count: number): Uint8Array {\n return new Uint8Array(crypto.randomBytes(count));\n }\n}\n\n//\n// STORE\n//\n\nexport const store = (blockstore: Blockstore): WnfsBlockStore => {\n const getBlock = async (cid: Uint8Array): Promise<Uint8Array | undefined> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.get(decodedCid);\n };\n\n const hasBlock = async (cid: Uint8Array): Promise<boolean> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.has(decodedCid);\n };\n\n const putBlockKeyed = async (cid: Uint8Array, bytes: Uint8Array): Promise<void> => {\n const decodedCid = CID.decode(cid);\n await blockstore.put(decodedCid, bytes);\n };\n\n // Don't hash blocks with the rs-wnfs default Blake 3, sha256 has better support.\n const putBlock = async (bytes: Uint8Array, codec: number): Promise<Uint8Array> => {\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, codec, hash);\n await blockstore.put(cid, bytes);\n return cid.bytes;\n };\n\n return { getBlock, hasBlock, putBlockKeyed, putBlock };\n};\n\nexport const storeName = () => 'dxos/wnfs';\n\n//\n// OTHER\n//\n\nexport const readFile = (file: File): Promise<Uint8Array> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (event) => {\n const result = event.target?.result;\n if (result === null || result === undefined || typeof result === 'string') {\n reject(new Error('Expected an ArrayBuffer'));\n return;\n }\n resolve(new Uint8Array(result));\n };\n reader.onerror = (err) => {\n reject(err);\n };\n reader.readAsArrayBuffer(file);\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Uint8Arrays from 'uint8arrays';\nimport { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from 'wnfs';\n\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { type WnfsCapabilities } from '../capabilities';\n\nimport { Rng, store } from './common';\n\n//\n// LOAD\n//\n\nexport const loadWnfs = async ({\n space,\n blockstore,\n instances,\n}: {\n space: Space;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n}) => {\n // TODO(wittjosiah): Remove.\n // Delete old properties if they exist.\n if (space.properties.wnfs_access_key !== undefined && space.properties.wnfs_private_forest_cid !== undefined) {\n delete space.properties.wnfs_access_key;\n delete space.properties.wnfs_private_forest_cid;\n }\n\n const cacheKey = space.properties.wnfs?.privateForestCid;\n if (instances?.[cacheKey]) {\n return instances[cacheKey];\n }\n\n const exists = !!space.properties.wnfs;\n const instance = exists ? await loadWnfsDir(blockstore, space) : await createWnfsDir(blockstore, space);\n if (instances) {\n instances[cacheKey] = instance;\n }\n\n return instance;\n};\n\n//\n// PRIVATE\n//\n\nconst createWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n const rng = new Rng();\n const forest = new PrivateForest(rng);\n\n const dirResult = await PrivateDirectory.newAndStore(forest.emptyName(), new Date(), forest, wnfsStore, rng);\n const dir = dirResult.rootDir as PrivateDirectory;\n\n const [accessKeyRaw, newForest]: [AccessKey, PrivateForest] = await dir\n .asNode()\n .store(dirResult.forest as PrivateForest, wnfsStore, rng);\n\n const cidBytes = await newForest.store(wnfsStore);\n\n space.properties.wnfs = {\n accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),\n privateForestCid: CID.decode(cidBytes).toString(),\n };\n\n return {\n directory: dir,\n forest: newForest,\n };\n};\n\nconst loadWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n\n const accessKey = AccessKey.fromBytes(Uint8Arrays.fromString(space.properties.wnfs.accessKey, 'base64'));\n const forest: PrivateForest = await PrivateForest.load(\n CID.parse(space.properties.wnfs.privateForestCid).bytes,\n wnfsStore,\n );\n const node: PrivateNode = await PrivateNode.load(accessKey, forest, wnfsStore);\n\n return {\n directory: node.asDir(),\n forest,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { store } from './common';\n\nexport const wnfsUrl = (filePath: string[]) => {\n return 'wnfs://' + filePath.map((f) => encodeURIComponent(f)).join('/');\n};\n\nexport const getPathFromUrl = (wnfsUrl: string) =>\n wnfsUrl\n .replace(/^wnfs:\\/\\//, '')\n .split('/')\n .map((p) => decodeURIComponent(p));\n\nexport const getBlobUrl = async ({\n wnfsUrl,\n blockstore,\n forest,\n directory,\n type,\n}: {\n wnfsUrl: string;\n blockstore: Blockstore;\n forest: PrivateForest;\n directory: PrivateDirectory;\n type?: string;\n}) => {\n const path = getPathFromUrl(wnfsUrl);\n const wnfsStore = store(blockstore);\n const { result } = await directory.read(path, true, forest, wnfsStore);\n const blob = new Blob([result], { type });\n return URL.createObjectURL(blob);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Raw from 'multiformats/codecs/raw';\nimport { sha256 } from 'multiformats/hashes/sha2';\n\nimport type { Space } from '@dxos/client/echo';\nimport { log } from '@dxos/log';\n\nimport { type WnfsCapabilities } from '../capabilities';\n\nimport { Rng, filePath, store } from './common';\nimport { loadWnfs } from './load';\nimport { wnfsUrl } from './wnfs-url';\n\nexport const upload = async ({\n file,\n blockstore,\n instances,\n space,\n}: {\n file: File;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n space: Space;\n}) => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const wnfsStore = store(blockstore);\n\n const bytes = new Uint8Array(await file.arrayBuffer());\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, Raw.code, hash);\n\n const path = filePath(cid.toString(), space);\n\n // Given the root directory of the private file system,\n // write the file contents to `path` in said directory.\n const result = await directory.write(path, true, bytes, new Date(), forest, wnfsStore, new Rng());\n\n // Given the new immutable instance of the root directory after writing to it,\n // **store** the changes in the \"dark forest\" and the associated (block) store.\n const [_, updatedForest] = await result.rootDir.store(result.forest, wnfsStore, new Rng());\n const cidBytes = await updatedForest.store(wnfsStore);\n\n // Update the forest pointer on the associated space.\n space.properties.wnfs.privateForestCid = CID.decode(cidBytes).toString();\n\n // Generate `wnfs://` URL & return the info.\n const info = {\n name: file.name,\n type: file.type,\n url: wnfsUrl(path),\n cid: cid.toString(),\n };\n\n log('upload', { file, info });\n return info;\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,WAAW;AACpB,SAASC,cAAc;AAGvB,YAAYC,YAAY;AAOjB,IAAMC,WAAW,CAACC,UAAkBC,UAAAA;AACzC,SAAO;IAAC;IAAUA,MAAMC;IAAI;IAASF;;AACvC;AAMO,IAAMG,MAAN,MAAMA;EACXC,YAAYC,OAA2B;AACrC,WAAO,IAAIC,WAAkBF,mBAAYC,KAAAA,CAAAA;EAC3C;AACF;AAMO,IAAME,QAAQ,CAACC,eAAAA;AACpB,QAAMC,WAAW,OAAOC,QAAAA;AACtB,UAAMC,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,WAAO,MAAMF,WAAWM,IAAIH,UAAAA;EAC9B;AAEA,QAAMI,WAAW,OAAOL,QAAAA;AACtB,UAAMC,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,WAAO,MAAMF,WAAWQ,IAAIL,UAAAA;EAC9B;AAEA,QAAMM,gBAAgB,OAAOP,KAAiBQ,UAAAA;AAC5C,UAAMP,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,UAAMF,WAAWW,IAAIR,YAAYO,KAAAA;EACnC;AAGA,QAAME,WAAW,OAAOF,OAAmBG,UAAAA;AACzC,UAAMC,OAAO,MAAMC,OAAO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;AAC7B;;;AChCA,SAASI,OAAAA,YAAW;AACpB,YAAYC,SAAS;AACrB,SAASC,UAAAA,eAAc;AAGvB,SAASC,WAAW;;AAQb,IAAMC,SAAS,OAAO,EAC3BC,MACAC,YACAC,WACAC,MAAK,MAMN;AACC,QAAM,EAAEC,WAAWC,OAAM,IAAK,MAAMC,SAAS;IAAEL;IAAYC;IAAWC;EAAM,CAAA;AAC5E,QAAMI,YAAYC,MAAMP,UAAAA;AAExB,QAAMQ,QAAQ,IAAIC,WAAW,MAAMV,KAAKW,YAAW,CAAA;AACnD,QAAMC,OAAO,MAAMC,QAAOC,OAAOL,KAAAA;AACjC,QAAMM,MAAMC,KAAIC,OAAO,GAAOC,UAAMN,IAAAA;AAEpC,QAAMO,OAAOC,SAASL,IAAIM,SAAQ,GAAIlB,KAAAA;AAItC,QAAMmB,SAAS,MAAMlB,UAAUmB,MAAMJ,MAAM,MAAMV,OAAO,oBAAIe,KAAAA,GAAQnB,QAAQE,WAAW,IAAIkB,IAAAA,CAAAA;AAI3F,QAAM,CAACC,GAAGC,aAAAA,IAAiB,MAAML,OAAOM,QAAQpB,MAAMc,OAAOjB,QAAQE,WAAW,IAAIkB,IAAAA,CAAAA;AACpF,QAAMI,WAAW,MAAMF,cAAcnB,MAAMD,SAAAA;AAG3CJ,QAAM2B,WAAWC,KAAKC,mBAAmBhB,KAAIiB,OAAOJ,QAAAA,EAAUR,SAAQ;AAGtE,QAAMa,OAAO;IACXC,MAAMnC,KAAKmC;IACXC,MAAMpC,KAAKoC;IACXC,KAAKC,QAAQnB,IAAAA;IACbJ,KAAKA,IAAIM,SAAQ;EACnB;AAEAkB,MAAI,UAAU;IAAEvC;IAAMkC;EAAK,GAAA;;;;;;AAC3B,SAAOA;AACT;",
|
|
6
|
-
"names": ["CID", "sha256", "crypto", "filePath", "fileName", "space", "id", "Rng", "randomBytes", "count", "Uint8Array", "store", "blockstore", "getBlock", "cid", "decodedCid", "CID", "decode", "get", "hasBlock", "has", "putBlockKeyed", "bytes", "put", "putBlock", "codec", "hash", "sha256", "digest", "create", "storeName", "CID", "Uint8Arrays", "AccessKey", "PrivateDirectory", "PrivateForest", "PrivateNode", "loadWnfs", "space", "blockstore", "instances", "properties", "wnfs_access_key", "undefined", "wnfs_private_forest_cid", "cacheKey", "wnfs", "privateForestCid", "exists", "instance", "loadWnfsDir", "createWnfsDir", "wnfsStore", "store", "rng", "Rng", "forest", "PrivateForest", "dirResult", "PrivateDirectory", "newAndStore", "emptyName", "Date", "dir", "rootDir", "accessKeyRaw", "newForest", "asNode", "cidBytes", "accessKey", "toString", "toBytes", "CID", "decode", "directory", "AccessKey", "fromBytes", "fromString", "load", "parse", "bytes", "node", "PrivateNode", "asDir", "wnfsUrl", "filePath", "map", "f", "encodeURIComponent", "join", "getPathFromUrl", "replace", "split", "p", "decodeURIComponent", "getBlobUrl", "blockstore", "forest", "directory", "type", "path", "wnfsStore", "store", "result", "read", "blob", "Blob", "URL", "createObjectURL", "CID", "Raw", "sha256", "log", "upload", "file", "blockstore", "instances", "space", "directory", "forest", "loadWnfs", "wnfsStore", "store", "bytes", "Uint8Array", "arrayBuffer", "hash", "sha256", "digest", "cid", "CID", "create", "code", "path", "filePath", "toString", "result", "write", "Date", "Rng", "_", "updatedForest", "rootDir", "cidBytes", "properties", "wnfs", "privateForestCid", "decode", "info", "name", "type", "url", "wnfsUrl", "log"]
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-OGPGLJCV.mjs";
|
|
4
|
-
|
|
5
|
-
// src/capabilities/capabilities.ts
|
|
6
|
-
import { defineCapability } from "@dxos/app-framework";
|
|
7
|
-
(function(WnfsCapabilities2) {
|
|
8
|
-
WnfsCapabilities2.Blockstore = defineCapability(`${meta.id}/capability/blockstore`);
|
|
9
|
-
WnfsCapabilities2.Instances = defineCapability(`${meta.id}/capability/instances`);
|
|
10
|
-
})(WnfsCapabilities || (WnfsCapabilities = {}));
|
|
11
|
-
var WnfsCapabilities;
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
WnfsCapabilities
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-F4QHZWQD.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 { meta } from '../meta';\n\nexport namespace WnfsCapabilities {\n export const Blockstore = defineCapability<Blockstore>(`${meta.id}/capability/blockstore`);\n\n export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;\n export const Instances = defineCapability<Instances>(`${meta.id}/capability/instances`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAOA,SAASA,wBAAwB;UAKhBC,mBAAAA;oBACFC,aAAaC,iBAA6B,GAAGC,KAAKC,EAAE,wBAAwB;oBAG5EC,YAAYH,iBAA4B,GAAGC,KAAKC,EAAE,uBAAuB;AACxF,GALiBJ,qBAAAA,mBAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["defineCapability", "WnfsCapabilities", "Blockstore", "defineCapability", "meta", "id", "Instances"]
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/meta.ts
|
|
8
|
-
import { trim } from "@dxos/util";
|
|
9
|
-
var meta = {
|
|
10
|
-
id: "dxos.org/plugin/wnfs",
|
|
11
|
-
name: "WNFS",
|
|
12
|
-
description: trim`
|
|
13
|
-
Decentralized file storage using the Web Native File System protocol.
|
|
14
|
-
Store and sync files with end-to-end encryption across devices without central servers.
|
|
15
|
-
`,
|
|
16
|
-
icon: "ph--file-cloud--regular",
|
|
17
|
-
iconHue: "teal",
|
|
18
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
__export,
|
|
23
|
-
meta
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=chunk-OGPGLJCV.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';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/wnfs',\n name: 'WNFS',\n description: trim`\n Decentralized file storage using the Web Native File System protocol.\n Store and sync files with end-to-end encryption across devices without central servers.\n `,\n icon: 'ph--file-cloud--regular',\n iconHue: 'teal',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs',\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;AACV;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source"]
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/capabilities/index.ts
|
|
2
|
-
import { lazy } from "@dxos/app-framework";
|
|
3
|
-
var Blockstore = lazy(() => import("./blockstore-2JFU4NBU.mjs"));
|
|
4
|
-
var FileUploader = lazy(() => import("./file-uploader-W6TJLAAK.mjs"));
|
|
5
|
-
var IntentResolver = lazy(() => import("./intent-resolver-FSW2EQF4.mjs"));
|
|
6
|
-
var Markdown = lazy(() => import("./markdown-WYQDCVFQ.mjs"));
|
|
7
|
-
var ReactSurface = lazy(() => import("./react-surface-DMU47U3X.mjs"));
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
Blockstore,
|
|
11
|
-
FileUploader,
|
|
12
|
-
IntentResolver,
|
|
13
|
-
Markdown,
|
|
14
|
-
ReactSurface
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-ZFPJA5F4.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const Blockstore = lazy(() => import('./blockstore'));\nexport const FileUploader = lazy(() => import('./file-uploader'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const Markdown = lazy(() => import('./markdown'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './capabilities';\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAAY;AAEd,IAAMC,aAAaC,KAAK,MAAM,OAAO,2BAAA,CAAA;AACrC,IAAMC,eAAeD,KAAK,MAAM,OAAO,8BAAA,CAAA;AACvC,IAAME,iBAAiBF,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMG,WAAWH,KAAK,MAAM,OAAO,yBAAA,CAAA;AACnC,IAAMI,eAAeJ,KAAK,MAAM,OAAO,8BAAA,CAAA;",
|
|
6
|
-
"names": ["lazy", "Blockstore", "lazy", "FileUploader", "IntentResolver", "Markdown", "ReactSurface"]
|
|
7
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WnfsAction
|
|
3
|
-
} from "./chunk-CWMKN2F6.mjs";
|
|
4
|
-
import "./chunk-OGPGLJCV.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/file-uploader.ts
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
import * as Function from "effect/Function";
|
|
9
|
-
import { Capabilities, chain, contributes, createIntent } from "@dxos/app-framework";
|
|
10
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
11
|
-
var file_uploader_default = ((context) => {
|
|
12
|
-
return contributes(Capabilities.FileUploader, (space, file) => {
|
|
13
|
-
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
14
|
-
const program = Effect.gen(function* () {
|
|
15
|
-
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, {
|
|
16
|
-
space,
|
|
17
|
-
file
|
|
18
|
-
}));
|
|
19
|
-
yield* dispatch(Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, {
|
|
20
|
-
target: space
|
|
21
|
-
})));
|
|
22
|
-
return fileInfo;
|
|
23
|
-
});
|
|
24
|
-
return Effect.runPromise(program);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
export {
|
|
28
|
-
file_uploader_default as default
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=file-uploader-W6TJLAAK.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 * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\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, (space, file) => {\n const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n const program = Effect.gen(function* () {\n const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { space, file }));\n yield* dispatch(\n Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })),\n );\n\n return fileInfo;\n });\n\n return Effect.runPromise(program);\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,YAAYA,YAAY;AACxB,YAAYC,cAAc;AAE1B,SAASC,cAAkCC,OAAOC,aAAaC,oBAAoB;AACnF,SAASC,mBAAmB;AAI5B,IAAA,yBAAe,CAACC,YAAAA;AACd,SAAOC,YAAYC,aAAaC,cAAc,CAACC,OAAOC,SAAAA;AACpD,UAAM,EAAEC,SAAQ,IAAKN,QAAQO,cAAcL,aAAaM,gBAAgB;AACxE,UAAMC,UAAiBC,WAAI,aAAA;AACzB,YAAMC,WAAW,OAAOL,SAASM,aAAaC,WAAWC,QAAQ;QAAEV;QAAOC;MAAK,CAAA,CAAA;AAC/E,aAAOC,SACIS,cAAKH,aAAaC,WAAWG,QAAQL,QAAAA,GAAWM,MAAMC,YAAYC,WAAW;QAAEC,QAAQhB;MAAM,CAAA,CAAA,CAAA;AAGxG,aAAOO;IACT,CAAA;AAEA,WAAcU,kBAAWZ,OAAAA;EAC3B,CAAA;AACF;",
|
|
6
|
-
"names": ["Effect", "Function", "Capabilities", "chain", "contributes", "createIntent", "SpaceAction", "context", "contributes", "Capabilities", "FileUploader", "space", "file", "dispatch", "getCapability", "IntentDispatcher", "program", "gen", "fileInfo", "createIntent", "WnfsAction", "Upload", "pipe", "Create", "chain", "SpaceAction", "AddObject", "target", "runPromise"]
|
|
7
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
upload
|
|
3
|
-
} from "./chunk-D6VTEQIE.mjs";
|
|
4
|
-
import {
|
|
5
|
-
WnfsCapabilities
|
|
6
|
-
} from "./chunk-F4QHZWQD.mjs";
|
|
7
|
-
import {
|
|
8
|
-
File_exports,
|
|
9
|
-
WnfsAction
|
|
10
|
-
} from "./chunk-CWMKN2F6.mjs";
|
|
11
|
-
import "./chunk-OGPGLJCV.mjs";
|
|
12
|
-
|
|
13
|
-
// src/capabilities/intent-resolver.ts
|
|
14
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
15
|
-
var intent_resolver_default = ((context) => contributes(Capabilities.IntentResolver, [
|
|
16
|
-
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
17
|
-
// Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
|
|
18
|
-
createResolver({
|
|
19
|
-
intent: WnfsAction.Create,
|
|
20
|
-
resolve: ({ name, type, cid }) => ({
|
|
21
|
-
data: {
|
|
22
|
-
object: File_exports.make({
|
|
23
|
-
name,
|
|
24
|
-
type,
|
|
25
|
-
cid
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
}),
|
|
30
|
-
createResolver({
|
|
31
|
-
intent: WnfsAction.Upload,
|
|
32
|
-
resolve: async ({ file, space }) => {
|
|
33
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
34
|
-
const info = await upload({
|
|
35
|
-
file,
|
|
36
|
-
blockstore,
|
|
37
|
-
space
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
data: info
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
]));
|
|
45
|
-
export {
|
|
46
|
-
intent_resolver_default as default
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=intent-resolver-FSW2EQF4.mjs.map
|
|
@@ -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';\n\nimport { upload } from '../helpers';\nimport { WnfsAction, WnfsFile } 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: WnfsFile.make({ 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;AAO9E,IAAA,2BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;;;EAGvCC,eAAe;IACbC,QAAQC,WAAWC;IACnBC,SAAS,CAAC,EAAEC,MAAMC,MAAMC,IAAG,OAAQ;MACjCC,MAAM;QACJC,QAAQC,aAASC,KAAK;UAAEN;UAAMC;UAAMC;QAAI,CAAA;MAC1C;IACF;EACF,CAAA;EACAP,eAAe;IACbC,QAAQC,WAAWU;IACnBR,SAAS,OAAO,EAAES,MAAMC,MAAK,MAAE;AAC7B,YAAMC,aAAanB,QAAQoB,cAAcC,iBAAiBC,UAAU;AACpE,YAAMC,OAAO,MAAMC,OAAO;QAAEP;QAAME;QAAYD;MAAM,CAAA;AACpD,aAAO;QAAEN,MAAMW;MAAK;IACtB;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createResolver", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "WnfsAction", "Create", "resolve", "name", "type", "cid", "data", "object", "WnfsFile", "make", "Upload", "file", "space", "blockstore", "getCapability", "WnfsCapabilities", "Blockstore", "info", "upload"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/markdown.ts", "../../../src/extensions/image.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type PluginContext, contributes } from '@dxos/app-framework';\nimport { MarkdownCapabilities } from '@dxos/plugin-markdown';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { image } from '../extensions';\n\nimport { WnfsCapabilities } from './capabilities';\n\nexport default (context: PluginContext) =>\n contributes(MarkdownCapabilities.Extensions, [\n ({ document }) => {\n const blockstore = context.getCapability(WnfsCapabilities.Blockstore);\n const instances = context.getCapability(WnfsCapabilities.Instances);\n\n if (document) {\n const space = getSpace(document);\n return space ? [image({ blockstore, instances, space })] : [];\n }\n\n return [];\n },\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type Extension, type Range, StateField } from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\nimport type { Blockstore } from 'interface-blockstore';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { Status, ThemeProvider } from '@dxos/react-ui';\nimport { focusField } from '@dxos/react-ui-editor';\nimport { defaultTx } from '@dxos/react-ui-theme';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { type WnfsCapabilities } from '../capabilities';\nimport { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';\n\nconst WAIT_UNTIL_LOADER = 1500;\n\nexport type ImageOptions = {\n blockstore: Blockstore;\n instances: WnfsCapabilities.Instances;\n space: Space;\n};\n\n/**\n * Create WNFS image decorations.\n */\nexport const image = (options: ImageOptions): Extension[] => {\n const blobUrlCache: Record<string, string> = {};\n const preloaded = new Set<string>();\n\n const preload = (url: string) => {\n if (!preloaded.has(url)) {\n const img = document.createElement('img');\n img.src = url;\n preloaded.add(url);\n }\n };\n\n return [\n StateField.define({\n create: (state) => {\n return Decoration.set(\n buildDecorations({ from: 0, to: state.doc.length, state, blobUrlCache, preload, options }),\n );\n },\n update: (value, tr) => {\n if (!tr.docChanged && !tr.selection) {\n return value;\n }\n\n // Find range of changes and cursor changes.\n const cursor = tr.state.selection.main.head;\n const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);\n let from = Math.min(cursor, oldCursor);\n let to = Math.max(cursor, oldCursor);\n tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {\n from = Math.min(from, fromB);\n to = Math.max(to, toB);\n });\n\n // Expand to cover lines.\n from = tr.state.doc.lineAt(from).from;\n to = tr.state.doc.lineAt(to).to;\n\n return value.map(tr.changes).update({\n filterFrom: from,\n filterTo: to,\n filter: () => false,\n add: buildDecorations({ from, to, state: tr.state, blobUrlCache, preload, options }),\n });\n },\n provide: (field) => EditorView.decorations.from(field),\n }),\n ];\n};\n\nconst buildDecorations = ({\n state,\n from,\n to,\n blobUrlCache,\n preload,\n options: { blockstore, instances, space },\n}: {\n state: EditorState;\n from: number;\n to: number;\n blobUrlCache: Record<string, string>;\n preload: (url: string) => void;\n options: ImageOptions;\n}) => {\n const decorations: Range<Decoration>[] = [];\n const cursor = state.selection.main.head;\n syntaxTree(state).iterate({\n enter: (node) => {\n if (node.name !== 'Image') {\n return;\n }\n\n const urlNode = node.node.getChild('URL');\n if (!urlNode) {\n return;\n }\n\n const hide = state.readOnly || cursor < node.from || cursor > node.to;\n const wnfsUrl = state.sliceDoc(urlNode.from, urlNode.to);\n if (!wnfsUrl.startsWith('wnfs://')) {\n return;\n }\n\n const path = getPathFromUrl(wnfsUrl);\n\n // Cannot load images from other spaces\n const spaceId = path[1];\n if (spaceId !== space.id) {\n return;\n }\n\n // Load image contents into memory blob\n const blobUrlPromise = (async () => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const url = await getBlobUrl({ wnfsUrl, blockstore, directory, forest });\n blobUrlCache[path.join('/')] = url;\n preload(url);\n return url;\n })();\n\n decorations.push(\n Decoration.replace({\n block: true, // Prevent cursor from entering.\n widget: new WnfsImageWidget(wnfsUrl, blobUrlCache[path.join('/')] ?? blobUrlPromise),\n }).range(hide ? node.from : node.to, node.to),\n );\n },\n from,\n to,\n });\n\n return decorations;\n};\n\nconst createImg = (view: EditorView, url: string) => {\n const img = document.createElement('img');\n img.setAttribute('src', url);\n img.setAttribute('class', 'cm-image-with-loader');\n // If focused, hide image until successfully loaded to avoid flickering effects.\n if (view.state.field(focusField)) {\n img.onload = () => img.classList.add('cm-loaded-image');\n } else {\n img.classList.add('cm-loaded-image');\n }\n return img;\n};\n\nclass WnfsImageWidget extends WidgetType {\n constructor(\n readonly _wnfsUrl: string,\n readonly _url: MaybePromise<string>,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._wnfsUrl === other._wnfsUrl;\n }\n\n override toDOM(view: EditorView) {\n if (typeof this._url === 'string') {\n return createImg(view, this._url);\n }\n\n const widget = document.createElement('div');\n widget.className = 'cm-image-wrapper';\n const loader = document.createElement('div');\n loader.className = 'mx-auto transition-opacity';\n let loaderAdded = false;\n\n const timeout = setTimeout(() => {\n const root = createRoot(loader);\n root.render(\n <ThemeProvider tx={defaultTx}>\n <Status indeterminate />\n </ThemeProvider>,\n );\n widget.appendChild(loader);\n loaderAdded = true;\n }, WAIT_UNTIL_LOADER);\n\n void this._url.then((url) => {\n clearTimeout(timeout);\n const img = createImg(view, url);\n loaderAdded && widget.removeChild(loader);\n widget.appendChild(img);\n });\n\n return widget;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAIA,SAA6BA,mBAAmB;AAChD,SAASC,4BAA4B;AACrC,SAASC,gBAAgB;;;ACFzB,SAASC,kBAAkB;AAC3B,SAAuDC,kBAAkB;AACzE,SAASC,YAAYC,YAAYC,kBAAkB;AAEnD,OAAOC,WAAW;AAClB,SAASC,kBAAkB;AAG3B,SAASC,QAAQC,qBAAqB;AACtC,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAM1B,IAAMC,oBAAoB;AAWnB,IAAMC,QAAQ,CAACC,YAAAA;AACpB,QAAMC,eAAuC,CAAC;AAC9C,QAAMC,YAAY,oBAAIC,IAAAA;AAE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Yf,MAAAA;AAClChB,aAAO4B,YAAYrG,GAAAA;IACrB,CAAA;AAEA,WAAOyE;EACT;AACF;;;AD9LA,IAAA,oBAAe,CAACgC,YACdC,YAAYC,qBAAqBC,YAAY;EAC3C,CAAC,EAAEC,UAAAA,UAAQ,MAAE;AACX,UAAMC,aAAaL,QAAQM,cAAcC,iBAAiBC,UAAU;AACpE,UAAMC,YAAYT,QAAQM,cAAcC,iBAAiBG,SAAS;AAElE,QAAIN,WAAU;AACZ,YAAMO,QAAQC,SAASR,SAAAA;AACvB,aAAOO,QAAQ;QAACE,MAAM;UAAER;UAAYI;UAAWE;QAAM,CAAA;UAAM,CAAA;IAC7D;AAEA,WAAO,CAAA;EACT;CACD;",
|
|
6
|
-
"names": ["contributes", "MarkdownCapabilities", "getSpace", "syntaxTree", "StateField", "Decoration", "EditorView", "WidgetType", "React", "createRoot", "Status", "ThemeProvider", "focusField", "defaultTx", "WAIT_UNTIL_LOADER", "image", "options", "blobUrlCache", "preloaded", "Set", "preload", "url", "has", "img", "document", "createElement", "src", "add", "StateField", "define", "create", "state", "Decoration", "set", "buildDecorations", "from", "to", "doc", "length", "update", "value", "tr", "docChanged", "selection", "cursor", "main", "head", "oldCursor", "changes", "mapPos", "startState", "Math", "min", "max", "iterChangedRanges", "fromA", "toA", "fromB", "toB", "lineAt", "map", "filterFrom", "filterTo", "filter", "provide", "field", "EditorView", "decorations", "blockstore", "instances", "space", "syntaxTree", "iterate", "enter", "node", "name", "urlNode", "getChild", "hide", "readOnly", "wnfsUrl", "sliceDoc", "startsWith", "path", "getPathFromUrl", "spaceId", "id", "blobUrlPromise", "directory", "forest", "loadWnfs", "getBlobUrl", "join", "push", "replace", "block", "widget", "WnfsImageWidget", "range", "createImg", "view", "setAttribute", "focusField", "onload", "classList", "WidgetType", "_wnfsUrl", "_url", "eq", "other", "toDOM", "className", "loader", "loaderAdded", "timeout", "setTimeout", "root", "createRoot", "render", "ThemeProvider", "tx", "defaultTx", "Status", "indeterminate", "appendChild", "then", "clearTimeout", "removeChild", "context", "contributes", "MarkdownCapabilities", "Extensions", "document", "blockstore", "getCapability", "WnfsCapabilities", "Blockstore", "instances", "Instances", "space", "getSpace", "image"]
|
|
7
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
File_exports,
|
|
3
|
-
WnfsAction
|
|
4
|
-
} from "./chunk-CWMKN2F6.mjs";
|
|
5
|
-
import {
|
|
6
|
-
meta
|
|
7
|
-
} from "./chunk-OGPGLJCV.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-roseFill")
|
|
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-LLNI7WXR.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(File_exports.File, 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-DMU47U3X.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 { WnfsAction, WnfsFile } 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: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, 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-roseFill',\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;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ACnB,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", "WnfsFile", "File", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
|
|
7
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type PluginContext } from '@dxos/app-framework';
|
|
2
|
-
declare const _default: (context: PluginContext) => Promise<import("@dxos/app-framework").Capability<import("@dxos/app-framework").InterfaceDef<import("interface-blockstore").Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>>>>;
|
|
3
|
-
export default _default;
|
|
4
|
-
//# sourceMappingURL=blockstore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blockstore.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/blockstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,qBAAqB,CAAC;yBAOhD,SAAS,aAAa;AAA5C,wBAOE"}
|
|
@@ -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;yBAOpF,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 +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 WnfsFile } from '../types';
|
|
3
|
-
export type FileContainerProps = {
|
|
4
|
-
role: string;
|
|
5
|
-
file: WnfsFile.File;
|
|
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,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,kBAAkB,6BAiCzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type PluginContext, contributes } from '@dxos/app-framework';
|
|
6
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
|
-
|
|
8
|
-
import * as Blockstore from '../blockstore';
|
|
9
|
-
|
|
10
|
-
import { WnfsCapabilities } from './capabilities';
|
|
11
|
-
|
|
12
|
-
export default async (context: PluginContext) => {
|
|
13
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
14
|
-
const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';
|
|
15
|
-
const blockstore = Blockstore.create(apiHost);
|
|
16
|
-
await blockstore.open();
|
|
17
|
-
|
|
18
|
-
return contributes(WnfsCapabilities.Blockstore, blockstore);
|
|
19
|
-
};
|
|
@@ -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, (space, file) => {
|
|
15
|
-
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
16
|
-
const program = Effect.gen(function* () {
|
|
17
|
-
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { space, file }));
|
|
18
|
-
yield* dispatch(
|
|
19
|
-
Function.pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return fileInfo;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return Effect.runPromise(program);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
import { upload } from '../helpers';
|
|
8
|
-
import { WnfsAction, WnfsFile } from '../types';
|
|
9
|
-
|
|
10
|
-
import { WnfsCapabilities } from './capabilities';
|
|
11
|
-
|
|
12
|
-
export default (context: PluginContext) =>
|
|
13
|
-
contributes(Capabilities.IntentResolver, [
|
|
14
|
-
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
15
|
-
// Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
|
|
16
|
-
createResolver({
|
|
17
|
-
intent: WnfsAction.Create,
|
|
18
|
-
resolve: ({ name, type, cid }) => ({
|
|
19
|
-
data: {
|
|
20
|
-
object: WnfsFile.make({ name, type, cid }),
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
}),
|
|
24
|
-
createResolver({
|
|
25
|
-
intent: WnfsAction.Upload,
|
|
26
|
-
resolve: async ({ file, space }) => {
|
|
27
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
28
|
-
const info = await upload({ file, blockstore, space });
|
|
29
|
-
return { data: info };
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
@@ -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
|
-
]);
|