@dxos/plugin-script 0.8.4-main.67995b8 → 0.8.4-main.c4373fc

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 (271) hide show
  1. package/dist/lib/browser/DeploymentDialog-7FNPALCV.mjs +12 -0
  2. package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs +578 -0
  3. package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-24LLLTLB.mjs +149 -0
  5. package/dist/lib/browser/ScriptContainer-24LLLTLB.mjs.map +7 -0
  6. package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-DPYULSME.mjs} +9 -8
  7. package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +28 -0
  9. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-DXWTBOND.mjs} +26 -27
  11. package/dist/lib/browser/chunk-DXWTBOND.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-ETFBQURU.mjs} +71 -50
  13. package/dist/lib/browser/chunk-ETFBQURU.mjs.map +7 -0
  14. package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EZVXV6DA.mjs} +3 -5
  15. package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-I3THDIT5.mjs +90 -0
  17. package/dist/lib/browser/chunk-I3THDIT5.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-N6M34EUC.mjs +112 -0
  19. package/dist/lib/browser/chunk-N6M34EUC.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-NNYSARXK.mjs} +15 -15
  21. package/dist/lib/browser/chunk-NNYSARXK.mjs.map +7 -0
  22. package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-OKXN2N7M.mjs} +2 -2
  23. package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-SRSEZWDY.mjs} +159 -68
  24. package/dist/lib/browser/chunk-SRSEZWDY.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-SWBZUZDX.mjs +80 -0
  26. package/dist/lib/browser/chunk-SWBZUZDX.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-VFJJA4WR.mjs +88 -0
  28. package/dist/lib/browser/chunk-VFJJA4WR.mjs.map +7 -0
  29. package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-G2N2CG63.mjs} +24 -8
  30. package/dist/lib/browser/compiler-G2N2CG63.mjs.map +7 -0
  31. package/dist/lib/browser/index.mjs +96 -39
  32. package/dist/lib/browser/index.mjs.map +3 -3
  33. package/dist/lib/browser/{intent-resolver-S3H2SMUY.mjs → intent-resolver-FYZRLYNT.mjs} +29 -13
  34. package/dist/lib/browser/intent-resolver-FYZRLYNT.mjs.map +7 -0
  35. package/dist/lib/browser/meta.json +1 -1
  36. package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-CFRYAL2P.mjs} +36 -13
  37. package/dist/lib/browser/react-surface-CFRYAL2P.mjs.map +7 -0
  38. package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-L3HCZRBP.mjs} +8 -8
  39. package/dist/lib/browser/settings-L3HCZRBP.mjs.map +7 -0
  40. package/dist/lib/browser/templates/index.mjs +1 -1
  41. package/dist/lib/browser/types/index.mjs +6 -4
  42. package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs → DeploymentDialog-AKAGR37W.mjs} +5 -5
  43. package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs +579 -0
  44. package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs.map +7 -0
  45. package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.mjs +150 -0
  46. package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.mjs.map +7 -0
  47. package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-UXJGHXSL.mjs} +9 -8
  48. package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +7 -0
  49. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +30 -0
  50. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +7 -0
  51. package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-5IKGUOMI.mjs} +15 -15
  52. package/dist/lib/node-esm/chunk-5IKGUOMI.mjs.map +7 -0
  53. package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-7MR2L4T3.mjs} +26 -27
  54. package/dist/lib/node-esm/chunk-7MR2L4T3.mjs.map +7 -0
  55. package/dist/lib/node-esm/chunk-C33FKUSC.mjs +91 -0
  56. package/dist/lib/node-esm/chunk-C33FKUSC.mjs.map +7 -0
  57. package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-NUXZQQ6P.mjs} +2 -2
  58. package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-OG2SIKHE.mjs} +3 -5
  59. package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-OQGBKNYU.mjs +90 -0
  61. package/dist/lib/node-esm/chunk-OQGBKNYU.mjs.map +7 -0
  62. package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-PMQ3D535.mjs} +159 -68
  63. package/dist/lib/node-esm/chunk-PMQ3D535.mjs.map +7 -0
  64. package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-U4CZGISN.mjs} +71 -50
  65. package/dist/lib/node-esm/chunk-U4CZGISN.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +114 -0
  67. package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-ZF5ULKED.mjs +81 -0
  69. package/dist/lib/node-esm/chunk-ZF5ULKED.mjs.map +7 -0
  70. package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-PLDAZ5GJ.mjs} +24 -8
  71. package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +7 -0
  72. package/dist/lib/node-esm/index.mjs +96 -39
  73. package/dist/lib/node-esm/index.mjs.map +3 -3
  74. package/dist/lib/node-esm/{intent-resolver-OHKNJFCC.mjs → intent-resolver-6J3CFL5T.mjs} +29 -13
  75. package/dist/lib/node-esm/intent-resolver-6J3CFL5T.mjs.map +7 -0
  76. package/dist/lib/node-esm/meta.json +1 -1
  77. package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-NPKEO7SA.mjs} +36 -13
  78. package/dist/lib/node-esm/react-surface-NPKEO7SA.mjs.map +7 -0
  79. package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-YWGZP4EW.mjs} +8 -8
  80. package/dist/lib/node-esm/settings-YWGZP4EW.mjs.map +7 -0
  81. package/dist/lib/node-esm/templates/index.mjs +1 -1
  82. package/dist/lib/node-esm/types/index.mjs +6 -4
  83. package/dist/types/src/ScriptPlugin.d.ts +1 -1
  84. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  85. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  86. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
  88. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  90. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/compiler.d.ts +1 -1
  92. package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/index.d.ts +6 -6
  94. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  96. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  98. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/settings.d.ts +1 -1
  100. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  101. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
  102. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  103. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +225 -13
  104. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  105. package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
  106. package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
  107. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  108. package/dist/types/src/components/NotebookContainer.d.ts +10 -0
  109. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  110. package/dist/types/src/components/NotebookContainer.stories.d.ts +231 -0
  111. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  112. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +16 -0
  113. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  114. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +231 -0
  115. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  116. package/dist/types/src/components/NotebookStack/index.d.ts +2 -0
  117. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  118. package/dist/types/src/components/ScriptContainer.d.ts +2 -2
  119. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  120. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  121. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +227 -10
  122. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  123. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  124. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
  125. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  126. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  127. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
  128. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  129. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +17 -4
  130. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/index.d.ts +3 -4
  132. package/dist/types/src/components/index.d.ts.map +1 -1
  133. package/dist/types/src/events.d.ts.map +1 -1
  134. package/dist/types/src/hooks/deploy.d.ts +11 -10
  135. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  136. package/dist/types/src/hooks/template.d.ts.map +1 -1
  137. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  138. package/dist/types/src/index.d.ts +1 -0
  139. package/dist/types/src/index.d.ts.map +1 -1
  140. package/dist/types/src/meta.d.ts +0 -1
  141. package/dist/types/src/meta.d.ts.map +1 -1
  142. package/dist/types/src/notebook/index.d.ts +2 -0
  143. package/dist/types/src/notebook/index.d.ts.map +1 -0
  144. package/dist/types/src/notebook/notebook.d.ts +39 -0
  145. package/dist/types/src/notebook/notebook.d.ts.map +1 -0
  146. package/dist/types/src/notebook/notebook.test.d.ts +2 -0
  147. package/dist/types/src/notebook/notebook.test.d.ts.map +1 -0
  148. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  149. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  150. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  151. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  152. package/dist/types/src/templates/chess.d.ts.map +1 -1
  153. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  154. package/dist/types/src/templates/discord.d.ts.map +1 -1
  155. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  156. package/dist/types/src/templates/forex.d.ts.map +1 -1
  157. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  158. package/dist/types/src/testing/data.d.ts +10 -0
  159. package/dist/types/src/testing/data.d.ts.map +1 -0
  160. package/dist/types/src/testing/index.d.ts +2 -0
  161. package/dist/types/src/testing/index.d.ts.map +1 -0
  162. package/dist/types/src/translations.d.ts +21 -2
  163. package/dist/types/src/translations.d.ts.map +1 -1
  164. package/dist/types/src/types/actions.d.ts +58 -0
  165. package/dist/types/src/types/actions.d.ts.map +1 -0
  166. package/dist/types/src/types/index.d.ts +1 -0
  167. package/dist/types/src/types/index.d.ts.map +1 -1
  168. package/dist/types/src/types/schema.d.ts +29 -32
  169. package/dist/types/src/types/schema.d.ts.map +1 -1
  170. package/dist/types/src/util/deploy.d.ts +3 -3
  171. package/dist/types/src/util/deploy.d.ts.map +1 -1
  172. package/dist/types/src/util/functions.d.ts +5 -2
  173. package/dist/types/src/util/functions.d.ts.map +1 -1
  174. package/dist/types/tsconfig.tsbuildinfo +1 -1
  175. package/package.json +76 -75
  176. package/src/ScriptPlugin.tsx +91 -69
  177. package/src/capabilities/app-graph-builder.ts +6 -5
  178. package/src/capabilities/artifact-definition.ts +7 -4
  179. package/src/capabilities/blueprint-definition.ts +30 -0
  180. package/src/capabilities/compiler.ts +2 -1
  181. package/src/capabilities/index.ts +1 -1
  182. package/src/capabilities/intent-resolver.ts +14 -4
  183. package/src/capabilities/react-surface.tsx +20 -7
  184. package/src/capabilities/settings.ts +3 -3
  185. package/src/compiler/compiler.ts +1 -1
  186. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +34 -20
  187. package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
  188. package/src/components/DeploymentDialog/index.ts +1 -1
  189. package/src/components/FrameContainer/FrameContainer.tsx +3 -2
  190. package/src/components/NotebookContainer.stories.tsx +36 -0
  191. package/src/components/NotebookContainer.tsx +82 -0
  192. package/src/components/NotebookStack/NotebookStack.stories.tsx +36 -0
  193. package/src/components/NotebookStack/NotebookStack.tsx +113 -0
  194. package/src/components/NotebookStack/index.ts +5 -0
  195. package/src/components/ScriptContainer.tsx +4 -3
  196. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +33 -17
  197. package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -23
  198. package/src/components/Settings/ScriptObjectSettings.tsx +111 -31
  199. package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
  200. package/src/components/TestPanel/TestContainer.tsx +2 -1
  201. package/src/components/TestPanel/TestPanel.tsx +6 -6
  202. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +84 -30
  203. package/src/components/TypescriptEditor/TypescriptEditor.tsx +32 -25
  204. package/src/components/index.ts +3 -0
  205. package/src/events.ts +2 -2
  206. package/src/hooks/deploy.ts +18 -19
  207. package/src/hooks/format.ts +2 -2
  208. package/src/hooks/template.ts +4 -3
  209. package/src/hooks/useCreateAndDeployScriptTemplates.ts +4 -3
  210. package/src/index.ts +1 -0
  211. package/src/meta.ts +2 -4
  212. package/src/notebook/index.ts +5 -0
  213. package/src/notebook/notebook.test.ts +38 -0
  214. package/src/notebook/notebook.ts +188 -0
  215. package/src/notebook/vfs-parser.test.ts +149 -0
  216. package/src/notebook/vfs-parser.ts +490 -0
  217. package/src/templates/chess.ts +3 -1
  218. package/src/templates/data-generator.ts +9 -3
  219. package/src/templates/discord.ts +12 -4
  220. package/src/templates/forex-effect.ts +7 -3
  221. package/src/templates/forex.ts +3 -1
  222. package/src/templates/gmail.ts +33 -62
  223. package/src/testing/data.ts +37 -0
  224. package/src/testing/index.ts +5 -0
  225. package/src/translations.ts +24 -4
  226. package/src/types/actions.ts +49 -0
  227. package/src/types/index.ts +1 -0
  228. package/src/types/schema.ts +24 -19
  229. package/src/util/deploy.ts +20 -33
  230. package/src/util/functions.ts +35 -6
  231. package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
  232. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
  233. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
  234. package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
  235. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
  236. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
  237. package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
  239. package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
  240. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  241. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  242. package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
  243. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  244. package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
  245. package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
  246. package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
  247. package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
  248. package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
  249. package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
  250. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
  251. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
  252. package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
  253. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
  254. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
  255. package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
  256. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  257. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
  258. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
  259. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  260. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  261. package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
  262. package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
  263. package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
  264. package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
  265. package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
  266. package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
  267. package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
  268. /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-7FNPALCV.mjs.map} +0 -0
  269. /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-OKXN2N7M.mjs.map} +0 -0
  270. /package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs.map → DeploymentDialog-AKAGR37W.mjs.map} +0 -0
  271. /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-NUXZQQ6P.mjs.map} +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
  import { useEffect, useMemo } from 'react';
