bookcover-core 0.14.0 → 0.16.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.
Files changed (117) hide show
  1. package/dist/barcode.d.ts +7 -1
  2. package/dist/barcode.js +10 -4
  3. package/dist/colors.d.ts +2 -1
  4. package/dist/colors.js +9 -4
  5. package/dist/defaults.d.ts +1 -1
  6. package/dist/defaults.js +1 -1
  7. package/dist/design.js +12 -7
  8. package/dist/generated/preset_icons_svg_data.d.ts +5 -0
  9. package/dist/generated/preset_icons_svg_data.js +275 -0
  10. package/dist/icon_cache.js +9 -0
  11. package/dist/index.d.ts +3 -1
  12. package/dist/index.js +9 -3
  13. package/dist/patterns.d.ts +4 -1
  14. package/dist/patterns.js +90 -262
  15. package/dist/patterns_svg.d.ts +6 -0
  16. package/dist/patterns_svg.js +275 -0
  17. package/dist/preset_icons.d.ts +7 -0
  18. package/dist/preset_icons.js +359 -0
  19. package/dist/preset_icons_svg.d.ts +6 -0
  20. package/dist/preset_icons_svg.js +13 -0
  21. package/dist/split.js +19 -5
  22. package/package.json +25 -5
  23. package/dist/assets.d.ts.map +0 -1
  24. package/dist/assets.js.map +0 -1
  25. package/dist/barcode.d.ts.map +0 -1
  26. package/dist/barcode.js.map +0 -1
  27. package/dist/build_files.d.ts.map +0 -1
  28. package/dist/build_files.js.map +0 -1
  29. package/dist/builtin_bg_regions.d.ts +0 -15
  30. package/dist/builtin_bg_regions.d.ts.map +0 -1
  31. package/dist/builtin_bg_regions.js +0 -73
  32. package/dist/builtin_bg_regions.js.map +0 -1
  33. package/dist/builtin_icons.d.ts.map +0 -1
  34. package/dist/builtin_icons.js.map +0 -1
  35. package/dist/colors.d.ts.map +0 -1
  36. package/dist/colors.js.map +0 -1
  37. package/dist/data_file.d.ts.map +0 -1
  38. package/dist/data_file.js.map +0 -1
  39. package/dist/defaults.d.ts.map +0 -1
  40. package/dist/defaults.js.map +0 -1
  41. package/dist/design.d.ts.map +0 -1
  42. package/dist/design.js.map +0 -1
  43. package/dist/dimensions.d.ts.map +0 -1
  44. package/dist/dimensions.js.map +0 -1
  45. package/dist/font_manifest.d.ts +0 -3
  46. package/dist/font_manifest.d.ts.map +0 -1
  47. package/dist/font_manifest.js +0 -18
  48. package/dist/font_manifest.js.map +0 -1
  49. package/dist/font_sizes.d.ts.map +0 -1
  50. package/dist/font_sizes.js.map +0 -1
  51. package/dist/fonts.d.ts.map +0 -1
  52. package/dist/fonts.js.map +0 -1
  53. package/dist/form_schema.d.ts.map +0 -1
  54. package/dist/form_schema.js.map +0 -1
  55. package/dist/form_state.d.ts.map +0 -1
  56. package/dist/form_state.js.map +0 -1
  57. package/dist/frame.d.ts.map +0 -1
  58. package/dist/frame.js.map +0 -1
  59. package/dist/frame_assets.d.ts +0 -3
  60. package/dist/frame_assets.d.ts.map +0 -1
  61. package/dist/frame_assets.js +0 -4
  62. package/dist/frame_assets.js.map +0 -1
  63. package/dist/generated/builtin_bg_regions.d.ts.map +0 -1
  64. package/dist/generated/builtin_bg_regions.js.map +0 -1
  65. package/dist/generated/font_manifest.json +0 -147
  66. package/dist/generated/han_hints.json +0 -7
  67. package/dist/generated/icon_svgs_data.d.ts.map +0 -1
  68. package/dist/generated/icon_svgs_data.js.map +0 -1
  69. package/dist/generated/noto_manifest.json +0 -2775
  70. package/dist/generated/templates_data.d.ts.map +0 -1
  71. package/dist/generated/templates_data.js.map +0 -1
  72. package/dist/generated/vector_bg_images_data.d.ts.map +0 -1
  73. package/dist/generated/vector_bg_images_data.js.map +0 -1
  74. package/dist/generated/vector_patterns_data.d.ts +0 -4
  75. package/dist/generated/vector_patterns_data.d.ts.map +0 -1
  76. package/dist/generated/vector_patterns_data.js +0 -33
  77. package/dist/generated/vector_patterns_data.js.map +0 -1
  78. package/dist/icon_cache.d.ts.map +0 -1
  79. package/dist/icon_cache.js.map +0 -1
  80. package/dist/image_regions.d.ts.map +0 -1
  81. package/dist/image_regions.js.map +0 -1
  82. package/dist/index.d.ts.map +0 -1
  83. package/dist/index.js.map +0 -1
  84. package/dist/noto_fonts.d.ts +0 -21
  85. package/dist/noto_fonts.d.ts.map +0 -1
  86. package/dist/noto_fonts.js +0 -208
  87. package/dist/noto_fonts.js.map +0 -1
  88. package/dist/patterns.d.ts.map +0 -1
  89. package/dist/patterns.js.map +0 -1
  90. package/dist/printers.d.ts +0 -17
  91. package/dist/printers.d.ts.map +0 -1
  92. package/dist/printers.js +0 -52
  93. package/dist/printers.js.map +0 -1
  94. package/dist/schema.d.ts.map +0 -1
  95. package/dist/schema.js.map +0 -1
  96. package/dist/split.d.ts.map +0 -1
  97. package/dist/split.js.map +0 -1
  98. package/dist/template_content.d.ts +0 -3
  99. package/dist/template_content.d.ts.map +0 -1
  100. package/dist/template_content.js +0 -4
  101. package/dist/template_content.js.map +0 -1
  102. package/dist/templates_data.d.ts +0 -4
  103. package/dist/templates_data.d.ts.map +0 -1
  104. package/dist/templates_data.js +0 -8
  105. package/dist/templates_data.js.map +0 -1
  106. package/dist/themes.d.ts +0 -12
  107. package/dist/themes.d.ts.map +0 -1
  108. package/dist/themes.js +0 -49
  109. package/dist/themes.js.map +0 -1
  110. package/dist/utils.d.ts.map +0 -1
  111. package/dist/utils.js.map +0 -1
  112. package/dist/vector_backgrounds.d.ts.map +0 -1
  113. package/dist/vector_backgrounds.js.map +0 -1
  114. package/dist/vector_patterns_data.d.ts +0 -4
  115. package/dist/vector_patterns_data.d.ts.map +0 -1
  116. package/dist/vector_patterns_data.js +0 -66
  117. package/dist/vector_patterns_data.js.map +0 -1
