@dxos/plugin-script 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (426) hide show
  1. package/dist/lib/browser/DeploymentDialog-GXNRUXF6.mjs +14 -0
  2. package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs +845 -0
  3. package/dist/lib/browser/NotebookContainer-4MM2VAQF.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs +149 -0
  5. package/dist/lib/browser/ScriptContainer-X6GCYZZW.mjs.map +7 -0
  6. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs +68 -0
  7. package/dist/lib/browser/app-graph-builder-7VO7AUI6.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs +17 -0
  9. package/dist/lib/browser/blueprint-definition-OSOUYI7A.mjs.map +7 -0
  10. package/dist/lib/browser/blueprints/index.mjs +8 -0
  11. package/dist/lib/browser/chunk-3O2DQGCP.mjs +113 -0
  12. package/dist/lib/browser/chunk-3O2DQGCP.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-BTWHM6FH.mjs +270 -0
  14. package/dist/lib/browser/chunk-BTWHM6FH.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
  16. package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
  18. package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-IQRLM6JK.mjs +137 -0
  20. package/dist/lib/browser/chunk-IQRLM6JK.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  22. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-NWSK27QB.mjs +606 -0
  24. package/dist/lib/browser/chunk-NWSK27QB.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-UX4GHJ5E.mjs +105 -0
  26. package/dist/lib/browser/chunk-UX4GHJ5E.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-WX2NVNFQ.mjs +557 -0
  28. package/dist/lib/browser/chunk-WX2NVNFQ.mjs.map +7 -0
  29. package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-WYR4QHPE.mjs} +8 -5
  30. package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
  31. package/dist/lib/browser/compiler-XRBFQFXO.mjs +161 -0
  32. package/dist/lib/browser/compiler-XRBFQFXO.mjs.map +7 -0
  33. package/dist/lib/browser/index.mjs +137 -103
  34. package/dist/lib/browser/index.mjs.map +4 -4
  35. package/dist/lib/browser/meta.json +1 -1
  36. package/dist/lib/browser/operation-resolver-MUNR376F.mjs +82 -0
  37. package/dist/lib/browser/operation-resolver-MUNR376F.mjs.map +7 -0
  38. package/dist/lib/browser/react-surface-5TEC66UY.mjs +139 -0
  39. package/dist/lib/browser/react-surface-5TEC66UY.mjs.map +7 -0
  40. package/dist/lib/browser/settings-R4WKREUJ.mjs +35 -0
  41. package/dist/lib/browser/settings-R4WKREUJ.mjs.map +7 -0
  42. package/dist/lib/browser/templates/index.mjs +2 -1
  43. package/dist/lib/browser/types/index.mjs +14 -6
  44. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs +15 -0
  45. package/dist/lib/node-esm/DeploymentDialog-EVFV2VJT.mjs.map +7 -0
  46. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs +846 -0
  47. package/dist/lib/node-esm/NotebookContainer-QLW5ZYGS.mjs.map +7 -0
  48. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs +150 -0
  49. package/dist/lib/node-esm/ScriptContainer-3DZ3BMHW.mjs.map +7 -0
  50. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs +69 -0
  51. package/dist/lib/node-esm/app-graph-builder-NVE3EVBG.mjs.map +7 -0
  52. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs +18 -0
  53. package/dist/lib/node-esm/blueprint-definition-NC7NNJGI.mjs.map +7 -0
  54. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  55. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  56. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs +107 -0
  57. package/dist/lib/node-esm/chunk-4F5FJZ36.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-5HSJPAK7.mjs} +8 -5
  59. package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  61. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs +114 -0
  63. package/dist/lib/node-esm/chunk-KN6SQYUF.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-MGWKULCD.mjs +558 -0
  65. package/dist/lib/node-esm/chunk-MGWKULCD.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
  67. package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs +271 -0
  69. package/dist/lib/node-esm/chunk-VWOLKNMO.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
  71. package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs +138 -0
  73. package/dist/lib/node-esm/chunk-YEWLTVBT.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs +607 -0
  75. package/dist/lib/node-esm/chunk-ZQGHFNO3.mjs.map +7 -0
  76. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs +162 -0
  77. package/dist/lib/node-esm/compiler-ORJAXDN7.mjs.map +7 -0
  78. package/dist/lib/node-esm/index.mjs +137 -103
  79. package/dist/lib/node-esm/index.mjs.map +4 -4
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs +83 -0
  82. package/dist/lib/node-esm/operation-resolver-CLE4ZCC5.mjs.map +7 -0
  83. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs +140 -0
  84. package/dist/lib/node-esm/react-surface-O3UDMKOQ.mjs.map +7 -0
  85. package/dist/lib/node-esm/settings-OFIMHU7K.mjs +36 -0
  86. package/dist/lib/node-esm/settings-OFIMHU7K.mjs.map +7 -0
  87. package/dist/lib/node-esm/templates/index.mjs +2 -1
  88. package/dist/lib/node-esm/types/index.mjs +14 -6
  89. package/dist/types/src/ScriptPlugin.d.ts +2 -1
  90. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  91. package/dist/types/src/blueprints/index.d.ts +2 -0
  92. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  93. package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
  94. package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  96. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  100. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  104. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
  108. package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
  110. package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/index.d.ts +6 -7
  112. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  113. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  116. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  118. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  120. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/settings/index.d.ts +7 -0
  122. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/settings/settings.d.ts +9 -0
  124. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  125. package/dist/types/src/compiler/compiler.d.ts +1 -1
  126. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  127. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +3 -3
  128. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  129. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +114 -10
  130. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  131. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
  132. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  133. package/dist/types/src/components/NotebookContainer.d.ts +8 -0
  134. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  135. package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
  136. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  137. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
  138. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
  139. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
  140. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
  141. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
  142. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  143. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
  144. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  145. package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
  146. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  147. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
  148. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
  149. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
  150. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
  151. package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
  152. package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
  153. package/dist/types/src/components/ScriptContainer.d.ts +7 -8
  154. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  155. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
  156. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  157. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +241 -2
  158. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  159. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  160. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  161. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
  162. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  163. package/dist/types/src/components/TestPanel/TestContainer.d.ts +3 -3
  164. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  165. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  166. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
  167. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  168. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -3
  169. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  170. package/dist/types/src/components/index.d.ts +3 -1
  171. package/dist/types/src/components/index.d.ts.map +1 -1
  172. package/dist/types/src/e2e/ai.test.d.ts +2 -0
  173. package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
  174. package/dist/types/src/e2e/deploy.test.d.ts +2 -0
  175. package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
  176. package/dist/types/src/hooks/deploy.d.ts +16 -31
  177. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  178. package/dist/types/src/hooks/format.d.ts +4 -4
  179. package/dist/types/src/hooks/format.d.ts.map +1 -1
  180. package/dist/types/src/hooks/index.d.ts +1 -0
  181. package/dist/types/src/hooks/index.d.ts.map +1 -1
  182. package/dist/types/src/hooks/template.d.ts +6 -16
  183. package/dist/types/src/hooks/template.d.ts.map +1 -1
  184. package/dist/types/src/hooks/useCompiler.d.ts +7 -0
  185. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
  186. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  187. package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
  188. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  189. package/dist/types/src/index.d.ts +2 -1
  190. package/dist/types/src/index.d.ts.map +1 -1
  191. package/dist/types/src/meta.d.ts +2 -3
  192. package/dist/types/src/meta.d.ts.map +1 -1
  193. package/dist/types/src/notebook/compute-graph.d.ts +58 -0
  194. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  195. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  196. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  197. package/dist/types/src/notebook/eval.d.ts +13 -0
  198. package/dist/types/src/notebook/eval.d.ts.map +1 -0
  199. package/dist/types/src/notebook/index.d.ts +2 -0
  200. package/dist/types/src/notebook/index.d.ts.map +1 -0
  201. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  202. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  203. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  204. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  205. package/dist/types/src/templates/anthropic.d.ts +8 -0
  206. package/dist/types/src/templates/anthropic.d.ts.map +1 -0
  207. package/dist/types/src/templates/chess-bot.d.ts +16 -0
  208. package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
  209. package/dist/types/src/templates/commentary.d.ts +16 -0
  210. package/dist/types/src/templates/commentary.d.ts.map +1 -0
  211. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  212. package/dist/types/src/templates/discord.d.ts.map +1 -1
  213. package/dist/types/src/templates/forex-effect.d.ts +4 -1
  214. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  215. package/dist/types/src/templates/forex.d.ts +4 -1
  216. package/dist/types/src/templates/forex.d.ts.map +1 -1
  217. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  218. package/dist/types/src/templates/index.d.ts +52 -1
  219. package/dist/types/src/templates/index.d.ts.map +1 -1
  220. package/dist/types/src/templates/ping.d.ts +3 -0
  221. package/dist/types/src/templates/ping.d.ts.map +1 -0
  222. package/dist/types/src/testing/data.d.ts +3 -0
  223. package/dist/types/src/testing/data.d.ts.map +1 -0
  224. package/dist/types/src/testing/index.d.ts +2 -0
  225. package/dist/types/src/testing/index.d.ts.map +1 -0
  226. package/dist/types/src/testing/simulator.test.d.ts +2 -0
  227. package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
  228. package/dist/types/src/translations.d.ts +31 -5
  229. package/dist/types/src/translations.d.ts.map +1 -1
  230. package/dist/types/src/types/Notebook.d.ts +100 -0
  231. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  232. package/dist/types/src/types/actions.d.ts +40 -0
  233. package/dist/types/src/types/actions.d.ts.map +1 -0
  234. package/dist/types/src/types/capabilities.d.ts +12 -0
  235. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  236. package/dist/types/src/types/events.d.ts +5 -0
  237. package/dist/types/src/types/events.d.ts.map +1 -0
  238. package/dist/types/src/types/index.d.ts +5 -1
  239. package/dist/types/src/types/index.d.ts.map +1 -1
  240. package/dist/types/src/types/types.d.ts +6 -0
  241. package/dist/types/src/types/types.d.ts.map +1 -0
  242. package/dist/types/src/util/deploy.d.ts +4 -4
  243. package/dist/types/src/util/deploy.d.ts.map +1 -1
  244. package/dist/types/src/util/functions.d.ts +6 -3
  245. package/dist/types/src/util/functions.d.ts.map +1 -1
  246. package/dist/types/tsconfig.tsbuildinfo +1 -1
  247. package/package.json +117 -82
  248. package/src/ScriptPlugin.tsx +55 -75
  249. package/src/blueprints/index.ts +5 -0
  250. package/src/blueprints/script-blueprint.ts +24 -0
  251. package/src/capabilities/app-graph-builder/app-graph-builder.ts +55 -0
  252. package/src/capabilities/app-graph-builder/index.ts +7 -0
  253. package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +98 -96
  254. package/src/capabilities/artifact-definition/index.ts +7 -0
  255. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  256. package/src/capabilities/blueprint-definition/index.ts +7 -0
  257. package/src/capabilities/compiler/compiler.ts +103 -0
  258. package/src/capabilities/compiler/index.ts +7 -0
  259. package/src/capabilities/index.ts +6 -10
  260. package/src/capabilities/operation-resolver/index.ts +7 -0
  261. package/src/capabilities/operation-resolver/operation-resolver.ts +74 -0
  262. package/src/capabilities/react-surface/index.ts +7 -0
  263. package/src/capabilities/react-surface/react-surface.tsx +118 -0
  264. package/src/capabilities/settings/index.ts +7 -0
  265. package/src/capabilities/settings/settings.ts +32 -0
  266. package/src/compiler/compiler.ts +10 -3
  267. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +37 -26
  268. package/src/components/DeploymentDialog/DeploymentDialog.tsx +41 -50
  269. package/src/components/FrameContainer/FrameContainer.tsx +6 -4
  270. package/src/components/NotebookContainer.stories.tsx +87 -0
  271. package/src/components/NotebookContainer.tsx +270 -0
  272. package/src/components/NotebookStack/NotebookCell.tsx +217 -0
  273. package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
  274. package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
  275. package/src/components/NotebookStack/NotebookStack.tsx +86 -0
  276. package/src/components/NotebookStack/index.ts +6 -0
  277. package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
  278. package/src/components/QueryEditor/QueryEditor.tsx +47 -0
  279. package/src/components/QueryEditor/index.ts +5 -0
  280. package/src/components/ScriptContainer.tsx +50 -35
  281. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +54 -19
  282. package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -36
  283. package/src/components/Settings/ScriptObjectSettings.tsx +136 -29
  284. package/src/components/Settings/ScriptPluginSettings.tsx +11 -21
  285. package/src/components/TestPanel/TestContainer.tsx +7 -7
  286. package/src/components/TestPanel/TestPanel.tsx +42 -19
  287. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +77 -17
  288. package/src/components/TypescriptEditor/TypescriptEditor.tsx +81 -80
  289. package/src/components/index.ts +3 -0
  290. package/src/e2e/ai.test.ts +92 -0
  291. package/src/e2e/deploy.test.ts +64 -0
  292. package/src/hooks/deploy.ts +44 -37
  293. package/src/hooks/format.ts +9 -5
  294. package/src/hooks/index.ts +1 -0
  295. package/src/hooks/template.ts +20 -23
  296. package/src/hooks/useCompiler.ts +24 -0
  297. package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
  298. package/src/hooks/useToolbarState.ts +29 -5
  299. package/src/index.ts +2 -1
  300. package/src/meta.ts +9 -7
  301. package/src/notebook/compute-graph.test.ts +82 -0
  302. package/src/notebook/compute-graph.ts +230 -0
  303. package/src/notebook/eval.ts +105 -0
  304. package/src/notebook/index.ts +5 -0
  305. package/src/notebook/vfs-parser.test.ts +149 -0
  306. package/src/notebook/vfs-parser.ts +451 -0
  307. package/src/templates/anthropic.ts +42 -0
  308. package/src/templates/chess-bot.ts +58 -0
  309. package/src/templates/commentary.ts +232 -0
  310. package/src/templates/data-generator.ts +3 -1
  311. package/src/templates/discord.ts +9 -1
  312. package/src/templates/forex-effect.ts +24 -25
  313. package/src/templates/forex.ts +9 -6
  314. package/src/templates/gmail.ts +22 -11
  315. package/src/templates/index.ts +24 -11
  316. package/src/templates/ping.ts +17 -0
  317. package/src/testing/data.ts +72 -0
  318. package/src/testing/index.ts +5 -0
  319. package/src/testing/simulator.test.ts +40 -0
  320. package/src/translations.ts +34 -7
  321. package/src/types/Notebook.ts +41 -0
  322. package/src/types/actions.ts +45 -0
  323. package/src/types/capabilities.ts +17 -0
  324. package/src/types/events.ts +11 -0
  325. package/src/types/index.ts +5 -1
  326. package/src/types/types.ts +15 -0
  327. package/src/util/deploy.ts +30 -40
  328. package/src/util/functions.ts +56 -23
  329. package/src/vite-env.d.ts +2 -0
  330. package/dist/lib/browser/DeploymentDialog-QZSTVNIS.mjs +0 -12
  331. package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs +0 -265
  332. package/dist/lib/browser/ScriptContainer-IA7YJMFR.mjs.map +0 -7
  333. package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs +0 -64
  334. package/dist/lib/browser/app-graph-builder-5NIA7SLT.mjs.map +0 -7
  335. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
  336. package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
  337. package/dist/lib/browser/chunk-4AUQEB2I.mjs +0 -88
  338. package/dist/lib/browser/chunk-4AUQEB2I.mjs.map +0 -7
  339. package/dist/lib/browser/chunk-5TVBECWH.mjs +0 -15
  340. package/dist/lib/browser/chunk-5TVBECWH.mjs.map +0 -7
  341. package/dist/lib/browser/chunk-B5QYN3AG.mjs +0 -556
  342. package/dist/lib/browser/chunk-B5QYN3AG.mjs.map +0 -7
  343. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  344. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  345. package/dist/lib/browser/chunk-KLGK77UK.mjs +0 -283
  346. package/dist/lib/browser/chunk-KLGK77UK.mjs.map +0 -7
  347. package/dist/lib/browser/chunk-NXKU3BNX.mjs +0 -222
  348. package/dist/lib/browser/chunk-NXKU3BNX.mjs.map +0 -7
  349. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  350. package/dist/lib/browser/chunk-YCZPTTFO.mjs +0 -153
  351. package/dist/lib/browser/chunk-YCZPTTFO.mjs.map +0 -7
  352. package/dist/lib/browser/compiler-O7MNN3XT.mjs +0 -98
  353. package/dist/lib/browser/compiler-O7MNN3XT.mjs.map +0 -7
  354. package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs +0 -89
  355. package/dist/lib/browser/intent-resolver-GGGTXYMB.mjs.map +0 -7
  356. package/dist/lib/browser/react-surface-C4ZTW4QA.mjs +0 -104
  357. package/dist/lib/browser/react-surface-C4ZTW4QA.mjs.map +0 -7
  358. package/dist/lib/browser/settings-A4E4R7VL.mjs +0 -24
  359. package/dist/lib/browser/settings-A4E4R7VL.mjs.map +0 -7
  360. package/dist/lib/node-esm/DeploymentDialog-G6EHEPXN.mjs +0 -13
  361. package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs +0 -266
  362. package/dist/lib/node-esm/ScriptContainer-6AVJSLU4.mjs.map +0 -7
  363. package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs +0 -65
  364. package/dist/lib/node-esm/app-graph-builder-V7QF54LT.mjs.map +0 -7
  365. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
  366. package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
  367. package/dist/lib/node-esm/chunk-35M3CHYE.mjs +0 -16
  368. package/dist/lib/node-esm/chunk-35M3CHYE.mjs.map +0 -7
  369. package/dist/lib/node-esm/chunk-5OGRMRLA.mjs +0 -90
  370. package/dist/lib/node-esm/chunk-5OGRMRLA.mjs.map +0 -7
  371. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  372. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  373. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  374. package/dist/lib/node-esm/chunk-M642JUOZ.mjs +0 -223
  375. package/dist/lib/node-esm/chunk-M642JUOZ.mjs.map +0 -7
  376. package/dist/lib/node-esm/chunk-MPN2DI4P.mjs +0 -557
  377. package/dist/lib/node-esm/chunk-MPN2DI4P.mjs.map +0 -7
  378. package/dist/lib/node-esm/chunk-WXKOIREL.mjs +0 -284
  379. package/dist/lib/node-esm/chunk-WXKOIREL.mjs.map +0 -7
  380. package/dist/lib/node-esm/chunk-ZA36GO4T.mjs +0 -154
  381. package/dist/lib/node-esm/chunk-ZA36GO4T.mjs.map +0 -7
  382. package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs +0 -99
  383. package/dist/lib/node-esm/compiler-TZUZ7I6H.mjs.map +0 -7
  384. package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs +0 -90
  385. package/dist/lib/node-esm/intent-resolver-DUJWXCRR.mjs.map +0 -7
  386. package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs +0 -105
  387. package/dist/lib/node-esm/react-surface-5CM3KXFE.mjs.map +0 -7
  388. package/dist/lib/node-esm/settings-FZ25DUX4.mjs +0 -25
  389. package/dist/lib/node-esm/settings-FZ25DUX4.mjs.map +0 -7
  390. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  391. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  392. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  393. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  394. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  395. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  396. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  397. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  398. package/dist/types/src/capabilities/compiler.d.ts +0 -4
  399. package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
  400. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  401. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  402. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  403. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  404. package/dist/types/src/capabilities/settings.d.ts +0 -4
  405. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  406. package/dist/types/src/events.d.ts +0 -4
  407. package/dist/types/src/events.d.ts.map +0 -1
  408. package/dist/types/src/templates/chess.d.ts +0 -3
  409. package/dist/types/src/templates/chess.d.ts.map +0 -1
  410. package/dist/types/src/templates/echo.d.ts +0 -6
  411. package/dist/types/src/templates/echo.d.ts.map +0 -1
  412. package/dist/types/src/types/schema.d.ts +0 -38
  413. package/dist/types/src/types/schema.d.ts.map +0 -1
  414. package/src/capabilities/app-graph-builder.ts +0 -64
  415. package/src/capabilities/blueprint-definition.ts +0 -30
  416. package/src/capabilities/capabilities.ts +0 -12
  417. package/src/capabilities/compiler.ts +0 -34
  418. package/src/capabilities/intent-resolver.ts +0 -77
  419. package/src/capabilities/react-surface.tsx +0 -90
  420. package/src/capabilities/settings.ts +0 -21
  421. package/src/events.ts +0 -11
  422. package/src/templates/chess.ts +0 -47
  423. package/src/templates/echo.ts +0 -8
  424. package/src/types/schema.ts +0 -37
  425. /package/dist/lib/browser/{DeploymentDialog-QZSTVNIS.mjs.map → DeploymentDialog-GXNRUXF6.mjs.map} +0 -0
  426. /package/dist/lib/{node-esm/DeploymentDialog-G6EHEPXN.mjs.map → browser/blueprints/index.mjs.map} +0 -0
