@dxos/react-ui-canvas-compute 0.9.1-staging.ee54ba693a → 0.11.0
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/index.mjs +2164 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +2 -51
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +2 -34
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +2 -51
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +2 -51
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +2 -51
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +2 -53
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +2 -51
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Feed.d.ts +2 -51
- package/dist/types/src/shapes/Feed.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +7 -50
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +2 -51
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +2 -51
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -101
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -103
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -55
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +2 -51
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +2 -51
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +2 -51
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +2 -51
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +4 -55
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +2 -51
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +2 -51
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +2 -51
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -17
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/append-def.d.ts +52 -0
- package/dist/types/src/shapes/append-def.d.ts.map +1 -0
- package/dist/types/src/shapes/array-def.d.ts +35 -0
- package/dist/types/src/shapes/array-def.d.ts.map +1 -0
- package/dist/types/src/shapes/audio-def.d.ts +52 -0
- package/dist/types/src/shapes/audio-def.d.ts.map +1 -0
- package/dist/types/src/shapes/beacon-def.d.ts +52 -0
- package/dist/types/src/shapes/beacon-def.d.ts.map +1 -0
- package/dist/types/src/shapes/chat-def.d.ts +52 -0
- package/dist/types/src/shapes/chat-def.d.ts.map +1 -0
- package/dist/types/src/shapes/common/Box.d.ts +0 -2
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +1 -3
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/box-defs.d.ts +3 -0
- package/dist/types/src/shapes/common/box-defs.d.ts.map +1 -0
- package/dist/types/src/shapes/common/function-anchors.d.ts +7 -0
- package/dist/types/src/shapes/common/function-anchors.d.ts.map +1 -0
- package/dist/types/src/shapes/common/index.d.ts +2 -0
- package/dist/types/src/shapes/common/index.d.ts.map +1 -1
- package/dist/types/src/shapes/constant-def.d.ts +54 -0
- package/dist/types/src/shapes/constant-def.d.ts.map +1 -0
- package/dist/types/src/shapes/database-def.d.ts +52 -0
- package/dist/types/src/shapes/database-def.d.ts.map +1 -0
- package/dist/types/src/shapes/feed-def.d.ts +52 -0
- package/dist/types/src/shapes/feed-def.d.ts.map +1 -0
- package/dist/types/src/shapes/function-def.d.ts +52 -0
- package/dist/types/src/shapes/function-def.d.ts.map +1 -0
- package/dist/types/src/shapes/gpt-def.d.ts +52 -0
- package/dist/types/src/shapes/gpt-def.d.ts.map +1 -0
- package/dist/types/src/shapes/gpt-realtime-def.d.ts +52 -0
- package/dist/types/src/shapes/gpt-realtime-def.d.ts.map +1 -0
- package/dist/types/src/shapes/index.d.ts +23 -0
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/src/shapes/json-def.d.ts +102 -0
- package/dist/types/src/shapes/json-def.d.ts.map +1 -0
- package/dist/types/src/shapes/logic-def.d.ts +104 -0
- package/dist/types/src/shapes/logic-def.d.ts.map +1 -0
- package/dist/types/src/shapes/rng-def.d.ts +56 -0
- package/dist/types/src/shapes/rng-def.d.ts.map +1 -0
- package/dist/types/src/shapes/scope-def.d.ts +52 -0
- package/dist/types/src/shapes/scope-def.d.ts.map +1 -0
- package/dist/types/src/shapes/surface-def.d.ts +52 -0
- package/dist/types/src/shapes/surface-def.d.ts.map +1 -0
- package/dist/types/src/shapes/switch-def.d.ts +52 -0
- package/dist/types/src/shapes/switch-def.d.ts.map +1 -0
- package/dist/types/src/shapes/table-def.d.ts +52 -0
- package/dist/types/src/shapes/table-def.d.ts.map +1 -0
- package/dist/types/src/shapes/template-def.d.ts +56 -0
- package/dist/types/src/shapes/template-def.d.ts.map +1 -0
- package/dist/types/src/shapes/text-def.d.ts +52 -0
- package/dist/types/src/shapes/text-def.d.ts.map +1 -0
- package/dist/types/src/shapes/text-to-image-def.d.ts +52 -0
- package/dist/types/src/shapes/text-to-image-def.d.ts.map +1 -0
- package/dist/types/src/shapes/thread-def.d.ts +52 -0
- package/dist/types/src/shapes/thread-def.d.ts.map +1 -0
- package/dist/types/src/shapes/trigger-def.d.ts +18 -0
- package/dist/types/src/shapes/trigger-def.d.ts.map +1 -0
- package/dist/types/src/shapes/trigger-spec.d.ts +9 -0
- package/dist/types/src/shapes/trigger-spec.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -46
- package/src/compute.stories.tsx +1 -1
- package/src/shapes/Append.tsx +3 -31
- package/src/shapes/Array.tsx +3 -43
- package/src/shapes/Audio.tsx +2 -26
- package/src/shapes/Beacon.tsx +2 -29
- package/src/shapes/Chat.tsx +1 -36
- package/src/shapes/Constant.tsx +1 -37
- package/src/shapes/Database.tsx +2 -27
- package/src/shapes/Feed.tsx +4 -35
- package/src/shapes/Function.tsx +4 -38
- package/src/shapes/Gpt.tsx +3 -33
- package/src/shapes/GptRealtime.tsx +2 -36
- package/src/shapes/Json.tsx +4 -70
- package/src/shapes/Logic.tsx +3 -58
- package/src/shapes/RNG.tsx +2 -32
- package/src/shapes/Scope.tsx +2 -31
- package/src/shapes/Surface.tsx +2 -32
- package/src/shapes/Switch.tsx +2 -26
- package/src/shapes/Table.tsx +3 -34
- package/src/shapes/Template.tsx +6 -36
- package/src/shapes/Text.tsx +2 -28
- package/src/shapes/TextToImage.tsx +2 -27
- package/src/shapes/Thread.tsx +3 -34
- package/src/shapes/Trigger.tsx +6 -79
- package/src/shapes/append-def.ts +42 -0
- package/src/shapes/array-def.ts +54 -0
- package/src/shapes/audio-def.ts +36 -0
- package/src/shapes/beacon-def.ts +39 -0
- package/src/shapes/chat-def.tsx +47 -0
- package/src/shapes/common/Box.tsx +2 -5
- package/src/shapes/common/FunctionBody.tsx +6 -25
- package/src/shapes/common/box-defs.ts +10 -0
- package/src/shapes/common/function-anchors.ts +37 -0
- package/src/shapes/common/index.ts +3 -0
- package/src/shapes/constant-def.tsx +48 -0
- package/src/shapes/database-def.ts +37 -0
- package/src/shapes/feed-def.ts +44 -0
- package/src/shapes/function-def.ts +46 -0
- package/src/shapes/gpt-def.ts +43 -0
- package/src/shapes/gpt-realtime-def.ts +46 -0
- package/src/shapes/index.ts +25 -0
- package/src/shapes/json-def.ts +80 -0
- package/src/shapes/logic-def.ts +69 -0
- package/src/shapes/rng-def.ts +42 -0
- package/src/shapes/scope-def.ts +41 -0
- package/src/shapes/surface-def.ts +42 -0
- package/src/shapes/switch-def.ts +36 -0
- package/src/shapes/table-def.ts +45 -0
- package/src/shapes/template-def.ts +48 -0
- package/src/shapes/text-def.ts +38 -0
- package/src/shapes/text-to-image-def.ts +37 -0
- package/src/shapes/thread-def.ts +45 -0
- package/src/shapes/trigger-def.ts +63 -0
- package/src/shapes/trigger-spec.ts +44 -0
- package/dist/lib/browser/index.mjs +0 -2596
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -2596
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/src/shapes/Gpt.tsx
CHANGED
|
@@ -2,34 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React, { useEffect, useState } from 'react';
|
|
7
6
|
|
|
8
|
-
import { GptInput, GptOutput } from '@dxos/conductor';
|
|
9
7
|
import { ScrollArea } from '@dxos/react-ui';
|
|
10
|
-
import { type ShapeComponentProps
|
|
8
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
11
9
|
|
|
12
10
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
import { FunctionBody
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
export const GptShape = Schema.extend(
|
|
17
|
-
ComputeShape,
|
|
18
|
-
Schema.Struct({
|
|
19
|
-
type: Schema.Literal('gpt'),
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export type GptShape = Schema.Schema.Type<typeof GptShape>;
|
|
24
|
-
|
|
25
|
-
export type CreateGptProps = CreateShapeProps<GptShape>;
|
|
26
|
-
|
|
27
|
-
export const createGpt = (props: CreateGptProps) =>
|
|
28
|
-
createShape<GptShape>({
|
|
29
|
-
type: 'gpt',
|
|
30
|
-
size: { width: 256, height: Math.max(getHeight(GptInput), getHeight(GptOutput)) },
|
|
31
|
-
...props,
|
|
32
|
-
});
|
|
11
|
+
import { FunctionBody } from './common';
|
|
12
|
+
import { type GptShape } from './gpt-def';
|
|
33
13
|
|
|
34
14
|
export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
35
15
|
const { meta, runtime } = useComputeNodeState(shape);
|
|
@@ -85,13 +65,3 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
85
65
|
/>
|
|
86
66
|
);
|
|
87
67
|
};
|
|
88
|
-
|
|
89
|
-
export const gptShape: ShapeDef<GptShape> = {
|
|
90
|
-
type: 'gpt',
|
|
91
|
-
name: 'GPT',
|
|
92
|
-
icon: 'ph--brain--regular',
|
|
93
|
-
component: GptComponent,
|
|
94
|
-
createShape: createGpt,
|
|
95
|
-
getAnchors: (shape) => createFunctionAnchors(shape, GptInput, GptOutput),
|
|
96
|
-
openable: true,
|
|
97
|
-
};
|
|
@@ -2,30 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React, { useState } from 'react';
|
|
7
6
|
|
|
8
7
|
import { log } from '@dxos/log';
|
|
9
8
|
import { useConfig } from '@dxos/react-client';
|
|
10
9
|
import { Icon } from '@dxos/react-ui';
|
|
11
|
-
import { type ShapeComponentProps
|
|
10
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
12
11
|
|
|
13
|
-
import {
|
|
14
|
-
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
15
|
-
|
|
16
|
-
export const GptRealtimeShape = Schema.extend(
|
|
17
|
-
ComputeShape,
|
|
18
|
-
Schema.Struct({
|
|
19
|
-
type: Schema.Literal('gpt-realtime'),
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export type GptRealtimeShape = Schema.Schema.Type<typeof GptRealtimeShape>;
|
|
24
|
-
|
|
25
|
-
export type CreateGptRealtimeProps = CreateShapeProps<GptRealtimeShape>;
|
|
26
|
-
|
|
27
|
-
export const createGptRealtime = (props: CreateGptRealtimeProps) =>
|
|
28
|
-
createShape<GptRealtimeShape>({ type: 'gpt-realtime', size: { width: 256, height: 256 }, ...props });
|
|
12
|
+
import { type GptRealtimeShape } from './gpt-realtime-def';
|
|
29
13
|
|
|
30
14
|
export const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeShape>) => {
|
|
31
15
|
const [isLive, setIsLive] = useState(false);
|
|
@@ -154,22 +138,4 @@ export const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeS
|
|
|
154
138
|
);
|
|
155
139
|
};
|
|
156
140
|
|
|
157
|
-
export const gptRealtimeShape: ShapeDef<GptRealtimeShape> = {
|
|
158
|
-
type: 'gpt-realtime',
|
|
159
|
-
name: 'GPT Realtime',
|
|
160
|
-
icon: 'ph--pulse--regular',
|
|
161
|
-
component: GptRealtimeComponent,
|
|
162
|
-
createShape: createGptRealtime,
|
|
163
|
-
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
164
|
-
getAnchors: (shape) =>
|
|
165
|
-
createFunctionAnchors(
|
|
166
|
-
shape,
|
|
167
|
-
Schema.Struct({
|
|
168
|
-
audio: Schema.Any,
|
|
169
|
-
}),
|
|
170
|
-
Schema.Struct({}),
|
|
171
|
-
),
|
|
172
|
-
resizable: true,
|
|
173
|
-
};
|
|
174
|
-
|
|
175
141
|
const DEFAULT_AI_SERVICE_URL = 'http://localhost:8788';
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -2,39 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import { DEFAULT_INPUT
|
|
9
|
-
import { type ShapeComponentProps
|
|
10
|
-
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
7
|
+
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
11
9
|
import { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
12
10
|
|
|
13
11
|
import { useComputeNodeState } from '../hooks';
|
|
14
|
-
import { Box
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
// Data
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
export const JsonShape = Schema.extend(
|
|
22
|
-
ComputeShape,
|
|
23
|
-
Schema.Struct({
|
|
24
|
-
type: Schema.Literal('json'),
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export type JsonShape = Schema.Schema.Type<typeof JsonShape>;
|
|
29
|
-
|
|
30
|
-
export const JsonTransformShape = Schema.extend(
|
|
31
|
-
ComputeShape,
|
|
32
|
-
Schema.Struct({
|
|
33
|
-
type: Schema.Literal('json-transform'),
|
|
34
|
-
}),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;
|
|
12
|
+
import { Box } from './common';
|
|
13
|
+
import { type JsonShape, type JsonTransformShape } from './json-def';
|
|
38
14
|
|
|
39
15
|
//
|
|
40
16
|
// Component
|
|
@@ -66,45 +42,3 @@ export type JsonTransformComponentProps = ShapeComponentProps<JsonTransformShape
|
|
|
66
42
|
export const JsonTransformComponent = ({ shape, ...props }: JsonTransformComponentProps) => {
|
|
67
43
|
return <Box shape={shape} />;
|
|
68
44
|
};
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
// Defs
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
export type CreateJsonProps = CreateShapeProps<JsonShape>;
|
|
75
|
-
|
|
76
|
-
export const createJson = (props: CreateJsonProps) =>
|
|
77
|
-
createShape<JsonShape>({ type: 'json', size: { width: 256, height: 256 }, ...props });
|
|
78
|
-
|
|
79
|
-
export const jsonShape: ShapeDef<JsonShape> = {
|
|
80
|
-
type: 'json',
|
|
81
|
-
name: 'JSON',
|
|
82
|
-
icon: 'ph--code--regular',
|
|
83
|
-
component: (props) => <JsonComponent {...props} />,
|
|
84
|
-
createShape: createJson,
|
|
85
|
-
getAnchors: (shape) =>
|
|
86
|
-
createAnchorMap(shape, {
|
|
87
|
-
[createAnchorId('input')]: { x: -1, y: 0 },
|
|
88
|
-
[createAnchorId('output')]: { x: 1, y: 0 },
|
|
89
|
-
}),
|
|
90
|
-
resizable: true,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type CreateJsonTransformProps = CreateShapeProps<JsonTransformShape> & { expression?: string };
|
|
94
|
-
|
|
95
|
-
export const createJsonTransform = (props: CreateJsonTransformProps) =>
|
|
96
|
-
createShape<JsonTransformShape>({
|
|
97
|
-
type: 'json-transform',
|
|
98
|
-
size: { width: 128, height: getHeight(JsonTransformInput) },
|
|
99
|
-
...props,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
export const jsonTransformShape: ShapeDef<JsonTransformShape> = {
|
|
103
|
-
type: 'json-transform',
|
|
104
|
-
name: 'Transform',
|
|
105
|
-
icon: 'ph--shuffle-simple--regular',
|
|
106
|
-
component: (props) => <JsonTransformComponent {...props} />,
|
|
107
|
-
createShape: createJsonTransform,
|
|
108
|
-
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
109
|
-
resizable: true,
|
|
110
|
-
};
|
package/src/shapes/Logic.tsx
CHANGED
|
@@ -2,36 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
7
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';
|
|
9
|
-
import { type ShapeComponentProps
|
|
8
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
10
9
|
|
|
11
|
-
import { FunctionBody
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
// Data
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
export const IfShape = Schema.extend(
|
|
19
|
-
ComputeShape,
|
|
20
|
-
Schema.Struct({
|
|
21
|
-
type: Schema.Literal('if'),
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export type IfShape = Schema.Schema.Type<typeof IfShape>;
|
|
26
|
-
|
|
27
|
-
export const IfElseShape = Schema.extend(
|
|
28
|
-
ComputeShape,
|
|
29
|
-
Schema.Struct({
|
|
30
|
-
type: Schema.Literal('if-else'),
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;
|
|
10
|
+
import { FunctionBody } from './common';
|
|
11
|
+
import { type IfElseShape, type IfShape } from './logic-def';
|
|
35
12
|
|
|
36
13
|
//
|
|
37
14
|
// Components
|
|
@@ -48,35 +25,3 @@ export type IfElseComponentProps = ShapeComponentProps<IfElseShape>;
|
|
|
48
25
|
export const IfElseComponent = ({ shape, ...props }: IfElseComponentProps) => {
|
|
49
26
|
return <FunctionBody shape={shape} inputSchema={IfElseInput} outputSchema={IfElseOutput} />;
|
|
50
27
|
};
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
// Defs
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
export type CreateIfProps = CreateShapeProps<IfShape> & { if?: string };
|
|
57
|
-
|
|
58
|
-
export const createIf = (props: CreateIfProps) =>
|
|
59
|
-
createShape<IfShape>({ type: 'if', size: { width: 192, height: getHeight(IfInput) }, ...props });
|
|
60
|
-
|
|
61
|
-
export const ifShape: ShapeDef<IfShape> = {
|
|
62
|
-
type: 'if',
|
|
63
|
-
name: 'IF',
|
|
64
|
-
icon: 'ph--arrows-split--regular',
|
|
65
|
-
component: (props) => <IfComponent {...props} />,
|
|
66
|
-
createShape: createIf,
|
|
67
|
-
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput),
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type CreateIfElseProps = CreateShapeProps<IfShape> & { if?: string };
|
|
71
|
-
|
|
72
|
-
export const createIfElse = (props: CreateIfElseProps) =>
|
|
73
|
-
createShape<IfElseShape>({ type: 'if-else', size: { width: 192, height: getHeight(IfElseInput) }, ...props });
|
|
74
|
-
|
|
75
|
-
export const ifElseShape: ShapeDef<IfElseShape> = {
|
|
76
|
-
type: 'if-else',
|
|
77
|
-
name: 'IF/ELSE',
|
|
78
|
-
icon: 'ph--arrows-merge--regular',
|
|
79
|
-
component: (props) => <IfElseComponent {...props} />,
|
|
80
|
-
createShape: createIfElse,
|
|
81
|
-
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput),
|
|
82
|
-
};
|
package/src/shapes/RNG.tsx
CHANGED
|
@@ -2,35 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React, { useEffect, useState } from 'react';
|
|
7
6
|
|
|
8
7
|
import { DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
8
|
import { Icon, type IconProps } from '@dxos/react-ui';
|
|
10
|
-
import { type ShapeComponentProps
|
|
9
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
11
10
|
|
|
12
11
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
export const RandomShape = Schema.extend(
|
|
16
|
-
ComputeShape,
|
|
17
|
-
Schema.Struct({
|
|
18
|
-
type: Schema.Literal('rng'),
|
|
19
|
-
min: Schema.optional(Schema.Number),
|
|
20
|
-
max: Schema.optional(Schema.Number),
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export type RandomShape = Schema.Schema.Type<typeof RandomShape>;
|
|
25
|
-
|
|
26
|
-
export type CreateRandomProps = CreateShapeProps<RandomShape>;
|
|
27
|
-
|
|
28
|
-
export const createRandom = (props: CreateRandomProps) =>
|
|
29
|
-
createShape<RandomShape>({
|
|
30
|
-
type: 'rng',
|
|
31
|
-
size: { width: 64, height: 64 },
|
|
32
|
-
...props,
|
|
33
|
-
});
|
|
12
|
+
import { type RandomShape } from './rng-def';
|
|
34
13
|
|
|
35
14
|
const icons = [
|
|
36
15
|
'ph--dice-one--regular',
|
|
@@ -76,12 +55,3 @@ export const RandomComponent = ({ shape }: ShapeComponentProps<RandomShape>) =>
|
|
|
76
55
|
</div>
|
|
77
56
|
);
|
|
78
57
|
};
|
|
79
|
-
|
|
80
|
-
export const randomShape: ShapeDef<RandomShape> = {
|
|
81
|
-
type: 'rng',
|
|
82
|
-
name: 'Random',
|
|
83
|
-
icon: 'ph--dice-six--regular',
|
|
84
|
-
component: RandomComponent,
|
|
85
|
-
createShape: createRandom,
|
|
86
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
87
|
-
};
|
package/src/shapes/Scope.tsx
CHANGED
|
@@ -2,35 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
7
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
9
8
|
import { useAudioStream } from '@dxos/react-ui-audio';
|
|
10
|
-
import { type ShapeComponentProps
|
|
9
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
11
10
|
import { Chaos, shaderPresets } from '@dxos/react-ui-experimental';
|
|
12
11
|
|
|
13
12
|
import { useComputeNodeState } from '../hooks';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
export const ScopeShape = Schema.extend(
|
|
17
|
-
ComputeShape,
|
|
18
|
-
Schema.Struct({
|
|
19
|
-
type: Schema.Literal('scope'),
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export type ScopeShape = Schema.Schema.Type<typeof ScopeShape>;
|
|
24
|
-
|
|
25
|
-
export type CreateScopeProps = CreateShapeProps<ScopeShape>;
|
|
26
|
-
|
|
27
|
-
export const createScope = (props: CreateScopeProps) =>
|
|
28
|
-
createShape<ScopeShape>({
|
|
29
|
-
type: 'scope',
|
|
30
|
-
size: { width: 128, height: 128 },
|
|
31
|
-
classNames: 'rounded-full border-primary-800',
|
|
32
|
-
...props,
|
|
33
|
-
});
|
|
13
|
+
import { type ScopeShape } from './scope-def';
|
|
34
14
|
|
|
35
15
|
export const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {
|
|
36
16
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -44,12 +24,3 @@ export const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {
|
|
|
44
24
|
</div>
|
|
45
25
|
);
|
|
46
26
|
};
|
|
47
|
-
|
|
48
|
-
export const scopeShape: ShapeDef<ScopeShape> = {
|
|
49
|
-
type: 'scope',
|
|
50
|
-
name: 'Scope',
|
|
51
|
-
icon: 'ph--waveform--regular',
|
|
52
|
-
component: ScopeComponent,
|
|
53
|
-
createShape: createScope,
|
|
54
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
55
|
-
};
|
package/src/shapes/Surface.tsx
CHANGED
|
@@ -2,37 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
9
8
|
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
10
9
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
11
10
|
import { Card } from '@dxos/react-ui';
|
|
12
|
-
import { type ShapeComponentProps
|
|
13
|
-
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
14
12
|
|
|
15
13
|
import { useComputeNodeState } from '../hooks';
|
|
16
14
|
import { Box, type BoxActionHandler } from './common';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
export const SurfaceShape = Schema.extend(
|
|
20
|
-
ComputeShape,
|
|
21
|
-
Schema.Struct({
|
|
22
|
-
type: Schema.Literal('surface'),
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
|
|
27
|
-
|
|
28
|
-
export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
|
|
29
|
-
|
|
30
|
-
export const createSurface = (props: CreateSurfaceProps) =>
|
|
31
|
-
createShape<SurfaceShape>({
|
|
32
|
-
type: 'surface',
|
|
33
|
-
size: { width: 384, height: 384 },
|
|
34
|
-
...props,
|
|
35
|
-
});
|
|
15
|
+
import { type SurfaceShape } from './surface-def';
|
|
36
16
|
|
|
37
17
|
export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) => {
|
|
38
18
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -54,13 +34,3 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
|
|
|
54
34
|
</Box>
|
|
55
35
|
);
|
|
56
36
|
};
|
|
57
|
-
|
|
58
|
-
export const surfaceShape: ShapeDef<SurfaceShape> = {
|
|
59
|
-
type: 'surface',
|
|
60
|
-
name: 'Surface',
|
|
61
|
-
icon: 'ph--frame-corners--regular',
|
|
62
|
-
component: SurfaceComponent,
|
|
63
|
-
createShape: createSurface,
|
|
64
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
65
|
-
resizable: true,
|
|
66
|
-
};
|
package/src/shapes/Switch.tsx
CHANGED
|
@@ -2,29 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React, { useEffect, useState } from 'react';
|
|
7
6
|
|
|
8
7
|
import { DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
8
|
import { Input } from '@dxos/react-ui';
|
|
10
|
-
import { type ShapeComponentProps
|
|
9
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
11
10
|
|
|
12
11
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
export const SwitchShape = Schema.extend(
|
|
16
|
-
ComputeShape,
|
|
17
|
-
Schema.Struct({
|
|
18
|
-
type: Schema.Literal('switch'),
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
export type SwitchShape = Schema.Schema.Type<typeof SwitchShape>;
|
|
23
|
-
|
|
24
|
-
export type CreateSwitchProps = CreateShapeProps<SwitchShape>;
|
|
25
|
-
|
|
26
|
-
export const createSwitch = (props: CreateSwitchProps) =>
|
|
27
|
-
createShape<SwitchShape>({ type: 'switch', size: { width: 64, height: 64 }, ...props });
|
|
12
|
+
import { type SwitchShape } from './switch-def';
|
|
28
13
|
|
|
29
14
|
// TODO(burdon): Should model as a constant.
|
|
30
15
|
export const SwitchComponent = ({ shape }: ShapeComponentProps<SwitchShape>) => {
|
|
@@ -42,12 +27,3 @@ export const SwitchComponent = ({ shape }: ShapeComponentProps<SwitchShape>) =>
|
|
|
42
27
|
</div>
|
|
43
28
|
);
|
|
44
29
|
};
|
|
45
|
-
|
|
46
|
-
export const switchShape: ShapeDef<SwitchShape> = {
|
|
47
|
-
type: 'switch',
|
|
48
|
-
name: 'Switch',
|
|
49
|
-
icon: 'ph--toggle-left--regular',
|
|
50
|
-
component: SwitchComponent,
|
|
51
|
-
createShape: createSwitch,
|
|
52
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
53
|
-
};
|
package/src/shapes/Table.tsx
CHANGED
|
@@ -2,46 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
import { Type } from '@dxos/echo';
|
|
10
|
-
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import { Message } from '@dxos/types';
|
|
7
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
12
8
|
|
|
13
|
-
import { Box
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
const InputSchema = createInputSchema(Type.getSchema(Message.Message));
|
|
17
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));
|
|
18
|
-
|
|
19
|
-
export const TableShape = Schema.extend(
|
|
20
|
-
ComputeShape,
|
|
21
|
-
Schema.Struct({
|
|
22
|
-
type: Schema.Literal('table'),
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export type TableShape = Schema.Schema.Type<typeof TableShape>;
|
|
27
|
-
|
|
28
|
-
export type CreateTableProps = CreateShapeProps<TableShape>;
|
|
29
|
-
|
|
30
|
-
export const createTable = (props: CreateTableProps) =>
|
|
31
|
-
createShape<TableShape>({ type: 'table', size: { width: 320, height: 512 }, ...props });
|
|
9
|
+
import { Box } from './common';
|
|
10
|
+
import { type TableShape } from './table-def';
|
|
32
11
|
|
|
33
12
|
export const TableComponent = ({ shape }: ShapeComponentProps<TableShape>) => {
|
|
34
13
|
// const items = shape.node.items.value;
|
|
35
14
|
|
|
36
15
|
return <Box shape={shape}></Box>;
|
|
37
16
|
};
|
|
38
|
-
|
|
39
|
-
export const tableShape: ShapeDef<TableShape> = {
|
|
40
|
-
type: 'table',
|
|
41
|
-
name: 'Table',
|
|
42
|
-
icon: 'ph--table--regular',
|
|
43
|
-
component: TableComponent,
|
|
44
|
-
createShape: createTable,
|
|
45
|
-
getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),
|
|
46
|
-
resizable: true,
|
|
47
|
-
};
|
package/src/shapes/Template.tsx
CHANGED
|
@@ -5,34 +5,19 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import { ComputeValueType,
|
|
8
|
+
import { ComputeValueType, getTemplateInputSchema } from '@dxos/conductor';
|
|
9
9
|
import { toJsonSchema } from '@dxos/echo/JsonSchema';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import {
|
|
12
12
|
type ShapeComponentProps,
|
|
13
|
-
type ShapeDef,
|
|
14
13
|
TextBox,
|
|
15
14
|
type TextBoxControl,
|
|
16
15
|
type TextBoxProps,
|
|
17
16
|
} from '@dxos/react-ui-canvas-editor';
|
|
18
17
|
|
|
19
18
|
import { useComputeNodeState } from '../hooks';
|
|
20
|
-
import { Box, TypeSelect
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
// Data
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
export const TemplateShape = Schema.extend(
|
|
28
|
-
ComputeShape,
|
|
29
|
-
Schema.Struct({
|
|
30
|
-
type: Schema.Literal('template'),
|
|
31
|
-
valueType: Schema.optional(ComputeValueType),
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;
|
|
19
|
+
import { Box, TypeSelect } from './common';
|
|
20
|
+
import { type TemplateShape } from './template-def';
|
|
36
21
|
|
|
37
22
|
//
|
|
38
23
|
// Component
|
|
@@ -79,21 +64,6 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
|
|
|
79
64
|
);
|
|
80
65
|
};
|
|
81
66
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export type CreateTemplateProps = CreateShapeProps<TemplateShape> & { text?: string };
|
|
87
|
-
|
|
88
|
-
export const createTemplate = (props: CreateTemplateProps) =>
|
|
89
|
-
createShape<TemplateShape>({ type: 'template', size: { width: 256, height: 384 }, ...props });
|
|
90
|
-
|
|
91
|
-
export const templateShape: ShapeDef<TemplateShape> = {
|
|
92
|
-
type: 'template',
|
|
93
|
-
name: 'Template',
|
|
94
|
-
icon: 'ph--article--regular',
|
|
95
|
-
component: (props) => <TextInputComponent {...props} placeholder={'Prompt'} />,
|
|
96
|
-
createShape: createTemplate,
|
|
97
|
-
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput, TemplateOutput),
|
|
98
|
-
resizable: true,
|
|
99
|
-
};
|
|
67
|
+
export const TemplateComponent = (props: ShapeComponentProps<TemplateShape>) => (
|
|
68
|
+
<TextInputComponent {...props} placeholder={'Prompt'} />
|
|
69
|
+
);
|
package/src/shapes/Text.tsx
CHANGED
|
@@ -2,30 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
7
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
9
|
-
import { type ShapeComponentProps,
|
|
10
|
-
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
8
|
+
import { type ShapeComponentProps, TextBox } from '@dxos/react-ui-canvas-editor';
|
|
11
9
|
|
|
12
10
|
import { useComputeNodeState } from '../hooks';
|
|
13
11
|
import { Box, type BoxActionHandler } from './common';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
export const TextShape = Schema.extend(
|
|
17
|
-
ComputeShape,
|
|
18
|
-
Schema.Struct({
|
|
19
|
-
type: Schema.Literal('text'),
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export type TextShape = Schema.Schema.Type<typeof TextShape>;
|
|
24
|
-
|
|
25
|
-
export type CreateTextProps = CreateShapeProps<TextShape>;
|
|
26
|
-
|
|
27
|
-
export const createText = (props: CreateTextProps) =>
|
|
28
|
-
createShape<TextShape>({ type: 'text', size: { width: 384, height: 384 }, ...props });
|
|
12
|
+
import { type TextShape } from './text-def';
|
|
29
13
|
|
|
30
14
|
export const TextComponent = ({ shape }: ShapeComponentProps<TextShape>) => {
|
|
31
15
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -44,13 +28,3 @@ export const TextComponent = ({ shape }: ShapeComponentProps<TextShape>) => {
|
|
|
44
28
|
</Box>
|
|
45
29
|
);
|
|
46
30
|
};
|
|
47
|
-
|
|
48
|
-
export const textShape: ShapeDef<TextShape> = {
|
|
49
|
-
type: 'text',
|
|
50
|
-
name: 'Text',
|
|
51
|
-
icon: 'ph--article--regular',
|
|
52
|
-
component: TextComponent,
|
|
53
|
-
createShape: createText,
|
|
54
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
55
|
-
resizable: true,
|
|
56
|
-
};
|
|
@@ -2,38 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import { type ShapeComponentProps
|
|
9
|
-
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
7
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
10
8
|
|
|
11
9
|
import { Box } from './common';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
export const TextToImageShape = Schema.extend(
|
|
15
|
-
ComputeShape,
|
|
16
|
-
Schema.Struct({
|
|
17
|
-
type: Schema.Literal('text-to-image'),
|
|
18
|
-
}),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export type TextToImageShape = Schema.Schema.Type<typeof TextToImageShape>;
|
|
22
|
-
|
|
23
|
-
export type CreateTextToImageProps = CreateShapeProps<TextToImageShape>;
|
|
24
|
-
|
|
25
|
-
export const createTextToImage = (props: CreateTextToImageProps) =>
|
|
26
|
-
createShape<TextToImageShape>({ type: 'text-to-image', size: { width: 128, height: 64 }, ...props });
|
|
10
|
+
import { type TextToImageShape } from './text-to-image-def';
|
|
27
11
|
|
|
28
12
|
export const TextToImageComponent = ({ shape }: ShapeComponentProps<TextToImageShape>) => {
|
|
29
13
|
return <Box shape={shape} />;
|
|
30
14
|
};
|
|
31
|
-
|
|
32
|
-
export const textToImageShape: ShapeDef<TextToImageShape> = {
|
|
33
|
-
type: 'text-to-image',
|
|
34
|
-
name: 'Image',
|
|
35
|
-
icon: 'ph--image--regular',
|
|
36
|
-
component: TextToImageComponent,
|
|
37
|
-
createShape: createTextToImage,
|
|
38
|
-
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
39
|
-
};
|