@dloizides/poster-render 0.0.0-stage → 0.2.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 +11 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/index.d.mts +224 -0
- package/dist/index.d.ts +224 -0
- package/dist/index.js +840 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +821 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +74 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Layouts `arch`, `phone-clock-safe`, `phone-arch`, `desktop-safe`, `desktop-arch` (FLIER-1 D4 "Keep all layouts"); `LAYOUT_CATALOGUE` + `defaultLayoutFor`.
|
|
6
|
+
- Critic r2 nits: arch prices moved up beside the arch top, lighter arch fill, phone arch top at 63% height, desktop arch 40 px right, logo top on the title cap top.
|
|
7
|
+
- Includes block uses one size for every line; `RenderReport.backdrop`; `Palette.arch`.
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
- FlierDoc schema + validator, render, exportPng, 4 layouts, 5 formats, palettes, font sets, Kizomba example.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 dloizides
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dloizides/poster-render
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One JSON document (`FlierDoc`) in, one poster out. Used by Flier Studio (FLIER-1 "Flier Studio").
|
|
4
|
+
|
|
5
|
+
- `flierDocSchema`: JSON Schema of `FlierDoc` (give it to an LLM as `response_format`).
|
|
6
|
+
- `validateFlierDoc(input)`: `{ ok, doc }` or `{ ok: false, errors }`; errors read `blocks.title: is required`.
|
|
7
|
+
- `render(doc, assets, canvas)`: validates first (throws `FlierDocError` before touching the canvas), resizes the canvas to the format, draws, returns a `RenderReport` (picture rect, text and card boxes).
|
|
8
|
+
- `exportPng(canvas)`: PNG `Blob` of the canvas size.
|
|
9
|
+
- Formats: story 1080x1920, post 1080x1350, square 1080x1080, phone 1170x2532, desktop 2560x1440.
|
|
10
|
+
- Layouts: `picture-right` (E-A), `picture-left` (E-B), `arch` (E-C), `picture-bottom`, `list`, `phone-clock-safe` (P-A, top kept clear for the lock-screen clock), `phone-arch` (P-B), `desktop-safe` (D-A, text clear of desktop icons and the taskbar), `desktop-arch` (D-B). `LAYOUT_CATALOGUE` lists id, design id, label, description and designed formats (for the app picker and the LLM prompt); `defaultLayoutFor(format)` gives E-A / P-A / D-A.
|
|
11
|
+
- Arch layouts paint a soft arch (palette `arch`, about 4% off the ground) behind the picture only, inside the picture region; prices sit large on either side. The includes block is set at one size for every line. Palettes: `sand`, `night`, `sea`, `rose`. Font sets: `classic`, `modern`, `elegant` (the app loads the web fonts).
|
|
12
|
+
- The picture is placed contain + anchor in its own region: never cropped, never faded, drawn last, and no text or card is laid out in its region. Text shrinks to fit, never overflows.
|
|
13
|
+
- Example: `kizombaWorkshopDocs` (3 workshops + list flier), `kizombaWorkshop` (the list flier).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
declare enum BackgroundStyle {
|
|
2
|
+
Solid = "solid",
|
|
3
|
+
Tint = "tint"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare enum FontSetId {
|
|
7
|
+
Classic = "classic",
|
|
8
|
+
Modern = "modern",
|
|
9
|
+
Elegant = "elegant"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare enum FormatId {
|
|
13
|
+
Story = "story",
|
|
14
|
+
Post = "post",
|
|
15
|
+
Square = "square",
|
|
16
|
+
Phone = "phone",
|
|
17
|
+
Desktop = "desktop"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare enum LayoutId {
|
|
21
|
+
PictureRight = "picture-right",
|
|
22
|
+
PictureLeft = "picture-left",
|
|
23
|
+
PictureBottom = "picture-bottom",
|
|
24
|
+
List = "list",
|
|
25
|
+
Arch = "arch",
|
|
26
|
+
PhoneClockSafe = "phone-clock-safe",
|
|
27
|
+
PhoneArch = "phone-arch",
|
|
28
|
+
DesktopSafe = "desktop-safe",
|
|
29
|
+
DesktopArch = "desktop-arch"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare enum PaletteId {
|
|
33
|
+
Sand = "sand",
|
|
34
|
+
Night = "night",
|
|
35
|
+
Sea = "sea",
|
|
36
|
+
Rose = "rose"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare enum PictureAnchor {
|
|
40
|
+
Top = "top",
|
|
41
|
+
Center = "center",
|
|
42
|
+
Bottom = "bottom"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface FormatSize {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
}
|
|
49
|
+
declare const FORMAT_SIZES: Readonly<Record<FormatId, FormatSize>>;
|
|
50
|
+
|
|
51
|
+
interface ScheduleRow {
|
|
52
|
+
label: string;
|
|
53
|
+
time: string;
|
|
54
|
+
}
|
|
55
|
+
interface PriceRow {
|
|
56
|
+
amount: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}
|
|
59
|
+
interface IncludesBlock {
|
|
60
|
+
heading: string;
|
|
61
|
+
items: string[];
|
|
62
|
+
}
|
|
63
|
+
interface FlierBlocks {
|
|
64
|
+
title: string;
|
|
65
|
+
titleBottom?: string;
|
|
66
|
+
script?: string;
|
|
67
|
+
venue?: string[];
|
|
68
|
+
schedule?: ScheduleRow[];
|
|
69
|
+
prices?: PriceRow[];
|
|
70
|
+
includes?: IncludesBlock;
|
|
71
|
+
footer?: string;
|
|
72
|
+
}
|
|
73
|
+
interface ListItem {
|
|
74
|
+
date: string;
|
|
75
|
+
schedule: ScheduleRow[];
|
|
76
|
+
price?: string;
|
|
77
|
+
}
|
|
78
|
+
interface PictureSlot {
|
|
79
|
+
imageId: string;
|
|
80
|
+
anchor: PictureAnchor;
|
|
81
|
+
scale: number;
|
|
82
|
+
}
|
|
83
|
+
interface LogoSlot {
|
|
84
|
+
imageId: string;
|
|
85
|
+
}
|
|
86
|
+
interface FlierDoc {
|
|
87
|
+
version: 1;
|
|
88
|
+
format: FormatId;
|
|
89
|
+
layout: LayoutId;
|
|
90
|
+
palette: PaletteId;
|
|
91
|
+
fonts: FontSetId;
|
|
92
|
+
background: BackgroundStyle;
|
|
93
|
+
picture?: PictureSlot;
|
|
94
|
+
logo?: LogoSlot;
|
|
95
|
+
blocks: FlierBlocks;
|
|
96
|
+
items?: ListItem[];
|
|
97
|
+
}
|
|
98
|
+
interface Rect {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
w: number;
|
|
102
|
+
h: number;
|
|
103
|
+
}
|
|
104
|
+
interface PosterImage {
|
|
105
|
+
readonly width: number;
|
|
106
|
+
readonly height: number;
|
|
107
|
+
}
|
|
108
|
+
type PosterAssets = Record<string, PosterImage | undefined>;
|
|
109
|
+
interface TextMetricsLike {
|
|
110
|
+
width: number;
|
|
111
|
+
}
|
|
112
|
+
interface PosterContext {
|
|
113
|
+
font: string;
|
|
114
|
+
fillStyle: string;
|
|
115
|
+
textAlign: string;
|
|
116
|
+
textBaseline: string;
|
|
117
|
+
globalAlpha: number;
|
|
118
|
+
save(): void;
|
|
119
|
+
restore(): void;
|
|
120
|
+
fillRect(x: number, y: number, w: number, h: number): void;
|
|
121
|
+
fillText(text: string, x: number, y: number): void;
|
|
122
|
+
measureText(text: string): TextMetricsLike;
|
|
123
|
+
drawImage(image: PosterImage, dx: number, dy: number, dw: number, dh: number): void;
|
|
124
|
+
beginPath(): void;
|
|
125
|
+
moveTo(x: number, y: number): void;
|
|
126
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, r: number): void;
|
|
127
|
+
arc(x: number, y: number, r: number, start: number, end: number): void;
|
|
128
|
+
closePath(): void;
|
|
129
|
+
fill(): void;
|
|
130
|
+
}
|
|
131
|
+
interface PosterCanvas {
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
getContext(kind: '2d'): PosterContext | null;
|
|
135
|
+
}
|
|
136
|
+
interface RenderReport {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
picture: Rect | null;
|
|
140
|
+
pictureRegion: Rect;
|
|
141
|
+
textBoxes: Rect[];
|
|
142
|
+
cardBoxes: Rect[];
|
|
143
|
+
backdrop: Rect | null;
|
|
144
|
+
}
|
|
145
|
+
interface Palette {
|
|
146
|
+
background: string;
|
|
147
|
+
tint: string;
|
|
148
|
+
title: string;
|
|
149
|
+
accent: string;
|
|
150
|
+
ink: string;
|
|
151
|
+
soft: string;
|
|
152
|
+
card: string;
|
|
153
|
+
arch: string;
|
|
154
|
+
}
|
|
155
|
+
interface FontSet {
|
|
156
|
+
display: string;
|
|
157
|
+
script: string;
|
|
158
|
+
body: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
declare const PALETTES: Readonly<Record<PaletteId, Palette>>;
|
|
162
|
+
|
|
163
|
+
declare const FONT_SETS: Readonly<Record<FontSetId, FontSet>>;
|
|
164
|
+
|
|
165
|
+
interface JsonSchema {
|
|
166
|
+
$schema?: string;
|
|
167
|
+
$id?: string;
|
|
168
|
+
title?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'integer';
|
|
171
|
+
properties?: Record<string, JsonSchema>;
|
|
172
|
+
required?: string[];
|
|
173
|
+
additionalProperties?: boolean;
|
|
174
|
+
enum?: readonly (string | number)[];
|
|
175
|
+
const?: string | number;
|
|
176
|
+
minLength?: number;
|
|
177
|
+
maxLength?: number;
|
|
178
|
+
minimum?: number;
|
|
179
|
+
maximum?: number;
|
|
180
|
+
items?: JsonSchema;
|
|
181
|
+
minItems?: number;
|
|
182
|
+
maxItems?: number;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare const flierDocSchema: JsonSchema;
|
|
186
|
+
|
|
187
|
+
type FlierDocResult = {
|
|
188
|
+
ok: true;
|
|
189
|
+
doc: FlierDoc;
|
|
190
|
+
} | {
|
|
191
|
+
ok: false;
|
|
192
|
+
errors: string[];
|
|
193
|
+
};
|
|
194
|
+
declare class FlierDocError extends Error {
|
|
195
|
+
readonly errors: string[];
|
|
196
|
+
constructor(errors: string[]);
|
|
197
|
+
}
|
|
198
|
+
/** Checks any input (form, preset file, LLM output) against the FlierDoc schema; errors read "path: problem". */
|
|
199
|
+
declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
200
|
+
|
|
201
|
+
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
202
|
+
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
203
|
+
|
|
204
|
+
interface DataUrlCanvas {
|
|
205
|
+
toDataURL(type: string): string;
|
|
206
|
+
}
|
|
207
|
+
/** Encodes the canvas as a PNG Blob of the canvas's exact pixel size. */
|
|
208
|
+
declare function exportPng(canvas: DataUrlCanvas): Blob;
|
|
209
|
+
|
|
210
|
+
interface LayoutCatalogueEntry {
|
|
211
|
+
id: LayoutId;
|
|
212
|
+
designId: string;
|
|
213
|
+
label: string;
|
|
214
|
+
description: string;
|
|
215
|
+
formats: readonly FormatId[];
|
|
216
|
+
}
|
|
217
|
+
declare const LAYOUT_CATALOGUE: readonly LayoutCatalogueEntry[];
|
|
218
|
+
/** The default layout for a format (D4: E-A for posters, P-A for phone, D-A for desktop). */
|
|
219
|
+
declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
220
|
+
|
|
221
|
+
declare const kizombaWorkshop: FlierDoc;
|
|
222
|
+
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
223
|
+
|
|
224
|
+
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, type LayoutCatalogueEntry, LayoutId, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterImage, type PriceRow, type Rect, type RenderReport, type ScheduleRow, type TextMetricsLike, defaultLayoutFor, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, validateFlierDoc };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
declare enum BackgroundStyle {
|
|
2
|
+
Solid = "solid",
|
|
3
|
+
Tint = "tint"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare enum FontSetId {
|
|
7
|
+
Classic = "classic",
|
|
8
|
+
Modern = "modern",
|
|
9
|
+
Elegant = "elegant"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare enum FormatId {
|
|
13
|
+
Story = "story",
|
|
14
|
+
Post = "post",
|
|
15
|
+
Square = "square",
|
|
16
|
+
Phone = "phone",
|
|
17
|
+
Desktop = "desktop"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare enum LayoutId {
|
|
21
|
+
PictureRight = "picture-right",
|
|
22
|
+
PictureLeft = "picture-left",
|
|
23
|
+
PictureBottom = "picture-bottom",
|
|
24
|
+
List = "list",
|
|
25
|
+
Arch = "arch",
|
|
26
|
+
PhoneClockSafe = "phone-clock-safe",
|
|
27
|
+
PhoneArch = "phone-arch",
|
|
28
|
+
DesktopSafe = "desktop-safe",
|
|
29
|
+
DesktopArch = "desktop-arch"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare enum PaletteId {
|
|
33
|
+
Sand = "sand",
|
|
34
|
+
Night = "night",
|
|
35
|
+
Sea = "sea",
|
|
36
|
+
Rose = "rose"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare enum PictureAnchor {
|
|
40
|
+
Top = "top",
|
|
41
|
+
Center = "center",
|
|
42
|
+
Bottom = "bottom"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface FormatSize {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
}
|
|
49
|
+
declare const FORMAT_SIZES: Readonly<Record<FormatId, FormatSize>>;
|
|
50
|
+
|
|
51
|
+
interface ScheduleRow {
|
|
52
|
+
label: string;
|
|
53
|
+
time: string;
|
|
54
|
+
}
|
|
55
|
+
interface PriceRow {
|
|
56
|
+
amount: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}
|
|
59
|
+
interface IncludesBlock {
|
|
60
|
+
heading: string;
|
|
61
|
+
items: string[];
|
|
62
|
+
}
|
|
63
|
+
interface FlierBlocks {
|
|
64
|
+
title: string;
|
|
65
|
+
titleBottom?: string;
|
|
66
|
+
script?: string;
|
|
67
|
+
venue?: string[];
|
|
68
|
+
schedule?: ScheduleRow[];
|
|
69
|
+
prices?: PriceRow[];
|
|
70
|
+
includes?: IncludesBlock;
|
|
71
|
+
footer?: string;
|
|
72
|
+
}
|
|
73
|
+
interface ListItem {
|
|
74
|
+
date: string;
|
|
75
|
+
schedule: ScheduleRow[];
|
|
76
|
+
price?: string;
|
|
77
|
+
}
|
|
78
|
+
interface PictureSlot {
|
|
79
|
+
imageId: string;
|
|
80
|
+
anchor: PictureAnchor;
|
|
81
|
+
scale: number;
|
|
82
|
+
}
|
|
83
|
+
interface LogoSlot {
|
|
84
|
+
imageId: string;
|
|
85
|
+
}
|
|
86
|
+
interface FlierDoc {
|
|
87
|
+
version: 1;
|
|
88
|
+
format: FormatId;
|
|
89
|
+
layout: LayoutId;
|
|
90
|
+
palette: PaletteId;
|
|
91
|
+
fonts: FontSetId;
|
|
92
|
+
background: BackgroundStyle;
|
|
93
|
+
picture?: PictureSlot;
|
|
94
|
+
logo?: LogoSlot;
|
|
95
|
+
blocks: FlierBlocks;
|
|
96
|
+
items?: ListItem[];
|
|
97
|
+
}
|
|
98
|
+
interface Rect {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
w: number;
|
|
102
|
+
h: number;
|
|
103
|
+
}
|
|
104
|
+
interface PosterImage {
|
|
105
|
+
readonly width: number;
|
|
106
|
+
readonly height: number;
|
|
107
|
+
}
|
|
108
|
+
type PosterAssets = Record<string, PosterImage | undefined>;
|
|
109
|
+
interface TextMetricsLike {
|
|
110
|
+
width: number;
|
|
111
|
+
}
|
|
112
|
+
interface PosterContext {
|
|
113
|
+
font: string;
|
|
114
|
+
fillStyle: string;
|
|
115
|
+
textAlign: string;
|
|
116
|
+
textBaseline: string;
|
|
117
|
+
globalAlpha: number;
|
|
118
|
+
save(): void;
|
|
119
|
+
restore(): void;
|
|
120
|
+
fillRect(x: number, y: number, w: number, h: number): void;
|
|
121
|
+
fillText(text: string, x: number, y: number): void;
|
|
122
|
+
measureText(text: string): TextMetricsLike;
|
|
123
|
+
drawImage(image: PosterImage, dx: number, dy: number, dw: number, dh: number): void;
|
|
124
|
+
beginPath(): void;
|
|
125
|
+
moveTo(x: number, y: number): void;
|
|
126
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, r: number): void;
|
|
127
|
+
arc(x: number, y: number, r: number, start: number, end: number): void;
|
|
128
|
+
closePath(): void;
|
|
129
|
+
fill(): void;
|
|
130
|
+
}
|
|
131
|
+
interface PosterCanvas {
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
getContext(kind: '2d'): PosterContext | null;
|
|
135
|
+
}
|
|
136
|
+
interface RenderReport {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
picture: Rect | null;
|
|
140
|
+
pictureRegion: Rect;
|
|
141
|
+
textBoxes: Rect[];
|
|
142
|
+
cardBoxes: Rect[];
|
|
143
|
+
backdrop: Rect | null;
|
|
144
|
+
}
|
|
145
|
+
interface Palette {
|
|
146
|
+
background: string;
|
|
147
|
+
tint: string;
|
|
148
|
+
title: string;
|
|
149
|
+
accent: string;
|
|
150
|
+
ink: string;
|
|
151
|
+
soft: string;
|
|
152
|
+
card: string;
|
|
153
|
+
arch: string;
|
|
154
|
+
}
|
|
155
|
+
interface FontSet {
|
|
156
|
+
display: string;
|
|
157
|
+
script: string;
|
|
158
|
+
body: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
declare const PALETTES: Readonly<Record<PaletteId, Palette>>;
|
|
162
|
+
|
|
163
|
+
declare const FONT_SETS: Readonly<Record<FontSetId, FontSet>>;
|
|
164
|
+
|
|
165
|
+
interface JsonSchema {
|
|
166
|
+
$schema?: string;
|
|
167
|
+
$id?: string;
|
|
168
|
+
title?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'integer';
|
|
171
|
+
properties?: Record<string, JsonSchema>;
|
|
172
|
+
required?: string[];
|
|
173
|
+
additionalProperties?: boolean;
|
|
174
|
+
enum?: readonly (string | number)[];
|
|
175
|
+
const?: string | number;
|
|
176
|
+
minLength?: number;
|
|
177
|
+
maxLength?: number;
|
|
178
|
+
minimum?: number;
|
|
179
|
+
maximum?: number;
|
|
180
|
+
items?: JsonSchema;
|
|
181
|
+
minItems?: number;
|
|
182
|
+
maxItems?: number;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare const flierDocSchema: JsonSchema;
|
|
186
|
+
|
|
187
|
+
type FlierDocResult = {
|
|
188
|
+
ok: true;
|
|
189
|
+
doc: FlierDoc;
|
|
190
|
+
} | {
|
|
191
|
+
ok: false;
|
|
192
|
+
errors: string[];
|
|
193
|
+
};
|
|
194
|
+
declare class FlierDocError extends Error {
|
|
195
|
+
readonly errors: string[];
|
|
196
|
+
constructor(errors: string[]);
|
|
197
|
+
}
|
|
198
|
+
/** Checks any input (form, preset file, LLM output) against the FlierDoc schema; errors read "path: problem". */
|
|
199
|
+
declare function validateFlierDoc(input: unknown): FlierDocResult;
|
|
200
|
+
|
|
201
|
+
/** Validates the doc, then draws it on the canvas (resized to the format); throws FlierDocError before touching the canvas. */
|
|
202
|
+
declare function render(input: unknown, assets: PosterAssets, canvas: PosterCanvas): RenderReport;
|
|
203
|
+
|
|
204
|
+
interface DataUrlCanvas {
|
|
205
|
+
toDataURL(type: string): string;
|
|
206
|
+
}
|
|
207
|
+
/** Encodes the canvas as a PNG Blob of the canvas's exact pixel size. */
|
|
208
|
+
declare function exportPng(canvas: DataUrlCanvas): Blob;
|
|
209
|
+
|
|
210
|
+
interface LayoutCatalogueEntry {
|
|
211
|
+
id: LayoutId;
|
|
212
|
+
designId: string;
|
|
213
|
+
label: string;
|
|
214
|
+
description: string;
|
|
215
|
+
formats: readonly FormatId[];
|
|
216
|
+
}
|
|
217
|
+
declare const LAYOUT_CATALOGUE: readonly LayoutCatalogueEntry[];
|
|
218
|
+
/** The default layout for a format (D4: E-A for posters, P-A for phone, D-A for desktop). */
|
|
219
|
+
declare function defaultLayoutFor(format: FormatId): LayoutId;
|
|
220
|
+
|
|
221
|
+
declare const kizombaWorkshop: FlierDoc;
|
|
222
|
+
declare const kizombaWorkshopDocs: FlierDoc[];
|
|
223
|
+
|
|
224
|
+
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, type LayoutCatalogueEntry, LayoutId, type ListItem, type LogoSlot, PALETTES, type Palette, PaletteId, PictureAnchor, type PictureSlot, type PosterAssets, type PosterCanvas, type PosterContext, type PosterImage, type PriceRow, type Rect, type RenderReport, type ScheduleRow, type TextMetricsLike, defaultLayoutFor, exportPng, flierDocSchema, kizombaWorkshop, kizombaWorkshopDocs, render, validateFlierDoc };
|