@dxos/plugin-script 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea
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-E5NXT4UQ.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs +817 -0
- package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs +148 -0
- package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-IABOSTBK.mjs → app-graph-builder-LEOPGBJD.mjs} +10 -8
- package/dist/lib/browser/app-graph-builder-LEOPGBJD.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-AR7ITBCD.mjs → blueprint-definition-6PZWZM2Y.mjs} +5 -3
- package/dist/lib/{node-esm/blueprint-definition-TJY4TX6S.mjs.map → browser/blueprint-definition-6PZWZM2Y.mjs.map} +1 -1
- package/dist/lib/browser/chunk-5S5YQNJZ.mjs +304 -0
- package/dist/lib/browser/chunk-5S5YQNJZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6CAH7VIE.mjs → chunk-A5K3TXYA.mjs} +20 -34
- package/dist/lib/browser/chunk-A5K3TXYA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
- package/dist/lib/browser/chunk-HCURXADW.mjs +102 -0
- package/dist/lib/browser/chunk-HCURXADW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-TH7GXPE3.mjs → chunk-HHTOAI2J.mjs} +126 -38
- package/dist/lib/browser/chunk-HHTOAI2J.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YCZPTTFO.mjs → chunk-IQMYIWHG.mjs} +14 -14
- package/dist/lib/browser/chunk-IQMYIWHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-LI4P25M5.mjs +111 -0
- package/dist/lib/browser/chunk-LI4P25M5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NXKU3BNX.mjs → chunk-Q2DGRQRN.mjs} +47 -14
- package/dist/lib/browser/chunk-Q2DGRQRN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
- package/dist/lib/browser/{compiler-2HJH34GM.mjs → compiler-Q4UY2COU.mjs} +12 -24
- package/dist/lib/{node-esm/compiler-7SP27RA6.mjs.map → browser/compiler-Q4UY2COU.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +105 -41
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-YMK5SXVC.mjs → intent-resolver-AMMHATM7.mjs} +39 -23
- package/dist/lib/browser/intent-resolver-AMMHATM7.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FEM5WWFH.mjs → react-surface-X4NATU6B.mjs} +43 -19
- package/dist/lib/browser/react-surface-X4NATU6B.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-6UXY7F7D.mjs} +10 -8
- package/dist/lib/browser/settings-6UXY7F7D.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +8 -4
- package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs +818 -0
- package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs +149 -0
- package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-CQTTAYHP.mjs → app-graph-builder-XJ3MY5BM.mjs} +10 -8
- package/dist/lib/node-esm/app-graph-builder-XJ3MY5BM.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-TJY4TX6S.mjs → blueprint-definition-5R6YCSZZ.mjs} +4 -3
- package/dist/lib/{browser/blueprint-definition-AR7ITBCD.mjs.map → node-esm/blueprint-definition-5R6YCSZZ.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs +90 -0
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
- package/dist/lib/node-esm/chunk-EJLYOSD7.mjs +113 -0
- package/dist/lib/node-esm/chunk-EJLYOSD7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2GBESIHU.mjs → chunk-GA27XSEY.mjs} +20 -34
- package/dist/lib/node-esm/chunk-GA27XSEY.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-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-N2XLVOFB.mjs +103 -0
- package/dist/lib/node-esm/chunk-N2XLVOFB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-M642JUOZ.mjs → chunk-O7HXE72S.mjs} +47 -14
- package/dist/lib/node-esm/chunk-O7HXE72S.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6M2R2FQF.mjs → chunk-OZ6LCME4.mjs} +126 -38
- package/dist/lib/node-esm/chunk-OZ6LCME4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TUGLYZDT.mjs +305 -0
- package/dist/lib/node-esm/chunk-TUGLYZDT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZA36GO4T.mjs → chunk-UEGPBCSF.mjs} +14 -14
- package/dist/lib/node-esm/chunk-UEGPBCSF.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-7SP27RA6.mjs → compiler-I6A4KE6E.mjs} +12 -24
- package/dist/lib/{browser/compiler-2HJH34GM.mjs.map → node-esm/compiler-I6A4KE6E.mjs.map} +2 -2
- package/dist/lib/node-esm/index.mjs +105 -41
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-SKRDYQCZ.mjs → intent-resolver-YKLZQR7U.mjs} +39 -23
- package/dist/lib/node-esm/intent-resolver-YKLZQR7U.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-AOKMDJR4.mjs → react-surface-LVGLBSTE.mjs} +43 -19
- package/dist/lib/node-esm/react-surface-LVGLBSTE.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-O4EZPUE3.mjs} +10 -8
- package/dist/lib/node-esm/settings-O4EZPUE3.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +8 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +110 -7
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +10 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +251 -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 +245 -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/ScriptContainer.d.ts +4 -4
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +237 -2
- 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 +2 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +11 -11
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +4 -14
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +45 -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/chess.d.ts.map +1 -1
- 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.map +1 -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 +43 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
- 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/translations.d.ts +29 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +31 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +54 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +75 -68
- package/src/ScriptPlugin.tsx +88 -69
- package/src/capabilities/app-graph-builder.ts +7 -6
- package/src/capabilities/artifact-definition.ts +1 -1
- package/src/capabilities/intent-resolver.ts +20 -11
- package/src/capabilities/react-surface.tsx +25 -13
- package/src/capabilities/settings.ts +3 -3
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +11 -4
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +11 -17
- package/src/components/NotebookContainer.stories.tsx +83 -0
- package/src/components/NotebookContainer.tsx +263 -0
- package/src/components/NotebookStack/NotebookCell.tsx +208 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +5 -5
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +22 -10
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +24 -27
- package/src/components/Settings/ScriptObjectSettings.tsx +95 -11
- package/src/components/Settings/ScriptPluginSettings.tsx +4 -19
- package/src/components/TestPanel/TestContainer.tsx +2 -2
- package/src/components/TestPanel/TestPanel.tsx +7 -7
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +71 -16
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +36 -34
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +14 -15
- package/src/hooks/format.ts +4 -4
- package/src/hooks/template.ts +6 -15
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +5 -5
- package/src/index.ts +1 -0
- package/src/meta.ts +7 -5
- package/src/notebook/compute-graph.test.ts +70 -0
- package/src/notebook/compute-graph.ts +206 -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/chess.ts +2 -0
- package/src/templates/data-generator.ts +2 -0
- package/src/templates/discord.ts +9 -1
- package/src/templates/forex-effect.ts +5 -1
- package/src/templates/forex.ts +2 -0
- package/src/templates/gmail.ts +21 -9
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +32 -7
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +11 -15
- package/src/util/functions.ts +33 -4
- package/dist/lib/browser/DeploymentDialog-QZSTVNIS.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-JUPCBUCP.mjs +0 -263
- package/dist/lib/browser/ScriptContainer-JUPCBUCP.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-IABOSTBK.mjs.map +0 -7
- package/dist/lib/browser/chunk-6CAH7VIE.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-NXKU3BNX.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-RNGIQIEJ.mjs +0 -88
- package/dist/lib/browser/chunk-RNGIQIEJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-TH7GXPE3.mjs.map +0 -7
- package/dist/lib/browser/chunk-YCZPTTFO.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YMK5SXVC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FEM5WWFH.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-G6EHEPXN.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-UXZUDQF6.mjs +0 -264
- package/dist/lib/node-esm/ScriptContainer-UXZUDQF6.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-CQTTAYHP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2GBESIHU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6M2R2FQF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GWHLP5LM.mjs +0 -90
- package/dist/lib/node-esm/chunk-GWHLP5LM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M642JUOZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZA36GO4T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-SKRDYQCZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-AOKMDJR4.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -38
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -37
- /package/dist/lib/browser/{DeploymentDialog-QZSTVNIS.mjs.map → DeploymentDialog-E5NXT4UQ.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-G6EHEPXN.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
|
|
7
|
+
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { AutomationPlugin } from '@dxos/plugin-automation';
|
|
10
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
|
+
import { SpacePlugin } from '@dxos/plugin-space';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
|
|
14
|
+
import { createNotebook } from '../../testing';
|
|
15
|
+
import { translations } from '../../translations';
|
|
16
|
+
|
|
17
|
+
import { NotebookStack } from './NotebookStack';
|
|
18
|
+
|
|
19
|
+
const meta = {
|
|
20
|
+
title: 'plugins/plugin-script/NotebookStack',
|
|
21
|
+
component: NotebookStack,
|
|
22
|
+
decorators: [
|
|
23
|
+
withTheme,
|
|
24
|
+
withLayout({ container: 'column', classNames: 'is-prose' }),
|
|
25
|
+
// TODO(burdon): Factor out Surface to avoid dependency on app-framework.
|
|
26
|
+
withPluginManager({
|
|
27
|
+
plugins: [
|
|
28
|
+
ClientPlugin({
|
|
29
|
+
onClientInitialized: async ({ client }) => {
|
|
30
|
+
await client.halo.createIdentity();
|
|
31
|
+
await client.spaces.waitUntilReady();
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
SpacePlugin({}),
|
|
35
|
+
SettingsPlugin(),
|
|
36
|
+
IntentPlugin(),
|
|
37
|
+
AutomationPlugin(),
|
|
38
|
+
],
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
parameters: {
|
|
42
|
+
translations,
|
|
43
|
+
},
|
|
44
|
+
} satisfies Meta<typeof NotebookStack>;
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
49
|
+
|
|
50
|
+
export const Default: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
notebook: createNotebook(),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { DropdownMenu, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { Stack, StackItem, type StackProps } from '@dxos/react-ui-stack';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
|
+
import { type Notebook } from '../../types';
|
|
12
|
+
import { type TypescriptEditorProps } from '../TypescriptEditor';
|
|
13
|
+
|
|
14
|
+
import { NotebookCell, type NotebookCellProps } from './NotebookCell';
|
|
15
|
+
import { NotebookMenu } from './NotebookMenu';
|
|
16
|
+
|
|
17
|
+
const minSectionHeight = 'min-bs-[16rem]';
|
|
18
|
+
|
|
19
|
+
export type NotebookStackProps = ThemedClassName<
|
|
20
|
+
{
|
|
21
|
+
notebook?: Notebook.Notebook;
|
|
22
|
+
onRearrange?: StackProps['onRearrange'];
|
|
23
|
+
} & (Pick<NotebookSectionProps, 'space' | 'graph' | 'promptResults' | 'onCellInsert' | 'onCellDelete'> &
|
|
24
|
+
Pick<TypescriptEditorProps, 'env'>)
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Option for narrow rail (with compact buttons that align with first button in toolbar).
|
|
28
|
+
export const NotebookStack = ({ classNames, notebook, onRearrange, ...props }: NotebookStackProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Stack classNames={classNames} orientation='vertical' size='contain' rail onRearrange={onRearrange}>
|
|
31
|
+
{notebook?.cells.map((cell, i) => (
|
|
32
|
+
<NotebookSection key={i} cell={cell} {...props} />
|
|
33
|
+
))}
|
|
34
|
+
</Stack>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type NotebookSectionProps = NotebookCellProps;
|
|
39
|
+
|
|
40
|
+
const NotebookSection = ({
|
|
41
|
+
cell,
|
|
42
|
+
space,
|
|
43
|
+
env,
|
|
44
|
+
promptResults,
|
|
45
|
+
onCellInsert,
|
|
46
|
+
onCellDelete,
|
|
47
|
+
...props
|
|
48
|
+
}: NotebookSectionProps) => {
|
|
49
|
+
const { t } = useTranslation(meta.id);
|
|
50
|
+
const resizable = cell.type === 'query';
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<StackItem.Root role='section' item={cell} draggable classNames={resizable && minSectionHeight}>
|
|
54
|
+
<StackItem.Heading classNames='bs-full p-1 justify-between attention-surface'>
|
|
55
|
+
<StackItem.DragHandle asChild>
|
|
56
|
+
<IconButton variant='ghost' icon='ph--dots-six-vertical--regular' iconOnly label='Drag handle' />
|
|
57
|
+
</StackItem.DragHandle>
|
|
58
|
+
<DropdownMenu.Root>
|
|
59
|
+
<DropdownMenu.Trigger asChild>
|
|
60
|
+
<IconButton
|
|
61
|
+
variant='ghost'
|
|
62
|
+
icon='ph--dots-three--regular'
|
|
63
|
+
iconOnly
|
|
64
|
+
label={t('notebook cell insert label')}
|
|
65
|
+
/>
|
|
66
|
+
</DropdownMenu.Trigger>
|
|
67
|
+
<NotebookMenu cell={cell} onCellInsert={onCellInsert} onCellDelete={onCellDelete} />
|
|
68
|
+
</DropdownMenu.Root>
|
|
69
|
+
{resizable && <StackItem.ResizeHandle />}
|
|
70
|
+
</StackItem.Heading>
|
|
71
|
+
|
|
72
|
+
{/* TODO(burdon): Move drag preview to outer stack (uniformly). */}
|
|
73
|
+
<StackItem.DragPreview>
|
|
74
|
+
{({ item: cell }) => (
|
|
75
|
+
<StackItem.Content classNames='overflow-visible bg-groupSurface border border-subduedSeparator'>
|
|
76
|
+
<NotebookCell space={space} cell={cell} env={env} dragging />
|
|
77
|
+
</StackItem.Content>
|
|
78
|
+
)}
|
|
79
|
+
</StackItem.DragPreview>
|
|
80
|
+
|
|
81
|
+
<StackItem.Content classNames='overflow-visible'>
|
|
82
|
+
<NotebookCell space={space} cell={cell} env={env} promptResults={promptResults} {...props} />
|
|
83
|
+
</StackItem.Content>
|
|
84
|
+
</StackItem.Root>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Script } from '@dxos/functions';
|
|
8
8
|
import { createDocAccessor, getSpace } from '@dxos/react-client/echo';
|
|
9
9
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
10
|
import { createDataExtensions, listener, stackItemContentEditorClassNames } from '@dxos/react-ui-editor';
|
|
11
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
12
|
|
|
13
13
|
import { useDeployState, useToolbarState } from '../hooks';
|
|
14
|
-
import { type
|
|
14
|
+
import { type ScriptSettings } from '../types';
|
|
15
15
|
|
|
16
16
|
import { ScriptToolbar } from './ScriptToolbar';
|
|
17
17
|
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
18
18
|
|
|
19
19
|
export type ScriptEditorProps = {
|
|
20
20
|
role: string;
|
|
21
|
-
script:
|
|
22
|
-
settings?:
|
|
21
|
+
script: Script.Script;
|
|
22
|
+
settings?: ScriptSettings;
|
|
23
23
|
} & Pick<TypescriptEditorProps, 'env'>;
|
|
24
24
|
|
|
25
25
|
export const ScriptContainer = ({ role, script, settings = { editorInputMode: 'vscode' }, env }: ScriptEditorProps) => {
|
|
@@ -33,7 +33,7 @@ export const ScriptContainer = ({ role, script, settings = { editorInputMode: 'v
|
|
|
33
33
|
script.source.target
|
|
34
34
|
? [
|
|
35
35
|
listener({
|
|
36
|
-
onChange: (text) => {
|
|
36
|
+
onChange: ({ text }) => {
|
|
37
37
|
if (script.source.target?.content !== text) {
|
|
38
38
|
script.changed = true;
|
|
39
39
|
}
|
|
@@ -2,21 +2,33 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { Script } from '@dxos/functions';
|
|
10
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
|
|
13
|
+
import { translations } from '../../translations';
|
|
13
14
|
|
|
14
15
|
import { ScriptToolbar } from './ScriptToolbar';
|
|
15
16
|
|
|
16
17
|
const meta = {
|
|
17
18
|
title: 'plugins/plugin-script/Toolbar',
|
|
18
19
|
component: ScriptToolbar,
|
|
19
|
-
|
|
20
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
21
|
+
decorators: [
|
|
22
|
+
withTheme,
|
|
23
|
+
withLayout({ classNames: 'is-prose' }),
|
|
24
|
+
withPluginManager({
|
|
25
|
+
plugins: [IntentPlugin(), ClientPlugin({})],
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
parameters: {
|
|
29
|
+
layout: 'centered',
|
|
30
|
+
translations,
|
|
31
|
+
},
|
|
20
32
|
} satisfies Meta<typeof ScriptToolbar>;
|
|
21
33
|
|
|
22
34
|
export default meta;
|
|
@@ -25,11 +37,11 @@ type Story = StoryObj<typeof meta>;
|
|
|
25
37
|
|
|
26
38
|
export const Default: Story = {
|
|
27
39
|
args: {
|
|
28
|
-
|
|
40
|
+
state: {},
|
|
41
|
+
script: Script.make({
|
|
29
42
|
name: 'test',
|
|
30
43
|
description: 'test',
|
|
31
|
-
source:
|
|
44
|
+
source: 'test',
|
|
32
45
|
}),
|
|
33
|
-
state: {},
|
|
34
46
|
},
|
|
35
47
|
};
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { Rx } from '@effect-rx/rx-react';
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type Script } from '@dxos/functions';
|
|
9
9
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
|
-
import { ElevationProvider,
|
|
10
|
+
import { ElevationProvider, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import {
|
|
12
12
|
type ActionGraphProps,
|
|
13
13
|
MenuProvider,
|
|
@@ -25,7 +25,28 @@ import {
|
|
|
25
25
|
createTemplateSelect,
|
|
26
26
|
useDeployDeps,
|
|
27
27
|
} from '../../hooks';
|
|
28
|
-
import {
|
|
28
|
+
import { meta } from '../../meta';
|
|
29
|
+
|
|
30
|
+
export type ScriptToolbarProps = {
|
|
31
|
+
role?: string;
|
|
32
|
+
script: Script.Script;
|
|
33
|
+
state: ScriptToolbarState;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const ScriptToolbar = ({ script, role, state }: ScriptToolbarProps) => {
|
|
37
|
+
const { t } = useTranslation(meta.id);
|
|
38
|
+
const options = useDeployDeps({ script });
|
|
39
|
+
const menu = useMemo(() => createToolbarActions({ state, script, t, ...options }), [state, script, options, t]);
|
|
40
|
+
const actions = useMenuActions(menu);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
44
|
+
<MenuProvider {...actions} attendableId={fullyQualifiedId(script)}>
|
|
45
|
+
<ToolbarMenu />
|
|
46
|
+
</MenuProvider>
|
|
47
|
+
</ElevationProvider>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
29
50
|
|
|
30
51
|
const createToolbarActions = ({ state, script, ...options }: CreateDeployOptions): Rx.Rx<ActionGraphProps> =>
|
|
31
52
|
Rx.make((get) =>
|
|
@@ -42,27 +63,3 @@ const createToolbarActions = ({ state, script, ...options }: CreateDeployOptions
|
|
|
42
63
|
}),
|
|
43
64
|
),
|
|
44
65
|
);
|
|
45
|
-
|
|
46
|
-
export type ScriptToolbarProps = ThemedClassName<{
|
|
47
|
-
role?: string;
|
|
48
|
-
script: ScriptType;
|
|
49
|
-
state: ScriptToolbarState;
|
|
50
|
-
}>;
|
|
51
|
-
|
|
52
|
-
export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbarProps) => {
|
|
53
|
-
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
54
|
-
const options = useDeployDeps({ script });
|
|
55
|
-
const toolbarCreator = useMemo(
|
|
56
|
-
() => createToolbarActions({ state, script, t, ...options }),
|
|
57
|
-
[state, script, options, t],
|
|
58
|
-
);
|
|
59
|
-
const menu = useMenuActions(toolbarCreator);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
63
|
-
<MenuProvider {...menu} attendableId={fullyQualifiedId(script)}>
|
|
64
|
-
<ToolbarMenu classNames={classNames} />
|
|
65
|
-
</MenuProvider>
|
|
66
|
-
</ElevationProvider>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
@@ -5,31 +5,35 @@
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
6
|
import React, { type ChangeEvent, useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
|
+
import { ToolId } from '@dxos/ai';
|
|
8
9
|
import { SettingsAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
11
|
+
import { Function, type Script, getInvocationUrl, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
10
12
|
import { log } from '@dxos/log';
|
|
11
13
|
import { useClient } from '@dxos/react-client';
|
|
12
14
|
import { Filter, Ref, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
13
15
|
import { Button, Clipboard, Input, useAsyncEffect, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
16
|
import { DataType } from '@dxos/schema';
|
|
17
|
+
import { kebabize } from '@dxos/util';
|
|
15
18
|
|
|
16
|
-
import {
|
|
19
|
+
import { meta } from '../../meta';
|
|
17
20
|
|
|
18
21
|
export type ScriptObjectSettingsProps = {
|
|
19
|
-
object:
|
|
22
|
+
object: Script.Script;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const ScriptObjectSettings = ({ object }: ScriptObjectSettingsProps) => {
|
|
23
26
|
return (
|
|
24
27
|
<>
|
|
25
28
|
<Binding object={object} />
|
|
29
|
+
<BlueprintEditor object={object} />
|
|
26
30
|
<Publishing object={object} />
|
|
27
31
|
</>
|
|
28
32
|
);
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
32
|
-
const { t } = useTranslation(
|
|
36
|
+
const { t } = useTranslation(meta.id);
|
|
33
37
|
return (
|
|
34
38
|
<Input.Root>
|
|
35
39
|
<Input.Label>{t('description label')}</Input.Label>
|
|
@@ -44,11 +48,95 @@ export const ScriptProperties = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
50
|
|
|
51
|
+
const BlueprintEditor = ({ object }: ScriptObjectSettingsProps) => {
|
|
52
|
+
const { t } = useTranslation(meta.id);
|
|
53
|
+
const space = getSpace(object);
|
|
54
|
+
const [fn] = useQuery(space, Filter.type(Function.Function, { source: Ref.make(object) }));
|
|
55
|
+
const blueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
|
|
56
|
+
|
|
57
|
+
const [creating, setCreating] = useState(false);
|
|
58
|
+
const [instructions, setInstructions] = useState<string>(`You can run the script "${object.name ?? 'script'}".`);
|
|
59
|
+
const blueprintKey = `dxos.org/blueprint/${kebabize(object.name ?? 'script')}`;
|
|
60
|
+
const existingBlueprint = blueprints.find((bp) => bp.key === blueprintKey);
|
|
61
|
+
|
|
62
|
+
useAsyncEffect(async () => {
|
|
63
|
+
if (!existingBlueprint) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const source = await existingBlueprint.instructions.source.load();
|
|
67
|
+
setInstructions(source.content ?? '');
|
|
68
|
+
}, [existingBlueprint]);
|
|
69
|
+
|
|
70
|
+
const handleSave = useCallback(async () => {
|
|
71
|
+
if (!space) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setCreating(true);
|
|
76
|
+
try {
|
|
77
|
+
if (existingBlueprint) {
|
|
78
|
+
const text = await existingBlueprint.instructions.source.load();
|
|
79
|
+
text.content = instructions;
|
|
80
|
+
if (fn?.key) {
|
|
81
|
+
const toolId = ToolId.make(fn.key);
|
|
82
|
+
if (!existingBlueprint.tools?.includes(toolId)) {
|
|
83
|
+
existingBlueprint.tools = [...(existingBlueprint.tools ?? []), toolId];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else if (fn?.key) {
|
|
87
|
+
space.db.add(
|
|
88
|
+
Blueprint.make({
|
|
89
|
+
key: blueprintKey,
|
|
90
|
+
name: object.name ?? 'Script',
|
|
91
|
+
instructions: Template.make({
|
|
92
|
+
source: instructions,
|
|
93
|
+
}),
|
|
94
|
+
tools: [ToolId.make(fn.key)],
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
await space.db.flush();
|
|
99
|
+
} finally {
|
|
100
|
+
setCreating(false);
|
|
101
|
+
}
|
|
102
|
+
}, [space, existingBlueprint, fn, blueprintKey, object.name, instructions]);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div className='flex flex-col gap-4 mlb-cardSpacingBlock'>
|
|
106
|
+
<div>
|
|
107
|
+
<h2>{t('blueprint editor label', { default: 'Blueprint' })}</h2>
|
|
108
|
+
<p className='text-description text-sm'>
|
|
109
|
+
{t('blueprint editor description', { default: 'Create a blueprint that exposes this script as a tool.' })}
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
<Input.Root>
|
|
113
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
114
|
+
<Input.Label>{t('blueprint instructions label', { default: 'Instructions' })}</Input.Label>
|
|
115
|
+
<Input.TextArea
|
|
116
|
+
placeholder={t('blueprint instructions placeholder', { default: 'Describe how this tool should be used.' })}
|
|
117
|
+
rows={6}
|
|
118
|
+
value={instructions}
|
|
119
|
+
onChange={(event) => setInstructions(event.target.value)}
|
|
120
|
+
classNames='resize-y'
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</Input.Root>
|
|
124
|
+
<div className='flex justify-end gap-2'>
|
|
125
|
+
<Button disabled={(!existingBlueprint && !fn?.key) || creating} onClick={handleSave}>
|
|
126
|
+
{t(creating ? 'creating label' : 'create blueprint label', {
|
|
127
|
+
default: creating ? 'Creating…' : 'Create blueprint',
|
|
128
|
+
})}
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
47
135
|
const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
48
|
-
const { t } = useTranslation(
|
|
136
|
+
const { t } = useTranslation(meta.id);
|
|
49
137
|
const client = useClient();
|
|
50
138
|
const space = getSpace(object);
|
|
51
|
-
const [fn] = useQuery(space, Filter.type(
|
|
139
|
+
const [fn] = useQuery(space, Filter.type(Function.Function, { source: Ref.make(object) }));
|
|
52
140
|
|
|
53
141
|
const functionId = fn && getUserFunctionIdInMetadata(getMeta(fn));
|
|
54
142
|
const functionUrl =
|
|
@@ -109,7 +197,7 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
109
197
|
|
|
110
198
|
// TODO(burdon): Move to separate tab?
|
|
111
199
|
const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
112
|
-
const { t } = useTranslation(
|
|
200
|
+
const { t } = useTranslation(meta.id);
|
|
113
201
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
114
202
|
const space = getSpace(object);
|
|
115
203
|
const [githubToken] = useQuery(space, Filter.type(DataType.AccessToken, { source: 'github.com' }));
|
|
@@ -196,7 +284,3 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
196
284
|
</div>
|
|
197
285
|
);
|
|
198
286
|
};
|
|
199
|
-
|
|
200
|
-
// TODO(wittjosiah): Factor out.
|
|
201
|
-
// From https://stackoverflow.com/a/67243723/2804332
|
|
202
|
-
const kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
|
|
@@ -4,38 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
7
|
import { useClient } from '@dxos/react-client';
|
|
9
8
|
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
9
|
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
11
10
|
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
12
11
|
|
|
13
12
|
import { meta } from '../../meta';
|
|
14
|
-
import { type
|
|
13
|
+
import { type ScriptSettings } from '../../types';
|
|
14
|
+
import { getAccessCredential } from '../../util';
|
|
15
15
|
|
|
16
|
-
export const ScriptPluginSettings = ({ settings }: { settings:
|
|
16
|
+
export const ScriptPluginSettings = ({ settings }: { settings: ScriptSettings }) => {
|
|
17
17
|
const { t } = useTranslation(meta.id);
|
|
18
18
|
const client = useClient();
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Check token.
|
|
21
21
|
const handleAuthenticate = async () => {
|
|
22
22
|
const { identityKey } = client.halo.identity.get()!;
|
|
23
|
-
await client.halo.writeCredentials([
|
|
24
|
-
{
|
|
25
|
-
issuer: identityKey,
|
|
26
|
-
issuanceDate: new Date(),
|
|
27
|
-
subject: {
|
|
28
|
-
id: identityKey,
|
|
29
|
-
assertion: {
|
|
30
|
-
'@type': 'dxos.halo.credentials.ServiceAccess',
|
|
31
|
-
serverName: 'hub.dxos.network',
|
|
32
|
-
serverKey: identityKey,
|
|
33
|
-
identityKey,
|
|
34
|
-
capabilities: ['composer:beta'],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
} satisfies Credential,
|
|
38
|
-
]);
|
|
23
|
+
await client.halo.writeCredentials([getAccessCredential(identityKey)]);
|
|
39
24
|
};
|
|
40
25
|
|
|
41
26
|
return (
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Script } from '@dxos/functions';
|
|
8
8
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
9
|
|
|
10
10
|
import { useDeployState, useToolbarState } from '../../hooks';
|
|
@@ -13,7 +13,7 @@ import { TestPanel } from './TestPanel';
|
|
|
13
13
|
|
|
14
14
|
export type TestContainerProps = {
|
|
15
15
|
role: string;
|
|
16
|
-
script:
|
|
16
|
+
script: Script.Script;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const TestContainer = ({ script }: TestContainerProps) => {
|
|
@@ -9,7 +9,7 @@ import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } fr
|
|
|
9
9
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
10
|
import { errorText, mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
13
|
|
|
14
14
|
type State = 'pending' | 'responding';
|
|
15
15
|
|
|
@@ -24,7 +24,7 @@ export type TestPanelProps = ThemedClassName<{
|
|
|
24
24
|
|
|
25
25
|
// TODO(burdon): Need persistent history (currently lost when switching tabs)..
|
|
26
26
|
export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
27
|
-
const { t } = useTranslation(
|
|
27
|
+
const { t } = useTranslation(meta.id);
|
|
28
28
|
|
|
29
29
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
30
30
|
const [input, setInput] = useState('');
|
|
@@ -41,7 +41,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const controller = useRef<AbortController>();
|
|
44
|
+
const controller = useRef<AbortController>(null);
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
return () => {
|
|
47
47
|
handleStop();
|
|
@@ -50,7 +50,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
50
50
|
|
|
51
51
|
const handleStop = () => {
|
|
52
52
|
controller.current?.abort('stop');
|
|
53
|
-
controller.current =
|
|
53
|
+
controller.current = null;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const handleClear = () => {
|
|
@@ -62,7 +62,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const handleResponse = ({ text, data, error }: { text?: string; data?: any; error?: Error } = {}) => {
|
|
65
|
-
controller.current =
|
|
65
|
+
controller.current = null;
|
|
66
66
|
setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);
|
|
67
67
|
setResult('');
|
|
68
68
|
setState(null);
|
|
@@ -163,7 +163,7 @@ export const TestPanel = ({ classNames, functionUrl }: TestPanelProps) => {
|
|
|
163
163
|
{/* TODO(burdon): Replace with Thread. */}
|
|
164
164
|
<MessageThread ref={scrollerRef} state={state} result={result} history={history} />
|
|
165
165
|
{/* TODO(burdon): Replace with Form based on the function's input schema. */}
|
|
166
|
-
<Toolbar.Root
|
|
166
|
+
<Toolbar.Root>
|
|
167
167
|
<Input.Root>
|
|
168
168
|
<Input.TextInput
|
|
169
169
|
ref={inputRef}
|
|
@@ -237,7 +237,7 @@ const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message
|
|
|
237
237
|
)}
|
|
238
238
|
|
|
239
239
|
{data && (
|
|
240
|
-
<SyntaxHighlighter language='json' className={mx(wrapper, '
|
|
240
|
+
<SyntaxHighlighter language='json' className={mx(wrapper, 'text-xs')}>
|
|
241
241
|
{JSON.stringify(data, null, 2)}
|
|
242
242
|
</SyntaxHighlighter>
|
|
243
243
|
)}
|