vizmatic 0.1.31 → 0.1.32
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.js +244 -31
- package/dist/index.cjs +13 -6
- package/dist/index.js +13 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3104,7 +3104,8 @@ function Flow({
|
|
|
3104
3104
|
// src/primitives/diagrams.ts
|
|
3105
3105
|
import React6 from "react";
|
|
3106
3106
|
function distributeValues(count, start, end) {
|
|
3107
|
-
if (count <=
|
|
3107
|
+
if (count <= 0) return [];
|
|
3108
|
+
if (count === 1) return [(start + end) / 2];
|
|
3108
3109
|
const step = (end - start) / (count - 1);
|
|
3109
3110
|
return Array.from({ length: count }, (_, index) => start + index * step);
|
|
3110
3111
|
}
|
|
@@ -3216,7 +3217,7 @@ function LayeredNetwork({
|
|
|
3216
3217
|
}).filter(Boolean)
|
|
3217
3218
|
);
|
|
3218
3219
|
const annotationY = showFormula || formula ? height - 84 : height - 26;
|
|
3219
|
-
const annotationElements = annotations.map(
|
|
3220
|
+
const annotationElements = annotations.slice(0, Math.max(0, layerXs.length - 1)).map(
|
|
3220
3221
|
(annotation, index) => label(
|
|
3221
3222
|
`annotation-${index}`,
|
|
3222
3223
|
annotation,
|
|
@@ -3325,12 +3326,18 @@ function GraphDiagram({
|
|
|
3325
3326
|
const layout = new Map(nodes.map((node) => {
|
|
3326
3327
|
const resolvedWidth = node.width ?? nodeWidth;
|
|
3327
3328
|
const resolvedHeight = node.height ?? nodeHeight;
|
|
3329
|
+
const minCx = resolvedWidth / 2;
|
|
3330
|
+
const maxCx = width - resolvedWidth / 2;
|
|
3331
|
+
const minCy = resolvedHeight / 2;
|
|
3332
|
+
const maxCy = height - resolvedHeight / 2;
|
|
3333
|
+
const requestedCx = padding + clamp(node.x, 0, 1) * (width - padding * 2);
|
|
3334
|
+
const requestedCy = padding + clamp(node.y, 0, 1) * (height - padding * 2);
|
|
3328
3335
|
return [node.id, {
|
|
3329
3336
|
...node,
|
|
3330
3337
|
width: resolvedWidth,
|
|
3331
3338
|
height: resolvedHeight,
|
|
3332
|
-
cx:
|
|
3333
|
-
cy:
|
|
3339
|
+
cx: minCx <= maxCx ? clamp(requestedCx, minCx, maxCx) : width / 2,
|
|
3340
|
+
cy: minCy <= maxCy ? clamp(requestedCy, minCy, maxCy) : height / 2
|
|
3334
3341
|
}];
|
|
3335
3342
|
}));
|
|
3336
3343
|
const edgeLayouts = edges.flatMap((edge, index) => {
|
|
@@ -3914,7 +3921,7 @@ function Matrix({
|
|
|
3914
3921
|
borderRadius: 6,
|
|
3915
3922
|
fontSize: 11,
|
|
3916
3923
|
fontWeight: 600,
|
|
3917
|
-
color: colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3924
|
+
color: !colorize ? c.textPrimary : colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3918
3925
|
fontFamily: "JetBrains Mono"
|
|
3919
3926
|
}
|
|
3920
3927
|
}, labels?.[ri]?.[ci] ?? formatValue(value))
|
|
@@ -5068,7 +5075,7 @@ function LineChart({
|
|
|
5068
5075
|
const plot = createPlotArea(width, height, margin);
|
|
5069
5076
|
const allValues = series.flatMap((item) => item.points);
|
|
5070
5077
|
const domain = chartDomain(allValues, min, max);
|
|
5071
|
-
const maxPoints = Math.max(...series.map((item) => item.points.length), 1);
|
|
5078
|
+
const maxPoints = Math.max(labels?.length ?? 0, ...series.map((item) => item.points.length), 1);
|
|
5072
5079
|
const xInset = maxPoints <= 1 ? 0 : Math.min(26, Math.max(14, plot.innerWidth * 0.06));
|
|
5073
5080
|
const xStart = maxPoints <= 1 ? plot.x + plot.innerWidth / 2 : plot.x + xInset;
|
|
5074
5081
|
const xSpan = maxPoints <= 1 ? 0 : Math.max(1, plot.innerWidth - xInset * 2);
|
|
@@ -6489,6 +6496,144 @@ async function renderAnimatedGifWithOutput(scenes, options) {
|
|
|
6489
6496
|
return { width: frames[0].width, height: frames[0].height };
|
|
6490
6497
|
}
|
|
6491
6498
|
|
|
6499
|
+
// src/bare-source.ts
|
|
6500
|
+
function readJsxTag(source, start) {
|
|
6501
|
+
if (source.startsWith("<>", start)) return { closing: false, end: start + 2, selfClosing: false };
|
|
6502
|
+
if (source.startsWith("</>", start)) return { closing: true, end: start + 3, selfClosing: false };
|
|
6503
|
+
const head = source.slice(start).match(/^<\s*(\/\s*)?[A-Za-z][\w.:$-]*/);
|
|
6504
|
+
if (!head) return void 0;
|
|
6505
|
+
const closing = Boolean(head[1]);
|
|
6506
|
+
let quote;
|
|
6507
|
+
let braces = 0;
|
|
6508
|
+
let escaped = false;
|
|
6509
|
+
for (let index = start + head[0].length; index < source.length; index += 1) {
|
|
6510
|
+
const character = source[index];
|
|
6511
|
+
if (quote) {
|
|
6512
|
+
if (escaped) escaped = false;
|
|
6513
|
+
else if (character === "\\") escaped = true;
|
|
6514
|
+
else if (character === quote) quote = void 0;
|
|
6515
|
+
continue;
|
|
6516
|
+
}
|
|
6517
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
6518
|
+
quote = character;
|
|
6519
|
+
continue;
|
|
6520
|
+
}
|
|
6521
|
+
if (character === "{") {
|
|
6522
|
+
braces += 1;
|
|
6523
|
+
continue;
|
|
6524
|
+
}
|
|
6525
|
+
if (character === "}") {
|
|
6526
|
+
braces = Math.max(0, braces - 1);
|
|
6527
|
+
continue;
|
|
6528
|
+
}
|
|
6529
|
+
if (character !== ">" || braces > 0) continue;
|
|
6530
|
+
const beforeClose = source.slice(start, index).trimEnd();
|
|
6531
|
+
return {
|
|
6532
|
+
closing,
|
|
6533
|
+
end: index + 1,
|
|
6534
|
+
selfClosing: !closing && beforeClose.endsWith("/")
|
|
6535
|
+
};
|
|
6536
|
+
}
|
|
6537
|
+
return void 0;
|
|
6538
|
+
}
|
|
6539
|
+
function skipJsxExpression(source, start) {
|
|
6540
|
+
let depth = 0;
|
|
6541
|
+
let quote;
|
|
6542
|
+
let escaped = false;
|
|
6543
|
+
let blockComment = false;
|
|
6544
|
+
let lineComment = false;
|
|
6545
|
+
for (let index = start; index < source.length; index += 1) {
|
|
6546
|
+
const character = source[index];
|
|
6547
|
+
const next = source[index + 1];
|
|
6548
|
+
if (lineComment) {
|
|
6549
|
+
if (character === "\n") lineComment = false;
|
|
6550
|
+
continue;
|
|
6551
|
+
}
|
|
6552
|
+
if (blockComment) {
|
|
6553
|
+
if (character === "*" && next === "/") {
|
|
6554
|
+
blockComment = false;
|
|
6555
|
+
index += 1;
|
|
6556
|
+
}
|
|
6557
|
+
continue;
|
|
6558
|
+
}
|
|
6559
|
+
if (quote) {
|
|
6560
|
+
if (escaped) escaped = false;
|
|
6561
|
+
else if (character === "\\") escaped = true;
|
|
6562
|
+
else if (character === quote) quote = void 0;
|
|
6563
|
+
continue;
|
|
6564
|
+
}
|
|
6565
|
+
if (character === "/" && next === "/") {
|
|
6566
|
+
lineComment = true;
|
|
6567
|
+
index += 1;
|
|
6568
|
+
continue;
|
|
6569
|
+
}
|
|
6570
|
+
if (character === "/" && next === "*") {
|
|
6571
|
+
blockComment = true;
|
|
6572
|
+
index += 1;
|
|
6573
|
+
continue;
|
|
6574
|
+
}
|
|
6575
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
6576
|
+
quote = character;
|
|
6577
|
+
continue;
|
|
6578
|
+
}
|
|
6579
|
+
if (character === "{") depth += 1;
|
|
6580
|
+
else if (character === "}" && --depth === 0) return index + 1;
|
|
6581
|
+
}
|
|
6582
|
+
return void 0;
|
|
6583
|
+
}
|
|
6584
|
+
function findJsxEnd(source, start) {
|
|
6585
|
+
let depth = 0;
|
|
6586
|
+
for (let index = start; index < source.length; index += 1) {
|
|
6587
|
+
if (source[index] === "{") {
|
|
6588
|
+
const expressionEnd = skipJsxExpression(source, index);
|
|
6589
|
+
if (expressionEnd == null) return void 0;
|
|
6590
|
+
index = expressionEnd - 1;
|
|
6591
|
+
continue;
|
|
6592
|
+
}
|
|
6593
|
+
if (source[index] !== "<") continue;
|
|
6594
|
+
const tag = readJsxTag(source, index);
|
|
6595
|
+
if (!tag) continue;
|
|
6596
|
+
if (tag.closing) depth -= 1;
|
|
6597
|
+
else if (!tag.selfClosing) depth += 1;
|
|
6598
|
+
index = tag.end - 1;
|
|
6599
|
+
if (depth === 0) return tag.end;
|
|
6600
|
+
}
|
|
6601
|
+
return void 0;
|
|
6602
|
+
}
|
|
6603
|
+
function hasOnlyTrailingSyntax(source) {
|
|
6604
|
+
let index = 0;
|
|
6605
|
+
while (index < source.length) {
|
|
6606
|
+
const rest = source.slice(index);
|
|
6607
|
+
const whitespace = rest.match(/^[\s;)]*/)?.[0].length ?? 0;
|
|
6608
|
+
index += whitespace;
|
|
6609
|
+
if (source.startsWith("//", index)) {
|
|
6610
|
+
const newline = source.indexOf("\n", index + 2);
|
|
6611
|
+
index = newline < 0 ? source.length : newline + 1;
|
|
6612
|
+
continue;
|
|
6613
|
+
}
|
|
6614
|
+
if (source.startsWith("/*", index)) {
|
|
6615
|
+
const end = source.indexOf("*/", index + 2);
|
|
6616
|
+
if (end < 0) return false;
|
|
6617
|
+
index = end + 2;
|
|
6618
|
+
continue;
|
|
6619
|
+
}
|
|
6620
|
+
return index >= source.length;
|
|
6621
|
+
}
|
|
6622
|
+
return true;
|
|
6623
|
+
}
|
|
6624
|
+
function findBareRootJsxStart(source) {
|
|
6625
|
+
const candidates = source.matchAll(/(^|\n)([\t ]*)(?:(?:export\s+default\s+)?(?:\(\s*)*)(<(?:[A-Z]|>))/g);
|
|
6626
|
+
for (const candidate of candidates) {
|
|
6627
|
+
if (candidate.index == null) continue;
|
|
6628
|
+
const lineStart = candidate.index + (candidate[1]?.length ?? 0);
|
|
6629
|
+
const expressionStart = lineStart + (candidate[2]?.length ?? 0);
|
|
6630
|
+
const jsxStart = candidate.index + candidate[0].lastIndexOf(candidate[3] ?? "<");
|
|
6631
|
+
const jsxEnd = findJsxEnd(source, jsxStart);
|
|
6632
|
+
if (jsxEnd != null && hasOnlyTrailingSyntax(source.slice(jsxEnd))) return expressionStart;
|
|
6633
|
+
}
|
|
6634
|
+
return -1;
|
|
6635
|
+
}
|
|
6636
|
+
|
|
6492
6637
|
// src/diagnostics.ts
|
|
6493
6638
|
import parseCssColor2 from "parse-css-color";
|
|
6494
6639
|
import { Children, isValidElement } from "react";
|
|
@@ -6540,6 +6685,19 @@ function numericFontWeight(value) {
|
|
|
6540
6685
|
if (typeof value === "string" && /^\d+$/.test(value)) return Number(value);
|
|
6541
6686
|
return void 0;
|
|
6542
6687
|
}
|
|
6688
|
+
function fontSizePixels(value, inherited) {
|
|
6689
|
+
if (typeof value === "number") return value;
|
|
6690
|
+
if (typeof value !== "string") return inherited;
|
|
6691
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|pt|rem|em|%)?$/);
|
|
6692
|
+
if (!match?.[1]) return inherited;
|
|
6693
|
+
const amount = Number(match[1]);
|
|
6694
|
+
const unit = match[2] ?? "px";
|
|
6695
|
+
if (unit === "pt") return amount * 4 / 3;
|
|
6696
|
+
if (unit === "rem") return amount * 16;
|
|
6697
|
+
if (unit === "em") return amount * (inherited ?? 16);
|
|
6698
|
+
if (unit === "%") return amount / 100 * (inherited ?? 16);
|
|
6699
|
+
return amount;
|
|
6700
|
+
}
|
|
6543
6701
|
function requiredContrast(context) {
|
|
6544
6702
|
const large = (context.fontSize ?? 16) >= 24 || (context.fontSize ?? 16) >= 18.66 && (context.fontWeight ?? 400) >= 700;
|
|
6545
6703
|
return large ? 3 : 4.5;
|
|
@@ -6562,7 +6720,7 @@ function resolveFunctionComponent(node, trustedComponents) {
|
|
|
6562
6720
|
return void 0;
|
|
6563
6721
|
}
|
|
6564
6722
|
}
|
|
6565
|
-
function analyzeContrast(element, theme, trustedComponents = /* @__PURE__ */ new Set()) {
|
|
6723
|
+
function analyzeContrast(element, theme, trustedComponents = /* @__PURE__ */ new Set(), rootBackground) {
|
|
6566
6724
|
const diagnostics = [];
|
|
6567
6725
|
const seen = /* @__PURE__ */ new Set();
|
|
6568
6726
|
let visited = 0;
|
|
@@ -6577,7 +6735,7 @@ function analyzeContrast(element, theme, trustedComponents = /* @__PURE__ */ new
|
|
|
6577
6735
|
const style = typeof node.type === "string" ? styleRecord(props.style) : {};
|
|
6578
6736
|
const background = colorFromCss(style.backgroundColor) ?? colorFromCss(style.background) ?? inherited.background;
|
|
6579
6737
|
const color = colorFromCss(style.color) ?? inherited.color;
|
|
6580
|
-
const fontSize =
|
|
6738
|
+
const fontSize = fontSizePixels(style.fontSize, inherited.fontSize);
|
|
6581
6739
|
const fontWeight = numericFontWeight(style.fontWeight) ?? inherited.fontWeight;
|
|
6582
6740
|
const context = { background, color, fontSize, fontWeight };
|
|
6583
6741
|
if (typeof node.type === "string" && hasDirectText(props.children) && color && background) {
|
|
@@ -6600,7 +6758,7 @@ function analyzeContrast(element, theme, trustedComponents = /* @__PURE__ */ new
|
|
|
6600
6758
|
}
|
|
6601
6759
|
Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`));
|
|
6602
6760
|
}
|
|
6603
|
-
visit(element, {}, "root");
|
|
6761
|
+
visit(element, { background: colorFromCss(rootBackground) }, "root");
|
|
6604
6762
|
return diagnostics;
|
|
6605
6763
|
}
|
|
6606
6764
|
function diagnosticFromMessage(message, severity, theme) {
|
|
@@ -6841,10 +6999,18 @@ function readFrameDimension(jsx, name) {
|
|
|
6841
6999
|
const raw = value?.[1] ?? value?.[2] ?? value?.[3] ?? value?.[4];
|
|
6842
7000
|
return raw ? Number(raw) : void 0;
|
|
6843
7001
|
}
|
|
6844
|
-
function
|
|
6845
|
-
const match =
|
|
6846
|
-
|
|
6847
|
-
|
|
7002
|
+
function staticImportSource(statement) {
|
|
7003
|
+
const match = statement.trim().match(/(?:\bfrom\s+)?(["'])([^"']+)\1\s*;?(?:\s*\/\/.*)?$/s);
|
|
7004
|
+
return match?.[2];
|
|
7005
|
+
}
|
|
7006
|
+
function readStaticImport(lines, start) {
|
|
7007
|
+
const statement = [lines[start]];
|
|
7008
|
+
let end = start;
|
|
7009
|
+
while (staticImportSource(statement.join("\n")) == null && end + 1 < lines.length) {
|
|
7010
|
+
end += 1;
|
|
7011
|
+
statement.push(lines[end]);
|
|
7012
|
+
}
|
|
7013
|
+
return { statement: statement.join("\n"), end };
|
|
6848
7014
|
}
|
|
6849
7015
|
function bareFrameAlias(name) {
|
|
6850
7016
|
return `__Vizmatic_${name}`;
|
|
@@ -6878,37 +7044,59 @@ function buildBareFrameModule(framePath, source) {
|
|
|
6878
7044
|
let width;
|
|
6879
7045
|
let height;
|
|
6880
7046
|
let preset = "default";
|
|
6881
|
-
|
|
7047
|
+
const lines = source.split(/\r?\n/);
|
|
7048
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
7049
|
+
const line = lines[index];
|
|
6882
7050
|
const trimmed = line.trim();
|
|
6883
7051
|
if (trimmed.startsWith("import ")) {
|
|
6884
|
-
|
|
6885
|
-
|
|
7052
|
+
const imported = readStaticImport(lines, index);
|
|
7053
|
+
const specifier = staticImportSource(imported.statement);
|
|
7054
|
+
if (specifier !== "react" && specifier !== "vizmatic") {
|
|
7055
|
+
imports.push(rewriteRelativeImports(imported.statement, framePath));
|
|
6886
7056
|
}
|
|
7057
|
+
index = imported.end;
|
|
6887
7058
|
continue;
|
|
6888
7059
|
}
|
|
6889
|
-
|
|
7060
|
+
bodyLines.push(line);
|
|
7061
|
+
}
|
|
7062
|
+
const body = bodyLines.join("\n");
|
|
7063
|
+
const jsxStart = findBareRootJsxStart(body);
|
|
7064
|
+
if (jsxStart < 0) return void 0;
|
|
7065
|
+
const setupLines = [];
|
|
7066
|
+
let metadataPreamble = true;
|
|
7067
|
+
let metadataBlockComment = false;
|
|
7068
|
+
for (const line of body.slice(0, jsxStart).split(/\r?\n/)) {
|
|
7069
|
+
const trimmed = line.trim();
|
|
7070
|
+
if (metadataBlockComment) {
|
|
7071
|
+
if (trimmed.includes("*/")) metadataBlockComment = false;
|
|
7072
|
+
setupLines.push(line);
|
|
7073
|
+
continue;
|
|
7074
|
+
}
|
|
7075
|
+
if (trimmed.startsWith("/*")) {
|
|
7076
|
+
metadataBlockComment = !trimmed.slice(2).includes("*/");
|
|
7077
|
+
setupLines.push(line);
|
|
7078
|
+
continue;
|
|
7079
|
+
}
|
|
7080
|
+
const dimension = metadataPreamble ? readDimensionLine(line) : void 0;
|
|
6890
7081
|
if (dimension) {
|
|
6891
7082
|
if (dimension.name === "width") width = dimension.value;
|
|
6892
7083
|
if (dimension.name === "height") height = dimension.value;
|
|
6893
7084
|
continue;
|
|
6894
7085
|
}
|
|
6895
|
-
const framePreset = readPresetLine(line);
|
|
7086
|
+
const framePreset = metadataPreamble ? readPresetLine(line) : void 0;
|
|
6896
7087
|
if (framePreset) {
|
|
6897
|
-
if (framePreset.preset)
|
|
6898
|
-
|
|
6899
|
-
} else {
|
|
7088
|
+
if (framePreset.preset) preset = framePreset.preset;
|
|
7089
|
+
else {
|
|
6900
7090
|
console.warn(
|
|
6901
7091
|
`warning: Unknown preset ${JSON.stringify(framePreset.requested)}; using "default". Available presets: "default", "engineering".`
|
|
6902
7092
|
);
|
|
6903
7093
|
}
|
|
6904
7094
|
continue;
|
|
6905
7095
|
}
|
|
6906
|
-
|
|
7096
|
+
if (trimmed && !trimmed.startsWith("//")) metadataPreamble = false;
|
|
7097
|
+
setupLines.push(line);
|
|
6907
7098
|
}
|
|
6908
|
-
const
|
|
6909
|
-
const jsxStart = findRootJsxStart(body);
|
|
6910
|
-
if (jsxStart < 0) return void 0;
|
|
6911
|
-
const setup = body.slice(0, jsxStart).replace(/^\s*export\s+/gm, "");
|
|
7099
|
+
const setup = setupLines.join("\n").replace(/^\s*export\s+/gm, "");
|
|
6912
7100
|
const jsx = body.slice(jsxStart).trim().replace(/^export\s+default\s+/, "").replace(/;\s*$/, "");
|
|
6913
7101
|
const frameWidth = readFrameDimension(jsx, "width");
|
|
6914
7102
|
const frameHeight = readFrameDimension(jsx, "height");
|
|
@@ -6953,8 +7141,7 @@ function isBareFrameSource(source) {
|
|
|
6953
7141
|
if (/\bdefineIllustration\s*\(/.test(source)) return false;
|
|
6954
7142
|
if (/\bcreateScenes\s*\(/.test(source)) return false;
|
|
6955
7143
|
if (/\bexport\s+(?:const|function)\s+create\b/.test(source)) return false;
|
|
6956
|
-
|
|
6957
|
-
return findRootJsxStart(body) >= 0;
|
|
7144
|
+
return findBareRootJsxStart(source) >= 0;
|
|
6958
7145
|
}
|
|
6959
7146
|
async function importBareFrame(filePath, source) {
|
|
6960
7147
|
source ??= await readFile2(filePath, "utf8");
|
|
@@ -7218,7 +7405,7 @@ function normalizeAutoSize(value, defaults) {
|
|
|
7218
7405
|
return defaults;
|
|
7219
7406
|
}
|
|
7220
7407
|
function normalizeFrameModule(mod) {
|
|
7221
|
-
const defaultObject = typeof mod.default === "object" && mod.default && "create" in mod.default ? mod.default : void 0;
|
|
7408
|
+
const defaultObject = typeof mod.default === "object" && mod.default && !isValidElement2(mod.default) && ("create" in mod.default || "default" in mod.default) ? mod.default : void 0;
|
|
7222
7409
|
const hasAutoSizeSetting = mod.autoSize != null || mod.__vizmaticAutoSize != null;
|
|
7223
7410
|
const hasWidth = mod.width != null || defaultObject?.width != null;
|
|
7224
7411
|
const hasHeight = mod.height != null || defaultObject?.height != null;
|
|
@@ -7380,6 +7567,21 @@ async function captureConsole(run) {
|
|
|
7380
7567
|
console.warn = original.warn;
|
|
7381
7568
|
}
|
|
7382
7569
|
}
|
|
7570
|
+
function suppressConsoleOutput() {
|
|
7571
|
+
const original = {
|
|
7572
|
+
error: console.error,
|
|
7573
|
+
log: console.log,
|
|
7574
|
+
warn: console.warn
|
|
7575
|
+
};
|
|
7576
|
+
console.error = () => void 0;
|
|
7577
|
+
console.log = () => void 0;
|
|
7578
|
+
console.warn = () => void 0;
|
|
7579
|
+
return () => {
|
|
7580
|
+
console.error = original.error;
|
|
7581
|
+
console.log = original.log;
|
|
7582
|
+
console.warn = original.warn;
|
|
7583
|
+
};
|
|
7584
|
+
}
|
|
7383
7585
|
function checkDiagnosticCounts(files) {
|
|
7384
7586
|
const diagnostics = files.flatMap((file) => [
|
|
7385
7587
|
...file.diagnostics,
|
|
@@ -7411,6 +7613,15 @@ function printCheckReport(files) {
|
|
|
7411
7613
|
}
|
|
7412
7614
|
async function checkCommand(argv) {
|
|
7413
7615
|
const args = parseCheckArgs(argv);
|
|
7616
|
+
const restoreConsole = args.json ? suppressConsoleOutput() : void 0;
|
|
7617
|
+
try {
|
|
7618
|
+
await checkCommandWithArgs(args);
|
|
7619
|
+
} catch (error) {
|
|
7620
|
+
restoreConsole?.();
|
|
7621
|
+
throw error;
|
|
7622
|
+
}
|
|
7623
|
+
}
|
|
7624
|
+
async function checkCommandWithArgs(args) {
|
|
7414
7625
|
const files = await findFrameFiles(args.inputs);
|
|
7415
7626
|
if (files.length === 0) throw new Error("no frame files found");
|
|
7416
7627
|
const tempDir = await mkdtemp(join2(tmpdir(), "vizmatic-check-"));
|
|
@@ -7438,7 +7649,8 @@ async function checkCommand(argv) {
|
|
|
7438
7649
|
const themeDiagnostics = [];
|
|
7439
7650
|
const prepared = await captureConsole(async () => {
|
|
7440
7651
|
const element = frameElement(mod, theme);
|
|
7441
|
-
|
|
7652
|
+
const rootBackground = args.background === "theme" ? getThemeColors(theme).bg : args.background === "transparent" ? void 0 : args.background;
|
|
7653
|
+
return analyzeContrast(element, theme, CONTRAST_TRUSTED_COMPONENTS, rootBackground);
|
|
7442
7654
|
});
|
|
7443
7655
|
themeDiagnostics.push(...prepared.messages.map(
|
|
7444
7656
|
(message) => diagnosticFromMessage(message.message, message.severity, theme)
|
|
@@ -7541,7 +7753,8 @@ async function checkCommand(argv) {
|
|
|
7541
7753
|
}
|
|
7542
7754
|
};
|
|
7543
7755
|
if (args.json) {
|
|
7544
|
-
|
|
7756
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
7757
|
+
`);
|
|
7545
7758
|
} else {
|
|
7546
7759
|
printCheckReport(reports);
|
|
7547
7760
|
console.log(`checked ${report.summary.files} file(s): ${summary.errors} error(s), ${summary.warnings} warning(s), ${summary.info} info`);
|
package/dist/index.cjs
CHANGED
|
@@ -3118,7 +3118,8 @@ function Flow({
|
|
|
3118
3118
|
// src/primitives/diagrams.ts
|
|
3119
3119
|
var import_react6 = __toESM(require("react"), 1);
|
|
3120
3120
|
function distributeValues(count, start, end) {
|
|
3121
|
-
if (count <=
|
|
3121
|
+
if (count <= 0) return [];
|
|
3122
|
+
if (count === 1) return [(start + end) / 2];
|
|
3122
3123
|
const step = (end - start) / (count - 1);
|
|
3123
3124
|
return Array.from({ length: count }, (_, index) => start + index * step);
|
|
3124
3125
|
}
|
|
@@ -3230,7 +3231,7 @@ function LayeredNetwork({
|
|
|
3230
3231
|
}).filter(Boolean)
|
|
3231
3232
|
);
|
|
3232
3233
|
const annotationY = showFormula || formula ? height - 84 : height - 26;
|
|
3233
|
-
const annotationElements = annotations.map(
|
|
3234
|
+
const annotationElements = annotations.slice(0, Math.max(0, layerXs.length - 1)).map(
|
|
3234
3235
|
(annotation, index) => label(
|
|
3235
3236
|
`annotation-${index}`,
|
|
3236
3237
|
annotation,
|
|
@@ -3339,12 +3340,18 @@ function GraphDiagram({
|
|
|
3339
3340
|
const layout = new Map(nodes.map((node) => {
|
|
3340
3341
|
const resolvedWidth = node.width ?? nodeWidth;
|
|
3341
3342
|
const resolvedHeight = node.height ?? nodeHeight;
|
|
3343
|
+
const minCx = resolvedWidth / 2;
|
|
3344
|
+
const maxCx = width - resolvedWidth / 2;
|
|
3345
|
+
const minCy = resolvedHeight / 2;
|
|
3346
|
+
const maxCy = height - resolvedHeight / 2;
|
|
3347
|
+
const requestedCx = padding + clamp(node.x, 0, 1) * (width - padding * 2);
|
|
3348
|
+
const requestedCy = padding + clamp(node.y, 0, 1) * (height - padding * 2);
|
|
3342
3349
|
return [node.id, {
|
|
3343
3350
|
...node,
|
|
3344
3351
|
width: resolvedWidth,
|
|
3345
3352
|
height: resolvedHeight,
|
|
3346
|
-
cx:
|
|
3347
|
-
cy:
|
|
3353
|
+
cx: minCx <= maxCx ? clamp(requestedCx, minCx, maxCx) : width / 2,
|
|
3354
|
+
cy: minCy <= maxCy ? clamp(requestedCy, minCy, maxCy) : height / 2
|
|
3348
3355
|
}];
|
|
3349
3356
|
}));
|
|
3350
3357
|
const edgeLayouts = edges.flatMap((edge, index) => {
|
|
@@ -3928,7 +3935,7 @@ function Matrix({
|
|
|
3928
3935
|
borderRadius: 6,
|
|
3929
3936
|
fontSize: 11,
|
|
3930
3937
|
fontWeight: 600,
|
|
3931
|
-
color: colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3938
|
+
color: !colorize ? c.textPrimary : colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3932
3939
|
fontFamily: "JetBrains Mono"
|
|
3933
3940
|
}
|
|
3934
3941
|
}, labels?.[ri]?.[ci] ?? formatValue(value))
|
|
@@ -5082,7 +5089,7 @@ function LineChart({
|
|
|
5082
5089
|
const plot = createPlotArea(width, height, margin);
|
|
5083
5090
|
const allValues = series.flatMap((item) => item.points);
|
|
5084
5091
|
const domain = chartDomain(allValues, min, max);
|
|
5085
|
-
const maxPoints = Math.max(...series.map((item) => item.points.length), 1);
|
|
5092
|
+
const maxPoints = Math.max(labels?.length ?? 0, ...series.map((item) => item.points.length), 1);
|
|
5086
5093
|
const xInset = maxPoints <= 1 ? 0 : Math.min(26, Math.max(14, plot.innerWidth * 0.06));
|
|
5087
5094
|
const xStart = maxPoints <= 1 ? plot.x + plot.innerWidth / 2 : plot.x + xInset;
|
|
5088
5095
|
const xSpan = maxPoints <= 1 ? 0 : Math.max(1, plot.innerWidth - xInset * 2);
|
package/dist/index.js
CHANGED
|
@@ -2984,7 +2984,8 @@ function Flow({
|
|
|
2984
2984
|
// src/primitives/diagrams.ts
|
|
2985
2985
|
import React6 from "react";
|
|
2986
2986
|
function distributeValues(count, start, end) {
|
|
2987
|
-
if (count <=
|
|
2987
|
+
if (count <= 0) return [];
|
|
2988
|
+
if (count === 1) return [(start + end) / 2];
|
|
2988
2989
|
const step = (end - start) / (count - 1);
|
|
2989
2990
|
return Array.from({ length: count }, (_, index) => start + index * step);
|
|
2990
2991
|
}
|
|
@@ -3096,7 +3097,7 @@ function LayeredNetwork({
|
|
|
3096
3097
|
}).filter(Boolean)
|
|
3097
3098
|
);
|
|
3098
3099
|
const annotationY = showFormula || formula ? height - 84 : height - 26;
|
|
3099
|
-
const annotationElements = annotations.map(
|
|
3100
|
+
const annotationElements = annotations.slice(0, Math.max(0, layerXs.length - 1)).map(
|
|
3100
3101
|
(annotation, index) => label(
|
|
3101
3102
|
`annotation-${index}`,
|
|
3102
3103
|
annotation,
|
|
@@ -3205,12 +3206,18 @@ function GraphDiagram({
|
|
|
3205
3206
|
const layout = new Map(nodes.map((node) => {
|
|
3206
3207
|
const resolvedWidth = node.width ?? nodeWidth;
|
|
3207
3208
|
const resolvedHeight = node.height ?? nodeHeight;
|
|
3209
|
+
const minCx = resolvedWidth / 2;
|
|
3210
|
+
const maxCx = width - resolvedWidth / 2;
|
|
3211
|
+
const minCy = resolvedHeight / 2;
|
|
3212
|
+
const maxCy = height - resolvedHeight / 2;
|
|
3213
|
+
const requestedCx = padding + clamp(node.x, 0, 1) * (width - padding * 2);
|
|
3214
|
+
const requestedCy = padding + clamp(node.y, 0, 1) * (height - padding * 2);
|
|
3208
3215
|
return [node.id, {
|
|
3209
3216
|
...node,
|
|
3210
3217
|
width: resolvedWidth,
|
|
3211
3218
|
height: resolvedHeight,
|
|
3212
|
-
cx:
|
|
3213
|
-
cy:
|
|
3219
|
+
cx: minCx <= maxCx ? clamp(requestedCx, minCx, maxCx) : width / 2,
|
|
3220
|
+
cy: minCy <= maxCy ? clamp(requestedCy, minCy, maxCy) : height / 2
|
|
3214
3221
|
}];
|
|
3215
3222
|
}));
|
|
3216
3223
|
const edgeLayouts = edges.flatMap((edge, index) => {
|
|
@@ -3794,7 +3801,7 @@ function Matrix({
|
|
|
3794
3801
|
borderRadius: 6,
|
|
3795
3802
|
fontSize: 11,
|
|
3796
3803
|
fontWeight: 600,
|
|
3797
|
-
color: colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3804
|
+
color: !colorize ? c.textPrimary : colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3798
3805
|
fontFamily: "JetBrains Mono"
|
|
3799
3806
|
}
|
|
3800
3807
|
}, labels?.[ri]?.[ci] ?? formatValue(value))
|
|
@@ -4948,7 +4955,7 @@ function LineChart({
|
|
|
4948
4955
|
const plot = createPlotArea(width, height, margin);
|
|
4949
4956
|
const allValues = series.flatMap((item) => item.points);
|
|
4950
4957
|
const domain = chartDomain(allValues, min, max);
|
|
4951
|
-
const maxPoints = Math.max(...series.map((item) => item.points.length), 1);
|
|
4958
|
+
const maxPoints = Math.max(labels?.length ?? 0, ...series.map((item) => item.points.length), 1);
|
|
4952
4959
|
const xInset = maxPoints <= 1 ? 0 : Math.min(26, Math.max(14, plot.innerWidth * 0.06));
|
|
4953
4960
|
const xStart = maxPoints <= 1 ? plot.x + plot.innerWidth / 2 : plot.x + xInset;
|
|
4954
4961
|
const xSpan = maxPoints <= 1 ? 0 : Math.max(1, plot.innerWidth - xInset * 2);
|
package/package.json
CHANGED