@dxos/plugin-script 0.7.5-main.9d26e3a → 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
package/src/ScriptPlugin.tsx
CHANGED
|
@@ -3,104 +3,76 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
-
import React from 'react';
|
|
8
6
|
|
|
9
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Capabilities,
|
|
9
|
+
contributes,
|
|
10
|
+
createIntent,
|
|
11
|
+
defineModule,
|
|
12
|
+
definePlugin,
|
|
13
|
+
Events,
|
|
14
|
+
oneOf,
|
|
15
|
+
} from '@dxos/app-framework';
|
|
16
|
+
import { type Space } from '@dxos/client/echo';
|
|
10
17
|
import { FunctionType, ScriptType } from '@dxos/functions';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
18
|
+
import { RefArray } from '@dxos/live-object';
|
|
19
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
13
20
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { AutomationPanel, ScriptContainer, ScriptSettings, ScriptSettingsPanel } from './components';
|
|
17
|
-
import meta, { SCRIPT_PLUGIN } from './meta';
|
|
18
|
-
import { templates } from './templates';
|
|
21
|
+
import { Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';
|
|
22
|
+
import { meta, SCRIPT_PLUGIN } from './meta';
|
|
19
23
|
import translations from './translations';
|
|
20
|
-
import { ScriptAction
|
|
24
|
+
import { ScriptAction } from './types';
|
|
21
25
|
|
|
22
|
-
export const ScriptPlugin = ()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
export const ScriptPlugin = () =>
|
|
27
|
+
definePlugin(meta, [
|
|
28
|
+
defineModule({
|
|
29
|
+
id: `${meta.id}/module/settings`,
|
|
30
|
+
activatesOn: Events.SetupSettings,
|
|
31
|
+
activate: ScriptSettings,
|
|
32
|
+
}),
|
|
33
|
+
defineModule({
|
|
34
|
+
id: `${meta.id}/module/compiler`,
|
|
35
|
+
activatesOn: Events.Startup,
|
|
36
|
+
activate: Compiler,
|
|
37
|
+
}),
|
|
38
|
+
defineModule({
|
|
39
|
+
id: `${meta.id}/module/translations`,
|
|
40
|
+
activatesOn: Events.SetupTranslations,
|
|
41
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
42
|
+
}),
|
|
43
|
+
defineModule({
|
|
44
|
+
id: `${meta.id}/module/metadata`,
|
|
45
|
+
activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),
|
|
46
|
+
activate: () =>
|
|
47
|
+
contributes(Capabilities.Metadata, {
|
|
48
|
+
id: ScriptType.typename,
|
|
49
|
+
metadata: {
|
|
50
|
+
creationSchema: ScriptAction.CreateScriptSchema,
|
|
51
|
+
createObject: (props: ScriptAction.CreateScriptProps, { space }: { space: Space }) =>
|
|
52
|
+
createIntent(ScriptAction.Create, { ...props, space }),
|
|
49
53
|
placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],
|
|
50
54
|
icon: 'ph--code--regular',
|
|
51
55
|
// TODO(wittjosiah): Move out of metadata.
|
|
52
56
|
loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),
|
|
53
57
|
},
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
createSurface({
|
|
76
|
-
id: `${SCRIPT_PLUGIN}/automation`,
|
|
77
|
-
role: 'complementary--automation',
|
|
78
|
-
disposition: 'hoist',
|
|
79
|
-
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
80
|
-
component: ({ data }) => <AutomationPanel subject={data.subject} />,
|
|
81
|
-
}),
|
|
82
|
-
createSurface({
|
|
83
|
-
id: `${SCRIPT_PLUGIN}/settings-panel`,
|
|
84
|
-
role: 'complementary--settings',
|
|
85
|
-
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
86
|
-
component: ({ data }) => <ScriptSettingsPanel script={data.subject} />,
|
|
87
|
-
}),
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
intent: {
|
|
91
|
-
resolvers: () =>
|
|
92
|
-
createResolver(ScriptAction.Create, ({ name }) => ({
|
|
93
|
-
data: {
|
|
94
|
-
object: create(ScriptType, {
|
|
95
|
-
source: makeRef(
|
|
96
|
-
create(TextType, {
|
|
97
|
-
content: templates[0].source,
|
|
98
|
-
}),
|
|
99
|
-
),
|
|
100
|
-
}),
|
|
101
|
-
},
|
|
102
|
-
})),
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
};
|
|
58
|
+
}),
|
|
59
|
+
}),
|
|
60
|
+
defineModule({
|
|
61
|
+
id: `${meta.id}/module/schema`,
|
|
62
|
+
activatesOn: ClientEvents.SetupClient,
|
|
63
|
+
activate: () => [
|
|
64
|
+
contributes(ClientCapabilities.SystemSchema, [FunctionType]),
|
|
65
|
+
contributes(ClientCapabilities.Schema, [ScriptType]),
|
|
66
|
+
],
|
|
67
|
+
}),
|
|
68
|
+
defineModule({
|
|
69
|
+
id: `${meta.id}/module/react-surface`,
|
|
70
|
+
activatesOn: Events.Startup,
|
|
71
|
+
activate: ReactSurface,
|
|
72
|
+
}),
|
|
73
|
+
defineModule({
|
|
74
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
75
|
+
activatesOn: Events.SetupIntents,
|
|
76
|
+
activate: IntentResolver,
|
|
77
|
+
}),
|
|
78
|
+
]);
|
|
@@ -38,8 +38,8 @@ describe('Bundler', () => {
|
|
|
38
38
|
test('HTTPS Import', async () => {
|
|
39
39
|
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
40
40
|
const result = await bundler.bundle(`
|
|
41
|
-
import {
|
|
42
|
-
|
|
41
|
+
import { invariant } from 'https://esm.sh/@dxos/invariant';
|
|
42
|
+
invariant(true);
|
|
43
43
|
`);
|
|
44
44
|
expect(result.bundle).to.exist;
|
|
45
45
|
expect(result.error).to.not.exist;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineCapability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { type Compiler } from '../compiler';
|
|
8
|
+
import { SCRIPT_PLUGIN } from '../meta';
|
|
9
|
+
|
|
10
|
+
export namespace ScriptCapabilities {
|
|
11
|
+
export const Compiler = defineCapability<Compiler>(`${SCRIPT_PLUGIN}/capability/compiler`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
+
|
|
8
|
+
import { contributes } from '@dxos/app-framework';
|
|
9
|
+
|
|
10
|
+
import { ScriptCapabilities } from './capabilities';
|
|
11
|
+
import { initializeBundler } from '../bundler';
|
|
12
|
+
import { Compiler } from '../compiler';
|
|
13
|
+
|
|
14
|
+
export default async () => {
|
|
15
|
+
const compiler = new Compiler();
|
|
16
|
+
|
|
17
|
+
await compiler.initialize();
|
|
18
|
+
// TODO(wittjosiah): Fetch types for https modules.
|
|
19
|
+
compiler.setFile('/src/typings.d.ts', "declare module 'https://*';");
|
|
20
|
+
// TODO(wittjosiah): Proper function handler types.
|
|
21
|
+
// TODO(wittjosiah): Remove.
|
|
22
|
+
compiler.setFile(
|
|
23
|
+
'/src/runtime.ts',
|
|
24
|
+
`
|
|
25
|
+
export const Filter: any = {};
|
|
26
|
+
export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;
|
|
27
|
+
export const functionHandler = (handler: FunctionHandler) => handler;
|
|
28
|
+
`,
|
|
29
|
+
);
|
|
30
|
+
await initializeBundler({ wasmUrl });
|
|
31
|
+
|
|
32
|
+
return contributes(ScriptCapabilities.Compiler, compiler);
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const Compiler = lazy(() => import('./compiler'));
|
|
8
|
+
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
10
|
+
export const ScriptSettings = lazy(() => import('./settings'));
|
|
11
|
+
|
|
12
|
+
export * from './capabilities';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Octokit } from '@octokit/core';
|
|
6
|
+
|
|
7
|
+
import { contributes, Capabilities, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { ScriptType } from '@dxos/functions';
|
|
9
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
10
|
+
import { TextType } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { templates } from '../templates';
|
|
13
|
+
import { ScriptAction } from '../types';
|
|
14
|
+
|
|
15
|
+
export default () =>
|
|
16
|
+
contributes(
|
|
17
|
+
Capabilities.IntentResolver,
|
|
18
|
+
createResolver(ScriptAction.Create, async ({ name, gistUrl, space }) => {
|
|
19
|
+
let content = templates[0].source;
|
|
20
|
+
const gistId = gistUrl?.split('/').at(-1);
|
|
21
|
+
if (gistId) {
|
|
22
|
+
// TODO(wittjosiah): Capability which contributes Octokit?
|
|
23
|
+
// NOTE: AccessToken not needed to read public gists.
|
|
24
|
+
const octokit = new Octokit();
|
|
25
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
26
|
+
gist_id: gistId,
|
|
27
|
+
});
|
|
28
|
+
const gistContent = Object.values(response.data.files ?? {})[0]?.content;
|
|
29
|
+
if (gistContent) {
|
|
30
|
+
content = gistContent;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
data: {
|
|
36
|
+
object: create(ScriptType, {
|
|
37
|
+
name,
|
|
38
|
+
source: makeRef(create(TextType, { content })),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { ScriptType } from '@dxos/functions';
|
|
9
|
+
import { Clipboard } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { ScriptCapabilities } from './capabilities';
|
|
12
|
+
import { AutomationPanel, ScriptSettings, ScriptContainer, ScriptSettingsPanel } from '../components';
|
|
13
|
+
import { SCRIPT_PLUGIN } from '../meta';
|
|
14
|
+
import { type ScriptSettingsProps } from '../types';
|
|
15
|
+
|
|
16
|
+
export default () =>
|
|
17
|
+
contributes(Capabilities.ReactSurface, [
|
|
18
|
+
createSurface({
|
|
19
|
+
id: `${SCRIPT_PLUGIN}/settings`,
|
|
20
|
+
role: 'settings',
|
|
21
|
+
filter: (data): data is any => data.subject === SCRIPT_PLUGIN,
|
|
22
|
+
component: () => {
|
|
23
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<ScriptSettingsProps>(SCRIPT_PLUGIN)!.value;
|
|
24
|
+
return <ScriptSettings settings={settings} />;
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
createSurface({
|
|
28
|
+
id: `${SCRIPT_PLUGIN}/article`,
|
|
29
|
+
role: 'article',
|
|
30
|
+
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
31
|
+
component: ({ data, role }) => {
|
|
32
|
+
const compiler = useCapability(ScriptCapabilities.Compiler);
|
|
33
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<ScriptSettingsProps>(SCRIPT_PLUGIN)!.value;
|
|
34
|
+
return <ScriptContainer role={role} script={data.subject} settings={settings} env={compiler.environment} />;
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
createSurface({
|
|
38
|
+
id: `${SCRIPT_PLUGIN}/automation`,
|
|
39
|
+
role: 'complementary--automation',
|
|
40
|
+
disposition: 'hoist',
|
|
41
|
+
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
42
|
+
component: ({ data }) => <AutomationPanel subject={data.subject} />,
|
|
43
|
+
}),
|
|
44
|
+
createSurface({
|
|
45
|
+
id: `${SCRIPT_PLUGIN}/settings-panel`,
|
|
46
|
+
role: 'complementary--settings',
|
|
47
|
+
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
48
|
+
component: ({ data }) => (
|
|
49
|
+
<Clipboard.Provider>
|
|
50
|
+
<ScriptSettingsPanel script={data.subject} />
|
|
51
|
+
</Clipboard.Provider>
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
6
|
+
import { create } from '@dxos/live-object';
|
|
7
|
+
|
|
8
|
+
import { SCRIPT_PLUGIN } from '../meta';
|
|
9
|
+
import { ScriptSettingsSchema } from '../types';
|
|
10
|
+
|
|
11
|
+
export default () => {
|
|
12
|
+
const settings = create(ScriptSettingsSchema, { editorInputMode: 'vscode' });
|
|
13
|
+
return contributes(Capabilities.Settings, { schema: ScriptSettingsSchema, prefix: SCRIPT_PLUGIN, value: settings });
|
|
14
|
+
};
|
|
@@ -2,20 +2,75 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { type ScriptType } from '@dxos/functions';
|
|
8
|
+
import { createDocAccessor, getSpace } from '@dxos/react-client/echo';
|
|
9
|
+
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
|
+
import { createDataExtensions, listener, stackItemContentEditorClassNames } from '@dxos/react-ui-editor';
|
|
12
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
13
|
import { mx } from '@dxos/react-ui-theme';
|
|
10
14
|
|
|
11
|
-
import {
|
|
15
|
+
import { DebugPanel } from './DebugPanel';
|
|
16
|
+
import { ScriptToolbar } from './ScriptToolbar';
|
|
17
|
+
import { useDeployState } from './ScriptToolbar/deploy';
|
|
18
|
+
import { useToolbarState } from './ScriptToolbar/useToolbarState';
|
|
19
|
+
import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
20
|
+
import { type ScriptSettingsProps } from '../types';
|
|
21
|
+
|
|
22
|
+
export type ScriptEditorProps = ThemedClassName<{
|
|
23
|
+
script: ScriptType;
|
|
24
|
+
settings: ScriptSettingsProps;
|
|
25
|
+
role?: string;
|
|
26
|
+
}> &
|
|
27
|
+
Pick<TypescriptEditorProps, 'env'>;
|
|
28
|
+
|
|
29
|
+
export const ScriptContainer = ({ role, classNames, script, settings, env }: ScriptEditorProps) => {
|
|
30
|
+
const identity = useIdentity();
|
|
31
|
+
const space = getSpace(script);
|
|
32
|
+
|
|
33
|
+
const extensions = useMemo(
|
|
34
|
+
() => [
|
|
35
|
+
listener({
|
|
36
|
+
onChange: (text) => {
|
|
37
|
+
if (script.source.target && script.source.target.content !== text) {
|
|
38
|
+
script.changed = true;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
createDataExtensions({
|
|
43
|
+
id: script.id,
|
|
44
|
+
text: script.source.target && createDocAccessor(script.source.target, ['content']),
|
|
45
|
+
space,
|
|
46
|
+
identity,
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
[script, script.source.target, space, identity],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const state = useToolbarState({ view: 'split' });
|
|
53
|
+
useDeployState({ state, script });
|
|
12
54
|
|
|
13
|
-
const ScriptContainer = ({ script, ...props }: ScriptEditorProps) => {
|
|
14
|
-
const attendableAttrs = useAttendableAttributes(fullyQualifiedId(script));
|
|
15
55
|
return (
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
|
|
56
|
+
<StackItem.Content toolbar>
|
|
57
|
+
<ScriptToolbar state={state} role={role} script={script} />
|
|
58
|
+
<div role='none' className={mx('flex flex-col w-full overflow-hidden divide-y divide-separator', classNames)}>
|
|
59
|
+
{state.view !== 'debug' && (
|
|
60
|
+
<TypescriptEditor
|
|
61
|
+
id={script.id}
|
|
62
|
+
env={env}
|
|
63
|
+
initialValue={script.source?.target?.content}
|
|
64
|
+
extensions={extensions}
|
|
65
|
+
className={stackItemContentEditorClassNames(role)}
|
|
66
|
+
inputMode={settings.editorInputMode}
|
|
67
|
+
toolbar
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
{state.view !== 'editor' && <DebugPanel functionUrl={state.functionUrl} />}
|
|
72
|
+
</div>
|
|
73
|
+
</StackItem.Content>
|
|
19
74
|
);
|
|
20
75
|
};
|
|
21
76
|
|
|
@@ -6,7 +6,8 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
8
|
import { useClient } from '@dxos/react-client';
|
|
9
|
-
import { Button, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
10
11
|
import { DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
11
12
|
|
|
12
13
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
@@ -39,9 +40,32 @@ export const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps })
|
|
|
39
40
|
|
|
40
41
|
return (
|
|
41
42
|
<>
|
|
43
|
+
{/* TODO(wittjosiah): Hide outside of dev environments. */}
|
|
42
44
|
<DeprecatedFormInput label={t('authenticate action label')}>
|
|
43
45
|
<Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>
|
|
44
46
|
</DeprecatedFormInput>
|
|
47
|
+
|
|
48
|
+
<DeprecatedFormInput label={t('editor input mode label')}>
|
|
49
|
+
<Select.Root
|
|
50
|
+
value={settings.editorInputMode ?? 'default'}
|
|
51
|
+
onValueChange={(value) => {
|
|
52
|
+
settings.editorInputMode = value as EditorInputMode;
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
|
|
56
|
+
<Select.Portal>
|
|
57
|
+
<Select.Content>
|
|
58
|
+
<Select.Viewport>
|
|
59
|
+
{EditorInputModes.map((mode) => (
|
|
60
|
+
<Select.Option key={mode} value={mode}>
|
|
61
|
+
{t(`settings editor input mode ${mode} label`)}
|
|
62
|
+
</Select.Option>
|
|
63
|
+
))}
|
|
64
|
+
</Select.Viewport>
|
|
65
|
+
</Select.Content>
|
|
66
|
+
</Select.Portal>
|
|
67
|
+
</Select.Root>
|
|
68
|
+
</DeprecatedFormInput>
|
|
45
69
|
</>
|
|
46
70
|
);
|
|
47
71
|
};
|