@dxos/plugin-wnfs 0.7.5-main.9d26e3a → 0.7.5-main.9d2a38b
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-I2P6I7CX.mjs +94 -0
- package/dist/lib/browser/FileContainer-I2P6I7CX.mjs.map +7 -0
- package/dist/lib/browser/blockstore-6U5XTSIH.mjs +192 -0
- package/dist/lib/browser/blockstore-6U5XTSIH.mjs.map +7 -0
- package/dist/lib/browser/chunk-357BWHML.mjs +16 -0
- package/dist/lib/browser/chunk-357BWHML.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VL3H7P4F.mjs → chunk-6YFT42F7.mjs} +5 -8
- package/dist/lib/browser/chunk-6YFT42F7.mjs.map +7 -0
- package/dist/lib/browser/chunk-EMRQJXBW.mjs +60 -0
- package/dist/lib/browser/chunk-EMRQJXBW.mjs.map +7 -0
- package/dist/lib/browser/chunk-SCQWJNHD.mjs +157 -0
- package/dist/lib/browser/chunk-SCQWJNHD.mjs.map +7 -0
- package/dist/lib/browser/chunk-YLGCDZV3.mjs +16 -0
- package/dist/lib/browser/chunk-YLGCDZV3.mjs.map +7 -0
- package/dist/lib/browser/file-uploader-EDHMSKYS.mjs +29 -0
- package/dist/lib/browser/file-uploader-EDHMSKYS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +96 -486
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-WDO4EIG3.mjs +43 -0
- package/dist/lib/browser/intent-resolver-WDO4EIG3.mjs.map +7 -0
- package/dist/lib/browser/markdown-MGSH5CVQ.mjs +198 -0
- package/dist/lib/browser/markdown-MGSH5CVQ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-EBQICOUA.mjs +81 -0
- package/dist/lib/browser/react-surface-EBQICOUA.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/types/src/WnfsPlugin.d.ts +1 -3
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/blockstore.d.ts +4 -1
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +4 -0
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +12 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader.d.ts +4 -0
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +4 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/FileContainer.d.ts +8 -0
- package/dist/types/src/components/FileContainer.d.ts.map +1 -0
- package/dist/types/src/components/FileInput.d.ts +8 -0
- package/dist/types/src/components/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -11
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/image.d.ts +5 -0
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -0
- package/dist/types/src/helpers/index.d.ts +5 -0
- package/dist/types/src/helpers/index.d.ts.map +1 -0
- package/dist/types/src/helpers/load.d.ts +13 -0
- package/dist/types/src/helpers/load.d.ts.map +1 -0
- package/dist/types/src/helpers/upload.d.ts +15 -0
- package/dist/types/src/helpers/upload.d.ts.map +1 -0
- package/dist/types/src/helpers/wnfs-url.d.ts +11 -0
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +14 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/file.d.ts +4 -6
- package/dist/types/src/types/file.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +49 -6
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -26
- package/src/WnfsPlugin.tsx +77 -86
- package/src/blockstore.ts +151 -21
- package/src/capabilities/blockstore.ts +18 -0
- package/src/capabilities/capabilities.ts +18 -0
- package/src/capabilities/file-uploader.ts +24 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +26 -0
- package/src/capabilities/markdown.ts +25 -0
- package/src/capabilities/react-surface.tsx +41 -0
- package/src/components/FileContainer.tsx +46 -0
- package/src/components/FileInput.tsx +46 -0
- package/src/components/index.ts +3 -4
- package/src/extensions/image.stories.tsx +26 -68
- package/src/extensions/image.tsx +203 -0
- package/src/{common.ts → helpers/common.ts} +1 -1
- package/src/helpers/index.ts +8 -0
- package/src/{load.ts → helpers/load.ts} +38 -9
- package/src/{upload.ts → helpers/upload.ts} +18 -4
- package/src/helpers/wnfs-url.ts +36 -0
- package/src/index.ts +2 -4
- package/src/meta.ts +1 -2
- package/src/translations.ts +5 -0
- package/src/types/file.ts +2 -3
- package/src/types/types.ts +30 -19
- package/dist/lib/browser/FileCard-HJIZDWJF.mjs +0 -39
- package/dist/lib/browser/FileCard-HJIZDWJF.mjs.map +0 -7
- package/dist/lib/browser/FileMain-WEWTX7QB.mjs +0 -27
- package/dist/lib/browser/FileMain-WEWTX7QB.mjs.map +0 -7
- package/dist/lib/browser/FileSection-BEUGJ7EI.mjs +0 -24
- package/dist/lib/browser/FileSection-BEUGJ7EI.mjs.map +0 -7
- package/dist/lib/browser/FileSlide-NYBGZEZS.mjs +0 -21
- package/dist/lib/browser/FileSlide-NYBGZEZS.mjs.map +0 -7
- package/dist/lib/browser/chunk-2I63TM7M.mjs +0 -27
- package/dist/lib/browser/chunk-2I63TM7M.mjs.map +0 -7
- package/dist/lib/browser/chunk-JDSKIDDR.mjs +0 -30
- package/dist/lib/browser/chunk-JDSKIDDR.mjs.map +0 -7
- package/dist/lib/browser/chunk-VL3H7P4F.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/types/src/common.d.ts.map +0 -1
- package/dist/types/src/components/FileCard.d.ts +0 -9
- package/dist/types/src/components/FileCard.d.ts.map +0 -1
- package/dist/types/src/components/FileMain.d.ts +0 -7
- package/dist/types/src/components/FileMain.d.ts.map +0 -1
- package/dist/types/src/components/FileSection.d.ts +0 -8
- package/dist/types/src/components/FileSection.d.ts.map +0 -1
- package/dist/types/src/components/FileSlide.d.ts +0 -8
- package/dist/types/src/components/FileSlide.d.ts.map +0 -1
- package/dist/types/src/load.d.ts +0 -8
- package/dist/types/src/load.d.ts.map +0 -1
- package/dist/types/src/upload.d.ts +0 -10
- package/dist/types/src/upload.d.ts.map +0 -1
- package/dist/types/src/wnfs-url.d.ts +0 -2
- package/dist/types/src/wnfs-url.d.ts.map +0 -1
- package/src/components/FileCard.tsx +0 -45
- package/src/components/FileMain.tsx +0 -28
- package/src/components/FileSection.tsx +0 -20
- package/src/components/FileSlide.tsx +0 -20
- package/src/extensions/image.ts +0 -244
- package/src/wnfs-url.ts +0 -7
- /package/dist/types/src/{common.d.ts → helpers/common.d.ts} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
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, PrivateForest, PrivateDirectory, PrivateNode } from 'wnfs';\n\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { Rng, store } from './common';\nimport { type WnfsCapabilities } from '../capabilities';\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 directory,\n forest,\n}: {\n wnfsUrl: string;\n blockstore: Blockstore;\n directory: PrivateDirectory;\n forest: PrivateForest;\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]);\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 { Rng, filePath, store } from './common';\nimport { loadWnfs } from './load';\nimport { wnfsUrl } from './wnfs-url';\nimport { type WnfsCapabilities } from '../capabilities';\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,OAAOC,OAAON,K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ACpB,YAAYC,SAAS;AACrB,SAASC,UAAAA,eAAc;AAGvB,SAASC,WAAW;;AAOb,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", "PrivateForest", "PrivateDirectory", "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", "directory", "forest", "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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// packages/plugins/plugin-wnfs/src/capabilities/index.ts
|
|
2
|
+
import { lazy } from "@dxos/app-framework";
|
|
3
|
+
var Blockstore = lazy(() => import("./blockstore-6U5XTSIH.mjs"));
|
|
4
|
+
var FileUploader = lazy(() => import("./file-uploader-EDHMSKYS.mjs"));
|
|
5
|
+
var IntentResolver = lazy(() => import("./intent-resolver-WDO4EIG3.mjs"));
|
|
6
|
+
var Markdown = lazy(() => import("./markdown-MGSH5CVQ.mjs"));
|
|
7
|
+
var ReactSurface = lazy(() => import("./react-surface-EBQICOUA.mjs"));
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
Blockstore,
|
|
11
|
+
FileUploader,
|
|
12
|
+
IntentResolver,
|
|
13
|
+
Markdown,
|
|
14
|
+
ReactSurface
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-YLGCDZV3.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WnfsAction
|
|
3
|
+
} from "./chunk-EMRQJXBW.mjs";
|
|
4
|
+
import "./chunk-6YFT42F7.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-wnfs/src/capabilities/file-uploader.ts
|
|
7
|
+
import { Effect, pipe } from "effect";
|
|
8
|
+
import { Capabilities, chain, contributes, createIntent } from "@dxos/app-framework";
|
|
9
|
+
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
10
|
+
var file_uploader_default = (context) => {
|
|
11
|
+
return contributes(Capabilities.FileUploader, (file, space) => {
|
|
12
|
+
const { dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
13
|
+
const program = Effect.gen(function* () {
|
|
14
|
+
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, {
|
|
15
|
+
file,
|
|
16
|
+
space
|
|
17
|
+
}));
|
|
18
|
+
yield* dispatch(pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, {
|
|
19
|
+
target: space
|
|
20
|
+
})));
|
|
21
|
+
return fileInfo;
|
|
22
|
+
});
|
|
23
|
+
return Effect.runPromise(program);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
file_uploader_default as default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=file-uploader-EDHMSKYS.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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, chain, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';\nimport { SpaceAction } from '@dxos/plugin-space/types';\n\nimport { WnfsAction } from '../types';\n\nexport default (context: PluginsContext) => {\n return contributes(Capabilities.FileUploader, (file, space) => {\n const { dispatch } = context.requestCapability(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,cAAcC,OAAOC,aAAaC,oBAAyC;AACpF,SAASC,mBAAmB;AAI5B,IAAA,wBAAe,CAACC,YAAAA;AACd,SAAOC,YAAYC,aAAaC,cAAc,CAACC,MAAMC,UAAAA;AACnD,UAAM,EAAEC,SAAQ,IAAKN,QAAQO,kBAAkBL,aAAaM,gBAAgB;AAE5E,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", "requestCapability", "IntentDispatcher", "program", "Effect", "gen", "fileInfo", "createIntent", "WnfsAction", "Upload", "pipe", "Create", "chain", "SpaceAction", "AddObject", "target", "runPromise"]
|
|
7
|
+
}
|