bookcover-web 0.22.3 → 0.24.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 +1 -0
- package/dist/embed_types.d.ts +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ interface GenerateOptions {
|
|
|
105
105
|
format?: 'pdf'|'svg'|'png' // default: 'pdf'
|
|
106
106
|
ppi?: number // PNG resolution, default: 144
|
|
107
107
|
split?: boolean // include split panels in result
|
|
108
|
+
pdf_pages?: boolean // PDF: front and back pages (no spine), bleed all round
|
|
108
109
|
custom_fonts?: Uint8Array[] // raw TTF bytes for custom fonts
|
|
109
110
|
}
|
|
110
111
|
|
package/dist/embed_types.d.ts
CHANGED
|
@@ -64,6 +64,23 @@ export interface InitMessage {
|
|
|
64
64
|
hide_size_section?: boolean;
|
|
65
65
|
bg_suggestions?: BgSuggestion[];
|
|
66
66
|
locale?: string;
|
|
67
|
+
/** Typst markup to put in place of marker text in the cover's blurb, keyed by marker (plain
|
|
68
|
+
* text exactly as the user sees it in the editor, e.g. 'AUTO-COPYRIGHT'), so the widget
|
|
69
|
+
* shows what will actually print. Applied only when the widget renders (its previews and
|
|
70
|
+
* its own PDF exports): the form is never changed, so the editor still shows the marker
|
|
71
|
+
* and data/finished messages send it back untouched. The host applies the same map when
|
|
72
|
+
* it renders final output, by passing it to build_schema() as `typst_substitutions`.
|
|
73
|
+
*
|
|
74
|
+
* Values are trusted Typst from the host, inserted verbatim. They follow the rules on
|
|
75
|
+
* BuildSchemaOptions.typst_substitutions in bookcover-core: wrap multi-line markup in one
|
|
76
|
+
* `#[…];` block or put the marker alone in its own paragraph; set your own text direction;
|
|
77
|
+
* keep text as escaped content rather than string literals; use no images or named fonts.
|
|
78
|
+
* A marker the user styles only part of (bolding half of it, say) isn't replaced.
|
|
79
|
+
*
|
|
80
|
+
* If a preview fails to compile with the substitutions, the widget reports it as an
|
|
81
|
+
* 'error' message and shows the preview without them, raw marker and all; a PDF export
|
|
82
|
+
* fails instead. Absent or empty changes nothing. */
|
|
83
|
+
typst_substitutions?: Record<string, string>;
|
|
67
84
|
}
|
|
68
85
|
/** Host -> widget. InitMessage is the first and must arrive before any other; later messages are
|
|
69
86
|
* only accepted from the same origin that sent it.
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { IconCategory } from 'bookcover-core';
|
|
|
9
9
|
export { tinted_contrast_text, pick_vivid_tint, synthesize_fill, blend_regions, region_hex, all_image_regions, analyze_pixel_regions, get_builtin_bg, get_builtin_bg_regions, BG_PREVIEW_DIR, VECTOR_BG_AUTO_COLOR, resolve_colors, darken_hsl } from 'bookcover-core';
|
|
10
10
|
export type { RegionStats, ImageRegions, ResolvedColors, BuiltinBg } from 'bookcover-core';
|
|
11
11
|
export { make_blank_form_values, build_schema, curly_quotes, parse_font_family, find_pattern, derive_colors, hex_override_to_hsl, hex_to_hsl, is_dark_color, warn_unknown } from 'bookcover-core';
|
|
12
|
-
export type { FormState, EmbedFormState, CustomFontStyle, DerivedColors } from 'bookcover-core';
|
|
12
|
+
export type { FormState, EmbedFormState, CustomFontStyle, BuildSchemaOptions, DerivedColors } from 'bookcover-core';
|
|
13
13
|
export { resolve_dimensions } from 'bookcover-core';
|
|
14
14
|
export type { GetDimensionsResult, DimensionInputs } from 'bookcover-core';
|
|
15
15
|
export type { InitMessage, HostMessage, WidgetMessage, BgSuggestion } from './embed_types.js';
|
|
@@ -27,6 +27,7 @@ export interface GenerateOptions {
|
|
|
27
27
|
format?: OutputFormat;
|
|
28
28
|
ppi?: number;
|
|
29
29
|
split?: boolean;
|
|
30
|
+
pdf_pages?: boolean;
|
|
30
31
|
custom_fonts?: Uint8Array[];
|
|
31
32
|
image_regions?: ImageRegions | null;
|
|
32
33
|
}
|
package/dist/index.js
CHANGED
|
@@ -453,6 +453,12 @@ export class CoverGenerator {
|
|
|
453
453
|
result.split = await split_png(data, dims, ppi, canvas_crop);
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
+
// Front and back pages, cut from the wraparound once any split above has used it. Loaded on
|
|
457
|
+
// demand, as it brings pdf-lib with it
|
|
458
|
+
if (options.pdf_pages && format === 'pdf') {
|
|
459
|
+
const { split_pdf_pages } = await import('bookcover-core/pdf-pages');
|
|
460
|
+
result.data = await split_pdf_pages(data, dims);
|
|
461
|
+
}
|
|
456
462
|
return result;
|
|
457
463
|
}
|
|
458
464
|
/** Revoke blob URLs and drop cached font bytes to free memory */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bookcover-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"license": "MIT-0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@myriaddreamin/typst-ts-renderer": "0.7.0",
|
|
41
41
|
"@myriaddreamin/typst-ts-web-compiler": "0.7.0",
|
|
42
42
|
"@myriaddreamin/typst.ts": "0.7.0",
|
|
43
|
-
"bookcover-core": "^0.
|
|
43
|
+
"bookcover-core": "^0.24.0",
|
|
44
44
|
"typst-fonts": "^0.1.4"
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false
|