@dloizides/poster-render 0.12.0 → 0.13.1
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 +8 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,7 @@ var MAX_FONT = 40;
|
|
|
100
100
|
var MIN_SPACING = -0.1;
|
|
101
101
|
var MAX_SPACING = 0.5;
|
|
102
102
|
var MAX_TIES = 12;
|
|
103
|
+
var MAX_SPACE = 2;
|
|
103
104
|
var WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
104
105
|
var lineKey = { type: "string", pattern: LINE_KEY_PATTERN };
|
|
105
106
|
var lineStyle = {
|
|
@@ -113,7 +114,9 @@ var lineStyle = {
|
|
|
113
114
|
weight: { type: "integer", enum: WEIGHTS },
|
|
114
115
|
italic: { type: "boolean" },
|
|
115
116
|
letterSpacing: { type: "number", minimum: MIN_SPACING, maximum: MAX_SPACING },
|
|
116
|
-
align: { type: "string", enum: Object.values(LineAlign) }
|
|
117
|
+
align: { type: "string", enum: Object.values(LineAlign) },
|
|
118
|
+
spaceAbove: { type: "number", minimum: 0, maximum: MAX_SPACE },
|
|
119
|
+
spaceBelow: { type: "number", minimum: 0, maximum: MAX_SPACE }
|
|
117
120
|
}
|
|
118
121
|
};
|
|
119
122
|
var lineStylesSchema = { type: "object", propertyNames: lineKey, additionalProperties: lineStyle };
|
|
@@ -356,6 +359,7 @@ var flierDocSchema = {
|
|
|
356
359
|
lineStyles: lineStylesSchema,
|
|
357
360
|
lineTies: lineTiesSchema,
|
|
358
361
|
rows: rowsSchema,
|
|
362
|
+
bullets: { type: "boolean" },
|
|
359
363
|
sectionOrder: { type: "array", maxItems: MAX_SECTIONS, items: { type: "string", enum: Object.values(BodySection) } },
|
|
360
364
|
items: {
|
|
361
365
|
type: "array",
|
|
@@ -806,10 +810,11 @@ function styled(line, key, sc) {
|
|
|
806
810
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
807
811
|
return { ...line, key };
|
|
808
812
|
}
|
|
813
|
+
const size = line.size * (style?.sizeScale ?? 1);
|
|
809
814
|
return {
|
|
810
815
|
...line,
|
|
811
816
|
key,
|
|
812
|
-
size
|
|
817
|
+
size,
|
|
813
818
|
color: style?.color ?? line.color,
|
|
814
819
|
weight: style?.weight ?? line.weight,
|
|
815
820
|
family: style?.font,
|
|
@@ -818,6 +823,8 @@ function styled(line, key, sc) {
|
|
|
818
823
|
widthScale: style?.widthScale,
|
|
819
824
|
fixedSize: style?.sizeScale === void 0 ? void 0 : true,
|
|
820
825
|
align: style?.align,
|
|
826
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * size,
|
|
827
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * size,
|
|
821
828
|
widthTie,
|
|
822
829
|
sizeTie
|
|
823
830
|
};
|
|
@@ -865,14 +872,14 @@ var GAP = {
|
|
|
865
872
|
rule: 8,
|
|
866
873
|
divider: 24
|
|
867
874
|
};
|
|
868
|
-
var makers = (p, u, sc, timeWeight = SEMI) => ({
|
|
875
|
+
var makers = (p, u, sc, timeWeight = SEMI, bullets = true) => ({
|
|
869
876
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
870
877
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
871
878
|
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
872
879
|
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
873
880
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
874
881
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
875
|
-
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: p.accent }, key, sc),
|
|
882
|
+
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: bullets ? p.accent : void 0 }, key, sc),
|
|
876
883
|
soft: (text2, size, key) => styled({ text: text2, role: "body", weight: MEDIUM, size: size * u, color: p.soft }, key, sc),
|
|
877
884
|
time: (text2, size, key) => styled({ text: text2, role: "body", weight: timeWeight, size: size * u, color: p.accent }, key, sc)
|
|
878
885
|
});
|
|
@@ -921,7 +928,9 @@ function halves(text2) {
|
|
|
921
928
|
}
|
|
922
929
|
function wrapped(line, wrap) {
|
|
923
930
|
const parts = wrap ? halves(line.text) : [line.text];
|
|
924
|
-
|
|
931
|
+
const last = parts.length - 1;
|
|
932
|
+
const edges = (i) => ({ spaceAbove: i === 0 ? line.spaceAbove : void 0, spaceBelow: i === last ? line.spaceBelow : void 0 });
|
|
933
|
+
return parts.length === 1 ? [line] : parts.map((text2, i) => i === 0 ? { ...line, ...edges(i), text: text2, tail: void 0 } : { ...line, ...edges(i), text: text2, tail: void 0, bullet: void 0, hang: line.bullet !== void 0 });
|
|
925
934
|
}
|
|
926
935
|
function scheduleLines(doc, l, row, i) {
|
|
927
936
|
const r3 = doc.rows;
|
|
@@ -985,13 +994,14 @@ function joined(order, parts) {
|
|
|
985
994
|
});
|
|
986
995
|
}
|
|
987
996
|
function bodyGroups(doc, p, u, options = {}) {
|
|
988
|
-
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
997
|
+
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight, doc.bullets !== false);
|
|
989
998
|
const b = doc.blocks;
|
|
990
999
|
const isList = doc.layout === "list" /* List */;
|
|
991
1000
|
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
992
1001
|
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}`))] : [];
|
|
993
1002
|
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
994
|
-
const
|
|
1003
|
+
const footerLines = (b.footer ?? "").split("\n").filter((text2) => text2.trim() !== "");
|
|
1004
|
+
const footer = footerLines.length > 0 ? [{ lines: footerLines.flatMap((text2) => wrapped(l.soft(text2, SIZE.small, "footer"), options.wrap)), gapAfter: 0 }] : [];
|
|
995
1005
|
const parts = {
|
|
996
1006
|
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
997
1007
|
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
@@ -1153,11 +1163,12 @@ function placeGroup(m, at, out) {
|
|
|
1153
1163
|
const top = y;
|
|
1154
1164
|
y += pad;
|
|
1155
1165
|
if (group.icon?.centre === true) {
|
|
1156
|
-
const textH = group.lines.reduce((h, line, i) => h + (sizes[i] ?? 0) * LINE_HEIGHT + (i < group.lines.length - 1 ? (line.gapAfter ?? 0) * k : 0), 0);
|
|
1166
|
+
const textH = group.lines.reduce((h, line, i) => h + (sizes[i] ?? 0) * LINE_HEIGHT + ((line.spaceAbove ?? 0) + (line.spaceBelow ?? 0)) * k + (i < group.lines.length - 1 ? (line.gapAfter ?? 0) * k : 0), 0);
|
|
1157
1167
|
y += Math.max(0, (d - textH) / 2);
|
|
1158
1168
|
}
|
|
1159
1169
|
group.lines.forEach((line, i) => {
|
|
1160
1170
|
const size = sizes[i] ?? 0;
|
|
1171
|
+
y += (line.spaceAbove ?? 0) * k;
|
|
1161
1172
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1162
1173
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1163
1174
|
const x = lineX(line, { col, pad, indent, w });
|
|
@@ -1166,7 +1177,7 @@ function placeGroup(m, at, out) {
|
|
|
1166
1177
|
if (line.bullet && out) {
|
|
1167
1178
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1168
1179
|
}
|
|
1169
|
-
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
1180
|
+
y += size * LINE_HEIGHT + ((line.gapAfter ?? 0) + (line.spaceBelow ?? 0)) * k;
|
|
1170
1181
|
});
|
|
1171
1182
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
1172
1183
|
y += pad;
|