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