@enhance-eng/enhance 0.1.7 → 0.1.13
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/{cli-output-identity.lib-BSUBcRJm.mjs → cli-output-identity.lib-DAJiBMGX.mjs} +589 -74
- package/dist/main.mjs +265 -354
- package/dist/mcp-invocation.adapter-BG-WBGEr.mjs +119 -0
- package/dist/mcp-main.mjs +36 -20
- package/dist/{mcp-server.adapter-lxpsuDlU.mjs → mcp-server.adapter-BgUZCdl4.mjs} +23 -12
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-EvvklGSw.mjs → mutation-key.adapter-BffKsNR-.mjs} +20 -7
- package/dist/remote-mcp-main.mjs +5 -5
- package/package.json +1 -1
- package/dist/mcp-invocation.adapter-Bn41hcLB.mjs +0 -64
|
@@ -209,6 +209,292 @@ const markCanvasViewedOutputSchema = z.object({ lastViewedAt: z.iso.datetime().n
|
|
|
209
209
|
const restoreCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
210
210
|
const restoreCanvasOutputSchema = z.object({ canvasId: z.uuid() });
|
|
211
211
|
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region ../../packages/contract/src/canvas/canvas-css-values.lib.ts
|
|
214
|
+
const UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
|
|
215
|
+
"aspect-ratio",
|
|
216
|
+
"-webkit-line-clamp",
|
|
217
|
+
"line-clamp",
|
|
218
|
+
"flex-grow",
|
|
219
|
+
"flex-shrink",
|
|
220
|
+
"font-weight",
|
|
221
|
+
"opacity",
|
|
222
|
+
"order",
|
|
223
|
+
"z-index",
|
|
224
|
+
"grid-area",
|
|
225
|
+
"grid-row",
|
|
226
|
+
"grid-column",
|
|
227
|
+
"grid-row-start",
|
|
228
|
+
"grid-row-end",
|
|
229
|
+
"grid-column-start",
|
|
230
|
+
"grid-column-end"
|
|
231
|
+
]);
|
|
232
|
+
const canvasCssValue = (property, value) => typeof value === "number" && !UNITLESS_PROPERTIES.has(property.toLowerCase()) ? `${String(value)}px` : String(value);
|
|
233
|
+
const SIDES$1 = [
|
|
234
|
+
"top",
|
|
235
|
+
"right",
|
|
236
|
+
"bottom",
|
|
237
|
+
"left"
|
|
238
|
+
];
|
|
239
|
+
const LEFT_SIDE_INDEX = 3;
|
|
240
|
+
const GRID_TEMPLATE_PROPERTIES = [
|
|
241
|
+
"grid-template-rows",
|
|
242
|
+
"grid-template-columns",
|
|
243
|
+
"grid-template-areas"
|
|
244
|
+
];
|
|
245
|
+
const SHORTHANDS = {
|
|
246
|
+
gap: ["row-gap", "column-gap"],
|
|
247
|
+
padding: SIDES$1.map((side) => `padding-${side}`),
|
|
248
|
+
margin: SIDES$1.map((side) => `margin-${side}`),
|
|
249
|
+
flex: [
|
|
250
|
+
"flex-grow",
|
|
251
|
+
"flex-shrink",
|
|
252
|
+
"flex-basis"
|
|
253
|
+
],
|
|
254
|
+
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
255
|
+
"place-content": ["align-content", "justify-content"],
|
|
256
|
+
"place-items": ["align-items", "justify-items"],
|
|
257
|
+
"place-self": ["align-self", "justify-self"],
|
|
258
|
+
"grid-template": GRID_TEMPLATE_PROPERTIES,
|
|
259
|
+
grid: [
|
|
260
|
+
...GRID_TEMPLATE_PROPERTIES,
|
|
261
|
+
"grid-auto-rows",
|
|
262
|
+
"grid-auto-columns",
|
|
263
|
+
"grid-auto-flow"
|
|
264
|
+
],
|
|
265
|
+
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
266
|
+
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
267
|
+
"grid-area": [
|
|
268
|
+
"grid-row-start",
|
|
269
|
+
"grid-column-start",
|
|
270
|
+
"grid-row-end",
|
|
271
|
+
"grid-column-end"
|
|
272
|
+
]
|
|
273
|
+
};
|
|
274
|
+
/** Related declarations stay authored; a longhand edit must not discard the rest of a shorthand. */
|
|
275
|
+
const canvasCssPropertyScope = (property) => SHORTHANDS[property.toLowerCase()] ?? [property.toLowerCase()];
|
|
276
|
+
const componentStateAfter = (state, character) => {
|
|
277
|
+
if (state.isEscaped) return {
|
|
278
|
+
...state,
|
|
279
|
+
isEscaped: false
|
|
280
|
+
};
|
|
281
|
+
if (character === "\\") return {
|
|
282
|
+
...state,
|
|
283
|
+
isEscaped: true
|
|
284
|
+
};
|
|
285
|
+
if (state.quote !== "") return {
|
|
286
|
+
...state,
|
|
287
|
+
quote: state.quote === character ? "" : state.quote
|
|
288
|
+
};
|
|
289
|
+
if (["\"", "'"].includes(character)) return {
|
|
290
|
+
...state,
|
|
291
|
+
quote: character
|
|
292
|
+
};
|
|
293
|
+
const delta = [
|
|
294
|
+
"(",
|
|
295
|
+
"[",
|
|
296
|
+
"{"
|
|
297
|
+
].includes(character) ? 1 : [
|
|
298
|
+
")",
|
|
299
|
+
"]",
|
|
300
|
+
"}"
|
|
301
|
+
].includes(character) ? -1 : 0;
|
|
302
|
+
return {
|
|
303
|
+
...state,
|
|
304
|
+
depth: state.depth + delta
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
/** Split only at CSS component boundaries, keeping functions, line names and strings intact. */
|
|
308
|
+
const canvasCssTokens = (value, separator = "space") => {
|
|
309
|
+
const tokens = [];
|
|
310
|
+
let token = "";
|
|
311
|
+
let state = {
|
|
312
|
+
depth: 0,
|
|
313
|
+
quote: "",
|
|
314
|
+
isEscaped: false
|
|
315
|
+
};
|
|
316
|
+
for (const character of value) {
|
|
317
|
+
const canSplit = state.depth === 0 && state.quote === "" && !state.isEscaped;
|
|
318
|
+
state = componentStateAfter(state, character);
|
|
319
|
+
if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
|
|
320
|
+
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
321
|
+
token = "";
|
|
322
|
+
} else token += character;
|
|
323
|
+
}
|
|
324
|
+
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
325
|
+
return tokens;
|
|
326
|
+
};
|
|
327
|
+
const omittedGridLine = (value) => /^(?:--|-?[_a-z\u{80}-\u{FFFF}])[-\w\u{80}-\u{FFFF}]*$/iu.test(value) && !/^(?:auto|span|initial|unset)$/iu.test(value) ? value : "auto";
|
|
328
|
+
const gridPlacementValue = (property, value, index) => {
|
|
329
|
+
const parts = canvasCssTokens(value, "/");
|
|
330
|
+
const first = parts[0] ?? value;
|
|
331
|
+
if (property !== "grid-area") return parts[index] ?? omittedGridLine(first);
|
|
332
|
+
const column = parts[1] ?? omittedGridLine(first);
|
|
333
|
+
return [
|
|
334
|
+
first,
|
|
335
|
+
column,
|
|
336
|
+
parts[2] ?? omittedGridLine(first),
|
|
337
|
+
parts[3] ?? omittedGridLine(column)
|
|
338
|
+
][index] ?? value;
|
|
339
|
+
};
|
|
340
|
+
const implicitGridValues = (row, column, hasAutoRows) => {
|
|
341
|
+
const tokens = canvasCssTokens(hasAutoRows ? row : column);
|
|
342
|
+
const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
|
|
343
|
+
const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
|
|
344
|
+
return [
|
|
345
|
+
hasAutoRows ? "none" : row,
|
|
346
|
+
hasAutoRows ? column : "none",
|
|
347
|
+
"none",
|
|
348
|
+
hasAutoRows && size !== "" ? size : "auto",
|
|
349
|
+
!hasAutoRows && size !== "" ? size : "auto",
|
|
350
|
+
flow
|
|
351
|
+
];
|
|
352
|
+
};
|
|
353
|
+
const gridTemplateValue = (property, value, index) => {
|
|
354
|
+
if (/^(?:none|initial|unset)$/iu.test(value)) return [
|
|
355
|
+
"none",
|
|
356
|
+
"none",
|
|
357
|
+
"none",
|
|
358
|
+
"auto",
|
|
359
|
+
"auto",
|
|
360
|
+
"row"
|
|
361
|
+
][index] ?? value;
|
|
362
|
+
const parts = canvasCssTokens(value, "/");
|
|
363
|
+
const row = parts[0] ?? value;
|
|
364
|
+
const column = parts[1];
|
|
365
|
+
if (row === "" || column === "" || parts.length > 2) return value;
|
|
366
|
+
const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
|
|
367
|
+
const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
|
|
368
|
+
if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
|
|
369
|
+
if (hasAutoRows || hasAutoColumns) return value;
|
|
370
|
+
const hasAreas = /["']/u.test(row);
|
|
371
|
+
if (column === void 0 && !hasAreas) return value;
|
|
372
|
+
return [
|
|
373
|
+
hasAreas ? value : row,
|
|
374
|
+
column ?? "none",
|
|
375
|
+
hasAreas ? row : "none",
|
|
376
|
+
"auto",
|
|
377
|
+
"auto",
|
|
378
|
+
"row"
|
|
379
|
+
][index] ?? value;
|
|
380
|
+
};
|
|
381
|
+
const flexValues = (tokens) => {
|
|
382
|
+
const numbers = [];
|
|
383
|
+
let basis = "0%";
|
|
384
|
+
for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
|
|
385
|
+
else basis = token;
|
|
386
|
+
return [
|
|
387
|
+
numbers[0] ?? "1",
|
|
388
|
+
numbers[1] ?? "1",
|
|
389
|
+
basis
|
|
390
|
+
];
|
|
391
|
+
};
|
|
392
|
+
const canvasCssShorthandValue = (property, value, index) => {
|
|
393
|
+
if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
|
|
394
|
+
if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
|
|
395
|
+
if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
|
|
396
|
+
const tokens = canvasCssTokens(value);
|
|
397
|
+
if (property === "flex-flow") return index === 0 ? tokens.find((token) => /^(?:row|column)(?:-reverse)?$/u.test(token)) ?? "row" : tokens.find((token) => /^(?:nowrap|wrap|wrap-reverse)$/u.test(token)) ?? "nowrap";
|
|
398
|
+
if (property === "flex") {
|
|
399
|
+
if (value === "none") return [
|
|
400
|
+
"0",
|
|
401
|
+
"0",
|
|
402
|
+
"auto"
|
|
403
|
+
][index] ?? value;
|
|
404
|
+
if (value === "initial") return [
|
|
405
|
+
"0",
|
|
406
|
+
"1",
|
|
407
|
+
"auto"
|
|
408
|
+
][index] ?? value;
|
|
409
|
+
return flexValues(tokens)[index] ?? value;
|
|
410
|
+
}
|
|
411
|
+
return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region ../../packages/contract/src/canvas/canvas-authored-css.lib.ts
|
|
416
|
+
const canvasAdditionalStyleDeclarations = (node) => {
|
|
417
|
+
if (node.additionalStyles === void 0) return {};
|
|
418
|
+
return Object.fromEntries(node.additionalStyles.declarations.filter((declaration) => declaration.enabled).map((declaration) => [declaration.property, declaration.value]));
|
|
419
|
+
};
|
|
420
|
+
/** Additional-style controls exclusively own every property they expose, including when off. */
|
|
421
|
+
const canvasAuthoredStyleDeclarations = (node) => {
|
|
422
|
+
const controlledProperties = new Set(node.additionalStyles?.declarations.map((declaration) => declaration.property.toLowerCase()));
|
|
423
|
+
return {
|
|
424
|
+
...Object.fromEntries(Object.entries(node.styles).filter(([property]) => !controlledProperties.has(property.toLowerCase()))),
|
|
425
|
+
...canvasAdditionalStyleDeclarations(node)
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
const hasCanvasCssPriority = (value) => /!important\s*$/iu.test(String(value));
|
|
429
|
+
const cssValue = (value, shouldPreserveCase) => {
|
|
430
|
+
const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
|
|
431
|
+
return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
|
|
432
|
+
};
|
|
433
|
+
/** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
|
|
434
|
+
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
435
|
+
let result = null;
|
|
436
|
+
let isImportant = false;
|
|
437
|
+
const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
|
|
438
|
+
for (const [key, raw] of declarations) {
|
|
439
|
+
const scope = canvasCssPropertyScope(key);
|
|
440
|
+
const index = scope.indexOf(property);
|
|
441
|
+
if (index === -1) continue;
|
|
442
|
+
const isPriority = hasCanvasCssPriority(raw);
|
|
443
|
+
if (isImportant && !isPriority) continue;
|
|
444
|
+
const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
|
|
445
|
+
result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
|
|
446
|
+
isImportant = isPriority;
|
|
447
|
+
}
|
|
448
|
+
return result ?? void 0;
|
|
449
|
+
};
|
|
450
|
+
/** Named controls override only their own longhand, even beside an important shorthand. */
|
|
451
|
+
const canvasLayoutPriorityDeclarations = (node, declarations) => {
|
|
452
|
+
const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
|
|
453
|
+
return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
|
|
454
|
+
};
|
|
455
|
+
const canvasWritingModeOf = (node, document) => {
|
|
456
|
+
const visited = /* @__PURE__ */ new Set();
|
|
457
|
+
let current = node;
|
|
458
|
+
while (current !== void 0 && !visited.has(current.id)) {
|
|
459
|
+
visited.add(current.id);
|
|
460
|
+
const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
|
|
461
|
+
if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
|
|
462
|
+
if (document === void 0) break;
|
|
463
|
+
const parentId = document.relationships[current.id]?.parentId;
|
|
464
|
+
if (parentId === void 0) break;
|
|
465
|
+
current = document.nodes[parentId];
|
|
466
|
+
}
|
|
467
|
+
return "horizontal-tb";
|
|
468
|
+
};
|
|
469
|
+
const canvasAxisStyleProperties = (node, axis, document) => {
|
|
470
|
+
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
471
|
+
return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
|
|
472
|
+
};
|
|
473
|
+
/** Authored display wins over legacy presets; Grid has no Flex main axis. */
|
|
474
|
+
const canvasLayoutFlowOf = (node) => {
|
|
475
|
+
if (node === void 0) return "freeform";
|
|
476
|
+
const display = canvasAuthoredLayoutValueOf(node, "display");
|
|
477
|
+
if (display !== void 0) {
|
|
478
|
+
if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
|
|
479
|
+
if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
|
|
480
|
+
return "freeform";
|
|
481
|
+
}
|
|
482
|
+
const container = node.layout?.container;
|
|
483
|
+
if (container === void 0) return "freeform";
|
|
484
|
+
return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
|
|
485
|
+
};
|
|
486
|
+
/** Read a Flex main axis in its inherited writing mode without persisting a preset. */
|
|
487
|
+
const canvasLayoutMainAxisOf = (node, document) => {
|
|
488
|
+
if (node === void 0) return void 0;
|
|
489
|
+
if (canvasLayoutFlowOf(node) !== "flex") return void 0;
|
|
490
|
+
const container = node.layout?.container;
|
|
491
|
+
const css = (property) => canvasAuthoredLayoutValueOf(node, property);
|
|
492
|
+
const direction = container?.direction ?? css("flex-direction") ?? "row";
|
|
493
|
+
if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
|
|
494
|
+
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
495
|
+
return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
|
|
496
|
+
};
|
|
497
|
+
|
|
212
498
|
//#endregion
|
|
213
499
|
//#region ../../packages/contract/src/canvas/canvas-limits.schema.ts
|
|
214
500
|
const MAX_CANVAS_VALUE = 1e5;
|
|
@@ -231,15 +517,12 @@ const canvasSizeIntentSchema = z.discriminatedUnion("mode", [
|
|
|
231
517
|
z.object({
|
|
232
518
|
mode: z.literal("fixed"),
|
|
233
519
|
value: nonNegativeCanvasNumberSchema
|
|
234
|
-
}),
|
|
235
|
-
canvasSizeIntentBoundsSchema.extend({
|
|
236
|
-
mode: z.literal("hug"),
|
|
237
|
-
basis: nonNegativeCanvasNumberSchema.optional()
|
|
238
|
-
}),
|
|
520
|
+
}).strict(),
|
|
521
|
+
canvasSizeIntentBoundsSchema.extend({ mode: z.literal("hug") }).strict(),
|
|
239
522
|
canvasSizeIntentBoundsSchema.extend({
|
|
240
523
|
mode: z.literal("fill"),
|
|
241
524
|
offset: boundedCanvasNumberSchema.optional()
|
|
242
|
-
})
|
|
525
|
+
}).strict()
|
|
243
526
|
]);
|
|
244
527
|
const canvasFlexPaddingSchema = z.object({
|
|
245
528
|
top: nonNegativeCanvasNumberSchema,
|
|
@@ -254,16 +537,6 @@ const canvasFlexMarginSchema = z.object({
|
|
|
254
537
|
bottom: canvasFlexMarginValueSchema,
|
|
255
538
|
left: canvasFlexMarginValueSchema
|
|
256
539
|
});
|
|
257
|
-
const canvasGridTrackSchema = z.object({
|
|
258
|
-
basis: nonNegativeCanvasNumberSchema,
|
|
259
|
-
align: z.enum([
|
|
260
|
-
"start",
|
|
261
|
-
"center",
|
|
262
|
-
"end",
|
|
263
|
-
"stretch"
|
|
264
|
-
]),
|
|
265
|
-
minimum: nonNegativeCanvasNumberSchema.optional()
|
|
266
|
-
});
|
|
267
540
|
const canvasGridAutoRepeatSchema = z.object({
|
|
268
541
|
mode: z.enum(["auto-fill", "auto-fit"]),
|
|
269
542
|
minimum: z.number().positive().max(MAX_CANVAS_VALUE)
|
|
@@ -303,18 +576,17 @@ const canvasFlexLayoutSchema = z.object({
|
|
|
303
576
|
wrap: z.enum(["nowrap", "wrap"]).optional(),
|
|
304
577
|
gridColumns: z.number().int().positive().max(MAX_CANVAS_VALUE).optional(),
|
|
305
578
|
gridAutoRepeat: canvasGridAutoRepeatSchema.optional(),
|
|
306
|
-
materialized: z.boolean().optional(),
|
|
307
579
|
padding: canvasFlexPaddingSchema
|
|
308
|
-
});
|
|
580
|
+
}).strict();
|
|
309
581
|
const canvasNodeLayoutSchema = z.object({
|
|
310
|
-
rotation: boundedCanvasNumberSchema,
|
|
582
|
+
rotation: boundedCanvasNumberSchema.optional(),
|
|
311
583
|
flipHorizontal: z.boolean().optional(),
|
|
312
584
|
flipVertical: z.boolean().optional(),
|
|
313
585
|
aspectRatioLocked: z.boolean().optional(),
|
|
314
586
|
aspectRatio: z.number().positive().max(MAX_CANVAS_VALUE).optional(),
|
|
315
|
-
horizontal: canvasSizeIntentSchema,
|
|
316
|
-
vertical: canvasSizeIntentSchema,
|
|
317
|
-
position: z.enum(["flow", "absolute"]),
|
|
587
|
+
horizontal: canvasSizeIntentSchema.optional(),
|
|
588
|
+
vertical: canvasSizeIntentSchema.optional(),
|
|
589
|
+
position: z.enum(["flow", "absolute"]).optional(),
|
|
318
590
|
alignSelf: z.enum([
|
|
319
591
|
"auto",
|
|
320
592
|
"start",
|
|
@@ -331,11 +603,10 @@ const canvasNodeLayoutSchema = z.object({
|
|
|
331
603
|
]).optional(),
|
|
332
604
|
flowOffset: canvasFlowOffsetSchema.optional(),
|
|
333
605
|
order: boundedCanvasNumberSchema.int().optional(),
|
|
334
|
-
margin: canvasFlexMarginSchema.optional(),
|
|
335
|
-
gridTrack: canvasGridTrackSchema.optional(),
|
|
606
|
+
margin: canvasFlexMarginSchema.partial().optional(),
|
|
336
607
|
clipContent: z.boolean().optional(),
|
|
337
|
-
container: canvasFlexLayoutSchema.optional()
|
|
338
|
-
});
|
|
608
|
+
container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
|
|
609
|
+
}).strict();
|
|
339
610
|
|
|
340
611
|
//#endregion
|
|
341
612
|
//#region ../../packages/contract/src/canvas/canvas-presentation.schema.ts
|
|
@@ -650,6 +921,8 @@ const MAX_SCENE_NODE_ID_LENGTH = 200;
|
|
|
650
921
|
const MAX_SCENE_LABEL_LENGTH = 500;
|
|
651
922
|
const MAX_SCENE_COMPONENT_LENGTH = 100;
|
|
652
923
|
const MAX_SCENE_SORT_KEY_LENGTH = 500;
|
|
924
|
+
const CANVAS_SCENE_VERSION = 3;
|
|
925
|
+
const canvasDocumentFormatSchema = z.literal(3, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
|
|
653
926
|
const canvasSceneBoxSchema = z.object({
|
|
654
927
|
x: z.number(),
|
|
655
928
|
y: z.number(),
|
|
@@ -690,7 +963,7 @@ const canvasSceneNodeSchema = z.looseObject({
|
|
|
690
963
|
box: canvasSceneBoxSchema.optional()
|
|
691
964
|
});
|
|
692
965
|
const canvasSceneDocumentSchema = z.object({
|
|
693
|
-
version: z.literal(
|
|
966
|
+
version: z.literal(3),
|
|
694
967
|
nodes: z.record(z.string(), canvasSceneNodeSchema),
|
|
695
968
|
relationships: z.record(z.string(), z.object({
|
|
696
969
|
parentId: z.string().min(1).max(MAX_SCENE_NODE_ID_LENGTH),
|
|
@@ -698,8 +971,45 @@ const canvasSceneDocumentSchema = z.object({
|
|
|
698
971
|
})),
|
|
699
972
|
tombstones: z.record(z.string(), z.literal(true)).default({})
|
|
700
973
|
});
|
|
974
|
+
const legacyRecordSchema = z.record(z.string(), z.unknown());
|
|
975
|
+
const legacyNode = (node) => {
|
|
976
|
+
const layout = legacyRecordSchema.safeParse(node["layout"]).data;
|
|
977
|
+
if (layout === void 0) return node;
|
|
978
|
+
const next = Object.fromEntries(Object.entries(layout).filter(([key]) => key !== "gridTrack"));
|
|
979
|
+
const container = legacyRecordSchema.safeParse(next["container"]).data;
|
|
980
|
+
if (container !== void 0) next["container"] = Object.fromEntries(Object.entries(container).filter(([key]) => key !== "materialized"));
|
|
981
|
+
for (const axis of ["horizontal", "vertical"]) {
|
|
982
|
+
const intent = legacyRecordSchema.safeParse(next[axis]).data;
|
|
983
|
+
if (intent?.["mode"] === "hug") next[axis] = Object.fromEntries(Object.entries(intent).filter(([key]) => key !== "basis"));
|
|
984
|
+
}
|
|
985
|
+
return {
|
|
986
|
+
...node,
|
|
987
|
+
layout: next
|
|
988
|
+
};
|
|
989
|
+
};
|
|
990
|
+
const legacyDocument = (blob) => {
|
|
991
|
+
if (Object.keys(blob).length === 0) return emptyCanvasSceneDocument();
|
|
992
|
+
const nodes = z.record(z.string(), legacyRecordSchema).safeParse(blob["nodes"]).data;
|
|
993
|
+
if (nodes === void 0) return blob;
|
|
994
|
+
return {
|
|
995
|
+
...blob,
|
|
996
|
+
version: 3,
|
|
997
|
+
nodes: Object.fromEntries(Object.entries(nodes).map(([id, node]) => [id, legacyNode(node)]))
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
/** Known old scenes are adapted in memory; only an explicit mutation persists the new format. */
|
|
1001
|
+
const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
|
|
1002
|
+
const blob = legacyRecordSchema.safeParse(value).data;
|
|
1003
|
+
if (blob === void 0) return value;
|
|
1004
|
+
const version = blob["version"];
|
|
1005
|
+
return (/* @__PURE__ */ new Set([
|
|
1006
|
+
void 0,
|
|
1007
|
+
1,
|
|
1008
|
+
2
|
|
1009
|
+
])).has(version) ? legacyDocument(blob) : blob;
|
|
1010
|
+
}, canvasSceneDocumentSchema);
|
|
701
1011
|
const emptyCanvasSceneDocument = () => ({
|
|
702
|
-
version:
|
|
1012
|
+
version: 3,
|
|
703
1013
|
nodes: { root: {
|
|
704
1014
|
id: "root",
|
|
705
1015
|
label: "Canvas",
|
|
@@ -744,9 +1054,10 @@ const canvasConversionReportSchema = z.object({
|
|
|
744
1054
|
layoutContainerCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_NODES).optional(),
|
|
745
1055
|
removedLeafNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
|
|
746
1056
|
retainedSemanticOwnerNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
|
|
747
|
-
truncatedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
|
|
1057
|
+
truncatedNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES * 2).optional(),
|
|
1058
|
+
addedLayoutNodeCount: z.number().int().nonnegative().max(MAX_CANVAS_CONVERSION_SOURCE_NODES).optional(),
|
|
748
1059
|
issues: z.array(canvasConversionIssueSchema).max(MAX_CANVAS_CONVERSION_SOURCE_NODES)
|
|
749
|
-
}).refine(({ collapsedNeutralWrapperNodeCount, collapsedTransferredWrapperNodeCount, collapsedWrapperNodeCount }) => collapsedWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount === void 0 || collapsedTransferredWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount + collapsedTransferredWrapperNodeCount === collapsedWrapperNodeCount, "wrapper collapse proof classes must explain the collapsed wrapper count").refine(({ collapsedNodeCount, collapsedWrapperNodeCount, removedLeafNodeCount }) => collapsedNodeCount === void 0 || collapsedWrapperNodeCount === void 0 || removedLeafNodeCount === void 0 || collapsedWrapperNodeCount + removedLeafNodeCount === collapsedNodeCount, "collapsed node kinds must explain the total collapsed node count").refine(({ collapsedNodeCount, nodeCount, sourceNodeCount, truncatedNodeCount }) => sourceNodeCount === void 0 || collapsedNodeCount === void 0 || sourceNodeCount - nodeCount === collapsedNodeCount + (truncatedNodeCount ?? 0), "collapsed and truncated node counts must explain the source to editable difference").refine(({ layoutContainerCount, nodeCount }) => layoutContainerCount === void 0 || layoutContainerCount <= nodeCount, "layout container count cannot exceed editable node count");
|
|
1060
|
+
}).refine(({ collapsedNeutralWrapperNodeCount, collapsedTransferredWrapperNodeCount, collapsedWrapperNodeCount }) => collapsedWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount === void 0 || collapsedTransferredWrapperNodeCount === void 0 || collapsedNeutralWrapperNodeCount + collapsedTransferredWrapperNodeCount === collapsedWrapperNodeCount, "wrapper collapse proof classes must explain the collapsed wrapper count").refine(({ collapsedNodeCount, collapsedWrapperNodeCount, removedLeafNodeCount }) => collapsedNodeCount === void 0 || collapsedWrapperNodeCount === void 0 || removedLeafNodeCount === void 0 || collapsedWrapperNodeCount + removedLeafNodeCount === collapsedNodeCount, "collapsed node kinds must explain the total collapsed node count").refine(({ addedLayoutNodeCount, collapsedNodeCount, nodeCount, sourceNodeCount, truncatedNodeCount }) => sourceNodeCount === void 0 || collapsedNodeCount === void 0 || sourceNodeCount + (addedLayoutNodeCount ?? 0) - nodeCount === collapsedNodeCount + (truncatedNodeCount ?? 0), "added, collapsed and truncated node counts must explain the source to editable difference").refine(({ layoutContainerCount, nodeCount }) => layoutContainerCount === void 0 || layoutContainerCount <= nodeCount, "layout container count cannot exceed editable node count");
|
|
750
1061
|
const canvasSubtreeDraftNodeSchema = canvasSceneNodeSchema.omit({ id: true }).extend({ temporaryId: temporaryIdSchema });
|
|
751
1062
|
const canvasSubtreeDraftRelationshipSchema = z.object({
|
|
752
1063
|
temporaryId: temporaryIdSchema,
|
|
@@ -762,6 +1073,7 @@ const canvasSubtreeDraftSchema = z.object({
|
|
|
762
1073
|
});
|
|
763
1074
|
const createEditableFrameInputSchema = z.object({
|
|
764
1075
|
canvasId: z.uuid(),
|
|
1076
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
765
1077
|
mutationId: z.uuid(),
|
|
766
1078
|
baseVersion: z.number().int().positive(),
|
|
767
1079
|
screenNodeId: z.string().min(1).max(200),
|
|
@@ -1147,11 +1459,7 @@ const conversionRouteStateSchema = z.discriminatedUnion("state", [
|
|
|
1147
1459
|
//#region ../../packages/contract/src/canvas/canvas-document.schema.ts
|
|
1148
1460
|
/** More screens than one canvas has ever held, and a bound on one save's work. */
|
|
1149
1461
|
const MAX_SCREENS_PER_DOCUMENT = 2e3;
|
|
1150
|
-
/**
|
|
1151
|
-
* The server never parses this. `record(string, unknown)` is the honest schema: it accepts
|
|
1152
|
-
* any JSON object and rejects a top-level array or scalar, which is the whole of the
|
|
1153
|
-
* server's knowledge of a document's shape.
|
|
1154
|
-
*/
|
|
1462
|
+
/** Reads retain unsupported documents; the write boundary validates the current scene format. */
|
|
1155
1463
|
const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
|
|
1156
1464
|
const getCanvasDocumentInputSchema = z.object({ canvasId: z.uuid() });
|
|
1157
1465
|
const documentScreenSchema = z.object({
|
|
@@ -1188,7 +1496,7 @@ const getCanvasDocumentOutputSchema = z.object({
|
|
|
1188
1496
|
const saveCanvasDocumentInputSchema = z.object({
|
|
1189
1497
|
canvasId: z.uuid(),
|
|
1190
1498
|
baseVersion: z.number().int().min(1),
|
|
1191
|
-
document: canvasDocumentBlobSchema,
|
|
1499
|
+
document: canvasDocumentBlobSchema.refine((document) => canvasSceneDocumentSchema.safeParse(document).success, "A save requires a valid current-format canvas document."),
|
|
1192
1500
|
/** Every screen the document names. Replaces the manifest wholesale. */
|
|
1193
1501
|
screenIds: z.array(z.uuid()).max(MAX_SCREENS_PER_DOCUMENT)
|
|
1194
1502
|
});
|
|
@@ -1273,6 +1581,7 @@ const canvasInspectNodeSummarySchema = z.object({
|
|
|
1273
1581
|
const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
1274
1582
|
const inspectCanvasOutputSchema = z.object({
|
|
1275
1583
|
canvasId: z.uuid(),
|
|
1584
|
+
openUrl: z.url(),
|
|
1276
1585
|
title: z.string().min(1),
|
|
1277
1586
|
version: z.number().int().positive(),
|
|
1278
1587
|
nodeCount: z.number().int().min(0),
|
|
@@ -1306,6 +1615,98 @@ const inspectCanvasNodeOutputSchema = z.object({
|
|
|
1306
1615
|
next: z.array(z.string().min(1))
|
|
1307
1616
|
});
|
|
1308
1617
|
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region ../../packages/contract/src/canvas/canvas-layout-ownership.lib.ts
|
|
1620
|
+
const CANVAS_LAYOUT_CSS_FIELDS = [
|
|
1621
|
+
["alignSelf", "align-self"],
|
|
1622
|
+
["order", "order"],
|
|
1623
|
+
["flexGrow", "flex-grow"],
|
|
1624
|
+
["flexShrink", "flex-shrink"],
|
|
1625
|
+
["flexBasis", "flex-basis"],
|
|
1626
|
+
["aspectRatio", "aspect-ratio"]
|
|
1627
|
+
];
|
|
1628
|
+
const CANVAS_CONTAINER_CSS_FIELDS = [
|
|
1629
|
+
["direction", "flex-direction"],
|
|
1630
|
+
["wrap", "flex-wrap"],
|
|
1631
|
+
["alignItems", "align-items"],
|
|
1632
|
+
["alignContent", "align-content"],
|
|
1633
|
+
["justifyContent", "justify-content"],
|
|
1634
|
+
["rowGap", "row-gap"],
|
|
1635
|
+
["columnGap", "column-gap"]
|
|
1636
|
+
];
|
|
1637
|
+
const SIDES = [
|
|
1638
|
+
"top",
|
|
1639
|
+
"right",
|
|
1640
|
+
"bottom",
|
|
1641
|
+
"left"
|
|
1642
|
+
];
|
|
1643
|
+
const releasedSpacing = (held, prefix, properties) => {
|
|
1644
|
+
const next = { ...held };
|
|
1645
|
+
for (const side of SIDES) if (properties.has(`${prefix}-${side}`)) Reflect.deleteProperty(next, side);
|
|
1646
|
+
return next;
|
|
1647
|
+
};
|
|
1648
|
+
/** A shorthand can release several named controls; a longhand releases only itself. */
|
|
1649
|
+
const releasedFields = (held, changed) => {
|
|
1650
|
+
const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
|
|
1651
|
+
const layout = { ...held };
|
|
1652
|
+
for (const [key, property] of CANVAS_LAYOUT_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(layout, key);
|
|
1653
|
+
if (layout.margin !== void 0) layout.margin = releasedSpacing(layout.margin, "margin", properties);
|
|
1654
|
+
if (layout.container === void 0) return layout;
|
|
1655
|
+
const container = { ...layout.container };
|
|
1656
|
+
if ((properties.has("row-gap") || properties.has("column-gap")) && container.gap !== void 0) {
|
|
1657
|
+
container.rowGap ??= container.gap;
|
|
1658
|
+
container.columnGap ??= container.gap;
|
|
1659
|
+
Reflect.deleteProperty(container, "gap");
|
|
1660
|
+
}
|
|
1661
|
+
for (const [key, property] of CANVAS_CONTAINER_CSS_FIELDS) if (properties.has(property)) Reflect.deleteProperty(container, key);
|
|
1662
|
+
if (container.padding !== void 0) container.padding = releasedSpacing(container.padding, "padding", properties);
|
|
1663
|
+
if (properties.has("grid-template-columns")) {
|
|
1664
|
+
Reflect.deleteProperty(container, "gridColumns");
|
|
1665
|
+
Reflect.deleteProperty(container, "gridAutoRepeat");
|
|
1666
|
+
}
|
|
1667
|
+
layout.container = container;
|
|
1668
|
+
return layout;
|
|
1669
|
+
};
|
|
1670
|
+
const axisWithoutCssBounds = (intent, properties, changed) => {
|
|
1671
|
+
if (intent === void 0 || intent.mode === "fixed") return intent;
|
|
1672
|
+
const released = { ...intent };
|
|
1673
|
+
for (const bound of ["min", "max"]) {
|
|
1674
|
+
if (properties.every((property) => !changed.has(`${bound}-${property}`))) continue;
|
|
1675
|
+
Reflect.deleteProperty(released, bound);
|
|
1676
|
+
Reflect.deleteProperty(released, `${bound}Parent`);
|
|
1677
|
+
}
|
|
1678
|
+
return released;
|
|
1679
|
+
};
|
|
1680
|
+
/** Editors hand CSS control back property by property; absent presets stay absent. */
|
|
1681
|
+
const canvasLayoutWithoutCssProperties = (held, changed, axes) => {
|
|
1682
|
+
const properties = new Set([...changed].flatMap((property) => canvasCssPropertyScope(property)));
|
|
1683
|
+
const layout = releasedFields(held, properties);
|
|
1684
|
+
if ([
|
|
1685
|
+
"overflow",
|
|
1686
|
+
"overflow-x",
|
|
1687
|
+
"overflow-y"
|
|
1688
|
+
].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "clipContent");
|
|
1689
|
+
if (properties.has("position")) Reflect.deleteProperty(layout, "position");
|
|
1690
|
+
if (properties.has("transform")) for (const key of [
|
|
1691
|
+
"rotation",
|
|
1692
|
+
"flipHorizontal",
|
|
1693
|
+
"flipVertical"
|
|
1694
|
+
]) Reflect.deleteProperty(layout, key);
|
|
1695
|
+
if ([
|
|
1696
|
+
"inset",
|
|
1697
|
+
"left",
|
|
1698
|
+
"right",
|
|
1699
|
+
"top",
|
|
1700
|
+
"bottom"
|
|
1701
|
+
].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "flowOffset");
|
|
1702
|
+
for (const axis of ["horizontal", "vertical"]) {
|
|
1703
|
+
const intent = axes[axis].some((property) => properties.has(property)) ? void 0 : axisWithoutCssBounds(layout[axis], axes[axis], properties);
|
|
1704
|
+
if (intent === void 0) Reflect.deleteProperty(layout, axis);
|
|
1705
|
+
else layout[axis] = intent;
|
|
1706
|
+
}
|
|
1707
|
+
return layout;
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1309
1710
|
//#endregion
|
|
1310
1711
|
//#region ../../packages/contract/src/canvas/canvas-object-kind.lib.ts
|
|
1311
1712
|
const ROOT_KIND = "root";
|
|
@@ -1655,15 +2056,62 @@ const canvasTextStylePatchSchema = z.strictObject({
|
|
|
1655
2056
|
z.literal("normal")
|
|
1656
2057
|
]).nullable().optional()
|
|
1657
2058
|
});
|
|
1658
|
-
const overflowStyleValue =
|
|
1659
|
-
"auto",
|
|
1660
|
-
"clip",
|
|
1661
|
-
"hidden",
|
|
1662
|
-
"scroll",
|
|
1663
|
-
"visible"
|
|
1664
|
-
]);
|
|
2059
|
+
const overflowStyleValue = canvasAdditionalStyleSchema.shape.value;
|
|
1665
2060
|
const dimensionalStyleValue = z.union([z.string(), boundedCanvasNumberSchema]);
|
|
2061
|
+
const layoutStylePatchValue = z.union([canvasAdditionalStyleSchema.shape.value, boundedCanvasNumberSchema]).nullable().optional();
|
|
1666
2062
|
const canvasNodeStylePatchSchema = canvasTextStylePatchSchema.extend({
|
|
2063
|
+
"align-content": layoutStylePatchValue,
|
|
2064
|
+
"align-items": layoutStylePatchValue,
|
|
2065
|
+
"align-self": layoutStylePatchValue,
|
|
2066
|
+
"aspect-ratio": layoutStylePatchValue,
|
|
2067
|
+
"block-size": layoutStylePatchValue,
|
|
2068
|
+
bottom: layoutStylePatchValue,
|
|
2069
|
+
"box-sizing": layoutStylePatchValue,
|
|
2070
|
+
display: layoutStylePatchValue,
|
|
2071
|
+
flex: layoutStylePatchValue,
|
|
2072
|
+
"flex-basis": layoutStylePatchValue,
|
|
2073
|
+
"flex-direction": layoutStylePatchValue,
|
|
2074
|
+
"flex-grow": layoutStylePatchValue,
|
|
2075
|
+
"flex-shrink": layoutStylePatchValue,
|
|
2076
|
+
"flex-wrap": layoutStylePatchValue,
|
|
2077
|
+
height: layoutStylePatchValue,
|
|
2078
|
+
"inline-size": layoutStylePatchValue,
|
|
2079
|
+
inset: layoutStylePatchValue,
|
|
2080
|
+
"inset-block": layoutStylePatchValue,
|
|
2081
|
+
"inset-block-end": layoutStylePatchValue,
|
|
2082
|
+
"inset-block-start": layoutStylePatchValue,
|
|
2083
|
+
"inset-inline": layoutStylePatchValue,
|
|
2084
|
+
"inset-inline-end": layoutStylePatchValue,
|
|
2085
|
+
"inset-inline-start": layoutStylePatchValue,
|
|
2086
|
+
"justify-content": layoutStylePatchValue,
|
|
2087
|
+
left: layoutStylePatchValue,
|
|
2088
|
+
margin: layoutStylePatchValue,
|
|
2089
|
+
"margin-block": layoutStylePatchValue,
|
|
2090
|
+
"margin-block-end": layoutStylePatchValue,
|
|
2091
|
+
"margin-block-start": layoutStylePatchValue,
|
|
2092
|
+
"margin-inline": layoutStylePatchValue,
|
|
2093
|
+
"margin-inline-end": layoutStylePatchValue,
|
|
2094
|
+
"margin-inline-start": layoutStylePatchValue,
|
|
2095
|
+
"max-block-size": layoutStylePatchValue,
|
|
2096
|
+
"max-height": layoutStylePatchValue,
|
|
2097
|
+
"max-inline-size": layoutStylePatchValue,
|
|
2098
|
+
"max-width": layoutStylePatchValue,
|
|
2099
|
+
"min-block-size": layoutStylePatchValue,
|
|
2100
|
+
"min-height": layoutStylePatchValue,
|
|
2101
|
+
"min-inline-size": layoutStylePatchValue,
|
|
2102
|
+
"min-width": layoutStylePatchValue,
|
|
2103
|
+
order: layoutStylePatchValue,
|
|
2104
|
+
padding: layoutStylePatchValue,
|
|
2105
|
+
"padding-block": layoutStylePatchValue,
|
|
2106
|
+
"padding-block-end": layoutStylePatchValue,
|
|
2107
|
+
"padding-block-start": layoutStylePatchValue,
|
|
2108
|
+
"padding-inline": layoutStylePatchValue,
|
|
2109
|
+
"padding-inline-end": layoutStylePatchValue,
|
|
2110
|
+
"padding-inline-start": layoutStylePatchValue,
|
|
2111
|
+
position: layoutStylePatchValue,
|
|
2112
|
+
right: layoutStylePatchValue,
|
|
2113
|
+
top: layoutStylePatchValue,
|
|
2114
|
+
width: layoutStylePatchValue,
|
|
1667
2115
|
background: z.string().nullable().optional(),
|
|
1668
2116
|
"background-color": z.string().nullable().optional(),
|
|
1669
2117
|
"border-bottom-left-radius": dimensionalStyleValue.optional(),
|
|
@@ -1736,6 +2184,12 @@ const parentageSchema = z.object({
|
|
|
1736
2184
|
parentId: nodeIdSchema$1,
|
|
1737
2185
|
sortKey: sortKeySchema
|
|
1738
2186
|
});
|
|
2187
|
+
const canvasSetStylesOperationSchema = z.object({
|
|
2188
|
+
op: z.literal("setStyles"),
|
|
2189
|
+
nodeId: nodeIdSchema$1,
|
|
2190
|
+
styles: canvasNodeStylePatchSchema,
|
|
2191
|
+
clear: z.array(canvasNodeStylePatchSchema.keyof()).min(1).max(Object.keys(canvasNodeStylePatchSchema.shape).length).refine((properties) => new Set(properties).size === properties.length).optional()
|
|
2192
|
+
}).refine((operation) => (operation.clear ?? []).every((property) => !Object.hasOwn(operation.styles, property)));
|
|
1739
2193
|
const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
1740
2194
|
insertConvertedSubtreeOperationSchema,
|
|
1741
2195
|
z.object({
|
|
@@ -1774,18 +2228,23 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
1774
2228
|
z.object({
|
|
1775
2229
|
op: z.literal("setBox"),
|
|
1776
2230
|
nodeId: nodeIdSchema$1,
|
|
1777
|
-
box: canvasSceneBoxSchema
|
|
2231
|
+
box: z.union([canvasSceneBoxSchema, z.literal("default")])
|
|
1778
2232
|
}),
|
|
1779
2233
|
z.object({
|
|
1780
2234
|
op: z.literal("setLabel"),
|
|
1781
2235
|
nodeId: nodeIdSchema$1,
|
|
1782
2236
|
label: z.string().trim().min(1).max(MAX_LABEL_LENGTH),
|
|
1783
|
-
labelOrigin: canvasNodeLabelOriginSchema.optional()
|
|
2237
|
+
labelOrigin: canvasNodeLabelOriginSchema.nullable().optional()
|
|
2238
|
+
}),
|
|
2239
|
+
z.object({
|
|
2240
|
+
op: z.literal("setContainerKind"),
|
|
2241
|
+
nodeId: nodeIdSchema$1,
|
|
2242
|
+
component: z.enum(["frame", "group"])
|
|
1784
2243
|
}),
|
|
1785
2244
|
z.object({
|
|
1786
2245
|
op: z.literal("setVisibility"),
|
|
1787
2246
|
nodeId: nodeIdSchema$1,
|
|
1788
|
-
visible: z.boolean()
|
|
2247
|
+
visible: z.boolean().nullable()
|
|
1789
2248
|
}),
|
|
1790
2249
|
z.object({
|
|
1791
2250
|
op: z.literal("setLocked"),
|
|
@@ -1797,11 +2256,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
1797
2256
|
nodeId: nodeIdSchema$1,
|
|
1798
2257
|
constraints: canvasNodeConstraintsSchema
|
|
1799
2258
|
}),
|
|
1800
|
-
|
|
1801
|
-
op: z.literal("setStyles"),
|
|
1802
|
-
nodeId: nodeIdSchema$1,
|
|
1803
|
-
styles: canvasNodeStylePatchSchema
|
|
1804
|
-
}),
|
|
2259
|
+
canvasSetStylesOperationSchema,
|
|
1805
2260
|
z.object({
|
|
1806
2261
|
op: z.literal("setAppearance"),
|
|
1807
2262
|
nodeId: nodeIdSchema$1,
|
|
@@ -1825,7 +2280,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
1825
2280
|
z.object({
|
|
1826
2281
|
op: z.literal("setProps"),
|
|
1827
2282
|
nodeId: nodeIdSchema$1,
|
|
1828
|
-
props: z.record(z.string(), z.unknown())
|
|
2283
|
+
props: z.union([z.record(z.string(), z.unknown()), z.literal("default")])
|
|
1829
2284
|
}),
|
|
1830
2285
|
z.object({
|
|
1831
2286
|
op: z.literal("setParentage"),
|
|
@@ -1844,6 +2299,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
1844
2299
|
const applyCanvasOperationsInputSchema = z.object({
|
|
1845
2300
|
canvasId: z.uuid(),
|
|
1846
2301
|
mutationId: z.uuid(),
|
|
2302
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
1847
2303
|
baseVersion: z.number().int().positive(),
|
|
1848
2304
|
operations: z.array(canvasOperationSchema).min(1).max(MAX_CANVAS_OPERATIONS)
|
|
1849
2305
|
});
|
|
@@ -2409,6 +2865,7 @@ const removeCanvasVersionNameInputSchema = z.object({
|
|
|
2409
2865
|
const canvasVersionMutationOutputSchema = z.object({ entry: canvasVersionEntrySchema });
|
|
2410
2866
|
const restoreCanvasVersionInputSchema = z.object({
|
|
2411
2867
|
canvasId: z.uuid(),
|
|
2868
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
2412
2869
|
versionId: z.uuid(),
|
|
2413
2870
|
expectedVersion: z.number().int().positive()
|
|
2414
2871
|
});
|
|
@@ -2421,6 +2878,7 @@ const restoreCanvasVersionOutputSchema = z.object({
|
|
|
2421
2878
|
});
|
|
2422
2879
|
const duplicateCanvasVersionInputSchema = z.object({
|
|
2423
2880
|
canvasId: z.uuid(),
|
|
2881
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
2424
2882
|
versionId: z.uuid(),
|
|
2425
2883
|
organisationId: z.union([z.uuid(), z.literal("personal")]),
|
|
2426
2884
|
title: z.string().trim().min(1).max(200).optional()
|
|
@@ -2761,6 +3219,51 @@ const deleteCommentOutputSchema = z.object({
|
|
|
2761
3219
|
deletedMessageIds: z.array(z.uuid())
|
|
2762
3220
|
});
|
|
2763
3221
|
|
|
3222
|
+
//#endregion
|
|
3223
|
+
//#region ../../packages/contract/src/fixture/canvas-fixture.lib.ts
|
|
3224
|
+
const ROOT_FIXTURE_NODE_ID = "root";
|
|
3225
|
+
const SORT_KEY_DIGITS = 4;
|
|
3226
|
+
const sortKeyAt = (seat) => `a${String(seat).padStart(SORT_KEY_DIGITS, "0")}`;
|
|
3227
|
+
const emptyFixtureDocument = () => ({
|
|
3228
|
+
version: 3,
|
|
3229
|
+
nodes: { [ROOT_FIXTURE_NODE_ID]: {
|
|
3230
|
+
id: ROOT_FIXTURE_NODE_ID,
|
|
3231
|
+
label: "Canvas",
|
|
3232
|
+
component: "root",
|
|
3233
|
+
styles: {}
|
|
3234
|
+
} },
|
|
3235
|
+
relationships: {}
|
|
3236
|
+
});
|
|
3237
|
+
const withFixtureNode = (document, node) => ({
|
|
3238
|
+
...document,
|
|
3239
|
+
nodes: {
|
|
3240
|
+
...document.nodes,
|
|
3241
|
+
[node.id]: node
|
|
3242
|
+
},
|
|
3243
|
+
relationships: {
|
|
3244
|
+
...document.relationships,
|
|
3245
|
+
[node.id]: {
|
|
3246
|
+
parentId: ROOT_FIXTURE_NODE_ID,
|
|
3247
|
+
sortKey: sortKeyAt(Object.keys(document.relationships).length)
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
});
|
|
3251
|
+
const withFixtureScreen = (document, input) => withFixtureNode(document, {
|
|
3252
|
+
id: input.id,
|
|
3253
|
+
label: input.label,
|
|
3254
|
+
component: "screen",
|
|
3255
|
+
props: { capture: {
|
|
3256
|
+
viewport: input.viewport,
|
|
3257
|
+
atMs: 0,
|
|
3258
|
+
screenId: input.screenId
|
|
3259
|
+
} },
|
|
3260
|
+
styles: {},
|
|
3261
|
+
box: {
|
|
3262
|
+
...input.at,
|
|
3263
|
+
...input.viewport
|
|
3264
|
+
}
|
|
3265
|
+
});
|
|
3266
|
+
|
|
2764
3267
|
//#endregion
|
|
2765
3268
|
//#region ../../packages/contract/src/organisation/organisation.schema.ts
|
|
2766
3269
|
const organisationRoleSchema = z.enum([
|
|
@@ -4141,7 +4644,10 @@ const MAX_RENDER_SCALE = 4;
|
|
|
4141
4644
|
const MAX_NODE_ID_LENGTH = 200;
|
|
4142
4645
|
const MAX_HTML_LENGTH = 1e6;
|
|
4143
4646
|
const MAX_ID_PREFIX_LENGTH = 100;
|
|
4144
|
-
const canvasApplyCapabilityInputSchema = applyCanvasOperationsInputSchema.omit({
|
|
4647
|
+
const canvasApplyCapabilityInputSchema = applyCanvasOperationsInputSchema.omit({
|
|
4648
|
+
mutationId: true,
|
|
4649
|
+
documentFormatVersion: true
|
|
4650
|
+
});
|
|
4145
4651
|
const canvasRenderCapabilityInputSchema = z.object({
|
|
4146
4652
|
canvasId: z.uuid(),
|
|
4147
4653
|
expectedVersion: z.number().int().positive().nullable().describe("Exact document version to render, or null to accept the current version."),
|
|
@@ -4432,7 +4938,7 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
4432
4938
|
"canvas.setReviewState": "Change the authenticated person’s review state on a canvas.",
|
|
4433
4939
|
"canvas.document.get": "Read a canvas document, version, and attached screen manifest.",
|
|
4434
4940
|
"canvas.document.save": "Replace a canvas document. A stale base version exits 5 as CONFLICT; read, merge, and retry.",
|
|
4435
|
-
"canvas.inspect": "
|
|
4941
|
+
"canvas.inspect": "Read the canonical browser URL for a canvas, its exact document version, kind counts, bounds, and next inspection commands.",
|
|
4436
4942
|
"canvas.tree": "List stable node ids, hierarchy, kinds, and world-space boxes for one canvas.",
|
|
4437
4943
|
"canvas.node": "Read one stable node with its exact styles, props, children, and current version.",
|
|
4438
4944
|
"canvas.selection": "Read the accountable person’s most recently changed live browser selection at an exact canvas version.",
|
|
@@ -4510,6 +5016,7 @@ const OPTION_DESCRIPTIONS = {
|
|
|
4510
5016
|
"--access-state": "Filter or set link reach: invite-only, link-view, or link-comment.",
|
|
4511
5017
|
"--has-unresolved": "Set true to return only canvases with unresolved comment threads.",
|
|
4512
5018
|
"--base-version": "Document version returned by `enhance canvas document get`.",
|
|
5019
|
+
"--document-format-version": "Supported canvas schema version for this writer, not the saved revision in baseVersion. Update the client if its format is no longer supported.",
|
|
4513
5020
|
"--operations": "One or more validated canvas operations; use the canvas apply command’s @file form for a batch.",
|
|
4514
5021
|
"--phase": "Agent work now in progress: reading, writing, creating, deleting, or rendering.",
|
|
4515
5022
|
"--node-ids": "Stable canvas node ids affected by the current agent activity.",
|
|
@@ -6503,8 +7010,7 @@ const worldBoxesOf = (document) => {
|
|
|
6503
7010
|
return boxes;
|
|
6504
7011
|
};
|
|
6505
7012
|
const toCanvasInspection = (value) => {
|
|
6506
|
-
const
|
|
6507
|
-
const parsed = canvasSceneDocumentSchema.safeParse(candidate);
|
|
7013
|
+
const parsed = canvasReadableSceneDocumentSchema.safeParse(value);
|
|
6508
7014
|
if (!parsed.success) return topologyFailure("its scene shape is invalid");
|
|
6509
7015
|
const topology = validateTopology(parsed.data);
|
|
6510
7016
|
if (topology.isErr()) return (0, import_index_cjs.err)(topology.error);
|
|
@@ -6540,20 +7046,22 @@ const inspection = async (handlers, canvasId) => {
|
|
|
6540
7046
|
projected: orThrow(toCanvasInspection(source.document).mapErr((message) => appError("INTERNAL", message)))
|
|
6541
7047
|
};
|
|
6542
7048
|
};
|
|
6543
|
-
const
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
7049
|
+
const inspect = (handlers, webOrigin) => agentCanvasReaderProcedure.input(inspectCanvasInputSchema).output(inspectCanvasOutputSchema).query(async ({ input }) => {
|
|
7050
|
+
const { source, projected } = await inspection(handlers, input.canvasId);
|
|
7051
|
+
return {
|
|
7052
|
+
canvasId: input.canvasId,
|
|
7053
|
+
openUrl: new URL(`/c/${input.canvasId}`, webOrigin).href,
|
|
7054
|
+
title: source.title,
|
|
7055
|
+
version: source.version,
|
|
7056
|
+
nodeCount: Math.max(0, projected.nodes.length - 1),
|
|
7057
|
+
rootChildCount: projected.children.get("root")?.length ?? 0,
|
|
7058
|
+
bounds: projected.bounds,
|
|
7059
|
+
kinds: projected.kinds,
|
|
7060
|
+
next: [`enhance canvas tree --canvas ${input.canvasId}`, `enhance canvas render --canvas ${input.canvasId} --expected-version ${String(source.version)}`]
|
|
7061
|
+
};
|
|
7062
|
+
});
|
|
7063
|
+
const createCanvasInspectionRouter = (handlers, webOrigin) => ({
|
|
7064
|
+
inspect: inspect(handlers, webOrigin),
|
|
6557
7065
|
tree: agentCanvasReaderProcedure.input(inspectCanvasTreeInputSchema).output(inspectCanvasTreeOutputSchema).query(async ({ input }) => {
|
|
6558
7066
|
const { source, projected } = await inspection(handlers, input.canvasId);
|
|
6559
7067
|
return {
|
|
@@ -8562,7 +9070,8 @@ const createTranscriptRouter = (handlers) => trpcRouter({
|
|
|
8562
9070
|
//#region ../api/src/app.router.ts
|
|
8563
9071
|
const DEFAULT_ROUTER_OPTIONS = {
|
|
8564
9072
|
shouldExposeInviteTokens: false,
|
|
8565
|
-
realtimeEndpoint: "ws://localhost:3000/v1/canvas-realtime"
|
|
9073
|
+
realtimeEndpoint: "ws://localhost:3000/v1/canvas-realtime",
|
|
9074
|
+
webOrigin: "http://localhost:5173"
|
|
8566
9075
|
};
|
|
8567
9076
|
/**
|
|
8568
9077
|
* The one tRPC surface, assembled from each bounded context's router.
|
|
@@ -8576,7 +9085,7 @@ const createAppRouter = (handlers, options = DEFAULT_ROUTER_OPTIONS) => trpcRout
|
|
|
8576
9085
|
...createCanvasRouter(handlers.canvas)._def.record,
|
|
8577
9086
|
...createCanvasImageRouter(handlers.canvas)._def.record,
|
|
8578
9087
|
...createCanvasLifecycleRouter(handlers.canvas)._def.record,
|
|
8579
|
-
...createCanvasInspectionRouter(handlers.render),
|
|
9088
|
+
...createCanvasInspectionRouter(handlers.render, options.webOrigin),
|
|
8580
9089
|
selection: createCanvasSelectionRoute(handlers.canvas.selection, handlers.render.readCanvas),
|
|
8581
9090
|
realtime: createCanvasRealtimeRouter(handlers.canvas, options.realtimeEndpoint),
|
|
8582
9091
|
document: createCanvasDocumentRouter(handlers.canvas),
|
|
@@ -8828,7 +9337,13 @@ const createCapabilityCatalogAdapter = () => {
|
|
|
8828
9337
|
meta: parsed.meta,
|
|
8829
9338
|
policy: procedurePolicy,
|
|
8830
9339
|
cliPath: procedurePolicy.exposure === "shared" ? id.replaceAll(".", " ") : null,
|
|
8831
|
-
...id === "canvas.render.importSource" && { inputExample: IMPORT_SOURCE_EXAMPLE }
|
|
9340
|
+
...id === "canvas.render.importSource" && { inputExample: IMPORT_SOURCE_EXAMPLE },
|
|
9341
|
+
...id === "canvas.document.save" && { inputExample: {
|
|
9342
|
+
canvasId: "00000000-0000-4000-8000-000000000010",
|
|
9343
|
+
baseVersion: 1,
|
|
9344
|
+
document: emptyCanvasSceneDocument(),
|
|
9345
|
+
screenIds: []
|
|
9346
|
+
} }
|
|
8832
9347
|
});
|
|
8833
9348
|
});
|
|
8834
9349
|
const productCapabilities = [...CANVAS_CAPABILITY_SPECS, ...COLLABORATION_CAPABILITY_SPECS].map((spec) => toCapabilityDefinition({
|
|
@@ -9053,4 +9568,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
9053
9568
|
});
|
|
9054
9569
|
|
|
9055
9570
|
//#endregion
|
|
9056
|
-
export {
|
|
9571
|
+
export { canvasLayoutWithoutCssProperties as $, startRecordingOutputSchema as A, getMeOutputSchema as B, CliError as C, createScreenOutputSchema as D, completeScreenOutputSchema as E, getPrototypeArtifactCapabilitiesOutputSchema as F, emptyFixtureDocument as G, cliAuthConfigurationSchema as H, getPrototypePublishStatusOutputSchema as I, canvasAgentActivityPhaseSchema as J, withFixtureScreen as K, prototypeArtifactManifestSchema as L, attachPrototypeArtifactOutputSchema as M, createPrototypeArtifactOutputSchema as N, appendRecordingChunkOutputSchema as O, foldPrototypeArtifactPath as P, canvasNodeStylePatchSchema as Q, prototypeArtifactPathSchema as R, PartialBatchError as S, appErrorSchema as T, createAgentTokenOutputSchema as U, MCP_AUTH_SCOPE as V, createOrganisationOutputSchema as W, applyCanvasOperationsOutputSchema as X, MAX_CANVAS_OPERATIONS as Y, canvasOperationSchema as Z, canvasWriteHtmlCapabilityInputSchema as _, canvasSchema as _t, toPresentedCapabilities as a, canvasWorldBoundsSchema as at, recordingSnapshotCapabilityInputSchema as b, ProcessExitError as c, downloadCanvasRenderOutputSchema as ct, createCapabilityPolicyAdapter as d, canvasAdditionalStyleSchema as dt, getCanvasDocumentOutputSchema as et, toCapabilityDefinition as f, canvasAuthoredLayoutValueOf as ft, canvasRenderCapabilityInputSchema as g, canvasLayoutPriorityDeclarations as gt, canvasApplyCapabilityInputSchema as h, canvasLayoutMainAxisOf as ht, toFailurePayload as i, RENDER_MIN_SCALE as it, PROTOTYPE_ARTIFACT_MANIFEST_PATH as j, completeRecordingOutputSchema as k, createCapabilityCatalogAdapter as l, getCanvasRenderOutputSchema as lt, PROCEDURE_DESCRIPTIONS as m, canvasAxisStyleProperties as mt, withCommandName as n, createCanvasConversionOutputSchema as nt, toSharedCapabilities as o, createCanvasRenderOutputSchema as ot, OPTION_DESCRIPTIONS as p, canvasAuthoredStyleDeclarations as pt, beginCanvasActivityOutputSchema as q, toExitCode as r, getCanvasConversionOutputSchema as rt, createMcpCapabilityDiscoveryAdapter as s, createRecordingSnapshotOutputSchema as st, withCommandInFailure as t, saveCanvasDocumentOutputSchema as tt, createRouterShapeAdapter as u, canvasReadableSceneDocumentSchema as ut, commentAttentionCapabilityInputSchema as v, transcriptOutputSchema as w, transcriptReadCapabilityInputSchema as x, prototypePublishCapabilityInputSchema as y, submitPrototypeArtifactOutputSchema as z };
|