@dxos/plugin-wnfs 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (147) hide show
  1. package/dist/lib/browser/FileContainer-EILNV5LV.mjs +74 -0
  2. package/dist/lib/browser/FileContainer-EILNV5LV.mjs.map +7 -0
  3. package/dist/lib/browser/blockstore-Q66HQJ4Q.mjs +191 -0
  4. package/dist/lib/browser/blockstore-Q66HQJ4Q.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-BXGCJRL2.mjs +155 -0
  6. package/dist/lib/browser/chunk-BXGCJRL2.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-HXVPBJ3A.mjs +56 -0
  8. package/dist/lib/browser/chunk-HXVPBJ3A.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-D6VTEQIE.mjs → chunk-UC4HMNZZ.mjs} +23 -13
  10. package/dist/lib/browser/chunk-UC4HMNZZ.mjs.map +7 -0
  11. package/dist/lib/browser/file-uploader-QL4DTOMM.mjs +35 -0
  12. package/dist/lib/browser/file-uploader-QL4DTOMM.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +85 -84
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/{markdown-5XD3I2NQ.mjs → markdown-AYCVG6TJ.mjs} +33 -41
  16. package/dist/lib/browser/markdown-AYCVG6TJ.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/operation-resolver-YYWUF6EY.mjs +99 -0
  19. package/dist/lib/browser/operation-resolver-YYWUF6EY.mjs.map +7 -0
  20. package/dist/lib/browser/react-surface-3LKVDPH7.mjs +60 -0
  21. package/dist/lib/browser/react-surface-3LKVDPH7.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +9 -6
  23. package/dist/types/src/WnfsPlugin.d.ts +2 -1
  24. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/blockstore/blockstore.d.ts +5 -0
  26. package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
  28. package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +6 -0
  30. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
  31. package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
  32. package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
  33. package/dist/types/src/capabilities/index.d.ts +5 -6
  34. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  36. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  38. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  40. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  42. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  44. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  46. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  47. package/dist/types/src/components/index.d.ts +1 -1
  48. package/dist/types/src/components/index.d.ts.map +1 -1
  49. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  50. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  51. package/dist/types/src/containers/FileContainer/index.d.ts +3 -0
  52. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  53. package/dist/types/src/containers/index.d.ts +3 -0
  54. package/dist/types/src/containers/index.d.ts.map +1 -0
  55. package/dist/types/src/extensions/image.d.ts +1 -1
  56. package/dist/types/src/extensions/image.d.ts.map +1 -1
  57. package/dist/types/src/helpers/load.d.ts +1 -1
  58. package/dist/types/src/helpers/load.d.ts.map +1 -1
  59. package/dist/types/src/helpers/upload.d.ts +1 -1
  60. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  61. package/dist/types/src/index.d.ts +1 -1
  62. package/dist/types/src/index.d.ts.map +1 -1
  63. package/dist/types/src/meta.d.ts +2 -2
  64. package/dist/types/src/meta.d.ts.map +1 -1
  65. package/dist/types/src/translations.d.ts +6 -3
  66. package/dist/types/src/translations.d.ts.map +1 -1
  67. package/dist/types/src/types/File.d.ts +16 -0
  68. package/dist/types/src/types/File.d.ts.map +1 -0
  69. package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
  70. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  71. package/dist/types/src/types/index.d.ts +2 -1
  72. package/dist/types/src/types/index.d.ts.map +1 -1
  73. package/dist/types/src/types/types.d.ts +107 -46
  74. package/dist/types/src/types/types.d.ts.map +1 -1
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +43 -36
  77. package/src/WnfsPlugin.tsx +49 -68
  78. package/src/capabilities/blockstore/blockstore.ts +22 -0
  79. package/src/capabilities/blockstore/index.ts +7 -0
  80. package/src/capabilities/file-uploader/file-uploader.ts +34 -0
  81. package/src/capabilities/file-uploader/index.ts +7 -0
  82. package/src/capabilities/index.ts +5 -9
  83. package/src/capabilities/markdown/index.ts +7 -0
  84. package/src/capabilities/markdown/markdown.ts +33 -0
  85. package/src/capabilities/operation-resolver/index.ts +7 -0
  86. package/src/capabilities/operation-resolver/operation-resolver.ts +62 -0
  87. package/src/capabilities/react-surface/index.ts +7 -0
  88. package/src/capabilities/react-surface/react-surface.tsx +51 -0
  89. package/src/components/FileInput.tsx +3 -3
  90. package/src/components/FilePreview.tsx +1 -1
  91. package/src/components/index.ts +1 -4
  92. package/src/containers/FileContainer/FileContainer.tsx +58 -0
  93. package/src/containers/FileContainer/index.ts +7 -0
  94. package/src/containers/index.ts +7 -0
  95. package/src/extensions/image.stories.tsx +4 -4
  96. package/src/extensions/image.tsx +6 -6
  97. package/src/helpers/load.ts +12 -7
  98. package/src/helpers/upload.ts +5 -2
  99. package/src/index.ts +1 -1
  100. package/src/meta.ts +8 -3
  101. package/src/translations.ts +6 -3
  102. package/src/types/File.ts +24 -0
  103. package/src/{capabilities → types}/capabilities.ts +3 -3
  104. package/src/types/index.ts +2 -1
  105. package/src/types/types.ts +54 -14
  106. package/dist/lib/browser/FileContainer-A4OJVMVS.mjs +0 -103
  107. package/dist/lib/browser/FileContainer-A4OJVMVS.mjs.map +0 -7
  108. package/dist/lib/browser/blockstore-HK4IYHJJ.mjs +0 -273
  109. package/dist/lib/browser/blockstore-HK4IYHJJ.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
  111. package/dist/lib/browser/chunk-FYRZOKHG.mjs +0 -13
  112. package/dist/lib/browser/chunk-FYRZOKHG.mjs.map +0 -7
  113. package/dist/lib/browser/chunk-PAIK4SJ3.mjs +0 -16
  114. package/dist/lib/browser/chunk-PAIK4SJ3.mjs.map +0 -7
  115. package/dist/lib/browser/chunk-QQB5IBX7.mjs +0 -64
  116. package/dist/lib/browser/chunk-QQB5IBX7.mjs.map +0 -7
  117. package/dist/lib/browser/chunk-Y5JMTQ74.mjs +0 -16
  118. package/dist/lib/browser/chunk-Y5JMTQ74.mjs.map +0 -7
  119. package/dist/lib/browser/file-uploader-5S37ZZCW.mjs +0 -30
  120. package/dist/lib/browser/file-uploader-5S37ZZCW.mjs.map +0 -7
  121. package/dist/lib/browser/intent-resolver-3KMIEDBO.mjs +0 -49
  122. package/dist/lib/browser/intent-resolver-3KMIEDBO.mjs.map +0 -7
  123. package/dist/lib/browser/markdown-5XD3I2NQ.mjs.map +0 -7
  124. package/dist/lib/browser/react-surface-5D7M3Y4W.mjs +0 -88
  125. package/dist/lib/browser/react-surface-5D7M3Y4W.mjs.map +0 -7
  126. package/dist/types/src/capabilities/blockstore.d.ts +0 -4
  127. package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
  128. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  129. package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
  130. package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
  131. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  132. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  133. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  134. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  135. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  136. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  137. package/dist/types/src/components/FileContainer.d.ts +0 -9
  138. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  139. package/dist/types/src/types/file.d.ts +0 -16
  140. package/dist/types/src/types/file.d.ts.map +0 -1
  141. package/src/capabilities/blockstore.ts +0 -19
  142. package/src/capabilities/file-uploader.ts +0 -27
  143. package/src/capabilities/intent-resolver.ts +0 -33
  144. package/src/capabilities/markdown.ts +0 -26
  145. package/src/capabilities/react-surface.tsx +0 -45
  146. package/src/components/FileContainer.tsx +0 -49
  147. package/src/types/file.ts +0 -17
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers/upload.ts", "../../../src/helpers/common.ts", "../../../src/helpers/load.ts", "../../../src/helpers/wnfs-url.ts"],
4
+ "sourcesContent": ["//\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 { Obj } from '@dxos/echo';\nimport { log } from '@dxos/log';\n\nimport { type WnfsCapabilities } from '../types';\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 Obj.change(space.properties, (p) => {\n p.wnfs.privateForestCid = CID.decode(cidBytes).toString();\n });\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", "//\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 { Obj } from '@dxos/echo';\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { type WnfsCapabilities } from '../types';\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 Obj.change(space.properties, (p) => {\n delete p['wnfs_access_key'];\n delete p['wnfs_private_forest_cid'];\n });\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 Obj.change(space.properties, (p) => {\n p.wnfs = {\n accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),\n privateForestCid: CID.decode(cidBytes).toString(),\n };\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"],
5
+ "mappings": ";AAKA,SAASA,OAAAA,YAAW;AACpB,YAAYC,SAAS;AACrB,SAASC,UAAAA,eAAc;AAGvB,SAASC,OAAAA,YAAW;AACpB,SAASC,WAAW;;;ACNpB,SAASC,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,UAAA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"names": ["CID", "Raw", "sha256", "Obj", "log", "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", "Obj", "loadWnfs", "space", "blockstore", "instances", "properties", "wnfs_access_key", "undefined", "wnfs_private_forest_cid", "Obj", "change", "p", "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", "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", "Obj", "change", "properties", "p", "wnfs", "privateForestCid", "decode", "info", "name", "type", "url", "wnfsUrl", "log"]
7
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ WnfsOperation
3
+ } from "./chunk-BXGCJRL2.mjs";
4
+
5
+ // src/capabilities/file-uploader/file-uploader.ts
6
+ import * as Effect from "effect/Effect";
7
+ import { Capabilities, Capability } from "@dxos/app-framework";
8
+ import { AppCapabilities } from "@dxos/app-toolkit";
9
+ import { runAndForwardErrors } from "@dxos/effect";
10
+ import { SpaceOperation } from "@dxos/plugin-space/types";
11
+ var file_uploader_default = Capability.makeModule(Effect.fnUntraced(function* () {
12
+ const capabilities = yield* Capability.Service;
13
+ return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {
14
+ const { invoke } = capabilities.get(Capabilities.OperationInvoker);
15
+ const program = Effect.gen(function* () {
16
+ const fileInfo = yield* invoke(WnfsOperation.Upload, {
17
+ db,
18
+ file
19
+ });
20
+ const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
21
+ if (createResult?.object) {
22
+ yield* invoke(SpaceOperation.AddObject, {
23
+ target: db,
24
+ object: createResult.object
25
+ });
26
+ }
27
+ return fileInfo;
28
+ });
29
+ return runAndForwardErrors(program);
30
+ });
31
+ }));
32
+ export {
33
+ file_uploader_default as default
34
+ };
35
+ //# sourceMappingURL=file-uploader-QL4DTOMM.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/capabilities/file-uploader/file-uploader.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { SpaceOperation } from '@dxos/plugin-space/types';\n\nimport { WnfsOperation } from '../../types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Get context for lazy capability access in callbacks.\n const capabilities = yield* Capability.Service;\n\n return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {\n const { invoke } = capabilities.get(Capabilities.OperationInvoker);\n const program = Effect.gen(function* () {\n const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });\n const createResult = yield* invoke(WnfsOperation.Create, fileInfo);\n if (createResult?.object) {\n yield* invoke(SpaceOperation.AddObject, { target: db, object: createResult.object });\n }\n\n return fileInfo;\n });\n\n return runAndForwardErrors(program);\n });\n }),\n);\n"],
5
+ "mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,uBAAuB;AAChC,SAASC,2BAA2B;AACpC,SAASC,sBAAsB;AAI/B,IAAA,wBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,SAAOJ,WAAWK,YAAYC,gBAAgBC,cAAc,CAACC,IAAIC,SAAAA;AAC/D,UAAM,EAAEC,OAAM,IAAKP,aAAaQ,IAAIC,aAAaC,gBAAgB;AACjE,UAAMC,UAAiBC,WAAI,aAAA;AACzB,YAAMC,WAAW,OAAON,OAAOO,cAAcC,QAAQ;QAAEV;QAAIC;MAAK,CAAA;AAChE,YAAMU,eAAe,OAAOT,OAAOO,cAAcG,QAAQJ,QAAAA;AACzD,UAAIG,cAAcE,QAAQ;AACxB,eAAOX,OAAOY,eAAeC,WAAW;UAAEC,QAAQhB;UAAIa,QAAQF,aAAaE;QAAO,CAAA;MACpF;AAEA,aAAOL;IACT,CAAA;AAEA,WAAOS,oBAAoBX,OAAAA;EAC7B,CAAA;AACF,CAAA,CAAA;",
6
+ "names": ["Effect", "Capabilities", "Capability", "AppCapabilities", "runAndForwardErrors", "SpaceOperation", "Capability", "makeModule", "fnUntraced", "capabilities", "Service", "contributes", "AppCapabilities", "FileUploader", "db", "file", "invoke", "get", "Capabilities", "OperationInvoker", "program", "gen", "fileInfo", "WnfsOperation", "Upload", "createResult", "Create", "object", "SpaceOperation", "AddObject", "target", "runAndForwardErrors"]
7
+ }
@@ -1,42 +1,56 @@
1
1
  import {
2
- Blockstore,
3
- FileUploader,
4
- IntentResolver,
5
- Markdown,
6
- ReactSurface
7
- } from "./chunk-Y5JMTQ74.mjs";
8
- import {
9
- WnfsCapabilities
10
- } from "./chunk-PAIK4SJ3.mjs";
11
- import {
12
- FileType,
13
- WnfsAction
14
- } from "./chunk-QQB5IBX7.mjs";
15
- import {
2
+ File_exports,
3
+ WnfsAction,
4
+ WnfsCapabilities,
5
+ WnfsOperation,
16
6
  meta
17
- } from "./chunk-FYRZOKHG.mjs";
7
+ } from "./chunk-BXGCJRL2.mjs";
18
8
 
