@redneckz/wildless-cms-uni-blocks 0.14.857 → 0.14.859

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 (321) hide show
  1. package/bundle/bundle.umd.js +2 -2
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ContentPage/computeAPIFallback.d.ts +3 -0
  4. package/bundle/content-page-repository/ContentPageRepository.d.ts +10 -0
  5. package/bundle/content-page-repository/JSONDocContentBox.d.ts +8 -0
  6. package/bundle/content-page-repository/TransformationOptions.d.ts +4 -0
  7. package/bundle/content-page-repository/clearAttachmentHref.d.ts +2 -0
  8. package/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
  9. package/bundle/content-page-repository/extensions.d.ts +3 -0
  10. package/bundle/content-page-repository/index.d.ts +3 -0
  11. package/bundle/content-page-repository/mapJSON.d.ts +1 -0
  12. package/bundle/content-page-repository/mergePages.d.ts +2 -0
  13. package/bundle/content-page-repository/replaceHeadingTags.d.ts +1 -0
  14. package/bundle/content-page-repository/resizeImg.d.ts +3 -0
  15. package/bundle/content-page-repository/transformAttachmentLink.d.ts +3 -0
  16. package/bundle/content-page-repository/transformContentPage.d.ts +4 -0
  17. package/bundle/content-page-repository/transformDocument.d.ts +3 -0
  18. package/bundle/content-page-repository/transformHTML.d.ts +1 -0
  19. package/bundle/content-page-repository/transformImg.d.ts +12 -0
  20. package/bundle/content-page-repository/transformMarkdown.d.ts +1 -0
  21. package/bundle/content-page-repository/transformPicture.d.ts +3 -0
  22. package/dist/components/ContentPage/computeAPIFallback.d.ts +3 -0
  23. package/dist/components/ContentPage/computeAPIFallback.js +22 -0
  24. package/dist/components/ContentPage/computeAPIFallback.js.map +1 -0
  25. package/dist/content-page-repository/ContentPageRepository.d.ts +10 -0
  26. package/dist/content-page-repository/ContentPageRepository.js +31 -0
  27. package/dist/content-page-repository/ContentPageRepository.js.map +1 -0
  28. package/dist/content-page-repository/JSONDocContentBox.d.ts +8 -0
  29. package/dist/content-page-repository/JSONDocContentBox.js +39 -0
  30. package/dist/content-page-repository/JSONDocContentBox.js.map +1 -0
  31. package/dist/content-page-repository/TransformationOptions.d.ts +4 -0
  32. package/dist/content-page-repository/TransformationOptions.js +2 -0
  33. package/dist/content-page-repository/TransformationOptions.js.map +1 -0
  34. package/dist/content-page-repository/clearAttachmentHref.d.ts +2 -0
  35. package/dist/content-page-repository/clearAttachmentHref.js +6 -0
  36. package/dist/content-page-repository/clearAttachmentHref.js.map +1 -0
  37. package/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
  38. package/dist/content-page-repository/computeImgOutputPath.js +18 -0
  39. package/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
  40. package/dist/content-page-repository/extensions.d.ts +3 -0
  41. package/dist/content-page-repository/extensions.js +18 -0
  42. package/dist/content-page-repository/extensions.js.map +1 -0
  43. package/dist/content-page-repository/index.d.ts +3 -0
  44. package/dist/content-page-repository/index.js +9 -0
  45. package/dist/content-page-repository/index.js.map +1 -0
  46. package/dist/content-page-repository/mapJSON.d.ts +1 -0
  47. package/dist/content-page-repository/mapJSON.js +26 -0
  48. package/dist/content-page-repository/mapJSON.js.map +1 -0
  49. package/dist/content-page-repository/mergePages.d.ts +2 -0
  50. package/dist/content-page-repository/mergePages.js +7 -0
  51. package/dist/content-page-repository/mergePages.js.map +1 -0
  52. package/dist/content-page-repository/replaceHeadingTags.d.ts +1 -0
  53. package/dist/content-page-repository/replaceHeadingTags.js +5 -0
  54. package/dist/content-page-repository/replaceHeadingTags.js.map +1 -0
  55. package/dist/content-page-repository/resizeImg.d.ts +3 -0
  56. package/dist/content-page-repository/resizeImg.js +19 -0
  57. package/dist/content-page-repository/resizeImg.js.map +1 -0
  58. package/dist/content-page-repository/transformAttachmentLink.d.ts +3 -0
  59. package/dist/content-page-repository/transformAttachmentLink.js +40 -0
  60. package/dist/content-page-repository/transformAttachmentLink.js.map +1 -0
  61. package/dist/content-page-repository/transformContentPage.d.ts +4 -0
  62. package/dist/content-page-repository/transformContentPage.js +78 -0
  63. package/dist/content-page-repository/transformContentPage.js.map +1 -0
  64. package/dist/content-page-repository/transformDocument.d.ts +3 -0
  65. package/dist/content-page-repository/transformDocument.js +38 -0
  66. package/dist/content-page-repository/transformDocument.js.map +1 -0
  67. package/dist/content-page-repository/transformHTML.d.ts +1 -0
  68. package/dist/content-page-repository/transformHTML.js +54 -0
  69. package/dist/content-page-repository/transformHTML.js.map +1 -0
  70. package/dist/content-page-repository/transformImg.d.ts +12 -0
  71. package/dist/content-page-repository/transformImg.js +51 -0
  72. package/dist/content-page-repository/transformImg.js.map +1 -0
  73. package/dist/content-page-repository/transformMarkdown.d.ts +1 -0
  74. package/dist/content-page-repository/transformMarkdown.js +18 -0
  75. package/dist/content-page-repository/transformMarkdown.js.map +1 -0
  76. package/dist/content-page-repository/transformPicture.d.ts +3 -0
  77. package/dist/content-page-repository/transformPicture.js +28 -0
  78. package/dist/content-page-repository/transformPicture.js.map +1 -0
  79. package/dist/ui-kit/Calculator/UnknownRate.js +1 -1
  80. package/dist/ui-kit/Calculator/UnknownRate.js.map +1 -1
  81. package/lib/common.css +1 -1
  82. package/lib/components/ContentPage/computeAPIFallback.d.ts +3 -0
  83. package/lib/components/ContentPage/computeAPIFallback.js +19 -0
  84. package/lib/components/ContentPage/computeAPIFallback.js.map +1 -0
  85. package/lib/content-page-repository/ContentPageRepository.d.ts +10 -0
  86. package/lib/content-page-repository/ContentPageRepository.js +25 -0
  87. package/lib/content-page-repository/ContentPageRepository.js.map +1 -0
  88. package/lib/content-page-repository/JSONDocContentBox.d.ts +8 -0
  89. package/lib/content-page-repository/JSONDocContentBox.js +36 -0
  90. package/lib/content-page-repository/JSONDocContentBox.js.map +1 -0
  91. package/lib/content-page-repository/TransformationOptions.d.ts +4 -0
  92. package/lib/content-page-repository/TransformationOptions.js +2 -0
  93. package/lib/content-page-repository/TransformationOptions.js.map +1 -0
  94. package/lib/content-page-repository/clearAttachmentHref.d.ts +2 -0
  95. package/lib/content-page-repository/clearAttachmentHref.js +3 -0
  96. package/lib/content-page-repository/clearAttachmentHref.js.map +1 -0
  97. package/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
  98. package/lib/content-page-repository/computeImgOutputPath.js +12 -0
  99. package/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
  100. package/lib/content-page-repository/extensions.d.ts +3 -0
  101. package/lib/content-page-repository/extensions.js +16 -0
  102. package/lib/content-page-repository/extensions.js.map +1 -0
  103. package/lib/content-page-repository/index.d.ts +3 -0
  104. package/lib/content-page-repository/index.js +4 -0
  105. package/lib/content-page-repository/index.js.map +1 -0
  106. package/lib/content-page-repository/mapJSON.d.ts +1 -0
  107. package/lib/content-page-repository/mapJSON.js +23 -0
  108. package/lib/content-page-repository/mapJSON.js.map +1 -0
  109. package/lib/content-page-repository/mergePages.d.ts +2 -0
  110. package/lib/content-page-repository/mergePages.js +4 -0
  111. package/lib/content-page-repository/mergePages.js.map +1 -0
  112. package/lib/content-page-repository/replaceHeadingTags.d.ts +1 -0
  113. package/lib/content-page-repository/replaceHeadingTags.js +2 -0
  114. package/lib/content-page-repository/replaceHeadingTags.js.map +1 -0
  115. package/lib/content-page-repository/resizeImg.d.ts +3 -0
  116. package/lib/content-page-repository/resizeImg.js +13 -0
  117. package/lib/content-page-repository/resizeImg.js.map +1 -0
  118. package/lib/content-page-repository/transformAttachmentLink.d.ts +3 -0
  119. package/lib/content-page-repository/transformAttachmentLink.js +34 -0
  120. package/lib/content-page-repository/transformAttachmentLink.js.map +1 -0
  121. package/lib/content-page-repository/transformContentPage.d.ts +4 -0
  122. package/lib/content-page-repository/transformContentPage.js +71 -0
  123. package/lib/content-page-repository/transformContentPage.js.map +1 -0
  124. package/lib/content-page-repository/transformDocument.d.ts +3 -0
  125. package/lib/content-page-repository/transformDocument.js +32 -0
  126. package/lib/content-page-repository/transformDocument.js.map +1 -0
  127. package/lib/content-page-repository/transformHTML.d.ts +1 -0
  128. package/lib/content-page-repository/transformHTML.js +25 -0
  129. package/lib/content-page-repository/transformHTML.js.map +1 -0
  130. package/lib/content-page-repository/transformImg.d.ts +12 -0
  131. package/lib/content-page-repository/transformImg.js +45 -0
  132. package/lib/content-page-repository/transformImg.js.map +1 -0
  133. package/lib/content-page-repository/transformMarkdown.d.ts +1 -0
  134. package/lib/content-page-repository/transformMarkdown.js +12 -0
  135. package/lib/content-page-repository/transformMarkdown.js.map +1 -0
  136. package/lib/content-page-repository/transformPicture.d.ts +3 -0
  137. package/lib/content-page-repository/transformPicture.js +22 -0
  138. package/lib/content-page-repository/transformPicture.js.map +1 -0
  139. package/lib/ui-kit/Calculator/UnknownRate.js +1 -1
  140. package/lib/ui-kit/Calculator/UnknownRate.js.map +1 -1
  141. package/mobile/bundle/bundle.umd.js +2 -2
  142. package/mobile/bundle/bundle.umd.min.js +1 -1
  143. package/mobile/bundle/components/ContentPage/computeAPIFallback.d.ts +3 -0
  144. package/mobile/bundle/content-page-repository/ContentPageRepository.d.ts +10 -0
  145. package/mobile/bundle/content-page-repository/JSONDocContentBox.d.ts +8 -0
  146. package/mobile/bundle/content-page-repository/TransformationOptions.d.ts +4 -0
  147. package/mobile/bundle/content-page-repository/clearAttachmentHref.d.ts +2 -0
  148. package/mobile/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
  149. package/mobile/bundle/content-page-repository/extensions.d.ts +3 -0
  150. package/mobile/bundle/content-page-repository/index.d.ts +3 -0
  151. package/mobile/bundle/content-page-repository/mapJSON.d.ts +1 -0
  152. package/mobile/bundle/content-page-repository/mergePages.d.ts +2 -0
  153. package/mobile/bundle/content-page-repository/replaceHeadingTags.d.ts +1 -0
  154. package/mobile/bundle/content-page-repository/resizeImg.d.ts +3 -0
  155. package/mobile/bundle/content-page-repository/transformAttachmentLink.d.ts +3 -0
  156. package/mobile/bundle/content-page-repository/transformContentPage.d.ts +4 -0
  157. package/mobile/bundle/content-page-repository/transformDocument.d.ts +3 -0
  158. package/mobile/bundle/content-page-repository/transformHTML.d.ts +1 -0
  159. package/mobile/bundle/content-page-repository/transformImg.d.ts +12 -0
  160. package/mobile/bundle/content-page-repository/transformMarkdown.d.ts +1 -0
  161. package/mobile/bundle/content-page-repository/transformPicture.d.ts +3 -0
  162. package/mobile/dist/components/ContentPage/computeAPIFallback.d.ts +3 -0
  163. package/mobile/dist/components/ContentPage/computeAPIFallback.js +22 -0
  164. package/mobile/dist/components/ContentPage/computeAPIFallback.js.map +1 -0
  165. package/mobile/dist/content-page-repository/ContentPageRepository.d.ts +10 -0
  166. package/mobile/dist/content-page-repository/ContentPageRepository.js +31 -0
  167. package/mobile/dist/content-page-repository/ContentPageRepository.js.map +1 -0
  168. package/mobile/dist/content-page-repository/JSONDocContentBox.d.ts +8 -0
  169. package/mobile/dist/content-page-repository/JSONDocContentBox.js +39 -0
  170. package/mobile/dist/content-page-repository/JSONDocContentBox.js.map +1 -0
  171. package/mobile/dist/content-page-repository/TransformationOptions.d.ts +4 -0
  172. package/mobile/dist/content-page-repository/TransformationOptions.js +2 -0
  173. package/mobile/dist/content-page-repository/TransformationOptions.js.map +1 -0
  174. package/mobile/dist/content-page-repository/clearAttachmentHref.d.ts +2 -0
  175. package/mobile/dist/content-page-repository/clearAttachmentHref.js +6 -0
  176. package/mobile/dist/content-page-repository/clearAttachmentHref.js.map +1 -0
  177. package/mobile/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
  178. package/mobile/dist/content-page-repository/computeImgOutputPath.js +18 -0
  179. package/mobile/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
  180. package/mobile/dist/content-page-repository/extensions.d.ts +3 -0
  181. package/mobile/dist/content-page-repository/extensions.js +18 -0
  182. package/mobile/dist/content-page-repository/extensions.js.map +1 -0
  183. package/mobile/dist/content-page-repository/index.d.ts +3 -0
  184. package/mobile/dist/content-page-repository/index.js +9 -0
  185. package/mobile/dist/content-page-repository/index.js.map +1 -0
  186. package/mobile/dist/content-page-repository/mapJSON.d.ts +1 -0
  187. package/mobile/dist/content-page-repository/mapJSON.js +26 -0
  188. package/mobile/dist/content-page-repository/mapJSON.js.map +1 -0
  189. package/mobile/dist/content-page-repository/mergePages.d.ts +2 -0
  190. package/mobile/dist/content-page-repository/mergePages.js +7 -0
  191. package/mobile/dist/content-page-repository/mergePages.js.map +1 -0
  192. package/mobile/dist/content-page-repository/replaceHeadingTags.d.ts +1 -0
  193. package/mobile/dist/content-page-repository/replaceHeadingTags.js +5 -0
  194. package/mobile/dist/content-page-repository/replaceHeadingTags.js.map +1 -0
  195. package/mobile/dist/content-page-repository/resizeImg.d.ts +3 -0
  196. package/mobile/dist/content-page-repository/resizeImg.js +19 -0
  197. package/mobile/dist/content-page-repository/resizeImg.js.map +1 -0
  198. package/mobile/dist/content-page-repository/transformAttachmentLink.d.ts +3 -0
  199. package/mobile/dist/content-page-repository/transformAttachmentLink.js +40 -0
  200. package/mobile/dist/content-page-repository/transformAttachmentLink.js.map +1 -0
  201. package/mobile/dist/content-page-repository/transformContentPage.d.ts +4 -0
  202. package/mobile/dist/content-page-repository/transformContentPage.js +78 -0
  203. package/mobile/dist/content-page-repository/transformContentPage.js.map +1 -0
  204. package/mobile/dist/content-page-repository/transformDocument.d.ts +3 -0
  205. package/mobile/dist/content-page-repository/transformDocument.js +38 -0
  206. package/mobile/dist/content-page-repository/transformDocument.js.map +1 -0
  207. package/mobile/dist/content-page-repository/transformHTML.d.ts +1 -0
  208. package/mobile/dist/content-page-repository/transformHTML.js +54 -0
  209. package/mobile/dist/content-page-repository/transformHTML.js.map +1 -0
  210. package/mobile/dist/content-page-repository/transformImg.d.ts +12 -0
  211. package/mobile/dist/content-page-repository/transformImg.js +51 -0
  212. package/mobile/dist/content-page-repository/transformImg.js.map +1 -0
  213. package/mobile/dist/content-page-repository/transformMarkdown.d.ts +1 -0
  214. package/mobile/dist/content-page-repository/transformMarkdown.js +18 -0
  215. package/mobile/dist/content-page-repository/transformMarkdown.js.map +1 -0
  216. package/mobile/dist/content-page-repository/transformPicture.d.ts +3 -0
  217. package/mobile/dist/content-page-repository/transformPicture.js +28 -0
  218. package/mobile/dist/content-page-repository/transformPicture.js.map +1 -0
  219. package/mobile/dist/ui-kit/Calculator/UnknownRate.js +1 -1
  220. package/mobile/dist/ui-kit/Calculator/UnknownRate.js.map +1 -1
  221. package/mobile/lib/common.css +1 -1
  222. package/mobile/lib/components/ContentPage/computeAPIFallback.d.ts +3 -0
  223. package/mobile/lib/components/ContentPage/computeAPIFallback.js +19 -0
  224. package/mobile/lib/components/ContentPage/computeAPIFallback.js.map +1 -0
  225. package/mobile/lib/content-page-repository/ContentPageRepository.d.ts +10 -0
  226. package/mobile/lib/content-page-repository/ContentPageRepository.js +25 -0
  227. package/mobile/lib/content-page-repository/ContentPageRepository.js.map +1 -0
  228. package/mobile/lib/content-page-repository/JSONDocContentBox.d.ts +8 -0
  229. package/mobile/lib/content-page-repository/JSONDocContentBox.js +36 -0
  230. package/mobile/lib/content-page-repository/JSONDocContentBox.js.map +1 -0
  231. package/mobile/lib/content-page-repository/TransformationOptions.d.ts +4 -0
  232. package/mobile/lib/content-page-repository/TransformationOptions.js +2 -0
  233. package/mobile/lib/content-page-repository/TransformationOptions.js.map +1 -0
  234. package/mobile/lib/content-page-repository/clearAttachmentHref.d.ts +2 -0
  235. package/mobile/lib/content-page-repository/clearAttachmentHref.js +3 -0
  236. package/mobile/lib/content-page-repository/clearAttachmentHref.js.map +1 -0
  237. package/mobile/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
  238. package/mobile/lib/content-page-repository/computeImgOutputPath.js +12 -0
  239. package/mobile/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
  240. package/mobile/lib/content-page-repository/extensions.d.ts +3 -0
  241. package/mobile/lib/content-page-repository/extensions.js +16 -0
  242. package/mobile/lib/content-page-repository/extensions.js.map +1 -0
  243. package/mobile/lib/content-page-repository/index.d.ts +3 -0
  244. package/mobile/lib/content-page-repository/index.js +4 -0
  245. package/mobile/lib/content-page-repository/index.js.map +1 -0
  246. package/mobile/lib/content-page-repository/mapJSON.d.ts +1 -0
  247. package/mobile/lib/content-page-repository/mapJSON.js +23 -0
  248. package/mobile/lib/content-page-repository/mapJSON.js.map +1 -0
  249. package/mobile/lib/content-page-repository/mergePages.d.ts +2 -0
  250. package/mobile/lib/content-page-repository/mergePages.js +4 -0
  251. package/mobile/lib/content-page-repository/mergePages.js.map +1 -0
  252. package/mobile/lib/content-page-repository/replaceHeadingTags.d.ts +1 -0
  253. package/mobile/lib/content-page-repository/replaceHeadingTags.js +2 -0
  254. package/mobile/lib/content-page-repository/replaceHeadingTags.js.map +1 -0
  255. package/mobile/lib/content-page-repository/resizeImg.d.ts +3 -0
  256. package/mobile/lib/content-page-repository/resizeImg.js +13 -0
  257. package/mobile/lib/content-page-repository/resizeImg.js.map +1 -0
  258. package/mobile/lib/content-page-repository/transformAttachmentLink.d.ts +3 -0
  259. package/mobile/lib/content-page-repository/transformAttachmentLink.js +34 -0
  260. package/mobile/lib/content-page-repository/transformAttachmentLink.js.map +1 -0
  261. package/mobile/lib/content-page-repository/transformContentPage.d.ts +4 -0
  262. package/mobile/lib/content-page-repository/transformContentPage.js +71 -0
  263. package/mobile/lib/content-page-repository/transformContentPage.js.map +1 -0
  264. package/mobile/lib/content-page-repository/transformDocument.d.ts +3 -0
  265. package/mobile/lib/content-page-repository/transformDocument.js +32 -0
  266. package/mobile/lib/content-page-repository/transformDocument.js.map +1 -0
  267. package/mobile/lib/content-page-repository/transformHTML.d.ts +1 -0
  268. package/mobile/lib/content-page-repository/transformHTML.js +25 -0
  269. package/mobile/lib/content-page-repository/transformHTML.js.map +1 -0
  270. package/mobile/lib/content-page-repository/transformImg.d.ts +12 -0
  271. package/mobile/lib/content-page-repository/transformImg.js +45 -0
  272. package/mobile/lib/content-page-repository/transformImg.js.map +1 -0
  273. package/mobile/lib/content-page-repository/transformMarkdown.d.ts +1 -0
  274. package/mobile/lib/content-page-repository/transformMarkdown.js +12 -0
  275. package/mobile/lib/content-page-repository/transformMarkdown.js.map +1 -0
  276. package/mobile/lib/content-page-repository/transformPicture.d.ts +3 -0
  277. package/mobile/lib/content-page-repository/transformPicture.js +22 -0
  278. package/mobile/lib/content-page-repository/transformPicture.js.map +1 -0
  279. package/mobile/lib/ui-kit/Calculator/UnknownRate.js +1 -1
  280. package/mobile/lib/ui-kit/Calculator/UnknownRate.js.map +1 -1
  281. package/mobile/src/components/ContentPage/computeAPIFallback.ts +35 -0
  282. package/mobile/src/content-page-repository/ContentPageRepository.ts +31 -0
  283. package/mobile/src/content-page-repository/JSONDocContentBox.ts +56 -0
  284. package/mobile/src/content-page-repository/TransformationOptions.ts +4 -0
  285. package/mobile/src/content-page-repository/clearAttachmentHref.ts +3 -0
  286. package/mobile/src/content-page-repository/computeImgOutputPath.ts +21 -0
  287. package/mobile/src/content-page-repository/extensions.ts +17 -0
  288. package/mobile/src/content-page-repository/index.ts +3 -0
  289. package/mobile/src/content-page-repository/mapJSON.ts +30 -0
  290. package/mobile/src/content-page-repository/mergePages.ts +8 -0
  291. package/mobile/src/content-page-repository/replaceHeadingTags.ts +2 -0
  292. package/mobile/src/content-page-repository/resizeImg.ts +17 -0
  293. package/mobile/src/content-page-repository/transformAttachmentLink.ts +46 -0
  294. package/mobile/src/content-page-repository/transformContentPage.ts +102 -0
  295. package/mobile/src/content-page-repository/transformDocument.ts +43 -0
  296. package/mobile/src/content-page-repository/transformHTML.ts +28 -0
  297. package/mobile/src/content-page-repository/transformImg.ts +81 -0
  298. package/mobile/src/content-page-repository/transformMarkdown.ts +14 -0
  299. package/mobile/src/content-page-repository/transformPicture.ts +35 -0
  300. package/mobile/src/ui-kit/Calculator/UnknownRate.tsx +1 -1
  301. package/package.json +21 -1
  302. package/src/components/ContentPage/computeAPIFallback.ts +35 -0
  303. package/src/content-page-repository/ContentPageRepository.ts +31 -0
  304. package/src/content-page-repository/JSONDocContentBox.ts +56 -0
  305. package/src/content-page-repository/TransformationOptions.ts +4 -0
  306. package/src/content-page-repository/clearAttachmentHref.ts +3 -0
  307. package/src/content-page-repository/computeImgOutputPath.ts +21 -0
  308. package/src/content-page-repository/extensions.ts +17 -0
  309. package/src/content-page-repository/index.ts +3 -0
  310. package/src/content-page-repository/mapJSON.ts +30 -0
  311. package/src/content-page-repository/mergePages.ts +8 -0
  312. package/src/content-page-repository/replaceHeadingTags.ts +2 -0
  313. package/src/content-page-repository/resizeImg.ts +17 -0
  314. package/src/content-page-repository/transformAttachmentLink.ts +46 -0
  315. package/src/content-page-repository/transformContentPage.ts +102 -0
  316. package/src/content-page-repository/transformDocument.ts +43 -0
  317. package/src/content-page-repository/transformHTML.ts +28 -0
  318. package/src/content-page-repository/transformImg.ts +81 -0
  319. package/src/content-page-repository/transformMarkdown.ts +14 -0
  320. package/src/content-page-repository/transformPicture.ts +35 -0
  321. package/src/ui-kit/Calculator/UnknownRate.tsx +1 -1
