@segnavia/format 0.2.0 → 0.4.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 +244 -0
- package/dist/book.js +109 -0
- package/dist/direction.d.ts +6 -0
- package/dist/direction.js +7 -1
- package/dist/index.d.ts +157 -37
- package/dist/index.js +35 -40
- package/dist/lexicon.d.ts +18 -0
- package/dist/lexicon.js +38 -0
- package/dist/numbering.d.ts +19 -0
- package/dist/numbering.js +106 -0
- package/dist/paper.d.ts +20 -1
- package/dist/paper.js +19 -1
- package/dist/scripts.d.ts +8 -0
- package/dist/scripts.js +5 -0
- package/dist/shots-used.d.ts +9 -0
- package/dist/shots-used.js +16 -0
- package/dist/timing.d.ts +4 -0
- package/dist/timing.js +10 -0
- package/dist/transition.d.ts +16 -0
- package/dist/transition.js +15 -0
- package/package.json +1 -1
package/dist/book.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/book.d.ts
|
|
3
|
+
export declare const BookMode: z.ZodEnum<{
|
|
4
|
+
continuous: "continuous";
|
|
5
|
+
paginated: "paginated";
|
|
6
|
+
}>;
|
|
7
|
+
export type BookMode = z.infer<typeof BookMode>;
|
|
8
|
+
export declare const BookSection: z.ZodObject<{
|
|
9
|
+
title: z.ZodOptional<z.ZodString>;
|
|
10
|
+
html: z.ZodString;
|
|
11
|
+
contents: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type BookSection = z.infer<typeof BookSection>;
|
|
14
|
+
export declare const Chapter: z.ZodObject<{
|
|
15
|
+
title: z.ZodString;
|
|
16
|
+
html: z.ZodString;
|
|
17
|
+
runningHead: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type Chapter = z.infer<typeof Chapter>;
|
|
20
|
+
export declare const BookPage: z.ZodObject<{
|
|
21
|
+
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
22
|
+
letter: "letter";
|
|
23
|
+
legal: "legal";
|
|
24
|
+
tabloid: "tabloid";
|
|
25
|
+
a3: "a3";
|
|
26
|
+
a4: "a4";
|
|
27
|
+
a5: "a5";
|
|
28
|
+
}>, z.ZodObject<{
|
|
29
|
+
width: z.ZodNumber;
|
|
30
|
+
height: z.ZodNumber;
|
|
31
|
+
unit: z.ZodEnum<{
|
|
32
|
+
mm: "mm";
|
|
33
|
+
in: "in";
|
|
34
|
+
pt: "pt";
|
|
35
|
+
}>;
|
|
36
|
+
}, z.core.$strip>]>;
|
|
37
|
+
orientation: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
portrait: "portrait";
|
|
39
|
+
landscape: "landscape";
|
|
40
|
+
}>>;
|
|
41
|
+
margin: z.ZodObject<{
|
|
42
|
+
top: z.ZodNumber;
|
|
43
|
+
bottom: z.ZodNumber;
|
|
44
|
+
inner: z.ZodNumber;
|
|
45
|
+
outer: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type BookPage = z.infer<typeof BookPage>;
|
|
49
|
+
export declare const Book: z.ZodPipe<z.ZodObject<{
|
|
50
|
+
title: z.ZodString;
|
|
51
|
+
mode: z.ZodEnum<{
|
|
52
|
+
continuous: "continuous";
|
|
53
|
+
paginated: "paginated";
|
|
54
|
+
}>;
|
|
55
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
57
|
+
letter: "letter";
|
|
58
|
+
legal: "legal";
|
|
59
|
+
tabloid: "tabloid";
|
|
60
|
+
a3: "a3";
|
|
61
|
+
a4: "a4";
|
|
62
|
+
a5: "a5";
|
|
63
|
+
}>, z.ZodObject<{
|
|
64
|
+
width: z.ZodNumber;
|
|
65
|
+
height: z.ZodNumber;
|
|
66
|
+
unit: z.ZodEnum<{
|
|
67
|
+
mm: "mm";
|
|
68
|
+
in: "in";
|
|
69
|
+
pt: "pt";
|
|
70
|
+
}>;
|
|
71
|
+
}, z.core.$strip>]>;
|
|
72
|
+
orientation: z.ZodDefault<z.ZodEnum<{
|
|
73
|
+
portrait: "portrait";
|
|
74
|
+
landscape: "landscape";
|
|
75
|
+
}>>;
|
|
76
|
+
margin: z.ZodObject<{
|
|
77
|
+
top: z.ZodNumber;
|
|
78
|
+
bottom: z.ZodNumber;
|
|
79
|
+
inner: z.ZodNumber;
|
|
80
|
+
outer: z.ZodNumber;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
scripts: z.ZodDefault<z.ZodEnum<{
|
|
84
|
+
refuse: "refuse";
|
|
85
|
+
sandboxed: "sandboxed";
|
|
86
|
+
}>>;
|
|
87
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
88
|
+
ltr: "ltr";
|
|
89
|
+
rtl: "rtl";
|
|
90
|
+
auto: "auto";
|
|
91
|
+
}>>;
|
|
92
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
93
|
+
frontMatter: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
94
|
+
title: z.ZodOptional<z.ZodString>;
|
|
95
|
+
html: z.ZodString;
|
|
96
|
+
contents: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
}, z.core.$strip>>>;
|
|
98
|
+
chapters: z.ZodArray<z.ZodObject<{
|
|
99
|
+
title: z.ZodString;
|
|
100
|
+
html: z.ZodString;
|
|
101
|
+
runningHead: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
numbering: z.ZodDefault<z.ZodObject<{
|
|
104
|
+
frontMatter: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
arabic: "arabic";
|
|
106
|
+
"roman-lower": "roman-lower";
|
|
107
|
+
"roman-upper": "roman-upper";
|
|
108
|
+
hebrew: "hebrew";
|
|
109
|
+
}>>;
|
|
110
|
+
body: z.ZodOptional<z.ZodEnum<{
|
|
111
|
+
arabic: "arabic";
|
|
112
|
+
"roman-lower": "roman-lower";
|
|
113
|
+
"roman-upper": "roman-upper";
|
|
114
|
+
hebrew: "hebrew";
|
|
115
|
+
}>>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
footnotes: z.ZodDefault<z.ZodObject<{
|
|
118
|
+
marker: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
119
|
+
arabic: "arabic";
|
|
120
|
+
"roman-lower": "roman-lower";
|
|
121
|
+
"roman-upper": "roman-upper";
|
|
122
|
+
hebrew: "hebrew";
|
|
123
|
+
}>, z.ZodLiteral<"symbols">]>>;
|
|
124
|
+
restart: z.ZodDefault<z.ZodEnum<{
|
|
125
|
+
chapter: "chapter";
|
|
126
|
+
book: "book";
|
|
127
|
+
}>>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
endnotes: z.ZodDefault<z.ZodObject<{
|
|
130
|
+
marker: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
131
|
+
arabic: "arabic";
|
|
132
|
+
"roman-lower": "roman-lower";
|
|
133
|
+
"roman-upper": "roman-upper";
|
|
134
|
+
hebrew: "hebrew";
|
|
135
|
+
}>, z.ZodLiteral<"symbols">]>>;
|
|
136
|
+
placement: z.ZodDefault<z.ZodEnum<{
|
|
137
|
+
chapter: "chapter";
|
|
138
|
+
book: "book";
|
|
139
|
+
}>>;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
rightHandOpenings: z.ZodDefault<z.ZodBoolean>;
|
|
142
|
+
contents: z.ZodDefault<z.ZodObject<{
|
|
143
|
+
pageNumbers: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
146
|
+
numbering: {
|
|
147
|
+
frontMatter: "arabic" | "roman-lower" | "roman-upper" | "hebrew";
|
|
148
|
+
body: "arabic" | "roman-lower" | "roman-upper" | "hebrew";
|
|
149
|
+
};
|
|
150
|
+
footnotes: {
|
|
151
|
+
marker: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | "symbols";
|
|
152
|
+
restart: "chapter" | "book";
|
|
153
|
+
};
|
|
154
|
+
endnotes: {
|
|
155
|
+
marker: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | "symbols";
|
|
156
|
+
placement: "chapter" | "book";
|
|
157
|
+
};
|
|
158
|
+
title: string;
|
|
159
|
+
mode: "continuous" | "paginated";
|
|
160
|
+
scripts: "refuse" | "sandboxed";
|
|
161
|
+
frontMatter: {
|
|
162
|
+
html: string;
|
|
163
|
+
contents: boolean;
|
|
164
|
+
title?: string | undefined;
|
|
165
|
+
}[];
|
|
166
|
+
chapters: {
|
|
167
|
+
title: string;
|
|
168
|
+
html: string;
|
|
169
|
+
runningHead?: string | undefined;
|
|
170
|
+
}[];
|
|
171
|
+
rightHandOpenings: boolean;
|
|
172
|
+
contents: {
|
|
173
|
+
pageNumbers: boolean;
|
|
174
|
+
};
|
|
175
|
+
page?: {
|
|
176
|
+
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | {
|
|
177
|
+
width: number;
|
|
178
|
+
height: number;
|
|
179
|
+
unit: "mm" | "in" | "pt";
|
|
180
|
+
};
|
|
181
|
+
orientation: "portrait" | "landscape";
|
|
182
|
+
margin: {
|
|
183
|
+
top: number;
|
|
184
|
+
bottom: number;
|
|
185
|
+
inner: number;
|
|
186
|
+
outer: number;
|
|
187
|
+
};
|
|
188
|
+
} | undefined;
|
|
189
|
+
dir?: "ltr" | "rtl" | "auto" | undefined;
|
|
190
|
+
lang?: string | undefined;
|
|
191
|
+
}, {
|
|
192
|
+
title: string;
|
|
193
|
+
mode: "continuous" | "paginated";
|
|
194
|
+
scripts: "refuse" | "sandboxed";
|
|
195
|
+
frontMatter: {
|
|
196
|
+
html: string;
|
|
197
|
+
contents: boolean;
|
|
198
|
+
title?: string | undefined;
|
|
199
|
+
}[];
|
|
200
|
+
chapters: {
|
|
201
|
+
title: string;
|
|
202
|
+
html: string;
|
|
203
|
+
runningHead?: string | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
numbering: {
|
|
206
|
+
frontMatter?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
|
|
207
|
+
body?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | undefined;
|
|
208
|
+
};
|
|
209
|
+
footnotes: {
|
|
210
|
+
restart: "chapter" | "book";
|
|
211
|
+
marker?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | "symbols" | undefined;
|
|
212
|
+
};
|
|
213
|
+
endnotes: {
|
|
214
|
+
placement: "chapter" | "book";
|
|
215
|
+
marker?: "arabic" | "roman-lower" | "roman-upper" | "hebrew" | "symbols" | undefined;
|
|
216
|
+
};
|
|
217
|
+
rightHandOpenings: boolean;
|
|
218
|
+
contents: {
|
|
219
|
+
pageNumbers: boolean;
|
|
220
|
+
};
|
|
221
|
+
page?: {
|
|
222
|
+
paper: "letter" | "legal" | "tabloid" | "a3" | "a4" | "a5" | {
|
|
223
|
+
width: number;
|
|
224
|
+
height: number;
|
|
225
|
+
unit: "mm" | "in" | "pt";
|
|
226
|
+
};
|
|
227
|
+
orientation: "portrait" | "landscape";
|
|
228
|
+
margin: {
|
|
229
|
+
top: number;
|
|
230
|
+
bottom: number;
|
|
231
|
+
inner: number;
|
|
232
|
+
outer: number;
|
|
233
|
+
};
|
|
234
|
+
} | undefined;
|
|
235
|
+
dir?: "ltr" | "rtl" | "auto" | undefined;
|
|
236
|
+
lang?: string | undefined;
|
|
237
|
+
}>>;
|
|
238
|
+
export type Book = z.infer<typeof Book>;
|
|
239
|
+
export type BookInput = z.input<typeof Book>;
|
|
240
|
+
export declare function noteMarkerIssues(book: Book, used: {
|
|
241
|
+
footnotes: boolean;
|
|
242
|
+
endnotes: boolean;
|
|
243
|
+
}): string[];
|
|
244
|
+
//#endregion
|
package/dist/book.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Direction } from "./direction.js";
|
|
2
|
+
import { NoteMarker, NumberSystem } from "./numbering.js";
|
|
3
|
+
import { Paper, sheetMm } from "./paper.js";
|
|
4
|
+
import { Scripts } from "./scripts.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/book.ts
|
|
7
|
+
const BookMode = z.enum(["continuous", "paginated"]);
|
|
8
|
+
const BookSection = z.object({
|
|
9
|
+
title: z.string().optional(),
|
|
10
|
+
html: z.string(),
|
|
11
|
+
contents: z.boolean().default(true)
|
|
12
|
+
});
|
|
13
|
+
const Chapter = z.object({
|
|
14
|
+
title: z.string(),
|
|
15
|
+
html: z.string(),
|
|
16
|
+
runningHead: z.string().optional()
|
|
17
|
+
});
|
|
18
|
+
const BookPage = z.object({
|
|
19
|
+
paper: Paper,
|
|
20
|
+
orientation: z.enum(["portrait", "landscape"]).default("portrait"),
|
|
21
|
+
margin: z.object({
|
|
22
|
+
top: z.number().nonnegative(),
|
|
23
|
+
bottom: z.number().nonnegative(),
|
|
24
|
+
inner: z.number().nonnegative(),
|
|
25
|
+
outer: z.number().nonnegative()
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
const BookShape = z.object({
|
|
29
|
+
title: z.string(),
|
|
30
|
+
mode: BookMode,
|
|
31
|
+
page: BookPage.optional(),
|
|
32
|
+
scripts: Scripts.default("refuse"),
|
|
33
|
+
dir: Direction.optional(),
|
|
34
|
+
lang: z.string().optional(),
|
|
35
|
+
frontMatter: z.array(BookSection).default([]),
|
|
36
|
+
chapters: z.array(Chapter).min(1),
|
|
37
|
+
numbering: z.object({
|
|
38
|
+
frontMatter: NumberSystem.optional(),
|
|
39
|
+
body: NumberSystem.optional()
|
|
40
|
+
}).default({}),
|
|
41
|
+
footnotes: z.object({
|
|
42
|
+
marker: NoteMarker.optional(),
|
|
43
|
+
restart: z.enum(["chapter", "book"]).default("chapter")
|
|
44
|
+
}).default({ restart: "chapter" }),
|
|
45
|
+
endnotes: z.object({
|
|
46
|
+
marker: NoteMarker.optional(),
|
|
47
|
+
placement: z.enum(["book", "chapter"]).default("book")
|
|
48
|
+
}).default({ placement: "book" }),
|
|
49
|
+
rightHandOpenings: z.boolean().default(false),
|
|
50
|
+
contents: z.object({ pageNumbers: z.boolean().default(true) }).default({ pageNumbers: true })
|
|
51
|
+
});
|
|
52
|
+
function isHebrew(lang) {
|
|
53
|
+
const primary = lang?.split("-")[0]?.toLowerCase();
|
|
54
|
+
return primary === "he" || primary === "iw";
|
|
55
|
+
}
|
|
56
|
+
const Book = BookShape.transform((book) => {
|
|
57
|
+
const hebrew = isHebrew(book.lang);
|
|
58
|
+
return {
|
|
59
|
+
...book,
|
|
60
|
+
numbering: {
|
|
61
|
+
frontMatter: book.numbering.frontMatter ?? (hebrew ? "arabic" : "roman-lower"),
|
|
62
|
+
body: book.numbering.body ?? (hebrew ? "hebrew" : "arabic")
|
|
63
|
+
},
|
|
64
|
+
footnotes: {
|
|
65
|
+
...book.footnotes,
|
|
66
|
+
marker: book.footnotes.marker ?? (hebrew ? "hebrew" : "symbols")
|
|
67
|
+
},
|
|
68
|
+
endnotes: {
|
|
69
|
+
...book.endnotes,
|
|
70
|
+
marker: book.endnotes.marker ?? "arabic"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}).superRefine((book, ctx) => {
|
|
74
|
+
if (book.mode === "paginated" && !book.page) ctx.addIssue({
|
|
75
|
+
code: "custom",
|
|
76
|
+
path: ["page"],
|
|
77
|
+
message: "a paginated book needs page; set page or use continuous mode"
|
|
78
|
+
});
|
|
79
|
+
if (book.frontMatter.length > 0 && book.numbering.frontMatter === book.numbering.body) ctx.addIssue({
|
|
80
|
+
code: "custom",
|
|
81
|
+
path: ["numbering"],
|
|
82
|
+
message: `front-matter and body numbering are both ${book.numbering.body}; the two must differ when front matter is present`
|
|
83
|
+
});
|
|
84
|
+
if (book.endnotes.placement === "chapter" && book.mode === "continuous") ctx.addIssue({
|
|
85
|
+
code: "custom",
|
|
86
|
+
path: ["endnotes", "placement"],
|
|
87
|
+
message: "endnotes are placed at the end of each chapter only in paginated mode; use book placement or paginated mode"
|
|
88
|
+
});
|
|
89
|
+
if (!book.page) return;
|
|
90
|
+
const trim = sheetMm(book.page);
|
|
91
|
+
const vertical = book.page.margin.top + book.page.margin.bottom;
|
|
92
|
+
const horizontal = book.page.margin.inner + book.page.margin.outer;
|
|
93
|
+
if (vertical >= trim.height) ctx.addIssue({
|
|
94
|
+
code: "custom",
|
|
95
|
+
path: ["page", "margin"],
|
|
96
|
+
message: `the top and bottom margins total ${vertical}mm and the page is ${trim.height}mm high; reduce the vertical margins to leave a text area`
|
|
97
|
+
});
|
|
98
|
+
if (horizontal >= trim.width) ctx.addIssue({
|
|
99
|
+
code: "custom",
|
|
100
|
+
path: ["page", "margin"],
|
|
101
|
+
message: `the inner and outer margins total ${horizontal}mm and the page is ${trim.width}mm wide; reduce the horizontal margins to leave a text area`
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
function noteMarkerIssues(book, used) {
|
|
105
|
+
if (!used.footnotes || !used.endnotes || book.footnotes.marker !== book.endnotes.marker) return [];
|
|
106
|
+
return [`footnote and endnote markers are both ${book.footnotes.marker}; the two must differ when both kinds are used`];
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { Book, BookMode, BookPage, BookSection, BookShape, Chapter, noteMarkerIssues };
|
package/dist/direction.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
//#region src/direction.d.ts
|
|
3
|
+
export declare const Direction: z.ZodEnum<{
|
|
4
|
+
ltr: "ltr";
|
|
5
|
+
rtl: "rtl";
|
|
6
|
+
auto: "auto";
|
|
7
|
+
}>;
|
|
2
8
|
export type TextDirection = 'ltr' | 'rtl';
|
|
3
9
|
export declare function firstStrongDirection(text: string): TextDirection | null;
|
|
4
10
|
export declare function languageDirection(lang: string | undefined): TextDirection | null;
|
package/dist/direction.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
//#region src/direction.ts
|
|
3
|
+
const Direction = z.enum([
|
|
4
|
+
"ltr",
|
|
5
|
+
"rtl",
|
|
6
|
+
"auto"
|
|
7
|
+
]);
|
|
2
8
|
const RTL_LETTER = /[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Adlam}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}\p{Script=Old_Hungarian}\p{Script=Imperial_Aramaic}\p{Script=Phoenician}]/u;
|
|
3
9
|
const LETTER = /\p{L}/u;
|
|
4
10
|
const RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
@@ -36,4 +42,4 @@ function resolveDirection(dir, lang, sample) {
|
|
|
36
42
|
return languageDirection(lang) ?? firstStrongDirection(sample) ?? "ltr";
|
|
37
43
|
}
|
|
38
44
|
//#endregion
|
|
39
|
-
export { firstStrongDirection, languageDirection, resolveDirection };
|
|
45
|
+
export { Direction, firstStrongDirection, languageDirection, resolveDirection };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Book, BookInput, BookMode, BookPage, BookSection, Chapter, noteMarkerIssues } from "./book.js";
|
|
2
|
+
import { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
|
|
3
|
+
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";
|
|
3
4
|
import { Imposed, MillimeterEdges, PageFit, PagePlacementKind, PagePlacementLayout, Placement, fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
|
|
5
|
+
import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
|
|
6
|
+
import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
|
|
7
|
+
import { Scripts } from "./scripts.js";
|
|
8
|
+
import { ShotUse, shotsUsed } from "./shots-used.js";
|
|
9
|
+
import { MAX_SLIDE_TIMING_MS } from "./timing.js";
|
|
10
|
+
import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition, TransitionInput } from "./transition.js";
|
|
4
11
|
import { z } from "zod";
|
|
5
12
|
//#region src/index.d.ts
|
|
6
13
|
export declare const Size: z.ZodObject<{
|
|
@@ -8,34 +15,6 @@ export declare const Size: z.ZodObject<{
|
|
|
8
15
|
height: z.ZodNumber;
|
|
9
16
|
}, z.core.$strip>;
|
|
10
17
|
export type Size = z.infer<typeof Size>;
|
|
11
|
-
export declare const Scripts: z.ZodEnum<{
|
|
12
|
-
refuse: "refuse";
|
|
13
|
-
sandboxed: "sandboxed";
|
|
14
|
-
}>;
|
|
15
|
-
export type Scripts = z.infer<typeof Scripts>;
|
|
16
|
-
export declare const Direction: z.ZodEnum<{
|
|
17
|
-
ltr: "ltr";
|
|
18
|
-
rtl: "rtl";
|
|
19
|
-
auto: "auto";
|
|
20
|
-
}>;
|
|
21
|
-
export declare const NAMED_PAPERS: readonly ["letter", "legal", "tabloid", "a3", "a4", "a5"];
|
|
22
|
-
export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
23
|
-
letter: "letter";
|
|
24
|
-
legal: "legal";
|
|
25
|
-
tabloid: "tabloid";
|
|
26
|
-
a3: "a3";
|
|
27
|
-
a4: "a4";
|
|
28
|
-
a5: "a5";
|
|
29
|
-
}>, z.ZodObject<{
|
|
30
|
-
width: z.ZodNumber;
|
|
31
|
-
height: z.ZodNumber;
|
|
32
|
-
unit: z.ZodEnum<{
|
|
33
|
-
mm: "mm";
|
|
34
|
-
in: "in";
|
|
35
|
-
pt: "pt";
|
|
36
|
-
}>;
|
|
37
|
-
}, z.core.$strip>]>;
|
|
38
|
-
export type Paper = z.infer<typeof Paper>;
|
|
39
18
|
export declare const Margin: z.ZodObject<{
|
|
40
19
|
top: z.ZodDefault<z.ZodNumber>;
|
|
41
20
|
right: z.ZodDefault<z.ZodNumber>;
|
|
@@ -526,6 +505,9 @@ export declare const Slide: z.ZodObject<{
|
|
|
526
505
|
untilWord: z.ZodOptional<z.ZodNumber>;
|
|
527
506
|
}, z.core.$strip>>>;
|
|
528
507
|
}, z.core.$strip>>;
|
|
508
|
+
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
509
|
+
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
510
|
+
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
529
511
|
}, z.core.$strip>;
|
|
530
512
|
export type Slide = z.infer<typeof Slide>;
|
|
531
513
|
export declare const DECK_SIZE: {
|
|
@@ -549,6 +531,23 @@ export declare const Deck: z.ZodObject<{
|
|
|
549
531
|
auto: "auto";
|
|
550
532
|
}>>;
|
|
551
533
|
lang: z.ZodOptional<z.ZodString>;
|
|
534
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
535
|
+
kind: z.ZodEnum<{
|
|
536
|
+
none: "none";
|
|
537
|
+
fade: "fade";
|
|
538
|
+
slide: "slide";
|
|
539
|
+
}>;
|
|
540
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
541
|
+
}, z.core.$strip>>;
|
|
542
|
+
playback: z.ZodOptional<z.ZodEnum<{
|
|
543
|
+
step: "step";
|
|
544
|
+
continuous: "continuous";
|
|
545
|
+
}>>;
|
|
546
|
+
captions: z.ZodOptional<z.ZodEnum<{
|
|
547
|
+
on: "on";
|
|
548
|
+
off: "off";
|
|
549
|
+
viewer: "viewer";
|
|
550
|
+
}>>;
|
|
552
551
|
slides: z.ZodArray<z.ZodObject<{
|
|
553
552
|
id: z.ZodString;
|
|
554
553
|
content: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -637,6 +636,9 @@ export declare const Deck: z.ZodObject<{
|
|
|
637
636
|
untilWord: z.ZodOptional<z.ZodNumber>;
|
|
638
637
|
}, z.core.$strip>>>;
|
|
639
638
|
}, z.core.$strip>>;
|
|
639
|
+
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
640
|
+
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
641
|
+
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
640
642
|
}, z.core.$strip>>;
|
|
641
643
|
}, z.core.$strip>;
|
|
642
644
|
export type Deck = z.infer<typeof Deck>;
|
|
@@ -696,13 +698,104 @@ export interface DeckLimits {
|
|
|
696
698
|
maxNotesBytes?: number;
|
|
697
699
|
}
|
|
698
700
|
export declare function exceedsLimits(deck: Deck, limits: DeckLimits): string[];
|
|
699
|
-
export interface ShotUse {
|
|
700
|
-
slide: string;
|
|
701
|
-
key?: string;
|
|
702
|
-
href?: string;
|
|
703
|
-
}
|
|
704
|
-
export declare function shotsUsed(deck: Deck): ShotUse[];
|
|
705
701
|
export declare function jsonSchemas(): {
|
|
702
|
+
book: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
703
|
+
title: z.ZodString;
|
|
704
|
+
mode: z.ZodEnum<{
|
|
705
|
+
continuous: "continuous";
|
|
706
|
+
paginated: "paginated";
|
|
707
|
+
}>;
|
|
708
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
709
|
+
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
710
|
+
letter: "letter";
|
|
711
|
+
legal: "legal";
|
|
712
|
+
tabloid: "tabloid";
|
|
713
|
+
a3: "a3";
|
|
714
|
+
a4: "a4";
|
|
715
|
+
a5: "a5";
|
|
716
|
+
}>, z.ZodObject<{
|
|
717
|
+
width: z.ZodNumber;
|
|
718
|
+
height: z.ZodNumber;
|
|
719
|
+
unit: z.ZodEnum<{
|
|
720
|
+
mm: "mm";
|
|
721
|
+
in: "in";
|
|
722
|
+
pt: "pt";
|
|
723
|
+
}>;
|
|
724
|
+
}, z.core.$strip>]>;
|
|
725
|
+
orientation: z.ZodDefault<z.ZodEnum<{
|
|
726
|
+
portrait: "portrait";
|
|
727
|
+
landscape: "landscape";
|
|
728
|
+
}>>;
|
|
729
|
+
margin: z.ZodObject<{
|
|
730
|
+
top: z.ZodNumber;
|
|
731
|
+
bottom: z.ZodNumber;
|
|
732
|
+
inner: z.ZodNumber;
|
|
733
|
+
outer: z.ZodNumber;
|
|
734
|
+
}, z.core.$strip>;
|
|
735
|
+
}, z.core.$strip>>;
|
|
736
|
+
scripts: z.ZodDefault<z.ZodEnum<{
|
|
737
|
+
refuse: "refuse";
|
|
738
|
+
sandboxed: "sandboxed";
|
|
739
|
+
}>>;
|
|
740
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
741
|
+
ltr: "ltr";
|
|
742
|
+
rtl: "rtl";
|
|
743
|
+
auto: "auto";
|
|
744
|
+
}>>;
|
|
745
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
746
|
+
frontMatter: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
747
|
+
title: z.ZodOptional<z.ZodString>;
|
|
748
|
+
html: z.ZodString;
|
|
749
|
+
contents: z.ZodDefault<z.ZodBoolean>;
|
|
750
|
+
}, z.core.$strip>>>;
|
|
751
|
+
chapters: z.ZodArray<z.ZodObject<{
|
|
752
|
+
title: z.ZodString;
|
|
753
|
+
html: z.ZodString;
|
|
754
|
+
runningHead: z.ZodOptional<z.ZodString>;
|
|
755
|
+
}, z.core.$strip>>;
|
|
756
|
+
numbering: z.ZodDefault<z.ZodObject<{
|
|
757
|
+
frontMatter: z.ZodOptional<z.ZodEnum<{
|
|
758
|
+
arabic: "arabic";
|
|
759
|
+
"roman-lower": "roman-lower";
|
|
760
|
+
"roman-upper": "roman-upper";
|
|
761
|
+
hebrew: "hebrew";
|
|
762
|
+
}>>;
|
|
763
|
+
body: z.ZodOptional<z.ZodEnum<{
|
|
764
|
+
arabic: "arabic";
|
|
765
|
+
"roman-lower": "roman-lower";
|
|
766
|
+
"roman-upper": "roman-upper";
|
|
767
|
+
hebrew: "hebrew";
|
|
768
|
+
}>>;
|
|
769
|
+
}, z.core.$strip>>;
|
|
770
|
+
footnotes: z.ZodDefault<z.ZodObject<{
|
|
771
|
+
marker: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
772
|
+
arabic: "arabic";
|
|
773
|
+
"roman-lower": "roman-lower";
|
|
774
|
+
"roman-upper": "roman-upper";
|
|
775
|
+
hebrew: "hebrew";
|
|
776
|
+
}>, z.ZodLiteral<"symbols">]>>;
|
|
777
|
+
restart: z.ZodDefault<z.ZodEnum<{
|
|
778
|
+
chapter: "chapter";
|
|
779
|
+
book: "book";
|
|
780
|
+
}>>;
|
|
781
|
+
}, z.core.$strip>>;
|
|
782
|
+
endnotes: z.ZodDefault<z.ZodObject<{
|
|
783
|
+
marker: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
784
|
+
arabic: "arabic";
|
|
785
|
+
"roman-lower": "roman-lower";
|
|
786
|
+
"roman-upper": "roman-upper";
|
|
787
|
+
hebrew: "hebrew";
|
|
788
|
+
}>, z.ZodLiteral<"symbols">]>>;
|
|
789
|
+
placement: z.ZodDefault<z.ZodEnum<{
|
|
790
|
+
chapter: "chapter";
|
|
791
|
+
book: "book";
|
|
792
|
+
}>>;
|
|
793
|
+
}, z.core.$strip>>;
|
|
794
|
+
rightHandOpenings: z.ZodDefault<z.ZodBoolean>;
|
|
795
|
+
contents: z.ZodDefault<z.ZodObject<{
|
|
796
|
+
pageNumbers: z.ZodDefault<z.ZodBoolean>;
|
|
797
|
+
}, z.core.$strip>>;
|
|
798
|
+
}, z.core.$strip>>;
|
|
706
799
|
page: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
707
800
|
html: z.ZodString;
|
|
708
801
|
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"fluid">, z.ZodObject<{
|
|
@@ -754,6 +847,13 @@ export declare function jsonSchemas(): {
|
|
|
754
847
|
marks: z.ZodDefault<z.ZodBoolean>;
|
|
755
848
|
}, z.core.$strip>>;
|
|
756
849
|
}, z.core.$strip>>;
|
|
850
|
+
lexicon: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
851
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
852
|
+
term: z.ZodString;
|
|
853
|
+
say: z.ZodString;
|
|
854
|
+
ipa: z.ZodOptional<z.ZodString>;
|
|
855
|
+
}, z.core.$strip>>;
|
|
856
|
+
}, z.core.$strip>>;
|
|
757
857
|
imposition: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
758
858
|
paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
759
859
|
letter: "letter";
|
|
@@ -836,6 +936,23 @@ export declare function jsonSchemas(): {
|
|
|
836
936
|
auto: "auto";
|
|
837
937
|
}>>;
|
|
838
938
|
lang: z.ZodOptional<z.ZodString>;
|
|
939
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
940
|
+
kind: z.ZodEnum<{
|
|
941
|
+
none: "none";
|
|
942
|
+
fade: "fade";
|
|
943
|
+
slide: "slide";
|
|
944
|
+
}>;
|
|
945
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
946
|
+
}, z.core.$strip>>;
|
|
947
|
+
playback: z.ZodOptional<z.ZodEnum<{
|
|
948
|
+
step: "step";
|
|
949
|
+
continuous: "continuous";
|
|
950
|
+
}>>;
|
|
951
|
+
captions: z.ZodOptional<z.ZodEnum<{
|
|
952
|
+
on: "on";
|
|
953
|
+
off: "off";
|
|
954
|
+
viewer: "viewer";
|
|
955
|
+
}>>;
|
|
839
956
|
slides: z.ZodArray<z.ZodObject<{
|
|
840
957
|
id: z.ZodString;
|
|
841
958
|
content: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -924,6 +1041,9 @@ export declare function jsonSchemas(): {
|
|
|
924
1041
|
untilWord: z.ZodOptional<z.ZodNumber>;
|
|
925
1042
|
}, z.core.$strip>>>;
|
|
926
1043
|
}, z.core.$strip>>;
|
|
1044
|
+
beforeMs: z.ZodOptional<z.ZodNumber>;
|
|
1045
|
+
afterMs: z.ZodOptional<z.ZodNumber>;
|
|
1046
|
+
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
927
1047
|
}, z.core.$strip>>;
|
|
928
1048
|
}, z.core.$strip>>;
|
|
929
1049
|
manifest: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
@@ -1024,4 +1144,4 @@ export declare function jsonSchemas(): {
|
|
|
1024
1144
|
}, z.core.$strip>>;
|
|
1025
1145
|
};
|
|
1026
1146
|
//#endregion
|
|
1027
|
-
export { type Imposed, MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, type MillimeterEdges, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, type PaperBox, type Placement, type TextDirection, firstStrongDirection, fitPage, impose, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, toMillimeters };
|
|
1147
|
+
export { Book, type BookInput, BookMode, BookPage, BookSection, Chapter, DEFAULT_TRANSITION_DURATION_MS, Direction, type Imposed, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, type MillimeterEdges, NAMED_PAPERS, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, PronunciationEntry, Scripts, type ShotUse, type TextDirection, Transition, TransitionInput, firstStrongDirection, fitPage, formatNumber, impose, languageDirection, lexiconVersion, mirrorPlacement, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Direction, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
|
|
2
|
+
import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
|
|
3
|
+
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";
|
|
4
|
+
import { Scripts } from "./scripts.js";
|
|
5
|
+
import { Book, BookMode, BookPage, BookSection, BookShape, Chapter, noteMarkerIssues } from "./book.js";
|
|
6
|
+
import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
|
|
7
|
+
import { MAX_SLIDE_TIMING_MS, SlideTiming, slideTimingIssues } from "./timing.js";
|
|
8
|
+
import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition } from "./transition.js";
|
|
3
9
|
import { fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
|
|
10
|
+
import { shotsUsed } from "./shots-used.js";
|
|
4
11
|
import { z } from "zod";
|
|
5
12
|
//#region src/index.ts
|
|
6
13
|
const Size = z.object({
|
|
7
14
|
width: z.number().int().positive(),
|
|
8
15
|
height: z.number().int().positive()
|
|
9
16
|
});
|
|
10
|
-
const Scripts = z.enum(["refuse", "sandboxed"]);
|
|
11
|
-
const Direction = z.enum([
|
|
12
|
-
"ltr",
|
|
13
|
-
"rtl",
|
|
14
|
-
"auto"
|
|
15
|
-
]);
|
|
16
|
-
const NAMED_PAPERS = [
|
|
17
|
-
"letter",
|
|
18
|
-
"legal",
|
|
19
|
-
"tabloid",
|
|
20
|
-
"a3",
|
|
21
|
-
"a4",
|
|
22
|
-
"a5"
|
|
23
|
-
];
|
|
24
|
-
const Paper = z.union([z.enum(NAMED_PAPERS), z.object({
|
|
25
|
-
width: z.number().positive(),
|
|
26
|
-
height: z.number().positive(),
|
|
27
|
-
unit: z.enum([
|
|
28
|
-
"mm",
|
|
29
|
-
"in",
|
|
30
|
-
"pt"
|
|
31
|
-
])
|
|
32
|
-
})]);
|
|
33
17
|
const Margin = z.object({
|
|
34
18
|
top: z.number().nonnegative().default(0),
|
|
35
19
|
right: z.number().nonnegative().default(0),
|
|
@@ -246,7 +230,10 @@ const Slide = z.object({
|
|
|
246
230
|
id: z.string(),
|
|
247
231
|
content: SlideContent,
|
|
248
232
|
notes: z.string().optional(),
|
|
249
|
-
narration: Narration.optional()
|
|
233
|
+
narration: Narration.optional(),
|
|
234
|
+
beforeMs: SlideTiming.optional(),
|
|
235
|
+
afterMs: SlideTiming.optional(),
|
|
236
|
+
holdMs: SlideTiming.optional()
|
|
250
237
|
});
|
|
251
238
|
const DECK_SIZE = {
|
|
252
239
|
width: 1280,
|
|
@@ -258,6 +245,13 @@ const DeckShape = z.object({
|
|
|
258
245
|
scripts: Scripts.default("refuse"),
|
|
259
246
|
dir: Direction.optional(),
|
|
260
247
|
lang: z.string().optional(),
|
|
248
|
+
transition: Transition.optional(),
|
|
249
|
+
playback: z.enum(["step", "continuous"]).optional(),
|
|
250
|
+
captions: z.enum([
|
|
251
|
+
"on",
|
|
252
|
+
"off",
|
|
253
|
+
"viewer"
|
|
254
|
+
]).optional(),
|
|
261
255
|
slides: z.array(Slide).min(1)
|
|
262
256
|
});
|
|
263
257
|
function annotationCueIssues(narration, annotations) {
|
|
@@ -289,6 +283,18 @@ const Deck = DeckShape.superRefine((deck, ctx) => {
|
|
|
289
283
|
],
|
|
290
284
|
message
|
|
291
285
|
});
|
|
286
|
+
for (const field of slideTimingIssues(slide)) {
|
|
287
|
+
const kind = field === "holdMs" ? "without" : "with";
|
|
288
|
+
ctx.addIssue({
|
|
289
|
+
code: "custom",
|
|
290
|
+
path: [
|
|
291
|
+
"slides",
|
|
292
|
+
index,
|
|
293
|
+
field
|
|
294
|
+
],
|
|
295
|
+
message: `${field} is allowed only ${kind} narration`
|
|
296
|
+
});
|
|
297
|
+
}
|
|
292
298
|
});
|
|
293
299
|
const ids = /* @__PURE__ */ new Set();
|
|
294
300
|
deck.slides.forEach((slide, index) => {
|
|
@@ -318,22 +324,11 @@ function exceedsLimits(deck, limits) {
|
|
|
318
324
|
});
|
|
319
325
|
return reasons;
|
|
320
326
|
}
|
|
321
|
-
function shotsUsed(deck) {
|
|
322
|
-
return deck.slides.flatMap((slide) => {
|
|
323
|
-
if (slide.content.kind === "shot") return [{
|
|
324
|
-
slide: slide.id,
|
|
325
|
-
key: slide.content.shot.key
|
|
326
|
-
}];
|
|
327
|
-
if (slide.content.kind === "shot-ref") return [{
|
|
328
|
-
slide: slide.id,
|
|
329
|
-
href: slide.content.href
|
|
330
|
-
}];
|
|
331
|
-
return [];
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
327
|
function jsonSchemas() {
|
|
335
328
|
return {
|
|
329
|
+
book: z.toJSONSchema(BookShape, { io: "input" }),
|
|
336
330
|
page: z.toJSONSchema(Page, { io: "input" }),
|
|
331
|
+
lexicon: z.toJSONSchema(Lexicon, { io: "input" }),
|
|
337
332
|
imposition: z.toJSONSchema(Imposition, { io: "input" }),
|
|
338
333
|
deck: z.toJSONSchema(DeckShape, { io: "input" }),
|
|
339
334
|
manifest: z.toJSONSchema(Manifest, { io: "input" }),
|
|
@@ -341,4 +336,4 @@ function jsonSchemas() {
|
|
|
341
336
|
};
|
|
342
337
|
}
|
|
343
338
|
//#endregion
|
|
344
|
-
export { Annotation, Box, Cue, DECK_SIZE, Deck, Direction, Imposition, MARK_GAP_MM, MARK_LENGTH_MM, MAX_IMPOSITION_CELLS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits, firstStrongDirection, fitPage, impose, jsonSchemas, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
|
|
339
|
+
export { Annotation, Book, BookMode, BookPage, BookSection, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, Imposition, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, Transition, Word, annotationCueIssues, exceedsLimits, firstStrongDirection, fitPage, formatNumber, impose, jsonSchemas, languageDirection, lexiconVersion, mirrorPlacement, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/lexicon.d.ts
|
|
3
|
+
export declare const PronunciationEntry: z.ZodObject<{
|
|
4
|
+
term: z.ZodString;
|
|
5
|
+
say: z.ZodString;
|
|
6
|
+
ipa: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type PronunciationEntry = z.infer<typeof PronunciationEntry>;
|
|
9
|
+
export declare const Lexicon: z.ZodObject<{
|
|
10
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
11
|
+
term: z.ZodString;
|
|
12
|
+
say: z.ZodString;
|
|
13
|
+
ipa: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type Lexicon = z.infer<typeof Lexicon>;
|
|
17
|
+
export declare function lexiconVersion(lexicon: Lexicon): string;
|
|
18
|
+
//#endregion
|
package/dist/lexicon.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/lexicon.ts
|
|
3
|
+
const SingleWord = z.string().min(1).regex(/^\S+$/u);
|
|
4
|
+
const PronunciationEntry = z.object({
|
|
5
|
+
term: SingleWord,
|
|
6
|
+
say: SingleWord,
|
|
7
|
+
ipa: z.string().optional()
|
|
8
|
+
});
|
|
9
|
+
const Lexicon = z.object({ entries: z.array(PronunciationEntry) }).superRefine((lexicon, ctx) => {
|
|
10
|
+
const terms = /* @__PURE__ */ new Set();
|
|
11
|
+
lexicon.entries.forEach((entry, index) => {
|
|
12
|
+
if (terms.has(entry.term)) ctx.addIssue({
|
|
13
|
+
code: "custom",
|
|
14
|
+
path: [
|
|
15
|
+
"entries",
|
|
16
|
+
index,
|
|
17
|
+
"term"
|
|
18
|
+
],
|
|
19
|
+
message: `the term ${JSON.stringify(entry.term)} appears more than once`
|
|
20
|
+
});
|
|
21
|
+
terms.add(entry.term);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
function lexiconVersion(lexicon) {
|
|
25
|
+
const canonical = [...lexicon.entries].sort((left, right) => left.term < right.term ? -1 : left.term > right.term ? 1 : 0).map(({ term, say, ipa }) => [
|
|
26
|
+
term,
|
|
27
|
+
say,
|
|
28
|
+
ipa ?? null
|
|
29
|
+
]);
|
|
30
|
+
let hash = 14695981039346656037n;
|
|
31
|
+
for (const byte of new TextEncoder().encode(JSON.stringify(canonical))) {
|
|
32
|
+
hash ^= BigInt(byte);
|
|
33
|
+
hash = BigInt.asUintN(64, hash * 1099511628211n);
|
|
34
|
+
}
|
|
35
|
+
return hash.toString(16).padStart(16, "0").slice(0, 12);
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Lexicon, PronunciationEntry, lexiconVersion };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/numbering.d.ts
|
|
3
|
+
export declare const NumberSystem: z.ZodEnum<{
|
|
4
|
+
arabic: "arabic";
|
|
5
|
+
"roman-lower": "roman-lower";
|
|
6
|
+
"roman-upper": "roman-upper";
|
|
7
|
+
hebrew: "hebrew";
|
|
8
|
+
}>;
|
|
9
|
+
export type NumberSystem = z.infer<typeof NumberSystem>;
|
|
10
|
+
export declare const NoteMarker: z.ZodUnion<readonly [z.ZodEnum<{
|
|
11
|
+
arabic: "arabic";
|
|
12
|
+
"roman-lower": "roman-lower";
|
|
13
|
+
"roman-upper": "roman-upper";
|
|
14
|
+
hebrew: "hebrew";
|
|
15
|
+
}>, z.ZodLiteral<"symbols">]>;
|
|
16
|
+
export type NoteMarker = z.infer<typeof NoteMarker>;
|
|
17
|
+
export declare function formatNumber(value: number, system: NumberSystem): string;
|
|
18
|
+
export declare function noteMarker(index: number, marker: NoteMarker): string;
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/numbering.ts
|
|
3
|
+
const NumberSystem = z.enum([
|
|
4
|
+
"arabic",
|
|
5
|
+
"roman-lower",
|
|
6
|
+
"roman-upper",
|
|
7
|
+
"hebrew"
|
|
8
|
+
]);
|
|
9
|
+
const NoteMarker = z.union([NumberSystem, z.literal("symbols")]);
|
|
10
|
+
const ROMAN_DIGITS = [
|
|
11
|
+
[1e3, "M"],
|
|
12
|
+
[900, "CM"],
|
|
13
|
+
[500, "D"],
|
|
14
|
+
[400, "CD"],
|
|
15
|
+
[100, "C"],
|
|
16
|
+
[90, "XC"],
|
|
17
|
+
[50, "L"],
|
|
18
|
+
[40, "XL"],
|
|
19
|
+
[10, "X"],
|
|
20
|
+
[9, "IX"],
|
|
21
|
+
[5, "V"],
|
|
22
|
+
[4, "IV"],
|
|
23
|
+
[1, "I"]
|
|
24
|
+
];
|
|
25
|
+
const HEBREW_ONES = [
|
|
26
|
+
"",
|
|
27
|
+
"א",
|
|
28
|
+
"ב",
|
|
29
|
+
"ג",
|
|
30
|
+
"ד",
|
|
31
|
+
"ה",
|
|
32
|
+
"ו",
|
|
33
|
+
"ז",
|
|
34
|
+
"ח",
|
|
35
|
+
"ט"
|
|
36
|
+
];
|
|
37
|
+
const HEBREW_TENS = [
|
|
38
|
+
"",
|
|
39
|
+
"י",
|
|
40
|
+
"כ",
|
|
41
|
+
"ל",
|
|
42
|
+
"מ",
|
|
43
|
+
"נ",
|
|
44
|
+
"ס",
|
|
45
|
+
"ע",
|
|
46
|
+
"פ",
|
|
47
|
+
"צ"
|
|
48
|
+
];
|
|
49
|
+
const NOTE_SYMBOLS = [
|
|
50
|
+
"*",
|
|
51
|
+
"†",
|
|
52
|
+
"‡",
|
|
53
|
+
"§"
|
|
54
|
+
];
|
|
55
|
+
function positiveInteger(value) {
|
|
56
|
+
if (!Number.isInteger(value) || value < 1) throw new RangeError(`value ${value} must be a positive integer`);
|
|
57
|
+
}
|
|
58
|
+
function inRange(value, maximum, system) {
|
|
59
|
+
if (value > maximum) throw new RangeError(`${system} value ${value} is outside the range 1 to ${maximum}`);
|
|
60
|
+
}
|
|
61
|
+
function roman(value) {
|
|
62
|
+
let remaining = value;
|
|
63
|
+
let result = "";
|
|
64
|
+
for (const [amount, digit] of ROMAN_DIGITS) while (remaining >= amount) {
|
|
65
|
+
result += digit;
|
|
66
|
+
remaining -= amount;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
function hebrewBelowThousand(value) {
|
|
71
|
+
const hundreds = "ת".repeat(Math.floor(value / 400));
|
|
72
|
+
const underFourHundred = value % 400;
|
|
73
|
+
const hundredsLetter = [
|
|
74
|
+
"",
|
|
75
|
+
"ק",
|
|
76
|
+
"ר",
|
|
77
|
+
"ש"
|
|
78
|
+
][Math.floor(underFourHundred / 100)];
|
|
79
|
+
const remainder = underFourHundred % 100;
|
|
80
|
+
if (remainder === 15) return `${hundreds}${hundredsLetter}טו`;
|
|
81
|
+
if (remainder === 16) return `${hundreds}${hundredsLetter}טז`;
|
|
82
|
+
return `${hundreds}${hundredsLetter}${HEBREW_TENS[Math.floor(remainder / 10)]}${HEBREW_ONES[remainder % 10]}`;
|
|
83
|
+
}
|
|
84
|
+
function hebrew(value) {
|
|
85
|
+
const thousands = Math.floor(value / 1e3);
|
|
86
|
+
const rest = value % 1e3;
|
|
87
|
+
return `${thousands === 0 ? "" : `${HEBREW_ONES[thousands]}׳`}${hebrewBelowThousand(rest)}`;
|
|
88
|
+
}
|
|
89
|
+
function formatNumber(value, system) {
|
|
90
|
+
positiveInteger(value);
|
|
91
|
+
if (system === "arabic") return String(value);
|
|
92
|
+
if (system === "hebrew") {
|
|
93
|
+
inRange(value, 9999, system);
|
|
94
|
+
return hebrew(value);
|
|
95
|
+
}
|
|
96
|
+
inRange(value, 3999, system);
|
|
97
|
+
const result = roman(value);
|
|
98
|
+
return system === "roman-lower" ? result.toLowerCase() : result;
|
|
99
|
+
}
|
|
100
|
+
function noteMarker(index, marker) {
|
|
101
|
+
positiveInteger(index);
|
|
102
|
+
if (marker !== "symbols") return formatNumber(index, marker);
|
|
103
|
+
return NOTE_SYMBOLS[(index - 1) % NOTE_SYMBOLS.length].repeat(Math.ceil(index / NOTE_SYMBOLS.length));
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { NoteMarker, NumberSystem, formatNumber, noteMarker };
|
package/dist/paper.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Print } from "./index.js";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
//#region src/paper.d.ts
|
|
4
|
+
export declare const NAMED_PAPERS: readonly ["letter", "legal", "tabloid", "a3", "a4", "a5"];
|
|
5
|
+
export declare const Paper: z.ZodUnion<readonly [z.ZodEnum<{
|
|
6
|
+
letter: "letter";
|
|
7
|
+
legal: "legal";
|
|
8
|
+
tabloid: "tabloid";
|
|
9
|
+
a3: "a3";
|
|
10
|
+
a4: "a4";
|
|
11
|
+
a5: "a5";
|
|
12
|
+
}>, z.ZodObject<{
|
|
13
|
+
width: z.ZodNumber;
|
|
14
|
+
height: z.ZodNumber;
|
|
15
|
+
unit: z.ZodEnum<{
|
|
16
|
+
mm: "mm";
|
|
17
|
+
in: "in";
|
|
18
|
+
pt: "pt";
|
|
19
|
+
}>;
|
|
20
|
+
}, z.core.$strip>]>;
|
|
21
|
+
export type Paper = z.infer<typeof Paper>;
|
|
3
22
|
export declare const MM_PER_PT: number;
|
|
4
23
|
export declare const MARK_LENGTH_MM = 5;
|
|
5
24
|
export declare const MARK_GAP_MM = 1;
|
package/dist/paper.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
//#region src/paper.ts
|
|
3
|
+
const NAMED_PAPERS = [
|
|
4
|
+
"letter",
|
|
5
|
+
"legal",
|
|
6
|
+
"tabloid",
|
|
7
|
+
"a3",
|
|
8
|
+
"a4",
|
|
9
|
+
"a5"
|
|
10
|
+
];
|
|
11
|
+
const Paper = z.union([z.enum(NAMED_PAPERS), z.object({
|
|
12
|
+
width: z.number().positive(),
|
|
13
|
+
height: z.number().positive(),
|
|
14
|
+
unit: z.enum([
|
|
15
|
+
"mm",
|
|
16
|
+
"in",
|
|
17
|
+
"pt"
|
|
18
|
+
])
|
|
19
|
+
})]);
|
|
2
20
|
const MM_PER_PT = 25.4 / 72;
|
|
3
21
|
const MARK_LENGTH_MM = 5;
|
|
4
22
|
const MARK_GAP_MM = 1;
|
|
@@ -156,4 +174,4 @@ function printBoxes(print) {
|
|
|
156
174
|
};
|
|
157
175
|
}
|
|
158
176
|
//#endregion
|
|
159
|
-
export { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, PAPER_MM, PX_PER_MM, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters };
|
|
177
|
+
export { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters };
|
package/dist/scripts.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/shots-used.ts
|
|
2
|
+
function shotsUsed(deck) {
|
|
3
|
+
return deck.slides.flatMap((slide) => {
|
|
4
|
+
if (slide.content.kind === "shot") return [{
|
|
5
|
+
slide: slide.id,
|
|
6
|
+
key: slide.content.shot.key
|
|
7
|
+
}];
|
|
8
|
+
if (slide.content.kind === "shot-ref") return [{
|
|
9
|
+
slide: slide.id,
|
|
10
|
+
href: slide.content.href
|
|
11
|
+
}];
|
|
12
|
+
return [];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { shotsUsed };
|
package/dist/timing.d.ts
ADDED
package/dist/timing.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/timing.ts
|
|
3
|
+
const MAX_SLIDE_TIMING_MS = 6e5;
|
|
4
|
+
const SlideTiming = z.number().finite().min(0).max(MAX_SLIDE_TIMING_MS);
|
|
5
|
+
function slideTimingIssues(slide) {
|
|
6
|
+
if (slide.narration) return slide.holdMs === void 0 ? [] : ["holdMs"];
|
|
7
|
+
return ["beforeMs", "afterMs"].filter((field) => slide[field] !== void 0);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { MAX_SLIDE_TIMING_MS, SlideTiming, slideTimingIssues };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/transition.d.ts
|
|
3
|
+
export declare const MIN_TRANSITION_DURATION_MS = 0;
|
|
4
|
+
export declare const MAX_TRANSITION_DURATION_MS = 2000;
|
|
5
|
+
export declare const DEFAULT_TRANSITION_DURATION_MS = 300;
|
|
6
|
+
export declare const Transition: z.ZodObject<{
|
|
7
|
+
kind: z.ZodEnum<{
|
|
8
|
+
none: "none";
|
|
9
|
+
fade: "fade";
|
|
10
|
+
slide: "slide";
|
|
11
|
+
}>;
|
|
12
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type Transition = z.infer<typeof Transition>;
|
|
15
|
+
export type TransitionInput = z.input<typeof Transition>;
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/transition.ts
|
|
3
|
+
const MIN_TRANSITION_DURATION_MS = 0;
|
|
4
|
+
const MAX_TRANSITION_DURATION_MS = 2e3;
|
|
5
|
+
const DEFAULT_TRANSITION_DURATION_MS = 300;
|
|
6
|
+
const Transition = z.object({
|
|
7
|
+
kind: z.enum([
|
|
8
|
+
"none",
|
|
9
|
+
"fade",
|
|
10
|
+
"slide"
|
|
11
|
+
]),
|
|
12
|
+
duration: z.number().int().min(0).max(MAX_TRANSITION_DURATION_MS).default(300)
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition };
|