@segnavia/format 0.38.0 → 0.40.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.
Files changed (60) hide show
  1. package/dist/board-edit.d.ts +2 -1
  2. package/dist/board-geometry.d.ts +2 -1
  3. package/dist/board-section-grid.d.ts +2 -1
  4. package/dist/board-sections.d.ts +2 -1
  5. package/dist/board.d.ts +8 -8
  6. package/dist/board.js +15 -11
  7. package/dist/book-exports.d.ts +2 -2
  8. package/dist/book-section.d.ts +171 -0
  9. package/dist/book-section.js +13 -2
  10. package/dist/book.d.ts +189 -47
  11. package/dist/book.js +18 -2
  12. package/dist/cover.d.ts +500 -0
  13. package/dist/cover.js +100 -0
  14. package/dist/deck-from-slides.d.ts +23 -4
  15. package/dist/deck.d.ts +144 -42
  16. package/dist/deck.js +22 -24
  17. package/dist/direction.d.ts +1 -1
  18. package/dist/font-collection.d.ts +8 -0
  19. package/dist/font-collection.js +191 -0
  20. package/dist/font-face.d.ts +8 -0
  21. package/dist/font-face.js +24 -0
  22. package/dist/font-refusal.d.ts +5 -0
  23. package/dist/font-refusal.js +9 -0
  24. package/dist/font-signature.d.ts +5 -0
  25. package/dist/font-signature.js +13 -0
  26. package/dist/fonts.d.ts +6 -1
  27. package/dist/fonts.js +3 -1
  28. package/dist/geometry.d.ts +20 -0
  29. package/dist/geometry.js +18 -0
  30. package/dist/image-fit.d.ts +10 -0
  31. package/dist/image-fit.js +10 -0
  32. package/dist/imposition-marks.d.ts +1 -1
  33. package/dist/imposition-schema.d.ts +185 -0
  34. package/dist/imposition-schema.js +122 -0
  35. package/dist/imposition.d.ts +8 -6
  36. package/dist/imposition.js +53 -42
  37. package/dist/index.d.ts +23 -1756
  38. package/dist/index.js +29 -212
  39. package/dist/json-schemas.d.ts +2181 -0
  40. package/dist/json-schemas.js +43 -0
  41. package/dist/media.d.ts +152 -0
  42. package/dist/media.js +119 -0
  43. package/dist/note-series.d.ts +4 -4
  44. package/dist/note-series.js +0 -5
  45. package/dist/page.d.ts +359 -0
  46. package/dist/page.js +110 -0
  47. package/dist/paper.d.ts +5 -5
  48. package/dist/placement-cycle.d.ts +5 -0
  49. package/dist/placement-cycle.js +30 -0
  50. package/dist/placement-refusal.d.ts +5 -0
  51. package/dist/placement-refusal.js +6 -0
  52. package/dist/placement.d.ts +76 -0
  53. package/dist/placement.js +100 -0
  54. package/dist/print.d.ts +72 -0
  55. package/dist/print.js +38 -0
  56. package/dist/printed-page-imposition.d.ts +2 -1
  57. package/dist/shots-used.d.ts +0 -1
  58. package/dist/shots-used.js +2 -2
  59. package/dist/slots.d.ts +13 -13
  60. package/package.json +1 -1