@@ -4,103 +4,107 @@
4
4
 
5
5
  import { autocompletion, completionKeymap } from '@codemirror/autocomplete';
6
6
  import { javascript } from '@codemirror/lang-javascript';
7
- import { defaultHighlightStyle } from '@codemirror/language';
7
+ import { HighlightStyle } from '@codemirror/language';
8
8
  import { lintKeymap } from '@codemirror/lint';
9
9
  import { Prec } from '@codemirror/state';
10
- import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
11
10
  import { keymap } from '@codemirror/view';
12
11
  import { tags } from '@lezer/highlight';
13
12
  import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
14
13
  import { continueKeymap } from '@valtown/codemirror-continue';
15
14
  import { type HoverInfo, tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from '@valtown/codemirror-ts';
16
- import React from 'react';
15
+ import React, { memo } from 'react';
17
16
 
18
17
  import { type ThemeMode, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
18
+ import { type UseTextEditorProps, useTextEditor } from '@dxos/react-ui-editor';
19
+ import { Domino } from '@dxos/ui';
19
20
  import {
21
+ type BasicExtensionsOptions,
20
22
  type EditorInputMode,
21
23
  InputModeExtensions,
22
- type UseTextEditorProps,
23
24
  createBasicExtensions,
24
25
  createThemeExtensions,
25
- folding,
26
- useTextEditor,
27
- } from '@dxos/react-ui-editor';
28
- import { mx } from '@dxos/react-ui-theme';
26
+ defaultStyles,
27
+ } from '@dxos/ui-editor';
28
+ import { mx } from '@dxos/ui-theme';
29
29
  import { isNonNullable } from '@dxos/util';
30
30
 
31
31
  export type TypescriptEditorProps = ThemedClassName<
32
32
  {
33
33
  id: string;
34
+ role?: string;
34
35
  inputMode?: EditorInputMode;
35
36
  toolbar?: boolean;
36
37
  env?: VirtualTypeScriptEnvironment;
38
+ options?: BasicExtensionsOptions;
37
39
  } & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>
38
40
  >;
39
41
 
40
- export const TypescriptEditor = ({
41
- classNames,
42
- id,
43
- inputMode = 'vscode',
44
- toolbar,
45
- env,
46
- initialValue,
47
- extensions,
48
- scrollTo,
49
- selection,
50
- }: TypescriptEditorProps) => {
51
- const { themeMode } = useThemeContext();
52
- const { parentRef, focusAttributes } = useTextEditor(
53
- () => ({
54
- id,
55
- initialValue,
56
- selection,
57
- scrollTo,
58
- extensions: [
59
- extensions,
60
- createBasicExtensions({
61
- highlightActiveLine: true,
62
- indentWithTab: true,
63
- lineNumbers: true,
64
- lineWrapping: false,
65
- monospace: true,
66
- scrollPastEnd: true,
67
- search: true,
68
- }),
69
- createThemeExtensions({ themeMode, syntaxHighlighting: true }),
70
- InputModeExtensions[inputMode],
71
- folding(),
72
- // Continues block comments when pressing Enter.
73
- Prec.high(keymap.of(continueKeymap)),
42
+ export const TypescriptEditor = memo(
43
+ ({
44
+ classNames,
45
+ id,
46
+ role = 'article',
47
+ inputMode = 'vscode',
48
+ env,
49
+ options,
50
+ initialValue,
51
+ extensions,
52
+ scrollTo,
53
+ selection,
54
+ }: TypescriptEditorProps) => {
55
+ const { themeMode } = useThemeContext();
56
+ const { parentRef, focusAttributes } = useTextEditor(
57
+ () => ({
58
+ id,
59
+ initialValue,
60
+ selection,
61
+ scrollTo,
62
+ extensions: [
63
+ extensions,
64
+ createBasicExtensions({
65
+ highlightActiveLine: true,
66
+ indentWithTab: true,
67
+ lineNumbers: true,
68
+ lineWrapping: false,
69
+ scrollPastEnd: role !== 'section',
70
+ search: true,
71
+ ...options,
72
+ }),
73
+ createThemeExtensions({
74
+ monospace: true,
75
+ themeMode,
76
+ syntaxHighlighting: true,
77
+ }),
74
78
 
75
- // TODO(burdon): Factor out.
76
- javascript({ typescript: true }),
77
- // https://github.com/val-town/codemirror-ts
78
- keymap.of(completionKeymap),
79
- autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
80
- keymap.of(lintKeymap),
81
- env && [
82
- tsFacet.of({ env, path: `/src/${id}.ts` }),
83
- tsSync(),
84
- tsLinter(),
85
- tsHover({ renderTooltip: createTooltipRenderer(themeMode) }),
86
- ],
87
- ].filter(isNonNullable),
88
- }),
89
- [id, extensions, themeMode, inputMode, selection, scrollTo],
90
- );
79
+ InputModeExtensions[inputMode],
80
+ javascript({ typescript: true }),
81
+ autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
91
82
 
92
- return (
93
- <div
94
- ref={parentRef}
95
- data-toolbar={toolbar ? 'enabled' : 'disabled'}
96
- className={mx(classNames)}
97
- {...focusAttributes}
98
- />
99
- );
100
- };
83
+ // Continues block comments when pressing Enter.
84
+ Prec.high(keymap.of(continueKeymap)),
85
+ keymap.of(completionKeymap),
86
+ keymap.of(lintKeymap),
87
+
88
+ // https://github.com/val-town/codemirror-ts
89
+ env && [
90
+ // TODO(burdon): Fix type.
91
+ tsFacet.of({ env: env as any, path: `./src/${id}.ts` }),
92
+ tsSync(),
93
+ tsLinter(),
94
+ tsHover({ renderTooltip: createTooltipRenderer(themeMode) }),
95
+ ],
96
+ ].filter(isNonNullable),
97
+ }),
98
+ [themeMode, id, extensions, inputMode, selection, scrollTo, env],
99
+ );
100
+
101
+ return <div ref={parentRef} className={mx(classNames)} {...focusAttributes} />;
102
+ },
103
+ );
101
104
 
105
+ // TODO(burdon): Factor out (react-ui-editor).
102
106
  const createTooltipRenderer = (themeMode: ThemeMode) => {
103
- const theme = themeMode === 'dark' ? oneDarkHighlightStyle : defaultHighlightStyle;
107
+ const theme = HighlightStyle.define(themeMode === 'dark' ? defaultStyles.dark : defaultStyles.light);
104
108
 
105
109
  const classFromKind = (_kind: string) => {
106
110
  // E.g., localName, methodName, parameterName, etc.
@@ -119,18 +123,15 @@ const createTooltipRenderer = (themeMode: ThemeMode) => {
119
123
  };
120
124
 
121
125
  return (info: HoverInfo) => {
122
- const div = document.createElement('div');
123
- div.className = 'p-1 rounded border border-separator bg-baseSurface xs:max-w-80 max-w-lg';
124
-
125
- if (info.quickInfo?.displayParts) {
126
- for (const part of info.quickInfo.displayParts) {
127
- const span = div.appendChild(document.createElement('span'));
128
- span.className = classFromKind(part.kind);
129
- span.innerText = part.text;
130
- }
131
- }
132
-
133
- return { dom: div };
126
+ const children =
127
+ info.quickInfo?.displayParts?.map(({ kind, text }) =>
128
+ Domino.of('span').classNames(classFromKind(kind)).text(text),
129
+ ) ?? [];
130
+ return {
131
+ dom: Domino.of('div')
132
+ .classNames('xs:max-is-80 max-is-lg p-1 bg-baseSurface rounded border border-separator')
133
+ .children(...children).root,
134
+ };
134
135
  };
135
136
  };
136
137
 
@@ -4,9 +4,12 @@
4
4
 
5
5
  import { lazy } from 'react';
6
6
 
7
+ export * from './NotebookStack';
7
8
  export * from './Settings';
8
9
  export * from './TestPanel';
10
+
9
11
  export { DEPLOYMENT_DIALOG } from './DeploymentDialog';
10
12
 
11
13
  export const ScriptContainer = lazy(() => import('./ScriptContainer'));
12
14
  export const DeploymentDialog = lazy(() => import('./DeploymentDialog'));
15
+ export const NotebookContainer = lazy(() => import('./NotebookContainer'));
@@ -0,0 +1,92 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe } from '@effect/vitest';
6
+ import { test } from 'vitest';
7
+
8
+ import { Client } from '@dxos/client';
9
+ import { type Space } from '@dxos/client-protocol';
10
+ import { configPreset } from '@dxos/config';
11
+ import { Function } from '@dxos/functions';
12
+ import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
13
+ import { bundleFunction } from '@dxos/functions-runtime/native';
14
+ import { FunctionRuntimeKind } from '@dxos/protocols';
15
+ import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
16
+
17
+ // To heavy to run in CI.
18
+ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e')).skip('Function', () => {
19
+ const config = configPreset({ edge: 'local' });
20
+
21
+ test('bundle anthropic function', { timeout: 120_000 }, async () => {
22
+ await bundleFunction({
23
+ entryPoint: new URL('../templates/anthropic.ts', import.meta.url).pathname,
24
+ verbose: true,
25
+ });
26
+ });
27
+
28
+ test('deploy empty function', { timeout: 120_000 }, async () => {
29
+ const { space, functionsServiceClient } = await setup();
30
+
31
+ await sync(space);
32
+ const func = await deployFunction(
33
+ space,
34
+ functionsServiceClient,
35
+ new URL('../templates/ping.ts', import.meta.url).pathname,
36
+ );
37
+ console.log(func);
38
+ throw new Error('test');
39
+ });
40
+
41
+ test('deploy and invoke anthropic function', { timeout: 120_000 }, async () => {
42
+ const { space, functionsServiceClient } = await setup();
43
+ await sync(space);
44
+ const func = await deployFunction(
45
+ space,
46
+ functionsServiceClient,
47
+ new URL('../templates/anthropic.ts', import.meta.url).pathname,
48
+ );
49
+
50
+ const result = await functionsServiceClient.invoke(func, {
51
+ message: 'Hello, world!',
52
+ });
53
+ console.log(result);
54
+ });
55
+
56
+ const setup = async () => {
57
+ const client = await new Client({ config, types: [Function.Function] }).initialize();
58
+ await client.halo.createIdentity();
59
+
60
+ const space = await client.spaces.create();
61
+ await space.waitUntilReady();
62
+ await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);
63
+
64
+ const functionsServiceClient = FunctionsServiceClient.fromClient(client);
65
+ return { client, space, functionsServiceClient };
66
+ };
67
+
68
+ const sync = async (space: Space) => {
69
+ await space.db.flush({ indexes: true });
70
+ await space.internal.syncToEdge({
71
+ onProgress: (state) =>
72
+ console.log(state ? `${state.unsyncedDocumentCount} documents syncing...` : 'connecting to edge...'),
73
+ });
74
+ };
75
+
76
+ const deployFunction = async (space: Space, functionsServiceClient: FunctionsServiceClient, entryPoint: string) => {
77
+ const artifact = await bundleFunction({
78
+ entryPoint,
79
+ verbose: true,
80
+ });
81
+ const func = await functionsServiceClient.deploy({
82
+ version: '0.0.1',
83
+ ownerPublicKey: space.key,
84
+ entryPoint: artifact.entryPoint,
85
+ assets: artifact.assets,
86
+ runtime: FunctionRuntimeKind.enums.WORKER_LOADER,
87
+ });
88
+
89
+ space.db.add(func);
90
+ return func;
91
+ };
92
+ });
@@ -0,0 +1,64 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { readFile } from 'node:fs/promises';
6
+
7
+ import { describe, expect, test } from 'vitest';
8
+
9
+ import { Client, type Config } from '@dxos/client';
10
+ import { createEdgeIdentity } from '@dxos/client/edge';
11
+ import { configPreset } from '@dxos/config';
12
+ import { bundleFunction } from '@dxos/functions-runtime/bundler';
13
+ import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
14
+ import { invariant } from '@dxos/invariant';
15
+ import { log } from '@dxos/log';
16
+
17
+ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('Functions deployment', () => {
18
+ test('deploys FOREX (effect) function and invokes it via EDGE (main)', { timeout: 120_000 }, async () => {
19
+ const config = configPreset({ edge: 'main' });
20
+ await testDeploy(config);
21
+ });
22
+
23
+ test('deploys FOREX (effect) function and invokes it via EDGE (production)', { timeout: 120_000 }, async () => {
24
+ const config = configPreset({ edge: 'production' });
25
+ await testDeploy(config);
26
+ });
27
+
28
+ const testDeploy = async (config: Config) => {
29
+ await using client = await new Client({ config }).initialize();
30
+ await client.halo.createIdentity();
31
+
32
+ const space = await client.spaces.create();
33
+ await space.waitUntilReady();
34
+
35
+ // Inline echo function source.
36
+ const source = await readFile(new URL('../templates/forex-effect.ts', import.meta.url), 'utf-8');
37
+
38
+ // Bundle and upload.
39
+ const buildResult = await bundleFunction({ source });
40
+ if ('error' in buildResult) {
41
+ throw buildResult.error ?? new Error('Bundle creation failed');
42
+ }
43
+ const functionsServiceClient = FunctionsServiceClient.fromClient(client);
44
+
45
+ const func = await functionsServiceClient.deploy({
46
+ ownerPublicKey: space.key,
47
+ version: '0.0.1',
48
+ entryPoint: buildResult.entryPoint,
49
+ assets: buildResult.assets,
50
+ });
51
+
52
+ // Invoke deployed function via EDGE directly.
53
+ const edgeClient = client.edge;
54
+ invariant(edgeClient, 'edgeClient is required');
55
+ edgeClient.setIdentity(createEdgeIdentity(client));
56
+
57
+ const input = { from: 'USD', to: 'EUR' };
58
+ const result = await functionsServiceClient.invoke(func, input);
59
+ log.info('>>> result', { result, func });
60
+ const resultNumber = Number(result);
61
+ expect(resultNumber).toBeGreaterThan(0);
62
+ expect(resultNumber).toBeLessThan(100);
63
+ };
64
+ });
@@ -4,15 +4,16 @@
4
4
 
