@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
- FLIER-2 "Bullets on/off and line spacing": `FlierDoc.bullets` (default true; false drops the includes bullet dot and its indent), `LineStyle.spaceAbove` / `spaceBelow` (em of the line size, 0-2) added above / below a line, and a footer holding line breaks sets one footer line per text line. Docs without the new fields render pixel-identical (45 snapshots unchanged).
|
|
6
|
+
|
|
3
7
|
## 0.6.0
|
|
4
8
|
|
|
5
9
|
- FLIER-2 "Flier Studio follow-ups" D30 (sample parity, gap table `apps/flier-studio/docs/design/FLIER-2-sample-parity/gap.md`), all optional:
|
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,10 +187,12 @@ interface FlierDoc {
|
|
|
178
187
|
lineStyles?: Record<LineKey, LineStyle | undefined>;
|
|
179
188
|
lineTies?: LineTie[];
|
|
180
189
|
rows?: RowTheme;
|
|
190
|
+
sectionOrder?: BodySection[];
|
|
191
|
+
bullets?: boolean;
|
|
181
192
|
}
|
|
182
193
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
183
194
|
type LineKey = string;
|
|
184
|
-
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing
|
|
195
|
+
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing, spaceAbove and spaceBelow are in em; widthScale widens or narrows the room the line may fill. */
|
|
185
196
|
interface LineStyle {
|
|
186
197
|
font?: string;
|
|
187
198
|
sizeScale?: number;
|
|
@@ -191,6 +202,8 @@ interface LineStyle {
|
|
|
191
202
|
italic?: boolean;
|
|
192
203
|
letterSpacing?: number;
|
|
193
204
|
align?: LineAlign;
|
|
205
|
+
spaceAbove?: number;
|
|
206
|
+
spaceBelow?: number;
|
|
194
207
|
}
|
|
195
208
|
/** Two lines drawn at one width (width) or one font size (size). */
|
|
196
209
|
interface LineTie {
|
|
@@ -267,6 +280,8 @@ interface RenderReport {
|
|
|
267
280
|
ruleBoxes: Rect[];
|
|
268
281
|
logo: Rect | null;
|
|
269
282
|
backdrop: Rect | null;
|
|
283
|
+
sectionOrder: BodySection[];
|
|
284
|
+
roleOrder: string[];
|
|
270
285
|
}
|
|
271
286
|
interface Palette {
|
|
272
287
|
background: string;
|
|
@@ -325,6 +340,16 @@ declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
|
325
340
|
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
326
341
|
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
327
342
|
|
|
343
|
+
/** The body sections of a layout in the order it draws them; the title block always sits above. */
|
|
344
|
+
declare function defaultSectionOrder(layout: LayoutId): BodySection[];
|
|
345
|
+
/** The doc's own section order (unknown and repeated entries dropped), then the layout's remaining sections. */
|
|
346
|
+
declare function sectionOrderOf(doc: Pick<FlierDoc, 'layout' | 'sectionOrder'>): BodySection[];
|
|
347
|
+
|
|
348
|
+
/** The role of a line key: the key without its list indices, so "schedule.0.label" is "schedule.label". */
|
|
349
|
+
declare const roleOf: (key: LineKey) => string;
|
|
350
|
+
/** Every drawn role once, ordered by the top of its first line, then left to right. */
|
|
351
|
+
declare function roleOrder(boxes: Record<LineKey, Rect | undefined>): string[];
|
|
352
|
+
|
|
328
353
|
interface DataUrlCanvas {
|
|
329
354
|
toDataURL(type: string): string;
|
|
330
355
|
}
|
|
@@ -345,4 +370,4 @@ declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
|
345
370
|
declare const kizombaWorkshop: FlierDoc;
|
|
346
371
|
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
347
372
|
|
|
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 };
|
|
373
|
+
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,10 +187,12 @@ interface FlierDoc {
|
|
|
178
187
|
lineStyles?: Record<LineKey, LineStyle | undefined>;
|
|
179
188
|
lineTies?: LineTie[];
|
|
180
189
|
rows?: RowTheme;
|
|
190
|
+
sectionOrder?: BodySection[];
|
|
191
|
+
bullets?: boolean;
|
|
181
192
|
}
|
|
182
193
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
183
194
|
type LineKey = string;
|
|
184
|
-
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing
|
|
195
|
+
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing, spaceAbove and spaceBelow are in em; widthScale widens or narrows the room the line may fill. */
|
|
185
196
|
interface LineStyle {
|
|
186
197
|
font?: string;
|
|
187
198
|
sizeScale?: number;
|
|
@@ -191,6 +202,8 @@ interface LineStyle {
|
|
|
191
202
|
italic?: boolean;
|
|
192
203
|
letterSpacing?: number;
|
|
193
204
|
align?: LineAlign;
|
|
205
|
+
spaceAbove?: number;
|
|
206
|
+
spaceBelow?: number;
|
|
194
207
|
}
|
|
195
208
|
/** Two lines drawn at one width (width) or one font size (size). */
|
|
196
209
|
interface LineTie {
|
|
@@ -267,6 +280,8 @@ interface RenderReport {
|
|
|
267
280
|
ruleBoxes: Rect[];
|
|
268
281
|
logo: Rect | null;
|
|
269
282
|
backdrop: Rect | null;
|
|
283
|
+
sectionOrder: BodySection[];
|
|
284
|
+
roleOrder: string[];
|
|
270
285
|
}
|
|
271
286
|
interface Palette {
|
|
272
287
|
background: string;
|
|
@@ -325,6 +340,16 @@ declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
|
325
340
|
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
326
341
|
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
327
342
|
|
|
343
|
+
/** The body sections of a layout in the order it draws them; the title block always sits above. */
|
|
344
|
+
declare function defaultSectionOrder(layout: LayoutId): BodySection[];
|
|
345
|
+
/** The doc's own section order (unknown and repeated entries dropped), then the layout's remaining sections. */
|
|
346
|
+
declare function sectionOrderOf(doc: Pick<FlierDoc, 'layout' | 'sectionOrder'>): BodySection[];
|
|
347
|
+
|
|
348
|
+
/** The role of a line key: the key without its list indices, so "schedule.0.label" is "schedule.label". */
|
|
349
|
+
declare const roleOf: (key: LineKey) => string;
|
|
350
|
+
/** Every drawn role once, ordered by the top of its first line, then left to right. */
|
|
351
|
+
declare function roleOrder(boxes: Record<LineKey, Rect | undefined>): string[];
|
|
352
|
+
|
|
328
353
|
interface DataUrlCanvas {
|
|
329
354
|
toDataURL(type: string): string;
|
|
330
355
|
}
|
|
@@ -345,4 +370,4 @@ declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
|
345
370
|
declare const kizombaWorkshop: FlierDoc;
|
|
346
371
|
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
347
372
|
|
|
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 };
|
|
373
|
+
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,13 +99,10 @@ 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;
|
|
105
|
+
var MAX_SPACE = 2;
|
|
98
106
|
var WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
99
107
|
var lineKey = { type: "string", pattern: LINE_KEY_PATTERN };
|
|
100
108
|
var lineStyle = {
|
|
@@ -102,13 +110,15 @@ var lineStyle = {
|
|
|
102
110
|
additionalProperties: false,
|
|
103
111
|
properties: {
|
|
104
112
|
font: { type: "string", minLength: 1, maxLength: MAX_FONT, pattern: "^[A-Za-z0-9 ]+$" },
|
|
105
|
-
sizeScale: { type: "number", minimum:
|
|
106
|
-
widthScale: { type: "number", minimum:
|
|
113
|
+
sizeScale: { type: "number", minimum: 0 },
|
|
114
|
+
widthScale: { type: "number", minimum: 0 },
|
|
107
115
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
108
116
|
weight: { type: "integer", enum: WEIGHTS },
|
|
109
117
|
italic: { type: "boolean" },
|
|
110
118
|
letterSpacing: { type: "number", minimum: MIN_SPACING, maximum: MAX_SPACING },
|
|
111
|
-
align: { type: "string", enum: Object.values(LineAlign) }
|
|
119
|
+
align: { type: "string", enum: Object.values(LineAlign) },
|
|
120
|
+
spaceAbove: { type: "number", minimum: 0, maximum: MAX_SPACE },
|
|
121
|
+
spaceBelow: { type: "number", minimum: 0, maximum: MAX_SPACE }
|
|
112
122
|
}
|
|
113
123
|
};
|
|
114
124
|
var lineStylesSchema = { type: "object", propertyNames: lineKey, additionalProperties: lineStyle };
|
|
@@ -272,6 +282,7 @@ var MIN_SCALE = 0.3;
|
|
|
272
282
|
var MAX_HEADER_GAP = 200;
|
|
273
283
|
var MIN_DATE_SCALE = 0.5;
|
|
274
284
|
var MAX_DATE_SCALE = 2;
|
|
285
|
+
var MAX_SECTIONS = 6;
|
|
275
286
|
var text = (maxLength) => ({ type: "string", minLength: 1, maxLength });
|
|
276
287
|
var scheduleRow = {
|
|
277
288
|
type: "object",
|
|
@@ -350,6 +361,8 @@ var flierDocSchema = {
|
|
|
350
361
|
lineStyles: lineStylesSchema,
|
|
351
362
|
lineTies: lineTiesSchema,
|
|
352
363
|
rows: rowsSchema,
|
|
364
|
+
bullets: { type: "boolean" },
|
|
365
|
+
sectionOrder: { type: "array", maxItems: MAX_SECTIONS, items: { type: "string", enum: Object.values(BodySection) } },
|
|
353
366
|
items: {
|
|
354
367
|
type: "array",
|
|
355
368
|
minItems: 1,
|
|
@@ -799,22 +812,38 @@ function styled(line, key, sc) {
|
|
|
799
812
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
800
813
|
return { ...line, key };
|
|
801
814
|
}
|
|
815
|
+
const size = line.size * (style?.sizeScale ?? 1);
|
|
802
816
|
return {
|
|
803
817
|
...line,
|
|
804
818
|
key,
|
|
805
|
-
size
|
|
819
|
+
size,
|
|
806
820
|
color: style?.color ?? line.color,
|
|
807
821
|
weight: style?.weight ?? line.weight,
|
|
808
822
|
family: style?.font,
|
|
809
823
|
italic: style?.italic,
|
|
810
824
|
spacing: style?.letterSpacing,
|
|
811
825
|
widthScale: style?.widthScale,
|
|
826
|
+
fixedSize: style?.sizeScale === void 0 ? void 0 : true,
|
|
812
827
|
align: style?.align,
|
|
828
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * size,
|
|
829
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * size,
|
|
813
830
|
widthTie,
|
|
814
831
|
sizeTie
|
|
815
832
|
};
|
|
816
833
|
}
|
|
817
834
|
|
|
835
|
+
// src/layout/sectionOrder.ts
|
|
836
|
+
var EVENT_ORDER = ["venue" /* Venue */, "schedule" /* Schedule */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
837
|
+
var LIST_ORDER = ["venue" /* Venue */, "items" /* Items */, "prices" /* Prices */, "includes" /* Includes */, "footer" /* Footer */];
|
|
838
|
+
function defaultSectionOrder(layout) {
|
|
839
|
+
return [...layout === "list" /* List */ ? LIST_ORDER : EVENT_ORDER];
|
|
840
|
+
}
|
|
841
|
+
function sectionOrderOf(doc) {
|
|
842
|
+
const base2 = defaultSectionOrder(doc.layout);
|
|
843
|
+
const own = (doc.sectionOrder ?? []).filter((s, i, all) => base2.includes(s) && all.indexOf(s) === i);
|
|
844
|
+
return [...own, ...base2.filter((s) => !own.includes(s))];
|
|
845
|
+
}
|
|
846
|
+
|
|
818
847
|
// src/layout/blockGroups.ts
|
|
819
848
|
var BOLD = 700;
|
|
820
849
|
var SEMI = 600;
|
|
@@ -845,14 +874,14 @@ var GAP = {
|
|
|
845
874
|
rule: 8,
|
|
846
875
|
divider: 24
|
|
847
876
|
};
|
|
848
|
-
var makers = (p, u, sc, timeWeight = SEMI) => ({
|
|
877
|
+
var makers = (p, u, sc, timeWeight = SEMI, bullets = true) => ({
|
|
849
878
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
850
879
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
851
880
|
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
852
881
|
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
853
882
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
854
883
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
855
|
-
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: p.accent }, key, sc),
|
|
884
|
+
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),
|
|
856
885
|
soft: (text2, size, key) => styled({ text: text2, role: "body", weight: MEDIUM, size: size * u, color: p.soft }, key, sc),
|
|
857
886
|
time: (text2, size, key) => styled({ text: text2, role: "body", weight: timeWeight, size: size * u, color: p.accent }, key, sc)
|
|
858
887
|
});
|
|
@@ -913,28 +942,26 @@ var tailed = (line, key, headLength) => ({ ...line, tail: { key, at: line.text.l
|
|
|
913
942
|
var priceAmount = (doc, line) => doc.rows?.priceGap === void 0 ? line : { ...line, gapAfter: doc.rows.priceGap };
|
|
914
943
|
function eventGroups(doc, l, u, options) {
|
|
915
944
|
const b = doc.blocks;
|
|
916
|
-
const
|
|
945
|
+
const rows = [];
|
|
946
|
+
const priced = [];
|
|
917
947
|
const schedule2 = b.schedule ?? [];
|
|
918
948
|
const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
|
|
919
949
|
const lastRow = schedule2.length + prices.length - 1;
|
|
920
950
|
const icons2 = doc.rows?.icons;
|
|
921
951
|
schedule2.forEach((row, i) => {
|
|
922
952
|
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
|
-
|
|
953
|
+
rows.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
|
|
924
954
|
});
|
|
925
955
|
prices.forEach((row, i) => {
|
|
926
956
|
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
|
-
|
|
957
|
+
priced.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
|
|
928
958
|
});
|
|
929
|
-
return
|
|
959
|
+
return [rows, priced];
|
|
930
960
|
}
|
|
931
961
|
function listGroups(doc, l, u, dateScale) {
|
|
932
962
|
const groups = (doc.items ?? []).map((item, n) => itemGroup(item, n, l, { u, dateScale }));
|
|
933
963
|
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;
|
|
964
|
+
return [groups, prices.length > 0 ? [{ lines: prices, gapAfter: GAP.row * u }] : []];
|
|
938
965
|
}
|
|
939
966
|
function flankPriceGroups(doc, p, u) {
|
|
940
967
|
const l = makers(p, u, styleContext(doc));
|
|
@@ -943,28 +970,47 @@ function flankPriceGroups(doc, p, u) {
|
|
|
943
970
|
function pinOf(look, u) {
|
|
944
971
|
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
972
|
}
|
|
973
|
+
function venueGroups(doc, p, u, l) {
|
|
974
|
+
const b = doc.blocks;
|
|
975
|
+
if (!b.venue) {
|
|
976
|
+
return [];
|
|
977
|
+
}
|
|
978
|
+
const size = doc.layout === "list" /* List */ ? SIZE.listVenue : SIZE.venue;
|
|
979
|
+
const look = doc.rows?.venue;
|
|
980
|
+
const line = look?.body === true ? l.bodyVenue : l.venue;
|
|
981
|
+
const venue = look?.oneLine === true ? [b.venue.join(" ")] : b.venue;
|
|
982
|
+
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) } }];
|
|
983
|
+
}
|
|
984
|
+
var bound = (s, next) => s === "venue" /* Venue */ && next === "schedule" /* Schedule */ || s === "includes" /* Includes */ && next === "footer" /* Footer */;
|
|
985
|
+
function joined(order, parts) {
|
|
986
|
+
const filled = order.filter((s) => parts[s].length > 0);
|
|
987
|
+
return filled.flatMap((s, n) => {
|
|
988
|
+
const groups = parts[s];
|
|
989
|
+
if (!bound(s, filled[n + 1])) {
|
|
990
|
+
return groups;
|
|
991
|
+
}
|
|
992
|
+
const attach = s === "includes" /* Includes */ ? { attachNext: true } : {};
|
|
993
|
+
return groups.map((g, i) => i === groups.length - 1 ? { ...g, keepWithNext: true, ...attach } : g);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
946
996
|
function bodyGroups(doc, p, u, options = {}) {
|
|
947
|
-
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
997
|
+
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight, doc.bullets !== false);
|
|
948
998
|
const b = doc.blocks;
|
|
949
|
-
const groups = [];
|
|
950
999
|
const isList = doc.layout === "list" /* List */;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small, "footer"), options.wrap), gapAfter: 0 });
|
|
966
|
-
}
|
|
967
|
-
return groups;
|
|
1000
|
+
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
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}`))] : [];
|
|
1002
|
+
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
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 }] : [];
|
|
1005
|
+
const parts = {
|
|
1006
|
+
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
1007
|
+
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
1008
|
+
["items" /* Items */]: isList ? rows : [],
|
|
1009
|
+
["prices" /* Prices */]: prices,
|
|
1010
|
+
["includes" /* Includes */]: includes,
|
|
1011
|
+
["footer" /* Footer */]: footer
|
|
1012
|
+
};
|
|
1013
|
+
return joined(sectionOrderOf(doc), parts);
|
|
968
1014
|
}
|
|
969
1015
|
|
|
970
1016
|
// src/layout/lineRuns.ts
|
|
@@ -1017,16 +1063,19 @@ function groupBox(group, k, colW) {
|
|
|
1017
1063
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1018
1064
|
}
|
|
1019
1065
|
function lineSize(line, width, k, avail) {
|
|
1066
|
+
if (line.fixedSize === true) {
|
|
1067
|
+
return line.size;
|
|
1068
|
+
}
|
|
1020
1069
|
const indent = bulletIndent(line, k);
|
|
1021
1070
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1022
1071
|
}
|
|
1023
|
-
function groupSizes(m, k, avail
|
|
1024
|
-
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k,
|
|
1072
|
+
function groupSizes(m, k, avail) {
|
|
1073
|
+
const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k, avail * (line.widthScale ?? 1)));
|
|
1025
1074
|
if (!m.group.uniform) {
|
|
1026
1075
|
return own;
|
|
1027
1076
|
}
|
|
1028
1077
|
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);
|
|
1078
|
+
return m.group.lines.map((line) => line.fixedSize === true ? line.size : line.size * ratio);
|
|
1030
1079
|
}
|
|
1031
1080
|
function tieMembers(all, k, colW, table, pick) {
|
|
1032
1081
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1035,7 +1084,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1035
1084
|
const sizes = table.get(m) ?? [];
|
|
1036
1085
|
m.group.lines.forEach((line, i) => {
|
|
1037
1086
|
const id = pick(line);
|
|
1038
|
-
if (id !== void 0) {
|
|
1087
|
+
if (id !== void 0 && line.fixedSize !== true) {
|
|
1039
1088
|
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
1089
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1041
1090
|
}
|
|
@@ -1056,8 +1105,8 @@ function sameWidths(list) {
|
|
|
1056
1105
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1057
1106
|
});
|
|
1058
1107
|
}
|
|
1059
|
-
function sizeTable(all, k, colW
|
|
1060
|
-
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail
|
|
1108
|
+
function sizeTable(all, k, colW) {
|
|
1109
|
+
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1061
1110
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1062
1111
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1063
1112
|
return table;
|
|
@@ -1114,20 +1163,21 @@ function placeGroup(m, at, out) {
|
|
|
1114
1163
|
const top = y;
|
|
1115
1164
|
y += pad;
|
|
1116
1165
|
if (group.icon?.centre === true) {
|
|
1117
|
-
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);
|
|
1118
1167
|
y += Math.max(0, (d - textH) / 2);
|
|
1119
1168
|
}
|
|
1120
1169
|
group.lines.forEach((line, i) => {
|
|
1121
1170
|
const size = sizes[i] ?? 0;
|
|
1171
|
+
y += (line.spaceAbove ?? 0) * k;
|
|
1122
1172
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1123
1173
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1124
1174
|
const x = lineX(line, { col, pad, indent, w });
|
|
1125
1175
|
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) });
|
|
1176
|
+
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
1177
|
if (line.bullet && out) {
|
|
1128
1178
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1129
1179
|
}
|
|
1130
|
-
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
1180
|
+
y += size * LINE_HEIGHT + ((line.gapAfter ?? 0) + (line.spaceBelow ?? 0)) * k;
|
|
1131
1181
|
});
|
|
1132
1182
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
1133
1183
|
y += pad;
|
|
@@ -1189,11 +1239,11 @@ function splitColumns(groups, zone) {
|
|
|
1189
1239
|
}
|
|
1190
1240
|
cut = keepTogether(groups, heights, cut);
|
|
1191
1241
|
return [
|
|
1192
|
-
{ col: { ...zone, w
|
|
1193
|
-
{ col: { ...zone, x: zone.x + w + gap, w
|
|
1242
|
+
{ col: { ...zone, w }, groups: groups.slice(0, cut) },
|
|
1243
|
+
{ col: { ...zone, x: zone.x + w + gap, w }, groups: groups.slice(cut) }
|
|
1194
1244
|
];
|
|
1195
1245
|
}
|
|
1196
|
-
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0
|
|
1246
|
+
var tableFor = (columns, k) => sizeTable(columns.flatMap((c) => c.groups), k, columns[0]?.col.w ?? 0);
|
|
1197
1247
|
function largestK(columns, zoneH) {
|
|
1198
1248
|
const fits = (k) => {
|
|
1199
1249
|
const table = tableFor(columns, k);
|
|
@@ -1343,11 +1393,11 @@ function flowAll(ctx, input, base2, reflow) {
|
|
|
1343
1393
|
const head = flow(ctx, headerGroups(doc, palette, u), zones.text, fonts);
|
|
1344
1394
|
const flanks = geo.flanks ?? [];
|
|
1345
1395
|
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 }),
|
|
1396
|
+
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
1397
|
const sides = flanks.length > 0 ? equalFlanks(ctx, flankPriceGroups(doc, palette, u), flanks, fonts) : [emptyFlow()];
|
|
1348
1398
|
return { geo: tight, zones, head, body, sides };
|
|
1349
1399
|
}
|
|
1350
|
-
var smallest = (t) => Math.min(Infinity, ...[t.head, t.body, ...t.sides].flatMap((f) => f.texts.map((x) => x.box.h / LINE_HEIGHT3)));
|
|
1400
|
+
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
1401
|
function shiftHeader(geo, shift) {
|
|
1352
1402
|
const { header, body } = geo;
|
|
1353
1403
|
const stacked = header.y + header.h <= body.y && header.x < body.x + body.w && body.x < header.x + header.w;
|
|
@@ -1432,6 +1482,21 @@ function lineBoxesOf(texts) {
|
|
|
1432
1482
|
return boxes;
|
|
1433
1483
|
}
|
|
1434
1484
|
|
|
1485
|
+
// src/render/roleOrder.ts
|
|
1486
|
+
var INDEX = /^\d+$/;
|
|
1487
|
+
var roleOf = (key) => key.split(".").filter((part) => !INDEX.test(part)).join(".");
|
|
1488
|
+
function roleOrder(boxes) {
|
|
1489
|
+
const first = /* @__PURE__ */ new Map();
|
|
1490
|
+
Object.entries(boxes).forEach(([key, box]) => {
|
|
1491
|
+
const role = roleOf(key);
|
|
1492
|
+
const seen = first.get(role);
|
|
1493
|
+
if (box !== void 0 && (seen === void 0 || box.y < seen.y || box.y === seen.y && box.x < seen.x)) {
|
|
1494
|
+
first.set(role, box);
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
return [...first.entries()].sort(([, a], [, b]) => a.y - b.y || a.x - b.x).map(([role]) => role);
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1435
1500
|
// src/render/overlap.ts
|
|
1436
1501
|
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
1437
1502
|
function placePicture(image, region, slot, fit) {
|
|
@@ -1683,18 +1748,21 @@ function render(input, assets, canvas) {
|
|
|
1683
1748
|
if (layered) {
|
|
1684
1749
|
flows.forEach((f) => drawMarks(ctx, f, radius));
|
|
1685
1750
|
}
|
|
1751
|
+
const lineBoxes = lineBoxesOf(flows.flatMap((f) => f.texts));
|
|
1686
1752
|
return {
|
|
1687
1753
|
width,
|
|
1688
1754
|
height,
|
|
1689
1755
|
picture,
|
|
1690
1756
|
pictureRegion: region,
|
|
1691
1757
|
textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
|
|
1692
|
-
lineBoxes
|
|
1758
|
+
lineBoxes,
|
|
1693
1759
|
cardBoxes: body.cards.map((c) => c.rect),
|
|
1694
1760
|
iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
|
|
1695
1761
|
ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
|
|
1696
1762
|
logo,
|
|
1697
|
-
backdrop
|
|
1763
|
+
backdrop,
|
|
1764
|
+
sectionOrder: sectionOrderOf(doc),
|
|
1765
|
+
roleOrder: roleOrder(lineBoxes)
|
|
1698
1766
|
};
|
|
1699
1767
|
}
|
|
1700
1768
|
|
|
@@ -1789,6 +1857,7 @@ var kizombaWorkshop = {
|
|
|
1789
1857
|
var kizombaWorkshopDocs = [...WORKSHOPS.map(workshopDoc), kizombaWorkshop];
|
|
1790
1858
|
|
|
1791
1859
|
exports.BackgroundStyle = BackgroundStyle;
|
|
1860
|
+
exports.BodySection = BodySection;
|
|
1792
1861
|
exports.FONT_SETS = FONT_SETS;
|
|
1793
1862
|
exports.FORMAT_SIZES = FORMAT_SIZES;
|
|
1794
1863
|
exports.FlierDocError = FlierDocError;
|
|
@@ -1804,13 +1873,17 @@ exports.PaletteId = PaletteId;
|
|
|
1804
1873
|
exports.PictureAnchor = PictureAnchor;
|
|
1805
1874
|
exports.RowIcon = RowIcon;
|
|
1806
1875
|
exports.defaultLayoutFor = defaultLayoutFor;
|
|
1876
|
+
exports.defaultSectionOrder = defaultSectionOrder;
|
|
1807
1877
|
exports.exportPng = exportPng;
|
|
1808
1878
|
exports.flierDocSchema = flierDocSchema;
|
|
1809
1879
|
exports.kizombaWorkshop = kizombaWorkshop;
|
|
1810
1880
|
exports.kizombaWorkshopDocs = kizombaWorkshopDocs;
|
|
1811
1881
|
exports.render = render;
|
|
1882
|
+
exports.roleOf = roleOf;
|
|
1883
|
+
exports.roleOrder = roleOrder;
|
|
1812
1884
|
exports.sameSize = sameSize;
|
|
1813
1885
|
exports.sameWidth = sameWidth;
|
|
1886
|
+
exports.sectionOrderOf = sectionOrderOf;
|
|
1814
1887
|
exports.validateFlierDoc = validateFlierDoc;
|
|
1815
1888
|
//# sourceMappingURL=index.js.map
|
|
1816
1889
|
//# sourceMappingURL=index.js.map
|