@segnavia/format 0.38.0 → 0.39.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 (59) 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 +185 -43
  11. package/dist/book.js +18 -2
  12. package/dist/cover.d.ts +337 -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/index.d.ts +23 -1756
  37. package/dist/index.js +29 -212
  38. package/dist/json-schemas.d.ts +1860 -0
  39. package/dist/json-schemas.js +43 -0
  40. package/dist/media.d.ts +152 -0
  41. package/dist/media.js +119 -0
  42. package/dist/note-series.d.ts +4 -4
  43. package/dist/note-series.js +0 -5
  44. package/dist/page.d.ts +174 -0
  45. package/dist/page.js +37 -0
  46. package/dist/paper.d.ts +1 -1
  47. package/dist/placement-cycle.d.ts +5 -0
  48. package/dist/placement-cycle.js +30 -0
  49. package/dist/placement-refusal.d.ts +5 -0
  50. package/dist/placement-refusal.js +6 -0
  51. package/dist/placement.d.ts +76 -0
  52. package/dist/placement.js +100 -0
  53. package/dist/print.d.ts +72 -0
  54. package/dist/print.js +38 -0
  55. package/dist/printed-page-imposition.d.ts +2 -1
  56. package/dist/shots-used.d.ts +0 -1
  57. package/dist/shots-used.js +2 -2
  58. package/dist/slots.d.ts +13 -13
  59. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ import { Media } from "./media.js";
