@dloizides/poster-render 0.13.1 → 0.14.2
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/CHANGELOG.md +5 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -95,7 +95,7 @@ var RowIcon = /* @__PURE__ */ ((RowIcon2) => {
|
|
|
95
95
|
})(RowIcon || {});
|
|
96
96
|
|
|
97
97
|
// src/schema/lineStyleSchema.ts
|
|
98
|
-
var LINE_KEY_PATTERN = "^(title|titleBottom|script|footer|includes[.]heading|includes[.]items[.][0-5]|venue[.][0-2]|schedule[.][0-5][.](label|time)|prices[.][0-3][.](amount|label)|items[.][0-7][.](date|price|schedule[.][0-5]))$";
|
|
98
|
+
var LINE_KEY_PATTERN = "^(title|titleBottom|script|footer|lines[.][0-5]|includes[.]heading|includes[.]items[.][0-5]|venue[.][0-2]|schedule[.][0-5][.](label|time)|prices[.][0-3][.](amount|label)|items[.][0-7][.](date|price|schedule[.][0-5]))$";
|
|
99
99
|
var MAX_FONT = 40;
|
|
100
100
|
var MIN_SPACING = -0.1;
|
|
101
101
|
var MAX_SPACING = 0.5;
|
|
@@ -272,6 +272,7 @@ var headerTuningSchema = {
|
|
|
272
272
|
// src/schema/flierDocSchema.ts
|
|
273
273
|
var SHORT = 60;
|
|
274
274
|
var LINE = 120;
|
|
275
|
+
var MAX_LINES = 6;
|
|
275
276
|
var MAX_ROWS2 = 6;
|
|
276
277
|
var MAX_ITEMS = 8;
|
|
277
278
|
var MAX_PRICES2 = 4;
|
|
@@ -316,7 +317,8 @@ var blocks = {
|
|
|
316
317
|
additionalProperties: false,
|
|
317
318
|
properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems: MAX_ROWS2 } }
|
|
318
319
|
},
|
|
319
|
-
footer: text(LINE)
|
|
320
|
+
footer: text(LINE),
|
|
321
|
+
lines: { type: "array", items: { type: "string", maxLength: LINE }, maxItems: MAX_LINES }
|
|
320
322
|
}
|
|
321
323
|
};
|
|
322
324
|
var flierDocSchema = {
|
|
@@ -810,21 +812,20 @@ function styled(line, key, sc) {
|
|
|
810
812
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
811
813
|
return { ...line, key };
|
|
812
814
|
}
|
|
813
|
-
const
|
|
815
|
+
const scaled = line.size * (style?.sizeScale ?? 1);
|
|
814
816
|
return {
|
|
815
817
|
...line,
|
|
816
818
|
key,
|
|
817
|
-
size,
|
|
818
819
|
color: style?.color ?? line.color,
|
|
819
820
|
weight: style?.weight ?? line.weight,
|
|
820
821
|
family: style?.font,
|
|
821
822
|
italic: style?.italic,
|
|
822
823
|
spacing: style?.letterSpacing,
|
|
823
824
|
widthScale: style?.widthScale,
|
|
824
|
-
|
|
825
|
+
sizeScale: style?.sizeScale,
|
|
825
826
|
align: style?.align,
|
|
826
|
-
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove *
|
|
827
|
-
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow *
|
|
827
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * scaled,
|
|
828
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * scaled,
|
|
828
829
|
widthTie,
|
|
829
830
|
sizeTie
|
|
830
831
|
};
|
|
@@ -1001,14 +1002,16 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
1001
1002
|
const includeLines = b.includes ? [l.accent(b.includes.heading, SIZE.small, "includes.heading"), ...b.includes.items.map((item, i) => l.item(item, SIZE.small, `includes.items.${i}`))] : [];
|
|
1002
1003
|
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
1003
1004
|
const footerLines = (b.footer ?? "").split("\n").filter((text2) => text2.trim() !== "");
|
|
1005
|
+
const free = (b.lines ?? []).flatMap((text2, i) => text2.trim() === "" ? [] : wrapped(l.strong(text2, SIZE.small, `lines.${i}`), options.wrap));
|
|
1004
1006
|
const footer = footerLines.length > 0 ? [{ lines: footerLines.flatMap((text2) => wrapped(l.soft(text2, SIZE.small, "footer"), options.wrap)), gapAfter: 0 }] : [];
|
|
1007
|
+
const freeGroup = free.length > 0 ? [{ lines: free, gapAfter: GAP.includes * u }] : [];
|
|
1005
1008
|
const parts = {
|
|
1006
1009
|
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
1007
1010
|
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
1008
1011
|
["items" /* Items */]: isList ? rows : [],
|
|
1009
1012
|
["prices" /* Prices */]: prices,
|
|
1010
1013
|
["includes" /* Includes */]: includes,
|
|
1011
|
-
["footer" /* Footer */]: footer
|
|
1014
|
+
["footer" /* Footer */]: [...freeGroup, ...footer]
|
|
1012
1015
|
};
|
|
1013
1016
|
return joined(sectionOrderOf(doc), parts);
|
|
1014
1017
|
}
|
|
@@ -1063,9 +1066,6 @@ function groupBox(group, k, colW) {
|
|
|
1063
1066
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1064
1067
|
}
|
|
1065
1068
|
function lineSize(line, width, k, avail) {
|
|
1066
|
-
if (line.fixedSize === true) {
|
|
1067
|
-
return line.size;
|
|
1068
|
-
}
|
|
1069
1069
|
const indent = bulletIndent(line, k);
|
|
1070
1070
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1071
1071
|
}
|
|
@@ -1075,7 +1075,7 @@ function groupSizes(m, k, avail) {
|
|
|
1075
1075
|
return own;
|
|
1076
1076
|
}
|
|
1077
1077
|
const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
|
|
1078
|
-
return m.group.lines.map((line) => line.
|
|
1078
|
+
return m.group.lines.map((line) => line.size * ratio);
|
|
1079
1079
|
}
|
|
1080
1080
|
function tieMembers(all, k, colW, table, pick) {
|
|
1081
1081
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1084,7 +1084,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1084
1084
|
const sizes = table.get(m) ?? [];
|
|
1085
1085
|
m.group.lines.forEach((line, i) => {
|
|
1086
1086
|
const id = pick(line);
|
|
1087
|
-
if (id !== void 0
|
|
1087
|
+
if (id !== void 0) {
|
|
1088
1088
|
const member = { line, width: Math.max(m.widths[i] ?? 1, 1), cap: Math.max(0, Math.min(1, line.widthScale ?? 1) * avail - bulletIndent(line, k)), sizes, i };
|
|
1089
1089
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1090
1090
|
}
|
|
@@ -1105,11 +1105,14 @@ function sameWidths(list) {
|
|
|
1105
1105
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|
|
1108
|
+
function applyScales(m, sizes) {
|
|
1109
|
+
return sizes.map((size, i) => size * (m.group.lines[i]?.sizeScale ?? 1));
|
|
1110
|
+
}
|
|
1108
1111
|
function sizeTable(all, k, colW) {
|
|
1109
1112
|
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1110
1113
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1111
1114
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1112
|
-
return table;
|
|
1115
|
+
return new Map(all.map((m) => [m, applyScales(m, table.get(m) ?? [])]));
|
|
1113
1116
|
}
|
|
1114
1117
|
|
|
1115
1118
|
// src/layout/textFlow.ts
|
|
@@ -1169,11 +1172,11 @@ function placeGroup(m, at, out) {
|
|
|
1169
1172
|
group.lines.forEach((line, i) => {
|
|
1170
1173
|
const size = sizes[i] ?? 0;
|
|
1171
1174
|
y += (line.spaceAbove ?? 0) * k;
|
|
1172
|
-
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1175
|
+
const indent = (indented(line) ? line.size * (line.sizeScale ?? 1) * k * BULLET_INDENT : 0) + iconIndent;
|
|
1173
1176
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1174
1177
|
const x = lineX(line, { col, pad, indent, w });
|
|
1175
1178
|
const box = { x, y, w, h: size * LINE_HEIGHT };
|
|
1176
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.
|
|
1179
|
+
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.sizeScale === void 0 ? {} : { fixed: true }, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
|
|
1177
1180
|
if (line.bullet && out) {
|
|
1178
1181
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1179
1182
|
}
|