@dxos/react-ui-canvas-compute 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/index.mjs +778 -962
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +778 -962
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +22 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +18 -31
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -2
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +6 -4
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +4 -4
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +2 -2
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -54
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +72 -113
- package/src/graph/controller.ts +109 -71
- package/src/graph/node-defs.ts +31 -31
- package/src/hooks/useComputeNodeState.ts +4 -3
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +3 -3
- package/src/schema.test.ts +11 -11
- package/src/shapes/Function.tsx +10 -8
- package/src/shapes/Gpt.tsx +6 -1
- package/src/shapes/Queue.tsx +15 -9
- package/src/shapes/RNG.tsx +5 -1
- package/src/shapes/Surface.tsx +9 -3
- package/src/shapes/Table.tsx +3 -3
- package/src/shapes/Thread.tsx +17 -11
- package/src/shapes/Trigger.tsx +33 -44
- package/src/shapes/common/Box.tsx +5 -6
- package/src/shapes/common/FunctionBody.tsx +2 -2
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +3 -3
- package/src/testing/circuits.ts +5 -14
package/src/shapes/Surface.tsx
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
9
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
10
|
+
import { Card } from '@dxos/react-ui';
|
|
10
11
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
12
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
12
13
|
|
|
@@ -27,7 +28,11 @@ export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
|
|
|
27
28
|
export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
|
|
28
29
|
|
|
29
30
|
export const createSurface = (props: CreateSurfaceProps) =>
|
|
30
|
-
createShape<SurfaceShape>({
|
|
31
|
+
createShape<SurfaceShape>({
|
|
32
|
+
type: 'surface',
|
|
33
|
+
size: { width: 384, height: 384 },
|
|
34
|
+
...props,
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) => {
|
|
33
38
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -40,9 +45,10 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
|
|
|
40
45
|
}
|
|
41
46
|
};
|
|
42
47
|
|
|
48
|
+
// TODO(burdon): Subject property?
|
|
43
49
|
return (
|
|
44
50
|
<Box shape={shape} onAction={handleAction}>
|
|
45
|
-
{value !== null && <Surface role='card--
|
|
51
|
+
<Card.Root>{value !== null && <Surface.Surface role='card--content' data={{ value }} limit={1} />}</Card.Root>
|
|
46
52
|
</Box>
|
|
47
53
|
);
|
|
48
54
|
};
|
package/src/shapes/Table.tsx
CHANGED
|
@@ -7,13 +7,13 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
-
import {
|
|
10
|
+
import { Message } from '@dxos/types';
|
|
11
11
|
|
|
12
12
|
import { Box, createFunctionAnchors } from './common';
|
|
13
13
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
14
14
|
|
|
15
|
-
const InputSchema = createInputSchema(
|
|
16
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(
|
|
15
|
+
const InputSchema = createInputSchema(Message.Message);
|
|
16
|
+
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));
|
|
17
17
|
|
|
18
18
|
export const TableShape = Schema.extend(
|
|
19
19
|
ComputeShape,
|
package/src/shapes/Thread.tsx
CHANGED
|
@@ -6,16 +6,16 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { ScrollArea, type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Message } from '@dxos/types';
|
|
12
|
+
import { mx } from '@dxos/ui-theme';
|
|
13
13
|
|
|
14
14
|
import { Box, createFunctionAnchors } from './common';
|
|
15
15
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
16
16
|
|
|
17
|
-
const InputSchema = createInputSchema(
|
|
18
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(
|
|
17
|
+
const InputSchema = createInputSchema(Message.Message);
|
|
18
|
+
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));
|
|
19
19
|
|
|
20
20
|
export const ThreadShape = Schema.extend(
|
|
21
21
|
ComputeShape,
|
|
@@ -42,18 +42,24 @@ export const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) =>
|
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<Box shape={shape}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
<ScrollArea.Root orientation='vertical'>
|
|
46
|
+
<ScrollArea.Viewport classNames='gap-2 p-2' ref={scrollRef}>
|
|
47
|
+
{[...items].map((item, i) => (
|
|
48
|
+
<ThreadItem key={i} item={item} />
|
|
49
|
+
))}
|
|
50
|
+
</ScrollArea.Viewport>
|
|
51
|
+
</ScrollArea.Root>
|
|
50
52
|
</Box>
|
|
51
53
|
);
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
export const ThreadItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
|
|
55
57
|
if (typeof item !== 'object') {
|
|
56
|
-
return
|
|
58
|
+
return (
|
|
59
|
+
<div role='none' className={mx(classNames)}>
|
|
60
|
+
{item}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
// TODO(burdon): Hack; introspect type.
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -6,24 +6,9 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { VoidInput } from '@dxos/conductor';
|
|
9
|
-
import { Filter, Obj, Query } from '@dxos/echo';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
type EmailTrigger,
|
|
13
|
-
EmailTriggerOutput,
|
|
14
|
-
FunctionTrigger,
|
|
15
|
-
type QueueTrigger,
|
|
16
|
-
QueueTriggerOutput,
|
|
17
|
-
type SubscriptionTrigger,
|
|
18
|
-
SubscriptionTriggerOutput,
|
|
19
|
-
type TimerTrigger,
|
|
20
|
-
TimerTriggerOutput,
|
|
21
|
-
type TriggerKind,
|
|
22
|
-
TriggerKinds,
|
|
23
|
-
type TriggerType,
|
|
24
|
-
type WebhookTrigger,
|
|
25
|
-
WebhookTriggerOutput,
|
|
26
|
-
} from '@dxos/functions';
|
|
9
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
10
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
11
|
+
import { Trigger, TriggerEvent } from '@dxos/functions';
|
|
27
12
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
28
13
|
import { useSpace } from '@dxos/react-client/echo';
|
|
29
14
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
@@ -36,25 +21,26 @@ export const TriggerShape = Schema.extend(
|
|
|
36
21
|
ComputeShape,
|
|
37
22
|
Schema.Struct({
|
|
38
23
|
type: Schema.Literal('trigger'),
|
|
39
|
-
functionTrigger: Schema.optional(Ref(
|
|
24
|
+
functionTrigger: Schema.optional(Ref.Ref(Trigger.Trigger)),
|
|
40
25
|
}),
|
|
41
26
|
);
|
|
42
|
-
|
|
27
|
+
|
|
28
|
+
export interface TriggerShape extends Schema.Schema.Type<typeof TriggerShape> {}
|
|
43
29
|
|
|
44
30
|
export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
|
|
45
31
|
spaceId?: SpaceId;
|
|
46
|
-
triggerKind?:
|
|
32
|
+
triggerKind?: Trigger.Kind;
|
|
47
33
|
};
|
|
48
34
|
|
|
49
35
|
export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
|
|
50
|
-
const functionTrigger =
|
|
36
|
+
const functionTrigger = Trigger.make({
|
|
51
37
|
enabled: true,
|
|
52
38
|
spec: createTriggerSpec(props),
|
|
53
39
|
});
|
|
54
40
|
return createShape<TriggerShape>({
|
|
55
41
|
type: 'trigger',
|
|
56
42
|
functionTrigger: Ref.make(functionTrigger),
|
|
57
|
-
size: { width: 192, height: getHeight(
|
|
43
|
+
size: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },
|
|
58
44
|
...props,
|
|
59
45
|
});
|
|
60
46
|
};
|
|
@@ -67,7 +53,9 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
67
53
|
|
|
68
54
|
useEffect(() => {
|
|
69
55
|
if (functionTrigger && !functionTrigger.spec) {
|
|
70
|
-
|
|
56
|
+
Obj.change(functionTrigger, (t) => {
|
|
57
|
+
t.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
58
|
+
});
|
|
71
59
|
}
|
|
72
60
|
}, [functionTrigger, functionTrigger?.spec]);
|
|
73
61
|
|
|
@@ -75,9 +63,11 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
75
63
|
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? 'email'));
|
|
76
64
|
}, [functionTrigger?.spec?.kind]);
|
|
77
65
|
|
|
78
|
-
const setKind = (kind:
|
|
66
|
+
const setKind = (kind: Trigger.Kind) => {
|
|
79
67
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
80
|
-
functionTrigger
|
|
68
|
+
Obj.change(functionTrigger!, (t) => {
|
|
69
|
+
t.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
70
|
+
});
|
|
81
71
|
}
|
|
82
72
|
};
|
|
83
73
|
|
|
@@ -89,7 +79,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
89
79
|
<FunctionBody
|
|
90
80
|
shape={shape}
|
|
91
81
|
status={
|
|
92
|
-
<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as
|
|
82
|
+
<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as Trigger.Kind)} />
|
|
93
83
|
}
|
|
94
84
|
inputSchema={VoidInput}
|
|
95
85
|
outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}
|
|
@@ -101,12 +91,12 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
101
91
|
const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {
|
|
102
92
|
return (
|
|
103
93
|
<Select.Root value={value} onValueChange={onValueChange}>
|
|
104
|
-
<Select.TriggerButton variant='ghost' classNames='w-full
|
|
94
|
+
<Select.TriggerButton variant='ghost' classNames='w-full px-0!' />
|
|
105
95
|
<Select.Portal>
|
|
106
96
|
<Select.Content>
|
|
107
97
|
<Select.ScrollUpButton />
|
|
108
98
|
<Select.Viewport>
|
|
109
|
-
{
|
|
99
|
+
{Trigger.Kinds.map((kind) => (
|
|
110
100
|
<Select.Option key={kind} value={kind}>
|
|
111
101
|
{kind}
|
|
112
102
|
</Select.Option>
|
|
@@ -120,37 +110,36 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
120
110
|
);
|
|
121
111
|
};
|
|
122
112
|
|
|
123
|
-
const createTriggerSpec = (props: { triggerKind?:
|
|
113
|
+
const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {
|
|
124
114
|
const kind = props.triggerKind ?? 'email';
|
|
125
115
|
switch (kind) {
|
|
126
116
|
case 'timer':
|
|
127
|
-
return { kind: 'timer', cron: '*/10 * * * * *' } satisfies
|
|
117
|
+
return { kind: 'timer', cron: '*/10 * * * * *' } satisfies Trigger.TimerSpec;
|
|
128
118
|
case 'webhook':
|
|
129
|
-
return { kind: 'webhook', method: 'POST' } satisfies
|
|
119
|
+
return { kind: 'webhook', method: 'POST' } satisfies Trigger.WebhookSpec;
|
|
130
120
|
case 'subscription':
|
|
131
121
|
return {
|
|
132
122
|
kind: 'subscription',
|
|
133
123
|
query: {
|
|
134
|
-
string: 'Query.select(Filter.nothing())',
|
|
135
124
|
ast: Query.select(Filter.nothing()).ast,
|
|
136
125
|
},
|
|
137
|
-
} satisfies
|
|
126
|
+
} satisfies Trigger.SubscriptionSpec;
|
|
138
127
|
case 'email':
|
|
139
|
-
return { kind: 'email' } satisfies
|
|
128
|
+
return { kind: 'email' } satisfies Trigger.EmailSpec;
|
|
140
129
|
case 'queue': {
|
|
141
|
-
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(),
|
|
142
|
-
return { kind: 'queue', queue: dxn } satisfies
|
|
130
|
+
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();
|
|
131
|
+
return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;
|
|
143
132
|
}
|
|
144
133
|
}
|
|
145
134
|
};
|
|
146
135
|
|
|
147
|
-
const getOutputSchema = (kind:
|
|
148
|
-
const kindToSchema: Record<
|
|
149
|
-
['email']:
|
|
150
|
-
['subscription']:
|
|
151
|
-
['timer']:
|
|
152
|
-
['webhook']:
|
|
153
|
-
['queue']:
|
|
136
|
+
const getOutputSchema = (kind: Trigger.Kind) => {
|
|
137
|
+
const kindToSchema: Record<Trigger.Kind, Schema.Schema<any>> = {
|
|
138
|
+
['email']: TriggerEvent.EmailEvent,
|
|
139
|
+
['subscription']: TriggerEvent.SubscriptionEvent,
|
|
140
|
+
['timer']: TriggerEvent.TimerEvent,
|
|
141
|
+
['webhook']: TriggerEvent.WebhookEvent,
|
|
142
|
+
['queue']: TriggerEvent.QueueEvent,
|
|
154
143
|
};
|
|
155
144
|
return kindToSchema[kind];
|
|
156
145
|
};
|
|
@@ -6,9 +6,8 @@ import React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react
|
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
-
import { useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
-
import {
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
import { type CanvasBoard, useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
11
|
|
|
13
12
|
export const headerHeight = 32;
|
|
14
13
|
export const footerHeight = 32;
|
|
@@ -17,7 +16,7 @@ export type BoxActionHandler = (action: 'run' | 'open' | 'close') => void;
|
|
|
17
16
|
|
|
18
17
|
export type BoxProps = PropsWithChildren<
|
|
19
18
|
ThemedClassName<{
|
|
20
|
-
shape: Shape;
|
|
19
|
+
shape: CanvasBoard.Shape;
|
|
21
20
|
title?: string;
|
|
22
21
|
status?: string | ReactNode;
|
|
23
22
|
open?: boolean;
|
|
@@ -33,7 +32,7 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
34
|
<div ref={forwardedRef} className='flex flex-col h-full w-full justify-between'>
|
|
36
|
-
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-
|
|
35
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface'>
|
|
37
36
|
<Icon icon={icon} classNames='mx-2' />
|
|
38
37
|
<div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>
|
|
39
38
|
<IconButton
|
|
@@ -51,7 +50,7 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
51
50
|
/>
|
|
52
51
|
</div>
|
|
53
52
|
<div className={mx('flex flex-col h-full grow overflow-hidden', classNames)}>{children}</div>
|
|
54
|
-
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-
|
|
53
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface'>
|
|
55
54
|
<div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>
|
|
56
55
|
{openable && (
|
|
57
56
|
<IconButton
|
|
@@ -8,7 +8,7 @@ import React, { type JSX, useRef, useState } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
10
10
|
import { useCanvasContext } from '@dxos/react-ui-canvas';
|
|
11
|
-
import { type
|
|
11
|
+
import { type CanvasBoard, type Polygon } from '@dxos/react-ui-canvas-editor';
|
|
12
12
|
import { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
13
13
|
|
|
14
14
|
import { Box, type BoxProps, footerHeight, headerHeight } from '../common';
|
|
@@ -18,7 +18,7 @@ const bodyPadding = 8;
|
|
|
18
18
|
const expandedHeight = 200;
|
|
19
19
|
|
|
20
20
|
export type FunctionBodyProps = {
|
|
21
|
-
shape: Shape;
|
|
21
|
+
shape: CanvasBoard.Shape;
|
|
22
22
|
name?: string;
|
|
23
23
|
content?: JSX.Element;
|
|
24
24
|
inputSchema?: Schema.Schema.Any;
|
|
@@ -11,7 +11,7 @@ import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
|
11
11
|
export const TypeSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {
|
|
12
12
|
return (
|
|
13
13
|
<Select.Root value={value} onValueChange={onValueChange}>
|
|
14
|
-
<Select.TriggerButton variant='ghost' classNames='w-full
|
|
14
|
+
<Select.TriggerButton variant='ghost' classNames='w-full px-0!' />
|
|
15
15
|
<Select.Portal>
|
|
16
16
|
<Select.Content>
|
|
17
17
|
<Select.ScrollUpButton />
|
package/src/shapes/defs.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { Polygon } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { type MakeOptional } from '@dxos/util';
|
|
12
12
|
|
|
@@ -37,7 +37,7 @@ export const ComputeShape = Schema.extend(
|
|
|
37
37
|
Polygon,
|
|
38
38
|
Schema.Struct({
|
|
39
39
|
// TODO(burdon): Rename computeNode?
|
|
40
|
-
node: Schema.optional(
|
|
40
|
+
node: Schema.optional(Obj.ID.annotations({ description: 'Compute node id' })),
|
|
41
41
|
}).pipe(Schema.mutable),
|
|
42
42
|
);
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ export type ComputeShape = Schema.Schema.Type<typeof ComputeShape>;
|
|
|
45
45
|
|
|
46
46
|
export const createShape = <S extends ComputeShape>({ id, ...rest }: CreateShapeProps<S> & { type: string }): S => {
|
|
47
47
|
return {
|
|
48
|
-
id: id ??
|
|
48
|
+
id: id ?? Obj.ID.random(),
|
|
49
49
|
...rest,
|
|
50
50
|
} as S;
|
|
51
51
|
};
|
package/src/testing/circuits.ts
CHANGED
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createSystemPrompt } from '@dxos/assistant';
|
|
6
|
-
import { ObjectId } from '@dxos/
|
|
7
|
-
import { type ServiceContainer } from '@dxos/functions';
|
|
8
|
-
import { DXN, SpaceId } from '@dxos/keys';
|
|
6
|
+
import { DXN, ObjectId, SpaceId } from '@dxos/keys';
|
|
9
7
|
import { type Dimension, type Point } from '@dxos/react-ui-canvas';
|
|
10
8
|
import { CanvasGraphModel, createNote, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
|
|
11
9
|
|
|
12
|
-
import { ComputeGraphController } from '../graph';
|
|
13
|
-
import { createComputeGraph } from '../hooks';
|
|
14
10
|
import {
|
|
15
11
|
type ComputeShape,
|
|
16
12
|
createAnd,
|
|
@@ -38,19 +34,14 @@ import {
|
|
|
38
34
|
createTextToImage,
|
|
39
35
|
} from '../shapes';
|
|
40
36
|
|
|
41
|
-
export const createComputeGraphController = (
|
|
42
|
-
graph: CanvasGraphModel<ComputeShape>,
|
|
43
|
-
serviceContainer: ServiceContainer,
|
|
44
|
-
) => {
|
|
45
|
-
const computeGraph = createComputeGraph(graph);
|
|
46
|
-
const controller = new ComputeGraphController(serviceContainer, computeGraph);
|
|
47
|
-
return { controller, graph };
|
|
48
|
-
};
|
|
49
|
-
|
|
50
37
|
//
|
|
51
38
|
// Circuits
|
|
52
39
|
//
|
|
53
40
|
|
|
41
|
+
export const createEmptyCircuit = () => {
|
|
42
|
+
return CanvasGraphModel.create<ComputeShape>();
|
|
43
|
+
};
|
|
44
|
+
|
|
54
45
|
export const createBasicCircuit = () => {
|
|
55
46
|
const model = CanvasGraphModel.create<ComputeShape>();
|
|
56
47
|
model.builder.call(({ model }) => {
|