@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/src/scene/defs.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2026 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// The compute shapes as scene-engine node definitions (MIGRATION.md M3): each `ShapeDef` becomes a
|
|
7
|
-
// `NodeDef` whose schema is the shape's with the engine's `z`, whose view renders the shape component
|
|
8
|
-
// unchanged, and whose ports come from the shape's anchors. The palette groups mirror the editor's.
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
import * as Schema from 'effect/Schema';
|
|
12
|
-
import * as Struct from 'effect/Struct';
|
|
13
|
-
|
|
14
|
-
import * as TriggerEvent from '@dxos/compute/TriggerEvent';
|
|
15
|
-
import { type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
16
|
-
import {
|
|
17
|
-
type CreateProps,
|
|
18
|
-
type NodeBase,
|
|
19
|
-
type NodeDef,
|
|
20
|
-
type NodeRegistry,
|
|
21
|
-
type Size,
|
|
22
|
-
defaultNodeRegistry,
|
|
23
|
-
} from '@dxos/react-ui-canvas/scene';
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
AndShape,
|
|
27
|
-
AppendShape,
|
|
28
|
-
AudioShape,
|
|
29
|
-
BeaconShape,
|
|
30
|
-
ChatShape,
|
|
31
|
-
type ComputeShape,
|
|
32
|
-
ConstantShape,
|
|
33
|
-
DatabaseShape,
|
|
34
|
-
FeedShape,
|
|
35
|
-
FunctionShape,
|
|
36
|
-
GptRealtimeShape,
|
|
37
|
-
GptShape,
|
|
38
|
-
IfElseShape,
|
|
39
|
-
IfShape,
|
|
40
|
-
JsonShape,
|
|
41
|
-
JsonTransformShape,
|
|
42
|
-
NotShape,
|
|
43
|
-
OrShape,
|
|
44
|
-
RandomShape,
|
|
45
|
-
ReducerShape,
|
|
46
|
-
ScopeShape,
|
|
47
|
-
SurfaceShape,
|
|
48
|
-
SwitchShape,
|
|
49
|
-
TemplateShape,
|
|
50
|
-
TextShape,
|
|
51
|
-
TextToImageShape,
|
|
52
|
-
ThreadShape,
|
|
53
|
-
TriggerShapeSchema,
|
|
54
|
-
andShape,
|
|
55
|
-
appendShape,
|
|
56
|
-
audioShape,
|
|
57
|
-
beaconShape,
|
|
58
|
-
chatShape,
|
|
59
|
-
constantShape,
|
|
60
|
-
databaseShape,
|
|
61
|
-
feedShape,
|
|
62
|
-
functionShape,
|
|
63
|
-
getHeight,
|
|
64
|
-
gptRealtimeShape,
|
|
65
|
-
gptShape,
|
|
66
|
-
ifElseShape,
|
|
67
|
-
ifShape,
|
|
68
|
-
jsonShape,
|
|
69
|
-
jsonTransformShape,
|
|
70
|
-
notShape,
|
|
71
|
-
orShape,
|
|
72
|
-
randomShape,
|
|
73
|
-
reducerShape,
|
|
74
|
-
scopeShape,
|
|
75
|
-
surfaceShape,
|
|
76
|
-
switchShape,
|
|
77
|
-
templateShape,
|
|
78
|
-
textShape,
|
|
79
|
-
textToImageShape,
|
|
80
|
-
threadShape,
|
|
81
|
-
triggerShape,
|
|
82
|
-
} from '../shapes/index.ts';
|
|
83
|
-
import { computeNodeView } from './NodeView.tsx';
|
|
84
|
-
import { anchorsToPorts } from './ports.ts';
|
|
85
|
-
|
|
86
|
-
/** The shape's schema with the engine's z-order key, so it is a node schema. */
|
|
87
|
-
const withZ = <Fields extends Schema.Struct.Fields>(shape: Schema.Struct<Fields>) =>
|
|
88
|
-
shape.mapFields(Struct.assign({ z: Schema.String }));
|
|
89
|
-
|
|
90
|
-
type Entry = { group: string; def: NodeDef };
|
|
91
|
-
|
|
92
|
-
/** `schema` is the shape's with `z` (`withZ`), applied at the call site so each stays a concrete struct. */
|
|
93
|
-
const entry = <S extends ComputeShape>(
|
|
94
|
-
group: string,
|
|
95
|
-
shape: ShapeDef<S>,
|
|
96
|
-
schema: Schema.Codec<S & { z: string }, unknown, never, never>,
|
|
97
|
-
defaultSize: Size = shape.createShape({ id: 'default', center: { x: 0, y: 0 } }).size,
|
|
98
|
-
): Entry => ({
|
|
99
|
-
group,
|
|
100
|
-
def: {
|
|
101
|
-
type: shape.type,
|
|
102
|
-
name: shape.name,
|
|
103
|
-
icon: shape.icon,
|
|
104
|
-
group,
|
|
105
|
-
schema,
|
|
106
|
-
component: computeNodeView(schema, shape.component),
|
|
107
|
-
create: ({ id, z, center, size }: CreateProps): NodeBase => ({ ...shape.createShape({ id, center }), z, size }),
|
|
108
|
-
defaultSize,
|
|
109
|
-
ports: (node) => (isShapeOf(schema, node) ? anchorsToPorts(shape.getAnchors?.(node) ?? {}, node.size) : []),
|
|
110
|
-
resizable: shape.resizable,
|
|
111
|
-
openable: shape.openable,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const isShapeOf = <S extends ComputeShape>(
|
|
116
|
-
schema: Schema.Codec<S, unknown, never, never>,
|
|
117
|
-
node: NodeBase,
|
|
118
|
-
): node is NodeBase & S => Schema.is(schema)(node);
|
|
119
|
-
|
|
120
|
-
/** Palette order, as the editor's `computeShapes`. */
|
|
121
|
-
const entries: Entry[] = [
|
|
122
|
-
entry('Inputs', constantShape, withZ(ConstantShape)),
|
|
123
|
-
entry('Inputs', templateShape, withZ(TemplateShape)),
|
|
124
|
-
entry('Inputs', chatShape, withZ(ChatShape)),
|
|
125
|
-
entry('Inputs', switchShape, withZ(SwitchShape)),
|
|
126
|
-
entry('Inputs', audioShape, withZ(AudioShape)),
|
|
127
|
-
// A trigger's `createShape` makes an ECHO object, so its default size is stated rather than sampled.
|
|
128
|
-
entry('Inputs', triggerShape, withZ(TriggerShapeSchema), { width: 192, height: getHeight(TriggerEvent.EmailEvent) }),
|
|
129
|
-
entry('Inputs', randomShape, withZ(RandomShape)),
|
|
130
|
-
entry('Transform', gptShape, withZ(GptShape)),
|
|
131
|
-
entry('Transform', gptRealtimeShape, withZ(GptRealtimeShape)),
|
|
132
|
-
entry('Transform', functionShape, withZ(FunctionShape)),
|
|
133
|
-
entry('Transform', databaseShape, withZ(DatabaseShape)),
|
|
134
|
-
entry('Transform', textToImageShape, withZ(TextToImageShape)),
|
|
135
|
-
entry('Transform', appendShape, withZ(AppendShape)),
|
|
136
|
-
entry('Operations', ifShape, withZ(IfShape)),
|
|
137
|
-
entry('Operations', ifElseShape, withZ(IfElseShape)),
|
|
138
|
-
entry('Operations', andShape, withZ(AndShape)),
|
|
139
|
-
entry('Operations', orShape, withZ(OrShape)),
|
|
140
|
-
entry('Operations', notShape, withZ(NotShape)),
|
|
141
|
-
entry('Operations', reducerShape, withZ(ReducerShape)),
|
|
142
|
-
entry('Operations', jsonTransformShape, withZ(JsonTransformShape)),
|
|
143
|
-
entry('Outputs', jsonShape, withZ(JsonShape)),
|
|
144
|
-
entry('Outputs', feedShape, withZ(FeedShape)),
|
|
145
|
-
entry('Outputs', threadShape, withZ(ThreadShape)),
|
|
146
|
-
entry('Outputs', textShape, withZ(TextShape)),
|
|
147
|
-
entry('Outputs', surfaceShape, withZ(SurfaceShape)),
|
|
148
|
-
entry('Outputs', beaconShape, withZ(BeaconShape)),
|
|
149
|
-
entry('Outputs', scopeShape, withZ(ScopeShape)),
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
export const computeNodeDefs: NodeDef[] = entries.map(({ def }) => def);
|
|
153
|
-
|
|
154
|
-
/** The compute types plus the engine's note under a `Misc` group. */
|
|
155
|
-
export const computeNodeRegistry: NodeRegistry = {
|
|
156
|
-
...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),
|
|
157
|
-
note: { ...defaultNodeRegistry.note, group: 'Misc' },
|
|
158
|
-
};
|
package/src/scene/ports.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2026 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Anchors as the scene engine's ports (MIGRATION.md §2.2): an anchor is a point relative to the shape's
|
|
7
|
-
// centre, a port is a side and an offset along it; the anchor id says which way a link may run.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
import { type Anchor } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import { type Port, type Size } from '@dxos/react-ui-canvas/scene';
|
|
12
|
-
|
|
13
|
-
import { parseAnchorId } from '../shapes/defs.ts';
|
|
14
|
-
|
|
15
|
-
/** The ports of a shape from its anchors; a port's direction comes from the `input.` / `output.` prefix. */
|
|
16
|
-
export const anchorsToPorts = (anchors: Record<string, Anchor>, size: Size): Port[] =>
|
|
17
|
-
Object.values(anchors).map(({ id, pos }) => {
|
|
18
|
-
const [kind] = parseAnchorId(id);
|
|
19
|
-
const half = { x: size.width / 2, y: size.height / 2 };
|
|
20
|
-
// The anchor sits on whichever edge it is nearer to; ties go to the vertical edges (the input / output sides).
|
|
21
|
-
const vertical = Math.abs(Math.abs(pos.x) - half.x) <= Math.abs(Math.abs(pos.y) - half.y);
|
|
22
|
-
const side = vertical ? (pos.x < 0 ? 'w' : 'e') : pos.y < 0 ? 'n' : 's';
|
|
23
|
-
const along = vertical ? (pos.y + half.y) / size.height : (pos.x + half.x) / size.width;
|
|
24
|
-
return {
|
|
25
|
-
id,
|
|
26
|
-
side,
|
|
27
|
-
offset: Math.min(Math.max(along, 0), 1),
|
|
28
|
-
...(kind === 'input' ? { accepts: 'in' as const } : kind === 'output' ? { accepts: 'out' as const } : {}),
|
|
29
|
-
};
|
|
30
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
8
|
-
import * as SchemaAST from '@dxos/effect/SchemaAST';
|
|
9
|
-
import { type Polygon } from '@dxos/react-ui-canvas-editor';
|
|
10
|
-
import { createAnchors, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import { DEFAULT_GRID } from '@dxos/react-ui-canvas/scene';
|
|
12
|
-
|
|
13
|
-
import { footerHeight, headerHeight } from '../common/index.ts';
|
|
14
|
-
import { createAnchorId } from '../defs.ts';
|
|
15
|
-
|
|
16
|
-
// Kept out of `FunctionBody.tsx`: react-refresh only fast-refreshes a module whose
|
|
17
|
-
// exports are all components, so values exported beside them force a full page reload on every edit.
|
|
18
|
-
|
|
19
|
-
/** Vertical padding inside the function body; the height maths below depends on it. */
|
|
20
|
-
export const bodyPadding = 8;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A function shape's height: the chrome plus a body grown to a whole number of grid cells. One row per
|
|
24
|
-
* input is a floor on the body rather than its height, so the box lands on the grid whatever its schema
|
|
25
|
-
* declares — the rows used to set it exactly, and `rowHeight` divides into no grid cell.
|
|
26
|
-
*/
|
|
27
|
-
export const getHeight = (input: Schema.Schema<any>, unit = DEFAULT_GRID) => {
|
|
28
|
-
const properties = SchemaAST.getPropertySignatures(input.ast);
|
|
29
|
-
const minBody = bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.
|
|
30
|
-
return headerHeight + footerHeight + Math.ceil(minBody / unit) * unit;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const createFunctionAnchors = (
|
|
34
|
-
shape: Polygon,
|
|
35
|
-
input: Schema.Schema<any> = VoidInput,
|
|
36
|
-
output: Schema.Schema<any> = VoidOutput,
|
|
37
|
-
) => {
|
|
38
|
-
// TODO(burdon): Set type.
|
|
39
|
-
const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));
|
|
40
|
-
const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>
|
|
41
|
-
createAnchorId('output', name.toString()),
|
|
42
|
-
);
|
|
43
|
-
return createAnchors({ shape, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 + 1 } });
|
|
44
|
-
};
|