@segnavia/format 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/board.d.ts CHANGED
@@ -4,10 +4,10 @@ export declare const BoardItem: z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  kind: z.ZodEnum<{
6
6
  paper: "paper";
7
+ image: "image";
7
8
  page: "page";
8
9
  book: "book";
9
10
  shot: "shot";
10
- image: "image";
11
11
  deck: "deck";
12
12
  }>;
13
13
  address: z.ZodString;
@@ -60,10 +60,10 @@ export declare const Board: z.ZodObject<{
60
60
  id: z.ZodString;
61
61
  kind: z.ZodEnum<{
62
62
  paper: "paper";
63
+ image: "image";
63
64
  page: "page";
64
65
  book: "book";
65
66
  shot: "shot";
66
- image: "image";
67
67
  deck: "deck";
68
68
  }>;
69
69
  address: z.ZodString;
package/dist/book.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Direction } from "./direction.js";
2
2
  import { Scripts } from "./scripts.js";
3
3
  import { NoteMarker, NumberSystem } from "./numbering.js";
4
- import { Paper, sheetMm } from "./paper.js";
4
+ import { Orientation, Paper, sheetMm } from "./paper.js";
5
5
  import { z } from "zod";
6
6
  //#region src/book.ts
7
7
  const BookMode = z.enum(["continuous", "paginated"]);
@@ -25,7 +25,7 @@ const Chapter = z.object({
25
25
  });
