@storyblok/svelte 2.0.1 → 2.0.4

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
@@ -36,7 +36,7 @@
36
36
 
37
37
  `@storyblok/svelte` helps you connect your Svelte project to Storyblok by:
38
38
 
39
- - Providing the `useStoryblokApi` function to interact with the Storyblok APIs, using the [storyblok-js-client](https://github.com/storyblok/storyblok-js-client)
39
+ - Providing the `getStoryblokApi` function to interact with the Storyblok APIs, using the [storyblok-js-client](https://github.com/storyblok/storyblok-js-client)
40
40
  - Enabling real time editing through the [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte)
41
41
  - Providing the `StoryblokComponent` which allows you to connect your components to the Storyblok Visual Editor -->
42
42
 
@@ -88,15 +88,15 @@ Install the file from the CDN and access the methods via `window.storyblokSvelte
88
88
 
89
89
  ### 1. Fetching Content
90
90
 
91
- Use the `useStoryblokApi()` gets your stories from the Storyblok CDN API:
91
+ Use the `getStoryblokApi()` gets your stories from the Storyblok CDN API:
92
92
 
93
93
  ```html
94
94
  <script>
95
95
  import { onMount } from "svelte";
96
- import { useStoryblokApi } from "@storyblok/svelte";
96
+ import { getStoryblokApi } from "@storyblok/svelte";
97
97
 
98
98
  onMount(async () => {
99
- const storyblokApi = useStoryblokApi();
99
+ const storyblokApi = getStoryblokApi();
100
100
  const { data } = await storyblokApi.get("cdn/stories/home", {
101
101
  version: "draft",
102
102
  });
@@ -113,12 +113,12 @@ Use `useStoryBridge` to get the updated story every time a change event is trigg
113
113
  ```html
114
114
  <script>
115
115
  import { onMount } from "svelte";
116
- import { useStoryblokApi, useStoryblokBridge } from "@storyblok/svelte";
116
+ import { getStoryblokApi, useStoryblokBridge } from "@storyblok/svelte";
117
117
 
118
118
  let story = null;
119
119
 
120
120
  onMount(async () => {
121
- const storyblokApi = useStoryblokApi();
121
+ const storyblokApi = getStoryblokApi();
122
122
  const { data } = await storyblokApi.get("cdn/stories/home", {
123
123
  version: "draft",
124
124
  });
@@ -142,7 +142,7 @@ In order to link the storyblok components, you have to
142
142
 
143
143
  - Load them in components when calling `storyblokInit`
144
144
 
145
- - Use the `storyblokEditable` svelte action on the root element of each component
145
+ - Use the `storyblokEditable` action on the root element of each component
146
146
 
147
147
  ```html
148
148
  <div use:storyblokEditable={blok} / >
@@ -1,12 +1,12 @@
1
- (function(f,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],y):(f=typeof globalThis!="undefined"?globalThis:f||self,y(f.storyblokSvelte={},f.t))})(this,function(f,y){"use strict";function ne(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var re=ne(y),oe=Object.defineProperty,se=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,B=(t,e,n)=>e in t?oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))ae.call(e,n)&&B(t,n,e[n]);if(N)for(var n of N(e))ce.call(e,n)&&B(t,n,e[n]);return t},E=(t,e)=>se(t,ie(e));let q=!1;const L=[],le=t=>new Promise((e,n)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}q?o():L.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=t,r.id="storyblok-javascript-bridge",r.onerror=o=>n(o),r.onload=o=>{L.forEach(s=>s()),q=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});/*!
1
+ (function(f,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],y):(f=typeof globalThis!="undefined"?globalThis:f||self,y(f.storyblokSvelte={},f.t))})(this,function(f,y){"use strict";function re(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var oe=re(y),se=Object.defineProperty,ie=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,B=(t,e,n)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))le.call(e,n)&&B(t,n,e[n]);if(N)for(var n of N(e))ce.call(e,n)&&B(t,n,e[n]);return t},E=(t,e)=>ie(t,ae(e));let L=!1;const q=[],ue=t=>new Promise((e,n)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}L?o():q.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=t,r.id="storyblok-javascript-bridge",r.onerror=o=>n(o),r.onload=o=>{q.forEach(s=>s()),L=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});/*!
2
2
  * storyblok-js-client v0.0.0-development
3
3
  * Universal JavaScript SDK for Storyblok's API
4
4
  * (c) 2020-2022 Stobylok Team
5
- */function D(t){return typeof t=="number"&&t==t&&t!==1/0&&t!==-1/0}function U(t,e,n){if(!D(e))throw new TypeError("Expected `limit` to be a finite number");if(!D(n))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],s=0,a=function(){s++;var c=setTimeout(function(){s--,r.length>0&&a(),o=o.filter(function(u){return u!==c})},n);o.indexOf(c)<0&&o.push(c);var l=r.shift();l.resolve(t.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,d){r.push({resolve:u,reject:d,args:c,self:l}),s<e&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}U.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const ue=function(t,e){if(!t)return null;let n={};for(let r in t){let o=t[r];e.indexOf(r)>-1&&o!==null&&(n[r]=o)}return n};var fe={nodes:{horizontal_rule:t=>({singleTag:"hr"}),blockquote:t=>({tag:"blockquote"}),bullet_list:t=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:t=>({singleTag:"br"}),heading:t=>({tag:"h"+t.attrs.level}),image:t=>({singleTag:[{tag:"img",attrs:ue(t.attrs,["src","alt","title"])}]}),list_item:t=>({tag:"li"}),ordered_list:t=>({tag:"ol"}),paragraph:t=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(t){const e=p({},t.attrs),{linktype:n="url"}=t.attrs;return n==="email"&&(e.href="mailto:"+e.href),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]})}};class de{constructor(e){e||(e=fe),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,n){this.nodes[e]=n}addMark(e,n){this.marks[e]=n}render(e={}){if(e.content&&Array.isArray(e.content)){let n="";return e.content.forEach(r=>{n+=this.renderNode(r)}),n}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let n=[];e.marks&&e.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderOpeningTag(s.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&n.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{n.push(this.renderNode(o))}):e.text?n.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,c=>s[c]):o}(e.text)):r&&r.singleTag?n.push(this.renderTag(r.singleTag," /")):r&&r.html&&n.push(r.html),r&&r.tag&&n.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderClosingTag(s.tag))}),n.join("")}renderTag(e,n){return e.constructor===String?`<${e}${n}>`:e.map(r=>{if(r.constructor===String)return`<${r}${n}>`;{let o="<"+r.tag;if(r.attrs)for(let s in r.attrs){let a=r.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${n}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.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 he=(t=0,e=t)=>{const n=Math.abs(e-t)||0,r=t<e?1:-1;return((o=0,s)=>[...Array(o)].map(s))(n,(o,s)=>s*r+t)},O=(t,e,n)=>{const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const s=t[o],a=n?"":encodeURIComponent(o);let i;i=typeof s=="object"?O(s,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),r.push(i)}return r.join("&")};let b={},g={};class pe{constructor(e,n){if(!n){let s=e.region?"-"+e.region:"",a=e.https===!1?"http":"https";n=e.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let r=Object.assign({},e.headers),o=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,o=3),e.rateLimit!==void 0&&(o=e.rateLimit),this.richTextResolver=new de(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=U(this.throttledRequest,o,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=re.default.create({baseURL:n,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(s=>e.responseInterceptor(s))}setComponentResolver(e){this.richTextResolver.addNode("blok",n=>{let r="";return n.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,n={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(n):n}makeRequest(e,n,r,o){const s=this.factoryParamOptions(e,((a={},i=25,c=1)=>E(p({},a),{per_page:i,page:c}))(n,r,o));return this.cacheResponse(e,s)}get(e,n){let r="/"+e;const o=this.factoryParamOptions(r,n);return this.cacheResponse(r,o)}async getAll(e,n={},r){const o=n.per_page||25,s="/"+e,a=s.split("/");r=r||a[a.length-1];const i=await this.makeRequest(s,n,o,1),c=Math.ceil(i.total/o);return((l=[],u)=>l.map(u).reduce((d,$)=>[...d,...$],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(he(1,c),async l=>this.makeRequest(s,n,o,l+1))],l=>Object.values(l.data[r]))}post(e,n){let r="/"+e;return this.throttle("post",r,n)}put(e,n){let r="/"+e;return this.throttle("put",r,n)}delete(e,n){let r="/"+e;return this.throttle("delete",r,n)}getStories(e){return this.get("cdn/stories",e)}getStory(e,n){return this.get("cdn/stories/"+e,n)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,n){const r=e[n];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,n,r){if(r.indexOf(e.component+"."+n)>-1){if(typeof e[n]=="string")this.relations[e[n]]&&(e[n]=this._cleanCopy(this.relations[e[n]]));else if(e[n].constructor===Array){let o=[];e[n].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),e[n]=o}}}iterateTree(e,n){let r=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)r(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,s,n),this._insertLinks(o,s)),r(o[s])}}};r(e.content)}async resolveLinks(e,n){let r=[];if(e.link_uuids){const o=e.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const c=Math.min(o,i+a);s.push(e.link_uuids.slice(i,c))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(o=>{this.links[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveRelations(e,n){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const c=Math.min(o,i+a);s.push(e.rel_uuids.slice(i,c))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(o=>{this.relations[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveStories(e,n){let r=[];n.resolve_relations!==void 0&&n.resolve_relations.length>0&&(r=n.resolve_relations.split(","),await this.resolveRelations(e,n)),["1","story","url"].indexOf(n.resolve_links)>-1&&await this.resolveLinks(e,n);for(const o in this.relations)this.iterateTree(this.relations[o],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(o=>{this.iterateTree(o,r)})}cacheResponse(e,n,r){return r===void 0&&(r=0),new Promise(async(o,s)=>{let a=O({url:e,params:n}),i=this.cacheProvider();if(this.cache.clear==="auto"&&n.version==="draft"&&await this.flushCache(),n.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(a);if(l)return o(l)}try{let l=await this.throttle("get",e,{params:n,paramsSerializer:d=>O(d)}),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 s(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,n),n.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(n.version=="draft"&&g[n.token]!=u.data.cv&&this.flushCache(),g[n.token]=u.data.cv),o(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,n,r).then(o).catch(s);s(l)}var c})}throttledRequest(e,n,r){return this.client[e](n,r)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>b[e],getAll:()=>b,set(e,n){b[e]=n},flush(){b={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var ge=(t={})=>{const{apiOptions:e}=t;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 pe(e)}},ye=t=>{if(typeof t!="object"||typeof t._editable=="undefined")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const me=(t,e,n={})=>{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}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(n).on(["input","published","change"],o=>{o.action=="input"&&o.story.id===t?e(o.story):window.location.reload()})})}},_e=(t={})=>{const{bridge:e,accessToken:n,use:r=[],apiOptions:o={}}=t;o.accessToken=o.accessToken||n;const s={bridge:e,apiOptions:o};let a={};return r.forEach(i=>{a=p(p({},a),i(s))}),e!==!1&&le("https://app.storyblok.com/f/storyblok-v2-latest.js"),a};function V(){}function R(t,e){for(const n in e)t[n]=e[n];return t}function J(t){return t()}function Y(){return Object.create(null)}function m(t){t.forEach(J)}function ke(t){return typeof t=="function"}function be(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function ve(t){return Object.keys(t).length===0}function we(t){const e={};for(const n in t)n[0]!=="$"&&(e[n]=t[n]);return e}function z(t,e){const n={};e=new Set(e);for(const r in t)!e.has(r)&&r[0]!=="$"&&(n[r]=t[r]);return n}function Te(t,e,n){t.insertBefore(e,n||null)}function F(t){t.parentNode.removeChild(t)}function $e(t){return document.createTextNode(t)}function Ee(){return $e("")}function Oe(t){return Array.from(t.childNodes)}let S;function _(t){S=t}const k=[],H=[],v=[],G=[],Re=Promise.resolve();let P=!1;function Se(){P||(P=!0,Re.then(K))}function j(t){v.push(t)}const x=new Set;let w=0;function K(){const t=S;do{for(;w<k.length;){const e=k[w];w++,_(e),Pe(e.$$)}for(_(null),k.length=0,w=0;H.length;)H.pop()();for(let e=0;e<v.length;e+=1){const n=v[e];x.has(n)||(x.add(n),n())}v.length=0}while(k.length);for(;G.length;)G.pop()();P=!1,x.clear(),_(t)}function Pe(t){if(t.fragment!==null){t.update(),m(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const T=new Set;let h;function je(){h={r:0,c:[],p:h}}function xe(){h.r||m(h.c),h=h.p}function A(t,e){t&&t.i&&(T.delete(t),t.i(e))}function Q(t,e,n,r){if(t&&t.o){if(T.has(t))return;T.add(t),h.c.push(()=>{T.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function Ae(t,e){const n={},r={},o={$$scope:1};let s=t.length;for(;s--;){const a=t[s],i=e[s];if(i){for(const c in a)c in i||(r[c]=1);for(const c in i)o[c]||(n[c]=i[c],o[c]=1);t[s]=i}else for(const c in a)o[c]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ce(t){return typeof t=="object"&&t!==null?t:{}}function W(t){t&&t.c()}function C(t,e,n,r){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=t.$$;o&&o.m(e,n),r||j(()=>{const c=s.map(J).filter(ke);a?a.push(...c):m(c),t.$$.on_mount=[]}),i.forEach(j)}function I(t,e){const n=t.$$;n.fragment!==null&&(m(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ie(t,e){t.$$.dirty[0]===-1&&(k.push(t),Se(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Me(t,e,n,r,o,s,a,i=[-1]){const c=S;_(t);const l=t.$$={fragment:null,ctx:null,props:s,update:V,not_equal:o,bound:Y(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Y(),dirty:i,skip_bound:!1,root:e.target||c.$$.root};a&&a(l.root);let u=!1;if(l.ctx=n?n(t,e.props||{},(d,$,...ee)=>{const te=ee.length?ee[0]:$;return l.ctx&&o(l.ctx[d],l.ctx[d]=te)&&(!l.skip_bound&&l.bound[d]&&l.bound[d](te),u&&Ie(t,d)),$}):[],l.update(),u=!0,m(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const d=Oe(e.target);l.fragment&&l.fragment.l(d),d.forEach(F)}else l.fragment&&l.fragment.c();e.intro&&A(t.$$.fragment),C(t,e.target,e.anchor,e.customElement),K()}_(c)}class Ne{$destroy(){I(this,1),this.$destroy=V}$on(e,n){const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!ve(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function Be(t){let e,n,r;const o=[{blok:t[0]},t[2]];var s=t[1];function a(i){let c={};for(let l=0;l<o.length;l+=1)c=R(c,o[l]);return{props:c}}return s&&(e=new s(a())),{c(){e&&W(e.$$.fragment),n=Ee()},m(i,c){e&&C(e,i,c),Te(i,n,c),r=!0},p(i,[c]){const l=c&5?Ae(o,[c&1&&{blok:i[0]},c&4&&Ce(i[2])]):{};if(s!==(s=i[1])){if(e){je();const u=e;Q(u.$$.fragment,1,0,()=>{I(u,1)}),xe()}s?(e=new s(a()),W(e.$$.fragment),A(e.$$.fragment,1),C(e,n.parentNode,n)):e=null}else s&&e.$set(l)},i(i){r||(e&&A(e.$$.fragment,i),r=!0)},o(i){e&&Q(e.$$.fragment,i),r=!1},d(i){i&&F(n),e&&I(e,i)}}}function qe(t,e,n){const r=["blok"];let o=z(e,r),{blok:s}=e,a;return s?a=Z(s.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),t.$$set=i=>{e=R(R({},e),we(i)),n(2,o=z(e,r)),"blok"in i&&n(0,s=i.blok)},[s,a,o]}class Le extends Ne{constructor(e){super();Me(this,e,qe,Be,be,{blok:0})}}const De=(t,e)=>{const n=r=>{const o=ye(r);o["data-blok-c"]&&(t.setAttribute("data-blok-c",o["data-blok-c"]),t.setAttribute("data-blok-uid",o["data-blok-uid"]),t.classList.add("storyblok__outline"))};return n(e),{update(r){n(r)}}};let M=null;const Ue=()=>(M||console.log("You can't use useStoryblokApi if you're not loading apiPlugin."),M);let X=null;const Ve=t=>{const{storyblokApi:e}=_e(t);M=e,X=t.components||{}},Z=t=>{const e=X[t];return e||console.error(`You didn't load the ${t} component. Please load it in storyblokInit. For example:
5
+ */function D(t){return typeof t=="number"&&t==t&&t!==1/0&&t!==-1/0}function U(t,e,n){if(!D(e))throw new TypeError("Expected `limit` to be a finite number");if(!D(n))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],s=0,a=function(){s++;var l=setTimeout(function(){s--,r.length>0&&a(),o=o.filter(function(u){return u!==l})},n);o.indexOf(l)<0&&o.push(l);var c=r.shift();c.resolve(t.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,d){r.push({resolve:u,reject:d,args:l,self:c}),s<e&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(l){l.reject(new throttle.AbortError)}),r.length=0},i}U.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const fe=function(t,e){if(!t)return null;let n={};for(let r in t){let o=t[r];e.indexOf(r)>-1&&o!==null&&(n[r]=o)}return n};var de={nodes:{horizontal_rule:t=>({singleTag:"hr"}),blockquote:t=>({tag:"blockquote"}),bullet_list:t=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:t=>({singleTag:"br"}),heading:t=>({tag:"h"+t.attrs.level}),image:t=>({singleTag:[{tag:"img",attrs:fe(t.attrs,["src","alt","title"])}]}),list_item:t=>({tag:"li"}),ordered_list:t=>({tag:"ol"}),paragraph:t=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(t){const e=p({},t.attrs),{linktype:n="url"}=t.attrs;return n==="email"&&(e.href="mailto:"+e.href),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]})}};class he{constructor(e){e||(e=de),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,n){this.nodes[e]=n}addMark(e,n){this.marks[e]=n}render(e={}){if(e.content&&Array.isArray(e.content)){let n="";return e.content.forEach(r=>{n+=this.renderNode(r)}),n}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let n=[];e.marks&&e.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderOpeningTag(s.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&n.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{n.push(this.renderNode(o))}):e.text?n.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,l=>s[l]):o}(e.text)):r&&r.singleTag?n.push(this.renderTag(r.singleTag," /")):r&&r.html&&n.push(r.html),r&&r.tag&&n.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderClosingTag(s.tag))}),n.join("")}renderTag(e,n){return e.constructor===String?`<${e}${n}>`:e.map(r=>{if(r.constructor===String)return`<${r}${n}>`;{let o="<"+r.tag;if(r.attrs)for(let s in r.attrs){let a=r.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${n}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.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 pe=(t=0,e=t)=>{const n=Math.abs(e-t)||0,r=t<e?1:-1;return((o=0,s)=>[...Array(o)].map(s))(n,(o,s)=>s*r+t)},O=(t,e,n)=>{const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const s=t[o],a=n?"":encodeURIComponent(o);let i;i=typeof s=="object"?O(s,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),r.push(i)}return r.join("&")};let b={},g={};class ge{constructor(e,n){if(!n){let s=e.region?"-"+e.region:"",a=e.https===!1?"http":"https";n=e.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let r=Object.assign({},e.headers),o=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,o=3),e.rateLimit!==void 0&&(o=e.rateLimit),this.richTextResolver=new he(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=U(this.throttledRequest,o,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=oe.default.create({baseURL:n,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(s=>e.responseInterceptor(s))}setComponentResolver(e){this.richTextResolver.addNode("blok",n=>{let r="";return n.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,n={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(n):n}makeRequest(e,n,r,o){const s=this.factoryParamOptions(e,((a={},i=25,l=1)=>E(p({},a),{per_page:i,page:l}))(n,r,o));return this.cacheResponse(e,s)}get(e,n){let r="/"+e;const o=this.factoryParamOptions(r,n);return this.cacheResponse(r,o)}async getAll(e,n={},r){const o=n.per_page||25,s="/"+e,a=s.split("/");r=r||a[a.length-1];const i=await this.makeRequest(s,n,o,1),l=Math.ceil(i.total/o);return((c=[],u)=>c.map(u).reduce((d,$)=>[...d,...$],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))(pe(1,l),async c=>this.makeRequest(s,n,o,c+1))],c=>Object.values(c.data[r]))}post(e,n){let r="/"+e;return this.throttle("post",r,n)}put(e,n){let r="/"+e;return this.throttle("put",r,n)}delete(e,n){let r="/"+e;return this.throttle("delete",r,n)}getStories(e){return this.get("cdn/stories",e)}getStory(e,n){return this.get("cdn/stories/"+e,n)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,n){const r=e[n];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,n,r){if(r.indexOf(e.component+"."+n)>-1){if(typeof e[n]=="string")this.relations[e[n]]&&(e[n]=this._cleanCopy(this.relations[e[n]]));else if(e[n].constructor===Array){let o=[];e[n].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),e[n]=o}}}iterateTree(e,n){let r=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)r(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,s,n),this._insertLinks(o,s)),r(o[s])}}};r(e.content)}async resolveLinks(e,n){let r=[];if(e.link_uuids){const o=e.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(e.link_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=e.links;r.forEach(o=>{this.links[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveRelations(e,n){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(e.rel_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=e.rels;r.forEach(o=>{this.relations[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveStories(e,n){let r=[];n.resolve_relations!==void 0&&n.resolve_relations.length>0&&(r=n.resolve_relations.split(","),await this.resolveRelations(e,n)),["1","story","url"].indexOf(n.resolve_links)>-1&&await this.resolveLinks(e,n);for(const o in this.relations)this.iterateTree(this.relations[o],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(o=>{this.iterateTree(o,r)})}cacheResponse(e,n,r){return r===void 0&&(r=0),new Promise(async(o,s)=>{let a=O({url:e,params:n}),i=this.cacheProvider();if(this.cache.clear==="auto"&&n.version==="draft"&&await this.flushCache(),n.version==="published"&&e!="/cdn/spaces/me"){const c=await i.get(a);if(c)return o(c)}try{let c=await this.throttle("get",e,{params:n,paramsSerializer:d=>O(d)}),u={data:c.data,headers:c.headers};if(c.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(c.headers["per-page"]),total:parseInt(c.headers.total)})),c.status!=200)return s(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,n),n.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(n.version=="draft"&&g[n.token]!=u.data.cv&&this.flushCache(),g[n.token]=u.data.cv),o(u)}catch(c){if(c.response&&c.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(l=1e3*r,new Promise(u=>setTimeout(u,l))),this.cacheResponse(e,n,r).then(o).catch(s);s(c)}var l})}throttledRequest(e,n,r){return this.client[e](n,r)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>b[e],getAll:()=>b,set(e,n){b[e]=n},flush(){b={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var ye=(t={})=>{const{apiOptions:e}=t;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 ge(e)}},me=t=>{if(typeof t!="object"||typeof t._editable=="undefined")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const _e="https://app.storyblok.com/f/storyblok-v2-latest.js",ke=(t,e,n={})=>{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(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(n).on(["input","published","change"],o=>{o.action=="input"&&o.story.id===t?e(o.story):window.location.reload()})})}},be=(t={})=>{const{bridge:e,accessToken:n,use:r=[],apiOptions:o={}}=t;o.accessToken=o.accessToken||n;const s={bridge:e,apiOptions:o};let a={};return r.forEach(i=>{a=p(p({},a),i(s))}),e!==!1&&ue(_e),a};function V(){}function S(t,e){for(const n in e)t[n]=e[n];return t}function J(t){return t()}function Y(){return Object.create(null)}function m(t){t.forEach(J)}function ve(t){return typeof t=="function"}function we(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Te(t){return Object.keys(t).length===0}function $e(t){const e={};for(const n in t)n[0]!=="$"&&(e[n]=t[n]);return e}function z(t,e){const n={};e=new Set(e);for(const r in t)!e.has(r)&&r[0]!=="$"&&(n[r]=t[r]);return n}function Ee(t,e,n){t.insertBefore(e,n||null)}function F(t){t.parentNode.removeChild(t)}function Oe(t){return document.createTextNode(t)}function Se(){return Oe("")}function Pe(t){return Array.from(t.childNodes)}let P;function _(t){P=t}const k=[],H=[],v=[],G=[],Re=Promise.resolve();let R=!1;function je(){R||(R=!0,Re.then(K))}function j(t){v.push(t)}const x=new Set;let w=0;function K(){const t=P;do{for(;w<k.length;){const e=k[w];w++,_(e),xe(e.$$)}for(_(null),k.length=0,w=0;H.length;)H.pop()();for(let e=0;e<v.length;e+=1){const n=v[e];x.has(n)||(x.add(n),n())}v.length=0}while(k.length);for(;G.length;)G.pop()();R=!1,x.clear(),_(t)}function xe(t){if(t.fragment!==null){t.update(),m(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const T=new Set;let h;function Ae(){h={r:0,c:[],p:h}}function Ce(){h.r||m(h.c),h=h.p}function A(t,e){t&&t.i&&(T.delete(t),t.i(e))}function Q(t,e,n,r){if(t&&t.o){if(T.has(t))return;T.add(t),h.c.push(()=>{T.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function Ie(t,e){const n={},r={},o={$$scope:1};let s=t.length;for(;s--;){const a=t[s],i=e[s];if(i){for(const l in a)l in i||(r[l]=1);for(const l in i)o[l]||(n[l]=i[l],o[l]=1);t[s]=i}else for(const l in a)o[l]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Me(t){return typeof t=="object"&&t!==null?t:{}}function W(t){t&&t.c()}function C(t,e,n,r){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=t.$$;o&&o.m(e,n),r||j(()=>{const l=s.map(J).filter(ve);a?a.push(...l):m(l),t.$$.on_mount=[]}),i.forEach(j)}function I(t,e){const n=t.$$;n.fragment!==null&&(m(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ne(t,e){t.$$.dirty[0]===-1&&(k.push(t),je(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Be(t,e,n,r,o,s,a,i=[-1]){const l=P;_(t);const c=t.$$={fragment:null,ctx:null,props:s,update:V,not_equal:o,bound:Y(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Y(),dirty:i,skip_bound:!1,root:e.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=n?n(t,e.props||{},(d,$,...te)=>{const ne=te.length?te[0]:$;return c.ctx&&o(c.ctx[d],c.ctx[d]=ne)&&(!c.skip_bound&&c.bound[d]&&c.bound[d](ne),u&&Ne(t,d)),$}):[],c.update(),u=!0,m(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){const d=Pe(e.target);c.fragment&&c.fragment.l(d),d.forEach(F)}else c.fragment&&c.fragment.c();e.intro&&A(t.$$.fragment),C(t,e.target,e.anchor,e.customElement),K()}_(l)}class Le{$destroy(){I(this,1),this.$destroy=V}$on(e,n){const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function qe(t){let e,n,r;const o=[{blok:t[0]},t[2]];var s=t[1];function a(i){let l={};for(let c=0;c<o.length;c+=1)l=S(l,o[c]);return{props:l}}return s&&(e=new s(a())),{c(){e&&W(e.$$.fragment),n=Se()},m(i,l){e&&C(e,i,l),Ee(i,n,l),r=!0},p(i,[l]){const c=l&5?Ie(o,[l&1&&{blok:i[0]},l&4&&Me(i[2])]):{};if(s!==(s=i[1])){if(e){Ae();const u=e;Q(u.$$.fragment,1,0,()=>{I(u,1)}),Ce()}s?(e=new s(a()),W(e.$$.fragment),A(e.$$.fragment,1),C(e,n.parentNode,n)):e=null}else s&&e.$set(c)},i(i){r||(e&&A(e.$$.fragment,i),r=!0)},o(i){e&&Q(e.$$.fragment,i),r=!1},d(i){i&&F(n),e&&I(e,i)}}}function De(t,e,n){const r=["blok"];let o=z(e,r),{blok:s}=e,a;return s?a=ee(s.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),t.$$set=i=>{e=S(S({},e),$e(i)),n(2,o=z(e,r)),"blok"in i&&n(0,s=i.blok)},[s,a,o]}class Ue extends Le{constructor(e){super();Be(this,e,De,qe,we,{blok:0})}}const Ve=(t,e)=>{const n=r=>{const o=me(r);o["data-blok-c"]&&(t.setAttribute("data-blok-c",o["data-blok-c"]),t.setAttribute("data-blok-uid",o["data-blok-uid"]),t.classList.add("storyblok__outline"))};return n(e),{update(r){n(r)}}};let M=null;const X=()=>(M||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),M);let Z=null;const Je=t=>{const{storyblokApi:e}=be(t);M=e,Z=t.components||{}},ee=t=>{const e=Z[t];return e||console.error(`You didn't load the ${t} component. Please load it in storyblokInit. For example:
6
6
  storyblokInit({
7
7
  accessToken: "<your-token>",
8
8
  components: {
9
9
  "teaser": Teaser
10
10
  }
11
11
  })
12
- `),e};f.StoryblokComponent=Le,f.apiPlugin=ge,f.getComponent=Z,f.storyblokEditable=De,f.storyblokInit=Ve,f.useStoryblokApi=Ue,f.useStoryblokBridge=me,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
12
+ `),e};f.StoryblokComponent=Ue,f.apiPlugin=ye,f.getComponent=ee,f.getStoryblokApi=X,f.storyblokEditable=Ve,f.storyblokInit=Je,f.useStoryblokApi=X,f.useStoryblokBridge=ke,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
@@ -406,6 +406,7 @@ var editable = (blok) => {
406
406
  "data-blok-uid": options.id + "-" + options.uid
407
407
  };
408
408
  };
409
+ const bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js";
409
410
  const useStoryblokBridge = (id, cb, options = {}) => {
410
411
  if (typeof window === "undefined") {
411
412
  return;
@@ -414,6 +415,10 @@ const useStoryblokBridge = (id, cb, options = {}) => {
414
415
  console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
415
416
  return;
416
417
  }
418
+ if (!id) {
419
+ console.warn("Story ID is not defined. Please provide a valid ID.");
420
+ return;
421
+ }
417
422
  window.storyblokRegisterEvent(() => {
418
423
  const sbBridge = new window.StoryblokBridge(options);
419
424
  sbBridge.on(["input", "published", "change"], (event) => {
@@ -434,7 +439,7 @@ const storyblokInit$1 = (pluginOptions = {}) => {
434
439
  result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
435
440
  });
436
441
  if (bridge !== false) {
437
- loadBridge("https://app.storyblok.com/f/storyblok-v2-latest.js");
442
+ loadBridge(bridgeLatest);
438
443
  }
439
444
  return result;
440
445
  };
@@ -854,7 +859,7 @@ const storyblokEditable = (node, value) => {
854
859
  let storyblokApiInstance = null;
855
860
  const useStoryblokApi = () => {
856
861
  if (!storyblokApiInstance) {
857
- console.log(`You can't use useStoryblokApi if you're not loading apiPlugin.`);
862
+ console.log(`You can't use getStoryblokApi if you're not loading apiPlugin.`);
858
863
  }
859
864
  return storyblokApiInstance;
860
865
  };
@@ -878,4 +883,4 @@ storyblokInit({
878
883
  }
879
884
  return component;
880
885
  };
881
- export { StoryblokComponent, api as apiPlugin, getComponent, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
886
+ export { StoryblokComponent, api as apiPlugin, getComponent, useStoryblokApi as getStoryblokApi, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
package/index.js CHANGED
@@ -28,12 +28,14 @@ let storyblokApiInstance = null;
28
28
  export const useStoryblokApi = () => {
29
29
  if (!storyblokApiInstance) {
30
30
  console.log(
31
- `You can't use useStoryblokApi if you're not loading apiPlugin.`
31
+ `You can't use getStoryblokApi if you're not loading apiPlugin.`
32
32
  );
33
33
  }
34
34
  return storyblokApiInstance;
35
35
  };
36
36
 
37
+ export { useStoryblokApi as getStoryblokApi };
38
+
37
39
  let componentsMap = null;
38
40
  export const storyblokInit = (options) => {
39
41
  const { storyblokApi } = sbInit(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/svelte",
3
- "version": "2.0.1",
3
+ "version": "2.0.4",
4
4
  "description": "Storyblok SDK to connect Storyblok with Svelte",
5
5
  "main": "./dist/storyblok-svelte.js",
6
6
  "module": "./dist/storyblok-svelte.mjs",
@@ -26,18 +26,18 @@
26
26
  "prepublishOnly": "npm run build && cp ../README.md ./"
27
27
  },
28
28
  "dependencies": {
29
- "@storyblok/js": "^1.0.3"
29
+ "@storyblok/js": "^1.1.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/core": "^7.15.0",
32
+ "@babel/core": "^7.17.9",
33
33
  "@cypress/vite-dev-server": "^2.2.2",
34
34
  "babel-jest": "^27.5.1",
35
- "cypress": "^9.4.1",
35
+ "cypress": "^9.5.3",
36
36
  "cypress-svelte-unit-test": "^3.3.4",
37
37
  "eslint-plugin-cypress": "^2.12.1",
38
- "eslint-plugin-jest": "^26.1.1",
38
+ "eslint-plugin-jest": "^26.1.3",
39
39
  "jest": "^27.5.1",
40
- "vite": "^2.4.4"
40
+ "vite": "^2.9.1"
41
41
  },
42
42
  "eslintConfig": {
43
43
  "env": {