@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { AnyOutput, FunctionInput } 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 { FunctionShapeComponent } from './Function';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Function.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 FunctionShape = Schema.extend(
|
|
18
|
+
ComputeShape,
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
type: Schema.Literal('function'),
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type FunctionShape = Schema.Schema.Type<typeof FunctionShape>;
|
|
25
|
+
|
|
26
|
+
export type CreateFunctionProps = CreateShapeProps<FunctionShape>;
|
|
27
|
+
|
|
28
|
+
export const createFunction = (props: CreateFunctionProps) =>
|
|
29
|
+
createShape<FunctionShape>({
|
|
30
|
+
type: 'function',
|
|
31
|
+
size: { width: 256, height: 192 },
|
|
32
|
+
...props,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
//
|
|
36
|
+
// Defs
|
|
37
|
+
//
|
|
38
|
+
|
|
39
|
+
export const functionShape: ShapeDef<FunctionShape> = {
|
|
40
|
+
type: 'function',
|
|
41
|
+
name: 'Function',
|
|
42
|
+
icon: 'ph--function--regular',
|
|
43
|
+
component: FunctionShapeComponent,
|
|
44
|
+
createShape: createFunction,
|
|
45
|
+
getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput),
|
|
46
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { GptInput, GptOutput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { createFunctionAnchors, getHeight } from './common';
|
|
11
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
12
|
+
import { GptComponent } from './Gpt';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Gpt.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 GptShape = Schema.extend(
|
|
18
|
+
ComputeShape,
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
type: Schema.Literal('gpt'),
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type GptShape = Schema.Schema.Type<typeof GptShape>;
|
|
25
|
+
|
|
26
|
+
export type CreateGptProps = CreateShapeProps<GptShape>;
|
|
27
|
+
|
|
28
|
+
export const createGpt = (props: CreateGptProps) =>
|
|
29
|
+
createShape<GptShape>({
|
|
30
|
+
type: 'gpt',
|
|
31
|
+
size: { width: 256, height: Math.max(getHeight(GptInput), getHeight(GptOutput)) },
|
|
32
|
+
...props,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const gptShape: ShapeDef<GptShape> = {
|
|
36
|
+
type: 'gpt',
|
|
37
|
+
name: 'GPT',
|
|
38
|
+
icon: 'ph--brain--regular',
|
|
39
|
+
component: GptComponent,
|
|
40
|
+
createShape: createGpt,
|
|
41
|
+
getAnchors: (shape) => createFunctionAnchors(shape, GptInput, GptOutput),
|
|
42
|
+
openable: true,
|
|
43
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
|
|
9
|
+
import { createFunctionAnchors } from './common';
|
|
10
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
11
|
+
import { GptRealtimeComponent } from './GptRealtime';
|
|
12
|
+
|
|
13
|
+
// Kept out of `GptRealtime.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 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 });
|
|
29
|
+
|
|
30
|
+
export const gptRealtimeShape: ShapeDef<GptRealtimeShape> = {
|
|
31
|
+
type: 'gpt-realtime',
|
|
32
|
+
name: 'GPT Realtime',
|
|
33
|
+
icon: 'ph--pulse--regular',
|
|
34
|
+
component: GptRealtimeComponent,
|
|
35
|
+
createShape: createGptRealtime,
|
|
36
|
+
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
37
|
+
getAnchors: (shape) =>
|
|
38
|
+
createFunctionAnchors(
|
|
39
|
+
shape,
|
|
40
|
+
Schema.Struct({
|
|
41
|
+
audio: Schema.Any,
|
|
42
|
+
}),
|
|
43
|
+
Schema.Struct({}),
|
|
44
|
+
),
|
|
45
|
+
resizable: true,
|
|
46
|
+
};
|
package/src/shapes/index.ts
CHANGED
|
@@ -5,6 +5,31 @@
|
|
|
5
5
|
export * from './common';
|
|
6
6
|
export * from './defs';
|
|
7
7
|
|
|
8
|
+
// Shape schemas, factories and defs, kept out of the component modules so those can fast-refresh.
|
|
9
|
+
export * from './append-def';
|
|
10
|
+
export * from './array-def';
|
|
11
|
+
export * from './audio-def';
|
|
12
|
+
export * from './beacon-def';
|
|
13
|
+
export * from './chat-def';
|
|
14
|
+
export * from './constant-def';
|
|
15
|
+
export * from './database-def';
|
|
16
|
+
export * from './feed-def';
|
|
17
|
+
export * from './function-def';
|
|
18
|
+
export * from './gpt-def';
|
|
19
|
+
export * from './gpt-realtime-def';
|
|
20
|
+
export * from './json-def';
|
|
21
|
+
export * from './logic-def';
|
|
22
|
+
export * from './rng-def';
|
|
23
|
+
export * from './scope-def';
|
|
24
|
+
export * from './surface-def';
|
|
25
|
+
export * from './switch-def';
|
|
26
|
+
export * from './table-def';
|
|
27
|
+
export * from './template-def';
|
|
28
|
+
export * from './text-def';
|
|
29
|
+
export * from './text-to-image-def';
|
|
30
|
+
export * from './thread-def';
|
|
31
|
+
export * from './trigger-def';
|
|
32
|
+
|
|
8
33
|
export * from './Array';
|
|
9
34
|
export * from './Append';
|
|
10
35
|
export * from './Audio';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { DefaultOutput, JsonTransformInput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
|
|
11
|
+
import { createFunctionAnchors, getHeight } from './common';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
|
+
import { JsonComponent, JsonTransformComponent } from './Json';
|
|
14
|
+
|
|
15
|
+
// Kept out of `Json.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
|
+
//
|
|
19
|
+
// Data
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
export const JsonShape = Schema.extend(
|
|
23
|
+
ComputeShape,
|
|
24
|
+
Schema.Struct({
|
|
25
|
+
type: Schema.Literal('json'),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export type JsonShape = Schema.Schema.Type<typeof JsonShape>;
|
|
30
|
+
|
|
31
|
+
export const JsonTransformShape = Schema.extend(
|
|
32
|
+
ComputeShape,
|
|
33
|
+
Schema.Struct({
|
|
34
|
+
type: Schema.Literal('json-transform'),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;
|
|
39
|
+
|
|
40
|
+
//
|
|
41
|
+
// Defs
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
export type CreateJsonProps = CreateShapeProps<JsonShape>;
|
|
45
|
+
|
|
46
|
+
export const createJson = (props: CreateJsonProps) =>
|
|
47
|
+
createShape<JsonShape>({ type: 'json', size: { width: 256, height: 256 }, ...props });
|
|
48
|
+
|
|
49
|
+
export const jsonShape: ShapeDef<JsonShape> = {
|
|
50
|
+
type: 'json',
|
|
51
|
+
name: 'JSON',
|
|
52
|
+
icon: 'ph--code--regular',
|
|
53
|
+
component: JsonComponent,
|
|
54
|
+
createShape: createJson,
|
|
55
|
+
getAnchors: (shape) =>
|
|
56
|
+
createAnchorMap(shape, {
|
|
57
|
+
[createAnchorId('input')]: { x: -1, y: 0 },
|
|
58
|
+
[createAnchorId('output')]: { x: 1, y: 0 },
|
|
59
|
+
}),
|
|
60
|
+
resizable: true,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type CreateJsonTransformProps = CreateShapeProps<JsonTransformShape> & { expression?: string };
|
|
64
|
+
|
|
65
|
+
export const createJsonTransform = (props: CreateJsonTransformProps) =>
|
|
66
|
+
createShape<JsonTransformShape>({
|
|
67
|
+
type: 'json-transform',
|
|
68
|
+
size: { width: 128, height: getHeight(JsonTransformInput) },
|
|
69
|
+
...props,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const jsonTransformShape: ShapeDef<JsonTransformShape> = {
|
|
73
|
+
type: 'json-transform',
|
|
74
|
+
name: 'Transform',
|
|
75
|
+
icon: 'ph--shuffle-simple--regular',
|
|
76
|
+
component: JsonTransformComponent,
|
|
77
|
+
createShape: createJsonTransform,
|
|
78
|
+
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
79
|
+
resizable: true,
|
|
80
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';
|
|
8
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
9
|
+
|
|
10
|
+
import { createFunctionAnchors, getHeight } from './common';
|
|
11
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
12
|
+
import { IfComponent, IfElseComponent } from './Logic';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Logic.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 IfShape = Schema.extend(
|
|
22
|
+
ComputeShape,
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal('if'),
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type IfShape = Schema.Schema.Type<typeof IfShape>;
|
|
29
|
+
|
|
30
|
+
export const IfElseShape = Schema.extend(
|
|
31
|
+
ComputeShape,
|
|
32
|
+
Schema.Struct({
|
|
33
|
+
type: Schema.Literal('if-else'),
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
// Defs
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
export type CreateIfProps = CreateShapeProps<IfShape> & { if?: string };
|
|
44
|
+
|
|
45
|
+
export const createIf = (props: CreateIfProps) =>
|
|
46
|
+
createShape<IfShape>({ type: 'if', size: { width: 192, height: getHeight(IfInput) }, ...props });
|
|
47
|
+
|
|
48
|
+
export const ifShape: ShapeDef<IfShape> = {
|
|
49
|
+
type: 'if',
|
|
50
|
+
name: 'IF',
|
|
51
|
+
icon: 'ph--arrows-split--regular',
|
|
52
|
+
component: IfComponent,
|
|
53
|
+
createShape: createIf,
|
|
54
|
+
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type CreateIfElseProps = CreateShapeProps<IfShape> & { if?: string };
|
|
58
|
+
|
|
59
|
+
export const createIfElse = (props: CreateIfElseProps) =>
|
|
60
|
+
createShape<IfElseShape>({ type: 'if-else', size: { width: 192, height: getHeight(IfElseInput) }, ...props });
|
|
61
|
+
|
|
62
|
+
export const ifElseShape: ShapeDef<IfElseShape> = {
|
|
63
|
+
type: 'if-else',
|
|
64
|
+
name: 'IF/ELSE',
|
|
65
|
+
icon: 'ph--arrows-merge--regular',
|
|
66
|
+
component: IfElseComponent,
|
|
67
|
+
createShape: createIfElse,
|
|
68
|
+
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput),
|
|
69
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
10
|
+
import { RandomComponent } from './RNG';
|
|
11
|
+
|
|
12
|
+
// Kept out of `RNG.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 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
|
+
});
|
|
34
|
+
|
|
35
|
+
export const randomShape: ShapeDef<RandomShape> = {
|
|
36
|
+
type: 'rng',
|
|
37
|
+
name: 'Random',
|
|
38
|
+
icon: 'ph--dice-six--regular',
|
|
39
|
+
component: RandomComponent,
|
|
40
|
+
createShape: createRandom,
|
|
41
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
42
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
10
|
+
import { ScopeComponent } from './Scope';
|
|
11
|
+
|
|
12
|
+
// Kept out of `Scope.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 ScopeShape = Schema.extend(
|
|
16
|
+
ComputeShape,
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
type: Schema.Literal('scope'),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type ScopeShape = Schema.Schema.Type<typeof ScopeShape>;
|
|
23
|
+
|
|
24
|
+
export type CreateScopeProps = CreateShapeProps<ScopeShape>;
|
|
25
|
+
|
|
26
|
+
export const createScope = (props: CreateScopeProps) =>
|
|
27
|
+
createShape<ScopeShape>({
|
|
28
|
+
type: 'scope',
|
|
29
|
+
size: { width: 128, height: 128 },
|
|
30
|
+
classNames: 'rounded-full border-primary-800',
|
|
31
|
+
...props,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const scopeShape: ShapeDef<ScopeShape> = {
|
|
35
|
+
type: 'scope',
|
|
36
|
+
name: 'Scope',
|
|
37
|
+
icon: 'ph--waveform--regular',
|
|
38
|
+
component: ScopeComponent,
|
|
39
|
+
createShape: createScope,
|
|
40
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
11
|
+
import { SurfaceComponent } from './Surface';
|
|
12
|
+
|
|
13
|
+
// Kept out of `Surface.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 SurfaceShape = Schema.extend(
|
|
17
|
+
ComputeShape,
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
type: Schema.Literal('surface'),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
|
|
24
|
+
|
|
25
|
+
export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
|
|
26
|
+
|
|
27
|
+
export const createSurface = (props: CreateSurfaceProps) =>
|
|
28
|
+
createShape<SurfaceShape>({
|
|
29
|
+
type: 'surface',
|
|
30
|
+
size: { width: 384, height: 384 },
|
|
31
|
+
...props,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const surfaceShape: ShapeDef<SurfaceShape> = {
|
|
35
|
+
type: 'surface',
|
|
36
|
+
name: 'Surface',
|
|
37
|
+
icon: 'ph--frame-corners--regular',
|
|
38
|
+
component: SurfaceComponent,
|
|
39
|
+
createShape: createSurface,
|
|
40
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
41
|
+
resizable: true,
|
|
42
|
+
};
|
|
@@ -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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
10
|
+
import { SwitchComponent } from './Switch';
|
|
11
|
+
|
|
12
|
+
// Kept out of `Switch.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 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 });
|
|
28
|
+
|
|
29
|
+
export const switchShape: ShapeDef<SwitchShape> = {
|
|
30
|
+
type: 'switch',
|
|
31
|
+
name: 'Switch',
|
|
32
|
+
icon: 'ph--toggle-left--regular',
|
|
33
|
+
component: SwitchComponent,
|
|
34
|
+
createShape: createSwitch,
|
|
35
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
36
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
8
|
+
import { Type } from '@dxos/echo';
|
|
9
|
+
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { Message } from '@dxos/types';
|
|
11
|
+
|
|
12
|
+
import { createFunctionAnchors } from './common';
|
|
13
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
14
|
+
import { TableComponent } from './Table';
|
|
15
|
+
|
|
16
|
+
// Kept out of `Table.tsx`: react-refresh only fast-refreshes a module whose
|
|
17
|
+
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
18
|
+
|
|
19
|
+
const InputSchema = createInputSchema(Type.getSchema(Message.Message));
|
|
20
|
+
|
|
21
|
+
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));
|
|
22
|
+
|
|
23
|
+
export const TableShape = Schema.extend(
|
|
24
|
+
ComputeShape,
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
type: Schema.Literal('table'),
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export type TableShape = Schema.Schema.Type<typeof TableShape>;
|
|
31
|
+
|
|
32
|
+
export type CreateTableProps = CreateShapeProps<TableShape>;
|
|
33
|
+
|
|
34
|
+
export const createTable = (props: CreateTableProps) =>
|
|
35
|
+
createShape<TableShape>({ type: 'table', size: { width: 320, height: 512 }, ...props });
|
|
36
|
+
|
|
37
|
+
export const tableShape: ShapeDef<TableShape> = {
|
|
38
|
+
type: 'table',
|
|
39
|
+
name: 'Table',
|
|
40
|
+
icon: 'ph--table--regular',
|
|
41
|
+
component: TableComponent,
|
|
42
|
+
createShape: createTable,
|
|
43
|
+
getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),
|
|
44
|
+
resizable: true,
|
|
45
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { ComputeValueType, TemplateOutput, VoidInput } 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 { TemplateComponent } from './Template';
|
|
13
|
+
|
|
14
|
+
// Kept out of `Template.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 TemplateShape = Schema.extend(
|
|
22
|
+
ComputeShape,
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal('template'),
|
|
25
|
+
valueType: Schema.optional(ComputeValueType),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Defs
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
export type CreateTemplateProps = CreateShapeProps<TemplateShape> & { text?: string };
|
|
36
|
+
|
|
37
|
+
export const createTemplate = (props: CreateTemplateProps) =>
|
|
38
|
+
createShape<TemplateShape>({ type: 'template', size: { width: 256, height: 384 }, ...props });
|
|
39
|
+
|
|
40
|
+
export const templateShape: ShapeDef<TemplateShape> = {
|
|
41
|
+
type: 'template',
|
|
42
|
+
name: 'Template',
|
|
43
|
+
icon: 'ph--article--regular',
|
|
44
|
+
component: TemplateComponent,
|
|
45
|
+
createShape: createTemplate,
|
|
46
|
+
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput, TemplateOutput),
|
|
47
|
+
resizable: true,
|
|
48
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
11
|
+
import { TextComponent } from './Text';
|
|
12
|
+
|
|
13
|
+
// Kept out of `Text.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 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 });
|
|
29
|
+
|
|
30
|
+
export const textShape: ShapeDef<TextShape> = {
|
|
31
|
+
type: 'text',
|
|
32
|
+
name: 'Text',
|
|
33
|
+
icon: 'ph--article--regular',
|
|
34
|
+
component: TextComponent,
|
|
35
|
+
createShape: createText,
|
|
36
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),
|
|
37
|
+
resizable: true,
|
|
38
|
+
};
|
|
@@ -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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
11
|
+
import { TextToImageComponent } from './TextToImage';
|
|
12
|
+
|
|
13
|
+
// Kept out of `TextToImage.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 TextToImageShape = Schema.extend(
|
|
17
|
+
ComputeShape,
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
type: Schema.Literal('text-to-image'),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type TextToImageShape = Schema.Schema.Type<typeof TextToImageShape>;
|
|
24
|
+
|
|
25
|
+
export type CreateTextToImageProps = CreateShapeProps<TextToImageShape>;
|
|
26
|
+
|
|
27
|
+
export const createTextToImage = (props: CreateTextToImageProps) =>
|
|
28
|
+
createShape<TextToImageShape>({ type: 'text-to-image', size: { width: 128, height: 64 }, ...props });
|
|
29
|
+
|
|
30
|
+
export const textToImageShape: ShapeDef<TextToImageShape> = {
|
|
31
|
+
type: 'text-to-image',
|
|
32
|
+
name: 'Image',
|
|
33
|
+
icon: 'ph--image--regular',
|
|
34
|
+
component: TextToImageComponent,
|
|
35
|
+
createShape: createTextToImage,
|
|
36
|
+
getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),
|
|
37
|
+
};
|