@dxos/plugin-script 0.8.4-main.67995b8 → 0.8.4-main.70d3990
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-5TKNGPVR.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-MHY3DXDE.mjs +817 -0
- package/dist/lib/browser/NotebookContainer-MHY3DXDE.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.mjs +148 -0
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-2WR2ATTJ.mjs} +12 -10
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +30 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs +88 -0
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-ALS6X4HU.mjs +304 -0
- package/dist/lib/browser/chunk-ALS6X4HU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-M6KJPUJK.mjs +111 -0
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-N5EYLQOT.mjs} +182 -90
- package/dist/lib/browser/chunk-N5EYLQOT.mjs.map +7 -0
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs +103 -0
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-SAN5Y7FI.mjs} +23 -21
- package/dist/lib/browser/chunk-SAN5Y7FI.mjs.map +7 -0
- package/dist/lib/browser/chunk-ULJFT73Q.mjs +513 -0
- package/dist/lib/browser/chunk-ULJFT73Q.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-4KHRSX7J.mjs} +10 -6
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +112 -53
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-S3H2SMUY.mjs → intent-resolver-TXTBWOVD.mjs} +39 -24
- package/dist/lib/browser/intent-resolver-TXTBWOVD.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-R245YN52.mjs} +45 -21
- package/dist/lib/browser/react-surface-R245YN52.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-MHJXRGDF.mjs} +10 -8
- package/dist/lib/browser/settings-MHJXRGDF.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +8 -4
- package/dist/lib/node-esm/DeploymentDialog-2ULNOZQH.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-2ULNOZQH.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-U4C2HQ4T.mjs +818 -0
- package/dist/lib/node-esm/NotebookContainer-U4C2HQ4T.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.mjs +149 -0
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-NCVLUL5R.mjs} +12 -10
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +31 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs +90 -0
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +113 -0
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-ND4BPYPR.mjs} +23 -21
- package/dist/lib/node-esm/chunk-ND4BPYPR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-UEVZP5DN.mjs} +182 -90
- package/dist/lib/node-esm/chunk-UEVZP5DN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VJSRZRLI.mjs +514 -0
- package/dist/lib/node-esm/chunk-VJSRZRLI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs +305 -0
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs +104 -0
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-DU5NQISX.mjs} +10 -6
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +112 -53
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-OHKNJFCC.mjs → intent-resolver-D6AVAQRA.mjs} +39 -24
- package/dist/lib/node-esm/intent-resolver-D6AVAQRA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-MHT3PJ6C.mjs} +45 -21
- package/dist/lib/node-esm/react-surface-MHT3PJ6C.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-BVJORMMJ.mjs} +10 -8
- package/dist/lib/node-esm/settings-BVJORMMJ.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +8 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +4 -4
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +246 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +10 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +254 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +248 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +4 -4
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +245 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
- 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 +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +20 -17
- 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 +4 -14
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +45 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +43 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +3 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +31 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +54 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +7 -7
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -76
- package/src/ScriptPlugin.tsx +81 -75
- package/src/capabilities/app-graph-builder.ts +12 -11
- package/src/capabilities/artifact-definition.ts +8 -6
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +3 -2
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +21 -12
- package/src/capabilities/react-surface.tsx +33 -19
- package/src/capabilities/settings.ts +3 -3
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +39 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -34
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +5 -4
- package/src/components/NotebookContainer.stories.tsx +83 -0
- package/src/components/NotebookContainer.tsx +260 -0
- package/src/components/NotebookStack/NotebookCell.tsx +216 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +10 -8
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +37 -30
- package/src/components/Settings/ScriptObjectSettings.tsx +130 -38
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestContainer.tsx +4 -3
- package/src/components/TestPanel/TestPanel.tsx +42 -19
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +37 -35
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +24 -24
- package/src/hooks/format.ts +4 -4
- package/src/hooks/template.ts +6 -15
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +11 -6
- package/src/index.ts +1 -0
- package/src/meta.ts +7 -5
- package/src/notebook/compute-graph.test.ts +70 -0
- package/src/notebook/compute-graph.ts +206 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +451 -0
- package/src/templates/chess.ts +3 -1
- package/src/templates/data-generator.ts +9 -3
- package/src/templates/discord.ts +12 -4
- package/src/templates/forex-effect.ts +7 -3
- package/src/templates/forex.ts +3 -1
- package/src/templates/gmail.ts +34 -64
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +35 -7
- package/src/types/Notebook.ts +42 -0
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +29 -46
- package/src/util/functions.ts +39 -8
- package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
- package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs +0 -283
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs +0 -233
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
- package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs +0 -284
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs +0 -234
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -38
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -37
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-5TKNGPVR.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
|
@@ -9,14 +9,19 @@ import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } fr
|
|
|
9
9
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
10
|
import { errorText, mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
13
|
|
|
14
14
|
type State = 'pending' | 'responding';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Request or response.
|
|
18
18
|
*/
|
|
19
|
-
type Message = {
|
|
19
|
+
type Message = {
|
|
20
|
+
type: 'request' | 'response';
|
|
21
|
+
text?: string;
|
|
22
|
+
data?: any;
|
|
23
|
+
error?: Error;
|
|
24
|
+
};
|
|
20
25
|
|
|
21
26
|
export type TestPanelProps = ThemedClassName<{
|
|
22
27
|
functionUrl?: string;
|
|
@@ -24,7 +29,7 @@ export type TestPanelProps = ThemedClassName<{
|
|
|
24
29
|
|
|
25
30
|
// TODO(burdon): Need persistent history (currently lost when switching tabs)..
|
|
26
31
|
export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
27
|
-
const { t } = useTranslation(
|
|
32
|
+
const { t } = useTranslation(meta.id);
|
|
28
33
|
|
|
29
34
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
30
35
|
const [input, setInput] = useState('');
|
|
@@ -41,7 +46,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
41
46
|
}
|
|
42
47
|
};
|
|
43
48
|
|
|
44
|
-
const controller = useRef<AbortController>();
|
|
49
|
+
const controller = useRef<AbortController>(null);
|
|
45
50
|
useEffect(() => {
|
|
46
51
|
return () => {
|
|
47
52
|
handleStop();
|
|
@@ -50,7 +55,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
50
55
|
|
|
51
56
|
const handleStop = () => {
|
|
52
57
|
controller.current?.abort('stop');
|
|
53
|
-
controller.current =
|
|
58
|
+
controller.current = null;
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
const handleClear = () => {
|
|
@@ -61,8 +66,16 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
61
66
|
inputRef.current?.focus();
|
|
62
67
|
};
|
|
63
68
|
|
|
64
|
-
const handleResponse = ({
|
|
65
|
-
|
|
69
|
+
const handleResponse = ({
|
|
70
|
+
text,
|
|
71
|
+
data,
|
|
72
|
+
error,
|
|
73
|
+
}: {
|
|
74
|
+
text?: string;
|
|
75
|
+
data?: any;
|
|
76
|
+
error?: Error;
|
|
77
|
+
} = {}) => {
|
|
78
|
+
controller.current = null;
|
|
66
79
|
setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);
|
|
67
80
|
setResult('');
|
|
68
81
|
setState(null);
|
|
@@ -108,7 +121,9 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
108
121
|
// Check for error.
|
|
109
122
|
if (!response.ok) {
|
|
110
123
|
const text = await response.text();
|
|
111
|
-
handleResponse({
|
|
124
|
+
handleResponse({
|
|
125
|
+
error: new Error(text || response.statusText || String(response.status)),
|
|
126
|
+
});
|
|
112
127
|
return;
|
|
113
128
|
}
|
|
114
129
|
|
|
@@ -159,11 +174,11 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
159
174
|
};
|
|
160
175
|
|
|
161
176
|
return (
|
|
162
|
-
<div className={mx('flex flex-col
|
|
177
|
+
<div className={mx('flex flex-col bs-full overflow-hidden', classNames)}>
|
|
163
178
|
{/* TODO(burdon): Replace with Thread. */}
|
|
164
179
|
<MessageThread ref={scrollerRef} state={state} result={result} history={history} />
|
|
165
180
|
{/* TODO(burdon): Replace with Form based on the function's input schema. */}
|
|
166
|
-
<Toolbar.Root
|
|
181
|
+
<Toolbar.Root>
|
|
167
182
|
<Input.Root>
|
|
168
183
|
<Input.TextInput
|
|
169
184
|
ref={inputRef}
|
|
@@ -174,12 +189,20 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
174
189
|
onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}
|
|
175
190
|
/>
|
|
176
191
|
</Input.Root>
|
|
177
|
-
<Toolbar.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
<Toolbar.IconButton
|
|
193
|
+
icon='ph--play--regular'
|
|
194
|
+
size={4}
|
|
195
|
+
label='Execute'
|
|
196
|
+
iconOnly
|
|
197
|
+
onClick={() => handleRequest(input)}
|
|
198
|
+
/>
|
|
199
|
+
<Toolbar.IconButton
|
|
200
|
+
icon={state ? 'ph--stop--regular' : 'ph--trash--regular'}
|
|
201
|
+
size={4}
|
|
202
|
+
label={state ? 'Stop' : 'Clear'}
|
|
203
|
+
iconOnly
|
|
204
|
+
onClick={() => (state ? handleStop() : handleClear())}
|
|
205
|
+
/>
|
|
183
206
|
</Toolbar.Root>
|
|
184
207
|
</div>
|
|
185
208
|
);
|
|
@@ -196,7 +219,7 @@ type MessageThreadProps = {
|
|
|
196
219
|
const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
197
220
|
({ state, history, result }: MessageThreadProps, forwardedRef) => {
|
|
198
221
|
return (
|
|
199
|
-
<div ref={forwardedRef} className='flex flex-col gap-6
|
|
222
|
+
<div ref={forwardedRef} className='flex flex-col gap-6 bs-full p-2 overflow-x-hidden overflow-y-auto'>
|
|
200
223
|
{history.map((message, i) => (
|
|
201
224
|
<div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
202
225
|
<div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
|
|
@@ -225,7 +248,7 @@ const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
|
225
248
|
|
|
226
249
|
const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {
|
|
227
250
|
const { type, text, data, error } = message;
|
|
228
|
-
const wrapper = 'p-1
|
|
251
|
+
const wrapper = 'p-1 pli-2 rounded-md bg-hoverSurface overflow-auto';
|
|
229
252
|
return (
|
|
230
253
|
<div className={mx('flex', type === 'request' ? 'ml-[1rem] justify-end' : 'mr-[1rem]', classNames)}>
|
|
231
254
|
{error && <div className={mx(wrapper, 'whitespace-pre', errorText)}>{String(error)}</div>}
|
|
@@ -237,7 +260,7 @@ const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message
|
|
|
237
260
|
)}
|
|
238
261
|
|
|
239
262
|
{data && (
|
|
240
|
-
<SyntaxHighlighter language='json' className={mx(wrapper, '
|
|
263
|
+
<SyntaxHighlighter language='json' className={mx(wrapper, 'text-xs')}>
|
|
241
264
|
{JSON.stringify(data, null, 2)}
|
|
242
265
|
</SyntaxHighlighter>
|
|
243
266
|
)}
|
|
@@ -2,43 +2,91 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import {
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
|
+
import { createObject } from '@dxos/react-client/echo';
|
|
10
|
+
import { Toolbar } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
12
|
import { createDataExtensions } from '@dxos/react-ui-editor';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
14
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
18
|
+
|
|
19
|
+
const SCRIPT = trim`
|
|
20
|
+
x * 2
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const DefaultStory = (props: TypescriptEditorProps) => {
|
|
24
|
+
const object = useMemo(() => createObject({ content: SCRIPT }), []);
|
|
25
|
+
const [result, setResult] = useState<object | undefined>({});
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Make this work.
|
|
28
|
+
// const object = useMemo(() => Text.make(templates[1].source), []);
|
|
29
|
+
// const script = useMemo(
|
|
30
|
+
// () =>
|
|
31
|
+
// Obj.make(ScriptType, {
|
|
32
|
+
// source: Ref.make(createObject({ content: templates[0].source })),
|
|
33
|
+
// }),
|
|
34
|
+
// [object],
|
|
35
|
+
// );
|
|
36
|
+
|
|
37
|
+
const extensions = useMemo(
|
|
38
|
+
() => [createDataExtensions({ id: object.id, text: createDocAccessor(object, ['content']) })],
|
|
39
|
+
[],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const handleRun = useCallback(async () => {
|
|
43
|
+
try {
|
|
44
|
+
const definitions: [string, any][] = [['x', 100]];
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
47
|
+
const result = new Function(...definitions.map(([name]) => name), `return ${object.content.trim()}`)(
|
|
48
|
+
...definitions.map(([, value]) => value),
|
|
49
|
+
);
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
setResult({
|
|
52
|
+
timestamp: Date.now(),
|
|
53
|
+
result,
|
|
54
|
+
});
|
|
55
|
+
} catch (err) {
|
|
56
|
+
setResult({
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
error: String(err),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [object]);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<StackItem.Content toolbar>
|
|
65
|
+
{/* <ScriptToolbar script={script} state={{}} /> */}
|
|
66
|
+
<Toolbar.Root>
|
|
67
|
+
<Toolbar.Button onClick={handleRun}>Run</Toolbar.Button>
|
|
68
|
+
</Toolbar.Root>
|
|
69
|
+
<div role='none' className='grid grid-rows-[1fr_min-content] bs-full overflow-hidden text-sm'>
|
|
70
|
+
<TypescriptEditor {...props} initialValue={object.content} extensions={extensions} />
|
|
71
|
+
<Json data={result} classNames='shrink-0 p-2 border-t border-subduedSeparator' />
|
|
72
|
+
</div>
|
|
73
|
+
</StackItem.Content>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const meta = {
|
|
38
78
|
title: 'plugins/plugin-script/TypescriptEditor',
|
|
39
79
|
component: TypescriptEditor,
|
|
40
80
|
render: DefaultStory,
|
|
41
|
-
decorators: [withTheme],
|
|
42
|
-
}
|
|
81
|
+
decorators: [withTheme, withLayout({ container: 'column', classNames: 'is-prose' })],
|
|
82
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
43
83
|
|
|
44
84
|
export default meta;
|
|
85
|
+
|
|
86
|
+
type Story = StoryObj<typeof meta>;
|
|
87
|
+
|
|
88
|
+
export const Default: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
id: 'test',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { autocompletion, completionKeymap } from '@codemirror/autocomplete';
|
|
5
6
|
import { javascript } from '@codemirror/lang-javascript';
|
|
6
|
-
import {
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
8
|
import { lintKeymap } from '@codemirror/lint';
|
|
8
9
|
import { Prec } from '@codemirror/state';
|
|
9
|
-
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
|
|
10
10
|
import { keymap } from '@codemirror/view';
|
|
11
11
|
import { tags } from '@lezer/highlight';
|
|
12
12
|
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
13
13
|
import { continueKeymap } from '@valtown/codemirror-continue';
|
|
14
|
-
import {
|
|
14
|
+
import { type HoverInfo, tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from '@valtown/codemirror-ts';
|
|
15
15
|
import React from 'react';
|
|
16
16
|
|
|
17
|
-
import { type
|
|
17
|
+
import { Domino, type ThemeMode, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
18
18
|
import {
|
|
19
|
+
type BasicExtensionsOptions,
|
|
19
20
|
type EditorInputMode,
|
|
20
21
|
InputModeExtensions,
|
|
21
22
|
type UseTextEditorProps,
|
|
22
|
-
autocomplete,
|
|
23
23
|
createBasicExtensions,
|
|
24
24
|
createThemeExtensions,
|
|
25
|
-
|
|
25
|
+
defaultStyles,
|
|
26
26
|
useTextEditor,
|
|
27
27
|
} from '@dxos/react-ui-editor';
|
|
28
28
|
import { mx } from '@dxos/react-ui-theme';
|
|
@@ -31,18 +31,21 @@ import { isNonNullable } from '@dxos/util';
|
|
|
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
42
|
export const TypescriptEditor = ({
|
|
41
43
|
classNames,
|
|
42
44
|
id,
|
|
45
|
+
role = 'article',
|
|
43
46
|
inputMode = 'vscode',
|
|
44
|
-
toolbar,
|
|
45
47
|
env,
|
|
48
|
+
options,
|
|
46
49
|
initialValue,
|
|
47
50
|
extensions,
|
|
48
51
|
scrollTo,
|
|
@@ -62,20 +65,26 @@ export const TypescriptEditor = ({
|
|
|
62
65
|
indentWithTab: true,
|
|
63
66
|
lineNumbers: true,
|
|
64
67
|
lineWrapping: false,
|
|
68
|
+
scrollPastEnd: role !== 'section',
|
|
69
|
+
search: true,
|
|
70
|
+
...options,
|
|
71
|
+
}),
|
|
72
|
+
createThemeExtensions({
|
|
65
73
|
monospace: true,
|
|
66
|
-
|
|
74
|
+
themeMode,
|
|
75
|
+
syntaxHighlighting: true,
|
|
67
76
|
}),
|
|
68
|
-
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
69
77
|
InputModeExtensions[inputMode],
|
|
70
|
-
|
|
78
|
+
|
|
79
|
+
javascript({ typescript: true }),
|
|
80
|
+
autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
|
|
81
|
+
|
|
71
82
|
// Continues block comments when pressing Enter.
|
|
72
83
|
Prec.high(keymap.of(continueKeymap)),
|
|
84
|
+
keymap.of(completionKeymap),
|
|
85
|
+
keymap.of(lintKeymap),
|
|
73
86
|
|
|
74
|
-
// TODO(burdon): Factor out.
|
|
75
|
-
javascript({ typescript: true }),
|
|
76
87
|
// https://github.com/val-town/codemirror-ts
|
|
77
|
-
autocomplete({ override: env ? [tsAutocomplete()] : undefined }),
|
|
78
|
-
keymap.of(lintKeymap),
|
|
79
88
|
env && [
|
|
80
89
|
tsFacet.of({ env, path: `/src/${id}.ts` }),
|
|
81
90
|
tsSync(),
|
|
@@ -87,18 +96,13 @@ export const TypescriptEditor = ({
|
|
|
87
96
|
[id, extensions, themeMode, inputMode, selection, scrollTo],
|
|
88
97
|
);
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ref={parentRef}
|
|
93
|
-
data-toolbar={toolbar ? 'enabled' : 'disabled'}
|
|
94
|
-
className={mx(classNames)}
|
|
95
|
-
{...focusAttributes}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
99
|
+
// TODO(brudon): Use react-ui-editor's Editor component.
|
|
100
|
+
return <div ref={parentRef} className={mx(classNames)} {...focusAttributes} />;
|
|
98
101
|
};
|
|
99
102
|
|
|
103
|
+
// TODO(burdon): Factor out (react-ui-editor).
|
|
100
104
|
const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
101
|
-
const theme = themeMode === 'dark' ?
|
|
105
|
+
const theme = HighlightStyle.define(themeMode === 'dark' ? defaultStyles.dark : defaultStyles.light);
|
|
102
106
|
|
|
103
107
|
const classFromKind = (_kind: string) => {
|
|
104
108
|
// E.g., localName, methodName, parameterName, etc.
|
|
@@ -117,18 +121,16 @@ const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
|
117
121
|
};
|
|
118
122
|
|
|
119
123
|
return (info: HoverInfo) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return { dom: div };
|
|
124
|
+
return {
|
|
125
|
+
dom: Domino.of('div')
|
|
126
|
+
.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
|
+
};
|
|
132
134
|
};
|
|
133
135
|
};
|
|
134
136
|
|
package/src/components/index.ts
CHANGED
|
@@ -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'));
|
package/src/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { defineEvent } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export namespace ScriptEvents {
|
|
10
|
-
export const SetupCompiler = defineEvent(`${
|
|
10
|
+
export const SetupCompiler = defineEvent(`${meta.id}/event/setup-compiler`);
|
|
11
11
|
}
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
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 {
|
|
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
14
|
import { errorMessageColors } from '@dxos/react-ui-theme';
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
+
import { meta } from '../meta';
|
|
16
17
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
17
18
|
|
|
18
19
|
export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
|
|
@@ -26,18 +27,18 @@ export type DeployState = {
|
|
|
26
27
|
|
|
27
28
|
export type CreateDeployOptions = {
|
|
28
29
|
state: Partial<DeployState>;
|
|
29
|
-
script:
|
|
30
|
-
fn:
|
|
30
|
+
script: Script.Script;
|
|
31
|
+
fn: Function.Function;
|
|
31
32
|
space?: Space;
|
|
32
|
-
|
|
33
|
+
existingFunctionId?: string;
|
|
33
34
|
client: Client;
|
|
34
35
|
t: TFunction;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export const createDeploy = ({ state, script, space, fn, client,
|
|
38
|
+
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
38
39
|
// TODO(wittjosiah): Should this be an action?
|
|
39
40
|
const errorItem = createMenuAction('error', () => {}, {
|
|
40
|
-
label: state.error ?? ['no error label', { ns:
|
|
41
|
+
label: state.error ?? ['no error label', { ns: meta.id }],
|
|
41
42
|
icon: 'ph--warning-circle--regular',
|
|
42
43
|
hidden: !state.error,
|
|
43
44
|
classNames: state.error && errorMessageColors,
|
|
@@ -53,7 +54,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
53
54
|
state.error = undefined;
|
|
54
55
|
state.deploying = true;
|
|
55
56
|
|
|
56
|
-
const result = await deployScript({ script, client, space, fn,
|
|
57
|
+
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
57
58
|
|
|
58
59
|
if (!result.success) {
|
|
59
60
|
log.catch(result.error);
|
|
@@ -64,7 +65,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
type: 'deploy',
|
|
67
|
-
label: [state.deploying ? '
|
|
68
|
+
label: [state.deploying ? 'publishing label' : 'deploy label', { ns: meta.id }],
|
|
68
69
|
icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
69
70
|
disabled: state.deploying,
|
|
70
71
|
classNames: state.deploying ? '[&_svg]:animate-spin' : '',
|
|
@@ -74,14 +75,13 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
74
75
|
const copyAction = createMenuAction<DeployActionProperties>(
|
|
75
76
|
'copy',
|
|
76
77
|
async () => {
|
|
77
|
-
if (
|
|
78
|
-
|
|
78
|
+
if (state.functionUrl) {
|
|
79
|
+
await navigator.clipboard.writeText(state.functionUrl);
|
|
79
80
|
}
|
|
80
|
-
await navigator.clipboard.writeText(state.functionUrl);
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
type: 'copy',
|
|
84
|
-
label: ['copy link label', { ns:
|
|
84
|
+
label: ['copy link label', { ns: meta.id }],
|
|
85
85
|
icon: 'ph--link--regular',
|
|
86
86
|
disabled: !state.functionUrl,
|
|
87
87
|
},
|
|
@@ -97,10 +97,10 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script:
|
|
101
|
-
const { space, client, fn,
|
|
100
|
+
export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script: Script.Script }) => {
|
|
101
|
+
const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
102
102
|
useEffect(() => {
|
|
103
|
-
if (!
|
|
103
|
+
if (!existingFunctionId) {
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -109,17 +109,17 @@ export const useDeployState = ({ state, script }: { state: Partial<DeployState>;
|
|
|
109
109
|
fn,
|
|
110
110
|
edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
|
|
111
111
|
});
|
|
112
|
-
}, [
|
|
112
|
+
}, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
|
|
113
113
|
|
|
114
114
|
useEffect(() => {
|
|
115
115
|
state.deployed = isScriptDeployed({ script, fn });
|
|
116
|
-
}, [script.changed,
|
|
116
|
+
}, [script.changed, existingFunctionId, fn, script]);
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
export const useDeployDeps = ({ script }: { script:
|
|
120
|
-
const space = getSpace(script);
|
|
121
|
-
const [fn] = useQuery(space, Query.type(FunctionType, { source: Ref.make(script) }));
|
|
119
|
+
export const useDeployDeps = ({ script }: { script: Script.Script }) => {
|
|
122
120
|
const client = useClient();
|
|
123
|
-
const
|
|
124
|
-
|
|
121
|
+
const space = getSpace(script);
|
|
122
|
+
const [fn] = useQuery(space, Query.type(Function.Function, { source: Ref.make(script) }));
|
|
123
|
+
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
|
|
124
|
+
return { client, space, fn, existingFunctionId };
|
|
125
125
|
};
|
package/src/hooks/format.ts
CHANGED
|
@@ -6,15 +6,15 @@ 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
|
|
9
|
+
import { type Script } from '@dxos/functions';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../meta';
|
|
14
14
|
|
|
15
15
|
export type FormatActionProperties = { type: 'format' };
|
|
16
16
|
|
|
17
|
-
export const createFormat = (script:
|
|
17
|
+
export const createFormat = (script: Script.Script) => {
|
|
18
18
|
const formatAction = createMenuAction(
|
|
19
19
|
'format',
|
|
20
20
|
async () => {
|
|
@@ -35,7 +35,7 @@ export const createFormat = (script: ScriptType) => {
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
label: ['format label', { ns:
|
|
38
|
+
label: ['format label', { ns: meta.id }],
|
|
39
39
|
icon: 'ph--magic-wand--regular',
|
|
40
40
|
},
|
|
41
41
|
);
|
package/src/hooks/template.ts
CHANGED
|
@@ -3,22 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Obj } from '@dxos/echo';
|
|
6
|
-
import { FUNCTIONS_PRESET_META_KEY, type
|
|
7
|
-
import {
|
|
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
|
|
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}`,
|
|
@@ -30,7 +22,7 @@ const createTemplateSelectActions = (script: ScriptType) => {
|
|
|
30
22
|
if (oldPresetIndex >= 0) {
|
|
31
23
|
metaKeys.splice(oldPresetIndex, 1);
|
|
32
24
|
}
|
|
33
|
-
if (template
|
|
25
|
+
if ('presetId' in template) {
|
|
34
26
|
metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
35
27
|
}
|
|
36
28
|
},
|
|
@@ -43,11 +35,10 @@ const createTemplateSelectActions = (script: ScriptType) => {
|
|
|
43
35
|
});
|
|
44
36
|
};
|
|
45
37
|
|
|
46
|
-
export const createTemplateSelect = (script:
|
|
47
|
-
const templateSelectGroup = createTemplateSelectGroup();
|
|
38
|
+
export const createTemplateSelect = (script: Script.Script) => {
|
|
48
39
|
const templateSelectActions = createTemplateSelectActions(script);
|
|
49
40
|
return {
|
|
50
|
-
nodes: [
|
|
41
|
+
nodes: [...templateSelectActions],
|
|
51
42
|
edges: [
|
|
52
43
|
{ source: 'root', target: 'template-select' },
|
|
53
44
|
...templateSelectActions.map((action) => ({ source: 'template-select', target: action.id })),
|