@storyblok/vue 6.3.1 → 6.3.2

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.
@@ -2,51 +2,7 @@ import type { SbBlokData } from "./types";
2
2
  export interface SbComponentProps {
3
3
  blok: SbBlokData;
4
4
  }
5
- declare const _default: {
6
- new (...args: any[]): {
7
- $: import("vue").ComponentInternalInstance;
8
- $data: {};
9
- $props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
10
- $attrs: {
11
- [x: string]: unknown;
12
- };
13
- $refs: {
14
- [x: string]: unknown;
15
- };
16
- $slots: Readonly<{
17
- [name: string]: import("vue").Slot;
18
- }>;
19
- $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
20
- $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
21
- $emit: (event: string, ...args: any[]) => void;
22
- $el: any;
23
- $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {}> & {
24
- beforeCreate?: (() => void) | (() => void)[];
25
- created?: (() => void) | (() => void)[];
26
- beforeMount?: (() => void) | (() => void)[];
27
- mounted?: (() => void) | (() => void)[];
28
- beforeUpdate?: (() => void) | (() => void)[];
29
- updated?: (() => void) | (() => void)[];
30
- activated?: (() => void) | (() => void)[];
31
- deactivated?: (() => void) | (() => void)[];
32
- beforeDestroy?: (() => void) | (() => void)[];
33
- beforeUnmount?: (() => void) | (() => void)[];
34
- destroyed?: (() => void) | (() => void)[];
35
- unmounted?: (() => void) | (() => void)[];
36
- renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
37
- renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
38
- errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void)[];
39
- };
40
- $forceUpdate: () => void;
41
- $nextTick: typeof import("vue").nextTick;
42
- $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean>): import("vue").WatchStopHandle;
43
- } & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>> & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
44
- __isFragment?: never;
45
- __isTeleport?: never;
46
- __isSuspense?: never;
47
- } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
48
- $slots: {};
49
- });
5
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<SbComponentProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<SbComponentProps>>>, {}>;
50
6
  export default _default;
51
7
  declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
