@enhance-eng/enhance 0.1.167 → 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-DbOpumEM.mjs → cli-output-identity.lib-CKns8qEG.mjs} +2211 -1719
- package/dist/main.mjs +678 -475
- package/dist/{mcp-invocation.adapter-CUyCBfrk.mjs → mcp-invocation.adapter-BfWB3PFL.mjs} +63 -38
- package/dist/mcp-main.mjs +9 -9
- package/dist/{mcp-server.adapter-KDg3Ektd.mjs → mcp-server.adapter-UiOcYGPZ.mjs} +109 -84
- package/dist/mcp.mjs +2 -2
- package/dist/remote-mcp-main.mjs +47 -15
- package/dist/{zod-messages.lib-Cs57z-_f.mjs → zod-messages.lib-G2BtVFRk.mjs} +3658 -3175
- 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,363 +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
|
-
"fontStyle",
|
|
1529
|
-
"fontVariant",
|
|
1530
|
-
"fontVariantCaps",
|
|
1531
|
-
"fontVariantLigatures",
|
|
1532
|
-
"fontVariantNumeric",
|
|
1533
|
-
"fontVariantPosition",
|
|
1534
|
-
"fontKerning",
|
|
1535
|
-
"fontVariationSettings",
|
|
1536
|
-
"fontWeight",
|
|
1537
|
-
"hyphenateCharacter",
|
|
1538
|
-
"hyphens",
|
|
1539
|
-
"justifyContent",
|
|
1540
|
-
"letterSpacing",
|
|
1541
|
-
"lineBreak",
|
|
1542
|
-
"lineHeight",
|
|
1543
|
-
"marginBottom",
|
|
1544
|
-
"marginLeft",
|
|
1545
|
-
"marginRight",
|
|
1546
|
-
"marginTop",
|
|
1547
|
-
"opacity",
|
|
1548
|
-
"overflowWrap",
|
|
1549
|
-
"paddingBottom",
|
|
1550
|
-
"paddingLeft",
|
|
1551
|
-
"paddingRight",
|
|
1552
|
-
"paddingTop",
|
|
1553
|
-
"rowGap",
|
|
1554
|
-
"tabSize",
|
|
1555
|
-
"textDecorationColor",
|
|
1556
|
-
"textDecorationLine",
|
|
1557
|
-
"textDecorationSkipInk",
|
|
1558
|
-
"textDecorationStyle",
|
|
1559
|
-
"textDecorationThickness",
|
|
1560
|
-
"textRendering",
|
|
1561
|
-
"textShadow",
|
|
1562
|
-
"textTransform",
|
|
1563
|
-
"textUnderlineOffset",
|
|
1564
|
-
"verticalAlign",
|
|
1565
|
-
"whiteSpace",
|
|
1566
|
-
"wordBreak",
|
|
1567
|
-
"wordSpacing",
|
|
1568
|
-
"WebkitFontSmoothing",
|
|
1569
|
-
"WebkitLocale",
|
|
1570
|
-
"WebkitTextFillColor",
|
|
1571
|
-
"WebkitTextStrokeColor",
|
|
1572
|
-
"WebkitTextStrokeWidth",
|
|
1573
|
-
"--canvas-text-stroke-alignment"
|
|
1574
|
-
]);
|
|
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);
|
|
1575
1546
|
|
|
1576
1547
|
//#endregion
|
|
1577
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1578
|
-
const
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
size: true,
|
|
1584
|
-
weight: true,
|
|
1585
|
-
style: true,
|
|
1586
|
-
variations: true,
|
|
1587
|
-
opticalSize: true,
|
|
1588
|
-
features: true,
|
|
1589
|
-
lineHeight: true,
|
|
1590
|
-
letterSpacing: true,
|
|
1591
|
-
transform: true,
|
|
1592
|
-
decoration: true,
|
|
1593
|
-
paragraphSpacing: true,
|
|
1594
|
-
paragraphIndent: true,
|
|
1595
|
-
listSpacing: true,
|
|
1596
|
-
hangingList: true,
|
|
1597
|
-
hangingPunctuation: true,
|
|
1598
|
-
verticalTrim: true,
|
|
1599
|
-
wrapStyle: true
|
|
1600
|
-
}).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
|
|
1601
|
-
const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
|
|
1602
|
-
const canvasTextStyleSchema = z.object({
|
|
1603
|
-
id: z.string().min(1),
|
|
1604
|
-
name: z.string().trim().min(1),
|
|
1605
|
-
description: z.string().max(MAX_DESCRIPTION$1),
|
|
1606
|
-
sortKey: z.string().min(1).optional(),
|
|
1607
|
-
sourceStyleId: z.string().min(1).optional(),
|
|
1608
|
-
sourceCanvasId: z.uuid().optional(),
|
|
1609
|
-
sourceRevision: z.number().int().positive().optional(),
|
|
1610
|
-
typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
|
|
1611
|
-
Reflect.deleteProperty(typography, "listStyle");
|
|
1612
|
-
return typography;
|
|
1613
|
-
})
|
|
1614
|
-
}).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
|
|
1615
|
-
message: "A source canvas belongs to a reference snapshot.",
|
|
1616
|
-
path: ["sourceCanvasId"]
|
|
1617
|
-
}).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
|
|
1618
|
-
message: "A published revision belongs to a source style and canvas.",
|
|
1619
|
-
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()
|
|
1620
1554
|
});
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
"subscript",
|
|
1626
|
-
"superscript"
|
|
1627
|
-
]).optional(),
|
|
1628
|
-
overrides: z.partialRecord(z.enum([
|
|
1629
|
-
"fontWeight",
|
|
1630
|
-
"fontStyle",
|
|
1631
|
-
"fontVariationSettings",
|
|
1632
|
-
"fontOpticalSizing",
|
|
1633
|
-
"textDecorationLine",
|
|
1634
|
-
"textDecorationStyle",
|
|
1635
|
-
"textDecorationColor",
|
|
1636
|
-
"textDecorationThickness",
|
|
1637
|
-
"textUnderlineOffset",
|
|
1638
|
-
"textDecorationSkipInk"
|
|
1639
|
-
]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
|
|
1640
|
-
}).strict();
|
|
1641
|
-
|
|
1642
|
-
//#endregion
|
|
1643
|
-
//#region ../../packages/contract/src/canvas/canvas-rich-text.lib.ts
|
|
1644
|
-
const fillsSchema = canvasPaintSchema.array().optional();
|
|
1645
|
-
/** What one rich text run stores besides its text, which the owner list of paint blends reads. */
|
|
1646
|
-
const canvasRichTextRunPaintSchema = z.object({ fills: fillsSchema });
|
|
1647
|
-
const characterFormattingSchema = canvasTextParagraphSchema.pick({
|
|
1648
|
-
paragraphSpacing: true,
|
|
1649
|
-
paragraphIndent: true,
|
|
1650
|
-
listSpacing: true,
|
|
1651
|
-
wrapStyle: true
|
|
1652
|
-
}).extend({
|
|
1653
|
-
hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
|
|
1654
|
-
verticalTrim: canvasTypographySchema.shape.verticalTrim,
|
|
1655
|
-
stroke: canvasTypographySchema.shape.stroke.nullable(),
|
|
1656
|
-
decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
|
|
1657
|
-
backgroundBlendMode: canvasBlendModeSchema.optional()
|
|
1658
|
-
}).strip();
|
|
1659
|
-
const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
|
|
1660
|
-
const richStylesOf = (value) => {
|
|
1661
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
1662
|
-
const entries = Object.entries(value);
|
|
1663
|
-
if (entries.some(([property, styleValue]) => !CANVAS_RICH_TEXT_STYLE_PROPERTIES.has(property) || typeof styleValue !== "string" && typeof styleValue !== "number")) return null;
|
|
1664
|
-
return Object.fromEntries(entries);
|
|
1665
|
-
};
|
|
1666
|
-
const richMetadataOf = (value) => {
|
|
1667
|
-
const sourcePath = Reflect.get(value, "sourcePath");
|
|
1668
|
-
return {
|
|
1669
|
-
...Object.fromEntries(Object.entries(value).filter(([key]) => ![
|
|
1670
|
-
"text",
|
|
1671
|
-
"href",
|
|
1672
|
-
"sourcePath",
|
|
1673
|
-
"styles",
|
|
1674
|
-
"fills",
|
|
1675
|
-
"stroke",
|
|
1676
|
-
"decorationBlendMode",
|
|
1677
|
-
"backgroundBlendMode",
|
|
1678
|
-
"paragraph",
|
|
1679
|
-
"paragraphSpacing",
|
|
1680
|
-
"paragraphIndent",
|
|
1681
|
-
"listSpacing",
|
|
1682
|
-
"hangingPunctuation",
|
|
1683
|
-
"verticalTrim",
|
|
1684
|
-
"wrapStyle",
|
|
1685
|
-
"soft",
|
|
1686
|
-
"textStyle"
|
|
1687
|
-
].includes(key))),
|
|
1688
|
-
...typeof sourcePath === "string" && { sourcePath }
|
|
1689
|
-
};
|
|
1690
|
-
};
|
|
1691
|
-
const richChildrenOf = (values) => {
|
|
1692
|
-
const result = [];
|
|
1693
|
-
const pending = values.toReversed().map((value) => ({
|
|
1694
|
-
value,
|
|
1695
|
-
target: result
|
|
1696
|
-
}));
|
|
1697
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
1698
|
-
while (pending.length > 0) {
|
|
1699
|
-
const task = pending.pop();
|
|
1700
|
-
if (task === void 0) continue;
|
|
1701
|
-
if ("done" in task) {
|
|
1702
|
-
ancestors.delete(task.done);
|
|
1703
|
-
continue;
|
|
1704
|
-
}
|
|
1705
|
-
const children = [];
|
|
1706
|
-
const node = richNodeOf(task.value, children);
|
|
1707
|
-
if (node === null) return null;
|
|
1708
|
-
task.target.push(node);
|
|
1709
|
-
if (node.kind !== "span") continue;
|
|
1710
|
-
const value = task.value;
|
|
1711
|
-
if (typeof value !== "object" || value === null || ancestors.has(value)) return null;
|
|
1712
|
-
ancestors.add(value);
|
|
1713
|
-
pending.push({ done: value });
|
|
1714
|
-
const nested = Reflect.get(value, "children");
|
|
1715
|
-
if (!Array.isArray(nested)) return null;
|
|
1716
|
-
const candidates = nested;
|
|
1717
|
-
for (const child of candidates.toReversed()) pending.push({
|
|
1718
|
-
value: child,
|
|
1719
|
-
target: children
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
return result;
|
|
1723
|
-
};
|
|
1724
|
-
const richBreakOf = (value) => {
|
|
1725
|
-
const soft = Reflect.get(value, "soft");
|
|
1726
|
-
if (soft !== void 0 && soft !== true) return null;
|
|
1727
|
-
return {
|
|
1728
|
-
...richMetadataOf(value),
|
|
1729
|
-
kind: "break",
|
|
1730
|
-
...soft === true && { soft }
|
|
1731
|
-
};
|
|
1732
|
-
};
|
|
1733
|
-
const richNodeOf = (value, children) => {
|
|
1734
|
-
if (typeof value !== "object" || value === null) return null;
|
|
1735
|
-
const kind = Reflect.get(value, "kind");
|
|
1736
|
-
const metadata = richMetadataOf(value);
|
|
1737
|
-
if (kind === "break") return richBreakOf(value);
|
|
1738
|
-
if (kind === "text") {
|
|
1739
|
-
const text = Reflect.get(value, "text");
|
|
1740
|
-
return typeof text === "string" ? {
|
|
1741
|
-
...metadata,
|
|
1742
|
-
kind,
|
|
1743
|
-
text
|
|
1744
|
-
} : null;
|
|
1745
|
-
}
|
|
1746
|
-
if (kind !== "span") return null;
|
|
1747
|
-
const values = Reflect.get(value, "children");
|
|
1748
|
-
const styles = richStylesOf(Reflect.get(value, "styles"));
|
|
1749
|
-
const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
|
|
1750
|
-
const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
|
|
1751
|
-
const formatting = characterFormattingSchema.safeParse(value);
|
|
1752
|
-
const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
|
|
1753
|
-
if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
|
|
1754
|
-
const href = safeHref(Reflect.get(value, "href"));
|
|
1755
|
-
return {
|
|
1756
|
-
...metadata,
|
|
1757
|
-
kind,
|
|
1758
|
-
styles,
|
|
1759
|
-
children,
|
|
1760
|
-
...textStyle.data !== void 0 && { textStyle: textStyle.data },
|
|
1761
|
-
...fills.data !== void 0 && { fills: fills.data },
|
|
1762
|
-
...paragraph.data !== void 0 && { paragraph: paragraph.data },
|
|
1763
|
-
...Object.fromEntries(Object.entries(formatting.data).filter(([, entry]) => entry !== void 0)),
|
|
1764
|
-
...href !== void 0 && { href }
|
|
1765
|
-
};
|
|
1766
|
-
};
|
|
1767
|
-
const richTextLeafValue = (node) => node.kind === "text" ? node.text : node.soft === true ? "\u2028" : "\n";
|
|
1768
|
-
const canvasRichTextValueOf = (nodes) => {
|
|
1769
|
-
const pending = nodes.toReversed();
|
|
1770
|
-
const text = [];
|
|
1771
|
-
while (pending.length > 0) {
|
|
1772
|
-
const node = pending.pop();
|
|
1773
|
-
if (node === void 0) break;
|
|
1774
|
-
if (node.kind === "span") for (const child of node.children.toReversed()) pending.push(child);
|
|
1775
|
-
else text.push(richTextLeafValue(node));
|
|
1776
|
-
}
|
|
1777
|
-
return text.join("");
|
|
1778
|
-
};
|
|
1779
|
-
const canvasRichTextOf = (node) => {
|
|
1780
|
-
const props = node.props;
|
|
1781
|
-
if (props === void 0 || !Array.isArray(props["richText"])) return [];
|
|
1782
|
-
const rich = richChildrenOf(props["richText"]);
|
|
1783
|
-
if (rich === null) return [];
|
|
1784
|
-
const text = props["text"];
|
|
1785
|
-
return canvasRichTextValueOf(rich) === text ? rich : [];
|
|
1786
|
-
};
|
|
1787
|
-
const hasCanvasRichTextPaints = (node) => {
|
|
1788
|
-
const pending = [...canvasRichTextOf(node)];
|
|
1789
|
-
while (pending.length > 0) {
|
|
1790
|
-
const run = pending.pop();
|
|
1791
|
-
if (run?.kind !== "span") continue;
|
|
1792
|
-
if (run.fills !== void 0) return true;
|
|
1793
|
-
for (const child of run.children) pending.push(child);
|
|
1794
|
-
}
|
|
1795
|
-
return false;
|
|
1796
|
-
};
|
|
1797
|
-
/** Existing-link edits retain authored formatting, including nested descendants. */
|
|
1798
|
-
const canvasRichTextLinkOf = (runs) => {
|
|
1799
|
-
const destinations = /* @__PURE__ */ new Set();
|
|
1800
|
-
const visit = (nodes, inherited) => {
|
|
1801
|
-
for (const node of nodes) if (node.kind === "span") visit(node.children, node.href ?? inherited);
|
|
1802
|
-
else destinations.add(inherited);
|
|
1803
|
-
};
|
|
1804
|
-
visit(runs);
|
|
1805
|
-
return destinations.size === 1 ? [...destinations][0] ?? null : null;
|
|
1806
|
-
};
|
|
1807
|
-
/**
|
|
1808
|
-
* The style text a run edit clears: the properties it sets, and for a stroke edit the style text
|
|
1809
|
-
* that copies a stroke, since the stroke value owns it.
|
|
1810
|
-
*/
|
|
1811
|
-
const canvasRunStylesClearedBy = (command) => [...Object.keys(command.styles), ...command.stroke === void 0 ? [] : [
|
|
1812
|
-
"WebkitTextStrokeWidth",
|
|
1813
|
-
"WebkitTextStrokeColor",
|
|
1814
|
-
"--canvas-text-stroke-alignment"
|
|
1815
|
-
]];
|
|
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);
|
|
1816
1559
|
|
|
1817
1560
|
//#endregion
|
|
1818
1561
|
//#region ../../packages/contract/src/shared/blob.schema.ts
|
|
@@ -1869,1061 +1612,668 @@ const canvasImageAssetIdentityFromPath = (path) => {
|
|
|
1869
1612
|
};
|
|
1870
1613
|
|
|
1871
1614
|
//#endregion
|
|
1872
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1873
|
-
const
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
const completeCanvasFontInputSchema = canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() });
|
|
1886
|
-
const reserveCanvasFontInputSchema = completeCanvasFontInputSchema.extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
|
|
1887
|
-
const completeCanvasFontOutputSchema = z.object({ path: z.string().startsWith("/v1/canvas-assets/") });
|
|
1888
|
-
const reserveCanvasFontOutputSchema = completeCanvasFontOutputSchema.extend({ upload: signedUploadSchema });
|
|
1889
|
-
const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
|
|
1890
|
-
const copyCanvasFontsInputSchema = z.object({
|
|
1891
|
-
canvasId: z.uuid(),
|
|
1892
|
-
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]
|
|
1893
1628
|
});
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
const
|
|
1901
|
-
if (
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
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
|
+
});
|
|
1906
1644
|
};
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
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({
|
|
1914
1779
|
canvasId: z.uuid(),
|
|
1915
|
-
|
|
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))
|
|
1916
1789
|
});
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
|
|
1920
|
-
bytes: z.number().int().positive(),
|
|
1921
|
-
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
1922
|
-
}), canvasAssetUploadIdentitySchema.extend({
|
|
1923
|
-
kind: z.literal("font"),
|
|
1924
|
-
contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
|
|
1925
|
-
bytes: z.number().int().positive(),
|
|
1926
|
-
sha256: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
1927
|
-
})]);
|
|
1928
|
-
const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
|
|
1929
|
-
kind: z.literal("image"),
|
|
1930
|
-
width: z.number().int().positive(),
|
|
1931
|
-
height: z.number().int().positive()
|
|
1932
|
-
}), z.strictObject({
|
|
1933
|
-
kind: z.literal("font"),
|
|
1934
|
-
family: z.string().min(1),
|
|
1935
|
-
subfamily: z.string(),
|
|
1936
|
-
style: z.enum([
|
|
1937
|
-
"normal",
|
|
1938
|
-
"italic",
|
|
1939
|
-
"oblique"
|
|
1940
|
-
]),
|
|
1941
|
-
minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
|
|
1942
|
-
maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
|
|
1943
|
-
}).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
|
|
1944
|
-
const canvasAssetUploadOutputSchema = z.strictObject({
|
|
1790
|
+
const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
|
|
1791
|
+
const inspectCanvasTreeOutputSchema = z.object({
|
|
1945
1792
|
canvasId: z.uuid(),
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
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
|
+
});
|
|
1957
1817
|
|
|
1958
1818
|
//#endregion
|
|
1959
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
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
|
+
})
|
|
1977
1849
|
]);
|
|
1978
|
-
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
"grid-template-rows",
|
|
1988
|
-
"grid-template-columns",
|
|
1989
|
-
"grid-template-areas"
|
|
1990
|
-
];
|
|
1991
|
-
const SHORTHANDS = {
|
|
1992
|
-
gap: ["row-gap", "column-gap"],
|
|
1993
|
-
"text-wrap": ["text-wrap-mode", "text-wrap-style"],
|
|
1994
|
-
padding: SIDES$2.map((side) => `padding-${side}`),
|
|
1995
|
-
margin: SIDES$2.map((side) => `margin-${side}`),
|
|
1996
|
-
flex: [
|
|
1997
|
-
"flex-grow",
|
|
1998
|
-
"flex-shrink",
|
|
1999
|
-
"flex-basis"
|
|
2000
|
-
],
|
|
2001
|
-
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
2002
|
-
"place-content": ["align-content", "justify-content"],
|
|
2003
|
-
"place-items": ["align-items", "justify-items"],
|
|
2004
|
-
"place-self": ["align-self", "justify-self"],
|
|
2005
|
-
"grid-template": GRID_TEMPLATE_PROPERTIES,
|
|
2006
|
-
grid: [
|
|
2007
|
-
...GRID_TEMPLATE_PROPERTIES,
|
|
2008
|
-
"grid-auto-rows",
|
|
2009
|
-
"grid-auto-columns",
|
|
2010
|
-
"grid-auto-flow"
|
|
2011
|
-
],
|
|
2012
|
-
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
2013
|
-
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
2014
|
-
"grid-area": [
|
|
2015
|
-
"grid-row-start",
|
|
2016
|
-
"grid-column-start",
|
|
2017
|
-
"grid-row-end",
|
|
2018
|
-
"grid-column-end"
|
|
2019
|
-
]
|
|
2020
|
-
};
|
|
2021
|
-
/** Related declarations stay authored; a longhand edit must not discard the rest of a shorthand. */
|
|
2022
|
-
const canvasCssPropertyScope = (property) => SHORTHANDS[property.toLowerCase()] ?? [property.toLowerCase()];
|
|
2023
|
-
const componentStateAfter = (state, character) => {
|
|
2024
|
-
if (state.isEscaped) return {
|
|
2025
|
-
...state,
|
|
2026
|
-
isEscaped: false
|
|
2027
|
-
};
|
|
2028
|
-
if (character === "\\") return {
|
|
2029
|
-
...state,
|
|
2030
|
-
isEscaped: true
|
|
2031
|
-
};
|
|
2032
|
-
if (state.quote !== "") return {
|
|
2033
|
-
...state,
|
|
2034
|
-
quote: state.quote === character ? "" : state.quote
|
|
2035
|
-
};
|
|
2036
|
-
if (["\"", "'"].includes(character)) return {
|
|
2037
|
-
...state,
|
|
2038
|
-
quote: character
|
|
2039
|
-
};
|
|
2040
|
-
const delta = [
|
|
2041
|
-
"(",
|
|
2042
|
-
"[",
|
|
2043
|
-
"{"
|
|
2044
|
-
].includes(character) ? 1 : [
|
|
2045
|
-
")",
|
|
2046
|
-
"]",
|
|
2047
|
-
"}"
|
|
2048
|
-
].includes(character) ? -1 : 0;
|
|
2049
|
-
return {
|
|
2050
|
-
...state,
|
|
2051
|
-
depth: state.depth + delta
|
|
2052
|
-
};
|
|
2053
|
-
};
|
|
2054
|
-
/** Split only at CSS component boundaries, keeping functions, line names and strings intact. */
|
|
2055
|
-
const canvasCssTokens = (value, separator = "space") => {
|
|
2056
|
-
const tokens = [];
|
|
2057
|
-
let token = "";
|
|
2058
|
-
let state = {
|
|
2059
|
-
depth: 0,
|
|
2060
|
-
quote: "",
|
|
2061
|
-
isEscaped: false
|
|
2062
|
-
};
|
|
2063
|
-
for (const character of value) {
|
|
2064
|
-
const canSplit = state.depth === 0 && state.quote === "" && !state.isEscaped;
|
|
2065
|
-
state = componentStateAfter(state, character);
|
|
2066
|
-
if (canSplit && (separator === "space" ? /\s/u.test(character) : character === separator)) {
|
|
2067
|
-
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
2068
|
-
token = "";
|
|
2069
|
-
} else token += character;
|
|
2070
|
-
}
|
|
2071
|
-
if (separator !== "space" || token !== "") tokens.push(token.trim());
|
|
2072
|
-
return tokens;
|
|
2073
|
-
};
|
|
2074
|
-
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";
|
|
2075
|
-
const gridPlacementValue = (property, value, index) => {
|
|
2076
|
-
const parts = canvasCssTokens(value, "/");
|
|
2077
|
-
const first = parts[0] ?? value;
|
|
2078
|
-
if (property !== "grid-area") return parts[index] ?? omittedGridLine(first);
|
|
2079
|
-
const column = parts[1] ?? omittedGridLine(first);
|
|
2080
|
-
return [
|
|
2081
|
-
first,
|
|
2082
|
-
column,
|
|
2083
|
-
parts[2] ?? omittedGridLine(first),
|
|
2084
|
-
parts[3] ?? omittedGridLine(column)
|
|
2085
|
-
][index] ?? value;
|
|
2086
|
-
};
|
|
2087
|
-
const implicitGridValues = (row, column, hasAutoRows) => {
|
|
2088
|
-
const tokens = canvasCssTokens(hasAutoRows ? row : column);
|
|
2089
|
-
const size = tokens.filter((token) => !/^(?:auto-flow|dense)$/iu.test(token)).join(" ");
|
|
2090
|
-
const flow = `${hasAutoRows ? "row" : "column"}${tokens.some((token) => /^dense$/iu.test(token)) ? " dense" : ""}`;
|
|
2091
|
-
return [
|
|
2092
|
-
hasAutoRows ? "none" : row,
|
|
2093
|
-
hasAutoRows ? column : "none",
|
|
2094
|
-
"none",
|
|
2095
|
-
hasAutoRows && size !== "" ? size : "auto",
|
|
2096
|
-
!hasAutoRows && size !== "" ? size : "auto",
|
|
2097
|
-
flow
|
|
2098
|
-
];
|
|
2099
|
-
};
|
|
2100
|
-
const gridTemplateValue = (property, value, index) => {
|
|
2101
|
-
if (/^(?:none|initial|unset)$/iu.test(value)) return [
|
|
2102
|
-
"none",
|
|
2103
|
-
"none",
|
|
2104
|
-
"none",
|
|
2105
|
-
"auto",
|
|
2106
|
-
"auto",
|
|
2107
|
-
"row"
|
|
2108
|
-
][index] ?? value;
|
|
2109
|
-
const parts = canvasCssTokens(value, "/");
|
|
2110
|
-
const row = parts[0] ?? value;
|
|
2111
|
-
const column = parts[1];
|
|
2112
|
-
if (row === "" || column === "" || parts.length > 2) return value;
|
|
2113
|
-
const hasAutoRows = canvasCssTokens(row).some((token) => token.toLowerCase() === "auto-flow");
|
|
2114
|
-
const hasAutoColumns = column !== void 0 && canvasCssTokens(column).some((token) => token.toLowerCase() === "auto-flow");
|
|
2115
|
-
if (property === "grid" && column !== void 0 && hasAutoRows !== hasAutoColumns) return implicitGridValues(row, column, hasAutoRows)[index] ?? value;
|
|
2116
|
-
if (hasAutoRows || hasAutoColumns) return value;
|
|
2117
|
-
const hasAreas = /["']/u.test(row);
|
|
2118
|
-
if (column === void 0 && !hasAreas) return value;
|
|
2119
|
-
return [
|
|
2120
|
-
hasAreas ? value : row,
|
|
2121
|
-
column ?? "none",
|
|
2122
|
-
hasAreas ? row : "none",
|
|
2123
|
-
"auto",
|
|
2124
|
-
"auto",
|
|
2125
|
-
"row"
|
|
2126
|
-
][index] ?? value;
|
|
2127
|
-
};
|
|
2128
|
-
const flexValues = (tokens) => {
|
|
2129
|
-
const numbers = [];
|
|
2130
|
-
let basis = "0%";
|
|
2131
|
-
for (const token of tokens) if (/^(?:\d+(?:\.\d*)?|\.\d+)$/u.test(token) && numbers.length < 2) numbers.push(token);
|
|
2132
|
-
else basis = token;
|
|
2133
|
-
return [
|
|
2134
|
-
numbers[0] ?? "1",
|
|
2135
|
-
numbers[1] ?? "1",
|
|
2136
|
-
basis
|
|
2137
|
-
];
|
|
2138
|
-
};
|
|
2139
|
-
const canvasCssShorthandValue = (property, value, index) => {
|
|
2140
|
-
if (/(?:var|env)\(|^(?:inherit|revert(?:-layer)?)$/iu.test(value)) return value;
|
|
2141
|
-
if (/^grid-(?:area|row|column)$/u.test(property)) return gridPlacementValue(property, value, index);
|
|
2142
|
-
if (property === "grid-template" || property === "grid") return gridTemplateValue(property, value, index);
|
|
2143
|
-
const tokens = canvasCssTokens(value);
|
|
2144
|
-
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";
|
|
2145
|
-
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";
|
|
2146
|
-
if (property === "flex") {
|
|
2147
|
-
if (value === "none") return [
|
|
2148
|
-
"0",
|
|
2149
|
-
"0",
|
|
2150
|
-
"auto"
|
|
2151
|
-
][index] ?? value;
|
|
2152
|
-
if (value === "initial") return [
|
|
2153
|
-
"0",
|
|
2154
|
-
"1",
|
|
2155
|
-
"auto"
|
|
2156
|
-
][index] ?? value;
|
|
2157
|
-
return flexValues(tokens)[index] ?? value;
|
|
2158
|
-
}
|
|
2159
|
-
return tokens[index] ?? (index === LEFT_SIDE_INDEX ? tokens[1] : void 0) ?? tokens[0] ?? value;
|
|
2160
|
-
};
|
|
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
|
+
});
|
|
2161
1859
|
|
|
2162
1860
|
//#endregion
|
|
2163
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2164
|
-
const
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
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"
|
|
1901
|
+
];
|
|
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
|
+
}]
|
|
2175
1937
|
};
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
const index = scope.indexOf(property);
|
|
2188
|
-
if (index === -1) continue;
|
|
2189
|
-
const isPriority = hasCanvasCssPriority(raw);
|
|
2190
|
-
if (isImportant && !isPriority) continue;
|
|
2191
|
-
const value = cssValue(raw, /^grid(?:-|$)/iu.test(key));
|
|
2192
|
-
result = scope.length === 1 ? value : canvasCssShorthandValue(key.toLowerCase(), value, index);
|
|
2193
|
-
isImportant = isPriority;
|
|
2194
|
-
}
|
|
2195
|
-
return result ?? void 0;
|
|
2196
|
-
};
|
|
2197
|
-
/**
|
|
2198
|
-
* Edits replace a node's style objects rather than changing them, so their identity keys the values
|
|
2199
|
-
* already read. Rendering a large document reads each property of each node many times.
|
|
2200
|
-
*/
|
|
2201
|
-
const readAuthoredValues = /* @__PURE__ */ new WeakMap();
|
|
2202
|
-
/** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
|
|
2203
|
-
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
2204
|
-
const known = readAuthoredValues.get(node.styles);
|
|
2205
|
-
const read = known !== void 0 && known.additionalStyles === node.additionalStyles ? known : {
|
|
2206
|
-
additionalStyles: node.additionalStyles,
|
|
2207
|
-
values: /* @__PURE__ */ new Map()
|
|
2208
|
-
};
|
|
2209
|
-
if (read !== known) readAuthoredValues.set(node.styles, read);
|
|
2210
|
-
if (read.values.has(property)) return read.values.get(property);
|
|
2211
|
-
const value = authoredLayoutValue(node, property);
|
|
2212
|
-
read.values.set(property, value);
|
|
2213
|
-
return value;
|
|
2214
|
-
};
|
|
2215
|
-
const canvasCssPixelValue = (value) => {
|
|
2216
|
-
if (value === void 0) return;
|
|
2217
|
-
return /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?$/u.test(value) ? Number(value.replace("px", "")) : void 0;
|
|
2218
|
-
};
|
|
2219
|
-
/** Named controls override only their own longhand, even beside an important shorthand. */
|
|
2220
|
-
const canvasLayoutPriorityDeclarations = (node, declarations) => {
|
|
2221
|
-
const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
|
|
2222
|
-
return Object.fromEntries(Object.entries(declarations).map(([property, value]) => [property, canvasCssPropertyScope(property).some((owned) => important.has(owned)) && !hasCanvasCssPriority(value) ? `${canvasCssValue(property, value)} !important` : value]));
|
|
2223
|
-
};
|
|
2224
|
-
const canvasWritingModeOf = (node, document) => {
|
|
2225
|
-
const visited = /* @__PURE__ */ new Set();
|
|
2226
|
-
let current = node;
|
|
2227
|
-
while (current !== void 0 && !visited.has(current.id)) {
|
|
2228
|
-
visited.add(current.id);
|
|
2229
|
-
const value = canvasAuthoredLayoutValueOf(current, "writing-mode");
|
|
2230
|
-
if (value !== void 0 && value !== "inherit" && value !== "unset") return value;
|
|
2231
|
-
if (document === void 0) break;
|
|
2232
|
-
const parentId = document.relationships[current.id]?.parentId;
|
|
2233
|
-
if (parentId === void 0) break;
|
|
2234
|
-
current = document.nodes[parentId];
|
|
2235
|
-
}
|
|
2236
|
-
return "horizontal-tb";
|
|
2237
|
-
};
|
|
2238
|
-
const canvasAxisStyleProperties = (node, axis, document) => {
|
|
2239
|
-
const isVerticalWriting = /^(?:vertical|sideways)-/u.test(canvasWritingModeOf(node, document));
|
|
2240
|
-
return [axis === "horizontal" ? "width" : "height", axis === "vertical" === isVerticalWriting ? "inline-size" : "block-size"];
|
|
2241
|
-
};
|
|
2242
|
-
const canvasLayoutPositionOf = (node) => {
|
|
2243
|
-
const position = canvasAuthoredLayoutValueOf(node, "position");
|
|
2244
|
-
return node.layout?.position ?? (position === "absolute" || position === "fixed" || position === void 0 && node.box !== void 0 ? "absolute" : "flow");
|
|
2245
|
-
};
|
|
2246
|
-
/** Authored display wins over legacy presets; Grid has no Flex main axis. */
|
|
2247
|
-
const canvasLayoutFlowOf = (node) => {
|
|
2248
|
-
if (node === void 0) return "freeform";
|
|
2249
|
-
const display = canvasAuthoredLayoutValueOf(node, "display");
|
|
2250
|
-
if (display !== void 0) {
|
|
2251
|
-
if (/^(?:(?:inline|block)\s+|inline-)?grid$/u.test(display)) return "grid";
|
|
2252
|
-
if (/^(?:(?:inline|block)\s+|inline-)?flex$/u.test(display)) return "flex";
|
|
2253
|
-
return "freeform";
|
|
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
|
|
2254
1949
|
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
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
|
|
2269
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
|
+
});
|
|
2270
1992
|
|
|
2271
1993
|
//#endregion
|
|
2272
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2273
|
-
const
|
|
2274
|
-
"
|
|
2275
|
-
"
|
|
2276
|
-
"
|
|
2277
|
-
"
|
|
2278
|
-
"
|
|
2279
|
-
"
|
|
2280
|
-
"
|
|
2281
|
-
"
|
|
2282
|
-
"
|
|
2283
|
-
"
|
|
2284
|
-
"
|
|
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"
|
|
2285
2011
|
];
|
|
2286
|
-
const
|
|
2287
|
-
"
|
|
2288
|
-
"
|
|
2289
|
-
"
|
|
2290
|
-
"
|
|
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"
|
|
2291
2045
|
];
|
|
2292
|
-
const GROUP_TRANSFORM = "--enhance-group-affine-residual";
|
|
2293
|
-
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.";
|
|
2294
|
-
const isSet = (value) => value !== void 0 && value !== "" && value !== "none";
|
|
2295
|
-
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);
|
|
2296
|
-
/**
|
|
2297
|
-
* The canvas draws a layer at its box only when it positions the layer absolutely and the layer
|
|
2298
|
-
* names no inset of its own; an inset on either axis takes that axis from the box. This is the
|
|
2299
|
-
* test the style projection makes before it writes `left` and `top` from the box, and a layer
|
|
2300
|
-
* with no box has no source.
|
|
2301
|
-
*/
|
|
2302
|
-
const canvasBoxSourceOf = (node) => {
|
|
2303
|
-
if (node.box === void 0) return void 0;
|
|
2304
|
-
const authored = canvasAuthoredStyleDeclarations(node);
|
|
2305
|
-
if (!(canvasLayoutPositionOf(node) === "absolute" && INSETS.every((property) => authored[property] === void 0))) return "recorded";
|
|
2306
|
-
return hasOwnTransform(node, authored) ? "placed-before-transform" : "placed";
|
|
2307
|
-
};
|
|
2308
|
-
/** One line for a whole read, however many of its boxes are recorded. */
|
|
2309
|
-
const canvasRecordedBoxNoteFor = (boxes) => boxes.some((box) => box.boxSource === "recorded") ? { boxNote: CANVAS_RECORDED_BOX_NOTE } : {};
|
|
2310
|
-
|
|
2311
|
-
//#endregion
|
|
2312
|
-
//#region ../../packages/contract/src/canvas/canvas-export-settings.schema.ts
|
|
2313
|
-
const format = z.enum(["png", "jpeg"]);
|
|
2314
|
-
const scale = z.number().positive();
|
|
2315
|
-
const canvasExportSettingsSchema = z.strictObject({
|
|
2316
|
-
format: format.optional(),
|
|
2317
|
-
scale: scale.optional()
|
|
2318
|
-
});
|
|
2319
|
-
const canvasExportSettingsPatchSchema = z.strictObject({
|
|
2320
|
-
format: format.nullable().optional(),
|
|
2321
|
-
scale: scale.nullable().optional()
|
|
2322
|
-
}).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
|
|
2323
2046
|
|
|
2324
2047
|
//#endregion
|
|
2325
|
-
//#region ../../packages/contract/src/canvas/canvas-
|
|
2326
|
-
const
|
|
2327
|
-
const
|
|
2328
|
-
const
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
x: coordinate,
|
|
2334
|
-
y: coordinate,
|
|
2335
|
-
width: dimension$1,
|
|
2336
|
-
height: dimension$1
|
|
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()
|
|
2337
2056
|
});
|
|
2338
|
-
const
|
|
2339
|
-
kind: z.literal("
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
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
|
|
2345
2070
|
})
|
|
2346
|
-
});
|
|
2347
|
-
const canvasPolygonGeometrySchema = z.strictObject({
|
|
2348
|
-
kind: z.literal("polygon"),
|
|
2349
|
-
count: z.number().int().min(MIN_POLYGON_POINTS),
|
|
2350
|
-
innerRatio: z.number().min(0).max(1).optional(),
|
|
2351
|
-
cornerRadius: dimension$1,
|
|
2352
|
-
cornerSmoothing: z.number().min(0).max(1)
|
|
2353
|
-
});
|
|
2354
|
-
const canvasBooleanOperationSchema = z.enum([
|
|
2355
|
-
"union",
|
|
2356
|
-
"subtract",
|
|
2357
|
-
"intersect",
|
|
2358
|
-
"exclude"
|
|
2359
2071
|
]);
|
|
2360
|
-
const
|
|
2361
|
-
kind: z.literal("
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
result: z.strictObject({
|
|
2365
|
-
path,
|
|
2366
|
-
fillRule: z.literal("nonzero"),
|
|
2367
|
-
isEmpty: z.boolean(),
|
|
2368
|
-
bounds: canvasGeometryBoundsSchema,
|
|
2369
|
-
inputKey: z.string().regex(/^[a-f0-9]{16}$/u)
|
|
2370
|
-
}).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()
|
|
2371
2076
|
});
|
|
2372
|
-
const
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
z.
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
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()
|
|
2384
2094
|
}),
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
//#endregion
|
|
2389
|
-
//#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
|
|
2390
|
-
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
2391
|
-
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.";
|
|
2392
|
-
const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
|
|
2393
|
-
/** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
|
|
2394
|
-
const FOR_CALLER = { forCaller: true };
|
|
2395
|
-
/**
|
|
2396
|
-
* The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
|
|
2397
|
-
* writes that format may make is `refuseUnsafeWriterFormat`'s call.
|
|
2398
|
-
*/
|
|
2399
|
-
const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
|
|
2400
|
-
description: `The document format this client writes. The current format is ${String(15)}.`,
|
|
2401
|
-
examples: [15]
|
|
2095
|
+
box: canvasWorldBoundsSchema,
|
|
2096
|
+
version: z.number().int().positive(),
|
|
2097
|
+
alreadyPresent: z.boolean()
|
|
2402
2098
|
});
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
};
|
|
2419
|
-
const canvasPreservedFontAppearanceSchema = z.object({
|
|
2420
|
-
signature: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
2421
|
-
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
2422
|
-
image: z.string().refine((image) => image.startsWith("data:image/jpeg;base64,") || canvasImageAssetIdentityFromPath(image) !== null),
|
|
2423
|
-
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"]
|
|
2424
2114
|
});
|
|
2425
|
-
const
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
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()
|
|
2430
2123
|
});
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
]);
|
|
2438
|
-
const canvasNodeConstraintsSchema = z.object({
|
|
2439
|
-
x: canvasConstraintSchema,
|
|
2440
|
-
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()
|
|
2441
2130
|
});
|
|
2442
|
-
const
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
"content",
|
|
2446
|
-
"user"
|
|
2447
|
-
]);
|
|
2448
|
-
const canvasSceneNodeSchema = z.looseObject({
|
|
2449
|
-
id: z.string().min(1),
|
|
2450
|
-
label: z.string(),
|
|
2451
|
-
component: z.string().min(1),
|
|
2452
|
-
labelOrigin: canvasNodeLabelOriginSchema.optional(),
|
|
2453
|
-
visible: z.boolean().optional(),
|
|
2454
|
-
locked: z.boolean().optional(),
|
|
2455
|
-
constraints: canvasNodeConstraintsSchema.optional(),
|
|
2456
|
-
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
2457
|
-
layout: canvasNodeLayoutSchema.optional(),
|
|
2458
|
-
responsive: z.never().optional(),
|
|
2459
|
-
appearance: canvasAppearanceValuesSchema.optional(),
|
|
2460
|
-
exportSettings: canvasExportSettingsSchema.optional(),
|
|
2461
|
-
typography: canvasAuthoredTypographySchema.optional(),
|
|
2462
|
-
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
2463
|
-
geometry: canvasGeometrySchema.optional(),
|
|
2464
|
-
compositing: z.never({ error: CANVAS_COMPOSITING_RETIRED }).optional(),
|
|
2465
|
-
props: z.record(z.string(), z.unknown()).optional(),
|
|
2466
|
-
box: canvasSceneBoxSchema.optional()
|
|
2131
|
+
const canvasRenderTimingSchema = z.object({
|
|
2132
|
+
phase: canvasRenderPhaseSchema,
|
|
2133
|
+
durationMs: z.number().int().min(0)
|
|
2467
2134
|
});
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
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()
|
|
2471
2151
|
});
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
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()
|
|
2477
2172
|
});
|
|
2478
|
-
const
|
|
2479
|
-
|
|
2480
|
-
|
|
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
|
-
locked: false,
|
|
2515
|
-
styles: {}
|
|
2516
|
-
} },
|
|
2517
|
-
relationships: {},
|
|
2518
|
-
tombstones: {}
|
|
2519
|
-
});
|
|
2520
|
-
const shellSchema = canvasSceneDocumentSchema.extend({
|
|
2521
|
-
nodes: z.record(z.string(), z.unknown()),
|
|
2522
|
-
relationships: z.record(z.string(), z.unknown())
|
|
2523
|
-
});
|
|
2524
|
-
|
|
2525
|
-
//#endregion
|
|
2526
|
-
//#region ../../packages/contract/src/canvas/canvas-conversion-draft.schema.ts
|
|
2527
|
-
const temporaryIdSchema = z.string().min(1);
|
|
2528
|
-
const canvasConversionIssueSchema = z.object({
|
|
2529
|
-
code: z.enum([
|
|
2530
|
-
"asset-unavailable",
|
|
2531
|
-
"content-omitted",
|
|
2532
|
-
"cross-origin-frame",
|
|
2533
|
-
"nodes-truncated",
|
|
2534
|
-
"responsive-behavior-not-editable",
|
|
2535
|
-
"style-degraded",
|
|
2536
|
-
"unsupported-surface"
|
|
2537
|
-
]),
|
|
2538
|
-
message: z.string().min(1),
|
|
2539
|
-
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()
|
|
2540
2209
|
});
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
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
|
-
collapsedTransferredWrapperNodeCount: z.number().int().nonnegative().optional(),
|
|
2578
|
-
layoutContainerCount: z.number().int().nonnegative().optional(),
|
|
2579
|
-
removedLeafNodeCount: z.number().int().nonnegative().optional(),
|
|
2580
|
-
retainedSemanticOwnerNodeCount: z.number().int().nonnegative().optional(),
|
|
2581
|
-
truncatedNodeCount: z.number().int().nonnegative().optional(),
|
|
2582
|
-
addedLayoutNodeCount: z.number().int().nonnegative().optional(),
|
|
2583
|
-
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()
|
|
2584
2246
|
});
|
|
2585
|
-
const
|
|
2586
|
-
const
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2247
|
+
const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2248
|
+
const downloadCanvasRenderOutputSchema = z.object({
|
|
2249
|
+
jobId: z.uuid(),
|
|
2250
|
+
download: signedDownloadSchema,
|
|
2251
|
+
source: canvasRenderSourceSchema.optional()
|
|
2590
2252
|
});
|
|
2591
|
-
const
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
report: {
|
|
2603
|
-
...draft.report,
|
|
2604
|
-
nodeCount: draft.nodes.length
|
|
2605
|
-
}
|
|
2606
|
-
}));
|
|
2607
|
-
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
2608
|
-
const editableFrameCaptureSchema = z.object({
|
|
2609
|
-
screenId: z.string().min(1),
|
|
2610
|
-
pageId: z.string().min(1),
|
|
2611
|
-
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"]) })
|
|
2612
2264
|
});
|
|
2613
|
-
const
|
|
2265
|
+
const createRecordingSnapshotInputSchema = z.object({
|
|
2614
2266
|
canvasId: z.uuid(),
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
const createEditableFrameInputSchema = z.union([z.strictObject({
|
|
2622
|
-
...editableFrameInputBase,
|
|
2623
|
-
screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself.")
|
|
2624
|
-
}), z.strictObject({
|
|
2625
|
-
...editableFrameInputBase,
|
|
2626
|
-
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
2627
|
-
})]).superRefine((input, context) => {
|
|
2628
|
-
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()
|
|
2629
2273
|
});
|
|
2630
|
-
const
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
previousVersion: z.number().int().positive(),
|
|
2634
|
-
version: z.number().int().positive(),
|
|
2635
|
-
rootNodeId: z.string().min(1),
|
|
2636
|
-
idMap: z.record(temporaryIdSchema, z.string().min(1)),
|
|
2637
|
-
insertedNodeIds: z.array(z.string().min(1)),
|
|
2638
|
-
removedNodeIds: z.array(z.string().min(1)),
|
|
2639
|
-
boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
|
|
2640
|
-
affectedBounds: canvasSceneBoxSchema
|
|
2641
|
-
});
|
|
2642
|
-
|
|
2643
|
-
//#endregion
|
|
2644
|
-
//#region ../../packages/contract/src/canvas/canvas-render.consts.ts
|
|
2645
|
-
const RENDER_PHASES = [
|
|
2646
|
-
"queued",
|
|
2647
|
-
"claimed",
|
|
2648
|
-
"grant",
|
|
2649
|
-
"navigate",
|
|
2650
|
-
"document",
|
|
2651
|
-
"sources",
|
|
2652
|
-
"fonts",
|
|
2653
|
-
"layout",
|
|
2654
|
-
"target",
|
|
2655
|
-
"capture",
|
|
2656
|
-
"serialize",
|
|
2657
|
-
"compile",
|
|
2658
|
-
"commit",
|
|
2659
|
-
"upload",
|
|
2660
|
-
"complete"
|
|
2661
|
-
];
|
|
2662
|
-
const RENDER_STATES = [
|
|
2663
|
-
"queued",
|
|
2664
|
-
"running",
|
|
2665
|
-
"succeeded",
|
|
2666
|
-
"failed",
|
|
2667
|
-
"cancelled",
|
|
2668
|
-
"expired"
|
|
2669
|
-
];
|
|
2670
|
-
const RENDER_FAILURE_REASONS = [
|
|
2671
|
-
"VERSION_CHANGED",
|
|
2672
|
-
"TARGET_NOT_FOUND",
|
|
2673
|
-
"TARGET_INVALID",
|
|
2674
|
-
"OUTPUT_TOO_LARGE",
|
|
2675
|
-
"READINESS_TIMEOUT",
|
|
2676
|
-
"SOURCE_FAILED",
|
|
2677
|
-
"BROWSER_CRASH",
|
|
2678
|
-
"CAPTURE_FAILED",
|
|
2679
|
-
"CONVERSION_FAILED",
|
|
2680
|
-
"PREPARATION_FAILED",
|
|
2681
|
-
"UPLOAD_FAILED",
|
|
2682
|
-
"WORKER_UNAVAILABLE",
|
|
2683
|
-
"CANCELLED",
|
|
2684
|
-
"EXPIRED",
|
|
2685
|
-
"INTERNAL"
|
|
2686
|
-
];
|
|
2687
|
-
const RENDER_WARNING_CODES = [
|
|
2688
|
-
"ASSET_UNAVAILABLE",
|
|
2689
|
-
"FONT_FALLBACK",
|
|
2690
|
-
"LOCAL_FONT_FALLBACK",
|
|
2691
|
-
"SOURCE_FALLBACK",
|
|
2692
|
-
"SCALE_REDUCED",
|
|
2693
|
-
"LAYOUT_FALLBACK",
|
|
2694
|
-
"DRAWN_APPROXIMATELY"
|
|
2695
|
-
];
|
|
2696
|
-
|
|
2697
|
-
//#endregion
|
|
2698
|
-
//#region ../../packages/contract/src/canvas/canvas-render.schema.ts
|
|
2699
|
-
const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
|
|
2700
|
-
const canvasRenderPixelLimitSchema = z.number().int().positive();
|
|
2701
|
-
const canvasWorldBoundsSchema = z.object({
|
|
2702
|
-
x: z.number(),
|
|
2703
|
-
y: z.number(),
|
|
2704
|
-
width: z.number().positive(),
|
|
2705
|
-
height: z.number().positive()
|
|
2706
|
-
});
|
|
2707
|
-
const canvasRenderTargetSchema = z.discriminatedUnion("kind", [
|
|
2708
|
-
z.object({ kind: z.literal("content") }),
|
|
2709
|
-
z.object({
|
|
2710
|
-
kind: z.literal("page"),
|
|
2711
|
-
pageId: z.string().min(1)
|
|
2712
|
-
}),
|
|
2713
|
-
z.object({
|
|
2714
|
-
kind: z.literal("node"),
|
|
2715
|
-
nodeId: z.string().min(1)
|
|
2716
|
-
}),
|
|
2717
|
-
z.object({
|
|
2718
|
-
kind: z.literal("bounds"),
|
|
2719
|
-
bounds: canvasWorldBoundsSchema
|
|
2720
|
-
})
|
|
2721
|
-
]);
|
|
2722
|
-
const canvasRenderSourceStateSchema = z.object({
|
|
2723
|
-
kind: z.literal("recording"),
|
|
2724
|
-
recordingId: z.uuid(),
|
|
2725
|
-
atMs: z.number().int().nonnegative()
|
|
2726
|
-
});
|
|
2727
|
-
const canvasRenderSourceStateEvidenceSchema = z.object({
|
|
2728
|
-
kind: z.literal("recording"),
|
|
2729
|
-
recordingId: z.uuid(),
|
|
2730
|
-
requestedAtMs: z.number().int().nonnegative(),
|
|
2731
|
-
settledAtMs: z.number().int().nonnegative()
|
|
2732
|
-
});
|
|
2733
|
-
const canvasRenderSnapshotResultSchema = z.object({
|
|
2734
|
-
recordingId: z.uuid(),
|
|
2735
|
-
atMs: z.number().int().nonnegative(),
|
|
2736
|
-
screenId: z.uuid(),
|
|
2737
|
-
/** Null when the snapshot asked for a place only, so no screen layer was added. */
|
|
2738
|
-
screenNodeId: z.string().min(1).nullable(),
|
|
2739
|
-
/** The page the place is on. */
|
|
2740
|
-
pageId: z.string().min(1).optional(),
|
|
2741
|
-
viewport: z.object({
|
|
2742
|
-
width: z.number().int().positive(),
|
|
2743
|
-
height: z.number().int().positive()
|
|
2744
|
-
}),
|
|
2745
|
-
box: canvasWorldBoundsSchema,
|
|
2746
|
-
version: z.number().int().positive(),
|
|
2747
|
-
alreadyPresent: z.boolean()
|
|
2748
|
-
});
|
|
2749
|
-
const createCanvasRenderInputSchema = z.object({
|
|
2750
|
-
canvasId: z.uuid(),
|
|
2751
|
-
expectedVersion: z.number().int().positive().optional(),
|
|
2752
|
-
scope: z.strictObject({
|
|
2753
|
-
pageId: z.string().min(1).optional(),
|
|
2754
|
-
nodeIds: z.array(z.string().min(1))
|
|
2755
|
-
}).optional(),
|
|
2756
|
-
target: canvasRenderTargetSchema.default({ kind: "content" }),
|
|
2757
|
-
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2758
|
-
scale: z.number().positive().default(1),
|
|
2759
|
-
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2760
|
-
format: z.literal("png").default("png")
|
|
2761
|
-
}).refine((input) => input.sourceState === void 0 || input.target.kind === "node", {
|
|
2762
|
-
message: "a source state requires a node render target",
|
|
2763
|
-
path: ["sourceState"]
|
|
2764
|
-
});
|
|
2765
|
-
const canvasRenderPhaseSchema = z.enum(RENDER_PHASES);
|
|
2766
|
-
const canvasRenderStateSchema = z.enum(RENDER_STATES);
|
|
2767
|
-
const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
|
|
2768
|
-
const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
|
|
2769
|
-
const canvasRenderWarningSchema = z.object({
|
|
2770
|
-
code: canvasRenderWarningCodeSchema,
|
|
2771
|
-
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
2772
|
-
sourceId: z.string().min(1).nullable()
|
|
2773
|
-
});
|
|
2774
|
-
const canvasRenderFailureSchema = z.object({
|
|
2775
|
-
reason: canvasRenderFailureReasonSchema,
|
|
2776
|
-
phase: canvasRenderPhaseSchema,
|
|
2777
|
-
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
2778
|
-
retryable: z.boolean(),
|
|
2779
|
-
sourceId: z.string().min(1).nullable()
|
|
2780
|
-
});
|
|
2781
|
-
const canvasRenderTimingSchema = z.object({
|
|
2782
|
-
phase: canvasRenderPhaseSchema,
|
|
2783
|
-
durationMs: z.number().int().min(0)
|
|
2784
|
-
});
|
|
2785
|
-
const canvasRenderResultSchema = z.object({
|
|
2786
|
-
canvasId: z.uuid(),
|
|
2787
|
-
requestedVersion: z.number().int().positive(),
|
|
2788
|
-
loadedVersion: z.number().int().positive(),
|
|
2789
|
-
target: canvasRenderTargetSchema,
|
|
2790
|
-
sourceState: canvasRenderSourceStateEvidenceSchema.optional(),
|
|
2791
|
-
snapshot: canvasRenderSnapshotResultSchema.optional(),
|
|
2792
|
-
bounds: canvasWorldBoundsSchema,
|
|
2793
|
-
width: z.number().int().positive(),
|
|
2794
|
-
height: z.number().int().positive(),
|
|
2795
|
-
scale: z.number().positive(),
|
|
2796
|
-
contentType: z.literal("image/png"),
|
|
2797
|
-
bytes: z.number().int().positive(),
|
|
2798
|
-
warnings: z.array(canvasRenderWarningSchema),
|
|
2799
|
-
timings: z.array(canvasRenderTimingSchema),
|
|
2800
|
-
expiresAt: z.iso.datetime()
|
|
2801
|
-
});
|
|
2802
|
-
const canvasRenderJobBaseSchema = z.object({
|
|
2803
|
-
id: z.uuid(),
|
|
2804
|
-
canvasId: z.uuid(),
|
|
2805
|
-
purpose: z.enum([
|
|
2806
|
-
"inspection",
|
|
2807
|
-
"snapshot",
|
|
2808
|
-
"thumbnail",
|
|
2809
|
-
"export"
|
|
2810
|
-
]),
|
|
2811
|
-
phase: canvasRenderPhaseSchema,
|
|
2812
|
-
requestedVersion: z.number().int().positive(),
|
|
2813
|
-
target: canvasRenderTargetSchema,
|
|
2814
|
-
sourceState: canvasRenderSourceStateSchema.optional(),
|
|
2815
|
-
scale: z.number().positive(),
|
|
2816
|
-
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
2817
|
-
format: z.literal("png"),
|
|
2818
|
-
attempt: z.number().int().min(0),
|
|
2819
|
-
lastFailure: canvasRenderFailureSchema.optional(),
|
|
2820
|
-
createdAt: z.iso.datetime(),
|
|
2821
|
-
updatedAt: z.iso.datetime()
|
|
2822
|
-
});
|
|
2823
|
-
const canvasRenderJobSchema = z.discriminatedUnion("state", [
|
|
2824
|
-
canvasRenderJobBaseSchema.extend({
|
|
2825
|
-
state: z.literal("queued"),
|
|
2826
|
-
result: z.null(),
|
|
2827
|
-
failure: z.null()
|
|
2828
|
-
}),
|
|
2829
|
-
canvasRenderJobBaseSchema.extend({
|
|
2830
|
-
state: z.literal("running"),
|
|
2831
|
-
result: z.null(),
|
|
2832
|
-
failure: z.null()
|
|
2833
|
-
}),
|
|
2834
|
-
canvasRenderJobBaseSchema.extend({
|
|
2835
|
-
state: z.literal("succeeded"),
|
|
2836
|
-
phase: z.literal("complete"),
|
|
2837
|
-
result: canvasRenderResultSchema,
|
|
2838
|
-
failure: z.null()
|
|
2839
|
-
}),
|
|
2840
|
-
canvasRenderJobBaseSchema.extend({
|
|
2841
|
-
state: z.literal("failed"),
|
|
2842
|
-
result: z.null(),
|
|
2843
|
-
failure: canvasRenderFailureSchema
|
|
2844
|
-
}),
|
|
2845
|
-
canvasRenderJobBaseSchema.extend({
|
|
2846
|
-
state: z.literal("cancelled"),
|
|
2847
|
-
result: z.null(),
|
|
2848
|
-
failure: canvasRenderFailureSchema.extend({ reason: z.literal("CANCELLED") })
|
|
2849
|
-
}),
|
|
2850
|
-
canvasRenderJobBaseSchema.extend({
|
|
2851
|
-
state: z.literal("expired"),
|
|
2852
|
-
result: z.null(),
|
|
2853
|
-
failure: canvasRenderFailureSchema.extend({ reason: z.literal("EXPIRED") })
|
|
2854
|
-
})
|
|
2855
|
-
]);
|
|
2856
|
-
const createCanvasRenderOutputSchema = z.object({
|
|
2857
|
-
job: canvasRenderJobSchema,
|
|
2858
|
-
alreadyExists: z.boolean()
|
|
2859
|
-
});
|
|
2860
|
-
const getCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2861
|
-
/** The longest an export read waits on the server for the job to settle. */
|
|
2862
|
-
const CANVAS_EXPORT_LONGEST_WAIT_MS = 1e4;
|
|
2863
|
-
const getCanvasExportInputSchema = getCanvasRenderInputSchema.extend({ waitMs: z.number().int().min(0).max(CANVAS_EXPORT_LONGEST_WAIT_MS).optional() });
|
|
2864
|
-
const getCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
2865
|
-
const cancelCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2866
|
-
const cancelCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
2867
|
-
const canvasRenderSourceSchema = z.discriminatedUnion("status", [z.object({
|
|
2868
|
-
status: z.literal("available"),
|
|
2869
|
-
version: z.number().int().positive(),
|
|
2870
|
-
format: z.literal("enhance-scene-json"),
|
|
2871
|
-
code: z.string(),
|
|
2872
|
-
prototypes: z.array(z.object({
|
|
2873
|
-
nodeId: z.string(),
|
|
2874
|
-
prototypeId: z.uuid(),
|
|
2875
|
-
deploymentId: z.uuid(),
|
|
2876
|
-
capability: z.literal("canvas.read"),
|
|
2877
|
-
canvasPath: z.string(),
|
|
2878
|
-
input: z.object({
|
|
2879
|
-
canvasRef: z.uuid(),
|
|
2880
|
-
view: z.literal("source"),
|
|
2881
|
-
nodeId: z.string()
|
|
2882
|
-
}),
|
|
2883
|
-
guidance: z.string()
|
|
2884
|
-
})),
|
|
2885
|
-
guidance: z.string()
|
|
2886
|
-
}), z.object({
|
|
2887
|
-
status: z.literal("unavailable"),
|
|
2888
|
-
guidance: z.string()
|
|
2889
|
-
})]);
|
|
2890
|
-
/** A person's image export of one layer at the saved revision, drawn by the render worker. */
|
|
2891
|
-
const createCanvasExportInputSchema = z.object({
|
|
2892
|
-
canvasId: z.uuid(),
|
|
2893
|
-
nodeId: z.string().min(1),
|
|
2894
|
-
expectedVersion: z.number().int().positive(),
|
|
2895
|
-
scale: z.number().positive()
|
|
2896
|
-
});
|
|
2897
|
-
const downloadCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2898
|
-
const downloadCanvasRenderOutputSchema = z.object({
|
|
2899
|
-
jobId: z.uuid(),
|
|
2900
|
-
download: signedDownloadSchema,
|
|
2901
|
-
source: canvasRenderSourceSchema.optional()
|
|
2902
|
-
});
|
|
2903
|
-
const canvasSnapshotRequestSchema = z.strictObject({
|
|
2904
|
-
previewJobId: z.uuid(),
|
|
2905
|
-
scope: z.strictObject({
|
|
2906
|
-
pageId: z.string().min(1).optional(),
|
|
2907
|
-
nodeIds: z.array(z.string().min(1))
|
|
2908
|
-
}),
|
|
2909
|
-
/**
|
|
2910
|
-
* Below the walkthrough: as a screen layer, which installed CLIs ask for, or as a place only,
|
|
2911
|
-
* where the agent's CLI lands an editable frame.
|
|
2912
|
-
*/
|
|
2913
|
-
placement: z.strictObject({ kind: z.enum(["below-source", "editable-below-source"]) })
|
|
2914
|
-
});
|
|
2915
|
-
const createRecordingSnapshotInputSchema = z.object({
|
|
2916
|
-
canvasId: z.uuid(),
|
|
2917
|
-
recordingId: z.uuid(),
|
|
2918
|
-
atMs: z.number().int().nonnegative(),
|
|
2919
|
-
context: z.strictObject({
|
|
2920
|
-
expectedVersion: z.number().int().positive(),
|
|
2921
|
-
request: canvasSnapshotRequestSchema
|
|
2922
|
-
}).optional()
|
|
2923
|
-
});
|
|
2924
|
-
const createRecordingSnapshotOutputSchema = z.object({
|
|
2925
|
-
job: canvasRenderJobSchema,
|
|
2926
|
-
alreadyExists: z.boolean()
|
|
2274
|
+
const createRecordingSnapshotOutputSchema = z.object({
|
|
2275
|
+
job: canvasRenderJobSchema,
|
|
2276
|
+
alreadyExists: z.boolean()
|
|
2927
2277
|
});
|
|
2928
2278
|
|
|
2929
2279
|
//#endregion
|
|
@@ -2933,11 +2283,20 @@ const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) })
|
|
|
2933
2283
|
//#endregion
|
|
2934
2284
|
//#region ../../packages/contract/src/canvas/canvas-conversion.schema.ts
|
|
2935
2285
|
const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
|
|
2936
|
-
z.object({
|
|
2286
|
+
z.object({
|
|
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()
|
|
2293
|
+
}),
|
|
2937
2294
|
z.object({
|
|
2938
2295
|
kind: z.literal("insert-children"),
|
|
2939
2296
|
pageId: z.string().min(1).optional(),
|
|
2940
|
-
targetNodeId: z.string().min(1)
|
|
2297
|
+
targetNodeId: z.string().min(1),
|
|
2298
|
+
/** World placement for a new top-level screen. Absent, the authored position stands. */
|
|
2299
|
+
placement: canvasPlacementIntentSchema.optional()
|
|
2941
2300
|
}),
|
|
2942
2301
|
z.object({
|
|
2943
2302
|
kind: z.literal("replace"),
|
|
@@ -3052,7 +2411,9 @@ const conversionRouteStateSchema = z.discriminatedUnion("state", [
|
|
|
3052
2411
|
state: z.literal("ready"),
|
|
3053
2412
|
jobId: z.uuid(),
|
|
3054
2413
|
loadedVersion: z.number().int().positive(),
|
|
3055
|
-
draft: canvasSubtreeDraftSchema
|
|
2414
|
+
draft: canvasSubtreeDraftSchema,
|
|
2415
|
+
/** Where measured placement put the draft's root, when the request asked for it. */
|
|
2416
|
+
placement: canvasSceneBoxSchema.optional()
|
|
3056
2417
|
}),
|
|
3057
2418
|
z.object({
|
|
3058
2419
|
state: z.literal("failed"),
|
|
@@ -3438,9 +2799,75 @@ const canvasEditTextOperationSchema = z.object({
|
|
|
3438
2799
|
});
|
|
3439
2800
|
|
|
3440
2801
|
//#endregion
|
|
3441
|
-
//#region ../../packages/contract/src/canvas/text-style
|
|
3442
|
-
const MAX_DESCRIPTION = 2e3;
|
|
3443
|
-
const
|
|
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
|
+
|
|
2867
|
+
//#endregion
|
|
2868
|
+
//#region ../../packages/contract/src/canvas/text-style-library.schema.ts
|
|
2869
|
+
const MAX_DESCRIPTION = 2e3;
|
|
2870
|
+
const MAX_TITLE = 200;
|
|
3444
2871
|
const MAX_PAGE = 50;
|
|
3445
2872
|
const DEFAULT_PAGE = 20;
|
|
3446
2873
|
const enabledTextStyleLibrarySchema = z.object({ title: z.string().trim().min(1).max(MAX_TITLE) }).strict();
|
|
@@ -3706,6 +3133,932 @@ const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
|
|
|
3706
3133
|
next: z.array(z.string().min(1))
|
|
3707
3134
|
});
|
|
3708
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
|
+
|
|
3709
4062
|
//#endregion
|
|
3710
4063
|
//#region ../../packages/contract/src/canvas/canvas-document.schema.ts
|
|
3711
4064
|
/** Reads retain unsupported documents; the write boundary validates the current scene format. */
|
|
@@ -3973,98 +4326,6 @@ const textLinksOf = (node) => {
|
|
|
3973
4326
|
return nonOverlapping;
|
|
3974
4327
|
};
|
|
3975
4328
|
|
|
3976
|
-
//#endregion
|
|
3977
|
-
//#region ../../packages/contract/src/canvas/canvas-property-section.schema.ts
|
|
3978
|
-
const CANVAS_PROPERTY_SECTIONS = [
|
|
3979
|
-
"position",
|
|
3980
|
-
"layout",
|
|
3981
|
-
"clip",
|
|
3982
|
-
"cornerRadius",
|
|
3983
|
-
"blending",
|
|
3984
|
-
"typography",
|
|
3985
|
-
"nativeControl",
|
|
3986
|
-
"textDecoration",
|
|
3987
|
-
"fill",
|
|
3988
|
-
"outline",
|
|
3989
|
-
"textStroke",
|
|
3990
|
-
"border",
|
|
3991
|
-
"outerShadow",
|
|
3992
|
-
"innerShadow",
|
|
3993
|
-
"filters",
|
|
3994
|
-
"additionalStyles",
|
|
3995
|
-
"vector",
|
|
3996
|
-
"export",
|
|
3997
|
-
"source"
|
|
3998
|
-
];
|
|
3999
|
-
const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
|
|
4000
|
-
|
|
4001
|
-
//#endregion
|
|
4002
|
-
//#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
|
|
4003
|
-
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
4004
|
-
const MAX_RENDER_KIND_LENGTH = 100;
|
|
4005
|
-
/**
|
|
4006
|
-
* What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
|
|
4007
|
-
* it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
|
|
4008
|
-
* was made, for a layer the browser lays out.
|
|
4009
|
-
*/
|
|
4010
|
-
const canvasBoxSourceSchema = z.enum([
|
|
4011
|
-
"placed",
|
|
4012
|
-
"placed-before-transform",
|
|
4013
|
-
"recorded"
|
|
4014
|
-
]);
|
|
4015
|
-
/** Present only on a read that holds a `recorded` box. */
|
|
4016
|
-
const boxNoteSchema = z.string().min(1).optional();
|
|
4017
|
-
const canvasInspectNodeSummarySchema = z.object({
|
|
4018
|
-
id: z.string().min(1),
|
|
4019
|
-
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
4020
|
-
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
4021
|
-
parentId: z.string().min(1).nullable(),
|
|
4022
|
-
childCount: z.number().int().min(0),
|
|
4023
|
-
box: canvasSceneBoxSchema.nullable(),
|
|
4024
|
-
boxSource: canvasBoxSourceSchema.optional(),
|
|
4025
|
-
propertySections: z.array(canvasPropertySectionSchema)
|
|
4026
|
-
});
|
|
4027
|
-
const inspectCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
4028
|
-
const inspectCanvasOutputSchema = z.object({
|
|
4029
|
-
canvasId: z.uuid(),
|
|
4030
|
-
openUrl: z.url(),
|
|
4031
|
-
title: z.string().min(1),
|
|
4032
|
-
version: z.number().int().positive(),
|
|
4033
|
-
nodeCount: z.number().int().min(0),
|
|
4034
|
-
rootChildCount: z.number().int().min(0),
|
|
4035
|
-
bounds: canvasSceneBoxSchema.nullable(),
|
|
4036
|
-
kinds: z.record(z.string(), z.number().int().min(0)),
|
|
4037
|
-
boxNote: boxNoteSchema,
|
|
4038
|
-
next: z.array(z.string().min(1))
|
|
4039
|
-
});
|
|
4040
|
-
const inspectCanvasTreeInputSchema = z.object({ canvasId: z.uuid() });
|
|
4041
|
-
const inspectCanvasTreeOutputSchema = z.object({
|
|
4042
|
-
canvasId: z.uuid(),
|
|
4043
|
-
version: z.number().int().positive(),
|
|
4044
|
-
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
4045
|
-
boxNote: boxNoteSchema
|
|
4046
|
-
});
|
|
4047
|
-
const inspectCanvasNodeInputSchema = z.object({
|
|
4048
|
-
canvasId: z.uuid(),
|
|
4049
|
-
nodeId: z.string().min(1)
|
|
4050
|
-
});
|
|
4051
|
-
const inspectCanvasNodeOutputSchema = z.object({
|
|
4052
|
-
canvasId: z.uuid(),
|
|
4053
|
-
version: z.number().int().positive(),
|
|
4054
|
-
node: canvasInspectNodeSummarySchema.extend({
|
|
4055
|
-
styles: z.record(z.string(), z.union([z.string(), z.number()])),
|
|
4056
|
-
layout: canvasNodeLayoutSchema.optional(),
|
|
4057
|
-
appearance: canvasAppearanceValuesSchema.optional(),
|
|
4058
|
-
geometry: canvasGeometrySchema.optional(),
|
|
4059
|
-
typography: canvasAuthoredTypographySchema.optional(),
|
|
4060
|
-
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
4061
|
-
props: z.record(z.string(), z.unknown()),
|
|
4062
|
-
children: z.array(z.string().min(1))
|
|
4063
|
-
}),
|
|
4064
|
-
boxNote: boxNoteSchema,
|
|
4065
|
-
next: z.array(z.string().min(1))
|
|
4066
|
-
});
|
|
4067
|
-
|
|
4068
4329
|
//#endregion
|
|
4069
4330
|
//#region ../../packages/contract/src/canvas/canvas-layout-ownership.lib.ts
|
|
4070
4331
|
const CANVAS_LAYOUT_CSS_FIELDS = [
|
|
@@ -4174,99 +4435,6 @@ const canvasLayoutWithoutCssProperties = (held, changed, axes) => {
|
|
|
4174
4435
|
return layout;
|
|
4175
4436
|
};
|
|
4176
4437
|
|
|
4177
|
-
//#endregion
|
|
4178
|
-
//#region ../../packages/contract/src/canvas/canvas-operation-writes.schema.ts
|
|
4179
|
-
/**
|
|
4180
|
-
* What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
|
|
4181
|
-
* values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
|
|
4182
|
-
* group of values, which a client that read the canvas in an older format may have stripped.
|
|
4183
|
-
*/
|
|
4184
|
-
const CANVAS_OPERATION_WRITES = {
|
|
4185
|
-
insertConvertedSubtree: "whole",
|
|
4186
|
-
insertNode: "whole",
|
|
4187
|
-
insertText: "names",
|
|
4188
|
-
insertPrototype: "names",
|
|
4189
|
-
setPrototypeDeployment: "names",
|
|
4190
|
-
editText: "names",
|
|
4191
|
-
setText: "names",
|
|
4192
|
-
setBox: "names",
|
|
4193
|
-
setLabel: "names",
|
|
4194
|
-
setContainerKind: "names",
|
|
4195
|
-
setVisibility: "names",
|
|
4196
|
-
setLocked: "names",
|
|
4197
|
-
setConstraints: "names",
|
|
4198
|
-
setStyles: "names",
|
|
4199
|
-
patchExportSettings: "names",
|
|
4200
|
-
setAppearance: "names",
|
|
4201
|
-
setLayout: "whole",
|
|
4202
|
-
patchTypography: "names",
|
|
4203
|
-
setTypography: "whole",
|
|
4204
|
-
patchAdditionalStyles: "names",
|
|
4205
|
-
setAdditionalStyles: "whole",
|
|
4206
|
-
setArtworkColor: "whole",
|
|
4207
|
-
setTextStyleLibrary: "whole",
|
|
4208
|
-
patchFontLibrary: "names",
|
|
4209
|
-
setTextStyle: "whole",
|
|
4210
|
-
setGeometry: "whole",
|
|
4211
|
-
setProps: "whole",
|
|
4212
|
-
setParentage: "names",
|
|
4213
|
-
move: "names",
|
|
4214
|
-
remove: "names"
|
|
4215
|
-
};
|
|
4216
|
-
|
|
4217
|
-
//#endregion
|
|
4218
|
-
//#region ../../packages/contract/src/canvas/canvas-mutation.schema.ts
|
|
4219
|
-
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
4220
|
-
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
4221
|
-
width: z.number().positive(),
|
|
4222
|
-
height: z.number().positive()
|
|
4223
|
-
});
|
|
4224
|
-
const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
|
|
4225
|
-
/** A receipt stored before boxes said what they are holds none, so the source stays optional. */
|
|
4226
|
-
const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
|
|
4227
|
-
const canvasMutationRequestContextSchema = z.strictObject({
|
|
4228
|
-
fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
4229
|
-
revisionPolicy: z.enum(["strict", "rebase"]),
|
|
4230
|
-
copiedNodeIds: copiedNodeIdsSchema.optional()
|
|
4231
|
-
});
|
|
4232
|
-
/** The request's fields alone, for callers that derive their own input from it. */
|
|
4233
|
-
const applyCanvasOperationsFieldsSchema = z.object({
|
|
4234
|
-
canvasId: z.uuid(),
|
|
4235
|
-
mutationId: z.uuid(),
|
|
4236
|
-
documentFormatVersion: canvasDocumentFormatSchema,
|
|
4237
|
-
baseVersion: z.number().int().positive(),
|
|
4238
|
-
operations: z.array(canvasOperationSchema).min(1),
|
|
4239
|
-
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
4240
|
-
writeScope: canvasWriteScopeSchema.optional()
|
|
4241
|
-
});
|
|
4242
|
-
const applyCanvasOperationsInputSchema = applyCanvasOperationsFieldsSchema.superRefine((input, context) => {
|
|
4243
|
-
refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
|
|
4244
|
-
});
|
|
4245
|
-
const applyCanvasOperationsOutputSchema = z.object({
|
|
4246
|
-
canvasId: z.uuid(),
|
|
4247
|
-
mutationId: z.uuid(),
|
|
4248
|
-
previousVersion: z.number().int().positive(),
|
|
4249
|
-
version: z.number().int().positive(),
|
|
4250
|
-
operations: z.array(canvasOperationSchema),
|
|
4251
|
-
insertedNodeIds: z.array(nodeIdSchema$2),
|
|
4252
|
-
changedNodeIds: z.array(nodeIdSchema$2),
|
|
4253
|
-
removedNodeIds: z.array(nodeIdSchema$2),
|
|
4254
|
-
boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
4255
|
-
affectedBounds: writableBoxSchema.nullable(),
|
|
4256
|
-
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
4257
|
-
next: z.array(z.string().min(1))
|
|
4258
|
-
});
|
|
4259
|
-
const getCanvasMutationInputSchema = z.strictObject({
|
|
4260
|
-
canvasId: z.uuid(),
|
|
4261
|
-
mutationId: z.uuid(),
|
|
4262
|
-
fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
|
|
4263
|
-
});
|
|
4264
|
-
const getCanvasMutationOutputSchema = z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
|
|
4265
|
-
state: z.literal("committed"),
|
|
4266
|
-
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
4267
|
-
result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
|
|
4268
|
-
})]);
|
|
4269
|
-
|
|
4270
4438
|
//#endregion
|
|
4271
4439
|
//#region ../../packages/contract/src/canvas/canvas-mutation-review.schema.ts
|
|
4272
4440
|
const LIMITS = {
|
|
@@ -4665,7 +4833,9 @@ const canvasDuplicatePreparationSchema = z.strictObject({
|
|
|
4665
4833
|
destination: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("native") }), z.strictObject({
|
|
4666
4834
|
kind: z.literal("inside"),
|
|
4667
4835
|
parentId: nodeId$5
|
|
4668
|
-
})])
|
|
4836
|
+
})]),
|
|
4837
|
+
/** World placement for a set of top-level copies. Absent, the native copy offset stands. */
|
|
4838
|
+
placement: canvasPlacementIntentSchema.optional()
|
|
4669
4839
|
});
|
|
4670
4840
|
const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
|
|
4671
4841
|
z.strictObject({
|
|
@@ -5416,6 +5586,10 @@ const claimRenderWorkOutputSchema = z.discriminatedUnion("purpose", [
|
|
|
5416
5586
|
outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
|
|
5417
5587
|
})
|
|
5418
5588
|
]);
|
|
5589
|
+
const snapshotPlacementSchema = z.object({
|
|
5590
|
+
x: z.number(),
|
|
5591
|
+
y: z.number()
|
|
5592
|
+
});
|
|
5419
5593
|
const completeRenderWorkInputSchema = z.object({
|
|
5420
5594
|
jobId: z.uuid(),
|
|
5421
5595
|
loadedVersion: z.number().int().positive(),
|
|
@@ -5436,14 +5610,18 @@ const completeRenderWorkInputSchema = z.object({
|
|
|
5436
5610
|
viewport: z.object({
|
|
5437
5611
|
width: z.number().int().positive(),
|
|
5438
5612
|
height: z.number().int().positive()
|
|
5439
|
-
})
|
|
5613
|
+
}),
|
|
5614
|
+
/** Where the page's search put the captured screen, at `loadedVersion`. */
|
|
5615
|
+
placement: snapshotPlacementSchema.optional()
|
|
5440
5616
|
}).optional()
|
|
5441
5617
|
});
|
|
5442
5618
|
const completeRenderWorkOutputSchema = z.object({ accepted: z.literal(true) });
|
|
5443
5619
|
const completeConversionWorkInputSchema = z.object({
|
|
5444
5620
|
jobId: z.uuid(),
|
|
5445
5621
|
loadedVersion: z.number().int().positive(),
|
|
5446
|
-
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()
|
|
5447
5625
|
});
|
|
5448
5626
|
const completeConversionWorkOutputSchema = z.object({ accepted: z.literal(true) });
|
|
5449
5627
|
const renderRouteSnapshotSchema = z.object({
|
|
@@ -5456,7 +5634,9 @@ const renderRouteSnapshotSchema = z.object({
|
|
|
5456
5634
|
viewport: z.object({
|
|
5457
5635
|
width: z.number().int().positive(),
|
|
5458
5636
|
height: z.number().int().positive()
|
|
5459
|
-
})
|
|
5637
|
+
}),
|
|
5638
|
+
/** Where the editor's search for a capture below this recording puts the screen. */
|
|
5639
|
+
placement: snapshotPlacementSchema.optional()
|
|
5460
5640
|
});
|
|
5461
5641
|
const failRenderWorkInputSchema = z.object({
|
|
5462
5642
|
jobId: z.uuid(),
|
|
@@ -7583,7 +7763,11 @@ const desktopRequestSchema = z.object({
|
|
|
7583
7763
|
const desktopMutationIntentSchema = z.object({
|
|
7584
7764
|
mutationId: id$2,
|
|
7585
7765
|
canvasId: id$2,
|
|
7586
|
-
procedure: z.enum([
|
|
7766
|
+
procedure: z.enum([
|
|
7767
|
+
"canvas.applyOperations",
|
|
7768
|
+
"canvas.render.importSource",
|
|
7769
|
+
"canvas.applyEdits"
|
|
7770
|
+
]),
|
|
7587
7771
|
input: z.record(z.string(), z.unknown()),
|
|
7588
7772
|
state: z.enum([
|
|
7589
7773
|
"recorded",
|
|
@@ -8235,7 +8419,9 @@ const createAgentTokenOutputSchema = z.object({
|
|
|
8235
8419
|
const listAgentTokensInputSchema = z.object({});
|
|
8236
8420
|
const listAgentTokensOutputSchema = z.object({
|
|
8237
8421
|
items: z.array(agentTokenSchema),
|
|
8238
|
-
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()
|
|
8239
8425
|
});
|
|
8240
8426
|
const revokeAgentTokenInputSchema = z.object({ tokenId: z.uuid() });
|
|
8241
8427
|
const revokeAgentTokenOutputSchema = z.object({
|
|
@@ -8254,6 +8440,49 @@ const cliAuthConfigurationSchema = z.discriminatedUnion("method", [z.object({ me
|
|
|
8254
8440
|
scope: z.literal(CLI_AUTH_SCOPE)
|
|
8255
8441
|
})]);
|
|
8256
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
|
+
|
|
8257
8486
|
//#endregion
|
|
8258
8487
|
//#region ../../packages/contract/src/person/person.schema.ts
|
|
8259
8488
|
const personSchema = z.object({
|
|
@@ -10558,7 +10787,9 @@ const listHeading = ({ two }) => two({
|
|
|
10558
10787
|
/**
|
|
10559
10788
|
* Each skill states its goal and names what the surface offers for it; the commands' own help
|
|
10560
10789
|
* and the tools' own descriptions teach the rest. A line is added only when measured runs are
|
|
10561
|
-
* worse without it; `skill-evaluation` holds the cases and what the last runs found.
|
|
10790
|
+
* worse without it; `skill-evaluation` holds the cases and what the last runs found. The design
|
|
10791
|
+
* skill's small-edit line and its two sections on the look of a screen were added without runs,
|
|
10792
|
+
* and the record marks each as not measured.
|
|
10562
10793
|
*/
|
|
10563
10794
|
const SKILLS = {
|
|
10564
10795
|
capture: {
|
|
@@ -10599,9 +10830,35 @@ ${listHeading(words)}
|
|
|
10599
10830
|
})} makes a canvas and answers with its id and its link.
|
|
10600
10831
|
- ${learn("canvas.read", "read what a canvas holds: its outline, or one screen as HTML")}
|
|
10601
10832
|
- ${learn("canvas.insertHtml", "add a screen as HTML, with an example")} Read it before the first insert.
|
|
10602
|
-
-
|
|
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"}\`.
|
|
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.
|
|
10835
|
+
- ${learn("canvas.updateHtml", "rebuild the inside of a layer")} Use it only when the structure itself changes.
|
|
10603
10836
|
- ${learn("canvas.importAsset", "bring in an image or a font")}
|
|
10604
10837
|
- ${learn("canvas.render", "get a picture of a screen")}
|
|
10838
|
+
|
|
10839
|
+
## Decide the look before the markup
|
|
10840
|
+
|
|
10841
|
+
A change to an existing screen keeps that screen's look. A new screen on a canvas that holds a product's screens takes their fonts, sizes, colours, spacing and corner radii. With no product to follow:
|
|
10842
|
+
|
|
10843
|
+
- White background, near-black text and one accent colour, used for the main action and little else, unless the brief asks otherwise.
|
|
10844
|
+
- Three type sizes, far apart: one large, one body, one small. No text under 13px, and body text at 4.5:1 contrast or more.
|
|
10845
|
+
- Make the thing that matters most much bigger than the rest. A page of equal cards has no first read.
|
|
10846
|
+
- Put content straight on the page and separate it with space: tight inside a group, generous between groups. Add a card, border or shadow only to show grouping or something clickable.
|
|
10847
|
+
- Real words and numbers of realistic length. SVG for icons, not emoji.
|
|
10848
|
+
- In repeated rows, give icons, values and trailing actions a fixed width, and keep the slot when a row has nothing in it.
|
|
10849
|
+
- Asked for several directions, change the layout or the idea, not only the accent colour, and keep the content the same.
|
|
10850
|
+
|
|
10851
|
+
## Look at what you made
|
|
10852
|
+
|
|
10853
|
+
After each screen, and after any change a person would notice, get a picture and check, in this order:
|
|
10854
|
+
|
|
10855
|
+
1. Is everything that was asked for there, and readable?
|
|
10856
|
+
2. Is anything cut off or overflowing its frame? Fix the frame's size or the content's wrapping; do not shrink the text.
|
|
10857
|
+
3. Do repeated rows line up down the page?
|
|
10858
|
+
4. Is the first thing you notice the thing that matters most?
|
|
10859
|
+
5. Is spacing even where it should be even?
|
|
10860
|
+
|
|
10861
|
+
Fix what you see with ${call("canvas.edit")}, not by rebuilding the screen, then look again.
|
|
10605
10862
|
`;
|
|
10606
10863
|
}
|
|
10607
10864
|
},
|
|
@@ -10676,6 +10933,27 @@ const skillTextsFor = (wording) => SKILL_NAMES.map((skill) => {
|
|
|
10676
10933
|
/** The job each skill is for, in the order of the skills, for a sentence that lists them. */
|
|
10677
10934
|
const SKILL_JOBS = SKILL_NAMES.map((skill) => SKILLS[skill].job);
|
|
10678
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
|
+
|
|
10679
10957
|
//#endregion
|
|
10680
10958
|
//#region src/infrastructure/mcp-tool-names.consts.ts
|
|
10681
10959
|
/** The tool a hosted assistant calls for each capability that has one of its own. */
|
|
@@ -10745,16 +11023,8 @@ const callOf = (capability, given) => inSurfaceWords({
|
|
|
10745
11023
|
cli: `enhance ${cliPathOf(capability)} ${given.cli}`,
|
|
10746
11024
|
mcp: `${toolOf(capability)} with ${JSON.stringify(given.mcp)}`
|
|
10747
11025
|
});
|
|
10748
|
-
/** Where a layer's current id is read: the tool's tree command, or an assistant's own read. */
|
|
10749
|
-
const layerListName = () => inSurfaceWords({
|
|
10750
|
-
cli: "canvas tree",
|
|
10751
|
-
mcp: "a new read of the canvas"
|
|
10752
|
-
});
|
|
10753
11026
|
/** The step that finds layer ids that still exist. */
|
|
10754
|
-
const currentNodeIdStep = (ids = "a current stable node id") =>
|
|
10755
|
-
cli: `Run canvas tree and use ${ids}.`,
|
|
10756
|
-
mcp: `Read the canvas again and use ${ids}.`
|
|
10757
|
-
});
|
|
11027
|
+
const currentNodeIdStep = (ids = "a current stable node id") => CANVAS_EDIT_WORDS[callingSurface()].currentIds(ids);
|
|
10758
11028
|
|
|
10759
11029
|
//#endregion
|
|
10760
11030
|
//#region src/application/stored-canvas-scene.use-case.ts
|
|
@@ -10772,6 +11042,20 @@ const readStoredCanvasScene = (document) => {
|
|
|
10772
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.");
|
|
10773
11043
|
};
|
|
10774
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
|
+
|
|
10775
11059
|
//#endregion
|
|
10776
11060
|
//#region ../../packages/contract/src/capture/capture-comparison.schema.ts
|
|
10777
11061
|
const COMMIT_LENGTH = 200;
|
|
@@ -10892,63 +11176,6 @@ const captureReviewSchema = z.strictObject({
|
|
|
10892
11176
|
}))
|
|
10893
11177
|
});
|
|
10894
11178
|
|
|
10895
|
-
//#endregion
|
|
10896
|
-
//#region src/application/canvas-reference.use-case.ts
|
|
10897
|
-
const hasCanvasReferenceScope = (reference) => reference.pageId !== void 0 || reference.nodeIds.length > 0;
|
|
10898
|
-
/** The origin a `/c/<id>` path is read against. The path names no host, and none is kept. */
|
|
10899
|
-
const PATH_ORIGIN = "https://canvas.invalid";
|
|
10900
|
-
/**
|
|
10901
|
-
* `canvas find` and `prototype publish` answer with the path `/c/<id>`, which is not an address by
|
|
10902
|
-
* itself, so it is read as the address it would be on any host.
|
|
10903
|
-
*/
|
|
10904
|
-
const asAddress = (reference) => {
|
|
10905
|
-
const candidate = reference.trim();
|
|
10906
|
-
return candidate.startsWith("/c/") ? `${PATH_ORIGIN}${candidate}` : reference;
|
|
10907
|
-
};
|
|
10908
|
-
const parseCanvasReference = (reference) => {
|
|
10909
|
-
const parsed = readCanvasReference(asAddress(reference));
|
|
10910
|
-
if (parsed.ok) return parsed.value;
|
|
10911
|
-
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.");
|
|
10912
|
-
};
|
|
10913
|
-
const fromCanvasReference = (reference) => {
|
|
10914
|
-
const parsed = parseCanvasReference(reference);
|
|
10915
|
-
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.");
|
|
10916
|
-
return parsed.canvasId;
|
|
10917
|
-
};
|
|
10918
|
-
const canvasReferenceNodeIds = (reference, document) => {
|
|
10919
|
-
if (!hasCanvasReferenceScope(reference)) return /* @__PURE__ */ new Set();
|
|
10920
|
-
const scope = resolveCanvasReference(reference, document);
|
|
10921
|
-
if (scope.ok) return scope.nodeIds;
|
|
10922
|
-
const reason = scope.reason;
|
|
10923
|
-
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.");
|
|
10924
|
-
};
|
|
10925
|
-
const assertCanvasReferenceNodes = (reference, document, nodeIds) => {
|
|
10926
|
-
if (!hasCanvasReferenceScope(reference)) return;
|
|
10927
|
-
const scope = canvasReferenceNodeIds(reference, document);
|
|
10928
|
-
assertNodesInScope(scope, nodeIds);
|
|
10929
|
-
};
|
|
10930
|
-
const assertNodesInScope = (scope, nodeIds) => {
|
|
10931
|
-
const outside = nodeIds.filter((id) => !scope.has(id));
|
|
10932
|
-
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.");
|
|
10933
|
-
};
|
|
10934
|
-
const canvasReferenceRenderTarget = (reference, document, target) => {
|
|
10935
|
-
if (!hasCanvasReferenceScope(reference)) return target;
|
|
10936
|
-
const scope = canvasReferenceNodeIds(reference, document);
|
|
10937
|
-
const nodeId = target.kind === "node" ? target.nodeId : target.kind === "content" && reference.nodeIds.length === 1 ? reference.nodeIds[0] : void 0;
|
|
10938
|
-
if (nodeId !== void 0) {
|
|
10939
|
-
assertNodesInScope(scope, [nodeId]);
|
|
10940
|
-
return {
|
|
10941
|
-
kind: "node",
|
|
10942
|
-
nodeId
|
|
10943
|
-
};
|
|
10944
|
-
}
|
|
10945
|
-
if (reference.nodeIds.length === 0 && reference.pageId !== void 0 && (target.kind === "content" || target.kind === "page" && target.pageId === reference.pageId)) return {
|
|
10946
|
-
kind: "page",
|
|
10947
|
-
pageId: reference.pageId
|
|
10948
|
-
};
|
|
10949
|
-
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.");
|
|
10950
|
-
};
|
|
10951
|
-
|
|
10952
11179
|
//#endregion
|
|
10953
11180
|
//#region src/application/canvas-resource-read.schema.ts
|
|
10954
11181
|
const MAX_RESOURCE_PAGE = 100;
|
|
@@ -11103,12 +11330,19 @@ const canvasSourceEvidenceSchema = z.discriminatedUnion("kind", [
|
|
|
11103
11330
|
})
|
|
11104
11331
|
]);
|
|
11105
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
|
+
|
|
11106
11341
|
//#endregion
|
|
11107
11342
|
//#region src/application/canvas-exchange.schema.ts
|
|
11108
|
-
const MAX_PREPARATION_WAIT_MS =
|
|
11109
|
-
const DEFAULT_PREPARATION_WAIT_MS =
|
|
11343
|
+
const MAX_PREPARATION_WAIT_MS = 12e4;
|
|
11344
|
+
const DEFAULT_PREPARATION_WAIT_MS = 3e4;
|
|
11110
11345
|
const MAX_TOKEN_LENGTH = 16384;
|
|
11111
|
-
const MAX_TARGETS = 1e3;
|
|
11112
11346
|
const MAX_OUTLINE_PAGE = 100;
|
|
11113
11347
|
const DEFAULT_OUTLINE_PAGE = 50;
|
|
11114
11348
|
const MAX_OUTLINE_DEPTH = 64;
|
|
@@ -11136,7 +11370,7 @@ const canvasReadInputSchema = z.discriminatedUnion("view", [
|
|
|
11136
11370
|
z.strictObject({
|
|
11137
11371
|
...sharedRead,
|
|
11138
11372
|
view: z.literal("outline"),
|
|
11139
|
-
rootNodeIds: z.array(nodeId$2).min(1).
|
|
11373
|
+
rootNodeIds: z.array(nodeId$2).min(1).optional(),
|
|
11140
11374
|
depth: z.number().int().min(0).max(MAX_OUTLINE_DEPTH).default(2),
|
|
11141
11375
|
limit: z.number().int().min(1).max(MAX_OUTLINE_PAGE).default(DEFAULT_OUTLINE_PAGE),
|
|
11142
11376
|
cursor: cursor.optional()
|
|
@@ -11147,18 +11381,26 @@ const canvasUpdateHtmlInputSchema = z.strictObject({
|
|
|
11147
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."),
|
|
11148
11382
|
snapshotToken: cursor,
|
|
11149
11383
|
html: z.string().min(1),
|
|
11150
|
-
removeNodeIds: z.array(nodeId$2).
|
|
11151
|
-
clientToken:
|
|
11384
|
+
removeNodeIds: z.array(nodeId$2).default([]),
|
|
11385
|
+
clientToken: retryClientTokenSchema
|
|
11152
11386
|
});
|
|
11153
|
-
const
|
|
11154
|
-
protocol: z.literal("enhance-canvas-editable/1"),
|
|
11387
|
+
const snapshotBinding = {
|
|
11155
11388
|
canvasId: z.uuid(),
|
|
11156
11389
|
version,
|
|
11157
11390
|
rootNodeId: nodeId$2,
|
|
11158
|
-
scopeNodeIds: z.array(nodeId$2).max(MAX_TARGETS),
|
|
11159
11391
|
scopePageId: z.string().nullable(),
|
|
11160
11392
|
digest: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
11161
|
-
}
|
|
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
|
+
})]);
|
|
11162
11404
|
const canvasOutlineCursorSchema = z.strictObject({
|
|
11163
11405
|
protocol: z.literal("enhance-canvas-outline/1"),
|
|
11164
11406
|
canvasId: z.uuid(),
|
|
@@ -11237,19 +11479,104 @@ const decodeCanvasExchangeToken = (token, schema) => {
|
|
|
11237
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.");
|
|
11238
11480
|
}
|
|
11239
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
|
+
};
|
|
11240
11498
|
const canvasSnapshotToken = (input) => encodeCanvasExchangeToken({
|
|
11241
|
-
protocol: "enhance-canvas-editable/
|
|
11499
|
+
protocol: "enhance-canvas-editable/2",
|
|
11242
11500
|
canvasId: input.reference.canvasId,
|
|
11243
11501
|
version: input.version,
|
|
11244
11502
|
rootNodeId: input.rootNodeId,
|
|
11245
|
-
|
|
11503
|
+
scopeDigest: scopeDigestOf(canonicalScope(input.reference)),
|
|
11246
11504
|
scopePageId: input.reference.pageId ?? null,
|
|
11247
11505
|
digest: canvasExchangeDigest(input.html)
|
|
11248
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. */
|
|
11249
11514
|
const resolveCanvasSnapshot = (token, reference) => {
|
|
11250
11515
|
const binding = decodeCanvasExchangeToken(token, canvasSnapshotBindingSchema);
|
|
11251
|
-
if (binding.canvasId !== reference.canvasId || binding.scopePageId !== (reference.pageId ?? null) ||
|
|
11252
|
-
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.");
|
|
11253
11580
|
};
|
|
11254
11581
|
|
|
11255
11582
|
//#endregion
|
|
@@ -11529,15 +11856,16 @@ const canvasEditCapabilityInputSchema = z.object({
|
|
|
11529
11856
|
|
|
11530
11857
|
//#endregion
|
|
11531
11858
|
//#region src/application/canvas-conversion-command.schema.ts
|
|
11532
|
-
const MAX_WAIT_MS$1 =
|
|
11533
|
-
const DEFAULT_WAIT_MS$1 =
|
|
11859
|
+
const MAX_WAIT_MS$1 = 12e4;
|
|
11860
|
+
const DEFAULT_WAIT_MS$1 = 3e4;
|
|
11534
11861
|
const canvasInsertHtmlInputSchema = z.strictObject({
|
|
11535
11862
|
canvasRef: z.string().min(1),
|
|
11536
11863
|
baseVersion: z.number().int().positive(),
|
|
11537
11864
|
destination: z.strictObject({ parentNodeId: canvasSceneNodeSchema.shape.id.describe("Existing editable container, or root for top-level insertion. Preserve page and selection scope.") }),
|
|
11538
|
-
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."),
|
|
11539
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."),
|
|
11540
|
-
clientToken:
|
|
11868
|
+
clientToken: retryClientTokenSchema
|
|
11541
11869
|
});
|
|
11542
11870
|
const canvasInsertHtmlCapabilityInputSchema = canvasInsertHtmlInputSchema.omit({ clientToken: true });
|
|
11543
11871
|
const canvasMakeEditableInputSchema = z.strictObject({
|
|
@@ -11613,7 +11941,7 @@ const canvasFindCursorSchema = z.strictObject({
|
|
|
11613
11941
|
const canvasCreateToolInputSchema = z.strictObject({
|
|
11614
11942
|
destination: canvasDestinationSchema,
|
|
11615
11943
|
title: createCanvasInputSchema.shape.title,
|
|
11616
|
-
clientToken:
|
|
11944
|
+
clientToken: retryClientTokenSchema
|
|
11617
11945
|
});
|
|
11618
11946
|
const canvasCreateToolOutputSchema = z.strictObject({
|
|
11619
11947
|
canvasRef: z.uuid(),
|
|
@@ -11631,7 +11959,7 @@ const canvasRemoveInputSchema = z.strictObject({
|
|
|
11631
11959
|
canvasRef: z.string().min(1),
|
|
11632
11960
|
baseVersion: z.number().int().positive(),
|
|
11633
11961
|
rootNodeIds: z.array(canvasSceneNodeSchema.shape.id).min(1),
|
|
11634
|
-
clientToken:
|
|
11962
|
+
clientToken: retryClientTokenSchema
|
|
11635
11963
|
});
|
|
11636
11964
|
const canvasRemoveCapabilityInputSchema = canvasRemoveInputSchema.omit({ clientToken: true });
|
|
11637
11965
|
|
|
@@ -11671,8 +11999,8 @@ const canvasRenderFileSchema = z.object({
|
|
|
11671
11999
|
|
|
11672
12000
|
//#endregion
|
|
11673
12001
|
//#region src/application/canvas-render-request.schema.ts
|
|
11674
|
-
const MAX_WAIT_MS =
|
|
11675
|
-
const DEFAULT_WAIT_MS =
|
|
12002
|
+
const MAX_WAIT_MS = 12e4;
|
|
12003
|
+
const DEFAULT_WAIT_MS = 3e4;
|
|
11676
12004
|
const canvasRenderRequestSchema = z.strictObject({
|
|
11677
12005
|
canvasRef: z.string().min(1),
|
|
11678
12006
|
expectedVersion: z.number().int().positive(),
|
|
@@ -11753,7 +12081,7 @@ const canvasRenderBatchResultSchema = z.object({
|
|
|
11753
12081
|
next: z.array(z.string())
|
|
11754
12082
|
});
|
|
11755
12083
|
const canvasRenderScopedInputSchema = z.union([canvasRenderRequestSchema, canvasRenderBatchRequestSchema]).meta({ type: "object" });
|
|
11756
|
-
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" });
|
|
11757
12085
|
|
|
11758
12086
|
//#endregion
|
|
11759
12087
|
//#region src/application/canvas-asset.schema.ts
|
|
@@ -11765,7 +12093,7 @@ const canvasAssetImportCapabilityInputSchema = z.strictObject({
|
|
|
11765
12093
|
path: z.string().min(1).describe("Explicit local file path. PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2.")
|
|
11766
12094
|
})
|
|
11767
12095
|
});
|
|
11768
|
-
const canvasAssetImportInputSchema = canvasAssetImportCapabilityInputSchema.extend({ clientToken:
|
|
12096
|
+
const canvasAssetImportInputSchema = canvasAssetImportCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
11769
12097
|
const canvasAssetImportOutputSchema = z.strictObject({
|
|
11770
12098
|
operation: canvasAssetOperationSchema,
|
|
11771
12099
|
resource: canvasAssetUploadOutputSchema.safeExtend({
|
|
@@ -11819,6 +12147,8 @@ const canvasWriteReceiptSchema = z.discriminatedUnion("outcome", [z.strictObject
|
|
|
11819
12147
|
total: z.number().int().nonnegative()
|
|
11820
12148
|
}).optional(),
|
|
11821
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(),
|
|
11822
12152
|
verification: z.strictObject({ rendered: z.literal(false) }),
|
|
11823
12153
|
warnings: z.array(z.string())
|
|
11824
12154
|
})]).meta({ type: "object" });
|
|
@@ -11838,8 +12168,8 @@ const canvasEditOutputSchema = z.union([canvasEditReceiptSchema, canvasWriteRece
|
|
|
11838
12168
|
const common = {
|
|
11839
12169
|
canvasRef: z.string().min(1),
|
|
11840
12170
|
baseVersion: z.number().int().positive(),
|
|
11841
|
-
waitMs: z.number().int().min(0).max(
|
|
11842
|
-
clientToken:
|
|
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."),
|
|
12172
|
+
clientToken: retryClientTokenSchema
|
|
11843
12173
|
};
|
|
11844
12174
|
const canvasArrangeInputSchema = z.strictObject({
|
|
11845
12175
|
...common,
|
|
@@ -11848,7 +12178,8 @@ const canvasArrangeInputSchema = z.strictObject({
|
|
|
11848
12178
|
const canvasDuplicateInputSchema = z.strictObject({
|
|
11849
12179
|
...common,
|
|
11850
12180
|
nodeIds: canvasDuplicatePreparationSchema.shape.nodeIds,
|
|
11851
|
-
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.")
|
|
11852
12183
|
});
|
|
11853
12184
|
const canvasArrangeCapabilityInputSchema = canvasArrangeInputSchema.omit({ clientToken: true });
|
|
11854
12185
|
const canvasDuplicateCapabilityInputSchema = canvasDuplicateInputSchema.omit({ clientToken: true });
|
|
@@ -11888,7 +12219,7 @@ const canvasCaptureCapabilityInputSchema = z.strictObject({
|
|
|
11888
12219
|
previewJobId: z.uuid().describe("The successful render job whose pixels you inspected at this exact recording time and canvas version."),
|
|
11889
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.")
|
|
11890
12221
|
});
|
|
11891
|
-
const canvasCaptureInputSchema = canvasCaptureCapabilityInputSchema.extend({ clientToken:
|
|
12222
|
+
const canvasCaptureInputSchema = canvasCaptureCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
11892
12223
|
const canvasCaptureOutputSchema = z.strictObject({
|
|
11893
12224
|
operation: z.discriminatedUnion("kind", [
|
|
11894
12225
|
z.strictObject({
|
|
@@ -12024,6 +12355,7 @@ const canvasConversionStatusSchema = z.strictObject({
|
|
|
12024
12355
|
version: z.number().int().positive(),
|
|
12025
12356
|
rootNodeId: z.string(),
|
|
12026
12357
|
affectedBounds: canvasSceneBoxSchema,
|
|
12358
|
+
placement: canvasPlacementResultSchema.optional().describe("Where a placed insertion saved its screen, at this version."),
|
|
12027
12359
|
insertedCount: z.number().int().nonnegative(),
|
|
12028
12360
|
removedCount: z.number().int().nonnegative(),
|
|
12029
12361
|
identityCount: z.number().int().nonnegative(),
|
|
@@ -12114,7 +12446,7 @@ const canvasPrototypeCapabilityInputSchema = z.strictObject({
|
|
|
12114
12446
|
waitMs: canvasRenderRequestSchema.shape.waitMs.describe("Additional ingestion polling, capped at five seconds. This budget does not include packaging or network transfers."),
|
|
12115
12447
|
source: z.discriminatedUnion("kind", [directorySourceSchema, deploymentSourceSchema])
|
|
12116
12448
|
});
|
|
12117
|
-
const canvasPrototypeInputSchema = canvasPrototypeCapabilityInputSchema.extend({ clientToken:
|
|
12449
|
+
const canvasPrototypeInputSchema = canvasPrototypeCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
12118
12450
|
const canvasPrototypeIntentSchema = canvasPrototypeInputSchema.extend({ source: z.discriminatedUnion("kind", [canvasPrototypeBuildSourceSchema, deploymentSourceSchema]) });
|
|
12119
12451
|
const canvasPrototypeOutputSchema = z.strictObject({
|
|
12120
12452
|
operation: prototypeOperationSchema,
|
|
@@ -12158,7 +12490,7 @@ const canvasPrototypeOutputSchema = z.strictObject({
|
|
|
12158
12490
|
//#region src/application/capture-page.schema.ts
|
|
12159
12491
|
const canvasCapturePageCapabilityInputSchema = z.strictObject({
|
|
12160
12492
|
...canvasRenderRequestSchema.pick({ canvasRef: true }).shape,
|
|
12161
|
-
waitMs: canvasRenderRequestSchema.shape.waitMs.describe("How long this call waits for the page to become editable, in milliseconds: at most
|
|
12493
|
+
waitMs: canvasRenderRequestSchema.shape.waitMs.describe("How long this call waits for the page to become editable, in milliseconds: at most 120000. Call again with the same captureId to keep waiting."),
|
|
12162
12494
|
captureId: z.uuid().optional().describe("The captureId the snippet answered with. Omit it to get a snippet to run in the page."),
|
|
12163
12495
|
title: z.string().optional().describe("Optional: a name for the frame. Without it, or when it is blank, the frame takes the captured page's own title."),
|
|
12164
12496
|
extent: z.enum(["full-page", "viewport"]).default("full-page").describe("What the snippet captures: the whole page, or only the visible window."),
|
|
@@ -12172,7 +12504,7 @@ const canvasCapturePageCapabilityInputSchema = z.strictObject({
|
|
|
12172
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."),
|
|
12173
12505
|
baseVersion: z.number().int().positive().optional().describe("The canvas version you read; the frame is saved as one change at it.")
|
|
12174
12506
|
});
|
|
12175
|
-
const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken:
|
|
12507
|
+
const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
|
|
12176
12508
|
const canvasCapturePageOutputSchema = z.strictObject({
|
|
12177
12509
|
step: z.enum([
|
|
12178
12510
|
"run-snippet",
|
|
@@ -12317,6 +12649,7 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
12317
12649
|
...CANVAS_VERSION_PROCEDURE_DESCRIPTIONS,
|
|
12318
12650
|
"canvas.createEditableFrame": "Insert one validated primitive subtree beside its source screen as an atomic canvas edit.",
|
|
12319
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.",
|
|
12320
12653
|
"canvas.applyOperations": "Atomically apply validated text, geometry, style, ordering, and removal operations to one canvas version.",
|
|
12321
12654
|
"canvas.realtime.ticket": "Issue a one-use browser ticket for a live canvas room.",
|
|
12322
12655
|
"canvas.realtime.activity.begin": "Show that this agent has started work on a canvas.",
|
|
@@ -12657,6 +12990,16 @@ const PROTOTYPE_LIFECYCLE_POLICY = {
|
|
|
12657
12990
|
reason: "Prototype upload lifecycle is wrapped by prototype publish.",
|
|
12658
12991
|
owner: "product"
|
|
12659
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
|
+
};
|
|
12660
13003
|
const STAGED_TRANSFER_POLICY = {
|
|
12661
13004
|
exposure: "internal",
|
|
12662
13005
|
reason: "Signed transfers are wrapped by prototype publish and asset import.",
|
|
@@ -12697,6 +13040,12 @@ const CAPTURE_PIPELINE_POLICY = {
|
|
|
12697
13040
|
owner: "product",
|
|
12698
13041
|
reason: "Capture reservation, publication and baseline promotion belong to explicit SDK pipeline callers."
|
|
12699
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
|
+
};
|
|
12700
13049
|
const PROCEDURE_CAPABILITY_POLICIES = {
|
|
12701
13050
|
"captureRun.review": SHARED_CAPABILITY_POLICY,
|
|
12702
13051
|
"captureRun.decide": {
|
|
@@ -12770,11 +13119,8 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12770
13119
|
...CANVAS_RECOVERY_POLICIES,
|
|
12771
13120
|
"canvas.chats.publish": CHAT_HISTORY_POLICY,
|
|
12772
13121
|
"canvas.copyFromWork": RECOVERY_COPY_POLICY,
|
|
12773
|
-
"canvas.applyOperations":
|
|
12774
|
-
|
|
12775
|
-
reason: "Wrapped by bounded, intention-revealing authoring capabilities.",
|
|
12776
|
-
owner: "product"
|
|
12777
|
-
},
|
|
13122
|
+
"canvas.applyOperations": AUTHORING_POLICY,
|
|
13123
|
+
"canvas.applyEdits": AUTHORING_POLICY,
|
|
12778
13124
|
"canvas.realtime.ticket": {
|
|
12779
13125
|
exposure: "internal",
|
|
12780
13126
|
reason: "Browser WebSocket admission is not an agent capability.",
|
|
@@ -12832,21 +13178,13 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12832
13178
|
reason: "Restoring historical state is restricted to an interactive person session.",
|
|
12833
13179
|
owner: "product"
|
|
12834
13180
|
},
|
|
12835
|
-
"person.createAgentToken":
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
"person.
|
|
12841
|
-
|
|
12842
|
-
reason: "Credential lifecycle remains in the interactive CLI auth surface.",
|
|
12843
|
-
owner: "cli"
|
|
12844
|
-
},
|
|
12845
|
-
"person.revokeAgentToken": {
|
|
12846
|
-
exposure: "cli-transport",
|
|
12847
|
-
reason: "Credential lifecycle remains in the interactive CLI auth surface.",
|
|
12848
|
-
owner: "cli"
|
|
12849
|
-
},
|
|
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,
|
|
12850
13188
|
"person.signIn": {
|
|
12851
13189
|
exposure: "internal",
|
|
12852
13190
|
reason: "Browser sign-in protocol is wrapped by the CLI auth surface.",
|
|
@@ -13438,6 +13776,8 @@ const SESSION_EXPIRED_REMEDIATION = `Your Enhance session expired. ${remediation
|
|
|
13438
13776
|
const remediationOf = (error, status) => {
|
|
13439
13777
|
const formatRefusal = error.fields?.["documentFormatVersion"];
|
|
13440
13778
|
if (formatRefusal !== void 0) return formatRefusal;
|
|
13779
|
+
const given = error.fields?.["remediation"];
|
|
13780
|
+
if (given !== void 0) return given;
|
|
13441
13781
|
if (status === void 0) return remediationFor(error.code);
|
|
13442
13782
|
const outcome = requestOutcomeOf({
|
|
13443
13783
|
kind: "response",
|
|
@@ -13447,7 +13787,7 @@ const remediationOf = (error, status) => {
|
|
|
13447
13787
|
});
|
|
13448
13788
|
if (outcome.kind === "sign-in" && outcome.reason === "session-expired") return SESSION_EXPIRED_REMEDIATION;
|
|
13449
13789
|
if (error.code === "CONFLICT" && outcome.kind === "transient") return "Wait a few seconds, then retry the same command with the same clientToken.";
|
|
13450
|
-
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.";
|
|
13451
13791
|
return remediationFor(error.code);
|
|
13452
13792
|
};
|
|
13453
13793
|
const trpcErrorSchema = z.object({ data: z.looseObject({
|
|
@@ -13458,8 +13798,12 @@ const appErrorFrom = (error) => {
|
|
|
13458
13798
|
const parsed = trpcErrorSchema.safeParse(error);
|
|
13459
13799
|
const appError = appErrorSchema.safeParse(parsed.success ? parsed.data.data.appError : null);
|
|
13460
13800
|
if (!appError.success) return null;
|
|
13801
|
+
const fields = Object.fromEntries(Object.entries(appError.data.fields ?? {}).filter(([name]) => name !== "remediation"));
|
|
13461
13802
|
return {
|
|
13462
|
-
appError:
|
|
13803
|
+
appError: {
|
|
13804
|
+
...appError.data,
|
|
13805
|
+
...appError.data.fields !== void 0 && { fields: Object.keys(fields).length === 0 ? void 0 : fields }
|
|
13806
|
+
},
|
|
13463
13807
|
remediation: remediationOf(appError.data, parsed.data?.data.httpStatus)
|
|
13464
13808
|
};
|
|
13465
13809
|
};
|
|
@@ -13932,14 +14276,7 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
13932
14276
|
inputSchema: canvasEditCapabilityInputSchema,
|
|
13933
14277
|
outputSchema: canvasEditOutputSchema,
|
|
13934
14278
|
summary: "Change selected text, styles, names, duplicates, or positions in one atomic design edit.",
|
|
13935
|
-
procedures: [
|
|
13936
|
-
"canvas.document.get",
|
|
13937
|
-
"canvas.mutation.get",
|
|
13938
|
-
"canvas.realtime.activity.begin",
|
|
13939
|
-
"canvas.realtime.activity.renew",
|
|
13940
|
-
"canvas.realtime.activity.end",
|
|
13941
|
-
"canvas.applyOperations"
|
|
13942
|
-
],
|
|
14279
|
+
procedures: ["canvas.edit"],
|
|
13943
14280
|
inputExample: {
|
|
13944
14281
|
canvas: CAPABILITY_UUID_EXAMPLE,
|
|
13945
14282
|
baseVersion: 1,
|
|
@@ -14826,19 +15163,21 @@ const PROCEDURES_WITHOUT_GENERIC_RECEIPTS = /* @__PURE__ */ new Set([
|
|
|
14826
15163
|
"screen.create",
|
|
14827
15164
|
"canvas.copyFromWork"
|
|
14828
15165
|
]);
|
|
15166
|
+
/**
|
|
15167
|
+
* The answer a token keeps: a success, or a refusal the same input would hear again. A fault of
|
|
15168
|
+
* ours (internal, rate limited, or no named error at all) is not an answer about the write, so
|
|
15169
|
+
* the token keeps nothing and the caller's retry with the same token runs it again.
|
|
15170
|
+
*/
|
|
14829
15171
|
const outcomeFrom = (result) => {
|
|
14830
15172
|
if (result.ok) return {
|
|
14831
15173
|
kind: "success",
|
|
14832
15174
|
data: result.data
|
|
14833
15175
|
};
|
|
14834
15176
|
const onWire = toWireAppError(result.error);
|
|
14835
|
-
if (onWire
|
|
14836
|
-
kind: "failure",
|
|
14837
|
-
error: onWire
|
|
14838
|
-
};
|
|
15177
|
+
if (onWire === null || onWire.code === "INTERNAL" || onWire.code === "RATE_LIMITED") return null;
|
|
14839
15178
|
return {
|
|
14840
15179
|
kind: "failure",
|
|
14841
|
-
error:
|
|
15180
|
+
error: onWire
|
|
14842
15181
|
};
|
|
14843
15182
|
};
|
|
14844
15183
|
const replay = (claim) => {
|
|
@@ -14864,13 +15203,17 @@ const idempotentMutations = trpcMiddleware(async ({ ctx, type, path, getRawInput
|
|
|
14864
15203
|
if (claimed.isErr()) throw toTrpcError(internalError(claimed.error.message));
|
|
14865
15204
|
if (claimed.value.kind !== "started") return replay(claimed.value);
|
|
14866
15205
|
const result = await next();
|
|
14867
|
-
const
|
|
15206
|
+
const key = {
|
|
14868
15207
|
personId: ctx.viewer.personId,
|
|
14869
15208
|
clientToken: ctx.idempotencyKey,
|
|
14870
|
-
procedure: path
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
15209
|
+
procedure: path
|
|
15210
|
+
};
|
|
15211
|
+
const outcome = outcomeFrom(result);
|
|
15212
|
+
const settled = await (outcome === null ? ctx.idempotency.release(key) : ctx.idempotency.complete({
|
|
15213
|
+
...key,
|
|
15214
|
+
outcome
|
|
15215
|
+
}));
|
|
15216
|
+
if (settled.isErr()) throw toTrpcError(internalError(settled.error.message));
|
|
14874
15217
|
return result;
|
|
14875
15218
|
});
|
|
14876
15219
|
|
|
@@ -14981,7 +15324,7 @@ const rpcValidationDiagnostic = (cause) => {
|
|
|
14981
15324
|
};
|
|
14982
15325
|
|
|
14983
15326
|
//#endregion
|
|
14984
|
-
//#region ../api/src/shared/trpc/
|
|
15327
|
+
//#region ../api/src/shared/trpc/request-log.procedure.ts
|
|
14985
15328
|
/** Query timings are logged to the hundredth of a millisecond; finer is noise. */
|
|
14986
15329
|
const HUNDREDTHS = 100;
|
|
14987
15330
|
/** A message on the log index is a message somebody pays to keep for 400 days. */
|
|
@@ -15020,6 +15363,16 @@ const failureOf = (error) => {
|
|
|
15020
15363
|
message: reasonOf(error).slice(0, MESSAGE_CAP)
|
|
15021
15364
|
};
|
|
15022
15365
|
};
|
|
15366
|
+
/** Which agent made a call, as the API worked it out when the call arrived; nothing for a person. */
|
|
15367
|
+
const agentLogFields = (viewer) => {
|
|
15368
|
+
if (viewer.kind !== "agent" || viewer.agentAttribution === void 0) return {};
|
|
15369
|
+
const agent = viewer.agentAttribution;
|
|
15370
|
+
return {
|
|
15371
|
+
agentClient: agent.agent_client,
|
|
15372
|
+
agentClientVersion: agent.agent_client_version ?? null,
|
|
15373
|
+
connectionPath: agent.connection_path
|
|
15374
|
+
};
|
|
15375
|
+
};
|
|
15023
15376
|
/**
|
|
15024
15377
|
* @justified amplification
|
|
15025
15378
|
* The canonical line: one per procedure call, and the whole of the profile.
|
|
@@ -15047,6 +15400,7 @@ const timed = trpcMiddleware(async ({ ctx, path, type, next }) => {
|
|
|
15047
15400
|
const failure = call.outcome.ok ? null : failureOf(call.outcome.error);
|
|
15048
15401
|
const line = {
|
|
15049
15402
|
...ctx.taggedFields(),
|
|
15403
|
+
...agentLogFields(ctx.viewer),
|
|
15050
15404
|
event: "ProcedureCalled",
|
|
15051
15405
|
procedure: path,
|
|
15052
15406
|
kind: type,
|
|
@@ -15072,6 +15426,9 @@ const timed = trpcMiddleware(async ({ ctx, path, type, next }) => {
|
|
|
15072
15426
|
}, "query");
|
|
15073
15427
|
return call.outcome;
|
|
15074
15428
|
});
|
|
15429
|
+
|
|
15430
|
+
//#endregion
|
|
15431
|
+
//#region ../api/src/shared/trpc/base.procedure.ts
|
|
15075
15432
|
const RENDER_GRANT_PROCEDURES = /* @__PURE__ */ new Set([
|
|
15076
15433
|
"canvas.document.get",
|
|
15077
15434
|
"canvas.document.parts",
|
|
@@ -15374,7 +15731,10 @@ const toCanvasSceneNodeContract = (node) => canvasSceneNodeSchema.parse({
|
|
|
15374
15731
|
* that has no screen layer, onto its page at the box the draft gives.
|
|
15375
15732
|
*/
|
|
15376
15733
|
const toEditableFrameOrigin = (input) => "screenNodeId" in input ? {
|
|
15377
|
-
destination: {
|
|
15734
|
+
destination: {
|
|
15735
|
+
kind: "adjacent",
|
|
15736
|
+
...input.position !== void 0 && { position: input.position }
|
|
15737
|
+
},
|
|
15378
15738
|
source: {
|
|
15379
15739
|
kind: "screen",
|
|
15380
15740
|
nodeId: input.screenNodeId
|
|
@@ -16683,7 +17043,38 @@ const receiptSchema$1 = applyCanvasOperationsOutputSchema.pick({
|
|
|
16683
17043
|
changedNodeIds: true,
|
|
16684
17044
|
removedNodeIds: true
|
|
16685
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
|
+
});
|
|
16686
17076
|
const createCanvasMutationRecoveryRouter = (handlers) => trpcRouter({
|
|
17077
|
+
applyEdits: edit(handlers),
|
|
16687
17078
|
revertMutations: canvasEditorProcedure.input(z.object({
|
|
16688
17079
|
canvasId: z.uuid(),
|
|
16689
17080
|
mutationIds: z.array(z.uuid()).min(1),
|
|
@@ -17377,13 +17768,17 @@ const wireResult = (job, result) => ({
|
|
|
17377
17768
|
...result.snapshot !== null && result.snapshot !== void 0 && { snapshot: result.snapshot },
|
|
17378
17769
|
expiresAt: result.expiresAt.toISOString()
|
|
17379
17770
|
});
|
|
17380
|
-
const wireConversionResult = (result) => ({
|
|
17771
|
+
const wireConversionResult = ({ placement, ...result }) => ({
|
|
17381
17772
|
...result,
|
|
17382
17773
|
idMap: { ...result.idMap },
|
|
17383
17774
|
insertedNodeIds: [...result.insertedNodeIds],
|
|
17384
17775
|
removedNodeIds: [...result.removedNodeIds],
|
|
17385
17776
|
boxes: { ...result.boxes },
|
|
17386
17777
|
affectedBounds: { ...result.affectedBounds },
|
|
17778
|
+
...placement !== void 0 && { placement: {
|
|
17779
|
+
...placement,
|
|
17780
|
+
roots: [...placement.roots]
|
|
17781
|
+
} },
|
|
17387
17782
|
report: {
|
|
17388
17783
|
...result.report,
|
|
17389
17784
|
issues: [...result.report.issues]
|
|
@@ -18255,6 +18650,43 @@ const createOrganisationPeopleRouter = (handlers) => trpcRouter({
|
|
|
18255
18650
|
transferOwnership: transferOwnership(handlers)
|
|
18256
18651
|
});
|
|
18257
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
|
+
|
|
18258
18690
|
//#endregion
|
|
18259
18691
|
//#region ../api/src/person/domain/prepared-canvas-id.domain-service.ts
|
|
18260
18692
|
const UUID_PART_LIMIT = 5;
|
|
@@ -18304,6 +18736,7 @@ const agentTokenRoutes = (handlers) => ({
|
|
|
18304
18736
|
}),
|
|
18305
18737
|
listAgentTokens: personProcedure.meta({ description: "List agent credentials so unused or revoked ones can be identified." }).input(listAgentTokensInputSchema).output(listAgentTokensOutputSchema).query(async ({ ctx }) => ({
|
|
18306
18738
|
isConnected: orThrow(await handlers.agentTokens.isConnected(ctx.viewer.personId)),
|
|
18739
|
+
hasEverConnected: orThrow(await handlers.agentTokens.hasEverConnected(ctx.viewer.personId)),
|
|
18307
18740
|
items: orThrow(await handlers.agentTokens.list(ctx.viewer.personId)).map((token) => tokenOnWire(token))
|
|
18308
18741
|
})),
|
|
18309
18742
|
revokeAgentToken: personProcedure.meta({ description: "Revoke an agent credential before its next request." }).input(revokeAgentTokenInputSchema).output(revokeAgentTokenOutputSchema).mutation(async ({ input, ctx }) => {
|
|
@@ -18432,6 +18865,15 @@ const profilePhotoRoutes = (profile) => ({
|
|
|
18432
18865
|
}))) }))
|
|
18433
18866
|
});
|
|
18434
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
|
+
|
|
18435
18877
|
//#endregion
|
|
18436
18878
|
//#region ../api/src/prototype/infrastructure/prototype-completion.mapper.ts
|
|
18437
18879
|
const toPrototypeCompletionContract = (completed, input) => {
|
|
@@ -19347,10 +19789,7 @@ const createAppRouter = (handlers, options = DEFAULT_ROUTER_OPTIONS) => trpcRout
|
|
|
19347
19789
|
people: createOrganisationPeopleRouter(handlers.organisation),
|
|
19348
19790
|
invites: createOrganisationInviteRouter(handlers.organisation)
|
|
19349
19791
|
}),
|
|
19350
|
-
person: trpcRouter(
|
|
19351
|
-
...createPersonRouter(handlers.person)._def.record,
|
|
19352
|
-
...profilePhotoRoutes(handlers.person.profile)
|
|
19353
|
-
}),
|
|
19792
|
+
person: trpcRouter(personRouterPlugin(handlers.person)),
|
|
19354
19793
|
prototype: createPrototypeRouter(handlers.prototype),
|
|
19355
19794
|
stagedUpload: createStagedUploadRouter(handlers.prototype.stagedUploads),
|
|
19356
19795
|
recording: trpcRouter({
|
|
@@ -19425,6 +19864,7 @@ const handlers = {
|
|
|
19425
19864
|
markRead: unavailable.execute
|
|
19426
19865
|
},
|
|
19427
19866
|
applyOperations: unavailable,
|
|
19867
|
+
edit: unavailable,
|
|
19428
19868
|
createEditableFrame: unavailable,
|
|
19429
19869
|
create: unavailable,
|
|
19430
19870
|
get: unavailable,
|
|
@@ -19530,7 +19970,14 @@ const handlers = {
|
|
|
19530
19970
|
list: () => unavailable.execute(),
|
|
19531
19971
|
find: () => unavailable.execute(),
|
|
19532
19972
|
isConnected: () => unavailable.execute(),
|
|
19973
|
+
hasEverConnected: () => unavailable.execute(),
|
|
19533
19974
|
revoke: () => unavailable.execute()
|
|
19975
|
+
},
|
|
19976
|
+
onboarding: {
|
|
19977
|
+
read: () => unavailable.execute(),
|
|
19978
|
+
dismiss: () => unavailable.execute(),
|
|
19979
|
+
present: () => unavailable.execute(),
|
|
19980
|
+
recordCanvasLinkCopied: () => unavailable.execute()
|
|
19534
19981
|
}
|
|
19535
19982
|
},
|
|
19536
19983
|
prototype: {
|
|
@@ -19894,6 +20341,47 @@ const boundedEntries = (compact, key, entries) => {
|
|
|
19894
20341
|
}
|
|
19895
20342
|
return kept;
|
|
19896
20343
|
};
|
|
20344
|
+
/**
|
|
20345
|
+
* An insert's count of problems, whether it is partial and the step that says to tell the person
|
|
20346
|
+
* come before any id list: an agent can read ids again, but not what the converter left out.
|
|
20347
|
+
*/
|
|
20348
|
+
const reportFields = (compact, original) => {
|
|
20349
|
+
const report = recordFrom(original["report"]);
|
|
20350
|
+
if (report === null) return {};
|
|
20351
|
+
const summary = {
|
|
20352
|
+
issueCount: report["issueCount"],
|
|
20353
|
+
partial: report["partial"]
|
|
20354
|
+
};
|
|
20355
|
+
const next = original["next"];
|
|
20356
|
+
const fields = {
|
|
20357
|
+
report: summary,
|
|
20358
|
+
...Array.isArray(next) && canFitReceipt({
|
|
20359
|
+
...compact,
|
|
20360
|
+
report: summary,
|
|
20361
|
+
next
|
|
20362
|
+
}) && { next }
|
|
20363
|
+
};
|
|
20364
|
+
const issues = Array.isArray(report["issues"]) ? report["issues"] : [];
|
|
20365
|
+
const kept = [];
|
|
20366
|
+
for (const issue of issues) {
|
|
20367
|
+
if (!canFitReceipt({
|
|
20368
|
+
...compact,
|
|
20369
|
+
...fields,
|
|
20370
|
+
report: {
|
|
20371
|
+
...summary,
|
|
20372
|
+
issues: [...kept, issue]
|
|
20373
|
+
}
|
|
20374
|
+
})) break;
|
|
20375
|
+
kept.push(issue);
|
|
20376
|
+
}
|
|
20377
|
+
return {
|
|
20378
|
+
...fields,
|
|
20379
|
+
report: {
|
|
20380
|
+
...summary,
|
|
20381
|
+
issues: kept
|
|
20382
|
+
}
|
|
20383
|
+
};
|
|
20384
|
+
};
|
|
19897
20385
|
const toCanvasAuthoringResult = (value) => {
|
|
19898
20386
|
const original = recordFrom(value);
|
|
19899
20387
|
if (original === null) return null;
|
|
@@ -19907,10 +20395,14 @@ const toCanvasAuthoringResult = (value) => {
|
|
|
19907
20395
|
value: complete,
|
|
19908
20396
|
detail: null
|
|
19909
20397
|
};
|
|
19910
|
-
const
|
|
20398
|
+
const shortened = {
|
|
19911
20399
|
...receipt,
|
|
19912
20400
|
detailTruncated: true
|
|
19913
20401
|
};
|
|
20402
|
+
const compact = {
|
|
20403
|
+
...shortened,
|
|
20404
|
+
...reportFields(shortened, original)
|
|
20405
|
+
};
|
|
19914
20406
|
for (const key of [
|
|
19915
20407
|
"mode",
|
|
19916
20408
|
"targetNodeId",
|
|
@@ -19971,4 +20463,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
19971
20463
|
});
|
|
19972
20464
|
|
|
19973
20465
|
//#endregion
|
|
19974
|
-
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 };
|