@zsherman/canvas 0.0.0-stage → 0.1.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.
Files changed (196) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +373 -0
  3. package/README.md +15 -2
  4. package/THIRD_PARTY_NOTICES.md +117 -0
  5. package/dist/dom/canvas/assets.js +89 -0
  6. package/dist/dom/canvas/board-store.js +56 -0
  7. package/dist/dom/canvas/canvas-actions.js +78 -0
  8. package/dist/dom/canvas/canvas-board.js +557 -0
  9. package/dist/dom/canvas/canvas-board.styles.js +110 -0
  10. package/dist/dom/canvas/canvas-chrome.js +1167 -0
  11. package/dist/dom/canvas/canvas-chrome.styles.js +220 -0
  12. package/dist/dom/canvas/canvas-comments.js +950 -0
  13. package/dist/dom/canvas/canvas-comments.styles.js +231 -0
  14. package/dist/dom/canvas/canvas-context.js +196 -0
  15. package/dist/dom/canvas/canvas-controller.js +697 -0
  16. package/dist/dom/canvas/canvas-cursor-chat.js +120 -0
  17. package/dist/dom/canvas/canvas-cursor-chat.styles.js +55 -0
  18. package/dist/dom/canvas/canvas-menus.js +276 -0
  19. package/dist/dom/canvas/canvas-menus.styles.js +7 -0
  20. package/dist/dom/canvas/canvas-style-bar.js +930 -0
  21. package/dist/dom/canvas/canvas-style-bar.styles.js +52 -0
  22. package/dist/dom/canvas/canvas-surface.js +1353 -0
  23. package/dist/dom/canvas/canvas-surface.styles.js +345 -0
  24. package/dist/dom/canvas/canvas-tool-rail.js +406 -0
  25. package/dist/dom/canvas/canvas-tool-rail.styles.js +20 -0
  26. package/dist/dom/canvas/comments.js +58 -0
  27. package/dist/dom/canvas/equality.js +13 -0
  28. package/dist/dom/canvas/export-png.js +496 -0
  29. package/dist/dom/canvas/gesture-machine.js +91 -0
  30. package/dist/dom/canvas/handlers.js +18 -0
  31. package/dist/dom/canvas/index.js +9 -0
  32. package/dist/dom/canvas/input.js +85 -0
  33. package/dist/dom/canvas/instant.js +28 -0
  34. package/dist/dom/canvas/kernel.js +39 -0
  35. package/dist/dom/canvas/motion.js +686 -0
  36. package/dist/dom/canvas/palette.js +165 -0
  37. package/dist/dom/canvas/random-id.js +15 -0
  38. package/dist/dom/canvas/scene-renderer.js +559 -0
  39. package/dist/dom/canvas/scene.styles.js +7 -0
  40. package/dist/dom/canvas/surface-model.js +324 -0
  41. package/dist/dom/canvas/uploads.js +294 -0
  42. package/dist/dom/index.js +9 -0
  43. package/dist/dom/kernel/actions.js +455 -0
  44. package/dist/dom/kernel/board.js +856 -0
  45. package/dist/dom/kernel/claims.js +40 -0
  46. package/dist/dom/kernel/clipboard.js +30 -0
  47. package/dist/dom/kernel/constants.js +210 -0
  48. package/dist/dom/kernel/contract.js +0 -0
  49. package/dist/dom/kernel/decode.js +85 -0
  50. package/dist/dom/kernel/editor.js +2077 -0
  51. package/dist/dom/kernel/errors.js +82 -0
  52. package/dist/dom/kernel/fonts/inter.js +7924 -0
  53. package/dist/dom/kernel/fractional-index.js +54 -0
  54. package/dist/dom/kernel/geometry.js +123 -0
  55. package/dist/dom/kernel/hit-test.js +156 -0
  56. package/dist/dom/kernel/index.js +22 -0
  57. package/dist/dom/kernel/inspect.js +116 -0
  58. package/dist/dom/kernel/kernel.js +251 -0
  59. package/dist/dom/kernel/outline.js +64 -0
  60. package/dist/dom/kernel/plan.js +1370 -0
  61. package/dist/dom/kernel/rev.js +173 -0
  62. package/dist/dom/kernel/scene.js +580 -0
  63. package/dist/dom/kernel/schema.js +1109 -0
  64. package/dist/dom/kernel/snap.js +258 -0
  65. package/dist/dom/kernel/svg.js +148 -0
  66. package/dist/dom/kernel/text.js +142 -0
  67. package/dist/solid/canvas/assets.jsx +89 -0
  68. package/dist/solid/canvas/board-store.jsx +56 -0
  69. package/dist/solid/canvas/canvas-actions.jsx +78 -0
  70. package/dist/solid/canvas/canvas-board.jsx +326 -0
  71. package/dist/solid/canvas/canvas-board.styles.jsx +110 -0
  72. package/dist/solid/canvas/canvas-chrome.jsx +612 -0
  73. package/dist/solid/canvas/canvas-chrome.styles.jsx +220 -0
  74. package/dist/solid/canvas/canvas-comments.jsx +435 -0
  75. package/dist/solid/canvas/canvas-comments.styles.jsx +231 -0
  76. package/dist/solid/canvas/canvas-context.jsx +174 -0
  77. package/dist/solid/canvas/canvas-controller.jsx +697 -0
  78. package/dist/solid/canvas/canvas-cursor-chat.jsx +87 -0
  79. package/dist/solid/canvas/canvas-cursor-chat.styles.jsx +55 -0
  80. package/dist/solid/canvas/canvas-menus.jsx +223 -0
  81. package/dist/solid/canvas/canvas-menus.styles.jsx +7 -0
  82. package/dist/solid/canvas/canvas-style-bar.jsx +486 -0
  83. package/dist/solid/canvas/canvas-style-bar.styles.jsx +52 -0
  84. package/dist/solid/canvas/canvas-surface.jsx +681 -0
  85. package/dist/solid/canvas/canvas-surface.styles.jsx +345 -0
  86. package/dist/solid/canvas/canvas-tool-rail.jsx +195 -0
  87. package/dist/solid/canvas/canvas-tool-rail.styles.jsx +20 -0
  88. package/dist/solid/canvas/comments.jsx +58 -0
  89. package/dist/solid/canvas/equality.jsx +13 -0
  90. package/dist/solid/canvas/export-png.jsx +496 -0
  91. package/dist/solid/canvas/gesture-machine.jsx +91 -0
  92. package/dist/solid/canvas/handlers.jsx +18 -0
  93. package/dist/solid/canvas/index.jsx +9 -0
  94. package/dist/solid/canvas/input.jsx +85 -0
  95. package/dist/solid/canvas/instant.jsx +28 -0
  96. package/dist/solid/canvas/kernel.jsx +39 -0
  97. package/dist/solid/canvas/motion.jsx +686 -0
  98. package/dist/solid/canvas/palette.jsx +165 -0
  99. package/dist/solid/canvas/random-id.jsx +15 -0
  100. package/dist/solid/canvas/scene-renderer.jsx +559 -0
  101. package/dist/solid/canvas/scene.styles.jsx +7 -0
  102. package/dist/solid/canvas/surface-model.jsx +324 -0
  103. package/dist/solid/canvas/uploads.jsx +294 -0
  104. package/dist/solid/index.jsx +9 -0
  105. package/dist/solid/kernel/actions.jsx +455 -0
  106. package/dist/solid/kernel/board.jsx +856 -0
  107. package/dist/solid/kernel/claims.jsx +40 -0
  108. package/dist/solid/kernel/clipboard.jsx +30 -0
  109. package/dist/solid/kernel/constants.jsx +210 -0
  110. package/dist/solid/kernel/contract.jsx +0 -0
  111. package/dist/solid/kernel/decode.jsx +85 -0
  112. package/dist/solid/kernel/editor.jsx +2077 -0
  113. package/dist/solid/kernel/errors.jsx +82 -0
  114. package/dist/solid/kernel/fonts/inter.jsx +7924 -0
  115. package/dist/solid/kernel/fractional-index.jsx +54 -0
  116. package/dist/solid/kernel/geometry.jsx +123 -0
  117. package/dist/solid/kernel/hit-test.jsx +156 -0
  118. package/dist/solid/kernel/index.jsx +22 -0
  119. package/dist/solid/kernel/inspect.jsx +116 -0
  120. package/dist/solid/kernel/kernel.jsx +251 -0
  121. package/dist/solid/kernel/outline.jsx +64 -0
  122. package/dist/solid/kernel/plan.jsx +1370 -0
  123. package/dist/solid/kernel/rev.jsx +173 -0
  124. package/dist/solid/kernel/scene.jsx +580 -0
  125. package/dist/solid/kernel/schema.jsx +1109 -0
  126. package/dist/solid/kernel/snap.jsx +258 -0
  127. package/dist/solid/kernel/svg.jsx +148 -0
  128. package/dist/solid/kernel/text.jsx +142 -0
  129. package/dist/styles.css +1 -0
  130. package/dist/types/canvas/assets.d.ts +111 -0
  131. package/dist/types/canvas/board-store.d.ts +86 -0
  132. package/dist/types/canvas/canvas-actions.d.ts +21 -0
  133. package/dist/types/canvas/canvas-board.d.ts +53 -0
  134. package/dist/types/canvas/canvas-board.styles.d.ts +94 -0
  135. package/dist/types/canvas/canvas-chrome.d.ts +109 -0
  136. package/dist/types/canvas/canvas-chrome.styles.d.ts +193 -0
  137. package/dist/types/canvas/canvas-comments.d.ts +20 -0
  138. package/dist/types/canvas/canvas-comments.styles.d.ts +208 -0
  139. package/dist/types/canvas/canvas-context.d.ts +104 -0
  140. package/dist/types/canvas/canvas-controller.d.ts +159 -0
  141. package/dist/types/canvas/canvas-cursor-chat.d.ts +13 -0
  142. package/dist/types/canvas/canvas-cursor-chat.styles.d.ts +54 -0
  143. package/dist/types/canvas/canvas-menus.d.ts +21 -0
  144. package/dist/types/canvas/canvas-menus.styles.d.ts +6 -0
  145. package/dist/types/canvas/canvas-style-bar.d.ts +19 -0
  146. package/dist/types/canvas/canvas-style-bar.styles.d.ts +43 -0
  147. package/dist/types/canvas/canvas-surface.d.ts +15 -0
  148. package/dist/types/canvas/canvas-surface.styles.d.ts +313 -0
  149. package/dist/types/canvas/canvas-tool-rail.d.ts +41 -0
  150. package/dist/types/canvas/canvas-tool-rail.styles.d.ts +15 -0
  151. package/dist/types/canvas/comments.d.ts +106 -0
  152. package/dist/types/canvas/equality.d.ts +4 -0
  153. package/dist/types/canvas/export-png.d.ts +77 -0
  154. package/dist/types/canvas/gesture-machine.d.ts +46 -0
  155. package/dist/types/canvas/handlers.d.ts +7 -0
  156. package/dist/types/canvas/index.d.ts +18 -0
  157. package/dist/types/canvas/input.d.ts +63 -0
  158. package/dist/types/canvas/instant.d.ts +13 -0
  159. package/dist/types/canvas/kernel.d.ts +27 -0
  160. package/dist/types/canvas/motion.d.ts +72 -0
  161. package/dist/types/canvas/palette.d.ts +46 -0
  162. package/dist/types/canvas/random-id.d.ts +6 -0
  163. package/dist/types/canvas/scene-renderer.d.ts +27 -0
  164. package/dist/types/canvas/scene.styles.d.ts +4 -0
  165. package/dist/types/canvas/surface-model.d.ts +113 -0
  166. package/dist/types/canvas/uploads.d.ts +58 -0
  167. package/dist/types/index.d.ts +1 -0
  168. package/dist/types/kernel/actions.d.ts +19 -0
  169. package/dist/types/kernel/board.d.ts +137 -0
  170. package/dist/types/kernel/claims.d.ts +29 -0
  171. package/dist/types/kernel/clipboard.d.ts +10 -0
  172. package/dist/types/kernel/constants.d.ts +195 -0
  173. package/dist/types/kernel/contract.d.ts +1533 -0
  174. package/dist/types/kernel/decode.d.ts +60 -0
  175. package/dist/types/kernel/editor.d.ts +12 -0
  176. package/dist/types/kernel/errors.d.ts +11 -0
  177. package/dist/types/kernel/fractional-index.d.ts +7 -0
  178. package/dist/types/kernel/geometry.d.ts +42 -0
  179. package/dist/types/kernel/hit-test.d.ts +16 -0
  180. package/dist/types/kernel/index.d.ts +8 -0
  181. package/dist/types/kernel/inspect.d.ts +6 -0
  182. package/dist/types/kernel/kernel.d.ts +6 -0
  183. package/dist/types/kernel/outline.d.ts +4 -0
  184. package/dist/types/kernel/plan.d.ts +20 -0
  185. package/dist/types/kernel/rev.d.ts +21 -0
  186. package/dist/types/kernel/scene.d.ts +16 -0
  187. package/dist/types/kernel/schema.d.ts +3436 -0
  188. package/dist/types/kernel/snap.d.ts +41 -0
  189. package/dist/types/kernel/svg.d.ts +3 -0
  190. package/dist/types/kernel/text.d.ts +21 -0
  191. package/docs/api.json +207 -0
  192. package/docs/canvas.md +444 -0
  193. package/docs/kernel.md +108 -0
  194. package/docs/llms.txt +41 -0
  195. package/docs/search-index.json +52 -0
  196. package/package.json +55 -4
