@dxos/plugin-script 0.8.4-main.3c1ae3b → 0.8.4-main.52d7546f51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
- package/dist/lib/browser/{NotebookContainer-GL2Z5I5Q.mjs → NotebookContainer-UQ4I24R6.mjs} +266 -238
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs +113 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-S22N3BUR.mjs → chunk-4N5TLXEJ.mjs} +26 -9
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs +270 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs.map +7 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs +137 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs.map +7 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs +609 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UGDRMROB.mjs → chunk-WWCDIB6Z.mjs} +160 -145
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EB6AXFXO.mjs → chunk-WYR4QHPE.mjs} +1 -1
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/{compiler-2HV5KXV4.mjs → compiler-VPUVTFQD.mjs} +40 -22
- package/dist/lib/browser/compiler-VPUVTFQD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +93 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs +83 -0
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-ASV2KBRA.mjs → react-surface-FYOQSC6S.mjs} +48 -36
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs.map +7 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs +36 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +9 -5
- package/dist/lib/node-esm/{DeploymentDialog-5EN2KZE5.mjs → DeploymentDialog-GGWDQMEB.mjs} +6 -7
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs.map +7 -0
- package/dist/lib/node-esm/{NotebookContainer-7RCEXND7.mjs → NotebookContainer-DQGZ6QHI.mjs} +266 -238
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs +610 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs +271 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IBV2DR36.mjs → chunk-5HSJPAK7.mjs} +1 -1
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4VVV5L5A.mjs → chunk-ECRSTVR6.mjs} +160 -145
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs +114 -0
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs +138 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2S43VHAM.mjs → chunk-V37R7KB5.mjs} +26 -9
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-KPEZKEHC.mjs → compiler-WUOSY6MS.mjs} +40 -22
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +93 -103
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs +84 -0
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-NXBO7VYB.mjs → react-surface-LREMOVNJ.mjs} +48 -36
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs.map +7 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs +37 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +9 -5
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
- package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +7 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +1 -3
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +3 -5
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +3 -250
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +3 -3
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +2 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +4 -5
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +2 -2
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +2 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +4 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +3 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/e2e/ai.test.d.ts +2 -0
- package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +7 -6
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -2
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +24 -11
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
- package/dist/types/src/templates/anthropic.d.ts +8 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +16 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +16 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/index.d.ts +12 -3
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +1 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +88 -19
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- package/dist/types/src/types/actions.d.ts +30 -44
- package/dist/types/src/types/actions.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +12 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +113 -90
- package/src/ScriptPlugin.tsx +38 -61
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +24 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +88 -85
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +119 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +33 -0
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +28 -24
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +22 -42
- package/src/components/FrameContainer/FrameContainer.tsx +1 -1
- package/src/components/NotebookContainer.stories.tsx +24 -20
- package/src/components/NotebookContainer.tsx +49 -38
- package/src/components/NotebookStack/NotebookCell.tsx +18 -17
- package/src/components/NotebookStack/NotebookStack.stories.tsx +20 -19
- package/src/components/NotebookStack/NotebookStack.tsx +4 -4
- package/src/components/QueryEditor/QueryEditor.stories.tsx +18 -7
- package/src/components/ScriptContainer.tsx +46 -32
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +39 -16
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -17
- package/src/components/Settings/ScriptObjectSettings.tsx +40 -29
- package/src/components/Settings/ScriptPluginSettings.tsx +19 -14
- package/src/components/TestPanel/TestContainer.tsx +5 -5
- package/src/components/TestPanel/TestPanel.tsx +25 -23
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +12 -7
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +69 -68
- package/src/e2e/ai.test.ts +92 -0
- package/src/hooks/deploy.ts +33 -26
- package/src/hooks/format.ts +5 -1
- package/src/hooks/template.ts +15 -9
- package/src/hooks/useCompiler.ts +5 -4
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +13 -19
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +1 -1
- package/src/meta.ts +2 -2
- package/src/notebook/compute-graph.test.ts +20 -8
- package/src/notebook/compute-graph.ts +45 -21
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +230 -0
- package/src/templates/forex-effect.ts +1 -1
- package/src/templates/index.ts +18 -5
- package/src/templates/ping.ts +14 -5
- package/src/types/Notebook.ts +7 -8
- package/src/types/actions.ts +17 -25
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/types.ts +1 -1
- package/src/util/deploy.ts +6 -2
- package/src/util/functions.ts +24 -22
- package/dist/lib/browser/DeploymentDialog-FIHD4UVK.mjs +0 -15
- package/dist/lib/browser/NotebookContainer-GL2Z5I5Q.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-F4OK3OG6.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-F4OK3OG6.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs +0 -66
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +0 -30
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +0 -7
- package/dist/lib/browser/chunk-2SXDKBM7.mjs +0 -304
- package/dist/lib/browser/chunk-2SXDKBM7.mjs.map +0 -7
- package/dist/lib/browser/chunk-6X7QVTRB.mjs +0 -112
- package/dist/lib/browser/chunk-6X7QVTRB.mjs.map +0 -7
- package/dist/lib/browser/chunk-75RTLLH4.mjs +0 -155
- package/dist/lib/browser/chunk-75RTLLH4.mjs.map +0 -7
- package/dist/lib/browser/chunk-7WFISUBY.mjs +0 -647
- package/dist/lib/browser/chunk-7WFISUBY.mjs.map +0 -7
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
- package/dist/lib/browser/chunk-MQHBMJLH.mjs +0 -103
- package/dist/lib/browser/chunk-MQHBMJLH.mjs.map +0 -7
- package/dist/lib/browser/chunk-S22N3BUR.mjs.map +0 -7
- package/dist/lib/browser/chunk-UGDRMROB.mjs.map +0 -7
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs +0 -15
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs.map +0 -7
- package/dist/lib/browser/compiler-2HV5KXV4.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3B4ESSCU.mjs +0 -105
- package/dist/lib/browser/intent-resolver-3B4ESSCU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ASV2KBRA.mjs.map +0 -7
- package/dist/lib/browser/settings-4NKLTJTT.mjs +0 -26
- package/dist/lib/browser/settings-4NKLTJTT.mjs.map +0 -7
- package/dist/lib/node-esm/NotebookContainer-7RCEXND7.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-763IAKOD.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-763IAKOD.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs +0 -67
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +0 -31
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2S43VHAM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-32AMTGGN.mjs +0 -104
- package/dist/lib/node-esm/chunk-32AMTGGN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4VVV5L5A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-535YDI5V.mjs +0 -156
- package/dist/lib/node-esm/chunk-535YDI5V.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs +0 -16
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6H4FYMCX.mjs +0 -114
- package/dist/lib/node-esm/chunk-6H4FYMCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DKS2EQW6.mjs +0 -648
- package/dist/lib/node-esm/chunk-DKS2EQW6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NQN3JE2R.mjs +0 -305
- package/dist/lib/node-esm/chunk-NQN3JE2R.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-KPEZKEHC.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GIACMXI4.mjs +0 -106
- package/dist/lib/node-esm/intent-resolver-GIACMXI4.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NXBO7VYB.mjs.map +0 -7
- package/dist/lib/node-esm/settings-PW5NXWLW.mjs +0 -27
- package/dist/lib/node-esm/settings-PW5NXWLW.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -8
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/testing/deploy.test.d.ts +0 -2
- package/dist/types/src/testing/deploy.test.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -65
- package/src/capabilities/blueprint-definition.ts +0 -30
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -84
- package/src/capabilities/intent-resolver.ts +0 -86
- package/src/capabilities/react-surface.tsx +0 -102
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -50
- package/src/testing/deploy.test.ts +0 -63
- /package/dist/lib/browser/{DeploymentDialog-FIHD4UVK.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-5EN2KZE5.mjs.map → browser/blueprints/index.mjs.map} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Script } from '@dxos/functions';
|
|
8
|
-
import {
|
|
8
|
+
import { Layout } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { useDeployState, useToolbarState } from '../../hooks';
|
|
11
11
|
|
|
@@ -16,12 +16,12 @@ export type TestContainerProps = {
|
|
|
16
16
|
script: Script.Script;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const TestContainer = ({ script }: TestContainerProps) => {
|
|
19
|
+
export const TestContainer = ({ role, script }: TestContainerProps) => {
|
|
20
20
|
const state = useToolbarState();
|
|
21
21
|
useDeployState({ state, script });
|
|
22
22
|
return (
|
|
23
|
-
<
|
|
24
|
-
<TestPanel functionUrl={state.functionUrl} />
|
|
25
|
-
</
|
|
23
|
+
<Layout.Main role={role}>
|
|
24
|
+
<TestPanel functionUrl={state.value.functionUrl} />
|
|
25
|
+
</Layout.Main>
|
|
26
26
|
);
|
|
27
27
|
};
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
|
-
import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { Avatar, Icon, Input, ScrollArea, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
|
-
import { errorText, mx } from '@dxos/
|
|
10
|
+
import { errorText, mx } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
12
|
import { meta } from '../../meta';
|
|
13
13
|
|
|
@@ -219,29 +219,31 @@ type MessageThreadProps = {
|
|
|
219
219
|
const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
220
220
|
({ state, history, result }: MessageThreadProps, forwardedRef) => {
|
|
221
221
|
return (
|
|
222
|
-
<
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
<div className='
|
|
226
|
-
|
|
227
|
-
<
|
|
222
|
+
<ScrollArea.Root orientation='vertical' classNames='bs-full' ref={forwardedRef}>
|
|
223
|
+
<ScrollArea.Viewport classNames='gap-6 p-2'>
|
|
224
|
+
{history.map((message, i) => (
|
|
225
|
+
<div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
226
|
+
<div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
|
|
227
|
+
<div className='overflow-auto'>
|
|
228
|
+
<MessageItem message={message} />
|
|
229
|
+
</div>
|
|
228
230
|
</div>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
))}
|
|
232
|
+
|
|
233
|
+
{result?.length > 0 && (
|
|
234
|
+
<div className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
235
|
+
<div className='p-1'>
|
|
236
|
+
{(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
|
|
237
|
+
<Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
|
|
238
|
+
)}
|
|
239
|
+
</div>
|
|
240
|
+
<div className='overflow-auto'>
|
|
241
|
+
<MessageItem message={{ type: 'response', text: result }} />
|
|
242
|
+
</div>
|
|
238
243
|
</div>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
</div>
|
|
243
|
-
)}
|
|
244
|
-
</div>
|
|
244
|
+
)}
|
|
245
|
+
</ScrollArea.Viewport>
|
|
246
|
+
</ScrollArea.Root>
|
|
245
247
|
);
|
|
246
248
|
},
|
|
247
249
|
);
|
|
@@ -8,10 +8,10 @@ import React, { useCallback, useMemo, useState } from 'react';
|
|
|
8
8
|
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
9
|
import { createObject } from '@dxos/react-client/echo';
|
|
10
10
|
import { Toolbar } from '@dxos/react-ui';
|
|
11
|
+
import { Layout } from '@dxos/react-ui';
|
|
11
12
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
-
import { createDataExtensions } from '@dxos/react-ui-editor';
|
|
13
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
14
13
|
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
14
|
+
import { createDataExtensions } from '@dxos/ui-editor';
|
|
15
15
|
import { trim } from '@dxos/util';
|
|
16
16
|
|
|
17
17
|
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
@@ -35,7 +35,12 @@ const DefaultStory = (props: TypescriptEditorProps) => {
|
|
|
35
35
|
// );
|
|
36
36
|
|
|
37
37
|
const extensions = useMemo(
|
|
38
|
-
() => [
|
|
38
|
+
() => [
|
|
39
|
+
createDataExtensions({
|
|
40
|
+
id: object.id,
|
|
41
|
+
text: createDocAccessor(object, ['content']),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
39
44
|
[],
|
|
40
45
|
);
|
|
41
46
|
|
|
@@ -61,16 +66,16 @@ const DefaultStory = (props: TypescriptEditorProps) => {
|
|
|
61
66
|
}, [object]);
|
|
62
67
|
|
|
63
68
|
return (
|
|
64
|
-
<
|
|
69
|
+
<Layout.Main toolbar>
|
|
65
70
|
{/* <ScriptToolbar script={script} state={{}} /> */}
|
|
66
71
|
<Toolbar.Root>
|
|
67
72
|
<Toolbar.Button onClick={handleRun}>Run</Toolbar.Button>
|
|
68
73
|
</Toolbar.Root>
|
|
69
74
|
<div role='none' className='grid grid-rows-[1fr_min-content] bs-full overflow-hidden text-sm'>
|
|
70
75
|
<TypescriptEditor {...props} initialValue={object.content} extensions={extensions} />
|
|
71
|
-
<Json data={result} classNames='shrink-0 p-2 border-
|
|
76
|
+
<Json data={result} classNames='shrink-0 p-2 border-bs border-subduedSeparator' />
|
|
72
77
|
</div>
|
|
73
|
-
</
|
|
78
|
+
</Layout.Main>
|
|
74
79
|
);
|
|
75
80
|
};
|
|
76
81
|
|
|
@@ -78,7 +83,7 @@ const meta = {
|
|
|
78
83
|
title: 'plugins/plugin-script/TypescriptEditor',
|
|
79
84
|
component: TypescriptEditor,
|
|
80
85
|
render: DefaultStory,
|
|
81
|
-
decorators: [withTheme, withLayout({
|
|
86
|
+
decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'is-proseMaxWidth' })],
|
|
82
87
|
} satisfies Meta<typeof DefaultStory>;
|
|
83
88
|
|
|
84
89
|
export default meta;
|
|
@@ -12,20 +12,20 @@ import { tags } from '@lezer/highlight';
|
|
|
12
12
|
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
13
13
|
import { continueKeymap } from '@valtown/codemirror-continue';
|
|
14
14
|
import { type HoverInfo, tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from '@valtown/codemirror-ts';
|
|
15
|
-
import React from 'react';
|
|
15
|
+
import React, { memo } from 'react';
|
|
16
16
|
|
|
17
|
-
import {
|
|
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';
|
|
18
20
|
import {
|
|
19
21
|
type BasicExtensionsOptions,
|
|
20
22
|
type EditorInputMode,
|
|
21
23
|
InputModeExtensions,
|
|
22
|
-
type UseTextEditorProps,
|
|
23
24
|
createBasicExtensions,
|
|
24
25
|
createThemeExtensions,
|
|
25
26
|
defaultStyles,
|
|
26
|
-
|
|
27
|
-
} from '@dxos/
|
|
28
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
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<
|
|
@@ -39,66 +39,68 @@ export type TypescriptEditorProps = ThemedClassName<
|
|
|
39
39
|
} & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>
|
|
40
40
|
>;
|
|
41
41
|
|
|
42
|
-
export const TypescriptEditor = (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
extensions
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
}),
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
InputModeExtensions[inputMode],
|
|
80
|
+
javascript({ typescript: true }),
|
|
81
|
+
autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
// Continues block comments when pressing Enter.
|
|
84
|
+
Prec.high(keymap.of(continueKeymap)),
|
|
85
|
+
keymap.of(completionKeymap),
|
|
86
|
+
keymap.of(lintKeymap),
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
);
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
return <div ref={parentRef} className={mx(classNames)} {...focusAttributes} />;
|
|
102
|
+
},
|
|
103
|
+
);
|
|
102
104
|
|
|
103
105
|
// TODO(burdon): Factor out (react-ui-editor).
|
|
104
106
|
const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
@@ -121,15 +123,14 @@ const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
|
121
123
|
};
|
|
122
124
|
|
|
123
125
|
return (info: HoverInfo) => {
|
|
126
|
+
const children =
|
|
127
|
+
info.quickInfo?.displayParts?.map(({ kind, text }) =>
|
|
128
|
+
Domino.of('span').classNames(classFromKind(kind)).text(text),
|
|
129
|
+
) ?? [];
|
|
124
130
|
return {
|
|
125
131
|
dom: Domino.of('div')
|
|
126
132
|
.classNames('xs:max-is-80 max-is-lg p-1 bg-baseSurface rounded border border-separator')
|
|
127
|
-
.children(
|
|
128
|
-
...(info.quickInfo?.displayParts?.map(({ kind, text }) =>
|
|
129
|
-
Domino.of('span').classNames(classFromKind(kind)).text(text),
|
|
130
|
-
) ?? []),
|
|
131
|
-
)
|
|
132
|
-
.build(),
|
|
133
|
+
.children(...children).root,
|
|
133
134
|
};
|
|
134
135
|
};
|
|
135
136
|
};
|
|
@@ -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
|
+
});
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type Client, useClient } from '@dxos/react-client';
|
|
|
11
11
|
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
12
|
import { type TFunction } from '@dxos/react-ui';
|
|
13
13
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
14
|
-
import { errorMessageColors } from '@dxos/
|
|
14
|
+
import { errorMessageColors } from '@dxos/ui-theme';
|
|
15
15
|
|
|
16
16
|
import { meta } from '../meta';
|
|
17
17
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
@@ -25,8 +25,10 @@ export type DeployState = {
|
|
|
25
25
|
error: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
import { type ScriptToolbarStateStore } from './useToolbarState';
|
|
29
|
+
|
|
28
30
|
export type CreateDeployOptions = {
|
|
29
|
-
state:
|
|
31
|
+
state: ScriptToolbarStateStore;
|
|
30
32
|
script: Script.Script;
|
|
31
33
|
fn: Function.Function;
|
|
32
34
|
space?: Space;
|
|
@@ -36,12 +38,14 @@ export type CreateDeployOptions = {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
41
|
+
const { value } = state;
|
|
42
|
+
|
|
39
43
|
// TODO(wittjosiah): Should this be an action?
|
|
40
44
|
const errorItem = createMenuAction('error', () => {}, {
|
|
41
|
-
label:
|
|
45
|
+
label: value.error ?? ['no error label', { ns: meta.id }],
|
|
42
46
|
icon: 'ph--warning-circle--regular',
|
|
43
|
-
hidden: !
|
|
44
|
-
classNames:
|
|
47
|
+
hidden: !value.error,
|
|
48
|
+
classNames: value.error && errorMessageColors,
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
const deployAction = createMenuAction<DeployActionProperties>(
|
|
@@ -51,39 +55,39 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
state.error
|
|
55
|
-
state.deploying
|
|
58
|
+
state.set('error', undefined);
|
|
59
|
+
state.set('deploying', true);
|
|
56
60
|
|
|
57
61
|
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
58
62
|
|
|
59
63
|
if (!result.success) {
|
|
60
64
|
log.catch(result.error);
|
|
61
|
-
state.error
|
|
65
|
+
state.set('error', t('upload failed label'));
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
state.deploying
|
|
68
|
+
state.set('deploying', false);
|
|
65
69
|
},
|
|
66
70
|
{
|
|
67
71
|
type: 'deploy',
|
|
68
|
-
label: [
|
|
69
|
-
icon:
|
|
70
|
-
disabled:
|
|
71
|
-
classNames:
|
|
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' : '',
|
|
72
76
|
},
|
|
73
77
|
);
|
|
74
78
|
|
|
75
79
|
const copyAction = createMenuAction<DeployActionProperties>(
|
|
76
80
|
'copy',
|
|
77
81
|
async () => {
|
|
78
|
-
if (
|
|
79
|
-
await navigator.clipboard.writeText(
|
|
82
|
+
if (value.functionUrl) {
|
|
83
|
+
await navigator.clipboard.writeText(value.functionUrl);
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
{
|
|
83
87
|
type: 'copy',
|
|
84
88
|
label: ['copy link label', { ns: meta.id }],
|
|
85
89
|
icon: 'ph--link--regular',
|
|
86
|
-
disabled: !
|
|
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:
|
|
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.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
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
126
|
export const useDeployDeps = ({ script }: { script: Script.Script }) => {
|
|
120
127
|
const client = useClient();
|
|
121
128
|
const space = getSpace(script);
|
|
122
|
-
const [fn] = useQuery(space, Query.type(Function.Function, { source: Ref.make(script) }));
|
|
129
|
+
const [fn] = useQuery(space?.db, Query.type(Function.Function, { source: Ref.make(script) }));
|
|
123
130
|
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
|
|
124
131
|
return { client, space, fn, existingFunctionId };
|
|
125
132
|
};
|
package/src/hooks/format.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { format } from 'prettier';
|
|
|
6
6
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
7
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
8
8
|
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { type Script } from '@dxos/functions';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
@@ -23,12 +24,15 @@ export const createFormat = (script: Script.Script) => {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
try {
|
|
26
|
-
|
|
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);
|
package/src/hooks/template.ts
CHANGED
|
@@ -15,15 +15,21 @@ const createTemplateSelectActions = (script: Script.Script) => {
|
|
|
15
15
|
return createMenuAction<TemplateActionProperties>(
|
|
16
16
|
`template--${template.id}`,
|
|
17
17
|
() => {
|
|
18
|
-
script
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
});
|
|
27
33
|
}
|
|
28
34
|
},
|
|
29
35
|
{
|
package/src/hooks/useCompiler.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useCapabilities, usePluginManager } from '@dxos/app-framework/
|
|
5
|
+
import { useCapabilities, usePluginManager } from '@dxos/app-framework/ui';
|
|
6
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
6
7
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
7
8
|
|
|
8
|
-
import { ScriptCapabilities } from '../capabilities';
|
|
9
9
|
import type { Compiler } from '../compiler';
|
|
10
|
-
import { ScriptEvents } from '../
|
|
10
|
+
import { ScriptEvents } from '../types';
|
|
11
|
+
import { ScriptCapabilities } from '../types';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Asynchronously sets up the compiler and returns it.
|
|
@@ -16,7 +17,7 @@ import { ScriptEvents } from '../events';
|
|
|
16
17
|
export const useCompiler = (): Compiler | undefined => {
|
|
17
18
|
const manager = usePluginManager();
|
|
18
19
|
useAsyncEffect(async () => {
|
|
19
|
-
await manager.activate(ScriptEvents.SetupCompiler);
|
|
20
|
+
await manager.activate(ScriptEvents.SetupCompiler).pipe(runAndForwardErrors);
|
|
20
21
|
}, [manager]);
|
|
21
22
|
const [compiler] = useCapabilities(ScriptCapabilities.Compiler);
|
|
22
23
|
return compiler;
|