@storyblok/astro 7.1.1 → 7.2.0

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.
@@ -499,7 +499,7 @@ const F = [], we = (e) => new Promise((t, s) => {
499
499
  return;
500
500
  }
501
501
  if (window.storyblokRegisterEvent = (l) => {
502
- if (window.location === window.parent.location) {
502
+ if (!window.location.search.includes("_storyblok")) {
503
503
  console.warn("You are not in Draft Mode or in the Visual Editor.");
504
504
  return;
505
505
  }
@@ -1,4 +1,4 @@
1
- (function(w,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(w=typeof globalThis<"u"?globalThis:w||self,T(w.storyblokAstro={}))})(this,function(w){"use strict";const T=`<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1
+ (function(w,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(w=typeof globalThis<"u"?globalThis:w||self,$(w.storyblokAstro={}))})(this,function(w){"use strict";const $=`<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
2
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
3
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
4
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -7,7 +7,7 @@
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`,Y=/[\p{Lu}]/u,q=/[\p{Ll}]/u,B=/^[\p{Lu}](?![\p{Lu}])/gu,N=/([\p{Alpha}\p{N}_]|$)/u,x=/[_.\- ]+/,X=new RegExp("^"+x.source),j=new RegExp(x.source+N.source,"gu"),P=new RegExp("\\d+"+N.source,"gu"),Z=(e,t,s,n)=>{let l=!1,r=!1,b=!1,p=!1;for(let i=0;i<e.length;i++){const u=e[i];p=i>2?e[i-3]==="-":!0,l&&Y.test(u)?(e=e.slice(0,i)+"-"+e.slice(i),l=!1,b=r,r=!0,i++):r&&b&&q.test(u)&&(!p||n)?(e=e.slice(0,i-1)+"-"+e.slice(i-1),b=r,r=!1,l=!0):(l=t(u)===u&&s(u)!==u,b=r,r=s(u)===u&&t(u)!==u)}return e},V=(e,t)=>(B.lastIndex=0,e.replaceAll(B,s=>t(s))),Q=(e,t)=>(j.lastIndex=0,P.lastIndex=0,e.replaceAll(P,(s,n,l)=>["_","-"].includes(e.charAt(l+s.length))?s:t(s)).replaceAll(j,(s,n)=>t(n)));function ee(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(r=>r.trim()).filter(r=>r.length).join("-"):e=e.trim(),e.length===0)return"";const s=t.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(t.locale),n=t.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(t.locale);return e.length===1?x.test(e)?"":t.pascalCase?n(e):s(e):(e!==s(e)&&(e=Z(e,s,n,t.preserveConsecutiveUppercase)),e=e.replace(X,""),e=t.preserveConsecutiveUppercase?V(e,s):s(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),Q(e,n))}function _(e){return ee(e)}function te(e,t={},s,n){const l="virtual:storyblok-components",r=`\0${l}`;return{name:"vite-plugin-storyblok-components",async resolveId(b){if(b===l)return r},async load(b){if(b===r){const p=[],i=[];for await(const[f,L]of Object.entries(t)){const S=await this.resolve(`/${e}/${L}.astro`);if(S)p.push(`import ${_(f)} from "${S.id}"`);else if(s)i.push(f);else throw new Error(`Component could not be found for blok "${f}"! Does "${`/${e}/${L}`}.astro" exist?`)}let u="";if(s)if(u=",FallbackComponent",n){const f=await this.resolve(`/${e}/${n}.astro`);if(!f)throw new Error(`Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`);p.push(`import FallbackComponent from "${f.id}"`)}else p.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${p.join(";")};export default {${Object.keys(t).filter(f=>!i.includes(f)).map(f=>_(f)).join(",")}${u}}`;if(s)return`${p[0]}; export default {${u.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
+ </svg>`,Y=/[\p{Lu}]/u,q=/[\p{Ll}]/u,B=/^[\p{Lu}](?![\p{Lu}])/gu,N=/([\p{Alpha}\p{N}_]|$)/u,_=/[_.\- ]+/,X=new RegExp("^"+_.source),j=new RegExp(_.source+N.source,"gu"),P=new RegExp("\\d+"+N.source,"gu"),Z=(e,t,s,n)=>{let l=!1,r=!1,b=!1,p=!1;for(let i=0;i<e.length;i++){const u=e[i];p=i>2?e[i-3]==="-":!0,l&&Y.test(u)?(e=e.slice(0,i)+"-"+e.slice(i),l=!1,b=r,r=!0,i++):r&&b&&q.test(u)&&(!p||n)?(e=e.slice(0,i-1)+"-"+e.slice(i-1),b=r,r=!1,l=!0):(l=t(u)===u&&s(u)!==u,b=r,r=s(u)===u&&t(u)!==u)}return e},V=(e,t)=>(B.lastIndex=0,e.replaceAll(B,s=>t(s))),Q=(e,t)=>(j.lastIndex=0,P.lastIndex=0,e.replaceAll(P,(s,n,l)=>["_","-"].includes(e.charAt(l+s.length))?s:t(s)).replaceAll(j,(s,n)=>t(n)));function ee(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(r=>r.trim()).filter(r=>r.length).join("-"):e=e.trim(),e.length===0)return"";const s=t.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(t.locale),n=t.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(t.locale);return e.length===1?_.test(e)?"":t.pascalCase?n(e):s(e):(e!==s(e)&&(e=Z(e,s,n,t.preserveConsecutiveUppercase)),e=e.replace(X,""),e=t.preserveConsecutiveUppercase?V(e,s):s(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),Q(e,n))}function x(e){return ee(e)}function te(e,t={},s,n){const l="virtual:storyblok-components",r=`\0${l}`;return{name:"vite-plugin-storyblok-components",async resolveId(b){if(b===l)return r},async load(b){if(b===r){const p=[],i=[];for await(const[f,L]of Object.entries(t)){const S=await this.resolve(`/${e}/${L}.astro`);if(S)p.push(`import ${x(f)} from "${S.id}"`);else if(s)i.push(f);else throw new Error(`Component could not be found for blok "${f}"! Does "${`/${e}/${L}`}.astro" exist?`)}let u="";if(s)if(u=",FallbackComponent",n){const f=await this.resolve(`/${e}/${n}.astro`);if(!f)throw new Error(`Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`);p.push(`import FallbackComponent from "${f.id}"`)}else p.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${p.join(";")};export default {${Object.keys(t).filter(f=>!i.includes(f)).map(f=>x(f)).join(",")}${u}}`;if(s)return`${p[0]}; export default {${u.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
11
11
  Please register your components or enable the fallback component.
12
12
  Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function oe(e,t,s){const n="virtual:storyblok-init",l=`\0${n}`;return{name:"vite-plugin-storyblok-init",async resolveId(r){if(r===n)return l},async load(r){if(r===l)return`
13
13
  import { storyblokInit, apiPlugin } from "@storyblok/js";
@@ -36,4 +36,4 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
36
36
  ${s}
37
37
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
38
38
  });
39
- `),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),r({id:"storyblok",name:"Storyblok",icon:T,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let D;async function ie(e){const{action:t,story:s}=e||{};if(t==="input"&&s){const n=async()=>{const r=await de(s),b=document.body;if(r.outerHTML===b.outerHTML)return;const p=document.querySelector('[data-blok-focused="true"]');ce(b,r,p),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(D),D=setTimeout(n,500)}["published","change"].includes(e==null?void 0:e.action)&&location.reload()}function ce(e,t,s){if(s){const n=s.getAttribute("data-blok-uid"),l=t.querySelector(`[data-blok-uid="${n}"]`);l&&(l.setAttribute("data-blok-focused","true"),s.replaceWith(l))}else e.replaceWith(t)}async function de(e){const s=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...e,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(s,"text/html").body}function ue(e,t){if(!t)return{src:e,attrs:{}};let s=0,n=0;const l={},r=[];function b(i,u,f,L,S){typeof i!="number"||i<=u||i>=f?console.warn(`[StoryblokRichText] - ${L.charAt(0).toUpperCase()+L.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):S.push(`${L}(${i})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(l.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(l.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(l.loading=t.loading),t.class&&(l.class=t.class),t.filters){const{filters:i}=t||{},{blur:u,brightness:f,fill:L,format:S,grayscale:E,quality:A,rotate:R}=i||{};u&&b(u,0,100,"blur",r),A&&b(A,0,100,"quality",r),f&&b(f,0,100,"brightness",r),L&&r.push(`fill(${L})`),E&&r.push("grayscale()"),R&&[0,90,180,270].includes(t.filters.rotate||0)&&r.push(`rotate(${R})`),S&&["webp","png","jpeg"].includes(S)&&r.push(`format(${S})`)}t.srcset&&(l.srcset=t.srcset.map(i=>{if(typeof i=="number")return`${e}/m/${i}x0/${r.length>0?`filters:${r.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,f]=i;return`${e}/m/${u}x${f}/${r.length>0?`filters:${r.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(l.sizes=t.sizes.join(", "))}let p=`${e}/m/`;return s>0&&n>0&&(p=`${p}${s}x${n}/`),r.length>0&&(p=`${p}filters:${r.join(":")}`),{src:p,attrs:l}}var h=(e=>(e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e))(h||{}),C=(e=>(e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e))(C||{}),U=(e=>(e.TEXT="text",e))(U||{}),$=(e=>(e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e))($||{});const pe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],be=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),fe=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ye(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function H(e,t={},s){const n=be(t),l=n?`${e} ${n}`:e,r=Array.isArray(s)?s.join(""):s||"";if(e){if(pe.includes(e))return`<${l}>`}else return r;return`<${l}>${r}</${e}>`}function F(e={}){const t=new Map,{renderFn:s=H,textFn:n=ye,resolvers:l={},optimizeImages:r=!1,keyedResolvers:b=!1}=e,p=s!==H,i=o=>(a,c)=>{const d=a.attrs||{};return c.render(o,d,a.children||null)},u=(o,a)=>{const{src:c,alt:d,title:y,srcset:k,sizes:g}=o.attrs||{};let m=c,v={};if(r){const{src:Ae,attrs:Ie}=ue(c,r);m=Ae,v=Ie}const $e={src:m,alt:d,title:y,srcset:k,sizes:g,...v};return a.render("img",I($e))},f=(o,a)=>{const{level:c,...d}=o.attrs||{};return a.render(`h${c}`,d,o.children)},L=(o,a)=>{var c,d,y,k;const g=a.render("img",{src:(c=o.attrs)==null?void 0:c.fallbackImage,alt:(d=o.attrs)==null?void 0:d.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return a.render("span",{"data-type":"emoji","data-name":(y=o.attrs)==null?void 0:y.name,"data-emoji":(k=o.attrs)==null?void 0:k.emoji},g)},S=(o,a)=>a.render("pre",o.attrs||{},a.render("code",{},o.children||"")),E=(o,a=!1)=>({text:c,attrs:d},y)=>{const{class:k,id:g,...m}=d||{},v=a?{class:k,id:g,style:fe(m)||void 0}:d||{};return y.render(o,I(v),c)},A=o=>M(o),R=o=>{const{marks:a,...c}=o;if("text"in o){if(a)return a.reduce((y,k)=>A({...k,text:y}),A({...c,children:c.children}));const d=o.attrs||{};if(b){const y=t.get("txt")||0;t.set("txt",y+1),d.key=`txt-${y}`}return n(c.text,d)}return""},K=(o,a)=>{const{linktype:c,href:d,anchor:y,...k}=o.attrs||{};let g="";switch(c){case $.ASSET:case $.URL:g=d;break;case $.EMAIL:g=`mailto:${d}`;break;case $.STORY:g=d,y&&(g=`${g}#${y}`);break;default:g=d;break}const m={...k};return g&&(m.href=g),a.render("a",m,o.text)},ve=(o,a)=>{var c,d;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),a.render("span",{blok:(c=o==null?void 0:o.attrs)==null?void 0:c.body[0],id:(d=o.attrs)==null?void 0:d.id,style:"display: none"})},Ce=(o,a)=>{const c={},d=a.render("tbody",{},o.children);return a.render("table",c,d)},Ee=(o,a)=>{const c={};return a.render("tr",c,o.children)},Le=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:k,...g}=o.attrs||{},m={...g};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),k&&v.push(`background-color: ${k};`),v.length>0&&(m.style=v.join(" ")),a.render("td",I(m),o.children)},Se=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:k,...g}=o.attrs||{},m={...g};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),k&&v.push(`background-color: ${k};`),v.length>0&&(m.style=v.join(" ")),a.render("th",I(m),o.children)},J=new Map([[h.DOCUMENT,i("")],[h.HEADING,f],[h.PARAGRAPH,i("p")],[h.UL_LIST,i("ul")],[h.OL_LIST,i("ol")],[h.LIST_ITEM,i("li")],[h.IMAGE,u],[h.EMOJI,L],[h.CODE_BLOCK,S],[h.HR,i("hr")],[h.BR,i("br")],[h.QUOTE,i("blockquote")],[h.COMPONENT,ve],[U.TEXT,R],[C.LINK,K],[C.ANCHOR,K],[C.STYLED,E("span",!0)],[C.BOLD,E("strong")],[C.TEXT_STYLE,E("span",!0)],[C.ITALIC,E("em")],[C.UNDERLINE,E("u")],[C.STRIKE,E("s")],[C.CODE,E("code")],[C.SUPERSCRIPT,E("sup")],[C.SUBSCRIPT,E("sub")],[C.HIGHLIGHT,E("mark")],[h.TABLE,Ce],[h.TABLE_ROW,Ee],[h.TABLE_CELL,Le],[h.TABLE_HEADER,Se]]),W=new Map([...J,...Object.entries(l).map(([o,a])=>[o,a])]),Te=()=>({render:(o,a={},c)=>{if(b&&o){const d=t.get(o)||0;t.set(o,d+1),a.key=`${o}-${d}`}return s(o,a,c)},originalResolvers:J,mergedResolvers:W});function O(o){const a=W.get(o.type);if(!a)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const c=Te();if(o.type==="text")return a(o,c);const d=o.content?o.content.map(M):void 0;return a({...o,children:d},c)}function M(o){return o.type==="doc"?p?o.content.map(O):o.content.map(O).join(""):Array.isArray(o)?o.map(O):O(o)}return{render:M}}let G=!1;const z=[],he=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=l=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?l():z.push(l)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=l=>s(l),n.onload=l=>{z.forEach(r=>r()),G=!0,t(l)},document.getElementsByTagName("head")[0].appendChild(n)}),ge=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let me="https://app.storyblok.com/f/storyblok-v2-latest.js";function ke(e,t){return F(t).render(e)}const we=()=>he(me);w.getLiveStory=ne,w.handleStoryblokMessage=ie,w.loadStoryblokBridge=we,w.renderRichText=ke,w.richTextResolver=F,w.storyblok=ae,w.storyblokEditable=ge,w.toCamelCase=_,w.useStoryblokApi=se,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
39
+ `),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),r({id:"storyblok",name:"Storyblok",icon:$,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let D;async function ie(e){const{action:t,story:s}=e||{};if(t==="input"&&s){const n=async()=>{const r=await de(s),b=document.body;if(r.outerHTML===b.outerHTML)return;const p=document.querySelector('[data-blok-focused="true"]');ce(b,r,p),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(D),D=setTimeout(n,500)}["published","change"].includes(e==null?void 0:e.action)&&location.reload()}function ce(e,t,s){if(s){const n=s.getAttribute("data-blok-uid"),l=t.querySelector(`[data-blok-uid="${n}"]`);l&&(l.setAttribute("data-blok-focused","true"),s.replaceWith(l))}else e.replaceWith(t)}async function de(e){const s=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...e,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(s,"text/html").body}function ue(e,t){if(!t)return{src:e,attrs:{}};let s=0,n=0;const l={},r=[];function b(i,u,f,L,S){typeof i!="number"||i<=u||i>=f?console.warn(`[StoryblokRichText] - ${L.charAt(0).toUpperCase()+L.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):S.push(`${L}(${i})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(l.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(l.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(l.loading=t.loading),t.class&&(l.class=t.class),t.filters){const{filters:i}=t||{},{blur:u,brightness:f,fill:L,format:S,grayscale:E,quality:A,rotate:R}=i||{};u&&b(u,0,100,"blur",r),A&&b(A,0,100,"quality",r),f&&b(f,0,100,"brightness",r),L&&r.push(`fill(${L})`),E&&r.push("grayscale()"),R&&[0,90,180,270].includes(t.filters.rotate||0)&&r.push(`rotate(${R})`),S&&["webp","png","jpeg"].includes(S)&&r.push(`format(${S})`)}t.srcset&&(l.srcset=t.srcset.map(i=>{if(typeof i=="number")return`${e}/m/${i}x0/${r.length>0?`filters:${r.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,f]=i;return`${e}/m/${u}x${f}/${r.length>0?`filters:${r.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(l.sizes=t.sizes.join(", "))}let p=`${e}/m/`;return s>0&&n>0&&(p=`${p}${s}x${n}/`),r.length>0&&(p=`${p}filters:${r.join(":")}`),{src:p,attrs:l}}var h=(e=>(e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e))(h||{}),C=(e=>(e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e))(C||{}),U=(e=>(e.TEXT="text",e))(U||{}),T=(e=>(e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e))(T||{});const pe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],be=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),fe=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ye(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function H(e,t={},s){const n=be(t),l=n?`${e} ${n}`:e,r=Array.isArray(s)?s.join(""):s||"";if(e){if(pe.includes(e))return`<${l}>`}else return r;return`<${l}>${r}</${e}>`}function F(e={}){const t=new Map,{renderFn:s=H,textFn:n=ye,resolvers:l={},optimizeImages:r=!1,keyedResolvers:b=!1}=e,p=s!==H,i=o=>(a,c)=>{const d=a.attrs||{};return c.render(o,d,a.children||null)},u=(o,a)=>{const{src:c,alt:d,title:y,srcset:m,sizes:g}=o.attrs||{};let k=c,v={};if(r){const{src:Ae,attrs:Ie}=ue(c,r);k=Ae,v=Ie}const Te={src:k,alt:d,title:y,srcset:m,sizes:g,...v};return a.render("img",I(Te))},f=(o,a)=>{const{level:c,...d}=o.attrs||{};return a.render(`h${c}`,d,o.children)},L=(o,a)=>{var c,d,y,m;const g=a.render("img",{src:(c=o.attrs)==null?void 0:c.fallbackImage,alt:(d=o.attrs)==null?void 0:d.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return a.render("span",{"data-type":"emoji","data-name":(y=o.attrs)==null?void 0:y.name,"data-emoji":(m=o.attrs)==null?void 0:m.emoji},g)},S=(o,a)=>a.render("pre",o.attrs||{},a.render("code",{},o.children||"")),E=(o,a=!1)=>({text:c,attrs:d},y)=>{const{class:m,id:g,...k}=d||{},v=a?{class:m,id:g,style:fe(k)||void 0}:d||{};return y.render(o,I(v),c)},A=o=>M(o),R=o=>{const{marks:a,...c}=o;if("text"in o){if(a)return a.reduce((y,m)=>A({...m,text:y}),A({...c,children:c.children}));const d=o.attrs||{};if(b){const y=t.get("txt")||0;t.set("txt",y+1),d.key=`txt-${y}`}return n(c.text,d)}return""},K=(o,a)=>{const{linktype:c,href:d,anchor:y,...m}=o.attrs||{};let g="";switch(c){case T.ASSET:case T.URL:g=d;break;case T.EMAIL:g=`mailto:${d}`;break;case T.STORY:g=d,y&&(g=`${g}#${y}`);break;default:g=d;break}const k={...m};return g&&(k.href=g),a.render("a",k,o.text)},ve=(o,a)=>{var c,d;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),a.render("span",{blok:(c=o==null?void 0:o.attrs)==null?void 0:c.body[0],id:(d=o.attrs)==null?void 0:d.id,style:"display: none"})},Ce=(o,a)=>{const c={},d=a.render("tbody",{},o.children);return a.render("table",c,d)},Ee=(o,a)=>{const c={};return a.render("tr",c,o.children)},Le=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:m,...g}=o.attrs||{},k={...g};c>1&&(k.colspan=c),d>1&&(k.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),m&&v.push(`background-color: ${m};`),v.length>0&&(k.style=v.join(" ")),a.render("td",I(k),o.children)},Se=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:m,...g}=o.attrs||{},k={...g};c>1&&(k.colspan=c),d>1&&(k.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),m&&v.push(`background-color: ${m};`),v.length>0&&(k.style=v.join(" ")),a.render("th",I(k),o.children)},J=new Map([[h.DOCUMENT,i("")],[h.HEADING,f],[h.PARAGRAPH,i("p")],[h.UL_LIST,i("ul")],[h.OL_LIST,i("ol")],[h.LIST_ITEM,i("li")],[h.IMAGE,u],[h.EMOJI,L],[h.CODE_BLOCK,S],[h.HR,i("hr")],[h.BR,i("br")],[h.QUOTE,i("blockquote")],[h.COMPONENT,ve],[U.TEXT,R],[C.LINK,K],[C.ANCHOR,K],[C.STYLED,E("span",!0)],[C.BOLD,E("strong")],[C.TEXT_STYLE,E("span",!0)],[C.ITALIC,E("em")],[C.UNDERLINE,E("u")],[C.STRIKE,E("s")],[C.CODE,E("code")],[C.SUPERSCRIPT,E("sup")],[C.SUBSCRIPT,E("sub")],[C.HIGHLIGHT,E("mark")],[h.TABLE,Ce],[h.TABLE_ROW,Ee],[h.TABLE_CELL,Le],[h.TABLE_HEADER,Se]]),W=new Map([...J,...Object.entries(l).map(([o,a])=>[o,a])]),$e=()=>({render:(o,a={},c)=>{if(b&&o){const d=t.get(o)||0;t.set(o,d+1),a.key=`${o}-${d}`}return s(o,a,c)},originalResolvers:J,mergedResolvers:W});function O(o){const a=W.get(o.type);if(!a)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const c=$e();if(o.type==="text")return a(o,c);const d=o.content?o.content.map(M):void 0;return a({...o,children:d},c)}function M(o){return o.type==="doc"?p?o.content.map(O):o.content.map(O).join(""):Array.isArray(o)?o.map(O):O(o)}return{render:M}}let G=!1;const z=[],he=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=l=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?l():z.push(l)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=l=>s(l),n.onload=l=>{z.forEach(r=>r()),G=!0,t(l)},document.getElementsByTagName("head")[0].appendChild(n)}),ge=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let ke="https://app.storyblok.com/f/storyblok-v2-latest.js";function me(e,t){return F(t).render(e)}const we=()=>he(ke);w.getLiveStory=ne,w.handleStoryblokMessage=ie,w.loadStoryblokBridge=we,w.renderRichText=me,w.richTextResolver=F,w.storyblok=ae,w.storyblokEditable=ge,w.toCamelCase=x,w.useStoryblokApi=se,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "7.1.1",
4
+ "version": "7.2.0",
5
5
  "private": false,
6
6
  "description": "Official Astro integration for the Storyblok Headless CMS",
7
7
  "author": "Storyblok",
@@ -56,12 +56,11 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "camelcase": "^8.0.0",
59
- "@storyblok/js": "4.1.1"
59
+ "@storyblok/js": "4.2.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@cypress/vite-dev-server": "^6.0.3",
63
63
  "@rollup/plugin-dynamic-import-vars": "^2.1.5",
64
- "@storyblok/eslint-config": "^0.3.0",
65
64
  "@types/lodash.mergewith": "^4.6.9",
66
65
  "@types/node": "^22.15.18",
67
66
  "astro": "^5.0.9",
@@ -77,7 +76,8 @@
77
76
  "vite": "^6.3.5",
78
77
  "vite-plugin-dts": "^4.5.3",
79
78
  "vite-plugin-static-copy": "^2.2.0",
80
- "vitest": "^3.1.3"
79
+ "vitest": "^3.1.3",
80
+ "@storyblok/eslint-config": "0.4.0"
81
81
  },
82
82
  "eslintConfig": {
83
83
  "env": {