@dxos/react-ui-canvas-compute 0.8.3 → 0.8.4-main.03d5cd7b56

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 (128) hide show
  1. package/dist/lib/browser/index.mjs +1053 -1266
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +1053 -1266
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  8. package/dist/types/src/compute-layout.d.ts.map +1 -1
  9. package/dist/types/src/compute.stories.d.ts +33 -5
  10. package/dist/types/src/compute.stories.d.ts.map +1 -1
  11. package/dist/types/src/graph/controller.d.ts +45 -27
  12. package/dist/types/src/graph/controller.d.ts.map +1 -1
  13. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  14. package/dist/types/src/hooks/useComputeGraphController.d.ts +2 -2
  15. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  16. package/dist/types/src/hooks/useComputeNodeState.d.ts +4 -4
  17. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  18. package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
  19. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  20. package/dist/types/src/json.test.d.ts +1 -1
  21. package/dist/types/src/json.test.d.ts.map +1 -1
  22. package/dist/types/src/shapes/Append.d.ts +2 -2
  23. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  24. package/dist/types/src/shapes/Array.d.ts +2 -2
  25. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Audio.d.ts +2 -2
  27. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Beacon.d.ts +2 -2
  29. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  30. package/dist/types/src/shapes/Boolean.d.ts +8 -8
  31. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  32. package/dist/types/src/shapes/Chat.d.ts +2 -2
  33. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  34. package/dist/types/src/shapes/Constant.d.ts +2 -2
  35. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  36. package/dist/types/src/shapes/Database.d.ts +2 -2
  37. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  38. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +10 -10
  39. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  40. package/dist/types/src/shapes/Function.d.ts +2 -2
  41. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  42. package/dist/types/src/shapes/Gpt.d.ts +2 -2
  43. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  44. package/dist/types/src/shapes/GptRealtime.d.ts +2 -2
  45. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  46. package/dist/types/src/shapes/Json.d.ts +3 -3
  47. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  48. package/dist/types/src/shapes/Logic.d.ts +3 -3
  49. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  50. package/dist/types/src/shapes/RNG.d.ts +3 -3
  51. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  52. package/dist/types/src/shapes/Scope.d.ts +2 -2
  53. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  54. package/dist/types/src/shapes/Surface.d.ts +2 -2
  55. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  56. package/dist/types/src/shapes/Switch.d.ts +2 -2
  57. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  58. package/dist/types/src/shapes/Table.d.ts +2 -2
  59. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  60. package/dist/types/src/shapes/Template.d.ts +3 -3
  61. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  62. package/dist/types/src/shapes/Text.d.ts +2 -2
  63. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  64. package/dist/types/src/shapes/TextToImage.d.ts +2 -2
  65. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  66. package/dist/types/src/shapes/Thread.d.ts +2 -2
  67. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  68. package/dist/types/src/shapes/Trigger.d.ts +8 -35
  69. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  70. package/dist/types/src/shapes/common/Box.d.ts +4 -4
  71. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  72. package/dist/types/src/shapes/common/FunctionBody.d.ts +3 -3
  73. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  74. package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
  75. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  76. package/dist/types/src/shapes/defs.d.ts +3 -2
  77. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  78. package/dist/types/src/shapes/index.d.ts +2 -2
  79. package/dist/types/src/shapes/index.d.ts.map +1 -1
  80. package/dist/types/src/testing/circuits.d.ts +18 -24
  81. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  82. package/dist/types/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +61 -54
  84. package/src/README.md +0 -3
  85. package/src/compute-layout.ts +1 -1
  86. package/src/compute.stories.tsx +104 -140
  87. package/src/graph/controller.ts +153 -81
  88. package/src/graph/node-defs.ts +34 -33
  89. package/src/hooks/useComputeGraphController.ts +2 -2
  90. package/src/hooks/useComputeNodeState.ts +9 -8
  91. package/src/hooks/useGraphMonitor.ts +11 -10
  92. package/src/json.test.ts +4 -4
  93. package/src/registry.ts +4 -4
  94. package/src/schema.test.ts +13 -13
  95. package/src/shapes/Append.tsx +3 -3
  96. package/src/shapes/Array.tsx +3 -3
  97. package/src/shapes/Audio.tsx +4 -4
  98. package/src/shapes/Beacon.tsx +4 -5
  99. package/src/shapes/Boolean.tsx +4 -4
  100. package/src/shapes/Chat.tsx +3 -3
  101. package/src/shapes/Constant.tsx +3 -3
  102. package/src/shapes/Database.tsx +2 -2
  103. package/src/shapes/{Queue.tsx → Feed.tsx} +29 -23
  104. package/src/shapes/Function.tsx +19 -16
  105. package/src/shapes/Gpt.tsx +12 -6
  106. package/src/shapes/GptRealtime.tsx +2 -2
  107. package/src/shapes/Json.tsx +12 -5
  108. package/src/shapes/Logic.tsx +3 -3
  109. package/src/shapes/RNG.tsx +9 -6
  110. package/src/shapes/Scope.tsx +4 -4
  111. package/src/shapes/Surface.tsx +15 -6
  112. package/src/shapes/Switch.tsx +3 -3
  113. package/src/shapes/Table.tsx +7 -6
  114. package/src/shapes/Template.tsx +5 -5
  115. package/src/shapes/Text.tsx +4 -4
  116. package/src/shapes/TextToImage.tsx +2 -2
  117. package/src/shapes/Thread.tsx +16 -13
  118. package/src/shapes/Trigger.tsx +47 -59
  119. package/src/shapes/common/Box.tsx +7 -10
  120. package/src/shapes/common/FunctionBody.tsx +5 -4
  121. package/src/shapes/common/TypeSelect.tsx +1 -1
  122. package/src/shapes/defs.ts +5 -4
  123. package/src/shapes/index.ts +2 -2
  124. package/src/testing/circuits.ts +10 -19
  125. package/dist/lib/node/index.cjs +0 -2896
  126. package/dist/lib/node/index.cjs.map +0 -7
  127. package/dist/lib/node/meta.json +0 -1
  128. package/dist/types/src/shapes/Queue.d.ts.map +0 -1
