@segnavia/format 0.39.0 → 0.40.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-section.d.ts +3 -3
- package/dist/book.d.ts +14 -14
- package/dist/cover.d.ts +178 -15
- package/dist/deck-from-slides.d.ts +1 -1
- package/dist/deck.d.ts +3 -3
- package/dist/imposition-schema.d.ts +6 -6
- package/dist/imposition.d.ts +2 -2
- package/dist/imposition.js +53 -42
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/json-schemas.d.ts +357 -36
- package/dist/page.d.ts +194 -9
- package/dist/page.js +83 -10
- package/dist/paper.d.ts +4 -4
- package/dist/placement.d.ts +1 -1
- package/dist/print.d.ts +1 -1
- package/package.json +1 -1
package/dist/page.d.ts
CHANGED
|
@@ -1,22 +1,59 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/page.d.ts
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
3
|
+
export declare const PAGE_WIDTHS: {
|
|
4
|
+
readonly standard: 1024;
|
|
5
|
+
readonly wide: 1440;
|
|
6
|
+
};
|
|
7
|
+
export declare const FULL_PAGE_SIZE: {
|
|
8
|
+
readonly width: "full";
|
|
9
|
+
readonly height: "auto";
|
|
10
|
+
};
|
|
11
|
+
export declare const FlowingWidth: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
|
|
12
|
+
export type FlowingWidth = z.infer<typeof FlowingWidth>;
|
|
13
|
+
export declare const PageWidths: z.ZodObject<{
|
|
14
|
+
standard: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
wide: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type PageWidths = z.infer<typeof PageWidths>;
|
|
18
|
+
export declare const PageSize: z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
|
|
19
|
+
readonly width: "full";
|
|
20
|
+
readonly height: "auto";
|
|
21
|
+
}, "fluid">>, z.ZodObject<{
|
|
5
22
|
width: z.ZodNumber;
|
|
6
23
|
height: z.ZodNumber;
|
|
7
24
|
}, z.core.$strip>, z.ZodObject<{
|
|
8
|
-
width: z.ZodNumber
|
|
25
|
+
width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
|
|
9
26
|
height: z.ZodLiteral<"auto">;
|
|
10
27
|
}, z.core.$strip>]>;
|
|
11
28
|
export type PageSize = z.infer<typeof PageSize>;
|
|
12
|
-
export
|
|
13
|
-
|
|
29
|
+
export interface ResolvedPageWidth {
|
|
30
|
+
measure?: number;
|
|
31
|
+
viewportWidth: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const PageBody: z.ZodUnion<readonly [z.ZodObject<{
|
|
14
34
|
html: z.ZodString;
|
|
15
|
-
|
|
35
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
36
|
+
markdown: z.ZodString;
|
|
37
|
+
}, z.core.$strict>]>;
|
|
38
|
+
export type PageBody = z.infer<typeof PageBody>;
|
|
39
|
+
export declare function resolvePageWidth(size: PageSize, overrides?: PageWidths): ResolvedPageWidth;
|
|
40
|
+
export declare const Page: z.ZodPipe<z.ZodObject<{
|
|
41
|
+
id: z.ZodOptional<z.ZodString>;
|
|
42
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
43
|
+
html: z.ZodString;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
markdown: z.ZodString;
|
|
46
|
+
}, z.core.$strict>]>>;
|
|
47
|
+
html: z.ZodOptional<z.ZodString>;
|
|
48
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
49
|
+
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodPipe<z.ZodLiteral<"fluid">, z.ZodTransform<{
|
|
50
|
+
readonly width: "full";
|
|
51
|
+
readonly height: "auto";
|
|
52
|
+
}, "fluid">>, z.ZodObject<{
|
|
16
53
|
width: z.ZodNumber;
|
|
17
54
|
height: z.ZodNumber;
|
|
18
55
|
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
-
width: z.ZodNumber
|
|
56
|
+
width: z.ZodUnion<readonly [z.ZodLiteral<"full">, z.ZodLiteral<"standard">, z.ZodLiteral<"wide">, z.ZodNumber]>;
|
|
20
57
|
height: z.ZodLiteral<"auto">;
|
|
21
58
|
}, z.core.$strip>]>>;
|
|
22
59
|
scripts: z.ZodDefault<z.ZodEnum<{
|
|
@@ -62,8 +99,8 @@ export declare const Page: z.ZodObject<{
|
|
|
62
99
|
width: z.ZodNumber;
|
|
63
100
|
height: z.ZodNumber;
|
|
64
101
|
unit: z.ZodEnum<{
|
|
65
|
-
mm: "mm";
|
|
66
102
|
in: "in";
|
|
103
|
+
mm: "mm";
|
|
67
104
|
pt: "pt";
|
|
68
105
|
}>;
|
|
69
106
|
}, z.core.$strip>]>;
|
|
@@ -168,7 +205,155 @@ export declare const Page: z.ZodObject<{
|
|
|
168
205
|
local: z.ZodString;
|
|
169
206
|
fallback: z.ZodString;
|
|
170
207
|
}, z.core.$strip>]>>>;
|
|
171
|
-
}, z.core.$strip
|
|
208
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
209
|
+
body: PageBody;
|
|
210
|
+
size: {
|
|
211
|
+
width: number;
|
|
212
|
+
height: number;
|
|
213
|
+
} | {
|
|
214
|
+
readonly width: "full";
|
|
215
|
+
readonly height: "auto";
|
|
216
|
+
} | {
|
|
217
|
+
width: number | "full" | "standard" | "wide";
|
|
218
|
+
height: "auto";
|
|
219
|
+
};
|
|
220
|
+
scripts: "refuse" | "sandboxed";
|
|
221
|
+
id?: string | undefined;
|
|
222
|
+
dir?: "auto" | "ltr" | "rtl" | undefined;
|
|
223
|
+
lang?: string | undefined;
|
|
224
|
+
print?: {
|
|
225
|
+
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | "business-card-us" | "business-card-eu" | "business-card-square-us" | "business-card-slim-us" | "postcard-4x6" | "postcard-5x7" | "postcard-6x9" | "postcard-6x11" | "card-square-4in" | "half-letter" | "a6" | "dl" | "rack-card-4x9" | "rack-card-3.5x8.5" | "poster-12x18" | "poster-16x20" | "poster-18x24" | "poster-24x36" | "a2" | "a1" | "a0" | {
|
|
226
|
+
width: number;
|
|
227
|
+
height: number;
|
|
228
|
+
unit: "in" | "mm" | "pt";
|
|
229
|
+
};
|
|
230
|
+
orientation: "portrait" | "landscape";
|
|
231
|
+
bleed: number;
|
|
232
|
+
safe: number;
|
|
233
|
+
marks: boolean;
|
|
234
|
+
markColor: "black" | "registration";
|
|
235
|
+
margin?: {
|
|
236
|
+
top: number;
|
|
237
|
+
right: number;
|
|
238
|
+
bottom: number;
|
|
239
|
+
left: number;
|
|
240
|
+
} | undefined;
|
|
241
|
+
} | undefined;
|
|
242
|
+
printedPages?: {
|
|
243
|
+
parents: {
|
|
244
|
+
name: string;
|
|
245
|
+
basedOn?: string | undefined;
|
|
246
|
+
margin?: {
|
|
247
|
+
top: number;
|
|
248
|
+
bottom: number;
|
|
249
|
+
inner: number;
|
|
250
|
+
outer: number;
|
|
251
|
+
} | undefined;
|
|
252
|
+
head?: string | undefined;
|
|
253
|
+
foot?: string | undefined;
|
|
254
|
+
}[];
|
|
255
|
+
rules: {
|
|
256
|
+
last?: string | undefined;
|
|
257
|
+
verso?: string | undefined;
|
|
258
|
+
recto?: string | undefined;
|
|
259
|
+
first?: string | undefined;
|
|
260
|
+
every: string;
|
|
261
|
+
};
|
|
262
|
+
numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
|
|
263
|
+
} | undefined;
|
|
264
|
+
slots?: {
|
|
265
|
+
key: string;
|
|
266
|
+
label: string;
|
|
267
|
+
type: "text" | "image" | "phone" | "email" | "link" | "qr";
|
|
268
|
+
required: boolean;
|
|
269
|
+
overflow: "refuse" | "shrink" | "truncate" | "wrap";
|
|
270
|
+
placeholder?: string | undefined;
|
|
271
|
+
minSize?: number | undefined;
|
|
272
|
+
}[] | undefined;
|
|
273
|
+
fonts?: ({
|
|
274
|
+
app: string;
|
|
275
|
+
} | {
|
|
276
|
+
local: string;
|
|
277
|
+
fallback: string;
|
|
278
|
+
})[] | undefined;
|
|
279
|
+
}, {
|
|
280
|
+
size: {
|
|
281
|
+
width: number;
|
|
282
|
+
height: number;
|
|
283
|
+
} | {
|
|
284
|
+
readonly width: "full";
|
|
285
|
+
readonly height: "auto";
|
|
286
|
+
} | {
|
|
287
|
+
width: number | "full" | "standard" | "wide";
|
|
288
|
+
height: "auto";
|
|
289
|
+
};
|
|
290
|
+
scripts: "refuse" | "sandboxed";
|
|
291
|
+
id?: string | undefined;
|
|
292
|
+
body?: {
|
|
293
|
+
html: string;
|
|
294
|
+
} | {
|
|
295
|
+
markdown: string;
|
|
296
|
+
} | undefined;
|
|
297
|
+
html?: string | undefined;
|
|
298
|
+
markdown?: string | undefined;
|
|
299
|
+
dir?: "auto" | "ltr" | "rtl" | undefined;
|
|
300
|
+
lang?: string | undefined;
|
|
301
|
+
print?: {
|
|
302
|
+
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | "business-card-us" | "business-card-eu" | "business-card-square-us" | "business-card-slim-us" | "postcard-4x6" | "postcard-5x7" | "postcard-6x9" | "postcard-6x11" | "card-square-4in" | "half-letter" | "a6" | "dl" | "rack-card-4x9" | "rack-card-3.5x8.5" | "poster-12x18" | "poster-16x20" | "poster-18x24" | "poster-24x36" | "a2" | "a1" | "a0" | {
|
|
303
|
+
width: number;
|
|
304
|
+
height: number;
|
|
305
|
+
unit: "in" | "mm" | "pt";
|
|
306
|
+
};
|
|
307
|
+
orientation: "portrait" | "landscape";
|
|
308
|
+
bleed: number;
|
|
309
|
+
safe: number;
|
|
310
|
+
marks: boolean;
|
|
311
|
+
markColor: "black" | "registration";
|
|
312
|
+
margin?: {
|
|
313
|
+
top: number;
|
|
314
|
+
right: number;
|
|
315
|
+
bottom: number;
|
|
316
|
+
left: number;
|
|
317
|
+
} | undefined;
|
|
318
|
+
} | undefined;
|
|
319
|
+
printedPages?: {
|
|
320
|
+
parents: {
|
|
321
|
+
name: string;
|
|
322
|
+
basedOn?: string | undefined;
|
|
323
|
+
margin?: {
|
|
324
|
+
top: number;
|
|
325
|
+
bottom: number;
|
|
326
|
+
inner: number;
|
|
327
|
+
outer: number;
|
|
328
|
+
} | undefined;
|
|
329
|
+
head?: string | undefined;
|
|
330
|
+
foot?: string | undefined;
|
|
331
|
+
}[];
|
|
332
|
+
rules: {
|
|
333
|
+
last?: string | undefined;
|
|
334
|
+
verso?: string | undefined;
|
|
335
|
+
recto?: string | undefined;
|
|
336
|
+
first?: string | undefined;
|
|
337
|
+
every: string;
|
|
338
|
+
};
|
|
339
|
+
numbering?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
slots?: {
|
|
342
|
+
key: string;
|
|
343
|
+
label: string;
|
|
344
|
+
type: "text" | "image" | "phone" | "email" | "link" | "qr";
|
|
345
|
+
required: boolean;
|
|
346
|
+
overflow: "refuse" | "shrink" | "truncate" | "wrap";
|
|
347
|
+
placeholder?: string | undefined;
|
|
348
|
+
minSize?: number | undefined;
|
|
349
|
+
}[] | undefined;
|
|
350
|
+
fonts?: ({
|
|
351
|
+
app: string;
|
|
352
|
+
} | {
|
|
353
|
+
local: string;
|
|
354
|
+
fallback: string;
|
|
355
|
+
})[] | undefined;
|
|
356
|
+
}>>;
|
|
172
357
|
export type Page = z.infer<typeof Page>;
|
|
173
358
|
export type PageInput = z.input<typeof Page>;
|
|
174
359
|
//#endregion
|
package/dist/page.js
CHANGED
|
@@ -7,19 +7,54 @@ import { PrintedPages, pagePrintedPagesIssues } from "./printed-pages.js";
|
|
|
7
7
|
import { Print } from "./print.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
//#region src/page.ts
|
|
10
|
-
const
|
|
10
|
+
const PAGE_WIDTHS = {
|
|
11
|
+
standard: 1024,
|
|
12
|
+
wide: 1440
|
|
13
|
+
};
|
|
14
|
+
const FULL_PAGE_SIZE = {
|
|
15
|
+
width: "full",
|
|
16
|
+
height: "auto"
|
|
17
|
+
};
|
|
18
|
+
const FlowingWidth = z.union([
|
|
19
|
+
z.literal("full"),
|
|
20
|
+
z.literal("standard"),
|
|
21
|
+
z.literal("wide"),
|
|
22
|
+
z.number().int().positive()
|
|
23
|
+
]);
|
|
24
|
+
const PageWidths = z.object({
|
|
25
|
+
standard: z.number().positive().optional(),
|
|
26
|
+
wide: z.number().positive().optional()
|
|
27
|
+
});
|
|
28
|
+
const FlowingPageSize = z.object({
|
|
29
|
+
width: FlowingWidth,
|
|
30
|
+
height: z.literal("auto")
|
|
31
|
+
});
|
|
32
|
+
const LegacyFluidPageSize = z.literal("fluid").transform(() => FULL_PAGE_SIZE);
|
|
11
33
|
const PageSize = z.union([
|
|
12
|
-
|
|
34
|
+
LegacyFluidPageSize,
|
|
13
35
|
Size,
|
|
14
|
-
|
|
15
|
-
width: z.number().int().positive(),
|
|
16
|
-
height: z.literal("auto")
|
|
17
|
-
})
|
|
36
|
+
FlowingPageSize
|
|
18
37
|
]);
|
|
19
|
-
const
|
|
38
|
+
const PageBody = z.union([z.strictObject({ html: z.string() }), z.strictObject({ markdown: z.string() })]);
|
|
39
|
+
function resolvePageWidth(size, overrides = {}) {
|
|
40
|
+
const width = size.width;
|
|
41
|
+
if (typeof width === "number") return {
|
|
42
|
+
measure: width,
|
|
43
|
+
viewportWidth: width
|
|
44
|
+
};
|
|
45
|
+
if (width === "full") return { viewportWidth: overrides.standard ?? PAGE_WIDTHS.standard };
|
|
46
|
+
const measure = overrides[width] ?? PAGE_WIDTHS[width];
|
|
47
|
+
return {
|
|
48
|
+
measure,
|
|
49
|
+
viewportWidth: measure
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const PageShape = z.object({
|
|
20
53
|
id: z.string().optional(),
|
|
21
|
-
|
|
22
|
-
|
|
54
|
+
body: PageBody.optional(),
|
|
55
|
+
html: z.string().optional(),
|
|
56
|
+
markdown: z.string().optional(),
|
|
57
|
+
size: PageSize.default(FULL_PAGE_SIZE),
|
|
23
58
|
scripts: Scripts.default("refuse"),
|
|
24
59
|
dir: Direction.optional(),
|
|
25
60
|
lang: z.string().optional(),
|
|
@@ -28,10 +63,48 @@ const Page = z.object({
|
|
|
28
63
|
slots: Slots.optional(),
|
|
29
64
|
fonts: z.array(FontReference).optional()
|
|
30
65
|
}).superRefine((page, ctx) => {
|
|
66
|
+
const fields = bodyChoices(page).map(({ field }) => field);
|
|
67
|
+
if (fields.length === 0) ctx.addIssue({
|
|
68
|
+
code: "custom",
|
|
69
|
+
path: ["body"],
|
|
70
|
+
message: "body, html or markdown is required; provide exactly one page body"
|
|
71
|
+
});
|
|
72
|
+
if (fields.length > 1) {
|
|
73
|
+
const names = fields.join(", ");
|
|
74
|
+
for (const field of fields) ctx.addIssue({
|
|
75
|
+
code: "custom",
|
|
76
|
+
path: [field],
|
|
77
|
+
message: `${names} were all given; provide exactly one of body, html or markdown`
|
|
78
|
+
});
|
|
79
|
+
}
|
|
31
80
|
for (const issue of pagePrintedPagesIssues(page)) ctx.addIssue({
|
|
32
81
|
code: "custom",
|
|
33
82
|
...issue
|
|
34
83
|
});
|
|
35
84
|
});
|
|
85
|
+
const BODY_SHORTHANDS = [{
|
|
86
|
+
field: "html",
|
|
87
|
+
body: (value) => ({ html: value })
|
|
88
|
+
}, {
|
|
89
|
+
field: "markdown",
|
|
90
|
+
body: (value) => ({ markdown: value })
|
|
91
|
+
}];
|
|
92
|
+
function bodyChoices(page) {
|
|
93
|
+
return [...page.body === void 0 ? [] : [{
|
|
94
|
+
field: "body",
|
|
95
|
+
body: page.body
|
|
96
|
+
}], ...BODY_SHORTHANDS.flatMap(({ field, body }) => page[field] === void 0 ? [] : [{
|
|
97
|
+
field,
|
|
98
|
+
body: body(page[field])
|
|
99
|
+
}])];
|
|
100
|
+
}
|
|
101
|
+
const Page = PageShape.transform(({ html, markdown, ...page }) => ({
|
|
102
|
+
...page,
|
|
103
|
+
body: bodyChoices({
|
|
104
|
+
...page,
|
|
105
|
+
html,
|
|
106
|
+
markdown
|
|
107
|
+
})[0]?.body
|
|
108
|
+
}));
|
|
36
109
|
//#endregion
|
|
37
|
-
export {
|
|
110
|
+
export { FULL_PAGE_SIZE, FlowingWidth, PAGE_WIDTHS, Page, PageBody, PageSize, PageWidths, resolvePageWidth };
|
package/dist/paper.d.ts
CHANGED
|
@@ -151,8 +151,8 @@ export declare const CUSTOM_PAPER_MIN_MM = 10;
|
|
|
151
151
|
export declare const CUSTOM_PAPER_MAX_MM = 2000;
|
|
152
152
|
export declare const PAPER_UNITS: readonly ["mm", "in", "pt"];
|
|
153
153
|
export declare const PaperUnit: z.ZodEnum<{
|
|
154
|
-
mm: "mm";
|
|
155
154
|
in: "in";
|
|
155
|
+
mm: "mm";
|
|
156
156
|
pt: "pt";
|
|
157
157
|
}>;
|
|
158
158
|
export type PaperUnit = z.infer<typeof PaperUnit>;
|
|
@@ -194,8 +194,8 @@ export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
194
194
|
width: z.ZodNumber;
|
|
195
195
|
height: z.ZodNumber;
|
|
196
196
|
unit: z.ZodEnum<{
|
|
197
|
-
mm: "mm";
|
|
198
197
|
in: "in";
|
|
198
|
+
mm: "mm";
|
|
199
199
|
pt: "pt";
|
|
200
200
|
}>;
|
|
201
201
|
}, z.core.$strip>]>;
|
|
@@ -233,8 +233,8 @@ export declare const PrintSetting: z.ZodObject<{
|
|
|
233
233
|
width: z.ZodNumber;
|
|
234
234
|
height: z.ZodNumber;
|
|
235
235
|
unit: z.ZodEnum<{
|
|
236
|
-
mm: "mm";
|
|
237
236
|
in: "in";
|
|
237
|
+
mm: "mm";
|
|
238
238
|
pt: "pt";
|
|
239
239
|
}>;
|
|
240
240
|
}, z.core.$strip>]>;
|
|
@@ -277,8 +277,8 @@ export declare const PrintSettingInput: z.ZodObject<{
|
|
|
277
277
|
width: z.ZodNumber;
|
|
278
278
|
height: z.ZodNumber;
|
|
279
279
|
unit: z.ZodEnum<{
|
|
280
|
-
mm: "mm";
|
|
281
280
|
in: "in";
|
|
281
|
+
mm: "mm";
|
|
282
282
|
pt: "pt";
|
|
283
283
|
}>;
|
|
284
284
|
}, z.core.$strip>]>;
|
package/dist/placement.d.ts
CHANGED
|
@@ -40,9 +40,9 @@ export declare const PlacementShape: z.ZodObject<{
|
|
|
40
40
|
page: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
41
41
|
box: z.ZodOptional<z.ZodEnum<{
|
|
42
42
|
media: "media";
|
|
43
|
-
bleed: "bleed";
|
|
44
43
|
crop: "crop";
|
|
45
44
|
trim: "trim";
|
|
45
|
+
bleed: "bleed";
|
|
46
46
|
art: "art";
|
|
47
47
|
}>>;
|
|
48
48
|
crop: z.ZodOptional<z.ZodObject<{
|
package/dist/print.d.ts
CHANGED