@@ -0,0 +1,56 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ export interface TransformationOptions {
2
+ contentDir: string;
3
+ publicDir: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ export const ATTACHMENT_PREFIX = 'file://';
2
+
3
+ export const clearAttachmentHref = (href: string): string => href.replace(ATTACHMENT_PREFIX, '');
@@ -0,0 +1,21 @@
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
+ }
@@ -0,0 +1,17 @@
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'];
@@ -0,0 +1,3 @@
1
+ export { clearAttachmentHref } from './clearAttachmentHref';
2
+ export { ContentPageRepository } from './ContentPageRepository';
3
+ export { transformContentPage } from './transformContentPage';
@@ -0,0 +1,30 @@
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
+ }
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,2 @@
1
+ export const replaceHeadingTags = (html: string) =>
2
+ html.replaceAll(/<h(\d)>(.*?)<\/h\d>/g, '<p class="h$1">$2</p>');
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,46 @@
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
+ }
@@ -0,0 +1,102 @@
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
+ };
@@ -0,0 +1,43 @@
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
+ }
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,81 @@
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)));
@@ -0,0 +1,14 @@
1
+ import remarkHtml from 'remark-html';
2
+ import remarkParse from 'remark-parse';
3
+ import { unified } from 'unified';
4
+ import { replaceHeadingTags } from './replaceHeadingTags';
5
+
6
+ export async function transformMarkdown(markdown: string | null | undefined): Promise<string> {
7
+ if (!markdown) {
8
+ return '';
9
+ }
10
+
11
+ const result = await unified().use(remarkParse).use(remarkHtml).process(markdown);
12
+
13
+ return replaceHeadingTags(result.toString('utf-8'));
14
+ }
@@ -0,0 +1,35 @@
1
+ import path from 'path';
2
+ import sharp from 'sharp';
3
+ import { type Picture } from '../model/Picture';
4
+ import { type TransformationOptions } from './TransformationOptions';
5
+ import { transformImg } from './transformImg';
6
+
7
+ export async function transformPicture(
8
+ picture: Picture,
9
+ pagePath: string,
10
+ options: TransformationOptions,
11
+ ): Promise<Picture> {
12
+ const src = picture?.src || '';
13
+
14
+ const transformedImgPath = await transformImg(src, pagePath, { ...options, ...picture });
15
+
16
+ const { width, height } = await sharp(transformedImgPath).metadata();
17
+ const containerSize = width && height ? { width, height } : undefined;
18
+
19
+ const sources = picture.sources || [];
20
+ const transformedSources = await Promise.all(
21
+ sources.map((_) => transformImg(src, pagePath, { ...options, ..._, containerSize })),
22
+ );
23
+
24
+ const imgPathToSrc = (_: string) => path.join('/', path.relative(options.publicDir, _));
25
+
26
+ return {
27
+ ...picture,
28
+ src: imgPathToSrc(transformedImgPath),
29
+ sources: transformedSources.map((_, i) => ({
30
+ ...sources[i],
31
+ src: imgPathToSrc(_),
32
+ size: { width, height },
33
+ })),
34
+ };
35
+ }
@@ -5,7 +5,7 @@ import { Paragraph } from '../Paragraph/Paragraph';
5
5
  import { Text } from '../Text/Text';
