@storyblok/vue 9.4.3 → 9.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FallbackComponent-vpkAikkq.js +1 -1
- package/dist/storyblok-vue.js +3 -3
- package/dist/storyblok-vue.mjs +25 -25
- package/dist/vue.css +1 -1
- package/package.json +2 -2
package/dist/storyblok-vue.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @storyblok/vue
|
|
3
|
-
* (c)
|
|
3
|
+
* (c) 2026
|
|
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:$,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 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 L=f,T={};if(o){const{src:st,attrs:rt}=ye(f,o);L=st,T=rt}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:fe(L)||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 L={...w};return b&&(L.href=b),u.render("a",L,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,...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)},et=(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)},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,$],[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{message:a}}}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",V={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ee={DRAFT:"draft",PUBLISHED:"published"},Ee=25,q={SMALL:25,MEDIUM:50,LARGE:75},O={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},G=1e3,M=3;function Le(e){return e.version===ee.DRAFT}function Se(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 $e(e){return e<=q.SMALL?O.SINGLE_OR_SMALL:e<=q.MEDIUM?O.MEDIUM:e<=q.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&&!Le(t))return G;if(Se(e,t))return O.SINGLE_OR_SMALL;const n=t.per_page||Ee;return $e(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 S={};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,V.defaultAgentName),r.set(V.defaultAgentVersion,V.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=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,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 $=Ce(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 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 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(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
|
|
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||ie("useStoryblokApi"),j),Ve=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&&re(r.value.id,n=>r.value=n,s)}),j){const{data:n}=await j.get(`cdn/stories/${e}`,t);r.value=n.story}else ie("useStoryblok");return r},Ge={install(e,t={}){e.directive("editable",Fe),e.component("StoryblokComponent",z),e.component("StoryblokRichText",oe),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Je)));const{storyblokApi:s}=He(t);j=s||null,e.provide("VueSDKOptions",t)}},ze={class:"fallback-component"},Ye={class:"component"},Je=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",ze,[d.createElementVNode("p",null,[s[0]||(s[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",Ye,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=te,_.StoryblokComponent=z,_.StoryblokRichText=oe,_.StoryblokVue=Ge,_.TextTypes=J,_.apiPlugin=Ne,_.renderRichText=Ue,_.richTextResolver=U,_.useStoryblok=Ve,_.useStoryblokApi=qe,_.useStoryblokBridge=re,_.useStoryblokRichText=ne,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @storyblok/vue
|
|
3
|
-
* (c)
|
|
3
|
+
* (c) 2026
|
|
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 U, inject as ve, createBlock as se, openBlock as re, mergeProps as be, createSlots as ke, renderList as Re, withCtx as we, renderSlot as _e, normalizeProps as Te, guardReactiveProps as Ae, h as ne, createTextVNode as
|
|
7
|
+
import { defineComponent as te, ref as H, resolveDynamicComponent as U, inject as ve, createBlock as se, openBlock as re, mergeProps as be, createSlots as ke, renderList as Re, withCtx as we, renderSlot as _e, normalizeProps as Te, guardReactiveProps as Ae, h as ne, createTextVNode as Ee, watch as Le, onMounted as $e, defineAsyncComponent as Se } from "vue";
|
|
8
8
|
var Ie = Object.defineProperty, Ce = (e, t, s) => t in e ? Ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, y = (e, t, s) => Ce(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;
|
|
@@ -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: L, 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})`), L && o.push("grayscale()"), $ && [
|
|
58
58
|
0,
|
|
59
59
|
90,
|
|
60
60
|
180,
|
|
@@ -134,7 +134,7 @@ 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
|
+
}, L = (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,
|
|
@@ -221,7 +221,7 @@ 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, L],
|
|
225
225
|
[R.HR, d("hr")],
|
|
226
226
|
[R.BR, d("br")],
|
|
227
227
|
[R.QUOTE, d("blockquote")],
|
|
@@ -295,10 +295,10 @@ const X = [], He = (e) => new Promise((t, s) => {
|
|
|
295
295
|
...e,
|
|
296
296
|
per_page: t,
|
|
297
297
|
page: s
|
|
298
|
-
}), Ue = (e) => new Promise((t) => setTimeout(t, e)), Be = (e = 0, t) => Array.from({ length: e }, t),
|
|
298
|
+
}), Ue = (e) => new Promise((t) => setTimeout(t, e)), Be = (e = 0, t) => Array.from({ length: e }, t), qe = (e = 0, t = e) => {
|
|
299
299
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
300
300
|
return Be(s, (n, o) => o * r + e);
|
|
301
|
-
},
|
|
301
|
+
}, Fe = async (e, t) => Promise.all(e.map(t)), Ge = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), V = (e, t, s) => {
|
|
302
302
|
const r = [];
|
|
303
303
|
for (const n in e) {
|
|
304
304
|
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
@@ -372,7 +372,7 @@ var Ve = class {
|
|
|
372
372
|
const c = await this._responseHandler(a);
|
|
373
373
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
|
|
374
374
|
} catch (a) {
|
|
375
|
-
return { message: a };
|
|
375
|
+
return a.name === "AbortError" ? { message: "Request timeout: The request was aborted due to timeout" } : { message: a.message || a.toString() || "An unknown error occurred" };
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
setFetchOptions(e = {}) {
|
|
@@ -411,14 +411,14 @@ var Ve = class {
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
}, ze = Ve;
|
|
414
|
-
const Z = "SB-Agent",
|
|
414
|
+
const Z = "SB-Agent", q = {
|
|
415
415
|
defaultAgentName: "SB-JS-CLIENT",
|
|
416
416
|
defaultAgentVersion: "SB-Agent-Version",
|
|
417
417
|
packageVersion: "7.0.0"
|
|
418
418
|
}, ie = {
|
|
419
419
|
DRAFT: "draft",
|
|
420
420
|
PUBLISHED: "published"
|
|
421
|
-
}, Ye = 25,
|
|
421
|
+
}, Ye = 25, F = {
|
|
422
422
|
SMALL: 25,
|
|
423
423
|
MEDIUM: 50,
|
|
424
424
|
LARGE: 75
|
|
@@ -436,7 +436,7 @@ function Ke(e, t) {
|
|
|
436
436
|
return s && r || n;
|
|
437
437
|
}
|
|
438
438
|
function We(e) {
|
|
439
|
-
return e <=
|
|
439
|
+
return e <= F.SMALL ? C.SINGLE_OR_SMALL : e <= F.MEDIUM ? C.MEDIUM : e <= F.LARGE ? C.LARGE : C.VERY_LARGE;
|
|
440
440
|
}
|
|
441
441
|
function M(e, t, s = {}, r) {
|
|
442
442
|
if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, G);
|
|
@@ -537,7 +537,7 @@ var tt = et, st = class {
|
|
|
537
537
|
}
|
|
538
538
|
};
|
|
539
539
|
let N = {};
|
|
540
|
-
const
|
|
540
|
+
const E = {};
|
|
541
541
|
var rt = class {
|
|
542
542
|
/**
|
|
543
543
|
*
|
|
@@ -554,7 +554,7 @@ var rt = class {
|
|
|
554
554
|
const r = new Headers();
|
|
555
555
|
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
556
|
r.set(n, o);
|
|
557
|
-
}), r.has(Z) || (r.set(Z,
|
|
557
|
+
}), r.has(Z) || (r.set(Z, q.defaultAgentName), r.set(q.defaultAgentVersion, q.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = Qe(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new st(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 || ie.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new ze({
|
|
558
558
|
baseURL: s,
|
|
559
559
|
timeout: e.timeout || 0,
|
|
560
560
|
headers: r,
|
|
@@ -563,7 +563,7 @@ var rt = class {
|
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
565
|
parseParams(e) {
|
|
566
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
566
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[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
567
|
}
|
|
568
568
|
factoryParamOptions(e, t) {
|
|
569
569
|
return B(e) ? this.parseParams(t) : t;
|
|
@@ -582,7 +582,7 @@ var rt = class {
|
|
|
582
582
|
async getAll(e, t = {}, s, r) {
|
|
583
583
|
const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), l = s ?? o.substring(o.lastIndexOf("/") + 1);
|
|
584
584
|
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 qe(
|
|
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 Fe(qe(a, d), (h) => this.makeRequest(o, t, n, h + 1, r));
|
|
586
586
|
return Ge([c, ...v], (h) => Object.values(h.data[l]));
|
|
587
587
|
}
|
|
588
588
|
post(e, t = {}, s) {
|
|
@@ -781,8 +781,8 @@ var rt = class {
|
|
|
781
781
|
data: h.data,
|
|
782
782
|
headers: h.headers
|
|
783
783
|
};
|
|
784
|
-
const
|
|
785
|
-
if ((
|
|
784
|
+
const L = Xe(h.headers);
|
|
785
|
+
if ((L == null ? void 0 : L.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = L.max), (v = h.headers) != null && v["per-page"] && (b = Object.assign({}, b, {
|
|
786
786
|
perPage: h.headers["per-page"] ? Number.parseInt(h.headers["per-page"]) : 0,
|
|
787
787
|
total: h.headers["per-page"] ? Number.parseInt(h.headers.total) : 0
|
|
788
788
|
})), b.data.story || b.data.stories) {
|
|
@@ -791,7 +791,7 @@ var rt = class {
|
|
|
791
791
|
}
|
|
792
792
|
t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, b);
|
|
793
793
|
const _ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
794
|
-
return t.token && b.data.cv && (_ &&
|
|
794
|
+
return t.token && b.data.cv && (_ && E[t.token] && E[t.token] !== b.data.cv && await this.flushCache(), E[t.token] = b.data.cv), c(b);
|
|
795
795
|
} catch (h) {
|
|
796
796
|
if (h.response && h.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
797
797
|
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 +803,16 @@ var rt = class {
|
|
|
803
803
|
return this.client.setFetchOptions(r), this.client[e](t, s);
|
|
804
804
|
}
|
|
805
805
|
cacheVersions() {
|
|
806
|
-
return
|
|
806
|
+
return E;
|
|
807
807
|
}
|
|
808
808
|
cacheVersion() {
|
|
809
|
-
return
|
|
809
|
+
return E[this.accessToken];
|
|
810
810
|
}
|
|
811
811
|
setCacheVersion(e) {
|
|
812
|
-
this.accessToken && (
|
|
812
|
+
this.accessToken && (E[this.accessToken] = e);
|
|
813
813
|
}
|
|
814
814
|
clearCacheVersion() {
|
|
815
|
-
this.accessToken && (
|
|
815
|
+
this.accessToken && (E[this.accessToken] = 0);
|
|
816
816
|
}
|
|
817
817
|
cacheProvider() {
|
|
818
818
|
switch (this.cache.type) {
|
|
@@ -978,7 +978,7 @@ function ct(e) {
|
|
|
978
978
|
renderFn: ne,
|
|
979
979
|
// TODO: Check why this changed.
|
|
980
980
|
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
981
|
-
textFn:
|
|
981
|
+
textFn: Ee,
|
|
982
982
|
keyedResolvers: !0,
|
|
983
983
|
resolvers: {
|
|
984
984
|
[R.COMPONENT]: lt,
|
|
@@ -995,7 +995,7 @@ const ut = /* @__PURE__ */ te({
|
|
|
995
995
|
},
|
|
996
996
|
setup(e) {
|
|
997
997
|
const t = e, s = H(), r = () => s.value;
|
|
998
|
-
return
|
|
998
|
+
return Le([() => t.doc, () => t.resolvers], ([n, o]) => {
|
|
999
999
|
const { render: l } = ct({
|
|
1000
1000
|
resolvers: o ?? {}
|
|
1001
1001
|
});
|
package/dist/vue.css
CHANGED
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.4",
|
|
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.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rollup/plugin-typescript": "^12.1.2",
|