package/dist/page.d.ts ADDED
@@ -0,0 +1,359 @@
1
+ import { z } from "zod";
2
+ //#region src/page.d.ts
3
+ export declare const PAGE_WIDTHS: {
4
+ readonly standard: 1024;
5
+ readonly wide: 1440;
6
+ };
7
+ export declare const FULL_PAGE_SIZE: {
8
+ readonly width: "full";
9
+ readonly height: "auto";
10
+ };
11
+ export declare const FlowingWidth: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
12
+ export type FlowingWidth = z.infer<typeof FlowingWidth>;
13
+ export declare const PageWidths: z.ZodObject<{
14
+ standard: z.ZodOptional<z.ZodNumber>;
15
+ wide: z.ZodOptional<z.ZodNumber>;
16
+ }, z.core.$strip>;
17
+ export type PageWidths = z.infer<typeof PageWidths>;
18
+ export declare const PageSize: z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
19
+ readonly width: "full";
20
+ readonly height: "auto";
21
+ }, "fluid">>, z.ZodObject<{
22
+ width: z.ZodNumber;
23
+ height: z.ZodNumber;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
26
+ height: z.ZodLiteral<"auto">;
27
+ }, z.core.$strip>]>;
28
+ export type PageSize = z.infer<typeof PageSize>;
29
+ export interface ResolvedPageWidth {
30
+ measure?: number;
31
+ viewportWidth: number;
32
+ }
33
+ export declare const PageBody: z.ZodUnion<readonly [z.ZodObject<{
34
+ html: z.ZodString;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ markdown: z.ZodString;
37
+ }, z.core.$strict>]>;
38
+ export type PageBody = z.infer<typeof PageBody>;
39
+ export declare function resolvePageWidth(size: PageSize, overrides?: PageWidths): ResolvedPageWidth;
40
+ export declare const Page: z.ZodPipe<z.ZodObject<{
41
+ id: z.ZodOptional<z.ZodString>;
42
+ body: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
43
+ html: z.ZodString;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ markdown: z.ZodString;
46
+ }, z.core.$strict>]>>;
47
+ html: z.ZodOptional<z.ZodString>;
48
+ markdown: z.ZodOptional<z.ZodString>;
49
+ size: z.ZodDefault<z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
50
+ readonly width: "full";
51
+ readonly height: "auto";
52
+ }, "fluid">>, z.ZodObject<{
53
+ width: z.ZodNumber;
54
+ height: z.ZodNumber;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
57
+ height: z.ZodLiteral<"auto">;
58
+ }, z.core.$strip>]>>;
59
+ scripts: z.ZodDefault<z.ZodEnum<{
60
+ refuse: "refuse";
61
+ sandboxed: "sandboxed";
62
+ }>>;
63
+ dir: z.ZodOptional<z.ZodEnum<{
64
+ auto: "auto";
65
+ ltr: "ltr";
66
+ rtl: "rtl";
67
+ }>>;
68
+ lang: z.ZodOptional<z.ZodString>;
69
+ print: z.ZodOptional<z.ZodObject<{
70
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
71
+ letter: "letter";
72
+ legal: "legal";
73
+ tabloid: "tabloid";
74
+ a3: "a3";
75
+ a4: "a4";
76
+ a5: "a5";
77
+ "business-card-us": "business-card-us";
78
+ "business-card-eu": "business-card-eu";
79
+ "business-card-square-us": "business-card-square-us";
80
+ "business-card-slim-us": "business-card-slim-us";
81
+ "postcard-4x6": "postcard-4x6";
82
+ "postcard-5x7": "postcard-5x7";
83
+ "postcard-6x9": "postcard-6x9";
84
+ "postcard-6x11": "postcard-6x11";
85
+ "card-square-4in": "card-square-4in";
86
+ "half-letter": "half-letter";
87
+ a6: "a6";
88
+ dl: "dl";
89
+ "rack-card-4x9": "rack-card-4x9";
90
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
91
+ "poster-12x18": "poster-12x18";
92
+ "poster-16x20": "poster-16x20";
93
+ "poster-18x24": "poster-18x24";
94
+ "poster-24x36": "poster-24x36";
95
+ a2: "a2";
96
+ a1: "a1";
97
+ a0: "a0";
98
+ }>, z.ZodObject<{
99
+ width: z.ZodNumber;
100
+ height: z.ZodNumber;
101
+ unit: z.ZodEnum<{
102
+ in: "in";
103
+ mm: "mm";
104
+ pt: "pt";
105
+ }>;
106
+ }, z.core.$strip>]>;
107
+ orientation: z.ZodDefault<z.ZodEnum<{
108
+ portrait: "portrait";
109
+ landscape: "landscape";
110
+ }>>;
111
+ margin: z.ZodOptional<z.ZodObject<{
112
+ top: z.ZodDefault<z.ZodNumber>;
113
+ right: z.ZodDefault<z.ZodNumber>;
114
+ bottom: z.ZodDefault<z.ZodNumber>;
115
+ left: z.ZodDefault<z.ZodNumber>;
116
+ }, z.core.$strip>>;
117
+ bleed: z.ZodDefault<z.ZodNumber>;
118
+ safe: z.ZodDefault<z.ZodNumber>;
119
+ marks: z.ZodDefault<z.ZodBoolean>;
120
+ markColor: z.ZodDefault<z.ZodEnum<{
121
+ black: "black";
122
+ registration: "registration";
123
+ }>>;
124
+ }, z.core.$strip>>;
125
+ printedPages: z.ZodOptional<z.ZodObject<{
126
+ parents: z.ZodArray<z.ZodObject<{
127
+ name: z.ZodString;
128
+ basedOn: z.ZodOptional<z.ZodString>;
129
+ margin: z.ZodOptional<z.ZodObject<{
130
+ top: z.ZodNumber;
131
+ bottom: z.ZodNumber;
132
+ inner: z.ZodNumber;
133
+ outer: z.ZodNumber;
134
+ }, z.core.$strip>>;
135
+ head: z.ZodOptional<z.ZodString>;
136
+ foot: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strip>>;
138
+ rules: z.ZodPipe<z.ZodObject<{
139
+ every: z.ZodString;
140
+ first: z.ZodOptional<z.ZodString>;
141
+ recto: z.ZodOptional<z.ZodString>;
142
+ verso: z.ZodOptional<z.ZodString>;
143
+ last: z.ZodOptional<z.ZodString>;
144
+ }, z.core.$loose>, z.ZodTransform<{
145
+ last?: string | undefined;
146
+ verso?: string | undefined;
147
+ recto?: string | undefined;
148
+ first?: string | undefined;
149
+ every: string;
150
+ }, {
151
+ [x: string]: unknown;
152
+ every: string;
153
+ first?: string | undefined;
154
+ recto?: string | undefined;
155
+ verso?: string | undefined;
156
+ last?: string | undefined;
157
+ }>>;
158
+ numbering: z.ZodOptional<z.ZodEnum<{
159
+ arabic: "arabic";
160
+ "roman-lower": "roman-lower";
161
+ "roman-upper": "roman-upper";
162
+ hebrew: "hebrew";
163
+ }>>;
164
+ }, z.core.$strip>>;
165
+ slots: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
166
+ key: z.ZodString;
167
+ label: z.ZodString;
168
+ type: z.ZodEnum<{
169
+ text: "text";
170
+ image: "image";
171
+ phone: "phone";
172
+ email: "email";
173
+ link: "link";
174
+ qr: "qr";
175
+ }>;
176
+ required: z.ZodDefault<z.ZodBoolean>;
177
+ placeholder: z.ZodOptional<z.ZodString>;
178
+ overflow: z.ZodDefault<z.ZodEnum<{
179
+ refuse: "refuse";
180
+ shrink: "shrink";
181
+ truncate: "truncate";
182
+ wrap: "wrap";
183
+ }>>;
184
+ minSize: z.ZodOptional<z.ZodNumber>;
185
+ }, z.core.$strip>, z.ZodTransform<{
186
+ key: string;
187
+ label: string;
188
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
189
+ required: boolean;
190
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
191
+ placeholder?: string | undefined;
192
+ minSize?: number | undefined;
193
+ }, {
194
+ key: string;
195
+ label: string;
196
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
197
+ required: boolean;
198
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
199
+ placeholder?: string | undefined;
200
+ minSize?: number | undefined;
201
+ }>>>>;
202
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
203
+ app: z.ZodString;
204
+ }, z.core.$strip>, z.ZodObject<{
205
+ local: z.ZodString;
206
+ fallback: z.ZodString;
207
+ }, z.core.$strip>]>>>;
208
+ }, z.core.$strip>, z.ZodTransform<{
209
+ body: PageBody;
210
+ size: {
211
+ width: number;
212
+ height: number;
213
+ } | {
214
+ readonly width: "full";
215
+ readonly height: "auto";
216
+ } | {
217
+ width: number | "full" | "standard" | "wide";
218
+ height: "auto";
219
+ };
220
+ scripts: "refuse" | "sandboxed";
221
+ id?: string | undefined;
222
+ dir?: "auto" | "ltr" | "rtl" | undefined;
223
+ lang?: string | undefined;
224
+ print?: {
225
+ paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | "business-card-us" | "business-card-eu" | "business-card-square-us" | "business-card-slim-us" | "postcard-4x6" | "postcard-5x7" | "postcard-6x9" | "postcard-6x11" | "card-square-4in" | "half-letter" | "a6" | "dl" | "rack-card-4x9" | "rack-card-3.5x8.5" | "poster-12x18" | "poster-16x20" | "poster-18x24" | "poster-24x36" | "a2" | "a1" | "a0" | {
226
+ width: number;
227
+ height: number;
228
+ unit: "in" | "mm" | "pt";
229
+ };
230
+ orientation: "portrait" | "landscape";
231
+ bleed: number;
232
+ safe: number;
233
+ marks: boolean;
234
+ markColor: "black" | "registration";
235
+ margin?: {
236
+ top: number;
237
+ right: number;
238
+ bottom: number;
239
+ left: number;
240
+ } | undefined;
241
+ } | undefined;
242
+ printedPages?: {
243
+ parents: {
244
+ name: string;
245
+ basedOn?: string | undefined;
246
+ margin?: {
247
+ top: number;
248
+ bottom: number;
249
+ inner: number;
250
+ outer: number;
251
+ } | undefined;
252
+ head?: string | undefined;
253
+ foot?: string | undefined;
254
+ }[];
255
+ rules: {
256
+ last?: string | undefined;
257
+ verso?: string | undefined;
258
+ recto?: string | undefined;
259
+ first?: string | undefined;
260
+ every: string;
261
+ };
262
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
263
+ } | undefined;
264
+ slots?: {
265
+ key: string;
266
+ label: string;
267
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
268
+ required: boolean;
269
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
270
+ placeholder?: string | undefined;
271
+ minSize?: number | undefined;
272
+ }[] | undefined;
273
+ fonts?: ({
274
+ app: string;
275
+ } | {
276
+ local: string;
277
+ fallback: string;
278
+ })[] | undefined;
279
+ }, {
280
+ size: {
281
+ width: number;
282
+ height: number;
283
+ } | {
284
+ readonly width: "full";
285
+ readonly height: "auto";
286
+ } | {
287
+ width: number | "full" | "standard" | "wide";
288
+ height: "auto";
289
+ };
290
+ scripts: "refuse" | "sandboxed";
291
+ id?: string | undefined;
292
+ body?: {
293
+ html: string;
294
+ } | {
295
+ markdown: string;
296
+ } | undefined;
297
+ html?: string | undefined;
298
+ markdown?: string | undefined;
299
+ dir?: "auto" | "ltr" | "rtl" | undefined;
300
+ lang?: string | undefined;
301
+ print?: {
302
+ paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | "business-card-us" | "business-card-eu" | "business-card-square-us" | "business-card-slim-us" | "postcard-4x6" | "postcard-5x7" | "postcard-6x9" | "postcard-6x11" | "card-square-4in" | "half-letter" | "a6" | "dl" | "rack-card-4x9" | "rack-card-3.5x8.5" | "poster-12x18" | "poster-16x20" | "poster-18x24" | "poster-24x36" | "a2" | "a1" | "a0" | {
303
+ width: number;
304
+ height: number;
305
+ unit: "in" | "mm" | "pt";
306
+ };
307
+ orientation: "portrait" | "landscape";
308
+ bleed: number;
309
+ safe: number;
310
+ marks: boolean;
311
+ markColor: "black" | "registration";
312
+ margin?: {
313
+ top: number;
314
+ right: number;
315
+ bottom: number;
316
+ left: number;
317
+ } | undefined;
318
+ } | undefined;
319
+ printedPages?: {
320
+ parents: {
321
+ name: string;
322
+ basedOn?: string | undefined;
323
+ margin?: {
324
+ top: number;
325
+ bottom: number;
326
+ inner: number;
327
+ outer: number;
328
+ } | undefined;
329
+ head?: string | undefined;
330
+ foot?: string | undefined;
331
+ }[];
332
+ rules: {
333
+ last?: string | undefined;
334
+ verso?: string | undefined;
335
+ recto?: string | undefined;
336
+ first?: string | undefined;
337
+ every: string;
338
+ };
339
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
340
+ } | undefined;
341
+ slots?: {
342
+ key: string;
343
+ label: string;
344
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
345
+ required: boolean;
346
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
347
+ placeholder?: string | undefined;
348
+ minSize?: number | undefined;
349
+ }[] | undefined;
350
+ fonts?: ({
351
+ app: string;
352
+ } | {
353
+ local: string;
354
+ fallback: string;
355
+ })[] | undefined;
356
+ }>>;
357
+ export type Page = z.infer<typeof Page>;
358
+ export type PageInput = z.input<typeof Page>;
359
+ //#endregion
package/dist/page.js ADDED
@@ -0,0 +1,110 @@
1
+ import { Direction } from "./direction.js";
2
+ import { Size } from "./geometry.js";
3
+ import { Scripts } from "./scripts.js";
4
+ import { Slots } from "./slots.js";
5
+ import { FontReference } from "./fonts.js";
6
+ import { PrintedPages, pagePrintedPagesIssues } from "./printed-pages.js";
7
+ import { Print } from "./print.js";
8
+ import { z } from "zod";
9
+ //#region src/page.ts
10
+ const PAGE_WIDTHS = {
11
+ standard: 1024,
12
+ wide: 1440
13
+ };
14
+ const FULL_PAGE_SIZE = {
15
+ width: "full",
16
+ height: "auto"
17
+ };
18
+ const FlowingWidth = z.union([
19
+ z.literal("full"),
20
+ z.literal("standard"),
21
+ z.literal("wide"),
22
+ z.number().int().positive()
23
+ ]);
24
+ const PageWidths = z.object({
25
+ standard: z.number().positive().optional(),
26
+ wide: z.number().positive().optional()
27
+ });
28
+ const FlowingPageSize = z.object({
29
+ width: FlowingWidth,
30
+ height: z.literal("auto")
31
+ });
32
+ const LegacyFluidPageSize = z.literal("fluid").transform(() => FULL_PAGE_SIZE);
33
+ const PageSize = z.union([
34
+ LegacyFluidPageSize,
35
+ Size,
36
+ FlowingPageSize
37
+ ]);
38
+ const PageBody = z.union([z.strictObject({ html: z.string() }), z.strictObject({ markdown: z.string() })]);
39
+ function resolvePageWidth(size, overrides = {}) {
40
+ const width = size.width;
41
+ if (typeof width === "number") return {
42
+ measure: width,
43
+ viewportWidth: width
44
+ };
45
+ if (width === "full") return { viewportWidth: overrides.standard ?? PAGE_WIDTHS.standard };
46
+ const measure = overrides[width] ?? PAGE_WIDTHS[width];
47
+ return {
48
+ measure,
49
+ viewportWidth: measure
50
+ };
51
+ }
52
+ const PageShape = z.object({
53
+ id: z.string().optional(),
54
+ body: PageBody.optional(),
55
+ html: z.string().optional(),
56
+ markdown: z.string().optional(),
57
+ size: PageSize.default(FULL_PAGE_SIZE),
58
+ scripts: Scripts.default("refuse"),
59
+ dir: Direction.optional(),
60
+ lang: z.string().optional(),
61
+ print: Print.optional(),
62
+ printedPages: PrintedPages.optional(),
63
+ slots: Slots.optional(),
64
+ fonts: z.array(FontReference).optional()
65
+ }).superRefine((page, ctx) => {
66
+ const fields = bodyChoices(page).map(({ field }) => field);
67
+ if (fields.length === 0) ctx.addIssue({
68
+ code: "custom",
69
+ path: ["body"],
70
+ message: "body, html or markdown is required; provide exactly one page body"
71
+ });
72
+ if (fields.length > 1) {
73
+ const names = fields.join(", ");
74
+ for (const field of fields) ctx.addIssue({
75
+ code: "custom",
76
+ path: [field],
77
+ message: `${names} were all given; provide exactly one of body, html or markdown`
78
+ });
79
+ }
80
+ for (const issue of pagePrintedPagesIssues(page)) ctx.addIssue({
81
+ code: "custom",
82
+ ...issue
83
+ });
84
+ });
85
+ const BODY_SHORTHANDS = [{
86
+ field: "html",
87
+ body: (value) => ({ html: value })
88
+ }, {
89
+ field: "markdown",
90
+ body: (value) => ({ markdown: value })
91
+ }];
92
+ function bodyChoices(page) {
93
+ return [...page.body === void 0 ? [] : [{
94
+ field: "body",
95
+ body: page.body
96
+ }], ...BODY_SHORTHANDS.flatMap(({ field, body }) => page[field] === void 0 ? [] : [{
97
+ field,
98
+ body: body(page[field])
99
+ }])];
100
+ }
101
+ const Page = PageShape.transform(({ html, markdown, ...page }) => ({
102
+ ...page,
103
+ body: bodyChoices({
104
+ ...page,
105
+ html,
106
+ markdown
107
+ })[0]?.body
108
+ }));
109
+ //#endregion
110
+ export { FULL_PAGE_SIZE, FlowingWidth, PAGE_WIDTHS, Page, PageBody, PageSize, PageWidths, resolvePageWidth };
package/dist/paper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Print } from "./index.js";
1
+ import { Print } from "./print.js";
2
2
  import { z } from "zod";
