bookcover-web 0.20.1 → 0.22.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.
@@ -1,11 +1,5 @@
1
1
  import type { EmbedFormState } from 'bookcover-core';
2
2
  import type { CustomFont } from 'typst-fonts';
3
- /** Locales the widget UI supports. Lives in this published package, so adding a widget
4
- * locale requires a bookcover-web release. Codes are ISO 639-3, plus an ISO 15924 script
5
- * suffix where one language is written in more than one script (zho_hans = Simplified
6
- * Chinese). An unrecognised locale sent by a host falls back to the widget's own detection
7
- * rather than failing, so a host may send a code newer than the widget it embeds. */
8
- export type AppLocale = 'eng' | 'ara' | 'ben' | 'deu' | 'fas' | 'fra' | 'hin' | 'ind' | 'ita' | 'jpn' | 'kor' | 'mar' | 'por' | 'rus' | 'spa' | 'tam' | 'tel' | 'tha' | 'tur' | 'urd' | 'vie' | 'zho_hans';
9
3
  /** One candidate background the host offers alongside the widget's own built-ins — typically an
10
4
  * image the user already used on another of their covers, which the widget would otherwise make
11
5
  * them find on disk and upload again.
@@ -69,7 +63,7 @@ export interface InitMessage {
69
63
  finished_mode?: boolean;
70
64
  hide_size_section?: boolean;
71
65
  bg_suggestions?: BgSuggestion[];
72
- locale?: AppLocale;
66
+ locale?: string;
73
67
  }
74
68
  /** Host -> widget. InitMessage is the first and must arrive before any other; later messages are
75
69
  * only accepted from the same origin that sent it.
@@ -118,7 +112,19 @@ export type HostMessage = InitMessage | {
118
112
  *
119
113
  * 'bg_suggestion_selected' asks the host for the bytes behind one of the BgSuggestions it sent
120
114
  * in InitMessage, carrying that suggestion's id verbatim. The host answers with
121
- * 'bg_suggestion_resolved'. */
115
+ * 'bg_suggestion_resolved'.
116
+ *
117
+ * 'error' relays an unexpected widget failure, since a cross-origin host can't observe the
118
+ * iframe's errors itself. It is purely informational — it never stands in for 'cancelled' or
119
+ * changes what data/finished mean, and the editor carries on (or not) exactly as it would
120
+ * have standalone. `message` is always plain text, never an Error object (structured clone
121
+ * drops or mangles those across browsers): "<ErrorType>: <message>\n\n<stack>", plus a
122
+ * trailing paragraph of context where the widget has some (e.g. Vue's error info). `build` is
123
+ * the widget's short commit hash, suffixed "-dirty" for a build from a modified tree, and null
124
+ * from a dev server. Noise (cross-origin "Script error.", ResizeObserver loops, cancelled
125
+ * fetches, browser extensions) is filtered out, each distinct message is sent at most once
126
+ * per page load, and no more than 20 in total. Like 'ready', one raised before the host's
127
+ * InitMessage arrives is posted with target origin '*'. */
122
128
  export type WidgetMessage = {
123
129
  type: 'ready';
124
130
  } | {
@@ -138,5 +144,9 @@ export type WidgetMessage = {
138
144
  } | {
139
145
  type: 'bg_suggestion_selected';
140
146
  id: string;
147
+ } | {
148
+ type: 'error';
149
+ message: string;
150
+ build: string | null;
141
151
  };
142
152
  //# sourceMappingURL=embed_types.d.ts.map
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export type { CoverSchema, TitlePosition, FontConfig, OutputFormat, SplitResult,
4
4
  export type { BundledFont, CjkVariant, CustomFont } from 'typst-fonts';
5
5
  export { font_file_url } from 'typst-fonts/web';
6
6
  export { get_fonts, get_bundled_font } from 'typst-fonts';
7
- export { list_patterns, collect_fonts, collect_all_fonts, default_spine_title, list_vector_backgrounds, find_vector_background, list_builtin_icons, find_builtin_icon, icon_categories, suggested_icons, generate_palette, cover_schema } from 'bookcover-core';
7
+ export { list_patterns, collect_fonts, collect_all_fonts, default_spine_title, list_vector_backgrounds, find_vector_background, load_vector_background_svg, recolor_vector_svg, list_builtin_icons, find_builtin_icon, icon_categories, suggested_icons, generate_palette, cover_schema } from 'bookcover-core';
8
8
  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';
@@ -12,7 +12,7 @@ export { make_blank_form_values, build_schema, curly_quotes, parse_font_family,
12
12
  export type { FormState, EmbedFormState, CustomFontStyle, DerivedColors } from 'bookcover-core';
13
13
  export { resolve_dimensions } from 'bookcover-core';
14
14
  export type { GetDimensionsResult, DimensionInputs } from 'bookcover-core';
15
- export type { InitMessage, HostMessage, WidgetMessage, BgSuggestion, AppLocale } from './embed_types.js';
15
+ export type { InitMessage, HostMessage, WidgetMessage, BgSuggestion } from './embed_types.js';
16
16
  export interface InitOptions {
17
17
  wasm_url: string;
18
18
  renderer_wasm_url?: string;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { base_font } from 'typst-fonts';
7
7
  import { load_fonts_prefix, font_urls_for as build_font_urls, fetch_font_bytes, fonts_to_blob_urls, revoke_blob_urls } from 'typst-fonts/web';
8
8
  export { font_file_url } from 'typst-fonts/web';
9
9
  export { get_fonts, get_bundled_font } from 'typst-fonts';
10
- export { list_patterns, collect_fonts, collect_all_fonts, default_spine_title, list_vector_backgrounds, find_vector_background, list_builtin_icons, find_builtin_icon, icon_categories, suggested_icons, generate_palette, cover_schema } from 'bookcover-core';
10
+ export { list_patterns, collect_fonts, collect_all_fonts, default_spine_title, list_vector_backgrounds, find_vector_background, load_vector_background_svg, recolor_vector_svg, list_builtin_icons, find_builtin_icon, icon_categories, suggested_icons, generate_palette, cover_schema } from 'bookcover-core';
11
11
  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';
12
12
  // Form state + form->schema conversion, so hosts can derive the renderable schema themselves
13
13
  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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bookcover-web",
3
- "version": "0.20.1",
3
+ "version": "0.22.0",
4
4
  "license": "MIT-0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "@myriaddreamin/typst-ts-renderer": "0.7.0",
40
40
  "@myriaddreamin/typst-ts-web-compiler": "0.7.0",
41
41
  "@myriaddreamin/typst.ts": "0.7.0",
42
- "bookcover-core": "^0.20.1",
42
+ "bookcover-core": "^0.22.0",
43
43
  "typst-fonts": "^0.1.0"
44
44
  },
45
45
  "sideEffects": false