@elixpo/lixsketch 5.5.12 → 5.5.14
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/react/{AIRenderer-PWWLWI6U.js → AIRenderer-ATIKGFB4.js} +90 -8
- package/dist/react/{AIRenderer-PWWLWI6U.js.map → AIRenderer-ATIKGFB4.js.map} +2 -2
- package/dist/react/Circle-ZH76FPOR.js +8 -0
- package/dist/react/CodeShape-TE74XP5V.js +8 -0
- package/dist/react/{CopyPaste-SA72NDFN.js → CopyPaste-UTU5MPKY.js} +14 -10
- package/dist/react/{CopyPaste-SA72NDFN.js.map → CopyPaste-UTU5MPKY.js.map} +2 -2
- package/dist/react/{EventDispatcher-BZQRHROG.js → EventDispatcher-K4CNNBAU.js} +2 -2
- package/dist/react/FreehandStroke-BOWDNAVC.js +8 -0
- package/dist/react/{GraphEngine-IHRVGUGG.js → GraphEngine-KQXHNTZQ.js} +39 -1
- package/dist/react/{GraphEngine-IHRVGUGG.js.map → GraphEngine-KQXHNTZQ.js.map} +2 -2
- package/dist/react/{MermaidStructuredRenderer-GGOOGON5.js → MermaidStructuredRenderer-26WGA6YD.js} +152 -25
- package/dist/react/MermaidStructuredRenderer-26WGA6YD.js.map +7 -0
- package/dist/react/Rectangle-2F7BAXG4.js +8 -0
- package/dist/react/{SceneSerializer-ZPHV6IUP.js → SceneSerializer-34VQFJN7.js} +6 -6
- package/dist/react/{Selection-VVUHY5YJ.js → Selection-XLRY6VYO.js} +2 -2
- package/dist/react/{SketchEngine-NPF2XN6Z.js → SketchEngine-P3XNZA56.js} +12 -12
- package/dist/react/TextShape-QRDG4P7F.js +8 -0
- package/dist/react/{chunk-42O6W7DF.js → chunk-62W6XTCZ.js} +13 -9
- package/dist/react/{chunk-42O6W7DF.js.map → chunk-62W6XTCZ.js.map} +2 -2
- package/dist/react/{chunk-AJAZC37E.js → chunk-GZ6NPDAB.js} +7 -11
- package/dist/react/{chunk-AJAZC37E.js.map → chunk-GZ6NPDAB.js.map} +2 -2
- package/dist/react/{chunk-YKJUBFHE.js → chunk-HKYUJUD7.js} +34 -2
- package/dist/react/chunk-HKYUJUD7.js.map +7 -0
- package/dist/react/{chunk-Q2GA4MBZ.js → chunk-IW2NRHNK.js} +11 -2
- package/dist/react/{chunk-Q2GA4MBZ.js.map → chunk-IW2NRHNK.js.map} +2 -2
- package/dist/react/{chunk-7TZSIR6V.js → chunk-MB7VS6MK.js} +13 -9
- package/dist/react/{chunk-7TZSIR6V.js.map → chunk-MB7VS6MK.js.map} +2 -2
- package/dist/react/{chunk-T6ZVV5ZO.js → chunk-Z4YVT54E.js} +11 -9
- package/dist/react/{chunk-T6ZVV5ZO.js.map → chunk-Z4YVT54E.js.map} +2 -2
- package/dist/react/index.js +26 -18
- package/dist/react/index.js.map +2 -2
- package/dist/react/styles.css +10 -3
- package/package.json +1 -1
- package/src/core/AIRenderer.js +104 -6
- package/src/core/CopyPaste.js +11 -5
- package/src/core/GraphEngine.js +45 -0
- package/src/core/MermaidStructuredRenderer.js +162 -22
- package/src/core/Selection.js +15 -2
- package/src/react/LixSketchCanvas.jsx +4 -0
- package/src/react/components/AppMenu.jsx +2 -2
- package/src/react/components/Toolbar.jsx +1 -1
- package/src/react/components/modals/CommandPalette.jsx +3 -3
- package/src/react/components/sidebars/FrameSidebar.jsx +1 -1
- package/src/react/components/sidebars/IconSidebar.jsx +2 -2
- package/src/react/components/sidebars/ShapeSidebar.jsx +1 -1
- package/src/react/store/useSketchStore.js +7 -2
- package/src/react/store/useUIStore.js +3 -4
- package/src/react/styles.css +12 -3
- package/src/shapes/Circle.js +8 -12
- package/src/shapes/CodeShape.js +17 -12
- package/src/shapes/FreehandStroke.js +46 -3
- package/src/shapes/Rectangle.js +14 -11
- package/src/shapes/TextShape.js +17 -12
- package/dist/react/Circle-KPG7TKIX.js +0 -8
- package/dist/react/CodeShape-K4DIZAIV.js +0 -8
- package/dist/react/FreehandStroke-CK24NUT3.js +0 -8
- package/dist/react/MermaidStructuredRenderer-GGOOGON5.js.map +0 -7
- package/dist/react/Rectangle-6FE7RN6W.js +0 -8
- package/dist/react/TextShape-U6ZZKB35.js +0 -8
- package/dist/react/chunk-YKJUBFHE.js.map +0 -7
- /package/dist/react/{Circle-KPG7TKIX.js.map → Circle-ZH76FPOR.js.map} +0 -0
- /package/dist/react/{CodeShape-K4DIZAIV.js.map → CodeShape-TE74XP5V.js.map} +0 -0
- /package/dist/react/{EventDispatcher-BZQRHROG.js.map → EventDispatcher-K4CNNBAU.js.map} +0 -0
- /package/dist/react/{FreehandStroke-CK24NUT3.js.map → FreehandStroke-BOWDNAVC.js.map} +0 -0
- /package/dist/react/{Rectangle-6FE7RN6W.js.map → Rectangle-2F7BAXG4.js.map} +0 -0
- /package/dist/react/{SceneSerializer-ZPHV6IUP.js.map → SceneSerializer-34VQFJN7.js.map} +0 -0
- /package/dist/react/{Selection-VVUHY5YJ.js.map → Selection-XLRY6VYO.js.map} +0 -0
- /package/dist/react/{SketchEngine-NPF2XN6Z.js.map → SketchEngine-P3XNZA56.js.map} +0 -0
- /package/dist/react/{TextShape-U6ZZKB35.js.map → TextShape-QRDG4P7F.js.map} +0 -0
|
@@ -20,12 +20,12 @@ function parseMermaid(src) {
|
|
|
20
20
|
const classAssigns = [];
|
|
21
21
|
const nodeStyles = /* @__PURE__ */ new Map();
|
|
22
22
|
const palette = [
|
|
23
|
-
{ fill: "#
|
|
24
|
-
{ fill: "#
|
|
25
|
-
{ fill: "#
|
|
26
|
-
{ fill: "#
|
|
27
|
-
{ fill: "#
|
|
28
|
-
{ fill: "#
|
|
23
|
+
{ fill: "#eee9f7", stroke: "#7667a8" },
|
|
24
|
+
{ fill: "#e6def2", stroke: "#8875b5" },
|
|
25
|
+
{ fill: "#ddd2eb", stroke: "#6f5f9c" },
|
|
26
|
+
{ fill: "#f2edf8", stroke: "#9a88bf" },
|
|
27
|
+
{ fill: "#e2daf0", stroke: "#806cab" },
|
|
28
|
+
{ fill: "#ebe4f5", stroke: "#705d9c" }
|
|
29
29
|
];
|
|
30
30
|
function parseStyleProps(value) {
|
|
31
31
|
const props = {};
|
|
@@ -1051,8 +1051,89 @@ function generateFramePreviewSVG(frame, width = 500, height = 350) {
|
|
|
1051
1051
|
${svgContent}
|
|
1052
1052
|
</svg>`;
|
|
1053
1053
|
}
|
|
1054
|
+
function colorRgb(value) {
|
|
1055
|
+
if (!value || typeof value !== "string") return null;
|
|
1056
|
+
const rgbMatch = value.trim().match(/^rgba?\(\s*(\d+(?:\.\d+)?)\s*[, ]\s*(\d+(?:\.\d+)?)\s*[, ]\s*(\d+(?:\.\d+)?)/i);
|
|
1057
|
+
if (rgbMatch) {
|
|
1058
|
+
return {
|
|
1059
|
+
r: Math.min(255, Number(rgbMatch[1])),
|
|
1060
|
+
g: Math.min(255, Number(rgbMatch[2])),
|
|
1061
|
+
b: Math.min(255, Number(rgbMatch[3]))
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
let hex = value.trim().replace("#", "");
|
|
1065
|
+
if (hex.length === 3) hex = hex.split("").map((char) => char + char).join("");
|
|
1066
|
+
if (!/^[0-9a-f]{6}$/i.test(hex)) return null;
|
|
1067
|
+
return {
|
|
1068
|
+
r: parseInt(hex.slice(0, 2), 16),
|
|
1069
|
+
g: parseInt(hex.slice(2, 4), 16),
|
|
1070
|
+
b: parseInt(hex.slice(4, 6), 16)
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
function relativeLuminance(value) {
|
|
1074
|
+
const rgb = colorRgb(value);
|
|
1075
|
+
if (!rgb) return null;
|
|
1076
|
+
const channel = (component) => {
|
|
1077
|
+
const normalized = component / 255;
|
|
1078
|
+
return normalized <= 0.03928 ? normalized / 12.92 : Math.pow((normalized + 0.055) / 1.055, 2.4);
|
|
1079
|
+
};
|
|
1080
|
+
return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);
|
|
1081
|
+
}
|
|
1082
|
+
function contrastRatio(a, b) {
|
|
1083
|
+
const first = relativeLuminance(a);
|
|
1084
|
+
const second = relativeLuminance(b);
|
|
1085
|
+
if (first == null || second == null) return 1;
|
|
1086
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
1087
|
+
}
|
|
1088
|
+
function readableForeground(background) {
|
|
1089
|
+
return contrastRatio("#34304a", background) >= contrastRatio("#f6f2fb", background) ? "#34304a" : "#f6f2fb";
|
|
1090
|
+
}
|
|
1091
|
+
function readableColor(color, background, minimum = 3) {
|
|
1092
|
+
if (!colorRgb(color) || contrastRatio(color, background) >= minimum) return color;
|
|
1093
|
+
return readableForeground(background);
|
|
1094
|
+
}
|
|
1095
|
+
function adaptCanvasContrast(background) {
|
|
1096
|
+
if (typeof window === "undefined" || !Array.isArray(window.shapes)) return;
|
|
1097
|
+
const foreground = readableForeground(background);
|
|
1098
|
+
const muted = foreground === "#34304a" ? "#716a7d" : "#c8bddb";
|
|
1099
|
+
window.__canvasContrastColor = foreground;
|
|
1100
|
+
window.__ensureCanvasContrast = readableColor;
|
|
1101
|
+
for (const shape of window.shapes) {
|
|
1102
|
+
if (!shape) continue;
|
|
1103
|
+
if (typeof shape.adaptToBackground === "function") {
|
|
1104
|
+
shape.adaptToBackground(background, foreground, muted);
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
const owner = shape.parentFrame;
|
|
1108
|
+
const generated = !!(shape._diagramType || shape._frameType === "graph" || owner?._diagramType || owner?._frameType === "graph");
|
|
1109
|
+
const fill = shape.options?.fill;
|
|
1110
|
+
const solidFill = fill && fill !== "transparent" && fill !== "none";
|
|
1111
|
+
if (shape.options?.closedFill) {
|
|
1112
|
+
shape.options.outlineStroke = background;
|
|
1113
|
+
if (typeof shape.draw === "function") shape.draw();
|
|
1114
|
+
continue;
|
|
1115
|
+
}
|
|
1116
|
+
if (shape.options?.stroke && (generated || ["#fff", "#ffffff", "#000", "#000000", "#1a1a2e"].includes(shape.options.stroke.toLowerCase()))) {
|
|
1117
|
+
shape.options.stroke = readableColor(shape.options.stroke, background, 3);
|
|
1118
|
+
}
|
|
1119
|
+
if (shape.shapeName === "frame" && generated && shape.options) {
|
|
1120
|
+
shape.options.stroke = muted;
|
|
1121
|
+
}
|
|
1122
|
+
if ("labelColor" in shape && generated) {
|
|
1123
|
+
shape.labelColor = solidFill ? readableColor(shape.labelColor || foreground, fill, 4.5) : foreground;
|
|
1124
|
+
}
|
|
1125
|
+
if (shape.group && generated) {
|
|
1126
|
+
shape.group.querySelectorAll("text").forEach((text) => {
|
|
1127
|
+
const current = text.getAttribute("fill") || foreground;
|
|
1128
|
+
text.setAttribute("fill", solidFill ? readableColor(current, fill, 4.5) : readableColor(current, background, 4.5));
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
if (typeof shape.draw === "function") shape.draw();
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1054
1134
|
function initAIRenderer() {
|
|
1055
1135
|
window.__autoAttach = autoAttach;
|
|
1136
|
+
window.__adaptCanvasContrast = adaptCanvasContrast;
|
|
1056
1137
|
let _seqParser = null;
|
|
1057
1138
|
let _seqPreview = null;
|
|
1058
1139
|
let _seqCanvas = null;
|
|
@@ -1075,7 +1156,7 @@ function initAIRenderer() {
|
|
|
1075
1156
|
}
|
|
1076
1157
|
async function loadStructuredRenderer() {
|
|
1077
1158
|
if (_structured) return;
|
|
1078
|
-
_structured = await import("./MermaidStructuredRenderer-
|
|
1159
|
+
_structured = await import("./MermaidStructuredRenderer-26WGA6YD.js");
|
|
1079
1160
|
}
|
|
1080
1161
|
function mermaidHeader(src) {
|
|
1081
1162
|
return src.split("\n").map((line) => line.trim()).find((line) => line && !line.startsWith("%%"))?.toLowerCase() || "";
|
|
@@ -1163,6 +1244,7 @@ function initAIRenderer() {
|
|
|
1163
1244
|
loadStructuredRenderer();
|
|
1164
1245
|
}
|
|
1165
1246
|
export {
|
|
1247
|
+
adaptCanvasContrast,
|
|
1166
1248
|
autoAttach,
|
|
1167
1249
|
generateFramePreviewSVG,
|
|
1168
1250
|
generatePreviewSVG,
|
|
@@ -1170,4 +1252,4 @@ export {
|
|
|
1170
1252
|
parseMermaid,
|
|
1171
1253
|
renderAIDiagram
|
|
1172
1254
|
};
|
|
1173
|
-
//# sourceMappingURL=AIRenderer-
|
|
1255
|
+
//# sourceMappingURL=AIRenderer-ATIKGFB4.js.map
|