@segnavia/format 0.39.0 → 0.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cover.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { Page, PageBody } from "./page.js";
1
2
  import { Motif } from "./motif.js";
2
- import { Page } from "./page.js";
3
3
  import { z } from "zod";
4
4
  //#region src/cover.d.ts
5
5
  export declare const COVER_SHEET: {
@@ -8,14 +8,23 @@ export declare const COVER_SHEET: {
8
8
  };
9
9
  export declare const COVER_DRAWING_VERSION = 1;
10
10
  export declare const Cover: z.ZodPipe<z.ZodObject<{
11
- page: z.ZodObject<{
11
+ page: z.ZodPipe<z.ZodObject<{
12
12
  id: z.ZodOptional<z.ZodString>;
13
- html: z.ZodString;
14
- size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
13
+ body: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
14
+ html: z.ZodString;
15
+ }, z.core.$strict>, z.ZodObject<{
16
+ markdown: z.ZodString;
17
+ }, z.core.$strict>]>>;
18
+ html: z.ZodOptional<z.ZodString>;
19
+ markdown: z.ZodOptional<z.ZodString>;
20
+ size: z.ZodDefault<z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
21
+ readonly width: "full";
22
+ readonly height: "auto";
23
+ }, "fluid">>, z.ZodObject<{
15
24
  width: z.ZodNumber;
16
25
  height: z.ZodNumber;
17
26
  }, z.core.$strip>, z.ZodObject<{
18
- width: z.ZodNumber;
27
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
19
28
  height: z.ZodLiteral<"auto">;
20
29
  }, z.core.$strip>]>>;
21
30
  scripts: z.ZodDefault<z.ZodEnum<{
@@ -167,7 +176,155 @@ export declare const Cover: z.ZodPipe<z.ZodObject<{
167
176
  local: z.ZodString;
168
177
  fallback: z.ZodString;
169
178
  }, z.core.$strip>]>>>;
170
- }, z.core.$strip>;
179
+ }, z.core.$strip>, z.ZodTransform<{
180
+ body: PageBody;
181
+ size: {
182
+ readonly width: "full";
183
+ readonly height: "auto";
184
+ } | {
185
+ width: number;
186
+ height: number;
187
+ } | {
188
+ width: number | "full" | "standard" | "wide";
189
+ height: "auto";
190
+ };
191
+ scripts: "refuse" | "sandboxed";
192
+ id?: string | undefined;
193
+ dir?: "auto" | "ltr" | "rtl" | undefined;
194
+ lang?: string | undefined;
195
+ print?: {
196
+ 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" | {
197
+ width: number;
198
+ height: number;
199
+ unit: "mm" | "in" | "pt";
200
+ };
201
+ orientation: "portrait" | "landscape";
202
+ bleed: number;
203
+ safe: number;
204
+ marks: boolean;
205
+ markColor: "black" | "registration";
206
+ margin?: {
207
+ top: number;
208
+ right: number;
209
+ bottom: number;
210
+ left: number;
211
+ } | undefined;
212
+ } | undefined;
213
+ printedPages?: {
214
+ parents: {
215
+ name: string;
216
+ basedOn?: string | undefined;
217
+ margin?: {
218
+ top: number;
219
+ bottom: number;
220
+ inner: number;
221
+ outer: number;
222
+ } | undefined;
223
+ head?: string | undefined;
224
+ foot?: string | undefined;
225
+ }[];
226
+ rules: {
227
+ last?: string | undefined;
228
+ verso?: string | undefined;
229
+ recto?: string | undefined;
230
+ first?: string | undefined;
231
+ every: string;
232
+ };
233
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
234
+ } | undefined;
235
+ slots?: {
236
+ key: string;
237
+ label: string;
238
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
239
+ required: boolean;
240
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
241
+ placeholder?: string | undefined;
242
+ minSize?: number | undefined;
243
+ }[] | undefined;
244
+ fonts?: ({
245
+ app: string;
246
+ } | {
247
+ local: string;
248
+ fallback: string;
249
+ })[] | undefined;
250
+ }, {
251
+ size: {
252
+ readonly width: "full";
253
+ readonly height: "auto";
254
+ } | {
255
+ width: number;
256
+ height: number;
257
+ } | {
258
+ width: number | "full" | "standard" | "wide";
259
+ height: "auto";
260
+ };
261
+ scripts: "refuse" | "sandboxed";
262
+ id?: string | undefined;
263
+ body?: {
264
+ html: string;
265
+ } | {
266
+ markdown: string;
267
+ } | undefined;
268
+ html?: string | undefined;
269
+ markdown?: string | undefined;
270
+ dir?: "auto" | "ltr" | "rtl" | undefined;
271
+ lang?: string | undefined;
272
+ print?: {
273
+ 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" | {
274
+ width: number;
275
+ height: number;
276
+ unit: "mm" | "in" | "pt";
277
+ };
278
+ orientation: "portrait" | "landscape";
279
+ bleed: number;
280
+ safe: number;
281
+ marks: boolean;
282
+ markColor: "black" | "registration";
283
+ margin?: {
284
+ top: number;
285
+ right: number;
286
+ bottom: number;
287
+ left: number;
288
+ } | undefined;
289
+ } | undefined;
290
+ printedPages?: {
291
+ parents: {
292
+ name: string;
293
+ basedOn?: string | undefined;
294
+ margin?: {
295
+ top: number;
296
+ bottom: number;
297
+ inner: number;
298
+ outer: number;
299
+ } | undefined;
300
+ head?: string | undefined;
301
+ foot?: string | undefined;
302
+ }[];
303
+ rules: {
304
+ last?: string | undefined;
305
+ verso?: string | undefined;
306
+ recto?: string | undefined;
307
+ first?: string | undefined;
308
+ every: string;
309
+ };
310
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
311
+ } | undefined;
312
+ slots?: {
313
+ key: string;
314
+ label: string;
315
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
316
+ required: boolean;
317
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
318
+ placeholder?: string | undefined;
319
+ minSize?: number | undefined;
320
+ }[] | undefined;
321
+ fonts?: ({
322
+ app: string;
323
+ } | {
324
+ local: string;
325
+ fallback: string;
326
+ })[] | undefined;
327
+ }>>;
171
328
  id: z.ZodOptional<z.ZodString>;
172
329
  name: z.ZodOptional<z.ZodString>;
173
330
  }, z.core.$strip>, z.ZodTransform<{
@@ -190,12 +347,15 @@ export declare const Cover: z.ZodPipe<z.ZodObject<{
190
347
  left: number;
191
348
  } | undefined;
192
349
  };
