@storyblok/svelte 2.3.5 → 2.3.6
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-svelte.js +4 -4
- package/dist/storyblok-svelte.mjs +160 -155
- package/package.json +4 -4
package/dist/storyblok-svelte.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.storyblokSvelte={},h.e))})(this,function(h,m){"use strict";const
|
|
1
|
+
(function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.storyblokSvelte={},h.e))})(this,function(h,m){"use strict";const ct=(r=>r&&typeof r=="object"&&"default"in r?r:{default:r})(m);var ut=Object.defineProperty,ht=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,B=(r,t,e)=>t in r?ut(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t)=>{for(var e in t||(t={}))dt.call(t,e)&&B(r,e,t[e]);if(q)for(var e of q(t))pt.call(t,e)&&B(r,e,t[e]);return r},R=(r,t)=>ht(r,ft(t));let D=!1;const z=[],gt=r=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}D?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const n=document.createElement("script");n.async=!0,n.src=r,n.id="storyblok-javascript-bridge",n.onerror=s=>e(s),n.onload=s=>{z.forEach(o=>o()),D=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),mt=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e},yt=r=>r==="email";var U={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(r){return{tag:["pre",{tag:"code",attrs:r.attrs}]}},hard_break(){return{singleTag:"br"}},heading(r){return{tag:`h${r.attrs.level}`}},image(r){return{singleTag:[{tag:"img",attrs:mt(r.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return yt(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled(r){return{tag:[{tag:"span",attrs:r.attrs}]}}}};const kt=function(r){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},e=/[&<>"']/g,n=RegExp(e.source);return r&&n.test(r)?r.replace(e,s=>t[s]):r};class H{constructor(t){t||(t=U),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(kt(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let o=`<${s.tag}`;if(s.attrs)for(let a in s.attrs){let i=s.attrs[a];i!==null&&(o+=` ${a}="${i}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}/*!
|
|
2
2
|
* storyblok-js-client v4.5.2
|
|
3
3
|
* Universal JavaScript SDK for Storyblok's API
|
|
4
4
|
* (c) 2020-2022 Stobylok Team
|
|
5
|
-
*/function H(r){return typeof r=="number"&&r==r&&r!==1/0&&r!==-1/0}function V(r,t,e){if(!H(t))throw new TypeError("Expected `limit` to be a finite number");if(!H(e))throw new TypeError("Expected `interval` to be a finite number");var n=[],o=[],s=0,a=function(){s++;var l=setTimeout(function(){s--,n.length>0&&a(),o=o.filter(function(u){return u!==l})},e);o.indexOf(l)<0&&o.push(l);var c=n.shift();c.resolve(r.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,f){n.push({resolve:u,reject:f,args:l,self:c}),s<t&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],n.forEach(function(l){l.reject(new throttle.AbortError)}),n.length=0},i}V.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const yt=function(r,t){if(!r)return null;let e={};for(let n in r){let o=r[n];t.indexOf(n)>-1&&o!==null&&(e[n]=o)}return e};var kt={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:r=>({tag:`h${r.attrs.level}`}),image:r=>({singleTag:[{tag:"img",attrs:yt(r.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:r=>({tag:[{tag:"span",attrs:r.attrs}]})}};class _t{constructor(t){t||(t=kt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderOpeningTag(s.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(o=>{e.push(this.renderNode(o))}):t.text?e.push(function(o){const s={"&":"&","<":"<",">":">",'"':""","'":"'"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,l=>s[l]):o}(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderClosingTag(s.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(n=>{if(n.constructor===String)return`<${n}${e}>`;{let o=`<${n.tag}`;if(n.attrs)for(let s in n.attrs){let a=n.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const bt=(r=0,t=r)=>{const e=Math.abs(t-r)||0,n=r<t?1:-1;return((o=0,s)=>[...Array(o)].map(s))(e,(o,s)=>s*n+r)},E=(r,t,e)=>{const n=[];for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;const s=r[o],a=e?"":encodeURIComponent(o);let i;i=typeof s=="object"?E(s,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),n.push(i)}return n.join("&")};let b={},g={};class vt{constructor(t,e){if(!e){let s=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let n=Object.assign({},t.headers),o=5;t.oauthToken!==void 0&&(n.Authorization=t.oauthToken,o=3),t.rateLimit!==void 0&&(o=t.rateLimit),this.richTextResolver=new _t(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=V(this.throttledRequest,o,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=at.default.create({baseURL:e,timeout:t.timeout||0,headers:n,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(s=>t.responseInterceptor(s)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let n="";return e.attrs.body.forEach(o=>{n+=t(o.component,o)}),{html:n}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((n="")=>n.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,n,o){const s=this.factoryParamOptions(t,((a={},i=25,l=1)=>R(d({},a),{per_page:i,page:l}))(e,n,o));return this.cacheResponse(t,s)}get(t,e){let n=`/${t}`;const o=this.factoryParamOptions(n,e);return this.cacheResponse(n,o)}async getAll(t,e={},n){const o=e.per_page||25,s=`/${t}`,a=s.split("/");n=n||a[a.length-1];const i=await this.makeRequest(s,e,o,1),l=i.total?Math.ceil(i.total/o):1;return((c=[],u)=>c.map(u).reduce((f,$)=>[...f,...$],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))(bt(1,l),async c=>this.makeRequest(s,e,o,c+1))],c=>Object.values(c.data[n]))}post(t,e){let n=`/${t}`;return this.throttle("post",n,e)}put(t,e){let n=`/${t}`;return this.throttle("put",n,e)}delete(t,e){let n=`/${t}`;return this.throttle("delete",n,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const n=t[e];n&&n.fieldtype=="multilink"&&n.linktype=="story"&&typeof n.id=="string"&&this.links[n.id]?n.story=this._cleanCopy(this.links[n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[n.uuid]&&(n.story=this._cleanCopy(this.links[n.uuid]))}_insertRelations(t,e,n){if(n.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let o=[];t[e].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),t[e]=o}}}_insertAssetsRelations(t,e){e.forEach(n=>{t.id===n.id&&(t.original=n,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let n=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)n(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)o.component&&o._uid||o.type==="link"?(this._insertRelations(o,s,e),this._insertLinks(o,s)):"id"in o&&o.fieldtype==="asset"&&this._insertAssetsRelations(o,e),n(o[s])}}};n(t.content)}async resolveLinks(t,e){let n=[];if(t.link_uuids){const o=t.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.link_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.links;n.forEach(o=>{this.links[o.uuid]=R(d({},o),{_stopResolving:!0})})}async resolveRelations(t,e){let n=[];if(t.rel_uuids){const o=t.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.rel_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.rels;n.forEach(o=>{this.relations[o.uuid]=R(d({},o),{_stopResolving:!0})})}async resolveStories(t,e){let n=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(n=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const o in this.relations)this.iterateTree(this.relations[o],n);t.story?this.iterateTree(t.story,n):t.stories.forEach(o=>{this.iterateTree(o,n)})}resolveAssetsRelations(t){const{assets:e,stories:n,story:o}=t;if(n)for(const s of n)this.iterateTree(s,e);else{if(!o)return t;this.iterateTree(o,e)}}cacheResponse(t,e,n){return n===void 0&&(n=0),new Promise(async(o,s)=>{let a=E({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return o(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:f=>E(f)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),u=Object.assign({},u,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0}),c.status!=200)return s(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),o(u)}catch(c){if(c.response&&c.response.status===429&&(n+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${n} seconds.`),await(l=1e3*n,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,n).then(o).catch(s);s(c)}var l})}throttledRequest(t,e,n){return this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const wt=(r={})=>{const{apiOptions:t}=r;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new vt(t)}};var Tt=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let S;const $t="https://app.storyblok.com/f/storyblok-v2-latest.js",Rt=(r,t,e={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],o=>{o.action==="input"&&o.story.id===r?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===r&&window.location.reload()})})}},Et=(r={})=>{const{bridge:t,accessToken:e,use:n=[],apiOptions:o={},richText:s={}}=r;o.accessToken=o.accessToken||e;const a={bridge:t,apiOptions:o};let i={};return n.forEach(l=>{i=d(d({},i),l(a))}),t!==!1&&dt($t),S=new U(s.schema),s.resolver&&J(S,s.resolver),i},J=(r,t)=>{r.addNode("blok",e=>{let n="";return e.attrs.body.forEach(o=>{n+=t(o.component,o)}),{html:n}})},St=(r,t,e)=>{let n=e||S;if(!n){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(t&&(n=new U(t.schema),t.resolver&&J(n,t.resolver)),n.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
5
|
+
*/function V(r){return typeof r=="number"&&r==r&&r!==1/0&&r!==-1/0}function J(r,t,e){if(!V(t))throw new TypeError("Expected `limit` to be a finite number");if(!V(e))throw new TypeError("Expected `interval` to be a finite number");var n=[],s=[],o=0,a=function(){o++;var l=setTimeout(function(){o--,n.length>0&&a(),s=s.filter(function(u){return u!==l})},e);s.indexOf(l)<0&&s.push(l);var c=n.shift();c.resolve(r.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,f){n.push({resolve:u,reject:f,args:l,self:c}),o<t&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],n.forEach(function(l){l.reject(new throttle.AbortError)}),n.length=0},i}J.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const _t=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e};var bt={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:r=>({tag:`h${r.attrs.level}`}),image:r=>({singleTag:[{tag:"img",attrs:_t(r.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:r=>({tag:[{tag:"span",attrs:r.attrs}]})}};class vt{constructor(t){t||(t=bt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(function(s){const o={"&":"&","<":"<",">":">",'"':""","'":"'"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,l=>o[l]):s}(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(n=>{if(n.constructor===String)return`<${n}${e}>`;{let s=`<${n.tag}`;if(n.attrs)for(let o in n.attrs){let a=n.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const $t=(r=0,t=r)=>{const e=Math.abs(t-r)||0,n=r<t?1:-1;return((s=0,o)=>[...Array(s)].map(o))(e,(s,o)=>o*n+r)},E=(r,t,e)=>{const n=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const o=r[s],a=e?"":encodeURIComponent(s);let i;i=typeof o=="object"?E(o,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),n.push(i)}return n.join("&")};let b={},g={};class wt{constructor(t,e){if(!e){let o=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let n=Object.assign({},t.headers),s=5;t.oauthToken!==void 0&&(n.Authorization=t.oauthToken,s=3),t.rateLimit!==void 0&&(s=t.rateLimit),this.richTextResolver=new vt(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=J(this.throttledRequest,s,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=ct.default.create({baseURL:e,timeout:t.timeout||0,headers:n,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(o=>t.responseInterceptor(o)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((n="")=>n.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,n,s){const o=this.factoryParamOptions(t,((a={},i=25,l=1)=>R(d({},a),{per_page:i,page:l}))(e,n,s));return this.cacheResponse(t,o)}get(t,e){let n=`/${t}`;const s=this.factoryParamOptions(n,e);return this.cacheResponse(n,s)}async getAll(t,e={},n){const s=e.per_page||25,o=`/${t}`,a=o.split("/");n=n||a[a.length-1];const i=await this.makeRequest(o,e,s,1),l=i.total?Math.ceil(i.total/s):1;return((c=[],u)=>c.map(u).reduce((f,T)=>[...f,...T],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))($t(1,l),async c=>this.makeRequest(o,e,s,c+1))],c=>Object.values(c.data[n]))}post(t,e){let n=`/${t}`;return this.throttle("post",n,e)}put(t,e){let n=`/${t}`;return this.throttle("put",n,e)}delete(t,e){let n=`/${t}`;return this.throttle("delete",n,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const n=t[e];n&&n.fieldtype=="multilink"&&n.linktype=="story"&&typeof n.id=="string"&&this.links[n.id]?n.story=this._cleanCopy(this.links[n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[n.uuid]&&(n.story=this._cleanCopy(this.links[n.uuid]))}_insertRelations(t,e,n){if(n.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let s=[];t[e].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),t[e]=s}}}_insertAssetsRelations(t,e){e.forEach(n=>{t.id===n.id&&(t.original=n,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let n=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)n(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,e),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,e),n(s[o])}}};n(t.content)}async resolveLinks(t,e){let n=[];if(t.link_uuids){const s=t.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.link_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.links;n.forEach(s=>{this.links[s.uuid]=R(d({},s),{_stopResolving:!0})})}async resolveRelations(t,e){let n=[];if(t.rel_uuids){const s=t.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.rel_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.rels;n.forEach(s=>{this.relations[s.uuid]=R(d({},s),{_stopResolving:!0})})}async resolveStories(t,e){let n=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(n=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],n);t.story?this.iterateTree(t.story,n):t.stories.forEach(s=>{this.iterateTree(s,n)})}resolveAssetsRelations(t){const{assets:e,stories:n,story:s}=t;if(n)for(const o of n)this.iterateTree(o,e);else{if(!s)return t;this.iterateTree(s,e)}}cacheResponse(t,e,n){return n===void 0&&(n=0),new Promise(async(s,o)=>{let a=E({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return s(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:f=>E(f)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),u=Object.assign({},u,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0}),c.status!=200)return o(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),s(u)}catch(c){if(c.response&&c.response.status===429&&(n+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${n} seconds.`),await(l=1e3*n,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,n).then(s).catch(o);o(c)}var l})}throttledRequest(t,e,n){return this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const Tt=(r={})=>{const{apiOptions:t}=r;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new wt(t)}};var Rt=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let S;const Et="https://app.storyblok.com/f/storyblok-v2-latest.js",St=(r,t,e={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],s=>{s.action==="input"&&s.story.id===r?t(s.story):(s.action==="change"||s.action==="published")&&s.storyId===r&&window.location.reload()})})}},xt=(r={})=>{const{bridge:t,accessToken:e,use:n=[],apiOptions:s={},richText:o={}}=r;s.accessToken=s.accessToken||e;const a={bridge:t,apiOptions:s};let i={};return n.forEach(l=>{i=d(d({},i),l(a))}),t!==!1&>(Et),S=new H(o.schema),o.resolver&&Y(S,o.resolver),i},Y=(r,t)=>{r.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})},Ot=(r,t,e)=>{let n=e||S;if(!n){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(t&&(n=new H(t.schema),t.resolver&&Y(n,t.resolver)),n.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
6
6
|
|
|
7
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function
|
|
7
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function x(){}function O(r,t){for(const e in t)r[e]=t[e];return r}function F(r){return r()}function K(){return Object.create(null)}function y(r){r.forEach(F)}function G(r){return typeof r=="function"}function jt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Pt(r){return Object.keys(r).length===0}function At(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Q(r,t){const e={};t=new Set(t);for(const n in r)!t.has(n)&&n[0]!=="$"&&(e[n]=r[n]);return e}function Ct(r,t,e){r.insertBefore(t,e||null)}function W(r){r.parentNode.removeChild(r)}function Mt(r){return document.createTextNode(r)}function Nt(){return Mt("")}function It(r){return Array.from(r.childNodes)}function X(r,t){return new r(t)}let j;function k(r){j=r}const _=[],Z=[],v=[],tt=[],Lt=Promise.resolve();let P=!1;function qt(){P||(P=!0,Lt.then(et))}function A(r){v.push(r)}const C=new Set;let $=0;function et(){const r=j;do{for(;$<_.length;){const t=_[$];$++,k(t),Bt(t.$$)}for(k(null),_.length=0,$=0;Z.length;)Z.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];C.has(e)||(C.add(e),e())}v.length=0}while(_.length);for(;tt.length;)tt.pop()();P=!1,C.clear(),k(r)}function Bt(r){if(r.fragment!==null){r.update(),y(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(A)}}const w=new Set;let p;function Dt(){p={r:0,c:[],p}}function zt(){p.r||y(p.c),p=p.p}function M(r,t){r&&r.i&&(w.delete(r),r.i(t))}function rt(r,t,e,n){if(r&&r.o){if(w.has(r))return;w.add(r),p.c.push(()=>{w.delete(r),n&&(e&&r.d(1),n())}),r.o(t)}else n&&n()}function Ut(r,t){const e={},n={},s={$$scope:1};let o=r.length;for(;o--;){const a=r[o],i=t[o];if(i){for(const l in a)l in i||(n[l]=1);for(const l in i)s[l]||(e[l]=i[l],s[l]=1);r[o]=i}else for(const l in a)s[l]=1}for(const a in n)a in e||(e[a]=void 0);return e}function Ht(r){return typeof r=="object"&&r!==null?r:{}}function nt(r){r&&r.c()}function N(r,t,e,n){const{fragment:s,after_update:o}=r.$$;s&&s.m(t,e),n||A(()=>{const a=r.$$.on_mount.map(F).filter(G);r.$$.on_destroy?r.$$.on_destroy.push(...a):y(a),r.$$.on_mount=[]}),o.forEach(A)}function I(r,t){const e=r.$$;e.fragment!==null&&(y(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Vt(r,t){r.$$.dirty[0]===-1&&(_.push(r),qt(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Jt(r,t,e,n,s,o,a,i=[-1]){const l=j;k(r);const c=r.$$={fragment:null,ctx:[],props:o,update:x,not_equal:s,bound:K(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:K(),dirty:i,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=e?e(r,t.props||{},(f,T,...at)=>{const lt=at.length?at[0]:T;return c.ctx&&s(c.ctx[f],c.ctx[f]=lt)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](lt),u&&Vt(r,f)),T}):[],c.update(),u=!0,y(c.before_update),c.fragment=n?n(c.ctx):!1,t.target){if(t.hydrate){const f=It(t.target);c.fragment&&c.fragment.l(f),f.forEach(W)}else c.fragment&&c.fragment.c();t.intro&&M(r.$$.fragment),N(r,t.target,t.anchor,t.customElement),et()}k(l)}class Yt{$destroy(){I(this,1),this.$destroy=x}$on(t,e){if(!G(e))return x;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}$set(t){this.$$set&&!Pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ft(r){let t,e,n;const s=[{blok:r[0]},r[2]];var o=r[1];function a(i){let l={};for(let c=0;c<s.length;c+=1)l=O(l,s[c]);return{props:l}}return o&&(t=X(o,a())),{c(){t&&nt(t.$$.fragment),e=Nt()},m(i,l){t&&N(t,i,l),Ct(i,e,l),n=!0},p(i,[l]){const c=l&5?Ut(s,[l&1&&{blok:i[0]},l&4&&Ht(i[2])]):{};if(o!==(o=i[1])){if(t){Dt();const u=t;rt(u.$$.fragment,1,0,()=>{I(u,1)}),zt()}o?(t=X(o,a()),nt(t.$$.fragment),M(t.$$.fragment,1),N(t,e.parentNode,e)):t=null}else o&&t.$set(c)},i(i){n||(t&&M(t.$$.fragment,i),n=!0)},o(i){t&&rt(t.$$.fragment,i),n=!1},d(i){i&&W(e),t&&I(t,i)}}}function Kt(r,t,e){const n=["blok"];let s=Q(t,n),o,{blok:a}=t;return a?o=it(a.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),r.$$set=i=>{t=O(O({},t),At(i)),e(2,s=Q(t,n)),"blok"in i&&e(0,a=i.blok)},[a,o,s]}class Gt extends Yt{constructor(t){super(),Jt(this,t,Kt,Ft,jt,{blok:0})}}const Qt=(r,t)=>{const e=n=>{const s=Rt(n);s["data-blok-c"]&&(r.setAttribute("data-blok-c",s["data-blok-c"]),r.setAttribute("data-blok-uid",s["data-blok-uid"]),r.classList.add("storyblok__outline"))};return e(t),{update(n){e(n)}}};let L=null;const st=()=>(L||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),L);let ot=null;const Wt=r=>{const{storyblokApi:t}=xt(r);L=t,ot=r.components||{}},it=r=>{const t=ot[r];return t||console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
|
|
8
8
|
storyblokInit({
|
|
9
9
|
accessToken: "<your-token>",
|
|
10
10
|
components: {
|
|
11
11
|
"teaser": Teaser
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
|
-
`),t};h.RichTextSchema=
|
|
14
|
+
`),t};h.RichTextSchema=U,h.StoryblokComponent=Gt,h.apiPlugin=Tt,h.getComponent=it,h.getStoryblokApi=st,h.renderRichText=Ot,h.storyblokEditable=Qt,h.storyblokInit=Wt,h.useStoryblokApi=st,h.useStoryblokBridge=St,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import st from "axios";
|
|
2
|
+
var ot = Object.defineProperty, it = Object.defineProperties, at = Object.getOwnPropertyDescriptors, L = Object.getOwnPropertySymbols, lt = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, B = (r, t, e) => t in r ? ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
|
|
3
3
|
for (var e in t || (t = {}))
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
for (var e of
|
|
7
|
-
|
|
4
|
+
lt.call(t, e) && B(r, e, t[e]);
|
|
5
|
+
if (L)
|
|
6
|
+
for (var e of L(t))
|
|
7
|
+
ct.call(t, e) && B(r, e, t[e]);
|
|
8
8
|
return r;
|
|
9
|
-
},
|
|
10
|
-
let
|
|
11
|
-
const
|
|
9
|
+
}, w = (r, t) => it(r, at(t));
|
|
10
|
+
let z = !1;
|
|
11
|
+
const D = [], ut = (r) => new Promise((t, e) => {
|
|
12
12
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
13
13
|
if (window.location === window.parent.location) {
|
|
14
14
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
z ? s() : D.push(s);
|
|
18
18
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
19
19
|
return;
|
|
20
20
|
const n = document.createElement("script");
|
|
21
21
|
n.async = !0, n.src = r, n.id = "storyblok-javascript-bridge", n.onerror = (s) => e(s), n.onload = (s) => {
|
|
22
|
-
|
|
22
|
+
D.forEach((o) => o()), z = !0, t(s);
|
|
23
23
|
}, document.getElementsByTagName("head")[0].appendChild(n);
|
|
24
|
-
}),
|
|
24
|
+
}), ht = function(r, t) {
|
|
25
25
|
if (!r)
|
|
26
26
|
return null;
|
|
27
27
|
let e = {};
|
|
@@ -30,8 +30,8 @@ const z = [], lt = (r) => new Promise((t, e) => {
|
|
|
30
30
|
t.indexOf(n) > -1 && s !== null && (e[n] = s);
|
|
31
31
|
}
|
|
32
32
|
return e;
|
|
33
|
-
},
|
|
34
|
-
var
|
|
33
|
+
}, ft = (r) => r === "email";
|
|
34
|
+
var dt = {
|
|
35
35
|
nodes: {
|
|
36
36
|
horizontal_rule() {
|
|
37
37
|
return {
|
|
@@ -74,7 +74,7 @@ var ht = {
|
|
|
74
74
|
singleTag: [
|
|
75
75
|
{
|
|
76
76
|
tag: "img",
|
|
77
|
-
attrs:
|
|
77
|
+
attrs: ht(r.attrs, ["src", "alt", "title"])
|
|
78
78
|
}
|
|
79
79
|
]
|
|
80
80
|
};
|
|
@@ -128,7 +128,7 @@ var ht = {
|
|
|
128
128
|
},
|
|
129
129
|
link(r) {
|
|
130
130
|
const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
|
|
131
|
-
return
|
|
131
|
+
return ft(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
|
|
132
132
|
tag: [
|
|
133
133
|
{
|
|
134
134
|
tag: "a",
|
|
@@ -149,7 +149,7 @@ var ht = {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
const
|
|
152
|
+
const pt = function(r) {
|
|
153
153
|
const t = {
|
|
154
154
|
"&": "&",
|
|
155
155
|
"<": "<",
|
|
@@ -159,9 +159,9 @@ const ft = function(r) {
|
|
|
159
159
|
}, e = /[&<>"']/g, n = RegExp(e.source);
|
|
160
160
|
return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
|
|
161
161
|
};
|
|
162
|
-
class
|
|
162
|
+
class Q {
|
|
163
163
|
constructor(t) {
|
|
164
|
-
t || (t =
|
|
164
|
+
t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
165
165
|
}
|
|
166
166
|
addNode(t, e) {
|
|
167
167
|
this.nodes[t] = e;
|
|
@@ -187,7 +187,7 @@ class K {
|
|
|
187
187
|
const n = this.getMatchingNode(t);
|
|
188
188
|
return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
|
|
189
189
|
e.push(this.renderNode(s));
|
|
190
|
-
}) : t.text ? e.push(
|
|
190
|
+
}) : t.text ? e.push(pt(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
191
191
|
const o = this.getMatchingMark(s);
|
|
192
192
|
o && e.push(this.renderClosingTag(o.tag));
|
|
193
193
|
}), e.join("");
|
|
@@ -227,13 +227,13 @@ class K {
|
|
|
227
227
|
* Universal JavaScript SDK for Storyblok's API
|
|
228
228
|
* (c) 2020-2022 Stobylok Team
|
|
229
229
|
*/
|
|
230
|
-
function
|
|
230
|
+
function U(r) {
|
|
231
231
|
return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
if (!
|
|
233
|
+
function W(r, t, e) {
|
|
234
|
+
if (!U(t))
|
|
235
235
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
236
|
-
if (!
|
|
236
|
+
if (!U(e))
|
|
237
237
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
238
238
|
var n = [], s = [], o = 0, a = function() {
|
|
239
239
|
o++;
|
|
@@ -257,10 +257,10 @@ function G(r, t, e) {
|
|
|
257
257
|
}), n.length = 0;
|
|
258
258
|
}, i;
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
W.AbortError = function() {
|
|
261
261
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
262
262
|
};
|
|
263
|
-
const
|
|
263
|
+
const gt = function(r, t) {
|
|
264
264
|
if (!r)
|
|
265
265
|
return null;
|
|
266
266
|
let e = {};
|
|
@@ -270,13 +270,13 @@ const dt = function(r, t) {
|
|
|
270
270
|
}
|
|
271
271
|
return e;
|
|
272
272
|
};
|
|
273
|
-
var
|
|
273
|
+
var mt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: gt(r.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(r) {
|
|
274
274
|
const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
|
|
275
275
|
return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
|
|
276
276
|
}, styled: (r) => ({ tag: [{ tag: "span", attrs: r.attrs }] }) } };
|
|
277
|
-
class
|
|
277
|
+
class yt {
|
|
278
278
|
constructor(t) {
|
|
279
|
-
t || (t =
|
|
279
|
+
t || (t = mt), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
280
280
|
}
|
|
281
281
|
addNode(t, e) {
|
|
282
282
|
this.nodes[t] = e;
|
|
@@ -340,7 +340,7 @@ class gt {
|
|
|
340
340
|
return this.marks[t.type](t);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
const
|
|
343
|
+
const kt = (r = 0, t = r) => {
|
|
344
344
|
const e = Math.abs(t - r) || 0, n = r < t ? 1 : -1;
|
|
345
345
|
return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * n + r);
|
|
346
346
|
}, R = (r, t, e) => {
|
|
@@ -355,14 +355,14 @@ const mt = (r = 0, t = r) => {
|
|
|
355
355
|
return n.join("&");
|
|
356
356
|
};
|
|
357
357
|
let _ = {}, p = {};
|
|
358
|
-
class
|
|
358
|
+
class _t {
|
|
359
359
|
constructor(t, e) {
|
|
360
360
|
if (!e) {
|
|
361
361
|
let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
|
|
362
362
|
e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
|
|
363
363
|
}
|
|
364
364
|
let n = Object.assign({}, t.headers), s = 5;
|
|
365
|
-
t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new
|
|
365
|
+
t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new yt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = W(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = st.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
|
|
366
366
|
}
|
|
367
367
|
setComponentResolver(t) {
|
|
368
368
|
this.richTextResolver.addNode("blok", (e) => {
|
|
@@ -379,7 +379,7 @@ class yt {
|
|
|
379
379
|
return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
|
|
380
380
|
}
|
|
381
381
|
makeRequest(t, e, n, s) {
|
|
382
|
-
const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) =>
|
|
382
|
+
const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => w(d({}, a), { per_page: i, page: l }))(e, n, s));
|
|
383
383
|
return this.cacheResponse(t, o);
|
|
384
384
|
}
|
|
385
385
|
get(t, e) {
|
|
@@ -391,7 +391,7 @@ class yt {
|
|
|
391
391
|
const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
|
|
392
392
|
n = n || a[a.length - 1];
|
|
393
393
|
const i = await this.makeRequest(o, e, s, 1), l = i.total ? Math.ceil(i.total / s) : 1;
|
|
394
|
-
return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(
|
|
394
|
+
return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(kt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
|
|
395
395
|
}
|
|
396
396
|
post(t, e) {
|
|
397
397
|
let n = `/${t}`;
|
|
@@ -474,7 +474,7 @@ class yt {
|
|
|
474
474
|
} else
|
|
475
475
|
n = t.links;
|
|
476
476
|
n.forEach((s) => {
|
|
477
|
-
this.links[s.uuid] =
|
|
477
|
+
this.links[s.uuid] = w(d({}, s), { _stopResolving: !0 });
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
async resolveRelations(t, e) {
|
|
@@ -494,7 +494,7 @@ class yt {
|
|
|
494
494
|
} else
|
|
495
495
|
n = t.rels;
|
|
496
496
|
n.forEach((s) => {
|
|
497
|
-
this.relations[s.uuid] =
|
|
497
|
+
this.relations[s.uuid] = w(d({}, s), { _stopResolving: !0 });
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
async resolveStories(t, e) {
|
|
@@ -565,15 +565,15 @@ class yt {
|
|
|
565
565
|
return await this.cacheProvider().flush(), this;
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
|
-
const
|
|
568
|
+
const Vt = (r = {}) => {
|
|
569
569
|
const { apiOptions: t } = r;
|
|
570
570
|
if (!t.accessToken) {
|
|
571
571
|
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");
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
|
-
return { storyblokApi: new
|
|
574
|
+
return { storyblokApi: new _t(t) };
|
|
575
575
|
};
|
|
576
|
-
var
|
|
576
|
+
var bt = (r) => {
|
|
577
577
|
if (typeof r != "object" || typeof r._editable > "u")
|
|
578
578
|
return {};
|
|
579
579
|
const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
@@ -583,7 +583,7 @@ var kt = (r) => {
|
|
|
583
583
|
};
|
|
584
584
|
};
|
|
585
585
|
let x;
|
|
586
|
-
const
|
|
586
|
+
const vt = "https://app.storyblok.com/f/storyblok-v2-latest.js", Jt = (r, t, e = {}) => {
|
|
587
587
|
if (!(typeof window > "u")) {
|
|
588
588
|
if (typeof window.storyblokRegisterEvent > "u") {
|
|
589
589
|
console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
|
|
@@ -599,7 +599,7 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
|
|
|
599
599
|
});
|
|
600
600
|
});
|
|
601
601
|
}
|
|
602
|
-
},
|
|
602
|
+
}, $t = (r = {}) => {
|
|
603
603
|
const {
|
|
604
604
|
bridge: t,
|
|
605
605
|
accessToken: e,
|
|
@@ -612,8 +612,8 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
|
|
|
612
612
|
let i = {};
|
|
613
613
|
return n.forEach((l) => {
|
|
614
614
|
i = d(d({}, i), l(a));
|
|
615
|
-
}), t !== !1 &&
|
|
616
|
-
},
|
|
615
|
+
}), t !== !1 && ut(vt), x = new Q(o.schema), o.resolver && X(x, o.resolver), i;
|
|
616
|
+
}, X = (r, t) => {
|
|
617
617
|
r.addNode("blok", (e) => {
|
|
618
618
|
let n = "";
|
|
619
619
|
return e.attrs.body.forEach((s) => {
|
|
@@ -622,135 +622,138 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
|
|
|
622
622
|
html: n
|
|
623
623
|
};
|
|
624
624
|
});
|
|
625
|
-
},
|
|
625
|
+
}, Yt = (r, t, e) => {
|
|
626
626
|
let n = e || x;
|
|
627
627
|
if (!n) {
|
|
628
628
|
console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
|
|
629
629
|
return;
|
|
630
630
|
}
|
|
631
|
-
return r === "" ? "" : r ? (t && (n = new
|
|
631
|
+
return r === "" ? "" : r ? (t && (n = new Q(t.schema), t.resolver && X(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
632
632
|
|
|
633
633
|
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
634
634
|
};
|
|
635
|
-
function
|
|
635
|
+
function E() {
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
function O(r, t) {
|
|
638
638
|
for (const e in t)
|
|
639
639
|
r[e] = t[e];
|
|
640
640
|
return r;
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function Z(r) {
|
|
643
643
|
return r();
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function H() {
|
|
646
646
|
return /* @__PURE__ */ Object.create(null);
|
|
647
647
|
}
|
|
648
648
|
function y(r) {
|
|
649
|
-
r.forEach(
|
|
649
|
+
r.forEach(Z);
|
|
650
650
|
}
|
|
651
|
-
function
|
|
651
|
+
function tt(r) {
|
|
652
652
|
return typeof r == "function";
|
|
653
653
|
}
|
|
654
654
|
function wt(r, t) {
|
|
655
655
|
return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
|
|
656
656
|
}
|
|
657
|
-
function
|
|
657
|
+
function Tt(r) {
|
|
658
658
|
return Object.keys(r).length === 0;
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function Rt(r) {
|
|
661
661
|
const t = {};
|
|
662
662
|
for (const e in r)
|
|
663
663
|
e[0] !== "$" && (t[e] = r[e]);
|
|
664
664
|
return t;
|
|
665
665
|
}
|
|
666
|
-
function
|
|
666
|
+
function V(r, t) {
|
|
667
667
|
const e = {};
|
|
668
668
|
t = new Set(t);
|
|
669
669
|
for (const n in r)
|
|
670
670
|
!t.has(n) && n[0] !== "$" && (e[n] = r[n]);
|
|
671
671
|
return e;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function xt(r, t, e) {
|
|
674
674
|
r.insertBefore(t, e || null);
|
|
675
675
|
}
|
|
676
|
-
function
|
|
676
|
+
function et(r) {
|
|
677
677
|
r.parentNode.removeChild(r);
|
|
678
678
|
}
|
|
679
|
-
function
|
|
679
|
+
function Et(r) {
|
|
680
680
|
return document.createTextNode(r);
|
|
681
681
|
}
|
|
682
|
-
function
|
|
683
|
-
return
|
|
682
|
+
function Ot() {
|
|
683
|
+
return Et("");
|
|
684
684
|
}
|
|
685
|
-
function
|
|
685
|
+
function St(r) {
|
|
686
686
|
return Array.from(r.childNodes);
|
|
687
687
|
}
|
|
688
|
-
|
|
688
|
+
function J(r, t) {
|
|
689
|
+
return new r(t);
|
|
690
|
+
}
|
|
691
|
+
let N;
|
|
689
692
|
function m(r) {
|
|
690
|
-
|
|
693
|
+
N = r;
|
|
691
694
|
}
|
|
692
|
-
const g = [],
|
|
693
|
-
let
|
|
694
|
-
function
|
|
695
|
-
|
|
695
|
+
const g = [], Y = [], v = [], F = [], jt = Promise.resolve();
|
|
696
|
+
let S = !1;
|
|
697
|
+
function Pt() {
|
|
698
|
+
S || (S = !0, jt.then(rt));
|
|
696
699
|
}
|
|
697
|
-
function
|
|
700
|
+
function j(r) {
|
|
698
701
|
v.push(r);
|
|
699
702
|
}
|
|
700
703
|
const T = /* @__PURE__ */ new Set();
|
|
701
704
|
let b = 0;
|
|
702
|
-
function
|
|
703
|
-
const r =
|
|
705
|
+
function rt() {
|
|
706
|
+
const r = N;
|
|
704
707
|
do {
|
|
705
708
|
for (; b < g.length; ) {
|
|
706
709
|
const t = g[b];
|
|
707
|
-
b++, m(t),
|
|
710
|
+
b++, m(t), At(t.$$);
|
|
708
711
|
}
|
|
709
|
-
for (m(null), g.length = 0, b = 0;
|
|
710
|
-
|
|
712
|
+
for (m(null), g.length = 0, b = 0; Y.length; )
|
|
713
|
+
Y.pop()();
|
|
711
714
|
for (let t = 0; t < v.length; t += 1) {
|
|
712
715
|
const e = v[t];
|
|
713
716
|
T.has(e) || (T.add(e), e());
|
|
714
717
|
}
|
|
715
718
|
v.length = 0;
|
|
716
719
|
} while (g.length);
|
|
717
|
-
for (;
|
|
718
|
-
|
|
719
|
-
|
|
720
|
+
for (; F.length; )
|
|
721
|
+
F.pop()();
|
|
722
|
+
S = !1, T.clear(), m(r);
|
|
720
723
|
}
|
|
721
|
-
function
|
|
724
|
+
function At(r) {
|
|
722
725
|
if (r.fragment !== null) {
|
|
723
726
|
r.update(), y(r.before_update);
|
|
724
727
|
const t = r.dirty;
|
|
725
|
-
r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(
|
|
728
|
+
r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(j);
|
|
726
729
|
}
|
|
727
730
|
}
|
|
728
|
-
const
|
|
731
|
+
const $ = /* @__PURE__ */ new Set();
|
|
729
732
|
let f;
|
|
730
|
-
function
|
|
733
|
+
function Ct() {
|
|
731
734
|
f = {
|
|
732
735
|
r: 0,
|
|
733
736
|
c: [],
|
|
734
737
|
p: f
|
|
735
738
|
};
|
|
736
739
|
}
|
|
737
|
-
function
|
|
740
|
+
function Mt() {
|
|
738
741
|
f.r || y(f.c), f = f.p;
|
|
739
742
|
}
|
|
740
|
-
function
|
|
741
|
-
r && r.i && (
|
|
743
|
+
function P(r, t) {
|
|
744
|
+
r && r.i && ($.delete(r), r.i(t));
|
|
742
745
|
}
|
|
743
|
-
function
|
|
746
|
+
function K(r, t, e, n) {
|
|
744
747
|
if (r && r.o) {
|
|
745
|
-
if (
|
|
748
|
+
if ($.has(r))
|
|
746
749
|
return;
|
|
747
|
-
|
|
748
|
-
|
|
750
|
+
$.add(r), f.c.push(() => {
|
|
751
|
+
$.delete(r), n && (e && r.d(1), n());
|
|
749
752
|
}), r.o(t);
|
|
750
753
|
} else
|
|
751
754
|
n && n();
|
|
752
755
|
}
|
|
753
|
-
function
|
|
756
|
+
function Nt(r, t) {
|
|
754
757
|
const e = {}, n = {}, s = { $$scope: 1 };
|
|
755
758
|
let o = r.length;
|
|
756
759
|
for (; o--; ) {
|
|
@@ -769,67 +772,69 @@ function Mt(r, t) {
|
|
|
769
772
|
a in e || (e[a] = void 0);
|
|
770
773
|
return e;
|
|
771
774
|
}
|
|
772
|
-
function
|
|
775
|
+
function It(r) {
|
|
773
776
|
return typeof r == "object" && r !== null ? r : {};
|
|
774
777
|
}
|
|
775
|
-
function
|
|
778
|
+
function G(r) {
|
|
776
779
|
r && r.c();
|
|
777
780
|
}
|
|
778
|
-
function
|
|
779
|
-
const { fragment: s,
|
|
780
|
-
s && s.m(t, e), n ||
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
}),
|
|
781
|
+
function A(r, t, e, n) {
|
|
782
|
+
const { fragment: s, after_update: o } = r.$$;
|
|
783
|
+
s && s.m(t, e), n || j(() => {
|
|
784
|
+
const a = r.$$.on_mount.map(Z).filter(tt);
|
|
785
|
+
r.$$.on_destroy ? r.$$.on_destroy.push(...a) : y(a), r.$$.on_mount = [];
|
|
786
|
+
}), o.forEach(j);
|
|
784
787
|
}
|
|
785
|
-
function
|
|
788
|
+
function C(r, t) {
|
|
786
789
|
const e = r.$$;
|
|
787
790
|
e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
|
|
788
791
|
}
|
|
789
|
-
function
|
|
790
|
-
r.$$.dirty[0] === -1 && (g.push(r),
|
|
792
|
+
function qt(r, t) {
|
|
793
|
+
r.$$.dirty[0] === -1 && (g.push(r), Pt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
|
|
791
794
|
}
|
|
792
|
-
function
|
|
793
|
-
const l =
|
|
795
|
+
function Lt(r, t, e, n, s, o, a, i = [-1]) {
|
|
796
|
+
const l = N;
|
|
794
797
|
m(r);
|
|
795
798
|
const c = r.$$ = {
|
|
796
799
|
fragment: null,
|
|
797
|
-
ctx:
|
|
800
|
+
ctx: [],
|
|
798
801
|
props: o,
|
|
799
|
-
update:
|
|
802
|
+
update: E,
|
|
800
803
|
not_equal: s,
|
|
801
|
-
bound:
|
|
804
|
+
bound: H(),
|
|
802
805
|
on_mount: [],
|
|
803
806
|
on_destroy: [],
|
|
804
807
|
on_disconnect: [],
|
|
805
808
|
before_update: [],
|
|
806
809
|
after_update: [],
|
|
807
810
|
context: new Map(t.context || (l ? l.$$.context : [])),
|
|
808
|
-
callbacks:
|
|
811
|
+
callbacks: H(),
|
|
809
812
|
dirty: i,
|
|
810
813
|
skip_bound: !1,
|
|
811
814
|
root: t.target || l.$$.root
|
|
812
815
|
};
|
|
813
816
|
a && a(c.root);
|
|
814
817
|
let u = !1;
|
|
815
|
-
if (c.ctx = e ? e(r, t.props || {}, (h, k, ...
|
|
816
|
-
const
|
|
817
|
-
return c.ctx && s(c.ctx[h], c.ctx[h] =
|
|
818
|
+
if (c.ctx = e ? e(r, t.props || {}, (h, k, ...I) => {
|
|
819
|
+
const q = I.length ? I[0] : k;
|
|
820
|
+
return c.ctx && s(c.ctx[h], c.ctx[h] = q) && (!c.skip_bound && c.bound[h] && c.bound[h](q), u && qt(r, h)), k;
|
|
818
821
|
}) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
|
|
819
822
|
if (t.hydrate) {
|
|
820
|
-
const h =
|
|
821
|
-
c.fragment && c.fragment.l(h), h.forEach(
|
|
823
|
+
const h = St(t.target);
|
|
824
|
+
c.fragment && c.fragment.l(h), h.forEach(et);
|
|
822
825
|
} else
|
|
823
826
|
c.fragment && c.fragment.c();
|
|
824
|
-
t.intro &&
|
|
827
|
+
t.intro && P(r.$$.fragment), A(r, t.target, t.anchor, t.customElement), rt();
|
|
825
828
|
}
|
|
826
829
|
m(l);
|
|
827
830
|
}
|
|
828
|
-
class
|
|
831
|
+
class Bt {
|
|
829
832
|
$destroy() {
|
|
830
|
-
|
|
833
|
+
C(this, 1), this.$destroy = E;
|
|
831
834
|
}
|
|
832
835
|
$on(t, e) {
|
|
836
|
+
if (!tt(e))
|
|
837
|
+
return E;
|
|
833
838
|
const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
|
|
834
839
|
return n.push(e), () => {
|
|
835
840
|
const s = n.indexOf(e);
|
|
@@ -837,69 +842,69 @@ class Lt {
|
|
|
837
842
|
};
|
|
838
843
|
}
|
|
839
844
|
$set(t) {
|
|
840
|
-
this.$$set &&
|
|
845
|
+
this.$$set && !Tt(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
|
|
841
846
|
}
|
|
842
847
|
}
|
|
843
|
-
function
|
|
848
|
+
function zt(r) {
|
|
844
849
|
let t, e, n;
|
|
845
850
|
const s = [{ blok: r[0] }, r[2]];
|
|
846
851
|
var o = r[1];
|
|
847
852
|
function a(i) {
|
|
848
853
|
let l = {};
|
|
849
854
|
for (let c = 0; c < s.length; c += 1)
|
|
850
|
-
l =
|
|
855
|
+
l = O(l, s[c]);
|
|
851
856
|
return { props: l };
|
|
852
857
|
}
|
|
853
|
-
return o && (t =
|
|
858
|
+
return o && (t = J(o, a())), {
|
|
854
859
|
c() {
|
|
855
|
-
t &&
|
|
860
|
+
t && G(t.$$.fragment), e = Ot();
|
|
856
861
|
},
|
|
857
862
|
m(i, l) {
|
|
858
|
-
t &&
|
|
863
|
+
t && A(t, i, l), xt(i, e, l), n = !0;
|
|
859
864
|
},
|
|
860
865
|
p(i, [l]) {
|
|
861
|
-
const c = l & 5 ?
|
|
866
|
+
const c = l & 5 ? Nt(s, [
|
|
862
867
|
l & 1 && { blok: i[0] },
|
|
863
|
-
l & 4 &&
|
|
868
|
+
l & 4 && It(i[2])
|
|
864
869
|
]) : {};
|
|
865
870
|
if (o !== (o = i[1])) {
|
|
866
871
|
if (t) {
|
|
867
|
-
|
|
872
|
+
Ct();
|
|
868
873
|
const u = t;
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}),
|
|
874
|
+
K(u.$$.fragment, 1, 0, () => {
|
|
875
|
+
C(u, 1);
|
|
876
|
+
}), Mt();
|
|
872
877
|
}
|
|
873
|
-
o ? (t =
|
|
878
|
+
o ? (t = J(o, a()), G(t.$$.fragment), P(t.$$.fragment, 1), A(t, e.parentNode, e)) : t = null;
|
|
874
879
|
} else
|
|
875
880
|
o && t.$set(c);
|
|
876
881
|
},
|
|
877
882
|
i(i) {
|
|
878
|
-
n || (t &&
|
|
883
|
+
n || (t && P(t.$$.fragment, i), n = !0);
|
|
879
884
|
},
|
|
880
885
|
o(i) {
|
|
881
|
-
t &&
|
|
886
|
+
t && K(t.$$.fragment, i), n = !1;
|
|
882
887
|
},
|
|
883
888
|
d(i) {
|
|
884
|
-
i &&
|
|
889
|
+
i && et(e), t && C(t, i);
|
|
885
890
|
}
|
|
886
891
|
};
|
|
887
892
|
}
|
|
888
|
-
function
|
|
893
|
+
function Dt(r, t, e) {
|
|
889
894
|
const n = ["blok"];
|
|
890
|
-
let s =
|
|
891
|
-
return a ? o =
|
|
892
|
-
t =
|
|
895
|
+
let s = V(t, n), o, { blok: a } = t;
|
|
896
|
+
return a ? o = Ut(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
|
|
897
|
+
t = O(O({}, t), Rt(i)), e(2, s = V(t, n)), "blok" in i && e(0, a = i.blok);
|
|
893
898
|
}, [a, o, s];
|
|
894
899
|
}
|
|
895
|
-
class
|
|
900
|
+
class Ft extends Bt {
|
|
896
901
|
constructor(t) {
|
|
897
|
-
super(),
|
|
902
|
+
super(), Lt(this, t, Dt, zt, wt, { blok: 0 });
|
|
898
903
|
}
|
|
899
904
|
}
|
|
900
|
-
const
|
|
905
|
+
const Kt = (r, t) => {
|
|
901
906
|
const e = (n) => {
|
|
902
|
-
const s =
|
|
907
|
+
const s = bt(n);
|
|
903
908
|
s["data-blok-c"] && (r.setAttribute("data-blok-c", s["data-blok-c"]), r.setAttribute("data-blok-uid", s["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
904
909
|
};
|
|
905
910
|
return e(t), {
|
|
@@ -908,16 +913,16 @@ const Ft = (r, t) => {
|
|
|
908
913
|
}
|
|
909
914
|
};
|
|
910
915
|
};
|
|
911
|
-
let
|
|
912
|
-
const
|
|
916
|
+
let M = null;
|
|
917
|
+
const Gt = () => (M || console.log(
|
|
913
918
|
"You can't use getStoryblokApi if you're not loading apiPlugin."
|
|
914
|
-
),
|
|
915
|
-
let
|
|
916
|
-
const
|
|
917
|
-
const { storyblokApi: t } =
|
|
918
|
-
|
|
919
|
-
},
|
|
920
|
-
const t =
|
|
919
|
+
), M);
|
|
920
|
+
let nt = null;
|
|
921
|
+
const Qt = (r) => {
|
|
922
|
+
const { storyblokApi: t } = $t(r);
|
|
923
|
+
M = t, nt = r.components || {};
|
|
924
|
+
}, Ut = (r) => {
|
|
925
|
+
const t = nt[r];
|
|
921
926
|
return t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
|
|
922
927
|
storyblokInit({
|
|
923
928
|
accessToken: "<your-token>",
|
|
@@ -928,14 +933,14 @@ storyblokInit({
|
|
|
928
933
|
`), t;
|
|
929
934
|
};
|
|
930
935
|
export {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
936
|
+
dt as RichTextSchema,
|
|
937
|
+
Ft as StoryblokComponent,
|
|
938
|
+
Vt as apiPlugin,
|
|
939
|
+
Ut as getComponent,
|
|
940
|
+
Gt as getStoryblokApi,
|
|
941
|
+
Yt as renderRichText,
|
|
942
|
+
Kt as storyblokEditable,
|
|
943
|
+
Qt as storyblokInit,
|
|
944
|
+
Gt as useStoryblokApi,
|
|
945
|
+
Jt as useStoryblokBridge
|
|
941
946
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/svelte",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.6",
|
|
4
4
|
"description": "Storyblok SDK to connect Storyblok with Svelte",
|
|
5
5
|
"main": "./dist/storyblok-svelte.js",
|
|
6
6
|
"module": "./dist/storyblok-svelte.mjs",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"cypress-svelte-unit-test": "^3.3.4",
|
|
40
40
|
"eslint-plugin-cypress": "^2.12.1",
|
|
41
41
|
"eslint-plugin-jest": "^27.0.4",
|
|
42
|
-
"jest": "^29.
|
|
42
|
+
"jest": "^29.2.1",
|
|
43
43
|
"svelte-preprocess": "^4.10.7",
|
|
44
|
-
"typescript": "^4.8.
|
|
45
|
-
"vite": "^3.1.
|
|
44
|
+
"typescript": "^4.8.4",
|
|
45
|
+
"vite": "^3.1.8"
|
|
46
46
|
},
|
|
47
47
|
"eslintConfig": {
|
|
48
48
|
"env": {
|