yumiamd 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/bin.js +1 -1
- package/dist/{chunk-VMBKNPA7.js → chunk-Y2OWK5OP.js} +180 -120
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +10 -10
package/dist/bin.js
CHANGED
|
@@ -2193,7 +2193,7 @@ var NativeYumiaParser = class {
|
|
|
2193
2193
|
}
|
|
2194
2194
|
} else if (dLine.startsWith("node ")) {
|
|
2195
2195
|
const nParts = dLine.slice(5).trim();
|
|
2196
|
-
const nIdMatch = nParts.match(/^(\
|
|
2196
|
+
const nIdMatch = nParts.match(/^(\[[^\]]+\]|\([^)]+\)|\{[^}]+\}|[a-zA-Z0-9_-]+(?:\[\([^)]+\)\]|\(\([^)]+\)\)|\[[^\]]+\]|\{[^}]+\})?)/);
|
|
2197
2197
|
const nLabelMatch = nParts.match(/\blabel=["']([^"']+)["']/);
|
|
2198
2198
|
const nShapeMatch = nParts.match(/\bshape=["']?([^"'\s]+)["']?/);
|
|
2199
2199
|
const nVarMatch = nParts.match(/\bvariant=["']?([^"'\s]+)["']?/);
|
|
@@ -2202,6 +2202,7 @@ var NativeYumiaParser = class {
|
|
|
2202
2202
|
const explicitLabel = nLabelMatch ? nLabelMatch[1] : void 0;
|
|
2203
2203
|
const node = ensureNode(nId, nShapeMatch ? nShapeMatch[1] : void 0, nVarMatch ? nVarMatch[1] : void 0, explicitLabel);
|
|
2204
2204
|
nodeMap.set(nId.toLowerCase(), node);
|
|
2205
|
+
nodeMap.set(node.id, node);
|
|
2205
2206
|
}
|
|
2206
2207
|
}
|
|
2207
2208
|
nextIdx++;
|
|
@@ -2753,9 +2754,17 @@ function computeDiagramLayout(diagram, availableWidth, isLR = (diagram.direction
|
|
|
2753
2754
|
};
|
|
2754
2755
|
if (nodeIds.length === 0)
|
|
2755
2756
|
return empty;
|
|
2757
|
+
const connected = /* @__PURE__ */ new Set();
|
|
2758
|
+
diagram.edges.forEach((e) => {
|
|
2759
|
+
connected.add(e.from);
|
|
2760
|
+
connected.add(e.to);
|
|
2761
|
+
});
|
|
2762
|
+
const activeIds = connected.size > 0 ? nodeIds.filter((id) => connected.has(id)) : nodeIds;
|
|
2763
|
+
if (activeIds.length === 0)
|
|
2764
|
+
return empty;
|
|
2756
2765
|
const inDegree = {};
|
|
2757
2766
|
const adj = {};
|
|
2758
|
-
|
|
2767
|
+
activeIds.forEach((id) => {
|
|
2759
2768
|
inDegree[id] = 0;
|
|
2760
2769
|
adj[id] = [];
|
|
2761
2770
|
});
|
|
@@ -2769,20 +2778,20 @@ function computeDiagramLayout(diagram, availableWidth, isLR = (diagram.direction
|
|
|
2769
2778
|
});
|
|
2770
2779
|
const ranks = {};
|
|
2771
2780
|
const queue = [];
|
|
2772
|
-
const visitBudget = Math.max(4,
|
|
2781
|
+
const visitBudget = Math.max(4, activeIds.length * 2);
|
|
2773
2782
|
const visits = {};
|
|
2774
|
-
|
|
2783
|
+
activeIds.forEach((id) => {
|
|
2775
2784
|
if (inDegree[id] === 0) {
|
|
2776
2785
|
ranks[id] = 0;
|
|
2777
2786
|
queue.push(id);
|
|
2778
2787
|
}
|
|
2779
2788
|
});
|
|
2780
2789
|
if (queue.length === 0) {
|
|
2781
|
-
ranks[
|
|
2782
|
-
queue.push(
|
|
2790
|
+
ranks[activeIds[0]] = 0;
|
|
2791
|
+
queue.push(activeIds[0]);
|
|
2783
2792
|
}
|
|
2784
2793
|
let steps = 0;
|
|
2785
|
-
const maxSteps =
|
|
2794
|
+
const maxSteps = activeIds.length * activeIds.length + 8;
|
|
2786
2795
|
while (queue.length > 0 && steps < maxSteps) {
|
|
2787
2796
|
steps++;
|
|
2788
2797
|
const u = queue.shift();
|
|
@@ -2791,7 +2800,7 @@ function computeDiagramLayout(diagram, availableWidth, isLR = (diagram.direction
|
|
|
2791
2800
|
continue;
|
|
2792
2801
|
const r = ranks[u] ?? 0;
|
|
2793
2802
|
for (const v of adj[u] || []) {
|
|
2794
|
-
const nextR = Math.min(
|
|
2803
|
+
const nextR = Math.min(activeIds.length - 1, r + 1);
|
|
2795
2804
|
if (ranks[v] === void 0 || ranks[v] < nextR) {
|
|
2796
2805
|
ranks[v] = nextR;
|
|
2797
2806
|
if ((visits[v] || 0) <= visitBudget) {
|
|
@@ -2800,13 +2809,13 @@ function computeDiagramLayout(diagram, availableWidth, isLR = (diagram.direction
|
|
|
2800
2809
|
}
|
|
2801
2810
|
}
|
|
2802
2811
|
}
|
|
2803
|
-
|
|
2812
|
+
activeIds.forEach((id, idx) => {
|
|
2804
2813
|
if (ranks[id] === void 0) {
|
|
2805
|
-
ranks[id] = Math.min(idx,
|
|
2814
|
+
ranks[id] = Math.min(idx, activeIds.length - 1);
|
|
2806
2815
|
}
|
|
2807
2816
|
});
|
|
2808
2817
|
const rankGroups = {};
|
|
2809
|
-
|
|
2818
|
+
activeIds.forEach((id) => {
|
|
2810
2819
|
const r = ranks[id] ?? 0;
|
|
2811
2820
|
if (!rankGroups[r])
|
|
2812
2821
|
rankGroups[r] = [];
|
|
@@ -2819,13 +2828,14 @@ function computeDiagramLayout(diagram, availableWidth, isLR = (diagram.direction
|
|
|
2819
2828
|
maxLane = Math.max(maxLane, rankGroups[r].length);
|
|
2820
2829
|
});
|
|
2821
2830
|
const titleOffset = diagram.title ? options.titleHeight ?? 28 : 0;
|
|
2822
|
-
const gapX = isLR ?
|
|
2823
|
-
const gapY = isLR ?
|
|
2824
|
-
const nodeWidth = isLR ? Math.max(
|
|
2825
|
-
const
|
|
2826
|
-
const
|
|
2831
|
+
const gapX = isLR ? 36 : 24;
|
|
2832
|
+
const gapY = isLR ? 22 : 32;
|
|
2833
|
+
const nodeWidth = isLR ? Math.max(100, Math.min(260, (availableWidth - 48 - gapX * (numRanks - 1)) / numRanks)) : Math.max(100, Math.min(220, (availableWidth - 48 - gapX * (maxLane - 1)) / Math.max(1, maxLane)));
|
|
2834
|
+
const activeNodes = diagram.nodes.filter((n) => activeIds.includes(n.id));
|
|
2835
|
+
const longestLabel = Math.max(1, ...activeNodes.map((n) => (n.label || n.id).length));
|
|
2836
|
+
const charsPerLine = Math.max(8, Math.floor((nodeWidth - 16) / 6.5));
|
|
2827
2837
|
const labelLines = Math.max(1, Math.ceil(longestLabel / charsPerLine));
|
|
2828
|
-
const nodeHeight = Math.max(
|
|
2838
|
+
const nodeHeight = Math.max(40, Math.min(84, 20 + labelLines * 16));
|
|
2829
2839
|
const contentH = isLR ? maxLane * (nodeHeight + gapY) - gapY : numRanks * (nodeHeight + gapY) - gapY;
|
|
2830
2840
|
const height = titleOffset + 24 + contentH + 16;
|
|
2831
2841
|
const originX = options.originX ?? 0;
|
|
@@ -2983,7 +2993,7 @@ var DefaultLayoutEngine = class {
|
|
|
2983
2993
|
return { element, bounds: { x, y, width, height } };
|
|
2984
2994
|
}
|
|
2985
2995
|
case "code": {
|
|
2986
|
-
const height = this.estimateCodeHeight(element);
|
|
2996
|
+
const height = this.estimateCodeHeight(element, width);
|
|
2987
2997
|
return { element, bounds: { x, y, width, height } };
|
|
2988
2998
|
}
|
|
2989
2999
|
case "quote": {
|
|
@@ -3005,11 +3015,11 @@ var DefaultLayoutEngine = class {
|
|
|
3005
3015
|
case "callout": {
|
|
3006
3016
|
const c = element;
|
|
3007
3017
|
const lines = Math.ceil(c.text.length / Math.max(15, Math.floor(width / 14))) || 1;
|
|
3008
|
-
const height = Math.max(
|
|
3018
|
+
const height = Math.max(100, lines * 30 + (c.title ? 52 : 0) + 40);
|
|
3009
3019
|
return { element, bounds: { x, y, width, height } };
|
|
3010
3020
|
}
|
|
3011
3021
|
case "badge": {
|
|
3012
|
-
return { element, bounds: { x, y, width, height:
|
|
3022
|
+
return { element, bounds: { x, y, width, height: 52 } };
|
|
3013
3023
|
}
|
|
3014
3024
|
case "math": {
|
|
3015
3025
|
const height = 90;
|
|
@@ -3087,19 +3097,19 @@ var DefaultLayoutEngine = class {
|
|
|
3087
3097
|
layoutHero(element, x, y, width, gap, compact = false) {
|
|
3088
3098
|
let curY = y;
|
|
3089
3099
|
if (element.badge || element.tagline) {
|
|
3090
|
-
curY += compact ?
|
|
3100
|
+
curY += compact ? 44 : 56;
|
|
3091
3101
|
}
|
|
3092
|
-
const charsPerLineTitle = Math.max(
|
|
3102
|
+
const charsPerLineTitle = Math.max(10, Math.floor(width / (compact ? 36 : 30)));
|
|
3093
3103
|
const titleLines = Math.max(1, Math.ceil(element.title.length / charsPerLineTitle));
|
|
3094
|
-
const titleHeight = compact ? Math.max(
|
|
3104
|
+
const titleHeight = compact ? Math.max(72, titleLines * 52 + 16) : Math.max(110, titleLines * 76 + 28);
|
|
3095
3105
|
curY += titleHeight;
|
|
3096
3106
|
if (element.subtitle) {
|
|
3097
|
-
const charsPerLineSub = Math.max(
|
|
3107
|
+
const charsPerLineSub = Math.max(18, Math.floor(width / (compact ? 22 : 18)));
|
|
3098
3108
|
const subLines = Math.max(1, Math.ceil(element.subtitle.length / charsPerLineSub));
|
|
3099
|
-
const subHeight = compact ? Math.max(
|
|
3109
|
+
const subHeight = compact ? Math.max(44, subLines * 34 + 12) : Math.max(64, subLines * 40 + 18);
|
|
3100
3110
|
curY += subHeight;
|
|
3101
3111
|
}
|
|
3102
|
-
curY += compact ?
|
|
3112
|
+
curY += compact ? 14 : 20;
|
|
3103
3113
|
const children = [];
|
|
3104
3114
|
if (element.elements) {
|
|
3105
3115
|
for (const child of element.elements) {
|
|
@@ -3116,19 +3126,29 @@ var DefaultLayoutEngine = class {
|
|
|
3116
3126
|
}
|
|
3117
3127
|
layoutGrid(element, x, y, width, gap) {
|
|
3118
3128
|
const colCount = typeof element.columns === "number" ? element.columns : parseInt(String(element.columns), 10) || 2;
|
|
3119
|
-
const
|
|
3129
|
+
const rawGap = element.gap !== void 0 ? Number(element.gap) : gap;
|
|
3130
|
+
const gridGap = Number.isFinite(rawGap) && rawGap >= 0 ? rawGap : gap;
|
|
3131
|
+
const totalGap = gridGap * (colCount - 1);
|
|
3120
3132
|
const colWidth = Math.max(10, (width - totalGap) / colCount);
|
|
3121
3133
|
const children = [];
|
|
3122
3134
|
const colYs = Array(colCount).fill(y);
|
|
3123
3135
|
for (let i = 0; i < element.elements.length; i++) {
|
|
3124
3136
|
const colIdx = i % colCount;
|
|
3125
|
-
const colX = x + colIdx * (colWidth +
|
|
3137
|
+
const colX = x + colIdx * (colWidth + gridGap);
|
|
3126
3138
|
const childEl = element.elements[i];
|
|
3127
3139
|
const childNode = this.layoutSingleElement(childEl, colX, colYs[colIdx], colWidth, gap);
|
|
3128
3140
|
children.push(childNode);
|
|
3129
|
-
colYs[colIdx] += childNode.bounds.height +
|
|
3141
|
+
colYs[colIdx] += childNode.bounds.height + gridGap;
|
|
3142
|
+
}
|
|
3143
|
+
const rowCount = Math.ceil(children.length / colCount);
|
|
3144
|
+
for (let row = 0; row < rowCount; row++) {
|
|
3145
|
+
const rowNodes = children.slice(row * colCount, row * colCount + colCount);
|
|
3146
|
+
const rowMax = Math.max(...rowNodes.map((n) => n.bounds.height), 0);
|
|
3147
|
+
for (const node of rowNodes) {
|
|
3148
|
+
node.bounds.height = rowMax;
|
|
3149
|
+
}
|
|
3130
3150
|
}
|
|
3131
|
-
const maxGridHeight = Math.max(...
|
|
3151
|
+
const maxGridHeight = Math.max(...children.map((n) => n.bounds.y + n.bounds.height - y), 100);
|
|
3132
3152
|
return {
|
|
3133
3153
|
element,
|
|
3134
3154
|
bounds: { x, y, width, height: maxGridHeight },
|
|
@@ -3136,12 +3156,13 @@ var DefaultLayoutEngine = class {
|
|
|
3136
3156
|
};
|
|
3137
3157
|
}
|
|
3138
3158
|
layoutCompare(element, x, y, width, gap) {
|
|
3139
|
-
const
|
|
3140
|
-
const
|
|
3141
|
-
const
|
|
3159
|
+
const vsGap = Math.max(gap, 56);
|
|
3160
|
+
const colW = (width - vsGap) / 2;
|
|
3161
|
+
const titleH = 56;
|
|
3162
|
+
const pad = 28;
|
|
3142
3163
|
const leftStartY = y + pad + (element.leftTitle ? titleH : 0);
|
|
3143
3164
|
const { nodes: leftChildren, totalHeight: leftInnerH } = this.layoutElementList(element.left, x + pad, leftStartY, colW - pad * 2, gap / 2);
|
|
3144
|
-
const rightX = x + colW +
|
|
3165
|
+
const rightX = x + colW + vsGap;
|
|
3145
3166
|
const rightStartY = y + pad + (element.rightTitle ? titleH : 0);
|
|
3146
3167
|
const { nodes: rightChildren, totalHeight: rightInnerH } = this.layoutElementList(element.right, rightX + pad, rightStartY, colW - pad * 2, gap / 2);
|
|
3147
3168
|
const totalHeight = Math.max(leftInnerH, rightInnerH, 120) + (element.leftTitle || element.rightTitle ? titleH : 0) + pad * 2;
|
|
@@ -3171,11 +3192,12 @@ var DefaultLayoutEngine = class {
|
|
|
3171
3192
|
}
|
|
3172
3193
|
}
|
|
3173
3194
|
layoutCard(element, x, y, width, gap) {
|
|
3174
|
-
const cardPadding =
|
|
3195
|
+
const cardPadding = 28;
|
|
3175
3196
|
const innerWidth = Math.max(10, width - cardPadding * 2);
|
|
3176
|
-
const titleHeight = element.title ?
|
|
3197
|
+
const titleHeight = element.title ? 56 : 0;
|
|
3177
3198
|
const innerStartY = y + cardPadding + titleHeight;
|
|
3178
|
-
const
|
|
3199
|
+
const innerGap = Math.min(12, Math.max(6, Math.round(gap * 0.4)));
|
|
3200
|
+
const { nodes: children, totalHeight: innerHeight } = this.layoutElementList(element.elements, x + cardPadding, innerStartY, innerWidth, innerGap);
|
|
3179
3201
|
const cardHeight = titleHeight + innerHeight + cardPadding * 2 + 12;
|
|
3180
3202
|
const bounds = { x, y, width, height: Math.max(120, cardHeight) };
|
|
3181
3203
|
return {
|
|
@@ -3227,30 +3249,36 @@ var DefaultLayoutEngine = class {
|
|
|
3227
3249
|
}
|
|
3228
3250
|
estimateHeadingHeight(heading, width = 1600) {
|
|
3229
3251
|
const fontSize = heading.level === 1 ? 46 : heading.level === 2 ? 36 : 28;
|
|
3230
|
-
const charWidth = fontSize * 0.
|
|
3231
|
-
const charsPerLine = Math.max(
|
|
3252
|
+
const charWidth = fontSize * 0.62;
|
|
3253
|
+
const charsPerLine = Math.max(12, Math.floor(width / charWidth));
|
|
3232
3254
|
const lines = Math.ceil(heading.text.length / charsPerLine) || 1;
|
|
3233
|
-
const lineHeight = fontSize * 1.
|
|
3234
|
-
|
|
3255
|
+
const lineHeight = fontSize * 1.4;
|
|
3256
|
+
const minH = heading.level === 1 ? 110 : heading.level === 2 ? 88 : 72;
|
|
3257
|
+
return Math.max(minH, Math.round(lines * lineHeight + 28));
|
|
3235
3258
|
}
|
|
3236
3259
|
estimateParagraphHeight(paragraph, width) {
|
|
3237
|
-
const charsPerLine = Math.max(
|
|
3260
|
+
const charsPerLine = Math.max(18, Math.floor(width / 9.5));
|
|
3238
3261
|
const lines = Math.ceil(paragraph.text.length / charsPerLine) || 1;
|
|
3239
|
-
return Math.max(
|
|
3262
|
+
return Math.max(36, lines * 34 + 8);
|
|
3240
3263
|
}
|
|
3241
3264
|
estimateListHeight(list, width = 800) {
|
|
3242
|
-
const charsPerLine = Math.max(
|
|
3265
|
+
const charsPerLine = Math.max(18, Math.floor(width / 9.5));
|
|
3243
3266
|
let totalHeight = 0;
|
|
3244
3267
|
for (const item of list.items) {
|
|
3245
3268
|
const cleanLen = item.text.replace(/\*\*/g, "").replace(/\*/g, "").length;
|
|
3246
3269
|
const lines = Math.ceil(cleanLen / charsPerLine) || 1;
|
|
3247
|
-
totalHeight += lines *
|
|
3270
|
+
totalHeight += lines * 32 + 10;
|
|
3248
3271
|
}
|
|
3249
3272
|
return Math.max(40, totalHeight);
|
|
3250
3273
|
}
|
|
3251
|
-
estimateCodeHeight(code) {
|
|
3252
|
-
const lines = code.code.split("\n")
|
|
3253
|
-
|
|
3274
|
+
estimateCodeHeight(code, width = 800) {
|
|
3275
|
+
const lines = code.code.split("\n");
|
|
3276
|
+
const charsPerLine = Math.max(18, Math.floor((width - 48) / 9.5));
|
|
3277
|
+
let visualLines = 0;
|
|
3278
|
+
for (const line of lines) {
|
|
3279
|
+
visualLines += Math.max(1, Math.ceil((line.length || 1) / charsPerLine));
|
|
3280
|
+
}
|
|
3281
|
+
return Math.max(120, visualLines * 34 + 84);
|
|
3254
3282
|
}
|
|
3255
3283
|
estimateQuoteHeight(quote, width) {
|
|
3256
3284
|
const charsPerLine = Math.max(20, Math.floor(width / 14));
|
|
@@ -6261,7 +6289,9 @@ var PptxRenderer = class {
|
|
|
6261
6289
|
h: rect.h,
|
|
6262
6290
|
align: paragraph.align || "left",
|
|
6263
6291
|
valign: "top",
|
|
6264
|
-
margin: 0
|
|
6292
|
+
margin: 0,
|
|
6293
|
+
// Keep glyphs inside the layout box; wrapping is fine, overflow into neighbors is not.
|
|
6294
|
+
shrinkText: rect.h < 0.32
|
|
6265
6295
|
});
|
|
6266
6296
|
}
|
|
6267
6297
|
renderList(pptxSlide, list, rect, theme) {
|
|
@@ -6601,14 +6631,15 @@ var PptxRenderer = class {
|
|
|
6601
6631
|
});
|
|
6602
6632
|
} else {
|
|
6603
6633
|
pptxSlide.addText(code.code, {
|
|
6604
|
-
x: rect.x + 0.
|
|
6605
|
-
y: rect.y + 0.
|
|
6606
|
-
w: rect.w - 0.
|
|
6607
|
-
h: rect.h - 0.
|
|
6608
|
-
fontSize: 11.5,
|
|
6634
|
+
x: rect.x + 0.22,
|
|
6635
|
+
y: rect.y + 0.36,
|
|
6636
|
+
w: Math.max(0.2, rect.w - 0.44),
|
|
6637
|
+
h: Math.max(0.2, rect.h - 0.48),
|
|
6638
|
+
fontSize: rect.h < 2.2 ? 10 : 11.5,
|
|
6609
6639
|
fontFace: "Consolas",
|
|
6610
6640
|
color: textColor,
|
|
6611
|
-
valign: "top"
|
|
6641
|
+
valign: "top",
|
|
6642
|
+
margin: 0
|
|
6612
6643
|
});
|
|
6613
6644
|
}
|
|
6614
6645
|
}
|
|
@@ -6674,12 +6705,12 @@ var PptxRenderer = class {
|
|
|
6674
6705
|
line: { color: sevColor, width: 2 },
|
|
6675
6706
|
rectRadius: 0.08
|
|
6676
6707
|
});
|
|
6677
|
-
const titleH = callout.title ? 0.
|
|
6708
|
+
const titleH = callout.title ? 0.38 : 0;
|
|
6678
6709
|
if (callout.title) {
|
|
6679
6710
|
pptxSlide.addText(callout.title, {
|
|
6680
|
-
x: rect.x + 0.
|
|
6681
|
-
y: rect.y + 0.
|
|
6682
|
-
w: rect.w - 0.
|
|
6711
|
+
x: rect.x + 0.2,
|
|
6712
|
+
y: rect.y + 0.16,
|
|
6713
|
+
w: rect.w - 0.4,
|
|
6683
6714
|
h: 0.3,
|
|
6684
6715
|
fontSize: 13,
|
|
6685
6716
|
bold: true,
|
|
@@ -6688,10 +6719,10 @@ var PptxRenderer = class {
|
|
|
6688
6719
|
});
|
|
6689
6720
|
}
|
|
6690
6721
|
pptxSlide.addText(callout.text, {
|
|
6691
|
-
x: rect.x + 0.
|
|
6692
|
-
y: rect.y + titleH + 0.
|
|
6693
|
-
w: rect.w - 0.
|
|
6694
|
-
h: rect.h - titleH - 0.
|
|
6722
|
+
x: rect.x + 0.2,
|
|
6723
|
+
y: rect.y + titleH + 0.14,
|
|
6724
|
+
w: rect.w - 0.4,
|
|
6725
|
+
h: Math.max(0.2, rect.h - titleH - 0.28),
|
|
6695
6726
|
fontSize: 12,
|
|
6696
6727
|
color: this.cleanHexColor(theme.colors.text),
|
|
6697
6728
|
fontFace: cleanFontFace(theme.typography.bodyFont),
|
|
@@ -6708,15 +6739,17 @@ var PptxRenderer = class {
|
|
|
6708
6739
|
};
|
|
6709
6740
|
const align = hero.align || "center";
|
|
6710
6741
|
const compact = rect.h < 2.4;
|
|
6711
|
-
|
|
6712
|
-
|
|
6742
|
+
const maxY = rect.y + rect.h - 0.04;
|
|
6743
|
+
let curY = rect.y + (compact ? 0.08 : 0.24);
|
|
6744
|
+
if (hero.badge && curY < maxY) {
|
|
6713
6745
|
const badgeW = Math.min(3.2, Math.max(1.4, hero.badge.length * 0.11 + 0.6));
|
|
6714
6746
|
const badgeX = align === "left" ? rect.x : align === "right" ? rect.x + rect.w - badgeW : rect.x + (rect.w - badgeW) / 2;
|
|
6747
|
+
const badgeH = Math.min(compact ? 0.26 : 0.32, maxY - curY);
|
|
6715
6748
|
pptxSlide.addShape(pptx.ShapeType.roundRect, {
|
|
6716
6749
|
x: badgeX,
|
|
6717
6750
|
y: curY,
|
|
6718
6751
|
w: badgeW,
|
|
6719
|
-
h:
|
|
6752
|
+
h: badgeH,
|
|
6720
6753
|
fill: { color: this.cleanHexColor(theme.colors.surface) },
|
|
6721
6754
|
line: { color: this.cleanHexColor(theme.colors.primary), width: 1.5 },
|
|
6722
6755
|
rectRadius: 0.16
|
|
@@ -6725,7 +6758,7 @@ var PptxRenderer = class {
|
|
|
6725
6758
|
x: badgeX,
|
|
6726
6759
|
y: curY,
|
|
6727
6760
|
w: badgeW,
|
|
6728
|
-
h:
|
|
6761
|
+
h: badgeH,
|
|
6729
6762
|
fontSize: compact ? 9 : 10,
|
|
6730
6763
|
bold: true,
|
|
6731
6764
|
color: this.cleanHexColor(theme.colors.primary),
|
|
@@ -6734,12 +6767,13 @@ var PptxRenderer = class {
|
|
|
6734
6767
|
valign: "middle"
|
|
6735
6768
|
});
|
|
6736
6769
|
curY += compact ? 0.36 : 0.48;
|
|
6737
|
-
} else if (hero.tagline) {
|
|
6770
|
+
} else if (hero.tagline && curY < maxY) {
|
|
6771
|
+
const tagH = Math.min(0.32, maxY - curY);
|
|
6738
6772
|
pptxSlide.addText(hero.tagline.toUpperCase(), {
|
|
6739
6773
|
x: rect.x,
|
|
6740
6774
|
y: curY,
|
|
6741
6775
|
w: rect.w,
|
|
6742
|
-
h:
|
|
6776
|
+
h: tagH,
|
|
6743
6777
|
fontSize: compact ? 10 : 11,
|
|
6744
6778
|
bold: true,
|
|
6745
6779
|
color: this.cleanHexColor(theme.colors.primary),
|
|
@@ -6749,24 +6783,28 @@ var PptxRenderer = class {
|
|
|
6749
6783
|
curY += compact ? 0.34 : 0.42;
|
|
6750
6784
|
}
|
|
6751
6785
|
const titleLines = Math.max(1, Math.ceil(hero.title.length / (compact ? 48 : 38)));
|
|
6752
|
-
const
|
|
6786
|
+
const titleBudget = Math.max(0.24, maxY - curY - (hero.subtitle ? 0.3 : 0.02));
|
|
6787
|
+
const titleH = Math.min(Math.max(compact ? 0.42 : 0.7, titleLines * (compact ? 0.36 : 0.55) + 0.08), titleBudget);
|
|
6753
6788
|
const displaySize = themeSizeToPptxPoints(theme.typography.sizes?.display, 56);
|
|
6754
|
-
const titleFontSize = compact ? titleLines > 1 ? Math.min(
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6789
|
+
const titleFontSize = compact ? titleLines > 1 ? Math.min(20, displaySize - 16) : Math.min(24, displaySize - 12) : titleLines > 2 ? displaySize - 10 : titleLines > 1 ? displaySize - 6 : displaySize;
|
|
6790
|
+
if (titleH >= 0.24) {
|
|
6791
|
+
pptxSlide.addText(hero.title, {
|
|
6792
|
+
x: rect.x,
|
|
6793
|
+
y: curY,
|
|
6794
|
+
w: rect.w,
|
|
6795
|
+
h: titleH,
|
|
6796
|
+
fontSize: titleFontSize,
|
|
6797
|
+
bold: true,
|
|
6798
|
+
color: this.cleanHexColor(theme.colors.text),
|
|
6799
|
+
fontFace: cleanFontFace(theme.typography.headingFont),
|
|
6800
|
+
align,
|
|
6801
|
+
valign: "top"
|
|
6802
|
+
});
|
|
6803
|
+
}
|
|
6766
6804
|
curY += titleH + (compact ? 0.04 : 0.08);
|
|
6767
|
-
if (hero.subtitle) {
|
|
6805
|
+
if (hero.subtitle && curY < maxY - 0.14) {
|
|
6768
6806
|
const subLines = Math.max(1, Math.ceil(hero.subtitle.length / (compact ? 64 : 56)));
|
|
6769
|
-
const subH = Math.max(compact ? 0.28 : 0.38, subLines * 0.28 + 0.06);
|
|
6807
|
+
const subH = Math.min(Math.max(compact ? 0.28 : 0.38, subLines * 0.28 + 0.06), maxY - curY);
|
|
6770
6808
|
const bodySize = themeSizeToPptxPoints(theme.typography.sizes?.body, 18);
|
|
6771
6809
|
const subFontSize = compact ? bodySize - 1 : subLines > 2 ? bodySize - 1 : bodySize + 1;
|
|
6772
6810
|
pptxSlide.addText(hero.subtitle, {
|
|
@@ -6777,22 +6815,22 @@ var PptxRenderer = class {
|
|
|
6777
6815
|
fontSize: subFontSize,
|
|
6778
6816
|
color: this.cleanHexColor(theme.colors.muted || theme.colors.text),
|
|
6779
6817
|
fontFace: cleanFontFace(theme.typography.bodyFont),
|
|
6780
|
-
align
|
|
6818
|
+
align,
|
|
6819
|
+
valign: "top"
|
|
6781
6820
|
});
|
|
6782
6821
|
curY += subH + (compact ? 0.06 : 0.12);
|
|
6783
6822
|
}
|
|
6784
|
-
if (hero.tagline && hero.badge) {
|
|
6823
|
+
if (hero.tagline && hero.badge && curY + 0.28 <= maxY) {
|
|
6785
6824
|
pptxSlide.addText(hero.tagline, {
|
|
6786
6825
|
x: rect.x,
|
|
6787
6826
|
y: curY,
|
|
6788
6827
|
w: rect.w,
|
|
6789
|
-
h: 0.
|
|
6828
|
+
h: 0.28,
|
|
6790
6829
|
fontSize: 12,
|
|
6791
6830
|
color: this.cleanHexColor(theme.colors.muted || theme.colors.text),
|
|
6792
6831
|
fontFace: cleanFontFace(theme.typography.bodyFont),
|
|
6793
6832
|
align
|
|
6794
6833
|
});
|
|
6795
|
-
curY += 0.35;
|
|
6796
6834
|
}
|
|
6797
6835
|
if (node.children) {
|
|
6798
6836
|
for (const childNode of node.children) {
|
|
@@ -7024,7 +7062,7 @@ ${item.description}` : "";
|
|
|
7024
7062
|
const { element, bounds } = node;
|
|
7025
7063
|
const compare = element;
|
|
7026
7064
|
const rect = this.toInches(bounds, scaleX, scaleY);
|
|
7027
|
-
const colW = (rect.w - 0.
|
|
7065
|
+
const colW = (rect.w - 0.5) / 2;
|
|
7028
7066
|
pptxSlide.addShape(pptx.ShapeType.roundRect, {
|
|
7029
7067
|
x: rect.x,
|
|
7030
7068
|
y: rect.y,
|
|
@@ -7046,7 +7084,7 @@ ${item.description}` : "";
|
|
|
7046
7084
|
fontFace: cleanFontFace(theme.typography.headingFont)
|
|
7047
7085
|
});
|
|
7048
7086
|
}
|
|
7049
|
-
const rightX = rect.x + colW + 0.
|
|
7087
|
+
const rightX = rect.x + colW + 0.5;
|
|
7050
7088
|
pptxSlide.addShape(pptx.ShapeType.roundRect, {
|
|
7051
7089
|
x: rightX,
|
|
7052
7090
|
y: rect.y,
|
|
@@ -7068,26 +7106,30 @@ ${item.description}` : "";
|
|
|
7068
7106
|
fontFace: cleanFontFace(theme.typography.headingFont)
|
|
7069
7107
|
});
|
|
7070
7108
|
}
|
|
7071
|
-
const
|
|
7072
|
-
|
|
7109
|
+
const vsW = 0.42;
|
|
7110
|
+
const vsH = 0.42;
|
|
7111
|
+
const vsX = rect.x + colW + (0.5 - vsW) / 2;
|
|
7112
|
+
const vsY = rect.y + rect.h / 2 - vsH / 2;
|
|
7113
|
+
pptxSlide.addShape(pptx.ShapeType.ellipse, {
|
|
7073
7114
|
x: vsX,
|
|
7074
|
-
y:
|
|
7075
|
-
w:
|
|
7076
|
-
h:
|
|
7077
|
-
fill: { color: this.cleanHexColor(theme.colors.
|
|
7078
|
-
|
|
7115
|
+
y: vsY,
|
|
7116
|
+
w: vsW,
|
|
7117
|
+
h: vsH,
|
|
7118
|
+
fill: { color: this.cleanHexColor(theme.colors.surface || theme.colors.background) },
|
|
7119
|
+
line: { color: this.cleanHexColor(theme.colors.primary), width: 1.5 }
|
|
7079
7120
|
});
|
|
7080
7121
|
pptxSlide.addText("VS", {
|
|
7081
7122
|
x: vsX,
|
|
7082
|
-
y:
|
|
7083
|
-
w:
|
|
7084
|
-
h:
|
|
7085
|
-
fontSize:
|
|
7123
|
+
y: vsY,
|
|
7124
|
+
w: vsW,
|
|
7125
|
+
h: vsH,
|
|
7126
|
+
fontSize: 11,
|
|
7086
7127
|
bold: true,
|
|
7087
|
-
color: this.cleanHexColor(theme.colors.
|
|
7128
|
+
color: this.cleanHexColor(theme.colors.text),
|
|
7088
7129
|
fontFace: cleanFontFace(theme.typography.headingFont),
|
|
7089
7130
|
align: "center",
|
|
7090
|
-
valign: "middle"
|
|
7131
|
+
valign: "middle",
|
|
7132
|
+
margin: 0
|
|
7091
7133
|
});
|
|
7092
7134
|
if (node.children) {
|
|
7093
7135
|
for (const childNode of node.children) {
|
|
@@ -7522,17 +7564,18 @@ ${mermaid.code}`, {
|
|
|
7522
7564
|
line: { color: nodeBorderColor, width: 1 }
|
|
7523
7565
|
});
|
|
7524
7566
|
}
|
|
7525
|
-
pptxSlide.addText(fitDiagramLabel(n.label, Math.max(
|
|
7526
|
-
x: p.x + 0.
|
|
7567
|
+
pptxSlide.addText(fitDiagramLabel(n.label, Math.max(10, Math.floor(nodeW * 72 / 6.8))), {
|
|
7568
|
+
x: p.x + 0.08,
|
|
7527
7569
|
y: p.y + 0.06,
|
|
7528
|
-
w: Math.max(0.1, nodeW - 0.
|
|
7570
|
+
w: Math.max(0.1, nodeW - 0.16),
|
|
7529
7571
|
h: Math.max(0.1, nodeH - 0.12),
|
|
7530
7572
|
align: "center",
|
|
7531
7573
|
valign: "middle",
|
|
7532
|
-
fontSize: n.label.length >
|
|
7574
|
+
fontSize: nodeW < 1.1 ? 10 : n.label.length > 22 ? 11 : 12,
|
|
7533
7575
|
bold: true,
|
|
7534
7576
|
color: this.cleanHexColor(theme.colors.text || "ffffff"),
|
|
7535
|
-
fontFace: cleanFontFace(theme.typography.headingFont)
|
|
7577
|
+
fontFace: cleanFontFace(theme.typography.headingFont),
|
|
7578
|
+
margin: 0
|
|
7536
7579
|
});
|
|
7537
7580
|
});
|
|
7538
7581
|
}
|
|
@@ -8156,10 +8199,12 @@ var HtmlRenderer = class {
|
|
|
8156
8199
|
.yumia-grid {
|
|
8157
8200
|
display: grid;
|
|
8158
8201
|
width: 100%;
|
|
8159
|
-
flex: 1;
|
|
8202
|
+
flex: 1 1 auto;
|
|
8160
8203
|
min-height: 0;
|
|
8204
|
+
max-height: 100%;
|
|
8161
8205
|
gap: clamp(1rem, 1.8vw, 1.6rem);
|
|
8162
8206
|
align-items: stretch;
|
|
8207
|
+
align-content: start;
|
|
8163
8208
|
margin-top: 0.4rem;
|
|
8164
8209
|
}
|
|
8165
8210
|
|
|
@@ -8203,14 +8248,16 @@ var HtmlRenderer = class {
|
|
|
8203
8248
|
background: var(--yumia-surface);
|
|
8204
8249
|
border: 1.5px solid var(--yumia-border);
|
|
8205
8250
|
border-radius: 14px;
|
|
8206
|
-
padding: clamp(1.
|
|
8251
|
+
padding: clamp(1.1rem, 1.8vw, 1.5rem);
|
|
8207
8252
|
display: flex;
|
|
8208
8253
|
flex-direction: column;
|
|
8209
8254
|
justify-content: flex-start;
|
|
8210
|
-
gap: 0.
|
|
8255
|
+
gap: 0.45rem;
|
|
8211
8256
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
|
|
8212
8257
|
height: 100%;
|
|
8258
|
+
max-height: 100%;
|
|
8213
8259
|
min-height: 0;
|
|
8260
|
+
overflow: hidden;
|
|
8214
8261
|
box-sizing: border-box;
|
|
8215
8262
|
transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
|
|
8216
8263
|
}
|
|
@@ -9856,7 +9903,8 @@ var HtmlRenderer = class {
|
|
|
9856
9903
|
case "grid": {
|
|
9857
9904
|
const g = element;
|
|
9858
9905
|
const cols = typeof g.columns === "number" ? `repeat(${g.columns}, minmax(0, 1fr))` : g.columns;
|
|
9859
|
-
const
|
|
9906
|
+
const gapRaw = g.gap !== void 0 ? g.gap : "1.5rem";
|
|
9907
|
+
const gap = typeof gapRaw === "number" ? `${gapRaw}px` : /^\d+(\.\d+)?$/.test(String(gapRaw).trim()) ? `${String(gapRaw).trim()}px` : String(gapRaw);
|
|
9860
9908
|
const inner = g.elements.map((child) => this.renderElement(child, theme, presentation)).join("\n");
|
|
9861
9909
|
return `<div class="yumia-grid" style="grid-template-columns:${cols}; gap:${gap};">${inner}</div>`;
|
|
9862
9910
|
}
|
|
@@ -10761,9 +10809,9 @@ var PdfRenderer = class {
|
|
|
10761
10809
|
doc.restore();
|
|
10762
10810
|
const midX = x + colW + gap / 2;
|
|
10763
10811
|
const midY = y + height / 2;
|
|
10764
|
-
doc.circle(midX, midY,
|
|
10765
|
-
doc.circle(midX, midY,
|
|
10766
|
-
doc.font(this.getPdfFont(theme, "bold")).fontSize(
|
|
10812
|
+
doc.circle(midX, midY, 16).fill(theme.colors.surface || "#151522");
|
|
10813
|
+
doc.circle(midX, midY, 16).lineWidth(1.4).strokeColor(theme.colors.primary).stroke();
|
|
10814
|
+
doc.font(this.getPdfFont(theme, "bold")).fontSize(10).fillColor(theme.colors.text).text("VS", midX - 14, midY - 5, { width: 28, align: "center" });
|
|
10767
10815
|
if (compare.leftTitle) {
|
|
10768
10816
|
doc.font(this.getPdfFont(theme, "bold")).fontSize(11).fillColor(leftColor).text(this.stripFormatting(compare.leftTitle), x + 10, y + 10, {
|
|
10769
10817
|
width: colW - 20,
|
|
@@ -11267,7 +11315,10 @@ var PdfRenderer = class {
|
|
|
11267
11315
|
doc.roundedRect(x, y, width, boxH2, 8).strokeColor(theme.colors.border || "rgba(255,255,255,0.1)").stroke();
|
|
11268
11316
|
let topY2 = y + 8;
|
|
11269
11317
|
if (ch.title) {
|
|
11270
|
-
doc.font(this.getPdfFont(theme, "bold")).fontSize(13).fillColor(theme.colors.text).text(this.stripFormatting(ch.title), x + 14, topY2, {
|
|
11318
|
+
doc.font(this.getPdfFont(theme, "bold")).fontSize(13).fillColor(theme.colors.text).text(this.stripFormatting(ch.title), x + 14, topY2, {
|
|
11319
|
+
width: width - 28,
|
|
11320
|
+
align: "center"
|
|
11321
|
+
});
|
|
11271
11322
|
topY2 += 18;
|
|
11272
11323
|
}
|
|
11273
11324
|
const values2 = ch.series[0]?.values || [];
|
|
@@ -11345,7 +11396,10 @@ var PdfRenderer = class {
|
|
|
11345
11396
|
doc.roundedRect(x, y, width, boxH2, 8).strokeColor(theme.colors.border || "rgba(255,255,255,0.1)").stroke();
|
|
11346
11397
|
let topY2 = y + 8;
|
|
11347
11398
|
if (ch.title) {
|
|
11348
|
-
doc.font(this.getPdfFont(theme, "bold")).fontSize(13).fillColor(theme.colors.text).text(this.stripFormatting(ch.title), x + 14, topY2, {
|
|
11399
|
+
doc.font(this.getPdfFont(theme, "bold")).fontSize(13).fillColor(theme.colors.text).text(this.stripFormatting(ch.title), x + 14, topY2, {
|
|
11400
|
+
width: width - 28,
|
|
11401
|
+
align: "center"
|
|
11402
|
+
});
|
|
11349
11403
|
topY2 += 18;
|
|
11350
11404
|
}
|
|
11351
11405
|
const val = ch.series[0]?.values[0] || 0;
|
|
@@ -11385,7 +11439,10 @@ var PdfRenderer = class {
|
|
|
11385
11439
|
}
|
|
11386
11440
|
doc.font(this.getPdfFont(theme, "bold")).fontSize(20).fillColor(theme.colors.text).text(`${val}%`, cx - 40, cy - 16, { width: 80, align: "center" });
|
|
11387
11441
|
if (ch.labels?.[0]) {
|
|
11388
|
-
doc.font(this.getPdfFont(theme, "regular")).fontSize(9).fillColor(theme.colors.muted || "#888888").text(this.stripFormatting(ch.labels[0]), cx - 60, cy + 6, {
|
|
11442
|
+
doc.font(this.getPdfFont(theme, "regular")).fontSize(9).fillColor(theme.colors.muted || "#888888").text(this.stripFormatting(ch.labels[0]), cx - 60, cy + 6, {
|
|
11443
|
+
width: 120,
|
|
11444
|
+
align: "center"
|
|
11445
|
+
});
|
|
11389
11446
|
}
|
|
11390
11447
|
return y + boxH2 + 8;
|
|
11391
11448
|
}
|
|
@@ -11742,7 +11799,10 @@ var PdfRenderer = class {
|
|
|
11742
11799
|
doc.restore();
|
|
11743
11800
|
doc.roundedRect(boxX, topY, partW, 26, 5).fill(theme.colors.surface || "rgba(255,255,255,0.06)");
|
|
11744
11801
|
doc.roundedRect(boxX, topY, partW, 26, 5).lineWidth(1.2).strokeColor(primaryColor).stroke();
|
|
11745
|
-
doc.font(this.getPdfFont(theme, "bold")).fontSize(9).fillColor(theme.colors.text).text(this.stripFormatting(p.name), boxX + 2, topY + 8, {
|
|
11802
|
+
doc.font(this.getPdfFont(theme, "bold")).fontSize(9).fillColor(theme.colors.text).text(this.stripFormatting(p.name), boxX + 2, topY + 8, {
|
|
11803
|
+
width: partW - 4,
|
|
11804
|
+
align: "center"
|
|
11805
|
+
});
|
|
11746
11806
|
});
|
|
11747
11807
|
messages.forEach((msg, idx) => {
|
|
11748
11808
|
const x1 = positions[msg.from] || x + 20;
|
|
@@ -11957,7 +12017,7 @@ function startDevServer(filePath, options = {}) {
|
|
|
11957
12017
|
// src/cli.ts
|
|
11958
12018
|
import { mkdirSync, readFileSync as readFileSync3, watch as fsWatch, writeFileSync } from "fs";
|
|
11959
12019
|
import { basename, dirname, extname, join, resolve as resolve3 } from "path";
|
|
11960
|
-
var VERSION = "0.1.
|
|
12020
|
+
var VERSION = "0.1.32";
|
|
11961
12021
|
function printHelp() {
|
|
11962
12022
|
return `
|
|
11963
12023
|
YumiaMD \u2014 Markdown-based presentation compiler (v${VERSION})
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from '@yumiamd/renderer-pptx';
|
|
|
9
9
|
export * from '@yumiamd/renderer-html';
|
|
10
10
|
export * from '@yumiamd/renderer-pdf';
|
|
11
11
|
|
|
12
|
-
declare const VERSION = "0.1.
|
|
12
|
+
declare const VERSION = "0.1.32";
|
|
13
13
|
declare function printHelp(): string;
|
|
14
14
|
declare function runCli(argv: string[]): Promise<{
|
|
15
15
|
exitCode: number;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yumiamd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Command line interface and compiler for YumiaMD presentations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsup": "^8.5.1",
|
|
25
|
-
"@yumiamd/
|
|
26
|
-
"@yumiamd/
|
|
27
|
-
"@yumiamd/
|
|
28
|
-
"@yumiamd/
|
|
29
|
-
"@yumiamd/
|
|
30
|
-
"@yumiamd/
|
|
31
|
-
"@yumiamd/renderer": "0.1.
|
|
32
|
-
"@yumiamd/
|
|
33
|
-
"@yumiamd/
|
|
25
|
+
"@yumiamd/layout": "0.1.32",
|
|
26
|
+
"@yumiamd/ast": "0.1.32",
|
|
27
|
+
"@yumiamd/renderer-pdf": "0.1.32",
|
|
28
|
+
"@yumiamd/parser": "0.1.32",
|
|
29
|
+
"@yumiamd/renderer": "0.1.32",
|
|
30
|
+
"@yumiamd/theme": "0.1.32",
|
|
31
|
+
"@yumiamd/renderer-html": "0.1.32",
|
|
32
|
+
"@yumiamd/renderer-pptx": "0.1.32",
|
|
33
|
+
"@yumiamd/core": "0.1.32"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"yumia",
|