26
26
  const BookPage = z.object({
27
27
  paper: Paper,
28
- orientation: z.enum(["portrait", "landscape"]).default("portrait"),
28
+ orientation: Orientation.default("portrait"),
29
29
  margin: z.object({
30
30
  top: z.number().nonnegative(),
31
31
  bottom: z.number().nonnegative(),
@@ -122,5 +122,12 @@ export declare function deckFromSlides(rows: SlideRow[], options: DeckFromSlides
122
122
  } | undefined;
123
123
  playback?: "continuous" | "segmented" | undefined;
124
124
  captions?: "on" | "off" | "viewer" | undefined;
125
+ slots?: {
126
+ key: string;
127
+ label: string;
128
+ type: "text" | "phone" | "email" | "link" | "image";
129
+ required: boolean;
130
+ placeholder?: string | undefined;
131
+ }[] | undefined;
125
132
  };
126
133
  //#endregion
package/dist/deck.d.ts CHANGED
@@ -438,6 +438,19 @@ export declare const Deck: z.ZodObject<{
438
438
  off: "off";
439
439
  viewer: "viewer";
440
440
  }>>;
441
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
442
+ key: z.ZodString;
443
+ label: z.ZodString;
444
+ type: z.ZodEnum<{
445
+ text: "text";
446
+ phone: "phone";
447
+ email: "email";
448
+ link: "link";
449
+ image: "image";
450
+ }>;
451
+ required: z.ZodDefault<z.ZodBoolean>;
452
+ placeholder: z.ZodOptional<z.ZodString>;
453
+ }, z.core.$strip>>>;
441
454
  slides: z.ZodArray<z.ZodObject<{
442
455
  id: z.ZodString;
443
456
  content: z.ZodDiscriminatedUnion<[z.ZodObject<{
package/dist/deck.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Direction } from "./direction.js";
2
2
  import { Scripts } from "./scripts.js";
3
+ import { Slots } from "./slots.js";
3
4
  import { SlideTiming, slideTimingIssues } from "./timing.js";
4
5
  import { Transition } from "./transition.js";
5
6
  import { z } from "zod";
@@ -142,6 +143,7 @@ const DeckShape = z.object({
142
143
  "off",
143
144
  "viewer"
144
145
  ]).optional(),
146
+ slots: Slots.optional(),
145
147
  slides: z.array(Slide).min(1)
146
148
  });
147
149
  function annotationCueIssues(narration, annotations) {
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import { assignMembership, fitSection, fitTouchedSections, makeRoom, settleBoard
9
9
  import { Book, BookContents, BookFrontMatterEntry, BookInput, BookMode, BookPage, BookSection, BookView, BookViewInput, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
10
10
  import { DeckFromSlidesOptions, SlideRow, deckFromSlides } from "./deck-from-slides.js";
11
11
  import { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
12
- import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, PaperBox, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
12
+ import { CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, NamedPaper, NamedPaperMetadata, ORIENTATIONS, Orientation, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PX_PER_MM, Paper, PaperBox, PaperGroup, PaperUnit, PrintSetting, PrintSettingInput, fromMillimeters, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
13
13
  import { Imposed, MillimeterEdges, PageFit, PagePlacementKind, PagePlacementLayout, Placement, fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
14
14
  import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
15
15
  import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
@@ -17,6 +17,7 @@ import { Scripts } from "./scripts.js";
17
17
  import { ShotUse, shotsUsed } from "./shots-used.js";
18
18
  import { MAX_SLIDE_TIMING_MS } from "./timing.js";
19
19
  import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition, TransitionInput } from "./transition.js";
20
+ import { Fill, SLOT_TYPES, SlotDeclaration, SlotDeclarationInput, SlotReport, SlotState, SlotType, SlotValue, Slots, SlotsInput, SlotsOptions, mergeSlotDeclarations } from "./slots.js";
20
21
  import { z } from "zod";
21
22
  //#region src/index.d.ts
22
23
  export declare const Margin: z.ZodObject<{
@@ -178,6 +179,7 @@ export declare const PageSize: z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.Zod
178
179
  }, z.core.$strip>]>;
179
180
  export type PageSize = z.infer<typeof PageSize>;
180
181
  export declare const Page: z.ZodObject<{
182
+ id: z.ZodOptional<z.ZodString>;
181
183
  html: z.ZodString;
182
184
  size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
183
185
  width: z.ZodNumber;
@@ -248,6 +250,19 @@ export declare const Page: z.ZodObject<{
248
250
  safe: z.ZodDefault<z.ZodNumber>;
249
251
  marks: z.ZodDefault<z.ZodBoolean>;
250
252
  }, z.core.$strip>>;
253
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
254
+ key: z.ZodString;
255
+ label: z.ZodString;
256
+ type: z.ZodEnum<{
257
+ text: "text";
258
+ phone: "phone";
259
+ email: "email";
260
+ link: "link";
261
+ image: "image";
262
+ }>;
263
+ required: z.ZodDefault<z.ZodBoolean>;
264
+ placeholder: z.ZodOptional<z.ZodString>;
265
+ }, z.core.$strip>>>;
251
266
  }, z.core.$strip>;
252
267
  export type Page = z.infer<typeof Page>;
253
268
  export type PageInput = z.input<typeof Page>;
@@ -390,6 +405,7 @@ export declare function jsonSchemas(): {
390
405
  html: z.ZodString;
391
406
  }, z.core.$strip>>;
392
407
  page: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
408
+ id: z.ZodOptional<z.ZodString>;
393
409
  html: z.ZodString;
394
410
  size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
395
411
  width: z.ZodNumber;
@@ -460,6 +476,19 @@ export declare function jsonSchemas(): {
460
476
  safe: z.ZodDefault<z.ZodNumber>;
461
477
  marks: z.ZodDefault<z.ZodBoolean>;
462
478
  }, z.core.$strip>>;
479
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
480
+ key: z.ZodString;
481
+ label: z.ZodString;
482
+ type: z.ZodEnum<{
483
+ text: "text";
484
+ phone: "phone";
485
+ email: "email";
486
+ link: "link";
487
+ image: "image";
488
+ }>;
489
+ required: z.ZodDefault<z.ZodBoolean>;
490
+ placeholder: z.ZodOptional<z.ZodString>;
491
+ }, z.core.$strip>>>;
463
492
  }, z.core.$strip>>;
464
493
  lexicon: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
465
494
  entries: z.ZodArray<z.ZodObject<{
@@ -599,6 +628,19 @@ export declare function jsonSchemas(): {
599
628
  off: "off";
600
629
  viewer: "viewer";
601
630
  }>>;
631
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
632
+ key: z.ZodString;
633
+ label: z.ZodString;
634
+ type: z.ZodEnum<{
635
+ text: "text";
636
+ phone: "phone";
637
+ email: "email";
638
+ link: "link";
639
+ image: "image";
640
+ }>;
641
+ required: z.ZodDefault<z.ZodBoolean>;
642
+ placeholder: z.ZodOptional<z.ZodString>;
643
+ }, z.core.$strip>>>;
602
644
  slides: z.ZodArray<z.ZodObject<{
603
645
  id: z.ZodString;
604
646
  content: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -820,10 +862,10 @@ export declare function jsonSchemas(): {
820
862
  id: z.ZodString;
821
863
  kind: z.ZodEnum<{
822
864
  paper: "paper";
865
+ image: "image";
823
866
  page: "page";
824
867
  book: "book";
825
868
  shot: "shot";
826
- image: "image";
827
869
  deck: "deck";
828
870
  }>;
829
871
  address: z.ZodString;
@@ -858,6 +900,118 @@ export declare function jsonSchemas(): {
858
900
  }, z.core.$strip>>>;
859
901
  }, z.core.$strip>>;
860
902
  }, z.core.$strip>>;
903
+ printSetting: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
904
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
905
+ letter: "letter";
906
+ legal: "legal";
907
+ tabloid: "tabloid";
908
+ a3: "a3";
909
+ a4: "a4";
910
+ a5: "a5";
911
+ "business-card-us": "business-card-us";
912
+ "business-card-eu": "business-card-eu";
913
+ "business-card-square-us": "business-card-square-us";
914
+ "business-card-slim-us": "business-card-slim-us";
915
+ "postcard-4x6": "postcard-4x6";
916
+ "postcard-5x7": "postcard-5x7";
917
+ "postcard-6x9": "postcard-6x9";
918
+ "postcard-6x11": "postcard-6x11";
919
+ "card-square-4in": "card-square-4in";
920
+ "half-letter": "half-letter";
921
+ a6: "a6";
922
+ dl: "dl";
923
+ "rack-card-4x9": "rack-card-4x9";
924
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
925
+ "poster-12x18": "poster-12x18";
926
+ "poster-16x20": "poster-16x20";
927
+ "poster-18x24": "poster-18x24";
928
+ "poster-24x36": "poster-24x36";
929
+ a2: "a2";
930
+ a1: "a1";
931
+ a0: "a0";
932
+ }>, z.ZodObject<{
933
+ width: z.ZodNumber;
934
+ height: z.ZodNumber;
935
+ unit: z.ZodEnum<{
936
+ mm: "mm";
937
+ in: "in";
938
+ pt: "pt";
939
+ }>;
940
+ }, z.core.$strip>]>;
941
+ orientation: z.ZodEnum<{
942
+ portrait: "portrait";
943
+ landscape: "landscape";
944
+ }>;
945
+ }, z.core.$strip>>;
946
+ printSettingInput: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
947
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
948
+ letter: "letter";
949
+ legal: "legal";
950
+ tabloid: "tabloid";
951
+ a3: "a3";
952
+ a4: "a4";
953
+ a5: "a5";
954
+ "business-card-us": "business-card-us";
955
+ "business-card-eu": "business-card-eu";
956
+ "business-card-square-us": "business-card-square-us";
957
+ "business-card-slim-us": "business-card-slim-us";
958
+ "postcard-4x6": "postcard-4x6";
959
+ "postcard-5x7": "postcard-5x7";
960
+ "postcard-6x9": "postcard-6x9";
961
+ "postcard-6x11": "postcard-6x11";
962
+ "card-square-4in": "card-square-4in";
963
+ "half-letter": "half-letter";
964
+ a6: "a6";
965
+ dl: "dl";
966
+ "rack-card-4x9": "rack-card-4x9";
967
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
968
+ "poster-12x18": "poster-12x18";
969
+ "poster-16x20": "poster-16x20";
970
+ "poster-18x24": "poster-18x24";
971
+ "poster-24x36": "poster-24x36";
972
+ a2: "a2";
973
+ a1: "a1";
974
+ a0: "a0";
975
+ }>, z.ZodObject<{
976
+ width: z.ZodNumber;
977
+ height: z.ZodNumber;
978
+ unit: z.ZodEnum<{
979
+ mm: "mm";
980
+ in: "in";
981
+ pt: "pt";
982
+ }>;
983
+ }, z.core.$strip>]>;
984
+ orientation: z.ZodEnum<{
985
+ portrait: "portrait";
986
+ landscape: "landscape";
987
+ }>;
988
+ }, z.core.$strict>>;
989
+ slotDeclaration: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
990
+ key: z.ZodString;
991
+ label: z.ZodString;
992
+ type: z.ZodEnum<{
993
+ text: "text";
994
+ phone: "phone";
995
+ email: "email";
996
+ link: "link";
997
+ image: "image";
998
+ }>;
999
+ required: z.ZodDefault<z.ZodBoolean>;
1000
+ placeholder: z.ZodOptional<z.ZodString>;
1001
+ }, z.core.$strip>>;
1002
+ slotDeclarationInput: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
1003
+ key: z.ZodString;
1004
+ label: z.ZodString;
1005
+ type: z.ZodEnum<{
1006
+ text: "text";
1007
+ phone: "phone";
1008
+ email: "email";
1009
+ link: "link";
1010
+ image: "image";
1011
+ }>;
1012
+ required: z.ZodDefault<z.ZodBoolean>;
1013
+ placeholder: z.ZodOptional<z.ZodString>;
1014
+ }, z.core.$strict>>;
861
1015
  };
