@enhance-eng/enhance 0.1.168 → 0.1.170
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-DMHqCPUz.mjs → cli-output-identity.lib-CKns8qEG.mjs} +2183 -1794
- package/dist/main.mjs +654 -445
- package/dist/{mcp-invocation.adapter-YFCrLzlc.mjs → mcp-invocation.adapter-BfWB3PFL.mjs} +46 -26
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-CUuoL6AI.mjs → mcp-server.adapter-UiOcYGPZ.mjs} +32 -14
- package/dist/mcp.mjs +2 -2
- package/dist/remote-mcp-main.mjs +37 -15
- package/dist/{zod-messages.lib-T23QiUQO.mjs → zod-messages.lib-G2BtVFRk.mjs} +3604 -3152
- package/package.json +2 -1
|
@@ -445,14 +445,14 @@ const completeObjectPictureWorkInputSchema = z.object({
|
|
|
445
445
|
//#region ../../packages/contract/src/canvas/canvas-outline.schema.ts
|
|
446
446
|
/** The most top layers one report may hold; a browser with more sends the rest in later reports. */
|
|
447
447
|
const CANVAS_OUTLINE_REPORT_LIMIT = 200;
|
|
448
|
-
const coordinate$
|
|
449
|
-
const extent = z.number().nonnegative();
|
|
448
|
+
const coordinate$2 = z.number();
|
|
449
|
+
const extent$1 = z.number().nonnegative();
|
|
450
450
|
/** A box in page coordinates. */
|
|
451
451
|
const canvasOutlineBoxSchema = z.strictObject({
|
|
452
|
-
x: coordinate$
|
|
453
|
-
y: coordinate$
|
|
454
|
-
width: extent,
|
|
455
|
-
height: extent
|
|
452
|
+
x: coordinate$2,
|
|
453
|
+
y: coordinate$2,
|
|
454
|
+
width: extent$1,
|
|
455
|
+
height: extent$1
|
|
456
456
|
});
|
|
457
457
|
/** What a browser measured of one top layer: its own box, and how far its descendants paint. */
|
|
458
458
|
const canvasOutlineMeasurementSchema = z.strictObject({
|
|
@@ -1456,365 +1456,106 @@ const canvasAdditionalStylePatchSchema = z.object({
|
|
|
1456
1456
|
}).strict().refine((patch) => patch.set?.every((item) => patch.clear?.includes(item.id) !== true) ?? true, "a declaration cannot be set and cleared in the same patch");
|
|
1457
1457
|
|
|
1458
1458
|
//#endregion
|
|
1459
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
"
|
|
1459
|
+
//#region ../../packages/contract/src/canvas/canvas-geometry.schema.ts
|
|
1460
|
+
const coordinate$1 = z.number();
|
|
1461
|
+
const dimension$1 = coordinate$1.nonnegative();
|
|
1462
|
+
const MAX_ID_LENGTH = 200;
|
|
1463
|
+
const MIN_POLYGON_POINTS = 3;
|
|
1464
|
+
const identity$1 = z.string().min(1).max(MAX_ID_LENGTH);
|
|
1465
|
+
const path = z.string().regex(/^[MmLlHhVvCcSsQqTtAaZzEe\d\s.,+-]*$/u);
|
|
1466
|
+
const canvasGeometryBoundsSchema = z.strictObject({
|
|
1467
|
+
x: coordinate$1,
|
|
1468
|
+
y: coordinate$1,
|
|
1469
|
+
width: dimension$1,
|
|
1470
|
+
height: dimension$1
|
|
1471
|
+
});
|
|
1472
|
+
const canvasPathGeometrySchema = z.strictObject({
|
|
1473
|
+
kind: z.literal("path"),
|
|
1474
|
+
path: path.min(1),
|
|
1475
|
+
fillRule: z.enum(["nonzero", "evenodd"]),
|
|
1476
|
+
viewBox: canvasGeometryBoundsSchema.extend({
|
|
1477
|
+
width: dimension$1.positive(),
|
|
1478
|
+
height: dimension$1.positive()
|
|
1479
|
+
})
|
|
1480
|
+
});
|
|
1481
|
+
const canvasPolygonGeometrySchema = z.strictObject({
|
|
1482
|
+
kind: z.literal("polygon"),
|
|
1483
|
+
count: z.number().int().min(MIN_POLYGON_POINTS),
|
|
1484
|
+
innerRatio: z.number().min(0).max(1).optional(),
|
|
1485
|
+
cornerRadius: dimension$1,
|
|
1486
|
+
cornerSmoothing: z.number().min(0).max(1)
|
|
1487
|
+
});
|
|
1488
|
+
const canvasBooleanOperationSchema = z.enum([
|
|
1489
|
+
"union",
|
|
1490
|
+
"subtract",
|
|
1491
|
+
"intersect",
|
|
1492
|
+
"exclude"
|
|
1474
1493
|
]);
|
|
1475
|
-
const
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
};
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1494
|
+
const canvasBooleanGeometrySchema = z.strictObject({
|
|
1495
|
+
kind: z.literal("boolean"),
|
|
1496
|
+
operation: canvasBooleanOperationSchema,
|
|
1497
|
+
operandIds: z.array(identity$1).min(1).refine((ids) => new Set(ids).size === ids.length),
|
|
1498
|
+
result: z.strictObject({
|
|
1499
|
+
path,
|
|
1500
|
+
fillRule: z.literal("nonzero"),
|
|
1501
|
+
isEmpty: z.boolean(),
|
|
1502
|
+
bounds: canvasGeometryBoundsSchema,
|
|
1503
|
+
inputKey: z.string().regex(/^[a-f0-9]{16}$/u)
|
|
1504
|
+
}).refine((result) => result.isEmpty === (result.path === ""))
|
|
1505
|
+
});
|
|
1506
|
+
const canvasGeometrySchema = z.discriminatedUnion("kind", [
|
|
1507
|
+
canvasPathGeometrySchema,
|
|
1508
|
+
canvasPolygonGeometrySchema,
|
|
1509
|
+
z.strictObject({
|
|
1510
|
+
kind: z.literal("mask"),
|
|
1511
|
+
maskId: identity$1,
|
|
1512
|
+
/** Absent paints as alpha. An outline mask clips to the source's shape only. */
|
|
1513
|
+
mode: z.enum([
|
|
1514
|
+
"alpha",
|
|
1515
|
+
"luminance",
|
|
1516
|
+
"outline"
|
|
1517
|
+
]).optional()
|
|
1518
|
+
}),
|
|
1519
|
+
canvasBooleanGeometrySchema
|
|
1492
1520
|
]);
|
|
1493
|
-
const isCanvasRichTextHref = (value) => {
|
|
1494
|
-
const href = value.trim();
|
|
1495
|
-
if (href === "") return false;
|
|
1496
|
-
try {
|
|
1497
|
-
const url = new URL(href, "https://enhance.invalid/");
|
|
1498
|
-
return SAFE_HREF_PROTOCOLS.has(url.protocol) && (!["http:", "https:"].includes(url.protocol) || isHttpHostname(url));
|
|
1499
|
-
} catch {
|
|
1500
|
-
return false;
|
|
1501
|
-
}
|
|
1502
|
-
};
|
|
1503
1521
|
|
|
1504
1522
|
//#endregion
|
|
1505
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1506
|
-
const
|
|
1507
|
-
"
|
|
1508
|
-
"
|
|
1509
|
-
"
|
|
1510
|
-
"
|
|
1511
|
-
"
|
|
1512
|
-
"
|
|
1513
|
-
"
|
|
1514
|
-
"
|
|
1515
|
-
"
|
|
1516
|
-
"
|
|
1517
|
-
"
|
|
1518
|
-
"
|
|
1519
|
-
"
|
|
1520
|
-
"
|
|
1521
|
-
"
|
|
1522
|
-
"
|
|
1523
|
-
"
|
|
1524
|
-
"
|
|
1525
|
-
"
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
"fontStretch",
|
|
1529
|
-
"fontStyle",
|
|
1530
|
-
"fontVariant",
|
|
1531
|
-
"fontVariantCaps",
|
|
1532
|
-
"fontVariantLigatures",
|
|
1533
|
-
"fontVariantNumeric",
|
|
1534
|
-
"fontVariantPosition",
|
|
1535
|
-
"fontKerning",
|
|
1536
|
-
"fontVariationSettings",
|
|
1537
|
-
"fontWeight",
|
|
1538
|
-
"hyphenateCharacter",
|
|
1539
|
-
"hyphens",
|
|
1540
|
-
"justifyContent",
|
|
1541
|
-
"letterSpacing",
|
|
1542
|
-
"lineBreak",
|
|
1543
|
-
"lineHeight",
|
|
1544
|
-
"marginBottom",
|
|
1545
|
-
"marginLeft",
|
|
1546
|
-
"marginRight",
|
|
1547
|
-
"marginTop",
|
|
1548
|
-
"opacity",
|
|
1549
|
-
"overflowWrap",
|
|
1550
|
-
"paddingBottom",
|
|
1551
|
-
"paddingLeft",
|
|
1552
|
-
"paddingRight",
|
|
1553
|
-
"paddingTop",
|
|
1554
|
-
"rowGap",
|
|
1555
|
-
"tabSize",
|
|
1556
|
-
"textDecorationColor",
|
|
1557
|
-
"textDecorationLine",
|
|
1558
|
-
"textDecorationSkipInk",
|
|
1559
|
-
"textDecorationStyle",
|
|
1560
|
-
"textDecorationThickness",
|
|
1561
|
-
"textRendering",
|
|
1562
|
-
"textShadow",
|
|
1563
|
-
"textTransform",
|
|
1564
|
-
"textUnderlineOffset",
|
|
1565
|
-
"unicodeBidi",
|
|
1566
|
-
"verticalAlign",
|
|
1567
|
-
"whiteSpace",
|
|
1568
|
-
"wordBreak",
|
|
1569
|
-
"wordSpacing",
|
|
1570
|
-
"WebkitFontSmoothing",
|
|
1571
|
-
"WebkitLocale",
|
|
1572
|
-
"WebkitTextFillColor",
|
|
1573
|
-
"WebkitTextStrokeColor",
|
|
1574
|
-
"WebkitTextStrokeWidth",
|
|
1575
|
-
"--canvas-text-stroke-alignment"
|
|
1576
|
-
]);
|
|
1523
|
+
//#region ../../packages/contract/src/canvas/canvas-property-section.schema.ts
|
|
1524
|
+
const CANVAS_PROPERTY_SECTIONS = [
|
|
1525
|
+
"position",
|
|
1526
|
+
"layout",
|
|
1527
|
+
"clip",
|
|
1528
|
+
"cornerRadius",
|
|
1529
|
+
"blending",
|
|
1530
|
+
"typography",
|
|
1531
|
+
"nativeControl",
|
|
1532
|
+
"textDecoration",
|
|
1533
|
+
"fill",
|
|
1534
|
+
"outline",
|
|
1535
|
+
"textStroke",
|
|
1536
|
+
"border",
|
|
1537
|
+
"outerShadow",
|
|
1538
|
+
"innerShadow",
|
|
1539
|
+
"filters",
|
|
1540
|
+
"additionalStyles",
|
|
1541
|
+
"vector",
|
|
1542
|
+
"export",
|
|
1543
|
+
"source"
|
|
1544
|
+
];
|
|
1545
|
+
const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
|
|
1577
1546
|
|
|
1578
1547
|
//#endregion
|
|
1579
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1580
|
-
const
|
|
1581
|
-
const
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
size: true,
|
|
1586
|
-
weight: true,
|
|
1587
|
-
style: true,
|
|
1588
|
-
variations: true,
|
|
1589
|
-
opticalSize: true,
|
|
1590
|
-
features: true,
|
|
1591
|
-
lineHeight: true,
|
|
1592
|
-
letterSpacing: true,
|
|
1593
|
-
transform: true,
|
|
1594
|
-
decoration: true,
|
|
1595
|
-
paragraphSpacing: true,
|
|
1596
|
-
paragraphIndent: true,
|
|
1597
|
-
listSpacing: true,
|
|
1598
|
-
hangingList: true,
|
|
1599
|
-
hangingPunctuation: true,
|
|
1600
|
-
verticalTrim: true,
|
|
1601
|
-
wrapStyle: true
|
|
1602
|
-
}).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
|
|
1603
|
-
const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
|
|
1604
|
-
const canvasTextStyleSchema = z.object({
|
|
1605
|
-
id: z.string().min(1),
|
|
1606
|
-
name: z.string().trim().min(1),
|
|
1607
|
-
description: z.string().max(MAX_DESCRIPTION$1),
|
|
1608
|
-
sortKey: z.string().min(1).optional(),
|
|
1609
|
-
sourceStyleId: z.string().min(1).optional(),
|
|
1610
|
-
sourceCanvasId: z.uuid().optional(),
|
|
1611
|
-
sourceRevision: z.number().int().positive().optional(),
|
|
1612
|
-
typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
|
|
1613
|
-
Reflect.deleteProperty(typography, "listStyle");
|
|
1614
|
-
return typography;
|
|
1615
|
-
})
|
|
1616
|
-
}).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
|
|
1617
|
-
message: "A source canvas belongs to a reference snapshot.",
|
|
1618
|
-
path: ["sourceCanvasId"]
|
|
1619
|
-
}).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
|
|
1620
|
-
message: "A published revision belongs to a source style and canvas.",
|
|
1621
|
-
path: ["sourceRevision"]
|
|
1548
|
+
//#region ../../packages/contract/src/canvas/canvas-export-settings.schema.ts
|
|
1549
|
+
const format = z.enum(["png", "jpeg"]);
|
|
1550
|
+
const scale = z.number().positive();
|
|
1551
|
+
const canvasExportSettingsSchema = z.strictObject({
|
|
1552
|
+
format: format.optional(),
|
|
1553
|
+
scale: scale.optional()
|
|
1622
1554
|
});
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
"subscript",
|
|
1628
|
-
"superscript"
|
|
1629
|
-
]).optional(),
|
|
1630
|
-
overrides: z.partialRecord(z.enum([
|
|
1631
|
-
"fontWeight",
|
|
1632
|
-
"fontStyle",
|
|
1633
|
-
"fontVariationSettings",
|
|
1634
|
-
"fontOpticalSizing",
|
|
1635
|
-
"textDecorationLine",
|
|
1636
|
-
"textDecorationStyle",
|
|
1637
|
-
"textDecorationColor",
|
|
1638
|
-
"textDecorationThickness",
|
|
1639
|
-
"textUnderlineOffset",
|
|
1640
|
-
"textDecorationSkipInk"
|
|
1641
|
-
]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
|
|
1642
|
-
}).strict();
|
|
1643
|
-
|
|
1644
|
-
//#endregion
|
|
1645
|
-
//#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
|
|
1646
|
-
const fillsSchema = canvasPaintSchema.array().optional();
|
|
1647
|
-
/** What one rich text run stores besides its text, which the owner list of paint blends reads. */
|
|
1648
|
-
const canvasRichTextRunPaintSchema = z.object({ fills: fillsSchema });
|
|
1649
|
-
const characterFormattingSchema = canvasTextParagraphSchema.pick({
|
|
1650
|
-
paragraphSpacing: true,
|
|
1651
|
-
paragraphIndent: true,
|
|
1652
|
-
listSpacing: true,
|
|
1653
|
-
wrapStyle: true
|
|
1654
|
-
}).extend({
|
|
1655
|
-
hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
|
|
1656
|
-
verticalTrim: canvasTypographySchema.shape.verticalTrim,
|
|
1657
|
-
stroke: canvasTypographySchema.shape.stroke.nullable(),
|
|
1658
|
-
decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
|
|
1659
|
-
backgroundBlendMode: canvasBlendModeSchema.optional()
|
|
1660
|
-
}).strip();
|
|
1661
|
-
const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
|
|
1662
|
-
const richStylesOf = (value) => {
|
|
1663
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
1664
|
-
const entries = Object.entries(value);
|
|
1665
|
-
if (entries.some(([property, styleValue]) => !CANVAS_RICH_TEXT_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
|
|
1666
|
-
return Object.fromEntries(entries);
|
|
1667
|
-
};
|
|
1668
|
-
const richMetadataOf = (value) => {
|
|
1669
|
-
const sourcePath = Reflect.get(value, "sourcePath");
|
|
1670
|
-
return {
|
|
1671
|
-
...Object.fromEntries(Object.entries(value).filter(([key]) => ![
|
|
1672
|
-
"text",
|
|
1673
|
-
"href",
|
|
1674
|
-
"sourcePath",
|
|
1675
|
-
"styles",
|
|
1676
|
-
"fills",
|
|
1677
|
-
"stroke",
|
|
1678
|
-
"decorationBlendMode",
|
|
1679
|
-
"backgroundBlendMode",
|
|
1680
|
-
"paragraph",
|
|
1681
|
-
"paragraphSpacing",
|
|
1682
|
-
"paragraphIndent",
|
|
1683
|
-
"listSpacing",
|
|
1684
|
-
"hangingPunctuation",
|
|
1685
|
-
"verticalTrim",
|
|
1686
|
-
"wrapStyle",
|
|
1687
|
-
"soft",
|
|
1688
|
-
"textStyle"
|
|
1689
|
-
].includes(key))),
|
|
1690
|
-
...typeof sourcePath === "string" && { sourcePath }
|
|
1691
|
-
};
|
|
1692
|
-
};
|
|
1693
|
-
const richChildrenOf = (values) => {
|
|
1694
|
-
const result = [];
|
|
1695
|
-
const pending = values.toReversed().map((value) => ({
|
|
1696
|
-
value,
|
|
1697
|
-
target: result
|
|
1698
|
-
}));
|
|
1699
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
1700
|
-
while (pending.length > 0) {
|
|
1701
|
-
const task = pending.pop();
|
|
1702
|
-
if (task === void 0) continue;
|
|
1703
|
-
if ("done" in task) {
|
|
1704
|
-
ancestors.delete(task.done);
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
const children = [];
|
|
1708
|
-
const node = richNodeOf(task.value, children);
|
|
1709
|
-
if (node === null) return null;
|
|
1710
|
-
task.target.push(node);
|
|
1711
|
-
if (node.kind !== "span") continue;
|
|
1712
|
-
const value = task.value;
|
|
1713
|
-
if (typeof value !== "object" || value === null || ancestors.has(value)) return null;
|
|
1714
|
-
ancestors.add(value);
|
|
1715
|
-
pending.push({ done: value });
|
|
1716
|
-
const nested = Reflect.get(value, "children");
|
|
1717
|
-
if (!Array.isArray(nested)) return null;
|
|
1718
|
-
const candidates = nested;
|
|
1719
|
-
for (const child of candidates.toReversed()) pending.push({
|
|
1720
|
-
value: child,
|
|
1721
|
-
target: children
|
|
1722
|
-
});
|
|
1723
|
-
}
|
|
1724
|
-
return result;
|
|
1725
|
-
};
|
|
1726
|
-
const richBreakOf = (value) => {
|
|
1727
|
-
const soft = Reflect.get(value, "soft");
|
|
1728
|
-
if (soft !== void 0 && soft !== true) return null;
|
|
1729
|
-
return {
|
|
1730
|
-
...richMetadataOf(value),
|
|
1731
|
-
kind: "break",
|
|
1732
|
-
...soft === true && { soft }
|
|
1733
|
-
};
|
|
1734
|
-
};
|
|
1735
|
-
const richNodeOf = (value, children) => {
|
|
1736
|
-
if (typeof value !== "object" || value === null) return null;
|
|
1737
|
-
const kind = Reflect.get(value, "kind");
|
|
1738
|
-
const metadata = richMetadataOf(value);
|
|
1739
|
-
if (kind === "break") return richBreakOf(value);
|
|
1740
|
-
if (kind === "text") {
|
|
1741
|
-
const text = Reflect.get(value, "text");
|
|
1742
|
-
return typeof text === "string" ? {
|
|
1743
|
-
...metadata,
|
|
1744
|
-
kind,
|
|
1745
|
-
text
|
|
1746
|
-
} : null;
|
|
1747
|
-
}
|
|
1748
|
-
if (kind !== "span") return null;
|
|
1749
|
-
const values = Reflect.get(value, "children");
|
|
1750
|
-
const styles = richStylesOf(Reflect.get(value, "styles"));
|
|
1751
|
-
const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
|
|
1752
|
-
const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
|
|
1753
|
-
const formatting = characterFormattingSchema.safeParse(value);
|
|
1754
|
-
const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
|
|
1755
|
-
if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
|
|
1756
|
-
const href = safeHref(Reflect.get(value, "href"));
|
|
1757
|
-
return {
|
|
1758
|
-
...metadata,
|
|
1759
|
-
kind,
|
|
1760
|
-
styles,
|
|
1761
|
-
children,
|
|
1762
|
-
...textStyle.data !== void 0 && { textStyle: textStyle.data },
|
|
1763
|
-
...fills.data !== void 0 && { fills: fills.data },
|
|
1764
|
-
...paragraph.data !== void 0 && { paragraph: paragraph.data },
|
|
1765
|
-
...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
|
|
1766
|
-
...href !== void 0 && { href }
|
|
1767
|
-
};
|
|
1768
|
-
};
|
|
1769
|
-
const richTextLeafValue = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
|
|
1770
|
-
const canvasRichTextValueOf = (nodes) => {
|
|
1771
|
-
const pending = nodes.toReversed();
|
|
1772
|
-
const text = [];
|
|
1773
|
-
while (pending.length > 0) {
|
|
1774
|
-
const node = pending.pop();
|
|
1775
|
-
if (node === void 0) break;
|
|
1776
|
-
if (node.kind === "span") for (const child of node.children.toReversed()) pending.push(child);
|
|
1777
|
-
else text.push(richTextLeafValue(node));
|
|
1778
|
-
}
|
|
1779
|
-
return text.join("");
|
|
1780
|
-
};
|
|
1781
|
-
const canvasRichTextOf = (node) => {
|
|
1782
|
-
const props = node.props;
|
|
1783
|
-
if (props === void 0 || !Array.isArray(props["richText"])) return [];
|
|
1784
|
-
const rich = richChildrenOf(props["richText"]);
|
|
1785
|
-
if (rich === null) return [];
|
|
1786
|
-
const text = props["text"];
|
|
1787
|
-
return canvasRichTextValueOf(rich) === text ? rich : [];
|
|
1788
|
-
};
|
|
1789
|
-
const hasCanvasRichTextPaints = (node) => {
|
|
1790
|
-
const pending = [...canvasRichTextOf(node)];
|
|
1791
|
-
while (pending.length > 0) {
|
|
1792
|
-
const run = pending.pop();
|
|
1793
|
-
if (run?.kind !== "span") continue;
|
|
1794
|
-
if (run.fills !== void 0) return true;
|
|
1795
|
-
for (const child of run.children) pending.push(child);
|
|
1796
|
-
}
|
|
1797
|
-
return false;
|
|
1798
|
-
};
|
|
1799
|
-
/** Existing-link edits retain authored formatting, including nested descendants. */
|
|
1800
|
-
const canvasRichTextLinkOf = (runs) => {
|
|
1801
|
-
const destinations = /* @__PURE__ */ new Set();
|
|
1802
|
-
const visit = (nodes, inherited) => {
|
|
1803
|
-
for (const node of nodes) if (node.kind === "span") visit(node.children, node.href ?? inherited);
|
|
1804
|
-
else destinations.add(inherited);
|
|
1805
|
-
};
|
|
1806
|
-
visit(runs);
|
|
1807
|
-
return destinations.size === 1 ? [...destinations][0] ?? null : null;
|
|
1808
|
-
};
|
|
1809
|
-
/**
|
|
1810
|
-
* The style text a run edit clears: the properties it sets, and for a stroke edit the style text
|
|
1811
|
-
* that copies a stroke, since the stroke value owns it.
|
|
1812
|
-
*/
|
|
1813
|
-
const canvasRunStylesClearedBy = (command) => [...Object.keys(command.styles), ...command.stroke === void 0 ? [] : [
|
|
1814
|
-
"WebkitTextStrokeWidth",
|
|
1815
|
-
"WebkitTextStrokeColor",
|
|
1816
|
-
"--canvas-text-stroke-alignment"
|
|
1817
|
-
]];
|
|
1555
|
+
const canvasExportSettingsPatchSchema = z.strictObject({
|
|
1556
|
+
format: format.nullable().optional(),
|
|
1557
|
+
scale: scale.nullable().optional()
|
|
1558
|
+
}).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
|
|
1818
1559
|
|
|
1819
1560
|
//#endregion
|
|
1820
1561
|
//#region ../../packages/contract/src/shared/blob.schema.ts
|
|
@@ -1871,1183 +1612,790 @@ const canvasImageAssetIdentityFromPath = (path) => {
|
|
|
1871
1612
|
};
|
|
1872
1613
|
|
|
1873
1614
|
//#endregion
|
|
1874
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1875
|
-
const
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
const completeCanvasFontInputSchema = canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() });
|
|
1888
|
-
const reserveCanvasFontInputSchema = completeCanvasFontInputSchema.extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
|
|
1889
|
-
const completeCanvasFontOutputSchema = z.object({ path: z.string().startsWith("/v1/canvas-assets/") });
|
|
1890
|
-
const reserveCanvasFontOutputSchema = completeCanvasFontOutputSchema.extend({ upload: signedUploadSchema });
|
|
1891
|
-
const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
|
|
1892
|
-
const copyCanvasFontsInputSchema = z.object({
|
|
1893
|
-
canvasId: z.uuid(),
|
|
1894
|
-
sources: z.array(canvasFontAssetIdentitySchema).min(1)
|
|
1615
|
+
//#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
|
|
1616
|
+
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
1617
|
+
const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
|
|
1618
|
+
const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
|
|
1619
|
+
/** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
|
|
1620
|
+
const FOR_CALLER = { forCaller: true };
|
|
1621
|
+
/**
|
|
1622
|
+
* The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
|
|
1623
|
+
* writes that format may make is `refuseUnsafeWriterFormat`'s call.
|
|
1624
|
+
*/
|
|
1625
|
+
const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
|
|
1626
|
+
description: `The document format this client writes. The current format is ${String(15)}.`,
|
|
1627
|
+
examples: [15]
|
|
1895
1628
|
});
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
const
|
|
1903
|
-
if (
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1629
|
+
/**
|
|
1630
|
+
* Refuses a write its client's format could get wrong. A client whose format differs from the
|
|
1631
|
+
* current one only in its number may still name changes, but a whole value it sends may lack
|
|
1632
|
+
* fields added since, so that needs the current format.
|
|
1633
|
+
*/
|
|
1634
|
+
const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
|
|
1635
|
+
const writer = canvasWriterFormat(documentFormatVersion);
|
|
1636
|
+
if (writer === "current" || writer === "number-only" && writes === "names") return;
|
|
1637
|
+
context.addIssue({
|
|
1638
|
+
code: "custom",
|
|
1639
|
+
path: ["documentFormatVersion"],
|
|
1640
|
+
message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
|
|
1641
|
+
params: FOR_CALLER,
|
|
1642
|
+
input: documentFormatVersion
|
|
1643
|
+
});
|
|
1908
1644
|
};
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
const
|
|
1645
|
+
const canvasPreservedFontAppearanceSchema = z.object({
|
|
1646
|
+
signature: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
1647
|
+
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
1648
|
+
image: z.string().refine((image) => image.startsWith("data:image/jpeg;base64,") || canvasImageAssetIdentityFromPath(image) !== null),
|
|
1649
|
+
families: z.array(z.string().min(1)).min(1)
|
|
1650
|
+
});
|
|
1651
|
+
const canvasSceneBoxSchema = z.object({
|
|
1652
|
+
x: z.number(),
|
|
1653
|
+
y: z.number(),
|
|
1654
|
+
width: z.number().nonnegative(),
|
|
1655
|
+
height: z.number().nonnegative()
|
|
1656
|
+
});
|
|
1657
|
+
const canvasConstraintSchema = z.enum([
|
|
1658
|
+
"start",
|
|
1659
|
+
"center",
|
|
1660
|
+
"end",
|
|
1661
|
+
"stretch",
|
|
1662
|
+
"scale"
|
|
1663
|
+
]);
|
|
1664
|
+
const canvasNodeConstraintsSchema = z.object({
|
|
1665
|
+
x: canvasConstraintSchema,
|
|
1666
|
+
y: canvasConstraintSchema
|
|
1667
|
+
});
|
|
1668
|
+
const canvasNodeLabelOriginSchema = z.enum([
|
|
1669
|
+
"source",
|
|
1670
|
+
"generated",
|
|
1671
|
+
"content",
|
|
1672
|
+
"user"
|
|
1673
|
+
]);
|
|
1674
|
+
const canvasSceneNodeSchema = z.looseObject({
|
|
1675
|
+
id: z.string().min(1),
|
|
1676
|
+
label: z.string(),
|
|
1677
|
+
component: z.string().min(1),
|
|
1678
|
+
labelOrigin: canvasNodeLabelOriginSchema.optional(),
|
|
1679
|
+
visible: z.boolean().optional(),
|
|
1680
|
+
locked: z.boolean().optional(),
|
|
1681
|
+
constraints: canvasNodeConstraintsSchema.optional(),
|
|
1682
|
+
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
1683
|
+
layout: canvasNodeLayoutSchema.optional(),
|
|
1684
|
+
responsive: z.never().optional(),
|
|
1685
|
+
appearance: canvasAppearanceValuesSchema.optional(),
|
|
1686
|
+
exportSettings: canvasExportSettingsSchema.optional(),
|
|
1687
|
+
typography: canvasAuthoredTypographySchema.optional(),
|
|
1688
|
+
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
1689
|
+
geometry: canvasGeometrySchema.optional(),
|
|
1690
|
+
compositing: z.never({ error: CANVAS_COMPOSITING_RETIRED }).optional(),
|
|
1691
|
+
props: z.record(z.string(), z.unknown()).optional(),
|
|
1692
|
+
box: canvasSceneBoxSchema.optional()
|
|
1693
|
+
});
|
|
1694
|
+
const canvasSceneRelationshipSchema = z.object({
|
|
1695
|
+
parentId: z.string().min(1),
|
|
1696
|
+
sortKey: z.string().min(1)
|
|
1697
|
+
});
|
|
1698
|
+
const canvasSceneDocumentSchema = z.object({
|
|
1699
|
+
version: z.literal(15),
|
|
1700
|
+
nodes: z.record(z.string(), canvasSceneNodeSchema),
|
|
1701
|
+
relationships: z.record(z.string(), canvasSceneRelationshipSchema),
|
|
1702
|
+
tombstones: z.record(z.string(), z.literal(true)).default({})
|
|
1703
|
+
});
|
|
1704
|
+
const legacyRecordSchema = z.record(z.string(), z.unknown());
|
|
1705
|
+
/** Known old scenes are adapted in memory; only an explicit mutation persists the new format. */
|
|
1706
|
+
const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
|
|
1707
|
+
const blob = legacyRecordSchema.safeParse(value).data;
|
|
1708
|
+
if (blob === void 0) return value;
|
|
1709
|
+
if (Object.keys(blob).length === 0) return emptyCanvasSceneDocument();
|
|
1710
|
+
return adaptCanvasDocumentFormat(blob);
|
|
1711
|
+
}, canvasSceneDocumentSchema);
|
|
1712
|
+
/** A document's version, or the read result that refuses it before anything else is read. */
|
|
1713
|
+
const refusedVersionOf = (blob) => {
|
|
1714
|
+
const version = blob["version"];
|
|
1715
|
+
if (version !== void 0 && (typeof version !== "number" || !Number.isSafeInteger(version) || version < 1)) return { status: "invalid" };
|
|
1716
|
+
if (version !== void 0 && version > 15) return {
|
|
1717
|
+
status: "unsupported",
|
|
1718
|
+
formatVersion: version
|
|
1719
|
+
};
|
|
1720
|
+
return null;
|
|
1721
|
+
};
|
|
1722
|
+
const readCanvasSceneDocument = (blob) => {
|
|
1723
|
+
if (blob === void 0) return { status: "missing" };
|
|
1724
|
+
const refused = refusedVersionOf(blob);
|
|
1725
|
+
if (refused !== null) return refused;
|
|
1726
|
+
const parsed = canvasReadableSceneDocumentSchema.safeParse(blob);
|
|
1727
|
+
return parsed.success ? {
|
|
1728
|
+
status: "current",
|
|
1729
|
+
document: parsed.data
|
|
1730
|
+
} : { status: "invalid" };
|
|
1731
|
+
};
|
|
1732
|
+
const emptyCanvasSceneDocument = () => ({
|
|
1733
|
+
version: 15,
|
|
1734
|
+
nodes: { root: {
|
|
1735
|
+
id: "root",
|
|
1736
|
+
label: "Canvas",
|
|
1737
|
+
component: "root",
|
|
1738
|
+
labelOrigin: "generated",
|
|
1739
|
+
visible: true,
|
|
1740
|
+
locked: false,
|
|
1741
|
+
styles: {}
|
|
1742
|
+
} },
|
|
1743
|
+
relationships: {},
|
|
1744
|
+
tombstones: {}
|
|
1745
|
+
});
|
|
1746
|
+
const shellSchema = canvasSceneDocumentSchema.extend({
|
|
1747
|
+
nodes: z.record(z.string(), z.unknown()),
|
|
1748
|
+
relationships: z.record(z.string(), z.unknown())
|
|
1749
|
+
});
|
|
1750
|
+
|
|
1751
|
+
//#endregion
|
|
1752
|
+
//#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
|
|
1753
|
+
const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
|
|
1754
|
+
const MAX_RENDER_KIND_LENGTH = 100;
|
|
1755
|
+
/**
|
|
1756
|
+
* What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
|
|
1757
|
+
* it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
|
|
1758
|
+
* was made, for a layer the browser lays out.
|
|
1759
|
+
*/
|
|
1760
|
+
const canvasBoxSourceSchema = z.enum([
|
|
1761
|
+
"placed",
|
|
1762
|
+
"placed-before-transform",
|
|
1763
|
+
"recorded"
|
|
1764
|
+
]);
|
|
1765
|
+
/** Present only on a read that holds a `recorded` box. */
|
|
1766
|
+
const boxNoteSchema = z.string().min(1).optional();
|
|
1767
|
+
const canvasInspectNodeSummarySchema = z.object({
|
|
1768
|
+
id: z.string().min(1),
|
|
1769
|
+
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
1770
|
+
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
1771
|
+
parentId: z.string().min(1).nullable(),
|
|
1772
|
+
childCount: z.number().int().min(0),
|
|
1773
|
+
box: canvasSceneBoxSchema.nullable(),
|
|
1774
|
+
boxSource: canvasBoxSourceSchema.optional(),
|
|
1775
|
+
propertySections: z.array(canvasPropertySectionSchema)
|
|
1776
|
+
});
|
|
1777
|
+
const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
1778
|
+
const inspectCanvasOutputSchema = z.object({
|
|
1916
1779
|
canvasId: z.uuid(),
|
|
1917
|
-
|
|
1780
|
+
openUrl: z.url(),
|
|
1781
|
+
title: z.string().min(1),
|
|
1782
|
+
version: z.number().int().positive(),
|
|
1783
|
+
nodeCount: z.number().int().min(0),
|
|
1784
|
+
rootChildCount: z.number().int().min(0),
|
|
1785
|
+
bounds: canvasSceneBoxSchema.nullable(),
|
|
1786
|
+
kinds: z.record(z.string(), z.number().int().min(0)),
|
|
1787
|
+
boxNote: boxNoteSchema,
|
|
1788
|
+
next: z.array(z.string().min(1))
|
|
1918
1789
|
});
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
|
|
1922
|
-
bytes: z.number().int().positive(),
|
|
1923
|
-
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
1924
|
-
}), canvasAssetUploadIdentitySchema.extend({
|
|
1925
|
-
kind: z.literal("font"),
|
|
1926
|
-
contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
|
|
1927
|
-
bytes: z.number().int().positive(),
|
|
1928
|
-
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
1929
|
-
})]);
|
|
1930
|
-
const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
|
|
1931
|
-
kind: z.literal("image"),
|
|
1932
|
-
width: z.number().int().positive(),
|
|
1933
|
-
height: z.number().int().positive()
|
|
1934
|
-
}), z.strictObject({
|
|
1935
|
-
kind: z.literal("font"),
|
|
1936
|
-
family: z.string().min(1),
|
|
1937
|
-
subfamily: z.string(),
|
|
1938
|
-
style: z.enum([
|
|
1939
|
-
"normal",
|
|
1940
|
-
"italic",
|
|
1941
|
-
"oblique"
|
|
1942
|
-
]),
|
|
1943
|
-
minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
|
|
1944
|
-
maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
|
|
1945
|
-
}).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
|
|
1946
|
-
const canvasAssetUploadOutputSchema = z.strictObject({
|
|
1790
|
+
const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
|
|
1791
|
+
const inspectCanvasTreeOutputSchema = z.object({
|
|
1947
1792
|
canvasId: z.uuid(),
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1793
|
+
version: z.number().int().positive(),
|
|
1794
|
+
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
1795
|
+
boxNote: boxNoteSchema
|
|
1796
|
+
});
|
|
1797
|
+
const inspectCanvasNodeInputSchema = z.object({
|
|
1798
|
+
canvasId: z.uuid(),
|
|
1799
|
+
nodeId: z.string().min(1)
|
|
1800
|
+
});
|
|
1801
|
+
const inspectCanvasNodeOutputSchema = z.object({
|
|
1802
|
+
canvasId: z.uuid(),
|
|
1803
|
+
version: z.number().int().positive(),
|
|
1804
|
+
node: canvasInspectNodeSummarySchema.extend({
|
|
1805
|
+
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
1806
|
+
layout: canvasNodeLayoutSchema.optional(),
|
|
1807
|
+
appearance: canvasAppearanceValuesSchema.optional(),
|
|
1808
|
+
geometry: canvasGeometrySchema.optional(),
|
|
1809
|
+
typography: canvasAuthoredTypographySchema.optional(),
|
|
1810
|
+
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
1811
|
+
props: z.record(z.string(), z.unknown()),
|
|
1812
|
+
children: z.array(z.string().min(1))
|
|
1813
|
+
}),
|
|
1814
|
+
boxNote: boxNoteSchema,
|
|
1815
|
+
next: z.array(z.string().min(1))
|
|
1816
|
+
});
|
|
1959
1817
|
|
|
1960
1818
|
//#endregion
|
|
1961
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1819
|
+
//#region ../../packages/contract/src/canvas/canvas-placement.schema.ts
|
|
1820
|
+
const coordinate = z.number();
|
|
1821
|
+
const extent = z.number().positive();
|
|
1822
|
+
const placedBox = z.strictObject({
|
|
1823
|
+
x: coordinate,
|
|
1824
|
+
y: coordinate,
|
|
1825
|
+
width: extent,
|
|
1826
|
+
height: extent
|
|
1827
|
+
});
|
|
1828
|
+
/** Where the person who started the request was looking; a preference, never a camera command. */
|
|
1829
|
+
const canvasInitiatingViewHintSchema = z.strictObject({
|
|
1830
|
+
pageId: z.string().min(1),
|
|
1831
|
+
bounds: placedBox
|
|
1832
|
+
});
|
|
1833
|
+
/** How a new top-level screen or copied set is placed on its page. Omitted, positions stay as authored. */
|
|
1834
|
+
const canvasPlacementIntentSchema = z.discriminatedUnion("kind", [
|
|
1835
|
+
z.strictObject({
|
|
1836
|
+
kind: z.literal("auto"),
|
|
1837
|
+
view: canvasInitiatingViewHintSchema.optional()
|
|
1838
|
+
}),
|
|
1839
|
+
z.strictObject({
|
|
1840
|
+
kind: z.literal("near"),
|
|
1841
|
+
anchorNodeId: z.string().min(1),
|
|
1842
|
+
side: z.enum(["right", "below"])
|
|
1843
|
+
}),
|
|
1844
|
+
z.strictObject({
|
|
1845
|
+
kind: z.literal("explicit"),
|
|
1846
|
+
x: coordinate,
|
|
1847
|
+
y: coordinate
|
|
1848
|
+
})
|
|
1979
1849
|
]);
|
|
1980
|
-
|
|
1981
|
-
const
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1850
|
+
/** Where a committed change put its roots, as saved at its own revision. */
|
|
1851
|
+
const canvasPlacementResultSchema = z.strictObject({
|
|
1852
|
+
pageId: z.string().min(1),
|
|
1853
|
+
bounds: placedBox,
|
|
1854
|
+
roots: z.array(z.strictObject({
|
|
1855
|
+
nodeId: z.string().min(1),
|
|
1856
|
+
box: placedBox
|
|
1857
|
+
})).min(1)
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
//#endregion
|
|
1861
|
+
//#region ../../packages/contract/src/canvas/canvas-conversion-draft.schema.ts
|
|
1862
|
+
const temporaryIdSchema = z.string().min(1);
|
|
1863
|
+
const canvasConversionIssueSchema = z.object({
|
|
1864
|
+
code: z.enum([
|
|
1865
|
+
"asset-unavailable",
|
|
1866
|
+
"content-omitted",
|
|
1867
|
+
"cross-origin-frame",
|
|
1868
|
+
"nodes-truncated",
|
|
1869
|
+
"responsive-behavior-not-editable",
|
|
1870
|
+
"style-degraded",
|
|
1871
|
+
"unsupported-surface",
|
|
1872
|
+
"vertical-writing-unsupported"
|
|
1873
|
+
]),
|
|
1874
|
+
message: z.string().min(1),
|
|
1875
|
+
temporaryId: temporaryIdSchema.optional()
|
|
1876
|
+
});
|
|
1877
|
+
/** Source features that CSS cannot draw; a conversion writes the closest CSS and counts each. */
|
|
1878
|
+
const CANVAS_UNSUPPORTED_FEATURES = [
|
|
1879
|
+
"text-stroke-inside",
|
|
1880
|
+
"text-stroke-outside-translucent",
|
|
1881
|
+
"text-stroke-paints",
|
|
1882
|
+
"text-inner-shadow",
|
|
1883
|
+
"text-shadow-spread",
|
|
1884
|
+
"text-shadow-blend",
|
|
1885
|
+
"text-background-blur",
|
|
1886
|
+
"progressive-layer-blur",
|
|
1887
|
+
"progressive-background-blur",
|
|
1888
|
+
"blend-plus-darker",
|
|
1889
|
+
"blend-linear-burn",
|
|
1890
|
+
"image-exposure",
|
|
1891
|
+
"image-contrast",
|
|
1892
|
+
"image-saturation",
|
|
1893
|
+
"image-temperature",
|
|
1894
|
+
"image-tint",
|
|
1895
|
+
"image-highlights",
|
|
1896
|
+
"image-shadows",
|
|
1897
|
+
"effect-noise",
|
|
1898
|
+
"effect-texture",
|
|
1899
|
+
"effect-glass",
|
|
1900
|
+
"mask-source"
|
|
1992
1901
|
];
|
|
1993
|
-
const
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
isEscaped: false
|
|
2029
|
-
};
|
|
2030
|
-
if (character === "\\") return {
|
|
2031
|
-
...state,
|
|
2032
|
-
isEscaped: true
|
|
2033
|
-
};
|
|
2034
|
-
if (state.quote !== "") return {
|
|
2035
|
-
...state,
|
|
2036
|
-
quote: state.quote === character ? "" : state.quote
|
|
2037
|
-
};
|
|
2038
|
-
if (["\"", "'"].includes(character)) return {
|
|
2039
|
-
...state,
|
|
2040
|
-
quote: character
|
|
2041
|
-
};
|
|
2042
|
-
const delta = [
|
|
2043
|
-
"(",
|
|
2044
|
-
"[",
|
|
2045
|
-
"{"
|
|
2046
|
-
].includes(character) ? 1 : [
|
|
2047
|
-
")",
|
|
2048
|
-
"]",
|
|
2049
|
-
"}"
|
|
2050
|
-
].includes(character) ? -1 : 0;
|
|
2051
|
-
return {
|
|
2052
|
-
...state,
|
|
2053
|
-
depth: state.depth + delta
|
|
2054
|
-
};
|
|
1902
|
+
const canvasUnsupportedFeatureSchema = z.enum(CANVAS_UNSUPPORTED_FEATURES);
|
|
1903
|
+
const canvasConversionReportSchema = z.object({
|
|
1904
|
+
nodeCount: z.number().int().positive(),
|
|
1905
|
+
unsupportedFeatures: z.array(z.object({
|
|
1906
|
+
feature: canvasUnsupportedFeatureSchema,
|
|
1907
|
+
count: z.number().int().positive()
|
|
1908
|
+
})).optional(),
|
|
1909
|
+
sourceNodeCount: z.number().int().positive().optional(),
|
|
1910
|
+
collapsedNodeCount: z.number().int().nonnegative().optional(),
|
|
1911
|
+
collapsedWrapperNodeCount: z.number().int().nonnegative().optional(),
|
|
1912
|
+
collapsedNeutralWrapperNodeCount: z.number().int().nonnegative().optional(),
|
|
1913
|
+
collapsedTransferredWrapperNodeCount: z.number().int().nonnegative().optional(),
|
|
1914
|
+
layoutContainerCount: z.number().int().nonnegative().optional(),
|
|
1915
|
+
removedLeafNodeCount: z.number().int().nonnegative().optional(),
|
|
1916
|
+
retainedSemanticOwnerNodeCount: z.number().int().nonnegative().optional(),
|
|
1917
|
+
truncatedNodeCount: z.number().int().nonnegative().optional(),
|
|
1918
|
+
addedLayoutNodeCount: z.number().int().nonnegative().optional(),
|
|
1919
|
+
issues: z.array(canvasConversionIssueSchema)
|
|
1920
|
+
});
|
|
1921
|
+
const canvasSubtreeDraftNodeSchema = canvasSceneNodeSchema.omit({ id: true }).extend({ temporaryId: temporaryIdSchema });
|
|
1922
|
+
const canvasSubtreeDraftRelationshipSchema = z.object({
|
|
1923
|
+
temporaryId: temporaryIdSchema,
|
|
1924
|
+
parentTemporaryId: temporaryIdSchema,
|
|
1925
|
+
sortKey: z.string().min(1)
|
|
1926
|
+
});
|
|
1927
|
+
/**
|
|
1928
|
+
* A report that cannot be read says so, rather than reading as "nothing left out". The kind is an
|
|
1929
|
+
* existing one, because installed clients check kinds strictly and would refuse the whole answer.
|
|
1930
|
+
*/
|
|
1931
|
+
const UNREADABLE_REPORT = {
|
|
1932
|
+
nodeCount: 0,
|
|
1933
|
+
issues: [{
|
|
1934
|
+
code: "content-omitted",
|
|
1935
|
+
message: "The converter's report could not be read, so what it left out of this insert is unknown."
|
|
1936
|
+
}]
|
|
2055
1937
|
};
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
state = componentStateAfter(state, character);
|
|
2068
|
-
if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
|
|
2069
|
-
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
2070
|
-
token = "";
|
|
2071
|
-
} else token += character;
|
|
1938
|
+
const canvasSubtreeDraftSchema = z.object({
|
|
1939
|
+
version: z.literal(1),
|
|
1940
|
+
rootTemporaryId: temporaryIdSchema,
|
|
1941
|
+
nodes: z.array(canvasSubtreeDraftNodeSchema).min(1),
|
|
1942
|
+
relationships: z.array(canvasSubtreeDraftRelationshipSchema),
|
|
1943
|
+
report: canvasConversionReportSchema.catch(UNREADABLE_REPORT)
|
|
1944
|
+
}).transform((draft) => ({
|
|
1945
|
+
...draft,
|
|
1946
|
+
report: {
|
|
1947
|
+
...draft.report,
|
|
1948
|
+
nodeCount: draft.nodes.length
|
|
2072
1949
|
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
parts[3] ?? omittedGridLine(column)
|
|
2087
|
-
][index] ?? value;
|
|
2088
|
-
};
|
|
2089
|
-
const implicitGridValues = (row, column, hasAutoRows) => {
|
|
2090
|
-
const tokens = canvasCssTokens(hasAutoRows ? row : column);
|
|
2091
|
-
const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
|
|
2092
|
-
const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
|
|
2093
|
-
return [
|
|
2094
|
-
hasAutoRows ? "none" : row,
|
|
2095
|
-
hasAutoRows ? column : "none",
|
|
2096
|
-
"none",
|
|
2097
|
-
hasAutoRows && size !== "" ? size : "auto",
|
|
2098
|
-
!hasAutoRows && size !== "" ? size : "auto",
|
|
2099
|
-
flow
|
|
2100
|
-
];
|
|
2101
|
-
};
|
|
2102
|
-
const gridTemplateValue = (property, value, index) => {
|
|
2103
|
-
if (/^(?:none|initial|unset)$/iu.test(value)) return [
|
|
2104
|
-
"none",
|
|
2105
|
-
"none",
|
|
2106
|
-
"none",
|
|
2107
|
-
"auto",
|
|
2108
|
-
"auto",
|
|
2109
|
-
"row"
|
|
2110
|
-
][index] ?? value;
|
|
2111
|
-
const parts = canvasCssTokens(value, "/");
|
|
2112
|
-
const row = parts[0] ?? value;
|
|
2113
|
-
const column = parts[1];
|
|
2114
|
-
if (row === "" || column === "" || parts.length > 2) return value;
|
|
2115
|
-
const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
|
|
2116
|
-
const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
|
|
2117
|
-
if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
|
|
2118
|
-
if (hasAutoRows || hasAutoColumns) return value;
|
|
2119
|
-
const hasAreas = /["']/u.test(row);
|
|
2120
|
-
if (column === void 0 && !hasAreas) return value;
|
|
2121
|
-
return [
|
|
2122
|
-
hasAreas ? value : row,
|
|
2123
|
-
column ?? "none",
|
|
2124
|
-
hasAreas ? row : "none",
|
|
2125
|
-
"auto",
|
|
2126
|
-
"auto",
|
|
2127
|
-
"row"
|
|
2128
|
-
][index] ?? value;
|
|
2129
|
-
};
|
|
2130
|
-
const flexValues = (tokens) => {
|
|
2131
|
-
const numbers = [];
|
|
2132
|
-
let basis = "0%";
|
|
2133
|
-
for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
|
|
2134
|
-
else basis = token;
|
|
2135
|
-
return [
|
|
2136
|
-
numbers[0] ?? "1",
|
|
2137
|
-
numbers[1] ?? "1",
|
|
2138
|
-
basis
|
|
2139
|
-
];
|
|
2140
|
-
};
|
|
2141
|
-
const canvasCssShorthandValue = (property, value, index) => {
|
|
2142
|
-
if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
|
|
2143
|
-
if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
|
|
2144
|
-
if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
|
|
2145
|
-
const tokens = canvasCssTokens(value);
|
|
2146
|
-
if (property === "text-wrap") return index === 0 ? tokens.find((token) => /^(?:wrap|nowrap)$/u.test(token)) ?? "wrap" : tokens.find((token) => /^(?:auto|balance|pretty|stable)$/u.test(token)) ?? "auto";
|
|
2147
|
-
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";
|
|
2148
|
-
if (property === "flex") {
|
|
2149
|
-
if (value === "none") return [
|
|
2150
|
-
"0",
|
|
2151
|
-
"0",
|
|
2152
|
-
"auto"
|
|
2153
|
-
][index] ?? value;
|
|
2154
|
-
if (value === "initial") return [
|
|
2155
|
-
"0",
|
|
2156
|
-
"1",
|
|
2157
|
-
"auto"
|
|
2158
|
-
][index] ?? value;
|
|
2159
|
-
return flexValues(tokens)[index] ?? value;
|
|
2160
|
-
}
|
|
2161
|
-
return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
|
|
2162
|
-
};
|
|
2163
|
-
|
|
2164
|
-
//#endregion
|
|
2165
|
-
//#region ../../packages/contract/src/canvas/canvas-authored-css.lib.ts
|
|
2166
|
-
const canvasAdditionalStyleDeclarations = (node) => {
|
|
2167
|
-
if (node.additionalStyles === void 0) return {};
|
|
2168
|
-
return Object.fromEntries(node.additionalStyles.declarations.filter((declaration) => declaration.enabled).map((declaration) => [declaration.property, declaration.value]));
|
|
2169
|
-
};
|
|
2170
|
-
/** Additional-style controls exclusively own every property they expose, including when off. */
|
|
2171
|
-
const canvasAuthoredStyleDeclarations = (node) => {
|
|
2172
|
-
const controlledProperties = new Set(node.additionalStyles?.declarations.map((declaration) => declaration.property.toLowerCase()));
|
|
2173
|
-
return {
|
|
2174
|
-
...Object.fromEntries(Object.entries(node.styles).filter(([property]) => !controlledProperties.has(property.toLowerCase()))),
|
|
2175
|
-
...canvasAdditionalStyleDeclarations(node)
|
|
2176
|
-
};
|
|
2177
|
-
};
|
|
2178
|
-
const hasCanvasCssPriority = (value) => /!important\s*$/iu.test(String(value));
|
|
2179
|
-
const cssValue = (value, shouldPreserveCase) => {
|
|
2180
|
-
const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
|
|
2181
|
-
return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
|
|
2182
|
-
};
|
|
2183
|
-
const authoredLayoutValue = (node, property) => {
|
|
2184
|
-
let result = null;
|
|
2185
|
-
let isImportant = false;
|
|
2186
|
-
const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
|
|
2187
|
-
for (const [key, raw] of declarations) {
|
|
2188
|
-
const scope = canvasCssPropertyScope(key);
|
|
2189
|
-
const index = scope.indexOf(property);
|
|
2190
|
-
if (index === -1) continue;
|
|
2191
|
-
const isPriority = hasCanvasCssPriority(raw);
|
|
2192
|
-
if (isImportant && !isPriority) continue;
|
|
2193
|
-
const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
|
|
2194
|
-
result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
|
|
2195
|
-
isImportant = isPriority;
|
|
2196
|
-
}
|
|
2197
|
-
return result ?? void 0;
|
|
2198
|
-
};
|
|
2199
|
-
/**
|
|
2200
|
-
* Edits replace a node's style objects rather than changing them, so their identity keys the values
|
|
2201
|
-
* already read. Rendering a large document reads each property of each node many times.
|
|
2202
|
-
*/
|
|
2203
|
-
const readAuthoredValues = /* @__PURE__ */ new WeakMap();
|
|
2204
|
-
/** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
|
|
2205
|
-
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
2206
|
-
const known = readAuthoredValues.get(node.styles);
|
|
2207
|
-
const read = known !== void 0 && known.additionalStyles === node.additionalStyles ? known : {
|
|
2208
|
-
additionalStyles: node.additionalStyles,
|
|
2209
|
-
values: /* @__PURE__ */ new Map()
|
|
2210
|
-
};
|
|
2211
|
-
if (read !== known) readAuthoredValues.set(node.styles, read);
|
|
2212
|
-
if (read.values.has(property)) return read.values.get(property);
|
|
2213
|
-
const value = authoredLayoutValue(node, property);
|
|
2214
|
-
read.values.set(property, value);
|
|
2215
|
-
return value;
|
|
2216
|
-
};
|
|
2217
|
-
const canvasCssPixelValue = (value) => {
|
|
2218
|
-
if (value === void 0) return;
|
|
2219
|
-
return /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?$/u.test(value) ? Number(value.replace("px", "")) : void 0;
|
|
2220
|
-
};
|
|
2221
|
-
/** Named controls override only their own longhand, even beside an important shorthand. */
|
|
2222
|
-
const canvasLayoutPriorityDeclarations = (node, declarations) => {
|
|
2223
|
-
const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
|
|
2224
|
-
return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
|
|
2225
|
-
};
|
|
2226
|
-
const canvasWritingModeOf = (node, document) => {
|
|
2227
|
-
const visited = /* @__PURE__ */ new Set();
|
|
2228
|
-
let current = node;
|
|
2229
|
-
while (current !== void 0 && !visited.has(current.id)) {
|
|
2230
|
-
visited.add(current.id);
|
|
2231
|
-
const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
|
|
2232
|
-
if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
|
|
2233
|
-
if (document === void 0) break;
|
|
2234
|
-
const parentId = document.relationships[current.id]?.parentId;
|
|
2235
|
-
if (parentId === void 0) break;
|
|
2236
|
-
current = document.nodes[parentId];
|
|
2237
|
-
}
|
|
2238
|
-
return "horizontal-tb";
|
|
2239
|
-
};
|
|
2240
|
-
const canvasAxisStyleProperties = (node, axis, document) => {
|
|
2241
|
-
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
2242
|
-
return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
|
|
2243
|
-
};
|
|
2244
|
-
const canvasLayoutPositionOf = (node) => {
|
|
2245
|
-
const position = canvasAuthoredLayoutValueOf(node, "position");
|
|
2246
|
-
return node.layout?.position ?? (position === "absolute" || position === "fixed" || position === void 0 && node.box !== void 0 ? "absolute" : "flow");
|
|
2247
|
-
};
|
|
2248
|
-
/** Authored display wins over legacy presets; Grid has no Flex main axis. */
|
|
2249
|
-
const canvasLayoutFlowOf = (node) => {
|
|
2250
|
-
if (node === void 0) return "freeform";
|
|
2251
|
-
const display = canvasAuthoredLayoutValueOf(node, "display");
|
|
2252
|
-
if (display !== void 0) {
|
|
2253
|
-
if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
|
|
2254
|
-
if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
|
|
2255
|
-
return "freeform";
|
|
2256
|
-
}
|
|
2257
|
-
const container = node.layout?.container;
|
|
2258
|
-
if (container === void 0) return "freeform";
|
|
2259
|
-
return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
|
|
2260
|
-
};
|
|
2261
|
-
/** Read a Flex main axis in its inherited writing mode without persisting a preset. */
|
|
2262
|
-
const canvasLayoutMainAxisOf = (node, document) => {
|
|
2263
|
-
if (node === void 0) return void 0;
|
|
2264
|
-
if (canvasLayoutFlowOf(node) !== "flex") return void 0;
|
|
2265
|
-
const container = node.layout?.container;
|
|
2266
|
-
const css = (property) => canvasAuthoredLayoutValueOf(node, property);
|
|
2267
|
-
const direction = container?.direction ?? css("flex-direction") ?? "row";
|
|
2268
|
-
if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
|
|
2269
|
-
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
2270
|
-
return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
|
|
1950
|
+
}));
|
|
1951
|
+
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
1952
|
+
const editableFrameCaptureSchema = z.object({
|
|
1953
|
+
screenId: z.string().min(1),
|
|
1954
|
+
pageId: z.string().min(1),
|
|
1955
|
+
pictureNodeId: z.string().min(1).optional().describe("The capture's picture, which the frame replaces in place and whose id it keeps. Refused as capture-already-landed once the picture is a frame.")
|
|
1956
|
+
});
|
|
1957
|
+
const editableFrameInputBase = {
|
|
1958
|
+
canvasId: z.uuid(),
|
|
1959
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
1960
|
+
mutationId: z.uuid(),
|
|
1961
|
+
baseVersion: z.number().int().positive(),
|
|
1962
|
+
draft: canvasSubtreeDraftSchema
|
|
2271
1963
|
};
|
|
1964
|
+
/** An editable frame comes from exactly one screen layer or one capture, never both. */
|
|
1965
|
+
const createEditableFrameInputSchema = z.union([z.strictObject({
|
|
1966
|
+
...editableFrameInputBase,
|
|
1967
|
+
screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself."),
|
|
1968
|
+
position: z.strictObject({
|
|
1969
|
+
x: z.number(),
|
|
1970
|
+
y: z.number()
|
|
1971
|
+
}).optional().describe("Where the editor measured room for the frame below its screen.")
|
|
1972
|
+
}), z.strictObject({
|
|
1973
|
+
...editableFrameInputBase,
|
|
1974
|
+
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
1975
|
+
})]).superRefine((input, context) => {
|
|
1976
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
1977
|
+
});
|
|
1978
|
+
const createEditableFrameResultSchema = z.object({
|
|
1979
|
+
canvasId: z.uuid(),
|
|
1980
|
+
mutationId: z.uuid(),
|
|
1981
|
+
previousVersion: z.number().int().positive(),
|
|
1982
|
+
version: z.number().int().positive(),
|
|
1983
|
+
rootNodeId: z.string().min(1),
|
|
1984
|
+
idMap: z.record(temporaryIdSchema, z.string().min(1)),
|
|
1985
|
+
insertedNodeIds: z.array(z.string().min(1)),
|
|
1986
|
+
removedNodeIds: z.array(z.string().min(1)),
|
|
1987
|
+
boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
|
|
1988
|
+
affectedBounds: canvasSceneBoxSchema,
|
|
1989
|
+
/** Where requested placement saved the root; absent when the request asked for none. */
|
|
1990
|
+
placement: canvasPlacementResultSchema.optional()
|
|
1991
|
+
});
|
|
2272
1992
|
|
|
2273
1993
|
//#endregion
|
|
2274
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2275
|
-
const
|
|
2276
|
-
"
|
|
2277
|
-
"
|
|
2278
|
-
"
|
|
2279
|
-
"
|
|
2280
|
-
"
|
|
2281
|
-
"
|
|
2282
|
-
"
|
|
2283
|
-
"
|
|
2284
|
-
"
|
|
2285
|
-
"
|
|
2286
|
-
"
|
|
1994
|
+
//#region ../../packages/contract/src/canvas/canvas-render.consts.ts
|
|
1995
|
+
const RENDER_PHASES = [
|
|
1996
|
+
"queued",
|
|
1997
|
+
"claimed",
|
|
1998
|
+
"grant",
|
|
1999
|
+
"navigate",
|
|
2000
|
+
"document",
|
|
2001
|
+
"sources",
|
|
2002
|
+
"fonts",
|
|
2003
|
+
"layout",
|
|
2004
|
+
"target",
|
|
2005
|
+
"capture",
|
|
2006
|
+
"serialize",
|
|
2007
|
+
"compile",
|
|
2008
|
+
"commit",
|
|
2009
|
+
"upload",
|
|
2010
|
+
"complete"
|
|
2287
2011
|
];
|
|
2288
|
-
const
|
|
2289
|
-
"
|
|
2290
|
-
"
|
|
2291
|
-
"
|
|
2292
|
-
"
|
|
2012
|
+
const RENDER_STATES = [
|
|
2013
|
+
"queued",
|
|
2014
|
+
"running",
|
|
2015
|
+
"succeeded",
|
|
2016
|
+
"failed",
|
|
2017
|
+
"cancelled",
|
|
2018
|
+
"expired"
|
|
2019
|
+
];
|
|
2020
|
+
const RENDER_FAILURE_REASONS = [
|
|
2021
|
+
"VERSION_CHANGED",
|
|
2022
|
+
"TARGET_NOT_FOUND",
|
|
2023
|
+
"TARGET_INVALID",
|
|
2024
|
+
"OUTPUT_TOO_LARGE",
|
|
2025
|
+
"READINESS_TIMEOUT",
|
|
2026
|
+
"SOURCE_FAILED",
|
|
2027
|
+
"BROWSER_CRASH",
|
|
2028
|
+
"CAPTURE_FAILED",
|
|
2029
|
+
"CONVERSION_FAILED",
|
|
2030
|
+
"PREPARATION_FAILED",
|
|
2031
|
+
"UPLOAD_FAILED",
|
|
2032
|
+
"WORKER_UNAVAILABLE",
|
|
2033
|
+
"CANCELLED",
|
|
2034
|
+
"EXPIRED",
|
|
2035
|
+
"INTERNAL"
|
|
2036
|
+
];
|
|
2037
|
+
const RENDER_WARNING_CODES = [
|
|
2038
|
+
"ASSET_UNAVAILABLE",
|
|
2039
|
+
"FONT_FALLBACK",
|
|
2040
|
+
"LOCAL_FONT_FALLBACK",
|
|
2041
|
+
"SOURCE_FALLBACK",
|
|
2042
|
+
"SCALE_REDUCED",
|
|
2043
|
+
"LAYOUT_FALLBACK",
|
|
2044
|
+
"DRAWN_APPROXIMATELY"
|
|
2293
2045
|
];
|
|
2294
|
-
const GROUP_TRANSFORM = "--enhance-group-affine-residual";
|
|
2295
|
-
const CANVAS_RECORDED_BOX_NOTE = "A box whose boxSource is \"recorded\" is a size kept from when the layer was made: the browser lays that layer out, so the box is not where it is drawn. `enhance canvas render` shows what is on screen.";
|
|
2296
|
-
const isSet = (value) => value !== void 0 && value !== "" && value !== "none";
|
|
2297
|
-
const hasOwnTransform = (node, authored) => TRANSFORMS.some((property) => isSet(authored[property])) || (node.layout?.rotation ?? 0) !== 0 || node.layout?.flipHorizontal === true || node.layout?.flipVertical === true || Object.keys(authored).some((property) => property.toLowerCase() === GROUP_TRANSFORM);
|
|
2298
|
-
/**
|
|
2299
|
-
* The canvas draws a layer at its box only when it positions the layer absolutely and the layer
|
|
2300
|
-
* names no inset of its own; an inset on either axis takes that axis from the box. This is the
|
|
2301
|
-
* test the style projection makes before it writes `left` and `top` from the box, and a layer
|
|
2302
|
-
* with no box has no source.
|
|
2303
|
-
*/
|
|
2304
|
-
const canvasBoxSourceOf = (node) => {
|
|
2305
|
-
if (node.box === void 0) return void 0;
|
|
2306
|
-
const authored = canvasAuthoredStyleDeclarations(node);
|
|
2307
|
-
if (!(canvasLayoutPositionOf(node) === "absolute" && INSETS.every((property) => authored[property] === void 0))) return "recorded";
|
|
2308
|
-
return hasOwnTransform(node, authored) ? "placed-before-transform" : "placed";
|
|
2309
|
-
};
|
|
2310
|
-
/** One line for a whole read, however many of its boxes are recorded. */
|
|
2311
|
-
const canvasRecordedBoxNoteFor = (boxes) => boxes.some((box) => box.boxSource === "recorded") ? { boxNote: CANVAS_RECORDED_BOX_NOTE } : {};
|
|
2312
2046
|
|
|
2313
2047
|
//#endregion
|
|
2314
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2315
|
-
const
|
|
2316
|
-
const
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2319
|
-
|
|
2048
|
+
//#region ../../packages/contract/src/canvas/canvas-render.schema.ts
|
|
2049
|
+
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
2050
|
+
const canvasRenderPixelLimitSchema = z.number().int().positive();
|
|
2051
|
+
const canvasWorldBoundsSchema = z.object({
|
|
2052
|
+
x: z.number(),
|
|
2053
|
+
y: z.number(),
|
|
2054
|
+
width: z.number().positive(),
|
|
2055
|
+
height: z.number().positive()
|
|
2320
2056
|
});
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
const canvasGeometryBoundsSchema = z.strictObject({
|
|
2335
|
-
x: coordinate,
|
|
2336
|
-
y: coordinate,
|
|
2337
|
-
width: dimension$1,
|
|
2338
|
-
height: dimension$1
|
|
2339
|
-
});
|
|
2340
|
-
const canvasPathGeometrySchema = z.strictObject({
|
|
2341
|
-
kind: z.literal("path"),
|
|
2342
|
-
path: path.min(1),
|
|
2343
|
-
fillRule: z.enum(["nonzero", "evenodd"]),
|
|
2344
|
-
viewBox: canvasGeometryBoundsSchema.extend({
|
|
2345
|
-
width: dimension$1.positive(),
|
|
2346
|
-
height: dimension$1.positive()
|
|
2057
|
+
const canvasRenderTargetSchema = z.discriminatedUnion("kind", [
|
|
2058
|
+
z.object({ kind: z.literal("content") }),
|
|
2059
|
+
z.object({
|
|
2060
|
+
kind: z.literal("page"),
|
|
2061
|
+
pageId: z.string().min(1)
|
|
2062
|
+
}),
|
|
2063
|
+
z.object({
|
|
2064
|
+
kind: z.literal("node"),
|
|
2065
|
+
nodeId: z.string().min(1)
|
|
2066
|
+
}),
|
|
2067
|
+
z.object({
|
|
2068
|
+
kind: z.literal("bounds"),
|
|
2069
|
+
bounds: canvasWorldBoundsSchema
|
|
2347
2070
|
})
|
|
2348
|
-
});
|
|
2349
|
-
const canvasPolygonGeometrySchema = z.strictObject({
|
|
2350
|
-
kind: z.literal("polygon"),
|
|
2351
|
-
count: z.number().int().min(MIN_POLYGON_POINTS),
|
|
2352
|
-
innerRatio: z.number().min(0).max(1).optional(),
|
|
2353
|
-
cornerRadius: dimension$1,
|
|
2354
|
-
cornerSmoothing: z.number().min(0).max(1)
|
|
2355
|
-
});
|
|
2356
|
-
const canvasBooleanOperationSchema = z.enum([
|
|
2357
|
-
"union",
|
|
2358
|
-
"subtract",
|
|
2359
|
-
"intersect",
|
|
2360
|
-
"exclude"
|
|
2361
2071
|
]);
|
|
2362
|
-
const
|
|
2363
|
-
kind: z.literal("
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
result: z.strictObject({
|
|
2367
|
-
path,
|
|
2368
|
-
fillRule: z.literal("nonzero"),
|
|
2369
|
-
isEmpty: z.boolean(),
|
|
2370
|
-
bounds: canvasGeometryBoundsSchema,
|
|
2371
|
-
inputKey: z.string().regex(/^[a-f0-9]{16}$/u)
|
|
2372
|
-
}).refine((result) => result.isEmpty === (result.path === ""))
|
|
2072
|
+
const canvasRenderSourceStateSchema = z.object({
|
|
2073
|
+
kind: z.literal("recording"),
|
|
2074
|
+
recordingId: z.uuid(),
|
|
2075
|
+
atMs: z.number().int().nonnegative()
|
|
2373
2076
|
});
|
|
2374
|
-
const
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
z.
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2077
|
+
const canvasRenderSourceStateEvidenceSchema = z.object({
|
|
2078
|
+
kind: z.literal("recording"),
|
|
2079
|
+
recordingId: z.uuid(),
|
|
2080
|
+
requestedAtMs: z.number().int().nonnegative(),
|
|
2081
|
+
settledAtMs: z.number().int().nonnegative()
|
|
2082
|
+
});
|
|
2083
|
+
const canvasRenderSnapshotResultSchema = z.object({
|
|
2084
|
+
recordingId: z.uuid(),
|
|
2085
|
+
atMs: z.number().int().nonnegative(),
|
|
2086
|
+
screenId: z.uuid(),
|
|
2087
|
+
/** Null when the snapshot asked for a place only, so no screen layer was added. */
|
|
2088
|
+
screenNodeId: z.string().min(1).nullable(),
|
|
2089
|
+
/** The page the place is on. */
|
|
2090
|
+
pageId: z.string().min(1).optional(),
|
|
2091
|
+
viewport: z.object({
|
|
2092
|
+
width: z.number().int().positive(),
|
|
2093
|
+
height: z.number().int().positive()
|
|
2386
2094
|
}),
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
//#endregion
|
|
2391
|
-
//#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
|
|
2392
|
-
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
2393
|
-
const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
|
|
2394
|
-
const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
|
|
2395
|
-
/** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
|
|
2396
|
-
const FOR_CALLER = { forCaller: true };
|
|
2397
|
-
/**
|
|
2398
|
-
* The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
|
|
2399
|
-
* writes that format may make is `refuseUnsafeWriterFormat`'s call.
|
|
2400
|
-
*/
|
|
2401
|
-
const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
|
|
2402
|
-
description: `The document format this client writes. The current format is ${String(15)}.`,
|
|
2403
|
-
examples: [15]
|
|
2095
|
+
box: canvasWorldBoundsSchema,
|
|
2096
|
+
version: z.number().int().positive(),
|
|
2097
|
+
alreadyPresent: z.boolean()
|
|
2404
2098
|
});
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
};
|
|
2421
|
-
const canvasPreservedFontAppearanceSchema = z.object({
|
|
2422
|
-
signature: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
2423
|
-
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
2424
|
-
image: z.string().refine((image) => image.startsWith("data:image/jpeg;base64,") || canvasImageAssetIdentityFromPath(image) !== null),
|
|
2425
|
-
families: z.array(z.string().min(1)).min(1)
|
|
2099
|
+
const createCanvasRenderInputSchema = z.object({
|
|
2100
|
+
canvasId: z.uuid(),
|
|
2101
|
+
expectedVersion: z.number().int().positive().optional(),
|
|
2102
|
+
scope: z.strictObject({
|
|
2103
|
+
pageId: z.string().min(1).optional(),
|
|
2104
|
+
nodeIds: z.array(z.string().min(1))
|
|
2105
|
+
}).optional(),
|
|
2106
|
+
target: canvasRenderTargetSchema.default({ kind: "content" }),
|
|
2107
|
+
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2108
|
+
scale: z.number().positive().default(1),
|
|
2109
|
+
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2110
|
+
format: z.literal("png").default("png")
|
|
2111
|
+
}).refine((input) => input.sourceState === void 0 || input.target.kind === "node", {
|
|
2112
|
+
message: "a source state requires a node render target",
|
|
2113
|
+
path: ["sourceState"]
|
|
2426
2114
|
});
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2115
|
+
const canvasRenderPhaseSchema = z.enum(RENDER_PHASES);
|
|
2116
|
+
const canvasRenderStateSchema = z.enum(RENDER_STATES);
|
|
2117
|
+
const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
|
|
2118
|
+
const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
|
|
2119
|
+
const canvasRenderWarningSchema = z.object({
|
|
2120
|
+
code: canvasRenderWarningCodeSchema,
|
|
2121
|
+
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
|
|
2122
|
+
sourceId: z.string().min(1).nullable()
|
|
2432
2123
|
});
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
]);
|
|
2440
|
-
const canvasNodeConstraintsSchema = z.object({
|
|
2441
|
-
x: canvasConstraintSchema,
|
|
2442
|
-
y: canvasConstraintSchema
|
|
2124
|
+
const canvasRenderFailureSchema = z.object({
|
|
2125
|
+
reason: canvasRenderFailureReasonSchema,
|
|
2126
|
+
phase: canvasRenderPhaseSchema,
|
|
2127
|
+
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
|
|
2128
|
+
retryable: z.boolean(),
|
|
2129
|
+
sourceId: z.string().min(1).nullable()
|
|
2443
2130
|
});
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
"content",
|
|
2448
|
-
"user"
|
|
2449
|
-
]);
|
|
2450
|
-
const canvasSceneNodeSchema = z.looseObject({
|
|
2451
|
-
id: z.string().min(1),
|
|
2452
|
-
label: z.string(),
|
|
2453
|
-
component: z.string().min(1),
|
|
2454
|
-
labelOrigin: canvasNodeLabelOriginSchema.optional(),
|
|
2455
|
-
visible: z.boolean().optional(),
|
|
2456
|
-
locked: z.boolean().optional(),
|
|
2457
|
-
constraints: canvasNodeConstraintsSchema.optional(),
|
|
2458
|
-
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
2459
|
-
layout: canvasNodeLayoutSchema.optional(),
|
|
2460
|
-
responsive: z.never().optional(),
|
|
2461
|
-
appearance: canvasAppearanceValuesSchema.optional(),
|
|
2462
|
-
exportSettings: canvasExportSettingsSchema.optional(),
|
|
2463
|
-
typography: canvasAuthoredTypographySchema.optional(),
|
|
2464
|
-
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
2465
|
-
geometry: canvasGeometrySchema.optional(),
|
|
2466
|
-
compositing: z.never({ error: CANVAS_COMPOSITING_RETIRED }).optional(),
|
|
2467
|
-
props: z.record(z.string(), z.unknown()).optional(),
|
|
2468
|
-
box: canvasSceneBoxSchema.optional()
|
|
2131
|
+
const canvasRenderTimingSchema = z.object({
|
|
2132
|
+
phase: canvasRenderPhaseSchema,
|
|
2133
|
+
durationMs: z.number().int().min(0)
|
|
2469
2134
|
});
|
|
2470
|
-
const
|
|
2471
|
-
|
|
2472
|
-
|
|
2135
|
+
const canvasRenderResultSchema = z.object({
|
|
2136
|
+
canvasId: z.uuid(),
|
|
2137
|
+
requestedVersion: z.number().int().positive(),
|
|
2138
|
+
loadedVersion: z.number().int().positive(),
|
|
2139
|
+
target: canvasRenderTargetSchema,
|
|
2140
|
+
sourceState: canvasRenderSourceStateEvidenceSchema.optional(),
|
|
2141
|
+
snapshot: canvasRenderSnapshotResultSchema.optional(),
|
|
2142
|
+
bounds: canvasWorldBoundsSchema,
|
|
2143
|
+
width: z.number().int().positive(),
|
|
2144
|
+
height: z.number().int().positive(),
|
|
2145
|
+
scale: z.number().positive(),
|
|
2146
|
+
contentType: z.literal("image/png"),
|
|
2147
|
+
bytes: z.number().int().positive(),
|
|
2148
|
+
warnings: z.array(canvasRenderWarningSchema),
|
|
2149
|
+
timings: z.array(canvasRenderTimingSchema),
|
|
2150
|
+
expiresAt: z.iso.datetime()
|
|
2473
2151
|
});
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2152
|
+
const canvasRenderJobBaseSchema = z.object({
|
|
2153
|
+
id: z.uuid(),
|
|
2154
|
+
canvasId: z.uuid(),
|
|
2155
|
+
purpose: z.enum([
|
|
2156
|
+
"inspection",
|
|
2157
|
+
"snapshot",
|
|
2158
|
+
"thumbnail",
|
|
2159
|
+
"export"
|
|
2160
|
+
]),
|
|
2161
|
+
phase: canvasRenderPhaseSchema,
|
|
2162
|
+
requestedVersion: z.number().int().positive(),
|
|
2163
|
+
target: canvasRenderTargetSchema,
|
|
2164
|
+
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2165
|
+
scale: z.number().positive(),
|
|
2166
|
+
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2167
|
+
format: z.literal("png"),
|
|
2168
|
+
attempt: z.number().int().min(0),
|
|
2169
|
+
lastFailure: canvasRenderFailureSchema.optional(),
|
|
2170
|
+
createdAt: z.iso.datetime(),
|
|
2171
|
+
updatedAt: z.iso.datetime()
|
|
2479
2172
|
});
|
|
2480
|
-
const
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
locked: false,
|
|
2517
|
-
styles: {}
|
|
2518
|
-
} },
|
|
2519
|
-
relationships: {},
|
|
2520
|
-
tombstones: {}
|
|
2521
|
-
});
|
|
2522
|
-
const shellSchema = canvasSceneDocumentSchema.extend({
|
|
2523
|
-
nodes: z.record(z.string(), z.unknown()),
|
|
2524
|
-
relationships: z.record(z.string(), z.unknown())
|
|
2525
|
-
});
|
|
2526
|
-
|
|
2527
|
-
//#endregion
|
|
2528
|
-
//#region ../../packages/contract/src/canvas/canvas-conversion-draft.schema.ts
|
|
2529
|
-
const temporaryIdSchema = z.string().min(1);
|
|
2530
|
-
const canvasConversionIssueSchema = z.object({
|
|
2531
|
-
code: z.enum([
|
|
2532
|
-
"asset-unavailable",
|
|
2533
|
-
"content-omitted",
|
|
2534
|
-
"cross-origin-frame",
|
|
2535
|
-
"nodes-truncated",
|
|
2536
|
-
"responsive-behavior-not-editable",
|
|
2537
|
-
"style-degraded",
|
|
2538
|
-
"unsupported-surface",
|
|
2539
|
-
"vertical-writing-unsupported"
|
|
2540
|
-
]),
|
|
2541
|
-
message: z.string().min(1),
|
|
2542
|
-
temporaryId: temporaryIdSchema.optional()
|
|
2173
|
+
const canvasRenderJobSchema = z.discriminatedUnion("state", [
|
|
2174
|
+
canvasRenderJobBaseSchema.extend({
|
|
2175
|
+
state: z.literal("queued"),
|
|
2176
|
+
result: z.null(),
|
|
2177
|
+
failure: z.null()
|
|
2178
|
+
}),
|
|
2179
|
+
canvasRenderJobBaseSchema.extend({
|
|
2180
|
+
state: z.literal("running"),
|
|
2181
|
+
result: z.null(),
|
|
2182
|
+
failure: z.null()
|
|
2183
|
+
}),
|
|
2184
|
+
canvasRenderJobBaseSchema.extend({
|
|
2185
|
+
state: z.literal("succeeded"),
|
|
2186
|
+
phase: z.literal("complete"),
|
|
2187
|
+
result: canvasRenderResultSchema,
|
|
2188
|
+
failure: z.null()
|
|
2189
|
+
}),
|
|
2190
|
+
canvasRenderJobBaseSchema.extend({
|
|
2191
|
+
state: z.literal("failed"),
|
|
2192
|
+
result: z.null(),
|
|
2193
|
+
failure: canvasRenderFailureSchema
|
|
2194
|
+
}),
|
|
2195
|
+
canvasRenderJobBaseSchema.extend({
|
|
2196
|
+
state: z.literal("cancelled"),
|
|
2197
|
+
result: z.null(),
|
|
2198
|
+
failure: canvasRenderFailureSchema.extend({ reason: z.literal("CANCELLED") })
|
|
2199
|
+
}),
|
|
2200
|
+
canvasRenderJobBaseSchema.extend({
|
|
2201
|
+
state: z.literal("expired"),
|
|
2202
|
+
result: z.null(),
|
|
2203
|
+
failure: canvasRenderFailureSchema.extend({ reason: z.literal("EXPIRED") })
|
|
2204
|
+
})
|
|
2205
|
+
]);
|
|
2206
|
+
const createCanvasRenderOutputSchema = z.object({
|
|
2207
|
+
job: canvasRenderJobSchema,
|
|
2208
|
+
alreadyExists: z.boolean()
|
|
2543
2209
|
});
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
"
|
|
2553
|
-
|
|
2554
|
-
"
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
collapsedTransferredWrapperNodeCount: z.number().int().nonnegative().optional(),
|
|
2581
|
-
layoutContainerCount: z.number().int().nonnegative().optional(),
|
|
2582
|
-
removedLeafNodeCount: z.number().int().nonnegative().optional(),
|
|
2583
|
-
retainedSemanticOwnerNodeCount: z.number().int().nonnegative().optional(),
|
|
2584
|
-
truncatedNodeCount: z.number().int().nonnegative().optional(),
|
|
2585
|
-
addedLayoutNodeCount: z.number().int().nonnegative().optional(),
|
|
2586
|
-
issues: z.array(canvasConversionIssueSchema)
|
|
2210
|
+
const getCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2211
|
+
/** The longest an export read waits on the server for the job to settle. */
|
|
2212
|
+
const CANVAS_EXPORT_LONGEST_WAIT_MS = 1e4;
|
|
2213
|
+
const getCanvasExportInputSchema = getCanvasRenderInputSchema.extend({ waitMs: z.number().int().min(0).max(CANVAS_EXPORT_LONGEST_WAIT_MS).optional() });
|
|
2214
|
+
const getCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
2215
|
+
const cancelCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2216
|
+
const cancelCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
2217
|
+
const canvasRenderSourceSchema = z.discriminatedUnion("status", [z.object({
|
|
2218
|
+
status: z.literal("available"),
|
|
2219
|
+
version: z.number().int().positive(),
|
|
2220
|
+
format: z.literal("enhance-scene-json"),
|
|
2221
|
+
code: z.string(),
|
|
2222
|
+
prototypes: z.array(z.object({
|
|
2223
|
+
nodeId: z.string(),
|
|
2224
|
+
prototypeId: z.uuid(),
|
|
2225
|
+
deploymentId: z.uuid(),
|
|
2226
|
+
capability: z.literal("canvas.read"),
|
|
2227
|
+
canvasPath: z.string(),
|
|
2228
|
+
input: z.object({
|
|
2229
|
+
canvasRef: z.uuid(),
|
|
2230
|
+
view: z.literal("source"),
|
|
2231
|
+
nodeId: z.string()
|
|
2232
|
+
}),
|
|
2233
|
+
guidance: z.string()
|
|
2234
|
+
})),
|
|
2235
|
+
guidance: z.string()
|
|
2236
|
+
}), z.object({
|
|
2237
|
+
status: z.literal("unavailable"),
|
|
2238
|
+
guidance: z.string()
|
|
2239
|
+
})]);
|
|
2240
|
+
/** A person's image export of one layer at the saved revision, drawn by the render worker. */
|
|
2241
|
+
const createCanvasExportInputSchema = z.object({
|
|
2242
|
+
canvasId: z.uuid(),
|
|
2243
|
+
nodeId: z.string().min(1),
|
|
2244
|
+
expectedVersion: z.number().int().positive(),
|
|
2245
|
+
scale: z.number().positive()
|
|
2587
2246
|
});
|
|
2588
|
-
const
|
|
2589
|
-
const
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2247
|
+
const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2248
|
+
const downloadCanvasRenderOutputSchema = z.object({
|
|
2249
|
+
jobId: z.uuid(),
|
|
2250
|
+
download: signedDownloadSchema,
|
|
2251
|
+
source: canvasRenderSourceSchema.optional()
|
|
2593
2252
|
});
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
}
|
|
2605
|
-
const canvasSubtreeDraftSchema = z.object({
|
|
2606
|
-
version: z.literal(1),
|
|
2607
|
-
rootTemporaryId: temporaryIdSchema,
|
|
2608
|
-
nodes: z.array(canvasSubtreeDraftNodeSchema).min(1),
|
|
2609
|
-
relationships: z.array(canvasSubtreeDraftRelationshipSchema),
|
|
2610
|
-
report: canvasConversionReportSchema.catch(UNREADABLE_REPORT)
|
|
2611
|
-
}).transform((draft) => ({
|
|
2612
|
-
...draft,
|
|
2613
|
-
report: {
|
|
2614
|
-
...draft.report,
|
|
2615
|
-
nodeCount: draft.nodes.length
|
|
2616
|
-
}
|
|
2617
|
-
}));
|
|
2618
|
-
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
2619
|
-
const editableFrameCaptureSchema = z.object({
|
|
2620
|
-
screenId: z.string().min(1),
|
|
2621
|
-
pageId: z.string().min(1),
|
|
2622
|
-
pictureNodeId: z.string().min(1).optional().describe("The capture's picture, which the frame replaces in place and whose id it keeps. Refused as capture-already-landed once the picture is a frame.")
|
|
2253
|
+
const canvasSnapshotRequestSchema = z.strictObject({
|
|
2254
|
+
previewJobId: z.uuid(),
|
|
2255
|
+
scope: z.strictObject({
|
|
2256
|
+
pageId: z.string().min(1).optional(),
|
|
2257
|
+
nodeIds: z.array(z.string().min(1))
|
|
2258
|
+
}),
|
|
2259
|
+
/**
|
|
2260
|
+
* Below the walkthrough: as a screen layer, which installed CLIs ask for, or as a place only,
|
|
2261
|
+
* where the agent's CLI lands an editable frame.
|
|
2262
|
+
*/
|
|
2263
|
+
placement: z.strictObject({ kind: z.enum(["below-source", "editable-below-source"]) })
|
|
2623
2264
|
});
|
|
2624
|
-
const
|
|
2265
|
+
const createRecordingSnapshotInputSchema = z.object({
|
|
2625
2266
|
canvasId: z.uuid(),
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
const createEditableFrameInputSchema = z.union([z.strictObject({
|
|
2633
|
-
...editableFrameInputBase,
|
|
2634
|
-
screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself.")
|
|
2635
|
-
}), z.strictObject({
|
|
2636
|
-
...editableFrameInputBase,
|
|
2637
|
-
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
2638
|
-
})]).superRefine((input, context) => {
|
|
2639
|
-
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
2267
|
+
recordingId: z.uuid(),
|
|
2268
|
+
atMs: z.number().int().nonnegative(),
|
|
2269
|
+
context: z.strictObject({
|
|
2270
|
+
expectedVersion: z.number().int().positive(),
|
|
2271
|
+
request: canvasSnapshotRequestSchema
|
|
2272
|
+
}).optional()
|
|
2640
2273
|
});
|
|
2641
|
-
const
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
previousVersion: z.number().int().positive(),
|
|
2645
|
-
version: z.number().int().positive(),
|
|
2646
|
-
rootNodeId: z.string().min(1),
|
|
2647
|
-
idMap: z.record(temporaryIdSchema, z.string().min(1)),
|
|
2648
|
-
insertedNodeIds: z.array(z.string().min(1)),
|
|
2649
|
-
removedNodeIds: z.array(z.string().min(1)),
|
|
2650
|
-
boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
|
|
2651
|
-
affectedBounds: canvasSceneBoxSchema
|
|
2274
|
+
const createRecordingSnapshotOutputSchema = z.object({
|
|
2275
|
+
job: canvasRenderJobSchema,
|
|
2276
|
+
alreadyExists: z.boolean()
|
|
2652
2277
|
});
|
|
2653
2278
|
|
|
2654
2279
|
//#endregion
|
|
2655
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2656
|
-
const
|
|
2657
|
-
"queued",
|
|
2658
|
-
"claimed",
|
|
2659
|
-
"grant",
|
|
2660
|
-
"navigate",
|
|
2661
|
-
"document",
|
|
2662
|
-
"sources",
|
|
2663
|
-
"fonts",
|
|
2664
|
-
"layout",
|
|
2665
|
-
"target",
|
|
2666
|
-
"capture",
|
|
2667
|
-
"serialize",
|
|
2668
|
-
"compile",
|
|
2669
|
-
"commit",
|
|
2670
|
-
"upload",
|
|
2671
|
-
"complete"
|
|
2672
|
-
];
|
|
2673
|
-
const RENDER_STATES = [
|
|
2674
|
-
"queued",
|
|
2675
|
-
"running",
|
|
2676
|
-
"succeeded",
|
|
2677
|
-
"failed",
|
|
2678
|
-
"cancelled",
|
|
2679
|
-
"expired"
|
|
2680
|
-
];
|
|
2681
|
-
const RENDER_FAILURE_REASONS = [
|
|
2682
|
-
"VERSION_CHANGED",
|
|
2683
|
-
"TARGET_NOT_FOUND",
|
|
2684
|
-
"TARGET_INVALID",
|
|
2685
|
-
"OUTPUT_TOO_LARGE",
|
|
2686
|
-
"READINESS_TIMEOUT",
|
|
2687
|
-
"SOURCE_FAILED",
|
|
2688
|
-
"BROWSER_CRASH",
|
|
2689
|
-
"CAPTURE_FAILED",
|
|
2690
|
-
"CONVERSION_FAILED",
|
|
2691
|
-
"PREPARATION_FAILED",
|
|
2692
|
-
"UPLOAD_FAILED",
|
|
2693
|
-
"WORKER_UNAVAILABLE",
|
|
2694
|
-
"CANCELLED",
|
|
2695
|
-
"EXPIRED",
|
|
2696
|
-
"INTERNAL"
|
|
2697
|
-
];
|
|
2698
|
-
const RENDER_WARNING_CODES = [
|
|
2699
|
-
"ASSET_UNAVAILABLE",
|
|
2700
|
-
"FONT_FALLBACK",
|
|
2701
|
-
"LOCAL_FONT_FALLBACK",
|
|
2702
|
-
"SOURCE_FALLBACK",
|
|
2703
|
-
"SCALE_REDUCED",
|
|
2704
|
-
"LAYOUT_FALLBACK",
|
|
2705
|
-
"DRAWN_APPROXIMATELY"
|
|
2706
|
-
];
|
|
2280
|
+
//#region ../../packages/contract/src/canvas/canvas-write-scope.schema.ts
|
|
2281
|
+
const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) });
|
|
2707
2282
|
|
|
2708
2283
|
//#endregion
|
|
2709
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2710
|
-
const
|
|
2711
|
-
const canvasRenderPixelLimitSchema = z.number().int().positive();
|
|
2712
|
-
const canvasWorldBoundsSchema = z.object({
|
|
2713
|
-
x: z.number(),
|
|
2714
|
-
y: z.number(),
|
|
2715
|
-
width: z.number().positive(),
|
|
2716
|
-
height: z.number().positive()
|
|
2717
|
-
});
|
|
2718
|
-
const canvasRenderTargetSchema = z.discriminatedUnion("kind", [
|
|
2719
|
-
z.object({ kind: z.literal("content") }),
|
|
2284
|
+
//#region ../../packages/contract/src/canvas/canvas-conversion.schema.ts
|
|
2285
|
+
const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
|
|
2720
2286
|
z.object({
|
|
2721
|
-
kind: z.literal("
|
|
2722
|
-
|
|
2287
|
+
kind: z.literal("adjacent"),
|
|
2288
|
+
/** Where the page was measured to have room for the frame. Absent, stored boxes are searched. */
|
|
2289
|
+
position: z.strictObject({
|
|
2290
|
+
x: z.number(),
|
|
2291
|
+
y: z.number()
|
|
2292
|
+
}).optional()
|
|
2723
2293
|
}),
|
|
2724
2294
|
z.object({
|
|
2725
|
-
kind: z.literal("
|
|
2726
|
-
|
|
2295
|
+
kind: z.literal("insert-children"),
|
|
2296
|
+
pageId: z.string().min(1).optional(),
|
|
2297
|
+
targetNodeId: z.string().min(1),
|
|
2298
|
+
/** World placement for a new top-level screen. Absent, the authored position stands. */
|
|
2299
|
+
placement: canvasPlacementIntentSchema.optional()
|
|
2727
2300
|
}),
|
|
2728
2301
|
z.object({
|
|
2729
|
-
kind: z.literal("
|
|
2730
|
-
|
|
2302
|
+
kind: z.literal("replace"),
|
|
2303
|
+
targetNodeId: z.string().min(1),
|
|
2304
|
+
/**
|
|
2305
|
+
* A capture's swap: the target must still be the capture's picture. When another browser has
|
|
2306
|
+
* already made it editable, the swap is refused as `capture-already-landed`.
|
|
2307
|
+
*/
|
|
2308
|
+
onlyPicture: z.literal(true).optional()
|
|
2731
2309
|
})
|
|
2732
2310
|
]);
|
|
2733
|
-
const
|
|
2734
|
-
kind: z.literal("
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
version: z.number().int().positive(),
|
|
2758
|
-
alreadyPresent: z.boolean()
|
|
2759
|
-
});
|
|
2760
|
-
const createCanvasRenderInputSchema = z.object({
|
|
2761
|
-
canvasId: z.uuid(),
|
|
2762
|
-
expectedVersion: z.number().int().positive().optional(),
|
|
2763
|
-
scope: z.strictObject({
|
|
2764
|
-
pageId: z.string().min(1).optional(),
|
|
2765
|
-
nodeIds: z.array(z.string().min(1))
|
|
2766
|
-
}).optional(),
|
|
2767
|
-
target: canvasRenderTargetSchema.default({ kind: "content" }),
|
|
2768
|
-
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2769
|
-
scale: z.number().positive().default(1),
|
|
2770
|
-
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2771
|
-
format: z.literal("png").default("png")
|
|
2772
|
-
}).refine((input) => input.sourceState === void 0 || input.target.kind === "node", {
|
|
2773
|
-
message: "a source state requires a node render target",
|
|
2774
|
-
path: ["sourceState"]
|
|
2775
|
-
});
|
|
2776
|
-
const canvasRenderPhaseSchema = z.enum(RENDER_PHASES);
|
|
2777
|
-
const canvasRenderStateSchema = z.enum(RENDER_STATES);
|
|
2778
|
-
const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
|
|
2779
|
-
const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
|
|
2780
|
-
const canvasRenderWarningSchema = z.object({
|
|
2781
|
-
code: canvasRenderWarningCodeSchema,
|
|
2782
|
-
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
2783
|
-
sourceId: z.string().min(1).nullable()
|
|
2784
|
-
});
|
|
2785
|
-
const canvasRenderFailureSchema = z.object({
|
|
2786
|
-
reason: canvasRenderFailureReasonSchema,
|
|
2787
|
-
phase: canvasRenderPhaseSchema,
|
|
2788
|
-
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
2789
|
-
retryable: z.boolean(),
|
|
2790
|
-
sourceId: z.string().min(1).nullable()
|
|
2791
|
-
});
|
|
2792
|
-
const canvasRenderTimingSchema = z.object({
|
|
2793
|
-
phase: canvasRenderPhaseSchema,
|
|
2794
|
-
durationMs: z.number().int().min(0)
|
|
2795
|
-
});
|
|
2796
|
-
const canvasRenderResultSchema = z.object({
|
|
2797
|
-
canvasId: z.uuid(),
|
|
2798
|
-
requestedVersion: z.number().int().positive(),
|
|
2799
|
-
loadedVersion: z.number().int().positive(),
|
|
2800
|
-
target: canvasRenderTargetSchema,
|
|
2801
|
-
sourceState: canvasRenderSourceStateEvidenceSchema.optional(),
|
|
2802
|
-
snapshot: canvasRenderSnapshotResultSchema.optional(),
|
|
2803
|
-
bounds: canvasWorldBoundsSchema,
|
|
2804
|
-
width: z.number().int().positive(),
|
|
2805
|
-
height: z.number().int().positive(),
|
|
2806
|
-
scale: z.number().positive(),
|
|
2807
|
-
contentType: z.literal("image/png"),
|
|
2808
|
-
bytes: z.number().int().positive(),
|
|
2809
|
-
warnings: z.array(canvasRenderWarningSchema),
|
|
2810
|
-
timings: z.array(canvasRenderTimingSchema),
|
|
2811
|
-
expiresAt: z.iso.datetime()
|
|
2311
|
+
const canvasConversionSourceSchema = z.discriminatedUnion("kind", [z.object({
|
|
2312
|
+
kind: z.literal("screen"),
|
|
2313
|
+
nodeId: z.string().min(1)
|
|
2314
|
+
}), z.object({
|
|
2315
|
+
kind: z.literal("html"),
|
|
2316
|
+
html: z.string().min(1),
|
|
2317
|
+
label: z.string().min(1),
|
|
2318
|
+
idPrefix: z.string().min(1).regex(/^[\w-]+$/u).optional()
|
|
2319
|
+
})]);
|
|
2320
|
+
const canvasConversionRequestSchema = z.object({
|
|
2321
|
+
source: canvasConversionSourceSchema,
|
|
2322
|
+
destination: canvasConversionDestinationSchema,
|
|
2323
|
+
revisionPolicy: z.enum(["strict", "rebase"]).optional()
|
|
2324
|
+
}).superRefine((request, context) => {
|
|
2325
|
+
if (request.source.kind === "screen" && request.destination.kind !== "adjacent") context.addIssue({
|
|
2326
|
+
code: "custom",
|
|
2327
|
+
message: "stored screens convert beside their source",
|
|
2328
|
+
path: ["destination"]
|
|
2329
|
+
});
|
|
2330
|
+
if (request.source.kind === "html" && request.destination.kind === "adjacent") context.addIssue({
|
|
2331
|
+
code: "custom",
|
|
2332
|
+
message: "authored HTML requires an editable destination",
|
|
2333
|
+
path: ["destination"]
|
|
2334
|
+
});
|
|
2812
2335
|
});
|
|
2813
|
-
const
|
|
2336
|
+
const canvasConversionSourceSummarySchema = z.discriminatedUnion("kind", [z.object({
|
|
2337
|
+
kind: z.literal("screen"),
|
|
2338
|
+
nodeId: z.string().min(1)
|
|
2339
|
+
}), z.object({
|
|
2340
|
+
kind: z.literal("html"),
|
|
2341
|
+
label: z.string().min(1)
|
|
2342
|
+
})]);
|
|
2343
|
+
const canvasConversionJobBaseSchema = z.object({
|
|
2814
2344
|
id: z.uuid(),
|
|
2815
2345
|
canvasId: z.uuid(),
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
"snapshot",
|
|
2819
|
-
"thumbnail",
|
|
2820
|
-
"export"
|
|
2821
|
-
]),
|
|
2346
|
+
source: canvasConversionSourceSummarySchema,
|
|
2347
|
+
destination: canvasConversionDestinationSchema,
|
|
2822
2348
|
phase: canvasRenderPhaseSchema,
|
|
2823
2349
|
requestedVersion: z.number().int().positive(),
|
|
2824
|
-
|
|
2825
|
-
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2826
|
-
scale: z.number().positive(),
|
|
2827
|
-
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2828
|
-
format: z.literal("png"),
|
|
2829
|
-
attempt: z.number().int().min(0),
|
|
2830
|
-
lastFailure: canvasRenderFailureSchema.optional(),
|
|
2350
|
+
attempt: z.number().int().nonnegative(),
|
|
2831
2351
|
createdAt: z.iso.datetime(),
|
|
2832
2352
|
updatedAt: z.iso.datetime()
|
|
2833
2353
|
});
|
|
2834
|
-
const
|
|
2835
|
-
|
|
2354
|
+
const canvasConversionJobSchema = z.discriminatedUnion("state", [
|
|
2355
|
+
canvasConversionJobBaseSchema.extend({
|
|
2836
2356
|
state: z.literal("queued"),
|
|
2837
2357
|
result: z.null(),
|
|
2838
2358
|
failure: z.null()
|
|
2839
2359
|
}),
|
|
2840
|
-
|
|
2360
|
+
canvasConversionJobBaseSchema.extend({
|
|
2841
2361
|
state: z.literal("running"),
|
|
2842
2362
|
result: z.null(),
|
|
2843
2363
|
failure: z.null()
|
|
2844
2364
|
}),
|
|
2845
|
-
|
|
2365
|
+
canvasConversionJobBaseSchema.extend({
|
|
2846
2366
|
state: z.literal("succeeded"),
|
|
2847
2367
|
phase: z.literal("complete"),
|
|
2848
|
-
result:
|
|
2368
|
+
result: createEditableFrameResultSchema.extend({ report: canvasConversionReportSchema }),
|
|
2849
2369
|
failure: z.null()
|
|
2850
2370
|
}),
|
|
2851
|
-
|
|
2371
|
+
canvasConversionJobBaseSchema.extend({
|
|
2852
2372
|
state: z.literal("failed"),
|
|
2853
2373
|
result: z.null(),
|
|
2854
2374
|
failure: canvasRenderFailureSchema
|
|
2855
2375
|
}),
|
|
2856
|
-
|
|
2376
|
+
canvasConversionJobBaseSchema.extend({
|
|
2857
2377
|
state: z.literal("cancelled"),
|
|
2858
2378
|
result: z.null(),
|
|
2859
2379
|
failure: canvasRenderFailureSchema.extend({ reason: z.literal("CANCELLED") })
|
|
2860
2380
|
}),
|
|
2861
|
-
|
|
2381
|
+
canvasConversionJobBaseSchema.extend({
|
|
2862
2382
|
state: z.literal("expired"),
|
|
2863
2383
|
result: z.null(),
|
|
2864
2384
|
failure: canvasRenderFailureSchema.extend({ reason: z.literal("EXPIRED") })
|
|
2865
2385
|
})
|
|
2866
2386
|
]);
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
const
|
|
2878
|
-
|
|
2879
|
-
status: z.literal("available"),
|
|
2880
|
-
version: z.number().int().positive(),
|
|
2881
|
-
format: z.literal("enhance-scene-json"),
|
|
2882
|
-
code: z.string(),
|
|
2883
|
-
prototypes: z.array(z.object({
|
|
2884
|
-
nodeId: z.string(),
|
|
2885
|
-
prototypeId: z.uuid(),
|
|
2886
|
-
deploymentId: z.uuid(),
|
|
2887
|
-
capability: z.literal("canvas.read"),
|
|
2888
|
-
canvasPath: z.string(),
|
|
2889
|
-
input: z.object({
|
|
2890
|
-
canvasRef: z.uuid(),
|
|
2891
|
-
view: z.literal("source"),
|
|
2892
|
-
nodeId: z.string()
|
|
2893
|
-
}),
|
|
2894
|
-
guidance: z.string()
|
|
2895
|
-
})),
|
|
2896
|
-
guidance: z.string()
|
|
2897
|
-
}), z.object({
|
|
2898
|
-
status: z.literal("unavailable"),
|
|
2899
|
-
guidance: z.string()
|
|
2900
|
-
})]);
|
|
2901
|
-
/** A person's image export of one layer at the saved revision, drawn by the render worker. */
|
|
2902
|
-
const createCanvasExportInputSchema = z.object({
|
|
2903
|
-
canvasId: z.uuid(),
|
|
2904
|
-
nodeId: z.string().min(1),
|
|
2905
|
-
expectedVersion: z.number().int().positive(),
|
|
2906
|
-
scale: z.number().positive()
|
|
2907
|
-
});
|
|
2908
|
-
const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2909
|
-
const downloadCanvasRenderOutputSchema = z.object({
|
|
2910
|
-
jobId: z.uuid(),
|
|
2911
|
-
download: signedDownloadSchema,
|
|
2912
|
-
source: canvasRenderSourceSchema.optional()
|
|
2913
|
-
});
|
|
2914
|
-
const canvasSnapshotRequestSchema = z.strictObject({
|
|
2915
|
-
previewJobId: z.uuid(),
|
|
2916
|
-
scope: z.strictObject({
|
|
2917
|
-
pageId: z.string().min(1).optional(),
|
|
2918
|
-
nodeIds: z.array(z.string().min(1))
|
|
2919
|
-
}),
|
|
2920
|
-
/**
|
|
2921
|
-
* Below the walkthrough: as a screen layer, which installed CLIs ask for, or as a place only,
|
|
2922
|
-
* where the agent's CLI lands an editable frame.
|
|
2923
|
-
*/
|
|
2924
|
-
placement: z.strictObject({ kind: z.enum(["below-source", "editable-below-source"]) })
|
|
2925
|
-
});
|
|
2926
|
-
const createRecordingSnapshotInputSchema = z.object({
|
|
2927
|
-
canvasId: z.uuid(),
|
|
2928
|
-
recordingId: z.uuid(),
|
|
2929
|
-
atMs: z.number().int().nonnegative(),
|
|
2930
|
-
context: z.strictObject({
|
|
2931
|
-
expectedVersion: z.number().int().positive(),
|
|
2932
|
-
request: canvasSnapshotRequestSchema
|
|
2933
|
-
}).optional()
|
|
2934
|
-
});
|
|
2935
|
-
const createRecordingSnapshotOutputSchema = z.object({
|
|
2936
|
-
job: canvasRenderJobSchema,
|
|
2937
|
-
alreadyExists: z.boolean()
|
|
2938
|
-
});
|
|
2939
|
-
|
|
2940
|
-
//#endregion
|
|
2941
|
-
//#region ../../packages/contract/src/canvas/canvas-write-scope.schema.ts
|
|
2942
|
-
const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) });
|
|
2943
|
-
|
|
2944
|
-
//#endregion
|
|
2945
|
-
//#region ../../packages/contract/src/canvas/canvas-conversion.schema.ts
|
|
2946
|
-
const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
|
|
2947
|
-
z.object({ kind: z.literal("adjacent") }),
|
|
2948
|
-
z.object({
|
|
2949
|
-
kind: z.literal("insert-children"),
|
|
2950
|
-
pageId: z.string().min(1).optional(),
|
|
2951
|
-
targetNodeId: z.string().min(1)
|
|
2952
|
-
}),
|
|
2953
|
-
z.object({
|
|
2954
|
-
kind: z.literal("replace"),
|
|
2955
|
-
targetNodeId: z.string().min(1),
|
|
2956
|
-
/**
|
|
2957
|
-
* A capture's swap: the target must still be the capture's picture. When another browser has
|
|
2958
|
-
* already made it editable, the swap is refused as `capture-already-landed`.
|
|
2959
|
-
*/
|
|
2960
|
-
onlyPicture: z.literal(true).optional()
|
|
2961
|
-
})
|
|
2962
|
-
]);
|
|
2963
|
-
const canvasConversionSourceSchema = z.discriminatedUnion("kind", [z.object({
|
|
2964
|
-
kind: z.literal("screen"),
|
|
2965
|
-
nodeId: z.string().min(1)
|
|
2966
|
-
}), z.object({
|
|
2967
|
-
kind: z.literal("html"),
|
|
2968
|
-
html: z.string().min(1),
|
|
2969
|
-
label: z.string().min(1),
|
|
2970
|
-
idPrefix: z.string().min(1).regex(/^[\w-]+$/u).optional()
|
|
2971
|
-
})]);
|
|
2972
|
-
const canvasConversionRequestSchema = z.object({
|
|
2973
|
-
source: canvasConversionSourceSchema,
|
|
2974
|
-
destination: canvasConversionDestinationSchema,
|
|
2975
|
-
revisionPolicy: z.enum(["strict", "rebase"]).optional()
|
|
2976
|
-
}).superRefine((request, context) => {
|
|
2977
|
-
if (request.source.kind === "screen" && request.destination.kind !== "adjacent") context.addIssue({
|
|
2978
|
-
code: "custom",
|
|
2979
|
-
message: "stored screens convert beside their source",
|
|
2980
|
-
path: ["destination"]
|
|
2981
|
-
});
|
|
2982
|
-
if (request.source.kind === "html" && request.destination.kind === "adjacent") context.addIssue({
|
|
2983
|
-
code: "custom",
|
|
2984
|
-
message: "authored HTML requires an editable destination",
|
|
2985
|
-
path: ["destination"]
|
|
2986
|
-
});
|
|
2987
|
-
});
|
|
2988
|
-
const canvasConversionSourceSummarySchema = z.discriminatedUnion("kind", [z.object({
|
|
2989
|
-
kind: z.literal("screen"),
|
|
2990
|
-
nodeId: z.string().min(1)
|
|
2991
|
-
}), z.object({
|
|
2992
|
-
kind: z.literal("html"),
|
|
2993
|
-
label: z.string().min(1)
|
|
2994
|
-
})]);
|
|
2995
|
-
const canvasConversionJobBaseSchema = z.object({
|
|
2996
|
-
id: z.uuid(),
|
|
2997
|
-
canvasId: z.uuid(),
|
|
2998
|
-
source: canvasConversionSourceSummarySchema,
|
|
2999
|
-
destination: canvasConversionDestinationSchema,
|
|
3000
|
-
phase: canvasRenderPhaseSchema,
|
|
3001
|
-
requestedVersion: z.number().int().positive(),
|
|
3002
|
-
attempt: z.number().int().nonnegative(),
|
|
3003
|
-
createdAt: z.iso.datetime(),
|
|
3004
|
-
updatedAt: z.iso.datetime()
|
|
3005
|
-
});
|
|
3006
|
-
const canvasConversionJobSchema = z.discriminatedUnion("state", [
|
|
3007
|
-
canvasConversionJobBaseSchema.extend({
|
|
3008
|
-
state: z.literal("queued"),
|
|
3009
|
-
result: z.null(),
|
|
3010
|
-
failure: z.null()
|
|
3011
|
-
}),
|
|
3012
|
-
canvasConversionJobBaseSchema.extend({
|
|
3013
|
-
state: z.literal("running"),
|
|
3014
|
-
result: z.null(),
|
|
3015
|
-
failure: z.null()
|
|
3016
|
-
}),
|
|
3017
|
-
canvasConversionJobBaseSchema.extend({
|
|
3018
|
-
state: z.literal("succeeded"),
|
|
3019
|
-
phase: z.literal("complete"),
|
|
3020
|
-
result: createEditableFrameResultSchema.extend({ report: canvasConversionReportSchema }),
|
|
3021
|
-
failure: z.null()
|
|
3022
|
-
}),
|
|
3023
|
-
canvasConversionJobBaseSchema.extend({
|
|
3024
|
-
state: z.literal("failed"),
|
|
3025
|
-
result: z.null(),
|
|
3026
|
-
failure: canvasRenderFailureSchema
|
|
3027
|
-
}),
|
|
3028
|
-
canvasConversionJobBaseSchema.extend({
|
|
3029
|
-
state: z.literal("cancelled"),
|
|
3030
|
-
result: z.null(),
|
|
3031
|
-
failure: canvasRenderFailureSchema.extend({ reason: z.literal("CANCELLED") })
|
|
3032
|
-
}),
|
|
3033
|
-
canvasConversionJobBaseSchema.extend({
|
|
3034
|
-
state: z.literal("expired"),
|
|
3035
|
-
result: z.null(),
|
|
3036
|
-
failure: canvasRenderFailureSchema.extend({ reason: z.literal("EXPIRED") })
|
|
3037
|
-
})
|
|
3038
|
-
]);
|
|
3039
|
-
const createCanvasConversionInputSchema = canvasConversionRequestSchema.and(z.object({
|
|
3040
|
-
canvasId: z.uuid(),
|
|
3041
|
-
expectedVersion: z.number().int().positive().optional(),
|
|
3042
|
-
mutationId: z.uuid().optional(),
|
|
3043
|
-
writeScope: canvasWriteScopeSchema.optional(),
|
|
3044
|
-
scope: createCanvasRenderInputSchema.shape.scope
|
|
3045
|
-
})).refine((input) => input.scope === void 0 && input.revisionPolicy !== "strict" || input.expectedVersion !== void 0, {
|
|
3046
|
-
message: "scoped or strict conversion requires an expected version",
|
|
3047
|
-
path: ["expectedVersion"]
|
|
3048
|
-
});
|
|
3049
|
-
const createCanvasConversionOutputSchema = z.object({
|
|
3050
|
-
job: canvasConversionJobSchema,
|
|
2387
|
+
const createCanvasConversionInputSchema = canvasConversionRequestSchema.and(z.object({
|
|
2388
|
+
canvasId: z.uuid(),
|
|
2389
|
+
expectedVersion: z.number().int().positive().optional(),
|
|
2390
|
+
mutationId: z.uuid().optional(),
|
|
2391
|
+
writeScope: canvasWriteScopeSchema.optional(),
|
|
2392
|
+
scope: createCanvasRenderInputSchema.shape.scope
|
|
2393
|
+
})).refine((input) => input.scope === void 0 && input.revisionPolicy !== "strict" || input.expectedVersion !== void 0, {
|
|
2394
|
+
message: "scoped or strict conversion requires an expected version",
|
|
2395
|
+
path: ["expectedVersion"]
|
|
2396
|
+
});
|
|
2397
|
+
const createCanvasConversionOutputSchema = z.object({
|
|
2398
|
+
job: canvasConversionJobSchema,
|
|
3051
2399
|
alreadyExists: z.boolean()
|
|
3052
2400
|
});
|
|
3053
2401
|
const getCanvasConversionInputSchema = z.object({ jobId: z.uuid() });
|
|
@@ -3063,7 +2411,9 @@ const conversionRouteStateSchema = z.discriminatedUnion("state", [
|
|
|
3063
2411
|
state: z.literal("ready"),
|
|
3064
2412
|
jobId: z.uuid(),
|
|
3065
2413
|
loadedVersion: z.number().int().positive(),
|
|
3066
|
-
draft: canvasSubtreeDraftSchema
|
|
2414
|
+
draft: canvasSubtreeDraftSchema,
|
|
2415
|
+
/** Where measured placement put the draft's root, when the request asked for it. */
|
|
2416
|
+
placement: canvasSceneBoxSchema.optional()
|
|
3067
2417
|
}),
|
|
3068
2418
|
z.object({
|
|
3069
2419
|
state: z.literal("failed"),
|
|
@@ -3448,6 +2798,72 @@ const canvasEditTextOperationSchema = z.object({
|
|
|
3448
2798
|
source: canvasTextSourceSchema.optional()
|
|
3449
2799
|
});
|
|
3450
2800
|
|
|
2801
|
+
//#endregion
|
|
2802
|
+
//#region ../../packages/contract/src/canvas/canvas-text-style.schema.ts
|
|
2803
|
+
const MAX_DESCRIPTION$1 = 2e3;
|
|
2804
|
+
const MAX_OVERRIDE_VALUE = 1e3;
|
|
2805
|
+
const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
|
|
2806
|
+
family: true,
|
|
2807
|
+
fallbackFamilies: true,
|
|
2808
|
+
size: true,
|
|
2809
|
+
weight: true,
|
|
2810
|
+
style: true,
|
|
2811
|
+
variations: true,
|
|
2812
|
+
opticalSize: true,
|
|
2813
|
+
features: true,
|
|
2814
|
+
lineHeight: true,
|
|
2815
|
+
letterSpacing: true,
|
|
2816
|
+
transform: true,
|
|
2817
|
+
decoration: true,
|
|
2818
|
+
paragraphSpacing: true,
|
|
2819
|
+
paragraphIndent: true,
|
|
2820
|
+
listSpacing: true,
|
|
2821
|
+
hangingList: true,
|
|
2822
|
+
hangingPunctuation: true,
|
|
2823
|
+
verticalTrim: true,
|
|
2824
|
+
wrapStyle: true
|
|
2825
|
+
}).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
|
|
2826
|
+
const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
|
|
2827
|
+
const canvasTextStyleSchema = z.object({
|
|
2828
|
+
id: z.string().min(1),
|
|
2829
|
+
name: z.string().trim().min(1),
|
|
2830
|
+
description: z.string().max(MAX_DESCRIPTION$1),
|
|
2831
|
+
sortKey: z.string().min(1).optional(),
|
|
2832
|
+
sourceStyleId: z.string().min(1).optional(),
|
|
2833
|
+
sourceCanvasId: z.uuid().optional(),
|
|
2834
|
+
sourceRevision: z.number().int().positive().optional(),
|
|
2835
|
+
typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
|
|
2836
|
+
Reflect.deleteProperty(typography, "listStyle");
|
|
2837
|
+
return typography;
|
|
2838
|
+
})
|
|
2839
|
+
}).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
|
|
2840
|
+
message: "A source canvas belongs to a reference snapshot.",
|
|
2841
|
+
path: ["sourceCanvasId"]
|
|
2842
|
+
}).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
|
|
2843
|
+
message: "A published revision belongs to a source style and canvas.",
|
|
2844
|
+
path: ["sourceRevision"]
|
|
2845
|
+
});
|
|
2846
|
+
const canvasTextStyleBindingSchema = z.object({
|
|
2847
|
+
id: canvasTextStyleSchema.shape.id,
|
|
2848
|
+
position: z.enum([
|
|
2849
|
+
"normal",
|
|
2850
|
+
"subscript",
|
|
2851
|
+
"superscript"
|
|
2852
|
+
]).optional(),
|
|
2853
|
+
overrides: z.partialRecord(z.enum([
|
|
2854
|
+
"fontWeight",
|
|
2855
|
+
"fontStyle",
|
|
2856
|
+
"fontVariationSettings",
|
|
2857
|
+
"fontOpticalSizing",
|
|
2858
|
+
"textDecorationLine",
|
|
2859
|
+
"textDecorationStyle",
|
|
2860
|
+
"textDecorationColor",
|
|
2861
|
+
"textDecorationThickness",
|
|
2862
|
+
"textUnderlineOffset",
|
|
2863
|
+
"textDecorationSkipInk"
|
|
2864
|
+
]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
|
|
2865
|
+
}).strict();
|
|
2866
|
+
|
|
3451
2867
|
//#endregion
|
|
3452
2868
|
//#region ../../packages/contract/src/canvas/text-style-library.schema.ts
|
|
3453
2869
|
const MAX_DESCRIPTION = 2e3;
|
|
@@ -3717,6 +3133,932 @@ const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
|
|
|
3717
3133
|
next: z.array(z.string().min(1))
|
|
3718
3134
|
});
|
|
3719
3135
|
|
|
3136
|
+
//#endregion
|
|
3137
|
+
//#region ../../packages/contract/src/canvas/canvas-operation-writes.schema.ts
|
|
3138
|
+
/**
|
|
3139
|
+
* What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
|
|
3140
|
+
* values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
|
|
3141
|
+
* group of values, which a client that read the canvas in an older format may have stripped.
|
|
3142
|
+
*/
|
|
3143
|
+
const CANVAS_OPERATION_WRITES = {
|
|
3144
|
+
insertConvertedSubtree: "whole",
|
|
3145
|
+
insertNode: "whole",
|
|
3146
|
+
insertText: "names",
|
|
3147
|
+
insertPrototype: "names",
|
|
3148
|
+
setPrototypeDeployment: "names",
|
|
3149
|
+
editText: "names",
|
|
3150
|
+
setText: "names",
|
|
3151
|
+
setBox: "names",
|
|
3152
|
+
setLabel: "names",
|
|
3153
|
+
setContainerKind: "names",
|
|
3154
|
+
setVisibility: "names",
|
|
3155
|
+
setLocked: "names",
|
|
3156
|
+
setConstraints: "names",
|
|
3157
|
+
setStyles: "names",
|
|
3158
|
+
patchExportSettings: "names",
|
|
3159
|
+
setAppearance: "names",
|
|
3160
|
+
setLayout: "whole",
|
|
3161
|
+
patchTypography: "names",
|
|
3162
|
+
setTypography: "whole",
|
|
3163
|
+
patchAdditionalStyles: "names",
|
|
3164
|
+
setAdditionalStyles: "whole",
|
|
3165
|
+
setArtworkColor: "whole",
|
|
3166
|
+
setTextStyleLibrary: "whole",
|
|
3167
|
+
patchFontLibrary: "names",
|
|
3168
|
+
setTextStyle: "whole",
|
|
3169
|
+
setGeometry: "whole",
|
|
3170
|
+
setProps: "whole",
|
|
3171
|
+
setParentage: "names",
|
|
3172
|
+
move: "names",
|
|
3173
|
+
remove: "names"
|
|
3174
|
+
};
|
|
3175
|
+
|
|
3176
|
+
//#endregion
|
|
3177
|
+
//#region ../../packages/contract/src/canvas/canvas-mutation.schema.ts
|
|
3178
|
+
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
3179
|
+
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
3180
|
+
width: z.number().positive(),
|
|
3181
|
+
height: z.number().positive()
|
|
3182
|
+
});
|
|
3183
|
+
const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
|
|
3184
|
+
/** A receipt stored before boxes said what they are holds none, so the source stays optional. */
|
|
3185
|
+
const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
|
|
3186
|
+
const canvasMutationRequestContextSchema = z.strictObject({
|
|
3187
|
+
fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
3188
|
+
revisionPolicy: z.enum(["strict", "rebase"]),
|
|
3189
|
+
copiedNodeIds: copiedNodeIdsSchema.optional()
|
|
3190
|
+
});
|
|
3191
|
+
/** The request's fields alone, for callers that derive their own input from it. */
|
|
3192
|
+
const applyCanvasOperationsFieldsSchema = z.object({
|
|
3193
|
+
canvasId: z.uuid(),
|
|
3194
|
+
mutationId: z.uuid(),
|
|
3195
|
+
documentFormatVersion: canvasDocumentFormatSchema,
|
|
3196
|
+
baseVersion: z.number().int().positive(),
|
|
3197
|
+
operations: z.array(canvasOperationSchema).min(1),
|
|
3198
|
+
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
3199
|
+
writeScope: canvasWriteScopeSchema.optional()
|
|
3200
|
+
});
|
|
3201
|
+
const applyCanvasOperationsInputSchema = applyCanvasOperationsFieldsSchema.superRefine((input, context) => {
|
|
3202
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
|
|
3203
|
+
});
|
|
3204
|
+
const applyCanvasOperationsOutputSchema = z.object({
|
|
3205
|
+
canvasId: z.uuid(),
|
|
3206
|
+
mutationId: z.uuid(),
|
|
3207
|
+
previousVersion: z.number().int().positive(),
|
|
3208
|
+
version: z.number().int().positive(),
|
|
3209
|
+
operations: z.array(canvasOperationSchema),
|
|
3210
|
+
insertedNodeIds: z.array(nodeIdSchema$2),
|
|
3211
|
+
changedNodeIds: z.array(nodeIdSchema$2),
|
|
3212
|
+
removedNodeIds: z.array(nodeIdSchema$2),
|
|
3213
|
+
boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
3214
|
+
affectedBounds: writableBoxSchema.nullable(),
|
|
3215
|
+
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
3216
|
+
next: z.array(z.string().min(1))
|
|
3217
|
+
});
|
|
3218
|
+
const getCanvasMutationInputSchema = z.strictObject({
|
|
3219
|
+
canvasId: z.uuid(),
|
|
3220
|
+
mutationId: z.uuid(),
|
|
3221
|
+
fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
|
|
3222
|
+
});
|
|
3223
|
+
const getCanvasMutationOutputSchema = z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
|
|
3224
|
+
state: z.literal("committed"),
|
|
3225
|
+
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
3226
|
+
result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
|
|
3227
|
+
})]);
|
|
3228
|
+
|
|
3229
|
+
//#endregion
|
|
3230
|
+
//#region ../../packages/contract/src/canvas/canvas-agent-edit.schema.ts
|
|
3231
|
+
const nodeId$6 = z.string().min(1);
|
|
3232
|
+
const nodeIds$2 = z.array(nodeId$6).min(1);
|
|
3233
|
+
/** An agent's small edits, in the order the API plans them. */
|
|
3234
|
+
const canvasAgentEditsSchema = z.array(z.discriminatedUnion("kind", [
|
|
3235
|
+
z.object({
|
|
3236
|
+
kind: z.literal("set_text"),
|
|
3237
|
+
nodeId: nodeId$6,
|
|
3238
|
+
text: z.string()
|
|
3239
|
+
}),
|
|
3240
|
+
z.object({
|
|
3241
|
+
kind: z.literal("set_styles"),
|
|
3242
|
+
nodeIds: nodeIds$2,
|
|
3243
|
+
styles: z.record(z.string(), z.union([
|
|
3244
|
+
z.string(),
|
|
3245
|
+
z.number(),
|
|
3246
|
+
z.null()
|
|
3247
|
+
]))
|
|
3248
|
+
}),
|
|
3249
|
+
z.object({
|
|
3250
|
+
kind: z.literal("rename"),
|
|
3251
|
+
nodeId: nodeId$6,
|
|
3252
|
+
name: z.string().trim().min(1)
|
|
3253
|
+
}),
|
|
3254
|
+
z.object({
|
|
3255
|
+
kind: z.literal("duplicate"),
|
|
3256
|
+
nodeIds: nodeIds$2,
|
|
3257
|
+
parentId: nodeId$6.optional()
|
|
3258
|
+
}),
|
|
3259
|
+
z.object({
|
|
3260
|
+
kind: z.literal("move"),
|
|
3261
|
+
nodeId: nodeId$6,
|
|
3262
|
+
destination: z.discriminatedUnion("kind", [
|
|
3263
|
+
z.object({
|
|
3264
|
+
kind: z.literal("before"),
|
|
3265
|
+
nodeId: nodeId$6
|
|
3266
|
+
}),
|
|
3267
|
+
z.object({
|
|
3268
|
+
kind: z.literal("after"),
|
|
3269
|
+
nodeId: nodeId$6
|
|
3270
|
+
}),
|
|
3271
|
+
z.object({
|
|
3272
|
+
kind: z.literal("parent"),
|
|
3273
|
+
parentId: nodeId$6,
|
|
3274
|
+
index: z.number().int().nonnegative().optional()
|
|
3275
|
+
})
|
|
3276
|
+
])
|
|
3277
|
+
})
|
|
3278
|
+
])).min(1);
|
|
3279
|
+
/** An edit batch the API plans and saves as one version. */
|
|
3280
|
+
const editCanvasInputSchema = z.strictObject({
|
|
3281
|
+
canvasId: z.uuid(),
|
|
3282
|
+
mutationId: z.uuid(),
|
|
3283
|
+
baseVersion: z.number().int().positive(),
|
|
3284
|
+
edits: canvasAgentEditsSchema,
|
|
3285
|
+
/** The prefix of copies' ids; the API makes one from the mutation id when it is left out. */
|
|
3286
|
+
idPrefix: z.string().min(1).optional(),
|
|
3287
|
+
/** A selection link's layers: the batch may change nothing outside them. */
|
|
3288
|
+
scopeNodeIds: z.array(nodeId$6).optional(),
|
|
3289
|
+
/** A selection link's page: the batch may name no layer on another page. */
|
|
3290
|
+
scopePageId: z.string().min(1).optional(),
|
|
3291
|
+
/** Whose words a refusal's next step is written in. */
|
|
3292
|
+
surface: z.enum(["cli", "mcp"]).optional(),
|
|
3293
|
+
fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
|
|
3294
|
+
});
|
|
3295
|
+
const plannedNodeSchema = z.object({
|
|
3296
|
+
sourceId: z.string(),
|
|
3297
|
+
newId: z.string(),
|
|
3298
|
+
name: z.string(),
|
|
3299
|
+
component: z.string(),
|
|
3300
|
+
descendantIdMap: z.record(z.string(), z.string())
|
|
3301
|
+
});
|
|
3302
|
+
const editCanvasOutputSchema = z.discriminatedUnion("outcome", [applyCanvasOperationsOutputSchema.extend({
|
|
3303
|
+
outcome: z.literal("committed"),
|
|
3304
|
+
/** True when the answer is the commit of an earlier identical request. */
|
|
3305
|
+
recovered: z.boolean(),
|
|
3306
|
+
duplicatedNodes: z.array(plannedNodeSchema).optional(),
|
|
3307
|
+
moves: z.array(z.object({
|
|
3308
|
+
nodeId: z.string(),
|
|
3309
|
+
parentId: z.string(),
|
|
3310
|
+
index: z.number().int()
|
|
3311
|
+
})).optional(),
|
|
3312
|
+
affectedParents: z.array(z.object({
|
|
3313
|
+
parentId: z.string(),
|
|
3314
|
+
children: z.array(z.string())
|
|
3315
|
+
})).optional()
|
|
3316
|
+
}), z.object({
|
|
3317
|
+
outcome: z.literal("no_op"),
|
|
3318
|
+
canvasId: z.uuid(),
|
|
3319
|
+
version: z.number().int().positive()
|
|
3320
|
+
})]);
|
|
3321
|
+
|
|
3322
|
+
//#endregion
|
|
3323
|
+
//#region ../../packages/contract/src/canvas/canvas-text-links.lib.ts
|
|
3324
|
+
const FORBIDDEN_DOMAIN_CHARACTERS = /* @__PURE__ */ new Set([
|
|
3325
|
+
"#",
|
|
3326
|
+
"%",
|
|
3327
|
+
"/",
|
|
3328
|
+
":",
|
|
3329
|
+
"<",
|
|
3330
|
+
">",
|
|
3331
|
+
"?",
|
|
3332
|
+
"@",
|
|
3333
|
+
"[",
|
|
3334
|
+
"\\",
|
|
3335
|
+
"]",
|
|
3336
|
+
"^",
|
|
3337
|
+
"|"
|
|
3338
|
+
]);
|
|
3339
|
+
const ASCII_SPACE = 32;
|
|
3340
|
+
const ASCII_DELETE = 127;
|
|
3341
|
+
/** Check the decoded host because browser URL parsing can retain host spaces as percent escapes. */
|
|
3342
|
+
const isHttpHostname = (url) => {
|
|
3343
|
+
if (url.hostname.startsWith("[")) return true;
|
|
3344
|
+
const hostname = decodeURIComponent(url.hostname);
|
|
3345
|
+
for (const character of hostname) {
|
|
3346
|
+
const point = character.codePointAt(0) ?? 0;
|
|
3347
|
+
if (point === ASCII_DELETE || point <= ASCII_SPACE || FORBIDDEN_DOMAIN_CHARACTERS.has(character)) return false;
|
|
3348
|
+
}
|
|
3349
|
+
return hostname !== "";
|
|
3350
|
+
};
|
|
3351
|
+
const SAFE_HREF_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
3352
|
+
"http:",
|
|
3353
|
+
"https:",
|
|
3354
|
+
"mailto:",
|
|
3355
|
+
"tel:"
|
|
3356
|
+
]);
|
|
3357
|
+
const isCanvasRichTextHref = (value) => {
|
|
3358
|
+
const href = value.trim();
|
|
3359
|
+
if (href === "") return false;
|
|
3360
|
+
try {
|
|
3361
|
+
const url = new URL(href, "https://enhance.invalid/");
|
|
3362
|
+
return SAFE_HREF_PROTOCOLS.has(url.protocol) && (!["http:", "https:"].includes(url.protocol) || isHttpHostname(url));
|
|
3363
|
+
} catch {
|
|
3364
|
+
return false;
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
|
|
3368
|
+
//#endregion
|
|
3369
|
+
//#region ../../packages/contract/src/canvas/canvas-rich-text.consts.ts
|
|
3370
|
+
const CANVAS_RICH_TEXT_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
3371
|
+
"alignItems",
|
|
3372
|
+
"backgroundColor",
|
|
3373
|
+
"borderBottom",
|
|
3374
|
+
"borderBottomLeftRadius",
|
|
3375
|
+
"borderBottomRightRadius",
|
|
3376
|
+
"borderLeft",
|
|
3377
|
+
"borderRight",
|
|
3378
|
+
"borderTop",
|
|
3379
|
+
"borderTopLeftRadius",
|
|
3380
|
+
"borderTopRightRadius",
|
|
3381
|
+
"boxShadow",
|
|
3382
|
+
"boxSizing",
|
|
3383
|
+
"color",
|
|
3384
|
+
"columnGap",
|
|
3385
|
+
"direction",
|
|
3386
|
+
"display",
|
|
3387
|
+
"flexDirection",
|
|
3388
|
+
"fontFamily",
|
|
3389
|
+
"fontFeatureSettings",
|
|
3390
|
+
"fontOpticalSizing",
|
|
3391
|
+
"fontSize",
|
|
3392
|
+
"fontStretch",
|
|
3393
|
+
"fontStyle",
|
|
3394
|
+
"fontVariant",
|
|
3395
|
+
"fontVariantCaps",
|
|
3396
|
+
"fontVariantLigatures",
|
|
3397
|
+
"fontVariantNumeric",
|
|
3398
|
+
"fontVariantPosition",
|
|
3399
|
+
"fontKerning",
|
|
3400
|
+
"fontVariationSettings",
|
|
3401
|
+
"fontWeight",
|
|
3402
|
+
"hyphenateCharacter",
|
|
3403
|
+
"hyphens",
|
|
3404
|
+
"justifyContent",
|
|
3405
|
+
"letterSpacing",
|
|
3406
|
+
"lineBreak",
|
|
3407
|
+
"lineHeight",
|
|
3408
|
+
"marginBottom",
|
|
3409
|
+
"marginLeft",
|
|
3410
|
+
"marginRight",
|
|
3411
|
+
"marginTop",
|
|
3412
|
+
"opacity",
|
|
3413
|
+
"overflowWrap",
|
|
3414
|
+
"paddingBottom",
|
|
3415
|
+
"paddingLeft",
|
|
3416
|
+
"paddingRight",
|
|
3417
|
+
"paddingTop",
|
|
3418
|
+
"rowGap",
|
|
3419
|
+
"tabSize",
|
|
3420
|
+
"textCombineUpright",
|
|
3421
|
+
"textDecorationColor",
|
|
3422
|
+
"textDecorationLine",
|
|
3423
|
+
"textDecorationSkipInk",
|
|
3424
|
+
"textDecorationStyle",
|
|
3425
|
+
"textDecorationThickness",
|
|
3426
|
+
"textEmphasisColor",
|
|
3427
|
+
"textEmphasisPosition",
|
|
3428
|
+
"textEmphasisStyle",
|
|
3429
|
+
"textOrientation",
|
|
3430
|
+
"textRendering",
|
|
3431
|
+
"textShadow",
|
|
3432
|
+
"textTransform",
|
|
3433
|
+
"textUnderlineOffset",
|
|
3434
|
+
"unicodeBidi",
|
|
3435
|
+
"verticalAlign",
|
|
3436
|
+
"whiteSpace",
|
|
3437
|
+
"wordBreak",
|
|
3438
|
+
"wordSpacing",
|
|
3439
|
+
"WebkitFontSmoothing",
|
|
3440
|
+
"WebkitLocale",
|
|
3441
|
+
"WebkitTextFillColor",
|
|
3442
|
+
"WebkitTextStrokeColor",
|
|
3443
|
+
"WebkitTextStrokeWidth",
|
|
3444
|
+
"--canvas-text-stroke-alignment"
|
|
3445
|
+
]);
|
|
3446
|
+
|
|
3447
|
+
//#endregion
|
|
3448
|
+
//#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
|
|
3449
|
+
const fillsSchema = canvasPaintSchema.array().optional();
|
|
3450
|
+
/** What one rich text run stores besides its text, which the owner list of paint blends reads. */
|
|
3451
|
+
const canvasRichTextRunPaintSchema = z.object({ fills: fillsSchema });
|
|
3452
|
+
const characterFormattingSchema = canvasTextParagraphSchema.pick({
|
|
3453
|
+
paragraphSpacing: true,
|
|
3454
|
+
paragraphIndent: true,
|
|
3455
|
+
listSpacing: true,
|
|
3456
|
+
wrapStyle: true
|
|
3457
|
+
}).extend({
|
|
3458
|
+
hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
|
|
3459
|
+
verticalTrim: canvasTypographySchema.shape.verticalTrim,
|
|
3460
|
+
stroke: canvasTypographySchema.shape.stroke.nullable(),
|
|
3461
|
+
decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
|
|
3462
|
+
backgroundBlendMode: canvasBlendModeSchema.optional()
|
|
3463
|
+
}).strip();
|
|
3464
|
+
const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
|
|
3465
|
+
const richStylesOf = (value) => {
|
|
3466
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
3467
|
+
const entries = Object.entries(value);
|
|
3468
|
+
if (entries.some(([property, styleValue]) => !CANVAS_RICH_TEXT_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
|
|
3469
|
+
return Object.fromEntries(entries);
|
|
3470
|
+
};
|
|
3471
|
+
const richMetadataOf = (value) => {
|
|
3472
|
+
const sourcePath = Reflect.get(value, "sourcePath");
|
|
3473
|
+
return {
|
|
3474
|
+
...Object.fromEntries(Object.entries(value).filter(([key]) => ![
|
|
3475
|
+
"text",
|
|
3476
|
+
"href",
|
|
3477
|
+
"sourcePath",
|
|
3478
|
+
"styles",
|
|
3479
|
+
"fills",
|
|
3480
|
+
"stroke",
|
|
3481
|
+
"decorationBlendMode",
|
|
3482
|
+
"backgroundBlendMode",
|
|
3483
|
+
"paragraph",
|
|
3484
|
+
"paragraphSpacing",
|
|
3485
|
+
"paragraphIndent",
|
|
3486
|
+
"listSpacing",
|
|
3487
|
+
"hangingPunctuation",
|
|
3488
|
+
"verticalTrim",
|
|
3489
|
+
"wrapStyle",
|
|
3490
|
+
"soft",
|
|
3491
|
+
"textStyle"
|
|
3492
|
+
].includes(key))),
|
|
3493
|
+
...typeof sourcePath === "string" && { sourcePath }
|
|
3494
|
+
};
|
|
3495
|
+
};
|
|
3496
|
+
const richChildrenOf = (values) => {
|
|
3497
|
+
const result = [];
|
|
3498
|
+
const pending = values.toReversed().map((value) => ({
|
|
3499
|
+
value,
|
|
3500
|
+
target: result
|
|
3501
|
+
}));
|
|
3502
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
3503
|
+
while (pending.length > 0) {
|
|
3504
|
+
const task = pending.pop();
|
|
3505
|
+
if (task === void 0) continue;
|
|
3506
|
+
if ("done" in task) {
|
|
3507
|
+
ancestors.delete(task.done);
|
|
3508
|
+
continue;
|
|
3509
|
+
}
|
|
3510
|
+
const children = [];
|
|
3511
|
+
const node = richNodeOf(task.value, children);
|
|
3512
|
+
if (node === null) return null;
|
|
3513
|
+
task.target.push(node);
|
|
3514
|
+
if (node.kind !== "span") continue;
|
|
3515
|
+
const value = task.value;
|
|
3516
|
+
if (typeof value !== "object" || value === null || ancestors.has(value)) return null;
|
|
3517
|
+
ancestors.add(value);
|
|
3518
|
+
pending.push({ done: value });
|
|
3519
|
+
const nested = Reflect.get(value, "children");
|
|
3520
|
+
if (!Array.isArray(nested)) return null;
|
|
3521
|
+
const candidates = nested;
|
|
3522
|
+
for (const child of candidates.toReversed()) pending.push({
|
|
3523
|
+
value: child,
|
|
3524
|
+
target: children
|
|
3525
|
+
});
|
|
3526
|
+
}
|
|
3527
|
+
return result;
|
|
3528
|
+
};
|
|
3529
|
+
const richBreakOf = (value) => {
|
|
3530
|
+
const soft = Reflect.get(value, "soft");
|
|
3531
|
+
if (soft !== void 0 && soft !== true) return null;
|
|
3532
|
+
return {
|
|
3533
|
+
...richMetadataOf(value),
|
|
3534
|
+
kind: "break",
|
|
3535
|
+
...soft === true && { soft }
|
|
3536
|
+
};
|
|
3537
|
+
};
|
|
3538
|
+
const richNodeOf = (value, children) => {
|
|
3539
|
+
if (typeof value !== "object" || value === null) return null;
|
|
3540
|
+
const kind = Reflect.get(value, "kind");
|
|
3541
|
+
const metadata = richMetadataOf(value);
|
|
3542
|
+
if (kind === "break") return richBreakOf(value);
|
|
3543
|
+
if (kind === "text") {
|
|
3544
|
+
const text = Reflect.get(value, "text");
|
|
3545
|
+
return typeof text === "string" ? {
|
|
3546
|
+
...metadata,
|
|
3547
|
+
kind,
|
|
3548
|
+
text
|
|
3549
|
+
} : null;
|
|
3550
|
+
}
|
|
3551
|
+
if (kind !== "span") return null;
|
|
3552
|
+
const values = Reflect.get(value, "children");
|
|
3553
|
+
const styles = richStylesOf(Reflect.get(value, "styles"));
|
|
3554
|
+
const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
|
|
3555
|
+
const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
|
|
3556
|
+
const formatting = characterFormattingSchema.safeParse(value);
|
|
3557
|
+
const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
|
|
3558
|
+
if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
|
|
3559
|
+
const href = safeHref(Reflect.get(value, "href"));
|
|
3560
|
+
return {
|
|
3561
|
+
...metadata,
|
|
3562
|
+
kind,
|
|
3563
|
+
styles,
|
|
3564
|
+
children,
|
|
3565
|
+
...textStyle.data !== void 0 && { textStyle: textStyle.data },
|
|
3566
|
+
...fills.data !== void 0 && { fills: fills.data },
|
|
3567
|
+
...paragraph.data !== void 0 && { paragraph: paragraph.data },
|
|
3568
|
+
...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
|
|
3569
|
+
...href !== void 0 && { href }
|
|
3570
|
+
};
|
|
3571
|
+
};
|
|
3572
|
+
const richTextLeafValue = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
|
|
3573
|
+
const canvasRichTextValueOf = (nodes) => {
|
|
3574
|
+
const pending = nodes.toReversed();
|
|
3575
|
+
const text = [];
|
|
3576
|
+
while (pending.length > 0) {
|
|
3577
|
+
const node = pending.pop();
|
|
3578
|
+
if (node === void 0) break;
|
|
3579
|
+
if (node.kind === "span") for (const child of node.children.toReversed()) pending.push(child);
|
|
3580
|
+
else text.push(richTextLeafValue(node));
|
|
3581
|
+
}
|
|
3582
|
+
return text.join("");
|
|
3583
|
+
};
|
|
3584
|
+
const canvasRichTextOf = (node) => {
|
|
3585
|
+
const props = node.props;
|
|
3586
|
+
if (props === void 0 || !Array.isArray(props["richText"])) return [];
|
|
3587
|
+
const rich = richChildrenOf(props["richText"]);
|
|
3588
|
+
if (rich === null) return [];
|
|
3589
|
+
const text = props["text"];
|
|
3590
|
+
return canvasRichTextValueOf(rich) === text ? rich : [];
|
|
3591
|
+
};
|
|
3592
|
+
const hasCanvasRichTextPaints = (node) => {
|
|
3593
|
+
const pending = [...canvasRichTextOf(node)];
|
|
3594
|
+
while (pending.length > 0) {
|
|
3595
|
+
const run = pending.pop();
|
|
3596
|
+
if (run?.kind !== "span") continue;
|
|
3597
|
+
if (run.fills !== void 0) return true;
|
|
3598
|
+
for (const child of run.children) pending.push(child);
|
|
3599
|
+
}
|
|
3600
|
+
return false;
|
|
3601
|
+
};
|
|
3602
|
+
/** Existing-link edits retain authored formatting, including nested descendants. */
|
|
3603
|
+
const canvasRichTextLinkOf = (runs) => {
|
|
3604
|
+
const destinations = /* @__PURE__ */ new Set();
|
|
3605
|
+
const visit = (nodes, inherited) => {
|
|
3606
|
+
for (const node of nodes) if (node.kind === "span") visit(node.children, node.href ?? inherited);
|
|
3607
|
+
else destinations.add(inherited);
|
|
3608
|
+
};
|
|
3609
|
+
visit(runs);
|
|
3610
|
+
return destinations.size === 1 ? [...destinations][0] ?? null : null;
|
|
3611
|
+
};
|
|
3612
|
+
/**
|
|
3613
|
+
* The style text a run edit clears: the properties it sets, and for a stroke edit the style text
|
|
3614
|
+
* that copies a stroke, since the stroke value owns it.
|
|
3615
|
+
*/
|
|
3616
|
+
const canvasRunStylesClearedBy = (command) => [...Object.keys(command.styles), ...command.stroke === void 0 ? [] : [
|
|
3617
|
+
"WebkitTextStrokeWidth",
|
|
3618
|
+
"WebkitTextStrokeColor",
|
|
3619
|
+
"--canvas-text-stroke-alignment"
|
|
3620
|
+
]];
|
|
3621
|
+
|
|
3622
|
+
//#endregion
|
|
3623
|
+
//#region ../../packages/contract/src/canvas/canvas-font-asset.schema.ts
|
|
3624
|
+
const FONT_PATH_SEGMENT_LIMIT = 4;
|
|
3625
|
+
const CANVAS_FONT_CONTENT_TYPES = [
|
|
3626
|
+
"font/ttf",
|
|
3627
|
+
"font/otf",
|
|
3628
|
+
"font/woff",
|
|
3629
|
+
"font/woff2",
|
|
3630
|
+
"font/collection"
|
|
3631
|
+
];
|
|
3632
|
+
const canvasFontAssetIdentitySchema = z.object({
|
|
3633
|
+
canvasId: z.uuid(),
|
|
3634
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
3635
|
+
});
|
|
3636
|
+
const completeCanvasFontInputSchema = canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() });
|
|
3637
|
+
const reserveCanvasFontInputSchema = completeCanvasFontInputSchema.extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
|
|
3638
|
+
const completeCanvasFontOutputSchema = z.object({ path: z.string().startsWith("/v1/canvas-assets/") });
|
|
3639
|
+
const reserveCanvasFontOutputSchema = completeCanvasFontOutputSchema.extend({ upload: signedUploadSchema });
|
|
3640
|
+
const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
|
|
3641
|
+
const copyCanvasFontsInputSchema = z.object({
|
|
3642
|
+
canvasId: z.uuid(),
|
|
3643
|
+
sources: z.array(canvasFontAssetIdentitySchema).min(1)
|
|
3644
|
+
});
|
|
3645
|
+
const copyCanvasFontsOutputSchema = z.object({ resources: z.array(z.object({
|
|
3646
|
+
source: canvasFontAssetIdentitySchema,
|
|
3647
|
+
path: z.string()
|
|
3648
|
+
})) });
|
|
3649
|
+
const canvasFontAssetIdentityFromPath = (path) => {
|
|
3650
|
+
if (!path.startsWith("/v1/canvas-assets/")) return null;
|
|
3651
|
+
const [canvasId, kind, sha256, extra] = path.slice(CANVAS_ASSET_PATH_PREFIX.length).split("/", FONT_PATH_SEGMENT_LIMIT);
|
|
3652
|
+
if (kind !== "fonts" || extra !== void 0) return null;
|
|
3653
|
+
return canvasFontAssetIdentitySchema.safeParse({
|
|
3654
|
+
canvasId,
|
|
3655
|
+
sha256
|
|
3656
|
+
}).data ?? null;
|
|
3657
|
+
};
|
|
3658
|
+
|
|
3659
|
+
//#endregion
|
|
3660
|
+
//#region ../../packages/contract/src/canvas/canvas-asset-upload.schema.ts
|
|
3661
|
+
const MAX_FONT_WEIGHT = 1e3;
|
|
3662
|
+
const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
|
|
3663
|
+
const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
|
|
3664
|
+
const canvasAssetUploadIdentitySchema = z.strictObject({
|
|
3665
|
+
canvasId: z.uuid(),
|
|
3666
|
+
clientToken: z.uuid()
|
|
3667
|
+
});
|
|
3668
|
+
const reserveCanvasAssetInputSchema = z.discriminatedUnion("kind", [canvasAssetUploadIdentitySchema.extend({
|
|
3669
|
+
kind: z.literal("image"),
|
|
3670
|
+
contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
|
|
3671
|
+
bytes: z.number().int().positive(),
|
|
3672
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
3673
|
+
}), canvasAssetUploadIdentitySchema.extend({
|
|
3674
|
+
kind: z.literal("font"),
|
|
3675
|
+
contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
|
|
3676
|
+
bytes: z.number().int().positive(),
|
|
3677
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
3678
|
+
})]);
|
|
3679
|
+
const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
|
|
3680
|
+
kind: z.literal("image"),
|
|
3681
|
+
width: z.number().int().positive(),
|
|
3682
|
+
height: z.number().int().positive()
|
|
3683
|
+
}), z.strictObject({
|
|
3684
|
+
kind: z.literal("font"),
|
|
3685
|
+
family: z.string().min(1),
|
|
3686
|
+
subfamily: z.string(),
|
|
3687
|
+
style: z.enum([
|
|
3688
|
+
"normal",
|
|
3689
|
+
"italic",
|
|
3690
|
+
"oblique"
|
|
3691
|
+
]),
|
|
3692
|
+
minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
|
|
3693
|
+
maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
|
|
3694
|
+
}).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
|
|
3695
|
+
const canvasAssetUploadOutputSchema = z.strictObject({
|
|
3696
|
+
canvasId: z.uuid(),
|
|
3697
|
+
clientToken: z.uuid(),
|
|
3698
|
+
assetId: z.uuid(),
|
|
3699
|
+
kind: z.enum(["image", "font"]),
|
|
3700
|
+
contentType: z.string(),
|
|
3701
|
+
bytes: z.number().int().positive(),
|
|
3702
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
3703
|
+
path: z.string().startsWith("/v1/canvas-assets/"),
|
|
3704
|
+
state: z.enum(["awaiting_upload", "ready"]),
|
|
3705
|
+
metadata: canvasAssetMetadataSchema.nullable()
|
|
3706
|
+
}).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) => isStoredContentType(asset.kind, asset.contentType), "Content type must match the asset kind.").refine((asset) => asset.path === (asset.kind === "image" ? canvasImageAssetPath(asset.canvasId, asset.assetId) : canvasFontAssetPath(asset.canvasId, asset.sha256)), "The resource path must match its native identity.");
|
|
3707
|
+
const reserveCanvasAssetOutputSchema = canvasAssetUploadOutputSchema.safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
|
|
3708
|
+
|
|
3709
|
+
//#endregion
|
|
3710
|
+
//#region ../../packages/contract/src/canvas/canvas-css-values.lib.ts
|
|
3711
|
+
const UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
|
|
3712
|
+
"aspect-ratio",
|
|
3713
|
+
"-webkit-line-clamp",
|
|
3714
|
+
"line-clamp",
|
|
3715
|
+
"flex-grow",
|
|
3716
|
+
"flex-shrink",
|
|
3717
|
+
"font-weight",
|
|
3718
|
+
"opacity",
|
|
3719
|
+
"order",
|
|
3720
|
+
"z-index",
|
|
3721
|
+
"grid-area",
|
|
3722
|
+
"grid-row",
|
|
3723
|
+
"grid-column",
|
|
3724
|
+
"grid-row-start",
|
|
3725
|
+
"grid-row-end",
|
|
3726
|
+
"grid-column-start",
|
|
3727
|
+
"grid-column-end"
|
|
3728
|
+
]);
|
|
3729
|
+
const canvasCssValue = (property, value) => typeof value === "number" && !UNITLESS_PROPERTIES.has(property.toLowerCase()) ? `${String(value)}px` : String(value);
|
|
3730
|
+
const SIDES$2 = [
|
|
3731
|
+
"top",
|
|
3732
|
+
"right",
|
|
3733
|
+
"bottom",
|
|
3734
|
+
"left"
|
|
3735
|
+
];
|
|
3736
|
+
const LEFT_SIDE_INDEX = 3;
|
|
3737
|
+
const GRID_TEMPLATE_PROPERTIES = [
|
|
3738
|
+
"grid-template-rows",
|
|
3739
|
+
"grid-template-columns",
|
|
3740
|
+
"grid-template-areas"
|
|
3741
|
+
];
|
|
3742
|
+
const SHORTHANDS = {
|
|
3743
|
+
gap: ["row-gap", "column-gap"],
|
|
3744
|
+
"text-wrap": ["text-wrap-mode", "text-wrap-style"],
|
|
3745
|
+
padding: SIDES$2.map((side) => `padding-${side}`),
|
|
3746
|
+
margin: SIDES$2.map((side) => `margin-${side}`),
|
|
3747
|
+
flex: [
|
|
3748
|
+
"flex-grow",
|
|
3749
|
+
"flex-shrink",
|
|
3750
|
+
"flex-basis"
|
|
3751
|
+
],
|
|
3752
|
+
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
3753
|
+
"place-content": ["align-content", "justify-content"],
|
|
3754
|
+
"place-items": ["align-items", "justify-items"],
|
|
3755
|
+
"place-self": ["align-self", "justify-self"],
|
|
3756
|
+
"grid-template": GRID_TEMPLATE_PROPERTIES,
|
|
3757
|
+
grid: [
|
|
3758
|
+
...GRID_TEMPLATE_PROPERTIES,
|
|
3759
|
+
"grid-auto-rows",
|
|
3760
|
+
"grid-auto-columns",
|
|
3761
|
+
"grid-auto-flow"
|
|
3762
|
+
],
|
|
3763
|
+
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
3764
|
+
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
3765
|
+
"grid-area": [
|
|
3766
|
+
"grid-row-start",
|
|
3767
|
+
"grid-column-start",
|
|
3768
|
+
"grid-row-end",
|
|
3769
|
+
"grid-column-end"
|
|
3770
|
+
]
|
|
3771
|
+
};
|
|
3772
|
+
/** Related declarations stay authored; a longhand edit must not discard the rest of a shorthand. */
|
|
3773
|
+
const canvasCssPropertyScope = (property) => SHORTHANDS[property.toLowerCase()] ?? [property.toLowerCase()];
|
|
3774
|
+
const componentStateAfter = (state, character) => {
|
|
3775
|
+
if (state.isEscaped) return {
|
|
3776
|
+
...state,
|
|
3777
|
+
isEscaped: false
|
|
3778
|
+
};
|
|
3779
|
+
if (character === "\\") return {
|
|
3780
|
+
...state,
|
|
3781
|
+
isEscaped: true
|
|
3782
|
+
};
|
|
3783
|
+
if (state.quote !== "") return {
|
|
3784
|
+
...state,
|
|
3785
|
+
quote: state.quote === character ? "" : state.quote
|
|
3786
|
+
};
|
|
3787
|
+
if (["\"", "'"].includes(character)) return {
|
|
3788
|
+
...state,
|
|
3789
|
+
quote: character
|
|
3790
|
+
};
|
|
3791
|
+
const delta = [
|
|
3792
|
+
"(",
|
|
3793
|
+
"[",
|
|
3794
|
+
"{"
|
|
3795
|
+
].includes(character) ? 1 : [
|
|
3796
|
+
")",
|
|
3797
|
+
"]",
|
|
3798
|
+
"}"
|
|
3799
|
+
].includes(character) ? -1 : 0;
|
|
3800
|
+
return {
|
|
3801
|
+
...state,
|
|
3802
|
+
depth: state.depth + delta
|
|
3803
|
+
};
|
|
3804
|
+
};
|
|
3805
|
+
/** Split only at CSS component boundaries, keeping functions, line names and strings intact. */
|
|
3806
|
+
const canvasCssTokens = (value, separator = "space") => {
|
|
3807
|
+
const tokens = [];
|
|
3808
|
+
let token = "";
|
|
3809
|
+
let state = {
|
|
3810
|
+
depth: 0,
|
|
3811
|
+
quote: "",
|
|
3812
|
+
isEscaped: false
|
|
3813
|
+
};
|
|
3814
|
+
for (const character of value) {
|
|
3815
|
+
const canSplit = state.depth === 0 && state.quote === "" && !state.isEscaped;
|
|
3816
|
+
state = componentStateAfter(state, character);
|
|
3817
|
+
if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
|
|
3818
|
+
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
3819
|
+
token = "";
|
|
3820
|
+
} else token += character;
|
|
3821
|
+
}
|
|
3822
|
+
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
3823
|
+
return tokens;
|
|
3824
|
+
};
|
|
3825
|
+
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";
|
|
3826
|
+
const gridPlacementValue = (property, value, index) => {
|
|
3827
|
+
const parts = canvasCssTokens(value, "/");
|
|
3828
|
+
const first = parts[0] ?? value;
|
|
3829
|
+
if (property !== "grid-area") return parts[index] ?? omittedGridLine(first);
|
|
3830
|
+
const column = parts[1] ?? omittedGridLine(first);
|
|
3831
|
+
return [
|
|
3832
|
+
first,
|
|
3833
|
+
column,
|
|
3834
|
+
parts[2] ?? omittedGridLine(first),
|
|
3835
|
+
parts[3] ?? omittedGridLine(column)
|
|
3836
|
+
][index] ?? value;
|
|
3837
|
+
};
|
|
3838
|
+
const implicitGridValues = (row, column, hasAutoRows) => {
|
|
3839
|
+
const tokens = canvasCssTokens(hasAutoRows ? row : column);
|
|
3840
|
+
const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
|
|
3841
|
+
const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
|
|
3842
|
+
return [
|
|
3843
|
+
hasAutoRows ? "none" : row,
|
|
3844
|
+
hasAutoRows ? column : "none",
|
|
3845
|
+
"none",
|
|
3846
|
+
hasAutoRows && size !== "" ? size : "auto",
|
|
3847
|
+
!hasAutoRows && size !== "" ? size : "auto",
|
|
3848
|
+
flow
|
|
3849
|
+
];
|
|
3850
|
+
};
|
|
3851
|
+
const gridTemplateValue = (property, value, index) => {
|
|
3852
|
+
if (/^(?:none|initial|unset)$/iu.test(value)) return [
|
|
3853
|
+
"none",
|
|
3854
|
+
"none",
|
|
3855
|
+
"none",
|
|
3856
|
+
"auto",
|
|
3857
|
+
"auto",
|
|
3858
|
+
"row"
|
|
3859
|
+
][index] ?? value;
|
|
3860
|
+
const parts = canvasCssTokens(value, "/");
|
|
3861
|
+
const row = parts[0] ?? value;
|
|
3862
|
+
const column = parts[1];
|
|
3863
|
+
if (row === "" || column === "" || parts.length > 2) return value;
|
|
3864
|
+
const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
|
|
3865
|
+
const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
|
|
3866
|
+
if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
|
|
3867
|
+
if (hasAutoRows || hasAutoColumns) return value;
|
|
3868
|
+
const hasAreas = /["']/u.test(row);
|
|
3869
|
+
if (column === void 0 && !hasAreas) return value;
|
|
3870
|
+
return [
|
|
3871
|
+
hasAreas ? value : row,
|
|
3872
|
+
column ?? "none",
|
|
3873
|
+
hasAreas ? row : "none",
|
|
3874
|
+
"auto",
|
|
3875
|
+
"auto",
|
|
3876
|
+
"row"
|
|
3877
|
+
][index] ?? value;
|
|
3878
|
+
};
|
|
3879
|
+
const flexValues = (tokens) => {
|
|
3880
|
+
const numbers = [];
|
|
3881
|
+
let basis = "0%";
|
|
3882
|
+
for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
|
|
3883
|
+
else basis = token;
|
|
3884
|
+
return [
|
|
3885
|
+
numbers[0] ?? "1",
|
|
3886
|
+
numbers[1] ?? "1",
|
|
3887
|
+
basis
|
|
3888
|
+
];
|
|
3889
|
+
};
|
|
3890
|
+
const canvasCssShorthandValue = (property, value, index) => {
|
|
3891
|
+
if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
|
|
3892
|
+
if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
|
|
3893
|
+
if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
|
|
3894
|
+
const tokens = canvasCssTokens(value);
|
|
3895
|
+
if (property === "text-wrap") return index === 0 ? tokens.find((token) => /^(?:wrap|nowrap)$/u.test(token)) ?? "wrap" : tokens.find((token) => /^(?:auto|balance|pretty|stable)$/u.test(token)) ?? "auto";
|
|
3896
|
+
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";
|
|
3897
|
+
if (property === "flex") {
|
|
3898
|
+
if (value === "none") return [
|
|
3899
|
+
"0",
|
|
3900
|
+
"0",
|
|
3901
|
+
"auto"
|
|
3902
|
+
][index] ?? value;
|
|
3903
|
+
if (value === "initial") return [
|
|
3904
|
+
"0",
|
|
3905
|
+
"1",
|
|
3906
|
+
"auto"
|
|
3907
|
+
][index] ?? value;
|
|
3908
|
+
return flexValues(tokens)[index] ?? value;
|
|
3909
|
+
}
|
|
3910
|
+
return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
|
|
3911
|
+
};
|
|
3912
|
+
|
|
3913
|
+
//#endregion
|
|
3914
|
+
//#region ../../packages/contract/src/canvas/canvas-authored-css.lib.ts
|
|
3915
|
+
const canvasAdditionalStyleDeclarations = (node) => {
|
|
3916
|
+
if (node.additionalStyles === void 0) return {};
|
|
3917
|
+
return Object.fromEntries(node.additionalStyles.declarations.filter((declaration) => declaration.enabled).map((declaration) => [declaration.property, declaration.value]));
|
|
3918
|
+
};
|
|
3919
|
+
/** Additional-style controls exclusively own every property they expose, including when off. */
|
|
3920
|
+
const canvasAuthoredStyleDeclarations = (node) => {
|
|
3921
|
+
const controlledProperties = new Set(node.additionalStyles?.declarations.map((declaration) => declaration.property.toLowerCase()));
|
|
3922
|
+
return {
|
|
3923
|
+
...Object.fromEntries(Object.entries(node.styles).filter(([property]) => !controlledProperties.has(property.toLowerCase()))),
|
|
3924
|
+
...canvasAdditionalStyleDeclarations(node)
|
|
3925
|
+
};
|
|
3926
|
+
};
|
|
3927
|
+
const hasCanvasCssPriority = (value) => /!important\s*$/iu.test(String(value));
|
|
3928
|
+
const cssValue = (value, shouldPreserveCase) => {
|
|
3929
|
+
const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
|
|
3930
|
+
return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
|
|
3931
|
+
};
|
|
3932
|
+
const authoredLayoutValue = (node, property) => {
|
|
3933
|
+
let result = null;
|
|
3934
|
+
let isImportant = false;
|
|
3935
|
+
const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
|
|
3936
|
+
for (const [key, raw] of declarations) {
|
|
3937
|
+
const scope = canvasCssPropertyScope(key);
|
|
3938
|
+
const index = scope.indexOf(property);
|
|
3939
|
+
if (index === -1) continue;
|
|
3940
|
+
const isPriority = hasCanvasCssPriority(raw);
|
|
3941
|
+
if (isImportant && !isPriority) continue;
|
|
3942
|
+
const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
|
|
3943
|
+
result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
|
|
3944
|
+
isImportant = isPriority;
|
|
3945
|
+
}
|
|
3946
|
+
return result ?? void 0;
|
|
3947
|
+
};
|
|
3948
|
+
/**
|
|
3949
|
+
* Edits replace a node's style objects rather than changing them, so their identity keys the values
|
|
3950
|
+
* already read. Rendering a large document reads each property of each node many times.
|
|
3951
|
+
*/
|
|
3952
|
+
const readAuthoredValues = /* @__PURE__ */ new WeakMap();
|
|
3953
|
+
/** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
|
|
3954
|
+
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
3955
|
+
const known = readAuthoredValues.get(node.styles);
|
|
3956
|
+
const read = known !== void 0 && known.additionalStyles === node.additionalStyles ? known : {
|
|
3957
|
+
additionalStyles: node.additionalStyles,
|
|
3958
|
+
values: /* @__PURE__ */ new Map()
|
|
3959
|
+
};
|
|
3960
|
+
if (read !== known) readAuthoredValues.set(node.styles, read);
|
|
3961
|
+
if (read.values.has(property)) return read.values.get(property);
|
|
3962
|
+
const value = authoredLayoutValue(node, property);
|
|
3963
|
+
read.values.set(property, value);
|
|
3964
|
+
return value;
|
|
3965
|
+
};
|
|
3966
|
+
const canvasCssPixelValue = (value) => {
|
|
3967
|
+
if (value === void 0) return;
|
|
3968
|
+
return /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?$/u.test(value) ? Number(value.replace("px", "")) : void 0;
|
|
3969
|
+
};
|
|
3970
|
+
/** Named controls override only their own longhand, even beside an important shorthand. */
|
|
3971
|
+
const canvasLayoutPriorityDeclarations = (node, declarations) => {
|
|
3972
|
+
const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
|
|
3973
|
+
return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
|
|
3974
|
+
};
|
|
3975
|
+
const canvasWritingModeOf = (node, document) => {
|
|
3976
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3977
|
+
let current = node;
|
|
3978
|
+
while (current !== void 0 && !visited.has(current.id)) {
|
|
3979
|
+
visited.add(current.id);
|
|
3980
|
+
const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
|
|
3981
|
+
if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
|
|
3982
|
+
if (document === void 0) break;
|
|
3983
|
+
const parentId = document.relationships[current.id]?.parentId;
|
|
3984
|
+
if (parentId === void 0) break;
|
|
3985
|
+
current = document.nodes[parentId];
|
|
3986
|
+
}
|
|
3987
|
+
return "horizontal-tb";
|
|
3988
|
+
};
|
|
3989
|
+
const canvasAxisStyleProperties = (node, axis, document) => {
|
|
3990
|
+
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
3991
|
+
return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
|
|
3992
|
+
};
|
|
3993
|
+
const canvasLayoutPositionOf = (node) => {
|
|
3994
|
+
const position = canvasAuthoredLayoutValueOf(node, "position");
|
|
3995
|
+
return node.layout?.position ?? (position === "absolute" || position === "fixed" || position === void 0 && node.box !== void 0 ? "absolute" : "flow");
|
|
3996
|
+
};
|
|
3997
|
+
/** Authored display wins over legacy presets; Grid has no Flex main axis. */
|
|
3998
|
+
const canvasLayoutFlowOf = (node) => {
|
|
3999
|
+
if (node === void 0) return "freeform";
|
|
4000
|
+
const display = canvasAuthoredLayoutValueOf(node, "display");
|
|
4001
|
+
if (display !== void 0) {
|
|
4002
|
+
if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
|
|
4003
|
+
if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
|
|
4004
|
+
return "freeform";
|
|
4005
|
+
}
|
|
4006
|
+
const container = node.layout?.container;
|
|
4007
|
+
if (container === void 0) return "freeform";
|
|
4008
|
+
return container.gridColumns !== void 0 || container.gridAutoRepeat !== void 0 ? "grid" : "flex";
|
|
4009
|
+
};
|
|
4010
|
+
/** Read a Flex main axis in its inherited writing mode without persisting a preset. */
|
|
4011
|
+
const canvasLayoutMainAxisOf = (node, document) => {
|
|
4012
|
+
if (node === void 0) return void 0;
|
|
4013
|
+
if (canvasLayoutFlowOf(node) !== "flex") return void 0;
|
|
4014
|
+
const container = node.layout?.container;
|
|
4015
|
+
const css = (property) => canvasAuthoredLayoutValueOf(node, property);
|
|
4016
|
+
const direction = container?.direction ?? css("flex-direction") ?? "row";
|
|
4017
|
+
if (!/^(?:row|column)(?:-reverse)?$/u.test(direction)) return void 0;
|
|
4018
|
+
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
4019
|
+
return direction.startsWith("column") === isVerticalWriting ? "horizontal" : "vertical";
|
|
4020
|
+
};
|
|
4021
|
+
|
|
4022
|
+
//#endregion
|
|
4023
|
+
//#region ../../packages/contract/src/canvas/canvas-box-source.lib.ts
|
|
4024
|
+
const INSETS = [
|
|
4025
|
+
"left",
|
|
4026
|
+
"right",
|
|
4027
|
+
"top",
|
|
4028
|
+
"bottom",
|
|
4029
|
+
"inset",
|
|
4030
|
+
"inset-inline",
|
|
4031
|
+
"inset-inline-start",
|
|
4032
|
+
"inset-inline-end",
|
|
4033
|
+
"inset-block",
|
|
4034
|
+
"inset-block-start",
|
|
4035
|
+
"inset-block-end"
|
|
4036
|
+
];
|
|
4037
|
+
const TRANSFORMS = [
|
|
4038
|
+
"transform",
|
|
4039
|
+
"translate",
|
|
4040
|
+
"rotate",
|
|
4041
|
+
"scale"
|
|
4042
|
+
];
|
|
4043
|
+
const GROUP_TRANSFORM = "--enhance-group-affine-residual";
|
|
4044
|
+
const CANVAS_RECORDED_BOX_NOTE = "A box whose boxSource is \"recorded\" is a size kept from when the layer was made: the browser lays that layer out, so the box is not where it is drawn. `enhance canvas render` shows what is on screen.";
|
|
4045
|
+
const isSet = (value) => value !== void 0 && value !== "" && value !== "none";
|
|
4046
|
+
const hasOwnTransform = (node, authored) => TRANSFORMS.some((property) => isSet(authored[property])) || (node.layout?.rotation ?? 0) !== 0 || node.layout?.flipHorizontal === true || node.layout?.flipVertical === true || Object.keys(authored).some((property) => property.toLowerCase() === GROUP_TRANSFORM);
|
|
4047
|
+
/**
|
|
4048
|
+
* The canvas draws a layer at its box only when it positions the layer absolutely and the layer
|
|
4049
|
+
* names no inset of its own; an inset on either axis takes that axis from the box. This is the
|
|
4050
|
+
* test the style projection makes before it writes `left` and `top` from the box, and a layer
|
|
4051
|
+
* with no box has no source.
|
|
4052
|
+
*/
|
|
4053
|
+
const canvasBoxSourceOf = (node) => {
|
|
4054
|
+
if (node.box === void 0) return void 0;
|
|
4055
|
+
const authored = canvasAuthoredStyleDeclarations(node);
|
|
4056
|
+
if (!(canvasLayoutPositionOf(node) === "absolute" && INSETS.every((property) => authored[property] === void 0))) return "recorded";
|
|
4057
|
+
return hasOwnTransform(node, authored) ? "placed-before-transform" : "placed";
|
|
4058
|
+
};
|
|
4059
|
+
/** One line for a whole read, however many of its boxes are recorded. */
|
|
4060
|
+
const canvasRecordedBoxNoteFor = (boxes) => boxes.some((box) => box.boxSource === "recorded") ? { boxNote: CANVAS_RECORDED_BOX_NOTE } : {};
|
|
4061
|
+
|
|
3720
4062
|
//#endregion
|
|
3721
4063
|
//#region ../../packages/contract/src/canvas/canvas-document.schema.ts
|
|
3722
4064
|
/** Reads retain unsupported documents; the write boundary validates the current scene format. */
|
|
@@ -3984,98 +4326,6 @@ const textLinksOf = (node) => {
|
|
|
3984
4326
|
return nonOverlapping;
|
|
3985
4327
|
};
|
|
3986
4328
|
|
|
3987
|
-
//#endregion
|
|
3988
|
-
//#region ../../packages/contract/src/canvas/canvas-property-section.schema.ts
|
|
3989
|
-
const CANVAS_PROPERTY_SECTIONS = [
|
|
3990
|
-
"position",
|
|
3991
|
-
"layout",
|
|
3992
|
-
"clip",
|
|
3993
|
-
"cornerRadius",
|
|
3994
|
-
"blending",
|
|
3995
|
-
"typography",
|
|
3996
|
-
"nativeControl",
|
|
3997
|
-
"textDecoration",
|
|
3998
|
-
"fill",
|
|
3999
|
-
"outline",
|
|
4000
|
-
"textStroke",
|
|
4001
|
-
"border",
|
|
4002
|
-
"outerShadow",
|
|
4003
|
-
"innerShadow",
|
|
4004
|
-
"filters",
|
|
4005
|
-
"additionalStyles",
|
|
4006
|
-
"vector",
|
|
4007
|
-
"export",
|
|
4008
|
-
"source"
|
|
4009
|
-
];
|
|
4010
|
-
const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
|
|
4011
|
-
|
|
4012
|
-
//#endregion
|
|
4013
|
-
//#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
|
|
4014
|
-
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
4015
|
-
const MAX_RENDER_KIND_LENGTH = 100;
|
|
4016
|
-
/**
|
|
4017
|
-
* What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
|
|
4018
|
-
* it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
|
|
4019
|
-
* was made, for a layer the browser lays out.
|
|
4020
|
-
*/
|
|
4021
|
-
const canvasBoxSourceSchema = z.enum([
|
|
4022
|
-
"placed",
|
|
4023
|
-
"placed-before-transform",
|
|
4024
|
-
"recorded"
|
|
4025
|
-
]);
|
|
4026
|
-
/** Present only on a read that holds a `recorded` box. */
|
|
4027
|
-
const boxNoteSchema = z.string().min(1).optional();
|
|
4028
|
-
const canvasInspectNodeSummarySchema = z.object({
|
|
4029
|
-
id: z.string().min(1),
|
|
4030
|
-
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
4031
|
-
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
4032
|
-
parentId: z.string().min(1).nullable(),
|
|
4033
|
-
childCount: z.number().int().min(0),
|
|
4034
|
-
box: canvasSceneBoxSchema.nullable(),
|
|
4035
|
-
boxSource: canvasBoxSourceSchema.optional(),
|
|
4036
|
-
propertySections: z.array(canvasPropertySectionSchema)
|
|
4037
|
-
});
|
|
4038
|
-
const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
4039
|
-
const inspectCanvasOutputSchema = z.object({
|
|
4040
|
-
canvasId: z.uuid(),
|
|
4041
|
-
openUrl: z.url(),
|
|
4042
|
-
title: z.string().min(1),
|
|
4043
|
-
version: z.number().int().positive(),
|
|
4044
|
-
nodeCount: z.number().int().min(0),
|
|
4045
|
-
rootChildCount: z.number().int().min(0),
|
|
4046
|
-
bounds: canvasSceneBoxSchema.nullable(),
|
|
4047
|
-
kinds: z.record(z.string(), z.number().int().min(0)),
|
|
4048
|
-
boxNote: boxNoteSchema,
|
|
4049
|
-
next: z.array(z.string().min(1))
|
|
4050
|
-
});
|
|
4051
|
-
const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
|
|
4052
|
-
const inspectCanvasTreeOutputSchema = z.object({
|
|
4053
|
-
canvasId: z.uuid(),
|
|
4054
|
-
version: z.number().int().positive(),
|
|
4055
|
-
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
4056
|
-
boxNote: boxNoteSchema
|
|
4057
|
-
});
|
|
4058
|
-
const inspectCanvasNodeInputSchema = z.object({
|
|
4059
|
-
canvasId: z.uuid(),
|
|
4060
|
-
nodeId: z.string().min(1)
|
|
4061
|
-
});
|
|
4062
|
-
const inspectCanvasNodeOutputSchema = z.object({
|
|
4063
|
-
canvasId: z.uuid(),
|
|
4064
|
-
version: z.number().int().positive(),
|
|
4065
|
-
node: canvasInspectNodeSummarySchema.extend({
|
|
4066
|
-
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
4067
|
-
layout: canvasNodeLayoutSchema.optional(),
|
|
4068
|
-
appearance: canvasAppearanceValuesSchema.optional(),
|
|
4069
|
-
geometry: canvasGeometrySchema.optional(),
|
|
4070
|
-
typography: canvasAuthoredTypographySchema.optional(),
|
|
4071
|
-
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
4072
|
-
props: z.record(z.string(), z.unknown()),
|
|
4073
|
-
children: z.array(z.string().min(1))
|
|
4074
|
-
}),
|
|
4075
|
-
boxNote: boxNoteSchema,
|
|
4076
|
-
next: z.array(z.string().min(1))
|
|
4077
|
-
});
|
|
4078
|
-
|
|
4079
4329
|
//#endregion
|
|
4080
4330
|
//#region ../../packages/contract/src/canvas/canvas-layout-ownership.lib.ts
|
|
4081
4331
|
const CANVAS_LAYOUT_CSS_FIELDS = [
|
|
@@ -4162,121 +4412,28 @@ const canvasLayoutWithoutCssProperties = (held, changed, axes) => {
|
|
|
4162
4412
|
].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "clipContent");
|
|
4163
4413
|
if (properties.has("position")) {
|
|
4164
4414
|
Reflect.deleteProperty(layout, "position");
|
|
4165
|
-
Reflect.deleteProperty(layout, "retainedIgnore");
|
|
4166
|
-
Reflect.deleteProperty(layout, "gridParticipation");
|
|
4167
|
-
}
|
|
4168
|
-
if (properties.has("transform")) for (const key of [
|
|
4169
|
-
"rotation",
|
|
4170
|
-
"flipHorizontal",
|
|
4171
|
-
"flipVertical"
|
|
4172
|
-
]) Reflect.deleteProperty(layout, key);
|
|
4173
|
-
if ([
|
|
4174
|
-
"inset",
|
|
4175
|
-
"left",
|
|
4176
|
-
"right",
|
|
4177
|
-
"top",
|
|
4178
|
-
"bottom"
|
|
4179
|
-
].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "flowOffset");
|
|
4180
|
-
for (const axis of ["horizontal", "vertical"]) {
|
|
4181
|
-
const intent = axes[axis].some((property) => properties.has(property)) ? void 0 : axisWithoutCssBounds(layout[axis], axes[axis], properties);
|
|
4182
|
-
if (intent === void 0) Reflect.deleteProperty(layout, axis);
|
|
4183
|
-
else layout[axis] = intent;
|
|
4184
|
-
}
|
|
4185
|
-
return layout;
|
|
4186
|
-
};
|
|
4187
|
-
|
|
4188
|
-
//#endregion
|
|
4189
|
-
//#region ../../packages/contract/src/canvas/canvas-operation-writes.schema.ts
|
|
4190
|
-
/**
|
|
4191
|
-
* What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
|
|
4192
|
-
* values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
|
|
4193
|
-
* group of values, which a client that read the canvas in an older format may have stripped.
|
|
4194
|
-
*/
|
|
4195
|
-
const CANVAS_OPERATION_WRITES = {
|
|
4196
|
-
insertConvertedSubtree: "whole",
|
|
4197
|
-
insertNode: "whole",
|
|
4198
|
-
insertText: "names",
|
|
4199
|
-
insertPrototype: "names",
|
|
4200
|
-
setPrototypeDeployment: "names",
|
|
4201
|
-
editText: "names",
|
|
4202
|
-
setText: "names",
|
|
4203
|
-
setBox: "names",
|
|
4204
|
-
setLabel: "names",
|
|
4205
|
-
setContainerKind: "names",
|
|
4206
|
-
setVisibility: "names",
|
|
4207
|
-
setLocked: "names",
|
|
4208
|
-
setConstraints: "names",
|
|
4209
|
-
setStyles: "names",
|
|
4210
|
-
patchExportSettings: "names",
|
|
4211
|
-
setAppearance: "names",
|
|
4212
|
-
setLayout: "whole",
|
|
4213
|
-
patchTypography: "names",
|
|
4214
|
-
setTypography: "whole",
|
|
4215
|
-
patchAdditionalStyles: "names",
|
|
4216
|
-
setAdditionalStyles: "whole",
|
|
4217
|
-
setArtworkColor: "whole",
|
|
4218
|
-
setTextStyleLibrary: "whole",
|
|
4219
|
-
patchFontLibrary: "names",
|
|
4220
|
-
setTextStyle: "whole",
|
|
4221
|
-
setGeometry: "whole",
|
|
4222
|
-
setProps: "whole",
|
|
4223
|
-
setParentage: "names",
|
|
4224
|
-
move: "names",
|
|
4225
|
-
remove: "names"
|
|
4226
|
-
};
|
|
4227
|
-
|
|
4228
|
-
//#endregion
|
|
4229
|
-
//#region ../../packages/contract/src/canvas/canvas-mutation.schema.ts
|
|
4230
|
-
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
4231
|
-
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
4232
|
-
width: z.number().positive(),
|
|
4233
|
-
height: z.number().positive()
|
|
4234
|
-
});
|
|
4235
|
-
const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
|
|
4236
|
-
/** A receipt stored before boxes said what they are holds none, so the source stays optional. */
|
|
4237
|
-
const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
|
|
4238
|
-
const canvasMutationRequestContextSchema = z.strictObject({
|
|
4239
|
-
fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
4240
|
-
revisionPolicy: z.enum(["strict", "rebase"]),
|
|
4241
|
-
copiedNodeIds: copiedNodeIdsSchema.optional()
|
|
4242
|
-
});
|
|
4243
|
-
/** The request's fields alone, for callers that derive their own input from it. */
|
|
4244
|
-
const applyCanvasOperationsFieldsSchema = z.object({
|
|
4245
|
-
canvasId: z.uuid(),
|
|
4246
|
-
mutationId: z.uuid(),
|
|
4247
|
-
documentFormatVersion: canvasDocumentFormatSchema,
|
|
4248
|
-
baseVersion: z.number().int().positive(),
|
|
4249
|
-
operations: z.array(canvasOperationSchema).min(1),
|
|
4250
|
-
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
4251
|
-
writeScope: canvasWriteScopeSchema.optional()
|
|
4252
|
-
});
|
|
4253
|
-
const applyCanvasOperationsInputSchema = applyCanvasOperationsFieldsSchema.superRefine((input, context) => {
|
|
4254
|
-
refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
|
|
4255
|
-
});
|
|
4256
|
-
const applyCanvasOperationsOutputSchema = z.object({
|
|
4257
|
-
canvasId: z.uuid(),
|
|
4258
|
-
mutationId: z.uuid(),
|
|
4259
|
-
previousVersion: z.number().int().positive(),
|
|
4260
|
-
version: z.number().int().positive(),
|
|
4261
|
-
operations: z.array(canvasOperationSchema),
|
|
4262
|
-
insertedNodeIds: z.array(nodeIdSchema$2),
|
|
4263
|
-
changedNodeIds: z.array(nodeIdSchema$2),
|
|
4264
|
-
removedNodeIds: z.array(nodeIdSchema$2),
|
|
4265
|
-
boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
4266
|
-
affectedBounds: writableBoxSchema.nullable(),
|
|
4267
|
-
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
4268
|
-
next: z.array(z.string().min(1))
|
|
4269
|
-
});
|
|
4270
|
-
const getCanvasMutationInputSchema = z.strictObject({
|
|
4271
|
-
canvasId: z.uuid(),
|
|
4272
|
-
mutationId: z.uuid(),
|
|
4273
|
-
fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
|
|
4274
|
-
});
|
|
4275
|
-
const getCanvasMutationOutputSchema = z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
|
|
4276
|
-
state: z.literal("committed"),
|
|
4277
|
-
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
4278
|
-
result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
|
|
4279
|
-
})]);
|
|
4415
|
+
Reflect.deleteProperty(layout, "retainedIgnore");
|
|
4416
|
+
Reflect.deleteProperty(layout, "gridParticipation");
|
|
4417
|
+
}
|
|
4418
|
+
if (properties.has("transform")) for (const key of [
|
|
4419
|
+
"rotation",
|
|
4420
|
+
"flipHorizontal",
|
|
4421
|
+
"flipVertical"
|
|
4422
|
+
]) Reflect.deleteProperty(layout, key);
|
|
4423
|
+
if ([
|
|
4424
|
+
"inset",
|
|
4425
|
+
"left",
|
|
4426
|
+
"right",
|
|
4427
|
+
"top",
|
|
4428
|
+
"bottom"
|
|
4429
|
+
].some((property) => properties.has(property))) Reflect.deleteProperty(layout, "flowOffset");
|
|
4430
|
+
for (const axis of ["horizontal", "vertical"]) {
|
|
4431
|
+
const intent = axes[axis].some((property) => properties.has(property)) ? void 0 : axisWithoutCssBounds(layout[axis], axes[axis], properties);
|
|
4432
|
+
if (intent === void 0) Reflect.deleteProperty(layout, axis);
|
|
4433
|
+
else layout[axis] = intent;
|
|
4434
|
+
}
|
|
4435
|
+
return layout;
|
|
4436
|
+
};
|
|
4280
4437
|
|
|
4281
4438
|
//#endregion
|
|
4282
4439
|
//#region ../../packages/contract/src/canvas/canvas-mutation-review.schema.ts
|
|
@@ -4676,7 +4833,9 @@ const canvasDuplicatePreparationSchema = z.strictObject({
|
|
|
4676
4833
|
destination: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("native") }), z.strictObject({
|
|
4677
4834
|
kind: z.literal("inside"),
|
|
4678
4835
|
parentId: nodeId$5
|
|
4679
|
-
})])
|
|
4836
|
+
})]),
|
|
4837
|
+
/** World placement for a set of top-level copies. Absent, the native copy offset stands. */
|
|
4838
|
+
placement: canvasPlacementIntentSchema.optional()
|
|
4680
4839
|
});
|
|
4681
4840
|
const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
|
|
4682
4841
|
z.strictObject({
|
|
@@ -5427,6 +5586,10 @@ const claimRenderWorkOutputSchema = z.discriminatedUnion("purpose", [
|
|
|
5427
5586
|
outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
|
|
5428
5587
|
})
|
|
5429
5588
|
]);
|
|
5589
|
+
const snapshotPlacementSchema = z.object({
|
|
5590
|
+
x: z.number(),
|
|
5591
|
+
y: z.number()
|
|
5592
|
+
});
|
|
5430
5593
|
const completeRenderWorkInputSchema = z.object({
|
|
5431
5594
|
jobId: z.uuid(),
|
|
5432
5595
|
loadedVersion: z.number().int().positive(),
|
|
@@ -5447,14 +5610,18 @@ const completeRenderWorkInputSchema = z.object({
|
|
|
5447
5610
|
viewport: z.object({
|
|
5448
5611
|
width: z.number().int().positive(),
|
|
5449
5612
|
height: z.number().int().positive()
|
|
5450
|
-
})
|
|
5613
|
+
}),
|
|
5614
|
+
/** Where the page's search put the captured screen, at `loadedVersion`. */
|
|
5615
|
+
placement: snapshotPlacementSchema.optional()
|
|
5451
5616
|
}).optional()
|
|
5452
5617
|
});
|
|
5453
5618
|
const completeRenderWorkOutputSchema = z.object({ accepted: z.literal(true) });
|
|
5454
5619
|
const completeConversionWorkInputSchema = z.object({
|
|
5455
5620
|
jobId: z.uuid(),
|
|
5456
5621
|
loadedVersion: z.number().int().positive(),
|
|
5457
|
-
draft: canvasSubtreeDraftSchema
|
|
5622
|
+
draft: canvasSubtreeDraftSchema,
|
|
5623
|
+
/** The root's measured place at `loadedVersion`, for a request that asked to be placed. */
|
|
5624
|
+
placement: canvasSceneBoxSchema.optional()
|
|
5458
5625
|
});
|
|
5459
5626
|
const completeConversionWorkOutputSchema = z.object({ accepted: z.literal(true) });
|
|
5460
5627
|
const renderRouteSnapshotSchema = z.object({
|
|
@@ -5467,7 +5634,9 @@ const renderRouteSnapshotSchema = z.object({
|
|
|
5467
5634
|
viewport: z.object({
|
|
5468
5635
|
width: z.number().int().positive(),
|
|
5469
5636
|
height: z.number().int().positive()
|
|
5470
|
-
})
|
|
5637
|
+
}),
|
|
5638
|
+
/** Where the editor's search for a capture below this recording puts the screen. */
|
|
5639
|
+
placement: snapshotPlacementSchema.optional()
|
|
5471
5640
|
});
|
|
5472
5641
|
const failRenderWorkInputSchema = z.object({
|
|
5473
5642
|
jobId: z.uuid(),
|
|
@@ -7594,7 +7763,11 @@ const desktopRequestSchema = z.object({
|
|
|
7594
7763
|
const desktopMutationIntentSchema = z.object({
|
|
7595
7764
|
mutationId: id$2,
|
|
7596
7765
|
canvasId: id$2,
|
|
7597
|
-
procedure: z.enum([
|
|
7766
|
+
procedure: z.enum([
|
|
7767
|
+
"canvas.applyOperations",
|
|
7768
|
+
"canvas.render.importSource",
|
|
7769
|
+
"canvas.applyEdits"
|
|
7770
|
+
]),
|
|
7598
7771
|
input: z.record(z.string(), z.unknown()),
|
|
7599
7772
|
state: z.enum([
|
|
7600
7773
|
"recorded",
|
|
@@ -8246,7 +8419,9 @@ const createAgentTokenOutputSchema = z.object({
|
|
|
8246
8419
|
const listAgentTokensInputSchema = z.object({});
|
|
8247
8420
|
const listAgentTokensOutputSchema = z.object({
|
|
8248
8421
|
items: z.array(agentTokenSchema),
|
|
8249
|
-
isConnected: z.boolean()
|
|
8422
|
+
isConnected: z.boolean(),
|
|
8423
|
+
/** True once any agent credential of this person was ever used, even if all are now revoked. */
|
|
8424
|
+
hasEverConnected: z.boolean()
|
|
8250
8425
|
});
|
|
8251
8426
|
const revokeAgentTokenInputSchema = z.object({ tokenId: z.uuid() });
|
|
8252
8427
|
const revokeAgentTokenOutputSchema = z.object({
|
|
@@ -8265,6 +8440,49 @@ const cliAuthConfigurationSchema = z.discriminatedUnion("method", [z.object({ me
|
|
|
8265
8440
|
scope: z.literal(CLI_AUTH_SCOPE)
|
|
8266
8441
|
})]);
|
|
8267
8442
|
|
|
8443
|
+
//#endregion
|
|
8444
|
+
//#region ../../packages/contract/src/person/onboarding.schema.ts
|
|
8445
|
+
/** The four contextual canvas hints, in the order the canvas offers them. */
|
|
8446
|
+
const ONBOARDING_STEP_IDS = [
|
|
8447
|
+
"connect_agent",
|
|
8448
|
+
"first_agent_work",
|
|
8449
|
+
"comment",
|
|
8450
|
+
"share_comments"
|
|
8451
|
+
];
|
|
8452
|
+
const onboardingStepIdSchema = z.enum(ONBOARDING_STEP_IDS);
|
|
8453
|
+
/** One person's preferences for one hint. `isSnoozed` is worked out with the API's clock. */
|
|
8454
|
+
const onboardingStepStateSchema = z.object({
|
|
8455
|
+
isAcknowledged: z.boolean(),
|
|
8456
|
+
maybeLaterCount: z.number().int().min(0),
|
|
8457
|
+
snoozedUntil: z.iso.datetime().nullable(),
|
|
8458
|
+
isSnoozed: z.boolean(),
|
|
8459
|
+
isStopped: z.boolean(),
|
|
8460
|
+
automaticShowCount: z.number().int().min(0),
|
|
8461
|
+
lastPresentationId: z.uuid().nullable()
|
|
8462
|
+
});
|
|
8463
|
+
const onboardingInputSchema = z.strictObject({});
|
|
8464
|
+
const onboardingOutputSchema = z.object({
|
|
8465
|
+
hasCommented: z.boolean(),
|
|
8466
|
+
hasCopiedCanvasLink: z.boolean(),
|
|
8467
|
+
steps: z.object({
|
|
8468
|
+
connect_agent: onboardingStepStateSchema,
|
|
8469
|
+
first_agent_work: onboardingStepStateSchema,
|
|
8470
|
+
comment: onboardingStepStateSchema,
|
|
8471
|
+
share_comments: onboardingStepStateSchema
|
|
8472
|
+
})
|
|
8473
|
+
});
|
|
8474
|
+
const dismissOnboardingStepInputSchema = z.strictObject({
|
|
8475
|
+
stepId: onboardingStepIdSchema,
|
|
8476
|
+
choice: z.enum(["got_it", "maybe_later"])
|
|
8477
|
+
});
|
|
8478
|
+
const presentOnboardingStepInputSchema = z.strictObject({
|
|
8479
|
+
stepId: onboardingStepIdSchema,
|
|
8480
|
+
presentationId: z.uuid()
|
|
8481
|
+
});
|
|
8482
|
+
const presentOnboardingStepOutputSchema = z.object({ automaticShowNumber: z.number().int().min(1) });
|
|
8483
|
+
const recordCanvasLinkCopiedInputSchema = z.strictObject({});
|
|
8484
|
+
const recordCanvasLinkCopiedOutputSchema = z.object({ hasCopiedCanvasLink: z.literal(true) });
|
|
8485
|
+
|
|
8268
8486
|
//#endregion
|
|
8269
8487
|
//#region ../../packages/contract/src/person/person.schema.ts
|
|
8270
8488
|
const personSchema = z.object({
|
|
@@ -10612,6 +10830,7 @@ ${listHeading(words)}
|
|
|
10612
10830
|
})} makes a canvas and answers with its id and its link.
|
|
10613
10831
|
- ${learn("canvas.read", "read what a canvas holds: its outline, or one screen as HTML")}
|
|
10614
10832
|
- ${learn("canvas.insertHtml", "add a screen as HTML, with an example")} Read it before the first insert.
|
|
10833
|
+
- Give a new top-level screen \`"placement": {"kind": "auto"}\` so Enhance puts it in free space, unless the person gave coordinates. Place the next screen of a sequence with \`{"kind": "near", "anchorNodeId": "<the previous screen's id from its answer>", "side": "right"}\`.
|
|
10615
10834
|
- ${learn("canvas.edit", "change text, styles, names and order on layers that are already there, and copy a layer, many in one call")} Use it for any change to existing work.
|
|
10616
10835
|
- ${learn("canvas.updateHtml", "rebuild the inside of a layer")} Use it only when the structure itself changes.
|
|
10617
10836
|
- ${learn("canvas.importAsset", "bring in an image or a font")}
|
|
@@ -10714,6 +10933,27 @@ const skillTextsFor = (wording) => SKILL_NAMES.map((skill) => {
|
|
|
10714
10933
|
/** The job each skill is for, in the order of the skills, for a sentence that lists them. */
|
|
10715
10934
|
const SKILL_JOBS = SKILL_NAMES.map((skill) => SKILLS[skill].job);
|
|
10716
10935
|
|
|
10936
|
+
//#endregion
|
|
10937
|
+
//#region ../../packages/canvas-document/src/canvas-edit-words.consts.ts
|
|
10938
|
+
/**
|
|
10939
|
+
* The phrases a planned edit's refusal uses, for each way into Enhance: the command-line tool's
|
|
10940
|
+
* commands, and the tools an assistant calls. The tool layer holds the tool names to its own list.
|
|
10941
|
+
*/
|
|
10942
|
+
const CANVAS_EDIT_WORDS = {
|
|
10943
|
+
cli: {
|
|
10944
|
+
layerList: "canvas tree",
|
|
10945
|
+
currentIds: (ids = "a current stable node id") => `Run canvas tree and use ${ids}.`,
|
|
10946
|
+
updateHtml: "canvas update-html",
|
|
10947
|
+
arrange: "canvas arrange"
|
|
10948
|
+
},
|
|
10949
|
+
mcp: {
|
|
10950
|
+
layerList: "a new read of the canvas",
|
|
10951
|
+
currentIds: (ids = "a current stable node id") => `Read the canvas again and use ${ids}.`,
|
|
10952
|
+
updateHtml: "canvas_update_html",
|
|
10953
|
+
arrange: "canvas_arrange"
|
|
10954
|
+
}
|
|
10955
|
+
};
|
|
10956
|
+
|
|
10717
10957
|
//#endregion
|
|
10718
10958
|
//#region src/infrastructure/mcp-tool-names.consts.ts
|
|
10719
10959
|
/** The tool a hosted assistant calls for each capability that has one of its own. */
|
|
@@ -10783,16 +11023,8 @@ const callOf = (capability, given) => inSurfaceWords({
|
|
|
10783
11023
|
cli: `enhance ${cliPathOf(capability)} ${given.cli}`,
|
|
10784
11024
|
mcp: `${toolOf(capability)} with ${JSON.stringify(given.mcp)}`
|
|
10785
11025
|
});
|
|
10786
|
-
/** Where a layer's current id is read: the tool's tree command, or an assistant's own read. */
|
|
10787
|
-
const layerListName = () => inSurfaceWords({
|
|
10788
|
-
cli: "canvas tree",
|
|
10789
|
-
mcp: "a new read of the canvas"
|
|
10790
|
-
});
|
|
10791
11026
|
/** The step that finds layer ids that still exist. */
|
|
10792
|
-
const currentNodeIdStep = (ids = "a current stable node id") =>
|
|
10793
|
-
cli: `Run canvas tree and use ${ids}.`,
|
|
10794
|
-
mcp: `Read the canvas again and use ${ids}.`
|
|
10795
|
-
});
|
|
11027
|
+
const currentNodeIdStep = (ids = "a current stable node id") => CANVAS_EDIT_WORDS[callingSurface()].currentIds(ids);
|
|
10796
11028
|
|
|
10797
11029
|
//#endregion
|
|
10798
11030
|
//#region src/application/stored-canvas-scene.use-case.ts
|
|
@@ -10810,6 +11042,20 @@ const readStoredCanvasScene = (document) => {
|
|
|
10810
11042
|
throw new CliError("INTERNAL", "The stored canvas is not an editable scene.", "Open the canvas in the editor and repair or recreate the invalid document.");
|
|
10811
11043
|
};
|
|
10812
11044
|
|
|
11045
|
+
//#endregion
|
|
11046
|
+
//#region ../../packages/canvas-document/src/canvas-work-tally.lib.ts
|
|
11047
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11048
|
+
const apartCounts = /* @__PURE__ */ new Map();
|
|
11049
|
+
const apart = { depth: 0 };
|
|
11050
|
+
/**
|
|
11051
|
+
* Counts work an editor path did, by kind. The integration count gates read the tally to hold
|
|
11052
|
+
* per-edit work constant as boards grow; the product never reads it.
|
|
11053
|
+
*/
|
|
11054
|
+
const tallyCanvasWork = (kind, amount = 1) => {
|
|
11055
|
+
const held = apart.depth > 0 ? apartCounts : counts;
|
|
11056
|
+
held.set(kind, (held.get(kind) ?? 0) + amount);
|
|
11057
|
+
};
|
|
11058
|
+
|
|
10813
11059
|
//#endregion
|
|
10814
11060
|
//#region ../../packages/contract/src/capture/capture-comparison.schema.ts
|
|
10815
11061
|
const COMMIT_LENGTH = 200;
|
|
@@ -10930,63 +11176,6 @@ const captureReviewSchema = z.strictObject({
|
|
|
10930
11176
|
}))
|
|
10931
11177
|
});
|
|
10932
11178
|
|
|
10933
|
-
//#endregion
|
|
10934
|
-
//#region src/application/canvas-reference.use-case.ts
|
|
10935
|
-
const hasCanvasReferenceScope = (reference) => reference.pageId !== void 0 || reference.nodeIds.length > 0;
|
|
10936
|
-
/** The origin a `/c/<id>` path is read against. The path names no host, and none is kept. */
|
|
10937
|
-
const PATH_ORIGIN = "https://canvas.invalid";
|
|
10938
|
-
/**
|
|
10939
|
-
* `canvas find` and `prototype publish` answer with the path `/c/<id>`, which is not an address by
|
|
10940
|
-
* itself, so it is read as the address it would be on any host.
|
|
10941
|
-
*/
|
|
10942
|
-
const asAddress = (reference) => {
|
|
10943
|
-
const candidate = reference.trim();
|
|
10944
|
-
return candidate.startsWith("/c/") ? `${PATH_ORIGIN}${candidate}` : reference;
|
|
10945
|
-
};
|
|
10946
|
-
const parseCanvasReference = (reference) => {
|
|
10947
|
-
const parsed = readCanvasReference(asAddress(reference));
|
|
10948
|
-
if (parsed.ok) return parsed.value;
|
|
10949
|
-
throw new CliError("BAD_REQUEST", `The canvas link contains an invalid or unsupported ${parsed.reason}.`, "Copy a current canvas, page or selection link. Recording and version links require their dedicated commands; do not discard their scope.");
|
|
10950
|
-
};
|
|
10951
|
-
const fromCanvasReference = (reference) => {
|
|
10952
|
-
const parsed = parseCanvasReference(reference);
|
|
10953
|
-
if (hasCanvasReferenceScope(parsed)) throw new CliError("BAD_REQUEST", `This command cannot discard the link ${parsed.nodeIds.length > 0 ? "selection" : "page"}.`, "Use canvas tree, a scoped render or a targeted edit. Use a canvas URL without page or selection only when the request covers the whole canvas.");
|
|
10954
|
-
return parsed.canvasId;
|
|
10955
|
-
};
|
|
10956
|
-
const canvasReferenceNodeIds = (reference, document) => {
|
|
10957
|
-
if (!hasCanvasReferenceScope(reference)) return /* @__PURE__ */ new Set();
|
|
10958
|
-
const scope = resolveCanvasReference(reference, document);
|
|
10959
|
-
if (scope.ok) return scope.nodeIds;
|
|
10960
|
-
const reason = scope.reason;
|
|
10961
|
-
throw new CliError(reason === "page" || reason === "selection" ? "NOT_FOUND" : "BAD_REQUEST", `The link ${reason} is unavailable or inconsistent: ${reference.nodeIds.join(", ")}${reference.pageId === void 0 ? "" : ` on page ${reference.pageId}`}.`, "Copy a current link. Keep its complete page and selection; do not substitute or broaden the target.");
|
|
10962
|
-
};
|
|
10963
|
-
const assertCanvasReferenceNodes = (reference, document, nodeIds) => {
|
|
10964
|
-
if (!hasCanvasReferenceScope(reference)) return;
|
|
10965
|
-
const scope = canvasReferenceNodeIds(reference, document);
|
|
10966
|
-
assertNodesInScope(scope, nodeIds);
|
|
10967
|
-
};
|
|
10968
|
-
const assertNodesInScope = (scope, nodeIds) => {
|
|
10969
|
-
const outside = nodeIds.filter((id) => !scope.has(id));
|
|
10970
|
-
if (outside.length > 0) throw new CliError("BAD_REQUEST", `These nodes are outside the link selection: ${outside.join(", ")}.`, "Limit the edit to the selected nodes and their descendants. Request a wider selection only when the person wants a wider change.");
|
|
10971
|
-
};
|
|
10972
|
-
const canvasReferenceRenderTarget = (reference, document, target) => {
|
|
10973
|
-
if (!hasCanvasReferenceScope(reference)) return target;
|
|
10974
|
-
const scope = canvasReferenceNodeIds(reference, document);
|
|
10975
|
-
const nodeId = target.kind === "node" ? target.nodeId : target.kind === "content" && reference.nodeIds.length === 1 ? reference.nodeIds[0] : void 0;
|
|
10976
|
-
if (nodeId !== void 0) {
|
|
10977
|
-
assertNodesInScope(scope, [nodeId]);
|
|
10978
|
-
return {
|
|
10979
|
-
kind: "node",
|
|
10980
|
-
nodeId
|
|
10981
|
-
};
|
|
10982
|
-
}
|
|
10983
|
-
if (reference.nodeIds.length === 0 && reference.pageId !== void 0 && (target.kind === "content" || target.kind === "page" && target.pageId === reference.pageId)) return {
|
|
10984
|
-
kind: "page",
|
|
10985
|
-
pageId: reference.pageId
|
|
10986
|
-
};
|
|
10987
|
-
throw new CliError("BAD_REQUEST", "This render target would discard the link page or selection.", "Render the linked page, or choose one node within the selection. Bounds and other pages may include unrelated content.");
|
|
10988
|
-
};
|
|
10989
|
-
|
|
10990
11179
|
//#endregion
|
|
10991
11180
|
//#region src/application/canvas-resource-read.schema.ts
|
|
10992
11181
|
const MAX_RESOURCE_PAGE = 100;
|
|
@@ -11141,12 +11330,19 @@ const canvasSourceEvidenceSchema = z.discriminatedUnion("kind", [
|
|
|
11141
11330
|
})
|
|
11142
11331
|
]);
|
|
11143
11332
|
|
|
11333
|
+
//#endregion
|
|
11334
|
+
//#region src/application/client-token.schema.ts
|
|
11335
|
+
/**
|
|
11336
|
+
* A write's retry token, as every agent tool takes it: left out, the tool makes one and names it in
|
|
11337
|
+
* its answer, so an agent never invents a value that another request may already have used.
|
|
11338
|
+
*/
|
|
11339
|
+
const retryClientTokenSchema = z.uuid().optional().describe("Leave out: the tool makes one and names it in its answer. Repeat that clientToken, with identical arguments, only after an uncertain outcome.");
|
|
11340
|
+
|
|
11144
11341
|
//#endregion
|
|
11145
11342
|
//#region src/application/canvas-exchange.schema.ts
|
|
11146
11343
|
const MAX_PREPARATION_WAIT_MS = 12e4;
|
|
11147
11344
|
const DEFAULT_PREPARATION_WAIT_MS = 3e4;
|
|
11148
11345
|
const MAX_TOKEN_LENGTH = 16384;
|
|
11149
|
-
const MAX_TARGETS = 1e3;
|
|
11150
11346
|
const MAX_OUTLINE_PAGE = 100;
|
|
11151
11347
|
const DEFAULT_OUTLINE_PAGE = 50;
|
|
11152
11348
|
const MAX_OUTLINE_DEPTH = 64;
|
|
@@ -11174,7 +11370,7 @@ const canvasReadInputSchema = z.discriminatedUnion("view", [
|
|
|
11174
11370
|
z.strictObject({
|
|
11175
11371
|
...sharedRead,
|
|
11176
11372
|
view: z.literal("outline"),
|
|
11177
|
-
rootNodeIds: z.array(nodeId$2).min(1).
|
|
11373
|
+
rootNodeIds: z.array(nodeId$2).min(1).optional(),
|
|
11178
11374
|
depth: z.number().int().min(0).max(MAX_OUTLINE_DEPTH).default(2),
|
|
11179
11375
|
limit: z.number().int().min(1).max(MAX_OUTLINE_PAGE).default(DEFAULT_OUTLINE_PAGE),
|
|
11180
11376
|
cursor: cursor.optional()
|
|
@@ -11185,18 +11381,26 @@ const canvasUpdateHtmlInputSchema = z.strictObject({
|
|
|
11185
11381
|
waitMs: z.number().int().min(0).max(MAX_PREPARATION_WAIT_MS).default(DEFAULT_PREPARATION_WAIT_MS).describe("Additional polling for native HTML compilation. Preparation alone never commits."),
|
|
11186
11382
|
snapshotToken: cursor,
|
|
11187
11383
|
html: z.string().min(1),
|
|
11188
|
-
removeNodeIds: z.array(nodeId$2).
|
|
11189
|
-
clientToken:
|
|
11384
|
+
removeNodeIds: z.array(nodeId$2).default([]),
|
|
11385
|
+
clientToken: retryClientTokenSchema
|
|
11190
11386
|
});
|
|
11191
|
-
const
|
|
11192
|
-
protocol: z.literal("enhance-canvas-editable/1"),
|
|
11387
|
+
const snapshotBinding = {
|
|
11193
11388
|
canvasId: z.uuid(),
|
|
11194
11389
|
version,
|
|
11195
11390
|
rootNodeId: nodeId$2,
|
|
11196
|
-
scopeNodeIds: z.array(nodeId$2).max(MAX_TARGETS),
|
|
11197
11391
|
scopePageId: z.string().nullable(),
|
|
11198
11392
|
digest: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
11199
|
-
}
|
|
11393
|
+
};
|
|
11394
|
+
/** Tokens issued before the scope became a digest list their selected roots; both are read. */
|
|
11395
|
+
const canvasSnapshotBindingSchema = z.discriminatedUnion("protocol", [z.strictObject({
|
|
11396
|
+
...snapshotBinding,
|
|
11397
|
+
protocol: z.literal("enhance-canvas-editable/1"),
|
|
11398
|
+
scopeNodeIds: z.array(nodeId$2)
|
|
11399
|
+
}), z.strictObject({
|
|
11400
|
+
...snapshotBinding,
|
|
11401
|
+
protocol: z.literal("enhance-canvas-editable/2"),
|
|
11402
|
+
scopeDigest: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
11403
|
+
})]);
|
|
11200
11404
|
const canvasOutlineCursorSchema = z.strictObject({
|
|
11201
11405
|
protocol: z.literal("enhance-canvas-outline/1"),
|
|
11202
11406
|
canvasId: z.uuid(),
|
|
@@ -11275,19 +11479,104 @@ const decodeCanvasExchangeToken = (token, schema) => {
|
|
|
11275
11479
|
throw new CliError("BAD_REQUEST", "The canvas snapshot or cursor is invalid or unsupported.", "Repeat the read and use its complete token without changing it.");
|
|
11276
11480
|
}
|
|
11277
11481
|
};
|
|
11482
|
+
const byCodeUnit = (left, right) => {
|
|
11483
|
+
if (left === right) return 0;
|
|
11484
|
+
return left < right ? -1 : 1;
|
|
11485
|
+
};
|
|
11486
|
+
/** The selected roots a snapshot is bound to: each once, in an order every machine agrees on. */
|
|
11487
|
+
const canonicalScope = (reference) => {
|
|
11488
|
+
const scope = [...new Set(reference.nodeIds)].toSorted(byCodeUnit);
|
|
11489
|
+
tallyCanvasWork("scope ids sorted", scope.length);
|
|
11490
|
+
return scope;
|
|
11491
|
+
};
|
|
11492
|
+
/** The fixed-length fingerprint of a scope: its size never follows the selection's. */
|
|
11493
|
+
const scopeDigestOf = (scope) => {
|
|
11494
|
+
const encoded = JSON.stringify(scope);
|
|
11495
|
+
tallyCanvasWork("scope bytes hashed", Buffer.byteLength(encoded));
|
|
11496
|
+
return createHash("sha256").update(encoded).digest("hex");
|
|
11497
|
+
};
|
|
11278
11498
|
const canvasSnapshotToken = (input) => encodeCanvasExchangeToken({
|
|
11279
|
-
protocol: "enhance-canvas-editable/
|
|
11499
|
+
protocol: "enhance-canvas-editable/2",
|
|
11280
11500
|
canvasId: input.reference.canvasId,
|
|
11281
11501
|
version: input.version,
|
|
11282
11502
|
rootNodeId: input.rootNodeId,
|
|
11283
|
-
|
|
11503
|
+
scopeDigest: scopeDigestOf(canonicalScope(input.reference)),
|
|
11284
11504
|
scopePageId: input.reference.pageId ?? null,
|
|
11285
11505
|
digest: canvasExchangeDigest(input.html)
|
|
11286
11506
|
});
|
|
11507
|
+
const hasSameScope = (binding, reference) => {
|
|
11508
|
+
const scope = canonicalScope(reference);
|
|
11509
|
+
if (binding.protocol === "enhance-canvas-editable/2") return binding.scopeDigest === scopeDigestOf(scope);
|
|
11510
|
+
const bound = new Set(binding.scopeNodeIds);
|
|
11511
|
+
return bound.size === scope.length && scope.every((id) => bound.has(id));
|
|
11512
|
+
};
|
|
11513
|
+
/** What a snapshot was taken of, in one shape for every token format still in flight. */
|
|
11287
11514
|
const resolveCanvasSnapshot = (token, reference) => {
|
|
11288
11515
|
const binding = decodeCanvasExchangeToken(token, canvasSnapshotBindingSchema);
|
|
11289
|
-
if (binding.canvasId !== reference.canvasId || binding.scopePageId !== (reference.pageId ?? null) ||
|
|
11290
|
-
return
|
|
11516
|
+
if (binding.canvasId !== reference.canvasId || binding.scopePageId !== (reference.pageId ?? null) || !hasSameScope(binding, reference)) throw new CliError("BAD_REQUEST", "The editable snapshot belongs to a different canvas, page or selection.", "Use the original canvas reference and read a fresh complete subtree if its scope must change.");
|
|
11517
|
+
return {
|
|
11518
|
+
canvasId: binding.canvasId,
|
|
11519
|
+
version: binding.version,
|
|
11520
|
+
rootNodeId: binding.rootNodeId,
|
|
11521
|
+
digest: binding.digest
|
|
11522
|
+
};
|
|
11523
|
+
};
|
|
11524
|
+
|
|
11525
|
+
//#endregion
|
|
11526
|
+
//#region src/application/canvas-reference.use-case.ts
|
|
11527
|
+
const hasCanvasReferenceScope = (reference) => reference.pageId !== void 0 || reference.nodeIds.length > 0;
|
|
11528
|
+
/** The origin a `/c/<id>` path is read against. The path names no host, and none is kept. */
|
|
11529
|
+
const PATH_ORIGIN = "https://canvas.invalid";
|
|
11530
|
+
/**
|
|
11531
|
+
* `canvas find` and `prototype publish` answer with the path `/c/<id>`, which is not an address by
|
|
11532
|
+
* itself, so it is read as the address it would be on any host.
|
|
11533
|
+
*/
|
|
11534
|
+
const asAddress = (reference) => {
|
|
11535
|
+
const candidate = reference.trim();
|
|
11536
|
+
return candidate.startsWith("/c/") ? `${PATH_ORIGIN}${candidate}` : reference;
|
|
11537
|
+
};
|
|
11538
|
+
const parseCanvasReference = (reference) => {
|
|
11539
|
+
const parsed = readCanvasReference(asAddress(reference));
|
|
11540
|
+
if (parsed.ok) return parsed.value;
|
|
11541
|
+
throw new CliError("BAD_REQUEST", `The canvas link contains an invalid or unsupported ${parsed.reason}.`, "Copy a current canvas, page or selection link. Recording and version links require their dedicated commands; do not discard their scope.");
|
|
11542
|
+
};
|
|
11543
|
+
const fromCanvasReference = (reference) => {
|
|
11544
|
+
const parsed = parseCanvasReference(reference);
|
|
11545
|
+
if (hasCanvasReferenceScope(parsed)) throw new CliError("BAD_REQUEST", `This command cannot discard the link ${parsed.nodeIds.length > 0 ? "selection" : "page"}.`, "Use canvas tree, a scoped render or a targeted edit. Use a canvas URL without page or selection only when the request covers the whole canvas.");
|
|
11546
|
+
return parsed.canvasId;
|
|
11547
|
+
};
|
|
11548
|
+
const canvasReferenceNodeIds = (reference, document) => {
|
|
11549
|
+
if (!hasCanvasReferenceScope(reference)) return /* @__PURE__ */ new Set();
|
|
11550
|
+
const scope = resolveCanvasReference(reference, document);
|
|
11551
|
+
if (scope.ok) return scope.nodeIds;
|
|
11552
|
+
const reason = scope.reason;
|
|
11553
|
+
throw new CliError(reason === "page" || reason === "selection" ? "NOT_FOUND" : "BAD_REQUEST", `The link ${reason} is unavailable or inconsistent: ${reference.nodeIds.join(", ")}${reference.pageId === void 0 ? "" : ` on page ${reference.pageId}`}.`, "Copy a current link. Keep its complete page and selection; do not substitute or broaden the target.");
|
|
11554
|
+
};
|
|
11555
|
+
const assertCanvasReferenceNodes = (reference, document, nodeIds) => {
|
|
11556
|
+
if (!hasCanvasReferenceScope(reference)) return;
|
|
11557
|
+
const scope = canvasReferenceNodeIds(reference, document);
|
|
11558
|
+
assertNodesInScope(scope, nodeIds);
|
|
11559
|
+
};
|
|
11560
|
+
const assertNodesInScope = (scope, nodeIds) => {
|
|
11561
|
+
const outside = nodeIds.filter((id) => !scope.has(id));
|
|
11562
|
+
if (outside.length > 0) throw new CliError("BAD_REQUEST", `These nodes are outside the link selection: ${outside.join(", ")}.`, "Limit the edit to the selected nodes and their descendants. Request a wider selection only when the person wants a wider change.");
|
|
11563
|
+
};
|
|
11564
|
+
const canvasReferenceRenderTarget = (reference, document, target) => {
|
|
11565
|
+
if (!hasCanvasReferenceScope(reference)) return target;
|
|
11566
|
+
const scope = canvasReferenceNodeIds(reference, document);
|
|
11567
|
+
const nodeId = target.kind === "node" ? target.nodeId : target.kind === "content" && reference.nodeIds.length === 1 ? reference.nodeIds[0] : void 0;
|
|
11568
|
+
if (nodeId !== void 0) {
|
|
11569
|
+
assertNodesInScope(scope, [nodeId]);
|
|
11570
|
+
return {
|
|
11571
|
+
kind: "node",
|
|
11572
|
+
nodeId
|
|
11573
|
+
};
|
|
11574
|
+
}
|
|
11575
|
+
if (reference.nodeIds.length === 0 && reference.pageId !== void 0 && (target.kind === "content" || target.kind === "page" && target.pageId === reference.pageId)) return {
|
|
11576
|
+
kind: "page",
|
|
11577
|
+
pageId: reference.pageId
|
|
11578
|
+
};
|
|
11579
|
+
throw new CliError("BAD_REQUEST", "This render target would discard the link page or selection.", "Render the linked page, or choose one node within the selection. Bounds and other pages may include unrelated content.");
|
|
11291
11580
|
};
|
|
11292
11581
|
|
|
11293
11582
|
//#endregion
|
|
@@ -11573,9 +11862,10 @@ const canvasInsertHtmlInputSchema = z.strictObject({
|
|
|
11573
11862
|
canvasRef: z.string().min(1),
|
|
11574
11863
|
baseVersion: z.number().int().positive(),
|
|
11575
11864
|
destination: z.strictObject({ parentNodeId: canvasSceneNodeSchema.shape.id.describe("Existing editable container, or root for top-level insertion. Preserve page and selection scope.") }),
|
|
11576
|
-
html: z.string().min(1).describe("One populated, safe HTML/CSS visual group.
|
|
11865
|
+
html: z.string().min(1).describe("One populated, safe HTML/CSS visual group. Without placement, the root lands at its authored position. The canonical compiler assigns fresh IDs."),
|
|
11866
|
+
placement: canvasPlacementIntentSchema.optional().describe("Where a new top-level screen (parentNodeId root) goes. auto: Enhance finds free space on the page and ignores the position authored on the root. near: beside or below an existing screen, the way to lay out a sequence; name the previous screen from its receipt. explicit: exactly these page coordinates, overlap allowed. Omit to keep the authored position. Not accepted for an insertion inside a container. The answer reports where the screen landed in result.placement."),
|
|
11577
11867
|
waitMs: z.number().int().min(0).max(MAX_WAIT_MS$1).default(DEFAULT_WAIT_MS$1).describe("Additional polling after the initial server call; this does not bound initial compilation time."),
|
|
11578
|
-
clientToken:
|
|
11868
|
+
clientToken: retryClientTokenSchema
|
|
11579
11869
|
});
|
|
11580
11870
|
const canvasInsertHtmlCapabilityInputSchema = canvasInsertHtmlInputSchema.omit({ clientToken: true });
|
|
11581
11871
|
const canvasMakeEditableInputSchema = z.strictObject({
|
|
@@ -11651,7 +11941,7 @@ const canvasFindCursorSchema = z.strictObject({
|
|
|
11651
11941
|
const canvasCreateToolInputSchema = z.strictObject({
|
|
11652
11942
|
destination: canvasDestinationSchema,
|
|
11653
11943
|
title: createCanvasInputSchema.shape.title,
|
|
11654
|
-
clientToken:
|
|
11944
|
+
clientToken: retryClientTokenSchema
|
|
11655
11945
|
});
|
|
11656
11946
|
const canvasCreateToolOutputSchema = z.strictObject({
|
|
11657
11947
|
canvasRef: z.uuid(),
|
|
@@ -11669,7 +11959,7 @@ const canvasRemoveInputSchema = z.strictObject({
|
|
|
11669
11959
|
canvasRef: z.string().min(1),
|
|
11670
11960
|
baseVersion: z.number().int().positive(),
|
|
11671
11961
|
rootNodeIds: z.array(canvasSceneNodeSchema.shape.id).min(1),
|
|
11672
|
-
clientToken:
|
|
11962
|
+
clientToken: retryClientTokenSchema
|
|
11673
11963
|
});
|
|
11674
11964
|
const canvasRemoveCapabilityInputSchema = canvasRemoveInputSchema.omit({ clientToken: true });
|
|
11675
11965
|
|
|
@@ -11791,7 +12081,7 @@ const canvasRenderBatchResultSchema = z.object({
|
|
|
11791
12081
|
next: z.array(z.string())
|
|
11792
12082
|
});
|
|
11793
12083
|
const canvasRenderScopedInputSchema = z.union([canvasRenderRequestSchema, canvasRenderBatchRequestSchema]).meta({ type: "object" });
|
|
11794
|
-
const canvasRenderScopedToolInputSchema = z.union([canvasRenderRequestSchema.extend({ clientToken:
|
|
12084
|
+
const canvasRenderScopedToolInputSchema = z.union([canvasRenderRequestSchema.extend({ clientToken: retryClientTokenSchema }), canvasRenderBatchRequestSchema.safeExtend({ clientToken: z.uuid().optional() })]).meta({ type: "object" });
|
|
11795
12085
|
|
|
11796
12086
|
//#endregion
|
|
11797
12087
|
//#region src/application/canvas-asset.schema.ts
|
|
@@ -11803,7 +12093,7 @@ const canvasAssetImportCapabilityInputSchema = z.strictObject({
|
|
|
11803
12093
|
path: z.string().min(1).describe("Explicit local file path. PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2.")
|
|
11804
12094
|
})
|
|
11805
12095
|
});
|
|
11806
|
-
const canvasAssetImportInputSchema = canvasAssetImportCapabilityInputSchema.extend({ clientToken:
|
|
12096
|
+
const canvasAssetImportInputSchema = canvasAssetImportCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
11807
12097
|
const canvasAssetImportOutputSchema = z.strictObject({
|
|
11808
12098
|
operation: canvasAssetOperationSchema,
|
|
11809
12099
|
resource: canvasAssetUploadOutputSchema.safeExtend({
|
|
@@ -11857,6 +12147,8 @@ const canvasWriteReceiptSchema = z.discriminatedUnion("outcome", [z.strictObject
|
|
|
11857
12147
|
total: z.number().int().nonnegative()
|
|
11858
12148
|
}).optional(),
|
|
11859
12149
|
affected: z.strictObject(affectedNodes),
|
|
12150
|
+
/** Where a placed copied set was saved; absent when the request asked for no placement. */
|
|
12151
|
+
placement: canvasPlacementResultSchema.optional(),
|
|
11860
12152
|
verification: z.strictObject({ rendered: z.literal(false) }),
|
|
11861
12153
|
warnings: z.array(z.string())
|
|
11862
12154
|
})]).meta({ type: "object" });
|
|
@@ -11877,7 +12169,7 @@ const common = {
|
|
|
11877
12169
|
canvasRef: z.string().min(1),
|
|
11878
12170
|
baseVersion: z.number().int().positive(),
|
|
11879
12171
|
waitMs: z.number().int().min(0).max(12e4).default(3e4).describe("Additional polling after the initial server call; this does not bound initial native preparation time."),
|
|
11880
|
-
clientToken:
|
|
12172
|
+
clientToken: retryClientTokenSchema
|
|
11881
12173
|
};
|
|
11882
12174
|
const canvasArrangeInputSchema = z.strictObject({
|
|
11883
12175
|
...common,
|
|
@@ -11886,7 +12178,8 @@ const canvasArrangeInputSchema = z.strictObject({
|
|
|
11886
12178
|
const canvasDuplicateInputSchema = z.strictObject({
|
|
11887
12179
|
...common,
|
|
11888
12180
|
nodeIds: canvasDuplicatePreparationSchema.shape.nodeIds,
|
|
11889
|
-
destination: canvasDuplicatePreparationSchema.shape.destination
|
|
12181
|
+
destination: canvasDuplicatePreparationSchema.shape.destination,
|
|
12182
|
+
placement: canvasDuplicatePreparationSchema.shape.placement.describe("Where a set of top-level copies goes: {kind:\"auto\"} for free space on the page, {kind:\"near\",anchorNodeId,side} beside a layer, or {kind:\"explicit\",x,y}. The set moves as one. Omit it for the native copy offset.")
|
|
11890
12183
|
});
|
|
11891
12184
|
const canvasArrangeCapabilityInputSchema = canvasArrangeInputSchema.omit({ clientToken: true });
|
|
11892
12185
|
const canvasDuplicateCapabilityInputSchema = canvasDuplicateInputSchema.omit({ clientToken: true });
|
|
@@ -11926,7 +12219,7 @@ const canvasCaptureCapabilityInputSchema = z.strictObject({
|
|
|
11926
12219
|
previewJobId: z.uuid().describe("The successful render job whose pixels you inspected at this exact recording time and canvas version."),
|
|
11927
12220
|
placement: canvasSnapshotRequestSchema.shape.placement.describe("Use editable-below-source. below-source is kept for older clients and lands the same editable frame below the root-level recording on its page.")
|
|
11928
12221
|
});
|
|
11929
|
-
const canvasCaptureInputSchema = canvasCaptureCapabilityInputSchema.extend({ clientToken:
|
|
12222
|
+
const canvasCaptureInputSchema = canvasCaptureCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
11930
12223
|
const canvasCaptureOutputSchema = z.strictObject({
|
|
11931
12224
|
operation: z.discriminatedUnion("kind", [
|
|
11932
12225
|
z.strictObject({
|
|
@@ -12062,6 +12355,7 @@ const canvasConversionStatusSchema = z.strictObject({
|
|
|
12062
12355
|
version: z.number().int().positive(),
|
|
12063
12356
|
rootNodeId: z.string(),
|
|
12064
12357
|
affectedBounds: canvasSceneBoxSchema,
|
|
12358
|
+
placement: canvasPlacementResultSchema.optional().describe("Where a placed insertion saved its screen, at this version."),
|
|
12065
12359
|
insertedCount: z.number().int().nonnegative(),
|
|
12066
12360
|
removedCount: z.number().int().nonnegative(),
|
|
12067
12361
|
identityCount: z.number().int().nonnegative(),
|
|
@@ -12152,7 +12446,7 @@ const canvasPrototypeCapabilityInputSchema = z.strictObject({
|
|
|
12152
12446
|
waitMs: canvasRenderRequestSchema.shape.waitMs.describe("Additional ingestion polling, capped at five seconds. This budget does not include packaging or network transfers."),
|
|
12153
12447
|
source: z.discriminatedUnion("kind", [directorySourceSchema, deploymentSourceSchema])
|
|
12154
12448
|
});
|
|
12155
|
-
const canvasPrototypeInputSchema = canvasPrototypeCapabilityInputSchema.extend({ clientToken:
|
|
12449
|
+
const canvasPrototypeInputSchema = canvasPrototypeCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
12156
12450
|
const canvasPrototypeIntentSchema = canvasPrototypeInputSchema.extend({ source: z.discriminatedUnion("kind", [canvasPrototypeBuildSourceSchema, deploymentSourceSchema]) });
|
|
12157
12451
|
const canvasPrototypeOutputSchema = z.strictObject({
|
|
12158
12452
|
operation: prototypeOperationSchema,
|
|
@@ -12210,7 +12504,7 @@ const canvasCapturePageCapabilityInputSchema = z.strictObject({
|
|
|
12210
12504
|
}).optional().describe("Optional: the width and height the snippet answered, for the picture shown while the page converts. Without it that picture is 1280 by 800. The frame always takes the captured page's own size."),
|
|
12211
12505
|
baseVersion: z.number().int().positive().optional().describe("The canvas version you read; the frame is saved as one change at it.")
|
|
12212
12506
|
});
|
|
12213
|
-
const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken:
|
|
12507
|
+
const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
12214
12508
|
const canvasCapturePageOutputSchema = z.strictObject({
|
|
12215
12509
|
step: z.enum([
|
|
12216
12510
|
"run-snippet",
|
|
@@ -12355,6 +12649,7 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
12355
12649
|
...CANVAS_VERSION_PROCEDURE_DESCRIPTIONS,
|
|
12356
12650
|
"canvas.createEditableFrame": "Insert one validated primitive subtree beside its source screen as an atomic canvas edit.",
|
|
12357
12651
|
"canvas.create": "Create a canvas and return the id required by canvas-scoped commands.",
|
|
12652
|
+
"canvas.applyEdits": "Plan and save an agent's text, style, name, copy and order edits as one canvas version.",
|
|
12358
12653
|
"canvas.applyOperations": "Atomically apply validated text, geometry, style, ordering, and removal operations to one canvas version.",
|
|
12359
12654
|
"canvas.realtime.ticket": "Issue a one-use browser ticket for a live canvas room.",
|
|
12360
12655
|
"canvas.realtime.activity.begin": "Show that this agent has started work on a canvas.",
|
|
@@ -12695,6 +12990,16 @@ const PROTOTYPE_LIFECYCLE_POLICY = {
|
|
|
12695
12990
|
reason: "Prototype upload lifecycle is wrapped by prototype publish.",
|
|
12696
12991
|
owner: "product"
|
|
12697
12992
|
};
|
|
12993
|
+
const ONBOARDING_POLICY = {
|
|
12994
|
+
exposure: "internal",
|
|
12995
|
+
reason: "Onboarding hints and their preferences belong to the person's own web app.",
|
|
12996
|
+
owner: "product"
|
|
12997
|
+
};
|
|
12998
|
+
const CREDENTIAL_LIFECYCLE_POLICY = {
|
|
12999
|
+
exposure: "cli-transport",
|
|
13000
|
+
reason: "Credential lifecycle remains in the interactive CLI auth surface.",
|
|
13001
|
+
owner: "cli"
|
|
13002
|
+
};
|
|
12698
13003
|
const STAGED_TRANSFER_POLICY = {
|
|
12699
13004
|
exposure: "internal",
|
|
12700
13005
|
reason: "Signed transfers are wrapped by prototype publish and asset import.",
|
|
@@ -12735,6 +13040,12 @@ const CAPTURE_PIPELINE_POLICY = {
|
|
|
12735
13040
|
owner: "product",
|
|
12736
13041
|
reason: "Capture reservation, publication and baseline promotion belong to explicit SDK pipeline callers."
|
|
12737
13042
|
};
|
|
13043
|
+
/** A write that agents reach only through the bounded, intention-revealing authoring commands. */
|
|
13044
|
+
const AUTHORING_POLICY = {
|
|
13045
|
+
exposure: "internal",
|
|
13046
|
+
reason: "Wrapped by bounded, intention-revealing authoring capabilities.",
|
|
13047
|
+
owner: "product"
|
|
13048
|
+
};
|
|
12738
13049
|
const PROCEDURE_CAPABILITY_POLICIES = {
|
|
12739
13050
|
"captureRun.review": SHARED_CAPABILITY_POLICY,
|
|
12740
13051
|
"captureRun.decide": {
|
|
@@ -12808,11 +13119,8 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12808
13119
|
...CANVAS_RECOVERY_POLICIES,
|
|
12809
13120
|
"canvas.chats.publish": CHAT_HISTORY_POLICY,
|
|
12810
13121
|
"canvas.copyFromWork": RECOVERY_COPY_POLICY,
|
|
12811
|
-
"canvas.applyOperations":
|
|
12812
|
-
|
|
12813
|
-
reason: "Wrapped by bounded, intention-revealing authoring capabilities.",
|
|
12814
|
-
owner: "product"
|
|
12815
|
-
},
|
|
13122
|
+
"canvas.applyOperations": AUTHORING_POLICY,
|
|
13123
|
+
"canvas.applyEdits": AUTHORING_POLICY,
|
|
12816
13124
|
"canvas.realtime.ticket": {
|
|
12817
13125
|
exposure: "internal",
|
|
12818
13126
|
reason: "Browser WebSocket admission is not an agent capability.",
|
|
@@ -12870,21 +13178,13 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12870
13178
|
reason: "Restoring historical state is restricted to an interactive person session.",
|
|
12871
13179
|
owner: "product"
|
|
12872
13180
|
},
|
|
12873
|
-
"person.createAgentToken":
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
"person.
|
|
12879
|
-
|
|
12880
|
-
reason: "Credential lifecycle remains in the interactive CLI auth surface.",
|
|
12881
|
-
owner: "cli"
|
|
12882
|
-
},
|
|
12883
|
-
"person.revokeAgentToken": {
|
|
12884
|
-
exposure: "cli-transport",
|
|
12885
|
-
reason: "Credential lifecycle remains in the interactive CLI auth surface.",
|
|
12886
|
-
owner: "cli"
|
|
12887
|
-
},
|
|
13181
|
+
"person.createAgentToken": CREDENTIAL_LIFECYCLE_POLICY,
|
|
13182
|
+
"person.listAgentTokens": CREDENTIAL_LIFECYCLE_POLICY,
|
|
13183
|
+
"person.revokeAgentToken": CREDENTIAL_LIFECYCLE_POLICY,
|
|
13184
|
+
"person.onboarding": ONBOARDING_POLICY,
|
|
13185
|
+
"person.dismissOnboardingStep": ONBOARDING_POLICY,
|
|
13186
|
+
"person.presentOnboardingStep": ONBOARDING_POLICY,
|
|
13187
|
+
"person.recordCanvasLinkCopied": ONBOARDING_POLICY,
|
|
12888
13188
|
"person.signIn": {
|
|
12889
13189
|
exposure: "internal",
|
|
12890
13190
|
reason: "Browser sign-in protocol is wrapped by the CLI auth surface.",
|
|
@@ -13476,6 +13776,8 @@ const SESSION_EXPIRED_REMEDIATION = `Your Enhance session expired. ${remediation
|
|
|
13476
13776
|
const remediationOf = (error, status) => {
|
|
13477
13777
|
const formatRefusal = error.fields?.["documentFormatVersion"];
|
|
13478
13778
|
if (formatRefusal !== void 0) return formatRefusal;
|
|
13779
|
+
const given = error.fields?.["remediation"];
|
|
13780
|
+
if (given !== void 0) return given;
|
|
13479
13781
|
if (status === void 0) return remediationFor(error.code);
|
|
13480
13782
|
const outcome = requestOutcomeOf({
|
|
13481
13783
|
kind: "response",
|
|
@@ -13485,7 +13787,7 @@ const remediationOf = (error, status) => {
|
|
|
13485
13787
|
});
|
|
13486
13788
|
if (outcome.kind === "sign-in" && outcome.reason === "session-expired") return SESSION_EXPIRED_REMEDIATION;
|
|
13487
13789
|
if (error.code === "CONFLICT" && outcome.kind === "transient") return "Wait a few seconds, then retry the same command with the same clientToken.";
|
|
13488
|
-
if (outcome.kind === "fault" && outcome.detail === "mutation-id-reused") return "Do not reuse a clientToken with different arguments. Send this change
|
|
13790
|
+
if (outcome.kind === "fault" && outcome.detail === "mutation-id-reused") return "Do not reuse a clientToken with different arguments. Send this change without a clientToken; the tool makes a new one.";
|
|
13489
13791
|
return remediationFor(error.code);
|
|
13490
13792
|
};
|
|
13491
13793
|
const trpcErrorSchema = z.object({ data: z.looseObject({
|
|
@@ -13496,8 +13798,12 @@ const appErrorFrom = (error) => {
|
|
|
13496
13798
|
const parsed = trpcErrorSchema.safeParse(error);
|
|
13497
13799
|
const appError = appErrorSchema.safeParse(parsed.success ? parsed.data.data.appError : null);
|
|
13498
13800
|
if (!appError.success) return null;
|
|
13801
|
+
const fields = Object.fromEntries(Object.entries(appError.data.fields ?? {}).filter(([name]) => name !== "remediation"));
|
|
13499
13802
|
return {
|
|
13500
|
-
appError:
|
|
13803
|
+
appError: {
|
|
13804
|
+
...appError.data,
|
|
13805
|
+
...appError.data.fields !== void 0 && { fields: Object.keys(fields).length === 0 ? void 0 : fields }
|
|
13806
|
+
},
|
|
13501
13807
|
remediation: remediationOf(appError.data, parsed.data?.data.httpStatus)
|
|
13502
13808
|
};
|
|
13503
13809
|
};
|
|
@@ -13970,14 +14276,7 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
13970
14276
|
inputSchema: canvasEditCapabilityInputSchema,
|
|
13971
14277
|
outputSchema: canvasEditOutputSchema,
|
|
13972
14278
|
summary: "Change selected text, styles, names, duplicates, or positions in one atomic design edit.",
|
|
13973
|
-
procedures: [
|
|
13974
|
-
"canvas.document.get",
|
|
13975
|
-
"canvas.mutation.get",
|
|
13976
|
-
"canvas.realtime.activity.begin",
|
|
13977
|
-
"canvas.realtime.activity.renew",
|
|
13978
|
-
"canvas.realtime.activity.end",
|
|
13979
|
-
"canvas.applyOperations"
|
|
13980
|
-
],
|
|
14279
|
+
procedures: ["canvas.edit"],
|
|
13981
14280
|
inputExample: {
|
|
13982
14281
|
canvas: CAPABILITY_UUID_EXAMPLE,
|
|
13983
14282
|
baseVersion: 1,
|
|
@@ -15432,7 +15731,10 @@ const toCanvasSceneNodeContract = (node) => canvasSceneNodeSchema.parse({
|
|
|
15432
15731
|
* that has no screen layer, onto its page at the box the draft gives.
|
|
15433
15732
|
*/
|
|
15434
15733
|
const toEditableFrameOrigin = (input) => "screenNodeId" in input ? {
|
|
15435
|
-
destination: {
|
|
15734
|
+
destination: {
|
|
15735
|
+
kind: "adjacent",
|
|
15736
|
+
...input.position !== void 0 && { position: input.position }
|
|
15737
|
+
},
|
|
15436
15738
|
source: {
|
|
15437
15739
|
kind: "screen",
|
|
15438
15740
|
nodeId: input.screenNodeId
|
|
@@ -16741,7 +17043,38 @@ const receiptSchema$1 = applyCanvasOperationsOutputSchema.pick({
|
|
|
16741
17043
|
changedNodeIds: true,
|
|
16742
17044
|
removedNodeIds: true
|
|
16743
17045
|
}).extend({ review: canvasMutationReviewSchema });
|
|
17046
|
+
/** An agent's edit batch: the API plans it on the layers it touches and saves it as one version. */
|
|
17047
|
+
const edit = (handlers) => canvasEditorProcedure.input(editCanvasInputSchema).output(editCanvasOutputSchema).mutation(async ({ input, ctx }) => {
|
|
17048
|
+
const edited = orThrow(await handlers.edit.execute({
|
|
17049
|
+
...input,
|
|
17050
|
+
surface: input.surface ?? "cli",
|
|
17051
|
+
personId: ctx.viewer.personId,
|
|
17052
|
+
actor: toCanvasMutationActor(ctx.viewer)
|
|
17053
|
+
}));
|
|
17054
|
+
if (edited.outcome === "no_op") return edited;
|
|
17055
|
+
const { duplicatedNodes, moves, affectedParents, ...applied } = edited;
|
|
17056
|
+
return {
|
|
17057
|
+
...applied,
|
|
17058
|
+
operations: applied.operations.map((operation) => canvasOperationSchema.parse(operation)),
|
|
17059
|
+
insertedNodeIds: [...applied.insertedNodeIds],
|
|
17060
|
+
changedNodeIds: [...applied.changedNodeIds],
|
|
17061
|
+
removedNodeIds: [...applied.removedNodeIds],
|
|
17062
|
+
boxes: { ...applied.boxes },
|
|
17063
|
+
...applied.copiedNodeIds !== void 0 && { copiedNodeIds: { ...applied.copiedNodeIds } },
|
|
17064
|
+
...duplicatedNodes !== void 0 && { duplicatedNodes: duplicatedNodes.map((node) => ({
|
|
17065
|
+
...node,
|
|
17066
|
+
descendantIdMap: { ...node.descendantIdMap }
|
|
17067
|
+
})) },
|
|
17068
|
+
...moves !== void 0 && { moves: moves.map((move) => ({ ...move })) },
|
|
17069
|
+
...affectedParents !== void 0 && { affectedParents: affectedParents.map((parent) => ({
|
|
17070
|
+
parentId: parent.parentId,
|
|
17071
|
+
children: [...parent.children]
|
|
17072
|
+
})) },
|
|
17073
|
+
next: []
|
|
17074
|
+
};
|
|
17075
|
+
});
|
|
16744
17076
|
const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
|
|
17077
|
+
applyEdits: edit(handlers),
|
|
16745
17078
|
revertMutations: canvasEditorProcedure.input(z.object({
|
|
16746
17079
|
canvasId: z.uuid(),
|
|
16747
17080
|
mutationIds: z.array(z.uuid()).min(1),
|
|
@@ -17435,13 +17768,17 @@ const wireResult = (job, result) => ({
|
|
|
17435
17768
|
...result.snapshot !== null && result.snapshot !== void 0 && { snapshot: result.snapshot },
|
|
17436
17769
|
expiresAt: result.expiresAt.toISOString()
|
|
17437
17770
|
});
|
|
17438
|
-
const wireConversionResult = (result) => ({
|
|
17771
|
+
const wireConversionResult = ({ placement, ...result }) => ({
|
|
17439
17772
|
...result,
|
|
17440
17773
|
idMap: { ...result.idMap },
|
|
17441
17774
|
insertedNodeIds: [...result.insertedNodeIds],
|
|
17442
17775
|
removedNodeIds: [...result.removedNodeIds],
|
|
17443
17776
|
boxes: { ...result.boxes },
|
|
17444
17777
|
affectedBounds: { ...result.affectedBounds },
|
|
17778
|
+
...placement !== void 0 && { placement: {
|
|
17779
|
+
...placement,
|
|
17780
|
+
roots: [...placement.roots]
|
|
17781
|
+
} },
|
|
17445
17782
|
report: {
|
|
17446
17783
|
...result.report,
|
|
17447
17784
|
issues: [...result.report.issues]
|
|
@@ -18313,6 +18650,43 @@ const createOrganisationPeopleRouter = (handlers) => trpcRouter({
|
|
|
18313
18650
|
transferOwnership: transferOwnership(handlers)
|
|
18314
18651
|
});
|
|
18315
18652
|
|
|
18653
|
+
//#endregion
|
|
18654
|
+
//#region ../api/src/person/infrastructure/onboarding.router.ts
|
|
18655
|
+
const stepOnWire = (step) => ({
|
|
18656
|
+
...step,
|
|
18657
|
+
snoozedUntil: step.snoozedUntil?.toISOString() ?? null
|
|
18658
|
+
});
|
|
18659
|
+
/** Translates the onboarding calls into the use case. No rules, no persistence. */
|
|
18660
|
+
const onboardingRoutes = (onboarding) => ({
|
|
18661
|
+
onboarding: personProcedure.meta({ description: "Read the onboarding facts and hint preferences for this person." }).input(onboardingInputSchema).output(onboardingOutputSchema).query(async ({ ctx }) => {
|
|
18662
|
+
const view = orThrow(await onboarding.read(ctx.viewer.personId));
|
|
18663
|
+
return {
|
|
18664
|
+
hasCommented: view.hasCommented,
|
|
18665
|
+
hasCopiedCanvasLink: view.hasCopiedCanvasLink,
|
|
18666
|
+
steps: {
|
|
18667
|
+
connect_agent: stepOnWire(view.steps.connect_agent),
|
|
18668
|
+
first_agent_work: stepOnWire(view.steps.first_agent_work),
|
|
18669
|
+
comment: stepOnWire(view.steps.comment),
|
|
18670
|
+
share_comments: stepOnWire(view.steps.share_comments)
|
|
18671
|
+
}
|
|
18672
|
+
};
|
|
18673
|
+
}),
|
|
18674
|
+
dismissOnboardingStep: personProcedure.meta({ description: "Record Got it or Maybe later on one onboarding hint." }).input(dismissOnboardingStepInputSchema).output(onboardingStepStateSchema).mutation(async ({ input, ctx }) => stepOnWire(orThrow(await onboarding.dismiss({
|
|
18675
|
+
personId: ctx.viewer.personId,
|
|
18676
|
+
stepId: input.stepId,
|
|
18677
|
+
choice: input.choice
|
|
18678
|
+
})))),
|
|
18679
|
+
presentOnboardingStep: personProcedure.meta({ description: "Count one automatic showing of an onboarding hint." }).input(presentOnboardingStepInputSchema).output(presentOnboardingStepOutputSchema).mutation(async ({ input, ctx }) => ({ automaticShowNumber: orThrow(await onboarding.present({
|
|
18680
|
+
personId: ctx.viewer.personId,
|
|
18681
|
+
stepId: input.stepId,
|
|
18682
|
+
presentationId: input.presentationId
|
|
18683
|
+
})) })),
|
|
18684
|
+
recordCanvasLinkCopied: personProcedure.meta({ description: "Record that a canvas link was copied successfully." }).input(recordCanvasLinkCopiedInputSchema).output(recordCanvasLinkCopiedOutputSchema).mutation(async ({ ctx }) => {
|
|
18685
|
+
orThrow(await onboarding.recordCanvasLinkCopied(ctx.viewer.personId));
|
|
18686
|
+
return { hasCopiedCanvasLink: true };
|
|
18687
|
+
})
|
|
18688
|
+
});
|
|
18689
|
+
|
|
18316
18690
|
//#endregion
|
|
18317
18691
|
//#region ../api/src/person/domain/prepared-canvas-id.domain-service.ts
|
|
18318
18692
|
const UUID_PART_LIMIT = 5;
|
|
@@ -18362,6 +18736,7 @@ const agentTokenRoutes = (handlers) => ({
|
|
|
18362
18736
|
}),
|
|
18363
18737
|
listAgentTokens: personProcedure.meta({ description: "List agent credentials so unused or revoked ones can be identified." }).input(listAgentTokensInputSchema).output(listAgentTokensOutputSchema).query(async ({ ctx }) => ({
|
|
18364
18738
|
isConnected: orThrow(await handlers.agentTokens.isConnected(ctx.viewer.personId)),
|
|
18739
|
+
hasEverConnected: orThrow(await handlers.agentTokens.hasEverConnected(ctx.viewer.personId)),
|
|
18365
18740
|
items: orThrow(await handlers.agentTokens.list(ctx.viewer.personId)).map((token) => tokenOnWire(token))
|
|
18366
18741
|
})),
|
|
18367
18742
|
revokeAgentToken: personProcedure.meta({ description: "Revoke an agent credential before its next request." }).input(revokeAgentTokenInputSchema).output(revokeAgentTokenOutputSchema).mutation(async ({ input, ctx }) => {
|
|
@@ -18490,6 +18865,15 @@ const profilePhotoRoutes = (profile) => ({
|
|
|
18490
18865
|
}))) }))
|
|
18491
18866
|
});
|
|
18492
18867
|
|
|
18868
|
+
//#endregion
|
|
18869
|
+
//#region ../api/src/person/person-router.plugin.ts
|
|
18870
|
+
/** The `person` namespace: this context's routers side by side, as a router may not import one. */
|
|
18871
|
+
const personRouterPlugin = (handlers) => ({
|
|
18872
|
+
...createPersonRouter(handlers)._def.record,
|
|
18873
|
+
...profilePhotoRoutes(handlers.profile),
|
|
18874
|
+
...onboardingRoutes(handlers.onboarding)
|
|
18875
|
+
});
|
|
18876
|
+
|
|
18493
18877
|
//#endregion
|
|
18494
18878
|
//#region ../api/src/prototype/infrastructure/prototype-completion.mapper.ts
|
|
18495
18879
|
const toPrototypeCompletionContract = (completed, input) => {
|
|
@@ -19405,10 +19789,7 @@ const createAppRouter = (handlers, options = DEFAULT_ROUTER_OPTIONS) => trpcRout
|
|
|
19405
19789
|
people: createOrganisationPeopleRouter(handlers.organisation),
|
|
19406
19790
|
invites: createOrganisationInviteRouter(handlers.organisation)
|
|
19407
19791
|
}),
|
|
19408
|
-
person: trpcRouter(
|
|
19409
|
-
...createPersonRouter(handlers.person)._def.record,
|
|
19410
|
-
...profilePhotoRoutes(handlers.person.profile)
|
|
19411
|
-
}),
|
|
19792
|
+
person: trpcRouter(personRouterPlugin(handlers.person)),
|
|
19412
19793
|
prototype: createPrototypeRouter(handlers.prototype),
|
|
19413
19794
|
stagedUpload: createStagedUploadRouter(handlers.prototype.stagedUploads),
|
|
19414
19795
|
recording: trpcRouter({
|
|
@@ -19483,6 +19864,7 @@ const handlers = {
|
|
|
19483
19864
|
markRead: unavailable.execute
|
|
19484
19865
|
},
|
|
19485
19866
|
applyOperations: unavailable,
|
|
19867
|
+
edit: unavailable,
|
|
19486
19868
|
createEditableFrame: unavailable,
|
|
19487
19869
|
create: unavailable,
|
|
19488
19870
|
get: unavailable,
|
|
@@ -19588,7 +19970,14 @@ const handlers = {
|
|
|
19588
19970
|
list: () => unavailable.execute(),
|
|
19589
19971
|
find: () => unavailable.execute(),
|
|
19590
19972
|
isConnected: () => unavailable.execute(),
|
|
19973
|
+
hasEverConnected: () => unavailable.execute(),
|
|
19591
19974
|
revoke: () => unavailable.execute()
|
|
19975
|
+
},
|
|
19976
|
+
onboarding: {
|
|
19977
|
+
read: () => unavailable.execute(),
|
|
19978
|
+
dismiss: () => unavailable.execute(),
|
|
19979
|
+
present: () => unavailable.execute(),
|
|
19980
|
+
recordCanvasLinkCopied: () => unavailable.execute()
|
|
19592
19981
|
}
|
|
19593
19982
|
},
|
|
19594
19983
|
prototype: {
|
|
@@ -20074,4 +20463,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
20074
20463
|
});
|
|
20075
20464
|
|
|
20076
20465
|
//#endregion
|
|
20077
|
-
export { canvasAssetImportInputSchema as $,
|
|
20466
|
+
export { canvasAssetImportInputSchema as $, screenTextCommentTargetSchema as $n, editCanvasOutputSchema as $r, commandName as $t, recordingSnapshotCapabilityInputSchema as A, getMeOutputSchema as An, textOf as Ar, canvasReferenceNodeIds as At, operationStatusImageSchema as B, commentMessageSchema as Bn, canvasLayoutMainAxisOf as Br, canvasOutlineCursorSchema as Bt, PROCEDURE_DESCRIPTIONS as C, canvasPaintSchema as Ci, createPrototypeArtifactOutputSchema as Cn, GROUP_KIND as Cr, ROOT_FIELD as Ct, canvasWriteHtmlCapabilityInputSchema as D, prototypeArtifactManifestSchema as Dn, SCREEN_KIND as Dr, objectFieldNames as Dt, canvasRenderCapabilityInputSchema as E, getPrototypePublishStatusOutputSchema as En, RECTANGLE_KIND as Er, isInputRecord as Et, canvasPrototypeCapabilityInputSchema as F, listOrganisationsOutputSchema as Fn, canvasRecordedBoxNoteFor as Fr, canvasExchangeDigest as Ft, canvasCaptureOutputSchema as G, getCommentOutputSchema as Gn, canvasAssetUploadOutputSchema as Gr, retryClientTokenSchema as Gt, operationStatusOutputSchema as H, commentThreadSchema as Hn, canvasLayoutPriorityDeclarations as Hr, canvasReadOutputSchema as Ht, canvasPrototypeInputSchema as I, emptyFixtureDocument as In, canvasAuthoredLayoutValueOf as Ir, canvasSnapshotToken as It, canvasDuplicateCapabilityInputSchema as J, replyCommentInputSchema as Jn, canvasFontAssetIdentityFromPath as Jr, tallyCanvasWork as Jt, canvasArrangeCapabilityInputSchema as K, listCommentsInputSchema as Kn, reserveCanvasAssetInputSchema as Kr, canvasTranscriptCursorSchema as Kt, canvasPrototypeIntentSchema as L, withFixtureScreen as Ln, canvasAuthoredStyleDeclarations as Lr, decodeCanvasExchangeToken as Lt, canvasCapturePageCapabilityInputSchema as M, cliAuthConfigurationSchema as Mn, saveCanvasDocumentOutputSchema as Mr, fromCanvasReference as Mt, canvasCapturePageInputSchema as N, createAgentTokenOutputSchema as Nn, wholeCanvasDocumentOutputSchema as Nr, hasCanvasReferenceScope as Nt, commentAttentionCapabilityInputSchema as O, prototypeArtifactPathSchema as On, TEXT_KIND as Or, quotedValue as Ot, canvasCapturePageOutputSchema as P, createOrganisationOutputSchema as Pn, canvasBoxSourceOf as Pr, parseCanvasReference as Pt, canvasAssetImportCapabilityInputSchema as Q, screenElementsCommentTargetSchema as Qn, CANVAS_RICH_TEXT_STYLE_PROPERTIES as Qr, cliPathOf as Qt, canvasPrototypeOutputSchema as R, commentAuthorSchema as Rn, canvasAxisStyleProperties as Rr, encodeCanvasExchangeToken as Rt, PROTOTYPE_UPDATE_GUIDANCE as S, canvasBlendModeSchema as Si, attachPrototypeArtifactOutputSchema as Sn, FRAME_KIND as Sr, canvasEditsSchema as St, canvasReadCapabilityInputSchema as T, getPrototypeArtifactCapabilitiesOutputSchema as Tn, PAGE_KIND as Tr, inputProblemSummary as Tt, canvasCaptureCapabilityInputSchema as U, domLocatorSchema as Un, canvasCssTokens as Ur, canvasUpdateHtmlCapabilityInputSchema as Ut, operationStatusInputSchema as V, commentResolverSchema as Vn, canvasLayoutPositionOf as Vr, canvasReadInputSchema as Vt, canvasCaptureInputSchema as W, elementAnchorSchema as Wn, canvasCssValue as Wr, canvasUpdateHtmlInputSchema as Wt, canvasPreparationOutputSchema as X, screenAreaCommentTargetSchema as Xn, canvasRichTextValueOf as Xr, callOf as Xt, canvasDuplicateInputSchema as Y, replyCommentOutputSchema as Yn, canvasRichTextOf as Yr, readStoredCanvasScene as Yt, canvasWriteReceiptSchema as Z, screenElementCommentTargetSchema as Zn, hasCanvasRichTextPaints as Zr, callingSurface as Zt, CANVAS_UPDATE_HTML_INPUT_EXAMPLE as _, emptyCanvasSceneDocument as _i, appendRecordingChunkOutputSchema as _n, canvasAgentActivityPhaseSchema as _r, canvasInsertHtmlCapabilityInputSchema as _t, createRouterShapeAdapter as a, createCanvasConversionOutputSchema as ai, MCP_TOOL_BY_CAPABILITY as an, canvasTextPropsWithContent as ar, canvasRenderScopedToolInputSchema as at, ProcessExitError as b, canvasAdditionalStyleSchema as bi, startRecordingOutputSchema as bn, createCanvasPreparationOutputSchema as br, canvasMakeEditableInputSchema as bt, toKebabCase as c, canvasRenderStateSchema as ci, SKILL_NAMES as cn, canvasCaptureSchema as cr, canvasRemoveCapabilityInputSchema as ct, createMcpCapabilityDiscoveryAdapter as d, createCanvasRenderOutputSchema as di, CliError as dn, canvasRecordingPropsSchema as dr, canvasCreateToolOutputSchema as dt, applyCanvasOperationsInputSchema as ei, currentNodeIdStep as en, startCommentInputSchema as er, canvasAssetImportOutputSchema as et, toExitCode as f, createRecordingSnapshotOutputSchema as fi, isFormatRefusalError as fn, captureLandingSchema as fr, canvasFindCursorSchema as ft, toRemoteError as g, canvasSceneDocumentSchema as gi, createScreenOutputSchema as gn, beginCanvasActivityOutputSchema as gr, listedCanvasesAnswerSchema as gt, toPublishedExitTable as h, canvasReadableSceneDocumentSchema as hi, completeScreenOutputSchema as hn, resolveCanvasReference as hr, createdCanvasAnswerSchema as ht, createLazyCapabilityCatalogAdapter as i, canvasNodeStylePatchSchema as ii, onSurface as in, canvasTextChangeBetween as ir, canvasRenderScopedInputSchema as it, transcriptReadCapabilityInputSchema as j, MCP_AUTH_SCOPE as jn, mapCanvasFontSources as jr, canvasReferenceRenderTarget as jt, prototypePublishCapabilityInputSchema as k, submitPrototypeArtifactOutputSchema as kn, canvasLayoutWithoutCssProperties as kr, assertCanvasReferenceNodes as kt, toPresentedCapabilities as l, canvasRenderTargetSchema as li, skillTextsFor as ln, canvasConversionMetadataSchema as lr, canvasRemoveInputSchema as lt, toMcpFailurePayload as m, getCanvasRenderOutputSchema as mi, appErrorSchema as mn, canvasReferencePageOf as mr, canvasFindOutputSchema as mt, withCommandName as n, getCanvasMutationOutputSchema as ni, inSurfaceWords as nn, applyCanvasTypographyPatch as nr, canvasRenderBatchResultSchema as nt, CAPTURE_PAGE_CALLS as o, getCanvasConversionOutputSchema as oi, CANVAS_EDIT_WORDS as on, canvasTextRunsOf as or, canvasRenderRequestSchema as ot, toFailurePayload as p, downloadCanvasRenderOutputSchema as pi, transcriptOutputSchema as pn, DEFAULT_CANVAS_REFERENCE_PAGE_ID as pr, canvasFindInputSchema as pt, canvasArrangeInputSchema as q, listCommentsOutputSchema as qn, reserveCanvasAssetOutputSchema as qr, canvasResourcesCursorSchema as qt, toCanvasAuthoringResult as r, canvasOperationSchema as ri, inputName as rn, canvasCssTypographyOwners as rr, canvasRenderPendingSchema as rt, toCapabilityDefinition as s, canvasRenderSourceStateSchema as si, SKILL_JOBS as sn, CAPTURE_LANDING_CONVERTING as sr, canvasRenderFileSchema as st, withCommandInFailure as t, applyCanvasOperationsOutputSchema as ti, diagnosisStep as tn, createCapturePassOutputSchema as tr, canvasRenderBatchRequestSchema as tt, toSharedCapabilities as u, canvasWorldBoundsSchema as ui, PartialBatchError as un, canvasPrototypePropsSchema as ur, canvasCreateToolInputSchema as ut, CAPABILITY_UUID_EXAMPLE as v, canvasImageAssetIdentityFromPath as vi, completeRecordingOutputSchema as vn, AGENT_CLIENT_HEADER as vr, canvasInsertHtmlInputSchema as vt, canvasApplyCapabilityInputSchema as w, canvasSchema as wi, foldPrototypeArtifactPath as wn, IMAGE_KIND as wr, inputProblemFields as wt, OPTION_DESCRIPTIONS as x, CANVAS_BLEND_MODES as xi, PROTOTYPE_ARTIFACT_MANIFEST_PATH as xn, getCanvasPreparationOutputSchema as xr, canvasEditCapabilityInputSchema as xt, createCapabilityPolicyAdapter as y, signedDownloadSchema as yi, getRecordingOutputSchema as yn, agentClientMetadata as yr, canvasMakeEditableCapabilityInputSchema as yt, canvasConversionStatusSchema as z, commentCanvasContextSchema as zn, canvasCssPixelValue as zr, resolveCanvasSnapshot as zt };
|