@storyblok/vue 9.0.4-rc.0 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/storyblok-vue.js +2 -2
- package/dist/storyblok-vue.mjs +98 -98
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
21
|
<p align="center">
|
|
22
|
-
<a href="https://
|
|
23
|
-
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=
|
|
22
|
+
<a href="https://storyblok.com/join-discord">
|
|
23
|
+
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=8d60ff">
|
|
24
24
|
</a>
|
|
25
25
|
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
|
|
26
|
-
<img src="https://img.shields.io/badge/Follow-%40storyblok-
|
|
26
|
+
<img src="https://img.shields.io/badge/Follow-%40storyblok-8d60ff?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
|
|
27
27
|
</a>
|
|
28
28
|
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue">
|
|
29
|
-
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-
|
|
29
|
+
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-8d60ff?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
|
|
30
30
|
</a>
|
|
31
31
|
</p>
|
|
32
32
|
|
|
@@ -52,7 +52,7 @@ For help, discussion about best practices, or any other conversation that would
|
|
|
52
52
|
|
|
53
53
|
For community support, chatting with other users, please visit:
|
|
54
54
|
|
|
55
|
-
- [Discuss Storyblok on Discord](https://
|
|
55
|
+
- [Discuss Storyblok on Discord](https://storyblok.com/join-discord)
|
|
56
56
|
|
|
57
57
|
## Support
|
|
58
58
|
|
|
@@ -67,7 +67,7 @@ We understand that you might not be able to share your company's project code. P
|
|
|
67
67
|
|
|
68
68
|
### Feedback
|
|
69
69
|
|
|
70
|
-
If you have a question, please ask in the [Discuss Storyblok on Discord](https://
|
|
70
|
+
If you have a question, please ask in the [Discuss Storyblok on Discord](https://storyblok.com/join-discord) channel.
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
## License
|
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(v,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(v=typeof globalThis<"u"?globalThis:v||self,f(v.storyblokVue={},v.Vue))})(this,function(v,f){"use strict";function te(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function a(i,u,m,y,E){typeof i!="number"||i<=u||i>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):E.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:i}=e||{},{blur:u,brightness:m,fill:y,format:E,grayscale:$,quality:L,rotate:P}=i||{};u&&a(u,0,100,"blur",n),L&&a(L,0,100,"quality",n),m&&a(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),$&&n.push("grayscale()"),P&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${P})`),E&&["webp","png","jpeg"].includes(E)&&n.push(`format(${E})`)}e.srcset&&(r.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${s}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,m]=i;return`${s}/m/${u}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let c=`${s}/m/`;return t>0&&o>0&&(c=`${c}${t}x${o}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:r}}var k=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s))(k||{}),R=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))(R||{}),x=(s=>(s.TEXT="text",s))(x||{}),C=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(C||{});const se=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],re=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),oe=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function ne(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function F(s,e={},t){const o=re(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(se.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function D(s={}){const e=new Map,{renderFn:t=F,textFn:o=ne,resolvers:r={},optimizeImages:n=!1,keyedResolvers:a=!1}=s,c=t!==F,i=l=>(h,d)=>{const p=h.attrs||{};return d.render(l,p,h.children||null)},u=(l,h)=>{const{src:d,alt:p,title:g,srcset:T,sizes:_}=l.attrs||{};let w=d,A={};if(n){const{src:Ue,attrs:Me}=te(d,n);w=Ue,A=Me}const He={src:w,alt:p,title:g,srcset:T,sizes:_,...A};return h.render("img",O(He))},m=(l,h)=>{const{level:d,...p}=l.attrs||{};return h.render(`h${d}`,p,l.children)},y=(l,h)=>{var d,p,g,T;const _=h.render("img",{src:(d=l.attrs)==null?void 0:d.fallbackImage,alt:(p=l.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(g=l.attrs)==null?void 0:g.name,"data-emoji":(T=l.attrs)==null?void 0:T.emoji},_)},E=(l,h)=>h.render("pre",l.attrs||{},h.render("code",{},l.children||"")),$=(l,h=!1)=>({text:d,attrs:p},g)=>{const{class:T,id:_,...w}=p||{},A=h?{class:T,id:_,style:oe(w)||void 0}:p||{};return g.render(l,O(A),d)},L=l=>M(l),P=l=>{const{marks:h,...d}=l;if("text"in l){if(h)return h.reduce((g,T)=>L({...T,text:g}),L({...d,children:d.children}));const p=l.attrs||{};if(a){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Q=(l,h)=>{const{linktype:d,href:p,anchor:g,...T}=l.attrs||{};let _="";switch(d){case C.ASSET:case C.URL:_=p;break;case C.EMAIL:_=`mailto:${p}`;break;case C.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const w={...T};return _&&(w.href=_),h.render("a",w,l.text)},je=(l,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(p=l.attrs)==null?void 0:p.id,style:"display: none"})},Pe=(l,h)=>{const d={},p=h.render("tbody",{},l.children);return h.render("table",d,p)},Ne=(l,h)=>{const d={};return h.render("tr",d,l.children)},xe=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const A=[];return g&&A.push(`width: ${g}px;`),T&&A.push(`background-color: ${T};`),A.length>0&&(w.style=A.join(" ")),h.render("td",O(w),l.children)},De=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const A=[];return g&&A.push(`width: ${g}px;`),T&&A.push(`background-color: ${T};`),A.length>0&&(w.style=A.join(" ")),h.render("th",O(w),l.children)},Z=new Map([[k.DOCUMENT,i("")],[k.HEADING,m],[k.PARAGRAPH,i("p")],[k.UL_LIST,i("ul")],[k.OL_LIST,i("ol")],[k.LIST_ITEM,i("li")],[k.IMAGE,u],[k.EMOJI,y],[k.CODE_BLOCK,E],[k.HR,i("hr")],[k.BR,i("br")],[k.QUOTE,i("blockquote")],[k.COMPONENT,je],[x.TEXT,P],[R.LINK,Q],[R.ANCHOR,Q],[R.STYLED,$("span",!0)],[R.BOLD,$("strong")],[R.TEXT_STYLE,$("span",!0)],[R.ITALIC,$("em")],[R.UNDERLINE,$("u")],[R.STRIKE,$("s")],[R.CODE,$("code")],[R.SUPERSCRIPT,$("sup")],[R.SUBSCRIPT,$("sub")],[R.HIGHLIGHT,$("mark")],[k.TABLE,Pe],[k.TABLE_ROW,Ne],[k.TABLE_CELL,xe],[k.TABLE_HEADER,De]]),ee=new Map([...Z,...Object.entries(r).map(([l,h])=>[l,h])]),Be=()=>({render:(l,h={},d)=>{if(a&&l){const p=e.get(l)||0;e.set(l,p+1),h.key=`${l}-${p}`}return t(l,h,d)},originalResolvers:Z,mergedResolvers:ee});function N(l){const h=ee.get(l.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=Be();if(l.type==="text")return h(l,d);const p=l.content?l.content.map(M):void 0;return h({...l,children:p},d)}function M(l){return l.type==="doc"?c?l.content.map(N):l.content.map(N).join(""):Array.isArray(l)?l.map(N):N(l)}return{render:M}}let V=!1;const z=[],ie=s=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}V?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=r=>t(r),o.onload=r=>{z.forEach(n=>n()),V=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var ae=Object.defineProperty,le=(s,e,t)=>e in s?ae(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>le(s,typeof e!="symbol"?e+"":e,t);class ce extends Error{constructor(e){super(e),this.name="AbortError"}}function ue(s,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let r=[],n=0,a=!1;const c=async()=>{n++;const u=o.shift();if(u)try{const y=await s(...u.args);u.resolve(y)}catch(y){u.reject(y)}const m=setTimeout(()=>{n--,o.length>0&&c(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},i=(...u)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,y)=>{o.push({resolve:m,reject:y,args:u}),n<e&&c()});return i.abort=()=>{a=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ce("Throttle function aborted"))),o.length=0},i}const he=(s="")=>s.includes("/cdn/"),de=(s,e=25,t=1)=>({...s,per_page:e,page:t}),pe=s=>new Promise(e=>setTimeout(e,s)),fe=(s=0,e)=>Array.from({length:s},e),me=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return fe(t,(r,n)=>n*o+s)},ye=async(s,e)=>Promise.all(s.map(e)),be=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),B=(s,e,t)=>{const o=[];for(const r in s){if(!Object.prototype.hasOwnProperty.call(s,r))continue;const n=s[r];if(n==null)continue;const a=t?"":encodeURIComponent(r);let c;typeof n=="object"?c=B(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(c)}return o.join("&")},q=s=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[s]??e.eu};class ke{constructor(e){b(this,"baseURL"),b(this,"timeout"),b(this,"headers"),b(this,"responseInterceptor"),b(this,"fetch"),b(this,"ejectInterceptor"),b(this,"url"),b(this,"parameters"),b(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=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{o.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:a}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const i=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(c);const u=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(i){return{message:i}}}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((o,r)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}}const G="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},ge={DRAFT:"draft"};let j={};const S={};class ve{constructor(e,t){b(this,"client"),b(this,"maxRetries"),b(this,"retriesDelay"),b(this,"throttle"),b(this,"accessToken"),b(this,"cache"),b(this,"resolveCounter"),b(this,"relations"),b(this,"links"),b(this,"version"),b(this,"richTextResolver"),b(this,"resolveNestedRelations"),b(this,"stringifiedStoriesCache"),b(this,"inlineAssets");let o=e.endpoint||t;if(!o){const a=e.https===!1?"http":"https";e.oauthToken?o=`${a}://${q(e.region)}/v1`:o=`${a}://${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(([a,c])=>{r.set(a,c)}),r.has(G)||(r.set(G,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=ue(this.throttledRequest.bind(this),n,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||ge.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:o,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 he(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const a=this.factoryParamOptions(e,de(t,o,r));return this.cacheResponse(e,a,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,o)}async getAll(e,t={},o,r){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),c=o??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,u=await this.makeRequest(a,t,n,i,r),m=u.total?Math.ceil(u.total/n):1,y=await ye(me(i,m),E=>this.makeRequest(a,t,n,E+1,r));return be([u,...y],E=>Object.values(E.data[c]))}post(e,t={},o){const r=`/${e}`;return this.throttle("post",r,t,o)}put(e,t={},o){const r=`/${e}`;return this.throttle("put",r,t,o)}delete(e,t={},o){t||(t={});const r=`/${e}`;return this.throttle("delete",r,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}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,o){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[o][r.id]?r.story=this._cleanCopy(this.links[o][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[o][r.uuid]&&(r.story=this._cleanCopy(this.links[o][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,o){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(o,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,r){if(Array.isArray(o)?o.find(a=>a.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,r)}iterateTree(e,t,o){const r=(n,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((c,i)=>r(c,`${a}[${i}]`));else if(typeof n=="object")for(const c in n){const i=a?`${a}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,o),this._insertLinks(n,c,o)),r(n[c],i)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.link_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.rel_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var r,n;let a=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(a=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),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,o),this.resolveNestedRelations)for(const c in this.relations[o])this.iterateTree(this.relations[o][c],a,o);e.story?this.iterateTree(e.story,a,o):e.stories.forEach(c=>{this.iterateTree(c,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=B({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await a.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,i)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return i(m);let y={data:m.data,headers:m.headers};if((u=m.headers)!=null&&u["per-page"]&&(y=Object.assign({},y,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),y.data.story||y.data.stories){const $=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${$}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,y);const E=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(E&&S[t.token]&&S[t.token]!==y.data.cv&&await this.flushCache(),S[t.token]=y.data.cv),c(y)}catch(m){if(m.response&&m.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await pe(this.retriesDelay),this.cacheResponse(e,t,o).then(c).catch(i);i(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}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(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},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=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let r={...o};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...r,...e.data.assets.find(n=>n.id===r.id)});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(o=>(o.content=t(o.content),o))),e}}const _e=(s={})=>{const{apiOptions:e}=s;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ve(e)}},we=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let J="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(s,e,t={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),a=n!==null&&+n===s;if(!(!r||!a)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],c=>{var i;c&&(c.action==="input"&&((i=c.story)==null?void 0:i.id)===s?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===s&&window.location.reload())})})}},Te=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:a={},bridgeUrl:c}=s;a.accessToken=a.accessToken||r;const i={bridge:o,apiOptions:a};let u={};n.forEach(y=>{u={...u,...y(i)}}),c&&(J=c);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return o!==!1&&m&&ie(J),u};function Re(s,e){return D(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),a=f.ref(t.blok.component);return!r&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(a.value)=="string"&&console.error(`Is the Fallback component "${a.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(c,i)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(a.value),f.mergeProps({ref_key:"blokRef",ref:o},{...c.$props,...c.$attrs}),null,16))}}),$e=s=>{var e,t;return f.h(U,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function Y(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:$e,...s.resolvers}};return D(e)}const W=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=f.ref(),o=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([r,n])=>{const{render:a}=Y({resolvers:n??{}});t.value=a(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),Ae={beforeMount(s,e){if(e.value){const t=we(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},X=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
-
`)};let I=null;const
|
|
7
|
+
(function(v,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(v=typeof globalThis<"u"?globalThis:v||self,f(v.storyblokVue={},v.Vue))})(this,function(v,f){"use strict";function se(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function a(i,u,m,y,S){typeof i!="number"||i<=u||i>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):S.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:i}=e||{},{blur:u,brightness:m,fill:y,format:S,grayscale:$,quality:L,rotate:P}=i||{};u&&a(u,0,100,"blur",n),L&&a(L,0,100,"quality",n),m&&a(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),$&&n.push("grayscale()"),P&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${P})`),S&&["webp","png","jpeg"].includes(S)&&n.push(`format(${S})`)}e.srcset&&(r.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${s}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,m]=i;return`${s}/m/${u}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let c=`${s}/m/`;return t>0&&o>0&&(c=`${c}${t}x${o}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:r}}var k=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s))(k||{}),R=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))(R||{}),x=(s=>(s.TEXT="text",s))(x||{}),C=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(C||{});const re=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],oe=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),ne=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function ie(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function V(s,e={},t){const o=oe(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(re.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function B(s={}){const e=new Map,{renderFn:t=V,textFn:o=ie,resolvers:r={},optimizeImages:n=!1,keyedResolvers:a=!1}=s,c=t!==V,i=l=>(h,d)=>{const p=h.attrs||{};return d.render(l,p,h.children||null)},u=(l,h)=>{const{src:d,alt:p,title:g,srcset:T,sizes:_}=l.attrs||{};let w=d,E={};if(n){const{src:Ue,attrs:Me}=se(d,n);w=Ue,E=Me}const He={src:w,alt:p,title:g,srcset:T,sizes:_,...E};return h.render("img",O(He))},m=(l,h)=>{const{level:d,...p}=l.attrs||{};return h.render(`h${d}`,p,l.children)},y=(l,h)=>{var d,p,g,T;const _=h.render("img",{src:(d=l.attrs)==null?void 0:d.fallbackImage,alt:(p=l.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(g=l.attrs)==null?void 0:g.name,"data-emoji":(T=l.attrs)==null?void 0:T.emoji},_)},S=(l,h)=>h.render("pre",l.attrs||{},h.render("code",{},l.children||"")),$=(l,h=!1)=>({text:d,attrs:p},g)=>{const{class:T,id:_,...w}=p||{},E=h?{class:T,id:_,style:ne(w)||void 0}:p||{};return g.render(l,O(E),d)},L=l=>M(l),P=l=>{const{marks:h,...d}=l;if("text"in l){if(h)return h.reduce((g,T)=>L({...T,text:g}),L({...d,children:d.children}));const p=l.attrs||{};if(a){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Z=(l,h)=>{const{linktype:d,href:p,anchor:g,...T}=l.attrs||{};let _="";switch(d){case C.ASSET:case C.URL:_=p;break;case C.EMAIL:_=`mailto:${p}`;break;case C.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const w={...T};return _&&(w.href=_),h.render("a",w,l.text)},je=(l,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(p=l.attrs)==null?void 0:p.id,style:"display: none"})},Pe=(l,h)=>{const d={},p=h.render("tbody",{},l.children);return h.render("table",d,p)},Ne=(l,h)=>{const d={};return h.render("tr",d,l.children)},xe=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const E=[];return g&&E.push(`width: ${g}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(w.style=E.join(" ")),h.render("td",O(w),l.children)},Be=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const E=[];return g&&E.push(`width: ${g}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(w.style=E.join(" ")),h.render("th",O(w),l.children)},ee=new Map([[k.DOCUMENT,i("")],[k.HEADING,m],[k.PARAGRAPH,i("p")],[k.UL_LIST,i("ul")],[k.OL_LIST,i("ol")],[k.LIST_ITEM,i("li")],[k.IMAGE,u],[k.EMOJI,y],[k.CODE_BLOCK,S],[k.HR,i("hr")],[k.BR,i("br")],[k.QUOTE,i("blockquote")],[k.COMPONENT,je],[x.TEXT,P],[R.LINK,Z],[R.ANCHOR,Z],[R.STYLED,$("span",!0)],[R.BOLD,$("strong")],[R.TEXT_STYLE,$("span",!0)],[R.ITALIC,$("em")],[R.UNDERLINE,$("u")],[R.STRIKE,$("s")],[R.CODE,$("code")],[R.SUPERSCRIPT,$("sup")],[R.SUBSCRIPT,$("sub")],[R.HIGHLIGHT,$("mark")],[k.TABLE,Pe],[k.TABLE_ROW,Ne],[k.TABLE_CELL,xe],[k.TABLE_HEADER,Be]]),te=new Map([...ee,...Object.entries(r).map(([l,h])=>[l,h])]),De=()=>({render:(l,h={},d)=>{if(a&&l){const p=e.get(l)||0;e.set(l,p+1),h.key=`${l}-${p}`}return t(l,h,d)},originalResolvers:ee,mergedResolvers:te});function N(l){const h=te.get(l.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=De();if(l.type==="text")return h(l,d);const p=l.content?l.content.map(M):void 0;return h({...l,children:p},d)}function M(l){return l.type==="doc"?c?l.content.map(N):l.content.map(N).join(""):Array.isArray(l)?l.map(N):N(l)}return{render:M}}let F=!1;const z=[],ae=s=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}F?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=r=>t(r),o.onload=r=>{z.forEach(n=>n()),F=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var le=Object.defineProperty,ce=(s,e,t)=>e in s?le(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>ce(s,typeof e!="symbol"?e+"":e,t);class ue extends Error{constructor(e){super(e),this.name="AbortError"}}function he(s,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let r=[],n=0,a=!1;const c=async()=>{n++;const u=o.shift();if(u)try{const y=await s(...u.args);u.resolve(y)}catch(y){u.reject(y)}const m=setTimeout(()=>{n--,o.length>0&&c(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},i=(...u)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,y)=>{o.push({resolve:m,reject:y,args:u}),n<e&&c()});return i.abort=()=>{a=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ue("Throttle function aborted"))),o.length=0},i}const q=(s="")=>s.includes("/cdn/"),de=(s,e=25,t=1)=>({...s,per_page:e,page:t}),pe=s=>new Promise(e=>setTimeout(e,s)),fe=(s=0,e)=>Array.from({length:s},e),me=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return fe(t,(r,n)=>n*o+s)},ye=async(s,e)=>Promise.all(s.map(e)),be=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),D=(s,e,t)=>{const o=[];for(const r in s){if(!Object.prototype.hasOwnProperty.call(s,r))continue;const n=s[r];if(n==null)continue;const a=t?"":encodeURIComponent(r);let c;typeof n=="object"?c=D(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(c)}return o.join("&")},G=s=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[s]??e.eu};class ke{constructor(e){b(this,"baseURL"),b(this,"timeout"),b(this,"headers"),b(this,"responseInterceptor"),b(this,"fetch"),b(this,"ejectInterceptor"),b(this,"url"),b(this,"parameters"),b(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=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{o.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${D(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:a}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const i=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(c);const u=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(i){return{message:i}}}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((o,r)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}}const J="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ge={PUBLISHED:"published"};let j={};const A={};class ve{constructor(e,t){b(this,"client"),b(this,"maxRetries"),b(this,"retriesDelay"),b(this,"throttle"),b(this,"accessToken"),b(this,"cache"),b(this,"resolveCounter"),b(this,"relations"),b(this,"links"),b(this,"version"),b(this,"richTextResolver"),b(this,"resolveNestedRelations"),b(this,"stringifiedStoriesCache"),b(this,"inlineAssets");let o=e.endpoint||t;if(!o){const a=e.https===!1?"http":"https";e.oauthToken?o=`${a}://${G(e.region)}/v1`:o=`${a}://${G(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(([a,c])=>{r.set(a,c)}),r.has(J)||(r.set(J,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=he(this.throttledRequest.bind(this),n,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||ge.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:o,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=A[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 q(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const a=this.factoryParamOptions(e,de(t,o,r));return this.cacheResponse(e,a,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;q(r)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,o)}async getAll(e,t={},o,r){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),c=o??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,u=await this.makeRequest(a,t,n,i,r),m=u.total?Math.ceil(u.total/n):1,y=await ye(me(i,m),S=>this.makeRequest(a,t,n,S+1,r));return be([u,...y],S=>Object.values(S.data[c]))}post(e,t={},o){const r=`/${e}`;return this.throttle("post",r,t,o)}put(e,t={},o){const r=`/${e}`;return this.throttle("put",r,t,o)}delete(e,t={},o){t||(t={});const r=`/${e}`;return this.throttle("delete",r,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}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,o){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[o][r.id]?r.story=this._cleanCopy(this.links[o][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[o][r.uuid]&&(r.story=this._cleanCopy(this.links[o][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,o){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(o,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,r){if(Array.isArray(o)?o.find(a=>a.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,r)}iterateTree(e,t,o){const r=(n,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((c,i)=>r(c,`${a}[${i}]`));else if(typeof n=="object")for(const c in n){const i=a?`${a}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,o),this._insertLinks(n,c,o)),r(n[c],i)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.link_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.rel_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var r,n;let a=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(a=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),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,o),this.resolveNestedRelations)for(const c in this.relations[o])this.iterateTree(this.relations[o][c],a,o);e.story?this.iterateTree(e.story,a,o):e.stories.forEach(c=>{this.iterateTree(c,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=D({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await a.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,i)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return i(m);let y={data:m.data,headers:m.headers};if((u=m.headers)!=null&&u["per-page"]&&(y=Object.assign({},y,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),y.data.story||y.data.stories){const $=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${$}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,y);const S=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(S&&A[t.token]&&A[t.token]!==y.data.cv&&await this.flushCache(),A[t.token]=y.data.cv),c(y)}catch(m){if(m.response&&m.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await pe(this.retriesDelay),this.cacheResponse(e,t,o).then(c).catch(i);i(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}cacheVersions(){return A}cacheVersion(){return A[this.accessToken]}setCacheVersion(e){this.accessToken&&(A[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(A[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},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=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let r={...o};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...r,...e.data.assets.find(n=>n.id===r.id)});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(o=>(o.content=t(o.content),o))),e}}const _e=(s={})=>{const{apiOptions:e}=s;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ve(e)}},we=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let K="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(s,e,t={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),a=n!==null&&+n===s;if(!(!r||!a)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],c=>{var i;c&&(c.action==="input"&&((i=c.story)==null?void 0:i.id)===s?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===s&&window.location.reload())})})}},Te=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:a={},bridgeUrl:c}=s;a.accessToken=a.accessToken||r;const i={bridge:o,apiOptions:a};let u={};n.forEach(y=>{u={...u,...y(i)}}),c&&(K=c);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return o!==!1&&m&&ae(K),u};function Re(s,e){return B(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),a=f.ref(t.blok.component);return!r&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(a.value)=="string"&&console.error(`Is the Fallback component "${a.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(c,i)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(a.value),f.mergeProps({ref_key:"blokRef",ref:o},{...c.$props,...c.$attrs}),null,16))}}),$e=s=>{var e,t;return f.h(U,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function W(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:$e,...s.resolvers}};return B(e)}const X=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=f.ref(),o=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([r,n])=>{const{render:a}=W({resolvers:n??{}});t.value=a(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),Ee={beforeMount(s,e){if(e.value){const t=we(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},Q=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
+
`)};let I=null;const Se=()=>(I||Q("useStoryblokApi"),I),Ae=async(s,e={},t={})=>{const o=f.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,f.onMounted(()=>{o.value&&o.value.id&&Y(o.value.id,r=>o.value=r,t)}),I){const{data:r}=await I.get(`cdn/stories/${s}`,e);o.value=r.story}else Q("useStoryblok");return o},Ce={install(s,e={}){s.directive("editable",Ee),s.component("StoryblokComponent",U),s.component("StoryblokRichText",X),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>Oe)));const{storyblokApi:t}=Te(e);I=t||null,s.provide("VueSDKOptions",e)}},Ie={class:"fallback-component"},Le={class:"component"},Oe=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[o,r]of e)t[o]=r;return t})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(f.openBlock(),f.createElementBlock("div",Ie,[f.createElementVNode("p",null,[t[0]||(t[0]=f.createTextVNode(" Component could not be found for blok ")),f.createElementVNode("span",Le,f.toDisplayString(e.blok.component),1),t[1]||(t[1]=f.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=k,v.MarkTypes=R,v.StoryblokComponent=U,v.StoryblokRichText=X,v.StoryblokVue=Ce,v.TextTypes=x,v.apiPlugin=_e,v.renderRichText=Re,v.richTextResolver=B,v.useStoryblok=Ae,v.useStoryblokApi=Se,v.useStoryblokBridge=Y,v.useStoryblokRichText=W,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent as
|
|
8
|
-
function
|
|
7
|
+
import { defineComponent as Y, ref as P, resolveDynamicComponent as N, inject as de, createBlock as W, openBlock as X, mergeProps as pe, h as Q, createTextVNode as fe, watch as ye, onMounted as me, defineAsyncComponent as be } from "vue";
|
|
8
|
+
function ge(s, e) {
|
|
9
9
|
if (!e)
|
|
10
10
|
return { src: s, attrs: {} };
|
|
11
11
|
let t = 0, o = 0;
|
|
@@ -15,8 +15,8 @@ function be(s, e) {
|
|
|
15
15
|
}
|
|
16
16
|
if (typeof e == "object") {
|
|
17
17
|
if (typeof e.width == "number" && e.width > 0 ? (r.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (r.height = e.height, o = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (r.loading = e.loading), e.class && (r.class = e.class), e.filters) {
|
|
18
|
-
const { filters: i } = e || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: T, quality:
|
|
19
|
-
u && a(u, 0, 100, "blur", n),
|
|
18
|
+
const { filters: i } = e || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: T, quality: A, rotate: L } = i || {};
|
|
19
|
+
u && a(u, 0, 100, "blur", n), A && a(A, 0, 100, "quality", n), f && a(f, 0, 100, "brightness", n), y && n.push(`fill(${y})`), T && n.push("grayscale()"), L && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${L})`), R && ["webp", "png", "jpeg"].includes(R) && n.push(`format(${R})`);
|
|
20
20
|
}
|
|
21
21
|
e.srcset && (r.srcset = e.srcset.map((i) => {
|
|
22
22
|
if (typeof i == "number")
|
|
@@ -36,8 +36,8 @@ function be(s, e) {
|
|
|
36
36
|
attrs: r
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
var g = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s.TABLE = "table", s.TABLE_ROW = "tableRow", s.TABLE_CELL = "tableCell", s.TABLE_HEADER = "tableHeader", s))(g || {}), $ = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))($ || {}),
|
|
40
|
-
const
|
|
39
|
+
var g = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s.TABLE = "table", s.TABLE_ROW = "tableRow", s.TABLE_CELL = "tableCell", s.TABLE_HEADER = "tableHeader", s))(g || {}), $ = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))($ || {}), Z = /* @__PURE__ */ ((s) => (s.TEXT = "text", s))(Z || {}), S = /* @__PURE__ */ ((s) => (s.URL = "url", s.STORY = "story", s.ASSET = "asset", s.EMAIL = "email", s))(S || {});
|
|
40
|
+
const ve = [
|
|
41
41
|
"area",
|
|
42
42
|
"base",
|
|
43
43
|
"br",
|
|
@@ -52,23 +52,23 @@ const ge = [
|
|
|
52
52
|
"source",
|
|
53
53
|
"track",
|
|
54
54
|
"wbr"
|
|
55
|
-
],
|
|
56
|
-
function
|
|
55
|
+
], ke = (s = {}) => Object.keys(s).map((e) => `${e}="${s[e]}"`).join(" "), we = (s = {}) => Object.keys(s).map((e) => `${e}: ${s[e]}`).join("; ");
|
|
56
|
+
function Te(s) {
|
|
57
57
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
58
58
|
}
|
|
59
59
|
const O = (s) => Object.fromEntries(Object.entries(s).filter(([e, t]) => t !== void 0));
|
|
60
60
|
function F(s, e = {}, t) {
|
|
61
|
-
const o =
|
|
61
|
+
const o = ke(e), r = o ? `${s} ${o}` : s, n = Array.isArray(t) ? t.join("") : t || "";
|
|
62
62
|
if (s) {
|
|
63
|
-
if (
|
|
63
|
+
if (ve.includes(s))
|
|
64
64
|
return `<${r}>`;
|
|
65
65
|
} else return n;
|
|
66
66
|
return `<${r}>${n}</${s}>`;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ee(s = {}) {
|
|
69
69
|
const e = /* @__PURE__ */ new Map(), {
|
|
70
70
|
renderFn: t = F,
|
|
71
|
-
textFn: o =
|
|
71
|
+
textFn: o = Te,
|
|
72
72
|
resolvers: r = {},
|
|
73
73
|
optimizeImages: n = !1,
|
|
74
74
|
keyedResolvers: a = !1
|
|
@@ -79,10 +79,10 @@ function Z(s = {}) {
|
|
|
79
79
|
const { src: d, alt: p, title: b, srcset: w, sizes: v } = l.attrs || {};
|
|
80
80
|
let k = d, _ = {};
|
|
81
81
|
if (n) {
|
|
82
|
-
const { src:
|
|
83
|
-
k =
|
|
82
|
+
const { src: ue, attrs: he } = ge(d, n);
|
|
83
|
+
k = ue, _ = he;
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const ce = {
|
|
86
86
|
src: k,
|
|
87
87
|
alt: p,
|
|
88
88
|
title: b,
|
|
@@ -90,7 +90,7 @@ function Z(s = {}) {
|
|
|
90
90
|
sizes: v,
|
|
91
91
|
..._
|
|
92
92
|
};
|
|
93
|
-
return h.render("img", O(
|
|
93
|
+
return h.render("img", O(ce));
|
|
94
94
|
}, f = (l, h) => {
|
|
95
95
|
const { level: d, ...p } = l.attrs || {};
|
|
96
96
|
return h.render(`h${d}`, p, l.children);
|
|
@@ -116,16 +116,16 @@ function Z(s = {}) {
|
|
|
116
116
|
const { class: w, id: v, ...k } = p || {}, _ = h ? {
|
|
117
117
|
class: w,
|
|
118
118
|
id: v,
|
|
119
|
-
style:
|
|
119
|
+
style: we(k) || void 0
|
|
120
120
|
} : p || {};
|
|
121
121
|
return b.render(l, O(_), d);
|
|
122
|
-
},
|
|
122
|
+
}, A = (l) => x(l), L = (l) => {
|
|
123
123
|
const { marks: h, ...d } = l;
|
|
124
124
|
if ("text" in l) {
|
|
125
125
|
if (h)
|
|
126
126
|
return h.reduce(
|
|
127
|
-
(b, w) =>
|
|
128
|
-
|
|
127
|
+
(b, w) => A({ ...w, text: b }),
|
|
128
|
+
A({ ...d, children: d.children })
|
|
129
129
|
);
|
|
130
130
|
const p = l.attrs || {};
|
|
131
131
|
if (a) {
|
|
@@ -135,7 +135,7 @@ function Z(s = {}) {
|
|
|
135
135
|
return o(d.text, p);
|
|
136
136
|
}
|
|
137
137
|
return "";
|
|
138
|
-
},
|
|
138
|
+
}, D = (l, h) => {
|
|
139
139
|
const { linktype: d, href: p, anchor: b, ...w } = l.attrs || {};
|
|
140
140
|
let v = "";
|
|
141
141
|
switch (d) {
|
|
@@ -155,27 +155,27 @@ function Z(s = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
const k = { ...w };
|
|
157
157
|
return v && (k.href = v), h.render("a", k, l.text);
|
|
158
|
-
},
|
|
158
|
+
}, re = (l, h) => {
|
|
159
159
|
var d, p;
|
|
160
160
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
|
|
161
161
|
blok: (d = l == null ? void 0 : l.attrs) == null ? void 0 : d.body[0],
|
|
162
162
|
id: (p = l.attrs) == null ? void 0 : p.id,
|
|
163
163
|
style: "display: none"
|
|
164
164
|
});
|
|
165
|
-
},
|
|
165
|
+
}, oe = (l, h) => {
|
|
166
166
|
const d = {}, p = h.render("tbody", {}, l.children);
|
|
167
167
|
return h.render("table", d, p);
|
|
168
|
-
},
|
|
168
|
+
}, ne = (l, h) => {
|
|
169
169
|
const d = {};
|
|
170
170
|
return h.render("tr", d, l.children);
|
|
171
|
-
},
|
|
171
|
+
}, ie = (l, h) => {
|
|
172
172
|
const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = l.attrs || {}, k = {
|
|
173
173
|
...v
|
|
174
174
|
};
|
|
175
175
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
176
176
|
const _ = [];
|
|
177
177
|
return b && _.push(`width: ${b}px;`), w && _.push(`background-color: ${w};`), _.length > 0 && (k.style = _.join(" ")), h.render("td", O(k), l.children);
|
|
178
|
-
},
|
|
178
|
+
}, ae = (l, h) => {
|
|
179
179
|
const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = l.attrs || {}, k = {
|
|
180
180
|
...v
|
|
181
181
|
};
|
|
@@ -195,10 +195,10 @@ function Z(s = {}) {
|
|
|
195
195
|
[g.HR, i("hr")],
|
|
196
196
|
[g.BR, i("br")],
|
|
197
197
|
[g.QUOTE, i("blockquote")],
|
|
198
|
-
[g.COMPONENT,
|
|
199
|
-
[
|
|
200
|
-
[$.LINK,
|
|
201
|
-
[$.ANCHOR,
|
|
198
|
+
[g.COMPONENT, re],
|
|
199
|
+
[Z.TEXT, L],
|
|
200
|
+
[$.LINK, D],
|
|
201
|
+
[$.ANCHOR, D],
|
|
202
202
|
[$.STYLED, T("span", !0)],
|
|
203
203
|
[$.BOLD, T("strong")],
|
|
204
204
|
[$.TEXT_STYLE, T("span", !0)],
|
|
@@ -209,14 +209,14 @@ function Z(s = {}) {
|
|
|
209
209
|
[$.SUPERSCRIPT, T("sup")],
|
|
210
210
|
[$.SUBSCRIPT, T("sub")],
|
|
211
211
|
[$.HIGHLIGHT, T("mark")],
|
|
212
|
-
[g.TABLE,
|
|
213
|
-
[g.TABLE_ROW,
|
|
214
|
-
[g.TABLE_CELL,
|
|
215
|
-
[g.TABLE_HEADER,
|
|
212
|
+
[g.TABLE, oe],
|
|
213
|
+
[g.TABLE_ROW, ne],
|
|
214
|
+
[g.TABLE_CELL, ie],
|
|
215
|
+
[g.TABLE_HEADER, ae]
|
|
216
216
|
]), M = new Map([
|
|
217
217
|
...B,
|
|
218
218
|
...Object.entries(r).map(([l, h]) => [l, h])
|
|
219
|
-
]),
|
|
219
|
+
]), le = () => ({
|
|
220
220
|
render: (l, h = {}, d) => {
|
|
221
221
|
if (a && l) {
|
|
222
222
|
const p = e.get(l) || 0;
|
|
@@ -231,24 +231,24 @@ function Z(s = {}) {
|
|
|
231
231
|
const h = M.get(l.type);
|
|
232
232
|
if (!h)
|
|
233
233
|
return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
|
|
234
|
-
const d =
|
|
234
|
+
const d = le();
|
|
235
235
|
if (l.type === "text")
|
|
236
236
|
return h(l, d);
|
|
237
|
-
const p = l.content ? l.content.map(
|
|
237
|
+
const p = l.content ? l.content.map(x) : void 0;
|
|
238
238
|
return h({
|
|
239
239
|
...l,
|
|
240
240
|
children: p
|
|
241
241
|
}, d);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function x(l) {
|
|
244
244
|
return l.type === "doc" ? c ? l.content.map(C) : l.content.map(C).join("") : Array.isArray(l) ? l.map(C) : C(l);
|
|
245
245
|
}
|
|
246
246
|
return {
|
|
247
|
-
render:
|
|
247
|
+
render: x
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
let V = !1;
|
|
251
|
-
const z = [],
|
|
251
|
+
const z = [], _e = (s) => new Promise((e, t) => {
|
|
252
252
|
if (typeof window > "u") {
|
|
253
253
|
t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
254
254
|
return;
|
|
@@ -268,8 +268,8 @@ const z = [], Te = (s) => new Promise((e, t) => {
|
|
|
268
268
|
z.forEach((n) => n()), V = !0, e(r);
|
|
269
269
|
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
270
270
|
});
|
|
271
|
-
var
|
|
272
|
-
class
|
|
271
|
+
var Re = Object.defineProperty, $e = (s, e, t) => e in s ? Re(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, m = (s, e, t) => $e(s, typeof e != "symbol" ? e + "" : e, t);
|
|
272
|
+
class Ee extends Error {
|
|
273
273
|
constructor(e) {
|
|
274
274
|
super(e), this.name = "AbortError";
|
|
275
275
|
}
|
|
@@ -308,18 +308,18 @@ function Ae(s, e, t) {
|
|
|
308
308
|
});
|
|
309
309
|
return i.abort = () => {
|
|
310
310
|
a = !0, r.forEach(clearTimeout), r = [], o.forEach(
|
|
311
|
-
(u) => u.reject(() => new
|
|
311
|
+
(u) => u.reject(() => new Ee("Throttle function aborted"))
|
|
312
312
|
), o.length = 0;
|
|
313
313
|
}, i;
|
|
314
314
|
}
|
|
315
|
-
const
|
|
315
|
+
const G = (s = "") => s.includes("/cdn/"), Se = (s, e = 25, t = 1) => ({
|
|
316
316
|
...s,
|
|
317
317
|
per_page: e,
|
|
318
318
|
page: t
|
|
319
319
|
}), Ie = (s) => new Promise((e) => setTimeout(e, s)), Le = (s = 0, e) => Array.from({ length: s }, e), Ce = (s = 0, e = s) => {
|
|
320
320
|
const t = Math.abs(e - s) || 0, o = s < e ? 1 : -1;
|
|
321
321
|
return Le(t, (r, n) => n * o + s);
|
|
322
|
-
}, Oe = async (s, e) => Promise.all(s.map(e)), je = (s = [], e) => s.map(e).reduce((t, o) => [...t, ...o], []),
|
|
322
|
+
}, Oe = async (s, e) => Promise.all(s.map(e)), je = (s = [], e) => s.map(e).reduce((t, o) => [...t, ...o], []), U = (s, e, t) => {
|
|
323
323
|
const o = [];
|
|
324
324
|
for (const r in s) {
|
|
325
325
|
if (!Object.prototype.hasOwnProperty.call(s, r))
|
|
@@ -329,14 +329,14 @@ const Ee = (s = "") => s.includes("/cdn/"), Se = (s, e = 25, t = 1) => ({
|
|
|
329
329
|
continue;
|
|
330
330
|
const a = t ? "" : encodeURIComponent(r);
|
|
331
331
|
let c;
|
|
332
|
-
typeof n == "object" ? c =
|
|
332
|
+
typeof n == "object" ? c = U(
|
|
333
333
|
n,
|
|
334
334
|
e ? e + encodeURIComponent(`[${a}]`) : a,
|
|
335
335
|
Array.isArray(n)
|
|
336
336
|
) : c = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(c);
|
|
337
337
|
}
|
|
338
338
|
return o.join("&");
|
|
339
|
-
},
|
|
339
|
+
}, q = (s) => {
|
|
340
340
|
const e = {
|
|
341
341
|
eu: "api.storyblok.com",
|
|
342
342
|
us: "api-us.storyblok.com",
|
|
@@ -346,7 +346,7 @@ const Ee = (s = "") => s.includes("/cdn/"), Se = (s, e = 25, t = 1) => ({
|
|
|
346
346
|
};
|
|
347
347
|
return e[s] ?? e.eu;
|
|
348
348
|
};
|
|
349
|
-
class
|
|
349
|
+
class Pe {
|
|
350
350
|
constructor(e) {
|
|
351
351
|
m(this, "baseURL"), m(this, "timeout"), m(this, "headers"), m(this, "responseInterceptor"), m(this, "fetch"), m(this, "ejectInterceptor"), m(this, "url"), m(this, "parameters"), m(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 = {};
|
|
352
352
|
}
|
|
@@ -384,7 +384,7 @@ class xe {
|
|
|
384
384
|
}
|
|
385
385
|
async _methodHandler(e) {
|
|
386
386
|
let t = `${this.baseURL}${this.url}`, o = null;
|
|
387
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${
|
|
387
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${U(this.parameters)}` : o = JSON.stringify(this.parameters);
|
|
388
388
|
const r = new URL(t), n = new AbortController(), { signal: a } = n;
|
|
389
389
|
let c;
|
|
390
390
|
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
|
@@ -449,15 +449,15 @@ class xe {
|
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
const
|
|
452
|
+
const J = "SB-Agent", H = {
|
|
453
453
|
defaultAgentName: "SB-JS-CLIENT",
|
|
454
454
|
defaultAgentVersion: "SB-Agent-Version",
|
|
455
|
-
packageVersion: "
|
|
456
|
-
},
|
|
457
|
-
|
|
455
|
+
packageVersion: "7.0.0"
|
|
456
|
+
}, xe = {
|
|
457
|
+
PUBLISHED: "published"
|
|
458
458
|
};
|
|
459
459
|
let j = {};
|
|
460
|
-
const
|
|
460
|
+
const E = {};
|
|
461
461
|
class Ne {
|
|
462
462
|
/**
|
|
463
463
|
*
|
|
@@ -469,12 +469,12 @@ class Ne {
|
|
|
469
469
|
let o = e.endpoint || t;
|
|
470
470
|
if (!o) {
|
|
471
471
|
const a = e.https === !1 ? "http" : "https";
|
|
472
|
-
e.oauthToken ? o = `${a}://${
|
|
472
|
+
e.oauthToken ? o = `${a}://${q(e.region)}/v1` : o = `${a}://${q(e.region)}/v2`;
|
|
473
473
|
}
|
|
474
474
|
const r = new Headers();
|
|
475
475
|
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(([a, c]) => {
|
|
476
476
|
r.set(a, c);
|
|
477
|
-
}), r.has(
|
|
477
|
+
}), r.has(J) || (r.set(J, H.defaultAgentName), r.set(
|
|
478
478
|
H.defaultAgentVersion,
|
|
479
479
|
H.packageVersion
|
|
480
480
|
));
|
|
@@ -483,7 +483,7 @@ class Ne {
|
|
|
483
483
|
this.throttledRequest.bind(this),
|
|
484
484
|
n,
|
|
485
485
|
1e3
|
|
486
|
-
), 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 ||
|
|
486
|
+
), 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 || xe.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Pe({
|
|
487
487
|
baseURL: o,
|
|
488
488
|
timeout: e.timeout || 0,
|
|
489
489
|
headers: r,
|
|
@@ -492,10 +492,10 @@ class Ne {
|
|
|
492
492
|
});
|
|
493
493
|
}
|
|
494
494
|
parseParams(e) {
|
|
495
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
495
|
+
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;
|
|
496
496
|
}
|
|
497
497
|
factoryParamOptions(e, t) {
|
|
498
|
-
return
|
|
498
|
+
return G(e) ? this.parseParams(t) : t;
|
|
499
499
|
}
|
|
500
500
|
makeRequest(e, t, o, r, n) {
|
|
501
501
|
const a = this.factoryParamOptions(
|
|
@@ -507,7 +507,7 @@ class Ne {
|
|
|
507
507
|
get(e, t = {}, o) {
|
|
508
508
|
t || (t = {});
|
|
509
509
|
const r = `/${e}`;
|
|
510
|
-
t.version = t.version || this.version;
|
|
510
|
+
G(r) && (t.version = t.version || this.version);
|
|
511
511
|
const n = this.factoryParamOptions(r, t);
|
|
512
512
|
return this.cacheResponse(r, n, void 0, o);
|
|
513
513
|
}
|
|
@@ -713,7 +713,7 @@ class Ne {
|
|
|
713
713
|
}), this.stringifiedStoriesCache = {}, delete this.links[o], delete this.relations[o];
|
|
714
714
|
}
|
|
715
715
|
async cacheResponse(e, t, o, r) {
|
|
716
|
-
const n =
|
|
716
|
+
const n = U({ url: e, params: t }), a = this.cacheProvider();
|
|
717
717
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
718
718
|
const c = await a.get(n);
|
|
719
719
|
if (c)
|
|
@@ -740,7 +740,7 @@ class Ne {
|
|
|
740
740
|
}
|
|
741
741
|
t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, y);
|
|
742
742
|
const R = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
743
|
-
return t.token && y.data.cv && (R &&
|
|
743
|
+
return t.token && y.data.cv && (R && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), c(y);
|
|
744
744
|
} catch (f) {
|
|
745
745
|
if (f.response && f.status === 429 && (o = typeof o > "u" ? 0 : o + 1, o < this.maxRetries))
|
|
746
746
|
return console.log(
|
|
@@ -754,16 +754,16 @@ class Ne {
|
|
|
754
754
|
return this.client.setFetchOptions(r), this.client[e](t, o);
|
|
755
755
|
}
|
|
756
756
|
cacheVersions() {
|
|
757
|
-
return
|
|
757
|
+
return E;
|
|
758
758
|
}
|
|
759
759
|
cacheVersion() {
|
|
760
|
-
return
|
|
760
|
+
return E[this.accessToken];
|
|
761
761
|
}
|
|
762
762
|
setCacheVersion(e) {
|
|
763
|
-
this.accessToken && (
|
|
763
|
+
this.accessToken && (E[this.accessToken] = e);
|
|
764
764
|
}
|
|
765
765
|
clearCacheVersion() {
|
|
766
|
-
this.accessToken && (
|
|
766
|
+
this.accessToken && (E[this.accessToken] = 0);
|
|
767
767
|
}
|
|
768
768
|
cacheProvider() {
|
|
769
769
|
switch (this.cache.type) {
|
|
@@ -850,8 +850,8 @@ const Ge = (s = {}) => {
|
|
|
850
850
|
return {};
|
|
851
851
|
}
|
|
852
852
|
};
|
|
853
|
-
let
|
|
854
|
-
const
|
|
853
|
+
let K = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
854
|
+
const Ue = (s, e, t = {}) => {
|
|
855
855
|
var o;
|
|
856
856
|
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((o = window.location) == null ? void 0 : o.href).searchParams.get(
|
|
857
857
|
"_storyblok"
|
|
@@ -868,7 +868,7 @@ const De = (s, e, t = {}) => {
|
|
|
868
868
|
});
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
|
-
},
|
|
871
|
+
}, De = (s = {}) => {
|
|
872
872
|
var e, t;
|
|
873
873
|
const {
|
|
874
874
|
bridge: o,
|
|
@@ -882,37 +882,37 @@ const De = (s, e, t = {}) => {
|
|
|
882
882
|
let u = {};
|
|
883
883
|
n.forEach((y) => {
|
|
884
884
|
u = { ...u, ...y(i) };
|
|
885
|
-
}), c && (
|
|
885
|
+
}), c && (K = c);
|
|
886
886
|
const f = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
887
|
-
return o !== !1 && f &&
|
|
887
|
+
return o !== !1 && f && _e(K), u;
|
|
888
888
|
};
|
|
889
889
|
function qe(s, e) {
|
|
890
|
-
return
|
|
890
|
+
return ee(e).render(s);
|
|
891
891
|
}
|
|
892
|
-
const
|
|
892
|
+
const te = /* @__PURE__ */ Y({
|
|
893
893
|
__name: "StoryblokComponent",
|
|
894
894
|
props: {
|
|
895
895
|
blok: {}
|
|
896
896
|
},
|
|
897
897
|
setup(s, { expose: e }) {
|
|
898
|
-
const t = s, o =
|
|
898
|
+
const t = s, o = P();
|
|
899
899
|
e({
|
|
900
900
|
value: o
|
|
901
901
|
});
|
|
902
|
-
const r = typeof N(t.blok.component) != "string", n =
|
|
902
|
+
const r = typeof N(t.blok.component) != "string", n = de("VueSDKOptions"), a = P(t.blok.component);
|
|
903
903
|
return !r && n && (n.enableFallbackComponent ? (a.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(a.value) == "string" && console.error(
|
|
904
904
|
`Is the Fallback component "${a.value}" registered properly?`
|
|
905
905
|
)) : console.error(
|
|
906
906
|
`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
|
|
907
|
-
)), (c, i) => (
|
|
907
|
+
)), (c, i) => (X(), W(N(a.value), pe({
|
|
908
908
|
ref_key: "blokRef",
|
|
909
909
|
ref: o
|
|
910
910
|
}, { ...c.$props, ...c.$attrs }), null, 16));
|
|
911
911
|
}
|
|
912
912
|
}), Be = (s) => {
|
|
913
913
|
var e, t;
|
|
914
|
-
return
|
|
915
|
-
|
|
914
|
+
return Q(
|
|
915
|
+
te,
|
|
916
916
|
{
|
|
917
917
|
blok: (e = s == null ? void 0 : s.attrs) == null ? void 0 : e.body[0],
|
|
918
918
|
id: (t = s.attrs) == null ? void 0 : t.id
|
|
@@ -922,27 +922,27 @@ const ee = /* @__PURE__ */ K({
|
|
|
922
922
|
};
|
|
923
923
|
function Me(s) {
|
|
924
924
|
const e = {
|
|
925
|
-
renderFn:
|
|
925
|
+
renderFn: Q,
|
|
926
926
|
// TODO: Check why this changed.
|
|
927
927
|
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
928
|
-
textFn:
|
|
928
|
+
textFn: fe,
|
|
929
929
|
keyedResolvers: !0,
|
|
930
930
|
resolvers: {
|
|
931
931
|
[g.COMPONENT]: Be,
|
|
932
932
|
...s.resolvers
|
|
933
933
|
}
|
|
934
934
|
};
|
|
935
|
-
return
|
|
935
|
+
return ee(e);
|
|
936
936
|
}
|
|
937
|
-
const Fe = /* @__PURE__ */
|
|
937
|
+
const Fe = /* @__PURE__ */ Y({
|
|
938
938
|
__name: "StoryblokRichText",
|
|
939
939
|
props: {
|
|
940
940
|
doc: {},
|
|
941
941
|
resolvers: {}
|
|
942
942
|
},
|
|
943
943
|
setup(s) {
|
|
944
|
-
const e = s, t =
|
|
945
|
-
return
|
|
944
|
+
const e = s, t = P(), o = () => t.value;
|
|
945
|
+
return ye([() => e.doc, () => e.resolvers], ([r, n]) => {
|
|
946
946
|
const { render: a } = Me({
|
|
947
947
|
resolvers: n ?? {}
|
|
948
948
|
});
|
|
@@ -950,7 +950,7 @@ const Fe = /* @__PURE__ */ K({
|
|
|
950
950
|
}, {
|
|
951
951
|
immediate: !0,
|
|
952
952
|
deep: !0
|
|
953
|
-
}), (r, n) => (
|
|
953
|
+
}), (r, n) => (X(), W(o));
|
|
954
954
|
}
|
|
955
955
|
}), Ve = {
|
|
956
956
|
beforeMount(s, e) {
|
|
@@ -959,15 +959,15 @@ const Fe = /* @__PURE__ */ K({
|
|
|
959
959
|
Object.keys(t).length > 0 && (s.setAttribute("data-blok-c", t["data-blok-c"]), s.setAttribute("data-blok-uid", t["data-blok-uid"]), s.classList.add("storyblok__outline"));
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
|
-
},
|
|
962
|
+
}, se = (s) => {
|
|
963
963
|
console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
964
964
|
`);
|
|
965
965
|
};
|
|
966
966
|
let I = null;
|
|
967
|
-
const Je = () => (I ||
|
|
968
|
-
const o =
|
|
969
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
970
|
-
o.value && o.value.id &&
|
|
967
|
+
const Je = () => (I || se("useStoryblokApi"), I), Ke = async (s, e = {}, t = {}) => {
|
|
968
|
+
const o = P(null);
|
|
969
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, me(() => {
|
|
970
|
+
o.value && o.value.id && Ue(
|
|
971
971
|
o.value.id,
|
|
972
972
|
(r) => o.value = r,
|
|
973
973
|
t
|
|
@@ -979,30 +979,30 @@ const Je = () => (I || te("useStoryblokApi"), I), Ke = async (s, e = {}, t = {})
|
|
|
979
979
|
);
|
|
980
980
|
o.value = r.story;
|
|
981
981
|
} else
|
|
982
|
-
|
|
982
|
+
se("useStoryblok");
|
|
983
983
|
return o;
|
|
984
984
|
}, Ye = {
|
|
985
985
|
install(s, e = {}) {
|
|
986
|
-
s.directive("editable", Ve), s.component("StoryblokComponent",
|
|
986
|
+
s.directive("editable", Ve), s.component("StoryblokComponent", te), s.component("StoryblokRichText", Fe), e.enableFallbackComponent && !e.customFallbackComponent && s.component(
|
|
987
987
|
"FallbackComponent",
|
|
988
|
-
|
|
988
|
+
be(() => import("./FallbackComponent-Dky11gEu.js"))
|
|
989
989
|
);
|
|
990
|
-
const { storyblokApi: t } =
|
|
990
|
+
const { storyblokApi: t } = De(e);
|
|
991
991
|
I = t || null, s.provide("VueSDKOptions", e);
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
994
|
export {
|
|
995
995
|
g as BlockTypes,
|
|
996
996
|
$ as MarkTypes,
|
|
997
|
-
|
|
997
|
+
te as StoryblokComponent,
|
|
998
998
|
Fe as StoryblokRichText,
|
|
999
999
|
Ye as StoryblokVue,
|
|
1000
|
-
|
|
1000
|
+
Z as TextTypes,
|
|
1001
1001
|
Ge as apiPlugin,
|
|
1002
1002
|
qe as renderRichText,
|
|
1003
|
-
|
|
1003
|
+
ee as richTextResolver,
|
|
1004
1004
|
Ke as useStoryblok,
|
|
1005
1005
|
Je as useStoryblokApi,
|
|
1006
|
-
|
|
1006
|
+
Ue as useStoryblokBridge,
|
|
1007
1007
|
Me as useStoryblokRichText
|
|
1008
1008
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.1.1",
|
|
5
5
|
"description": "SDK to integrate Storyblok into your project using Vue.",
|
|
6
6
|
"author": "Storyblok",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/storyblok/monoblok/tree/main/packages/vue#readme",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/storyblok/
|
|
11
|
+
"url": "https://github.com/storyblok/monoblok.git",
|
|
12
|
+
"directory": "packages/vue"
|
|
11
13
|
},
|
|
12
14
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/storyblok/
|
|
15
|
+
"url": "https://github.com/storyblok/monoblok/issues"
|
|
14
16
|
},
|
|
15
17
|
"exports": {
|
|
16
18
|
".": {
|
|
@@ -29,12 +31,12 @@
|
|
|
29
31
|
"vue": ">=3.4"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@storyblok/js": "4.
|
|
34
|
+
"@storyblok/js": "4.1.1"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
36
38
|
"@storyblok/eslint-config": "^0.3.0",
|
|
37
|
-
"@types/node": "^22.15.
|
|
39
|
+
"@types/node": "^22.15.18",
|
|
38
40
|
"@typescript-eslint/parser": "^8.23.0",
|
|
39
41
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
40
42
|
"cypress": "^14.3.3",
|