@storyblok/astro 2.0.10 → 2.0.12

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.
@@ -6,9 +6,9 @@
6
6
  apiOptions: ${JSON.stringify(r)},
7
7
  });
8
8
  export const storyblokApiInstance = storyblokApi;
9
- `}}}const I=/[\p{Lu}]/u,E=/[\p{Ll}]/u,h=/^[\p{Lu}](?![\p{Lu}])/gu,f=/([\p{Alpha}\p{N}_]|$)/u,g=/[_.\- ]+/,S=new RegExp("^"+g.source),p=new RegExp(g.source+f.source,"gu"),b=new RegExp("\\d+"+f.source,"gu"),C=(t,e,r,o)=>{let n=!1,s=!1,c=!1,u=!1;for(let i=0;i<t.length;i++){const l=t[i];u=i>2?t[i-3]==="-":!0,n&&I.test(l)?(t=t.slice(0,i)+"-"+t.slice(i),n=!1,c=s,s=!0,i++):s&&c&&E.test(l)&&(!u||o)?(t=t.slice(0,i-1)+"-"+t.slice(i-1),c=s,s=!1,n=!0):(n=e(l)===l&&r(l)!==l,c=s,s=r(l)===l&&e(l)!==l)}return t},w=(t,e)=>(h.lastIndex=0,t.replace(h,r=>e(r))),R=(t,e)=>(p.lastIndex=0,b.lastIndex=0,t.replace(p,(r,o)=>e(o)).replace(b,r=>e(r)));function y(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(s=>s.trim()).filter(s=>s.length).join("-"):t=t.trim(),t.length===0)return"";const r=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),o=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return t.length===1?g.test(t)?"":e.pascalCase?o(t):r(t):(t!==r(t)&&(t=C(t,r,o,e.preserveConsecutiveUppercase)),t=t.replace(S,""),t=e.preserveConsecutiveUppercase?w(t,r):r(t),e.pascalCase&&(t=o(t.charAt(0))+t.slice(1)),R(t,o))}function $(t){const e="virtual:storyblok-components",r="\0"+e;return{name:"vite-plugin-storyblok-components",async resolveId(o){if(o===e)return r},async load(o){if(o===r){const n=[];for await(const[s,c]of Object.entries(t)){const{id:u}=await this.resolve("/src/"+c+".astro");n.push(`import ${y(s)} from "${u}"`)}return`${n.join(";")};export default {${Object.keys(t).map(s=>y(s)).join(",")}}`}}}}let k=!1;const m=[],x=t=>new Promise((e,r)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=n=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}k?n():m.push(n)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=t,o.id="storyblok-javascript-bridge",o.onerror=n=>r(n),o.onload=n=>{m.forEach(s=>s()),k=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(o)});var N=Object.defineProperty,j=(t,e,r)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e,r)=>(j(t,typeof e!="symbol"?e+"":e,r),r);const L=function(t,e){const r={};for(const o in t){const n=t[o];e.indexOf(o)>-1&&n!==null&&(r[o]=n)}return r},_=t=>t==="email",O=()=>({singleTag:"hr"}),M=()=>({tag:"blockquote"}),P=()=>({tag:"ul"}),U=t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),D=()=>({singleTag:"br"}),B=t=>({tag:`h${t.attrs.level}`}),z=t=>({singleTag:[{tag:"img",attrs:L(t.attrs,["src","alt","title"])}]}),F=()=>({tag:"li"}),q=()=>({tag:"ol"}),J=()=>({tag:"p"}),V=()=>({tag:"b"}),K=()=>({tag:"strike"}),G=()=>({tag:"u"}),Y=()=>({tag:"strong"}),H=()=>({tag:"code"}),Q=()=>({tag:"i"}),W=t=>{const e={...t.attrs},{linktype:r="url"}=t.attrs;return _(r)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},Z=t=>({tag:[{tag:"span",attrs:t.attrs}]}),T={nodes:{horizontal_rule:O,blockquote:M,bullet_list:P,code_block:U,hard_break:D,heading:B,image:z,list_item:F,ordered_list:q,paragraph:J},marks:{bold:V,strike:K,underline:G,strong:Y,code:H,italic:Q,link:W,styled:Z}},X=function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,o=RegExp(r.source);return t&&o.test(t)?t.replace(r,n=>e[n]):t};class A{constructor(e){v(this,"marks"),v(this,"nodes"),e||(e=T),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,r){this.nodes[e]=r}addMark(e,r){this.marks[e]=r}render(e){if(e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(o=>{r+=this.renderNode(o)}),r}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const r=[];e.marks&&e.marks.forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderOpeningTag(s.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&r.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(n=>{r.push(this.renderNode(n))}):e.text?r.push(X(e.text)):o&&o.singleTag?r.push(this.renderTag(o.singleTag," /")):o&&o.html&&r.push(o.html),o&&o.tag&&r.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderClosingTag(s.tag))}),r.join("")}renderTag(e,r){return e.constructor===String?`<${e}${r}>`:e.map(o=>{if(o.constructor===String)return`<${o}${r}>`;{let n=`<${o.tag}`;if(o.attrs)for(const s in o.attrs){const c=o.attrs[s];c!==null&&(n+=` ${s}="${c}"`)}return`${n}${r}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){const r=this.nodes[e.type];if(typeof r=="function")return r(e)}getMatchingMark(e){const r=this.marks[e.type];if(typeof r=="function")return r(e)}}const ee=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let te;const re="https://app.storyblok.com/f/storyblok-v2-latest.js",oe=(t,e)=>{t.addNode("blok",r=>{let o="";return r.attrs.body.forEach(n=>{o+=e(n.component,n)}),{html:o}})},se=(t,e,r)=>{let o=r||te;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return t===""?"":t?(e&&(o=new A(e.schema),e.resolver&&oe(o,e.resolver)),o.render(t)):(console.warn(`${t} is not a valid Richtext object. This might be because the value of the richtext field is empty.
9
+ `}}}const A=/[\p{Lu}]/u,E=/[\p{Ll}]/u,h=/^[\p{Lu}](?![\p{Lu}])/gu,f=/([\p{Alpha}\p{N}_]|$)/u,g=/[_.\- ]+/,w=new RegExp("^"+g.source),p=new RegExp(g.source+f.source,"gu"),b=new RegExp("\\d+"+f.source,"gu"),C=(t,e,r,o)=>{let n=!1,s=!1,i=!1,u=!1;for(let l=0;l<t.length;l++){const c=t[l];u=l>2?t[l-3]==="-":!0,n&&A.test(c)?(t=t.slice(0,l)+"-"+t.slice(l),n=!1,i=s,s=!0,l++):s&&i&&E.test(c)&&(!u||o)?(t=t.slice(0,l-1)+"-"+t.slice(l-1),i=s,s=!1,n=!0):(n=e(c)===c&&r(c)!==c,i=s,s=r(c)===c&&e(c)!==c)}return t},S=(t,e)=>(h.lastIndex=0,t.replace(h,r=>e(r))),$=(t,e)=>(p.lastIndex=0,b.lastIndex=0,t.replace(p,(r,o)=>e(o)).replace(b,r=>e(r)));function y(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(s=>s.trim()).filter(s=>s.length).join("-"):t=t.trim(),t.length===0)return"";const r=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),o=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return t.length===1?g.test(t)?"":e.pascalCase?o(t):r(t):(t!==r(t)&&(t=C(t,r,o,e.preserveConsecutiveUppercase)),t=t.replace(w,""),t=e.preserveConsecutiveUppercase?S(t,r):r(t),e.pascalCase&&(t=o(t.charAt(0))+t.slice(1)),$(t,o))}function R(t){const e="virtual:storyblok-components",r="\0"+e;return{name:"vite-plugin-storyblok-components",async resolveId(o){if(o===e)return r},async load(o){if(o===r){const n=[];for await(const[s,i]of Object.entries(t)){const u=await this.resolve("/src/"+i+".astro");if(!u)throw new Error(`Component could not be found for blok "${s}"! Does "/src/${i}.astro" exist?`);n.push(`import ${y(s)} from "${u.id}"`)}return`${n.join(";")};export default {${Object.keys(t).map(s=>y(s)).join(",")}}`}}}}let k=!1;const m=[],x=t=>new Promise((e,r)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=n=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}k?n():m.push(n)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=t,o.id="storyblok-javascript-bridge",o.onerror=n=>r(n),o.onload=n=>{m.forEach(s=>s()),k=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(o)});var N=Object.defineProperty,j=(t,e,r)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e,r)=>(j(t,typeof e!="symbol"?e+"":e,r),r);const L=function(t,e){const r={};for(const o in t){const n=t[o];e.indexOf(o)>-1&&n!==null&&(r[o]=n)}return r},_=t=>t==="email",O=()=>({singleTag:"hr"}),M=()=>({tag:"blockquote"}),P=()=>({tag:"ul"}),D=t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),U=()=>({singleTag:"br"}),B=t=>({tag:`h${t.attrs.level}`}),z=t=>({singleTag:[{tag:"img",attrs:L(t.attrs,["src","alt","title"])}]}),F=()=>({tag:"li"}),q=()=>({tag:"ol"}),J=()=>({tag:"p"}),V=()=>({tag:"b"}),K=()=>({tag:"strike"}),G=()=>({tag:"u"}),Y=()=>({tag:"strong"}),H=()=>({tag:"code"}),Q=()=>({tag:"i"}),W=t=>{const e={...t.attrs},{linktype:r="url"}=t.attrs;return _(r)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},Z=t=>({tag:[{tag:"span",attrs:t.attrs}]}),T={nodes:{horizontal_rule:O,blockquote:M,bullet_list:P,code_block:D,hard_break:U,heading:B,image:z,list_item:F,ordered_list:q,paragraph:J},marks:{bold:V,strike:K,underline:G,strong:Y,code:H,italic:Q,link:W,styled:Z}},X=function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,o=RegExp(r.source);return t&&o.test(t)?t.replace(r,n=>e[n]):t};class I{constructor(e){v(this,"marks"),v(this,"nodes"),e||(e=T),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,r){this.nodes[e]=r}addMark(e,r){this.marks[e]=r}render(e){if(e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(o=>{r+=this.renderNode(o)}),r}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const r=[];e.marks&&e.marks.forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderOpeningTag(s.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&r.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(n=>{r.push(this.renderNode(n))}):e.text?r.push(X(e.text)):o&&o.singleTag?r.push(this.renderTag(o.singleTag," /")):o&&o.html&&r.push(o.html),o&&o.tag&&r.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderClosingTag(s.tag))}),r.join("")}renderTag(e,r){return e.constructor===String?`<${e}${r}>`:e.map(o=>{if(o.constructor===String)return`<${o}${r}>`;{let n=`<${o.tag}`;if(o.attrs)for(const s in o.attrs){const i=o.attrs[s];i!==null&&(n+=` ${s}="${i}"`)}return`${n}${r}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){const r=this.nodes[e.type];if(typeof r=="function")return r(e)}getMatchingMark(e){const r=this.marks[e.type];if(typeof r=="function")return r(e)}}const ee=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let te;const re="https://app.storyblok.com/f/storyblok-v2-latest.js",oe=(t,e)=>{t.addNode("blok",r=>{let o="";return r.attrs.body.forEach(n=>{o+=e(n.component,n)}),{html:o}})},se=(t,e,r)=>{let o=r||te;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return t===""?"":t?(e&&(o=new I(e.schema),e.resolver&&oe(o,e.resolver)),o.render(t)):(console.warn(`${t} is not a valid Richtext object. This might be because the value of the richtext field is empty.
10
10
 
11
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},ne=()=>x(re);function ae(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function ie(t,e){const r=globalThis.storyblokApiInstance.richTextResolver;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return se(t,e,r)}function le(t){const e={useCustomApi:!1,bridge:!0,...t};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:r,updateConfig:o})=>{o({vite:{plugins:[d(e.accessToken,e.useCustomApi,e.apiOptions),$(e.components)]}}),r("page-ssr",`
11
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},ne=()=>x(re);function ae(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function ie(t,e){const r=globalThis.storyblokApiInstance.richTextResolver;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return se(t,e,r)}function le(t){const e={useCustomApi:!1,bridge:!0,...t};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:r,updateConfig:o})=>{o({vite:{plugins:[d(e.accessToken,e.useCustomApi,e.apiOptions),R(e.components)]}}),r("page-ssr",`
12
12
  import { storyblokApiInstance } from "virtual:storyblok-init";
13
13
  globalThis.storyblokApiInstance = storyblokApiInstance;
14
14
  `),e.bridge&&r("page",`
@@ -23,4 +23,4 @@
23
23
  }
24
24
  });
25
25
  });
