@alanizcreative/formation-static 1.3.0-beta.36 → 1.3.0-beta.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/cjs/components/Navigation/Navigation.js +1 -1
  2. package/cjs/contentful/contentfulDataNormal.js +1 -1
  3. package/cjs/local/localDataNormal.js +1 -1
  4. package/cjs/redirects/redirects.js +1 -1
  5. package/cjs/render/render.js +1 -1
  6. package/cjs/render/renderTypes.d.ts +0 -1
  7. package/cjs/serverless/Ajax/Ajax.js +1 -1
  8. package/cjs/serverless/Contact/Contact.js +1 -1
  9. package/cjs/serverless/serverless.js +1 -1
  10. package/cjs/store/store.js +1 -1
  11. package/cjs/text/RichText/RichText.js +1 -1
  12. package/cjs/utils/action/action.js +1 -1
  13. package/cjs/utils/archive/archive.js +1 -1
  14. package/cjs/utils/filter/filter.js +1 -1
  15. package/cjs/utils/image/image.js +1 -1
  16. package/cjs/utils/image/imageLocal.js +1 -1
  17. package/cjs/utils/image/imageRemote.js +1 -1
  18. package/cjs/utils/json/json.js +1 -1
  19. package/cjs/utils/link/link.js +1 -1
  20. package/cjs/utils/link/linkShare.js +1 -1
  21. package/cjs/utils/path/path.js +1 -1
  22. package/cjs/utils/scriptStyle/scriptStyle.js +1 -1
  23. package/cjs/utils/shortcode/shortcode.js +1 -1
  24. package/cjs/utils/tag/tag.js +1 -1
  25. package/cjs/wordpress/wordpressDataNormal.js +1 -1
  26. package/lib/components/Navigation/Navigation.js +1 -1
  27. package/lib/contentful/contentfulDataNormal.js +1 -1
  28. package/lib/local/localDataNormal.js +1 -1
  29. package/lib/redirects/redirects.js +1 -1
  30. package/lib/render/render.js +1 -1
  31. package/lib/render/renderTypes.d.ts +0 -1
  32. package/lib/serverless/Ajax/Ajax.js +1 -1
  33. package/lib/serverless/Contact/Contact.js +1 -1
  34. package/lib/serverless/serverless.js +1 -1
  35. package/lib/store/store.js +1 -1
  36. package/lib/text/RichText/RichText.js +1 -1
  37. package/lib/utils/action/action.js +1 -1
  38. package/lib/utils/archive/archive.js +1 -1
  39. package/lib/utils/filter/filter.js +1 -1
  40. package/lib/utils/image/image.js +1 -1
  41. package/lib/utils/image/imageLocal.js +1 -1
  42. package/lib/utils/image/imageRemote.js +1 -1
  43. package/lib/utils/link/link.js +1 -1
  44. package/lib/utils/link/linkShare.js +1 -1
  45. package/lib/utils/path/path.js +1 -1
  46. package/lib/utils/scriptStyle/scriptStyle.js +1 -1
  47. package/lib/utils/shortcode/shortcode.js +1 -1
  48. package/lib/utils/tag/tag.js +1 -1
  49. package/lib/wordpress/wordpressDataNormal.js +1 -1
  50. package/package.json +13 -14
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Navigation=void 0;const link_js_1=require("../../utils/link/link.js"),array_js_1=require("../../utils/array/array.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),function_js_1=require("../../utils/function/function.js"),number_js_1=require("../../utils/number/number.js"),contentType_js_1=require("../../utils/contentType/contentType.js"),archive_js_1=require("../../utils/archive/archive.js");class Navigation{navigations=[];items=[];init=!1;#itemsById=new Map;#navigationsByLocation=new Map;constructor(props){this.init=this.#initialize(props)}#initialize(props){if(!(0,object_js_1.isObjectStrict)(props))return!1;const{navigations:navigations,items:items}=props;return!(!(0,array_js_1.isArrayStrict)(navigations)||!(0,array_js_1.isArrayStrict)(items))&&(this.navigations=navigations,this.items=items,this.items.forEach((item=>{(0,object_js_1.isObjectStrict)(item)&&this.#itemsById.set(item.id,item)})),this.navigations.forEach((nav=>{if(!(0,object_js_1.isObjectStrict)(nav))return;const{title:title,location:location,items:items=[]}=nav,locations=(0,array_js_1.isArrayStrict)(location)?location:[location];(0,string_js_1.isStringStrict)(title)&&(0,array_js_1.isArrayStrict)(items)&&locations.forEach((loc=>{this.#navigationsByLocation.set(loc,{title:title,items:items})}))})),!0)}#recurseItemChildren(children,output,currentLink="",currentType=[]){let childCurrent=!1;return children.forEach((child=>{const newItem=this.#getItem(this.#itemsById.get(child?.id||""),currentLink,currentType);if(!newItem)return;const{current:current,archiveCurrent:archiveCurrent}=newItem;(current||archiveCurrent)&&(childCurrent=!0),output.push(newItem)})),childCurrent}#getItem(item,currentLink,currentType=[]){if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,title:title,link:link,internalLink:internalLink,externalLink:externalLink,children:children}=item;let external=!1;(0,string_js_1.isStringStrict)(externalLink)&&(external=!0);const newLink=(0,string_js_1.isStringStrict)(link)?link:(0,link_js_1.getLink)(internalLink,externalLink),newItem={...item,id:id,title:title,link:newLink,external:external};newLink&&!external&&(newItem.current=newLink===currentLink);const internalId=internalLink?.id;if((0,string_js_1.isStringStrict)(internalId)){let archiveCurrent=!1;for(const type of currentType){if(internalId===(0,archive_js_1.getArchiveMeta)(type,internalLink?.locale).id){archiveCurrent=!0;break}}newItem.archiveCurrent=archiveCurrent}let descendentCurrent=!1;if((0,array_js_1.isArrayStrict)(children)){const newChildren=[];descendentCurrent=this.#recurseItemChildren(children,newChildren,currentLink,currentType),newItem.children=newChildren}return descendentCurrent&&(newItem.descendentCurrent=descendentCurrent),newItem}#getItems(items=[],currentLink,currentType){const resItems=[];return items.forEach((item=>{const newItem=this.#getItem(this.#itemsById.get(item?.id||""),currentLink,currentType);newItem&&resItems.push(newItem)})),resItems}#recurseOutput=(items,output,args,depth=0,maxDepth)=>{if((0,number_js_1.isNumber)(maxDepth)&&depth>maxDepth)return;const dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",depthAttr=args.depthAttr?` ${dataAttr}-depth="${depth}"`:"",listFilterArgs={args:args,output:output,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeList)&&args.filterBeforeList(listFilterArgs);const listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",listTag=(0,string_js_1.isStringStrict)(args.listTag)?args.listTag:"ul";output.ref+=`<${listTag}${depthAttr}${listClasses}${listAttrs}>`,items.forEach(((item,index)=>{const{title:title,link:link,external:external=!1,children:children,current:current=!1,descendentCurrent:descendentCurrent=!1,archiveCurrent:archiveCurrent=!1}=item,filterArgs={args:args,item:item,output:output,index:index,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeItem)&&args.filterBeforeItem(filterArgs);const itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemTag=(0,string_js_1.isStringStrict)(args.itemTag)?args.itemTag:"li";let itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"";current&&(itemAttrs+=` ${dataAttr}-current`),descendentCurrent&&(itemAttrs+=` ${dataAttr}-descendent-current`),archiveCurrent&&(itemAttrs+=` ${dataAttr}-archive-current`),output.ref+=`<${itemTag}${depthAttr}${itemClasses}${itemAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),!external&&(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const hasLink=(0,string_js_1.isStringStrict)(link),linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrsArr=[hasLink?`href="${link}"`:'type="button"'];(0,string_js_1.isStringStrict)(args.linkAttr)&&linkAttrsArr.push(args.linkAttr),current&&(linkAttrsArr.push(`${dataAttr}-current`),hasLink&&linkAttrsArr.push('aria-current="page"')),descendentCurrent&&linkAttrsArr.push(`${dataAttr}-descendent-current`),archiveCurrent&&linkAttrsArr.push(`${dataAttr}-archive-current`);const linkAttrs=` ${linkAttrsArr.join(" ")}`,linkTag=hasLink?"a":"button";output.ref+=`<${linkTag}${depthAttr}${linkClasses}${linkAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLinkText)&&args.filterBeforeLinkText(filterArgs),output.ref+=title,(0,function_js_1.isFunction)(args.filterAfterLinkText)&&args.filterAfterLinkText(filterArgs),output.ref+=`</${linkTag}>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),(0,array_js_1.isArrayStrict)(children)&&this.#recurseOutput(children,output,args,depth+1,maxDepth),output.ref+=`</${itemTag}>`,(0,function_js_1.isFunction)(args.filterAfterItem)&&args.filterAfterItem(filterArgs)})),output.ref+=`</${listTag}>`,(0,function_js_1.isFunction)(args.filterAfterList)&&args.filterAfterList(listFilterArgs)};getOutput(location,args,maxDepth){const nav=this.#navigationsByLocation.get(location);if(!nav)return"";args=Object.assign({depthAttr:!1},args||{});const items=nav.items,{currentLink:currentLink,currentType:currentType}=args,currLink=(0,string_js_1.isStringStrict)(currentLink)?currentLink:"",currType=((0,array_js_1.isArrayStrict)(currentType)?currentType:[currentType]).map((type=>(0,contentType_js_1.normalizeContentType)(type))),normalizedItems=this.#getItems(items,currLink,currType);if(!normalizedItems.length)return"";const output={ref:""};return this.#recurseOutput(normalizedItems,output,args,0,maxDepth),output.ref}getBreadcrumbs(items,args){if(!(0,array_js_1.isArrayStrict)(items))return"";const current=(args=Object.assign({a11yClass:"a-hide-vis"},args||{})).current,dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",filteredItems=items.filter((item=>!!(0,string_js_1.isStringStrict)(item.title)&&(!!(0,string_js_1.isString)(item.slug)&&(item.slug=(0,link_js_1.getSlug)({id:item.id,slug:item.slug,contentType:item.contentType,itemData:item.internalLink}),!0)))),itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"",lastItemIndex=filteredItems.length-1,itemsArr=filteredItems.map(((item,index)=>{const{title:title,slug:slug}=item,link=(0,link_js_1.getPermalink)(slug),output={ref:""},lastLevel=lastItemIndex===index,filterArgs={output:output,lastLevel:lastLevel};output.ref+=`<li${itemClasses}${itemAttrs}${lastLevel?` ${dataAttr}-last`:""}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrs=(0,string_js_1.isStringStrict)(args.linkAttr)?` ${args.linkAttr}`:"";return output.ref+=`<a${linkClasses} href="${link}"${linkAttrs}>${title}</a>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),output.ref+="</li>",output.ref})),currentLabel=(0,string_js_1.isStringStrict)(args.currentLabel)?args.currentLabel:"(current page)",currentClasses=(0,string_js_1.isStringStrict)(args.currentClass)?` class="${args.currentClass}"`:"",a11yClasses=(0,string_js_1.isStringStrict)(args.a11yClass)?` class="${args.a11yClass}"`:"",currentItem=(0,string_js_1.isStringStrict)(current)?`\n <li${itemClasses}${itemAttrs} ${dataAttr}-current>\n <span${currentClasses}>${current}<span${a11yClasses}> ${currentLabel}</span></span>\n </li>\n `:"";return`\n <ol${listClasses}${listAttrs}>\n ${itemsArr.join("")}\n ${currentItem}\n </ol>\n `}getItemsById(){return this.#itemsById}getNavigationsByLocation(){return this.#navigationsByLocation}getNavigationByLocation(location){return this.#navigationsByLocation.get(location)}}exports.Navigation=Navigation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Navigation=void 0;const link_js_1=require("../../utils/link/link.js"),array_js_1=require("../../utils/array/array.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),function_js_1=require("../../utils/function/function.js"),number_js_1=require("../../utils/number/number.js"),contentType_js_1=require("../../utils/contentType/contentType.js"),archive_js_1=require("../../utils/archive/archive.js");class Navigation{navigations=[];items=[];init=!1;#itemsById=new Map;#navigationsByLocation=new Map;constructor(props){this.init=this.#initialize(props)}#initialize(props){if(!(0,object_js_1.isObjectStrict)(props))return!1;const{navigations:navigations,items:items}=props;return!(!(0,array_js_1.isArrayStrict)(navigations)||!(0,array_js_1.isArrayStrict)(items))&&(this.navigations=navigations,this.items=items,this.items.forEach(item=>{(0,object_js_1.isObjectStrict)(item)&&this.#itemsById.set(item.id,item)}),this.navigations.forEach(nav=>{if(!(0,object_js_1.isObjectStrict)(nav))return;const{title:title,location:location,items:items=[]}=nav,locations=(0,array_js_1.isArrayStrict)(location)?location:[location];(0,string_js_1.isStringStrict)(title)&&(0,array_js_1.isArrayStrict)(items)&&locations.forEach(loc=>{this.#navigationsByLocation.set(loc,{title:title,items:items})})}),!0)}#recurseItemChildren(children,output,currentLink="",currentType=[]){let childCurrent=!1;return children.forEach(child=>{const newItem=this.#getItem(this.#itemsById.get(child?.id||""),currentLink,currentType);if(!newItem)return;const{current:current,archiveCurrent:archiveCurrent}=newItem;(current||archiveCurrent)&&(childCurrent=!0),output.push(newItem)}),childCurrent}#getItem(item,currentLink,currentType=[]){if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,title:title,link:link,internalLink:internalLink,externalLink:externalLink,children:children}=item;let external=!1;(0,string_js_1.isStringStrict)(externalLink)&&(external=!0);const newLink=(0,string_js_1.isStringStrict)(link)?link:(0,link_js_1.getLink)(internalLink,externalLink),newItem={...item,id:id,title:title,link:newLink,external:external};newLink&&!external&&(newItem.current=newLink===currentLink);const internalId=internalLink?.id;if((0,string_js_1.isStringStrict)(internalId)){let archiveCurrent=!1;for(const type of currentType){if(internalId===(0,archive_js_1.getArchiveMeta)(type,internalLink?.locale).id){archiveCurrent=!0;break}}newItem.archiveCurrent=archiveCurrent}let descendentCurrent=!1;if((0,array_js_1.isArrayStrict)(children)){const newChildren=[];descendentCurrent=this.#recurseItemChildren(children,newChildren,currentLink,currentType),newItem.children=newChildren}return descendentCurrent&&(newItem.descendentCurrent=descendentCurrent),newItem}#getItems(items=[],currentLink,currentType){const resItems=[];return items.forEach(item=>{const newItem=this.#getItem(this.#itemsById.get(item?.id||""),currentLink,currentType);newItem&&resItems.push(newItem)}),resItems}#recurseOutput=(items,output,args,depth=0,maxDepth)=>{if((0,number_js_1.isNumber)(maxDepth)&&depth>maxDepth)return;const dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",depthAttr=args.depthAttr?` ${dataAttr}-depth="${depth}"`:"",listFilterArgs={args:args,output:output,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeList)&&args.filterBeforeList(listFilterArgs);const listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",listTag=(0,string_js_1.isStringStrict)(args.listTag)?args.listTag:"ul";output.ref+=`<${listTag}${depthAttr}${listClasses}${listAttrs}>`,items.forEach((item,index)=>{const{title:title,link:link,external:external=!1,children:children,current:current=!1,descendentCurrent:descendentCurrent=!1,archiveCurrent:archiveCurrent=!1}=item,filterArgs={args:args,item:item,output:output,index:index,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeItem)&&args.filterBeforeItem(filterArgs);const itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemTag=(0,string_js_1.isStringStrict)(args.itemTag)?args.itemTag:"li";let itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"";current&&(itemAttrs+=` ${dataAttr}-current`),descendentCurrent&&(itemAttrs+=` ${dataAttr}-descendent-current`),archiveCurrent&&(itemAttrs+=` ${dataAttr}-archive-current`),output.ref+=`<${itemTag}${depthAttr}${itemClasses}${itemAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),!external&&(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const hasLink=(0,string_js_1.isStringStrict)(link),linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrsArr=[hasLink?`href="${link}"`:'type="button"'];(0,string_js_1.isStringStrict)(args.linkAttr)&&linkAttrsArr.push(args.linkAttr),current&&(linkAttrsArr.push(`${dataAttr}-current`),hasLink&&linkAttrsArr.push('aria-current="page"')),descendentCurrent&&linkAttrsArr.push(`${dataAttr}-descendent-current`),archiveCurrent&&linkAttrsArr.push(`${dataAttr}-archive-current`);const linkAttrs=` ${linkAttrsArr.join(" ")}`,linkTag=hasLink?"a":"button";output.ref+=`<${linkTag}${depthAttr}${linkClasses}${linkAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLinkText)&&args.filterBeforeLinkText(filterArgs),output.ref+=title,(0,function_js_1.isFunction)(args.filterAfterLinkText)&&args.filterAfterLinkText(filterArgs),output.ref+=`</${linkTag}>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),(0,array_js_1.isArrayStrict)(children)&&this.#recurseOutput(children,output,args,depth+1,maxDepth),output.ref+=`</${itemTag}>`,(0,function_js_1.isFunction)(args.filterAfterItem)&&args.filterAfterItem(filterArgs)}),output.ref+=`</${listTag}>`,(0,function_js_1.isFunction)(args.filterAfterList)&&args.filterAfterList(listFilterArgs)};getOutput(location,args,maxDepth){const nav=this.#navigationsByLocation.get(location);if(!nav)return"";args=Object.assign({depthAttr:!1},args||{});const items=nav.items,{currentLink:currentLink,currentType:currentType}=args,currLink=(0,string_js_1.isStringStrict)(currentLink)?currentLink:"",currType=((0,array_js_1.isArrayStrict)(currentType)?currentType:[currentType]).map(type=>(0,contentType_js_1.normalizeContentType)(type)),normalizedItems=this.#getItems(items,currLink,currType);if(!normalizedItems.length)return"";const output={ref:""};return this.#recurseOutput(normalizedItems,output,args,0,maxDepth),output.ref}getBreadcrumbs(items,args){if(!(0,array_js_1.isArrayStrict)(items))return"";const current=(args=Object.assign({a11yClass:"a-hide-vis"},args||{})).current,dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",filteredItems=items.filter(item=>!!(0,string_js_1.isStringStrict)(item.title)&&(!!(0,string_js_1.isString)(item.slug)&&(item.slug=(0,link_js_1.getSlug)({id:item.id,slug:item.slug,contentType:item.contentType,itemData:item.internalLink}),!0))),itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"",lastItemIndex=filteredItems.length-1,itemsArr=filteredItems.map((item,index)=>{const{title:title,slug:slug}=item,link=(0,link_js_1.getPermalink)(slug),output={ref:""},lastLevel=lastItemIndex===index,filterArgs={output:output,lastLevel:lastLevel};output.ref+=`<li${itemClasses}${itemAttrs}${lastLevel?` ${dataAttr}-last`:""}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrs=(0,string_js_1.isStringStrict)(args.linkAttr)?` ${args.linkAttr}`:"";return output.ref+=`<a${linkClasses} href="${link}"${linkAttrs}>${title}</a>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),output.ref+="</li>",output.ref}),currentLabel=(0,string_js_1.isStringStrict)(args.currentLabel)?args.currentLabel:"(current page)",currentClasses=(0,string_js_1.isStringStrict)(args.currentClass)?` class="${args.currentClass}"`:"",a11yClasses=(0,string_js_1.isStringStrict)(args.a11yClass)?` class="${args.a11yClass}"`:"",currentItem=(0,string_js_1.isStringStrict)(current)?`\n <li${itemClasses}${itemAttrs} ${dataAttr}-current>\n <span${currentClasses}>${current}<span${a11yClasses}> ${currentLabel}</span></span>\n </li>\n `:"";return`\n <ol${listClasses}${listAttrs}>\n ${itemsArr.join("")}\n ${currentItem}\n </ol>\n `}getItemsById(){return this.#itemsById}getNavigationsByLocation(){return this.#navigationsByLocation}getNavigationByLocation(location){return this.#navigationsByLocation.get(location)}}exports.Navigation=Navigation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeContentfulData=void 0;const contentType_js_1=require("../utils/contentType/contentType.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),objectUtils_js_1=require("../utils/object/objectUtils.js"),number_js_1=require("../utils/number/number.js"),config_js_1=require("../config/config.js"),getTag=(type="text")=>({br:"br",hr:"hr",paragraph:"p",blockquote:"blockquote",bold:"b",italic:"i",underline:"u",superscript:"sup",subscript:"sub",code:"code",hyperlink:"a","entry-hyperlink":"a","asset-hyperlink":"a","heading-1":"h1","heading-2":"h2","heading-3":"h3","heading-4":"h4","heading-5":"h5","heading-6":"h6","list-item":"li","unordered-list":"ul","ordered-list":"ol",table:"table","table-row":"tr","table-cell":"td","table-header-cell":"th"}[type]||""),normalizeRichText=items=>{const newItems=[];return items.forEach((item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{nodeType:nodeType,data:data,value:value,marks:marks,content:content}=item,tag=getTag(nodeType);let contentValue,link,internalLink;if((0,string_js_1.isStringStrict)(value)&&(contentValue=value,contentValue=contentValue.replace(/\n/g,"<br>"),(0,array_js_1.isArrayStrict)(marks))){const markTags=marks.map((m=>getTag(m.type)));contentValue=`${markTags.map((m=>`<${m}>`)).join("")}${value}${markTags.map((m=>`</${m}>`)).join("")}`}if((0,string_js_1.isStringStrict)(content)&&(contentValue=content),(0,array_js_1.isArrayStrict)(content)){const contentArr=normalizeRichText(content);contentArr.length&&(contentValue=contentArr)}if((0,object_js_1.isObjectStrict)(data)&&(link=(0,string_js_1.isString)(data.uri)?data.uri:"",(0,object_js_1.isObjectStrict)(data.target))){const target=data.target;"entry-hyperlink"===nodeType&&(internalLink=target);const url=target.fields?.file?.url;"asset-hyperlink"===nodeType&&(0,string_js_1.isString)(url)&&(link=`https:${url}`)}if(!contentValue)return;const newItem={content:contentValue};return(0,string_js_1.isStringStrict)(tag)&&(newItem.tag=tag),(0,string_js_1.isStringStrict)(link)&&(newItem.link=link),(0,object_js_1.isObjectStrict)(internalLink)&&(newItem.internalLink=normalizeItem(internalLink,[],!0)),newItems.push(newItem)})),newItems},normalizeFile=(file,fields)=>{const type=(0,string_js_1.isString)(file.contentType)?file.contentType:"",format=type?type.split("/")[1]:"";return{url:(0,string_js_1.isString)(file.url)?`https:${file.url}`:"",name:(0,string_js_1.isString)(file.fileName)?file.fileName:"",alt:(0,string_js_1.isString)(fields.description)?fields.description:"",width:(0,number_js_1.isNumber)(file.details?.image?.width)?file.details.image.width:0,height:(0,number_js_1.isNumber)(file.details?.image?.height)?file.details.image.height:0,size:(0,number_js_1.isNumber)(file.details?.size)?file.details.size:0,format:"jpeg"===format?"jpg":format,type:type}},normalizeItem=(item,data,isInternalLink=!1)=>{let newItem={};const itemCopy={...item};(0,string_js_1.isString)(itemCopy.sys?.id)&&(newItem.id=itemCopy.sys.id),(0,string_js_1.isStringStrict)(itemCopy.sys?.locale)&&(newItem.locale=itemCopy.sys.locale);let type="";if((0,string_js_1.isString)(itemCopy.sys?.type)&&(type=itemCopy.sys.type),(0,string_js_1.isString)(itemCopy.sys?.contentType?.sys?.id)&&(type=itemCopy.sys.contentType.sys.id),type&&"Link"!==type&&(newItem.contentType=(0,contentType_js_1.normalizeContentType)(type),(0,string_js_1.isString)(config_js_1.config.renderTypes[type])&&(newItem.renderType=config_js_1.config.renderTypes[type])),(0,array_js_1.isArrayStrict)(itemCopy.metadata?.tags)&&(newItem.metadata={tags:itemCopy.metadata.tags.map((t=>({id:(0,string_js_1.isString)(t.sys?.id)?t.sys.id:""})))}),(0,object_js_1.isObjectStrict)(itemCopy.fields)){const fields=itemCopy.fields,file=fields.file;if((0,object_js_1.isObjectStrict)(file))return Object.assign(normalizeFile(file,fields),newItem);(0,objectUtils_js_1.getObjectKeys)(fields).forEach((prop=>{const field=fields[prop];if("content"!==prop||!isInternalLink)if((0,object_js_1.isObjectStrict)(field))if("document"===field.nodeType){const{content:content}=field;(0,array_js_1.isArrayStrict)(content)&&(newItem[prop]=content.map((c=>(0,object_js_1.isObjectStrict)(c)?normalizeItem(c,data,isInternalLink):c)))}else newItem[prop]=normalizeItem(field,data,"internalLink"===prop);else(0,array_js_1.isArrayStrict)(field)?newItem[prop]=field.map((f=>(0,object_js_1.isObjectStrict)(f)?normalizeItem(f,data,isInternalLink):f)):newItem[prop]=field}))}if((0,string_js_1.isString)(itemCopy.nodeType)){const nodeType=itemCopy.nodeType;if("embedded-entry-block"===nodeType||"embedded-asset-block"===nodeType){const content=(0,object_js_1.isObjectStrict)(itemCopy.data?.target)?itemCopy.data.target:{};newItem=normalizeItem(content,data,isInternalLink)}else newItem.renderType="richText",newItem.tag=getTag(itemCopy.nodeType),(0,string_js_1.isString)(itemCopy.content)&&(newItem.content=itemCopy.content),(0,array_js_1.isArrayStrict)(itemCopy.content)&&(newItem.content=normalizeRichText(itemCopy.content))}return newItem},normalizeContentfulData=(data,_newData=[])=>(0,array_js_1.isArrayStrict)(data)?(data.forEach((item=>{(0,object_js_1.isObjectStrict)(item)&&_newData.push(normalizeItem(item,_newData))})),_newData):[];exports.normalizeContentfulData=normalizeContentfulData;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeContentfulData=void 0;const contentType_js_1=require("../utils/contentType/contentType.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),objectUtils_js_1=require("../utils/object/objectUtils.js"),number_js_1=require("../utils/number/number.js"),config_js_1=require("../config/config.js"),getTag=(type="text")=>({br:"br",hr:"hr",paragraph:"p",blockquote:"blockquote",bold:"b",italic:"i",underline:"u",superscript:"sup",subscript:"sub",code:"code",hyperlink:"a","entry-hyperlink":"a","asset-hyperlink":"a","heading-1":"h1","heading-2":"h2","heading-3":"h3","heading-4":"h4","heading-5":"h5","heading-6":"h6","list-item":"li","unordered-list":"ul","ordered-list":"ol",table:"table","table-row":"tr","table-cell":"td","table-header-cell":"th"}[type]||""),normalizeRichText=items=>{const newItems=[];return items.forEach(item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{nodeType:nodeType,data:data,value:value,marks:marks,content:content}=item,tag=getTag(nodeType);let contentValue,link,internalLink;if((0,string_js_1.isStringStrict)(value)&&(contentValue=value,contentValue=contentValue.replace(/\n/g,"<br>"),(0,array_js_1.isArrayStrict)(marks))){const markTags=marks.map(m=>getTag(m.type));contentValue=`${markTags.map(m=>`<${m}>`).join("")}${value}${markTags.map(m=>`</${m}>`).join("")}`}if((0,string_js_1.isStringStrict)(content)&&(contentValue=content),(0,array_js_1.isArrayStrict)(content)){const contentArr=normalizeRichText(content);contentArr.length&&(contentValue=contentArr)}if((0,object_js_1.isObjectStrict)(data)&&(link=(0,string_js_1.isString)(data.uri)?data.uri:"",(0,object_js_1.isObjectStrict)(data.target))){const target=data.target;"entry-hyperlink"===nodeType&&(internalLink=target);const url=target.fields?.file?.url;"asset-hyperlink"===nodeType&&(0,string_js_1.isString)(url)&&(link=`https:${url}`)}if(!contentValue)return;const newItem={content:contentValue};return(0,string_js_1.isStringStrict)(tag)&&(newItem.tag=tag),(0,string_js_1.isStringStrict)(link)&&(newItem.link=link),(0,object_js_1.isObjectStrict)(internalLink)&&(newItem.internalLink=normalizeItem(internalLink,[],!0)),newItems.push(newItem)}),newItems},normalizeFile=(file,fields)=>{const type=(0,string_js_1.isString)(file.contentType)?file.contentType:"",format=type?type.split("/")[1]:"";return{url:(0,string_js_1.isString)(file.url)?`https:${file.url}`:"",name:(0,string_js_1.isString)(file.fileName)?file.fileName:"",alt:(0,string_js_1.isString)(fields.description)?fields.description:"",width:(0,number_js_1.isNumber)(file.details?.image?.width)?file.details.image.width:0,height:(0,number_js_1.isNumber)(file.details?.image?.height)?file.details.image.height:0,size:(0,number_js_1.isNumber)(file.details?.size)?file.details.size:0,format:"jpeg"===format?"jpg":format,type:type}},normalizeItem=(item,data,isInternalLink=!1)=>{let newItem={};const itemCopy={...item};(0,string_js_1.isString)(itemCopy.sys?.id)&&(newItem.id=itemCopy.sys.id),(0,string_js_1.isStringStrict)(itemCopy.sys?.locale)&&(newItem.locale=itemCopy.sys.locale);let type="";if((0,string_js_1.isString)(itemCopy.sys?.type)&&(type=itemCopy.sys.type),(0,string_js_1.isString)(itemCopy.sys?.contentType?.sys?.id)&&(type=itemCopy.sys.contentType.sys.id),type&&"Link"!==type&&(newItem.contentType=(0,contentType_js_1.normalizeContentType)(type),(0,string_js_1.isString)(config_js_1.config.renderTypes[type])&&(newItem.renderType=config_js_1.config.renderTypes[type])),(0,array_js_1.isArrayStrict)(itemCopy.metadata?.tags)&&(newItem.metadata={tags:itemCopy.metadata.tags.map(t=>({id:(0,string_js_1.isString)(t.sys?.id)?t.sys.id:""}))}),(0,object_js_1.isObjectStrict)(itemCopy.fields)){const fields=itemCopy.fields,file=fields.file;if((0,object_js_1.isObjectStrict)(file))return Object.assign(normalizeFile(file,fields),newItem);(0,objectUtils_js_1.getObjectKeys)(fields).forEach(prop=>{const field=fields[prop];if("content"!==prop||!isInternalLink)if((0,object_js_1.isObjectStrict)(field))if("document"===field.nodeType){const{content:content}=field;(0,array_js_1.isArrayStrict)(content)&&(newItem[prop]=content.map(c=>(0,object_js_1.isObjectStrict)(c)?normalizeItem(c,data,isInternalLink):c))}else newItem[prop]=normalizeItem(field,data,"internalLink"===prop);else(0,array_js_1.isArrayStrict)(field)?newItem[prop]=field.map(f=>(0,object_js_1.isObjectStrict)(f)?normalizeItem(f,data,isInternalLink):f):newItem[prop]=field})}if((0,string_js_1.isString)(itemCopy.nodeType)){const nodeType=itemCopy.nodeType;if("embedded-entry-block"===nodeType||"embedded-asset-block"===nodeType){const content=(0,object_js_1.isObjectStrict)(itemCopy.data?.target)?itemCopy.data.target:{};newItem=normalizeItem(content,data,isInternalLink)}else newItem.renderType="richText",newItem.tag=getTag(itemCopy.nodeType),(0,string_js_1.isString)(itemCopy.content)&&(newItem.content=itemCopy.content),(0,array_js_1.isArrayStrict)(itemCopy.content)&&(newItem.content=normalizeRichText(itemCopy.content))}return newItem},normalizeContentfulData=(data,_newData=[])=>(0,array_js_1.isArrayStrict)(data)?(data.forEach(item=>{(0,object_js_1.isObjectStrict)(item)&&_newData.push(normalizeItem(item,_newData))}),_newData):[];exports.normalizeContentfulData=normalizeContentfulData;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeLocalData=void 0;const object_js_1=require("../utils/object/object.js"),array_js_1=require("../utils/array/array.js"),string_js_1=require("../utils/string/string.js"),store_js_1=require("../store/store.js"),normalizeLocalRefs=(data,refData,imageData,refProps=["internalLink","term","taxonomy"],imageProps=["image"],unsetProps=["content"],contentType)=>{const newData=(0,array_js_1.isArray)(data)?[]:{},isTemplate="contentTemplate"===data.renderType,isNavigation="navigation"===contentType,isNavigationItem="navigationItem"===contentType;for(const[key,value]of Object.entries(data)){const isRef=refProps.includes(key),isImage=imageProps.includes(key),isStr=(0,string_js_1.isStringStrict)(value),isArr=(0,array_js_1.isArrayStrict)(value);let newValue=value;if(isTemplate&&"content"===key&&isArr&&(newValue=value.map((item=>{if(!(0,string_js_1.isStringStrict)(item))return item;const ref=refData[item];return(0,object_js_1.isObjectStrict)(ref)?{...ref}:void 0}))),(isNavigation&&"items"===key||isNavigationItem&&"children"===key)&&isArr&&(newValue=value.map((id=>(0,string_js_1.isStringStrict)(id)?{id:id,title:refData[id]?.title}:null)).filter(Boolean)),isImage&&isStr&&(newValue=imageData[value]?{...imageData[value]}:null),isRef&&isStr){const ref=refData[value];(0,object_js_1.isObjectStrict)(ref)&&(newValue={...ref},unsetProps.forEach((prop=>{newValue[prop]&&(newValue[prop]=void 0)})))}isRef&&(0,array_js_1.isArrayStrict)(value)&&(newValue=value.map((refKey=>{if(!(0,string_js_1.isStringStrict)(refKey))return null;const ref=refData[refKey];if(!(0,object_js_1.isObjectStrict)(ref))return null;const newRef={...ref};return unsetProps.forEach((prop=>{newRef[prop]&&(newRef[prop]=void 0)})),newRef})).filter(Boolean)),(0,object_js_1.isObject)(newValue)&&(newValue=normalizeLocalRefs(newValue,refData,imageData,refProps,imageProps,unsetProps)),newData[key]=newValue}return newData},normalizeLocalData=(data,refProps,imageProps,unsetProps)=>{const newData={},imageMeta=(0,store_js_1.getStoreItem)("imageMeta"),refData={};for(const[key,item]of Object.entries(data))(0,object_js_1.isObjectStrict)(item)&&(refData[key]={id:key,...item});for(const[key,item]of Object.entries(refData))newData[key]=normalizeLocalRefs(item,refData,imageMeta,refProps,imageProps,unsetProps,item.contentType);return newData};exports.normalizeLocalData=normalizeLocalData;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeLocalData=void 0;const object_js_1=require("../utils/object/object.js"),array_js_1=require("../utils/array/array.js"),string_js_1=require("../utils/string/string.js"),store_js_1=require("../store/store.js"),normalizeLocalRefs=(data,refData,imageData,refProps=["internalLink","term","taxonomy"],imageProps=["image"],unsetProps=["content"],contentType)=>{const newData=(0,array_js_1.isArray)(data)?[]:{},isTemplate="contentTemplate"===data.renderType,isNavigation="navigation"===contentType,isNavigationItem="navigationItem"===contentType;for(const[key,value]of Object.entries(data)){const isRef=refProps.includes(key),isImage=imageProps.includes(key),isStr=(0,string_js_1.isStringStrict)(value),isArr=(0,array_js_1.isArrayStrict)(value);let newValue=value;if(isTemplate&&"content"===key&&isArr&&(newValue=value.map(item=>{if(!(0,string_js_1.isStringStrict)(item))return item;const ref=refData[item];return(0,object_js_1.isObjectStrict)(ref)?{...ref}:void 0})),(isNavigation&&"items"===key||isNavigationItem&&"children"===key)&&isArr&&(newValue=value.map(id=>(0,string_js_1.isStringStrict)(id)?{id:id,title:refData[id]?.title}:null).filter(Boolean)),isImage&&isStr&&(newValue=imageData[value]?{...imageData[value]}:null),isRef&&isStr){const ref=refData[value];(0,object_js_1.isObjectStrict)(ref)&&(newValue={...ref},unsetProps.forEach(prop=>{newValue[prop]&&(newValue[prop]=void 0)}))}isRef&&(0,array_js_1.isArrayStrict)(value)&&(newValue=value.map(refKey=>{if(!(0,string_js_1.isStringStrict)(refKey))return null;const ref=refData[refKey];if(!(0,object_js_1.isObjectStrict)(ref))return null;const newRef={...ref};return unsetProps.forEach(prop=>{newRef[prop]&&(newRef[prop]=void 0)}),newRef}).filter(Boolean)),(0,object_js_1.isObject)(newValue)&&(newValue=normalizeLocalRefs(newValue,refData,imageData,refProps,imageProps,unsetProps)),newData[key]=newValue}return newData},normalizeLocalData=(data,refProps,imageProps,unsetProps)=>{const newData={},imageMeta=(0,store_js_1.getStoreItem)("imageMeta"),refData={};for(const[key,item]of Object.entries(data))(0,object_js_1.isObjectStrict)(item)&&(refData[key]={id:key,...item});for(const[key,item]of Object.entries(refData))newData[key]=normalizeLocalRefs(item,refData,imageMeta,refProps,imageProps,unsetProps,item.contentType);return newData};exports.normalizeLocalData=normalizeLocalData;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setRedirects=exports.redirects=void 0;const array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js");let redirects=[];exports.redirects=redirects;const setRedirects=data=>!!(0,array_js_1.isArrayStrict)(data)&&(exports.redirects=redirects=[],data.forEach((item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{redirect:redirect}=item;(0,array_js_1.isArrayStrict)(redirect)&&(exports.redirects=redirects=redirects.concat(redirect))})),redirects.length>1);exports.setRedirects=setRedirects;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setRedirects=exports.redirects=void 0;const array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js");let redirects=[];exports.redirects=redirects;const setRedirects=data=>!!(0,array_js_1.isArrayStrict)(data)&&(exports.redirects=redirects=[],data.forEach(item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{redirect:redirect}=item;(0,array_js_1.isArrayStrict)(redirect)&&(exports.redirects=redirects=redirects.concat(redirect))}),redirects.length>1);exports.setRedirects=setRedirects;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setRenderFunctions=exports.renderHttpError=exports.renderNavigation=exports.renderLayout=exports.renderFunctions=exports.renderContent=exports.renderItem=exports.render=void 0;const action_js_1=require("../utils/action/action.js"),filter_js_1=require("../utils/filter/filter.js"),link_js_1=require("../utils/link/link.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),number_js_1=require("../utils/number/number.js"),function_js_1=require("../utils/function/function.js"),shortcode_js_1=require("../utils/shortcode/shortcode.js"),tag_js_1=require("../utils/tag/tag.js"),store_js_1=require("../store/store.js"),redirects_js_1=require("../redirects/redirects.js"),scriptStyle_js_1=require("../utils/scriptStyle/scriptStyle.js"),Container_js_1=require("../layouts/Container/Container.js"),Column_js_1=require("../layouts/Column/Column.js"),Form_js_1=require("../objects/Form/Form.js"),FormField_js_1=require("../objects/Form/FormField.js"),FormOption_js_1=require("../objects/Form/FormOption.js"),RichText_js_1=require("../text/RichText/RichText.js"),config_js_1=require("../config/config.js"),defaultRenderFunctions={container:Container_js_1.Container,column:Column_js_1.Column,form:Form_js_1.Form,formField:FormField_js_1.FormField,formOption:FormOption_js_1.FormOption,richText:RichText_js_1.RichText};let renderFunctions={...defaultRenderFunctions};exports.renderFunctions=renderFunctions;let renderLayout=()=>"";exports.renderLayout=renderLayout;let renderHttpError=()=>"";exports.renderHttpError=renderHttpError;let renderNavigation=()=>{};exports.renderNavigation=renderNavigation;const setRenderFunctions=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const{functions:functions,layout:layout,navigation:navigation,httpError:httpError}=args;return!(!(0,object_js_1.isObjectStrict)(functions)||!(0,function_js_1.isFunction)(layout))&&(exports.renderFunctions=renderFunctions={...defaultRenderFunctions,...functions},exports.renderLayout=renderLayout=layout,(0,function_js_1.isFunction)(navigation)&&(exports.renderNavigation=renderNavigation=navigation),(0,function_js_1.isFunction)(httpError)&&(exports.renderHttpError=renderHttpError=httpError),!0)};exports.setRenderFunctions=setRenderFunctions;const getContentTemplate=(content,templates=[],named=!1)=>{if(!(0,array_js_1.isArrayStrict)(content))return{content:[],namedContent:{},templates:[]};const namedContent={},newContent=content.map((c=>(named&&(0,string_js_1.isString)(c.name)&&(namedContent[c.name]={...c}),(0,tag_js_1.tagExists)(c,"template")?(templates.push({...c}),{metadata:{tags:[{id:"templateBreak"}]}}):c)));return{namedContent:namedContent,content:newContent,templates:structuredClone(templates)}},mapContentTemplate=(templates,content=[],namedContent={},named=!1)=>{if(!(0,array_js_1.isArrayStrict)(templates))return templates;const lastTemplateIndex=templates.length-1;return templates.forEach(((t,i)=>{content[0]&&(0,tag_js_1.tagExists)(content[0],"templateBreak")&&content.length>=1&&content.shift();if((0,tag_js_1.tagExists)(t,"templateOptional")&&i===lastTemplateIndex&&!content.length)return void templates.pop();const isSlot=(0,tag_js_1.tagExists)(t,"templateSlot");let children=t.content;if((0,array_js_1.isArrayStrict)(children)&&!isSlot&&!named){let repeat;const newChildren=[...children],repeatIndex=children.findIndex((c=>{const isRepeat=(0,tag_js_1.tagExists)(c,"templateRepeat");return isRepeat&&(repeat=c),isRepeat}));if(-1!==repeatIndex&&repeat){let breakIndex=content.findIndex((c=>(0,tag_js_1.tagExists)(c,"templateBreak")));breakIndex=-1===breakIndex?content.length:breakIndex;let insertIndex=repeatIndex;for(let j=insertIndex;j<breakIndex-1;j+=1)newChildren.splice(insertIndex,0,structuredClone(repeat)),insertIndex=j}children=newChildren}if(isSlot&&content.length>=1){let fill=null;return fill=named?namedContent[t.name]:content.shift(),void(fill&&(templates[i]=fill))}(0,array_js_1.isArray)(children)&&templates[i]&&(templates[i].content=mapContentTemplate(children,content,namedContent,named))})),templates},renderContent=async(args,_html={ref:""})=>{if(!(0,object_js_1.isObjectStrict)(args))return _html.ref;const{content:content=[],serverlessData:serverlessData,previewData:previewData,itemData:itemData,itemContains:itemContains=new Set,itemHeadings:itemHeadings=[],parents:parents=[],depth:depth=0}=args;let{headingsIndex:headingsIndex=-1}=args;if(!(0,array_js_1.isArrayStrict)(content))return _html.ref;for(const item of content){if(!(0,object_js_1.isObjectStrict)(item))continue;const props={...item},renderType=(0,string_js_1.isString)(props.renderType)?props.renderType:"",isRichText="richText"===renderType;let childrenArr,children=props.content;if("contentTemplate"===renderType){const isNamed=(0,tag_js_1.tagExists)(item,"templateNamed"),template=getContentTemplate((0,array_js_1.isArray)(props.content)?props.content:[],[],isNamed);children=mapContentTemplate(template.templates,template.content,template.namedContent,isNamed)}let childrenStr="";(0,array_js_1.isArrayStrict)(children)&&!isRichText&&(childrenArr=children),(0,string_js_1.isStringStrict)(children)&&!isRichText&&(childrenStr=children),"content"===renderType&&0===depth&&(headingsIndex=itemHeadings.push([])-1);let renderStart="",renderEnd="",filterType="",filterArgs={};const renderFunction=renderFunctions[renderType];if((0,function_js_1.isFunction)(renderFunction)){childrenArr&&(props.content=void 0);const renderArgs={args:props,parents:parents,itemData:itemData,itemContains:itemContains,serverlessData:serverlessData,previewData:previewData};childrenArr&&(renderArgs.children=childrenArr),"richText"===renderType&&(renderArgs.headings=itemHeadings[headingsIndex]);const renderOutput=await renderFunction(renderArgs);if((0,array_js_1.isArrayStrict)(renderOutput)){const[start,end]=renderOutput;(0,string_js_1.isString)(start)&&(renderStart=start),(0,string_js_1.isString)(end)&&(renderEnd=end)}(0,string_js_1.isString)(renderOutput)&&(renderStart=renderOutput,childrenArr=void 0),itemContains.add(renderType),filterType=renderType,filterArgs={...props,content:void 0}}const renderContentFilterArgs={renderType:filterType,args:filterArgs},[filterRenderStart,filterRenderEnd]=await(0,filter_js_1.applyFilters)("renderContent",[renderStart,renderEnd],renderContentFilterArgs,!0);if((0,string_js_1.isString)(filterRenderStart)&&(renderStart=filterRenderStart),(0,string_js_1.isString)(filterRenderEnd)&&(renderEnd=filterRenderEnd),_html.ref+=renderStart+childrenStr,childrenArr){const parentsCopy=[...parents];renderType&&parentsCopy.unshift({renderType:renderType,args:{...props,content:void 0,parents:void 0}}),await renderContent({content:childrenArr,serverlessData:serverlessData,previewData:previewData,parents:parentsCopy,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,headingsIndex:headingsIndex,depth:depth+1},_html)}_html.ref+=renderEnd}return _html.ref};exports.renderContent=renderContent;const renderItem=async(args,_contentType)=>{if(!(0,object_js_1.isObjectStrict)(args))return null;const{item:item,serverlessData:serverlessData,previewData:previewData}=args;if(!(0,object_js_1.isObjectStrict)(item))return null;const contentType=item.contentType;if(!(0,string_js_1.isStringStrict)(contentType))return null;if("taxonomy"===contentType&&!0!==item.isPage)return null;const id=item.id;if(!(0,string_js_1.isStringStrict)(id))return null;if(!(0,string_js_1.isStringStrict)(item.slug))return null;let serverlessRender=!1;const itemContains=new Set,itemHeadings=[];scriptStyle_js_1.scripts.deps.clear(),scriptStyle_js_1.scripts.item.clear(),scriptStyle_js_1.scripts.meta={},scriptStyle_js_1.styles.deps.clear(),scriptStyle_js_1.styles.item.clear();const renderItemStartArgs={id:id,itemData:{...item},contentType:contentType,itemContains:new Set,itemHeadings:[],serverlessData:serverlessData,previewData:previewData};await(0,action_js_1.doActions)("renderItemStart",renderItemStartArgs,!0);const title=item.title,meta={title:"",description:"",url:"",image:"",canonical:"",prev:"",next:"",index:!0,isIndex:!1,...item.meta};(0,string_js_1.isStringStrict)(item.metaTitle)&&(meta.title=item.metaTitle),(0,string_js_1.isStringStrict)(item.metaDescription)&&(meta.description=item.metaDescription),(0,string_js_1.isStringStrict)(item.metaImage?.url)&&(meta.image=item.metaImage.url),!(0,string_js_1.isStringStrict)(meta.title)&&(0,string_js_1.isStringStrict)(title)&&(meta.title=title);const slugArgs={id:id,contentType:contentType,slug:item.slug,returnParents:!0,itemData:item,page:0},s=(0,link_js_1.getSlug)(slugArgs,!0),slug=s.slug,slugIsHtml=slug.endsWith(".html"),permalink=(0,link_js_1.getPermalink)(slug,!slugIsHtml),parents=s.parents;meta.url=permalink,meta.canonical=permalink;const taxonomy="term"===contentType?item.taxonomy:"taxonomy"===contentType?item:null;item.baseUrl=permalink,item.baseType=(0,object_js_1.isObjectStrict)(taxonomy)&&(0,array_js_1.isArrayStrict)(taxonomy.contentTypes)?taxonomy.contentTypes:contentType;let formattedSlug="index"!==slug&&""!==slug?`/${slug}/`:"/";slugIsHtml&&(formattedSlug=slug);const cmsLocales=config_js_1.config.cms.locales,slugData=[id,(0,string_js_1.isStringStrict)(_contentType)?_contentType:contentType];if((0,string_js_1.isStringStrict)(item.locale)&&cmsLocales){const locale=item.locale;cmsLocales.includes(locale)&&locale!==cmsLocales[0]&&slugData.push(locale)}(0,store_js_1.setStoreItem)("slugs",slugData,slugIsHtml?`/${slug}`:formattedSlug);const index="index"===item.slug;let itemServerlessData;if(meta.isIndex=index,(0,object_js_1.isObjectStrict)(serverlessData)){if(!(serverlessData.path===formattedSlug&&null!=serverlessData.query))return{serverlessRender:!1};itemServerlessData=serverlessData}const itemData={...item};itemData.id=id,itemData.parents=parents,itemData.content=void 0;let contentOutput="";const contentData=item.content;(0,string_js_1.isStringStrict)(contentData)&&(contentOutput=contentData),(0,array_js_1.isArrayStrict)(contentData)&&(contentOutput=await renderContent({content:contentData,serverlessData:itemServerlessData,parents:[],itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,previewData:previewData})),contentOutput=await(0,shortcode_js_1.doShortcodes)(contentOutput,itemData);const pag=itemData.pagination;if((0,object_js_1.isObjectStrict)(pag)){const{current:current=0,total:total=1,currentFilters:currentFilters,prevFilters:prevFilters,nextFilters:nextFilters}=pag;if(meta.canonicalParams=`${current>1?`?page=${current}`:""}${(0,string_js_1.isString)(currentFilters)?currentFilters:""}`,(0,string_js_1.isStringStrict)(pag.title)&&(meta.paginationTitle=pag.title),(0,number_js_1.isNumber)(pag.prev)&&pag.prev>=1){slugArgs.page=pag.prev;const p=(0,link_js_1.getSlug)(slugArgs,!0);meta.prev=`${(0,link_js_1.getPermalink)(p.slug,1===pag.prev)}${(0,string_js_1.isString)(prevFilters)?prevFilters:""}`}if((0,number_js_1.isNumber)(pag.next)&&pag.next>1&&pag.next<total){slugArgs.page=pag.next;const n=(0,link_js_1.getSlug)(slugArgs,!0);meta.next=`${(0,link_js_1.getPermalink)(n.slug,!1)}${(0,string_js_1.isString)(nextFilters)?nextFilters:""}`}serverlessRender=!0}let layoutOutput="";if((0,function_js_1.isFunction)(renderLayout)){const layoutArgs={id:id,meta:meta,contentType:contentType,content:contentOutput,slug:formattedSlug,itemContains:itemContains,itemHeadings:itemHeadings,itemData:itemData,serverlessData:serverlessData,previewData:previewData};layoutOutput=await renderLayout(layoutArgs)}const renderItemFilterArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,serverlessData:serverlessData,previewData:previewData};layoutOutput=await(0,filter_js_1.applyFilters)("renderItem",layoutOutput,renderItemFilterArgs,!0);const renderItemEndArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,serverlessData:serverlessData,previewData:previewData};return await(0,action_js_1.doActions)("renderItemEnd",renderItemEndArgs,!0),{serverlessRender:serverlessRender,itemData:itemData,data:{slug:formattedSlug,output:layoutOutput}}};exports.renderItem=renderItem;const render=async args=>{if(!(0,object_js_1.isObjectStrict)(args))return[];const{allData:allData,serverlessData:serverlessData,previewData:previewData}=args,isServerless=null!=serverlessData,isPreview=null!=previewData;if(scriptStyle_js_1.scripts.deps.clear(),scriptStyle_js_1.scripts.item.clear(),scriptStyle_js_1.scripts.meta={},scriptStyle_js_1.styles.deps.clear(),scriptStyle_js_1.styles.item.clear(),!(0,object_js_1.isObjectStrict)(allData))return[];const{redirect:redirect,content:content}=allData;await(0,action_js_1.doActions)("renderStart",args,!0);const data=[];isServerless||(0,store_js_1.setStoreData)(allData),(0,function_js_1.isFunction)(renderNavigation)&&await renderNavigation({navigations:(0,store_js_1.getStoreItem)("navigations"),items:(0,store_js_1.getStoreItem)("navigationItems")}),(0,redirects_js_1.setRedirects)(redirect);for(const[contentType,contentItems]of Object.entries(content))if((0,array_js_1.isArrayStrict)(contentItems))for(const contentItem of contentItems){const item=await renderItem({item:await(0,filter_js_1.applyFilters)("renderItemData",contentItem,{contentType:contentType},!0),serverlessData:serverlessData,previewData:previewData},contentType);if(!item)continue;const{serverlessRender:serverlessRender=!1,data:itemData}=item;itemData&&(data.push(itemData),serverlessRender&&!isServerless&&(0,store_js_1.setStoreItem)("serverless",["reload"],itemData.slug))}const[outputItem]=data,output=(isServerless||isPreview)&&outputItem?outputItem:data;return await(0,action_js_1.doActions)("renderEnd",{...args,data:output},!0),output};exports.render=render;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setRenderFunctions=exports.renderHttpError=exports.renderNavigation=exports.renderLayout=exports.renderFunctions=exports.renderContent=exports.renderItem=exports.render=void 0;const action_js_1=require("../utils/action/action.js"),filter_js_1=require("../utils/filter/filter.js"),link_js_1=require("../utils/link/link.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),number_js_1=require("../utils/number/number.js"),function_js_1=require("../utils/function/function.js"),shortcode_js_1=require("../utils/shortcode/shortcode.js"),tag_js_1=require("../utils/tag/tag.js"),store_js_1=require("../store/store.js"),redirects_js_1=require("../redirects/redirects.js"),scriptStyle_js_1=require("../utils/scriptStyle/scriptStyle.js"),Container_js_1=require("../layouts/Container/Container.js"),Column_js_1=require("../layouts/Column/Column.js"),Form_js_1=require("../objects/Form/Form.js"),FormField_js_1=require("../objects/Form/FormField.js"),FormOption_js_1=require("../objects/Form/FormOption.js"),RichText_js_1=require("../text/RichText/RichText.js"),config_js_1=require("../config/config.js"),defaultRenderFunctions={container:Container_js_1.Container,column:Column_js_1.Column,form:Form_js_1.Form,formField:FormField_js_1.FormField,formOption:FormOption_js_1.FormOption,richText:RichText_js_1.RichText};let renderFunctions={...defaultRenderFunctions};exports.renderFunctions=renderFunctions;let renderLayout=()=>"";exports.renderLayout=renderLayout;let renderHttpError=()=>"";exports.renderHttpError=renderHttpError;let renderNavigation=()=>{};exports.renderNavigation=renderNavigation;const setRenderFunctions=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const{functions:functions,layout:layout,navigation:navigation,httpError:httpError}=args;return!(!(0,object_js_1.isObjectStrict)(functions)||!(0,function_js_1.isFunction)(layout))&&(exports.renderFunctions=renderFunctions={...defaultRenderFunctions,...functions},exports.renderLayout=renderLayout=layout,(0,function_js_1.isFunction)(navigation)&&(exports.renderNavigation=renderNavigation=navigation),(0,function_js_1.isFunction)(httpError)&&(exports.renderHttpError=renderHttpError=httpError),!0)};exports.setRenderFunctions=setRenderFunctions;const getContentTemplate=(content,templates=[],named=!1)=>{if(!(0,array_js_1.isArrayStrict)(content))return{content:[],namedContent:{},templates:[]};const namedContent={},newContent=content.map(c=>(named&&(0,string_js_1.isString)(c.name)&&(namedContent[c.name]={...c}),(0,tag_js_1.tagExists)(c,"template")?(templates.push({...c}),{metadata:{tags:[{id:"templateBreak"}]}}):c));return{namedContent:namedContent,content:newContent,templates:structuredClone(templates)}},mapContentTemplate=(templates,content=[],namedContent={},named=!1)=>{if(!(0,array_js_1.isArrayStrict)(templates))return templates;const lastTemplateIndex=templates.length-1;return templates.forEach((t,i)=>{content[0]&&(0,tag_js_1.tagExists)(content[0],"templateBreak")&&content.length>=1&&content.shift();if((0,tag_js_1.tagExists)(t,"templateOptional")&&i===lastTemplateIndex&&!content.length)return void templates.pop();const isSlot=(0,tag_js_1.tagExists)(t,"templateSlot");let children=t.content;if((0,array_js_1.isArrayStrict)(children)&&!isSlot&&!named){let repeat;const newChildren=[...children],repeatIndex=children.findIndex(c=>{const isRepeat=(0,tag_js_1.tagExists)(c,"templateRepeat");return isRepeat&&(repeat=c),isRepeat});if(-1!==repeatIndex&&repeat){let breakIndex=content.findIndex(c=>(0,tag_js_1.tagExists)(c,"templateBreak"));breakIndex=-1===breakIndex?content.length:breakIndex;let insertIndex=repeatIndex;for(let j=insertIndex;j<breakIndex-1;j+=1)newChildren.splice(insertIndex,0,structuredClone(repeat)),insertIndex=j}children=newChildren}if(isSlot&&content.length>=1){let fill=null;return fill=named?namedContent[t.name]:content.shift(),void(fill&&(templates[i]=fill))}(0,array_js_1.isArray)(children)&&templates[i]&&(templates[i].content=mapContentTemplate(children,content,namedContent,named))}),templates},renderContent=async(args,_html={ref:""})=>{if(!(0,object_js_1.isObjectStrict)(args))return _html.ref;const{content:content=[],serverlessData:serverlessData,previewData:previewData,itemData:itemData,itemContains:itemContains=new Set,itemHeadings:itemHeadings=[],parents:parents=[],depth:depth=0}=args;let{headingsIndex:headingsIndex=-1}=args;if(!(0,array_js_1.isArrayStrict)(content))return _html.ref;for(const item of content){if(!(0,object_js_1.isObjectStrict)(item))continue;const props={...item},renderType=(0,string_js_1.isString)(props.renderType)?props.renderType:"",isRichText="richText"===renderType;let childrenArr,children=props.content;if("contentTemplate"===renderType){const isNamed=(0,tag_js_1.tagExists)(item,"templateNamed"),template=getContentTemplate((0,array_js_1.isArray)(props.content)?props.content:[],[],isNamed);children=mapContentTemplate(template.templates,template.content,template.namedContent,isNamed)}let childrenStr="";(0,array_js_1.isArrayStrict)(children)&&!isRichText&&(childrenArr=children),(0,string_js_1.isStringStrict)(children)&&!isRichText&&(childrenStr=children),"content"===renderType&&0===depth&&(headingsIndex=itemHeadings.push([])-1);let renderStart="",renderEnd="",filterType="",filterArgs={};const renderFunction=renderFunctions[renderType];if((0,function_js_1.isFunction)(renderFunction)){childrenArr&&(props.content=void 0);const renderArgs={args:props,parents:parents,itemData:itemData,itemContains:itemContains,serverlessData:serverlessData,previewData:previewData};childrenArr&&(renderArgs.children=childrenArr),"richText"===renderType&&(renderArgs.headings=itemHeadings[headingsIndex]);const renderOutput=await renderFunction(renderArgs);if((0,array_js_1.isArrayStrict)(renderOutput)){const[start,end]=renderOutput;(0,string_js_1.isString)(start)&&(renderStart=start),(0,string_js_1.isString)(end)&&(renderEnd=end)}(0,string_js_1.isString)(renderOutput)&&(renderStart=renderOutput,childrenArr=void 0),itemContains.add(renderType),filterType=renderType,filterArgs={...props,content:void 0}}const renderContentFilterArgs={renderType:filterType,args:filterArgs},[filterRenderStart,filterRenderEnd]=await(0,filter_js_1.applyFilters)("renderContent",[renderStart,renderEnd],renderContentFilterArgs,!0);if((0,string_js_1.isString)(filterRenderStart)&&(renderStart=filterRenderStart),(0,string_js_1.isString)(filterRenderEnd)&&(renderEnd=filterRenderEnd),_html.ref+=renderStart+childrenStr,childrenArr){const parentsCopy=[...parents];renderType&&parentsCopy.unshift({renderType:renderType,args:{...props,content:void 0,parents:void 0}}),await renderContent({content:childrenArr,serverlessData:serverlessData,previewData:previewData,parents:parentsCopy,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,headingsIndex:headingsIndex,depth:depth+1},_html)}_html.ref+=renderEnd}return _html.ref};exports.renderContent=renderContent;const renderItem=async(args,_contentType)=>{if(!(0,object_js_1.isObjectStrict)(args))return null;const{item:item,serverlessData:serverlessData,previewData:previewData}=args;if(!(0,object_js_1.isObjectStrict)(item))return null;const contentType=item.contentType;if(!(0,string_js_1.isStringStrict)(contentType))return null;if("taxonomy"===contentType&&!0!==item.isPage)return null;const id=item.id;if(!(0,string_js_1.isStringStrict)(id))return null;if(!(0,string_js_1.isStringStrict)(item.slug))return null;let serverlessRender=!1;const itemContains=new Set,itemHeadings=[];scriptStyle_js_1.scripts.deps.clear(),scriptStyle_js_1.scripts.item.clear(),scriptStyle_js_1.scripts.meta={},scriptStyle_js_1.styles.deps.clear(),scriptStyle_js_1.styles.item.clear();const renderItemStartArgs={id:id,itemData:{...item},contentType:contentType,itemContains:new Set,itemHeadings:[],serverlessData:serverlessData,previewData:previewData};await(0,action_js_1.doActions)("renderItemStart",renderItemStartArgs,!0);const title=item.title,meta={title:"",description:"",url:"",image:"",canonical:"",prev:"",next:"",index:!0,isIndex:!1,...item.meta};(0,string_js_1.isStringStrict)(item.metaTitle)&&(meta.title=item.metaTitle),(0,string_js_1.isStringStrict)(item.metaDescription)&&(meta.description=item.metaDescription),(0,string_js_1.isStringStrict)(item.metaImage?.url)&&(meta.image=item.metaImage.url),!(0,string_js_1.isStringStrict)(meta.title)&&(0,string_js_1.isStringStrict)(title)&&(meta.title=title);const slugArgs={id:id,contentType:contentType,slug:item.slug,returnParents:!0,itemData:item,page:0},s=(0,link_js_1.getSlug)(slugArgs,!0),slug=s.slug,slugIsHtml=slug.endsWith(".html"),permalink=(0,link_js_1.getPermalink)(slug,!slugIsHtml),parents=s.parents;meta.url=permalink,meta.canonical=permalink;const taxonomy="term"===contentType?item.taxonomy:"taxonomy"===contentType?item:null;item.baseUrl=permalink,item.baseType=(0,object_js_1.isObjectStrict)(taxonomy)&&(0,array_js_1.isArrayStrict)(taxonomy.contentTypes)?taxonomy.contentTypes:contentType;let formattedSlug="index"!==slug&&""!==slug?`/${slug}/`:"/";slugIsHtml&&(formattedSlug=slug);const cmsLocales=config_js_1.config.cms.locales,slugData=[id,(0,string_js_1.isStringStrict)(_contentType)?_contentType:contentType];if((0,string_js_1.isStringStrict)(item.locale)&&cmsLocales){const locale=item.locale;cmsLocales.includes(locale)&&locale!==cmsLocales[0]&&slugData.push(locale)}(0,store_js_1.setStoreItem)("slugs",slugData,slugIsHtml?`/${slug}`:formattedSlug);const index="index"===item.slug;let itemServerlessData;if(meta.isIndex=index,(0,object_js_1.isObjectStrict)(serverlessData)){if(!(serverlessData.path===formattedSlug&&null!=serverlessData.query))return{serverlessRender:!1};itemServerlessData=serverlessData}const itemData={...item};itemData.id=id,itemData.parents=parents,itemData.content=void 0;let contentOutput="";const contentData=item.content;(0,string_js_1.isStringStrict)(contentData)&&(contentOutput=contentData),(0,array_js_1.isArrayStrict)(contentData)&&(contentOutput=await renderContent({content:contentData,serverlessData:itemServerlessData,parents:[],itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,previewData:previewData})),contentOutput=await(0,shortcode_js_1.doShortcodes)(contentOutput,itemData);const pag=itemData.pagination;if((0,object_js_1.isObjectStrict)(pag)){const{current:current=0,total:total=1,currentFilters:currentFilters,prevFilters:prevFilters,nextFilters:nextFilters}=pag;if(meta.canonicalParams=`${current>1?`?page=${current}`:""}${(0,string_js_1.isString)(currentFilters)?currentFilters:""}`,(0,string_js_1.isStringStrict)(pag.title)&&(meta.paginationTitle=pag.title),(0,number_js_1.isNumber)(pag.prev)&&pag.prev>=1){slugArgs.page=pag.prev;const p=(0,link_js_1.getSlug)(slugArgs,!0);meta.prev=`${(0,link_js_1.getPermalink)(p.slug,1===pag.prev)}${(0,string_js_1.isString)(prevFilters)?prevFilters:""}`}if((0,number_js_1.isNumber)(pag.next)&&pag.next>1&&pag.next<total){slugArgs.page=pag.next;const n=(0,link_js_1.getSlug)(slugArgs,!0);meta.next=`${(0,link_js_1.getPermalink)(n.slug,!1)}${(0,string_js_1.isString)(nextFilters)?nextFilters:""}`}serverlessRender=!0}let layoutOutput="";if((0,function_js_1.isFunction)(renderLayout)){const layoutArgs={id:id,meta:meta,contentType:contentType,content:contentOutput,slug:formattedSlug,itemContains:itemContains,itemHeadings:itemHeadings,itemData:itemData,serverlessData:serverlessData,previewData:previewData};layoutOutput=await renderLayout(layoutArgs)}const renderItemFilterArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,serverlessData:serverlessData,previewData:previewData};layoutOutput=await(0,filter_js_1.applyFilters)("renderItem",layoutOutput,renderItemFilterArgs,!0);const renderItemEndArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,itemData:itemData,itemContains:itemContains,itemHeadings:itemHeadings,serverlessData:serverlessData,previewData:previewData};return await(0,action_js_1.doActions)("renderItemEnd",renderItemEndArgs,!0),{serverlessRender:serverlessRender,itemData:itemData,data:{slug:formattedSlug,output:layoutOutput}}};exports.renderItem=renderItem;const render=async args=>{if(!(0,object_js_1.isObjectStrict)(args))return[];const{allData:allData,serverlessData:serverlessData,previewData:previewData}=args,isServerless=null!=serverlessData,isPreview=null!=previewData;if(scriptStyle_js_1.scripts.deps.clear(),scriptStyle_js_1.scripts.item.clear(),scriptStyle_js_1.scripts.meta={},scriptStyle_js_1.styles.deps.clear(),scriptStyle_js_1.styles.item.clear(),!(0,object_js_1.isObjectStrict)(allData))return[];const{redirect:redirect,content:content}=allData;await(0,action_js_1.doActions)("renderStart",args,!0);const data=[];isServerless||(0,store_js_1.setStoreData)(allData),(0,function_js_1.isFunction)(renderNavigation)&&await renderNavigation({navigations:(0,store_js_1.getStoreItem)("navigations"),items:(0,store_js_1.getStoreItem)("navigationItems")}),(0,redirects_js_1.setRedirects)(redirect);for(const[contentType,contentItems]of Object.entries(content))if((0,array_js_1.isArrayStrict)(contentItems))for(const contentItem of contentItems){const item=await renderItem({item:await(0,filter_js_1.applyFilters)("renderItemData",contentItem,{contentType:contentType},!0),serverlessData:serverlessData,previewData:previewData},contentType);if(!item)continue;const{serverlessRender:serverlessRender=!1,data:itemData}=item;itemData&&(data.push(itemData),serverlessRender&&!isServerless&&(0,store_js_1.setStoreItem)("serverless",["reload"],itemData.slug))}const[outputItem]=data,output=(isServerless||isPreview)&&outputItem?outputItem:data;return await(0,action_js_1.doActions)("renderEnd",{...args,data:output},!0),output};exports.render=render;
@@ -30,7 +30,6 @@ export interface RenderPreviewData {
30
30
  id: string;
31
31
  contentType: string;
32
32
  locale?: string;
33
- env?: string;
34
33
  }
35
34
  export interface RenderRedirect {
36
35
  redirect: string[];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ajax=void 0;const ResponseError_js_1=require("../../utils/ResponseError/ResponseError.js"),filter_js_1=require("../../utils/filter/filter.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),number_js_1=require("../../utils/number/number.js"),function_js_1=require("../../utils/function/function.js"),print_js_1=require("../../utils/print/print.js"),config_js_1=require("../../config/config.js"),serverless_js_1=require("../serverless.js"),Ajax=async(request,env)=>{try{const data=await request.json();if(!(0,object_js_1.isObjectStrict)(data))throw new Error("Data not an object");const honeypotName=`${config_js_1.config.namespace}_asi`;if((0,object_js_1.isObjectStrict)(data.inputs?.[honeypotName])){const honeypotValue=data.inputs[honeypotName].value;if((0,string_js_1.isStringStrict)(honeypotValue)){const options={status:200,headers:{"Content-Type":"application/json"}};return new Response(JSON.stringify({success:"Form successully sent"}),options)}delete data.inputs[honeypotName]}const action=data.action;if(!(0,string_js_1.isStringStrict)(action))throw new Error("No action");let res=null;const ajaxFn=serverless_js_1.serverlessActions[action];(0,function_js_1.isFunction)(ajaxFn)&&(res=await ajaxFn(data,request,env));const ajaxResultFilterArgs={data:data,request:request,env:env};if(res=await(0,filter_js_1.applyFilters)("ajaxResult",res,ajaxResultFilterArgs,!0),!res)throw new Error("No result");if(res.error)throw new ResponseError_js_1.ResponseError(res.error.message,res.error.response);const options={status:200,headers:{"Content-Type":"application/json"}};let message="";if(res.success){const{message:successMessage,headers:headers}=res.success;(0,string_js_1.isStringStrict)(successMessage)&&(message=successMessage),(0,object_js_1.isObjectStrict)(headers)&&(options.headers={...options.headers,...headers})}return new Response(JSON.stringify({success:message}),options)}catch(error){(0,print_js_1.print)("[FRM] Error with ajax function",error);let statusCode=500,message=error instanceof Error?error.message:"Unknown error";error instanceof ResponseError_js_1.ResponseError&&((0,number_js_1.isNumber)(error.response?.status)&&(statusCode=error.response.status),(0,string_js_1.isStringStrict)(error.message)&&(message=error.message));const options={status:statusCode,headers:{"Content-Type":"application/json"}};return new Response(JSON.stringify({error:message}),options)}};exports.Ajax=Ajax;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ajax=void 0;const ResponseError_js_1=require("../../utils/ResponseError/ResponseError.js"),filter_js_1=require("../../utils/filter/filter.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),number_js_1=require("../../utils/number/number.js"),function_js_1=require("../../utils/function/function.js"),print_js_1=require("../../utils/print/print.js"),config_js_1=require("../../config/config.js"),serverless_js_1=require("../serverless.js"),Ajax=async(request,env)=>{try{const{method:method,json:json}=request;if("POST"!==method)return new Response(JSON.stringify({error:"Method not allowed"}),{status:405,headers:{"Content-Type":"application/json"}});const data=await json();if(!(0,object_js_1.isObjectStrict)(data))throw new Error("Data not an object");const honeypotName=`${config_js_1.config.namespace}_asi`;if((0,object_js_1.isObjectStrict)(data.inputs?.[honeypotName])){const honeypotValue=data.inputs[honeypotName].value;if((0,string_js_1.isStringStrict)(honeypotValue)){const options={status:200,headers:{"Content-Type":"application/json"}};return new Response(JSON.stringify({success:"Form successully sent"}),options)}delete data.inputs[honeypotName]}const action=data.action;if(!(0,string_js_1.isStringStrict)(action))throw new Error("No action");let res=null;const ajaxFn=serverless_js_1.serverlessActions[action];(0,function_js_1.isFunction)(ajaxFn)&&(res=await ajaxFn(data,request,env));const ajaxResultFilterArgs={data:data,request:request,env:env};if(res=await(0,filter_js_1.applyFilters)("ajaxResult",res,ajaxResultFilterArgs,!0),!res)throw new Error("No result");if(res.error)throw new ResponseError_js_1.ResponseError(res.error.message,res.error.response);const options={status:200,headers:{"Content-Type":"application/json"}};let message="";if(res.success){const{message:successMessage,headers:headers}=res.success;(0,string_js_1.isStringStrict)(successMessage)&&(message=successMessage),(0,object_js_1.isObjectStrict)(headers)&&(options.headers={...options.headers,...headers})}return new Response(JSON.stringify({success:message}),options)}catch(error){(0,print_js_1.print)("[FRM] Error with ajax function",error);let statusCode=500,message=error instanceof Error?error.message:"Unknown error";error instanceof ResponseError_js_1.ResponseError&&((0,number_js_1.isNumber)(error.response?.status)&&(statusCode=error.response.status),(0,string_js_1.isStringStrict)(error.message)&&(message=error.message));const options={status:statusCode,headers:{"Content-Type":"application/json"}};return new Response(JSON.stringify({error:message}),options)}};exports.Ajax=Ajax;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Contact=void 0;const config_js_1=require("../../config/config.js"),escape_js_1=require("../../utils/escape/escape.js"),array_js_1=require("../../utils/array/array.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),objectUtils_js_1=require("../../utils/object/objectUtils.js"),filter_js_1=require("../../utils/filter/filter.js"),link_js_1=require("../../utils/link/link.js"),store_js_1=require("../../store/store.js"),minify_js_1=require("../../utils/minify/minify.js"),recurseEmailHtml=(data,html,plain,depth=1)=>{if(!(0,object_js_1.isObject)(data))return;const isArr=(0,array_js_1.isArray)(data);(0,objectUtils_js_1.getObjectKeys)(data).forEach((label=>{const value=data[label],l=label.toString(),h=depth+1;1===depth&&(html.ref+='\n <tr>\n <td style="padding: 16px 0; border-bottom: 2px solid #ccc;">\n '),label&&!isArr&&(html.ref+=`\n <h${h} style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.3em">\n ${l}\n </h${h}>\n `,plain.ref+=`${l}\n`),recurseEmailHtml(value,html,plain,depth+1),(0,string_js_1.isString)(value)&&(html.ref+=`\n <p style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.5em;">\n ${value}\n </p>\n `,plain.ref+=value.replace(/<br\s*\/?>/gi,"\n").replace(/(<([^>]+)>)/gi,"")+"\n"),1===depth&&(html.ref+="\n </td>\n </tr>\n ",plain.ref+="\n")}))},Contact=async args=>{const{id:id,action:action,inputs:inputs}=args;if(!(0,string_js_1.isStringStrict)(id))return{error:{message:"No id"}};if(!(0,object_js_1.isObjectStrict)(inputs)||!Object.keys(inputs).length)return{error:{message:"No inputs"}};const formMetaData=(0,store_js_1.getStoreItem)("formMeta");if(!(0,object_js_1.isObjectStrict)(formMetaData))return{error:{message:"No meta"}};const meta=formMetaData[id];if(!(0,object_js_1.isObjectStrict)(meta))return{error:{message:"No meta object"}};const toEmail=meta.toEmail;if(!(0,string_js_1.isStringStrict)(toEmail))return{error:{message:"No to email"}};const toEmails=toEmail.split(","),senderEmail=meta.senderEmail;if(!(0,string_js_1.isStringStrict)(senderEmail))return{error:{message:"No sender email"}};let subject=(0,string_js_1.isStringStrict)(meta.subject)?meta.subject:"",replyToEmail="";const header=`${config_js_1.config.title} contact form submission`,footer=`This email was sent from a contact form on ${config_js_1.config.title} (${(0,link_js_1.getPermalink)()})`,outputData={},html={ref:""},plain={ref:""};for(const[name,input]of Object.entries(inputs)){const inputType=input.type,inputLabel=input.label?.trim()||`[${name}]`,inputValue=input.value;let inputValueStr="";if(inputValueStr=(0,array_js_1.isArray)(inputValue)?inputValue.map((v=>(0,escape_js_1.escape)(v.toString().trim()))).join("<br>"):(0,escape_js_1.escape)(inputValue.toString().trim()),"subject"===name){subject=inputValueStr?`${(0,string_js_1.isStringStrict)(subject)?`${subject} - `:""}${inputValueStr}`:subject;continue}"email"===inputType&&inputValueStr&&(replyToEmail=inputValueStr,inputValueStr=`<a href="mailto:${inputValueStr}">${inputValueStr}</a>`);const outputValue=""===inputValueStr?"--":inputValueStr;let hasLegend=!1,legend="";if((0,string_js_1.isStringStrict)(input.legend)&&(hasLegend=!0,legend=input.legend),hasLegend){null==outputData[legend]&&(outputData[legend]={});null==outputData[legend][inputLabel]&&(outputData[legend][inputLabel]=[]),outputData[legend][inputLabel].push(outputValue)}if(!hasLegend){null==outputData[inputLabel]&&(outputData[inputLabel]=[]),outputData[inputLabel].push(outputValue)}}recurseEmailHtml(outputData,html,plain);const outputHtml=`\n <table width="100%" cellpadding="0" cellspacing="0" border="0">\n <tr>\n <td align="center" width="100%" style="padding: 0 16px 16px 16px;">\n <table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-right: auto; margin-left: auto; border-spacing: 0; max-width: 37.5em;">\n <tr>\n <td style="padding: 32px 0 0 0;">\n <h1 style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.3em;">\n ${header}\n </h1>\n </td>\n </tr>\n <tr>\n <td>\n <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">\n ${html.ref}\n <tr>\n <td style="padding: 32px 0;">\n <p style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.5em;">\n ${footer}\n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n `,outputPlain=`${header}\n\n${plain.ref}${footer}`;subject||(subject=`${config_js_1.config.title} Contact Form`);const body={id:id,action:action,inputs:inputs,to:toEmails,sender:senderEmail,subject:subject,text:(0,minify_js_1.minify)(outputPlain),html:(0,minify_js_1.minify)(outputHtml)};return replyToEmail&&(body.replyTo=replyToEmail),await(0,filter_js_1.applyFilters)("contactResult",{},body,!0)};exports.Contact=Contact;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Contact=void 0;const config_js_1=require("../../config/config.js"),escape_js_1=require("../../utils/escape/escape.js"),array_js_1=require("../../utils/array/array.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),objectUtils_js_1=require("../../utils/object/objectUtils.js"),filter_js_1=require("../../utils/filter/filter.js"),link_js_1=require("../../utils/link/link.js"),store_js_1=require("../../store/store.js"),minify_js_1=require("../../utils/minify/minify.js"),recurseEmailHtml=(data,html,plain,depth=1)=>{if(!(0,object_js_1.isObject)(data))return;const isArr=(0,array_js_1.isArray)(data);(0,objectUtils_js_1.getObjectKeys)(data).forEach(label=>{const value=data[label],l=label.toString(),h=depth+1;1===depth&&(html.ref+='\n <tr>\n <td style="padding: 16px 0; border-bottom: 2px solid #ccc;">\n '),label&&!isArr&&(html.ref+=`\n <h${h} style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.3em">\n ${l}\n </h${h}>\n `,plain.ref+=`${l}\n`),recurseEmailHtml(value,html,plain,depth+1),(0,string_js_1.isString)(value)&&(html.ref+=`\n <p style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.5em;">\n ${value}\n </p>\n `,plain.ref+=value.replace(/<br\s*\/?>/gi,"\n").replace(/(<([^>]+)>)/gi,"")+"\n"),1===depth&&(html.ref+="\n </td>\n </tr>\n ",plain.ref+="\n")})},Contact=async args=>{const{id:id,action:action,inputs:inputs}=args;if(!(0,string_js_1.isStringStrict)(id))return{error:{message:"No id"}};if(!(0,object_js_1.isObjectStrict)(inputs)||!Object.keys(inputs).length)return{error:{message:"No inputs"}};const formMetaData=(0,store_js_1.getStoreItem)("formMeta");if(!(0,object_js_1.isObjectStrict)(formMetaData))return{error:{message:"No meta"}};const meta=formMetaData[id];if(!(0,object_js_1.isObjectStrict)(meta))return{error:{message:"No meta object"}};const toEmail=meta.toEmail;if(!(0,string_js_1.isStringStrict)(toEmail))return{error:{message:"No to email"}};const toEmails=toEmail.split(","),senderEmail=meta.senderEmail;if(!(0,string_js_1.isStringStrict)(senderEmail))return{error:{message:"No sender email"}};let subject=(0,string_js_1.isStringStrict)(meta.subject)?meta.subject:"",replyToEmail="";const header=`${config_js_1.config.title} contact form submission`,footer=`This email was sent from a contact form on ${config_js_1.config.title} (${(0,link_js_1.getPermalink)()})`,outputData={},html={ref:""},plain={ref:""};for(const[name,input]of Object.entries(inputs)){const inputType=input.type,inputLabel=input.label?.trim()||`[${name}]`,inputValue=input.value;let inputValueStr="";if(inputValueStr=(0,array_js_1.isArray)(inputValue)?inputValue.map(v=>(0,escape_js_1.escape)(v.toString().trim())).join("<br>"):(0,escape_js_1.escape)(inputValue.toString().trim()),"subject"===name){subject=inputValueStr?`${(0,string_js_1.isStringStrict)(subject)?`${subject} - `:""}${inputValueStr}`:subject;continue}"email"===inputType&&inputValueStr&&(replyToEmail=inputValueStr,inputValueStr=`<a href="mailto:${inputValueStr}">${inputValueStr}</a>`);const outputValue=""===inputValueStr?"--":inputValueStr;let hasLegend=!1,legend="";if((0,string_js_1.isStringStrict)(input.legend)&&(hasLegend=!0,legend=input.legend),hasLegend){null==outputData[legend]&&(outputData[legend]={});null==outputData[legend][inputLabel]&&(outputData[legend][inputLabel]=[]),outputData[legend][inputLabel].push(outputValue)}if(!hasLegend){null==outputData[inputLabel]&&(outputData[inputLabel]=[]),outputData[inputLabel].push(outputValue)}}recurseEmailHtml(outputData,html,plain);const outputHtml=`\n <table width="100%" cellpadding="0" cellspacing="0" border="0">\n <tr>\n <td align="center" width="100%" style="padding: 0 16px 16px 16px;">\n <table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-right: auto; margin-left: auto; border-spacing: 0; max-width: 37.5em;">\n <tr>\n <td style="padding: 32px 0 0 0;">\n <h1 style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.3em;">\n ${header}\n </h1>\n </td>\n </tr>\n <tr>\n <td>\n <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">\n ${html.ref}\n <tr>\n <td style="padding: 32px 0;">\n <p style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.5em;">\n ${footer}\n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n `,outputPlain=`${header}\n\n${plain.ref}${footer}`;subject||(subject=`${config_js_1.config.title} Contact Form`);const body={id:id,action:action,inputs:inputs,to:toEmails,sender:senderEmail,subject:subject,text:(0,minify_js_1.minify)(outputPlain),html:(0,minify_js_1.minify)(outputHtml)};return replyToEmail&&(body.replyTo=replyToEmail),await(0,filter_js_1.applyFilters)("contactResult",{},body,!0)};exports.Contact=Contact;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setServerless=exports.serverlessRender=exports.serverlessReload=exports.serverlessPreview=exports.serverlessActions=void 0;const string_js_1=require("../utils/string/string.js"),object_js_1=require("../utils/object/object.js"),function_js_1=require("../utils/function/function.js"),render_js_1=require("../render/render.js"),minify_js_1=require("../utils/minify/minify.js"),print_js_1=require("../utils/print/print.js");let serverlessActions={};exports.serverlessActions=serverlessActions;const serverlessPreview=request=>{const{method:method,url:url}=request;if("GET"!==method)return;const{searchParams:searchParams}=new URL(url),contentType=searchParams.get("content_type"),locale=searchParams.get("locale"),env=searchParams.get("env"),id=searchParams.get("preview");if(!(0,string_js_1.isStringStrict)(id)||!(0,string_js_1.isStringStrict)(contentType))return;const previewData={id:id,contentType:contentType};return(0,string_js_1.isStringStrict)(locale)&&(previewData.locale=locale),(0,string_js_1.isStringStrict)(env)&&(previewData.env=env),previewData};exports.serverlessPreview=serverlessPreview;const serverlessReload=request=>{const{url:url,method:method}=request;if("GET"!==method)return;const{searchParams:searchParams,pathname:pathname}=new URL(url),page=searchParams.get("page"),filters=searchParams.get("filters"),path=pathname,query={};let noPage=!1,noFilters=!1;return(0,string_js_1.isStringStrict)(page)?query.page=page:noPage=!0,(0,string_js_1.isStringStrict)(filters)?query.filters=filters:noFilters=!0,noPage&&noFilters?void 0:{query:query,path:path}};exports.serverlessReload=serverlessReload;const serverlessRender=async(getData,serverlessData,previewData)=>{try{const data=await(0,render_js_1.render)({serverlessData:serverlessData,previewData:previewData,allData:await getData({serverlessData:serverlessData,previewData:previewData})});let html="",status=200;(0,object_js_1.isObjectStrict)(data)&&(html=data.output);const isEmpty=""===html;return isEmpty&&(status=404),isEmpty&&(0,function_js_1.isFunction)(render_js_1.renderHttpError)&&(html=await(0,render_js_1.renderHttpError)({code:status})),new Response((0,minify_js_1.minify)(html),{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}catch(error){(0,print_js_1.print)("[FRM] Error on serverless render",error);const status=500,html=await(0,render_js_1.renderHttpError)({code:status});return new Response(html,{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}};exports.serverlessRender=serverlessRender;const setServerless=actions=>{(0,object_js_1.isObjectStrict)(actions)&&(exports.serverlessActions=serverlessActions={...actions})};exports.setServerless=setServerless;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setServerless=exports.serverlessRender=exports.serverlessReload=exports.serverlessPreview=exports.serverlessActions=void 0;const string_js_1=require("../utils/string/string.js"),object_js_1=require("../utils/object/object.js"),function_js_1=require("../utils/function/function.js"),render_js_1=require("../render/render.js"),minify_js_1=require("../utils/minify/minify.js"),print_js_1=require("../utils/print/print.js");let serverlessActions={};exports.serverlessActions=serverlessActions;const serverlessPreview=request=>{const{method:method,url:url}=request;if("GET"!==method)return;const{searchParams:searchParams}=new URL(url),contentType=searchParams.get("content_type"),locale=searchParams.get("locale"),id=searchParams.get("preview");if(!(0,string_js_1.isStringStrict)(id)||!(0,string_js_1.isStringStrict)(contentType))return;const previewData={id:id,contentType:contentType};return(0,string_js_1.isStringStrict)(locale)&&(previewData.locale=locale),previewData};exports.serverlessPreview=serverlessPreview;const serverlessReload=request=>{const{url:url,method:method}=request;if("GET"!==method)return;const{searchParams:searchParams,pathname:pathname}=new URL(url),page=searchParams.get("page"),filters=searchParams.get("filters"),path=pathname,query={};let noPage=!1,noFilters=!1;return(0,string_js_1.isStringStrict)(page)?query.page=page:noPage=!0,(0,string_js_1.isStringStrict)(filters)?query.filters=filters:noFilters=!0,noPage&&noFilters?void 0:{query:query,path:path}};exports.serverlessReload=serverlessReload;const serverlessRender=async(getData,serverlessData,previewData)=>{try{const data=await(0,render_js_1.render)({serverlessData:serverlessData,previewData:previewData,allData:await getData({serverlessData:serverlessData,previewData:previewData})});let html="",status=200;(0,object_js_1.isObjectStrict)(data)&&(html=data.output);const isEmpty=""===html;return isEmpty&&(status=404),isEmpty&&(0,function_js_1.isFunction)(render_js_1.renderHttpError)&&(html=await(0,render_js_1.renderHttpError)({code:status})),new Response((0,minify_js_1.minify)(html),{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}catch(error){(0,print_js_1.print)("[FRM] Error on serverless render",error);const status=500,html=await(0,render_js_1.renderHttpError)({code:status});return new Response(html,{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}};exports.serverlessRender=serverlessRender;const setServerless=actions=>{(0,object_js_1.isObjectStrict)(actions)&&(exports.serverlessActions=serverlessActions={...actions})};exports.setServerless=setServerless;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStoreItem=exports.setStoreItem=exports.setStoreData=exports.setStore=exports.storeDir=exports.store=void 0;const contentType_js_1=require("../utils/contentType/contentType.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),archive_js_1=require("../utils/archive/archive.js"),config_js_1=require("../config/config.js");let storeDir="lib/store";exports.storeDir=storeDir;const defaultStore={slugs:{},parents:{},navigations:[],navigationItems:[],formMeta:{},archiveMeta:{},imageMeta:{},taxonomies:{},serverless:{}};let store={...defaultStore};exports.store=store;const setStore=(args,dir="lib/store")=>(0,object_js_1.isObjectStrict)(args)?(exports.store=store={...defaultStore,...args},(0,string_js_1.isStringStrict)(dir)&&(exports.storeDir=storeDir=dir),store):store;exports.setStore=setStore;const setStoreItem=(prop,value,subProp)=>!(!(0,string_js_1.isStringStrict)(prop)||!(0,object_js_1.isObject)(value)||null==store[prop])&&((0,string_js_1.isStringStrict)(subProp)?store[prop][subProp]=value:store[prop]=value,!0);exports.setStoreItem=setStoreItem;const setStoreData=allData=>{if(!(0,object_js_1.isObjectStrict)(allData))return!1;const{navigation:navigation,navigationItem:navigationItem,content:content}=allData;store.navigations=(0,array_js_1.isArrayStrict)(navigation)?navigation:[],store.navigationItems=(0,array_js_1.isArrayStrict)(navigationItem)?navigationItem:[];const data={...allData,...content};return config_js_1.config.hierarchicalTypes.forEach((type=>{const items=data[type];(0,array_js_1.isArrayStrict)(items)&&items.forEach((item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,parent:parent,archive:archive,slug:slug,title:title,locale:locale}=item;if(!(0,string_js_1.isStringStrict)(id))return;const archiveType=(0,contentType_js_1.normalizeContentType)(archive);if((0,string_js_1.isStringStrict)(archiveType)){const hasLocale=(0,string_js_1.isStringStrict)(locale),archiveMeta=(0,archive_js_1.getArchiveMeta)(archiveType,locale),newArchive={id:id,slug:slug,title:title,contentType:type,...archiveMeta};hasLocale?(store.archiveMeta[archiveType]||(store.archiveMeta[archiveType]={}),store.archiveMeta[archiveType][locale]=newArchive):store.archiveMeta[archiveType]=newArchive}if((0,object_js_1.isObjectStrict)(parent)){const parentSlug=parent.slug,parentTitle=parent.title,parentId=parent.id;(0,string_js_1.isStringStrict)(parentSlug)&&(0,string_js_1.isStringStrict)(parentTitle)&&(0,string_js_1.isStringStrict)(parentId)&&(null==store.parents[type]&&(store.parents[type]={}),store.parents[type][id]=[parentId,parentSlug,parentTitle])}}))})),!0};exports.setStoreData=setStoreData;const getStoreItem=prop=>store[prop];exports.getStoreItem=getStoreItem;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStoreItem=exports.setStoreItem=exports.setStoreData=exports.setStore=exports.storeDir=exports.store=void 0;const contentType_js_1=require("../utils/contentType/contentType.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),archive_js_1=require("../utils/archive/archive.js"),config_js_1=require("../config/config.js");let storeDir="lib/store";exports.storeDir=storeDir;const defaultStore={slugs:{},parents:{},navigations:[],navigationItems:[],formMeta:{},archiveMeta:{},imageMeta:{},taxonomies:{},serverless:{}};let store={...defaultStore};exports.store=store;const setStore=(args,dir="lib/store")=>(0,object_js_1.isObjectStrict)(args)?(exports.store=store={...defaultStore,...args},(0,string_js_1.isStringStrict)(dir)&&(exports.storeDir=storeDir=dir),store):store;exports.setStore=setStore;const setStoreItem=(prop,value,subProp)=>!(!(0,string_js_1.isStringStrict)(prop)||!(0,object_js_1.isObject)(value)||null==store[prop])&&((0,string_js_1.isStringStrict)(subProp)?store[prop][subProp]=value:store[prop]=value,!0);exports.setStoreItem=setStoreItem;const setStoreData=allData=>{if(!(0,object_js_1.isObjectStrict)(allData))return!1;const{navigation:navigation,navigationItem:navigationItem,content:content}=allData;store.navigations=(0,array_js_1.isArrayStrict)(navigation)?navigation:[],store.navigationItems=(0,array_js_1.isArrayStrict)(navigationItem)?navigationItem:[];const data={...allData,...content};return config_js_1.config.hierarchicalTypes.forEach(type=>{const items=data[type];(0,array_js_1.isArrayStrict)(items)&&items.forEach(item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,parent:parent,archive:archive,slug:slug,title:title,locale:locale}=item;if(!(0,string_js_1.isStringStrict)(id))return;const archiveType=(0,contentType_js_1.normalizeContentType)(archive);if((0,string_js_1.isStringStrict)(archiveType)){const hasLocale=(0,string_js_1.isStringStrict)(locale),archiveMeta=(0,archive_js_1.getArchiveMeta)(archiveType,locale),newArchive={id:id,slug:slug,title:title,contentType:type,...archiveMeta};hasLocale?(store.archiveMeta[archiveType]||(store.archiveMeta[archiveType]={}),store.archiveMeta[archiveType][locale]=newArchive):store.archiveMeta[archiveType]=newArchive}if((0,object_js_1.isObjectStrict)(parent)){const parentSlug=parent.slug,parentTitle=parent.title,parentId=parent.id;(0,string_js_1.isStringStrict)(parentSlug)&&(0,string_js_1.isStringStrict)(parentTitle)&&(0,string_js_1.isStringStrict)(parentId)&&(null==store.parents[type]&&(store.parents[type]={}),store.parents[type][id]=[parentId,parentSlug,parentTitle])}})}),!0};exports.setStoreData=setStoreData;const getStoreItem=prop=>store[prop];exports.getStoreItem=getStoreItem;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPlainText=exports.RichText=void 0;const link_js_1=require("../../utils/link/link.js"),excerpt_js_1=require("../../utils/excerpt/excerpt.js"),filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),array_js_1=require("../../utils/array/array.js"),object_js_1=require("../../utils/object/object.js"),heading_js_1=require("../../utils/heading/heading.js"),containsShortcode=(tag,content)=>"p"===tag&&"["===content.charAt(0)&&"]"===content.charAt(content.length-1),addDataAttr=(dataAttr=!0,tag="")=>(0,array_js_1.isArrayStrict)(dataAttr)?dataAttr.includes(tag):dataAttr,getContent=args=>{const{content:content=[],props:props,dataAttr:dataAttr=!1}=args;let{_output:_output=""}=args;for(const item of content){const newItem=(0,filter_js_1.applyFilters)("richTextContentItem",item,props),itemObj=(0,object_js_1.isObjectStrict)(newItem)?newItem:{},{link:link,attr:attr,internalLink:internalLink,content:itemContent}=itemObj;let{tag:tag=""}=itemObj,newContent=itemContent;const isSingleTag="br"===tag||"hr"===tag;(0,array_js_1.isArrayStrict)(itemContent)&&(newContent=getContent({content:itemContent,props:props,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach((([key,value])=>{attrs.push(`${key}="${value}"`)})),"a"===tag){let anchorLink=link;internalLink&&(anchorLink=(0,link_js_1.getLink)(internalLink)),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}let outputStr="";if((0,string_js_1.isString)(newContent)){const richTextContentFilterArgs={args:newItem,props:props},filteredContent=(0,filter_js_1.applyFilters)("richTextContent",newContent,richTextContentFilterArgs);(0,string_js_1.isString)(filteredContent)&&(newContent=filteredContent),outputStr+=newContent}containsShortcode(tag,outputStr)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&outputStr.trim()&&!isSingleTag&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=outputStr,outputStr=`${opening}${outputStr}${closing}`),isSingleTag&&(outputStr=`<${tag}>`);const richTextContentOutputArgs={args:newItem,props:props,element:{opening:opening,closing:closing,content:inner}};outputStr=(0,filter_js_1.applyFilters)("richTextContentOutput",outputStr,richTextContentOutputArgs),_output+=outputStr}return _output},getPlainText=(args,_output="")=>{if((0,string_js_1.isString)(args))return args;const content=(0,object_js_1.isObjectStrict)(args)?args.content:args;if(!(0,array_js_1.isArrayStrict)(content))return _output;for(const item of content){const{content:itemContent}=(0,object_js_1.isObjectStrict)(item)?item:{};(0,string_js_1.isString)(itemContent)&&(_output+=itemContent),(0,array_js_1.isArrayStrict)(itemContent)&&(_output=getPlainText({content:itemContent},_output))}return _output};exports.getPlainText=getPlainText;const RichText=props=>{if(!(0,object_js_1.isObjectStrict)(props))return"";if(props=(0,filter_js_1.applyFilters)("richTextProps",props),!(0,object_js_1.isObjectStrict)(props))return"";const{args:args}=props;if(!(0,object_js_1.isObjectStrict)(args))return"";const{content:content=[],classes:classes,link:link,internalLink:internalLink,textStyle:textStyle,headingStyle:headingStyle,align:align,style:style,attr:attr,dataAttr:dataAttr=!0}=args;let{tag:tag=""}=args;if("hr"===tag||"br"===tag)return`<${tag}>`;const isSectionHeading=(0,heading_js_1.isHeading)(tag),classesArr=[];(0,string_js_1.isStringStrict)(classes)&&classesArr.push(classes),(0,string_js_1.isStringStrict)(textStyle)&&classesArr.push(textStyle),(0,string_js_1.isStringStrict)(headingStyle)&&isSectionHeading&&classesArr.push(headingStyle),(0,string_js_1.isStringStrict)(align)&&classesArr.push(align);const filterProps={...props};filterProps.args.content=void 0;let headingObj,output="",headingStr="";(0,string_js_1.isStringStrict)(content)&&(output=content,headingStr=content),(0,array_js_1.isArrayStrict)(content)&&(headingObj=content,output=getContent({content:content,props:filterProps,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),isSectionHeading){const headingContents=(0,excerpt_js_1.getExcerpt)({limit:10,limitExcerpt:!0,excerpt:headingStr,content:headingObj}),id=headingContents.trim().replace(/&hellip;/g,"").replace(/[^\w\s]|_/g,"").replace(/\s+/g,"-").toLowerCase();headingContents&&id&&(attrs.push(`id="${id}"`),(0,array_js_1.isArray)(props.headings)&&props.headings.push({id:id,title:headingContents,type:tag}))}if("a"===tag){let anchorLink=link;const inLink=(0,link_js_1.getLink)(internalLink);(0,string_js_1.isStringStrict)(inLink)&&(anchorLink=inLink),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}classesArr.length&&attrs.push(`class="${classesArr.join(" ")}"`),(0,string_js_1.isStringStrict)(style)&&attrs.push(`style="${style}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach((([key,value])=>{attrs.push(`${key}="${value}"`)})),containsShortcode(tag,output)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&output.trim()&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=output,output=`${opening}${output}${closing}`);const richTextOutputArgs={props:filterProps,element:{opening:opening,closing:closing,content:inner}};return output=(0,filter_js_1.applyFilters)("richTextOutput",output,richTextOutputArgs),output};exports.RichText=RichText;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPlainText=exports.RichText=void 0;const link_js_1=require("../../utils/link/link.js"),excerpt_js_1=require("../../utils/excerpt/excerpt.js"),filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),array_js_1=require("../../utils/array/array.js"),object_js_1=require("../../utils/object/object.js"),heading_js_1=require("../../utils/heading/heading.js"),containsShortcode=(tag,content)=>"p"===tag&&"["===content.charAt(0)&&"]"===content.charAt(content.length-1),addDataAttr=(dataAttr=!0,tag="")=>(0,array_js_1.isArrayStrict)(dataAttr)?dataAttr.includes(tag):dataAttr,getContent=args=>{const{content:content=[],props:props,dataAttr:dataAttr=!1}=args;let{_output:_output=""}=args;for(const item of content){const newItem=(0,filter_js_1.applyFilters)("richTextContentItem",item,props),itemObj=(0,object_js_1.isObjectStrict)(newItem)?newItem:{},{link:link,attr:attr,internalLink:internalLink,content:itemContent}=itemObj;let{tag:tag=""}=itemObj,newContent=itemContent;const isSingleTag="br"===tag||"hr"===tag;(0,array_js_1.isArrayStrict)(itemContent)&&(newContent=getContent({content:itemContent,props:props,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach(([key,value])=>{attrs.push(`${key}="${value}"`)}),"a"===tag){let anchorLink=link;internalLink&&(anchorLink=(0,link_js_1.getLink)(internalLink)),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}let outputStr="";if((0,string_js_1.isString)(newContent)){const richTextContentFilterArgs={args:newItem,props:props},filteredContent=(0,filter_js_1.applyFilters)("richTextContent",newContent,richTextContentFilterArgs);(0,string_js_1.isString)(filteredContent)&&(newContent=filteredContent),outputStr+=newContent}containsShortcode(tag,outputStr)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&outputStr.trim()&&!isSingleTag&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=outputStr,outputStr=`${opening}${outputStr}${closing}`),isSingleTag&&(outputStr=`<${tag}>`);const richTextContentOutputArgs={args:newItem,props:props,element:{opening:opening,closing:closing,content:inner}};outputStr=(0,filter_js_1.applyFilters)("richTextContentOutput",outputStr,richTextContentOutputArgs),_output+=outputStr}return _output},getPlainText=(args,_output="")=>{if((0,string_js_1.isString)(args))return args;const content=(0,object_js_1.isObjectStrict)(args)?args.content:args;if(!(0,array_js_1.isArrayStrict)(content))return _output;for(const item of content){const{content:itemContent}=(0,object_js_1.isObjectStrict)(item)?item:{};(0,string_js_1.isString)(itemContent)&&(_output+=itemContent),(0,array_js_1.isArrayStrict)(itemContent)&&(_output=getPlainText({content:itemContent},_output))}return _output};exports.getPlainText=getPlainText;const RichText=props=>{if(!(0,object_js_1.isObjectStrict)(props))return"";if(props=(0,filter_js_1.applyFilters)("richTextProps",props),!(0,object_js_1.isObjectStrict)(props))return"";const{args:args}=props;if(!(0,object_js_1.isObjectStrict)(args))return"";const{content:content=[],classes:classes,link:link,internalLink:internalLink,textStyle:textStyle,headingStyle:headingStyle,align:align,style:style,attr:attr,dataAttr:dataAttr=!0}=args;let{tag:tag=""}=args;if("hr"===tag||"br"===tag)return`<${tag}>`;const isSectionHeading=(0,heading_js_1.isHeading)(tag),classesArr=[];(0,string_js_1.isStringStrict)(classes)&&classesArr.push(classes),(0,string_js_1.isStringStrict)(textStyle)&&classesArr.push(textStyle),(0,string_js_1.isStringStrict)(headingStyle)&&isSectionHeading&&classesArr.push(headingStyle),(0,string_js_1.isStringStrict)(align)&&classesArr.push(align);const filterProps={...props};filterProps.args.content=void 0;let headingObj,output="",headingStr="";(0,string_js_1.isStringStrict)(content)&&(output=content,headingStr=content),(0,array_js_1.isArrayStrict)(content)&&(headingObj=content,output=getContent({content:content,props:filterProps,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),isSectionHeading){const headingContents=(0,excerpt_js_1.getExcerpt)({limit:10,limitExcerpt:!0,excerpt:headingStr,content:headingObj}),id=headingContents.trim().replace(/&hellip;/g,"").replace(/[^\w\s]|_/g,"").replace(/\s+/g,"-").toLowerCase();headingContents&&id&&(attrs.push(`id="${id}"`),(0,array_js_1.isArray)(props.headings)&&props.headings.push({id:id,title:headingContents,type:tag}))}if("a"===tag){let anchorLink=link;const inLink=(0,link_js_1.getLink)(internalLink);(0,string_js_1.isStringStrict)(inLink)&&(anchorLink=inLink),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}classesArr.length&&attrs.push(`class="${classesArr.join(" ")}"`),(0,string_js_1.isStringStrict)(style)&&attrs.push(`style="${style}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach(([key,value])=>{attrs.push(`${key}="${value}"`)}),containsShortcode(tag,output)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&output.trim()&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=output,output=`${opening}${output}${closing}`);const richTextOutputArgs={props:filterProps,element:{opening:opening,closing:closing,content:inner}};return output=(0,filter_js_1.applyFilters)("richTextOutput",output,richTextOutputArgs),output};exports.RichText=RichText;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setActions=exports.resetActions=exports.doActions=exports.removeAction=exports.addAction=exports.actions=void 0;const set_js_1=require("../set/set.js"),string_js_1=require("../string/string.js"),object_js_1=require("../object/object.js"),function_js_1=require("../function/function.js");let actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]]);exports.actions=actions;const addAction=(name,action)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(action))&&((0,set_js_1.isSet)(actions.get(name))||actions.set(name,new Set),actions.get(name)?.add(action),!0);exports.addAction=addAction;const removeAction=(name,action)=>{if(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(action))return!1;const actionSet=actions.get(name);return!!(0,set_js_1.isSet)(actionSet)&&actionSet.delete(action)};exports.removeAction=removeAction;const doSequentially=async(callbacks,args)=>{for(const callback of callbacks)await callback(args)},doActions=(name,args,isAsync=!1)=>{const actionSet=actions.get(name);if(!(0,set_js_1.isSetStrict)(actionSet))return;const callbacks=[];for(const callback of actionSet.values())isAsync?callbacks.push(callback):callback(args);isAsync&&doSequentially(callbacks,args).then((result=>result)).catch((()=>!1))};exports.doActions=doActions;const resetActions=()=>{exports.actions=actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]])};exports.resetActions=resetActions;const setActions=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const newActions=Object.entries(args);return!!newActions.length&&(resetActions(),newActions.forEach((([name,action])=>{action&&addAction(name,action)})),!0)};exports.setActions=setActions;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setActions=exports.resetActions=exports.doActions=exports.removeAction=exports.addAction=exports.actions=void 0;const set_js_1=require("../set/set.js"),string_js_1=require("../string/string.js"),object_js_1=require("../object/object.js"),function_js_1=require("../function/function.js");let actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]]);exports.actions=actions;const addAction=(name,action)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(action))&&((0,set_js_1.isSet)(actions.get(name))||actions.set(name,new Set),actions.get(name)?.add(action),!0);exports.addAction=addAction;const removeAction=(name,action)=>{if(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(action))return!1;const actionSet=actions.get(name);return!!(0,set_js_1.isSet)(actionSet)&&actionSet.delete(action)};exports.removeAction=removeAction;const doSequentially=async(callbacks,args)=>{for(const callback of callbacks)await callback(args)},doActions=(name,args,isAsync=!1)=>{const actionSet=actions.get(name);if(!(0,set_js_1.isSetStrict)(actionSet))return;const callbacks=[];for(const callback of actionSet.values())isAsync?callbacks.push(callback):callback(args);isAsync&&doSequentially(callbacks,args).then(result=>result).catch(()=>!1)};exports.doActions=doActions;const resetActions=()=>{exports.actions=actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]])};exports.resetActions=resetActions;const setActions=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const newActions=Object.entries(args);return!!newActions.length&&(resetActions(),newActions.forEach(([name,action])=>{action&&addAction(name,action)}),!0)};exports.setActions=setActions;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getArchiveLabels=exports.getArchiveLink=exports.getTaxonomyInfo=exports.getArchiveInfo=exports.getArchiveMeta=exports.isArchive=exports.isTerm=void 0;const store_js_1=require("../../store/store.js"),object_js_1=require("../object/object.js"),array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),boolean_js_1=require("../boolean/boolean.js"),contentType_js_1=require("../contentType/contentType.js"),link_js_1=require("../link/link.js"),isTerm=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{contentType:type,taxonomy:taxonomy}=itemData;return!("term"!==type||!(0,object_js_1.isObjectStrict)(taxonomy))&&taxonomy.contentTypes.includes(contentType)};exports.isTerm=isTerm;const isArchive=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{archive:archive}=itemData;return archive===contentType||isTerm(contentType,itemData)};exports.isArchive=isArchive;const getArchiveMeta=(contentType,locale)=>{const archiveMeta=(0,store_js_1.getStoreItem)("archiveMeta")[contentType];return(0,object_js_1.isObjectStrict)(archiveMeta)?(0,string_js_1.isStringStrict)(locale)&&(0,object_js_1.isObjectStrict)(archiveMeta[locale])?archiveMeta[locale]:archiveMeta:{}};exports.getArchiveMeta=getArchiveMeta;const getArchiveInfo=(contentType,locale)=>{const value={id:"",slug:"",title:"",contentType:""};if("page"===(contentType=(0,contentType_js_1.normalizeContentType)(contentType)))return value;const{id:id,slug:slug,title:title,contentType:type}=getArchiveMeta(contentType,locale);return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentType=(0,string_js_1.isStringStrict)(type)?type:"",value};exports.getArchiveInfo=getArchiveInfo;const getTaxonomyInfo=(contentType,itemData)=>{const value={id:"",slug:"",title:"",contentTypes:[],primaryContentType:"",usePrimaryContentTypeSlug:!0,isPage:!1},taxObj="taxonomy"===contentType?itemData:itemData?.taxonomy;if(!(0,object_js_1.isObjectStrict)(taxObj))return value;const{id:id,slug:slug,link:link,title:title,contentTypes:contentTypes,usePrimaryContentTypeSlug:usePrimaryContentTypeSlug,isPage:isPage}=taxObj,taxonomyTypes=(0,array_js_1.isArrayStrict)(contentTypes)?contentTypes.map((type=>(0,contentType_js_1.normalizeContentType)(type))):[],primaryTaxonomyType=taxonomyTypes[0];return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentTypes=taxonomyTypes,value.primaryContentType=(0,string_js_1.isStringStrict)(primaryTaxonomyType)?primaryTaxonomyType:"",value.usePrimaryContentTypeSlug=!(0,boolean_js_1.isBoolean)(usePrimaryContentTypeSlug)||usePrimaryContentTypeSlug,value.isPage=!!(0,boolean_js_1.isBoolean)(isPage)&&isPage,(0,string_js_1.isStringStrict)(link)&&(value.link=link),value};exports.getTaxonomyInfo=getTaxonomyInfo;const getArchiveLink=(contentType,itemData)=>{let slug,title="";const taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,contentTypes:taxonomyTypes,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;"term"===contentType&&taxonomyIsPage&&(slug=(0,link_js_1.getSlug)({slug:"",contentType:contentType,itemData:itemData}),title=taxonomyTitle);const taxonomyType=taxonomyTypes[0],useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType);const archiveInfo=getArchiveInfo(contentType),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveType}=archiveInfo;return archiveSlug&&archiveId&&(slug=(0,link_js_1.getSlug)({id:archiveId,slug:archiveSlug,contentType:archiveType}),title=getArchiveLabel(contentType,itemData,"plural",archiveTitle)),{title:title,link:(0,string_js_1.isStringStrict)(slug)?(0,link_js_1.getPermalink)(slug):""}};exports.getArchiveLink=getArchiveLink;const getArchiveLabel=(contentType,itemData,labelType="singular",fallback)=>{fallback=(0,string_js_1.isStringStrict)(fallback)?fallback:"singular"===labelType?"Post":"Posts";const label=getArchiveMeta(contentType,itemData?.locale)[labelType];return(0,string_js_1.isStringStrict)(label)?label:fallback},getArchiveLabels=(contentType,itemData)=>{let singular="Post",plural="Posts";const taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;if("term"===contentType&&taxonomyIsPage&&(0,string_js_1.isStringStrict)(taxonomyTitle))return{singular:taxonomyTitle,plural:taxonomyTitle};const useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);return"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType),(0,string_js_1.isStringStrict)(contentType)&&(contentType=(0,contentType_js_1.normalizeContentType)(contentType),singular=getArchiveLabel(contentType,itemData),plural=getArchiveLabel(contentType,itemData,"plural")),{singular:singular,plural:plural}};exports.getArchiveLabels=getArchiveLabels;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getArchiveLabels=exports.getArchiveLink=exports.getTaxonomyInfo=exports.getArchiveInfo=exports.getArchiveMeta=exports.isArchive=exports.isTerm=void 0;const store_js_1=require("../../store/store.js"),object_js_1=require("../object/object.js"),array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),boolean_js_1=require("../boolean/boolean.js"),contentType_js_1=require("../contentType/contentType.js"),link_js_1=require("../link/link.js"),isTerm=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{contentType:type,taxonomy:taxonomy}=itemData;return!("term"!==type||!(0,object_js_1.isObjectStrict)(taxonomy))&&taxonomy.contentTypes.includes(contentType)};exports.isTerm=isTerm;const isArchive=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{archive:archive}=itemData;return archive===contentType||isTerm(contentType,itemData)};exports.isArchive=isArchive;const getArchiveMeta=(contentType,locale)=>{const archiveMeta=(0,store_js_1.getStoreItem)("archiveMeta")[contentType];return(0,object_js_1.isObjectStrict)(archiveMeta)?(0,string_js_1.isStringStrict)(locale)&&(0,object_js_1.isObjectStrict)(archiveMeta[locale])?archiveMeta[locale]:archiveMeta:{}};exports.getArchiveMeta=getArchiveMeta;const getArchiveInfo=(contentType,locale)=>{const value={id:"",slug:"",title:"",contentType:""};if("page"===(contentType=(0,contentType_js_1.normalizeContentType)(contentType)))return value;const{id:id,slug:slug,title:title,contentType:type}=getArchiveMeta(contentType,locale);return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentType=(0,string_js_1.isStringStrict)(type)?type:"",value};exports.getArchiveInfo=getArchiveInfo;const getTaxonomyInfo=(contentType,itemData)=>{const value={id:"",slug:"",title:"",contentTypes:[],primaryContentType:"",usePrimaryContentTypeSlug:!0,isPage:!1},taxObj="taxonomy"===contentType?itemData:itemData?.taxonomy;if(!(0,object_js_1.isObjectStrict)(taxObj))return value;const{id:id,slug:slug,link:link,title:title,contentTypes:contentTypes,usePrimaryContentTypeSlug:usePrimaryContentTypeSlug,isPage:isPage}=taxObj,taxonomyTypes=(0,array_js_1.isArrayStrict)(contentTypes)?contentTypes.map(type=>(0,contentType_js_1.normalizeContentType)(type)):[],primaryTaxonomyType=taxonomyTypes[0];return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentTypes=taxonomyTypes,value.primaryContentType=(0,string_js_1.isStringStrict)(primaryTaxonomyType)?primaryTaxonomyType:"",value.usePrimaryContentTypeSlug=!(0,boolean_js_1.isBoolean)(usePrimaryContentTypeSlug)||usePrimaryContentTypeSlug,value.isPage=!!(0,boolean_js_1.isBoolean)(isPage)&&isPage,(0,string_js_1.isStringStrict)(link)&&(value.link=link),value};exports.getTaxonomyInfo=getTaxonomyInfo;const getArchiveLink=(contentType,itemData)=>{let slug,title="";const taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,contentTypes:taxonomyTypes,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;"term"===contentType&&taxonomyIsPage&&(slug=(0,link_js_1.getSlug)({slug:"",contentType:contentType,itemData:itemData}),title=taxonomyTitle);const taxonomyType=taxonomyTypes[0],useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType);const archiveInfo=getArchiveInfo(contentType),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveType}=archiveInfo;return archiveSlug&&archiveId&&(slug=(0,link_js_1.getSlug)({id:archiveId,slug:archiveSlug,contentType:archiveType}),title=getArchiveLabel(contentType,itemData,"plural",archiveTitle)),{title:title,link:(0,string_js_1.isStringStrict)(slug)?(0,link_js_1.getPermalink)(slug):""}};exports.getArchiveLink=getArchiveLink;const getArchiveLabel=(contentType,itemData,labelType="singular",fallback)=>{fallback=(0,string_js_1.isStringStrict)(fallback)?fallback:"singular"===labelType?"Post":"Posts";const label=getArchiveMeta(contentType,itemData?.locale)[labelType];return(0,string_js_1.isStringStrict)(label)?label:fallback},getArchiveLabels=(contentType,itemData)=>{let singular="Post",plural="Posts";const taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;if("term"===contentType&&taxonomyIsPage&&(0,string_js_1.isStringStrict)(taxonomyTitle))return{singular:taxonomyTitle,plural:taxonomyTitle};const useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);return"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType),(0,string_js_1.isStringStrict)(contentType)&&(contentType=(0,contentType_js_1.normalizeContentType)(contentType),singular=getArchiveLabel(contentType,itemData),plural=getArchiveLabel(contentType,itemData,"plural")),{singular:singular,plural:plural}};exports.getArchiveLabels=getArchiveLabels;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setFilters=exports.resetFilters=exports.applyFilters=exports.removeFilter=exports.addFilter=exports.filters=void 0;const set_js_1=require("../set/set.js"),string_js_1=require("../string/string.js"),object_js_1=require("../object/object.js"),function_js_1=require("../function/function.js");let filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["ajaxResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]]);exports.filters=filters;const addFilter=(name,filter)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(filter))&&((0,set_js_1.isSet)(filters.get(name))||filters.set(name,new Set),filters.get(name)?.add(filter),!0);exports.addFilter=addFilter;const removeFilter=(name,filter)=>{if(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(filter))return!1;const filterSet=filters.get(name);return!!(0,set_js_1.isSet)(filterSet)&&filterSet.delete(filter)};exports.removeFilter=removeFilter;const applySequentially=async(callbacks,value,args)=>{for(const callback of callbacks)value=await callback(value,args);return value},applyFilters=(name,value,args,isAsync=!1)=>{const filterSet=filters.get(name);if(!(0,set_js_1.isSetStrict)(filterSet))return value;const callbacks=[];for(const callback of filterSet.values())isAsync?callbacks.push(callback):value=callback(value,args);return isAsync?applySequentially(callbacks,value,args).then((newValue=>newValue)).catch((()=>value)):value};exports.applyFilters=applyFilters;const resetFilters=()=>{exports.filters=filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["ajaxResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]])};exports.resetFilters=resetFilters;const setFilters=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const newFilters=Object.entries(args);return!!newFilters.length&&(resetFilters(),newFilters.forEach((([name,filter])=>{filter&&addFilter(name,filter)})),!0)};exports.setFilters=setFilters;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setFilters=exports.resetFilters=exports.applyFilters=exports.removeFilter=exports.addFilter=exports.filters=void 0;const set_js_1=require("../set/set.js"),string_js_1=require("../string/string.js"),object_js_1=require("../object/object.js"),function_js_1=require("../function/function.js");let filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["ajaxResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]]);exports.filters=filters;const addFilter=(name,filter)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(filter))&&((0,set_js_1.isSet)(filters.get(name))||filters.set(name,new Set),filters.get(name)?.add(filter),!0);exports.addFilter=addFilter;const removeFilter=(name,filter)=>{if(!(0,string_js_1.isStringStrict)(name)||!(0,function_js_1.isFunction)(filter))return!1;const filterSet=filters.get(name);return!!(0,set_js_1.isSet)(filterSet)&&filterSet.delete(filter)};exports.removeFilter=removeFilter;const applySequentially=async(callbacks,value,args)=>{for(const callback of callbacks)value=await callback(value,args);return value},applyFilters=(name,value,args,isAsync=!1)=>{const filterSet=filters.get(name);if(!(0,set_js_1.isSetStrict)(filterSet))return value;const callbacks=[];for(const callback of filterSet.values())isAsync?callbacks.push(callback):value=callback(value,args);return isAsync?applySequentially(callbacks,value,args).then(newValue=>newValue).catch(()=>value):value};exports.applyFilters=applyFilters;const resetFilters=()=>{exports.filters=filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["ajaxResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]])};exports.resetFilters=resetFilters;const setFilters=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const newFilters=Object.entries(args);return!!newFilters.length&&(resetFilters(),newFilters.forEach(([name,filter])=>{filter&&addFilter(name,filter)}),!0)};exports.setFilters=setFilters;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getImageMaxWidth=exports.getImageClosestSize=exports.getImage=void 0;const config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),number_js_1=require("../number/number.js"),object_js_1=require("../object/object.js"),dataSource_js_1=require("../dataSource/dataSource.js"),getImageUrl=(url,format,quality,width,height,params)=>{const urlObj=new URL(url);return Object.entries(params).forEach((([key,value])=>{let val=value;"%format"===val&&(val=format),"%quality"===val&&(val=`${quality}`),"%width"===val&&(val=`${width}`),"%height"===val&&(val=`${height}`),urlObj.searchParams.set(key,val)})),urlObj.toString()},getImage=(args,returnDetails=!1)=>{const{data:data,classes:classes,attr:attr,alt:imageAlt="inherit",width:width="auto",height:height="auto",lazy:lazy=!0,picture:picture=!1,quality:quality=75,source:source=config_js_1.config.source,maxWidth:maxWidth=1200,viewportWidth:viewportWidth=100,format:format="webp",params:params={fm:"%format",q:"%quality",w:"%width",h:"%height"}}=(0,object_js_1.isObjectStrict)(args)?args:{},fallback=returnDetails?{output:"",aspectRatio:0,naturalWidth:0,naturalHeight:0,src:"",srcFallback:"",srcset:[],sizes:""}:"";if(!(0,object_js_1.isObjectStrict)(data))return fallback;const{path:path="",alt:dataAlt="",width:naturalWidth=1,height:naturalHeight=1,format:naturalFormat="jpg",sizes:dataSizes}=data;let{url:url=config_js_1.config.image.remoteUrl}=data,alt="inherit"===imageAlt?dataAlt:imageAlt;(0,string_js_1.isStringStrict)(alt)||(alt="");const isLocal="local"===source,isRemote=dataSource_js_1.dataSource.isContentful(source)||"remote"===source,isWordpress=dataSource_js_1.dataSource.isWordPress(source);if(isLocal){if(!(0,string_js_1.isStringStrict)(path))return fallback;url=`${config_js_1.config.image.localUrl}/${path}`}const aspectRatio=naturalHeight/naturalWidth,aspectRatioReverse=naturalWidth/naturalHeight;let w=naturalWidth,h=naturalHeight;if((0,number_js_1.isNumber)(width)&&(w=width,h=(0,string_js_1.isString)(height)?w*aspectRatio:height),(0,number_js_1.isNumber)(height)&&(h=height,w=(0,string_js_1.isString)(width)?h*aspectRatioReverse:width),w>maxWidth&&(w=Math.round(maxWidth),h=Math.round(w*aspectRatio)),isWordpress&&dataSizes&&!dataSizes[w]){const isNatural=w===naturalWidth;isNatural||(w=getImageClosestSize(w,Object.keys(dataSizes).map((s=>parseInt(s,10)))),h=Math.round(w*aspectRatio)),isNatural&&(dataSizes[w]=url)}let src=url,srcFallback=url;isLocal&&(src=`${url}.${format}`,srcFallback=`${url}.${naturalFormat}`),isRemote&&(src=getImageUrl(url,format,quality,w,h,params),srcFallback=getImageUrl(url,naturalFormat,quality,w,h,params));const sizes=`(min-width: ${w/16}rem) ${w/16}rem, ${viewportWidth}vw`,srcsetFallback=[];let srcset=[...config_js_1.config.image.sizes];srcset.includes(w)||srcset.push(w),srcset=srcset.filter((s=>s<=w)),srcset.sort(((a,b)=>a-b));const srcsetSource=[];srcset.forEach((s=>{if(isLocal){const base=`${url}${s!==naturalWidth?`@${s}`:""}`;srcsetFallback.push(`${base}.${naturalFormat} ${s}w`),srcsetSource.push(`${base}.${format} ${s}w`)}if(isRemote){const sizeHeight=Math.round(s*aspectRatio);srcsetFallback.push(getImageUrl(url,naturalFormat,quality,s,sizeHeight,params)+` ${s}w`),srcsetSource.push(getImageUrl(url,format,quality,s,sizeHeight,params)+` ${s}w`)}if(isWordpress){const sizeUrl=dataSizes?.[s];(0,string_js_1.isStringStrict)(sizeUrl)&&srcsetSource.push(`${sizeUrl} ${s}w`)}}));let sourceOutput="";picture&&(sourceOutput=`<source srcset="${srcsetSource.join(", ")}" sizes="${sizes}" type="image/${format}">`);let eagerHackOutput="";lazy||(eagerHackOutput=`\n <img\n alt=""\n role="presentation"\n aria-hidden="true"\n src="data:image/svg+xml;charset=utf-8,%3Csvg height='${h}' width='${w}' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E" style="pointerEvents: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%"\n >\n `);const output=`\n ${eagerHackOutput}\n ${sourceOutput}\n <img\n ${(0,string_js_1.isStringStrict)(classes)?` class="${classes}"`:""}\n alt="${alt}"\n src="${picture?srcFallback:src}"\n srcset="${picture?srcsetFallback.join(", "):srcsetSource.join(", ")}"\n sizes="${sizes}"\n width="${w}"\n height="${h}"\n ${(0,string_js_1.isStringStrict)(attr)?` ${attr}`:""}\n ${lazy?' loading="lazy" decoding="async"':' loading="eager"'}\n >\n `;return returnDetails?{output:output,aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight,src:src,srcFallback:srcFallback,srcset:srcsetSource,sizes:sizes}:output};exports.getImage=getImage;const getImageClosestSize=(size,sizes=[])=>(sizes.length||(sizes=config_js_1.config.image.sizes),[...sizes].reduce(((prev,curr)=>Math.abs(curr-size)<=Math.abs(prev-size)?curr:prev)));exports.getImageClosestSize=getImageClosestSize;const getImageMaxWidth=args=>{if(!(0,object_js_1.isObjectStrict)(args))return 0;const{parents:parents,widths:widths,maxWidths:maxWidths,breakpoints:breakpoints,source:source=config_js_1.config.source}=args;if(!((0,array_js_1.isArrayStrict)(parents)&&(0,object_js_1.isObjectStrict)(widths)&&(0,object_js_1.isObjectStrict)(maxWidths)&&(0,array_js_1.isArrayStrict)(breakpoints)))return 0;const w=[];let m=0;if(parents.forEach((parent=>{if(!(0,object_js_1.isObjectStrict)(parent))return;const{renderType:renderType,args:args}=parent;if((0,object_js_1.isObjectStrict)(args)){if("column"===renderType){const{width:width="Default",widthSmall:widthSmall="Default",widthMedium:widthMedium="Default",widthLarge:widthLarge="Default"}=args;w[0]=(0,number_js_1.isNumber)(widths[width])&&widths[width]>0?widths[width]:1,w[1]=(0,number_js_1.isNumber)(widths[widthSmall])&&widths[widthSmall]>0?widths[widthSmall]:w[0],w[2]=(0,number_js_1.isNumber)(widths[widthMedium])&&widths[widthMedium]>0?widths[widthMedium]:w[1],w[3]=(0,number_js_1.isNumber)(widths[widthLarge])&&widths[widthLarge]>0?widths[widthLarge]:w[2]}if("container"===renderType){const{maxWidth:maxWidth="Default"}=args;m=(0,number_js_1.isNumber)(maxWidths[maxWidth])?maxWidths[maxWidth]:0}}})),!w.length&&0===m)return 0;const bk=[...breakpoints],calc=[];let lastW=1;bk.forEach(((b,i)=>{const wd=w[i];(0,number_js_1.isNumber)(wd)&&(lastW=wd,m>0&&b>m?calc.push(wd*m):calc.push(wd*b))})),m>0&&calc.push(lastW*m);const res=2*Math.max(...calc);return"local"===source?getImageClosestSize(res):res};exports.getImageMaxWidth=getImageMaxWidth;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getImageMaxWidth=exports.getImageClosestSize=exports.getImage=void 0;const config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),number_js_1=require("../number/number.js"),object_js_1=require("../object/object.js"),dataSource_js_1=require("../dataSource/dataSource.js"),getImageUrl=(url,format,quality,width,height,params)=>{const urlObj=new URL(url);return Object.entries(params).forEach(([key,value])=>{let val=value;"%format"===val&&(val=format),"%quality"===val&&(val=`${quality}`),"%width"===val&&(val=`${width}`),"%height"===val&&(val=`${height}`),urlObj.searchParams.set(key,val)}),urlObj.toString()},getImage=(args,returnDetails=!1)=>{const{data:data,classes:classes,attr:attr,alt:imageAlt="inherit",width:width="auto",height:height="auto",lazy:lazy=!0,picture:picture=!1,quality:quality=75,source:source=config_js_1.config.source,maxWidth:maxWidth=1200,viewportWidth:viewportWidth=100,format:format="webp",params:params={fm:"%format",q:"%quality",w:"%width",h:"%height"}}=(0,object_js_1.isObjectStrict)(args)?args:{},fallback=returnDetails?{output:"",aspectRatio:0,naturalWidth:0,naturalHeight:0,src:"",srcFallback:"",srcset:[],sizes:""}:"";if(!(0,object_js_1.isObjectStrict)(data))return fallback;const{path:path="",alt:dataAlt="",width:naturalWidth=1,height:naturalHeight=1,format:naturalFormat="jpg",sizes:dataSizes}=data;let{url:url=config_js_1.config.image.remoteUrl}=data,alt="inherit"===imageAlt?dataAlt:imageAlt;(0,string_js_1.isStringStrict)(alt)||(alt="");const isLocal="local"===source,isRemote=dataSource_js_1.dataSource.isContentful(source)||"remote"===source,isWordpress=dataSource_js_1.dataSource.isWordPress(source);if(isLocal){if(!(0,string_js_1.isStringStrict)(path))return fallback;url=`${config_js_1.config.image.localUrl}/${path}`}const aspectRatio=naturalHeight/naturalWidth,aspectRatioReverse=naturalWidth/naturalHeight;let w=naturalWidth,h=naturalHeight;if((0,number_js_1.isNumber)(width)&&(w=width,h=(0,string_js_1.isString)(height)?w*aspectRatio:height),(0,number_js_1.isNumber)(height)&&(h=height,w=(0,string_js_1.isString)(width)?h*aspectRatioReverse:width),w>maxWidth&&(w=Math.round(maxWidth),h=Math.round(w*aspectRatio)),isWordpress&&dataSizes&&!dataSizes[w]){const isNatural=w===naturalWidth;isNatural||(w=getImageClosestSize(w,Object.keys(dataSizes).map(s=>parseInt(s,10))),h=Math.round(w*aspectRatio)),isNatural&&(dataSizes[w]=url)}let src=url,srcFallback=url;isLocal&&(src=`${url}.${format}`,srcFallback=`${url}.${naturalFormat}`),isRemote&&(src=getImageUrl(url,format,quality,w,h,params),srcFallback=getImageUrl(url,naturalFormat,quality,w,h,params));const sizes=`(min-width: ${w/16}rem) ${w/16}rem, ${viewportWidth}vw`,srcsetFallback=[];let srcset=[...config_js_1.config.image.sizes];srcset.includes(w)||srcset.push(w),srcset=srcset.filter(s=>s<=w),srcset.sort((a,b)=>a-b);const srcsetSource=[];srcset.forEach(s=>{if(isLocal){const base=`${url}${s!==naturalWidth?`@${s}`:""}`;srcsetFallback.push(`${base}.${naturalFormat} ${s}w`),srcsetSource.push(`${base}.${format} ${s}w`)}if(isRemote){const sizeHeight=Math.round(s*aspectRatio);srcsetFallback.push(getImageUrl(url,naturalFormat,quality,s,sizeHeight,params)+` ${s}w`),srcsetSource.push(getImageUrl(url,format,quality,s,sizeHeight,params)+` ${s}w`)}if(isWordpress){const sizeUrl=dataSizes?.[s];(0,string_js_1.isStringStrict)(sizeUrl)&&srcsetSource.push(`${sizeUrl} ${s}w`)}});let sourceOutput="";picture&&(sourceOutput=`<source srcset="${srcsetSource.join(", ")}" sizes="${sizes}" type="image/${format}">`);let eagerHackOutput="";lazy||(eagerHackOutput=`\n <img\n alt=""\n role="presentation"\n aria-hidden="true"\n src="data:image/svg+xml;charset=utf-8,%3Csvg height='${h}' width='${w}' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E" style="pointerEvents: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%"\n >\n `);const output=`\n ${eagerHackOutput}\n ${sourceOutput}\n <img\n ${(0,string_js_1.isStringStrict)(classes)?` class="${classes}"`:""}\n alt="${alt}"\n src="${picture?srcFallback:src}"\n srcset="${picture?srcsetFallback.join(", "):srcsetSource.join(", ")}"\n sizes="${sizes}"\n width="${w}"\n height="${h}"\n ${(0,string_js_1.isStringStrict)(attr)?` ${attr}`:""}\n ${lazy?' loading="lazy" decoding="async"':' loading="eager"'}\n >\n `;return returnDetails?{output:output,aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight,src:src,srcFallback:srcFallback,srcset:srcsetSource,sizes:sizes}:output};exports.getImage=getImage;const getImageClosestSize=(size,sizes=[])=>(sizes.length||(sizes=config_js_1.config.image.sizes),[...sizes].reduce((prev,curr)=>Math.abs(curr-size)<=Math.abs(prev-size)?curr:prev));exports.getImageClosestSize=getImageClosestSize;const getImageMaxWidth=args=>{if(!(0,object_js_1.isObjectStrict)(args))return 0;const{parents:parents,widths:widths,maxWidths:maxWidths,breakpoints:breakpoints,source:source=config_js_1.config.source}=args;if(!((0,array_js_1.isArrayStrict)(parents)&&(0,object_js_1.isObjectStrict)(widths)&&(0,object_js_1.isObjectStrict)(maxWidths)&&(0,array_js_1.isArrayStrict)(breakpoints)))return 0;const w=[];let m=0;if(parents.forEach(parent=>{if(!(0,object_js_1.isObjectStrict)(parent))return;const{renderType:renderType,args:args}=parent;if((0,object_js_1.isObjectStrict)(args)){if("column"===renderType){const{width:width="Default",widthSmall:widthSmall="Default",widthMedium:widthMedium="Default",widthLarge:widthLarge="Default"}=args;w[0]=(0,number_js_1.isNumber)(widths[width])&&widths[width]>0?widths[width]:1,w[1]=(0,number_js_1.isNumber)(widths[widthSmall])&&widths[widthSmall]>0?widths[widthSmall]:w[0],w[2]=(0,number_js_1.isNumber)(widths[widthMedium])&&widths[widthMedium]>0?widths[widthMedium]:w[1],w[3]=(0,number_js_1.isNumber)(widths[widthLarge])&&widths[widthLarge]>0?widths[widthLarge]:w[2]}if("container"===renderType){const{maxWidth:maxWidth="Default"}=args;m=(0,number_js_1.isNumber)(maxWidths[maxWidth])?maxWidths[maxWidth]:0}}}),!w.length&&0===m)return 0;const bk=[...breakpoints],calc=[];let lastW=1;bk.forEach((b,i)=>{const wd=w[i];(0,number_js_1.isNumber)(wd)&&(lastW=wd,m>0&&b>m?calc.push(wd*m):calc.push(wd*b))}),m>0&&calc.push(lastW*m);const res=2*Math.max(...calc);return"local"===source?getImageClosestSize(res):res};exports.getImageMaxWidth=getImageMaxWidth;
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.setLocalImages=void 0;const node_path_1=require("node:path"),promises_1=require("node:fs/promises"),sharp_1=__importDefault(require("sharp")),filePath_js_1=require("../file/filePath.js"),string_js_1=require("../string/string.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),setLocalImages=async()=>{const inputDir=config_js_1.config.image.inputDir,outputDir=config_js_1.config.image.outputDir;if(!(0,string_js_1.isStringStrict)(inputDir)||!(0,string_js_1.isStringStrict)(outputDir))throw new Error("No input or output directories");await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir),{recursive:!0});const images=[],meta={};for await(const path of(0,filePath_js_1.getFilePaths)(inputDir)){const baseName=(0,node_path_1.basename)(path),ext=(0,node_path_1.extname)(baseName);if(!(0,string_js_1.isStringStrict)(ext))continue;const[base]=baseName.split(ext);if(!(0,string_js_1.isStringStrict)(base?.trim()))continue;let[,folders]=(0,node_path_1.dirname)(path).split(`${inputDir}/`);(0,string_js_1.isStringStrict)(folders)&&folders!==baseName?await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir,folders),{recursive:!0}):folders="";const instance=(0,sharp_1.default)(path),metadata=await(0,sharp_1.default)(path).metadata(),stats=await(0,promises_1.stat)(path),{width:width=0,height:height=0,format:fileFormat="jpeg"}=metadata,id=`${folders?`${folders}/`:""}${base}`,format=ext.replace(".","");meta[id]={path:id,name:baseName,type:`image/${fileFormat}`,format:format,size:stats.size,width:width,height:height};let sizes=[...config_js_1.config.image.sizes];sizes.includes(width)||sizes.push(width),sizes=sizes.filter((s=>s<=width)),sizes.forEach((size=>{images.push({size:size,format:format,path:(0,node_path_1.resolve)(path),newPath:(0,node_path_1.resolve)(outputDir,folders,`${base}${size!==width?`@${size}`:""}`),instance:instance})}))}if(!images.length)throw new Error("No local images to transform");return(0,store_js_1.setStoreItem)("imageMeta",meta),await Promise.all(images.map((async image=>{const{size:size,instance:instance,newPath:newPath,format:format}=image;return await instance.clone().resize(size).toFile(`${newPath}.${format}`),await instance.clone().resize(size).webp({quality:config_js_1.config.image.quality}).toFile(`${newPath}.webp`)})))};exports.setLocalImages=setLocalImages;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.setLocalImages=void 0;const node_path_1=require("node:path"),promises_1=require("node:fs/promises"),sharp_1=__importDefault(require("sharp")),filePath_js_1=require("../file/filePath.js"),string_js_1=require("../string/string.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),setLocalImages=async()=>{const inputDir=config_js_1.config.image.inputDir,outputDir=config_js_1.config.image.outputDir;if(!(0,string_js_1.isStringStrict)(inputDir)||!(0,string_js_1.isStringStrict)(outputDir))throw new Error("No input or output directories");await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir),{recursive:!0});const images=[],meta={};for await(const path of(0,filePath_js_1.getFilePaths)(inputDir)){const baseName=(0,node_path_1.basename)(path),ext=(0,node_path_1.extname)(baseName);if(!(0,string_js_1.isStringStrict)(ext))continue;const[base]=baseName.split(ext);if(!(0,string_js_1.isStringStrict)(base?.trim()))continue;let[,folders]=(0,node_path_1.dirname)(path).split(`${inputDir}/`);(0,string_js_1.isStringStrict)(folders)&&folders!==baseName?await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir,folders),{recursive:!0}):folders="";const instance=(0,sharp_1.default)(path),metadata=await(0,sharp_1.default)(path).metadata(),stats=await(0,promises_1.stat)(path),{width:width=0,height:height=0,format:fileFormat="jpeg"}=metadata,id=`${folders?`${folders}/`:""}${base}`,format=ext.replace(".","");meta[id]={path:id,name:baseName,type:`image/${fileFormat}`,format:format,size:stats.size,width:width,height:height};let sizes=[...config_js_1.config.image.sizes];sizes.includes(width)||sizes.push(width),sizes=sizes.filter(s=>s<=width),sizes.forEach(size=>{images.push({size:size,format:format,path:(0,node_path_1.resolve)(path),newPath:(0,node_path_1.resolve)(outputDir,folders,`${base}${size!==width?`@${size}`:""}`),instance:instance})})}if(!images.length)throw new Error("No local images to transform");return(0,store_js_1.setStoreItem)("imageMeta",meta),await Promise.all(images.map(async image=>{const{size:size,instance:instance,newPath:newPath,format:format}=image;return await instance.clone().resize(size).toFile(`${newPath}.${format}`),await instance.clone().resize(size).webp({quality:config_js_1.config.image.quality}).toFile(`${newPath}.webp`)}))};exports.setLocalImages=setLocalImages;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRemoteImages=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getRemoteImages=async images=>{const inputDir=config_js_1.config.image.inputDir;if(!(0,string_js_1.isStringStrict)(inputDir))throw new Error("No input directory");if(!(0,array_js_1.isArrayStrict)(images))throw new Error("No images array");return await Promise.all(images.map((async image=>{const{path:path,url:url,format:format="jpg"}=image;if(!(0,string_js_1.isStringStrict)(path)||!(0,string_js_1.isStringStrict)(url)||!(0,string_js_1.isStringStrict)(format))throw new Error("No path, url or format");const resp=await fetch(url);if(!resp.ok)throw new Error("Failed to fetch image");const buffer=await resp.arrayBuffer(),fullPath=`${inputDir}/${path}.${format}`,folders=fullPath.split("/");return folders.pop(),await(0,promises_1.mkdir)((0,node_path_1.resolve)(folders.join("/")),{recursive:!0}),await(0,promises_1.writeFile)((0,node_path_1.resolve)(fullPath),Buffer.from(buffer)),fullPath})))};exports.getRemoteImages=getRemoteImages;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRemoteImages=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getRemoteImages=async images=>{const inputDir=config_js_1.config.image.inputDir;if(!(0,string_js_1.isStringStrict)(inputDir))throw new Error("No input directory");if(!(0,array_js_1.isArrayStrict)(images))throw new Error("No images array");return await Promise.all(images.map(async image=>{const{path:path,url:url,format:format="jpg"}=image;if(!(0,string_js_1.isStringStrict)(path)||!(0,string_js_1.isStringStrict)(url)||!(0,string_js_1.isStringStrict)(format))throw new Error("No path, url or format");const resp=await fetch(url);if(!resp.ok)throw new Error("Failed to fetch image");const buffer=await resp.arrayBuffer(),fullPath=`${inputDir}/${path}.${format}`,folders=fullPath.split("/");return folders.pop(),await(0,promises_1.mkdir)((0,node_path_1.resolve)(folders.join("/")),{recursive:!0}),await(0,promises_1.writeFile)((0,node_path_1.resolve)(fullPath),Buffer.from(buffer)),fullPath}))};exports.getRemoteImages=getRemoteImages;
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);desc&&!("get"in desc?!m.__esModule:desc.writable||desc.configurable)||(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}:function(o,m,k,k2){void 0===k2&&(k2=k),o[k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)Object.prototype.hasOwnProperty.call(o,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(null!=mod)for(var k=ownKeys(mod),i=0;i<k.length;i++)"default"!==k[i]&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJsonFile=exports.getJson=void 0;const object_js_1=require("../object/object.js"),path_js_1=require("../path/path.js"),filter_js_1=require("../filter/filter.js"),getJson=value=>{try{const val=JSON.parse(value);if((0,object_js_1.isObject)(val))return val;throw new Error("Parsed value is not an object")}catch{return}};exports.getJson=getJson;const getJsonFile=async(path,store=!1)=>{let res,newPath=path;try{newPath=store?(0,path_js_1.getPath)(path,"store"):path;const{default:obj}=await Promise.resolve(`${newPath}`).then((s=>__importStar(require(s))));if(!(0,object_js_1.isObject)(obj))throw new Error("No object in json file");res=obj}catch{res=void 0}return store?await(0,filter_js_1.applyFilters)("storeData",res,newPath,!0):res};exports.getJsonFile=getJsonFile;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);desc&&!("get"in desc?!m.__esModule:desc.writable||desc.configurable)||(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}:function(o,m,k,k2){void 0===k2&&(k2=k),o[k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)Object.prototype.hasOwnProperty.call(o,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(null!=mod)for(var k=ownKeys(mod),i=0;i<k.length;i++)"default"!==k[i]&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJsonFile=exports.getJson=void 0;const object_js_1=require("../object/object.js"),path_js_1=require("../path/path.js"),filter_js_1=require("../filter/filter.js"),getJson=value=>{try{const val=JSON.parse(value);if((0,object_js_1.isObject)(val))return val;throw new Error("Parsed value is not an object")}catch{return}};exports.getJson=getJson;const getJsonFile=async(path,store=!1)=>{let res,newPath=path;try{newPath=store?(0,path_js_1.getPath)(path,"store"):path;const{default:obj}=await Promise.resolve(`${newPath}`).then(s=>__importStar(require(s)));if(!(0,object_js_1.isObject)(obj))throw new Error("No object in json file");res=obj}catch{res=void 0}return store?await(0,filter_js_1.applyFilters)("storeData",res,newPath,!0):res};exports.getJsonFile=getJsonFile;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPermalink=exports.getLink=exports.getSlug=void 0;const number_js_1=require("../number/number.js"),object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),filter_js_1=require("../filter/filter.js"),archive_js_1=require("../archive/archive.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),getParentSlug=(id,contentType,parents,taxonomy,locale)=>{const storeParents=(0,store_js_1.getStoreItem)("parents"),parent=storeParents[contentType]?.[id];if(parent){const[parentId,parentSlug,parentTitle]=parent,newParent={id:parentId,slug:parentSlug,title:parentTitle,contentType:contentType,locale:locale};"term"===contentType&&(newParent.taxonomy=taxonomy),parents.unshift(newParent),getParentSlug(parentId,contentType,parents,taxonomy,locale)}},getSlug=(args,returnParents=!1)=>{const{id:id="",page:page=0,slug:initSlug="",contentType:contentType="page",itemData:itemData}=(0,object_js_1.isObjectStrict)(args)?args:{};let slug=initSlug,typeSlug="",taxSlug="",parentSlugs="",parts=[];const{hierarchicalTypes:hierarchicalTypes,typeInSlug:typeInSlug,localeInSlug:localeInSlug,taxonomyInSlug:taxonomyInSlug}=config_js_1.config,itemLocale=(0,string_js_1.isStringStrict)(itemData?.locale)?itemData.locale:void 0,hasItemLocale=null!=itemLocale,locale=hasItemLocale?localeInSlug[itemLocale]:"",hasLocale=(0,string_js_1.isStringStrict)(locale),taxonomyInfo=(0,archive_js_1.getTaxonomyInfo)(contentType,itemData),isTaxonomy="taxonomy"===contentType,isTerm="term"===contentType,{id:taxonomyId,slug:taxonomySlug,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug,isPage:taxonomyIsPage}=taxonomyInfo,archiveType=(0,string_js_1.isStringStrict)(taxonomyType)?taxonomyType:contentType,archiveInfo=(0,archive_js_1.getArchiveInfo)(archiveType,itemLocale),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveContentType}=archiveInfo,archiveParents=[];if(archiveSlug&&archiveId&&(typeSlug=archiveSlug,archiveParents.push({contentType:archiveContentType,title:archiveTitle,slug:archiveSlug,id:archiveId,locale:itemLocale})),!isTaxonomy&&!isTerm||taxonomyUseTypeSlug||(typeSlug=""),isTerm&&taxonomySlug&&taxonomyId){taxSlug=taxonomySlug;const taxInSlug=taxonomyInSlug[taxSlug];if((0,string_js_1.isString)(taxInSlug)&&(taxSlug=taxInSlug),(0,object_js_1.isObjectStrict)(taxInSlug)&&hasItemLocale){const localizedTaxSlug=taxInSlug[itemLocale];(0,string_js_1.isString)(localizedTaxSlug)&&(taxSlug=localizedTaxSlug)}taxonomyIsPage&&archiveParents.push({contentType:"taxonomy",locale:itemLocale,...taxonomyInfo})}const contentTypeInSlug=typeInSlug[archiveType];if((0,string_js_1.isString)(contentTypeInSlug)&&(typeSlug=contentTypeInSlug),(0,object_js_1.isObjectStrict)(contentTypeInSlug)&&hasItemLocale){const localizedTypeSlug=contentTypeInSlug[itemLocale];(0,string_js_1.isString)(localizedTypeSlug)&&(typeSlug=localizedTypeSlug)}const isHierarchical=hierarchicalTypes.includes(contentType);let parents=[],hasParents=!1;getParentSlug(isHierarchical?id:archiveId,isHierarchical?contentType:archiveContentType,parents,taxonomyInfo,itemLocale),parents.length&&(parentSlugs=parents.map((({slug:slug})=>slug)).join("/"),hasParents=!0),parents=isHierarchical?[...archiveParents,...parents]:[...parents,...archiveParents];const isIndex="index"===slug;isIndex&&!returnParents&&(slug=""),hasLocale&&parts.push(locale),hasParents&&!isHierarchical&&parts.push(parentSlugs),typeSlug&&parts.push(typeSlug),taxSlug&&parts.push(taxSlug),hasParents&&isHierarchical&&parts.push(parentSlugs),(0,string_js_1.isStringStrict)(slug)&&!isIndex&&parts.push(slug),parts=(0,filter_js_1.applyFilters)("slugParts",parts,args);let fullSlug=`${parts.length?parts.join("/"):""}${(0,number_js_1.isNumber)(page)&&page>1?`/?page=${page}`:""}`;if(fullSlug=(0,filter_js_1.applyFilters)("slug",fullSlug,args),returnParents){return{slug:fullSlug,parents:parents}}return fullSlug};exports.getSlug=getSlug;const getPermalink=(slug="",trailingSlash=!0)=>{let url="";if(config_js_1.config.env.prod&&(url=config_js_1.config.env.prodUrl),!(0,string_js_1.isStringStrict)(slug)||"/"===slug)return`${url}/`;const hasStartSlash=slug.startsWith("/"),hasEndSlash=slug.endsWith("/");return hasStartSlash||(slug=`/${slug}`),!hasEndSlash&&trailingSlash&&(slug=`${slug}/`),`${url}${slug}`};exports.getPermalink=getPermalink;const getLink=(internalLink,externalLink)=>{if((0,object_js_1.isObjectStrict)(internalLink)){const slug=internalLink.slug,res=getSlug({id:internalLink.id,contentType:internalLink.contentType,itemData:internalLink,slug:(0,string_js_1.isString)(slug)?slug:""});return getPermalink(res)}return(0,string_js_1.isStringStrict)(externalLink)?externalLink:""};exports.getLink=getLink;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPermalink=exports.getLink=exports.getSlug=void 0;const number_js_1=require("../number/number.js"),object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),filter_js_1=require("../filter/filter.js"),archive_js_1=require("../archive/archive.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),getParentSlug=(id,contentType,parents,taxonomy,locale)=>{const storeParents=(0,store_js_1.getStoreItem)("parents"),parent=storeParents[contentType]?.[id];if(parent){const[parentId,parentSlug,parentTitle]=parent,newParent={id:parentId,slug:parentSlug,title:parentTitle,contentType:contentType,locale:locale};"term"===contentType&&(newParent.taxonomy=taxonomy),parents.unshift(newParent),getParentSlug(parentId,contentType,parents,taxonomy,locale)}},getSlug=(args,returnParents=!1)=>{const{id:id="",page:page=0,slug:initSlug="",contentType:contentType="page",itemData:itemData}=(0,object_js_1.isObjectStrict)(args)?args:{};let slug=initSlug,typeSlug="",taxSlug="",parentSlugs="",parts=[];const{hierarchicalTypes:hierarchicalTypes,typeInSlug:typeInSlug,localeInSlug:localeInSlug,taxonomyInSlug:taxonomyInSlug}=config_js_1.config,itemLocale=(0,string_js_1.isStringStrict)(itemData?.locale)?itemData.locale:void 0,hasItemLocale=null!=itemLocale,locale=hasItemLocale?localeInSlug[itemLocale]:"",hasLocale=(0,string_js_1.isStringStrict)(locale),taxonomyInfo=(0,archive_js_1.getTaxonomyInfo)(contentType,itemData),isTaxonomy="taxonomy"===contentType,isTerm="term"===contentType,{id:taxonomyId,slug:taxonomySlug,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug,isPage:taxonomyIsPage}=taxonomyInfo,archiveType=(0,string_js_1.isStringStrict)(taxonomyType)?taxonomyType:contentType,archiveInfo=(0,archive_js_1.getArchiveInfo)(archiveType,itemLocale),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveContentType}=archiveInfo,archiveParents=[];if(archiveSlug&&archiveId&&(typeSlug=archiveSlug,archiveParents.push({contentType:archiveContentType,title:archiveTitle,slug:archiveSlug,id:archiveId,locale:itemLocale})),!isTaxonomy&&!isTerm||taxonomyUseTypeSlug||(typeSlug=""),isTerm&&taxonomySlug&&taxonomyId){taxSlug=taxonomySlug;const taxInSlug=taxonomyInSlug[taxSlug];if((0,string_js_1.isString)(taxInSlug)&&(taxSlug=taxInSlug),(0,object_js_1.isObjectStrict)(taxInSlug)&&hasItemLocale){const localizedTaxSlug=taxInSlug[itemLocale];(0,string_js_1.isString)(localizedTaxSlug)&&(taxSlug=localizedTaxSlug)}taxonomyIsPage&&archiveParents.push({contentType:"taxonomy",locale:itemLocale,...taxonomyInfo})}const contentTypeInSlug=typeInSlug[archiveType];if((0,string_js_1.isString)(contentTypeInSlug)&&(typeSlug=contentTypeInSlug),(0,object_js_1.isObjectStrict)(contentTypeInSlug)&&hasItemLocale){const localizedTypeSlug=contentTypeInSlug[itemLocale];(0,string_js_1.isString)(localizedTypeSlug)&&(typeSlug=localizedTypeSlug)}const isHierarchical=hierarchicalTypes.includes(contentType);let parents=[],hasParents=!1;getParentSlug(isHierarchical?id:archiveId,isHierarchical?contentType:archiveContentType,parents,taxonomyInfo,itemLocale),parents.length&&(parentSlugs=parents.map(({slug:slug})=>slug).join("/"),hasParents=!0),parents=isHierarchical?[...archiveParents,...parents]:[...parents,...archiveParents];const isIndex="index"===slug;isIndex&&!returnParents&&(slug=""),hasLocale&&parts.push(locale),hasParents&&!isHierarchical&&parts.push(parentSlugs),typeSlug&&parts.push(typeSlug),taxSlug&&parts.push(taxSlug),hasParents&&isHierarchical&&parts.push(parentSlugs),(0,string_js_1.isStringStrict)(slug)&&!isIndex&&parts.push(slug),parts=(0,filter_js_1.applyFilters)("slugParts",parts,args);let fullSlug=`${parts.length?parts.join("/"):""}${(0,number_js_1.isNumber)(page)&&page>1?`/?page=${page}`:""}`;if(fullSlug=(0,filter_js_1.applyFilters)("slug",fullSlug,args),returnParents){return{slug:fullSlug,parents:parents}}return fullSlug};exports.getSlug=getSlug;const getPermalink=(slug="",trailingSlash=!0)=>{let url="";if(config_js_1.config.env.prod&&(url=config_js_1.config.env.prodUrl),!(0,string_js_1.isStringStrict)(slug)||"/"===slug)return`${url}/`;const hasStartSlash=slug.startsWith("/"),hasEndSlash=slug.endsWith("/");return hasStartSlash||(slug=`/${slug}`),!hasEndSlash&&trailingSlash&&(slug=`${slug}/`),`${url}${slug}`};exports.getPermalink=getPermalink;const getLink=(internalLink,externalLink)=>{if((0,object_js_1.isObjectStrict)(internalLink)){const slug=internalLink.slug,res=getSlug({id:internalLink.id,contentType:internalLink.contentType,itemData:internalLink,slug:(0,string_js_1.isString)(slug)?slug:""});return getPermalink(res)}return(0,string_js_1.isStringStrict)(externalLink)?externalLink:""};exports.getLink=getLink;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getShareLinks=void 0;const string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),shareLinks={Facebook:"https://www.facebook.com/sharer.php?u=",X:"https://twitter.com/intent/tweet?url=",LinkedIn:"https://www.linkedin.com/shareArticle?url=",Pinterest:"https://pinterest.com/pin/create/button/?url=",Reddit:"https://reddit.com/submit?url=",Email:""},getShareLinks=(url,platforms,title)=>(0,string_js_1.isStringStrict)(url)&&(0,array_js_1.isArrayStrict)(platforms)?platforms.map((platform=>{const platformLink=shareLinks[platform];let link=(0,string_js_1.isStringStrict)(platformLink)?`${platformLink}${url}`:"";return"Email"===platform&&(link=`mailto:?subject=${encodeURIComponent((0,string_js_1.isStringStrict)(title)?title:"Check out this article")}&body=${url}`),{type:platform,link:link}})):[];exports.getShareLinks=getShareLinks;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getShareLinks=void 0;const string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),shareLinks={Facebook:"https://www.facebook.com/sharer.php?u=",X:"https://twitter.com/intent/tweet?url=",LinkedIn:"https://www.linkedin.com/shareArticle?url=",Pinterest:"https://pinterest.com/pin/create/button/?url=",Reddit:"https://reddit.com/submit?url=",Email:""},getShareLinks=(url,platforms,title)=>(0,string_js_1.isStringStrict)(url)&&(0,array_js_1.isArrayStrict)(platforms)?platforms.map(platform=>{const platformLink=shareLinks[platform];let link=(0,string_js_1.isStringStrict)(platformLink)?`${platformLink}${url}`:"";return"Email"===platform&&(link=`mailto:?subject=${encodeURIComponent((0,string_js_1.isStringStrict)(title)?title:"Check out this article")}&body=${url}`),{type:platform,link:link}}):[];exports.getShareLinks=getShareLinks;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPathDepth=exports.getPath=void 0;const string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),store_js_1=require("../../store/store.js"),getPath=(file,type)=>{const root=config_js_1.config.env.dir;if(!(0,string_js_1.isStringStrict)(root)||!(0,string_js_1.isStringStrict)(file))return"";let append=file;if("store"===type){const dir=store_js_1.storeDir;(0,string_js_1.isStringStrict)(dir)&&(append=`${dir}/${file}.json`)}return`${root}${root.endsWith("/")?"":"/"}${append}`};exports.getPath=getPath;const getPathDepth=(path="")=>{if(!(0,string_js_1.isStringStrict)(path))return"";let pathDepth=path.split("/");return pathDepth.pop(),pathDepth=pathDepth.map((()=>"../")),pathDepth.join("")};exports.getPathDepth=getPathDepth;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPathDepth=exports.getPath=void 0;const string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),store_js_1=require("../../store/store.js"),getPath=(file,type)=>{const root=config_js_1.config.env.dir;if(!(0,string_js_1.isStringStrict)(root)||!(0,string_js_1.isStringStrict)(file))return"";let append=file;if("store"===type){const dir=store_js_1.storeDir;(0,string_js_1.isStringStrict)(dir)&&(append=`${dir}/${file}.json`)}return`${root}${root.endsWith("/")?"":"/"}${append}`};exports.getPath=getPath;const getPathDepth=(path="")=>{if(!(0,string_js_1.isStringStrict)(path))return"";let pathDepth=path.split("/");return pathDepth.pop(),pathDepth=pathDepth.map(()=>"../"),pathDepth.join("")};exports.getPathDepth=getPathDepth;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.outputStyles=exports.outputScripts=exports.addStyle=exports.addScript=exports.styles=exports.scripts=void 0;const array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),scripts={deps:new Map,item:new Map,build:new Map,meta:{}};exports.scripts=scripts;const styles={deps:new Map,item:new Map,build:new Map};exports.styles=styles;const addScriptStyle=(type,path,deps=[])=>{if(!(0,string_js_1.isStringStrict)(path))return!1;const isScripts="scripts"===type,assets=isScripts?scripts:styles,ext=isScripts?"js":"scss",{inputDir:inputDir,outputDir:outputDir}=config_js_1.config[type],input=`${inputDir}/${path}.${ext}`,output=`${outputDir}/${path}`;return assets.item.set(output,input),assets.build.set(output,input),(0,array_js_1.isArrayStrict)(deps)&&deps.forEach((dep=>{const depInput=`${inputDir}/${dep}.${ext}`,depOutput=`${outputDir}/${dep}`;assets.deps.has(output)||assets.deps.set(output,new Set),assets.deps.get(output)?.add(depOutput),assets.item.set(depOutput,depInput),assets.build.set(depOutput,depInput)})),!0},addScript=(path,deps=[])=>addScriptStyle("scripts",path,deps);exports.addScript=addScript;const addStyle=(path,deps=[])=>addScriptStyle("styles",path,deps);exports.addStyle=addStyle;const outputScriptsStyles=(type,link)=>{if(!(0,string_js_1.isStringStrict)(link))return"";const{item:item,deps:deps}="scripts"===type?scripts:styles;if(!item.size)return"";const itemOut=Array.from(item.keys());itemOut.sort(((a,b)=>{const aIsDep=deps.get(b)?.has(a),bIsDep=deps.get(a)?.has(b);return!0===aIsDep?-1:!0===bIsDep?1:0}));let output="";return itemOut.forEach((out=>{"scripts"===type&&(output+=`<script type="module" src="${link}${out}.js"><\/script>`),"styles"===type&&(output+=`<link rel="stylesheet" href="${link}${out}.css" media="all">`)})),output},outputScripts=link=>outputScriptsStyles("scripts",link);exports.outputScripts=outputScripts;const outputStyles=link=>outputScriptsStyles("styles",link);exports.outputStyles=outputStyles;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.outputStyles=exports.outputScripts=exports.addStyle=exports.addScript=exports.styles=exports.scripts=void 0;const array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),scripts={deps:new Map,item:new Map,build:new Map,meta:{}};exports.scripts=scripts;const styles={deps:new Map,item:new Map,build:new Map};exports.styles=styles;const addScriptStyle=(type,path,deps=[])=>{if(!(0,string_js_1.isStringStrict)(path))return!1;const isScripts="scripts"===type,assets=isScripts?scripts:styles,ext=isScripts?"js":"scss",{inputDir:inputDir,outputDir:outputDir}=config_js_1.config[type],input=`${inputDir}/${path}.${ext}`,output=`${outputDir}/${path}`;return assets.item.set(output,input),assets.build.set(output,input),(0,array_js_1.isArrayStrict)(deps)&&deps.forEach(dep=>{const depInput=`${inputDir}/${dep}.${ext}`,depOutput=`${outputDir}/${dep}`;assets.deps.has(output)||assets.deps.set(output,new Set),assets.deps.get(output)?.add(depOutput),assets.item.set(depOutput,depInput),assets.build.set(depOutput,depInput)}),!0},addScript=(path,deps=[])=>addScriptStyle("scripts",path,deps);exports.addScript=addScript;const addStyle=(path,deps=[])=>addScriptStyle("styles",path,deps);exports.addStyle=addStyle;const outputScriptsStyles=(type,link)=>{if(!(0,string_js_1.isStringStrict)(link))return"";const{item:item,deps:deps}="scripts"===type?scripts:styles;if(!item.size)return"";const itemOut=Array.from(item.keys());itemOut.sort((a,b)=>{const aIsDep=deps.get(b)?.has(a),bIsDep=deps.get(a)?.has(b);return!0===aIsDep?-1:!0===bIsDep?1:0});let output="";return itemOut.forEach(out=>{"scripts"===type&&(output+=`<script type="module" src="${link}${out}.js"><\/script>`),"styles"===type&&(output+=`<link rel="stylesheet" href="${link}${out}.css" media="all">`)}),output},outputScripts=link=>outputScriptsStyles("scripts",link);exports.outputScripts=outputScripts;const outputStyles=link=>outputScriptsStyles("styles",link);exports.outputStyles=outputStyles;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stripShortcodes=exports.setShortcodes=exports.resetShortcodes=exports.doShortcodes=exports.removeShortcode=exports.addShortcode=exports.shortcodes=void 0;const object_js_1=require("../object/object.js"),array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),function_js_1=require("../function/function.js"),number_js_1=require("../number/number.js"),escape_js_1=require("../escape/escape.js"),shortcodes=new Map;exports.shortcodes=shortcodes;const attrReg=/[\w-]+=".*?"/g,getShortcodeData=(content,tagNames,props,itemData)=>{if(!(0,string_js_1.isStringStrict)(content)||!(0,string_js_1.isStringStrict)(tagNames))return[];const reg=new RegExp(String.raw`\[(?:\/)?(?<name>${tagNames})(?:\s[^\]]*?)?\]`,"g"),matches=[...content.matchAll(reg)];if(!matches.length)return[];const data=[];return matches.forEach(((opening,i)=>{const name=opening.groups?.name,tag=opening[0];if(!(0,string_js_1.isStringStrict)(name)||tag.startsWith("[/"))return;const info=props||shortcodes.get(name);if(!(0,object_js_1.isObjectStrict)(info))return;const child=info.child,hasChild=(0,string_js_1.isStringStrict)(child),startIndex=opening.index,startLen=tag.length;let endIndex=startIndex+tag.length,endLen=0;const closingTag=`[/${name}]`,closingMatch=hasChild?matches.find((m=>m[0]===closingTag)):matches[i+1];closingMatch?.[0]===closingTag&&(endIndex=closingMatch.index,endLen=closingTag.length);const attributes={},attributeTypes=(0,object_js_1.isObjectStrict)(info.attributeTypes)?info.attributeTypes:{},attr=tag.match(attrReg);(0,array_js_1.isArrayStrict)(attr)&&attr.forEach((a=>{const[key,value]=a.split("=");if(!(0,string_js_1.isStringStrict)(key)||!(0,string_js_1.isStringStrict)(value))return;let val=(0,escape_js_1.escape)(value.replace(/"/g,""));if((0,string_js_1.isStringStrict)(attributeTypes[key])){const type=attributeTypes[key];if("number"===type){const num=parseInt(val,10);val=isNaN(num)?0:num}"boolean"===type&&(val="true"===val)}attributes[key]=val}));let replaceContent="",innerContent="";(0,number_js_1.isNumber)(startIndex)&&(0,number_js_1.isNumber)(endIndex)&&(replaceContent=content.slice(startIndex,endIndex+endLen),innerContent=content.slice(startIndex+startLen,endIndex));let children=[];hasChild&&(children=getShortcodeData(innerContent,child,props,itemData)),data.push({name:name,replaceContent:replaceContent,content:innerContent,attributes:attributes,children:children,itemData:itemData})})),data},addShortcode=(name,shortcode)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,object_js_1.isObjectStrict)(shortcode))&&(shortcodes.set(name,shortcode),!0);exports.addShortcode=addShortcode;const removeShortcode=name=>!!(0,string_js_1.isStringStrict)(name)&&shortcodes.delete(name);exports.removeShortcode=removeShortcode;const doShortcodes=async(content,itemData)=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),data=getShortcodeData(content,names,void 0,itemData);if(!data.length)return content;let newContent=content;for(const datum of data){const{name:name,replaceContent:replaceContent}=datum,callback=shortcodes.get(name)?.callback;if((0,function_js_1.isFunction)(callback)){const res=await callback({...datum,itemData:itemData});(0,string_js_1.isStringStrict)(res)&&(newContent=newContent.replace(replaceContent,res))}}return newContent};exports.doShortcodes=doShortcodes;const resetShortcodes=()=>{shortcodes.clear()};exports.resetShortcodes=resetShortcodes;const setShortcodes=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const names=Object.entries(args);return!!names.length&&(resetShortcodes(),names.forEach((([name,shortcode])=>{addShortcode(name,shortcode)})),!0)};exports.setShortcodes=setShortcodes;const stripShortcodes=content=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),reg=new RegExp(String.raw`\[(?:\/)?(?<name>${names})(?:\s[^\]]*?)?\]`,"g");return content.replace(reg,(()=>""))};exports.stripShortcodes=stripShortcodes;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stripShortcodes=exports.setShortcodes=exports.resetShortcodes=exports.doShortcodes=exports.removeShortcode=exports.addShortcode=exports.shortcodes=void 0;const object_js_1=require("../object/object.js"),array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),function_js_1=require("../function/function.js"),number_js_1=require("../number/number.js"),escape_js_1=require("../escape/escape.js"),shortcodes=new Map;exports.shortcodes=shortcodes;const attrReg=/[\w-]+=".*?"/g,getShortcodeData=(content,tagNames,props,itemData)=>{if(!(0,string_js_1.isStringStrict)(content)||!(0,string_js_1.isStringStrict)(tagNames))return[];const reg=new RegExp(String.raw`\[(?:\/)?(?<name>${tagNames})(?:\s[^\]]*?)?\]`,"g"),matches=[...content.matchAll(reg)];if(!matches.length)return[];const data=[];return matches.forEach((opening,i)=>{const name=opening.groups?.name,tag=opening[0];if(!(0,string_js_1.isStringStrict)(name)||tag.startsWith("[/"))return;const info=props||shortcodes.get(name);if(!(0,object_js_1.isObjectStrict)(info))return;const child=info.child,hasChild=(0,string_js_1.isStringStrict)(child),startIndex=opening.index,startLen=tag.length;let endIndex=startIndex+tag.length,endLen=0;const closingTag=`[/${name}]`,closingMatch=hasChild?matches.find(m=>m[0]===closingTag):matches[i+1];closingMatch?.[0]===closingTag&&(endIndex=closingMatch.index,endLen=closingTag.length);const attributes={},attributeTypes=(0,object_js_1.isObjectStrict)(info.attributeTypes)?info.attributeTypes:{},attr=tag.match(attrReg);(0,array_js_1.isArrayStrict)(attr)&&attr.forEach(a=>{const[key,value]=a.split("=");if(!(0,string_js_1.isStringStrict)(key)||!(0,string_js_1.isStringStrict)(value))return;let val=(0,escape_js_1.escape)(value.replace(/"/g,""));if((0,string_js_1.isStringStrict)(attributeTypes[key])){const type=attributeTypes[key];if("number"===type){const num=parseInt(val,10);val=isNaN(num)?0:num}"boolean"===type&&(val="true"===val)}attributes[key]=val});let replaceContent="",innerContent="";(0,number_js_1.isNumber)(startIndex)&&(0,number_js_1.isNumber)(endIndex)&&(replaceContent=content.slice(startIndex,endIndex+endLen),innerContent=content.slice(startIndex+startLen,endIndex));let children=[];hasChild&&(children=getShortcodeData(innerContent,child,props,itemData)),data.push({name:name,replaceContent:replaceContent,content:innerContent,attributes:attributes,children:children,itemData:itemData})}),data},addShortcode=(name,shortcode)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,object_js_1.isObjectStrict)(shortcode))&&(shortcodes.set(name,shortcode),!0);exports.addShortcode=addShortcode;const removeShortcode=name=>!!(0,string_js_1.isStringStrict)(name)&&shortcodes.delete(name);exports.removeShortcode=removeShortcode;const doShortcodes=async(content,itemData)=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),data=getShortcodeData(content,names,void 0,itemData);if(!data.length)return content;let newContent=content;for(const datum of data){const{name:name,replaceContent:replaceContent}=datum,callback=shortcodes.get(name)?.callback;if((0,function_js_1.isFunction)(callback)){const res=await callback({...datum,itemData:itemData});(0,string_js_1.isStringStrict)(res)&&(newContent=newContent.replace(replaceContent,res))}}return newContent};exports.doShortcodes=doShortcodes;const resetShortcodes=()=>{shortcodes.clear()};exports.resetShortcodes=resetShortcodes;const setShortcodes=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const names=Object.entries(args);return!!names.length&&(resetShortcodes(),names.forEach(([name,shortcode])=>{addShortcode(name,shortcode)}),!0)};exports.setShortcodes=setShortcodes;const stripShortcodes=content=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),reg=new RegExp(String.raw`\[(?:\/)?(?<name>${names})(?:\s[^\]]*?)?\]`,"g");return content.replace(reg,()=>"")};exports.stripShortcodes=stripShortcodes;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tagExists=exports.getTag=void 0;const object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getTag=(item,id)=>{if(!(0,object_js_1.isObjectStrict)(item)||!(0,string_js_1.isStringStrict)(id))return;const tags=item.metadata?.tags;if(!(0,array_js_1.isArrayStrict)(tags))return;let tagInfo;return tags.find((tag=>{if(!(0,object_js_1.isObjectStrict)(tag))return!1;const tagId=tag.id;return tagId===id&&(tagInfo={id:tagId},!0)})),tagInfo};exports.getTag=getTag;const tagExists=(item,id)=>null!=getTag(item,id);exports.tagExists=tagExists;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tagExists=exports.getTag=void 0;const object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getTag=(item,id)=>{if(!(0,object_js_1.isObjectStrict)(item)||!(0,string_js_1.isStringStrict)(id))return;const tags=item.metadata?.tags;if(!(0,array_js_1.isArrayStrict)(tags))return;let tagInfo;return tags.find(tag=>{if(!(0,object_js_1.isObjectStrict)(tag))return!1;const tagId=tag.id;return tagId===id&&(tagInfo={id:tagId},!0)}),tagInfo};exports.getTag=getTag;const tagExists=(item,id)=>null!=getTag(item,id);exports.tagExists=tagExists;