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