@storyblok/astro 5.1.2 → 6.0.0-next.1

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.
@@ -1,14 +1,23 @@
1
- (function(k,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(k=typeof globalThis<"u"?globalThis:k||self,N(k.storyblokAstro={}))})(this,function(k){"use strict";function N(o,t,r){const i="virtual:storyblok-init",s=`\0${i}`;return{name:"vite-plugin-storyblok-init",async resolveId(l){if(l===i)return s},async load(l){if(l===s)return`
1
+ (function(u,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(u=typeof globalThis<"u"?globalThis:u||self,b(u.storyblokAstro={}))})(this,function(u){"use strict";const b=`<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
+ <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
+ <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
+ <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
5
+ <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
6
+ <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
7
+ </g>
8
+ </g>
9
+ </g>
10
+ </svg>`,j=/[\p{Lu}]/u,M=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,y=/[_.\- ]+/,P=new RegExp("^"+y.source),C=new RegExp(y.source+v.source,"gu"),S=new RegExp("\\d+"+v.source,"gu"),O=(r,e,t,o)=>{let s=!1,n=!1,a=!1,l=!1;for(let i=0;i<r.length;i++){const c=r[i];l=i>2?r[i-3]==="-":!0,s&&j.test(c)?(r=r.slice(0,i)+"-"+r.slice(i),s=!1,a=n,n=!0,i++):n&&a&&M.test(c)&&(!l||o)?(r=r.slice(0,i-1)+"-"+r.slice(i-1),a=n,n=!1,s=!0):(s=e(c)===c&&t(c)!==c,a=n,n=t(c)===c&&e(c)!==c)}return r},_=(r,e)=>($.lastIndex=0,r.replaceAll($,t=>e(t))),N=(r,e)=>(C.lastIndex=0,S.lastIndex=0,r.replaceAll(S,(t,o,s)=>["_","-"].includes(r.charAt(s+t.length))?t:e(t)).replaceAll(C,(t,o)=>e(o)));function z(r,e){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(n=>n.trim()).filter(n=>n.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),o=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return r.length===1?y.test(r)?"":e.pascalCase?o(r):t(r):(r!==t(r)&&(r=O(r,t,o,e.preserveConsecutiveUppercase)),r=r.replace(P,""),r=e.preserveConsecutiveUppercase?_(r,t):t(r),e.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),N(r,o))}function m(r){return z(r)}function B(r,e={},t,o){const s="virtual:storyblok-components",n=`\0${s}`;return{name:"vite-plugin-storyblok-components",async resolveId(a){if(a===s)return n},async load(a){if(a===n){const l=[],i=[];for await(const[d,f]of Object.entries(e)){const h=await this.resolve(`/${r}/${f}.astro`);if(h)l.push(`import ${m(d)} from "${h.id}"`);else if(t)i.push(d);else throw new Error(`Component could not be found for blok "${d}"! Does "${`/${r}/${f}`}.astro" exist?`)}let c="";if(t)if(c=",FallbackComponent",o){const d=await this.resolve(`/${r}/${o}.astro`);if(!d)throw new Error(`Custom fallback component could not be found. Does "${`/${r}/${o}`}.astro" exist?`);l.push(`import FallbackComponent from "${d.id}"`)}else l.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(e).length)return`${l.join(";")};export default {${Object.keys(e).filter(d=>!i.includes(d)).map(d=>m(d)).join(",")}${c}}`;if(t)return`${l[0]}; export default {${c.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
11
+ Please register your components or enable the fallback component.
12
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function F(r,e,t){const o="virtual:storyblok-init",s=`\0${o}`;return{name:"vite-plugin-storyblok-init",async resolveId(n){if(n===o)return s},async load(n){if(n===s)return`
2
13
  import { storyblokInit, apiPlugin } from "@storyblok/js";
3
14
  const { storyblokApi } = storyblokInit({
4
- accessToken: "${o}",
5
- use: ${t?"[]":"[apiPlugin]"},
6
- apiOptions: ${JSON.stringify(r)},
15
+ accessToken: "${r}",
16
+ use: ${e?"[]":"[apiPlugin]"},
17
+ apiOptions: ${JSON.stringify(t)},
7
18
  });
8
19
  export const storyblokApiInstance = storyblokApi;
9
- `}}}const Xe=/[\p{Lu}]/u,Ye=/[\p{Ll}]/u,he=/^[\p{Lu}](?![\p{Lu}])/gu,be=/([\p{Alpha}\p{N}_]|$)/u,te=/[_.\- ]+/,Qe=new RegExp("^"+te.source),ye=new RegExp(te.source+be.source,"gu"),me=new RegExp("\\d+"+be.source,"gu"),et=(o,t,r,i)=>{let s=!1,l=!1,u=!1,f=!1;for(let g=0;g<o.length;g++){const y=o[g];f=g>2?o[g-3]==="-":!0,s&&Xe.test(y)?(o=o.slice(0,g)+"-"+o.slice(g),s=!1,u=l,l=!0,g++):l&&u&&Ye.test(y)&&(!f||i)?(o=o.slice(0,g-1)+"-"+o.slice(g-1),u=l,l=!1,s=!0):(s=t(y)===y&&r(y)!==y,u=l,l=r(y)===y&&t(y)!==y)}return o},tt=(o,t)=>(he.lastIndex=0,o.replaceAll(he,r=>t(r))),rt=(o,t)=>(ye.lastIndex=0,me.lastIndex=0,o.replaceAll(me,(r,i,s)=>["_","-"].includes(o.charAt(s+r.length))?r:t(r)).replaceAll(ye,(r,i)=>t(i)));function nt(o,t){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(o)?o=o.map(l=>l.trim()).filter(l=>l.length).join("-"):o=o.trim(),o.length===0)return"";const r=t.locale===!1?l=>l.toLowerCase():l=>l.toLocaleLowerCase(t.locale),i=t.locale===!1?l=>l.toUpperCase():l=>l.toLocaleUpperCase(t.locale);return o.length===1?te.test(o)?"":t.pascalCase?i(o):r(o):(o!==r(o)&&(o=et(o,r,i,t.preserveConsecutiveUppercase)),o=o.replace(Qe,""),o=t.preserveConsecutiveUppercase?tt(o,r):r(o),t.pascalCase&&(o=i(o.charAt(0))+o.slice(1)),rt(o,i))}function re(o){return nt(o)}function ot(o,t={},r,i){const s="virtual:storyblok-components",l=`\0${s}`;return{name:"vite-plugin-storyblok-components",async resolveId(u){if(u===s)return l},async load(u){if(u===l){const f=[],g=[];for await(const[_,A]of Object.entries(t)){const C=await this.resolve(`/${o}/${A}.astro`);if(C)f.push(`import ${re(_)} from "${C.id}"`);else if(r)g.push(_);else throw new Error(`Component could not be found for blok "${_}"! Does "${`/${o}/${A}`}.astro" exist?`)}let y="";if(r)if(y=",FallbackComponent",i){const _=await this.resolve(`/${o}/${i}.astro`);if(!_)throw new Error(`Custom fallback component could not be found. Does "${`/${o}/${i}`}.astro" exist?`);f.push(`import FallbackComponent from "${_.id}"`)}else f.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${f.join(";")};export default {${Object.keys(t).filter(_=>!g.includes(_)).map(_=>re(_)).join(",")}${y}}`;if(r)return`${f[0]}; export default {${y.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
- Please register your components or enable the fallback component.
11
- Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function at(o){const t="virtual:storyblok-options",r=`\0${t}`;return{name:"vite-plugin-storyblok-options",async resolveId(i){if(i===t)return r},async load(i){if(i===r)return`export default ${JSON.stringify(o)}`}}}let ve=!1;const _e=[],it=o=>new Promise((t,r)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}ve?s():_e.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=o,i.id="storyblok-javascript-bridge",i.onerror=s=>r(s),i.onload=s=>{_e.forEach(l=>l()),ve=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(i)});var st=Object.defineProperty,lt=(o,t,r)=>t in o?st(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,I=(o,t,r)=>lt(o,typeof t!="symbol"?t+"":t,r);let ct=class{constructor(){I(this,"isCDNUrl",(o="")=>o.includes("/cdn/")),I(this,"getOptionsPage",(o,t=25,r=1)=>({...o,per_page:t,page:r})),I(this,"delay",o=>new Promise(t=>setTimeout(t,o))),I(this,"arrayFrom",(o=0,t)=>Array.from({length:o},t)),I(this,"range",(o=0,t=o)=>{const r=Math.abs(t-o)||0,i=o<t?1:-1;return this.arrayFrom(r,(s,l)=>l*i+o)}),I(this,"asyncMap",async(o,t)=>Promise.all(o.map(t))),I(this,"flatMap",(o=[],t)=>o.map(t).reduce((r,i)=>[...r,...i],[])),I(this,"escapeHTML",function(o){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,i=new RegExp(r.source);return o&&i.test(o)?o.replace(r,s=>t[s]):o})}stringify(o,t,r){const i=[];for(const s in o){if(!Object.prototype.hasOwnProperty.call(o,s))continue;const l=o[s],u=r?"":encodeURIComponent(s);let f;typeof l=="object"?f=this.stringify(l,t?t+encodeURIComponent(`[${u}]`):u,Array.isArray(l)):f=`${t?t+encodeURIComponent(`[${u}]`):u}=${encodeURIComponent(l)}`,i.push(f)}return i.join("&")}getRegionURL(o){const t="api.storyblok.com",r="api-us.storyblok.com",i="app.storyblokchina.cn",s="api-ap.storyblok.com",l="api-ca.storyblok.com";switch(o){case"us":return r;case"cn":return i;case"ap":return s;case"ca":return l;default:return t}}};const ut=function(o,t){const r={};for(const i in o){const s=o[i];t.includes(i)&&s!==null&&(r[i]=s)}return r},ft=o=>o==="email",dt=()=>({singleTag:"hr"}),pt=()=>({tag:"blockquote"}),gt=()=>({tag:"ul"}),ht=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),bt=()=>({singleTag:"br"}),yt=o=>({tag:`h${o.attrs.level}`}),mt=o=>({singleTag:[{tag:"img",attrs:ut(o.attrs,["src","alt","title"])}]}),vt=()=>({tag:"li"}),_t=()=>({tag:"ol"}),wt=()=>({tag:"p"}),kt=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Tt=()=>({tag:"b"}),Ct=()=>({tag:"s"}),At=()=>({tag:"u"}),St=()=>({tag:"strong"}),It=()=>({tag:"code"}),$t=()=>({tag:"i"}),Ot=o=>{if(!o.attrs)return{tag:""};const t=new ct().escapeHTML,r={...o.attrs},{linktype:i="url"}=o.attrs;if(delete r.linktype,r.href&&(r.href=t(o.attrs.href||"")),ft(i)&&(r.href=`mailto:${r.href}`),r.anchor&&(r.href=`${r.href}#${r.anchor}`,delete r.anchor),r.custom){for(const s in r.custom)r[s]=r.custom[s];delete r.custom}return{tag:[{tag:"a",attrs:r}]}},jt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),xt=()=>({tag:"sub"}),Et=()=>({tag:"sup"}),Rt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Pt=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Lt=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},we={nodes:{horizontal_rule:dt,blockquote:pt,bullet_list:gt,code_block:ht,hard_break:bt,heading:yt,image:mt,list_item:vt,ordered_list:_t,paragraph:wt,emoji:kt},marks:{bold:Tt,strike:Ct,underline:At,strong:St,code:It,italic:$t,link:Ot,styled:jt,subscript:xt,superscript:Et,anchor:Rt,highlight:Pt,textStyle:Lt}},Mt=function(o){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,i=new RegExp(r.source);return o&&i.test(o)?o.replace(r,s=>t[s]):o};let ke=!1;class Nt{constructor(t){I(this,"marks"),I(this,"nodes"),t||(t=we),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,r){this.nodes[t]=r}addMark(t,r){this.marks[t]=r}render(t,r={optimizeImages:!1},i=!0){if(!ke&&i&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),ke=!0),t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(l=>{s+=this.renderNode(l)}),r.optimizeImages?this.optimizeImages(s,r.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
20
+ `}}}function D(r){const e="virtual:storyblok-options",t=`\0${e}`;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===e)return t},async load(o){if(o===t)return`export default ${JSON.stringify(r)}`}}}let I=!1;const T=[],U=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?s():T.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>t(s),o.onload=s=>{T.forEach(n=>n()),I=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(o)});var q=Object.defineProperty,H=(r,e,t)=>e in r?q(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>H(r,typeof e!="symbol"?e+"":e,t);let W=class{constructor(){p(this,"isCDNUrl",(r="")=>r.includes("/cdn/")),p(this,"getOptionsPage",(r,e=25,t=1)=>({...r,per_page:e,page:t})),p(this,"delay",r=>new Promise(e=>setTimeout(e,r))),p(this,"arrayFrom",(r=0,e)=>Array.from({length:r},e)),p(this,"range",(r=0,e=r)=>{const t=Math.abs(e-r)||0,o=r<e?1:-1;return this.arrayFrom(t,(s,n)=>n*o+r)}),p(this,"asyncMap",async(r,e)=>Promise.all(r.map(e))),p(this,"flatMap",(r=[],e)=>r.map(e).reduce((t,o)=>[...t,...o],[])),p(this,"escapeHTML",function(r){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,o=new RegExp(t.source);return r&&o.test(r)?r.replace(t,s=>e[s]):r})}stringify(r,e,t){const o=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const n=r[s],a=t?"":encodeURIComponent(s);let l;typeof n=="object"?l=this.stringify(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):l=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")}getRegionURL(r){const e="api.storyblok.com",t="api-us.storyblok.com",o="app.storyblokchina.cn",s="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(r){case"us":return t;case"cn":return o;case"ap":return s;case"ca":return n;default:return e}}};const J=function(r,e){const t={};for(const o in r){const s=r[o];e.includes(o)&&s!==null&&(t[o]=s)}return t},V=r=>r==="email",K=()=>({singleTag:"hr"}),Z=()=>({tag:"blockquote"}),G=()=>({tag:"ul"}),X=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),Y=()=>({singleTag:"br"}),Q=r=>({tag:`h${r.attrs.level}`}),ee=r=>({singleTag:[{tag:"img",attrs:J(r.attrs,["src","alt","title"])}]}),te=()=>({tag:"li"}),re=()=>({tag:"ol"}),oe=()=>({tag:"p"}),se=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),ne=()=>({tag:"b"}),ae=()=>({tag:"s"}),le=()=>({tag:"u"}),ie=()=>({tag:"strong"}),ce=()=>({tag:"code"}),ue=()=>({tag:"i"}),de=r=>{if(!r.attrs)return{tag:""};const e=new W().escapeHTML,t={...r.attrs},{linktype:o="url"}=r.attrs;if(delete t.linktype,t.href&&(t.href=e(r.attrs.href||"")),V(o)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ge=r=>({tag:[{tag:"span",attrs:r.attrs}]}),pe=()=>({tag:"sub"}),fe=()=>({tag:"sup"}),he=r=>({tag:[{tag:"span",attrs:r.attrs}]}),be=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},ye=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},A={nodes:{horizontal_rule:K,blockquote:Z,bullet_list:G,code_block:X,hard_break:Y,heading:Q,image:ee,list_item:te,ordered_list:re,paragraph:oe,emoji:se},marks:{bold:ne,strike:ae,underline:le,strong:ie,code:ce,italic:ue,link:de,styled:ge,subscript:pe,superscript:fe,anchor:he,highlight:be,textStyle:ye}},me=function(r){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,o=new RegExp(t.source);return r&&o.test(r)?r.replace(t,s=>e[s]):r};let E=!1;class ke{constructor(e){p(this,"marks"),p(this,"nodes"),e||(e=A),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},o=!0){if(!E&&o&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),E=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(n=>{s+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
12
21
  The "content" field must be an array of nodes as the type ISbRichtext.
13
22
  ISbRichtext:
14
23
  content?: ISbRichtext[]
@@ -31,39 +40,25 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
31
40
  }
32
41
  ],
33
42
  type: 'doc'
34
- }`),""}optimizeImages(t,r){let i=0,s=0,l="",u="";typeof r!="boolean"&&(typeof r.width=="number"&&r.width>0&&(l+=`width="${r.width}" `,i=r.width),typeof r.height=="number"&&r.height>0&&(l+=`height="${r.height}" `,s=r.height),(r.loading==="lazy"||r.loading==="eager")&&(l+=`loading="${r.loading}" `),typeof r.class=="string"&&r.class.length>0&&(l+=`class="${r.class}" `),r.filters&&(typeof r.filters.blur=="number"&&r.filters.blur>=0&&r.filters.blur<=100&&(u+=`:blur(${r.filters.blur})`),typeof r.filters.brightness=="number"&&r.filters.brightness>=-100&&r.filters.brightness<=100&&(u+=`:brightness(${r.filters.brightness})`),r.filters.fill&&(r.filters.fill.match(/[0-9A-F]{6}/gi)||r.filters.fill==="transparent")&&(u+=`:fill(${r.filters.fill})`),r.filters.format&&["webp","png","jpeg"].includes(r.filters.format)&&(u+=`:format(${r.filters.format})`),typeof r.filters.grayscale=="boolean"&&r.filters.grayscale&&(u+=":grayscale()"),typeof r.filters.quality=="number"&&r.filters.quality>=0&&r.filters.quality<=100&&(u+=`:quality(${r.filters.quality})`),r.filters.rotate&&[90,180,270].includes(r.filters.rotate)&&(u+=`:rotate(${r.filters.rotate})`),u.length>0&&(u=`/filters${u}`))),l.length>0&&(t=t.replace(/<img/g,`<img ${l.trim()}`));const f=i>0||s>0||u.length>0?`${i}x${s}${u}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${f}`),typeof r!="boolean"&&(r.sizes||r.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,g=>{var y,_;const A=g.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(A&&A.length>0){const C={srcset:(y=r.srcset)==null?void 0:y.map(w=>{if(typeof w=="number")return`//${A}/m/${w}x0${u} ${w}w`;if(typeof w=="object"&&w.length===2){let x=0,J=0;return typeof w[0]=="number"&&(x=w[0]),typeof w[1]=="number"&&(J=w[1]),`//${A}/m/${x}x${J}${u} ${x}w`}return""}).join(", "),sizes:(_=r.sizes)==null?void 0:_.map(w=>w).join(", ")};let O="";return C.srcset&&(O+=`srcset="${C.srcset}" `),C.sizes&&(O+=`sizes="${C.sizes}" `),g.replace(/<img/g,`<img ${O.trim()}`)}return g})),t}renderNode(t){const r=[];t.marks&&t.marks.forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&r.push(this.renderOpeningTag(l.tag))});const i=this.getMatchingNode(t);return i&&i.tag&&r.push(this.renderOpeningTag(i.tag)),t.content?t.content.forEach(s=>{r.push(this.renderNode(s))}):t.text?r.push(Mt(t.text)):i&&i.singleTag?r.push(this.renderTag(i.singleTag," /")):i&&i.html?r.push(i.html):t.type==="emoji"&&r.push(this.renderEmoji(t)),i&&i.tag&&r.push(this.renderClosingTag(i.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&r.push(this.renderClosingTag(l.tag))}),r.join("")}renderTag(t,r){return t.constructor===String?`<${t}${r}>`:t.map(i=>{if(i.constructor===String)return`<${i}${r}>`;{let s=`<${i.tag}`;if(i.attrs){for(const l in i.attrs)if(Object.prototype.hasOwnProperty.call(i.attrs,l)){const u=i.attrs[l];u!==null&&(s+=` ${l}="${u}"`)}}return`${s}${r}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(t){const r=this.nodes[t.type];if(typeof r=="function")return r(t)}getMatchingMark(t){const r=this.marks[t.type];if(typeof r=="function")return r(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const r=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(r," /")}}const Te=Nt,zt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const t=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}:{}}catch{return{}}};let Ft,Dt="https://app.storyblok.com/f/storyblok-v2-latest.js";const Bt=(o,t)=>{o.addNode("blok",r=>{let i="";return r.attrs.body.forEach(s=>{i+=t(s.component,s)}),{html:i}})},Ut=o=>!o||!(o!=null&&o.content.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule")),Ht=(o,t,r)=>{let i=r||Ft;if(!i){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ut(o)?"":(t&&(i=new Te(t.schema),t.resolver&&Bt(i,t.resolver)),i.render(o,{},!1))},qt=()=>it(Dt);function Gt(o){const t={resolveRelations:[]};function r(i){i&&Array.isArray(t.resolveRelations)&&t.resolveRelations.push(...Array.isArray(i)?i:[i])}for(const i of o)if(i.options){const{apiOptions:s,bridgeOptions:l}=i.options;if(r(s==null?void 0:s.resolve_relations),l){const{resolveRelations:u,...f}=l;r(u),Object.assign(t,f)}}return t.resolveRelations=[...new Set(t.resolveRelations)],t}var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jt(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var z={exports:{}};z.exports;var Ce;function Wt(){return Ce||(Ce=1,function(o,t){var r=200,i="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,f="[object Arguments]",g="[object Array]",y="[object AsyncFunction]",_="[object Boolean]",A="[object Date]",C="[object Error]",O="[object Function]",w="[object GeneratorFunction]",x="[object Map]",J="[object Number]",sr="[object Null]",Ie="[object Object]",lr="[object Proxy]",cr="[object RegExp]",ur="[object Set]",fr="[object String]",dr="[object Undefined]",pr="[object WeakMap]",gr="[object ArrayBuffer]",hr="[object DataView]",br="[object Float32Array]",yr="[object Float64Array]",mr="[object Int8Array]",vr="[object Int16Array]",_r="[object Int32Array]",wr="[object Uint8Array]",kr="[object Uint8ClampedArray]",Tr="[object Uint16Array]",Cr="[object Uint32Array]",Ar=/[\\^$.*+?()[\]{}|]/g,Sr=/^\[object .+?Constructor\]$/,Ir=/^(?:0|[1-9]\d*)$/,b={};b[br]=b[yr]=b[mr]=b[vr]=b[_r]=b[wr]=b[kr]=b[Tr]=b[Cr]=!0,b[f]=b[g]=b[gr]=b[_]=b[hr]=b[A]=b[C]=b[O]=b[x]=b[J]=b[Ie]=b[cr]=b[ur]=b[fr]=b[pr]=!1;var $e=typeof G=="object"&&G&&G.Object===Object&&G,$r=typeof self=="object"&&self&&self.Object===Object&&self,D=$e||$r||Function("return this")(),Oe=t&&!t.nodeType&&t,B=Oe&&!0&&o&&!o.nodeType&&o,je=B&&B.exports===Oe,ne=je&&$e.process,xe=function(){try{var e=B&&B.require&&B.require("util").types;return e||ne&&ne.binding&&ne.binding("util")}catch{}}(),Ee=xe&&xe.isTypedArray;function Or(e,n,a){switch(a.length){case 0:return e.call(n);case 1:return e.call(n,a[0]);case 2:return e.call(n,a[0],a[1]);case 3:return e.call(n,a[0],a[1],a[2])}return e.apply(n,a)}function jr(e,n){for(var a=-1,c=Array(e);++a<e;)c[a]=n(a);return c}function xr(e){return function(n){return e(n)}}function Er(e,n){return e==null?void 0:e[n]}function Rr(e,n){return function(a){return e(n(a))}}var Pr=Array.prototype,Lr=Function.prototype,W=Object.prototype,oe=D["__core-js_shared__"],K=Lr.toString,j=W.hasOwnProperty,Re=function(){var e=/[^.]+$/.exec(oe&&oe.keys&&oe.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Pe=W.toString,Mr=K.call(Object),Nr=RegExp("^"+K.call(j).replace(Ar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Z=je?D.Buffer:void 0,Le=D.Symbol,Me=D.Uint8Array;Z&&Z.allocUnsafe;var Ne=Rr(Object.getPrototypeOf,Object),ze=Object.create,zr=W.propertyIsEnumerable,Fr=Pr.splice,E=Le?Le.toStringTag:void 0,V=function(){try{var e=se(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Dr=Z?Z.isBuffer:void 0,Fe=Math.max,Br=Date.now,De=se(D,"Map"),U=se(Object,"create"),Ur=function(){function e(){}return function(n){if(!P(n))return{};if(ze)return ze(n);e.prototype=n;var a=new e;return e.prototype=void 0,a}}();function R(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function Hr(){this.__data__=U?U(null):{},this.size=0}function qr(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function Gr(e){var n=this.__data__;if(U){var a=n[e];return a===i?void 0:a}return j.call(n,e)?n[e]:void 0}function Jr(e){var n=this.__data__;return U?n[e]!==void 0:j.call(n,e)}function Wr(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=U&&n===void 0?i:n,this}R.prototype.clear=Hr,R.prototype.delete=qr,R.prototype.get=Gr,R.prototype.has=Jr,R.prototype.set=Wr;function $(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function Kr(){this.__data__=[],this.size=0}function Zr(e){var n=this.__data__,a=X(n,e);if(a<0)return!1;var c=n.length-1;return a==c?n.pop():Fr.call(n,a,1),--this.size,!0}function Vr(e){var n=this.__data__,a=X(n,e);return a<0?void 0:n[a][1]}function Xr(e){return X(this.__data__,e)>-1}function Yr(e,n){var a=this.__data__,c=X(a,e);return c<0?(++this.size,a.push([e,n])):a[c][1]=n,this}$.prototype.clear=Kr,$.prototype.delete=Zr,$.prototype.get=Vr,$.prototype.has=Xr,$.prototype.set=Yr;function L(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function Qr(){this.size=0,this.__data__={hash:new R,map:new(De||$),string:new R}}function en(e){var n=Q(this,e).delete(e);return this.size-=n?1:0,n}function tn(e){return Q(this,e).get(e)}function rn(e){return Q(this,e).has(e)}function nn(e,n){var a=Q(this,e),c=a.size;return a.set(e,n),this.size+=a.size==c?0:1,this}L.prototype.clear=Qr,L.prototype.delete=en,L.prototype.get=tn,L.prototype.has=rn,L.prototype.set=nn;function M(e){var n=this.__data__=new $(e);this.size=n.size}function on(){this.__data__=new $,this.size=0}function an(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function sn(e){return this.__data__.get(e)}function ln(e){return this.__data__.has(e)}function cn(e,n){var a=this.__data__;if(a instanceof $){var c=a.__data__;if(!De||c.length<r-1)return c.push([e,n]),this.size=++a.size,this;a=this.__data__=new L(c)}return a.set(e,n),this.size=a.size,this}M.prototype.clear=on,M.prototype.delete=an,M.prototype.get=sn,M.prototype.has=ln,M.prototype.set=cn;function un(e,n){var a=ue(e),c=!a&&ce(e),d=!a&&!c&&Ge(e),h=!a&&!c&&!d&&We(e),m=a||c||d||h,p=m?jr(e.length,String):[],v=p.length;for(var S in e)m&&(S=="length"||d&&(S=="offset"||S=="parent")||h&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||He(S,v))||p.push(S);return p}function ae(e,n,a){(a!==void 0&&!ee(e[n],a)||a===void 0&&!(n in e))&&ie(e,n,a)}function fn(e,n,a){var c=e[n];(!(j.call(e,n)&&ee(c,a))||a===void 0&&!(n in e))&&ie(e,n,a)}function X(e,n){for(var a=e.length;a--;)if(ee(e[a][0],n))return a;return-1}function ie(e,n,a){n=="__proto__"&&V?V(e,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[n]=a}var dn=An();function Y(e){return e==null?e===void 0?dr:sr:E&&E in Object(e)?Sn(e):En(e)}function Be(e){return H(e)&&Y(e)==f}function pn(e){if(!P(e)||jn(e))return!1;var n=de(e)?Nr:Sr;return n.test(Mn(e))}function gn(e){return H(e)&&Je(e.length)&&!!b[Y(e)]}function hn(e){if(!P(e))return xn(e);var n=qe(e),a=[];for(var c in e)c=="constructor"&&(n||!j.call(e,c))||a.push(c);return a}function Ue(e,n,a,c,d){e!==n&&dn(n,function(h,m){if(d||(d=new M),P(h))bn(e,n,m,a,Ue,c,d);else{var p=c?c(le(e,m),h,m+"",e,n,d):void 0;p===void 0&&(p=h),ae(e,m,p)}},Ke)}function bn(e,n,a,c,d,h,m){var p=le(e,a),v=le(n,a),S=m.get(v);if(S){ae(e,a,S);return}var T=h?h(p,v,a+"",e,n,m):void 0,q=T===void 0;if(q){var pe=ue(v),ge=!pe&&Ge(v),Ve=!pe&&!ge&&We(v);T=v,pe||ge||Ve?ue(p)?T=p:Nn(p)?T=kn(p):ge?(q=!1,T=vn(v)):Ve?(q=!1,T=wn(v)):T=[]:zn(v)||ce(v)?(T=p,ce(p)?T=Fn(p):(!P(p)||de(p))&&(T=In(v))):q=!1}q&&(m.set(v,T),d(T,v,c,h,m),m.delete(v)),ae(e,a,T)}function yn(e,n){return Pn(Rn(e,n,Ze),e+"")}var mn=V?function(e,n){return V(e,"toString",{configurable:!0,enumerable:!1,value:Bn(n),writable:!0})}:Ze;function vn(e,n){return e.slice()}function _n(e){var n=new e.constructor(e.byteLength);return new Me(n).set(new Me(e)),n}function wn(e,n){var a=_n(e.buffer);return new e.constructor(a,e.byteOffset,e.length)}function kn(e,n){var a=-1,c=e.length;for(n||(n=Array(c));++a<c;)n[a]=e[a];return n}function Tn(e,n,a,c){var d=!a;a||(a={});for(var h=-1,m=n.length;++h<m;){var p=n[h],v=void 0;v===void 0&&(v=e[p]),d?ie(a,p,v):fn(a,p,v)}return a}function Cn(e){return yn(function(n,a){var c=-1,d=a.length,h=d>1?a[d-1]:void 0,m=d>2?a[2]:void 0;for(h=e.length>3&&typeof h=="function"?(d--,h):void 0,m&&$n(a[0],a[1],m)&&(h=d<3?void 0:h,d=1),n=Object(n);++c<d;){var p=a[c];p&&e(n,p,c,h)}return n})}function An(e){return function(n,a,c){for(var d=-1,h=Object(n),m=c(n),p=m.length;p--;){var v=m[++d];if(a(h[v],v,h)===!1)break}return n}}function Q(e,n){var a=e.__data__;return On(n)?a[typeof n=="string"?"string":"hash"]:a.map}function se(e,n){var a=Er(e,n);return pn(a)?a:void 0}function Sn(e){var n=j.call(e,E),a=e[E];try{e[E]=void 0;var c=!0}catch{}var d=Pe.call(e);return c&&(n?e[E]=a:delete e[E]),d}function In(e){return typeof e.constructor=="function"&&!qe(e)?Ur(Ne(e)):{}}function He(e,n){var a=typeof e;return n=n??u,!!n&&(a=="number"||a!="symbol"&&Ir.test(e))&&e>-1&&e%1==0&&e<n}function $n(e,n,a){if(!P(a))return!1;var c=typeof n;return(c=="number"?fe(a)&&He(n,a.length):c=="string"&&n in a)?ee(a[n],e):!1}function On(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function jn(e){return!!Re&&Re in e}function qe(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||W;return e===a}function xn(e){var n=[];if(e!=null)for(var a in Object(e))n.push(a);return n}function En(e){return Pe.call(e)}function Rn(e,n,a){return n=Fe(n===void 0?e.length-1:n,0),function(){for(var c=arguments,d=-1,h=Fe(c.length-n,0),m=Array(h);++d<h;)m[d]=c[n+d];d=-1;for(var p=Array(n+1);++d<n;)p[d]=c[d];return p[n]=a(m),Or(e,this,p)}}function le(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var Pn=Ln(mn);function Ln(e){var n=0,a=0;return function(){var c=Br(),d=l-(c-a);if(a=c,d>0){if(++n>=s)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function Mn(e){if(e!=null){try{return K.call(e)}catch{}try{return e+""}catch{}}return""}function ee(e,n){return e===n||e!==e&&n!==n}var ce=Be(function(){return arguments}())?Be:function(e){return H(e)&&j.call(e,"callee")&&!zr.call(e,"callee")},ue=Array.isArray;function fe(e){return e!=null&&Je(e.length)&&!de(e)}function Nn(e){return H(e)&&fe(e)}var Ge=Dr||Un;function de(e){if(!P(e))return!1;var n=Y(e);return n==O||n==w||n==y||n==lr}function Je(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=u}function P(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function H(e){return e!=null&&typeof e=="object"}function zn(e){if(!H(e)||Y(e)!=Ie)return!1;var n=Ne(e);if(n===null)return!0;var a=j.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&K.call(a)==Mr}var We=Ee?xr(Ee):gn;function Fn(e){return Tn(e,Ke(e))}function Ke(e){return fe(e)?un(e):hn(e)}var Dn=Cn(function(e,n,a,c){Ue(e,n,a,c)});function Bn(e){return function(){return e}}function Ze(e){return e}function Un(){return!1}o.exports=Dn}(z,z.exports)),z.exports}var Kt=Wt();const Zt=Jt(Kt);function Vt(o){let t={};function r(i,s){if((s==null?void 0:s.type)==="AwaitExpression"&&s.argument.type==="CallExpression"&&s.argument.callee.type==="Identifier"&&s.argument.callee.name==="useStoryblok"){const l=s.argument.arguments;if(l&&l[1].type==="ObjectExpression"){const u=Ae(l[1].properties);t={...t,apiOptions:u}}if(l&&l[2].type==="ObjectExpression"){const u=Ae(l[2].properties);t={...t,bridgeOptions:u}}}}return Zt({},o,r),t}function Ae(o){const t={};return o.reduce((r,i)=>{if(i.type!=="Property")return r;const{key:s,value:l}=i,{type:u}=l;if(s.type!=="Identifier")return r;if(u==="Literal")r[s.name]=l.value;else if(u==="ArrayExpression"){const f=l.elements.reduce((g,y)=>y.type==="Literal"&&y.value?[...g,y.value]:g,[]);r[s.name]=f}return r},t)}let F=[];function Xt(o,t){const r="virtual:storyblok-bridge",i=`\0${r}`;if(!o||t!=="server")return{name:"vite-plugin-storyblok-bridge",resolveId(f){if(f===r)return i},load(f){if(f===i)return"export const bridgeOptions = null"}};let s=[],l=null,u;return{name:"vite-plugin-storyblok-bridge",async resolveId(f){if(f===r)return i},async transform(f,g){var w;if(g.includes("node_modules")&&!g.includes("/pages/")||!f.includes("useStoryblok"))return;const _=this.getModuleInfo(g);if(!((w=_==null?void 0:_.meta)!=null&&w.astro))return;const[,...A]=g.split("src/pages/"),C=A.join("/").replace(".astro",""),O=Vt(this.parse(f));F.length&&(s=F.filter(x=>x.url!==C)),s.push({url:C,options:O}),l&&(u&&clearTimeout(u),u=setTimeout(()=>{Yt(F,s)||(F.length!==0&&(l==null||l.restart(),console.info("Bridge options updated. Restarting...")),F=[...s])},1e3))},async load(f){if(f===i)return`export const bridgeOptions = ${JSON.stringify(Gt(s))}`},configureServer(f){l=f}}}function Yt(o=[],t=[]){return t.every(({url:r,options:i})=>{const s=o.find(l=>(l==null?void 0:l.url)===r);return s&&JSON.stringify(i)===JSON.stringify(s.options)})}const Qt=`<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">
35
- <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
36
- <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
37
- <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
38
- <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
39
- <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
40
- </g>
41
- </g>
42
- </g>
43
- </svg>`;let Se;async function er(o){const{action:t,story:r}=o||{};if(t==="input"&&r){const i=async()=>{const l=await rr(r),u=document.body;if(l.outerHTML===u.outerHTML)return;const f=document.querySelector('[data-blok-focused="true"]');tr(u,l,f)};clearTimeout(Se),Se=setTimeout(i,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function tr(o,t,r){if(r){const i=r.getAttribute("data-blok-uid"),s=t.querySelector(`[data-blok-uid="${i}"]`);s&&(s.setAttribute("data-blok-focused","true"),r.replaceWith(s))}else o.replaceWith(t)}async function rr(o){const r=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(r,"text/html").body}function nr(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function or(o,t={},r={},i){var l;if(!globalThis.storyblokApiInstance)throw new Error("storyblokApiInstance has not been initialized correctly");let s=null;if(i&&i.locals._storyblok_preview_data)s=i.locals._storyblok_preview_data;else{const{data:u}=await((l=globalThis==null?void 0:globalThis.storyblokApiInstance)==null?void 0:l.get(o,t));s=u.story}return s}function ar(o,t){var i;const r=(i=globalThis==null?void 0:globalThis.storyblokApiInstance)==null?void 0:i.richTextResolver;if(!r)throw new Error("Please initialize the Storyblok SDK before calling the renderRichText function");return Ht(o,t,r)}function ir(o){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...o};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:r,updateConfig:i,addDevToolbarApp:s,addMiddleware:l,config:u})=>{if(i({vite:{plugins:[N(t.accessToken,t.useCustomApi,t.apiOptions),ot(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),at(t),Xt(t.livePreview,u.output)]}}),t.livePreview&&(u==null?void 0:u.output)!=="server")throw new Error("To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode.");if(r("page-ssr",`
44
- import { storyblokApiInstance } from "virtual:storyblok-init";
45
- globalThis.storyblokApiInstance = storyblokApiInstance;
46
- `),t.bridge&&!t.livePreview){let f="";if(typeof t.bridge=="object"){const g={...t.bridge};f=`const storyblokInstance = new StoryblokBridge(${JSON.stringify(g)});`}else f="const storyblokInstance = new StoryblokBridge()";r("page",`
47
- import { loadStoryblokBridge } from "@storyblok/astro";
48
- loadStoryblokBridge().then(() => {
49
- const { StoryblokBridge, location } = window;
50
- ${f}
51
-
52
- storyblokInstance.on(["published", "change"], (event) => {
53
- if (!event.slugChanged) {
54
- location.reload(true);
55
- }
43
+ }`),""}optimizeImages(e,t){let o=0,s=0,n="",a="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,o=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(a+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(a+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(a+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(a+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(a+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(a+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(a+=`:rotate(${t.filters.rotate})`),a.length>0&&(a=`/filters${a}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=o>0||s>0||a.length>0?`${o}x${s}${a}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,i=>{var c,d;const f=i.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(f&&f.length>0){const h={srcset:(c=t.srcset)==null?void 0:c.map(g=>{if(typeof g=="number")return`//${f}/m/${g}x0${a} ${g}w`;if(typeof g=="object"&&g.length===2){let w=0,R=0;return typeof g[0]=="number"&&(w=g[0]),typeof g[1]=="number"&&(R=g[1]),`//${f}/m/${w}x${R}${a} ${w}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(g=>g).join(", ")};let k="";return h.srcset&&(k+=`srcset="${h.srcset}" `),h.sizes&&(k+=`sizes="${h.sizes}" `),i.replace(/<img/g,`<img ${k.trim()}`)}return i})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&t.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(me(e.text)):o&&o.singleTag?t.push(this.renderTag(o.singleTag," /")):o&&o.html?t.push(o.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),o&&o.tag&&t.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(o=>{if(o.constructor===String)return`<${o}${t}>`;{let s=`<${o.tag}`;if(o.attrs){for(const n in o.attrs)if(Object.prototype.hasOwnProperty.call(o.attrs,n)){const a=o.attrs[n];a!==null&&(s+=` ${n}="${a}"`)}}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const L=ke,we=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let $e,ve="https://app.storyblok.com/f/storyblok-v2-latest.js";const Ce=(r,e)=>{r.addNode("blok",t=>{let o="";return t.attrs.body.forEach(s=>{o+=e(s.component,s)}),{html:o}})},Se=r=>!r||!(r!=null&&r.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ie=(r,e,t)=>{let o=t||$e;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Se(r)?"":(e&&(o=new L(e.schema),e.resolver&&Ce(o,e.resolver)),o.render(r,{},!1))},Te=()=>U(ve);function Ae(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function Ee(r){let e=null;return r&&r.locals._storyblok_preview_data&&(e=r.locals._storyblok_preview_data),e}function Le(r,e){var o;const t=(o=globalThis==null?void 0:globalThis.storyblokApiInstance)==null?void 0:o.richTextResolver;if(!t)throw new Error("Please initialize the Storyblok SDK before calling the renderRichText function");return Ie(r,e,t)}function xe(r){return typeof r=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});`:"const storyblokInstance = new StoryblokBridge();"}function Re(r){const e={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...r},t=xe(e.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:o,updateConfig:s,addDevToolbarApp:n,addMiddleware:a,config:l})=>{if(s({vite:{plugins:[F(e.accessToken,e.useCustomApi,e.apiOptions),B(e.componentsDir,e.components,e.enableFallbackComponent,e.customFallbackComponent),D(e)]}}),e.livePreview&&(l==null?void 0:l.output)!=="server")throw new Error("To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode.");o("page-ssr",`
44
+ import { storyblokApiInstance } from "virtual:storyblok-init";
45
+ globalThis.storyblokApiInstance = storyblokApiInstance;
46
+ `),e.bridge&&!e.livePreview&&o("page",`
47
+ import { loadStoryblokBridge } from "@storyblok/astro";
48
+ loadStoryblokBridge().then(() => {
49
+ const { StoryblokBridge, location } = window;
50
+ ${t}
51
+ storyblokInstance.on(["published", "change"], (event) => {
52
+ if (!event.slugChanged) {
53
+ location.reload(true);
54
+ }
55
+ });
56
56
  });
57
- });
58
- `)}t.livePreview&&(r("page",`
59
- import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
60
- import { bridgeOptions } from "virtual:storyblok-bridge";
61
- console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
62
- loadStoryblokBridge().then(() => {
63
- const { StoryblokBridge, location } = window;
64
- if(bridgeOptions){
65
- const storyblokInstance = new StoryblokBridge(bridgeOptions);
57
+ `),e.livePreview&&(o("page",`
58
+ import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
59
+ loadStoryblokBridge().then(() => {
60
+ const { StoryblokBridge, location } = window;
61
+ ${t}
66
62
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
67
- };
68
- });
69
- `),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s({id:"storyblok",name:"Storyblok",icon:Qt,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}k.RichTextResolver=Te,k.RichTextSchema=we,k.default=ir,k.handleStoryblokMessage=er,k.loadStoryblokBridge=qt,k.renderRichText=ar,k.storyblokEditable=zt,k.toCamelCase=re,k.useStoryblok=or,k.useStoryblokApi=nr,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
63
+ });
64
+ `),a({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),n({id:"storyblok",name:"Storyblok",icon:b,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let x;async function je(r){const{action:e,story:t}=r||{};if(e==="input"&&t){const o=async()=>{const n=await Pe(t),a=document.body;if(n.outerHTML===a.outerHTML)return;const l=document.querySelector('[data-blok-focused="true"]');Me(a,n,l),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(x),x=setTimeout(o,500)}["published","change"].includes(r==null?void 0:r.action)&&location.reload()}function Me(r,e,t){if(t){const o=t.getAttribute("data-blok-uid"),s=e.querySelector(`[data-blok-uid="${o}"]`);s&&(s.setAttribute("data-blok-focused","true"),t.replaceWith(s))}else r.replaceWith(e)}async function Pe(r){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...r,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}u.RichTextResolver=L,u.RichTextSchema=A,u.getLiveStory=Ee,u.handleStoryblokMessage=je,u.loadStoryblokBridge=Te,u.renderRichText=Le,u.storyblok=Re,u.storyblokEditable=we,u.toCamelCase=m,u.useStoryblokApi=Ae,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/dist/types.d.ts CHANGED
@@ -9,4 +9,4 @@ ISbStoriesParams, // previously StoriesParams
9
9
  ISbStory, // previously Story
10
10
  ISbStoryData, // previously StoryData
11
11
  ISbStoryParams, // previously StoryParams
12
- SbBlokData, SbBlokKeyDataTypes, SbPluginFactory, SbRichTextOptions, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokClient, StoryblokComponentType, } from '@storyblok/js';
12
+ RichTextResolver, SbBlokData, SbBlokKeyDataTypes, SbPluginFactory, SbRichTextOptions, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokClient, StoryblokComponentType, } from '@storyblok/js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "5.1.2",
4
+ "version": "6.0.0-next.1",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@9.13.2",
7
7
  "description": "Official Astro integration for the Storyblok Headless CMS",
@@ -71,9 +71,8 @@
71
71
  "astro": "^3.0.0 || ^4.0.0 || ^5.0.0"
72
72
  },
73
73
  "dependencies": {
74
- "@storyblok/js": "3.1.9",
75
- "camelcase": "^8.0.0",
76
- "lodash.mergewith": "^4.6.2"
74
+ "@storyblok/js": "^3.1.9",
75
+ "camelcase": "^8.0.0"
77
76
  },
78
77
  "devDependencies": {
79
78
  "@commitlint/cli": "^19.5.0",
@@ -81,7 +80,6 @@
81
80
  "@cypress/vite-dev-server": "^5.2.0",
82
81
  "@rollup/plugin-dynamic-import-vars": "^2.1.5",
83
82
  "@storyblok/eslint-config": "^0.3.0",
84
- "@types/lodash.mergewith": "^4.6.9",
85
83
  "@types/node": "22.10.2",
86
84
  "astro": "^5.0.9",
87
85
  "cypress": "^13.15.2",
@@ -1,3 +0,0 @@
1
- import { StoryblokBridgeConfigV2 } from '@storyblok/js';
2
- import { RawCode } from '../vite-plugins/vite-plugin-storyblok-bridge';
3
- export declare function generateFinalBridgeObject(rawCode: RawCode): StoryblokBridgeConfigV2;
@@ -1,7 +0,0 @@
1
- import { RawCodeItemOptions } from '../vite-plugins/vite-plugin-storyblok-bridge';
2
- import { Rollup } from 'vite';
3
- /**
4
- * Parses through the Abstract Syntax Tree (AST) code to locate the 'useStoryblok' function and its properties.
5
- * This functionality is crucial for generating a virtual module that can be utilized during the initialization of the Storyblok bridge.
6
- */
7
- export declare function parseAstRawCode(astCode: Rollup.ProgramNode): RawCodeItemOptions;
@@ -1,12 +0,0 @@
1
- import { ISbStoriesParams, StoryblokBridgeConfigV2 } from '@storyblok/js';
2
- import { Plugin } from 'vite';
3
- export interface RawCodeItem {
4
- url: string;
5
- options?: RawCodeItemOptions;
6
- }
7
- export type RawCode = RawCodeItem[];
8
- export interface RawCodeItemOptions {
9
- apiOptions?: ISbStoriesParams;
10
- bridgeOptions?: StoryblokBridgeConfigV2;
11
- }
12
- export declare function vitePluginStoryblokBridge(experimentalLivePreview: boolean, output: string): Plugin;