6
6
 
7
7
  export const UnknownRate = JSX<TitleProps>(({ title = 'Ставка' }) => (
8
- <div className="space-y-s min-w-96">
8
+ <div className="space-y-s lg:min-w-96">
9
9
  <Text size="text-l" font="font-light" color="text-secondary-text">
10
10
  {title}
11
11
  </Text>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.857",
3
+ "version": "0.14.859",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -39,6 +39,26 @@
39
39
  "./lib/common.css": "./lib/common.css",
40
40
  "./mobile/lib/common.css": "./mobile/lib/common.css",
41
41
  "./fonts/ubuntu/*": "./fonts/ubuntu/*",
42
+ "./lib/content-page-repository": {
43
+ "import": "./lib/content-page-repository/index.js",
44
+ "require": "./dist/content-page-repository/index.js",
45
+ "types": "./lib/content-page-repository/index.d.ts"
46
+ },
47
+ "./lib/content-page-repository/*": {
48
+ "import": "./lib/content-page-repository/*.js",
49
+ "require": "./dist/content-page-repository/*.js",
50
+ "types": "./lib/content-page-repository/*.d.ts"
51
+ },
52
+ "./mobile/lib/content-page-repository": {
53
+ "import": "./mobile/lib/content-page-repository/index.js",
54
+ "require": "./mobile/dist/content-page-repository/index.js",
55
+ "types": "./mobile/lib/content-page-repository/index.d.ts"
56
+ },
57
+ "./mobile/lib/content-page-repository/*": {
58
+ "import": "./mobile/lib/content-page-repository/*.js",
59
+ "require": "./mobile/dist/content-page-repository/*.js",
60
+ "types": "./mobile/lib/content-page-repository/*.d.ts"
61
+ },
42
62
  "./bundle/*.js": "./bundle/*.js",
43
63
  "./bundle/*.json": "./bundle/*.json",
44
64
  "./*.json": "./*.json",
@@ -0,0 +1,35 @@
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 ContentPageDef } from '../../model/ContentPageDef';
5
+ import { type Fallback } from '../../model/Fallback';
6
+ import { unique } from '../../utils/unique';
7
+ import { joinPath } from '../../utils/url';
8
+
9
+ type FallbackEntry = [key: string, data: JSONNode];
10
+
11
+ const BASE_DIR = 'content';
12
+
13
+ export const computeAPIFallback = async (contentPageData: ContentPageDef): Promise<Fallback> => {
14
+ return Object.fromEntries(
15
+ (await computeFallbackFromContentRefs(contentPageData)).filter(([key, data]) => key && data),
16
+ );
17
+ };
18
+
19
+ const computeFallbackFromContentRefs = async (
20
+ contentPageData: ContentPageDef,
21
+ ): Promise<FallbackEntry[]> => {
22
+ const refs = unique(collectRef(contentPageData as JSONNode));
23
+
24
+ return (
25
+ await Promise.allSettled(
26
+ refs.map(async (_) => [
27
+ _,
28
+ (await ContentPageRepository.inst.generatePage(joinPath(BASE_DIR, _))) as JSONNode,
29
+ ]),
30
+ )
31
+ )
32
+ .filter((_): _ is PromiseFulfilledResult<FallbackEntry> => _.status === 'fulfilled')
33
+ .map(({ value }) => value)
34
+ .map(([ref, data]) => [ref, resolveJPointer(data, ref)]);
35
+ };
@@ -0,0 +1,31 @@
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
+ }