3
3
  //#region src/paper.d.ts
4
4
  export declare const NAMED_PAPERS: readonly ["letter", "legal", "tabloid", "a3", "a4", "a5", "business-card-us", "business-card-eu", "business-card-square-us", "business-card-slim-us", "postcard-4x6", "postcard-5x7", "postcard-6x9", "postcard-6x11", "card-square-4in", "half-letter", "a6", "dl", "rack-card-4x9", "rack-card-3.5x8.5", "poster-12x18", "poster-16x20", "poster-18x24", "poster-24x36", "a2", "a1", "a0"];
@@ -151,8 +151,8 @@ export declare const CUSTOM_PAPER_MIN_MM = 10;
151
151
  export declare const CUSTOM_PAPER_MAX_MM = 2000;
152
152
  export declare const PAPER_UNITS: readonly ["mm", "in", "pt"];
153
153
  export declare const PaperUnit: z.ZodEnum<{
154
- mm: "mm";
155
154
  in: "in";
155
+ mm: "mm";
156
156
  pt: "pt";
157
157
  }>;
158
158
  export type PaperUnit = z.infer<typeof PaperUnit>;
@@ -194,8 +194,8 @@ export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
194
194
  width: z.ZodNumber;
195
195
  height: z.ZodNumber;
196
196
  unit: z.ZodEnum<{
197
- mm: "mm";
198
197
  in: "in";
198
+ mm: "mm";
199
199
  pt: "pt";
200
200
  }>;
