@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.
Files changed (171) hide show
  1. package/dist/lib/index.mjs +2164 -0
  2. package/dist/lib/index.mjs.map +1 -0
  3. package/dist/types/src/compute.stories.d.ts.map +1 -1
  4. package/dist/types/src/shapes/Append.d.ts +2 -51
  5. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  6. package/dist/types/src/shapes/Array.d.ts +2 -34
  7. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  8. package/dist/types/src/shapes/Audio.d.ts +2 -51
  9. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  10. package/dist/types/src/shapes/Beacon.d.ts +2 -51
  11. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  12. package/dist/types/src/shapes/Chat.d.ts +2 -51
  13. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  14. package/dist/types/src/shapes/Constant.d.ts +2 -53
  15. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  16. package/dist/types/src/shapes/Database.d.ts +2 -51
  17. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  18. package/dist/types/src/shapes/Feed.d.ts +2 -51
  19. package/dist/types/src/shapes/Feed.d.ts.map +1 -1
  20. package/dist/types/src/shapes/Function.d.ts +7 -50
  21. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  22. package/dist/types/src/shapes/Gpt.d.ts +2 -51
  23. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  24. package/dist/types/src/shapes/GptRealtime.d.ts +2 -51
  25. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Json.d.ts +2 -101
  27. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Logic.d.ts +2 -103
  29. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  30. package/dist/types/src/shapes/RNG.d.ts +2 -55
  31. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  32. package/dist/types/src/shapes/Scope.d.ts +2 -51
  33. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  34. package/dist/types/src/shapes/Surface.d.ts +2 -51
  35. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  36. package/dist/types/src/shapes/Switch.d.ts +2 -51
  37. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  38. package/dist/types/src/shapes/Table.d.ts +2 -51
  39. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  40. package/dist/types/src/shapes/Template.d.ts +4 -55
  41. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  42. package/dist/types/src/shapes/Text.d.ts +2 -51
  43. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  44. package/dist/types/src/shapes/TextToImage.d.ts +2 -51
  45. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  46. package/dist/types/src/shapes/Thread.d.ts +2 -51
  47. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  48. package/dist/types/src/shapes/Trigger.d.ts +2 -17
  49. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  50. package/dist/types/src/shapes/append-def.d.ts +52 -0
  51. package/dist/types/src/shapes/append-def.d.ts.map +1 -0
  52. package/dist/types/src/shapes/array-def.d.ts +35 -0
  53. package/dist/types/src/shapes/array-def.d.ts.map +1 -0
  54. package/dist/types/src/shapes/audio-def.d.ts +52 -0
  55. package/dist/types/src/shapes/audio-def.d.ts.map +1 -0
  56. package/dist/types/src/shapes/beacon-def.d.ts +52 -0
  57. package/dist/types/src/shapes/beacon-def.d.ts.map +1 -0
  58. package/dist/types/src/shapes/chat-def.d.ts +52 -0
  59. package/dist/types/src/shapes/chat-def.d.ts.map +1 -0
  60. package/dist/types/src/shapes/common/Box.d.ts +0 -2
  61. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  62. package/dist/types/src/shapes/common/FunctionBody.d.ts +1 -3
  63. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  64. package/dist/types/src/shapes/common/box-defs.d.ts +3 -0
  65. package/dist/types/src/shapes/common/box-defs.d.ts.map +1 -0
  66. package/dist/types/src/shapes/common/function-anchors.d.ts +7 -0
  67. package/dist/types/src/shapes/common/function-anchors.d.ts.map +1 -0
  68. package/dist/types/src/shapes/common/index.d.ts +2 -0
  69. package/dist/types/src/shapes/common/index.d.ts.map +1 -1
  70. package/dist/types/src/shapes/constant-def.d.ts +54 -0
  71. package/dist/types/src/shapes/constant-def.d.ts.map +1 -0
  72. package/dist/types/src/shapes/database-def.d.ts +52 -0
  73. package/dist/types/src/shapes/database-def.d.ts.map +1 -0
  74. package/dist/types/src/shapes/feed-def.d.ts +52 -0
  75. package/dist/types/src/shapes/feed-def.d.ts.map +1 -0
  76. package/dist/types/src/shapes/function-def.d.ts +52 -0
  77. package/dist/types/src/shapes/function-def.d.ts.map +1 -0
  78. package/dist/types/src/shapes/gpt-def.d.ts +52 -0
  79. package/dist/types/src/shapes/gpt-def.d.ts.map +1 -0
  80. package/dist/types/src/shapes/gpt-realtime-def.d.ts +52 -0
  81. package/dist/types/src/shapes/gpt-realtime-def.d.ts.map +1 -0
  82. package/dist/types/src/shapes/index.d.ts +23 -0
  83. package/dist/types/src/shapes/index.d.ts.map +1 -1
  84. package/dist/types/src/shapes/json-def.d.ts +102 -0
  85. package/dist/types/src/shapes/json-def.d.ts.map +1 -0
  86. package/dist/types/src/shapes/logic-def.d.ts +104 -0
  87. package/dist/types/src/shapes/logic-def.d.ts.map +1 -0
  88. package/dist/types/src/shapes/rng-def.d.ts +56 -0
  89. package/dist/types/src/shapes/rng-def.d.ts.map +1 -0
  90. package/dist/types/src/shapes/scope-def.d.ts +52 -0
  91. package/dist/types/src/shapes/scope-def.d.ts.map +1 -0
  92. package/dist/types/src/shapes/surface-def.d.ts +52 -0
  93. package/dist/types/src/shapes/surface-def.d.ts.map +1 -0
  94. package/dist/types/src/shapes/switch-def.d.ts +52 -0
  95. package/dist/types/src/shapes/switch-def.d.ts.map +1 -0
  96. package/dist/types/src/shapes/table-def.d.ts +52 -0
  97. package/dist/types/src/shapes/table-def.d.ts.map +1 -0
  98. package/dist/types/src/shapes/template-def.d.ts +56 -0
  99. package/dist/types/src/shapes/template-def.d.ts.map +1 -0
  100. package/dist/types/src/shapes/text-def.d.ts +52 -0
  101. package/dist/types/src/shapes/text-def.d.ts.map +1 -0
  102. package/dist/types/src/shapes/text-to-image-def.d.ts +52 -0
  103. package/dist/types/src/shapes/text-to-image-def.d.ts.map +1 -0
  104. package/dist/types/src/shapes/thread-def.d.ts +52 -0
  105. package/dist/types/src/shapes/thread-def.d.ts.map +1 -0
  106. package/dist/types/src/shapes/trigger-def.d.ts +18 -0
  107. package/dist/types/src/shapes/trigger-def.d.ts.map +1 -0
  108. package/dist/types/src/shapes/trigger-spec.d.ts +9 -0
  109. package/dist/types/src/shapes/trigger-spec.d.ts.map +1 -0
  110. package/dist/types/tsconfig.tsbuildinfo +1 -1
  111. package/package.json +43 -46
  112. package/src/compute.stories.tsx +1 -1
  113. package/src/shapes/Append.tsx +3 -31
  114. package/src/shapes/Array.tsx +3 -43
  115. package/src/shapes/Audio.tsx +2 -26
  116. package/src/shapes/Beacon.tsx +2 -29
  117. package/src/shapes/Chat.tsx +1 -36
  118. package/src/shapes/Constant.tsx +1 -37
  119. package/src/shapes/Database.tsx +2 -27
  120. package/src/shapes/Feed.tsx +4 -35
  121. package/src/shapes/Function.tsx +4 -38
  122. package/src/shapes/Gpt.tsx +3 -33
  123. package/src/shapes/GptRealtime.tsx +2 -36
  124. package/src/shapes/Json.tsx +4 -70
  125. package/src/shapes/Logic.tsx +3 -58
  126. package/src/shapes/RNG.tsx +2 -32
  127. package/src/shapes/Scope.tsx +2 -31
  128. package/src/shapes/Surface.tsx +2 -32
  129. package/src/shapes/Switch.tsx +2 -26
  130. package/src/shapes/Table.tsx +3 -34
  131. package/src/shapes/Template.tsx +6 -36
  132. package/src/shapes/Text.tsx +2 -28
  133. package/src/shapes/TextToImage.tsx +2 -27
  134. package/src/shapes/Thread.tsx +3 -34
  135. package/src/shapes/Trigger.tsx +6 -79
  136. package/src/shapes/append-def.ts +42 -0
  137. package/src/shapes/array-def.ts +54 -0
  138. package/src/shapes/audio-def.ts +36 -0
  139. package/src/shapes/beacon-def.ts +39 -0
  140. package/src/shapes/chat-def.tsx +47 -0
  141. package/src/shapes/common/Box.tsx +2 -5
  142. package/src/shapes/common/FunctionBody.tsx +6 -25
  143. package/src/shapes/common/box-defs.ts +10 -0
  144. package/src/shapes/common/function-anchors.ts +37 -0
  145. package/src/shapes/common/index.ts +3 -0
  146. package/src/shapes/constant-def.tsx +48 -0
  147. package/src/shapes/database-def.ts +37 -0
  148. package/src/shapes/feed-def.ts +44 -0
  149. package/src/shapes/function-def.ts +46 -0
  150. package/src/shapes/gpt-def.ts +43 -0
  151. package/src/shapes/gpt-realtime-def.ts +46 -0
  152. package/src/shapes/index.ts +25 -0
  153. package/src/shapes/json-def.ts +80 -0
  154. package/src/shapes/logic-def.ts +69 -0
  155. package/src/shapes/rng-def.ts +42 -0
  156. package/src/shapes/scope-def.ts +41 -0
  157. package/src/shapes/surface-def.ts +42 -0
  158. package/src/shapes/switch-def.ts +36 -0
  159. package/src/shapes/table-def.ts +45 -0
  160. package/src/shapes/template-def.ts +48 -0
  161. package/src/shapes/text-def.ts +38 -0
  162. package/src/shapes/text-to-image-def.ts +37 -0
  163. package/src/shapes/thread-def.ts +45 -0
  164. package/src/shapes/trigger-def.ts +63 -0
  165. package/src/shapes/trigger-spec.ts +44 -0
  166. package/dist/lib/browser/index.mjs +0 -2596
  167. package/dist/lib/browser/index.mjs.map +0 -7
  168. package/dist/lib/browser/meta.json +0 -1
  169. package/dist/lib/node-esm/index.mjs +0 -2596
  170. package/dist/lib/node-esm/index.mjs.map +0 -7
  171. package/dist/lib/node-esm/meta.json +0 -1
