@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.2
|
|
4
|
+
|
|
5
|
+
- FLIER-SIZE-1 "Line size jumps at 101%": sizeScale multiplies the line's fitted size, so 100% to 101% is a 1% change (first published here; 0.14.1 never reached npm).
|
|
6
|
+
- POSTER-LINUX-1 "poster-render tests pass on Linux CI": the suite registers bundled OFL theme fonts and passes on Linux and Windows, so the release builds through GitHub Actions trusted publishing.
|
|
7
|
+
|
|
3
8
|
## 0.13.1
|
|
4
9
|
|
|
5
10
|
- D-SPACE-1 "Space above/below applies per item": a wrapped line keeps `spaceAbove` on its first part and `spaceBelow` on its last, so a wrapped includes item's own lines stay tight.
|
package/dist/index.d.mts
CHANGED
|
@@ -97,7 +97,7 @@ interface JsonSchema {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/** Every text line a style or tie can name: block fields by path, list items by index. */
|
|
100
|
-
declare const 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]))$";
|
|
100
|
+
declare const 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]))$";
|
|
101
101
|
|
|
102
102
|
interface ScheduleRow {
|
|
103
103
|
label: string;
|
|
@@ -120,6 +120,7 @@ interface FlierBlocks {
|
|
|
120
120
|
prices?: PriceRow[];
|
|
121
121
|
includes?: IncludesBlock;
|
|
122
122
|
footer?: string;
|
|
123
|
+
lines?: string[];
|
|
123
124
|
}
|
|
124
125
|
interface ListItem {
|
|
125
126
|
date: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ interface JsonSchema {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/** Every text line a style or tie can name: block fields by path, list items by index. */
|
|
100
|
-
declare const 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]))$";
|
|
100
|
+
declare const 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]))$";
|
|
101
101
|
|
|
102
102
|
interface ScheduleRow {
|
|
103
103
|
label: string;
|
|
@@ -120,6 +120,7 @@ interface FlierBlocks {
|
|
|
120
120
|
prices?: PriceRow[];
|
|
121
121
|
includes?: IncludesBlock;
|
|
122
122
|
footer?: string;
|
|
123
|
+
lines?: string[];
|
|
123
124
|
}
|
|
124
125
|
interface ListItem {
|
|
125
126
|
date: string;
|
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ var RowIcon = /* @__PURE__ */ ((RowIcon2) => {
|
|
|
97
97
|
})(RowIcon || {});
|
|
98
98
|
|
|
99
99
|
// src/schema/lineStyleSchema.ts
|
|
100
|
-
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]))$";
|
|
100
|
+
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]))$";
|
|
101
101
|
var MAX_FONT = 40;
|
|
102
102
|
var MIN_SPACING = -0.1;
|
|
103
103
|
var MAX_SPACING = 0.5;
|
|
@@ -274,6 +274,7 @@ var headerTuningSchema = {
|
|
|
274
274
|
// src/schema/flierDocSchema.ts
|
|
275
275
|
var SHORT = 60;
|
|
276
276
|
var LINE = 120;
|
|
277
|
+
var MAX_LINES = 6;
|
|
277
278
|
var MAX_ROWS2 = 6;
|
|
278
279
|
var MAX_ITEMS = 8;
|
|
279
280
|
var MAX_PRICES2 = 4;
|
|
@@ -318,7 +319,8 @@ var blocks = {
|
|
|
318
319
|
additionalProperties: false,
|
|
319
320
|
properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems: MAX_ROWS2 } }
|
|
320
321
|
},
|
|
321
|
-
footer: text(LINE)
|
|
322
|
+
footer: text(LINE),
|
|
323
|
+
lines: { type: "array", items: { type: "string", maxLength: LINE }, maxItems: MAX_LINES }
|
|
322
324
|
}
|
|
323
325
|
};
|
|
324
326
|
var flierDocSchema = {
|
|
@@ -812,21 +814,20 @@ function styled(line, key, sc) {
|
|
|
812
814
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
813
815
|
return { ...line, key };
|
|
814
816
|
}
|
|
815
|
-
const
|
|
817
|
+
const scaled = line.size * (style?.sizeScale ?? 1);
|
|
816
818
|
return {
|
|
817
819
|
...line,
|
|
818
820
|
key,
|
|
819
|
-
size,
|
|
820
821
|
color: style?.color ?? line.color,
|
|
821
822
|
weight: style?.weight ?? line.weight,
|
|
822
823
|
family: style?.font,
|
|
823
824
|
italic: style?.italic,
|
|
824
825
|
spacing: style?.letterSpacing,
|
|
825
826
|
widthScale: style?.widthScale,
|
|
826
|
-
|
|
827
|
+
sizeScale: style?.sizeScale,
|
|
827
828
|
align: style?.align,
|
|
828
|
-
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove *
|
|
829
|
-
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow *
|
|
829
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * scaled,
|
|
830
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * scaled,
|
|
830
831
|
widthTie,
|
|
831
832
|
sizeTie
|
|
832
833
|
};
|
|
@@ -1003,14 +1004,16 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
1003
1004
|
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}`))] : [];
|
|
1004
1005
|
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
1005
1006
|
const footerLines = (b.footer ?? "").split("\n").filter((text2) => text2.trim() !== "");
|
|
1007
|
+
const free = (b.lines ?? []).flatMap((text2, i) => text2.trim() === "" ? [] : wrapped(l.strong(text2, SIZE.small, `lines.${i}`), options.wrap));
|
|
1006
1008
|
const footer = footerLines.length > 0 ? [{ lines: footerLines.flatMap((text2) => wrapped(l.soft(text2, SIZE.small, "footer"), options.wrap)), gapAfter: 0 }] : [];
|
|
1009
|
+
const freeGroup = free.length > 0 ? [{ lines: free, gapAfter: GAP.includes * u }] : [];
|
|
1007
1010
|
const parts = {
|
|
1008
1011
|
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
1009
1012
|
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
1010
1013
|
["items" /* Items */]: isList ? rows : [],
|
|
1011
1014
|
["prices" /* Prices */]: prices,
|
|
1012
1015
|
["includes" /* Includes */]: includes,
|
|
1013
|
-
["footer" /* Footer */]: footer
|
|
1016
|
+
["footer" /* Footer */]: [...freeGroup, ...footer]
|
|
1014
1017
|
};
|
|
1015
1018
|
return joined(sectionOrderOf(doc), parts);
|
|
1016
1019
|
}
|
|
@@ -1065,9 +1068,6 @@ function groupBox(group, k, colW) {
|
|
|
1065
1068
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1066
1069
|
}
|
|
1067
1070
|
function lineSize(line, width, k, avail) {
|
|
1068
|
-
if (line.fixedSize === true) {
|
|
1069
|
-
return line.size;
|
|
1070
|
-
}
|
|
1071
1071
|
const indent = bulletIndent(line, k);
|
|
1072
1072
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1073
1073
|
}
|
|
@@ -1077,7 +1077,7 @@ function groupSizes(m, k, avail) {
|
|
|
1077
1077
|
return own;
|
|
1078
1078
|
}
|
|
1079
1079
|
const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
|
|
1080
|
-
return m.group.lines.map((line) => line.
|
|
1080
|
+
return m.group.lines.map((line) => line.size * ratio);
|
|
1081
1081
|
}
|
|
1082
1082
|
function tieMembers(all, k, colW, table, pick) {
|
|
1083
1083
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1086,7 +1086,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1086
1086
|
const sizes = table.get(m) ?? [];
|
|
1087
1087
|
m.group.lines.forEach((line, i) => {
|
|
1088
1088
|
const id = pick(line);
|
|
1089
|
-
if (id !== void 0
|
|
1089
|
+
if (id !== void 0) {
|
|
1090
1090
|
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 };
|
|
1091
1091
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1092
1092
|
}
|
|
@@ -1107,11 +1107,14 @@ function sameWidths(list) {
|
|
|
1107
1107
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1108
1108
|
});
|
|
1109
1109
|
}
|
|
1110
|
+
function applyScales(m, sizes) {
|
|
1111
|
+
return sizes.map((size, i) => size * (m.group.lines[i]?.sizeScale ?? 1));
|
|
1112
|
+
}
|
|
1110
1113
|
function sizeTable(all, k, colW) {
|
|
1111
1114
|
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1112
1115
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1113
1116
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1114
|
-
return table;
|
|
1117
|
+
return new Map(all.map((m) => [m, applyScales(m, table.get(m) ?? [])]));
|
|
1115
1118
|
}
|
|
1116
1119
|
|
|
1117
1120
|
// src/layout/textFlow.ts
|
|
@@ -1171,11 +1174,11 @@ function placeGroup(m, at, out) {
|
|
|
1171
1174
|
group.lines.forEach((line, i) => {
|
|
1172
1175
|
const size = sizes[i] ?? 0;
|
|
1173
1176
|
y += (line.spaceAbove ?? 0) * k;
|
|
1174
|
-
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1177
|
+
const indent = (indented(line) ? line.size * (line.sizeScale ?? 1) * k * BULLET_INDENT : 0) + iconIndent;
|
|
1175
1178
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1176
1179
|
const x = lineX(line, { col, pad, indent, w });
|
|
1177
1180
|
const box = { x, y, w, h: size * LINE_HEIGHT };
|
|
1178
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.
|
|
1181
|
+
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) });
|
|
1179
1182
|
if (line.bullet && out) {
|
|
1180
1183
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1181
1184
|
}
|