@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 @@
|
|
|
1
|
+
{"version":3,"file":"replaceHeadingTags.js","sourceRoot":"","sources":["../../src/content-page-repository/replaceHeadingTags.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CACjD,IAAI,CAAC,UAAU,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
export const resizeImg = (size, options) => (chain) => size
|
|
3
|
+
? chain.resize(size.width || null, size.height || null, {
|
|
4
|
+
/*
|
|
5
|
+
* Editor behaviour with one dimension present: resize by given dimension maintaining aspect ratio. (fit: contain)
|
|
6
|
+
* With two dimensions present: resize trying to fill given dimensions (fit: fill)
|
|
7
|
+
*/
|
|
8
|
+
fit: size.width && size.height ? sharp.fit.fill : sharp.fit.contain,
|
|
9
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
10
|
+
...options,
|
|
11
|
+
})
|
|
12
|
+
: chain;
|
|
13
|
+
//# sourceMappingURL=resizeImg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizeImg.js","sourceRoot":"","sources":["../../src/content-page-repository/resizeImg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D,MAAM,CAAC,MAAM,SAAS,GACpB,CAAC,IAAyB,EAAE,OAAuB,EAAE,EAAE,CACvD,CAAC,KAAY,EAAS,EAAE,CACtB,IAAI;IACF,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE;QACpD;;;WAGG;QACH,GAAG,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO;QACnE,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAC1C,GAAG,OAAO;KACX,CAAC;IACJ,CAAC,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import { isUUID } from '../utils/isUUID.js';
|
|
5
|
+
import { clearAttachmentHref } from './clearAttachmentHref.js';
|
|
6
|
+
const mkdir = util.promisify(fs.mkdir);
|
|
7
|
+
const copyFile = util.promisify(fs.copyFile);
|
|
8
|
+
export async function transformAttachmentLink(link, pagePath, options) {
|
|
9
|
+
if (!link?.href) {
|
|
10
|
+
return link;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return {
|
|
14
|
+
...link,
|
|
15
|
+
href: await transformHref(clearAttachmentHref(link.href), options),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.info(`No "${link.href}" attachment found on page: "${pagePath}"`);
|
|
20
|
+
return link;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function transformHref(input, options) {
|
|
24
|
+
if (isUUID(input)) {
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
27
|
+
const { contentDir, publicDir } = options;
|
|
28
|
+
const docRelativePath = path.relative(contentDir, input);
|
|
29
|
+
const output = path.join(publicDir, docRelativePath);
|
|
30
|
+
await mkdir(path.dirname(output), { recursive: true });
|
|
31
|
+
await copyFile(input, output);
|
|
32
|
+
return path.join('/', docRelativePath);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=transformAttachmentLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformAttachmentLink.js","sourceRoot":"","sources":["../../src/content-page-repository/transformAttachmentLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,IAAe,EACf,QAAgB,EAChB,OAA8B;IAE9B,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,IAAI;QACF,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;SACnE,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,gCAAgC,QAAQ,GAAG,CAAC,CAAC;QAE1E,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,KAAa,EAAE,OAA8B;IACxE,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QACjB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IAErD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ContentPageDef } from '../model/ContentPageDef';
|
|
2
|
+
import { type TransformationOptions } from './TransformationOptions';
|
|
3
|
+
export declare function transformContentPage(pagePath: string, options: TransformationOptions): Promise<ContentPageDef>;
|
|
4
|
+
export declare const generatedPagePath: (pagePath: string) => string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import util from 'util';
|
|
3
|
+
import { isUUID } from '../utils/isUUID.js';
|
|
4
|
+
import { tableFunc } from '../utils/tableFunc.js';
|
|
5
|
+
import { ATTACHMENT_PREFIX } from './clearAttachmentHref.js';
|
|
6
|
+
import { DOCUMENT_EXT_LIST, IMAGE_EXT_LIST, OUTPUT_SUFFIX } from './extensions.js';
|
|
7
|
+
import { mapJSON } from './mapJSON.js';
|
|
8
|
+
import { mergePages } from './mergePages.js';
|
|
9
|
+
import { transformAttachmentLink } from './transformAttachmentLink.js';
|
|
10
|
+
import { transformDocument } from './transformDocument.js';
|
|
11
|
+
import { transformHTML } from './transformHTML.js';
|
|
12
|
+
import { transformMarkdown } from './transformMarkdown.js';
|
|
13
|
+
import { transformPicture } from './transformPicture.js';
|
|
14
|
+
const readFile = util.promisify(fs.readFile);
|
|
15
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
16
|
+
const DEFAULT_PARENT_CONTENT = {};
|
|
17
|
+
export async function transformContentPage(pagePath, options) {
|
|
18
|
+
const content = JSON.parse(await readFile(pagePath, 'utf8'));
|
|
19
|
+
const parentContent = await (content?._extends
|
|
20
|
+
? JSON.parse(await readFile(content._extends, 'utf-8'))
|
|
21
|
+
: DEFAULT_PARENT_CONTENT);
|
|
22
|
+
const mergedContent = mergePages(parentContent, content);
|
|
23
|
+
const result = await mapJSON(mergedContent, async (value, [key]) => {
|
|
24
|
+
try {
|
|
25
|
+
return await transform([value, key])(value, pagePath, options);
|
|
26
|
+
}
|
|
27
|
+
catch (ex) {
|
|
28
|
+
console.warn(`Error while transforming field "${key}" on page: ${pagePath}`);
|
|
29
|
+
console.error(ex);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
});
|
|
33
|
+
await writeFile(generatedPagePath(pagePath), JSON.stringify(result), 'utf-8');
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
const transform = tableFunc([
|
|
37
|
+
[([value, key]) => isMarkdown(key, value), async (value) => transformMarkdown(value)],
|
|
38
|
+
[([value, key]) => isHTML(key, value), async (value) => transformHTML(value)],
|
|
39
|
+
[([value]) => isUUID(value?.src), async (value) => ({ src: value?.src })],
|
|
40
|
+
[
|
|
41
|
+
([value]) => isAttachmentLink(value),
|
|
42
|
+
async (value, pagePath, options) => transformAttachmentLink(value, pagePath, options),
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
([value]) => isAttachmentFile(value, DOCUMENT_EXT_LIST),
|
|
46
|
+
async (value, pagePath, options) => transformDocument(value, pagePath, options),
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
([value]) => isAttachmentFile(value, IMAGE_EXT_LIST),
|
|
50
|
+
async (value, pagePath, options) => transformPicture(value, pagePath, options),
|
|
51
|
+
],
|
|
52
|
+
[() => true, async (value) => value],
|
|
53
|
+
]);
|
|
54
|
+
export const generatedPagePath = (pagePath) => `${pagePath}${OUTPUT_SUFFIX}`;
|
|
55
|
+
const isMarkdown = (key, value) => isString(value) && key?.endsWith('__md');
|
|
56
|
+
const isHTML = (key, value) => isString(value) && key?.endsWith('__html');
|
|
57
|
+
const isAttachmentLink = (_) => isLocalPath(_?.href) && (_.href.startsWith(ATTACHMENT_PREFIX) || isLocalFile(_.href));
|
|
58
|
+
const isAttachmentFile = (_, exts) => Boolean(_ && isLocalPath(_?.src)) && exts.some((ext) => _.src.toLowerCase().endsWith(ext));
|
|
59
|
+
const isLocalPath = (_) => isString(_) && _.length < 1024 && !isURL(_);
|
|
60
|
+
const isURL = (src) => ['data:', 'https:', 'http:'].some((proto) => src.startsWith(proto));
|
|
61
|
+
const isString = (_) => Boolean(_ && typeof _ === 'string');
|
|
62
|
+
const isLocalFile = (_) => isString(_) && isFileExists(_);
|
|
63
|
+
const isFileExists = (_) => {
|
|
64
|
+
try {
|
|
65
|
+
return fs.statSync(_).isFile();
|
|
66
|
+
}
|
|
67
|
+
catch (ex) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=transformContentPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformContentPage.js","sourceRoot":"","sources":["../../src/content-page-repository/transformContentPage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IA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'path';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import { isUUID } from '../utils/isUUID.js';
|
|
5
|
+
const mkdir = util.promisify(fs.mkdir);
|
|
6
|
+
const copyFile = util.promisify(fs.copyFile);
|
|
7
|
+
const stat = util.promisify(fs.stat);
|
|
8
|
+
export async function transformDocument(attachment, pagePath, options) {
|
|
9
|
+
if (!attachment?.src || isUUID(attachment.src)) {
|
|
10
|
+
return attachment;
|
|
11
|
+
}
|
|
12
|
+
const { contentDir, publicDir } = options;
|
|
13
|
+
const input = attachment.src;
|
|
14
|
+
const docRelativePath = path.relative(contentDir, input);
|
|
15
|
+
const output = path.join(publicDir, docRelativePath);
|
|
16
|
+
const inputFileSize = (await stat(input)).size;
|
|
17
|
+
try {
|
|
18
|
+
await mkdir(path.dirname(output), { recursive: true });
|
|
19
|
+
await copyFile(input, output);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.info(`No "${input}" attachment found on page: "${pagePath}"`);
|
|
23
|
+
return attachment;
|
|
24
|
+
}
|
|
25
|
+
const src = path.join('/', docRelativePath);
|
|
26
|
+
return {
|
|
27
|
+
...attachment,
|
|
28
|
+
src,
|
|
29
|
+
fileSize: inputFileSize,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=transformDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformDocument.js","sourceRoot":"","sources":["../../src/content-page-repository/transformDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,Q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
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.js';
|
|
6
|
+
export async function transformHTML(html) {
|
|
7
|
+
if (!html) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const extendedSchema = {
|
|
11
|
+
...defaultSchema,
|
|
12
|
+
protocols: {
|
|
13
|
+
...defaultSchema.protocols,
|
|
14
|
+
href: [...(defaultSchema?.protocols?.href || []), 'tel'],
|
|
15
|
+
src: [...(defaultSchema.protocols?.src ?? []), 'data'],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const result = await unified()
|
|
19
|
+
.use(rehypeParse)
|
|
20
|
+
.use(rehypeSanitize, extendedSchema)
|
|
21
|
+
.use(rehypeStringify)
|
|
22
|
+
.process(html);
|
|
23
|
+
return replaceHeadingTags(result.toString('utf-8'));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=transformHTML.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformHTML.js","sourceRoot":"","sources":["../../src/content-page-repository/transformHTML.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,cAAc,EAAE,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAA+B;IACjE,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IAED,MAAM,cAAc,GAAG;QACrB,GAAG,aAAa;QAChB,SAAS,EAAE;YACT,GAAG,aAAa,CAAC,SAAS;YAC1B,IAAI,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC;YACxD,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC;SACvD;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE;SAC3B,GAAG,CAAC,WAAW,CAAC;SAChB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC;SACnC,GAAG,CAAC,eAAe,CAAC;SACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ImageSize } from '../model/ImageSize';
|
|
2
|
+
import { type ImgSource } from '../model/Picture';
|
|
3
|
+
import { type TransformationOptions } from './TransformationOptions';
|
|
4
|
+
declare type ImgOutputPath = string;
|
|
5
|
+
declare type TransformationTaskKey = ImgOutputPath;
|
|
6
|
+
declare type TransformationTasksCache = Map<TransformationTaskKey, Promise<ImgOutputPath>>;
|
|
7
|
+
declare type TransformImgOptions = TransformationOptions & ImgSource & {
|
|
8
|
+
containerSize?: ImageSize;
|
|
9
|
+
cache?: TransformationTasksCache;
|
|
10
|
+
};
|
|
11
|
+
export declare function transformImg(src: string, pagePath: string, options: TransformImgOptions): ImgOutputPath | Promise<ImgOutputPath>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import sharp from 'sharp';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty.js';
|
|
6
|
+
import { computeImgOutputPath } from './computeImgOutputPath.js';
|
|
7
|
+
import { resizeImg } from './resizeImg.js';
|
|
8
|
+
const mkdir = util.promisify(fs.mkdir);
|
|
9
|
+
const copyFile = util.promisify(fs.copyFile);
|
|
10
|
+
const defaultTransformationCache = new Map();
|
|
11
|
+
const isNilTransform = ({ size, containerSize, format }) => isPictureSizeEmpty(size) && isPictureSizeEmpty(containerSize) && !format;
|
|
12
|
+
const isVectorInput = (input) => ['.svg', '.eps', '.epsf', '.epsi', '.pdf'].some((ext) => input.toLowerCase().endsWith(ext));
|
|
13
|
+
export function transformImg(src, pagePath, options) {
|
|
14
|
+
if (!src) {
|
|
15
|
+
return src;
|
|
16
|
+
}
|
|
17
|
+
const withoutTransform = isNilTransform(options) || isVectorInput(src);
|
|
18
|
+
const output = computeImgOutputPath(src, options, withoutTransform);
|
|
19
|
+
const { cache = defaultTransformationCache } = options;
|
|
20
|
+
const cachedResult = cache.get(output);
|
|
21
|
+
if (cachedResult) {
|
|
22
|
+
return cachedResult;
|
|
23
|
+
}
|
|
24
|
+
const result = (async () => {
|
|
25
|
+
try {
|
|
26
|
+
await mkdir(path.dirname(output), { recursive: true });
|
|
27
|
+
if (withoutTransform) {
|
|
28
|
+
await copyFile(src, output);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const chain = await computeTransformationChain(options)(sharp(src));
|
|
32
|
+
await chain.toFile(output);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
console.info(`No "${src}" attachment found on page: "${pagePath}"`);
|
|
37
|
+
}
|
|
38
|
+
return output;
|
|
39
|
+
})();
|
|
40
|
+
cache.set(output, result);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
const computeTransformationChain = ({ size, containerSize, format, options, }) => pipe(resizeImg(isPictureSizeEmpty(size) ? containerSize : size), (_) => format ? _.toFormat(format, { ...options, lossless: true }) : _);
|
|
44
|
+
const pipe = (...operations) => operations.reduce((a, b) => async (chain) => b(await a(chain)));
|
|
45
|
+
//# sourceMappingURL=transformImg.js.map
|
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CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAChE,CAAC;AAEJ,MAAM,IAAI,GAAG,CAAC,GAAG,UAA2D,EAAE,EAAE,CAC9E,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAY,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transformMarkdown(markdown: string | null | undefined): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import remarkHtml from 'remark-html';
|
|
2
|
+
import remarkParse from 'remark-parse';
|
|
3
|
+
import { unified } from 'unified';
|
|
4
|
+
import { replaceHeadingTags } from './replaceHeadingTags.js';
|
|
5
|
+
export async function transformMarkdown(markdown) {
|
|
6
|
+
if (!markdown) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
const result = await unified().use(remarkParse).use(remarkHtml).process(markdown);
|
|
10
|
+
return replaceHeadingTags(result.toString('utf-8'));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=transformMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformMarkdown.js","sourceRoot":"","sources":["../../src/content-page-repository/transformMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAmC;IACzE,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,EAAE,CAAC;KACX;IAED,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElF,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import { transformImg } from './transformImg.js';
|
|
4
|
+
export async function transformPicture(picture, pagePath, options) {
|
|
5
|
+
const src = picture?.src || '';
|
|
6
|
+
const transformedImgPath = await transformImg(src, pagePath, { ...options, ...picture });
|
|
7
|
+
const { width, height } = await sharp(transformedImgPath).metadata();
|
|
8
|
+
const containerSize = width && height ? { width, height } : undefined;
|
|
9
|
+
const sources = picture.sources || [];
|
|
10
|
+
const transformedSources = await Promise.all(sources.map((_) => transformImg(src, pagePath, { ...options, ..._, containerSize })));
|
|
11
|
+
const imgPathToSrc = (_) => path.join('/', path.relative(options.publicDir, _));
|
|
12
|
+
return {
|
|
13
|
+
...picture,
|
|
14
|
+
src: imgPathToSrc(transformedImgPath),
|
|
15
|
+
sources: transformedSources.map((_, i) => ({
|
|
16
|
+
...sources[i],
|
|
17
|
+
src: imgPathToSrc(_),
|
|
18
|
+
size: { width, height },
|
|
19
|
+
})),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=transformPicture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformPicture.js","sourceRoot":"","sources":["../../src/content-page-repository/transformPicture.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgB,EAChB,QA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 +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
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type BlocksRegistry } from '../../model/BlocksRegistry';
|
|
2
|
+
import { type BlockDef, type Slot } from '../../model/ContentPageDef';
|
|
3
|
+
import { mapSlot } from './mapSlot';
|
|
4
|
+
import { toMobileBlock } from './toMobileBlock';
|
|
5
|
+
|
|
6
|
+
export function normalizeBlock<S extends Slot>(block?: S, blocksRegistry?: BlocksRegistry): S {
|
|
7
|
+
const { mobile } = (block || {}) as BlockDef;
|
|
8
|
+
|
|
9
|
+
return mapSlot(filterBlocks(blocksRegistry))((mobile ? toMobileBlock(block) : block) || {}) as S;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const filterBlocks =
|
|
13
|
+
(blocksRegistry?: BlocksRegistry) =>
|
|
14
|
+
(blocks?: BlockDef[]): BlockDef[] =>
|
|
15
|
+
blocks
|
|
16
|
+
? blocks
|
|
17
|
+
?.filter(
|
|
18
|
+
(block) =>
|
|
19
|
+
blocksRegistry &&
|
|
20
|
+
(block?.type || block?.mobile?.type || '') in blocksRegistry &&
|
|
21
|
+
!block.mobile?.hidden &&
|
|
22
|
+
!block?.hidden,
|
|
23
|
+
)
|
|
24
|
+
.map((block) => normalizeBlock(block, blocksRegistry))
|
|
25
|
+
: [];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BlocksRegistry } from '../../model/BlocksRegistry';
|
|
2
|
+
import { type ContentPageDef } from '../../model/ContentPageDef';
|
|
3
|
+
import { normalizeBlock } from './normalizeBlock';
|
|
4
|
+
|
|
5
|
+
export const normalizePage =
|
|
6
|
+
(blocksRegistry: BlocksRegistry) =>
|
|
7
|
+
(contentPage: ContentPageDef | undefined | null): ContentPageDef =>
|
|
8
|
+
contentPage ? normalizeBlock(contentPage, blocksRegistry) : {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type BlockDef } from '../../model/ContentPageDef';
|
|
2
|
+
|
|
3
|
+
export function toMobileBlock(block: BlockDef = {}): BlockDef {
|
|
4
|
+
const { mobile, ...desktop } = block;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
...desktop,
|
|
8
|
+
...(mobile?.style ? { style: mobile.style } : {}),
|
|
9
|
+
...(mobile?.content ? { content: mobile.content } : {}),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|