26
- `)}}}}a.RichTextResolver=A,a.RichTextSchema=T,a.default=le,a.loadStoryblokBridge=ne,a.renderRichText=ie,a.storyblokEditable=ee,a.useStoryblokApi=ae,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
26
+ `)}}}}a.RichTextResolver=I,a.RichTextSchema=T,a.default=le,a.loadStoryblokBridge=ne,a.renderRichText=ie,a.storyblokEditable=ee,a.useStoryblokApi=ae,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,13 +1,13 @@
1
1
  function m(t, e, r) {
2
- const o = "virtual:storyblok-init", a = "\0" + o;
2
+ const o = "virtual:storyblok-init", n = "\0" + o;
3
3
  return {
4
4
  name: "vite-plugin-storyblok-init",
5
5
  async resolveId(s) {
6
6
  if (s === o)
7
- return a;
7
+ return n;
8
8
  },
9
9
  async load(s) {
10
- if (s === a)
10
+ if (s === n)
11
11
  return `
12
12
  import { storyblokInit, apiPlugin } from "@storyblok/js";
13
13
  const { storyblokApi } = storyblokInit({
@@ -21,13 +21,13 @@ function m(t, e, r) {
21
21
  };
22
22
  }
23
23
  const v = /[\p{Lu}]/u, I = /[\p{Ll}]/u, u = /^[\p{Lu}](?![\p{Lu}])/gu, k = /([\p{Alpha}\p{N}_]|$)/u, d = /[_.\- ]+/, T = new RegExp("^" + d.source), g = new RegExp(d.source + k.source, "gu"), h = new RegExp("\\d+" + k.source, "gu"), A = (t, e, r, o) => {
24
- let a = !1, s = !1, i = !1, c = !1;
25
- for (let n = 0; n < t.length; n++) {
26
- const l = t[n];
27
- c = n > 2 ? t[n - 3] === "-" : !0, a && v.test(l) ? (t = t.slice(0, n) + "-" + t.slice(n), a = !1, i = s, s = !0, n++) : s && i && I.test(l) && (!c || o) ? (t = t.slice(0, n - 1) + "-" + t.slice(n - 1), i = s, s = !1, a = !0) : (a = e(l) === l && r(l) !== l, i = s, s = r(l) === l && e(l) !== l);
24
+ let n = !1, s = !1, a = !1, c = !1;
25
+ for (let l = 0; l < t.length; l++) {
26
+ const i = t[l];
27
+ c = l > 2 ? t[l - 3] === "-" : !0, n && v.test(i) ? (t = t.slice(0, l) + "-" + t.slice(l), n = !1, a = s, s = !0, l++) : s && a && I.test(i) && (!c || o) ? (t = t.slice(0, l - 1) + "-" + t.slice(l - 1), a = s, s = !1, n = !0) : (n = e(i) === i && r(i) !== i, a = s, s = r(i) === i && e(i) !== i);
28
28
  }
29
29
  return t;
30
- }, E = (t, e) => (u.lastIndex = 0, t.replace(u, (r) => e(r))), C = (t, e) => (g.lastIndex = 0, h.lastIndex = 0, t.replace(g, (r, o) => e(o)).replace(h, (r) => e(r)));
30
+ }, E = (t, e) => (u.lastIndex = 0, t.replace(u, (r) => e(r))), w = (t, e) => (g.lastIndex = 0, h.lastIndex = 0, t.replace(g, (r, o) => e(o)).replace(h, (r) => e(r)));
31
31
  function p(t, e) {
32
32
  if (!(typeof t == "string" || Array.isArray(t)))
33
33
  throw new TypeError("Expected the input to be `string | string[]`");
@@ -38,9 +38,9 @@ function p(t, e) {
38
38
  }, Array.isArray(t) ? t = t.map((s) => s.trim()).filter((s) => s.length).join("-") : t = t.trim(), t.length === 0)
39
39
  return "";
40
40
  const r = e.locale === !1 ? (s) => s.toLowerCase() : (s) => s.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (s) => s.toUpperCase() : (s) => s.toLocaleUpperCase(e.locale);
41
- return t.length === 1 ? d.test(t) ? "" : e.pascalCase ? o(t) : r(t) : (t !== r(t) && (t = A(t, r, o, e.preserveConsecutiveUppercase)), t = t.replace(T, ""), t = e.preserveConsecutiveUppercase ? E(t, r) : r(t), e.pascalCase && (t = o(t.charAt(0)) + t.slice(1)), C(t, o));
41
+ return t.length === 1 ? d.test(t) ? "" : e.pascalCase ? o(t) : r(t) : (t !== r(t) && (t = A(t, r, o, e.preserveConsecutiveUppercase)), t = t.replace(T, ""), t = e.preserveConsecutiveUppercase ? E(t, r) : r(t), e.pascalCase && (t = o(t.charAt(0)) + t.slice(1)), w(t, o));
42
42
  }
43
- function w(t) {
43
+ function C(t) {
44
44
  const e = "virtual:storyblok-components", r = "\0" + e;
45
45
  return {
46
46
  name: "vite-plugin-storyblok-components",
@@ -50,37 +50,41 @@ function w(t) {
50
50
  },
51
51
  async load(o) {
52
52
  if (o === r) {
53
- const a = [];
54
- for await (const [s, i] of Object.entries(t)) {
55
- const { id: c } = await this.resolve("/src/" + i + ".astro");
56
- a.push(`import ${p(s)} from "${c}"`);
53
+ const n = [];
54
+ for await (const [s, a] of Object.entries(t)) {
55
+ const c = await this.resolve("/src/" + a + ".astro");
56
+ if (!c)
57
+ throw new Error(
58
+ `Component could not be found for blok "${s}"! Does "/src/${a}.astro" exist?`
59
+ );
60
+ n.push(`import ${p(s)} from "${c.id}"`);
57
61
  }
58
- return `${a.join(";")};export default {${Object.keys(t).map((s) => p(s)).join(",")}}`;
62
+ return `${n.join(";")};export default {${Object.keys(t).map((s) => p(s)).join(",")}}`;
59
63
  }
60
64
  }
61
65
  };
62
66
  }
63
67
  let f = !1;
64
68
  const b = [], S = (t) => new Promise((e, r) => {
65
- if (typeof window > "u" || (window.storyblokRegisterEvent = (a) => {
69
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
66
70
  if (window.location === window.parent.location) {
67
71
  console.warn("You are not in Draft Mode or in the Visual Editor.");
68
72
  return;
69
73
  }
70
- f ? a() : b.push(a);
74
+ f ? n() : b.push(n);
71
75
  }, document.getElementById("storyblok-javascript-bridge")))
72
76
  return;
73
77
  const o = document.createElement("script");
74
- o.async = !0, o.src = t, o.id = "storyblok-javascript-bridge", o.onerror = (a) => r(a), o.onload = (a) => {
75
- b.forEach((s) => s()), f = !0, e(a);
78
+ o.async = !0, o.src = t, o.id = "storyblok-javascript-bridge", o.onerror = (n) => r(n), o.onload = (n) => {
79
+ b.forEach((s) => s()), f = !0, e(n);
76
80
  }, document.getElementsByTagName("head")[0].appendChild(o);
77
81
  });
78
- var $ = Object.defineProperty, R = (t, e, r) => e in t ? $(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, y = (t, e, r) => (R(t, typeof e != "symbol" ? e + "" : e, r), r);
79
- const x = function(t, e) {
82
+ var $ = Object.defineProperty, x = (t, e, r) => e in t ? $(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, y = (t, e, r) => (x(t, typeof e != "symbol" ? e + "" : e, r), r);
83
+ const R = function(t, e) {
80
84
  const r = {};
81
85
  for (const o in t) {
82
- const a = t[o];
83
- e.indexOf(o) > -1 && a !== null && (r[o] = a);
86
+ const n = t[o];
87
+ e.indexOf(o) > -1 && n !== null && (r[o] = n);
84
88
  }
85
89
  return r;
86
90
  }, N = (t) => t === "email", L = () => ({
@@ -101,14 +105,14 @@ const x = function(t, e) {
101
105
  singleTag: "br"
102
106
  }), M = (t) => ({
103
107
  tag: `h${t.attrs.level}`
104
- }), U = (t) => ({
108
+ }), D = (t) => ({
105
109
  singleTag: [
106
110
  {
107
111
  tag: "img",
108
- attrs: x(t.attrs, ["src", "alt", "title"])
112
+ attrs: R(t.attrs, ["src", "alt", "title"])
109
113
  }
110
114
  ]
111
- }), D = () => ({
115
+ }), U = () => ({
112
116
  tag: "li"
113
117
  }), B = () => ({
114
118
  tag: "ol"
@@ -151,8 +155,8 @@ const x = function(t, e) {
151
155
  code_block: _,
152
156
  hard_break: P,
153
157
  heading: M,
154
- image: U,
155
- list_item: D,
158
+ image: D,
159
+ list_item: U,
156
160
  ordered_list: B,
157
161
  paragraph: z
158
162
  },
@@ -174,7 +178,7 @@ const x = function(t, e) {
174
178
  '"': "&quot;",
175
179
  "'": "&#39;"
176
180
  }, r = /[&<>"']/g, o = RegExp(r.source);
177
- return t && o.test(t) ? t.replace(r, (a) => e[a]) : t;
181
+ return t && o.test(t) ? t.replace(r, (n) => e[n]) : t;
178
182
  };
179
183
  class Z {
180
184
  constructor(e) {
@@ -199,15 +203,15 @@ class Z {
199
203
  }
200
204
  renderNode(e) {
201
205
  const r = [];
202
- e.marks && e.marks.forEach((a) => {
203
- const s = this.getMatchingMark(a);
206
+ e.marks && e.marks.forEach((n) => {
207
+ const s = this.getMatchingMark(n);
204
208
  s && r.push(this.renderOpeningTag(s.tag));
205
209
  });
206
210
  const o = this.getMatchingNode(e);
207
- return o && o.tag && r.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((a) => {
208
- r.push(this.renderNode(a));
209
- }) : e.text ? r.push(W(e.text)) : o && o.singleTag ? r.push(this.renderTag(o.singleTag, " /")) : o && o.html && r.push(o.html), o && o.tag && r.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((a) => {
210
- const s = this.getMatchingMark(a);
211
+ return o && o.tag && r.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((n) => {
212
+ r.push(this.renderNode(n));
213
+ }) : e.text ? r.push(W(e.text)) : o && o.singleTag ? r.push(this.renderTag(o.singleTag, " /")) : o && o.html && r.push(o.html), o && o.tag && r.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
214
+ const s = this.getMatchingMark(n);
211
215
  s && r.push(this.renderClosingTag(s.tag));
212
216
  }), r.join("");
213
217
  }
@@ -216,13 +220,13 @@ class Z {
216
220
  if (o.constructor === String)
217
221
  return `<${o}${r}>`;
218
222
  {
219
- let a = `<${o.tag}`;
223
+ let n = `<${o.tag}`;
220
224
  if (o.attrs)
221
225
  for (const s in o.attrs) {
222
- const i = o.attrs[s];
223
- i !== null && (a += ` ${s}="${i}"`);
226
+ const a = o.attrs[s];
227
+ a !== null && (n += ` ${s}="${a}"`);
224
228
  }
225
- return `${a}${r}>`;
229
+ return `${n}${r}>`;
226
230
  }
227
231
  }).join("");
228
232
  }
@@ -258,8 +262,8 @@ let X;
258
262
  const ee = "https://app.storyblok.com/f/storyblok-v2-latest.js", te = (t, e) => {
259
263
  t.addNode("blok", (r) => {
260
264
  let o = "";
261
- return r.attrs.body.forEach((a) => {
262
- o += e(a.component, a);
265
+ return r.attrs.body.forEach((n) => {
266
+ o += e(n.component, n);
263
267
  }), {
264
268
  html: o
265
269
  };
@@ -276,10 +280,10 @@ const ee = "https://app.storyblok.com/f/storyblok-v2-latest.js", te = (t, e) =>
276
280
 
277
281
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
278
282
  }, se = () => S(ee);
279
- function ae() {
283
+ function ne() {
280
284
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
281
285
  }
282
- function ne(t, e) {
286
+ function ae(t, e) {
283
287
  const r = globalThis.storyblokApiInstance.richTextResolver;
284
288
  if (!r) {
285
289
  console.error(
@@ -307,7 +311,7 @@ function le(t) {
307
311
  e.useCustomApi,
308
312
  e.apiOptions
309
313
  ),
310
- w(e.components)
314
+ C(e.components)
311
315
  ]
312
316
  }
313
317
  }), r(
@@ -341,7 +345,7 @@ export {
341
345
  Q as RichTextSchema,
342
346
  le as default,
343
347
  se as loadStoryblokBridge,
344
- ne as renderRichText,
348
+ ae as renderRichText,
345
349
  oe as storyblokEditable,
346
- ae as useStoryblokApi
350
+ ne as useStoryblokApi
347
351
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Official Astro integration for the Storyblok Headless CMS",
5
5
  "main": "./dist/storyblok-astro.js",
6
6
  "module": "./dist/storyblok-astro.mjs",
@@ -34,14 +34,14 @@
34
34
  "devDependencies": {
35
35
  "@cypress/vite-dev-server": "^5.0.4",
36
36
  "@rollup/plugin-dynamic-import-vars": "^2.0.3",
37
- "@types/node": "18.14.2",
38
- "astro": "2.0.15",
37
+ "@types/node": "18.14.6",
38
+ "astro": "2.1.0",
39
39
  "cypress": "^12.7.0",
40
40
  "eslint-plugin-cypress": "^2.12.1",
41
- "start-server-and-test": "^1.15.5",
41
+ "start-server-and-test": "^2.0.0",
42
42
  "typescript": "4.9.5",
43
43
  "vite": "^4.1.4",
44
- "vite-plugin-dts": "^2.0.2"
44
+ "vite-plugin-dts": "^2.1.0"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",