@dloizides/poster-render 0.11.3 → 0.12.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/dist/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +110 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,15 @@ declare enum BackgroundStyle {
|
|
|
5
5
|
Brush = "brush"
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare enum BodySection {
|
|
9
|
+
Venue = "venue",
|
|
10
|
+
Schedule = "schedule",
|
|
11
|
+
Items = "items",
|
|
12
|
+
Prices = "prices",
|
|
13
|
+
Includes = "includes",
|
|
14
|
+
Footer = "footer"
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
declare enum FontSetId {
|
|
9
18
|
Classic = "classic",
|
|
10
19
|
Modern = "modern",
|
|
@@ -178,6 +187,7 @@ interface FlierDoc {
|
|
|
178
187
|
lineStyles?: Record<LineKey, LineStyle | undefined>;
|
|
179
188
|
lineTies?: LineTie[];
|
|
180
189
|
rows?: RowTheme;
|
|
190
|
+
sectionOrder?: BodySection[];
|
|
181
191
|
}
|
|
182
192
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
183
193
|
type LineKey = string;
|
|
@@ -267,6 +277,8 @@ interface RenderReport {
|
|
|
267
277
|
ruleBoxes: Rect[];
|
|
268
278
|
logo: Rect | null;
|
|
269
279
|
backdrop: Rect | null;
|
|
280
|
+
sectionOrder: BodySection[];
|
|
281
|
+
roleOrder: string[];
|
|
270
282
|
}
|
|
271
283
|
interface Palette {
|
|
272
284
|
background: string;
|
|
@@ -325,6 +337,16 @@ declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
|
325
337
|
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
326
338
|
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
327
339
|
|
|
340
|
+
/** The body sections of a layout in the order it draws them; the title block always sits above. */
|
|
341
|
+
declare function defaultSectionOrder(layout: LayoutId): BodySection[];
|
|
342
|
+
/** The doc's own section order (unknown and repeated entries dropped), then the layout's remaining sections. */
|
|
343
|
+
declare function sectionOrderOf(doc: Pick<FlierDoc, 'layout' | 'sectionOrder'>): BodySection[];
|
|
344
|
+
|
|
345
|
+
/** The role of a line key: the key without its list indices, so "schedule.0.label" is "schedule.label". */
|
|
346
|
+
declare const roleOf: (key: LineKey) => string;
|
|
347
|
+
/** Every drawn role once, ordered by the top of its first line, then left to right. */
|
|
348
|
+
declare function roleOrder(boxes: Record<LineKey, Rect | undefined>): string[];
|
|
349
|
+
|
|
328
350
|
interface DataUrlCanvas {
|
|
329
351
|
toDataURL(type: string): string;
|
|
330
352
|
}
|
|
@@ -345,4 +367,4 @@ declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
|
345
367
|
declare const kizombaWorkshop: FlierDoc;
|
|
346
368
|
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
347
369
|
|
|
348
|
-
export { BackgroundStyle, type DataUrlCanvas, FONT_SETS, FORMAT_SIZES, type FlierBlocks, type FlierDoc, FlierDocError, type FlierDocResult, type FontSet, FontSetId, FormatId, type FormatSize, type IncludesBlock, type JsonSchema, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, type LayoutCatalogueEntry, LayoutId, LineAlign, type LineKey, type LineStyle, type LineTie, LineTieKind, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureOverlap, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterGradient, type PosterImage, type PosterTuning, type PriceRow, type Rect, type RenderReport, RowIcon, type RowTheme, type ScheduleRow, type SkyStop, type TextMetricsLike, defaultLayoutFor, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, sameSize, sameWidth, validateFlierDoc };
|
|
370
|
+
export { BackgroundStyle, BodySection, type DataUrlCanvas, FONT_SETS, FORMAT_SIZES, type FlierBlocks, type FlierDoc, FlierDocError, type FlierDocResult, type FontSet, FontSetId, FormatId, type FormatSize, type IncludesBlock, type JsonSchema, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, type LayoutCatalogueEntry, LayoutId, LineAlign, type LineKey, type LineStyle, type LineTie, LineTieKind, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureOverlap, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterGradient, type PosterImage, type PosterTuning, type PriceRow, type Rect, type RenderReport, RowIcon, type RowTheme, type ScheduleRow, type SkyStop, type TextMetricsLike, defaultLayoutFor, defaultSectionOrder, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, roleOf, roleOrder, sameSize, sameWidth, sectionOrderOf, validateFlierDoc };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ declare enum BackgroundStyle {
|
|
|
5
5
|
Brush = "brush"
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare enum BodySection {
|
|
9
|
+
Venue = "venue",
|
|
10
|
+
Schedule = "schedule",
|
|
11
|
+
Items = "items",
|
|
12
|
+
Prices = "prices",
|
|
13
|
+
Includes = "includes",
|
|
14
|
+
Footer = "footer"
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
declare enum FontSetId {
|
|
9
18
|
Classic = "classic",
|
|
10
19
|
Modern = "modern",
|
|
@@ -178,6 +187,7 @@ interface FlierDoc {
|
|
|
178
187
|
lineStyles?: Record<LineKey, LineStyle | undefined>;
|
|
179
188
|
lineTies?: LineTie[];
|
|
180
189
|
rows?: RowTheme;
|
|
190
|
+
sectionOrder?: BodySection[];
|
|
181
191
|
}
|
|
182
192
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
183
193
|
type LineKey = string;
|
|
@@ -267,6 +277,8 @@ interface RenderReport {
|
|
|
267
277
|
ruleBoxes: Rect[];
|
|
268
278
|
logo: Rect | null;
|
|
269
279
|
backdrop: Rect | null;
|
|
280
|
+
sectionOrder: BodySection[];
|
|
281
|
+
roleOrder: string[];
|
|
270
282
|
}
|
|
271
283
|
interface Palette {
|
|
272
284
|
background: string;
|
|
@@ -325,6 +337,16 @@ declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
|
325
337
|
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
326
338
|
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
327
339
|
|
|
340
|
+
/** The body sections of a layout in the order it draws them; the title block always sits above. */
|
|
341
|
+
declare function defaultSectionOrder(layout: LayoutId): BodySection[];
|
|
342
|
+
/** The doc's own section order (unknown and repeated entries dropped), then the layout's remaining sections. */
|
|
343
|
+
declare function sectionOrderOf(doc: Pick<FlierDoc, 'layout' | 'sectionOrder'>): BodySection[];
|
|
344
|
+
|
|
345
|
+
/** The role of a line key: the key without its list indices, so "schedule.0.label" is "schedule.label". */
|
|
346
|
+
declare const roleOf: (key: LineKey) => string;
|
|
347
|
+
/** Every drawn role once, ordered by the top of its first line, then left to right. */
|
|
348
|
+
declare function roleOrder(boxes: Record<LineKey, Rect | undefined>): string[];
|
|
349
|
+
|
|
328
350
|
interface DataUrlCanvas {
|
|
329
351
|
toDataURL(type: string): string;
|
|
330
352
|
}
|
|
@@ -345,4 +367,4 @@ declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
|
345
367
|
declare const kizombaWorkshop: FlierDoc;
|
|
346
368
|
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
347
369
|
|
|
348
|
-
export { BackgroundStyle, type DataUrlCanvas, FONT_SETS, FORMAT_SIZES, type FlierBlocks, type FlierDoc, FlierDocError, type FlierDocResult, type FontSet, FontSetId, FormatId, type FormatSize, type IncludesBlock, type JsonSchema, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, type LayoutCatalogueEntry, LayoutId, LineAlign, type LineKey, type LineStyle, type LineTie, LineTieKind, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureOverlap, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterGradient, type PosterImage, type PosterTuning, type PriceRow, type Rect, type RenderReport, RowIcon, type RowTheme, type ScheduleRow, type SkyStop, type TextMetricsLike, defaultLayoutFor, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, sameSize, sameWidth, validateFlierDoc };
|
|
370
|
+
export { BackgroundStyle, BodySection, type DataUrlCanvas, FONT_SETS, FORMAT_SIZES, type FlierBlocks, type FlierDoc, FlierDocError, type FlierDocResult, type FontSet, FontSetId, FormatId, type FormatSize, type IncludesBlock, type JsonSchema, LAYOUT_CATALOGUE, LINE_KEY_PATTERN, type LayoutCatalogueEntry, LayoutId, LineAlign, type LineKey, type LineStyle, type LineTie, LineTieKind, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureOverlap, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterGradient, type PosterImage, type PosterTuning, type PriceRow, type Rect, type RenderReport, RowIcon, type RowTheme, type ScheduleRow, type SkyStop, type TextMetricsLike, defaultLayoutFor, defaultSectionOrder, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, roleOf, roleOrder, sameSize, sameWidth, sectionOrderOf, validateFlierDoc };
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,17 @@ var BackgroundStyle = /* @__PURE__ */ ((BackgroundStyle2) => {
|
|
|
9
9
|
return BackgroundStyle2;
|
|
10
10
|
})(BackgroundStyle || {});
|
|
11
11
|
|
|
12
|
+
// src/enums/BodySection.ts
|
|
13
|
+
var BodySection = /* @__PURE__ */ ((BodySection2) => {
|
|
14
|
+
BodySection2["Venue"] = "venue";
|
|
15
|
+
BodySection2["Schedule"] = "schedule";
|
|
16
|
+
BodySection2["Items"] = "items";
|
|
17
|
+
BodySection2["Prices"] = "prices";
|
|
18
|
+
BodySection2["Includes"] = "includes";
|
|
19
|
+
BodySection2["Footer"] = "footer";
|
|
20
|
+
return BodySection2;
|
|
21
|
+
})(BodySection || {});
|
|
22
|
+
|
|
12
23
|
// src/enums/FontSetId.ts
|
|
13
24
|
var FontSetId = /* @__PURE__ */ ((FontSetId2) => {
|
|
14
25
|
FontSetId2["Classic"] = "classic";
|
|
@@ -88,10 +99,6 @@ var RowIcon = /* @__PURE__ */ ((RowIcon2) => {
|
|
|
88
99
|
// src/schema/lineStyleSchema.ts
|
|
89
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]))$";
|
|
90
101
|
var MAX_FONT = 40;
|
|
91
|
-
var MIN_SIZE_SCALE = 0.25;
|
|
92
|
-
var MAX_SIZE_SCALE = 3;
|
|
93
|
-
var MIN_WIDTH_SCALE = 0.5;
|
|
94
|
-
var MAX_WIDTH_SCALE = 1.5;
|
|
95
102
|
var MIN_SPACING = -0.1;
|
|
96
103
|
var MAX_SPACING = 0.5;
|
|
97
104
|
var MAX_TIES = 12;
|
|
@@ -102,8 +109,8 @@ var lineStyle = {
|
|
|
102
109
|
additionalProperties: false,
|
|
103
110
|
properties: {
|
|
104
111
|
font: { type: "string", minLength: 1, maxLength: MAX_FONT, pattern: "^[A-Za-z0-9 ]+$" },
|
|
105
|
-
sizeScale: { type: "number", minimum:
|
|
106
|
-
widthScale: { type: "number", minimum:
|
|
112
|
+
sizeScale: { type: "number", minimum: 0 },
|
|
113
|
+
widthScale: { type: "number", minimum: 0 },
|
|
107
114
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
108
115
|
weight: { type: "integer", enum: WEIGHTS },
|
|
109
116
|
italic: { type: "boolean" },
|
|
@@ -272,6 +279,7 @@ var MIN_SCALE = 0.3;
|
|
|
272
279
|
var MAX_HEADER_GAP = 200;
|
|
273
280
|
var MIN_DATE_SCALE = 0.5;
|
|
274
281
|
var MAX_DATE_SCALE = 2;
|
|
282
|
+
var MAX_SECTIONS = 6;
|
|
275
283
|
var text = (maxLength) => ({ type: "string", minLength: 1, maxLength });
|
|
276
284
|
var scheduleRow = {
|
|
277
285
|
type: "object",
|
|
@@ -350,6 +358,7 @@ var flierDocSchema = {
|
|
|
350
358
|
lineStyles: lineStylesSchema,
|
|
351
359
|
lineTies: lineTiesSchema,
|
|
352
360
|
rows: rowsSchema,
|
|
361
|
+
sectionOrder: { type: "array", maxItems: MAX_SECTIONS, items: { type: "string", enum: Object.values(BodySection) } },
|
|
353
362
|
items: {
|
|
354
363
|
type: "array",
|
|
355
364
|
minItems: 1,
|
|
@@ -809,12 +818,25 @@ function styled(line, key, sc) {
|
|
|
809
818
|
italic: style?.italic,
|
|
810
819
|
spacing: style?.letterSpacing,
|
|
811
820
|
widthScale: style?.widthScale,
|
|
821
|
+
fixedSize: style?.sizeScale === void 0 ? void 0 : true,
|
|
812
822
|
align: style?.align,
|
|
813
823
|
widthTie,
|
|
814
824
|
sizeTie
|
|
815
825
|
};
|
|
816
826
|
}
|
|
817
827
|
|
|
828
|
+
// src/layout/sectionOrder.ts
|
|
829
|
+
var EVENT_ORDER = ["venue" /* Venue */, "schedule" /* Schedule */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
830
|
+
var LIST_ORDER = ["venue" /* Venue */, "items" /* Items */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
831
|
+
function defaultSectionOrder(layout) {
|
|
832
|
+
return [...layout === "list" /* List */ ? LIST_ORDER : EVENT_ORDER];
|
|
833
|
+
}
|
|
834
|
+
function sectionOrderOf(doc) {
|
|
835
|
+
const base2 = defaultSectionOrder(doc.layout);
|
|
836
|
+
const own = (doc.sectionOrder ?? []).filter((s, i, all) => base2.includes(s) && all.indexOf(s) === i);
|
|
837
|
+
return [...own, ...base2.filter((s) => !own.includes(s))];
|
|
838
|
+
}
|
|
839
|
+
|
|
818
840
|
// src/layout/blockGroups.ts
|
|
819
841
|
var BOLD = 700;
|
|
820
842
|
var SEMI = 600;
|
|
@@ -913,28 +935,26 @@ var tailed = (line, key, headLength) => ({ ...line, tail: { key, at: line.text.l
|
|
|
913
935
|
var priceAmount = (doc, line) => doc.rows?.priceGap === void 0 ? line : { ...line, gapAfter: doc.rows.priceGap };
|
|
914
936
|
function eventGroups(doc, l, u, options) {
|
|
915
937
|
const b = doc.blocks;
|
|
916
|
-
const
|
|
938
|
+
const rows = [];
|
|
939
|
+
const priced = [];
|
|
917
940
|
const schedule2 = b.schedule ?? [];
|
|
918
941
|
const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
|
|
919
942
|
const lastRow = schedule2.length + prices.length - 1;
|
|
920
943
|
const icons2 = doc.rows?.icons;
|
|
921
944
|
schedule2.forEach((row, i) => {
|
|
922
945
|
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);
|
|
923
|
-
|
|
946
|
+
rows.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
|
|
924
947
|
});
|
|
925
948
|
prices.forEach((row, i) => {
|
|
926
949
|
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`)];
|
|
927
|
-
|
|
950
|
+
priced.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
|
|
928
951
|
});
|
|
929
|
-
return
|
|
952
|
+
return [rows, priced];
|
|
930
953
|
}
|
|
931
954
|
function listGroups(doc, l, u, dateScale) {
|
|
932
955
|
const groups = (doc.items ?? []).map((item, n) => itemGroup(item, n, l, { u, dateScale }));
|
|
933
956
|
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)) ?? [];
|
|
934
|
-
|
|
935
|
-
groups.push({ lines: prices, gapAfter: GAP.row * u });
|
|
936
|
-
}
|
|
937
|
-
return groups;
|
|
957
|
+
return [groups, prices.length > 0 ? [{ lines: prices, gapAfter: GAP.row * u }] : []];
|
|
938
958
|
}
|
|
939
959
|
function flankPriceGroups(doc, p, u) {
|
|
940
960
|
const l = makers(p, u, styleContext(doc));
|
|
@@ -943,28 +963,46 @@ function flankPriceGroups(doc, p, u) {
|
|
|
943
963
|
function pinOf(look, u) {
|
|
944
964
|
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 };
|
|
945
965
|
}
|
|
966
|
+
function venueGroups(doc, p, u, l) {
|
|
967
|
+
const b = doc.blocks;
|
|
968
|
+
if (!b.venue) {
|
|
969
|
+
return [];
|
|
970
|
+
}
|
|
971
|
+
const size = doc.layout === "list" /* List */ ? SIZE.listVenue : SIZE.venue;
|
|
972
|
+
const look = doc.rows?.venue;
|
|
973
|
+
const line = look?.body === true ? l.bodyVenue : l.venue;
|
|
974
|
+
const venue = look?.oneLine === true ? [b.venue.join(" ")] : b.venue;
|
|
975
|
+
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) } }];
|
|
976
|
+
}
|
|
977
|
+
var bound = (s, next) => s === "venue" /* Venue */ && next === "schedule" /* Schedule */ || s === "includes" /* Includes */ && next === "footer" /* Footer */;
|
|
978
|
+
function joined(order, parts) {
|
|
979
|
+
const filled = order.filter((s) => parts[s].length > 0);
|
|
980
|
+
return filled.flatMap((s, n) => {
|
|
981
|
+
const groups = parts[s];
|
|
982
|
+
if (!bound(s, filled[n + 1])) {
|
|
983
|
+
return groups;
|
|
984
|
+
}
|
|
985
|
+
const attach = s === "includes" /* Includes */ ? { attachNext: true } : {};
|
|
986
|
+
return groups.map((g, i) => i === groups.length - 1 ? { ...g, keepWithNext: true, ...attach } : g);
|
|
987
|
+
});
|
|
988
|
+
}
|
|
946
989
|
function bodyGroups(doc, p, u, options = {}) {
|
|
947
990
|
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
948
991
|
const b = doc.blocks;
|
|
949
|
-
const groups = [];
|
|
950
992
|
const isList = doc.layout === "list" /* List */;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
if (b.footer) {
|
|
965
|
-
groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small, "footer"), options.wrap), gapAfter: 0 });
|
|
966
|
-
}
|
|
967
|
-
return groups;
|
|
993
|
+
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
994
|
+
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}`))] : [];
|
|
995
|
+
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
996
|
+
const footer = b.footer ? [{ lines: wrapped(l.soft(b.footer, SIZE.small, "footer"), options.wrap), gapAfter: 0 }] : [];
|
|
997
|
+
const parts = {
|
|
998
|
+
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
999
|
+
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
1000
|
+
["items" /* Items */]: isList ? rows : [],
|
|
1001
|
+
["prices" /* Prices */]: prices,
|
|
1002
|
+
["includes" /* Includes */]: includes,
|
|
1003
|
+
["footer" /* Footer */]: footer
|
|
1004
|
+
};
|
|
1005
|
+
return joined(sectionOrderOf(doc), parts);
|
|
968
1006
|
}
|
|
969
1007
|
|
|
970
1008
|
// src/layout/lineRuns.ts
|
|
@@ -1017,16 +1055,19 @@ function groupBox(group, k, colW) {
|
|
|
1017
1055
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1018
1056
|
}
|
|
1019
1057
|
function lineSize(line, width, k, avail) {
|
|
1058
|
+
if (line.fixedSize === true) {
|
|
1059
|
+
return line.size;
|
|
1060
|
+
}
|
|
1020
1061
|
const indent = bulletIndent(line, k);
|
|
1021
1062
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1022
1063
|
}
|
|
1023
|
-
function groupSizes(m, k, avail
|
|
1024
|
-
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k,
|
|
1064
|
+
function groupSizes(m, k, avail) {
|
|
1065
|
+
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k, avail * (line.widthScale ?? 1)));
|
|
1025
1066
|
if (!m.group.uniform) {
|
|
1026
1067
|
return own;
|
|
1027
1068
|
}
|
|
1028
1069
|
const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
|
|
1029
|
-
return m.group.lines.map((line) => line.size * ratio);
|
|
1070
|
+
return m.group.lines.map((line) => line.fixedSize === true ? line.size : line.size * ratio);
|
|
1030
1071
|
}
|
|
1031
1072
|
function tieMembers(all, k, colW, table, pick) {
|
|
1032
1073
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1035,7 +1076,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1035
1076
|
const sizes = table.get(m) ?? [];
|
|
1036
1077
|
m.group.lines.forEach((line, i) => {
|
|
1037
1078
|
const id = pick(line);
|
|
1038
|
-
if (id !== void 0) {
|
|
1079
|
+
if (id !== void 0 && line.fixedSize !== true) {
|
|
1039
1080
|
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 };
|
|
1040
1081
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1041
1082
|
}
|
|
@@ -1056,8 +1097,8 @@ function sameWidths(list) {
|
|
|
1056
1097
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1057
1098
|
});
|
|
1058
1099
|
}
|
|
1059
|
-
function sizeTable(all, k, colW
|
|
1060
|
-
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail
|
|
1100
|
+
function sizeTable(all, k, colW) {
|
|
1101
|
+
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1061
1102
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1062
1103
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1063
1104
|
return table;
|
|
@@ -1123,7 +1164,7 @@ function placeGroup(m, at, out) {
|
|
|
1123
1164
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1124
1165
|
const x = lineX(line, { col, pad, indent, w });
|
|
1125
1166
|
const box = { x, y, w, h: size * LINE_HEIGHT };
|
|
1126
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
|
|
1167
|
+
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) });
|
|
1127
1168
|
if (line.bullet && out) {
|
|
1128
1169
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1129
1170
|
}
|
|
@@ -1189,11 +1230,11 @@ function splitColumns(groups, zone) {
|
|
|
1189
1230
|
}
|
|
1190
1231
|
cut = keepTogether(groups, heights, cut);
|
|
1191
1232
|
return [
|
|
1192
|
-
{ col: { ...zone, w
|
|
1193
|
-
{ col: { ...zone, x: zone.x + w + gap, w
|
|
1233
|
+
{ col: { ...zone, w }, groups: groups.slice(0, cut) },
|
|
1234
|
+
{ col: { ...zone, x: zone.x + w + gap, w }, groups: groups.slice(cut) }
|
|
1194
1235
|
];
|
|
1195
1236
|
}
|
|
1196
|
-
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0
|
|
1237
|
+
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0);
|
|
1197
1238
|
function largestK(columns, zoneH) {
|
|
1198
1239
|
const fits = (k) => {
|
|
1199
1240
|
const table = tableFor(columns, k);
|
|
@@ -1343,11 +1384,11 @@ function flowAll(ctx, input, base2, reflow) {
|
|
|
1343
1384
|
const head = flow(ctx, headerGroups(doc, palette, u), zones.text, fonts);
|
|
1344
1385
|
const flanks = geo.flanks ?? [];
|
|
1345
1386
|
const tight = closeHeaderGap(geo, head, doc.tuning?.headerGap, u);
|
|
1346
|
-
const body = flow(ctx, bodyGroups(doc, palette, u, { withPrices: flanks.length === 0, compact: reflow.compact, wrap: reflow.wrap, dateScale: doc.tuning?.itemDateScale }),
|
|
1387
|
+
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);
|
|
1347
1388
|
const sides = flanks.length > 0 ? equalFlanks(ctx, flankPriceGroups(doc, palette, u), flanks, fonts) : [emptyFlow()];
|
|
1348
1389
|
return { geo: tight, zones, head, body, sides };
|
|
1349
1390
|
}
|
|
1350
|
-
var smallest = (t) => Math.min(Infinity, ...[t.head, t.body, ...t.sides].flatMap((f) => f.texts.map((x) => x.box.h / LINE_HEIGHT3)));
|
|
1391
|
+
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)));
|
|
1351
1392
|
function shiftHeader(geo, shift) {
|
|
1352
1393
|
const { header, body } = geo;
|
|
1353
1394
|
const stacked = header.y + header.h <= body.y && header.x < body.x + body.w && body.x < header.x + header.w;
|
|
@@ -1432,6 +1473,21 @@ function lineBoxesOf(texts) {
|
|
|
1432
1473
|
return boxes;
|
|
1433
1474
|
}
|
|
1434
1475
|
|
|
1476
|
+
// src/render/roleOrder.ts
|
|
1477
|
+
var INDEX = /^\d+$/;
|
|
1478
|
+
var roleOf = (key) => key.split(".").filter((part) => !INDEX.test(part)).join(".");
|
|
1479
|
+
function roleOrder(boxes) {
|
|
1480
|
+
const first = /* @__PURE__ */ new Map();
|
|
1481
|
+
Object.entries(boxes).forEach(([key, box]) => {
|
|
1482
|
+
const role = roleOf(key);
|
|
1483
|
+
const seen = first.get(role);
|
|
1484
|
+
if (box !== void 0 && (seen === void 0 || box.y < seen.y || box.y === seen.y && box.x < seen.x)) {
|
|
1485
|
+
first.set(role, box);
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
return [...first.entries()].sort(([, a], [, b]) => a.y - b.y || a.x - b.x).map(([role]) => role);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1435
1491
|
// src/render/overlap.ts
|
|
1436
1492
|
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
1437
1493
|
function placePicture(image, region, slot, fit) {
|
|
@@ -1683,18 +1739,21 @@ function render(input, assets, canvas) {
|
|
|
1683
1739
|
if (layered) {
|
|
1684
1740
|
flows.forEach((f) => drawMarks(ctx, f, radius));
|
|
1685
1741
|
}
|
|
1742
|
+
const lineBoxes = lineBoxesOf(flows.flatMap((f) => f.texts));
|
|
1686
1743
|
return {
|
|
1687
1744
|
width,
|
|
1688
1745
|
height,
|
|
1689
1746
|
picture,
|
|
1690
1747
|
pictureRegion: region,
|
|
1691
1748
|
textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
|
|
1692
|
-
lineBoxes
|
|
1749
|
+
lineBoxes,
|
|
1693
1750
|
cardBoxes: body.cards.map((c) => c.rect),
|
|
1694
1751
|
iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
|
|
1695
1752
|
ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
|
|
1696
1753
|
logo,
|
|
1697
|
-
backdrop
|
|
1754
|
+
backdrop,
|
|
1755
|
+
sectionOrder: sectionOrderOf(doc),
|
|
1756
|
+
roleOrder: roleOrder(lineBoxes)
|
|
1698
1757
|
};
|
|
1699
1758
|
}
|
|
1700
1759
|
|
|
@@ -1789,6 +1848,7 @@ var kizombaWorkshop = {
|
|
|
1789
1848
|
var kizombaWorkshopDocs = [...WORKSHOPS.map(workshopDoc), kizombaWorkshop];
|
|
1790
1849
|
|
|
1791
1850
|
exports.BackgroundStyle = BackgroundStyle;
|
|
1851
|
+
exports.BodySection = BodySection;
|
|
1792
1852
|
exports.FONT_SETS = FONT_SETS;
|
|
1793
1853
|
exports.FORMAT_SIZES = FORMAT_SIZES;
|
|
1794
1854
|
exports.FlierDocError = FlierDocError;
|
|
@@ -1804,13 +1864,17 @@ exports.PaletteId = PaletteId;
|
|
|
1804
1864
|
exports.PictureAnchor = PictureAnchor;
|
|
1805
1865
|
exports.RowIcon = RowIcon;
|
|
1806
1866
|
exports.defaultLayoutFor = defaultLayoutFor;
|
|
1867
|
+
exports.defaultSectionOrder = defaultSectionOrder;
|
|
1807
1868
|
exports.exportPng = exportPng;
|
|
1808
1869
|
exports.flierDocSchema = flierDocSchema;
|
|
1809
1870
|
exports.kizombaWorkshop = kizombaWorkshop;
|
|
1810
1871
|
exports.kizombaWorkshopDocs = kizombaWorkshopDocs;
|
|
1811
1872
|
exports.render = render;
|
|
1873
|
+
exports.roleOf = roleOf;
|
|
1874
|
+
exports.roleOrder = roleOrder;
|
|
1812
1875
|
exports.sameSize = sameSize;
|
|
1813
1876
|
exports.sameWidth = sameWidth;
|
|
1877
|
+
exports.sectionOrderOf = sectionOrderOf;
|
|
1814
1878
|
exports.validateFlierDoc = validateFlierDoc;
|
|
1815
1879
|
//# sourceMappingURL=index.js.map
|
|
1816
1880
|
//# sourceMappingURL=index.js.map
|