19
9
  // src/WnfsPlugin.tsx
20
- import * as Function from "effect/Function";
21
- import { Capabilities, Events, chain, contributes, createIntent, defineModule, definePlugin } from "@dxos/app-framework";
10
+ import * as Effect from "effect/Effect";
11
+ import { Capability as Capability6, Plugin } from "@dxos/app-framework";
12
+ import { AppPlugin } from "@dxos/app-toolkit";
13
+ import { Operation } from "@dxos/operation";
22
14
  import { ClientEvents } from "@dxos/plugin-client";
23
15
  import { MarkdownEvents } from "@dxos/plugin-markdown";
24
- import { SpaceCapabilities } from "@dxos/plugin-space";
25
- import { defineObjectForm } from "@dxos/plugin-space/types";
16
+ import { SpaceCapabilities, SpaceEvents } from "@dxos/plugin-space";
17
+
18
+ // src/capabilities/blockstore/index.ts
19
+ import { Capability } from "@dxos/app-framework";
20
+ var Blockstore = Capability.lazy("Blockstore", () => import("./blockstore-Q66HQJ4Q.mjs"));
21
+
22
+ // src/capabilities/file-uploader/index.ts
23
+ import { Capability as Capability2 } from "@dxos/app-framework";
24
+ var FileUploader = Capability2.lazy("FileUploader", () => import("./file-uploader-QL4DTOMM.mjs"));
25
+
26
+ // src/capabilities/markdown/index.ts
27
+ import { Capability as Capability3 } from "@dxos/app-framework";
28
+ var Markdown = Capability3.lazy("Markdown", () => import("./markdown-AYCVG6TJ.mjs"));
29
+
30
+ // src/capabilities/operation-resolver/index.ts
31
+ import { Capability as Capability4 } from "@dxos/app-framework";
32
+ var OperationResolver = Capability4.lazy("OperationResolver", () => import("./operation-resolver-YYWUF6EY.mjs"));
33
+
34
+ // src/capabilities/react-surface/index.ts
35
+ import { Capability as Capability5 } from "@dxos/app-framework";
36
+ var ReactSurface = Capability5.lazy("ReactSurface", () => import("./react-surface-3LKVDPH7.mjs"));
26
37
 
