@dxos/plugin-script 0.9.1-staging.ee54ba693a → 0.11.0
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/ScriptPlugin.mjs +25 -0
- package/dist/lib/ScriptPlugin.mjs.map +1 -0
- package/dist/lib/ScriptPlugin.node.mjs +11 -0
- package/dist/lib/ScriptPlugin.node.mjs.map +1 -0
- package/dist/lib/ScriptPlugin.workerd.mjs +11 -0
- package/dist/lib/ScriptPlugin.workerd.mjs.map +1 -0
- package/dist/lib/capabilities/node.mjs +11 -0
- package/dist/lib/capabilities/node.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +13 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-DeploymentDialog.mjs +85 -0
- package/dist/lib/chunk-DeploymentDialog.mjs.map +1 -0
- package/dist/lib/chunk-NotebookArticle.mjs +719 -0
- package/dist/lib/chunk-NotebookArticle.mjs.map +1 -0
- package/dist/lib/chunk-ScriptArticle.mjs +67 -0
- package/dist/lib/chunk-ScriptArticle.mjs.map +1 -0
- package/dist/lib/chunk-ScriptProperties.mjs +240 -0
- package/dist/lib/chunk-ScriptProperties.mjs.map +1 -0
- package/dist/lib/chunk-ScriptSettings.mjs +40 -0
- package/dist/lib/chunk-ScriptSettings.mjs.map +1 -0
- package/dist/lib/chunk-TestContainer.mjs +40 -0
- package/dist/lib/chunk-TestContainer.mjs.map +1 -0
- package/dist/lib/chunk-app-graph-builder.mjs +33 -0
- package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
- package/dist/lib/chunk-compiler.mjs +60 -0
- package/dist/lib/chunk-compiler.mjs.map +1 -0
- package/dist/lib/chunk-compiler2.mjs +76 -0
- package/dist/lib/chunk-compiler2.mjs.map +1 -0
- package/dist/lib/chunk-create-object.mjs +36 -0
- package/dist/lib/chunk-create-object.mjs.map +1 -0
- package/dist/lib/chunk-create-script.mjs +32 -0
- package/dist/lib/chunk-create-script.mjs.map +1 -0
- package/dist/lib/chunk-create.mjs +34 -0
- package/dist/lib/chunk-create.mjs.map +1 -0
- package/dist/lib/chunk-delete.mjs +15 -0
- package/dist/lib/chunk-delete.mjs.map +1 -0
- package/dist/lib/chunk-deploy.mjs +53 -0
- package/dist/lib/chunk-deploy.mjs.map +1 -0
- package/dist/lib/chunk-functions.mjs +238 -0
- package/dist/lib/chunk-functions.mjs.map +1 -0
- package/dist/lib/chunk-inspect-invocations.mjs +42 -0
- package/dist/lib/chunk-inspect-invocations.mjs.map +1 -0
- package/dist/lib/chunk-install-function.mjs +40 -0
- package/dist/lib/chunk-install-function.mjs.map +1 -0
- package/dist/lib/chunk-invoke.mjs +25 -0
- package/dist/lib/chunk-invoke.mjs.map +1 -0
- package/dist/lib/chunk-meta.mjs +33 -0
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +13 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-query-deployed-functions.mjs +31 -0
- package/dist/lib/chunk-query-deployed-functions.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +140 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-read.mjs +20 -0
- package/dist/lib/chunk-read.mjs.map +1 -0
- package/dist/lib/chunk-settings.mjs +23 -0
- package/dist/lib/chunk-settings.mjs.map +1 -0
- package/dist/lib/chunk-skill-definition.mjs +10 -0
- package/dist/lib/chunk-skill-definition.mjs.map +1 -0
- package/dist/lib/chunk-skills.mjs +35 -0
- package/dist/lib/chunk-skills.mjs.map +1 -0
- package/dist/lib/{neutral/chunk-WAGQ77UQ.mjs → chunk-templates.mjs} +82 -84
- package/dist/lib/chunk-templates.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +90 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/chunk-update.mjs +27 -0
- package/dist/lib/chunk-update.mjs.map +1 -0
- package/dist/lib/chunk-util.mjs +146 -0
- package/dist/lib/chunk-util.mjs.map +1 -0
- package/dist/lib/components.mjs +618 -0
- package/dist/lib/components.mjs.map +1 -0
- package/dist/lib/containers.mjs +12 -0
- package/dist/lib/containers.mjs.map +1 -0
- package/dist/lib/hooks.mjs +307 -0
- package/dist/lib/hooks.mjs.map +1 -0
- package/dist/lib/index.mjs +5 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/operations.mjs +7 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/skills.mjs +2 -0
- package/dist/lib/templates.mjs +2 -0
- package/dist/lib/testing.mjs +75 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +98 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/capabilities/ScriptSurfaces.d.ts +28 -0
- package/dist/types/src/capabilities/ScriptSurfaces.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/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.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +1 -1
- 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/containers/DeploymentDialog/DeploymentDialog.d.ts +5 -2
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +4 -1
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts +4 -1
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts +4 -1
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts +4 -1
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +4 -1
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts +4 -1
- package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts +4 -1
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts +4 -1
- package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts.map +1 -1
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts +4 -1
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +2 -35
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -23
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -18
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
- package/dist/types/src/skills/functions/deploy.d.ts.map +1 -1
- package/dist/types/src/skills/functions/inspect-invocations.d.ts.map +1 -1
- package/dist/types/src/templates/chess-bot.d.ts +2 -2
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -1
- package/dist/types/src/templates/commentary.d.ts +2 -2
- package/dist/types/src/templates/commentary.d.ts.map +1 -1
- package/dist/types/src/types/ScriptCapabilities.d.ts +1 -1
- package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +88 -82
- package/src/capabilities/ScriptSurfaces.tsx +96 -0
- package/src/capabilities/app-graph-builder.ts +2 -2
- package/src/capabilities/compiler.ts +1 -1
- package/src/capabilities/react-surface.ts +82 -0
- package/src/components/NotebookStack/NotebookCell.tsx +9 -2
- package/src/components/NotebookStack/NotebookStack.stories.tsx +2 -0
- package/src/components/NotebookStack/NotebookStack.tsx +22 -14
- package/src/components/QueryEditor/QueryEditor.stories.tsx +1 -1
- package/src/components/QueryEditor/QueryEditor.tsx +1 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +1 -1
- package/src/components/TestPanel/TestPanel.tsx +2 -2
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +1 -1
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +1 -1
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +3 -1
- package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +1 -1
- package/src/containers/NotebookArticle/NotebookArticle.tsx +4 -2
- package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +2 -1
- package/src/containers/ScriptArticle/ScriptArticle.tsx +3 -1
- package/src/containers/ScriptProperties/FunctionBinding.tsx +5 -3
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +4 -2
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +2 -1
- package/src/containers/ScriptProperties/ScriptProperties.tsx +2 -0
- package/src/containers/ScriptProperties/SkillEditor.tsx +3 -1
- package/src/containers/ScriptSettings/ScriptSettings.tsx +2 -0
- package/src/containers/TestContainer/TestContainer.tsx +4 -2
- package/src/e2e/ai.test.ts +2 -2
- package/src/e2e/deploy.test.ts +2 -2
- package/src/hooks/deploy.ts +13 -4
- package/src/hooks/format.ts +2 -2
- package/src/hooks/template.ts +3 -3
- package/src/hooks/useToolbarState.ts +1 -1
- package/src/notebook/compute-graph.test.ts +1 -1
- package/src/notebook/compute-graph.ts +1 -1
- package/src/skills/functions/deploy.ts +5 -6
- package/src/skills/functions/inspect-invocations.ts +2 -2
- package/src/skills/functions/install-function.ts +1 -1
- package/src/skills/functions/invoke.ts +1 -1
- package/src/skills/functions/query-deployed-functions.ts +1 -1
- package/src/templates/chess-bot.ts +3 -3
- package/src/templates/commentary.ts +3 -3
- package/src/testing/simulator.test.ts +1 -1
- package/src/types/ScriptCapabilities.ts +1 -1
- package/src/util/deploy.ts +3 -3
- package/src/util/functions.ts +2 -2
- package/dist/lib/neutral/DeploymentDialog-7OIIL7LB.mjs +0 -114
- package/dist/lib/neutral/DeploymentDialog-7OIIL7LB.mjs.map +0 -7
- package/dist/lib/neutral/NotebookArticle-AOBB3XGD.mjs +0 -745
- package/dist/lib/neutral/NotebookArticle-AOBB3XGD.mjs.map +0 -7
- package/dist/lib/neutral/ScriptArticle-I3DOJARR.mjs +0 -79
- package/dist/lib/neutral/ScriptArticle-I3DOJARR.mjs.map +0 -7
- package/dist/lib/neutral/ScriptPlugin.mjs +0 -51
- package/dist/lib/neutral/ScriptPlugin.mjs.map +0 -7
- package/dist/lib/neutral/ScriptPlugin.node.mjs +0 -27
- package/dist/lib/neutral/ScriptPlugin.node.mjs.map +0 -7
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs +0 -21
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs.map +0 -7
- package/dist/lib/neutral/ScriptProperties-RHDQGMGT.mjs +0 -296
- package/dist/lib/neutral/ScriptProperties-RHDQGMGT.mjs.map +0 -7
- package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs +0 -35
- package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs.map +0 -7
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs +0 -44
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-POP3CX6G.mjs +0 -52
- package/dist/lib/neutral/app-graph-builder-POP3CX6G.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/index.mjs +0 -21
- package/dist/lib/neutral/capabilities/index.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/node.mjs +0 -17
- package/dist/lib/neutral/capabilities/node.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2REUEDUA.mjs +0 -56
- package/dist/lib/neutral/chunk-2REUEDUA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-652CIABA.mjs +0 -124
- package/dist/lib/neutral/chunk-652CIABA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6DOWVKIW.mjs +0 -344
- package/dist/lib/neutral/chunk-6DOWVKIW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CHNFYLKW.mjs +0 -52
- package/dist/lib/neutral/chunk-CHNFYLKW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-INFWOSTM.mjs +0 -156
- package/dist/lib/neutral/chunk-INFWOSTM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KSVKXCTX.mjs +0 -8
- package/dist/lib/neutral/chunk-KSVKXCTX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NVV5UYY4.mjs +0 -50
- package/dist/lib/neutral/chunk-NVV5UYY4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-USJ44FIU.mjs +0 -8
- package/dist/lib/neutral/chunk-USJ44FIU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WAGQ77UQ.mjs.map +0 -7
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs +0 -101
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs.map +0 -7
- package/dist/lib/neutral/components/index.mjs +0 -695
- package/dist/lib/neutral/components/index.mjs.map +0 -7
- package/dist/lib/neutral/containers/index.mjs +0 -19
- package/dist/lib/neutral/containers/index.mjs.map +0 -7
- package/dist/lib/neutral/create-SGHWWTET.mjs +0 -46
- package/dist/lib/neutral/create-SGHWWTET.mjs.map +0 -7
- package/dist/lib/neutral/create-object-QW66KQWS.mjs +0 -43
- package/dist/lib/neutral/create-object-QW66KQWS.mjs.map +0 -7
- package/dist/lib/neutral/create-script-CIEJOBIU.mjs +0 -45
- package/dist/lib/neutral/create-script-CIEJOBIU.mjs.map +0 -7
- package/dist/lib/neutral/delete-72RXVLVI.mjs +0 -21
- package/dist/lib/neutral/delete-72RXVLVI.mjs.map +0 -7
- package/dist/lib/neutral/deploy-PJTJAQZY.mjs +0 -67
- package/dist/lib/neutral/deploy-PJTJAQZY.mjs.map +0 -7
- package/dist/lib/neutral/hooks/index.mjs +0 -369
- package/dist/lib/neutral/hooks/index.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -41
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/inspect-invocations-ZUXVUAML.mjs +0 -59
- package/dist/lib/neutral/inspect-invocations-ZUXVUAML.mjs.map +0 -7
- package/dist/lib/neutral/install-function-YFDZLVMJ.mjs +0 -49
- package/dist/lib/neutral/install-function-YFDZLVMJ.mjs.map +0 -7
- package/dist/lib/neutral/invoke-CDRBQ2WA.mjs +0 -32
- package/dist/lib/neutral/invoke-CDRBQ2WA.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -10
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/operation-handler-M3B6IRMV.mjs +0 -18
- package/dist/lib/neutral/operation-handler-M3B6IRMV.mjs.map +0 -7
- package/dist/lib/neutral/operations/index.mjs +0 -8
- package/dist/lib/neutral/operations/index.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -16
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/query-deployed-functions-RBQMGON2.mjs +0 -34
- package/dist/lib/neutral/query-deployed-functions-RBQMGON2.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-GEXOZLBC.mjs +0 -120
- package/dist/lib/neutral/react-surface-GEXOZLBC.mjs.map +0 -7
- package/dist/lib/neutral/read-OY3K5R3V.mjs +0 -26
- package/dist/lib/neutral/read-OY3K5R3V.mjs.map +0 -7
- package/dist/lib/neutral/settings-FD7HXEY6.mjs +0 -30
- package/dist/lib/neutral/settings-FD7HXEY6.mjs.map +0 -7
- package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs +0 -15
- package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs.map +0 -7
- package/dist/lib/neutral/skills/index.mjs +0 -10
- package/dist/lib/neutral/skills/index.mjs.map +0 -7
- package/dist/lib/neutral/templates/index.mjs +0 -10
- package/dist/lib/neutral/templates/index.mjs.map +0 -7
- package/dist/lib/neutral/translations.mjs +0 -104
- package/dist/lib/neutral/translations.mjs.map +0 -7
- package/dist/lib/neutral/types/index.mjs +0 -17
- package/dist/lib/neutral/types/index.mjs.map +0 -7
- package/dist/lib/neutral/update-Z5VGOLBN.mjs +0 -44
- package/dist/lib/neutral/update-Z5VGOLBN.mjs.map +0 -7
- package/src/capabilities/react-surface.tsx +0 -132
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import { t as Compiler } from "./chunk-compiler.mjs";
|
|
2
|
+
import { arrayMove, isNonNullable } from "@dxos/util";
|
|
3
|
+
import { Obj } from "@dxos/echo";
|
|
4
|
+
import { meta } from "#meta";
|
|
5
|
+
import { log } from "@dxos/log";
|
|
6
|
+
import { forwardRef, useCallback, useId, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { Avatar, DropdownMenu, ElevationProvider, Icon, IconButton, Input, ScrollArea, Toolbar, composable, composableProps, useAsyncEffect, useThemeContext, useTranslation } from "@dxos/react-ui";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Mosaic } from "@dxos/react-ui-mosaic";
|
|
10
|
+
import { mx } from "@dxos/ui-theme";
|
|
11
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
12
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
13
|
+
import { Doc } from "@dxos/echo-doc";
|
|
14
|
+
import { invariant } from "@dxos/invariant";
|
|
15
|
+
import { TemplateEditor } from "@dxos/plugin-routine/components";
|
|
16
|
+
import { QueryEditor as QueryEditor$1 } from "@dxos/react-ui-components";
|
|
17
|
+
import { Editor, useTextEditor } from "@dxos/react-ui-editor";
|
|
18
|
+
import { InputModeExtensions, createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown, defaultStyles } from "@dxos/ui-editor";
|
|
19
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
20
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
21
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
22
|
+
import { lintKeymap } from "@codemirror/lint";
|
|
23
|
+
import { Prec } from "@codemirror/state";
|
|
24
|
+
import { keymap } from "@codemirror/view";
|
|
25
|
+
import { tags } from "@lezer/highlight";
|
|
26
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
27
|
+
import { continueKeymap } from "@valtown/codemirror-continue";
|
|
28
|
+
import { tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from "@valtown/codemirror-ts";
|
|
29
|
+
import { Domino } from "@dxos/ui";
|
|
30
|
+
import { ModuleResolutionKind, ScriptTarget } from "typescript";
|
|
31
|
+
import queryApi from "@dxos/echo-query/api.d.ts?raw";
|
|
32
|
+
import { Atom } from "@effect-atom/atom";
|
|
33
|
+
import { Menu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
|
|
34
|
+
import { createDeploy, createFormat, createTemplateSelect, useDeployDeps } from "#hooks";
|
|
35
|
+
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
36
|
+
//#region src/components/NotebookStack/NotebookMenu.tsx
|
|
37
|
+
var NotebookMenu = ({ cell, onCellInsert, onCellDelete }) => {
|
|
38
|
+
const { t } = useTranslation(meta.profile.key);
|
|
39
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [/* @__PURE__ */ jsxs(DropdownMenu.Viewport, { children: [
|
|
40
|
+
/* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
41
|
+
onClick: () => onCellInsert?.("script", cell?.id),
|
|
42
|
+
children: t("notebook-cell-insert-script.label")
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
45
|
+
onClick: () => onCellInsert?.("prompt", cell?.id),
|
|
46
|
+
children: t("notebook-cell-insert-prompt.label")
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
49
|
+
onClick: () => onCellInsert?.("query", cell?.id),
|
|
50
|
+
children: t("notebook-cell-insert-query.label")
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
53
|
+
onClick: () => onCellInsert?.("markdown", cell?.id),
|
|
54
|
+
children: t("notebook-cell-insert-markdown.label")
|
|
55
|
+
}),
|
|
56
|
+
cell && onCellDelete && /* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
57
|
+
onClick: () => onCellDelete?.(cell.id),
|
|
58
|
+
children: t("notebook-cell-delete.label")
|
|
59
|
+
})
|
|
60
|
+
] }), /* @__PURE__ */ jsx(DropdownMenu.Arrow, {})] }) });
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/components/TypescriptEditor/TypescriptEditor.tsx
|
|
64
|
+
var TypescriptEditor = composable(({ classNames, id, role = "article", inputMode = "vscode", env, options, initialValue, extensions, scrollTo, selection, ...props }, forwardedRef) => {
|
|
65
|
+
const { themeMode } = useThemeContext();
|
|
66
|
+
const { parentRef, focusAttributes } = useTextEditor(() => ({
|
|
67
|
+
id,
|
|
68
|
+
initialValue,
|
|
69
|
+
selection,
|
|
70
|
+
scrollTo,
|
|
71
|
+
extensions: [
|
|
72
|
+
extensions,
|
|
73
|
+
createThemeExtensions({
|
|
74
|
+
monospace: true,
|
|
75
|
+
themeMode,
|
|
76
|
+
syntaxHighlighting: true
|
|
77
|
+
}),
|
|
78
|
+
createBasicExtensions({
|
|
79
|
+
highlightActiveLine: true,
|
|
80
|
+
indentWithTab: true,
|
|
81
|
+
lineNumbers: true,
|
|
82
|
+
lineWrapping: false,
|
|
83
|
+
scrollPastEnd: role === "article",
|
|
84
|
+
search: true,
|
|
85
|
+
...options
|
|
86
|
+
}),
|
|
87
|
+
InputModeExtensions[inputMode],
|
|
88
|
+
javascript({ typescript: true }),
|
|
89
|
+
autocompletion({ override: env ? [tsAutocomplete()] : void 0 }),
|
|
90
|
+
Prec.high(keymap.of(continueKeymap)),
|
|
91
|
+
keymap.of(completionKeymap),
|
|
92
|
+
keymap.of(lintKeymap),
|
|
93
|
+
env && [
|
|
94
|
+
tsFacet.of({
|
|
95
|
+
env,
|
|
96
|
+
path: `./src/${id}.ts`
|
|
97
|
+
}),
|
|
98
|
+
tsSync(),
|
|
99
|
+
tsLinter(),
|
|
100
|
+
tsHover({ renderTooltip: createTooltipRenderer(themeMode) })
|
|
101
|
+
]
|
|
102
|
+
].filter(isNonNullable)
|
|
103
|
+
}), [
|
|
104
|
+
themeMode,
|
|
105
|
+
id,
|
|
106
|
+
extensions,
|
|
107
|
+
inputMode,
|
|
108
|
+
selection,
|
|
109
|
+
scrollTo,
|
|
110
|
+
env
|
|
111
|
+
]);
|
|
112
|
+
return /* @__PURE__ */ jsx("div", {
|
|
113
|
+
...composableProps(props, {
|
|
114
|
+
classNames,
|
|
115
|
+
...focusAttributes
|
|
116
|
+
}),
|
|
117
|
+
ref: composeRefs(parentRef, forwardedRef)
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
var createTooltipRenderer = (themeMode) => {
|
|
121
|
+
const theme = HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light);
|
|
122
|
+
const classFromKind = (_kind) => {
|
|
123
|
+
const kind = _kind.endsWith("Name") ? "name" : _kind;
|
|
124
|
+
if (!(kind in tags)) return "";
|
|
125
|
+
const tag = tags[kind];
|
|
126
|
+
if (typeof tag === "function") return "";
|
|
127
|
+
return theme.style([tag]) ?? "";
|
|
128
|
+
};
|
|
129
|
+
return (info) => {
|
|
130
|
+
const children = info.quickInfo?.displayParts?.map(({ kind, text }) => Domino.of("span").classNames(classFromKind(kind)).text(text)) ?? [];
|
|
131
|
+
return { dom: Domino.of("div").classNames("xs:max-w-80 max-w-lg p-1 dx-base-surface rounded-sm border border-separator").append(...children).root };
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/components/NotebookStack/NotebookCell.tsx
|
|
136
|
+
var __dxlog_file$1 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/NotebookStack/NotebookCell.tsx";
|
|
137
|
+
var editorStyles = "p-2 ps-3";
|
|
138
|
+
var valueStyles = "p-1 ps-3";
|
|
139
|
+
var NotebookCell = ({ db, graph, dragging, cell, promptResults, env }) => {
|
|
140
|
+
const { t } = useTranslation(meta.profile.key);
|
|
141
|
+
const extensions = useMemo(() => {
|
|
142
|
+
return cell.source?.target ? [createDataExtensions({
|
|
143
|
+
id: cell.id,
|
|
144
|
+
text: Doc.createAccessor(cell.source.target, ["content"])
|
|
145
|
+
})] : [];
|
|
146
|
+
}, [cell.source?.target]);
|
|
147
|
+
const explorerGraph = cell.graph?.target;
|
|
148
|
+
const handleQueryChange = useCallback((value) => {
|
|
149
|
+
invariant(cell.source?.target, void 0, {
|
|
150
|
+
"~LogMeta": "~LogMeta",
|
|
151
|
+
F: __dxlog_file$1,
|
|
152
|
+
L: 59,
|
|
153
|
+
S: void 0,
|
|
154
|
+
A: ["cell.source?.target", ""]
|
|
155
|
+
});
|
|
156
|
+
Obj.update(cell.source.target, (obj) => {
|
|
157
|
+
obj.content = value;
|
|
158
|
+
});
|
|
159
|
+
}, [cell]);
|
|
160
|
+
switch (cell.type) {
|
|
161
|
+
case "markdown":
|
|
162
|
+
if (!cell.source?.target) return null;
|
|
163
|
+
return /* @__PURE__ */ jsx(NotebookTextEditor, {
|
|
164
|
+
id: cell.id,
|
|
165
|
+
classNames: editorStyles,
|
|
166
|
+
initialValue: cell.source.target.content,
|
|
167
|
+
extensions
|
|
168
|
+
});
|
|
169
|
+
case "script":
|
|
170
|
+
if (!cell.source?.target) return null;
|
|
171
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
172
|
+
className: "flex flex-col divide-y divide-subdued-separator",
|
|
173
|
+
children: [/* @__PURE__ */ jsx(TypescriptEditor, {
|
|
174
|
+
id: cell.id,
|
|
175
|
+
role: "section",
|
|
176
|
+
classNames: editorStyles,
|
|
177
|
+
initialValue: cell.source.target.content,
|
|
178
|
+
extensions,
|
|
179
|
+
env,
|
|
180
|
+
options: {
|
|
181
|
+
placeholder: t("notebook-cell.placeholder"),
|
|
182
|
+
highlightActiveLine: false,
|
|
183
|
+
lineNumbers: false
|
|
184
|
+
}
|
|
185
|
+
}), /* @__PURE__ */ jsx(NotebookCellValue, {
|
|
186
|
+
cell,
|
|
187
|
+
graph
|
|
188
|
+
})]
|
|
189
|
+
});
|
|
190
|
+
case "query":
|
|
191
|
+
if (!cell.source?.target) return null;
|
|
192
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
className: mx("h-full overflow-hidden grid", explorerGraph && !dragging && "grid-rows-[min-content_1fr]"),
|
|
194
|
+
children: [/* @__PURE__ */ jsx(QueryEditor$1, {
|
|
195
|
+
id: cell.id,
|
|
196
|
+
classNames: editorStyles,
|
|
197
|
+
db,
|
|
198
|
+
value: cell.source.target.content,
|
|
199
|
+
onChange: handleQueryChange
|
|
200
|
+
}), explorerGraph && !dragging && /* @__PURE__ */ jsx(Surface.Surface, {
|
|
201
|
+
type: AppSurface.Section,
|
|
202
|
+
limit: 1,
|
|
203
|
+
data: {
|
|
204
|
+
subject: explorerGraph,
|
|
205
|
+
attendableId: cell.id
|
|
206
|
+
}
|
|
207
|
+
})]
|
|
208
|
+
});
|
|
209
|
+
case "prompt":
|
|
210
|
+
if (!cell.prompt?.target) return null;
|
|
211
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TemplateEditor, {
|
|
212
|
+
id: cell.id,
|
|
213
|
+
source: cell.prompt.target.text,
|
|
214
|
+
lineNumbers: false,
|
|
215
|
+
classNames: editorStyles
|
|
216
|
+
}), /* @__PURE__ */ jsx(NotebookPromptResult, {
|
|
217
|
+
cell,
|
|
218
|
+
promptResults
|
|
219
|
+
})] });
|
|
220
|
+
default: return null;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var NotebookCellValue = ({ cell, graph }) => {
|
|
224
|
+
const name = graph?.getExpressions()[cell.id]?.name;
|
|
225
|
+
const value = graph?.getValue(cell.id);
|
|
226
|
+
if (value == null) return null;
|
|
227
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: mx("flex w-full bg-group-surface text-description font-mono", valueStyles),
|
|
229
|
+
children: [name && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
230
|
+
className: "text-success-text",
|
|
231
|
+
children: name
|
|
232
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
233
|
+
className: "text-description",
|
|
234
|
+
children: "\xA0=\xA0"
|
|
235
|
+
})] }), /* @__PURE__ */ jsx("span", { children: value })]
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
var NotebookPromptResult = ({ cell, promptResults }) => {
|
|
239
|
+
if (!cell.prompt) return null;
|
|
240
|
+
const value = promptResults?.[cell.prompt.uri];
|
|
241
|
+
if (value == null) return null;
|
|
242
|
+
return /* @__PURE__ */ jsx("div", {
|
|
243
|
+
className: mx("flex w-full dx-group-surface text-description border-y border-subdued-separator", valueStyles),
|
|
244
|
+
children: /* @__PURE__ */ jsx(NotebookTextEditor, {
|
|
245
|
+
readOnly: true,
|
|
246
|
+
value
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
var NotebookTextEditor = ({ classNames, extensions: extensionsProp, readOnly, ...props }) => {
|
|
251
|
+
const { t } = useTranslation(meta.profile.key);
|
|
252
|
+
const { themeMode } = useThemeContext();
|
|
253
|
+
const extensions = useMemo(() => {
|
|
254
|
+
return [
|
|
255
|
+
createThemeExtensions({
|
|
256
|
+
themeMode,
|
|
257
|
+
syntaxHighlighting: true
|
|
258
|
+
}),
|
|
259
|
+
createBasicExtensions({
|
|
260
|
+
placeholder: t("notebook-markdown.placeholder"),
|
|
261
|
+
readOnly
|
|
262
|
+
}),
|
|
263
|
+
createMarkdownExtensions(),
|
|
264
|
+
decorateMarkdown(),
|
|
265
|
+
extensionsProp
|
|
266
|
+
].filter(isNonNullable);
|
|
267
|
+
}, [
|
|
268
|
+
extensionsProp,
|
|
269
|
+
readOnly,
|
|
270
|
+
themeMode,
|
|
271
|
+
t
|
|
272
|
+
]);
|
|
273
|
+
return /* @__PURE__ */ jsx(Editor.Root, { children: /* @__PURE__ */ jsx(Editor.View, {
|
|
274
|
+
...props,
|
|
275
|
+
classNames: mx("border focus-within:border-focus-ring-subtle", classNames),
|
|
276
|
+
extensions,
|
|
277
|
+
selectionEnd: true
|
|
278
|
+
}) });
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/components/NotebookStack/NotebookStack.tsx
|
|
282
|
+
var minSectionHeight = "min-h-[16rem]";
|
|
283
|
+
var getCellId = (cell) => cell.id;
|
|
284
|
+
var NotebookStack = composable(({ notebook, db, graph, promptResults, onCellInsert, onCellDelete, env, ...props }, forwardedRef) => {
|
|
285
|
+
const [viewport, setViewport] = useState(null);
|
|
286
|
+
const Tile = useCallback((tileProps) => /* @__PURE__ */ jsx(NotebookSection, {
|
|
287
|
+
...tileProps,
|
|
288
|
+
db,
|
|
289
|
+
graph,
|
|
290
|
+
promptResults,
|
|
291
|
+
onCellInsert,
|
|
292
|
+
onCellDelete,
|
|
293
|
+
env
|
|
294
|
+
}), [
|
|
295
|
+
db,
|
|
296
|
+
graph,
|
|
297
|
+
promptResults,
|
|
298
|
+
onCellInsert,
|
|
299
|
+
onCellDelete,
|
|
300
|
+
env
|
|
301
|
+
]);
|
|
302
|
+
const instanceId = useId();
|
|
303
|
+
const eventHandler = useMemo(() => ({
|
|
304
|
+
id: `notebook:${notebook?.id ?? "anon"}:${instanceId}`,
|
|
305
|
+
canDrop: ({ source }) => !!notebook && notebook.cells.some((cell) => cell.id === source.id),
|
|
306
|
+
onDrop: ({ source, target }) => {
|
|
307
|
+
if (!notebook || !target) return;
|
|
308
|
+
const to = target.type === "tile" || target.type === "placeholder" ? target.location : target.type === "container" ? notebook.cells.length : -1;
|
|
309
|
+
const insertIndex = typeof to === "number" && to >= 0 ? Math.floor(to) : -1;
|
|
310
|
+
if (insertIndex < 0) return;
|
|
311
|
+
Obj.update(notebook, (notebook) => {
|
|
312
|
+
const from = notebook.cells.findIndex((cell) => cell.id === source.id);
|
|
313
|
+
if (from !== -1) arrayMove(notebook.cells, from, insertIndex);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}), [notebook, instanceId]);
|
|
317
|
+
return /* @__PURE__ */ jsx(Mosaic.Container, {
|
|
318
|
+
asChild: true,
|
|
319
|
+
orientation: "vertical",
|
|
320
|
+
autoScroll: viewport,
|
|
321
|
+
eventHandler,
|
|
322
|
+
ref: forwardedRef,
|
|
323
|
+
children: /* @__PURE__ */ jsx(ScrollArea.Root, {
|
|
324
|
+
orientation: "vertical",
|
|
325
|
+
padding: true,
|
|
326
|
+
...composableProps(props),
|
|
327
|
+
children: /* @__PURE__ */ jsx(ScrollArea.Viewport, {
|
|
328
|
+
ref: setViewport,
|
|
329
|
+
children: /* @__PURE__ */ jsx(Mosaic.Stack, {
|
|
330
|
+
orientation: "vertical",
|
|
331
|
+
items: notebook?.cells ?? [],
|
|
332
|
+
getId: getCellId,
|
|
333
|
+
Tile
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
var NotebookSection = ({ data: cell, db, env, graph, promptResults, onCellInsert, onCellDelete, ...tileProps }) => {
|
|
340
|
+
const { t } = useTranslation(meta.profile.key);
|
|
341
|
+
const resizable = cell.type === "query";
|
|
342
|
+
const [dragHandle, setDragHandle] = useState(null);
|
|
343
|
+
return /* @__PURE__ */ jsxs(Mosaic.Tile, {
|
|
344
|
+
...tileProps,
|
|
345
|
+
data: cell,
|
|
346
|
+
dragHandle,
|
|
347
|
+
classNames: mx("grid grid-cols-[min-content_1fr] overflow-visible border border-subdued-separator", resizable && minSectionHeight),
|
|
348
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
349
|
+
className: "flex flex-col p-1 border-e border-subdued-separator dx-attention-surface",
|
|
350
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
351
|
+
ref: setDragHandle,
|
|
352
|
+
variant: "ghost",
|
|
353
|
+
icon: "ph--dots-six-vertical--regular",
|
|
354
|
+
iconOnly: true,
|
|
355
|
+
label: "Drag handle"
|
|
356
|
+
}), /* @__PURE__ */ jsxs(DropdownMenu.Root, { children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
|
|
357
|
+
asChild: true,
|
|
358
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
359
|
+
variant: "ghost",
|
|
360
|
+
icon: "ph--dots-three--regular",
|
|
361
|
+
iconOnly: true,
|
|
362
|
+
label: t("notebook-cell-insert.label")
|
|
363
|
+
})
|
|
364
|
+
}), /* @__PURE__ */ jsx(NotebookMenu, {
|
|
365
|
+
cell,
|
|
366
|
+
onCellInsert,
|
|
367
|
+
onCellDelete
|
|
368
|
+
})] })]
|
|
369
|
+
}), /* @__PURE__ */ jsx(NotebookCell, {
|
|
370
|
+
db,
|
|
371
|
+
cell,
|
|
372
|
+
env,
|
|
373
|
+
graph,
|
|
374
|
+
promptResults
|
|
375
|
+
})]
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/components/QueryEditor/QueryEditor.tsx
|
|
380
|
+
var GLOBALS = `
|
|
381
|
+
namespace QueryAPI {
|
|
382
|
+
${queryApi}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare global {
|
|
386
|
+
const Query: typeof QueryAPI.Query;
|
|
387
|
+
const Filter: typeof QueryAPI.Filter;
|
|
388
|
+
const Order: typeof QueryAPI.Order;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export {};
|
|
392
|
+
`;
|
|
393
|
+
var QueryEditor = (props) => {
|
|
394
|
+
const [compiler, setCompiler] = useState();
|
|
395
|
+
useAsyncEffect(async () => {
|
|
396
|
+
const compiler = new Compiler({
|
|
397
|
+
lib: ["ES5"],
|
|
398
|
+
target: ScriptTarget.ES2022,
|
|
399
|
+
moduleResolution: ModuleResolutionKind.Bundler
|
|
400
|
+
});
|
|
401
|
+
await compiler.initialize(GLOBALS);
|
|
402
|
+
setCompiler(compiler);
|
|
403
|
+
}, []);
|
|
404
|
+
if (!compiler) return null;
|
|
405
|
+
return /* @__PURE__ */ jsx(TypescriptEditor, {
|
|
406
|
+
...props,
|
|
407
|
+
env: compiler.environment
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/components/ScriptToolbar/ScriptToolbar.tsx
|
|
412
|
+
var ScriptToolbar = composable(({ script, attendableId, role, state, ...props }, forwardedRef) => {
|
|
413
|
+
const { t } = useTranslation(meta.profile.key);
|
|
414
|
+
const options = useDeployDeps({ script });
|
|
415
|
+
const menuActions = useMenuActions(useMemo(() => createToolbarActions({
|
|
416
|
+
state,
|
|
417
|
+
script,
|
|
418
|
+
t,
|
|
419
|
+
...options
|
|
420
|
+
}), [
|
|
421
|
+
state,
|
|
422
|
+
script,
|
|
423
|
+
options,
|
|
424
|
+
t
|
|
425
|
+
]));
|
|
426
|
+
return /* @__PURE__ */ jsx(ElevationProvider, {
|
|
427
|
+
elevation: role === AppSurface.Section.role ? "positioned" : "base",
|
|
428
|
+
children: /* @__PURE__ */ jsx(Menu.Root, {
|
|
429
|
+
...menuActions,
|
|
430
|
+
attendableId,
|
|
431
|
+
children: /* @__PURE__ */ jsx(Menu.Toolbar, {
|
|
432
|
+
...composableProps(props),
|
|
433
|
+
ref: forwardedRef
|
|
434
|
+
})
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
var createToolbarActions = ({ state, script, ...options }) => Atom.make((get) => {
|
|
439
|
+
get(state.atom);
|
|
440
|
+
const templateSelect = createTemplateSelect(script);
|
|
441
|
+
const format = createFormat(script);
|
|
442
|
+
const gap = createGapSeparator();
|
|
443
|
+
const deploy = createDeploy({
|
|
444
|
+
state,
|
|
445
|
+
script,
|
|
446
|
+
...options
|
|
447
|
+
});
|
|
448
|
+
return {
|
|
449
|
+
nodes: [
|
|
450
|
+
...templateSelect.nodes,
|
|
451
|
+
...format.nodes,
|
|
452
|
+
...gap.nodes,
|
|
453
|
+
...deploy.nodes
|
|
454
|
+
],
|
|
455
|
+
edges: [
|
|
456
|
+
...templateSelect.edges,
|
|
457
|
+
...format.edges,
|
|
458
|
+
...gap.edges,
|
|
459
|
+
...deploy.edges
|
|
460
|
+
]
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/components/TestPanel/TestPanel.tsx
|
|
465
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/components/TestPanel/TestPanel.tsx";
|
|
466
|
+
var TestPanel = composable(({ classNames, onInvoke, ...props }, forwardedRef) => {
|
|
467
|
+
const { t } = useTranslation(meta.profile.key);
|
|
468
|
+
const inputRef = useRef(null);
|
|
469
|
+
const [input, setInput] = useState("");
|
|
470
|
+
const [state, setState] = useState(null);
|
|
471
|
+
const [history, setHistory] = useState([]);
|
|
472
|
+
const scrollerRef = useRef(null);
|
|
473
|
+
const handleScroll = () => {
|
|
474
|
+
if (scrollerRef.current) scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
|
|
475
|
+
};
|
|
476
|
+
const handleClear = () => {
|
|
477
|
+
setInput("");
|
|
478
|
+
setHistory([]);
|
|
479
|
+
inputRef.current?.focus();
|
|
480
|
+
};
|
|
481
|
+
const handleResponse = ({ text, data, error } = {}) => {
|
|
482
|
+
setHistory((history) => [...history, {
|
|
483
|
+
type: "response",
|
|
484
|
+
text,
|
|
485
|
+
data,
|
|
486
|
+
error
|
|
487
|
+
}]);
|
|
488
|
+
setState(null);
|
|
489
|
+
handleScroll();
|
|
490
|
+
};
|
|
491
|
+
const handleRequest = async (input) => {
|
|
492
|
+
if (!onInvoke) {
|
|
493
|
+
handleResponse({ error: /* @__PURE__ */ new Error("Function not deployed") });
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
let data = input;
|
|
497
|
+
let displayText = input;
|
|
498
|
+
if (input.charAt(0) === "{") try {
|
|
499
|
+
const validJsonString = input.replace(/'/g, "\"").replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, "$1\"$2\"$3");
|
|
500
|
+
data = JSON.parse(validJsonString);
|
|
501
|
+
displayText = JSON.stringify(data, null, 2);
|
|
502
|
+
} catch (err) {
|
|
503
|
+
handleResponse({ error: /* @__PURE__ */ new Error("Invalid JSON input") });
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
try {
|
|
507
|
+
setState("pending");
|
|
508
|
+
setInput("");
|
|
509
|
+
setHistory((history) => [...history, {
|
|
510
|
+
type: "request",
|
|
511
|
+
text: displayText
|
|
512
|
+
}]);
|
|
513
|
+
setTimeout(handleScroll);
|
|
514
|
+
const result = await onInvoke(data);
|
|
515
|
+
if (typeof result === "string") handleResponse({ text: result });
|
|
516
|
+
else handleResponse({ data: result });
|
|
517
|
+
} catch (err) {
|
|
518
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
519
|
+
handleResponse({ error });
|
|
520
|
+
log.catch(err, void 0, {
|
|
521
|
+
"~LogMeta": "~LogMeta",
|
|
522
|
+
F: __dxlog_file,
|
|
523
|
+
L: 105,
|
|
524
|
+
S: void 0
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
529
|
+
...composableProps(props, { classNames: ["flex flex-col h-full overflow-hidden", classNames] }),
|
|
530
|
+
ref: forwardedRef,
|
|
531
|
+
children: [/* @__PURE__ */ jsx(MessageThread, {
|
|
532
|
+
ref: scrollerRef,
|
|
533
|
+
state,
|
|
534
|
+
history
|
|
535
|
+
}), /* @__PURE__ */ jsxs(Toolbar.Root, { children: [
|
|
536
|
+
/* @__PURE__ */ jsx(Input.Root, { children: /* @__PURE__ */ jsx(Input.TextInput, {
|
|
537
|
+
ref: inputRef,
|
|
538
|
+
autoFocus: true,
|
|
539
|
+
placeholder: t("function-request.placeholder"),
|
|
540
|
+
value: input,
|
|
541
|
+
onChange: (ev) => setInput(ev.target.value),
|
|
542
|
+
onKeyDown: (ev) => ev.key === "Enter" && handleRequest(input)
|
|
543
|
+
}) }),
|
|
544
|
+
/* @__PURE__ */ jsx(Toolbar.IconButton, {
|
|
545
|
+
icon: "ph--play--regular",
|
|
546
|
+
label: "Execute",
|
|
547
|
+
iconOnly: true,
|
|
548
|
+
onClick: () => handleRequest(input)
|
|
549
|
+
}),
|
|
550
|
+
/* @__PURE__ */ jsx(Toolbar.IconButton, {
|
|
551
|
+
icon: "ph--trash--regular",
|
|
552
|
+
label: "Clear",
|
|
553
|
+
iconOnly: true,
|
|
554
|
+
onClick: handleClear
|
|
555
|
+
})
|
|
556
|
+
] })]
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
var MessageThread = forwardRef(({ state, history }, forwardedRef) => {
|
|
560
|
+
return /* @__PURE__ */ jsx(ScrollArea.Root, {
|
|
561
|
+
orientation: "vertical",
|
|
562
|
+
classNames: "h-full",
|
|
563
|
+
ref: forwardedRef,
|
|
564
|
+
children: /* @__PURE__ */ jsxs(ScrollArea.Viewport, {
|
|
565
|
+
classNames: "gap-6 p-2",
|
|
566
|
+
children: [history.map((message, i) => /* @__PURE__ */ jsxs("div", {
|
|
567
|
+
className: "grid grid-cols-[var(--dx-rail-item)_1fr_var(--dx-rail-item)]",
|
|
568
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
569
|
+
className: "p-1",
|
|
570
|
+
children: message.type === "response" && /* @__PURE__ */ jsx(RobotAvatar, {})
|
|
571
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
572
|
+
className: "overflow-auto",
|
|
573
|
+
children: /* @__PURE__ */ jsx(MessageItem, { message })
|
|
574
|
+
})]
|
|
575
|
+
}, i)), state === "pending" && /* @__PURE__ */ jsx("div", {
|
|
576
|
+
className: "grid grid-cols-[var(--dx-rail-item)_1fr_var(--dx-rail-item)]",
|
|
577
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
578
|
+
className: "p-1",
|
|
579
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
580
|
+
icon: "ph--spinner--regular",
|
|
581
|
+
size: 6,
|
|
582
|
+
classNames: "animate-spin"
|
|
583
|
+
})
|
|
584
|
+
})
|
|
585
|
+
})]
|
|
586
|
+
})
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
var MessageItem = ({ classNames, message }) => {
|
|
590
|
+
const { type, text, data, error } = message;
|
|
591
|
+
const wrapper = "p-1 px-2 rounded-md bg-hover-surface overflow-auto";
|
|
592
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
593
|
+
className: mx("flex", type === "request" ? "ml-[1rem] justify-end" : "mr-[1rem]", classNames),
|
|
594
|
+
children: [
|
|
595
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
596
|
+
className: mx(wrapper, "whitespace-pre text-error-text"),
|
|
597
|
+
children: String(error)
|
|
598
|
+
}),
|
|
599
|
+
text !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
600
|
+
className: mx(wrapper, type === "request" && "bg-primary-500 dark:bg-primary-600"),
|
|
601
|
+
children: text || "Ø"
|
|
602
|
+
}),
|
|
603
|
+
data && /* @__PURE__ */ jsx(JsonHighlighter, {
|
|
604
|
+
data,
|
|
605
|
+
classNames: mx(wrapper, "text-xs")
|
|
606
|
+
})
|
|
607
|
+
]
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
var RobotAvatar = () => /* @__PURE__ */ jsx(Avatar.Root, { children: /* @__PURE__ */ jsx(Avatar.Content, {
|
|
611
|
+
size: 6,
|
|
612
|
+
variant: "circle",
|
|
613
|
+
icon: "ph--drone--regular"
|
|
614
|
+
}) });
|
|
615
|
+
//#endregion
|
|
616
|
+
export { NotebookMenu, NotebookStack, QueryEditor, ScriptToolbar, TestPanel, TypescriptEditor };
|
|
617
|
+
|
|
618
|
+
//# sourceMappingURL=components.mjs.map
|