@dxos/plugin-script 0.6.8-staging.77f93a3 → 0.6.8-staging.dec6b33
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/{ScriptEditor-6Q7HFLJ6.mjs → ScriptEditor-7XICKICQ.mjs} +42 -21
- package/dist/lib/browser/ScriptEditor-7XICKICQ.mjs.map +7 -0
- package/dist/lib/browser/{TypescriptEditor-HP35MTEQ.mjs → TypescriptEditor-PIRIDDUS.mjs} +2 -2
- package/dist/lib/browser/{chunk-2EM5Y66A.mjs → chunk-D4O723CR.mjs} +4 -2
- package/dist/lib/browser/chunk-D4O723CR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EZ7PWOLU.mjs → chunk-SK3L274X.mjs} +6 -6
- package/dist/lib/browser/{chunk-EZ7PWOLU.mjs.map → chunk-SK3L274X.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-Z72YKDJ2.mjs → chunk-ZGCETT2W.mjs} +13 -3
- package/dist/lib/browser/chunk-ZGCETT2W.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +7 -4
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +3 -1
- package/dist/lib/node/{ScriptEditor-AIVKL2NX.cjs → ScriptEditor-M7KZ2CRS.cjs} +45 -26
- package/dist/lib/node/ScriptEditor-M7KZ2CRS.cjs.map +7 -0
- package/dist/lib/node/{TypescriptEditor-PWOAN5RQ.cjs → TypescriptEditor-OTWJUIWB.cjs} +7 -7
- package/dist/lib/node/{TypescriptEditor-PWOAN5RQ.cjs.map → TypescriptEditor-OTWJUIWB.cjs.map} +2 -2
- package/dist/lib/node/{chunk-SLV3SDZE.cjs → chunk-ITLHJMWP.cjs} +6 -4
- package/dist/lib/node/chunk-ITLHJMWP.cjs.map +7 -0
- package/dist/lib/node/{chunk-6Y2S6SGK.cjs → chunk-VW2POILW.cjs} +17 -6
- package/dist/lib/node/chunk-VW2POILW.cjs.map +7 -0
- package/dist/lib/node/{chunk-LWUBFTPA.cjs → chunk-X6A3D4PD.cjs} +9 -9
- package/dist/lib/node/{chunk-LWUBFTPA.cjs.map → chunk-X6A3D4PD.cjs.map} +2 -2
- package/dist/lib/node/edge/index.cjs +8 -8
- package/dist/lib/node/edge/index.cjs.map +1 -1
- package/dist/lib/node/index.cjs +16 -13
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +5 -3
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/types/script.d.ts +33 -2
- package/dist/types/src/types/script.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/ScriptPlugin.tsx +3 -6
- package/src/components/ScriptEditor.tsx +29 -13
- package/src/components/Toolbar.tsx +24 -4
- package/src/components/TypescriptEditor.tsx +4 -1
- package/src/edge/functions.ts +1 -2
- package/src/types/script.ts +7 -2
- package/src/types/types.tsx +1 -1
- package/dist/lib/browser/ScriptEditor-6Q7HFLJ6.mjs.map +0 -7
- package/dist/lib/browser/chunk-2EM5Y66A.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z72YKDJ2.mjs.map +0 -7
- package/dist/lib/node/ScriptEditor-AIVKL2NX.cjs.map +0 -7
- package/dist/lib/node/chunk-6Y2S6SGK.cjs.map +0 -7
- package/dist/lib/node/chunk-SLV3SDZE.cjs.map +0 -7
- /package/dist/lib/browser/{TypescriptEditor-HP35MTEQ.mjs.map → TypescriptEditor-PIRIDDUS.mjs.map} +0 -0
|
@@ -6,7 +6,6 @@ declare const ScriptType_base: import("@dxos/echo-schema").AbstractTypedObject<{
|
|
|
6
6
|
id: string;
|
|
7
7
|
}>;
|
|
8
8
|
name?: string | undefined;
|
|
9
|
-
binding?: string | undefined;
|
|
10
9
|
changed?: boolean | undefined;
|
|
11
10
|
} & {
|
|
12
11
|
id: string;
|
|
@@ -17,10 +16,42 @@ declare const ScriptType_base: import("@dxos/echo-schema").AbstractTypedObject<{
|
|
|
17
16
|
} & {
|
|
18
17
|
id: string;
|
|
19
18
|
}>;
|
|
20
|
-
binding: S.optional<typeof S.String>;
|
|
21
19
|
changed: S.optional<typeof S.Boolean>;
|
|
22
20
|
}>>;
|
|
23
21
|
export declare class ScriptType extends ScriptType_base {
|
|
24
22
|
}
|
|
23
|
+
declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject<{
|
|
24
|
+
source?: import("@dxos/echo-schema").Ref<{
|
|
25
|
+
source: import("@dxos/echo-schema").Ref<{
|
|
26
|
+
content: string;
|
|
27
|
+
} & {
|
|
28
|
+
id: string;
|
|
29
|
+
}>;
|
|
30
|
+
name?: string | undefined;
|
|
31
|
+
changed?: boolean | undefined;
|
|
32
|
+
} & {
|
|
33
|
+
id: string;
|
|
34
|
+
}>;
|
|
35
|
+
version: number;
|
|
36
|
+
binding?: string | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
id: string;
|
|
39
|
+
}, S.Struct.Encoded<{
|
|
40
|
+
version: typeof S.Number;
|
|
41
|
+
binding: S.optional<typeof S.String>;
|
|
42
|
+
source: S.optional<ref<{
|
|
43
|
+
source: import("@dxos/echo-schema").Ref<{
|
|
44
|
+
content: string;
|
|
45
|
+
} & {
|
|
46
|
+
id: string;
|
|
47
|
+
}>;
|
|
48
|
+
name?: string | undefined;
|
|
49
|
+
changed?: boolean | undefined;
|
|
50
|
+
} & {
|
|
51
|
+
id: string;
|
|
52
|
+
}>>;
|
|
53
|
+
}>>;
|
|
54
|
+
export declare class FunctionType extends FunctionType_base {
|
|
55
|
+
}
|
|
25
56
|
export {};
|
|
26
57
|
//# sourceMappingURL=script.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../../src/types/script.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../../src/types/script.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;AAGxD,qBAAa,UAAW,SAAQ,eAK9B;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAMhC;CAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
|
|
2
2
|
import { type SchemaProvides } from '@dxos/plugin-client';
|
|
3
|
-
import type
|
|
3
|
+
import { type StackProvides } from '@dxos/plugin-stack';
|
|
4
4
|
export declare enum ScriptAction {
|
|
5
5
|
CREATE = "dxos.org/plugin/script/create"
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,oBAAY,YAAY;IACtB,MAAM,kCAA4B;CACnC;AAED,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAChD,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,oBAAoB,GACpB,cAAc,GACd,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-script",
|
|
3
|
-
"version": "0.6.8-staging.
|
|
3
|
+
"version": "0.6.8-staging.dec6b33",
|
|
4
4
|
"description": "Braneframe notebook plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -67,29 +67,29 @@
|
|
|
67
67
|
"esbuild-wasm": "^0.16.14",
|
|
68
68
|
"iso-did": "^1.6.0",
|
|
69
69
|
"lodash.get": "^4.4.2",
|
|
70
|
-
"@dxos/app-framework": "0.6.8-staging.
|
|
71
|
-
"@dxos/async": "0.6.8-staging.
|
|
72
|
-
"@dxos/client": "0.6.8-staging.
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/echo-schema": "0.6.8-staging.
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/plugin-explorer": "0.6.8-staging.
|
|
82
|
-
"@dxos/plugin-
|
|
83
|
-
"@dxos/plugin-
|
|
84
|
-
"@dxos/plugin-
|
|
85
|
-
"@dxos/plugin-
|
|
86
|
-
"@dxos/plugin-theme": "0.6.8-staging.
|
|
87
|
-
"@dxos/protocols": "0.6.8-staging.
|
|
88
|
-
"@dxos/react-client": "0.6.8-staging.
|
|
89
|
-
"@dxos/rpc": "0.6.8-staging.
|
|
90
|
-
"@dxos/react-ui-editor": "0.6.8-staging.
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
70
|
+
"@dxos/app-framework": "0.6.8-staging.dec6b33",
|
|
71
|
+
"@dxos/async": "0.6.8-staging.dec6b33",
|
|
72
|
+
"@dxos/client": "0.6.8-staging.dec6b33",
|
|
73
|
+
"@dxos/crypto": "0.6.8-staging.dec6b33",
|
|
74
|
+
"@dxos/debug": "0.6.8-staging.dec6b33",
|
|
75
|
+
"@dxos/echo-schema": "0.6.8-staging.dec6b33",
|
|
76
|
+
"@dxos/invariant": "0.6.8-staging.dec6b33",
|
|
77
|
+
"@dxos/client-protocol": "0.6.8-staging.dec6b33",
|
|
78
|
+
"@dxos/keys": "0.6.8-staging.dec6b33",
|
|
79
|
+
"@dxos/log": "0.6.8-staging.dec6b33",
|
|
80
|
+
"@dxos/plugin-client": "0.6.8-staging.dec6b33",
|
|
81
|
+
"@dxos/plugin-explorer": "0.6.8-staging.dec6b33",
|
|
82
|
+
"@dxos/plugin-graph": "0.6.8-staging.dec6b33",
|
|
83
|
+
"@dxos/plugin-markdown": "0.6.8-staging.dec6b33",
|
|
84
|
+
"@dxos/plugin-stack": "0.6.8-staging.dec6b33",
|
|
85
|
+
"@dxos/plugin-space": "0.6.8-staging.dec6b33",
|
|
86
|
+
"@dxos/plugin-theme": "0.6.8-staging.dec6b33",
|
|
87
|
+
"@dxos/protocols": "0.6.8-staging.dec6b33",
|
|
88
|
+
"@dxos/react-client": "0.6.8-staging.dec6b33",
|
|
89
|
+
"@dxos/rpc": "0.6.8-staging.dec6b33",
|
|
90
|
+
"@dxos/react-ui-editor": "0.6.8-staging.dec6b33",
|
|
91
|
+
"@dxos/util": "0.6.8-staging.dec6b33",
|
|
92
|
+
"@dxos/rpc-tunnel": "0.6.8-staging.dec6b33"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -99,20 +99,20 @@
|
|
|
99
99
|
"react": "~18.2.0",
|
|
100
100
|
"react-dom": "~18.2.0",
|
|
101
101
|
"vite": "^5.3.4",
|
|
102
|
-
"@dxos/echo-generator": "0.6.8-staging.
|
|
103
|
-
"@dxos/random": "0.6.8-staging.
|
|
104
|
-
"@dxos/react-ui": "0.6.8-staging.
|
|
105
|
-
"@dxos/react-ui-
|
|
106
|
-
"@dxos/react-ui-
|
|
107
|
-
"@dxos/storybook-utils": "0.6.8-staging.
|
|
102
|
+
"@dxos/echo-generator": "0.6.8-staging.dec6b33",
|
|
103
|
+
"@dxos/random": "0.6.8-staging.dec6b33",
|
|
104
|
+
"@dxos/react-ui": "0.6.8-staging.dec6b33",
|
|
105
|
+
"@dxos/react-ui-mosaic": "0.6.8-staging.dec6b33",
|
|
106
|
+
"@dxos/react-ui-theme": "0.6.8-staging.dec6b33",
|
|
107
|
+
"@dxos/storybook-utils": "0.6.8-staging.dec6b33"
|
|
108
108
|
},
|
|
109
109
|
"optionalDependencies": {
|
|
110
110
|
"@phosphor-icons/react": "^2.1.5",
|
|
111
111
|
"react": "^18.0.0",
|
|
112
112
|
"react-dom": "^18.0.0",
|
|
113
|
-
"@dxos/react-ui
|
|
114
|
-
"@dxos/react-ui-
|
|
115
|
-
"@dxos/react-ui": "0.6.8-staging.
|
|
113
|
+
"@dxos/react-ui": "0.6.8-staging.dec6b33",
|
|
114
|
+
"@dxos/react-ui-theme": "0.6.8-staging.dec6b33",
|
|
115
|
+
"@dxos/react-ui-mosaic": "0.6.8-staging.dec6b33"
|
|
116
116
|
},
|
|
117
117
|
"publishConfig": {
|
|
118
118
|
"access": "public"
|
package/src/ScriptPlugin.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import { loadObjectReferences } from '@dxos/react-client/echo';
|
|
|
16
16
|
import { ScriptEditor } from './components';
|
|
17
17
|
import meta, { SCRIPT_PLUGIN } from './meta';
|
|
18
18
|
import translations from './translations';
|
|
19
|
-
import { ScriptType } from './types';
|
|
19
|
+
import { FunctionType, ScriptType } from './types';
|
|
20
20
|
import { ScriptAction, type ScriptPluginProvides } from './types';
|
|
21
21
|
|
|
22
22
|
export type ScriptPluginProps = {
|
|
@@ -40,7 +40,7 @@ export const ScriptPlugin = ({ containerUrl }: ScriptPluginProps): PluginDefinit
|
|
|
40
40
|
},
|
|
41
41
|
translations,
|
|
42
42
|
echo: {
|
|
43
|
-
schema: [ScriptType],
|
|
43
|
+
schema: [ScriptType, FunctionType],
|
|
44
44
|
},
|
|
45
45
|
graph: {
|
|
46
46
|
builder: (plugins) => {
|
|
@@ -93,10 +93,7 @@ export const ScriptPlugin = ({ containerUrl }: ScriptPluginProps): PluginDefinit
|
|
|
93
93
|
type: ['plugin name', { ns: SCRIPT_PLUGIN }],
|
|
94
94
|
label: ['create stack section label', { ns: SCRIPT_PLUGIN }],
|
|
95
95
|
icon: (props: any) => <Code {...props} />,
|
|
96
|
-
intent: {
|
|
97
|
-
plugin: SCRIPT_PLUGIN,
|
|
98
|
-
action: ScriptAction.CREATE,
|
|
99
|
-
},
|
|
96
|
+
intent: { plugin: SCRIPT_PLUGIN, action: ScriptAction.CREATE },
|
|
100
97
|
},
|
|
101
98
|
],
|
|
102
99
|
},
|
|
@@ -7,7 +7,7 @@ import React, { useCallback, useMemo, useState } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { useClient } from '@dxos/react-client';
|
|
10
|
-
import { createDocAccessor, getMeta, getSpace } from '@dxos/react-client/echo';
|
|
10
|
+
import { create, createDocAccessor, Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
12
12
|
import { useTranslation } from '@dxos/react-ui';
|
|
13
13
|
import { createDataExtensions, listener } from '@dxos/react-ui-editor';
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
uploadWorkerFunction,
|
|
23
23
|
} from '../edge';
|
|
24
24
|
import { SCRIPT_PLUGIN } from '../meta';
|
|
25
|
-
import { type ScriptType } from '../types';
|
|
25
|
+
import { FunctionType, type ScriptType } from '../types';
|
|
26
26
|
|
|
27
27
|
export type ScriptEditorProps = {
|
|
28
28
|
script: ScriptType;
|
|
@@ -34,6 +34,10 @@ export const ScriptEditor = ({ script, role }: ScriptEditorProps) => {
|
|
|
34
34
|
const client = useClient();
|
|
35
35
|
const identity = useIdentity();
|
|
36
36
|
const space = getSpace(script);
|
|
37
|
+
const [fn] = useQuery(
|
|
38
|
+
space,
|
|
39
|
+
Filter.schema(FunctionType, (fn) => fn.source === script),
|
|
40
|
+
);
|
|
37
41
|
const extensions = useMemo(
|
|
38
42
|
() => [
|
|
39
43
|
listener({
|
|
@@ -53,18 +57,18 @@ export const ScriptEditor = ({ script, role }: ScriptEditorProps) => {
|
|
|
53
57
|
[script, script.source, space, identity],
|
|
54
58
|
);
|
|
55
59
|
const initialValue = useMemo(() => script.source?.content, [script.source]);
|
|
56
|
-
const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(
|
|
60
|
+
const existingFunctionUrl = fn && getUserFunctionUrlInMetadata(getMeta(fn));
|
|
57
61
|
const [error, setError] = useState<string>();
|
|
58
62
|
|
|
59
63
|
const handleBindingChange = useCallback(
|
|
60
64
|
(binding: string) => {
|
|
61
|
-
|
|
65
|
+
fn.binding = binding;
|
|
62
66
|
},
|
|
63
|
-
[
|
|
67
|
+
[fn],
|
|
64
68
|
);
|
|
65
69
|
|
|
66
70
|
const handleDeploy = useCallback(async () => {
|
|
67
|
-
if (!script.source || !identity) {
|
|
71
|
+
if (!script.source || !identity || !space) {
|
|
68
72
|
return;
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -79,33 +83,45 @@ export const ScriptEditor = ({ script, role }: ScriptEditorProps) => {
|
|
|
79
83
|
halo: client.halo,
|
|
80
84
|
ownerDid,
|
|
81
85
|
functionId: existingFunctionId,
|
|
82
|
-
name: script.name,
|
|
83
86
|
source: script.source.content,
|
|
84
87
|
});
|
|
85
|
-
if (result !== 'success' || functionId === undefined) {
|
|
88
|
+
if (result !== 'success' || functionId === undefined || functionVersionNumber === undefined) {
|
|
86
89
|
throw new Error(errorMessage);
|
|
87
90
|
}
|
|
88
91
|
log.info('function uploaded', { functionId, functionVersionNumber });
|
|
89
|
-
|
|
92
|
+
if (fn) {
|
|
93
|
+
fn.version = functionVersionNumber;
|
|
94
|
+
}
|
|
95
|
+
const deployedFunction =
|
|
96
|
+
fn ?? space.db.add(create(FunctionType, { version: functionVersionNumber, source: script }));
|
|
97
|
+
const meta = getMeta(deployedFunction);
|
|
90
98
|
setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);
|
|
91
99
|
script.changed = false;
|
|
92
100
|
} catch (err: any) {
|
|
93
101
|
log.catch(err);
|
|
94
102
|
setError(t('upload failed label'));
|
|
95
103
|
}
|
|
96
|
-
}, [existingFunctionUrl, script, script.name, script.source]);
|
|
104
|
+
}, [fn, existingFunctionUrl, script, script.name, script.source]);
|
|
97
105
|
|
|
98
106
|
return (
|
|
99
|
-
<div
|
|
107
|
+
<div
|
|
108
|
+
role='none'
|
|
109
|
+
className={mx(role === 'article' && 'row-span-2', 'flex flex-col is-full bs-full overflow-hidden')}
|
|
110
|
+
>
|
|
100
111
|
<Toolbar
|
|
101
|
-
binding={
|
|
112
|
+
binding={fn?.binding ?? ''}
|
|
102
113
|
onBindingChange={handleBindingChange}
|
|
103
114
|
deployed={Boolean(existingFunctionUrl) && !script.changed}
|
|
104
115
|
onDeploy={handleDeploy}
|
|
105
116
|
functionUrl={existingFunctionUrl}
|
|
106
117
|
error={error}
|
|
107
118
|
/>
|
|
108
|
-
<TypescriptEditor
|
|
119
|
+
<TypescriptEditor
|
|
120
|
+
id={script.id}
|
|
121
|
+
initialValue={initialValue}
|
|
122
|
+
extensions={extensions}
|
|
123
|
+
className='flex is-full bs-full overflow-hidden'
|
|
124
|
+
/>
|
|
109
125
|
</div>
|
|
110
126
|
);
|
|
111
127
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Check, Checks, CircleNotch, Link, PencilSimple, UploadSimple, WarningCircle, X } from '@phosphor-icons/react';
|
|
6
|
-
import React, { useRef, useState } from 'react';
|
|
6
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Button,
|
|
@@ -27,12 +27,26 @@ export type ToolbarProps = {
|
|
|
27
27
|
error?: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const Toolbar = ({
|
|
30
|
+
export const Toolbar = ({
|
|
31
|
+
binding: _binding,
|
|
32
|
+
onBindingChange,
|
|
33
|
+
deployed,
|
|
34
|
+
onDeploy,
|
|
35
|
+
functionUrl,
|
|
36
|
+
error,
|
|
37
|
+
}: ToolbarProps) => {
|
|
31
38
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
32
39
|
const [pending, setPending] = useState(false);
|
|
33
40
|
const [editing, setEditing] = useState(false);
|
|
41
|
+
const [binding, setBinding] = useState(_binding);
|
|
34
42
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
35
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!editing && _binding !== binding) {
|
|
46
|
+
setBinding(_binding);
|
|
47
|
+
}
|
|
48
|
+
}, [_binding]);
|
|
49
|
+
|
|
36
50
|
const handleEdit = () => {
|
|
37
51
|
setEditing(true);
|
|
38
52
|
inputRef.current?.focus();
|
|
@@ -40,7 +54,7 @@ export const Toolbar = ({ binding, onBindingChange, deployed, onDeploy, function
|
|
|
40
54
|
|
|
41
55
|
const handleSave = () => {
|
|
42
56
|
setEditing(false);
|
|
43
|
-
onBindingChange(
|
|
57
|
+
onBindingChange(binding);
|
|
44
58
|
};
|
|
45
59
|
|
|
46
60
|
const handleCancel = () => {
|
|
@@ -71,7 +85,13 @@ export const Toolbar = ({ binding, onBindingChange, deployed, onDeploy, function
|
|
|
71
85
|
{/* TODO(wittjosiah): Binding input shouldn't be in the toolbar. */}
|
|
72
86
|
<Input.Root>
|
|
73
87
|
<Input.Label>{t('binding label')}</Input.Label>
|
|
74
|
-
<Input.TextInput
|
|
88
|
+
<Input.TextInput
|
|
89
|
+
ref={inputRef}
|
|
90
|
+
classNames='!is-auto'
|
|
91
|
+
disabled={!editing}
|
|
92
|
+
value={binding}
|
|
93
|
+
onChange={(event) => setBinding(event.target.value.toUpperCase())}
|
|
94
|
+
/>
|
|
75
95
|
{editing ? (
|
|
76
96
|
<>
|
|
77
97
|
<Button variant='ghost' onClick={handleCancel}>
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
createBasicExtensions,
|
|
14
14
|
createThemeExtensions,
|
|
15
15
|
editorContent,
|
|
16
|
+
editorGutter,
|
|
17
|
+
editorMonospace,
|
|
16
18
|
useTextEditor,
|
|
17
19
|
type UseTextEditorProps,
|
|
18
20
|
} from '@dxos/react-ui-editor';
|
|
@@ -34,7 +36,6 @@ export const TypescriptEditor = ({
|
|
|
34
36
|
scrollPastEnd,
|
|
35
37
|
}: TypescriptEditorProps) => {
|
|
36
38
|
const { themeMode } = useThemeContext();
|
|
37
|
-
|
|
38
39
|
const { parentRef, focusAttributes } = useTextEditor(
|
|
39
40
|
() => ({
|
|
40
41
|
id,
|
|
@@ -51,6 +52,8 @@ export const TypescriptEditor = ({
|
|
|
51
52
|
content: { className: editorContent },
|
|
52
53
|
},
|
|
53
54
|
}),
|
|
55
|
+
editorGutter,
|
|
56
|
+
editorMonospace,
|
|
54
57
|
javascript({ typescript: true }),
|
|
55
58
|
autocomplete(),
|
|
56
59
|
].filter(nonNullable),
|
package/src/edge/functions.ts
CHANGED
|
@@ -37,8 +37,7 @@ export type UploadWorkerProps = {
|
|
|
37
37
|
credentialLoadTimeout?: number; // ms to wait for credentials to load
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const defaultUserFunctionsBaseUrl = 'http://localhost:8600';
|
|
41
|
-
// const userFunctionsBaseUrl = 'https://functions-nftest.dxos.workers.dev';
|
|
40
|
+
const defaultUserFunctionsBaseUrl = 'https://functions-staging.dxos.workers.dev'; // 'http://localhost:8600';
|
|
42
41
|
|
|
43
42
|
const getBaseUrl = (config: Config) => {
|
|
44
43
|
return config.get('runtime.app.env.DX_USERFUNCTIONS_BASE_URL') || defaultUserFunctionsBaseUrl;
|
package/src/types/script.ts
CHANGED
|
@@ -8,9 +8,14 @@ import { TextType } from '@dxos/plugin-markdown/types';
|
|
|
8
8
|
export class ScriptType extends TypedObject({ typename: 'dxos.org/type/Script', version: '0.1.0' })({
|
|
9
9
|
name: S.optional(S.String),
|
|
10
10
|
source: ref(TextType),
|
|
11
|
+
// Whether source has changed since last deploy.
|
|
12
|
+
changed: S.optional(S.Boolean),
|
|
13
|
+
}) {}
|
|
11
14
|
|
|
15
|
+
export class FunctionType extends TypedObject({ typename: 'dxos.org/type/Function', version: '0.1.0' })({
|
|
16
|
+
version: S.Number,
|
|
12
17
|
// Local binding to a function name.
|
|
13
18
|
binding: S.optional(S.String),
|
|
14
|
-
//
|
|
15
|
-
|
|
19
|
+
// Reference to a source script if it exists within ECHO.
|
|
20
|
+
source: S.optional(ref(ScriptType)),
|
|
16
21
|
}) {}
|
package/src/types/types.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
TranslationsProvides,
|
|
11
11
|
} from '@dxos/app-framework';
|
|
12
12
|
import { type SchemaProvides } from '@dxos/plugin-client';
|
|
13
|
-
import type
|
|
13
|
+
import { type StackProvides } from '@dxos/plugin-stack';
|
|
14
14
|
|
|
15
15
|
import { SCRIPT_PLUGIN } from '../meta';
|
|
16
16
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ScriptEditor.tsx", "../../../src/components/Toolbar.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { createDocAccessor, getMeta, getSpace } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { createDataExtensions, listener } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { Toolbar } from './Toolbar';\nimport { TypescriptEditor } from './TypescriptEditor';\nimport {\n getUserFunctionUrlInMetadata,\n publicKeyToDid,\n setUserFunctionUrlInMetadata,\n uploadWorkerFunction,\n} from '../edge';\nimport { SCRIPT_PLUGIN } from '../meta';\nimport { type ScriptType } from '../types';\n\nexport type ScriptEditorProps = {\n script: ScriptType;\n role?: string;\n};\n\nexport const ScriptEditor = ({ script, role }: ScriptEditorProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const identity = useIdentity();\n const space = getSpace(script);\n const extensions = useMemo(\n () => [\n listener({\n onChange: (text) => {\n if (script.source && script.source?.content !== text) {\n script.changed = true;\n }\n },\n }),\n createDataExtensions({\n id: script.id,\n text: script.source && createDocAccessor(script.source, ['content']),\n space,\n identity,\n }),\n ],\n [script, script.source, space, identity],\n );\n const initialValue = useMemo(() => script.source?.content, [script.source]);\n const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(script));\n const [error, setError] = useState<string>();\n\n const handleBindingChange = useCallback(\n (binding: string) => {\n script.binding = binding;\n },\n [script],\n );\n\n const handleDeploy = useCallback(async () => {\n if (!script.source || !identity) {\n return;\n }\n\n setError(undefined);\n\n try {\n const existingFunctionId = existingFunctionUrl?.split('/').at(-1);\n const ownerDid = (existingFunctionUrl?.split('/').at(-2) as DID) ?? publicKeyToDid(identity.identityKey);\n\n const { result, functionId, functionVersionNumber, errorMessage } = await uploadWorkerFunction({\n clientConfig: client.config,\n halo: client.halo,\n ownerDid,\n functionId: existingFunctionId,\n name: script.name,\n source: script.source.content,\n });\n if (result !== 'success' || functionId === undefined) {\n throw new Error(errorMessage);\n }\n log.info('function uploaded', { functionId, functionVersionNumber });\n const meta = getMeta(script);\n setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);\n script.changed = false;\n } catch (err: any) {\n log.catch(err);\n setError(t('upload failed label'));\n }\n }, [existingFunctionUrl, script, script.name, script.source]);\n\n return (\n <div role='none' className={mx(role === 'article' && 'row-span-2', 'is-full pli-2')}>\n <Toolbar\n binding={script.binding ?? ''}\n onBindingChange={handleBindingChange}\n deployed={Boolean(existingFunctionUrl) && !script.changed}\n onDeploy={handleDeploy}\n functionUrl={existingFunctionUrl}\n error={error}\n />\n <TypescriptEditor id={script.id} initialValue={initialValue} extensions={extensions} />\n </div>\n );\n};\n\nexport default ScriptEditor;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Check, Checks, CircleNotch, Link, PencilSimple, UploadSimple, WarningCircle, X } from '@phosphor-icons/react';\nimport React, { useRef, useState } from 'react';\n\nimport {\n Button,\n DensityProvider,\n ElevationProvider,\n Input,\n Toolbar as NaturalToolbar,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\nimport { getSize, mx } from '@dxos/react-ui-theme';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport type ToolbarProps = {\n binding: string;\n onBindingChange: (binding: string) => void;\n deployed?: boolean;\n onDeploy?: () => Promise<void>;\n functionUrl?: string;\n error?: string;\n};\n\nexport const Toolbar = ({ binding, onBindingChange, deployed, onDeploy, functionUrl, error }: ToolbarProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const [pending, setPending] = useState(false);\n const [editing, setEditing] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleEdit = () => {\n setEditing(true);\n inputRef.current?.focus();\n };\n\n const handleSave = () => {\n setEditing(false);\n onBindingChange(inputRef.current?.value || '');\n };\n\n const handleCancel = () => {\n setEditing(false);\n };\n\n const handleCopyLink = async () => {\n if (!functionUrl) {\n return;\n }\n\n await navigator.clipboard.writeText(functionUrl);\n };\n\n const handleDeploy = async () => {\n setPending(true);\n await onDeploy?.();\n setPending(false);\n };\n\n return (\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root\n classNames='p-1 is-full shrink-0 overflow-x-auto overflow-y-hidden'\n style={{ contain: 'layout' }}\n >\n {/* TODO(wittjosiah): Binding input shouldn't be in the toolbar. */}\n <Input.Root>\n <Input.Label>{t('binding label')}</Input.Label>\n <Input.TextInput ref={inputRef} defaultValue={binding} disabled={!editing} classNames='!is-auto' />\n {editing ? (\n <>\n <Button variant='ghost' onClick={handleCancel}>\n <X className={getSize(4)} />\n </Button>\n <Button variant='ghost' onClick={handleSave}>\n <Check className={getSize(4)} />\n </Button>\n </>\n ) : (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button variant='ghost' onClick={handleEdit}>\n <PencilSimple className={getSize(4)} />\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('edit binding label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n </Input.Root>\n <div role='separator' className='grow' />\n {/* TODO(wittjosiah): Better treatment for status indicators in toolbar? */}\n {error ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <WarningCircle className={getSize(4)} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {error}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : deployed ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Checks className={getSize(4)} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('deployed label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : null}\n {functionUrl && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleCopyLink}>\n <Link className={getSize(4)} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('copy link label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleDeploy} disabled={pending}>\n {pending ? (\n <CircleNotch className={mx('spinner', getSize(4))} />\n ) : (\n <UploadSimple className={getSize(4)} />\n )}\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {pending ? t('pending label') : t('deploy label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAKA,OAAOA,UAASC,aAAaC,SAASC,YAAAA,iBAAgB;AAEtD,SAASC,WAAW;AACpB,SAASC,iBAAiB;AAC1B,SAASC,mBAAmBC,SAASC,gBAAgB;AACrD,SAASC,mBAAmB;AAC5B,SAASC,kBAAAA,uBAAsB;AAC/B,SAASC,sBAAsBC,gBAAgB;AAC/C,SAASC,MAAAA,WAAU;;;ACTnB,SAASC,OAAOC,QAAQC,aAAaC,MAAMC,cAAcC,cAAcC,eAAeC,SAAS;AAC/F,OAAOC,SAASC,QAAQC,gBAAgB;AAExC,SACEC,QACAC,iBACAC,mBACAC,OACAC,WAAWC,gBACXC,SACAC,sBACK;AACP,SAASC,SAASC,UAAU;AAarB,IAAMC,UAAU,CAAC,EAAEC,SAASC,iBAAiBC,UAAUC,UAAUC,aAAa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3B8B,iBAAiBhC;IACjBiC,UAAUC,QAAQxC,mBAAAA,KAAwB,CAACvB,OAAOkB;IAClD8C,UAAUhC;IACViC,aAAa1C;IACbG;MAEF,gBAAA8B,OAAA,cAACU,kBAAAA;IAAiB9C,IAAIpB,OAAOoB;IAAIE;IAA4BX;;AAGnE;AAEA,IAAA,uBAAeZ;",
|
|
6
|
-
"names": ["React", "useCallback", "useMemo", "useState", "log", "useClient", "createDocAccessor", "getMeta", "getSpace", "useIdentity", "useTranslation", "createDataExtensions", "listener", "mx", "Check", "Checks", "CircleNotch", "Link", "PencilSimple", "UploadSimple", "WarningCircle", "X", "React", "useRef", "useState", "Button", "DensityProvider", "ElevationProvider", "Input", "Toolbar", "NaturalToolbar", "Tooltip", "useTranslation", "getSize", "mx", "Toolbar", "binding", "onBindingChange", "deployed", "onDeploy", "functionUrl", "error", "t", "useTranslation", "SCRIPT_PLUGIN", "pending", "setPending", "useState", "editing", "setEditing", "inputRef", "useRef", "handleEdit", "current", "focus", "handleSave", "value", "handleCancel", "handleCopyLink", "navigator", "clipboard", "writeText", "handleDeploy", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "classNames", "style", "contain", "Input", "Label", "TextInput", "ref", "defaultValue", "disabled", "Button", "variant", "onClick", "X", "className", "getSize", "Check", "Tooltip", "Trigger", "asChild", "PencilSimple", "Portal", "Content", "Arrow", "div", "role", "WarningCircle", "Checks", "Link", "CircleNotch", "mx", "UploadSimple", "ScriptEditor", "script", "role", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "identity", "useIdentity", "space", "getSpace", "extensions", "useMemo", "listener", "onChange", "text", "source", "content", "changed", "createDataExtensions", "id", "createDocAccessor", "initialValue", "existingFunctionUrl", "getUserFunctionUrlInMetadata", "getMeta", "error", "setError", "useState", "handleBindingChange", "useCallback", "binding", "handleDeploy", "undefined", "existingFunctionId", "split", "at", "ownerDid", "publicKeyToDid", "identityKey", "result", "functionId", "functionVersionNumber", "errorMessage", "uploadWorkerFunction", "clientConfig", "config", "halo", "name", "Error", "log", "info", "meta", "setUserFunctionUrlInMetadata", "err", "catch", "React", "div", "className", "mx", "Toolbar", "onBindingChange", "deployed", "Boolean", "onDeploy", "functionUrl", "TypescriptEditor"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/TypescriptEditor.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { javascript } from '@codemirror/lang-javascript';\nimport { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport React from 'react';\n\nimport { useThemeContext } from '@dxos/react-ui';\nimport {\n autocomplete,\n createBasicExtensions,\n createThemeExtensions,\n editorContent,\n useTextEditor,\n type UseTextEditorProps,\n} from '@dxos/react-ui-editor';\nimport { nonNullable } from '@dxos/util';\n\nexport type TypescriptEditorProps = {\n id: string;\n className?: string;\n scrollPastEnd?: boolean;\n} & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;\n\nexport const TypescriptEditor = ({\n id,\n extensions,\n initialValue,\n scrollTo,\n selection,\n className,\n scrollPastEnd,\n}: TypescriptEditorProps) => {\n const { themeMode } = useThemeContext();\n\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n initialValue,\n extensions: [\n extensions,\n // TODO(wittjosiah): Highlight active line doesn't work.\n createBasicExtensions({ highlightActiveLine: true, indentWithTab: true, lineNumbers: true, scrollPastEnd }),\n // TODO(wittjosiah): Factor out syntax highlighting to theme extensions.\n themeMode === 'dark' ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),\n createThemeExtensions({\n themeMode,\n slots: {\n content: { className: editorContent },\n },\n }),\n javascript({ typescript: true }),\n autocomplete(),\n ].filter(nonNullable),\n selection,\n scrollTo,\n }),\n [id, initialValue, extensions, themeMode, selection, scrollTo],\n );\n\n return <div ref={parentRef} className={className} {...focusAttributes} />;\n};\n\nexport default TypescriptEditor;\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,kBAAkB;AAC3B,SAASC,uBAAuBC,0BAA0B;AAC1D,SAASC,6BAA6B;AACtC,OAAOC,WAAW;AAElB,SAASC,uBAAuB;AAChC,SACEC,cACAC,uBACAC,uBACAC,eACAC,qBAEK;AACP,SAASC,mBAAmB;AAQrB,IAAMC,mBAAmB,CAAC,EAC/BC,IACAC,YACAC,cACAC,UACAC,WACAC,WACAC,cAAa,MACS;AACtB,QAAM,EAAEC,UAAS,IAAKC,gBAAAA;AAEtB,QAAM,EAAEC,WAAWC,gBAAe,IAAKC,cACrC,OAAO;IACLX;IACAE;IACAD,YAAY;MACVA;;MAEAW,sBAAsB;QAAEC,qBAAqB;QAAMC,eAAe;QAAMC,aAAa;QAAMT;MAAc,CAAA;;MAEzGC,cAAc,SAASS,mBAAmBC,qBAAAA,IAAyBD,mBAAmBE,qBAAAA;MACtFC,sBAAsB;QACpBZ;QACAa,OAAO;UACLC,SAAS;YAAEhB,WAAWiB;UAAc;QACtC;MACF,CAAA;MACAC,WAAW;QAAEC,YAAY;MAAK,CAAA;MAC9BC,aAAAA;MACAC,OAAOC,WAAAA;IACTvB;IACAD;EACF,IACA;IAACH;IAAIE;IAAcD;IAAYM;IAAWH;IAAWD;GAAS;AAGhE,SAAO,sBAAA,cAACyB,OAAAA;IAAIC,KAAKpB;IAAWJ;IAAuB,GAAGK;;AACxD;AAEA,IAAA,2BAAeX;",
|
|
6
|
-
"names": ["javascript", "defaultHighlightStyle", "syntaxHighlighting", "oneDarkHighlightStyle", "React", "useThemeContext", "autocomplete", "createBasicExtensions", "createThemeExtensions", "editorContent", "useTextEditor", "nonNullable", "TypescriptEditor", "id", "extensions", "initialValue", "scrollTo", "selection", "className", "scrollPastEnd", "themeMode", "useThemeContext", "parentRef", "focusAttributes", "useTextEditor", "createBasicExtensions", "highlightActiveLine", "indentWithTab", "lineNumbers", "syntaxHighlighting", "oneDarkHighlightStyle", "defaultHighlightStyle", "createThemeExtensions", "slots", "content", "editorContent", "javascript", "typescript", "autocomplete", "filter", "nonNullable", "div", "ref"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/script.ts", "../../../src/types/types.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/plugin-markdown/types';\n\nexport class ScriptType extends TypedObject({ typename: 'dxos.org/type/Script', version: '0.1.0' })({\n name: S.optional(S.String),\n source: ref(TextType),\n\n // Local binding to a function name.\n binding: S.optional(S.String),\n // Whether source has changed since last deploy.\n changed: S.optional(S.Boolean),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport type { StackProvides } from '@dxos/plugin-stack';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport enum ScriptAction {\n CREATE = `${SCRIPT_PLUGIN}/create`,\n}\n\nexport type ScriptPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n StackProvides;\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,KAAKC,GAAGC,mBAAmB;AACpC,SAASC,gBAAgB;AAElB,IAAMC,aAAN,cAAyBC,YAAY;EAAEC,UAAU;EAAwBC,SAAS;AAAQ,CAAA,EAAG;EAClGC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,QAAQC,IAAIC,QAAAA;;EAGZC,SAASN,EAAEC,SAASD,EAAEE,MAAM;;EAE5BK,SAASP,EAAEC,SAASD,EAAEQ,OAAO;AAC/B,CAAA,EAAA;AAAI;;;;UCCQC,eAAAA;0CACD,GAAGC,aAAAA,SAAsB,IAAA;GADxBD,iBAAAA,eAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["ref", "S", "TypedObject", "TextType", "ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "source", "ref", "TextType", "binding", "changed", "Boolean", "ScriptAction", "SCRIPT_PLUGIN"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ScriptEditor.tsx", "../../../src/components/Toolbar.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { createDocAccessor, getMeta, getSpace } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { createDataExtensions, listener } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { Toolbar } from './Toolbar';\nimport { TypescriptEditor } from './TypescriptEditor';\nimport {\n getUserFunctionUrlInMetadata,\n publicKeyToDid,\n setUserFunctionUrlInMetadata,\n uploadWorkerFunction,\n} from '../edge';\nimport { SCRIPT_PLUGIN } from '../meta';\nimport { type ScriptType } from '../types';\n\nexport type ScriptEditorProps = {\n script: ScriptType;\n role?: string;\n};\n\nexport const ScriptEditor = ({ script, role }: ScriptEditorProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const identity = useIdentity();\n const space = getSpace(script);\n const extensions = useMemo(\n () => [\n listener({\n onChange: (text) => {\n if (script.source && script.source?.content !== text) {\n script.changed = true;\n }\n },\n }),\n createDataExtensions({\n id: script.id,\n text: script.source && createDocAccessor(script.source, ['content']),\n space,\n identity,\n }),\n ],\n [script, script.source, space, identity],\n );\n const initialValue = useMemo(() => script.source?.content, [script.source]);\n const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(script));\n const [error, setError] = useState<string>();\n\n const handleBindingChange = useCallback(\n (binding: string) => {\n script.binding = binding;\n },\n [script],\n );\n\n const handleDeploy = useCallback(async () => {\n if (!script.source || !identity) {\n return;\n }\n\n setError(undefined);\n\n try {\n const existingFunctionId = existingFunctionUrl?.split('/').at(-1);\n const ownerDid = (existingFunctionUrl?.split('/').at(-2) as DID) ?? publicKeyToDid(identity.identityKey);\n\n const { result, functionId, functionVersionNumber, errorMessage } = await uploadWorkerFunction({\n clientConfig: client.config,\n halo: client.halo,\n ownerDid,\n functionId: existingFunctionId,\n name: script.name,\n source: script.source.content,\n });\n if (result !== 'success' || functionId === undefined) {\n throw new Error(errorMessage);\n }\n log.info('function uploaded', { functionId, functionVersionNumber });\n const meta = getMeta(script);\n setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);\n script.changed = false;\n } catch (err: any) {\n log.catch(err);\n setError(t('upload failed label'));\n }\n }, [existingFunctionUrl, script, script.name, script.source]);\n\n return (\n <div role='none' className={mx(role === 'article' && 'row-span-2', 'is-full pli-2')}>\n <Toolbar\n binding={script.binding ?? ''}\n onBindingChange={handleBindingChange}\n deployed={Boolean(existingFunctionUrl) && !script.changed}\n onDeploy={handleDeploy}\n functionUrl={existingFunctionUrl}\n error={error}\n />\n <TypescriptEditor id={script.id} initialValue={initialValue} extensions={extensions} />\n </div>\n );\n};\n\nexport default ScriptEditor;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Check, Checks, CircleNotch, Link, PencilSimple, UploadSimple, WarningCircle, X } from '@phosphor-icons/react';\nimport React, { useRef, useState } from 'react';\n\nimport {\n Button,\n DensityProvider,\n ElevationProvider,\n Input,\n Toolbar as NaturalToolbar,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\nimport { getSize, mx } from '@dxos/react-ui-theme';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport type ToolbarProps = {\n binding: string;\n onBindingChange: (binding: string) => void;\n deployed?: boolean;\n onDeploy?: () => Promise<void>;\n functionUrl?: string;\n error?: string;\n};\n\nexport const Toolbar = ({ binding, onBindingChange, deployed, onDeploy, functionUrl, error }: ToolbarProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const [pending, setPending] = useState(false);\n const [editing, setEditing] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleEdit = () => {\n setEditing(true);\n inputRef.current?.focus();\n };\n\n const handleSave = () => {\n setEditing(false);\n onBindingChange(inputRef.current?.value || '');\n };\n\n const handleCancel = () => {\n setEditing(false);\n };\n\n const handleCopyLink = async () => {\n if (!functionUrl) {\n return;\n }\n\n await navigator.clipboard.writeText(functionUrl);\n };\n\n const handleDeploy = async () => {\n setPending(true);\n await onDeploy?.();\n setPending(false);\n };\n\n return (\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root\n classNames='p-1 is-full shrink-0 overflow-x-auto overflow-y-hidden'\n style={{ contain: 'layout' }}\n >\n {/* TODO(wittjosiah): Binding input shouldn't be in the toolbar. */}\n <Input.Root>\n <Input.Label>{t('binding label')}</Input.Label>\n <Input.TextInput ref={inputRef} defaultValue={binding} disabled={!editing} classNames='!is-auto' />\n {editing ? (\n <>\n <Button variant='ghost' onClick={handleCancel}>\n <X className={getSize(4)} />\n </Button>\n <Button variant='ghost' onClick={handleSave}>\n <Check className={getSize(4)} />\n </Button>\n </>\n ) : (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button variant='ghost' onClick={handleEdit}>\n <PencilSimple className={getSize(4)} />\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('edit binding label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n </Input.Root>\n <div role='separator' className='grow' />\n {/* TODO(wittjosiah): Better treatment for status indicators in toolbar? */}\n {error ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <WarningCircle className={getSize(4)} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {error}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : deployed ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Checks className={getSize(4)} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('deployed label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : null}\n {functionUrl && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleCopyLink}>\n <Link className={getSize(4)} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('copy link label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleDeploy} disabled={pending}>\n {pending ? (\n <CircleNotch className={mx('spinner', getSize(4))} />\n ) : (\n <UploadSimple className={getSize(4)} />\n )}\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {pending ? t('pending label') : t('deploy label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,mBAAsD;AAEtD,iBAAoB;AACpB,0BAA0B;AAC1B,kBAAqD;AACrD,kBAA4B;AAC5B,sBAA+B;AAC/B,6BAA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Zc,MAAMxC,OAAOwC;QACb5B,QAAQZ,OAAOY,OAAOC;MACxB,CAAA;AACA,UAAImB,WAAW,aAAaC,eAAeR,QAAW;AACpD,cAAM,IAAIgB,MAAMN,YAAAA;MAClB;AACAO,qBAAIC,KAAK,qBAAqB;QAAEV;QAAYC;MAAsB,GAAA;;;;;;AAClE,YAAMU,WAAOvB,qBAAQrB,MAAAA;AACrB6C,8DAA6BD,MAAM,IAAIf,QAAAA,IAAYI,UAAAA,EAAY;AAC/DjC,aAAOc,UAAU;IACnB,SAASgC,KAAU;AACjBJ,qBAAIK,MAAMD,KAAAA,QAAAA;;;;;;AACVxB,eAASlF,EAAE,qBAAA,CAAA;IACb;EACF,GAAG;IAAC+E;IAAqBnB;IAAQA,OAAOwC;IAAMxC,OAAOY;GAAO;AAE5D,SACEnD,6BAAAA,QAAA,cAAC8B,OAAAA;IAAIC,MAAK;IAAOX,eAAWgB,sBAAAA,IAAGL,SAAS,aAAa,cAAc,eAAA;KACjE/B,6BAAAA,QAAA,cAAC5B,SAAAA;IACCC,SAASkE,OAAOlE,WAAW;IAC3BC,iBAAiBwF;IACjBvF,UAAUgH,QAAQ7B,mBAAAA,KAAwB,CAACnB,OAAOc;IAClD7E,UAAUuB;IACVtB,aAAaiF;IACbhF;MAEFsB,6BAAAA,QAAA,cAACwF,wCAAAA;IAAiBjC,IAAIhB,OAAOgB;IAAIE;IAA4BX;;AAGnE;AAEA,IAAA,uBAAeR;",
|
|
6
|
-
"names": ["import_react", "import_react_ui", "import_react_ui_theme", "Toolbar", "binding", "onBindingChange", "deployed", "onDeploy", "functionUrl", "error", "t", "useTranslation", "SCRIPT_PLUGIN", "pending", "setPending", "useState", "editing", "setEditing", "inputRef", "useRef", "handleEdit", "current", "focus", "handleSave", "value", "handleCancel", "handleCopyLink", "navigator", "clipboard", "writeText", "handleDeploy", "React", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "classNames", "style", "contain", "Input", "Label", "TextInput", "ref", "defaultValue", "disabled", "Button", "variant", "onClick", "X", "className", "getSize", "Check", "Tooltip", "Trigger", "asChild", "PencilSimple", "Portal", "Content", "Arrow", "div", "role", "WarningCircle", "Checks", "Link", "CircleNotch", "mx", "UploadSimple", "ScriptEditor", "script", "client", "useClient", "identity", "useIdentity", "space", "getSpace", "extensions", "useMemo", "listener", "onChange", "text", "source", "content", "changed", "createDataExtensions", "id", "createDocAccessor", "initialValue", "existingFunctionUrl", "getUserFunctionUrlInMetadata", "getMeta", "setError", "handleBindingChange", "useCallback", "undefined", "existingFunctionId", "split", "at", "ownerDid", "publicKeyToDid", "identityKey", "result", "functionId", "functionVersionNumber", "errorMessage", "uploadWorkerFunction", "clientConfig", "config", "halo", "name", "Error", "log", "info", "meta", "setUserFunctionUrlInMetadata", "err", "catch", "Boolean", "TypescriptEditor"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/script.ts", "../../../src/types/types.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/plugin-markdown/types';\n\nexport class ScriptType extends TypedObject({ typename: 'dxos.org/type/Script', version: '0.1.0' })({\n name: S.optional(S.String),\n source: ref(TextType),\n\n // Local binding to a function name.\n binding: S.optional(S.String),\n // Whether source has changed since last deploy.\n changed: S.optional(S.Boolean),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport type { StackProvides } from '@dxos/plugin-stack';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport enum ScriptAction {\n CREATE = `${SCRIPT_PLUGIN}/create`,\n}\n\nexport type ScriptPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n StackProvides;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAoC;AACpC,mBAAyB;AAElB,IAAMA,aAAN,kBAAyBC,gCAAY;EAAEC,UAAU;EAAwBC,SAAS;AAAQ,CAAA,EAAG;EAClGC,MAAMC,qBAAEC,SAASD,qBAAEE,MAAM;EACzBC,YAAQC,wBAAIC,qBAAAA;;EAGZC,SAASN,qBAAEC,SAASD,qBAAEE,MAAM;;EAE5BK,SAASP,qBAAEC,SAASD,qBAAEQ,OAAO;AAC/B,CAAA,EAAA;AAAI;;UCCQC,eAAAA;0CACD,GAAGC,mCAAAA,SAAsB,IAAA;GADxBD,iBAAAA,eAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "source", "ref", "TextType", "binding", "changed", "Boolean", "ScriptAction", "SCRIPT_PLUGIN"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/TypescriptEditor.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { javascript } from '@codemirror/lang-javascript';\nimport { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport React from 'react';\n\nimport { useThemeContext } from '@dxos/react-ui';\nimport {\n autocomplete,\n createBasicExtensions,\n createThemeExtensions,\n editorContent,\n useTextEditor,\n type UseTextEditorProps,\n} from '@dxos/react-ui-editor';\nimport { nonNullable } from '@dxos/util';\n\nexport type TypescriptEditorProps = {\n id: string;\n className?: string;\n scrollPastEnd?: boolean;\n} & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;\n\nexport const TypescriptEditor = ({\n id,\n extensions,\n initialValue,\n scrollTo,\n selection,\n className,\n scrollPastEnd,\n}: TypescriptEditorProps) => {\n const { themeMode } = useThemeContext();\n\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n initialValue,\n extensions: [\n extensions,\n // TODO(wittjosiah): Highlight active line doesn't work.\n createBasicExtensions({ highlightActiveLine: true, indentWithTab: true, lineNumbers: true, scrollPastEnd }),\n // TODO(wittjosiah): Factor out syntax highlighting to theme extensions.\n themeMode === 'dark' ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),\n createThemeExtensions({\n themeMode,\n slots: {\n content: { className: editorContent },\n },\n }),\n javascript({ typescript: true }),\n autocomplete(),\n ].filter(nonNullable),\n selection,\n scrollTo,\n }),\n [id, initialValue, extensions, themeMode, selection, scrollTo],\n );\n\n return <div ref={parentRef} className={className} {...focusAttributes} />;\n};\n\nexport default TypescriptEditor;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,6BAA2B;AAC3B,sBAA0D;AAC1D,4BAAsC;AACtC,mBAAkB;AAElB,sBAAgC;AAChC,6BAOO;AACP,kBAA4B;AAQrB,IAAMA,mBAAmB,CAAC,EAC/BC,IACAC,YACAC,cACAC,UACAC,WACAC,WACAC,cAAa,MACS;AACtB,QAAM,EAAEC,UAAS,QAAKC,iCAAAA;AAEtB,QAAM,EAAEC,WAAWC,gBAAe,QAAKC,sCACrC,OAAO;IACLX;IACAE;IACAD,YAAY;MACVA;;UAEAW,8CAAsB;QAAEC,qBAAqB;QAAMC,eAAe;QAAMC,aAAa;QAAMT;MAAc,CAAA;;MAEzGC,cAAc,aAASS,oCAAmBC,2CAAAA,QAAyBD,oCAAmBE,qCAAAA;UACtFC,8CAAsB;QACpBZ;QACAa,OAAO;UACLC,SAAS;YAAEhB,WAAWiB;UAAc;QACtC;MACF,CAAA;UACAC,mCAAW;QAAEC,YAAY;MAAK,CAAA;UAC9BC,qCAAAA;MACAC,OAAOC,uBAAAA;IACTvB;IACAD;EACF,IACA;IAACH;IAAIE;IAAcD;IAAYM;IAAWH;IAAWD;GAAS;AAGhE,SAAO,6BAAAyB,QAAA,cAACC,OAAAA;IAAIC,KAAKrB;IAAWJ;IAAuB,GAAGK;;AACxD;AAEA,IAAA,2BAAeX;",
|
|
6
|
-
"names": ["TypescriptEditor", "id", "extensions", "initialValue", "scrollTo", "selection", "className", "scrollPastEnd", "themeMode", "useThemeContext", "parentRef", "focusAttributes", "useTextEditor", "createBasicExtensions", "highlightActiveLine", "indentWithTab", "lineNumbers", "syntaxHighlighting", "oneDarkHighlightStyle", "defaultHighlightStyle", "createThemeExtensions", "slots", "content", "editorContent", "javascript", "typescript", "autocomplete", "filter", "nonNullable", "React", "div", "ref"]
|
|
7
|
-
}
|
/package/dist/lib/browser/{TypescriptEditor-HP35MTEQ.mjs.map → TypescriptEditor-PIRIDDUS.mjs.map}
RENAMED
|
File without changes
|