@dxos/react-ui-canvas-compute 0.8.3 → 0.8.4-main.1068cf700f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +938 -1074
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +938 -1074
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +33 -5
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +40 -27
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +2 -2
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +4 -3
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +1 -1
- package/dist/types/src/json.test.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +1 -1
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +6 -34
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +4 -4
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +3 -3
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +2 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -52
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +84 -139
- package/src/graph/controller.ts +121 -80
- package/src/graph/node-defs.ts +7 -6
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +10 -7
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +4 -4
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +13 -13
- package/src/shapes/Append.tsx +3 -3
- package/src/shapes/Array.tsx +3 -3
- package/src/shapes/Audio.tsx +5 -4
- package/src/shapes/Beacon.tsx +6 -6
- package/src/shapes/Boolean.tsx +5 -5
- package/src/shapes/Chat.tsx +4 -3
- package/src/shapes/Constant.tsx +4 -3
- package/src/shapes/Database.tsx +2 -2
- package/src/shapes/Function.tsx +19 -16
- package/src/shapes/Gpt.tsx +13 -6
- package/src/shapes/GptRealtime.tsx +3 -3
- package/src/shapes/Json.tsx +4 -3
- package/src/shapes/Logic.tsx +3 -3
- package/src/shapes/Queue.tsx +18 -11
- package/src/shapes/RNG.tsx +10 -6
- package/src/shapes/Scope.tsx +6 -5
- package/src/shapes/Surface.tsx +11 -6
- package/src/shapes/Switch.tsx +5 -4
- package/src/shapes/Table.tsx +7 -6
- package/src/shapes/Template.tsx +6 -5
- package/src/shapes/Text.tsx +5 -4
- package/src/shapes/TextToImage.tsx +2 -2
- package/src/shapes/Thread.tsx +22 -15
- package/src/shapes/Trigger.tsx +51 -58
- package/src/shapes/common/Box.tsx +10 -11
- package/src/shapes/common/FunctionBody.tsx +7 -6
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +5 -4
- package/src/testing/circuits.ts +8 -17
- package/dist/lib/node/index.cjs +0 -2896
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/src/shapes/Beacon.tsx
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 {
|
|
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';
|
|
15
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
16
16
|
export const BeaconShape = Schema.extend(
|
|
17
17
|
ComputeShape,
|
|
18
18
|
Schema.Struct({
|
|
@@ -33,10 +33,10 @@ export const BeaconComponent = ({ shape }: ShapeComponentProps<BeaconShape>) =>
|
|
|
33
33
|
const value = input?.type === 'executed' ? input.value : false;
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<div className='flex
|
|
36
|
+
<div className='flex is-full justify-center items-center'>
|
|
37
37
|
<Icon
|
|
38
38
|
icon='ph--sun--regular'
|
|
39
|
-
classNames={
|
|
39
|
+
classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}
|
|
40
40
|
size={8}
|
|
41
41
|
/>
|
|
42
42
|
</div>
|
package/src/shapes/Boolean.tsx
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { type FC } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
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
|
|
11
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
12
12
|
|
|
13
13
|
//
|
|
14
14
|
// Gate utils.
|
|
@@ -57,7 +57,7 @@ const defineShape = <S extends GateShape>({
|
|
|
57
57
|
// Be careful not to name component factories with a capital letter.
|
|
58
58
|
component: () => {
|
|
59
59
|
return (
|
|
60
|
-
<div className='flex
|
|
60
|
+
<div className='flex is-full justify-center items-center'>
|
|
61
61
|
<Symbol />
|
|
62
62
|
</div>
|
|
63
63
|
);
|
|
@@ -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='
|
|
98
|
+
<svg viewBox={`0 0 ${width} ${height}`} className='is-full bs-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} />
|
package/src/shapes/Chat.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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,10 +15,11 @@ 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';
|
|
21
19
|
|
|
20
|
+
import { Box } from './common';
|
|
21
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
22
|
+
|
|
22
23
|
//
|
|
23
24
|
// Data
|
|
24
25
|
//
|
package/src/shapes/Constant.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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,10 +17,11 @@ 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';
|
|
23
21
|
|
|
22
|
+
import { Box, TypeSelect } from './common';
|
|
23
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
24
|
+
|
|
24
25
|
//
|
|
25
26
|
// Data
|
|
26
27
|
//
|
package/src/shapes/Database.tsx
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
13
|
|
|
14
14
|
export const DatabaseShape = Schema.extend(
|
|
15
15
|
ComputeShape,
|
package/src/shapes/Function.tsx
CHANGED
|
@@ -2,26 +2,27 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { AnyOutput, FunctionInput } from '@dxos/conductor';
|
|
9
|
-
import { getSnapshot, isInstanceOf
|
|
10
|
-
import {
|
|
9
|
+
import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
|
|
10
|
+
import { Function, Script } from '@dxos/functions';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter,
|
|
12
|
+
import { Filter, parseId } from '@dxos/react-client/echo';
|
|
13
13
|
import {
|
|
14
|
+
type ShapeComponentProps,
|
|
15
|
+
type ShapeDef,
|
|
14
16
|
TextBox,
|
|
15
17
|
type TextBoxControl,
|
|
16
18
|
type TextBoxProps,
|
|
17
|
-
type ShapeComponentProps,
|
|
18
|
-
type ShapeDef,
|
|
19
19
|
} from '@dxos/react-ui-canvas-editor';
|
|
20
20
|
|
|
21
|
-
import { Box, createFunctionAnchors } from './common';
|
|
22
|
-
import { ComputeShape, createShape, type CreateShapeProps } from './defs';
|
|
23
21
|
import { useComputeNodeState } from '../hooks';
|
|
24
22
|
|
|
23
|
+
import { Box, createFunctionAnchors } from './common';
|
|
24
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
25
|
+
|
|
25
26
|
export const FunctionShape = Schema.extend(
|
|
26
27
|
ComputeShape,
|
|
27
28
|
Schema.Struct({
|
|
@@ -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>({
|
|
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(
|
|
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(Function.Function, { source: Ref.make(object) })).run();
|
|
67
70
|
if (!fn) {
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
node.value = value;
|
|
72
|
-
node.function =
|
|
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
|
);
|
package/src/shapes/Gpt.tsx
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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';
|
|
15
13
|
|
|
14
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
15
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
16
|
+
|
|
16
17
|
export const GptShape = Schema.extend(
|
|
17
18
|
ComputeShape,
|
|
18
19
|
Schema.Struct({
|
|
@@ -43,8 +44,10 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
43
44
|
setText('');
|
|
44
45
|
break;
|
|
45
46
|
}
|
|
47
|
+
|
|
46
48
|
case 'custom': {
|
|
47
|
-
|
|
49
|
+
// TODO(burdon): Any?
|
|
50
|
+
const token = ev.event;
|
|
48
51
|
switch (token.type) {
|
|
49
52
|
case 'content_block_delta':
|
|
50
53
|
switch (token.delta.type) {
|
|
@@ -72,7 +75,11 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
72
75
|
return (
|
|
73
76
|
<FunctionBody
|
|
74
77
|
shape={shape}
|
|
75
|
-
content={
|
|
78
|
+
content={
|
|
79
|
+
<ScrollArea.Root orientation='vertical' thin>
|
|
80
|
+
<ScrollArea.Viewport>{text}</ScrollArea.Viewport>
|
|
81
|
+
</ScrollArea.Root>
|
|
82
|
+
}
|
|
76
83
|
status={`${tokens} tokens`}
|
|
77
84
|
inputSchema={meta.input}
|
|
78
85
|
outputSchema={meta.output}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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,
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
15
15
|
|
|
16
16
|
export const GptRealtimeShape = Schema.extend(
|
|
17
17
|
ComputeShape,
|
|
@@ -143,7 +143,7 @@ export const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeS
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
return (
|
|
146
|
-
<div className='flex
|
|
146
|
+
<div className='flex is-full justify-center items-center'>
|
|
147
147
|
<Icon
|
|
148
148
|
icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}
|
|
149
149
|
size={16}
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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';
|
|
@@ -10,10 +10,11 @@ import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-e
|
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { JsonFilter } 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';
|
|
16
14
|
|
|
15
|
+
import { Box, createFunctionAnchors, getHeight } from './common';
|
|
16
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
|
+
|
|
17
18
|
//
|
|
18
19
|
// Data
|
|
19
20
|
//
|
package/src/shapes/Logic.tsx
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 {
|
|
12
|
-
import { ComputeShape,
|
|
11
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
13
13
|
|
|
14
14
|
//
|
|
15
15
|
// Data
|
package/src/shapes/Queue.tsx
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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/
|
|
11
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
|
+
|
|
13
|
+
import { useComputeNodeState } from '../hooks';
|
|
12
14
|
|
|
13
15
|
import { createFunctionAnchors } from './common';
|
|
14
16
|
import { Box, type BoxActionHandler } from './common';
|
|
15
|
-
import { ComputeShape,
|
|
16
|
-
import { useComputeNodeState } from '../hooks';
|
|
17
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
17
18
|
|
|
18
19
|
export const QueueShape = Schema.extend(
|
|
19
20
|
ComputeShape,
|
|
@@ -27,7 +28,11 @@ export type QueueShape = Schema.Schema.Type<typeof QueueShape>;
|
|
|
27
28
|
export type CreateQueueProps = CreateShapeProps<QueueShape>;
|
|
28
29
|
|
|
29
30
|
export const createQueue = (props: CreateQueueProps) =>
|
|
30
|
-
createShape<QueueShape>({
|
|
31
|
+
createShape<QueueShape>({
|
|
32
|
+
type: 'queue',
|
|
33
|
+
size: { width: 256, height: 512 },
|
|
34
|
+
...props,
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
33
38
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -41,11 +46,13 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
41
46
|
|
|
42
47
|
return (
|
|
43
48
|
<Box shape={shape} status={`${items.length} items`} onAction={handleAction}>
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
<ScrollArea.Root orientation='vertical'>
|
|
50
|
+
<ScrollArea.Viewport classNames='divide-y divide-separator'>
|
|
51
|
+
{[...items].map((item, i) => (
|
|
52
|
+
<QueueItem key={i} classNames='p-1 pli-2' item={item} />
|
|
53
|
+
))}
|
|
54
|
+
</ScrollArea.Viewport>
|
|
55
|
+
</ScrollArea.Root>
|
|
49
56
|
</Box>
|
|
50
57
|
);
|
|
51
58
|
};
|
package/src/shapes/RNG.tsx
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 {
|
|
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';
|
|
15
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
16
16
|
export const RandomShape = Schema.extend(
|
|
17
17
|
ComputeShape,
|
|
18
18
|
Schema.Struct({
|
|
@@ -27,7 +27,11 @@ export type RandomShape = Schema.Schema.Type<typeof RandomShape>;
|
|
|
27
27
|
export type CreateRandomProps = CreateShapeProps<RandomShape>;
|
|
28
28
|
|
|
29
29
|
export const createRandom = (props: CreateRandomProps) =>
|
|
30
|
-
createShape<RandomShape>({
|
|
30
|
+
createShape<RandomShape>({
|
|
31
|
+
type: 'rng',
|
|
32
|
+
size: { width: 64, height: 64 },
|
|
33
|
+
...props,
|
|
34
|
+
});
|
|
31
35
|
|
|
32
36
|
const icons = [
|
|
33
37
|
'ph--dice-one--regular',
|
|
@@ -69,7 +73,7 @@ export const RandomComponent = ({ shape }: ShapeComponentProps<RandomShape>) =>
|
|
|
69
73
|
|
|
70
74
|
return (
|
|
71
75
|
<div className='flex grow items-center justify-center'>
|
|
72
|
-
<Icon icon={icon} classNames={
|
|
76
|
+
<Icon icon={icon} classNames={spin && 'animate-[spin_1s]'} size={10} onClick={handleClick} />
|
|
73
77
|
</div>
|
|
74
78
|
);
|
|
75
79
|
};
|
package/src/shapes/Scope.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 {
|
|
10
|
-
import {
|
|
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';
|
|
14
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
15
16
|
export const ScopeShape = Schema.extend(
|
|
16
17
|
ComputeShape,
|
|
17
18
|
Schema.Struct({
|
|
@@ -38,7 +39,7 @@ export const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {
|
|
|
38
39
|
const { getAverage } = useAudioStream(active);
|
|
39
40
|
|
|
40
41
|
return (
|
|
41
|
-
<div className='flex
|
|
42
|
+
<div className='flex is-full justify-center items-center bg-black'>
|
|
42
43
|
<Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />
|
|
43
44
|
</div>
|
|
44
45
|
);
|
package/src/shapes/Surface.tsx
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
9
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
12
12
|
|
|
13
|
-
import { Box, type BoxActionHandler } from './common';
|
|
14
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
15
13
|
import { useComputeNodeState } from '../hooks';
|
|
16
14
|
|
|
15
|
+
import { Box, type BoxActionHandler } from './common';
|
|
16
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
|
+
|
|
17
18
|
export const SurfaceShape = Schema.extend(
|
|
18
19
|
ComputeShape,
|
|
19
20
|
Schema.Struct({
|
|
@@ -26,7 +27,11 @@ export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
|
|
|
26
27
|
export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
|
|
27
28
|
|
|
28
29
|
export const createSurface = (props: CreateSurfaceProps) =>
|
|
29
|
-
createShape<SurfaceShape>({
|
|
30
|
+
createShape<SurfaceShape>({
|
|
31
|
+
type: 'surface',
|
|
32
|
+
size: { width: 384, height: 384 },
|
|
33
|
+
...props,
|
|
34
|
+
});
|
|
30
35
|
|
|
31
36
|
export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) => {
|
|
32
37
|
const { runtime } = useComputeNodeState(shape);
|
|
@@ -41,7 +46,7 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
|
|
|
41
46
|
|
|
42
47
|
return (
|
|
43
48
|
<Box shape={shape} onAction={handleAction}>
|
|
44
|
-
{value !== null && <Surface role='
|
|
49
|
+
{value !== null && <Surface.Surface role='card--extrinsic' data={{ value }} limit={1} />}
|
|
45
50
|
</Box>
|
|
46
51
|
);
|
|
47
52
|
};
|
package/src/shapes/Switch.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 { Input } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
10
|
+
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
13
12
|
import { useComputeNodeState } from '../hooks';
|
|
14
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
15
16
|
export const SwitchShape = Schema.extend(
|
|
16
17
|
ComputeShape,
|
|
17
18
|
Schema.Struct({
|
|
@@ -35,7 +36,7 @@ export const SwitchComponent = ({ shape }: ShapeComponentProps<SwitchShape>) =>
|
|
|
35
36
|
}, [value]);
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
|
-
<div className='flex
|
|
39
|
+
<div className='flex is-full justify-center items-center' onClick={(ev) => ev.stopPropagation()}>
|
|
39
40
|
<Input.Root>
|
|
40
41
|
<Input.Switch checked={value} onCheckedChange={(value) => setValue(value)} />
|
|
41
42
|
</Input.Root>
|
package/src/shapes/Table.tsx
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { createInputSchema, createOutputSchema
|
|
8
|
+
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { Message } from '@dxos/types';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
import { ComputeShape,
|
|
12
|
+
import { Box, createFunctionAnchors } from './common';
|
|
13
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
13
14
|
|
|
14
|
-
const InputSchema = createInputSchema(
|
|
15
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(
|
|
15
|
+
const InputSchema = createInputSchema(Message.Message);
|
|
16
|
+
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));
|
|
16
17
|
|
|
17
18
|
export const TableShape = Schema.extend(
|
|
18
19
|
ComputeShape,
|
package/src/shapes/Template.tsx
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import { ComputeValueType,
|
|
9
|
-
import { toJsonSchema } from '@dxos/echo
|
|
8
|
+
import { ComputeValueType, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';
|
|
9
|
+
import { toJsonSchema } from '@dxos/echo/internal';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import {
|
|
12
12
|
type ShapeComponentProps,
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
type TextBoxProps,
|
|
17
17
|
} from '@dxos/react-ui-canvas-editor';
|
|
18
18
|
|
|
19
|
-
import { Box, createFunctionAnchors, TypeSelect } from './common';
|
|
20
|
-
import { ComputeShape, createShape, type CreateShapeProps } from './defs';
|
|
21
19
|
import { useComputeNodeState } from '../hooks';
|
|
22
20
|
|
|
21
|
+
import { Box, TypeSelect, createFunctionAnchors } from './common';
|
|
22
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
23
|
+
|
|
23
24
|
//
|
|
24
25
|
// Data
|
|
25
26
|
//
|
package/src/shapes/Text.tsx
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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 {
|
|
9
|
+
import { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
|
-
import { Box, type BoxActionHandler } from './common';
|
|
13
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
14
12
|
import { useComputeNodeState } from '../hooks';
|
|
15
13
|
|
|
14
|
+
import { Box, type BoxActionHandler } from './common';
|
|
15
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
16
|
+
|
|
16
17
|
export const TextShape = Schema.extend(
|
|
17
18
|
ComputeShape,
|
|
18
19
|
Schema.Struct({
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
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
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
13
|
|
|
14
14
|
export const TextToImageShape = Schema.extend(
|
|
15
15
|
ComputeShape,
|