@dxos/plugin-script 0.7.4 → 0.7.5-labs.401163d
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-PMTZROAZ.mjs → AutomationPanel-J3SZ5L3Y.mjs} +4 -11
- package/dist/lib/browser/AutomationPanel-J3SZ5L3Y.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs +713 -0
- package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs.map +7 -0
- package/dist/lib/browser/artifact-YCIVHFSS.mjs +243 -0
- package/dist/lib/browser/artifact-YCIVHFSS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-45LXDWNF.mjs} +2 -2
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs +15 -0
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs.map +7 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs +21 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs.map +7 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs +40 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs.map +7 -0
- package/dist/lib/browser/chunk-UDLKK74O.mjs +69 -0
- package/dist/lib/browser/chunk-UDLKK74O.mjs.map +7 -0
- package/dist/lib/browser/chunk-WAXHENSY.mjs +236 -0
- package/dist/lib/browser/chunk-WAXHENSY.mjs.map +7 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs +82 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +111 -359
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs +45 -0
- package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ETY4XKFG.mjs +65 -0
- package/dist/lib/browser/react-surface-ETY4XKFG.mjs.map +7 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs +24 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +10 -0
- package/dist/lib/node/{AutomationPanel-AAGQREH7.cjs → AutomationPanel-4M55FURO.cjs} +16 -17
- package/dist/lib/node/AutomationPanel-4M55FURO.cjs.map +7 -0
- package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs +719 -0
- package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs.map +7 -0
- package/dist/lib/node/artifact-IPGGY2Z2.cjs +262 -0
- package/dist/lib/node/artifact-IPGGY2Z2.cjs.map +7 -0
- package/dist/lib/node/chunk-3VDHZ54A.cjs +264 -0
- package/dist/lib/node/chunk-3VDHZ54A.cjs.map +7 -0
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-5UH3F7TA.cjs} +11 -8
- package/dist/lib/node/chunk-5UH3F7TA.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-ALY3N6PW.cjs} +12 -8
- package/dist/lib/node/chunk-ALY3N6PW.cjs.map +7 -0
- package/dist/lib/node/chunk-DJGLGRQV.cjs +60 -0
- package/dist/lib/node/chunk-DJGLGRQV.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-IID7WUQS.cjs} +6 -6
- package/dist/lib/node/chunk-JKPNBFU2.cjs +77 -0
- package/dist/lib/node/chunk-JKPNBFU2.cjs.map +7 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs +104 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs.map +7 -0
- package/dist/lib/node/index.cjs +108 -347
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-WFLQNAID.cjs +59 -0
- package/dist/lib/node/intent-resolver-WFLQNAID.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-OIQJFA7P.cjs +84 -0
- package/dist/lib/node/react-surface-OIQJFA7P.cjs.map +7 -0
- package/dist/lib/node/settings-SZFSMSKM.cjs +38 -0
- package/dist/lib/node/settings-SZFSMSKM.cjs.map +7 -0
- package/dist/lib/node/{types/index.cjs → types.cjs} +6 -8
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-ETQEDY5I.mjs → AutomationPanel-W6SKG35R.mjs} +4 -11
- package/dist/lib/node-esm/AutomationPanel-W6SKG35R.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs +714 -0
- package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs.map +7 -0
- package/dist/lib/node-esm/artifact-7H4HGX5W.mjs +245 -0
- package/dist/lib/node-esm/artifact-7H4HGX5W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5CEKSMA5.mjs +71 -0
- package/dist/lib/node-esm/chunk-5CEKSMA5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-CGF7EOGD.mjs} +2 -2
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs +16 -0
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-P2V2Y5LV.mjs} +7 -4
- package/dist/lib/node-esm/chunk-P2V2Y5LV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs +41 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WCAUDRF4.mjs +237 -0
- package/dist/lib/node-esm/chunk-WCAUDRF4.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs +83 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +111 -359
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs +46 -0
- package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-N67GNKC2.mjs +66 -0
- package/dist/lib/node-esm/react-surface-N67GNKC2.mjs.map +7 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.mjs +25 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +11 -0
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact.d.ts +11 -0
- package/dist/types/src/capabilities/artifact.d.ts.map +1 -0
- 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 +7 -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/AutomationPanel/AutomationPanel.d.ts +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +2 -2
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- 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 +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/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.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/hooks/deploy.d.ts +48 -0
- package/dist/types/src/hooks/deploy.d.ts.map +1 -0
- package/dist/types/src/hooks/format.d.ts +25 -0
- package/dist/types/src/hooks/format.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/template.d.ts +31 -0
- package/dist/types/src/hooks/template.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts +14 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarState.d.ts +10 -0
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/hooks/view.d.ts +33 -0
- package/dist/types/src/hooks/view.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts +3 -0
- package/dist/types/src/templates/discord.d.ts.map +1 -0
- package/dist/types/src/templates/echo.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/forex-effect.d.ts +6 -0
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -0
- package/dist/types/src/templates/forex.d.ts +1 -1
- package/dist/types/src/templates/forex.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 +54 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +30 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -55
- package/src/ScriptPlugin.tsx +62 -145
- package/src/capabilities/artifact.ts +219 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +46 -0
- package/src/capabilities/react-surface.tsx +54 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/compiler/compiler.browser.test.ts +1 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +2 -4
- package/src/components/FrameContainer/FrameContainer.tsx +5 -4
- package/src/components/ScriptContainer.tsx +69 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +28 -4
- package/src/components/ScriptSettingsPanel.tsx +140 -53
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +53 -0
- package/src/{bundler → components/ScriptToolbar}/index.ts +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +75 -10
- package/src/hooks/deploy.ts +169 -0
- package/src/hooks/format.ts +47 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/template.ts +64 -0
- package/src/hooks/useToolbarAction.ts +54 -0
- package/src/hooks/useToolbarState.ts +16 -0
- package/src/hooks/view.ts +52 -0
- package/src/index.ts +2 -7
- package/src/meta.ts +4 -2
- package/src/templates/discord.ts +88 -0
- package/src/templates/echo.ts +5 -1
- package/src/templates/email.ts +26 -23
- package/src/templates/forex-effect.ts +44 -0
- package/src/templates/forex.ts +21 -13
- package/src/{templates.ts → templates/index.ts} +20 -5
- package/src/translations.ts +20 -1
- package/src/types.ts +39 -0
- package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs +0 -425
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +0 -7
- package/dist/lib/browser/chunk-4UTRJLQ3.mjs +0 -286
- package/dist/lib/browser/chunk-4UTRJLQ3.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs +0 -18
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-QFZUFT5G.mjs +0 -48
- package/dist/lib/browser/chunk-QFZUFT5G.mjs.map +0 -7
- package/dist/lib/browser/chunk-U3OP64V4.mjs +0 -123
- package/dist/lib/browser/chunk-U3OP64V4.mjs.map +0 -7
- package/dist/lib/browser/edge/index.mjs +0 -19
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types/index.mjs +0 -12
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs +0 -427
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-CS25QNKZ.cjs +0 -151
- package/dist/lib/node/chunk-CS25QNKZ.cjs.map +0 -7
- package/dist/lib/node/chunk-DQYAU2CJ.cjs +0 -67
- package/dist/lib/node/chunk-DQYAU2CJ.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs +0 -298
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/edge/index.cjs +0 -41
- package/dist/lib/node/edge/index.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs +0 -426
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +0 -125
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs +0 -288
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs +0 -49
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -20
- package/dist/lib/node-esm/edge/index.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/lib/node-esm/types/index.mjs +0 -13
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/bundler/bundler.d.ts +0 -39
- package/dist/types/src/bundler/bundler.d.ts.map +0 -1
- package/dist/types/src/bundler/bundler.test.d.ts +0 -2
- package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
- package/dist/types/src/bundler/index.d.ts +0 -2
- package/dist/types/src/bundler/index.d.ts.map +0 -1
- 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/edge/functions.d.ts +0 -25
- package/dist/types/src/edge/functions.d.ts.map +0 -1
- package/dist/types/src/edge/index.d.ts +0 -2
- package/dist/types/src/edge/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -71
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -8
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/bundler/bundler.test.ts +0 -54
- package/src/bundler/bundler.ts +0 -250
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -52
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -191
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- package/src/components/Toolbar/index.ts +0 -5
- package/src/edge/functions.ts +0 -116
- package/src/edge/index.ts +0 -7
- package/src/types/index.ts +0 -6
- package/src/types/schema.ts +0 -44
- package/src/types/types.ts +0 -29
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-45LXDWNF.mjs.map} +0 -0
- /package/dist/lib/browser/{edge/index.mjs.map → types.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-IID7WUQS.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-CGF7EOGD.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types.mjs.map} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
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({
|
|
19
|
+
intent: ScriptAction.Create,
|
|
20
|
+
resolve: async ({ name, gistUrl }) => {
|
|
21
|
+
let content = templates[0].source;
|
|
22
|
+
const gistId = gistUrl?.split('/').at(-1);
|
|
23
|
+
if (gistId) {
|
|
24
|
+
// TODO(wittjosiah): Capability which contributes Octokit?
|
|
25
|
+
// NOTE: AccessToken not needed to read public gists.
|
|
26
|
+
const octokit = new Octokit();
|
|
27
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
28
|
+
gist_id: gistId,
|
|
29
|
+
});
|
|
30
|
+
const gistContent = Object.values(response.data.files ?? {})[0]?.content;
|
|
31
|
+
if (gistContent) {
|
|
32
|
+
content = gistContent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
data: {
|
|
38
|
+
object: create(ScriptType, {
|
|
39
|
+
name,
|
|
40
|
+
source: makeRef(create(TextType, { content })),
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
@@ -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 { SettingsStore } from '@dxos/local-storage';
|
|
10
|
+
import { Clipboard } from '@dxos/react-ui';
|
|
11
|
+
|
|
12
|
+
import { ScriptCapabilities } from './capabilities';
|
|
13
|
+
import { AutomationPanel, ScriptSettings, ScriptContainer, ScriptSettingsPanel } from '../components';
|
|
14
|
+
import { SCRIPT_PLUGIN } from '../meta';
|
|
15
|
+
import { type ScriptSettingsProps } from '../types';
|
|
16
|
+
|
|
17
|
+
export default () =>
|
|
18
|
+
contributes(Capabilities.ReactSurface, [
|
|
19
|
+
createSurface({
|
|
20
|
+
id: `${SCRIPT_PLUGIN}/settings`,
|
|
21
|
+
role: 'article',
|
|
22
|
+
filter: (data): data is { subject: SettingsStore<ScriptSettingsProps> } =>
|
|
23
|
+
data.subject instanceof SettingsStore && data.subject.prefix === SCRIPT_PLUGIN,
|
|
24
|
+
component: ({ data: { subject } }) => <ScriptSettings settings={subject.value} />,
|
|
25
|
+
}),
|
|
26
|
+
createSurface({
|
|
27
|
+
id: `${SCRIPT_PLUGIN}/article`,
|
|
28
|
+
role: 'article',
|
|
29
|
+
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
30
|
+
component: ({ data, role }) => {
|
|
31
|
+
const compiler = useCapability(ScriptCapabilities.Compiler);
|
|
32
|
+
// TODO(dmaretskyi): Since settings store is not reactive, this would break on the script plugin being enabled without a page reload.
|
|
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
|
+
position: '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
|
+
};
|
|
@@ -12,7 +12,7 @@ describe('Compiler', () => {
|
|
|
12
12
|
await compiler.initialize();
|
|
13
13
|
compiler.setFile('/src/x.ts', 'export const x = 100');
|
|
14
14
|
compiler.setFile('/src/y.ts', 'import { x } from "./x"; export const y = x + 100;');
|
|
15
|
-
const result =
|
|
15
|
+
const result = compiler.compile('/src/y.ts');
|
|
16
16
|
expect(result).to.exist;
|
|
17
17
|
});
|
|
18
18
|
});
|
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ReactiveEchoObject } from '@dxos/client/echo';
|
|
8
7
|
import { failUndefined } from '@dxos/debug';
|
|
8
|
+
import { FunctionType, ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
9
9
|
import { useClient } from '@dxos/react-client';
|
|
10
|
-
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
10
|
+
import { Filter, getMeta, getSpace, type ReactiveEchoObject, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { Select, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
|
|
13
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '../../edge';
|
|
14
13
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
15
|
-
import { FunctionType, ScriptType } from '../../types';
|
|
16
14
|
import { DebugPanel } from '../DebugPanel';
|
|
17
15
|
|
|
18
16
|
export interface AutomationPanelProps {
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
import React, { useEffect, useRef } from 'react';
|
|
6
6
|
|
|
7
7
|
import { clientServiceBundle } from '@dxos/client-protocol';
|
|
8
|
+
import { type BundleResult } from '@dxos/functions/bundler';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
8
10
|
import { log } from '@dxos/log';
|
|
9
11
|
import { useClient } from '@dxos/react-client';
|
|
10
12
|
import { baseSurface, mx } from '@dxos/react-ui-theme';
|
|
11
13
|
import { createProtoRpcPeer } from '@dxos/rpc';
|
|
12
14
|
import { createIFramePort } from '@dxos/rpc-tunnel';
|
|
13
15
|
|
|
14
|
-
import { type BundlerResult } from '../../bundler';
|
|
15
|
-
|
|
16
16
|
export type FrameContainerProps = {
|
|
17
17
|
containerUrl: string;
|
|
18
|
-
result:
|
|
18
|
+
result: BundleResult;
|
|
19
19
|
debug?: boolean;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -46,6 +46,7 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
|
|
|
46
46
|
}, [iframeRef]);
|
|
47
47
|
|
|
48
48
|
// Encodes compiled code via URL.
|
|
49
|
+
invariant(result.sourceHash, 'Source hash is required.');
|
|
49
50
|
const sourceHash = Buffer.from(result.sourceHash).toString('hex');
|
|
50
51
|
const src = result.bundle && `${containerUrl}?ts=${sourceHash}#code=${encodeURIComponent(result.bundle)}`;
|
|
51
52
|
|
|
@@ -59,7 +60,7 @@ export const FrameContainer = ({ containerUrl, result, debug = true }: FrameCont
|
|
|
59
60
|
className={mx(
|
|
60
61
|
baseSurface,
|
|
61
62
|
'flex absolute right-2 bottom-2 w-[400px] h-[200px] ring rounded',
|
|
62
|
-
'z-
|
|
63
|
+
'z-20 overflow-x-hidden overflow-y-auto',
|
|
63
64
|
)}
|
|
64
65
|
>
|
|
65
66
|
<pre className='text-xs whitespace-break-spaces break-all p-2'>
|
|
@@ -2,20 +2,80 @@
|
|
|
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 { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';
|
|
18
|
+
import { useDeployState, useToolbarState } from '../hooks';
|
|
19
|
+
import { type ScriptSettingsProps } from '../types';
|
|
20
|
+
|
|
21
|
+
export type ScriptEditorProps = ThemedClassName<{
|
|
22
|
+
script: ScriptType;
|
|
23
|
+
settings?: ScriptSettingsProps;
|
|
24
|
+
role?: string;
|
|
25
|
+
}> &
|
|
26
|
+
Pick<TypescriptEditorProps, 'env'>;
|
|
27
|
+
|
|
28
|
+
export const ScriptContainer = ({
|
|
29
|
+
role,
|
|
30
|
+
classNames,
|
|
31
|
+
script,
|
|
32
|
+
settings = { editorInputMode: 'vscode' },
|
|
33
|
+
env,
|
|
34
|
+
}: ScriptEditorProps) => {
|
|
35
|
+
const identity = useIdentity();
|
|
36
|
+
const space = getSpace(script);
|
|
37
|
+
|
|
38
|
+
const extensions = useMemo(
|
|
39
|
+
() => [
|
|
40
|
+
listener({
|
|
41
|
+
onChange: (text) => {
|
|
42
|
+
if (script.source.target && script.source.target.content !== text) {
|
|
43
|
+
script.changed = true;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
createDataExtensions({
|
|
48
|
+
id: script.id,
|
|
49
|
+
text: script.source.target && createDocAccessor(script.source.target, ['content']),
|
|
50
|
+
space,
|
|
51
|
+
identity,
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
[script, script.source.target, space, identity],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const state = useToolbarState({ view: 'editor' });
|
|
58
|
+
useDeployState({ state, script });
|
|
12
59
|
|
|
13
|
-
const ScriptContainer = ({ script, ...props }: ScriptEditorProps) => {
|
|
14
|
-
const attendableAttrs = useAttendableAttributes(fullyQualifiedId(script));
|
|
15
60
|
return (
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
|
|
61
|
+
<StackItem.Content toolbar>
|
|
62
|
+
<ScriptToolbar state={state} role={role} script={script} />
|
|
63
|
+
<div role='none' className={mx('flex flex-col w-full overflow-hidden divide-y divide-separator', classNames)}>
|
|
64
|
+
{state.view !== 'debug' && (
|
|
65
|
+
<TypescriptEditor
|
|
66
|
+
id={script.id}
|
|
67
|
+
env={env}
|
|
68
|
+
initialValue={script.source?.target?.content}
|
|
69
|
+
extensions={extensions}
|
|
70
|
+
className={stackItemContentEditorClassNames(role)}
|
|
71
|
+
inputMode={settings.editorInputMode}
|
|
72
|
+
toolbar
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
|
|
76
|
+
{state.view !== 'editor' && <DebugPanel functionUrl={state.functionUrl} />}
|
|
77
|
+
</div>
|
|
78
|
+
</StackItem.Content>
|
|
19
79
|
);
|
|
20
80
|
};
|
|
21
81
|
|
|
@@ -6,8 +6,9 @@ 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';
|
|
10
|
-
import {
|
|
9
|
+
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
11
|
+
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
11
12
|
|
|
12
13
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
13
14
|
import { type ScriptSettingsProps } from '../../types';
|
|
@@ -38,10 +39,33 @@ export const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps })
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
return (
|
|
41
|
-
|
|
42
|
+
<DeprecatedFormContainer>
|
|
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>
|
|
45
|
-
|
|
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>
|
|
69
|
+
</DeprecatedFormContainer>
|
|
46
70
|
);
|
|
47
71
|
};
|
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { Octokit } from '@octokit/core';
|
|
6
|
+
import React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';
|
|
6
7
|
|
|
8
|
+
import { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
7
11
|
import { useClient } from '@dxos/react-client';
|
|
8
12
|
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
9
|
-
import { Button,
|
|
13
|
+
import { Button, Clipboard, Input, Separator, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import { AccessTokenType } from '@dxos/schema';
|
|
10
15
|
|
|
11
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '../edge';
|
|
12
16
|
import { SCRIPT_PLUGIN } from '../meta';
|
|
13
|
-
|
|
17
|
+
|
|
18
|
+
// TODO(wittjosiah): Factor out.
|
|
19
|
+
// From https://stackoverflow.com/a/67243723/2804332
|
|
20
|
+
const kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
|
|
14
21
|
|
|
15
22
|
export type ScriptSettingsPanelProps = {
|
|
16
23
|
script: ScriptType;
|
|
@@ -18,18 +25,39 @@ export type ScriptSettingsPanelProps = {
|
|
|
18
25
|
|
|
19
26
|
export const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {
|
|
20
27
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
28
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
21
29
|
const client = useClient();
|
|
22
30
|
const space = getSpace(script);
|
|
23
31
|
const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
|
|
32
|
+
const [githubToken] = useQuery(space, Filter.schema(AccessTokenType, { source: 'github.com' }));
|
|
33
|
+
const gistKey = getMeta(script).keys.find(({ source }) => source === 'github.com');
|
|
34
|
+
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const token = githubToken?.token;
|
|
38
|
+
const gistId = gistKey?.id;
|
|
39
|
+
if (!token || !gistId) {
|
|
40
|
+
setGistUrl(undefined);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const timeout = setTimeout(async () => {
|
|
45
|
+
try {
|
|
46
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
47
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
48
|
+
gist_id: gistId,
|
|
49
|
+
});
|
|
50
|
+
setGistUrl(response.data.html_url);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
log.catch(err);
|
|
53
|
+
setGistUrl(undefined);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return () => clearTimeout(timeout);
|
|
58
|
+
}, [githubToken, gistKey]);
|
|
31
59
|
|
|
32
|
-
const [binding, setBinding] =
|
|
60
|
+
const [binding, setBinding] = useControlledState(fn?.binding ?? '');
|
|
33
61
|
const handleBindingChange = useCallback(
|
|
34
62
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
35
63
|
setBinding(event.target.value);
|
|
@@ -47,55 +75,114 @@ export const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {
|
|
|
47
75
|
spaceId: space?.id,
|
|
48
76
|
});
|
|
49
77
|
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
const handleOpenTokenManager = useCallback(
|
|
79
|
+
() => dispatch(createIntent(SettingsAction.Open, { plugin: 'dxos.org/plugin/token-manager' })),
|
|
80
|
+
[],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const [publishing, setPublishing] = useState(false);
|
|
84
|
+
const handlePublish = useCallback(async () => {
|
|
85
|
+
setPublishing(true);
|
|
86
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
87
|
+
const source = await script.source.load();
|
|
88
|
+
const filename = script.name ? kebabize(script.name) : 'composer-script';
|
|
89
|
+
const files = { [`${filename}.ts`]: { content: source.content } };
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
// TODO(wittjosiah): Factor out to intent.
|
|
93
|
+
const meta = getMeta(script);
|
|
94
|
+
const githubKey = meta.keys.find(({ source }) => source === 'github.com');
|
|
95
|
+
const gistId = githubKey?.id;
|
|
96
|
+
if (gistId) {
|
|
97
|
+
await octokit.request('PATCH /gists/{gist_id}', {
|
|
98
|
+
gist_id: gistId,
|
|
99
|
+
files,
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
const response = await octokit.request('POST /gists', {
|
|
103
|
+
public: true,
|
|
104
|
+
files,
|
|
105
|
+
});
|
|
106
|
+
if (response.data.id) {
|
|
107
|
+
meta.keys.push({ source: 'github.com', id: response.data.id });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} finally {
|
|
111
|
+
setPublishing(false);
|
|
112
|
+
}
|
|
113
|
+
}, [script, githubToken]);
|
|
52
114
|
|
|
53
115
|
return (
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
116
|
+
<>
|
|
117
|
+
<div role='form' className='flex flex-col w-full p-2 gap-4'>
|
|
118
|
+
<Input.Root>
|
|
119
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
120
|
+
<Input.Label>{t('description label')}</Input.Label>
|
|
121
|
+
<Input.TextInput
|
|
122
|
+
placeholder={t('description placeholder')}
|
|
123
|
+
value={script.description ?? ''}
|
|
124
|
+
onChange={(event) => {
|
|
125
|
+
script.description = event.target.value;
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
</Input.Root>
|
|
130
|
+
</div>
|
|
131
|
+
{fn && functionUrl && (
|
|
66
132
|
<>
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
133
|
+
<Separator />
|
|
134
|
+
<div role='form' className='flex flex-col w-full p-2 gap-4'>
|
|
135
|
+
<h2>{t('remote function settings heading')}</h2>
|
|
136
|
+
<Input.Root>
|
|
137
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
138
|
+
<Input.Label>{t('function url label')}</Input.Label>
|
|
139
|
+
<div role='none' className='flex gap-1'>
|
|
140
|
+
<Input.TextInput
|
|
141
|
+
disabled
|
|
142
|
+
value={functionUrl}
|
|
143
|
+
onChange={(event) => {
|
|
144
|
+
fn.name = event.target.value;
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
<Clipboard.IconButton value={functionUrl} />
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</Input.Root>
|
|
151
|
+
<Input.Root>
|
|
152
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
153
|
+
<Input.Label>{t('function binding label')}</Input.Label>
|
|
73
154
|
<Input.TextInput
|
|
74
|
-
|
|
75
|
-
value={
|
|
76
|
-
onChange={
|
|
77
|
-
|
|
78
|
-
}}
|
|
155
|
+
placeholder={t('function binding placeholder')}
|
|
156
|
+
value={binding}
|
|
157
|
+
onChange={handleBindingChange}
|
|
158
|
+
onBlur={handleBindingBlur}
|
|
79
159
|
/>
|
|
80
|
-
<Button onClick={handleCopy}>
|
|
81
|
-
<Icon icon='ph--copy--regular' size={4} />
|
|
82
|
-
</Button>
|
|
83
160
|
</div>
|
|
84
|
-
</
|
|
85
|
-
</
|
|
86
|
-
<Input.Root>
|
|
87
|
-
<div role='none' className='flex flex-col gap-1'>
|
|
88
|
-
<Input.Label>{t('function binding label')}</Input.Label>
|
|
89
|
-
<Input.TextInput
|
|
90
|
-
placeholder={t('function binding placeholder')}
|
|
91
|
-
value={binding}
|
|
92
|
-
onChange={handleBindingChange}
|
|
93
|
-
onBlur={handleBindingBlur}
|
|
94
|
-
/>
|
|
95
|
-
</div>
|
|
96
|
-
</Input.Root>
|
|
161
|
+
</Input.Root>
|
|
162
|
+
</div>
|
|
97
163
|
</>
|
|
98
164
|
)}
|
|
99
|
-
|
|
165
|
+
<Separator />
|
|
166
|
+
<div className='flex flex-col w-full p-2 gap-4'>
|
|
167
|
+
<div>
|
|
168
|
+
<h2>{t('script publish settings label')}</h2>
|
|
169
|
+
<p className='text-description text-sm'>{t('script publish settings description')}</p>
|
|
170
|
+
</div>
|
|
171
|
+
{!githubToken && (
|
|
172
|
+
<div className='flex flex-col items-center justify-center gap-2'>
|
|
173
|
+
<span>{t('no github token label')}</span>
|
|
174
|
+
<Button onClick={handleOpenTokenManager}>{t('open token manager label')}</Button>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
{githubToken && (
|
|
178
|
+
<div className='flex justify-end gap-2'>
|
|
179
|
+
{gistUrl && <Clipboard.IconButton value={gistUrl} />}
|
|
180
|
+
<Button disabled={publishing} onClick={handlePublish}>
|
|
181
|
+
{t(publishing ? 'publishing label' : 'publish label')}
|
|
182
|
+
</Button>
|
|
183
|
+
</div>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
</>
|
|
100
187
|
);
|
|
101
188
|
};
|
package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx}
RENAMED
|
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
|
|
|
8
8
|
|
|
9
9
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { ScriptToolbar } from './ScriptToolbar';
|
|
12
12
|
import { templates } from '../../templates';
|
|
13
13
|
|
|
14
14
|
export const Default = {
|
|
@@ -23,7 +23,7 @@ export const Default = {
|
|
|
23
23
|
|
|
24
24
|
const meta: Meta = {
|
|
25
25
|
title: 'plugins/plugin-script/Toolbar',
|
|
26
|
-
component:
|
|
26
|
+
component: ScriptToolbar,
|
|
27
27
|
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ScriptType } from '@dxos/functions';
|
|
8
|
+
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
|
+
import { ElevationProvider, type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
+
import { stackItemContentToolbarClassNames } from '@dxos/react-ui-editor';
|
|
11
|
+
import { createGapSeparator, MenuProvider, ToolbarMenu, useMenuActions } from '@dxos/react-ui-menu';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
type ScriptToolbarState,
|
|
15
|
+
createDeploy,
|
|
16
|
+
createFormat,
|
|
17
|
+
createTemplateSelect,
|
|
18
|
+
createView,
|
|
19
|
+
useToolbarAction,
|
|
20
|
+
} from '../../hooks';
|
|
21
|
+
|
|
22
|
+
export type ScriptToolbarProps = ThemedClassName<{
|
|
23
|
+
role?: string;
|
|
24
|
+
script: ScriptType;
|
|
25
|
+
state: ScriptToolbarState;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
const createToolbar = (state: ScriptToolbarState) => {
|
|
29
|
+
const templateSelect = createTemplateSelect();
|
|
30
|
+
const format = createFormat();
|
|
31
|
+
const gap = createGapSeparator();
|
|
32
|
+
const deploy = createDeploy(state);
|
|
33
|
+
const view = createView(state);
|
|
34
|
+
return {
|
|
35
|
+
nodes: [...templateSelect.nodes, ...format.nodes, ...gap.nodes, ...deploy.nodes, ...view.nodes],
|
|
36
|
+
edges: [...templateSelect.edges, ...format.edges, ...gap.edges, ...deploy.edges, ...view.edges],
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbarProps) => {
|
|
41
|
+
const handleAction = useToolbarAction({ state, script });
|
|
42
|
+
const toolbarCreator = useCallback(() => createToolbar(state), [state]);
|
|
43
|
+
const menu = useMenuActions(toolbarCreator);
|
|
44
|
+
return (
|
|
45
|
+
<div role='none' className={stackItemContentToolbarClassNames(role)}>
|
|
46
|
+
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
47
|
+
<MenuProvider {...menu} onAction={handleAction} attendableId={fullyQualifiedId(script)}>
|
|
48
|
+
<ToolbarMenu classNames={classNames} />
|
|
49
|
+
</MenuProvider>
|
|
50
|
+
</ElevationProvider>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -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;
|