@dxos/plugin-script 0.8.4-main.c1de068 → 0.8.4-main.e098934
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs → DeploymentDialog-QZSTVNIS.mjs} +3 -3
- package/dist/lib/browser/{ScriptContainer-Z6SIGRRC.mjs → ScriptContainer-DNNA6XC6.mjs} +14 -11
- package/dist/lib/browser/ScriptContainer-DNNA6XC6.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-IABOSTBK.mjs} +2 -2
- package/dist/lib/{node-esm/app-graph-builder-7EYIHWH4.mjs.map → browser/app-graph-builder-IABOSTBK.mjs.map} +3 -3
- package/dist/lib/browser/blueprint-definition-AR7ITBCD.mjs +28 -0
- package/dist/lib/browser/blueprint-definition-AR7ITBCD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-6CAH7VIE.mjs} +14 -14
- package/dist/lib/browser/chunk-6CAH7VIE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-GZKWMME3.mjs} +42 -41
- package/dist/lib/browser/chunk-GZKWMME3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-NXKU3BNX.mjs} +33 -44
- package/dist/lib/browser/chunk-NXKU3BNX.mjs.map +7 -0
- package/dist/lib/browser/chunk-RNGIQIEJ.mjs +88 -0
- package/dist/lib/browser/chunk-RNGIQIEJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-YCZPTTFO.mjs} +3 -3
- package/dist/lib/browser/chunk-YCZPTTFO.mjs.map +7 -0
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-2HJH34GM.mjs} +20 -4
- package/dist/lib/browser/compiler-2HJH34GM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-7B77IG3N.mjs → intent-resolver-F4YSRPJI.mjs} +8 -10
- package/dist/lib/browser/intent-resolver-F4YSRPJI.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-BBHFU6MI.mjs} +6 -6
- package/dist/lib/browser/react-surface-BBHFU6MI.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs → DeploymentDialog-G6EHEPXN.mjs} +3 -3
- package/dist/lib/node-esm/{ScriptContainer-KPU75HHI.mjs → ScriptContainer-KPYZN2KY.mjs} +14 -11
- package/dist/lib/node-esm/ScriptContainer-KPYZN2KY.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-CQTTAYHP.mjs} +2 -2
- package/dist/lib/{browser/app-graph-builder-HLQ7K3BT.mjs.map → node-esm/app-graph-builder-CQTTAYHP.mjs.map} +3 -3
- package/dist/lib/node-esm/blueprint-definition-TJY4TX6S.mjs +30 -0
- package/dist/lib/node-esm/blueprint-definition-TJY4TX6S.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-2GBESIHU.mjs} +14 -14
- package/dist/lib/node-esm/chunk-2GBESIHU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GWHLP5LM.mjs +90 -0
- package/dist/lib/node-esm/chunk-GWHLP5LM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-HUHVIOL5.mjs} +42 -41
- package/dist/lib/node-esm/chunk-HUHVIOL5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-M642JUOZ.mjs} +33 -44
- package/dist/lib/node-esm/chunk-M642JUOZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-ZA36GO4T.mjs} +3 -3
- package/dist/lib/node-esm/chunk-ZA36GO4T.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-7SP27RA6.mjs} +20 -4
- package/dist/lib/node-esm/compiler-7SP27RA6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +14 -13
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-FRZGS4TB.mjs → intent-resolver-CGQYRWWD.mjs} +8 -10
- package/dist/lib/node-esm/intent-resolver-CGQYRWWD.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-UWIWPKZD.mjs} +6 -6
- package/dist/lib/node-esm/react-surface-UWIWPKZD.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +139 -12
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +7 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +10 -3
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +5 -4
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +3 -3
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -61
- package/src/ScriptPlugin.tsx +4 -4
- package/src/capabilities/app-graph-builder.ts +2 -2
- package/src/capabilities/artifact-definition.ts +7 -11
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +2 -1
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +2 -5
- package/src/capabilities/react-surface.tsx +3 -2
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +28 -16
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +5 -5
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +3 -2
- package/src/components/ScriptContainer.tsx +3 -2
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +19 -14
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -4
- package/src/components/Settings/ScriptObjectSettings.tsx +19 -23
- package/src/components/Settings/ScriptPluginSettings.tsx +33 -28
- package/src/components/TestPanel/TestContainer.tsx +2 -1
- package/src/components/TestPanel/TestPanel.tsx +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +9 -16
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +6 -4
- package/src/hooks/deploy.ts +11 -11
- package/src/hooks/template.ts +1 -1
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +1 -0
- package/src/templates/chess.ts +1 -1
- package/src/templates/data-generator.ts +7 -3
- package/src/templates/discord.ts +4 -4
- package/src/templates/forex-effect.ts +3 -3
- package/src/templates/forex.ts +1 -1
- package/src/templates/gmail.ts +13 -54
- package/src/translations.ts +1 -0
- package/src/util/deploy.ts +20 -33
- package/src/util/functions.ts +4 -4
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs +0 -249
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7B77IG3N.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FRZGS4TB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-QZSTVNIS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs.map → DeploymentDialog-G6EHEPXN.mjs.map} +0 -0
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
|
-
import React, { type ChangeEvent, useCallback,
|
|
6
|
+
import React, { type ChangeEvent, useCallback, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { FunctionType, type ScriptType, getInvocationUrl,
|
|
8
|
+
import { SettingsAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter, getMeta, getSpace,
|
|
13
|
-
import { Button, Clipboard, Input, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Filter, Ref, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
13
|
+
import { Button, Clipboard, Input, useAsyncEffect, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
14
|
import { DataType } from '@dxos/schema';
|
|
15
15
|
|
|
16
16
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
@@ -50,10 +50,10 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
50
50
|
const space = getSpace(object);
|
|
51
51
|
const [fn] = useQuery(space, Filter.type(FunctionType, { source: Ref.make(object) }));
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const functionId = fn && getUserFunctionIdInMetadata(getMeta(fn));
|
|
54
54
|
const functionUrl =
|
|
55
|
-
|
|
56
|
-
getInvocationUrl(
|
|
55
|
+
functionId &&
|
|
56
|
+
getInvocationUrl(functionId, client.config.values.runtime?.services?.edge?.url ?? '', {
|
|
57
57
|
spaceId: space?.id,
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -116,7 +116,7 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
116
116
|
const gistKey = getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
117
117
|
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
useAsyncEffect(async () => {
|
|
120
120
|
const token = githubToken?.token;
|
|
121
121
|
const gistId = gistKey?.id;
|
|
122
122
|
if (!token || !gistId) {
|
|
@@ -124,20 +124,16 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return () => clearTimeout(timeout);
|
|
127
|
+
try {
|
|
128
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
129
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
130
|
+
gist_id: gistId,
|
|
131
|
+
});
|
|
132
|
+
setGistUrl(response.data.html_url);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
log.catch(err);
|
|
135
|
+
setGistUrl(undefined);
|
|
136
|
+
}
|
|
141
137
|
}, [githubToken, gistKey]);
|
|
142
138
|
|
|
143
139
|
const handleOpenTokenManager = useCallback(
|
|
@@ -8,7 +8,7 @@ import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
|
8
8
|
import { useClient } from '@dxos/react-client';
|
|
9
9
|
import { Button, Select, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';
|
|
11
|
-
import {
|
|
11
|
+
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
12
12
|
|
|
13
13
|
import { meta } from '../../meta';
|
|
14
14
|
import { type ScriptSettingsProps } from '../../types';
|
|
@@ -39,33 +39,38 @@ export const ScriptPluginSettings = ({ settings }: { settings: ScriptSettingsPro
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
<ControlPage>
|
|
43
|
+
<ControlSection title={t('settings title', { ns: meta.id })}>
|
|
44
|
+
<ControlGroup>
|
|
45
|
+
{/* TODO(wittjosiah): Hide outside of dev environments. */}
|
|
46
|
+
<ControlItemInput title={t('authenticate action label')}>
|
|
47
|
+
<Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>
|
|
48
|
+
</ControlItemInput>
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
<ControlItemInput title={t('editor input mode label')}>
|
|
51
|
+
<Select.Root
|
|
52
|
+
value={settings.editorInputMode ?? 'default'}
|
|
53
|
+
onValueChange={(value) => {
|
|
54
|
+
settings.editorInputMode = value as EditorInputMode;
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Select.TriggerButton placeholder={t('select editor input mode placeholder')} />
|
|
58
|
+
<Select.Portal>
|
|
59
|
+
<Select.Content>
|
|
60
|
+
<Select.Viewport>
|
|
61
|
+
{EditorInputModes.map((mode) => (
|
|
62
|
+
<Select.Option key={mode} value={mode}>
|
|
63
|
+
{t(`settings editor input mode ${mode} label`)}
|
|
64
|
+
</Select.Option>
|
|
65
|
+
))}
|
|
66
|
+
</Select.Viewport>
|
|
67
|
+
<Select.Arrow />
|
|
68
|
+
</Select.Content>
|
|
69
|
+
</Select.Portal>
|
|
70
|
+
</Select.Root>
|
|
71
|
+
</ControlItemInput>
|
|
72
|
+
</ControlGroup>
|
|
73
|
+
</ControlSection>
|
|
74
|
+
</ControlPage>
|
|
70
75
|
);
|
|
71
76
|
};
|
|
@@ -7,9 +7,10 @@ import React from 'react';
|
|
|
7
7
|
import { type ScriptType } from '@dxos/functions';
|
|
8
8
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
9
|
|
|
10
|
-
import { TestPanel } from './TestPanel';
|
|
11
10
|
import { useDeployState, useToolbarState } from '../../hooks';
|
|
12
11
|
|
|
12
|
+
import { TestPanel } from './TestPanel';
|
|
13
|
+
|
|
13
14
|
export type TestContainerProps = {
|
|
14
15
|
role: string;
|
|
15
16
|
script: ScriptType;
|
|
@@ -237,7 +237,7 @@ const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message
|
|
|
237
237
|
)}
|
|
238
238
|
|
|
239
239
|
{data && (
|
|
240
|
-
<SyntaxHighlighter language='json' className={mx(wrapper, '
|
|
240
|
+
<SyntaxHighlighter language='json' className={mx(wrapper, 'text-xs')}>
|
|
241
241
|
{JSON.stringify(data, null, 2)}
|
|
242
242
|
</SyntaxHighlighter>
|
|
243
243
|
)}
|
|
@@ -4,25 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
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
12
|
import { withTheme } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
|
-
import { TypescriptEditor } from './TypescriptEditor';
|
|
15
14
|
import { templates } from '../../templates';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
// - language support for S
|
|
19
|
-
// - hierarchical editor (DND)
|
|
20
|
-
// - virtual document image rendering
|
|
21
|
-
// - mobile rendering error
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): JSX.
|
|
24
|
-
// TODO(burdon): Effect schema.
|
|
25
|
-
// TODO(burdon): react-buddy for storybook?
|
|
16
|
+
import { TypescriptEditor } from './TypescriptEditor';
|
|
26
17
|
|
|
27
18
|
const DefaultStory = () => {
|
|
28
19
|
const object = useMemo(() => createObject({ content: templates[0].source }), []);
|
|
@@ -32,13 +23,15 @@ const DefaultStory = () => {
|
|
|
32
23
|
return <TypescriptEditor id='test' initialValue={initialValue} extensions={extensions} />;
|
|
33
24
|
};
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const meta: Meta = {
|
|
26
|
+
const meta = {
|
|
38
27
|
title: 'plugins/plugin-script/TypescriptEditor',
|
|
39
|
-
component: TypescriptEditor,
|
|
28
|
+
component: TypescriptEditor as any,
|
|
40
29
|
render: DefaultStory,
|
|
41
30
|
decorators: [withTheme],
|
|
42
|
-
}
|
|
31
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
43
32
|
|
|
44
33
|
export default meta;
|
|
34
|
+
|
|
35
|
+
type Story = StoryObj<typeof meta>;
|
|
36
|
+
|
|
37
|
+
export const Default: Story = {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { autocompletion, completionKeymap } from '@codemirror/autocomplete';
|
|
5
6
|
import { javascript } from '@codemirror/lang-javascript';
|
|
6
7
|
import { defaultHighlightStyle } from '@codemirror/language';
|
|
7
8
|
import { lintKeymap } from '@codemirror/lint';
|
|
@@ -11,15 +12,14 @@ import { keymap } from '@codemirror/view';
|
|
|
11
12
|
import { tags } from '@lezer/highlight';
|
|
12
13
|
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
13
14
|
import { continueKeymap } from '@valtown/codemirror-continue';
|
|
14
|
-
import {
|
|
15
|
+
import { type HoverInfo, tsAutocomplete, tsFacet, tsHover, tsLinter, tsSync } from '@valtown/codemirror-ts';
|
|
15
16
|
import React from 'react';
|
|
16
17
|
|
|
17
|
-
import { type
|
|
18
|
+
import { type ThemeMode, type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
18
19
|
import {
|
|
19
20
|
type EditorInputMode,
|
|
20
21
|
InputModeExtensions,
|
|
21
22
|
type UseTextEditorProps,
|
|
22
|
-
autocomplete,
|
|
23
23
|
createBasicExtensions,
|
|
24
24
|
createThemeExtensions,
|
|
25
25
|
folding,
|
|
@@ -64,6 +64,7 @@ export const TypescriptEditor = ({
|
|
|
64
64
|
lineWrapping: false,
|
|
65
65
|
monospace: true,
|
|
66
66
|
scrollPastEnd: true,
|
|
67
|
+
search: true,
|
|
67
68
|
}),
|
|
68
69
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
69
70
|
InputModeExtensions[inputMode],
|
|
@@ -74,7 +75,8 @@ export const TypescriptEditor = ({
|
|
|
74
75
|
// TODO(burdon): Factor out.
|
|
75
76
|
javascript({ typescript: true }),
|
|
76
77
|
// https://github.com/val-town/codemirror-ts
|
|
77
|
-
|
|
78
|
+
keymap.of(completionKeymap),
|
|
79
|
+
autocompletion({ override: env ? [tsAutocomplete()] : undefined }),
|
|
78
80
|
keymap.of(lintKeymap),
|
|
79
81
|
env && [
|
|
80
82
|
tsFacet.of({ env, path: `/src/${id}.ts` }),
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { FunctionType, type ScriptType,
|
|
7
|
+
import { FunctionType, type ScriptType, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { type Client, useClient } from '@dxos/react-client';
|
|
10
|
-
import {
|
|
10
|
+
import { Query, Ref, type Space, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { type TFunction } from '@dxos/react-ui';
|
|
12
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
13
|
import { errorMessageColors } from '@dxos/react-ui-theme';
|
|
@@ -29,12 +29,12 @@ export type CreateDeployOptions = {
|
|
|
29
29
|
script: ScriptType;
|
|
30
30
|
fn: FunctionType;
|
|
31
31
|
space?: Space;
|
|
32
|
-
|
|
32
|
+
existingFunctionId?: string;
|
|
33
33
|
client: Client;
|
|
34
34
|
t: TFunction;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export const createDeploy = ({ state, script, space, fn, client,
|
|
37
|
+
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
38
38
|
// TODO(wittjosiah): Should this be an action?
|
|
39
39
|
const errorItem = createMenuAction('error', () => {}, {
|
|
40
40
|
label: state.error ?? ['no error label', { ns: SCRIPT_PLUGIN }],
|
|
@@ -53,7 +53,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
53
53
|
state.error = undefined;
|
|
54
54
|
state.deploying = true;
|
|
55
55
|
|
|
56
|
-
const result = await deployScript({ script, client, space, fn,
|
|
56
|
+
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
57
57
|
|
|
58
58
|
if (!result.success) {
|
|
59
59
|
log.catch(result.error);
|
|
@@ -98,9 +98,9 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
export const useDeployState = ({ state, script }: { state: Partial<DeployState>; script: ScriptType }) => {
|
|
101
|
-
const { space, client, fn,
|
|
101
|
+
const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
102
102
|
useEffect(() => {
|
|
103
|
-
if (!
|
|
103
|
+
if (!existingFunctionId) {
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -109,17 +109,17 @@ export const useDeployState = ({ state, script }: { state: Partial<DeployState>;
|
|
|
109
109
|
fn,
|
|
110
110
|
edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
|
|
111
111
|
});
|
|
112
|
-
}, [
|
|
112
|
+
}, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url]);
|
|
113
113
|
|
|
114
114
|
useEffect(() => {
|
|
115
115
|
state.deployed = isScriptDeployed({ script, fn });
|
|
116
|
-
}, [script.changed,
|
|
116
|
+
}, [script.changed, existingFunctionId, fn, script]);
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
export const useDeployDeps = ({ script }: { script: ScriptType }) => {
|
|
120
120
|
const space = getSpace(script);
|
|
121
121
|
const [fn] = useQuery(space, Query.type(FunctionType, { source: Ref.make(script) }));
|
|
122
122
|
const client = useClient();
|
|
123
|
-
const
|
|
124
|
-
return { space, fn, client,
|
|
123
|
+
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(getMeta(fn)), [fn]);
|
|
124
|
+
return { space, fn, client, existingFunctionId };
|
|
125
125
|
};
|
package/src/hooks/template.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Obj } from '@dxos/echo';
|
|
6
6
|
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
|
|
7
|
-
import {
|
|
7
|
+
import { createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
8
8
|
|
|
9
9
|
import { SCRIPT_PLUGIN } from '../meta';
|
|
10
10
|
import { templates } from '../templates';
|
|
@@ -55,5 +55,6 @@ export const useCreateAndDeployScriptTemplates = (space: Space | undefined, scri
|
|
|
55
55
|
setStatus(hasErrors ? 'error' : 'success');
|
|
56
56
|
}, [space, dispatch, client, scriptTemplates]);
|
|
57
57
|
|
|
58
|
+
// TODO(burdon): Return onCreateAndDeployScripts.
|
|
58
59
|
return { handleCreateAndDeployScripts, status, error };
|
|
59
60
|
};
|
package/src/templates/chess.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { Expando, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';
|
|
9
9
|
|
|
@@ -12,11 +12,15 @@ export default defineFunction({
|
|
|
12
12
|
documentAmount: S.optional(S.Number),
|
|
13
13
|
textSize: S.optional(S.Number),
|
|
14
14
|
mutationAmount: S.optional(S.Number),
|
|
15
|
+
waitAfterCreation: S.optional(S.Number),
|
|
15
16
|
}),
|
|
16
17
|
|
|
17
18
|
outputSchema: S.Struct({}),
|
|
18
19
|
|
|
19
|
-
handler: async ({
|
|
20
|
+
handler: async ({
|
|
21
|
+
data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },
|
|
22
|
+
context: { space },
|
|
23
|
+
}: any) => {
|
|
20
24
|
await space.db.graph.schemaRegistry.addSchema([Expando]);
|
|
21
25
|
const result: Record<string, any> = {};
|
|
22
26
|
const objects: Expando[] = [];
|
|
@@ -42,7 +46,7 @@ export default defineFunction({
|
|
|
42
46
|
|
|
43
47
|
// Flush and wait for data to propagate.
|
|
44
48
|
await space.db.flush();
|
|
45
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
49
|
+
await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));
|
|
46
50
|
return { createdObjects: objects.length };
|
|
47
51
|
},
|
|
48
52
|
});
|
package/src/templates/discord.ts
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { DXN, EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.
|
|
8
|
+
import { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
9
9
|
import {
|
|
10
10
|
DiscordConfig,
|
|
11
11
|
DiscordREST,
|
|
12
12
|
DiscordRESTMemoryLive,
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.
|
|
14
|
+
} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
import {
|
|
16
|
+
import { Config, Effect, Redacted, Ref } from 'https://esm.sh/effect@3.17.0?bundle=false';
|
|
17
17
|
|
|
18
18
|
const MessageSchema = S.Struct({
|
|
19
19
|
id: ObjectId,
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import { S, defineFunction } from 'dxos:functions';
|
|
7
7
|
import {
|
|
8
|
+
FetchHttpClient,
|
|
8
9
|
HttpClient,
|
|
9
10
|
HttpClientRequest,
|
|
10
|
-
FetchHttpClient,
|
|
11
11
|
// @ts-ignore
|
|
12
|
-
} from 'https://esm.sh/@effect/platform@0.
|
|
12
|
+
} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
import { Effect, Schedule } from 'https://esm.sh/effect@3.
|
|
14
|
+
import { Effect, Schedule } from 'https://esm.sh/effect@3.17.0?bundle=false';
|
|
15
15
|
|
|
16
16
|
export default defineFunction({
|
|
17
17
|
description: 'Returns the exchange rate between two currencies.',
|
package/src/templates/forex.ts
CHANGED
package/src/templates/gmail.ts
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import {
|
|
9
|
+
FetchHttpClient,
|
|
9
10
|
HttpClient,
|
|
10
11
|
HttpClientRequest,
|
|
11
|
-
FetchHttpClient,
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
} from 'https://esm.sh/@effect/platform@0.
|
|
13
|
+
} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
import { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
import {
|
|
17
|
+
import { Chunk, Effect, Ref, Schedule, Stream, pipe } from 'https://esm.sh/effect@3.17.0?bundle=false';
|
|
18
18
|
|
|
19
19
|
export default defineFunction({
|
|
20
20
|
inputSchema: S.Struct({
|
|
@@ -98,7 +98,7 @@ export default defineFunction({
|
|
|
98
98
|
sender,
|
|
99
99
|
blocks: [
|
|
100
100
|
{
|
|
101
|
-
|
|
101
|
+
_tag: 'text',
|
|
102
102
|
text: Buffer.from(content, 'base64').toString('utf-8'),
|
|
103
103
|
},
|
|
104
104
|
],
|
|
@@ -174,57 +174,16 @@ const ActorSchema = S.Struct({
|
|
|
174
174
|
role: S.optional(ActorRole),
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
const
|
|
177
|
+
const Base = S.Struct({
|
|
178
178
|
pending: S.optional(S.Boolean),
|
|
179
179
|
});
|
|
180
|
-
type
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
S.
|
|
184
|
-
|
|
185
|
-
disposition: S.optional(S.String),
|
|
186
|
-
text: S.String,
|
|
187
|
-
}),
|
|
188
|
-
).pipe(S.mutable);
|
|
189
|
-
type TextContentBlock = S.Schema.Type<typeof TextContentBlock>;
|
|
190
|
-
const JsonContentBlock = S.extend(
|
|
191
|
-
AbstractContentBlock,
|
|
192
|
-
S.Struct({
|
|
193
|
-
type: S.Literal('json'),
|
|
194
|
-
disposition: S.optional(S.String),
|
|
195
|
-
data: S.String,
|
|
196
|
-
}),
|
|
197
|
-
).pipe(S.mutable);
|
|
198
|
-
type JsonContentBlock = S.Schema.Type<typeof JsonContentBlock>;
|
|
199
|
-
const Base64ImageSource = S.Struct({
|
|
200
|
-
type: S.Literal('base64'),
|
|
201
|
-
mediaType: S.String,
|
|
202
|
-
data: S.String,
|
|
180
|
+
type Base = S.Schema.Type<typeof Base>;
|
|
181
|
+
const Text = S.TaggedStruct('text', {
|
|
182
|
+
mimeType: S.optional(S.String),
|
|
183
|
+
text: S.String,
|
|
184
|
+
...Base.fields,
|
|
203
185
|
}).pipe(S.mutable);
|
|
204
|
-
|
|
205
|
-
type: S.Literal('http'),
|
|
206
|
-
url: S.String,
|
|
207
|
-
}).pipe(S.mutable);
|
|
208
|
-
const ImageSource = S.Union(Base64ImageSource, HttpImageSource);
|
|
209
|
-
type ImageSource = S.Schema.Type<typeof ImageSource>;
|
|
210
|
-
const ImageContentBlock = S.extend(
|
|
211
|
-
AbstractContentBlock,
|
|
212
|
-
S.Struct({
|
|
213
|
-
type: S.Literal('image'),
|
|
214
|
-
id: S.optional(S.String),
|
|
215
|
-
source: S.optional(ImageSource),
|
|
216
|
-
}),
|
|
217
|
-
).pipe(S.mutable);
|
|
218
|
-
type ImageContentBlock = S.Schema.Type<typeof ImageContentBlock>;
|
|
219
|
-
const ReferenceContentBlock = S.extend(
|
|
220
|
-
AbstractContentBlock,
|
|
221
|
-
S.Struct({
|
|
222
|
-
type: S.Literal('reference'),
|
|
223
|
-
reference: S.Any,
|
|
224
|
-
}),
|
|
225
|
-
).pipe(S.mutable);
|
|
226
|
-
type ReferenceContentBlock = S.Schema.Type<typeof ReferenceContentBlock>;
|
|
227
|
-
const MessageContentBlock = S.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
|
|
186
|
+
interface Text extends S.Schema.Type<typeof Text> {}
|
|
228
187
|
|
|
229
188
|
const MessageType = S.Struct({
|
|
230
189
|
id: ObjectId,
|
|
@@ -234,7 +193,7 @@ const MessageType = S.Struct({
|
|
|
234
193
|
sender: ActorSchema.annotations({
|
|
235
194
|
description: 'Identity of the message sender.',
|
|
236
195
|
}),
|
|
237
|
-
blocks: S.Array(
|
|
196
|
+
blocks: S.Array(Text).annotations({
|
|
238
197
|
description: 'Contents of the message.',
|
|
239
198
|
}),
|
|
240
199
|
properties: S.optional(
|
package/src/translations.ts
CHANGED