201
201
  }, z.core.$strip>]>;
@@ -233,8 +233,8 @@ export declare const PrintSetting: z.ZodObject<{
233
233
  width: z.ZodNumber;
234
234
  height: z.ZodNumber;
235
235
  unit: z.ZodEnum<{
236
- mm: "mm";
237
236
  in: "in";
237
+ mm: "mm";
238
238
  pt: "pt";
239
239
  }>;
240
240
  }, z.core.$strip>]>;
@@ -277,8 +277,8 @@ export declare const PrintSettingInput: z.ZodObject<{
277
277
  width: z.ZodNumber;
278
278
  height: z.ZodNumber;
279
279
  unit: z.ZodEnum<{
280
- mm: "mm";
281
280
  in: "in";
281
+ mm: "mm";
282
282
  pt: "pt";
283
283
  }>;
284
284
  }, z.core.$strip>]>;
@@ -0,0 +1,5 @@
1
+ //#region src/placement-cycle.d.ts
2
+ export type PlacementGraph = Readonly<Record<string, readonly string[]>>;
3
+ export declare function findPlacementCycle(graph: PlacementGraph): string[] | undefined;
4
+ export declare function checkPlacementCycles(graph: PlacementGraph): void;
5
+ //#endregion
@@ -0,0 +1,30 @@
1
+ import { PlacementRefusedError } from "./placement-refusal.js";
2
+ //#region src/placement-cycle.ts
3
+ function findPlacementCycle(graph) {
4
+ const visiting = /* @__PURE__ */ new Set();
5
+ const visited = /* @__PURE__ */ new Set();
6
+ const path = [];
7
+ const visit = (address) => {
8
+ if (visiting.has(address)) return [...path.slice(path.indexOf(address)), address];
9
+ if (visited.has(address)) return void 0;
10
+ visiting.add(address);
11
+ path.push(address);
12
+ for (const child of graph[address] ?? []) {
13
+ const cycle = visit(child);
14
+ if (cycle) return cycle;
15
+ }
16
+ path.pop();
17
+ visiting.delete(address);
18
+ visited.add(address);
19
+ };
20
+ for (const address of Object.keys(graph)) {
21
+ const cycle = visit(address);
22
+ if (cycle) return cycle;
23
+ }
24
+ }
25
+ function checkPlacementCycles(graph) {
26
+ const cycle = findPlacementCycle(graph);
27
+ if (cycle) throw new PlacementRefusedError(`address could not be accepted because the placement chain ${cycle.join(" → ")} is a cycle; remove any one placement in the chain to clear this refusal`);
28
+ }
29
+ //#endregion
30
+ export { checkPlacementCycles, findPlacementCycle };
@@ -0,0 +1,5 @@
1
+ //#region src/placement-refusal.d.ts
2
+ export declare class PlacementRefusedError extends Error {
3
+ name: string;
4
+ }
5
+ //#endregion
@@ -0,0 +1,6 @@
1
+ //#region src/placement-refusal.ts
2
+ var PlacementRefusedError = class extends Error {
3
+ name = "PlacementRefusedError";
4
+ };
5
+ //#endregion
6
+ export { PlacementRefusedError };
@@ -0,0 +1,76 @@
1
+ import { Media } from "./media.js";
2
+ import { z } from "zod";
3
+ //#region src/placement.d.ts
4
+ export declare const PLACEMENT_ACCEPTS: {
5
+ readonly board: readonly ["deck", "page", "paper", "book", "media", "shot"];
6
+ readonly book: readonly ["media", "page"];
7
+ readonly page: readonly ["media"];
8
+ readonly deck: readonly ["media"];
9
+ readonly paper: readonly ["media"];
10
+ };
11
+ export declare const AssetKind: z.ZodEnum<{
12
+ deck: "deck";
13
+ page: "page";
14
+ paper: "paper";
15
+ book: "book";
16
+ media: "media";
17
+ shot: "shot";
18
+ }>;
19
+ export type AssetKind = z.infer<typeof AssetKind>;
20
+ export type PlacementContainer = keyof typeof PLACEMENT_ACCEPTS;
21
+ export declare const CropEdge: z.ZodString;
22
+ export type CropEdge = z.infer<typeof CropEdge>;
23
+ export declare const PlacementCrop: z.ZodObject<{
24
+ top: z.ZodOptional<z.ZodString>;
25
+ right: z.ZodOptional<z.ZodString>;
26
+ bottom: z.ZodOptional<z.ZodString>;
27
+ left: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ export type PlacementCrop = z.infer<typeof PlacementCrop>;
30
+ export declare const PlacementShape: z.ZodObject<{
31
+ kind: z.ZodEnum<{
32
+ deck: "deck";
33
+ page: "page";
34
+ paper: "paper";
35
+ book: "book";
36
+ media: "media";
37
+ shot: "shot";
38
+ }>;
39
+ address: z.ZodString;
40
+ page: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
41
+ box: z.ZodOptional<z.ZodEnum<{
42
+ media: "media";
43
+ crop: "crop";
44
+ trim: "trim";
45
+ bleed: "bleed";
46
+ art: "art";
47
+ }>>;
48
+ crop: z.ZodOptional<z.ZodObject<{
49
+ top: z.ZodOptional<z.ZodString>;
50
+ right: z.ZodOptional<z.ZodString>;
51
+ bottom: z.ZodOptional<z.ZodString>;
52
+ left: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strip>>;
54
+ fit: z.ZodOptional<z.ZodEnum<{
55
+ width: "width";
56
+ contain: "contain";
57
+ cover: "cover";
58
+ focus: "focus";
59
+ }>>;
60
+ alt: z.ZodOptional<z.ZodObject<{
61
+ text: z.ZodString;
62
+ lang: z.ZodOptional<z.ZodString>;
63
+ dir: z.ZodOptional<z.ZodEnum<{
64
+ auto: "auto";
65
+ ltr: "ltr";
66
+ rtl: "rtl";
67
+ }>>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
70
+ export type Placement = z.infer<typeof PlacementShape>;
71
+ export type PlacementInput = z.input<typeof PlacementShape>;
72
+ declare function parsePlacement(input: PlacementInput, container: PlacementContainer, placed?: Media): Placement;
73
+ export declare const Placement: {
74
+ parse: typeof parsePlacement;
75
+ };
76
+ //#endregion