@dxos/plugin-script 0.8.4-main.7ace549 → 0.8.4-main.8baae0fced
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/LICENSE +102 -5
- package/README.md +15 -13
- package/dist/lib/neutral/DeploymentDialog-6DBF3V6C.mjs +112 -0
- package/dist/lib/neutral/DeploymentDialog-6DBF3V6C.mjs.map +7 -0
- package/dist/lib/{browser/NotebookContainer-MHY3DXDE.mjs → neutral/NotebookArticle-VBBVX4BW.mjs} +245 -299
- package/dist/lib/neutral/NotebookArticle-VBBVX4BW.mjs.map +7 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs +79 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.mjs +39 -0
- package/dist/lib/neutral/ScriptPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs +27 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs +31 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs.map +7 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs +297 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs.map +7 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs +44 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs +52 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +10 -0
- package/dist/lib/neutral/capabilities/index.mjs +21 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +17 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs +56 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs.map +7 -0
- package/dist/lib/{browser/chunk-EB6AXFXO.mjs → neutral/chunk-436PZKYX.mjs} +4 -3
- package/dist/lib/neutral/chunk-436PZKYX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4OWPUMGN.mjs +8 -0
- package/dist/lib/neutral/chunk-4OWPUMGN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-A4LRH25S.mjs +105 -0
- package/dist/lib/neutral/chunk-A4LRH25S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BDRB6ZX2.mjs +52 -0
- package/dist/lib/neutral/chunk-BDRB6ZX2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BMO5VOKL.mjs +125 -0
- package/dist/lib/neutral/chunk-BMO5VOKL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MI6X5CTJ.mjs +336 -0
- package/dist/lib/neutral/chunk-MI6X5CTJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SNUWHNEW.mjs +8 -0
- package/dist/lib/neutral/chunk-SNUWHNEW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs +150 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +7 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs +101 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +721 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +17 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-ZUHIXCBS.mjs +46 -0
- package/dist/lib/neutral/create-ZUHIXCBS.mjs.map +7 -0
- package/dist/lib/neutral/create-object-F2NWICFV.mjs +44 -0
- package/dist/lib/neutral/create-object-F2NWICFV.mjs.map +7 -0
- package/dist/lib/neutral/create-script-H5S4AO47.mjs +45 -0
- package/dist/lib/neutral/create-script-H5S4AO47.mjs.map +7 -0
- package/dist/lib/neutral/delete-PAUWA2QM.mjs +21 -0
- package/dist/lib/neutral/delete-PAUWA2QM.mjs.map +7 -0
- package/dist/lib/neutral/deploy-M73G7HMP.mjs +63 -0
- package/dist/lib/neutral/deploy-M73G7HMP.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +369 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +41 -0
- package/dist/lib/neutral/inspect-invocations-UO27IPCL.mjs +59 -0
- package/dist/lib/neutral/inspect-invocations-UO27IPCL.mjs.map +7 -0
- package/dist/lib/neutral/install-function-MSWSC244.mjs +49 -0
- package/dist/lib/neutral/install-function-MSWSC244.mjs.map +7 -0
- package/dist/lib/neutral/invoke-V6XYXKLD.mjs +32 -0
- package/dist/lib/neutral/invoke-V6XYXKLD.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/operation-handler-KIZ7XZ5G.mjs +18 -0
- package/dist/lib/neutral/operation-handler-KIZ7XZ5G.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/query-deployed-functions-4MMKQ6BR.mjs +34 -0
- package/dist/lib/neutral/query-deployed-functions-4MMKQ6BR.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-K4SSUR57.mjs +120 -0
- package/dist/lib/neutral/react-surface-K4SSUR57.mjs.map +7 -0
- package/dist/lib/neutral/read-FFOSK6A3.mjs +26 -0
- package/dist/lib/neutral/read-FFOSK6A3.mjs.map +7 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs +30 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/templates/index.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +104 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/update-PJS5GG3Y.mjs +63 -0
- package/dist/lib/neutral/update-PJS5GG3Y.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +3 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/ScriptPlugin.node.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.test.d.ts +2 -0
- package/dist/types/src/ScriptPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts +11 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts +129 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/delete.d.ts +16 -0
- package/dist/types/src/blueprints/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts +20 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +27 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts +11 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts +20 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts +13 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/read.d.ts +20 -0
- package/dist/types/src/blueprints/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +25 -0
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -0
- 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 +4 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/compiler.d.ts +3 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +16 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +19 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +18 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/{FrameContainer/FrameContainer.d.ts → FramePanel/FramePanel.d.ts} +3 -3
- package/dist/types/src/components/FramePanel/FramePanel.d.ts.map +1 -0
- package/dist/types/src/components/FramePanel/index.d.ts +2 -0
- package/dist/types/src/components/FramePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +4 -4
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +5 -3
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +221 -229
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts +8 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts +241 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts +2 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +8 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +221 -229
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts +4 -2
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/index.d.ts +0 -1
- package/dist/types/src/components/TestPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +6 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +6 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/DeploymentDialog/DeploymentDialog.d.ts +0 -2
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +240 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts +2 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts +2 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts +10 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +6 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts +8 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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/e2e/deploy.test.d.ts +2 -0
- package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +20 -26
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +4 -3
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +4 -3
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts +7 -0
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
- 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 +2 -3
- 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 +25 -12
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -1
- package/dist/types/src/operations/create-script.d.ts +5 -0
- package/dist/types/src/operations/create-script.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/templates/anthropic.d.ts +7 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chat.d.ts.map +1 -1
- package/dist/types/src/templates/chess-bot.d.ts +12 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +13 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- 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/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +5 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +5 -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 +33 -24
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +2 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/testing/test-notebook.d.ts +3 -0
- package/dist/types/src/testing/test-notebook.d.ts.map +1 -0
- package/dist/types/src/testing/test-script.d.ts +7 -0
- package/dist/types/src/testing/test-script.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +222 -92
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +109 -22
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- package/dist/types/src/types/ScriptCapabilities.d.ts +6 -0
- package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/ScriptEvents.d.ts +3 -0
- package/dist/types/src/types/ScriptEvents.d.ts.map +1 -0
- package/dist/types/src/types/ScriptOperation.d.ts +29 -0
- package/dist/types/src/types/ScriptOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +7 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +2 -2
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +2 -2
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +178 -101
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +23 -80
- package/src/ScriptPlugin.workerd.ts +18 -0
- package/src/blueprints/functions/create.ts +47 -0
- package/src/blueprints/functions/definitions.ts +323 -0
- package/src/blueprints/functions/delete.ts +23 -0
- package/src/blueprints/functions/deploy.ts +71 -0
- package/src/blueprints/functions/index.ts +19 -0
- package/src/blueprints/functions/inspect-invocations.ts +56 -0
- package/src/blueprints/functions/install-function.ts +56 -0
- package/src/blueprints/functions/invoke.ts +34 -0
- package/src/blueprints/functions/query-deployed-functions.ts +35 -0
- package/src/blueprints/functions/read.ts +29 -0
- package/src/blueprints/functions/update.ts +68 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +55 -0
- package/src/capabilities/app-graph-builder.ts +40 -58
- package/src/capabilities/artifact-definition.ts +99 -97
- package/src/capabilities/blueprint-definition.ts +13 -24
- package/src/capabilities/compiler.ts +99 -22
- package/src/capabilities/create-object.ts +48 -0
- package/src/capabilities/index.ts +13 -9
- package/src/capabilities/node.ts +16 -0
- package/src/capabilities/operation-handler.ts +21 -0
- package/src/capabilities/react-surface.tsx +120 -93
- package/src/capabilities/settings.ts +26 -14
- package/src/compiler/compiler.ts +21 -3
- package/src/components/{FrameContainer/FrameContainer.tsx → FramePanel/FramePanel.tsx} +7 -6
- package/src/components/{FrameContainer → FramePanel}/index.ts +1 -1
- package/src/components/NotebookStack/NotebookCell.tsx +42 -32
- package/src/components/NotebookStack/NotebookMenu.tsx +7 -7
- package/src/components/NotebookStack/NotebookStack.stories.tsx +24 -25
- package/src/components/NotebookStack/NotebookStack.tsx +31 -20
- package/src/components/QueryEditor/QueryEditor.stories.tsx +96 -0
- package/src/components/QueryEditor/QueryEditor.tsx +49 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.tsx +32 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.tsx +42 -0
- package/src/components/ScriptPluginSettings/index.ts +5 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +42 -20
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +38 -43
- package/src/components/TestPanel/TestPanel.tsx +110 -194
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +24 -17
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +74 -66
- package/src/components/index.ts +6 -7
- package/src/constants.ts +7 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +63 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +99 -0
- package/src/containers/DeploymentDialog/index.ts +5 -0
- package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +85 -0
- package/src/{components/NotebookContainer.tsx → containers/NotebookArticle/NotebookArticle.tsx} +93 -98
- package/src/containers/NotebookArticle/index.ts +5 -0
- package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +107 -0
- package/src/containers/ScriptArticle/ScriptArticle.tsx +85 -0
- package/src/containers/ScriptArticle/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +102 -0
- package/src/containers/ScriptProperties/FunctionBinding.tsx +83 -0
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +121 -0
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +76 -0
- package/src/containers/ScriptProperties/ScriptProperties.tsx +24 -0
- package/src/containers/ScriptProperties/index.ts +5 -0
- package/src/containers/TestContainer/TestContainer.tsx +44 -0
- package/src/containers/TestContainer/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/e2e/ai.test.ts +93 -0
- package/src/e2e/deploy.test.ts +66 -0
- package/src/hooks/deploy.ts +42 -33
- package/src/hooks/format.ts +9 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +19 -12
- package/src/hooks/useCompiler.ts +25 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -20
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -4
- package/src/meta.ts +5 -4
- package/src/notebook/compute-graph.test.ts +21 -9
- package/src/notebook/compute-graph.ts +46 -22
- package/src/notebook/vfs-parser.ts +10 -3
- package/src/operations/create-script.ts +46 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/templates/anthropic.ts +49 -0
- package/src/templates/chat.ts +1 -1
- package/src/templates/chess-bot.ts +63 -0
- package/src/templates/commentary.ts +248 -0
- package/src/templates/data-generator.ts +2 -2
- package/src/templates/discord.ts +3 -3
- package/src/templates/forex-effect.ts +35 -29
- package/src/templates/forex.ts +27 -17
- package/src/templates/gmail.ts +4 -4
- package/src/templates/index.ts +31 -18
- package/src/templates/ping.ts +22 -5
- package/src/testing/index.ts +2 -1
- package/src/testing/simulator.test.ts +39 -0
- package/src/testing/{data.ts → test-notebook.ts} +11 -12
- package/src/testing/test-script.ts +28 -0
- package/src/translations.ts +86 -87
- package/src/types/Notebook.ts +18 -15
- package/src/types/ScriptCapabilities.ts +18 -0
- package/src/types/ScriptEvents.ts +11 -0
- package/src/types/ScriptOperation.ts +42 -0
- package/src/types/Settings.ts +20 -0
- package/src/types/index.ts +5 -2
- package/src/types/types.ts +1 -11
- package/src/util/deploy.ts +25 -29
- package/src/util/functions.ts +30 -27
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-5TKNGPVR.mjs +0 -14
- package/dist/lib/browser/NotebookContainer-MHY3DXDE.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.mjs +0 -148
- package/dist/lib/browser/ScriptContainer-CW6YN3DQ.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-2G2NA6DQ.mjs +0 -88
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ALS6X4HU.mjs +0 -304
- package/dist/lib/browser/chunk-ALS6X4HU.mjs.map +0 -7
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
- package/dist/lib/browser/chunk-M6KJPUJK.mjs +0 -111
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +0 -7
- package/dist/lib/browser/chunk-N5EYLQOT.mjs +0 -647
- package/dist/lib/browser/chunk-N5EYLQOT.mjs.map +0 -7
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs +0 -103
- package/dist/lib/browser/chunk-QIZ3BPRK.mjs.map +0 -7
- package/dist/lib/browser/chunk-SAN5Y7FI.mjs +0 -155
- package/dist/lib/browser/chunk-SAN5Y7FI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ULJFT73Q.mjs +0 -513
- package/dist/lib/browser/chunk-ULJFT73Q.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-4KHRSX7J.mjs +0 -86
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -268
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TXTBWOVD.mjs +0 -104
- package/dist/lib/browser/intent-resolver-TXTBWOVD.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-R245YN52.mjs +0 -128
- package/dist/lib/browser/react-surface-R245YN52.mjs.map +0 -7
- package/dist/lib/browser/settings-MHJXRGDF.mjs +0 -26
- package/dist/lib/browser/settings-MHJXRGDF.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -14
- package/dist/lib/node-esm/DeploymentDialog-2ULNOZQH.mjs +0 -15
- package/dist/lib/node-esm/NotebookContainer-U4C2HQ4T.mjs +0 -818
- package/dist/lib/node-esm/NotebookContainer-U4C2HQ4T.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.mjs +0 -149
- package/dist/lib/node-esm/ScriptContainer-VRPEKB4T.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-55JZVM6K.mjs +0 -16
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs +0 -90
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +0 -113
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs +0 -33
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ND4BPYPR.mjs +0 -156
- package/dist/lib/node-esm/chunk-ND4BPYPR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UEVZP5DN.mjs +0 -648
- package/dist/lib/node-esm/chunk-UEVZP5DN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VJSRZRLI.mjs +0 -514
- package/dist/lib/node-esm/chunk-VJSRZRLI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs +0 -305
- package/dist/lib/node-esm/chunk-VTRMJSQL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs +0 -104
- package/dist/lib/node-esm/chunk-XYKKDWUR.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs +0 -87
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -269
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-D6AVAQRA.mjs +0 -105
- package/dist/lib/node-esm/intent-resolver-D6AVAQRA.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-MHT3PJ6C.mjs +0 -129
- package/dist/lib/node-esm/react-surface-MHT3PJ6C.mjs.map +0 -7
- package/dist/lib/node-esm/settings-BVJORMMJ.mjs +0 -27
- package/dist/lib/node-esm/settings-BVJORMMJ.mjs.map +0 -7
- package/dist/lib/node-esm/templates/index.mjs +0 -11
- package/dist/lib/node-esm/types/index.mjs +0 -15
- 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/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +0 -251
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +0 -4
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/frame.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/frame.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/index.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.d.ts +0 -10
- package/dist/types/src/components/NotebookContainer.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +0 -254
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptContainer.d.ts +0 -12
- package/dist/types/src/components/ScriptContainer.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +0 -8
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +0 -6
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/index.d.ts +0 -3
- package/dist/types/src/components/Settings/index.d.ts.map +0 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +0 -8
- package/dist/types/src/components/TestPanel/TestContainer.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 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/testing/data.d.ts +0 -3
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/types/actions.d.ts +0 -54
- package/dist/types/src/types/actions.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -86
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -58
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -123
- package/src/components/DeploymentDialog/index.ts +0 -9
- package/src/components/FrameContainer/frame.html +0 -25
- package/src/components/FrameContainer/frame.tsx +0 -51
- package/src/components/NotebookContainer.stories.tsx +0 -83
- package/src/components/ScriptContainer.tsx +0 -70
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -298
- package/src/components/Settings/ScriptPluginSettings.tsx +0 -61
- package/src/components/Settings/index.ts +0 -6
- package/src/components/TestPanel/TestContainer.tsx +0 -27
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -49
- package/src/types/actions.ts +0 -53
- /package/dist/lib/{browser/templates → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser/DeploymentDialog-5TKNGPVR.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/templates → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types → neutral/templates}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-2ULNOZQH.mjs.map → neutral/types/index.mjs.map} +0 -0
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Compiler
|
|
3
|
+
} from "../chunk-2REUEDUA.mjs";
|
|
4
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/index.ts
|
|
7
|
+
import { lazy } from "react";
|
|
8
|
+
|
|
9
|
+
// src/components/FramePanel/FramePanel.tsx
|
|
10
|
+
import React, { useEffect, useRef } from "react";
|
|
11
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
12
|
+
import { invariant } from "@dxos/invariant";
|
|
13
|
+
import { log } from "@dxos/log";
|
|
14
|
+
import { useClient } from "@dxos/react-client";
|
|
15
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
16
|
+
import { createIFramePort } from "@dxos/rpc-tunnel";
|
|
17
|
+
import { mx } from "@dxos/ui-theme";
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/FramePanel/FramePanel.tsx";
|
|
19
|
+
var FramePanel = ({ containerUrl, result, debug = true }) => {
|
|
20
|
+
const client = useClient();
|
|
21
|
+
const iframeRef = useRef(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (iframeRef.current) {
|
|
24
|
+
const rpc = createProtoRpcPeer({
|
|
25
|
+
exposed: clientServiceBundle,
|
|
26
|
+
handlers: client._services.services,
|
|
27
|
+
port: createIFramePort({
|
|
28
|
+
channel: "frame",
|
|
29
|
+
iframe: iframeRef.current,
|
|
30
|
+
origin: "*"
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
rpc.open().catch((e) => log.catch(e, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 29, S: void 0 }));
|
|
34
|
+
return () => {
|
|
35
|
+
rpc.close().catch((e) => log.catch(e, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 31, S: void 0 }));
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, [
|
|
39
|
+
iframeRef
|
|
40
|
+
]);
|
|
41
|
+
invariant(result.sourceHash, "Source hash is required.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 38, S: void 0, A: ["result.sourceHash", "'Source hash is required.'"] });
|
|
42
|
+
const sourceHash = Buffer.from(result.sourceHash).toString("hex");
|
|
43
|
+
const src = "bundle" in result ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(new TextDecoder().decode(Object.values(result.bundle)[0]))}` : void 0;
|
|
44
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("iframe", {
|
|
45
|
+
ref: iframeRef,
|
|
46
|
+
sandbox: "allow-scripts",
|
|
47
|
+
src,
|
|
48
|
+
style: {
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "100%"
|
|
51
|
+
}
|
|
52
|
+
}), debug && /* @__PURE__ */ React.createElement("div", {
|
|
53
|
+
className: "relative"
|
|
54
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
55
|
+
className: mx("flex absolute right-2 bottom-2 w-[30rem] h-[200px] bg-base-surface ring rounded-sm", "z-20 overflow-x-hidden overflow-y-auto")
|
|
56
|
+
}, /* @__PURE__ */ React.createElement("pre", {
|
|
57
|
+
className: "text-xs whitespace-break-spaces break-all p-2"
|
|
58
|
+
}, JSON.stringify({
|
|
59
|
+
timestamp: result.timestamp,
|
|
60
|
+
sourceHash,
|
|
61
|
+
error: "error" in result ? result.error : void 0,
|
|
62
|
+
src
|
|
63
|
+
}, void 0, 2)))));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/components/NotebookStack/NotebookMenu.tsx
|
|
67
|
+
import React2 from "react";
|
|
68
|
+
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
69
|
+
import { meta } from "#meta";
|
|
70
|
+
var NotebookMenu = ({ cell, onCellInsert, onCellDelete }) => {
|
|
71
|
+
const { t } = useTranslation(meta.id);
|
|
72
|
+
return /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
73
|
+
onClick: () => onCellInsert?.("script", cell?.id)
|
|
74
|
+
}, t("notebook-cell-insert-script.label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
75
|
+
onClick: () => onCellInsert?.("prompt", cell?.id)
|
|
76
|
+
}, t("notebook-cell-insert-prompt.label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
77
|
+
onClick: () => onCellInsert?.("query", cell?.id)
|
|
78
|
+
}, t("notebook-cell-insert-query.label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
79
|
+
onClick: () => onCellInsert?.("markdown", cell?.id)
|
|
80
|
+
}, t("notebook-cell-insert-markdown.label")), cell && onCellDelete && /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
81
|
+
onClick: () => onCellDelete?.(cell.id)
|
|
82
|
+
}, t("notebook-cell-delete.label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/components/NotebookStack/NotebookStack.tsx
|
|
86
|
+
import React5 from "react";
|
|
87
|
+
import { DropdownMenu as DropdownMenu2, IconButton, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
88
|
+
import { Stack, StackItem } from "@dxos/react-ui-stack";
|
|
89
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
90
|
+
import { meta as meta3 } from "#meta";
|
|
91
|
+
|
|
92
|
+
// src/components/NotebookStack/NotebookCell.tsx
|
|
93
|
+
import React4, { useCallback, useMemo } from "react";
|
|
94
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
95
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
96
|
+
import { Obj } from "@dxos/echo";
|
|
97
|
+
import { createDocAccessor } from "@dxos/echo-db";
|
|
98
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
99
|
+
import { TemplateEditor } from "@dxos/plugin-assistant/components";
|
|
100
|
+
import { useThemeContext as useThemeContext2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
101
|
+
import { QueryEditor } from "@dxos/react-ui-components";
|
|
102
|
+
import { Editor } from "@dxos/react-ui-editor";
|
|
103
|
+
import { createBasicExtensions as createBasicExtensions2, createDataExtensions, createMarkdownExtensions, createThemeExtensions as createThemeExtensions2, decorateMarkdown } from "@dxos/ui-editor";
|
|
104
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
105
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
106
|
+
import { meta as meta2 } from "#meta";
|
|
107
|
+
|
|
108
|
+
// src/components/TypescriptEditor/TypescriptEditor.tsx
|
|
109
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
110
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
111
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
112
|
+
import { lintKeymap } from "@codemirror/lint";
|
|
113
|
+
import { Prec } from "@codemirror/state";
|
|
114
|
+
import { keymap } from "@codemirror/view";
|
|
115
|
+
import { tags } from "@lezer/highlight";
|
|
116
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
117
|
+
import { continueKeymap } from "@valtown/codemirror-continue";
|
|
118
|
+
import { tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from "@valtown/codemirror-ts";
|
|
119
|
+
import React3 from "react";
|
|
120
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
121
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
122
|
+
import { Domino } from "@dxos/ui";
|
|
123
|
+
import { InputModeExtensions, createBasicExtensions, createThemeExtensions, defaultStyles } from "@dxos/ui-editor";
|
|
124
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
125
|
+
import { isNonNullable } from "@dxos/util";
|
|
126
|
+
var TypescriptEditor = composable(({ classNames, id, role = "article", inputMode = "vscode", env, options, initialValue, extensions, scrollTo, selection, ...props }, forwardedRef) => {
|
|
127
|
+
const { themeMode } = useThemeContext();
|
|
128
|
+
const { parentRef, focusAttributes } = useTextEditor(() => ({
|
|
129
|
+
id,
|
|
130
|
+
initialValue,
|
|
131
|
+
selection,
|
|
132
|
+
scrollTo,
|
|
133
|
+
extensions: [
|
|
134
|
+
extensions,
|
|
135
|
+
createBasicExtensions({
|
|
136
|
+
highlightActiveLine: true,
|
|
137
|
+
indentWithTab: true,
|
|
138
|
+
lineNumbers: true,
|
|
139
|
+
lineWrapping: false,
|
|
140
|
+
scrollPastEnd: role !== "section",
|
|
141
|
+
search: true,
|
|
142
|
+
...options
|
|
143
|
+
}),
|
|
144
|
+
createThemeExtensions({
|
|
145
|
+
monospace: true,
|
|
146
|
+
themeMode,
|
|
147
|
+
syntaxHighlighting: true
|
|
148
|
+
}),
|
|
149
|
+
InputModeExtensions[inputMode],
|
|
150
|
+
javascript({
|
|
151
|
+
typescript: true
|
|
152
|
+
}),
|
|
153
|
+
autocompletion({
|
|
154
|
+
override: env ? [
|
|
155
|
+
tsAutocomplete()
|
|
156
|
+
] : void 0
|
|
157
|
+
}),
|
|
158
|
+
// Continues block comments when pressing Enter.
|
|
159
|
+
Prec.high(keymap.of(continueKeymap)),
|
|
160
|
+
keymap.of(completionKeymap),
|
|
161
|
+
keymap.of(lintKeymap),
|
|
162
|
+
// https://github.com/val-town/codemirror-ts
|
|
163
|
+
env && [
|
|
164
|
+
// TODO(burdon): Fix type.
|
|
165
|
+
tsFacet.of({
|
|
166
|
+
env,
|
|
167
|
+
path: `./src/${id}.ts`
|
|
168
|
+
}),
|
|
169
|
+
tsSync(),
|
|
170
|
+
tsLinter(),
|
|
171
|
+
tsHover({
|
|
172
|
+
renderTooltip: createTooltipRenderer(themeMode)
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
].filter(isNonNullable)
|
|
176
|
+
}), [
|
|
177
|
+
themeMode,
|
|
178
|
+
id,
|
|
179
|
+
extensions,
|
|
180
|
+
inputMode,
|
|
181
|
+
selection,
|
|
182
|
+
scrollTo,
|
|
183
|
+
env
|
|
184
|
+
]);
|
|
185
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
186
|
+
...composableProps(props, {
|
|
187
|
+
classNames,
|
|
188
|
+
...focusAttributes
|
|
189
|
+
}),
|
|
190
|
+
ref: composeRefs(parentRef, forwardedRef)
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
var createTooltipRenderer = (themeMode) => {
|
|
194
|
+
const theme = HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light);
|
|
195
|
+
const classFromKind = (_kind) => {
|
|
196
|
+
const kind = _kind.endsWith("Name") ? "name" : _kind;
|
|
197
|
+
const validTag = kind in tags;
|
|
198
|
+
if (!validTag) {
|
|
199
|
+
return "";
|
|
200
|
+
}
|
|
201
|
+
const tag = tags[kind];
|
|
202
|
+
if (typeof tag === "function") {
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
return theme.style([
|
|
206
|
+
tag
|
|
207
|
+
]) ?? "";
|
|
208
|
+
};
|
|
209
|
+
return (info) => {
|
|
210
|
+
const children = info.quickInfo?.displayParts?.map(({ kind, text }) => Domino.of("span").classNames(classFromKind(kind)).text(text)) ?? [];
|
|
211
|
+
return {
|
|
212
|
+
dom: Domino.of("div").classNames("xs:max-w-80 max-w-lg p-1 bg-base-surface rounded-sm border border-separator").append(...children).root
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/components/NotebookStack/NotebookCell.tsx
|
|
218
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/NotebookStack/NotebookCell.tsx";
|
|
219
|
+
var editorStyles = "p-2 ps-3";
|
|
220
|
+
var valueStyles = "p-1 ps-3";
|
|
221
|
+
var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
222
|
+
const { t } = useTranslation2(meta2.id);
|
|
223
|
+
const extensions = useMemo(() => {
|
|
224
|
+
return cell.source?.target ? [
|
|
225
|
+
createDataExtensions({
|
|
226
|
+
id: cell.id,
|
|
227
|
+
text: createDocAccessor(cell.source.target, [
|
|
228
|
+
"content"
|
|
229
|
+
])
|
|
230
|
+
})
|
|
231
|
+
].filter(isNonNullable2) : [];
|
|
232
|
+
}, [
|
|
233
|
+
cell.source?.target
|
|
234
|
+
]);
|
|
235
|
+
const explorerGraph = cell.graph?.target;
|
|
236
|
+
const handleQueryChange = useCallback((value) => {
|
|
237
|
+
invariant2(cell.source?.target, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 38, S: void 0, A: ["cell.source?.target", ""] });
|
|
238
|
+
Obj.update(cell.source.target, (obj) => {
|
|
239
|
+
obj.content = value;
|
|
240
|
+
});
|
|
241
|
+
}, [
|
|
242
|
+
cell
|
|
243
|
+
]);
|
|
244
|
+
switch (cell.type) {
|
|
245
|
+
case "markdown":
|
|
246
|
+
if (!cell.source?.target) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
return /* @__PURE__ */ React4.createElement(NotebookTextEditor, {
|
|
250
|
+
id: cell.id,
|
|
251
|
+
classNames: editorStyles,
|
|
252
|
+
initialValue: cell.source.target.content,
|
|
253
|
+
extensions
|
|
254
|
+
});
|
|
255
|
+
case "script":
|
|
256
|
+
if (!cell.source?.target) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TypescriptEditor, {
|
|
260
|
+
id: cell.id,
|
|
261
|
+
role: "section",
|
|
262
|
+
classNames: editorStyles,
|
|
263
|
+
initialValue: cell.source.target.content,
|
|
264
|
+
extensions,
|
|
265
|
+
env,
|
|
266
|
+
options: {
|
|
267
|
+
placeholder: t("notebook-cell.placeholder"),
|
|
268
|
+
highlightActiveLine: false,
|
|
269
|
+
lineNumbers: false
|
|
270
|
+
}
|
|
271
|
+
}), /* @__PURE__ */ React4.createElement(NotebookCellValue, {
|
|
272
|
+
cell,
|
|
273
|
+
graph
|
|
274
|
+
}));
|
|
275
|
+
case "query":
|
|
276
|
+
if (!cell.source?.target) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
280
|
+
className: mx2("h-full overflow-hidden grid", explorerGraph && !dragging && "grid-rows-[min-content_1fr]")
|
|
281
|
+
}, /* @__PURE__ */ React4.createElement(QueryEditor, {
|
|
282
|
+
id: cell.id,
|
|
283
|
+
classNames: [
|
|
284
|
+
editorStyles,
|
|
285
|
+
"border-b border-subdued-separator"
|
|
286
|
+
],
|
|
287
|
+
db,
|
|
288
|
+
value: cell.source.target.content,
|
|
289
|
+
onChange: handleQueryChange
|
|
290
|
+
}), explorerGraph && !dragging && /* @__PURE__ */ React4.createElement(Surface.Surface, {
|
|
291
|
+
type: AppSurface.Section,
|
|
292
|
+
limit: 1,
|
|
293
|
+
data: {
|
|
294
|
+
subject: explorerGraph,
|
|
295
|
+
attendableId: cell.id
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
298
|
+
// TODO(burdon): Use streaming response from Chat.
|
|
299
|
+
case "prompt":
|
|
300
|
+
if (!cell.prompt?.target) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TemplateEditor, {
|
|
304
|
+
id: cell.id,
|
|
305
|
+
template: cell.prompt.target.instructions,
|
|
306
|
+
lineNumbers: false,
|
|
307
|
+
classNames: editorStyles
|
|
308
|
+
}), /* @__PURE__ */ React4.createElement(NotebookPromptResult, {
|
|
309
|
+
cell,
|
|
310
|
+
promptResults
|
|
311
|
+
}));
|
|
312
|
+
default:
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
var NotebookCellValue = ({ cell, graph }) => {
|
|
317
|
+
const name = graph?.getExpressions()[cell.id]?.name;
|
|
318
|
+
const value = graph?.getValue(cell.id);
|
|
319
|
+
if (value == null) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
323
|
+
className: mx2("flex w-full bg-group-surface border-y border-subdued-separator text-description font-mono", valueStyles)
|
|
324
|
+
}, name && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("span", {
|
|
325
|
+
className: "text-success-text"
|
|
326
|
+
}, name), /* @__PURE__ */ React4.createElement("span", {
|
|
327
|
+
className: "text-description"
|
|
328
|
+
}, "\xA0=\xA0")), /* @__PURE__ */ React4.createElement("span", null, value));
|
|
329
|
+
};
|
|
330
|
+
var NotebookPromptResult = ({ cell, promptResults }) => {
|
|
331
|
+
if (!cell.prompt) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
const value = promptResults?.[cell.prompt.dxn.toString()];
|
|
335
|
+
if (value == null) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
339
|
+
className: mx2("flex w-full bg-group-surface text-description border-y border-subdued-separator", valueStyles)
|
|
340
|
+
}, /* @__PURE__ */ React4.createElement(NotebookTextEditor, {
|
|
341
|
+
readOnly: true,
|
|
342
|
+
value
|
|
343
|
+
}));
|
|
344
|
+
};
|
|
345
|
+
var NotebookTextEditor = ({ extensions: extensionsProp, readOnly, ...props }) => {
|
|
346
|
+
const { t } = useTranslation2(meta2.id);
|
|
347
|
+
const { themeMode } = useThemeContext2();
|
|
348
|
+
const extensions = useMemo(() => {
|
|
349
|
+
return [
|
|
350
|
+
createBasicExtensions2({
|
|
351
|
+
placeholder: t("notebook-markdown.placeholder"),
|
|
352
|
+
readOnly
|
|
353
|
+
}),
|
|
354
|
+
createThemeExtensions2({
|
|
355
|
+
themeMode,
|
|
356
|
+
syntaxHighlighting: true
|
|
357
|
+
}),
|
|
358
|
+
createMarkdownExtensions(),
|
|
359
|
+
decorateMarkdown(),
|
|
360
|
+
extensionsProp
|
|
361
|
+
].filter(isNonNullable2);
|
|
362
|
+
}, [
|
|
363
|
+
extensionsProp
|
|
364
|
+
]);
|
|
365
|
+
return /* @__PURE__ */ React4.createElement(Editor.Root, null, /* @__PURE__ */ React4.createElement(Editor.View, {
|
|
366
|
+
...props,
|
|
367
|
+
extensions,
|
|
368
|
+
selectionEnd: true
|
|
369
|
+
}));
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/components/NotebookStack/NotebookStack.tsx
|
|
373
|
+
var minSectionHeight = "min-h-[16rem]";
|
|
374
|
+
var NotebookStack = composable2(({ notebook, onRearrange, db, graph, promptResults, onCellInsert, onCellDelete, env, ...props }, forwardedRef) => {
|
|
375
|
+
const sectionProps = {
|
|
376
|
+
db,
|
|
377
|
+
graph,
|
|
378
|
+
promptResults,
|
|
379
|
+
onCellInsert,
|
|
380
|
+
onCellDelete,
|
|
381
|
+
env
|
|
382
|
+
};
|
|
383
|
+
return /* @__PURE__ */ React5.createElement(Stack, {
|
|
384
|
+
...composableProps2(props),
|
|
385
|
+
orientation: "vertical",
|
|
386
|
+
size: "contain",
|
|
387
|
+
rail: true,
|
|
388
|
+
onRearrange,
|
|
389
|
+
ref: forwardedRef
|
|
390
|
+
}, notebook?.cells.map((cell, i) => /* @__PURE__ */ React5.createElement(NotebookSection, {
|
|
391
|
+
key: i,
|
|
392
|
+
cell,
|
|
393
|
+
...sectionProps
|
|
394
|
+
})));
|
|
395
|
+
});
|
|
396
|
+
var NotebookSection = ({ cell, db, env, promptResults, onCellInsert, onCellDelete, ...props }) => {
|
|
397
|
+
const { t } = useTranslation3(meta3.id);
|
|
398
|
+
const resizable = cell.type === "query";
|
|
399
|
+
return /* @__PURE__ */ React5.createElement(StackItem.Root, {
|
|
400
|
+
role: "section",
|
|
401
|
+
item: cell,
|
|
402
|
+
draggable: true,
|
|
403
|
+
classNames: resizable && minSectionHeight
|
|
404
|
+
}, /* @__PURE__ */ React5.createElement(StackItem.Heading, {
|
|
405
|
+
classNames: "h-full p-1 justify-between dx-attention-surface"
|
|
406
|
+
}, /* @__PURE__ */ React5.createElement(StackItem.DragHandle, {
|
|
407
|
+
asChild: true
|
|
408
|
+
}, /* @__PURE__ */ React5.createElement(IconButton, {
|
|
409
|
+
variant: "ghost",
|
|
410
|
+
icon: "ph--dots-six-vertical--regular",
|
|
411
|
+
iconOnly: true,
|
|
412
|
+
label: "Drag handle"
|
|
413
|
+
})), /* @__PURE__ */ React5.createElement(DropdownMenu2.Root, null, /* @__PURE__ */ React5.createElement(DropdownMenu2.Trigger, {
|
|
414
|
+
asChild: true
|
|
415
|
+
}, /* @__PURE__ */ React5.createElement(IconButton, {
|
|
416
|
+
variant: "ghost",
|
|
417
|
+
icon: "ph--dots-three--regular",
|
|
418
|
+
iconOnly: true,
|
|
419
|
+
label: t("notebook-cell-insert.label")
|
|
420
|
+
})), /* @__PURE__ */ React5.createElement(NotebookMenu, {
|
|
421
|
+
cell,
|
|
422
|
+
onCellInsert,
|
|
423
|
+
onCellDelete
|
|
424
|
+
})), resizable && /* @__PURE__ */ React5.createElement(StackItem.ResizeHandle, null)), /* @__PURE__ */ React5.createElement(StackItem.DragPreview, null, ({ item: cell2 }) => /* @__PURE__ */ React5.createElement(StackItem.Content, {
|
|
425
|
+
classNames: "overflow-visible bg-group-surface border border-subdued-separator"
|
|
426
|
+
}, /* @__PURE__ */ React5.createElement(NotebookCell, {
|
|
427
|
+
db,
|
|
428
|
+
cell: cell2,
|
|
429
|
+
env,
|
|
430
|
+
dragging: true
|
|
431
|
+
}))), /* @__PURE__ */ React5.createElement(StackItem.Content, {
|
|
432
|
+
classNames: "overflow-visible"
|
|
433
|
+
}, /* @__PURE__ */ React5.createElement(NotebookCell, {
|
|
434
|
+
db,
|
|
435
|
+
cell,
|
|
436
|
+
env,
|
|
437
|
+
promptResults,
|
|
438
|
+
...props
|
|
439
|
+
})));
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/components/QueryEditor/QueryEditor.tsx
|
|
443
|
+
import React6, { useState } from "react";
|
|
444
|
+
import { ModuleResolutionKind, ScriptTarget } from "typescript";
|
|
445
|
+
import queryApi from "@dxos/echo-query/api.d.ts?raw";
|
|
446
|
+
import { useAsyncEffect } from "@dxos/react-ui";
|
|
447
|
+
var GLOBALS = `
|
|
448
|
+
namespace QueryAPI {
|
|
449
|
+
${queryApi}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare global {
|
|
453
|
+
const Query: typeof QueryAPI.Query;
|
|
454
|
+
const Filter: typeof QueryAPI.Filter;
|
|
455
|
+
const Order: typeof QueryAPI.Order;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export {};
|
|
459
|
+
`;
|
|
460
|
+
var QueryEditor2 = (props) => {
|
|
461
|
+
const [compiler, setCompiler] = useState();
|
|
462
|
+
useAsyncEffect(async () => {
|
|
463
|
+
const compiler2 = new Compiler({
|
|
464
|
+
lib: [
|
|
465
|
+
"ES5"
|
|
466
|
+
],
|
|
467
|
+
target: ScriptTarget.ES2022,
|
|
468
|
+
// Avoid `@typescript/vfs`'s deprecated `node10` default (rejected by TS 6).
|
|
469
|
+
moduleResolution: ModuleResolutionKind.Bundler
|
|
470
|
+
});
|
|
471
|
+
await compiler2.initialize(GLOBALS);
|
|
472
|
+
setCompiler(compiler2);
|
|
473
|
+
}, []);
|
|
474
|
+
if (!compiler) {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
return /* @__PURE__ */ React6.createElement(TypescriptEditor, {
|
|
478
|
+
...props,
|
|
479
|
+
env: compiler.environment
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// src/components/ScriptToolbar/ScriptToolbar.tsx
|
|
484
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
485
|
+
import React7, { useMemo as useMemo2 } from "react";
|
|
486
|
+
import { ElevationProvider, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
487
|
+
import { Menu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
|
|
488
|
+
import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
|
|
489
|
+
import { createDeploy, createFormat, createTemplateSelect, useDeployDeps } from "#hooks";
|
|
490
|
+
import { meta as meta4 } from "#meta";
|
|
491
|
+
var ScriptToolbar = composable3(({ script, attendableId, role, state, ...props }, forwardedRef) => {
|
|
492
|
+
const { t } = useTranslation4(meta4.id);
|
|
493
|
+
const options = useDeployDeps({
|
|
494
|
+
script
|
|
495
|
+
});
|
|
496
|
+
const menuCreator = useMemo2(() => createToolbarActions({
|
|
497
|
+
state,
|
|
498
|
+
script,
|
|
499
|
+
t,
|
|
500
|
+
...options
|
|
501
|
+
}), [
|
|
502
|
+
state,
|
|
503
|
+
script,
|
|
504
|
+
options,
|
|
505
|
+
t
|
|
506
|
+
]);
|
|
507
|
+
const menuActions = useMenuActions(menuCreator);
|
|
508
|
+
return /* @__PURE__ */ React7.createElement(ElevationProvider, {
|
|
509
|
+
elevation: role === "section" ? "positioned" : "base"
|
|
510
|
+
}, /* @__PURE__ */ React7.createElement(Menu.Root, {
|
|
511
|
+
...menuActions,
|
|
512
|
+
attendableId
|
|
513
|
+
}, /* @__PURE__ */ React7.createElement(Menu.Toolbar, {
|
|
514
|
+
...composableProps3(props),
|
|
515
|
+
ref: forwardedRef
|
|
516
|
+
})));
|
|
517
|
+
});
|
|
518
|
+
var createToolbarActions = ({ state, script, ...options }) => Atom.make((get) => {
|
|
519
|
+
get(state.atom);
|
|
520
|
+
const templateSelect = createTemplateSelect(script);
|
|
521
|
+
const format = createFormat(script);
|
|
522
|
+
const gap = createGapSeparator();
|
|
523
|
+
const deploy = createDeploy({
|
|
524
|
+
state,
|
|
525
|
+
script,
|
|
526
|
+
...options
|
|
527
|
+
});
|
|
528
|
+
return {
|
|
529
|
+
nodes: [
|
|
530
|
+
...templateSelect.nodes,
|
|
531
|
+
...format.nodes,
|
|
532
|
+
...gap.nodes,
|
|
533
|
+
...deploy.nodes
|
|
534
|
+
],
|
|
535
|
+
edges: [
|
|
536
|
+
...templateSelect.edges,
|
|
537
|
+
...format.edges,
|
|
538
|
+
...gap.edges,
|
|
539
|
+
...deploy.edges
|
|
540
|
+
]
|
|
541
|
+
};
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// src/components/TestPanel/TestPanel.tsx
|
|
545
|
+
import React8, { forwardRef, useRef as useRef2, useState as useState2 } from "react";
|
|
546
|
+
import { log as log2 } from "@dxos/log";
|
|
547
|
+
import { Avatar, Icon, Input, ScrollArea, Toolbar, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
548
|
+
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
549
|
+
import { composable as composable4, composableProps as composableProps4, mx as mx3 } from "@dxos/ui-theme";
|
|
550
|
+
import { meta as meta5 } from "#meta";
|
|
551
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/TestPanel/TestPanel.tsx";
|
|
552
|
+
var TestPanel = composable4(({ classNames, onInvoke, ...props }, forwardedRef) => {
|
|
553
|
+
const { t } = useTranslation5(meta5.id);
|
|
554
|
+
const inputRef = useRef2(null);
|
|
555
|
+
const [input, setInput] = useState2("");
|
|
556
|
+
const [state, setState] = useState2(null);
|
|
557
|
+
const [history, setHistory] = useState2([]);
|
|
558
|
+
const scrollerRef = useRef2(null);
|
|
559
|
+
const handleScroll = () => {
|
|
560
|
+
if (scrollerRef.current) {
|
|
561
|
+
scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
const handleClear = () => {
|
|
565
|
+
setInput("");
|
|
566
|
+
setHistory([]);
|
|
567
|
+
inputRef.current?.focus();
|
|
568
|
+
};
|
|
569
|
+
const handleResponse = ({ text, data, error } = {}) => {
|
|
570
|
+
setHistory((history2) => [
|
|
571
|
+
...history2,
|
|
572
|
+
{
|
|
573
|
+
type: "response",
|
|
574
|
+
text,
|
|
575
|
+
data,
|
|
576
|
+
error
|
|
577
|
+
}
|
|
578
|
+
]);
|
|
579
|
+
setState(null);
|
|
580
|
+
handleScroll();
|
|
581
|
+
};
|
|
582
|
+
const handleRequest = async (input2) => {
|
|
583
|
+
if (!onInvoke) {
|
|
584
|
+
handleResponse({
|
|
585
|
+
error: new Error("Function not deployed")
|
|
586
|
+
});
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
let data = input2;
|
|
590
|
+
let displayText = input2;
|
|
591
|
+
if (input2.charAt(0) === "{") {
|
|
592
|
+
try {
|
|
593
|
+
const validJsonString = input2.replace(/'/g, '"').replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, '$1"$2"$3');
|
|
594
|
+
data = JSON.parse(validJsonString);
|
|
595
|
+
displayText = JSON.stringify(data, null, 2);
|
|
596
|
+
} catch (err) {
|
|
597
|
+
handleResponse({
|
|
598
|
+
error: new Error("Invalid JSON input")
|
|
599
|
+
});
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
try {
|
|
604
|
+
setState("pending");
|
|
605
|
+
setInput("");
|
|
606
|
+
setHistory((history2) => [
|
|
607
|
+
...history2,
|
|
608
|
+
{
|
|
609
|
+
type: "request",
|
|
610
|
+
text: displayText
|
|
611
|
+
}
|
|
612
|
+
]);
|
|
613
|
+
setTimeout(handleScroll);
|
|
614
|
+
const result = await onInvoke(data);
|
|
615
|
+
if (typeof result === "string") {
|
|
616
|
+
handleResponse({
|
|
617
|
+
text: result
|
|
618
|
+
});
|
|
619
|
+
} else {
|
|
620
|
+
handleResponse({
|
|
621
|
+
data: result
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
} catch (err) {
|
|
625
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
626
|
+
handleResponse({
|
|
627
|
+
error
|
|
628
|
+
});
|
|
629
|
+
log2.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 89, S: void 0 });
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
633
|
+
...composableProps4(props, {
|
|
634
|
+
classNames: [
|
|
635
|
+
"flex flex-col h-full overflow-hidden",
|
|
636
|
+
classNames
|
|
637
|
+
]
|
|
638
|
+
}),
|
|
639
|
+
ref: forwardedRef
|
|
640
|
+
}, /* @__PURE__ */ React8.createElement(MessageThread, {
|
|
641
|
+
ref: scrollerRef,
|
|
642
|
+
state,
|
|
643
|
+
history
|
|
644
|
+
}), /* @__PURE__ */ React8.createElement(Toolbar.Root, null, /* @__PURE__ */ React8.createElement(Input.Root, null, /* @__PURE__ */ React8.createElement(Input.TextInput, {
|
|
645
|
+
ref: inputRef,
|
|
646
|
+
autoFocus: true,
|
|
647
|
+
placeholder: t("function-request.placeholder"),
|
|
648
|
+
value: input,
|
|
649
|
+
onChange: (ev) => setInput(ev.target.value),
|
|
650
|
+
onKeyDown: (ev) => ev.key === "Enter" && handleRequest(input)
|
|
651
|
+
})), /* @__PURE__ */ React8.createElement(Toolbar.IconButton, {
|
|
652
|
+
icon: "ph--play--regular",
|
|
653
|
+
label: "Execute",
|
|
654
|
+
iconOnly: true,
|
|
655
|
+
onClick: () => handleRequest(input)
|
|
656
|
+
}), /* @__PURE__ */ React8.createElement(Toolbar.IconButton, {
|
|
657
|
+
icon: "ph--trash--regular",
|
|
658
|
+
label: "Clear",
|
|
659
|
+
iconOnly: true,
|
|
660
|
+
onClick: handleClear
|
|
661
|
+
})));
|
|
662
|
+
});
|
|
663
|
+
var MessageThread = /* @__PURE__ */ forwardRef(({ state, history }, forwardedRef) => {
|
|
664
|
+
return /* @__PURE__ */ React8.createElement(ScrollArea.Root, {
|
|
665
|
+
orientation: "vertical",
|
|
666
|
+
classNames: "h-full",
|
|
667
|
+
ref: forwardedRef
|
|
668
|
+
}, /* @__PURE__ */ React8.createElement(ScrollArea.Viewport, {
|
|
669
|
+
classNames: "gap-6 p-2"
|
|
670
|
+
}, history.map((message, i) => /* @__PURE__ */ React8.createElement("div", {
|
|
671
|
+
key: i,
|
|
672
|
+
className: "grid grid-cols-[2rem_1fr_2rem]"
|
|
673
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
674
|
+
className: "p-1"
|
|
675
|
+
}, message.type === "response" && /* @__PURE__ */ React8.createElement(RobotAvatar, null)), /* @__PURE__ */ React8.createElement("div", {
|
|
676
|
+
className: "overflow-auto"
|
|
677
|
+
}, /* @__PURE__ */ React8.createElement(MessageItem, {
|
|
678
|
+
message
|
|
679
|
+
})))), state === "pending" && /* @__PURE__ */ React8.createElement("div", {
|
|
680
|
+
className: "grid grid-cols-[2rem_1fr_2rem]"
|
|
681
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
682
|
+
className: "p-1"
|
|
683
|
+
}, /* @__PURE__ */ React8.createElement(Icon, {
|
|
684
|
+
icon: "ph--spinner--regular",
|
|
685
|
+
size: 6,
|
|
686
|
+
classNames: "animate-spin"
|
|
687
|
+
})))));
|
|
688
|
+
});
|
|
689
|
+
var MessageItem = ({ classNames, message }) => {
|
|
690
|
+
const { type, text, data, error } = message;
|
|
691
|
+
const wrapper = "p-1 px-2 rounded-md bg-hover-surface overflow-auto";
|
|
692
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
693
|
+
className: mx3("flex", type === "request" ? "ml-[1rem] justify-end" : "mr-[1rem]", classNames)
|
|
694
|
+
}, error && /* @__PURE__ */ React8.createElement("div", {
|
|
695
|
+
className: mx3(wrapper, "whitespace-pre text-error-text")
|
|
696
|
+
}, String(error)), text !== void 0 && /* @__PURE__ */ React8.createElement("div", {
|
|
697
|
+
className: mx3(wrapper, type === "request" && "bg-primary-500 dark:bg-primary-600")
|
|
698
|
+
}, text || "\xD8"), data && /* @__PURE__ */ React8.createElement(JsonHighlighter, {
|
|
699
|
+
data,
|
|
700
|
+
classNames: mx3(wrapper, "text-xs")
|
|
701
|
+
}));
|
|
702
|
+
};
|
|
703
|
+
var RobotAvatar = () => /* @__PURE__ */ React8.createElement(Avatar.Root, null, /* @__PURE__ */ React8.createElement(Avatar.Content, {
|
|
704
|
+
size: 6,
|
|
705
|
+
variant: "circle",
|
|
706
|
+
icon: "ph--drone--regular"
|
|
707
|
+
}));
|
|
708
|
+
|
|
709
|
+
// src/components/index.ts
|
|
710
|
+
var ScriptPluginSettings = lazy(() => import("../ScriptPluginSettings-T4JMUSHN.mjs"));
|
|
711
|
+
export {
|
|
712
|
+
FramePanel,
|
|
713
|
+
NotebookMenu,
|
|
714
|
+
NotebookStack,
|
|
715
|
+
QueryEditor2 as QueryEditor,
|
|
716
|
+
ScriptPluginSettings,
|
|
717
|
+
ScriptToolbar,
|
|
718
|
+
TestPanel,
|
|
719
|
+
TypescriptEditor
|
|
720
|
+
};
|
|
721
|
+
//# sourceMappingURL=index.mjs.map
|