@@ -2,44 +2,44 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import { describe, test } from 'vitest';
7
7
 
8
- import { live } from '@dxos/client/echo';
9
- import { BaseGraphNode, Graph } from '@dxos/graph';
8
+ import { Graph } from '@dxos/graph';
10
9
  import {
10
+ CanvasBoard,
11
+ CanvasGraphModel,
11
12
  Polygon,
12
13
  createEllipse,
13
14
  createPath,
14
15
  createRectangle,
15
16
  isPath,
16
17
  isPolygon,
17
- Shape,
18
18
  } from '@dxos/react-ui-canvas-editor';
19
19
 
20
- import { createSwitch, ComputeShape, createFunction } from './shapes';
20
+ import { ComputeShape, createFunction, createSwitch } from './shapes';
21
21
 
22
22
  describe('compute', () => {
23
23
  test('model', ({ expect }) => {
24
- // const model = CanvasGraphModel.create<ComputeShape>();
24
+ const model = CanvasGraphModel.create<ComputeShape>();
25
25
  const node = createSwitch({ id: 'x', center: { x: 0, y: 0 }, size: { width: 80, height: 80 } });
26
26
  console.log(JSON.stringify(node, null, 2));
27
27
  expect(Schema.is(ComputeShape)(node)).toBe(true);
28
28
  expect(Schema.is(Polygon)(node)).toBe(true);
29
- expect(Schema.is(Shape)(node)).toBe(true);
30
- expect(Schema.is(BaseGraphNode)(node)).toBe(true);
29
+ expect(Schema.is(CanvasBoard.Shape)(node)).toBe(true);
30
+ expect(Schema.is(Graph.Node)(node)).toBe(true);
31
31
 
32
- const graph = live(Graph, { nodes: [], edges: [] });
33
- graph.nodes.push(node); // Throws.
32
+ const graph: Graph.Any = { nodes: [], edges: [] };
33
+ graph.nodes.push(node);
34
34
 
35
- // model.createNode(node);
36
- // console.log(JSON.stringify(model, null, 2));
35
+ model.createNode(node);
36
+ console.log(JSON.stringify(model, null, 2));
37
37
  });
38
38
  });