5
5
  import { useEffect, useMemo } from 'react';
6
6
 
7
- import { FunctionType, type ScriptType, getUserFunctionIdInMetadata } from '@dxos/functions';
7
+ import { Obj, Query, Ref } from '@dxos/echo';
8
+ import { Function, type Script, getUserFunctionIdInMetadata } from '@dxos/functions';
8
9
  import { log } from '@dxos/log';
9
10
  import { type Client, useClient } from '@dxos/react-client';
10
- import { Query, Ref, type Space, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
11
+ import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
11
12
  import { type TFunction } from '@dxos/react-ui';
12
13
  import { createMenuAction } from '@dxos/react-ui-menu';
13
- import { errorMessageColors } from '@dxos/react-ui-theme';
14
+ import { errorMessageColors } from '@dxos/ui-theme';
14
15
 
15
- import { SCRIPT_PLUGIN } from '../meta';
16
+ import { meta } from '../meta';
16
17
  import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
17
18
 
18
19
  export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
@@ -24,10 +25,12 @@ export type DeployState = {
24
25
  error: string;
25
26
  };
26
27
 
28
+ import { type ScriptToolbarStateStore } from './useToolbarState';
29
+
27
30
  export type CreateDeployOptions = {
28
- state: Partial<DeployState>;
29
- script: ScriptType;
30
- fn: FunctionType;
31
+ state: ScriptToolbarStateStore;
32
+ script: Script.Script;
33
+ fn: Function.Function;
31
34
  space?: Space;
32
35
  existingFunctionId?: string;
33
36
  client: Client;
@@ -35,12 +38,14 @@ export type CreateDeployOptions = {
35
38
  };
36
39
 
37
40
  export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
41
+ const { value } = state;
42
+
38
43
  // TODO(wittjosiah): Should this be an action?
39
44
  const errorItem = createMenuAction('error', () => {}, {
40
- label: state.error ?? ['no error label', { ns: SCRIPT_PLUGIN }],
45
+ label: value.error ?? ['no error label', { ns: meta.id }],
41
46
  icon: 'ph--warning-circle--regular',
42
- hidden: !state.error,
43
- classNames: state.error && errorMessageColors,
47
+ hidden: !value.error,
48
+ classNames: value.error && errorMessageColors,
44
49
  });
45
50
 
46
51
  const deployAction = createMenuAction<DeployActionProperties>(
@@ -50,40 +55,39 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
50
55
  return;
51
56
  }
52
57
 
53
- state.error = undefined;
54
- state.deploying = true;
58
+ state.set('error', undefined);
59
+ state.set('deploying', true);
55
60
 
56
61
  const result = await deployScript({ script, client, space, fn, existingFunctionId });
57
62
 
58
63
  if (!result.success) {
59
64
  log.catch(result.error);
60
- state.error = t('upload failed label');
65
+ state.set('error', t('upload failed label'));
61
66
  }
62
67
 
63
- state.deploying = false;
68
+ state.set('deploying', false);
64
69
  },
65
70
  {
66
71
  type: 'deploy',
67
- label: [state.deploying ? 'pending label' : 'deploy label', { ns: SCRIPT_PLUGIN }],
68
- icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
69
- disabled: state.deploying,
70
- classNames: state.deploying ? '[&_svg]:animate-spin' : '',
72
+ label: [value.deploying ? 'publishing label' : 'deploy label', { ns: meta.id }],
73
+ icon: value.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
74
+ disabled: value.deploying,
75
+ classNames: value.deploying ? '[&_svg]:animate-spin' : '',
71
76
  },
72
77
  );