862
1016
  //#endregion
863
- export { Annotation, type ArrangeOptions, Board, type BoardInput, BoardItem, type BoardItemAnchor, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, GridCell, type GridDropTarget, ImageFit, type Imposed, Lexicon, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PLAYBACK_MODES, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, Playback, type PlaybackMode, Point, PronunciationEntry, PublishedShot, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, deriveSectionCells, exceedsLimits, firstStrongDirection, fitPage, fitSection, fitTouchedSections, foldForSearch, formatNumber, gridDropMarkerBox, gridDropTarget, impose, insertIntoGrid, isBookContents, isHebrew, itemAt, itemHeight, languageDirection, layoutSection, lexiconVersion, makeRoom, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, parsePlayback, printBoxes, printPadding, printProperties, removeFromGrid, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
1017
+ export { Annotation, type ArrangeOptions, Board, type BoardInput, BoardItem, type BoardItemAnchor, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, Fill, GridCell, type GridDropTarget, ImageFit, type Imposed, Lexicon, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, type NamedPaper, type NamedPaperMetadata, Narration, NoteMarker, NumberSystem, ORIENTATIONS, Orientation, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLAYBACK_MODES, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type PaperGroup, PaperUnit, type Placement, Playback, type PlaybackMode, Point, PrintSetting, PrintSettingInput, PronunciationEntry, PublishedShot, 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, SlotReport, SlotState, SlotType, SlotValue, Slots, SlotsInput, SlotsOptions, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, deriveSectionCells, exceedsLimits, firstStrongDirection, fitPage, fitSection, fitTouchedSections, foldForSearch, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, insertIntoGrid, isBookContents, isHebrew, itemAt, itemHeight, languageDirection, layoutSection, lexiconVersion, makeRoom, mergeSlotDeclarations, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, parsePlayback, printBoxes, printPadding, printProperties, removeFromGrid, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
2
2
  import { Scripts } from "./scripts.js";
3
+ import { SLOT_TYPES, SlotDeclaration, SlotDeclarationInput, SlotType, Slots, SlotsInput, mergeSlotDeclarations } from "./slots.js";
3
4
  import { MAX_SLIDE_TIMING_MS } from "./timing.js";
4
5
  import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition } from "./transition.js";
5
6
  import { Annotation, Box, Cue, DECK_SIZE, Deck, DeckShape, ImageFit, Manifest, Narration, PLAYBACK_MODES, Playback, Point, PublishedShot, SHOT_KEY, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits, parsePlayback } from "./deck.js";
6
7
  import { Board, BoardItem, BoardLabel, BoardSection, GridCell } from "./board.js";
7
8
  import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
8
- import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
9
+ import { CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_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, Paper, PaperUnit, PrintSetting, PrintSettingInput, fromMillimeters, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
9
10
  import { Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookShape, BookView, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
10
11
  import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
11
12
  import { MIN_BOARD_ITEM_WIDTH, addItem, moveItems, moveSection, removeItems, resizeItem } from "./board-edit.js";
@@ -27,7 +28,7 @@ const Margin = z.object({
27
28
  });
28
29
  const Print = z.object({
29
30
  paper: Paper,
30
- orientation: z.enum(["portrait", "landscape"]).default("portrait"),
31
+ orientation: Orientation.default("portrait"),
31
32
  margin: Margin.optional(),
32
33
  bleed: z.number().nonnegative().default(0),
33
34
  safe: z.number().nonnegative().default(0),
@@ -52,12 +53,8 @@ const ImpositionGap = z.object({
52
53
  const MAX_IMPOSITION_CELLS = 1e4;
53
54
  const Imposition = z.object({
54
55
  paper: Paper,
55
- orientation: z.enum(["portrait", "landscape"]).default("portrait"),
56
- unit: z.enum([
57
- "mm",
58
- "in",
59
- "pt"
60
- ]).default("mm"),
56
+ orientation: Orientation.default("portrait"),
57
+ unit: PaperUnit.default("mm"),
61
58
  margin: Margin.default({
62
59
  top: 0,
63
60
  right: 0,
@@ -138,12 +135,14 @@ const PageSize = z.union([
138
135
  })
139
136
  ]);
140
137
  const Page = z.object({
138
+ id: z.string().optional(),
141
139
  html: z.string(),
142
140
  size: PageSize.default("fluid"),
143
141
  scripts: Scripts.default("refuse"),
144
142
  dir: Direction.optional(),
145
143
  lang: z.string().optional(),
146
- print: Print.optional()
144
+ print: Print.optional(),
145
+ slots: Slots.optional()
147
146
  });
148
147
  function jsonSchemas() {
149
148
  return {
@@ -155,8 +154,12 @@ function jsonSchemas() {
155
154
  deck: z.toJSONSchema(DeckShape, { io: "input" }),
156
155
  manifest: z.toJSONSchema(Manifest, { io: "input" }),
157
156
  publishedShot: z.toJSONSchema(PublishedShot, { io: "input" }),
158
- board: z.toJSONSchema(Board, { io: "input" })
157
+ board: z.toJSONSchema(Board, { io: "input" }),
158
+ printSetting: z.toJSONSchema(PrintSetting, { io: "input" }),
159
+ printSettingInput: z.toJSONSchema(PrintSettingInput, { io: "input" }),
160
+ slotDeclaration: z.toJSONSchema(SlotDeclaration, { io: "input" }),
161
+ slotDeclarationInput: z.toJSONSchema(SlotDeclarationInput, { io: "input" })
159
162
  };
160
163
  }
161
164
  //#endregion
162
- export { Annotation, Board, BoardItem, BoardLabel, BoardSection, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, GridCell, ImageFit, Imposition, Lexicon, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PLAYBACK_MODES, PX_PER_MM, Page, PageSize, Paper, Playback, Point, Print, PronunciationEntry, PublishedShot, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, TextDirection, Transition, Word, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, deriveSectionCells, exceedsLimits, firstStrongDirection, fitPage, fitSection, fitTouchedSections, foldForSearch, formatNumber, gridDropMarkerBox, gridDropTarget, impose, insertIntoGrid, isBookContents, isHebrew, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, makeRoom, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, parsePlayback, printBoxes, printPadding, printProperties, removeFromGrid, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
165
+ export { Annotation, Board, BoardItem, BoardLabel, BoardSection, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_MM, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, GridCell, ImageFit, Imposition, Lexicon, MAKE_ROOM_LIMIT, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, ORIENTATIONS, Orientation, PAPER_GROUPS, PAPER_METADATA, PAPER_MM, PAPER_UNITS, PLAYBACK_MODES, PX_PER_MM, Page, PageSize, Paper, PaperUnit, Playback, Point, Print, PrintSetting, PrintSettingInput, PronunciationEntry, PublishedShot, SECTION_GAP, SECTION_MIN_SIZE, SECTION_PADDING, SECTION_TITLE_ROOM, SHOT_KEY, SLOT_TYPES, Scripts, Shot, Size, Slide, SlideContent, SlotDeclaration, SlotDeclarationInput, SlotType, Slots, SlotsInput, TextDirection, Transition, Word, addItem, annotationCueIssues, arrange, assignMembership, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, deriveSectionCells, exceedsLimits, firstStrongDirection, fitPage, fitSection, fitTouchedSections, foldForSearch, formatNumber, fromMillimeters, gridDropMarkerBox, gridDropTarget, impose, insertIntoGrid, isBookContents, isHebrew, itemAt, itemHeight, jsonSchemas, languageDirection, layoutSection, lexiconVersion, makeRoom, mergeSlotDeclarations, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, parsePlayback, printBoxes, printPadding, printProperties, removeFromGrid, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, settleBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
package/dist/paper.d.ts CHANGED
@@ -2,6 +2,166 @@ import { Print } from "./index.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"];
5
+ export type NamedPaper = (typeof NAMED_PAPERS)[number];
6
+ export declare const PAPER_GROUPS: readonly ["Office", "Cards", "Leaflets", "Posters"];
7
+ export type PaperGroup = (typeof PAPER_GROUPS)[number];
8
+ export interface NamedPaperMetadata {
9
+ name: string;
10
+ group: PaperGroup;
11
+ size: string;
12
+ }
13
+ export declare const PAPER_METADATA: {
14
+ letter: {
15
+ name: string;
16
+ group: "Office";
17
+ size: string;
18
+ };
19
+ legal: {
20
+ name: string;
21
+ group: "Office";
22
+ size: string;
23
+ };
24
+ tabloid: {
25
+ name: string;
26
+ group: "Office";
27
+ size: string;
28
+ };
29
+ a3: {
30
+ name: string;
31
+ group: "Office";
32
+ size: string;
33
+ };
34
+ a4: {
35
+ name: string;
36
+ group: "Office";
37
+ size: string;
38
+ };
39
+ a5: {
40
+ name: string;
41
+ group: "Office";
42
+ size: string;
43
+ };
44
+ 'business-card-us': {
45
+ name: string;
46
+ group: "Cards";
47
+ size: string;
48
+ };
49
+ 'business-card-eu': {
50
+ name: string;
51
+ group: "Cards";
52
+ size: string;
53
+ };
54
+ 'business-card-square-us': {
55
+ name: string;
56
+ group: "Cards";
57
+ size: string;
58
+ };
59
+ 'business-card-slim-us': {
60
+ name: string;
61
+ group: "Cards";
62
+ size: string;
63
+ };
64
+ 'postcard-4x6': {
65
+ name: string;
66
+ group: "Cards";
67
+ size: string;
68
+ };
69
+ 'postcard-5x7': {
70
+ name: string;
71
+ group: "Cards";
72
+ size: string;
73
+ };
74
+ 'postcard-6x9': {
75
+ name: string;
76
+ group: "Cards";
77
+ size: string;
78
+ };
79
+ 'postcard-6x11': {
80
+ name: string;
81
+ group: "Cards";
82
+ size: string;
83
+ };
84
+ 'card-square-4in': {
85
+ name: string;
86
+ group: "Cards";
87
+ size: string;
88
+ };
89
+ 'half-letter': {
90
+ name: string;
91
+ group: "Leaflets";
92
+ size: string;
93
+ };
94
+ a6: {
95
+ name: string;
96
+ group: "Leaflets";
97
+ size: string;
98
+ };
99
+ dl: {
100
+ name: string;
101
+ group: "Leaflets";
102
+ size: string;
103
+ };
104
+ 'rack-card-4x9': {
105
+ name: string;
106
+ group: "Leaflets";
107
+ size: string;
108
+ };
109
+ 'rack-card-3.5x8.5': {
110
+ name: string;
111
+ group: "Leaflets";
112
+ size: string;
113
+ };
114
+ 'poster-12x18': {
115
+ name: string;
116
+ group: "Posters";
117
+ size: string;
118
+ };
119
+ 'poster-16x20': {
120
+ name: string;
121
+ group: "Posters";
122
+ size: string;
123
+ };
124
+ 'poster-18x24': {
125
+ name: string;
126
+ group: "Posters";
127
+ size: string;
128
+ };
129
+ 'poster-24x36': {
130
+ name: string;
131
+ group: "Posters";
132
+ size: string;
133
+ };
134
+ a2: {
135
+ name: string;
136
+ group: "Posters";
137
+ size: string;
138
+ };
139
+ a1: {
140
+ name: string;
141
+ group: "Posters";
142
+ size: string;
143
+ };
144
+ a0: {
145
+ name: string;
146
+ group: "Posters";
147
+ size: string;
148
+ };
149
+ };
150
+ export declare const CUSTOM_PAPER_MIN_MM = 10;
151
+ export declare const CUSTOM_PAPER_MAX_MM = 2000;
152
+ export declare const PAPER_UNITS: readonly ["mm", "in", "pt"];
153
+ export declare const PaperUnit: z.ZodEnum<{
154
+ mm: "mm";
155
+ in: "in";
156
+ pt: "pt";
157
+ }>;
158
+ export type PaperUnit = z.infer<typeof PaperUnit>;
159
+ export declare const ORIENTATIONS: readonly ["portrait", "landscape"];
160
+ export declare const Orientation: z.ZodEnum<{
161
+ portrait: "portrait";
162
+ landscape: "landscape";
163
+ }>;
164
+ export type Orientation = z.infer<typeof Orientation>;
5
165
  export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
6
166
  letter: "letter";
7
167
  legal: "legal";
@@ -40,11 +200,100 @@ export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
40
200
  }>;
41
201
  }, z.core.$strip>]>;
42
202
  export type Paper = z.infer<typeof Paper>;
203
+ export declare const PrintSetting: z.ZodObject<{
204
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
205
+ letter: "letter";
206
+ legal: "legal";
207
+ tabloid: "tabloid";
208
+ a3: "a3";
209
+ a4: "a4";
210
+ a5: "a5";
211
+ "business-card-us": "business-card-us";
212
+ "business-card-eu": "business-card-eu";
213
+ "business-card-square-us": "business-card-square-us";
214
+ "business-card-slim-us": "business-card-slim-us";
215
+ "postcard-4x6": "postcard-4x6";
216
+ "postcard-5x7": "postcard-5x7";
217
+ "postcard-6x9": "postcard-6x9";
218
+ "postcard-6x11": "postcard-6x11";
219
+ "card-square-4in": "card-square-4in";
220
+ "half-letter": "half-letter";
221
+ a6: "a6";
222
+ dl: "dl";
223
+ "rack-card-4x9": "rack-card-4x9";
224
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
225
+ "poster-12x18": "poster-12x18";
226
+ "poster-16x20": "poster-16x20";
227
+ "poster-18x24": "poster-18x24";
228
+ "poster-24x36": "poster-24x36";
229
+ a2: "a2";
230
+ a1: "a1";
231
+ a0: "a0";
232
+ }>, z.ZodObject<{
233
+ width: z.ZodNumber;
234
+ height: z.ZodNumber;
235
+ unit: z.ZodEnum<{
236
+ mm: "mm";
237
+ in: "in";
238
+ pt: "pt";
239
+ }>;
240
+ }, z.core.$strip>]>;
241
+ orientation: z.ZodEnum<{
242
+ portrait: "portrait";
243
+ landscape: "landscape";
244
+ }>;
245
+ }, z.core.$strip>;
246
+ export type PrintSetting = z.infer<typeof PrintSetting>;
247
+ export declare const PrintSettingInput: z.ZodObject<{
248
+ paper: z.ZodUnion<readonly [z.ZodEnum<{
249
+ letter: "letter";
250
+ legal: "legal";
251
+ tabloid: "tabloid";
252
+ a3: "a3";
253
+ a4: "a4";
254
+ a5: "a5";
255
+ "business-card-us": "business-card-us";
256
+ "business-card-eu": "business-card-eu";
257
+ "business-card-square-us": "business-card-square-us";
258
+ "business-card-slim-us": "business-card-slim-us";
259
+ "postcard-4x6": "postcard-4x6";
260
+ "postcard-5x7": "postcard-5x7";
261
+ "postcard-6x9": "postcard-6x9";
262
+ "postcard-6x11": "postcard-6x11";
263
+ "card-square-4in": "card-square-4in";
264
+ "half-letter": "half-letter";
265
+ a6: "a6";
266
+ dl: "dl";
267
+ "rack-card-4x9": "rack-card-4x9";
268
+ "rack-card-3.5x8.5": "rack-card-3.5x8.5";
269
+ "poster-12x18": "poster-12x18";
270
+ "poster-16x20": "poster-16x20";
271
+ "poster-18x24": "poster-18x24";
272
+ "poster-24x36": "poster-24x36";
273
+ a2: "a2";
274
+ a1: "a1";
275
+ a0: "a0";
276
+ }>, z.ZodObject<{
277
+ width: z.ZodNumber;
278
+ height: z.ZodNumber;
279
+ unit: z.ZodEnum<{
280
+ mm: "mm";
281
+ in: "in";
282
+ pt: "pt";
283
+ }>;
284
+ }, z.core.$strip>]>;
285
+ orientation: z.ZodEnum<{
286
+ portrait: "portrait";
287
+ landscape: "landscape";
288
+ }>;
289
+ }, z.core.$strict>;
290
+ export type PrintSettingInput = z.input<typeof PrintSettingInput>;
43
291
  export declare const MM_PER_PT: number;
44
292
  export declare const MARK_LENGTH_MM = 5;
45
293
  export declare const MARK_GAP_MM = 1;
46
294
  export declare const roundMillimeters: (mm: number) => number;
47
- export declare function toMillimeters(value: number, unit: 'mm' | 'in' | 'pt'): number;
295
+ export declare function toMillimeters(value: number, unit: PaperUnit): number;
296
+ export declare function fromMillimeters(millimeters: number, unit: PaperUnit): number;
48
297
  export declare const PAPER_MM: Record<Extract<Paper, string>, {
49
298
  width: number;
50
299
  height: number;
package/dist/paper.js CHANGED
@@ -29,15 +29,180 @@ const NAMED_PAPERS = [
29
29
  "a1",
30
30
  "a0"
31
31
  ];
32
- const Paper = z.union([z.enum(NAMED_PAPERS), z.object({
32
+ const PAPER_GROUPS = [
33
+ "Office",
34
+ "Cards",
35
+ "Leaflets",
36
+ "Posters"
37
+ ];
38
+ const PAPER_METADATA = {
39
+ letter: {
40
+ name: "Letter",
41
+ group: "Office",
42
+ size: "8.5 × 11 in"
43
+ },
44
+ legal: {
45
+ name: "Legal",
46
+ group: "Office",
47
+ size: "8.5 × 14 in"
48
+ },
49
+ tabloid: {
50
+ name: "Tabloid",
51
+ group: "Office",
52
+ size: "11 × 17 in"
53
+ },
54
+ a3: {
55
+ name: "A3",
56
+ group: "Office",
57
+ size: "297 × 420 mm"
58
+ },
59
+ a4: {
60
+ name: "A4",
61
+ group: "Office",
62
+ size: "210 × 297 mm"
63
+ },
64
+ a5: {
65
+ name: "A5",
66
+ group: "Office",
67
+ size: "148 × 210 mm"
68
+ },
69
+ "business-card-us": {
70
+ name: "Business card (US)",
71
+ group: "Cards",
72
+ size: "3.5 × 2 in"
73
+ },
74
+ "business-card-eu": {
75
+ name: "Business card (EU)",
76
+ group: "Cards",
77
+ size: "85 × 55 mm"
78
+ },
79
+ "business-card-square-us": {
80
+ name: "Square business card (US)",
81
+ group: "Cards",
82
+ size: "2.5 × 2.5 in"
83
+ },
84
+ "business-card-slim-us": {
85
+ name: "Slim business card (US)",
86
+ group: "Cards",
87
+ size: "3.5 × 1.75 in"
88
+ },
89
+ "postcard-4x6": {
90
+ name: "Postcard",
91
+ group: "Cards",
92
+ size: "4 × 6 in"
93
+ },
94
+ "postcard-5x7": {
95
+ name: "Postcard",
96
+ group: "Cards",
97
+ size: "5 × 7 in"
98
+ },
99
+ "postcard-6x9": {
100
+ name: "Postcard",
101
+ group: "Cards",
102
+ size: "6 × 9 in"
103
+ },
104
+ "postcard-6x11": {
105
+ name: "Postcard",
106
+ group: "Cards",
107
+ size: "6 × 11 in"
108
+ },
109
+ "card-square-4in": {
110
+ name: "Square card",
111
+ group: "Cards",
112
+ size: "4 × 4 in"
113
+ },
114
+ "half-letter": {
115
+ name: "Half letter",
116
+ group: "Leaflets",
117
+ size: "5.5 × 8.5 in"
118
+ },
119
+ a6: {
120
+ name: "A6",
121
+ group: "Leaflets",
122
+ size: "105 × 148 mm"
123
+ },
124
+ dl: {
125
+ name: "DL",
126
+ group: "Leaflets",
127
+ size: "99 × 210 mm"
128
+ },
129
+ "rack-card-4x9": {
130
+ name: "Rack card",
131
+ group: "Leaflets",
132
+ size: "4 × 9 in"
133
+ },
134
+ "rack-card-3.5x8.5": {
135
+ name: "Rack card",
136
+ group: "Leaflets",
137
+ size: "3.5 × 8.5 in"
138
+ },
139
+ "poster-12x18": {
140
+ name: "Poster",
141
+ group: "Posters",
142
+ size: "12 × 18 in"
143
+ },
144
+ "poster-16x20": {
145
+ name: "Poster",
146
+ group: "Posters",
147
+ size: "16 × 20 in"
148
+ },
149
+ "poster-18x24": {
150
+ name: "Poster",
151
+ group: "Posters",
152
+ size: "18 × 24 in"
153
+ },
154
+ "poster-24x36": {
155
+ name: "Poster",
156
+ group: "Posters",
157
+ size: "24 × 36 in"
158
+ },
159
+ a2: {
160
+ name: "A2",
161
+ group: "Posters",
162
+ size: "420 × 594 mm"
163
+ },
164
+ a1: {
165
+ name: "A1",
166
+ group: "Posters",
167
+ size: "594 × 841 mm"
168
+ },
169
+ a0: {
170
+ name: "A0",
171
+ group: "Posters",
172
+ size: "841 × 1189 mm"
173
+ }
174
+ };
175
+ const CUSTOM_PAPER_MIN_MM = 10;
176
+ const CUSTOM_PAPER_MAX_MM = 2e3;
177
+ const PAPER_UNITS = [
178
+ "mm",
179
+ "in",
180
+ "pt"
181
+ ];
182
+ const PaperUnit = z.enum(PAPER_UNITS);
183
+ const ORIENTATIONS = ["portrait", "landscape"];
184
+ const Orientation = z.enum(ORIENTATIONS);
185
+ const CustomPaper = z.object({
33
186
  width: z.number().positive(),
34
187
  height: z.number().positive(),
35
- unit: z.enum([
36
- "mm",
37
- "in",
38
- "pt"
39
- ])
40
- })]);
188
+ unit: PaperUnit
189
+ }).superRefine((paper, ctx) => {
190
+ for (const side of ["width", "height"]) {
191
+ const millimeters = toMillimeters(paper[side], paper.unit);
192
+ if (millimeters < 10 || millimeters > 2e3) ctx.addIssue({
193
+ code: "custom",
194
+ path: [side],
195
+ message: `${side} must be between 10mm and ${CUSTOM_PAPER_MAX_MM}mm`
196
+ });
197
+ }
198
+ });
199
+ const Paper = z.union([z.enum(NAMED_PAPERS), CustomPaper]);
200
+ const PrintSettingShape = {
201
+ paper: Paper,
202
+ orientation: Orientation
203
+ };
204
+ const PrintSetting = z.object(PrintSettingShape);
205
+ const PrintSettingInput = z.strictObject(PrintSettingShape);
41
206
  const MM_PER_PT = 25.4 / 72;
42
207
  const MARK_LENGTH_MM = 5;
43
208
  const MARK_GAP_MM = 1;
@@ -45,6 +210,9 @@ const roundMillimeters = (mm) => Math.round(mm * 100) / 100;
45
210
  function toMillimeters(value, unit) {
46
211
  return value * (unit === "in" ? 25.4 : unit === "pt" ? MM_PER_PT : 1);
47
212
  }
213
+ function fromMillimeters(millimeters, unit) {
214
+ return millimeters / (unit === "in" ? 25.4 : unit === "pt" ? MM_PER_PT : 1);
215
+ }
48
216
  const PAPER_SIZE = {
49
217
  letter: {
50
218
  width: 8.5,
@@ -314,4 +482,4 @@ function printBoxes(print) {
314
482
  };
315
483
  }
316
484
  //#endregion
317
- export { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters };
485
+ export { CUSTOM_PAPER_MAX_MM, CUSTOM_PAPER_MIN_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, Paper, PaperUnit, PrintSetting, PrintSettingInput, fromMillimeters, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters };
@@ -0,0 +1,91 @@
1
+ import { z } from "zod";
2
+ //#region src/slots.d.ts
3
+ export declare const SLOT_TYPES: readonly ["text", "phone", "email", "link", "image"];
4
+ export declare const SlotType: z.ZodEnum<{
5
+ text: "text";
6
+ phone: "phone";
7
+ email: "email";
8
+ link: "link";
9
+ image: "image";
10
+ }>;
11
+ export type SlotType = z.infer<typeof SlotType>;
12
+ export declare const SlotDeclaration: z.ZodObject<{
13
+ key: z.ZodString;
14
+ label: z.ZodString;
15
+ type: z.ZodEnum<{
16
+ text: "text";
17
+ phone: "phone";
18
+ email: "email";
19
+ link: "link";
20
+ image: "image";
21
+ }>;
22
+ required: z.ZodDefault<z.ZodBoolean>;
23
+ placeholder: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>;
25
+ export type SlotDeclaration = z.infer<typeof SlotDeclaration>;
26
+ export declare const SlotDeclarationInput: z.ZodObject<{
27
+ key: z.ZodString;
28
+ label: z.ZodString;
29
+ type: z.ZodEnum<{
30
+ text: "text";
31
+ phone: "phone";
32
+ email: "email";
33
+ link: "link";
34
+ image: "image";
35
+ }>;
36
+ required: z.ZodDefault<z.ZodBoolean>;
37
+ placeholder: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strict>;
39
+ export type SlotDeclarationInput = z.input<typeof SlotDeclarationInput>;
40
+ export declare const Slots: z.ZodArray<z.ZodObject<{
41
+ key: z.ZodString;
42
+ label: z.ZodString;
43
+ type: z.ZodEnum<{
44
+ text: "text";
45
+ phone: "phone";
46
+ email: "email";
47
+ link: "link";
48
+ image: "image";
49
+ }>;
50
+ required: z.ZodDefault<z.ZodBoolean>;
51
+ placeholder: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strip>>;
53
+ export type Slots = z.infer<typeof Slots>;
54
+ export declare const SlotsInput: z.ZodArray<z.ZodObject<{
55
+ key: z.ZodString;
56
+ label: z.ZodString;
57
+ type: z.ZodEnum<{
58
+ text: "text";
59
+ phone: "phone";
60
+ email: "email";
61
+ link: "link";
62
+ image: "image";
63
+ }>;
64
+ required: z.ZodDefault<z.ZodBoolean>;
65
+ placeholder: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strict>>;
67
+ export type SlotsInput = z.input<typeof SlotsInput>;
68
+ export type SlotValue = string | {
69
+ asset: string;
70
+ };
71
+ export interface Fill {
72
+ id: string;
73
+ label?: string;
74
+ values: Record<string, SlotValue>;
75
+ }
76
+ export type SlotState = 'filled' | 'placeholder' | 'unavailable' | 'invalid';
77
+ export interface SlotReport {
78
+ fill: string | null;
79
+ slots: Record<string, SlotState>;
80
+ }
81
+ export interface SlotsOptions {
82
+ fill?: Fill;
83
+ declarations?: SlotDeclarationInput[];
84
+ /** Resolve an asset without network access. Hosts should honour the signal so timed-out renders stop this work promptly. */
85
+ resolveAsset?: (ref: string, options: {
86
+ signal: AbortSignal;
87
+ }) => Promise<string>;
88
+ report?: (report: SlotReport) => void;
89
+ }
90
+ export declare function mergeSlotDeclarations(...groups: ReadonlyArray<readonly SlotDeclaration[]>): SlotDeclaration[];
91
+ //#endregion
package/dist/slots.js ADDED
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ //#region src/slots.ts
3
+ const SLOT_TYPES = [
4
+ "text",
5
+ "phone",
6
+ "email",
7
+ "link",
8
+ "image"
9
+ ];
10
+ const SlotType = z.enum(SLOT_TYPES);
11
+ const SlotDeclarationShape = {
12
+ key: z.string().regex(/^[^.\s]+(?:\.[^.\s]+)*$/, "a slot key must be a dotted path"),
13
+ label: z.string().min(1),
14
+ type: SlotType,
15
+ required: z.boolean().default(false),
16
+ placeholder: z.string().optional()
17
+ };
18
+ const SlotDeclaration = z.object(SlotDeclarationShape);
19
+ const SlotDeclarationInput = z.strictObject(SlotDeclarationShape);
20
+ const Slots = z.array(SlotDeclaration).superRefine((slots, ctx) => {
21
+ const seen = /* @__PURE__ */ new Set();
22
+ slots.forEach((slot, index) => {
23
+ if (seen.has(slot.key)) ctx.addIssue({
24
+ code: "custom",
25
+ path: [index, "key"],
26
+ message: `slot key "${slot.key}" is used twice`
27
+ });
28
+ seen.add(slot.key);
29
+ });
30
+ });
31
+ const SlotsInput = z.array(SlotDeclarationInput).superRefine((slots, ctx) => {
32
+ const seen = /* @__PURE__ */ new Set();
33
+ slots.forEach((slot, index) => {
34
+ if (seen.has(slot.key)) ctx.addIssue({
35
+ code: "custom",
36
+ path: [index, "key"],
37
+ message: `slot key "${slot.key}" is used twice`
38
+ });
39
+ seen.add(slot.key);
40
+ });
41
+ });
42
+ function mergeSlotDeclarations(...groups) {
43
+ const merged = /* @__PURE__ */ new Map();
44
+ for (const slot of groups.flat()) {
45
+ const previous = merged.get(slot.key);
46
+ if (!previous) {
47
+ merged.set(slot.key, slot);
48
+ continue;
49
+ }
50
+ if (previous.type !== slot.type || previous.required !== slot.required) throw new RangeError(`Slot "${slot.key}" has conflicting declarations: type ${previous.type}, required ${previous.required}; type ${slot.type}, required ${slot.required}.`);
51
+ }
52
+ return [...merged.values()];
53
+ }
54
+ //#endregion
55
+ export { SLOT_TYPES, SlotDeclaration, SlotDeclarationInput, SlotType, Slots, SlotsInput, mergeSlotDeclarations };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segnavia/format",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {