@dxos/react-ui-canvas-compute 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/chunk-types.mjs +142 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/index.mjs +526 -430
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/graph/controller.d.ts +1 -1
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/compute-context.d.ts +5 -4
- package/dist/types/src/hooks/compute-context.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +18 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/registry.d.ts +5 -8
- package/dist/types/src/registry.d.ts.map +1 -1
- package/dist/types/src/scene/compute.stories.d.ts.map +1 -1
- package/dist/types/src/scene/echo-store.d.ts +1 -1
- package/dist/types/src/scene/echo-store.d.ts.map +1 -1
- package/dist/types/src/scene/index.d.ts +0 -3
- package/dist/types/src/scene/index.d.ts.map +1 -1
- package/dist/types/src/scene/projection.d.ts.map +1 -1
- package/dist/types/src/scene/scene.d.ts +2 -2
- package/dist/types/src/scene/scene.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +2 -2
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +3 -3
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +2 -2
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +2 -2
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +4 -52
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +3 -3
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +3 -4
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +2 -2
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Feed.d.ts +2 -2
- package/dist/types/src/shapes/Feed.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +3 -5
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +2 -2
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +2 -2
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +5 -5
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +5 -5
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +2 -2
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +2 -2
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +2 -2
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +2 -2
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +2 -2
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +2 -2
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +2 -2
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +2 -2
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +3 -3
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/append-def.d.ts +1 -2
- package/dist/types/src/shapes/append-def.d.ts.map +1 -1
- package/dist/types/src/shapes/array-def.d.ts +2 -3
- package/dist/types/src/shapes/array-def.d.ts.map +1 -1
- package/dist/types/src/shapes/audio-def.d.ts +1 -2
- package/dist/types/src/shapes/audio-def.d.ts.map +1 -1
- package/dist/types/src/shapes/beacon-def.d.ts +1 -2
- package/dist/types/src/shapes/beacon-def.d.ts.map +1 -1
- package/dist/types/src/shapes/chat-def.d.ts +1 -2
- package/dist/types/src/shapes/chat-def.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TextBox.d.ts +26 -0
- package/dist/types/src/shapes/common/TextBox.d.ts.map +1 -0
- package/dist/types/src/shapes/common/index.d.ts +3 -1
- package/dist/types/src/shapes/common/index.d.ts.map +1 -1
- package/dist/types/src/shapes/common/node-def.d.ts +24 -0
- package/dist/types/src/shapes/common/node-def.d.ts.map +1 -0
- package/dist/types/src/shapes/common/ports.d.ts +33 -0
- package/dist/types/src/shapes/common/ports.d.ts.map +1 -0
- package/dist/types/src/shapes/constant-def.d.ts +1 -2
- package/dist/types/src/shapes/constant-def.d.ts.map +1 -1
- package/dist/types/src/shapes/database-def.d.ts +1 -2
- package/dist/types/src/shapes/database-def.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +7 -2
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/shapes/feed-def.d.ts +1 -2
- package/dist/types/src/shapes/feed-def.d.ts.map +1 -1
- package/dist/types/src/shapes/function-def.d.ts +1 -2
- package/dist/types/src/shapes/function-def.d.ts.map +1 -1
- package/dist/types/src/shapes/gpt-def.d.ts +1 -2
- package/dist/types/src/shapes/gpt-def.d.ts.map +1 -1
- package/dist/types/src/shapes/gpt-realtime-def.d.ts +1 -2
- package/dist/types/src/shapes/gpt-realtime-def.d.ts.map +1 -1
- package/dist/types/src/shapes/json-def.d.ts +2 -3
- package/dist/types/src/shapes/json-def.d.ts.map +1 -1
- package/dist/types/src/shapes/logic-def.d.ts +2 -3
- package/dist/types/src/shapes/logic-def.d.ts.map +1 -1
- package/dist/types/src/shapes/ports.test.d.ts +2 -0
- package/dist/types/src/shapes/ports.test.d.ts.map +1 -0
- package/dist/types/src/shapes/rng-def.d.ts +1 -2
- package/dist/types/src/shapes/rng-def.d.ts.map +1 -1
- package/dist/types/src/shapes/scope-def.d.ts +1 -2
- package/dist/types/src/shapes/scope-def.d.ts.map +1 -1
- package/dist/types/src/shapes/surface-def.d.ts +1 -2
- package/dist/types/src/shapes/surface-def.d.ts.map +1 -1
- package/dist/types/src/shapes/switch-def.d.ts +1 -2
- package/dist/types/src/shapes/switch-def.d.ts.map +1 -1
- package/dist/types/src/shapes/table-def.d.ts +1 -2
- package/dist/types/src/shapes/table-def.d.ts.map +1 -1
- package/dist/types/src/shapes/template-def.d.ts +1 -2
- package/dist/types/src/shapes/template-def.d.ts.map +1 -1
- package/dist/types/src/shapes/text-def.d.ts +1 -2
- package/dist/types/src/shapes/text-def.d.ts.map +1 -1
- package/dist/types/src/shapes/text-to-image-def.d.ts +1 -2
- package/dist/types/src/shapes/text-to-image-def.d.ts.map +1 -1
- package/dist/types/src/shapes/thread-def.d.ts +1 -2
- package/dist/types/src/shapes/thread-def.d.ts.map +1 -1
- package/dist/types/src/shapes/trigger-def.d.ts +1 -2
- package/dist/types/src/shapes/trigger-def.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/src/types/canvas-board.test.d.ts +2 -0
- package/dist/types/src/types/canvas-board.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/model.d.ts +10 -0
- package/dist/types/src/types/model.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +66 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/shapes.d.ts +114 -0
- package/dist/types/src/types/shapes.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -35
- package/src/graph/controller.ts +1 -1
- package/src/hooks/compute-context.ts +7 -4
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useGraphMonitor.ts +10 -1
- package/src/index.ts +1 -1
- package/src/playwright/scene.spec.ts +3 -3
- package/src/registry.ts +63 -91
- package/src/scene/compute.stories.tsx +3 -6
- package/src/scene/echo-store.test.ts +18 -7
- package/src/scene/echo-store.ts +7 -10
- package/src/scene/index.ts +0 -3
- package/src/scene/projection.ts +2 -3
- package/src/scene/scene.test.ts +4 -4
- package/src/scene/scene.ts +6 -4
- package/src/schema.test.ts +7 -36
- package/src/shapes/Append.tsx +2 -3
- package/src/shapes/Array.tsx +3 -4
- package/src/shapes/Audio.tsx +2 -2
- package/src/shapes/Beacon.tsx +2 -2
- package/src/shapes/Boolean.tsx +32 -29
- package/src/shapes/Chat.tsx +5 -10
- package/src/shapes/Constant.tsx +19 -12
- package/src/shapes/Database.tsx +2 -4
- package/src/shapes/Feed.tsx +2 -3
- package/src/shapes/Function.tsx +4 -10
- package/src/shapes/Gpt.tsx +2 -3
- package/src/shapes/GptRealtime.tsx +2 -2
- package/src/shapes/Json.tsx +5 -6
- package/src/shapes/Logic.tsx +5 -6
- package/src/shapes/RNG.tsx +2 -2
- package/src/shapes/Scope.tsx +2 -2
- package/src/shapes/Surface.tsx +9 -6
- package/src/shapes/Switch.tsx +10 -12
- package/src/shapes/Table.tsx +2 -4
- package/src/shapes/Template.tsx +10 -9
- package/src/shapes/Text.tsx +2 -3
- package/src/shapes/TextToImage.tsx +2 -4
- package/src/shapes/Thread.tsx +2 -3
- package/src/shapes/Trigger.tsx +3 -4
- package/src/shapes/append-def.ts +8 -7
- package/src/shapes/array-def.ts +8 -8
- package/src/shapes/audio-def.ts +8 -7
- package/src/shapes/beacon-def.ts +9 -8
- package/src/shapes/chat-def.tsx +8 -8
- package/src/shapes/common/Box.tsx +7 -4
- package/src/shapes/common/FunctionBody.tsx +13 -26
- package/src/shapes/common/TextBox.tsx +137 -0
- package/src/shapes/common/index.ts +3 -1
- package/src/shapes/common/node-def.tsx +117 -0
- package/src/shapes/common/ports.ts +107 -0
- package/src/shapes/constant-def.tsx +8 -8
- package/src/shapes/database-def.ts +8 -8
- package/src/shapes/defs.ts +21 -6
- package/src/shapes/feed-def.ts +8 -7
- package/src/shapes/function-def.ts +8 -7
- package/src/shapes/gpt-def.ts +8 -7
- package/src/shapes/gpt-realtime-def.ts +10 -10
- package/src/shapes/json-def.ts +15 -13
- package/src/shapes/logic-def.ts +14 -11
- package/src/shapes/ports.test.ts +23 -0
- package/src/shapes/rng-def.ts +8 -7
- package/src/shapes/scope-def.ts +8 -7
- package/src/shapes/surface-def.ts +8 -8
- package/src/shapes/switch-def.ts +8 -7
- package/src/shapes/table-def.ts +7 -7
- package/src/shapes/template-def.ts +8 -7
- package/src/shapes/text-def.ts +8 -8
- package/src/shapes/text-to-image-def.ts +8 -8
- package/src/shapes/thread-def.ts +8 -7
- package/src/shapes/trigger-def.ts +11 -8
- package/src/testing/circuits.ts +21 -7
- package/src/types/canvas-board.test.ts +84 -0
- package/src/types/index.ts +7 -0
- package/src/types/model.ts +63 -0
- package/src/types/schema.ts +73 -0
- package/src/types/shapes.ts +73 -0
- package/dist/types/src/compute-layout.d.ts +0 -9
- package/dist/types/src/compute-layout.d.ts.map +0 -1
- package/dist/types/src/compute.stories.d.ts +0 -58
- package/dist/types/src/compute.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +0 -10
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +0 -1
- package/dist/types/src/scene/NodeView.d.ts +0 -11
- package/dist/types/src/scene/NodeView.d.ts.map +0 -1
- package/dist/types/src/scene/defs.d.ts +0 -5
- package/dist/types/src/scene/defs.d.ts.map +0 -1
- package/dist/types/src/scene/ports.d.ts +0 -5
- package/dist/types/src/scene/ports.d.ts.map +0 -1
- package/dist/types/src/shapes/common/function-anchors.d.ts +0 -12
- package/dist/types/src/shapes/common/function-anchors.d.ts.map +0 -1
- package/src/compute-layout.ts +0 -37
- package/src/compute.stories.tsx +0 -302
- package/src/hooks/useComputeGraphController.ts +0 -65
- package/src/scene/NodeView.tsx +0 -42
- package/src/scene/defs.ts +0 -158
- package/src/scene/ports.ts +0 -30
- package/src/shapes/common/function-anchors.ts +0 -44
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React, { type PropsWithChildren } from 'react';
|
|
3
|
-
import { type ComputeGraphModel } from '@dxos/conductor';
|
|
4
|
-
import { type EditorRootProps } from '@dxos/react-ui-canvas-editor';
|
|
5
|
-
import { type ComputeGraphController } from './graph/index.ts';
|
|
6
|
-
import { type ComputeShape } from './shapes/index.ts';
|
|
7
|
-
type RenderProps = EditorRootProps<ComputeShape> & PropsWithChildren<{
|
|
8
|
-
init?: boolean;
|
|
9
|
-
sidebar?: 'canvas' | 'compute' | 'controller' | 'selected';
|
|
10
|
-
computeGraph?: ComputeGraphModel;
|
|
11
|
-
controller?: ComputeGraphController | null;
|
|
12
|
-
}>;
|
|
13
|
-
declare const DefaultStory: ({ id, children, graph, controller, sidebar: sidebarProp, registry, showGrid, snapToGrid, ...props }: RenderProps) => React.JSX.Element;
|
|
14
|
-
declare const meta: {
|
|
15
|
-
title: string;
|
|
16
|
-
component: any;
|
|
17
|
-
render: typeof DefaultStory;
|
|
18
|
-
decorators: import("@storybook/react").Decorator[];
|
|
19
|
-
parameters: {
|
|
20
|
-
layout: string;
|
|
21
|
-
};
|
|
22
|
-
argTypes: {
|
|
23
|
-
controller: {
|
|
24
|
-
table: {
|
|
25
|
-
disable: boolean;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
graph: {
|
|
29
|
-
table: {
|
|
30
|
-
disable: boolean;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
registry: {
|
|
34
|
-
table: {
|
|
35
|
-
disable: boolean;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
sidebar: {
|
|
39
|
-
control: "select";
|
|
40
|
-
options: (NonNullable<"canvas" | "compute" | "controller" | "selected" | undefined> | null)[];
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export default meta;
|
|
45
|
-
type Story = StoryObj<typeof meta>;
|
|
46
|
-
export declare const Default: Story;
|
|
47
|
-
export declare const Beacon: Story;
|
|
48
|
-
export declare const Transform: Story;
|
|
49
|
-
export declare const Logic: Story;
|
|
50
|
-
export declare const Control: Story;
|
|
51
|
-
export declare const Template: Story;
|
|
52
|
-
export declare const GPT: Story;
|
|
53
|
-
export declare const Plugins: Story;
|
|
54
|
-
export declare const Artifact: Story;
|
|
55
|
-
export declare const ImageGen: Story;
|
|
56
|
-
export declare const Audio: Story;
|
|
57
|
-
export declare const Voice: Story;
|
|
58
|
-
//# sourceMappingURL=compute.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compute.stories.d.ts","sourceRoot":"","sources":["../../../src/compute.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAwC,MAAM,OAAO,CAAC;AAI5F,OAAO,EAAE,KAAK,iBAAiB,EAA0C,MAAM,iBAAiB,CAAC;AAGjG,OAAO,EAAiC,KAAK,eAAe,EAAiB,MAAM,8BAA8B,CAAC;AAUlH,OAAO,EAAE,KAAK,sBAAsB,EAAgC,MAAM,kBAAkB,CAAC;AAG7F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAqBtD,KAAK,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,GAC9C,iBAAiB,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC;IAC3D,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,UAAU,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC5C,CAAC,CAAC;AAEL,QAAA,MAAM,YAAY,wGAUf,WAAW,sBAyHb,CAAC;AAEF,QAAA,MAAM,IAAI;;eAEkB,GAAG;;;;QAU3B,MAAM;;;;;gBA3JmB,OAAO;;;;;;;;;;;;;;;;;;CAsKC,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAKpB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAKvB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,KAKjB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
import { type EditorController, type EditorRootProps } from '@dxos/react-ui-canvas-editor';
|
|
3
|
-
import { type ComputeGraphController } from '../graph/index.ts';
|
|
4
|
-
import { type ComputeShape } from '../shapes/index.ts';
|
|
5
|
-
export type UseComputeGraphControllerOptions = Pick<EditorRootProps<ComputeShape>, 'graph'> & {
|
|
6
|
-
controller: ComputeGraphController | null;
|
|
7
|
-
editorRef: RefObject<EditorController | null>;
|
|
8
|
-
};
|
|
9
|
-
export declare const useComputeGraphController: ({ controller, graph, editorRef }: UseComputeGraphControllerOptions) => void;
|
|
10
|
-
//# sourceMappingURL=useComputeGraphController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useComputeGraphController.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useComputeGraphController.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAWvD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,GAAG;IAC5F,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,yBAAyB,qCAAsC,gCAAgC,SAsC3G,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
import { type ComponentType, type FC } from 'react';
|
|
3
|
-
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
4
|
-
import { type NodeViewProps } from '@dxos/react-ui-canvas/scene';
|
|
5
|
-
import { type ComputeShape } from '../shapes/index.ts';
|
|
6
|
-
/**
|
|
7
|
-
* The shape component under the engine's view props: the node is the shape (it carries the same fields
|
|
8
|
-
* plus `z`), re-rendered on every controller update since the runtime state it reads is not reactive.
|
|
9
|
-
*/
|
|
10
|
-
export declare const computeNodeView: <S extends ComputeShape>(schema: Schema.Codec<S, unknown, never, never>, Component: FC<ShapeComponentProps<S>>) => ComponentType<NodeViewProps>;
|
|
11
|
-
//# sourceMappingURL=NodeView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeView.d.ts","sourceRoot":"","sources":["../../../../src/scene/NodeView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAc,EAAE,KAAK,aAAa,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,6BAA6B,CAAC;AAIlF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,YAAY,UAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,aACnC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KACpC,aAAa,CAAC,aAAa,CAoB7B,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type NodeDef, type NodeRegistry } from '@dxos/react-ui-canvas/scene';
|
|
2
|
-
export declare const computeNodeDefs: NodeDef[];
|
|
3
|
-
/** The compute types plus the engine's note under a `Misc` group. */
|
|
4
|
-
export declare const computeNodeRegistry: NodeRegistry;
|
|
5
|
-
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../../src/scene/defs.ts"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,YAAY,EAGlB,MAAM,6BAA6B,CAAC;AAiIrC,eAAO,MAAM,eAAe,EAAE,OAAO,EAAkC,CAAC;AAExE,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Anchor } from '@dxos/react-ui-canvas-editor';
|
|
2
|
-
import { type Port, type Size } from '@dxos/react-ui-canvas/scene';
|
|
3
|
-
/** The ports of a shape from its anchors; a port's direction comes from the `input.` / `output.` prefix. */
|
|
4
|
-
export declare const anchorsToPorts: (anchors: Record<string, Anchor>, size: Size) => Port[];
|
|
5
|
-
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../../src/scene/ports.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAInE,4GAA4G;AAC5G,eAAO,MAAM,cAAc,YAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAG,IAAI,EAc7E,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as Schema from 'effect/Schema';
|
|
2
|
-
import { type Polygon } from '@dxos/react-ui-canvas-editor';
|
|
3
|
-
/** Vertical padding inside the function body; the height maths below depends on it. */
|
|
4
|
-
export declare const bodyPadding = 8;
|
|
5
|
-
/**
|
|
6
|
-
* A function shape's height: the chrome plus a body grown to a whole number of grid cells. One row per
|
|
7
|
-
* input is a floor on the body rather than its height, so the box lands on the grid whatever its schema
|
|
8
|
-
* declares — the rows used to set it exactly, and `rowHeight` divides into no grid cell.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getHeight: (input: Schema.Schema<any>, unit?: number) => number;
|
|
11
|
-
export declare const createFunctionAnchors: (shape: Polygon, input?: Schema.Schema<any>, output?: Schema.Schema<any>) => Record<string, import("@dxos/react-ui-canvas-editor").Anchor>;
|
|
12
|
-
//# sourceMappingURL=function-anchors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function-anchors.d.ts","sourceRoot":"","sources":["../../../../../src/shapes/common/function-anchors.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAI7C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAU5D,uFAAuF;AACvF,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,0BAIlD,CAAC;AAEF,eAAO,MAAM,qBAAqB,UACzB,OAAO,UACP,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WACjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,kEAQ3B,CAAC"}
|
package/src/compute-layout.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { DefaultInput, DefaultOutput } from '@dxos/conductor';
|
|
6
|
-
import * as JsonSchema from '@dxos/echo/JsonSchema';
|
|
7
|
-
import { type Anchor, ShapeLayout, type ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
8
|
-
|
|
9
|
-
import { type ComputeGraphController } from './graph/index.ts';
|
|
10
|
-
import { type ComputeShape, createFunctionAnchors } from './shapes/index.ts';
|
|
11
|
-
|
|
12
|
-
// TODO(burdon): Customize layout. Specialize ComputeShapeDef and registry.
|
|
13
|
-
export class ComputeShapeLayout extends ShapeLayout {
|
|
14
|
-
constructor(
|
|
15
|
-
private _controller: ComputeGraphController,
|
|
16
|
-
registry: ShapeRegistry,
|
|
17
|
-
) {
|
|
18
|
-
super(registry);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// TODO(burdon): Doesn't update.
|
|
22
|
-
override getAnchors(shape: ComputeShape): Record<string, Anchor> {
|
|
23
|
-
const shapeDef = this._registry.getShapeDef(shape.type);
|
|
24
|
-
let anchors = shapeDef?.getAnchors?.(shape) ?? {};
|
|
25
|
-
if (shape.node) {
|
|
26
|
-
const node = this._controller.graph.getNode(shape.node);
|
|
27
|
-
if (node.inputSchema || node.outputSchema) {
|
|
28
|
-
// TODO(burdon): Requires that component defined input and output types.
|
|
29
|
-
const inputSchema = node.inputSchema ? JsonSchema.toEffectSchema(node.inputSchema) : DefaultInput;
|
|
30
|
-
const outputSchema = node.outputSchema ? JsonSchema.toEffectSchema(node.outputSchema) : DefaultOutput;
|
|
31
|
-
anchors = createFunctionAnchors(shape, inputSchema, outputSchema);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return anchors;
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/compute.stories.tsx
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React, { type PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
-
import { capabilities } from '@dxos/assistant-toolkit/testing';
|
|
10
|
-
import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
|
|
11
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
-
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
13
|
-
import { Editor, type EditorController, type EditorRootProps, ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
14
|
-
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
15
|
-
import { Form } from '@dxos/react-ui-form';
|
|
16
|
-
import { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import * as Select from '@dxos/react-ui/Select';
|
|
18
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
|
-
import * as Toolbar from '@dxos/react-ui/Toolbar';
|
|
20
|
-
|
|
21
|
-
import { DiagnosticOverlay } from './components/index.ts';
|
|
22
|
-
import { ComputeShapeLayout } from './compute-layout.ts';
|
|
23
|
-
import { type ComputeGraphController, createComputeGraphController } from './graph/index.ts';
|
|
24
|
-
import { ComputeContext, useComputeGraphController, useGraphMonitor } from './hooks/index.ts';
|
|
25
|
-
import { computeShapes } from './registry.ts';
|
|
26
|
-
import { type ComputeShape } from './shapes/index.ts';
|
|
27
|
-
import {
|
|
28
|
-
createArtifactCircuit,
|
|
29
|
-
createAudioCircuit,
|
|
30
|
-
createBasicCircuit,
|
|
31
|
-
createControlCircuit,
|
|
32
|
-
createEmptyCircuit,
|
|
33
|
-
createGptCircuit,
|
|
34
|
-
createGPTRealtimeCircuit,
|
|
35
|
-
createLogicCircuit,
|
|
36
|
-
createTemplateCircuit,
|
|
37
|
-
createTransformCircuit,
|
|
38
|
-
} from './testing/index.ts';
|
|
39
|
-
import { createStoryRuntime } from './testing/services.ts';
|
|
40
|
-
|
|
41
|
-
// TODO(burdon): Replace ServiceContainer.
|
|
42
|
-
|
|
43
|
-
const sidebarTypes: NonNullable<RenderProps['sidebar']>[] = ['canvas', 'compute', 'controller', 'selected'] as const;
|
|
44
|
-
|
|
45
|
-
const hiddenArg = { table: { disable: true } };
|
|
46
|
-
|
|
47
|
-
type RenderProps = EditorRootProps<ComputeShape> &
|
|
48
|
-
PropsWithChildren<{
|
|
49
|
-
init?: boolean;
|
|
50
|
-
sidebar?: 'canvas' | 'compute' | 'controller' | 'selected';
|
|
51
|
-
computeGraph?: ComputeGraphModel;
|
|
52
|
-
controller?: ComputeGraphController | null;
|
|
53
|
-
}>;
|
|
54
|
-
|
|
55
|
-
const DefaultStory = ({
|
|
56
|
-
id = 'test',
|
|
57
|
-
children,
|
|
58
|
-
graph,
|
|
59
|
-
controller = null,
|
|
60
|
-
sidebar: sidebarProp,
|
|
61
|
-
registry,
|
|
62
|
-
showGrid = true,
|
|
63
|
-
snapToGrid = true,
|
|
64
|
-
...props
|
|
65
|
-
}: RenderProps) => {
|
|
66
|
-
const editorRef = useRef<EditorController>(null);
|
|
67
|
-
|
|
68
|
-
// Selection.
|
|
69
|
-
const [selection, selected] = useSelection(graph);
|
|
70
|
-
|
|
71
|
-
const getComputeNode = (id?: string): ComputeNode | undefined => {
|
|
72
|
-
if (id) {
|
|
73
|
-
const node = graph?.getNode(id) as ComputeShape;
|
|
74
|
-
if (node?.node) {
|
|
75
|
-
return controller?.graph.getNode(node.node);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// Sidebar.
|
|
81
|
-
const [sidebar, setSidebar] = useState<RenderProps['sidebar']>(sidebarProp);
|
|
82
|
-
const json = useMemo(() => {
|
|
83
|
-
switch (sidebar) {
|
|
84
|
-
case 'canvas':
|
|
85
|
-
return { graph };
|
|
86
|
-
case 'compute':
|
|
87
|
-
return { graph: controller?.graph };
|
|
88
|
-
case 'controller':
|
|
89
|
-
return { state: controller?.state };
|
|
90
|
-
case 'selected':
|
|
91
|
-
return { shape: selected, compute: getComputeNode(selected?.id) };
|
|
92
|
-
}
|
|
93
|
-
}, [graph, controller, sidebar, selected]);
|
|
94
|
-
|
|
95
|
-
// Controller.
|
|
96
|
-
useComputeGraphController({ controller, graph, editorRef });
|
|
97
|
-
|
|
98
|
-
// Sync monitor.
|
|
99
|
-
const graphMonitor = useGraphMonitor(controller?.graph);
|
|
100
|
-
|
|
101
|
-
// Layout.
|
|
102
|
-
const layout = useMemo(
|
|
103
|
-
() => (controller && registry ? new ComputeShapeLayout(controller, registry) : undefined),
|
|
104
|
-
[controller, registry],
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const [diagnostics, setDiagnostics] = useState<GraphDiagnostic[]>([]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (controller) {
|
|
110
|
-
void controller.checkGraph().then(() => {
|
|
111
|
-
setDiagnostics(controller.diagnostics);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}, []);
|
|
115
|
-
|
|
116
|
-
if (!controller) {
|
|
117
|
-
return <div />;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<div className='grid grid-cols-[1fr_360px] dx-fill'>
|
|
122
|
-
<ComputeContext.Provider value={{ controller, registry }}>
|
|
123
|
-
<Container id={id} classNames={['flex grow overflow-hidden', !sidebar && 'col-span-2']}>
|
|
124
|
-
<Editor.Root<ComputeShape>
|
|
125
|
-
ref={editorRef}
|
|
126
|
-
id={id}
|
|
127
|
-
graph={graph}
|
|
128
|
-
graphMonitor={graphMonitor}
|
|
129
|
-
layout={layout}
|
|
130
|
-
registry={registry}
|
|
131
|
-
selection={selection}
|
|
132
|
-
autoZoom
|
|
133
|
-
showGrid={showGrid}
|
|
134
|
-
snapToGrid={snapToGrid}
|
|
135
|
-
{...props}
|
|
136
|
-
>
|
|
137
|
-
<Editor.Canvas>{children}</Editor.Canvas>
|
|
138
|
-
<Editor.UI showTools />
|
|
139
|
-
</Editor.Root>
|
|
140
|
-
<DiagnosticOverlay diagnostics={diagnostics} />
|
|
141
|
-
</Container>
|
|
142
|
-
</ComputeContext.Provider>
|
|
143
|
-
|
|
144
|
-
{sidebar && (
|
|
145
|
-
<Container id='sidebar' classNames='flex flex-col h-full overflow-hidden'>
|
|
146
|
-
<Toolbar.Root>
|
|
147
|
-
<Select.Root
|
|
148
|
-
value={[sidebar]}
|
|
149
|
-
onValueChange={({ value: [value] }) => setSidebar(value as RenderProps['sidebar'])}
|
|
150
|
-
items={sidebarTypes.map((type) => ({ value: type, label: type }))}
|
|
151
|
-
>
|
|
152
|
-
<Select.Trigger classNames='w-full' />
|
|
153
|
-
<Select.Content>
|
|
154
|
-
{sidebarTypes.map((type) => (
|
|
155
|
-
<Select.Item key={type} item={{ value: type, label: type }} />
|
|
156
|
-
))}
|
|
157
|
-
</Select.Content>
|
|
158
|
-
</Select.Root>
|
|
159
|
-
</Toolbar.Root>
|
|
160
|
-
|
|
161
|
-
<div className='flex flex-col h-full overflow-hidden divide-y divider-separator'>
|
|
162
|
-
{/* TODO(burdon): Provide schema. */}
|
|
163
|
-
{sidebar === 'selected' && selected && (
|
|
164
|
-
<Form.Root<ComputeNode> values={getComputeNode(selected.id) ?? {}}>
|
|
165
|
-
<Form.Viewport>
|
|
166
|
-
<Form.Content>
|
|
167
|
-
<Form.Fields />
|
|
168
|
-
<Form.Actions />
|
|
169
|
-
</Form.Content>
|
|
170
|
-
</Form.Viewport>
|
|
171
|
-
</Form.Root>
|
|
172
|
-
)}
|
|
173
|
-
<Syntax.Root data={json}>
|
|
174
|
-
<Syntax.Content>
|
|
175
|
-
<Syntax.Filter />
|
|
176
|
-
<Syntax.Viewport>
|
|
177
|
-
<Syntax.Code />
|
|
178
|
-
</Syntax.Viewport>
|
|
179
|
-
</Syntax.Content>
|
|
180
|
-
</Syntax.Root>
|
|
181
|
-
</div>
|
|
182
|
-
</Container>
|
|
183
|
-
)}
|
|
184
|
-
</div>
|
|
185
|
-
);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const meta = {
|
|
189
|
-
title: 'ui/react-ui-canvas-compute/compute',
|
|
190
|
-
component: Editor.Root as any,
|
|
191
|
-
render: DefaultStory,
|
|
192
|
-
decorators: [
|
|
193
|
-
withTheme(),
|
|
194
|
-
withLayout({ layout: 'fullscreen' }),
|
|
195
|
-
withAttention(),
|
|
196
|
-
withClientProvider({ createIdentity: true, createSpace: true }),
|
|
197
|
-
withPluginManager({ capabilities }),
|
|
198
|
-
],
|
|
199
|
-
parameters: {
|
|
200
|
-
layout: 'fullscreen',
|
|
201
|
-
},
|
|
202
|
-
argTypes: {
|
|
203
|
-
controller: hiddenArg,
|
|
204
|
-
graph: hiddenArg,
|
|
205
|
-
registry: hiddenArg,
|
|
206
|
-
sidebar: {
|
|
207
|
-
control: 'select',
|
|
208
|
-
options: [...sidebarTypes, null],
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
} satisfies Meta<typeof DefaultStory>;
|
|
212
|
-
|
|
213
|
-
export default meta;
|
|
214
|
-
|
|
215
|
-
type Story = StoryObj<typeof meta>;
|
|
216
|
-
|
|
217
|
-
export const Default: Story = {
|
|
218
|
-
args: {
|
|
219
|
-
registry: new ShapeRegistry(computeShapes),
|
|
220
|
-
...createComputeGraphController(createEmptyCircuit(), createStoryRuntime()),
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export const Beacon: Story = {
|
|
225
|
-
args: {
|
|
226
|
-
registry: new ShapeRegistry(computeShapes),
|
|
227
|
-
...createComputeGraphController(createBasicCircuit(), createStoryRuntime()),
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export const Transform: Story = {
|
|
232
|
-
args: {
|
|
233
|
-
registry: new ShapeRegistry(computeShapes),
|
|
234
|
-
...createComputeGraphController(createTransformCircuit(), createStoryRuntime()),
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
export const Logic: Story = {
|
|
239
|
-
args: {
|
|
240
|
-
registry: new ShapeRegistry(computeShapes),
|
|
241
|
-
...createComputeGraphController(createLogicCircuit(), createStoryRuntime()),
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export const Control: Story = {
|
|
246
|
-
args: {
|
|
247
|
-
registry: new ShapeRegistry(computeShapes),
|
|
248
|
-
...createComputeGraphController(createControlCircuit(), createStoryRuntime()),
|
|
249
|
-
},
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
export const Template: Story = {
|
|
253
|
-
args: {
|
|
254
|
-
registry: new ShapeRegistry(computeShapes),
|
|
255
|
-
...createComputeGraphController(createTemplateCircuit(), createStoryRuntime()),
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export const GPT: Story = {
|
|
260
|
-
args: {
|
|
261
|
-
registry: new ShapeRegistry(computeShapes),
|
|
262
|
-
...createComputeGraphController(createGptCircuit({ history: true }), createStoryRuntime()),
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export const Plugins: Story = {
|
|
267
|
-
args: {
|
|
268
|
-
registry: new ShapeRegistry(computeShapes),
|
|
269
|
-
...createComputeGraphController(
|
|
270
|
-
createGptCircuit({ history: true, image: true, artifact: true }),
|
|
271
|
-
createStoryRuntime(),
|
|
272
|
-
),
|
|
273
|
-
},
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export const Artifact: Story = {
|
|
277
|
-
args: {
|
|
278
|
-
registry: new ShapeRegistry(computeShapes),
|
|
279
|
-
...createComputeGraphController(createArtifactCircuit(), createStoryRuntime()),
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export const ImageGen: Story = {
|
|
284
|
-
args: {
|
|
285
|
-
registry: new ShapeRegistry(computeShapes),
|
|
286
|
-
...createComputeGraphController(createGptCircuit({ image: true, artifact: true }), createStoryRuntime()),
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
export const Audio: Story = {
|
|
291
|
-
args: {
|
|
292
|
-
registry: new ShapeRegistry(computeShapes),
|
|
293
|
-
...createComputeGraphController(createAudioCircuit(), createStoryRuntime()),
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export const Voice: Story = {
|
|
298
|
-
args: {
|
|
299
|
-
registry: new ShapeRegistry(computeShapes),
|
|
300
|
-
...createComputeGraphController(createGPTRealtimeCircuit(), createStoryRuntime()),
|
|
301
|
-
},
|
|
302
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type RefObject, useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type CleanupFn } from '@dxos/async';
|
|
8
|
-
import { type EditorController, type EditorRootProps } from '@dxos/react-ui-canvas-editor';
|
|
9
|
-
|
|
10
|
-
import { type ComputeGraphController } from '../graph/index.ts';
|
|
11
|
-
import { type ComputeShape } from '../shapes/index.ts';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Move to async/context?
|
|
14
|
-
const combine = (...cbs: CleanupFn[]) => {
|
|
15
|
-
return () => {
|
|
16
|
-
for (const cb of cbs) {
|
|
17
|
-
cb();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type UseComputeGraphControllerOptions = Pick<EditorRootProps<ComputeShape>, 'graph'> & {
|
|
23
|
-
controller: ComputeGraphController | null;
|
|
24
|
-
editorRef: RefObject<EditorController | null>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const useComputeGraphController = ({ controller, graph, editorRef }: UseComputeGraphControllerOptions) => {
|
|
28
|
-
const [, forceUpdate] = useState({});
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!controller || !graph) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
void controller.open();
|
|
36
|
-
const off = combine(
|
|
37
|
-
controller.update.on(() => {
|
|
38
|
-
void editorRef.current?.update();
|
|
39
|
-
forceUpdate({});
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
// TODO(burdon): Every node is called on every update.
|
|
43
|
-
controller.output.on(({ nodeId, property, value }) => {
|
|
44
|
-
if (value.type === 'not-executed') {
|
|
45
|
-
// If the node didn't execute, don't trigger.
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const edge = graph.edges.find((edge) => {
|
|
50
|
-
const source = graph.getNode(edge.source);
|
|
51
|
-
return (source as ComputeShape).node === nodeId && edge.output === property;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (edge) {
|
|
55
|
-
void editorRef.current?.action?.({ type: 'trigger', edges: [edge] });
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
return () => {
|
|
61
|
-
void controller.close();
|
|
62
|
-
off();
|
|
63
|
-
};
|
|
64
|
-
}, [graph, controller]);
|
|
65
|
-
};
|
package/src/scene/NodeView.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2026 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
import React, { type ComponentType, type FC } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';
|
|
9
|
-
import { type NodeViewProps, UnknownNodeView } from '@dxos/react-ui-canvas/scene';
|
|
10
|
-
|
|
11
|
-
import { useComputeContext } from '../hooks/compute-context.ts';
|
|
12
|
-
import { useControllerUpdates } from '../hooks/useControllerUpdates.ts';
|
|
13
|
-
import { type ComputeShape } from '../shapes/index.ts';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The shape component under the engine's view props: the node is the shape (it carries the same fields
|
|
17
|
-
* plus `z`), re-rendered on every controller update since the runtime state it reads is not reactive.
|
|
18
|
-
*/
|
|
19
|
-
export const computeNodeView = <S extends ComputeShape>(
|
|
20
|
-
schema: Schema.Codec<S, unknown, never, never>,
|
|
21
|
-
Component: FC<ShapeComponentProps<S>>,
|
|
22
|
-
): ComponentType<NodeViewProps> => {
|
|
23
|
-
const isShape = Schema.is(schema);
|
|
24
|
-
const View = (props: NodeViewProps) => {
|
|
25
|
-
const { node, selected } = props;
|
|
26
|
-
const { controller } = useComputeContext();
|
|
27
|
-
useControllerUpdates(controller);
|
|
28
|
-
if (!isShape(node)) {
|
|
29
|
-
return <UnknownNodeView {...props} />;
|
|
30
|
-
}
|
|
31
|
-
// The shape components were written against the editor's frame body, which is a full-size flex
|
|
32
|
-
// container (`styles.frameContainer`); the engine's node frame is not, so their `grow` / `w-full`
|
|
33
|
-
// centring collapsed to the top-left corner. The wrapper restores that contract for every shape.
|
|
34
|
-
return (
|
|
35
|
-
<div className='dx-cover flex'>
|
|
36
|
-
<Component shape={node} selected={selected} />
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
View.displayName = `ComputeNodeView(${Component.displayName ?? Component.name})`;
|
|
41
|
-
return View;
|
|
42
|
-
};
|