postext 1.91.2 → 1.93.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 (296) hide show
  1. package/dist/__tests__/composed/corpus.test.js +3 -1
  2. package/dist/__tests__/composed/corpus.test.js.map +1 -1
  3. package/dist/__tests__/exports.test.js +96 -0
  4. package/dist/__tests__/exports.test.js.map +1 -1
  5. package/dist/__tests__/paint/cropMarks.test.js +31 -0
  6. package/dist/__tests__/paint/cropMarks.test.js.map +1 -1
  7. package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts +2 -0
  8. package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts.map +1 -0
  9. package/dist/__tests__/pipeline/pages/reliefPlates.test.js +92 -0
  10. package/dist/__tests__/pipeline/pages/reliefPlates.test.js.map +1 -0
  11. package/dist/__tests__/production/compose.test.d.ts +2 -0
  12. package/dist/__tests__/production/compose.test.d.ts.map +1 -0
  13. package/dist/__tests__/production/compose.test.js +178 -0
  14. package/dist/__tests__/production/compose.test.js.map +1 -0
  15. package/dist/__tests__/production/config.test.d.ts +2 -0
  16. package/dist/__tests__/production/config.test.d.ts.map +1 -0
  17. package/dist/__tests__/production/config.test.js +83 -0
  18. package/dist/__tests__/production/config.test.js.map +1 -0
  19. package/dist/__tests__/production/cover.test.d.ts +2 -0
  20. package/dist/__tests__/production/cover.test.d.ts.map +1 -0
  21. package/dist/__tests__/production/cover.test.js +273 -0
  22. package/dist/__tests__/production/cover.test.js.map +1 -0
  23. package/dist/__tests__/production/coverLayers.test.d.ts +2 -0
  24. package/dist/__tests__/production/coverLayers.test.d.ts.map +1 -0
  25. package/dist/__tests__/production/coverLayers.test.js +198 -0
  26. package/dist/__tests__/production/coverLayers.test.js.map +1 -0
  27. package/dist/__tests__/production/coverOutputs.test.d.ts +2 -0
  28. package/dist/__tests__/production/coverOutputs.test.d.ts.map +1 -0
  29. package/dist/__tests__/production/coverOutputs.test.js +104 -0
  30. package/dist/__tests__/production/coverOutputs.test.js.map +1 -0
  31. package/dist/__tests__/production/coverTextBoxes.test.d.ts +2 -0
  32. package/dist/__tests__/production/coverTextBoxes.test.d.ts.map +1 -0
  33. package/dist/__tests__/production/coverTextBoxes.test.js +127 -0
  34. package/dist/__tests__/production/coverTextBoxes.test.js.map +1 -0
  35. package/dist/__tests__/production/geometry.test.d.ts +2 -0
  36. package/dist/__tests__/production/geometry.test.d.ts.map +1 -0
  37. package/dist/__tests__/production/geometry.test.js +281 -0
  38. package/dist/__tests__/production/geometry.test.js.map +1 -0
  39. package/dist/__tests__/production/mirrorBleed.test.d.ts +2 -0
  40. package/dist/__tests__/production/mirrorBleed.test.d.ts.map +1 -0
  41. package/dist/__tests__/production/mirrorBleed.test.js +129 -0
  42. package/dist/__tests__/production/mirrorBleed.test.js.map +1 -0
  43. package/dist/__tests__/production/shapes.test.d.ts +2 -0
  44. package/dist/__tests__/production/shapes.test.d.ts.map +1 -0
  45. package/dist/__tests__/production/shapes.test.js +107 -0
  46. package/dist/__tests__/production/shapes.test.js.map +1 -0
  47. package/dist/__tests__/production/sheets.test.d.ts +2 -0
  48. package/dist/__tests__/production/sheets.test.d.ts.map +1 -0
  49. package/dist/__tests__/production/sheets.test.js +153 -0
  50. package/dist/__tests__/production/sheets.test.js.map +1 -0
  51. package/dist/bundle/api.d.ts +8 -0
  52. package/dist/bundle/api.d.ts.map +1 -1
  53. package/dist/bundle/api.js +3 -0
  54. package/dist/bundle/api.js.map +1 -1
  55. package/dist/bundle/codec/files.d.ts.map +1 -1
  56. package/dist/bundle/codec/files.js +2 -0
  57. package/dist/bundle/codec/files.js.map +1 -1
  58. package/dist/bundle/codec/plan.d.ts +12 -0
  59. package/dist/bundle/codec/plan.d.ts.map +1 -1
  60. package/dist/bundle/codec/plan.js +12 -1
  61. package/dist/bundle/codec/plan.js.map +1 -1
  62. package/dist/bundle/codec/read.d.ts +3 -0
  63. package/dist/bundle/codec/read.d.ts.map +1 -1
  64. package/dist/bundle/codec/read.js +14 -2
  65. package/dist/bundle/codec/read.js.map +1 -1
  66. package/dist/bundle/index.d.ts +1 -1
  67. package/dist/bundle/index.d.ts.map +1 -1
  68. package/dist/bundle/index.js +1 -1
  69. package/dist/bundle/index.js.map +1 -1
  70. package/dist/bundle/manifest/locale.d.ts +3 -0
  71. package/dist/bundle/manifest/locale.d.ts.map +1 -1
  72. package/dist/bundle/manifest/locale.js +5 -0
  73. package/dist/bundle/manifest/locale.js.map +1 -1
  74. package/dist/bundle/manifest/validation.d.ts.map +1 -1
  75. package/dist/bundle/manifest/validation.js +4 -0
  76. package/dist/bundle/manifest/validation.js.map +1 -1
  77. package/dist/bundle/manifest.d.ts +1 -1
  78. package/dist/bundle/manifest.d.ts.map +1 -1
  79. package/dist/bundle/manifest.js +1 -1
  80. package/dist/bundle/manifest.js.map +1 -1
  81. package/dist/bundle/types.d.ts +7 -0
  82. package/dist/bundle/types.d.ts.map +1 -1
  83. package/dist/checks/configWarnings/collect.d.ts +6 -1
  84. package/dist/checks/configWarnings/collect.d.ts.map +1 -1
  85. package/dist/checks/configWarnings/collect.js +9 -1
  86. package/dist/checks/configWarnings/collect.js.map +1 -1
  87. package/dist/checks/configWarnings/cover.d.ts +18 -0
  88. package/dist/checks/configWarnings/cover.d.ts.map +1 -0
  89. package/dist/checks/configWarnings/cover.js +206 -0
  90. package/dist/checks/configWarnings/cover.js.map +1 -0
  91. package/dist/checks/configWarnings/production.d.ts +12 -0
  92. package/dist/checks/configWarnings/production.d.ts.map +1 -0
  93. package/dist/checks/configWarnings/production.js +48 -0
  94. package/dist/checks/configWarnings/production.js.map +1 -0
  95. package/dist/checks/preflight.d.ts.map +1 -1
  96. package/dist/checks/preflight.js +5 -0
  97. package/dist/checks/preflight.js.map +1 -1
  98. package/dist/checks/preflightFolds.d.ts +19 -0
  99. package/dist/checks/preflightFolds.d.ts.map +1 -0
  100. package/dist/checks/preflightFolds.js +81 -0
  101. package/dist/checks/preflightFolds.js.map +1 -0
  102. package/dist/checks/preflightIssues.d.ts +24 -0
  103. package/dist/checks/preflightIssues.d.ts.map +1 -1
  104. package/dist/composed/paint.d.ts +2 -1
  105. package/dist/composed/paint.d.ts.map +1 -1
  106. package/dist/composed/paint.js +3 -2
  107. package/dist/composed/paint.js.map +1 -1
  108. package/dist/defaults/bookKeys.d.ts +2 -2
  109. package/dist/defaults/bookKeys.d.ts.map +1 -1
  110. package/dist/defaults/bookKeys.js +2 -2
  111. package/dist/defaults/bookKeys.js.map +1 -1
  112. package/dist/defaults/index.d.ts +1 -1
  113. package/dist/defaults/index.d.ts.map +1 -1
  114. package/dist/defaults/index.js +1 -1
  115. package/dist/defaults/index.js.map +1 -1
  116. package/dist/defaults/output/folio.d.ts +6 -1
  117. package/dist/defaults/output/folio.d.ts.map +1 -1
  118. package/dist/defaults/output/folio.js +10 -0
  119. package/dist/defaults/output/folio.js.map +1 -1
  120. package/dist/defaults/output/production.d.ts +13 -0
  121. package/dist/defaults/output/production.d.ts.map +1 -0
  122. package/dist/defaults/output/production.js +84 -0
  123. package/dist/defaults/output/production.js.map +1 -0
  124. package/dist/defaults/page.d.ts.map +1 -1
  125. package/dist/defaults/page.js +4 -1
  126. package/dist/defaults/page.js.map +1 -1
  127. package/dist/defaults/structure/headerFooter/resolve.d.ts.map +1 -1
  128. package/dist/defaults/structure/headerFooter/resolve.js +1 -0
  129. package/dist/defaults/structure/headerFooter/resolve.js.map +1 -1
  130. package/dist/design/elementKeys.d.ts +6 -0
  131. package/dist/design/elementKeys.d.ts.map +1 -1
  132. package/dist/design/elementKeys.js +5 -5
  133. package/dist/design/elementKeys.js.map +1 -1
  134. package/dist/designs/parts.d.ts +2 -1
  135. package/dist/designs/parts.d.ts.map +1 -1
  136. package/dist/designs/parts.js +2 -1
  137. package/dist/designs/parts.js.map +1 -1
  138. package/dist/index.d.ts +2 -2
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.js +1 -1
  141. package/dist/index.js.map +1 -1
  142. package/dist/paint/cropMarks.d.ts +2 -1
  143. package/dist/paint/cropMarks.d.ts.map +1 -1
  144. package/dist/paint/cropMarks.js +7 -1
  145. package/dist/paint/cropMarks.js.map +1 -1
  146. package/dist/pipeline/config.d.ts.map +1 -1
  147. package/dist/pipeline/config.js +9 -2
  148. package/dist/pipeline/config.js.map +1 -1
  149. package/dist/pipeline/pages/dieCuts.d.ts +2 -1
  150. package/dist/pipeline/pages/dieCuts.d.ts.map +1 -1
  151. package/dist/pipeline/pages/dieCuts.js +18 -2
  152. package/dist/pipeline/pages/dieCuts.js.map +1 -1
  153. package/dist/pipeline/pages/headerFooter/pageDecoration.d.ts.map +1 -1
  154. package/dist/pipeline/pages/headerFooter/pageDecoration.js +8 -3
  155. package/dist/pipeline/pages/headerFooter/pageDecoration.js.map +1 -1
  156. package/dist/pipeline/pages/headerFooter/slotLayout.d.ts +3 -2
  157. package/dist/pipeline/pages/headerFooter/slotLayout.d.ts.map +1 -1
  158. package/dist/pipeline/pages/headerFooter/slotLayout.js +1 -1
  159. package/dist/pipeline/pages/headerFooter/slotLayout.js.map +1 -1
  160. package/dist/production/barcodeSvg.d.ts +28 -0
  161. package/dist/production/barcodeSvg.d.ts.map +1 -0
  162. package/dist/production/barcodeSvg.js +64 -0
  163. package/dist/production/barcodeSvg.js.map +1 -0
  164. package/dist/production/buildCover.d.ts +104 -0
  165. package/dist/production/buildCover.d.ts.map +1 -0
  166. package/dist/production/buildCover.js +169 -0
  167. package/dist/production/buildCover.js.map +1 -0
  168. package/dist/production/catalogue.d.ts +40 -0
  169. package/dist/production/catalogue.d.ts.map +1 -0
  170. package/dist/production/catalogue.js +106 -0
  171. package/dist/production/catalogue.js.map +1 -0
  172. package/dist/production/compose.d.ts +123 -0
  173. package/dist/production/compose.d.ts.map +1 -0
  174. package/dist/production/compose.js +264 -0
  175. package/dist/production/compose.js.map +1 -0
  176. package/dist/production/config.d.ts +15 -0
  177. package/dist/production/config.d.ts.map +1 -0
  178. package/dist/production/config.js +143 -0
  179. package/dist/production/config.js.map +1 -0
  180. package/dist/production/coverArt.d.ts +74 -0
  181. package/dist/production/coverArt.d.ts.map +1 -0
  182. package/dist/production/coverArt.js +355 -0
  183. package/dist/production/coverArt.js.map +1 -0
  184. package/dist/production/coverDesign.d.ts +22 -0
  185. package/dist/production/coverDesign.d.ts.map +1 -0
  186. package/dist/production/coverDesign.js +111 -0
  187. package/dist/production/coverDesign.js.map +1 -0
  188. package/dist/production/coverLabels.d.ts +8 -0
  189. package/dist/production/coverLabels.d.ts.map +1 -0
  190. package/dist/production/coverLabels.js +23 -0
  191. package/dist/production/coverLabels.js.map +1 -0
  192. package/dist/production/coverSource.d.ts +79 -0
  193. package/dist/production/coverSource.d.ts.map +1 -0
  194. package/dist/production/coverSource.js +142 -0
  195. package/dist/production/coverSource.js.map +1 -0
  196. package/dist/production/coverTextBoxes.d.ts +68 -0
  197. package/dist/production/coverTextBoxes.d.ts.map +1 -0
  198. package/dist/production/coverTextBoxes.js +187 -0
  199. package/dist/production/coverTextBoxes.js.map +1 -0
  200. package/dist/production/exchange.d.ts +38 -0
  201. package/dist/production/exchange.d.ts.map +1 -0
  202. package/dist/production/exchange.js +146 -0
  203. package/dist/production/exchange.js.map +1 -0
  204. package/dist/production/folio.d.ts +21 -0
  205. package/dist/production/folio.d.ts.map +1 -0
  206. package/dist/production/folio.js +35 -0
  207. package/dist/production/folio.js.map +1 -0
  208. package/dist/production/geometry.d.ts +84 -0
  209. package/dist/production/geometry.d.ts.map +1 -0
  210. package/dist/production/geometry.js +220 -0
  211. package/dist/production/geometry.js.map +1 -0
  212. package/dist/production/guards.d.ts +6 -0
  213. package/dist/production/guards.d.ts.map +1 -0
  214. package/dist/production/guards.js +6 -0
  215. package/dist/production/guards.js.map +1 -0
  216. package/dist/production/index.d.ts +27 -0
  217. package/dist/production/index.d.ts.map +1 -0
  218. package/dist/production/index.js +20 -0
  219. package/dist/production/index.js.map +1 -0
  220. package/dist/production/isbn.d.ts +67 -0
  221. package/dist/production/isbn.d.ts.map +1 -0
  222. package/dist/production/isbn.js +135 -0
  223. package/dist/production/isbn.js.map +1 -0
  224. package/dist/production/measures.d.ts +30 -0
  225. package/dist/production/measures.d.ts.map +1 -0
  226. package/dist/production/measures.js +54 -0
  227. package/dist/production/measures.js.map +1 -0
  228. package/dist/production/mirrorBleed.d.ts +54 -0
  229. package/dist/production/mirrorBleed.d.ts.map +1 -0
  230. package/dist/production/mirrorBleed.js +92 -0
  231. package/dist/production/mirrorBleed.js.map +1 -0
  232. package/dist/production/shapes.d.ts +65 -0
  233. package/dist/production/shapes.d.ts.map +1 -0
  234. package/dist/production/shapes.js +313 -0
  235. package/dist/production/shapes.js.map +1 -0
  236. package/dist/production/spine.d.ts +38 -0
  237. package/dist/production/spine.d.ts.map +1 -0
  238. package/dist/production/spine.js +48 -0
  239. package/dist/production/spine.js.map +1 -0
  240. package/dist/production/svgSafe.d.ts +25 -0
  241. package/dist/production/svgSafe.d.ts.map +1 -0
  242. package/dist/production/svgSafe.js +33 -0
  243. package/dist/production/svgSafe.js.map +1 -0
  244. package/dist/production/version.d.ts +66 -0
  245. package/dist/production/version.d.ts.map +1 -0
  246. package/dist/production/version.js +68 -0
  247. package/dist/production/version.js.map +1 -0
  248. package/dist/types/config.d.ts +12 -0
  249. package/dist/types/config.d.ts.map +1 -1
  250. package/dist/types/designCut.d.ts +13 -1
  251. package/dist/types/designCut.d.ts.map +1 -1
  252. package/dist/types/designElements.d.ts +15 -0
  253. package/dist/types/designElements.d.ts.map +1 -1
  254. package/dist/types/output/cover.d.ts +269 -0
  255. package/dist/types/output/cover.d.ts.map +1 -0
  256. package/dist/types/output/cover.js +2 -0
  257. package/dist/types/output/cover.js.map +1 -0
  258. package/dist/types/output/production.d.ts +186 -0
  259. package/dist/types/output/production.d.ts.map +1 -0
  260. package/dist/types/output/production.js +2 -0
  261. package/dist/types/output/production.js.map +1 -0
  262. package/dist/types/page.d.ts +5 -0
  263. package/dist/types/page.d.ts.map +1 -1
  264. package/dist/types.d.ts +2 -0
  265. package/dist/types.d.ts.map +1 -1
  266. package/dist/util/base64.d.ts +3 -0
  267. package/dist/util/base64.d.ts.map +1 -0
  268. package/dist/util/base64.js +48 -0
  269. package/dist/util/base64.js.map +1 -0
  270. package/dist/util/png.d.ts +10 -0
  271. package/dist/util/png.d.ts.map +1 -0
  272. package/dist/util/png.js +60 -0
  273. package/dist/util/png.js.map +1 -0
  274. package/dist/util/xmlEscape.d.ts +6 -0
  275. package/dist/util/xmlEscape.d.ts.map +1 -0
  276. package/dist/util/xmlEscape.js +15 -0
  277. package/dist/util/xmlEscape.js.map +1 -0
  278. package/dist/vdt/design.d.ts +10 -1
  279. package/dist/vdt/design.d.ts.map +1 -1
  280. package/dist/vdt/design.js.map +1 -1
  281. package/dist/vdt/pages.d.ts +13 -0
  282. package/dist/vdt/pages.d.ts.map +1 -1
  283. package/dist/vdt.d.ts +1 -1
  284. package/dist/vdt.d.ts.map +1 -1
  285. package/dist/word/anchors/base64.d.ts +1 -2
  286. package/dist/word/anchors/base64.d.ts.map +1 -1
  287. package/dist/word/anchors/base64.js +2 -46
  288. package/dist/word/anchors/base64.js.map +1 -1
  289. package/dist/word/semantic/design/ground.d.ts.map +1 -1
  290. package/dist/word/semantic/design/ground.js +5 -47
  291. package/dist/word/semantic/design/ground.js.map +1 -1
  292. package/dist/word/xml.d.ts +1 -4
  293. package/dist/word/xml.d.ts.map +1 -1
  294. package/dist/word/xml.js +1 -13
  295. package/dist/word/xml.js.map +1 -1
  296. package/package.json +5 -1