2
+ import { PlacementShape } from "./placement.js";
3
+ import { SlotDeclaration, SlotDeclarationInput } from "./slots.js";
4
+ import { DeckShape, Manifest, PublishedShot } from "./deck.js";
5
+ import { Board } from "./board.js";
6
+ import { FontReference, FontReferenceInput, LocalFaceTransport, LocalFacesTransport } from "./fonts.js";
7
+ import { Motif, MotifInput } from "./motif.js";
8
+ import { PrintSetting, PrintSettingInput } from "./paper.js";
9
+ import { BookShape, BookView } from "./book.js";
10
+ import { Page } from "./page.js";
11
+ import { Cover } from "./cover.js";
12
+ import { Imposition } from "./imposition-schema.js";
13
+ import { Lexicon } from "./lexicon.js";
14
+ import { z } from "zod";
15
+ //#region src/json-schemas.ts
16
+ function jsonSchemas() {
17
+ return {
18
+ book: z.toJSONSchema(BookShape, { io: "input" }),
19
+ bookView: z.toJSONSchema(BookView, { io: "input" }),
20
+ page: z.toJSONSchema(Page, { io: "input" }),
21
+ lexicon: z.toJSONSchema(Lexicon, { io: "input" }),
22
+ imposition: z.toJSONSchema(Imposition, { io: "input" }),
23
+ deck: z.toJSONSchema(DeckShape, { io: "input" }),
24
+ manifest: z.toJSONSchema(Manifest, { io: "input" }),
25
+ publishedShot: z.toJSONSchema(PublishedShot, { io: "input" }),
26
+ board: z.toJSONSchema(Board, { io: "input" }),
27
+ printSetting: z.toJSONSchema(PrintSetting, { io: "input" }),
28
+ printSettingInput: z.toJSONSchema(PrintSettingInput, { io: "input" }),
29
+ slotDeclaration: z.toJSONSchema(SlotDeclaration, { io: "input" }),
30
+ slotDeclarationInput: z.toJSONSchema(SlotDeclarationInput, { io: "input" }),
31
+ fontReference: z.toJSONSchema(FontReference, { io: "input" }),
32
+ fontReferenceInput: z.toJSONSchema(FontReferenceInput, { io: "input" }),
33
+ localFaceTransport: z.toJSONSchema(LocalFaceTransport, { io: "input" }),
34
+ localFacesTransport: z.toJSONSchema(LocalFacesTransport, { io: "input" }),
35
+ motif: z.toJSONSchema(Motif, { io: "input" }),
36
+ motifInput: z.toJSONSchema(MotifInput, { io: "input" }),
37
+ media: z.toJSONSchema(Media, { io: "input" }),
38
+ placement: z.toJSONSchema(PlacementShape, { io: "input" }),
39
+ cover: z.toJSONSchema(Cover, { io: "input" })
40
+ };
41
+ }
42
+ //#endregion
43
+ export { jsonSchemas };
@@ -0,0 +1,152 @@
1
+ import { TextDirection } from "./direction.js";
2
+ import { z } from "zod";
3
+ //#region src/media.d.ts
4
+ export declare const MediaFormat: z.ZodEnum<{
5
+ png: "png";
6
+ jpeg: "jpeg";
7
+ gif: "gif";
8
+ webp: "webp";
9
+ svg: "svg";
10
+ pdf: "pdf";
11
+ ai: "ai";
12
+ }>;
13
+ export type MediaFormat = z.infer<typeof MediaFormat>;
14
+ export declare const MEDIA_FORMATS: Record<MediaFormat, {
15
+ pages: boolean;
16
+ raster: boolean;
17
+ }>;
18
+ export declare const MediaText: z.ZodObject<{
19
+ text: z.ZodString;
20
+ lang: z.ZodOptional<z.ZodString>;
21
+ dir: z.ZodOptional<z.ZodEnum<{
22
+ auto: "auto";
23
+ ltr: "ltr";
24
+ rtl: "rtl";
25
+ }>>;
26
+ }, z.core.$strip>;
27
+ export type MediaText = z.infer<typeof MediaText>;
28
+ export declare function mediaTextDirection(text: MediaText): TextDirection;
29
+ export declare const PageSelector: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
30
+ export type PageSelector = z.infer<typeof PageSelector>;
31
+ export declare const MediaPage: z.ZodObject<{
32
+ name: z.ZodOptional<z.ZodString>;
33
+ boxes: z.ZodObject<{
34
+ media: z.ZodObject<{
35
+ x: z.ZodNumber;
36
+ y: z.ZodNumber;
37
+ width: z.ZodNumber;
38
+ height: z.ZodNumber;
39
+ }, z.core.$strip>;
40
+ crop: z.ZodOptional<z.ZodObject<{
41
+ x: z.ZodNumber;
42
+ y: z.ZodNumber;
43
+ width: z.ZodNumber;
44
+ height: z.ZodNumber;
45
+ }, z.core.$strip>>;
46
+ trim: z.ZodOptional<z.ZodObject<{
47
+ x: z.ZodNumber;
48
+ y: z.ZodNumber;
49
+ width: z.ZodNumber;
50
+ height: z.ZodNumber;
51
+ }, z.core.$strip>>;
52
+ bleed: z.ZodOptional<z.ZodObject<{
53
+ x: z.ZodNumber;
54
+ y: z.ZodNumber;
55
+ width: z.ZodNumber;
56
+ height: z.ZodNumber;
57
+ }, z.core.$strip>>;
58
+ art: z.ZodOptional<z.ZodObject<{
59
+ x: z.ZodNumber;
60
+ y: z.ZodNumber;
61
+ width: z.ZodNumber;
62
+ height: z.ZodNumber;
63
+ }, z.core.$strip>>;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>;
66
+ export type MediaPage = z.infer<typeof MediaPage>;
67
+ export declare const Media: z.ZodObject<{
68
+ format: z.ZodEnum<{
69
+ png: "png";
70
+ jpeg: "jpeg";
71
+ gif: "gif";
72
+ webp: "webp";
73
+ svg: "svg";
74
+ pdf: "pdf";
75
+ ai: "ai";
76
+ }>;
77
+ size: z.ZodObject<{
78
+ width: z.ZodNumber;
79
+ height: z.ZodNumber;
80
+ }, z.core.$strip>;
81
+ pages: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ name: z.ZodOptional<z.ZodString>;
83
+ boxes: z.ZodObject<{
84
+ media: z.ZodObject<{
85
+ x: z.ZodNumber;
86
+ y: z.ZodNumber;
87
+ width: z.ZodNumber;
88
+ height: z.ZodNumber;
89
+ }, z.core.$strip>;
90
+ crop: z.ZodOptional<z.ZodObject<{
91
+ x: z.ZodNumber;
92
+ y: z.ZodNumber;
93
+ width: z.ZodNumber;
94
+ height: z.ZodNumber;
95
+ }, z.core.$strip>>;
96
+ trim: z.ZodOptional<z.ZodObject<{
97
+ x: z.ZodNumber;
98
+ y: z.ZodNumber;
99
+ width: z.ZodNumber;
100
+ height: z.ZodNumber;
101
+ }, z.core.$strip>>;
102
+ bleed: z.ZodOptional<z.ZodObject<{
103
+ x: z.ZodNumber;
104
+ y: z.ZodNumber;
105
+ width: z.ZodNumber;
106
+ height: z.ZodNumber;
107
+ }, z.core.$strip>>;
108
+ art: z.ZodOptional<z.ZodObject<{
109
+ x: z.ZodNumber;
110
+ y: z.ZodNumber;
111
+ width: z.ZodNumber;
112
+ height: z.ZodNumber;
113
+ }, z.core.$strip>>;
114
+ }, z.core.$strip>;
115
+ }, z.core.$strip>>>;
116
+ resolution: z.ZodOptional<z.ZodNumber>;
117
+ alt: z.ZodOptional<z.ZodObject<{
118
+ text: z.ZodString;
119
+ lang: z.ZodOptional<z.ZodString>;
120
+ dir: z.ZodOptional<z.ZodEnum<{
121
+ auto: "auto";
122
+ ltr: "ltr";
123
+ rtl: "rtl";
124
+ }>>;
125
+ }, z.core.$strip>>;
126
+ caption: z.ZodOptional<z.ZodObject<{
127
+ text: z.ZodString;
128
+ lang: z.ZodOptional<z.ZodString>;
129
+ dir: z.ZodOptional<z.ZodEnum<{
130
+ auto: "auto";
131
+ ltr: "ltr";
132
+ rtl: "rtl";
133
+ }>>;
134
+ }, z.core.$strip>>;
135
+ credit: z.ZodOptional<z.ZodObject<{
136
+ text: z.ZodString;
137
+ lang: z.ZodOptional<z.ZodString>;
138
+ dir: z.ZodOptional<z.ZodEnum<{
139
+ auto: "auto";
140
+ ltr: "ltr";
141
+ rtl: "rtl";
142
+ }>>;
143
+ }, z.core.$strip>>;
144
+ derivedFrom: z.ZodOptional<z.ZodObject<{
145
+ address: z.ZodString;
146
+ page: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
147
+ name: z.ZodOptional<z.ZodString>;
148
+ }, z.core.$strip>>;
149
+ }, z.core.$strip>;
150
+ export type Media = z.infer<typeof Media>;
151
+ export type MediaInput = z.input<typeof Media>;
152
+ //#endregion
package/dist/media.js ADDED
@@ -0,0 +1,119 @@
1
+ import { Direction, resolveDirection } from "./direction.js";
2
+ import { Box } from "./geometry.js";
3
+ import { z } from "zod";
4
+ //#region src/media.ts
5
+ const MediaFormat = z.enum([
6
+ "png",
7
+ "jpeg",
8
+ "gif",
9
+ "webp",
10
+ "svg",
11
+ "pdf",
12
+ "ai"
13
+ ]);
14
+ const MEDIA_FORMATS = {
15
+ png: {
16
+ pages: false,
17
+ raster: true
18
+ },
19
+ jpeg: {
20
+ pages: false,
21
+ raster: true
22
+ },
23
+ gif: {
24
+ pages: false,
25
+ raster: true
26
+ },
27
+ webp: {
28
+ pages: false,
29
+ raster: true
30
+ },
31
+ svg: {
32
+ pages: false,
33
+ raster: false
34
+ },
35
+ pdf: {
36
+ pages: true,
37
+ raster: false
38
+ },
39
+ ai: {
40
+ pages: true,
41
+ raster: false
42
+ }
43
+ };
44
+ const MediaText = z.object({
45
+ text: z.string().min(1),
46
+ lang: z.string().optional(),
47
+ dir: Direction.optional()
48
+ });
49
+ function mediaTextDirection(text) {
50
+ return resolveDirection(text.dir, text.lang, text.text);
51
+ }
52
+ const PageSelector = z.union([z.string().trim().min(1), z.number().int().positive()]);
53
+ const PageBox = Box.superRefine((box, ctx) => {
54
+ if (box.width <= 0) ctx.addIssue({
55
+ code: "custom",
56
+ path: ["width"],
57
+ message: "box width must be positive; pass a positive width to clear this refusal"
58
+ });
59
+ if (box.height <= 0) ctx.addIssue({
60
+ code: "custom",
61
+ path: ["height"],
62
+ message: "box height must be positive; pass a positive height to clear this refusal"
63
+ });
64
+ });
65
+ const PAGE_BOXES = [
66
+ "media",
67
+ "crop",
68
+ "trim",
69
+ "bleed",
70
+ "art"
71
+ ];
72
+ const PageBoxName = z.enum(PAGE_BOXES);
73
+ const MediaPageBoxesShape = {
74
+ media: PageBox,
75
+ crop: PageBox.optional(),
76
+ trim: PageBox.optional(),
77
+ bleed: PageBox.optional(),
78
+ art: PageBox.optional()
79
+ };
80
+ const MediaPage = z.object({
81
+ name: z.string().min(1).optional(),
82
+ boxes: z.object(MediaPageBoxesShape)
83
+ });
84
+ const Media = z.object({
85
+ format: MediaFormat,
86
+ size: z.object({
87
+ width: z.number().positive("size.width could not be accepted; pass a positive width to clear this refusal"),
88
+ height: z.number().positive("size.height could not be accepted; pass a positive height to clear this refusal")
89
+ }),
90
+ pages: z.array(MediaPage).optional(),
91
+ resolution: z.number().positive("resolution could not be accepted; pass a positive resolution to clear this refusal").optional(),
92
+ alt: MediaText.optional(),
93
+ caption: MediaText.optional(),
94
+ credit: MediaText.optional(),
95
+ derivedFrom: z.object({
96
+ address: z.string().min(1),
97
+ page: PageSelector,
98
+ name: z.string().min(1).optional()
99
+ }).optional()
100
+ }).superRefine((media, ctx) => {
101
+ const capabilities = MEDIA_FORMATS[media.format];
102
+ if (media.pages !== void 0 && !capabilities.pages) ctx.addIssue({
103
+ code: "custom",
104
+ path: ["pages"],
105
+ message: `pages could not be accepted for ${media.format}; remove pages or use a format with pages to clear this refusal`
106
+ });
107
+ if (media.resolution !== void 0 && !capabilities.raster) ctx.addIssue({
108
+ code: "custom",
109
+ path: ["resolution"],
110
+ message: `resolution could not be accepted for ${media.format}; remove resolution or use a raster format to clear this refusal`
111
+ });
112
+ if (media.derivedFrom !== void 0 && capabilities.pages) ctx.addIssue({
113
+ code: "custom",
114
+ path: ["derivedFrom"],
115
+ message: `derivedFrom could not be accepted for ${media.format}; remove derivedFrom or use a format without pages to clear this refusal`
116
+ });
117
+ });
118
+ //#endregion
119
+ export { MEDIA_FORMATS, Media, MediaFormat, MediaPage, MediaText, PAGE_BOXES, PageBoxName, PageSelector, mediaTextDirection };
@@ -3,14 +3,14 @@ import { z } from "zod";
3
3
  //#region src/note-series.d.ts
4
4
  export declare const NotePlacement: z.ZodEnum<{
5
5
  page: "page";
6
- chapter: "chapter";
7
6
  book: "book";
7
+ chapter: "chapter";
8
8
  part: "part";
9
9
  }>;
10
10
  export type NotePlacement = z.infer<typeof NotePlacement>;
11
11
  export declare const NoteNumbering: z.ZodEnum<{
12
- chapter: "chapter";
13
12
  book: "book";
13
+ chapter: "chapter";
14
14
  part: "part";
15
15
  }>;
16
16
  export type NoteNumbering = z.infer<typeof NoteNumbering>;
@@ -18,13 +18,13 @@ export declare const NoteSeries: z.ZodObject<{
18
18
  name: z.ZodString;
19
19
  placement: z.ZodOptional<z.ZodEnum<{
20
20
  page: "page";
21
- chapter: "chapter";
22
21
  book: "book";
22
+ chapter: "chapter";
23
23
  part: "part";
24
24
  }>>;
25
25
  numbering: z.ZodOptional<z.ZodEnum<{
26
- chapter: "chapter";
27
26
  book: "book";
27
+ chapter: "chapter";
28
28
  part: "part";
29
29
  }>>;
30
30
  marker: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
@@ -134,11 +134,6 @@ function noteSeriesIssues(series, mode) {
134
134
  message: `note series ${item.name} uses ${item.placement} placement only available in paginated mode; use page or book placement, or paginated mode`
135
135
  });
136
136
  });
