@segnavia/format 0.20.0 → 0.21.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/book.js +2 -2
- package/dist/index.d.ts +90 -2
- package/dist/index.js +9 -10
- package/dist/paper.d.ts +250 -1
- package/dist/paper.js +176 -8
- package/package.json +1 -1
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:
|
|
28
|
+
orientation: Orientation.default("portrait"),
|
|
29
29
|
margin: z.object({
|
|
30
30
|
top: z.number().nonnegative(),
|
|
31
31
|
bottom: z.number().nonnegative(),
|
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";
|
|
@@ -178,6 +178,7 @@ export declare const PageSize: z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.Zod
|
|
|
178
178
|
}, z.core.$strip>]>;
|
|
179
179
|
export type PageSize = z.infer<typeof PageSize>;
|
|
180
180
|
export declare const Page: z.ZodObject<{
|
|
181
|
+
id: z.ZodOptional<z.ZodString>;
|
|
181
182
|
html: z.ZodString;
|
|
182
183
|
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
|
|
183
184
|
width: z.ZodNumber;
|
|
@@ -390,6 +391,7 @@ export declare function jsonSchemas(): {
|
|
|
390
391
|
html: z.ZodString;
|
|
391
392
|
}, z.core.$strip>>;
|
|
392
393
|
page: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
394
|
+
id: z.ZodOptional<z.ZodString>;
|
|
393
395
|
html: z.ZodString;
|
|
394
396
|
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
|
|
395
397
|
width: z.ZodNumber;
|
|
@@ -858,6 +860,92 @@ export declare function jsonSchemas(): {
|
|
|
858
860
|
}, z.core.$strip>>>;
|
|
859
861
|
}, z.core.$strip>>;
|
|
860
862
|
}, z.core.$strip>>;
|
|
863
|
+
printSetting: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
864
|
+
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
865
|
+
letter: "letter";
|
|
866
|
+
legal: "legal";
|
|
867
|
+
tabloid: "tabloid";
|
|
868
|
+
a3: "a3";
|
|
869
|
+
a4: "a4";
|
|
870
|
+
a5: "a5";
|
|
871
|
+
"business-card-us": "business-card-us";
|
|
872
|
+
"business-card-eu": "business-card-eu";
|
|
873
|
+
"business-card-square-us": "business-card-square-us";
|
|
874
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
875
|
+
"postcard-4x6": "postcard-4x6";
|
|
876
|
+
"postcard-5x7": "postcard-5x7";
|
|
877
|
+
"postcard-6x9": "postcard-6x9";
|
|
878
|
+
"postcard-6x11": "postcard-6x11";
|
|
879
|
+
"card-square-4in": "card-square-4in";
|
|
880
|
+
"half-letter": "half-letter";
|
|
881
|
+
a6: "a6";
|
|
882
|
+
dl: "dl";
|
|
883
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
884
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
885
|
+
"poster-12x18": "poster-12x18";
|
|
886
|
+
"poster-16x20": "poster-16x20";
|
|
887
|
+
"poster-18x24": "poster-18x24";
|
|
888
|
+
"poster-24x36": "poster-24x36";
|
|
889
|
+
a2: "a2";
|
|
890
|
+
a1: "a1";
|
|
891
|
+
a0: "a0";
|
|
892
|
+
}>, z.ZodObject<{
|
|
893
|
+
width: z.ZodNumber;
|
|
894
|
+
height: z.ZodNumber;
|
|
895
|
+
unit: z.ZodEnum<{
|
|
896
|
+
mm: "mm";
|
|
897
|
+
in: "in";
|
|
898
|
+
pt: "pt";
|
|
899
|
+
}>;
|
|
900
|
+
}, z.core.$strip>]>;
|
|
901
|
+
orientation: z.ZodEnum<{
|
|
902
|
+
portrait: "portrait";
|
|
903
|
+
landscape: "landscape";
|
|
904
|
+
}>;
|
|
905
|
+
}, z.core.$strip>>;
|
|
906
|
+
printSettingInput: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
907
|
+
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
908
|
+
letter: "letter";
|
|
909
|
+
legal: "legal";
|
|
910
|
+
tabloid: "tabloid";
|
|
911
|
+
a3: "a3";
|
|
912
|
+
a4: "a4";
|
|
913
|
+
a5: "a5";
|
|
914
|
+
"business-card-us": "business-card-us";
|
|
915
|
+
"business-card-eu": "business-card-eu";
|
|
916
|
+
"business-card-square-us": "business-card-square-us";
|
|
917
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
918
|
+
"postcard-4x6": "postcard-4x6";
|
|
919
|
+
"postcard-5x7": "postcard-5x7";
|
|
920
|
+
"postcard-6x9": "postcard-6x9";
|
|
921
|
+
"postcard-6x11": "postcard-6x11";
|
|
922
|
+
"card-square-4in": "card-square-4in";
|
|
923
|
+
"half-letter": "half-letter";
|
|
924
|
+
a6: "a6";
|
|
925
|
+
dl: "dl";
|
|
926
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
927
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
928
|
+
"poster-12x18": "poster-12x18";
|
|
929
|
+
"poster-16x20": "poster-16x20";
|
|
930
|
+
"poster-18x24": "poster-18x24";
|
|
931
|
+
"poster-24x36": "poster-24x36";
|
|
932
|
+
a2: "a2";
|
|
933
|
+
a1: "a1";
|
|
934
|
+
a0: "a0";
|
|
935
|
+
}>, z.ZodObject<{
|
|
936
|
+
width: z.ZodNumber;
|
|
937
|
+
height: z.ZodNumber;
|
|
938
|
+
unit: z.ZodEnum<{
|
|
939
|
+
mm: "mm";
|
|
940
|
+
in: "in";
|
|
941
|
+
pt: "pt";
|
|
942
|
+
}>;
|
|
943
|
+
}, z.core.$strip>]>;
|
|
944
|
+
orientation: z.ZodEnum<{
|
|
945
|
+
portrait: "portrait";
|
|
946
|
+
landscape: "landscape";
|
|
947
|
+
}>;
|
|
948
|
+
}, z.core.$strict>>;
|
|
861
949
|
};
|
|
862
950
|
//#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 };
|
|
951
|
+
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, 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, 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, fromMillimeters, 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 };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSIT
|
|
|
5
5
|
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
6
|
import { Board, BoardItem, BoardLabel, BoardSection, GridCell } from "./board.js";
|
|
7
7
|
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";
|
|
8
|
+
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
9
|
import { Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookShape, BookView, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
10
10
|
import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
|
|
11
11
|
import { MIN_BOARD_ITEM_WIDTH, addItem, moveItems, moveSection, removeItems, resizeItem } from "./board-edit.js";
|
|
@@ -27,7 +27,7 @@ const Margin = z.object({
|
|
|
27
27
|
});
|
|
28
28
|
const Print = z.object({
|
|
29
29
|
paper: Paper,
|
|
30
|
-
orientation:
|
|
30
|
+
orientation: Orientation.default("portrait"),
|
|
31
31
|
margin: Margin.optional(),
|
|
32
32
|
bleed: z.number().nonnegative().default(0),
|
|
33
33
|
safe: z.number().nonnegative().default(0),
|
|
@@ -52,12 +52,8 @@ const ImpositionGap = z.object({
|
|
|
52
52
|
const MAX_IMPOSITION_CELLS = 1e4;
|
|
53
53
|
const Imposition = z.object({
|
|
54
54
|
paper: Paper,
|
|
55
|
-
orientation:
|
|
56
|
-
unit:
|
|
57
|
-
"mm",
|
|
58
|
-
"in",
|
|
59
|
-
"pt"
|
|
60
|
-
]).default("mm"),
|
|
55
|
+
orientation: Orientation.default("portrait"),
|
|
56
|
+
unit: PaperUnit.default("mm"),
|
|
61
57
|
margin: Margin.default({
|
|
62
58
|
top: 0,
|
|
63
59
|
right: 0,
|
|
@@ -138,6 +134,7 @@ const PageSize = z.union([
|
|
|
138
134
|
})
|
|
139
135
|
]);
|
|
140
136
|
const Page = z.object({
|
|
137
|
+
id: z.string().optional(),
|
|
141
138
|
html: z.string(),
|
|
142
139
|
size: PageSize.default("fluid"),
|
|
143
140
|
scripts: Scripts.default("refuse"),
|
|
@@ -155,8 +152,10 @@ function jsonSchemas() {
|
|
|
155
152
|
deck: z.toJSONSchema(DeckShape, { io: "input" }),
|
|
156
153
|
manifest: z.toJSONSchema(Manifest, { io: "input" }),
|
|
157
154
|
publishedShot: z.toJSONSchema(PublishedShot, { io: "input" }),
|
|
158
|
-
board: z.toJSONSchema(Board, { io: "input" })
|
|
155
|
+
board: z.toJSONSchema(Board, { io: "input" }),
|
|
156
|
+
printSetting: z.toJSONSchema(PrintSetting, { io: "input" }),
|
|
157
|
+
printSettingInput: z.toJSONSchema(PrintSettingInput, { io: "input" })
|
|
159
158
|
};
|
|
160
159
|
}
|
|
161
160
|
//#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 };
|
|
161
|
+
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, 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, fromMillimeters, 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 };
|
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:
|
|
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
|
|
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:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 };
|