@enhance-eng/enhance 0.1.17 → 0.1.21
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-LnsyU8mi.mjs → cli-output-identity.lib-a1wTreJ6.mjs} +2376 -1147
- package/dist/main.mjs +193 -20
- package/dist/{mcp-invocation.adapter-CdKeCw-i.mjs → mcp-invocation.adapter-NrVhm7y8.mjs} +2 -2
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-Bk2r-Iiz.mjs → mcp-server.adapter-Cgp05gfi.mjs} +1 -1
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-CRbBW6xF.mjs → mutation-key.adapter-x3QOYrKY.mjs} +88 -73
- package/dist/remote-mcp-main.mjs +5 -5
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as createOrganisationOutputSchema, A as parseCanvasReference, At as
|
|
3
|
-
import { a as createOauthLoopbackAdapter, c as createWriteHtmlCanvasComposite, d as createApplyCanvasComposite, f as createCanvasActivityComposite, l as createEditCanvasComposite, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, p as createRenderCanvasComposite, r as CLI_CONFIG, s as createRenderFileAdapter, t as createMutationKeyAdapter, u as sceneAtVersion } from "./mutation-key.adapter-
|
|
2
|
+
import { $ as createOrganisationOutputSchema, A as parseCanvasReference, At as canvasLayoutPriorityDeclarations, D as assertCanvasReferenceOperations, Dt as canvasAuthoredStyleDeclarations, E as assertCanvasReferenceNodes, Et as canvasAuthoredLayoutValueOf, F as completeScreenOutputSchema, I as createScreenOutputSchema, L as appendRecordingChunkOutputSchema, M as CliError, Mt as canvasSchema, O as canvasReferenceNodeIds, Ot as canvasAxisStyleProperties, P as appErrorSchema, R as completeRecordingOutputSchema, T as canvasEditsSchema, Tt as canvasReadableSceneDocumentSchema, _t as RENDER_MIN_SCALE, a as toExitCode, at as beginCanvasActivityOutputSchema, bt as canvasWorldBoundsSchema, c as toSharedCapabilities, ct as getCanvasDocumentOutputSchema, d as createCapabilityCatalogAdapter, et as emptyFixtureDocument, f as createRouterShapeAdapter, g as PROCEDURE_DESCRIPTIONS, h as OPTION_DESCRIPTIONS, i as toCanvasAuthoringResult, it as canvasTextRunsOf, j as PartialBatchError, k as fromCanvasReference, kt as canvasLayoutMainAxisOf, l as createMcpCapabilityDiscoveryAdapter, lt as saveCanvasDocumentOutputSchema, n as withCommandName, o as toFailurePayload, ot as canvasAgentActivityPhaseSchema, p as createCapabilityPolicyAdapter, pt as canvasOperationSchema, t as withCommandInFailure, tt as withFixtureScreen, u as ProcessExitError, ut as MAX_CANVAS_OPERATIONS, z as startRecordingOutputSchema } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
|
+
import { a as createOauthLoopbackAdapter, c as createWriteHtmlCanvasComposite, d as createApplyCanvasComposite, f as createCanvasActivityComposite, l as createEditCanvasComposite, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, p as createRenderCanvasComposite, r as CLI_CONFIG, s as createRenderFileAdapter, t as createMutationKeyAdapter, u as sceneAtVersion } from "./mutation-key.adapter-x3QOYrKY.mjs";
|
|
4
4
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
5
5
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-rI5HpMEo.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
@@ -15,6 +15,76 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
15
15
|
import { readFile } from "node:fs/promises";
|
|
16
16
|
import { proxify } from "trpc-cli/dist/proxify.js";
|
|
17
17
|
|
|
18
|
+
//#region ../../packages/contract/src/canvas/canvas-color-css.lib.ts
|
|
19
|
+
const BYTE_MAX = 255;
|
|
20
|
+
const CHANNEL_PRECISION = 1e6;
|
|
21
|
+
const roundedChannel = (value) => Math.round(value * BYTE_MAX * CHANNEL_PRECISION) / CHANNEL_PRECISION;
|
|
22
|
+
const canvasColorCss = (color, opacity = 1) => {
|
|
23
|
+
const alpha = color.alpha * opacity;
|
|
24
|
+
if (color.space === "srgb") {
|
|
25
|
+
const channels = [
|
|
26
|
+
color.red,
|
|
27
|
+
color.green,
|
|
28
|
+
color.blue
|
|
29
|
+
].map((channel) => String(roundedChannel(channel))).join(" ");
|
|
30
|
+
return alpha === 1 ? `rgb(${channels})` : `rgb(${channels} / ${String(alpha)})`;
|
|
31
|
+
}
|
|
32
|
+
const channels = `${String(color.red)} ${String(color.green)} ${String(color.blue)}`;
|
|
33
|
+
return `color(${color.space} ${channels} / ${String(alpha)})`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region ../../packages/contract/src/canvas/canvas-typography-css.lib.ts
|
|
38
|
+
const PERCENT$2 = 100;
|
|
39
|
+
/** Native bidi chooses each automatic paragraph's base direction without changing its alignment. */
|
|
40
|
+
const canvasTextDirectionDeclarations = (direction) => direction === void 0 ? {} : {
|
|
41
|
+
...direction !== "auto" && { direction },
|
|
42
|
+
"unicode-bidi": direction === "auto" ? "plaintext" : "isolate"
|
|
43
|
+
};
|
|
44
|
+
const CSS_IDENTIFIER = /^-?[_a-z][-\w]*$/iu;
|
|
45
|
+
const CSS_VARIABLE = /^var\(--[-\w]+\)$/iu;
|
|
46
|
+
const fontFamilyName = (family) => CSS_IDENTIFIER.test(family) || CSS_VARIABLE.test(family) ? family : JSON.stringify(family);
|
|
47
|
+
const canvasTypographyFontFamily = (typography) => [.../* @__PURE__ */ new Set([
|
|
48
|
+
typography.family,
|
|
49
|
+
...typography.family === "Inter" ? ["Inter Variable"] : [],
|
|
50
|
+
...typography.family === "JetBrains Mono" ? ["JetBrains Mono Variable"] : [],
|
|
51
|
+
...typography.fallbackFamilies
|
|
52
|
+
])].map((family) => fontFamilyName(family)).join(", ");
|
|
53
|
+
/** Weight is the sole wght owner; the remaining axes never shadow the visible weight field. */
|
|
54
|
+
const canvasFontVariationSettings = (typography) => Object.entries({
|
|
55
|
+
...typography.variations,
|
|
56
|
+
...typography.weight !== void 0 && { wght: typography.weight },
|
|
57
|
+
...typography.opticalSize?.mode === "fixed" && { opsz: typography.opticalSize.value }
|
|
58
|
+
}).toSorted(([a], [b]) => a.localeCompare(b, "en", { caseFirst: "upper" })).map(([tag, value]) => `${JSON.stringify(tag)} ${String(value)}`).join(", ");
|
|
59
|
+
const canvasFontFeatureSettings = (features) => {
|
|
60
|
+
const settings = Object.entries(features ?? {}).toSorted(([a], [b]) => a.localeCompare(b, "en")).map(([tag, value]) => `${JSON.stringify(tag)} ${String(value)}`).join(", ");
|
|
61
|
+
return settings === "" ? "normal" : settings;
|
|
62
|
+
};
|
|
63
|
+
const lineHeightDeclaration = (height) => {
|
|
64
|
+
if (height.mode === "normal") return "normal";
|
|
65
|
+
return height.mode === "percent" ? String(height.value / PERCENT$2) : height.value;
|
|
66
|
+
};
|
|
67
|
+
function canvasTypographyMetricDeclarations(typography) {
|
|
68
|
+
return {
|
|
69
|
+
...typography.lineHeight !== void 0 && { "line-height": lineHeightDeclaration(typography.lineHeight) },
|
|
70
|
+
...typography.letterSpacing !== void 0 && { "letter-spacing": typeof typography.letterSpacing === "number" ? typography.letterSpacing : `${String(typography.letterSpacing.value / PERCENT$2)}em` }
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const canvasDecorationLengthCss = (length) => {
|
|
74
|
+
if (length === void 0) return "auto";
|
|
75
|
+
if (typeof length === "number") return length;
|
|
76
|
+
return length.mode === "font-default" ? "from-font" : `${String(length.value)}%`;
|
|
77
|
+
};
|
|
78
|
+
const canvasTextDecorationDeclarations = (decoration) => ({
|
|
79
|
+
"text-decoration-line": decoration.line,
|
|
80
|
+
"text-decoration-style": decoration.style,
|
|
81
|
+
"text-decoration-color": decoration.color === void 0 ? "currentColor" : canvasColorCss(decoration.color),
|
|
82
|
+
"text-decoration-thickness": canvasDecorationLengthCss(decoration.thickness),
|
|
83
|
+
"text-underline-offset": canvasDecorationLengthCss(decoration.offset),
|
|
84
|
+
"text-decoration-skip-ink": decoration.skipInk ?? "auto"
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
18
88
|
//#region ../../packages/contract/src/recording/event-stream.lib.ts
|
|
19
89
|
/**
|
|
20
90
|
* @justified docs/comments.md#intent
|
|
@@ -444,7 +514,8 @@ const selectMutationToken = (input, value) => {
|
|
|
444
514
|
const configureCanvasApply = (canvas, input) => {
|
|
445
515
|
canvas.command("apply").description("Apply an atomic canvas edit batch and return its affected bounds.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID to edit.").requiredOption("--base-version <integer>", "Exact version returned by canvas inspect or tree.").requiredOption("--operations <json-or-@path>", "JSON operation array inline, or @path to a JSON file.").option("--client-token <uuid>", "Stable UUID to reuse only when retrying this exact batch.").addHelpText("after", [
|
|
446
516
|
"",
|
|
447
|
-
"Supported operations: insertNode, insertText, insertPrototype, setText, setBox, setLabel, setVisibility, setLocked, setConstraints, setStyles, setAppearance, setLayout, setTypography, setAdditionalStyles, setProps, setParentage, move, remove.",
|
|
517
|
+
"Supported operations: insertNode, insertText, insertPrototype, setText, editText, setBox, setLabel, setVisibility, setLocked, setConstraints, setStyles, setAppearance, setLayout, patchTypography, setTypography, patchAdditionalStyles, setAdditionalStyles, setProps, setParentage, move, remove.",
|
|
518
|
+
"Use editText for revision-aware character or range changes. setText replaces the whole text and is rejected if it conflicts with a newer text edit.",
|
|
448
519
|
"Example:",
|
|
449
520
|
` enhance canvas apply --canvas <url-or-id> --base-version 3 --operations '[{"op":"insertText","nodeId":"txt_summary","parentId":"root","text":"Checkout needs an address.","box":{"x":120,"y":594,"width":720,"height":80},"styles":{"font-size":24}}]'`
|
|
450
521
|
].join("\n")).action(async (options) => {
|
|
@@ -866,18 +937,72 @@ const appearanceCss = (appearance) => {
|
|
|
866
937
|
...effectCss(appearance)
|
|
867
938
|
};
|
|
868
939
|
};
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
"font-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
940
|
+
const typographyFamilyCss = (node, typography) => {
|
|
941
|
+
const result = {};
|
|
942
|
+
const authoredStyles = canvasAuthoredStyleDeclarations(node);
|
|
943
|
+
const families = String(authoredStyles["font-family"] ?? "sans-serif").split(",").map((family) => family.trim().replaceAll(/^(?:"|')|(?:"|')$/gu, ""));
|
|
944
|
+
if (typography.family !== void 0 || typography.fallbackFamilies !== void 0) {
|
|
945
|
+
const [family = "sans-serif", ...fallbackFamilies] = families;
|
|
946
|
+
result["font-family"] = canvasTypographyFontFamily({
|
|
947
|
+
family: typography.family ?? family,
|
|
948
|
+
fallbackFamilies: typography.fallbackFamilies ?? fallbackFamilies
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
return result;
|
|
952
|
+
};
|
|
953
|
+
const typographyFontCss = (typography) => {
|
|
954
|
+
const result = {};
|
|
955
|
+
if (typography.size !== void 0) result["font-size"] = `${String(typography.size)}px`;
|
|
956
|
+
if (typography.weight !== void 0) result["font-weight"] = typography.weight;
|
|
957
|
+
if (typography.style !== void 0) result["font-style"] = typography.style;
|
|
958
|
+
if (typography.variations !== void 0 || typography.opticalSize !== void 0) result["font-variation-settings"] = canvasFontVariationSettings({
|
|
959
|
+
...typography.weight !== void 0 && { weight: typography.weight },
|
|
960
|
+
...typography.variations !== void 0 && { variations: typography.variations },
|
|
961
|
+
...typography.opticalSize !== void 0 && { opticalSize: typography.opticalSize }
|
|
962
|
+
});
|
|
963
|
+
if (typography.opticalSize !== void 0) result["font-optical-sizing"] = typography.opticalSize.mode === "auto" ? "auto" : "none";
|
|
964
|
+
if (typography.features !== void 0) result["font-feature-settings"] = canvasFontFeatureSettings(typography.features);
|
|
965
|
+
Object.assign(result, canvasTypographyMetricDeclarations(typography));
|
|
966
|
+
return result;
|
|
967
|
+
};
|
|
968
|
+
const typographyParagraphCss = (typography) => {
|
|
969
|
+
const result = {};
|
|
970
|
+
if (typography.align !== void 0) result["text-align"] = typography.align;
|
|
971
|
+
if (typography.transform !== void 0) result["text-transform"] = typography.transform;
|
|
972
|
+
Object.assign(result, canvasTextDirectionDeclarations(typography.direction));
|
|
973
|
+
if (typography.paragraphIndent !== void 0) result["text-indent"] = `${String(typography.paragraphIndent)}px each-line`;
|
|
974
|
+
if (typography.hangingPunctuation !== void 0) result["hanging-punctuation"] = "none";
|
|
975
|
+
return result;
|
|
976
|
+
};
|
|
977
|
+
const typographyVerticalCss = (typography) => {
|
|
978
|
+
const result = {};
|
|
979
|
+
if (typography.verticalAlign !== void 0 && typography.verticalAlign !== "top") {
|
|
980
|
+
result["display"] = "flex";
|
|
981
|
+
result["flex-direction"] = "column";
|
|
982
|
+
result["justify-content"] = typography.verticalAlign === "middle" ? "center" : "flex-end";
|
|
983
|
+
}
|
|
984
|
+
if (typography.verticalTrim !== void 0) {
|
|
985
|
+
result["text-box-trim"] = typography.verticalTrim === "cap-height" ? "trim-both" : "none";
|
|
986
|
+
result["text-box-edge"] = "cap alphabetic";
|
|
987
|
+
}
|
|
988
|
+
return result;
|
|
989
|
+
};
|
|
990
|
+
const typographyDecorationCss = (typography) => {
|
|
991
|
+
const result = {};
|
|
992
|
+
if (typography.decoration !== void 0) Object.assign(result, canvasTextDecorationDeclarations(typography.decoration));
|
|
993
|
+
if (typography.wrapping !== void 0) result["white-space"] = typography.wrapping === "wrap" ? "normal" : typography.wrapping;
|
|
994
|
+
if (typography.wrapStyle !== void 0) result["text-wrap-style"] = typography.wrapStyle;
|
|
995
|
+
return result;
|
|
996
|
+
};
|
|
997
|
+
const typographyCss = (node) => {
|
|
998
|
+
const typography = node.typography ?? {};
|
|
999
|
+
return {
|
|
1000
|
+
...typographyFamilyCss(node, typography),
|
|
1001
|
+
...typographyFontCss(typography),
|
|
1002
|
+
...typographyParagraphCss(typography),
|
|
1003
|
+
...typographyVerticalCss(typography),
|
|
1004
|
+
...typographyDecorationCss(typography)
|
|
1005
|
+
};
|
|
881
1006
|
};
|
|
882
1007
|
const computedCanvasNodeCss = (node, document) => ({
|
|
883
1008
|
...Object.fromEntries(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([property]) => node.layout?.clipContent === void 0 || ![
|
|
@@ -885,7 +1010,7 @@ const computedCanvasNodeCss = (node, document) => ({
|
|
|
885
1010
|
"overflow-x",
|
|
886
1011
|
"overflow-y"
|
|
887
1012
|
].includes(property))),
|
|
888
|
-
...typographyCss(node
|
|
1013
|
+
...typographyCss(node),
|
|
889
1014
|
...appearanceCss(node.appearance),
|
|
890
1015
|
...canvasStyleLayoutCss(node, document),
|
|
891
1016
|
...node.visible === false && { display: "none" }
|
|
@@ -904,6 +1029,48 @@ const stringProperty = (node, property) => {
|
|
|
904
1029
|
return typeof value === "string" ? value : "";
|
|
905
1030
|
};
|
|
906
1031
|
const jsxString = (value) => `{${JSON.stringify(value)}}`;
|
|
1032
|
+
const optionalRichProperty = (value, format) => value === void 0 ? [] : [format(value)];
|
|
1033
|
+
const jsxRichTextNode = (node, depth) => {
|
|
1034
|
+
const indent = " ".repeat(depth);
|
|
1035
|
+
const content = `${indent}${jsxString(node.text)}`;
|
|
1036
|
+
return node.sourcePath === void 0 ? content : `${indent}<span data-source-path=${JSON.stringify(node.sourcePath)}>${jsxString(node.text)}</span>`;
|
|
1037
|
+
};
|
|
1038
|
+
const jsxRichBreakNode = (node, depth) => {
|
|
1039
|
+
const indent = " ".repeat(depth);
|
|
1040
|
+
const sourcePath = optionalRichProperty(node.sourcePath, (value) => `data-source-path=${JSON.stringify(value)}`).join("");
|
|
1041
|
+
return `${indent}<br data-text-break="${node.soft === true ? "line" : "paragraph"}"${sourcePath === "" ? "" : ` ${sourcePath}`} />`;
|
|
1042
|
+
};
|
|
1043
|
+
const jsxRichContainerNode = (node, depth) => {
|
|
1044
|
+
const indent = " ".repeat(depth);
|
|
1045
|
+
const properties = [
|
|
1046
|
+
...optionalRichProperty(node.sourcePath, (value) => `data-source-path=${JSON.stringify(value)}`),
|
|
1047
|
+
...optionalRichProperty(node.href, (value) => `href={${JSON.stringify(value)}}`),
|
|
1048
|
+
...optionalRichProperty(node.href, () => "rel=\"noreferrer\" target=\"_blank\""),
|
|
1049
|
+
...optionalRichProperty(Object.keys(node.styles).length === 0 ? void 0 : node.styles, (value) => `style={${JSON.stringify(value)}}`),
|
|
1050
|
+
...optionalRichProperty(node.textStyle, (value) => `data-text-style={${JSON.stringify(value)}}`),
|
|
1051
|
+
...optionalRichProperty(node.paragraph, (value) => `data-text-paragraph={${JSON.stringify(value)}}`),
|
|
1052
|
+
...optionalRichProperty(node.fills, (value) => `data-text-fills={${JSON.stringify(value)}}`),
|
|
1053
|
+
...optionalRichProperty(node.paragraphSpacing, (value) => `data-paragraph-spacing=${JSON.stringify(value)}`),
|
|
1054
|
+
...optionalRichProperty(node.paragraphIndent, (value) => `data-paragraph-indent=${JSON.stringify(value)}`),
|
|
1055
|
+
...optionalRichProperty(node.listSpacing, (value) => `data-list-spacing=${JSON.stringify(value)}`),
|
|
1056
|
+
...optionalRichProperty(node.hangingPunctuation, (value) => `data-hanging-punctuation=${JSON.stringify(value)}`),
|
|
1057
|
+
...optionalRichProperty(node.verticalTrim, (value) => `data-vertical-trim=${JSON.stringify(value)}`),
|
|
1058
|
+
...optionalRichProperty(node.wrapStyle, (value) => `data-wrap-style=${JSON.stringify(value)}`)
|
|
1059
|
+
];
|
|
1060
|
+
const tag = node.href === void 0 ? "span" : "a";
|
|
1061
|
+
const children = node.children.map((child) => jsxRichNode(child, depth + 1));
|
|
1062
|
+
return [
|
|
1063
|
+
`${indent}<${tag}${properties.length === 0 ? "" : ` ${properties.join(" ")}`}>`,
|
|
1064
|
+
...children,
|
|
1065
|
+
`${indent}</${tag}>`
|
|
1066
|
+
].join("\n");
|
|
1067
|
+
};
|
|
1068
|
+
const jsxRichNode = (node, depth) => {
|
|
1069
|
+
if (node.kind === "text") return jsxRichTextNode(node, depth);
|
|
1070
|
+
if (node.kind === "break") return jsxRichBreakNode(node, depth);
|
|
1071
|
+
return jsxRichContainerNode(node, depth);
|
|
1072
|
+
};
|
|
1073
|
+
const jsxRichText = (node, depth) => canvasTextRunsOf(node).map((run) => jsxRichNode(run, depth)).join("\n");
|
|
907
1074
|
const jsxFor = (document, nodeId, depth, maximumDepth) => {
|
|
908
1075
|
const node = requireNode(document, nodeId);
|
|
909
1076
|
const indent = " ".repeat(depth);
|
|
@@ -916,7 +1083,7 @@ const jsxFor = (document, nodeId, depth, maximumDepth) => {
|
|
|
916
1083
|
if (node.component === "image") return `${indent}<img ${properties.join(" ")} alt=${JSON.stringify(stringProperty(node, "alt"))} src=${JSON.stringify(stringProperty(node, "src"))} />`;
|
|
917
1084
|
if (node.component === "svg") return `${indent}<div ${properties.join(" ")} data-component="svg" />`;
|
|
918
1085
|
const tag = node.component === "text" ? "span" : "div";
|
|
919
|
-
const text = node.component === "text" ?
|
|
1086
|
+
const text = node.component === "text" ? jsxRichText(node, depth + 1) : "";
|
|
920
1087
|
const children = (depth >= maximumDepth ? [] : childrenOf(document, nodeId)).map((childId) => jsxFor(document, childId, depth + 1, maximumDepth));
|
|
921
1088
|
if (text === "" && children.length === 0) return `${indent}<${tag} ${properties.join(" ")} />`;
|
|
922
1089
|
return [
|
|
@@ -1349,10 +1516,11 @@ const COMMAND_SUMMARIES = {
|
|
|
1349
1516
|
"canvas.duplicate": "Copy a canvas into a shelf.",
|
|
1350
1517
|
"canvas.deletePermanently": "Permanently delete a binned canvas.",
|
|
1351
1518
|
"canvas.restore": "Restore a binned canvas.",
|
|
1352
|
-
"canvas.inspect": "Read
|
|
1519
|
+
"canvas.inspect": "Read canvas URL, structure, and next steps.",
|
|
1353
1520
|
"canvas.tree": "List canvas node ids, hierarchy, kinds, and boxes.",
|
|
1354
1521
|
"canvas.node": "Read one canvas node and its children.",
|
|
1355
1522
|
"canvas.selection": "Read the person’s current live browser selection.",
|
|
1523
|
+
"canvas text-style-library": "Discover and publish text styles.",
|
|
1356
1524
|
"canvas realtime": "Canvas presence and activity.",
|
|
1357
1525
|
"canvas document": "Read or replace a canvas document.",
|
|
1358
1526
|
"canvas version": "Retained canvas history.",
|
|
@@ -1391,6 +1559,7 @@ const createProcessAdapter = () => ({ exit: (code) => {
|
|
|
1391
1559
|
//#endregion
|
|
1392
1560
|
//#region src/infrastructure/cli-polish.lib.ts
|
|
1393
1561
|
const NAMESPACES = {
|
|
1562
|
+
"canvas text-style-library": "Find, read, and publish reusable text styles across canvases.",
|
|
1394
1563
|
canvas: "Canvases: create, find, share, and manage review surfaces.",
|
|
1395
1564
|
"canvas render": "Render production-faithful canvas pixels after inspecting exact structure and geometry.",
|
|
1396
1565
|
"canvas version": "Inspect and name retained canvas history.",
|
|
@@ -1526,7 +1695,11 @@ const polishCli = (command, input, path = []) => {
|
|
|
1526
1695
|
//#endregion
|
|
1527
1696
|
//#region src/infrastructure/cli-surface.lib.ts
|
|
1528
1697
|
const CLI_EXCLUDED_PROCEDURES = createCapabilityPolicyAdapter().excludedProcedures;
|
|
1529
|
-
const CLI_EXCLUDED_NAMESPACES = /* @__PURE__ */ new Set([
|
|
1698
|
+
const CLI_EXCLUDED_NAMESPACES = /* @__PURE__ */ new Set([
|
|
1699
|
+
"canvas thumbnail",
|
|
1700
|
+
"canvas font-catalog",
|
|
1701
|
+
"telemetry"
|
|
1702
|
+
]);
|
|
1530
1703
|
const procedurePathOf$1 = (command) => {
|
|
1531
1704
|
const details = Reflect.get(command, "__trpcCli");
|
|
1532
1705
|
if (typeof details !== "object" || details === null) return null;
|
|
@@ -2148,7 +2321,7 @@ const main = async () => {
|
|
|
2148
2321
|
const credentials = createFileCredentialAdapter(CLI_CONFIG.configDirectory);
|
|
2149
2322
|
const mutationKey = createMutationKeyAdapter();
|
|
2150
2323
|
const cli = createCliProgram({
|
|
2151
|
-
version: "0.1.
|
|
2324
|
+
version: "0.1.21",
|
|
2152
2325
|
credentials,
|
|
2153
2326
|
remote: createHttpRemoteAdapter(CLI_CONFIG.apiUrl, credentials, mutationKey),
|
|
2154
2327
|
mutationKey,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { o as toFailurePayload } from "./cli-output-identity.lib-
|
|
3
|
-
import { a as createOauthLoopbackAdapter, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-
|
|
2
|
+
import { o as toFailurePayload } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
|
+
import { a as createOauthLoopbackAdapter, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-x3QOYrKY.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/infrastructure/mcp-auth.adapter.ts
|
package/dist/mcp-main.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as createCapabilityCatalogAdapter, m as toCapabilityDefinition } from "./cli-output-identity.lib-
|
|
3
|
-
import { r as CLI_CONFIG } from "./mutation-key.adapter-
|
|
2
|
+
import { d as createCapabilityCatalogAdapter, m as toCapabilityDefinition } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
|
+
import { r as CLI_CONFIG } from "./mutation-key.adapter-x3QOYrKY.mjs";
|
|
4
4
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-rI5HpMEo.mjs";
|
|
5
|
-
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
6
|
-
import { t as createMcpServerAdapter } from "./mcp-server.adapter-
|
|
5
|
+
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-NrVhm7y8.mjs";
|
|
6
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-Cgp05gfi.mjs";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
@@ -152,7 +152,7 @@ const capabilities = [
|
|
|
152
152
|
exampleInput: {},
|
|
153
153
|
exampleOutput: {
|
|
154
154
|
status: "ok",
|
|
155
|
-
runtimeVersion: "0.1.
|
|
155
|
+
runtimeVersion: "0.1.21",
|
|
156
156
|
api: {
|
|
157
157
|
reachable: true,
|
|
158
158
|
status: 200
|
|
@@ -167,10 +167,10 @@ const createMcpTransportCapabilityAdapter = () => capabilities;
|
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/mcp-main.ts
|
|
169
169
|
const credentials = createFileCredentialAdapter(CLI_CONFIG.configDirectory);
|
|
170
|
-
const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.
|
|
170
|
+
const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.21");
|
|
171
171
|
const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
|
|
172
172
|
serveStdio(() => createMcpServerAdapter({
|
|
173
|
-
version: "0.1.
|
|
173
|
+
version: "0.1.21",
|
|
174
174
|
name: CLI_CONFIG.mcpServiceName,
|
|
175
175
|
commandName: CLI_CONFIG.commandName,
|
|
176
176
|
invocation,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as parseCanvasReference, E as assertCanvasReferenceNodes, M as CliError,
|
|
2
|
+
import { A as parseCanvasReference, E as assertCanvasReferenceNodes, M as CliError, Tt as canvasReadableSceneDocumentSchema, ct as getCanvasDocumentOutputSchema, d as createCapabilityCatalogAdapter, i as toCanvasAuthoringResult, l as createMcpCapabilityDiscoveryAdapter, n as withCommandName, o as toFailurePayload, r as canvasRenderResultSchema, s as toPresentedCapabilities, t as withCommandInFailure, vt as canvasRenderSourceStateSchema, w as canvasEditCapabilityInputSchema, y as canvasWriteHtmlCapabilityInputSchema, yt as canvasRenderTargetSchema } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { readFile, rm } from "node:fs/promises";
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as toSharedCapabilities, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-
|
|
2
|
+
import { c as toSharedCapabilities, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
3
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
4
|
-
import { t as createMcpServerAdapter } from "./mcp-server.adapter-
|
|
4
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-Cgp05gfi.mjs";
|
|
5
5
|
|
|
6
6
|
export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as parseCanvasReference, B as PROTOTYPE_ARTIFACT_MANIFEST_PATH, C as transcriptReadCapabilityInputSchema, Ct as
|
|
2
|
+
import { A as parseCanvasReference, B as PROTOTYPE_ARTIFACT_MANIFEST_PATH, C as transcriptReadCapabilityInputSchema, Ct as downloadCanvasRenderOutputSchema, D as assertCanvasReferenceOperations, E as assertCanvasReferenceNodes, G as getPrototypePublishStatusOutputSchema, H as createPrototypeArtifactOutputSchema, J as submitPrototypeArtifactOutputSchema, K as prototypeArtifactManifestSchema, M as CliError, N as transcriptOutputSchema, Ot as canvasAxisStyleProperties, Q as createAgentTokenOutputSchema, S as recordingSnapshotCapabilityInputSchema, St as createRecordingSnapshotOutputSchema, Tt as canvasReadableSceneDocumentSchema, U as foldPrototypeArtifactPath, V as attachPrototypeArtifactOutputSchema, W as getPrototypeArtifactCapabilitiesOutputSchema, Y as getMeOutputSchema, Z as cliAuthConfigurationSchema, _ as canvasApplyCapabilityInputSchema, at as beginCanvasActivityOutputSchema, b as commentAttentionCapabilityInputSchema, ct as getCanvasDocumentOutputSchema, dt as applyCanvasOperationsInputSchema, ft as applyCanvasOperationsOutputSchema, gt as getCanvasConversionOutputSchema, ht as createCanvasConversionOutputSchema, j as PartialBatchError, jt as canvasAdditionalStyleSchema, mt as canvasNodeStylePatchSchema, nt as applyCanvasTypographyPatch, q as prototypeArtifactPathSchema, rt as canvasCssTypographyOwners, st as canvasLayoutWithoutCssProperties, ut as MAX_CANVAS_OPERATIONS, v as canvasRenderCapabilityInputSchema, w as canvasEditCapabilityInputSchema, wt as getCanvasRenderOutputSchema, x as prototypePublishCapabilityInputSchema, xt as createCanvasRenderOutputSchema, y as canvasWriteHtmlCapabilityInputSchema } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { homedir, tmpdir } from "node:os";
|
|
5
5
|
import process from "node:process";
|
|
@@ -16,6 +16,56 @@ import { createTRPCUntypedClient, httpLink } from "@trpc/client";
|
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
import { createServer } from "node:http";
|
|
18
18
|
|
|
19
|
+
//#region ../../packages/contract/src/canvas/canvas-additional-style-patch.lib.ts
|
|
20
|
+
const reorderedDeclarations = (declarations, order) => {
|
|
21
|
+
const ordered = new Set(order);
|
|
22
|
+
const prefix = [];
|
|
23
|
+
const groups = /* @__PURE__ */ new Map();
|
|
24
|
+
let group = prefix;
|
|
25
|
+
for (const declaration of declarations) {
|
|
26
|
+
if (ordered.has(declaration.id)) {
|
|
27
|
+
group = [];
|
|
28
|
+
groups.set(declaration.id, group);
|
|
29
|
+
}
|
|
30
|
+
group.push(declaration);
|
|
31
|
+
}
|
|
32
|
+
return [...prefix, ...order.flatMap((id) => groups.get(id) ?? [])];
|
|
33
|
+
};
|
|
34
|
+
/** Peer rows keep their preceding anchor when an explicitly ordered subset moves. */
|
|
35
|
+
const applyCanvasAdditionalStylePatch = (before, patch) => {
|
|
36
|
+
const removed = new Set(patch.clear);
|
|
37
|
+
const values = new Map((before?.declarations ?? []).filter((item) => !removed.has(item.id)).map((item) => [item.id, item]));
|
|
38
|
+
const updates = patch.set ?? [];
|
|
39
|
+
for (const declaration of updates) values.set(declaration.id, declaration);
|
|
40
|
+
const declarations = Array.from(values, ([, value]) => value);
|
|
41
|
+
if (declarations.length === 0 && (patch.empty === "remove" || before === void 0 && patch.empty !== "keep")) return null;
|
|
42
|
+
return { declarations: patch.order === void 0 ? declarations : reorderedDeclarations(declarations, patch.order) };
|
|
43
|
+
};
|
|
44
|
+
const canvasAdditionalStylePatchBetween = (before, after) => {
|
|
45
|
+
const previous = new Map(before?.declarations.map((item) => [item.id, item]));
|
|
46
|
+
const next = after?.declarations ?? [];
|
|
47
|
+
const nextIds = new Set(next.map((item) => item.id));
|
|
48
|
+
const clear = Array.from(previous, ([id]) => id).filter((id) => !nextIds.has(id));
|
|
49
|
+
const set = next.filter((item) => {
|
|
50
|
+
const held = previous.get(item.id);
|
|
51
|
+
return held?.property !== item.property || held.value !== item.value || held.enabled !== item.enabled;
|
|
52
|
+
});
|
|
53
|
+
const patch = {
|
|
54
|
+
...clear.length > 0 && { clear },
|
|
55
|
+
...set.length > 0 && { set }
|
|
56
|
+
};
|
|
57
|
+
const projected = applyCanvasAdditionalStylePatch(before, patch);
|
|
58
|
+
const order = next.map((item) => item.id);
|
|
59
|
+
const hasOrderChange = JSON.stringify(projected?.declarations.map((item) => item.id) ?? []) !== JSON.stringify(order);
|
|
60
|
+
const empty = after === void 0 && before !== void 0 ? "remove" : before === void 0 && after !== void 0 && next.length === 0 ? "keep" : void 0;
|
|
61
|
+
return empty === void 0 && !hasOrderChange && set.length === 0 && clear.length === 0 ? null : {
|
|
62
|
+
...patch,
|
|
63
|
+
...hasOrderChange && { order },
|
|
64
|
+
...empty !== void 0 && { empty }
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
19
69
|
//#region src/application/auth.use-case.ts
|
|
20
70
|
const TOKEN = /^enh_[\w-]{43}$/;
|
|
21
71
|
const authenticated = (value) => {
|
|
@@ -326,7 +376,7 @@ const union = (boxes) => {
|
|
|
326
376
|
const apply = async (remote, input) => {
|
|
327
377
|
const response = await remote.mutate(APPLY_PROCEDURE, {
|
|
328
378
|
...input,
|
|
329
|
-
documentFormatVersion:
|
|
379
|
+
documentFormatVersion: 5
|
|
330
380
|
});
|
|
331
381
|
const parsed = applyCanvasOperationsOutputSchema.safeParse(response);
|
|
332
382
|
if (!parsed.success) throw new CliError("INTERNAL", "The API returned an invalid canvas apply response.", "Run `enhance doctor`; report the API and CLI versions if they differ.");
|
|
@@ -604,76 +654,49 @@ const moveCanvasNodeOperations = (document, inputs) => {
|
|
|
604
654
|
|
|
605
655
|
//#endregion
|
|
606
656
|
//#region src/application/canvas-typography-operations.use-case.ts
|
|
607
|
-
const NORMAL_FONT_WEIGHT = 400;
|
|
608
|
-
const BOLD_FONT_WEIGHT = 700;
|
|
609
|
-
const fontSize = (value) => {
|
|
610
|
-
if (typeof value === "number") return value;
|
|
611
|
-
return /^(?:\d+(?:\.\d+)?|\.\d+)px$/u.test(String(value)) ? Number(String(value).replace("px", "")) : NaN;
|
|
612
|
-
};
|
|
613
|
-
const fontWeight = (value) => {
|
|
614
|
-
if (value === "normal") return NORMAL_FONT_WEIGHT;
|
|
615
|
-
return value === "bold" ? BOLD_FONT_WEIGHT : Number(value);
|
|
616
|
-
};
|
|
617
657
|
const canvasTypographyOperation = (node, styles) => {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
"
|
|
621
|
-
"font-size",
|
|
622
|
-
"font-weight",
|
|
623
|
-
"font-style"
|
|
624
|
-
];
|
|
625
|
-
if (keys.every((key) => !Object.hasOwn(styles, key))) return null;
|
|
626
|
-
if (keys.some((key) => styles[key] === null)) throw new CliError("BAD_REQUEST", "Imported typography needs an explicit font value.", "Replace the font family, pixel size, weight or style instead of clearing that field.");
|
|
627
|
-
const next = { ...node.typography };
|
|
628
|
-
const family = styles["font-family"];
|
|
629
|
-
if (family !== void 0) {
|
|
630
|
-
const families = String(family).split(",").map((held) => held.trim().replaceAll(/^(?:"|')|(?:"|')$/gu, "")).filter((held) => held !== "");
|
|
631
|
-
next.family = families[0] ?? "";
|
|
632
|
-
next.fallbackFamilies = families.slice(1);
|
|
633
|
-
}
|
|
634
|
-
if (styles["font-size"] !== void 0) next.size = fontSize(styles["font-size"]);
|
|
635
|
-
if (styles["font-weight"] !== void 0) next.weight = fontWeight(styles["font-weight"]);
|
|
636
|
-
const typography = canvasTypographySchema.safeParse({
|
|
637
|
-
...next,
|
|
638
|
-
...styles["font-style"] !== void 0 && { style: styles["font-style"] }
|
|
639
|
-
});
|
|
640
|
-
if (!typography.success) throw new CliError("BAD_REQUEST", "The font edit cannot be represented by editable typography.", "Use a font family list, numeric or pixel size, weight from 1 to 1000, and normal, italic or oblique style.");
|
|
641
|
-
return {
|
|
642
|
-
op: "setTypography",
|
|
658
|
+
const clear = canvasCssTypographyOwners(new Set(Object.keys(styles))).filter((property) => node.typography?.[property] !== void 0);
|
|
659
|
+
return clear.length === 0 ? null : {
|
|
660
|
+
op: "patchTypography",
|
|
643
661
|
nodeId: node.id,
|
|
644
|
-
typography:
|
|
662
|
+
typography: { clear }
|
|
645
663
|
};
|
|
646
664
|
};
|
|
647
665
|
|
|
648
666
|
//#endregion
|
|
649
667
|
//#region src/application/canvas-style-operations.use-case.ts
|
|
650
668
|
const ADDITIONAL_STYLE_ID_LENGTH = 200;
|
|
669
|
+
const ADDITIONAL_STYLE_SUFFIX_LENGTH = 10;
|
|
651
670
|
const camelToKebab = (property) => property.startsWith("--") ? property : property.replace(/^Webkit/u, "-webkit-").replace(/^Moz/u, "-moz-").replaceAll(/([a-z\d])([A-Z])/gu, "$1-$2").toLowerCase();
|
|
652
671
|
const additionalOperation = (node, styles) => {
|
|
653
|
-
const held = new Map((node.additionalStyles?.declarations ?? []).map((declaration) => [declaration.
|
|
672
|
+
const held = new Map((node.additionalStyles?.declarations ?? []).map((declaration) => [declaration.id, declaration]));
|
|
654
673
|
for (const [property, value] of Object.entries(styles)) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
674
|
+
const replaced = Array.from(held, ([, item]) => item).filter((item) => item.property.toLowerCase() === property);
|
|
675
|
+
for (const item of replaced) held.delete(item.id);
|
|
676
|
+
if (value === null || canvasNodeStylePatchSchema.safeParse({ [property]: value }).success) continue;
|
|
677
|
+
const base = replaced[0]?.id ?? `css-${property}`.slice(0, ADDITIONAL_STYLE_ID_LENGTH - ADDITIONAL_STYLE_SUFFIX_LENGTH);
|
|
678
|
+
let id = base;
|
|
679
|
+
for (let suffix = 1; held.has(id); suffix += 1) id = `${base}-${String(suffix)}`;
|
|
659
680
|
const result = canvasAdditionalStyleSchema.safeParse({
|
|
660
|
-
id
|
|
681
|
+
id,
|
|
661
682
|
property,
|
|
662
683
|
value: String(value),
|
|
663
684
|
enabled: true
|
|
664
685
|
});
|
|
665
686
|
if (!result.success) throw new CliError("BAD_REQUEST", `Style ${property} is not safe CSS.`, "Use a valid CSS property without imports, expressions, or executable URLs.");
|
|
666
|
-
held.set(
|
|
687
|
+
held.set(id, result.data);
|
|
667
688
|
}
|
|
668
689
|
const declarations = [];
|
|
669
690
|
for (const declaration of held.values()) {
|
|
670
691
|
if (declarations.length === 128) throw new CliError("BAD_REQUEST", "Too many additional CSS declarations.", "Remove unused declarations before adding more; no styles were changed.");
|
|
671
692
|
declarations.push(declaration);
|
|
672
693
|
}
|
|
673
|
-
|
|
674
|
-
|
|
694
|
+
const requested = declarations.length === 0 && node.additionalStyles === void 0 ? void 0 : { declarations };
|
|
695
|
+
const patch = canvasAdditionalStylePatchBetween(node.additionalStyles, requested);
|
|
696
|
+
return patch === null ? null : {
|
|
697
|
+
op: "patchAdditionalStyles",
|
|
675
698
|
nodeId: node.id,
|
|
676
|
-
additionalStyles:
|
|
699
|
+
additionalStyles: patch
|
|
677
700
|
};
|
|
678
701
|
};
|
|
679
702
|
const layoutOperation = (document, node, next, styles) => {
|
|
@@ -709,7 +732,7 @@ const operationsForNode = (document, node, source) => {
|
|
|
709
732
|
const next = {
|
|
710
733
|
...node,
|
|
711
734
|
styles: { ...node.styles },
|
|
712
|
-
...additional !== null &&
|
|
735
|
+
...additional !== null && { additionalStyles: applyCanvasAdditionalStylePatch(node.additionalStyles, additional.additionalStyles) ?? void 0 }
|
|
713
736
|
};
|
|
714
737
|
for (const [property, value] of Object.entries(stylePatch)) if (value === null) Reflect.deleteProperty(next.styles, property);
|
|
715
738
|
else next.styles[property] = value;
|
|
@@ -761,22 +784,17 @@ const canvasStyleOperations = (document, updates) => {
|
|
|
761
784
|
|
|
762
785
|
//#endregion
|
|
763
786
|
//#region src/application/canvas-edit-operations.use-case.ts
|
|
764
|
-
const TEXT_LEADING = 1.35;
|
|
765
787
|
const projectStyles = (node, operation) => {
|
|
766
788
|
const styles = { ...node.styles };
|
|
767
789
|
for (const [name, value] of Object.entries(operation.styles)) if (value === null || value === void 0) Reflect.deleteProperty(styles, name);
|
|
768
790
|
else styles[name] = value;
|
|
769
791
|
const cleared = operation.clear ?? [];
|
|
770
792
|
for (const name of cleared) Reflect.deleteProperty(styles, name);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (typeof size === "number") styles["line-height"] = `${String(Math.round(size * TEXT_LEADING))}px`;
|
|
774
|
-
else if (size === null) Reflect.deleteProperty(styles, "line-height");
|
|
775
|
-
}
|
|
776
|
-
return {
|
|
793
|
+
const typography = applyCanvasTypographyPatch(node.typography, { clear: [...canvasCssTypographyOwners(/* @__PURE__ */ new Set([...Object.keys(operation.styles), ...cleared]))] });
|
|
794
|
+
return projectPresentation({
|
|
777
795
|
...node,
|
|
778
796
|
styles
|
|
779
|
-
};
|
|
797
|
+
}, "typography", typography ?? "default");
|
|
780
798
|
};
|
|
781
799
|
const PLANNED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
782
800
|
"insertNode",
|
|
@@ -785,15 +803,17 @@ const PLANNED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
785
803
|
"setStyles",
|
|
786
804
|
"setAppearance",
|
|
787
805
|
"setTypography",
|
|
806
|
+
"patchTypography",
|
|
788
807
|
"setLayout",
|
|
789
808
|
"setAdditionalStyles",
|
|
809
|
+
"patchAdditionalStyles",
|
|
790
810
|
"setParentage"
|
|
791
811
|
]);
|
|
792
812
|
const isPlannedOperation = (operation) => PLANNED_OPERATIONS.has(operation.op);
|
|
793
|
-
const
|
|
813
|
+
const projectPresentation = (node, field, value) => {
|
|
794
814
|
const next = { ...node };
|
|
795
|
-
if (
|
|
796
|
-
else next
|
|
815
|
+
if (value === "default") Reflect.deleteProperty(next, field);
|
|
816
|
+
else Reflect.set(next, field, value);
|
|
797
817
|
return next;
|
|
798
818
|
};
|
|
799
819
|
const projectNode = (node, operation) => {
|
|
@@ -824,19 +844,14 @@ const projectNode = (node, operation) => {
|
|
|
824
844
|
if (Object.keys(appearance).length === 0) Reflect.deleteProperty(next, "appearance");
|
|
825
845
|
return next;
|
|
826
846
|
}
|
|
827
|
-
case "
|
|
828
|
-
case "
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
return
|
|
833
|
-
}
|
|
834
|
-
case "setAdditionalStyles": {
|
|
835
|
-
const next = { ...node };
|
|
836
|
-
if (operation.additionalStyles === "default") Reflect.deleteProperty(next, "additionalStyles");
|
|
837
|
-
else next.additionalStyles = operation.additionalStyles;
|
|
838
|
-
return next;
|
|
847
|
+
case "patchTypography": return projectPresentation(node, "typography", applyCanvasTypographyPatch(node.typography, operation.typography) ?? "default");
|
|
848
|
+
case "setTypography": return projectPresentation(node, "typography", operation.typography);
|
|
849
|
+
case "setLayout": return projectPresentation(node, "layout", operation.layout);
|
|
850
|
+
case "patchAdditionalStyles": {
|
|
851
|
+
const additionalStyles = applyCanvasAdditionalStylePatch(node.additionalStyles, operation.additionalStyles);
|
|
852
|
+
return projectPresentation(node, "additionalStyles", additionalStyles ?? "default");
|
|
839
853
|
}
|
|
854
|
+
case "setAdditionalStyles": return projectPresentation(node, "additionalStyles", operation.additionalStyles);
|
|
840
855
|
}
|
|
841
856
|
};
|
|
842
857
|
const projectOperation = (scene, operation) => {
|
|
@@ -988,7 +1003,7 @@ const createEditCanvasComposite = (remote) => ({ execute: async (input) => {
|
|
|
988
1003
|
const parsed = applyCanvasOperationsInputSchema.safeParse({
|
|
989
1004
|
canvasId: input.canvasId,
|
|
990
1005
|
mutationId: input.mutationId,
|
|
991
|
-
documentFormatVersion:
|
|
1006
|
+
documentFormatVersion: 5,
|
|
992
1007
|
baseVersion: input.baseVersion,
|
|
993
1008
|
operations: plan.operations
|
|
994
1009
|
});
|