postext-idml 0.0.0-stage → 0.1.1

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 (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -2
  3. package/dist/export/colours.d.ts +14 -0
  4. package/dist/export/colours.d.ts.map +1 -0
  5. package/dist/export/colours.js +53 -0
  6. package/dist/export/colours.js.map +1 -0
  7. package/dist/export/document.d.ts +19 -0
  8. package/dist/export/document.d.ts.map +1 -0
  9. package/dist/export/document.js +110 -0
  10. package/dist/export/document.js.map +1 -0
  11. package/dist/export/fields.d.ts +19 -0
  12. package/dist/export/fields.d.ts.map +1 -0
  13. package/dist/export/fields.js +76 -0
  14. package/dist/export/fields.js.map +1 -0
  15. package/dist/export/fonts.d.ts +21 -0
  16. package/dist/export/fonts.d.ts.map +1 -0
  17. package/dist/export/fonts.js +56 -0
  18. package/dist/export/fonts.js.map +1 -0
  19. package/dist/export/geometry.d.ts +25 -0
  20. package/dist/export/geometry.d.ts.map +1 -0
  21. package/dist/export/geometry.js +37 -0
  22. package/dist/export/geometry.js.map +1 -0
  23. package/dist/export/idml.test.d.ts +2 -0
  24. package/dist/export/idml.test.d.ts.map +1 -0
  25. package/dist/export/idml.test.js +521 -0
  26. package/dist/export/idml.test.js.map +1 -0
  27. package/dist/export/images.d.ts +6 -0
  28. package/dist/export/images.d.ts.map +1 -0
  29. package/dist/export/images.js +75 -0
  30. package/dist/export/images.js.map +1 -0
  31. package/dist/export/index.d.ts +5 -0
  32. package/dist/export/index.d.ts.map +1 -0
  33. package/dist/export/index.js +145 -0
  34. package/dist/export/index.js.map +1 -0
  35. package/dist/export/inline.d.ts +6 -0
  36. package/dist/export/inline.d.ts.map +1 -0
  37. package/dist/export/inline.js +68 -0
  38. package/dist/export/inline.js.map +1 -0
  39. package/dist/export/keptLines.d.ts +31 -0
  40. package/dist/export/keptLines.d.ts.map +1 -0
  41. package/dist/export/keptLines.js +141 -0
  42. package/dist/export/keptLines.js.map +1 -0
  43. package/dist/export/keptLines.test.d.ts +2 -0
  44. package/dist/export/keptLines.test.d.ts.map +1 -0
  45. package/dist/export/keptLines.test.js +151 -0
  46. package/dist/export/keptLines.test.js.map +1 -0
  47. package/dist/export/paragraphs.d.ts +52 -0
  48. package/dist/export/paragraphs.d.ts.map +1 -0
  49. package/dist/export/paragraphs.js +294 -0
  50. package/dist/export/paragraphs.js.map +1 -0
  51. package/dist/export/parts.d.ts +114 -0
  52. package/dist/export/parts.d.ts.map +1 -0
  53. package/dist/export/parts.js +143 -0
  54. package/dist/export/parts.js.map +1 -0
  55. package/dist/export/sfnt.d.ts +19 -0
  56. package/dist/export/sfnt.d.ts.map +1 -0
  57. package/dist/export/sfnt.js +109 -0
  58. package/dist/export/sfnt.js.map +1 -0
  59. package/dist/export/sfnt.test.d.ts +2 -0
  60. package/dist/export/sfnt.test.d.ts.map +1 -0
  61. package/dist/export/sfnt.test.js +58 -0
  62. package/dist/export/sfnt.test.js.map +1 -0
  63. package/dist/export/shapes.d.ts +21 -0
  64. package/dist/export/shapes.d.ts.map +1 -0
  65. package/dist/export/shapes.js +146 -0
  66. package/dist/export/shapes.js.map +1 -0
  67. package/dist/export/spreads.d.ts +25 -0
  68. package/dist/export/spreads.d.ts.map +1 -0
  69. package/dist/export/spreads.js +193 -0
  70. package/dist/export/spreads.js.map +1 -0
  71. package/dist/export/story.d.ts +38 -0
  72. package/dist/export/story.d.ts.map +1 -0
  73. package/dist/export/story.js +271 -0
  74. package/dist/export/story.js.map +1 -0
  75. package/dist/export/tables.d.ts +10 -0
  76. package/dist/export/tables.d.ts.map +1 -0
  77. package/dist/export/tables.js +95 -0
  78. package/dist/export/tables.js.map +1 -0
  79. package/dist/export/writer.d.ts +141 -0
  80. package/dist/export/writer.d.ts.map +1 -0
  81. package/dist/export/writer.js +10 -0
  82. package/dist/export/writer.js.map +1 -0
  83. package/dist/import/blocks.d.ts +33 -0
  84. package/dist/import/blocks.d.ts.map +1 -0
  85. package/dist/import/blocks.js +210 -0
  86. package/dist/import/blocks.js.map +1 -0
  87. package/dist/import/context.d.ts +83 -0
  88. package/dist/import/context.d.ts.map +1 -0
  89. package/dist/import/context.js +147 -0
  90. package/dist/import/context.js.map +1 -0
  91. package/dist/import/decide.d.ts +9 -0
  92. package/dist/import/decide.d.ts.map +1 -0
  93. package/dist/import/decide.js +61 -0
  94. package/dist/import/decide.js.map +1 -0
  95. package/dist/import/design.d.ts +33 -0
  96. package/dist/import/design.d.ts.map +1 -0
  97. package/dist/import/design.js +220 -0
  98. package/dist/import/design.js.map +1 -0
  99. package/dist/import/escape.d.ts +33 -0
  100. package/dist/import/escape.d.ts.map +1 -0
  101. package/dist/import/escape.js +106 -0
  102. package/dist/import/escape.js.map +1 -0
  103. package/dist/import/flow.d.ts +22 -0
  104. package/dist/import/flow.d.ts.map +1 -0
  105. package/dist/import/flow.js +329 -0
  106. package/dist/import/flow.js.map +1 -0
  107. package/dist/import/hooks.d.ts +6 -0
  108. package/dist/import/hooks.d.ts.map +1 -0
  109. package/dist/import/hooks.js +101 -0
  110. package/dist/import/hooks.js.map +1 -0
  111. package/dist/import/index.d.ts +24 -0
  112. package/dist/import/index.d.ts.map +1 -0
  113. package/dist/import/index.js +210 -0
  114. package/dist/import/index.js.map +1 -0
  115. package/dist/import/inline.d.ts +62 -0
  116. package/dist/import/inline.d.ts.map +1 -0
  117. package/dist/import/inline.js +395 -0
  118. package/dist/import/inline.js.map +1 -0
  119. package/dist/import/looks.d.ts +57 -0
  120. package/dist/import/looks.d.ts.map +1 -0
  121. package/dist/import/looks.js +259 -0
  122. package/dist/import/looks.js.map +1 -0
  123. package/dist/import/marks.d.ts +33 -0
  124. package/dist/import/marks.d.ts.map +1 -0
  125. package/dist/import/marks.js +190 -0
  126. package/dist/import/marks.js.map +1 -0
  127. package/dist/import/nested.d.ts +7 -0
  128. package/dist/import/nested.d.ts.map +1 -0
  129. package/dist/import/nested.js +122 -0
  130. package/dist/import/nested.js.map +1 -0
  131. package/dist/import/objects.d.ts +27 -0
  132. package/dist/import/objects.d.ts.map +1 -0
  133. package/dist/import/objects.js +84 -0
  134. package/dist/import/objects.js.map +1 -0
  135. package/dist/import/pages.d.ts +12 -0
  136. package/dist/import/pages.d.ts.map +1 -0
  137. package/dist/import/pages.js +294 -0
  138. package/dist/import/pages.js.map +1 -0
  139. package/dist/import/pagesetup.d.ts +24 -0
  140. package/dist/import/pagesetup.d.ts.map +1 -0
  141. package/dist/import/pagesetup.js +138 -0
  142. package/dist/import/pagesetup.js.map +1 -0
  143. package/dist/import/pictures.d.ts +25 -0
  144. package/dist/import/pictures.d.ts.map +1 -0
  145. package/dist/import/pictures.js +167 -0
  146. package/dist/import/pictures.js.map +1 -0
  147. package/dist/import/report.d.ts +12 -0
  148. package/dist/import/report.d.ts.map +1 -0
  149. package/dist/import/report.js +39 -0
  150. package/dist/import/report.js.map +1 -0
  151. package/dist/import/scan.d.ts +26 -0
  152. package/dist/import/scan.d.ts.map +1 -0
  153. package/dist/import/scan.js +147 -0
  154. package/dist/import/scan.js.map +1 -0
  155. package/dist/import/styleconfig.d.ts +6 -0
  156. package/dist/import/styleconfig.d.ts.map +1 -0
  157. package/dist/import/styleconfig.js +269 -0
  158. package/dist/import/styleconfig.js.map +1 -0
  159. package/dist/import/tables.d.ts +8 -0
  160. package/dist/import/tables.d.ts.map +1 -0
  161. package/dist/import/tables.js +210 -0
  162. package/dist/import/tables.js.map +1 -0
  163. package/dist/import/tests/hostile.test.d.ts +2 -0
  164. package/dist/import/tests/hostile.test.d.ts.map +1 -0
  165. package/dist/import/tests/hostile.test.js +106 -0
  166. package/dist/import/tests/hostile.test.js.map +1 -0
  167. package/dist/import/tests/kit.test-helper.d.ts +32 -0
  168. package/dist/import/tests/kit.test-helper.d.ts.map +1 -0
  169. package/dist/import/tests/kit.test-helper.js +41 -0
  170. package/dist/import/tests/kit.test-helper.js.map +1 -0
  171. package/dist/import/tests/reference.test.d.ts +2 -0
  172. package/dist/import/tests/reference.test.d.ts.map +1 -0
  173. package/dist/import/tests/reference.test.js +184 -0
  174. package/dist/import/tests/reference.test.js.map +1 -0
  175. package/dist/import/tests/safety.test.d.ts +2 -0
  176. package/dist/import/tests/safety.test.d.ts.map +1 -0
  177. package/dist/import/tests/safety.test.js +82 -0
  178. package/dist/import/tests/safety.test.js.map +1 -0
  179. package/dist/import/tests/text.test.d.ts +2 -0
  180. package/dist/import/tests/text.test.d.ts.map +1 -0
  181. package/dist/import/tests/text.test.js +160 -0
  182. package/dist/import/tests/text.test.js.map +1 -0
  183. package/dist/import/types.d.ts +114 -0
  184. package/dist/import/types.d.ts.map +1 -0
  185. package/dist/import/types.js +3 -0
  186. package/dist/import/types.js.map +1 -0
  187. package/dist/import/values.d.ts +31 -0
  188. package/dist/import/values.d.ts.map +1 -0
  189. package/dist/import/values.js +108 -0
  190. package/dist/import/values.js.map +1 -0
  191. package/dist/index.d.ts +6 -0
  192. package/dist/index.d.ts.map +1 -0
  193. package/dist/index.js +7 -0
  194. package/dist/index.js.map +1 -0
  195. package/dist/model/document.d.ts +522 -0
  196. package/dist/model/document.d.ts.map +1 -0
  197. package/dist/model/document.js +4 -0
  198. package/dist/model/document.js.map +1 -0
  199. package/dist/model/geometry.d.ts +58 -0
  200. package/dist/model/geometry.d.ts.map +1 -0
  201. package/dist/model/geometry.js +92 -0
  202. package/dist/model/geometry.js.map +1 -0
  203. package/dist/package/errors.d.ts +8 -0
  204. package/dist/package/errors.d.ts.map +1 -0
  205. package/dist/package/errors.js +15 -0
  206. package/dist/package/errors.js.map +1 -0
  207. package/dist/package/open.d.ts +22 -0
  208. package/dist/package/open.d.ts.map +1 -0
  209. package/dist/package/open.js +114 -0
  210. package/dist/package/open.js.map +1 -0
  211. package/dist/read/designmap.d.ts +13 -0
  212. package/dist/read/designmap.d.ts.map +1 -0
  213. package/dist/read/designmap.js +246 -0
  214. package/dist/read/designmap.js.map +1 -0
  215. package/dist/read/fixture.test-helper.d.ts +33 -0
  216. package/dist/read/fixture.test-helper.d.ts.map +1 -0
  217. package/dist/read/fixture.test-helper.js +81 -0
  218. package/dist/read/fixture.test-helper.js.map +1 -0
  219. package/dist/read/hostile.test.d.ts +2 -0
  220. package/dist/read/hostile.test.d.ts.map +1 -0
  221. package/dist/read/hostile.test.js +333 -0
  222. package/dist/read/hostile.test.js.map +1 -0
  223. package/dist/read/index.d.ts +21 -0
  224. package/dist/read/index.d.ts.map +1 -0
  225. package/dist/read/index.js +214 -0
  226. package/dist/read/index.js.map +1 -0
  227. package/dist/read/items.d.ts +8 -0
  228. package/dist/read/items.d.ts.map +1 -0
  229. package/dist/read/items.js +215 -0
  230. package/dist/read/items.js.map +1 -0
  231. package/dist/read/languages.d.ts +5 -0
  232. package/dist/read/languages.d.ts.map +1 -0
  233. package/dist/read/languages.js +39 -0
  234. package/dist/read/languages.js.map +1 -0
  235. package/dist/read/preferences.d.ts +9 -0
  236. package/dist/read/preferences.d.ts.map +1 -0
  237. package/dist/read/preferences.js +74 -0
  238. package/dist/read/preferences.js.map +1 -0
  239. package/dist/read/props.d.ts +31 -0
  240. package/dist/read/props.d.ts.map +1 -0
  241. package/dist/read/props.js +94 -0
  242. package/dist/read/props.js.map +1 -0
  243. package/dist/read/reference.test.d.ts +2 -0
  244. package/dist/read/reference.test.d.ts.map +1 -0
  245. package/dist/read/reference.test.js +428 -0
  246. package/dist/read/reference.test.js.map +1 -0
  247. package/dist/read/resources.d.ts +9 -0
  248. package/dist/read/resources.d.ts.map +1 -0
  249. package/dist/read/resources.js +129 -0
  250. package/dist/read/resources.js.map +1 -0
  251. package/dist/read/spreads.d.ts +12 -0
  252. package/dist/read/spreads.d.ts.map +1 -0
  253. package/dist/read/spreads.js +94 -0
  254. package/dist/read/spreads.js.map +1 -0
  255. package/dist/read/story.d.ts +22 -0
  256. package/dist/read/story.d.ts.map +1 -0
  257. package/dist/read/story.js +325 -0
  258. package/dist/read/story.js.map +1 -0
  259. package/dist/read/story.test.d.ts +2 -0
  260. package/dist/read/story.test.d.ts.map +1 -0
  261. package/dist/read/story.test.js +99 -0
  262. package/dist/read/story.test.js.map +1 -0
  263. package/dist/read/styles.d.ts +6 -0
  264. package/dist/read/styles.d.ts.map +1 -0
  265. package/dist/read/styles.js +122 -0
  266. package/dist/read/styles.js.map +1 -0
  267. package/dist/read/tables.d.ts +10 -0
  268. package/dist/read/tables.d.ts.map +1 -0
  269. package/dist/read/tables.js +88 -0
  270. package/dist/read/tables.js.map +1 -0
  271. package/dist/resolve/colour.d.ts +39 -0
  272. package/dist/resolve/colour.d.ts.map +1 -0
  273. package/dist/resolve/colour.js +135 -0
  274. package/dist/resolve/colour.js.map +1 -0
  275. package/dist/resolve/format.d.ts +140 -0
  276. package/dist/resolve/format.d.ts.map +1 -0
  277. package/dist/resolve/format.js +232 -0
  278. package/dist/resolve/format.js.map +1 -0
  279. package/dist/resolve/geometry.d.ts +102 -0
  280. package/dist/resolve/geometry.d.ts.map +1 -0
  281. package/dist/resolve/geometry.js +192 -0
  282. package/dist/resolve/geometry.js.map +1 -0
  283. package/dist/resolve/index.d.ts +14 -0
  284. package/dist/resolve/index.d.ts.map +1 -0
  285. package/dist/resolve/index.js +10 -0
  286. package/dist/resolve/index.js.map +1 -0
  287. package/dist/resolve/inspect.d.ts +109 -0
  288. package/dist/resolve/inspect.d.ts.map +1 -0
  289. package/dist/resolve/inspect.js +319 -0
  290. package/dist/resolve/inspect.js.map +1 -0
  291. package/dist/resolve/masters.d.ts +23 -0
  292. package/dist/resolve/masters.d.ts.map +1 -0
  293. package/dist/resolve/masters.js +99 -0
  294. package/dist/resolve/masters.js.map +1 -0
  295. package/dist/resolve/order.d.ts +65 -0
  296. package/dist/resolve/order.d.ts.map +1 -0
  297. package/dist/resolve/order.js +292 -0
  298. package/dist/resolve/order.js.map +1 -0
  299. package/dist/resolve/reference.test.d.ts +2 -0
  300. package/dist/resolve/reference.test.d.ts.map +1 -0
  301. package/dist/resolve/reference.test.js +342 -0
  302. package/dist/resolve/reference.test.js.map +1 -0
  303. package/dist/resolve/styles.d.ts +26 -0
  304. package/dist/resolve/styles.d.ts.map +1 -0
  305. package/dist/resolve/styles.js +124 -0
  306. package/dist/resolve/styles.js.map +1 -0
  307. package/dist/roundtrip.test.d.ts +2 -0
  308. package/dist/roundtrip.test.d.ts.map +1 -0
  309. package/dist/roundtrip.test.js +89 -0
  310. package/dist/roundtrip.test.js.map +1 -0
  311. package/dist/testing/kit.test-helper.d.ts +9 -0
  312. package/dist/testing/kit.test-helper.d.ts.map +1 -0
  313. package/dist/testing/kit.test-helper.js +32 -0
  314. package/dist/testing/kit.test-helper.js.map +1 -0
  315. package/dist/xml/read.d.ts +48 -0
  316. package/dist/xml/read.d.ts.map +1 -0
  317. package/dist/xml/read.js +212 -0
  318. package/dist/xml/read.js.map +1 -0
  319. package/dist/xml/write.d.ts +9 -0
  320. package/dist/xml/write.d.ts.map +1 -0
  321. package/dist/xml/write.js +24 -0
  322. package/dist/xml/write.js.map +1 -0
  323. package/package.json +65 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/read/preferences.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,+DAA+D;AAE/D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAmB,MAAM,gBAAgB,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,EAA0B;IAClD,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;QAC9B,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC;QAC1B,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC;QAC5B,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EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3L,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM;YAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;QAChD,GAAG,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACrD,GAAG,CAAC,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,eAAe,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3F,CAAC;IACD,IAAI,CAAC,EAAE,CAAC;QACN,GAAG,CAAC,YAAY,GAAG;YACjB,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,IAAI,EAAE;YAC1C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,0BAA0B,IAAI,GAAG,CAAC,YAAY,CAAC,UAAU;YAC7E,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,mBAAmB,CAAC,IAAI,KAAK;SAC7C,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,gBAAgB;QAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC5E,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type XmlElement } from '../xml/read.js';
