@dxos/plugin-script 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-65TWT6S5.mjs +13 -0
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs +683 -0
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-IABOSTBK.mjs → app-graph-builder-DPYULSME.mjs} +8 -7
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +28 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +7 -0
- package/dist/lib/browser/chunk-5CYLWXRH.mjs +89 -0
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +7 -0
- package/dist/lib/browser/chunk-75LH4EUR.mjs +326 -0
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MWZDJNCQ.mjs → chunk-E7DXDICD.mjs} +27 -28
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EZVXV6DA.mjs} +3 -5
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OULPWKXN.mjs → chunk-I3QSGUFJ.mjs} +157 -66
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SUOLJH55.mjs → chunk-JO2O7W6J.mjs} +71 -50
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +7 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs +112 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OAVS36Q3.mjs → chunk-NM4WQS4F.mjs} +14 -14
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-OKXN2N7M.mjs} +2 -2
- package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
- package/dist/lib/browser/{compiler-RIWQVBPX.mjs → compiler-G2N2CG63.mjs} +24 -11
- package/dist/lib/browser/{compiler-RIWQVBPX.mjs.map → compiler-G2N2CG63.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +113 -37
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-SAL2TM7U.mjs → intent-resolver-JLU7DVLQ.mjs} +31 -15
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-E3SXU6ON.mjs → react-surface-76SDTUYG.mjs} +38 -15
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-ERFKVNUK.mjs} +9 -8
- package/dist/lib/browser/settings-ERFKVNUK.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{DeploymentDialog-O2XZVRLU.mjs → DeploymentDialog-I63ZC2HH.mjs} +6 -5
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs +684 -0
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-CQTTAYHP.mjs → app-graph-builder-UXJGHXSL.mjs} +8 -7
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +30 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +7 -0
- 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-4X375PGY.mjs +90 -0
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs +327 -0
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IO6T72KY.mjs → chunk-C2ORIPKH.mjs} +14 -14
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-NUXZQQ6P.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-OG2SIKHE.mjs} +3 -5
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6WMFL3JL.mjs → chunk-SMFPSKQT.mjs} +157 -66
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +114 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7L4JDSXJ.mjs → chunk-VZAFGLD7.mjs} +27 -28
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PACUN7RS.mjs → chunk-YW36TZ7K.mjs} +71 -50
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-S52P5P3F.mjs → compiler-PLDAZ5GJ.mjs} +24 -11
- package/dist/lib/node-esm/{compiler-S52P5P3F.mjs.map → compiler-PLDAZ5GJ.mjs.map} +2 -2
- package/dist/lib/node-esm/index.mjs +113 -37
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-GO53JOPL.mjs → intent-resolver-SFGTIFOG.mjs} +31 -15
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-W3NRCS5O.mjs → react-surface-SHEBNW4R.mjs} +38 -15
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-5TYXQ42N.mjs} +9 -8
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +7 -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 +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +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/DeploymentDialog/DeploymentDialog.d.ts +2 -2
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +246 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.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 +248 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +14 -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 +248 -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 +2 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +245 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- 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/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 +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- 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 +12 -11
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- 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/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/notebook.d.ts +35 -0
- package/dist/types/src/notebook/notebook.d.ts.map +1 -0
- package/dist/types/src/notebook/notebook.test.d.ts +2 -0
- package/dist/types/src/notebook/notebook.test.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 +19 -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 +28 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/actions.d.ts +66 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +54 -31
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +3 -3
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +5 -2
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +72 -68
- package/src/ScriptPlugin.tsx +99 -64
- package/src/capabilities/app-graph-builder.ts +4 -3
- package/src/capabilities/artifact-definition.ts +1 -1
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +14 -4
- package/src/capabilities/react-surface.tsx +17 -5
- package/src/capabilities/settings.ts +3 -3
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +34 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +12 -18
- package/src/components/FrameContainer/FrameContainer.tsx +3 -2
- package/src/components/NotebookContainer.stories.tsx +32 -0
- package/src/components/NotebookContainer.tsx +124 -0
- package/src/components/NotebookStack/NotebookCell.tsx +217 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +32 -0
- package/src/components/NotebookStack/NotebookStack.tsx +79 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -18
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +29 -22
- package/src/components/Settings/ScriptObjectSettings.tsx +109 -29
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestPanel.tsx +6 -6
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +74 -27
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +30 -24
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +17 -18
- package/src/hooks/format.ts +2 -2
- package/src/hooks/template.ts +4 -3
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +3 -3
- package/src/index.ts +1 -0
- package/src/meta.ts +2 -4
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/notebook.test.ts +70 -0
- package/src/notebook/notebook.ts +183 -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 +11 -3
- package/src/templates/forex-effect.ts +6 -2
- package/src/templates/forex.ts +2 -0
- package/src/templates/gmail.ts +31 -60
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +47 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +31 -4
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +1 -0
- package/src/types/schema.ts +30 -19
- package/src/util/deploy.ts +20 -33
- package/src/util/functions.ts +35 -6
- package/dist/lib/browser/DeploymentDialog-C3XH2Z56.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-FUBR4OZE.mjs +0 -263
- package/dist/lib/browser/ScriptContainer-FUBR4OZE.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-IABOSTBK.mjs.map +0 -7
- package/dist/lib/browser/chunk-G4A2MGAL.mjs +0 -88
- package/dist/lib/browser/chunk-G4A2MGAL.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-MWZDJNCQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-OAVS36Q3.mjs.map +0 -7
- package/dist/lib/browser/chunk-OULPWKXN.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-SUOLJH55.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-SAL2TM7U.mjs.map +0 -7
- package/dist/lib/browser/react-surface-E3SXU6ON.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-VJ75TM24.mjs +0 -264
- package/dist/lib/node-esm/ScriptContainer-VJ75TM24.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-CQTTAYHP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3BBEM2U7.mjs +0 -90
- package/dist/lib/node-esm/chunk-3BBEM2U7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6WMFL3JL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7L4JDSXJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IO6T72KY.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-PACUN7RS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GO53JOPL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-W3NRCS5O.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/lib/browser/{DeploymentDialog-C3XH2Z56.mjs.map → DeploymentDialog-65TWT6S5.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-OKXN2N7M.mjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-O2XZVRLU.mjs.map → DeploymentDialog-I63ZC2HH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-NUXZQQ6P.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { autocompletion, completionKeymap } from '@codemirror/autocomplete';
|
|
5
6
|
import { javascript } from '@codemirror/lang-javascript';
|
|
6
|
-
import {
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
8
|
import { lintKeymap } from '@codemirror/lint';
|
|
8
9
|
import { Prec } from '@codemirror/state';
|
|
9
|
-
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
|
|
10
10
|
import { keymap } from '@codemirror/view';
|
|
11
11
|
import { tags } from '@lezer/highlight';
|
|
12
12
|
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
@@ -14,15 +14,15 @@ import { continueKeymap } from '@valtown/codemirror-continue';
|
|
|
14
14
|
import { type HoverInfo, tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from '@valtown/codemirror-ts';
|
|
15
15
|
import React from 'react';
|
|
16
16
|
|
|
17
|
-
import { type ThemeMode, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
17
|
+
import { Domino, type ThemeMode, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
18
18
|
import {
|
|
19
|
+
type BasicExtensionsOptions,
|
|
19
20
|
type EditorInputMode,
|
|
20
21
|
InputModeExtensions,
|
|
21
22
|
type UseTextEditorProps,
|
|
22
|
-
autocomplete,
|
|
23
23
|
createBasicExtensions,
|
|
24
24
|
createThemeExtensions,
|
|
25
|
-
|
|
25
|
+
defaultStyles,
|
|
26
26
|
useTextEditor,
|
|
27
27
|
} from '@dxos/react-ui-editor';
|
|
28
28
|
import { mx } from '@dxos/react-ui-theme';
|
|
@@ -31,18 +31,22 @@ import { isNonNullable } from '@dxos/util';
|
|
|
31
31
|
export type TypescriptEditorProps = ThemedClassName<
|
|
32
32
|
{
|
|
33
33
|
id: string;
|
|
34
|
+
role?: string;
|
|
34
35
|
inputMode?: EditorInputMode;
|
|
35
36
|
toolbar?: boolean;
|
|
36
37
|
env?: VirtualTypeScriptEnvironment;
|
|
38
|
+
options?: BasicExtensionsOptions;
|
|
37
39
|
} & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>
|
|
38
40
|
>;
|
|
39
41
|
|
|
40
42
|
export const TypescriptEditor = ({
|
|
41
43
|
classNames,
|
|
42
44
|
id,
|
|
45
|
+
role = 'article',
|
|
43
46
|
inputMode = 'vscode',
|
|
44
47
|
toolbar,
|
|
45
48
|
env,
|
|
49
|
+
options,
|
|
46
50
|
initialValue,
|
|
47
51
|
extensions,
|
|
48
52
|
scrollTo,
|
|
@@ -63,20 +67,22 @@ export const TypescriptEditor = ({
|
|
|
63
67
|
lineNumbers: true,
|
|
64
68
|
lineWrapping: false,
|
|
65
69
|
monospace: true,
|
|
66
|
-
scrollPastEnd:
|
|
70
|
+
scrollPastEnd: role !== 'section',
|
|
67
71
|
search: true,
|
|
72
|
+
...options,
|
|
68
73
|
}),
|
|
69
74
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
70
75
|
InputModeExtensions[inputMode],
|
|
71
|
-
|
|
76
|
+
|
|
77
|
+
javascript({ typescript: true }),
|
|
78
|
+
autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
|
|
79
|
+
|
|
72
80
|
// Continues block comments when pressing Enter.
|
|
73
81
|
Prec.high(keymap.of(continueKeymap)),
|
|
82
|
+
keymap.of(completionKeymap),
|
|
83
|
+
keymap.of(lintKeymap),
|
|
74
84
|
|
|
75
|
-
// TODO(burdon): Factor out.
|
|
76
|
-
javascript({ typescript: true }),
|
|
77
85
|
// https://github.com/val-town/codemirror-ts
|
|
78
|
-
autocomplete({ override: env ? [tsAutocomplete()] : undefined }),
|
|
79
|
-
keymap.of(lintKeymap),
|
|
80
86
|
env && [
|
|
81
87
|
tsFacet.of({ env, path: `/src/${id}.ts` }),
|
|
82
88
|
tsSync(),
|
|
@@ -88,6 +94,7 @@ export const TypescriptEditor = ({
|
|
|
88
94
|
[id, extensions, themeMode, inputMode, selection, scrollTo],
|
|
89
95
|
);
|
|
90
96
|
|
|
97
|
+
// TODO(brudon): Use react-ui-editor's Editor component.
|
|
91
98
|
return (
|
|
92
99
|
<div
|
|
93
100
|
ref={parentRef}
|
|
@@ -98,8 +105,9 @@ export const TypescriptEditor = ({
|
|
|
98
105
|
);
|
|
99
106
|
};
|
|
100
107
|
|
|
108
|
+
// TODO(burdon): Factor out (react-ui-editor).
|
|
101
109
|
const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
102
|
-
const theme = themeMode === 'dark' ?
|
|
110
|
+
const theme = HighlightStyle.define(themeMode === 'dark' ? defaultStyles.dark : defaultStyles.light);
|
|
103
111
|
|
|
104
112
|
const classFromKind = (_kind: string) => {
|
|
105
113
|
// E.g., localName, methodName, parameterName, etc.
|
|
@@ -118,18 +126,16 @@ const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
|
118
126
|
};
|
|
119
127
|
|
|
120
128
|
return (info: HoverInfo) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return { dom: div };
|
|
129
|
+
return {
|
|
130
|
+
dom: Domino.of('div')
|
|
131
|
+
.classNames('xs:max-is-80 max-is-lg p-1 bg-baseSurface rounded border border-separator')
|
|
132
|
+
.children(
|
|
133
|
+
...(info.quickInfo?.displayParts?.map(({ kind, text }) =>
|
|
134
|
+
Domino.of('span').classNames(classFromKind(kind)).text(text),
|
|
135
|
+
) ?? []),
|
|
136
|
+
)
|
|
137
|
+
.build(),
|
|
138
|
+
};
|
|
133
139
|
};
|
|
134
140
|
};
|
|
135
141
|
|
package/src/components/index.ts
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
+
export * from './NotebookStack';
|
|
7
8
|
export * from './Settings';
|
|
8
9
|
export * from './TestPanel';
|
|
10
|
+
|
|
9
11
|
export { DEPLOYMENT_DIALOG } from './DeploymentDialog';
|
|
10
12
|
|
|
11
13
|
export const ScriptContainer = lazy(() => import('./ScriptContainer'));
|
|
12
14
|
export const DeploymentDialog = lazy(() => import('./DeploymentDialog'));
|
|
15
|
+
export const NotebookContainer = lazy(() => import('./NotebookContainer'));
|
package/src/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { defineEvent } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export namespace ScriptEvents {
|
|
10
|
-
export const SetupCompiler = defineEvent(`${
|
|
10
|
+
export const SetupCompiler = defineEvent(`${meta.id}/event/setup-compiler`);
|
|
11
11
|
}
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { FunctionType, type ScriptType,
|
|
7
|
+
import { FunctionType, type ScriptType, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { type Client, useClient } from '@dxos/react-client';
|
|
10
10
|
import { Query, Ref, type Space, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
@@ -12,7 +12,7 @@ import { type TFunction } from '@dxos/react-ui';
|
|
|
12
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
13
|
import { errorMessageColors } from '@dxos/react-ui-theme';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { meta } from '../meta';
|
|
16
16
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
17
17
|
|
|
18
18
|
export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
|
|
@@ -29,15 +29,15 @@ export type CreateDeployOptions = {
|
|
|
29
29
|
script: ScriptType;
|
|
30
30
|
fn: FunctionType;
|
|
31
31
|
space?: Space;
|
|
32
|
-
|
|
32
|
+
existingFunctionId?: string;
|
|
33
33
|
client: Client;
|
|
34
34
|
t: TFunction;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export const createDeploy = ({ state, script, space, fn, client,
|
|
37
|
+
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
38
38
|
// TODO(wittjosiah): Should this be an action?
|
|
39
39
|
const errorItem = createMenuAction('error', () => {}, {
|
|
40
|
-
label: state.error ?? ['no error label', { ns:
|
|
40
|
+
label: state.error ?? ['no error label', { ns: meta.id }],
|
|
41
41
|
icon: 'ph--warning-circle--regular',
|
|
42
42
|
hidden: !state.error,
|
|
43
43
|
classNames: state.error && errorMessageColors,
|
|
@@ -53,7 +53,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
53
53
|
state.error = undefined;
|
|
54
54
|
state.deploying = true;
|
|
55
55
|
|
|
56
|
-
const result = await deployScript({ script, client, space, fn,
|
|
56
|
+
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
57
57
|
|
|
58
58
|
if (!result.success) {
|
|
59
59
|
log.catch(result.error);
|
|
@@ -64,7 +64,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
type: 'deploy',
|
|
67
|
-
label: [state.deploying ? '
|
|
67
|
+
label: [state.deploying ? 'publishing label' : 'deploy label', { ns: meta.id }],
|
|
68
68
|
icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
69
69
|
disabled: state.deploying,
|
|
70
70
|
classNames: state.deploying ? '[&_svg]:animate-spin' : '',
|
|
@@ -74,14 +74,13 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
74
74
|
const copyAction = createMenuAction<DeployActionProperties>(
|
|
75
75
|
'copy',
|
|
76
76
|
async () => {
|
|
77
|
-
if (
|
|
78
|
-
|
|
77
|
+
if (state.functionUrl) {
|
|
78
|
+
await navigator.clipboard.writeText(state.functionUrl);
|
|
79
79
|
}
|
|
80
|
-
await navigator.clipboard.writeText(state.functionUrl);
|
|
81
80
|
},
|
|
82
81
|
{
|
|
83
82
|
type: 'copy',
|
|
84
|
-
label: ['copy link label', { ns:
|
|
83
|
+
label: ['copy link label', { ns: meta.id }],
|
|
85
84
|
icon: 'ph--link--regular',
|
|
86
85
|
disabled: !state.functionUrl,
|
|
87
86
|
},
|
|
@@ -98,9 +97,9 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script: ScriptType }) => {
|
|
101
|
-
const { space, client, fn,
|
|
100
|
+
const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
102
101
|
useEffect(() => {
|
|
103
|
-
if (!
|
|
102
|
+
if (!existingFunctionId) {
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -109,17 +108,17 @@ export const useDeployState = ({ state, script }: { state: Partial<DeployState>;
|
|
|
109
108
|
fn,
|
|
110
109
|
edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
|
|
111
110
|
});
|
|
112
|
-
}, [
|
|
111
|
+
}, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
|
|
113
112
|
|
|
114
113
|
useEffect(() => {
|
|
115
114
|
state.deployed = isScriptDeployed({ script, fn });
|
|
116
|
-
}, [script.changed,
|
|
115
|
+
}, [script.changed, existingFunctionId, fn, script]);
|
|
117
116
|
};
|
|
118
117
|
|
|
119
118
|
export const useDeployDeps = ({ script }: { script: ScriptType }) => {
|
|
119
|
+
const client = useClient();
|
|
120
120
|
const space = getSpace(script);
|
|
121
121
|
const [fn] = useQuery(space, Query.type(FunctionType, { source: Ref.make(script) }));
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
return { space, fn, client, existingFunctionUrl };
|
|
122
|
+
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(getMeta(fn)), [fn]);
|
|
123
|
+
return { client, space, fn, existingFunctionId };
|
|
125
124
|
};
|
package/src/hooks/format.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type ScriptType } from '@dxos/functions';
|
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../meta';
|
|
14
14
|
|
|
15
15
|
export type FormatActionProperties = { type: 'format' };
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ export const createFormat = (script: ScriptType) => {
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
label: ['format label', { ns:
|
|
38
|
+
label: ['format label', { ns: meta.id }],
|
|
39
39
|
icon: 'ph--magic-wand--regular',
|
|
40
40
|
},
|
|
41
41
|
);
|
package/src/hooks/template.ts
CHANGED
|
@@ -6,14 +6,15 @@ import { Obj } from '@dxos/echo';
|
|
|
6
6
|
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
|
|
7
7
|
import { createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { meta } from '../meta';
|
|
10
10
|
import { templates } from '../templates';
|
|
11
11
|
|
|
12
12
|
export type TemplateActionProperties = { type: 'template'; value: string };
|
|
13
13
|
|
|
14
14
|
const createTemplateSelectGroup = () => {
|
|
15
|
+
// TODO(burdon): This should not be in the toolbar (move to create Object dialog).
|
|
15
16
|
return createMenuItemGroup('template-select', {
|
|
16
|
-
label: ['template select group label', { ns:
|
|
17
|
+
label: ['template select group label', { ns: meta.id }],
|
|
17
18
|
variant: 'dropdownMenu',
|
|
18
19
|
});
|
|
19
20
|
};
|
|
@@ -30,7 +31,7 @@ const createTemplateSelectActions = (script: ScriptType) => {
|
|
|
30
31
|
if (oldPresetIndex >= 0) {
|
|
31
32
|
metaKeys.splice(oldPresetIndex, 1);
|
|
32
33
|
}
|
|
33
|
-
if (template
|
|
34
|
+
if ('presetId' in template) {
|
|
34
35
|
metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
35
36
|
}
|
|
36
37
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
6
|
import { useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { chain, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
@@ -40,8 +40,8 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
|
|
|
40
40
|
const deploymentResults = await Promise.all(
|
|
41
41
|
scriptTemplates.map(async (template) => {
|
|
42
42
|
const result = await dispatch(
|
|
43
|
-
pipe(
|
|
44
|
-
createIntent(ScriptAction.
|
|
43
|
+
Function.pipe(
|
|
44
|
+
createIntent(ScriptAction.CreateScript, { space, initialTemplateId: template.id as any }),
|
|
45
45
|
chain(SpaceAction.AddObject, { target: space }),
|
|
46
46
|
),
|
|
47
47
|
);
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const SCRIPT_PLUGIN = 'dxos.org/plugin/script';
|
|
8
|
-
|
|
9
7
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
8
|
+
id: 'dxos.org/plugin/script',
|
|
11
9
|
name: 'Scripts',
|
|
12
10
|
description:
|
|
13
|
-
'Scripts
|
|
11
|
+
'Scripts enable you to deploy custom functions that run on the edge. These functions can be referenced by your AI agent and called inside of cells in any Sheet. Use scripts to interact with API’s or external data inside of Composer.',
|
|
14
12
|
icon: 'ph--code--regular',
|
|
15
13
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',
|
|
16
14
|
tags: ['labs'],
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { trim } from '@dxos/util';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Evaluate the script (with dependencies as arguments).
|
|
9
|
+
*/
|
|
10
|
+
export const evalScript = (code: string, deps: Record<string, any> = {}) => {
|
|
11
|
+
// Create a sandboxed environment that blocks access to window and document.
|
|
12
|
+
const sandbox = {
|
|
13
|
+
...deps,
|
|
14
|
+
|
|
15
|
+
// Block access to global objects.
|
|
16
|
+
console: undefined,
|
|
17
|
+
document: undefined,
|
|
18
|
+
global: undefined,
|
|
19
|
+
globalThis: undefined,
|
|
20
|
+
self: undefined,
|
|
21
|
+
window: undefined,
|
|
22
|
+
|
|
23
|
+
// Allow some safe globals.
|
|
24
|
+
Array,
|
|
25
|
+
Boolean,
|
|
26
|
+
Date,
|
|
27
|
+
Error,
|
|
28
|
+
JSON,
|
|
29
|
+
Map,
|
|
30
|
+
Math,
|
|
31
|
+
Number,
|
|
32
|
+
Object,
|
|
33
|
+
Promise,
|
|
34
|
+
RegExp,
|
|
35
|
+
Set,
|
|
36
|
+
String,
|
|
37
|
+
|
|
38
|
+
// Functions.
|
|
39
|
+
isFinite,
|
|
40
|
+
isNaN,
|
|
41
|
+
parseFloat,
|
|
42
|
+
parseInt,
|
|
43
|
+
|
|
44
|
+
// Note: undefined and null are not included as they are keywords, not variables.
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Create function with all sandbox keys as parameters.
|
|
48
|
+
const sandboxKeys = Object.keys(sandbox);
|
|
49
|
+
const sandboxValues = Object.values(sandbox);
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
52
|
+
const fn = new Function(
|
|
53
|
+
...sandboxKeys,
|
|
54
|
+
trim`
|
|
55
|
+
'use strict';
|
|
56
|
+
return ${code};
|
|
57
|
+
`,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return fn(...sandboxValues);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Globals.
|
|
65
|
+
*/
|
|
66
|
+
export const builtIns = new Set([
|
|
67
|
+
// Types.
|
|
68
|
+
'Array',
|
|
69
|
+
'Date',
|
|
70
|
+
'Error',
|
|
71
|
+
'JSON',
|
|
72
|
+
'Map',
|
|
73
|
+
'Math',
|
|
74
|
+
'Number',
|
|
75
|
+
'Object',
|
|
76
|
+
'Promise',
|
|
77
|
+
'RegExp',
|
|
78
|
+
'Set',
|
|
79
|
+
'String',
|
|
80
|
+
|
|
81
|
+
// Functions.
|
|
82
|
+
'isFinite',
|
|
83
|
+
'isNaN',
|
|
84
|
+
'parseFloat',
|
|
85
|
+
'parseInt',
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Default system definitions.
|
|
90
|
+
*/
|
|
91
|
+
export const systemDefinitions = trim`
|
|
92
|
+
interface Array<T> { length: number; [n: number]: T; }
|
|
93
|
+
interface Boolean {}
|
|
94
|
+
interface Function {}
|
|
95
|
+
interface IArguments {}
|
|
96
|
+
interface Number {}
|
|
97
|
+
interface Object {}
|
|
98
|
+
interface RegExp {}
|
|
99
|
+
interface String { length: number; }
|
|
100
|
+
|
|
101
|
+
interface CallableFunction extends Function {}
|
|
102
|
+
interface NewableFunction extends Function {}
|
|
103
|
+
|
|
104
|
+
declare var console: { log(...args: any[]): void };
|
|
105
|
+
`;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { createNotebook } from '../testing';
|
|
8
|
+
|
|
9
|
+
import { ComputeGraph } from './notebook';
|
|
10
|
+
|
|
11
|
+
describe('notebook', () => {
|
|
12
|
+
test('parse dependency graph', () => {
|
|
13
|
+
const notebook = createNotebook();
|
|
14
|
+
const computer = new ComputeGraph(notebook);
|
|
15
|
+
const result = computer.parse();
|
|
16
|
+
|
|
17
|
+
const getId = (i: number) => notebook.cells[i].id;
|
|
18
|
+
|
|
19
|
+
// Check dependencies.
|
|
20
|
+
expect(result.dependencyGraph).toMatchObject({
|
|
21
|
+
[getId(0)]: [getId(1), getId(2)],
|
|
22
|
+
[getId(3)]: [getId(1)],
|
|
23
|
+
[getId(4)]: [getId(0), getId(3)],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Compute values.
|
|
27
|
+
const values = computer.evaluate();
|
|
28
|
+
expect(values).toEqual({
|
|
29
|
+
[getId(0)]: 300,
|
|
30
|
+
[getId(2)]: 200,
|
|
31
|
+
[getId(3)]: 200,
|
|
32
|
+
[getId(4)]: 500,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('evalScript blocks access to window and document', () => {
|
|
37
|
+
const notebook = createNotebook();
|
|
38
|
+
// Replace one of the cells with code that tries to access window/document.
|
|
39
|
+
if (notebook.cells[2].script?.target) {
|
|
40
|
+
notebook.cells[2].script.target.content = 'b = typeof window';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const computer = new ComputeGraph(notebook);
|
|
44
|
+
computer.parse();
|
|
45
|
+
const values = computer.evaluate();
|
|
46
|
+
|
|
47
|
+
// Should evaluate to 'undefined' since window is blocked.
|
|
48
|
+
expect(values[notebook.cells[2].id]).toBe('undefined');
|
|
49
|
+
|
|
50
|
+
// Test document access.
|
|
51
|
+
if (notebook.cells[2].script?.target) {
|
|
52
|
+
notebook.cells[2].script.target.content = 'b = typeof document';
|
|
53
|
+
}
|
|
54
|
+
computer.parse();
|
|
55
|
+
const values2 = computer.evaluate();
|
|
56
|
+
|
|
57
|
+
// Should evaluate to 'undefined' since document is blocked.
|
|
58
|
+
expect(values2[notebook.cells[2].id]).toBe('undefined');
|
|
59
|
+
|
|
60
|
+
// Test that safe globals still work.
|
|
61
|
+
if (notebook.cells[2].script?.target) {
|
|
62
|
+
notebook.cells[2].script.target.content = 'b = Math.max(100, 200)';
|
|
63
|
+
}
|
|
64
|
+
computer.parse();
|
|
65
|
+
const values3 = computer.evaluate();
|
|
66
|
+
|
|
67
|
+
// Should evaluate correctly.
|
|
68
|
+
expect(values3[notebook.cells[2].id]).toBe(200);
|
|
69
|
+
});
|
|
70
|
+
});
|