73
78
 
74
79
  const copyAction = createMenuAction<DeployActionProperties>(
75
80
  'copy',
76
81
  async () => {
77
- if (!state.functionUrl) {
78
- return;
82
+ if (value.functionUrl) {
83
+ await navigator.clipboard.writeText(value.functionUrl);
79
84
  }
80
- await navigator.clipboard.writeText(state.functionUrl);
81
85
  },
82
86
  {
83
87
  type: 'copy',
84
- label: ['copy link label', { ns: SCRIPT_PLUGIN }],
88
+ label: ['copy link label', { ns: meta.id }],
85
89
  icon: 'ph--link--regular',
86
- disabled: !state.functionUrl,
90
+ disabled: !value.functionUrl,
87
91
  },
88
92
  );
89
93
 
@@ -97,29 +101,32 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
97
101
  };
98
102
  };
99
103
 
100
- export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script: ScriptType }) => {
104
+ export const useDeployState = ({ state, script }: { state: ScriptToolbarStateStore; script: Script.Script }) => {
101
105
  const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
102
106
  useEffect(() => {
103
107
  if (!existingFunctionId) {
104
108
  return;
105
109
  }
106
110
 
107
- state.functionUrl = getFunctionUrl({
108
- script,
109
- fn,
110
- edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
111
- });
112
- }, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
111
+ state.set(
112
+ 'functionUrl',
113
+ getFunctionUrl({
114
+ script,
115
+ fn,
116
+ edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
117
+ }),
118
+ );
119
+ }, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url, state]);
113
120
 