27
38
  // src/translations.ts
28
39
  var translations = [
29
40
  {
30
41
  "en-US": {
31
- [FileType.typename]: {
42
+ [File_exports.File.typename]: {
32
43
  "typename label": "File",
44
+ "typename label_zero": "Files",
45
+ "typename label_one": "File",
46
+ "typename label_other": "Files",
33
47
  "object name placeholder": "New file",
34
48
  "rename object label": "Rename file",
35
- "delete object label": "Delete file"
49
+ "delete object label": "Delete file",
50
+ "object deleted label": "File deleted"
36
51
  },
37
52
  [meta.id]: {
38
53
  "plugin name": "Files",
39
- "delete object label": "Delete",
40
54
  "file input placeholder": "Drop a file here, or click to select a file"
41
55
  }
42
56
  }
@@ -44,70 +58,57 @@ var translations = [
44
58
  ];
45
59
 
46
60
  // src/WnfsPlugin.tsx
47
- var WnfsPlugin = definePlugin(meta, () => [
48
- defineModule({
49
- id: `${meta.id}/module/blockstore`,
50
- activatesOn: ClientEvents.ClientReady,
51
- activate: Blockstore
52
- }),
53
- defineModule({
54
- id: `${meta.id}/module/instances`,
55
- activatesOn: ClientEvents.ClientReady,
56
- activate: () => {
57
- const instances = {};
58
- return contributes(WnfsCapabilities.Instances, instances);
61
+ var WnfsPlugin = Plugin.define(meta).pipe(AppPlugin.addMetadataModule({
62
+ metadata: {
63
+ id: File_exports.File.typename,
64
+ metadata: {
65
+ // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
66
+ icon: "ph--file--regular",
67
+ iconHue: "teal",
68
+ inputSchema: WnfsAction.UploadFileSchema,
69
+ createObject: (props, { db }) => Effect.gen(function* () {
70
+ const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, {
71
+ ...props,
72
+ db
73
+ });
74
+ return object;
75
+ })
59
76
  }
60
- }),
61
- defineModule({
62
- id: `${meta.id}/module/translations`,
63
- activatesOn: Events.SetupTranslations,
64
- activate: () => contributes(Capabilities.Translations, translations)
65
- }),
66
- defineModule({
67
- id: `${meta.id}/module/metadata`,
68
- activatesOn: Events.SetupMetadata,
69
- activate: () => contributes(Capabilities.Metadata, {
70
- id: FileType.typename,
71
- metadata: {
72
- label: (object) => object instanceof FileType ? object.name : void 0,
73
- // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
74
- icon: "ph--file--regular"
75
- }
76
- })
77
- }),
78
- defineModule({
79
- id: `${meta.id}/module/object-form`,
80
- activatesOn: ClientEvents.SetupSchema,
81
- activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
82
- objectSchema: FileType,
83
- formSchema: WnfsAction.UploadFileSchema,
84
- getIntent: (props, options) => Function.pipe(createIntent(WnfsAction.Upload, {
85
- ...props,
86
- space: options.space
87
- }), chain(WnfsAction.Create, {}))
88
- }))
89
- }),
90
- defineModule({
91
- id: `${meta.id}/module/file-uploader`,
92
- activatesOn: ClientEvents.ClientReady,
93
- activate: FileUploader
94
- }),
95
- defineModule({
96
- id: `${meta.id}/module/markdown`,
97
- activatesOn: MarkdownEvents.SetupExtensions,
98
- activate: Markdown
99
- }),
100
- defineModule({
101
- id: `${meta.id}/module/react-surface`,
102
- activatesOn: Events.SetupReactSurface,
103
- activate: ReactSurface
104
- }),
105
- defineModule({
106
- id: `${meta.id}/module/intent-resolver`,
107
- activatesOn: Events.SetupIntentResolver,
108
- activate: IntentResolver
77
+ }
78
+ }), AppPlugin.addOperationResolverModule({
79
+ activate: OperationResolver
80
+ }), AppPlugin.addSchemaModule({
81
+ schema: [
82
+ File_exports.File
83
+ ]
84
+ }), AppPlugin.addSurfaceModule({
85
+ activate: ReactSurface
86
+ }), AppPlugin.addTranslationsModule({
87
+ translations
88
+ }), Plugin.addModule({
89
+ id: "blockstore",
90
+ activatesOn: ClientEvents.ClientReady,
91
+ activate: Blockstore
92
+ }), Plugin.addModule({
93
+ id: "instances",
94
+ activatesOn: ClientEvents.ClientReady,
95
+ activate: () => Effect.sync(() => {
96
+ const instances = {};
97
+ return Capability6.contributes(WnfsCapabilities.Instances, instances);
109
98
  })
110
- ]);
99
+ }), Plugin.addModule({
100
+ id: "on-space-created",
101
+ activatesOn: SpaceEvents.SpaceCreated,
102
+ activate: () => Effect.succeed(Capability6.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation.invoke(WnfsOperation.OnCreateSpace, params)))
103
+ }), Plugin.addModule({
104
+ id: "file-uploader",
105
+ activatesOn: ClientEvents.ClientReady,
106
+ activate: FileUploader
107
+ }), Plugin.addModule({
108
+ id: "markdown",
109
+ activatesOn: MarkdownEvents.SetupExtensions,
110
+ activate: Markdown
111
+ }), Plugin.make);
111
112
  export {
112
113
  WnfsCapabilities,
113
114
  WnfsPlugin,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/WnfsPlugin.tsx", "../../../src/translations.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\n\nimport {\n Capabilities,\n Events,\n chain,\n contributes,\n createIntent,\n defineModule,\n definePlugin,\n} from '@dxos/app-framework';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { MarkdownEvents } from '@dxos/plugin-markdown';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport { Blockstore, FileUploader, IntentResolver, Markdown, ReactSurface, WnfsCapabilities } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { FileType, WnfsAction } from './types';\n\nexport const WnfsPlugin = definePlugin(meta, () => [\n defineModule({\n id: `${meta.id}/module/blockstore`,\n activatesOn: ClientEvents.ClientReady,\n activate: Blockstore,\n }),\n defineModule({\n id: `${meta.id}/module/instances`,\n activatesOn: ClientEvents.ClientReady,\n activate: () => {\n const instances: WnfsCapabilities.Instances = {};\n return contributes(WnfsCapabilities.Instances, instances);\n },\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: FileType.typename,\n metadata: {\n label: (object: any) => (object instanceof FileType ? object.name : undefined),\n // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.\n icon: 'ph--file--regular',\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: FileType,\n formSchema: WnfsAction.UploadFileSchema,\n getIntent: (props, options) =>\n Function.pipe(\n createIntent(WnfsAction.Upload, { ...props, space: options.space }),\n chain(WnfsAction.Create, {}),\n ),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/file-uploader`,\n activatesOn: ClientEvents.ClientReady,\n activate: FileUploader,\n }),\n defineModule({\n id: `${meta.id}/module/markdown`,\n activatesOn: MarkdownEvents.SetupExtensions,\n activate: Markdown,\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { FileType } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [FileType.typename]: {\n 'typename label': 'File',\n 'object name placeholder': 'New file',\n 'rename object label': 'Rename file',\n 'delete object label': 'Delete file',\n },\n [meta.id]: {\n 'plugin name': 'Files',\n 'delete object label': 'Delete',\n 'file input placeholder': 'Drop a file here, or click to select a file',\n },\n },\n },\n] as const satisfies Resource[];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAIA,YAAYA,cAAc;AAE1B,SACEC,cACAC,QACAC,OACAC,aACAC,cACAC,cACAC,oBACK;AACP,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;;;ACT1B,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,SAASC,Q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aAAaC,aAAaC;IAC1BC,UAAUsC;EACZ,CAAA;EACA3C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAa0C,eAAeC;IAC5BxC,UAAUyC;EACZ,CAAA;EACA9C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaS,OAAOoC;IACpB1C,UAAU2C;EACZ,CAAA;EACAhD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaS,OAAOsC;IACpB5C,UAAU6C;EACZ,CAAA;CACD;",
6
- "names": ["Function", "Capabilities", "Events", "chain", "contributes", "createIntent", "defineModule", "definePlugin", "ClientEvents", "MarkdownEvents", "SpaceCapabilities", "defineObjectForm", "translations", "FileType", "typename", "meta", "id", "WnfsPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "ClientEvents", "ClientReady", "activate", "Blockstore", "instances", "contributes", "WnfsCapabilities", "Instances", "Events", "SetupTranslations", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "FileType", "typename", "metadata", "label", "object", "name", "undefined", "icon", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "formSchema", "WnfsAction", "UploadFileSchema", "getIntent", "props", "options", "pipe", "createIntent", "Upload", "space", "chain", "Create", "FileUploader", "MarkdownEvents", "SetupExtensions", "Markdown", "SetupReactSurface", "ReactSurface", "SetupIntentResolver", "IntentResolver"]
3
+ "sources": ["../../../src/WnfsPlugin.tsx", "../../../src/capabilities/blockstore/index.ts", "../../../src/capabilities/file-uploader/index.ts", "../../../src/capabilities/markdown/index.ts", "../../../src/capabilities/operation-resolver/index.ts", "../../../src/capabilities/react-surface/index.ts", "../../../src/translations.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability, Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/operation';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { MarkdownEvents } from '@dxos/plugin-markdown';\nimport { SpaceCapabilities, SpaceEvents } from '@dxos/plugin-space';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { Blockstore, FileUploader, Markdown, OperationResolver, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { WnfsAction, WnfsCapabilities, WnfsFile, WnfsOperation } from './types';\n\nexport const WnfsPlugin = Plugin.define(meta).pipe(\n AppPlugin.addMetadataModule({\n metadata: {\n id: WnfsFile.File.typename,\n metadata: {\n // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.\n icon: 'ph--file--regular',\n iconHue: 'teal',\n inputSchema: WnfsAction.UploadFileSchema,\n createObject: ((props, { db }) =>\n Effect.gen(function* () {\n const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db });\n return object;\n })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addOperationResolverModule({ activate: OperationResolver }),\n AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n id: 'blockstore',\n activatesOn: ClientEvents.ClientReady,\n activate: Blockstore,\n }),\n Plugin.addModule({\n id: 'instances',\n activatesOn: ClientEvents.ClientReady,\n activate: () =>\n Effect.sync(() => {\n const instances: WnfsCapabilities.Instances = {};\n return Capability.contributes(WnfsCapabilities.Instances, instances);\n }),\n }),\n Plugin.addModule({\n id: 'on-space-created',\n activatesOn: SpaceEvents.SpaceCreated,\n activate: () =>\n Effect.succeed(\n Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) =>\n Operation.invoke(WnfsOperation.OnCreateSpace, params),\n ),\n ),\n }),\n Plugin.addModule({\n id: 'file-uploader',\n activatesOn: ClientEvents.ClientReady,\n activate: FileUploader,\n }),\n Plugin.addModule({\n id: 'markdown',\n activatesOn: MarkdownEvents.SetupExtensions,\n activate: Markdown,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const Markdown = Capability.lazy('Markdown', () => import('./markdown'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const OperationResolver = Capability.lazy('OperationResolver', () => import('./operation-resolver'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { WnfsFile } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [WnfsFile.File.typename]: {\n 'typename label': 'File',\n 'typename label_zero': 'Files',\n 'typename label_one': 'File',\n 'typename label_other': 'Files',\n 'object name placeholder': 'New file',\n 'rename object label': 'Rename file',\n 'delete object label': 'Delete file',\n 'object deleted label': 'File deleted',\n },\n [meta.id]: {\n 'plugin name': 'Files',\n 'file input placeholder': 'Drop a file here, or click to select a file',\n },\n },\n },\n] as const satisfies Resource[];\n"],
5
+ "mappings": ";;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAAA,aAAYC,cAAc;AACnC,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,mBAAmBC,mBAAmB;;;ACP/C,SAASC,kBAAkB;AAEpB,IAAMC,aAAaC,WAAWC,KAAK,cAAc,MAAM,OAAO,2BAAA,CAAA;;;ACFrE,SAASC,cAAAA,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AAa,CAAA,GAC/CjC,OAAOkC,UAAU;EACf3B,IAAI;EACJ4B,aAAaC,aAAaC;EAC1BX,UAAUY;AACZ,CAAA,GACAtC,OAAOkC,UAAU;EACf3B,IAAI;EACJ4B,aAAaC,aAAaC;EAC1BX,UAAU,MACDa,YAAK,MAAA;AACV,UAAMC,YAAwC,CAAC;AAC/C,WAAOC,YAAWC,YAAYC,iBAAiBC,WAAWJ,SAAAA;EAC5D,CAAA;AACJ,CAAA,GACAxC,OAAOkC,UAAU;EACf3B,IAAI;EACJ4B,aAAaU,YAAYC;EACzBpB,UAAU,MACDqB,eACLN,YAAWC,YAAYM,kBAAkBC,eAAe,CAACC,WACvD7B,UAAUC,OAAOC,cAAc0B,eAAeC,MAAAA,CAAAA,CAAAA;AAGtD,CAAA,GACAlD,OAAOkC,UAAU;EACf3B,IAAI;EACJ4B,aAAaC,aAAaC;EAC1BX,UAAUyB;AACZ,CAAA,GACAnD,OAAOkC,UAAU;EACf3B,IAAI;EACJ4B,aAAaiB,eAAeC;EAC5B3B,UAAU4B;AACZ,CAAA,GACAtD,OAAOuD,IAAI;",
6
+ "names": ["Effect", "Capability", "Plugin", "AppPlugin", "Operation", "ClientEvents", "MarkdownEvents", "SpaceCapabilities", "SpaceEvents", "Capability", "Blockstore", "Capability", "lazy", "Capability", "FileUploader", "Capability", "lazy", "Capability", "Markdown", "Capability", "lazy", "Capability", "OperationResolver", "Capability", "lazy", "Capability", "ReactSurface", "Capability", "lazy", "translations", "WnfsFile", "File", "typename", "meta", "id", "WnfsPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addMetadataModule", "metadata", "id", "WnfsFile", "File", "typename", "icon", "iconHue", "inputSchema", "WnfsAction", "UploadFileSchema", "createObject", "props", "db", "gen", "object", "Operation", "invoke", "WnfsOperation", "CreateFile", "addOperationResolverModule", "activate", "OperationResolver", "addSchemaModule", "schema", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations", "addModule", "activatesOn", "ClientEvents", "ClientReady", "Blockstore", "sync", "instances", "Capability", "contributes", "WnfsCapabilities", "Instances", "SpaceEvents", "SpaceCreated", "succeed", "SpaceCapabilities", "OnCreateSpace", "params", "FileUploader", "MarkdownEvents", "SetupExtensions", "Markdown", "make"]
7
7
  }
@@ -2,14 +2,14 @@ import {
2
2
  getBlobUrl,
3
3
  getPathFromUrl,
4
4
  loadWnfs
5
- } from "./chunk-D6VTEQIE.mjs";
5
+ } from "./chunk-UC4HMNZZ.mjs";
6
6
  import {
7
7
  WnfsCapabilities
8
- } from "./chunk-PAIK4SJ3.mjs";
9
- import "./chunk-FYRZOKHG.mjs";
8
+ } from "./chunk-BXGCJRL2.mjs";
10
9
 
11
- // src/capabilities/markdown.ts
12
- import { contributes } from "@dxos/app-framework";
10
+ // src/capabilities/markdown/markdown.ts
11
+ import * as Effect from "effect/Effect";
12
+ import { Capability } from "@dxos/app-framework";
13
13
  import { MarkdownCapabilities } from "@dxos/plugin-markdown";
14
14
  import { getSpace } from "@dxos/react-client/echo";
15
15
 
@@ -20,21 +20,8 @@ import { Decoration, EditorView, WidgetType } from "@codemirror/view";
20
20
  import React from "react";
21
21
  import { createRoot } from "react-dom/client";
22
22
  import { Status, ThemeProvider } from "@dxos/react-ui";
23
- import { focusField } from "@dxos/react-ui-editor";
24
- import { defaultTx } from "@dxos/react-ui-theme";
25
- function _define_property(obj, key, value) {
26
- if (key in obj) {
27
- Object.defineProperty(obj, key, {
28
- value,
29
- enumerable: true,
30
- configurable: true,
31
- writable: true
32
- });
33
- } else {
34
- obj[key] = value;
35
- }
36
- return obj;
37
- }
23
+ import { focusField } from "@dxos/ui-editor";
24
+ import { defaultTx } from "@dxos/ui-theme";
38
25
  var WAIT_UNTIL_LOADER = 1500;
39
26
  var image = (options) => {
40
27
  const blobUrlCache = {};
@@ -150,6 +137,11 @@ var createImg = (view, url) => {
150
137
  return img;
151
138
  };
152
139
  var WnfsImageWidget = class extends WidgetType {
140
+ _wnfsUrl;
141
+ _url;
142
+ constructor(_wnfsUrl, _url) {
143
+ super(), this._wnfsUrl = _wnfsUrl, this._url = _url;
144
+ }
153
145
  eq(other) {
154
146
  return this._wnfsUrl === other._wnfsUrl;
155
147
  }
@@ -180,30 +172,30 @@ var WnfsImageWidget = class extends WidgetType {
180
172
  });
181
173
  return widget;
182
174
  }
183
- constructor(_wnfsUrl, _url) {
184
- super(), _define_property(this, "_wnfsUrl", void 0), _define_property(this, "_url", void 0), this._wnfsUrl = _wnfsUrl, this._url = _url;
185
- }
186
175
  };
187
176
 
188
- // src/capabilities/markdown.ts
189
- var markdown_default = ((context) => contributes(MarkdownCapabilities.Extensions, [
190
- ({ document: document2 }) => {
191
- const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
192
- const instances = context.getCapability(WnfsCapabilities.Instances);
193
- if (document2) {
194
- const space = getSpace(document2);
195
- return space ? [
196
- image({
197
- blockstore,
198
- instances,
199
- space
200
- })
201
- ] : [];
177
+ // src/capabilities/markdown/markdown.ts
178
+ var markdown_default = Capability.makeModule(Effect.fnUntraced(function* () {
179
+ const capabilities = yield* Capability.Service;
180
+ return Capability.contributes(MarkdownCapabilities.Extensions, [
181
+ ({ document: document2 }) => {
182
+ const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
183
+ const instances = capabilities.get(WnfsCapabilities.Instances);
184
+ if (document2) {
185
+ const space = getSpace(document2);
186
+ return space ? [
187
+ image({
188
+ blockstore,
189
+ instances,
190
+ space
191
+ })
192
+ ] : [];
193
+ }
194
+ return [];
202
195
  }
203
- return [];
204
- }
205
- ]));
196
+ ]);
197
+ }));
206
198
  export {
207
199
  markdown_default as default
208
200
  };
209
- //# sourceMappingURL=markdown-5XD3I2NQ.mjs.map
201
+ //# sourceMappingURL=markdown-AYCVG6TJ.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/capabilities/markdown/markdown.ts", "../../../src/extensions/image.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { MarkdownCapabilities } from '@dxos/plugin-markdown';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { image } from '../../extensions';\nimport { WnfsCapabilities } from '../../types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Get context for lazy capability access in callbacks.\n const capabilities = yield* Capability.Service;\n\n return Capability.contributes(MarkdownCapabilities.Extensions, [\n ({ document }: { document?: any }) => {\n const blockstore = capabilities.get(WnfsCapabilities.Blockstore);\n const instances = capabilities.get(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);\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/ui-editor';\nimport { defaultTx } from '@dxos/ui-theme';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';\nimport { type WnfsCapabilities } from '../types';\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,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,4BAA4B;AACrC,SAASC,gBAAgB;;;ACJzB,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;A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3F,MAAM4E,UAAUC,MAAM/E,GAAAA;AAC5B4F,qBAAejB,OAAO+B,YAAYf,MAAAA;AAClChB,aAAO4B,YAAYrG,GAAAA;IACrB,CAAA;AAEA,WAAOyE;EACT;AACF;;;AD7LA,IAAA,mBAAegC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,SAAOJ,WAAWK,YAAYC,qBAAqBC,YAAY;IAC7D,CAAC,EAAEC,UAAAA,UAAQ,MAAsB;AAC/B,YAAMC,aAAaN,aAAaO,IAAIC,iBAAiBC,UAAU;AAC/D,YAAMC,YAAYV,aAAaO,IAAIC,iBAAiBG,SAAS;AAE7D,UAAIN,WAAU;AACZ,cAAMO,QAAQC,SAASR,SAAAA;AACvB,eAAOO,QAAQ;UAACE,MAAM;YAAER;YAAYI;YAAWE;UAAM,CAAA;YAAM,CAAA;MAC7D;AAEA,aAAO,CAAA;IACT;GACD;AACH,CAAA,CAAA;",
6
+ "names": ["Effect", "Capability", "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", "Capability", "makeModule", "fnUntraced", "capabilities", "Service", "contributes", "MarkdownCapabilities", "Extensions", "document", "blockstore", "get", "WnfsCapabilities", "Blockstore", "instances", "Instances", "space", "getSpace", "image"]
7
+ }