@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
package/dist/lib/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as RectangleShape, c as Shape, i as Polygon, l as schema_exports, n as NoteShape, o as isPath, r as PathShape, s as isPolygon, t as EllipseShape, u as CanvasGraphModel } from "./chunk-types.mjs";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Exit from "effect/Exit";
|
|
3
4
|
import * as Layer from "effect/Layer";
|
|
@@ -9,19 +10,24 @@ import { AnyOutput, AppendInput, ComputeBeginEvent, ComputeCustomEvent, ComputeE
|
|
|
9
10
|
import { Resource } from "@dxos/context";
|
|
10
11
|
import * as EffectEx from "@dxos/effect/EffectEx";
|
|
11
12
|
import { log } from "@dxos/log";
|
|
12
|
-
import { Fragment, createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
13
|
+
import { Fragment, createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState } from "react";
|
|
13
14
|
import { raise } from "@dxos/debug";
|
|
14
15
|
import * as Schema from "effect/Schema";
|
|
15
16
|
import { invariant } from "@dxos/invariant";
|
|
16
17
|
import { Filter, JsonSchema, Obj, Query, Ref, Type } from "@dxos/echo";
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
18
|
+
import { DEFAULT_CELL, DEFAULT_GRID, LINK_TYPES, Point, Size, UnknownNodeView, createFreehandProjection, defaultNodeRegistry, endpointNode, initialKeys, nodeDef, reduceIntent, sortByZ } from "@dxos/react-ui-canvas/scene";
|
|
19
|
+
import * as Icon from "@dxos/react-ui/Icon";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
21
|
import * as SchemaAST from "@dxos/effect/SchemaAST";
|
|
20
22
|
import * as Struct from "effect/Struct";
|
|
21
23
|
import * as Button from "@dxos/react-ui/Button";
|
|
22
|
-
import * as Icon from "@dxos/react-ui/Icon";
|
|
23
24
|
import { mx } from "@dxos/ui-theme";
|
|
24
|
-
import {
|
|
25
|
+
import { json } from "@codemirror/lang-json";
|
|
26
|
+
import { Prec } from "@codemirror/state";
|
|
27
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
28
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
29
|
+
import * as Hooks from "@dxos/react-ui/Hooks";
|
|
30
|
+
import { createBasicExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
|
|
25
31
|
import * as Select from "@dxos/react-ui/Select";
|
|
26
32
|
import * as Field from "@dxos/react-ui/Field";
|
|
27
33
|
import * as Input from "@dxos/react-ui/Input";
|
|
@@ -51,37 +57,9 @@ var ComputeContext = createContext(null);
|
|
|
51
57
|
var useComputeContext = () => {
|
|
52
58
|
return useContext(ComputeContext) ?? raise(/* @__PURE__ */ new Error("Missing ComputeContext"));
|
|
53
59
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
return () => {
|
|
58
|
-
for (const cb of cbs) cb();
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
62
|
-
const [, forceUpdate] = useState({});
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!controller || !graph) return;
|
|
65
|
-
controller.open();
|
|
66
|
-
const off = combine(controller.update.on(() => {
|
|
67
|
-
editorRef.current?.update();
|
|
68
|
-
forceUpdate({});
|
|
69
|
-
}), controller.output.on(({ nodeId, property, value }) => {
|
|
70
|
-
if (value.type === "not-executed") return;
|
|
71
|
-
const edge = graph.edges.find((edge) => {
|
|
72
|
-
return graph.getNode(edge.source).node === nodeId && edge.output === property;
|
|
73
|
-
});
|
|
74
|
-
if (edge) editorRef.current?.action?.({
|
|
75
|
-
type: "trigger",
|
|
76
|
-
edges: [edge]
|
|
77
|
-
});
|
|
78
|
-
}));
|
|
79
|
-
return () => {
|
|
80
|
-
controller.close();
|
|
81
|
-
off();
|
|
82
|
-
};
|
|
83
|
-
}, [graph, controller]);
|
|
84
|
-
};
|
|
60
|
+
/** The definition of the node being rendered, from the registry the scene renders with, for the frame chrome. */
|
|
61
|
+
var ComputeNodeDefContext = createContext(void 0);
|
|
62
|
+
var useComputeNodeDef = () => useContext(ComputeNodeDefContext);
|
|
85
63
|
//#endregion
|
|
86
64
|
//#region src/hooks/useComputeNodeState.ts
|
|
87
65
|
var __dxlog_file$7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
@@ -154,14 +132,14 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
154
132
|
invariant(sourceNode?.node, void 0, {
|
|
155
133
|
"~LogMeta": "~LogMeta",
|
|
156
134
|
F: __dxlog_file$6,
|
|
157
|
-
L:
|
|
135
|
+
L: 32,
|
|
158
136
|
S: void 0,
|
|
159
137
|
A: ["sourceNode?.node", ""]
|
|
160
138
|
});
|
|
161
139
|
invariant(targetNode?.node, void 0, {
|
|
162
140
|
"~LogMeta": "~LogMeta",
|
|
163
141
|
F: __dxlog_file$6,
|
|
164
|
-
L:
|
|
142
|
+
L: 33,
|
|
165
143
|
S: void 0,
|
|
166
144
|
A: ["targetNode?.node", ""]
|
|
167
145
|
});
|
|
@@ -641,6 +619,78 @@ var deleteTriggerObjects = (computeGraph, shapes) => {
|
|
|
641
619
|
var headerHeight = 2 * DEFAULT_GRID;
|
|
642
620
|
var footerHeight = 2 * DEFAULT_GRID;
|
|
643
621
|
//#endregion
|
|
622
|
+
//#region src/shapes/common/node-def.tsx
|
|
623
|
+
/**
|
|
624
|
+
* A size in scene px as nominal units (major cells) to the nearest half cell, so a new node lands close to that px
|
|
625
|
+
* size and its edges on the grid.
|
|
626
|
+
*/
|
|
627
|
+
var toNominal = ({ width, height }) => ({
|
|
628
|
+
width: Math.round(width / DEFAULT_CELL * 2) / 2,
|
|
629
|
+
height: Math.round(height / DEFAULT_CELL * 2) / 2
|
|
630
|
+
});
|
|
631
|
+
/** A compute shape's node definition. */
|
|
632
|
+
var defineComputeNode = ({ schema, component, create, defaultSize, ports, ...rest }) => {
|
|
633
|
+
const isShape = Schema.is(schema);
|
|
634
|
+
return {
|
|
635
|
+
...rest,
|
|
636
|
+
schema,
|
|
637
|
+
component: computeNodeView(isShape, component),
|
|
638
|
+
create: ({ id, z, center, size }) => ({
|
|
639
|
+
...create({
|
|
640
|
+
id,
|
|
641
|
+
center
|
|
642
|
+
}),
|
|
643
|
+
z,
|
|
644
|
+
size
|
|
645
|
+
}),
|
|
646
|
+
defaultSize: toNominal(defaultSize ?? create({
|
|
647
|
+
id: "default",
|
|
648
|
+
center: {
|
|
649
|
+
x: 0,
|
|
650
|
+
y: 0
|
|
651
|
+
}
|
|
652
|
+
}).size),
|
|
653
|
+
ports: (node) => isShape(node) ? ports(node) : []
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* The shape's component under the engine's view props, re-rendered on every controller update since the
|
|
658
|
+
* runtime state it reads is not reactive; a node that is not the shape renders as an unknown node.
|
|
659
|
+
*/
|
|
660
|
+
var computeNodeView = (isShape, Component) => {
|
|
661
|
+
const View = (props) => {
|
|
662
|
+
const { node, registry } = props;
|
|
663
|
+
const { controller } = useComputeContext();
|
|
664
|
+
useControllerUpdates(controller);
|
|
665
|
+
if (!isShape(node)) return /* @__PURE__ */ jsx(UnknownNodeView, { ...props });
|
|
666
|
+
if (!node.node) {
|
|
667
|
+
const def = nodeDef(registry, node);
|
|
668
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
669
|
+
className: "dx-cover flex flex-col items-center justify-center gap-1 text-fg-muted",
|
|
670
|
+
children: [def?.icon && /* @__PURE__ */ jsx(Icon.Icon, {
|
|
671
|
+
icon: def.icon,
|
|
672
|
+
size: "lg"
|
|
673
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
674
|
+
className: "text-sm truncate",
|
|
675
|
+
children: def?.name ?? node.type
|
|
676
|
+
})]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
return /* @__PURE__ */ jsx(ComputeNodeDefContext.Provider, {
|
|
680
|
+
value: nodeDef(registry, node),
|
|
681
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
682
|
+
className: "dx-cover flex",
|
|
683
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
684
|
+
...props,
|
|
685
|
+
node
|
|
686
|
+
})
|
|
687
|
+
})
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
View.displayName = `ComputeNodeView(${Component.displayName ?? Component.name})`;
|
|
691
|
+
return View;
|
|
692
|
+
};
|
|
693
|
+
//#endregion
|
|
644
694
|
//#region src/shapes/defs.ts
|
|
645
695
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({ name: name.toString() }));
|
|
646
696
|
var createAnchorId = (kind, property = kind === "input" ? DEFAULT_INPUT : DEFAULT_OUTPUT) => [kind, property].join(".");
|
|
@@ -648,7 +698,12 @@ var parseAnchorId = (id) => {
|
|
|
648
698
|
const parts = id.match(/(input|output)\.(.+)/);
|
|
649
699
|
return parts ? parts.slice(1) : [void 0, id];
|
|
650
700
|
};
|
|
651
|
-
var ComputeShape =
|
|
701
|
+
var ComputeShape = Shape.mapFields(Struct.assign({
|
|
702
|
+
center: Point,
|
|
703
|
+
size: Size.mapFields(Struct.map(Schema.mutableKey))
|
|
704
|
+
})).mapFields(Struct.map(Schema.mutableKey)).mapFields(Struct.assign({ node: Schema.mutableKey(Schema.optional(Obj.ID.annotate({ description: "Compute node id" }))) }));
|
|
705
|
+
/** The shape's schema with the engine's z-order key, so it is a node schema. */
|
|
706
|
+
var withZ = (shape) => shape.mapFields(Struct.assign({ z: Schema.String }));
|
|
652
707
|
var createShape = ({ id, ...rest }) => {
|
|
653
708
|
return {
|
|
654
709
|
id: id ?? Obj.ID.random(),
|
|
@@ -656,28 +711,79 @@ var createShape = ({ id, ...rest }) => {
|
|
|
656
711
|
};
|
|
657
712
|
};
|
|
658
713
|
//#endregion
|
|
659
|
-
//#region src/shapes/common/
|
|
660
|
-
/** Vertical padding inside the function body; the height maths below depends on it. */
|
|
661
|
-
var bodyPadding = 8;
|
|
714
|
+
//#region src/shapes/common/ports.ts
|
|
662
715
|
/**
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
* declares — the rows used to set it exactly, and `rowHeight` divides into no grid cell.
|
|
716
|
+
* Height of one property row, two minor grid cells: with the rows centred in a body that is a whole number of rows,
|
|
717
|
+
* every row's centre, and so every port, lands on a minor grid line.
|
|
666
718
|
*/
|
|
667
|
-
var
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
719
|
+
var rowHeight = 2 * DEFAULT_GRID;
|
|
720
|
+
/** A function shape's height: the chrome plus one row per input (at least one), each a whole number of rows. */
|
|
721
|
+
var getHeight = (input) => {
|
|
722
|
+
const properties = SchemaAST.getPropertySignatures(input.ast);
|
|
723
|
+
return headerHeight + footerHeight + Math.max(properties.length, 1) * rowHeight;
|
|
724
|
+
};
|
|
725
|
+
/** `n` points one row apart, centred on `center`. */
|
|
726
|
+
var getRowPoints = (center, n) => {
|
|
727
|
+
const span = (n - 1) * rowHeight;
|
|
728
|
+
return [...Array(n)].map((_, index) => ({
|
|
729
|
+
x: center.x,
|
|
730
|
+
y: center.y - span / 2 + index * rowHeight
|
|
731
|
+
}));
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* The ports at the given points: each sits on whichever edge it is nearer to, at its offset along it; the
|
|
735
|
+
* id's `input.` / `output.` prefix says which way a link may run.
|
|
736
|
+
*/
|
|
737
|
+
var pointsToPorts = (points, size) => points.map(({ id, pos }) => {
|
|
738
|
+
const [kind] = parseAnchorId(id);
|
|
739
|
+
const half = {
|
|
740
|
+
x: size.width / 2,
|
|
741
|
+
y: size.height / 2
|
|
742
|
+
};
|
|
743
|
+
const vertical = Math.abs(Math.abs(pos.x) - half.x) <= Math.abs(Math.abs(pos.y) - half.y);
|
|
744
|
+
const side = vertical ? pos.x < 0 ? "w" : "e" : pos.y < 0 ? "n" : "s";
|
|
745
|
+
const along = vertical ? (pos.y + half.y) / size.height : (pos.x + half.x) / size.width;
|
|
746
|
+
return {
|
|
747
|
+
id,
|
|
748
|
+
side,
|
|
749
|
+
offset: Math.min(Math.max(along, 0), 1),
|
|
750
|
+
...kind === "input" ? { accepts: "in" } : kind === "output" ? { accepts: "out" } : {}
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
/** Ports at points given in half-sizes from the centre (`{ x: 1, y: 0 }` is the middle of the east side). */
|
|
754
|
+
var createPorts = (size, points) => pointsToPorts(Object.entries(points).map(([id, { x, y }]) => ({
|
|
755
|
+
id,
|
|
756
|
+
pos: {
|
|
757
|
+
x: x * size.width / 2,
|
|
758
|
+
y: y * size.height / 2
|
|
759
|
+
}
|
|
760
|
+
})), size);
|
|
761
|
+
/** Inputs stacked one row apart down the west side and outputs down the east, centred on `center`. */
|
|
762
|
+
var createRowPorts = ({ size, inputs, outputs, center = {
|
|
763
|
+
x: 0,
|
|
764
|
+
y: 0
|
|
765
|
+
} }) => pointsToPorts([...getRowPoints({
|
|
766
|
+
x: center.x - size.width / 2,
|
|
767
|
+
y: center.y
|
|
768
|
+
}, inputs.length).map((pos, index) => ({
|
|
769
|
+
id: inputs[index],
|
|
770
|
+
pos
|
|
771
|
+
})), ...getRowPoints({
|
|
772
|
+
x: center.x + size.width / 2,
|
|
773
|
+
y: center.y
|
|
774
|
+
}, outputs.length).map((pos, index) => ({
|
|
775
|
+
id: outputs[index],
|
|
776
|
+
pos
|
|
777
|
+
}))], size);
|
|
778
|
+
/** A function shape's ports: one per property of its input and output schemas, level with the body's rows. */
|
|
779
|
+
var createFunctionPorts = (size, input = VoidInput, output = VoidOutput) => {
|
|
780
|
+
return createRowPorts({
|
|
781
|
+
size,
|
|
782
|
+
inputs: SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId("input", name.toString())),
|
|
783
|
+
outputs: SchemaAST.getPropertySignatures(output.ast).map(({ name }) => createAnchorId("output", name.toString())),
|
|
678
784
|
center: {
|
|
679
785
|
x: 0,
|
|
680
|
-
y: (headerHeight - footerHeight) / 2
|
|
786
|
+
y: (headerHeight - footerHeight) / 2
|
|
681
787
|
}
|
|
682
788
|
});
|
|
683
789
|
};
|
|
@@ -692,14 +798,17 @@ var Box = forwardRef(({ children, classNames, shape, title, status, open, onActi
|
|
|
692
798
|
S: void 0,
|
|
693
799
|
A: ["shape.type", ""]
|
|
694
800
|
});
|
|
695
|
-
const { controller,
|
|
696
|
-
const
|
|
801
|
+
const { controller, debug = false } = useComputeContext();
|
|
802
|
+
const def = useComputeNodeDef();
|
|
803
|
+
const icon = def?.icon ?? "ph--circle-dashed--regular";
|
|
804
|
+
const name = def?.name;
|
|
805
|
+
const openable = def?.openable;
|
|
697
806
|
const nodeId = shape.node;
|
|
698
807
|
const handleRun = () => {
|
|
699
808
|
controller.exec(nodeId).catch((err) => log.catch(err, void 0, {
|
|
700
809
|
"~LogMeta": "~LogMeta",
|
|
701
810
|
F: __dxlog_file$2,
|
|
702
|
-
L:
|
|
811
|
+
L: 43,
|
|
703
812
|
S: void 0
|
|
704
813
|
}));
|
|
705
814
|
};
|
|
@@ -762,22 +871,16 @@ var Box = forwardRef(({ children, classNames, shape, title, status, open, onActi
|
|
|
762
871
|
var expandedHeight = 200;
|
|
763
872
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
764
873
|
const { resize } = useComputeContext();
|
|
765
|
-
const rootRef = useRef(null);
|
|
766
874
|
const [open, setOpen] = useState(false);
|
|
767
875
|
const handleAction = (action) => {
|
|
768
876
|
const opening = action === "open";
|
|
769
|
-
|
|
770
|
-
else if (rootRef.current) {
|
|
771
|
-
const element = getParentShapeElement(rootRef.current, shape.id);
|
|
772
|
-
if (element) element.style.height = opening ? `${element.offsetHeight + expandedHeight}px` : "";
|
|
773
|
-
}
|
|
877
|
+
resize?.(shape.id, opening ? expandedHeight : -200);
|
|
774
878
|
setOpen(opening);
|
|
775
879
|
};
|
|
776
880
|
const inputs = getProperties(inputSchema.ast);
|
|
777
881
|
const outputs = getProperties(outputSchema.ast);
|
|
778
882
|
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
779
883
|
return /* @__PURE__ */ jsxs(Box, {
|
|
780
|
-
ref: rootRef,
|
|
781
884
|
shape,
|
|
782
885
|
title: name,
|
|
783
886
|
classNames: "divide-y divide-separator-subtle",
|
|
@@ -785,24 +888,26 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
785
888
|
onAction: handleAction,
|
|
786
889
|
...props,
|
|
787
890
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
788
|
-
className: `grid grid-cols-${columnCount}
|
|
789
|
-
style: {
|
|
790
|
-
paddingTop: 8,
|
|
791
|
-
paddingBottom: 8
|
|
792
|
-
},
|
|
891
|
+
className: mx(`grid grid-cols-${columnCount}`, !open && "grow"),
|
|
793
892
|
children: [(inputs?.length ?? 0) > 0 && /* @__PURE__ */ jsx("div", {
|
|
794
|
-
className: "flex flex-col",
|
|
893
|
+
className: "flex flex-col justify-center",
|
|
795
894
|
children: inputs?.map(({ name }) => /* @__PURE__ */ jsx("div", {
|
|
796
|
-
className: "px-2
|
|
895
|
+
className: "flex items-center px-2 text-sm font-mono",
|
|
797
896
|
style: { height: rowHeight },
|
|
798
|
-
children:
|
|
897
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
898
|
+
className: "truncate",
|
|
899
|
+
children: name
|
|
900
|
+
})
|
|
799
901
|
}, name))
|
|
800
902
|
}), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ jsx("div", {
|
|
801
|
-
className: "flex flex-col",
|
|
903
|
+
className: "flex flex-col justify-center",
|
|
802
904
|
children: outputs?.map(({ name }) => /* @__PURE__ */ jsx("div", {
|
|
803
|
-
className: "px-2
|
|
905
|
+
className: "flex items-center justify-end px-2 text-sm font-mono",
|
|
804
906
|
style: { height: rowHeight },
|
|
805
|
-
children:
|
|
907
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
908
|
+
className: "truncate",
|
|
909
|
+
children: name
|
|
910
|
+
})
|
|
806
911
|
}, name))
|
|
807
912
|
})]
|
|
808
913
|
}), open && /* @__PURE__ */ jsx("div", {
|
|
@@ -812,6 +917,91 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
812
917
|
});
|
|
813
918
|
};
|
|
814
919
|
//#endregion
|
|
920
|
+
//#region src/shapes/common/TextBox.tsx
|
|
921
|
+
var TextBox = forwardRef(({ classNames, value = "", centered, onEnter, onCancel, language, ...rest }, forwardedRef) => {
|
|
922
|
+
const themeMode = Hooks.useThemeMode();
|
|
923
|
+
const modified = useRef(false);
|
|
924
|
+
const doc = useRef(value);
|
|
925
|
+
useEffect(() => {
|
|
926
|
+
modified.current = false;
|
|
927
|
+
doc.current = value;
|
|
928
|
+
}, [value]);
|
|
929
|
+
const { parentRef, view, focusAttributes } = useTextEditor(() => {
|
|
930
|
+
return {
|
|
931
|
+
id: "text",
|
|
932
|
+
initialValue: value,
|
|
933
|
+
extensions: [
|
|
934
|
+
createBasicExtensions({
|
|
935
|
+
lineWrapping: !centered,
|
|
936
|
+
...rest
|
|
937
|
+
}),
|
|
938
|
+
...language === "json" ? [json()] : language === "markdown" ? [createMarkdownExtensions(), decorateMarkdown()] : [],
|
|
939
|
+
createThemeExtensions({
|
|
940
|
+
themeMode,
|
|
941
|
+
syntaxHighlighting: !!language,
|
|
942
|
+
slots: {
|
|
943
|
+
editor: { className: "h-full w-full [&>.cm-scroller]:scrollbar-none p-2" },
|
|
944
|
+
content: { className: mx(centered && "text-center") }
|
|
945
|
+
}
|
|
946
|
+
}),
|
|
947
|
+
EditorView.updateListener.of((update) => {
|
|
948
|
+
if (update.docChanged) modified.current = doc.current !== update.state.doc.toString();
|
|
949
|
+
}),
|
|
950
|
+
EditorView.focusChangeEffect.of((state, focusing) => {
|
|
951
|
+
if (!focusing && modified.current) onEnter?.(state.doc.toString());
|
|
952
|
+
return null;
|
|
953
|
+
}),
|
|
954
|
+
Prec.highest(keymap.of([
|
|
955
|
+
{
|
|
956
|
+
key: "Enter",
|
|
957
|
+
preventDefault: true,
|
|
958
|
+
run: (view) => {
|
|
959
|
+
onEnter?.(view.state.doc.toString());
|
|
960
|
+
modified.current = false;
|
|
961
|
+
return true;
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
key: "Shift-Enter",
|
|
966
|
+
run: (view) => {
|
|
967
|
+
view.dispatch(view.state.replaceSelection("\n"));
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
key: "Escape",
|
|
973
|
+
run: () => {
|
|
974
|
+
onCancel?.();
|
|
975
|
+
modified.current = false;
|
|
976
|
+
return true;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
]))
|
|
980
|
+
]
|
|
981
|
+
};
|
|
982
|
+
}, [value, language]);
|
|
983
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
984
|
+
setText: (text) => {
|
|
985
|
+
view?.dispatch({ changes: {
|
|
986
|
+
from: 0,
|
|
987
|
+
to: view.state.doc.length,
|
|
988
|
+
insert: text
|
|
989
|
+
} });
|
|
990
|
+
},
|
|
991
|
+
focus: () => {
|
|
992
|
+
view?.focus();
|
|
993
|
+
}
|
|
994
|
+
}), [view]);
|
|
995
|
+
useEffect(() => {
|
|
996
|
+
view?.dispatch({ selection: { anchor: view.state.doc.length } });
|
|
997
|
+
}, [view]);
|
|
998
|
+
return /* @__PURE__ */ jsx("div", {
|
|
999
|
+
ref: parentRef,
|
|
1000
|
+
...focusAttributes,
|
|
1001
|
+
className: mx("dx-fill overflow-hidden", classNames)
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
//#endregion
|
|
815
1005
|
//#region src/shapes/common/TypeSelect.tsx
|
|
816
1006
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
817
1007
|
return /* @__PURE__ */ jsxs(Select.Root, {
|
|
@@ -832,7 +1022,7 @@ var TypeSelect = ({ value, onValueChange }) => {
|
|
|
832
1022
|
};
|
|
833
1023
|
//#endregion
|
|
834
1024
|
//#region src/shapes/Append.tsx
|
|
835
|
-
var AppendComponent = ({ shape }) => {
|
|
1025
|
+
var AppendComponent = ({ node: shape }) => {
|
|
836
1026
|
return /* @__PURE__ */ jsx(FunctionBody, {
|
|
837
1027
|
shape,
|
|
838
1028
|
inputSchema: AppendInput
|
|
@@ -849,17 +1039,19 @@ var createAppend = (props) => createShape({
|
|
|
849
1039
|
},
|
|
850
1040
|
...props
|
|
851
1041
|
});
|
|
852
|
-
var
|
|
1042
|
+
var appendNodeDef = defineComputeNode({
|
|
853
1043
|
type: "append",
|
|
854
1044
|
name: "Append",
|
|
855
1045
|
icon: "ph--list-plus--regular",
|
|
1046
|
+
group: "Transform",
|
|
1047
|
+
schema: withZ(AppendShape),
|
|
856
1048
|
component: AppendComponent,
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
};
|
|
1049
|
+
create: createAppend,
|
|
1050
|
+
ports: (shape) => createFunctionPorts(shape.size, AppendInput)
|
|
1051
|
+
});
|
|
860
1052
|
//#endregion
|
|
861
1053
|
//#region src/shapes/Array.tsx
|
|
862
|
-
var ReducerComponent = ({ shape }) => {
|
|
1054
|
+
var ReducerComponent = ({ node: shape }) => {
|
|
863
1055
|
return /* @__PURE__ */ jsx(FunctionBody, {
|
|
864
1056
|
shape,
|
|
865
1057
|
inputSchema: ReducerInput,
|
|
@@ -869,7 +1061,7 @@ var ReducerComponent = ({ shape }) => {
|
|
|
869
1061
|
//#endregion
|
|
870
1062
|
//#region src/shapes/array-def.ts
|
|
871
1063
|
var ReducerShape = ComputeShape.mapFields(Struct.assign({ type: Schema.Literal("reducer") }));
|
|
872
|
-
var createReducer = ({
|
|
1064
|
+
var createReducer = ({ size = {
|
|
873
1065
|
width: 192,
|
|
874
1066
|
height: getHeight(ReducerInput)
|
|
875
1067
|
}, ...rest }) => createShape({
|
|
@@ -877,17 +1069,19 @@ var createReducer = ({ id, size = {
|
|
|
877
1069
|
size,
|
|
878
1070
|
...rest
|
|
879
1071
|
});
|
|
880
|
-
var
|
|
1072
|
+
var reducerNodeDef = defineComputeNode({
|
|
881
1073
|
type: "reducer",
|
|
882
1074
|
name: "Reducer",
|
|
883
1075
|
icon: "ph--repeat--regular",
|
|
1076
|
+
group: "Operations",
|
|
1077
|
+
schema: withZ(ReducerShape),
|
|
884
1078
|
component: ReducerComponent,
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
};
|
|
1079
|
+
create: createReducer,
|
|
1080
|
+
ports: (shape) => createFunctionPorts(shape.size, ReducerInput, ReducerOutput)
|
|
1081
|
+
});
|
|
888
1082
|
//#endregion
|
|
889
1083
|
//#region src/shapes/Audio.tsx
|
|
890
|
-
var AudioComponent = ({ shape }) => {
|
|
1084
|
+
var AudioComponent = ({ node: shape }) => {
|
|
891
1085
|
const { runtime } = useComputeNodeState(shape);
|
|
892
1086
|
const [active, setActive] = useState(false);
|
|
893
1087
|
useEffect(() => {
|
|
@@ -915,20 +1109,22 @@ var createAudio = (props) => createShape({
|
|
|
915
1109
|
},
|
|
916
1110
|
...props
|
|
917
1111
|
});
|
|
918
|
-
var
|
|
1112
|
+
var audioNodeDef = defineComputeNode({
|
|
919
1113
|
type: "audio",
|
|
920
1114
|
name: "Audio",
|
|
921
1115
|
icon: "ph--microphone--regular",
|
|
1116
|
+
group: "Inputs",
|
|
1117
|
+
schema: withZ(AudioShape),
|
|
922
1118
|
component: AudioComponent,
|
|
923
|
-
|
|
924
|
-
|
|
1119
|
+
create: createAudio,
|
|
1120
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
925
1121
|
x: 1,
|
|
926
1122
|
y: 0
|
|
927
1123
|
} })
|
|
928
|
-
};
|
|
1124
|
+
});
|
|
929
1125
|
//#endregion
|
|
930
1126
|
//#region src/shapes/Beacon.tsx
|
|
931
|
-
var BeaconComponent = ({ shape }) => {
|
|
1127
|
+
var BeaconComponent = ({ node: shape }) => {
|
|
932
1128
|
const { runtime } = useComputeNodeState(shape);
|
|
933
1129
|
const input = runtime.inputs[DEFAULT_INPUT];
|
|
934
1130
|
const value = input?.type === "executed" ? input.value : false;
|
|
@@ -952,20 +1148,22 @@ var createBeacon = (props) => createShape({
|
|
|
952
1148
|
},
|
|
953
1149
|
...props
|
|
954
1150
|
});
|
|
955
|
-
var
|
|
1151
|
+
var beaconNodeDef = defineComputeNode({
|
|
956
1152
|
type: "beacon",
|
|
957
1153
|
name: "Beacon",
|
|
958
1154
|
icon: "ph--sun--regular",
|
|
1155
|
+
group: "Outputs",
|
|
1156
|
+
schema: withZ(BeaconShape),
|
|
959
1157
|
component: BeaconComponent,
|
|
960
|
-
|
|
961
|
-
|
|
1158
|
+
create: createBeacon,
|
|
1159
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("input")]: {
|
|
962
1160
|
x: -1,
|
|
963
1161
|
y: 0
|
|
964
1162
|
} })
|
|
965
|
-
};
|
|
1163
|
+
});
|
|
966
1164
|
//#endregion
|
|
967
1165
|
//#region src/shapes/Chat.tsx
|
|
968
|
-
var TextInputComponent = ({ shape, title,
|
|
1166
|
+
var TextInputComponent = ({ node: shape, title, placeholder }) => {
|
|
969
1167
|
const { runtime } = useComputeNodeState(shape);
|
|
970
1168
|
const inputRef = useRef(null);
|
|
971
1169
|
const handleEnter = (text) => {
|
|
@@ -981,7 +1179,7 @@ var TextInputComponent = ({ shape, title, ...props }) => {
|
|
|
981
1179
|
children: /* @__PURE__ */ jsx(TextBox, {
|
|
982
1180
|
ref: inputRef,
|
|
983
1181
|
onEnter: handleEnter,
|
|
984
|
-
|
|
1182
|
+
placeholder
|
|
985
1183
|
})
|
|
986
1184
|
});
|
|
987
1185
|
};
|
|
@@ -996,22 +1194,24 @@ var createChat = (props) => createShape({
|
|
|
996
1194
|
},
|
|
997
1195
|
...props
|
|
998
1196
|
});
|
|
999
|
-
var
|
|
1197
|
+
var chatNodeDef = defineComputeNode({
|
|
1000
1198
|
type: "chat",
|
|
1001
1199
|
name: "Chat",
|
|
1002
1200
|
icon: "ph--textbox--regular",
|
|
1201
|
+
group: "Inputs",
|
|
1202
|
+
schema: withZ(ChatShape),
|
|
1003
1203
|
component: (props) => /* @__PURE__ */ jsx(TextInputComponent, {
|
|
1004
1204
|
...props,
|
|
1005
1205
|
title: "Prompt",
|
|
1006
1206
|
placeholder: "Message"
|
|
1007
1207
|
}),
|
|
1008
|
-
|
|
1009
|
-
|
|
1208
|
+
create: createChat,
|
|
1209
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1010
1210
|
x: 1,
|
|
1011
1211
|
y: 0
|
|
1012
1212
|
} }),
|
|
1013
1213
|
resizable: true
|
|
1014
|
-
};
|
|
1214
|
+
});
|
|
1015
1215
|
//#endregion
|
|
1016
1216
|
//#region src/shapes/Constant.tsx
|
|
1017
1217
|
var inferType = (value) => {
|
|
@@ -1020,7 +1220,7 @@ var inferType = (value) => {
|
|
|
1020
1220
|
else if (typeof value === "boolean") return "boolean";
|
|
1021
1221
|
else if (typeof value === "object") return "object";
|
|
1022
1222
|
};
|
|
1023
|
-
var ConstantComponent = ({ shape, title,
|
|
1223
|
+
var ConstantComponent = ({ node: shape, title, placeholder }) => {
|
|
1024
1224
|
const { node } = useComputeNodeState(shape);
|
|
1025
1225
|
const [type, setType] = useState(inferType(node.value) ?? ComputeValueType.literals[0]);
|
|
1026
1226
|
const inputRef = useRef(null);
|
|
@@ -1044,16 +1244,17 @@ var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
|
1044
1244
|
}),
|
|
1045
1245
|
children: [
|
|
1046
1246
|
(type === "string" || type === "number") && /* @__PURE__ */ jsx(TextBox, {
|
|
1047
|
-
|
|
1247
|
+
placeholder,
|
|
1048
1248
|
ref: inputRef,
|
|
1049
1249
|
value: node.value,
|
|
1050
1250
|
onEnter: handleEnter
|
|
1051
1251
|
}),
|
|
1052
1252
|
type === "object" && /* @__PURE__ */ jsx(TextBox, {
|
|
1053
|
-
|
|
1253
|
+
placeholder,
|
|
1054
1254
|
ref: inputRef,
|
|
1055
1255
|
value: JSON.stringify(node.value, null, 2),
|
|
1056
|
-
language: "json"
|
|
1256
|
+
language: "json",
|
|
1257
|
+
onEnter: handleEnter
|
|
1057
1258
|
}),
|
|
1058
1259
|
type === "boolean" && /* @__PURE__ */ jsx("div", {
|
|
1059
1260
|
className: "flex grow justify-center items-center",
|
|
@@ -1081,24 +1282,26 @@ var createConstant = (props) => createShape({
|
|
|
1081
1282
|
},
|
|
1082
1283
|
...props
|
|
1083
1284
|
});
|
|
1084
|
-
var
|
|
1285
|
+
var constantNodeDef = defineComputeNode({
|
|
1085
1286
|
type: "constant",
|
|
1086
1287
|
name: "Value",
|
|
1087
1288
|
icon: "ph--dots-three-circle--regular",
|
|
1289
|
+
group: "Inputs",
|
|
1290
|
+
schema: withZ(ConstantShape),
|
|
1088
1291
|
component: (props) => /* @__PURE__ */ jsx(ConstantComponent, {
|
|
1089
1292
|
...props,
|
|
1090
1293
|
placeholder: "Constant"
|
|
1091
1294
|
}),
|
|
1092
|
-
|
|
1093
|
-
|
|
1295
|
+
create: createConstant,
|
|
1296
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1094
1297
|
x: 1,
|
|
1095
1298
|
y: 0
|
|
1096
1299
|
} }),
|
|
1097
1300
|
resizable: true
|
|
1098
|
-
};
|
|
1301
|
+
});
|
|
1099
1302
|
//#endregion
|
|
1100
1303
|
//#region src/shapes/Database.tsx
|
|
1101
|
-
var DatabaseComponent = ({ shape }) => {
|
|
1304
|
+
var DatabaseComponent = ({ node: shape }) => {
|
|
1102
1305
|
return /* @__PURE__ */ jsx(Box, { shape });
|
|
1103
1306
|
};
|
|
1104
1307
|
//#endregion
|
|
@@ -1112,20 +1315,22 @@ var createDatabase = (props) => createShape({
|
|
|
1112
1315
|
},
|
|
1113
1316
|
...props
|
|
1114
1317
|
});
|
|
1115
|
-
var
|
|
1318
|
+
var databaseNodeDef = defineComputeNode({
|
|
1116
1319
|
type: "database",
|
|
1117
1320
|
name: "ECHO",
|
|
1118
1321
|
icon: "ph--database--regular",
|
|
1322
|
+
group: "Transform",
|
|
1323
|
+
schema: withZ(DatabaseShape),
|
|
1119
1324
|
component: DatabaseComponent,
|
|
1120
|
-
|
|
1121
|
-
|
|
1325
|
+
create: createDatabase,
|
|
1326
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1122
1327
|
x: 1,
|
|
1123
1328
|
y: 0
|
|
1124
1329
|
} })
|
|
1125
|
-
};
|
|
1330
|
+
});
|
|
1126
1331
|
//#endregion
|
|
1127
1332
|
//#region src/shapes/Feed.tsx
|
|
1128
|
-
var FeedComponent = ({ shape }) => {
|
|
1333
|
+
var FeedComponent = ({ node: shape }) => {
|
|
1129
1334
|
const { runtime } = useComputeNodeState(shape);
|
|
1130
1335
|
const items = runtime.outputs[DEFAULT_OUTPUT]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT].value : [];
|
|
1131
1336
|
return /* @__PURE__ */ jsx(Box, {
|
|
@@ -1167,18 +1372,20 @@ var createFeed = (props) => createShape({
|
|
|
1167
1372
|
},
|
|
1168
1373
|
...props
|
|
1169
1374
|
});
|
|
1170
|
-
var
|
|
1375
|
+
var feedNodeDef = defineComputeNode({
|
|
1171
1376
|
type: "queue",
|
|
1172
1377
|
name: "Feed",
|
|
1173
1378
|
icon: "ph--queue--regular",
|
|
1379
|
+
group: "Outputs",
|
|
1380
|
+
schema: withZ(FeedShape),
|
|
1174
1381
|
component: FeedComponent,
|
|
1175
|
-
|
|
1176
|
-
|
|
1382
|
+
create: createFeed,
|
|
1383
|
+
ports: (shape) => createFunctionPorts(shape.size, QueueInput, QueueOutput),
|
|
1177
1384
|
resizable: true
|
|
1178
|
-
};
|
|
1385
|
+
});
|
|
1179
1386
|
//#endregion
|
|
1180
1387
|
//#region src/shapes/Function.tsx
|
|
1181
|
-
var FunctionShapeComponent = ({ shape,
|
|
1388
|
+
var FunctionShapeComponent = ({ node: shape, placeholder }) => {
|
|
1182
1389
|
const client = useClient();
|
|
1183
1390
|
const { node, runtime } = useComputeNodeState(shape);
|
|
1184
1391
|
const inputRef = useRef(null);
|
|
@@ -1205,7 +1412,7 @@ var FunctionShapeComponent = ({ shape, title, ...props }) => {
|
|
|
1205
1412
|
title: "Function",
|
|
1206
1413
|
onAction: handleAction,
|
|
1207
1414
|
children: /* @__PURE__ */ jsx(TextBox, {
|
|
1208
|
-
|
|
1415
|
+
placeholder,
|
|
1209
1416
|
ref: inputRef,
|
|
1210
1417
|
value: node.value,
|
|
1211
1418
|
language: node.valueType === "object" ? "json" : void 0,
|
|
@@ -1225,17 +1432,19 @@ var createFunction = (props) => createShape({
|
|
|
1225
1432
|
},
|
|
1226
1433
|
...props
|
|
1227
1434
|
});
|
|
1228
|
-
var
|
|
1435
|
+
var functionNodeDef = defineComputeNode({
|
|
1229
1436
|
type: "function",
|
|
1230
1437
|
name: "Function",
|
|
1231
1438
|
icon: "ph--function--regular",
|
|
1439
|
+
group: "Transform",
|
|
1440
|
+
schema: withZ(FunctionShape),
|
|
1232
1441
|
component: FunctionShapeComponent,
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
};
|
|
1442
|
+
create: createFunction,
|
|
1443
|
+
ports: (shape) => createFunctionPorts(shape.size, FunctionInput, AnyOutput)
|
|
1444
|
+
});
|
|
1236
1445
|
//#endregion
|
|
1237
1446
|
//#region src/shapes/Gpt.tsx
|
|
1238
|
-
var GptComponent = ({ shape }) => {
|
|
1447
|
+
var GptComponent = ({ node: shape }) => {
|
|
1239
1448
|
const { meta, runtime } = useComputeNodeState(shape);
|
|
1240
1449
|
const [text, setText] = useState("");
|
|
1241
1450
|
const [tokens, setTokens] = useState(0);
|
|
@@ -1287,19 +1496,21 @@ var createGpt = (props) => createShape({
|
|
|
1287
1496
|
},
|
|
1288
1497
|
...props
|
|
1289
1498
|
});
|
|
1290
|
-
var
|
|
1499
|
+
var gptNodeDef = defineComputeNode({
|
|
1291
1500
|
type: "gpt",
|
|
1292
1501
|
name: "GPT",
|
|
1293
1502
|
icon: "ph--brain--regular",
|
|
1503
|
+
group: "Transform",
|
|
1504
|
+
schema: withZ(GptShape),
|
|
1294
1505
|
component: GptComponent,
|
|
1295
|
-
|
|
1296
|
-
|
|
1506
|
+
create: createGpt,
|
|
1507
|
+
ports: (shape) => createFunctionPorts(shape.size, GptInput, GptOutput),
|
|
1297
1508
|
openable: true
|
|
1298
|
-
};
|
|
1509
|
+
});
|
|
1299
1510
|
//#endregion
|
|
1300
1511
|
//#region src/shapes/GptRealtime.tsx
|
|
1301
1512
|
var __dxlog_file$1 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
1302
|
-
var GptRealtimeComponent = ({ shape }) => {
|
|
1513
|
+
var GptRealtimeComponent = ({ node: shape }) => {
|
|
1303
1514
|
const [isLive, setIsLive] = useState(false);
|
|
1304
1515
|
const [isReady, setIsReady] = useState(false);
|
|
1305
1516
|
const config = useConfig();
|
|
@@ -1400,18 +1611,20 @@ var createGptRealtime = (props) => createShape({
|
|
|
1400
1611
|
},
|
|
1401
1612
|
...props
|
|
1402
1613
|
});
|
|
1403
|
-
var
|
|
1614
|
+
var gptRealtimeNodeDef = defineComputeNode({
|
|
1404
1615
|
type: "gpt-realtime",
|
|
1405
1616
|
name: "GPT Realtime",
|
|
1406
1617
|
icon: "ph--pulse--regular",
|
|
1618
|
+
group: "Transform",
|
|
1619
|
+
schema: withZ(GptRealtimeShape),
|
|
1407
1620
|
component: GptRealtimeComponent,
|
|
1408
|
-
|
|
1409
|
-
|
|
1621
|
+
create: createGptRealtime,
|
|
1622
|
+
ports: (shape) => createFunctionPorts(shape.size, Schema.Struct({ audio: Schema.Any }), Schema.Struct({})),
|
|
1410
1623
|
resizable: true
|
|
1411
|
-
};
|
|
1624
|
+
});
|
|
1412
1625
|
//#endregion
|
|
1413
1626
|
//#region src/shapes/Json.tsx
|
|
1414
|
-
var JsonComponent = ({ shape
|
|
1627
|
+
var JsonComponent = ({ node: shape }) => {
|
|
1415
1628
|
const { runtime } = useComputeNodeState(shape);
|
|
1416
1629
|
const input = runtime.inputs[DEFAULT_INPUT];
|
|
1417
1630
|
const value = input?.type === "executed" ? input.value : void 0;
|
|
@@ -1423,7 +1636,7 @@ var JsonComponent = ({ shape, ...props }) => {
|
|
|
1423
1636
|
})
|
|
1424
1637
|
});
|
|
1425
1638
|
};
|
|
1426
|
-
var JsonTransformComponent = ({ shape
|
|
1639
|
+
var JsonTransformComponent = ({ node: shape }) => {
|
|
1427
1640
|
return /* @__PURE__ */ jsx(Box, { shape });
|
|
1428
1641
|
};
|
|
1429
1642
|
//#endregion
|
|
@@ -1438,13 +1651,15 @@ var createJson = (props) => createShape({
|
|
|
1438
1651
|
},
|
|
1439
1652
|
...props
|
|
1440
1653
|
});
|
|
1441
|
-
var
|
|
1654
|
+
var jsonNodeDef = defineComputeNode({
|
|
1442
1655
|
type: "json",
|
|
1443
1656
|
name: "JSON",
|
|
1444
1657
|
icon: "ph--code--regular",
|
|
1658
|
+
group: "Outputs",
|
|
1659
|
+
schema: withZ(JsonShape),
|
|
1445
1660
|
component: JsonComponent,
|
|
1446
|
-
|
|
1447
|
-
|
|
1661
|
+
create: createJson,
|
|
1662
|
+
ports: (shape) => createPorts(shape.size, {
|
|
1448
1663
|
[createAnchorId("input")]: {
|
|
1449
1664
|
x: -1,
|
|
1450
1665
|
y: 0
|
|
@@ -1455,7 +1670,7 @@ var jsonShape = {
|
|
|
1455
1670
|
}
|
|
1456
1671
|
}),
|
|
1457
1672
|
resizable: true
|
|
1458
|
-
};
|
|
1673
|
+
});
|
|
1459
1674
|
var createJsonTransform = (props) => createShape({
|
|
1460
1675
|
type: "json-transform",
|
|
1461
1676
|
size: {
|
|
@@ -1464,25 +1679,27 @@ var createJsonTransform = (props) => createShape({
|
|
|
1464
1679
|
},
|
|
1465
1680
|
...props
|
|
1466
1681
|
});
|
|
1467
|
-
var
|
|
1682
|
+
var jsonTransformNodeDef = defineComputeNode({
|
|
1468
1683
|
type: "json-transform",
|
|
1469
1684
|
name: "Transform",
|
|
1470
1685
|
icon: "ph--shuffle-simple--regular",
|
|
1686
|
+
group: "Operations",
|
|
1687
|
+
schema: withZ(JsonTransformShape),
|
|
1471
1688
|
component: JsonTransformComponent,
|
|
1472
|
-
|
|
1473
|
-
|
|
1689
|
+
create: createJsonTransform,
|
|
1690
|
+
ports: (shape) => createFunctionPorts(shape.size, JsonTransformInput, DefaultOutput),
|
|
1474
1691
|
resizable: true
|
|
1475
|
-
};
|
|
1692
|
+
});
|
|
1476
1693
|
//#endregion
|
|
1477
1694
|
//#region src/shapes/Logic.tsx
|
|
1478
|
-
var IfComponent = ({ shape
|
|
1695
|
+
var IfComponent = ({ node: shape }) => {
|
|
1479
1696
|
return /* @__PURE__ */ jsx(FunctionBody, {
|
|
1480
1697
|
shape,
|
|
1481
1698
|
inputSchema: IfInput,
|
|
1482
1699
|
outputSchema: IfOutput
|
|
1483
1700
|
});
|
|
1484
1701
|
};
|
|
1485
|
-
var IfElseComponent = ({ shape
|
|
1702
|
+
var IfElseComponent = ({ node: shape }) => {
|
|
1486
1703
|
return /* @__PURE__ */ jsx(FunctionBody, {
|
|
1487
1704
|
shape,
|
|
1488
1705
|
inputSchema: IfElseInput,
|
|
@@ -1501,14 +1718,16 @@ var createIf = (props) => createShape({
|
|
|
1501
1718
|
},
|
|
1502
1719
|
...props
|
|
1503
1720
|
});
|
|
1504
|
-
var
|
|
1721
|
+
var ifNodeDef = defineComputeNode({
|
|
1505
1722
|
type: "if",
|
|
1506
1723
|
name: "IF",
|
|
1507
1724
|
icon: "ph--arrows-split--regular",
|
|
1725
|
+
group: "Operations",
|
|
1726
|
+
schema: withZ(IfShape),
|
|
1508
1727
|
component: IfComponent,
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
};
|
|
1728
|
+
create: createIf,
|
|
1729
|
+
ports: (shape) => createFunctionPorts(shape.size, IfInput, IfOutput)
|
|
1730
|
+
});
|
|
1512
1731
|
var createIfElse = (props) => createShape({
|
|
1513
1732
|
type: "if-else",
|
|
1514
1733
|
size: {
|
|
@@ -1517,14 +1736,16 @@ var createIfElse = (props) => createShape({
|
|
|
1517
1736
|
},
|
|
1518
1737
|
...props
|
|
1519
1738
|
});
|
|
1520
|
-
var
|
|
1739
|
+
var ifElseNodeDef = defineComputeNode({
|
|
1521
1740
|
type: "if-else",
|
|
1522
1741
|
name: "IF/ELSE",
|
|
1523
1742
|
icon: "ph--arrows-merge--regular",
|
|
1743
|
+
group: "Operations",
|
|
1744
|
+
schema: withZ(IfElseShape),
|
|
1524
1745
|
component: IfElseComponent,
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
};
|
|
1746
|
+
create: createIfElse,
|
|
1747
|
+
ports: (shape) => createFunctionPorts(shape.size, IfElseInput, IfElseOutput)
|
|
1748
|
+
});
|
|
1528
1749
|
//#endregion
|
|
1529
1750
|
//#region src/shapes/RNG.tsx
|
|
1530
1751
|
var icons = [
|
|
@@ -1536,7 +1757,7 @@ var icons = [
|
|
|
1536
1757
|
"ph--dice-six--regular"
|
|
1537
1758
|
];
|
|
1538
1759
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1539
|
-
var RandomComponent = ({ shape }) => {
|
|
1760
|
+
var RandomComponent = ({ node: shape }) => {
|
|
1540
1761
|
const { runtime } = useComputeNodeState(shape);
|
|
1541
1762
|
const [spin, setSpin] = useState(false);
|
|
1542
1763
|
const [icon, setIcon] = useState(pickIcon());
|
|
@@ -1583,20 +1804,22 @@ var createRandom = (props) => createShape({
|
|
|
1583
1804
|
},
|
|
1584
1805
|
...props
|
|
1585
1806
|
});
|
|
1586
|
-
var
|
|
1807
|
+
var randomNodeDef = defineComputeNode({
|
|
1587
1808
|
type: "rng",
|
|
1588
1809
|
name: "Random",
|
|
1589
1810
|
icon: "ph--dice-six--regular",
|
|
1811
|
+
group: "Inputs",
|
|
1812
|
+
schema: withZ(RandomShape),
|
|
1590
1813
|
component: RandomComponent,
|
|
1591
|
-
|
|
1592
|
-
|
|
1814
|
+
create: createRandom,
|
|
1815
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1593
1816
|
x: 1,
|
|
1594
1817
|
y: 0
|
|
1595
1818
|
} })
|
|
1596
|
-
};
|
|
1819
|
+
});
|
|
1597
1820
|
//#endregion
|
|
1598
1821
|
//#region src/shapes/Scope.tsx
|
|
1599
|
-
var ScopeComponent = ({ shape }) => {
|
|
1822
|
+
var ScopeComponent = ({ node: shape }) => {
|
|
1600
1823
|
const { runtime } = useComputeNodeState(shape);
|
|
1601
1824
|
const input = runtime.inputs[DEFAULT_INPUT];
|
|
1602
1825
|
const active = input?.type === "executed" ? input.value : false;
|
|
@@ -1625,28 +1848,32 @@ var createScope = (props) => createShape({
|
|
|
1625
1848
|
classNames: "rounded-full border-primary-800",
|
|
1626
1849
|
...props
|
|
1627
1850
|
});
|
|
1628
|
-
var
|
|
1851
|
+
var scopeNodeDef = defineComputeNode({
|
|
1629
1852
|
type: "scope",
|
|
1630
1853
|
name: "Scope",
|
|
1631
1854
|
icon: "ph--waveform--regular",
|
|
1855
|
+
group: "Outputs",
|
|
1856
|
+
schema: withZ(ScopeShape),
|
|
1632
1857
|
component: ScopeComponent,
|
|
1633
|
-
|
|
1634
|
-
|
|
1858
|
+
create: createScope,
|
|
1859
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("input")]: {
|
|
1635
1860
|
x: -1,
|
|
1636
1861
|
y: 0
|
|
1637
1862
|
} })
|
|
1638
|
-
};
|
|
1863
|
+
});
|
|
1639
1864
|
//#endregion
|
|
1640
1865
|
//#region src/shapes/Surface.tsx
|
|
1641
|
-
var SurfaceComponent = ({ shape }) => {
|
|
1866
|
+
var SurfaceComponent = ({ node: shape }) => {
|
|
1642
1867
|
const { runtime } = useComputeNodeState(shape);
|
|
1643
1868
|
const input = runtime.inputs[DEFAULT_INPUT];
|
|
1644
1869
|
const value = input?.type === "executed" ? input.value : null;
|
|
1645
1870
|
return /* @__PURE__ */ jsx(Box, {
|
|
1646
1871
|
shape,
|
|
1647
|
-
children: /* @__PURE__ */ jsx(Card.Root, {
|
|
1872
|
+
children: value !== null && /* @__PURE__ */ jsx(Card.Root, {
|
|
1648
1873
|
grid: true,
|
|
1649
|
-
|
|
1874
|
+
border: false,
|
|
1875
|
+
classNames: "dx-grow",
|
|
1876
|
+
children: /* @__PURE__ */ jsx(Surface.Surface, {
|
|
1650
1877
|
type: AppSurface.CardContent,
|
|
1651
1878
|
data: { subject: value },
|
|
1652
1879
|
limit: 1
|
|
@@ -1665,21 +1892,23 @@ var createSurface = (props) => createShape({
|
|
|
1665
1892
|
},
|
|
1666
1893
|
...props
|
|
1667
1894
|
});
|
|
1668
|
-
var
|
|
1895
|
+
var surfaceNodeDef = defineComputeNode({
|
|
1669
1896
|
type: "surface",
|
|
1670
1897
|
name: "Surface",
|
|
1671
1898
|
icon: "ph--frame-corners--regular",
|
|
1899
|
+
group: "Outputs",
|
|
1900
|
+
schema: withZ(SurfaceShape),
|
|
1672
1901
|
component: SurfaceComponent,
|
|
1673
|
-
|
|
1674
|
-
|
|
1902
|
+
create: createSurface,
|
|
1903
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("input")]: {
|
|
1675
1904
|
x: -1,
|
|
1676
1905
|
y: 0
|
|
1677
1906
|
} }),
|
|
1678
1907
|
resizable: true
|
|
1679
|
-
};
|
|
1908
|
+
});
|
|
1680
1909
|
//#endregion
|
|
1681
1910
|
//#region src/shapes/Switch.tsx
|
|
1682
|
-
var SwitchComponent = ({ shape }) => {
|
|
1911
|
+
var SwitchComponent = ({ node: shape }) => {
|
|
1683
1912
|
const { runtime } = useComputeNodeState(shape);
|
|
1684
1913
|
const [value, setValue] = useState(false);
|
|
1685
1914
|
useEffect(() => {
|
|
@@ -1687,12 +1916,15 @@ var SwitchComponent = ({ shape }) => {
|
|
|
1687
1916
|
}, [value]);
|
|
1688
1917
|
return /* @__PURE__ */ jsx("div", {
|
|
1689
1918
|
className: "flex w-full justify-center items-center",
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1919
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1920
|
+
className: "inline-flex",
|
|
1921
|
+
onPointerDown: (ev) => ev.stopPropagation(),
|
|
1922
|
+
onClick: (ev) => ev.stopPropagation(),
|
|
1923
|
+
children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(Input.Switch, {
|
|
1924
|
+
checked: value,
|
|
1925
|
+
onCheckedChange: ({ checked: value }) => setValue(value)
|
|
1926
|
+
}) })
|
|
1927
|
+
})
|
|
1696
1928
|
});
|
|
1697
1929
|
};
|
|
1698
1930
|
//#endregion
|
|
@@ -1706,20 +1938,22 @@ var createSwitch = (props) => createShape({
|
|
|
1706
1938
|
},
|
|
1707
1939
|
...props
|
|
1708
1940
|
});
|
|
1709
|
-
var
|
|
1941
|
+
var switchNodeDef = defineComputeNode({
|
|
1710
1942
|
type: "switch",
|
|
1711
1943
|
name: "Switch",
|
|
1712
1944
|
icon: "ph--toggle-left--regular",
|
|
1945
|
+
group: "Inputs",
|
|
1946
|
+
schema: withZ(SwitchShape),
|
|
1713
1947
|
component: SwitchComponent,
|
|
1714
|
-
|
|
1715
|
-
|
|
1948
|
+
create: createSwitch,
|
|
1949
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1716
1950
|
x: 1,
|
|
1717
1951
|
y: 0
|
|
1718
1952
|
} })
|
|
1719
|
-
};
|
|
1953
|
+
});
|
|
1720
1954
|
//#endregion
|
|
1721
1955
|
//#region src/shapes/Table.tsx
|
|
1722
|
-
var TableComponent = ({ shape }) => {
|
|
1956
|
+
var TableComponent = ({ node: shape }) => {
|
|
1723
1957
|
return /* @__PURE__ */ jsx(Box, { shape });
|
|
1724
1958
|
};
|
|
1725
1959
|
//#endregion
|
|
@@ -1735,19 +1969,20 @@ var createTable = (props) => createShape({
|
|
|
1735
1969
|
},
|
|
1736
1970
|
...props
|
|
1737
1971
|
});
|
|
1738
|
-
var
|
|
1972
|
+
var tableNodeDef = defineComputeNode({
|
|
1739
1973
|
type: "table",
|
|
1740
1974
|
name: "Table",
|
|
1741
1975
|
icon: "ph--table--regular",
|
|
1976
|
+
schema: withZ(TableShape),
|
|
1742
1977
|
component: TableComponent,
|
|
1743
|
-
|
|
1744
|
-
|
|
1978
|
+
create: createTable,
|
|
1979
|
+
ports: (shape) => createFunctionPorts(shape.size, InputSchema$1, OutputSchema$1),
|
|
1745
1980
|
resizable: true
|
|
1746
|
-
};
|
|
1981
|
+
});
|
|
1747
1982
|
//#endregion
|
|
1748
1983
|
//#region src/shapes/Template.tsx
|
|
1749
1984
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
1750
|
-
var TextInputComponent$1 = ({ shape,
|
|
1985
|
+
var TextInputComponent$1 = ({ node: shape, placeholder }) => {
|
|
1751
1986
|
const { node } = useComputeNodeState(shape);
|
|
1752
1987
|
const inputRef = useRef(null);
|
|
1753
1988
|
const handleEnter = (text) => {
|
|
@@ -1762,7 +1997,7 @@ var TextInputComponent$1 = ({ shape, title, ...props }) => {
|
|
|
1762
1997
|
invariant(Schema.is(ComputeValueType)(newType), "Invalid type", {
|
|
1763
1998
|
"~LogMeta": "~LogMeta",
|
|
1764
1999
|
F: __dxlog_file,
|
|
1765
|
-
L:
|
|
2000
|
+
L: 44,
|
|
1766
2001
|
S: void 0,
|
|
1767
2002
|
A: ["Schema.is(ComputeValueType)(newType)", "'Invalid type'"]
|
|
1768
2003
|
});
|
|
@@ -1777,7 +2012,7 @@ var TextInputComponent$1 = ({ shape, title, ...props }) => {
|
|
|
1777
2012
|
onValueChange: handleTypeChange
|
|
1778
2013
|
}),
|
|
1779
2014
|
children: /* @__PURE__ */ jsx(TextBox, {
|
|
1780
|
-
|
|
2015
|
+
placeholder,
|
|
1781
2016
|
ref: inputRef,
|
|
1782
2017
|
value: node.value,
|
|
1783
2018
|
language: node.valueType === "object" ? "json" : void 0,
|
|
@@ -1804,18 +2039,20 @@ var createTemplate = (props) => createShape({
|
|
|
1804
2039
|
},
|
|
1805
2040
|
...props
|
|
1806
2041
|
});
|
|
1807
|
-
var
|
|
2042
|
+
var templateNodeDef = defineComputeNode({
|
|
1808
2043
|
type: "template",
|
|
1809
2044
|
name: "Template",
|
|
1810
2045
|
icon: "ph--article--regular",
|
|
2046
|
+
group: "Inputs",
|
|
2047
|
+
schema: withZ(TemplateShape),
|
|
1811
2048
|
component: TemplateComponent,
|
|
1812
|
-
|
|
1813
|
-
|
|
2049
|
+
create: createTemplate,
|
|
2050
|
+
ports: (shape) => createFunctionPorts(shape.size, VoidInput, TemplateOutput),
|
|
1814
2051
|
resizable: true
|
|
1815
|
-
};
|
|
2052
|
+
});
|
|
1816
2053
|
//#endregion
|
|
1817
2054
|
//#region src/shapes/Text.tsx
|
|
1818
|
-
var TextComponent = ({ shape }) => {
|
|
2055
|
+
var TextComponent = ({ node: shape }) => {
|
|
1819
2056
|
const { runtime } = useComputeNodeState(shape);
|
|
1820
2057
|
const input = runtime.inputs[DEFAULT_INPUT];
|
|
1821
2058
|
const value = input?.type === "executed" ? input.value : 0;
|
|
@@ -1835,21 +2072,23 @@ var createText = (props) => createShape({
|
|
|
1835
2072
|
},
|
|
1836
2073
|
...props
|
|
1837
2074
|
});
|
|
1838
|
-
var
|
|
2075
|
+
var textNodeDef = defineComputeNode({
|
|
1839
2076
|
type: "text",
|
|
1840
2077
|
name: "Text",
|
|
1841
2078
|
icon: "ph--article--regular",
|
|
2079
|
+
group: "Outputs",
|
|
2080
|
+
schema: withZ(TextShape),
|
|
1842
2081
|
component: TextComponent,
|
|
1843
|
-
|
|
1844
|
-
|
|
2082
|
+
create: createText,
|
|
2083
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("input")]: {
|
|
1845
2084
|
x: -1,
|
|
1846
2085
|
y: 0
|
|
1847
2086
|
} }),
|
|
1848
2087
|
resizable: true
|
|
1849
|
-
};
|
|
2088
|
+
});
|
|
1850
2089
|
//#endregion
|
|
1851
2090
|
//#region src/shapes/TextToImage.tsx
|
|
1852
|
-
var TextToImageComponent = ({ shape }) => {
|
|
2091
|
+
var TextToImageComponent = ({ node: shape }) => {
|
|
1853
2092
|
return /* @__PURE__ */ jsx(Box, { shape });
|
|
1854
2093
|
};
|
|
1855
2094
|
//#endregion
|
|
@@ -1863,20 +2102,22 @@ var createTextToImage = (props) => createShape({
|
|
|
1863
2102
|
},
|
|
1864
2103
|
...props
|
|
1865
2104
|
});
|
|
1866
|
-
var
|
|
2105
|
+
var textToImageNodeDef = defineComputeNode({
|
|
1867
2106
|
type: "text-to-image",
|
|
1868
2107
|
name: "Image",
|
|
1869
2108
|
icon: "ph--image--regular",
|
|
2109
|
+
group: "Transform",
|
|
2110
|
+
schema: withZ(TextToImageShape),
|
|
1870
2111
|
component: TextToImageComponent,
|
|
1871
|
-
|
|
1872
|
-
|
|
2112
|
+
create: createTextToImage,
|
|
2113
|
+
ports: (shape) => createPorts(shape.size, { [createAnchorId("output")]: {
|
|
1873
2114
|
x: 1,
|
|
1874
2115
|
y: 0
|
|
1875
2116
|
} })
|
|
1876
|
-
};
|
|
2117
|
+
});
|
|
1877
2118
|
//#endregion
|
|
1878
2119
|
//#region src/shapes/Thread.tsx
|
|
1879
|
-
var ThreadComponent = ({ shape }) => {
|
|
2120
|
+
var ThreadComponent = ({ node: shape }) => {
|
|
1880
2121
|
const items = [];
|
|
1881
2122
|
const scrollRef = useRef(null);
|
|
1882
2123
|
useEffect(() => {
|
|
@@ -1921,15 +2162,17 @@ var createThread = (props) => createShape({
|
|
|
1921
2162
|
},
|
|
1922
2163
|
...props
|
|
1923
2164
|
});
|
|
1924
|
-
var
|
|
2165
|
+
var threadNodeDef = defineComputeNode({
|
|
1925
2166
|
type: "thread",
|
|
1926
2167
|
name: "Thread",
|
|
1927
2168
|
icon: "ph--chats-circle--regular",
|
|
2169
|
+
group: "Outputs",
|
|
2170
|
+
schema: withZ(ThreadShape),
|
|
1928
2171
|
component: ThreadComponent,
|
|
1929
|
-
|
|
1930
|
-
|
|
2172
|
+
create: createThread,
|
|
2173
|
+
ports: (shape) => createFunctionPorts(shape.size, InputSchema, OutputSchema),
|
|
1931
2174
|
resizable: true
|
|
1932
|
-
};
|
|
2175
|
+
});
|
|
1933
2176
|
//#endregion
|
|
1934
2177
|
//#region src/shapes/trigger-spec.ts
|
|
1935
2178
|
var createTriggerSpec = (props) => {
|
|
@@ -1954,7 +2197,7 @@ var getOutputSchema = (kind) => {
|
|
|
1954
2197
|
};
|
|
1955
2198
|
//#endregion
|
|
1956
2199
|
//#region src/shapes/Trigger.tsx
|
|
1957
|
-
var TriggerComponent = ({ shape }) => {
|
|
2200
|
+
var TriggerComponent = ({ node: shape }) => {
|
|
1958
2201
|
const [space] = useSpaces();
|
|
1959
2202
|
const functionTrigger = useResolveRef(shape.functionTrigger);
|
|
1960
2203
|
useEffect(() => {
|
|
@@ -2027,14 +2270,20 @@ var createTrigger = (props) => {
|
|
|
2027
2270
|
...props
|
|
2028
2271
|
});
|
|
2029
2272
|
};
|
|
2030
|
-
var
|
|
2273
|
+
var triggerNodeDef = defineComputeNode({
|
|
2031
2274
|
type: "trigger",
|
|
2032
2275
|
name: "Trigger",
|
|
2033
2276
|
icon: "ph--lightning--regular",
|
|
2277
|
+
group: "Inputs",
|
|
2278
|
+
schema: withZ(TriggerShapeSchema),
|
|
2034
2279
|
component: TriggerComponent,
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2280
|
+
create: createTrigger,
|
|
2281
|
+
defaultSize: {
|
|
2282
|
+
width: 192,
|
|
2283
|
+
height: getHeight(TriggerEvent.EmailEvent)
|
|
2284
|
+
},
|
|
2285
|
+
ports: (shape) => createFunctionPorts(shape.size, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2286
|
+
});
|
|
2038
2287
|
//#endregion
|
|
2039
2288
|
//#region src/shapes/Boolean.tsx
|
|
2040
2289
|
var GateShape = ComputeShape.mapFields(Struct.assign({ type: Schema.String }));
|
|
@@ -2045,19 +2294,21 @@ var createGate = (props) => createShape({
|
|
|
2045
2294
|
},
|
|
2046
2295
|
...props
|
|
2047
2296
|
});
|
|
2048
|
-
var
|
|
2297
|
+
var defineGate = ({ type, name, icon, symbol: Symbol, create, inputs, outputs = [createAnchorId("output")] }) => defineComputeNode({
|
|
2049
2298
|
type,
|
|
2050
2299
|
name,
|
|
2051
2300
|
icon,
|
|
2301
|
+
group: "Operations",
|
|
2302
|
+
schema: withZ(GateShape),
|
|
2052
2303
|
component: () => {
|
|
2053
2304
|
return /* @__PURE__ */ jsx("div", {
|
|
2054
2305
|
className: "flex w-full justify-center items-center",
|
|
2055
2306
|
children: /* @__PURE__ */ jsx(Symbol, {})
|
|
2056
2307
|
});
|
|
2057
2308
|
},
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
shape,
|
|
2309
|
+
create,
|
|
2310
|
+
ports: (shape) => createRowPorts({
|
|
2311
|
+
size: shape.size,
|
|
2061
2312
|
inputs,
|
|
2062
2313
|
outputs
|
|
2063
2314
|
})
|
|
@@ -2075,7 +2326,7 @@ var createSymbol = (pathConstructor, inputs) => ({ width = 64, height = 32, clas
|
|
|
2075
2326
|
viewBox: `0 0 ${width} ${height}`,
|
|
2076
2327
|
className: "dx-fill",
|
|
2077
2328
|
children: [
|
|
2078
|
-
|
|
2329
|
+
getRowPoints({
|
|
2079
2330
|
x: 0,
|
|
2080
2331
|
y: centerY
|
|
2081
2332
|
}, inputs).map(({ x, y }, i) => /* @__PURE__ */ jsx("line", {
|
|
@@ -2119,12 +2370,12 @@ var createAnd = (props) => {
|
|
|
2119
2370
|
type: "and"
|
|
2120
2371
|
});
|
|
2121
2372
|
};
|
|
2122
|
-
var
|
|
2373
|
+
var andNodeDef = defineGate({
|
|
2123
2374
|
type: "and",
|
|
2124
2375
|
name: "AND",
|
|
2125
2376
|
icon: "ph--intersection--regular",
|
|
2126
2377
|
symbol: AndSymbol,
|
|
2127
|
-
|
|
2378
|
+
create: createAnd,
|
|
2128
2379
|
inputs: ["input.a", "input.b"]
|
|
2129
2380
|
});
|
|
2130
2381
|
var OrSymbol = createSymbol(({ startX, endX, height }) => {
|
|
@@ -2145,12 +2396,12 @@ var createOr = (props) => {
|
|
|
2145
2396
|
type: "or"
|
|
2146
2397
|
});
|
|
2147
2398
|
};
|
|
2148
|
-
var
|
|
2399
|
+
var orNodeDef = defineGate({
|
|
2149
2400
|
type: "or",
|
|
2150
2401
|
name: "OR",
|
|
2151
2402
|
icon: "ph--union--regular",
|
|
2152
2403
|
symbol: OrSymbol,
|
|
2153
|
-
|
|
2404
|
+
create: createOr,
|
|
2154
2405
|
inputs: ["input.a", "input.b"]
|
|
2155
2406
|
});
|
|
2156
2407
|
var NotSymbol = createSymbol(({ startX, endX, height }) => {
|
|
@@ -2173,72 +2424,54 @@ var createNot = (props) => {
|
|
|
2173
2424
|
type: "not"
|
|
2174
2425
|
});
|
|
2175
2426
|
};
|
|
2176
|
-
var
|
|
2427
|
+
var notNodeDef = defineGate({
|
|
2177
2428
|
type: "not",
|
|
2178
2429
|
name: "NOT",
|
|
2179
2430
|
icon: "ph--x--regular",
|
|
2180
2431
|
symbol: NotSymbol,
|
|
2181
|
-
|
|
2432
|
+
create: createNot,
|
|
2182
2433
|
inputs: [createAnchorId("input")]
|
|
2183
2434
|
});
|
|
2184
2435
|
//#endregion
|
|
2185
2436
|
//#region src/registry.ts
|
|
2186
|
-
/**
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
shapes: [
|
|
2216
|
-
ifShape,
|
|
2217
|
-
ifElseShape,
|
|
2218
|
-
andShape,
|
|
2219
|
-
orShape,
|
|
2220
|
-
notShape,
|
|
2221
|
-
reducerShape,
|
|
2222
|
-
jsonTransformShape
|
|
2223
|
-
]
|
|
2224
|
-
},
|
|
2225
|
-
{
|
|
2226
|
-
title: "Outputs",
|
|
2227
|
-
shapes: [
|
|
2228
|
-
jsonShape,
|
|
2229
|
-
feedShape,
|
|
2230
|
-
threadShape,
|
|
2231
|
-
textShape,
|
|
2232
|
-
surfaceShape,
|
|
2233
|
-
beaconShape,
|
|
2234
|
-
scopeShape
|
|
2235
|
-
]
|
|
2236
|
-
},
|
|
2237
|
-
{
|
|
2238
|
-
title: "Misc",
|
|
2239
|
-
shapes: [noteShape]
|
|
2240
|
-
}
|
|
2437
|
+
/** The compute types in palette order, each under its group (Inputs, Transform, Operations, Outputs). */
|
|
2438
|
+
var computeNodeDefs = [
|
|
2439
|
+
constantNodeDef,
|
|
2440
|
+
templateNodeDef,
|
|
2441
|
+
chatNodeDef,
|
|
2442
|
+
switchNodeDef,
|
|
2443
|
+
audioNodeDef,
|
|
2444
|
+
triggerNodeDef,
|
|
2445
|
+
randomNodeDef,
|
|
2446
|
+
gptNodeDef,
|
|
2447
|
+
gptRealtimeNodeDef,
|
|
2448
|
+
functionNodeDef,
|
|
2449
|
+
databaseNodeDef,
|
|
2450
|
+
textToImageNodeDef,
|
|
2451
|
+
appendNodeDef,
|
|
2452
|
+
ifNodeDef,
|
|
2453
|
+
ifElseNodeDef,
|
|
2454
|
+
andNodeDef,
|
|
2455
|
+
orNodeDef,
|
|
2456
|
+
notNodeDef,
|
|
2457
|
+
reducerNodeDef,
|
|
2458
|
+
jsonTransformNodeDef,
|
|
2459
|
+
jsonNodeDef,
|
|
2460
|
+
feedNodeDef,
|
|
2461
|
+
threadNodeDef,
|
|
2462
|
+
textNodeDef,
|
|
2463
|
+
surfaceNodeDef,
|
|
2464
|
+
beaconNodeDef,
|
|
2465
|
+
scopeNodeDef
|
|
2241
2466
|
];
|
|
2467
|
+
/** The compute types plus the engine's note under a `Misc` group. */
|
|
2468
|
+
var computeNodeRegistry = {
|
|
2469
|
+
...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),
|
|
2470
|
+
note: {
|
|
2471
|
+
...defaultNodeRegistry.note,
|
|
2472
|
+
group: "Misc"
|
|
2473
|
+
}
|
|
2474
|
+
};
|
|
2242
2475
|
//#endregion
|
|
2243
2476
|
//#region src/scene/Bullets.tsx
|
|
2244
2477
|
var RADIUS = 3;
|
|
@@ -2292,124 +2525,6 @@ var fireBullet = (layer, path) => {
|
|
|
2292
2525
|
requestAnimationFrame(step);
|
|
2293
2526
|
};
|
|
2294
2527
|
//#endregion
|
|
2295
|
-
//#region src/scene/NodeView.tsx
|
|
2296
|
-
/**
|
|
2297
|
-
* The shape component under the engine's view props: the node is the shape (it carries the same fields
|
|
2298
|
-
* plus `z`), re-rendered on every controller update since the runtime state it reads is not reactive.
|
|
2299
|
-
*/
|
|
2300
|
-
var computeNodeView = (schema, Component) => {
|
|
2301
|
-
const isShape = Schema.is(schema);
|
|
2302
|
-
const View = (props) => {
|
|
2303
|
-
const { node, selected } = props;
|
|
2304
|
-
const { controller } = useComputeContext();
|
|
2305
|
-
useControllerUpdates(controller);
|
|
2306
|
-
if (!isShape(node)) return /* @__PURE__ */ jsx(UnknownNodeView, { ...props });
|
|
2307
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2308
|
-
className: "dx-cover flex",
|
|
2309
|
-
children: /* @__PURE__ */ jsx(Component, {
|
|
2310
|
-
shape: node,
|
|
2311
|
-
selected
|
|
2312
|
-
})
|
|
2313
|
-
});
|
|
2314
|
-
};
|
|
2315
|
-
View.displayName = `ComputeNodeView(${Component.displayName ?? Component.name})`;
|
|
2316
|
-
return View;
|
|
2317
|
-
};
|
|
2318
|
-
//#endregion
|
|
2319
|
-
//#region src/scene/ports.ts
|
|
2320
|
-
/** The ports of a shape from its anchors; a port's direction comes from the `input.` / `output.` prefix. */
|
|
2321
|
-
var anchorsToPorts = (anchors, size) => Object.values(anchors).map(({ id, pos }) => {
|
|
2322
|
-
const [kind] = parseAnchorId(id);
|
|
2323
|
-
const half = {
|
|
2324
|
-
x: size.width / 2,
|
|
2325
|
-
y: size.height / 2
|
|
2326
|
-
};
|
|
2327
|
-
const vertical = Math.abs(Math.abs(pos.x) - half.x) <= Math.abs(Math.abs(pos.y) - half.y);
|
|
2328
|
-
const side = vertical ? pos.x < 0 ? "w" : "e" : pos.y < 0 ? "n" : "s";
|
|
2329
|
-
const along = vertical ? (pos.y + half.y) / size.height : (pos.x + half.x) / size.width;
|
|
2330
|
-
return {
|
|
2331
|
-
id,
|
|
2332
|
-
side,
|
|
2333
|
-
offset: Math.min(Math.max(along, 0), 1),
|
|
2334
|
-
...kind === "input" ? { accepts: "in" } : kind === "output" ? { accepts: "out" } : {}
|
|
2335
|
-
};
|
|
2336
|
-
});
|
|
2337
|
-
//#endregion
|
|
2338
|
-
//#region src/scene/defs.ts
|
|
2339
|
-
/** The shape's schema with the engine's z-order key, so it is a node schema. */
|
|
2340
|
-
var withZ = (shape) => shape.mapFields(Struct.assign({ z: Schema.String }));
|
|
2341
|
-
/** `schema` is the shape's with `z` (`withZ`), applied at the call site so each stays a concrete struct. */
|
|
2342
|
-
var entry = (group, shape, schema, defaultSize = shape.createShape({
|
|
2343
|
-
id: "default",
|
|
2344
|
-
center: {
|
|
2345
|
-
x: 0,
|
|
2346
|
-
y: 0
|
|
2347
|
-
}
|
|
2348
|
-
}).size) => ({
|
|
2349
|
-
group,
|
|
2350
|
-
def: {
|
|
2351
|
-
type: shape.type,
|
|
2352
|
-
name: shape.name,
|
|
2353
|
-
icon: shape.icon,
|
|
2354
|
-
group,
|
|
2355
|
-
schema,
|
|
2356
|
-
component: computeNodeView(schema, shape.component),
|
|
2357
|
-
create: ({ id, z, center, size }) => ({
|
|
2358
|
-
...shape.createShape({
|
|
2359
|
-
id,
|
|
2360
|
-
center
|
|
2361
|
-
}),
|
|
2362
|
-
z,
|
|
2363
|
-
size
|
|
2364
|
-
}),
|
|
2365
|
-
defaultSize,
|
|
2366
|
-
ports: (node) => isShapeOf(schema, node) ? anchorsToPorts(shape.getAnchors?.(node) ?? {}, node.size) : [],
|
|
2367
|
-
resizable: shape.resizable,
|
|
2368
|
-
openable: shape.openable
|
|
2369
|
-
}
|
|
2370
|
-
});
|
|
2371
|
-
var isShapeOf = (schema, node) => Schema.is(schema)(node);
|
|
2372
|
-
var computeNodeDefs = [
|
|
2373
|
-
entry("Inputs", constantShape, withZ(ConstantShape)),
|
|
2374
|
-
entry("Inputs", templateShape, withZ(TemplateShape)),
|
|
2375
|
-
entry("Inputs", chatShape, withZ(ChatShape)),
|
|
2376
|
-
entry("Inputs", switchShape, withZ(SwitchShape)),
|
|
2377
|
-
entry("Inputs", audioShape, withZ(AudioShape)),
|
|
2378
|
-
entry("Inputs", triggerShape, withZ(TriggerShapeSchema), {
|
|
2379
|
-
width: 192,
|
|
2380
|
-
height: getHeight(TriggerEvent.EmailEvent)
|
|
2381
|
-
}),
|
|
2382
|
-
entry("Inputs", randomShape, withZ(RandomShape)),
|
|
2383
|
-
entry("Transform", gptShape, withZ(GptShape)),
|
|
2384
|
-
entry("Transform", gptRealtimeShape, withZ(GptRealtimeShape)),
|
|
2385
|
-
entry("Transform", functionShape, withZ(FunctionShape)),
|
|
2386
|
-
entry("Transform", databaseShape, withZ(DatabaseShape)),
|
|
2387
|
-
entry("Transform", textToImageShape, withZ(TextToImageShape)),
|
|
2388
|
-
entry("Transform", appendShape, withZ(AppendShape)),
|
|
2389
|
-
entry("Operations", ifShape, withZ(IfShape)),
|
|
2390
|
-
entry("Operations", ifElseShape, withZ(IfElseShape)),
|
|
2391
|
-
entry("Operations", andShape, withZ(AndShape)),
|
|
2392
|
-
entry("Operations", orShape, withZ(OrShape)),
|
|
2393
|
-
entry("Operations", notShape, withZ(NotShape)),
|
|
2394
|
-
entry("Operations", reducerShape, withZ(ReducerShape)),
|
|
2395
|
-
entry("Operations", jsonTransformShape, withZ(JsonTransformShape)),
|
|
2396
|
-
entry("Outputs", jsonShape, withZ(JsonShape)),
|
|
2397
|
-
entry("Outputs", feedShape, withZ(FeedShape)),
|
|
2398
|
-
entry("Outputs", threadShape, withZ(ThreadShape)),
|
|
2399
|
-
entry("Outputs", textShape, withZ(TextShape)),
|
|
2400
|
-
entry("Outputs", surfaceShape, withZ(SurfaceShape)),
|
|
2401
|
-
entry("Outputs", beaconShape, withZ(BeaconShape)),
|
|
2402
|
-
entry("Outputs", scopeShape, withZ(ScopeShape))
|
|
2403
|
-
].map(({ def }) => def);
|
|
2404
|
-
/** The compute types plus the engine's note under a `Misc` group. */
|
|
2405
|
-
var computeNodeRegistry = {
|
|
2406
|
-
...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),
|
|
2407
|
-
note: {
|
|
2408
|
-
...defaultNodeRegistry.note,
|
|
2409
|
-
group: "Misc"
|
|
2410
|
-
}
|
|
2411
|
-
};
|
|
2412
|
-
//#endregion
|
|
2413
2528
|
//#region src/scene/echo-store.ts
|
|
2414
2529
|
/** The scene id a board's own layout takes; a board holds one scene, so it is the board's id. */
|
|
2415
2530
|
var boardSceneId = (board) => board.id;
|
|
@@ -2442,7 +2557,7 @@ var sceneFromLayout = (id, layout, name) => {
|
|
|
2442
2557
|
};
|
|
2443
2558
|
};
|
|
2444
2559
|
var nodeFromShape = (shape, z) => {
|
|
2445
|
-
const { guide: _guide,
|
|
2560
|
+
const { guide: _guide, ...rest } = shape;
|
|
2446
2561
|
const style = styleFromShape(shape);
|
|
2447
2562
|
return {
|
|
2448
2563
|
...rest,
|
|
@@ -2450,12 +2565,11 @@ var nodeFromShape = (shape, z) => {
|
|
|
2450
2565
|
...style ? { style } : {}
|
|
2451
2566
|
};
|
|
2452
2567
|
};
|
|
2453
|
-
/** A shape's look: its own `style` when the engine wrote one, else the editor's
|
|
2568
|
+
/** A shape's look: its own `style` when the engine wrote one, else the editor's top-level `guide`. */
|
|
2454
2569
|
var styleFromShape = (shape) => {
|
|
2455
|
-
const { style, guide
|
|
2570
|
+
const { style, guide } = shape;
|
|
2456
2571
|
const merged = {
|
|
2457
2572
|
...guide !== void 0 ? { guide } : {},
|
|
2458
|
-
...classNames !== void 0 ? { className: classNames } : {},
|
|
2459
2573
|
...style
|
|
2460
2574
|
};
|
|
2461
2575
|
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
@@ -2522,8 +2636,7 @@ var shapeFromNode = (node) => {
|
|
|
2522
2636
|
return {
|
|
2523
2637
|
...rest,
|
|
2524
2638
|
...style ? { style } : {},
|
|
2525
|
-
...style?.guide !== void 0 ? { guide: style.guide } : {}
|
|
2526
|
-
...style?.className !== void 0 ? { classNames: style.className } : {}
|
|
2639
|
+
...style?.guide !== void 0 ? { guide: style.guide } : {}
|
|
2527
2640
|
};
|
|
2528
2641
|
};
|
|
2529
2642
|
var edgeFromLink = (link) => {
|
|
@@ -2723,14 +2836,14 @@ var withRuntimePorts = (controller, node) => {
|
|
|
2723
2836
|
const outputSchema = computeNode.outputSchema ? JsonSchema$1.toEffectSchema(computeNode.outputSchema) : DefaultOutput;
|
|
2724
2837
|
return {
|
|
2725
2838
|
...node,
|
|
2726
|
-
ports:
|
|
2839
|
+
ports: createFunctionPorts(node.size, inputSchema, outputSchema)
|
|
2727
2840
|
};
|
|
2728
2841
|
};
|
|
2729
2842
|
var model = (controller) => controller.graph;
|
|
2730
2843
|
//#endregion
|
|
2731
2844
|
//#region src/scene/scene.ts
|
|
2732
2845
|
var sceneFromCircuit = (model, id = "circuit", name) => {
|
|
2733
|
-
const shapes = model.nodes.filter(
|
|
2846
|
+
const shapes = model.nodes.filter(Schema.is(ComputeShape));
|
|
2734
2847
|
const keys = initialKeys(shapes.length + model.edges.length);
|
|
2735
2848
|
const nodes = {};
|
|
2736
2849
|
shapes.forEach((shape, index) => {
|
|
@@ -2761,7 +2874,7 @@ var sceneFromCircuit = (model, id = "circuit", name) => {
|
|
|
2761
2874
|
node: edge.target,
|
|
2762
2875
|
port: createAnchorId("input", edge.input ?? DEFAULT_INPUT)
|
|
2763
2876
|
},
|
|
2764
|
-
|
|
2877
|
+
ends: { end: "arrow" }
|
|
2765
2878
|
};
|
|
2766
2879
|
});
|
|
2767
2880
|
return {
|
|
@@ -2772,23 +2885,6 @@ var sceneFromCircuit = (model, id = "circuit", name) => {
|
|
|
2772
2885
|
};
|
|
2773
2886
|
};
|
|
2774
2887
|
//#endregion
|
|
2775
|
-
|
|
2776
|
-
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2777
|
-
_controller;
|
|
2778
|
-
constructor(_controller, registry) {
|
|
2779
|
-
super(registry);
|
|
2780
|
-
this._controller = _controller;
|
|
2781
|
-
}
|
|
2782
|
-
getAnchors(shape) {
|
|
2783
|
-
let anchors = this._registry.getShapeDef(shape.type)?.getAnchors?.(shape) ?? {};
|
|
2784
|
-
if (shape.node) {
|
|
2785
|
-
const node = this._controller.graph.getNode(shape.node);
|
|
2786
|
-
if (node.inputSchema || node.outputSchema) anchors = createFunctionAnchors(shape, node.inputSchema ? JsonSchema$1.toEffectSchema(node.inputSchema) : DefaultInput, node.outputSchema ? JsonSchema$1.toEffectSchema(node.outputSchema) : DefaultOutput);
|
|
2787
|
-
}
|
|
2788
|
-
return anchors;
|
|
2789
|
-
}
|
|
2790
|
-
};
|
|
2791
|
-
//#endregion
|
|
2792
|
-
export { AndShape, AppendComponent, AppendShape, AudioComponent, AudioShape, BeaconComponent, BeaconShape, Box, Bullets, ChatShape, ComputeContext, ComputeGraphController, ComputeShape, ComputeShapeLayout, ConstantComponent, ConstantShape, DatabaseComponent, DatabaseShape, FeedComponent, FeedItem, FeedShape, FunctionBody, FunctionShape, FunctionShapeComponent, GptComponent, GptRealtimeComponent, GptRealtimeShape, GptShape, IfComponent, IfElseComponent, IfElseShape, IfShape, InvalidStateError, JsonComponent, JsonShape, JsonTransformComponent, JsonTransformShape, NotShape, OrShape, RandomComponent, RandomShape, ReducerComponent, ReducerShape, ScopeComponent, ScopeShape, SurfaceComponent, SurfaceShape, SwitchComponent, SwitchShape, TableComponent, TableShape, TemplateComponent, TemplateShape, TextComponent, TextInputComponent, TextShape, TextToImageComponent, TextToImageShape, ThreadComponent, ThreadItem, ThreadShape, TriggerComponent, TriggerShape, TriggerShapeSchema, TypeSelect, anchorsToPorts, andShape, appendShape, applySceneToLayout, audioShape, beaconShape, boardSceneId, bodyPadding, chatShape, computeNodeDefs, computeNodeRegistry, computeNodeView, computeShapes, constantShape, createAnchorId, createAnd, createAppend, createAudio, createBeacon, createChat, createComputeGraph, createComputeGraphController, createComputeNode, createComputeProjection, createConstant, createDatabase, createEchoStore, createFeed, createFunction, createFunctionAnchors, createGpt, createGptRealtime, createIf, createIfElse, createJson, createJsonTransform, createNot, createOr, createRandom, createReducer, createScope, createShape, createSurface, createSwitch, createTable, createTemplate, createText, createTextToImage, createThread, createTrigger, databaseShape, deleteTriggerObjects, feedShape, findEdge, findEdges, footerHeight, functionShape, getHeight, getProperties, gptRealtimeShape, gptShape, headerHeight, ifElseShape, ifShape, isValidComputeNode, jsonShape, jsonTransformShape, mapEdge, notShape, orShape, parseAnchorId, randomShape, reducerShape, resolveComputeNode, sceneFromCircuit, sceneFromLayout, scopeShape, surfaceShape, switchShape, syncCreate, syncDelete, syncLink, tableShape, templateShape, textShape, textToImageShape, threadShape, triggerShape, useComputeContext, useComputeGraphController, useComputeNodeState, useControllerUpdates, useGraphMonitor };
|
|
2888
|
+
export { AndShape, AppendComponent, AppendShape, AudioComponent, AudioShape, BeaconComponent, BeaconShape, Box, Bullets, schema_exports as CanvasBoard, CanvasGraphModel, ChatShape, ComputeContext, ComputeGraphController, ComputeNodeDefContext, ComputeShape, ConstantComponent, ConstantShape, DatabaseComponent, DatabaseShape, EllipseShape, FeedComponent, FeedItem, FeedShape, FunctionBody, FunctionShape, FunctionShapeComponent, GptComponent, GptRealtimeComponent, GptRealtimeShape, GptShape, IfComponent, IfElseComponent, IfElseShape, IfShape, InvalidStateError, JsonComponent, JsonShape, JsonTransformComponent, JsonTransformShape, NotShape, NoteShape, OrShape, PathShape, Polygon, RandomComponent, RandomShape, RectangleShape, ReducerComponent, ReducerShape, ScopeComponent, ScopeShape, SurfaceComponent, SurfaceShape, SwitchComponent, SwitchShape, TableComponent, TableShape, TemplateComponent, TemplateShape, TextBox, TextComponent, TextInputComponent, TextShape, TextToImageComponent, TextToImageShape, ThreadComponent, ThreadItem, ThreadShape, TriggerComponent, TriggerShape, TriggerShapeSchema, TypeSelect, andNodeDef, appendNodeDef, applySceneToLayout, audioNodeDef, beaconNodeDef, boardSceneId, chatNodeDef, computeNodeDefs, computeNodeRegistry, constantNodeDef, createAnchorId, createAnd, createAppend, createAudio, createBeacon, createChat, createComputeGraph, createComputeGraphController, createComputeNode, createComputeProjection, createConstant, createDatabase, createEchoStore, createFeed, createFunction, createFunctionPorts, createGpt, createGptRealtime, createIf, createIfElse, createJson, createJsonTransform, createNot, createOr, createPorts, createRandom, createReducer, createRowPorts, createScope, createShape, createSurface, createSwitch, createTable, createTemplate, createText, createTextToImage, createThread, createTrigger, databaseNodeDef, defineComputeNode, deleteTriggerObjects, feedNodeDef, findEdge, findEdges, footerHeight, functionNodeDef, getHeight, getProperties, getRowPoints, gptNodeDef, gptRealtimeNodeDef, headerHeight, ifElseNodeDef, ifNodeDef, isPath, isPolygon, isValidComputeNode, jsonNodeDef, jsonTransformNodeDef, mapEdge, notNodeDef, orNodeDef, parseAnchorId, pointsToPorts, randomNodeDef, reducerNodeDef, resolveComputeNode, rowHeight, sceneFromCircuit, sceneFromLayout, scopeNodeDef, surfaceNodeDef, switchNodeDef, syncCreate, syncDelete, syncLink, tableNodeDef, templateNodeDef, textNodeDef, textToImageNodeDef, threadNodeDef, triggerNodeDef, useComputeContext, useComputeNodeDef, useComputeNodeState, useControllerUpdates, useGraphMonitor, withZ };
|
|
2793
2889
|
|
|
2794
2890
|
//# sourceMappingURL=index.mjs.map
|