52
8
  declare type __VLS_TypePropsToRuntimeProps<T> = {
@@ -2,7 +2,7 @@
2
2
  * storyblok-js-client v4.5.2
3
3
  * Universal JavaScript SDK for Storyblok's API
4
4
  * (c) 2020-2022 Stobylok Team
5
- */function E(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function O(n,e,t){if(!E(e))throw new TypeError("Expected `limit` to be a finite number");if(!E(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],o=0,a=function(){o++;var c=setTimeout(function(){o--,r.length>0&&a(),s=s.filter(function(u){return u!==c})},t);s.indexOf(c)<0&&s.push(c);var l=r.shift();l.resolve(n.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,y){r.push({resolve:u,reject:y,args:c,self:l}),o<e&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}O.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const H=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t};var J={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:H(n.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const e=p({},n.attrs),{linktype:t="url"}=n.attrs;return t==="email"&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class Y{constructor(e){e||(e=J),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,c=>o[c]):s}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs)for(let o in r.attrs){let a=r.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const F=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return((s=0,o)=>[...Array(s)].map(o))(t,(s,o)=>o*r+n)},v=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],a=t?"":encodeURIComponent(s);let i;i=typeof o=="object"?v(o,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),r.push(i)}return r.join("&")};let m={},f={};class K{constructor(e,t){if(!t){let o=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let r=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new Y(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=O(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=M.default.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(o=>e.responseInterceptor(o)),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=f[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const o=this.factoryParamOptions(e,((a={},i=25,c=1)=>b(p({},a),{per_page:i,page:c}))(t,r,s));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const s=this.factoryParamOptions(r,t);return this.cacheResponse(r,s)}async getAll(e,t={},r){const s=t.per_page||25,o=`/${e}`,a=o.split("/");r=r||a[a.length-1];const i=await this.makeRequest(o,t,s,1),c=Math.ceil(i.total/s);return((l=[],u)=>l.map(u).reduce((y,ne)=>[...y,...ne],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(F(1,c),async l=>this.makeRequest(o,t,s,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let s=[];e[t].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),e[t]=s}}}_insertAssetsRelations(e,t){t.forEach(r=>{e.id===r.id&&(e.original=r,e.original.filename=e.filename,e.original.filename=e.original.filename.includes("https://s3.amazonaws.com/")?e.original.filename:e.original.filename.replace("https://","https://s3.amazonaws.com/"),delete e.original.s3_filename)})}iterateTree(e,t){let r=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)r(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,t),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,t),r(s[o])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const s=e.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.link_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(s=>{this.links[s.uuid]=b(p({},s),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const s=e.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.rel_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(s=>{this.relations[s.uuid]=b(p({},s),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];if(t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(e.rels||e.rel_uuids)&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&(e.links||e.link_uuids)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(s=>{this.iterateTree(s,r)})}resolveAssetsRelations(e){const{assets:t,stories:r,story:s}=e;if(r)for(const o of r)this.iterateTree(o,t);else{if(!s)return e;this.iterateTree(s,t)}}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(s,o)=>{let a=v({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(a);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:y=>v(y)}),u={data:l.data,headers:l.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return o(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(t.version=="draft"&&f[t.token]!=u.data.cv&&this.flushCache(),f[t.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,t,r).then(s).catch(o);o(l)}var c})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return f}cacheVersion(){return f[this.accessToken]}setCacheVersion(e){this.accessToken&&(f[this.accessToken]=e)}cacheProvider(){return this.cache.type==="memory"?{get:e=>m[e],getAll:()=>m,set(e,t){m[e]=t},flush(){m={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const G=(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 K(e)}};var Q=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let k;const W="https://app.storyblok.com/f/storyblok-v2-latest.js",P=(n,e,t={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){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(t).on(["input","published","change"],s=>{s.story.id===n&&(s.action==="input"?e(s.story):window.location.reload())})})}},X=(n={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:s={},richText:o={}}=n;s.accessToken=s.accessToken||t;const a={bridge:e,apiOptions:s};let i={};return r.forEach(c=>{i=p(p({},i),c(a))}),e!==!1&&z(W),k=new S(o.schema),o.resolver&&j(k,o.resolver),i},j=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Z=(n,e)=>{if(!k){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}if(n==="")return"";if(!n)return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
5
+ */function E(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function O(n,e,t){if(!E(e))throw new TypeError("Expected `limit` to be a finite number");if(!E(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],o=0,a=function(){o++;var c=setTimeout(function(){o--,r.length>0&&a(),s=s.filter(function(u){return u!==c})},t);s.indexOf(c)<0&&s.push(c);var l=r.shift();l.resolve(n.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,y){r.push({resolve:u,reject:y,args:c,self:l}),o<e&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}O.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const H=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t};var J={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:H(n.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const e=p({},n.attrs),{linktype:t="url"}=n.attrs;return t==="email"&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class Y{constructor(e){e||(e=J),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,c=>o[c]):s}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs)for(let o in r.attrs){let a=r.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const F=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return((s=0,o)=>[...Array(s)].map(o))(t,(s,o)=>o*r+n)},v=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],a=t?"":encodeURIComponent(s);let i;i=typeof o=="object"?v(o,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),r.push(i)}return r.join("&")};let m={},f={};class K{constructor(e,t){if(!t){let o=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let r=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new Y(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=O(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=M.default.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(o=>e.responseInterceptor(o)),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=f[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const o=this.factoryParamOptions(e,((a={},i=25,c=1)=>b(p({},a),{per_page:i,page:c}))(t,r,s));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const s=this.factoryParamOptions(r,t);return this.cacheResponse(r,s)}async getAll(e,t={},r){const s=t.per_page||25,o=`/${e}`,a=o.split("/");r=r||a[a.length-1];const i=await this.makeRequest(o,t,s,1),c=Math.ceil(i.total/s);return((l=[],u)=>l.map(u).reduce((y,ne)=>[...y,...ne],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(F(1,c),async l=>this.makeRequest(o,t,s,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let s=[];e[t].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),e[t]=s}}}_insertAssetsRelations(e,t){t.forEach(r=>{e.id===r.id&&(e.original=r,e.original.filename=e.filename,e.original.filename=e.original.filename.includes("https://s3.amazonaws.com/")?e.original.filename:e.original.filename.replace("https://","https://s3.amazonaws.com/"),delete e.original.s3_filename)})}iterateTree(e,t){let r=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)r(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,t),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,t),r(s[o])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const s=e.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.link_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(s=>{this.links[s.uuid]=b(p({},s),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const s=e.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.rel_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(s=>{this.relations[s.uuid]=b(p({},s),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];if(t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(e.rels||e.rel_uuids)&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&(e.links||e.link_uuids)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(s=>{this.iterateTree(s,r)})}resolveAssetsRelations(e){const{assets:t,stories:r,story:s}=e;if(r)for(const o of r)this.iterateTree(o,t);else{if(!s)return e;this.iterateTree(s,t)}}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(s,o)=>{let a=v({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(a);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:y=>v(y)}),u={data:l.data,headers:l.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return o(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(t.version=="draft"&&f[t.token]!=u.data.cv&&this.flushCache(),f[t.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,t,r).then(s).catch(o);o(l)}var c})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return f}cacheVersion(){return f[this.accessToken]}setCacheVersion(e){this.accessToken&&(f[this.accessToken]=e)}cacheProvider(){return this.cache.type==="memory"?{get:e=>m[e],getAll:()=>m,set(e,t){m[e]=t},flush(){m={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const G=(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 K(e)}};var Q=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let k;const W="https://app.storyblok.com/f/storyblok-v2-latest.js",P=(n,e,t={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){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(t).on(["input","published","change"],s=>{s.action==="input"&&s.story.id===n?e(s.story):(s.action==="change"||s.action==="published")&&s.storyId===n&&window.location.reload()})})}},X=(n={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:s={},richText:o={}}=n;s.accessToken=s.accessToken||t;const a={bridge:e,apiOptions:s};let i={};return r.forEach(c=>{i=p(p({},i),c(a))}),e!==!1&&z(W),k=new S(o.schema),o.resolver&&j(k,o.resolver),i},j=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Z=(n,e)=>{if(!k){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}if(n==="")return"";if(!n)return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
6
6
 
7
7
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"";let t=k;return e&&(t=new S(e.schema),e.resolver&&j(t,e.resolver)),t.render(n)},A=d.defineComponent({__name:"StoryblokComponent",props:{blok:null},setup(n){return(e,t)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.blok.component),d.normalizeProps(d.guardReactiveProps({...e.$props,...e.$attrs})),null,16))}}),ee={beforeMount(n,e){if(e.value){const t=Q(e.value);n.setAttribute("data-blok-c",t["data-blok-c"]),n.setAttribute("data-blok-uid",t["data-blok-uid"]),n.classList.add("storyblok__outline")}}},x=n=>{console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
8
  `)};let g=null;const te=()=>(g||x("useStoryblokApi"),g),re=async(n,e={},t={})=>{const r=d.ref(null);if(d.onMounted(()=>{r.value&&r.value.id&&P(r.value.id,s=>r.value=s,t)}),g){const{data:s}=await g.get(`cdn/stories/${n}`,e);r.value=s.story}else x("useStoryblok");return r},se={install(n,e={}){n.directive("editable",ee),n.component("StoryblokComponent",A);const{storyblokApi:t}=X(e);g=t}};h.RichTextSchema=$,h.StoryblokComponent=A,h.StoryblokVue=se,h.apiPlugin=G,h.renderRichText=Z,h.useStoryblok=re,h.useStoryblokApi=te,h.useStoryblokBridge=P,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,15 +1,15 @@
1
1
  import { defineComponent as P, openBlock as j, createBlock as x, resolveDynamicComponent as A, normalizeProps as C, guardReactiveProps as M, ref as N, onMounted as I } from "vue";
2
2
  import q from "axios";
3
- var L = Object.defineProperty, z = Object.defineProperties, B = Object.getOwnPropertyDescriptors, v = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, h = (n, t) => {
3
+ var L = Object.defineProperty, z = Object.defineProperties, B = Object.getOwnPropertyDescriptors, b = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, v = (o, t, e) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, h = (o, t) => {
4
4
  for (var e in t || (t = {}))
5
- D.call(t, e) && b(n, e, t[e]);
6
- if (v)
7
- for (var e of v(t))
8
- U.call(t, e) && b(n, e, t[e]);
9
- return n;
10
- }, y = (n, t) => z(n, B(t));
5
+ D.call(t, e) && v(o, e, t[e]);
6
+ if (b)
7
+ for (var e of b(t))
8
+ U.call(t, e) && v(o, e, t[e]);
9
+ return o;
10
+ }, y = (o, t) => z(o, B(t));
11
11
  let _ = !1;
12
- const T = [], V = (n) => new Promise((t, e) => {
12
+ const T = [], V = (o) => new Promise((t, e) => {
13
13
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
14
14
  if (window.location === window.parent.location) {
15
15
  console.warn("You are not in Draft Mode or in the Visual Editor.");
@@ -19,19 +19,19 @@ const T = [], V = (n) => new Promise((t, e) => {
19
19
  }, document.getElementById("storyblok-javascript-bridge")))
20
20
  return;
21
21
  const r = document.createElement("script");
22
- r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
23
- T.forEach((o) => o()), _ = !0, t(s);
22
+ r.async = !0, r.src = o, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
23
+ T.forEach((n) => n()), _ = !0, t(s);
24
24
  }, document.getElementsByTagName("head")[0].appendChild(r);
25
- }), H = function(n, t) {
26
- if (!n)
25
+ }), H = function(o, t) {
26
+ if (!o)
27
27
  return null;
28
28
  let e = {};
29
- for (let r in n) {
30
- let s = n[r];
29
+ for (let r in o) {
30
+ let s = o[r];
31
31
  t.indexOf(r) > -1 && s !== null && (e[r] = s);
32
32
  }
33
33
  return e;
34
- }, J = (n) => n === "email";
34
+ }, J = (o) => o === "email";
35
35
  var Y = {
36
36
  nodes: {
37
37
  horizontal_rule() {
@@ -49,13 +49,13 @@ var Y = {
49
49
  tag: "ul"
50
50
  };
51
51
  },
52
- code_block(n) {
52
+ code_block(o) {
53
53
  return {
54
54
  tag: [
55
55
  "pre",
56
56
  {
57
57
  tag: "code",
58
- attrs: n.attrs
58
+ attrs: o.attrs
59
59
  }
60
60
  ]
61
61
  };
@@ -65,17 +65,17 @@ var Y = {
65
65
  singleTag: "br"
66
66
  };
67
67
  },
68
- heading(n) {
68
+ heading(o) {
69
69
  return {
70
- tag: `h${n.attrs.level}`
70
+ tag: `h${o.attrs.level}`
71
71
  };
72
72
  },
73
- image(n) {
73
+ image(o) {
74
74
  return {
75
75
  singleTag: [
76
76
  {
77
77
  tag: "img",
78
- attrs: H(n.attrs, ["src", "alt", "title"])
78
+ attrs: H(o.attrs, ["src", "alt", "title"])
79
79
  }
80
80
  ]
81
81
  };
@@ -127,8 +127,8 @@ var Y = {
127
127
  tag: "i"
128
128
  };
129
129
  },
130
- link(n) {
131
- const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
130
+ link(o) {
131
+ const t = h({}, o.attrs), { linktype: e = "url" } = o.attrs;
132
132
  return J(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
133
133
  tag: [
134
134
  {
@@ -138,19 +138,19 @@ var Y = {
138
138
  ]
139
139
  };
140
140
  },
141
- styled(n) {
141
+ styled(o) {
142
142
  return {
143
143
  tag: [
144
144
  {
145
145
  tag: "span",
146
- attrs: n.attrs
146
+ attrs: o.attrs
147
147
  }
148
148
  ]
149
149
  };
150
150
  }
151
151
  }
152
152
  };
153
- const F = function(n) {
153
+ const F = function(o) {
154
154
  const t = {
155
155
  "&": "&amp;",
156
156
  "<": "&lt;",
@@ -158,7 +158,7 @@ const F = function(n) {
158
158
  '"': "&quot;",
159
159
  "'": "&#39;"
160
160
  }, e = /[&<>"']/g, r = RegExp(e.source);
161
- return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
161
+ return o && r.test(o) ? o.replace(e, (s) => t[s]) : o;
162
162
  };
163
163
  class R {
164
164
  constructor(t) {
@@ -182,15 +182,15 @@ class R {
182
182
  renderNode(t) {
183
183
  let e = [];
184
184
  t.marks && t.marks.forEach((s) => {
185
- const o = this.getMatchingMark(s);
186
- o && e.push(this.renderOpeningTag(o.tag));
185
+ const n = this.getMatchingMark(s);
186
+ n && e.push(this.renderOpeningTag(n.tag));
187
187
  });
188
188
  const r = this.getMatchingNode(t);
189
189
  return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
190
190
  e.push(this.renderNode(s));
191
191
  }) : t.text ? e.push(F(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
192
- const o = this.getMatchingMark(s);
193
- o && e.push(this.renderClosingTag(o.tag));
192
+ const n = this.getMatchingMark(s);
193
+ n && e.push(this.renderClosingTag(n.tag));
194
194
  }), e.join("");
195
195
  }
196
196
  renderTag(t, e) {
@@ -198,13 +198,13 @@ class R {
198
198
  if (s.constructor === String)
199
199
  return `<${s}${e}>`;
200
200
  {
201
- let o = `<${s.tag}`;
201
+ let n = `<${s.tag}`;
202
202
  if (s.attrs)
203
203
  for (let a in s.attrs) {
204
204
  let i = s.attrs[a];
205
- i !== null && (o += ` ${a}="${i}"`);
205
+ i !== null && (n += ` ${a}="${i}"`);
206
206
  }
207
- return `${o}${e}>`;
207
+ return `${n}${e}>`;
208
208
  }
209
209
  }).join("");
210
210
  }
@@ -228,28 +228,28 @@ class R {
228
228
  * Universal JavaScript SDK for Storyblok's API
229
229
  * (c) 2020-2022 Stobylok Team
230
230
  */
231
- function w(n) {
232
- return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
231
+ function w(o) {
232
+ return typeof o == "number" && o == o && o !== 1 / 0 && o !== -1 / 0;
233
233
  }
234
- function $(n, t, e) {
234
+ function $(o, t, e) {
235
235
  if (!w(t))
236
236
  throw new TypeError("Expected `limit` to be a finite number");
237
237
  if (!w(e))
238
238
  throw new TypeError("Expected `interval` to be a finite number");
239
- var r = [], s = [], o = 0, a = function() {
240
- o++;
239
+ var r = [], s = [], n = 0, a = function() {
240
+ n++;
241
241
  var c = setTimeout(function() {
242
- o--, r.length > 0 && a(), s = s.filter(function(u) {
242
+ n--, r.length > 0 && a(), s = s.filter(function(u) {
243
243
  return u !== c;
244
244
  });
245
245
  }, e);
246
246
  s.indexOf(c) < 0 && s.push(c);
247
247
  var l = r.shift();
248
- l.resolve(n.apply(l.self, l.args));
248
+ l.resolve(o.apply(l.self, l.args));
249
249
  }, i = function() {
250
250
  var c = arguments, l = this;
251
251
  return new Promise(function(u, p) {
252
- r.push({ resolve: u, reject: p, args: c, self: l }), o < t && a();
252
+ r.push({ resolve: u, reject: p, args: c, self: l }), n < t && a();
253
253
  });
254
254
  };
255
255
  return i.abort = function() {
@@ -261,20 +261,20 @@ function $(n, t, e) {
261
261
  $.AbortError = function() {
262
262
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
263
263
  };
264
- const K = function(n, t) {
265
- if (!n)
264
+ const K = function(o, t) {
265
+ if (!o)
266
266
  return null;
267
267
  let e = {};
268
- for (let r in n) {
269
- let s = n[r];
268
+ for (let r in o) {
269
+ let s = o[r];
270
270
  t.indexOf(r) > -1 && s !== null && (e[r] = s);
271
271
  }
272
272
  return e;
273
273
  };
274
- var G = { 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: K(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) {
275
- const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
274
+ var G = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (o) => ({ tag: ["pre", { tag: "code", attrs: o.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (o) => ({ tag: `h${o.attrs.level}` }), image: (o) => ({ singleTag: [{ tag: "img", attrs: K(o.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(o) {
275
+ const t = h({}, o.attrs), { linktype: e = "url" } = o.attrs;
276
276
  return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
277
- }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
277
+ }, styled: (o) => ({ tag: [{ tag: "span", attrs: o.attrs }] }) } };
278
278
  class Q {
279
279
  constructor(t) {
280
280
  t || (t = G), this.marks = t.marks || [], this.nodes = t.nodes || [];
@@ -297,18 +297,18 @@ class Q {
297
297
  renderNode(t) {
298
298
  let e = [];
299
299
  t.marks && t.marks.forEach((s) => {
300
- const o = this.getMatchingMark(s);
301
- o && e.push(this.renderOpeningTag(o.tag));
300
+ const n = this.getMatchingMark(s);
301
+ n && e.push(this.renderOpeningTag(n.tag));
302
302
  });
303
303
  const r = this.getMatchingNode(t);
304
304
  return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
305
305
  e.push(this.renderNode(s));
306
306
  }) : t.text ? e.push(function(s) {
307
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
308
- return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
307
+ const n = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
308
+ return s && i.test(s) ? s.replace(a, (c) => n[c]) : s;
309
309
  }(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
310
- const o = this.getMatchingMark(s);
311
- o && e.push(this.renderClosingTag(o.tag));
310
+ const n = this.getMatchingMark(s);
311
+ n && e.push(this.renderClosingTag(n.tag));
312
312
  }), e.join("");
313
313
  }
314
314
  renderTag(t, e) {
@@ -318,9 +318,9 @@ class Q {
318
318
  {
319
319
  let s = `<${r.tag}`;
320
320
  if (r.attrs)
321
- for (let o in r.attrs) {
322
- let a = r.attrs[o];
323
- a !== null && (s += ` ${o}="${a}"`);
321
+ for (let n in r.attrs) {
322
+ let a = r.attrs[n];
323
+ a !== null && (s += ` ${n}="${a}"`);
324
324
  }
325
325
  return `${s}${e}>`;
326
326
  }
@@ -341,17 +341,17 @@ class Q {
341
341
  return this.marks[t.type](t);
342
342
  }
343
343
  }
344
- const W = (n = 0, t = n) => {
345
- const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
346
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
347
- }, k = (n, t, e) => {
344
+ const W = (o = 0, t = o) => {
345
+ const e = Math.abs(t - o) || 0, r = o < t ? 1 : -1;
346
+ return ((s = 0, n) => [...Array(s)].map(n))(e, (s, n) => n * r + o);
347
+ }, k = (o, t, e) => {
348
348
  const r = [];
349
- for (const s in n) {
350
- if (!Object.prototype.hasOwnProperty.call(n, s))
349
+ for (const s in o) {
350
+ if (!Object.prototype.hasOwnProperty.call(o, s))
351
351
  continue;
352
- const o = n[s], a = e ? "" : encodeURIComponent(s);
352
+ const n = o[s], a = e ? "" : encodeURIComponent(s);
353
353
  let i;
354
- i = typeof o == "object" ? k(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
354
+ i = typeof n == "object" ? k(n, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(n)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(n), r.push(i);
355
355
  }
356
356
  return r.join("&");
357
357
  };
@@ -359,11 +359,11 @@ let f = {}, d = {};
359
359
  class X {
360
360
  constructor(t, e) {
361
361
  if (!e) {
362
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
363
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
362
+ let n = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
363
+ e = t.oauthToken === void 0 ? `${a}://api${n}.storyblok.com/v2` : `${a}://api${n}.storyblok.com/v1`;
364
364
  }
365
365
  let r = Object.assign({}, t.headers), s = 5;
366
- t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new Q(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = q.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
366
+ t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new Q(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = q.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((n) => t.responseInterceptor(n)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
367
367
  }
368
368
  setComponentResolver(t) {
369
369
  this.richTextResolver.addNode("blok", (e) => {
@@ -380,8 +380,8 @@ class X {
380
380
  return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
381
381
  }
382
382
  makeRequest(t, e, r, s) {
383
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(h({}, a), { per_page: i, page: c }))(e, r, s));
384
- return this.cacheResponse(t, o);
383
+ const n = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(h({}, a), { per_page: i, page: c }))(e, r, s));
384
+ return this.cacheResponse(t, n);
385
385
  }
386
386
  get(t, e) {
387
387
  let r = `/${t}`;
@@ -389,10 +389,10 @@ class X {
389
389
  return this.cacheResponse(r, s);
390
390
  }
391
391
  async getAll(t, e = {}, r) {
392
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
392
+ const s = e.per_page || 25, n = `/${t}`, a = n.split("/");
393
393
  r = r || a[a.length - 1];
394
- const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
395
- return ((l = [], u) => l.map(u).reduce((p, O) => [...p, ...O], []))([i, ...await (async (l = [], u) => Promise.all(l.map(u)))(W(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
394
+ const i = await this.makeRequest(n, e, s, 1), c = Math.ceil(i.total / s);
395
+ return ((l = [], u) => l.map(u).reduce((p, O) => [...p, ...O], []))([i, ...await (async (l = [], u) => Promise.all(l.map(u)))(W(1, c), async (l) => this.makeRequest(n, e, s, l + 1))], (l) => Object.values(l.data[r]));
396
396
  }
397
397
  post(t, e) {
398
398
  let r = `/${t}`;
@@ -431,8 +431,8 @@ class X {
431
431
  this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
432
432
  else if (t[e].constructor === Array) {
433
433
  let s = [];
434
- t[e].forEach((o) => {
435
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
434
+ t[e].forEach((n) => {
435
+ this.relations[n] && s.push(this._cleanCopy(this.relations[n]));
436
436
  }), t[e] = s;
437
437
  }
438
438
  }
@@ -446,13 +446,13 @@ class X {
446
446
  let r = (s) => {
447
447
  if (s != null) {
448
448
  if (s.constructor === Array)
449
- for (let o = 0; o < s.length; o++)
450
- r(s[o]);
449
+ for (let n = 0; n < s.length; n++)
450
+ r(s[n]);
451
451
  else if (s.constructor === Object) {
452
452
  if (s._stopResolving)
453
453
  return;
454
- for (let o in s)
455
- s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
454
+ for (let n in s)
455
+ s.component && s._uid || s.type === "link" ? (this._insertRelations(s, n, e), this._insertLinks(s, n)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[n]);
456
456
  }
457
457
  }
458
458
  };
@@ -462,14 +462,14 @@ class X {
462
462
  let r = [];
463
463
  if (t.link_uuids) {
464
464
  const s = t.link_uuids.length;
465
- let o = [];
465
+ let n = [];
466
466
  const a = 50;
467
467
  for (let i = 0; i < s; i += a) {
468
468
  const c = Math.min(s, i + a);
469
- o.push(t.link_uuids.slice(i, c));
469
+ n.push(t.link_uuids.slice(i, c));
470
470
  }
471
- for (let i = 0; i < o.length; i++)
472
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
471
+ for (let i = 0; i < n.length; i++)
472
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: n[i].join(",") })).data.stories.forEach((c) => {
473
473
  r.push(c);
474
474
  });
475
475
  } else
@@ -482,14 +482,14 @@ class X {
482
482
  let r = [];
483
483
  if (t.rel_uuids) {
484
484
  const s = t.rel_uuids.length;
485
- let o = [];
485
+ let n = [];
486
486
  const a = 50;
487
487
  for (let i = 0; i < s; i += a) {
488
488
  const c = Math.min(s, i + a);
489
- o.push(t.rel_uuids.slice(i, c));
489
+ n.push(t.rel_uuids.slice(i, c));
490
490
  }
491
- for (let i = 0; i < o.length; i++)
492
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
491
+ for (let i = 0; i < n.length; i++)
492
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: n[i].join(",") })).data.stories.forEach((c) => {
493
493
  r.push(c);
494
494
  });
495
495
  } else
@@ -510,8 +510,8 @@ class X {
510
510
  resolveAssetsRelations(t) {
511
511
  const { assets: e, stories: r, story: s } = t;
512
512
  if (r)
513
- for (const o of r)
514
- this.iterateTree(o, e);
513
+ for (const n of r)
514
+ this.iterateTree(n, e);
515
515
  else {
516
516
  if (!s)
517
517
  return t;
@@ -519,7 +519,7 @@ class X {
519
519
  }
520
520
  }
521
521
  cacheResponse(t, e, r) {
522
- return r === void 0 && (r = 0), new Promise(async (s, o) => {
522
+ return r === void 0 && (r = 0), new Promise(async (s, n) => {
523
523
  let a = k({ url: t, params: e }), i = this.cacheProvider();
524
524
  if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
525
525
  const l = await i.get(a);
@@ -529,12 +529,12 @@ class X {
529
529
  try {
530
530
  let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => k(p) }), u = { data: l.data, headers: l.headers };
531
531
  if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), l.headers["per-page"] && (u = Object.assign({}, u, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
532
- return o(l);
532
+ return n(l);
533
533
  (u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && d[e.token] != u.data.cv && this.flushCache(), d[e.token] = u.data.cv), s(u);
534
534
  } catch (l) {
535
535
  if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
536
- return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(o);
537
- o(l);
536
+ return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(n);
537
+ n(l);
538
538
  }
539
539
  var c;
540
540
  });
@@ -566,56 +566,56 @@ class X {
566
566
  return await this.cacheProvider().flush(), this;
567
567
  }
568
568
  }
569
- const at = (n = {}) => {
570
- const { apiOptions: t } = n;
569
+ const at = (o = {}) => {
570
+ const { apiOptions: t } = o;
571
571
  if (!t.accessToken) {
572
572
  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");
573
573
  return;
574
574
  }
575
575
  return { storyblokApi: new X(t) };
576
576
  };
577
- var Z = (n) => {
578
- if (typeof n != "object" || typeof n._editable > "u")
577
+ var Z = (o) => {
578
+ if (typeof o != "object" || typeof o._editable > "u")
579
579
  return {};
580
- const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
580
+ const t = JSON.parse(o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
581
581
  return {
582
582
  "data-blok-c": JSON.stringify(t),
583
583
  "data-blok-uid": t.id + "-" + t.uid
584
584
  };
585
585
  };
586
586
  let m;
587
- const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (n, t, e = {}) => {
587
+ const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (o, t, e = {}) => {
588
588
  if (!(typeof window > "u")) {
589
589
  if (typeof window.storyblokRegisterEvent > "u") {
590
590
  console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
591
591
  return;
592
592
  }
593
- if (!n) {
593
+ if (!o) {
594
594
  console.warn("Story ID is not defined. Please provide a valid ID.");
595
595
  return;
596
596
  }
597
597
  window.storyblokRegisterEvent(() => {
598
598
  new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
599
- s.story.id === n && (s.action === "input" ? t(s.story) : window.location.reload());
599
+ s.action === "input" && s.story.id === o ? t(s.story) : (s.action === "change" || s.action === "published") && s.storyId === o && window.location.reload();
600
600
  });
601
601
  });
602
602
  }
603
- }, rt = (n = {}) => {
603
+ }, rt = (o = {}) => {
604
604
  const {
605
605
  bridge: t,
606
606
  accessToken: e,
607
607
  use: r = [],
608
608
  apiOptions: s = {},
609
- richText: o = {}
610
- } = n;
609
+ richText: n = {}
610
+ } = o;
611
611
  s.accessToken = s.accessToken || e;
612
612
  const a = { bridge: t, apiOptions: s };
613
613
  let i = {};
614
614
  return r.forEach((c) => {
615
615
  i = h(h({}, i), c(a));
616
- }), t !== !1 && V(tt), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
617
- }, E = (n, t) => {
618
- n.addNode("blok", (e) => {
616
+ }), t !== !1 && V(tt), m = new R(n.schema), n.resolver && E(m, n.resolver), i;
617
+ }, E = (o, t) => {
618
+ o.addNode("blok", (e) => {
619
619
  let r = "";
620
620
  return e.attrs.body.forEach((s) => {
621
621
  r += t(s.component, s);
@@ -623,40 +623,40 @@ const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (n, t, e =
623
623
  html: r
624
624
  };
625
625
  });
626
- }, lt = (n, t) => {
626
+ }, lt = (o, t) => {
627
627
  if (!m) {
628
628
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
629
  return;
630
630
  }
631
- if (n === "")
631
+ if (o === "")
632
632
  return "";
633
- if (!n)
634
- return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
633
+ if (!o)
634
+ return console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
635
635
 
636
636
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "";
637
637
  let e = m;
638
- return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(n);
638
+ return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(o);
639
639
  }, st = /* @__PURE__ */ P({
640
640
  __name: "StoryblokComponent",
641
641
  props: {
642
642
  blok: null
643
643
  },
644
- setup(n) {
645
- return (t, e) => (j(), x(A(n.blok.component), C(M({ ...t.$props, ...t.$attrs })), null, 16));
644
+ setup(o) {
645
+ return (t, e) => (j(), x(A(o.blok.component), C(M({ ...t.$props, ...t.$attrs })), null, 16));
646
646
  }
647
- }), nt = {
648
- beforeMount(n, t) {
647
+ }), ot = {
648
+ beforeMount(o, t) {
649
649
  if (t.value) {
650
650
  const e = Z(t.value);
651
- n.setAttribute("data-blok-c", e["data-blok-c"]), n.setAttribute("data-blok-uid", e["data-blok-uid"]), n.classList.add("storyblok__outline");
651
+ o.setAttribute("data-blok-c", e["data-blok-c"]), o.setAttribute("data-blok-uid", e["data-blok-uid"]), o.classList.add("storyblok__outline");
652
652
  }
653
653
  }
654
- }, S = (n) => {
655
- console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
654
+ }, S = (o) => {
655
+ console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
656
656
  `);
657
657
  };
658
658
  let g = null;
659
- const ct = () => (g || S("useStoryblokApi"), g), ut = async (n, t = {}, e = {}) => {
659
+ const ct = () => (g || S("useStoryblokApi"), g), ut = async (o, t = {}, e = {}) => {
660
660
  const r = N(null);
661
661
  if (I(() => {
662
662
  r.value && r.value.id && et(
@@ -666,7 +666,7 @@ const ct = () => (g || S("useStoryblokApi"), g), ut = async (n, t = {}, e = {})
666
666
  );
667
667
  }), g) {
668
668
  const { data: s } = await g.get(
669
- `cdn/stories/${n}`,
669
+ `cdn/stories/${o}`,
670
670
  t
671
671
  );
672
672
  r.value = s.story;
@@ -674,8 +674,8 @@ const ct = () => (g || S("useStoryblokApi"), g), ut = async (n, t = {}, e = {})
674
674
  S("useStoryblok");
675
675
  return r;
676
676
  }, ht = {
677
- install(n, t = {}) {
678
- n.directive("editable", nt), n.component("StoryblokComponent", st);
677
+ install(o, t = {}) {
678
+ o.directive("editable", ot), o.component("StoryblokComponent", st);
679
679
  const { storyblokApi: e } = rt(t);
680
680
  g = e;
681
681
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
- "version": "6.3.1",
3
+ "version": "6.3.2",
4
4
  "description": "Storyblok directive for get editable elements.",
5
5
  "main": "./dist/storyblok-vue.js",
6
6
  "module": "./dist/storyblok-vue.mjs",
@@ -24,13 +24,13 @@
24
24
  "prepublishOnly": "npm run build && cp ../README.md ./"
25
25
  },
26
26
  "dependencies": {
27
- "@storyblok/js": "^1.8.0"
27
+ "@storyblok/js": "^1.8.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.18.10",
31
31
  "@cypress/vite-dev-server": "^2.0.7",
32
32
  "@cypress/vue": "^3.1.2",
33
- "@vitejs/plugin-vue": "^2.3.3",
33
+ "@vitejs/plugin-vue": "^2.3.4",
34
34
  "@vue/babel-preset-app": "^5.0.8",
35
35
  "@vue/test-utils": "next",
36
36
  "@vue/tsconfig": "^0.1.3",
@@ -40,10 +40,10 @@
40
40
  "eslint-plugin-jest": "^26.8.2",
41
41
  "jest": "^28.1.3",
42
42
  "typescript": "^4.7.4",
43
- "vite": "^3.0.5",
44
- "vue": "^3.2.33",
43
+ "vite": "^3.1.0",
44
+ "vue": "^3.2.39",
45
45
  "vue-jest": "next",
46
- "vue-tsc": "^0.40.1"
46
+ "vue-tsc": "^0.40.13"
47
47
  },
48
48
  "babel": {
49
49
  "presets": [