package/dist/barcode.d.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * Generate an ISBN-13 barcode as SVG bytes sized to the given region.
3
- * Uses toSVG() which is platform-independent (no canvas / Node Buffer required).
4
3
  * width_mm/height_mm are from printing-services cover_region_barcode (mm).
4
+ *
5
+ * Calls the isbn encoder directly rather than bwip-js's toSVG(). toSVG() dispatches on the
6
+ * bcid string, and that lookup table references all ~110 symbologies, so none of them can be
7
+ * dropped — the dispatch alone costs ~1.5MB of encoders we never use. Naming the encoder
8
+ * leaves only its own code reachable. The 'generic' entry point also avoids the canvas/DOM
9
+ * path, which is dead weight here on both platforms. Output is unchanged: this is the same
10
+ * encoder and the same SVG drawing backend toSVG() would have reached.
5
11
  */
6
12
  export declare function generate_isbn_barcode(isbn: string, width_mm: number, height_mm: number): Uint8Array;
7
13
  //# sourceMappingURL=barcode.d.ts.map
package/dist/barcode.js CHANGED
@@ -1,16 +1,22 @@
1
1
  // ISBN barcode generation using bwip-js (SVG output — works in both Node and browser)
2
- import * as bwipjs from 'bwip-js';
2
+ import { isbn as bwipp_isbn, drawingSVG } from 'bwip-js/generic';
3
3
  const encoder = new TextEncoder();
