@neta-art/cohub 8.24.0 → 9.0.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/board/animation.d.ts +57 -181
- package/dist/board/animation.js +374 -220
- package/dist/board/core/arrow-geometry.d.ts +33 -18
- package/dist/board/core/arrow-geometry.js +283 -52
- package/dist/board/core/draw-geometry.d.ts +22 -36
- package/dist/board/core/draw-geometry.js +148 -85
- package/dist/board/core/export-assets.d.ts +3 -6
- package/dist/board/core/export-assets.js +0 -2
- package/dist/board/core/export-plan.d.ts +12 -63
- package/dist/board/core/export-plan.js +55 -94
- package/dist/board/core/palette.d.ts +4 -21
- package/dist/board/core/palette.js +8 -13
- package/dist/board/core/scene.d.ts +33 -0
- package/dist/board/core/scene.js +302 -0
- package/dist/board/core/shape-definition.d.ts +12 -24
- package/dist/board/core/shape-definition.js +0 -19
- package/dist/board/core/shape-types.d.ts +6 -120
- package/dist/board/core/shape-types.js +5 -5
- package/dist/board/core/text-metrics.d.ts +8 -11
- package/dist/board/core/text-metrics.js +5 -34
- package/dist/board/core/tool-styles.d.ts +6 -16
- package/dist/board/core/tool-styles.js +17 -25
- package/dist/board/export/index.d.ts +10 -17
- package/dist/board/export/index.js +22 -21
- package/dist/board/export/scene.d.ts +10 -16
- package/dist/board/export/scene.js +17 -30
- package/dist/board/geometry.d.ts +27 -56
- package/dist/board/geometry.js +7 -67
- package/dist/board/headless/index.d.ts +6 -27
- package/dist/board/headless/index.js +4 -19
- package/dist/board/headless/sketch.d.ts +19 -0
- package/dist/board/headless/sketch.js +146 -0
- package/dist/board/image-key.d.ts +2 -12
- package/dist/board/image-key.js +3 -13
- package/dist/board/index.d.ts +18 -20
- package/dist/board/index.js +17 -17
- package/dist/board/media-playback.d.ts +3 -6
- package/dist/board/media-playback.js +6 -6
- package/dist/board/presets.d.ts +150 -0
- package/dist/board/presets.js +226 -0
- package/dist/board/render/board-background.d.ts +5 -3
- package/dist/board/render/board-background.js +8 -7
- package/dist/board/render/clip.d.ts +14 -0
- package/dist/board/render/clip.js +47 -0
- package/dist/board/render/index.d.ts +8 -5
- package/dist/board/render/index.js +7 -4
- package/dist/board/render/media-interaction.d.ts +4 -5
- package/dist/board/render/media-interaction.js +1 -2
- package/dist/board/render/palette.d.ts +6 -2
- package/dist/board/render/palette.js +7 -1
- package/dist/board/render/renderers/arrow-card-renderer.js +69 -71
- package/dist/board/render/renderers/audio-card-renderer.js +3 -3
- package/dist/board/render/renderers/base-card-renderer.d.ts +6 -17
- package/dist/board/render/renderers/base-card-renderer.js +1 -24
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -50
- package/dist/board/render/renderers/board-renderer-registry.js +6 -7
- package/dist/board/render/renderers/draw-card-renderer.js +89 -56
- package/dist/board/render/renderers/effect-card-renderer.d.ts +6 -0
- package/dist/board/render/renderers/effect-card-renderer.js +197 -0
- package/dist/board/render/renderers/far-plate.d.ts +4 -21
- package/dist/board/render/renderers/far-plate.js +15 -34
- package/dist/board/render/renderers/file-card-renderer.d.ts +4 -25
- package/dist/board/render/renderers/file-card-renderer.js +8 -58
- package/dist/board/render/renderers/frame-card-renderer.js +28 -28
- package/dist/board/render/renderers/image-card-renderer.d.ts +4 -3
- package/dist/board/render/renderers/image-card-renderer.js +0 -9
- package/dist/board/render/renderers/shape-card-renderer.d.ts +9 -0
- package/dist/board/render/renderers/shape-card-renderer.js +240 -0
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/sketch-card-renderer.js +98 -0
- package/dist/board/render/renderers/task-card-renderer.d.ts +0 -1
- package/dist/board/render/renderers/task-card-renderer.js +14 -16
- package/dist/board/render/renderers/text-card-renderer.d.ts +1 -3
- package/dist/board/render/renderers/text-card-renderer.js +56 -46
- package/dist/board/render/renderers/unknown-card-renderer.js +4 -10
- package/dist/board/render/renderers/video-card-renderer.d.ts +4 -2
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sketch-host.d.ts +14 -0
- package/dist/board/render/sketch-host.js +216 -0
- package/dist/board/render/stroke.d.ts +12 -0
- package/dist/board/render/stroke.js +90 -0
- package/dist/board/render/text-measurement.d.ts +6 -26
- package/dist/board/render/text-measurement.js +11 -30
- package/dist/board/replay.d.ts +6 -31
- package/dist/board/replay.js +45 -203
- package/dist/board/runtime/board-player.d.ts +24 -0
- package/dist/board/runtime/board-player.js +161 -0
- package/dist/board/task.d.ts +2 -10
- package/dist/board/task.js +1 -10
- package/dist/chunks/environment.d.ts +2291 -3864
- package/dist/chunks/host-bridge.d.ts +253 -0
- package/dist/chunks/http.d.ts +233 -58
- package/dist/chunks/http.js +1046 -1028
- package/dist/chunks/transport.js +113 -59
- package/dist/chunks/websocket.d.ts +1 -1
- package/dist/chunks/websocket.js +1 -1
- package/dist/host-bridge.d.ts +54 -0
- package/dist/host-bridge.js +322 -0
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +74 -191
- package/dist/index.js +2032 -1186
- package/dist/protocol/dist/board-constants.d.ts +1 -29
- package/dist/protocol/dist/board-constants.js +2 -115
- package/dist/protocol/dist/board-layout.d.ts +59 -0
- package/dist/protocol/dist/board-layout.js +482 -0
- package/dist/protocol/dist/board-model.d.ts +2052 -0
- package/dist/protocol/dist/board-model.js +592 -0
- package/dist/protocol/dist/board-patch.d.ts +86 -0
- package/dist/protocol/dist/board-patch.js +734 -0
- package/dist/protocol/dist/board-schema.d.ts +33 -0
- package/dist/protocol/dist/board-schema.js +59 -0
- package/dist/protocol/dist/board-upgrade.d.ts +1 -0
- package/dist/protocol/dist/board-url.d.ts +1 -3
- package/dist/protocol/dist/board-url.js +2 -2
- package/dist/protocol/dist/board.d.ts +37 -232
- package/dist/protocol/dist/board.js +62 -160
- package/dist/protocol/dist/display/actions.d.ts +1 -0
- package/dist/protocol/dist/display/index.d.ts +2 -0
- package/dist/protocol/dist/index.d.ts +11 -12
- package/dist/protocol/dist/model/metrics.d.ts +2 -0
- package/dist/protocol/dist/model/session.d.ts +2 -1
- package/dist/protocol/dist/realtime/types.d.ts +2 -2
- package/dist/protocol/dist/runtime/index.d.ts +1 -0
- package/dist/space-picker.d.ts +1 -0
- package/dist/space-picker.js +1 -0
- package/dist/types.d.ts +2 -5
- package/package.json +9 -1
- package/dist/board/core/connections.d.ts +0 -108
- package/dist/board/core/connections.js +0 -455
- package/dist/board/mutation.d.ts +0 -6
- package/dist/board/mutation.js +0 -14
- package/dist/board/render/connection-layer.d.ts +0 -53
- package/dist/board/render/connection-layer.js +0 -375
- package/dist/board/render/renderers/geo-card-renderer.d.ts +0 -5
- package/dist/board/render/renderers/geo-card-renderer.js +0 -127
- package/dist/board/semantic-document.d.ts +0 -37
- package/dist/board/semantic-document.js +0 -288
- package/dist/board/semantic-mutation.d.ts +0 -10
- package/dist/board/semantic-mutation.js +0 -209
- package/dist/protocol/dist/board-animation.js +0 -34
- package/dist/protocol/dist/board-authoring.d.ts +0 -1326
- package/dist/protocol/dist/board-authoring.js +0 -302
- package/dist/protocol/dist/board-capability-registry.d.ts +0 -2
- package/dist/protocol/dist/board-capability-registry.js +0 -123
- package/dist/protocol/dist/board-codec.d.ts +0 -3
- package/dist/protocol/dist/board-codec.js +0 -383
- package/dist/protocol/dist/board-composition.d.ts +0 -383
- package/dist/protocol/dist/board-composition.js +0 -310
- package/dist/protocol/dist/board-connection.d.ts +0 -317
- package/dist/protocol/dist/board-connection.js +0 -219
- package/dist/protocol/dist/board-document.d.ts +0 -1566
- package/dist/protocol/dist/board-document.js +0 -456
- package/dist/protocol/dist/board-effect.d.ts +0 -96
- package/dist/protocol/dist/board-effect.js +0 -54
- package/dist/protocol/dist/board-geometry.d.ts +0 -15
- package/dist/protocol/dist/board-geometry.js +0 -137
- package/dist/protocol/dist/board-node.d.ts +0 -8
- package/dist/protocol/dist/board-node.js +0 -252
- /package/dist/protocol/dist/{board-animation.d.ts → host-bridge.d.ts} +0 -0
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region ../protocol/dist/board-connection.d.ts
|
|
3
|
-
/** Sides of a node frame a connection can attach to. */
|
|
4
|
-
declare const BOARD_CONNECTION_SIDES: readonly ["top", "right", "bottom", "left"];
|
|
5
|
-
type BoardConnectionSide = (typeof BOARD_CONNECTION_SIDES)[number];
|
|
6
|
-
/**
|
|
7
|
-
* Where a connection meets its node.
|
|
8
|
-
*
|
|
9
|
-
* - `auto` — the side is chosen from the live geometry of both endpoints, so the
|
|
10
|
-
* connection stays sensible through any move or resize. This is the default and
|
|
11
|
-
* what almost every connection should use.
|
|
12
|
-
* - `side` — the user pinned a side; `offset` (0..1) positions it along that edge.
|
|
13
|
-
* - `fixed` — the user pinned an exact normalized point on the frame.
|
|
14
|
-
*
|
|
15
|
-
* `auto` is a *declaration of intent*, not a computed value: the resolved side is
|
|
16
|
-
* never written back, so the connection keeps adapting instead of freezing the
|
|
17
|
-
* first layout it happened to have.
|
|
18
|
-
*/
|
|
19
|
-
declare const BoardConnectionAnchorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
|
-
kind: z.ZodLiteral<"auto">;
|
|
21
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
22
|
-
kind: z.ZodLiteral<"side">;
|
|
23
|
-
side: z.ZodEnum<{
|
|
24
|
-
bottom: "bottom";
|
|
25
|
-
left: "left";
|
|
26
|
-
right: "right";
|
|
27
|
-
top: "top";
|
|
28
|
-
}>;
|
|
29
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
-
kind: z.ZodLiteral<"fixed">;
|
|
32
|
-
nx: z.ZodNumber;
|
|
33
|
-
ny: z.ZodNumber;
|
|
34
|
-
}, z.core.$strip>]>;
|
|
35
|
-
type BoardConnectionAnchor = z.infer<typeof BoardConnectionAnchorSchema>;
|
|
36
|
-
declare const AUTO_BOARD_CONNECTION_ANCHOR: BoardConnectionAnchor;
|
|
37
|
-
declare const BoardConnectionEndpointSchema: z.ZodObject<{
|
|
38
|
-
itemId: z.ZodString;
|
|
39
|
-
portId: z.ZodOptional<z.ZodString>;
|
|
40
|
-
anchor: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
41
|
-
kind: z.ZodLiteral<"auto">;
|
|
42
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
-
kind: z.ZodLiteral<"side">;
|
|
44
|
-
side: z.ZodEnum<{
|
|
45
|
-
bottom: "bottom";
|
|
46
|
-
left: "left";
|
|
47
|
-
right: "right";
|
|
48
|
-
top: "top";
|
|
49
|
-
}>;
|
|
50
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
51
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
52
|
-
kind: z.ZodLiteral<"fixed">;
|
|
53
|
-
nx: z.ZodNumber;
|
|
54
|
-
ny: z.ZodNumber;
|
|
55
|
-
}, z.core.$strip>]>>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
type BoardConnectionEndpoint = z.infer<typeof BoardConnectionEndpointSchema>;
|
|
58
|
-
/**
|
|
59
|
-
* Which ends carry an arrowhead.
|
|
60
|
-
*
|
|
61
|
-
* This is the *semantic* direction, not a style flag: `forward` means the
|
|
62
|
-
* relation reads source → target, `backward` means target → source, and `none`
|
|
63
|
-
* means the relation is symmetric. Renderers derive arrowheads from it, so the
|
|
64
|
-
* drawing can never disagree with the meaning.
|
|
65
|
-
*/
|
|
66
|
-
declare const BOARD_CONNECTION_DIRECTIONS: readonly ["none", "forward", "backward", "both"];
|
|
67
|
-
type BoardConnectionDirection = (typeof BOARD_CONNECTION_DIRECTIONS)[number];
|
|
68
|
-
/** How the line travels between its two resolved endpoints. */
|
|
69
|
-
declare const BOARD_CONNECTION_ROUTINGS: readonly ["straight", "curve", "orthogonal"];
|
|
70
|
-
type BoardConnectionRouting = (typeof BOARD_CONNECTION_ROUTINGS)[number];
|
|
71
|
-
declare const BOARD_CONNECTION_LINES: readonly ["solid", "dashed"];
|
|
72
|
-
type BoardConnectionLine = (typeof BOARD_CONNECTION_LINES)[number];
|
|
73
|
-
/**
|
|
74
|
-
* The default relation kind.
|
|
75
|
-
*
|
|
76
|
-
* "related" is deliberately unopinionated: drawing a line between two nodes
|
|
77
|
-
* states that they are connected, not *how*. A stronger claim (depends-on,
|
|
78
|
-
* blocks, ...) is something the user or an agent asserts explicitly.
|
|
79
|
-
*/
|
|
80
|
-
declare const DEFAULT_BOARD_RELATION: "related";
|
|
81
|
-
/**
|
|
82
|
-
* Relation kind — a free-form slug, not an enum.
|
|
83
|
-
*
|
|
84
|
-
* Boards are used for domains we do not control, so a closed vocabulary would
|
|
85
|
-
* force unrelated meanings into the wrong bucket. The format is constrained
|
|
86
|
-
* (lowercase, dash/dot separated) so relations stay comparable and queryable
|
|
87
|
-
* across clients instead of accumulating near-duplicate spellings.
|
|
88
|
-
*/
|
|
89
|
-
declare const BoardRelationSchema: z.ZodDefault<z.ZodString>;
|
|
90
|
-
/**
|
|
91
|
-
* Waypoints a user dragged the line through, in world space.
|
|
92
|
-
*
|
|
93
|
-
* Stored because they are *input*, not output: the resolved path is recomputed
|
|
94
|
-
* from them on every read, but the intent behind a hand-routed line cannot be
|
|
95
|
-
* recovered once discarded.
|
|
96
|
-
*/
|
|
97
|
-
declare const BoardConnectionWaypointSchema: z.ZodObject<{
|
|
98
|
-
x: z.ZodNumber;
|
|
99
|
-
y: z.ZodNumber;
|
|
100
|
-
}, z.core.$strip>;
|
|
101
|
-
declare const BoardConnectionRoutingSchema: z.ZodObject<{
|
|
102
|
-
kind: z.ZodDefault<z.ZodEnum<{
|
|
103
|
-
curve: "curve";
|
|
104
|
-
orthogonal: "orthogonal";
|
|
105
|
-
straight: "straight";
|
|
106
|
-
}>>;
|
|
107
|
-
bend: z.ZodDefault<z.ZodNumber>;
|
|
108
|
-
waypoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
109
|
-
x: z.ZodNumber;
|
|
110
|
-
y: z.ZodNumber;
|
|
111
|
-
}, z.core.$strip>>>;
|
|
112
|
-
}, z.core.$strip>;
|
|
113
|
-
type BoardConnectionRoutingConfig = z.infer<typeof BoardConnectionRoutingSchema>;
|
|
114
|
-
declare const BoardConnectionStyleSchema: z.ZodObject<{
|
|
115
|
-
color: z.ZodDefault<z.ZodString>;
|
|
116
|
-
size: z.ZodDefault<z.ZodNumber>;
|
|
117
|
-
line: z.ZodDefault<z.ZodEnum<{
|
|
118
|
-
dashed: "dashed";
|
|
119
|
-
solid: "solid";
|
|
120
|
-
}>>;
|
|
121
|
-
}, z.core.$strip>;
|
|
122
|
-
type BoardConnectionStyle = z.infer<typeof BoardConnectionStyleSchema>;
|
|
123
|
-
declare const DEFAULT_BOARD_CONNECTION_ROUTING: BoardConnectionRoutingConfig;
|
|
124
|
-
declare const DEFAULT_BOARD_CONNECTION_STYLE: BoardConnectionStyle;
|
|
125
|
-
declare const BoardConnectionSchema: z.ZodObject<{
|
|
126
|
-
id: z.ZodString;
|
|
127
|
-
source: z.ZodObject<{
|
|
128
|
-
itemId: z.ZodString;
|
|
129
|
-
portId: z.ZodOptional<z.ZodString>;
|
|
130
|
-
anchor: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
131
|
-
kind: z.ZodLiteral<"auto">;
|
|
132
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
-
kind: z.ZodLiteral<"side">;
|
|
134
|
-
side: z.ZodEnum<{
|
|
135
|
-
bottom: "bottom";
|
|
136
|
-
left: "left";
|
|
137
|
-
right: "right";
|
|
138
|
-
top: "top";
|
|
139
|
-
}>;
|
|
140
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
141
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
-
kind: z.ZodLiteral<"fixed">;
|
|
143
|
-
nx: z.ZodNumber;
|
|
144
|
-
ny: z.ZodNumber;
|
|
145
|
-
}, z.core.$strip>]>>;
|
|
146
|
-
}, z.core.$strip>;
|
|
147
|
-
target: z.ZodObject<{
|
|
148
|
-
itemId: z.ZodString;
|
|
149
|
-
portId: z.ZodOptional<z.ZodString>;
|
|
150
|
-
anchor: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
151
|
-
kind: z.ZodLiteral<"auto">;
|
|
152
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
-
kind: z.ZodLiteral<"side">;
|
|
154
|
-
side: z.ZodEnum<{
|
|
155
|
-
bottom: "bottom";
|
|
156
|
-
left: "left";
|
|
157
|
-
right: "right";
|
|
158
|
-
top: "top";
|
|
159
|
-
}>;
|
|
160
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
161
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
162
|
-
kind: z.ZodLiteral<"fixed">;
|
|
163
|
-
nx: z.ZodNumber;
|
|
164
|
-
ny: z.ZodNumber;
|
|
165
|
-
}, z.core.$strip>]>>;
|
|
166
|
-
}, z.core.$strip>;
|
|
167
|
-
relation: z.ZodDefault<z.ZodString>;
|
|
168
|
-
direction: z.ZodDefault<z.ZodEnum<{
|
|
169
|
-
backward: "backward";
|
|
170
|
-
both: "both";
|
|
171
|
-
forward: "forward";
|
|
172
|
-
none: "none";
|
|
173
|
-
}>>;
|
|
174
|
-
label: z.ZodDefault<z.ZodString>;
|
|
175
|
-
routing: z.ZodDefault<z.ZodObject<{
|
|
176
|
-
kind: z.ZodDefault<z.ZodEnum<{
|
|
177
|
-
curve: "curve";
|
|
178
|
-
orthogonal: "orthogonal";
|
|
179
|
-
straight: "straight";
|
|
180
|
-
}>>;
|
|
181
|
-
bend: z.ZodDefault<z.ZodNumber>;
|
|
182
|
-
waypoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
183
|
-
x: z.ZodNumber;
|
|
184
|
-
y: z.ZodNumber;
|
|
185
|
-
}, z.core.$strip>>>;
|
|
186
|
-
}, z.core.$strip>>;
|
|
187
|
-
style: z.ZodDefault<z.ZodObject<{
|
|
188
|
-
color: z.ZodDefault<z.ZodString>;
|
|
189
|
-
size: z.ZodDefault<z.ZodNumber>;
|
|
190
|
-
line: z.ZodDefault<z.ZodEnum<{
|
|
191
|
-
dashed: "dashed";
|
|
192
|
-
solid: "solid";
|
|
193
|
-
}>>;
|
|
194
|
-
}, z.core.$strip>>;
|
|
195
|
-
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
196
|
-
}, z.core.$strict>;
|
|
197
|
-
type BoardConnection = z.infer<typeof BoardConnectionSchema>;
|
|
198
|
-
/** Server-owned fields, mirroring how nodes carry a board id and revision. */
|
|
199
|
-
type BoardConnectionRecord = BoardConnection & {
|
|
200
|
-
boardId: string;
|
|
201
|
-
revision: number;
|
|
202
|
-
createdAt: string | null;
|
|
203
|
-
updatedAt: string | null;
|
|
204
|
-
};
|
|
205
|
-
/** The client-authored form of a connection (no server-owned fields). */
|
|
206
|
-
type BoardConnectionInput = BoardConnection;
|
|
207
|
-
/**
|
|
208
|
-
* A patch to an existing connection.
|
|
209
|
-
*
|
|
210
|
-
* `id` is excluded: a connection's identity never changes, and re-pointing both
|
|
211
|
-
* endpoints is an edit of the same relation, not a new one.
|
|
212
|
-
*/
|
|
213
|
-
declare const BoardConnectionPatchSchema: z.ZodObject<{
|
|
214
|
-
source: z.ZodOptional<z.ZodObject<{
|
|
215
|
-
itemId: z.ZodString;
|
|
216
|
-
portId: z.ZodOptional<z.ZodString>;
|
|
217
|
-
anchor: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
218
|
-
kind: z.ZodLiteral<"auto">;
|
|
219
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
220
|
-
kind: z.ZodLiteral<"side">;
|
|
221
|
-
side: z.ZodEnum<{
|
|
222
|
-
bottom: "bottom";
|
|
223
|
-
left: "left";
|
|
224
|
-
right: "right";
|
|
225
|
-
top: "top";
|
|
226
|
-
}>;
|
|
227
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
228
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
-
kind: z.ZodLiteral<"fixed">;
|
|
230
|
-
nx: z.ZodNumber;
|
|
231
|
-
ny: z.ZodNumber;
|
|
232
|
-
}, z.core.$strip>]>>;
|
|
233
|
-
}, z.core.$strip>>;
|
|
234
|
-
target: z.ZodOptional<z.ZodObject<{
|
|
235
|
-
itemId: z.ZodString;
|
|
236
|
-
portId: z.ZodOptional<z.ZodString>;
|
|
237
|
-
anchor: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
238
|
-
kind: z.ZodLiteral<"auto">;
|
|
239
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
240
|
-
kind: z.ZodLiteral<"side">;
|
|
241
|
-
side: z.ZodEnum<{
|
|
242
|
-
bottom: "bottom";
|
|
243
|
-
left: "left";
|
|
244
|
-
right: "right";
|
|
245
|
-
top: "top";
|
|
246
|
-
}>;
|
|
247
|
-
offset: z.ZodDefault<z.ZodNumber>;
|
|
248
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
249
|
-
kind: z.ZodLiteral<"fixed">;
|
|
250
|
-
nx: z.ZodNumber;
|
|
251
|
-
ny: z.ZodNumber;
|
|
252
|
-
}, z.core.$strip>]>>;
|
|
253
|
-
}, z.core.$strip>>;
|
|
254
|
-
relation: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
255
|
-
direction: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
256
|
-
backward: "backward";
|
|
257
|
-
both: "both";
|
|
258
|
-
forward: "forward";
|
|
259
|
-
none: "none";
|
|
260
|
-
}>>>;
|
|
261
|
-
label: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
262
|
-
routing: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
263
|
-
kind: z.ZodDefault<z.ZodEnum<{
|
|
264
|
-
curve: "curve";
|
|
265
|
-
orthogonal: "orthogonal";
|
|
266
|
-
straight: "straight";
|
|
267
|
-
}>>;
|
|
268
|
-
bend: z.ZodDefault<z.ZodNumber>;
|
|
269
|
-
waypoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
270
|
-
x: z.ZodNumber;
|
|
271
|
-
y: z.ZodNumber;
|
|
272
|
-
}, z.core.$strip>>>;
|
|
273
|
-
}, z.core.$strip>>>;
|
|
274
|
-
style: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
275
|
-
color: z.ZodDefault<z.ZodString>;
|
|
276
|
-
size: z.ZodDefault<z.ZodNumber>;
|
|
277
|
-
line: z.ZodDefault<z.ZodEnum<{
|
|
278
|
-
dashed: "dashed";
|
|
279
|
-
solid: "solid";
|
|
280
|
-
}>>;
|
|
281
|
-
}, z.core.$strip>>>;
|
|
282
|
-
metadata: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
283
|
-
}, z.core.$strict>;
|
|
284
|
-
type BoardConnectionPatch = z.infer<typeof BoardConnectionPatchSchema>;
|
|
285
|
-
/** Both item ids a connection touches, deduped for a self-loop. */
|
|
286
|
-
declare function connectionItemIds(connection: BoardConnection): string[];
|
|
287
|
-
/** Whether a connection touches the given node. */
|
|
288
|
-
declare function connectionTouchesItem(connection: BoardConnection, itemId: string): boolean;
|
|
289
|
-
/** The item at the far end of a connection from `itemId`, or null. */
|
|
290
|
-
declare function connectionOtherItemId(connection: BoardConnection, itemId: string): string | null;
|
|
291
|
-
declare function normalizeBoardConnectionStyle(style: Partial<BoardConnectionStyle> | undefined): BoardConnectionStyle;
|
|
292
|
-
/**
|
|
293
|
-
* Build a connection with every default filled in.
|
|
294
|
-
*
|
|
295
|
-
* Callers only state what they mean (which items, and optionally the relation),
|
|
296
|
-
* so a connection created by the editor, an agent or the CLI is byte-identical
|
|
297
|
-
* for the same intent.
|
|
298
|
-
*/
|
|
299
|
-
declare function createBoardConnection(input: {
|
|
300
|
-
id: string;
|
|
301
|
-
sourceItemId: string;
|
|
302
|
-
targetItemId: string;
|
|
303
|
-
relation?: string;
|
|
304
|
-
direction?: BoardConnectionDirection;
|
|
305
|
-
label?: string;
|
|
306
|
-
sourcePortId?: string;
|
|
307
|
-
targetPortId?: string;
|
|
308
|
-
sourceAnchor?: BoardConnectionAnchor;
|
|
309
|
-
targetAnchor?: BoardConnectionAnchor;
|
|
310
|
-
routing?: Partial<BoardConnectionRoutingConfig>;
|
|
311
|
-
style?: Partial<BoardConnectionStyle>;
|
|
312
|
-
metadata?: Record<string, unknown>;
|
|
313
|
-
}): BoardConnection;
|
|
314
|
-
/** Reverse a connection's endpoints, preserving the relation's reading order. */
|
|
315
|
-
declare function flipBoardConnection(connection: BoardConnection): BoardConnection;
|
|
316
|
-
//#endregion
|
|
317
|
-
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BoardConnection, BoardConnectionAnchor, BoardConnectionAnchorSchema, BoardConnectionDirection, BoardConnectionEndpoint, BoardConnectionEndpointSchema, BoardConnectionInput, BoardConnectionLine, BoardConnectionPatch, BoardConnectionPatchSchema, BoardConnectionRecord, BoardConnectionRouting, BoardConnectionRoutingConfig, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionSide, BoardConnectionStyle, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardRelationSchema, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, connectionItemIds, connectionOtherItemId, connectionTouchesItem, createBoardConnection, flipBoardConnection, normalizeBoardConnectionStyle };
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { BOARD_CONNECTION_STROKE_SIZE, clampBoardStrokeSize } from "./board-constants.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
//#region ../protocol/dist/board-connection.js
|
|
4
|
-
/**
|
|
5
|
-
* Board connections — the first-class relation between two Board nodes.
|
|
6
|
-
*
|
|
7
|
-
* A connection is *not* a shape. It has no frame of its own: its geometry is
|
|
8
|
-
* derived entirely from the two nodes it joins, which is exactly why it belongs
|
|
9
|
-
* in its own entity rather than in the item list. Storing it as a node would
|
|
10
|
-
* force a bounding box to be persisted and kept in sync with both endpoints —
|
|
11
|
-
* a second source of truth that is stale the moment either node moves.
|
|
12
|
-
*
|
|
13
|
-
* The stored form is therefore purely semantic: which items, in which direction,
|
|
14
|
-
* anchored where, routed how. Every world coordinate is resolved at read time
|
|
15
|
-
* from the live node frames (see the SDK's connection geometry), so a connection
|
|
16
|
-
* can never drift from the nodes it describes.
|
|
17
|
-
*
|
|
18
|
-
* Agents read this model directly: `source`, `target`, `relation` and `label`
|
|
19
|
-
* carry the meaning, while `routing` and `style` carry only presentation. A
|
|
20
|
-
* reader that wants the graph never has to interpret pixels.
|
|
21
|
-
*/
|
|
22
|
-
/** Sides of a node frame a connection can attach to. */
|
|
23
|
-
const BOARD_CONNECTION_SIDES = [
|
|
24
|
-
"top",
|
|
25
|
-
"right",
|
|
26
|
-
"bottom",
|
|
27
|
-
"left"
|
|
28
|
-
];
|
|
29
|
-
/**
|
|
30
|
-
* Where a connection meets its node.
|
|
31
|
-
*
|
|
32
|
-
* - `auto` — the side is chosen from the live geometry of both endpoints, so the
|
|
33
|
-
* connection stays sensible through any move or resize. This is the default and
|
|
34
|
-
* what almost every connection should use.
|
|
35
|
-
* - `side` — the user pinned a side; `offset` (0..1) positions it along that edge.
|
|
36
|
-
* - `fixed` — the user pinned an exact normalized point on the frame.
|
|
37
|
-
*
|
|
38
|
-
* `auto` is a *declaration of intent*, not a computed value: the resolved side is
|
|
39
|
-
* never written back, so the connection keeps adapting instead of freezing the
|
|
40
|
-
* first layout it happened to have.
|
|
41
|
-
*/
|
|
42
|
-
const BoardConnectionAnchorSchema = z.union([
|
|
43
|
-
z.object({ kind: z.literal("auto") }),
|
|
44
|
-
z.object({
|
|
45
|
-
kind: z.literal("side"),
|
|
46
|
-
side: z.enum(BOARD_CONNECTION_SIDES),
|
|
47
|
-
offset: z.number().finite().min(0).max(1).default(.5)
|
|
48
|
-
}),
|
|
49
|
-
z.object({
|
|
50
|
-
kind: z.literal("fixed"),
|
|
51
|
-
nx: z.number().finite().min(0).max(1),
|
|
52
|
-
ny: z.number().finite().min(0).max(1)
|
|
53
|
-
})
|
|
54
|
-
]);
|
|
55
|
-
const AUTO_BOARD_CONNECTION_ANCHOR = { kind: "auto" };
|
|
56
|
-
const BoardConnectionEndpointSchema = z.object({
|
|
57
|
-
itemId: z.string().min(1).max(160),
|
|
58
|
-
/** Optional semantic port. Older connections omit it and remain valid. */
|
|
59
|
-
portId: z.string().min(1).max(120).optional(),
|
|
60
|
-
anchor: BoardConnectionAnchorSchema.default(AUTO_BOARD_CONNECTION_ANCHOR)
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* Which ends carry an arrowhead.
|
|
64
|
-
*
|
|
65
|
-
* This is the *semantic* direction, not a style flag: `forward` means the
|
|
66
|
-
* relation reads source → target, `backward` means target → source, and `none`
|
|
67
|
-
* means the relation is symmetric. Renderers derive arrowheads from it, so the
|
|
68
|
-
* drawing can never disagree with the meaning.
|
|
69
|
-
*/
|
|
70
|
-
const BOARD_CONNECTION_DIRECTIONS = [
|
|
71
|
-
"none",
|
|
72
|
-
"forward",
|
|
73
|
-
"backward",
|
|
74
|
-
"both"
|
|
75
|
-
];
|
|
76
|
-
/** How the line travels between its two resolved endpoints. */
|
|
77
|
-
const BOARD_CONNECTION_ROUTINGS = [
|
|
78
|
-
"straight",
|
|
79
|
-
"curve",
|
|
80
|
-
"orthogonal"
|
|
81
|
-
];
|
|
82
|
-
const BOARD_CONNECTION_LINES = ["solid", "dashed"];
|
|
83
|
-
/**
|
|
84
|
-
* The default relation kind.
|
|
85
|
-
*
|
|
86
|
-
* "related" is deliberately unopinionated: drawing a line between two nodes
|
|
87
|
-
* states that they are connected, not *how*. A stronger claim (depends-on,
|
|
88
|
-
* blocks, ...) is something the user or an agent asserts explicitly.
|
|
89
|
-
*/
|
|
90
|
-
const DEFAULT_BOARD_RELATION = "related";
|
|
91
|
-
/**
|
|
92
|
-
* Relation kind — a free-form slug, not an enum.
|
|
93
|
-
*
|
|
94
|
-
* Boards are used for domains we do not control, so a closed vocabulary would
|
|
95
|
-
* force unrelated meanings into the wrong bucket. The format is constrained
|
|
96
|
-
* (lowercase, dash/dot separated) so relations stay comparable and queryable
|
|
97
|
-
* across clients instead of accumulating near-duplicate spellings.
|
|
98
|
-
*/
|
|
99
|
-
const BoardRelationSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/, "relation must be a lowercase slug").default(DEFAULT_BOARD_RELATION);
|
|
100
|
-
/**
|
|
101
|
-
* Waypoints a user dragged the line through, in world space.
|
|
102
|
-
*
|
|
103
|
-
* Stored because they are *input*, not output: the resolved path is recomputed
|
|
104
|
-
* from them on every read, but the intent behind a hand-routed line cannot be
|
|
105
|
-
* recovered once discarded.
|
|
106
|
-
*/
|
|
107
|
-
const BoardConnectionWaypointSchema = z.object({
|
|
108
|
-
x: z.number().finite(),
|
|
109
|
-
y: z.number().finite()
|
|
110
|
-
});
|
|
111
|
-
const BoardConnectionRoutingSchema = z.object({
|
|
112
|
-
kind: z.enum(BOARD_CONNECTION_ROUTINGS).default("curve"),
|
|
113
|
-
/** Curve bow as a fraction of endpoint distance (-0.85..0.85). */
|
|
114
|
-
bend: z.number().finite().min(-.85).max(.85).default(0),
|
|
115
|
-
waypoints: z.array(BoardConnectionWaypointSchema).max(64).default([])
|
|
116
|
-
});
|
|
117
|
-
const BoardConnectionStyleSchema = z.object({
|
|
118
|
-
/** Palette color id, resolved to a theme token at render time. */
|
|
119
|
-
color: z.string().min(1).max(40).default("brand"),
|
|
120
|
-
size: z.number().finite().positive().default(BOARD_CONNECTION_STROKE_SIZE),
|
|
121
|
-
line: z.enum(BOARD_CONNECTION_LINES).default("solid")
|
|
122
|
-
});
|
|
123
|
-
const DEFAULT_BOARD_CONNECTION_ROUTING = {
|
|
124
|
-
kind: "curve",
|
|
125
|
-
bend: 0,
|
|
126
|
-
waypoints: []
|
|
127
|
-
};
|
|
128
|
-
const DEFAULT_BOARD_CONNECTION_STYLE = {
|
|
129
|
-
color: "brand",
|
|
130
|
-
size: BOARD_CONNECTION_STROKE_SIZE,
|
|
131
|
-
line: "solid"
|
|
132
|
-
};
|
|
133
|
-
const BoardConnectionSchema = z.object({
|
|
134
|
-
id: z.string().min(1).max(160),
|
|
135
|
-
source: BoardConnectionEndpointSchema,
|
|
136
|
-
target: BoardConnectionEndpointSchema,
|
|
137
|
-
relation: BoardRelationSchema,
|
|
138
|
-
direction: z.enum(BOARD_CONNECTION_DIRECTIONS).default("forward"),
|
|
139
|
-
label: z.string().max(280).default(""),
|
|
140
|
-
routing: BoardConnectionRoutingSchema.default(DEFAULT_BOARD_CONNECTION_ROUTING),
|
|
141
|
-
style: BoardConnectionStyleSchema.default(DEFAULT_BOARD_CONNECTION_STYLE),
|
|
142
|
-
metadata: z.record(z.string(), z.unknown()).default({})
|
|
143
|
-
}).strict();
|
|
144
|
-
/**
|
|
145
|
-
* A patch to an existing connection.
|
|
146
|
-
*
|
|
147
|
-
* `id` is excluded: a connection's identity never changes, and re-pointing both
|
|
148
|
-
* endpoints is an edit of the same relation, not a new one.
|
|
149
|
-
*/
|
|
150
|
-
const BoardConnectionPatchSchema = BoardConnectionSchema.omit({ id: true }).partial();
|
|
151
|
-
/** Both item ids a connection touches, deduped for a self-loop. */
|
|
152
|
-
function connectionItemIds(connection) {
|
|
153
|
-
return connection.source.itemId === connection.target.itemId ? [connection.source.itemId] : [connection.source.itemId, connection.target.itemId];
|
|
154
|
-
}
|
|
155
|
-
/** Whether a connection touches the given node. */
|
|
156
|
-
function connectionTouchesItem(connection, itemId) {
|
|
157
|
-
return connection.source.itemId === itemId || connection.target.itemId === itemId;
|
|
158
|
-
}
|
|
159
|
-
/** The item at the far end of a connection from `itemId`, or null. */
|
|
160
|
-
function connectionOtherItemId(connection, itemId) {
|
|
161
|
-
if (connection.source.itemId === itemId) return connection.target.itemId;
|
|
162
|
-
if (connection.target.itemId === itemId) return connection.source.itemId;
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
function normalizeBoardConnectionStyle(style) {
|
|
166
|
-
return {
|
|
167
|
-
color: style?.color?.trim() || DEFAULT_BOARD_CONNECTION_STYLE.color,
|
|
168
|
-
size: clampBoardStrokeSize(typeof style?.size === "number" && Number.isFinite(style.size) ? style.size : DEFAULT_BOARD_CONNECTION_STYLE.size),
|
|
169
|
-
line: style?.line ?? DEFAULT_BOARD_CONNECTION_STYLE.line
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Build a connection with every default filled in.
|
|
174
|
-
*
|
|
175
|
-
* Callers only state what they mean (which items, and optionally the relation),
|
|
176
|
-
* so a connection created by the editor, an agent or the CLI is byte-identical
|
|
177
|
-
* for the same intent.
|
|
178
|
-
*/
|
|
179
|
-
function createBoardConnection(input) {
|
|
180
|
-
return {
|
|
181
|
-
id: input.id,
|
|
182
|
-
source: {
|
|
183
|
-
itemId: input.sourceItemId,
|
|
184
|
-
...input.sourcePortId ? { portId: input.sourcePortId } : {},
|
|
185
|
-
anchor: input.sourceAnchor ?? AUTO_BOARD_CONNECTION_ANCHOR
|
|
186
|
-
},
|
|
187
|
-
target: {
|
|
188
|
-
itemId: input.targetItemId,
|
|
189
|
-
...input.targetPortId ? { portId: input.targetPortId } : {},
|
|
190
|
-
anchor: input.targetAnchor ?? AUTO_BOARD_CONNECTION_ANCHOR
|
|
191
|
-
},
|
|
192
|
-
relation: input.relation ?? "related",
|
|
193
|
-
direction: input.direction ?? "forward",
|
|
194
|
-
label: input.label ?? "",
|
|
195
|
-
routing: {
|
|
196
|
-
...DEFAULT_BOARD_CONNECTION_ROUTING,
|
|
197
|
-
...input.routing
|
|
198
|
-
},
|
|
199
|
-
style: normalizeBoardConnectionStyle(input.style),
|
|
200
|
-
metadata: input.metadata ?? {}
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
/** Reverse a connection's endpoints, preserving the relation's reading order. */
|
|
204
|
-
function flipBoardConnection(connection) {
|
|
205
|
-
const direction = connection.direction === "forward" ? "backward" : connection.direction === "backward" ? "forward" : connection.direction;
|
|
206
|
-
return {
|
|
207
|
-
...connection,
|
|
208
|
-
source: connection.target,
|
|
209
|
-
target: connection.source,
|
|
210
|
-
direction,
|
|
211
|
-
routing: {
|
|
212
|
-
...connection.routing,
|
|
213
|
-
bend: -connection.routing.bend,
|
|
214
|
-
waypoints: [...connection.routing.waypoints].reverse()
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
//#endregion
|
|
219
|
-
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BoardConnectionAnchorSchema, BoardConnectionEndpointSchema, BoardConnectionPatchSchema, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardRelationSchema, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, connectionItemIds, connectionOtherItemId, connectionTouchesItem, createBoardConnection, flipBoardConnection, normalizeBoardConnectionStyle };
|