6
6
 
7
- import { FunctionType, type ScriptType, getUserFunctionUrlInMetadata } from '@dxos/functions';
7
+ import { FunctionType, type ScriptType, getUserFunctionIdInMetadata } from '@dxos/functions';
8
8
  import { log } from '@dxos/log';
9
9
  import { type Client, useClient } from '@dxos/react-client';
10
- import { getMeta, getSpace, Query, Ref, type Space, useQuery } from '@dxos/react-client/echo';
10
+ import { Query, Ref, type Space, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
11
11
  import { type TFunction } from '@dxos/react-ui';
12
12
  import { createMenuAction } from '@dxos/react-ui-menu';
13
13
  import { errorMessageColors } from '@dxos/react-ui-theme';
14
14
 
15
- import { SCRIPT_PLUGIN } from '../meta';
15
+ import { meta } from '../meta';
16
16
  import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
17
17
 
18
18
  export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
@@ -29,15 +29,15 @@ export type CreateDeployOptions = {
29
29
  script: ScriptType;
30
30
  fn: FunctionType;
31
31
  space?: Space;
32
- existingFunctionUrl?: string;
32
+ existingFunctionId?: string;
33
33
  client: Client;
34
34
  t: TFunction;
35
35
  };
36
36
 
37
- export const createDeploy = ({ state, script, space, fn, client, existingFunctionUrl, t }: CreateDeployOptions) => {
37
+ export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
38
38
  // TODO(wittjosiah): Should this be an action?
39
39
  const errorItem = createMenuAction('error', () => {}, {
40
- label: state.error ?? ['no error label', { ns: SCRIPT_PLUGIN }],
40
+ label: state.error ?? ['no error label', { ns: meta.id }],
41
41
  icon: 'ph--warning-circle--regular',
42
42
  hidden: !state.error,
43
43
  classNames: state.error && errorMessageColors,
@@ -53,7 +53,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
53
53
  state.error = undefined;
54
54
  state.deploying = true;
55
55
 
56
- const result = await deployScript({ script, client, space, fn, existingFunctionUrl });
56
+ const result = await deployScript({ script, client, space, fn, existingFunctionId });
57
57
 
58
58
  if (!result.success) {
59
59
  log.catch(result.error);
@@ -64,7 +64,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
64
64
  },
65
65
  {
66
66
  type: 'deploy',
67
- label: [state.deploying ? 'pending label' : 'deploy label', { ns: SCRIPT_PLUGIN }],
67
+ label: [state.deploying ? 'publishing label' : 'deploy label', { ns: meta.id }],
68
68
  icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
69
69
  disabled: state.deploying,
70
70
  classNames: state.deploying ? '[&_svg]:animate-spin' : '',
@@ -74,14 +74,13 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
74
74
  const copyAction = createMenuAction<DeployActionProperties>(
75
75
  'copy',
76
76
  async () => {
77
- if (!state.functionUrl) {
78
- return;
77
+ if (state.functionUrl) {
78
+ await navigator.clipboard.writeText(state.functionUrl);
79
79
  }
80
- await navigator.clipboard.writeText(state.functionUrl);
81
80
  },
82
81
  {
83
82
  type: 'copy',
84
- label: ['copy link label', { ns: SCRIPT_PLUGIN }],
83
+ label: ['copy link label', { ns: meta.id }],
85
84
  icon: 'ph--link--regular',
86
85
  disabled: !state.functionUrl,
87
86
  },
@@ -98,9 +97,9 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
98
97
  };
99
98
 
100
99
  export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script: ScriptType }) => {
101
- const { space, client, fn, existingFunctionUrl } = useDeployDeps({ script });
100
+ const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
102
101
  useEffect(() => {
103
- if (!existingFunctionUrl) {
102
+ if (!existingFunctionId) {
104
103
  return;
105
104
  }
106
105
 
@@ -109,17 +108,17 @@ export const useDeployState = ({ state, script }: { state: Partial<DeployState>;
109
108
  fn,
110
109
  edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
111
110
  });
112
- }, [existingFunctionUrl, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
111
+ }, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
113
112
 
114
113
  useEffect(() => {
115
114
  state.deployed = isScriptDeployed({ script, fn });
116
- }, [script.changed, existingFunctionUrl, fn, script]);
115
+ }, [script.changed, existingFunctionId, fn, script]);
117
116
  };
118
117
 
119
118
  export const useDeployDeps = ({ script }: { script: ScriptType }) => {
119
+ const client = useClient();
120
120
  const space = getSpace(script);
121
121
  const [fn] = useQuery(space, Query.type(FunctionType, { source: Ref.make(script) }));
122
- const client = useClient();
123
- const existingFunctionUrl = useMemo(() => fn && getUserFunctionUrlInMetadata(getMeta(fn)), [fn]);
124
- return { space, fn, client, existingFunctionUrl };
122
+ const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(getMeta(fn)), [fn]);
123
+ return { client, space, fn, existingFunctionId };
125
124
  };
@@ -10,7 +10,7 @@ import { type ScriptType } from '@dxos/functions';
10
10
  import { log } from '@dxos/log';
11
11
  import { createMenuAction } from '@dxos/react-ui-menu';
12
12
 
13
- import { SCRIPT_PLUGIN } from '../meta';
13
+ import { meta } from '../meta';
14
14
 
15
15
  export type FormatActionProperties = { type: 'format' };
16
16
 
@@ -35,7 +35,7 @@ export const createFormat = (script: ScriptType) => {
35
35
  }
36
36
  },
37
37
  {
38
- label: ['format label', { ns: SCRIPT_PLUGIN }],
38
+ label: ['format label', { ns: meta.id }],
39
39
  icon: 'ph--magic-wand--regular',
40
40
  },
41
41
  );
@@ -4,16 +4,17 @@
4
4
 
5
5
  import { Obj } from '@dxos/echo';
6
6
  import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
7
- import { createMenuItemGroup, createMenuAction } from '@dxos/react-ui-menu';
7
+ import { createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
8
8
 
9
- import { SCRIPT_PLUGIN } from '../meta';
9
+ import { meta } from '../meta';
10
10
  import { templates } from '../templates';
11
11
 
12
12
  export type TemplateActionProperties = { type: 'template'; value: string };
13
13
 
14
14
  const createTemplateSelectGroup = () => {
15
+ // TODO(burdon): This should not be in the toolbar (move to create Object dialog).
15
16
  return createMenuItemGroup('template-select', {
16
- label: ['template select group label', { ns: SCRIPT_PLUGIN }],
17
+ label: ['template select group label', { ns: meta.id }],
17
18
  variant: 'dropdownMenu',
18
19
  });
19
20
  };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { pipe } from 'effect/Function';
5
+ import * as Function from 'effect/Function';
6
6
  import { useCallback, useState } from 'react';
7
7
 
8
8
  import { chain, createIntent, useIntentDispatcher } from '@dxos/app-framework';
@@ -40,8 +40,8 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
40
40
  const deploymentResults = await Promise.all(
41
41
  scriptTemplates.map(async (template) => {
42
42
  const result = await dispatch(
43
- pipe(
44
- createIntent(ScriptAction.Create, { space, initialTemplateId: template.id }),
43
+ Function.pipe(
44
+ createIntent(ScriptAction.CreateScript, { space, initialTemplateId: template.id }),
45
45
  chain(SpaceAction.AddObject, { target: space }),
46
46
  ),
47
47
  );
@@ -55,5 +55,6 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
55
55
  setStatus(hasErrors ? 'error' : 'success');
56
56
  }, [space, dispatch, client, scriptTemplates]);
57
57
 
58
+ // TODO(burdon): Return onCreateAndDeployScripts.
58
59
  return { handleCreateAndDeployScripts, status, error };
59
60
  };
package/src/index.ts CHANGED
@@ -5,5 +5,6 @@
5
5
  export { ScriptCapabilities } from './capabilities';
6
6
  export * from './components';
7
7
  export * from './meta';
8
+ export * from './util';
8
9
 
9
10
  export * from './ScriptPlugin';
package/src/meta.ts CHANGED
@@ -4,13 +4,11 @@
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
- export const SCRIPT_PLUGIN = 'dxos.org/plugin/script';
8
-
9
7
  export const meta: PluginMeta = {
10
- id: SCRIPT_PLUGIN,
8
+ id: 'dxos.org/plugin/script',
11
9
  name: 'Scripts',
12
10
  description:
13
- 'Scripts in Composer allow you to deploy custom functions that run on the edge. These functions can be referenced by your AI agent and called inside of cells in any Sheet. Use scripts to interact with API’s or external data inside of Composer.',
11
+ 'Scripts enable you to deploy custom functions that run on the edge. These functions can be referenced by your AI agent and called inside of cells in any Sheet. Use scripts to interact with API’s or external data inside of Composer.',
14
12
  icon: 'ph--code--regular',
15
13
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',
16
14
  tags: ['labs'],
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './notebook';
@@ -0,0 +1,38 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, expect, test } from 'vitest';
6
+
7
+ import { createNotebook } from '../testing';
8
+
9
+ import { ComputeGraph } from './notebook';
10
+
11
+ // TODO(burdon): Create test where one cell could be a AI prompt that references other cells.
12
+ // TODO(burdon): UI cells: Value, Query, TS Expression, Prompt (show input and output).
13
+
14
+ describe('notebook', () => {
15
+ test('parse dependency graph', () => {
16
+ const notebook = createNotebook();
17
+ const computer = new ComputeGraph(notebook);
18
+ const result = computer.parse();
19
+
20
+ const getId = (i: number) => notebook.cells[i].id;
21
+
22
+ // Check dependencies.
23
+ expect(result.dependencyGraph).toMatchObject({
24
+ [getId(0)]: [getId(1), getId(2)],
25
+ [getId(3)]: [getId(1)],
26
+ [getId(4)]: [getId(0), getId(3)],
27
+ });
28
+
29
+ // Compute values.
30
+ const values = computer.evaluate();
31
+ expect(values).toEqual({
32
+ [getId(0)]: 300,
33
+ [getId(2)]: 200,
34
+ [getId(3)]: 200,
35
+ [getId(4)]: 500,
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,188 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Signal, signal } from '@preact/signals-core';
6
+
7
+ import { log } from '@dxos/log';
8
+
9
+ import { type Notebook } from '../types';
10
+
11
+ import { type ParsedExpression, VirtualTypeScriptParser } from './vfs-parser';
12
+
13
+ /**
14
+ * Compute graph that evaluates the notebook cells.
15
+ */
16
+ export class ComputeGraph {
17
+ private readonly _parser = new VirtualTypeScriptParser();
18
+
19
+ private _expressions = signal<Record<string, ParsedExpression>>({});
20
+ private _values = signal<Record<string, any>>({});
21
+
22
+ constructor(private readonly _notebook: Notebook.Notebook) {}
23
+
24
+ /**
25
+ * Parsed expressions by cell ID.
26
+ */
27
+ get expressions(): Signal<Record<string, ParsedExpression>> {
28
+ return this._expressions;
29
+ }
30
+
31
+ /**
32
+ * Computed values by cell ID.
33
+ */
34
+ get values(): Signal<Record<string, any>> {
35
+ return this._values;
36
+ }
37
+
38
+ /**
39
+ * Compute values.
40
+ */
41
+ evaluate() {
42
+ // Parse expressions.
43
+ const { expressions, dependencyGraph } = this.parse();
44
+ this._values.value = {};
45
+
46
+ // Create a map of cell IDs to expressions for easy lookup.
47
+ const cellExpressions = new Map<string, ParsedExpression>();
48
+ Object.entries(expressions).forEach(([id, expr]) => {
49
+ cellExpressions.set(id, expr);
50
+ });
51
+
52
+ // Topological sort to determine evaluation order.
53
+ const evaluationOrder = this.topologicalSort(Object.keys(expressions), dependencyGraph);
54
+
55
+ // Values by reference name.
56
+ const valuesByName: Record<string, any> = {};
57
+ const valuesByCellId: Record<string, any> = {};
58
+
59
+ // Evaluate cells in dependency order.
60
+ for (const cellId of evaluationOrder) {
61
+ const expr = cellExpressions.get(cellId);
62
+ if (!expr) {
63
+ log.error('no expression for cell', { cellId });
64
+ continue;
65
+ }
66
+
67
+ const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.script.target?.content;
68
+ if (!cellSource) {
69
+ log.error('no source for cell', { cellId });
70
+ continue;
71
+ }
72
+
73
+ try {
74
+ // For assignments or declarations, evaluate and store the value.
75
+ if (expr.name && expr.value !== undefined) {
76
+ // If the parser extracted a literal value, use it directly.
77
+ valuesByName[expr.name] = expr.value;
78
+ valuesByCellId[cellId] = expr.value;
79
+ } else if (expr.name) {
80
+ // For non-literal assignments, we need to evaluate the expression.
81
+ // The parser identifies it's an assignment, so we can extract the RHS.
82
+ const equalIndex = cellSource.indexOf('=');
83
+ if (equalIndex !== -1) {
84
+ // Find the actual assignment operator (not in strings or other contexts).
85
+ let rhs = cellSource.substring(equalIndex + 1).trim();
86
+
87
+ // Handle semicolon at the end.
88
+ if (rhs.endsWith(';')) {
89
+ rhs = rhs.slice(0, -1).trim();
90
+ }
91
+
92
+ const result = this.evalScript(rhs, valuesByName);
93
+ valuesByName[expr.name] = result;
94
+ if (typeof result !== 'function') {
95
+ valuesByCellId[cellId] = result;
96
+ }
97
+ }
98
+ } else {
99
+ // For expressions without assignment, just evaluate.
100
+ const result = this.evalScript(cellSource, valuesByName);
101
+ valuesByCellId[cellId] = result;
102
+ }
103
+ } catch (error) {
104
+ log.error('error evaluating cell', { cellId, error });
105
+ }
106
+ }
107
+
108
+ this._values.value = valuesByCellId;
109
+ return valuesByCellId;
110
+ }
111
+
112
+ /**
113
+ * Parse expressions.
114
+ */
115
+ parse() {
116
+ const expressions = this._notebook.cells.reduce<Record<string, ParsedExpression>>((acc, cell) => {
117
+ const text = cell.script.target?.content.trim();
118
+ if (text) {
119
+ const parsed = this._parser.parseExpression(text);
120
+ acc[cell.id] = parsed;
121
+ }
122
+
123
+ return acc;
124
+ }, {});
125
+
126
+ // Build dependency graph.
127
+ const dependencyGraph = this.buildDependencyGraph(expressions);
128
+ this._expressions.value = expressions;
129
+ return { expressions, dependencyGraph };
130
+ }
131
+
132
+ private topologicalSort(nodes: string[], dependencies: Record<string, string[]>): string[] {
133
+ const visited = new Set<string>();
134
+ const result: string[] = [];
135
+
136
+ const visit = (node: string) => {
137
+ if (visited.has(node)) {
138
+ return;
139
+ }
140
+
141
+ visited.add(node);
142
+
143
+ // Visit dependencies first.
144
+ const deps = dependencies[node] || [];
145
+ deps.forEach((dep) => visit(dep));
146
+ result.push(node);
147
+ };
148
+
149
+ // Visit all nodes.
150
+ nodes.forEach((node) => visit(node));
151
+ return result;
152
+ }
153
+
154
+ private buildDependencyGraph(expressions: Record<string, ParsedExpression>): Record<string, string[]> {
155
+ // Create a map of variable names to their cell IDs.
156
+ const nameToCellId = new Map<string, string>();
157
+ Object.entries(expressions).forEach(([id, expr]) => {
158
+ if (expr.name) {
159
+ nameToCellId.set(expr.name, id);
160
+ }
161
+ });
162
+
163
+ // Build the dependency graph using cell IDs.
164
+ const graph: Record<string, string[]> = {};
165
+ Object.entries(expressions).forEach(([id, expr]) => {
166
+ if (expr.references && expr.references.length > 0) {
167
+ // Map variable references to cell IDs.
168
+ const dependencyCellIds = expr.references
169
+ .map((ref) => nameToCellId.get(ref))
170
+ .filter((cellId): cellId is string => cellId !== undefined && cellId !== id);
171
+
172
+ if (dependencyCellIds.length > 0) {
173
+ graph[id] = dependencyCellIds;
174
+ }
175
+ }
176
+ });
177
+
178
+ return graph;
179
+ }
180
+
181
+ /**
182
+ * Evaluate the script (with dependencies as arguments).
183
+ */
184
+ private evalScript(code: string, deps: Record<string, any> = {}) {
185
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
186
+ return new Function(...Object.keys(deps), 'return ' + code)(...Object.values(deps));
187
+ }
188
+ }
@@ -0,0 +1,149 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, expect, test } from 'vitest';
6
+
7
+ import { NotebookVirtualParser, VirtualTypeScriptParser } from './vfs-parser';
8
+
9
+ describe('vfs-parser', () => {
10
+ test('parse simple assignments', () => {
11
+ const parser = new VirtualTypeScriptParser();
12
+
13
+ const tests = [
14
+ {
15
+ input: 'const a = 1',
16
+ expected: {
17
+ name: 'a',
18
+ type: 'variable',
19
+ },
20
+ },
21
+ {
22
+ input: 'a = 1',
23
+ expected: {
24
+ name: 'a',
25
+ type: 'variable',
26
+ },
27
+ },
28
+ ];
29
+
30
+ tests.forEach(({ input, expected }) => {
31
+ const result = parser.parseExpression(input);
32
+ expect(result, input).toMatchObject(expected);
33
+ });
34
+ });
35
+
36
+ test('parse variable with references', () => {
37
+ const parser = new VirtualTypeScriptParser();
38
+
39
+ const tests = [
40
+ {
41
+ input: 'const y = x * 2',
42
+ expected: {
43
+ name: 'y',
44
+ type: 'variable',
45
+ references: ['x'],
46
+ },
47
+ },
48
+ {
49
+ input: 'y = x * 2',
50
+ expected: {
51
+ name: 'y',
52
+ type: 'variable',
53
+ references: ['x'],
54
+ },
55
+ },
56
+ ];
57
+
58
+ tests.forEach(({ input, expected }) => {
59
+ const result = parser.parseExpression(input);
60
+ expect(result, input).toMatchObject(expected);
61
+ });
62
+ });
63
+
64
+ test('parse simple expression with references', () => {
65
+ const parser = new VirtualTypeScriptParser();
66
+
67
+ const result = parser.parseExpression('(a + b) * c');
68
+ expect(result).toMatchObject({
69
+ references: ['a', 'b', 'c'],
70
+ });
71
+ });
72
+
73
+ test('parse single expression', () => {
74
+ const parser = new VirtualTypeScriptParser();
75
+
76
+ const result = parser.parseExpression('const add = (a: number, b: number): number => a + b;');
77
+ expect(result).toMatchObject({
78
+ name: 'add',
79
+ type: 'function',
80
+ valueType: expect.stringContaining('(a: number, b: number) => number'),
81
+ returnType: 'number',
82
+ parameters: [
83
+ { name: 'a', type: 'number' },
84
+ { name: 'b', type: 'number' },
85
+ ],
86
+ });
87
+ });
88
+
89
+ test('analyze multiple files', () => {
90
+ const parser = new VirtualTypeScriptParser();
91
+
92
+ const files = [
93
+ {
94
+ filename: '/test.ts',
95
+ content: 'export const PI = 3.14159;\nexport function square(x: number): number { return x * x; }',
96
+ },
97
+ ];
98
+
99
+ const results = parser.analyzeFiles(files);
100
+ expect(results).toHaveLength(2);
101
+ expect(results[0]).toMatchObject({
102
+ name: 'PI',
103
+ type: 'variable',
104
+ valueType: '3.14159',
105
+ });
106
+ expect(results[1]).toMatchObject({
107
+ name: 'square',
108
+ type: 'function',
109
+ returnType: 'number',
110
+ parameters: [{ name: 'x', type: 'number' }],
111
+ });
112
+ });
113
+
114
+ test('notebook cell analysis', () => {
115
+ const parser = new NotebookVirtualParser();
116
+
117
+ const cells = [
118
+ { id: 'cell1', code: 'const x: number = 10;' },
119
+ { id: 'cell2', code: 'const y = x * 2;' },
120
+ { id: 'cell3', code: 'console.log(y);' },
121
+ ];
122
+
123
+ const analysis = parser.analyzeNotebook(cells);
124
+
125
+ // Cell 1 exports x.
126
+ const cell1 = analysis.get('cell1');
127
+ expect(cell1?.exports).toHaveLength(1);
128
+ expect(cell1?.exports[0]).toMatchObject({
129
+ name: 'x',
130
+ type: 'variable',
131
+ valueType: 'number',
132
+ });
133
+ expect(cell1?.imports).toHaveLength(0);
134
+
135
+ // Cell 2 imports x and exports y.
136
+ const cell2 = analysis.get('cell2');
137
+ expect(cell2?.exports).toHaveLength(1);
138
+ expect(cell2?.exports[0]).toMatchObject({
139
+ name: 'y',
140
+ type: 'variable',
141
+ });
142
+ expect(cell2?.imports).toContain('x');
143
+
144
+ // Cell 3 imports y.
145
+ const cell3 = analysis.get('cell3');
146
+ expect(cell3?.exports).toHaveLength(0);
147
+ expect(cell3?.imports).toContain('y');
148
+ });
149
+ });