39
39
 
40
40
  describe('schema', () => {
41
41
  test('basic types', ({ expect }) => {
42
- const shapes: Shape[] = [];
42
+ const shapes: CanvasBoard.Shape[] = [];
43
43
  shapes.push(createRectangle({ id: 'shape-1', center: { x: 0, y: 0 }, size: { width: 80, height: 80 } }));
44
44
  shapes.push(createEllipse({ id: 'shape-2', center: { x: 0, y: 0 }, size: { width: 80, height: 80 } }));
45
45
  shapes.push(createFunction({ id: 'shape-3', center: { x: 0, y: 0 } }));
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { AppendInput } from '@dxos/conductor';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
 
11
- import { createFunctionAnchors, FunctionBody, getHeight } from './common';
12
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
11
+ import { FunctionBody, createFunctionAnchors, getHeight } from './common';
12
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
13
13
 
14
14
  export const AppendShape = Schema.extend(
15
15
  ComputeShape,
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { ReducerInput, ReducerOutput } from '@dxos/conductor';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
 
11
- import { createFunctionAnchors, FunctionBody, getHeight } from './common';
12
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
11
+ import { FunctionBody, createFunctionAnchors, getHeight } from './common';
12
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
13
13
 
14
14
  //
15
15
  // Data
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useEffect, useState } from 'react';
7
7
 
8
8
  import { Icon } from '@dxos/react-ui';
9
- import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
9
+ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
10
10
 
11
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
12
11
  import { useComputeNodeState } from '../hooks';
12
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
13
13
 
14
14
  export const AudioShape = Schema.extend(
15
15
  ComputeShape,
@@ -37,7 +37,7 @@ export const AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {
37
37
  <div className='flex w-full justify-center items-center'>
38
38
  <Icon
39
39
  icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}
40
- classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-red-500']}
40
+ classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}
41
41
  size={8}
42
42
  onClick={() => setActive(!active)}
43
43
  />
@@ -2,16 +2,15 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { DEFAULT_INPUT, isTruthy } from '@dxos/conductor';
9
9
  import { Icon } from '@dxos/react-ui';
10
- import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
- import { mx } from '@dxos/react-ui-theme';
10
+ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
12
11
 
13
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
14
12
  import { useComputeNodeState } from '../hooks';
13
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
15
14
 
16
15
  export const BeaconShape = Schema.extend(
17
16
  ComputeShape,
@@ -36,7 +35,7 @@ export const BeaconComponent = ({ shape }: ShapeComponentProps<BeaconShape>) =>
36
35
  <div className='flex w-full justify-center items-center'>
37
36
  <Icon
38
37
  icon='ph--sun--regular'
39
- classNames={mx('transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500')}
38
+ classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}
40
39
  size={8}
41
40
  />
42
41
  </div>
@@ -2,13 +2,13 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { type FC } from 'react';
7
7
 
8
- import { getAnchorPoints, type ShapeDef } from '@dxos/react-ui-canvas-editor';
8
+ import { type ShapeDef, getAnchorPoints } from '@dxos/react-ui-canvas-editor';
9
9
  import { createAnchors } from '@dxos/react-ui-canvas-editor';
10
10
 
11
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
11
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
12
12
 
13
13
  //
14
14
  // Gate utils.
@@ -95,7 +95,7 @@ const createSymbol =
95
95
  const paths = pathConstructor({ startX, endX, height });
96
96
 
97
97
  return (
98
- <svg viewBox={`0 0 ${width} ${height}`} className='w-full h-full'>
98
+ <svg viewBox={`0 0 ${width} ${height}`} className='h-full w-full'>
99
99
  {/* Input line. */}
100
100
  {getAnchorPoints({ x: 0, y: centerY }, inputs).map(({ x, y }, i) => (
101
101
  <line key={i} x1={x} y1={y} x2={startX * 1.3} y2={y} strokeWidth={strokeWidth} className={className} />
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useRef } from 'react';
7
7
 
8
8
  import { DEFAULT_OUTPUT } from '@dxos/conductor';
@@ -15,9 +15,9 @@ import {
15
15
  } from '@dxos/react-ui-canvas-editor';
16
16
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
17
17
 
18
- import { Box } from './common';
19
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
20
18
  import { useComputeNodeState } from '../hooks';
19
+ import { Box } from './common';
20
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
21
21
 
22
22
  //
23
23
  // Data
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useCallback, useRef, useState } from 'react';
7
7
 
8
8
  import { ComputeValueType } from '@dxos/conductor';
@@ -17,9 +17,9 @@ import {
17
17
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
18
18
  import { safeParseJson } from '@dxos/util';
19
19
 
20
- import { Box, TypeSelect } from './common';
21
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
22
20
  import { useComputeNodeState } from '../hooks';
21
+ import { Box, TypeSelect } from './common';
22
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
23
23
 
24
24
  //
25
25
  // Data
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
9
9
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
10
10
 
11
11
  import { Box } from './common';
12
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
12
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
13
13
 
14
14
  export const DatabaseShape = Schema.extend(
15
15
  ComputeShape,
@@ -2,34 +2,38 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { Fragment } from 'react';
7
7
 
8
8
  import { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';
9
- import { type ThemedClassName } from '@dxos/react-ui';
9
+ import { ScrollArea, type ThemedClassName } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
- import { mx } from '@dxos/react-ui-theme';
11
+ import { mx } from '@dxos/ui-theme';
12
12
 
13
+ import { useComputeNodeState } from '../hooks';
13
14
  import { createFunctionAnchors } from './common';
14
15
  import { Box, type BoxActionHandler } from './common';
15
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
16
- import { useComputeNodeState } from '../hooks';
16
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
17
17
 
18
- export const QueueShape = Schema.extend(
18
+ export const FeedShape = Schema.extend(
19
19
  ComputeShape,
20
20
  Schema.Struct({
21
21
  type: Schema.Literal('queue'),
22
22
  }),
23
23
  );
24
24
 
25
- export type QueueShape = Schema.Schema.Type<typeof QueueShape>;
25
+ export type FeedShape = Schema.Schema.Type<typeof FeedShape>;
26
26
 
27
- export type CreateQueueProps = CreateShapeProps<QueueShape>;
27
+ export type CreateFeedProps = CreateShapeProps<FeedShape>;
28
28
 
29
- export const createQueue = (props: CreateQueueProps) =>
30
- createShape<QueueShape>({ type: 'queue', size: { width: 256, height: 512 }, ...props });
29
+ export const createFeed = (props: CreateFeedProps) =>
30
+ createShape<FeedShape>({
31
+ type: 'queue',
32
+ size: { width: 256, height: 512 },
33
+ ...props,
34
+ });
31
35
 
32
- export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
36
+ export const FeedComponent = ({ shape }: ShapeComponentProps<FeedShape>) => {
33
37
  const { runtime } = useComputeNodeState(shape);
34
38
  const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];
35
39
 
@@ -41,22 +45,24 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
41
45
 
42
46
  return (
43
47
  <Box shape={shape} status={`${items.length} items`} onAction={handleAction}>
44
- <div className='flex flex-col w-full overflow-y-scroll divide-y divide-separator'>
45
- {[...items].map((item, i) => (
46
- <QueueItem key={i} classNames='p-1 px-2' item={item} />
47
- ))}
48
- </div>
48
+ <ScrollArea.Root orientation='vertical'>
49
+ <ScrollArea.Viewport classNames='divide-y divide-separator'>
50
+ {[...items].map((item, i) => (
51
+ <FeedItem key={i} classNames='p-1 px-2' item={item} />
52
+ ))}
53
+ </ScrollArea.Viewport>
54
+ </ScrollArea.Root>
49
55
  </Box>
50
56
  );
51
57
  };
52
58
 
53
- export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
59
+ export const FeedItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
54
60
  if (typeof item !== 'object') {
55
61
  return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;
56
62
  }
57
63
 
58
64
  return (
59
- <div className={mx('grid grid-cols-[80px,1fr]', classNames)}>
65
+ <div className={mx('grid grid-cols-[80px_1fr]', classNames)}>
60
66
  {Object.entries(item).map(([key, value]) => (
61
67
  <Fragment key={key}>
62
68
  <div className='p-1 text-xs text-subdued'>{key}</div>
@@ -67,12 +73,12 @@ export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
67
73
  );
68
74
  };
69
75
 
70
- export const queueShape: ShapeDef<QueueShape> = {
71
- type: 'queue',
72
- name: 'Queue',
76
+ export const feedShape: ShapeDef<FeedShape> = {
77
+ type: 'feed',
78
+ name: 'Feed',
73
79
  icon: 'ph--queue--regular',
74
- component: QueueComponent,
75
- createShape: createQueue,
80
+ component: FeedComponent,
81
+ createShape: createFeed,
76
82
  getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
77
83
  resizable: true,
78
84
  };
@@ -2,25 +2,26 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useCallback, useRef } from 'react';
7
7
 
8
+ import { Script } from '@dxos/compute';
9
+ import { Operation } from '@dxos/compute';
8
10
  import { AnyOutput, FunctionInput } from '@dxos/conductor';
9
- import { getSnapshot, isInstanceOf, Ref } from '@dxos/echo-schema';
10
- import { FunctionType, ScriptType } from '@dxos/functions';
11
+ import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
11
12
  import { useClient } from '@dxos/react-client';
12
- import { Filter, makeRef, parseId } from '@dxos/react-client/echo';
13
+ import { Filter, parseId } from '@dxos/react-client/echo';
13
14
  import {
15
+ type ShapeComponentProps,
16
+ type ShapeDef,
14
17
  TextBox,
15
18
  type TextBoxControl,
16
19
  type TextBoxProps,
17
- type ShapeComponentProps,
18
- type ShapeDef,
19
20
  } from '@dxos/react-ui-canvas-editor';
20
21
 
21
- import { Box, createFunctionAnchors } from './common';
22
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
23
22
  import { useComputeNodeState } from '../hooks';
23
+ import { Box, createFunctionAnchors } from './common';
24
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
24
25
 
25
26
  export const FunctionShape = Schema.extend(
26
27
  ComputeShape,
@@ -34,7 +35,11 @@ export type FunctionShape = Schema.Schema.Type<typeof FunctionShape>;
34
35
  export type CreateFunctionProps = CreateShapeProps<FunctionShape>;
35
36
 
36
37
  export const createFunction = (props: CreateFunctionProps) =>
37
- createShape<FunctionShape>({ type: 'function', size: { width: 256, height: 192 }, ...props });
38
+ createShape<FunctionShape>({
39
+ type: 'function',
40
+ size: { width: 256, height: 192 },
41
+ ...props,
42
+ });
38
43
 
39
44
  //
40
45
  // Component
@@ -57,21 +62,19 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
57
62
 
58
63
  const space = client.spaces.get(spaceId);
59
64
  const object = space?.db.getObjectById(objectId);
60
- if (!space || !isInstanceOf(ScriptType, object)) {
65
+ if (!space || !isInstanceOf(Script.Script, object)) {
61
66
  return;
62
67
  }
63
68
 
64
- const {
65
- objects: [fn],
66
- } = await space.db.query(Filter.type(FunctionType, { source: Ref.make(object) })).run();
69
+ const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();
67
70
  if (!fn) {
68
71
  return;
69
72
  }
70
73
 
71
74
  node.value = value;
72
- node.function = makeRef(fn);
73
- node.inputSchema = getSnapshot(fn.inputSchema);
74
- node.outputSchema = getSnapshot(fn.outputSchema);
75
+ node.function = Ref.make(fn);
76
+ node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : undefined;
77
+ node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : undefined;
75
78
  },
76
79
  [client, node],
77
80
  );
@@ -2,16 +2,16 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useEffect, useState } from 'react';
7
7
 
8
- import { type GenerationStreamEvent } from '@dxos/ai';
9
8
  import { GptInput, GptOutput } from '@dxos/conductor';
9
+ import { ScrollArea } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
 
12
- import { createFunctionAnchors, FunctionBody, getHeight } from './common';
13
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
14
12
  import { useComputeNodeState } from '../hooks';
13
+ import { FunctionBody, createFunctionAnchors, getHeight } from './common';
14
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
15
15
 
16
16
  export const GptShape = Schema.extend(
17
17
  ComputeShape,
@@ -43,8 +43,10 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
43
43
  setText('');
44
44
  break;
45
45
  }
46
+
46
47
  case 'custom': {
47
- const token: GenerationStreamEvent = ev.event;
48
+ // TODO(burdon): Any?
49
+ const token = ev.event;
48
50
  switch (token.type) {
49
51
  case 'content_block_delta':
50
52
  switch (token.delta.type) {
@@ -72,7 +74,11 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
72
74
  return (
73
75
  <FunctionBody
74
76
  shape={shape}
75
- content={<div className='px-2 py-1 overflow-y-scroll'>{text}</div>}
77
+ content={
78
+ <ScrollArea.Root orientation='vertical' thin>
79
+ <ScrollArea.Viewport>{text}</ScrollArea.Viewport>
80
+ </ScrollArea.Root>
81
+ }
76
82
  status={`${tokens} tokens`}
77
83
  inputSchema={meta.input}
78
84
  outputSchema={meta.output}
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useState } from 'react';
7
7
 
8
8
  import { log } from '@dxos/log';
@@ -11,7 +11,7 @@ import { Icon } from '@dxos/react-ui';
11
11
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
12
12
 
13
13
  import { createFunctionAnchors } from './common';
14
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
14
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
15
15
 
16
16
  export const GptRealtimeShape = Schema.extend(
17
17
  ComputeShape,
@@ -2,17 +2,17 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
11
- import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
11
+ import { Syntax } from '@dxos/react-ui-syntax-highlighter';
12
12
 
13
- import { createFunctionAnchors, getHeight, Box } from './common';
14
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
15
13
  import { useComputeNodeState } from '../hooks';
14
+ import { Box, createFunctionAnchors, getHeight } from './common';
15
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
16
16
 
17
17
  //
18
18
  // Data
@@ -49,7 +49,14 @@ export const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {
49
49
 
50
50
  return (
51
51
  <Box shape={shape}>
52
- <JsonFilter data={value} classNames='text-xs' />
52
+ <Syntax.Root data={value}>
53
+ <Syntax.Content>
54
+ <Syntax.Filter />
55
+ <Syntax.Viewport>
56
+ <Syntax.Code classNames='text-xs' />
57
+ </Syntax.Viewport>
58
+ </Syntax.Content>
59
+ </Syntax.Root>
53
60
  </Box>
54
61
  );
55
62
  };
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
 
11
- import { createFunctionAnchors, FunctionBody, getHeight } from './common';
12
- import { ComputeShape, createShape, type CreateShapeProps } from './defs';
11
+ import { FunctionBody, createFunctionAnchors, getHeight } from './common';
12
+ import { ComputeShape, type CreateShapeProps, createShape } from './defs';
13
13
 
14
14
  //
15
15
  // Data
@@ -2,16 +2,15 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useEffect, useState } from 'react';
7
7
 
8
8
  import { DEFAULT_OUTPUT } from '@dxos/conductor';
9
9
  import { Icon, type IconProps } from '@dxos/react-ui';
10
- import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
- import { mx } from '@dxos/react-ui-theme';
10
+ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
12
11
 
13
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
14
12
  import { useComputeNodeState } from '../hooks';
13
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
15
14
 
16
15
  export const RandomShape = Schema.extend(
17
16
  ComputeShape,
@@ -27,7 +26,11 @@ export type RandomShape = Schema.Schema.Type<typeof RandomShape>;
27
26
  export type CreateRandomProps = CreateShapeProps<RandomShape>;
28
27
 
29
28
  export const createRandom = (props: CreateRandomProps) =>
30
- createShape<RandomShape>({ type: 'rng', size: { width: 64, height: 64 }, ...props });
29
+ createShape<RandomShape>({
30
+ type: 'rng',
31
+ size: { width: 64, height: 64 },
32
+ ...props,
33
+ });
31
34
 
32
35
  const icons = [
33
36
  'ph--dice-one--regular',
@@ -69,7 +72,7 @@ export const RandomComponent = ({ shape }: ShapeComponentProps<RandomShape>) =>
69
72
 
70
73
  return (
71
74
  <div className='flex grow items-center justify-center'>
72
- <Icon icon={icon} classNames={mx(spin && 'animate-[spin_1s]')} size={10} onClick={handleClick} />
75
+ <Icon icon={icon} classNames={spin && 'animate-[spin_1s]'} size={10} onClick={handleClick} />
73
76
  </div>
74
77
  );
75
78
  };
@@ -2,15 +2,15 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { DEFAULT_INPUT } from '@dxos/conductor';
9
- import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
- import { useAudioStream, Chaos, shaderPresets } from '@dxos/react-ui-sfx';
9
+ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
10
+ import { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';
11
11
 
12
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
13
12
  import { useComputeNodeState } from '../hooks';
13
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
14
14
 
15
15
  export const ScopeShape = Schema.extend(
16
16
  ComputeShape,
@@ -2,17 +2,19 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
- import { Surface } from '@dxos/app-framework';
8
+ import { Surface } from '@dxos/app-framework/ui';
9
+ import { AppSurface } from '@dxos/app-toolkit/ui';
9
10
  import { DEFAULT_INPUT } from '@dxos/conductor';
11
+ import { Card } from '@dxos/react-ui';
10
12
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
13
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
12
14
 
13
- import { Box, type BoxActionHandler } from './common';
14
- import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
15
15
  import { useComputeNodeState } from '../hooks';
16
+ import { Box, type BoxActionHandler } from './common';
17
+ import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
16
18
 
17
19
  export const SurfaceShape = Schema.extend(
18
20
  ComputeShape,
@@ -26,7 +28,11 @@ export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
26
28
  export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
27
29
 
28
30
  export const createSurface = (props: CreateSurfaceProps) =>
29
- createShape<SurfaceShape>({ type: 'surface', size: { width: 384, height: 384 }, ...props });
31
+ createShape<SurfaceShape>({
32
+ type: 'surface',
33
+ size: { width: 384, height: 384 },
34
+ ...props,
35
+ });
30
36
 
31
37
  export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) => {
32
38
  const { runtime } = useComputeNodeState(shape);
@@ -39,9 +45,12 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
39
45
  }
40
46
  };
41
47
 
48
+ // TODO(burdon): Subject property?
42
49
  return (
43
50
  <Box shape={shape} onAction={handleAction}>
44
- {value !== null && <Surface role='canvas-node' data={{ value }} limit={1} />}
51
+ <Card.Root>
52
+ {value !== null && <Surface.Surface type={AppSurface.Card} data={{ subject: value }} limit={1} />}
53
+ </Card.Root>
45
54
  </Box>
46
55
  );
47
56
  };