@segnavia/format 0.17.0 → 0.19.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.d.ts +44 -2
- package/dist/deck-from-slides.d.ts +1 -0
- package/dist/deck-from-slides.js +4 -2
- package/dist/deck.d.ts +2 -0
- package/dist/deck.js +2 -1
- package/dist/index.d.ts +127 -0
- package/dist/paper.d.ts +24 -3
- package/dist/paper.js +155 -15
- package/package.json +1 -1
package/dist/book.d.ts
CHANGED
|
@@ -40,6 +40,27 @@ export declare const BookPage: z.ZodObject<{
|
|
|
40
40
|
a3: "a3";
|
|
41
41
|
a4: "a4";
|
|
42
42
|
a5: "a5";
|
|
43
|
+
"business-card-us": "business-card-us";
|
|
44
|
+
"business-card-eu": "business-card-eu";
|
|
45
|
+
"business-card-square-us": "business-card-square-us";
|
|
46
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
47
|
+
"postcard-4x6": "postcard-4x6";
|
|
48
|
+
"postcard-5x7": "postcard-5x7";
|
|
49
|
+
"postcard-6x9": "postcard-6x9";
|
|
50
|
+
"postcard-6x11": "postcard-6x11";
|
|
51
|
+
"card-square-4in": "card-square-4in";
|
|
52
|
+
"half-letter": "half-letter";
|
|
53
|
+
a6: "a6";
|
|
54
|
+
dl: "dl";
|
|
55
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
56
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
57
|
+
"poster-12x18": "poster-12x18";
|
|
58
|
+
"poster-16x20": "poster-16x20";
|
|
59
|
+
"poster-18x24": "poster-18x24";
|
|
60
|
+
"poster-24x36": "poster-24x36";
|
|
61
|
+
a2: "a2";
|
|
62
|
+
a1: "a1";
|
|
63
|
+
a0: "a0";
|
|
43
64
|
}>, z.ZodObject<{
|
|
44
65
|
width: z.ZodNumber;
|
|
45
66
|
height: z.ZodNumber;
|
|
@@ -92,6 +113,27 @@ export declare const Book: z.ZodPipe<z.ZodObject<{
|
|
|
92
113
|
a3: "a3";
|
|
93
114
|
a4: "a4";
|
|
94
115
|
a5: "a5";
|
|
116
|
+
"business-card-us": "business-card-us";
|
|
117
|
+
"business-card-eu": "business-card-eu";
|
|
118
|
+
"business-card-square-us": "business-card-square-us";
|
|
119
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
120
|
+
"postcard-4x6": "postcard-4x6";
|
|
121
|
+
"postcard-5x7": "postcard-5x7";
|
|
122
|
+
"postcard-6x9": "postcard-6x9";
|
|
123
|
+
"postcard-6x11": "postcard-6x11";
|
|
124
|
+
"card-square-4in": "card-square-4in";
|
|
125
|
+
"half-letter": "half-letter";
|
|
126
|
+
a6: "a6";
|
|
127
|
+
dl: "dl";
|
|
128
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
129
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
130
|
+
"poster-12x18": "poster-12x18";
|
|
131
|
+
"poster-16x20": "poster-16x20";
|
|
132
|
+
"poster-18x24": "poster-18x24";
|
|
133
|
+
"poster-24x36": "poster-24x36";
|
|
134
|
+
a2: "a2";
|
|
135
|
+
a1: "a1";
|
|
136
|
+
a0: "a0";
|
|
95
137
|
}>, z.ZodObject<{
|
|
96
138
|
width: z.ZodNumber;
|
|
97
139
|
height: z.ZodNumber;
|
|
@@ -215,7 +257,7 @@ export declare const Book: z.ZodPipe<z.ZodObject<{
|
|
|
215
257
|
depth: number;
|
|
216
258
|
};
|
|
217
259
|
page?: {
|
|
218
|
-
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | {
|
|
260
|
+
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" | {
|
|
219
261
|
width: number;
|
|
220
262
|
height: number;
|
|
221
263
|
unit: "mm" | "in" | "pt";
|
|
@@ -266,7 +308,7 @@ export declare const Book: z.ZodPipe<z.ZodObject<{
|
|
|
266
308
|
depth: number;
|
|
267
309
|
};
|
|
268
310
|
page?: {
|
|
269
|
-
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | {
|
|
311
|
+
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" | {
|
|
270
312
|
width: number;
|
|
271
313
|
height: number;
|
|
272
314
|
unit: "mm" | "in" | "pt";
|
|
@@ -112,6 +112,7 @@ export declare function deckFromSlides(rows: SlideRow[], options: DeckFromSlides
|
|
|
112
112
|
beforeMs?: number | undefined;
|
|
113
113
|
afterMs?: number | undefined;
|
|
114
114
|
holdMs?: number | undefined;
|
|
115
|
+
printAtMs?: number | undefined;
|
|
115
116
|
}[];
|
|
116
117
|
dir?: "ltr" | "rtl" | "auto" | undefined;
|
|
117
118
|
lang?: string | undefined;
|
package/dist/deck-from-slides.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Deck } from "./deck.js";
|
|
2
2
|
//#region src/deck-from-slides.ts
|
|
3
|
+
const optionalPrintAt = (printAtMs) => printAtMs === void 0 ? {} : { printAtMs };
|
|
3
4
|
function deckFromSlides(rows, options) {
|
|
4
5
|
const { omitNotes = false, ...deckOptions } = options;
|
|
5
6
|
const slides = rows.map(({ kind, ...row }) => {
|
|
6
|
-
const { id, notes, narration, beforeMs, afterMs, holdMs } = row;
|
|
7
|
+
const { id, notes, narration, beforeMs, afterMs, holdMs, printAtMs } = row;
|
|
7
8
|
const common = {
|
|
8
9
|
id,
|
|
9
10
|
...!omitNotes && notes !== void 0 ? { notes } : {},
|
|
10
11
|
...narration !== void 0 ? { narration } : {},
|
|
11
12
|
...beforeMs !== void 0 ? { beforeMs } : {},
|
|
12
13
|
...afterMs !== void 0 ? { afterMs } : {},
|
|
13
|
-
...holdMs !== void 0 ? { holdMs } : {}
|
|
14
|
+
...holdMs !== void 0 ? { holdMs } : {},
|
|
15
|
+
...optionalPrintAt(printAtMs)
|
|
14
16
|
};
|
|
15
17
|
return kind === "html" ? {
|
|
16
18
|
...common,
|
package/dist/deck.d.ts
CHANGED
|
@@ -379,6 +379,7 @@ export declare const Slide: z.ZodObject<{
|
|
|
379
379
|
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
380
380
|
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
381
381
|
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
382
|
+
printAtMs: z.ZodOptional<z.ZodNumber>;
|
|
382
383
|
}, z.core.$strip>;
|
|
383
384
|
export type Slide = z.infer<typeof Slide>;
|
|
384
385
|
export declare const DECK_SIZE: {
|
|
@@ -549,6 +550,7 @@ export declare const Deck: z.ZodObject<{
|
|
|
549
550
|
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
550
551
|
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
551
552
|
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
553
|
+
printAtMs: z.ZodOptional<z.ZodNumber>;
|
|
552
554
|
}, z.core.$strip>>;
|
|
553
555
|
}, z.core.$strip>;
|
|
554
556
|
export type Deck = z.infer<typeof Deck>;
|
package/dist/deck.js
CHANGED
|
@@ -113,7 +113,8 @@ const Slide = z.object({
|
|
|
113
113
|
narration: Narration.optional(),
|
|
114
114
|
beforeMs: SlideTiming.optional(),
|
|
115
115
|
afterMs: SlideTiming.optional(),
|
|
116
|
-
holdMs: SlideTiming.optional()
|
|
116
|
+
holdMs: SlideTiming.optional(),
|
|
117
|
+
printAtMs: z.number().nonnegative().optional()
|
|
117
118
|
});
|
|
118
119
|
const DECK_SIZE = {
|
|
119
120
|
width: 1280,
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,27 @@ export declare const Print: z.ZodObject<{
|
|
|
33
33
|
a3: "a3";
|
|
34
34
|
a4: "a4";
|
|
35
35
|
a5: "a5";
|
|
36
|
+
"business-card-us": "business-card-us";
|
|
37
|
+
"business-card-eu": "business-card-eu";
|
|
38
|
+
"business-card-square-us": "business-card-square-us";
|
|
39
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
40
|
+
"postcard-4x6": "postcard-4x6";
|
|
41
|
+
"postcard-5x7": "postcard-5x7";
|
|
42
|
+
"postcard-6x9": "postcard-6x9";
|
|
43
|
+
"postcard-6x11": "postcard-6x11";
|
|
44
|
+
"card-square-4in": "card-square-4in";
|
|
45
|
+
"half-letter": "half-letter";
|
|
46
|
+
a6: "a6";
|
|
47
|
+
dl: "dl";
|
|
48
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
49
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
50
|
+
"poster-12x18": "poster-12x18";
|
|
51
|
+
"poster-16x20": "poster-16x20";
|
|
52
|
+
"poster-18x24": "poster-18x24";
|
|
53
|
+
"poster-24x36": "poster-24x36";
|
|
54
|
+
a2: "a2";
|
|
55
|
+
a1: "a1";
|
|
56
|
+
a0: "a0";
|
|
36
57
|
}>, z.ZodObject<{
|
|
37
58
|
width: z.ZodNumber;
|
|
38
59
|
height: z.ZodNumber;
|
|
@@ -67,6 +88,27 @@ export declare const Imposition: z.ZodObject<{
|
|
|
67
88
|
a3: "a3";
|
|
68
89
|
a4: "a4";
|
|
69
90
|
a5: "a5";
|
|
91
|
+
"business-card-us": "business-card-us";
|
|
92
|
+
"business-card-eu": "business-card-eu";
|
|
93
|
+
"business-card-square-us": "business-card-square-us";
|
|
94
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
95
|
+
"postcard-4x6": "postcard-4x6";
|
|
96
|
+
"postcard-5x7": "postcard-5x7";
|
|
97
|
+
"postcard-6x9": "postcard-6x9";
|
|
98
|
+
"postcard-6x11": "postcard-6x11";
|
|
99
|
+
"card-square-4in": "card-square-4in";
|
|
100
|
+
"half-letter": "half-letter";
|
|
101
|
+
a6: "a6";
|
|
102
|
+
dl: "dl";
|
|
103
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
104
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
105
|
+
"poster-12x18": "poster-12x18";
|
|
106
|
+
"poster-16x20": "poster-16x20";
|
|
107
|
+
"poster-18x24": "poster-18x24";
|
|
108
|
+
"poster-24x36": "poster-24x36";
|
|
109
|
+
a2: "a2";
|
|
110
|
+
a1: "a1";
|
|
111
|
+
a0: "a0";
|
|
70
112
|
}>, z.ZodObject<{
|
|
71
113
|
width: z.ZodNumber;
|
|
72
114
|
height: z.ZodNumber;
|
|
@@ -162,6 +204,27 @@ export declare const Page: z.ZodObject<{
|
|
|
162
204
|
a3: "a3";
|
|
163
205
|
a4: "a4";
|
|
164
206
|
a5: "a5";
|
|
207
|
+
"business-card-us": "business-card-us";
|
|
208
|
+
"business-card-eu": "business-card-eu";
|
|
209
|
+
"business-card-square-us": "business-card-square-us";
|
|
210
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
211
|
+
"postcard-4x6": "postcard-4x6";
|
|
212
|
+
"postcard-5x7": "postcard-5x7";
|
|
213
|
+
"postcard-6x9": "postcard-6x9";
|
|
214
|
+
"postcard-6x11": "postcard-6x11";
|
|
215
|
+
"card-square-4in": "card-square-4in";
|
|
216
|
+
"half-letter": "half-letter";
|
|
217
|
+
a6: "a6";
|
|
218
|
+
dl: "dl";
|
|
219
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
220
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
221
|
+
"poster-12x18": "poster-12x18";
|
|
222
|
+
"poster-16x20": "poster-16x20";
|
|
223
|
+
"poster-18x24": "poster-18x24";
|
|
224
|
+
"poster-24x36": "poster-24x36";
|
|
225
|
+
a2: "a2";
|
|
226
|
+
a1: "a1";
|
|
227
|
+
a0: "a0";
|
|
165
228
|
}>, z.ZodObject<{
|
|
166
229
|
width: z.ZodNumber;
|
|
167
230
|
height: z.ZodNumber;
|
|
@@ -203,6 +266,27 @@ export declare function jsonSchemas(): {
|
|
|
203
266
|
a3: "a3";
|
|
204
267
|
a4: "a4";
|
|
205
268
|
a5: "a5";
|
|
269
|
+
"business-card-us": "business-card-us";
|
|
270
|
+
"business-card-eu": "business-card-eu";
|
|
271
|
+
"business-card-square-us": "business-card-square-us";
|
|
272
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
273
|
+
"postcard-4x6": "postcard-4x6";
|
|
274
|
+
"postcard-5x7": "postcard-5x7";
|
|
275
|
+
"postcard-6x9": "postcard-6x9";
|
|
276
|
+
"postcard-6x11": "postcard-6x11";
|
|
277
|
+
"card-square-4in": "card-square-4in";
|
|
278
|
+
"half-letter": "half-letter";
|
|
279
|
+
a6: "a6";
|
|
280
|
+
dl: "dl";
|
|
281
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
282
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
283
|
+
"poster-12x18": "poster-12x18";
|
|
284
|
+
"poster-16x20": "poster-16x20";
|
|
285
|
+
"poster-18x24": "poster-18x24";
|
|
286
|
+
"poster-24x36": "poster-24x36";
|
|
287
|
+
a2: "a2";
|
|
288
|
+
a1: "a1";
|
|
289
|
+
a0: "a0";
|
|
206
290
|
}>, z.ZodObject<{
|
|
207
291
|
width: z.ZodNumber;
|
|
208
292
|
height: z.ZodNumber;
|
|
@@ -332,6 +416,27 @@ export declare function jsonSchemas(): {
|
|
|
332
416
|
a3: "a3";
|
|
333
417
|
a4: "a4";
|
|
334
418
|
a5: "a5";
|
|
419
|
+
"business-card-us": "business-card-us";
|
|
420
|
+
"business-card-eu": "business-card-eu";
|
|
421
|
+
"business-card-square-us": "business-card-square-us";
|
|
422
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
423
|
+
"postcard-4x6": "postcard-4x6";
|
|
424
|
+
"postcard-5x7": "postcard-5x7";
|
|
425
|
+
"postcard-6x9": "postcard-6x9";
|
|
426
|
+
"postcard-6x11": "postcard-6x11";
|
|
427
|
+
"card-square-4in": "card-square-4in";
|
|
428
|
+
"half-letter": "half-letter";
|
|
429
|
+
a6: "a6";
|
|
430
|
+
dl: "dl";
|
|
431
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
432
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
433
|
+
"poster-12x18": "poster-12x18";
|
|
434
|
+
"poster-16x20": "poster-16x20";
|
|
435
|
+
"poster-18x24": "poster-18x24";
|
|
436
|
+
"poster-24x36": "poster-24x36";
|
|
437
|
+
a2: "a2";
|
|
438
|
+
a1: "a1";
|
|
439
|
+
a0: "a0";
|
|
335
440
|
}>, z.ZodObject<{
|
|
336
441
|
width: z.ZodNumber;
|
|
337
442
|
height: z.ZodNumber;
|
|
@@ -371,6 +476,27 @@ export declare function jsonSchemas(): {
|
|
|
371
476
|
a3: "a3";
|
|
372
477
|
a4: "a4";
|
|
373
478
|
a5: "a5";
|
|
479
|
+
"business-card-us": "business-card-us";
|
|
480
|
+
"business-card-eu": "business-card-eu";
|
|
481
|
+
"business-card-square-us": "business-card-square-us";
|
|
482
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
483
|
+
"postcard-4x6": "postcard-4x6";
|
|
484
|
+
"postcard-5x7": "postcard-5x7";
|
|
485
|
+
"postcard-6x9": "postcard-6x9";
|
|
486
|
+
"postcard-6x11": "postcard-6x11";
|
|
487
|
+
"card-square-4in": "card-square-4in";
|
|
488
|
+
"half-letter": "half-letter";
|
|
489
|
+
a6: "a6";
|
|
490
|
+
dl: "dl";
|
|
491
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
492
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
493
|
+
"poster-12x18": "poster-12x18";
|
|
494
|
+
"poster-16x20": "poster-16x20";
|
|
495
|
+
"poster-18x24": "poster-18x24";
|
|
496
|
+
"poster-24x36": "poster-24x36";
|
|
497
|
+
a2: "a2";
|
|
498
|
+
a1: "a1";
|
|
499
|
+
a0: "a0";
|
|
374
500
|
}>, z.ZodObject<{
|
|
375
501
|
width: z.ZodNumber;
|
|
376
502
|
height: z.ZodNumber;
|
|
@@ -585,6 +711,7 @@ export declare function jsonSchemas(): {
|
|
|
585
711
|
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
586
712
|
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
587
713
|
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
714
|
+
printAtMs: z.ZodOptional<z.ZodNumber>;
|
|
588
715
|
}, z.core.$strip>>;
|
|
589
716
|
}, z.core.$strip>>;
|
|
590
717
|
manifest: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
package/dist/paper.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Print } from "./index.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/paper.d.ts
|
|
4
|
-
export declare const NAMED_PAPERS: readonly ["letter", "legal", "tabloid", "a3", "a4", "a5"];
|
|
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
5
|
export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
6
6
|
letter: "letter";
|
|
7
7
|
legal: "legal";
|
|
@@ -9,6 +9,27 @@ export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
9
9
|
a3: "a3";
|
|
10
10
|
a4: "a4";
|
|
11
11
|
a5: "a5";
|
|
12
|
+
"business-card-us": "business-card-us";
|
|
13
|
+
"business-card-eu": "business-card-eu";
|
|
14
|
+
"business-card-square-us": "business-card-square-us";
|
|
15
|
+
"business-card-slim-us": "business-card-slim-us";
|
|
16
|
+
"postcard-4x6": "postcard-4x6";
|
|
17
|
+
"postcard-5x7": "postcard-5x7";
|
|
18
|
+
"postcard-6x9": "postcard-6x9";
|
|
19
|
+
"postcard-6x11": "postcard-6x11";
|
|
20
|
+
"card-square-4in": "card-square-4in";
|
|
21
|
+
"half-letter": "half-letter";
|
|
22
|
+
a6: "a6";
|
|
23
|
+
dl: "dl";
|
|
24
|
+
"rack-card-4x9": "rack-card-4x9";
|
|
25
|
+
"rack-card-3.5x8.5": "rack-card-3.5x8.5";
|
|
26
|
+
"poster-12x18": "poster-12x18";
|
|
27
|
+
"poster-16x20": "poster-16x20";
|
|
28
|
+
"poster-18x24": "poster-18x24";
|
|
29
|
+
"poster-24x36": "poster-24x36";
|
|
30
|
+
a2: "a2";
|
|
31
|
+
a1: "a1";
|
|
32
|
+
a0: "a0";
|
|
12
33
|
}>, z.ZodObject<{
|
|
13
34
|
width: z.ZodNumber;
|
|
14
35
|
height: z.ZodNumber;
|
|
@@ -22,12 +43,12 @@ export type Paper = z.infer<typeof Paper>;
|
|
|
22
43
|
export declare const MM_PER_PT: number;
|
|
23
44
|
export declare const MARK_LENGTH_MM = 5;
|
|
24
45
|
export declare const MARK_GAP_MM = 1;
|
|
46
|
+
export declare const roundMillimeters: (mm: number) => number;
|
|
47
|
+
export declare function toMillimeters(value: number, unit: 'mm' | 'in' | 'pt'): number;
|
|
25
48
|
export declare const PAPER_MM: Record<Extract<Paper, string>, {
|
|
26
49
|
width: number;
|
|
27
50
|
height: number;
|
|
28
51
|
}>;
|
|
29
|
-
export declare const roundMillimeters: (mm: number) => number;
|
|
30
|
-
export declare function toMillimeters(value: number, unit: 'mm' | 'in' | 'pt'): number;
|
|
31
52
|
export declare function sheetMm(print: Pick<Print, 'paper' | 'orientation'>): {
|
|
32
53
|
width: number;
|
|
33
54
|
height: number;
|
package/dist/paper.js
CHANGED
|
@@ -6,7 +6,28 @@ const NAMED_PAPERS = [
|
|
|
6
6
|
"tabloid",
|
|
7
7
|
"a3",
|
|
8
8
|
"a4",
|
|
9
|
-
"a5"
|
|
9
|
+
"a5",
|
|
10
|
+
"business-card-us",
|
|
11
|
+
"business-card-eu",
|
|
12
|
+
"business-card-square-us",
|
|
13
|
+
"business-card-slim-us",
|
|
14
|
+
"postcard-4x6",
|
|
15
|
+
"postcard-5x7",
|
|
16
|
+
"postcard-6x9",
|
|
17
|
+
"postcard-6x11",
|
|
18
|
+
"card-square-4in",
|
|
19
|
+
"half-letter",
|
|
20
|
+
"a6",
|
|
21
|
+
"dl",
|
|
22
|
+
"rack-card-4x9",
|
|
23
|
+
"rack-card-3.5x8.5",
|
|
24
|
+
"poster-12x18",
|
|
25
|
+
"poster-16x20",
|
|
26
|
+
"poster-18x24",
|
|
27
|
+
"poster-24x36",
|
|
28
|
+
"a2",
|
|
29
|
+
"a1",
|
|
30
|
+
"a0"
|
|
10
31
|
];
|
|
11
32
|
const Paper = z.union([z.enum(NAMED_PAPERS), z.object({
|
|
12
33
|
width: z.number().positive(),
|
|
@@ -20,36 +41,155 @@ const Paper = z.union([z.enum(NAMED_PAPERS), z.object({
|
|
|
20
41
|
const MM_PER_PT = 25.4 / 72;
|
|
21
42
|
const MARK_LENGTH_MM = 5;
|
|
22
43
|
const MARK_GAP_MM = 1;
|
|
23
|
-
const
|
|
44
|
+
const roundMillimeters = (mm) => Math.round(mm * 100) / 100;
|
|
45
|
+
function toMillimeters(value, unit) {
|
|
46
|
+
return value * (unit === "in" ? 25.4 : unit === "pt" ? MM_PER_PT : 1);
|
|
47
|
+
}
|
|
48
|
+
const PAPER_SIZE = {
|
|
24
49
|
letter: {
|
|
25
|
-
width:
|
|
26
|
-
height:
|
|
50
|
+
width: 8.5,
|
|
51
|
+
height: 11,
|
|
52
|
+
unit: "in"
|
|
27
53
|
},
|
|
28
54
|
legal: {
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
55
|
+
width: 8.5,
|
|
56
|
+
height: 14,
|
|
57
|
+
unit: "in"
|
|
31
58
|
},
|
|
32
59
|
tabloid: {
|
|
33
|
-
width:
|
|
34
|
-
height:
|
|
60
|
+
width: 11,
|
|
61
|
+
height: 17,
|
|
62
|
+
unit: "in"
|
|
35
63
|
},
|
|
36
64
|
a3: {
|
|
37
65
|
width: 297,
|
|
38
|
-
height: 420
|
|
66
|
+
height: 420,
|
|
67
|
+
unit: "mm"
|
|
39
68
|
},
|
|
40
69
|
a4: {
|
|
41
70
|
width: 210,
|
|
42
|
-
height: 297
|
|
71
|
+
height: 297,
|
|
72
|
+
unit: "mm"
|
|
43
73
|
},
|
|
44
74
|
a5: {
|
|
45
75
|
width: 148,
|
|
46
|
-
height: 210
|
|
76
|
+
height: 210,
|
|
77
|
+
unit: "mm"
|
|
78
|
+
},
|
|
79
|
+
"business-card-us": {
|
|
80
|
+
width: 2,
|
|
81
|
+
height: 3.5,
|
|
82
|
+
unit: "in"
|
|
83
|
+
},
|
|
84
|
+
"business-card-eu": {
|
|
85
|
+
width: 55,
|
|
86
|
+
height: 85,
|
|
87
|
+
unit: "mm"
|
|
88
|
+
},
|
|
89
|
+
"business-card-square-us": {
|
|
90
|
+
width: 2.5,
|
|
91
|
+
height: 2.5,
|
|
92
|
+
unit: "in"
|
|
93
|
+
},
|
|
94
|
+
"business-card-slim-us": {
|
|
95
|
+
width: 1.75,
|
|
96
|
+
height: 3.5,
|
|
97
|
+
unit: "in"
|
|
98
|
+
},
|
|
99
|
+
"postcard-4x6": {
|
|
100
|
+
width: 4,
|
|
101
|
+
height: 6,
|
|
102
|
+
unit: "in"
|
|
103
|
+
},
|
|
104
|
+
"postcard-5x7": {
|
|
105
|
+
width: 5,
|
|
106
|
+
height: 7,
|
|
107
|
+
unit: "in"
|
|
108
|
+
},
|
|
109
|
+
"postcard-6x9": {
|
|
110
|
+
width: 6,
|
|
111
|
+
height: 9,
|
|
112
|
+
unit: "in"
|
|
113
|
+
},
|
|
114
|
+
"postcard-6x11": {
|
|
115
|
+
width: 6,
|
|
116
|
+
height: 11,
|
|
117
|
+
unit: "in"
|
|
118
|
+
},
|
|
119
|
+
"card-square-4in": {
|
|
120
|
+
width: 4,
|
|
121
|
+
height: 4,
|
|
122
|
+
unit: "in"
|
|
123
|
+
},
|
|
124
|
+
"half-letter": {
|
|
125
|
+
width: 5.5,
|
|
126
|
+
height: 8.5,
|
|
127
|
+
unit: "in"
|
|
128
|
+
},
|
|
129
|
+
a6: {
|
|
130
|
+
width: 105,
|
|
131
|
+
height: 148,
|
|
132
|
+
unit: "mm"
|
|
133
|
+
},
|
|
134
|
+
dl: {
|
|
135
|
+
width: 99,
|
|
136
|
+
height: 210,
|
|
137
|
+
unit: "mm"
|
|
138
|
+
},
|
|
139
|
+
"rack-card-4x9": {
|
|
140
|
+
width: 4,
|
|
141
|
+
height: 9,
|
|
142
|
+
unit: "in"
|
|
143
|
+
},
|
|
144
|
+
"rack-card-3.5x8.5": {
|
|
145
|
+
width: 3.5,
|
|
146
|
+
height: 8.5,
|
|
147
|
+
unit: "in"
|
|
148
|
+
},
|
|
149
|
+
"poster-12x18": {
|
|
150
|
+
width: 12,
|
|
151
|
+
height: 18,
|
|
152
|
+
unit: "in"
|
|
153
|
+
},
|
|
154
|
+
"poster-16x20": {
|
|
155
|
+
width: 16,
|
|
156
|
+
height: 20,
|
|
157
|
+
unit: "in"
|
|
158
|
+
},
|
|
159
|
+
"poster-18x24": {
|
|
160
|
+
width: 18,
|
|
161
|
+
height: 24,
|
|
162
|
+
unit: "in"
|
|
163
|
+
},
|
|
164
|
+
"poster-24x36": {
|
|
165
|
+
width: 24,
|
|
166
|
+
height: 36,
|
|
167
|
+
unit: "in"
|
|
168
|
+
},
|
|
169
|
+
a2: {
|
|
170
|
+
width: 420,
|
|
171
|
+
height: 594,
|
|
172
|
+
unit: "mm"
|
|
173
|
+
},
|
|
174
|
+
a1: {
|
|
175
|
+
width: 594,
|
|
176
|
+
height: 841,
|
|
177
|
+
unit: "mm"
|
|
178
|
+
},
|
|
179
|
+
a0: {
|
|
180
|
+
width: 841,
|
|
181
|
+
height: 1189,
|
|
182
|
+
unit: "mm"
|
|
47
183
|
}
|
|
48
184
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
|
|
185
|
+
const paperMillimeters = () => Object.fromEntries(NAMED_PAPERS.map((paper) => {
|
|
186
|
+
const { width, height, unit } = PAPER_SIZE[paper];
|
|
187
|
+
return [paper, {
|
|
188
|
+
width: roundMillimeters(toMillimeters(width, unit)),
|
|
189
|
+
height: roundMillimeters(toMillimeters(height, unit))
|
|
190
|
+
}];
|
|
191
|
+
}));
|
|
192
|
+
const PAPER_MM = paperMillimeters();
|
|
53
193
|
function sheetMm(print) {
|
|
54
194
|
const portrait = typeof print.paper === "string" ? PAPER_MM[print.paper] : {
|
|
55
195
|
width: toMillimeters(print.paper.width, print.paper.unit),
|