193
- html: string;
194
- size: "fluid" | {
350
+ body: PageBody;
351
+ size: {
352
+ readonly width: "full";
353
+ readonly height: "auto";
354
+ } | {
195
355
  width: number;
196
356
  height: number;
197
357
  } | {
198
- width: number;
358
+ width: number | "full" | "standard" | "wide";
199
359
  height: "auto";
200
360
  };
201
361
  scripts: "refuse" | "sandboxed";
@@ -244,12 +404,15 @@ export declare const Cover: z.ZodPipe<z.ZodObject<{
244
404
  name?: string | undefined;
245
405
  }, {
246
406
  page: {
247
- html: string;
248
- size: "fluid" | {
407
+ body: PageBody;
408
+ size: {
409
+ readonly width: "full";
410
+ readonly height: "auto";
411
+ } | {
249
412
  width: number;
250
413
  height: number;
251
414
  } | {
252
- width: number;
415
+ width: number | "full" | "standard" | "wide";
253
416
  height: "auto";
254
417
  };
255
418
  scripts: "refuse" | "sandboxed";
@@ -1,4 +1,4 @@
1
- import { Page } from "./page.js";
1
+ import { Page, PageWidths } from "./page.js";
2
2
  import { Print } from "./print.js";
3
3
  import { PaperBox } from "./paper.js";
4
4
  import { Imposition } from "./imposition-schema.js";
@@ -59,6 +59,6 @@ export declare function impose(imposition: Imposition, pageCount: number): Impos
59
59
  export declare function fitPage(page: {
60
60
  size: Page['size'];
61
61
  print?: Print;
62
- }, placement: ImpositionPlacement, fit: 'contain' | 'cover'): PageFit;
62
+ }, placement: ImpositionPlacement, fit: 'contain' | 'cover', pageWidths?: PageWidths): PageFit;
63
63
  export declare function pagePlacementLayout(size: Page['size'], placement: ImpositionPlacement, fit: PageFit): PagePlacementLayout;
64
64
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { PX_PER_MM, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
2
+ import { resolvePageWidth } from "./page.js";
2
3
  import { foldCellPages, foldPageCountMessage } from "./fold.js";
3
4
  //#region src/imposition.ts
4
5
  const zeroCrop = () => ({
@@ -225,46 +226,56 @@ function trimDiffers(page, placement) {
225
226
  const trim = sheetMm(page.print);
226
227
  return Math.abs(trim.width - placement.trim.width) > .01 || Math.abs(trim.height - placement.trim.height) > .01;
227
228
  }
228
- function fitPage(page, placement, fit) {
229
+ function fitPage(page, placement, fit, pageWidths) {
229
230
  const differs = trimDiffers(page, placement);
230
- if (page.size === "fluid") return {
231
- flow: true,
232
- width: placement.bleedBox.width * PX_PER_MM,
233
- height: null,
234
- scale: 1,
235
- x: placement.bleedBox.x,
236
- y: placement.bleedBox.y,
237
- bands: {
238
- inline: 0,
239
- block: 0
240
- },
241
- crop: zeroCrop(),
242
- differs
243
- };
244
- if (page.size.height === "auto") return {
245
- flow: true,
246
- width: page.size.width,
247
- height: null,
248
- scale: placement.trim.width * PX_PER_MM / page.size.width,
249
- x: placement.trim.x,
250
- y: placement.trim.y,
251
- bands: {
252
- inline: 0,
253
- block: 0
254
- },
255
- crop: zeroCrop(),
256
- differs
257
- };
231
+ const size = page.size;
232
+ if (size.height === "auto") {
233
+ const resolved = resolvePageWidth(size, pageWidths);
234
+ if (size.width !== "full") {
235
+ const named = typeof size.width === "string";
236
+ const width = named ? Math.min(resolved.viewportWidth, placement.trim.width * PX_PER_MM) : resolved.viewportWidth;
237
+ const scale = named ? 1 : placement.trim.width * PX_PER_MM / width;
238
+ const inline = named ? (placement.trim.width - width / PX_PER_MM) / 2 : 0;
239
+ return {
240
+ flow: true,
241
+ width,
242
+ height: null,
243
+ scale,
244
+ x: roundMillimeters(placement.trim.x + inline),
245
+ y: placement.trim.y,
246
+ bands: {
247
+ inline: 0,
248
+ block: 0
249
+ },
250
+ crop: zeroCrop(),
251
+ differs
252
+ };
253
+ }
254
+ return {
255
+ flow: true,
256
+ width: placement.bleedBox.width * PX_PER_MM,
257
+ height: null,
258
+ scale: 1,
259
+ x: placement.bleedBox.x,
260
+ y: placement.bleedBox.y,
261
+ bands: {
262
+ inline: 0,
263
+ block: 0
264
+ },
265
+ crop: zeroCrop(),
266
+ differs
267
+ };
268
+ }
258
269
  if (fit === "contain") {
259
- const scale = Math.min(placement.trim.width * PX_PER_MM / page.size.width, placement.trim.height * PX_PER_MM / page.size.height);
260
- const width = page.size.width * scale / PX_PER_MM;
261
- const height = page.size.height * scale / PX_PER_MM;
270
+ const scale = Math.min(placement.trim.width * PX_PER_MM / size.width, placement.trim.height * PX_PER_MM / size.height);
271
+ const width = size.width * scale / PX_PER_MM;
272
+ const height = size.height * scale / PX_PER_MM;
262
273
  const inline = (placement.trim.width - width) / 2;
263
274
  const block = (placement.trim.height - height) / 2;
264
275
  return {
265
276
  flow: false,
266
- width: page.size.width,
267
- height: page.size.height,
277
+ width: size.width,
278
+ height: size.height,
268
279
  scale,
269
280
  x: roundMillimeters(placement.trim.x + inline),
270
281
  y: roundMillimeters(placement.trim.y + block),
@@ -278,15 +289,15 @@ function fitPage(page, placement, fit) {
278
289
  }
279
290
  const horizontalBleed = Math.max(placement.bleed.left, placement.bleed.right);
280
291
  const verticalBleed = Math.max(placement.bleed.top, placement.bleed.bottom);
281
- const scale = Math.max((placement.trim.width + horizontalBleed * 2) * PX_PER_MM / page.size.width, (placement.trim.height + verticalBleed * 2) * PX_PER_MM / page.size.height);
282
- const width = page.size.width * scale / PX_PER_MM;
283
- const height = page.size.height * scale / PX_PER_MM;
292
+ const scale = Math.max((placement.trim.width + horizontalBleed * 2) * PX_PER_MM / size.width, (placement.trim.height + verticalBleed * 2) * PX_PER_MM / size.height);
293
+ const width = size.width * scale / PX_PER_MM;
294
+ const height = size.height * scale / PX_PER_MM;
284
295
  const x = placement.trim.x + (placement.trim.width - width) / 2;
285
296
  const y = placement.trim.y + (placement.trim.height - height) / 2;
286
297
  return {
287
298
  flow: false,
288
- width: page.size.width,
289
- height: page.size.height,
299
+ width: size.width,
300
+ height: size.height,
290
301
  scale,
291
302
  x: roundMillimeters(x),
292
303
  y: roundMillimeters(y),
@@ -304,7 +315,7 @@ function fitPage(page, placement, fit) {
304
315
  };
305
316
  }
306
317
  function pagePlacementLayout(size, placement, fit) {
307
- if (size === "fluid") return {
318
+ if (size.width === "full") return {
308
319
  kind: "fluid",
309
320
  piece: {
310
321
  width: placement.bleedBox.width * PX_PER_MM,
@@ -316,14 +327,14 @@ function pagePlacementLayout(size, placement, fit) {
316
327
  if (size.height === "auto") return {
317
328
  kind: "growing",
318
329
  piece: {
319
- width: size.width,
330
+ width: fit.width,
320
331
  height: placement.trim.height * PX_PER_MM / fit.scale
321
332
  },
322
333
  inset: false,
323
334
  paper: {
324
335
  x: fit.x,
325
336
  y: fit.y,
326
- width: placement.trim.width,
337
+ width: fit.width * fit.scale / PX_PER_MM,
327
338
  height: placement.trim.height
328
339
  }
329
340
  };
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@ import { BOOK_PARENT_NAMES, FlowingParentNames, PRINTED_PAGE_LIMIT, PRINTED_PAGE
14
14
  import { BookChapterEntry, BookContents, BookDivision, BookDivisions, BookFrontMatterEntry, BookItem, BookOpens, BookSection, BookSectionEntry, BookSectionParents, BookTemplate, Chapter, DesignedPage, DesignedSection, MAX_PART_DEPTH, Part, PlacedSection, REGION_NAME, TemplatedPage, TemplatedSection, bookSections, isBookContents, isChapter, isDesignedSection, isPart, isPlacedSection, isTemplatedSection } from "./book-section.js";
15
15
  import { Book, BookInput, BookMode, BookPage, BookRunningHead, BookRunningHeadSource, BookView, BookViewInput, BookViewPagination, resolveBookPagination } from "./book.js";
16
16
  import "./book-exports.js";
17
+ import { FULL_PAGE_SIZE, FlowingWidth, PAGE_WIDTHS, Page, PageBody, PageInput, PageSize, PageWidths, ResolvedPageWidth, resolvePageWidth } from "./page.js";
17
18
  import { BOOK_FURNITURE, BookFurniture, LIBRARY_MOTIF_PREFIX, MOTIF_ATTRIBUTE, Motif, MotifField, MotifFieldInput, MotifInput, MotifPlacement, MotifSource, MotifVersion, MotifVersionChoice, MotifVersionInput, PRINTED_PAGE_CONTEXT, PRINTED_PAGE_FOLIO_PATH, PRINTED_PAGE_NUMBER_PATH, PRINTED_PAGE_RUNNING_HEAD_PATH, PRINTED_PAGE_TOTAL_PATH, chooseMotifVersion, motifFieldAttribute } from "./motif.js";
18
- import { FLUID_WIDTH, Page, PageInput, PageSize } from "./page.js";
19
19
  import { COVER_DRAWING_VERSION, COVER_SHEET, Cover, CoverDigestMaterial, CoverInput, coverDigest, digestCoverMaterial } from "./cover.js";
20
20
  import { DeckFromSlidesOptions, SlideRow, deckFromSlides } from "./deck-from-slides.js";
21
21
  import { DependencyDecision, dependencyDecision, dependencyOriginSet, originSet } from "./dependency-policy.js";
@@ -45,4 +45,4 @@ import { ShotUse, shotsUsed } from "./shots-used.js";
45
45
  import { Fill, FillValues, SLOT_TYPES, SlotDeclaration, SlotDeclarationInput, SlotKey, SlotReport, SlotSource, SlotState, SlotType, SlotValue, Slots, SlotsInput, SlotsOptions, mergeSlotDeclarations } from "./slots.js";
46
46
  import { MAX_SLIDE_TIMING_MS } from "./timing.js";
47
47
  import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition, TransitionInput } from "./transition.js";
48
- export { APP_FONT_NAME, APP_FONT_NAME_MESSAGE, Annotation, type AppFont, type ArrangeOptions, AssetKind, BOOK_FURNITURE, BOOK_PARENT_NAMES, Board, type BoardInput, BoardItem, type BoardItemAnchor, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookChapterEntry, BookContents, type BookDivision, type BookDivisions, BookFrontMatterEntry, BookFurniture, type BookInput, BookItem, BookMode, BookOpens, BookPage, BookRunningHead, BookRunningHeadSource, BookSection, type BookSectionEntry, BookSectionParents, BookTemplate, BookView, type BookViewInput, BookViewPagination, Box, COLLECTION_TAG, COVER_DRAWING_VERSION, COVER_SHEET, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cover, type CoverDigestMaterial, type CoverInput, CropEdge, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, type DependencyDecision, DesignedPage, DesignedSection, Direction, type ExtractedFontFace, FLUID_WIDTH, FOLD_DASH_OFF_MM, FOLD_DASH_ON_MM, FOLD_KINDS, FOLD_TUCK_IN_MM, FONT_FORMATS, FONT_GENERICS, Fill, FillValues, FlowingParentNames, type FoldKind, type FontFace, FontFaceRefusedError, type FontFormat, type FontGeneric, FontReference, FontReferenceInput, type FontSource, GridCell, type GridDropTarget, ImageFit, type Imposed, Imposition, type ImpositionInput, type ImpositionMarkEdge, type ImpositionPlacement, type ImpositionSideMarks, LIBRARY_MOTIF_PREFIX, LOCAL_FONT_LIMITS, Lexicon, LocalFaceTransport, type LocalFacesInput, LocalFacesTransport, type LocalFontLimitFace, type LocalFontLimits, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_PART_DEPTH, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MEDIA_FORMATS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_MARK_LENGTH_MM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, MOTIF_ATTRIBUTE, Manifest, Margin, MarkColor, type MarkSegment, Media, MediaFormat, type MediaInput, MediaPage, MediaText, type MillimeterEdges, Motif, MotifField, MotifFieldInput, MotifInput, MotifPlacement, MotifSource, MotifVersion, MotifVersionChoice, MotifVersionInput, NAMED_PAPERS, type NamedPaper, type NamedPaperMetadata, Narration, NoteMarker, NoteNumbering, NotePlacement, NoteSeries, type NoteSeriesInput, NumberSystem, ORIENTATIONS, type OmittedImpositionMark, Orientation, PAPER_FIT_TOLERANCE_MM, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLACEMENT_ACCEPTS, PLAYBACK_MODES, PRINTED_PAGE_CONTEXT, PRINTED_PAGE_FOLIO_PATH, PRINTED_PAGE_LIMIT, PRINTED_PAGE_NUMBER_PATH, PRINTED_PAGE_ROLES, PRINTED_PAGE_RUNNING_HEAD_PATH, PRINTED_PAGE_TOTAL_PATH, PX_PER_MM, PX_PER_PT, Page, type PageFit, type PageInput, type PagePlacementKind, type PagePlacementLayout, PageSelector, PageSize, Paper, type PaperBox, type PaperGroup, PaperUnit, ParentPage, ParentPageMargin, Part, PlacedSection, Placement, type PlacementContainer, PlacementCrop, type PlacementGraph, type PlacementInput, PlacementRefusedError, Playback, type PlaybackMode, Point, Print, type PrintInput, PrintSetting, PrintSettingInput, PrintedPageRole, PrintedPageRules, PrintedPages, PronunciationEntry, PublishedShot, REGION_NAME, type ResolvedFontFace, type ResolvedNoteSeries, ResolvedParentPage, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, SLOT_TYPES, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, SlotDeclaration, SlotDeclarationInput, SlotKey, SlotReport, SlotSource, SlotState, SlotType, SlotValue, Slots, SlotsInput, SlotsOptions, TemplatedPage, TemplatedSection, TextArea, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, bookParentPages, bookSections, checkPlacementCycles, chooseMotifVersion, classifyFont, collectionFaces, coverDigest, deckFromSlides, defaultPageNumbering, dependencyDecision, dependencyOriginSet, deriveSectionCells, digestCoverMaterial, exceedsLimits, extractFace, findPlacementCycle, firstStrongDirection, fitPage, fitSection, fitTouchedSections, flowingParentNames, foldCellPages, foldColumns, foldForSearch, foldPageCountMessage, foldPanelMap, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, impositionMarks, insertIntoGrid, isBookContents, isChapter, isDesignedSection, isHebrew, isPart, isPlacedSection, isPrintedPageIdentityImposition, isTemplatedSection, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, localFontLimitRefusal, localFontReferences, makeRoom, mediaTextDirection, mergeSlotDeclarations, mirrorPlacement, motifFieldAttribute, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, originSet, pagePlacementLayout, pagePrintedPagesIssues, paperPixels, parentListIssues, parsePlayback, printBoxes, printPadding, printProperties, printedPagesIssues, removeFromGrid, removeItems, resizeItem, resolveBookPagination, resolveDirection, resolveFontFace, resolveNoteSeries, resolveParentPages, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, textArea, textDirection, toMillimeters, visibleItems, zoomAt, zoomToFit };
48
+ export { APP_FONT_NAME, APP_FONT_NAME_MESSAGE, Annotation, type AppFont, type ArrangeOptions, AssetKind, BOOK_FURNITURE, BOOK_PARENT_NAMES, Board, type BoardInput, BoardItem, type BoardItemAnchor, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookChapterEntry, BookContents, type BookDivision, type BookDivisions, BookFrontMatterEntry, BookFurniture, type BookInput, BookItem, BookMode, BookOpens, BookPage, BookRunningHead, BookRunningHeadSource, BookSection, type BookSectionEntry, BookSectionParents, BookTemplate, BookView, type BookViewInput, BookViewPagination, Box, COLLECTION_TAG, COVER_DRAWING_VERSION, COVER_SHEET, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cover, type CoverDigestMaterial, type CoverInput, CropEdge, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, type DependencyDecision, DesignedPage, DesignedSection, Direction, type ExtractedFontFace, FOLD_DASH_OFF_MM, FOLD_DASH_ON_MM, FOLD_KINDS, FOLD_TUCK_IN_MM, FONT_FORMATS, FONT_GENERICS, FULL_PAGE_SIZE, Fill, FillValues, FlowingParentNames, FlowingWidth, type FoldKind, type FontFace, FontFaceRefusedError, type FontFormat, type FontGeneric, FontReference, FontReferenceInput, type FontSource, GridCell, type GridDropTarget, ImageFit, type Imposed, Imposition, type ImpositionInput, type ImpositionMarkEdge, type ImpositionPlacement, type ImpositionSideMarks, LIBRARY_MOTIF_PREFIX, LOCAL_FONT_LIMITS, Lexicon, LocalFaceTransport, type LocalFacesInput, LocalFacesTransport, type LocalFontLimitFace, type LocalFontLimits, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_PART_DEPTH, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MEDIA_FORMATS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_MARK_LENGTH_MM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, MOTIF_ATTRIBUTE, Manifest, Margin, MarkColor, type MarkSegment, Media, MediaFormat, type MediaInput, MediaPage, MediaText, type MillimeterEdges, Motif, MotifField, MotifFieldInput, MotifInput, MotifPlacement, MotifSource, MotifVersion, MotifVersionChoice, MotifVersionInput, NAMED_PAPERS, type NamedPaper, type NamedPaperMetadata, Narration, NoteMarker, NoteNumbering, NotePlacement, NoteSeries, type NoteSeriesInput, NumberSystem, ORIENTATIONS, type OmittedImpositionMark, Orientation, PAGE_WIDTHS, PAPER_FIT_TOLERANCE_MM, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLACEMENT_ACCEPTS, PLAYBACK_MODES, PRINTED_PAGE_CONTEXT, PRINTED_PAGE_FOLIO_PATH, PRINTED_PAGE_LIMIT, PRINTED_PAGE_NUMBER_PATH, PRINTED_PAGE_ROLES, PRINTED_PAGE_RUNNING_HEAD_PATH, PRINTED_PAGE_TOTAL_PATH, PX_PER_MM, PX_PER_PT, Page, PageBody, type PageFit, type PageInput, type PagePlacementKind, type PagePlacementLayout, PageSelector, PageSize, PageWidths, Paper, type PaperBox, type PaperGroup, PaperUnit, ParentPage, ParentPageMargin, Part, PlacedSection, Placement, type PlacementContainer, PlacementCrop, type PlacementGraph, type PlacementInput, PlacementRefusedError, Playback, type PlaybackMode, Point, Print, type PrintInput, PrintSetting, PrintSettingInput, PrintedPageRole, PrintedPageRules, PrintedPages, PronunciationEntry, PublishedShot, REGION_NAME, type ResolvedFontFace, type ResolvedNoteSeries, type ResolvedPageWidth, ResolvedParentPage, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, SLOT_TYPES, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, SlotDeclaration, SlotDeclarationInput, SlotKey, SlotReport, SlotSource, SlotState, SlotType, SlotValue, Slots, SlotsInput, SlotsOptions, TemplatedPage, TemplatedSection, TextArea, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, bookParentPages, bookSections, checkPlacementCycles, chooseMotifVersion, classifyFont, collectionFaces, coverDigest, deckFromSlides, defaultPageNumbering, dependencyDecision, dependencyOriginSet, deriveSectionCells, digestCoverMaterial, exceedsLimits, extractFace, findPlacementCycle, firstStrongDirection, fitPage, fitSection, fitTouchedSections, flowingParentNames, foldCellPages, foldColumns, foldForSearch, foldPageCountMessage, foldPanelMap, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, impositionMarks, insertIntoGrid, isBookContents, isChapter, isDesignedSection, isHebrew, isPart, isPlacedSection, isPrintedPageIdentityImposition, isTemplatedSection, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, localFontLimitRefusal, localFontReferences, makeRoom, mediaTextDirection, mergeSlotDeclarations, mirrorPlacement, motifFieldAttribute, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, originSet, pagePlacementLayout, pagePrintedPagesIssues, paperPixels, parentListIssues, parsePlayback, printBoxes, printPadding, printProperties, printedPagesIssues, removeFromGrid, removeItems, resizeItem, resolveBookPagination, resolveDirection, resolveFontFace, resolveNoteSeries, resolvePageWidth, resolveParentPages, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, textArea, textDirection, toMillimeters, visibleItems, zoomAt, zoomToFit };
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ import { NoteNumbering, NotePlacement, NoteSeries, noteMarkerIssues, resolveNote
25
25
  import { CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, FOLD_DASH_OFF_MM, FOLD_DASH_ON_MM, MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, ORIENTATIONS, Orientation, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PX_PER_MM, PX_PER_PT, Paper, PaperUnit, PrintSetting, PrintSettingInput, fromMillimeters, paperPixels, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
26
26
  import { Book, BookMode, BookPage, BookRunningHead, BookRunningHeadSource, BookView, BookViewPagination, resolveBookPagination } from "./book.js";
27
27
  import { Margin, MarkColor, Print } from "./print.js";
28
- import { FLUID_WIDTH, Page, PageSize } from "./page.js";
28
+ import { FULL_PAGE_SIZE, FlowingWidth, PAGE_WIDTHS, Page, PageBody, PageSize, PageWidths, resolvePageWidth } from "./page.js";
29
29
  import { COVER_DRAWING_VERSION, COVER_SHEET, Cover, coverDigest, digestCoverMaterial } from "./cover.js";
30
30
  import { deckFromSlides } from "./deck-from-slides.js";
31
31
  import { dependencyDecision, dependencyOriginSet, originSet } from "./dependency-policy.js";
@@ -44,4 +44,4 @@ import { LOCAL_FONT_LIMITS, localFontLimitRefusal } from "./local-font-limits.js
44
44
  import { checkPlacementCycles, findPlacementCycle } from "./placement-cycle.js";
45
45
  import { isPrintedPageIdentityImposition } from "./printed-page-imposition.js";
46
46
  import { shotsUsed } from "./shots-used.js";
47
- export { APP_FONT_NAME, APP_FONT_NAME_MESSAGE, Annotation, AssetKind, BOOK_FURNITURE, BOOK_PARENT_NAMES, Board, BoardItem, BoardLabel, BoardSection, Book, BookChapterEntry, BookContents, BookFrontMatterEntry, BookItem, BookMode, BookOpens, BookPage, BookRunningHead, BookRunningHeadSource, BookSection, BookSectionParents, BookTemplate, BookView, BookViewPagination, Box, COLLECTION_TAG, COVER_DRAWING_VERSION, COVER_SHEET, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cover, CropEdge, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, DesignedPage, DesignedSection, Direction, FLUID_WIDTH, FOLD_DASH_OFF_MM, FOLD_DASH_ON_MM, FOLD_KINDS, FOLD_TUCK_IN_MM, FONT_FORMATS, FONT_GENERICS, FillValues, FontFaceRefusedError, FontReference, FontReferenceInput, GridCell, ImageFit, Imposition, LIBRARY_MOTIF_PREFIX, LOCAL_FONT_LIMITS, Lexicon, LocalFaceTransport, LocalFacesTransport, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_PART_DEPTH, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MEDIA_FORMATS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_MARK_LENGTH_MM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, MOTIF_ATTRIBUTE, Manifest, Margin, MarkColor, Media, MediaFormat, MediaPage, MediaText, Motif, MotifField, MotifFieldInput, MotifInput, MotifVersion, MotifVersionInput, NAMED_PAPERS, Narration, NoteMarker, NoteNumbering, NotePlacement, NoteSeries, NumberSystem, ORIENTATIONS, Orientation, PAPER_FIT_TOLERANCE_MM, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLACEMENT_ACCEPTS, PLAYBACK_MODES, PRINTED_PAGE_CONTEXT, PRINTED_PAGE_FOLIO_PATH, PRINTED_PAGE_LIMIT, PRINTED_PAGE_NUMBER_PATH, PRINTED_PAGE_ROLES, PRINTED_PAGE_RUNNING_HEAD_PATH, PRINTED_PAGE_TOTAL_PATH, PX_PER_MM, PX_PER_PT, Page, PageSelector, PageSize, Paper, PaperUnit, ParentPage, ParentPageMargin, Part, PlacedSection, Placement, PlacementCrop, PlacementRefusedError, Playback, Point, Print, PrintSetting, PrintSettingInput, PrintedPageRules, PrintedPages, PronunciationEntry, PublishedShot, REGION_NAME, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, SLOT_TYPES, Scripts, Shot, Size, Slide, SlideContent, SlotDeclaration, SlotDeclarationInput, SlotKey, SlotType, SlotValue, Slots, SlotsInput, TemplatedPage, TemplatedSection, TextDirection, Transition, Word, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, bookParentPages, bookSections, checkPlacementCycles, chooseMotifVersion, classifyFont, collectionFaces, coverDigest, deckFromSlides, defaultPageNumbering, dependencyDecision, dependencyOriginSet, deriveSectionCells, digestCoverMaterial, exceedsLimits, extractFace, findPlacementCycle, firstStrongDirection, fitPage, fitSection, fitTouchedSections, flowingParentNames, foldCellPages, foldColumns, foldForSearch, foldPageCountMessage, foldPanelMap, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, impositionMarks, insertIntoGrid, isBookContents, isChapter, isDesignedSection, isHebrew, isPart, isPlacedSection, isPrintedPageIdentityImposition, isTemplatedSection, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, localFontLimitRefusal, localFontReferences, makeRoom, mediaTextDirection, mergeSlotDeclarations, mirrorPlacement, motifFieldAttribute, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, originSet, pagePlacementLayout, pagePrintedPagesIssues, paperPixels, parentListIssues, parsePlayback, printBoxes, printPadding, printProperties, printedPagesIssues, removeFromGrid, removeItems, resizeItem, resolveBookPagination, resolveDirection, resolveFontFace, resolveNoteSeries, resolveParentPages, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, textArea, textDirection, toMillimeters, visibleItems, zoomAt, zoomToFit };
47
+ export { APP_FONT_NAME, APP_FONT_NAME_MESSAGE, Annotation, AssetKind, BOOK_FURNITURE, BOOK_PARENT_NAMES, Board, BoardItem, BoardLabel, BoardSection, Book, BookChapterEntry, BookContents, BookFrontMatterEntry, BookItem, BookMode, BookOpens, BookPage, BookRunningHead, BookRunningHeadSource, BookSection, BookSectionParents, BookTemplate, BookView, BookViewPagination, Box, COLLECTION_TAG, COVER_DRAWING_VERSION, COVER_SHEET, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cover, CropEdge, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, DesignedPage, DesignedSection, Direction, FOLD_DASH_OFF_MM, FOLD_DASH_ON_MM, FOLD_KINDS, FOLD_TUCK_IN_MM, FONT_FORMATS, FONT_GENERICS, FULL_PAGE_SIZE, FillValues, FlowingWidth, FontFaceRefusedError, FontReference, FontReferenceInput, GridCell, ImageFit, Imposition, LIBRARY_MOTIF_PREFIX, LOCAL_FONT_LIMITS, Lexicon, LocalFaceTransport, LocalFacesTransport, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_PART_DEPTH, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MEDIA_FORMATS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_MARK_LENGTH_MM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, MOTIF_ATTRIBUTE, Manifest, Margin, MarkColor, Media, MediaFormat, MediaPage, MediaText, Motif, MotifField, MotifFieldInput, MotifInput, MotifVersion, MotifVersionInput, NAMED_PAPERS, Narration, NoteMarker, NoteNumbering, NotePlacement, NoteSeries, NumberSystem, ORIENTATIONS, Orientation, PAGE_WIDTHS, PAPER_FIT_TOLERANCE_MM, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLACEMENT_ACCEPTS, PLAYBACK_MODES, PRINTED_PAGE_CONTEXT, PRINTED_PAGE_FOLIO_PATH, PRINTED_PAGE_LIMIT, PRINTED_PAGE_NUMBER_PATH, PRINTED_PAGE_ROLES, PRINTED_PAGE_RUNNING_HEAD_PATH, PRINTED_PAGE_TOTAL_PATH, PX_PER_MM, PX_PER_PT, Page, PageBody, PageSelector, PageSize, PageWidths, Paper, PaperUnit, ParentPage, ParentPageMargin, Part, PlacedSection, Placement, PlacementCrop, PlacementRefusedError, Playback, Point, Print, PrintSetting, PrintSettingInput, PrintedPageRules, PrintedPages, PronunciationEntry, PublishedShot, REGION_NAME, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, SLOT_TYPES, Scripts, Shot, Size, Slide, SlideContent, SlotDeclaration, SlotDeclarationInput, SlotKey, SlotType, SlotValue, Slots, SlotsInput, TemplatedPage, TemplatedSection, TextDirection, Transition, Word, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, bookParentPages, bookSections, checkPlacementCycles, chooseMotifVersion, classifyFont, collectionFaces, coverDigest, deckFromSlides, defaultPageNumbering, dependencyDecision, dependencyOriginSet, deriveSectionCells, digestCoverMaterial, exceedsLimits, extractFace, findPlacementCycle, firstStrongDirection, fitPage, fitSection, fitTouchedSections, flowingParentNames, foldCellPages, foldColumns, foldForSearch, foldPageCountMessage, foldPanelMap, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, impositionMarks, insertIntoGrid, isBookContents, isChapter, isDesignedSection, isHebrew, isPart, isPlacedSection, isPrintedPageIdentityImposition, isTemplatedSection, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, localFontLimitRefusal, localFontReferences, makeRoom, mediaTextDirection, mergeSlotDeclarations, mirrorPlacement, motifFieldAttribute, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, originSet, pagePlacementLayout, pagePrintedPagesIssues, paperPixels, parentListIssues, parsePlayback, printBoxes, printPadding, printProperties, printedPagesIssues, removeFromGrid, removeItems, resizeItem, resolveBookPagination, resolveDirection, resolveFontFace, resolveNoteSeries, resolvePageWidth, resolveParentPages, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, textArea, textDirection, toMillimeters, visibleItems, zoomAt, zoomToFit };
@@ -1,4 +1,5 @@
1
1
  import { BookItem } from "./book-section.js";
2
+ import { PageBody } from "./page.js";
2
3
  import { z } from "zod";
3
4
  //#region src/json-schemas.d.ts
4
5
  export declare function jsonSchemas(): {
@@ -438,14 +439,23 @@ export declare function jsonSchemas(): {
438
439
  }, z.core.$strip>;
439
440
  }, z.core.$strip>>;
440
441
  }, z.core.$strip>>;
441
- page: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
442
+ page: z.core.ZodStandardJSONSchemaPayload<z.ZodPipe<z.ZodObject<{
442
443
  id: z.ZodOptional<z.ZodString>;
443
- html: z.ZodString;
444
- size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
444
+ body: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
445
+ html: z.ZodString;
446
+ }, z.core.$strict>, z.ZodObject<{
447
+ markdown: z.ZodString;
448
+ }, z.core.$strict>]>>;
449
+ html: z.ZodOptional<z.ZodString>;
450
+ markdown: z.ZodOptional<z.ZodString>;
451
+ size: z.ZodDefault<z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
452
+ readonly width: "full";
453
+ readonly height: "auto";
454
+ }, "fluid">>, z.ZodObject<{
445
455
  width: z.ZodNumber;
446
456
  height: z.ZodNumber;
447
457
  }, z.core.$strip>, z.ZodObject<{
448
- width: z.ZodNumber;
458
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
449
459
  height: z.ZodLiteral<"auto">;
450
460
  }, z.core.$strip>]>>;
451
461
  scripts: z.ZodDefault<z.ZodEnum<{
@@ -597,7 +607,155 @@ export declare function jsonSchemas(): {
597
607
  local: z.ZodString;
598
608
  fallback: z.ZodString;
599
609
  }, z.core.$strip>]>>>;
600
- }, z.core.$strip>>;
610
+ }, z.core.$strip>, z.ZodTransform<{
611
+ body: PageBody;
612
+ size: {
613
+ readonly width: "full";
614
+ readonly height: "auto";
615
+ } | {
616
+ width: number;
617
+ height: number;
618
+ } | {
619
+ width: number | "full" | "standard" | "wide";
620
+ height: "auto";
621
+ };
622
+ scripts: "refuse" | "sandboxed";
623
+ id?: string | undefined;
624
+ dir?: "auto" | "ltr" | "rtl" | undefined;
625
+ lang?: string | undefined;
626
+ print?: {
627
+ 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" | {
628
+ width: number;
629
+ height: number;
630
+ unit: "mm" | "in" | "pt";
631
+ };
632
+ orientation: "portrait" | "landscape";
633
+ bleed: number;
634
+ safe: number;
635
+ marks: boolean;
636
+ markColor: "black" | "registration";
637
+ margin?: {
638
+ top: number;
639
+ right: number;
640
+ bottom: number;
641
+ left: number;
642
+ } | undefined;
643
+ } | undefined;
644
+ printedPages?: {
645
+ parents: {
646
+ name: string;
647
+ basedOn?: string | undefined;
648
+ margin?: {
649
+ top: number;
650
+ bottom: number;
651
+ inner: number;
652
+ outer: number;
653
+ } | undefined;
654
+ head?: string | undefined;
655
+ foot?: string | undefined;
656
+ }[];
657
+ rules: {
658
+ last?: string | undefined;
659
+ verso?: string | undefined;
660
+ recto?: string | undefined;
661
+ first?: string | undefined;
662
+ every: string;
663
+ };
664
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
665
+ } | undefined;
666
+ slots?: {
667
+ key: string;
668
+ label: string;
669
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
670
+ required: boolean;
671
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
672
+ placeholder?: string | undefined;
673
+ minSize?: number | undefined;
674
+ }[] | undefined;
675
+ fonts?: ({
676
+ app: string;
677
+ } | {
678
+ local: string;
679
+ fallback: string;
680
+ })[] | undefined;
681
+ }, {
682
+ size: {
683
+ readonly width: "full";
684
+ readonly height: "auto";
685
+ } | {
686
+ width: number;
687
+ height: number;
688
+ } | {
689
+ width: number | "full" | "standard" | "wide";
690
+ height: "auto";
691
+ };
692
+ scripts: "refuse" | "sandboxed";
693
+ id?: string | undefined;
694
+ body?: {
695
+ html: string;
696
+ } | {
697
+ markdown: string;
698
+ } | undefined;
699
+ html?: string | undefined;
700
+ markdown?: string | undefined;
701
+ dir?: "auto" | "ltr" | "rtl" | undefined;
702
+ lang?: string | undefined;
703
+ print?: {
704
+ 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" | {
705
+ width: number;
706
+ height: number;
707
+ unit: "mm" | "in" | "pt";
708
+ };
709
+ orientation: "portrait" | "landscape";
710
+ bleed: number;
711
+ safe: number;
712
+ marks: boolean;
713
+ markColor: "black" | "registration";
714
+ margin?: {
715
+ top: number;
716
+ right: number;
717
+ bottom: number;
718
+ left: number;
719
+ } | undefined;
720
+ } | undefined;
721
+ printedPages?: {
722
+ parents: {
723
+ name: string;
724
+ basedOn?: string | undefined;
725
+ margin?: {
726
+ top: number;
727
+ bottom: number;
728
+ inner: number;
729
+ outer: number;
730
+ } | undefined;
731
+ head?: string | undefined;
732
+ foot?: string | undefined;
733
+ }[];
734
+ rules: {
735
+ last?: string | undefined;
736
+ verso?: string | undefined;
737
+ recto?: string | undefined;
738
+ first?: string | undefined;
739
+ every: string;
740
+ };
741
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
742
+ } | undefined;
743
+ slots?: {
744
+ key: string;
745
+ label: string;
746
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
747
+ required: boolean;
748
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
749
+ placeholder?: string | undefined;
750
+ minSize?: number | undefined;
751
+ }[] | undefined;
752
+ fonts?: ({
753
+ app: string;
754
+ } | {
755
+ local: string;
756
+ fallback: string;
757
+ })[] | undefined;
758
+ }>>>;
601
759
  lexicon: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
602
760
  entries: z.ZodArray<z.ZodObject<{
603
761
  term: z.ZodString;
@@ -1549,14 +1707,23 @@ export declare function jsonSchemas(): {
1549
1707
  }, z.core.$strip>>;
1550
1708
  }, z.core.$strip>>;
1551
1709
  cover: z.core.ZodStandardJSONSchemaPayload<z.ZodPipe<z.ZodObject<{
1552
- page: z.ZodObject<{
1710
+ page: z.ZodPipe<z.ZodObject<{
1553
1711
  id: z.ZodOptional<z.ZodString>;
1554
- html: z.ZodString;
1555
- size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
1712
+ body: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
1713
+ html: z.ZodString;
1714
+ }, z.core.$strict>, z.ZodObject<{
1715
+ markdown: z.ZodString;
1716
+ }, z.core.$strict>]>>;
1717
+ html: z.ZodOptional<z.ZodString>;
1718
+ markdown: z.ZodOptional<z.ZodString>;
1719
+ size: z.ZodDefault<z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
1720
+ readonly width: "full";
1721
+ readonly height: "auto";
1722
+ }, "fluid">>, z.ZodObject<{
1556
1723
  width: z.ZodNumber;
1557
1724
  height: z.ZodNumber;
1558
1725
  }, z.core.$strip>, z.ZodObject<{
1559
- width: z.ZodNumber;
1726
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
1560
1727
  height: z.ZodLiteral<"auto">;
1561
1728
  }, z.core.$strip>]>>;
1562
1729
  scripts: z.ZodDefault<z.ZodEnum<{
@@ -1708,7 +1875,155 @@ export declare function jsonSchemas(): {
1708
1875
  local: z.ZodString;
1709
1876
  fallback: z.ZodString;
1710
1877
  }, z.core.$strip>]>>>;
1711
- }, z.core.$strip>;
1878
+ }, z.core.$strip>, z.ZodTransform<{
1879
+ body: PageBody;
1880
+ size: {
1881
+ readonly width: "full";
1882
+ readonly height: "auto";
1883
+ } | {
1884
+ width: number;
1885
+ height: number;
1886
+ } | {
1887
+ width: number | "full" | "standard" | "wide";
1888
+ height: "auto";
1889
+ };
1890
+ scripts: "refuse" | "sandboxed";
1891
+ id?: string | undefined;
1892
+ dir?: "auto" | "ltr" | "rtl" | undefined;
1893
+ lang?: string | undefined;
1894
+ print?: {
1895
+ 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" | {
1896
+ width: number;
1897
+ height: number;
1898
+ unit: "mm" | "in" | "pt";
1899
+ };
1900
+ orientation: "portrait" | "landscape";
1901
+ bleed: number;
1902
+ safe: number;
1903
+ marks: boolean;
1904
+ markColor: "black" | "registration";
1905
+ margin?: {
1906
+ top: number;
1907
+ right: number;
1908
+ bottom: number;
1909
+ left: number;
1910
+ } | undefined;
1911
+ } | undefined;
1912
+ printedPages?: {
1913
+ parents: {
1914
+ name: string;
1915
+ basedOn?: string | undefined;
1916
+ margin?: {
1917
+ top: number;
1918
+ bottom: number;
1919
+ inner: number;
1920
+ outer: number;
1921
+ } | undefined;
1922
+ head?: string | undefined;
1923
+ foot?: string | undefined;
1924
+ }[];
1925
+ rules: {
1926
+ last?: string | undefined;
1927
+ verso?: string | undefined;
1928
+ recto?: string | undefined;
1929
+ first?: string | undefined;
1930
+ every: string;
1931
+ };
1932
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
1933
+ } | undefined;
1934
+ slots?: {
1935
+ key: string;
1936
+ label: string;
1937
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
1938
+ required: boolean;
1939
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
1940
+ placeholder?: string | undefined;
1941
+ minSize?: number | undefined;
1942
+ }[] | undefined;
1943
+ fonts?: ({
1944
+ app: string;
1945
+ } | {
1946
+ local: string;
1947
+ fallback: string;
1948
+ })[] | undefined;
1949
+ }, {
1950
+ size: {
1951
+ readonly width: "full";
1952
+ readonly height: "auto";
1953
+ } | {
1954
+ width: number;
1955
+ height: number;
1956
+ } | {
1957
+ width: number | "full" | "standard" | "wide";
1958
+ height: "auto";
1959
+ };
1960
+ scripts: "refuse" | "sandboxed";
1961
+ id?: string | undefined;
1962
+ body?: {
1963
+ html: string;
1964
+ } | {
1965
+ markdown: string;
1966
+ } | undefined;
1967
+ html?: string | undefined;
1968
+ markdown?: string | undefined;
1969
+ dir?: "auto" | "ltr" | "rtl" | undefined;
1970
+ lang?: string | undefined;
1971
+ print?: {
1972
+ 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" | {
1973
+ width: number;
1974
+ height: number;
1975
+ unit: "mm" | "in" | "pt";
1976
+ };
1977
+ orientation: "portrait" | "landscape";
1978
+ bleed: number;
1979
+ safe: number;
1980
+ marks: boolean;
1981
+ markColor: "black" | "registration";
1982
+ margin?: {
1983
+ top: number;
1984
+ right: number;
1985
+ bottom: number;
1986
+ left: number;
1987
+ } | undefined;
1988
+ } | undefined;
1989
+ printedPages?: {
1990
+ parents: {
1991
+ name: string;
1992
+ basedOn?: string | undefined;
1993
+ margin?: {
1994
+ top: number;
1995
+ bottom: number;
1996
+ inner: number;
1997
+ outer: number;
1998
+ } | undefined;
1999
+ head?: string | undefined;
2000
+ foot?: string | undefined;
2001
+ }[];
2002
+ rules: {
2003
+ last?: string | undefined;
2004
+ verso?: string | undefined;
2005
+ recto?: string | undefined;
2006
+ first?: string | undefined;
2007
+ every: string;
2008
+ };
2009
+ numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
2010
+ } | undefined;
2011
+ slots?: {
2012
+ key: string;
2013
+ label: string;
2014
+ type: "text" | "image" | "phone" | "email" | "link" | "qr";
2015
+ required: boolean;
2016
+ overflow: "refuse" | "shrink" | "truncate" | "wrap";
2017
+ placeholder?: string | undefined;
2018
+ minSize?: number | undefined;
2019
+ }[] | undefined;
2020
+ fonts?: ({
2021
+ app: string;
2022
+ } | {
2023
+ local: string;
2024
+ fallback: string;
2025
+ })[] | undefined;
2026
+ }>>;
1712
2027
  id: z.ZodOptional<z.ZodString>;
1713
2028
  name: z.ZodOptional<z.ZodString>;
1714
2029
  }, z.core.$strip>, z.ZodTransform<{
@@ -1731,12 +2046,15 @@ export declare function jsonSchemas(): {
1731
2046
  left: number;
1732
2047
  } | undefined;
1733
2048
  };
1734
- html: string;
1735
- size: "fluid" | {
2049
+ body: PageBody;
2050
+ size: {
2051
+ readonly width: "full";
2052
+ readonly height: "auto";
2053
+ } | {
1736
2054
  width: number;
1737
2055
  height: number;
1738
2056
  } | {
1739
- width: number;
2057
+ width: number | "full" | "standard" | "wide";
1740
2058
  height: "auto";
1741
2059
  };
1742
2060
  scripts: "refuse" | "sandboxed";
@@ -1785,12 +2103,15 @@ export declare function jsonSchemas(): {
1785
2103
  name?: string | undefined;
1786
2104
  }, {
1787
2105
  page: {
1788
- html: string;
1789
- size: "fluid" | {
2106
+ body: PageBody;
2107
+ size: {
2108
+ readonly width: "full";
2109
+ readonly height: "auto";
2110
+ } | {
1790
2111
  width: number;
1791
2112
  height: number;
1792
2113
  } | {
1793
- width: number;
2114
+ width: number | "full" | "standard" | "wide";
1794
2115
  height: "auto";
1795
2116
  };
1796
2117
  scripts: "refuse" | "sandboxed";
package/dist/page.d.ts CHANGED
@@ -1,22 +1,59 @@
1
1
  import { z } from "zod";
2
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<{
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<{
5
22
  width: z.ZodNumber;
6
23
  height: z.ZodNumber;
7
24
  }, z.core.$strip>, z.ZodObject<{
8
- width: z.ZodNumber;
25
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
9
26
  height: z.ZodLiteral<"auto">;
10
27
  }, z.core.$strip>]>;
11
28
  export type PageSize = z.infer<typeof PageSize>;
12
- export declare const Page: z.ZodObject<{
13
- id: z.ZodOptional<z.ZodString>;
29
+ export interface ResolvedPageWidth {
30
+ measure?: number;
31
+ viewportWidth: number;
32
+ }
33
+ export declare const PageBody: z.ZodUnion<readonly [z.ZodObject<{
14
34
  html: z.ZodString;
15
- size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
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<{
16
53
  width: z.ZodNumber;
17
54
  height: z.ZodNumber;
18
55
  }, z.core.$strip>, z.ZodObject<{
19
- width: z.ZodNumber;
56
+ width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
20
57
  height: z.ZodLiteral<"auto">;
21
58
  }, z.core.$strip>]>>;
22
59
  scripts: z.ZodDefault<z.ZodEnum<{
@@ -168,7 +205,155 @@ export declare const Page: z.ZodObject<{
168
205
  local: z.ZodString;
169
206
  fallback: z.ZodString;
170
207
  }, z.core.$strip>]>>>;
171
- }, z.core.$strip>;
208
+ }, z.core.$strip>, z.ZodTransform<{
209
+ body: PageBody;
210
+ size: {
211
+ readonly width: "full";
212
+ readonly height: "auto";
213
+ } | {
214
+ width: number;
215
+ height: number;
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: "mm" | "in" | "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
+ readonly width: "full";
282
+ readonly height: "auto";
283
+ } | {
284
+ width: number;
285
+ height: number;
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: "mm" | "in" | "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
+ }>>;
172
357
  export type Page = z.infer<typeof Page>;
173
358
  export type PageInput = z.input<typeof Page>;
174
359
  //#endregion
package/dist/page.js CHANGED
@@ -7,19 +7,54 @@ import { PrintedPages, pagePrintedPagesIssues } from "./printed-pages.js";
7
7
  import { Print } from "./print.js";
8
8
  import { z } from "zod";
9
9
  //#region src/page.ts
10
- const FLUID_WIDTH = 1024;
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);
11
33
  const PageSize = z.union([
12
- z.literal("fluid"),
34
+ LegacyFluidPageSize,
13
35
  Size,
14
- z.object({
15
- width: z.number().int().positive(),
16
- height: z.literal("auto")
17
- })
36
+ FlowingPageSize
18
37
  ]);
19
- const Page = z.object({
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({
20
53
  id: z.string().optional(),
21
- html: z.string(),
22
- size: PageSize.default("fluid"),
54
+ body: PageBody.optional(),
55
+ html: z.string().optional(),
56
+ markdown: z.string().optional(),
57
+ size: PageSize.default(FULL_PAGE_SIZE),
23
58
  scripts: Scripts.default("refuse"),
24
59
  dir: Direction.optional(),
25
60
  lang: z.string().optional(),
@@ -28,10 +63,48 @@ const Page = z.object({
28
63
  slots: Slots.optional(),
29
64
  fonts: z.array(FontReference).optional()
30
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
+ }
31
80
  for (const issue of pagePrintedPagesIssues(page)) ctx.addIssue({
32
81
  code: "custom",
33
82
  ...issue
34
83
  });
35
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
+ }));
36
109
  //#endregion
37
- export { FLUID_WIDTH, Page, PageSize };
110
+ export { FULL_PAGE_SIZE, FlowingWidth, PAGE_WIDTHS, Page, PageBody, PageSize, PageWidths, resolvePageWidth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segnavia/format",
3
- "version": "0.39.0",
3
+ "version": "0.40.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {