@storyblok/js 1.0.4 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
- var B=Object.defineProperty,L=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var E=(h,d,p)=>d in h?B(h,d,{enumerable:!0,configurable:!0,writable:!0,value:p}):h[d]=p,g=(h,d)=>{for(var p in d||(d={}))D.call(d,p)&&E(h,p,d[p]);if(R)for(var p of R(d))J.call(d,p)&&E(h,p,d[p]);return h},m=(h,d)=>L(h,U(d));(function(h,d){typeof exports=="object"&&typeof module!="undefined"?d(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],d):(h=typeof globalThis!="undefined"?globalThis:h||self,d(h.storyblok={},h.t))})(this,function(h,d){"use strict";function p(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var S=p(d);let v=!1;const w=[],j=n=>new Promise((e,r)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}v?s():w.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const t=document.createElement("script");t.async=!0,t.src=n,t.id="storyblok-javascript-bridge",t.onerror=s=>r(s),t.onload=s=>{w.forEach(o=>o()),v=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(t)});/*!
2
- * storyblok-js-client v0.0.0-development
1
+ var z=Object.defineProperty,U=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(u,d,p)=>d in u?z(u,d,{enumerable:!0,configurable:!0,writable:!0,value:p}):u[d]=p,g=(u,d)=>{for(var p in d||(d={}))J.call(d,p)&&S(u,p,d[p]);if($)for(var p of $(d))V.call(d,p)&&S(u,p,d[p]);return u},k=(u,d)=>U(u,D(d));(function(u,d){typeof exports=="object"&&typeof module!="undefined"?d(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],d):(u=typeof globalThis!="undefined"?globalThis:u||self,d(u.storyblok={},u.e))})(this,function(u,d){"use strict";function p(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var j=p(d);let v=!1;const w=[],T=n=>new Promise((t,s)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}v?r():w.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const e=document.createElement("script");e.async=!0,e.src=n,e.id="storyblok-javascript-bridge",e.onerror=r=>s(r),e.onload=r=>{w.forEach(o=>o()),v=!0,t(r)},document.getElementsByTagName("head")[0].appendChild(e)});/*!
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 T(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function _(n,e,r){if(!T(e))throw new TypeError("Expected `limit` to be a finite number");if(!T(r))throw new TypeError("Expected `interval` to be a finite number");var t=[],s=[],o=0,i=function(){o++;var c=setTimeout(function(){o--,t.length>0&&i(),s=s.filter(function(u){return u!==c})},r);s.indexOf(c)<0&&s.push(c);var l=t.shift();l.resolve(n.apply(l.self,l.args))},a=function(){var c=arguments,l=this;return new Promise(function(u,y){t.push({resolve:u,reject:y,args:c,self:l}),o<e&&i()})};return a.abort=function(){s.forEach(clearTimeout),s=[],t.forEach(function(c){c.reject(new throttle.AbortError)}),t.length=0},a}_.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const O=function(n,e){if(!n)return null;let r={};for(let t in n){let s=n[t];e.indexOf(t)>-1&&s!==null&&(r[t]=s)}return r};var C={nodes:{horizontal_rule:n=>({singleTag:"hr"}),blockquote:n=>({tag:"blockquote"}),bullet_list:n=>({tag:"ul"}),code_block:n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),hard_break:n=>({singleTag:"br"}),heading:n=>({tag:"h"+n.attrs.level}),image:n=>({singleTag:[{tag:"img",attrs:O(n.attrs,["src","alt","title"])}]}),list_item:n=>({tag:"li"}),ordered_list:n=>({tag:"ol"}),paragraph:n=>({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=g({},n.attrs),{linktype:r="url"}=n.attrs;return r==="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 P{constructor(e){e||(e=C),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.content&&Array.isArray(e.content)){let r="";return e.content.forEach(t=>{r+=this.renderNode(t)}),r}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let r=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&r.push(this.renderOpeningTag(o.tag))});const t=this.getMatchingNode(e);return t&&t.tag&&r.push(this.renderOpeningTag(t.tag)),e.content?e.content.forEach(s=>{r.push(this.renderNode(s))}):e.text?r.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}(e.text)):t&&t.singleTag?r.push(this.renderTag(t.singleTag," /")):t&&t.html&&r.push(t.html),t&&t.tag&&r.push(this.renderClosingTag(t.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&r.push(this.renderClosingTag(o.tag))}),r.join("")}renderTag(e,r){return e.constructor===String?`<${e}${r}>`:e.map(t=>{if(t.constructor===String)return`<${t}${r}>`;{let s="<"+t.tag;if(t.attrs)for(let o in t.attrs){let i=t.attrs[o];i!==null&&(s+=` ${o}="${i}"`)}return`${s}${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){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 A=(n=0,e=n)=>{const r=Math.abs(e-n)||0,t=n<e?1:-1;return((s=0,o)=>[...Array(s)].map(o))(r,(s,o)=>o*t+n)},b=(n,e,r)=>{const t=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],i=r?"":encodeURIComponent(s);let a;a=typeof o=="object"?b(o,e?e+encodeURIComponent("["+i+"]"):i,Array.isArray(o)):(e?e+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(o),t.push(a)}return t.join("&")};let k={},f={};class ${constructor(e,r){if(!r){let o=e.region?"-"+e.region:"",i=e.https===!1?"http":"https";r=e.oauthToken===void 0?`${i}://api${o}.storyblok.com/v2`:`${i}://api${o}.storyblok.com/v1`}let t=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(t.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new P(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=_(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=S.default.create({baseURL:r,timeout:e.timeout||0,headers:t,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(o=>e.responseInterceptor(o))}setComponentResolver(e){this.richTextResolver.addNode("blok",r=>{let t="";return r.attrs.body.forEach(s=>{t+=e(s.component,s)}),{html:t}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=f[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,r={}){return((t="")=>t.indexOf("/cdn/")>-1)(e)?this.parseParams(r):r}makeRequest(e,r,t,s){const o=this.factoryParamOptions(e,((i={},a=25,c=1)=>m(g({},i),{per_page:a,page:c}))(r,t,s));return this.cacheResponse(e,o)}get(e,r){let t="/"+e;const s=this.factoryParamOptions(t,r);return this.cacheResponse(t,s)}async getAll(e,r={},t){const s=r.per_page||25,o="/"+e,i=o.split("/");t=t||i[i.length-1];const a=await this.makeRequest(o,r,s,1),c=Math.ceil(a.total/s);return((l=[],u)=>l.map(u).reduce((y,q)=>[...y,...q],[]))([a,...await(async(l=[],u)=>Promise.all(l.map(u)))(A(1,c),async l=>this.makeRequest(o,r,s,l+1))],l=>Object.values(l.data[t]))}post(e,r){let t="/"+e;return this.throttle("post",t,r)}put(e,r){let t="/"+e;return this.throttle("put",t,r)}delete(e,r){let t="/"+e;return this.throttle("delete",t,r)}getStories(e){return this.get("cdn/stories",e)}getStory(e,r){return this.get("cdn/stories/"+e,r)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,r){const t=e[r];t&&t.fieldtype=="multilink"&&t.linktype=="story"&&typeof t.id=="string"&&this.links[t.id]?t.story=this._cleanCopy(this.links[t.id]):t&&t.linktype==="story"&&typeof t.uuid=="string"&&this.links[t.uuid]&&(t.story=this._cleanCopy(this.links[t.uuid]))}_insertRelations(e,r,t){if(t.indexOf(e.component+"."+r)>-1){if(typeof e[r]=="string")this.relations[e[r]]&&(e[r]=this._cleanCopy(this.relations[e[r]]));else if(e[r].constructor===Array){let s=[];e[r].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),e[r]=s}}}iterateTree(e,r){let t=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)t(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,r),this._insertLinks(s,o)),t(s[o])}}};t(e.content)}async resolveLinks(e,r){let t=[];if(e.link_uuids){const s=e.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(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:r.language,version:r.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{t.push(c)})}else t=e.links;t.forEach(s=>{this.links[s.uuid]=m(g({},s),{_stopResolving:!0})})}async resolveRelations(e,r){let t=[];if(e.rel_uuids){const s=e.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(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:r.language,version:r.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{t.push(c)})}else t=e.rels;t.forEach(s=>{this.relations[s.uuid]=m(g({},s),{_stopResolving:!0})})}async resolveStories(e,r){let t=[];r.resolve_relations!==void 0&&r.resolve_relations.length>0&&(t=r.resolve_relations.split(","),await this.resolveRelations(e,r)),["1","story","url"].indexOf(r.resolve_links)>-1&&await this.resolveLinks(e,r);for(const s in this.relations)this.iterateTree(this.relations[s],t);e.story?this.iterateTree(e.story,t):e.stories.forEach(s=>{this.iterateTree(s,t)})}cacheResponse(e,r,t){return t===void 0&&(t=0),new Promise(async(s,o)=>{let i=b({url:e,params:r}),a=this.cacheProvider();if(this.cache.clear==="auto"&&r.version==="draft"&&await this.flushCache(),r.version==="published"&&e!="/cdn/spaces/me"){const l=await a.get(i);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:r,paramsSerializer:y=>b(y)}),u={data:l.data,headers:l.headers};if(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,r),r.version==="published"&&e!="/cdn/spaces/me"&&a.set(i,u),u.data.cv&&(r.version=="draft"&&f[r.token]!=u.data.cv&&this.flushCache(),f[r.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(t+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${t} seconds.`),await(c=1e3*t,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,r,t).then(s).catch(o);o(l)}var c})}throttledRequest(e,r,t){return this.client[e](r,t)}cacheVersions(){return f}cacheVersion(){return f[this.accessToken]}setCacheVersion(e){this.accessToken&&(f[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>k[e],getAll:()=>k,set(e,r){k[e]=r},flush(){k={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var x=(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 $(e)}},M=n=>{if(typeof n!="object"||typeof n._editable=="undefined")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const I=(n,e,r={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],s=>{s.action=="input"&&s.story.id===n?e(s.story):window.location.reload()})})}},N=(n={})=>{const{bridge:e,accessToken:r,use:t=[],apiOptions:s={}}=n;s.accessToken=s.accessToken||r;const o={bridge:e,apiOptions:s};let i={};return t.forEach(a=>{i=g(g({},i),a(o))}),e!==!1&&j("https://app.storyblok.com/f/storyblok-v2-latest.js"),i};h.apiPlugin=x,h.storyblokEditable=M,h.storyblokInit=N,h.useStoryblokBridge=I,Object.defineProperty(h,"__esModule",{value:!0}),h[Symbol.toStringTag]="Module"});
5
+ */function _(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function R(n,t,s){if(!_(t))throw new TypeError("Expected `limit` to be a finite number");if(!_(s))throw new TypeError("Expected `interval` to be a finite number");var e=[],r=[],o=0,i=function(){o++;var c=setTimeout(function(){o--,e.length>0&&i(),r=r.filter(function(h){return h!==c})},s);r.indexOf(c)<0&&r.push(c);var l=e.shift();l.resolve(n.apply(l.self,l.args))},a=function(){var c=arguments,l=this;return new Promise(function(h,y){e.push({resolve:h,reject:y,args:c,self:l}),o<t&&i()})};return a.abort=function(){r.forEach(clearTimeout),r=[],e.forEach(function(c){c.reject(new throttle.AbortError)}),e.length=0},a}R.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const O=function(n,t){if(!n)return null;let s={};for(let e in n){let r=n[e];t.indexOf(e)>-1&&r!==null&&(s[e]=r)}return s};var A={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:O(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=g({},n.attrs),{linktype:s="url"}=n.attrs;return s==="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 P{constructor(t){t||(t=A),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,s){this.nodes[t]=s}addMark(t,s){this.marks[t]=s}render(t={}){if(t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(e=>{s+=this.renderNode(e)}),s}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let s=[];t.marks&&t.marks.forEach(r=>{const o=this.getMatchingMark(r);o&&s.push(this.renderOpeningTag(o.tag))});const e=this.getMatchingNode(t);return e&&e.tag&&s.push(this.renderOpeningTag(e.tag)),t.content?t.content.forEach(r=>{s.push(this.renderNode(r))}):t.text?s.push(function(r){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i=/[&<>"']/g,a=RegExp(i.source);return r&&a.test(r)?r.replace(i,c=>o[c]):r}(t.text)):e&&e.singleTag?s.push(this.renderTag(e.singleTag," /")):e&&e.html&&s.push(e.html),e&&e.tag&&s.push(this.renderClosingTag(e.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const o=this.getMatchingMark(r);o&&s.push(this.renderClosingTag(o.tag))}),s.join("")}renderTag(t,s){return t.constructor===String?`<${t}${s}>`:t.map(e=>{if(e.constructor===String)return`<${e}${s}>`;{let r=`<${e.tag}`;if(e.attrs)for(let o in e.attrs){let i=e.attrs[o];i!==null&&(r+=` ${o}="${i}"`)}return`${r}${s}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(s=>s.constructor===String?`</${s}>`:`</${s.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 C=(n=0,t=n)=>{const s=Math.abs(t-n)||0,e=n<t?1:-1;return((r=0,o)=>[...Array(r)].map(o))(s,(r,o)=>o*e+n)},b=(n,t,s)=>{const e=[];for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r],i=s?"":encodeURIComponent(r);let a;a=typeof o=="object"?b(o,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(o)):(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(o),e.push(a)}return e.join("&")};let m={},f={};class x{constructor(t,s){if(!s){let o=t.region?`-${t.region}`:"",i=t.https===!1?"http":"https";s=t.oauthToken===void 0?`${i}://api${o}.storyblok.com/v2`:`${i}://api${o}.storyblok.com/v1`}let e=Object.assign({},t.headers),r=5;t.oauthToken!==void 0&&(e.Authorization=t.oauthToken,r=3),t.rateLimit!==void 0&&(r=t.rateLimit),this.richTextResolver=new P(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=R(this.throttledRequest,r,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=j.default.create({baseURL:s,timeout:t.timeout||0,headers:e,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",s=>{let e="";return s.attrs.body.forEach(r=>{e+=t(r.component,r)}),{html:e}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=f[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,s={}){return((e="")=>e.indexOf("/cdn/")>-1)(t)?this.parseParams(s):s}makeRequest(t,s,e,r){const o=this.factoryParamOptions(t,((i={},a=25,c=1)=>k(g({},i),{per_page:a,page:c}))(s,e,r));return this.cacheResponse(t,o)}get(t,s){let e=`/${t}`;const r=this.factoryParamOptions(e,s);return this.cacheResponse(e,r)}async getAll(t,s={},e){const r=s.per_page||25,o=`/${t}`,i=o.split("/");e=e||i[i.length-1];const a=await this.makeRequest(o,s,r,1),c=Math.ceil(a.total/r);return((l=[],h)=>l.map(h).reduce((y,L)=>[...y,...L],[]))([a,...await(async(l=[],h)=>Promise.all(l.map(h)))(C(1,c),async l=>this.makeRequest(o,s,r,l+1))],l=>Object.values(l.data[e]))}post(t,s){let e=`/${t}`;return this.throttle("post",e,s)}put(t,s){let e=`/${t}`;return this.throttle("put",e,s)}delete(t,s){let e=`/${t}`;return this.throttle("delete",e,s)}getStories(t){return this.get("cdn/stories",t)}getStory(t,s){return this.get(`cdn/stories/${t}`,s)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,s){const e=t[s];e&&e.fieldtype=="multilink"&&e.linktype=="story"&&typeof e.id=="string"&&this.links[e.id]?e.story=this._cleanCopy(this.links[e.id]):e&&e.linktype==="story"&&typeof e.uuid=="string"&&this.links[e.uuid]&&(e.story=this._cleanCopy(this.links[e.uuid]))}_insertRelations(t,s,e){if(e.indexOf(t.component+"."+s)>-1){if(typeof t[s]=="string")this.relations[t[s]]&&(t[s]=this._cleanCopy(this.relations[t[s]]));else if(t[s].constructor===Array){let r=[];t[s].forEach(o=>{this.relations[o]&&r.push(this._cleanCopy(this.relations[o]))}),t[s]=r}}}_insertAssetsRelations(t,s){s.forEach(e=>{t.id===e.id&&(t.original=e,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,s){let e=r=>{if(r!=null){if(r.constructor===Array)for(let o=0;o<r.length;o++)e(r[o]);else if(r.constructor===Object){if(r._stopResolving)return;for(let o in r)r.component&&r._uid||r.type==="link"?(this._insertRelations(r,o,s),this._insertLinks(r,o)):r.fieldtype==="asset"&&this._insertAssetsRelations(r,s),e(r[o])}}};e(t.content)}async resolveLinks(t,s){let e=[];if(t.link_uuids){const r=t.link_uuids.length;let o=[];const i=50;for(let a=0;a<r;a+=i){const c=Math.min(r,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:s.language,version:s.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{e.push(c)})}else e=t.links;e.forEach(r=>{this.links[r.uuid]=k(g({},r),{_stopResolving:!0})})}async resolveRelations(t,s){let e=[];if(t.rel_uuids){const r=t.rel_uuids.length;let o=[];const i=50;for(let a=0;a<r;a+=i){const c=Math.min(r,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:s.language,version:s.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{e.push(c)})}else e=t.rels;e.forEach(r=>{this.relations[r.uuid]=k(g({},r),{_stopResolving:!0})})}async resolveStories(t,s){let e=[];if(s.resolve_relations!==void 0&&s.resolve_relations.length>0&&(e=s.resolve_relations.split(","),await this.resolveRelations(t,s)),["1","story","url"].indexOf(s.resolve_links)>-1&&await this.resolveLinks(t,s),this.resolveNestedRelations)for(const r in this.relations)this.iterateTree(this.relations[r],e);t.story?this.iterateTree(t.story,e):t.stories.forEach(r=>{this.iterateTree(r,e)})}resolveAssetsRelations(t){const{assets:s,stories:e,story:r}=t;if(e)for(const o of e)this.iterateTree(o,s);else this.iterateTree(r,s)}cacheResponse(t,s,e){return e===void 0&&(e=0),new Promise(async(r,o)=>{let i=b({url:t,params:s}),a=this.cacheProvider();if(this.cache.clear==="auto"&&s.version==="draft"&&await this.flushCache(),s.version==="published"&&t!="/cdn/spaces/me"){const l=await a.get(i);if(l)return r(l)}try{let l=await this.throttle("get",t,{params:s,paramsSerializer:y=>b(y)}),h={data:l.data,headers:l.headers};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)return o(l);(h.data.story||h.data.stories)&&await this.resolveStories(h.data,s),s.version==="published"&&t!="/cdn/spaces/me"&&a.set(i,h),h.data.cv&&(s.version=="draft"&&f[s.token]!=h.data.cv&&this.flushCache(),f[s.token]=h.data.cv),r(h)}catch(l){if(l.response&&l.response.status===429&&(e+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${e} seconds.`),await(c=1e3*e,new Promise(h=>setTimeout(h,c))),this.cacheResponse(t,s,e).then(r).catch(o);o(l)}var c})}throttledRequest(t,s,e){return this.client[t](s,e)}cacheVersions(){return f}cacheVersion(){return f[this.accessToken]}setCacheVersion(t){this.accessToken&&(f[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>m[t],getAll:()=>m,set(t,s){m[t]=s},flush(){m={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}var M=(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 x(t)}},N=n=>{if(typeof n!="object"||typeof n._editable=="undefined")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 E="https://app.storyblok.com/f/storyblok-v2-latest.js",I=(n,t,s={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],r=>{r.action=="input"&&r.story.id===n?t(r.story):window.location.reload()})})}},B=(n={})=>{const{bridge:t,accessToken:s,use:e=[],apiOptions:r={}}=n;r.accessToken=r.accessToken||s;const o={bridge:t,apiOptions:r};let i={};return e.forEach(a=>{i=g(g({},i),a(o))}),t!==!1&&T(E),i},q=()=>T(E);u.apiPlugin=M,u.loadStoryblokBridge=q,u.storyblokEditable=N,u.storyblokInit=B,u.useStoryblokBridge=I,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module"});
@@ -17,7 +17,7 @@ var __spreadValues = (a2, b) => {
17
17
  return a2;
18
18
  };
19
19
  var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
20
- import t from "axios";
20
+ import e from "axios";
21
21
  let loaded = false;
22
22
  const callbacks = [];
23
23
  const loadBridge = (src) => {
@@ -50,313 +50,326 @@ const loadBridge = (src) => {
50
50
  });
51
51
  };
52
52
  /*!
53
- * storyblok-js-client v0.0.0-development
53
+ * storyblok-js-client v4.5.2
54
54
  * Universal JavaScript SDK for Storyblok's API
55
55
  * (c) 2020-2022 Stobylok Team
56
56
  */
57
- function e(t2) {
58
- return typeof t2 == "number" && (t2 == t2 && t2 !== 1 / 0 && t2 !== -1 / 0);
57
+ function t(e2) {
58
+ return typeof e2 == "number" && (e2 == e2 && e2 !== 1 / 0 && e2 !== -1 / 0);
59
59
  }
60
- function r(t2, r2, s2) {
61
- if (!e(r2))
60
+ function s(e2, s2, r2) {
61
+ if (!t(s2))
62
62
  throw new TypeError("Expected `limit` to be a finite number");
63
- if (!e(s2))
63
+ if (!t(r2))
64
64
  throw new TypeError("Expected `interval` to be a finite number");
65
- var n2 = [], i2 = [], o2 = 0, a2 = function() {
65
+ var i2 = [], n2 = [], o2 = 0, a2 = function() {
66
66
  o2++;
67
- var e2 = setTimeout(function() {
68
- o2--, n2.length > 0 && a2(), i2 = i2.filter(function(t3) {
69
- return t3 !== e2;
67
+ var t2 = setTimeout(function() {
68
+ o2--, i2.length > 0 && a2(), n2 = n2.filter(function(e3) {
69
+ return e3 !== t2;
70
70
  });
71
- }, s2);
72
- i2.indexOf(e2) < 0 && i2.push(e2);
73
- var r3 = n2.shift();
74
- r3.resolve(t2.apply(r3.self, r3.args));
71
+ }, r2);
72
+ n2.indexOf(t2) < 0 && n2.push(t2);
73
+ var s3 = i2.shift();
74
+ s3.resolve(e2.apply(s3.self, s3.args));
75
75
  }, l2 = function() {
76
- var t3 = arguments, e2 = this;
77
- return new Promise(function(s3, i3) {
78
- n2.push({ resolve: s3, reject: i3, args: t3, self: e2 }), o2 < r2 && a2();
76
+ var e3 = arguments, t2 = this;
77
+ return new Promise(function(r3, n3) {
78
+ i2.push({ resolve: r3, reject: n3, args: e3, self: t2 }), o2 < s2 && a2();
79
79
  });
80
80
  };
81
81
  return l2.abort = function() {
82
- i2.forEach(clearTimeout), i2 = [], n2.forEach(function(t3) {
83
- t3.reject(new throttle.AbortError());
84
- }), n2.length = 0;
82
+ n2.forEach(clearTimeout), n2 = [], i2.forEach(function(e3) {
83
+ e3.reject(new throttle.AbortError());
84
+ }), i2.length = 0;
85
85
  }, l2;
86
86
  }
87
- r.AbortError = function() {
87
+ s.AbortError = function() {
88
88
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
89
89
  };
90
- const s = function(t2, e2) {
91
- if (!t2)
90
+ const r = function(e2, t2) {
91
+ if (!e2)
92
92
  return null;
93
- let r2 = {};
94
- for (let s2 in t2) {
95
- let n2 = t2[s2];
96
- e2.indexOf(s2) > -1 && n2 !== null && (r2[s2] = n2);
93
+ let s2 = {};
94
+ for (let r2 in e2) {
95
+ let i2 = e2[r2];
96
+ t2.indexOf(r2) > -1 && i2 !== null && (s2[r2] = i2);
97
97
  }
98
- return r2;
98
+ return s2;
99
99
  };
100
- var n = { nodes: { horizontal_rule: (t2) => ({ singleTag: "hr" }), blockquote: (t2) => ({ tag: "blockquote" }), bullet_list: (t2) => ({ tag: "ul" }), code_block: (t2) => ({ tag: ["pre", { tag: "code", attrs: t2.attrs }] }), hard_break: (t2) => ({ singleTag: "br" }), heading: (t2) => ({ tag: "h" + t2.attrs.level }), image: (t2) => ({ singleTag: [{ tag: "img", attrs: s(t2.attrs, ["src", "alt", "title"]) }] }), list_item: (t2) => ({ tag: "li" }), ordered_list: (t2) => ({ tag: "ol" }), paragraph: (t2) => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(t2) {
101
- const e2 = __spreadValues({}, t2.attrs), { linktype: r2 = "url" } = t2.attrs;
102
- return r2 === "email" && (e2.href = "mailto:" + e2.href), e2.anchor && (e2.href = `${e2.href}#${e2.anchor}`, delete e2.anchor), { tag: [{ tag: "a", attrs: e2 }] };
103
- }, styled: (t2) => ({ tag: [{ tag: "span", attrs: t2.attrs }] }) } };
104
- class i {
105
- constructor(t2) {
106
- t2 || (t2 = n), this.marks = t2.marks || [], this.nodes = t2.nodes || [];
107
- }
108
- addNode(t2, e2) {
109
- this.nodes[t2] = e2;
110
- }
111
- addMark(t2, e2) {
112
- this.marks[t2] = e2;
113
- }
114
- render(t2 = {}) {
115
- if (t2.content && Array.isArray(t2.content)) {
116
- let e2 = "";
117
- return t2.content.forEach((t3) => {
118
- e2 += this.renderNode(t3);
119
- }), e2;
100
+ var i = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (e2) => ({ tag: ["pre", { tag: "code", attrs: e2.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (e2) => ({ tag: `h${e2.attrs.level}` }), image: (e2) => ({ singleTag: [{ tag: "img", attrs: r(e2.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(e2) {
101
+ const t2 = __spreadValues({}, e2.attrs), { linktype: s2 = "url" } = e2.attrs;
102
+ return s2 === "email" && (t2.href = `mailto:${t2.href}`), t2.anchor && (t2.href = `${t2.href}#${t2.anchor}`, delete t2.anchor), { tag: [{ tag: "a", attrs: t2 }] };
103
+ }, styled: (e2) => ({ tag: [{ tag: "span", attrs: e2.attrs }] }) } };
104
+ class n {
105
+ constructor(e2) {
106
+ e2 || (e2 = i), this.marks = e2.marks || [], this.nodes = e2.nodes || [];
107
+ }
108
+ addNode(e2, t2) {
109
+ this.nodes[e2] = t2;
110
+ }
111
+ addMark(e2, t2) {
112
+ this.marks[e2] = t2;
113
+ }
114
+ render(e2 = {}) {
115
+ if (e2.content && Array.isArray(e2.content)) {
116
+ let t2 = "";
117
+ return e2.content.forEach((e3) => {
118
+ t2 += this.renderNode(e3);
119
+ }), t2;
120
120
  }
121
121
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
122
122
  }
123
- renderNode(t2) {
124
- let e2 = [];
125
- t2.marks && t2.marks.forEach((t3) => {
126
- const r3 = this.getMatchingMark(t3);
127
- r3 && e2.push(this.renderOpeningTag(r3.tag));
123
+ renderNode(e2) {
124
+ let t2 = [];
125
+ e2.marks && e2.marks.forEach((e3) => {
126
+ const s3 = this.getMatchingMark(e3);
127
+ s3 && t2.push(this.renderOpeningTag(s3.tag));
128
128
  });
129
- const r2 = this.getMatchingNode(t2);
130
- return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)), t2.content ? t2.content.forEach((t3) => {
131
- e2.push(this.renderNode(t3));
132
- }) : t2.text ? e2.push(function(t3) {
133
- const e3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, r3 = /[&<>"']/g, s2 = RegExp(r3.source);
134
- return t3 && s2.test(t3) ? t3.replace(r3, (t4) => e3[t4]) : t3;
135
- }(t2.text)) : r2 && r2.singleTag ? e2.push(this.renderTag(r2.singleTag, " /")) : r2 && r2.html && e2.push(r2.html), r2 && r2.tag && e2.push(this.renderClosingTag(r2.tag)), t2.marks && t2.marks.slice(0).reverse().forEach((t3) => {
136
- const r3 = this.getMatchingMark(t3);
137
- r3 && e2.push(this.renderClosingTag(r3.tag));
138
- }), e2.join("");
139
- }
140
- renderTag(t2, e2) {
141
- if (t2.constructor === String)
142
- return `<${t2}${e2}>`;
143
- return t2.map((t3) => {
144
- if (t3.constructor === String)
145
- return `<${t3}${e2}>`;
129
+ const s2 = this.getMatchingNode(e2);
130
+ return s2 && s2.tag && t2.push(this.renderOpeningTag(s2.tag)), e2.content ? e2.content.forEach((e3) => {
131
+ t2.push(this.renderNode(e3));
132
+ }) : e2.text ? t2.push(function(e3) {
133
+ const t3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, s3 = /[&<>"']/g, r2 = RegExp(s3.source);
134
+ return e3 && r2.test(e3) ? e3.replace(s3, (e4) => t3[e4]) : e3;
135
+ }(e2.text)) : s2 && s2.singleTag ? t2.push(this.renderTag(s2.singleTag, " /")) : s2 && s2.html && t2.push(s2.html), s2 && s2.tag && t2.push(this.renderClosingTag(s2.tag)), e2.marks && e2.marks.slice(0).reverse().forEach((e3) => {
136
+ const s3 = this.getMatchingMark(e3);
137
+ s3 && t2.push(this.renderClosingTag(s3.tag));
138
+ }), t2.join("");
139
+ }
140
+ renderTag(e2, t2) {
141
+ if (e2.constructor === String)
142
+ return `<${e2}${t2}>`;
143
+ return e2.map((e3) => {
144
+ if (e3.constructor === String)
145
+ return `<${e3}${t2}>`;
146
146
  {
147
- let r2 = "<" + t3.tag;
148
- if (t3.attrs)
149
- for (let e3 in t3.attrs) {
150
- let s2 = t3.attrs[e3];
151
- s2 !== null && (r2 += ` ${e3}="${s2}"`);
147
+ let s2 = `<${e3.tag}`;
148
+ if (e3.attrs)
149
+ for (let t3 in e3.attrs) {
150
+ let r2 = e3.attrs[t3];
151
+ r2 !== null && (s2 += ` ${t3}="${r2}"`);
152
152
  }
153
- return `${r2}${e2}>`;
153
+ return `${s2}${t2}>`;
154
154
  }
155
155
  }).join("");
156
156
  }
157
- renderOpeningTag(t2) {
158
- return this.renderTag(t2, "");
157
+ renderOpeningTag(e2) {
158
+ return this.renderTag(e2, "");
159
159
  }
160
- renderClosingTag(t2) {
161
- if (t2.constructor === String)
162
- return `</${t2}>`;
163
- return t2.slice(0).reverse().map((t3) => t3.constructor === String ? `</${t3}>` : `</${t3.tag}>`).join("");
160
+ renderClosingTag(e2) {
161
+ if (e2.constructor === String)
162
+ return `</${e2}>`;
163
+ return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
164
164
  }
165
- getMatchingNode(t2) {
166
- if (typeof this.nodes[t2.type] == "function")
167
- return this.nodes[t2.type](t2);
165
+ getMatchingNode(e2) {
166
+ if (typeof this.nodes[e2.type] == "function")
167
+ return this.nodes[e2.type](e2);
168
168
  }
169
- getMatchingMark(t2) {
170
- if (typeof this.marks[t2.type] == "function")
171
- return this.marks[t2.type](t2);
169
+ getMatchingMark(e2) {
170
+ if (typeof this.marks[e2.type] == "function")
171
+ return this.marks[e2.type](e2);
172
172
  }
173
173
  }
174
- const o = (t2 = 0, e2 = t2) => {
175
- const r2 = Math.abs(e2 - t2) || 0, s2 = t2 < e2 ? 1 : -1;
176
- return ((t3 = 0, e3) => [...Array(t3)].map(e3))(r2, (e3, r3) => r3 * s2 + t2);
177
- }, a = (t2, e2, r2) => {
178
- const s2 = [];
179
- for (const n2 in t2) {
180
- if (!Object.prototype.hasOwnProperty.call(t2, n2))
174
+ const o = (e2 = 0, t2 = e2) => {
175
+ const s2 = Math.abs(t2 - e2) || 0, r2 = e2 < t2 ? 1 : -1;
176
+ return ((e3 = 0, t3) => [...Array(e3)].map(t3))(s2, (t3, s3) => s3 * r2 + e2);
177
+ }, a = (e2, t2, s2) => {
178
+ const r2 = [];
179
+ for (const i2 in e2) {
180
+ if (!Object.prototype.hasOwnProperty.call(e2, i2))
181
181
  continue;
182
- const i2 = t2[n2], o2 = r2 ? "" : encodeURIComponent(n2);
182
+ const n2 = e2[i2], o2 = s2 ? "" : encodeURIComponent(i2);
183
183
  let l2;
184
- l2 = typeof i2 == "object" ? a(i2, e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(i2)) : (e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(i2), s2.push(l2);
184
+ l2 = typeof n2 == "object" ? a(n2, t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(n2)) : (t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(n2), r2.push(l2);
185
185
  }
186
- return s2.join("&");
186
+ return r2.join("&");
187
187
  };
188
188
  let l = {}, c = {};
189
- class StoryblokClient {
190
- constructor(e2, s2) {
191
- if (!s2) {
192
- let t2 = e2.region ? "-" + e2.region : "", r2 = e2.https === false ? "http" : "https";
193
- s2 = e2.oauthToken === void 0 ? `${r2}://api${t2}.storyblok.com/v2` : `${r2}://api${t2}.storyblok.com/v1`;
189
+ class h {
190
+ constructor(t2, r2) {
191
+ if (!r2) {
192
+ let e2 = t2.region ? `-${t2.region}` : "", s2 = t2.https === false ? "http" : "https";
193
+ r2 = t2.oauthToken === void 0 ? `${s2}://api${e2}.storyblok.com/v2` : `${s2}://api${e2}.storyblok.com/v1`;
194
194
  }
195
- let n2 = Object.assign({}, e2.headers), o2 = 5;
196
- e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client = t.create({ baseURL: s2, timeout: e2.timeout || 0, headers: n2, proxy: e2.proxy || false }), e2.responseInterceptor && this.client.interceptors.response.use((t2) => e2.responseInterceptor(t2));
197
- }
198
- setComponentResolver(t2) {
199
- this.richTextResolver.addNode("blok", (e2) => {
200
- let r2 = "";
201
- return e2.attrs.body.forEach((e3) => {
202
- r2 += t2(e3.component, e3);
203
- }), { html: r2 };
195
+ let i2 = Object.assign({}, t2.headers), o2 = 5;
196
+ t2.oauthToken !== void 0 && (i2.Authorization = t2.oauthToken, o2 = 3), t2.rateLimit !== void 0 && (o2 = t2.rateLimit), this.richTextResolver = new n(t2.richTextSchema), typeof t2.componentResolver == "function" && this.setComponentResolver(t2.componentResolver), this.maxRetries = t2.maxRetries || 5, this.throttle = s(this.throttledRequest, o2, 1e3), this.accessToken = t2.accessToken, this.relations = {}, this.links = {}, this.cache = t2.cache || { clear: "manual" }, this.client = e.create({ baseURL: r2, timeout: t2.timeout || 0, headers: i2, proxy: t2.proxy || false }), t2.responseInterceptor && this.client.interceptors.response.use((e2) => t2.responseInterceptor(e2)), this.resolveNestedRelations = t2.resolveNestedRelations || true;
197
+ }
198
+ setComponentResolver(e2) {
199
+ this.richTextResolver.addNode("blok", (t2) => {
200
+ let s2 = "";
201
+ return t2.attrs.body.forEach((t3) => {
202
+ s2 += e2(t3.component, t3);
203
+ }), { html: s2 };
204
204
  });
205
205
  }
206
- parseParams(t2 = {}) {
207
- return t2.version || (t2.version = "published"), t2.token || (t2.token = this.getToken()), t2.cv || (t2.cv = c[t2.token]), Array.isArray(t2.resolve_relations) && (t2.resolve_relations = t2.resolve_relations.join(",")), t2;
206
+ parseParams(e2 = {}) {
207
+ return e2.version || (e2.version = "published"), e2.token || (e2.token = this.getToken()), e2.cv || (e2.cv = c[e2.token]), Array.isArray(e2.resolve_relations) && (e2.resolve_relations = e2.resolve_relations.join(",")), e2;
208
208
  }
209
- factoryParamOptions(t2, e2 = {}) {
210
- return ((t3 = "") => t3.indexOf("/cdn/") > -1)(t2) ? this.parseParams(e2) : e2;
209
+ factoryParamOptions(e2, t2 = {}) {
210
+ return ((e3 = "") => e3.indexOf("/cdn/") > -1)(e2) ? this.parseParams(t2) : t2;
211
211
  }
212
- makeRequest(t2, e2, r2, s2) {
213
- const n2 = this.factoryParamOptions(t2, ((t3 = {}, e3 = 25, r3 = 1) => __spreadProps(__spreadValues({}, t3), { per_page: e3, page: r3 }))(e2, r2, s2));
214
- return this.cacheResponse(t2, n2);
212
+ makeRequest(e2, t2, s2, r2) {
213
+ const i2 = this.factoryParamOptions(e2, ((e3 = {}, t3 = 25, s3 = 1) => __spreadProps(__spreadValues({}, e3), { per_page: t3, page: s3 }))(t2, s2, r2));
214
+ return this.cacheResponse(e2, i2);
215
215
  }
216
- get(t2, e2) {
217
- let r2 = "/" + t2;
218
- const s2 = this.factoryParamOptions(r2, e2);
219
- return this.cacheResponse(r2, s2);
216
+ get(e2, t2) {
217
+ let s2 = `/${e2}`;
218
+ const r2 = this.factoryParamOptions(s2, t2);
219
+ return this.cacheResponse(s2, r2);
220
220
  }
221
- async getAll(t2, e2 = {}, r2) {
222
- const s2 = e2.per_page || 25, n2 = "/" + t2, i2 = n2.split("/");
223
- r2 = r2 || i2[i2.length - 1];
224
- const a2 = await this.makeRequest(n2, e2, s2, 1), l2 = Math.ceil(a2.total / s2);
225
- return ((t3 = [], e3) => t3.map(e3).reduce((t4, e4) => [...t4, ...e4], []))([a2, ...await (async (t3 = [], e3) => Promise.all(t3.map(e3)))(o(1, l2), async (t3) => this.makeRequest(n2, e2, s2, t3 + 1))], (t3) => Object.values(t3.data[r2]));
221
+ async getAll(e2, t2 = {}, s2) {
222
+ const r2 = t2.per_page || 25, i2 = `/${e2}`, n2 = i2.split("/");
223
+ s2 = s2 || n2[n2.length - 1];
224
+ const a2 = await this.makeRequest(i2, t2, r2, 1), l2 = Math.ceil(a2.total / r2);
225
+ return ((e3 = [], t3) => e3.map(t3).reduce((e4, t4) => [...e4, ...t4], []))([a2, ...await (async (e3 = [], t3) => Promise.all(e3.map(t3)))(o(1, l2), async (e3) => this.makeRequest(i2, t2, r2, e3 + 1))], (e3) => Object.values(e3.data[s2]));
226
226
  }
227
- post(t2, e2) {
228
- let r2 = "/" + t2;
229
- return this.throttle("post", r2, e2);
227
+ post(e2, t2) {
228
+ let s2 = `/${e2}`;
229
+ return this.throttle("post", s2, t2);
230
230
  }
231
- put(t2, e2) {
232
- let r2 = "/" + t2;
233
- return this.throttle("put", r2, e2);
231
+ put(e2, t2) {
232
+ let s2 = `/${e2}`;
233
+ return this.throttle("put", s2, t2);
234
234
  }
235
- delete(t2, e2) {
236
- let r2 = "/" + t2;
237
- return this.throttle("delete", r2, e2);
235
+ delete(e2, t2) {
236
+ let s2 = `/${e2}`;
237
+ return this.throttle("delete", s2, t2);
238
238
  }
239
- getStories(t2) {
240
- return this.get("cdn/stories", t2);
239
+ getStories(e2) {
240
+ return this.get("cdn/stories", e2);
241
241
  }
242
- getStory(t2, e2) {
243
- return this.get("cdn/stories/" + t2, e2);
242
+ getStory(e2, t2) {
243
+ return this.get(`cdn/stories/${e2}`, t2);
244
244
  }
245
- setToken(t2) {
246
- this.accessToken = t2;
245
+ setToken(e2) {
246
+ this.accessToken = e2;
247
247
  }
248
248
  getToken() {
249
249
  return this.accessToken;
250
250
  }
251
- _cleanCopy(t2) {
252
- return JSON.parse(JSON.stringify(t2));
253
- }
254
- _insertLinks(t2, e2) {
255
- const r2 = t2[e2];
256
- r2 && r2.fieldtype == "multilink" && r2.linktype == "story" && typeof r2.id == "string" && this.links[r2.id] ? r2.story = this._cleanCopy(this.links[r2.id]) : r2 && r2.linktype === "story" && typeof r2.uuid == "string" && this.links[r2.uuid] && (r2.story = this._cleanCopy(this.links[r2.uuid]));
257
- }
258
- _insertRelations(t2, e2, r2) {
259
- if (r2.indexOf(t2.component + "." + e2) > -1) {
260
- if (typeof t2[e2] == "string")
261
- this.relations[t2[e2]] && (t2[e2] = this._cleanCopy(this.relations[t2[e2]]));
262
- else if (t2[e2].constructor === Array) {
263
- let r3 = [];
264
- t2[e2].forEach((t3) => {
265
- this.relations[t3] && r3.push(this._cleanCopy(this.relations[t3]));
266
- }), t2[e2] = r3;
251
+ _cleanCopy(e2) {
252
+ return JSON.parse(JSON.stringify(e2));
253
+ }
254
+ _insertLinks(e2, t2) {
255
+ const s2 = e2[t2];
256
+ s2 && s2.fieldtype == "multilink" && s2.linktype == "story" && typeof s2.id == "string" && this.links[s2.id] ? s2.story = this._cleanCopy(this.links[s2.id]) : s2 && s2.linktype === "story" && typeof s2.uuid == "string" && this.links[s2.uuid] && (s2.story = this._cleanCopy(this.links[s2.uuid]));
257
+ }
258
+ _insertRelations(e2, t2, s2) {
259
+ if (s2.indexOf(e2.component + "." + t2) > -1) {
260
+ if (typeof e2[t2] == "string")
261
+ this.relations[e2[t2]] && (e2[t2] = this._cleanCopy(this.relations[e2[t2]]));
262
+ else if (e2[t2].constructor === Array) {
263
+ let s3 = [];
264
+ e2[t2].forEach((e3) => {
265
+ this.relations[e3] && s3.push(this._cleanCopy(this.relations[e3]));
266
+ }), e2[t2] = s3;
267
267
  }
268
268
  }
269
269
  }
270
- iterateTree(t2, e2) {
271
- let r2 = (t3) => {
272
- if (t3 != null) {
273
- if (t3.constructor === Array)
274
- for (let e3 = 0; e3 < t3.length; e3++)
275
- r2(t3[e3]);
276
- else if (t3.constructor === Object) {
277
- if (t3._stopResolving)
270
+ _insertAssetsRelations(e2, t2) {
271
+ t2.forEach((t3) => {
272
+ e2.id === t3.id && (e2.original = t3, e2.original.filename = e2.filename, e2.original.filename = e2.original.filename.includes("https://s3.amazonaws.com/") ? e2.original.filename : e2.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e2.original.s3_filename);
273
+ });
274
+ }
275
+ iterateTree(e2, t2) {
276
+ let s2 = (e3) => {
277
+ if (e3 != null) {
278
+ if (e3.constructor === Array)
279
+ for (let t3 = 0; t3 < e3.length; t3++)
280
+ s2(e3[t3]);
281
+ else if (e3.constructor === Object) {
282
+ if (e3._stopResolving)
278
283
  return;
279
- for (let s2 in t3)
280
- (t3.component && t3._uid || t3.type === "link") && (this._insertRelations(t3, s2, e2), this._insertLinks(t3, s2)), r2(t3[s2]);
284
+ for (let r2 in e3)
285
+ e3.component && e3._uid || e3.type === "link" ? (this._insertRelations(e3, r2, t2), this._insertLinks(e3, r2)) : e3.fieldtype === "asset" && this._insertAssetsRelations(e3, t2), s2(e3[r2]);
281
286
  }
282
287
  }
283
288
  };
284
- r2(t2.content);
285
- }
286
- async resolveLinks(t2, e2) {
287
- let r2 = [];
288
- if (t2.link_uuids) {
289
- const s2 = t2.link_uuids.length;
290
- let n2 = [];
291
- const i2 = 50;
292
- for (let e3 = 0; e3 < s2; e3 += i2) {
293
- const r3 = Math.min(s2, e3 + i2);
294
- n2.push(t2.link_uuids.slice(e3, r3));
289
+ s2(e2.content);
290
+ }
291
+ async resolveLinks(e2, t2) {
292
+ let s2 = [];
293
+ if (e2.link_uuids) {
294
+ const r2 = e2.link_uuids.length;
295
+ let i2 = [];
296
+ const n2 = 50;
297
+ for (let t3 = 0; t3 < r2; t3 += n2) {
298
+ const s3 = Math.min(r2, t3 + n2);
299
+ i2.push(e2.link_uuids.slice(t3, s3));
295
300
  }
296
- for (let t3 = 0; t3 < n2.length; t3++) {
297
- (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
298
- r2.push(t4);
301
+ for (let e3 = 0; e3 < i2.length; e3++) {
302
+ (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
303
+ s2.push(e4);
299
304
  });
300
305
  }
301
306
  } else
302
- r2 = t2.links;
303
- r2.forEach((t3) => {
304
- this.links[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
307
+ s2 = e2.links;
308
+ s2.forEach((e3) => {
309
+ this.links[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
305
310
  });
306
311
  }
307
- async resolveRelations(t2, e2) {
308
- let r2 = [];
309
- if (t2.rel_uuids) {
310
- const s2 = t2.rel_uuids.length;
311
- let n2 = [];
312
- const i2 = 50;
313
- for (let e3 = 0; e3 < s2; e3 += i2) {
314
- const r3 = Math.min(s2, e3 + i2);
315
- n2.push(t2.rel_uuids.slice(e3, r3));
312
+ async resolveRelations(e2, t2) {
313
+ let s2 = [];
314
+ if (e2.rel_uuids) {
315
+ const r2 = e2.rel_uuids.length;
316
+ let i2 = [];
317
+ const n2 = 50;
318
+ for (let t3 = 0; t3 < r2; t3 += n2) {
319
+ const s3 = Math.min(r2, t3 + n2);
320
+ i2.push(e2.rel_uuids.slice(t3, s3));
316
321
  }
317
- for (let t3 = 0; t3 < n2.length; t3++) {
318
- (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
319
- r2.push(t4);
322
+ for (let e3 = 0; e3 < i2.length; e3++) {
323
+ (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
324
+ s2.push(e4);
320
325
  });
321
326
  }
322
327
  } else
323
- r2 = t2.rels;
324
- r2.forEach((t3) => {
325
- this.relations[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
328
+ s2 = e2.rels;
329
+ s2.forEach((e3) => {
330
+ this.relations[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
326
331
  });
327
332
  }
328
- async resolveStories(t2, e2) {
329
- let r2 = [];
330
- e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(t2, e2)), ["1", "story", "url"].indexOf(e2.resolve_links) > -1 && await this.resolveLinks(t2, e2);
331
- for (const t3 in this.relations)
332
- this.iterateTree(this.relations[t3], r2);
333
- t2.story ? this.iterateTree(t2.story, r2) : t2.stories.forEach((t3) => {
334
- this.iterateTree(t3, r2);
333
+ async resolveStories(e2, t2) {
334
+ let s2 = [];
335
+ if (t2.resolve_relations !== void 0 && t2.resolve_relations.length > 0 && (s2 = t2.resolve_relations.split(","), await this.resolveRelations(e2, t2)), ["1", "story", "url"].indexOf(t2.resolve_links) > -1 && await this.resolveLinks(e2, t2), this.resolveNestedRelations)
336
+ for (const e3 in this.relations)
337
+ this.iterateTree(this.relations[e3], s2);
338
+ e2.story ? this.iterateTree(e2.story, s2) : e2.stories.forEach((e3) => {
339
+ this.iterateTree(e3, s2);
335
340
  });
336
341
  }
337
- cacheResponse(t2, e2, r2) {
338
- return r2 === void 0 && (r2 = 0), new Promise(async (s2, n2) => {
339
- let i2 = a({ url: t2, params: e2 }), o2 = this.cacheProvider();
340
- if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" && t2 != "/cdn/spaces/me") {
341
- const t3 = await o2.get(i2);
342
- if (t3)
343
- return s2(t3);
342
+ resolveAssetsRelations(e2) {
343
+ const { assets: t2, stories: s2, story: r2 } = e2;
344
+ if (s2)
345
+ for (const e3 of s2)
346
+ this.iterateTree(e3, t2);
347
+ else
348
+ this.iterateTree(r2, t2);
349
+ }
350
+ cacheResponse(e2, t2, s2) {
351
+ return s2 === void 0 && (s2 = 0), new Promise(async (r2, i2) => {
352
+ let n2 = a({ url: e2, params: t2 }), o2 = this.cacheProvider();
353
+ if (this.cache.clear === "auto" && t2.version === "draft" && await this.flushCache(), t2.version === "published" && e2 != "/cdn/spaces/me") {
354
+ const e3 = await o2.get(n2);
355
+ if (e3)
356
+ return r2(e3);
344
357
  }
345
358
  try {
346
- let r3 = await this.throttle("get", t2, { params: e2, paramsSerializer: (t3) => a(t3) }), l3 = { data: r3.data, headers: r3.headers };
347
- if (r3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(r3.headers["per-page"]), total: parseInt(r3.headers.total) })), r3.status != 200)
348
- return n2(r3);
349
- (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" && t2 != "/cdn/spaces/me" && o2.set(i2, l3), l3.data.cv && (e2.version == "draft" && c[e2.token] != l3.data.cv && this.flushCache(), c[e2.token] = l3.data.cv), s2(l3);
350
- } catch (i3) {
351
- if (i3.response && i3.response.status === 429 && (r2 += 1) < this.maxRetries)
352
- return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((t3) => setTimeout(t3, l2))), this.cacheResponse(t2, e2, r2).then(s2).catch(n2);
353
- n2(i3);
359
+ let s3 = await this.throttle("get", e2, { params: t2, paramsSerializer: (e3) => a(e3) }), l3 = { data: s3.data, headers: s3.headers };
360
+ if (l3.data.assets && l3.data.assets.length && this.resolveAssetsRelations(l3.data), s3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(s3.headers["per-page"]), total: parseInt(s3.headers.total) })), s3.status != 200)
361
+ return i2(s3);
362
+ (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, t2), t2.version === "published" && e2 != "/cdn/spaces/me" && o2.set(n2, l3), l3.data.cv && (t2.version == "draft" && c[t2.token] != l3.data.cv && this.flushCache(), c[t2.token] = l3.data.cv), r2(l3);
363
+ } catch (n3) {
364
+ if (n3.response && n3.response.status === 429 && (s2 += 1) < this.maxRetries)
365
+ return console.log(`Hit rate limit. Retrying in ${s2} seconds.`), await (l2 = 1e3 * s2, new Promise((e3) => setTimeout(e3, l2))), this.cacheResponse(e2, t2, s2).then(r2).catch(i2);
366
+ i2(n3);
354
367
  }
355
368
  var l2;
356
369
  });
357
370
  }
358
- throttledRequest(t2, e2, r2) {
359
- return this.client[t2](e2, r2);
371
+ throttledRequest(e2, t2, s2) {
372
+ return this.client[e2](t2, s2);
360
373
  }
361
374
  cacheVersions() {
362
375
  return c;
@@ -364,24 +377,19 @@ class StoryblokClient {
364
377
  cacheVersion() {
365
378
  return c[this.accessToken];
366
379
  }
367
- setCacheVersion(t2) {
368
- this.accessToken && (c[this.accessToken] = t2);
380
+ setCacheVersion(e2) {
381
+ this.accessToken && (c[this.accessToken] = e2);
369
382
  }
370
383
  cacheProvider() {
371
- switch (this.cache.type) {
372
- case "memory":
373
- return { get: (t2) => l[t2], getAll: () => l, set(t2, e2) {
374
- l[t2] = e2;
375
- }, flush() {
376
- l = {};
377
- } };
378
- default:
379
- return { get() {
380
- }, getAll() {
381
- }, set() {
382
- }, flush() {
383
- } };
384
- }
384
+ return this.cache.type === "memory" ? { get: (e2) => l[e2], getAll: () => l, set(e2, t2) {
385
+ l[e2] = t2;
386
+ }, flush() {
387
+ l = {};
388
+ } } : { get() {
389
+ }, getAll() {
390
+ }, set() {
391
+ }, flush() {
392
+ } };
385
393
  }
386
394
  async flushCache() {
387
395
  return await this.cacheProvider().flush(), this;
@@ -393,7 +401,7 @@ var api = (options = {}) => {
393
401
  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");
394
402
  return;
395
403
  }
396
- const storyblokApi = new StoryblokClient(apiOptions);
404
+ const storyblokApi = new h(apiOptions);
397
405
  return { storyblokApi };
398
406
  };
399
407
  var editable = (blok) => {
@@ -406,6 +414,7 @@ var editable = (blok) => {
406
414
  "data-blok-uid": options.id + "-" + options.uid
407
415
  };
408
416
  };
417
+ const bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js";
409
418
  const useStoryblokBridge = (id, cb, options = {}) => {
410
419
  if (typeof window === "undefined") {
411
420
  return;
@@ -438,8 +447,11 @@ const storyblokInit = (pluginOptions = {}) => {
438
447
  result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
439
448
  });
440
449
  if (bridge !== false) {
441
- loadBridge("https://app.storyblok.com/f/storyblok-v2-latest.js");
450
+ loadBridge(bridgeLatest);
442
451
  }
443
452
  return result;
444
453
  };
445
- export { api as apiPlugin, editable as storyblokEditable, storyblokInit, useStoryblokBridge };
454
+ const loadStoryblokBridge = () => {
455
+ return loadBridge(bridgeLatest);
456
+ };
457
+ export { api as apiPlugin, loadStoryblokBridge, editable as storyblokEditable, storyblokInit, useStoryblokBridge };
@@ -0,0 +1,7 @@
1
+ import { SbSDKOptions, StoryblokBridgeConfigV2, StoryData } from "./types";
2
+ export declare const useStoryblokBridge: (id: Number, cb: (newStory: StoryData) => void, options?: StoryblokBridgeConfigV2) => void;
3
+ export { default as apiPlugin } from "./modules/api";
4
+ export { default as storyblokEditable } from "./modules/editable";
5
+ export declare const storyblokInit: (pluginOptions?: SbSDKOptions) => {};
6
+ export declare const loadStoryblokBridge: () => Promise<unknown>;
7
+ export * from "./types";
@@ -0,0 +1,6 @@
1
+ import StoryblokClient from "storyblok-js-client";
2
+ import { SbSDKOptions } from "../types";
3
+ declare const _default: (options?: SbSDKOptions) => {
4
+ storyblokApi: StoryblokClient;
5
+ };
6
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const loadBridge: (src: string) => Promise<unknown>;
@@ -0,0 +1,9 @@
1
+ import { SbBlokData } from "../types";
2
+ declare const _default: (blok: SbBlokData) => {
3
+ "data-blok-c"?: undefined;
4
+ "data-blok-uid"?: undefined;
5
+ } | {
6
+ "data-blok-c": string;
7
+ "data-blok-uid": string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { StoryblokConfig, StoryblokComponent } from "storyblok-js-client";
2
+ declare global {
3
+ interface Window {
4
+ storyblokRegisterEvent: (cb: Function) => void;
5
+ StoryblokBridge: (options?: StoryblokBridgeConfigV2) => void;
6
+ }
7
+ }
8
+ export declare type SbBlokKeyDataTypes = string | number | object;
9
+ export interface SbBlokData extends StoryblokComponent<string> {
10
+ [index: string]: SbBlokKeyDataTypes;
11
+ }
12
+ export interface SbSDKOptions {
13
+ bridge?: boolean;
14
+ accessToken?: string;
15
+ use?: [];
16
+ apiOptions?: StoryblokConfig;
17
+ }
18
+ export interface StoryblokBridgeConfigV2 {
19
+ resolveRelations?: [string];
20
+ customParent?: string;
21
+ preventClicks?: boolean;
22
+ }
23
+ export interface StoryblokBridgeV2 {
24
+ pingEditor: (event: any) => void;
25
+ isInEditor: () => boolean;
26
+ enterEditmode: () => void;
27
+ on: (event: "customEvent" | "published" | "input" | "change" | "unpublished" | "enterEditmode" | string[], callback: (payload?: StoryblokEventPayload) => void) => void;
28
+ }
29
+ export type { StoryblokConfig, StoryblokCache, StoryblokCacheProvider, StoryblokResult, StoryblokManagmentApiResult, StoryblokComponent, StoryData, AlternateObject, Stories, Story, StoriesParams, StoryParams, Richtext, RichtextInstance, } from "storyblok-js-client";
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
- "version": "1.0.4",
3
+ "version": "1.2.1",
4
4
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
5
5
  "main": "./dist/storyblok-js.js",
6
6
  "module": "./dist/storyblok-js.mjs",
7
+ "types": "./dist/types/index.d.ts",
7
8
  "files": [
8
9
  "dist"
9
10
  ],
@@ -15,30 +16,31 @@
15
16
  },
16
17
  "scripts": {
17
18
  "dev": "vite build --watch",
18
- "build": "vite build",
19
+ "build": "vite build && tsc --project tsconfig.json",
19
20
  "test": "npm run test:unit && npm run test:e2e",
20
21
  "test:unit": "jest __tests__",
21
22
  "test:e2e": "start-server-and-test cy:playground http-get://localhost:3000/ cy:run",
22
23
  "test:e2e-watch": "start-server-and-test cy:playground http-get://localhost:3000/ cy:open",
23
24
  "cy:playground": "npm run demo --prefix ../playground",
24
- "cy:run": "cypress run --spec 'cypress/integration/*'",
25
- "cy:open": "cypress open --spec 'cypress/integration/*'",
25
+ "cy:run": "cypress run",
26
+ "cy:open": "cypress open",
26
27
  "prepublishOnly": "npm run build && cp ../README.md ./"
27
28
  },
28
29
  "dependencies": {
29
- "storyblok-js-client": "^4.2.0"
30
+ "storyblok-js-client": "^4.5.2"
30
31
  },
31
32
  "devDependencies": {
32
- "@babel/core": "^7.15.0",
33
+ "@babel/core": "^7.17.9",
33
34
  "@babel/preset-env": "^7.16.11",
34
- "babel-jest": "^26.6.3",
35
- "cypress": "^8.3.0",
35
+ "@tsconfig/recommended": "^1.0.1",
36
+ "babel-jest": "^28.1.0",
37
+ "cypress": "^9.6.1",
36
38
  "eslint-plugin-cypress": "^2.12.1",
37
- "eslint-plugin-jest": "^25.2.4",
38
- "jest": "^26.6.3",
39
+ "eslint-plugin-jest": "^26.2.2",
40
+ "jest": "^28.0.2",
39
41
  "jest-console": "^0.1.0",
40
42
  "start-server-and-test": "^1.14.0",
41
- "vite": "^2.4.4"
43
+ "vite": "^2.9.6"
42
44
  },
43
45
  "babel": {
44
46
  "presets": [