postext 1.2.2 → 1.3.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/README.md +18 -0
- package/dist/__tests__/bundle.test.d.ts +2 -0
- package/dist/__tests__/bundle.test.d.ts.map +1 -0
- package/dist/__tests__/bundle.test.js +210 -0
- package/dist/__tests__/bundle.test.js.map +1 -0
- package/dist/__tests__/columnBalancing.test.js +23 -0
- package/dist/__tests__/columnBalancing.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +15 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/parts.test.js +14 -0
- package/dist/__tests__/parts.test.js.map +1 -1
- package/dist/__tests__/pipeline/scratchDeepSky.test.d.ts +3 -0
- package/dist/__tests__/pipeline/scratchDeepSky.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/scratchDeepSky.test.js +137 -0
- package/dist/__tests__/pipeline/scratchDeepSky.test.js.map +1 -0
- package/dist/__tests__/pipeline/spanBands.test.js +18 -0
- package/dist/__tests__/pipeline/spanBands.test.js.map +1 -1
- package/dist/bundle/adapters.d.ts +38 -0
- package/dist/bundle/adapters.d.ts.map +1 -0
- package/dist/bundle/adapters.js +142 -0
- package/dist/bundle/adapters.js.map +1 -0
- package/dist/bundle/api.d.ts +94 -0
- package/dist/bundle/api.d.ts.map +1 -0
- package/dist/bundle/api.js +91 -0
- package/dist/bundle/api.js.map +1 -0
- package/dist/bundle/book.d.ts +24 -0
- package/dist/bundle/book.d.ts.map +1 -0
- package/dist/bundle/book.js +55 -0
- package/dist/bundle/book.js.map +1 -0
- package/dist/bundle/codec.d.ts +105 -0
- package/dist/bundle/codec.d.ts.map +1 -0
- package/dist/bundle/codec.js +245 -0
- package/dist/bundle/codec.js.map +1 -0
- package/dist/bundle/index.d.ts +14 -0
- package/dist/bundle/index.d.ts.map +1 -0
- package/dist/bundle/index.js +10 -0
- package/dist/bundle/index.js.map +1 -0
- package/dist/bundle/manifest.d.ts +76 -0
- package/dist/bundle/manifest.d.ts.map +1 -0
- package/dist/bundle/manifest.js +444 -0
- package/dist/bundle/manifest.js.map +1 -0
- package/dist/bundle/types.d.ts +141 -0
- package/dist/bundle/types.d.ts.map +1 -0
- package/dist/bundle/types.js +6 -0
- package/dist/bundle/types.js.map +1 -0
- package/dist/bundle/zip.d.ts +23 -0
- package/dist/bundle/zip.d.ts.map +1 -0
- package/dist/bundle/zip.js +87 -0
- package/dist/bundle/zip.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +24 -1
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/calloutLayout.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.js +6 -5
- package/dist/pipeline/calloutLayout.js.map +1 -1
- package/dist/pipeline/columnBalancing.d.ts.map +1 -1
- package/dist/pipeline/columnBalancing.js +14 -2
- package/dist/pipeline/columnBalancing.js.map +1 -1
- package/dist/pipeline/placeholders.d.ts +2 -1
- package/dist/pipeline/placeholders.d.ts.map +1 -1
- package/dist/pipeline/placeholders.js +11 -1
- package/dist/pipeline/placeholders.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
// Pure helpers for bundle manifests: validation, locale resolution, file
|
|
2
|
+
// naming, and conversion of manifest entries into engine resources and
|
|
3
|
+
// custom fonts. No DOM or storage access.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Validation
|
|
6
|
+
function isRecord(v) {
|
|
7
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
8
|
+
}
|
|
9
|
+
function isNonEmptyString(v) {
|
|
10
|
+
return typeof v === 'string' && v.length > 0;
|
|
11
|
+
}
|
|
12
|
+
function isOptionalString(v) {
|
|
13
|
+
return v === undefined || typeof v === 'string';
|
|
14
|
+
}
|
|
15
|
+
function isOptionalStringList(v) {
|
|
16
|
+
return v === undefined || (Array.isArray(v) && v.every(isNonEmptyString));
|
|
17
|
+
}
|
|
18
|
+
/** The optional showcase fields: wrong types reject the manifest rather
|
|
19
|
+
* than being silently dropped. */
|
|
20
|
+
export function hasValidShowcaseMeta(v) {
|
|
21
|
+
return isOptionalStringList(v.locales)
|
|
22
|
+
&& isOptionalString(v.thumbnail)
|
|
23
|
+
&& isOptionalString(v.license)
|
|
24
|
+
&& isOptionalString(v.credits)
|
|
25
|
+
&& isOptionalStringList(v.tags);
|
|
26
|
+
}
|
|
27
|
+
function isMarkdownField(v) {
|
|
28
|
+
if (isNonEmptyString(v))
|
|
29
|
+
return true;
|
|
30
|
+
if (!isRecord(v))
|
|
31
|
+
return false;
|
|
32
|
+
const values = Object.values(v);
|
|
33
|
+
return values.length > 0 && values.every(isNonEmptyString);
|
|
34
|
+
}
|
|
35
|
+
function isChapterSpec(v) {
|
|
36
|
+
return isRecord(v) && typeof v.title === 'string' && isNonEmptyString(v.file);
|
|
37
|
+
}
|
|
38
|
+
function isChapterList(v) {
|
|
39
|
+
return Array.isArray(v) && v.length > 0 && v.every(isChapterSpec);
|
|
40
|
+
}
|
|
41
|
+
function isChaptersField(v) {
|
|
42
|
+
if (isChapterList(v))
|
|
43
|
+
return true;
|
|
44
|
+
if (!isRecord(v))
|
|
45
|
+
return false;
|
|
46
|
+
const values = Object.values(v);
|
|
47
|
+
return values.length > 0 && values.every(isChapterList);
|
|
48
|
+
}
|
|
49
|
+
function isLocaleOverrides(v) {
|
|
50
|
+
if (!isRecord(v))
|
|
51
|
+
return false;
|
|
52
|
+
if (v.config !== undefined && !isRecord(v.config))
|
|
53
|
+
return false;
|
|
54
|
+
if (v.resources !== undefined) {
|
|
55
|
+
if (!Array.isArray(v.resources))
|
|
56
|
+
return false;
|
|
57
|
+
if (!v.resources.every((r) => isRecord(r) && isNonEmptyString(r.id)))
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function isViewField(v) {
|
|
63
|
+
if (!isRecord(v))
|
|
64
|
+
return false;
|
|
65
|
+
return v.canvasScope === undefined || v.canvasScope === 'book' || v.canvasScope === 'chapter';
|
|
66
|
+
}
|
|
67
|
+
function isLocalizedField(v) {
|
|
68
|
+
return isRecord(v) && Object.values(v).every(isLocaleOverrides);
|
|
69
|
+
}
|
|
70
|
+
/** True when `data` is a valid `preset.json`, version 1 (`markdown`) or 2
|
|
71
|
+
* (`chapters`). */
|
|
72
|
+
export function isBundleManifest(data) {
|
|
73
|
+
if (!isRecord(data))
|
|
74
|
+
return false;
|
|
75
|
+
if (data.version !== 1 && data.version !== 2)
|
|
76
|
+
return false;
|
|
77
|
+
if (!isNonEmptyString(data.id) || !isNonEmptyString(data.name))
|
|
78
|
+
return false;
|
|
79
|
+
if (data.version === 1 && !isMarkdownField(data.markdown))
|
|
80
|
+
return false;
|
|
81
|
+
if (data.version === 2 && !isChaptersField(data.chapters))
|
|
82
|
+
return false;
|
|
83
|
+
if (!hasValidShowcaseMeta(data))
|
|
84
|
+
return false;
|
|
85
|
+
if (data.view !== undefined && !isViewField(data.view))
|
|
86
|
+
return false;
|
|
87
|
+
if (data.localized !== undefined && !isLocalizedField(data.localized))
|
|
88
|
+
return false;
|
|
89
|
+
if (data.config !== undefined && !isRecord(data.config))
|
|
90
|
+
return false;
|
|
91
|
+
if (data.resources !== undefined) {
|
|
92
|
+
if (!Array.isArray(data.resources))
|
|
93
|
+
return false;
|
|
94
|
+
if (!data.resources.every((r) => isRecord(r) && isNonEmptyString(r.id) && isNonEmptyString(r.typeId)))
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (data.fonts !== undefined) {
|
|
98
|
+
if (!Array.isArray(data.fonts))
|
|
99
|
+
return false;
|
|
100
|
+
const ok = data.fonts.every((f) => isRecord(f) && isNonEmptyString(f.name) && Array.isArray(f.variants)
|
|
101
|
+
&& f.variants.every((v) => isRecord(v) && typeof v.weight === 'number' && isNonEmptyString(v.file)));
|
|
102
|
+
if (!ok)
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Locale resolution
|
|
109
|
+
/** The key of a locale → value map that serves `locale`: exact tag, base
|
|
110
|
+
* language, the manifest's own locale, then the first key. */
|
|
111
|
+
function pickLocaleKey(keys, locale, manifestLocale) {
|
|
112
|
+
const wanted = locale.toLowerCase();
|
|
113
|
+
const byLower = new Map(keys.map((k) => [k.toLowerCase(), k]));
|
|
114
|
+
const exact = byLower.get(wanted);
|
|
115
|
+
if (exact)
|
|
116
|
+
return exact;
|
|
117
|
+
const base = wanted.split(/[-_]/)[0];
|
|
118
|
+
const baseKey = byLower.get(base);
|
|
119
|
+
if (baseKey)
|
|
120
|
+
return baseKey;
|
|
121
|
+
if (manifestLocale) {
|
|
122
|
+
const own = byLower.get(manifestLocale.toLowerCase())
|
|
123
|
+
?? byLower.get(manifestLocale.toLowerCase().split(/[-_]/)[0]);
|
|
124
|
+
if (own)
|
|
125
|
+
return own;
|
|
126
|
+
}
|
|
127
|
+
return keys[0];
|
|
128
|
+
}
|
|
129
|
+
function pickByLocale(map, locale, manifestLocale) {
|
|
130
|
+
return map[pickLocaleKey(Object.keys(map), locale, manifestLocale)];
|
|
131
|
+
}
|
|
132
|
+
/** Which markdown file a version 1 manifest serves for `locale`. */
|
|
133
|
+
export function pickMarkdownFile(manifest, locale) {
|
|
134
|
+
const md = manifest.markdown;
|
|
135
|
+
if (typeof md === 'string')
|
|
136
|
+
return md;
|
|
137
|
+
return pickByLocale(md, locale, manifest.locale);
|
|
138
|
+
}
|
|
139
|
+
/** The per-locale overrides that apply to `locale`, or null when the
|
|
140
|
+
* manifest has none. A bundle whose chapters are a locale map applies the
|
|
141
|
+
* overrides of the locale its chapters were picked from, so text and
|
|
142
|
+
* wording never disagree. */
|
|
143
|
+
export function pickLocaleOverrides(manifest, locale) {
|
|
144
|
+
const localized = manifest.localized;
|
|
145
|
+
if (!localized || Object.keys(localized).length === 0)
|
|
146
|
+
return null;
|
|
147
|
+
const chapterMap = manifest.version === 2 && !Array.isArray(manifest.chapters) ? manifest.chapters
|
|
148
|
+
: manifest.version === 1 && typeof manifest.markdown !== 'string' ? manifest.markdown
|
|
149
|
+
: null;
|
|
150
|
+
const key = chapterMap
|
|
151
|
+
? pickLocaleKey(Object.keys(chapterMap), locale, manifest.locale)
|
|
152
|
+
: pickLocaleKey(Object.keys(localized), locale, manifest.locale);
|
|
153
|
+
// Only that locale's own overrides (exact tag or base language) apply: a
|
|
154
|
+
// locale without any keeps the shared wording.
|
|
155
|
+
const wanted = key.toLowerCase();
|
|
156
|
+
const base = wanted.split(/[-_]/)[0];
|
|
157
|
+
const keys = Object.keys(localized);
|
|
158
|
+
const found = keys.find((k) => k.toLowerCase() === wanted)
|
|
159
|
+
?? keys.find((k) => k.toLowerCase().split(/[-_]/)[0] === base);
|
|
160
|
+
return found ? localized[found] : null;
|
|
161
|
+
}
|
|
162
|
+
/** The locale a bundle actually serves for `locale`: the key of its
|
|
163
|
+
* chapter map when the content is a locale map, else the manifest's own
|
|
164
|
+
* locale, else `locale` itself. */
|
|
165
|
+
export function resolveBundleLocale(manifest, locale) {
|
|
166
|
+
const map = manifest.version === 2
|
|
167
|
+
? (Array.isArray(manifest.chapters) ? null : manifest.chapters)
|
|
168
|
+
: (typeof manifest.markdown === 'string' ? null : manifest.markdown);
|
|
169
|
+
if (map)
|
|
170
|
+
return pickLocaleKey(Object.keys(map), locale, manifest.locale);
|
|
171
|
+
return manifest.locale ?? locale;
|
|
172
|
+
}
|
|
173
|
+
/** The chapter files to read for `locale`: a version 1 manifest yields a
|
|
174
|
+
* single untitled chapter. */
|
|
175
|
+
export function pickChapterSpecs(manifest, locale) {
|
|
176
|
+
if (manifest.version === 1)
|
|
177
|
+
return [{ title: '', file: pickMarkdownFile(manifest, locale) }];
|
|
178
|
+
const ch = manifest.chapters;
|
|
179
|
+
return Array.isArray(ch) ? ch : pickByLocale(ch, locale, manifest.locale);
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// File names
|
|
183
|
+
/** Lowercase, hyphen-separated slug: diacritics stripped, runs of anything
|
|
184
|
+
* else collapsed to one hyphen. '' for symbol-only input. */
|
|
185
|
+
export function slugify(input) {
|
|
186
|
+
return input
|
|
187
|
+
.normalize('NFKD')
|
|
188
|
+
.replace(/[̀-ͯ]/g, '')
|
|
189
|
+
.toLowerCase()
|
|
190
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
191
|
+
.replace(/^-+|-+$/g, '');
|
|
192
|
+
}
|
|
193
|
+
/** `candidate`, or `candidate-2`, `-3`, … when `taken` has it; a blank
|
|
194
|
+
* candidate falls back to `fallback`. */
|
|
195
|
+
export function uniqueSlug(candidate, taken, fallback = 'resource') {
|
|
196
|
+
const base = candidate || fallback;
|
|
197
|
+
if (!taken.has(base))
|
|
198
|
+
return base;
|
|
199
|
+
let n = 2;
|
|
200
|
+
while (taken.has(`${base}-${n}`))
|
|
201
|
+
n++;
|
|
202
|
+
return `${base}-${n}`;
|
|
203
|
+
}
|
|
204
|
+
/** `chapters/01-intro.md`: zero-padded ordinal (at least two digits) plus a
|
|
205
|
+
* slug of the title, unique against `taken` (which it extends). */
|
|
206
|
+
export function chapterFileName(index, title, taken, count = 1) {
|
|
207
|
+
const digits = Math.max(2, String(count).length);
|
|
208
|
+
const ordinal = String(index + 1).padStart(digits, '0');
|
|
209
|
+
const name = uniqueSlug(`${ordinal}-${slugify(title) || 'chapter'}`, taken, 'chapter');
|
|
210
|
+
taken.add(name);
|
|
211
|
+
return `chapters/${name}.md`;
|
|
212
|
+
}
|
|
213
|
+
export function fileExtension(file) {
|
|
214
|
+
const base = file.split('/').pop() ?? file;
|
|
215
|
+
const dot = base.lastIndexOf('.');
|
|
216
|
+
return dot === -1 ? '' : base.slice(dot + 1).toLowerCase();
|
|
217
|
+
}
|
|
218
|
+
export function fileBasename(file) {
|
|
219
|
+
return file.split('/').pop() ?? file;
|
|
220
|
+
}
|
|
221
|
+
const MIME_BY_EXT = {
|
|
222
|
+
svg: 'image/svg+xml',
|
|
223
|
+
png: 'image/png',
|
|
224
|
+
jpg: 'image/jpeg',
|
|
225
|
+
jpeg: 'image/jpeg',
|
|
226
|
+
webp: 'image/webp',
|
|
227
|
+
gif: 'image/gif',
|
|
228
|
+
pdf: 'application/pdf',
|
|
229
|
+
ttf: 'font/ttf',
|
|
230
|
+
otf: 'font/otf',
|
|
231
|
+
woff2: 'font/woff2',
|
|
232
|
+
md: 'text/markdown',
|
|
233
|
+
json: 'application/json',
|
|
234
|
+
};
|
|
235
|
+
/** Media type of a bundle file, from its extension. */
|
|
236
|
+
export function mimeForFile(file) {
|
|
237
|
+
return MIME_BY_EXT[fileExtension(file)] ?? 'application/octet-stream';
|
|
238
|
+
}
|
|
239
|
+
const BITMAP_FORMAT_BY_EXT = {
|
|
240
|
+
png: 'png',
|
|
241
|
+
jpg: 'jpeg',
|
|
242
|
+
jpeg: 'jpeg',
|
|
243
|
+
webp: 'webp',
|
|
244
|
+
gif: 'gif',
|
|
245
|
+
};
|
|
246
|
+
/** True when `file` is a bitmap the engine can place. */
|
|
247
|
+
export function isBitmapFile(file) {
|
|
248
|
+
return fileExtension(file) in BITMAP_FORMAT_BY_EXT;
|
|
249
|
+
}
|
|
250
|
+
export function isSvgFile(file) {
|
|
251
|
+
return fileExtension(file) === 'svg';
|
|
252
|
+
}
|
|
253
|
+
export function isPdfFile(file) {
|
|
254
|
+
return fileExtension(file) === 'pdf';
|
|
255
|
+
}
|
|
256
|
+
/** Font format of a file name, or null when it is not a font. */
|
|
257
|
+
export function fontFormatFromFile(file) {
|
|
258
|
+
switch (fileExtension(file)) {
|
|
259
|
+
case 'woff2': return 'woff2';
|
|
260
|
+
case 'woff': return 'woff';
|
|
261
|
+
case 'ttf': return 'ttf';
|
|
262
|
+
case 'otf': return 'otf';
|
|
263
|
+
default: return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const EXT_BY_BITMAP_FORMAT = {
|
|
267
|
+
png: 'png',
|
|
268
|
+
jpeg: 'jpg',
|
|
269
|
+
webp: 'webp',
|
|
270
|
+
gif: 'gif',
|
|
271
|
+
};
|
|
272
|
+
const EXT_BY_IMAGE_MIME = {
|
|
273
|
+
'image/png': 'png',
|
|
274
|
+
'image/jpeg': 'jpg',
|
|
275
|
+
'image/webp': 'webp',
|
|
276
|
+
'image/gif': 'gif',
|
|
277
|
+
'image/svg+xml': 'svg',
|
|
278
|
+
};
|
|
279
|
+
/** File extension to write an image of this media type under, or null when
|
|
280
|
+
* it is not a picture a bundle takes (a cover thumbnail). */
|
|
281
|
+
export function extensionForImageMime(mime) {
|
|
282
|
+
return EXT_BY_IMAGE_MIME[mime.toLowerCase()] ?? null;
|
|
283
|
+
}
|
|
284
|
+
/** File extension to write a resource's bytes under, or null for resources
|
|
285
|
+
* without a file (tables). */
|
|
286
|
+
export function extensionForResource(r) {
|
|
287
|
+
if (r.kind === 'svg' && r.svg)
|
|
288
|
+
return 'svg';
|
|
289
|
+
if (r.kind === 'bitmap' && r.bitmap)
|
|
290
|
+
return EXT_BY_BITMAP_FORMAT[r.bitmap.format] ?? r.bitmap.format;
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const identity = (file) => file;
|
|
294
|
+
/** Turn manifest font families into `config.customFonts` entries plus the
|
|
295
|
+
* list of files to read. `.woff` is not supported by the PDF backend and
|
|
296
|
+
* is skipped with a warning, as is any unrecognised extension. */
|
|
297
|
+
export function fontsToCustomFonts(fonts, fileIdFor = identity) {
|
|
298
|
+
const families = [];
|
|
299
|
+
const files = [];
|
|
300
|
+
const warnings = [];
|
|
301
|
+
for (const family of fonts) {
|
|
302
|
+
const variants = [];
|
|
303
|
+
for (const v of family.variants) {
|
|
304
|
+
const format = fontFormatFromFile(v.file);
|
|
305
|
+
if (!format || format === 'woff') {
|
|
306
|
+
warnings.push(`${family.name}: unsupported font file "${v.file}"`);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const fileId = fileIdFor(v.file);
|
|
310
|
+
const fileName = fileBasename(v.file);
|
|
311
|
+
const style = v.style === 'italic' ? 'italic' : 'normal';
|
|
312
|
+
variants.push({ weight: v.weight, style, fileId, format, fileName });
|
|
313
|
+
files.push({ fileId, fileName, format, file: v.file, family: family.name, weight: v.weight, style });
|
|
314
|
+
}
|
|
315
|
+
if (variants.length > 0) {
|
|
316
|
+
families.push({ name: family.name, variants, ...(family.redistributable === false ? { redistributable: false } : {}) });
|
|
317
|
+
}
|
|
318
|
+
else
|
|
319
|
+
warnings.push(`${family.name}: no usable variants`);
|
|
320
|
+
}
|
|
321
|
+
return { families, files, warnings };
|
|
322
|
+
}
|
|
323
|
+
/** Build an engine `Resource` from a manifest entry. `size` supplies the
|
|
324
|
+
* intrinsic dimensions when the spec omits them. Bitmap/SVG kind is
|
|
325
|
+
* derived from the file extension. */
|
|
326
|
+
export function resourceFromSpec(spec, size, fileIdFor = identity) {
|
|
327
|
+
const now = Date.now();
|
|
328
|
+
const { file, pdfFile, width, height, ...rest } = spec;
|
|
329
|
+
const base = { ...rest, createdAt: now, updatedAt: now };
|
|
330
|
+
if (!file)
|
|
331
|
+
return base;
|
|
332
|
+
const fileId = fileIdFor(file);
|
|
333
|
+
const w = width ?? size?.width;
|
|
334
|
+
const h = height ?? size?.height;
|
|
335
|
+
if (isSvgFile(file)) {
|
|
336
|
+
const master = pdfFile && isPdfFile(pdfFile) ? { pdfFileId: fileIdFor(pdfFile) } : {};
|
|
337
|
+
return {
|
|
338
|
+
...base,
|
|
339
|
+
kind: 'svg',
|
|
340
|
+
svg: w && h ? { fileId, width: w, height: h, ...master } : { fileId, ...master },
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const format = BITMAP_FORMAT_BY_EXT[fileExtension(file)];
|
|
344
|
+
if (format) {
|
|
345
|
+
return {
|
|
346
|
+
...base,
|
|
347
|
+
kind: 'bitmap',
|
|
348
|
+
bitmap: { fileId, format, width: w ?? 0, height: h ?? 0 },
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
return base;
|
|
352
|
+
}
|
|
353
|
+
// ---------------------------------------------------------------------------
|
|
354
|
+
// Intrinsic sizes, without a DOM
|
|
355
|
+
function parseSvgLength(value) {
|
|
356
|
+
if (!value)
|
|
357
|
+
return null;
|
|
358
|
+
const trimmed = value.trim();
|
|
359
|
+
if (trimmed.endsWith('%'))
|
|
360
|
+
return null;
|
|
361
|
+
const num = parseFloat(trimmed);
|
|
362
|
+
if (!Number.isFinite(num) || num <= 0)
|
|
363
|
+
return null;
|
|
364
|
+
const unit = trimmed.replace(/^[\d.+-]+/, '').toLowerCase();
|
|
365
|
+
const factor = unit === 'pt' ? 96 / 72 : unit === 'pc' ? 16 : unit === 'in' ? 96 : unit === 'cm' ? 96 / 2.54 : unit === 'mm' ? 96 / 25.4 : 1;
|
|
366
|
+
return num * factor;
|
|
367
|
+
}
|
|
368
|
+
/** An SVG's intrinsic pixel size from its root element: explicit
|
|
369
|
+
* `width`/`height`, else the `viewBox` extent; undefined when neither
|
|
370
|
+
* gives one. Reads the markup textually, so it runs anywhere. */
|
|
371
|
+
export function svgSize(markup) {
|
|
372
|
+
const tag = /<svg\b([^>]*)>/i.exec(markup.replace(/<!--[\s\S]*?-->/g, ''));
|
|
373
|
+
if (!tag)
|
|
374
|
+
return undefined;
|
|
375
|
+
const attrs = {};
|
|
376
|
+
for (const m of tag[1].matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) {
|
|
377
|
+
attrs[m[1]] = m[3] ?? m[4] ?? '';
|
|
378
|
+
}
|
|
379
|
+
const w = parseSvgLength(attrs.width);
|
|
380
|
+
const h = parseSvgLength(attrs.height);
|
|
381
|
+
if (w && h)
|
|
382
|
+
return { width: w, height: h };
|
|
383
|
+
const viewBox = attrs.viewBox;
|
|
384
|
+
if (viewBox) {
|
|
385
|
+
const parts = viewBox.trim().split(/[\s,]+/).map(Number);
|
|
386
|
+
if (parts.length === 4 && parts.every(Number.isFinite) && parts[2] > 0 && parts[3] > 0) {
|
|
387
|
+
return { width: parts[2], height: parts[3] };
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
/** A bitmap's pixel size read from its header (PNG, JPEG, GIF, WebP), or
|
|
393
|
+
* undefined when the header is not recognised. */
|
|
394
|
+
export function bitmapSize(bytes) {
|
|
395
|
+
const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
396
|
+
const view = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
397
|
+
const ascii = (at, len) => String.fromCharCode(...b.subarray(at, at + len));
|
|
398
|
+
if (b.length >= 24 && b[0] === 0x89 && ascii(1, 3) === 'PNG') {
|
|
399
|
+
return { width: view.getUint32(16), height: view.getUint32(20) };
|
|
400
|
+
}
|
|
401
|
+
if (b.length >= 10 && ascii(0, 3) === 'GIF') {
|
|
402
|
+
return { width: view.getUint16(6, true), height: view.getUint16(8, true) };
|
|
403
|
+
}
|
|
404
|
+
if (b.length >= 30 && ascii(0, 4) === 'RIFF' && ascii(8, 4) === 'WEBP') {
|
|
405
|
+
const chunk = ascii(12, 4);
|
|
406
|
+
if (chunk === 'VP8X') {
|
|
407
|
+
const w = 1 + (b[24] | (b[25] << 8) | (b[26] << 16));
|
|
408
|
+
const h = 1 + (b[27] | (b[28] << 8) | (b[29] << 16));
|
|
409
|
+
return { width: w, height: h };
|
|
410
|
+
}
|
|
411
|
+
if (chunk === 'VP8 ')
|
|
412
|
+
return { width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff };
|
|
413
|
+
if (chunk === 'VP8L') {
|
|
414
|
+
const bits = view.getUint32(21, true);
|
|
415
|
+
return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };
|
|
416
|
+
}
|
|
417
|
+
return undefined;
|
|
418
|
+
}
|
|
419
|
+
if (b.length >= 4 && b[0] === 0xff && b[1] === 0xd8) {
|
|
420
|
+
let i = 2;
|
|
421
|
+
while (i + 9 < b.length) {
|
|
422
|
+
if (b[i] !== 0xff) {
|
|
423
|
+
i++;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const marker = b[i + 1];
|
|
427
|
+
if (marker === 0xff) {
|
|
428
|
+
i++;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
// Start-of-frame markers carry the size (not DHT, JPG, DAC).
|
|
432
|
+
if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
|
|
433
|
+
return { width: view.getUint16(i + 7), height: view.getUint16(i + 5) };
|
|
434
|
+
}
|
|
435
|
+
if (marker === 0xd8 || (marker >= 0xd0 && marker <= 0xd7) || marker === 0x01) {
|
|
436
|
+
i += 2;
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
i += 2 + view.getUint16(i + 2);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/bundle/manifest.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,uEAAuE;AACvE,0CAA0C;AAc1C,8EAA8E;AAC9E,aAAa;AAEb,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAU;IAClC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,gBAAgB,CAAC,C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,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { CustomFontFormat, PostextConfig, Resource } from '../types';
|
|
2
|
+
/** Optional showcase metadata a manifest may carry: everything a picker can
|
|
3
|
+
* show beyond name and description. All fields are purely descriptive. */
|
|
4
|
+
export interface BundleShowcaseMeta {
|
|
5
|
+
/** Every locale the bundle carries chapters for (a bilingual bundle lists
|
|
6
|
+
* both); `locale` stays the primary one. */
|
|
7
|
+
locales?: string[];
|
|
8
|
+
/** Preview image (`thumbnail.jpg`), relative to the bundle root. */
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
/** Licence of the bundled content, as a short label (`CC BY 4.0`). */
|
|
11
|
+
license?: string;
|
|
12
|
+
/** One-line credit for the content and imagery sources. */
|
|
13
|
+
credits?: string;
|
|
14
|
+
/** Free-form tags (`two-column`, `magazine`, `book`). */
|
|
15
|
+
tags?: string[];
|
|
16
|
+
}
|
|
17
|
+
/** A resource declaration inside `preset.json`. Bitmap/SVG payloads are
|
|
18
|
+
* referenced by `file` (relative to the bundle root); tables keep their
|
|
19
|
+
* model inline. `width`/`height` are optional — when missing they are read
|
|
20
|
+
* from the file when the bundle is opened. */
|
|
21
|
+
export type BundleResourceSpec = Omit<Resource, 'createdAt' | 'updatedAt' | 'bitmap' | 'svg'> & {
|
|
22
|
+
file?: string;
|
|
23
|
+
/** SVG resources only: a single-page PDF holding the same figure as
|
|
24
|
+
* vectors, embedded verbatim by the PDF backend in place of the SVG
|
|
25
|
+
* (`Resource.svg.pdfFileId`). */
|
|
26
|
+
pdfFile?: string;
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
/** Source line / credits set under the resource (`Resource.note`). */
|
|
30
|
+
note?: string;
|
|
31
|
+
};
|
|
32
|
+
export interface BundleFontVariantSpec {
|
|
33
|
+
weight: number;
|
|
34
|
+
style: 'normal' | 'italic';
|
|
35
|
+
/** Font file relative to the bundle root (`.ttf`, `.otf` or `.woff2`). */
|
|
36
|
+
file: string;
|
|
37
|
+
}
|
|
38
|
+
export interface BundleFontFamilySpec {
|
|
39
|
+
name: string;
|
|
40
|
+
variants: BundleFontVariantSpec[];
|
|
41
|
+
/** False when the bundle may set its pages with this family but must not
|
|
42
|
+
* pass the files on: writing the bundle out again leaves the family's
|
|
43
|
+
* files (and its `fonts[]` entry) behind. Defaults to true. */
|
|
44
|
+
redistributable?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** One chapter file inside a version 2 bundle (`chapters/01-intro.md`). */
|
|
47
|
+
export interface BundleChapterSpec {
|
|
48
|
+
title: string;
|
|
49
|
+
file: string;
|
|
50
|
+
}
|
|
51
|
+
/** What a bilingual bundle changes per locale on top of its shared `config`
|
|
52
|
+
* and `resources`: top-level config keys replaced wholesale for that
|
|
53
|
+
* locale, and the wording of resources — caption, note, alt text, a
|
|
54
|
+
* table's cells — merged by id. A resource whose artwork carries words may
|
|
55
|
+
* also name its own `file` for the locale. */
|
|
56
|
+
export interface BundleLocaleOverrides {
|
|
57
|
+
config?: Partial<PostextConfig>;
|
|
58
|
+
resources?: (Pick<BundleResourceSpec, 'id'> & Partial<Pick<BundleResourceSpec, 'caption' | 'note' | 'altText' | 'table' | 'file' | 'pdfFile' | 'width' | 'height'>>)[];
|
|
59
|
+
}
|
|
60
|
+
/** What a canvas lays out: the active chapter (continued after the ones
|
|
61
|
+
* before it) or the whole book as one continuous document. */
|
|
62
|
+
export type BundleCanvasScope = 'chapter' | 'book';
|
|
63
|
+
/** How a viewer opens the bundle: settings that are not part of the engine
|
|
64
|
+
* configuration. */
|
|
65
|
+
export interface BundleViewSpec {
|
|
66
|
+
canvasScope?: BundleCanvasScope;
|
|
67
|
+
}
|
|
68
|
+
interface BundleManifestBase extends BundleShowcaseMeta {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
locale?: string;
|
|
73
|
+
/** Sandbox only: auto-load this bundle for a pristine sandbox when it is
|
|
74
|
+
* served from a private preset source. */
|
|
75
|
+
default?: boolean;
|
|
76
|
+
view?: BundleViewSpec;
|
|
77
|
+
config?: PostextConfig;
|
|
78
|
+
resources?: BundleResourceSpec[];
|
|
79
|
+
fonts?: BundleFontFamilySpec[];
|
|
80
|
+
/** Locale → overrides, resolved with the same rules as a locale →
|
|
81
|
+
* chapters map (exact tag, base language, the manifest's locale, first
|
|
82
|
+
* entry). */
|
|
83
|
+
localized?: Record<string, BundleLocaleOverrides>;
|
|
84
|
+
}
|
|
85
|
+
/** `preset.json` version 1: a single markdown document. Still read; every
|
|
86
|
+
* writer produces version 2. */
|
|
87
|
+
export interface BundleManifestV1 extends BundleManifestBase {
|
|
88
|
+
version: 1;
|
|
89
|
+
/** Markdown file, or a locale → file map. */
|
|
90
|
+
markdown: string | Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/** `preset.json` version 2: a book — one markdown file per chapter, in
|
|
93
|
+
* order, or a locale → chapter list map. */
|
|
94
|
+
export interface BundleManifestV2 extends BundleManifestBase {
|
|
95
|
+
version: 2;
|
|
96
|
+
chapters: BundleChapterSpec[] | Record<string, BundleChapterSpec[]>;
|
|
97
|
+
}
|
|
98
|
+
export type BundleManifest = BundleManifestV1 | BundleManifestV2;
|
|
99
|
+
/** Reads one bundle file by its manifest-relative path; rejects when the
|
|
100
|
+
* file does not exist. */
|
|
101
|
+
export type BundleFileReader = (path: string) => Promise<ArrayBuffer>;
|
|
102
|
+
/** How the files a bundle declares are named once loaded: the `fileId`
|
|
103
|
+
* written into `Resource.bitmap/svg` and `config.customFonts`. Defaults to
|
|
104
|
+
* the path inside the bundle. */
|
|
105
|
+
export interface BundleIdScheme {
|
|
106
|
+
blob: (file: string) => string;
|
|
107
|
+
font: (file: string) => string;
|
|
108
|
+
}
|
|
109
|
+
/** Intrinsic pixel size of a picture. */
|
|
110
|
+
export interface BundleImageSize {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
}
|
|
114
|
+
/** A chapter as read from a bundle. `title` is the manifest's (possibly
|
|
115
|
+
* empty for a version 1 bundle). */
|
|
116
|
+
export interface BundleChapter {
|
|
117
|
+
title: string;
|
|
118
|
+
/** Path of the chapter's markdown inside the bundle. */
|
|
119
|
+
file: string;
|
|
120
|
+
markdown: string;
|
|
121
|
+
}
|
|
122
|
+
export interface BundleBlob {
|
|
123
|
+
fileId: string;
|
|
124
|
+
/** Path inside the bundle. */
|
|
125
|
+
file: string;
|
|
126
|
+
bytes: ArrayBuffer;
|
|
127
|
+
mime: string;
|
|
128
|
+
}
|
|
129
|
+
export interface BundleFontFile {
|
|
130
|
+
fileId: string;
|
|
131
|
+
/** Path inside the bundle. */
|
|
132
|
+
file: string;
|
|
133
|
+
fileName: string;
|
|
134
|
+
family: string;
|
|
135
|
+
weight: number;
|
|
136
|
+
style: 'normal' | 'italic';
|
|
137
|
+
format: CustomFontFormat;
|
|
138
|
+
bytes: ArrayBuffer;
|
|
139
|
+
}
|
|
140
|
+
export {};
|
|
141
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bundle/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE1E;2EAC2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC;iDAC6C;IAC7C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,EAAE,CA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Ae;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;qCACqC;AACrC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC;CACpB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The `.postext` bundle format: a directory-shaped set of files — a
|
|
2
|
+
// `preset.json` manifest, one markdown file per chapter, `resources/*` and
|
|
3
|
+
// `fonts/*` — zipped into one file. These types describe the manifest; the
|
|
4
|
+
// codec lives in `manifest.ts`, `codec.ts` and `zip.ts`.
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bundle/types.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,2EAA2E;AAC3E,2EAA2E;AAC3E,yDAAyD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BundleFileReader } from './types';
|
|
2
|
+
export declare const POSTEXT_EXTENSION = ".postext";
|
|
3
|
+
export declare const POSTEXT_MIME = "application/zip";
|
|
4
|
+
export declare const MANIFEST_FILE = "preset.json";
|
|
5
|
+
export interface OpenedBundleZip {
|
|
6
|
+
/** The parsed `preset.json` (not yet validated). */
|
|
7
|
+
manifest: unknown;
|
|
8
|
+
readFile: BundleFileReader;
|
|
9
|
+
/** Directory prefix under which the bundle lives inside the archive
|
|
10
|
+
* (empty when `preset.json` sits at the root). */
|
|
11
|
+
rootPrefix: string;
|
|
12
|
+
/** Normalised paths of every file entry, prefix included. */
|
|
13
|
+
entries: string[];
|
|
14
|
+
/** Every file, keyed by its path relative to the bundle root. */
|
|
15
|
+
files: Map<string, Uint8Array>;
|
|
16
|
+
}
|
|
17
|
+
/** Unzip a `.postext` archive and locate its manifest. Throws when the
|
|
18
|
+
* bytes are not a zip or hold no (or several) `preset.json`. */
|
|
19
|
+
export declare function openBundleZip(bytes: Uint8Array): OpenedBundleZip;
|
|
20
|
+
/** Zip a bundle's files (path → bytes). Already-compressed payloads are
|
|
21
|
+
* stored as-is. */
|
|
22
|
+
export declare function zipBundle(files: Record<string, Uint8Array>): Uint8Array;
|
|
23
|
+
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/bundle/zip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,YAAY,oBAAoB,CAAC;AAC9C,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;uDACmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iEAAiE;IACjE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAChC;AAmBD;iEACiE;AACjE,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CA8ChE;AAID;oBACoB;AACpB,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAOvE"}
|