@storyblok/astro 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  <div align="center">
2
2
  <a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro" align="center">
3
- <img src="https://a.storyblok.com/f/88751/600x200/cc68aca8ea/storyblok-astro.jpg" width="300" height="100" alt="Storyblok + Astro">
3
+ <img src="https://a.storyblok.com/f/88751/1500x500/7974d6bc34/storyblok-astro.png" width="300" height="100" alt="Storyblok + Astro">
4
4
  </a>
5
5
  <h1 align="center">@storyblok/astro</h1>
6
- <p align="center">Astro module for the <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro" target="_blank">Storyblok</a>, Headless CMS.</p> <br />
6
+ <p align="center">Astro module for the <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro" target="_blank">Storyblok</a> Headless CMS.</p> <br />
7
7
  </div>
8
8
 
9
9
  <p align="center">
@@ -61,7 +61,7 @@ export default defineConfig({
61
61
 
62
62
  ### Options
63
63
 
64
- When you initialize the module, you can pass all [_@storyblok/js_ options](https://github.com/storyblok/storyblok-js#features-and-api)
64
+ When you initialize the module, you can pass all [_@storyblok/js_ options](https://github.com/storyblok/storyblok-js#features-and-api). For Spaces created in the United States, you have to set the `region` parameter accordingly `{ apiOptions: { region: 'us' } }`.
65
65
 
66
66
  ```js
67
67
  // Defaults
@@ -125,7 +125,7 @@ const { blok } = Astro.props
125
125
  ---
126
126
 
127
127
  <main {...storyblokEditable(blok)}>
128
- {blok.body?.map(blok => {return <StoryblokComponent blok="{blok}" />})}
128
+ {blok.body?.map(blok => {return <StoryblokComponent blok={blok} />})}
129
129
  </main>
130
130
  ```
131
131
 
@@ -160,7 +160,7 @@ const { data } = await storyblokApi.get("cdn/stories/home", {
160
160
  const story = data.story;
161
161
  ---
162
162
 
163
- <StoryblokComponent blok="{story.content}" />
163
+ <StoryblokComponent blok={story.content} />
164
164
  ```
165
165
 
166
166
  > Note: The available methods are described in the [storyblok-js-client] repository(https://github.com/storyblok/storyblok-js-client#method-storyblokget)
@@ -174,9 +174,9 @@ In order to dynamically generate Astro pages based on the Stories in your Storyb
174
174
  import { useStoryblokApi } from "@storyblok/astro";
175
175
  import StoryblokComponent from "@storyblok/astro/StoryblokComponent.astro";
176
176
 
177
- const storyblokApi = useStoryblokApi();
178
-
179
177
  export async function getStaticPaths() {
178
+ const storyblokApi = useStoryblokApi();
179
+
180
180
  const { data } = await storyblokApi.get("cdn/links", {
181
181
  version: "draft",
182
182
  });
@@ -192,6 +192,8 @@ export async function getStaticPaths() {
192
192
 
193
193
  const { slug } = Astro.params;
194
194
 
195
+ const storyblokApi = useStoryblokApi();
196
+
195
197
  const { data } = await storyblokApi.get(`cdn/stories/${slug}`, {
196
198
  version: "draft",
197
199
  });
@@ -199,7 +201,7 @@ const { data } = await storyblokApi.get(`cdn/stories/${slug}`, {
199
201
  const story = data.story;
200
202
  ---
201
203
 
202
- <StoryblokComponent blok="{story.content}" />
204
+ <StoryblokComponent blok={story.content} />
203
205
  ```
204
206
 
205
207
  ### Using the Storyblok Bridge
@@ -221,7 +223,33 @@ const { blok } = Astro.props
221
223
  const renderedRichText = renderRichText(blok.text)
222
224
  ---
223
225
 
224
- <div set:html="{renderedRichText}"></div>
226
+ <div set:html={renderedRichText}></div>
227
+ ```
228
+
229
+ You can also set a **custom Schema and component resolver** by passing the options as the second parameter of the `renderRichText` function:
230
+
231
+ ```js
232
+ import { RichTextSchema, renderRichText } from "@storyblok/astro";
233
+ import cloneDeep from "clone-deep";
234
+
235
+ const mySchema = cloneDeep(RichTextSchema); // you can make a copy of the default RichTextSchema
236
+ // ... and edit the nodes and marks, or add your own.
237
+ // Check the base RichTextSchema source here https://github.com/storyblok/storyblok-js-client/blob/master/source/schema.js
238
+
239
+ const { blok } = Astro.props
240
+
241
+ const renderedRichText = renderRichText(blok.text, {
242
+ schema: mySchema,
243
+ resolver: (component, blok) => {
244
+ switch (component) {
245
+ case "my-custom-component":
246
+ return `<div class="my-component-class">${blok.text}</div>`;
247
+ break;
248
+ default:
249
+ return `Component ${component} not found`;
250
+ }
251
+ },
252
+ });
225
253
  ```
226
254
 
227
255
  ## API
@@ -1,8 +1,8 @@
1
1
  ---
2
- import components from 'virtual:storyblok-components';
3
- const { blok } = Astro.props;
2
+ import components from "virtual:storyblok-components";
3
+ const { blok, ...props } = Astro.props;
4
4
 
5
- const Component = components[blok.component];
5
+ const Component = components[blok.component];
6
6
  ---
7
7
 
8
- {<Component blok={blok} />}
8
+ <Component blok={blok} {...props} />
@@ -1,10 +1,10 @@
1
- (function(h,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h.storyblokAstro={},h.axios))})(this,function(h,g){"use strict";const E=(n=>n&&typeof n=="object"&&"default"in n?n:{default:n})(g);function j(n){const t="virtual:storyblok-components",e="\0"+t;return{name:"vite-plugin-storyblok",async resolveId(r){if(r===t)return e},async load(r){if(r===e){const s=[];for await(const[o,i]of Object.entries(n)){const{id:a}=await this.resolve("/src/"+i+".astro");s.push(`import ${o} from "${a}"`)}return`${s.join(";")};export default {${Object.keys(n).join(",")}}`}}}}var S=Object.defineProperty,A=Object.defineProperties,P=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,v=(n,t,e)=>t in n?S(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,d=(n,t)=>{for(var e in t||(t={}))x.call(t,e)&&v(n,e,t[e]);if(b)for(var e of b(t))M.call(t,e)&&v(n,e,t[e]);return n},k=(n,t)=>A(n,P(t));let T=!1;const _=[],w=n=>new Promise((t,e)=>{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}T?s():_.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>e(s),r.onload=s=>{_.forEach(o=>o()),T=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(r)}),C=function(n,t){if(!n)return null;let e={};for(let r in n){let s=n[r];t.indexOf(r)>-1&&s!==null&&(e[r]=s)}return e},I=n=>n==="email";var N={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(n){return{tag:["pre",{tag:"code",attrs:n.attrs}]}},hard_break(){return{singleTag:"br"}},heading(n){return{tag:`h${n.attrs.level}`}},image(n){return{singleTag:[{tag:"img",attrs:C(n.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(n){const t=d({},n.attrs),{linktype:e="url"}=n.attrs;return I(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled(n){return{tag:[{tag:"span",attrs:n.attrs}]}}}};const q=function(n){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,r=RegExp(e.source);return n&&r.test(n)?n.replace(e,s=>t[s]):n};class L{constructor(t){t||(t=N),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(r=>{e+=this.renderNode(r)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(t);return r&&r.tag&&e.push(this.renderOpeningTag(r.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(q(t.text)):r&&r.singleTag?e.push(this.renderTag(r.singleTag," /")):r&&r.html&&e.push(r.html),r&&r.tag&&e.push(this.renderClosingTag(r.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let o=`<${s.tag}`;if(s.attrs)for(let i in s.attrs){let a=s.attrs[i];a!==null&&(o+=` ${i}="${a}"`)}return`${o}${e}>`}}).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){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}/*!
1
+ (function(h,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h.storyblokAstro={},h.axios))})(this,function(h,g){"use strict";const A=(n=>n&&typeof n=="object"&&"default"in n?n:{default:n})(g);function P(n){const e="virtual:storyblok-components",t="\0"+e;return{name:"vite-plugin-storyblok",async resolveId(r){if(r===e)return t},async load(r){if(r===t){const s=[];for await(const[o,a]of Object.entries(n)){const{id:i}=await this.resolve("/src/"+a+".astro");s.push(`import ${o} from "${i}"`)}return`${s.join(";")};export default {${Object.keys(n).join(",")}}`}}}}var M=Object.defineProperty,I=Object.defineProperties,C=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,T=(n,e,t)=>e in n?M(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))N.call(e,t)&&T(n,t,e[t]);if(v)for(var t of v(e))q.call(e,t)&&T(n,t,e[t]);return n},k=(n,e)=>I(n,C(e));let _=!1;const w=[],R=n=>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}_?s():w.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{w.forEach(o=>o()),_=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)}),L=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t},B=n=>n==="email";var $={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(n){return{tag:["pre",{tag:"code",attrs:n.attrs}]}},hard_break(){return{singleTag:"br"}},heading(n){return{tag:`h${n.attrs.level}`}},image(n){return{singleTag:[{tag:"img",attrs:L(n.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(n){const e=d({},n.attrs),{linktype:t="url"}=n.attrs;return B(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled(n){return{tag:[{tag:"span",attrs:n.attrs}]}}}};const z=function(n){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=RegExp(t.source);return n&&r.test(n)?n.replace(t,s=>e[s]):n};class O{constructor(e){e||(e=$),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(z(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let o=`<${s.tag}`;if(s.attrs)for(let a in s.attrs){let i=s.attrs[a];i!==null&&(o+=` ${a}="${i}"`)}return`${o}${t}>`}}).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){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}/*!
2
2
  * storyblok-js-client v4.5.2
3
3
  * Universal JavaScript SDK for Storyblok's API
4
4
  * (c) 2020-2022 Stobylok Team
5
- */function $(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function R(n,t,e){if(!$(t))throw new TypeError("Expected `limit` to be a finite number");if(!$(e))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],o=0,i=function(){o++;var c=setTimeout(function(){o--,r.length>0&&i(),s=s.filter(function(u){return u!==c})},e);s.indexOf(c)<0&&s.push(c);var l=r.shift();l.resolve(n.apply(l.self,l.args))},a=function(){var c=arguments,l=this;return new Promise(function(u,f){r.push({resolve:u,reject:f,args:c,self:l}),o<t&&i()})};return a.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},a}R.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const B=function(n,t){if(!n)return null;let e={};for(let r in n){let s=n[r];t.indexOf(r)>-1&&s!==null&&(e[r]=s)}return e};var z={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:n=>({tag:`h${n.attrs.level}`}),image:n=>({singleTag:[{tag:"img",attrs:B(n.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const t=d({},n.attrs),{linktype:e="url"}=n.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class U{constructor(t){t||(t=z),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(r=>{e+=this.renderNode(r)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(t);return r&&r.tag&&e.push(this.renderOpeningTag(r.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i=/[&<>"']/g,a=RegExp(i.source);return s&&a.test(s)?s.replace(i,c=>o[c]):s}(t.text)):r&&r.singleTag?e.push(this.renderTag(r.singleTag," /")):r&&r.html&&e.push(r.html),r&&r.tag&&e.push(this.renderClosingTag(r.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(r=>{if(r.constructor===String)return`<${r}${e}>`;{let s=`<${r.tag}`;if(r.attrs)for(let o in r.attrs){let i=r.attrs[o];i!==null&&(s+=` ${o}="${i}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const H=(n=0,t=n)=>{const e=Math.abs(t-n)||0,r=n<t?1:-1;return((s=0,o)=>[...Array(s)].map(o))(e,(s,o)=>o*r+n)},m=(n,t,e)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],i=e?"":encodeURIComponent(s);let a;a=typeof o=="object"?m(o,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(o)):(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(o),r.push(a)}return r.join("&")};let y={},p={};class V{constructor(t,e){if(!e){let o=t.region?`-${t.region}`:"",i=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${i}://api${o}.storyblok.com/v2`:`${i}://api${o}.storyblok.com/v1`}let r=Object.assign({},t.headers),s=5;t.oauthToken!==void 0&&(r.Authorization=t.oauthToken,s=3),t.rateLimit!==void 0&&(s=t.rateLimit),this.richTextResolver=new U(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=R(this.throttledRequest,s,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=E.default.create({baseURL:e,timeout:t.timeout||0,headers:r,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(o=>t.responseInterceptor(o)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let r="";return e.attrs.body.forEach(s=>{r+=t(s.component,s)}),{html:r}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=p[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((r="")=>r.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,r,s){const o=this.factoryParamOptions(t,((i={},a=25,c=1)=>k(d({},i),{per_page:a,page:c}))(e,r,s));return this.cacheResponse(t,o)}get(t,e){let r=`/${t}`;const s=this.factoryParamOptions(r,e);return this.cacheResponse(r,s)}async getAll(t,e={},r){const s=e.per_page||25,o=`/${t}`,i=o.split("/");r=r||i[i.length-1];const a=await this.makeRequest(o,e,s,1),c=Math.ceil(a.total/s);return((l=[],u)=>l.map(u).reduce((f,Z)=>[...f,...Z],[]))([a,...await(async(l=[],u)=>Promise.all(l.map(u)))(H(1,c),async l=>this.makeRequest(o,e,s,l+1))],l=>Object.values(l.data[r]))}post(t,e){let r=`/${t}`;return this.throttle("post",r,e)}put(t,e){let r=`/${t}`;return this.throttle("put",r,e)}delete(t,e){let r=`/${t}`;return this.throttle("delete",r,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const r=t[e];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(t,e,r){if(r.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let s=[];t[e].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),t[e]=s}}}_insertAssetsRelations(t,e){e.forEach(r=>{t.id===r.id&&(t.original=r,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let r=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)r(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,e),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,e),r(s[o])}}};r(t.content)}async resolveLinks(t,e){let r=[];if(t.link_uuids){const s=t.link_uuids.length;let o=[];const i=50;for(let a=0;a<s;a+=i){const c=Math.min(s,a+i);o.push(t.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.links;r.forEach(s=>{this.links[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveRelations(t,e){let r=[];if(t.rel_uuids){const s=t.rel_uuids.length;let o=[];const i=50;for(let a=0;a<s;a+=i){const c=Math.min(s,a+i);o.push(t.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.rels;r.forEach(s=>{this.relations[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveStories(t,e){let r=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(r=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],r);t.story?this.iterateTree(t.story,r):t.stories.forEach(s=>{this.iterateTree(s,r)})}resolveAssetsRelations(t){const{assets:e,stories:r,story:s}=t;if(r)for(const o of r)this.iterateTree(o,e);else{if(!s)return t;this.iterateTree(s,e)}}cacheResponse(t,e,r){return r===void 0&&(r=0),new Promise(async(s,o)=>{let i=m({url:t,params:e}),a=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const l=await a.get(i);if(l)return s(l)}try{let l=await this.throttle("get",t,{params:e,paramsSerializer:f=>m(f)}),u={data:l.data,headers:l.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return o(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&a.set(i,u),u.data.cv&&(e.version=="draft"&&p[e.token]!=u.data.cv&&this.flushCache(),p[e.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(t,e,r).then(s).catch(o);o(l)}var c})}throttledRequest(t,e,r){return this.client[t](e,r)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(t){this.accessToken&&(p[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>y[t],getAll:()=>y,set(t,e){y[t]=e},flush(){y={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const D=(n={})=>{const{apiOptions:t}=n;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new V(t)}};var J=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};const t=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};const F=new L,O="https://app.storyblok.com/f/storyblok-v2-latest.js",Y=(n={})=>{const{bridge:t,accessToken:e,use:r=[],apiOptions:s={}}=n;s.accessToken=s.accessToken||e;const o={bridge:t,apiOptions:s};let i={};return r.forEach(a=>{i=d(d({},i),a(o))}),t!==!1&&w(O),i},G=n=>n===""?"":n?F.render(n):(console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
5
+ */function E(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function S(n,e,t){if(!E(e))throw new TypeError("Expected `limit` to be a finite number");if(!E(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],o=0,a=function(){o++;var c=setTimeout(function(){o--,r.length>0&&a(),s=s.filter(function(u){return u!==c})},t);s.indexOf(c)<0&&s.push(c);var l=r.shift();l.resolve(n.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,f){r.push({resolve:u,reject:f,args:c,self:l}),o<e&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}S.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const D=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t};var U={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:n=>({tag:`h${n.attrs.level}`}),image:n=>({singleTag:[{tag:"img",attrs:D(n.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const e=d({},n.attrs),{linktype:t="url"}=n.attrs;return t==="email"&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class H{constructor(e){e||(e=U),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,c=>o[c]):s}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs)for(let o in r.attrs){let a=r.attrs[o];a!==null&&(s+=` ${o}="${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){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const V=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return((s=0,o)=>[...Array(s)].map(o))(t,(s,o)=>o*r+n)},m=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],a=t?"":encodeURIComponent(s);let i;i=typeof o=="object"?m(o,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),r.push(i)}return r.join("&")};let y={},p={};class J{constructor(e,t){if(!t){let o=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let r=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new H(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=S(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=A.default.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(o=>e.responseInterceptor(o)),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=p[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const o=this.factoryParamOptions(e,((a={},i=25,c=1)=>k(d({},a),{per_page:i,page:c}))(t,r,s));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const s=this.factoryParamOptions(r,t);return this.cacheResponse(r,s)}async getAll(e,t={},r){const s=t.per_page||25,o=`/${e}`,a=o.split("/");r=r||a[a.length-1];const i=await this.makeRequest(o,t,s,1),c=Math.ceil(i.total/s);return((l=[],u)=>l.map(u).reduce((f,te)=>[...f,...te],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(V(1,c),async l=>this.makeRequest(o,t,s,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let s=[];e[t].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),e[t]=s}}}_insertAssetsRelations(e,t){t.forEach(r=>{e.id===r.id&&(e.original=r,e.original.filename=e.filename,e.original.filename=e.original.filename.includes("https://s3.amazonaws.com/")?e.original.filename:e.original.filename.replace("https://","https://s3.amazonaws.com/"),delete e.original.s3_filename)})}iterateTree(e,t){let r=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)r(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,t),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,t),r(s[o])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const s=e.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.link_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(s=>{this.links[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const s=e.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.rel_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(s=>{this.relations[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];if(t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(e.rels||e.rel_uuids)&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&(e.links||e.link_uuids)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(s=>{this.iterateTree(s,r)})}resolveAssetsRelations(e){const{assets:t,stories:r,story:s}=e;if(r)for(const o of r)this.iterateTree(o,t);else{if(!s)return e;this.iterateTree(s,t)}}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(s,o)=>{let a=m({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(a);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:f=>m(f)}),u={data:l.data,headers:l.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return o(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(t.version=="draft"&&p[t.token]!=u.data.cv&&this.flushCache(),p[t.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,t,r).then(s).catch(o);o(l)}var c})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(e){this.accessToken&&(p[this.accessToken]=e)}cacheProvider(){return this.cache.type==="memory"?{get:e=>y[e],getAll:()=>y,set(e,t){y[e]=t},flush(){y={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const F=(n={})=>{const{apiOptions:e}=n;if(!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new J(e)}};var K=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let b;const j="https://app.storyblok.com/f/storyblok-v2-latest.js",Y=(n={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:s={},richText:o={}}=n;s.accessToken=s.accessToken||t;const a={bridge:e,apiOptions:s};let i={};return r.forEach(c=>{i=d(d({},i),c(a))}),e!==!1&&R(j),b=new O(o.schema),o.resolver&&x(b,o.resolver),i},x=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},G=(n,e,t)=>{let r=t||b;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return n===""?"":n?(e&&(r=new O(e.schema),e.resolver&&x(r,e.resolver)),r.render(n)):(console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
6
6
 
7
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),""),K=()=>w(O);function Q(n,t,e){const{storyblokApi:r}=Y({accessToken:n,use:t||[D],apiOptions:{...e}});globalThis.storyblokApiInstance=r}function W(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function X(n){return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:e})=>{e({vite:{plugins:[j(n.components)]}}),Q(n.accessToken,n.use,n.apiOptions),(n.bridge||!0)&&t("page",`
7
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},Q=()=>R(j);function W(n,e,t){const{storyblokApi:r}=Y({accessToken:n,use:e||[F],apiOptions:{...t}});globalThis.storyblokApiInstance=r}function X(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function Z(n,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return G(n,e,t)}function ee(n){return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:e,updateConfig:t})=>{var s;t({vite:{plugins:[P(n.components)]}}),W(n.accessToken,n.use,n.apiOptions),((s=n.bridge)!=null?s:!0)&&e("page",`
8
8
  import { loadStoryblokBridge } from "@storyblok/astro";
9
9
  loadStoryblokBridge().then(() => {
10
10
  const { StoryblokBridge, location } = window;
@@ -16,4 +16,4 @@
16
16
  }
17
17
  });
18
18
  });
19
- `)}}}}h.default=X,h.loadStoryblokBridge=K,h.renderRichText=G,h.storyblokEditable=J,h.useStoryblokApi=W,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
19
+ `)}}}}h.RichTextSchema=$,h.default=ee,h.loadStoryblokBridge=Q,h.renderRichText=Z,h.storyblokEditable=K,h.useStoryblokApi=X,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,5 +1,5 @@
1
- import O from "axios";
2
- function E(n) {
1
+ import S from "axios";
2
+ function j(n) {
3
3
  const t = "virtual:storyblok-components", e = "\0" + t;
4
4
  return {
5
5
  name: "vite-plugin-storyblok",
@@ -10,38 +10,38 @@ function E(n) {
10
10
  async load(r) {
11
11
  if (r === e) {
12
12
  const s = [];
13
- for await (const [o, i] of Object.entries(n)) {
14
- const { id: a } = await this.resolve("/src/" + i + ".astro");
15
- s.push(`import ${o} from "${a}"`);
13
+ for await (const [o, a] of Object.entries(n)) {
14
+ const { id: i } = await this.resolve("/src/" + a + ".astro");
15
+ s.push(`import ${o} from "${i}"`);
16
16
  }
17
17
  return `${s.join(";")};export default {${Object.keys(n).join(",")}}`;
18
18
  }
19
19
  }
20
20
  };
21
21
  }
22
- var j = Object.defineProperty, S = Object.defineProperties, A = Object.getOwnPropertyDescriptors, k = Object.getOwnPropertySymbols, P = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable, m = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, u = (n, t) => {
22
+ var A = Object.defineProperty, P = Object.defineProperties, M = Object.getOwnPropertyDescriptors, k = Object.getOwnPropertySymbols, I = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? A(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, u = (n, t) => {
23
23
  for (var e in t || (t = {}))
24
- P.call(t, e) && m(n, e, t[e]);
24
+ I.call(t, e) && b(n, e, t[e]);
25
25
  if (k)
26
26
  for (var e of k(t))
27
- x.call(t, e) && m(n, e, t[e]);
27
+ C.call(t, e) && b(n, e, t[e]);
28
28
  return n;
29
- }, f = (n, t) => S(n, A(t));
30
- let b = !1;
31
- const v = [], _ = (n) => new Promise((t, e) => {
29
+ }, f = (n, t) => P(n, M(t));
30
+ let v = !1;
31
+ const T = [], w = (n) => new Promise((t, e) => {
32
32
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
33
33
  if (window.location === window.parent.location) {
34
34
  console.warn("You are not in Draft Mode or in the Visual Editor.");
35
35
  return;
36
36
  }
37
- b ? s() : v.push(s);
37
+ v ? s() : T.push(s);
38
38
  }, document.getElementById("storyblok-javascript-bridge")))
39
39
  return;
40
40
  const r = document.createElement("script");
41
41
  r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
42
- v.forEach((o) => o()), b = !0, t(s);
42
+ T.forEach((o) => o()), v = !0, t(s);
43
43
  }, document.getElementsByTagName("head")[0].appendChild(r);
44
- }), M = function(n, t) {
44
+ }), N = function(n, t) {
45
45
  if (!n)
46
46
  return null;
47
47
  let e = {};
@@ -50,8 +50,8 @@ const v = [], _ = (n) => new Promise((t, e) => {
50
50
  t.indexOf(r) > -1 && s !== null && (e[r] = s);
51
51
  }
52
52
  return e;
53
- }, C = (n) => n === "email";
54
- var I = {
53
+ }, q = (n) => n === "email";
54
+ var z = {
55
55
  nodes: {
56
56
  horizontal_rule() {
57
57
  return {
@@ -94,7 +94,7 @@ var I = {
94
94
  singleTag: [
95
95
  {
96
96
  tag: "img",
97
- attrs: M(n.attrs, ["src", "alt", "title"])
97
+ attrs: N(n.attrs, ["src", "alt", "title"])
98
98
  }
99
99
  ]
100
100
  };
@@ -148,7 +148,7 @@ var I = {
148
148
  },
149
149
  link(n) {
150
150
  const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
151
- return C(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
151
+ return q(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
152
152
  tag: [
153
153
  {
154
154
  tag: "a",
@@ -169,7 +169,7 @@ var I = {
169
169
  }
170
170
  }
171
171
  };
172
- const N = function(n) {
172
+ const B = function(n) {
173
173
  const t = {
174
174
  "&": "&amp;",
175
175
  "<": "&lt;",
@@ -179,9 +179,9 @@ const N = function(n) {
179
179
  }, e = /[&<>"']/g, r = RegExp(e.source);
180
180
  return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
181
181
  };
182
- class q {
182
+ class R {
183
183
  constructor(t) {
184
- t || (t = I), this.marks = t.marks || [], this.nodes = t.nodes || [];
184
+ t || (t = z), this.marks = t.marks || [], this.nodes = t.nodes || [];
185
185
  }
186
186
  addNode(t, e) {
187
187
  this.nodes[t] = e;
@@ -207,7 +207,7 @@ class q {
207
207
  const r = this.getMatchingNode(t);
208
208
  return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
209
209
  e.push(this.renderNode(s));
210
- }) : t.text ? e.push(N(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
210
+ }) : t.text ? e.push(B(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
211
211
  const o = this.getMatchingMark(s);
212
212
  o && e.push(this.renderClosingTag(o.tag));
213
213
  }), e.join("");
@@ -219,9 +219,9 @@ class q {
219
219
  {
220
220
  let o = `<${s.tag}`;
221
221
  if (s.attrs)
222
- for (let i in s.attrs) {
223
- let a = s.attrs[i];
224
- a !== null && (o += ` ${i}="${a}"`);
222
+ for (let a in s.attrs) {
223
+ let i = s.attrs[a];
224
+ i !== null && (o += ` ${a}="${i}"`);
225
225
  }
226
226
  return `${o}${e}>`;
227
227
  }
@@ -247,40 +247,40 @@ class q {
247
247
  * Universal JavaScript SDK for Storyblok's API
248
248
  * (c) 2020-2022 Stobylok Team
249
249
  */
250
- function T(n) {
250
+ function _(n) {
251
251
  return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
252
252
  }
253
- function w(n, t, e) {
254
- if (!T(t))
253
+ function $(n, t, e) {
254
+ if (!_(t))
255
255
  throw new TypeError("Expected `limit` to be a finite number");
256
- if (!T(e))
256
+ if (!_(e))
257
257
  throw new TypeError("Expected `interval` to be a finite number");
258
- var r = [], s = [], o = 0, i = function() {
258
+ var r = [], s = [], o = 0, a = function() {
259
259
  o++;
260
260
  var c = setTimeout(function() {
261
- o--, r.length > 0 && i(), s = s.filter(function(h) {
261
+ o--, r.length > 0 && a(), s = s.filter(function(h) {
262
262
  return h !== c;
263
263
  });
264
264
  }, e);
265
265
  s.indexOf(c) < 0 && s.push(c);
266
266
  var l = r.shift();
267
267
  l.resolve(n.apply(l.self, l.args));
268
- }, a = function() {
268
+ }, i = function() {
269
269
  var c = arguments, l = this;
270
270
  return new Promise(function(h, p) {
271
- r.push({ resolve: h, reject: p, args: c, self: l }), o < t && i();
271
+ r.push({ resolve: h, reject: p, args: c, self: l }), o < t && a();
272
272
  });
273
273
  };
274
- return a.abort = function() {
274
+ return i.abort = function() {
275
275
  s.forEach(clearTimeout), s = [], r.forEach(function(c) {
276
276
  c.reject(new throttle.AbortError());
277
277
  }), r.length = 0;
278
- }, a;
278
+ }, i;
279
279
  }
280
- w.AbortError = function() {
280
+ $.AbortError = function() {
281
281
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
282
282
  };
283
- const B = function(n, t) {
283
+ const L = function(n, t) {
284
284
  if (!n)
285
285
  return null;
286
286
  let e = {};
@@ -290,13 +290,13 @@ const B = function(n, t) {
290
290
  }
291
291
  return e;
292
292
  };
293
- var L = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: B(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
293
+ var U = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: L(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
294
294
  const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
295
295
  return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
296
296
  }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
297
- class z {
297
+ class H {
298
298
  constructor(t) {
299
- t || (t = L), this.marks = t.marks || [], this.nodes = t.nodes || [];
299
+ t || (t = U), this.marks = t.marks || [], this.nodes = t.nodes || [];
300
300
  }
301
301
  addNode(t, e) {
302
302
  this.nodes[t] = e;
@@ -323,8 +323,8 @@ class z {
323
323
  return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
324
324
  e.push(this.renderNode(s));
325
325
  }) : t.text ? e.push(function(s) {
326
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, i = /[&<>"']/g, a = RegExp(i.source);
327
- return s && a.test(s) ? s.replace(i, (c) => o[c]) : s;
326
+ const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
327
+ return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
328
328
  }(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
329
329
  const o = this.getMatchingMark(s);
330
330
  o && e.push(this.renderClosingTag(o.tag));
@@ -338,8 +338,8 @@ class z {
338
338
  let s = `<${r.tag}`;
339
339
  if (r.attrs)
340
340
  for (let o in r.attrs) {
341
- let i = r.attrs[o];
342
- i !== null && (s += ` ${o}="${i}"`);
341
+ let a = r.attrs[o];
342
+ a !== null && (s += ` ${o}="${a}"`);
343
343
  }
344
344
  return `${s}${e}>`;
345
345
  }
@@ -360,7 +360,7 @@ class z {
360
360
  return this.marks[t.type](t);
361
361
  }
362
362
  }
363
- const U = (n = 0, t = n) => {
363
+ const V = (n = 0, t = n) => {
364
364
  const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
365
365
  return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
366
366
  }, y = (n, t, e) => {
@@ -368,21 +368,21 @@ const U = (n = 0, t = n) => {
368
368
  for (const s in n) {
369
369
  if (!Object.prototype.hasOwnProperty.call(n, s))
370
370
  continue;
371
- const o = n[s], i = e ? "" : encodeURIComponent(s);
372
- let a;
373
- a = typeof o == "object" ? y(o, t ? t + encodeURIComponent("[" + i + "]") : i, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(o), r.push(a);
371
+ const o = n[s], a = e ? "" : encodeURIComponent(s);
372
+ let i;
373
+ i = typeof o == "object" ? y(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
374
374
  }
375
375
  return r.join("&");
376
376
  };
377
377
  let g = {}, d = {};
378
- class H {
378
+ class D {
379
379
  constructor(t, e) {
380
380
  if (!e) {
381
- let o = t.region ? `-${t.region}` : "", i = t.https === !1 ? "http" : "https";
382
- e = t.oauthToken === void 0 ? `${i}://api${o}.storyblok.com/v2` : `${i}://api${o}.storyblok.com/v1`;
381
+ let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
382
+ e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
383
383
  }
384
384
  let r = Object.assign({}, t.headers), s = 5;
385
- t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new z(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = w(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = O.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
385
+ t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new H(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = S.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
386
386
  }
387
387
  setComponentResolver(t) {
388
388
  this.richTextResolver.addNode("blok", (e) => {
@@ -399,7 +399,7 @@ class H {
399
399
  return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
400
400
  }
401
401
  makeRequest(t, e, r, s) {
402
- const o = this.factoryParamOptions(t, ((i = {}, a = 25, c = 1) => f(u({}, i), { per_page: a, page: c }))(e, r, s));
402
+ const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => f(u({}, a), { per_page: i, page: c }))(e, r, s));
403
403
  return this.cacheResponse(t, o);
404
404
  }
405
405
  get(t, e) {
@@ -408,10 +408,10 @@ class H {
408
408
  return this.cacheResponse(r, s);
409
409
  }
410
410
  async getAll(t, e = {}, r) {
411
- const s = e.per_page || 25, o = `/${t}`, i = o.split("/");
412
- r = r || i[i.length - 1];
413
- const a = await this.makeRequest(o, e, s, 1), c = Math.ceil(a.total / s);
414
- return ((l = [], h) => l.map(h).reduce((p, R) => [...p, ...R], []))([a, ...await (async (l = [], h) => Promise.all(l.map(h)))(U(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
411
+ const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
412
+ r = r || a[a.length - 1];
413
+ const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
414
+ return ((l = [], h) => l.map(h).reduce((p, x) => [...p, ...x], []))([i, ...await (async (l = [], h) => Promise.all(l.map(h)))(V(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
415
415
  }
416
416
  post(t, e) {
417
417
  let r = `/${t}`;
@@ -482,13 +482,13 @@ class H {
482
482
  if (t.link_uuids) {
483
483
  const s = t.link_uuids.length;
484
484
  let o = [];
485
- const i = 50;
486
- for (let a = 0; a < s; a += i) {
487
- const c = Math.min(s, a + i);
488
- o.push(t.link_uuids.slice(a, c));
485
+ const a = 50;
486
+ for (let i = 0; i < s; i += a) {
487
+ const c = Math.min(s, i + a);
488
+ o.push(t.link_uuids.slice(i, c));
489
489
  }
490
- for (let a = 0; a < o.length; a++)
491
- (await this.getStories({ per_page: i, language: e.language, version: e.version, by_uuids: o[a].join(",") })).data.stories.forEach((c) => {
490
+ for (let i = 0; i < o.length; i++)
491
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
492
492
  r.push(c);
493
493
  });
494
494
  } else
@@ -502,13 +502,13 @@ class H {
502
502
  if (t.rel_uuids) {
503
503
  const s = t.rel_uuids.length;
504
504
  let o = [];
505
- const i = 50;
506
- for (let a = 0; a < s; a += i) {
507
- const c = Math.min(s, a + i);
508
- o.push(t.rel_uuids.slice(a, c));
505
+ const a = 50;
506
+ for (let i = 0; i < s; i += a) {
507
+ const c = Math.min(s, i + a);
508
+ o.push(t.rel_uuids.slice(i, c));
509
509
  }
510
- for (let a = 0; a < o.length; a++)
511
- (await this.getStories({ per_page: i, language: e.language, version: e.version, by_uuids: o[a].join(",") })).data.stories.forEach((c) => {
510
+ for (let i = 0; i < o.length; i++)
511
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
512
512
  r.push(c);
513
513
  });
514
514
  } else
@@ -539,9 +539,9 @@ class H {
539
539
  }
540
540
  cacheResponse(t, e, r) {
541
541
  return r === void 0 && (r = 0), new Promise(async (s, o) => {
542
- let i = y({ url: t, params: e }), a = this.cacheProvider();
542
+ let a = y({ url: t, params: e }), i = this.cacheProvider();
543
543
  if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
544
- const l = await a.get(i);
544
+ const l = await i.get(a);
545
545
  if (l)
546
546
  return s(l);
547
547
  }
@@ -549,7 +549,7 @@ class H {
549
549
  let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => y(p) }), h = { data: l.data, headers: l.headers };
550
550
  if (h.data.assets && h.data.assets.length && this.resolveAssetsRelations(h.data), l.headers["per-page"] && (h = Object.assign({}, h, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
551
551
  return o(l);
552
- (h.data.story || h.data.stories) && await this.resolveStories(h.data, e), e.version === "published" && t != "/cdn/spaces/me" && a.set(i, h), h.data.cv && (e.version == "draft" && d[e.token] != h.data.cv && this.flushCache(), d[e.token] = h.data.cv), s(h);
552
+ (h.data.story || h.data.stories) && await this.resolveStories(h.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, h), h.data.cv && (e.version == "draft" && d[e.token] != h.data.cv && this.flushCache(), d[e.token] = h.data.cv), s(h);
553
553
  } catch (l) {
554
554
  if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
555
555
  return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((h) => setTimeout(h, c))), this.cacheResponse(t, e, r).then(s).catch(o);
@@ -585,15 +585,15 @@ class H {
585
585
  return await this.cacheProvider().flush(), this;
586
586
  }
587
587
  }
588
- const V = (n = {}) => {
588
+ const J = (n = {}) => {
589
589
  const { apiOptions: t } = n;
590
590
  if (!t.accessToken) {
591
591
  console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
592
592
  return;
593
593
  }
594
- return { storyblokApi: new H(t) };
594
+ return { storyblokApi: new D(t) };
595
595
  };
596
- var G = (n) => {
596
+ var Q = (n) => {
597
597
  if (typeof n != "object" || typeof n._editable > "u")
598
598
  return {};
599
599
  const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
@@ -602,38 +602,70 @@ var G = (n) => {
602
602
  "data-blok-uid": t.id + "-" + t.uid
603
603
  };
604
604
  };
605
- const J = new q(), $ = "https://app.storyblok.com/f/storyblok-v2-latest.js", D = (n = {}) => {
606
- const { bridge: t, accessToken: e, use: r = [], apiOptions: s = {} } = n;
605
+ let m;
606
+ const O = "https://app.storyblok.com/f/storyblok-v2-latest.js", F = (n = {}) => {
607
+ const {
608
+ bridge: t,
609
+ accessToken: e,
610
+ use: r = [],
611
+ apiOptions: s = {},
612
+ richText: o = {}
613
+ } = n;
607
614
  s.accessToken = s.accessToken || e;
608
- const o = { bridge: t, apiOptions: s };
615
+ const a = { bridge: t, apiOptions: s };
609
616
  let i = {};
610
- return r.forEach((a) => {
611
- i = u(u({}, i), a(o));
612
- }), t !== !1 && _($), i;
613
- }, K = (n) => n === "" ? "" : n ? J.render(n) : (console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
617
+ return r.forEach((c) => {
618
+ i = u(u({}, i), c(a));
619
+ }), t !== !1 && w(O), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
620
+ }, E = (n, t) => {
621
+ n.addNode("blok", (e) => {
622
+ let r = "";
623
+ return e.attrs.body.forEach((s) => {
624
+ r += t(s.component, s);
625
+ }), {
626
+ html: r
627
+ };
628
+ });
629
+ }, K = (n, t, e) => {
630
+ let r = e || m;
631
+ if (!r) {
632
+ console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
633
+ return;
634
+ }
635
+ return n === "" ? "" : n ? (t && (r = new R(t.schema), t.resolver && E(r, t.resolver)), r.render(n)) : (console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
614
636
 
615
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), ""), Q = () => _($);
616
- function F(n, t, e) {
617
- const { storyblokApi: r } = D({
637
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
638
+ }, W = () => w(O);
639
+ function Y(n, t, e) {
640
+ const { storyblokApi: r } = F({
618
641
  accessToken: n,
619
- use: t || [V],
642
+ use: t || [J],
620
643
  apiOptions: { ...e }
621
644
  });
622
645
  globalThis.storyblokApiInstance = r;
623
646
  }
624
- function W() {
647
+ function X() {
625
648
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
626
649
  }
627
- function X(n) {
650
+ function Z(n, t) {
651
+ const e = globalThis.storyblokApiInstance.richTextResolver;
652
+ if (!e) {
653
+ console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
654
+ return;
655
+ }
656
+ return K(n, t, e);
657
+ }
658
+ function tt(n) {
628
659
  return {
629
660
  name: "@storyblok/astro",
630
661
  hooks: {
631
662
  "astro:config:setup": ({ injectScript: t, updateConfig: e }) => {
663
+ var s;
632
664
  e({
633
665
  vite: {
634
- plugins: [E(n.components)]
666
+ plugins: [j(n.components)]
635
667
  }
636
- }), F(n.accessToken, n.use, n.apiOptions), (n.bridge || !0) && t("page", `
668
+ }), Y(n.accessToken, n.use, n.apiOptions), ((s = n.bridge) != null ? s : !0) && t("page", `
637
669
  import { loadStoryblokBridge } from "@storyblok/astro";
638
670
  loadStoryblokBridge().then(() => {
639
671
  const { StoryblokBridge, location } = window;
@@ -651,9 +683,10 @@ function X(n) {
651
683
  };
652
684
  }
653
685
  export {
654
- X as default,
655
- Q as loadStoryblokBridge,
656
- K as renderRichText,
657
- G as storyblokEditable,
658
- W as useStoryblokApi
686
+ z as RichTextSchema,
687
+ tt as default,
688
+ W as loadStoryblokBridge,
689
+ Z as renderRichText,
690
+ Q as storyblokEditable,
691
+ X as useStoryblokApi
659
692
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "UPDATE DESCRIPTION",
5
5
  "main": "./dist/storyblok-astro.js",
6
6
  "module": "./dist/storyblok-astro.mjs",
@@ -27,38 +27,17 @@
27
27
  "prepublishOnly": "npm run build && cp ../README.md ./"
28
28
  },
29
29
  "dependencies": {
30
- "@storyblok/js": "^1.7.2"
30
+ "@storyblok/js": "^1.8.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "^7.15.0",
34
33
  "@cypress/vite-dev-server": "^2.0.7",
35
- "@rollup/plugin-dynamic-import-vars": "^1.4.3",
36
- "@vue/babel-preset-app": "^4.5.13",
37
- "@vue/test-utils": "next",
34
+ "@rollup/plugin-dynamic-import-vars": "^1.4.4",
38
35
  "axios": "^0.27.2",
39
- "babel-jest": "^26.6.3",
40
36
  "cypress": "^10.6.0",
41
37
  "eslint-plugin-cypress": "^2.12.1",
42
- "eslint-plugin-jest": "^25.2.4",
43
- "jest": "^26.6.3",
44
38
  "start-server-and-test": "^1.14.0",
45
39
  "vite": "^3.0.8"
46
40
  },
47
- "babel": {
48
- "presets": [
49
- "@vue/babel-preset-app"
50
- ]
51
- },
52
- "jest": {
53
- "moduleFileExtensions": [
54
- "js",
55
- "json",
56
- "vue"
57
- ],
58
- "transform": {
59
- "^.+\\.js$": "babel-jest"
60
- }
61
- },
62
41
  "repository": {
63
42
  "type": "git",
64
43
  "url": "https://github.com/storyblok/storyblok-astro"