@dloizides/poster-render 0.12.0 → 0.13.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/CHANGELOG.md +4 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- 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
|
});
|
|
@@ -985,13 +992,14 @@ function joined(order, parts) {
|
|
|
985
992
|
});
|
|
986
993
|
}
|
|
987
994
|
function bodyGroups(doc, p, u, options = {}) {
|
|
988
|
-
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
995
|
+
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight, doc.bullets !== false);
|
|
989
996
|
const b = doc.blocks;
|
|
990
997
|
const isList = doc.layout === "list" /* List */;
|
|
991
998
|
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
992
999
|
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
1000
|
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
994
|
-
const
|
|
1001
|
+
const footerLines = (b.footer ?? "").split("\n").filter((text2) => text2.trim() !== "");
|
|
1002
|
+
const footer = footerLines.length > 0 ? [{ lines: footerLines.flatMap((text2) => wrapped(l.soft(text2, SIZE.small, "footer"), options.wrap)), gapAfter: 0 }] : [];
|
|
995
1003
|
const parts = {
|
|
996
1004
|
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
997
1005
|
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
@@ -1153,11 +1161,12 @@ function placeGroup(m, at, out) {
|
|
|
1153
1161
|
const top = y;
|
|
1154
1162
|
y += pad;
|
|
1155
1163
|
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);
|
|
1164
|
+
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
1165
|
y += Math.max(0, (d - textH) / 2);
|
|
1158
1166
|
}
|
|
1159
1167
|
group.lines.forEach((line, i) => {
|
|
1160
1168
|
const size = sizes[i] ?? 0;
|
|
1169
|
+
y += (line.spaceAbove ?? 0) * k;
|
|
1161
1170
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1162
1171
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1163
1172
|
const x = lineX(line, { col, pad, indent, w });
|
|
@@ -1166,7 +1175,7 @@ function placeGroup(m, at, out) {
|
|
|
1166
1175
|
if (line.bullet && out) {
|
|
1167
1176
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1168
1177
|
}
|
|
1169
|
-
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
1178
|
+
y += size * LINE_HEIGHT + ((line.gapAfter ?? 0) + (line.spaceBelow ?? 0)) * k;
|
|
1170
1179
|
});
|
|
1171
1180
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
1172
1181
|
y += pad;
|