postext 1.91.1 → 1.92.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 (301) hide show
  1. package/dist/__tests__/exports.test.js +92 -0
  2. package/dist/__tests__/exports.test.js.map +1 -1
  3. package/dist/__tests__/paint/cropMarks.test.js +31 -0
  4. package/dist/__tests__/paint/cropMarks.test.js.map +1 -1
  5. package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts +2 -0
  6. package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts.map +1 -0
  7. package/dist/__tests__/pipeline/pages/reliefPlates.test.js +92 -0
  8. package/dist/__tests__/pipeline/pages/reliefPlates.test.js.map +1 -0
  9. package/dist/__tests__/pipeline/passFrontPages.test.d.ts +2 -0
  10. package/dist/__tests__/pipeline/passFrontPages.test.d.ts.map +1 -0
  11. package/dist/__tests__/pipeline/passFrontPages.test.js +66 -0
  12. package/dist/__tests__/pipeline/passFrontPages.test.js.map +1 -0
  13. package/dist/__tests__/production/compose.test.d.ts +2 -0
  14. package/dist/__tests__/production/compose.test.d.ts.map +1 -0
  15. package/dist/__tests__/production/compose.test.js +177 -0
  16. package/dist/__tests__/production/compose.test.js.map +1 -0
  17. package/dist/__tests__/production/config.test.d.ts +2 -0
  18. package/dist/__tests__/production/config.test.d.ts.map +1 -0
  19. package/dist/__tests__/production/config.test.js +83 -0
  20. package/dist/__tests__/production/config.test.js.map +1 -0
  21. package/dist/__tests__/production/cover.test.d.ts +2 -0
  22. package/dist/__tests__/production/cover.test.d.ts.map +1 -0
  23. package/dist/__tests__/production/cover.test.js +273 -0
  24. package/dist/__tests__/production/cover.test.js.map +1 -0
  25. package/dist/__tests__/production/coverLayers.test.d.ts +2 -0
  26. package/dist/__tests__/production/coverLayers.test.d.ts.map +1 -0
  27. package/dist/__tests__/production/coverLayers.test.js +198 -0
  28. package/dist/__tests__/production/coverLayers.test.js.map +1 -0
  29. package/dist/__tests__/production/coverOutputs.test.d.ts +2 -0
  30. package/dist/__tests__/production/coverOutputs.test.d.ts.map +1 -0
  31. package/dist/__tests__/production/coverOutputs.test.js +104 -0
  32. package/dist/__tests__/production/coverOutputs.test.js.map +1 -0
  33. package/dist/__tests__/production/geometry.test.d.ts +2 -0
  34. package/dist/__tests__/production/geometry.test.d.ts.map +1 -0
  35. package/dist/__tests__/production/geometry.test.js +281 -0
  36. package/dist/__tests__/production/geometry.test.js.map +1 -0
  37. package/dist/__tests__/production/mirrorBleed.test.d.ts +2 -0
  38. package/dist/__tests__/production/mirrorBleed.test.d.ts.map +1 -0
  39. package/dist/__tests__/production/mirrorBleed.test.js +129 -0
  40. package/dist/__tests__/production/mirrorBleed.test.js.map +1 -0
  41. package/dist/__tests__/production/shapes.test.d.ts +2 -0
  42. package/dist/__tests__/production/shapes.test.d.ts.map +1 -0
  43. package/dist/__tests__/production/shapes.test.js +107 -0
  44. package/dist/__tests__/production/shapes.test.js.map +1 -0
  45. package/dist/__tests__/production/sheets.test.d.ts +2 -0
  46. package/dist/__tests__/production/sheets.test.d.ts.map +1 -0
  47. package/dist/__tests__/production/sheets.test.js +153 -0
  48. package/dist/__tests__/production/sheets.test.js.map +1 -0
  49. package/dist/bundle/api.d.ts +8 -0
  50. package/dist/bundle/api.d.ts.map +1 -1
  51. package/dist/bundle/api.js +3 -0
  52. package/dist/bundle/api.js.map +1 -1
  53. package/dist/bundle/codec/files.d.ts.map +1 -1
  54. package/dist/bundle/codec/files.js +2 -0
  55. package/dist/bundle/codec/files.js.map +1 -1
  56. package/dist/bundle/codec/plan.d.ts +12 -0
  57. package/dist/bundle/codec/plan.d.ts.map +1 -1
  58. package/dist/bundle/codec/plan.js +12 -1
  59. package/dist/bundle/codec/plan.js.map +1 -1
  60. package/dist/bundle/codec/read.d.ts +3 -0
  61. package/dist/bundle/codec/read.d.ts.map +1 -1
  62. package/dist/bundle/codec/read.js +14 -2
  63. package/dist/bundle/codec/read.js.map +1 -1
  64. package/dist/bundle/index.d.ts +1 -1
  65. package/dist/bundle/index.d.ts.map +1 -1
  66. package/dist/bundle/index.js +1 -1
  67. package/dist/bundle/index.js.map +1 -1
  68. package/dist/bundle/manifest/locale.d.ts +3 -0
  69. package/dist/bundle/manifest/locale.d.ts.map +1 -1
  70. package/dist/bundle/manifest/locale.js +5 -0
  71. package/dist/bundle/manifest/locale.js.map +1 -1
  72. package/dist/bundle/manifest/validation.d.ts.map +1 -1
  73. package/dist/bundle/manifest/validation.js +4 -0
  74. package/dist/bundle/manifest/validation.js.map +1 -1
  75. package/dist/bundle/manifest.d.ts +1 -1
  76. package/dist/bundle/manifest.d.ts.map +1 -1
  77. package/dist/bundle/manifest.js +1 -1
  78. package/dist/bundle/manifest.js.map +1 -1
  79. package/dist/bundle/types.d.ts +7 -0
  80. package/dist/bundle/types.d.ts.map +1 -1
  81. package/dist/checks/configWarnings/collect.d.ts +6 -1
  82. package/dist/checks/configWarnings/collect.d.ts.map +1 -1
  83. package/dist/checks/configWarnings/collect.js +9 -1
  84. package/dist/checks/configWarnings/collect.js.map +1 -1
  85. package/dist/checks/configWarnings/cover.d.ts +17 -0
  86. package/dist/checks/configWarnings/cover.d.ts.map +1 -0
  87. package/dist/checks/configWarnings/cover.js +146 -0
  88. package/dist/checks/configWarnings/cover.js.map +1 -0
  89. package/dist/checks/configWarnings/production.d.ts +12 -0
  90. package/dist/checks/configWarnings/production.d.ts.map +1 -0
  91. package/dist/checks/configWarnings/production.js +48 -0
  92. package/dist/checks/configWarnings/production.js.map +1 -0
  93. package/dist/checks/preflight.d.ts.map +1 -1
  94. package/dist/checks/preflight.js +5 -0
  95. package/dist/checks/preflight.js.map +1 -1
  96. package/dist/checks/preflightFolds.d.ts +19 -0
  97. package/dist/checks/preflightFolds.d.ts.map +1 -0
  98. package/dist/checks/preflightFolds.js +81 -0
  99. package/dist/checks/preflightFolds.js.map +1 -0
  100. package/dist/checks/preflightIssues.d.ts +24 -0
  101. package/dist/checks/preflightIssues.d.ts.map +1 -1
  102. package/dist/composed/paint.d.ts +2 -1
  103. package/dist/composed/paint.d.ts.map +1 -1
  104. package/dist/composed/paint.js +3 -2
  105. package/dist/composed/paint.js.map +1 -1
  106. package/dist/defaults/bookKeys.d.ts +2 -2
  107. package/dist/defaults/bookKeys.d.ts.map +1 -1
  108. package/dist/defaults/bookKeys.js +2 -2
  109. package/dist/defaults/bookKeys.js.map +1 -1
  110. package/dist/defaults/index.d.ts +1 -1
  111. package/dist/defaults/index.d.ts.map +1 -1
  112. package/dist/defaults/index.js +1 -1
  113. package/dist/defaults/index.js.map +1 -1
  114. package/dist/defaults/output/folio.d.ts +6 -1
  115. package/dist/defaults/output/folio.d.ts.map +1 -1
  116. package/dist/defaults/output/folio.js +10 -0
  117. package/dist/defaults/output/folio.js.map +1 -1
  118. package/dist/defaults/output/production.d.ts +12 -0
  119. package/dist/defaults/output/production.d.ts.map +1 -0
  120. package/dist/defaults/output/production.js +83 -0
  121. package/dist/defaults/output/production.js.map +1 -0
  122. package/dist/defaults/page.d.ts.map +1 -1
  123. package/dist/defaults/page.js +4 -1
  124. package/dist/defaults/page.js.map +1 -1
  125. package/dist/defaults/structure/headerFooter/resolve.d.ts.map +1 -1
  126. package/dist/defaults/structure/headerFooter/resolve.js +1 -0
  127. package/dist/defaults/structure/headerFooter/resolve.js.map +1 -1
  128. package/dist/design/elementKeys.d.ts +6 -0
  129. package/dist/design/elementKeys.d.ts.map +1 -1
  130. package/dist/design/elementKeys.js +5 -5
  131. package/dist/design/elementKeys.js.map +1 -1
  132. package/dist/designs/parts.d.ts +2 -1
  133. package/dist/designs/parts.d.ts.map +1 -1
  134. package/dist/designs/parts.js +2 -1
  135. package/dist/designs/parts.js.map +1 -1
  136. package/dist/index.d.ts +2 -2
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js +1 -1
  139. package/dist/index.js.map +1 -1
  140. package/dist/paint/cropMarks.d.ts +2 -1
  141. package/dist/paint/cropMarks.d.ts.map +1 -1
  142. package/dist/paint/cropMarks.js +7 -1
  143. package/dist/paint/cropMarks.js.map +1 -1
  144. package/dist/pipeline/build/passMade.d.ts +37 -0
  145. package/dist/pipeline/build/passMade.d.ts.map +1 -1
  146. package/dist/pipeline/build/passMade.js +59 -0
  147. package/dist/pipeline/build/passMade.js.map +1 -1
  148. package/dist/pipeline/build/passRejoin.d.ts.map +1 -1
  149. package/dist/pipeline/build/passRejoin.js +23 -0
  150. package/dist/pipeline/build/passRejoin.js.map +1 -1
  151. package/dist/pipeline/build/passReuse.d.ts +6 -0
  152. package/dist/pipeline/build/passReuse.d.ts.map +1 -1
  153. package/dist/pipeline/build/passReuse.js +44 -28
  154. package/dist/pipeline/build/passReuse.js.map +1 -1
  155. package/dist/pipeline/config.d.ts.map +1 -1
  156. package/dist/pipeline/config.js +9 -2
  157. package/dist/pipeline/config.js.map +1 -1
  158. package/dist/pipeline/pages/dieCuts.d.ts +2 -1
  159. package/dist/pipeline/pages/dieCuts.d.ts.map +1 -1
  160. package/dist/pipeline/pages/dieCuts.js +18 -2
  161. package/dist/pipeline/pages/dieCuts.js.map +1 -1
  162. package/dist/pipeline/pages/headerFooter/pageDecoration.d.ts.map +1 -1
  163. package/dist/pipeline/pages/headerFooter/pageDecoration.js +8 -3
  164. package/dist/pipeline/pages/headerFooter/pageDecoration.js.map +1 -1
  165. package/dist/pipeline/pages/headerFooter/slotLayout.d.ts +3 -2
  166. package/dist/pipeline/pages/headerFooter/slotLayout.d.ts.map +1 -1
  167. package/dist/pipeline/pages/headerFooter/slotLayout.js +1 -1
  168. package/dist/pipeline/pages/headerFooter/slotLayout.js.map +1 -1
  169. package/dist/production/barcodeSvg.d.ts +28 -0
  170. package/dist/production/barcodeSvg.d.ts.map +1 -0
  171. package/dist/production/barcodeSvg.js +64 -0
  172. package/dist/production/barcodeSvg.js.map +1 -0
  173. package/dist/production/buildCover.d.ts +104 -0
  174. package/dist/production/buildCover.d.ts.map +1 -0
  175. package/dist/production/buildCover.js +169 -0
  176. package/dist/production/buildCover.js.map +1 -0
  177. package/dist/production/catalogue.d.ts +40 -0
  178. package/dist/production/catalogue.d.ts.map +1 -0
  179. package/dist/production/catalogue.js +106 -0
  180. package/dist/production/catalogue.js.map +1 -0
  181. package/dist/production/compose.d.ts +120 -0
  182. package/dist/production/compose.d.ts.map +1 -0
  183. package/dist/production/compose.js +288 -0
  184. package/dist/production/compose.js.map +1 -0
  185. package/dist/production/config.d.ts +15 -0
  186. package/dist/production/config.d.ts.map +1 -0
  187. package/dist/production/config.js +143 -0
  188. package/dist/production/config.js.map +1 -0
  189. package/dist/production/coverArt.d.ts +74 -0
  190. package/dist/production/coverArt.d.ts.map +1 -0
  191. package/dist/production/coverArt.js +355 -0
  192. package/dist/production/coverArt.js.map +1 -0
  193. package/dist/production/coverDesign.d.ts +22 -0
  194. package/dist/production/coverDesign.d.ts.map +1 -0
  195. package/dist/production/coverDesign.js +111 -0
  196. package/dist/production/coverDesign.js.map +1 -0
  197. package/dist/production/coverLabels.d.ts +8 -0
  198. package/dist/production/coverLabels.d.ts.map +1 -0
  199. package/dist/production/coverLabels.js +23 -0
  200. package/dist/production/coverLabels.js.map +1 -0
  201. package/dist/production/coverSource.d.ts +79 -0
  202. package/dist/production/coverSource.d.ts.map +1 -0
  203. package/dist/production/coverSource.js +142 -0
  204. package/dist/production/coverSource.js.map +1 -0
  205. package/dist/production/exchange.d.ts +38 -0
  206. package/dist/production/exchange.d.ts.map +1 -0
  207. package/dist/production/exchange.js +146 -0
  208. package/dist/production/exchange.js.map +1 -0
  209. package/dist/production/folio.d.ts +21 -0
  210. package/dist/production/folio.d.ts.map +1 -0
  211. package/dist/production/folio.js +35 -0
  212. package/dist/production/folio.js.map +1 -0
  213. package/dist/production/geometry.d.ts +84 -0
  214. package/dist/production/geometry.d.ts.map +1 -0
  215. package/dist/production/geometry.js +220 -0
  216. package/dist/production/geometry.js.map +1 -0
  217. package/dist/production/guards.d.ts +6 -0
  218. package/dist/production/guards.d.ts.map +1 -0
  219. package/dist/production/guards.js +6 -0
  220. package/dist/production/guards.js.map +1 -0
  221. package/dist/production/index.d.ts +25 -0
  222. package/dist/production/index.d.ts.map +1 -0
  223. package/dist/production/index.js +19 -0
  224. package/dist/production/index.js.map +1 -0
  225. package/dist/production/isbn.d.ts +67 -0
  226. package/dist/production/isbn.d.ts.map +1 -0
  227. package/dist/production/isbn.js +135 -0
  228. package/dist/production/isbn.js.map +1 -0
  229. package/dist/production/measures.d.ts +30 -0
  230. package/dist/production/measures.d.ts.map +1 -0
  231. package/dist/production/measures.js +54 -0
  232. package/dist/production/measures.js.map +1 -0
  233. package/dist/production/mirrorBleed.d.ts +54 -0
  234. package/dist/production/mirrorBleed.d.ts.map +1 -0
  235. package/dist/production/mirrorBleed.js +92 -0
  236. package/dist/production/mirrorBleed.js.map +1 -0
  237. package/dist/production/shapes.d.ts +65 -0
  238. package/dist/production/shapes.d.ts.map +1 -0
  239. package/dist/production/shapes.js +313 -0
  240. package/dist/production/shapes.js.map +1 -0
  241. package/dist/production/spine.d.ts +38 -0
  242. package/dist/production/spine.d.ts.map +1 -0
  243. package/dist/production/spine.js +48 -0
  244. package/dist/production/spine.js.map +1 -0
  245. package/dist/production/svgSafe.d.ts +25 -0
  246. package/dist/production/svgSafe.d.ts.map +1 -0
  247. package/dist/production/svgSafe.js +33 -0
  248. package/dist/production/svgSafe.js.map +1 -0
  249. package/dist/production/version.d.ts +66 -0
  250. package/dist/production/version.d.ts.map +1 -0
  251. package/dist/production/version.js +68 -0
  252. package/dist/production/version.js.map +1 -0
  253. package/dist/types/config.d.ts +12 -0
  254. package/dist/types/config.d.ts.map +1 -1
  255. package/dist/types/designCut.d.ts +13 -1
  256. package/dist/types/designCut.d.ts.map +1 -1
  257. package/dist/types/designElements.d.ts +15 -0
  258. package/dist/types/designElements.d.ts.map +1 -1
  259. package/dist/types/output/cover.d.ts +230 -0
  260. package/dist/types/output/cover.d.ts.map +1 -0
  261. package/dist/types/output/cover.js +2 -0
  262. package/dist/types/output/cover.js.map +1 -0
  263. package/dist/types/output/production.d.ts +186 -0
  264. package/dist/types/output/production.d.ts.map +1 -0
  265. package/dist/types/output/production.js +2 -0
  266. package/dist/types/output/production.js.map +1 -0
  267. package/dist/types/page.d.ts +5 -0
  268. package/dist/types/page.d.ts.map +1 -1
  269. package/dist/types.d.ts +2 -0
  270. package/dist/types.d.ts.map +1 -1
  271. package/dist/util/base64.d.ts +3 -0
  272. package/dist/util/base64.d.ts.map +1 -0
  273. package/dist/util/base64.js +48 -0
  274. package/dist/util/base64.js.map +1 -0
  275. package/dist/util/png.d.ts +10 -0
  276. package/dist/util/png.d.ts.map +1 -0
  277. package/dist/util/png.js +60 -0
  278. package/dist/util/png.js.map +1 -0
  279. package/dist/util/xmlEscape.d.ts +6 -0
  280. package/dist/util/xmlEscape.d.ts.map +1 -0
  281. package/dist/util/xmlEscape.js +15 -0
  282. package/dist/util/xmlEscape.js.map +1 -0
  283. package/dist/vdt/design.d.ts +10 -1
  284. package/dist/vdt/design.d.ts.map +1 -1
  285. package/dist/vdt/design.js.map +1 -1
  286. package/dist/vdt/pages.d.ts +13 -0
  287. package/dist/vdt/pages.d.ts.map +1 -1
  288. package/dist/vdt.d.ts +1 -1
  289. package/dist/vdt.d.ts.map +1 -1
  290. package/dist/word/anchors/base64.d.ts +1 -2
  291. package/dist/word/anchors/base64.d.ts.map +1 -1
  292. package/dist/word/anchors/base64.js +2 -46
  293. package/dist/word/anchors/base64.js.map +1 -1
  294. package/dist/word/semantic/design/ground.d.ts.map +1 -1
  295. package/dist/word/semantic/design/ground.js +5 -47
  296. package/dist/word/semantic/design/ground.js.map +1 -1
  297. package/dist/word/xml.d.ts +1 -4
  298. package/dist/word/xml.d.ts.map +1 -1
  299. package/dist/word/xml.js +1 -13
  300. package/dist/word/xml.js.map +1 -1
  301. package/package.json +5 -1
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The flat sheets of a manufactured book, in millimetres: the cover of a
3
+ * softcover, the case of a hardcover, its dust jacket and its endpapers.
4
+ * Each sheet is a row of named zones (the back cover, the spine, the front
5
+ * cover, the flaps, the joints…) with the folds and scores between them,
6
+ * the area kept clear inside each, and the bleed (or turn-in) round it. A
7
+ * design anchors to the zones, so a change of binding moves it with them.
8
+ */
9
+ const inset = (r, left, top, right, bottom) => ({
10
+ x: r.x + left,
11
+ y: r.y + top,
12
+ width: Math.max(0, r.width - left - right),
13
+ height: Math.max(0, r.height - top - bottom),
14
+ });
15
+ /** Safe margin either side inside a spine: 2 mm, 1 mm on spines of 9 mm
16
+ * or less (IngramSpark). */
17
+ export const spineSafeMargin = (spine) => (spine > 9 ? 2 : 1);
18
+ /** Lays panels side by side from `x0`, all `height` high from `y0`, with
19
+ * the given lines between them. */
20
+ function row(panels, x0, y0, height, safe, clearTopBottom) {
21
+ let x = x0;
22
+ return panels.map((p) => {
23
+ const rect = { x, y: y0, width: p.width, height };
24
+ x += p.width;
25
+ const vertical = safe + clearTopBottom;
26
+ return {
27
+ name: p.name,
28
+ rect,
29
+ safe: inset(rect, (p.safeX ?? safe) + (p.clearLeft ?? 0), vertical, (p.safeX ?? safe) + (p.clearRight ?? 0), vertical),
30
+ };
31
+ });
32
+ }
33
+ function lineAt(zones, after, kind) {
34
+ const z = zones.find((zone) => zone.name === after);
35
+ return { x: z.rect.x + z.rect.width, kind };
36
+ }
37
+ /** A sheet read from the right (a book bound on the right: Arabic,
38
+ * Hebrew, a vertical Chinese or Japanese book): the same panels in
39
+ * mirror order, the front on the left and the back on the right, with
40
+ * every zone, safe area and line moved across. Its zones stay listed left
41
+ * to right. */
42
+ export function mirrorSheet(sheet) {
43
+ const flip = (r) => ({ ...r, x: sheet.width - r.x - r.width });
44
+ return {
45
+ ...sheet,
46
+ trim: flip(sheet.trim),
47
+ zones: sheet.zones.map((z) => ({ ...z, rect: flip(z.rect), safe: flip(z.safe) })).sort((a, b) => a.rect.x - b.rect.x),
48
+ lines: sheet.lines.map((l) => ({ ...l, x: sheet.width - l.x })).sort((a, b) => a.x - b.x),
49
+ };
50
+ }
51
+ /** The cover sheet of a softcover: back, spine and front (and the flaps),
52
+ * scored at the spine and at the hinges, with bleed all round. */
53
+ export function softcoverSheet(trim, spine, m, flaps) {
54
+ const b = m.bleed;
55
+ const panelW = flaps ? trim.width - m.flapFoldInset : trim.width;
56
+ const panels = [
57
+ ...(flaps ? [{ name: 'flapBack', width: m.flapWidth }] : []),
58
+ { name: 'back', width: panelW, clearRight: m.hingeScore },
59
+ { name: 'spine', width: spine, safeX: spineSafeMargin(spine) },
60
+ { name: 'front', width: panelW, clearLeft: m.hingeScore },
61
+ ...(flaps ? [{ name: 'flapFront', width: m.flapWidth }] : []),
62
+ ];
63
+ const zones = row(panels, b, b, trim.height, m.safeMargin, 0);
64
+ const lines = [];
65
+ if (flaps)
66
+ lines.push(lineAt(zones, 'flapBack', 'fold'));
67
+ const back = lineAt(zones, 'back', 'fold');
68
+ const front = lineAt(zones, 'spine', 'fold');
69
+ if (m.hingeScore > 0)
70
+ lines.push({ x: back.x - m.hingeScore, kind: 'score' });
71
+ lines.push(back, front);
72
+ if (m.hingeScore > 0)
73
+ lines.push({ x: front.x + m.hingeScore, kind: 'score' });
74
+ if (flaps)
75
+ lines.push(lineAt(zones, 'front', 'fold'));
76
+ const width = panels.reduce((w, p) => w + p.width, 0);
77
+ return {
78
+ kind: 'softcover',
79
+ width: width + 2 * b,
80
+ height: trim.height + 2 * b,
81
+ trim: { x: b, y: b, width, height: trim.height },
82
+ bleed: b,
83
+ zones,
84
+ lines,
85
+ spine,
86
+ };
87
+ }
88
+ /** Board size of a case for a trim, mm. */
89
+ export function caseBoard(trim, m) {
90
+ return { width: trim.width - m.boardSetback + m.square, height: trim.height + 2 * m.square };
91
+ }
92
+ /** Width of the spine of a case, mm: the block's spine, the two boards
93
+ * beside it and the allowance, and on a round case the round's own. */
94
+ export function caseSpineWidth(blockSpine, style, m) {
95
+ const flat = blockSpine + 2 * m.board + m.caseSpineAllowance;
96
+ return style === 'caseRound' ? flat + m.roundSpineAllowance : flat;
97
+ }
98
+ /** The covering sheet of a case: two boards and the spine with a joint
99
+ * either side, and the turn-in all round. Text keeps clear of the board
100
+ * edges by the board's thickness, which the material wraps round. */
101
+ export function caseSheet(trim, caseSpine, m) {
102
+ const t = m.turnIn;
103
+ const board = caseBoard(trim, m);
104
+ const panels = [
105
+ { name: 'back', width: board.width, clearLeft: m.board },
106
+ { name: 'jointBack', width: m.joint },
107
+ { name: 'spine', width: caseSpine, safeX: spineSafeMargin(caseSpine) },
108
+ { name: 'jointFront', width: m.joint },
109
+ { name: 'front', width: board.width, clearRight: m.board },
110
+ ];
111
+ const zones = row(panels, t, t, board.height, m.safeMargin, m.board);
112
+ const width = panels.reduce((w, p) => w + p.width, 0);
113
+ const lines = [
114
+ { x: t, kind: 'fold' },
115
+ lineAt(zones, 'back', 'joint'),
116
+ lineAt(zones, 'jointBack', 'joint'),
117
+ lineAt(zones, 'spine', 'joint'),
118
+ lineAt(zones, 'jointFront', 'joint'),
119
+ { x: t + width, kind: 'fold' },
120
+ ];
121
+ return {
122
+ kind: 'case',
123
+ width: width + 2 * t,
124
+ height: board.height + 2 * t,
125
+ trim: { x: t, y: t, width, height: board.height },
126
+ bleed: t,
127
+ zones,
128
+ lines,
129
+ spine: caseSpine,
130
+ };
131
+ }
132
+ /** The dust jacket of a case: as tall as the boards, its spine the case's,
133
+ * its panels reaching over the joint to the fore-edge and a little past
134
+ * it for the board the flap folds round, and its flaps. */
135
+ export function jacketSheet(trim, caseSpine, m) {
136
+ const b = m.jacketBleed;
137
+ const board = caseBoard(trim, m);
138
+ const fa = m.jacketFoldAllowance;
139
+ const panelW = board.width + m.joint + fa;
140
+ const spine = caseSpine;
141
+ const panels = [
142
+ { name: 'flapBack', width: m.jacketFlapWidth },
143
+ { name: 'back', width: panelW },
144
+ { name: 'spine', width: spine, safeX: spineSafeMargin(spine) },
145
+ { name: 'front', width: panelW },
146
+ { name: 'flapFront', width: m.jacketFlapWidth },
147
+ ];
148
+ const zones = row(panels, b, b, board.height, m.safeMargin, 0);
149
+ const width = panels.reduce((w, p) => w + p.width, 0);
150
+ return {
151
+ kind: 'jacket',
152
+ width: width + 2 * b,
153
+ height: board.height + 2 * b,
154
+ trim: { x: b, y: b, width, height: board.height },
155
+ bleed: b,
156
+ zones,
157
+ lines: ['flapBack', 'back', 'spine', 'front'].map((name) => lineAt(zones, name, 'fold')),
158
+ spine,
159
+ };
160
+ }
161
+ /** One endpaper spread, the size of two pages of the block: the pastedown
162
+ * glued to the board and the free flyleaf, the fold between them with
163
+ * its glue strip and the joint kept clear, bleed at head, foot and the
164
+ * outer edges. `side` is the front or back of the book; `rtl`, a book
165
+ * bound on the right. */
166
+ export function endpaperSheet(trim, m, side, rtl = false) {
167
+ const b = m.endpaperBleed;
168
+ // Opening the front of a left-bound book, the pastedown lies on the left.
169
+ const pastedownLeft = (side === 'front') !== rtl;
170
+ const clear = Math.max(m.endpaperGlueStrip, m.joint);
171
+ const left = { name: pastedownLeft ? 'pastedown' : 'flyleaf', width: trim.width, clearRight: clear };
172
+ const right = { name: pastedownLeft ? 'flyleaf' : 'pastedown', width: trim.width, clearLeft: clear };
173
+ const zones = row([left, right], b, b, trim.height, m.safeMargin, 0);
174
+ const fold = b + trim.width;
175
+ zones.push({
176
+ name: 'hinge',
177
+ rect: { x: fold - clear, y: b, width: 2 * clear, height: trim.height },
178
+ safe: { x: fold, y: b, width: 0, height: 0 },
179
+ });
180
+ const glueX = pastedownLeft ? fold + m.endpaperGlueStrip : fold - m.endpaperGlueStrip;
181
+ return {
182
+ kind: 'endpaper',
183
+ width: 2 * trim.width + 2 * b,
184
+ height: trim.height + 2 * b,
185
+ trim: { x: b, y: b, width: 2 * trim.width, height: trim.height },
186
+ bleed: b,
187
+ zones,
188
+ lines: [{ x: fold, kind: 'fold' }, { x: glueX, kind: 'glue' }],
189
+ spine: 0,
190
+ };
191
+ }
192
+ export const PROMO_FORMATS = {
193
+ // The cover image most EPUB stores ask for (Apple Books, Kobo, KDP):
194
+ // 1600 × 2560 px, 1 : 1.6.
195
+ epub: { width: 1600, height: 2560 },
196
+ square: { width: 1080, height: 1080 },
197
+ story: { width: 1080, height: 1920 },
198
+ // Link previews (Open Graph).
199
+ landscape: { width: 1200, height: 630 },
200
+ };
201
+ /** The front cover recomposed in a screen format: one zone, the front,
202
+ * as wide as the trim so its type keeps its size against it, as tall as
203
+ * the format says; no bleed, no folds. */
204
+ export function promoSheet(trim, format, safeMargin) {
205
+ const px = PROMO_FORMATS[format];
206
+ const width = trim.width;
207
+ const height = (width * px.height) / px.width;
208
+ const rect = { x: 0, y: 0, width, height };
209
+ return {
210
+ kind: 'promo',
211
+ width,
212
+ height,
213
+ trim: rect,
214
+ bleed: 0,
215
+ zones: [{ name: 'front', rect, safe: inset(rect, safeMargin, safeMargin, safeMargin, safeMargin) }],
216
+ lines: [],
217
+ spine: 0,
218
+ };
219
+ }
220
+ //# sourceMappingURL=geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/production/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwCH,MAAM,KAAK,GAAG,CAAC,CAAY,EAAE,IAAY,EAAE,GAAW,EAAE,KAAa,EAAE,MAAc,EAAa,EAAE,CAAC,CAAC;IACpG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI;IACb,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;IACZ,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IAC1C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;CAC7C,CAAC,CAAC;AAcH;6BAC6B;AAC7B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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EAAE,IAAI;QACV,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;QACnG,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,CAAC;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Checks for values read from untrusted data. Not exported from the
2
+ * package. */
3
+ export declare const isRecord: (v: unknown) => v is Record<string, unknown>;
4
+ /** A finite number, zero or more. */
5
+ export declare const isNum: (v: unknown) => v is number;
6
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/production/guards.ts"],"names":[],"mappings":"AAAA;eACe;AAEf,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAsD,CAAC;AAExH,qCAAqC;AACrC,eAAO,MAAM,KAAK,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAA+D,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Checks for values read from untrusted data. Not exported from the
2
+ * package. */
3
+ export const isRecord = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
4
+ /** A finite number, zero or more. */
5
+ export const isNum = (v) => typeof v === 'number' && Number.isFinite(v) && v >= 0;
6
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/production/guards.ts"],"names":[],"mappings":"AAAA;eACe;AAEf,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAExH,qCAAqC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ export * from './isbn.js';
2
+ export * from './barcodeSvg.js';
3
+ export * from './measures.js';
4
+ export * from './spine.js';
5
+ export * from './geometry.js';
6
+ export * from './version.js';
7
+ export * from './exchange.js';
8
+ export * from './config.js';
9
+ export { coverPage, sheetGuides, COVER_SLOT_ZONES, COVER_TEMPLATE_ID, COVER_ID_PREFIX, BARCODE_RESOURCE_ID } from './compose.js';
10
+ export type { CoverPageOptions, CoverPage, CoverIssue, SheetGuide, MirrorPicture } from './compose.js';
11
+ export { coverSource, coverFrames, coverParagraphStyles, markdownLiteral, COVER_PARAGRAPH_STYLES, COVER_FRAME_SHEETS } from './coverSource.js';
12
+ export { catalogueRange, withCatalogue, expandCatalogueText, CATALOGUE_STYLE, CATALOGUE_CURRENT_STYLE } from './catalogue.js';
13
+ export type { CoverSourceIssue } from './coverSource.js';
14
+ export { buildCover, coverZoneBox, coverSheetNames, coverDesignFor } from './buildCover.js';
15
+ export type { BuildCoverInput, BuildCoverIssue, BuiltCover, CoverSheetKind, CoverPageBox } from './buildCover.js';
16
+ export { coverElementRect, placeCoverElement, outlinePathData } from './coverDesign.js';
17
+ export { basicShape, roundedRectPath, pathData, coverPathCommands, flattenCoverPath, coverPathBounds, BASIC_SHAPES } from './shapes.js';
18
+ export type { BasicShape } from './shapes.js';
19
+ export { COVER_FINISH_INKS } from './coverArt.js';
20
+ export { workIsbnCaption } from './coverLabels.js';
21
+ export { folioOfBook, folioVersionOf, productionFolioBinding } from './folio.js';
22
+ export { DEFAULT_BINDING_MEASURES, BUILT_IN_BINDING_PROFILES, DEFAULT_SPINE_TEXT } from '../defaults/output/production.js';
23
+ export type * from '../types/output/production.js';
24
+ export type * from '../types/output/cover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AE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3H,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,0BAA0B,CAAC"}
@@ -0,0 +1,19 @@
1
+ export * from './isbn.js';
2
+ export * from './barcodeSvg.js';
3
+ export * from './measures.js';
4
+ export * from './spine.js';
5
+ export * from './geometry.js';
6
+ export * from './version.js';
7
+ export * from './exchange.js';
8
+ export * from './config.js';
9
+ export { coverPage, sheetGuides, COVER_SLOT_ZONES, COVER_TEMPLATE_ID, COVER_ID_PREFIX, BARCODE_RESOURCE_ID } from './compose.js';
10
+ export { coverSource, coverFrames, coverParagraphStyles, markdownLiteral, COVER_PARAGRAPH_STYLES, COVER_FRAME_SHEETS } from './coverSource.js';
11
+ export { catalogueRange, withCatalogue, expandCatalogueText, CATALOGUE_STYLE, CATALOGUE_CURRENT_STYLE } from './catalogue.js';
12
+ export { buildCover, coverZoneBox, coverSheetNames, coverDesignFor } from './buildCover.js';
13
+ export { coverElementRect, placeCoverElement, outlinePathData } from './coverDesign.js';
14
+ export { basicShape, roundedRectPath, pathData, coverPathCommands, flattenCoverPath, coverPathBounds, BASIC_SHAPES } from './shapes.js';
15
+ export { COVER_FINISH_INKS } from './coverArt.js';
16
+ export { workIsbnCaption } from './coverLabels.js';
17
+ export { folioOfBook, folioVersionOf, productionFolioBinding } from './folio.js';
18
+ export { DEFAULT_BINDING_MEASURES, BUILT_IN_BINDING_PROFILES, DEFAULT_SPINE_TEXT } from '../defaults/output/production.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/production/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjI,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/I,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9H,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExI,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ISBN and its EAN-13 barcode: reading an ISBN as written (with or without
3
+ * hyphens, ISBN-10 or ISBN-13), checking it, and the bars of the barcode
4
+ * printed on the back cover, with the optional five-digit add-on (a price).
5
+ */
6
+ /** Why an ISBN cannot be read: characters other than digits, hyphens and
7
+ * spaces (and a final X on an ISBN-10); neither 10 nor 13 digits; a
8
+ * 13-digit number that does not start 978 or 979; or a wrong check digit. */
9
+ export type IsbnError = 'chars' | 'length' | 'prefix' | 'checksum';
10
+ export type IsbnReading = {
11
+ ok: true;
12
+ isbn13: string;
13
+ isbn10?: string;
14
+ } | {
15
+ ok: false;
16
+ error: IsbnError;
17
+ };
18
+ /** The EAN-13 check digit of twelve digits. */
19
+ export declare function ean13CheckDigit(first12: string): number;
20
+ /** Reads an ISBN as written, `978-0-306-40615-7`, `ISBN 0306406152` or
21
+ * `9780306406157`, and gives it as the thirteen digits of the barcode
22
+ * (an ISBN-10 is converted) together with its ISBN-10 when it has one. */
23
+ export declare function parseIsbn(raw: string): IsbnReading;
24
+ /** One bar of a barcode, in modules from the left edge of the symbol (the
25
+ * quiet zone not included). Guard bars run down past the others, into
26
+ * the line of digits. */
27
+ export interface BarcodeBar {
28
+ x: number;
29
+ width: number;
30
+ guard: boolean;
31
+ }
32
+ /** An EAN-13 symbol, and its add-on when there is one: the bars and the
33
+ * digits printed under them. */
34
+ export interface Ean13Symbol {
35
+ digits: string;
36
+ bars: BarcodeBar[];
37
+ /** Width of the main symbol in modules (95). */
38
+ width: number;
39
+ addOn?: {
40
+ digits: string;
41
+ bars: BarcodeBar[];
42
+ x: number;
43
+ width: number;
44
+ };
45
+ }
46
+ /** Width of an EAN-13 module at 100 % (nominal size), mm. */
47
+ export declare const EAN13_MODULE_MM = 0.33;
48
+ /** Height of the bars at 100 %, mm (the guard bars are 5 modules longer). */
49
+ export declare const EAN13_BAR_HEIGHT_MM = 22.85;
50
+ /** Quiet zones at either side, in modules: 11 on the left, 7 on the right. */
51
+ export declare const EAN13_QUIET_ZONE: {
52
+ readonly left: 11;
53
+ readonly right: 7;
54
+ };
55
+ /** Gap between the main symbol and its add-on, in modules (7 … 12). */
56
+ export declare const EAN_ADDON_GAP = 9;
57
+ /** The bars of an EAN-13 for thirteen digits, with the bars of a five-digit
58
+ * add-on when `addOn` is given (a price: `'51995'`). Throws on input that
59
+ * is not thirteen digits with a right check digit, or an add-on that is
60
+ * not five digits: read the ISBN with {@link parseIsbn} first. */
61
+ export declare function ean13Symbol(digits: string, addOn?: string): Ean13Symbol;
62
+ /** The line printed over the barcode: `ISBN 978-0-306-40615-7` when the
63
+ * ISBN was written with its hyphens (they mark the registration group,
64
+ * publisher and title, which only the agency's range table can place),
65
+ * the bare thirteen digits otherwise. */
66
+ export declare function isbnCaption(raw: string, isbn13: string): string;
67
+ //# sourceMappingURL=isbn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isbn.d.ts","sourceRoot":"","sources":["../../src/production/isbn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;8EAE8E;AAC9E,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnE,MAAM,MAAM,WAAW,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAOpC,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIvD;AAqBD;;2EAE2E;AAC3E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAalD;AAaD;;0BAE0B;AAC1B,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;iCACiC;AACjC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1E;AAED,6DAA6D;AAC7D,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB;;;CAAkC,CAAC;AAChE,uEAAuE;AACvE,eAAO,MAAM,aAAa,IAAI,CAAC;AAa/B;;;mEAGmE;AACnE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CA6BvE;AAED;;;0CAG0C;AAC1C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI/D"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * ISBN and its EAN-13 barcode: reading an ISBN as written (with or without
3
+ * hyphens, ISBN-10 or ISBN-13), checking it, and the bars of the barcode
4
+ * printed on the back cover, with the optional five-digit add-on (a price).
5
+ */
6
+ /** The digits of an ISBN as written: `ISBN`, hyphens and spaces dropped. */
7
+ function isbnDigits(raw) {
8
+ return raw.trim().replace(/^isbn(?:-1[03])?:?\s*/i, '').replace(/[\s‐-―-]/g, '');
9
+ }
10
+ /** The EAN-13 check digit of twelve digits. */
11
+ export function ean13CheckDigit(first12) {
12
+ let sum = 0;
13
+ for (let i = 0; i < 12; i++)
14
+ sum += Number(first12[i]) * (i % 2 === 0 ? 1 : 3);
15
+ return (10 - (sum % 10)) % 10;
16
+ }
17
+ function isbn10CheckValid(digits) {
18
+ let sum = 0;
19
+ for (let i = 0; i < 10; i++) {
20
+ const c = digits[i];
21
+ sum += (c === 'X' || c === 'x' ? 10 : Number(c)) * (10 - i);
22
+ }
23
+ return sum % 11 === 0;
24
+ }
25
+ /** The ISBN-10 of a 978 ISBN-13 (979 numbers have none). */
26
+ function isbn10Of(isbn13) {
27
+ if (!isbn13.startsWith('978'))
28
+ return undefined;
29
+ const nine = isbn13.slice(3, 12);
30
+ let sum = 0;
31
+ for (let i = 0; i < 9; i++)
32
+ sum += Number(nine[i]) * (10 - i);
33
+ const check = (11 - (sum % 11)) % 11;
34
+ return nine + (check === 10 ? 'X' : String(check));
35
+ }
36
+ /** Reads an ISBN as written, `978-0-306-40615-7`, `ISBN 0306406152` or
37
+ * `9780306406157`, and gives it as the thirteen digits of the barcode
38
+ * (an ISBN-10 is converted) together with its ISBN-10 when it has one. */
39
+ export function parseIsbn(raw) {
40
+ const d = isbnDigits(raw);
41
+ if (/^\d{9}[\dXx]$/.test(d)) {
42
+ if (!isbn10CheckValid(d))
43
+ return { ok: false, error: 'checksum' };
44
+ const first12 = '978' + d.slice(0, 9);
45
+ return { ok: true, isbn13: first12 + ean13CheckDigit(first12), isbn10: d.toUpperCase() };
46
+ }
47
+ if (!/^[\dXx]*$/.test(d))
48
+ return { ok: false, error: 'chars' };
49
+ if (d.length !== 13 || !/^\d+$/.test(d))
50
+ return { ok: false, error: 'length' };
51
+ if (!d.startsWith('978') && !d.startsWith('979'))
52
+ return { ok: false, error: 'prefix' };
53
+ if (ean13CheckDigit(d) !== Number(d[12]))
54
+ return { ok: false, error: 'checksum' };
55
+ const isbn10 = isbn10Of(d);
56
+ return isbn10 ? { ok: true, isbn13: d, isbn10 } : { ok: true, isbn13: d };
57
+ }
58
+ // EAN-13 digit patterns (GS1 General Specifications, 5.2.1.2): the left
59
+ // half in sets A (odd parity) and B (even), the right half in set C.
60
+ const SET_A = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'];
61
+ const SET_C = SET_A.map((p) => [...p].map((b) => (b === '1' ? '0' : '1')).join(''));
62
+ const SET_B = SET_C.map((p) => [...p].reverse().join(''));
63
+ /** Which set each left-hand digit takes, by the first digit (which is
64
+ * not drawn as bars: it is read from this pattern). */
65
+ const EAN13_PARITY = ['AAAAAA', 'AABABB', 'AABBAB', 'AABBBA', 'ABAABB', 'ABBAAB', 'ABBBAA', 'ABABAB', 'ABABBA', 'ABBABA'];
66
+ /** Which set each digit of the five-digit add-on takes, by its checksum. */
67
+ const EAN5_PARITY = ['BBAAA', 'BABAA', 'BAABA', 'BAAAB', 'ABBAA', 'AABBA', 'AAABB', 'ABABA', 'ABAAB', 'AABAB'];
68
+ /** Width of an EAN-13 module at 100 % (nominal size), mm. */
69
+ export const EAN13_MODULE_MM = 0.33;
70
+ /** Height of the bars at 100 %, mm (the guard bars are 5 modules longer). */
71
+ export const EAN13_BAR_HEIGHT_MM = 22.85;
72
+ /** Quiet zones at either side, in modules: 11 on the left, 7 on the right. */
73
+ export const EAN13_QUIET_ZONE = { left: 11, right: 7 };
74
+ /** Gap between the main symbol and its add-on, in modules (7 … 12). */
75
+ export const EAN_ADDON_GAP = 9;
76
+ function runs(pattern, offset, guard) {
77
+ const bars = [];
78
+ for (let i = 0; i < pattern.length; i++) {
79
+ if (pattern[i] !== '1')
80
+ continue;
81
+ const last = bars[bars.length - 1];
82
+ if (last && last.x + last.width === offset + i && last.guard === guard(i))
83
+ last.width++;
84
+ else
85
+ bars.push({ x: offset + i, width: 1, guard: guard(i) });
86
+ }
87
+ return bars;
88
+ }
89
+ /** The bars of an EAN-13 for thirteen digits, with the bars of a five-digit
90
+ * add-on when `addOn` is given (a price: `'51995'`). Throws on input that
91
+ * is not thirteen digits with a right check digit, or an add-on that is
92
+ * not five digits: read the ISBN with {@link parseIsbn} first. */
93
+ export function ean13Symbol(digits, addOn) {
94
+ if (!/^\d{13}$/.test(digits) || ean13CheckDigit(digits) !== Number(digits[12])) {
95
+ throw new Error(`ean13Symbol: "${digits}" is not an EAN-13`);
96
+ }
97
+ const parity = EAN13_PARITY[Number(digits[0])];
98
+ let pattern = '101';
99
+ for (let i = 1; i <= 6; i++) {
100
+ const set = parity[i - 1] === 'A' ? SET_A : SET_B;
101
+ pattern += set[Number(digits[i])];
102
+ }
103
+ pattern += '01010';
104
+ for (let i = 7; i <= 12; i++)
105
+ pattern += SET_C[Number(digits[i])];
106
+ pattern += '101';
107
+ const isGuard = (i) => i < 3 || (i >= 45 && i < 50) || i >= 92;
108
+ const symbol = { digits, bars: runs(pattern, 0, isGuard), width: 95 };
109
+ if (addOn !== undefined) {
110
+ if (!/^\d{5}$/.test(addOn))
111
+ throw new Error(`ean13Symbol: add-on "${addOn}" is not five digits`);
112
+ const d = [...addOn].map(Number);
113
+ const check = (3 * (d[0] + d[2] + d[4]) + 9 * (d[1] + d[3])) % 10;
114
+ const addOnParity = EAN5_PARITY[check];
115
+ let add = '1011';
116
+ d.forEach((digit, i) => {
117
+ if (i > 0)
118
+ add += '01';
119
+ add += (addOnParity[i] === 'A' ? SET_A : SET_B)[digit];
120
+ });
121
+ const x = 95 + EAN_ADDON_GAP;
122
+ symbol.addOn = { digits: addOn, bars: runs(add, x, () => false), x, width: add.length };
123
+ }
124
+ return symbol;
125
+ }
126
+ /** The line printed over the barcode: `ISBN 978-0-306-40615-7` when the
127
+ * ISBN was written with its hyphens (they mark the registration group,
128
+ * publisher and title, which only the agency's range table can place),
129
+ * the bare thirteen digits otherwise. */
130
+ export function isbnCaption(raw, isbn13) {
131
+ const written = raw.trim().replace(/^isbn(?:-1[03])?:?\s*/i, '');
132
+ const hyphenated = /^97[89][-‐ ]\d+[-‐ ]\d+[-‐ ]\d+[-‐ ]\d$/.test(written);
133
+ return `ISBN ${hyphenated ? written.replace(/[‐ ]/g, '-') : isbn13}`;
134
+ }
135
+ //# sourceMappingURL=isbn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isbn.js","sourceRoot":"","sources":["../../src/production/isbn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,4EAA4E;AAC5E,SA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AC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;0CAG0C;AAC1C,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,MAAc;IACrD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,yCAAyC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3E,OAAO,QAAQ,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { FolioBindingType } from '../types/output/folio.js';
2
+ import type { BindingMeasures, BindingStyle, BindingProfile, ProductionLength, ProductionVersion, TrimMm } from '../types/output/production.js';
3
+ /** A {@link ProductionLength} for a trim, mm. */
4
+ export declare function resolveLength(length: ProductionLength, trim: TrimMm): number;
5
+ /** Every measure of a binding as millimetres for one trim. */
6
+ export type ResolvedBindingMeasures = {
7
+ [K in keyof BindingMeasures]: number;
8
+ };
9
+ /** The measures of a version for its trim: the defaults of its binding
10
+ * style, under the profile's, under the version's own overrides. */
11
+ export declare function resolveBindingMeasures(profile: BindingProfile, trim: TrimMm, overrides?: ProductionVersion['overrides']): ResolvedBindingMeasures;
12
+ /** A book a binding profile cannot make: its trim or spine is outside the
13
+ * profile's `accepts`. */
14
+ export interface ProfileOutOfRangeWarning {
15
+ kind: 'profileOutOfRange';
16
+ profile: string;
17
+ measure: 'trimWidth' | 'trimHeight' | 'spine';
18
+ /** The book's value and the limit it passes, mm. */
19
+ value: number;
20
+ limit: number;
21
+ side: 'min' | 'max';
22
+ }
23
+ /** What of a book a binding profile does not accept. */
24
+ export declare function checkProfileAccepts(profile: BindingProfile, trim: TrimMm, spine: number): ProfileOutOfRangeWarning[];
25
+ /** The binding Folio's 3D book takes for a binding style: the print
26
+ * cover's styles are finer (a case with a flat or a round spine), Folio's
27
+ * name how the book opens and looks. One mapping, used wherever a version
28
+ * binds the 3D book. */
29
+ export declare const FOLIO_BINDING_OF_STYLE: Readonly<Record<BindingStyle, FolioBindingType>>;
30
+ //# sourceMappingURL=measures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measures.d.ts","sourceRoot":"","sources":["../../src/production/measures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACP,MAAM,+BAA+B,CAAC;AAEvC,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5E;AAED,8DAA8D;AAC9D,MAAM,MAAM,uBAAuB,GAAG;KAAG,CAAC,IAAI,MAAM,eAAe,GAAG,MAAM;CAAE,CAAC;AAE/E;qEACqE;AACrE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,GACzC,uBAAuB,CAQzB;AAED;2BAC2B;AAC3B,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;IAC9C,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;CACrB;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,wBAAwB,EAAE,CAepH;AAED;;;yBAGyB;AACzB,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAKnF,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { DEFAULT_BINDING_MEASURES } from '../defaults/output/production.js';
2
+ /** A {@link ProductionLength} for a trim, mm. */
3
+ export function resolveLength(length, trim) {
4
+ if (typeof length === 'number')
5
+ return length;
6
+ if (Array.isArray(length)) {
7
+ const step = length.find((s) => !s.upTo || (trim.width <= s.upTo.width && trim.height <= s.upTo.height));
8
+ return (step ?? length[length.length - 1])?.mm ?? 0;
9
+ }
10
+ const raw = length.ratio * (length.of === 'height' ? trim.height : trim.width);
11
+ return Math.min(length.max ?? Infinity, Math.max(length.min ?? -Infinity, raw));
12
+ }
13
+ /** The measures of a version for its trim: the defaults of its binding
14
+ * style, under the profile's, under the version's own overrides. */
15
+ export function resolveBindingMeasures(profile, trim, overrides) {
16
+ const merged = { ...DEFAULT_BINDING_MEASURES[profile.style], ...profile.measures };
17
+ const out = {};
18
+ for (const key of Object.keys(merged)) {
19
+ const own = overrides?.[key];
20
+ out[key] = own !== undefined ? own : resolveLength(merged[key], trim);
21
+ }
22
+ return out;
23
+ }
24
+ /** What of a book a binding profile does not accept. */
25
+ export function checkProfileAccepts(profile, trim, spine) {
26
+ const out = [];
27
+ const a = profile.accepts;
28
+ if (!a)
29
+ return out;
30
+ const push = (measure, value, limit, side) => {
31
+ if (limit === undefined)
32
+ return;
33
+ if (side === 'min' ? value < limit : value > limit)
34
+ out.push({ kind: 'profileOutOfRange', profile: profile.id, measure, value, limit, side });
35
+ };
36
+ push('trimWidth', trim.width, a.trim?.min?.width, 'min');
37
+ push('trimHeight', trim.height, a.trim?.min?.height, 'min');
38
+ push('trimWidth', trim.width, a.trim?.max?.width, 'max');
39
+ push('trimHeight', trim.height, a.trim?.max?.height, 'max');
40
+ push('spine', spine, a.spine?.min, 'min');
41
+ push('spine', spine, a.spine?.max, 'max');
42
+ return out;
43
+ }
44
+ /** The binding Folio's 3D book takes for a binding style: the print
45
+ * cover's styles are finer (a case with a flat or a round spine), Folio's
46
+ * name how the book opens and looks. One mapping, used wherever a version
47
+ * binds the 3D book. */
48
+ export const FOLIO_BINDING_OF_STYLE = {
49
+ perfect: 'paperback',
50
+ sewnSoftcover: 'sewn',
51
+ caseFlat: 'hardcover',
52
+ caseRound: 'hardcover',
53
+ };
54
+ //# sourceMappingURL=measures.js.map