114
121
  useEffect(() => {
115
- state.deployed = isScriptDeployed({ script, fn });
116
- }, [script.changed, existingFunctionId, fn, script]);
122
+ state.set('deployed', isScriptDeployed({ script, fn }));
123
+ }, [script.changed, existingFunctionId, fn, script, state]);
117
124
  };
118
125
 
119
- export const useDeployDeps = ({ script }: { script: ScriptType }) => {
120
- const space = getSpace(script);
121
- const [fn] = useQuery(space, Query.type(FunctionType, { source: Ref.make(script) }));
126
+ export const useDeployDeps = ({ script }: { script: Script.Script }) => {
122
127
  const client = useClient();
123
- const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(getMeta(fn)), [fn]);
124
- return { space, fn, client, existingFunctionId };
128
+ const space = getSpace(script);
129
+ const [fn] = useQuery(space?.db, Query.type(Function.Function, { source: Ref.make(script) }));
130
+ const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
131
+ return { client, space, fn, existingFunctionId };
125
132
  };
@@ -6,15 +6,16 @@ import { format } from 'prettier';
6
6
  import prettierPluginEstree from 'prettier/plugins/estree';
7
7
  import prettierPluginTypescript from 'prettier/plugins/typescript';
8
8
 
9
- import { type ScriptType } from '@dxos/functions';
9
+ import { Obj } from '@dxos/echo';
10
+ import { type Script } from '@dxos/functions';
10
11
  import { log } from '@dxos/log';
