@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/Thread.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, useRef } from 'react';
|
|
7
6
|
|
|
8
|
-
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
|
-
import { Type } from '@dxos/echo';
|
|
10
7
|
import { ScrollArea, type ThemedClassName } from '@dxos/react-ui';
|
|
11
|
-
import { type ShapeComponentProps
|
|
12
|
-
import { Message } from '@dxos/types';
|
|
8
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
13
9
|
import { mx } from '@dxos/ui-theme';
|
|
14
10
|
|
|
15
|
-
import { Box
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
const InputSchema = createInputSchema(Type.getSchema(Message.Message));
|
|
19
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));
|
|
20
|
-
|
|
21
|
-
export const ThreadShape = Schema.extend(
|
|
22
|
-
ComputeShape,
|
|
23
|
-
Schema.Struct({
|
|
24
|
-
type: Schema.Literal('thread'),
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export type ThreadShape = Schema.Schema.Type<typeof ThreadShape>;
|
|
29
|
-
|
|
30
|
-
export type CreateThreadProps = CreateShapeProps<ThreadShape>;
|
|
31
|
-
|
|
32
|
-
export const createThread = (props: CreateThreadProps) =>
|
|
33
|
-
createShape<ThreadShape>({ type: 'thread', size: { width: 384, height: 384 }, ...props });
|
|
11
|
+
import { Box } from './common';
|
|
12
|
+
import { type ThreadShape } from './thread-def';
|
|
34
13
|
|
|
35
14
|
export const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) => {
|
|
36
15
|
const items: any[] = [];
|
|
@@ -79,13 +58,3 @@ export const ThreadItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
79
58
|
</div>
|
|
80
59
|
);
|
|
81
60
|
};
|
|
82
|
-
|
|
83
|
-
export const threadShape: ShapeDef<ThreadShape> = {
|
|
84
|
-
type: 'thread',
|
|
85
|
-
name: 'Thread',
|
|
86
|
-
icon: 'ph--chats-circle--regular',
|
|
87
|
-
component: ThreadComponent,
|
|
88
|
-
createShape: createThread,
|
|
89
|
-
getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),
|
|
90
|
-
resizable: true,
|
|
91
|
-
};
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -2,54 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import React, { useEffect } from 'react';
|
|
7
6
|
|
|
8
|
-
import { Trigger
|
|
7
|
+
import { Trigger } from '@dxos/compute';
|
|
9
8
|
import { VoidInput } from '@dxos/conductor';
|
|
10
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
11
10
|
import { type Mutable } from '@dxos/echo/Obj';
|
|
12
|
-
import { type SpaceId } from '@dxos/keys';
|
|
13
11
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
14
12
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
15
|
-
import { type ShapeComponentProps
|
|
13
|
+
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
16
14
|
|
|
17
|
-
import { FunctionBody,
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
const TriggerShapeSchema = Schema.extend(
|
|
21
|
-
ComputeShape,
|
|
22
|
-
Schema.Struct({
|
|
23
|
-
type: Schema.Literal('trigger'),
|
|
24
|
-
functionTrigger: Schema.optional(Ref.Ref(Trigger.Trigger)),
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// TODO(wittjosiah): Try to clean up this type inference.
|
|
29
|
-
export interface TriggerShape extends ComputeShape {
|
|
30
|
-
type: 'trigger';
|
|
31
|
-
functionTrigger?: Ref.Ref<Trigger.Trigger>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const TriggerShape: Schema.Schema<TriggerShape> = TriggerShapeSchema as any;
|
|
35
|
-
|
|
36
|
-
export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
|
|
37
|
-
spaceId?: SpaceId;
|
|
38
|
-
triggerKind?: Trigger.Kind;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
|
|
42
|
-
const functionTrigger = Trigger.make({
|
|
43
|
-
enabled: true,
|
|
44
|
-
spec: createTriggerSpec(props),
|
|
45
|
-
});
|
|
46
|
-
return createShape<TriggerShape>({
|
|
47
|
-
type: 'trigger',
|
|
48
|
-
functionTrigger: Ref.make(functionTrigger),
|
|
49
|
-
size: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },
|
|
50
|
-
...props,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
15
|
+
import { FunctionBody, getHeight } from './common';
|
|
16
|
+
import { type TriggerShape } from './trigger-def';
|
|
17
|
+
import { createTriggerSpec, getOutputSchema } from './trigger-spec';
|
|
53
18
|
|
|
54
19
|
export type TriggerComponentProps = ShapeComponentProps<TriggerShape>;
|
|
55
20
|
|
|
@@ -115,41 +80,3 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
115
80
|
</Select.Root>
|
|
116
81
|
);
|
|
117
82
|
};
|
|
118
|
-
|
|
119
|
-
const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {
|
|
120
|
-
const kind = props.triggerKind ?? 'email';
|
|
121
|
-
switch (kind) {
|
|
122
|
-
case 'timer':
|
|
123
|
-
return Trigger.specTimer('*/10 * * * * *');
|
|
124
|
-
case 'webhook':
|
|
125
|
-
return Trigger.specWebhook({ method: 'POST' });
|
|
126
|
-
case 'subscription':
|
|
127
|
-
return Trigger.specSubscription(Query.select(Filter.nothing()));
|
|
128
|
-
case 'email':
|
|
129
|
-
return Trigger.specEmail();
|
|
130
|
-
case 'feed': {
|
|
131
|
-
return { kind: 'feed' } satisfies Trigger.FeedSpec;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
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
|
-
['feed']: TriggerEvent.FeedEvent,
|
|
143
|
-
};
|
|
144
|
-
return kindToSchema[kind];
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export const triggerShape: ShapeDef<TriggerShape> = {
|
|
148
|
-
type: 'trigger',
|
|
149
|
-
name: 'Trigger',
|
|
150
|
-
icon: 'ph--lightning--regular',
|
|
151
|
-
component: TriggerComponent,
|
|
152
|
-
createShape: createTrigger,
|
|
153
|
-
getAnchors: (shape) =>
|
|
154
|
-
createFunctionAnchors(shape, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? 'email')),
|
|
155
|
-
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { AppendInput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { AppendComponent } from './Append';
|
|
11
|
+
import { createFunctionAnchors, getHeight } from './common';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Append.tsx`: react-refresh only fast-refreshes a module whose
|
|
15
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
16
|
+
|
|
17
|
+
export const AppendShape = Schema.extend(
|
|
18
|
+
ComputeShape,
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
type: Schema.Literal('append'),
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type AppendShape = Schema.Schema.Type<typeof AppendShape>;
|
|
25
|
+
|
|
26
|
+
export type CreateAppendProps = CreateShapeProps<AppendShape>;
|
|
27
|
+
|
|
28
|
+
export const createAppend = (props: CreateAppendProps) =>
|
|
29
|
+
createShape<AppendShape>({
|
|
30
|
+
type: 'append',
|
|
31
|
+
size: { width: 128, height: getHeight(AppendInput) },
|
|
32
|
+
...props,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const appendShape: ShapeDef<AppendShape> = {
|
|
36
|
+
type: 'append',
|
|
37
|
+
name: 'Append',
|
|
38
|
+
icon: 'ph--list-plus--regular',
|
|
39
|
+
component: AppendComponent,
|
|
40
|
+
createShape: createAppend,
|
|
41
|
+
getAnchors: (shape) => createFunctionAnchors(shape, AppendInput),
|
|
42
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { ReducerInput, ReducerOutput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { ReducerComponent } from './Array';
|
|
11
|
+
import { createFunctionAnchors, getHeight } from './common';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Array.tsx`: react-refresh only fast-refreshes a module whose
|
|
15
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Data
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const ReducerShape = Schema.extend(
|
|
22
|
+
ComputeShape,
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal('reducer'),
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type ReducerShape = Schema.Schema.Type<typeof ReducerShape>;
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// Defs
|
|
32
|
+
//
|
|
33
|
+
|
|
34
|
+
export type CreateReduceProps = CreateShapeProps<ReducerShape> & { reduce?: string };
|
|
35
|
+
|
|
36
|
+
export const createReducer = ({
|
|
37
|
+
id,
|
|
38
|
+
size = { width: 192, height: getHeight(ReducerInput) },
|
|
39
|
+
...rest
|
|
40
|
+
}: CreateReduceProps): ReducerShape =>
|
|
41
|
+
createShape<ReducerShape>({
|
|
42
|
+
type: 'reducer',
|
|
43
|
+
size,
|
|
44
|
+
...rest,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const reducerShape: ShapeDef<ReducerShape> = {
|
|
48
|
+
type: 'reducer',
|
|
49
|
+
name: 'Reducer',
|
|
50
|
+
icon: 'ph--repeat--regular',
|
|
51
|
+
component: ReducerComponent,
|
|
52
|
+
createShape: createReducer,
|
|
53
|
+
getAnchors: (shape) => createFunctionAnchors(shape, ReducerInput, ReducerOutput),
|
|
54
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
8
|
+
|
|
9
|
+
import { AudioComponent } from './Audio';
|
|
10
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
11
|
+
|
|
12
|
+
// Kept out of `Audio.tsx`: react-refresh only fast-refreshes a module whose
|
|
13
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
14
|
+
|
|
15
|
+
export const AudioShape = Schema.extend(
|
|
16
|
+
ComputeShape,
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
type: Schema.Literal('audio'),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type AudioShape = Schema.Schema.Type<typeof AudioShape>;
|
|
23
|
+
|
|
24
|
+
export type CreateAudioProps = CreateShapeProps<AudioShape>;
|
|
25
|
+
|
|
26
|
+
export const createAudio = (props: CreateAudioProps) =>
|
|
27
|
+
createShape<AudioShape>({ type: 'audio', size: { width: 64, height: 64 }, ...props });
|
|
28
|
+
|
|
29
|
+
export const audioShape: ShapeDef<AudioShape> = {
|
|
30
|
+
type: 'audio',
|
|
31
|
+
name: 'Audio',
|
|
32
|
+
icon: 'ph--microphone--regular',
|
|
33
|
+
component: AudioComponent,
|
|
34
|
+
createShape: createAudio,
|
|
35
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
36
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
8
|
+
|
|
9
|
+
import { BeaconComponent } from './Beacon';
|
|
10
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
11
|
+
|
|
12
|
+
// Kept out of `Beacon.tsx`: react-refresh only fast-refreshes a module whose
|
|
13
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
14
|
+
|
|
15
|
+
export const BeaconShape = Schema.extend(
|
|
16
|
+
ComputeShape,
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
type: Schema.Literal('beacon'),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type BeaconShape = Schema.Schema.Type<typeof BeaconShape>;
|
|
23
|
+
|
|
24
|
+
export type CreateBeaconProps = CreateShapeProps<BeaconShape>;
|
|
25
|
+
|
|
26
|
+
export const createBeacon = (props: CreateBeaconProps) =>
|
|
27
|
+
createShape<BeaconShape>({ type: 'beacon', size: { width: 64, height: 64 }, ...props });
|
|
28
|
+
|
|
29
|
+
export const beaconShape: ShapeDef<BeaconShape> = {
|
|
30
|
+
type: 'beacon',
|
|
31
|
+
name: 'Beacon',
|
|
32
|
+
icon: 'ph--sun--regular',
|
|
33
|
+
component: BeaconComponent,
|
|
34
|
+
createShape: createBeacon,
|
|
35
|
+
getAnchors: (shape) =>
|
|
36
|
+
createAnchorMap(shape, {
|
|
37
|
+
[createAnchorId('input')]: { x: -1, y: 0 },
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
|
|
11
|
+
import { TextInputComponent } from './Chat';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Chat.tsx`: react-refresh only fast-refreshes a module whose
|
|
15
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Data
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const ChatShape = Schema.extend(
|
|
22
|
+
ComputeShape,
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal('chat'),
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type ChatShape = Schema.Schema.Type<typeof ChatShape>;
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// Defs
|
|
32
|
+
//
|
|
33
|
+
|
|
34
|
+
export type CreateChatProps = CreateShapeProps<ChatShape>;
|
|
35
|
+
|
|
36
|
+
export const createChat = (props: CreateChatProps) =>
|
|
37
|
+
createShape<ChatShape>({ type: 'chat', size: { width: 256, height: 128 }, ...props });
|
|
38
|
+
|
|
39
|
+
export const chatShape: ShapeDef<ChatShape> = {
|
|
40
|
+
type: 'chat',
|
|
41
|
+
name: 'Chat',
|
|
42
|
+
icon: 'ph--textbox--regular',
|
|
43
|
+
component: (props) => <TextInputComponent {...props} title={'Prompt'} placeholder={'Message'} />,
|
|
44
|
+
createShape: createChat,
|
|
45
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
46
|
+
resizable: true,
|
|
47
|
+
};
|
|
@@ -9,9 +9,6 @@ import { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
|
9
9
|
import { type CanvasBoard, useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { mx } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
|
-
export const headerHeight = 32;
|
|
13
|
-
export const footerHeight = 32;
|
|
14
|
-
|
|
15
12
|
export type BoxActionHandler = (action: 'run' | 'open' | 'close') => void;
|
|
16
13
|
|
|
17
14
|
export type BoxProps = PropsWithChildren<
|
|
@@ -32,7 +29,7 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
32
29
|
|
|
33
30
|
return (
|
|
34
31
|
<div ref={forwardedRef} className='flex flex-col h-full w-full justify-between'>
|
|
35
|
-
<div className='flex shrink-0 w-full justify-between items-center h-[32px]
|
|
32
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>
|
|
36
33
|
<Icon icon={icon} classNames='mx-2' />
|
|
37
34
|
<div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>
|
|
38
35
|
<IconButton
|
|
@@ -49,7 +46,7 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
49
46
|
/>
|
|
50
47
|
</div>
|
|
51
48
|
<div className={mx('flex flex-col h-full grow overflow-hidden', classNames)}>{children}</div>
|
|
52
|
-
<div className='flex shrink-0 w-full justify-between items-center h-[32px]
|
|
49
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>
|
|
53
50
|
<div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>
|
|
54
51
|
{openable && (
|
|
55
52
|
<IconButton
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type * as Schema from 'effect/Schema';
|
|
6
|
-
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
6
|
import React, { type JSX, useRef, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
10
9
|
import { useCanvasContext } from '@dxos/react-ui-canvas';
|
|
11
|
-
import { type CanvasBoard
|
|
12
|
-
import {
|
|
10
|
+
import { type CanvasBoard } from '@dxos/react-ui-canvas-editor';
|
|
11
|
+
import { getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
13
12
|
|
|
14
|
-
import { Box, type BoxProps
|
|
15
|
-
import {
|
|
13
|
+
import { Box, type BoxProps } from '../common';
|
|
14
|
+
import { getProperties } from '../defs';
|
|
15
|
+
import { bodyPadding } from './function-anchors';
|
|
16
16
|
|
|
17
|
-
const bodyPadding = 8;
|
|
18
17
|
const expandedHeight = 200;
|
|
19
18
|
|
|
20
19
|
export type FunctionBodyProps = {
|
|
@@ -70,7 +69,7 @@ export const FunctionBody = ({
|
|
|
70
69
|
ref={rootRef}
|
|
71
70
|
shape={shape}
|
|
72
71
|
title={name}
|
|
73
|
-
classNames='divide-y divide-separator'
|
|
72
|
+
classNames='divide-y divide-subdued-separator'
|
|
74
73
|
open={open}
|
|
75
74
|
onAction={handleAction}
|
|
76
75
|
{...props}
|
|
@@ -106,21 +105,3 @@ export const FunctionBody = ({
|
|
|
106
105
|
</Box>
|
|
107
106
|
);
|
|
108
107
|
};
|
|
109
|
-
|
|
110
|
-
export const getHeight = (input: Schema.Schema<any>) => {
|
|
111
|
-
const properties = SchemaAST.getPropertySignatures(input.ast);
|
|
112
|
-
return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const createFunctionAnchors = (
|
|
116
|
-
shape: Polygon,
|
|
117
|
-
input: Schema.Schema<any> = VoidInput,
|
|
118
|
-
output: Schema.Schema<any> = VoidOutput,
|
|
119
|
-
) => {
|
|
120
|
-
// TODO(burdon): Set type.
|
|
121
|
-
const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));
|
|
122
|
-
const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>
|
|
123
|
-
createAnchorId('output', name.toString()),
|
|
124
|
-
);
|
|
125
|
-
return createAnchors({ shape, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 + 1 } });
|
|
126
|
-
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// Kept out of `Box.tsx`: react-refresh only fast-refreshes a module whose
|
|
6
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
7
|
+
|
|
8
|
+
export const headerHeight = 32;
|
|
9
|
+
|
|
10
|
+
export const footerHeight = 32;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
|
|
8
|
+
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
9
|
+
import { type Polygon } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { createAnchors, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
11
|
+
|
|
12
|
+
import { footerHeight, headerHeight } from '../common';
|
|
13
|
+
import { createAnchorId } from '../defs';
|
|
14
|
+
|
|
15
|
+
// Kept out of `FunctionBody.tsx`: react-refresh only fast-refreshes a module whose
|
|
16
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
17
|
+
|
|
18
|
+
/** Vertical padding inside the function body; the height maths below depends on it. */
|
|
19
|
+
export const bodyPadding = 8;
|
|
20
|
+
|
|
21
|
+
export const getHeight = (input: Schema.Schema<any>) => {
|
|
22
|
+
const properties = SchemaAST.getPropertySignatures(input.ast);
|
|
23
|
+
return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const createFunctionAnchors = (
|
|
27
|
+
shape: Polygon,
|
|
28
|
+
input: Schema.Schema<any> = VoidInput,
|
|
29
|
+
output: Schema.Schema<any> = VoidOutput,
|
|
30
|
+
) => {
|
|
31
|
+
// TODO(burdon): Set type.
|
|
32
|
+
const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));
|
|
33
|
+
const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>
|
|
34
|
+
createAnchorId('output', name.toString()),
|
|
35
|
+
);
|
|
36
|
+
return createAnchors({ shape, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 + 1 } });
|
|
37
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
|
|
11
|
+
import { ConstantComponent } from './Constant';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Constant.tsx`: react-refresh only fast-refreshes a module whose
|
|
15
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Data
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const ConstantShape = Schema.extend(
|
|
22
|
+
ComputeShape,
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal('constant'),
|
|
25
|
+
value: Schema.optional(Schema.Any),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export type ConstantShape = Schema.Schema.Type<typeof ConstantShape>;
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Defs
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
export type CreateConstantProps = CreateShapeProps<ConstantShape>;
|
|
36
|
+
|
|
37
|
+
export const createConstant = (props: CreateConstantProps) =>
|
|
38
|
+
createShape<ConstantShape>({ type: 'constant', size: { width: 192, height: 128 }, ...props });
|
|
39
|
+
|
|
40
|
+
export const constantShape: ShapeDef<ConstantShape> = {
|
|
41
|
+
type: 'constant',
|
|
42
|
+
name: 'Value',
|
|
43
|
+
icon: 'ph--dots-three-circle--regular',
|
|
44
|
+
component: (props) => <ConstantComponent {...props} placeholder={'Constant'} />,
|
|
45
|
+
createShape: createConstant,
|
|
46
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
47
|
+
resizable: true,
|
|
48
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
8
|
+
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { DatabaseComponent } from './Database';
|
|
11
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
12
|
+
|
|
13
|
+
// Kept out of `Database.tsx`: react-refresh only fast-refreshes a module whose
|
|
14
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
15
|
+
|
|
16
|
+
export const DatabaseShape = Schema.extend(
|
|
17
|
+
ComputeShape,
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
type: Schema.Literal('database'),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type DatabaseShape = Schema.Schema.Type<typeof DatabaseShape>;
|
|
24
|
+
|
|
25
|
+
export type CreateDatabaseProps = CreateShapeProps<DatabaseShape>;
|
|
26
|
+
|
|
27
|
+
export const createDatabase = (props: CreateDatabaseProps) =>
|
|
28
|
+
createShape<DatabaseShape>({ type: 'database', size: { width: 128, height: 64 }, ...props });
|
|
29
|
+
|
|
30
|
+
export const databaseShape: ShapeDef<DatabaseShape> = {
|
|
31
|
+
type: 'database',
|
|
32
|
+
name: 'ECHO',
|
|
33
|
+
icon: 'ph--database--regular',
|
|
34
|
+
component: DatabaseComponent,
|
|
35
|
+
createShape: createDatabase,
|
|
36
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
37
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { QueueInput, QueueOutput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { createFunctionAnchors } from './common';
|
|
11
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
12
|
+
import { FeedComponent } from './Feed';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Feed.tsx`: react-refresh only fast-refreshes a module whose
|
|
15
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
16
|
+
|
|
17
|
+
export const FeedShape = Schema.extend(
|
|
18
|
+
ComputeShape,
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
type: Schema.Literal('queue'),
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type FeedShape = Schema.Schema.Type<typeof FeedShape>;
|
|
25
|
+
|
|
26
|
+
export type CreateFeedProps = CreateShapeProps<FeedShape>;
|
|
27
|
+
|
|
28
|
+
export const createFeed = (props: CreateFeedProps) =>
|
|
29
|
+
createShape<FeedShape>({
|
|
30
|
+
type: 'queue',
|
|
31
|
+
size: { width: 256, height: 512 },
|
|
32
|
+
...props,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const feedShape: ShapeDef<FeedShape> = {
|
|
36
|
+
// Must match the shape's `type` literal ('queue') so the registry resolves it; the registry is keyed by this.
|
|
37
|
+
type: 'queue',
|
|
38
|
+
name: 'Feed',
|
|
39
|
+
icon: 'ph--queue--regular',
|
|
40
|
+
component: FeedComponent,
|
|
41
|
+
createShape: createFeed,
|
|
42
|
+
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
43
|
+
resizable: true,
|
|
44
|
+
};
|