@elixpo/lixsketch 5.5.12 → 5.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/react/{AIRenderer-PWWLWI6U.js → AIRenderer-ATIKGFB4.js} +90 -8
  2. package/dist/react/{AIRenderer-PWWLWI6U.js.map → AIRenderer-ATIKGFB4.js.map} +2 -2
  3. package/dist/react/{CopyPaste-SA72NDFN.js → CopyPaste-VUM5WRDX.js} +2 -2
  4. package/dist/react/FreehandStroke-JKTCTOKU.js +8 -0
  5. package/dist/react/{GraphEngine-IHRVGUGG.js → GraphEngine-KQXHNTZQ.js} +39 -1
  6. package/dist/react/{GraphEngine-IHRVGUGG.js.map → GraphEngine-KQXHNTZQ.js.map} +2 -2
  7. package/dist/react/{MermaidStructuredRenderer-GGOOGON5.js → MermaidStructuredRenderer-26WGA6YD.js} +152 -25
  8. package/dist/react/MermaidStructuredRenderer-26WGA6YD.js.map +7 -0
  9. package/dist/react/{SceneSerializer-ZPHV6IUP.js → SceneSerializer-3RWFYSLY.js} +2 -2
  10. package/dist/react/{SketchEngine-NPF2XN6Z.js → SketchEngine-WW5LIHNT.js} +6 -6
  11. package/dist/react/{chunk-YKJUBFHE.js → chunk-ABZEV54U.js} +23 -2
  12. package/dist/react/chunk-ABZEV54U.js.map +7 -0
  13. package/dist/react/index.js +26 -18
  14. package/dist/react/index.js.map +2 -2
  15. package/dist/react/styles.css +10 -3
  16. package/package.json +1 -1
  17. package/src/core/AIRenderer.js +104 -6
  18. package/src/core/GraphEngine.js +45 -0
  19. package/src/core/MermaidStructuredRenderer.js +162 -22
  20. package/src/react/LixSketchCanvas.jsx +4 -0
  21. package/src/react/components/AppMenu.jsx +2 -2
  22. package/src/react/components/Toolbar.jsx +1 -1
  23. package/src/react/components/modals/CommandPalette.jsx +3 -3
  24. package/src/react/components/sidebars/FrameSidebar.jsx +1 -1
  25. package/src/react/components/sidebars/IconSidebar.jsx +2 -2
  26. package/src/react/components/sidebars/ShapeSidebar.jsx +1 -1
  27. package/src/react/store/useSketchStore.js +7 -2
  28. package/src/react/store/useUIStore.js +3 -4
  29. package/src/react/styles.css +12 -3
  30. package/src/shapes/FreehandStroke.js +28 -3
  31. package/dist/react/FreehandStroke-CK24NUT3.js +0 -8
  32. package/dist/react/MermaidStructuredRenderer-GGOOGON5.js.map +0 -7
  33. package/dist/react/chunk-YKJUBFHE.js.map +0 -7
  34. /package/dist/react/{CopyPaste-SA72NDFN.js.map → CopyPaste-VUM5WRDX.js.map} +0 -0
  35. /package/dist/react/{FreehandStroke-CK24NUT3.js.map → FreehandStroke-JKTCTOKU.js.map} +0 -0
  36. /package/dist/react/{SceneSerializer-ZPHV6IUP.js.map → SceneSerializer-3RWFYSLY.js.map} +0 -0
  37. /package/dist/react/{SketchEngine-NPF2XN6Z.js.map → SketchEngine-WW5LIHNT.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: "#e8f3ec", stroke: "#5f836c" },
24
- { fill: "#f6eadf", stroke: "#a97852" },
25
- { fill: "#eee9f4", stroke: "#7e6b91" },
26
- { fill: "#f5efcf", stroke: "#9a8745" },
27
- { fill: "#e5f0f1", stroke: "#5d7f82" },
28
- { fill: "#f4e5e3", stroke: "#9a6863" }
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-GGOOGON5.js");
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-PWWLWI6U.js.map
1255
+ //# sourceMappingURL=AIRenderer-ATIKGFB4.js.map