@@ -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, type ShapeDef } from '@dxos/react-ui-canvas-editor';
8
+ import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
11
9
 
12
10
  import { useComputeNodeState } from '../hooks';
13
- import { FunctionBody, createFunctionAnchors, getHeight } from './common';
14
- import { ComputeShape, type CreateShapeProps, createShape } from './defs';
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, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
+ import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
12
11
 
13
- import { createFunctionAnchors } from './common';
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';
@@ -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, DefaultOutput, JsonTransformInput } from '@dxos/conductor';
9
- import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
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, createFunctionAnchors, getHeight } from './common';
15
- import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };
@@ -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, type ShapeDef } from '@dxos/react-ui-canvas-editor';
8
+ import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
10
9
 
11
- import { FunctionBody, createFunctionAnchors, getHeight } from './common';
12
- import { ComputeShape, type CreateShapeProps, createShape } from './defs';
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
- };
@@ -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, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
9
+ import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
11
10
 
12
11
  import { useComputeNodeState } from '../hooks';
13
- import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };
@@ -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, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };
@@ -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, type ShapeDef } from '@dxos/react-ui-canvas-editor';
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };
@@ -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, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
9
+ import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
11
10
 
12
11
  import { useComputeNodeState } from '../hooks';
13
- import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };
@@ -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 { createInputSchema, createOutputSchema } from '@dxos/conductor';
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, createFunctionAnchors } from './common';
14
- import { ComputeShape, type CreateShapeProps, createShape } from './defs';
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
- };
@@ -5,34 +5,19 @@
5
5
  import * as Schema from 'effect/Schema';
6
6
  import React, { useRef } from 'react';
7
7
 
8
- import { ComputeValueType, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';
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, createFunctionAnchors } from './common';
21
- import { ComputeShape, type CreateShapeProps, createShape } from './defs';
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
- // Defs
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
+ );
@@ -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, type ShapeDef, TextBox } from '@dxos/react-ui-canvas-editor';
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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, type ShapeDef } from '@dxos/react-ui-canvas-editor';
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 { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
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
- };