@redneckz/wildless-cms-uni-blocks 0.14.858 → 0.14.860
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.
- package/bundle/bundle.umd.js +1 -1
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/bundle/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/bundle/components/ContentPage/mapSlot.d.ts +2 -0
- package/bundle/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/bundle/components/ContentPage/normalizeBlock.mobile.d.ts +3 -0
- package/bundle/components/ContentPage/normalizePage.d.ts +3 -0
- package/bundle/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/bundle/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/bundle/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/bundle/content-page-repository/TransformationOptions.d.ts +4 -0
- package/bundle/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/bundle/content-page-repository/extensions.d.ts +3 -0
- package/bundle/content-page-repository/index.d.ts +3 -0
- package/bundle/content-page-repository/mapJSON.d.ts +1 -0
- package/bundle/content-page-repository/mergePages.d.ts +2 -0
- package/bundle/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/bundle/content-page-repository/resizeImg.d.ts +3 -0
- package/bundle/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/bundle/content-page-repository/transformContentPage.d.ts +4 -0
- package/bundle/content-page-repository/transformDocument.d.ts +3 -0
- package/bundle/content-page-repository/transformHTML.d.ts +1 -0
- package/bundle/content-page-repository/transformImg.d.ts +12 -0
- package/bundle/content-page-repository/transformMarkdown.d.ts +1 -0
- package/bundle/content-page-repository/transformPicture.d.ts +3 -0
- package/bundle/model/Fallback.d.ts +1 -0
- package/dist/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/dist/components/ContentPage/computeAPIFallback.js +36 -0
- package/dist/components/ContentPage/computeAPIFallback.js.map +1 -0
- package/dist/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/dist/components/ContentPage/loadModuleFallback.js +36 -0
- package/dist/components/ContentPage/loadModuleFallback.js.map +1 -0
- package/dist/components/ContentPage/mapSlot.d.ts +2 -0
- package/dist/components/ContentPage/mapSlot.js +16 -0
- package/dist/components/ContentPage/mapSlot.js.map +1 -0
- package/dist/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/dist/components/ContentPage/normalizeBlock.js +15 -0
- package/dist/components/ContentPage/normalizeBlock.js.map +1 -0
- package/dist/components/ContentPage/normalizeBlock.mobile.d.ts +3 -0
- package/dist/components/ContentPage/normalizeBlock.mobile.js +18 -0
- package/dist/components/ContentPage/normalizeBlock.mobile.js.map +1 -0
- package/dist/components/ContentPage/normalizePage.d.ts +3 -0
- package/dist/components/ContentPage/normalizePage.js +6 -0
- package/dist/components/ContentPage/normalizePage.js.map +1 -0
- package/dist/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/dist/components/ContentPage/toMobileBlock.js +12 -0
- package/dist/components/ContentPage/toMobileBlock.js.map +1 -0
- package/dist/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/dist/content-page-repository/ContentPageRepository.js +31 -0
- package/dist/content-page-repository/ContentPageRepository.js.map +1 -0
- package/dist/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/dist/content-page-repository/JSONDocContentBox.js +39 -0
- package/dist/content-page-repository/JSONDocContentBox.js.map +1 -0
- package/dist/content-page-repository/TransformationOptions.d.ts +4 -0
- package/dist/content-page-repository/TransformationOptions.js +2 -0
- package/dist/content-page-repository/TransformationOptions.js.map +1 -0
- package/dist/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/dist/content-page-repository/clearAttachmentHref.js +6 -0
- package/dist/content-page-repository/clearAttachmentHref.js.map +1 -0
- package/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/dist/content-page-repository/computeImgOutputPath.js +18 -0
- package/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/dist/content-page-repository/extensions.d.ts +3 -0
- package/dist/content-page-repository/extensions.js +18 -0
- package/dist/content-page-repository/extensions.js.map +1 -0
- package/dist/content-page-repository/index.d.ts +3 -0
- package/dist/content-page-repository/index.js +9 -0
- package/dist/content-page-repository/index.js.map +1 -0
- package/dist/content-page-repository/mapJSON.d.ts +1 -0
- package/dist/content-page-repository/mapJSON.js +26 -0
- package/dist/content-page-repository/mapJSON.js.map +1 -0
- package/dist/content-page-repository/mergePages.d.ts +2 -0
- package/dist/content-page-repository/mergePages.js +7 -0
- package/dist/content-page-repository/mergePages.js.map +1 -0
- package/dist/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/dist/content-page-repository/replaceHeadingTags.js +5 -0
- package/dist/content-page-repository/replaceHeadingTags.js.map +1 -0
- package/dist/content-page-repository/resizeImg.d.ts +3 -0
- package/dist/content-page-repository/resizeImg.js +19 -0
- package/dist/content-page-repository/resizeImg.js.map +1 -0
- package/dist/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/dist/content-page-repository/transformAttachmentLink.js +40 -0
- package/dist/content-page-repository/transformAttachmentLink.js.map +1 -0
- package/dist/content-page-repository/transformContentPage.d.ts +4 -0
- package/dist/content-page-repository/transformContentPage.js +78 -0
- package/dist/content-page-repository/transformContentPage.js.map +1 -0
- package/dist/content-page-repository/transformDocument.d.ts +3 -0
- package/dist/content-page-repository/transformDocument.js +38 -0
- package/dist/content-page-repository/transformDocument.js.map +1 -0
- package/dist/content-page-repository/transformHTML.d.ts +1 -0
- package/dist/content-page-repository/transformHTML.js +54 -0
- package/dist/content-page-repository/transformHTML.js.map +1 -0
- package/dist/content-page-repository/transformImg.d.ts +12 -0
- package/dist/content-page-repository/transformImg.js +51 -0
- package/dist/content-page-repository/transformImg.js.map +1 -0
- package/dist/content-page-repository/transformMarkdown.d.ts +1 -0
- package/dist/content-page-repository/transformMarkdown.js +18 -0
- package/dist/content-page-repository/transformMarkdown.js.map +1 -0
- package/dist/content-page-repository/transformPicture.d.ts +3 -0
- package/dist/content-page-repository/transformPicture.js +28 -0
- package/dist/content-page-repository/transformPicture.js.map +1 -0
- package/dist/model/Fallback.d.ts +1 -0
- package/lib/common.css +1 -1
- package/lib/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/lib/components/ContentPage/computeAPIFallback.js +33 -0
- package/lib/components/ContentPage/computeAPIFallback.js.map +1 -0
- package/lib/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/lib/components/ContentPage/loadModuleFallback.js +10 -0
- package/lib/components/ContentPage/loadModuleFallback.js.map +1 -0
- package/lib/components/ContentPage/mapSlot.d.ts +2 -0
- package/lib/components/ContentPage/mapSlot.js +13 -0
- package/lib/components/ContentPage/mapSlot.js.map +1 -0
- package/lib/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/lib/components/ContentPage/normalizeBlock.js +12 -0
- package/lib/components/ContentPage/normalizeBlock.js.map +1 -0
- package/lib/components/ContentPage/normalizeBlock.mobile.d.ts +3 -0
- package/lib/components/ContentPage/normalizeBlock.mobile.js +15 -0
- package/lib/components/ContentPage/normalizeBlock.mobile.js.map +1 -0
- package/lib/components/ContentPage/normalizePage.d.ts +3 -0
- package/lib/components/ContentPage/normalizePage.js +3 -0
- package/lib/components/ContentPage/normalizePage.js.map +1 -0
- package/lib/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/lib/components/ContentPage/toMobileBlock.js +9 -0
- package/lib/components/ContentPage/toMobileBlock.js.map +1 -0
- package/lib/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/lib/content-page-repository/ContentPageRepository.js +25 -0
- package/lib/content-page-repository/ContentPageRepository.js.map +1 -0
- package/lib/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/lib/content-page-repository/JSONDocContentBox.js +36 -0
- package/lib/content-page-repository/JSONDocContentBox.js.map +1 -0
- package/lib/content-page-repository/TransformationOptions.d.ts +4 -0
- package/lib/content-page-repository/TransformationOptions.js +2 -0
- package/lib/content-page-repository/TransformationOptions.js.map +1 -0
- package/lib/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/lib/content-page-repository/clearAttachmentHref.js +3 -0
- package/lib/content-page-repository/clearAttachmentHref.js.map +1 -0
- package/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/lib/content-page-repository/computeImgOutputPath.js +12 -0
- package/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/lib/content-page-repository/extensions.d.ts +3 -0
- package/lib/content-page-repository/extensions.js +16 -0
- package/lib/content-page-repository/extensions.js.map +1 -0
- package/lib/content-page-repository/index.d.ts +3 -0
- package/lib/content-page-repository/index.js +4 -0
- package/lib/content-page-repository/index.js.map +1 -0
- package/lib/content-page-repository/mapJSON.d.ts +1 -0
- package/lib/content-page-repository/mapJSON.js +23 -0
- package/lib/content-page-repository/mapJSON.js.map +1 -0
- package/lib/content-page-repository/mergePages.d.ts +2 -0
- package/lib/content-page-repository/mergePages.js +4 -0
- package/lib/content-page-repository/mergePages.js.map +1 -0
- package/lib/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/lib/content-page-repository/replaceHeadingTags.js +2 -0
- package/lib/content-page-repository/replaceHeadingTags.js.map +1 -0
- package/lib/content-page-repository/resizeImg.d.ts +3 -0
- package/lib/content-page-repository/resizeImg.js +13 -0
- package/lib/content-page-repository/resizeImg.js.map +1 -0
- package/lib/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/lib/content-page-repository/transformAttachmentLink.js +34 -0
- package/lib/content-page-repository/transformAttachmentLink.js.map +1 -0
- package/lib/content-page-repository/transformContentPage.d.ts +4 -0
- package/lib/content-page-repository/transformContentPage.js +71 -0
- package/lib/content-page-repository/transformContentPage.js.map +1 -0
- package/lib/content-page-repository/transformDocument.d.ts +3 -0
- package/lib/content-page-repository/transformDocument.js +32 -0
- package/lib/content-page-repository/transformDocument.js.map +1 -0
- package/lib/content-page-repository/transformHTML.d.ts +1 -0
- package/lib/content-page-repository/transformHTML.js +25 -0
- package/lib/content-page-repository/transformHTML.js.map +1 -0
- package/lib/content-page-repository/transformImg.d.ts +12 -0
- package/lib/content-page-repository/transformImg.js +45 -0
- package/lib/content-page-repository/transformImg.js.map +1 -0
- package/lib/content-page-repository/transformMarkdown.d.ts +1 -0
- package/lib/content-page-repository/transformMarkdown.js +12 -0
- package/lib/content-page-repository/transformMarkdown.js.map +1 -0
- package/lib/content-page-repository/transformPicture.d.ts +3 -0
- package/lib/content-page-repository/transformPicture.js +22 -0
- package/lib/content-page-repository/transformPicture.js.map +1 -0
- package/lib/model/Fallback.d.ts +1 -0
- package/mobile/bundle/bundle.umd.js +1 -1
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/mobile/bundle/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/mobile/bundle/components/ContentPage/mapSlot.d.ts +2 -0
- package/mobile/bundle/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/mobile/bundle/components/ContentPage/normalizePage.d.ts +3 -0
- package/mobile/bundle/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/mobile/bundle/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/mobile/bundle/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/mobile/bundle/content-page-repository/TransformationOptions.d.ts +4 -0
- package/mobile/bundle/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/mobile/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/bundle/content-page-repository/extensions.d.ts +3 -0
- package/mobile/bundle/content-page-repository/index.d.ts +3 -0
- package/mobile/bundle/content-page-repository/mapJSON.d.ts +1 -0
- package/mobile/bundle/content-page-repository/mergePages.d.ts +2 -0
- package/mobile/bundle/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/mobile/bundle/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/bundle/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/mobile/bundle/content-page-repository/transformContentPage.d.ts +4 -0
- package/mobile/bundle/content-page-repository/transformDocument.d.ts +3 -0
- package/mobile/bundle/content-page-repository/transformHTML.d.ts +1 -0
- package/mobile/bundle/content-page-repository/transformImg.d.ts +12 -0
- package/mobile/bundle/content-page-repository/transformMarkdown.d.ts +1 -0
- package/mobile/bundle/content-page-repository/transformPicture.d.ts +3 -0
- package/mobile/bundle/model/Fallback.d.ts +1 -0
- package/mobile/dist/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/mobile/dist/components/ContentPage/computeAPIFallback.js +36 -0
- package/mobile/dist/components/ContentPage/computeAPIFallback.js.map +1 -0
- package/mobile/dist/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/mobile/dist/components/ContentPage/loadModuleFallback.js +36 -0
- package/mobile/dist/components/ContentPage/loadModuleFallback.js.map +1 -0
- package/mobile/dist/components/ContentPage/mapSlot.d.ts +2 -0
- package/mobile/dist/components/ContentPage/mapSlot.js +16 -0
- package/mobile/dist/components/ContentPage/mapSlot.js.map +1 -0
- package/mobile/dist/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/mobile/dist/components/ContentPage/normalizeBlock.js +18 -0
- package/mobile/dist/components/ContentPage/normalizeBlock.js.map +1 -0
- package/mobile/dist/components/ContentPage/normalizePage.d.ts +3 -0
- package/mobile/dist/components/ContentPage/normalizePage.js +6 -0
- package/mobile/dist/components/ContentPage/normalizePage.js.map +1 -0
- package/mobile/dist/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/mobile/dist/components/ContentPage/toMobileBlock.js +12 -0
- package/mobile/dist/components/ContentPage/toMobileBlock.js.map +1 -0
- package/mobile/dist/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/mobile/dist/content-page-repository/ContentPageRepository.js +31 -0
- package/mobile/dist/content-page-repository/ContentPageRepository.js.map +1 -0
- package/mobile/dist/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/mobile/dist/content-page-repository/JSONDocContentBox.js +39 -0
- package/mobile/dist/content-page-repository/JSONDocContentBox.js.map +1 -0
- package/mobile/dist/content-page-repository/TransformationOptions.d.ts +4 -0
- package/mobile/dist/content-page-repository/TransformationOptions.js +2 -0
- package/mobile/dist/content-page-repository/TransformationOptions.js.map +1 -0
- package/mobile/dist/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/mobile/dist/content-page-repository/clearAttachmentHref.js +6 -0
- package/mobile/dist/content-page-repository/clearAttachmentHref.js.map +1 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.js +18 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/mobile/dist/content-page-repository/extensions.d.ts +3 -0
- package/mobile/dist/content-page-repository/extensions.js +18 -0
- package/mobile/dist/content-page-repository/extensions.js.map +1 -0
- package/mobile/dist/content-page-repository/index.d.ts +3 -0
- package/mobile/dist/content-page-repository/index.js +9 -0
- package/mobile/dist/content-page-repository/index.js.map +1 -0
- package/mobile/dist/content-page-repository/mapJSON.d.ts +1 -0
- package/mobile/dist/content-page-repository/mapJSON.js +26 -0
- package/mobile/dist/content-page-repository/mapJSON.js.map +1 -0
- package/mobile/dist/content-page-repository/mergePages.d.ts +2 -0
- package/mobile/dist/content-page-repository/mergePages.js +7 -0
- package/mobile/dist/content-page-repository/mergePages.js.map +1 -0
- package/mobile/dist/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/mobile/dist/content-page-repository/replaceHeadingTags.js +5 -0
- package/mobile/dist/content-page-repository/replaceHeadingTags.js.map +1 -0
- package/mobile/dist/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/dist/content-page-repository/resizeImg.js +19 -0
- package/mobile/dist/content-page-repository/resizeImg.js.map +1 -0
- package/mobile/dist/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/mobile/dist/content-page-repository/transformAttachmentLink.js +40 -0
- package/mobile/dist/content-page-repository/transformAttachmentLink.js.map +1 -0
- package/mobile/dist/content-page-repository/transformContentPage.d.ts +4 -0
- package/mobile/dist/content-page-repository/transformContentPage.js +78 -0
- package/mobile/dist/content-page-repository/transformContentPage.js.map +1 -0
- package/mobile/dist/content-page-repository/transformDocument.d.ts +3 -0
- package/mobile/dist/content-page-repository/transformDocument.js +38 -0
- package/mobile/dist/content-page-repository/transformDocument.js.map +1 -0
- package/mobile/dist/content-page-repository/transformHTML.d.ts +1 -0
- package/mobile/dist/content-page-repository/transformHTML.js +54 -0
- package/mobile/dist/content-page-repository/transformHTML.js.map +1 -0
- package/mobile/dist/content-page-repository/transformImg.d.ts +12 -0
- package/mobile/dist/content-page-repository/transformImg.js +51 -0
- package/mobile/dist/content-page-repository/transformImg.js.map +1 -0
- package/mobile/dist/content-page-repository/transformMarkdown.d.ts +1 -0
- package/mobile/dist/content-page-repository/transformMarkdown.js +18 -0
- package/mobile/dist/content-page-repository/transformMarkdown.js.map +1 -0
- package/mobile/dist/content-page-repository/transformPicture.d.ts +3 -0
- package/mobile/dist/content-page-repository/transformPicture.js +28 -0
- package/mobile/dist/content-page-repository/transformPicture.js.map +1 -0
- package/mobile/dist/model/Fallback.d.ts +1 -0
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/ContentPage/computeAPIFallback.d.ts +4 -0
- package/mobile/lib/components/ContentPage/computeAPIFallback.js +33 -0
- package/mobile/lib/components/ContentPage/computeAPIFallback.js.map +1 -0
- package/mobile/lib/components/ContentPage/loadModuleFallback.d.ts +2 -0
- package/mobile/lib/components/ContentPage/loadModuleFallback.js +10 -0
- package/mobile/lib/components/ContentPage/loadModuleFallback.js.map +1 -0
- package/mobile/lib/components/ContentPage/mapSlot.d.ts +2 -0
- package/mobile/lib/components/ContentPage/mapSlot.js +13 -0
- package/mobile/lib/components/ContentPage/mapSlot.js.map +1 -0
- package/mobile/lib/components/ContentPage/normalizeBlock.d.ts +3 -0
- package/mobile/lib/components/ContentPage/normalizeBlock.js +15 -0
- package/mobile/lib/components/ContentPage/normalizeBlock.js.map +1 -0
- package/mobile/lib/components/ContentPage/normalizePage.d.ts +3 -0
- package/mobile/lib/components/ContentPage/normalizePage.js +3 -0
- package/mobile/lib/components/ContentPage/normalizePage.js.map +1 -0
- package/mobile/lib/components/ContentPage/toMobileBlock.d.ts +2 -0
- package/mobile/lib/components/ContentPage/toMobileBlock.js +9 -0
- package/mobile/lib/components/ContentPage/toMobileBlock.js.map +1 -0
- package/mobile/lib/content-page-repository/ContentPageRepository.d.ts +10 -0
- package/mobile/lib/content-page-repository/ContentPageRepository.js +25 -0
- package/mobile/lib/content-page-repository/ContentPageRepository.js.map +1 -0
- package/mobile/lib/content-page-repository/JSONDocContentBox.d.ts +8 -0
- package/mobile/lib/content-page-repository/JSONDocContentBox.js +36 -0
- package/mobile/lib/content-page-repository/JSONDocContentBox.js.map +1 -0
- package/mobile/lib/content-page-repository/TransformationOptions.d.ts +4 -0
- package/mobile/lib/content-page-repository/TransformationOptions.js +2 -0
- package/mobile/lib/content-page-repository/TransformationOptions.js.map +1 -0
- package/mobile/lib/content-page-repository/clearAttachmentHref.d.ts +2 -0
- package/mobile/lib/content-page-repository/clearAttachmentHref.js +3 -0
- package/mobile/lib/content-page-repository/clearAttachmentHref.js.map +1 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.js +12 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/mobile/lib/content-page-repository/extensions.d.ts +3 -0
- package/mobile/lib/content-page-repository/extensions.js +16 -0
- package/mobile/lib/content-page-repository/extensions.js.map +1 -0
- package/mobile/lib/content-page-repository/index.d.ts +3 -0
- package/mobile/lib/content-page-repository/index.js +4 -0
- package/mobile/lib/content-page-repository/index.js.map +1 -0
- package/mobile/lib/content-page-repository/mapJSON.d.ts +1 -0
- package/mobile/lib/content-page-repository/mapJSON.js +23 -0
- package/mobile/lib/content-page-repository/mapJSON.js.map +1 -0
- package/mobile/lib/content-page-repository/mergePages.d.ts +2 -0
- package/mobile/lib/content-page-repository/mergePages.js +4 -0
- package/mobile/lib/content-page-repository/mergePages.js.map +1 -0
- package/mobile/lib/content-page-repository/replaceHeadingTags.d.ts +1 -0
- package/mobile/lib/content-page-repository/replaceHeadingTags.js +2 -0
- package/mobile/lib/content-page-repository/replaceHeadingTags.js.map +1 -0
- package/mobile/lib/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/lib/content-page-repository/resizeImg.js +13 -0
- package/mobile/lib/content-page-repository/resizeImg.js.map +1 -0
- package/mobile/lib/content-page-repository/transformAttachmentLink.d.ts +3 -0
- package/mobile/lib/content-page-repository/transformAttachmentLink.js +34 -0
- package/mobile/lib/content-page-repository/transformAttachmentLink.js.map +1 -0
- package/mobile/lib/content-page-repository/transformContentPage.d.ts +4 -0
- package/mobile/lib/content-page-repository/transformContentPage.js +71 -0
- package/mobile/lib/content-page-repository/transformContentPage.js.map +1 -0
- package/mobile/lib/content-page-repository/transformDocument.d.ts +3 -0
- package/mobile/lib/content-page-repository/transformDocument.js +32 -0
- package/mobile/lib/content-page-repository/transformDocument.js.map +1 -0
- package/mobile/lib/content-page-repository/transformHTML.d.ts +1 -0
- package/mobile/lib/content-page-repository/transformHTML.js +25 -0
- package/mobile/lib/content-page-repository/transformHTML.js.map +1 -0
- package/mobile/lib/content-page-repository/transformImg.d.ts +12 -0
- package/mobile/lib/content-page-repository/transformImg.js +45 -0
- package/mobile/lib/content-page-repository/transformImg.js.map +1 -0
- package/mobile/lib/content-page-repository/transformMarkdown.d.ts +1 -0
- package/mobile/lib/content-page-repository/transformMarkdown.js +12 -0
- package/mobile/lib/content-page-repository/transformMarkdown.js.map +1 -0
- package/mobile/lib/content-page-repository/transformPicture.d.ts +3 -0
- package/mobile/lib/content-page-repository/transformPicture.js +22 -0
- package/mobile/lib/content-page-repository/transformPicture.js.map +1 -0
- package/mobile/lib/model/Fallback.d.ts +1 -0
- package/mobile/src/components/ContentPage/computeAPIFallback.ts +67 -0
- package/mobile/src/components/ContentPage/loadModuleFallback.ts +11 -0
- package/mobile/src/components/ContentPage/mapSlot.ts +18 -0
- package/mobile/src/components/ContentPage/normalizeBlock.ts +25 -0
- package/mobile/src/components/ContentPage/normalizePage.ts +8 -0
- package/mobile/src/components/ContentPage/toMobileBlock.ts +11 -0
- package/mobile/src/content-page-repository/ContentPageRepository.ts +31 -0
- package/mobile/src/content-page-repository/JSONDocContentBox.ts +56 -0
- package/mobile/src/content-page-repository/TransformationOptions.ts +4 -0
- package/mobile/src/content-page-repository/clearAttachmentHref.ts +3 -0
- package/mobile/src/content-page-repository/computeImgOutputPath.ts +21 -0
- package/mobile/src/content-page-repository/extensions.ts +17 -0
- package/mobile/src/content-page-repository/index.ts +3 -0
- package/mobile/src/content-page-repository/mapJSON.ts +30 -0
- package/mobile/src/content-page-repository/mergePages.ts +8 -0
- package/mobile/src/content-page-repository/replaceHeadingTags.ts +2 -0
- package/mobile/src/content-page-repository/resizeImg.ts +17 -0
- package/mobile/src/content-page-repository/transformAttachmentLink.ts +46 -0
- package/mobile/src/content-page-repository/transformContentPage.ts +102 -0
- package/mobile/src/content-page-repository/transformDocument.ts +43 -0
- package/mobile/src/content-page-repository/transformHTML.ts +28 -0
- package/mobile/src/content-page-repository/transformImg.ts +81 -0
- package/mobile/src/content-page-repository/transformMarkdown.ts +14 -0
- package/mobile/src/content-page-repository/transformPicture.ts +35 -0
- package/mobile/src/model/Fallback.ts +1 -0
- package/package.json +21 -1
- package/src/components/ContentPage/ContentPage.fixture.mobile.tsx +4 -1
- package/src/components/ContentPage/ContentPage.fixture.tsx +7 -2
- package/src/components/ContentPage/computeAPIFallback.ts +67 -0
- package/src/components/ContentPage/loadModuleFallback.ts +11 -0
- package/src/components/ContentPage/mapSlot.ts +18 -0
- package/src/components/ContentPage/normalizeBlock.mobile.ts +25 -0
- package/src/components/ContentPage/normalizeBlock.ts +21 -0
- package/src/components/ContentPage/normalizePage.ts +8 -0
- package/src/components/ContentPage/toMobileBlock.ts +11 -0
- package/src/content-page-repository/ContentPageRepository.ts +31 -0
- package/src/content-page-repository/JSONDocContentBox.ts +56 -0
- package/src/content-page-repository/TransformationOptions.ts +4 -0
- package/src/content-page-repository/clearAttachmentHref.ts +3 -0
- package/src/content-page-repository/computeImgOutputPath.ts +21 -0
- package/src/content-page-repository/extensions.ts +17 -0
- package/src/content-page-repository/index.ts +3 -0
- package/src/content-page-repository/mapJSON.ts +30 -0
- package/src/content-page-repository/mergePages.ts +8 -0
- package/src/content-page-repository/replaceHeadingTags.ts +2 -0
- package/src/content-page-repository/resizeImg.ts +17 -0
- package/src/content-page-repository/transformAttachmentLink.ts +46 -0
- package/src/content-page-repository/transformContentPage.ts +102 -0
- package/src/content-page-repository/transformDocument.ts +43 -0
- package/src/content-page-repository/transformHTML.ts +28 -0
- package/src/content-page-repository/transformImg.ts +81 -0
- package/src/content-page-repository/transformMarkdown.ts +14 -0
- package/src/content-page-repository/transformPicture.ts +35 -0
- package/src/model/Fallback.ts +1 -0
|
@@ -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,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,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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redneckz/wildless-cms-uni-blocks",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.860",
|
|
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",
|
|
@@ -4,12 +4,15 @@ import '../../setup-fixture';
|
|
|
4
4
|
import { type ContentPageDef } from '../../model/ContentPageDef';
|
|
5
5
|
import { Blocks } from '../Blocks';
|
|
6
6
|
import { ContentPage } from './ContentPage';
|
|
7
|
+
import { normalizePage } from './normalizePage';
|
|
7
8
|
import { useContentPageData } from './useContentPageData';
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
default: () => {
|
|
11
12
|
const data = useContentPageData(Blocks);
|
|
12
13
|
|
|
13
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
<ContentPage blocksRegistry={Blocks} data={normalizePage(Blocks)(data as ContentPageDef)} />
|
|
16
|
+
);
|
|
14
17
|
},
|
|
15
18
|
};
|
|
@@ -5,6 +5,7 @@ import { type BlockDecorator } from '../../model/BlockDecorator';
|
|
|
5
5
|
import { type ContentPageDef } from '../../model/ContentPageDef';
|
|
6
6
|
import { Blocks } from '../Blocks';
|
|
7
7
|
import { ContentPage } from './ContentPage';
|
|
8
|
+
import { normalizePage } from './normalizePage';
|
|
8
9
|
import { useContentPageData } from './useContentPageData';
|
|
9
10
|
|
|
10
11
|
const blockDecorator: BlockDecorator = ({ blockClassName, block, render }, i) => (
|
|
@@ -32,7 +33,11 @@ export default {
|
|
|
32
33
|
const data = useContentPageData(Blocks);
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
<ContentPage
|
|
36
|
+
<ContentPage
|
|
37
|
+
className="bg-main"
|
|
38
|
+
blocksRegistry={Blocks}
|
|
39
|
+
data={normalizePage(Blocks)(data as ContentPageDef)}
|
|
40
|
+
/>
|
|
36
41
|
);
|
|
37
42
|
},
|
|
38
43
|
editor: () => {
|
|
@@ -43,7 +48,7 @@ export default {
|
|
|
43
48
|
<ContentPage
|
|
44
49
|
className="bg-transparent"
|
|
45
50
|
blocksRegistry={Blocks}
|
|
46
|
-
data={data as ContentPageDef}
|
|
51
|
+
data={normalizePage(Blocks)(data as ContentPageDef)}
|
|
47
52
|
blockDecorator={blockDecorator}
|
|
48
53
|
/>
|
|
49
54
|
</div>
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
});
|