@dxos/plugin-script 0.7.2 → 0.7.3-staging.971cd8d
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-BZCRRLOQ.mjs → AutomationPanel-PMTZROAZ.mjs} +18 -11
- package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +7 -0
- package/dist/lib/browser/{ScriptContainer-GQ2KJ5BM.mjs → ScriptContainer-RYZFYCNK.mjs} +27 -25
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NCZUJKJE.mjs → chunk-K7KY6YMG.mjs} +14 -10
- package/dist/lib/browser/chunk-K7KY6YMG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DTVOXLPP.mjs → chunk-QFZUFT5G.mjs} +2 -2
- package/dist/lib/browser/{chunk-DTVOXLPP.mjs.map → chunk-QFZUFT5G.mjs.map} +3 -3
- package/dist/lib/browser/chunk-U3OP64V4.mjs +123 -0
- package/dist/lib/browser/chunk-U3OP64V4.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +5 -9
- package/dist/lib/browser/index.mjs +15 -18
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{AutomationPanel-VNLNP3EE.cjs → AutomationPanel-AAGQREH7.cjs} +21 -16
- package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +7 -0
- package/dist/lib/node/{ScriptContainer-K67ZWCKL.cjs → ScriptContainer-FZ44UIRC.cjs} +32 -30
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ4WIWCP.cjs → chunk-4INUJLXL.cjs} +16 -12
- package/dist/lib/node/chunk-4INUJLXL.cjs.map +7 -0
- package/dist/lib/node/chunk-CS25QNKZ.cjs +151 -0
- package/dist/lib/node/chunk-CS25QNKZ.cjs.map +7 -0
- package/dist/lib/node/{chunk-T4PYTKIW.cjs → chunk-DQYAU2CJ.cjs} +5 -5
- package/dist/lib/node/{chunk-T4PYTKIW.cjs.map → chunk-DQYAU2CJ.cjs.map} +3 -3
- package/dist/lib/node/edge/index.cjs +10 -14
- package/dist/lib/node/edge/index.cjs.map +2 -2
- package/dist/lib/node/index.cjs +30 -33
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +4 -4
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AutomationPanel-NWE2QCOE.mjs → AutomationPanel-ETQEDY5I.mjs} +18 -11
- package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +7 -0
- package/dist/lib/node-esm/{ScriptContainer-BVDYLJZI.mjs → ScriptContainer-3PKDW34A.mjs} +27 -25
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +125 -0
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2HYWFUEN.mjs → chunk-GMVPKT6A.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-2HYWFUEN.mjs.map → chunk-GMVPKT6A.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-DXWSRDEN.mjs → chunk-OFYGBUNI.mjs} +14 -10
- package/dist/lib/node-esm/chunk-OFYGBUNI.mjs.map +7 -0
- package/dist/lib/node-esm/edge/index.mjs +5 -9
- package/dist/lib/node-esm/index.mjs +15 -18
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +1 -5
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/edge/functions.d.ts +13 -21
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/edge/index.d.ts +0 -3
- package/dist/types/src/edge/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +43 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +2 -2
- package/dist/types/src/types/types.d.ts +2 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/ScriptPlugin.tsx +4 -8
- package/src/components/AutomationPanel/AutomationPanel.tsx +10 -5
- package/src/components/DebugPanel/DebugPanel.tsx +41 -30
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +5 -25
- package/src/components/ScriptBlock/ScriptBlock.tsx +3 -8
- package/src/components/ScriptEditor.tsx +16 -23
- package/src/components/ScriptSettingsPanel.tsx +1 -5
- package/src/edge/functions.ts +69 -109
- package/src/edge/index.ts +0 -3
- package/src/translations.ts +4 -0
- package/src/types/schema.ts +1 -1
- package/src/types/types.ts +1 -3
- package/dist/lib/browser/AutomationPanel-BZCRRLOQ.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-GQ2KJ5BM.mjs.map +0 -7
- package/dist/lib/browser/chunk-5GGRYRS4.mjs +0 -253
- package/dist/lib/browser/chunk-5GGRYRS4.mjs.map +0 -7
- package/dist/lib/browser/chunk-NCZUJKJE.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-VNLNP3EE.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-K67ZWCKL.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ4WIWCP.cjs.map +0 -7
- package/dist/lib/node/chunk-XS6GEYYH.cjs +0 -273
- package/dist/lib/node/chunk-XS6GEYYH.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-NWE2QCOE.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-BVDYLJZI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DXWSRDEN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V74XKPLC.mjs +0 -255
- package/dist/lib/node-esm/chunk-V74XKPLC.mjs.map +0 -7
- package/dist/types/src/edge/codec.d.ts +0 -4
- package/dist/types/src/edge/codec.d.ts.map +0 -1
- package/dist/types/src/edge/header-codec.d.ts +0 -24
- package/dist/types/src/edge/header-codec.d.ts.map +0 -1
- package/dist/types/src/edge/hub-protocol.d.ts +0 -6
- package/dist/types/src/edge/hub-protocol.d.ts.map +0 -1
- package/src/edge/codec.ts +0 -13
- package/src/edge/header-codec.ts +0 -97
- package/src/edge/hub-protocol.ts +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/edge/index.ts"],"names":[],"mappings":"AAMA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/edge/index.ts"],"names":[],"mappings":"AAMA,cAAc,aAAa,CAAC"}
|
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
'en-US': {
|
|
3
|
+
[x: string]: {
|
|
4
|
+
'typename label': string;
|
|
5
|
+
'plugin name'?: undefined;
|
|
6
|
+
'object title placeholder'?: undefined;
|
|
7
|
+
'create object label'?: undefined;
|
|
8
|
+
'create stack section label'?: undefined;
|
|
9
|
+
'binding placeholder'?: undefined;
|
|
10
|
+
'function request placeholder'?: undefined;
|
|
11
|
+
'deploy label'?: undefined;
|
|
12
|
+
'deployed label'?: undefined;
|
|
13
|
+
'upload failed label'?: undefined;
|
|
14
|
+
'copy link label'?: undefined;
|
|
15
|
+
'format label'?: undefined;
|
|
16
|
+
'toggle details label'?: undefined;
|
|
17
|
+
'authenticate action label'?: undefined;
|
|
18
|
+
'authenticate button label'?: undefined;
|
|
19
|
+
'name label'?: undefined;
|
|
20
|
+
'remote function settings heading'?: undefined;
|
|
21
|
+
'function url label'?: undefined;
|
|
22
|
+
'function binding label'?: undefined;
|
|
23
|
+
'function binding placeholder'?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
'plugin name': string;
|
|
26
|
+
'object title placeholder': string;
|
|
27
|
+
'create object label': string;
|
|
28
|
+
'create stack section label': string;
|
|
29
|
+
'binding placeholder': string;
|
|
30
|
+
'function request placeholder': string;
|
|
31
|
+
'deploy label': string;
|
|
32
|
+
'deployed label': string;
|
|
33
|
+
'upload failed label': string;
|
|
34
|
+
'copy link label': string;
|
|
35
|
+
'format label': string;
|
|
36
|
+
'toggle details label': string;
|
|
37
|
+
'authenticate action label': string;
|
|
38
|
+
'authenticate button label': string;
|
|
39
|
+
'name label': string;
|
|
40
|
+
'remote function settings heading': string;
|
|
41
|
+
'function url label': string;
|
|
42
|
+
'function binding label': string;
|
|
43
|
+
'function binding placeholder': string;
|
|
44
|
+
'typename label'?: undefined;
|
|
45
|
+
};
|
|
3
46
|
"dxos.org/plugin/script": {
|
|
4
47
|
'plugin name': string;
|
|
5
48
|
'object title placeholder': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBA6BE"}
|
|
@@ -39,14 +39,14 @@ declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject
|
|
|
39
39
|
} & {
|
|
40
40
|
id: string;
|
|
41
41
|
}>;
|
|
42
|
-
version:
|
|
42
|
+
version: string;
|
|
43
43
|
inputSchema?: JsonSchemaType | undefined;
|
|
44
44
|
binding?: string | undefined;
|
|
45
45
|
} & {
|
|
46
46
|
id: string;
|
|
47
47
|
}, S.Struct.Encoded<{
|
|
48
48
|
name: typeof S.NonEmptyString;
|
|
49
|
-
version: typeof S.
|
|
49
|
+
version: typeof S.String;
|
|
50
50
|
source: S.optional<ref<{
|
|
51
51
|
name?: string | undefined;
|
|
52
52
|
description?: string | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SettingsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
|
|
2
|
-
import { type SchemaProvides } from '@dxos/plugin-
|
|
3
|
-
import { type SpaceInitProvides } from '@dxos/plugin-space';
|
|
2
|
+
import { type SchemaProvides } from '@dxos/plugin-space';
|
|
4
3
|
export declare enum ScriptAction {
|
|
5
4
|
CREATE = "dxos.org/plugin/script/create"
|
|
6
5
|
}
|
|
7
6
|
export type ScriptSettingsProps = {};
|
|
8
|
-
export type ScriptPluginProvides = GraphBuilderProvides & IntentResolverProvides & MetadataRecordsProvides & SchemaProvides & SettingsProvides<ScriptSettingsProps> &
|
|
7
|
+
export type ScriptPluginProvides = GraphBuilderProvides & IntentResolverProvides & MetadataRecordsProvides & SchemaProvides & SettingsProvides<ScriptSettingsProps> & SurfaceProvides & TranslationsProvides;
|
|
9
8
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,oBAAY,YAAY;IACtB,MAAM,kCAA4B;CACnC;AAED,MAAM,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAErC,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GACrD,sBAAsB,GACtB,uBAAuB,GACvB,cAAc,GACd,gBAAgB,CAAC,mBAAmB,CAAC,GACrC,eAAe,GACf,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-script",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-staging.971cd8d",
|
|
4
4
|
"description": "Braneframe notebook plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -67,32 +67,34 @@
|
|
|
67
67
|
"prettier": "^3.2.4",
|
|
68
68
|
"react-syntax-highlighter": "^15.5.0",
|
|
69
69
|
"typescript": "^5.6.2",
|
|
70
|
-
"@dxos/app-framework": "0.7.
|
|
71
|
-
"@dxos/async": "0.7.
|
|
72
|
-
"@dxos/client": "0.7.
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/echo-schema": "0.7.
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/plugin-
|
|
83
|
-
"@dxos/plugin-
|
|
84
|
-
"@dxos/plugin-
|
|
85
|
-
"@dxos/plugin-
|
|
86
|
-
"@dxos/plugin-
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/react-
|
|
91
|
-
"@dxos/react-ui-
|
|
92
|
-
"@dxos/react-ui-
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/rpc-tunnel": "0.7.
|
|
70
|
+
"@dxos/app-framework": "0.7.3-staging.971cd8d",
|
|
71
|
+
"@dxos/async": "0.7.3-staging.971cd8d",
|
|
72
|
+
"@dxos/client": "0.7.3-staging.971cd8d",
|
|
73
|
+
"@dxos/crypto": "0.7.3-staging.971cd8d",
|
|
74
|
+
"@dxos/client-protocol": "0.7.3-staging.971cd8d",
|
|
75
|
+
"@dxos/debug": "0.7.3-staging.971cd8d",
|
|
76
|
+
"@dxos/echo-schema": "0.7.3-staging.971cd8d",
|
|
77
|
+
"@dxos/edge-client": "0.7.3-staging.971cd8d",
|
|
78
|
+
"@dxos/invariant": "0.7.3-staging.971cd8d",
|
|
79
|
+
"@dxos/keys": "0.7.3-staging.971cd8d",
|
|
80
|
+
"@dxos/live-object": "0.7.3-staging.971cd8d",
|
|
81
|
+
"@dxos/log": "0.7.3-staging.971cd8d",
|
|
82
|
+
"@dxos/plugin-client": "0.7.3-staging.971cd8d",
|
|
83
|
+
"@dxos/plugin-explorer": "0.7.3-staging.971cd8d",
|
|
84
|
+
"@dxos/plugin-graph": "0.7.3-staging.971cd8d",
|
|
85
|
+
"@dxos/plugin-markdown": "0.7.3-staging.971cd8d",
|
|
86
|
+
"@dxos/plugin-space": "0.7.3-staging.971cd8d",
|
|
87
|
+
"@dxos/plugin-stack": "0.7.3-staging.971cd8d",
|
|
88
|
+
"@dxos/plugin-theme": "0.7.3-staging.971cd8d",
|
|
89
|
+
"@dxos/protocols": "0.7.3-staging.971cd8d",
|
|
90
|
+
"@dxos/react-client": "0.7.3-staging.971cd8d",
|
|
91
|
+
"@dxos/react-ui-attention": "0.7.3-staging.971cd8d",
|
|
92
|
+
"@dxos/react-ui-editor": "0.7.3-staging.971cd8d",
|
|
93
|
+
"@dxos/react-ui-form": "0.7.3-staging.971cd8d",
|
|
94
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.3-staging.971cd8d",
|
|
95
|
+
"@dxos/rpc-tunnel": "0.7.3-staging.971cd8d",
|
|
96
|
+
"@dxos/util": "0.7.3-staging.971cd8d",
|
|
97
|
+
"@dxos/rpc": "0.7.3-staging.971cd8d"
|
|
96
98
|
},
|
|
97
99
|
"devDependencies": {
|
|
98
100
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -102,20 +104,19 @@
|
|
|
102
104
|
"react": "~18.2.0",
|
|
103
105
|
"react-dom": "~18.2.0",
|
|
104
106
|
"vite": "5.4.7",
|
|
105
|
-
"@dxos/
|
|
106
|
-
"@dxos/
|
|
107
|
-
"@dxos/react-ui": "0.7.
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/react-ui-theme": "0.7.
|
|
110
|
-
"@dxos/storybook-utils": "0.7.2"
|
|
107
|
+
"@dxos/random": "0.7.3-staging.971cd8d",
|
|
108
|
+
"@dxos/react-ui-mosaic": "0.7.3-staging.971cd8d",
|
|
109
|
+
"@dxos/react-ui": "0.7.3-staging.971cd8d",
|
|
110
|
+
"@dxos/storybook-utils": "0.7.3-staging.971cd8d",
|
|
111
|
+
"@dxos/react-ui-theme": "0.7.3-staging.971cd8d"
|
|
111
112
|
},
|
|
112
113
|
"peerDependencies": {
|
|
113
114
|
"@phosphor-icons/react": "^2.1.5",
|
|
114
115
|
"react": "~18.2.0",
|
|
115
116
|
"react-dom": "~18.2.0",
|
|
116
|
-
"@dxos/react-ui": "0.7.
|
|
117
|
-
"@dxos/react-ui
|
|
118
|
-
"@dxos/react-ui-
|
|
117
|
+
"@dxos/react-ui-mosaic": "0.7.3-staging.971cd8d",
|
|
118
|
+
"@dxos/react-ui": "0.7.3-staging.971cd8d",
|
|
119
|
+
"@dxos/react-ui-theme": "0.7.3-staging.971cd8d"
|
|
119
120
|
},
|
|
120
121
|
"publishConfig": {
|
|
121
122
|
"access": "public"
|
package/src/ScriptPlugin.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
9
|
import { NavigationAction, parseIntentPlugin, type PluginDefinition, resolvePlugin } from '@dxos/app-framework';
|
|
10
|
-
import { create } from '@dxos/
|
|
10
|
+
import { create } from '@dxos/live-object';
|
|
11
11
|
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
12
12
|
import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
|
|
13
13
|
import { TextType } from '@dxos/plugin-markdown/types';
|
|
@@ -48,6 +48,7 @@ export const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {
|
|
|
48
48
|
metadata: {
|
|
49
49
|
records: {
|
|
50
50
|
[ScriptType.typename]: {
|
|
51
|
+
createObject: ScriptAction.CREATE,
|
|
51
52
|
placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],
|
|
52
53
|
icon: 'ph--code--regular',
|
|
53
54
|
// TODO(wittjosiah): Move out of metadata.
|
|
@@ -57,13 +58,8 @@ export const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {
|
|
|
57
58
|
},
|
|
58
59
|
translations,
|
|
59
60
|
echo: {
|
|
60
|
-
schema: [ScriptType
|
|
61
|
-
|
|
62
|
-
space: {
|
|
63
|
-
onSpaceCreate: {
|
|
64
|
-
label: ['create object label', { ns: SCRIPT_PLUGIN }],
|
|
65
|
-
action: ScriptAction.CREATE,
|
|
66
|
-
},
|
|
61
|
+
schema: [ScriptType],
|
|
62
|
+
system: [FunctionType],
|
|
67
63
|
},
|
|
68
64
|
graph: {
|
|
69
65
|
builder: (plugins) => {
|
|
@@ -8,9 +8,10 @@ import { type ReactiveEchoObject } from '@dxos/client/echo';
|
|
|
8
8
|
import { failUndefined } from '@dxos/debug';
|
|
9
9
|
import { useClient } from '@dxos/react-client';
|
|
10
10
|
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
|
-
import { Select } from '@dxos/react-ui';
|
|
11
|
+
import { Select, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
|
|
13
13
|
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '../../edge';
|
|
14
|
+
import { SCRIPT_PLUGIN } from '../../meta';
|
|
14
15
|
import { FunctionType, ScriptType } from '../../types';
|
|
15
16
|
import { DebugPanel } from '../DebugPanel';
|
|
16
17
|
|
|
@@ -19,17 +20,21 @@ export interface AutomationPanelProps {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const AutomationPanel = ({ subject }: AutomationPanelProps) => {
|
|
23
|
+
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
22
24
|
const space = getSpace(subject);
|
|
23
25
|
|
|
24
26
|
// TODO(dmaretskyi): Parametric query.
|
|
25
27
|
const functions = useQuery(
|
|
26
28
|
space ?? undefined,
|
|
27
|
-
|
|
29
|
+
subject instanceof ScriptType
|
|
30
|
+
? Filter.schema(FunctionType, { source: subject })
|
|
31
|
+
: Filter.schema(FunctionType, (fn) => fn.binding != null),
|
|
28
32
|
{},
|
|
29
33
|
[subject],
|
|
30
34
|
);
|
|
35
|
+
|
|
31
36
|
const [selectedFunction, setSelectedFunction] = useState<FunctionType | null>(null);
|
|
32
|
-
const
|
|
37
|
+
const chatFunction = subject instanceof ScriptType ? functions[0] : selectedFunction;
|
|
33
38
|
|
|
34
39
|
return (
|
|
35
40
|
<div className='h-full flex flex-col'>
|
|
@@ -40,8 +45,8 @@ export const AutomationPanel = ({ subject }: AutomationPanelProps) => {
|
|
|
40
45
|
functions={functions}
|
|
41
46
|
/>
|
|
42
47
|
)}
|
|
43
|
-
{
|
|
44
|
-
{subject instanceof ScriptType && functions.length === 0 && <p>
|
|
48
|
+
{chatFunction && <ChatPanel fn={chatFunction} subject={subject} />}
|
|
49
|
+
{subject instanceof ScriptType && functions.length === 0 && <div className='p-1'>{t('not deployed')}</div>}
|
|
45
50
|
</div>
|
|
46
51
|
);
|
|
47
52
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
@@ -159,12 +159,10 @@ export const DebugPanel = ({ classNames, functionUrl }: DebugPanelProps) => {
|
|
|
159
159
|
|
|
160
160
|
return (
|
|
161
161
|
<div className={mx('flex flex-col h-full overflow-hidden', classNames)}>
|
|
162
|
-
{/* TODO(burdon): Replace with Thread
|
|
163
|
-
<
|
|
164
|
-
<MessageThread state={state} result={result} history={history} />
|
|
165
|
-
</div>
|
|
162
|
+
{/* TODO(burdon): Replace with Thread. */}
|
|
163
|
+
<MessageThread ref={scrollerRef} state={state} result={result} history={history} />
|
|
166
164
|
|
|
167
|
-
<Toolbar.Root classNames='p-
|
|
165
|
+
<Toolbar.Root classNames='p-1'>
|
|
168
166
|
<Input.Root>
|
|
169
167
|
<Input.TextInput
|
|
170
168
|
ref={inputRef}
|
|
@@ -189,32 +187,45 @@ export const DebugPanel = ({ classNames, functionUrl }: DebugPanelProps) => {
|
|
|
189
187
|
// TODO(burdon): Replace with thread?
|
|
190
188
|
// TODO(burdon): Button to delete individual messages.
|
|
191
189
|
// TODO(burdon): Button to edit/re-run question.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
190
|
+
type MessageThreadProps = {
|
|
191
|
+
state: State | null;
|
|
192
|
+
history: Message[];
|
|
193
|
+
result: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
|
|
197
|
+
({ state, history, result }: MessageThreadProps, forwardedRef) => {
|
|
198
|
+
if (!history.length && !result.length) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<div ref={forwardedRef} className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>
|
|
204
|
+
{history.map((message, i) => (
|
|
205
|
+
<div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
206
|
+
<div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
|
|
207
|
+
<div className='overflow-auto'>
|
|
208
|
+
<MessageItem message={message} />
|
|
209
|
+
</div>
|
|
209
210
|
</div>
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
))}
|
|
212
|
+
|
|
213
|
+
{result?.length > 0 && (
|
|
214
|
+
<div className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
215
|
+
<div className='p-1'>
|
|
216
|
+
{(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
|
|
217
|
+
<Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
|
|
218
|
+
)}
|
|
219
|
+
</div>
|
|
220
|
+
<div className='overflow-auto'>
|
|
221
|
+
<MessageItem message={{ type: 'response', text: result }} />
|
|
222
|
+
</div>
|
|
212
223
|
</div>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
},
|
|
228
|
+
);
|
|
218
229
|
|
|
219
230
|
const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {
|
|
220
231
|
const { type, text, data, error } = message;
|
|
@@ -5,12 +5,10 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React, {
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
9
|
|
|
10
|
-
import { createSpaceObjectGenerator, TestSchemaType } from '@dxos/echo-generator';
|
|
11
10
|
import { TextType } from '@dxos/plugin-markdown/types';
|
|
12
|
-
import {
|
|
13
|
-
import { create, createObject, useSpaces } from '@dxos/react-client/echo';
|
|
11
|
+
import { create, createObject } from '@dxos/react-client/echo';
|
|
14
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
13
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
16
14
|
|
|
@@ -19,6 +17,8 @@ import { ScriptType } from '../../types';
|
|
|
19
17
|
// @ts-ignore
|
|
20
18
|
import mainUrl from '../FrameContainer/frame?url';
|
|
21
19
|
|
|
20
|
+
const typename = 'example.com/type/contact';
|
|
21
|
+
|
|
22
22
|
const code = [
|
|
23
23
|
"import { Filter, useQuery, useSpaces} from '@dxos/react-client/echo';",
|
|
24
24
|
"import { Chart, Explorer, Globe } from '@dxos/plugin-explorer';",
|
|
@@ -26,32 +26,12 @@ const code = [
|
|
|
26
26
|
'export default () => {',
|
|
27
27
|
' const spaces = useSpaces();',
|
|
28
28
|
' const space = spaces[1]',
|
|
29
|
-
|
|
29
|
+
` const objects = useQuery(space, Filter.typename('${typename}'));`,
|
|
30
30
|
' return <Chart items={objects} accessor={object => ({ x: object.lat, y: object.lng })} />',
|
|
31
31
|
'}',
|
|
32
32
|
].join('\n');
|
|
33
33
|
|
|
34
34
|
const DefaultStory = () => {
|
|
35
|
-
const client = useClient();
|
|
36
|
-
const spaces = useSpaces();
|
|
37
|
-
console.log(spaces.length);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
try {
|
|
41
|
-
// TODO(burdon): Default not set.
|
|
42
|
-
const generator = createSpaceObjectGenerator(client.spaces.default);
|
|
43
|
-
generator.addSchemas();
|
|
44
|
-
void generator
|
|
45
|
-
.createObjects({
|
|
46
|
-
[TestSchemaType.organization]: 20,
|
|
47
|
-
[TestSchemaType.contact]: 50,
|
|
48
|
-
})
|
|
49
|
-
.catch(() => {});
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.log(err);
|
|
52
|
-
}
|
|
53
|
-
}, [client]);
|
|
54
|
-
|
|
55
35
|
// TODO(burdon): Review what's the right way to create automerge-backed objects.
|
|
56
36
|
const object = useMemo(() => createObject(create(ScriptType, { source: create(TextType, { content: code }) })), []);
|
|
57
37
|
|
|
@@ -8,7 +8,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { createDocAccessor, DocAccessor } from '@dxos/react-client/echo';
|
|
10
10
|
import { Toolbar, Button, Icon } from '@dxos/react-ui';
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
12
11
|
|
|
13
12
|
import { Bundler, type BundlerResult, initializeBundler } from '../../bundler';
|
|
14
13
|
import { type ScriptType } from '../../types';
|
|
@@ -28,10 +27,6 @@ const PROVIDED_MODULES = [
|
|
|
28
27
|
export type ScriptBlockProps = {
|
|
29
28
|
script: ScriptType;
|
|
30
29
|
hideSelector?: boolean;
|
|
31
|
-
classes?: {
|
|
32
|
-
root?: string;
|
|
33
|
-
toolbar?: string;
|
|
34
|
-
};
|
|
35
30
|
|
|
36
31
|
// Url to the page used to host the script in the iframe.
|
|
37
32
|
containerUrl: string;
|
|
@@ -41,7 +36,7 @@ export type ScriptBlockProps = {
|
|
|
41
36
|
* @deprecated
|
|
42
37
|
*/
|
|
43
38
|
// TODO(burdon): Cache compiled results in context.
|
|
44
|
-
export const ScriptBlock = ({ script, hideSelector,
|
|
39
|
+
export const ScriptBlock = ({ script, hideSelector, containerUrl }: ScriptBlockProps) => {
|
|
45
40
|
const source = useMemo(() => script.source && createDocAccessor(script.source, ['content']), [script.source]);
|
|
46
41
|
const [result, setResult] = useState<BundlerResult>();
|
|
47
42
|
const bundler = useMemo(
|
|
@@ -78,9 +73,9 @@ export const ScriptBlock = ({ script, hideSelector, classes, containerUrl }: Scr
|
|
|
78
73
|
);
|
|
79
74
|
|
|
80
75
|
return (
|
|
81
|
-
<div className=
|
|
76
|
+
<div className='flex flex-col grow overflow-hidden'>
|
|
82
77
|
{!hideSelector && (
|
|
83
|
-
<Toolbar.Root
|
|
78
|
+
<Toolbar.Root>
|
|
84
79
|
<div className='grow' />
|
|
85
80
|
{result?.bundle && !result?.error && (
|
|
86
81
|
<div title={String(result.error)}>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type DID } from 'iso-did/types';
|
|
6
5
|
import { format } from 'prettier';
|
|
7
6
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
8
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
@@ -23,10 +22,10 @@ import { Bundler } from '../bundler';
|
|
|
23
22
|
import {
|
|
24
23
|
getInvocationUrl,
|
|
25
24
|
getUserFunctionUrlInMetadata,
|
|
26
|
-
publicKeyToDid,
|
|
27
25
|
setUserFunctionUrlInMetadata,
|
|
28
26
|
uploadWorkerFunction,
|
|
29
|
-
|
|
27
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
28
|
+
incrementSemverPatch,
|
|
30
29
|
} from '../edge';
|
|
31
30
|
import { SCRIPT_PLUGIN } from '../meta';
|
|
32
31
|
import { templates } from '../templates';
|
|
@@ -42,11 +41,7 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
|
|
|
42
41
|
const client = useClient();
|
|
43
42
|
const identity = useIdentity();
|
|
44
43
|
const space = getSpace(script);
|
|
45
|
-
|
|
46
|
-
const [fn] = useQuery(
|
|
47
|
-
space,
|
|
48
|
-
Filter.schema(FunctionType, (fn) => fn.source === script),
|
|
49
|
-
);
|
|
44
|
+
const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
|
|
50
45
|
|
|
51
46
|
const extensions = useMemo(
|
|
52
47
|
() => [
|
|
@@ -95,12 +90,12 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
|
|
|
95
90
|
script.name = template.name;
|
|
96
91
|
script.source!.content = template.source;
|
|
97
92
|
const metaKeys = getMeta(script).keys;
|
|
98
|
-
const oldPresetIndex = metaKeys.findIndex((key) => key.source ===
|
|
93
|
+
const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
|
|
99
94
|
if (oldPresetIndex >= 0) {
|
|
100
95
|
metaKeys.splice(oldPresetIndex, 1);
|
|
101
96
|
}
|
|
102
97
|
if (template.presetId) {
|
|
103
|
-
metaKeys.push({ source:
|
|
98
|
+
metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
};
|
|
@@ -114,7 +109,6 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
|
|
|
114
109
|
|
|
115
110
|
try {
|
|
116
111
|
const existingFunctionId = existingFunctionUrl?.split('/').at(-1);
|
|
117
|
-
const ownerDid = (existingFunctionUrl?.split('/').at(-2) as DID) ?? publicKeyToDid(identity.identityKey);
|
|
118
112
|
|
|
119
113
|
const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });
|
|
120
114
|
const buildResult = await bundler.bundle(script.source.content);
|
|
@@ -122,24 +116,23 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
|
|
|
122
116
|
throw buildResult.error;
|
|
123
117
|
}
|
|
124
118
|
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
const { functionId, version, meta } = await uploadWorkerFunction({
|
|
120
|
+
client,
|
|
121
|
+
spaceId: space.id,
|
|
122
|
+
version: fn ? incrementSemverPatch(fn.version) : '0.0.1',
|
|
129
123
|
functionId: existingFunctionId,
|
|
130
124
|
source: buildResult.bundle,
|
|
131
125
|
});
|
|
132
|
-
if (
|
|
133
|
-
throw new Error(
|
|
126
|
+
if (functionId === undefined || version === undefined) {
|
|
127
|
+
throw new Error(`Upload didn't return expected data: functionId=${functionId}, version=${version}`);
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
log.info('function uploaded', { functionId,
|
|
130
|
+
log.info('function uploaded', { functionId, version });
|
|
137
131
|
if (fn) {
|
|
138
|
-
fn.version =
|
|
132
|
+
fn.version = version;
|
|
139
133
|
}
|
|
140
134
|
|
|
141
|
-
const deployedFunction =
|
|
142
|
-
fn ?? space.db.add(create(FunctionType, { name: functionId, version: functionVersionNumber, source: script }));
|
|
135
|
+
const deployedFunction = fn ?? space.db.add(create(FunctionType, { name: functionId, version, source: script }));
|
|
143
136
|
|
|
144
137
|
script.changed = false;
|
|
145
138
|
|
|
@@ -149,14 +142,14 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
|
|
|
149
142
|
log.verbose('no input schema in function metadata', { functionId });
|
|
150
143
|
}
|
|
151
144
|
|
|
152
|
-
setUserFunctionUrlInMetadata(getMeta(deployedFunction), `/${
|
|
145
|
+
setUserFunctionUrlInMetadata(getMeta(deployedFunction), `/${space.id}/${functionId}`);
|
|
153
146
|
|
|
154
147
|
setView('split');
|
|
155
148
|
} catch (err: any) {
|
|
156
149
|
log.catch(err);
|
|
157
150
|
setError(t('upload failed label'));
|
|
158
151
|
}
|
|
159
|
-
}, [fn, existingFunctionUrl, script, script.name, script.source]);
|
|
152
|
+
}, [fn, existingFunctionUrl, script, script.name, script.source, space?.id ?? null]);
|
|
160
153
|
|
|
161
154
|
const functionUrl = useMemo(() => {
|
|
162
155
|
if (!existingFunctionUrl) {
|
|
@@ -20,11 +20,7 @@ export const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {
|
|
|
20
20
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
21
21
|
const client = useClient();
|
|
22
22
|
const space = getSpace(script);
|
|
23
|
-
|
|
24
|
-
const [fn] = useQuery(
|
|
25
|
-
space,
|
|
26
|
-
Filter.schema(FunctionType, (fn) => fn.source === script),
|
|
27
|
-
);
|
|
23
|
+
const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
|
|
28
24
|
|
|
29
25
|
const handleNameChange = useCallback(
|
|
30
26
|
(event: ChangeEvent<HTMLInputElement>) => {
|