@@ -0,0 +1,1533 @@
1
+ /**
2
+ * The kernel contract: every type that crosses the kernel's surface.
3
+ *
4
+ * Every value is plain JSON: objects, arrays, strings, finite numbers,
5
+ * booleans and `null`. No value is ever `undefined`. An optional key (`?:`)
6
+ * appears only on inputs a caller writes (commands, transactions), where a
7
+ * missing key means the documented default; every value the kernel returns
8
+ * has all of its keys. Unknown keys are refused, so a typo fails loudly.
9
+ *
10
+ * Inputs are treated as immutable: the kernel remembers which objects it has
11
+ * already checked, so a host must not change an object after passing it.
12
+ *
13
+ * A Rust kernel generates its types from the JSON Schema of these types and
14
+ * must pass the same fixtures (`fixtures/`).
15
+ */
16
+ /** A path into an argument, e.g. `["transaction", "commands", 2, "id"]`. */
17
+ export type PathJson = ReadonlyArray<string | number>;
18
+ /**
19
+ * Why a call failed. Each error names the fix in `message`, written for the
20
+ * person or agent that sent the input.
21
+ */
22
+ export type CommandErrorJson = {
23
+ readonly _tag: "ShapeNotFound";
24
+ readonly path: PathJson;
25
+ readonly id: string;
26
+ /** Up to three existing ids closest to `id`, closest first. */
27
+ readonly closest: ReadonlyArray<string>;
28
+ readonly message: string;
29
+ } | {
30
+ readonly _tag: "TransactionNotFound";
31
+ readonly path: PathJson;
32
+ readonly id: string;
33
+ readonly closest: ReadonlyArray<string>;
34
+ readonly message: string;
35
+ } | {
36
+ readonly _tag: "Invalid";
37
+ readonly path: PathJson;
38
+ /** What the field at `path` accepts. */
39
+ readonly expected: string;
40
+ readonly message: string;
41
+ } | {
42
+ readonly _tag: "Claimed";
43
+ readonly path: PathJson;
44
+ readonly id: string;
45
+ /**
46
+ * The actors whose connections hold the shape right now. The planner's
47
+ * own actor appears when another of its connections holds it.
48
+ */
49
+ readonly by: ReadonlyArray<string>;
50
+ readonly message: string;
51
+ } | {
52
+ readonly _tag: "Locked";
53
+ readonly path: PathJson;
54
+ readonly id: string;
55
+ readonly message: string;
56
+ } | {
57
+ /**
58
+ * The transaction is not among the board's recent records, and older
59
+ * ones have been dropped, so it may have been one of them.
60
+ */
61
+ readonly _tag: "HistoryExpired";
62
+ readonly path: PathJson;
63
+ readonly id: string;
64
+ /** The `seq` of the oldest record the board still keeps. */
65
+ readonly oldest: number;
66
+ readonly message: string;
67
+ } | {
68
+ readonly _tag: "TooLarge";
69
+ readonly path: PathJson;
70
+ readonly limit: number;
71
+ readonly size: number;
72
+ readonly message: string;
73
+ };
74
+ /** Every kernel function returns one of these and never throws. */
75
+ export type Outcome<A> = {
76
+ readonly ok: A;
77
+ } | {
78
+ readonly error: CommandErrorJson;
79
+ };
80
+ export interface PointJson {
81
+ readonly x: number;
82
+ readonly y: number;
83
+ }
84
+ export interface BoxJson {
85
+ readonly x: number;
86
+ readonly y: number;
87
+ readonly w: number;
88
+ readonly h: number;
89
+ }
90
+ export type SideJson = "top" | "right" | "bottom" | "left";
91
+ /**
92
+ * A palette key. The document names colors only by key; a renderer resolves
93
+ * each key through its theme's palette (`PaletteJson`).
94
+ */
95
+ export type ColorJson = "ink" | "gray" | "yellow" | "orange" | "red" | "pink" | "violet" | "blue" | "teal" | "green";
96
+ /** Size token: a font size for text, a stroke width for ink. */
97
+ export type SizeJson = "s" | "m" | "l" | "xl";
98
+ export type BoxFormJson = "rectangle" | "ellipse";
99
+ /** How a connector end is drawn. */
100
+ export type HeadJson = "none" | "arrow" | "triangle" | "dot";
101
+ /** `straight`: one segment. `elbow`: horizontal and vertical segments. */
102
+ export type RouteJson = "straight" | "elbow";
103
+ /** Horizontal text alignment. */
104
+ export type TextAlignJson = "start" | "center" | "end";
105
+ export type DashJson = "solid" | "dashed" | "dotted";
106
+ /** Ink variant: `pen` is opaque, `marker` is wide and opaque, `highlighter` is wide and translucent. */
107
+ export type BrushJson = "pen" | "marker" | "highlighter";
108
+ /**
109
+ * Where a connector end attaches.
110
+ *
111
+ * - `Shape` follows a shape. `at` is a fixed spot on the shape as fractions
112
+ * of its box (`{ x: 0.5, y: 0 }` is the middle of the top edge); `null`
113
+ * lets the end float to the outline facing the other end.
114
+ * - `Point` is free on the board.
115
+ */
116
+ export type AnchorJson = {
117
+ readonly _tag: "Shape";
118
+ readonly id: string;
119
+ readonly at: PointJson | null;
120
+ } | {
121
+ readonly _tag: "Point";
122
+ readonly x: number;
123
+ readonly y: number;
124
+ };
125
+ export interface StickyStyleJson {
126
+ readonly color: ColorJson;
127
+ readonly size: SizeJson;
128
+ readonly align: TextAlignJson;
129
+ }
130
+ export interface BoxStyleJson {
131
+ readonly color: ColorJson;
132
+ readonly form: BoxFormJson;
133
+ readonly size: SizeJson;
134
+ readonly align: TextAlignJson;
135
+ /** Whether the inside is filled with the color's light tone. */
136
+ readonly fill: boolean;
137
+ readonly dash: DashJson;
138
+ }
139
+ export interface TextStyleJson {
140
+ readonly color: ColorJson;
141
+ readonly size: SizeJson;
142
+ readonly align: TextAlignJson;
143
+ /** `auto`: the shape is as wide as its longest line. `fixed`: lines wrap at `w`. */
144
+ readonly width: "auto" | "fixed";
145
+ }
146
+ export interface ArrowStyleJson {
147
+ readonly color: ColorJson;
148
+ readonly start: HeadJson;
149
+ readonly end: HeadJson;
150
+ readonly route: RouteJson;
151
+ readonly dash: DashJson;
152
+ }
153
+ export interface InkStyleJson {
154
+ readonly color: ColorJson;
155
+ readonly size: SizeJson;
156
+ readonly brush: BrushJson;
157
+ }
158
+ export type StyleJson = StickyStyleJson | BoxStyleJson | TextStyleJson | ArrowStyleJson | InkStyleJson;
159
+ /** Fields every shape row has. */
160
+ interface RowJson {
161
+ readonly id: string;
162
+ /** Top-left corner; for a connector, its start as last planned. */
163
+ readonly x: number;
164
+ readonly y: number;
165
+ /** Size; for a connector, end minus start as last planned (may be negative). */
166
+ readonly w: number;
167
+ readonly h: number;
168
+ /** Fractional index; shapes draw in ascending `z`, ties by `id`. */
169
+ readonly z: string;
170
+ /** Shapes with the same group id select and move together. */
171
+ readonly group: string | null;
172
+ /** A locked shape can be selected but not moved, resized, edited or deleted until unlocked. */
173
+ readonly locked: boolean;
174
+ readonly createdBy: string;
175
+ readonly updatedBy: string;
176
+ }
177
+ export interface StickyJson extends RowJson {
178
+ readonly kind: "Sticky";
179
+ readonly text: string;
180
+ readonly style: StickyStyleJson;
181
+ }
182
+ /** A rectangle or ellipse, with optional text inside. */
183
+ export interface BoxShapeJson extends RowJson {
184
+ readonly kind: "Box";
185
+ readonly text: string;
186
+ readonly style: BoxStyleJson;
187
+ }
188
+ export interface TextJson extends RowJson {
189
+ readonly kind: "Text";
190
+ readonly text: string;
191
+ readonly style: TextStyleJson;
192
+ }
193
+ /** A connector between two anchors. */
194
+ export interface ArrowJson extends RowJson {
195
+ readonly kind: "Arrow";
196
+ readonly from: AnchorJson;
197
+ readonly to: AnchorJson;
198
+ readonly style: ArrowStyleJson;
199
+ }
200
+ /** A freehand stroke. `points` are relative to `x, y`. */
201
+ export interface InkJson extends RowJson {
202
+ readonly kind: "Ink";
203
+ readonly points: ReadonlyArray<PointJson>;
204
+ readonly style: InkStyleJson;
205
+ }
206
+ /**
207
+ * A picture. `asset` is the host's opaque reference to the file; the host
208
+ * resolves it to a URL and the kernel never sees one. No natural size is
209
+ * stored: `w` and `h` hold the aspect, and resizing keeps it.
210
+ */
211
+ export interface ImageJson extends RowJson {
212
+ readonly kind: "Image";
213
+ readonly asset: string;
214
+ /** Description for screen readers and agents; "" when there is none. */
215
+ readonly alt: string;
216
+ }
217
+ /**
218
+ * A frozen instant: `at` is integer epoch milliseconds (UTC), from 0 to
219
+ * 8.64e15, set when the shape is created and never changed after (no patch
220
+ * takes it). The kernel never formats it in a local time zone: the scene
221
+ * carries `at`, and the renderer formats it for its viewer.
222
+ */
223
+ export interface TimestampJson extends RowJson {
224
+ readonly kind: "Timestamp";
225
+ readonly at: number;
226
+ }
227
+ export type ShapeJson = StickyJson | BoxShapeJson | TextJson | ArrowJson | InkJson | ImageJson | TimestampJson;
228
+ export type ShapeKindJson = ShapeJson["kind"];
229
+ /** Row fields a patch change sets. */
230
+ export interface ShapeFieldsJson {
231
+ readonly x?: number;
232
+ readonly y?: number;
233
+ readonly w?: number;
234
+ readonly h?: number;
235
+ readonly z?: string;
236
+ readonly group?: string | null;
237
+ readonly locked?: boolean;
238
+ readonly text?: string;
239
+ readonly style?: StyleJson;
240
+ readonly from?: AnchorJson;
241
+ readonly to?: AnchorJson;
242
+ readonly points?: ReadonlyArray<PointJson>;
243
+ readonly asset?: string;
244
+ readonly alt?: string;
245
+ readonly updatedBy?: string;
246
+ }
247
+ /** One row write. */
248
+ export type ShapeChangeJson = {
249
+ readonly op: "set";
250
+ readonly shape: ShapeJson;
251
+ } | {
252
+ readonly op: "patch";
253
+ readonly id: string;
254
+ readonly fields: ShapeFieldsJson;
255
+ } | {
256
+ readonly op: "remove";
257
+ readonly id: string;
258
+ };
259
+ export interface AuthorJson {
260
+ readonly principal: string;
261
+ /** The agent acting for the principal, if any. */
262
+ readonly via: string | null;
263
+ }
264
+ /** The record of one transaction, kept in the board's recent history. */
265
+ export interface TransactionRecordJson {
266
+ readonly id: string;
267
+ /** The board's `head` after this transaction: 1 for the first, then one more each time. */
268
+ readonly seq: number;
269
+ readonly author: AuthorJson;
270
+ readonly reason: string | null;
271
+ readonly mode: "commit" | "propose";
272
+ /**
273
+ * What the transaction wrote, or for a proposal what it would write. A
274
+ * proposal's changes reach the rows only when a later transaction accepts it.
275
+ */
276
+ readonly changes: ReadonlyArray<ShapeChangeJson>;
277
+ /** Index for index, the change that undoes each of `changes`. */
278
+ readonly inverse: ReadonlyArray<ShapeChangeJson>;
279
+ /** Ids of the shapes `changes` touch. */
280
+ readonly shapes: ReadonlyArray<string>;
281
+ /** Proposals this transaction accepted. */
282
+ readonly accepts: ReadonlyArray<string>;
283
+ /** Transactions this transaction reverted (a pending proposal reverted is rejected). */
284
+ readonly reverts: ReadonlyArray<string>;
285
+ }
286
+ /**
287
+ * A board: its shapes, how many transactions it has seen, and the recent
288
+ * ones, within `BOARD_HISTORY`. `apply` drops the oldest settled records past
289
+ * the bound, so a board is the same size after a thousand edits as after ten.
290
+ */
291
+ export interface BoardJson {
292
+ readonly shapes: ReadonlyArray<ShapeJson>;
293
+ /** The `seq` of the last transaction applied; 0 for a new board. */
294
+ readonly head: number;
295
+ /**
296
+ * Recent transaction records in `seq` order: every pending proposal, and
297
+ * the newest settled records that fit `BOARD_HISTORY`. Only these can be
298
+ * reverted, accepted, or checked for a reused id.
299
+ */
300
+ readonly transactions: ReadonlyArray<TransactionRecordJson>;
301
+ }
302
+ /**
303
+ * The bound on a board's history. Sizes are UTF-8 bytes of a record written
304
+ * as compact JSON, without whitespace.
305
+ */
306
+ export interface BoardHistoryJson {
307
+ /** Most records a board keeps, pending proposals included. */
308
+ readonly records: number;
309
+ /** Most bytes of records a board keeps, pending proposals included. */
310
+ readonly bytes: number;
311
+ /** Largest record one transaction may produce. */
312
+ readonly recordBytes: number;
313
+ /** Most pending proposals at once. */
314
+ readonly proposals: number;
315
+ /** Most bytes of pending proposals at once. */
316
+ readonly proposalBytes: number;
317
+ }
318
+ /**
319
+ * What copy and cut put on the clipboard. A host writes it as
320
+ * `JSON.stringify(clipboard)` and reads it back with `decodeClipboard`.
321
+ */
322
+ export interface ClipboardJson {
323
+ readonly kind: "hyper-canvas";
324
+ readonly version: 1;
325
+ readonly shapes: ReadonlyArray<ShapeJson>;
326
+ }
327
+ /**
328
+ * What `decodeClipboard` read from clipboard text.
329
+ *
330
+ * - `Shapes`: a board clipboard to send as `Paste`.
331
+ * - `NotOurs`: anything else (plain text, other apps' JSON); paste it as text.
332
+ * - `Invalid`: a board clipboard (`kind` is `"hyper-canvas"`) this kernel
333
+ * cannot read, for example from a newer version; tell the person why.
334
+ */
335
+ export type ClipboardDecodeJson = {
336
+ readonly _tag: "Shapes";
337
+ readonly clipboard: ClipboardJson;
338
+ } | {
339
+ readonly _tag: "NotOurs";
340
+ } | {
341
+ readonly _tag: "Invalid";
342
+ readonly error: CommandErrorJson;
343
+ };
344
+ /** Where a new or moved shape goes. Without one, it goes to the right of everything. */
345
+ export type PlacementJson = {
346
+ readonly _tag: "At";
347
+ readonly x: number;
348
+ readonly y: number;
349
+ } | {
350
+ readonly _tag: "Beside";
351
+ readonly shape: string;
352
+ readonly side: SideJson;
353
+ /** Default 40. */
354
+ readonly gap?: number;
355
+ };
356
+ /** A new shape. Left-out fields take the documented defaults. */
357
+ export type ShapeInputJson = {
358
+ readonly kind: "Sticky";
359
+ /** Default: `sticky-<transaction>-<n>`. */
360
+ readonly id?: string;
361
+ readonly text?: string;
362
+ readonly color?: ColorJson;
363
+ readonly size?: SizeJson;
364
+ readonly align?: TextAlignJson;
365
+ readonly w?: number;
366
+ readonly h?: number;
367
+ } | {
368
+ readonly kind: "Box";
369
+ readonly id?: string;
370
+ readonly text?: string;
371
+ readonly form?: BoxFormJson;
372
+ readonly color?: ColorJson;
373
+ readonly size?: SizeJson;
374
+ readonly align?: TextAlignJson;
375
+ readonly fill?: boolean;
376
+ readonly dash?: DashJson;
377
+ readonly w?: number;
378
+ readonly h?: number;
379
+ } | {
380
+ readonly kind: "Text";
381
+ readonly id?: string;
382
+ readonly text: string;
383
+ readonly color?: ColorJson;
384
+ readonly size?: SizeJson;
385
+ readonly align?: TextAlignJson;
386
+ /** Wrap width; left out, the text is as wide as its longest line. */
387
+ readonly w?: number;
388
+ } | {
389
+ readonly kind: "Arrow";
390
+ readonly id?: string;
391
+ readonly from: AnchorJson;
392
+ readonly to: AnchorJson;
393
+ readonly color?: ColorJson;
394
+ readonly start?: HeadJson;
395
+ readonly end?: HeadJson;
396
+ readonly route?: RouteJson;
397
+ readonly dash?: DashJson;
398
+ } | {
399
+ readonly kind: "Ink";
400
+ readonly id?: string;
401
+ /** Board coordinates, in drawing order. */
402
+ readonly points: ReadonlyArray<PointJson>;
403
+ readonly color?: ColorJson;
404
+ readonly size?: SizeJson;
405
+ readonly brush?: BrushJson;
406
+ } | {
407
+ readonly kind: "Image";
408
+ readonly id?: string;
409
+ readonly asset: string;
410
+ /** Default "". */
411
+ readonly alt?: string;
412
+ readonly w: number;
413
+ readonly h: number;
414
+ } | {
415
+ readonly kind: "Timestamp";
416
+ readonly id?: string;
417
+ /** Integer epoch milliseconds, 0 to 8.64e15: the host's "now" when it places one. */
418
+ readonly at: number;
419
+ /** Default `DEFAULTS.timestamp`. */
420
+ readonly w?: number;
421
+ readonly h?: number;
422
+ };
423
+ /**
424
+ * Changes to one shape. Each key applies only to the kinds that have it. A
425
+ * timestamp takes `x`, `y`, `w` and `h` only: its instant never changes.
426
+ */
427
+ export interface ShapePatchJson {
428
+ readonly x?: number;
429
+ readonly y?: number;
430
+ readonly w?: number;
431
+ readonly h?: number;
432
+ readonly text?: string;
433
+ readonly color?: ColorJson;
434
+ readonly size?: SizeJson;
435
+ readonly align?: TextAlignJson;
436
+ readonly form?: BoxFormJson;
437
+ readonly fill?: boolean;
438
+ readonly dash?: DashJson;
439
+ readonly brush?: BrushJson;
440
+ readonly start?: HeadJson;
441
+ readonly end?: HeadJson;
442
+ readonly route?: RouteJson;
443
+ readonly from?: AnchorJson;
444
+ readonly to?: AnchorJson;
445
+ /**
446
+ * Image only: replaces the picture in place, keeping its id, box and draw
447
+ * order. The kernel does not know natural sizes, so the box keeps its
448
+ * aspect; send `w` and `h` too to fit a different one.
449
+ */
450
+ readonly asset?: string;
451
+ readonly alt?: string;
452
+ }
453
+ export type AlignJson = "left" | "center" | "right" | "top" | "middle" | "bottom";
454
+ export type CommandJson = {
455
+ readonly _tag: "Create";
456
+ readonly shape: ShapeInputJson;
457
+ readonly place?: PlacementJson;
458
+ } | {
459
+ readonly _tag: "Update";
460
+ readonly id: string;
461
+ readonly patch: ShapePatchJson;
462
+ } | {
463
+ readonly _tag: "Move";
464
+ readonly ids: ReadonlyArray<string>;
465
+ /** Where the top-left corner of the shapes' joint bounds goes. */
466
+ readonly place: PlacementJson;
467
+ } | {
468
+ /** Scales the shapes' joint bounds to `box`. */
469
+ readonly _tag: "Resize";
470
+ readonly ids: ReadonlyArray<string>;
471
+ readonly box: BoxJson;
472
+ } | {
473
+ readonly _tag: "Delete";
474
+ readonly ids: ReadonlyArray<string>;
475
+ } | {
476
+ readonly _tag: "Reorder";
477
+ readonly ids: ReadonlyArray<string>;
478
+ /** `forward` and `backward` step past the nearest overlapping shape. */
479
+ readonly to: "front" | "back" | "forward" | "backward";
480
+ } | {
481
+ readonly _tag: "Align";
482
+ readonly ids: ReadonlyArray<string>;
483
+ readonly to: AlignJson;
484
+ } | {
485
+ /** Equal gaps between three or more shapes, keeping the outer two in place. */
486
+ readonly _tag: "Distribute";
487
+ readonly ids: ReadonlyArray<string>;
488
+ readonly axis: "horizontal" | "vertical";
489
+ } | {
490
+ readonly _tag: "Duplicate";
491
+ readonly ids: ReadonlyArray<string>;
492
+ /** Offset of the copies; default 16 each. */
493
+ readonly dx?: number;
494
+ readonly dy?: number;
495
+ /** Ids for the copies, one per id in `ids` in order; default generated. */
496
+ readonly as?: ReadonlyArray<string>;
497
+ } | {
498
+ readonly _tag: "Paste";
499
+ readonly clipboard: ClipboardJson;
500
+ /** Where the top-left corner of the pasted shapes goes; default where they were. */
501
+ readonly place?: PlacementJson;
502
+ /** Ids for the pasted shapes, one per clipboard shape in order. */
503
+ readonly as?: ReadonlyArray<string>;
504
+ } | {
505
+ readonly _tag: "Group";
506
+ readonly ids: ReadonlyArray<string>;
507
+ /** Default: `group-<transaction>-<n>`. */
508
+ readonly group?: string;
509
+ } | {
510
+ readonly _tag: "Ungroup";
511
+ readonly ids: ReadonlyArray<string>;
512
+ } | {
513
+ readonly _tag: "Lock";
514
+ readonly ids: ReadonlyArray<string>;
515
+ readonly locked: boolean;
516
+ } | {
517
+ readonly _tag: "Accept";
518
+ readonly transaction: string;
519
+ } | {
520
+ readonly _tag: "Revert";
521
+ readonly transaction: string;
522
+ };
523
+ export interface TransactionJson {
524
+ /** Unique on the board. */
525
+ readonly id: string;
526
+ readonly commands: ReadonlyArray<CommandJson>;
527
+ readonly reason?: string;
528
+ readonly mode: "commit" | "propose";
529
+ /** The agent acting for the principal, if any. */
530
+ readonly via?: string;
531
+ }
532
+ export interface PlanJson {
533
+ /** Row writes for the host to store, in order. Empty for a proposal. */
534
+ readonly changes: ReadonlyArray<ShapeChangeJson>;
535
+ readonly inverse: ReadonlyArray<ShapeChangeJson>;
536
+ /** The log entry to append in the same write. */
537
+ readonly record: TransactionRecordJson;
538
+ }
539
+ /** A pending proposal, for a review list. */
540
+ export interface ProposalJson {
541
+ readonly transaction: string;
542
+ readonly author: AuthorJson;
543
+ readonly reason: string | null;
544
+ readonly shapes: ReadonlyArray<string>;
545
+ readonly added: number;
546
+ readonly changed: number;
547
+ readonly removed: number;
548
+ }
549
+ export type ActorKindJson = "person" | "agent";
550
+ export type DraftKindJson = "sticky" | "rectangle" | "ellipse" | "text";
551
+ /** Where a moving shape's `x`, `y` go. */
552
+ export interface TargetJson {
553
+ readonly id: string;
554
+ readonly x: number;
555
+ readonly y: number;
556
+ }
557
+ /**
558
+ * What an actor is doing. The scene draws previews from it. Every preview
559
+ * names where things end up, never an offset, so a preview drawn over a board
560
+ * that already holds the result draws the result once: the order in which
561
+ * the commit and the presence update arrive does not matter.
562
+ */
563
+ export type ActivityJson = {
564
+ readonly _tag: "Idle";
565
+ } | {
566
+ readonly _tag: "Thinking";
567
+ readonly label: string;
568
+ } | {
569
+ readonly _tag: "Working";
570
+ readonly label: string;
571
+ } | {
572
+ /** Moving shapes: each to its own target. */
573
+ readonly _tag: "Gesture";
574
+ readonly shapes: ReadonlyArray<TargetJson>;
575
+ /** The id of the transaction the drop commits as; see `Resizing`. */
576
+ readonly transaction: string;
577
+ } | {
578
+ /** Scaling the shapes' joint bounds to `box`. */
579
+ readonly _tag: "Resizing";
580
+ readonly ids: ReadonlyArray<string>;
581
+ readonly box: BoxJson;
582
+ /**
583
+ * The id of the transaction the drop commits as (`TransactionJson.id`),
584
+ * reserved when the gesture starts. Each gesture has its own, never
585
+ * reused even when the gesture is cancelled or its drop changes nothing,
586
+ * and no other transaction takes it, so a viewer tells two gestures on
587
+ * the same shapes apart when no other activity was published between
588
+ * them, and knows which commit ends which.
589
+ */
590
+ readonly transaction: string;
591
+ } | {
592
+ readonly _tag: "Selecting";
593
+ readonly box: BoxJson;
594
+ } | {
595
+ /**
596
+ * Drawing a new shape. `id` is the id it will have, so the preview stops
597
+ * once the board holds it; null when unknown.
598
+ */
599
+ readonly _tag: "Creating";
600
+ readonly draft: DraftKindJson;
601
+ readonly box: BoxJson;
602
+ readonly id: string | null;
603
+ } | {
604
+ /**
605
+ * Drawing a connector or moving an end of one. `arrow` is its id: the
606
+ * board's connector is drawn with these ends, or, until the board holds
607
+ * it, a guide is. Null for a new connector whose id is unknown.
608
+ */
609
+ readonly _tag: "Connecting";
610
+ readonly arrow: string | null;
611
+ readonly from: AnchorJson;
612
+ readonly to: AnchorJson;
613
+ } | {
614
+ /** A stroke in progress. `id` as for `Creating`. */
615
+ readonly _tag: "Inking";
616
+ readonly points: ReadonlyArray<PointJson>;
617
+ readonly color: ColorJson;
618
+ readonly size: SizeJson;
619
+ readonly brush: BrushJson;
620
+ readonly id: string | null;
621
+ } | {
622
+ readonly _tag: "Erasing";
623
+ readonly ids: ReadonlyArray<string>;
624
+ } | {
625
+ readonly _tag: "Typing";
626
+ readonly id: string;
627
+ };
628
+ export interface CursorJson {
629
+ readonly point: PointJson;
630
+ /** How long the cursor should glide to `point`; 0 jumps. Agents use this to move visibly. */
631
+ readonly arriveInMs: number;
632
+ }
633
+ /**
634
+ * One connection's presence. An actor (a person or agent) may hold several
635
+ * connections at once, for example a board open in two tabs; each publishes
636
+ * its own entry.
637
+ */
638
+ export interface PresenceJson {
639
+ readonly actor: string;
640
+ /**
641
+ * Which of the actor's connections this is, unique among that actor's
642
+ * entries (an id, as for shapes). A host running the editor publishes its
643
+ * editor's `session`; any other client (an agent, a server job) uses an id
644
+ * of its own and passes it to `plan`. Entries with the same actor and
645
+ * connection are one entry: the last one counts, at the first's position.
646
+ */
647
+ readonly connection: string;
648
+ /** Display name for cursor labels and the outline. */
649
+ readonly name: string;
650
+ readonly kind: ActorKindJson;
651
+ readonly cursor: CursorJson | null;
652
+ readonly selection: ReadonlyArray<string>;
653
+ readonly viewport: BoxJson;
654
+ readonly following: string | null;
655
+ readonly activity: ActivityJson;
656
+ /**
657
+ * Shapes this connection is editing. A claim is held per connection: the
658
+ * actor's other connections are refused like anyone else (see `Kernel.plan`).
659
+ */
660
+ readonly claims: ReadonlyArray<string>;
661
+ /** Images this actor is uploading, at most `LIMITS.uploads`. */
662
+ readonly uploads: ReadonlyArray<UploadJson>;
663
+ /**
664
+ * Cursor chat: a short message shown at the cursor, at most `LIMITS.chat`
665
+ * (200) UTF-16 code units, or null when none is open. Presence only: never
666
+ * stored on the board.
667
+ */
668
+ readonly chat: string | null;
669
+ }
670
+ /**
671
+ * An image on its way: where it will appear. Nothing is stored until the
672
+ * host inserts the image; scenes draw a placeholder from presence.
673
+ */
674
+ export interface UploadJson {
675
+ /** The host's id for the upload. */
676
+ readonly id: string;
677
+ readonly box: BoxJson;
678
+ /** File name to show, if any. */
679
+ readonly name: string | null;
680
+ }
681
+ /** The visible part of the board, in board units, and who is looking. */
682
+ export interface ViewportJson {
683
+ readonly x: number;
684
+ readonly y: number;
685
+ readonly w: number;
686
+ readonly h: number;
687
+ /** Screen pixels per board unit: the screen is `w * zoom` by `h * zoom` pixels. */
688
+ readonly zoom: number;
689
+ /**
690
+ * The actor whose screen this is. The scene draws this connection's own
691
+ * feedback from the editor state, and from the viewer's other connections
692
+ * only their previews (no cursor, selection or marquee).
693
+ */
694
+ readonly viewer: string | null;
695
+ }
696
+ /** Marks a shape drawn as a preview rather than as it is. */
697
+ export type GhostJson = {
698
+ readonly _tag: "Proposal";
699
+ readonly transaction: string;
700
+ readonly change: "add" | "change" | "remove";
701
+ } | {
702
+ readonly _tag: "Erasing";
703
+ readonly actor: string;
704
+ } | null;
705
+ export interface FontRefJson {
706
+ /** CSS font families, first choice first. */
707
+ readonly families: ReadonlyArray<string>;
708
+ /** CSS font weight. */
709
+ readonly weight: number;
710
+ /** Font size in board units. */
711
+ readonly size: number;
712
+ /** Line height in board units. */
713
+ readonly lineHeight: number;
714
+ }
715
+ /** One laid-out line: `x` is where it starts, `y` its baseline, `width` its measured width. */
716
+ export interface TextLineJson {
717
+ readonly text: string;
718
+ readonly x: number;
719
+ readonly y: number;
720
+ readonly width: number;
721
+ }
722
+ export type ResizeHandleJson = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
723
+ export type HandleJson = ResizeHandleJson | "from" | "to";
724
+ /** How a fill uses its palette key: `note` is sticky paper, `light` a box fill. */
725
+ export type ToneJson = "note" | "light";
726
+ export type SnapKindJson = "edge" | "center" | "spacing" | "grid";
727
+ /**
728
+ * One thing to draw, in board coordinates, back to front. Every item has a
729
+ * `key` unique in its scene and stable across scenes, for diffing.
730
+ */
731
+ /**
732
+ * One thing to draw, in board coordinates, back to front. Every item has a
733
+ * `key` unique in its scene and stable across scenes, for diffing, and a
734
+ * `rev`: two items with the same `rev` are equal in every other field, so a
735
+ * renderer that drew an item with this key and rev may skip it. `rev` is
736
+ * opaque, deterministic and specific to the kernel build; it is not part of
737
+ * the conformance fixtures.
738
+ */
739
+ export type DrawItemJson = {
740
+ readonly _tag: "Rect";
741
+ readonly key: string;
742
+ readonly rev: string;
743
+ readonly id: string;
744
+ readonly box: BoxJson;
745
+ readonly fill: ColorJson | null;
746
+ readonly tone: ToneJson;
747
+ readonly stroke: ColorJson | null;
748
+ readonly dash: DashJson;
749
+ readonly radius: number;
750
+ readonly shadow: boolean;
751
+ readonly ghost: GhostJson;
752
+ } | {
753
+ readonly _tag: "Ellipse";
754
+ readonly key: string;
755
+ readonly rev: string;
756
+ readonly id: string;
757
+ readonly box: BoxJson;
758
+ readonly fill: ColorJson | null;
759
+ readonly tone: ToneJson;
760
+ readonly stroke: ColorJson | null;
761
+ readonly dash: DashJson;
762
+ readonly ghost: GhostJson;
763
+ } | {
764
+ readonly _tag: "TextLines";
765
+ readonly key: string;
766
+ readonly rev: string;
767
+ readonly id: string;
768
+ /** The box lines are laid out in; `align` is relative to it. */
769
+ readonly box: BoxJson;
770
+ readonly lines: ReadonlyArray<TextLineJson>;
771
+ readonly font: FontRefJson;
772
+ readonly color: ColorJson;
773
+ readonly align: TextAlignJson;
774
+ readonly ghost: GhostJson;
775
+ } | {
776
+ /** A connector or an ink stroke. */
777
+ readonly _tag: "Path";
778
+ readonly key: string;
779
+ readonly rev: string;
780
+ readonly id: string;
781
+ readonly d: string;
782
+ readonly stroke: ColorJson;
783
+ readonly width: number;
784
+ readonly dash: DashJson;
785
+ readonly opacity: number;
786
+ readonly start: HeadJson;
787
+ readonly end: HeadJson;
788
+ readonly ghost: GhostJson;
789
+ } | {
790
+ /** A connector being drawn. */
791
+ readonly _tag: "Guide";
792
+ readonly key: string;
793
+ readonly rev: string;
794
+ readonly actor: string;
795
+ readonly kind: ActorKindJson;
796
+ readonly d: string;
797
+ readonly start: HeadJson;
798
+ readonly end: HeadJson;
799
+ } | {
800
+ readonly _tag: "InkPreview";
801
+ readonly key: string;
802
+ readonly rev: string;
803
+ readonly actor: string;
804
+ readonly d: string;
805
+ readonly stroke: ColorJson;
806
+ readonly width: number;
807
+ readonly opacity: number;
808
+ } | {
809
+ /** A shape being dragged out. */
810
+ readonly _tag: "Draft";
811
+ readonly key: string;
812
+ readonly rev: string;
813
+ readonly actor: string;
814
+ readonly kind: ActorKindJson;
815
+ readonly draft: DraftKindJson;
816
+ readonly box: BoxJson;
817
+ } | {
818
+ /** The outline of the shape under the viewer's pointer. */
819
+ readonly _tag: "Hover";
820
+ readonly key: string;
821
+ readonly rev: string;
822
+ readonly id: string;
823
+ readonly d: string;
824
+ } | {
825
+ readonly _tag: "Selection";
826
+ readonly key: string;
827
+ readonly rev: string;
828
+ readonly actor: string;
829
+ readonly kind: ActorKindJson;
830
+ /** Whether it is the viewer's own selection. */
831
+ readonly mine: boolean;
832
+ readonly id: string;
833
+ readonly box: BoxJson;
834
+ } | {
835
+ /** The joint bounds of the viewer's selection. */
836
+ readonly _tag: "Bounds";
837
+ readonly key: string;
838
+ readonly rev: string;
839
+ readonly box: BoxJson;
840
+ } | {
841
+ readonly _tag: "Handle";
842
+ readonly key: string;
843
+ readonly rev: string;
844
+ readonly handle: HandleJson;
845
+ readonly box: BoxJson;
846
+ } | {
847
+ readonly _tag: "Marquee";
848
+ readonly key: string;
849
+ readonly rev: string;
850
+ readonly actor: string;
851
+ readonly kind: ActorKindJson;
852
+ readonly mine: boolean;
853
+ readonly box: BoxJson;
854
+ } | {
855
+ /** Where the DOM text editor sits while the viewer edits `id`; matches its `TextLines`. */
856
+ readonly _tag: "TextEditor";
857
+ readonly key: string;
858
+ readonly rev: string;
859
+ readonly id: string;
860
+ readonly box: BoxJson;
861
+ readonly font: FontRefJson;
862
+ readonly color: ColorJson;
863
+ readonly align: TextAlignJson;
864
+ } | {
865
+ /** Draw `asset`, as the host resolves it, stretched to `box`. */
866
+ readonly _tag: "Image";
867
+ readonly key: string;
868
+ readonly rev: string;
869
+ readonly id: string;
870
+ readonly box: BoxJson;
871
+ readonly asset: string;
872
+ readonly alt: string;
873
+ readonly ghost: GhostJson;
874
+ } | {
875
+ /** A placeholder for an upload; hosts overlay their own progress. */
876
+ readonly _tag: "Upload";
877
+ readonly key: string;
878
+ readonly rev: string;
879
+ readonly actor: string;
880
+ readonly kind: ActorKindJson;
881
+ readonly mine: boolean;
882
+ readonly id: string;
883
+ readonly box: BoxJson;
884
+ readonly name: string | null;
885
+ } | {
886
+ readonly _tag: "SnapGuide";
887
+ readonly key: string;
888
+ readonly rev: string;
889
+ readonly guide: SnapKindJson;
890
+ readonly from: PointJson;
891
+ readonly to: PointJson;
892
+ } | {
893
+ /** The trail of the viewer's eraser. */
894
+ readonly _tag: "EraserTrail";
895
+ readonly key: string;
896
+ readonly rev: string;
897
+ readonly d: string;
898
+ } | {
899
+ readonly _tag: "Cursor";
900
+ readonly key: string;
901
+ readonly rev: string;
902
+ readonly actor: string;
903
+ readonly kind: ActorKindJson;
904
+ readonly point: PointJson;
905
+ readonly label: string;
906
+ readonly arriveInMs: number;
907
+ /** The connection's cursor chat, to draw as a bubble at the cursor; null for none. */
908
+ readonly chat: string | null;
909
+ } | {
910
+ /**
911
+ * A timestamp shape in `box`. `at` is integer epoch milliseconds; the
912
+ * renderer formats it in its viewer's time zone.
913
+ */
914
+ readonly _tag: "Timestamp";
915
+ readonly key: string;
916
+ readonly rev: string;
917
+ readonly id: string;
918
+ readonly box: BoxJson;
919
+ readonly at: number;
920
+ readonly ghost: GhostJson;
921
+ };
922
+ export interface SceneJson {
923
+ /** The visible board area. */
924
+ readonly box: BoxJson;
925
+ readonly zoom: number;
926
+ readonly items: ReadonlyArray<DrawItemJson>;
927
+ }
928
+ /** One palette entry: strong (strokes, text), light (box fills), note (sticky paper). */
929
+ export interface SwatchJson {
930
+ readonly strong: string;
931
+ readonly light: string;
932
+ readonly note: string;
933
+ }
934
+ /** Concrete colors for one theme, as CSS hex (`#rrggbb` or `#rrggbbaa`). */
935
+ export interface PaletteJson {
936
+ readonly background: string;
937
+ /** Text on sticky paper, for every color: notes stay paper in a dark theme. */
938
+ readonly noteInk: string;
939
+ readonly colors: {
940
+ readonly ink: SwatchJson;
941
+ readonly gray: SwatchJson;
942
+ readonly yellow: SwatchJson;
943
+ readonly orange: SwatchJson;
944
+ readonly red: SwatchJson;
945
+ readonly pink: SwatchJson;
946
+ readonly violet: SwatchJson;
947
+ readonly blue: SwatchJson;
948
+ readonly teal: SwatchJson;
949
+ readonly green: SwatchJson;
950
+ };
951
+ /** The viewer's selection, bounds, handles and marquee. */
952
+ readonly selection: string;
953
+ /** Other people's selections and cursors. */
954
+ readonly person: string;
955
+ /** Agents' selections and cursors. */
956
+ readonly agent: string;
957
+ readonly snap: string;
958
+ }
959
+ export type PointerKindJson = "mouse" | "pen" | "touch";
960
+ export interface HitProbeJson {
961
+ readonly point: PointJson;
962
+ /** Screen pixels per board unit; tolerances are in screen pixels. */
963
+ readonly zoom: number;
964
+ /** Selected shapes, whose resize handles and connector ends are hit first. */
965
+ readonly selection: ReadonlyArray<string>;
966
+ /** Touch hits with a wider tolerance than mouse and pen. */
967
+ readonly pointer: PointerKindJson;
968
+ }
969
+ export type HitJson = {
970
+ readonly _tag: "Nothing";
971
+ } | {
972
+ readonly _tag: "Shape";
973
+ readonly id: string;
974
+ } | {
975
+ readonly _tag: "Handle";
976
+ readonly handle: ResizeHandleJson;
977
+ } | {
978
+ readonly _tag: "End";
979
+ readonly id: string;
980
+ readonly end: "from" | "to";
981
+ };
982
+ /** A style value across shapes: the shared value, `"mixed"`, or null when no shape has it. */
983
+ export type SharedJson<A> = A | "mixed" | null;
984
+ export interface InspectionJson {
985
+ /** The shapes inspected, unknown ids dropped. */
986
+ readonly ids: ReadonlyArray<string>;
987
+ readonly kinds: ReadonlyArray<ShapeKindJson>;
988
+ readonly style: {
989
+ readonly color: SharedJson<ColorJson>;
990
+ readonly size: SharedJson<SizeJson>;
991
+ readonly align: SharedJson<TextAlignJson>;
992
+ readonly form: SharedJson<BoxFormJson>;
993
+ readonly fill: SharedJson<boolean>;
994
+ readonly dash: SharedJson<DashJson>;
995
+ readonly brush: SharedJson<BrushJson>;
996
+ readonly start: SharedJson<HeadJson>;
997
+ readonly end: SharedJson<HeadJson>;
998
+ readonly route: SharedJson<RouteJson>;
999
+ };
1000
+ readonly can: {
1001
+ readonly restyle: boolean;
1002
+ readonly editText: boolean;
1003
+ readonly delete: boolean;
1004
+ readonly duplicate: boolean;
1005
+ readonly group: boolean;
1006
+ readonly ungroup: boolean;
1007
+ readonly lock: boolean;
1008
+ readonly unlock: boolean;
1009
+ readonly align: boolean;
1010
+ readonly distribute: boolean;
1011
+ readonly reorder: boolean;
1012
+ readonly connect: boolean;
1013
+ };
1014
+ }
1015
+ /**
1016
+ * Advance widths for one face at one font size, in font units. Inter uses
1017
+ * optical sizing, so advances differ by size. Generated offline by
1018
+ * `scripts/font-data.ts`; see the README.
1019
+ */
1020
+ export interface FontSizeTableJson {
1021
+ /** Font size in board units (CSS px). */
1022
+ readonly size: number;
1023
+ /** Advance of a code point the face does not cover. */
1024
+ readonly missing: number;
1025
+ /** Runs of consecutive code points: `advances[i]` belongs to `start + i`. */
1026
+ readonly ranges: ReadonlyArray<{
1027
+ readonly start: number;
1028
+ readonly advances: ReadonlyArray<number>;
1029
+ }>;
1030
+ }
1031
+ export interface FontFaceJson {
1032
+ readonly family: string;
1033
+ readonly weight: number;
1034
+ readonly unitsPerEm: number;
1035
+ readonly ascender: number;
1036
+ readonly descender: number;
1037
+ /** One table per text size (16, 20, 28 and 40). */
1038
+ readonly sizes: ReadonlyArray<FontSizeTableJson>;
1039
+ }
1040
+ /** Faces in fallback order: a code point measures with the first face that covers it. */
1041
+ export interface FontDataJson {
1042
+ readonly faces: ReadonlyArray<FontFaceJson>;
1043
+ }
1044
+ export type ToolJson = "select" | "hand" | "rectangle" | "ellipse" | "sticky" | "text" | "arrow" | "pen" | "eraser" | "comment" | "timestamp";
1045
+ export interface ModifiersJson {
1046
+ readonly shift: boolean;
1047
+ readonly alt: boolean;
1048
+ /** Command on macOS, Control elsewhere. */
1049
+ readonly meta: boolean;
1050
+ }
1051
+ /** Everything a person can trigger by name: menus, shortcuts, the command menu. */
1052
+ export type ActionIdJson = "tool-select" | "tool-hand" | "tool-rectangle" | "tool-ellipse" | "tool-sticky" | "tool-text" | "tool-arrow" | "tool-pen" | "tool-eraser" | "tool-comment" | "tool-timestamp" | "cancel" | "delete" | "select-all" | "select-next" | "select-previous" | "edit-text" | "undo" | "redo" | "copy" | "cut" | "duplicate" | "connect" | "group" | "ungroup" | "lock" | "unlock" | "bring-forward" | "send-backward" | "bring-to-front" | "send-to-back" | "align-left" | "align-center" | "align-right" | "align-top" | "align-middle" | "align-bottom" | "distribute-horizontal" | "distribute-vertical" | "nudge-left" | "nudge-right" | "nudge-up" | "nudge-down" | "nudge-left-large" | "nudge-right-large" | "nudge-up-large" | "nudge-down-large" | "zoom-in" | "zoom-out" | "zoom-reset" | "zoom-to-fit" | "zoom-to-selection" | "toggle-grid";
1053
+ /** A key combination. `key` is a `KeyboardEvent.key` value, letters lowercase. */
1054
+ export interface ShortcutJson {
1055
+ readonly key: string;
1056
+ readonly shift: boolean;
1057
+ readonly alt: boolean;
1058
+ readonly meta: boolean;
1059
+ }
1060
+ export interface ActionJson {
1061
+ readonly id: ActionIdJson;
1062
+ readonly label: string;
1063
+ readonly group: "tool" | "edit" | "arrange" | "view" | "history";
1064
+ /** The first is the one to show. */
1065
+ readonly shortcuts: ReadonlyArray<ShortcutJson>;
1066
+ readonly enabled: boolean;
1067
+ /** Why it is disabled when the reason is not obvious, such as "Sam is editing this"; otherwise null. */
1068
+ readonly reason: string | null;
1069
+ /** For tools and toggles, whether it is on; otherwise null. */
1070
+ readonly checked: boolean | null;
1071
+ }
1072
+ export interface SnapGuideJson {
1073
+ readonly guide: SnapKindJson;
1074
+ readonly from: PointJson;
1075
+ readonly to: PointJson;
1076
+ }
1077
+ export type EditorModeJson = {
1078
+ readonly _tag: "Idle";
1079
+ } | {
1080
+ /** Pointer down, not yet past the drag threshold. */
1081
+ readonly _tag: "Pressing";
1082
+ readonly origin: PointJson;
1083
+ readonly target: HitJson;
1084
+ readonly additive: boolean;
1085
+ readonly wasSelected: boolean;
1086
+ } | {
1087
+ readonly _tag: "Dragging";
1088
+ readonly origin: PointJson;
1089
+ readonly ids: ReadonlyArray<string>;
1090
+ readonly dx: number;
1091
+ readonly dy: number;
1092
+ /** Alt-drag: drop copies, leave the originals. */
1093
+ readonly copy: boolean;
1094
+ readonly guides: ReadonlyArray<SnapGuideJson>;
1095
+ /** The transaction id reserved for the drop; see `Resizing`. */
1096
+ readonly transaction: string;
1097
+ } | {
1098
+ readonly _tag: "Resizing";
1099
+ readonly ids: ReadonlyArray<string>;
1100
+ readonly handle: ResizeHandleJson;
1101
+ readonly origin: PointJson;
1102
+ readonly start: BoxJson;
1103
+ readonly box: BoxJson;
1104
+ readonly guides: ReadonlyArray<SnapGuideJson>;
1105
+ /**
1106
+ * The transaction id reserved for the drop when the gesture started
1107
+ * (`seq` moves past it then), published as the activity's `transaction`.
1108
+ */
1109
+ readonly transaction: string;
1110
+ } | {
1111
+ readonly _tag: "Creating";
1112
+ readonly draft: DraftKindJson;
1113
+ readonly origin: PointJson;
1114
+ readonly box: BoxJson;
1115
+ readonly dragged: boolean;
1116
+ readonly guides: ReadonlyArray<SnapGuideJson>;
1117
+ } | {
1118
+ readonly _tag: "Marquee";
1119
+ readonly origin: PointJson;
1120
+ readonly point: PointJson;
1121
+ /** The selection the marquee adds to (shift) or an empty one. */
1122
+ readonly base: ReadonlyArray<string>;
1123
+ } | {
1124
+ readonly _tag: "Connecting";
1125
+ readonly origin: PointJson;
1126
+ readonly arrow: string | null;
1127
+ readonly from: AnchorJson;
1128
+ readonly to: AnchorJson;
1129
+ readonly moving: "from" | "to";
1130
+ } | {
1131
+ readonly _tag: "Inking";
1132
+ readonly points: ReadonlyArray<PointJson>;
1133
+ } | {
1134
+ readonly _tag: "Erasing";
1135
+ readonly ids: ReadonlyArray<string>;
1136
+ /** Recent pointer points, newest last. */
1137
+ readonly trail: ReadonlyArray<PointJson>;
1138
+ } | {
1139
+ readonly _tag: "EditingText";
1140
+ readonly id: string;
1141
+ readonly draft: string;
1142
+ readonly original: string;
1143
+ /** The transaction that created the shape for this edit, if any. */
1144
+ readonly created: string | null;
1145
+ } | {
1146
+ readonly _tag: "Panning";
1147
+ readonly origin: PointJson;
1148
+ readonly start: ViewportJson;
1149
+ } | {
1150
+ /**
1151
+ * Pointer down with the comment or timestamp tool. Releasing within the
1152
+ * drag threshold emits `Place`; moving past it drops the press.
1153
+ */
1154
+ readonly _tag: "Placing";
1155
+ readonly tool: "comment" | "timestamp";
1156
+ readonly origin: PointJson;
1157
+ };
1158
+ /**
1159
+ * Screen pixels along each edge that the host's chrome covers. Fitting and
1160
+ * zoom steps use the area inside them, so content is not centred under a
1161
+ * toolbar.
1162
+ */
1163
+ export interface InsetJson {
1164
+ readonly top: number;
1165
+ readonly right: number;
1166
+ readonly bottom: number;
1167
+ readonly left: number;
1168
+ }
1169
+ /** Style for new shapes and the style bar; null keeps each kind's default. */
1170
+ export interface ToolStyleJson {
1171
+ readonly color: ColorJson | null;
1172
+ readonly size: SizeJson | null;
1173
+ readonly align: TextAlignJson | null;
1174
+ readonly fill: boolean | null;
1175
+ readonly dash: DashJson | null;
1176
+ readonly brush: BrushJson | null;
1177
+ readonly start: HeadJson | null;
1178
+ readonly end: HeadJson | null;
1179
+ readonly route: RouteJson | null;
1180
+ }
1181
+ /**
1182
+ * An undo or redo entry: a transaction this editor sent, and the entry it
1183
+ * took from the other stack (put back if the host rejects the transaction).
1184
+ */
1185
+ export interface HistoryEntryJson {
1186
+ readonly transaction: string;
1187
+ readonly restores: string | null;
1188
+ }
1189
+ export interface EditorStateJson {
1190
+ /** Prefix of the transaction ids this editor sends: `<session>-<seq>`. */
1191
+ readonly session: string;
1192
+ readonly seq: number;
1193
+ readonly tool: ToolJson;
1194
+ /**
1195
+ * While Space is held, the tool to go back to when it is released; `tool`
1196
+ * is `hand` meanwhile. Otherwise null.
1197
+ */
1198
+ readonly spaceTool: ToolJson | null;
1199
+ readonly style: ToolStyleJson;
1200
+ /** Grid spacing to snap to, or null for no grid. */
1201
+ readonly grid: number | null;
1202
+ /** Only Select and Hand work, and nothing is sent but presence, viewport and clipboard. */
1203
+ readonly readOnly: boolean;
1204
+ readonly selection: ReadonlyArray<string>;
1205
+ readonly view: ViewportJson;
1206
+ /** Chrome over the view's edges; zeros until the host sends `Inset`. */
1207
+ readonly inset: InsetJson;
1208
+ /**
1209
+ * The actor whose view this one tracks: the host moves the view with
1210
+ * `SetView`, and any pan or zoom by the viewer sets it back to null, as
1211
+ * does a `Sync` with no connection of that actor in presence. With several
1212
+ * connections, the leader's last entry in presence is followed.
1213
+ */
1214
+ readonly following: string | null;
1215
+ readonly pointer: PointJson | null;
1216
+ readonly pointerKind: PointerKindJson;
1217
+ readonly modifiers: ModifiersJson;
1218
+ readonly hover: HitJson;
1219
+ readonly undo: ReadonlyArray<HistoryEntryJson>;
1220
+ readonly redo: ReadonlyArray<HistoryEntryJson>;
1221
+ readonly mode: EditorModeJson;
1222
+ /** Uploads this editor has begun and not ended, shown to others in presence. */
1223
+ readonly uploads: ReadonlyArray<UploadJson>;
1224
+ /** The viewer's cursor chat, published in presence; see `PresenceJson.chat`. */
1225
+ readonly chat: string | null;
1226
+ }
1227
+ /** A file being uploaded. Natural size in pixels, null until known. */
1228
+ export interface PendingImageJson {
1229
+ readonly id: string;
1230
+ readonly naturalW: number | null;
1231
+ readonly naturalH: number | null;
1232
+ readonly name: string | null;
1233
+ }
1234
+ /** An uploaded image to insert. */
1235
+ export interface NewImageJson {
1236
+ readonly asset: string;
1237
+ readonly alt: string;
1238
+ /** Natural size in pixels: the aspect, and the largest size it is inserted at. */
1239
+ readonly naturalW: number;
1240
+ readonly naturalH: number;
1241
+ /** The upload it replaces: the image takes that placeholder's place. */
1242
+ readonly upload: string | null;
1243
+ }
1244
+ export type EditorInputJson = {
1245
+ readonly _tag: "PointerDown";
1246
+ readonly point: PointJson;
1247
+ readonly button: "primary" | "middle" | "secondary";
1248
+ readonly pointer: PointerKindJson;
1249
+ /** 0 to 1; 0.5 for devices without pressure. */
1250
+ readonly pressure: number;
1251
+ readonly modifiers: ModifiersJson;
1252
+ } | {
1253
+ readonly _tag: "PointerMove";
1254
+ readonly point: PointJson;
1255
+ readonly pointer: PointerKindJson;
1256
+ readonly pressure: number;
1257
+ /** Coalesced samples since the last move, oldest first, before `point`. */
1258
+ readonly samples: ReadonlyArray<PointJson>;
1259
+ readonly modifiers: ModifiersJson;
1260
+ } | {
1261
+ readonly _tag: "PointerUp";
1262
+ readonly point: PointJson;
1263
+ readonly pointer: PointerKindJson;
1264
+ readonly modifiers: ModifiersJson;
1265
+ } | {
1266
+ readonly _tag: "PointerLeave";
1267
+ } | {
1268
+ readonly _tag: "PointerCancel";
1269
+ } | {
1270
+ readonly _tag: "DoubleClick";
1271
+ readonly point: PointJson;
1272
+ } | {
1273
+ readonly _tag: "KeyDown";
1274
+ readonly key: string;
1275
+ readonly modifiers: ModifiersJson;
1276
+ } | {
1277
+ readonly _tag: "KeyUp";
1278
+ readonly key: string;
1279
+ readonly modifiers: ModifiersJson;
1280
+ } | {
1281
+ /** Modifier keys changed without a key event the editor saw. */
1282
+ readonly _tag: "Modifiers";
1283
+ readonly modifiers: ModifiersJson;
1284
+ } | {
1285
+ /** A wheel event, deltas in screen pixels: pans, or zooms with meta (trackpad pinch sends meta). */
1286
+ readonly _tag: "Wheel";
1287
+ readonly point: PointJson;
1288
+ readonly dx: number;
1289
+ readonly dy: number;
1290
+ readonly modifiers: ModifiersJson;
1291
+ } | {
1292
+ /** Zoom by `factor`, keeping the board point under `point` in place (touch pinch). */
1293
+ readonly _tag: "Zoom";
1294
+ readonly point: PointJson;
1295
+ readonly factor: number;
1296
+ } | {
1297
+ /** Pan by screen pixels. */
1298
+ readonly _tag: "Pan";
1299
+ readonly dx: number;
1300
+ readonly dy: number;
1301
+ } | {
1302
+ readonly _tag: "ZoomTo";
1303
+ readonly to: "in" | "out" | "reset" | "fit" | "selection";
1304
+ } | {
1305
+ /** The host's view changed (resize, follow); taken as is. */
1306
+ readonly _tag: "SetView";
1307
+ readonly view: ViewportJson;
1308
+ } | {
1309
+ readonly _tag: "Blur";
1310
+ } | {
1311
+ /** The text editor's current value while editing text. */
1312
+ readonly _tag: "Text";
1313
+ readonly value: string;
1314
+ } | {
1315
+ readonly _tag: "Action";
1316
+ readonly action: ActionIdJson;
1317
+ } | {
1318
+ /** Sets the tool style and restyles the selection. */
1319
+ readonly _tag: "Style";
1320
+ readonly style: ToolStyleJson;
1321
+ } | {
1322
+ readonly _tag: "Select";
1323
+ readonly ids: ReadonlyArray<string>;
1324
+ } | {
1325
+ readonly _tag: "Copy";
1326
+ } | {
1327
+ readonly _tag: "Cut";
1328
+ } | {
1329
+ readonly _tag: "Paste";
1330
+ readonly clipboard: ClipboardJson;
1331
+ /** Where the pasted shapes' center goes; null pastes in place, offset if the originals are there. */
1332
+ readonly at: PointJson | null;
1333
+ /** Fresh ids, one per clipboard shape; empty to generate them. */
1334
+ readonly ids: ReadonlyArray<string>;
1335
+ } | {
1336
+ readonly _tag: "PasteText";
1337
+ readonly text: string;
1338
+ readonly at: PointJson | null;
1339
+ } | {
1340
+ /** Commands from the host (a toolbar, an agent panel) sent as this editor's transaction. */
1341
+ readonly _tag: "Run";
1342
+ readonly commands: ReadonlyArray<CommandJson>;
1343
+ readonly reason: string | null;
1344
+ } | {
1345
+ /** The store refused a transaction this editor sent; history and mode roll back. */
1346
+ readonly _tag: "Rejected";
1347
+ readonly transaction: string;
1348
+ } | {
1349
+ readonly _tag: "ReadOnly";
1350
+ readonly readOnly: boolean;
1351
+ } | {
1352
+ /** Track another actor's view, or stop with null. */
1353
+ readonly _tag: "Follow";
1354
+ readonly actor: string | null;
1355
+ } | {
1356
+ /** The host's chrome moved; fits and zoom steps use the area inside it. */
1357
+ readonly _tag: "Inset";
1358
+ readonly inset: InsetJson;
1359
+ } | {
1360
+ /**
1361
+ * The board or presence changed under the editor: drops selection of
1362
+ * shapes that are gone, stops what another connection now holds,
1363
+ * follows the leader's new viewport, and stops following (with an
1364
+ * announcement) when no connection of the leader is left in presence.
1365
+ */
1366
+ readonly _tag: "Sync";
1367
+ } | {
1368
+ /**
1369
+ * Shows placeholders for files being uploaded, laid out around `at`
1370
+ * like `InsertImage`. Nothing is stored.
1371
+ */
1372
+ readonly _tag: "BeginUpload";
1373
+ readonly at: PointJson;
1374
+ readonly uploads: ReadonlyArray<PendingImageJson>;
1375
+ } | {
1376
+ /** Removes a placeholder: the upload failed or was cancelled. */
1377
+ readonly _tag: "EndUpload";
1378
+ readonly id: string;
1379
+ } | {
1380
+ /**
1381
+ * Creates images in one transaction and selects them. Each keeps its
1382
+ * aspect: at most `DEFAULTS.image` on its long side and never larger
1383
+ * than its natural size, unless its short side would be under the
1384
+ * minimum size, which it is scaled up to;
1385
+ * one with an `upload` takes its placeholder's place and ends it, the
1386
+ * rest go in rows centred on `at`, without overlapping.
1387
+ */
1388
+ readonly _tag: "InsertImage";
1389
+ readonly at: PointJson;
1390
+ readonly images: ReadonlyArray<NewImageJson>;
1391
+ } | {
1392
+ /**
1393
+ * Opens, changes or closes (null) the viewer's cursor chat, which the
1394
+ * editor publishes in presence. Text past `LIMITS.chat` (200) code units
1395
+ * is cut at the last whole code point that fits; text with a lone
1396
+ * surrogate, or over `LIMITS.text`, is refused as `Invalid`.
1397
+ */
1398
+ readonly _tag: "Chat";
1399
+ readonly text: string | null;
1400
+ };
1401
+ /**
1402
+ * What the host publishes for its viewer, with its actor, name, kind and
1403
+ * connection (the editor's `session`), as that connection's `PresenceJson`.
1404
+ */
1405
+ export interface EditorPresenceJson {
1406
+ readonly cursor: CursorJson | null;
1407
+ readonly selection: ReadonlyArray<string>;
1408
+ /** The board area the viewer sees, so others can follow it and point to it. */
1409
+ readonly viewport: BoxJson;
1410
+ /** The actor the viewer follows, so the leader and others can see it. */
1411
+ readonly following: string | null;
1412
+ readonly activity: ActivityJson;
1413
+ readonly claims: ReadonlyArray<string>;
1414
+ readonly uploads: ReadonlyArray<UploadJson>;
1415
+ readonly chat: string | null;
1416
+ }
1417
+ /** Copy and cut give a structured payload and plain text. */
1418
+ export interface ClipboardDataJson {
1419
+ readonly clipboard: ClipboardJson;
1420
+ readonly text: string;
1421
+ }
1422
+ export type EditorActionJson = {
1423
+ /** Plan and apply this transaction before sending the next input. */
1424
+ readonly _tag: "Apply";
1425
+ readonly transaction: TransactionJson;
1426
+ } | {
1427
+ readonly _tag: "Presence";
1428
+ readonly presence: EditorPresenceJson;
1429
+ } | {
1430
+ /** `animate`: glide to the view (zoom steps, fit); otherwise jump (wheel, pinch, pan). */
1431
+ readonly _tag: "Viewport";
1432
+ readonly view: ViewportJson;
1433
+ readonly animate: boolean;
1434
+ } | {
1435
+ readonly _tag: "Clipboard";
1436
+ readonly data: ClipboardDataJson;
1437
+ } | {
1438
+ /** A sentence for a screen-reader live region. */
1439
+ readonly _tag: "Announce";
1440
+ readonly text: string;
1441
+ } | {
1442
+ /**
1443
+ * Text typed into a shape that someone else started editing first: it
1444
+ * was not saved. Offer it back, for example to copy.
1445
+ */
1446
+ readonly _tag: "Unsaved";
1447
+ readonly id: string;
1448
+ readonly text: string;
1449
+ } | {
1450
+ /**
1451
+ * A click (press and release within the drag threshold) with the
1452
+ * comment or timestamp tool. `at` is the board point pressed; `shape`
1453
+ * the topmost shape there, or null. The kernel stores nothing: the host
1454
+ * opens a comment there, or sends `Run` with a `Create` of a
1455
+ * `Timestamp` whose `at` is its own "now".
1456
+ */
1457
+ readonly _tag: "Place";
1458
+ readonly tool: "comment" | "timestamp";
1459
+ readonly at: PointJson;
1460
+ readonly shape: string | null;
1461
+ };
1462
+ /** CSS cursor to show. `pen` and `eraser` are custom cursors the host provides. */
1463
+ export type PointerStyleJson = "default" | "pointer" | "move" | "grab" | "grabbing" | "crosshair" | "text" | "ew-resize" | "ns-resize" | "nwse-resize" | "nesw-resize" | "not-allowed" | "pen" | "eraser";
1464
+ export interface EditorStepJson {
1465
+ readonly state: EditorStateJson;
1466
+ readonly actions: ReadonlyArray<EditorActionJson>;
1467
+ /** Whether the editor used the input; the host calls `preventDefault` only then. */
1468
+ readonly handled: boolean;
1469
+ readonly cursor: PointerStyleJson;
1470
+ }
1471
+ /**
1472
+ * Options for `toSvg`: the one input that is not JSON. A picture of a board
1473
+ * is drawn for one reader, so the caller decides how an instant reads.
1474
+ */
1475
+ export interface SvgOptions {
1476
+ /**
1477
+ * Formats a timestamp's instant (integer epoch milliseconds) as its label,
1478
+ * for example in the reader's time zone. Default: ISO 8601 in UTC
1479
+ * (`2026-11-20T15:04:00.000Z`). A formatter that throws or returns a
1480
+ * non-string falls back to the default.
1481
+ */
1482
+ readonly formatInstant?: (epochMs: number) => string;
1483
+ }
1484
+ /** The kernel's calls are plain functions; they can be destructured. */
1485
+ export interface Kernel {
1486
+ /**
1487
+ * Plans a transaction by `actor` through `connection`: the presence
1488
+ * connection it came from, or null for none (a server job, an agent
1489
+ * without presence). Fails with `Claimed` on a shape that some entry in
1490
+ * `presence` claims, unless this connection holds it: when several
1491
+ * connections claim a shape, the one first in (actor, connection) order
1492
+ * holds it, comparing each by UTF-16 code units.
1493
+ */
1494
+ readonly plan: (board: BoardJson, transaction: TransactionJson, actor: string, presence: ReadonlyArray<PresenceJson>, connection: string | null) => Outcome<PlanJson>;
1495
+ /** Applies a plan to an in-memory board. */
1496
+ readonly apply: (board: BoardJson, plan: PlanJson) => Outcome<BoardJson>;
1497
+ /**
1498
+ * What to draw: shapes in the viewport plus a margin, pending proposals as
1499
+ * ghosts, others' presence and, given the viewer's editor state, its own
1500
+ * gesture previews, hover, selection, handles and text editor.
1501
+ */
1502
+ readonly scene: (board: BoardJson, view: ViewportJson, presence: ReadonlyArray<PresenceJson>, editor: EditorStateJson | null) => Outcome<SceneJson>;
1503
+ readonly hitTest: (board: BoardJson, probe: HitProbeJson) => Outcome<HitJson>;
1504
+ /** A text description of the board for agents. */
1505
+ readonly outline: (board: BoardJson, presence: ReadonlyArray<PresenceJson>) => Outcome<string>;
1506
+ /**
1507
+ * A standalone SVG document of a scene in one theme. `assets` maps an
1508
+ * image's asset to its URL (`https:`, `http:`, `blob:` or a raster
1509
+ * `data:image/`); an image without one draws as a placeholder.
1510
+ * `options.formatInstant` labels timestamps (default: ISO 8601 in UTC).
1511
+ */
1512
+ readonly toSvg: (scene: SceneJson, palette: PaletteJson, assets?: Readonly<Record<string, string>>, options?: SvgOptions) => Outcome<string>;
1513
+ /**
1514
+ * One input. `presence` is everyone's, as `plan` takes it. This editor is
1515
+ * the connection (`view.viewer`, `state.session`); its own entry is
1516
+ * skipped, and the viewer's other connections count as others: the editor
1517
+ * does not start or send changes to shapes another connection holds, and
1518
+ * while following it keeps the view on the leader's viewport. Call it with
1519
+ * `Sync` whenever presence changes.
1520
+ */
1521
+ readonly editor: (state: EditorStateJson, board: BoardJson, input: EditorInputJson, presence: ReadonlyArray<PresenceJson>) => Outcome<EditorStepJson>;
1522
+ /** Every action with its label, shortcuts and whether it is enabled now. */
1523
+ readonly actions: (state: EditorStateJson, board: BoardJson, presence: ReadonlyArray<PresenceJson>) => Outcome<ReadonlyArray<ActionJson>>;
1524
+ /** Shared style values across shapes and what can be done with them. */
1525
+ readonly inspect: (board: BoardJson, ids: ReadonlyArray<string>) => Outcome<InspectionJson>;
1526
+ /** A short accessible description of one shape. */
1527
+ readonly describe: (board: BoardJson, id: string) => Outcome<string>;
1528
+ /** Pending proposals, oldest first. */
1529
+ readonly proposals: (board: BoardJson) => Outcome<ReadonlyArray<ProposalJson>>;
1530
+ /** A fresh editor state for `session`, looking at `view`. */
1531
+ readonly initialEditor: (session: string, view: ViewportJson) => Outcome<EditorStateJson>;
1532
+ }
1533
+ export {};