@redneckz/wildless-cms-uni-blocks 0.14.861 → 0.14.862

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 (454) hide show
  1. package/README.md +13 -5
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +14 -20
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/icons/IconName.d.ts +2 -2
  6. package/bundle/model/Fallback.d.ts +0 -1
  7. package/bundle/model/FormTypeFieldDef.d.ts +1 -1
  8. package/dist/components/TabsLayout/TabsLayout.js +13 -15
  9. package/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  10. package/dist/icons/IconName.d.ts +2 -2
  11. package/dist/icons/IconName.js +1 -1
  12. package/dist/icons/IconName.js.map +1 -1
  13. package/dist/model/Fallback.d.ts +0 -1
  14. package/dist/model/FormTypeFieldDef.d.ts +1 -1
  15. package/lib/common.css +1 -1
  16. package/lib/components/ApplicationForm/ApplicationForm.fixture.d.ts +1 -0
  17. package/lib/components/ApplicationForm/ApplicationForm.fixture.mobile.d.ts +1 -0
  18. package/lib/components/TabsLayout/TabsLayout.js +14 -16
  19. package/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  20. package/lib/icons/IconName.d.ts +2 -2
  21. package/lib/icons/IconName.js +1 -1
  22. package/lib/icons/IconName.js.map +1 -1
  23. package/lib/model/Fallback.d.ts +0 -1
  24. package/lib/model/FormTypeFieldDef.d.ts +1 -1
  25. package/lib/retail/components/DraftDialog/utils.d.ts +3 -3
  26. package/mobile/bundle/bundle.umd.js +14 -20
  27. package/mobile/bundle/bundle.umd.min.js +1 -1
  28. package/mobile/bundle/icons/IconName.d.ts +2 -2
  29. package/mobile/bundle/model/Fallback.d.ts +0 -1
  30. package/mobile/bundle/model/FormTypeFieldDef.d.ts +1 -1
  31. package/mobile/dist/components/TabsLayout/TabsLayout.js +13 -15
  32. package/mobile/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  33. package/mobile/dist/icons/IconName.d.ts +2 -2
  34. package/mobile/dist/icons/IconName.js +1 -1
  35. package/mobile/dist/icons/IconName.js.map +1 -1
  36. package/mobile/dist/model/Fallback.d.ts +0 -1
  37. package/mobile/dist/model/FormTypeFieldDef.d.ts +1 -1
  38. package/mobile/lib/common.css +1 -1
  39. package/mobile/lib/components/TabsLayout/TabsLayout.js +14 -16
  40. package/mobile/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  41. package/mobile/lib/icons/IconName.d.ts +2 -2
  42. package/mobile/lib/icons/IconName.js +1 -1
  43. package/mobile/lib/icons/IconName.js.map +1 -1
  44. package/mobile/lib/model/Fallback.d.ts +0 -1
  45. package/mobile/lib/model/FormTypeFieldDef.d.ts +1 -1
  46. package/mobile/src/components/ApplicationForm/ApplicationForm.example.json +30 -0
  47. package/mobile/src/components/TabsLayout/TabsLayout.tsx +19 -23
  48. package/mobile/src/icons/IconName.ts +2 -2
  49. package/mobile/src/icons/PercentIcon.svg +1 -1
  50. package/mobile/src/model/Fallback.ts +0 -1
  51. package/mobile/src/model/FormTypeFieldDef.ts +1 -0
  52. package/package.json +1 -21
  53. package/src/components/ApplicationForm/ApplicationForm.example.json +30 -0
  54. package/src/components/ApplicationForm/ApplicationForm.fixture.mobile.tsx +23 -0
  55. package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +23 -0
  56. package/src/components/ContentPage/ContentPage.fixture.mobile.tsx +1 -4
  57. package/src/components/ContentPage/ContentPage.fixture.tsx +2 -7
  58. package/src/components/TabsLayout/TabsLayout.tsx +19 -23
  59. package/src/icons/IconName.ts +2 -2
  60. package/src/icons/PercentIcon.svg +1 -1
  61. package/src/model/Fallback.ts +0 -1
  62. package/src/model/FormTypeFieldDef.ts +1 -0
  63. package/bundle/components/ContentPage/computeAPIFallback.d.ts +0 -4
  64. package/bundle/components/ContentPage/loadModuleFallback.d.ts +0 -2
  65. package/bundle/components/ContentPage/mapSlot.d.ts +0 -2
  66. package/bundle/components/ContentPage/normalizeBlock.d.ts +0 -3
  67. package/bundle/components/ContentPage/normalizeBlock.mobile.d.ts +0 -3
  68. package/bundle/components/ContentPage/normalizePage.d.ts +0 -3
  69. package/bundle/components/ContentPage/toMobileBlock.d.ts +0 -2
  70. package/bundle/content-page-repository/ContentPageRepository.d.ts +0 -10
  71. package/bundle/content-page-repository/JSONDocContentBox.d.ts +0 -8
  72. package/bundle/content-page-repository/TransformationOptions.d.ts +0 -4
  73. package/bundle/content-page-repository/clearAttachmentHref.d.ts +0 -2
  74. package/bundle/content-page-repository/computeImgOutputPath.d.ts +0 -3
  75. package/bundle/content-page-repository/extensions.d.ts +0 -3
  76. package/bundle/content-page-repository/index.d.ts +0 -3
  77. package/bundle/content-page-repository/mapJSON.d.ts +0 -1
  78. package/bundle/content-page-repository/mergePages.d.ts +0 -2
  79. package/bundle/content-page-repository/replaceHeadingTags.d.ts +0 -1
  80. package/bundle/content-page-repository/resizeImg.d.ts +0 -3
  81. package/bundle/content-page-repository/transformAttachmentLink.d.ts +0 -3
  82. package/bundle/content-page-repository/transformContentPage.d.ts +0 -4
  83. package/bundle/content-page-repository/transformDocument.d.ts +0 -3
  84. package/bundle/content-page-repository/transformHTML.d.ts +0 -1
  85. package/bundle/content-page-repository/transformImg.d.ts +0 -12
  86. package/bundle/content-page-repository/transformMarkdown.d.ts +0 -1
  87. package/bundle/content-page-repository/transformPicture.d.ts +0 -3
  88. package/dist/components/ContentPage/computeAPIFallback.d.ts +0 -4
  89. package/dist/components/ContentPage/computeAPIFallback.js +0 -36
  90. package/dist/components/ContentPage/computeAPIFallback.js.map +0 -1
  91. package/dist/components/ContentPage/loadModuleFallback.d.ts +0 -2
  92. package/dist/components/ContentPage/loadModuleFallback.js +0 -36
  93. package/dist/components/ContentPage/loadModuleFallback.js.map +0 -1
  94. package/dist/components/ContentPage/mapSlot.d.ts +0 -2
  95. package/dist/components/ContentPage/mapSlot.js +0 -16
  96. package/dist/components/ContentPage/mapSlot.js.map +0 -1
  97. package/dist/components/ContentPage/normalizeBlock.d.ts +0 -3
  98. package/dist/components/ContentPage/normalizeBlock.js +0 -15
  99. package/dist/components/ContentPage/normalizeBlock.js.map +0 -1
  100. package/dist/components/ContentPage/normalizeBlock.mobile.d.ts +0 -3
  101. package/dist/components/ContentPage/normalizeBlock.mobile.js +0 -18
  102. package/dist/components/ContentPage/normalizeBlock.mobile.js.map +0 -1
  103. package/dist/components/ContentPage/normalizePage.d.ts +0 -3
  104. package/dist/components/ContentPage/normalizePage.js +0 -6
  105. package/dist/components/ContentPage/normalizePage.js.map +0 -1
  106. package/dist/components/ContentPage/toMobileBlock.d.ts +0 -2
  107. package/dist/components/ContentPage/toMobileBlock.js +0 -12
  108. package/dist/components/ContentPage/toMobileBlock.js.map +0 -1
  109. package/dist/content-page-repository/ContentPageRepository.d.ts +0 -10
  110. package/dist/content-page-repository/ContentPageRepository.js +0 -31
  111. package/dist/content-page-repository/ContentPageRepository.js.map +0 -1
  112. package/dist/content-page-repository/JSONDocContentBox.d.ts +0 -8
  113. package/dist/content-page-repository/JSONDocContentBox.js +0 -39
  114. package/dist/content-page-repository/JSONDocContentBox.js.map +0 -1
  115. package/dist/content-page-repository/TransformationOptions.d.ts +0 -4
  116. package/dist/content-page-repository/TransformationOptions.js +0 -2
  117. package/dist/content-page-repository/TransformationOptions.js.map +0 -1
  118. package/dist/content-page-repository/clearAttachmentHref.d.ts +0 -2
  119. package/dist/content-page-repository/clearAttachmentHref.js +0 -6
  120. package/dist/content-page-repository/clearAttachmentHref.js.map +0 -1
  121. package/dist/content-page-repository/computeImgOutputPath.d.ts +0 -3
  122. package/dist/content-page-repository/computeImgOutputPath.js +0 -18
  123. package/dist/content-page-repository/computeImgOutputPath.js.map +0 -1
  124. package/dist/content-page-repository/extensions.d.ts +0 -3
  125. package/dist/content-page-repository/extensions.js +0 -18
  126. package/dist/content-page-repository/extensions.js.map +0 -1
  127. package/dist/content-page-repository/index.d.ts +0 -3
  128. package/dist/content-page-repository/index.js +0 -9
  129. package/dist/content-page-repository/index.js.map +0 -1
  130. package/dist/content-page-repository/mapJSON.d.ts +0 -1
  131. package/dist/content-page-repository/mapJSON.js +0 -26
  132. package/dist/content-page-repository/mapJSON.js.map +0 -1
  133. package/dist/content-page-repository/mergePages.d.ts +0 -2
  134. package/dist/content-page-repository/mergePages.js +0 -7
  135. package/dist/content-page-repository/mergePages.js.map +0 -1
  136. package/dist/content-page-repository/replaceHeadingTags.d.ts +0 -1
  137. package/dist/content-page-repository/replaceHeadingTags.js +0 -5
  138. package/dist/content-page-repository/replaceHeadingTags.js.map +0 -1
  139. package/dist/content-page-repository/resizeImg.d.ts +0 -3
  140. package/dist/content-page-repository/resizeImg.js +0 -19
  141. package/dist/content-page-repository/resizeImg.js.map +0 -1
  142. package/dist/content-page-repository/transformAttachmentLink.d.ts +0 -3
  143. package/dist/content-page-repository/transformAttachmentLink.js +0 -40
  144. package/dist/content-page-repository/transformAttachmentLink.js.map +0 -1
  145. package/dist/content-page-repository/transformContentPage.d.ts +0 -4
  146. package/dist/content-page-repository/transformContentPage.js +0 -78
  147. package/dist/content-page-repository/transformContentPage.js.map +0 -1
  148. package/dist/content-page-repository/transformDocument.d.ts +0 -3
  149. package/dist/content-page-repository/transformDocument.js +0 -38
  150. package/dist/content-page-repository/transformDocument.js.map +0 -1
  151. package/dist/content-page-repository/transformHTML.d.ts +0 -1
  152. package/dist/content-page-repository/transformHTML.js +0 -54
  153. package/dist/content-page-repository/transformHTML.js.map +0 -1
  154. package/dist/content-page-repository/transformImg.d.ts +0 -12
  155. package/dist/content-page-repository/transformImg.js +0 -51
  156. package/dist/content-page-repository/transformImg.js.map +0 -1
  157. package/dist/content-page-repository/transformMarkdown.d.ts +0 -1
  158. package/dist/content-page-repository/transformMarkdown.js +0 -18
  159. package/dist/content-page-repository/transformMarkdown.js.map +0 -1
  160. package/dist/content-page-repository/transformPicture.d.ts +0 -3
  161. package/dist/content-page-repository/transformPicture.js +0 -28
  162. package/dist/content-page-repository/transformPicture.js.map +0 -1
  163. package/lib/components/ContentPage/computeAPIFallback.d.ts +0 -4
  164. package/lib/components/ContentPage/computeAPIFallback.js +0 -33
  165. package/lib/components/ContentPage/computeAPIFallback.js.map +0 -1
  166. package/lib/components/ContentPage/loadModuleFallback.d.ts +0 -2
  167. package/lib/components/ContentPage/loadModuleFallback.js +0 -10
  168. package/lib/components/ContentPage/loadModuleFallback.js.map +0 -1
  169. package/lib/components/ContentPage/mapSlot.d.ts +0 -2
  170. package/lib/components/ContentPage/mapSlot.js +0 -13
  171. package/lib/components/ContentPage/mapSlot.js.map +0 -1
  172. package/lib/components/ContentPage/normalizeBlock.d.ts +0 -3
  173. package/lib/components/ContentPage/normalizeBlock.js +0 -12
  174. package/lib/components/ContentPage/normalizeBlock.js.map +0 -1
  175. package/lib/components/ContentPage/normalizeBlock.mobile.d.ts +0 -3
  176. package/lib/components/ContentPage/normalizeBlock.mobile.js +0 -15
  177. package/lib/components/ContentPage/normalizeBlock.mobile.js.map +0 -1
  178. package/lib/components/ContentPage/normalizePage.d.ts +0 -3
  179. package/lib/components/ContentPage/normalizePage.js +0 -3
  180. package/lib/components/ContentPage/normalizePage.js.map +0 -1
  181. package/lib/components/ContentPage/toMobileBlock.d.ts +0 -2
  182. package/lib/components/ContentPage/toMobileBlock.js +0 -9
  183. package/lib/components/ContentPage/toMobileBlock.js.map +0 -1
  184. package/lib/content-page-repository/ContentPageRepository.d.ts +0 -10
  185. package/lib/content-page-repository/ContentPageRepository.js +0 -25
  186. package/lib/content-page-repository/ContentPageRepository.js.map +0 -1
  187. package/lib/content-page-repository/JSONDocContentBox.d.ts +0 -8
  188. package/lib/content-page-repository/JSONDocContentBox.js +0 -36
  189. package/lib/content-page-repository/JSONDocContentBox.js.map +0 -1
  190. package/lib/content-page-repository/TransformationOptions.d.ts +0 -4
  191. package/lib/content-page-repository/TransformationOptions.js +0 -2
  192. package/lib/content-page-repository/TransformationOptions.js.map +0 -1
  193. package/lib/content-page-repository/clearAttachmentHref.d.ts +0 -2
  194. package/lib/content-page-repository/clearAttachmentHref.js +0 -3
  195. package/lib/content-page-repository/clearAttachmentHref.js.map +0 -1
  196. package/lib/content-page-repository/computeImgOutputPath.d.ts +0 -3
  197. package/lib/content-page-repository/computeImgOutputPath.js +0 -12
  198. package/lib/content-page-repository/computeImgOutputPath.js.map +0 -1
  199. package/lib/content-page-repository/extensions.d.ts +0 -3
  200. package/lib/content-page-repository/extensions.js +0 -16
  201. package/lib/content-page-repository/extensions.js.map +0 -1
  202. package/lib/content-page-repository/index.d.ts +0 -3
  203. package/lib/content-page-repository/index.js +0 -4
  204. package/lib/content-page-repository/index.js.map +0 -1
  205. package/lib/content-page-repository/mapJSON.d.ts +0 -1
  206. package/lib/content-page-repository/mapJSON.js +0 -23
  207. package/lib/content-page-repository/mapJSON.js.map +0 -1
  208. package/lib/content-page-repository/mergePages.d.ts +0 -2
  209. package/lib/content-page-repository/mergePages.js +0 -4
  210. package/lib/content-page-repository/mergePages.js.map +0 -1
  211. package/lib/content-page-repository/replaceHeadingTags.d.ts +0 -1
  212. package/lib/content-page-repository/replaceHeadingTags.js +0 -2
  213. package/lib/content-page-repository/replaceHeadingTags.js.map +0 -1
  214. package/lib/content-page-repository/resizeImg.d.ts +0 -3
  215. package/lib/content-page-repository/resizeImg.js +0 -13
  216. package/lib/content-page-repository/resizeImg.js.map +0 -1
  217. package/lib/content-page-repository/transformAttachmentLink.d.ts +0 -3
  218. package/lib/content-page-repository/transformAttachmentLink.js +0 -34
  219. package/lib/content-page-repository/transformAttachmentLink.js.map +0 -1
  220. package/lib/content-page-repository/transformContentPage.d.ts +0 -4
  221. package/lib/content-page-repository/transformContentPage.js +0 -71
  222. package/lib/content-page-repository/transformContentPage.js.map +0 -1
  223. package/lib/content-page-repository/transformDocument.d.ts +0 -3
  224. package/lib/content-page-repository/transformDocument.js +0 -32
  225. package/lib/content-page-repository/transformDocument.js.map +0 -1
  226. package/lib/content-page-repository/transformHTML.d.ts +0 -1
  227. package/lib/content-page-repository/transformHTML.js +0 -25
  228. package/lib/content-page-repository/transformHTML.js.map +0 -1
  229. package/lib/content-page-repository/transformImg.d.ts +0 -12
  230. package/lib/content-page-repository/transformImg.js +0 -45
  231. package/lib/content-page-repository/transformImg.js.map +0 -1
  232. package/lib/content-page-repository/transformMarkdown.d.ts +0 -1
  233. package/lib/content-page-repository/transformMarkdown.js +0 -12
  234. package/lib/content-page-repository/transformMarkdown.js.map +0 -1
  235. package/lib/content-page-repository/transformPicture.d.ts +0 -3
  236. package/lib/content-page-repository/transformPicture.js +0 -22
  237. package/lib/content-page-repository/transformPicture.js.map +0 -1
  238. package/mobile/bundle/components/ContentPage/computeAPIFallback.d.ts +0 -4
  239. package/mobile/bundle/components/ContentPage/loadModuleFallback.d.ts +0 -2
  240. package/mobile/bundle/components/ContentPage/mapSlot.d.ts +0 -2
  241. package/mobile/bundle/components/ContentPage/normalizeBlock.d.ts +0 -3
  242. package/mobile/bundle/components/ContentPage/normalizePage.d.ts +0 -3
  243. package/mobile/bundle/components/ContentPage/toMobileBlock.d.ts +0 -2
  244. package/mobile/bundle/content-page-repository/ContentPageRepository.d.ts +0 -10
  245. package/mobile/bundle/content-page-repository/JSONDocContentBox.d.ts +0 -8
  246. package/mobile/bundle/content-page-repository/TransformationOptions.d.ts +0 -4
  247. package/mobile/bundle/content-page-repository/clearAttachmentHref.d.ts +0 -2
  248. package/mobile/bundle/content-page-repository/computeImgOutputPath.d.ts +0 -3
  249. package/mobile/bundle/content-page-repository/extensions.d.ts +0 -3
  250. package/mobile/bundle/content-page-repository/index.d.ts +0 -3
  251. package/mobile/bundle/content-page-repository/mapJSON.d.ts +0 -1
  252. package/mobile/bundle/content-page-repository/mergePages.d.ts +0 -2
  253. package/mobile/bundle/content-page-repository/replaceHeadingTags.d.ts +0 -1
  254. package/mobile/bundle/content-page-repository/resizeImg.d.ts +0 -3
  255. package/mobile/bundle/content-page-repository/transformAttachmentLink.d.ts +0 -3
  256. package/mobile/bundle/content-page-repository/transformContentPage.d.ts +0 -4
  257. package/mobile/bundle/content-page-repository/transformDocument.d.ts +0 -3
  258. package/mobile/bundle/content-page-repository/transformHTML.d.ts +0 -1
  259. package/mobile/bundle/content-page-repository/transformImg.d.ts +0 -12
  260. package/mobile/bundle/content-page-repository/transformMarkdown.d.ts +0 -1
  261. package/mobile/bundle/content-page-repository/transformPicture.d.ts +0 -3
  262. package/mobile/dist/components/ContentPage/computeAPIFallback.d.ts +0 -4
  263. package/mobile/dist/components/ContentPage/computeAPIFallback.js +0 -36
  264. package/mobile/dist/components/ContentPage/computeAPIFallback.js.map +0 -1
  265. package/mobile/dist/components/ContentPage/loadModuleFallback.d.ts +0 -2
  266. package/mobile/dist/components/ContentPage/loadModuleFallback.js +0 -36
  267. package/mobile/dist/components/ContentPage/loadModuleFallback.js.map +0 -1
  268. package/mobile/dist/components/ContentPage/mapSlot.d.ts +0 -2
  269. package/mobile/dist/components/ContentPage/mapSlot.js +0 -16
  270. package/mobile/dist/components/ContentPage/mapSlot.js.map +0 -1
  271. package/mobile/dist/components/ContentPage/normalizeBlock.d.ts +0 -3
  272. package/mobile/dist/components/ContentPage/normalizeBlock.js +0 -18
  273. package/mobile/dist/components/ContentPage/normalizeBlock.js.map +0 -1
  274. package/mobile/dist/components/ContentPage/normalizePage.d.ts +0 -3
  275. package/mobile/dist/components/ContentPage/normalizePage.js +0 -6
  276. package/mobile/dist/components/ContentPage/normalizePage.js.map +0 -1
  277. package/mobile/dist/components/ContentPage/toMobileBlock.d.ts +0 -2
  278. package/mobile/dist/components/ContentPage/toMobileBlock.js +0 -12
  279. package/mobile/dist/components/ContentPage/toMobileBlock.js.map +0 -1
  280. package/mobile/dist/content-page-repository/ContentPageRepository.d.ts +0 -10
  281. package/mobile/dist/content-page-repository/ContentPageRepository.js +0 -31
  282. package/mobile/dist/content-page-repository/ContentPageRepository.js.map +0 -1
  283. package/mobile/dist/content-page-repository/JSONDocContentBox.d.ts +0 -8
  284. package/mobile/dist/content-page-repository/JSONDocContentBox.js +0 -39
  285. package/mobile/dist/content-page-repository/JSONDocContentBox.js.map +0 -1
  286. package/mobile/dist/content-page-repository/TransformationOptions.d.ts +0 -4
  287. package/mobile/dist/content-page-repository/TransformationOptions.js +0 -2
  288. package/mobile/dist/content-page-repository/TransformationOptions.js.map +0 -1
  289. package/mobile/dist/content-page-repository/clearAttachmentHref.d.ts +0 -2
  290. package/mobile/dist/content-page-repository/clearAttachmentHref.js +0 -6
  291. package/mobile/dist/content-page-repository/clearAttachmentHref.js.map +0 -1
  292. package/mobile/dist/content-page-repository/computeImgOutputPath.d.ts +0 -3
  293. package/mobile/dist/content-page-repository/computeImgOutputPath.js +0 -18
  294. package/mobile/dist/content-page-repository/computeImgOutputPath.js.map +0 -1
  295. package/mobile/dist/content-page-repository/extensions.d.ts +0 -3
  296. package/mobile/dist/content-page-repository/extensions.js +0 -18
  297. package/mobile/dist/content-page-repository/extensions.js.map +0 -1
  298. package/mobile/dist/content-page-repository/index.d.ts +0 -3
  299. package/mobile/dist/content-page-repository/index.js +0 -9
  300. package/mobile/dist/content-page-repository/index.js.map +0 -1
  301. package/mobile/dist/content-page-repository/mapJSON.d.ts +0 -1
  302. package/mobile/dist/content-page-repository/mapJSON.js +0 -26
  303. package/mobile/dist/content-page-repository/mapJSON.js.map +0 -1
  304. package/mobile/dist/content-page-repository/mergePages.d.ts +0 -2
  305. package/mobile/dist/content-page-repository/mergePages.js +0 -7
  306. package/mobile/dist/content-page-repository/mergePages.js.map +0 -1
  307. package/mobile/dist/content-page-repository/replaceHeadingTags.d.ts +0 -1
  308. package/mobile/dist/content-page-repository/replaceHeadingTags.js +0 -5
  309. package/mobile/dist/content-page-repository/replaceHeadingTags.js.map +0 -1
  310. package/mobile/dist/content-page-repository/resizeImg.d.ts +0 -3
  311. package/mobile/dist/content-page-repository/resizeImg.js +0 -19
  312. package/mobile/dist/content-page-repository/resizeImg.js.map +0 -1
  313. package/mobile/dist/content-page-repository/transformAttachmentLink.d.ts +0 -3
  314. package/mobile/dist/content-page-repository/transformAttachmentLink.js +0 -40
  315. package/mobile/dist/content-page-repository/transformAttachmentLink.js.map +0 -1
  316. package/mobile/dist/content-page-repository/transformContentPage.d.ts +0 -4
  317. package/mobile/dist/content-page-repository/transformContentPage.js +0 -78
  318. package/mobile/dist/content-page-repository/transformContentPage.js.map +0 -1
  319. package/mobile/dist/content-page-repository/transformDocument.d.ts +0 -3
  320. package/mobile/dist/content-page-repository/transformDocument.js +0 -38
  321. package/mobile/dist/content-page-repository/transformDocument.js.map +0 -1
  322. package/mobile/dist/content-page-repository/transformHTML.d.ts +0 -1
  323. package/mobile/dist/content-page-repository/transformHTML.js +0 -54
  324. package/mobile/dist/content-page-repository/transformHTML.js.map +0 -1
  325. package/mobile/dist/content-page-repository/transformImg.d.ts +0 -12
  326. package/mobile/dist/content-page-repository/transformImg.js +0 -51
  327. package/mobile/dist/content-page-repository/transformImg.js.map +0 -1
  328. package/mobile/dist/content-page-repository/transformMarkdown.d.ts +0 -1
  329. package/mobile/dist/content-page-repository/transformMarkdown.js +0 -18
  330. package/mobile/dist/content-page-repository/transformMarkdown.js.map +0 -1
  331. package/mobile/dist/content-page-repository/transformPicture.d.ts +0 -3
  332. package/mobile/dist/content-page-repository/transformPicture.js +0 -28
  333. package/mobile/dist/content-page-repository/transformPicture.js.map +0 -1
  334. package/mobile/lib/components/ContentPage/computeAPIFallback.d.ts +0 -4
  335. package/mobile/lib/components/ContentPage/computeAPIFallback.js +0 -33
  336. package/mobile/lib/components/ContentPage/computeAPIFallback.js.map +0 -1
  337. package/mobile/lib/components/ContentPage/loadModuleFallback.d.ts +0 -2
  338. package/mobile/lib/components/ContentPage/loadModuleFallback.js +0 -10
  339. package/mobile/lib/components/ContentPage/loadModuleFallback.js.map +0 -1
  340. package/mobile/lib/components/ContentPage/mapSlot.d.ts +0 -2
  341. package/mobile/lib/components/ContentPage/mapSlot.js +0 -13
  342. package/mobile/lib/components/ContentPage/mapSlot.js.map +0 -1
  343. package/mobile/lib/components/ContentPage/normalizeBlock.d.ts +0 -3
  344. package/mobile/lib/components/ContentPage/normalizeBlock.js +0 -15
  345. package/mobile/lib/components/ContentPage/normalizeBlock.js.map +0 -1
  346. package/mobile/lib/components/ContentPage/normalizePage.d.ts +0 -3
  347. package/mobile/lib/components/ContentPage/normalizePage.js +0 -3
  348. package/mobile/lib/components/ContentPage/normalizePage.js.map +0 -1
  349. package/mobile/lib/components/ContentPage/toMobileBlock.d.ts +0 -2
  350. package/mobile/lib/components/ContentPage/toMobileBlock.js +0 -9
  351. package/mobile/lib/components/ContentPage/toMobileBlock.js.map +0 -1
  352. package/mobile/lib/content-page-repository/ContentPageRepository.d.ts +0 -10
  353. package/mobile/lib/content-page-repository/ContentPageRepository.js +0 -25
  354. package/mobile/lib/content-page-repository/ContentPageRepository.js.map +0 -1
  355. package/mobile/lib/content-page-repository/JSONDocContentBox.d.ts +0 -8
  356. package/mobile/lib/content-page-repository/JSONDocContentBox.js +0 -36
  357. package/mobile/lib/content-page-repository/JSONDocContentBox.js.map +0 -1
  358. package/mobile/lib/content-page-repository/TransformationOptions.d.ts +0 -4
  359. package/mobile/lib/content-page-repository/TransformationOptions.js +0 -2
  360. package/mobile/lib/content-page-repository/TransformationOptions.js.map +0 -1
  361. package/mobile/lib/content-page-repository/clearAttachmentHref.d.ts +0 -2
  362. package/mobile/lib/content-page-repository/clearAttachmentHref.js +0 -3
  363. package/mobile/lib/content-page-repository/clearAttachmentHref.js.map +0 -1
  364. package/mobile/lib/content-page-repository/computeImgOutputPath.d.ts +0 -3
  365. package/mobile/lib/content-page-repository/computeImgOutputPath.js +0 -12
  366. package/mobile/lib/content-page-repository/computeImgOutputPath.js.map +0 -1
  367. package/mobile/lib/content-page-repository/extensions.d.ts +0 -3
  368. package/mobile/lib/content-page-repository/extensions.js +0 -16
  369. package/mobile/lib/content-page-repository/extensions.js.map +0 -1
  370. package/mobile/lib/content-page-repository/index.d.ts +0 -3
  371. package/mobile/lib/content-page-repository/index.js +0 -4
  372. package/mobile/lib/content-page-repository/index.js.map +0 -1
  373. package/mobile/lib/content-page-repository/mapJSON.d.ts +0 -1
  374. package/mobile/lib/content-page-repository/mapJSON.js +0 -23
  375. package/mobile/lib/content-page-repository/mapJSON.js.map +0 -1
  376. package/mobile/lib/content-page-repository/mergePages.d.ts +0 -2
  377. package/mobile/lib/content-page-repository/mergePages.js +0 -4
  378. package/mobile/lib/content-page-repository/mergePages.js.map +0 -1
  379. package/mobile/lib/content-page-repository/replaceHeadingTags.d.ts +0 -1
  380. package/mobile/lib/content-page-repository/replaceHeadingTags.js +0 -2
  381. package/mobile/lib/content-page-repository/replaceHeadingTags.js.map +0 -1
  382. package/mobile/lib/content-page-repository/resizeImg.d.ts +0 -3
  383. package/mobile/lib/content-page-repository/resizeImg.js +0 -13
  384. package/mobile/lib/content-page-repository/resizeImg.js.map +0 -1
  385. package/mobile/lib/content-page-repository/transformAttachmentLink.d.ts +0 -3
  386. package/mobile/lib/content-page-repository/transformAttachmentLink.js +0 -34
  387. package/mobile/lib/content-page-repository/transformAttachmentLink.js.map +0 -1
  388. package/mobile/lib/content-page-repository/transformContentPage.d.ts +0 -4
  389. package/mobile/lib/content-page-repository/transformContentPage.js +0 -71
  390. package/mobile/lib/content-page-repository/transformContentPage.js.map +0 -1
  391. package/mobile/lib/content-page-repository/transformDocument.d.ts +0 -3
  392. package/mobile/lib/content-page-repository/transformDocument.js +0 -32
  393. package/mobile/lib/content-page-repository/transformDocument.js.map +0 -1
  394. package/mobile/lib/content-page-repository/transformHTML.d.ts +0 -1
  395. package/mobile/lib/content-page-repository/transformHTML.js +0 -25
  396. package/mobile/lib/content-page-repository/transformHTML.js.map +0 -1
  397. package/mobile/lib/content-page-repository/transformImg.d.ts +0 -12
  398. package/mobile/lib/content-page-repository/transformImg.js +0 -45
  399. package/mobile/lib/content-page-repository/transformImg.js.map +0 -1
  400. package/mobile/lib/content-page-repository/transformMarkdown.d.ts +0 -1
  401. package/mobile/lib/content-page-repository/transformMarkdown.js +0 -12
  402. package/mobile/lib/content-page-repository/transformMarkdown.js.map +0 -1
  403. package/mobile/lib/content-page-repository/transformPicture.d.ts +0 -3
  404. package/mobile/lib/content-page-repository/transformPicture.js +0 -22
  405. package/mobile/lib/content-page-repository/transformPicture.js.map +0 -1
  406. package/mobile/src/components/ContentPage/computeAPIFallback.ts +0 -67
  407. package/mobile/src/components/ContentPage/loadModuleFallback.ts +0 -11
  408. package/mobile/src/components/ContentPage/mapSlot.ts +0 -18
  409. package/mobile/src/components/ContentPage/normalizeBlock.ts +0 -25
  410. package/mobile/src/components/ContentPage/normalizePage.ts +0 -8
  411. package/mobile/src/components/ContentPage/toMobileBlock.ts +0 -11
  412. package/mobile/src/content-page-repository/ContentPageRepository.ts +0 -31
  413. package/mobile/src/content-page-repository/JSONDocContentBox.ts +0 -56
  414. package/mobile/src/content-page-repository/TransformationOptions.ts +0 -4
  415. package/mobile/src/content-page-repository/clearAttachmentHref.ts +0 -3
  416. package/mobile/src/content-page-repository/computeImgOutputPath.ts +0 -21
  417. package/mobile/src/content-page-repository/extensions.ts +0 -17
  418. package/mobile/src/content-page-repository/index.ts +0 -3
  419. package/mobile/src/content-page-repository/mapJSON.ts +0 -30
  420. package/mobile/src/content-page-repository/mergePages.ts +0 -8
  421. package/mobile/src/content-page-repository/replaceHeadingTags.ts +0 -2
  422. package/mobile/src/content-page-repository/resizeImg.ts +0 -17
  423. package/mobile/src/content-page-repository/transformAttachmentLink.ts +0 -46
  424. package/mobile/src/content-page-repository/transformContentPage.ts +0 -102
  425. package/mobile/src/content-page-repository/transformDocument.ts +0 -43
  426. package/mobile/src/content-page-repository/transformHTML.ts +0 -28
  427. package/mobile/src/content-page-repository/transformImg.ts +0 -81
  428. package/mobile/src/content-page-repository/transformMarkdown.ts +0 -14
  429. package/mobile/src/content-page-repository/transformPicture.ts +0 -35
  430. package/src/components/ContentPage/computeAPIFallback.ts +0 -67
  431. package/src/components/ContentPage/loadModuleFallback.ts +0 -11
  432. package/src/components/ContentPage/mapSlot.ts +0 -18
  433. package/src/components/ContentPage/normalizeBlock.mobile.ts +0 -25
  434. package/src/components/ContentPage/normalizeBlock.ts +0 -21
  435. package/src/components/ContentPage/normalizePage.ts +0 -8
  436. package/src/components/ContentPage/toMobileBlock.ts +0 -11
  437. package/src/content-page-repository/ContentPageRepository.ts +0 -31
  438. package/src/content-page-repository/JSONDocContentBox.ts +0 -56
  439. package/src/content-page-repository/TransformationOptions.ts +0 -4
  440. package/src/content-page-repository/clearAttachmentHref.ts +0 -3
  441. package/src/content-page-repository/computeImgOutputPath.ts +0 -21
  442. package/src/content-page-repository/extensions.ts +0 -17
  443. package/src/content-page-repository/index.ts +0 -3
  444. package/src/content-page-repository/mapJSON.ts +0 -30
  445. package/src/content-page-repository/mergePages.ts +0 -8
  446. package/src/content-page-repository/replaceHeadingTags.ts +0 -2
  447. package/src/content-page-repository/resizeImg.ts +0 -17
  448. package/src/content-page-repository/transformAttachmentLink.ts +0 -46
  449. package/src/content-page-repository/transformContentPage.ts +0 -102
  450. package/src/content-page-repository/transformDocument.ts +0 -43
  451. package/src/content-page-repository/transformHTML.ts +0 -28
  452. package/src/content-page-repository/transformImg.ts +0 -81
  453. package/src/content-page-repository/transformMarkdown.ts +0 -14
  454. package/src/content-page-repository/transformPicture.ts +0 -35
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformPicture.js","sourceRoot":"","sources":["../../src/content-page-repository/transformPicture.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgB,EAChB,QAAgB,EAChB,OAA8B;IAE9B,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IAE/B,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEzF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrE,MAAM,aAAa,GAAG,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEtE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC1C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CACrF,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IAExF,OAAO;QACL,GAAG,OAAO;QACV,GAAG,EAAE,YAAY,CAAC,kBAAkB,CAAC;QACrC,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACzC,GAAG,OAAO,CAAC,CAAC,CAAC;YACb,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;YACpB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;SACxB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -1,67 +0,0 @@
1
- import { type JSONNode } from '@redneckz/json-op';
2
- import { collectRef, resolveJPointer } from '@redneckz/json-ref';
3
- import { ContentPageRepository } from '../../content-page-repository/ContentPageRepository';
4
- import { type BlocksRegistry } from '../../model/BlocksRegistry';
5
- import { type ContentPageDef } from '../../model/ContentPageDef';
6
- import { type Fallback, type FallbackMap } from '../../model/Fallback';
7
- import { unique } from '../../utils/unique';
8
- import { joinPath } from '../../utils/url';
9
- import { loadModuleFallback } from './loadModuleFallback';
10
-
11
- type FallbackEntry = [key: string, data: JSONNode];
12
-
13
- const BASE_DIR = 'content';
14
-
15
- export const computeAPIFallback = async (
16
- blocksRegistry: BlocksRegistry,
17
- contentPageData: ContentPageDef,
18
- ): Promise<Fallback> => {
19
- return Object.fromEntries(
20
- (
21
- await Promise.all([
22
- computeFallbackFromModules(blocksRegistry),
23
- computeFallbackFromContentRefs(contentPageData),
24
- ])
25
- )
26
- .flatMap((_) => _)
27
- .filter(([key, data]) => key && data),
28
- );
29
- };
30
-
31
- const computeFallbackFromModules = async (
32
- blocksRegistry: BlocksRegistry,
33
- ): Promise<FallbackEntry[]> => {
34
- const fallbackMap: FallbackMap = (
35
- await Promise.all(Object.keys(blocksRegistry).map(loadModuleFallback))
36
- )
37
- .filter((_): _ is FallbackMap => Boolean(_))
38
- .reduce((acc, _) => ({ ...acc, ..._ }), {});
39
-
40
- return (
41
- await Promise.allSettled(
42
- Object.entries(fallbackMap).map(
43
- async ([key, fetcher]): Promise<FallbackEntry> => [key, await fetcher()],
44
- ),
45
- )
46
- )
47
- .filter((_): _ is PromiseFulfilledResult<FallbackEntry> => _.status === 'fulfilled')
48
- .map(({ value }) => value);
49
- };
50
-
51
- const computeFallbackFromContentRefs = async (
52
- contentPageData: ContentPageDef,
53
- ): Promise<FallbackEntry[]> => {
54
- const refs = unique(collectRef(contentPageData as JSONNode));
55
-
56
- return (
57
- await Promise.allSettled(
58
- refs.map(async (_) => [
59
- _,
60
- (await ContentPageRepository.inst.generatePage(joinPath(BASE_DIR, _))) as JSONNode,
61
- ]),
62
- )
63
- )
64
- .filter((_): _ is PromiseFulfilledResult<FallbackEntry> => _.status === 'fulfilled')
65
- .map(({ value }) => value)
66
- .map(([ref, data]) => [ref, resolveJPointer(data, ref)]);
67
- };
@@ -1,11 +0,0 @@
1
- import { type FallbackMap } from '../../model/Fallback';
2
-
3
- export const loadModuleFallback = async (blockName: string): Promise<FallbackMap | undefined> => {
4
- try {
5
- const blockFallback = await import(`../${blockName}/${blockName}.fallback`);
6
-
7
- return blockFallback?.fallback ? await blockFallback.fallback() : undefined;
8
- } catch (error) {
9
- return undefined;
10
- }
11
- };
@@ -1,18 +0,0 @@
1
- import { type BlockDef, type Slot } from '../../model/ContentPageDef';
2
-
3
- export const mapSlot =
4
- (mapper: (blocks?: BlockDef[]) => BlockDef[]) =>
5
- <S extends Slot>(slot: S): S => ({
6
- ...slot,
7
- ...(slot.blocks ? { blocks: mapper(slot.blocks) } : {}),
8
- ...(slot.slots
9
- ? {
10
- slots: Object.fromEntries(
11
- Object.entries(slot.slots).map(([slotKey, slotBlocks]) => [
12
- slotKey,
13
- mapper(slotBlocks),
14
- ]),
15
- ),
16
- }
17
- : {}),
18
- });
@@ -1,25 +0,0 @@
1
- import { type BlocksRegistry } from '../../model/BlocksRegistry';
2
- import { type BlockDef, type Slot } from '../../model/ContentPageDef';
3
- import { mapSlot } from './mapSlot';
4
- import { toMobileBlock } from './toMobileBlock';
5
-
6
- export function normalizeBlock<S extends Slot>(block?: S, blocksRegistry?: BlocksRegistry): S {
7
- const { mobile } = (block || {}) as BlockDef;
8
-
9
- return mapSlot(filterBlocks(blocksRegistry))((mobile ? toMobileBlock(block) : block) || {}) as S;
10
- }
11
-
12
- const filterBlocks =
13
- (blocksRegistry?: BlocksRegistry) =>
14
- (blocks?: BlockDef[]): BlockDef[] =>
15
- blocks
16
- ? blocks
17
- ?.filter(
18
- (block) =>
19
- blocksRegistry &&
20
- (block?.type || block?.mobile?.type || '') in blocksRegistry &&
21
- !block.mobile?.hidden &&
22
- !block?.hidden,
23
- )
24
- .map((block) => normalizeBlock(block, blocksRegistry))
25
- : [];
@@ -1,8 +0,0 @@
1
- import { type BlocksRegistry } from '../../model/BlocksRegistry';
2
- import { type ContentPageDef } from '../../model/ContentPageDef';
3
- import { normalizeBlock } from './normalizeBlock';
4
-
5
- export const normalizePage =
6
- (blocksRegistry: BlocksRegistry) =>
7
- (contentPage: ContentPageDef | undefined | null): ContentPageDef =>
8
- contentPage ? normalizeBlock(contentPage, blocksRegistry) : {};
@@ -1,11 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
-
3
- export function toMobileBlock(block: BlockDef = {}): BlockDef {
4
- const { mobile, ...desktop } = block;
5
-
6
- return {
7
- ...desktop,
8
- ...(mobile?.style ? { style: mobile.style } : {}),
9
- ...(mobile?.content ? { content: mobile.content } : {}),
10
- };
11
- }
@@ -1,31 +0,0 @@
1
- import fs from 'fs';
2
- import { glob } from 'glob';
3
- import util from 'util';
4
- import { type ContentPageDef } from '../model/ContentPageDef';
5
- import { type TransformationOptions } from './TransformationOptions';
6
- import { generatedPagePath, transformContentPage } from './transformContentPage';
7
-
8
- const readFile = util.promisify(fs.readFile);
9
-
10
- export class ContentPageRepository {
11
- public static readonly inst = new ContentPageRepository();
12
-
13
- constructor(
14
- private readonly options: TransformationOptions = {
15
- contentDir: 'content',
16
- publicDir: 'public',
17
- },
18
- ) {}
19
-
20
- listAllContentPages(): Promise<string[]> {
21
- return glob(`${this.options.contentDir}/**/*.page.json`, { posix: true });
22
- }
23
-
24
- async readPage(filePath: string): Promise<ContentPageDef> {
25
- return JSON.parse(await readFile(generatedPagePath(filePath), 'utf-8'));
26
- }
27
-
28
- generatePage(filePath: string): Promise<ContentPageDef> {
29
- return transformContentPage(filePath, this.options);
30
- }
31
- }
@@ -1,56 +0,0 @@
1
- import {
2
- isJSONArray,
3
- isJSONRecord,
4
- JSONBoxDefault,
5
- type JSONBox,
6
- type JSONNode,
7
- type JSONRecord,
8
- } from '@redneckz/json-op';
9
- import { type JSONPathElement } from '@redneckz/json-op/lib/JSONPath';
10
-
11
- const isAtomicArray = (node: JSONNode | undefined): boolean =>
12
- isJSONArray(node) && !node.some(nodeId);
13
-
14
- const ID_PREFIX = 'id:';
15
-
16
- const nodeId = (node: JSONNode | undefined): string | undefined =>
17
- isJSONRecord(node) && '__id' in node ? (node.__id as string) : undefined;
18
-
19
- const keyToId = (p: JSONPathElement | undefined): string | undefined =>
20
- typeof p === 'string' && p.startsWith(ID_PREFIX) ? p.substring(ID_PREFIX.length) : undefined;
21
-
22
- const findIndexById = (_: JSONNode | undefined, id: string | undefined): number | -1 =>
23
- id && isJSONArray(_) ? _.findIndex((node) => id === nodeId(node)) : -1;
24
-
25
- export class JSONDocContentBox extends JSONBoxDefault {
26
- size(): number {
27
- return isAtomicArray(this._) ? 0 : super.size();
28
- }
29
-
30
- entries(): Array<[p: JSONPathElement, child: JSONBox]> {
31
- if (isAtomicArray(this._)) {
32
- return [];
33
- } else if (isJSONArray(this._)) {
34
- return this._.map((node, i) => [
35
- nodeId(node) ? `${ID_PREFIX}${nodeId(node)}` : i,
36
- new JSONDocContentBox(node),
37
- ]);
38
- } else {
39
- return super.entries();
40
- }
41
- }
42
-
43
- get(p?: JSONPathElement): JSONBox {
44
- const id = keyToId(p);
45
-
46
- return super.get(id ? findIndexById(this._, id) : p);
47
- }
48
-
49
- set(p: JSONPathElement | undefined, child: JSONNode): JSONBox {
50
- const id = keyToId(p);
51
- const index = findIndexById(this._, id);
52
- const adjustedIndex = index >= 0 ? index : this.size();
53
-
54
- return super.set(id ? adjustedIndex : p, id ? { ...(child as JSONRecord), __id: id } : child);
55
- }
56
- }
@@ -1,4 +0,0 @@
1
- export interface TransformationOptions {
2
- contentDir: string;
3
- publicDir: string;
4
- }
@@ -1,3 +0,0 @@
1
- export const ATTACHMENT_PREFIX = 'file://';
2
-
3
- export const clearAttachmentHref = (href: string): string => href.replace(ATTACHMENT_PREFIX, '');
@@ -1,21 +0,0 @@
1
- import path from 'path';
2
- import { type ImgSource } from '../model/Picture';
3
- import { type TransformationOptions } from './TransformationOptions';
4
-
5
- export function computeImgOutputPath(
6
- imgInputPath: string,
7
- { contentDir, publicDir, format, size }: TransformationOptions & ImgSource,
8
- withoutTransform = false,
9
- ): string {
10
- const imgRelativePath = path.relative(contentDir, imgInputPath);
11
-
12
- const imgDir = path.dirname(imgRelativePath);
13
-
14
- const inputExt = path.extname(imgRelativePath);
15
- const fileName = path.basename(imgRelativePath, inputExt);
16
- const suffixParts = [size?.width, size?.height].filter(Boolean);
17
- const suffix = suffixParts.length && !withoutTransform ? `-${suffixParts.join('-')}` : '';
18
- const ext = format && !withoutTransform ? `.${format}` : inputExt;
19
-
20
- return path.join(publicDir, imgDir, `${fileName}${suffix}${ext}`);
21
- }
@@ -1,17 +0,0 @@
1
- export const OUTPUT_SUFFIX = '.static';
2
-
3
- export const DOCUMENT_EXT_LIST = [
4
- '.txt',
5
- '.doc',
6
- '.docx',
7
- '.xls',
8
- '.xlsx',
9
- '.xlsb',
10
- '.ppt',
11
- '.pptx',
12
- '.pdf',
13
- '.zip',
14
- '.7z',
15
- ];
16
-
17
- export const IMAGE_EXT_LIST = ['.jpeg', '.jpg', '.png', '.gif', '.webp', '.heif', '.avif', '.svg'];
@@ -1,3 +0,0 @@
1
- export { clearAttachmentHref } from './clearAttachmentHref';
2
- export { ContentPageRepository } from './ContentPageRepository';
3
- export { transformContentPage } from './transformContentPage';
@@ -1,30 +0,0 @@
1
- export async function mapJSON<T>(
2
- data: T,
3
- mapper: <In, Out = In>(value: In, key: string[]) => Promise<Out>,
4
- keyParts: string[] = [],
5
- ): Promise<T> {
6
- if (data === null || data === undefined) {
7
- return data;
8
- }
9
-
10
- const mappedData = await mapper(data, keyParts);
11
- if (mappedData !== data) {
12
- return mappedData as T;
13
- }
14
-
15
- if (Array.isArray(data)) {
16
- const values = data.map((_, i) => mapJSON(_, mapper, [String(i)].concat(keyParts)));
17
-
18
- return Promise.all(values) as any;
19
- } else if (typeof data === 'object' && (data as any).toString() === '[object Object]') {
20
- const subKeys = Object.keys(data);
21
- const values = subKeys.map((k) => mapJSON(data[k], mapper, [k].concat(keyParts)));
22
- const pairs = (await Promise.all(values)).map((_, i) => ({
23
- [subKeys[i]]: _,
24
- }));
25
-
26
- return Object.assign({}, ...pairs);
27
- }
28
-
29
- return mapper<T>(data, keyParts);
30
- }
@@ -1,8 +0,0 @@
1
- import { leafs, merge, type JSONRecord } from '@redneckz/json-op';
2
- import { JSONDocContentBox } from './JSONDocContentBox';
3
-
4
- export const mergePages = (page: JSONRecord, diffs: JSONRecord): JSONRecord =>
5
- merge(
6
- new JSONDocContentBox(page as JSONRecord),
7
- leafs(new JSONDocContentBox(diffs as JSONRecord)),
8
- ) as JSONRecord;
@@ -1,2 +0,0 @@
1
- export const replaceHeadingTags = (html: string) =>
2
- html.replaceAll(/<h(\d)>(.*?)<\/h\d>/g, '<p class="h$1">$2</p>');
@@ -1,17 +0,0 @@
1
- import sharp, { type ResizeOptions, type Sharp } from 'sharp';
2
- import { type ImageSize } from '../model/ImageSize';
3
-
4
- export const resizeImg =
5
- (size?: Partial<ImageSize>, options?: ResizeOptions) =>
6
- (chain: Sharp): Sharp =>
7
- size
8
- ? chain.resize(size.width || null, size.height || null, {
9
- /*
10
- * Editor behaviour with one dimension present: resize by given dimension maintaining aspect ratio. (fit: contain)
11
- * With two dimensions present: resize trying to fill given dimensions (fit: fill)
12
- */
13
- fit: size.width && size.height ? sharp.fit.fill : sharp.fit.contain,
14
- background: { r: 0, g: 0, b: 0, alpha: 0 },
15
- ...options,
16
- })
17
- : chain;
@@ -1,46 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import util from 'util';
4
- import { type LinkProps } from '../model/LinkProps';
5
- import { isUUID } from '../utils/isUUID';
6
- import { clearAttachmentHref } from './clearAttachmentHref';
7
- import { type TransformationOptions } from './TransformationOptions';
8
-
9
- const mkdir = util.promisify(fs.mkdir);
10
- const copyFile = util.promisify(fs.copyFile);
11
-
12
- export async function transformAttachmentLink(
13
- link: LinkProps,
14
- pagePath: string,
15
- options: TransformationOptions,
16
- ): Promise<LinkProps> {
17
- if (!link?.href) {
18
- return link;
19
- }
20
-
21
- try {
22
- return {
23
- ...link,
24
- href: await transformHref(clearAttachmentHref(link.href), options),
25
- };
26
- } catch (e) {
27
- console.info(`No "${link.href}" attachment found on page: "${pagePath}"`);
28
-
29
- return link;
30
- }
31
- }
32
-
33
- async function transformHref(input: string, options: TransformationOptions) {
34
- if (isUUID(input)) {
35
- return input;
36
- }
37
-
38
- const { contentDir, publicDir } = options;
39
- const docRelativePath = path.relative(contentDir, input);
40
- const output = path.join(publicDir, docRelativePath);
41
-
42
- await mkdir(path.dirname(output), { recursive: true });
43
- await copyFile(input, output);
44
-
45
- return path.join('/', docRelativePath);
46
- }
@@ -1,102 +0,0 @@
1
- import { type JSONRecord } from '@redneckz/json-op';
2
- import fs from 'fs';
3
- import util from 'util';
4
- import { type Attachment } from '../model/Attachment';
5
- import { type ContentPageDef } from '../model/ContentPageDef';
6
- import { type LinkProps } from '../model/LinkProps';
7
- import { type Picture } from '../model/Picture';
8
- import { isUUID } from '../utils/isUUID';
9
- import { tableFunc } from '../utils/tableFunc';
10
- import { ATTACHMENT_PREFIX } from './clearAttachmentHref';
11
- import { DOCUMENT_EXT_LIST, IMAGE_EXT_LIST, OUTPUT_SUFFIX } from './extensions';
12
- import { mapJSON } from './mapJSON';
13
- import { mergePages } from './mergePages';
14
- import { type TransformationOptions } from './TransformationOptions';
15
- import { transformAttachmentLink } from './transformAttachmentLink';
16
- import { transformDocument } from './transformDocument';
17
- import { transformHTML } from './transformHTML';
18
- import { transformMarkdown } from './transformMarkdown';
19
- import { transformPicture } from './transformPicture';
20
-
21
- const readFile = util.promisify(fs.readFile);
22
- const writeFile = util.promisify(fs.writeFile);
23
-
24
- const DEFAULT_PARENT_CONTENT = {};
25
-
26
- export async function transformContentPage(
27
- pagePath: string,
28
- options: TransformationOptions,
29
- ): Promise<ContentPageDef> {
30
- const content: JSONRecord = JSON.parse(await readFile(pagePath, 'utf8'));
31
- const parentContent: JSONRecord = await (content?._extends
32
- ? JSON.parse(await readFile(content._extends as string, 'utf-8'))
33
- : DEFAULT_PARENT_CONTENT);
34
-
35
- const mergedContent = mergePages(parentContent, content);
36
-
37
- const result = await mapJSON(mergedContent as ContentPageDef, async (value: any, [key]) => {
38
- try {
39
- return await transform([value, key])(value, pagePath, options);
40
- } catch (ex) {
41
- console.warn(`Error while transforming field "${key}" on page: ${pagePath}`);
42
- console.error(ex);
43
- }
44
-
45
- return value;
46
- });
47
-
48
- await writeFile(generatedPagePath(pagePath), JSON.stringify(result), 'utf-8');
49
-
50
- return result;
51
- }
52
-
53
- const transform = tableFunc<
54
- [any, string],
55
- (value: any, pagePath: string, options: TransformationOptions) => Promise<any>
56
- >([
57
- [([value, key]) => isMarkdown(key, value), async (value: string) => transformMarkdown(value)],
58
- [([value, key]) => isHTML(key, value), async (value: string) => transformHTML(value)],
59
- [([value]) => isUUID(value?.src as string), async (value) => ({ src: value?.src })],
60
- [
61
- ([value]) => isAttachmentLink(value),
62
- async (value, pagePath, options) =>
63
- transformAttachmentLink(value as LinkProps, pagePath, options),
64
- ],
65
- [
66
- ([value]) => isAttachmentFile(value, DOCUMENT_EXT_LIST),
67
- async (value, pagePath, options) => transformDocument(value as Attachment, pagePath, options),
68
- ],
69
- [
70
- ([value]) => isAttachmentFile(value, IMAGE_EXT_LIST),
71
- async (value, pagePath, options) => transformPicture(value as Picture, pagePath, options),
72
- ],
73
- [() => true, async (value) => value],
74
- ]);
75
-
76
- export const generatedPagePath = (pagePath: string) => `${pagePath}${OUTPUT_SUFFIX}`;
77
-
78
- const isMarkdown = (key: string, value: any): value is string =>
79
- isString(value) && key?.endsWith('__md');
80
- const isHTML = (key: string, value: any): value is string =>
81
- isString(value) && key?.endsWith('__html');
82
-
83
- const isAttachmentLink = (_: any): _ is LinkProps =>
84
- isLocalPath(_?.href) && (_.href.startsWith(ATTACHMENT_PREFIX) || isLocalFile(_.href));
85
-
86
- const isAttachmentFile = (_: any, exts: string[]): _ is Attachment =>
87
- Boolean(_ && isLocalPath(_?.src)) && exts.some((ext) => _.src.toLowerCase().endsWith(ext));
88
-
89
- const isLocalPath = (_: any): _ is string => isString(_) && _.length < 1024 && !isURL(_);
90
- const isURL = (src: string) => ['data:', 'https:', 'http:'].some((proto) => src.startsWith(proto));
91
-
92
- const isString = (_: any): _ is string => Boolean(_ && typeof _ === 'string');
93
-
94
- const isLocalFile = (_: any): _ is string => isString(_) && isFileExists(_);
95
-
96
- const isFileExists = (_: string) => {
97
- try {
98
- return fs.statSync(_).isFile();
99
- } catch (ex) {
100
- return false;
101
- }
102
- };
@@ -1,43 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import util from 'util';
4
- import { type Attachment } from '../model/Attachment';
5
- import { isUUID } from '../utils/isUUID';
6
- import { type TransformationOptions } from './TransformationOptions';
7
-
8
- const mkdir = util.promisify(fs.mkdir);
9
- const copyFile = util.promisify(fs.copyFile);
10
- const stat = util.promisify(fs.stat);
11
-
12
- export async function transformDocument(
13
- attachment: Attachment,
14
- pagePath: string,
15
- options: TransformationOptions,
16
- ): Promise<Attachment> {
17
- if (!attachment?.src || isUUID(attachment.src)) {
18
- return attachment;
19
- }
20
-
21
- const { contentDir, publicDir } = options;
22
- const input = attachment.src;
23
- const docRelativePath = path.relative(contentDir, input);
24
- const output = path.join(publicDir, docRelativePath);
25
- const inputFileSize = (await stat(input)).size;
26
-
27
- try {
28
- await mkdir(path.dirname(output), { recursive: true });
29
- await copyFile(input, output);
30
- } catch (e) {
31
- console.info(`No "${input}" attachment found on page: "${pagePath}"`);
32
-
33
- return attachment;
34
- }
35
-
36
- const src = path.join('/', docRelativePath);
37
-
38
- return {
39
- ...attachment,
40
- src,
41
- fileSize: inputFileSize,
42
- };
43
- }
@@ -1,28 +0,0 @@
1
- import rehypeParse from 'rehype-parse';
2
- import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
3
- import rehypeStringify from 'rehype-stringify';
4
- import { unified } from 'unified';
5
- import { replaceHeadingTags } from './replaceHeadingTags';
6
-
7
- export async function transformHTML(html: string | null | undefined): Promise<string> {
8
- if (!html) {
9
- return '';
10
- }
11
-
12
- const extendedSchema = {
13
- ...defaultSchema,
14
- protocols: {
15
- ...defaultSchema.protocols,
16
- href: [...(defaultSchema?.protocols?.href || []), 'tel'],
17
- src: [...(defaultSchema.protocols?.src ?? []), 'data'],
18
- },
19
- };
20
-
21
- const result = await unified()
22
- .use(rehypeParse)
23
- .use(rehypeSanitize, extendedSchema)
24
- .use(rehypeStringify)
25
- .process(html);
26
-
27
- return replaceHeadingTags(result.toString('utf-8'));
28
- }
@@ -1,81 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import sharp, { type Sharp } from 'sharp';
4
- import util from 'util';
5
- import { type ImageSize } from '../model/ImageSize';
6
- import { type ImgSource } from '../model/Picture';
7
- import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty';
8
- import { computeImgOutputPath } from './computeImgOutputPath';
9
- import { resizeImg } from './resizeImg';
10
- import { type TransformationOptions } from './TransformationOptions';
11
-
12
- const mkdir = util.promisify(fs.mkdir);
13
- const copyFile = util.promisify(fs.copyFile);
14
-
15
- type ImgOutputPath = string;
16
- type TransformationTaskKey = ImgOutputPath;
17
- type TransformationTasksCache = Map<TransformationTaskKey, Promise<ImgOutputPath>>;
18
-
19
- type TransformImgOptions = TransformationOptions &
20
- ImgSource & { containerSize?: ImageSize; cache?: TransformationTasksCache };
21
-
22
- const defaultTransformationCache: TransformationTasksCache = new Map();
23
-
24
- const isNilTransform = ({ size, containerSize, format }: TransformImgOptions) =>
25
- isPictureSizeEmpty(size) && isPictureSizeEmpty(containerSize) && !format;
26
-
27
- const isVectorInput = (input: string) =>
28
- ['.svg', '.eps', '.epsf', '.epsi', '.pdf'].some((ext) => input.toLowerCase().endsWith(ext));
29
-
30
- export function transformImg(
31
- src: string,
32
- pagePath: string,
33
- options: TransformImgOptions,
34
- ): ImgOutputPath | Promise<ImgOutputPath> {
35
- if (!src) {
36
- return src;
37
- }
38
-
39
- const withoutTransform = isNilTransform(options) || isVectorInput(src);
40
-
41
- const output = computeImgOutputPath(src, options, withoutTransform);
42
-
43
- const { cache = defaultTransformationCache } = options;
44
-
45
- const cachedResult = cache.get(output);
46
- if (cachedResult) {
47
- return cachedResult;
48
- }
49
-
50
- const result = (async () => {
51
- try {
52
- await mkdir(path.dirname(output), { recursive: true });
53
- if (withoutTransform) {
54
- await copyFile(src, output);
55
- } else {
56
- const chain = await computeTransformationChain(options)(sharp(src));
57
- await chain.toFile(output);
58
- }
59
- } catch (e) {
60
- console.info(`No "${src}" attachment found on page: "${pagePath}"`);
61
- }
62
-
63
- return output;
64
- })();
65
- cache.set(output, result);
66
-
67
- return result;
68
- }
69
-
70
- const computeTransformationChain = ({
71
- size,
72
- containerSize,
73
- format,
74
- options,
75
- }: TransformImgOptions) =>
76
- pipe(resizeImg(isPictureSizeEmpty(size) ? containerSize : size), (_) =>
77
- format ? _.toFormat(format, { ...options, lossless: true }) : _,
78
- );
79
-
80
- const pipe = (...operations: Array<(chain: Sharp) => Promise<Sharp> | Sharp>) =>
81
- operations.reduce((a, b) => async (chain: Sharp) => b(await a(chain)));