11
12
  import { createMenuAction } from '@dxos/react-ui-menu';
12
13
 
13
- import { SCRIPT_PLUGIN } from '../meta';
14
+ import { meta } from '../meta';
14
15
 
15
16
  export type FormatActionProperties = { type: 'format' };
16
17
 
17
- export const createFormat = (script: ScriptType) => {
18
+ export const createFormat = (script: Script.Script) => {
18
19
  const formatAction = createMenuAction(
19
20
  'format',
20
21
  async () => {
@@ -23,19 +24,22 @@ export const createFormat = (script: ScriptType) => {
23
24
  }
24
25
 
25
26
  try {
26
- script.source.target!.content = await format(script.source.target!.content, {
27
+ const formatted = await format(script.source.target!.content, {
27
28
  parser: 'typescript',
28
29
  plugins: [prettierPluginEstree, prettierPluginTypescript],
29
30
  semi: true,
30
31
  singleQuote: true,
31
32
  });
33
+ Obj.change(script.source.target!, (s) => {
34
+ s.content = formatted;
35
+ });
32
36
  } catch (err: any) {
33
37
  // TODO(wittjosiah): Show error in UI.
34
38
  log.catch(err);
35
39
  }
36
40
  },
37
41
  {
38
- label: ['format label', { ns: SCRIPT_PLUGIN }],
42
+ label: ['format label', { ns: meta.id }],
39
43
  icon: 'ph--magic-wand--regular',
40
44
  },
41
45
  );
@@ -8,3 +8,4 @@ export * from './template';
8
8
 
9
9
  export * from './useCreateAndDeployScriptTemplates';
10
10
  export * from './useToolbarState';
11
+ export * from './useCompiler';
@@ -3,35 +3,33 @@
3
3
  //
4
4
 
5
5
  import { Obj } from '@dxos/echo';
6
- import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
7
- import { createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
6
+ import { FUNCTIONS_PRESET_META_KEY, type Script } from '@dxos/functions';
7
+ import { createMenuAction } from '@dxos/react-ui-menu';
8
8
 
9
- import { SCRIPT_PLUGIN } from '../meta';
10
9
  import { templates } from '../templates';
11
10
 
12
11
  export type TemplateActionProperties = { type: 'template'; value: string };
13
12
 
14
- const createTemplateSelectGroup = () => {
15
- return createMenuItemGroup('template-select', {
16
- label: ['template select group label', { ns: SCRIPT_PLUGIN }],
17
- variant: 'dropdownMenu',
18
- });
19
- };
20
-
21
- const createTemplateSelectActions = (script: ScriptType) => {
13
+ const createTemplateSelectActions = (script: Script.Script) => {
22
14
  return templates.map((template) => {
23
15
  return createMenuAction<TemplateActionProperties>(
24
16
  `template--${template.id}`,
25
17
  () => {
26
- script.name = template.name;
27
- script.source!.target!.content = template.source;
28
- const metaKeys = Obj.getMeta(script).keys;
29
- const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
30
- if (oldPresetIndex >= 0) {
31
- metaKeys.splice(oldPresetIndex, 1);
32
- }
33
- if (template.presetId) {
34
- metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
18
+ Obj.change(script, (s) => {
19
+ s.name = template.name;
20
+ const meta = Obj.getMeta(s);
21
+ const oldPresetIndex = meta.keys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
22
+ if (oldPresetIndex >= 0) {
23
+ meta.keys.splice(oldPresetIndex, 1);
24
+ }
25
+ if ('presetId' in template) {
26
+ meta.keys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
27
+ }
28
+ });
29
+ if (script.source?.target) {
30
+ Obj.change(script.source.target, (s) => {
31
+ s.content = template.source;
32
+ });
35
33
  }
36
34
  },
37
35
  {
@@ -43,11 +41,10 @@ const createTemplateSelectActions = (script: ScriptType) => {
43
41
  });
44
42
  };
45
43
 
46
- export const createTemplateSelect = (script: ScriptType) => {
47
- const templateSelectGroup = createTemplateSelectGroup();
44
+ export const createTemplateSelect = (script: Script.Script) => {
48
45
  const templateSelectActions = createTemplateSelectActions(script);
49
46
  return {
50
- nodes: [templateSelectGroup, ...templateSelectActions],
47
+ nodes: [...templateSelectActions],
51
48
  edges: [
52
49
  { source: 'root', target: 'template-select' },
53
50
  ...templateSelectActions.map((action) => ({ source: 'template-select', target: action.id })),