@dxos/plugin-script 0.8.4-main.2e9d522 → 0.8.4-main.406dc2a
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-65TWT6S5.mjs +13 -0
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs +683 -0
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-DPYULSME.mjs} +9 -8
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +28 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +7 -0
- package/dist/lib/browser/chunk-5CYLWXRH.mjs +89 -0
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +7 -0
- package/dist/lib/browser/chunk-75LH4EUR.mjs +326 -0
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-E7DXDICD.mjs} +29 -30
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EZVXV6DA.mjs} +3 -5
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-I3QSGUFJ.mjs} +159 -68
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-JO2O7W6J.mjs} +71 -50
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +7 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs +112 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-NM4WQS4F.mjs} +15 -15
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-OKXN2N7M.mjs} +2 -2
- package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-G2N2CG63.mjs} +24 -8
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +109 -39
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-7B77IG3N.mjs → intent-resolver-JLU7DVLQ.mjs} +33 -19
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-76SDTUYG.mjs} +36 -13
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-ERFKVNUK.mjs} +9 -8
- package/dist/lib/browser/settings-ERFKVNUK.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs → DeploymentDialog-I63ZC2HH.mjs} +6 -5
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs +684 -0
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-UXJGHXSL.mjs} +9 -8
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +30 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs +90 -0
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4X375PGY.mjs +90 -0
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs +327 -0
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-C2ORIPKH.mjs} +15 -15
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-NUXZQQ6P.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-OG2SIKHE.mjs} +3 -5
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-SMFPSKQT.mjs} +159 -68
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +114 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-VZAFGLD7.mjs} +29 -30
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-YW36TZ7K.mjs} +71 -50
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-PLDAZ5GJ.mjs} +24 -8
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +109 -39
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-FRZGS4TB.mjs → intent-resolver-SFGTIFOG.mjs} +33 -19
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-SHEBNW4R.mjs} +36 -13
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-5TYXQ42N.mjs} +9 -8
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +7 -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 +2 -2
- 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.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 +248 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +14 -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 +2 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- 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.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.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 +11 -10
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- 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/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/notebook.d.ts +35 -0
- package/dist/types/src/notebook/notebook.d.ts.map +1 -0
- package/dist/types/src/notebook/notebook.test.d.ts +2 -0
- package/dist/types/src/notebook/notebook.test.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 +19 -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 +28 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/actions.d.ts +66 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +54 -31
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +3 -3
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +5 -2
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +76 -69
- package/src/ScriptPlugin.tsx +93 -70
- package/src/capabilities/app-graph-builder.ts +6 -5
- package/src/capabilities/artifact-definition.ts +8 -12
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +2 -1
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +16 -9
- package/src/capabilities/react-surface.tsx +20 -7
- package/src/capabilities/settings.ts +3 -3
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +34 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +3 -2
- package/src/components/NotebookContainer.stories.tsx +32 -0
- package/src/components/NotebookContainer.tsx +124 -0
- package/src/components/NotebookStack/NotebookCell.tsx +217 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +32 -0
- package/src/components/NotebookStack/NotebookStack.tsx +79 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +4 -3
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -23
- package/src/components/Settings/ScriptObjectSettings.tsx +111 -31
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestContainer.tsx +2 -1
- package/src/components/TestPanel/TestPanel.tsx +6 -6
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +32 -25
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +18 -19
- package/src/hooks/format.ts +2 -2
- package/src/hooks/template.ts +5 -4
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +4 -3
- package/src/index.ts +1 -0
- package/src/meta.ts +2 -4
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/notebook.test.ts +70 -0
- package/src/notebook/notebook.ts +183 -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 +33 -62
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +47 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +31 -4
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +1 -0
- package/src/types/schema.ts +30 -19
- package/src/util/deploy.ts +20 -33
- package/src/util/functions.ts +35 -6
- 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-24Q3IHOU.mjs +0 -249
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs.map +0 -7
- 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.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-7B77IG3N.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/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-WAJFALUI.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.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.map +0 -7
- 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-FRZGS4TB.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/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-65TWT6S5.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-OKXN2N7M.mjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs.map → DeploymentDialog-I63ZC2HH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-NUXZQQ6P.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { DropdownMenu, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { Stack, StackItem, type StackProps } from '@dxos/react-ui-stack';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
|
+
import { type Notebook } from '../../types';
|
|
12
|
+
import { type TypescriptEditorProps } from '../TypescriptEditor';
|
|
13
|
+
|
|
14
|
+
import { NotebookCell, type NotebookCellProps } from './NotebookCell';
|
|
15
|
+
import { NotebookMenu } from './NotebookMenu';
|
|
16
|
+
|
|
17
|
+
const minSectionHeight = 'min-bs-[16rem]';
|
|
18
|
+
|
|
19
|
+
export type NotebookStackProps = ThemedClassName<
|
|
20
|
+
{
|
|
21
|
+
notebook?: Notebook.Notebook;
|
|
22
|
+
onRearrange?: StackProps['onRearrange'];
|
|
23
|
+
} & (Pick<NotebookSectionProps, 'space' | 'graph' | 'onCellInsert' | 'onCellDelete'> &
|
|
24
|
+
Pick<TypescriptEditorProps, 'env'>)
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Option for narrow rail (with compact buttons that align with first button in toolbar).
|
|
28
|
+
export const NotebookStack = ({ classNames, notebook, onRearrange, ...props }: NotebookStackProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Stack classNames={classNames} orientation='vertical' size='contain' rail onRearrange={onRearrange}>
|
|
31
|
+
{notebook?.cells.map((cell, i) => (
|
|
32
|
+
<NotebookSection key={i} cell={cell} {...props} />
|
|
33
|
+
))}
|
|
34
|
+
</Stack>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type NotebookSectionProps = NotebookCellProps;
|
|
39
|
+
|
|
40
|
+
const NotebookSection = ({ cell, space, env, onCellInsert, onCellDelete, ...props }: NotebookSectionProps) => {
|
|
41
|
+
const { t } = useTranslation(meta.id);
|
|
42
|
+
const resizable = cell.type === 'query' || cell.type === 'prompt';
|
|
43
|
+
|
|
44
|
+
// TOOD(burdon): Set size if no extrinsic size (provider).
|
|
45
|
+
return (
|
|
46
|
+
<StackItem.Root role='section' item={cell} draggable classNames={resizable && minSectionHeight}>
|
|
47
|
+
<StackItem.Heading classNames='bs-full p-1 justify-between attention-surface'>
|
|
48
|
+
<StackItem.DragHandle asChild>
|
|
49
|
+
<IconButton variant='ghost' icon='ph--dots-six-vertical--regular' iconOnly label='Drag handle' />
|
|
50
|
+
</StackItem.DragHandle>
|
|
51
|
+
<DropdownMenu.Root>
|
|
52
|
+
<DropdownMenu.Trigger asChild>
|
|
53
|
+
<IconButton
|
|
54
|
+
variant='ghost'
|
|
55
|
+
icon='ph--dots-three--regular'
|
|
56
|
+
iconOnly
|
|
57
|
+
label={t('notebook cell insert label')}
|
|
58
|
+
/>
|
|
59
|
+
</DropdownMenu.Trigger>
|
|
60
|
+
<NotebookMenu cell={cell} onCellInsert={onCellInsert} onCellDelete={onCellDelete} />
|
|
61
|
+
</DropdownMenu.Root>
|
|
62
|
+
{resizable && <StackItem.ResizeHandle />}
|
|
63
|
+
</StackItem.Heading>
|
|
64
|
+
|
|
65
|
+
{/* TODO(burdon): Move drag preview to outer stack (uniformly). */}
|
|
66
|
+
<StackItem.DragPreview>
|
|
67
|
+
{({ item: cell }) => (
|
|
68
|
+
<StackItem.Content classNames='overflow-visible bg-groupSurface border border-subduedSeparator'>
|
|
69
|
+
<NotebookCell space={space} cell={cell} env={env} dragging />
|
|
70
|
+
</StackItem.Content>
|
|
71
|
+
)}
|
|
72
|
+
</StackItem.DragPreview>
|
|
73
|
+
|
|
74
|
+
<StackItem.Content classNames='overflow-visible'>
|
|
75
|
+
<NotebookCell space={space} cell={cell} env={env} {...props} />
|
|
76
|
+
</StackItem.Content>
|
|
77
|
+
</StackItem.Root>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -10,15 +10,16 @@ import { useIdentity } from '@dxos/react-client/halo';
|
|
|
10
10
|
import { createDataExtensions, listener, stackItemContentEditorClassNames } from '@dxos/react-ui-editor';
|
|
11
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
12
|
|
|
13
|
+
import { useDeployState, useToolbarState } from '../hooks';
|
|
14
|
+
import { type ScriptSettings } from '../types';
|
|
15
|
+
|
|
13
16
|
import { ScriptToolbar } from './ScriptToolbar';
|
|
14
17
|
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
15
|
-
import { useDeployState, useToolbarState } from '../hooks';
|
|
16
|
-
import { type ScriptSettingsProps } from '../types';
|
|
17
18
|
|
|
18
19
|
export type ScriptEditorProps = {
|
|
19
20
|
role: string;
|
|
20
21
|
script: ScriptType;
|
|
21
|
-
settings?:
|
|
22
|
+
settings?: ScriptSettings;
|
|
22
23
|
} & Pick<TypescriptEditorProps, 'env'>;
|
|
23
24
|
|
|
24
25
|
export const ScriptContainer = ({ role, script, settings = { editorInputMode: 'vscode' }, env }: ScriptEditorProps) => {
|
|
@@ -2,29 +2,46 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { ScriptType } from '@dxos/functions';
|
|
11
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { DataType } from '@dxos/schema';
|
|
8
14
|
|
|
9
|
-
import {
|
|
15
|
+
import { translations } from '../../translations';
|
|
10
16
|
|
|
11
17
|
import { ScriptToolbar } from './ScriptToolbar';
|
|
12
|
-
import { templates } from '../../templates';
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
args: {
|
|
16
|
-
binding: 'example',
|
|
17
|
-
deployed: true,
|
|
18
|
-
templates,
|
|
19
|
-
onFormat: () => console.log('Format'),
|
|
20
|
-
onTogglePanel: () => {},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const meta: Meta = {
|
|
19
|
+
const meta = {
|
|
25
20
|
title: 'plugins/plugin-script/Toolbar',
|
|
26
21
|
component: ScriptToolbar,
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
23
|
+
decorators: [
|
|
24
|
+
withTheme,
|
|
25
|
+
withLayout({ classNames: 'is-prose' }),
|
|
26
|
+
withPluginManager({ plugins: [IntentPlugin(), ClientPlugin({})] }),
|
|
27
|
+
],
|
|
28
|
+
parameters: {
|
|
29
|
+
layout: 'centered',
|
|
30
|
+
translations,
|
|
31
|
+
},
|
|
32
|
+
} satisfies Meta<typeof ScriptToolbar>;
|
|
29
33
|
|
|
30
34
|
export default meta;
|
|
35
|
+
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
export const Default: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
state: {},
|
|
41
|
+
script: Obj.make(ScriptType, {
|
|
42
|
+
name: 'test',
|
|
43
|
+
description: 'test',
|
|
44
|
+
source: Ref.make(DataType.makeText('test')),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -7,8 +7,15 @@ import React, { useMemo } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { type ScriptType } from '@dxos/functions';
|
|
9
9
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
|
-
import { ElevationProvider,
|
|
11
|
-
import {
|
|
10
|
+
import { ElevationProvider, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import {
|
|
12
|
+
type ActionGraphProps,
|
|
13
|
+
MenuProvider,
|
|
14
|
+
ToolbarMenu,
|
|
15
|
+
createGapSeparator,
|
|
16
|
+
rxFromSignal,
|
|
17
|
+
useMenuActions,
|
|
18
|
+
} from '@dxos/react-ui-menu';
|
|
12
19
|
|
|
13
20
|
import {
|
|
14
21
|
type CreateDeployOptions,
|
|
@@ -18,23 +25,7 @@ import {
|
|
|
18
25
|
createTemplateSelect,
|
|
19
26
|
useDeployDeps,
|
|
20
27
|
} from '../../hooks';
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
const createToolbar = ({ state, script, ...options }: CreateDeployOptions) =>
|
|
24
|
-
Rx.make((get) =>
|
|
25
|
-
get(
|
|
26
|
-
rxFromSignal(() => {
|
|
27
|
-
const templateSelect = createTemplateSelect(script);
|
|
28
|
-
const format = createFormat(script);
|
|
29
|
-
const gap = createGapSeparator();
|
|
30
|
-
const deploy = createDeploy({ state, script, ...options });
|
|
31
|
-
return {
|
|
32
|
-
nodes: [...templateSelect.nodes, ...format.nodes, ...gap.nodes, ...deploy.nodes],
|
|
33
|
-
edges: [...templateSelect.edges, ...format.edges, ...gap.edges, ...deploy.edges],
|
|
34
|
-
};
|
|
35
|
-
}),
|
|
36
|
-
),
|
|
37
|
-
);
|
|
28
|
+
import { meta } from '../../meta';
|
|
38
29
|
|
|
39
30
|
export type ScriptToolbarProps = ThemedClassName<{
|
|
40
31
|
role?: string;
|
|
@@ -43,16 +34,32 @@ export type ScriptToolbarProps = ThemedClassName<{
|
|
|
43
34
|
}>;
|
|
44
35
|
|
|
45
36
|
export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbarProps) => {
|
|
46
|
-
const { t } = useTranslation(
|
|
37
|
+
const { t } = useTranslation(meta.id);
|
|
47
38
|
const options = useDeployDeps({ script });
|
|
48
|
-
const
|
|
49
|
-
const
|
|
39
|
+
const menu = useMemo(() => createToolbarActions({ state, script, t, ...options }), [state, script, options, t]);
|
|
40
|
+
const actions = useMenuActions(menu);
|
|
50
41
|
|
|
51
42
|
return (
|
|
52
43
|
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
53
|
-
<MenuProvider {...
|
|
44
|
+
<MenuProvider {...actions} attendableId={fullyQualifiedId(script)}>
|
|
54
45
|
<ToolbarMenu classNames={classNames} />
|
|
55
46
|
</MenuProvider>
|
|
56
47
|
</ElevationProvider>
|
|
57
48
|
);
|
|
58
49
|
};
|
|
50
|
+
|
|
51
|
+
const createToolbarActions = ({ state, script, ...options }: CreateDeployOptions): Rx.Rx<ActionGraphProps> =>
|
|
52
|
+
Rx.make((get) =>
|
|
53
|
+
get(
|
|
54
|
+
rxFromSignal(() => {
|
|
55
|
+
const templateSelect = createTemplateSelect(script);
|
|
56
|
+
const format = createFormat(script);
|
|
57
|
+
const gap = createGapSeparator();
|
|
58
|
+
const deploy = createDeploy({ state, script, ...options });
|
|
59
|
+
return {
|
|
60
|
+
nodes: [...templateSelect.nodes, ...format.nodes, ...gap.nodes, ...deploy.nodes],
|
|
61
|
+
edges: [...templateSelect.edges, ...format.edges, ...gap.edges, ...deploy.edges],
|
|
62
|
+
};
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
);
|
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
|
-
import React, { type ChangeEvent, useCallback,
|
|
6
|
+
import React, { type ChangeEvent, useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ToolId } from '@dxos/ai';
|
|
9
|
+
import { SettingsAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
11
|
+
import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
10
12
|
import { log } from '@dxos/log';
|
|
11
13
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter, getMeta, getSpace,
|
|
13
|
-
import { Button, Clipboard, Input, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import { Filter, Ref, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
15
|
+
import { Button, Clipboard, Input, useAsyncEffect, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
16
|
import { DataType } from '@dxos/schema';
|
|
17
|
+
import { kebabize } from '@dxos/util';
|
|
15
18
|
|
|
16
|
-
import {
|
|
19
|
+
import { meta } from '../../meta';
|
|
17
20
|
|
|
18
21
|
export type ScriptObjectSettingsProps = {
|
|
19
22
|
object: ScriptType;
|
|
@@ -23,13 +26,14 @@ export const ScriptObjectSettings = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
23
26
|
return (
|
|
24
27
|
<>
|
|
25
28
|
<Binding object={object} />
|
|
29
|
+
<BlueprintEditor object={object} />
|
|
26
30
|
<Publishing object={object} />
|
|
27
31
|
</>
|
|
28
32
|
);
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
32
|
-
const { t } = useTranslation(
|
|
36
|
+
const { t } = useTranslation(meta.id);
|
|
33
37
|
return (
|
|
34
38
|
<Input.Root>
|
|
35
39
|
<Input.Label>{t('description label')}</Input.Label>
|
|
@@ -44,16 +48,100 @@ export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
50
|
|
|
51
|
+
const BlueprintEditor = ({ object }: ScriptObjectSettingsProps) => {
|
|
52
|
+
const { t } = useTranslation(meta.id);
|
|
53
|
+
const space = getSpace(object);
|
|
54
|
+
const [fn] = useQuery(space, Filter.type(FunctionType, { source: Ref.make(object) }));
|
|
55
|
+
const blueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
|
|
56
|
+
|
|
57
|
+
const [creating, setCreating] = useState(false);
|
|
58
|
+
const [instructions, setInstructions] = useState<string>(`You can run the script "${object.name ?? 'script'}".`);
|
|
59
|
+
const blueprintKey = `dxos.org/blueprint/${kebabize(object.name ?? 'script')}`;
|
|
60
|
+
const existingBlueprint = blueprints.find((bp) => bp.key === blueprintKey);
|
|
61
|
+
|
|
62
|
+
useAsyncEffect(async () => {
|
|
63
|
+
if (!existingBlueprint) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const source = await existingBlueprint.instructions.source.load();
|
|
67
|
+
setInstructions(source.content ?? '');
|
|
68
|
+
}, [existingBlueprint]);
|
|
69
|
+
|
|
70
|
+
const handleSave = useCallback(async () => {
|
|
71
|
+
if (!space) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setCreating(true);
|
|
76
|
+
try {
|
|
77
|
+
if (existingBlueprint) {
|
|
78
|
+
const text = await existingBlueprint.instructions.source.load();
|
|
79
|
+
text.content = instructions;
|
|
80
|
+
if (fn?.key) {
|
|
81
|
+
const toolId = ToolId.make(fn.key);
|
|
82
|
+
if (!existingBlueprint.tools?.includes(toolId)) {
|
|
83
|
+
existingBlueprint.tools = [...(existingBlueprint.tools ?? []), toolId];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else if (fn?.key) {
|
|
87
|
+
space.db.add(
|
|
88
|
+
Blueprint.make({
|
|
89
|
+
key: blueprintKey,
|
|
90
|
+
name: object.name ?? 'Script',
|
|
91
|
+
instructions: Template.make({
|
|
92
|
+
source: instructions,
|
|
93
|
+
}),
|
|
94
|
+
tools: [ToolId.make(fn.key)],
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
await space.db.flush();
|
|
99
|
+
} finally {
|
|
100
|
+
setCreating(false);
|
|
101
|
+
}
|
|
102
|
+
}, [space, existingBlueprint, fn, blueprintKey, object.name, instructions]);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div className='flex flex-col gap-4 mlb-cardSpacingBlock'>
|
|
106
|
+
<div>
|
|
107
|
+
<h2>{t('blueprint editor label', { default: 'Blueprint' })}</h2>
|
|
108
|
+
<p className='text-description text-sm'>
|
|
109
|
+
{t('blueprint editor description', { default: 'Create a blueprint that exposes this script as a tool.' })}
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
<Input.Root>
|
|
113
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
114
|
+
<Input.Label>{t('blueprint instructions label', { default: 'Instructions' })}</Input.Label>
|
|
115
|
+
<Input.TextArea
|
|
116
|
+
placeholder={t('blueprint instructions placeholder', { default: 'Describe how this tool should be used.' })}
|
|
117
|
+
rows={6}
|
|
118
|
+
value={instructions}
|
|
119
|
+
onChange={(event) => setInstructions(event.target.value)}
|
|
120
|
+
classNames='resize-y'
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</Input.Root>
|
|
124
|
+
<div className='flex justify-end gap-2'>
|
|
125
|
+
<Button disabled={(!existingBlueprint && !fn?.key) || creating} onClick={handleSave}>
|
|
126
|
+
{t(creating ? 'creating label' : 'create blueprint label', {
|
|
127
|
+
default: creating ? 'Creating…' : 'Create blueprint',
|
|
128
|
+
})}
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
47
135
|
const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
48
|
-
const { t } = useTranslation(
|
|
136
|
+
const { t } = useTranslation(meta.id);
|
|
49
137
|
const client = useClient();
|
|
50
138
|
const space = getSpace(object);
|
|
51
139
|
const [fn] = useQuery(space, Filter.type(FunctionType, { source: Ref.make(object) }));
|
|
52
140
|
|
|
53
|
-
const
|
|
141
|
+
const functionId = fn && getUserFunctionIdInMetadata(getMeta(fn));
|
|
54
142
|
const functionUrl =
|
|
55
|
-
|
|
56
|
-
getInvocationUrl(
|
|
143
|
+
functionId &&
|
|
144
|
+
getInvocationUrl(functionId, client.config.values.runtime?.services?.edge?.url ?? '', {
|
|
57
145
|
spaceId: space?.id,
|
|
58
146
|
});
|
|
59
147
|
|
|
@@ -109,14 +197,14 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
109
197
|
|
|
110
198
|
// TODO(burdon): Move to separate tab?
|
|
111
199
|
const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
112
|
-
const { t } = useTranslation(
|
|
200
|
+
const { t } = useTranslation(meta.id);
|
|
113
201
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
114
202
|
const space = getSpace(object);
|
|
115
203
|
const [githubToken] = useQuery(space, Filter.type(DataType.AccessToken, { source: 'github.com' }));
|
|
116
204
|
const gistKey = getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
117
205
|
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
118
206
|
|
|
119
|
-
|
|
207
|
+
useAsyncEffect(async () => {
|
|
120
208
|
const token = githubToken?.token;
|
|
121
209
|
const gistId = gistKey?.id;
|
|
122
210
|
if (!token || !gistId) {
|
|
@@ -124,20 +212,16 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
124
212
|
return;
|
|
125
213
|
}
|
|
126
214
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return () => clearTimeout(timeout);
|
|
215
|
+
try {
|
|
216
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
217
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
218
|
+
gist_id: gistId,
|
|
219
|
+
});
|
|
220
|
+
setGistUrl(response.data.html_url);
|
|
221
|
+
} catch (err) {
|
|
222
|
+
log.catch(err);
|
|
223
|
+
setGistUrl(undefined);
|
|
224
|
+
}
|
|
141
225
|
}, [githubToken, gistKey]);
|
|
142
226
|
|
|
143
227
|
const handleOpenTokenManager = useCallback(
|
|
@@ -200,7 +284,3 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
200
284
|
</div>
|
|
201
285
|
);
|
|
202
286
|
};
|
|
203
|
-
|
|
204
|
-
// TODO(wittjosiah): Factor out.
|
|
205
|
-
// From https://stackoverflow.com/a/67243723/2804332
|
|
206
|
-
const kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
|
|
@@ -4,68 +4,58 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
7
|
import { useClient } from '@dxos/react-client';
|
|
9
8
|
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
9
|
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
11
|
-
import {
|
|
10
|
+
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
12
11
|
|
|
13
12
|
import { meta } from '../../meta';
|
|
14
|
-
import { type
|
|
13
|
+
import { type ScriptSettings } from '../../types';
|
|
14
|
+
import { getAccessCredential } from '../../util';
|
|
15
15
|
|
|
16
|
-
export const ScriptPluginSettings = ({ settings }: { settings:
|
|
16
|
+
export const ScriptPluginSettings = ({ settings }: { settings: ScriptSettings }) => {
|
|
17
17
|
const { t } = useTranslation(meta.id);
|
|
18
18
|
const client = useClient();
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Check token.
|
|
21
21
|
const handleAuthenticate = async () => {
|
|
22
22
|
const { identityKey } = client.halo.identity.get()!;
|
|
23
|
-
await client.halo.writeCredentials([
|
|
24
|
-
{
|
|
25
|
-
issuer: identityKey,
|
|
26
|
-
issuanceDate: new Date(),
|
|
27
|
-
subject: {
|
|
28
|
-
id: identityKey,
|
|
29
|
-
assertion: {
|
|
30
|
-
'@type': 'dxos.halo.credentials.ServiceAccess',
|
|
31
|
-
serverName: 'hub.dxos.network',
|
|
32
|
-
serverKey: identityKey,
|
|
33
|
-
identityKey,
|
|
34
|
-
capabilities: ['composer:beta'],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
} satisfies Credential,
|
|
38
|
-
]);
|
|
23
|
+
await client.halo.writeCredentials([getAccessCredential(identityKey)]);
|
|
39
24
|
};
|
|
40
25
|
|
|
41
26
|
return (
|
|
42
|
-
<
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
<ControlPage>
|
|
28
|
+
<ControlSection title={t('settings title', { ns: meta.id })}>
|
|
29
|
+
<ControlGroup>
|
|
30
|
+
{/* TODO(wittjosiah): Hide outside of dev environments. */}
|
|
31
|
+
<ControlItemInput title={t('authenticate action label')}>
|
|
32
|
+
<Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>
|
|
33
|
+
</ControlItemInput>
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
35
|
+
<ControlItemInput title={t('editor input mode label')}>
|
|
36
|
+
<Select.Root
|
|
37
|
+
value={settings.editorInputMode ?? 'default'}
|
|
38
|
+
onValueChange={(value) => {
|
|
39
|
+
settings.editorInputMode = value as EditorInputMode;
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
|
|
43
|
+
<Select.Portal>
|
|
44
|
+
<Select.Content>
|
|
45
|
+
<Select.Viewport>
|
|
46
|
+
{EditorInputModes.map((mode) => (
|
|
47
|
+
<Select.Option key={mode} value={mode}>
|
|
48
|
+
{t(`settings editor input mode ${mode} label`)}
|
|
49
|
+
</Select.Option>
|
|
50
|
+
))}
|
|
51
|
+
</Select.Viewport>
|
|
52
|
+
<Select.Arrow />
|
|
53
|
+
</Select.Content>
|
|
54
|
+
</Select.Portal>
|
|
55
|
+
</Select.Root>
|
|
56
|
+
</ControlItemInput>
|
|
57
|
+
</ControlGroup>
|
|
58
|
+
</ControlSection>
|
|
59
|
+
</ControlPage>
|
|
70
60
|
);
|
|
71
61
|
};
|
|
@@ -7,9 +7,10 @@ import React from 'react';
|
|
|
7
7
|
import { type ScriptType } from '@dxos/functions';
|
|
8
8
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
9
|
|
|
10
|
-
import { TestPanel } from './TestPanel';
|
|
11
10
|
import { useDeployState, useToolbarState } from '../../hooks';
|
|
12
11
|
|
|
12
|
+
import { TestPanel } from './TestPanel';
|
|
13
|
+
|
|
13
14
|
export type TestContainerProps = {
|
|
14
15
|
role: string;
|
|
15
16
|
script: ScriptType;
|
|
@@ -9,7 +9,7 @@ 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
|
|
|
@@ -24,7 +24,7 @@ export type TestPanelProps = ThemedClassName<{
|
|
|
24
24
|
|
|
25
25
|
// TODO(burdon): Need persistent history (currently lost when switching tabs)..
|
|
26
26
|
export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
27
|
-
const { t } = useTranslation(
|
|
27
|
+
const { t } = useTranslation(meta.id);
|
|
28
28
|
|
|
29
29
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
30
30
|
const [input, setInput] = useState('');
|
|
@@ -41,7 +41,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const controller = useRef<AbortController>();
|
|
44
|
+
const controller = useRef<AbortController>(null);
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
return () => {
|
|
47
47
|
handleStop();
|
|
@@ -50,7 +50,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
50
50
|
|
|
51
51
|
const handleStop = () => {
|
|
52
52
|
controller.current?.abort('stop');
|
|
53
|
-
controller.current =
|
|
53
|
+
controller.current = null;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const handleClear = () => {
|
|
@@ -62,7 +62,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const handleResponse = ({ text, data, error }: { text?: string; data?: any; error?: Error } = {}) => {
|
|
65
|
-
controller.current =
|
|
65
|
+
controller.current = null;
|
|
66
66
|
setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);
|
|
67
67
|
setResult('');
|
|
68
68
|
setState(null);
|
|
@@ -237,7 +237,7 @@ const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message
|
|
|
237
237
|
)}
|
|
238
238
|
|
|
239
239
|
{data && (
|
|
240
|
-
<SyntaxHighlighter language='json' className={mx(wrapper, '
|
|
240
|
+
<SyntaxHighlighter language='json' className={mx(wrapper, 'text-xs')}>
|
|
241
241
|
{JSON.stringify(data, null, 2)}
|
|
242
242
|
</SyntaxHighlighter>
|
|
243
243
|
)}
|