137
- const page = series.filter(({ placement }) => placement === "page");
138
- if (page.length > 1) issues.push({
139
- path: ["notes"],
140
- message: `note series ${page.map(({ name }) => name).join(" and ")} are both page-placed; declare one page-placed series`
141
- });
142
137
  return issues;
143
138
  }
144
139
  function noteMarkerIssues(series, used) {
package/dist/page.d.ts ADDED
@@ -0,0 +1,174 @@
1
+ import { z } from "zod";
2
+ //#region src/page.d.ts
3
+ export declare const FLUID_WIDTH = 1024;
4
+ export declare const PageSize: z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
5
+ width: z.ZodNumber;
6
+ height: z.ZodNumber;
7
+ }, z.core.$strip>, z.ZodObject<{
8
+ width: z.ZodNumber;
9
+ height: z.ZodLiteral<"auto">;
10
+ }, z.core.$strip>]>;
11
+ export type PageSize = z.infer<typeof PageSize>;
12
+ export declare const Page: z.ZodObject<{
13
+ id: z.ZodOptional<z.ZodString>;
14
+ html: z.ZodString;
15
+ size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
16
+ width: z.ZodNumber;
17
+ height: z.ZodNumber;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ width: z.ZodNumber;
20
+ height: z.ZodLiteral<"auto">;
21
+ }, z.core.$strip>]>>;
22
+ scripts: z.ZodDefault<z.ZodEnum<{
23
+ refuse: "refuse";
24
+ sandboxed: "sandboxed";
25
+ }>>;
26
+ dir: z.ZodOptional<z.ZodEnum<{
27
+ auto: "auto";
28
+ ltr: "ltr";
29
+ rtl: "rtl";
30
+ }>>;
31
+ lang: z.ZodOptional<z.ZodString>;
32
+ print: z.ZodOptional<z.ZodObject<{
33
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
34
+ letter: "letter";
35
+ legal: "legal";
36
+ tabloid: "tabloid";
37
+ a3: "a3";
38
+ a4: "a4";
39
+ a5: "a5";
40
+ "business-card-us": "business-card-us";
41
+ "business-card-eu": "business-card-eu";
42
+ "business-card-square-us": "business-card-square-us";
43
+ "business-card-slim-us": "business-card-slim-us";
44
+ "postcard-4x6": "postcard-4x6";
45
+ "postcard-5x7": "postcard-5x7";
46
+ "postcard-6x9": "postcard-6x9";
47
+ "postcard-6x11": "postcard-6x11";
48
+ "card-square-4in": "card-square-4in";
49
+ "half-letter": "half-letter";
50
+ a6: "a6";
51
+ dl: "dl";
52
+ "rack-card-4x9": "rack-card-4x9";
53
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
54
+ "poster-12x18": "poster-12x18";
55
+ "poster-16x20": "poster-16x20";
56
+ "poster-18x24": "poster-18x24";
57
+ "poster-24x36": "poster-24x36";
58
+ a2: "a2";
59
+ a1: "a1";
60
+ a0: "a0";
61
+ }>, z.ZodObject<{
62
+ width: z.ZodNumber;
63
+ height: z.ZodNumber;
64
+ unit: z.ZodEnum<{
65
+ mm: "mm";
66
+ in: "in";
67
+ pt: "pt";
68
+ }>;
69
+ }, z.core.$strip>]>;
70
+ orientation: z.ZodDefault<z.ZodEnum<{
71
+ portrait: "portrait";
72
+ landscape: "landscape";
73
+ }>>;
74
+ margin: z.ZodOptional<z.ZodObject<{
75
+ top: z.ZodDefault<z.ZodNumber>;
76
+ right: z.ZodDefault<z.ZodNumber>;
77
+ bottom: z.ZodDefault<z.ZodNumber>;
78
+ left: z.ZodDefault<z.ZodNumber>;
79
+ }, z.core.$strip>>;
80
+ bleed: z.ZodDefault<z.ZodNumber>;
81
+ safe: z.ZodDefault<z.ZodNumber>;
82
+ marks: z.ZodDefault<z.ZodBoolean>;
83
+ markColor: z.ZodDefault<z.ZodEnum<{
84
+ black: "black";
85
+ registration: "registration";
86
+ }>>;
87
+ }, z.core.$strip>>;
88
+ printedPages: z.ZodOptional<z.ZodObject<{
89
+ parents: z.ZodArray<z.ZodObject<{
90
+ name: z.ZodString;
91
+ basedOn: z.ZodOptional<z.ZodString>;
92
+ margin: z.ZodOptional<z.ZodObject<{
93
+ top: z.ZodNumber;
94
+ bottom: z.ZodNumber;
95
+ inner: z.ZodNumber;
96
+ outer: z.ZodNumber;
97
+ }, z.core.$strip>>;
98
+ head: z.ZodOptional<z.ZodString>;
99
+ foot: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>>;
101
+ rules: z.ZodPipe<z.ZodObject<{
102
+ every: z.ZodString;
103
+ first: z.ZodOptional<z.ZodString>;
104
+ recto: z.ZodOptional<z.ZodString>;
105
+ verso: z.ZodOptional<z.ZodString>;
106
+ last: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$loose>, z.ZodTransform<{
108
+ last?: string | undefined;
109
+ verso?: string | undefined;
110
+ recto?: string | undefined;
111
+ first?: string | undefined;
112
+ every: string;
113
+ }, {
114
+ [x: string]: unknown;
115
+ every: string;
116
+ first?: string | undefined;
117
+ recto?: string | undefined;
118
+ verso?: string | undefined;
119
+ last?: string | undefined;
120
+ }>>;
121
+ numbering: z.ZodOptional<z.ZodEnum<{
122
+ arabic: "arabic";
123
+ "roman-lower": "roman-lower";
124
+ "roman-upper": "roman-upper";
125
+ hebrew: "hebrew";
126
+ }>>;
127
+ }, z.core.$strip>>;
128
+ slots: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
129
+ key: z.ZodString;
130
+ label: z.ZodString;
131
+ type: z.ZodEnum<{
132
+ text: "text";
133
+ image: "image";
134
+ phone: "phone";
135
+ email: "email";
136
+ link: "link";
137
+ qr: "qr";
138
+ }>;
139
+ required: z.ZodDefault<z.ZodBoolean>;
140
+ placeholder: z.ZodOptional<z.ZodString>;
141
+ overflow: z.ZodDefault<z.ZodEnum<{
142
+ refuse: "refuse";
143
+ shrink: "shrink";
144
+ truncate: "truncate";
145
+ wrap: "wrap";
146
+ }>>;
147
+ minSize: z.ZodOptional<z.ZodNumber>;
148
+ }, z.core.$strip>, z.ZodTransform<{
149
+ key: string;
150
+ label: string;
151
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
152
+ required: boolean;
153
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
154
+ placeholder?: string | undefined;
155
+ minSize?: number | undefined;
156
+ }, {
157
+ key: string;
158
+ label: string;
159
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
160
+ required: boolean;
161
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
162
+ placeholder?: string | undefined;
163
+ minSize?: number | undefined;
164
+ }>>>>;
165
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
166
+ app: z.ZodString;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ local: z.ZodString;
169
+ fallback: z.ZodString;
170
+ }, z.core.$strip>]>>>;
171
+ }, z.core.$strip>;
172
+ export type Page = z.infer<typeof Page>;
173
+ export type PageInput = z.input<typeof Page>;
174
+ //#endregion
package/dist/page.js ADDED
@@ -0,0 +1,37 @@
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 FLUID_WIDTH = 1024;
11
+ const PageSize = z.union([
12
+ z.literal("fluid"),
13
+ Size,
14
+ z.object({
15
+ width: z.number().int().positive(),
16
+ height: z.literal("auto")
17
+ })
18
+ ]);
19
+ const Page = z.object({
20
+ id: z.string().optional(),
21
+ html: z.string(),
22
+ size: PageSize.default("fluid"),
23
+ scripts: Scripts.default("refuse"),
24
+ dir: Direction.optional(),
25
+ lang: z.string().optional(),
26
+ print: Print.optional(),
27
+ printedPages: PrintedPages.optional(),
28
+ slots: Slots.optional(),
29
+ fonts: z.array(FontReference).optional()
30
+ }).superRefine((page, ctx) => {
31
+ for (const issue of pagePrintedPagesIssues(page)) ctx.addIssue({
32
+ code: "custom",
33
+ ...issue
34
+ });
35
+ });
36
+ //#endregion
37
+ export { FLUID_WIDTH, Page, PageSize };
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"];
@@ -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 };