4
4
  /**
5
5
  * Generate an ISBN-13 barcode as SVG bytes sized to the given region.
6
- * Uses toSVG() which is platform-independent (no canvas / Node Buffer required).
7
6
  * width_mm/height_mm are from printing-services cover_region_barcode (mm).
7
+ *
8
+ * Calls the isbn encoder directly rather than bwip-js's toSVG(). toSVG() dispatches on the
9
+ * bcid string, and that lookup table references all ~110 symbologies, so none of them can be
10
+ * dropped — the dispatch alone costs ~1.5MB of encoders we never use. Naming the encoder
11
+ * leaves only its own code reachable. The 'generic' entry point also avoids the canvas/DOM
12
+ * path, which is dead weight here on both platforms. Output is unchanged: this is the same
13
+ * encoder and the same SVG drawing backend toSVG() would have reached.
8
14
  */
9
15
  export function generate_isbn_barcode(isbn, width_mm, height_mm) {
10
16
  // Trim surrounding whitespace but preserve internal dashes —
11
17
  // bwip-js requires dashes for ISBN grouping validation
12
18
  // bwip-js width/height are in mm
13
- const svg = bwipjs.toSVG({
19
+ const svg = bwipp_isbn({
14
20
  bcid: 'isbn',
15
21
  text: isbn.trim(),
16
22
  includetext: true,
@@ -19,7 +25,7 @@ export function generate_isbn_barcode(isbn, width_mm, height_mm) {
19
25
  paddingwidth: 10, // 1cm seems reasonable (not set according to any spec though)
20
26
  paddingheight: 10, // 1cm seems reasonable (not set according to any spec though)
21
27
  backgroundcolor: 'ffffff', // KDP and others are picky and insist on black/white
22
- });
28
+ }, drawingSVG());
23
29
  return encoder.encode(svg);
24
30
  }
25
31
  //# sourceMappingURL=barcode.js.map
package/dist/colors.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Convert a hex color string to an HSL tuple [h, s, l] */
2
2
  export declare function hex_to_hsl(hex: string): [number, number, number];
3
- /** Return true when white text has better contrast than black text against this color (WCAG) */
3
+ /** Return true when white text has better contrast against this color than the near-black
4
+ * text it pairs with (see DARK_TEXT_LUMINANCE) */
4
5
  export declare function is_dark_color(hex: string): boolean;
5
6
  /** Color values derived from the form's bg_color and spine_color */
6
7
  export interface DerivedColors {
package/dist/colors.js CHANGED
@@ -27,13 +27,18 @@ function relative_luminance(hex) {
27
27
  const b = to_linear(parseInt(hex.slice(5, 7), 16) / 255);
28
28
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
29
29
  }
30
- /** Return true when white text has better contrast than black text against this color (WCAG) */
30
+ // Luminance of the near-black (#1a1a1a = hsl(0deg, 0%, 10%)) that pairs with white as this
31
+ // module's auto text color — a printable K90 gray rather than pure black. The choice below is
32
+ // made against THIS, not pure black: near-black has less contrast than black does, so
33
+ // comparing against black picks it on mid-gray backgrounds where white actually reads better
34
+ const DARK_TEXT_LUMINANCE = relative_luminance('#1a1a1a');
35
+ /** Return true when white text has better contrast against this color than the near-black
36
+ * text it pairs with (see DARK_TEXT_LUMINANCE) */
31
37
  export function is_dark_color(hex) {
32
38
  const L = relative_luminance(hex);
33
- // Contrast ratio with white (L=1) vs black (L=0)
34
39
  const contrast_white = 1.05 / (L + 0.05);
35
- const contrast_black = (L + 0.05) / 0.05;
36
- return contrast_white > contrast_black;
40
+ const contrast_dark = (L + 0.05) / (DARK_TEXT_LUMINANCE + 0.05);
41
+ return contrast_white > contrast_dark;
37
42
  }
38
43
  /** Format HSL components as hsl(Hdeg, S%, L%) — compatible with CSS4 and Typst's color.hsl() */
39
44
  function fmt_hsl(h, s, l) {
@@ -7,7 +7,7 @@ export declare const SCHEMA_VERSION = 1;
7
7
  * the bundled pattern/vector/icon data. Hosts that re-render a frozen record later should
8
8
  * record this at freeze time (alongside the typst version their wrapper reports) so a drifted
9
9
  * reprint is detectable instead of silent. */
10
- export declare const RENDER_VERSION = 1;
10
+ export declare const RENDER_VERSION = 2;
11
11
  /** What an omitted CoverSchema field resolves to at render time. Derived fields are absent by
12
12
  * design — see the note at the top of this file. */
13
13
  export declare const SCHEMA_DEFAULTS: {
package/dist/defaults.js CHANGED
@@ -19,7 +19,7 @@ export const SCHEMA_VERSION = 1;
19
19
  * the bundled pattern/vector/icon data. Hosts that re-render a frozen record later should
20
20
  * record this at freeze time (alongside the typst version their wrapper reports) so a drifted
21
21
  * reprint is detectable instead of silent. */
22
- export const RENDER_VERSION = 1;
22
+ export const RENDER_VERSION = 2;
23
23
  /** What an omitted CoverSchema field resolves to at render time. Derived fields are absent by
24
24
  * design — see the note at the top of this file. */
25
25
  export const SCHEMA_DEFAULTS = {
package/dist/design.js CHANGED
@@ -108,18 +108,23 @@ export function generate_palette(base, count, scheme) {
108
108
  }
109
109
  return colors;
110
110
  }
111
- /** True when white text has more WCAG contrast than black against this color */
111
+ // The two colors auto text falls back to. The dark one is a near-black (K90% for print, see
112
+ // COLOR_DEFAULTS) rather than pure black, and its luminance is what the choice below is made
113
+ // against — comparing against PURE black instead picks it on mid-gray backgrounds where white
114
+ // actually reads better, since near-black's own contrast is lower than black's
115
+ const AUTO_TEXT_LIGHT = 'hsl(0deg, 0%, 100%)';
116
+ const AUTO_TEXT_DARK = 'hsl(0deg, 0%, 10%)';
117
+ const AUTO_TEXT_DARK_LUMINANCE = chroma.hsl(0, 0, 0.1).luminance();
118
+ /** True when the light auto text reads better than the dark one against this color */
112
119
  function is_dark(c) {
113
120
  const L = c.luminance();
114
- const contrast_white = 1.05 / (L + 0.05);
115
- const contrast_black = (L + 0.05) / 0.05;
116
- return contrast_white >= contrast_black;
121
+ const contrast_light = 1.05 / (L + 0.05);
122
+ const contrast_dark = (L + 0.05) / (AUTO_TEXT_DARK_LUMINANCE + 0.05);
123
+ return contrast_light >= contrast_dark;
117
124
  }
118
125
  /** Return white or near-black, whichever has more WCAG contrast against the given background */
119
126
  function auto_contrast_text(bg) {
120
- return is_dark(from_hsl(bg))
121
- ? 'hsl(0deg, 0%, 100%)' // white — better on dark backgrounds
122
- : 'hsl(0deg, 0%, 10%)'; // near-black (K90% for print)
127
+ return is_dark(from_hsl(bg)) ? AUTO_TEXT_LIGHT : AUTO_TEXT_DARK;
123
128
  }
124
129
  /** Same contrast choice as auto_contrast_text, but hex-in/hex-out — for callers (pick_vivid_tint)
125
130
  * that need to stay in hex rather than the hsl(Hdeg, S%, L%) string format */
@@ -0,0 +1,5 @@
1
+ /** Raw SVG text for each bundled preset icon, keyed by its full Iconify id
2
+ * (e.g. "game-icons:dead-wood"), using currentColor so resolve_icon() in icon_cache.ts
3
+ * can recolor them like a live-fetched Iconify icon */
4
+ export declare const PRESET_ICON_SVGS: Record<string, string>;
5
+ //# sourceMappingURL=preset_icons_svg_data.d.ts.map