@@ -0,0 +1,20 @@
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 { resolveCoverTextBoxes, keptCoverTextBoxes, COVER_GRID_EDGES, COVER_BESIDE_EDGES } from './coverTextBoxes.js';
14
+ export { coverElementRect, placeCoverElement, outlinePathData } from './coverDesign.js';
15
+ export { basicShape, roundedRectPath, pathData, coverPathCommands, flattenCoverPath, coverPathBounds, BASIC_SHAPES } from './shapes.js';
16
+ export { COVER_FINISH_INKS } from './coverArt.js';
17
+ export { workIsbnCaption } from './coverLabels.js';
18
+ export { folioOfBook, folioVersionOf, productionFolioBinding } from './folio.js';
19
+ export { DEFAULT_BINDING_MEASURES, BUILT_IN_BINDING_PROFILES, DEFAULT_SPINE_TEXT } from '../defaults/output/production.js';
20
+ //# 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,qBAAqB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEtH,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,"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nE,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,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;QAAE,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measures.js","sourceRoot":"","sources":["../../src/production/measures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wB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,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5D,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1C,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;yBAGyB;AACzB,MAAM,CAAC,MAAM,sBAAsB,GAAqD;IACtF,OAAO,EAAE,WAAW;IACpB,aAAa,EAAE,MAAM;IACrB,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,WAAW;CACvB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Mirror bleed: the design is drawn only a margin past the trim, and the
3
+ * rest of the bleed (a case's turn-in, the board edge) is the design's
4
+ * edge reflected outward. Along each side, the strip the margin leaves
5
+ * between the trim and the end of the design is folded out again and
6
+ * again, as a strip of paper: reflected, then copied, then reflected…, as
7
+ * far as the sheet goes. In a corner both sides fold, which turns the
8
+ * corner half a turn (the mirror of the mirror) instead of meeting in a
9
+ * cross. Only the perimeter is filled: inner folds (the spine, the flaps)
10
+ * keep the design itself.
11
+ */
12
+ import type { SheetRect } from './geometry.js';
13
+ /** One band of an axis, `from` to `to` mm, and the map that fills it from
14
+ * the design: `x' = scale · x + shift`. */
15
+ export interface MirrorBand {
16
+ from: number;
17
+ to: number;
18
+ scale: 1 | -1;
19
+ shift: number;
20
+ }
21
+ /** The most bands a side folds into: at the narrowest margin, 32 mm of
22
+ * bleed or turn-in, past any a binding asks for. */
23
+ export declare const MAX_MIRROR_BANDS = 16;
24
+ /** The narrowest design margin, mm: a narrower one would fold the edge
25
+ * into slivers no press registers. */
26
+ export declare const MIN_MIRROR_MARGIN = 2;
27
+ /** An axis cut into bands: the design's own, from `start − margin` to
28
+ * `end + margin` (the trim's edges and the margin past them, within the
29
+ * sheet), and the folded bands before and after it out to 0 and
30
+ * `sheetEnd`. */
31
+ export declare function mirrorBands(start: number, end: number, sheetEnd: number, margin: number): {
32
+ designed: [number, number];
33
+ before: MirrorBand[];
34
+ after: MirrorBand[];
35
+ capped: boolean;
36
+ };
37
+ /**
38
+ * The mirror bleed of a sheet `width` × `height` mm whose trim is `trim`:
39
+ * an SVG in mm that paints `content` (SVG of the sheet's background and
40
+ * movable elements, in sheet mm) folded into every band past the design
41
+ * margin, each band clipped to itself. Undefined when the design margin
42
+ * reaches the sheet's edge on every side (nothing to fill). `defs` are
43
+ * the clip paths `content` uses.
44
+ */
45
+ export declare function mirrorBleedSvg(sheet: {
46
+ width: number;
47
+ height: number;
48
+ trim: SheetRect;
49
+ }, margin: number, content: string, defs?: string): {
50
+ svg: string;
51
+ designed: SheetRect;
52
+ capped: boolean;
53
+ } | undefined;
54
+ //# sourceMappingURL=mirrorBleed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirrorBleed.d.ts","sourceRoot":"","sources":["../../src/production/mirrorBleed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;4CAC4C;AAC5C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;qDACqD;AACrD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;uCACuC;AACvC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;kBAGkB;AAClB,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CA0BpL;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,EACzD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,SAAK,GACR;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CA6BnE"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Mirror bleed: the design is drawn only a margin past the trim, and the
3
+ * rest of the bleed (a case's turn-in, the board edge) is the design's
4
+ * edge reflected outward. Along each side, the strip the margin leaves
5
+ * between the trim and the end of the design is folded out again and
6
+ * again, as a strip of paper: reflected, then copied, then reflected…, as
7
+ * far as the sheet goes. In a corner both sides fold, which turns the
8
+ * corner half a turn (the mirror of the mirror) instead of meeting in a
9
+ * cross. Only the perimeter is filled: inner folds (the spine, the flaps)
10
+ * keep the design itself.
11
+ */
12
+ /** How far each band's clip reaches past its edges, mm. */
13
+ const SEAM = 0.1;
14
+ /** The most bands a side folds into: at the narrowest margin, 32 mm of
15
+ * bleed or turn-in, past any a binding asks for. */
16
+ export const MAX_MIRROR_BANDS = 16;
17
+ /** The narrowest design margin, mm: a narrower one would fold the edge
18
+ * into slivers no press registers. */
19
+ export const MIN_MIRROR_MARGIN = 2;
20
+ /** An axis cut into bands: the design's own, from `start − margin` to
21
+ * `end + margin` (the trim's edges and the margin past them, within the
22
+ * sheet), and the folded bands before and after it out to 0 and
23
+ * `sheetEnd`. */
24
+ export function mirrorBands(start, end, sheetEnd, margin) {
25
+ const d = Math.max(MIN_MIRROR_MARGIN, Number.isFinite(margin) ? margin : MIN_MIRROR_MARGIN);
26
+ const a = Math.max(0, start - d);
27
+ const b = Math.min(sheetEnd, end + d);
28
+ const before = [];
29
+ for (let i = 1; i <= MAX_MIRROR_BANDS && a - (i - 1) * d > 1e-6; i++) {
30
+ const to = a - (i - 1) * d;
31
+ before.push({
32
+ from: Math.max(0, a - i * d),
33
+ to,
34
+ // An odd band reflects the strip about its own edge: x' = 2a − (i − 1)d − x.
35
+ ...(i % 2 === 1 ? { scale: -1, shift: 2 * a - (i - 1) * d } : { scale: 1, shift: -i * d }),
36
+ });
37
+ }
38
+ const after = [];
39
+ for (let i = 1; i <= MAX_MIRROR_BANDS && b + (i - 1) * d < sheetEnd - 1e-6; i++) {
40
+ const from = b + (i - 1) * d;
41
+ after.push({
42
+ from,
43
+ to: Math.min(sheetEnd, b + i * d),
44
+ ...(i % 2 === 1 ? { scale: -1, shift: 2 * b + (i - 1) * d } : { scale: 1, shift: i * d }),
45
+ });
46
+ }
47
+ // Bands left over when the cap was reached: the sheet's edge unfilled.
48
+ const capped = (before.length > 0 && before[before.length - 1].from > 1e-6) || (after.length > 0 && after[after.length - 1].to < sheetEnd - 1e-6);
49
+ return { designed: [a, b], before, after, capped };
50
+ }
51
+ const n = (v) => String(Math.round(v * 1000) / 1000);
52
+ /**
53
+ * The mirror bleed of a sheet `width` × `height` mm whose trim is `trim`:
54
+ * an SVG in mm that paints `content` (SVG of the sheet's background and
55
+ * movable elements, in sheet mm) folded into every band past the design
56
+ * margin, each band clipped to itself. Undefined when the design margin
57
+ * reaches the sheet's edge on every side (nothing to fill). `defs` are
58
+ * the clip paths `content` uses.
59
+ */
60
+ export function mirrorBleedSvg(sheet, margin, content, defs = '') {
61
+ const t = sheet.trim;
62
+ const xs = mirrorBands(t.x, t.x + t.width, sheet.width, margin);
63
+ const ys = mirrorBands(t.y, t.y + t.height, sheet.height, margin);
64
+ if (xs.before.length + xs.after.length + ys.before.length + ys.after.length === 0)
65
+ return undefined;
66
+ const centreX = { from: xs.designed[0], to: xs.designed[1], scale: 1, shift: 0 };
67
+ const centreY = { from: ys.designed[0], to: ys.designed[1], scale: 1, shift: 0 };
68
+ const clips = [];
69
+ const uses = [];
70
+ for (const bx of [...xs.before, centreX, ...xs.after]) {
71
+ for (const by of [...ys.before, centreY, ...ys.after]) {
72
+ if (bx === centreX && by === centreY)
73
+ continue;
74
+ const id = `mb${clips.length}`;
75
+ // Each band a tenth of a millimetre wider all round: next to a seam
76
+ // both bands show the same point of the design, and the overlap
77
+ // keeps a hairline from opening between them.
78
+ clips.push(`<clipPath id="${id}" clipPathUnits="userSpaceOnUse"><rect x="${n(bx.from - SEAM)}" y="${n(by.from - SEAM)}" width="${n(bx.to - bx.from + 2 * SEAM)}" height="${n(by.to - by.from + 2 * SEAM)}"/></clipPath>`);
79
+ uses.push(`<g clip-path="url(#${id})"><g transform="matrix(${bx.scale} 0 0 ${by.scale} ${n(bx.shift)} ${n(by.shift)})"><use href="#mirror-content"/></g></g>`);
80
+ }
81
+ }
82
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${n(sheet.width)}mm" height="${n(sheet.height)}mm" viewBox="0 0 ${n(sheet.width)} ${n(sheet.height)}">`
83
+ + `<defs>${defs}${clips.join('')}<g id="mirror-content">${content}</g></defs>`
84
+ + uses.join('')
85
+ + '</svg>';
86
+ return {
87
+ svg,
88
+ capped: xs.capped || ys.capped,
89
+ designed: { x: xs.designed[0], y: ys.designed[0], width: xs.designed[1] - xs.designed[0], height: ys.designed[1] - ys.designed[0] },
90
+ };
91
+ }
92
+ //# sourceMappingURL=mirrorBleed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirrorBleed.js","sourceRoot":"","sources":["../../src/production/mirrorBleed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaH,2DAA2D;AAC3D,MAAM,IAA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CAAC,IAAI;UAC/J,SAAS,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,0BAA0B,OAAO,aAAa;UAC5E,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;UACb,QAAQ,CAAC;IACb,OAAO;QACL,GAAG;QACH,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM;QAC9B,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;KACpI,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A cover's shapes and the basic effects of its boxes and shapes.
3
+ *
4
+ * A shape is a path of nodes, each with the handles of the curves that
5
+ * meet at it (none: a corner), in fractions of the element's box, so it
6
+ * stretches with the box. The basic shapes (a rectangle, an ellipse, a
7
+ * polygon, a star, a line) are such paths, every node of which can then be
8
+ * moved, curved or straightened.
9
+ *
10
+ * The effects: rounded corners (a box's), a border, a gradient from the
11
+ * element's colour to another, and a soft shadow. The outputs draw flat
12
+ * paths only, so a gradient and a shadow become a picture of their own:
13
+ * an SVG in which the gradient is a small raster cut to the shape and the
14
+ * shadow a raster of the shape blurred, as every output already draws.
15
+ */
16
+ import type { ColorValue } from '../types/page.js';
17
+ import type { CoverEffects, CoverPath, CoverPoint, SheetRect } from '../types/output/cover.js';
18
+ import type { VDTPathCommand } from '../vdt.js';
19
+ export type { CoverEffects, CoverPath, CoverPathNode, CoverPoint } from '../types/output/cover.js';
20
+ export type BasicShape = 'rectangle' | 'ellipse' | 'polygon' | 'star' | 'line';
21
+ export declare const BASIC_SHAPES: readonly BasicShape[];
22
+ /** A basic shape filling its box: a polygon of `sides` sides (default 6),
23
+ * a star of `sides` points (default 5). */
24
+ export declare function basicShape(kind: BasicShape, sides?: number): CoverPath;
25
+ /** A rectangle `w` × `h` (mm) with corners rounded to `radius` mm, as a
26
+ * path in fractions of it. */
27
+ export declare function roundedRectPath(w: number, h: number, radius: number): CoverPath;
28
+ /** A path as SVG path data, its points through `map` (by default as they
29
+ * are, in fractions). */
30
+ export declare function pathData(path: CoverPath, map?: (p: CoverPoint) => CoverPoint): string;
31
+ /** A path as page commands, its points through `map` (by default as they
32
+ * are, in fractions): what the die-cut geometry flattens and bounds. */
33
+ export declare function coverPathCommands(path: CoverPath, map?: (p: CoverPoint) => CoverPoint): VDTPathCommand[][];
34
+ /** A path's curves as straight steps (`steps` per curve): polygons in the
35
+ * same units, for an outline a finish follows or a shadow is cast by. */
36
+ export declare function flattenCoverPath(path: CoverPath, steps?: number): CoverPoint[][];
37
+ /** The box a path's curves span, in its own units. */
38
+ export declare function coverPathBounds(path: CoverPath): {
39
+ x: number;
40
+ y: number;
41
+ width: number;
42
+ height: number;
43
+ } | undefined;
44
+ /** Whether an element's effects need a picture of their own (a gradient,
45
+ * a shadow), which flat paths cannot draw. */
46
+ export declare const needsArt: (fx: CoverEffects) => boolean;
47
+ /**
48
+ * A box or a shape with its effects as one SVG, in sheet mm: its shadow,
49
+ * its fill (flat, or a gradient cut to the shape) and its border. `rect` is
50
+ * its box; `path` its shape (a box's: a rectangle, rounded or not).
51
+ * Returns the content (for a sheet-sized SVG, as the mirror's) and the
52
+ * box it covers, shadow and border included.
53
+ */
54
+ export declare function shapeArt(rect: SheetRect, path: CoverPath, fill: ColorValue | undefined, fx: CoverEffects, opacity?: number, idPrefix?: string): {
55
+ content: string;
56
+ defs: string;
57
+ bounds: SheetRect;
58
+ };
59
+ /** {@link shapeArt} as a standalone SVG the size of its bounds. */
60
+ export declare function shapeArtSvg(art: {
61
+ content: string;
62
+ defs: string;
63
+ bounds: SheetRect;
64
+ }): string;
65
+ //# sourceMappingURL=shapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/production/shapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAiB,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC9G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMhD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEnG,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAC/E,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAwD,CAAC;AAEvG;4CAC4C;AAC5C,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAyBtE;AAED;+BAC+B;AAC/B,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAoB/E;AAGD;0BAC0B;AAC1B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,GAAE,CAAC,CAAC,EAAE,UAAU,KAAK,UAAqB,GAAG,MAAM,CAkB/F;AAED;yEACyE;AACzE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,GAAE,CAAC,CAAC,EAAE,UAAU,KAAK,UAAqB,GAAG,cAAc,EAAE,EAAE,CA0BpH;AAED;0EAC0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,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