@dloizides/poster-render 0.9.1 → 0.10.0
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/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -794,10 +794,11 @@ function styled(line, key, sc) {
|
|
|
794
794
|
const widthTie = sc.width.get(key);
|
|
795
795
|
const sizeTie = sc.size.get(key);
|
|
796
796
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
797
|
-
return line;
|
|
797
|
+
return { ...line, key };
|
|
798
798
|
}
|
|
799
799
|
return {
|
|
800
800
|
...line,
|
|
801
|
+
key,
|
|
801
802
|
size: line.size * (style?.sizeScale ?? 1),
|
|
802
803
|
color: style?.color ?? line.color,
|
|
803
804
|
weight: style?.weight ?? line.weight,
|
|
@@ -1089,7 +1090,7 @@ function placeGroup(m, at, out) {
|
|
|
1089
1090
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1090
1091
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1091
1092
|
const x = lineX(line, { col, pad, indent, w });
|
|
1092
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box: { x, y, w, h: size * LINE_HEIGHT } });
|
|
1093
|
+
out?.texts.push({ text: line.text, font: "", color: line.color, box: { x, y, w, h: size * LINE_HEIGHT }, key: line.key });
|
|
1093
1094
|
if (line.bullet && out) {
|
|
1094
1095
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1095
1096
|
}
|
|
@@ -1610,6 +1611,23 @@ function drawLogo(ctx, doc, assets, fitted) {
|
|
|
1610
1611
|
}
|
|
1611
1612
|
return logo;
|
|
1612
1613
|
}
|
|
1614
|
+
function lineBoxesOf(texts) {
|
|
1615
|
+
const boxes = {};
|
|
1616
|
+
texts.forEach(({ key, box }) => {
|
|
1617
|
+
if (key !== void 0) {
|
|
1618
|
+
boxes[key] = union(boxes[key], box);
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
return boxes;
|
|
1622
|
+
}
|
|
1623
|
+
function union(a, b) {
|
|
1624
|
+
if (a === void 0) {
|
|
1625
|
+
return { ...b };
|
|
1626
|
+
}
|
|
1627
|
+
const x = Math.min(a.x, b.x);
|
|
1628
|
+
const y = Math.min(a.y, b.y);
|
|
1629
|
+
return { x, y, w: Math.max(a.x + a.w, b.x + b.w) - x, h: Math.max(a.y + a.h, b.y + b.h) - y };
|
|
1630
|
+
}
|
|
1613
1631
|
function render(input, assets, canvas) {
|
|
1614
1632
|
const doc = checked(input, assets);
|
|
1615
1633
|
const { width, height } = FORMAT_SIZES[doc.format];
|
|
@@ -1645,6 +1663,7 @@ function render(input, assets, canvas) {
|
|
|
1645
1663
|
picture,
|
|
1646
1664
|
pictureRegion: region,
|
|
1647
1665
|
textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
|
|
1666
|
+
lineBoxes: lineBoxesOf(flows.flatMap((f) => f.texts)),
|
|
1648
1667
|
cardBoxes: body.cards.map((c) => c.rect),
|
|
1649
1668
|
iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
|
|
1650
1669
|
ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
|