@storyblok/js 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +224 -205
- package/package.json +2 -2
package/dist/storyblok-js.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
5
5
|
* author: undefined
|
6
6
|
*/
|
7
|
-
(function(v,
|
7
|
+
(function(v,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(v=typeof globalThis<"u"?globalThis:v||self,I(v.storyblok={}))})(this,function(v){"use strict";let I=!1;const q=[],F=i=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?r():q.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=i,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{q.forEach(n=>n()),I=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var Z=Object.defineProperty,ee=(i,e,t)=>e in i?Z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,m=(i,e,t)=>ee(i,typeof e!="symbol"?e+"":e,t);class te extends Error{constructor(e){super(e),this.name="AbortError"}}function se(i,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 s=[];let r=[],n=0,o=!1;const c=async()=>{n++;const h=s.shift();if(h)try{const d=await i(...h.args);h.resolve(d)}catch(d){h.reject(d)}const u=setTimeout(()=>{n--,s.length>0&&c(),r=r.filter(d=>d!==u)},t);r.includes(u)||r.push(u)},a=(...h)=>o?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,d)=>{s.push({resolve:u,reject:d,args:h}),n<e&&c()});return a.abort=()=>{o=!0,r.forEach(clearTimeout),r=[],s.forEach(h=>h.reject(()=>new te("Throttle function aborted"))),s.length=0},a}class x{constructor(){m(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),m(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),m(this,"delay",e=>new Promise(t=>setTimeout(t,e))),m(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),m(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,o)=>o*r+e)}),m(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),m(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),m(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,r=new RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(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 c=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=this.stringify(o,t?t+encodeURIComponent(`[${c}]`):c,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${c}]`):c}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",o="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return o;default:return t}}}const re=function(i,e){const t={};for(const s in i){const r=i[s];e.includes(s)&&r!==null&&(t[s]=r)}return t},ie=i=>i==="email",ne=()=>({singleTag:"hr"}),oe=()=>({tag:"blockquote"}),ae=()=>({tag:"ul"}),le=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),ce=()=>({singleTag:"br"}),he=i=>({tag:`h${i.attrs.level}`}),ue=i=>({singleTag:[{tag:"img",attrs:re(i.attrs,["src","alt","title"])}]}),de=()=>({tag:"li"}),pe=()=>({tag:"ol"}),ge=()=>({tag:"p"}),fe=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),me=()=>({tag:"b"}),ye=()=>({tag:"s"}),be=()=>({tag:"u"}),ke=()=>({tag:"strong"}),ve=()=>({tag:"code"}),$e=()=>({tag:"i"}),Te=i=>{if(!i.attrs)return{tag:""};const e=new x().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),ie(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},we=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Re=()=>({tag:"sub"}),Ee=()=>({tag:"sup"}),_e=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Se=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},Ae=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},G={nodes:{horizontal_rule:ne,blockquote:oe,bullet_list:ae,code_block:le,hard_break:ce,heading:he,image:ue,list_item:de,ordered_list:pe,paragraph:ge,emoji:fe},marks:{bold:me,strike:ye,underline:be,strong:ke,code:ve,italic:$e,link:Te,styled:we,subscript:Re,superscript:Ee,anchor:_e,highlight:Se,textStyle:Ae}},je=function(i){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,s=new RegExp(t.source);return i&&s.test(i)?i.replace(t,r=>e[r]):i};let J=!1;class O{constructor(e){m(this,"marks"),m(this,"nodes"),e||(e=G),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},s=!0){if(!J&&s&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),J=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
|
8
8
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
9
9
|
ISbRichtext:
|
10
10
|
content?: ISbRichtext[]
|
@@ -27,4 +27,4 @@
|
|
27
27
|
}
|
28
28
|
],
|
29
29
|
type: 'doc'
|
30
|
-
}`),""}optimizeImages(e,t){let s=0,r=0,o="",n="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(o+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(o+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(o+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(o+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(n+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(n+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(n+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(n+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(n+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(n+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(n+=`:rotate(${t.filters.rotate})`),n.length>0&&(n=`/filters${n}`))),o.length>0&&(e=e.replace(/<img/g,`<img ${o.trim()}`));const c=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var h,u;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(y=>{if(typeof y=="number")return`//${p}/m/${y}x0${n} ${y}w`;if(typeof y=="object"&&y.length===2){let j=0,N=0;return typeof y[0]=="number"&&(j=y[0]),typeof y[1]=="number"&&(N=y[1]),`//${p}/m/${j}x${N}${n} ${j}w`}return""}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(y=>y).join(", ")};let S="";return b.srcset&&(S+=`srcset="${b.srcset}" `),b.sizes&&(S+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${S.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const o=this.getMatchingMark(r);o&&o.tag!==""&&t.push(this.renderOpeningTag(o.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(Ie(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const o=this.getMatchingMark(r);o&&o.tag!==""&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const o in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,o)){const n=s.attrs[o];n!==null&&(r+=` ${o}="${n}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class Ae{constructor(e){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={}}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;if(e==="get"){const a=new x;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),o=new AbortController,{signal:n}=o;let c;this.timeout&&(c=setTimeout(()=>o.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n,...this.fetchOptions});this.timeout&&clearTimeout(c);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}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}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const o={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(o)})}}const V="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let C={};const I={};class Oe{constructor(e,t){m(this,"client"),m(this,"maxRetries"),m(this,"retriesDelay"),m(this,"throttle"),m(this,"accessToken"),m(this,"cache"),m(this,"helpers"),m(this,"resolveCounter"),m(this,"relations"),m(this,"links"),m(this,"richTextResolver"),m(this,"resolveNestedRelations"),m(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const n=new x().getRegionURL,c=e.https===!1?"http":"https";e.oauthToken?s=`${c}://${n(e.region)}/v1`:s=`${c}://${n(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,c])=>{r.set(n,c)}),r.has(V)||(r.set(V,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let o=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),e.richTextSchema?this.richTextResolver=new O(e.richTextSchema):this.richTextResolver=new O,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=se(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new x,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ae({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=I[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 this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,o){const n=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,n,void 0,o)}get(e,t,s){t||(t={});const r=`/${e}`,o=this.factoryParamOptions(r,t);return this.cacheResponse(r,o,void 0,s)}async getAll(e,t,s,r){const o=(t==null?void 0:t.per_page)||25,n=`/${e}`.replace(/\/$/,""),c=s??n.substring(n.lastIndexOf("/")+1),a=1,h=await this.makeRequest(n,t,o,a,r),u=h.total?Math.ceil(h.total/o):1,p=await this.helpers.asyncMap(this.helpers.range(a,u),b=>this.makeRequest(n,t,o,b+1,r));return this.helpers.flatMap([h,...p],b=>Object.values(b.data[c]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){t||(t={});const r=`/${e}`;return Promise.resolve(this.throttle("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(o=>this.getStoryReference(s,o)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(n=>n.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(o):s===o)&&this._resolveField(e,t,r)}iterateTree(e,t,s){const r=(o,n="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((c,a)=>r(c,`${n}[${a}]`));else if(typeof o=="object")for(const c in o){const a=n?`${n}.${c}`:c;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,c,t,s),this._insertLinks(o,c,s)),r(o[c],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const o=e.link_uuids.length,n=[],c=50;for(let a=0;a<o;a+=c){const h=Math.min(o,a+c);n.push(e.link_uuids.slice(a,h))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:n[a].join(",")})).data.stories.forEach(h=>{r.push(h)})}else r=e.links;r.forEach(o=>{this.links[s][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length,n=[],c=50;for(let a=0;a<o;a+=c){const h=Math.min(o,a+c);n.push(e.rel_uuids.slice(a,h))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:n[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{r.push(h)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(o=>{this.relations[s][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,s){var r,o;let n=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=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||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],n,s);e.story?this.iterateTree(e.story,n,s):e.stories.forEach(c=>{this.iterateTree(c,n,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const o=this.helpers.stringify({url:e,params:t}),n=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await n.get(o);if(c)return Promise.resolve(c)}return new Promise(async(c,a)=>{var h;try{const u=await this.throttle("get",e,t,r);if(u.status!==200)return a(u);let p={data:u.data,headers:u.headers};if((h=u.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),p.data.story||p.data.stories){const S=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${S}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await n.set(o,p);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(b&&I[t.token]&&I[t.token]!==p.data.cv&&await this.flushCache(),I[t.token]=p.data.cv),c(p)}catch(u){if(u.response&&u.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 this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(a);a(u)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return I}cacheVersion(){return I[this.accessToken]}setCacheVersion(e){this.accessToken&&(I[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(I[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(C[e])},getAll(){return Promise.resolve(C)},set(e,t){return C[e]=t,Promise.resolve(void 0)},flush(){return C={},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}}const Le=(i={})=>{const{apiOptions:e}=i;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 Oe(e)}},xe=i=>{if(typeof i!="object"||typeof i._editable>"u")return{};try{const e=JSON.parse(i._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Ce(i,e){if(!e)return{src:i,attrs:{}};let t=0,s=0;const r={},o=[];function n(a,h,u,p,b){typeof a!="number"||a<=h||a>=u?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`):b.push(`${p}(${a})`)}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,s=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:a}=e||{},{blur:h,brightness:u,fill:p,format:b,grayscale:S,quality:y,rotate:j}=a||{};h&&n(h,0,100,"blur",o),y&&n(y,0,100,"quality",o),u&&n(u,0,100,"brightness",o),p&&o.push(`fill(${p})`),S&&o.push("grayscale()"),j&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${j})`),b&&["webp","png","jpeg"].includes(b)&&o.push(`format(${b})`)}e.srcset&&(r.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${i}/m/${a}x0/${o.length>0?`filters:${o.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,u]=a;return`${i}/m/${h}x${u}/${o.length>0?`filters:${o.join(":")}`:""} ${h}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=`${i}/m/`;return t>0&&s>0&&(c=`${c}${t}x${s}/`),o.length>0&&(c=`${c}filters:${o.join(":")}`),{src:c,attrs:r}}var $=(i=>(i.DOCUMENT="doc",i.HEADING="heading",i.PARAGRAPH="paragraph",i.QUOTE="blockquote",i.OL_LIST="ordered_list",i.UL_LIST="bullet_list",i.LIST_ITEM="list_item",i.CODE_BLOCK="code_block",i.HR="horizontal_rule",i.BR="hard_break",i.IMAGE="image",i.EMOJI="emoji",i.COMPONENT="blok",i.TABLE="table",i.TABLE_ROW="tableRow",i.TABLE_CELL="tableCell",i.TABLE_HEADER="tableHeader",i))($||{}),E=(i=>(i.BOLD="bold",i.STRONG="strong",i.STRIKE="strike",i.UNDERLINE="underline",i.ITALIC="italic",i.CODE="code",i.LINK="link",i.ANCHOR="anchor",i.STYLED="styled",i.SUPERSCRIPT="superscript",i.SUBSCRIPT="subscript",i.TEXT_STYLE="textStyle",i.HIGHLIGHT="highlight",i))(E||{}),B=(i=>(i.TEXT="text",i))(B||{}),L=(i=>(i.URL="url",i.STORY="story",i.ASSET="asset",i.EMAIL="email",i))(L||{});const Pe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ne=(i={})=>Object.keys(i).map(e=>`${e}="${i[e]}"`).join(" "),Me=(i={})=>Object.keys(i).map(e=>`${e}: ${i[e]}`).join("; ");function He(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const P=i=>Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==void 0));function K(i,e={},t){const s=Ne(e),r=s?`${i} ${s}`:i,o=Array.isArray(t)?t.join(""):t||"";if(i){if(Pe.includes(i))return`<${r}>`}else return o;return`<${r}>${o}</${i}>`}function Be(i={}){const e=new Map,{renderFn:t=K,textFn:s=He,resolvers:r={},optimizeImages:o=!1,keyedResolvers:n=!1}=i,c=t!==K,a=()=>({render:(l,d={},g)=>{if(n&&l){const f=e.get(l)||0;e.set(l,f+1),d.key=`${l}-${f}`}return t(l,d,g)}}),h=l=>(d,g)=>{const f=d.attrs||{};return g.render(l,f,d.children||null)},u=(l,d)=>{const{src:g,alt:f,title:k,srcset:R,sizes:T}=l.attrs||{};let w=g,_={};if(o){const{src:We,attrs:Xe}=Ce(g,o);w=We,_=Xe}const Ye={src:w,alt:f,title:k,srcset:R,sizes:T,..._};return d.render("img",P(Ye))},p=(l,d)=>{const{level:g,...f}=l.attrs||{};return d.render(`h${g}`,f,l.children)},b=(l,d)=>{var g,f,k,R;const T=d.render("img",{src:(g=l.attrs)==null?void 0:g.fallbackImage,alt:(f=l.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return d.render("span",{"data-type":"emoji","data-name":(k=l.attrs)==null?void 0:k.name,"data-emoji":(R=l.attrs)==null?void 0:R.emoji},T)},S=(l,d)=>d.render("pre",l.attrs||{},d.render("code",{},l.children||"")),y=(l,d=!1)=>({text:g,attrs:f},k)=>{const{class:R,id:T,...w}=f||{},_=d?{class:R,id:T,style:Me(w)||void 0}:f||{};return k.render(l,P(_),g)},j=l=>D(l),N=l=>{const{marks:d,...g}=l;if("text"in l){if(d)return d.reduce((k,R)=>j({...R,text:k}),j({...g,children:g.children}));const f=l.attrs||{};if(n){const k=e.get("txt")||0;e.set("txt",k+1),f.key=`txt-${k}`}return s(g.text,f)}return""},Q=(l,d)=>{const{linktype:g,href:f,anchor:k,...R}=l.attrs||{};let T="";switch(g){case L.ASSET:case L.URL:T=f;break;case L.EMAIL:T=`mailto:${f}`;break;case L.STORY:T=f,k&&(T=`${T}#${k}`);break;default:T=f;break}const w={...R};return T&&(w.href=T),d.render("a",w,l.text)},qe=(l,d)=>{var g,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),d.render("span",{blok:(g=l==null?void 0:l.attrs)==null?void 0:g.body[0],id:(f=l.attrs)==null?void 0:f.id,style:"display: none"})},Fe=(l,d)=>{const g={},f=d.render("tbody",{},l.children);return d.render("table",g,f)},Ge=(l,d)=>{const g={};return d.render("tr",g,l.children)},Je=(l,d)=>{const{colspan:g,rowspan:f,colwidth:k,backgroundColor:R,...T}=l.attrs||{},w={...T};g>1&&(w.colspan=g),f>1&&(w.rowspan=f);const _=[];return k&&_.push(`width: ${k}px;`),R&&_.push(`background-color: ${R};`),_.length>0&&(w.style=_.join(" ")),d.render("td",P(w),l.children)},Ve=(l,d)=>{const{colspan:g,rowspan:f,colwidth:k,backgroundColor:R,...T}=l.attrs||{},w={...T};g>1&&(w.colspan=g),f>1&&(w.rowspan=f);const _=[];return k&&_.push(`width: ${k}px;`),R&&_.push(`background-color: ${R};`),_.length>0&&(w.style=_.join(" ")),d.render("th",P(w),l.children)},Ke=new Map([[$.DOCUMENT,h("")],[$.HEADING,p],[$.PARAGRAPH,h("p")],[$.UL_LIST,h("ul")],[$.OL_LIST,h("ol")],[$.LIST_ITEM,h("li")],[$.IMAGE,u],[$.EMOJI,b],[$.CODE_BLOCK,S],[$.HR,h("hr")],[$.BR,h("br")],[$.QUOTE,h("blockquote")],[$.COMPONENT,qe],[B.TEXT,N],[E.LINK,Q],[E.ANCHOR,Q],[E.STYLED,y("span",!0)],[E.BOLD,y("strong")],[E.TEXT_STYLE,y("span",!0)],[E.ITALIC,y("em")],[E.UNDERLINE,y("u")],[E.STRIKE,y("s")],[E.CODE,y("code")],[E.SUPERSCRIPT,y("sup")],[E.SUBSCRIPT,y("sub")],[E.HIGHLIGHT,y("mark")],[$.TABLE,Fe],[$.TABLE_ROW,Ge],[$.TABLE_CELL,Je],[$.TABLE_HEADER,Ve],...Object.entries(r).map(([l,d])=>[l,d])]);function M(l){const d=Ke.get(l.type);if(!d)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const g=a();if(l.type==="text")return d(l,g);const f=l.content?l.content.map(D):void 0;return d({...l,children:f},g)}function D(l){return l.type==="doc"?c?l.content.map(M):l.content.map(M).join(""):Array.isArray(l)?l.map(M):M(l)}return{render:D}}let U,z="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(i,e,t={})=>{var c;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),n=o!==null&&+o===i;if(!(!r||!n)){if(!i){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],h=>{var u;h&&(h.action==="input"&&((u=h.story)==null?void 0:u.id)===i?e(h.story):(h.action==="change"||h.action==="published")&&h.storyId===i&&window.location.reload())})})}},W=(i,e)=>{i.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},Ue=(i={})=>{var p,b;const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:o={},bridgeUrl:n}=i;r.accessToken=r.accessToken||t;const c={bridge:e,apiOptions:r};let a={};s.forEach(S=>{a={...a,...S(c)}}),n&&(z=n);const u=!(typeof window>"u")&&((b=(p=window.location)==null?void 0:p.search)==null?void 0:b.includes("_storyblok_tk"));return e!==!1&&u&&F(z),U=new O(o.schema),o.resolver&&W(U,o.resolver),a},X=i=>{var e;return!i||!((e=i==null?void 0:i.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},ze=(i,e,t)=>{let s=t||U;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return X(i)?"":(e&&(s=new O(e.schema),e.resolver&&W(s,e.resolver)),s.render(i,{},!1))},De=()=>F(z);v.BlockTypes=$,v.MarkTypes=E,v.RichTextResolver=O,v.RichTextSchema=G,v.TextTypes=B,v.apiPlugin=Le,v.isRichTextEmpty=X,v.loadStoryblokBridge=De,v.registerStoryblokBridge=Y,v.renderRichText=ze,v.richTextResolver=Be,v.storyblokEditable=xe,v.storyblokInit=Ue,v.useStoryblokBridge=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
30
|
+
}`),""}optimizeImages(e,t){let s=0,r=0,n="",o="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(o+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(o+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(o+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(o+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(o+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(o+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(o+=`:rotate(${t.filters.rotate})`),o.length>0&&(o=`/filters${o}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const c=s>0||r>0||o.length>0?`${s}x${r}${o}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var h,u;const d=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(d&&d.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(y=>{if(typeof y=="number")return`//${d}/m/${y}x0${o} ${y}w`;if(typeof y=="object"&&y.length===2){let A=0,N=0;return typeof y[0]=="number"&&(A=y[0]),typeof y[1]=="number"&&(N=y[1]),`//${d}/m/${A}x${N}${o} ${A}w`}return""}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(y=>y).join(", ")};let S="";return b.srcset&&(S+=`srcset="${b.srcset}" `),b.sizes&&(S+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${S.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(je(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const n in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,n)){const o=s.attrs[n];o!==null&&(r+=` ${n}="${o}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class Ie{constructor(e){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={}}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;if(e==="get"){const a=new x;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:o}=n;let c;this.timeout&&(c=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&&clearTimeout(c);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}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}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}const V="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let C={};const j={};class Oe{constructor(e,t){m(this,"client"),m(this,"maxRetries"),m(this,"retriesDelay"),m(this,"throttle"),m(this,"accessToken"),m(this,"cache"),m(this,"helpers"),m(this,"resolveCounter"),m(this,"relations"),m(this,"links"),m(this,"richTextResolver"),m(this,"resolveNestedRelations"),m(this,"stringifiedStoriesCache"),m(this,"inlineAssets");let s=e.endpoint||t;if(!s){const o=new x().getRegionURL,c=e.https===!1?"http":"https";e.oauthToken?s=`${c}://${o(e.region)}/v1`:s=`${c}://${o(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(([o,c])=>{r.set(o,c)}),r.has(V)||(r.set(V,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),e.richTextSchema?this.richTextResolver=new O(e.richTextSchema):this.richTextResolver=new O,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=se(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new x,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.inlineAssets=e.inlineAssets||!1,this.client=new Ie({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=j[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 this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const o=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,o,void 0,n)}get(e,t,s){t||(t={});const r=`/${e}`,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(/\/$/,""),c=s??o.substring(o.lastIndexOf("/")+1),a=1,h=await this.makeRequest(o,t,n,a,r),u=h.total?Math.ceil(h.total/n):1,d=await this.helpers.asyncMap(this.helpers.range(a,u),b=>this.makeRequest(o,t,n,b+1,r));return this.helpers.flatMap([h,...d],b=>Object.values(b.data[c]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){t||(t={});const r=`/${e}`;return Promise.resolve(this.throttle("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((c,a)=>r(c,`${o}[${a}]`));else if(typeof n=="object")for(const c in n){const a=o?`${o}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,s),this._insertLinks(n,c,s)),r(n[c],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],c=50;for(let a=0;a<n;a+=c){const h=Math.min(n,a+c);o.push(e.link_uuids.slice(a,h))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(h=>{r.push(h)})}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=[],c=50;for(let a=0;a<n;a+=c){const h=Math.min(n,a+c);o.push(e.rel_uuids.slice(a,h))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{r.push(h)});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 c in this.relations[s])this.iterateTree(this.relations[s][c],o,s);e.story?this.iterateTree(e.story,o,s):e.stories.forEach(c=>{this.iterateTree(c,o,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=this.helpers.stringify({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)}return new Promise(async(c,a)=>{var h;try{const u=await this.throttle("get",e,t,r);if(u.status!==200)return a(u);let d={data:u.data,headers:u.headers};if((h=u.headers)!=null&&h["per-page"]&&(d=Object.assign({},d,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),d.data.story||d.data.stories){const S=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(d.data,t,`${S}`),d=await this.processInlineAssets(d)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,d);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&d.data.cv&&(b&&j[t.token]&&j[t.token]!==d.data.cv&&await this.flushCache(),j[t.token]=d.data.cv),c(d)}catch(u){if(u.response&&u.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 this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(a);a(u)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return j}cacheVersion(){return j[this.accessToken]}setCacheVersion(e){this.accessToken&&(j[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(j[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(C[e])},getAll(){return Promise.resolve(C)},set(e,t){return C[e]=t,Promise.resolve(void 0)},flush(){return C={},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={...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(s=>(s.content=t(s.content),s))),e}}const Le=(i={})=>{const{apiOptions:e}=i;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 Oe(e)}},xe=i=>{if(typeof i!="object"||typeof i._editable>"u")return{};try{const e=JSON.parse(i._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Ce(i,e){if(!e)return{src:i,attrs:{}};let t=0,s=0;const r={},n=[];function o(a,h,u,d,b){typeof a!="number"||a<=h||a>=u?console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase()+d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`):b.push(`${d}(${a})`)}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,s=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:a}=e||{},{blur:h,brightness:u,fill:d,format:b,grayscale:S,quality:y,rotate:A}=a||{};h&&o(h,0,100,"blur",n),y&&o(y,0,100,"quality",n),u&&o(u,0,100,"brightness",n),d&&n.push(`fill(${d})`),S&&n.push("grayscale()"),A&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${A})`),b&&["webp","png","jpeg"].includes(b)&&n.push(`format(${b})`)}e.srcset&&(r.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${i}/m/${a}x0/${n.length>0?`filters:${n.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,u]=a;return`${i}/m/${h}x${u}/${n.length>0?`filters:${n.join(":")}`:""} ${h}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=`${i}/m/`;return t>0&&s>0&&(c=`${c}${t}x${s}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:r}}var $=(i=>(i.DOCUMENT="doc",i.HEADING="heading",i.PARAGRAPH="paragraph",i.QUOTE="blockquote",i.OL_LIST="ordered_list",i.UL_LIST="bullet_list",i.LIST_ITEM="list_item",i.CODE_BLOCK="code_block",i.HR="horizontal_rule",i.BR="hard_break",i.IMAGE="image",i.EMOJI="emoji",i.COMPONENT="blok",i.TABLE="table",i.TABLE_ROW="tableRow",i.TABLE_CELL="tableCell",i.TABLE_HEADER="tableHeader",i))($||{}),E=(i=>(i.BOLD="bold",i.STRONG="strong",i.STRIKE="strike",i.UNDERLINE="underline",i.ITALIC="italic",i.CODE="code",i.LINK="link",i.ANCHOR="anchor",i.STYLED="styled",i.SUPERSCRIPT="superscript",i.SUBSCRIPT="subscript",i.TEXT_STYLE="textStyle",i.HIGHLIGHT="highlight",i))(E||{}),B=(i=>(i.TEXT="text",i))(B||{}),L=(i=>(i.URL="url",i.STORY="story",i.ASSET="asset",i.EMAIL="email",i))(L||{});const Pe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ne=(i={})=>Object.keys(i).map(e=>`${e}="${i[e]}"`).join(" "),Me=(i={})=>Object.keys(i).map(e=>`${e}: ${i[e]}`).join("; ");function He(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const P=i=>Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==void 0));function K(i,e={},t){const s=Ne(e),r=s?`${i} ${s}`:i,n=Array.isArray(t)?t.join(""):t||"";if(i){if(Pe.includes(i))return`<${r}>`}else return n;return`<${r}>${n}</${i}>`}function Be(i={}){const e=new Map,{renderFn:t=K,textFn:s=He,resolvers:r={},optimizeImages:n=!1,keyedResolvers:o=!1}=i,c=t!==K,a=()=>({render:(l,p={},g)=>{if(o&&l){const f=e.get(l)||0;e.set(l,f+1),p.key=`${l}-${f}`}return t(l,p,g)}}),h=l=>(p,g)=>{const f=p.attrs||{};return g.render(l,f,p.children||null)},u=(l,p)=>{const{src:g,alt:f,title:k,srcset:R,sizes:T}=l.attrs||{};let w=g,_={};if(n){const{src:We,attrs:Xe}=Ce(g,n);w=We,_=Xe}const Ye={src:w,alt:f,title:k,srcset:R,sizes:T,..._};return p.render("img",P(Ye))},d=(l,p)=>{const{level:g,...f}=l.attrs||{};return p.render(`h${g}`,f,l.children)},b=(l,p)=>{var g,f,k,R;const T=p.render("img",{src:(g=l.attrs)==null?void 0:g.fallbackImage,alt:(f=l.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return p.render("span",{"data-type":"emoji","data-name":(k=l.attrs)==null?void 0:k.name,"data-emoji":(R=l.attrs)==null?void 0:R.emoji},T)},S=(l,p)=>p.render("pre",l.attrs||{},p.render("code",{},l.children||"")),y=(l,p=!1)=>({text:g,attrs:f},k)=>{const{class:R,id:T,...w}=f||{},_=p?{class:R,id:T,style:Me(w)||void 0}:f||{};return k.render(l,P(_),g)},A=l=>D(l),N=l=>{const{marks:p,...g}=l;if("text"in l){if(p)return p.reduce((k,R)=>A({...R,text:k}),A({...g,children:g.children}));const f=l.attrs||{};if(o){const k=e.get("txt")||0;e.set("txt",k+1),f.key=`txt-${k}`}return s(g.text,f)}return""},Q=(l,p)=>{const{linktype:g,href:f,anchor:k,...R}=l.attrs||{};let T="";switch(g){case L.ASSET:case L.URL:T=f;break;case L.EMAIL:T=`mailto:${f}`;break;case L.STORY:T=f,k&&(T=`${T}#${k}`);break;default:T=f;break}const w={...R};return T&&(w.href=T),p.render("a",w,l.text)},qe=(l,p)=>{var g,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),p.render("span",{blok:(g=l==null?void 0:l.attrs)==null?void 0:g.body[0],id:(f=l.attrs)==null?void 0:f.id,style:"display: none"})},Fe=(l,p)=>{const g={},f=p.render("tbody",{},l.children);return p.render("table",g,f)},Ge=(l,p)=>{const g={};return p.render("tr",g,l.children)},Je=(l,p)=>{const{colspan:g,rowspan:f,colwidth:k,backgroundColor:R,...T}=l.attrs||{},w={...T};g>1&&(w.colspan=g),f>1&&(w.rowspan=f);const _=[];return k&&_.push(`width: ${k}px;`),R&&_.push(`background-color: ${R};`),_.length>0&&(w.style=_.join(" ")),p.render("td",P(w),l.children)},Ve=(l,p)=>{const{colspan:g,rowspan:f,colwidth:k,backgroundColor:R,...T}=l.attrs||{},w={...T};g>1&&(w.colspan=g),f>1&&(w.rowspan=f);const _=[];return k&&_.push(`width: ${k}px;`),R&&_.push(`background-color: ${R};`),_.length>0&&(w.style=_.join(" ")),p.render("th",P(w),l.children)},Ke=new Map([[$.DOCUMENT,h("")],[$.HEADING,d],[$.PARAGRAPH,h("p")],[$.UL_LIST,h("ul")],[$.OL_LIST,h("ol")],[$.LIST_ITEM,h("li")],[$.IMAGE,u],[$.EMOJI,b],[$.CODE_BLOCK,S],[$.HR,h("hr")],[$.BR,h("br")],[$.QUOTE,h("blockquote")],[$.COMPONENT,qe],[B.TEXT,N],[E.LINK,Q],[E.ANCHOR,Q],[E.STYLED,y("span",!0)],[E.BOLD,y("strong")],[E.TEXT_STYLE,y("span",!0)],[E.ITALIC,y("em")],[E.UNDERLINE,y("u")],[E.STRIKE,y("s")],[E.CODE,y("code")],[E.SUPERSCRIPT,y("sup")],[E.SUBSCRIPT,y("sub")],[E.HIGHLIGHT,y("mark")],[$.TABLE,Fe],[$.TABLE_ROW,Ge],[$.TABLE_CELL,Je],[$.TABLE_HEADER,Ve],...Object.entries(r).map(([l,p])=>[l,p])]);function M(l){const p=Ke.get(l.type);if(!p)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const g=a();if(l.type==="text")return p(l,g);const f=l.content?l.content.map(D):void 0;return p({...l,children:f},g)}function D(l){return l.type==="doc"?c?l.content.map(M):l.content.map(M).join(""):Array.isArray(l)?l.map(M):M(l)}return{render:D}}let U,z="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(i,e,t={})=>{var c;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),o=n!==null&&+n===i;if(!(!r||!o)){if(!i){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],h=>{var u;h&&(h.action==="input"&&((u=h.story)==null?void 0:u.id)===i?e(h.story):(h.action==="change"||h.action==="published")&&h.storyId===i&&window.location.reload())})})}},W=(i,e)=>{i.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},Ue=(i={})=>{var d,b;const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:n={},bridgeUrl:o}=i;r.accessToken=r.accessToken||t;const c={bridge:e,apiOptions:r};let a={};s.forEach(S=>{a={...a,...S(c)}}),o&&(z=o);const u=!(typeof window>"u")&&((b=(d=window.location)==null?void 0:d.search)==null?void 0:b.includes("_storyblok_tk"));return e!==!1&&u&&F(z),U=new O(n.schema),n.resolver&&W(U,n.resolver),a},X=i=>{var e;return!i||!((e=i==null?void 0:i.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},ze=(i,e,t)=>{let s=t||U;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return X(i)?"":(e&&(s=new O(e.schema),e.resolver&&W(s,e.resolver)),s.render(i,{},!1))},De=()=>F(z);v.BlockTypes=$,v.MarkTypes=E,v.RichTextResolver=O,v.RichTextSchema=G,v.TextTypes=B,v.apiPlugin=Le,v.isRichTextEmpty=X,v.loadStoryblokBridge=De,v.registerStoryblokBridge=Y,v.renderRichText=ze,v.richTextResolver=Be,v.storyblokEditable=xe,v.storyblokInit=Ue,v.useStoryblokBridge=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/dist/storyblok-js.mjs
CHANGED
@@ -16,11 +16,11 @@ const D = [], J = (i) => new Promise((e, t) => {
|
|
16
16
|
return;
|
17
17
|
const s = document.createElement("script");
|
18
18
|
s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
19
|
-
D.forEach((
|
19
|
+
D.forEach((n) => n()), z = !0, e(r);
|
20
20
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
21
21
|
});
|
22
|
-
var ie = Object.defineProperty,
|
23
|
-
class
|
22
|
+
var ie = Object.defineProperty, ne = (i, e, t) => e in i ? ie(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e, t) => ne(i, typeof e != "symbol" ? e + "" : e, t);
|
23
|
+
class oe extends Error {
|
24
24
|
constructor(e) {
|
25
25
|
super(e), this.name = "AbortError";
|
26
26
|
}
|
@@ -31,35 +31,35 @@ function ae(i, e, t) {
|
|
31
31
|
if (!Number.isFinite(t))
|
32
32
|
throw new TypeError("Expected `interval` to be a finite number");
|
33
33
|
const s = [];
|
34
|
-
let r = [],
|
34
|
+
let r = [], n = 0, o = !1;
|
35
35
|
const c = async () => {
|
36
|
-
|
36
|
+
n++;
|
37
37
|
const h = s.shift();
|
38
38
|
if (h)
|
39
39
|
try {
|
40
|
-
const
|
41
|
-
h.resolve(
|
42
|
-
} catch (
|
43
|
-
h.reject(
|
40
|
+
const d = await i(...h.args);
|
41
|
+
h.resolve(d);
|
42
|
+
} catch (d) {
|
43
|
+
h.reject(d);
|
44
44
|
}
|
45
45
|
const u = setTimeout(() => {
|
46
|
-
|
46
|
+
n--, s.length > 0 && c(), r = r.filter((d) => d !== u);
|
47
47
|
}, t);
|
48
48
|
r.includes(u) || r.push(u);
|
49
|
-
}, a = (...h) =>
|
49
|
+
}, a = (...h) => o ? Promise.reject(
|
50
50
|
new Error(
|
51
51
|
"Throttled function is already aborted and not accepting new promises"
|
52
52
|
)
|
53
|
-
) : new Promise((u,
|
53
|
+
) : new Promise((u, d) => {
|
54
54
|
s.push({
|
55
55
|
resolve: u,
|
56
|
-
reject:
|
56
|
+
reject: d,
|
57
57
|
args: h
|
58
|
-
}),
|
58
|
+
}), n < e && c();
|
59
59
|
});
|
60
60
|
return a.abort = () => {
|
61
|
-
|
62
|
-
(h) => h.reject(() => new
|
61
|
+
o = !0, r.forEach(clearTimeout), r = [], s.forEach(
|
62
|
+
(h) => h.reject(() => new oe("Throttle function aborted"))
|
63
63
|
), s.length = 0;
|
64
64
|
}, a;
|
65
65
|
}
|
@@ -71,7 +71,7 @@ class C {
|
|
71
71
|
page: s
|
72
72
|
})), m(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), m(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), m(this, "range", (e = 0, t = e) => {
|
73
73
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
74
|
-
return this.arrayFrom(s, (
|
74
|
+
return this.arrayFrom(s, (n, o) => o * r + e);
|
75
75
|
}), m(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), m(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), m(this, "escapeHTML", function(e) {
|
76
76
|
const t = {
|
77
77
|
"&": "&",
|
@@ -80,7 +80,7 @@ class C {
|
|
80
80
|
'"': """,
|
81
81
|
"'": "'"
|
82
82
|
}, s = /[&<>"']/g, r = new RegExp(s.source);
|
83
|
-
return e && r.test(e) ? e.replace(s, (
|
83
|
+
return e && r.test(e) ? e.replace(s, (n) => t[n]) : e;
|
84
84
|
});
|
85
85
|
}
|
86
86
|
/**
|
@@ -92,19 +92,19 @@ class C {
|
|
92
92
|
*/
|
93
93
|
stringify(e, t, s) {
|
94
94
|
const r = [];
|
95
|
-
for (const
|
96
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
95
|
+
for (const n in e) {
|
96
|
+
if (!Object.prototype.hasOwnProperty.call(e, n))
|
97
97
|
continue;
|
98
|
-
const
|
99
|
-
if (
|
98
|
+
const o = e[n];
|
99
|
+
if (o == null)
|
100
100
|
continue;
|
101
|
-
const c = s ? "" : encodeURIComponent(
|
101
|
+
const c = s ? "" : encodeURIComponent(n);
|
102
102
|
let a;
|
103
|
-
typeof
|
104
|
-
|
103
|
+
typeof o == "object" ? a = this.stringify(
|
104
|
+
o,
|
105
105
|
t ? t + encodeURIComponent(`[${c}]`) : c,
|
106
|
-
Array.isArray(
|
107
|
-
) : a = `${t ? t + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(
|
106
|
+
Array.isArray(o)
|
107
|
+
) : a = `${t ? t + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(o)}`, r.push(a);
|
108
108
|
}
|
109
109
|
return r.join("&");
|
110
110
|
}
|
@@ -114,16 +114,16 @@ class C {
|
|
114
114
|
* @return {string} The base URL of the region
|
115
115
|
*/
|
116
116
|
getRegionURL(e) {
|
117
|
-
const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn",
|
117
|
+
const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", n = "api-ap.storyblok.com", o = "api-ca.storyblok.com";
|
118
118
|
switch (e) {
|
119
119
|
case "us":
|
120
120
|
return s;
|
121
121
|
case "cn":
|
122
122
|
return r;
|
123
123
|
case "ap":
|
124
|
-
return o;
|
125
|
-
case "ca":
|
126
124
|
return n;
|
125
|
+
case "ca":
|
126
|
+
return o;
|
127
127
|
default:
|
128
128
|
return t;
|
129
129
|
}
|
@@ -209,18 +209,18 @@ const le = function(i, e) {
|
|
209
209
|
}
|
210
210
|
]
|
211
211
|
};
|
212
|
-
},
|
212
|
+
}, Ae = (i) => ({
|
213
213
|
tag: [
|
214
214
|
{
|
215
215
|
tag: "span",
|
216
216
|
attrs: i.attrs
|
217
217
|
}
|
218
218
|
]
|
219
|
-
}),
|
219
|
+
}), je = () => ({
|
220
220
|
tag: "sub"
|
221
|
-
}),
|
221
|
+
}), Ie = () => ({
|
222
222
|
tag: "sup"
|
223
|
-
}),
|
223
|
+
}), xe = (i) => ({
|
224
224
|
tag: [
|
225
225
|
{
|
226
226
|
tag: "span",
|
@@ -277,10 +277,10 @@ const le = function(i, e) {
|
|
277
277
|
code: Ee,
|
278
278
|
italic: _e,
|
279
279
|
link: Se,
|
280
|
-
styled:
|
281
|
-
subscript:
|
282
|
-
superscript:
|
283
|
-
anchor:
|
280
|
+
styled: Ae,
|
281
|
+
subscript: je,
|
282
|
+
superscript: Ie,
|
283
|
+
anchor: xe,
|
284
284
|
highlight: Oe,
|
285
285
|
textStyle: Le
|
286
286
|
}
|
@@ -310,8 +310,8 @@ class P {
|
|
310
310
|
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
311
311
|
), q = !0), e && e.content && Array.isArray(e.content)) {
|
312
312
|
let r = "";
|
313
|
-
return e.content.forEach((
|
314
|
-
r += this.renderNode(
|
313
|
+
return e.content.forEach((n) => {
|
314
|
+
r += this.renderNode(n);
|
315
315
|
}), t.optimizeImages ? this.optimizeImages(r, t.optimizeImages) : r;
|
316
316
|
}
|
317
317
|
return console.warn(
|
@@ -342,25 +342,25 @@ class P {
|
|
342
342
|
), "";
|
343
343
|
}
|
344
344
|
optimizeImages(e, t) {
|
345
|
-
let s = 0, r = 0,
|
346
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
347
|
-
const c = s > 0 || r > 0 ||
|
345
|
+
let s = 0, r = 0, n = "", o = "";
|
346
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (o += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (o += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (o += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (o += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (o += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (o += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (o += `:rotate(${t.filters.rotate})`), o.length > 0 && (o = `/filters${o}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
347
|
+
const c = s > 0 || r > 0 || o.length > 0 ? `${s}x${r}${o}` : "";
|
348
348
|
return e = e.replace(
|
349
349
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
350
350
|
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
351
351
|
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
352
352
|
var h, u;
|
353
|
-
const
|
353
|
+
const d = a.match(
|
354
354
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
355
355
|
);
|
356
|
-
if (
|
356
|
+
if (d && d.length > 0) {
|
357
357
|
const b = {
|
358
358
|
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
359
359
|
if (typeof y == "number")
|
360
|
-
return `//${
|
360
|
+
return `//${d}/m/${y}x0${o} ${y}w`;
|
361
361
|
if (typeof y == "object" && y.length === 2) {
|
362
|
-
let S = 0,
|
363
|
-
return typeof y[0] == "number" && (S = y[0]), typeof y[1] == "number" && (
|
362
|
+
let S = 0, I = 0;
|
363
|
+
return typeof y[0] == "number" && (S = y[0]), typeof y[1] == "number" && (I = y[1]), `//${d}/m/${S}x${I}${o} ${S}w`;
|
364
364
|
}
|
365
365
|
return "";
|
366
366
|
}).join(", "),
|
@@ -375,15 +375,15 @@ class P {
|
|
375
375
|
renderNode(e) {
|
376
376
|
const t = [];
|
377
377
|
e.marks && e.marks.forEach((r) => {
|
378
|
-
const
|
379
|
-
|
378
|
+
const n = this.getMatchingMark(r);
|
379
|
+
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
380
380
|
});
|
381
381
|
const s = this.getMatchingNode(e);
|
382
382
|
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
383
383
|
t.push(this.renderNode(r));
|
384
384
|
}) : e.text ? t.push(Pe(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
|
385
|
-
const
|
386
|
-
|
385
|
+
const n = this.getMatchingMark(r);
|
386
|
+
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
387
387
|
}), t.join("");
|
388
388
|
}
|
389
389
|
renderTag(e, t) {
|
@@ -393,10 +393,10 @@ class P {
|
|
393
393
|
{
|
394
394
|
let r = `<${s.tag}`;
|
395
395
|
if (s.attrs) {
|
396
|
-
for (const
|
397
|
-
if (Object.prototype.hasOwnProperty.call(s.attrs,
|
398
|
-
const
|
399
|
-
|
396
|
+
for (const n in s.attrs)
|
397
|
+
if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
|
398
|
+
const o = s.attrs[n];
|
399
|
+
o !== null && (r += ` ${n}="${o}"`);
|
400
400
|
}
|
401
401
|
}
|
402
402
|
return `${r}${t}>`;
|
@@ -481,15 +481,15 @@ class Ne {
|
|
481
481
|
)}`;
|
482
482
|
} else
|
483
483
|
s = JSON.stringify(this.parameters);
|
484
|
-
const r = new URL(t),
|
484
|
+
const r = new URL(t), n = new AbortController(), { signal: o } = n;
|
485
485
|
let c;
|
486
|
-
this.timeout && (c = setTimeout(() =>
|
486
|
+
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
487
487
|
try {
|
488
488
|
const a = await this.fetch(`${r}`, {
|
489
489
|
method: e,
|
490
490
|
headers: this.headers,
|
491
491
|
body: s,
|
492
|
-
signal:
|
492
|
+
signal: o,
|
493
493
|
...this.fetchOptions
|
494
494
|
});
|
495
495
|
this.timeout && clearTimeout(c);
|
@@ -514,12 +514,12 @@ class Ne {
|
|
514
514
|
return new Promise((s, r) => {
|
515
515
|
if (t.test(`${e.status}`))
|
516
516
|
return s(e);
|
517
|
-
const
|
517
|
+
const n = {
|
518
518
|
message: e.statusText,
|
519
519
|
status: e.status,
|
520
520
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
521
521
|
};
|
522
|
-
r(
|
522
|
+
r(n);
|
523
523
|
});
|
524
524
|
}
|
525
525
|
}
|
@@ -529,7 +529,7 @@ const F = "SB-Agent", H = {
|
|
529
529
|
packageVersion: "6.0.0"
|
530
530
|
};
|
531
531
|
let O = {};
|
532
|
-
const
|
532
|
+
const A = {};
|
533
533
|
class He {
|
534
534
|
/**
|
535
535
|
*
|
@@ -537,25 +537,25 @@ class He {
|
|
537
537
|
* @param pEndpoint string, optional
|
538
538
|
*/
|
539
539
|
constructor(e, t) {
|
540
|
-
m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "helpers"), m(this, "resolveCounter"), m(this, "relations"), m(this, "links"), m(this, "richTextResolver"), m(this, "resolveNestedRelations"), m(this, "stringifiedStoriesCache");
|
540
|
+
m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "helpers"), m(this, "resolveCounter"), m(this, "relations"), m(this, "links"), m(this, "richTextResolver"), m(this, "resolveNestedRelations"), m(this, "stringifiedStoriesCache"), m(this, "inlineAssets");
|
541
541
|
let s = e.endpoint || t;
|
542
542
|
if (!s) {
|
543
|
-
const
|
544
|
-
e.oauthToken ? s = `${c}://${
|
543
|
+
const o = new C().getRegionURL, c = e.https === !1 ? "http" : "https";
|
544
|
+
e.oauthToken ? s = `${c}://${o(e.region)}/v1` : s = `${c}://${o(e.region)}/v2`;
|
545
545
|
}
|
546
546
|
const r = new Headers();
|
547
|
-
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(([
|
548
|
-
r.set(
|
547
|
+
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(([o, c]) => {
|
548
|
+
r.set(o, c);
|
549
549
|
}), r.has(F) || (r.set(F, H.defaultAgentName), r.set(
|
550
550
|
H.defaultAgentVersion,
|
551
551
|
H.packageVersion
|
552
552
|
));
|
553
|
-
let
|
554
|
-
e.oauthToken && (r.set("Authorization", e.oauthToken),
|
553
|
+
let n = 5;
|
554
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new P(e.richTextSchema) : this.richTextResolver = new P(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ae(
|
555
555
|
this.throttledRequest.bind(this),
|
556
|
-
|
556
|
+
n,
|
557
557
|
1e3
|
558
|
-
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new C(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ne({
|
558
|
+
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new C(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.inlineAssets = e.inlineAssets || !1, this.client = new Ne({
|
559
559
|
baseURL: s,
|
560
560
|
timeout: e.timeout || 0,
|
561
561
|
headers: r,
|
@@ -574,35 +574,35 @@ class He {
|
|
574
574
|
});
|
575
575
|
}
|
576
576
|
parseParams(e) {
|
577
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
577
|
+
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;
|
578
578
|
}
|
579
579
|
factoryParamOptions(e, t) {
|
580
580
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
581
581
|
}
|
582
|
-
makeRequest(e, t, s, r,
|
583
|
-
const
|
582
|
+
makeRequest(e, t, s, r, n) {
|
583
|
+
const o = this.factoryParamOptions(
|
584
584
|
e,
|
585
585
|
this.helpers.getOptionsPage(t, s, r)
|
586
586
|
);
|
587
|
-
return this.cacheResponse(e,
|
587
|
+
return this.cacheResponse(e, o, void 0, n);
|
588
588
|
}
|
589
589
|
get(e, t, s) {
|
590
590
|
t || (t = {});
|
591
|
-
const r = `/${e}`,
|
592
|
-
return this.cacheResponse(r,
|
591
|
+
const r = `/${e}`, n = this.factoryParamOptions(r, t);
|
592
|
+
return this.cacheResponse(r, n, void 0, s);
|
593
593
|
}
|
594
594
|
async getAll(e, t, s, r) {
|
595
|
-
const
|
596
|
-
n,
|
597
|
-
t,
|
595
|
+
const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), c = s ?? o.substring(o.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
|
598
596
|
o,
|
597
|
+
t,
|
598
|
+
n,
|
599
599
|
a,
|
600
600
|
r
|
601
|
-
), u = h.total ? Math.ceil(h.total /
|
601
|
+
), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
|
602
602
|
this.helpers.range(a, u),
|
603
|
-
(b) => this.makeRequest(
|
603
|
+
(b) => this.makeRequest(o, t, n, b + 1, r)
|
604
604
|
);
|
605
|
-
return this.helpers.flatMap([h, ...
|
605
|
+
return this.helpers.flatMap([h, ...d], (b) => Object.values(b.data[c]));
|
606
606
|
}
|
607
607
|
post(e, t, s) {
|
608
608
|
const r = `/${e}`;
|
@@ -667,7 +667,7 @@ class He {
|
|
667
667
|
_resolveField(e, t, s) {
|
668
668
|
const r = e[t];
|
669
669
|
typeof r == "string" ? e[t] = this.getStoryReference(s, r) : Array.isArray(r) && (e[t] = r.map(
|
670
|
-
(
|
670
|
+
(n) => this.getStoryReference(s, n)
|
671
671
|
).filter(Boolean));
|
672
672
|
}
|
673
673
|
/**
|
@@ -688,12 +688,12 @@ class He {
|
|
688
688
|
* allowing flexible specification of relation patterns.
|
689
689
|
*/
|
690
690
|
_insertRelations(e, t, s, r) {
|
691
|
-
if (Array.isArray(s) ? s.find((
|
691
|
+
if (Array.isArray(s) ? s.find((o) => o.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
|
692
692
|
this._resolveField(e, t, r);
|
693
693
|
return;
|
694
694
|
}
|
695
|
-
const
|
696
|
-
(Array.isArray(s) ? s.includes(
|
695
|
+
const n = e.component ? `${e.component}.${t}` : t;
|
696
|
+
(Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, r);
|
697
697
|
}
|
698
698
|
/**
|
699
699
|
* Recursively traverses and resolves relations in the story content tree
|
@@ -702,14 +702,14 @@ class He {
|
|
702
702
|
* @param resolveId - The unique identifier for the current resolution context
|
703
703
|
*/
|
704
704
|
iterateTree(e, t, s) {
|
705
|
-
const r = (
|
706
|
-
if (!(!
|
707
|
-
if (Array.isArray(
|
708
|
-
|
709
|
-
else if (typeof
|
710
|
-
for (const c in
|
711
|
-
const a =
|
712
|
-
(
|
705
|
+
const r = (n, o = "") => {
|
706
|
+
if (!(!n || n._stopResolving)) {
|
707
|
+
if (Array.isArray(n))
|
708
|
+
n.forEach((c, a) => r(c, `${o}[${a}]`));
|
709
|
+
else if (typeof n == "object")
|
710
|
+
for (const c in n) {
|
711
|
+
const a = o ? `${o}.${c}` : c;
|
712
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t, s), this._insertLinks(n, c, s)), r(n[c], a);
|
713
713
|
}
|
714
714
|
}
|
715
715
|
};
|
@@ -718,18 +718,18 @@ class He {
|
|
718
718
|
async resolveLinks(e, t, s) {
|
719
719
|
let r = [];
|
720
720
|
if (e.link_uuids) {
|
721
|
-
const
|
722
|
-
for (let a = 0; a <
|
723
|
-
const h = Math.min(
|
724
|
-
|
721
|
+
const n = e.link_uuids.length, o = [], c = 50;
|
722
|
+
for (let a = 0; a < n; a += c) {
|
723
|
+
const h = Math.min(n, a + c);
|
724
|
+
o.push(e.link_uuids.slice(a, h));
|
725
725
|
}
|
726
|
-
for (let a = 0; a <
|
726
|
+
for (let a = 0; a < o.length; a++)
|
727
727
|
(await this.getStories({
|
728
728
|
per_page: c,
|
729
729
|
language: t.language,
|
730
730
|
version: t.version,
|
731
731
|
starts_with: t.starts_with,
|
732
|
-
by_uuids:
|
732
|
+
by_uuids: o[a].join(",")
|
733
733
|
})).data.stories.forEach(
|
734
734
|
(h) => {
|
735
735
|
r.push(h);
|
@@ -737,9 +737,9 @@ class He {
|
|
737
737
|
);
|
738
738
|
} else
|
739
739
|
r = e.links;
|
740
|
-
r.forEach((
|
741
|
-
this.links[s][
|
742
|
-
...
|
740
|
+
r.forEach((n) => {
|
741
|
+
this.links[s][n.uuid] = {
|
742
|
+
...n,
|
743
743
|
_stopResolving: !0
|
744
744
|
};
|
745
745
|
});
|
@@ -747,18 +747,18 @@ class He {
|
|
747
747
|
async resolveRelations(e, t, s) {
|
748
748
|
let r = [];
|
749
749
|
if (e.rel_uuids) {
|
750
|
-
const
|
751
|
-
for (let a = 0; a <
|
752
|
-
const h = Math.min(
|
753
|
-
|
750
|
+
const n = e.rel_uuids.length, o = [], c = 50;
|
751
|
+
for (let a = 0; a < n; a += c) {
|
752
|
+
const h = Math.min(n, a + c);
|
753
|
+
o.push(e.rel_uuids.slice(a, h));
|
754
754
|
}
|
755
|
-
for (let a = 0; a <
|
755
|
+
for (let a = 0; a < o.length; a++)
|
756
756
|
(await this.getStories({
|
757
757
|
per_page: c,
|
758
758
|
language: t.language,
|
759
759
|
version: t.version,
|
760
760
|
starts_with: t.starts_with,
|
761
|
-
by_uuids:
|
761
|
+
by_uuids: o[a].join(","),
|
762
762
|
excluding_fields: t.excluding_fields
|
763
763
|
})).data.stories.forEach((h) => {
|
764
764
|
r.push(h);
|
@@ -766,9 +766,9 @@ class He {
|
|
766
766
|
r.length > 0 && (e.rels = r, delete e.rel_uuids);
|
767
767
|
} else
|
768
768
|
r = e.rels;
|
769
|
-
r && r.length > 0 && r.forEach((
|
770
|
-
this.relations[s][
|
771
|
-
...
|
769
|
+
r && r.length > 0 && r.forEach((n) => {
|
770
|
+
this.relations[s][n.uuid] = {
|
771
|
+
...n,
|
772
772
|
_stopResolving: !0
|
773
773
|
};
|
774
774
|
});
|
@@ -783,23 +783,23 @@ class He {
|
|
783
783
|
*
|
784
784
|
*/
|
785
785
|
async resolveStories(e, t, s) {
|
786
|
-
var r,
|
787
|
-
let
|
788
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (
|
786
|
+
var r, n;
|
787
|
+
let o = [];
|
788
|
+
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)
|
789
789
|
for (const c in this.relations[s])
|
790
790
|
this.iterateTree(
|
791
791
|
this.relations[s][c],
|
792
|
-
|
792
|
+
o,
|
793
793
|
s
|
794
794
|
);
|
795
|
-
e.story ? this.iterateTree(e.story,
|
796
|
-
this.iterateTree(c,
|
795
|
+
e.story ? this.iterateTree(e.story, o, s) : e.stories.forEach((c) => {
|
796
|
+
this.iterateTree(c, o, s);
|
797
797
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
798
798
|
}
|
799
799
|
async cacheResponse(e, t, s, r) {
|
800
|
-
const
|
800
|
+
const n = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
|
801
801
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
802
|
-
const c = await
|
802
|
+
const c = await o.get(n);
|
803
803
|
if (c)
|
804
804
|
return Promise.resolve(c);
|
805
805
|
}
|
@@ -814,17 +814,17 @@ class He {
|
|
814
814
|
);
|
815
815
|
if (u.status !== 200)
|
816
816
|
return a(u);
|
817
|
-
let
|
818
|
-
if ((h = u.headers) != null && h["per-page"] && (
|
817
|
+
let d = { data: u.data, headers: u.headers };
|
818
|
+
if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
|
819
819
|
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
820
820
|
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
821
|
-
})),
|
821
|
+
})), d.data.story || d.data.stories) {
|
822
822
|
const _ = this.resolveCounter = ++this.resolveCounter % 1e3;
|
823
|
-
await this.resolveStories(
|
823
|
+
await this.resolveStories(d.data, t, `${_}`), d = await this.processInlineAssets(d);
|
824
824
|
}
|
825
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await
|
825
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, d);
|
826
826
|
const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
827
|
-
return t.token &&
|
827
|
+
return t.token && d.data.cv && (b && A[t.token] && A[t.token] !== d.data.cv && await this.flushCache(), A[t.token] = d.data.cv), c(d);
|
828
828
|
} catch (u) {
|
829
829
|
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
830
830
|
return console.log(
|
@@ -838,16 +838,16 @@ class He {
|
|
838
838
|
return this.client.setFetchOptions(r), this.client[e](t, s);
|
839
839
|
}
|
840
840
|
cacheVersions() {
|
841
|
-
return
|
841
|
+
return A;
|
842
842
|
}
|
843
843
|
cacheVersion() {
|
844
|
-
return
|
844
|
+
return A[this.accessToken];
|
845
845
|
}
|
846
846
|
setCacheVersion(e) {
|
847
|
-
this.accessToken && (
|
847
|
+
this.accessToken && (A[this.accessToken] = e);
|
848
848
|
}
|
849
849
|
clearCacheVersion() {
|
850
|
-
this.accessToken && (
|
850
|
+
this.accessToken && (A[this.accessToken] = 0);
|
851
851
|
}
|
852
852
|
cacheProvider() {
|
853
853
|
switch (this.cache.type) {
|
@@ -889,6 +889,25 @@ class He {
|
|
889
889
|
async flushCache() {
|
890
890
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
891
891
|
}
|
892
|
+
async processInlineAssets(e) {
|
893
|
+
if (!this.inlineAssets)
|
894
|
+
return e;
|
895
|
+
const t = (s) => {
|
896
|
+
if (!s || typeof s != "object")
|
897
|
+
return s;
|
898
|
+
if (Array.isArray(s))
|
899
|
+
return s.map((n) => t(n));
|
900
|
+
let r = { ...s };
|
901
|
+
r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
|
902
|
+
...r,
|
903
|
+
...e.data.assets.find((n) => n.id === r.id)
|
904
|
+
});
|
905
|
+
for (const n in r)
|
906
|
+
typeof r[n] == "object" && (r[n] = t(r[n]));
|
907
|
+
return r;
|
908
|
+
};
|
909
|
+
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;
|
910
|
+
}
|
892
911
|
}
|
893
912
|
const Fe = (i = {}) => {
|
894
913
|
const { apiOptions: e } = i;
|
@@ -918,21 +937,21 @@ function Me(i, e) {
|
|
918
937
|
if (!e)
|
919
938
|
return { src: i, attrs: {} };
|
920
939
|
let t = 0, s = 0;
|
921
|
-
const r = {},
|
922
|
-
function
|
923
|
-
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${
|
940
|
+
const r = {}, n = [];
|
941
|
+
function o(a, h, u, d, b) {
|
942
|
+
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : b.push(`${d}(${a})`);
|
924
943
|
}
|
925
944
|
if (typeof e == "object") {
|
926
945
|
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, s = 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) {
|
927
|
-
const { filters: a } = e || {}, { blur: h, brightness: u, fill:
|
928
|
-
h &&
|
946
|
+
const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: b, grayscale: _, quality: y, rotate: S } = a || {};
|
947
|
+
h && o(h, 0, 100, "blur", n), y && o(y, 0, 100, "quality", n), u && o(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), _ && n.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${S})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
|
929
948
|
}
|
930
949
|
e.srcset && (r.srcset = e.srcset.map((a) => {
|
931
950
|
if (typeof a == "number")
|
932
|
-
return `${i}/m/${a}x0/${
|
951
|
+
return `${i}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
|
933
952
|
if (Array.isArray(a) && a.length === 2) {
|
934
953
|
const [h, u] = a;
|
935
|
-
return `${i}/m/${h}x${u}/${
|
954
|
+
return `${i}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
936
955
|
} else {
|
937
956
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
938
957
|
return;
|
@@ -940,12 +959,12 @@ function Me(i, e) {
|
|
940
959
|
}).join(", ")), e.sizes && (r.sizes = e.sizes.join(", "));
|
941
960
|
}
|
942
961
|
let c = `${i}/m/`;
|
943
|
-
return t > 0 && s > 0 && (c = `${c}${t}x${s}/`),
|
962
|
+
return t > 0 && s > 0 && (c = `${c}${t}x${s}/`), n.length > 0 && (c = `${c}filters:${n.join(":")}`), {
|
944
963
|
src: c,
|
945
964
|
attrs: r
|
946
965
|
};
|
947
966
|
}
|
948
|
-
var $ = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))($ || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), V = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(V || {}),
|
967
|
+
var $ = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))($ || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), V = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(V || {}), j = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(j || {});
|
949
968
|
const Be = [
|
950
969
|
"area",
|
951
970
|
"base",
|
@@ -967,34 +986,34 @@ function De(i) {
|
|
967
986
|
}
|
968
987
|
const L = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
|
969
988
|
function G(i, e = {}, t) {
|
970
|
-
const s = Ue(e), r = s ? `${i} ${s}` : i,
|
989
|
+
const s = Ue(e), r = s ? `${i} ${s}` : i, n = Array.isArray(t) ? t.join("") : t || "";
|
971
990
|
if (i) {
|
972
991
|
if (Be.includes(i))
|
973
992
|
return `<${r}>`;
|
974
|
-
} else return
|
975
|
-
return `<${r}>${
|
993
|
+
} else return n;
|
994
|
+
return `<${r}>${n}</${i}>`;
|
976
995
|
}
|
977
996
|
function Je(i = {}) {
|
978
997
|
const e = /* @__PURE__ */ new Map(), {
|
979
998
|
renderFn: t = G,
|
980
999
|
textFn: s = De,
|
981
1000
|
resolvers: r = {},
|
982
|
-
optimizeImages:
|
983
|
-
keyedResolvers:
|
984
|
-
} = i, c = t !== G, a = () => ({ render: (l,
|
985
|
-
if (
|
1001
|
+
optimizeImages: n = !1,
|
1002
|
+
keyedResolvers: o = !1
|
1003
|
+
} = i, c = t !== G, a = () => ({ render: (l, p = {}, g) => {
|
1004
|
+
if (o && l) {
|
986
1005
|
const f = e.get(l) || 0;
|
987
|
-
e.set(l, f + 1),
|
1006
|
+
e.set(l, f + 1), p.key = `${l}-${f}`;
|
988
1007
|
}
|
989
|
-
return t(l,
|
990
|
-
} }), h = (l) => (
|
991
|
-
const f =
|
992
|
-
return g.render(l, f,
|
993
|
-
}, u = (l,
|
1008
|
+
return t(l, p, g);
|
1009
|
+
} }), h = (l) => (p, g) => {
|
1010
|
+
const f = p.attrs || {};
|
1011
|
+
return g.render(l, f, p.children || null);
|
1012
|
+
}, u = (l, p) => {
|
994
1013
|
const { src: g, alt: f, title: k, srcset: w, sizes: v } = l.attrs || {};
|
995
1014
|
let T = g, R = {};
|
996
|
-
if (
|
997
|
-
const { src: se, attrs: re } = Me(g,
|
1015
|
+
if (n) {
|
1016
|
+
const { src: se, attrs: re } = Me(g, n);
|
998
1017
|
T = se, R = re;
|
999
1018
|
}
|
1000
1019
|
const te = {
|
@@ -1005,63 +1024,63 @@ function Je(i = {}) {
|
|
1005
1024
|
sizes: v,
|
1006
1025
|
...R
|
1007
1026
|
};
|
1008
|
-
return
|
1009
|
-
},
|
1027
|
+
return p.render("img", L(te));
|
1028
|
+
}, d = (l, p) => {
|
1010
1029
|
const { level: g, ...f } = l.attrs || {};
|
1011
|
-
return
|
1012
|
-
}, b = (l,
|
1030
|
+
return p.render(`h${g}`, f, l.children);
|
1031
|
+
}, b = (l, p) => {
|
1013
1032
|
var g, f, k, w;
|
1014
|
-
const v =
|
1033
|
+
const v = p.render("img", {
|
1015
1034
|
src: (g = l.attrs) == null ? void 0 : g.fallbackImage,
|
1016
1035
|
alt: (f = l.attrs) == null ? void 0 : f.alt,
|
1017
1036
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
1018
1037
|
draggable: "false",
|
1019
1038
|
loading: "lazy"
|
1020
1039
|
});
|
1021
|
-
return
|
1040
|
+
return p.render("span", {
|
1022
1041
|
"data-type": "emoji",
|
1023
1042
|
"data-name": (k = l.attrs) == null ? void 0 : k.name,
|
1024
1043
|
"data-emoji": (w = l.attrs) == null ? void 0 : w.emoji
|
1025
1044
|
}, v);
|
1026
|
-
}, _ = (l,
|
1045
|
+
}, _ = (l, p) => p.render(
|
1027
1046
|
"pre",
|
1028
1047
|
l.attrs || {},
|
1029
|
-
|
1030
|
-
), y = (l,
|
1031
|
-
const { class: w, id: v, ...T } = f || {}, R =
|
1048
|
+
p.render("code", {}, l.children || "")
|
1049
|
+
), y = (l, p = !1) => ({ text: g, attrs: f }, k) => {
|
1050
|
+
const { class: w, id: v, ...T } = f || {}, R = p ? {
|
1032
1051
|
class: w,
|
1033
1052
|
id: v,
|
1034
1053
|
style: ze(T) || void 0
|
1035
1054
|
} : f || {};
|
1036
1055
|
return k.render(l, L(R), g);
|
1037
|
-
}, S = (l) => N(l),
|
1038
|
-
const { marks:
|
1056
|
+
}, S = (l) => N(l), I = (l) => {
|
1057
|
+
const { marks: p, ...g } = l;
|
1039
1058
|
if ("text" in l) {
|
1040
|
-
if (
|
1041
|
-
return
|
1059
|
+
if (p)
|
1060
|
+
return p.reduce(
|
1042
1061
|
(k, w) => S({ ...w, text: k }),
|
1043
1062
|
S({ ...g, children: g.children })
|
1044
1063
|
);
|
1045
1064
|
const f = l.attrs || {};
|
1046
|
-
if (
|
1065
|
+
if (o) {
|
1047
1066
|
const k = e.get("txt") || 0;
|
1048
1067
|
e.set("txt", k + 1), f.key = `txt-${k}`;
|
1049
1068
|
}
|
1050
1069
|
return s(g.text, f);
|
1051
1070
|
}
|
1052
1071
|
return "";
|
1053
|
-
}, U = (l,
|
1072
|
+
}, U = (l, p) => {
|
1054
1073
|
const { linktype: g, href: f, anchor: k, ...w } = l.attrs || {};
|
1055
1074
|
let v = "";
|
1056
1075
|
switch (g) {
|
1057
|
-
case
|
1058
|
-
case
|
1076
|
+
case j.ASSET:
|
1077
|
+
case j.URL:
|
1059
1078
|
v = f;
|
1060
1079
|
break;
|
1061
|
-
case
|
1080
|
+
case j.EMAIL:
|
1062
1081
|
v = `mailto:${f}`;
|
1063
1082
|
break;
|
1064
|
-
case
|
1083
|
+
case j.STORY:
|
1065
1084
|
v = f, k && (v = `${v}#${k}`);
|
1066
1085
|
break;
|
1067
1086
|
default:
|
@@ -1069,37 +1088,37 @@ function Je(i = {}) {
|
|
1069
1088
|
break;
|
1070
1089
|
}
|
1071
1090
|
const T = { ...w };
|
1072
|
-
return v && (T.href = v),
|
1073
|
-
}, Y = (l,
|
1091
|
+
return v && (T.href = v), p.render("a", T, l.text);
|
1092
|
+
}, Y = (l, p) => {
|
1074
1093
|
var g, f;
|
1075
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
1094
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), p.render("span", {
|
1076
1095
|
blok: (g = l == null ? void 0 : l.attrs) == null ? void 0 : g.body[0],
|
1077
1096
|
id: (f = l.attrs) == null ? void 0 : f.id,
|
1078
1097
|
style: "display: none"
|
1079
1098
|
});
|
1080
|
-
}, W = (l,
|
1081
|
-
const g = {}, f =
|
1082
|
-
return
|
1083
|
-
}, X = (l,
|
1099
|
+
}, W = (l, p) => {
|
1100
|
+
const g = {}, f = p.render("tbody", {}, l.children);
|
1101
|
+
return p.render("table", g, f);
|
1102
|
+
}, X = (l, p) => {
|
1084
1103
|
const g = {};
|
1085
|
-
return
|
1086
|
-
}, Q = (l,
|
1104
|
+
return p.render("tr", g, l.children);
|
1105
|
+
}, Q = (l, p) => {
|
1087
1106
|
const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
|
1088
1107
|
...v
|
1089
1108
|
};
|
1090
1109
|
g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
|
1091
1110
|
const R = [];
|
1092
|
-
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")),
|
1093
|
-
}, Z = (l,
|
1111
|
+
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), p.render("td", L(T), l.children);
|
1112
|
+
}, Z = (l, p) => {
|
1094
1113
|
const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
|
1095
1114
|
...v
|
1096
1115
|
};
|
1097
1116
|
g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
|
1098
1117
|
const R = [];
|
1099
|
-
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")),
|
1118
|
+
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), p.render("th", L(T), l.children);
|
1100
1119
|
}, ee = new Map([
|
1101
1120
|
[$.DOCUMENT, h("")],
|
1102
|
-
[$.HEADING,
|
1121
|
+
[$.HEADING, d],
|
1103
1122
|
[$.PARAGRAPH, h("p")],
|
1104
1123
|
[$.UL_LIST, h("ul")],
|
1105
1124
|
[$.OL_LIST, h("ol")],
|
@@ -1111,7 +1130,7 @@ function Je(i = {}) {
|
|
1111
1130
|
[$.BR, h("br")],
|
1112
1131
|
[$.QUOTE, h("blockquote")],
|
1113
1132
|
[$.COMPONENT, Y],
|
1114
|
-
[V.TEXT,
|
1133
|
+
[V.TEXT, I],
|
1115
1134
|
[E.LINK, U],
|
1116
1135
|
[E.ANCHOR, U],
|
1117
1136
|
[E.STYLED, y("span", !0)],
|
@@ -1128,23 +1147,23 @@ function Je(i = {}) {
|
|
1128
1147
|
[$.TABLE_ROW, X],
|
1129
1148
|
[$.TABLE_CELL, Q],
|
1130
1149
|
[$.TABLE_HEADER, Z],
|
1131
|
-
...Object.entries(r).map(([l,
|
1150
|
+
...Object.entries(r).map(([l, p]) => [l, p])
|
1132
1151
|
]);
|
1133
|
-
function
|
1134
|
-
const
|
1135
|
-
if (!
|
1152
|
+
function x(l) {
|
1153
|
+
const p = ee.get(l.type);
|
1154
|
+
if (!p)
|
1136
1155
|
return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
|
1137
1156
|
const g = a();
|
1138
1157
|
if (l.type === "text")
|
1139
|
-
return
|
1158
|
+
return p(l, g);
|
1140
1159
|
const f = l.content ? l.content.map(N) : void 0;
|
1141
|
-
return
|
1160
|
+
return p({
|
1142
1161
|
...l,
|
1143
1162
|
children: f
|
1144
1163
|
}, g);
|
1145
1164
|
}
|
1146
1165
|
function N(l) {
|
1147
|
-
return l.type === "doc" ? c ? l.content.map(
|
1166
|
+
return l.type === "doc" ? c ? l.content.map(x) : l.content.map(x).join("") : Array.isArray(l) ? l.map(x) : x(l);
|
1148
1167
|
}
|
1149
1168
|
return {
|
1150
1169
|
render: N
|
@@ -1153,10 +1172,10 @@ function Je(i = {}) {
|
|
1153
1172
|
let M, B = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
1154
1173
|
const Ve = (i, e, t = {}) => {
|
1155
1174
|
var c;
|
1156
|
-
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u",
|
1175
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
|
1157
1176
|
"_storyblok"
|
1158
|
-
),
|
1159
|
-
if (!(!r || !
|
1177
|
+
), o = n !== null && +n === i;
|
1178
|
+
if (!(!r || !o)) {
|
1160
1179
|
if (!i) {
|
1161
1180
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
1162
1181
|
return;
|
@@ -1178,23 +1197,23 @@ const Ve = (i, e, t = {}) => {
|
|
1178
1197
|
};
|
1179
1198
|
});
|
1180
1199
|
}, Ke = (i = {}) => {
|
1181
|
-
var
|
1200
|
+
var d, b;
|
1182
1201
|
const {
|
1183
1202
|
bridge: e,
|
1184
1203
|
accessToken: t,
|
1185
1204
|
use: s = [],
|
1186
1205
|
apiOptions: r = {},
|
1187
|
-
richText:
|
1188
|
-
bridgeUrl:
|
1206
|
+
richText: n = {},
|
1207
|
+
bridgeUrl: o
|
1189
1208
|
} = i;
|
1190
1209
|
r.accessToken = r.accessToken || t;
|
1191
1210
|
const c = { bridge: e, apiOptions: r };
|
1192
1211
|
let a = {};
|
1193
1212
|
s.forEach((_) => {
|
1194
1213
|
a = { ...a, ..._(c) };
|
1195
|
-
}),
|
1196
|
-
const u = !(typeof window > "u") && ((b = (
|
1197
|
-
return e !== !1 && u && J(B), M = new P(
|
1214
|
+
}), o && (B = o);
|
1215
|
+
const u = !(typeof window > "u") && ((b = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : b.includes("_storyblok_tk"));
|
1216
|
+
return e !== !1 && u && J(B), M = new P(n.schema), n.resolver && K(M, n.resolver), a;
|
1198
1217
|
}, qe = (i) => {
|
1199
1218
|
var e;
|
1200
1219
|
return !i || !((e = i == null ? void 0 : i.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storyblok/js",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.
|
4
|
+
"version": "3.5.0",
|
5
5
|
"private": false,
|
6
6
|
"packageManager": "pnpm@10.2.0",
|
7
7
|
"description": "SDK to integrate Storyblok into your project using JavaScript.",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
46
|
"@storyblok/richtext": "3.2.0",
|
47
|
-
"storyblok-js-client": "6.
|
47
|
+
"storyblok-js-client": "6.11.0"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
50
|
"@commitlint/cli": "^19.7.1",
|