2
+ import type { Props } from '../model/document.js';
3
+ import type { Path } from '../model/geometry.js';
4
+ export declare function propsOf(el: XmlElement): Props;
5
+ /** `<PathGeometry>` of an element's properties (or of `holder` itself). */
6
+ export declare function pathsOf(holder: XmlElement | undefined): Path[];
7
+ /** A property written as `<Name type="list"><ListItem>…</ListItem></Name>`,
8
+ * as numbers. */
9
+ export declare function listNumbers(prop: XmlElement | undefined): number[] | undefined;
10
+ /** A property's text (`<AppliedFont type="string">Minion Pro</AppliedFont>`). */
11
+ export declare const propText: (p: Props, name: string) => string | undefined;
12
+ /** A property's number (`<Leading type="unit">14</Leading>`); undefined
13
+ * for an enumeration (`Auto`). */
14
+ export declare function propNumber(p: Props, name: string): number | undefined;
15
+ /** Four edges written as attributes of a child (`Top`, `Left`, `Bottom`,
16
+ * `Right`), in that order. */
17
+ export declare function edges(el: XmlElement | undefined): [number, number, number, number];
18
+ /** Elements under `el`, depth first, that `match`; does not descend into
19
+ * those it yields. */
20
+ export declare function findAll(el: XmlElement, match: (e: XmlElement) => boolean, out?: XmlElement[]): XmlElement[];
21
+ /** A reference attribute: `n` and the empty string mean none. */
22
+ export declare const refOf: (v: string | undefined) => string | undefined;
23
+ /** A name without the `$ID/` mark InDesign puts before its own strings
24
+ * (`$ID/[No paragraph style]`, and `$ID/` alone for an empty one). */
25
+ export declare const plainName: (v: string | undefined) => string;
26
+ /** The items of a list property, each a record of named children
27
+ * (`<ListItem type="record"><Position type="unit">120</Position>…`). */
28
+ export declare function listRecords(prop: XmlElement | undefined): Record<string, XmlElement>[];
29
+ /** The items of a list property as text (`<ListItem type="object">…`). */
30
+ export declare function listTexts(prop: XmlElement | undefined): string[];
31
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/read/props.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsD,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,sBAAsB,CAAC;AAExD,wBAAgB,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,KAAK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+ import { child, children, isElement, localName, num, textOf } from '../xml/read.js';
4
+ export function propsOf(el) {
5
+ const properties = {};
6
+ for (const p of children(child(el, 'Properties')))
7
+ properties[localName(p.name)] = p;
8
+ return { attrs: el.attrs, properties };
9
+ }
10
+ const point = (s) => {
11
+ if (!s)
12
+ return undefined;
13
+ const [x, y] = s.trim().split(/\s+/).map(Number);
14
+ return Number.isFinite(x) && Number.isFinite(y) ? { x: x, y: y } : undefined;
15
+ };
16
+ /** `<PathGeometry>` of an element's properties (or of `holder` itself). */
17
+ export function pathsOf(holder) {
18
+ const geometry = holder && localName(holder.name) === 'PathGeometry' ? holder : child(child(holder, 'Properties'), 'PathGeometry');
19
+ const out = [];
20
+ for (const g of children(geometry, 'GeometryPathType')) {
21
+ const points = [];
22
+ for (const p of children(child(g, 'PathPointArray'), 'PathPointType')) {
23
+ const anchor = point(p.attrs.Anchor);
24
+ if (!anchor)
25
+ continue;
26
+ points.push({ anchor, left: point(p.attrs.LeftDirection) ?? anchor, right: point(p.attrs.RightDirection) ?? anchor });
27
+ }
28
+ if (points.length)
29
+ out.push({ open: g.attrs.PathOpen === 'true', points });
30
+ }
31
+ return out;
32
+ }
33
+ /** A property written as `<Name type="list"><ListItem>…</ListItem></Name>`,
34
+ * as numbers. */
35
+ export function listNumbers(prop) {
36
+ if (!prop)
37
+ return undefined;
38
+ const out = children(prop, 'ListItem').map((i) => Number(textOf(i)));
39
+ return out.length && out.every(Number.isFinite) ? out : undefined;
40
+ }
41
+ /** A property's text (`<AppliedFont type="string">Minion Pro</AppliedFont>`). */
42
+ export const propText = (p, name) => {
43
+ const el = p.properties[name];
44
+ return el ? textOf(el) : undefined;
45
+ };
46
+ /** A property's number (`<Leading type="unit">14</Leading>`); undefined
47
+ * for an enumeration (`Auto`). */
48
+ export function propNumber(p, name) {
49
+ const el = p.properties[name];
50
+ if (!el || el.attrs.type === 'enumeration')
51
+ return undefined;
52
+ const n = Number(textOf(el));
53
+ return Number.isFinite(n) ? n : undefined;
54
+ }
55
+ /** Four edges written as attributes of a child (`Top`, `Left`, `Bottom`,
56
+ * `Right`), in that order. */
57
+ export function edges(el) {
58
+ return [num(el, 'Top') ?? 0, num(el, 'Left') ?? 0, num(el, 'Bottom') ?? 0, num(el, 'Right') ?? 0];
59
+ }
60
+ /** Elements under `el`, depth first, that `match`; does not descend into
61
+ * those it yields. */
62
+ export function findAll(el, match, out = []) {
63
+ for (const c of el.children) {
64
+ if (!isElement(c))
65
+ continue;
66
+ if (match(c))
67
+ out.push(c);
68
+ else
69
+ findAll(c, match, out);
70
+ }
71
+ return out;
72
+ }
73
+ /** A reference attribute: `n` and the empty string mean none. */
74
+ export const refOf = (v) => (v && v !== 'n' ? v : undefined);
75
+ /** A name without the `$ID/` mark InDesign puts before its own strings
76
+ * (`$ID/[No paragraph style]`, and `$ID/` alone for an empty one). */
77
+ export const plainName = (v) => (v === undefined ? '' : v.startsWith('$ID/') ? v.slice(4) : v);
78
+ /** The items of a list property, each a record of named children
79
+ * (`<ListItem type="record"><Position type="unit">120</Position>…`). */
80
+ export function listRecords(prop) {
81
+ const out = [];
82
+ for (const item of children(prop, 'ListItem')) {
83
+ const record = {};
84
+ for (const field of children(item))
85
+ record[localName(field.name)] = field;
86
+ out.push(record);
87
+ }
88
+ return out;
89
+ }
90
+ /** The items of a list property as text (`<ListItem type="object">…`). */
91
+ export function listTexts(prop) {
92
+ return children(prop, 'ListItem').map((i) => textOf(i));
93
+ }
94
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/read/props.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,kDAAkD;AAElD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAmB,MAAM,gBAAgB,CAAC;AAIrG,MAAM,UAAU,OAAO,CAAC,EAAc;IACpC,MAAM,UAAU,GAA+B,EAAE,CAAC;IAClD,KAAK,MAAM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,SAAS,CAAC,CAAC;AAErG;uEACuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAqB,EAAU,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3H;yEACyE;AACzE,MAAM,UAAU,WAAW,CAAC,IAA4B;IACtD,MAAM,GAAG,GAAiC,EAAE,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GAA+B,EAAE,CAAC;QAC9C,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;QAC1E,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,SAAS,CAAC,IAA4B;IACpD,OAAO,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reference.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.test.d.ts","sourceRoot":"","sources":["../../src/read/reference.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,428 @@
1
+ // The reader against the package InDesign itself wrote: every fact here
2
+ // is one the script that made the document put there.
3
+ import { describe, expect, it } from 'vitest';
4
+ import { inlineItems, inlineText, reference, tablesOf } from './fixture.test-helper.js';
5
+ import { languageTag } from './languages.js';
6
+ import { plainText } from './story.js';
7
+ import { cellAt, rowBand } from './tables.js';
8
+ describe('reference package: the document', () => {
9
+ const doc = reference();
10
+ it('reads without a warning and says who wrote it', () => {
11
+ expect(doc.warnings).toEqual([]);
12
+ expect(doc.product).toBe('21.6(57)');
13
+ expect(doc.domVersion).toBe('21.5');
14
+ expect(doc.title).toBe('Reference');
15
+ expect(doc.author).toBe('Postext');
16
+ expect(doc.cmykProfile).toBe('Coated FOGRA39 (ISO 12647-2:2004)');
17
+ expect(doc.rgbProfile).toBe('sRGB IEC61966-2.1');
18
+ });
19
+ it('names the parts and reads every one', () => {
20
+ expect(doc.parts.graphic).toBe('Resources/Graphic.xml');
21
+ expect(doc.parts.spreads).toHaveLength(3);
22
+ expect(doc.parts.masterSpreads).toHaveLength(2);
23
+ expect(doc.parts.stories).toHaveLength(18);
24
+ expect(doc.stories.size).toBe(18);
25
+ // The story list also counts the XML backing story, which is a part
26
+ // of its own.
27
+ expect(doc.storyList).toHaveLength(19);
28
+ expect(doc.parts.backingStory).toBe('XML/BackingStory.xml');
29
+ // Linked pictures are not in the package: it carries no other file.
30
+ expect(doc.files.size).toBe(0);
31
+ });
32
+ it('has facing pages of 170 × 240 mm with a 3 mm bleed and a 14 pt baseline grid', () => {
33
+ const p = doc.preferences;
34
+ expect(p.facingPages).toBe(true);
35
+ expect(p.rightToLeft).toBe(false);
36
+ expect(p.pageWidth).toBeCloseTo((170 * 72) / 25.4, 6);
37
+ expect(p.pageHeight).toBeCloseTo((240 * 72) / 25.4, 6);
38
+ expect(p.bleed.top).toBeCloseTo((3 * 72) / 25.4, 6);
39
+ expect(p.bleed.outside).toBeCloseTo((3 * 72) / 25.4, 6);
40
+ expect(p.intent).toBe('PrintIntent');
41
+ expect(p.baselineGrid).toMatchObject({ start: 54, division: 14, shown: false });
42
+ expect(p.all?.FootnoteOption?.attrs.RuleOn).toBe('true');
43
+ expect(p.all?.TextPreference?.attrs.SmallCap).toBe('70');
44
+ });
45
+ it('has four pages named i, ii, 1, 2 on three spreads', () => {
46
+ const pages = doc.spreads.flatMap((s) => s.pages);
47
+ expect(doc.spreads.map((s) => s.pages.length)).toEqual([1, 2, 1]);
48
+ expect(pages.map((p) => p.name)).toEqual(['i', 'ii', '1', '2']);
49
+ expect(pages.map((p) => p.index)).toEqual([0, 1, 2, 3]);
50
+ expect(pages.map((p) => p.side)).toEqual(['right', 'left', 'right', 'left']);
51
+ expect(pages.map((p) => p.appliedMaster)).toEqual(['ud6', 'ud6', 'u171', undefined]);
52
+ for (const p of pages) {
53
+ expect(p.bounds.right - p.bounds.left).toBeCloseTo(481.8897637795276, 6);
54
+ expect(p.bounds.bottom - p.bounds.top).toBeCloseTo(680.3149606299213, 6);
55
+ }
56
+ });
57
+ it('reads the margins: 54/60/48/42 in two columns with a 14 pt gutter', () => {
58
+ const first = doc.spreads[0].pages[0];
59
+ expect(first.margins).toMatchObject({ top: 54, bottom: 60, left: 48, right: 42, columnCount: 2, columnGutter: 14, columnDirection: 'Horizontal' });
60
+ expect(first.margins.columnsPositions).toHaveLength(4);
61
+ expect(first.margins.columnsPositions[1]).toBeCloseTo(188.9448818897638, 6);
62
+ // The opener page takes its master's margins.
63
+ expect(doc.spreads[1].pages[1].margins).toMatchObject({ top: 36, bottom: 36, left: 36, right: 36, columnCount: 1 });
64
+ });
65
+ it('reads two masters, the second based on the first', () => {
66
+ const [a, b] = doc.masterSpreads;
67
+ expect(a).toMatchObject({ self: 'ud6', master: true, namePrefix: 'A', showMasterItems: true });
68
+ expect(a.basedOn).toBeUndefined();
69
+ expect(b).toMatchObject({ self: 'u171', name: 'B-Opener', namePrefix: 'B', baseName: 'Opener', basedOn: 'ud6' });
70
+ expect(a.pages.map((p) => p.side)).toEqual(['left', 'right']);
71
+ expect(a.pages.map((p) => p.index)).toEqual([-1, -1]);
72
+ expect(a.items.map((i) => i.kind)).toEqual(['TextFrame', 'TextFrame', 'TextFrame', 'TextFrame']);
73
+ expect(b.items.map((i) => i.kind)).toEqual(['Rectangle']);
74
+ });
75
+ it('records the master item overridden on page ii', () => {
76
+ const ii = doc.spreads[1].pages[0];
77
+ expect(ii.overrideList).toContain('u16d');
78
+ expect(doc.masterSpreads[0].items.some((i) => i.self === 'u16d')).toBe(true);
79
+ expect(plainText(doc.stories.get('u36a').paragraphs)).toBe('Overridden head');
80
+ });
81
+ it('reads the sections: lower roman, then arabic restarting at 1', () => {
82
+ expect(doc.sections).toHaveLength(2);
83
+ expect(doc.sections[0]).toMatchObject({ pageStart: 'ud4', length: 2, pageNumberStyle: 'LowerRoman', continueNumbering: true });
84
+ expect(doc.sections[1]).toMatchObject({ pageStart: 'ue4', length: 2, pageNumberStyle: 'Arabic', continueNumbering: false, pageNumberStart: 1 });
85
+ });
86
+ it('reads three layers, one of them hidden', () => {
87
+ expect(doc.layers.map((l) => [l.name, l.visible])).toEqual([['Capa 1', true], ['Hidden notes', false], ['Art', true]]);
88
+ expect(doc.layers.every((l) => l.printable && !l.locked)).toBe(true);
89
+ });
90
+ it('maps the languages InDesign lists to IETF tags', () => {
91
+ expect(doc.languages.get('Language/$ID/Spanish%3a Castilian')).toEqual({ name: 'Spanish: Castilian', tag: 'es-ES' });
92
+ expect(doc.languages.get('Language/$ID/English%3a USA')?.tag).toBe('en-US');
93
+ expect(doc.languages.get('Language/$ID/de_DE_2006')?.tag).toBe('de-DE');
94
+ expect(doc.languages.get('Language/$ID/[No Language]')?.tag).toBeUndefined();
95
+ const tags = {
96
+ 'English: UK': 'en-GB', 'French': 'fr-FR', 'French: Canadian': 'fr-CA', 'German: Reformed': 'de-DE-1996', 'German: Swiss': 'de-CH', 'German: Austrian': 'de-AT', 'German: Traditional': 'de-DE-1901',
97
+ 'Italian': 'it-IT', 'Portuguese': 'pt-PT', 'Portuguese: Brazilian': 'pt-BR', 'Catalan': 'ca', 'Dutch': 'nl-NL', 'Japanese': 'ja', 'Chinese: Simplified': 'zh-Hans', 'Chinese: Traditional': 'zh-Hant',
98
+ 'Arabic': 'ar', 'Hebrew': 'he', 'Russian': 'ru', 'Greek': 'el', 'Polish': 'pl', 'Swedish': 'sv', 'Danish': 'da', 'Norwegian: Bokmal': 'nb', 'Norwegian: Nynorsk': 'nn', 'Finnish': 'fi', 'Czech': 'cs', 'Hungarian': 'hu',
99
+ 'Turkish': 'tr', 'Romanian': 'ro', 'Ukrainian': 'uk', 'nl_NL_2005': 'nl-NL', 'hi_IN': 'hi-IN',
100
+ };
101
+ for (const [name, tag] of Object.entries(tags))
102
+ expect([name, languageTag(`$ID/${name}`)]).toEqual([name, tag]);
103
+ // Every language of the package but the placeholder has a tag.
104
+ const untagged = [...doc.languages.values()].filter((l) => !l.tag).map((l) => l.name);
105
+ expect(untagged).toEqual(['[No Language]']);
106
+ });
107
+ it('reads conditions, text variables, cross-reference formats and numbering lists', () => {
108
+ expect(doc.conditions.get('Condition/Print only')).toEqual({ self: 'Condition/Print only', name: 'Print only', visible: false });
109
+ expect(doc.conditions.get('Condition/Teacher')?.visible).toBe(true);
110
+ expect([...doc.textVariables.values()].map((v) => v.type)).toContain('ModificationDateType');
111
+ expect(doc.textVariables.size).toBe(10);
112
+ expect(doc.crossReferenceFormats.size).toBe(9);
113
+ expect(doc.crossReferenceFormats.get('u9f')?.blocks.map((b) => b.type)).toEqual(['CustomStringBuildingBlock', 'FullParagraphBuildingBlock', 'CustomStringBuildingBlock', 'PageNumberBuildingBlock']);
114
+ expect(doc.crossReferenceFormats.get('ua7')?.blocks[0]?.text).toBe('página ');
115
+ expect(doc.numberingLists.get('NumberingList/$ID/[Default]')).toMatchObject({ name: '[Default]', continueAcrossStories: false });
116
+ });
117
+ it('reads the three hyperlinks, the cross-reference and their destinations', () => {
118
+ const byName = new Map(doc.hyperlinks.map((h) => [h.name, h]));
119
+ expect(doc.hyperlinks).toHaveLength(4);
120
+ expect(byName.get('postext')).toMatchObject({ source: 'u1dd', destination: 'HyperlinkURLDestination/URL 1' });
121
+ expect(doc.destinations.get('HyperlinkURLDestination/URL 1')).toMatchObject({ kind: 'url', url: 'https://postext.dev/' });
122
+ expect(byName.get('to chapter')).toMatchObject({ source: 'u1e4', destination: 'HyperlinkTextDestination/chapter-one' });
123
+ expect(doc.destinations.get('HyperlinkTextDestination/chapter-one')).toMatchObject({ kind: 'text', name: 'chapter-one', story: 'u17e' });
124
+ expect(byName.get('to page 3')).toMatchObject({ source: 'u1e6', destination: 'HyperlinkPageDestination/Página 3' });
125
+ // The page destination names page "1", the third of the document.
126
+ expect(doc.destinations.get('HyperlinkPageDestination/Página 3')).toMatchObject({ kind: 'page', page: 'ue4' });
127
+ expect(doc.spreads[1].pages[1].self).toBe('ue4');
128
+ expect(byName.get('Referencia cruzada')).toMatchObject({ source: 'u1eb', destination: 'ParagraphDestination/Anclaje 1' });
129
+ expect(doc.destinations.get('ParagraphDestination/Anclaje 1')).toMatchObject({ kind: 'paragraph', story: 'u17e' });
130
+ });
131
+ it('reads the bookmark and the index topics', () => {
132
+ expect(doc.bookmarks).toEqual([{ name: 'Chapter Two', destination: 'HyperlinkPageDestination/Página 1', children: [] }]);
133
+ expect([...doc.topics.values()].map((t) => [...t.path, t.name].join(' > '))).toEqual(['Typography', 'Typography > Leading']);
134
+ });
135
+ });
136
+ describe('reference package: resources', () => {
137
+ const doc = reference();
138
+ const colour = (self) => doc.swatches.get(self);
139
+ it('reads the swatches with their values', () => {
140
+ expect(colour('Color/Brand Cyan')).toMatchObject({ kind: 'color', name: 'Brand Cyan', model: 'Process', space: 'CMYK', value: [80, 10, 0, 5], visible: true });
141
+ expect(colour('Color/Screen Red')).toMatchObject({ space: 'RGB', value: [220, 30, 40] });
142
+ expect(colour('Color/Lab Green')).toMatchObject({ space: 'LAB', value: [60, -50, 40] });
143
+ expect(colour('Color/PANTONE 185 C')).toMatchObject({ model: 'Spot', space: 'CMYK', value: [0, 93, 79, 0] });
144
+ expect(doc.swatches.get('Tint/PANTONE 185 C 40%25')).toMatchObject({ kind: 'tint', name: 'PANTONE 185 C 40%', base: 'Color/PANTONE 185 C', tint: 40 });
145
+ expect(doc.swatches.get('Gradient/Sky')).toMatchObject({
146
+ kind: 'gradient',
147
+ type: 'Linear',
148
+ stops: [{ color: 'Color/Brand Cyan', location: 0, midpoint: 50 }, { color: 'Color/Paper', location: 100, midpoint: 50 }],
149
+ });
150
+ expect(doc.swatches.get('Swatch/None')).toMatchObject({ kind: 'none', name: 'None' });
151
+ });
152
+ it("tells InDesign's own colours apart", () => {
153
+ expect(colour('Color/Black').special).toBe('black');
154
+ expect(colour('Color/Paper').special).toBe('paper');
155
+ expect(colour('Color/Registration')).toMatchObject({ special: 'registration', model: 'Registration' });
156
+ expect(colour('Color/Cyan')).toMatchObject({ special: 'reserved', visible: false });
157
+ expect(colour('Color/Brand Cyan').special).toBeUndefined();
158
+ });
159
+ it('reads the stroke styles and the fonts', () => {
160
+ expect(doc.strokeStyles.get('StrokeStyle/$ID/Solid')).toMatchObject({ name: 'Solid', kind: 'solid' });
161
+ expect(doc.strokeStyles.get('StrokeStyle/$ID/Canned Dashed 3x2')?.kind).toBe('dashed');
162
+ expect(doc.strokeStyles.get('StrokeStyle/$ID/Japanese Dots')?.kind).toBe('dotted');
163
+ expect(doc.strokeStyles.get('StrokeStyle/$ID/ThickThin')?.kind).toBe('striped');
164
+ expect(doc.fonts.find((f) => f.postScriptName === 'MinionPro-Regular')).toMatchObject({ family: 'Minion Pro', style: 'Regular', type: 'OpenTypeCFF', status: 'Installed' });
165
+ expect(doc.fonts.some((f) => f.family === 'Georgia' && f.style === 'Bold')).toBe(true);
166
+ });
167
+ it('reads the paragraph styles: a group, based-on by reference and by name', () => {
168
+ const h1 = doc.styles.paragraph.get('ParagraphStyle/Heads%3aH1');
169
+ expect(h1).toMatchObject({ kind: 'paragraph', name: 'H1', groups: ['Heads'], basedOn: 'ParagraphStyle/Body', root: false });
170
+ expect(h1.attrs.PointSize).toBe('22');
171
+ const body = doc.styles.paragraph.get('ParagraphStyle/Body');
172
+ // Written `type="string"` as `$ID/[No paragraph style]`.
173
+ expect(body.basedOn).toBe('ParagraphStyle/$ID/[No paragraph style]');
174
+ expect(doc.styles.paragraph.get('ParagraphStyle/$ID/[No paragraph style]')).toMatchObject({ root: true, name: '[No paragraph style]' });
175
+ expect(doc.styles.paragraph.get('ParagraphStyle/$ID/[No paragraph style]').basedOn).toBeUndefined();
176
+ expect(doc.styles.paragraph.get('ParagraphStyle/Bullets').attrs.BulletsAndNumberingListType).toBe('BulletList');
177
+ expect(doc.styles.paragraph.get('ParagraphStyle/Numbers').attrs.BulletsAndNumberingListType).toBe('NumberedList');
178
+ });
179
+ it('reads the nested style and the GREP style of Body', () => {
180
+ expect(doc.styles.paragraph.get('ParagraphStyle/Body').nested).toEqual([
181
+ { kind: 'nested', characterStyle: 'CharacterStyle/Emphasis', delimiter: ':', repetition: 1, inclusive: true },
182
+ { kind: 'grep', characterStyle: 'CharacterStyle/Strong red', expression: '\\d+' },
183
+ ]);
184
+ });
185
+ it('reads character, object, table and cell styles', () => {
186
+ expect(doc.styles.character.get('CharacterStyle/Emphasis')).toMatchObject({ name: 'Emphasis', basedOn: 'CharacterStyle/$ID/[No character style]' });
187
+ expect(doc.styles.character.get('CharacterStyle/Strong red').attrs).toMatchObject({ FillColor: 'Color/Screen Red', FontStyle: 'Bold' });
188
+ expect(doc.styles.character.get('CharacterStyle/$ID/[No character style]').root).toBe(true);
189
+ expect(doc.styles.object.get('ObjectStyle/Tinted box')).toMatchObject({ name: 'Tinted box', basedOn: 'ObjectStyle/$ID/[None]' });
190
+ expect(doc.styles.table.get('TableStyle/Ledger')).toMatchObject({ name: 'Ledger', basedOn: 'TableStyle/$ID/[No table style]' });
191
+ expect(doc.styles.cell.get('CellStyle/Money')).toMatchObject({ name: 'Money', basedOn: 'CellStyle/$ID/[None]' });
192
+ expect(doc.styles.cell.get('CellStyle/Money').attrs.FillColor).toBe('Tint/PANTONE 185 C 40%25');
193
+ });
194
+ });
195
+ describe('reference package: stories', () => {
196
+ const doc = reference();
197
+ const main = doc.stories.get('u17e');
198
+ it('cuts the main story into its nine paragraphs', () => {
199
+ expect(main.paragraphs).toHaveLength(9);
200
+ expect(main.paragraphs.map((p) => p.paragraphStyle)).toEqual(['ParagraphStyle/Heads%3aH1', ...Array(8).fill('ParagraphStyle/Body')]);
201
+ const text = plainText(main.paragraphs).split('\n');
202
+ expect(text[0]).toBe('Chapter One');
203
+ expect(text[1]).toMatch(/^Lead: this is the first paragraph with 123 numbers and some emphasised words to style\. /);
204
+ // One paragraph range holds the lead and the paragraphs after it:
205
+ // they are cut at the `Br`s, not at the range.
206
+ for (const i of [2, 3, 4, 5, 6, 7])
207
+ expect(text[i]).toMatch(/^Lorem ipsu/);
208
+ expect(main).toMatchObject({ direction: 'ltr', orientation: 'horizontal', endnotes: false, trackChanges: false });
209
+ });
210
+ it('keeps the local overrides of the lead paragraph on their runs', () => {
211
+ const lead = main.paragraphs[1];
212
+ const run = (word) => lead.runs.find((r) => inlineText(r.content) === word);
213
+ expect(run('with').characterStyle).toBe('CharacterStyle/Emphasis');
214
+ expect(run('numbers').attrs.FontStyle).toBe('Bold');
215
+ expect(run('and').attrs.Underline).toBe('true');
216
+ expect(run('some').attrs.StrikeThru).toBe('true');
217
+ expect(run('emphasised').attrs.Position).toBe('Superscript');
218
+ expect(run('words').attrs.Capitalization).toBe('SmallCaps');
219
+ expect(run('to').attrs.Tracking).toBe('50');
220
+ });
221
+ it('reads the two destinations at the head of the chapter', () => {
222
+ const marks = main.paragraphs[0].runs[0].content.filter((i) => i.kind === 'destination');
223
+ expect(marks).toEqual([
224
+ { kind: 'destination', self: 'ParagraphDestination/Anclaje 1', name: 'Anclaje 1', destinationType: 'paragraph' },
225
+ { kind: 'destination', self: 'HyperlinkTextDestination/chapter-one', name: 'chapter-one', destinationType: 'text' },
226
+ ]);
227
+ });
228
+ it('reads the footnote with its text, inside the first hyperlink', () => {
229
+ const para = main.paragraphs[2];
230
+ const linked = para.runs.filter((r) => r.linkSource === 'u1dd');
231
+ // The source wraps three character ranges: "si", the footnote, "t".
232
+ expect(linked.map((r) => inlineText(r.content))).toEqual(['si', '<footnote>', 't']);
233
+ const note = linked[1].content[0];
234
+ expect(note.kind).toBe('footnote');
235
+ if (note.kind !== 'footnote')
236
+ return;
237
+ expect(note.paragraphs).toHaveLength(1);
238
+ expect(inlineText(note.paragraphs[0].runs[0].content)).toBe('{footnoteNumber}\tA footnote with its own text.');
239
+ expect(linked[1].attrs.Position).toBe('Superscript');
240
+ });
241
+ it('reads hyperlink sources written inside a character range', () => {
242
+ const para = main.paragraphs[3];
243
+ expect(para.runs.filter((r) => r.linkSource === 'u1e4').map((r) => inlineText(r.content))).toEqual(['dolor']);
244
+ // The third link holds an inline rectangle between its letters.
245
+ expect(para.runs.filter((r) => r.linkSource === 'u1e6').map((r) => inlineText(r.content))).toEqual(['c<item>onsectetur']);
246
+ expect(para.runs.filter((r) => !r.linkSource).every((r) => r.crossReference === undefined)).toBe(true);
247
+ });
248
+ it('reads the cross-reference with its format and its page number variable', () => {
249
+ const runs = main.paragraphs[4].runs.filter((r) => r.linkSource === 'u1eb');
250
+ expect(runs).toHaveLength(2);
251
+ expect(runs.every((r) => r.crossReference?.format === 'u9f')).toBe(true);
252
+ expect(inlineText(runs[0].content)).toBe('”Chapter One” en la página ');
253
+ expect(runs[1].content).toEqual([{ kind: 'variable', variable: 'dTextVariablen<?AID 001b?>TV XRefPageNumber', result: 'i' }]);
254
+ expect(doc.textVariables.get('dTextVariablen<?AID 001b?>TV XRefPageNumber')?.type).toBe('XrefPageNumberType');
255
+ });
256
+ it('reads the two index marks with their topics', () => {
257
+ const marks = main.paragraphs.flatMap((p) => p.runs.flatMap((r) => r.content)).filter((i) => i.kind === 'indexMark');
258
+ expect(marks).toEqual([
259
+ { kind: 'indexMark', topic: 'u1eeTopicnTypography', type: 'CurrentPage' },
260
+ { kind: 'indexMark', topic: 'u1eeTopicnTypographyTopicnLeading', type: 'CurrentPage' },
261
+ ]);
262
+ for (const m of marks)
263
+ expect(doc.topics.has(m.topic)).toBe(true);
264
+ });
265
+ it('reads the anchored objects: inline, anchored frame, above line', () => {
266
+ const items = inlineItems(doc, 'u17e');
267
+ expect(items.map((i) => [i.self, i.kind, i.anchored?.position])).toEqual([
268
+ ['u23e', 'Rectangle', 'InlinePosition'],
269
+ ['u253', 'TextFrame', 'Anchored'],
270
+ ['u258', 'Rectangle', 'AboveLine'],
271
+ ]);
272
+ expect(items[0].attrs.FillColor).toBe('Color/Screen Red');
273
+ expect(items[1].textFrame?.story).toBe('u241');
274
+ expect(items[1].anchored?.props.AnchorPoint).toBe('TopLeftAnchor');
275
+ expect(plainText(doc.stories.get('u241').paragraphs)).toBe('Anchored sidebar');
276
+ // The picture is linked; its link was made neutral in the fixture.
277
+ expect(items[2].graphic).toMatchObject({ type: 'Image', space: 'Links_RGB', actualPpi: [300, 300] });
278
+ expect(items[2].graphic.link).toMatchObject({ uri: 'file:/Volumes/Work/reference/pic.png', name: 'pic.png', stored: 'Normal', format: 'Portable Network Graphics (PNG)' });
279
+ expect(items[2].graphic.data).toBeUndefined();
280
+ });
281
+ it('reads the table: header and footer rows, spans, cell kinds and styles', () => {
282
+ const [table] = tablesOf(doc, 'u17e');
283
+ expect(table).toBeDefined();
284
+ const t = table;
285
+ expect(t).toMatchObject({ headerRows: 1, footerRows: 1, bodyRows: 3, tableStyle: 'TableStyle/Ledger' });
286
+ expect(t.columns.map((c) => Math.round(c.width))).toEqual([120, 63, 63]);
287
+ expect(t.rows).toHaveLength(5);
288
+ expect(t.rows[2]).toMatchObject({ height: 30, minHeight: 30, autoGrow: false });
289
+ expect(t.rows[0].autoGrow).toBe(true);
290
+ expect(t.cells).toHaveLength(13);
291
+ // Merged across two columns, and down two rows.
292
+ expect(cellAt(t, 0, 1)).toMatchObject({ col: 0, row: 1, colSpan: 2, rowSpan: 1 });
293
+ expect(cellAt(t, 1, 1)).toBe(cellAt(t, 0, 1));
294
+ expect(cellAt(t, 0, 2)).toMatchObject({ col: 0, row: 2, colSpan: 1, rowSpan: 2 });
295
+ expect(cellAt(t, 0, 3)).toBe(cellAt(t, 0, 2));
296
+ expect(plainText(cellAt(t, 0, 1).paragraphs)).toBe('span two');
297
+ expect(plainText(cellAt(t, 0, 2).paragraphs)).toBe('tall');
298
+ expect([0, 1, 2].map((c) => plainText(cellAt(t, c, 0).paragraphs))).toEqual(['Head A', 'Head A', 'Head A']);
299
+ expect([0, 1, 2].map((c) => plainText(cellAt(t, c, 4).paragraphs))).toEqual(['F1', 'F1', 'F1']);
300
+ expect([0, 1, 2, 3, 4].map((r) => rowBand(t, r))).toEqual(['header', 'body', 'body', 'body', 'footer']);
301
+ // The cell with a cell style and a diagonal line, the rotated one,
302
+ // the one that holds a picture.
303
+ expect(cellAt(t, 2, 1)).toMatchObject({ cellStyle: 'CellStyle/Money', type: 'text' });
304
+ expect(cellAt(t, 2, 1).attrs.TopLeftDiagonalLine).toBe('true');
305
+ expect(cellAt(t, 2, 3).attrs.RotationAngle).toBe('90');
306
+ expect(plainText(cellAt(t, 2, 3).paragraphs)).toBe('rot');
307
+ const picture = cellAt(t, 2, 2);
308
+ expect(picture).toMatchObject({ type: 'graphic', paragraphs: [] });
309
+ expect(picture.items).toHaveLength(1);
310
+ expect(picture.items[0].graphic?.link?.name).toBe('pic.png');
311
+ });
312
+ it('reads the right-to-left story', () => {
313
+ const rtl = doc.stories.get('u277');
314
+ expect(rtl.direction).toBe('rtl');
315
+ expect(rtl.paragraphs[0].attrs).toMatchObject({ ParagraphDirection: 'RightToLeftDirection', Justification: 'RightAlign' });
316
+ // The script that made the document was read by InDesign in another
317
+ // encoding, so the Arabic it typed is not Arabic: the package holds
318
+ // what InDesign held. The digits between the words are as typed.
319
+ expect(plainText(rtl.paragraphs)).toMatch(/^\S+ \S+ 123 \S+ \S+$/);
320
+ });
321
+ it('reads ruby, emphasis marks and tate-chu-yoko on the Japanese text', () => {
322
+ const jp = doc.stories.get('u25e');
323
+ // The same of the Japanese: the characters are not the ones meant,
324
+ // the attributes on them are.
325
+ expect(plainText(jp.paragraphs)).toMatch(/12/);
326
+ expect(jp.orientation).toBe('horizontal');
327
+ const runs = jp.paragraphs[0].runs;
328
+ expect(runs.find((r) => r.attrs.RubyString)?.attrs).toMatchObject({ RubyFlag: '1' });
329
+ expect(runs.some((r) => r.attrs.KentenKind === 'KentenSesameDot')).toBe(true);
330
+ expect(runs.some((r) => r.attrs.Tatechuyoko === 'true')).toBe(true);
331
+ });
332
+ it('reads conditional text, hidden text and the note', () => {
333
+ const story = doc.stories.get('u2eb');
334
+ const [para] = story.paragraphs;
335
+ expect(story.paragraphs).toHaveLength(1);
336
+ const runs = para.runs;
337
+ expect(runs.map((r) => inlineText(r.content))).toEqual(['Sho<note>wn', ' text and conditional ', 'hidden text and', ' more.']);
338
+ expect(runs[0].conditions).toEqual(['Condition/Teacher']);
339
+ // The reference escapes the space of the name; the condition's own
340
+ // identifier does not.
341
+ expect(runs[2].conditions).toEqual(['Condition/Print only']);
342
+ expect(runs[2].hidden).toBe(true);
343
+ expect(runs[3].hidden).toBeUndefined();
344
+ for (const r of runs)
345
+ for (const c of r.conditions)
346
+ expect(doc.conditions.has(c)).toBe(true);
347
+ const note = runs[0].content[1];
348
+ expect(note.kind === 'note' && plainText(note.paragraphs)).toBe('An editorial note');
349
+ });
350
+ it('reads the lists: two bullet paragraphs, three numbered ones', () => {
351
+ const list = doc.stories.get('u305');
352
+ expect(list.paragraphs.map((p) => [p.paragraphStyle, plainText([p])])).toEqual([
353
+ ['ParagraphStyle/Bullets', 'First bullet'],
354
+ ['ParagraphStyle/Bullets', 'Second bullet'],
355
+ ['ParagraphStyle/Numbers', 'Step one'],
356
+ ['ParagraphStyle/Numbers', 'Step two'],
357
+ ['ParagraphStyle/Numbers', 'Step three'],
358
+ ]);
359
+ });
360
+ it('reads the automatic page number of the master as a special character', () => {
361
+ const folio = doc.stories.get('u116');
362
+ expect(folio.paragraphs[0].runs[0].content).toEqual([{ kind: 'special', char: 'pageNumber' }]);
363
+ expect(folio.paragraphs[0].attrs.Justification).toBe('CenterAlign');
364
+ });
365
+ it('keeps the tab list, the rule and the drop cap on the paragraph', () => {
366
+ const para = doc.stories.get('u34d').paragraphs[0];
367
+ expect(plainText([para])).toBe('Name\tPrice\t12.50');
368
+ expect(para.attrs).toMatchObject({ DropCapCharacters: '1', DropCapLines: '2', RuleBelow: 'true', RuleBelowLineWeight: '0.5' });
369
+ expect(para.properties.TabList).toBeDefined();
370
+ });
371
+ });
372
+ describe('reference package: page items', () => {
373
+ const doc = reference();
374
+ const item = (self) => [...doc.spreads, ...doc.masterSpreads].flatMap((s) => s.items).flatMap((i) => [i, ...i.children]).find((i) => i.self === self);
375
+ it('threads the main story over three frames, the first in two columns', () => {
376
+ expect(item('u190').textFrame).toMatchObject({ story: 'u17e', next: 'u1a8', columns: 2, gutter: 14 });
377
+ expect(item('u190').textFrame.previous).toBeUndefined();
378
+ expect(item('u1a8').textFrame).toMatchObject({ story: 'u17e', previous: 'u190', next: 'u1bf', columns: 1 });
379
+ expect(item('u1bf').textFrame).toMatchObject({ story: 'u17e', previous: 'u1a8' });
380
+ expect(item('u1bf').textFrame.next).toBeUndefined();
381
+ });
382
+ it('reads the placed picture: rounded corner, text wrap, object style', () => {
383
+ const frame = item('u22f');
384
+ expect(frame).toMatchObject({ kind: 'Rectangle', objectStyle: 'ObjectStyle/Tinted box', contentType: 'GraphicType', layer: 'ufb' });
385
+ expect(frame.attrs.TopLeftCornerOption).toBe('RoundedCorner');
386
+ expect(frame.wrap).toMatchObject({ mode: 'BoundingBoxTextWrap', offset: [6, 6, 6, 6], side: 'BothSides', inverse: false });
387
+ expect(frame.graphic).toMatchObject({ type: 'Image', effectivePpi: [192, 192] });
388
+ expect(frame.graphic.bounds.right).toBeCloseTo(144.0003, 3);
389
+ expect(frame.graphic.transform[0]).toBeCloseTo(1.5625, 4);
390
+ });
391
+ it('reads opacity and the drop shadow of the rotated picture', () => {
392
+ const frame = item('u234');
393
+ expect(frame.opacity).toBe(70);
394
+ expect(frame.effects).toEqual(['DropShadow']);
395
+ expect(item('u22f').opacity).toBe(100);
396
+ expect(item('u22f').effects).toEqual([]);
397
+ });
398
+ it('reads the group with its oval and polygon, and the line', () => {
399
+ const group = item('u23d');
400
+ expect(group).toMatchObject({ kind: 'Group', name: 'shapes' });
401
+ expect(group.children.map((c) => c.kind)).toEqual(['Oval', 'Polygon']);
402
+ expect(group.children[0].attrs).toMatchObject({ FillColor: 'Gradient/Sky', StrokeColor: 'Color/PANTONE 185 C', StrokeWeight: '2' });
403
+ expect(group.children[1].attrs.FillColor).toBe('Color/Lab Green');
404
+ expect(group.children[0].paths[0].points).toHaveLength(4);
405
+ // An oval's points have handles; a polygon's are corners.
406
+ const oval = group.children[0].paths[0].points[0];
407
+ expect(oval.left.x !== oval.anchor.x || oval.left.y !== oval.anchor.y).toBe(true);
408
+ const line = item('u23c');
409
+ expect(line.kind).toBe('GraphicLine');
410
+ expect(line.paths[0]).toMatchObject({ open: true });
411
+ expect(line.paths[0].points).toHaveLength(2);
412
+ });
413
+ it('reads hidden, non-printing and hidden-layer items, and text on a path', () => {
414
+ expect(item('u2cf')).toMatchObject({ visible: false, nonprinting: false });
415
+ expect(item('u2e6')).toMatchObject({ visible: true, nonprinting: true });
416
+ expect(item('u2b7').layer).toBe('uf2');
417
+ expect(doc.layers.find((l) => l.self === 'uf2').visible).toBe(false);
418
+ const oval = item('u333');
419
+ expect(oval.textPaths).toHaveLength(1);
420
+ expect(oval.textPaths[0]).toMatchObject({ story: 'u335' });
421
+ expect(oval.textPaths[0].props.PathEffect).toBe('RainbowPathEffect');
422
+ expect(plainText(doc.stories.get('u335').paragraphs)).toBe('Text on a path');
423
+ });
424
+ it('keeps the items of a spread back to front', () => {
425
+ expect(doc.spreads[1].items.map((i) => i.self)).toEqual(['u367', 'u1a8', 'u1bf', 'u22f', 'u234', 'u23d', 'u23c']);
426
+ });
427
+ });
428
+ //# sourceMappingURL=reference.test.js.map