@dloizides/poster-render 0.11.3 → 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 +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.js +126 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,17 @@ var BackgroundStyle = /* @__PURE__ */ ((BackgroundStyle2) => {
|
|
|
7
7
|
return BackgroundStyle2;
|
|
8
8
|
})(BackgroundStyle || {});
|
|
9
9
|
|
|
10
|
+
// src/enums/BodySection.ts
|
|
11
|
+
var BodySection = /* @__PURE__ */ ((BodySection2) => {
|
|
12
|
+
BodySection2["Venue"] = "venue";
|
|
13
|
+
BodySection2["Schedule"] = "schedule";
|
|
14
|
+
BodySection2["Items"] = "items";
|
|
15
|
+
BodySection2["Prices"] = "prices";
|
|
16
|
+
BodySection2["Includes"] = "includes";
|
|
17
|
+
BodySection2["Footer"] = "footer";
|
|
18
|
+
return BodySection2;
|
|
19
|
+
})(BodySection || {});
|
|
20
|
+
|
|
10
21
|
// src/enums/FontSetId.ts
|
|
11
22
|
var FontSetId = /* @__PURE__ */ ((FontSetId2) => {
|
|
12
23
|
FontSetId2["Classic"] = "classic";
|
|
@@ -86,13 +97,10 @@ var RowIcon = /* @__PURE__ */ ((RowIcon2) => {
|
|
|
86
97
|
// src/schema/lineStyleSchema.ts
|
|
87
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]))$";
|
|
88
99
|
var MAX_FONT = 40;
|
|
89
|
-
var MIN_SIZE_SCALE = 0.25;
|
|
90
|
-
var MAX_SIZE_SCALE = 3;
|
|
91
|
-
var MIN_WIDTH_SCALE = 0.5;
|
|
92
|
-
var MAX_WIDTH_SCALE = 1.5;
|
|
93
100
|
var MIN_SPACING = -0.1;
|
|
94
101
|
var MAX_SPACING = 0.5;
|
|
95
102
|
var MAX_TIES = 12;
|
|
103
|
+
var MAX_SPACE = 2;
|
|
96
104
|
var WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
97
105
|
var lineKey = { type: "string", pattern: LINE_KEY_PATTERN };
|
|
98
106
|
var lineStyle = {
|
|
@@ -100,13 +108,15 @@ var lineStyle = {
|
|
|
100
108
|
additionalProperties: false,
|
|
101
109
|
properties: {
|
|
102
110
|
font: { type: "string", minLength: 1, maxLength: MAX_FONT, pattern: "^[A-Za-z0-9 ]+$" },
|
|
103
|
-
sizeScale: { type: "number", minimum:
|
|
104
|
-
widthScale: { type: "number", minimum:
|
|
111
|
+
sizeScale: { type: "number", minimum: 0 },
|
|
112
|
+
widthScale: { type: "number", minimum: 0 },
|
|
105
113
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
106
114
|
weight: { type: "integer", enum: WEIGHTS },
|
|
107
115
|
italic: { type: "boolean" },
|
|
108
116
|
letterSpacing: { type: "number", minimum: MIN_SPACING, maximum: MAX_SPACING },
|
|
109
|
-
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 }
|
|
110
120
|
}
|
|
111
121
|
};
|
|
112
122
|
var lineStylesSchema = { type: "object", propertyNames: lineKey, additionalProperties: lineStyle };
|
|
@@ -270,6 +280,7 @@ var MIN_SCALE = 0.3;
|
|
|
270
280
|
var MAX_HEADER_GAP = 200;
|
|
271
281
|
var MIN_DATE_SCALE = 0.5;
|
|
272
282
|
var MAX_DATE_SCALE = 2;
|
|
283
|
+
var MAX_SECTIONS = 6;
|
|
273
284
|
var text = (maxLength) => ({ type: "string", minLength: 1, maxLength });
|
|
274
285
|
var scheduleRow = {
|
|
275
286
|
type: "object",
|
|
@@ -348,6 +359,8 @@ var flierDocSchema = {
|
|
|
348
359
|
lineStyles: lineStylesSchema,
|
|
349
360
|
lineTies: lineTiesSchema,
|
|
350
361
|
rows: rowsSchema,
|
|
362
|
+
bullets: { type: "boolean" },
|
|
363
|
+
sectionOrder: { type: "array", maxItems: MAX_SECTIONS, items: { type: "string", enum: Object.values(BodySection) } },
|
|
351
364
|
items: {
|
|
352
365
|
type: "array",
|
|
353
366
|
minItems: 1,
|
|
@@ -797,22 +810,38 @@ function styled(line, key, sc) {
|
|
|
797
810
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
798
811
|
return { ...line, key };
|
|
799
812
|
}
|
|
813
|
+
const size = line.size * (style?.sizeScale ?? 1);
|
|
800
814
|
return {
|
|
801
815
|
...line,
|
|
802
816
|
key,
|
|
803
|
-
size
|
|
817
|
+
size,
|
|
804
818
|
color: style?.color ?? line.color,
|
|
805
819
|
weight: style?.weight ?? line.weight,
|
|
806
820
|
family: style?.font,
|
|
807
821
|
italic: style?.italic,
|
|
808
822
|
spacing: style?.letterSpacing,
|
|
809
823
|
widthScale: style?.widthScale,
|
|
824
|
+
fixedSize: style?.sizeScale === void 0 ? void 0 : true,
|
|
810
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,
|
|
811
828
|
widthTie,
|
|
812
829
|
sizeTie
|
|
813
830
|
};
|
|
814
831
|
}
|
|
815
832
|
|
|
833
|
+
// src/layout/sectionOrder.ts
|
|
834
|
+
var EVENT_ORDER = ["venue" /* Venue */, "schedule" /* Schedule */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
835
|
+
var LIST_ORDER = ["venue" /* Venue */, "items" /* Items */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
836
|
+
function defaultSectionOrder(layout) {
|
|
837
|
+
return [...layout === "list" /* List */ ? LIST_ORDER : EVENT_ORDER];
|
|
838
|
+
}
|
|
839
|
+
function sectionOrderOf(doc) {
|
|
840
|
+
const base2 = defaultSectionOrder(doc.layout);
|
|
841
|
+
const own = (doc.sectionOrder ?? []).filter((s, i, all) => base2.includes(s) && all.indexOf(s) === i);
|
|
842
|
+
return [...own, ...base2.filter((s) => !own.includes(s))];
|
|
843
|
+
}
|
|
844
|
+
|
|
816
845
|
// src/layout/blockGroups.ts
|
|
817
846
|
var BOLD = 700;
|
|
818
847
|
var SEMI = 600;
|
|
@@ -843,14 +872,14 @@ var GAP = {
|
|
|
843
872
|
rule: 8,
|
|
844
873
|
divider: 24
|
|
845
874
|
};
|
|
846
|
-
var makers = (p, u, sc, timeWeight = SEMI) => ({
|
|
875
|
+
var makers = (p, u, sc, timeWeight = SEMI, bullets = true) => ({
|
|
847
876
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
848
877
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
849
878
|
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
850
879
|
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
851
880
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
852
881
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
853
|
-
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),
|
|
854
883
|
soft: (text2, size, key) => styled({ text: text2, role: "body", weight: MEDIUM, size: size * u, color: p.soft }, key, sc),
|
|
855
884
|
time: (text2, size, key) => styled({ text: text2, role: "body", weight: timeWeight, size: size * u, color: p.accent }, key, sc)
|
|
856
885
|
});
|
|
@@ -911,28 +940,26 @@ var tailed = (line, key, headLength) => ({ ...line, tail: { key, at: line.text.l
|
|
|
911
940
|
var priceAmount = (doc, line) => doc.rows?.priceGap === void 0 ? line : { ...line, gapAfter: doc.rows.priceGap };
|
|
912
941
|
function eventGroups(doc, l, u, options) {
|
|
913
942
|
const b = doc.blocks;
|
|
914
|
-
const
|
|
943
|
+
const rows = [];
|
|
944
|
+
const priced = [];
|
|
915
945
|
const schedule2 = b.schedule ?? [];
|
|
916
946
|
const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
|
|
917
947
|
const lastRow = schedule2.length + prices.length - 1;
|
|
918
948
|
const icons2 = doc.rows?.icons;
|
|
919
949
|
schedule2.forEach((row, i) => {
|
|
920
950
|
const lines = options.compact ? [tailed(l.strong(`${row.label} ${row.time}`, SIZE.scheduleLabel, `schedule.${i}.label`), `schedule.${i}.time`, row.label.length)] : scheduleLines(doc, l, row, i);
|
|
921
|
-
|
|
951
|
+
rows.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
|
|
922
952
|
});
|
|
923
953
|
prices.forEach((row, i) => {
|
|
924
954
|
const lines = options.compact ? [tailed(l.strong(`${row.amount} ${row.label}`, SIZE.priceAmount, `prices.${i}.amount`), `prices.${i}.label`, row.amount.length)] : [priceAmount(doc, l.strong(row.amount, SIZE.priceAmount, `prices.${i}.amount`)), l.accent(row.label, SIZE.priceLabel * (doc.rows?.priceLabelScale ?? 1), `prices.${i}.label`)];
|
|
925
|
-
|
|
955
|
+
priced.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
|
|
926
956
|
});
|
|
927
|
-
return
|
|
957
|
+
return [rows, priced];
|
|
928
958
|
}
|
|
929
959
|
function listGroups(doc, l, u, dateScale) {
|
|
930
960
|
const groups = (doc.items ?? []).map((item, n) => itemGroup(item, n, l, { u, dateScale }));
|
|
931
961
|
const prices = doc.blocks.prices?.map((row, i) => tailed(l.strong(`${row.amount} ${row.label}`, SIZE.listPrice, `prices.${i}.amount`), `prices.${i}.label`, row.amount.length)) ?? [];
|
|
932
|
-
|
|
933
|
-
groups.push({ lines: prices, gapAfter: GAP.row * u });
|
|
934
|
-
}
|
|
935
|
-
return groups;
|
|
962
|
+
return [groups, prices.length > 0 ? [{ lines: prices, gapAfter: GAP.row * u }] : []];
|
|
936
963
|
}
|
|
937
964
|
function flankPriceGroups(doc, p, u) {
|
|
938
965
|
const l = makers(p, u, styleContext(doc));
|
|
@@ -941,28 +968,47 @@ function flankPriceGroups(doc, p, u) {
|
|
|
941
968
|
function pinOf(look, u) {
|
|
942
969
|
return { size: look?.pinSize === void 0 ? void 0 : look.pinSize * u, gap: look?.pinGap === void 0 ? void 0 : look.pinGap * u, shift: look?.pinShift === void 0 ? void 0 : look.pinShift * u, centre: look?.centred };
|
|
943
970
|
}
|
|
971
|
+
function venueGroups(doc, p, u, l) {
|
|
972
|
+
const b = doc.blocks;
|
|
973
|
+
if (!b.venue) {
|
|
974
|
+
return [];
|
|
975
|
+
}
|
|
976
|
+
const size = doc.layout === "list" /* List */ ? SIZE.listVenue : SIZE.venue;
|
|
977
|
+
const look = doc.rows?.venue;
|
|
978
|
+
const line = look?.body === true ? l.bodyVenue : l.venue;
|
|
979
|
+
const venue = look?.oneLine === true ? [b.venue.join(" ")] : b.venue;
|
|
980
|
+
return [{ lines: venue.map((v, i) => line(v, size, `venue.${i}`)), gapAfter: GAP.venue * u, rule: dividerOf(doc, p, u) ?? { color: p.accent, height: GAP.rule * u }, ruleBelow: true, icon: { color: p.icon ?? p.accent, glyph: p.background, bare: look?.bare, ...pinOf(look, u) } }];
|
|
981
|
+
}
|
|
982
|
+
var bound = (s, next) => s === "venue" /* Venue */ && next === "schedule" /* Schedule */ || s === "includes" /* Includes */ && next === "footer" /* Footer */;
|
|
983
|
+
function joined(order, parts) {
|
|
984
|
+
const filled = order.filter((s) => parts[s].length > 0);
|
|
985
|
+
return filled.flatMap((s, n) => {
|
|
986
|
+
const groups = parts[s];
|
|
987
|
+
if (!bound(s, filled[n + 1])) {
|
|
988
|
+
return groups;
|
|
989
|
+
}
|
|
990
|
+
const attach = s === "includes" /* Includes */ ? { attachNext: true } : {};
|
|
991
|
+
return groups.map((g, i) => i === groups.length - 1 ? { ...g, keepWithNext: true, ...attach } : g);
|
|
992
|
+
});
|
|
993
|
+
}
|
|
944
994
|
function bodyGroups(doc, p, u, options = {}) {
|
|
945
|
-
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
995
|
+
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight, doc.bullets !== false);
|
|
946
996
|
const b = doc.blocks;
|
|
947
|
-
const groups = [];
|
|
948
997
|
const isList = doc.layout === "list" /* List */;
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small, "footer"), options.wrap), gapAfter: 0 });
|
|
964
|
-
}
|
|
965
|
-
return groups;
|
|
998
|
+
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
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}`))] : [];
|
|
1000
|
+
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
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 }] : [];
|
|
1003
|
+
const parts = {
|
|
1004
|
+
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
1005
|
+
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
1006
|
+
["items" /* Items */]: isList ? rows : [],
|
|
1007
|
+
["prices" /* Prices */]: prices,
|
|
1008
|
+
["includes" /* Includes */]: includes,
|
|
1009
|
+
["footer" /* Footer */]: footer
|
|
1010
|
+
};
|
|
1011
|
+
return joined(sectionOrderOf(doc), parts);
|
|
966
1012
|
}
|
|
967
1013
|
|
|
968
1014
|
// src/layout/lineRuns.ts
|
|
@@ -1015,16 +1061,19 @@ function groupBox(group, k, colW) {
|
|
|
1015
1061
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1016
1062
|
}
|
|
1017
1063
|
function lineSize(line, width, k, avail) {
|
|
1064
|
+
if (line.fixedSize === true) {
|
|
1065
|
+
return line.size;
|
|
1066
|
+
}
|
|
1018
1067
|
const indent = bulletIndent(line, k);
|
|
1019
1068
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1020
1069
|
}
|
|
1021
|
-
function groupSizes(m, k, avail
|
|
1022
|
-
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k,
|
|
1070
|
+
function groupSizes(m, k, avail) {
|
|
1071
|
+
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k, avail * (line.widthScale ?? 1)));
|
|
1023
1072
|
if (!m.group.uniform) {
|
|
1024
1073
|
return own;
|
|
1025
1074
|
}
|
|
1026
1075
|
const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
|
|
1027
|
-
return m.group.lines.map((line) => line.size * ratio);
|
|
1076
|
+
return m.group.lines.map((line) => line.fixedSize === true ? line.size : line.size * ratio);
|
|
1028
1077
|
}
|
|
1029
1078
|
function tieMembers(all, k, colW, table, pick) {
|
|
1030
1079
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1033,7 +1082,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1033
1082
|
const sizes = table.get(m) ?? [];
|
|
1034
1083
|
m.group.lines.forEach((line, i) => {
|
|
1035
1084
|
const id = pick(line);
|
|
1036
|
-
if (id !== void 0) {
|
|
1085
|
+
if (id !== void 0 && line.fixedSize !== true) {
|
|
1037
1086
|
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 };
|
|
1038
1087
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1039
1088
|
}
|
|
@@ -1054,8 +1103,8 @@ function sameWidths(list) {
|
|
|
1054
1103
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1055
1104
|
});
|
|
1056
1105
|
}
|
|
1057
|
-
function sizeTable(all, k, colW
|
|
1058
|
-
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail
|
|
1106
|
+
function sizeTable(all, k, colW) {
|
|
1107
|
+
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1059
1108
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1060
1109
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1061
1110
|
return table;
|
|
@@ -1112,20 +1161,21 @@ function placeGroup(m, at, out) {
|
|
|
1112
1161
|
const top = y;
|
|
1113
1162
|
y += pad;
|
|
1114
1163
|
if (group.icon?.centre === true) {
|
|
1115
|
-
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);
|
|
1116
1165
|
y += Math.max(0, (d - textH) / 2);
|
|
1117
1166
|
}
|
|
1118
1167
|
group.lines.forEach((line, i) => {
|
|
1119
1168
|
const size = sizes[i] ?? 0;
|
|
1169
|
+
y += (line.spaceAbove ?? 0) * k;
|
|
1120
1170
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1121
1171
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1122
1172
|
const x = lineX(line, { col, pad, indent, w });
|
|
1123
1173
|
const box = { x, y, w, h: size * LINE_HEIGHT };
|
|
1124
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
|
|
1174
|
+
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.fixedSize === true ? { fixed: true } : {}, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
|
|
1125
1175
|
if (line.bullet && out) {
|
|
1126
1176
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1127
1177
|
}
|
|
1128
|
-
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
1178
|
+
y += size * LINE_HEIGHT + ((line.gapAfter ?? 0) + (line.spaceBelow ?? 0)) * k;
|
|
1129
1179
|
});
|
|
1130
1180
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
1131
1181
|
y += pad;
|
|
@@ -1187,11 +1237,11 @@ function splitColumns(groups, zone) {
|
|
|
1187
1237
|
}
|
|
1188
1238
|
cut = keepTogether(groups, heights, cut);
|
|
1189
1239
|
return [
|
|
1190
|
-
{ col: { ...zone, w
|
|
1191
|
-
{ col: { ...zone, x: zone.x + w + gap, w
|
|
1240
|
+
{ col: { ...zone, w }, groups: groups.slice(0, cut) },
|
|
1241
|
+
{ col: { ...zone, x: zone.x + w + gap, w }, groups: groups.slice(cut) }
|
|
1192
1242
|
];
|
|
1193
1243
|
}
|
|
1194
|
-
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0
|
|
1244
|
+
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0);
|
|
1195
1245
|
function largestK(columns, zoneH) {
|
|
1196
1246
|
const fits = (k) => {
|
|
1197
1247
|
const table = tableFor(columns, k);
|
|
@@ -1341,11 +1391,11 @@ function flowAll(ctx, input, base2, reflow) {
|
|
|
1341
1391
|
const head = flow(ctx, headerGroups(doc, palette, u), zones.text, fonts);
|
|
1342
1392
|
const flanks = geo.flanks ?? [];
|
|
1343
1393
|
const tight = closeHeaderGap(geo, head, doc.tuning?.headerGap, u);
|
|
1344
|
-
const body = flow(ctx, bodyGroups(doc, palette, u, { withPrices: flanks.length === 0, compact: reflow.compact, wrap: reflow.wrap, dateScale: doc.tuning?.itemDateScale }),
|
|
1394
|
+
const body = flow(ctx, bodyGroups(doc, palette, u, { withPrices: flanks.length === 0, compact: reflow.compact, wrap: reflow.wrap, dateScale: doc.tuning?.itemDateScale }), tight.body, fonts);
|
|
1345
1395
|
const sides = flanks.length > 0 ? equalFlanks(ctx, flankPriceGroups(doc, palette, u), flanks, fonts) : [emptyFlow()];
|
|
1346
1396
|
return { geo: tight, zones, head, body, sides };
|
|
1347
1397
|
}
|
|
1348
|
-
var smallest = (t) => Math.min(Infinity, ...[t.head, t.body, ...t.sides].flatMap((f) => f.texts.map((x) => x.box.h / LINE_HEIGHT3)));
|
|
1398
|
+
var smallest = (t) => Math.min(Infinity, ...[t.head, t.body, ...t.sides].flatMap((f) => f.texts.filter((x) => x.fixed !== true).map((x) => x.box.h / LINE_HEIGHT3)));
|
|
1349
1399
|
function shiftHeader(geo, shift) {
|
|
1350
1400
|
const { header, body } = geo;
|
|
1351
1401
|
const stacked = header.y + header.h <= body.y && header.x < body.x + body.w && body.x < header.x + header.w;
|
|
@@ -1430,6 +1480,21 @@ function lineBoxesOf(texts) {
|
|
|
1430
1480
|
return boxes;
|
|
1431
1481
|
}
|
|
1432
1482
|
|
|
1483
|
+
// src/render/roleOrder.ts
|
|
1484
|
+
var INDEX = /^\d+$/;
|
|
1485
|
+
var roleOf = (key) => key.split(".").filter((part) => !INDEX.test(part)).join(".");
|
|
1486
|
+
function roleOrder(boxes) {
|
|
1487
|
+
const first = /* @__PURE__ */ new Map();
|
|
1488
|
+
Object.entries(boxes).forEach(([key, box]) => {
|
|
1489
|
+
const role = roleOf(key);
|
|
1490
|
+
const seen = first.get(role);
|
|
1491
|
+
if (box !== void 0 && (seen === void 0 || box.y < seen.y || box.y === seen.y && box.x < seen.x)) {
|
|
1492
|
+
first.set(role, box);
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
return [...first.entries()].sort(([, a], [, b]) => a.y - b.y || a.x - b.x).map(([role]) => role);
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1433
1498
|
// src/render/overlap.ts
|
|
1434
1499
|
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
1435
1500
|
function placePicture(image, region, slot, fit) {
|
|
@@ -1681,18 +1746,21 @@ function render(input, assets, canvas) {
|
|
|
1681
1746
|
if (layered) {
|
|
1682
1747
|
flows.forEach((f) => drawMarks(ctx, f, radius));
|
|
1683
1748
|
}
|
|
1749
|
+
const lineBoxes = lineBoxesOf(flows.flatMap((f) => f.texts));
|
|
1684
1750
|
return {
|
|
1685
1751
|
width,
|
|
1686
1752
|
height,
|
|
1687
1753
|
picture,
|
|
1688
1754
|
pictureRegion: region,
|
|
1689
1755
|
textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
|
|
1690
|
-
lineBoxes
|
|
1756
|
+
lineBoxes,
|
|
1691
1757
|
cardBoxes: body.cards.map((c) => c.rect),
|
|
1692
1758
|
iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
|
|
1693
1759
|
ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
|
|
1694
1760
|
logo,
|
|
1695
|
-
backdrop
|
|
1761
|
+
backdrop,
|
|
1762
|
+
sectionOrder: sectionOrderOf(doc),
|
|
1763
|
+
roleOrder: roleOrder(lineBoxes)
|
|
1696
1764
|
};
|
|
1697
1765
|
}
|
|
1698
1766
|
|
|
@@ -1786,6 +1854,6 @@ var kizombaWorkshop = {
|
|
|
1786
1854
|
};
|
|
1787
1855
|
var kizombaWorkshopDocs = [...WORKSHOPS.map(workshopDoc), kizombaWorkshop];
|
|
1788
1856
|
|
|
1789
|
-
export { BackgroundStyle, FONT_SETS, FORMAT_SIZES, FlierDocError, FontSetId, FormatId, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, LayoutId, LineAlign, LineTieKind, PALETTES, PaletteId, PictureAnchor, RowIcon, defaultLayoutFor, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, sameSize, sameWidth, validateFlierDoc };
|
|
1857
|
+
export { BackgroundStyle, BodySection, FONT_SETS, FORMAT_SIZES, FlierDocError, FontSetId, FormatId, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, LayoutId, LineAlign, LineTieKind, PALETTES, PaletteId, PictureAnchor, RowIcon, defaultLayoutFor, defaultSectionOrder, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, roleOf, roleOrder, sameSize, sameWidth, sectionOrderOf, validateFlierDoc };
|
|
1790
1858
|
//# sourceMappingURL=index.mjs.map
|
|
1791
1859
|
//# sourceMappingURL=index.mjs.map
|