@dxos/plugin-script 0.8.4-main.406dc2a → 0.8.4-main.4a85c3132b
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/README.md +15 -13
- package/dist/lib/browser/DeploymentDialog-IIOXAS47.mjs +138 -0
- package/dist/lib/browser/DeploymentDialog-IIOXAS47.mjs.map +7 -0
- package/dist/lib/browser/{NotebookContainer-LVGRPFY3.mjs → NotebookContainer-VVZOKGRC.mjs} +367 -200
- package/dist/lib/browser/NotebookContainer-VVZOKGRC.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-A5SSIUH6.mjs +93 -0
- package/dist/lib/browser/ScriptContainer-A5SSIUH6.mjs.map +7 -0
- package/dist/lib/browser/ScriptObjectSettings-HYYC7KXC.mjs +294 -0
- package/dist/lib/browser/ScriptObjectSettings-HYYC7KXC.mjs.map +7 -0
- package/dist/lib/browser/ScriptPluginSettings-UTWA7CBT.mjs +55 -0
- package/dist/lib/browser/ScriptPluginSettings-UTWA7CBT.mjs.map +7 -0
- package/dist/lib/browser/ScriptProperties-HREPUE65.mjs +28 -0
- package/dist/lib/browser/ScriptProperties-HREPUE65.mjs.map +7 -0
- package/dist/lib/browser/TestContainer-D4Y2K2TT.mjs +39 -0
- package/dist/lib/browser/TestContainer-D4Y2K2TT.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-YMZEJBAZ.mjs +17 -0
- package/dist/lib/browser/blueprint-definition-YMZEJBAZ.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-6IXFDTAI.mjs +113 -0
- package/dist/lib/browser/chunk-6IXFDTAI.mjs.map +7 -0
- package/dist/lib/browser/chunk-ATTZUDT7.mjs +67 -0
- package/dist/lib/browser/chunk-ATTZUDT7.mjs.map +7 -0
- package/dist/lib/browser/chunk-G3XIOLLI.mjs +174 -0
- package/dist/lib/browser/chunk-G3XIOLLI.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/{chunk-ST3ACVUC.mjs → chunk-J7PGML5B.mjs} +29 -12
- package/dist/lib/browser/chunk-J7PGML5B.mjs.map +7 -0
- package/dist/lib/browser/chunk-MUEVLYXJ.mjs +397 -0
- package/dist/lib/browser/chunk-MUEVLYXJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-PLDBKKYO.mjs +789 -0
- package/dist/lib/browser/chunk-PLDBKKYO.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q66L5EUR.mjs +20 -0
- package/dist/lib/browser/chunk-Q66L5EUR.mjs.map +7 -0
- package/dist/lib/browser/chunk-TW27W3EL.mjs +29 -0
- package/dist/lib/browser/chunk-TW27W3EL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EZVXV6DA.mjs → chunk-WYR4QHPE.mjs} +7 -2
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZYU2LP6U.mjs +11 -0
- package/dist/lib/browser/chunk-ZYU2LP6U.mjs.map +7 -0
- package/dist/lib/browser/compiler-53G6ZHQM.mjs +99 -0
- package/dist/lib/browser/compiler-53G6ZHQM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +111 -140
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-CYEISDDK.mjs +79 -0
- package/dist/lib/browser/operation-resolver-CYEISDDK.mjs.map +7 -0
- package/dist/lib/browser/react-surface-26P6HAFD.mjs +141 -0
- package/dist/lib/browser/react-surface-26P6HAFD.mjs.map +7 -0
- package/dist/lib/browser/settings-76UM7442.mjs +36 -0
- package/dist/lib/browser/settings-76UM7442.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +12 -7
- package/dist/lib/node-esm/DeploymentDialog-ZHPHEV2H.mjs +139 -0
- package/dist/lib/node-esm/DeploymentDialog-ZHPHEV2H.mjs.map +7 -0
- package/dist/lib/node-esm/{NotebookContainer-QY5NJGJI.mjs → NotebookContainer-ZLWTNMQA.mjs} +367 -200
- package/dist/lib/node-esm/NotebookContainer-ZLWTNMQA.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-S4UKQAWP.mjs +94 -0
- package/dist/lib/node-esm/ScriptContainer-S4UKQAWP.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptObjectSettings-C5QBRERY.mjs +295 -0
- package/dist/lib/node-esm/ScriptObjectSettings-C5QBRERY.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptPluginSettings-MFACDW4R.mjs +56 -0
- package/dist/lib/node-esm/ScriptPluginSettings-MFACDW4R.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptProperties-FMNIX3KU.mjs +29 -0
- package/dist/lib/node-esm/ScriptProperties-FMNIX3KU.mjs.map +7 -0
- package/dist/lib/node-esm/TestContainer-AO45YPGV.mjs +40 -0
- package/dist/lib/node-esm/TestContainer-AO45YPGV.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-5MGY6BRQ.mjs +18 -0
- package/dist/lib/node-esm/blueprint-definition-5MGY6BRQ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5BG7OJGQ.mjs +176 -0
- package/dist/lib/node-esm/chunk-5BG7OJGQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OG2SIKHE.mjs → chunk-5HSJPAK7.mjs} +7 -2
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-H46R2RS5.mjs +790 -0
- package/dist/lib/node-esm/chunk-H46R2RS5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JGN7TDJH.mjs +69 -0
- package/dist/lib/node-esm/chunk-JGN7TDJH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2GVTWESW.mjs → chunk-QG6ANK4B.mjs} +29 -12
- package/dist/lib/node-esm/chunk-QG6ANK4B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-S7DSCLOW.mjs +31 -0
- package/dist/lib/node-esm/chunk-S7DSCLOW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TZ2EBTPQ.mjs +22 -0
- package/dist/lib/node-esm/chunk-TZ2EBTPQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UFBVE33O.mjs +12 -0
- package/dist/lib/node-esm/chunk-UFBVE33O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WWD5LUU6.mjs +114 -0
- package/dist/lib/node-esm/chunk-WWD5LUU6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZDJ2FI7E.mjs +398 -0
- package/dist/lib/node-esm/chunk-ZDJ2FI7E.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-HHQW7EP3.mjs +100 -0
- package/dist/lib/node-esm/compiler-HHQW7EP3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +111 -140
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-HFFDXWND.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-HFFDXWND.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-THCIK266.mjs +142 -0
- package/dist/lib/node-esm/react-surface-THCIK266.mjs.map +7 -0
- package/dist/lib/node-esm/settings-CCHDPLFJ.mjs +37 -0
- package/dist/lib/node-esm/settings-CCHDPLFJ.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +12 -7
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
- package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +7 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/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 +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +4 -3
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +5 -4
- 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/ScriptToolbar/ScriptToolbar.d.ts +8 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +5 -4
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -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 +2 -4
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -0
- package/dist/types/src/{components/NotebookContainer.stories.d.ts → containers/DeploymentDialog/DeploymentDialog.stories.d.ts} +7 -6
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts +3 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts +7 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts +3 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts +10 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptObjectSettings/ScriptObjectSettings.d.ts +7 -0
- package/dist/types/src/containers/ScriptObjectSettings/ScriptObjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptObjectSettings/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptObjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptPluginSettings/ScriptPluginSettings.d.ts +8 -0
- package/dist/types/src/containers/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptPluginSettings/index.d.ts +3 -0
- package/dist/types/src/containers/ScriptPluginSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts +3 -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 +3 -0
- package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +9 -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 +17 -31
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +5 -4
- 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 +7 -16
- 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 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/index.d.ts +1 -1
- package/dist/types/src/notebook/index.d.ts.map +1 -1
- package/dist/types/src/templates/anthropic.d.ts +8 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +16 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +16 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- package/dist/types/src/templates/forex-effect.d.ts +4 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +4 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +12 -3
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +1 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -18
- package/dist/types/src/testing/data.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/translations.d.ts +4 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +108 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +30 -56
- package/dist/types/src/types/actions.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +12 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +3 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +114 -82
- package/src/ScriptPlugin.tsx +45 -87
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +31 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +97 -95
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +121 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +33 -0
- package/src/compiler/compiler.ts +10 -3
- package/src/components/FrameContainer/FrameContainer.tsx +6 -5
- package/src/components/FrameContainer/frame.html +21 -21
- package/src/components/NotebookStack/NotebookCell.tsx +85 -87
- package/src/components/NotebookStack/NotebookStack.stories.tsx +32 -10
- package/src/components/NotebookStack/NotebookStack.tsx +16 -9
- package/src/components/QueryEditor/QueryEditor.stories.tsx +102 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +42 -20
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +28 -31
- package/src/components/TestPanel/TestPanel.tsx +61 -36
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +25 -18
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +70 -74
- package/src/components/index.ts +4 -9
- package/src/constants.ts +7 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +61 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +99 -0
- package/src/containers/DeploymentDialog/index.ts +7 -0
- package/src/containers/NotebookContainer/NotebookContainer.stories.tsx +87 -0
- package/src/containers/NotebookContainer/NotebookContainer.tsx +268 -0
- package/src/containers/NotebookContainer/index.ts +7 -0
- package/src/containers/ScriptContainer/ScriptContainer.tsx +84 -0
- package/src/containers/ScriptContainer/index.ts +7 -0
- package/src/{components/Settings → containers/ScriptObjectSettings}/ScriptObjectSettings.tsx +55 -50
- package/src/containers/ScriptObjectSettings/index.ts +7 -0
- package/src/{components/Settings → containers/ScriptPluginSettings}/ScriptPluginSettings.tsx +19 -14
- package/src/containers/ScriptPluginSettings/index.ts +7 -0
- package/src/containers/ScriptProperties/ScriptProperties.tsx +33 -0
- package/src/containers/ScriptProperties/index.ts +7 -0
- package/src/containers/TestContainer/TestContainer.tsx +28 -0
- package/src/containers/TestContainer/index.ts +7 -0
- package/src/containers/index.ts +13 -0
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +43 -35
- package/src/hooks/format.ts +8 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +22 -26
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +14 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -1
- package/src/meta.ts +8 -4
- package/src/notebook/{notebook.test.ts → compute-graph.test.ts} +31 -19
- package/src/notebook/{notebook.ts → compute-graph.ts} +65 -18
- package/src/notebook/eval.ts +1 -1
- package/src/notebook/index.ts +1 -1
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +231 -0
- package/src/templates/data-generator.ts +1 -1
- package/src/templates/forex-effect.ts +22 -27
- package/src/templates/forex.ts +7 -6
- package/src/templates/gmail.ts +1 -2
- package/src/templates/index.ts +18 -5
- package/src/templates/ping.ts +14 -5
- package/src/testing/data.ts +34 -9
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +4 -3
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +18 -26
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +4 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +30 -40
- package/src/util/functions.ts +32 -28
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-65TWT6S5.mjs +0 -13
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs +0 -65
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
- package/dist/lib/browser/chunk-5CYLWXRH.mjs +0 -89
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-75LH4EUR.mjs +0 -326
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7DXDICD.mjs +0 -282
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs +0 -646
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO2O7W6J.mjs +0 -254
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6M34EUC.mjs +0 -112
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +0 -7
- package/dist/lib/browser/chunk-NM4WQS4F.mjs +0 -153
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +0 -7
- package/dist/lib/browser/chunk-OKXN2N7M.mjs +0 -15
- package/dist/lib/browser/chunk-OKXN2N7M.mjs.map +0 -7
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +0 -7
- package/dist/lib/browser/compiler-G2N2CG63.mjs +0 -98
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs +0 -105
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-76SDTUYG.mjs +0 -127
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +0 -7
- package/dist/lib/browser/settings-ERFKVNUK.mjs +0 -25
- package/dist/lib/browser/settings-ERFKVNUK.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs +0 -66
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4X375PGY.mjs +0 -90
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs +0 -327
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs +0 -154
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs +0 -16
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs +0 -647
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +0 -114
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs +0 -283
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs +0 -255
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs +0 -99
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs +0 -106
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs +0 -128
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +0 -7
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs +0 -26
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/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/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.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/notebook/notebook.d.ts +0 -35
- package/dist/types/src/notebook/notebook.d.ts.map +0 -1
- package/dist/types/src/notebook/notebook.test.d.ts +0 -2
- package/dist/types/src/notebook/notebook.test.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/types/schema.d.ts +0 -61
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -65
- package/src/capabilities/blueprint-definition.ts +0 -30
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -34
- package/src/capabilities/intent-resolver.ts +0 -87
- package/src/capabilities/react-surface.tsx +0 -102
- package/src/capabilities/settings.ts +0 -21
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -53
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -106
- package/src/components/DeploymentDialog/index.ts +0 -9
- package/src/components/NotebookContainer.stories.tsx +0 -32
- package/src/components/NotebookContainer.tsx +0 -124
- package/src/components/ScriptContainer.tsx +0 -69
- 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/schema.ts +0 -48
- /package/dist/lib/browser/{DeploymentDialog-65TWT6S5.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Compiler
|
|
3
|
+
} from "./chunk-ATTZUDT7.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createDeploy,
|
|
6
|
+
createFormat,
|
|
7
|
+
createTemplateSelect,
|
|
8
|
+
useDeployDeps
|
|
9
|
+
} from "./chunk-MUEVLYXJ.mjs";
|
|
10
|
+
import {
|
|
11
|
+
meta
|
|
12
|
+
} from "./chunk-WYR4QHPE.mjs";
|
|
13
|
+
|
|
14
|
+
// src/components/FrameContainer/FrameContainer.tsx
|
|
15
|
+
import React, { useEffect, useRef } from "react";
|
|
16
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
17
|
+
import { invariant } from "@dxos/invariant";
|
|
18
|
+
import { log } from "@dxos/log";
|
|
19
|
+
import { useClient } from "@dxos/react-client";
|
|
20
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
21
|
+
import { createIFramePort } from "@dxos/rpc-tunnel";
|
|
22
|
+
import { mx } from "@dxos/ui-theme";
|
|
23
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/FrameContainer/FrameContainer.tsx";
|
|
24
|
+
var FrameContainer = ({ containerUrl, result, debug = true }) => {
|
|
25
|
+
const client = useClient();
|
|
26
|
+
const iframeRef = useRef(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (iframeRef.current) {
|
|
29
|
+
const rpc = createProtoRpcPeer({
|
|
30
|
+
exposed: clientServiceBundle,
|
|
31
|
+
handlers: client._services.services,
|
|
32
|
+
port: createIFramePort({
|
|
33
|
+
channel: "frame",
|
|
34
|
+
iframe: iframeRef.current,
|
|
35
|
+
origin: "*"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
rpc.open().catch((e) => log.catch(e, void 0, {
|
|
39
|
+
F: __dxlog_file,
|
|
40
|
+
L: 41,
|
|
41
|
+
S: void 0,
|
|
42
|
+
C: (f, a) => f(...a)
|
|
43
|
+
}));
|
|
44
|
+
return () => {
|
|
45
|
+
rpc.close().catch((e) => log.catch(e, void 0, {
|
|
46
|
+
F: __dxlog_file,
|
|
47
|
+
L: 43,
|
|
48
|
+
S: void 0,
|
|
49
|
+
C: (f, a) => f(...a)
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, [
|
|
54
|
+
iframeRef
|
|
55
|
+
]);
|
|
56
|
+
invariant(result.sourceHash, "Source hash is required.", {
|
|
57
|
+
F: __dxlog_file,
|
|
58
|
+
L: 49,
|
|
59
|
+
S: void 0,
|
|
60
|
+
A: [
|
|
61
|
+
"result.sourceHash",
|
|
62
|
+
"'Source hash is required.'"
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
const sourceHash = Buffer.from(result.sourceHash).toString("hex");
|
|
66
|
+
const src = "bundle" in result ? `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(new TextDecoder().decode(Object.values(result.bundle)[0]))}` : void 0;
|
|
67
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("iframe", {
|
|
68
|
+
ref: iframeRef,
|
|
69
|
+
sandbox: "allow-scripts",
|
|
70
|
+
src,
|
|
71
|
+
style: {
|
|
72
|
+
width: "100%",
|
|
73
|
+
height: "100%"
|
|
74
|
+
}
|
|
75
|
+
}), debug && /* @__PURE__ */ React.createElement("div", {
|
|
76
|
+
className: "relative"
|
|
77
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
78
|
+
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")
|
|
79
|
+
}, /* @__PURE__ */ React.createElement("pre", {
|
|
80
|
+
className: "text-xs whitespace-break-spaces break-all p-2"
|
|
81
|
+
}, JSON.stringify({
|
|
82
|
+
timestamp: result.timestamp,
|
|
83
|
+
sourceHash,
|
|
84
|
+
error: "error" in result ? result.error : void 0,
|
|
85
|
+
src
|
|
86
|
+
}, void 0, 2)))));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/components/NotebookStack/NotebookMenu.tsx
|
|
90
|
+
import React2 from "react";
|
|
91
|
+
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
92
|
+
var NotebookMenu = ({ cell, onCellInsert, onCellDelete }) => {
|
|
93
|
+
const { t } = useTranslation(meta.id);
|
|
94
|
+
return /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
95
|
+
onClick: () => onCellInsert?.("script", cell?.id)
|
|
96
|
+
}, t("notebook cell insert script label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
97
|
+
onClick: () => onCellInsert?.("prompt", cell?.id)
|
|
98
|
+
}, t("notebook cell insert prompt label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
99
|
+
onClick: () => onCellInsert?.("query", cell?.id)
|
|
100
|
+
}, t("notebook cell insert query label")), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
101
|
+
onClick: () => onCellInsert?.("markdown", cell?.id)
|
|
102
|
+
}, t("notebook cell insert markdown label")), cell && onCellDelete && /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
103
|
+
onClick: () => onCellDelete?.(cell.id)
|
|
104
|
+
}, t("notebook cell delete label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/components/TypescriptEditor/TypescriptEditor.tsx
|
|
108
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
109
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
110
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
111
|
+
import { lintKeymap } from "@codemirror/lint";
|
|
112
|
+
import { Prec } from "@codemirror/state";
|
|
113
|
+
import { keymap } from "@codemirror/view";
|
|
114
|
+
import { tags } from "@lezer/highlight";
|
|
115
|
+
import { continueKeymap } from "@valtown/codemirror-continue";
|
|
116
|
+
import { tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from "@valtown/codemirror-ts";
|
|
117
|
+
import React3, { memo } from "react";
|
|
118
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
119
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
120
|
+
import { Domino } from "@dxos/ui";
|
|
121
|
+
import { InputModeExtensions, createBasicExtensions, createThemeExtensions, defaultStyles } from "@dxos/ui-editor";
|
|
122
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
123
|
+
import { isNonNullable } from "@dxos/util";
|
|
124
|
+
var TypescriptEditor = /* @__PURE__ */ memo(({ classNames, id, role = "article", inputMode = "vscode", env, options, initialValue, extensions, scrollTo, selection }) => {
|
|
125
|
+
const { themeMode } = useThemeContext();
|
|
126
|
+
const { parentRef, focusAttributes } = useTextEditor(() => ({
|
|
127
|
+
id,
|
|
128
|
+
initialValue,
|
|
129
|
+
selection,
|
|
130
|
+
scrollTo,
|
|
131
|
+
extensions: [
|
|
132
|
+
extensions,
|
|
133
|
+
createBasicExtensions({
|
|
134
|
+
highlightActiveLine: true,
|
|
135
|
+
indentWithTab: true,
|
|
136
|
+
lineNumbers: true,
|
|
137
|
+
lineWrapping: false,
|
|
138
|
+
scrollPastEnd: role !== "section",
|
|
139
|
+
search: true,
|
|
140
|
+
...options
|
|
141
|
+
}),
|
|
142
|
+
createThemeExtensions({
|
|
143
|
+
monospace: true,
|
|
144
|
+
themeMode,
|
|
145
|
+
syntaxHighlighting: true
|
|
146
|
+
}),
|
|
147
|
+
InputModeExtensions[inputMode],
|
|
148
|
+
javascript({
|
|
149
|
+
typescript: true
|
|
150
|
+
}),
|
|
151
|
+
autocompletion({
|
|
152
|
+
override: env ? [
|
|
153
|
+
tsAutocomplete()
|
|
154
|
+
] : void 0
|
|
155
|
+
}),
|
|
156
|
+
// Continues block comments when pressing Enter.
|
|
157
|
+
Prec.high(keymap.of(continueKeymap)),
|
|
158
|
+
keymap.of(completionKeymap),
|
|
159
|
+
keymap.of(lintKeymap),
|
|
160
|
+
// https://github.com/val-town/codemirror-ts
|
|
161
|
+
env && [
|
|
162
|
+
// TODO(burdon): Fix type.
|
|
163
|
+
tsFacet.of({
|
|
164
|
+
env,
|
|
165
|
+
path: `./src/${id}.ts`
|
|
166
|
+
}),
|
|
167
|
+
tsSync(),
|
|
168
|
+
tsLinter(),
|
|
169
|
+
tsHover({
|
|
170
|
+
renderTooltip: createTooltipRenderer(themeMode)
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
].filter(isNonNullable)
|
|
174
|
+
}), [
|
|
175
|
+
themeMode,
|
|
176
|
+
id,
|
|
177
|
+
extensions,
|
|
178
|
+
inputMode,
|
|
179
|
+
selection,
|
|
180
|
+
scrollTo,
|
|
181
|
+
env
|
|
182
|
+
]);
|
|
183
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
184
|
+
ref: parentRef,
|
|
185
|
+
className: mx2(classNames),
|
|
186
|
+
...focusAttributes
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
var createTooltipRenderer = (themeMode) => {
|
|
190
|
+
const theme = HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light);
|
|
191
|
+
const classFromKind = (_kind) => {
|
|
192
|
+
const kind = _kind.endsWith("Name") ? "name" : _kind;
|
|
193
|
+
const validTag = kind in tags;
|
|
194
|
+
if (!validTag) {
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
const tag = tags[kind];
|
|
198
|
+
if (typeof tag === "function") {
|
|
199
|
+
return "";
|
|
200
|
+
}
|
|
201
|
+
return theme.style([
|
|
202
|
+
tag
|
|
203
|
+
]) ?? "";
|
|
204
|
+
};
|
|
205
|
+
return (info) => {
|
|
206
|
+
const children = info.quickInfo?.displayParts?.map(({ kind, text }) => Domino.of("span").classNames(classFromKind(kind)).text(text)) ?? [];
|
|
207
|
+
return {
|
|
208
|
+
dom: Domino.of("div").classNames("xs:max-w-80 max-w-lg p-1 bg-base-surface rounded-sm border border-separator").children(...children).root
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// src/components/NotebookStack/NotebookStack.tsx
|
|
214
|
+
import React5 from "react";
|
|
215
|
+
import { DropdownMenu as DropdownMenu2, IconButton, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
216
|
+
import { Stack, StackItem } from "@dxos/react-ui-stack";
|
|
217
|
+
|
|
218
|
+
// src/components/NotebookStack/NotebookCell.tsx
|
|
219
|
+
import React4, { useCallback, useMemo } from "react";
|
|
220
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
221
|
+
import { Obj } from "@dxos/echo";
|
|
222
|
+
import { createDocAccessor } from "@dxos/echo-db";
|
|
223
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
224
|
+
import { TemplateEditor } from "@dxos/plugin-assistant";
|
|
225
|
+
import { useThemeContext as useThemeContext2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
226
|
+
import { QueryEditor } from "@dxos/react-ui-components";
|
|
227
|
+
import { EditorContent } from "@dxos/react-ui-editor";
|
|
228
|
+
import { createBasicExtensions as createBasicExtensions2, createDataExtensions, createMarkdownExtensions, createThemeExtensions as createThemeExtensions2, decorateMarkdown } from "@dxos/ui-editor";
|
|
229
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
230
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
231
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/NotebookStack/NotebookCell.tsx";
|
|
232
|
+
var editorStyles = "p-2 ps-3";
|
|
233
|
+
var valueStyles = "p-1 ps-3";
|
|
234
|
+
var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
235
|
+
const { t } = useTranslation2(meta.id);
|
|
236
|
+
const extensions = useMemo(() => {
|
|
237
|
+
return cell.source?.target ? [
|
|
238
|
+
createDataExtensions({
|
|
239
|
+
id: cell.id,
|
|
240
|
+
text: createDocAccessor(cell.source.target, [
|
|
241
|
+
"content"
|
|
242
|
+
])
|
|
243
|
+
})
|
|
244
|
+
].filter(isNonNullable2) : [];
|
|
245
|
+
}, [
|
|
246
|
+
cell.source?.target
|
|
247
|
+
]);
|
|
248
|
+
const explorerGraph = cell.graph?.target;
|
|
249
|
+
const handleQueryChange = useCallback((value) => {
|
|
250
|
+
invariant2(cell.source?.target, void 0, {
|
|
251
|
+
F: __dxlog_file2,
|
|
252
|
+
L: 63,
|
|
253
|
+
S: void 0,
|
|
254
|
+
A: [
|
|
255
|
+
"cell.source?.target",
|
|
256
|
+
""
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
Obj.change(cell.source.target, (s) => {
|
|
260
|
+
s.content = value;
|
|
261
|
+
});
|
|
262
|
+
}, [
|
|
263
|
+
cell
|
|
264
|
+
]);
|
|
265
|
+
switch (cell.type) {
|
|
266
|
+
case "markdown":
|
|
267
|
+
if (!cell.source?.target) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
return /* @__PURE__ */ React4.createElement(NotebookTextEditor, {
|
|
271
|
+
id: cell.id,
|
|
272
|
+
classNames: editorStyles,
|
|
273
|
+
initialValue: cell.source.target.content,
|
|
274
|
+
extensions
|
|
275
|
+
});
|
|
276
|
+
case "script":
|
|
277
|
+
if (!cell.source?.target) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TypescriptEditor, {
|
|
281
|
+
id: cell.id,
|
|
282
|
+
role: "section",
|
|
283
|
+
classNames: editorStyles,
|
|
284
|
+
initialValue: cell.source.target.content,
|
|
285
|
+
extensions,
|
|
286
|
+
env,
|
|
287
|
+
options: {
|
|
288
|
+
placeholder: t("notebook cell placeholder"),
|
|
289
|
+
highlightActiveLine: false,
|
|
290
|
+
lineNumbers: false
|
|
291
|
+
}
|
|
292
|
+
}), /* @__PURE__ */ React4.createElement(NotebookCellValue, {
|
|
293
|
+
cell,
|
|
294
|
+
graph
|
|
295
|
+
}));
|
|
296
|
+
case "query":
|
|
297
|
+
if (!cell.source?.target) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
301
|
+
className: mx3("h-full overflow-hidden grid", explorerGraph && !dragging && "grid-rows-[min-content_1fr]")
|
|
302
|
+
}, /* @__PURE__ */ React4.createElement(QueryEditor, {
|
|
303
|
+
id: cell.id,
|
|
304
|
+
classNames: [
|
|
305
|
+
editorStyles,
|
|
306
|
+
"border-b border-subdued-separator"
|
|
307
|
+
],
|
|
308
|
+
db,
|
|
309
|
+
value: cell.source.target.content,
|
|
310
|
+
onChange: handleQueryChange
|
|
311
|
+
}), explorerGraph && !dragging && /* @__PURE__ */ React4.createElement(Surface.Surface, {
|
|
312
|
+
role: "section",
|
|
313
|
+
limit: 1,
|
|
314
|
+
data: {
|
|
315
|
+
subject: explorerGraph
|
|
316
|
+
}
|
|
317
|
+
}));
|
|
318
|
+
// TODO(burdon): Use streaming response from Chat.
|
|
319
|
+
case "prompt":
|
|
320
|
+
if (!cell.prompt?.target) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TemplateEditor, {
|
|
324
|
+
id: cell.id,
|
|
325
|
+
template: cell.prompt.target.instructions,
|
|
326
|
+
lineNumbers: false,
|
|
327
|
+
classNames: editorStyles
|
|
328
|
+
}), /* @__PURE__ */ React4.createElement(NotebookPromptResult, {
|
|
329
|
+
cell,
|
|
330
|
+
promptResults
|
|
331
|
+
}));
|
|
332
|
+
default:
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
var NotebookCellValue = ({ cell, graph }) => {
|
|
337
|
+
const name = graph?.getExpressions()[cell.id]?.name;
|
|
338
|
+
const value = graph?.getValue(cell.id);
|
|
339
|
+
if (value == null) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
343
|
+
className: mx3("flex w-full bg-group-surface border-y border-subdued-separator text-description font-mono", valueStyles)
|
|
344
|
+
}, name && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("span", {
|
|
345
|
+
className: "text-success-text"
|
|
346
|
+
}, name), /* @__PURE__ */ React4.createElement("span", {
|
|
347
|
+
className: "text-description"
|
|
348
|
+
}, "\xA0=\xA0")), /* @__PURE__ */ React4.createElement("span", null, value));
|
|
349
|
+
};
|
|
350
|
+
var NotebookPromptResult = ({ cell, promptResults }) => {
|
|
351
|
+
if (!cell.prompt) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const value = promptResults?.[cell.prompt.dxn.toString()];
|
|
355
|
+
if (value == null) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
359
|
+
className: mx3("flex w-full bg-group-surface text-description border-y border-subdued-separator", valueStyles)
|
|
360
|
+
}, /* @__PURE__ */ React4.createElement(NotebookTextEditor, {
|
|
361
|
+
readOnly: true,
|
|
362
|
+
value
|
|
363
|
+
}));
|
|
364
|
+
};
|
|
365
|
+
var NotebookTextEditor = ({ extensions: extensionsProp, readOnly, ...props }) => {
|
|
366
|
+
const { t } = useTranslation2(meta.id);
|
|
367
|
+
const { themeMode } = useThemeContext2();
|
|
368
|
+
const extensions = useMemo(() => {
|
|
369
|
+
return [
|
|
370
|
+
createBasicExtensions2({
|
|
371
|
+
placeholder: t("notebook markdown placeholder"),
|
|
372
|
+
readOnly
|
|
373
|
+
}),
|
|
374
|
+
createThemeExtensions2({
|
|
375
|
+
themeMode,
|
|
376
|
+
syntaxHighlighting: true
|
|
377
|
+
}),
|
|
378
|
+
createMarkdownExtensions(),
|
|
379
|
+
decorateMarkdown(),
|
|
380
|
+
extensionsProp
|
|
381
|
+
].filter(isNonNullable2);
|
|
382
|
+
}, [
|
|
383
|
+
extensionsProp
|
|
384
|
+
]);
|
|
385
|
+
return /* @__PURE__ */ React4.createElement(EditorContent, {
|
|
386
|
+
...props,
|
|
387
|
+
extensions,
|
|
388
|
+
selectionEnd: true
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// src/components/NotebookStack/NotebookStack.tsx
|
|
393
|
+
var minSectionHeight = "min-h-[16rem]";
|
|
394
|
+
var NotebookStack = ({ classNames, notebook, onRearrange, ...props }) => {
|
|
395
|
+
return /* @__PURE__ */ React5.createElement(Stack, {
|
|
396
|
+
classNames,
|
|
397
|
+
orientation: "vertical",
|
|
398
|
+
size: "contain",
|
|
399
|
+
rail: true,
|
|
400
|
+
onRearrange
|
|
401
|
+
}, notebook?.cells.map((cell, i) => /* @__PURE__ */ React5.createElement(NotebookSection, {
|
|
402
|
+
key: i,
|
|
403
|
+
cell,
|
|
404
|
+
...props
|
|
405
|
+
})));
|
|
406
|
+
};
|
|
407
|
+
var NotebookSection = ({ cell, db, env, promptResults, onCellInsert, onCellDelete, ...props }) => {
|
|
408
|
+
const { t } = useTranslation3(meta.id);
|
|
409
|
+
const resizable = cell.type === "query";
|
|
410
|
+
return /* @__PURE__ */ React5.createElement(StackItem.Root, {
|
|
411
|
+
role: "section",
|
|
412
|
+
item: cell,
|
|
413
|
+
draggable: true,
|
|
414
|
+
classNames: resizable && minSectionHeight
|
|
415
|
+
}, /* @__PURE__ */ React5.createElement(StackItem.Heading, {
|
|
416
|
+
classNames: "h-full p-1 justify-between dx-attention-surface"
|
|
417
|
+
}, /* @__PURE__ */ React5.createElement(StackItem.DragHandle, {
|
|
418
|
+
asChild: true
|
|
419
|
+
}, /* @__PURE__ */ React5.createElement(IconButton, {
|
|
420
|
+
variant: "ghost",
|
|
421
|
+
icon: "ph--dots-six-vertical--regular",
|
|
422
|
+
iconOnly: true,
|
|
423
|
+
label: "Drag handle"
|
|
424
|
+
})), /* @__PURE__ */ React5.createElement(DropdownMenu2.Root, null, /* @__PURE__ */ React5.createElement(DropdownMenu2.Trigger, {
|
|
425
|
+
asChild: true
|
|
426
|
+
}, /* @__PURE__ */ React5.createElement(IconButton, {
|
|
427
|
+
variant: "ghost",
|
|
428
|
+
icon: "ph--dots-three--regular",
|
|
429
|
+
iconOnly: true,
|
|
430
|
+
label: t("notebook cell insert label")
|
|
431
|
+
})), /* @__PURE__ */ React5.createElement(NotebookMenu, {
|
|
432
|
+
cell,
|
|
433
|
+
onCellInsert,
|
|
434
|
+
onCellDelete
|
|
435
|
+
})), resizable && /* @__PURE__ */ React5.createElement(StackItem.ResizeHandle, null)), /* @__PURE__ */ React5.createElement(StackItem.DragPreview, null, ({ item: cell2 }) => /* @__PURE__ */ React5.createElement(StackItem.Content, {
|
|
436
|
+
classNames: "overflow-visible bg-group-surface border border-subdued-separator"
|
|
437
|
+
}, /* @__PURE__ */ React5.createElement(NotebookCell, {
|
|
438
|
+
db,
|
|
439
|
+
cell: cell2,
|
|
440
|
+
env,
|
|
441
|
+
dragging: true
|
|
442
|
+
}))), /* @__PURE__ */ React5.createElement(StackItem.Content, {
|
|
443
|
+
classNames: "overflow-visible"
|
|
444
|
+
}, /* @__PURE__ */ React5.createElement(NotebookCell, {
|
|
445
|
+
db,
|
|
446
|
+
cell,
|
|
447
|
+
env,
|
|
448
|
+
promptResults,
|
|
449
|
+
...props
|
|
450
|
+
})));
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// src/components/QueryEditor/QueryEditor.tsx
|
|
454
|
+
import React6, { useState } from "react";
|
|
455
|
+
import { ScriptTarget } from "typescript";
|
|
456
|
+
import queryApi from "@dxos/echo-query/api.d.ts?raw";
|
|
457
|
+
import { useAsyncEffect } from "@dxos/react-ui";
|
|
458
|
+
var GLOBALS = `
|
|
459
|
+
namespace QueryAPI {
|
|
460
|
+
${queryApi}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
declare global {
|
|
464
|
+
const Query: typeof QueryAPI.Query;
|
|
465
|
+
const Filter: typeof QueryAPI.Filter;
|
|
466
|
+
const Order: typeof QueryAPI.Order;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export {};
|
|
470
|
+
`;
|
|
471
|
+
var QueryEditor2 = (props) => {
|
|
472
|
+
const [compiler, setCompiler] = useState();
|
|
473
|
+
useAsyncEffect(async () => {
|
|
474
|
+
const compiler2 = new Compiler({
|
|
475
|
+
lib: [
|
|
476
|
+
"ES5"
|
|
477
|
+
],
|
|
478
|
+
target: ScriptTarget.ES2022
|
|
479
|
+
});
|
|
480
|
+
await compiler2.initialize(GLOBALS);
|
|
481
|
+
setCompiler(compiler2);
|
|
482
|
+
}, []);
|
|
483
|
+
if (!compiler) {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
return /* @__PURE__ */ React6.createElement(TypescriptEditor, {
|
|
487
|
+
...props,
|
|
488
|
+
env: compiler.environment
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// src/components/ScriptToolbar/ScriptToolbar.tsx
|
|
493
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
494
|
+
import React7, { useMemo as useMemo2 } from "react";
|
|
495
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
496
|
+
import { ElevationProvider, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
497
|
+
import { Menu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
|
|
498
|
+
var ScriptToolbar = ({ script, role, state, ...props }) => {
|
|
499
|
+
const { t } = useTranslation4(meta.id);
|
|
500
|
+
const options = useDeployDeps({
|
|
501
|
+
script
|
|
502
|
+
});
|
|
503
|
+
const menu = useMemo2(() => createToolbarActions({
|
|
504
|
+
state,
|
|
505
|
+
script,
|
|
506
|
+
t,
|
|
507
|
+
...options
|
|
508
|
+
}), [
|
|
509
|
+
state,
|
|
510
|
+
script,
|
|
511
|
+
options,
|
|
512
|
+
t
|
|
513
|
+
]);
|
|
514
|
+
const actions = useMenuActions(menu);
|
|
515
|
+
return /* @__PURE__ */ React7.createElement(ElevationProvider, {
|
|
516
|
+
elevation: role === "section" ? "positioned" : "base"
|
|
517
|
+
}, /* @__PURE__ */ React7.createElement(Menu.Root, {
|
|
518
|
+
...props,
|
|
519
|
+
...actions,
|
|
520
|
+
attendableId: Obj2.getDXN(script).toString()
|
|
521
|
+
}, /* @__PURE__ */ React7.createElement(Menu.Toolbar, null)));
|
|
522
|
+
};
|
|
523
|
+
var createToolbarActions = ({ state, script, ...options }) => Atom.make((get) => {
|
|
524
|
+
get(state.atom);
|
|
525
|
+
const templateSelect = createTemplateSelect(script);
|
|
526
|
+
const format = createFormat(script);
|
|
527
|
+
const gap = createGapSeparator();
|
|
528
|
+
const deploy = createDeploy({
|
|
529
|
+
state,
|
|
530
|
+
script,
|
|
531
|
+
...options
|
|
532
|
+
});
|
|
533
|
+
return {
|
|
534
|
+
nodes: [
|
|
535
|
+
...templateSelect.nodes,
|
|
536
|
+
...format.nodes,
|
|
537
|
+
...gap.nodes,
|
|
538
|
+
...deploy.nodes
|
|
539
|
+
],
|
|
540
|
+
edges: [
|
|
541
|
+
...templateSelect.edges,
|
|
542
|
+
...format.edges,
|
|
543
|
+
...gap.edges,
|
|
544
|
+
...deploy.edges
|
|
545
|
+
]
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// src/components/TestPanel/TestPanel.tsx
|
|
550
|
+
import React8, { forwardRef, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
551
|
+
import { log as log2 } from "@dxos/log";
|
|
552
|
+
import { Avatar, Icon, Input, ScrollArea, Toolbar, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
553
|
+
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
554
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
555
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/TestPanel/TestPanel.tsx";
|
|
556
|
+
var TestPanel = ({ classNames, functionUrl }) => {
|
|
557
|
+
const { t } = useTranslation5(meta.id);
|
|
558
|
+
const inputRef = useRef2(null);
|
|
559
|
+
const [input, setInput] = useState2("");
|
|
560
|
+
const [result, setResult] = useState2("");
|
|
561
|
+
const [state, setState] = useState2(null);
|
|
562
|
+
const [history, setHistory] = useState2([]);
|
|
563
|
+
const scrollerRef = useRef2(null);
|
|
564
|
+
const handleScroll = () => {
|
|
565
|
+
if (scrollerRef.current) {
|
|
566
|
+
scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
const controller = useRef2(null);
|
|
570
|
+
useEffect2(() => {
|
|
571
|
+
return () => {
|
|
572
|
+
handleStop();
|
|
573
|
+
};
|
|
574
|
+
}, []);
|
|
575
|
+
const handleStop = () => {
|
|
576
|
+
controller.current?.abort("stop");
|
|
577
|
+
controller.current = null;
|
|
578
|
+
};
|
|
579
|
+
const handleClear = () => {
|
|
580
|
+
handleStop();
|
|
581
|
+
setInput("");
|
|
582
|
+
setResult("");
|
|
583
|
+
setHistory([]);
|
|
584
|
+
inputRef.current?.focus();
|
|
585
|
+
};
|
|
586
|
+
const handleResponse = ({ text, data, error } = {}) => {
|
|
587
|
+
controller.current = null;
|
|
588
|
+
setHistory((history2) => [
|
|
589
|
+
...history2,
|
|
590
|
+
{
|
|
591
|
+
type: "response",
|
|
592
|
+
text,
|
|
593
|
+
data,
|
|
594
|
+
error
|
|
595
|
+
}
|
|
596
|
+
]);
|
|
597
|
+
setResult("");
|
|
598
|
+
setState(null);
|
|
599
|
+
handleScroll();
|
|
600
|
+
};
|
|
601
|
+
const handleRequest = async (input2) => {
|
|
602
|
+
try {
|
|
603
|
+
setState("pending");
|
|
604
|
+
let data = null;
|
|
605
|
+
if (input2.charAt(0) === "{") {
|
|
606
|
+
try {
|
|
607
|
+
const validJsonString = input2.replace(/'/g, '"').replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, '$1"$2"$3');
|
|
608
|
+
data = JSON.parse(validJsonString);
|
|
609
|
+
input2 = JSON.stringify(data, null, 2);
|
|
610
|
+
} catch (err) {
|
|
611
|
+
inputRef.current?.focus();
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
setInput("");
|
|
616
|
+
setResult("");
|
|
617
|
+
setHistory((history2) => [
|
|
618
|
+
...history2,
|
|
619
|
+
{
|
|
620
|
+
type: "request",
|
|
621
|
+
text: input2
|
|
622
|
+
}
|
|
623
|
+
]);
|
|
624
|
+
setTimeout(() => {
|
|
625
|
+
handleScroll();
|
|
626
|
+
});
|
|
627
|
+
controller.current = new AbortController();
|
|
628
|
+
const response = await fetch(functionUrl, {
|
|
629
|
+
signal: controller.current.signal,
|
|
630
|
+
method: "POST",
|
|
631
|
+
body: input2,
|
|
632
|
+
headers: {
|
|
633
|
+
"Content-Type": data ? "application/json" : "text/plain"
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
if (!response.ok) {
|
|
637
|
+
const text2 = await response.text();
|
|
638
|
+
handleResponse({
|
|
639
|
+
error: new Error(text2 || response.statusText || String(response.status))
|
|
640
|
+
});
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const contentType = response.headers.get("content-type");
|
|
644
|
+
if (contentType === "application/json") {
|
|
645
|
+
const data2 = await response.json();
|
|
646
|
+
handleResponse({
|
|
647
|
+
data: data2
|
|
648
|
+
});
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
setState("responding");
|
|
652
|
+
let text = "";
|
|
653
|
+
const reader = response.body.getReader();
|
|
654
|
+
const pump = async ({ done, value }) => {
|
|
655
|
+
text = text + new TextDecoder().decode(value);
|
|
656
|
+
if (!controller.current || done) {
|
|
657
|
+
handleResponse({
|
|
658
|
+
text
|
|
659
|
+
});
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
setResult(text);
|
|
663
|
+
setTimeout(() => {
|
|
664
|
+
handleScroll();
|
|
665
|
+
});
|
|
666
|
+
return reader.read().then(pump);
|
|
667
|
+
};
|
|
668
|
+
void reader.read().then(pump).catch((err) => {
|
|
669
|
+
if (err.name !== "AbortError") {
|
|
670
|
+
log2.catch(err, void 0, {
|
|
671
|
+
F: __dxlog_file3,
|
|
672
|
+
L: 162,
|
|
673
|
+
S: void 0,
|
|
674
|
+
C: (f, a) => f(...a)
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
} catch (err) {
|
|
679
|
+
if (err !== "stop") {
|
|
680
|
+
const error = err instanceof Error ? err : new Error(err);
|
|
681
|
+
handleResponse({
|
|
682
|
+
error
|
|
683
|
+
});
|
|
684
|
+
log2.catch(err, void 0, {
|
|
685
|
+
F: __dxlog_file3,
|
|
686
|
+
L: 169,
|
|
687
|
+
S: void 0,
|
|
688
|
+
C: (f, a) => f(...a)
|
|
689
|
+
});
|
|
690
|
+
} else {
|
|
691
|
+
handleResponse();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
696
|
+
className: mx4("flex flex-col h-full overflow-hidden", classNames)
|
|
697
|
+
}, /* @__PURE__ */ React8.createElement(MessageThread, {
|
|
698
|
+
ref: scrollerRef,
|
|
699
|
+
state,
|
|
700
|
+
result,
|
|
701
|
+
history
|
|
702
|
+
}), /* @__PURE__ */ React8.createElement(Toolbar.Root, null, /* @__PURE__ */ React8.createElement(Input.Root, null, /* @__PURE__ */ React8.createElement(Input.TextInput, {
|
|
703
|
+
ref: inputRef,
|
|
704
|
+
autoFocus: true,
|
|
705
|
+
placeholder: t("function request placeholder"),
|
|
706
|
+
value: input,
|
|
707
|
+
onChange: (ev) => setInput(ev.target.value),
|
|
708
|
+
onKeyDown: (ev) => ev.key === "Enter" && handleRequest(input)
|
|
709
|
+
})), /* @__PURE__ */ React8.createElement(Toolbar.IconButton, {
|
|
710
|
+
icon: "ph--play--regular",
|
|
711
|
+
size: 4,
|
|
712
|
+
label: "Execute",
|
|
713
|
+
iconOnly: true,
|
|
714
|
+
onClick: () => handleRequest(input)
|
|
715
|
+
}), /* @__PURE__ */ React8.createElement(Toolbar.IconButton, {
|
|
716
|
+
icon: state ? "ph--stop--regular" : "ph--trash--regular",
|
|
717
|
+
size: 4,
|
|
718
|
+
label: state ? "Stop" : "Clear",
|
|
719
|
+
iconOnly: true,
|
|
720
|
+
onClick: () => state ? handleStop() : handleClear()
|
|
721
|
+
})));
|
|
722
|
+
};
|
|
723
|
+
var MessageThread = /* @__PURE__ */ forwardRef(({ state, history, result }, forwardedRef) => {
|
|
724
|
+
return /* @__PURE__ */ React8.createElement(ScrollArea.Root, {
|
|
725
|
+
orientation: "vertical",
|
|
726
|
+
classNames: "h-full",
|
|
727
|
+
ref: forwardedRef
|
|
728
|
+
}, /* @__PURE__ */ React8.createElement(ScrollArea.Viewport, {
|
|
729
|
+
classNames: "gap-6 p-2"
|
|
730
|
+
}, history.map((message, i) => /* @__PURE__ */ React8.createElement("div", {
|
|
731
|
+
key: i,
|
|
732
|
+
className: "grid grid-cols-[2rem_1fr_2rem]"
|
|
733
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
734
|
+
className: "p-1"
|
|
735
|
+
}, message.type === "response" && /* @__PURE__ */ React8.createElement(RobotAvatar, null)), /* @__PURE__ */ React8.createElement("div", {
|
|
736
|
+
className: "overflow-auto"
|
|
737
|
+
}, /* @__PURE__ */ React8.createElement(MessageItem, {
|
|
738
|
+
message
|
|
739
|
+
})))), result?.length > 0 && /* @__PURE__ */ React8.createElement("div", {
|
|
740
|
+
className: "grid grid-cols-[2rem_1fr_2rem]"
|
|
741
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
742
|
+
className: "p-1"
|
|
743
|
+
}, state === "pending" && /* @__PURE__ */ React8.createElement(Icon, {
|
|
744
|
+
icon: "ph--spinner--regular",
|
|
745
|
+
size: 6,
|
|
746
|
+
classNames: "animate-spin"
|
|
747
|
+
}) || /* @__PURE__ */ React8.createElement(Icon, {
|
|
748
|
+
icon: "ph--robot--regular",
|
|
749
|
+
size: 6,
|
|
750
|
+
classNames: "animate-[pulse_1s_ease-in-out_infinite]"
|
|
751
|
+
})), /* @__PURE__ */ React8.createElement("div", {
|
|
752
|
+
className: "overflow-auto"
|
|
753
|
+
}, /* @__PURE__ */ React8.createElement(MessageItem, {
|
|
754
|
+
message: {
|
|
755
|
+
type: "response",
|
|
756
|
+
text: result
|
|
757
|
+
}
|
|
758
|
+
})))));
|
|
759
|
+
});
|
|
760
|
+
var MessageItem = ({ classNames, message }) => {
|
|
761
|
+
const { type, text, data, error } = message;
|
|
762
|
+
const wrapper = "p-1 px-2 rounded-md bg-hover-surface overflow-auto";
|
|
763
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
764
|
+
className: mx4("flex", type === "request" ? "ml-[1rem] justify-end" : "mr-[1rem]", classNames)
|
|
765
|
+
}, error && /* @__PURE__ */ React8.createElement("div", {
|
|
766
|
+
className: mx4(wrapper, "whitespace-pre text-error-text")
|
|
767
|
+
}, String(error)), text !== void 0 && /* @__PURE__ */ React8.createElement("div", {
|
|
768
|
+
className: mx4(wrapper, type === "request" && "bg-primary-500 dark:bg-primary-600")
|
|
769
|
+
}, text || "\xD8"), data && /* @__PURE__ */ React8.createElement(SyntaxHighlighter, {
|
|
770
|
+
language: "json",
|
|
771
|
+
className: mx4(wrapper, "text-xs")
|
|
772
|
+
}, JSON.stringify(data, null, 2)));
|
|
773
|
+
};
|
|
774
|
+
var RobotAvatar = () => /* @__PURE__ */ React8.createElement(Avatar.Root, null, /* @__PURE__ */ React8.createElement(Avatar.Content, {
|
|
775
|
+
size: 6,
|
|
776
|
+
variant: "circle",
|
|
777
|
+
icon: "ph--robot--regular"
|
|
778
|
+
}));
|
|
779
|
+
|
|
780
|
+
export {
|
|
781
|
+
FrameContainer,
|
|
782
|
+
NotebookMenu,
|
|
783
|
+
TypescriptEditor,
|
|
784
|
+
NotebookStack,
|
|
785
|
+
QueryEditor2 as QueryEditor,
|
|
786
|
+
ScriptToolbar,
|
|
787
|
+
TestPanel
|
|
788
|
+
};
|
|
789
|
+
//# sourceMappingURL=chunk-PLDBKKYO.mjs.map
|