@dxos/plugin-script 0.8.3 → 0.8.4-main.1068cf700f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs +845 -0
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +69 -0
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs +113 -0
- package/dist/lib/browser/chunk-3BSF5BIA.mjs.map +7 -0
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs +105 -0
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs +270 -0
- package/dist/lib/browser/chunk-BKGEAUUH.mjs.map +7 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs +137 -0
- package/dist/lib/browser/chunk-BU6CGVU2.mjs.map +7 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs +35 -0
- package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +7 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs +110 -0
- package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs +609 -0
- package/dist/lib/browser/chunk-LYMPME7J.mjs.map +7 -0
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs +557 -0
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6ZHHWU6S.mjs → chunk-WYR4QHPE.mjs} +9 -6
- package/dist/lib/browser/chunk-WYR4QHPE.mjs.map +7 -0
- package/dist/lib/browser/compiler-VPUVTFQD.mjs +161 -0
- package/dist/lib/browser/compiler-VPUVTFQD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +147 -109
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs +83 -0
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs +140 -0
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs.map +7 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs +36 -0
- package/dist/lib/browser/settings-5SF77MRH.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +10 -0
- package/dist/lib/browser/types/index.mjs +18 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs +846 -0
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +70 -0
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs +610 -0
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs +271 -0
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AEB5TPEW.mjs → chunk-5HSJPAK7.mjs} +9 -6
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs +558 -0
- package/dist/lib/node-esm/chunk-ECRSTVR6.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-KRVL7UYI.mjs +114 -0
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +112 -0
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs +138 -0
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs +107 -0
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +36 -0
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs +162 -0
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +147 -109
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs +84 -0
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs +141 -0
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs.map +7 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs +37 -0
- package/dist/lib/node-esm/settings-ILI762CY.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +11 -0
- package/dist/lib/node-esm/templates/index.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +19 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +2 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler/index.d.ts +3 -0
- package/dist/types/src/capabilities/compiler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +7 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +10 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +4 -4
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +244 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +8 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +249 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/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/ScriptContainer.d.ts +7 -8
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +7 -8
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +246 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +6 -4
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +5 -4
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +5 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/e2e/ai.test.d.ts +2 -0
- package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
- package/dist/types/src/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 +18 -32
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +4 -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 +6 -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 -3
- 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 +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/templates/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/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +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/gmail.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +54 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +3 -0
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +3 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/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 +94 -176
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +100 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +40 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- 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 +6 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +7 -7
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +128 -83
- package/src/ScriptPlugin.tsx +59 -78
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +24 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +56 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{artifact-definition.ts → artifact-definition/artifact-definition.ts} +105 -106
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/compiler/compiler.ts +103 -0
- package/src/capabilities/compiler/index.ts +7 -0
- package/src/capabilities/index.ts +6 -10
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +75 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +119 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +33 -0
- package/src/compiler/compiler.ts +11 -4
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +47 -24
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -54
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +8 -5
- package/src/components/FrameContainer/frame.tsx +1 -1
- package/src/components/NotebookContainer.stories.tsx +87 -0
- package/src/components/NotebookContainer.tsx +271 -0
- package/src/components/NotebookStack/NotebookCell.tsx +217 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +55 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/QueryEditor/QueryEditor.stories.tsx +100 -0
- package/src/components/QueryEditor/QueryEditor.tsx +47 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptContainer.tsx +52 -35
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +57 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +37 -33
- package/src/components/Settings/ScriptObjectSettings.tsx +151 -48
- package/src/components/Settings/ScriptPluginSettings.tsx +43 -48
- package/src/components/TestPanel/TestContainer.tsx +13 -7
- package/src/components/TestPanel/TestPanel.tsx +66 -41
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +86 -33
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +84 -81
- package/src/components/index.ts +3 -0
- package/src/e2e/ai.test.ts +92 -0
- package/src/e2e/deploy.test.ts +64 -0
- package/src/hooks/deploy.ts +49 -42
- package/src/hooks/format.ts +9 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +21 -24
- package/src/hooks/useCompiler.ts +24 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -1
- package/src/meta.ts +9 -7
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/compute-graph.ts +230 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +451 -0
- package/src/templates/anthropic.ts +42 -0
- package/src/templates/chess-bot.ts +58 -0
- package/src/templates/commentary.ts +230 -0
- package/src/templates/data-generator.ts +11 -5
- package/src/templates/discord.ts +12 -4
- package/src/templates/email.ts +2 -2
- package/src/templates/forex-effect.ts +24 -25
- package/src/templates/forex.ts +9 -6
- package/src/templates/gmail.ts +35 -65
- package/src/templates/index.ts +26 -11
- package/src/templates/ping.ts +17 -0
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/simulator.test.ts +40 -0
- package/src/translations.ts +42 -12
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +45 -0
- package/src/types/capabilities.ts +17 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +9 -0
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +38 -61
- package/src/util/functions.ts +58 -25
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-RPPPWEEL.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs +0 -261
- package/dist/lib/browser/ScriptContainer-RSN52NH7.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs +0 -64
- package/dist/lib/browser/app-graph-builder-5Z3MUX4N.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs +0 -249
- package/dist/lib/browser/artifact-definition-A4TBQL75.mjs.map +0 -7
- package/dist/lib/browser/chunk-3FU4QZVP.mjs +0 -364
- package/dist/lib/browser/chunk-3FU4QZVP.mjs.map +0 -7
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs +0 -557
- package/dist/lib/browser/chunk-3JLR2SHJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-6ZHHWU6S.mjs.map +0 -7
- package/dist/lib/browser/chunk-LA66DQGU.mjs +0 -153
- package/dist/lib/browser/chunk-LA66DQGU.mjs.map +0 -7
- package/dist/lib/browser/chunk-QJH7I2UV.mjs +0 -233
- package/dist/lib/browser/chunk-QJH7I2UV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs +0 -40
- package/dist/lib/browser/chunk-WB3X5Z7Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-YSQMXTYO.mjs +0 -15
- package/dist/lib/browser/chunk-YSQMXTYO.mjs.map +0 -7
- package/dist/lib/browser/compiler-W4BYJYTL.mjs +0 -82
- package/dist/lib/browser/compiler-W4BYJYTL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs +0 -90
- package/dist/lib/browser/intent-resolver-JOJNH4UX.mjs.map +0 -7
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs +0 -105
- package/dist/lib/browser/react-surface-7BKUWL2U.mjs.map +0 -7
- package/dist/lib/browser/settings-Z22D6JVJ.mjs +0 -24
- package/dist/lib/browser/settings-Z22D6JVJ.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -13
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs +0 -33
- package/dist/lib/node/DeploymentDialog-C3EEYGRH.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs +0 -278
- package/dist/lib/node/ScriptContainer-CAC7AISY.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs +0 -80
- package/dist/lib/node/app-graph-builder-25OOTBW4.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs +0 -265
- package/dist/lib/node/artifact-definition-QKZI6PTO.cjs.map +0 -7
- package/dist/lib/node/chunk-AU2FOE26.cjs +0 -369
- package/dist/lib/node/chunk-AU2FOE26.cjs.map +0 -7
- package/dist/lib/node/chunk-BUOBOT3V.cjs +0 -179
- package/dist/lib/node/chunk-BUOBOT3V.cjs.map +0 -7
- package/dist/lib/node/chunk-HCRW6T3G.cjs +0 -60
- package/dist/lib/node/chunk-HCRW6T3G.cjs.map +0 -7
- package/dist/lib/node/chunk-OSBMUJ4T.cjs +0 -580
- package/dist/lib/node/chunk-OSBMUJ4T.cjs.map +0 -7
- package/dist/lib/node/chunk-QG2X6J74.cjs +0 -52
- package/dist/lib/node/chunk-QG2X6J74.cjs.map +0 -7
- package/dist/lib/node/chunk-YO5W2IPQ.cjs +0 -251
- package/dist/lib/node/chunk-YO5W2IPQ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZEV3VARQ.cjs +0 -34
- package/dist/lib/node/chunk-ZEV3VARQ.cjs.map +0 -7
- package/dist/lib/node/compiler-TFSJRLL4.cjs +0 -104
- package/dist/lib/node/compiler-TFSJRLL4.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -225
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs +0 -100
- package/dist/lib/node/intent-resolver-BQ2NKEM7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-EUKPDFU3.cjs +0 -120
- package/dist/lib/node/react-surface-EUKPDFU3.cjs.map +0 -7
- package/dist/lib/node/settings-WO53FLYZ.cjs +0 -38
- package/dist/lib/node/settings-WO53FLYZ.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -34
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-IA4CH6WZ.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs +0 -262
- package/dist/lib/node-esm/ScriptContainer-4IOOIPBF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs +0 -65
- package/dist/lib/node-esm/app-graph-builder-IOOUTHV2.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-4XRYAP54.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs +0 -16
- package/dist/lib/node-esm/chunk-2KJYPUQD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AEB5TPEW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs +0 -558
- package/dist/lib/node-esm/chunk-B4TP3LSZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs +0 -234
- package/dist/lib/node-esm/chunk-MJJQBUOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs +0 -154
- package/dist/lib/node-esm/chunk-T7XDCUTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs +0 -41
- package/dist/lib/node-esm/chunk-UESZKXLR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs +0 -365
- package/dist/lib/node-esm/chunk-W2DAXWHA.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs +0 -83
- package/dist/lib/node-esm/compiler-7PQ4D43R.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs +0 -91
- package/dist/lib/node-esm/intent-resolver-HTM5PSRZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs +0 -106
- package/dist/lib/node-esm/react-surface-6UO64YOS.mjs.map +0 -7
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs +0 -25
- package/dist/lib/node-esm/settings-KZEGCDYX.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -14
- 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/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler.d.ts +0 -4
- package/dist/types/src/capabilities/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/templates/echo.d.ts +0 -6
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -40
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -64
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/compiler.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -80
- package/src/capabilities/react-surface.tsx +0 -89
- package/src/capabilities/settings.ts +0 -21
- package/src/events.ts +0 -11
- package/src/templates/chess.ts +0 -47
- package/src/templates/echo.ts +0 -8
- package/src/types.ts +0 -42
- /package/dist/lib/browser/{DeploymentDialog-RPPPWEEL.mjs.map → DeploymentDialog-XUAFCNI7.mjs.map} +0 -0
- /package/dist/lib/browser/{types.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-IA4CH6WZ.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types.mjs.map → browser/templates/index.mjs.map} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { trim } from '@dxos/util';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Evaluate the script (with dependencies as arguments).
|
|
9
|
+
*/
|
|
10
|
+
export const evalScript = async (code: string, deps: Record<string, any> = {}) => {
|
|
11
|
+
// Create a sandboxed environment that blocks access to window and document.
|
|
12
|
+
const sandbox = {
|
|
13
|
+
...deps,
|
|
14
|
+
|
|
15
|
+
// Block access to global objects.
|
|
16
|
+
console: undefined,
|
|
17
|
+
document: undefined,
|
|
18
|
+
global: undefined,
|
|
19
|
+
globalThis: undefined,
|
|
20
|
+
self: undefined,
|
|
21
|
+
window: undefined,
|
|
22
|
+
|
|
23
|
+
// Allow some safe globals.
|
|
24
|
+
Array,
|
|
25
|
+
Boolean,
|
|
26
|
+
Date,
|
|
27
|
+
Error,
|
|
28
|
+
JSON,
|
|
29
|
+
Map,
|
|
30
|
+
Math,
|
|
31
|
+
Number,
|
|
32
|
+
Object,
|
|
33
|
+
Promise,
|
|
34
|
+
RegExp,
|
|
35
|
+
Set,
|
|
36
|
+
String,
|
|
37
|
+
|
|
38
|
+
// Functions.
|
|
39
|
+
isFinite,
|
|
40
|
+
isNaN,
|
|
41
|
+
parseFloat,
|
|
42
|
+
parseInt,
|
|
43
|
+
|
|
44
|
+
// Note: undefined and null are not included as they are keywords, not variables.
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Create function with all sandbox keys as parameters.
|
|
48
|
+
const sandboxKeys = Object.keys(sandbox);
|
|
49
|
+
const sandboxValues = Object.values(sandbox);
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
52
|
+
const fn = new Function(
|
|
53
|
+
...sandboxKeys,
|
|
54
|
+
trim`
|
|
55
|
+
'use strict';
|
|
56
|
+
return ${code};
|
|
57
|
+
`,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return fn(...sandboxValues);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Globals.
|
|
65
|
+
*/
|
|
66
|
+
export const builtIns = new Set([
|
|
67
|
+
// Types.
|
|
68
|
+
'Array',
|
|
69
|
+
'Date',
|
|
70
|
+
'Error',
|
|
71
|
+
'JSON',
|
|
72
|
+
'Map',
|
|
73
|
+
'Math',
|
|
74
|
+
'Number',
|
|
75
|
+
'Object',
|
|
76
|
+
'Promise',
|
|
77
|
+
'RegExp',
|
|
78
|
+
'Set',
|
|
79
|
+
'String',
|
|
80
|
+
|
|
81
|
+
// Functions.
|
|
82
|
+
'isFinite',
|
|
83
|
+
'isNaN',
|
|
84
|
+
'parseFloat',
|
|
85
|
+
'parseInt',
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Default system definitions.
|
|
90
|
+
*/
|
|
91
|
+
export const systemDefinitions = trim`
|
|
92
|
+
interface Array<T> { length: number; [n: number]: T; }
|
|
93
|
+
interface Boolean {}
|
|
94
|
+
interface Function {}
|
|
95
|
+
interface IArguments {}
|
|
96
|
+
interface Number {}
|
|
97
|
+
interface Object {}
|
|
98
|
+
interface RegExp {}
|
|
99
|
+
interface String { length: number; }
|
|
100
|
+
|
|
101
|
+
interface CallableFunction extends Function {}
|
|
102
|
+
interface NewableFunction extends Function {}
|
|
103
|
+
|
|
104
|
+
declare var console: { log(...args: any[]): void };
|
|
105
|
+
`;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { NotebookVirtualParser, VirtualTypeScriptParser } from './vfs-parser';
|
|
8
|
+
|
|
9
|
+
describe('vfs-parser', () => {
|
|
10
|
+
test('parse simple assignments', () => {
|
|
11
|
+
const parser = new VirtualTypeScriptParser();
|
|
12
|
+
|
|
13
|
+
const tests = [
|
|
14
|
+
{
|
|
15
|
+
input: 'const a = 1',
|
|
16
|
+
expected: {
|
|
17
|
+
name: 'a',
|
|
18
|
+
type: 'variable',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
input: 'a = 1',
|
|
23
|
+
expected: {
|
|
24
|
+
name: 'a',
|
|
25
|
+
type: 'variable',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
tests.forEach(({ input, expected }) => {
|
|
31
|
+
const result = parser.parseExpression(input);
|
|
32
|
+
expect(result, input).toMatchObject(expected);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('parse variable with references', () => {
|
|
37
|
+
const parser = new VirtualTypeScriptParser();
|
|
38
|
+
|
|
39
|
+
const tests = [
|
|
40
|
+
{
|
|
41
|
+
input: 'const y = x * 2',
|
|
42
|
+
expected: {
|
|
43
|
+
name: 'y',
|
|
44
|
+
type: 'variable',
|
|
45
|
+
references: ['x'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
input: 'y = x * 2',
|
|
50
|
+
expected: {
|
|
51
|
+
name: 'y',
|
|
52
|
+
type: 'variable',
|
|
53
|
+
references: ['x'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
tests.forEach(({ input, expected }) => {
|
|
59
|
+
const result = parser.parseExpression(input);
|
|
60
|
+
expect(result, input).toMatchObject(expected);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('parse simple expression with references', () => {
|
|
65
|
+
const parser = new VirtualTypeScriptParser();
|
|
66
|
+
|
|
67
|
+
const result = parser.parseExpression('(a + b) * c');
|
|
68
|
+
expect(result).toMatchObject({
|
|
69
|
+
references: ['a', 'b', 'c'],
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('parse single expression', () => {
|
|
74
|
+
const parser = new VirtualTypeScriptParser();
|
|
75
|
+
|
|
76
|
+
const result = parser.parseExpression('const add = (a: number, b: number): number => a + b;');
|
|
77
|
+
expect(result).toMatchObject({
|
|
78
|
+
name: 'add',
|
|
79
|
+
type: 'function',
|
|
80
|
+
valueType: expect.stringContaining('(a: number, b: number) => number'),
|
|
81
|
+
returnType: 'number',
|
|
82
|
+
parameters: [
|
|
83
|
+
{ name: 'a', type: 'number' },
|
|
84
|
+
{ name: 'b', type: 'number' },
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('analyze multiple files', () => {
|
|
90
|
+
const parser = new VirtualTypeScriptParser();
|
|
91
|
+
|
|
92
|
+
const files = [
|
|
93
|
+
{
|
|
94
|
+
filename: '/test.ts',
|
|
95
|
+
content: 'export const PI = 3.14159;\nexport function square(x: number): number { return x * x; }',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
const results = parser.analyzeFiles(files);
|
|
100
|
+
expect(results).toHaveLength(2);
|
|
101
|
+
expect(results[0]).toMatchObject({
|
|
102
|
+
name: 'PI',
|
|
103
|
+
type: 'variable',
|
|
104
|
+
valueType: '3.14159',
|
|
105
|
+
});
|
|
106
|
+
expect(results[1]).toMatchObject({
|
|
107
|
+
name: 'square',
|
|
108
|
+
type: 'function',
|
|
109
|
+
returnType: 'number',
|
|
110
|
+
parameters: [{ name: 'x', type: 'number' }],
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('notebook cell analysis', () => {
|
|
115
|
+
const parser = new NotebookVirtualParser();
|
|
116
|
+
|
|
117
|
+
const cells = [
|
|
118
|
+
{ id: 'cell1', code: 'const x: number = 10;' },
|
|
119
|
+
{ id: 'cell2', code: 'const y = x * 2;' },
|
|
120
|
+
{ id: 'cell3', code: 'console.log(y);' },
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const analysis = parser.analyzeNotebook(cells);
|
|
124
|
+
|
|
125
|
+
// Cell 1 exports x.
|
|
126
|
+
const cell1 = analysis.get('cell1');
|
|
127
|
+
expect(cell1?.exports).toHaveLength(1);
|
|
128
|
+
expect(cell1?.exports[0]).toMatchObject({
|
|
129
|
+
name: 'x',
|
|
130
|
+
type: 'variable',
|
|
131
|
+
valueType: 'number',
|
|
132
|
+
});
|
|
133
|
+
expect(cell1?.imports).toHaveLength(0);
|
|
134
|
+
|
|
135
|
+
// Cell 2 imports x and exports y.
|
|
136
|
+
const cell2 = analysis.get('cell2');
|
|
137
|
+
expect(cell2?.exports).toHaveLength(1);
|
|
138
|
+
expect(cell2?.exports[0]).toMatchObject({
|
|
139
|
+
name: 'y',
|
|
140
|
+
type: 'variable',
|
|
141
|
+
});
|
|
142
|
+
expect(cell2?.imports).toContain('x');
|
|
143
|
+
|
|
144
|
+
// Cell 3 imports y.
|
|
145
|
+
const cell3 = analysis.get('cell3');
|
|
146
|
+
expect(cell3?.exports).toHaveLength(0);
|
|
147
|
+
expect(cell3?.imports).toContain('y');
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createSystem, createVirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
6
|
+
import ts from 'typescript';
|
|
7
|
+
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
|
|
10
|
+
import { builtIns, systemDefinitions } from './eval';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default system definitions.
|
|
14
|
+
*/
|
|
15
|
+
const systemFiles: VirtualFile[] = [
|
|
16
|
+
{
|
|
17
|
+
filename: '/lib.d.ts',
|
|
18
|
+
content: systemDefinitions,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export type ParsedExpression = {
|
|
23
|
+
name?: string;
|
|
24
|
+
type?: 'function' | 'variable' | 'class' | 'interface';
|
|
25
|
+
value?: any;
|
|
26
|
+
valueType?: string;
|
|
27
|
+
parameters?: Array<{ name: string; type: string }>;
|
|
28
|
+
returnType?: string;
|
|
29
|
+
references?: string[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type VirtualFile = {
|
|
33
|
+
filename: string;
|
|
34
|
+
content: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* TypeScript parser using Virtual File System for browser compatibility.
|
|
39
|
+
* This provides full TypeScript analysis including type information.
|
|
40
|
+
*/
|
|
41
|
+
export class VirtualTypeScriptParser {
|
|
42
|
+
protected compilerOptions: ts.CompilerOptions = {
|
|
43
|
+
target: ts.ScriptTarget.ES2020,
|
|
44
|
+
module: ts.ModuleKind.ESNext,
|
|
45
|
+
strict: true,
|
|
46
|
+
esModuleInterop: true,
|
|
47
|
+
skipLibCheck: true,
|
|
48
|
+
forceConsistentCasingInfilenames: true,
|
|
49
|
+
jsx: ts.JsxEmit.React,
|
|
50
|
+
noLib: true, // Don't automatically include default lib files.
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Parse a single expression or statement.
|
|
55
|
+
*/
|
|
56
|
+
parseExpression(input: string): ParsedExpression {
|
|
57
|
+
invariant(input.trim() !== '', 'input must not be empty');
|
|
58
|
+
const files: VirtualFile[] = [{ filename: '/temp.ts', content: input }];
|
|
59
|
+
const analysis = this.analyzeFiles(files);
|
|
60
|
+
|
|
61
|
+
// If no declarations found, check for standalone expression references.
|
|
62
|
+
if (analysis.length === 0) {
|
|
63
|
+
const sourcefilename = '/temp.ts';
|
|
64
|
+
const env = this.createEnvironment([{ filename: sourcefilename, content: input }]);
|
|
65
|
+
const sourceFile = env.getSourceFile(sourcefilename);
|
|
66
|
+
const typeChecker = env.languageService.getProgram()?.getTypeChecker();
|
|
67
|
+
|
|
68
|
+
if (sourceFile && typeChecker) {
|
|
69
|
+
// Check for assignment expressions.
|
|
70
|
+
const assignmentInfo = this.findAssignmentExpression(sourceFile, typeChecker);
|
|
71
|
+
if (assignmentInfo) {
|
|
72
|
+
return assignmentInfo;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const references = this.findAllReferences(sourceFile, typeChecker);
|
|
76
|
+
return { references };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return analysis[0];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Analyze multiple files with full type information.
|
|
85
|
+
*/
|
|
86
|
+
analyzeFiles(files: VirtualFile[]): ParsedExpression[] {
|
|
87
|
+
const env = this.createEnvironment(files);
|
|
88
|
+
const results: ParsedExpression[] = [];
|
|
89
|
+
const typeChecker = env.languageService.getProgram()?.getTypeChecker();
|
|
90
|
+
|
|
91
|
+
// Analyze each file.
|
|
92
|
+
files.forEach((file) => {
|
|
93
|
+
const sourceFile = env.getSourceFile(file.filename);
|
|
94
|
+
if (!sourceFile || !typeChecker) return;
|
|
95
|
+
|
|
96
|
+
const fileResults = this.analyzeSourceFile(sourceFile, typeChecker);
|
|
97
|
+
results.push(...fileResults);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Analyze a source file with type information.
|
|
105
|
+
*/
|
|
106
|
+
protected analyzeSourceFile(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression[] {
|
|
107
|
+
const results: ParsedExpression[] = [];
|
|
108
|
+
|
|
109
|
+
const visit = (node: ts.Node) => {
|
|
110
|
+
// Function declarations.
|
|
111
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
112
|
+
const symbol = typeChecker.getSymbolAtLocation(node.name);
|
|
113
|
+
const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
114
|
+
const signature = type && typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];
|
|
115
|
+
|
|
116
|
+
results.push({
|
|
117
|
+
name: node.name.text,
|
|
118
|
+
type: 'function',
|
|
119
|
+
parameters: this.extractParameters(signature, typeChecker),
|
|
120
|
+
returnType: signature ? typeChecker.typeToString(signature.getReturnType()) : 'any',
|
|
121
|
+
references: this.findReferences(node, sourceFile, typeChecker),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Variable declarations.
|
|
126
|
+
else if (ts.isVariableStatement(node)) {
|
|
127
|
+
node.declarationList.declarations.forEach((declaration) => {
|
|
128
|
+
if (ts.isIdentifier(declaration.name)) {
|
|
129
|
+
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
130
|
+
const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
|
|
131
|
+
|
|
132
|
+
let kind: 'function' | 'variable' = 'variable';
|
|
133
|
+
let parameters: Array<{ name: string; type: string }> | undefined;
|
|
134
|
+
let returnType: string | undefined;
|
|
135
|
+
let value: any;
|
|
136
|
+
|
|
137
|
+
// Get the type string.
|
|
138
|
+
const typeString = type ? typeChecker.typeToString(type) : 'any';
|
|
139
|
+
|
|
140
|
+
// Check if it's a function.
|
|
141
|
+
if (declaration.initializer) {
|
|
142
|
+
if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
|
|
143
|
+
kind = 'function';
|
|
144
|
+
const funcType = typeChecker.getTypeAtLocation(declaration.initializer);
|
|
145
|
+
const signature = typeChecker.getSignaturesOfType(funcType, ts.SignatureKind.Call)[0];
|
|
146
|
+
if (signature) {
|
|
147
|
+
parameters = this.extractParameters(signature, typeChecker);
|
|
148
|
+
returnType = typeChecker.typeToString(signature.getReturnType());
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
// Extract literal values
|
|
152
|
+
if (ts.isNumericLiteral(declaration.initializer)) {
|
|
153
|
+
value = Number(declaration.initializer.text);
|
|
154
|
+
} else if (ts.isStringLiteral(declaration.initializer)) {
|
|
155
|
+
value = declaration.initializer.text;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Find references in the initializer only.
|
|
161
|
+
const refs = declaration.initializer
|
|
162
|
+
? this.findReferences(declaration.initializer, sourceFile, typeChecker)
|
|
163
|
+
: [];
|
|
164
|
+
|
|
165
|
+
results.push({
|
|
166
|
+
name: declaration.name.text,
|
|
167
|
+
type: kind,
|
|
168
|
+
valueType: typeString,
|
|
169
|
+
value,
|
|
170
|
+
parameters,
|
|
171
|
+
returnType,
|
|
172
|
+
references: refs,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Class declarations.
|
|
179
|
+
else if (ts.isClassDeclaration(node) && node.name) {
|
|
180
|
+
results.push({
|
|
181
|
+
name: node.name.text,
|
|
182
|
+
type: 'class',
|
|
183
|
+
references: this.findReferences(node, sourceFile, typeChecker),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Interface declarations.
|
|
188
|
+
else if (ts.isInterfaceDeclaration(node)) {
|
|
189
|
+
results.push({
|
|
190
|
+
name: node.name.text,
|
|
191
|
+
type: 'interface',
|
|
192
|
+
references: this.findReferences(node, sourceFile, typeChecker),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
ts.forEachChild(node, visit);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
visit(sourceFile);
|
|
200
|
+
return results;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Extract parameter information from a signature.
|
|
205
|
+
*/
|
|
206
|
+
private extractParameters(
|
|
207
|
+
signature: ts.Signature | undefined,
|
|
208
|
+
typeChecker: ts.TypeChecker,
|
|
209
|
+
): Array<{ name: string; type: string }> {
|
|
210
|
+
if (!signature) return [];
|
|
211
|
+
|
|
212
|
+
return signature.parameters.map((param) => ({
|
|
213
|
+
name: param.getName(),
|
|
214
|
+
type: typeChecker.typeToString(typeChecker.getTypeOfSymbolAtLocation(param, param.valueDeclaration!)),
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Find all references to variables used in a node.
|
|
220
|
+
*/
|
|
221
|
+
private findReferences(node: ts.Node, _sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {
|
|
222
|
+
const references = new Set<string>();
|
|
223
|
+
const localSymbols = new Set<string>();
|
|
224
|
+
|
|
225
|
+
// First, collect local symbols (parameters, local variables).
|
|
226
|
+
const collectLocalSymbols = (node: ts.Node) => {
|
|
227
|
+
if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
228
|
+
node.parameters.forEach((param) => {
|
|
229
|
+
if (ts.isIdentifier(param.name)) {
|
|
230
|
+
localSymbols.add(param.name.text);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name)) {
|
|
236
|
+
localSymbols.add(node.name.text);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ts.forEachChild(node, collectLocalSymbols);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
collectLocalSymbols(node);
|
|
243
|
+
|
|
244
|
+
// Then find all identifier references.
|
|
245
|
+
const findRefs = (node: ts.Node) => {
|
|
246
|
+
if (ts.isIdentifier(node)) {
|
|
247
|
+
// Skip if it's a local symbol.
|
|
248
|
+
if (!localSymbols.has(node.text)) {
|
|
249
|
+
// Check if it's a reference (not a declaration).
|
|
250
|
+
const parent = node.parent;
|
|
251
|
+
const isDeclaration =
|
|
252
|
+
(ts.isVariableDeclaration(parent) && parent.name === node) ||
|
|
253
|
+
(ts.isFunctionDeclaration(parent) && parent.name === node) ||
|
|
254
|
+
(ts.isParameter(parent) && parent.name === node);
|
|
255
|
+
|
|
256
|
+
if (!isDeclaration && !this.isBuiltIn(node.text)) {
|
|
257
|
+
references.add(node.text);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
ts.forEachChild(node, findRefs);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
findRefs(node);
|
|
265
|
+
return Array.from(references);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Check if a name is a built-in global.
|
|
270
|
+
*/
|
|
271
|
+
protected isBuiltIn(name: string): boolean {
|
|
272
|
+
return builtIns.has(name);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Find assignment expressions in a source file.
|
|
277
|
+
*/
|
|
278
|
+
private findAssignmentExpression(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression | null {
|
|
279
|
+
let result: ParsedExpression | null = null;
|
|
280
|
+
|
|
281
|
+
const visit = (node: ts.Node) => {
|
|
282
|
+
if (ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression)) {
|
|
283
|
+
const expr = node.expression;
|
|
284
|
+
if (expr.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isIdentifier(expr.left)) {
|
|
285
|
+
const type = typeChecker.getTypeAtLocation(expr.right);
|
|
286
|
+
const typeString = typeChecker.typeToString(type);
|
|
287
|
+
|
|
288
|
+
// Get the literal value if it's a literal.
|
|
289
|
+
let value: any;
|
|
290
|
+
if (ts.isNumericLiteral(expr.right)) {
|
|
291
|
+
value = Number(expr.right.text);
|
|
292
|
+
} else if (ts.isStringLiteral(expr.right)) {
|
|
293
|
+
value = expr.right.text;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Find references in the right-hand side.
|
|
297
|
+
const references = this.findReferences(expr.right, sourceFile, typeChecker);
|
|
298
|
+
|
|
299
|
+
result = {
|
|
300
|
+
name: expr.left.text,
|
|
301
|
+
type: 'variable',
|
|
302
|
+
valueType: typeString,
|
|
303
|
+
value,
|
|
304
|
+
references,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!result) {
|
|
309
|
+
ts.forEachChild(node, visit);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
visit(sourceFile);
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Find all identifier references in a source file.
|
|
319
|
+
*/
|
|
320
|
+
protected findAllReferences(sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {
|
|
321
|
+
const references = new Set<string>();
|
|
322
|
+
|
|
323
|
+
const visit = (node: ts.Node) => {
|
|
324
|
+
if (ts.isIdentifier(node)) {
|
|
325
|
+
// Skip if it's a declaration.
|
|
326
|
+
const parent = node.parent;
|
|
327
|
+
const isDeclaration =
|
|
328
|
+
(ts.isVariableDeclaration(parent) && parent.name === node) ||
|
|
329
|
+
(ts.isFunctionDeclaration(parent) && parent.name === node) ||
|
|
330
|
+
(ts.isParameter(parent) && parent.name === node);
|
|
331
|
+
|
|
332
|
+
// Skip if it's the left-hand side of an assignment.
|
|
333
|
+
const isAssignmentTarget =
|
|
334
|
+
ts.isBinaryExpression(parent) &&
|
|
335
|
+
parent.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
336
|
+
parent.left === node;
|
|
337
|
+
|
|
338
|
+
if (!isDeclaration && !isAssignmentTarget && !this.isBuiltIn(node.text)) {
|
|
339
|
+
references.add(node.text);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
ts.forEachChild(node, visit);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
visit(sourceFile);
|
|
346
|
+
return Array.from(references);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
protected createEnvironment(files: VirtualFile[]) {
|
|
350
|
+
const allFiles = [...systemFiles, ...files];
|
|
351
|
+
|
|
352
|
+
const fileMap = new Map<string, string>();
|
|
353
|
+
allFiles.forEach(({ filename, content }) => {
|
|
354
|
+
fileMap.set(filename, content);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const system = createSystem(fileMap);
|
|
358
|
+
return createVirtualTypeScriptEnvironment(
|
|
359
|
+
system,
|
|
360
|
+
allFiles.map(({ filename }) => filename),
|
|
361
|
+
ts,
|
|
362
|
+
this.compilerOptions,
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Notebook-specific parser with dependency analysis.
|
|
369
|
+
*/
|
|
370
|
+
export class NotebookVirtualParser extends VirtualTypeScriptParser {
|
|
371
|
+
/**
|
|
372
|
+
* Analyze notebook cells with full type checking.
|
|
373
|
+
*/
|
|
374
|
+
analyzeNotebook(cells: Array<{ id: string; code: string }>) {
|
|
375
|
+
// Create cumulative environment where each cell can see previous cells.
|
|
376
|
+
const cumulativeCode: string[] = [];
|
|
377
|
+
const cellAnalysis: Map<
|
|
378
|
+
string,
|
|
379
|
+
{
|
|
380
|
+
exports: ParsedExpression[];
|
|
381
|
+
imports: string[];
|
|
382
|
+
errors: ts.Diagnostic[];
|
|
383
|
+
}
|
|
384
|
+
> = new Map();
|
|
385
|
+
|
|
386
|
+
cells.forEach((cell) => {
|
|
387
|
+
// Create files for all cells up to current.
|
|
388
|
+
const files: VirtualFile[] = [];
|
|
389
|
+
|
|
390
|
+
// Add previous cells as context.
|
|
391
|
+
if (cumulativeCode.length > 0) {
|
|
392
|
+
files.push({
|
|
393
|
+
filename: '/context.ts',
|
|
394
|
+
content: cumulativeCode.join('\n'),
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Add current cell.
|
|
399
|
+
const filename = `/cell/${cell.id}.ts`;
|
|
400
|
+
files.push({
|
|
401
|
+
filename,
|
|
402
|
+
content: cell.code,
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Create environment.
|
|
406
|
+
const env = this.createEnvironment(files);
|
|
407
|
+
|
|
408
|
+
// Get diagnostics (errors).
|
|
409
|
+
const diagnostics = env.languageService.getSemanticDiagnostics(filename);
|
|
410
|
+
|
|
411
|
+
// Analyze current cell.
|
|
412
|
+
const sourceFile = env.getSourceFile(filename);
|
|
413
|
+
const typeChecker = env.languageService.getProgram()?.getTypeChecker();
|
|
414
|
+
|
|
415
|
+
if (sourceFile && typeChecker) {
|
|
416
|
+
const exports = this.analyzeSourceFile(sourceFile, typeChecker);
|
|
417
|
+
|
|
418
|
+
// Find all references in the current cell.
|
|
419
|
+
const allRefs = new Set<string>();
|
|
420
|
+
exports.forEach((exp) => {
|
|
421
|
+
exp.references?.forEach((ref) => allRefs.add(ref));
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Also check for references not in exports (e.g., console.log(y)).
|
|
425
|
+
const additionalRefs = this.findAllReferences(sourceFile, typeChecker);
|
|
426
|
+
additionalRefs.forEach((ref) => allRefs.add(ref));
|
|
427
|
+
|
|
428
|
+
// Determine which references are imports from previous cells.
|
|
429
|
+
const previousExports = new Set<string>();
|
|
430
|
+
for (const [_prevCellId, prevAnalysis] of cellAnalysis) {
|
|
431
|
+
prevAnalysis.exports.forEach((exp) => {
|
|
432
|
+
if (exp.name) previousExports.add(exp.name);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const imports = Array.from(allRefs).filter((ref) => previousExports.has(ref));
|
|
437
|
+
|
|
438
|
+
cellAnalysis.set(cell.id, {
|
|
439
|
+
exports,
|
|
440
|
+
imports,
|
|
441
|
+
errors: diagnostics,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Add current cell code to cumulative.
|
|
446
|
+
cumulativeCode.push(cell.code);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
return cellAnalysis;
|
|
450
|
+
}
|
|
451
|
+
}
|