@storyblok/vue 9.4.4 → 9.4.5
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/dist/storyblok-vue.js +2 -2
- package/dist/storyblok-vue.mjs +133 -138
- package/package.json +2 -2
package/dist/storyblok-vue.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
(function(_,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(_=typeof globalThis<"u"?globalThis:_||self,d(_.storyblokVue={},_.Vue))})(this,function(_,d){"use strict";var ue=Object.defineProperty,he=(e,t,s)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,y=(e,t,s)=>he(e,typeof t!="symbol"?t+"":t,s);let R=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),E=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),J=function(e){return e.TEXT="text",e}({}),P=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const de=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],pe=(e={})=>{const{custom:t,...s}=e,r={...s,...t};return Object.keys(r).map(n=>`${n}="${r[n]}"`).join(" ")},fe=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function me(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function ye(e,t){if(!t)return{src:e,attrs:{}};let s=0,r=0;const n={},o=[];function l(c,p,k,h,v){typeof c!="number"||c<=p||c>=k?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${p} and ${k} (inclusive)`):v.push(`${h}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(n.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(n.height=t.height,r=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:p,brightness:k,fill:h,format:v,grayscale:L,quality:A,rotate:C}=c||{};p&&l(p,0,100,"blur",o),A&&l(A,0,100,"quality",o),k&&l(k,0,100,"brightness",o),h&&o.push(`fill(${h})`),L&&o.push("grayscale()"),C&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${C})`),v&&["webp","png","jpeg"].includes(v)&&o.push(`format(${v})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[p,k]=c;return`${e}/m/${p}x${k}/${o.length>0?`filters:${o.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(s>0||r>0)&&(a=`${a}${s}x${r}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function K(e,t={},s){const r=pe(t),n=r?`${e} ${r}`:e,o=Array.isArray(s)?s.join(""):s||"";if(e){if(de.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function U(e={}){const t=new Map,{renderFn:s=K,textFn:r=me,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=s!==K,c=(i={})=>{const{textAlign:u,class:f,id:m,style:g,...w}=i,b=[];return g&&b.push(g.endsWith(";")?g:`${g};`),u&&b.push(`text-align: ${u};`),I({...w,class:f,id:m,...b.length>0?{style:b.join(" ")}:{}})},p=i=>(u,f)=>{const m=c(u.attrs);return f.render(i,m,u.children||null)},k=(i,u)=>{const{src:f,alt:m,title:g,srcset:w,sizes:b}=i.attrs||{};let S=f,T={};if(o){const{src:st,attrs:rt}=ye(f,o);S=st,T=rt}const x={src:S,alt:m,title:g,srcset:w,sizes:b,...T};return u.render("img",I(x))},h=(i,u)=>{const{level:f,...m}=i.attrs||{},g=c(m);return u.render(`h${f}`,g,i.children)},v=(i,u)=>{var f,m,g,w;const b=u.render("img",{src:(f=i.attrs)==null?void 0:f.fallbackImage,alt:(m=i.attrs)==null?void 0:m.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(g=i.attrs)==null?void 0:g.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},b)},L=(i,u)=>u.render("pre",i.attrs||{},u.render("code",{},i.children||"")),A=(i,u=!1)=>({text:f,attrs:m},g)=>{const{class:w,id:b,...S}=m||{},T=u?{class:w,id:b,style:fe(S)||void 0}:m||{};return g.render(i,I(T),f)},C=i=>Y(i),Ke=i=>{const{marks:u,...f}=i;if("text"in i){if(u)return u.reduce((g,w)=>C({...w,text:g}),C({...f,children:f.children}));const m=i.attrs||{};if(l){const g=t.get("txt")||0;t.set("txt",g+1),m.key=`txt-${g}`}return r(f.text,m)}return""},ae=(i,u)=>{const{linktype:f,href:m,anchor:g,...w}=i.attrs||{};let b="";switch(f){case P.ASSET:case P.URL:b=m;break;case P.EMAIL:b=`mailto:${m}`;break;case P.STORY:b=m,g&&(b=`${b}#${g}`);break;default:b=m;break}const S={...w};return b&&(S.href=b),u.render("a",S,i.text)},We=(i,u)=>{var f,m;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(f=i==null?void 0:i.attrs)==null?void 0:f.body[0],id:(m=i.attrs)==null?void 0:m.id,style:"display: none"})},Xe=(i,u)=>{const f=c(i.attrs),m=i.children||null;return u.render("table",f,u.render("tbody",{},m))},Qe=(i,u)=>{const f=c(i.attrs);return u.render("tr",f,i.children)},Ze=(i,u)=>{const{colspan:f,rowspan:m,colwidth:g,backgroundColor:w,textAlign:b,...S}=i.attrs||{},T=[];g&&T.push(`width: ${g}px;`),w&&T.push(`background-color: ${w};`),b&&T.push(`text-align: ${b};`);const x={...S,...f>1?{colspan:f}:{},...m>1?{rowspan:m}:{},...T.length>0?{style:T.join(" ")}:{}};return u.render("td",I(x),i.children)},et=(i,u)=>{const{colspan:f,rowspan:m,colwidth:g,backgroundColor:w,textAlign:b,...S}=i.attrs||{},T=[];g&&T.push(`width: ${g}px;`),w&&T.push(`background-color: ${w};`),b&&T.push(`text-align: ${b};`);const x={...S,...f>1?{colspan:f}:{},...m>1?{rowspan:m}:{},...T.length>0?{style:T.join(" ")}:{}};return u.render("th",I(x),i.children)},le=new Map([[R.DOCUMENT,p("")],[R.HEADING,h],[R.PARAGRAPH,p("p")],[R.UL_LIST,p("ul")],[R.OL_LIST,p("ol")],[R.LIST_ITEM,p("li")],[R.IMAGE,k],[R.EMOJI,v],[R.CODE_BLOCK,L],[R.HR,p("hr")],[R.BR,p("br")],[R.QUOTE,p("blockquote")],[R.COMPONENT,We],[J.TEXT,Ke],[E.LINK,ae],[E.ANCHOR,ae],[E.STYLED,A("span",!0)],[E.BOLD,A("strong")],[E.TEXT_STYLE,A("span",!0)],[E.ITALIC,A("em")],[E.UNDERLINE,A("u")],[E.STRIKE,A("s")],[E.CODE,A("code")],[E.SUPERSCRIPT,A("sup")],[E.SUBSCRIPT,A("sub")],[E.HIGHLIGHT,A("mark")],[R.TABLE,Xe],[R.TABLE_ROW,Qe],[R.TABLE_CELL,Ze],[R.TABLE_HEADER,et]]),ce=new Map([...le,...Object.entries(n).map(([i,u])=>[i,u])]),tt=()=>({render:(i,u={},f)=>{if(l&&i){const m=t.get(i)||0;t.set(i,m+1),u.key=`${i}-${m}`}return s(i,u,f)},originalResolvers:le,mergedResolvers:ce});function H(i){const u=ce.get(i.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const f=tt();if(i.type==="text")return u(i,f);const m=i.content?i.content.map(Y):void 0;return u({...i,children:m},f)}function Y(i){return i.type==="doc"?a?i.content.map(H):i.content.map(H).join(""):Array.isArray(i)?i.map(H):H(i)}return{render:Y}}let W=!1;const X=[],ge=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}W?n():X.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const r=document.createElement("script");r.async=!0,r.src=e,r.id="storyblok-javascript-bridge",r.onerror=n=>s(n),r.onload=n=>{X.forEach(o=>o()),W=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(r)}),B=(e="")=>e.includes("/cdn/"),be=(e,t=25,s=1)=>({...e,per_page:t,page:s}),ke=e=>new Promise(t=>setTimeout(t,e)),ve=(e=0,t)=>Array.from({length:e},t),_e=(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return ve(s,(n,o)=>o*r+e)},Re=async(e,t)=>Promise.all(e.map(t)),we=(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]),F=(e,t,s)=>{const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=F(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")},Q=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var Te=class{constructor(e){y(this,"baseURL"),y(this,"timeout"),y(this,"headers"),y(this,"responseInterceptor"),y(this,"fetch"),y(this,"ejectInterceptor"),y(this,"url"),y(this,"parameters"),y(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;e==="get"?t=`${this.baseURL}${this.url}?${F(this.parameters)}`:s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:o}=n;let l=null;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:o,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return a.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:a.message||a.toString()||"An unknown error occurred"}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}},Ae=Te;const Z="SB-Agent",q={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ee={DRAFT:"draft",PUBLISHED:"published"},Ee=25,V={SMALL:25,MEDIUM:50,LARGE:75},O={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},G=1e3,M=3;function Se(e){return e.version===ee.DRAFT}function $e(e,t){const s=e.includes("/cdn/stories/"),r=e.split("/").length>3&&!e.endsWith("/cdn/stories"),n="find_by"in t;return s&&r||n}function Le(e){return e<=V.SMALL?O.SINGLE_OR_SMALL:e<=V.MEDIUM?O.MEDIUM:e<=V.LARGE?O.LARGE:O.VERY_LARGE}function N(e,t,s={},r){if(s.userRateLimit!==void 0)return Math.min(s.userRateLimit,G);if(s.serverHeadersRateLimit!==void 0)return Math.min(s.serverHeadersRateLimit,G);if(r!==void 0)return r;if(t&&!Se(t))return G;if($e(e,t))return O.SINGLE_OR_SMALL;const n=t.per_page||Ee;return Le(n)}function Ce(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],s=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!s)return null;const r={};if(t){const n=t.match(/r=(\d+)/);n&&(r.remaining=Number.parseInt(n[1],10))}if(s){const n=s.match(/q=(\d+)/);n&&(r.max=Number.parseInt(n[1],10))}return Object.keys(r).length>0?r:null}function Ie(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Oe=class extends Error{constructor(e){super(e),this.name="AbortError"}};function je(e,t,s){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let n=[],o=0,l=!1;const a=async()=>{o++;const p=r.shift();if(p)try{const h=await e(...p.args);p.resolve(h)}catch(h){p.reject(h)}const k=setTimeout(()=>{o--,r.length>0&&a(),n=n.filter(h=>h!==k)},s);n.includes(k)||n.push(k)},c=(...p)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((k,h)=>{r.push({resolve:k,reject:h,args:p}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],r.forEach(p=>p.reject(()=>new Oe("Throttle function aborted"))),r.length=0},c}var xe=je,Pe=class{constructor(e,t=1e3){y(this,"queues"),y(this,"interval"),y(this,"throttledRequestFn"),this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=xe(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let D={};const $={};var Me=class{constructor(e,t){y(this,"client"),y(this,"maxRetries"),y(this,"retriesDelay"),y(this,"throttleManager"),y(this,"accessToken"),y(this,"cache"),y(this,"resolveCounter"),y(this,"relations"),y(this,"links"),y(this,"version"),y(this,"rateLimitConfig"),y(this,"richTextResolver"),y(this,"resolveNestedRelations"),y(this,"stringifiedStoriesCache"),y(this,"inlineAssets");let s=e.endpoint||t;if(!s){const n=e.https===!1?"http":"https";e.oauthToken?s=`${n}://${Q(e.region)}/v1`:s=`${n}://${Q(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([n,o])=>{r.set(n,o)}),r.has(Z)||(r.set(Z,q.defaultAgentName),r.set(q.defaultAgentVersion,q.packageVersion)),e.oauthToken&&r.set("Authorization",e.oauthToken),this.rateLimitConfig=Ie(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttleManager=new Pe(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||ee.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new Ae({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=$[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return B(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const o=this.factoryParamOptions(e,be(t,s,r));return this.cacheResponse(e,o,void 0,n)}get(e,t={},s){t||(t={});const r=`/${e}`;B(r)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,s)}async getAll(e,t={},s,r){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=s??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,r),p=c.total?Math.ceil(c.total/(c.perPage||n)):1,k=await Re(_e(a,p),h=>this.makeRequest(o,t,n,h+1,r));return we([c,...k],h=>Object.values(h.data[l]))}post(e,t={},s){const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"post",r,t,s)}put(e,t={},s){const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"put",r,t,s)}delete(e,t={},s){t||(t={});const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"delete",r,t,s)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,s){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(s,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(s,n)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(o=>o.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(n):s===n)&&this._resolveField(e,t,r)}iterateTree(e,t,s){const r=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>r(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,s),this._insertLinks(n,l,s)),r(n[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let o=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],o,s);e.story?this.iterateTree(e.story,o,s):e.stories.forEach(l=>{this.iterateTree(l,o,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=F({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await o.get(n);if(c)return Promise.resolve(c)}const l=!B(e)&&this.rateLimitConfig.isManagementApi?M:void 0,a=N(e,t,this.rateLimitConfig,l);return new Promise(async(c,p)=>{var k;try{const h=await this.throttleManager.execute(a,"get",e,t,r);if(h.status!==200)return p(h);let v={data:h.data,headers:h.headers};const L=Ce(h.headers);if((L==null?void 0:L.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=L.max),(k=h.headers)!=null&&k["per-page"]&&(v=Object.assign({},v,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),v.data.story||v.data.stories){const C=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(v.data,t,`${C}`),v=await this.processInlineAssets(v)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,v);const A=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&v.data.cv&&(A&&$[t.token]&&$[t.token]!==v.data.cv&&await this.flushCache(),$[t.token]=v.data.cv),c(v)}catch(h){if(h.response&&h.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ke(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(p);p(h)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return $}cacheVersion(){return $[this.accessToken]}setCacheVersion(e){this.accessToken&&($[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&($[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(D[e])},getAll(){return Promise.resolve(D)},set(e,t){return D[e]=t,Promise.resolve(void 0)},flush(){return D={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=s=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(n=>t(n));let r={...s};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...e.data.assets.find(n=>n.id===r.id),...r});for(const n in r)typeof r[n]=="object"&&(r[n]=t(r[n]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(s=>(s.content=t(s.content),s))),e}},te=Me;const Ne=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new te(t)}},De=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let se="https://app.storyblok.com/f/storyblok-v2-latest.js";const re=(e,t,s={})=>{var r;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},He=(e={})=>{var t,s;const{bridge:r,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:r,apiOptions:l};let p={};o.forEach(h=>{p={...p,...h(c)}}),a&&(se=a);const k=!(typeof window>"u")&&((s=(t=window.location)==null?void 0:t.search)==null?void 0:s.includes("_storyblok_tk"));return r!==!1&&k&&ge(se),p};function Ue(e,t){return U(t).render(e)}const z=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const s=e,r=d.ref();t({value:r});const n=typeof d.resolveDynamicComponent(s.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=s.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${s.blok.component}"! Is it defined in main.ts as "app.component("${s.blok.component}", ${s.blok.component});"?`)),(c,p)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:r},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(k,h)=>({name:h,fn:d.withCtx(v=>[d.renderSlot(c.$slots,h,d.normalizeProps(d.guardReactiveProps(v)))])}))]),1040))}}),Be=e=>{var s;const t=(s=e==null?void 0:e.attrs)==null?void 0:s.body;return!Array.isArray(t)||t.length===0?[]:t.map(r=>{var n;return d.h(z,{blok:r,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function ne(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[R.COMPONENT]:Be,...e.resolvers}};return U(t)}const oe=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,s=d.ref(),r=()=>s.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=ne({resolvers:o??{}});s.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(r))}}),Fe={beforeMount(e,t){if(t.value){const s=De(t.value);Object.keys(s).length>0&&(e.setAttribute("data-blok-c",s["data-blok-c"]),e.setAttribute("data-blok-uid",s["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},ie=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
-
`)};let j=null;const qe=()=>(j||
|
|
7
|
+
(function(_,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(_=typeof globalThis<"u"?globalThis:_||self,d(_.storyblokVue={},_.Vue))})(this,function(_,d){"use strict";var ce=Object.defineProperty,ue=(e,t,s)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,y=(e,t,s)=>ue(e,typeof t!="symbol"?t+"":t,s);let R=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),E=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),Y=function(e){return e.TEXT="text",e}({}),P=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const he=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],de=(e={})=>{const{custom:t,...s}=e,r={...s,...t};return Object.keys(r).map(n=>`${n}="${r[n]}"`).join(" ")},pe=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function fe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function me(e,t){if(!t)return{src:e,attrs:{}};let s=0,r=0;const n={},o=[];function l(c,p,k,h,v){typeof c!="number"||c<=p||c>=k?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${p} and ${k} (inclusive)`):v.push(`${h}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(n.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(n.height=t.height,r=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:p,brightness:k,fill:h,format:v,grayscale:$,quality:A,rotate:C}=c||{};p&&l(p,0,100,"blur",o),A&&l(A,0,100,"quality",o),k&&l(k,0,100,"brightness",o),h&&o.push(`fill(${h})`),$&&o.push("grayscale()"),C&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${C})`),v&&["webp","png","jpeg"].includes(v)&&o.push(`format(${v})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[p,k]=c;return`${e}/m/${p}x${k}/${o.length>0?`filters:${o.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(s>0||r>0)&&(a=`${a}${s}x${r}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function J(e,t={},s){const r=de(t),n=r?`${e} ${r}`:e,o=Array.isArray(s)?s.join(""):s||"";if(e){if(he.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function U(e={}){const t=new Map,{renderFn:s=J,textFn:r=fe,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=s!==J,c=(i={})=>{const{textAlign:u,class:f,id:m,style:g,...w}=i,b=[];return g&&b.push(g.endsWith(";")?g:`${g};`),u&&b.push(`text-align: ${u};`),I({...w,class:f,id:m,...b.length>0?{style:b.join(" ")}:{}})},p=i=>(u,f)=>{const m=c(u.attrs);return f.render(i,m,u.children||null)},k=(i,u)=>{const{src:f,alt:m,title:g,srcset:w,sizes:b}=i.attrs||{};let L=f,T={};if(o){const{src:tt,attrs:st}=me(f,o);L=tt,T=st}const x={src:L,alt:m,title:g,srcset:w,sizes:b,...T};return u.render("img",I(x))},h=(i,u)=>{const{level:f,...m}=i.attrs||{},g=c(m);return u.render(`h${f}`,g,i.children)},v=(i,u)=>{var f,m,g,w;const b=u.render("img",{src:(f=i.attrs)==null?void 0:f.fallbackImage,alt:(m=i.attrs)==null?void 0:m.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(g=i.attrs)==null?void 0:g.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},b)},$=(i,u)=>u.render("pre",i.attrs||{},u.render("code",{},i.children||"")),A=(i,u=!1)=>({text:f,attrs:m},g)=>{const{class:w,id:b,...L}=m||{},T=u?{class:w,id:b,style:pe(L)||void 0}:m||{};return g.render(i,I(T),f)},C=i=>z(i),Je=i=>{const{marks:u,...f}=i;if("text"in i){if(u)return u.reduce((g,w)=>C({...w,text:g}),C({...f,children:f.children}));const m=i.attrs||{};if(l){const g=t.get("txt")||0;t.set("txt",g+1),m.key=`txt-${g}`}return r(f.text,m)}return""},ie=(i,u)=>{const{linktype:f,href:m,anchor:g,...w}=i.attrs||{};let b="";switch(f){case P.ASSET:case P.URL:b=m;break;case P.EMAIL:b=`mailto:${m}`;break;case P.STORY:b=m,g&&(b=`${b}#${g}`);break;default:b=m;break}const L={...w};return b&&(L.href=b),u.render("a",L,i.text)},Ke=(i,u)=>{var f,m;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(f=i==null?void 0:i.attrs)==null?void 0:f.body[0],id:(m=i.attrs)==null?void 0:m.id,style:"display: none"})},We=(i,u)=>{const f=c(i.attrs),m=i.children||null;return u.render("table",f,u.render("tbody",{},m))},Xe=(i,u)=>{const f=c(i.attrs);return u.render("tr",f,i.children)},Qe=(i,u)=>{const{colspan:f,rowspan:m,colwidth:g,backgroundColor:w,textAlign:b,...L}=i.attrs||{},T=[];g&&T.push(`width: ${g}px;`),w&&T.push(`background-color: ${w};`),b&&T.push(`text-align: ${b};`);const x={...L,...f>1?{colspan:f}:{},...m>1?{rowspan:m}:{},...T.length>0?{style:T.join(" ")}:{}};return u.render("td",I(x),i.children)},Ze=(i,u)=>{const{colspan:f,rowspan:m,colwidth:g,backgroundColor:w,textAlign:b,...L}=i.attrs||{},T=[];g&&T.push(`width: ${g}px;`),w&&T.push(`background-color: ${w};`),b&&T.push(`text-align: ${b};`);const x={...L,...f>1?{colspan:f}:{},...m>1?{rowspan:m}:{},...T.length>0?{style:T.join(" ")}:{}};return u.render("th",I(x),i.children)},ae=new Map([[R.DOCUMENT,p("")],[R.HEADING,h],[R.PARAGRAPH,p("p")],[R.UL_LIST,p("ul")],[R.OL_LIST,p("ol")],[R.LIST_ITEM,p("li")],[R.IMAGE,k],[R.EMOJI,v],[R.CODE_BLOCK,$],[R.HR,p("hr")],[R.BR,p("br")],[R.QUOTE,p("blockquote")],[R.COMPONENT,Ke],[Y.TEXT,Je],[E.LINK,ie],[E.ANCHOR,ie],[E.STYLED,A("span",!0)],[E.BOLD,A("strong")],[E.TEXT_STYLE,A("span",!0)],[E.ITALIC,A("em")],[E.UNDERLINE,A("u")],[E.STRIKE,A("s")],[E.CODE,A("code")],[E.SUPERSCRIPT,A("sup")],[E.SUBSCRIPT,A("sub")],[E.HIGHLIGHT,A("mark")],[R.TABLE,We],[R.TABLE_ROW,Xe],[R.TABLE_CELL,Qe],[R.TABLE_HEADER,Ze]]),le=new Map([...ae,...Object.entries(n).map(([i,u])=>[i,u])]),et=()=>({render:(i,u={},f)=>{if(l&&i){const m=t.get(i)||0;t.set(i,m+1),u.key=`${i}-${m}`}return s(i,u,f)},originalResolvers:ae,mergedResolvers:le});function D(i){const u=le.get(i.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const f=et();if(i.type==="text")return u(i,f);const m=i.content?i.content.map(z):void 0;return u({...i,children:m},f)}function z(i){return i.type==="doc"?a?i.content.map(D):i.content.map(D).join(""):Array.isArray(i)?i.map(D):D(i)}return{render:z}}let K=!1;const W=[],ye=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}K?n():W.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const r=document.createElement("script");r.async=!0,r.src=e,r.id="storyblok-javascript-bridge",r.onerror=n=>s(n),r.onload=n=>{W.forEach(o=>o()),K=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(r)}),B=(e="")=>e.includes("/cdn/"),ge=(e,t=25,s=1)=>({...e,per_page:t,page:s}),be=e=>new Promise(t=>setTimeout(t,e)),ke=(e=0,t)=>Array.from({length:e},t),ve=(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return ke(s,(n,o)=>o*r+e)},_e=async(e,t)=>Promise.all(e.map(t)),Re=(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]),q=(e,t,s)=>{const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=q(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")},X=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var we=class{constructor(e){y(this,"baseURL"),y(this,"timeout"),y(this,"headers"),y(this,"responseInterceptor"),y(this,"fetch"),y(this,"ejectInterceptor"),y(this,"url"),y(this,"parameters"),y(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;e==="get"?t=`${this.baseURL}${this.url}?${q(this.parameters)}`:s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:o}=n;let l=null;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:o,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return a.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:a.message||a.toString()||"An unknown error occurred"}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}},Te=we;const Q="SB-Agent",F={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},Ae={PUBLISHED:"published"},Ee=25,V={SMALL:25,MEDIUM:50,LARGE:75},O={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Z=1e3,M=3;function Le(e,t){const s=e.includes("/cdn/stories/"),r=e.split("/").length>3&&!e.endsWith("/cdn/stories"),n="find_by"in t;return s&&r||n}function Se(e){return e<=V.SMALL?O.SINGLE_OR_SMALL:e<=V.MEDIUM?O.MEDIUM:e<=V.LARGE?O.LARGE:O.VERY_LARGE}function N(e,t,s={},r){if(s.userRateLimit!==void 0)return Math.min(s.userRateLimit,Z);if(s.serverHeadersRateLimit!==void 0)return Math.min(s.serverHeadersRateLimit,Z);if(r!==void 0)return r;if(!e||!t||Le(e,t))return O.SINGLE_OR_SMALL;const n=t.per_page||Ee;return Se(n)}function $e(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],s=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!s)return null;const r={};if(t){const n=t.match(/r=(\d+)/);n&&(r.remaining=Number.parseInt(n[1],10))}if(s){const n=s.match(/q=(\d+)/);n&&(r.max=Number.parseInt(n[1],10))}return Object.keys(r).length>0?r:null}function Ce(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Ie=class extends Error{constructor(e){super(e),this.name="AbortError"}};function Oe(e,t,s){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let n=[],o=0,l=!1;const a=async()=>{o++;const p=r.shift();if(p)try{const h=await e(...p.args);p.resolve(h)}catch(h){p.reject(h)}const k=setTimeout(()=>{o--,r.length>0&&a(),n=n.filter(h=>h!==k)},s);n.includes(k)||n.push(k)},c=(...p)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((k,h)=>{r.push({resolve:k,reject:h,args:p}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],r.forEach(p=>p.reject(()=>new Ie("Throttle function aborted"))),r.length=0},c}var je=Oe,xe=class{constructor(e,t=1e3){y(this,"queues"),y(this,"interval"),y(this,"throttledRequestFn"),this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=je(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let H={};const S={};var Pe=class{constructor(e,t){y(this,"client"),y(this,"maxRetries"),y(this,"retriesDelay"),y(this,"throttleManager"),y(this,"accessToken"),y(this,"cache"),y(this,"resolveCounter"),y(this,"relations"),y(this,"links"),y(this,"version"),y(this,"rateLimitConfig"),y(this,"richTextResolver"),y(this,"resolveNestedRelations"),y(this,"stringifiedStoriesCache"),y(this,"inlineAssets");let s=e.endpoint||t;if(!s){const n=e.https===!1?"http":"https";e.oauthToken?s=`${n}://${X(e.region)}/v1`:s=`${n}://${X(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([n,o])=>{r.set(n,o)}),r.has(Q)||(r.set(Q,F.defaultAgentName),r.set(F.defaultAgentVersion,F.packageVersion)),e.oauthToken&&r.set("Authorization",e.oauthToken),this.rateLimitConfig=Ce(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttleManager=new xe(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||Ae.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new Te({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return B(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const o=this.factoryParamOptions(e,ge(t,s,r));return this.cacheResponse(e,o,void 0,n)}get(e,t={},s){t||(t={});const r=`/${e}`;B(r)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,s)}async getAll(e,t={},s,r){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=s??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,r),p=c.total?Math.ceil(c.total/(c.perPage||n)):1,k=await _e(ve(a,p),h=>this.makeRequest(o,t,n,h+1,r));return Re([c,...k],h=>Object.values(h.data[l]))}post(e,t={},s){const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"post",r,t,s)}put(e,t={},s){const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"put",r,t,s)}delete(e,t={},s){t||(t={});const r=`/${e}`,n=N(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(n,"delete",r,t,s)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,s){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(s,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(s,n)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(o=>o.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(n):s===n)&&this._resolveField(e,t,r)}iterateTree(e,t,s){const r=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>r(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,s),this._insertLinks(n,l,s)),r(n[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let o=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],o,s);e.story?this.iterateTree(e.story,o,s):e.stories.forEach(l=>{this.iterateTree(l,o,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=q({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await o.get(n);if(c)return Promise.resolve(c)}const l=!B(e)&&this.rateLimitConfig.isManagementApi?M:void 0,a=N(e,t,this.rateLimitConfig,l);return new Promise(async(c,p)=>{var k;try{const h=await this.throttleManager.execute(a,"get",e,t,r);if(h.status!==200)return p(h);let v={data:h.data,headers:h.headers};const $=$e(h.headers);if(($==null?void 0:$.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=$.max),(k=h.headers)!=null&&k["per-page"]&&(v=Object.assign({},v,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),v.data.story||v.data.stories){const C=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(v.data,t,`${C}`),v=await this.processInlineAssets(v)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,v);const A=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&v.data.cv&&(A&&S[t.token]&&S[t.token]!==v.data.cv&&await this.flushCache(),S[t.token]=v.data.cv),c(v)}catch(h){if(h.response&&h.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await be(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(p);p(h)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(H[e])},getAll(){return Promise.resolve(H)},set(e,t){return H[e]=t,Promise.resolve(void 0)},flush(){return H={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=s=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(n=>t(n));let r={...s};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...e.data.assets.find(n=>n.id===r.id),...r});for(const n in r)typeof r[n]=="object"&&(r[n]=t(r[n]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(s=>(s.content=t(s.content),s))),e}},ee=Pe;const Me=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ee(t)}},Ne=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let te="https://app.storyblok.com/f/storyblok-v2-latest.js";const se=(e,t,s={})=>{var r;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},He=(e={})=>{var t,s;const{bridge:r,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:r,apiOptions:l};let p={};o.forEach(h=>{p={...p,...h(c)}}),a&&(te=a);const k=!(typeof window>"u")&&((s=(t=window.location)==null?void 0:t.search)==null?void 0:s.includes("_storyblok_tk"));return r!==!1&&k&&ye(te),p};function De(e,t){return U(t).render(e)}const G=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const s=e,r=d.ref();t({value:r});const n=typeof d.resolveDynamicComponent(s.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=s.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${s.blok.component}"! Is it defined in main.ts as "app.component("${s.blok.component}", ${s.blok.component});"?`)),(c,p)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:r},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(k,h)=>({name:h,fn:d.withCtx(v=>[d.renderSlot(c.$slots,h,d.normalizeProps(d.guardReactiveProps(v)))])}))]),1040))}}),Ue=e=>{var s;const t=(s=e==null?void 0:e.attrs)==null?void 0:s.body;return!Array.isArray(t)||t.length===0?[]:t.map(r=>{var n;return d.h(G,{blok:r,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function re(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[R.COMPONENT]:Ue,...e.resolvers}};return U(t)}const ne=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,s=d.ref(),r=()=>s.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=re({resolvers:o??{}});s.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(r))}}),Be={beforeMount(e,t){if(t.value){const s=Ne(t.value);Object.keys(s).length>0&&(e.setAttribute("data-blok-c",s["data-blok-c"]),e.setAttribute("data-blok-uid",s["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},oe=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
+
`)};let j=null;const qe=()=>(j||oe("useStoryblokApi"),j),Fe=async(e,t={},s={})=>{const r=d.ref(null);if(s.resolveRelations=s.resolveRelations??t.resolve_relations,s.resolveLinks=s.resolveLinks??t.resolve_links,d.onMounted(()=>{r.value&&r.value.id&&se(r.value.id,n=>r.value=n,s)}),j){const{data:n}=await j.get(`cdn/stories/${e}`,t);r.value=n.story}else oe("useStoryblok");return r},Ve={install(e,t={}){e.directive("editable",Be),e.component("StoryblokComponent",G),e.component("StoryblokRichText",ne),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Ye)));const{storyblokApi:s}=He(t);j=s||null,e.provide("VueSDKOptions",t)}},Ge={class:"fallback-component"},ze={class:"component"},Ye=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const s=e.__vccOpts||e;for(const[r,n]of t)s[r]=n;return s})(d.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,s)=>(d.openBlock(),d.createElementBlock("div",Ge,[d.createElementVNode("p",null,[s[0]||(s[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",ze,d.toDisplayString(t.blok.component),1),s[1]||(s[1]=d.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));_.BlockTypes=R,_.MarkTypes=E,_.StoryblokClient=ee,_.StoryblokComponent=G,_.StoryblokRichText=ne,_.StoryblokVue=Ve,_.TextTypes=Y,_.apiPlugin=Me,_.renderRichText=De,_.richTextResolver=U,_.useStoryblok=Fe,_.useStoryblokApi=qe,_.useStoryblokBridge=se,_.useStoryblokRichText=re,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent as te, ref as H, resolveDynamicComponent as
|
|
8
|
-
var
|
|
7
|
+
import { defineComponent as te, ref as H, resolveDynamicComponent as D, inject as ge, createBlock as se, openBlock as re, mergeProps as ve, createSlots as be, renderList as ke, withCtx as Re, renderSlot as we, normalizeProps as _e, guardReactiveProps as Te, h as ne, createTextVNode as Ae, watch as Le, onMounted as Ee, defineAsyncComponent as $e } from "vue";
|
|
8
|
+
var Se = Object.defineProperty, Ie = (e, t, s) => t in e ? Se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, y = (e, t, s) => Ie(e, typeof t != "symbol" ? t + "" : t, s);
|
|
9
9
|
let R = /* @__PURE__ */ function(e) {
|
|
10
10
|
return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
|
|
11
11
|
}({}), T = /* @__PURE__ */ function(e) {
|
|
12
12
|
return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
|
|
13
|
-
}({}),
|
|
13
|
+
}({}), Ce = /* @__PURE__ */ function(e) {
|
|
14
14
|
return e.TEXT = "text", e;
|
|
15
15
|
}({}), j = /* @__PURE__ */ function(e) {
|
|
16
16
|
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
|
17
17
|
}({});
|
|
18
|
-
const
|
|
18
|
+
const xe = [
|
|
19
19
|
"area",
|
|
20
20
|
"base",
|
|
21
21
|
"br",
|
|
@@ -30,18 +30,18 @@ const Oe = [
|
|
|
30
30
|
"source",
|
|
31
31
|
"track",
|
|
32
32
|
"wbr"
|
|
33
|
-
],
|
|
33
|
+
], Oe = (e = {}) => {
|
|
34
34
|
const { custom: t, ...s } = e, r = {
|
|
35
35
|
...s,
|
|
36
36
|
...t
|
|
37
37
|
};
|
|
38
38
|
return Object.keys(r).map((n) => `${n}="${r[n]}"`).join(" ");
|
|
39
|
-
},
|
|
40
|
-
function
|
|
39
|
+
}, je = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
|
40
|
+
function Pe(e) {
|
|
41
41
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
42
42
|
}
|
|
43
43
|
const I = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
|
|
44
|
-
function
|
|
44
|
+
function Me(e, t) {
|
|
45
45
|
if (!t) return {
|
|
46
46
|
src: e,
|
|
47
47
|
attrs: {}
|
|
@@ -53,8 +53,8 @@ function Ne(e, t) {
|
|
|
53
53
|
}
|
|
54
54
|
if (typeof t == "object") {
|
|
55
55
|
if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (n.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (n.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete n.width, delete n.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
|
|
56
|
-
const { filters: c } = t || {}, { blur: d, brightness: v, fill: h, format: b, grayscale:
|
|
57
|
-
d && l(d, 0, 100, "blur", o), _ && l(_, 0, 100, "quality", o), v && l(v, 0, 100, "brightness", o), h && o.push(`fill(${h})`),
|
|
56
|
+
const { filters: c } = t || {}, { blur: d, brightness: v, fill: h, format: b, grayscale: E, quality: _, rotate: $ } = c || {};
|
|
57
|
+
d && l(d, 0, 100, "blur", o), _ && l(_, 0, 100, "quality", o), v && l(v, 0, 100, "brightness", o), h && o.push(`fill(${h})`), E && o.push("grayscale()"), $ && [
|
|
58
58
|
0,
|
|
59
59
|
90,
|
|
60
60
|
180,
|
|
@@ -82,15 +82,15 @@ function Ne(e, t) {
|
|
|
82
82
|
attrs: n
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
const r =
|
|
85
|
+
function J(e, t = {}, s) {
|
|
86
|
+
const r = Oe(t), n = r ? `${e} ${r}` : e, o = Array.isArray(s) ? s.join("") : s || "";
|
|
87
87
|
if (e) {
|
|
88
|
-
if (
|
|
88
|
+
if (xe.includes(e)) return `<${n}>`;
|
|
89
89
|
} else return o;
|
|
90
90
|
return `<${n}>${o}</${e}>`;
|
|
91
91
|
}
|
|
92
92
|
function oe(e = {}) {
|
|
93
|
-
const t = /* @__PURE__ */ new Map(), { renderFn: s =
|
|
93
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: s = J, textFn: r = Pe, resolvers: n = {}, optimizeImages: o = !1, keyedResolvers: l = !1 } = e, a = s !== J, c = (i = {}) => {
|
|
94
94
|
const { textAlign: u, class: p, id: f, style: m, ...k } = i, g = [];
|
|
95
95
|
return m && g.push(m.endsWith(";") ? m : `${m};`), u && g.push(`text-align: ${u};`), I({
|
|
96
96
|
...k,
|
|
@@ -105,8 +105,8 @@ function oe(e = {}) {
|
|
|
105
105
|
const { src: p, alt: f, title: m, srcset: k, sizes: g } = i.attrs || {};
|
|
106
106
|
let A = p, w = {};
|
|
107
107
|
if (o) {
|
|
108
|
-
const { src:
|
|
109
|
-
A =
|
|
108
|
+
const { src: me, attrs: ye } = Me(p, o);
|
|
109
|
+
A = me, w = ye;
|
|
110
110
|
}
|
|
111
111
|
const S = {
|
|
112
112
|
src: A,
|
|
@@ -134,14 +134,14 @@ function oe(e = {}) {
|
|
|
134
134
|
"data-name": (m = i.attrs) == null ? void 0 : m.name,
|
|
135
135
|
"data-emoji": (k = i.attrs) == null ? void 0 : k.emoji
|
|
136
136
|
}, g);
|
|
137
|
-
},
|
|
137
|
+
}, E = (i, u) => u.render("pre", i.attrs || {}, u.render("code", {}, i.children || "")), _ = (i, u = !1) => ({ text: p, attrs: f }, m) => {
|
|
138
138
|
const { class: k, id: g, ...A } = f || {}, w = u ? {
|
|
139
139
|
class: k,
|
|
140
140
|
id: g,
|
|
141
|
-
style:
|
|
141
|
+
style: je(A) || void 0
|
|
142
142
|
} : f || {};
|
|
143
143
|
return m.render(i, I(w), p);
|
|
144
|
-
}, $ = (i) =>
|
|
144
|
+
}, $ = (i) => U(i), le = (i) => {
|
|
145
145
|
const { marks: u, ...p } = i;
|
|
146
146
|
if ("text" in i) {
|
|
147
147
|
if (u) return u.reduce((m, k) => $({
|
|
@@ -159,7 +159,7 @@ function oe(e = {}) {
|
|
|
159
159
|
return r(p.text, f);
|
|
160
160
|
}
|
|
161
161
|
return "";
|
|
162
|
-
},
|
|
162
|
+
}, V = (i, u) => {
|
|
163
163
|
const { linktype: p, href: f, anchor: m, ...k } = i.attrs || {};
|
|
164
164
|
let g = "";
|
|
165
165
|
switch (p) {
|
|
@@ -179,20 +179,20 @@ function oe(e = {}) {
|
|
|
179
179
|
}
|
|
180
180
|
const A = { ...k };
|
|
181
181
|
return g && (A.href = g), u.render("a", A, i.text);
|
|
182
|
-
},
|
|
182
|
+
}, ce = (i, u) => {
|
|
183
183
|
var p, f;
|
|
184
184
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
|
|
185
185
|
blok: (p = i == null ? void 0 : i.attrs) == null ? void 0 : p.body[0],
|
|
186
186
|
id: (f = i.attrs) == null ? void 0 : f.id,
|
|
187
187
|
style: "display: none"
|
|
188
188
|
});
|
|
189
|
-
},
|
|
189
|
+
}, ue = (i, u) => {
|
|
190
190
|
const p = c(i.attrs), f = i.children || null;
|
|
191
191
|
return u.render("table", p, u.render("tbody", {}, f));
|
|
192
|
-
},
|
|
192
|
+
}, he = (i, u) => {
|
|
193
193
|
const p = c(i.attrs);
|
|
194
194
|
return u.render("tr", p, i.children);
|
|
195
|
-
},
|
|
195
|
+
}, de = (i, u) => {
|
|
196
196
|
const { colspan: p, rowspan: f, colwidth: m, backgroundColor: k, textAlign: g, ...A } = i.attrs || {}, w = [];
|
|
197
197
|
m && w.push(`width: ${m}px;`), k && w.push(`background-color: ${k};`), g && w.push(`text-align: ${g};`);
|
|
198
198
|
const S = {
|
|
@@ -202,7 +202,7 @@ function oe(e = {}) {
|
|
|
202
202
|
...w.length > 0 ? { style: w.join(" ") } : {}
|
|
203
203
|
};
|
|
204
204
|
return u.render("td", I(S), i.children);
|
|
205
|
-
},
|
|
205
|
+
}, pe = (i, u) => {
|
|
206
206
|
const { colspan: p, rowspan: f, colwidth: m, backgroundColor: k, textAlign: g, ...A } = i.attrs || {}, w = [];
|
|
207
207
|
m && w.push(`width: ${m}px;`), k && w.push(`background-color: ${k};`), g && w.push(`text-align: ${g};`);
|
|
208
208
|
const S = {
|
|
@@ -212,7 +212,7 @@ function oe(e = {}) {
|
|
|
212
212
|
...w.length > 0 ? { style: w.join(" ") } : {}
|
|
213
213
|
};
|
|
214
214
|
return u.render("th", I(S), i.children);
|
|
215
|
-
},
|
|
215
|
+
}, z = /* @__PURE__ */ new Map([
|
|
216
216
|
[R.DOCUMENT, d("")],
|
|
217
217
|
[R.HEADING, h],
|
|
218
218
|
[R.PARAGRAPH, d("p")],
|
|
@@ -221,14 +221,14 @@ function oe(e = {}) {
|
|
|
221
221
|
[R.LIST_ITEM, d("li")],
|
|
222
222
|
[R.IMAGE, v],
|
|
223
223
|
[R.EMOJI, b],
|
|
224
|
-
[R.CODE_BLOCK,
|
|
224
|
+
[R.CODE_BLOCK, E],
|
|
225
225
|
[R.HR, d("hr")],
|
|
226
226
|
[R.BR, d("br")],
|
|
227
227
|
[R.QUOTE, d("blockquote")],
|
|
228
|
-
[R.COMPONENT,
|
|
229
|
-
[
|
|
230
|
-
[T.LINK,
|
|
231
|
-
[T.ANCHOR,
|
|
228
|
+
[R.COMPONENT, ce],
|
|
229
|
+
[Ce.TEXT, le],
|
|
230
|
+
[T.LINK, V],
|
|
231
|
+
[T.ANCHOR, V],
|
|
232
232
|
[T.STYLED, _("span", !0)],
|
|
233
233
|
[T.BOLD, _("strong")],
|
|
234
234
|
[T.TEXT_STYLE, _("span", !0)],
|
|
@@ -239,11 +239,11 @@ function oe(e = {}) {
|
|
|
239
239
|
[T.SUPERSCRIPT, _("sup")],
|
|
240
240
|
[T.SUBSCRIPT, _("sub")],
|
|
241
241
|
[T.HIGHLIGHT, _("mark")],
|
|
242
|
-
[R.TABLE,
|
|
243
|
-
[R.TABLE_ROW,
|
|
244
|
-
[R.TABLE_CELL,
|
|
245
|
-
[R.TABLE_HEADER,
|
|
246
|
-
]),
|
|
242
|
+
[R.TABLE, ue],
|
|
243
|
+
[R.TABLE_ROW, he],
|
|
244
|
+
[R.TABLE_CELL, de],
|
|
245
|
+
[R.TABLE_HEADER, pe]
|
|
246
|
+
]), Y = new Map([...z, ...Object.entries(n).map(([i, u]) => [i, u])]), fe = () => ({
|
|
247
247
|
render: (i, u = {}, p) => {
|
|
248
248
|
if (l && i) {
|
|
249
249
|
const f = t.get(i) || 0;
|
|
@@ -251,28 +251,28 @@ function oe(e = {}) {
|
|
|
251
251
|
}
|
|
252
252
|
return s(i, u, p);
|
|
253
253
|
},
|
|
254
|
-
originalResolvers:
|
|
255
|
-
mergedResolvers:
|
|
254
|
+
originalResolvers: z,
|
|
255
|
+
mergedResolvers: Y
|
|
256
256
|
});
|
|
257
257
|
function O(i) {
|
|
258
|
-
const u =
|
|
258
|
+
const u = Y.get(i.type);
|
|
259
259
|
if (!u)
|
|
260
260
|
return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
|
|
261
|
-
const p =
|
|
261
|
+
const p = fe();
|
|
262
262
|
if (i.type === "text") return u(i, p);
|
|
263
|
-
const f = i.content ? i.content.map(
|
|
263
|
+
const f = i.content ? i.content.map(U) : void 0;
|
|
264
264
|
return u({
|
|
265
265
|
...i,
|
|
266
266
|
children: f
|
|
267
267
|
}, p);
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function U(i) {
|
|
270
270
|
return i.type === "doc" ? a ? i.content.map(O) : i.content.map(O).join("") : Array.isArray(i) ? i.map(O) : O(i);
|
|
271
271
|
}
|
|
272
|
-
return { render:
|
|
272
|
+
return { render: U };
|
|
273
273
|
}
|
|
274
|
-
let
|
|
275
|
-
const
|
|
274
|
+
let K = !1;
|
|
275
|
+
const W = [], Ne = (e) => new Promise((t, s) => {
|
|
276
276
|
if (typeof window > "u") {
|
|
277
277
|
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
278
278
|
return;
|
|
@@ -282,23 +282,23 @@ const X = [], He = (e) => new Promise((t, s) => {
|
|
|
282
282
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
K ? n() : W.push(n);
|
|
286
286
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
287
287
|
t(void 0);
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
const r = document.createElement("script");
|
|
291
291
|
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (n) => s(n), r.onload = (n) => {
|
|
292
|
-
|
|
292
|
+
W.forEach((o) => o()), K = !0, t(n);
|
|
293
293
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
294
|
-
}), B = (e = "") => e.includes("/cdn/"),
|
|
294
|
+
}), B = (e = "") => e.includes("/cdn/"), He = (e, t = 25, s = 1) => ({
|
|
295
295
|
...e,
|
|
296
296
|
per_page: t,
|
|
297
297
|
page: s
|
|
298
|
-
}), Ue = (e) => new Promise((t) => setTimeout(t, e)),
|
|
298
|
+
}), Ue = (e) => new Promise((t) => setTimeout(t, e)), De = (e = 0, t) => Array.from({ length: e }, t), Be = (e = 0, t = e) => {
|
|
299
299
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
300
|
-
return
|
|
301
|
-
},
|
|
300
|
+
return De(s, (n, o) => o * r + e);
|
|
301
|
+
}, qe = async (e, t) => Promise.all(e.map(t)), Fe = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), G = (e, t, s) => {
|
|
302
302
|
const r = [];
|
|
303
303
|
for (const n in e) {
|
|
304
304
|
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
@@ -306,10 +306,10 @@ const X = [], He = (e) => new Promise((t, s) => {
|
|
|
306
306
|
if (o == null) continue;
|
|
307
307
|
const l = s ? "" : encodeURIComponent(n);
|
|
308
308
|
let a;
|
|
309
|
-
typeof o == "object" ? a =
|
|
309
|
+
typeof o == "object" ? a = G(o, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(o)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(o)}`, r.push(a);
|
|
310
310
|
}
|
|
311
311
|
return r.join("&");
|
|
312
|
-
},
|
|
312
|
+
}, X = (e) => {
|
|
313
313
|
const t = {
|
|
314
314
|
eu: "api.storyblok.com",
|
|
315
315
|
us: "api-us.storyblok.com",
|
|
@@ -319,7 +319,7 @@ const X = [], He = (e) => new Promise((t, s) => {
|
|
|
319
319
|
};
|
|
320
320
|
return t[e] ?? t.eu;
|
|
321
321
|
};
|
|
322
|
-
var
|
|
322
|
+
var Ge = class {
|
|
323
323
|
constructor(e) {
|
|
324
324
|
y(this, "baseURL"), y(this, "timeout"), y(this, "headers"), y(this, "responseInterceptor"), y(this, "fetch"), y(this, "ejectInterceptor"), y(this, "url"), y(this, "parameters"), y(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
|
325
325
|
}
|
|
@@ -356,7 +356,7 @@ var Ve = class {
|
|
|
356
356
|
}
|
|
357
357
|
async _methodHandler(e) {
|
|
358
358
|
let t = `${this.baseURL}${this.url}`, s = null;
|
|
359
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${
|
|
359
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${G(this.parameters)}` : s = JSON.stringify(this.parameters);
|
|
360
360
|
const r = new URL(t), n = new AbortController(), { signal: o } = n;
|
|
361
361
|
let l = null;
|
|
362
362
|
this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
|
|
@@ -410,13 +410,12 @@ var Ve = class {
|
|
|
410
410
|
r(n);
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
|
-
},
|
|
414
|
-
const
|
|
413
|
+
}, Ve = Ge;
|
|
414
|
+
const Q = "SB-Agent", q = {
|
|
415
415
|
defaultAgentName: "SB-JS-CLIENT",
|
|
416
416
|
defaultAgentVersion: "SB-Agent-Version",
|
|
417
417
|
packageVersion: "7.0.0"
|
|
418
|
-
},
|
|
419
|
-
DRAFT: "draft",
|
|
418
|
+
}, ze = {
|
|
420
419
|
PUBLISHED: "published"
|
|
421
420
|
}, Ye = 25, F = {
|
|
422
421
|
SMALL: 25,
|
|
@@ -427,27 +426,23 @@ const Z = "SB-Agent", q = {
|
|
|
427
426
|
MEDIUM: 15,
|
|
428
427
|
LARGE: 10,
|
|
429
428
|
VERY_LARGE: 6
|
|
430
|
-
},
|
|
431
|
-
function Je(e) {
|
|
432
|
-
return e.version === ie.DRAFT;
|
|
433
|
-
}
|
|
434
|
-
function Ke(e, t) {
|
|
429
|
+
}, Z = 1e3, P = 3;
|
|
430
|
+
function Je(e, t) {
|
|
435
431
|
const s = e.includes("/cdn/stories/"), r = e.split("/").length > 3 && !e.endsWith("/cdn/stories"), n = "find_by" in t;
|
|
436
432
|
return s && r || n;
|
|
437
433
|
}
|
|
438
|
-
function
|
|
434
|
+
function Ke(e) {
|
|
439
435
|
return e <= F.SMALL ? C.SINGLE_OR_SMALL : e <= F.MEDIUM ? C.MEDIUM : e <= F.LARGE ? C.LARGE : C.VERY_LARGE;
|
|
440
436
|
}
|
|
441
437
|
function M(e, t, s = {}, r) {
|
|
442
|
-
if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit,
|
|
443
|
-
if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit,
|
|
438
|
+
if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, Z);
|
|
439
|
+
if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit, Z);
|
|
444
440
|
if (r !== void 0) return r;
|
|
445
|
-
if (t
|
|
446
|
-
if (Ke(e, t)) return C.SINGLE_OR_SMALL;
|
|
441
|
+
if (!e || !t || Je(e, t)) return C.SINGLE_OR_SMALL;
|
|
447
442
|
const n = t.per_page || Ye;
|
|
448
|
-
return
|
|
443
|
+
return Ke(n);
|
|
449
444
|
}
|
|
450
|
-
function
|
|
445
|
+
function We(e) {
|
|
451
446
|
if (!e) return null;
|
|
452
447
|
const t = e["x-ratelimit"] || e["X-RateLimit"], s = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
|
|
453
448
|
if (!t && !s) return null;
|
|
@@ -462,19 +457,19 @@ function Xe(e) {
|
|
|
462
457
|
}
|
|
463
458
|
return Object.keys(r).length > 0 ? r : null;
|
|
464
459
|
}
|
|
465
|
-
function
|
|
460
|
+
function Xe(e, t = !1) {
|
|
466
461
|
return {
|
|
467
462
|
userRateLimit: e,
|
|
468
463
|
serverHeadersRateLimit: void 0,
|
|
469
464
|
isManagementApi: t
|
|
470
465
|
};
|
|
471
466
|
}
|
|
472
|
-
var
|
|
467
|
+
var Qe = class extends Error {
|
|
473
468
|
constructor(e) {
|
|
474
469
|
super(e), this.name = "AbortError";
|
|
475
470
|
}
|
|
476
471
|
};
|
|
477
|
-
function
|
|
472
|
+
function Ze(e, t, s) {
|
|
478
473
|
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
|
479
474
|
if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
|
|
480
475
|
const r = [];
|
|
@@ -500,10 +495,10 @@ function et(e, t, s) {
|
|
|
500
495
|
}), o < t && a();
|
|
501
496
|
});
|
|
502
497
|
return c.abort = () => {
|
|
503
|
-
l = !0, n.forEach(clearTimeout), n = [], r.forEach((d) => d.reject(() => new
|
|
498
|
+
l = !0, n.forEach(clearTimeout), n = [], r.forEach((d) => d.reject(() => new Qe("Throttle function aborted"))), r.length = 0;
|
|
504
499
|
}, c;
|
|
505
500
|
}
|
|
506
|
-
var
|
|
501
|
+
var et = Ze, tt = class {
|
|
507
502
|
constructor(e, t = 1e3) {
|
|
508
503
|
y(this, "queues"), y(this, "interval"), y(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
|
|
509
504
|
}
|
|
@@ -512,7 +507,7 @@ var tt = et, st = class {
|
|
|
512
507
|
*/
|
|
513
508
|
getQueue(e) {
|
|
514
509
|
let t = this.queues.get(e);
|
|
515
|
-
return t || (t =
|
|
510
|
+
return t || (t = et(this.throttledRequestFn, e, this.interval), this.queues.set(e, t)), t;
|
|
516
511
|
}
|
|
517
512
|
/**
|
|
518
513
|
* Executes a request through the appropriate throttle queue based on rate limit
|
|
@@ -537,8 +532,8 @@ var tt = et, st = class {
|
|
|
537
532
|
}
|
|
538
533
|
};
|
|
539
534
|
let N = {};
|
|
540
|
-
const
|
|
541
|
-
var
|
|
535
|
+
const L = {};
|
|
536
|
+
var st = class {
|
|
542
537
|
/**
|
|
543
538
|
*
|
|
544
539
|
* @param config ISbConfig interface
|
|
@@ -549,12 +544,12 @@ var rt = class {
|
|
|
549
544
|
let s = e.endpoint || t;
|
|
550
545
|
if (!s) {
|
|
551
546
|
const n = e.https === !1 ? "http" : "https";
|
|
552
|
-
e.oauthToken ? s = `${n}://${
|
|
547
|
+
e.oauthToken ? s = `${n}://${X(e.region)}/v1` : s = `${n}://${X(e.region)}/v2`;
|
|
553
548
|
}
|
|
554
549
|
const r = new Headers();
|
|
555
550
|
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, o]) => {
|
|
556
551
|
r.set(n, o);
|
|
557
|
-
}), r.has(
|
|
552
|
+
}), r.has(Q) || (r.set(Q, q.defaultAgentName), r.set(q.defaultAgentVersion, q.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = Xe(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new tt(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ze.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ve({
|
|
558
553
|
baseURL: s,
|
|
559
554
|
timeout: e.timeout || 0,
|
|
560
555
|
headers: r,
|
|
@@ -563,13 +558,13 @@ var rt = class {
|
|
|
563
558
|
});
|
|
564
559
|
}
|
|
565
560
|
parseParams(e) {
|
|
566
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
561
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = L[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
567
562
|
}
|
|
568
563
|
factoryParamOptions(e, t) {
|
|
569
564
|
return B(e) ? this.parseParams(t) : t;
|
|
570
565
|
}
|
|
571
566
|
makeRequest(e, t, s, r, n) {
|
|
572
|
-
const o = this.factoryParamOptions(e,
|
|
567
|
+
const o = this.factoryParamOptions(e, He(t, s, r));
|
|
573
568
|
return this.cacheResponse(e, o, void 0, n);
|
|
574
569
|
}
|
|
575
570
|
get(e, t = {}, s) {
|
|
@@ -582,8 +577,8 @@ var rt = class {
|
|
|
582
577
|
async getAll(e, t = {}, s, r) {
|
|
583
578
|
const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), l = s ?? o.substring(o.lastIndexOf("/") + 1);
|
|
584
579
|
t.version = t.version || this.version;
|
|
585
|
-
const a = 1, c = await this.makeRequest(o, t, n, a, r), d = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, v = await
|
|
586
|
-
return
|
|
580
|
+
const a = 1, c = await this.makeRequest(o, t, n, a, r), d = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, v = await qe(Be(a, d), (h) => this.makeRequest(o, t, n, h + 1, r));
|
|
581
|
+
return Fe([c, ...v], (h) => Object.values(h.data[l]));
|
|
587
582
|
}
|
|
588
583
|
post(e, t = {}, s) {
|
|
589
584
|
const r = `/${e}`, n = M(void 0, void 0, this.rateLimitConfig, P);
|
|
@@ -763,7 +758,7 @@ var rt = class {
|
|
|
763
758
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
764
759
|
}
|
|
765
760
|
async cacheResponse(e, t, s, r) {
|
|
766
|
-
const n =
|
|
761
|
+
const n = G({
|
|
767
762
|
url: e,
|
|
768
763
|
params: t
|
|
769
764
|
}), o = this.cacheProvider();
|
|
@@ -781,8 +776,8 @@ var rt = class {
|
|
|
781
776
|
data: h.data,
|
|
782
777
|
headers: h.headers
|
|
783
778
|
};
|
|
784
|
-
const
|
|
785
|
-
if ((
|
|
779
|
+
const E = We(h.headers);
|
|
780
|
+
if ((E == null ? void 0 : E.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = E.max), (v = h.headers) != null && v["per-page"] && (b = Object.assign({}, b, {
|
|
786
781
|
perPage: h.headers["per-page"] ? Number.parseInt(h.headers["per-page"]) : 0,
|
|
787
782
|
total: h.headers["per-page"] ? Number.parseInt(h.headers.total) : 0
|
|
788
783
|
})), b.data.story || b.data.stories) {
|
|
@@ -791,7 +786,7 @@ var rt = class {
|
|
|
791
786
|
}
|
|
792
787
|
t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, b);
|
|
793
788
|
const _ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
794
|
-
return t.token && b.data.cv && (_ &&
|
|
789
|
+
return t.token && b.data.cv && (_ && L[t.token] && L[t.token] !== b.data.cv && await this.flushCache(), L[t.token] = b.data.cv), c(b);
|
|
795
790
|
} catch (h) {
|
|
796
791
|
if (h.response && h.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
797
792
|
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ue(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(d);
|
|
@@ -803,16 +798,16 @@ var rt = class {
|
|
|
803
798
|
return this.client.setFetchOptions(r), this.client[e](t, s);
|
|
804
799
|
}
|
|
805
800
|
cacheVersions() {
|
|
806
|
-
return
|
|
801
|
+
return L;
|
|
807
802
|
}
|
|
808
803
|
cacheVersion() {
|
|
809
|
-
return
|
|
804
|
+
return L[this.accessToken];
|
|
810
805
|
}
|
|
811
806
|
setCacheVersion(e) {
|
|
812
|
-
this.accessToken && (
|
|
807
|
+
this.accessToken && (L[this.accessToken] = e);
|
|
813
808
|
}
|
|
814
809
|
clearCacheVersion() {
|
|
815
|
-
this.accessToken && (
|
|
810
|
+
this.accessToken && (L[this.accessToken] = 0);
|
|
816
811
|
}
|
|
817
812
|
cacheProvider() {
|
|
818
813
|
switch (this.cache.type) {
|
|
@@ -868,8 +863,8 @@ var rt = class {
|
|
|
868
863
|
};
|
|
869
864
|
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((s) => (s.content = t(s.content), s))), e;
|
|
870
865
|
}
|
|
871
|
-
},
|
|
872
|
-
const
|
|
866
|
+
}, rt = st;
|
|
867
|
+
const dt = (e = {}) => {
|
|
873
868
|
const { apiOptions: t } = e;
|
|
874
869
|
if (!t || !t.accessToken) {
|
|
875
870
|
console.error(
|
|
@@ -877,8 +872,8 @@ const pt = (e = {}) => {
|
|
|
877
872
|
);
|
|
878
873
|
return;
|
|
879
874
|
}
|
|
880
|
-
return { storyblokApi: new
|
|
881
|
-
},
|
|
875
|
+
return { storyblokApi: new rt(t) };
|
|
876
|
+
}, nt = (e) => {
|
|
882
877
|
if (typeof e != "object" || typeof e._editable > "u")
|
|
883
878
|
return {};
|
|
884
879
|
try {
|
|
@@ -894,7 +889,7 @@ const pt = (e = {}) => {
|
|
|
894
889
|
}
|
|
895
890
|
};
|
|
896
891
|
let ee = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
897
|
-
const
|
|
892
|
+
const ot = (e, t, s = {}) => {
|
|
898
893
|
var r;
|
|
899
894
|
const n = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
900
895
|
"_storyblok"
|
|
@@ -911,7 +906,7 @@ const it = (e, t, s = {}) => {
|
|
|
911
906
|
});
|
|
912
907
|
});
|
|
913
908
|
}
|
|
914
|
-
},
|
|
909
|
+
}, it = (e = {}) => {
|
|
915
910
|
var t, s;
|
|
916
911
|
const {
|
|
917
912
|
bridge: r,
|
|
@@ -927,12 +922,12 @@ const it = (e, t, s = {}) => {
|
|
|
927
922
|
d = { ...d, ...h(c) };
|
|
928
923
|
}), a && (ee = a);
|
|
929
924
|
const v = !(typeof window > "u") && ((s = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : s.includes("_storyblok_tk"));
|
|
930
|
-
return r !== !1 && v &&
|
|
925
|
+
return r !== !1 && v && Ne(ee), d;
|
|
931
926
|
};
|
|
932
|
-
function
|
|
927
|
+
function pt(e, t) {
|
|
933
928
|
return oe(t).render(e);
|
|
934
929
|
}
|
|
935
|
-
const
|
|
930
|
+
const ie = /* @__PURE__ */ te({
|
|
936
931
|
__name: "StoryblokComponent",
|
|
937
932
|
props: {
|
|
938
933
|
blok: {}
|
|
@@ -943,51 +938,51 @@ const ae = /* @__PURE__ */ te({
|
|
|
943
938
|
t({
|
|
944
939
|
value: r
|
|
945
940
|
});
|
|
946
|
-
const n = typeof
|
|
947
|
-
return !n && o && (o.enableFallbackComponent ? (l.value = o.customFallbackComponent ?? "FallbackComponent", typeof
|
|
941
|
+
const n = typeof D(s.blok.component) != "string", o = ge("VueSDKOptions"), l = H((a = s.blok.component) == null ? void 0 : a.replace(/_/g, "-"));
|
|
942
|
+
return !n && o && (o.enableFallbackComponent ? (l.value = o.customFallbackComponent ?? "FallbackComponent", typeof D(l.value) == "string" && console.error(
|
|
948
943
|
`Is the Fallback component "${l.value}" registered properly?`
|
|
949
944
|
)) : console.error(
|
|
950
945
|
`Component could not be found for blok "${s.blok.component}"! Is it defined in main.ts as "app.component("${s.blok.component}", ${s.blok.component});"?`
|
|
951
|
-
)), (c, d) => (re(), se(
|
|
946
|
+
)), (c, d) => (re(), se(D(l.value), ve({
|
|
952
947
|
ref_key: "blokRef",
|
|
953
948
|
ref: r
|
|
954
|
-
}, { ...c.$props, ...c.$attrs }),
|
|
955
|
-
|
|
949
|
+
}, { ...c.$props, ...c.$attrs }), be({ _: 2 }, [
|
|
950
|
+
ke(c.$slots, (v, h) => ({
|
|
956
951
|
name: h,
|
|
957
|
-
fn:
|
|
958
|
-
|
|
952
|
+
fn: Re((b) => [
|
|
953
|
+
we(c.$slots, h, _e(Te(b)))
|
|
959
954
|
])
|
|
960
955
|
}))
|
|
961
956
|
]), 1040));
|
|
962
957
|
}
|
|
963
|
-
}),
|
|
958
|
+
}), at = (e) => {
|
|
964
959
|
var s;
|
|
965
960
|
const t = (s = e == null ? void 0 : e.attrs) == null ? void 0 : s.body;
|
|
966
961
|
return !Array.isArray(t) || t.length === 0 ? [] : t.map(
|
|
967
962
|
(r) => {
|
|
968
963
|
var n;
|
|
969
|
-
return ne(
|
|
964
|
+
return ne(ie, {
|
|
970
965
|
blok: r,
|
|
971
966
|
id: (n = e == null ? void 0 : e.attrs) == null ? void 0 : n.id
|
|
972
967
|
}, e.children);
|
|
973
968
|
}
|
|
974
969
|
);
|
|
975
970
|
};
|
|
976
|
-
function
|
|
971
|
+
function lt(e) {
|
|
977
972
|
const t = {
|
|
978
973
|
renderFn: ne,
|
|
979
974
|
// TODO: Check why this changed.
|
|
980
975
|
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
981
|
-
textFn:
|
|
976
|
+
textFn: Ae,
|
|
982
977
|
keyedResolvers: !0,
|
|
983
978
|
resolvers: {
|
|
984
|
-
[R.COMPONENT]:
|
|
979
|
+
[R.COMPONENT]: at,
|
|
985
980
|
...e.resolvers
|
|
986
981
|
}
|
|
987
982
|
};
|
|
988
983
|
return oe(t);
|
|
989
984
|
}
|
|
990
|
-
const
|
|
985
|
+
const ct = /* @__PURE__ */ te({
|
|
991
986
|
__name: "StoryblokRichText",
|
|
992
987
|
props: {
|
|
993
988
|
doc: {},
|
|
@@ -996,7 +991,7 @@ const ut = /* @__PURE__ */ te({
|
|
|
996
991
|
setup(e) {
|
|
997
992
|
const t = e, s = H(), r = () => s.value;
|
|
998
993
|
return Le([() => t.doc, () => t.resolvers], ([n, o]) => {
|
|
999
|
-
const { render: l } =
|
|
994
|
+
const { render: l } = lt({
|
|
1000
995
|
resolvers: o ?? {}
|
|
1001
996
|
});
|
|
1002
997
|
s.value = l(n);
|
|
@@ -1005,22 +1000,22 @@ const ut = /* @__PURE__ */ te({
|
|
|
1005
1000
|
deep: !0
|
|
1006
1001
|
}), (n, o) => (re(), se(r));
|
|
1007
1002
|
}
|
|
1008
|
-
}),
|
|
1003
|
+
}), ut = {
|
|
1009
1004
|
beforeMount(e, t) {
|
|
1010
1005
|
if (t.value) {
|
|
1011
|
-
const s =
|
|
1006
|
+
const s = nt(t.value);
|
|
1012
1007
|
Object.keys(s).length > 0 && (e.setAttribute("data-blok-c", s["data-blok-c"]), e.setAttribute("data-blok-uid", s["data-blok-uid"]), e.classList.add("storyblok__outline"));
|
|
1013
1008
|
}
|
|
1014
1009
|
}
|
|
1015
|
-
},
|
|
1010
|
+
}, ae = (e) => {
|
|
1016
1011
|
console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1017
1012
|
`);
|
|
1018
1013
|
};
|
|
1019
1014
|
let x = null;
|
|
1020
|
-
const
|
|
1015
|
+
const ft = () => (x || ae("useStoryblokApi"), x), mt = async (e, t = {}, s = {}) => {
|
|
1021
1016
|
const r = H(null);
|
|
1022
|
-
if (s.resolveRelations = s.resolveRelations ?? t.resolve_relations, s.resolveLinks = s.resolveLinks ?? t.resolve_links,
|
|
1023
|
-
r.value && r.value.id &&
|
|
1017
|
+
if (s.resolveRelations = s.resolveRelations ?? t.resolve_relations, s.resolveLinks = s.resolveLinks ?? t.resolve_links, Ee(() => {
|
|
1018
|
+
r.value && r.value.id && ot(
|
|
1024
1019
|
r.value.id,
|
|
1025
1020
|
(n) => r.value = n,
|
|
1026
1021
|
s
|
|
@@ -1032,31 +1027,31 @@ const mt = () => (x || le("useStoryblokApi"), x), yt = async (e, t = {}, s = {})
|
|
|
1032
1027
|
);
|
|
1033
1028
|
r.value = n.story;
|
|
1034
1029
|
} else
|
|
1035
|
-
|
|
1030
|
+
ae("useStoryblok");
|
|
1036
1031
|
return r;
|
|
1037
|
-
},
|
|
1032
|
+
}, yt = {
|
|
1038
1033
|
install(e, t = {}) {
|
|
1039
|
-
e.directive("editable",
|
|
1034
|
+
e.directive("editable", ut), e.component("StoryblokComponent", ie), e.component("StoryblokRichText", ct), t.enableFallbackComponent && !t.customFallbackComponent && e.component(
|
|
1040
1035
|
"FallbackComponent",
|
|
1041
|
-
|
|
1036
|
+
$e(() => import("./FallbackComponent-vpkAikkq.js"))
|
|
1042
1037
|
);
|
|
1043
|
-
const { storyblokApi: s } =
|
|
1038
|
+
const { storyblokApi: s } = it(t);
|
|
1044
1039
|
x = s || null, e.provide("VueSDKOptions", t);
|
|
1045
1040
|
}
|
|
1046
1041
|
};
|
|
1047
1042
|
export {
|
|
1048
1043
|
R as BlockTypes,
|
|
1049
1044
|
T as MarkTypes,
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1045
|
+
rt as StoryblokClient,
|
|
1046
|
+
ie as StoryblokComponent,
|
|
1047
|
+
ct as StoryblokRichText,
|
|
1048
|
+
yt as StoryblokVue,
|
|
1049
|
+
Ce as TextTypes,
|
|
1050
|
+
dt as apiPlugin,
|
|
1051
|
+
pt as renderRichText,
|
|
1057
1052
|
oe as richTextResolver,
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1053
|
+
mt as useStoryblok,
|
|
1054
|
+
ft as useStoryblokApi,
|
|
1055
|
+
ot as useStoryblokBridge,
|
|
1056
|
+
lt as useStoryblokRichText
|
|
1062
1057
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.4.
|
|
4
|
+
"version": "9.4.5",
|
|
5
5
|
"description": "SDK to integrate Storyblok into your project using Vue.",
|
|
6
6
|
"author": "Storyblok",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"vue": ">=3.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@storyblok/js": "4.4.
|
|
34
|
+
"@storyblok/js": "4.4.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rollup/plugin-typescript": "^12.1.2",
|