@dxos/plugin-script 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b
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/{AutomationPanel-RFQAQ7NF.mjs → AutomationPanel-OOIRJFPJ.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs +685 -0
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-C7VBULMK.mjs → chunk-5BU5ERNU.mjs} +3 -3
- package/dist/lib/browser/chunk-5BU5ERNU.mjs.map +7 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs +52 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs → chunk-SDHKTS6H.mjs} +2 -51
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs.map → chunk-SDHKTS6H.mjs.map} +4 -4
- package/dist/lib/browser/chunk-SIOGRRPF.mjs +224 -0
- package/dist/lib/browser/chunk-SIOGRRPF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-SJ4J527G.mjs} +2 -2
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs +40 -0
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs +15 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs.map +7 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs +84 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +112 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs +42 -0
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs +67 -0
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs.map +7 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs +24 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs → AutomationPanel-EPRDDR3A.cjs} +8 -8
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs +689 -0
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs.map +7 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs +252 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs.map +7 -0
- package/dist/lib/node/{chunk-PK3OQP5L.cjs → chunk-6VKZJ4MH.cjs} +26 -11
- package/dist/lib/node/chunk-6VKZJ4MH.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-A2DI2G4D.cjs} +12 -8
- package/dist/lib/node/chunk-A2DI2G4D.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-DQRAVZM7.cjs} +6 -6
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-EFTZN5X7.cjs} +7 -7
- package/dist/lib/node/chunk-EFTZN5X7.cjs.map +7 -0
- package/dist/lib/node/{chunk-WPP65EYS.cjs → chunk-T4TXCRN5.cjs} +6 -44
- package/dist/lib/node/chunk-T4TXCRN5.cjs.map +7 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs +64 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs.map +7 -0
- package/dist/lib/node/compiler-457ZR24G.cjs +104 -0
- package/dist/lib/node/compiler-457ZR24G.cjs.map +7 -0
- package/dist/lib/node/index.cjs +105 -276
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs +56 -0
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-OMBMSFZT.cjs +86 -0
- package/dist/lib/node/react-surface-OMBMSFZT.cjs.map +7 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs +38 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs.map +7 -0
- package/dist/lib/node/types.cjs +6 -4
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs → AutomationPanel-DMLAGQS5.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs +686 -0
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs +16 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-BHP545D7.mjs} +3 -3
- package/dist/lib/node-esm/chunk-BHP545D7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs → chunk-G76M6O46.mjs} +2 -51
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs.map → chunk-G76M6O46.mjs.map} +4 -4
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs +41 -0
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs +54 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs +225 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-XUWS7OTK.mjs} +2 -2
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs +85 -0
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +112 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs +43 -0
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs +68 -0
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs.map +7 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs +25 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +6 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +4 -0
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +10 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +11 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar/Toolbar.stories.d.ts → ScriptToolbar/ScriptToolbar.stories.d.ts} +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts +48 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts +25 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts +31 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts +14 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts +10 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts +33 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts +2 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/{templates.d.ts → templates/index.d.ts} +1 -1
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +91 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +14 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -46
- package/src/ScriptPlugin.tsx +63 -91
- package/src/bundler/bundler.test.ts +2 -2
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +12 -0
- package/src/capabilities/intent-resolver.ts +43 -0
- package/src/capabilities/react-surface.tsx +54 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/components/ScriptContainer.tsx +64 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +25 -1
- package/src/components/ScriptSettingsPanel.tsx +124 -50
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +51 -0
- package/src/components/ScriptToolbar/deploy.ts +157 -0
- package/src/components/ScriptToolbar/format.ts +47 -0
- package/src/components/{Toolbar → ScriptToolbar}/index.ts +1 -1
- package/src/components/ScriptToolbar/templateSelect.ts +64 -0
- package/src/components/ScriptToolbar/useToolbarAction.ts +54 -0
- package/src/components/ScriptToolbar/useToolbarState.ts +16 -0
- package/src/components/ScriptToolbar/view.ts +52 -0
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +73 -8
- package/src/index.ts +2 -6
- package/src/meta.ts +1 -1
- package/src/templates/email.ts +26 -23
- package/src/{templates.ts → templates/index.ts} +5 -5
- package/src/translations.ts +21 -0
- package/src/types.ts +19 -18
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs +0 -415
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQA3EB5K.mjs +0 -26
- package/dist/lib/browser/chunk-RQA3EB5K.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs +0 -426
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-PK3OQP5L.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs +0 -416
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs +0 -27
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +0 -12
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +0 -6
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/index.d.ts +0 -2
- package/dist/types/src/components/ScriptBlock/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptEditor.d.ts +0 -9
- package/dist/types/src/components/ScriptEditor.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -23
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -55
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -193
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- /package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs.map → AutomationPanel-OOIRJFPJ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-SJ4J527G.mjs.map} +0 -0
- /package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs.map → AutomationPanel-EPRDDR3A.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-DQRAVZM7.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs.map → AutomationPanel-DMLAGQS5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-XUWS7OTK.mjs.map} +0 -0
|
@@ -9,6 +9,7 @@ import React, { useMemo } from 'react';
|
|
|
9
9
|
|
|
10
10
|
import { createDocAccessor, createObject } from '@dxos/react-client/echo';
|
|
11
11
|
import { createDataExtensions } from '@dxos/react-ui-editor';
|
|
12
|
+
import { withTheme } from '@dxos/storybook-utils';
|
|
12
13
|
|
|
13
14
|
import { TypescriptEditor } from './TypescriptEditor';
|
|
14
15
|
import { templates } from '../../templates';
|
|
@@ -37,6 +38,7 @@ const meta: Meta = {
|
|
|
37
38
|
title: 'plugins/plugin-script/TypescriptEditor',
|
|
38
39
|
component: TypescriptEditor,
|
|
39
40
|
render: DefaultStory,
|
|
41
|
+
decorators: [withTheme],
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
export default meta;
|
|
@@ -3,18 +3,26 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { javascript } from '@codemirror/lang-javascript';
|
|
6
|
+
import { defaultHighlightStyle } from '@codemirror/language';
|
|
7
|
+
import { Prec } from '@codemirror/state';
|
|
8
|
+
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
|
|
9
|
+
import { keymap } from '@codemirror/view';
|
|
10
|
+
import { tags } from '@lezer/highlight';
|
|
6
11
|
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
7
|
-
import {
|
|
12
|
+
import { continueKeymap } from '@valtown/codemirror-continue';
|
|
13
|
+
import { tsSync, tsFacet, tsLinter, tsAutocomplete, tsHover, type HoverInfo } from '@valtown/codemirror-ts';
|
|
8
14
|
import React from 'react';
|
|
9
15
|
|
|
10
|
-
import { useThemeContext } from '@dxos/react-ui';
|
|
16
|
+
import { type ThemeMode, useThemeContext } from '@dxos/react-ui';
|
|
11
17
|
import {
|
|
12
18
|
autocomplete,
|
|
13
19
|
createBasicExtensions,
|
|
14
20
|
createThemeExtensions,
|
|
15
21
|
editorFullWidth,
|
|
16
|
-
|
|
22
|
+
type EditorInputMode,
|
|
17
23
|
editorMonospace,
|
|
24
|
+
EditorView,
|
|
25
|
+
folding,
|
|
18
26
|
InputModeExtensions,
|
|
19
27
|
useTextEditor,
|
|
20
28
|
type UseTextEditorProps,
|
|
@@ -23,7 +31,9 @@ import { nonNullable } from '@dxos/util';
|
|
|
23
31
|
|
|
24
32
|
export type TypescriptEditorProps = {
|
|
25
33
|
id: string;
|
|
34
|
+
inputMode?: EditorInputMode;
|
|
26
35
|
env?: VirtualTypeScriptEnvironment;
|
|
36
|
+
toolbar?: boolean;
|
|
27
37
|
} & Pick<UseTextEditorProps, 'className' | 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;
|
|
28
38
|
|
|
29
39
|
export const TypescriptEditor = ({
|
|
@@ -34,6 +44,8 @@ export const TypescriptEditor = ({
|
|
|
34
44
|
extensions,
|
|
35
45
|
scrollTo,
|
|
36
46
|
selection,
|
|
47
|
+
toolbar,
|
|
48
|
+
inputMode = 'vscode',
|
|
37
49
|
}: TypescriptEditorProps) => {
|
|
38
50
|
const { themeMode } = useThemeContext();
|
|
39
51
|
const { parentRef, focusAttributes } = useTextEditor(
|
|
@@ -56,24 +68,77 @@ export const TypescriptEditor = ({
|
|
|
56
68
|
content: { className: editorFullWidth },
|
|
57
69
|
},
|
|
58
70
|
}),
|
|
59
|
-
|
|
71
|
+
// NOTE: Not using default editor gutter because folding for code works best right beside text.
|
|
72
|
+
EditorView.theme({
|
|
73
|
+
'.cm-gutters': {
|
|
74
|
+
// Match margin from content.
|
|
75
|
+
marginTop: '16px',
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
InputModeExtensions[inputMode],
|
|
79
|
+
folding(),
|
|
80
|
+
// Continues block comments when you hit Enter.
|
|
81
|
+
Prec.high(keymap.of(continueKeymap)),
|
|
60
82
|
// TODO(burdon): Factor out.
|
|
61
83
|
[
|
|
62
84
|
editorMonospace,
|
|
63
85
|
javascript({ typescript: true }),
|
|
64
86
|
// https://github.com/val-town/codemirror-ts
|
|
65
87
|
autocomplete({ override: env ? [tsAutocomplete()] : [] }),
|
|
66
|
-
env
|
|
67
|
-
|
|
88
|
+
env
|
|
89
|
+
? [
|
|
90
|
+
tsFacet.of({ env, path: `/src/${id}.ts` }),
|
|
91
|
+
tsSync(),
|
|
92
|
+
tsLinter(),
|
|
93
|
+
tsHover({ renderTooltip: createTooltipRenderer(themeMode) }),
|
|
94
|
+
]
|
|
95
|
+
: [],
|
|
68
96
|
],
|
|
69
97
|
].filter(nonNullable),
|
|
70
98
|
selection,
|
|
71
99
|
scrollTo,
|
|
72
100
|
}),
|
|
73
|
-
[id, extensions, themeMode, selection, scrollTo],
|
|
101
|
+
[id, extensions, themeMode, inputMode, selection, scrollTo],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div ref={parentRef} data-toolbar={toolbar ? 'enabled' : 'disabled'} className={className} {...focusAttributes} />
|
|
74
106
|
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const createTooltipRenderer = (themeMode: ThemeMode) => {
|
|
110
|
+
const theme = themeMode === 'dark' ? oneDarkHighlightStyle : defaultHighlightStyle;
|
|
111
|
+
|
|
112
|
+
const classFromKind = (_kind: string) => {
|
|
113
|
+
// E.g., localName, methodName, parameterName, etc.
|
|
114
|
+
const kind = _kind.endsWith('Name') ? 'name' : _kind;
|
|
115
|
+
const validTag = kind in tags;
|
|
116
|
+
if (!validTag) {
|
|
117
|
+
return '';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const tag = tags[kind as keyof typeof tags];
|
|
121
|
+
if (typeof tag === 'function') {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return theme.style([tag]) ?? '';
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (info: HoverInfo) => {
|
|
129
|
+
const div = document.createElement('div');
|
|
130
|
+
div.className = 'p-1 rounded border border-separator bg-base xs:max-w-80 max-w-lg';
|
|
131
|
+
|
|
132
|
+
if (info.quickInfo?.displayParts) {
|
|
133
|
+
for (const part of info.quickInfo.displayParts) {
|
|
134
|
+
const span = div.appendChild(document.createElement('span'));
|
|
135
|
+
span.className = classFromKind(part.kind);
|
|
136
|
+
span.innerText = part.text;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
75
139
|
|
|
76
|
-
|
|
140
|
+
return { dom: div };
|
|
141
|
+
};
|
|
77
142
|
};
|
|
78
143
|
|
|
79
144
|
export default TypescriptEditor;
|
package/src/index.ts
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { ScriptPlugin } from './ScriptPlugin';
|
|
6
|
-
|
|
7
|
-
export default ScriptPlugin;
|
|
8
|
-
|
|
9
5
|
export * from './bundler';
|
|
10
|
-
export
|
|
6
|
+
export { ScriptCapabilities } from './capabilities';
|
|
11
7
|
export * from './components';
|
|
12
|
-
export * from './
|
|
8
|
+
export * from './meta';
|
|
13
9
|
|
|
14
10
|
export * from './ScriptPlugin';
|
package/src/meta.ts
CHANGED
package/src/templates/email.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Appends a message to the end of a Document configured through a trigger.
|
|
7
|
+
* Trigger must have a targetDocumentId field set in Meta.
|
|
7
8
|
*/
|
|
8
9
|
export default async ({
|
|
9
10
|
event: {
|
|
@@ -11,28 +12,30 @@ export default async ({
|
|
|
11
12
|
},
|
|
12
13
|
context: { space },
|
|
13
14
|
}: any) => {
|
|
14
|
-
const {
|
|
15
|
-
data: {
|
|
16
|
-
objects: [message],
|
|
17
|
-
},
|
|
18
|
-
} = await request.json();
|
|
15
|
+
const { data, trigger } = (await request.json()) as RequestPayload;
|
|
19
16
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
return new Response('Mailbox not found.', { status: 500 });
|
|
23
|
-
}
|
|
17
|
+
const documentId = trigger.meta.targetDocumentId;
|
|
18
|
+
const document = await space.db.query({ id: documentId }, { format: 'plain' }).first();
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
|
|
20
|
+
const contentId = document.content['/'].split(':')[3];
|
|
21
|
+
const documentContent = await space.db.query({ id: contentId }, { format: 'plain' }).first();
|
|
22
|
+
const modifiedContent = [
|
|
23
|
+
documentContent.content,
|
|
24
|
+
'',
|
|
25
|
+
'---',
|
|
26
|
+
`**From:** ${data.from}`,
|
|
27
|
+
`**Subject:** ${data.subject}`,
|
|
28
|
+
`**Date:** ${data.created}`,
|
|
29
|
+
'',
|
|
30
|
+
data.body,
|
|
31
|
+
].join('\n');
|
|
32
|
+
|
|
33
|
+
await space.db.update({ id: contentId }, { content: modifiedContent });
|
|
34
|
+
|
|
35
|
+
return new Response(JSON.stringify({ success: true }));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type RequestPayload = {
|
|
39
|
+
data: { from: string; subject: string; created: string; body: string };
|
|
40
|
+
trigger: { meta: { targetDocumentId: string } };
|
|
38
41
|
};
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import chat from './
|
|
6
|
+
import chat from './chat.ts?raw';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import chess from './
|
|
8
|
+
import chess from './chess.ts?raw';
|
|
9
9
|
// @ts-ignore
|
|
10
|
-
import echo from './
|
|
10
|
+
import echo from './echo.ts?raw';
|
|
11
11
|
// @ts-ignore
|
|
12
|
-
import email from './
|
|
12
|
+
import email from './email.ts?raw';
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
import forex from './
|
|
14
|
+
import forex from './forex.ts?raw';
|
|
15
15
|
|
|
16
16
|
const removeHeader = (str: string) => str.split('\n').slice(4).join('\n');
|
|
17
17
|
|
package/src/translations.ts
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { ScriptType } from '@dxos/functions';
|
|
6
|
+
|
|
5
7
|
import { SCRIPT_PLUGIN } from './meta';
|
|
6
8
|
|
|
7
9
|
export default [
|
|
8
10
|
{
|
|
9
11
|
'en-US': {
|
|
12
|
+
[ScriptType.typename]: {
|
|
13
|
+
'typename label': 'Script',
|
|
14
|
+
},
|
|
10
15
|
[SCRIPT_PLUGIN]: {
|
|
11
16
|
'plugin name': 'Scripts',
|
|
12
17
|
'object title placeholder': 'New script',
|
|
@@ -27,6 +32,22 @@ export default [
|
|
|
27
32
|
'function url label': 'Invocation URL',
|
|
28
33
|
'function binding label': 'Function binding',
|
|
29
34
|
'function binding placeholder': 'BINDING',
|
|
35
|
+
'script publish settings label': 'Publishing',
|
|
36
|
+
'script publish settings description': 'Scripts can be shared publicly as Github gists.',
|
|
37
|
+
'no github token label': 'This space has no Github access token available.',
|
|
38
|
+
'open token manager label': 'Open Token Manager',
|
|
39
|
+
'publish label': 'Publish',
|
|
40
|
+
'publishing label': 'Publishing',
|
|
41
|
+
'editor input mode label': 'Editor input mode',
|
|
42
|
+
'select editor input mode placeholder': 'Select editor input mode…',
|
|
43
|
+
'settings editor input mode default label': 'Default',
|
|
44
|
+
'settings editor input mode vim label': 'Vim',
|
|
45
|
+
'settings editor input mode vscode label': 'VS Code',
|
|
46
|
+
'view group label': 'View',
|
|
47
|
+
'view editor label': 'Editor',
|
|
48
|
+
'view split label': 'Split',
|
|
49
|
+
'view debug label': 'Debug',
|
|
50
|
+
'template select group label': 'Select template',
|
|
30
51
|
},
|
|
31
52
|
},
|
|
32
53
|
},
|
package/src/types.ts
CHANGED
|
@@ -2,37 +2,38 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SettingsProvides,
|
|
9
|
-
SurfaceProvides,
|
|
10
|
-
TranslationsProvides,
|
|
11
|
-
} from '@dxos/app-framework';
|
|
5
|
+
import { TitleAnnotationId } from '@effect/schema/AST';
|
|
6
|
+
|
|
7
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
12
8
|
import { S } from '@dxos/echo-schema';
|
|
13
9
|
import { ScriptType } from '@dxos/functions';
|
|
14
|
-
import {
|
|
10
|
+
import { EditorInputMode } from '@dxos/react-ui-editor';
|
|
15
11
|
|
|
16
12
|
import { SCRIPT_PLUGIN } from './meta';
|
|
17
13
|
|
|
18
14
|
export namespace ScriptAction {
|
|
19
15
|
const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;
|
|
20
16
|
|
|
17
|
+
export const CreateScriptSchema = S.Struct({
|
|
18
|
+
name: S.optional(S.String),
|
|
19
|
+
// TODO(wittjosiah): Placeholder annotation?
|
|
20
|
+
gistUrl: S.optional(S.String.annotations({ [TitleAnnotationId]: 'Import from Gist (url)' })),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type CreateScriptProps = S.Schema.Type<typeof CreateScriptSchema>;
|
|
24
|
+
|
|
21
25
|
export class Create extends S.TaggedClass<Create>()(`${SCRIPT_ACTION}/create`, {
|
|
22
|
-
input: S.Struct({
|
|
23
|
-
name: S.optional(S.String),
|
|
24
|
-
}),
|
|
26
|
+
input: S.extend(CreateScriptSchema, S.Struct({ space: SpaceSchema })),
|
|
25
27
|
output: S.Struct({
|
|
26
28
|
object: ScriptType,
|
|
27
29
|
}),
|
|
28
30
|
}) {}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
export
|
|
33
|
+
export const ScriptSettingsSchema = S.mutable(
|
|
34
|
+
S.Struct({
|
|
35
|
+
editorInputMode: EditorInputMode,
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
32
38
|
|
|
33
|
-
export type
|
|
34
|
-
MetadataRecordsProvides &
|
|
35
|
-
SchemaProvides &
|
|
36
|
-
SettingsProvides<ScriptSettingsProps> &
|
|
37
|
-
SurfaceProvides &
|
|
38
|
-
TranslationsProvides;
|
|
39
|
+
export type ScriptSettingsProps = S.Schema.Type<typeof ScriptSettingsSchema>;
|