@storyblok/react 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-0cdf4d8e.js → client-8bf0d228.js} +1 -1
- package/dist/{client-798eb80c.mjs → client-d552e212.mjs} +2 -2
- package/dist/{index-4af66cd0.mjs → index-9ce0eb0d.mjs} +2 -2
- package/dist/{index-364d653e.js → index-f2312f95.js} +1 -1
- package/dist/{storyblok-js-5db94779.js → storyblok-js-1fc8cce4.js} +1 -1
- package/dist/{storyblok-js-5fd880b4.mjs → storyblok-js-82c403db.mjs} +208 -202
- package/dist/storyblok-react.js +1 -1
- package/dist/storyblok-react.mjs +13 -13
- package/dist/storyblok-react2.js +1 -1
- package/dist/storyblok-react2.mjs +8 -8
- package/dist/storyblok-react3.js +1 -1
- package/dist/storyblok-react3.mjs +1 -1
- package/dist/storyblok-react4.js +1 -1
- package/dist/storyblok-react4.mjs +3 -3
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("./storyblok-js-
|
|
1
|
+
"use strict";const e=require("react"),t=require("./storyblok-js-1fc8cce4.js");exports.useStoryblokState=(r=null,o={})=>{let[s,n]=e.useState(r);if(!("undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent)||!r)return r;const i=s.internalId||s.id;return e.useEffect((()=>{n(r),t.pe(i,(e=>n(e)),o)}),[r]),s};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { p as pe } from "./storyblok-js-82c403db.mjs";
|
|
3
3
|
const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
|
|
4
4
|
let [story, setStory] = useState(initialStory);
|
|
5
5
|
const isBridgeEnable = typeof window !== "undefined" && typeof window.storyblokRegisterEvent !== "undefined";
|
|
@@ -9,7 +9,7 @@ const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
|
|
|
9
9
|
const id = story.internalId || story.id;
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
setStory(initialStory);
|
|
12
|
-
|
|
12
|
+
pe(
|
|
13
13
|
id,
|
|
14
14
|
(newStory) => setStory(newStory),
|
|
15
15
|
bridgeOptions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as me } from "./storyblok-js-82c403db.mjs";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
const StoryblokComponent = forwardRef(
|
|
4
4
|
({ blok, ...restProps }, ref) => {
|
|
@@ -38,7 +38,7 @@ const getComponent = (componentKey) => {
|
|
|
38
38
|
return componentsMap[componentKey];
|
|
39
39
|
};
|
|
40
40
|
const storyblokInit = (pluginOptions = {}) => {
|
|
41
|
-
const { storyblokApi } =
|
|
41
|
+
const { storyblokApi } = me(pluginOptions);
|
|
42
42
|
storyblokApiInstance = storyblokApi;
|
|
43
43
|
componentsMap = pluginOptions.components;
|
|
44
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./storyblok-js-
|
|
1
|
+
"use strict";const o=require("./storyblok-js-1fc8cce4.js"),e=require("react"),t=e.forwardRef((({blok:o,...t},r)=>{if(!o)return console.error("Please provide a 'blok' property to the StoryblokComponent"),e.createElement("div",null,"Please provide a blok property to the StoryblokComponent");const n=l(o.component);return n?e.createElement(n,{ref:r,blok:o,...t}):e.createElement("div",null)}));t.displayName="StoryblokComponent";let r=null,n={};const l=o=>n[o]?n[o]:(console.error(`Component ${o} doesn't exist.`),!1);exports.StoryblokComponent=t,exports.getComponent=l,exports.setComponents=o=>(n=o,n),exports.storyblokInit=(e={})=>{const{storyblokApi:t}=o.me(e);r=t,n=e.components},exports.useStoryblokApi=()=>(r||console.error("You can't use getStoryblokApi if you're not loading apiPlugin."),r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let t=!1;const e=[],s=s=>new Promise(((r,o)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{window.location!==window.parent.location?t?s():e.push(s):console.warn("You are not in Draft Mode or in the Visual Editor.")},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=s,i.id="storyblok-javascript-bridge",i.onerror=t=>o(t),i.onload=s=>{e.forEach((t=>t())),t=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(i)}));var r=Object.defineProperty,o=(t,e,s)=>(((t,e,s)=>{e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);function i(t){return!(t!=t||t===1/0||t===-1/0)}const n=function(t,e){const s={};for(const r in t){const o=t[r];e.indexOf(r)>-1&&null!==o&&(s[r]=o)}return s},a={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:t=>({tag:`h${t.attrs.level}`}),image:t=>({singleTag:[{tag:"img",attrs:n(t.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:t=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":t.attrs.name,emoji:t.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:t=>{const e={...t.attrs},{linktype:s="url"}=t.attrs;if((t=>"email"===t)(s)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const t in e.custom)e[t]=e.custom[t];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:t=>({tag:[{tag:"span",attrs:t.attrs}]}),highlight:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${t.attrs.color};`}}]}:{tag:""}},textStyle:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`color:${t.attrs.color}`}}]}:{tag:""}}}};class l{constructor(t){o(this,"marks"),o(this,"nodes"),t||(t=a),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach((t=>{s+=this.renderNode(t)})),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn("The render method must receive an Object with a \"content\" field.\n\t\t\tThe \"content\" field must be an array of nodes as the type ISbRichtext.\n\t\t\tISbRichtext:\n\t\t\t\tcontent?: ISbRichtext[]\n\t\t\t\tmarks?: ISbRichtext[]\n\t\t\t\tattrs?: any\n\t\t\t\ttext?: string\n\t\t\t\ttype: string\n\t\t\t\t\n\t\t\t\tExample:\n\t\t\t\t{\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttext: 'Hello World',\n\t\t\t\t\t\t\t\t\ttype: 'text'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\ttype: 'paragraph'\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\ttype: 'doc'\n\t\t\t\t}"),""}optimizeImages(t,e){let s=0,r=0,o="",i="";"boolean"!=typeof e&&("number"==typeof e.width&&e.width>0&&(o+=`width="${e.width}" `,s=e.width),"number"==typeof e.height&&e.height>0&&(o+=`height="${e.height}" `,r=e.height),("lazy"===e.loading||"eager"===e.loading)&&(o+=`loading="${e.loading}" `),"string"==typeof e.class&&e.class.length>0&&(o+=`class="${e.class}" `),e.filters&&("number"==typeof e.filters.blur&&e.filters.blur>=0&&e.filters.blur<=100&&(i+=`:blur(${e.filters.blur})`),"number"==typeof e.filters.brightness&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(i+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||"transparent"===e.filters.fill)&&(i+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(i+=`:format(${e.filters.format})`),"boolean"==typeof e.filters.grayscale&&e.filters.grayscale&&(i+=":grayscale()"),"number"==typeof e.filters.quality&&e.filters.quality>=0&&e.filters.quality<=100&&(i+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(i+=`:rotate(${e.filters.rotate})`),i.length>0&&(i="/filters"+i))),o.length>0&&(t=t.replace(/<img/g,`<img ${o.trim()}`));const n=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${n}`),"boolean"!=typeof e&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,(t=>{var s,r;const o=t.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(o&&o.length>0){const n={srcset:null==(s=e.srcset)?void 0:s.map((t=>{if("number"==typeof t)return`//${o}/m/${t}x0${i} ${t}w`;if("object"==typeof t&&2===t.length){let e=0,s=0;return"number"==typeof t[0]&&(e=t[0]),"number"==typeof t[1]&&(s=t[1]),`//${o}/m/${e}x${s}${i} ${e}w`}})).join(", "),sizes:null==(r=e.sizes)?void 0:r.map((t=>t)).join(", ")};let a="";return n.srcset&&(a+=`srcset="${n.srcset}" `),n.sizes&&(a+=`sizes="${n.sizes}" `),t.replace(/<img/g,`<img ${a.trim()}`)}return t}))),t}renderNode(t){const e=[];t.marks&&t.marks.forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderOpeningTag(s.tag))}));const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach((t=>{e.push(this.renderNode(t))})):t.text?e.push(function(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,r=RegExp(s.source);return t&&r.test(t)?t.replace(s,(t=>e[t])):t}(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):"emoji"===t.type&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderClosingTag(s.tag))})),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map((t=>{if(t.constructor===String)return`<${t}${e}>`;{let s=`<${t.tag}`;if(t.attrs)for(const e in t.attrs){const r=t.attrs[e];null!==r&&(s+=` ${e}="${r}"`)}return`${s}${e}>`}})).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map((t=>t.constructor===String?`</${t}>`:`</${t.tag}>`)).join("")}getMatchingNode(t){const e=this.nodes[t.type];if("function"==typeof e)return e(t)}getMatchingMark(t){const e=this.marks[t.type];if("function"==typeof e)return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class c{constructor(){o(this,"isCDNUrl",((t="")=>t.indexOf("/cdn/")>-1)),o(this,"getOptionsPage",((t,e=25,s=1)=>({...t,per_page:e,page:s}))),o(this,"delay",(t=>new Promise((e=>setTimeout(e,t))))),o(this,"arrayFrom",((t=0,e)=>[...Array(t)].map(e))),o(this,"range",((t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,((e,s)=>s*r+t))})),o(this,"asyncMap",(async(t,e)=>Promise.all(t.map(e)))),o(this,"flatMap",((t=[],e)=>t.map(e).reduce(((t,e)=>[...t,...e]),[])))}stringify(t,e,s){const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const i=t[o],n=s?"":encodeURIComponent(o);let a;a="object"==typeof i?this.stringify(i,e?e+encodeURIComponent("["+n+"]"):n,Array.isArray(i)):(e?e+encodeURIComponent("["+n+"]"):n)+"="+encodeURIComponent(i),r.push(a)}return r.join("&")}getRegionURL(t){switch(t){case"us":return"api-us.storyblok.com";case"cn":return"app.storyblokchina.cn";default:return"api.storyblok.com"}}}class h{constructor(t){o(this,"baseURL"),o(this,"timeout"),o(this,"headers"),o(this,"responseInterceptor"),o(this,"fetch"),o(this,"ejectInterceptor"),o(this,"url"),o(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=null!=t&&t.timeout?1e3*t.timeout:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};204!==t.status&&await t.json().then((t=>{s.data=t}));for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if("get"===t){const t=new c;e=`${this.baseURL}${this.url}?${t.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),o=new AbortController,{signal:i}=o;let n;this.timeout&&(n=setTimeout((()=>o.abort()),this.timeout));try{const e=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:i});this.timeout&&clearTimeout(n);const o=await this._responseHandler(e);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(o)):this._statusHandler(o)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise(((s,r)=>{if(e.test(`${t.status}`))return s(t);r({message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug})}))}}let u={};const p={};class d{constructor(t,e){o(this,"client"),o(this,"maxRetries"),o(this,"throttle"),o(this,"accessToken"),o(this,"cache"),o(this,"helpers"),o(this,"resolveCounter"),o(this,"relations"),o(this,"links"),o(this,"richTextResolver"),o(this,"resolveNestedRelations");let s=t.endpoint||e;if(!s){const e=(new c).getRegionURL,r=!1===t.https?"http":"https";s=t.oauthToken?`${r}://${e(t.region)}/v1`:`${r}://${e(t.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),r.forEach(((e,s)=>{t.headers&&t.headers[s]&&r.set(s,t.headers[s])}));let n=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),n=3),t.rateLimit&&(n=t.rateLimit),t.richTextSchema?this.richTextResolver=new l(t.richTextSchema):this.richTextResolver=new l,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=function(t,e,s){if(!i(e))throw new TypeError("Expected `limit` to be a finite number");if(!i(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let o=[],n=0;const a=function(){n++;const e=setTimeout((function(){n--,r.length>0&&a(),o=o.filter((function(t){return t!==e}))}),s);o.indexOf(e)<0&&o.push(e);const i=r.shift();i.resolve(t.apply(i.self,i.args))},l=function(...t){const s=this;return new Promise((function(o,i){r.push({resolve:o,reject:i,args:t,self:s}),n<e&&a()}))};return l.abort=function(){o.forEach(clearTimeout),o=[],r.forEach((function(t){t.reject((function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"}))})),r.length=0},l}(this.throttledRequest,n,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new c,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new h({baseURL:s,timeout:t.timeout||0,headers:r,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",(e=>{let s="";return e.attrs.body&&e.attrs.body.forEach((e=>{s+=t(e.component,e)})),{html:s}}))}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=p[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const o=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,o)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(null==e?void 0:e.per_page)||25,o=`/${t}`,i=o.split("/"),n=s||i[i.length-1],a=await this.makeRequest(o,e,r,1),l=a.total?Math.ceil(a.total/r):1,c=await this.helpers.asyncMap(this.helpers.range(1,l),(t=>this.makeRequest(o,e,r,t+1)));return this.helpers.flatMap([a,...c],(t=>Object.values(t.data[n])))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1)if("string"==typeof t[e])this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const s=[];t[e].forEach((t=>{this.relations[r][t]&&s.push(this._cleanCopy(this.relations[r][t]))})),t[e]=s}}iterateTree(t,e,s){const r=t=>{if(null!=t)if(t.constructor===Array)for(let e=0;e<t.length;e++)r(t[e]);else if(t.constructor===Object){if(t._stopResolving)return;for(const o in t)(t.component&&t._uid||"link"===t.type)&&(this._insertRelations(t,o,e,s),this._insertLinks(t,o,s)),r(t[o])}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const s=t.link_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.link_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.links;r.forEach((t=>{this.links[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const s=t.rel_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.rel_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.rels;r&&r.length>0&&r.forEach((t=>{this.relations[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveStories(t,e,s){var r,o;let i=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&("string"==typeof e.resolve_relations&&(i=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&(null!=(r=t.links)&&r.length||null!=(o=t.link_uuids)&&o.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const n in this.relations[s])this.iterateTree(this.relations[s][n],i,s);t.story?this.iterateTree(t.story,i,s):t.stories.forEach((t=>{this.iterateTree(t,i,s)})),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),o=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===e.version&&await this.flushCache(),"published"===e.version&&"/cdn/spaces/me"!=t){const t=await o.get(r);if(t)return Promise.resolve(t)}return new Promise(((s,i)=>{try{(async()=>{var n;try{const a=await this.throttle("get",t,e);let l={data:a.data,headers:a.headers};if(null!=(n=a.headers)&&n["per-page"]&&(l=Object.assign({},l,{perPage:a.headers["per-page"]?parseInt(a.headers["per-page"]):0,total:a.headers["per-page"]?parseInt(a.headers.total):0})),200!=a.status)return i(a);if(l.data.story||l.data.stories){const t=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(l.data,e,`${t}`)}return"published"===e.version&&"/cdn/spaces/me"!=t&&await o.set(r,l),l.data.cv&&e.token&&("draft"==e.version&&p[e.token]!=l.data.cv&&await this.flushCache(),p[e.token]=l.data.cv),s(l)}catch(a){return i(a)}})()}catch{}}))}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(t){this.accessToken&&(p[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get:t=>Promise.resolve(u[t]),getAll:()=>Promise.resolve(u),set:(t,e)=>(u[t]=e,Promise.resolve(void 0)),flush:()=>(u={},Promise.resolve(void 0))};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get:()=>Promise.resolve(void 0),getAll:()=>Promise.resolve(void 0),set:()=>Promise.resolve(void 0),flush:()=>Promise.resolve(void 0)}}}async flushCache(){return await this.cacheProvider().flush(),this}}let g;const f="https://app.storyblok.com/f/storyblok-v2-latest.js",m=(t,e)=>{t.addNode("blok",(t=>{let s="";return t.attrs.body.forEach((t=>{s+=e(t.component,t)})),{html:s}}))};exports.ce=(t={})=>{const{apiOptions:e}=t;if(e.accessToken)return{storyblokApi:new d(e)};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")},exports.de=(t,e,s)=>{let r=s||g;if(r)return(t=>{var e,s;return!t||"blok"!==(null==(e=null==t?void 0:t.content)?void 0:e[0].type)&&!(null!=(s=null==t?void 0:t.content)&&s[0].content)})(t)?"":(e&&(r=new l(e.schema),e.resolver&&m(r,e.resolver)),r.render(t));console.error("Please initialize the Storyblok SDK before calling the renderRichText function")},exports.ge=()=>s(f),exports.he=t=>{if("object"!=typeof t||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}},exports.ie=a,exports.pe=(t={})=>{var e,r;const{bridge:o,accessToken:i,use:n=[],apiOptions:a={},richText:c={}}=t;a.accessToken=a.accessToken||i;const h={bridge:o,apiOptions:a};let u={};n.forEach((t=>{u={...u,...t(h)}}));const p=!(typeof window>"u")&&(null==(r=null==(e=window.location)?void 0:e.search)?void 0:r.includes("_storyblok_tk"));return!1!==o&&p&&s(f),g=new l(c.schema),c.resolver&&m(g,c.resolver),u},exports.ue=(t,e,s={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL(null==(r=window.location)?void 0:r.href).searchParams.get("_storyblok")===t;if(o&&i){if(!t)return void console.warn("Story ID is not defined. Please provide a valid ID.");window.storyblokRegisterEvent((()=>{new window.StoryblokBridge(s).on(["input","published","change"],(s=>{"input"===s.action&&s.story.id===t?e(s.story):("change"===s.action||"published"===s.action)&&s.storyId===t&&window.location.reload()}))}))}},exports.y=l;
|
|
1
|
+
"use strict";let t=!1;const e=[],s=s=>new Promise(((r,o)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{window.location!==window.parent.location?t?s():e.push(s):console.warn("You are not in Draft Mode or in the Visual Editor.")},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=s,i.id="storyblok-javascript-bridge",i.onerror=t=>o(t),i.onload=s=>{e.forEach((t=>t())),t=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(i)}));var r=Object.defineProperty,o=(t,e,s)=>(((t,e,s)=>{e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);function i(t){return!(t!=t||t===1/0||t===-1/0)}const n=function(t,e){const s={};for(const r in t){const o=t[r];e.indexOf(r)>-1&&null!==o&&(s[r]=o)}return s},a={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:t=>({tag:`h${t.attrs.level}`}),image:t=>({singleTag:[{tag:"img",attrs:n(t.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:t=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":t.attrs.name,emoji:t.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:t=>{const e={...t.attrs},{linktype:s="url"}=t.attrs;if((t=>"email"===t)(s)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const t in e.custom)e[t]=e.custom[t];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:t=>({tag:[{tag:"span",attrs:t.attrs}]}),highlight:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${t.attrs.color};`}}]}:{tag:""}},textStyle:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`color:${t.attrs.color}`}}]}:{tag:""}}}};class l{constructor(t){o(this,"marks"),o(this,"nodes"),t||(t=a),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach((t=>{s+=this.renderNode(t)})),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn("The render method must receive an Object with a \"content\" field.\n\t\t\tThe \"content\" field must be an array of nodes as the type ISbRichtext.\n\t\t\tISbRichtext:\n\t\t\t\tcontent?: ISbRichtext[]\n\t\t\t\tmarks?: ISbRichtext[]\n\t\t\t\tattrs?: any\n\t\t\t\ttext?: string\n\t\t\t\ttype: string\n\t\t\t\t\n\t\t\t\tExample:\n\t\t\t\t{\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttext: 'Hello World',\n\t\t\t\t\t\t\t\t\ttype: 'text'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\ttype: 'paragraph'\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\ttype: 'doc'\n\t\t\t\t}"),""}optimizeImages(t,e){let s=0,r=0,o="",i="";"boolean"!=typeof e&&("number"==typeof e.width&&e.width>0&&(o+=`width="${e.width}" `,s=e.width),"number"==typeof e.height&&e.height>0&&(o+=`height="${e.height}" `,r=e.height),("lazy"===e.loading||"eager"===e.loading)&&(o+=`loading="${e.loading}" `),"string"==typeof e.class&&e.class.length>0&&(o+=`class="${e.class}" `),e.filters&&("number"==typeof e.filters.blur&&e.filters.blur>=0&&e.filters.blur<=100&&(i+=`:blur(${e.filters.blur})`),"number"==typeof e.filters.brightness&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(i+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||"transparent"===e.filters.fill)&&(i+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(i+=`:format(${e.filters.format})`),"boolean"==typeof e.filters.grayscale&&e.filters.grayscale&&(i+=":grayscale()"),"number"==typeof e.filters.quality&&e.filters.quality>=0&&e.filters.quality<=100&&(i+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(i+=`:rotate(${e.filters.rotate})`),i.length>0&&(i="/filters"+i))),o.length>0&&(t=t.replace(/<img/g,`<img ${o.trim()}`));const n=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${n}`),"boolean"!=typeof e&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,(t=>{var s,r;const o=t.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(o&&o.length>0){const n={srcset:null==(s=e.srcset)?void 0:s.map((t=>{if("number"==typeof t)return`//${o}/m/${t}x0${i} ${t}w`;if("object"==typeof t&&2===t.length){let e=0,s=0;return"number"==typeof t[0]&&(e=t[0]),"number"==typeof t[1]&&(s=t[1]),`//${o}/m/${e}x${s}${i} ${e}w`}})).join(", "),sizes:null==(r=e.sizes)?void 0:r.map((t=>t)).join(", ")};let a="";return n.srcset&&(a+=`srcset="${n.srcset}" `),n.sizes&&(a+=`sizes="${n.sizes}" `),t.replace(/<img/g,`<img ${a.trim()}`)}return t}))),t}renderNode(t){const e=[];t.marks&&t.marks.forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderOpeningTag(s.tag))}));const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach((t=>{e.push(this.renderNode(t))})):t.text?e.push(function(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,r=RegExp(s.source);return t&&r.test(t)?t.replace(s,(t=>e[t])):t}(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):"emoji"===t.type&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderClosingTag(s.tag))})),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map((t=>{if(t.constructor===String)return`<${t}${e}>`;{let s=`<${t.tag}`;if(t.attrs)for(const e in t.attrs){const r=t.attrs[e];null!==r&&(s+=` ${e}="${r}"`)}return`${s}${e}>`}})).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map((t=>t.constructor===String?`</${t}>`:`</${t.tag}>`)).join("")}getMatchingNode(t){const e=this.nodes[t.type];if("function"==typeof e)return e(t)}getMatchingMark(t){const e=this.marks[t.type];if("function"==typeof e)return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class c{constructor(){o(this,"isCDNUrl",((t="")=>t.indexOf("/cdn/")>-1)),o(this,"getOptionsPage",((t,e=25,s=1)=>({...t,per_page:e,page:s}))),o(this,"delay",(t=>new Promise((e=>setTimeout(e,t))))),o(this,"arrayFrom",((t=0,e)=>[...Array(t)].map(e))),o(this,"range",((t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,((e,s)=>s*r+t))})),o(this,"asyncMap",(async(t,e)=>Promise.all(t.map(e)))),o(this,"flatMap",((t=[],e)=>t.map(e).reduce(((t,e)=>[...t,...e]),[])))}stringify(t,e,s){const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const i=t[o],n=s?"":encodeURIComponent(o);let a;a="object"==typeof i?this.stringify(i,e?e+encodeURIComponent("["+n+"]"):n,Array.isArray(i)):(e?e+encodeURIComponent("["+n+"]"):n)+"="+encodeURIComponent(i),r.push(a)}return r.join("&")}getRegionURL(t){switch(t){case"us":return"api-us.storyblok.com";case"cn":return"app.storyblokchina.cn";default:return"api.storyblok.com"}}}class h{constructor(t){o(this,"baseURL"),o(this,"timeout"),o(this,"headers"),o(this,"responseInterceptor"),o(this,"fetch"),o(this,"ejectInterceptor"),o(this,"url"),o(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=null!=t&&t.timeout?1e3*t.timeout:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};204!==t.status&&await t.json().then((t=>{s.data=t}));for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if("get"===t){const t=new c;e=`${this.baseURL}${this.url}?${t.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),o=new AbortController,{signal:i}=o;let n;this.timeout&&(n=setTimeout((()=>o.abort()),this.timeout));try{const e=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:i});this.timeout&&clearTimeout(n);const o=await this._responseHandler(e);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(o)):this._statusHandler(o)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise(((s,r)=>{if(e.test(`${t.status}`))return s(t);r({message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug})}))}}const u="SB-Agent",p="SB-JS-CLIENT",d="SB-Agent-Version",g="2.2.3";let f={};const m={};class y{constructor(t,e){o(this,"client"),o(this,"maxRetries"),o(this,"throttle"),o(this,"accessToken"),o(this,"cache"),o(this,"helpers"),o(this,"resolveCounter"),o(this,"relations"),o(this,"links"),o(this,"richTextResolver"),o(this,"resolveNestedRelations");let s=t.endpoint||e;if(!s){const e=(new c).getRegionURL,r=!1===t.https?"http":"https";s=t.oauthToken?`${r}://${e(t.region)}/v1`:`${r}://${e(t.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),t.headers)for(const o in t.headers)r.set(o,t.headers[o]);r.has(u)||(r.set(u,p),r.set(d,g));let n=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),n=3),t.rateLimit&&(n=t.rateLimit),t.richTextSchema?this.richTextResolver=new l(t.richTextSchema):this.richTextResolver=new l,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=function(t,e,s){if(!i(e))throw new TypeError("Expected `limit` to be a finite number");if(!i(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let o=[],n=0;const a=function(){n++;const e=setTimeout((function(){n--,r.length>0&&a(),o=o.filter((function(t){return t!==e}))}),s);o.indexOf(e)<0&&o.push(e);const i=r.shift();i.resolve(t.apply(i.self,i.args))},l=function(...t){const s=this;return new Promise((function(o,i){r.push({resolve:o,reject:i,args:t,self:s}),n<e&&a()}))};return l.abort=function(){o.forEach(clearTimeout),o=[],r.forEach((function(t){t.reject((function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"}))})),r.length=0},l}(this.throttledRequest,n,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new c,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new h({baseURL:s,timeout:t.timeout||0,headers:r,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",(e=>{let s="";return e.attrs.body&&e.attrs.body.forEach((e=>{s+=t(e.component,e)})),{html:s}}))}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=m[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const o=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,o)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(null==e?void 0:e.per_page)||25,o=`/${t}`,i=o.split("/"),n=s||i[i.length-1],a=await this.makeRequest(o,e,r,1),l=a.total?Math.ceil(a.total/r):1,c=await this.helpers.asyncMap(this.helpers.range(1,l),(t=>this.makeRequest(o,e,r,t+1)));return this.helpers.flatMap([a,...c],(t=>Object.values(t.data[n])))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1)if("string"==typeof t[e])this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const s=[];t[e].forEach((t=>{this.relations[r][t]&&s.push(this._cleanCopy(this.relations[r][t]))})),t[e]=s}}iterateTree(t,e,s){const r=t=>{if(null!=t)if(t.constructor===Array)for(let e=0;e<t.length;e++)r(t[e]);else if(t.constructor===Object){if(t._stopResolving)return;for(const o in t)(t.component&&t._uid||"link"===t.type)&&(this._insertRelations(t,o,e,s),this._insertLinks(t,o,s)),r(t[o])}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const s=t.link_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.link_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.links;r.forEach((t=>{this.links[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const s=t.rel_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.rel_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.rels;r&&r.length>0&&r.forEach((t=>{this.relations[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveStories(t,e,s){var r,o;let i=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&("string"==typeof e.resolve_relations&&(i=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&(null!=(r=t.links)&&r.length||null!=(o=t.link_uuids)&&o.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const n in this.relations[s])this.iterateTree(this.relations[s][n],i,s);t.story?this.iterateTree(t.story,i,s):t.stories.forEach((t=>{this.iterateTree(t,i,s)})),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),o=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===e.version&&await this.flushCache(),"published"===e.version&&"/cdn/spaces/me"!=t){const t=await o.get(r);if(t)return Promise.resolve(t)}return new Promise(((s,i)=>{try{(async()=>{var n;try{const a=await this.throttle("get",t,e);let l={data:a.data,headers:a.headers};if(null!=(n=a.headers)&&n["per-page"]&&(l=Object.assign({},l,{perPage:a.headers["per-page"]?parseInt(a.headers["per-page"]):0,total:a.headers["per-page"]?parseInt(a.headers.total):0})),200!=a.status)return i(a);if(l.data.story||l.data.stories){const t=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(l.data,e,`${t}`)}return"published"===e.version&&"/cdn/spaces/me"!=t&&await o.set(r,l),l.data.cv&&e.token&&("draft"==e.version&&m[e.token]!=l.data.cv&&await this.flushCache(),m[e.token]=l.data.cv),s(l)}catch(a){return i(a)}})()}catch{}}))}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(t){this.accessToken&&(m[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get:t=>Promise.resolve(f[t]),getAll:()=>Promise.resolve(f),set:(t,e)=>(f[t]=e,Promise.resolve(void 0)),flush:()=>(f={},Promise.resolve(void 0))};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get:()=>Promise.resolve(void 0),getAll:()=>Promise.resolve(void 0),set:()=>Promise.resolve(void 0),flush:()=>Promise.resolve(void 0)}}}async flushCache(){return await this.cacheProvider().flush(),this}}let b;const v="https://app.storyblok.com/f/storyblok-v2-latest.js",k=(t,e)=>{t.addNode("blok",(t=>{let s="";return t.attrs.body.forEach((t=>{s+=e(t.component,t)})),{html:s}}))};exports._e=(t,e,s)=>{let r=s||b;if(r)return(t=>{var e,s;return!t||"blok"!==(null==(e=null==t?void 0:t.content)?void 0:e[0].type)&&!(null!=(s=null==t?void 0:t.content)&&s[0].content)})(t)?"":(e&&(r=new l(e.schema),e.resolver&&k(r,e.resolver)),r.render(t));console.error("Please initialize the Storyblok SDK before calling the renderRichText function")},exports.b=l,exports.de=t=>{if("object"!=typeof t||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}},exports.ge=()=>s(v),exports.ie=a,exports.me=(t={})=>{var e,r;const{bridge:o,accessToken:i,use:n=[],apiOptions:a={},richText:c={}}=t;a.accessToken=a.accessToken||i;const h={bridge:o,apiOptions:a};let u={};n.forEach((t=>{u={...u,...t(h)}}));const p=!(typeof window>"u")&&(null==(r=null==(e=window.location)?void 0:e.search)?void 0:r.includes("_storyblok_tk"));return!1!==o&&p&&s(v),b=new l(c.schema),c.resolver&&k(b,c.resolver),u},exports.pe=(t,e,s={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL(null==(r=window.location)?void 0:r.href).searchParams.get("_storyblok")===t;if(o&&i){if(!t)return void console.warn("Story ID is not defined. Please provide a valid ID.");window.storyblokRegisterEvent((()=>{new window.StoryblokBridge(s).on(["input","published","change"],(s=>{"input"===s.action&&s.story.id===t?e(s.story):("change"===s.action||"published"===s.action)&&s.storyId===t&&window.location.reload()}))}))}},exports.ue=(t={})=>{const{apiOptions:e}=t;if(e.accessToken)return{storyblokApi:new y(e)};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")};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
1
|
+
let I = false;
|
|
2
|
+
const O = [], A = (n) => new Promise((e, t) => {
|
|
3
3
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
4
4
|
if (window.location === window.parent.location) {
|
|
5
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
I ? r() : O.push(r);
|
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
10
10
|
return;
|
|
11
11
|
const s = document.createElement("script");
|
|
12
12
|
s.async = true, s.src = n, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
|
13
|
-
|
|
13
|
+
O.forEach((o) => o()), I = true, e(r);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
17
|
-
function
|
|
16
|
+
var j = Object.defineProperty, U = (n, e, t) => e in n ? j(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t, h = (n, e, t) => (U(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
17
|
+
function v(n) {
|
|
18
18
|
return !(n !== n || n === 1 / 0 || n === -1 / 0);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
if (!
|
|
20
|
+
function H(n, e, t) {
|
|
21
|
+
if (!v(e))
|
|
22
22
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
-
if (!
|
|
23
|
+
if (!v(t))
|
|
24
24
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
25
|
const s = [];
|
|
26
|
-
let r = [],
|
|
27
|
-
const
|
|
28
|
-
|
|
26
|
+
let r = [], o = 0;
|
|
27
|
+
const i = function() {
|
|
28
|
+
o++;
|
|
29
29
|
const a = setTimeout(function() {
|
|
30
|
-
|
|
30
|
+
o--, s.length > 0 && i(), r = r.filter(function(u) {
|
|
31
31
|
return u !== a;
|
|
32
32
|
});
|
|
33
33
|
}, t);
|
|
@@ -36,13 +36,13 @@ function S(n, e, t) {
|
|
|
36
36
|
l.resolve(n.apply(l.self, l.args));
|
|
37
37
|
}, c = function(...a) {
|
|
38
38
|
const l = this;
|
|
39
|
-
return new Promise(function(u,
|
|
39
|
+
return new Promise(function(u, d) {
|
|
40
40
|
s.push({
|
|
41
41
|
resolve: u,
|
|
42
|
-
reject:
|
|
42
|
+
reject: d,
|
|
43
43
|
args: a,
|
|
44
44
|
self: l
|
|
45
|
-
}),
|
|
45
|
+
}), o < e && i();
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
return c.abort = function() {
|
|
@@ -53,20 +53,20 @@ function S(n, e, t) {
|
|
|
53
53
|
}), s.length = 0;
|
|
54
54
|
}, c;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const P = function(n, e) {
|
|
57
57
|
const t = {};
|
|
58
58
|
for (const s in n) {
|
|
59
59
|
const r = n[s];
|
|
60
60
|
e.indexOf(s) > -1 && r !== null && (t[s] = r);
|
|
61
61
|
}
|
|
62
62
|
return t;
|
|
63
|
-
},
|
|
63
|
+
}, x = (n) => n === "email", C = () => ({
|
|
64
64
|
singleTag: "hr"
|
|
65
|
-
}),
|
|
65
|
+
}), G = () => ({
|
|
66
66
|
tag: "blockquote"
|
|
67
|
-
}),
|
|
67
|
+
}), $ = () => ({
|
|
68
68
|
tag: "ul"
|
|
69
|
-
}),
|
|
69
|
+
}), B = (n) => ({
|
|
70
70
|
tag: [
|
|
71
71
|
"pre",
|
|
72
72
|
{
|
|
@@ -74,24 +74,24 @@ const C = function(n, e) {
|
|
|
74
74
|
attrs: n.attrs
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
|
-
}),
|
|
77
|
+
}), D = () => ({
|
|
78
78
|
singleTag: "br"
|
|
79
|
-
}),
|
|
79
|
+
}), M = (n) => ({
|
|
80
80
|
tag: `h${n.attrs.level}`
|
|
81
|
-
}),
|
|
81
|
+
}), L = (n) => ({
|
|
82
82
|
singleTag: [
|
|
83
83
|
{
|
|
84
84
|
tag: "img",
|
|
85
|
-
attrs:
|
|
85
|
+
attrs: P(n.attrs, ["src", "alt", "title"])
|
|
86
86
|
}
|
|
87
87
|
]
|
|
88
|
-
}),
|
|
88
|
+
}), V = () => ({
|
|
89
89
|
tag: "li"
|
|
90
|
-
}),
|
|
90
|
+
}), F = () => ({
|
|
91
91
|
tag: "ol"
|
|
92
|
-
}),
|
|
92
|
+
}), W = () => ({
|
|
93
93
|
tag: "p"
|
|
94
|
-
}),
|
|
94
|
+
}), K = (n) => ({
|
|
95
95
|
tag: [
|
|
96
96
|
{
|
|
97
97
|
tag: "span",
|
|
@@ -102,21 +102,21 @@ const C = function(n, e) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
]
|
|
105
|
-
}),
|
|
105
|
+
}), q = () => ({
|
|
106
106
|
tag: "b"
|
|
107
|
-
}),
|
|
107
|
+
}), z = () => ({
|
|
108
108
|
tag: "strike"
|
|
109
|
-
}),
|
|
109
|
+
}), X = () => ({
|
|
110
110
|
tag: "u"
|
|
111
|
-
}),
|
|
111
|
+
}), Y = () => ({
|
|
112
112
|
tag: "strong"
|
|
113
|
-
}),
|
|
113
|
+
}), J = () => ({
|
|
114
114
|
tag: "code"
|
|
115
|
-
}),
|
|
115
|
+
}), Z = () => ({
|
|
116
116
|
tag: "i"
|
|
117
117
|
}), Q = (n) => {
|
|
118
118
|
const e = { ...n.attrs }, { linktype: t = "url" } = n.attrs;
|
|
119
|
-
if (
|
|
119
|
+
if (x(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
|
|
120
120
|
for (const s in e.custom)
|
|
121
121
|
e[s] = e.custom[s];
|
|
122
122
|
delete e.custom;
|
|
@@ -129,25 +129,25 @@ const C = function(n, e) {
|
|
|
129
129
|
}
|
|
130
130
|
]
|
|
131
131
|
};
|
|
132
|
-
},
|
|
132
|
+
}, ee = (n) => ({
|
|
133
133
|
tag: [
|
|
134
134
|
{
|
|
135
135
|
tag: "span",
|
|
136
136
|
attrs: n.attrs
|
|
137
137
|
}
|
|
138
138
|
]
|
|
139
|
-
}),
|
|
139
|
+
}), te = () => ({
|
|
140
140
|
tag: "sub"
|
|
141
|
-
}),
|
|
141
|
+
}), se = () => ({
|
|
142
142
|
tag: "sup"
|
|
143
|
-
}),
|
|
143
|
+
}), re = (n) => ({
|
|
144
144
|
tag: [
|
|
145
145
|
{
|
|
146
146
|
tag: "span",
|
|
147
147
|
attrs: n.attrs
|
|
148
148
|
}
|
|
149
149
|
]
|
|
150
|
-
}),
|
|
150
|
+
}), oe = (n) => {
|
|
151
151
|
var e;
|
|
152
152
|
return (e = n.attrs) != null && e.color ? {
|
|
153
153
|
tag: [
|
|
@@ -161,7 +161,7 @@ const C = function(n, e) {
|
|
|
161
161
|
} : {
|
|
162
162
|
tag: ""
|
|
163
163
|
};
|
|
164
|
-
},
|
|
164
|
+
}, ne = (n) => {
|
|
165
165
|
var e;
|
|
166
166
|
return (e = n.attrs) != null && e.color ? {
|
|
167
167
|
tag: [
|
|
@@ -177,34 +177,34 @@ const C = function(n, e) {
|
|
|
177
177
|
};
|
|
178
178
|
}, ie = {
|
|
179
179
|
nodes: {
|
|
180
|
-
horizontal_rule:
|
|
181
|
-
blockquote:
|
|
182
|
-
bullet_list:
|
|
183
|
-
code_block:
|
|
184
|
-
hard_break:
|
|
185
|
-
heading:
|
|
186
|
-
image:
|
|
187
|
-
list_item:
|
|
188
|
-
ordered_list:
|
|
189
|
-
paragraph:
|
|
190
|
-
emoji:
|
|
180
|
+
horizontal_rule: C,
|
|
181
|
+
blockquote: G,
|
|
182
|
+
bullet_list: $,
|
|
183
|
+
code_block: B,
|
|
184
|
+
hard_break: D,
|
|
185
|
+
heading: M,
|
|
186
|
+
image: L,
|
|
187
|
+
list_item: V,
|
|
188
|
+
ordered_list: F,
|
|
189
|
+
paragraph: W,
|
|
190
|
+
emoji: K
|
|
191
191
|
},
|
|
192
192
|
marks: {
|
|
193
|
-
bold:
|
|
194
|
-
strike:
|
|
195
|
-
underline:
|
|
196
|
-
strong:
|
|
197
|
-
code:
|
|
198
|
-
italic:
|
|
193
|
+
bold: q,
|
|
194
|
+
strike: z,
|
|
195
|
+
underline: X,
|
|
196
|
+
strong: Y,
|
|
197
|
+
code: J,
|
|
198
|
+
italic: Z,
|
|
199
199
|
link: Q,
|
|
200
|
-
styled:
|
|
201
|
-
subscript:
|
|
202
|
-
superscript:
|
|
203
|
-
anchor:
|
|
204
|
-
highlight:
|
|
205
|
-
textStyle:
|
|
206
|
-
}
|
|
207
|
-
},
|
|
200
|
+
styled: ee,
|
|
201
|
+
subscript: te,
|
|
202
|
+
superscript: se,
|
|
203
|
+
anchor: re,
|
|
204
|
+
highlight: oe,
|
|
205
|
+
textStyle: ne
|
|
206
|
+
}
|
|
207
|
+
}, ae = function(n) {
|
|
208
208
|
const e = {
|
|
209
209
|
"&": "&",
|
|
210
210
|
"<": "<",
|
|
@@ -214,7 +214,7 @@ const C = function(n, e) {
|
|
|
214
214
|
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
215
215
|
return n && s.test(n) ? n.replace(t, (r) => e[r]) : n;
|
|
216
216
|
};
|
|
217
|
-
class
|
|
217
|
+
class b {
|
|
218
218
|
constructor(e) {
|
|
219
219
|
h(this, "marks"), h(this, "nodes"), e || (e = ie), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
220
220
|
}
|
|
@@ -259,31 +259,31 @@ class y {
|
|
|
259
259
|
), "";
|
|
260
260
|
}
|
|
261
261
|
optimizeImages(e, t) {
|
|
262
|
-
let s = 0, r = 0,
|
|
263
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
|
264
|
-
const c = s > 0 || r > 0 ||
|
|
262
|
+
let s = 0, r = 0, o = "", i = "";
|
|
263
|
+
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 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
|
|
264
|
+
const c = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
|
|
265
265
|
return e = e.replace(
|
|
266
266
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
267
267
|
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
|
268
268
|
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
269
269
|
var l, u;
|
|
270
|
-
const
|
|
270
|
+
const d = a.match(
|
|
271
271
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
272
272
|
);
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
srcset: (l = t.srcset) == null ? void 0 : l.map((
|
|
276
|
-
if (typeof
|
|
277
|
-
return `//${
|
|
278
|
-
if (typeof
|
|
279
|
-
let
|
|
280
|
-
return typeof
|
|
273
|
+
if (d && d.length > 0) {
|
|
274
|
+
const m = {
|
|
275
|
+
srcset: (l = t.srcset) == null ? void 0 : l.map((p) => {
|
|
276
|
+
if (typeof p == "number")
|
|
277
|
+
return `//${d}/m/${p}x0${i} ${p}w`;
|
|
278
|
+
if (typeof p == "object" && p.length === 2) {
|
|
279
|
+
let T = 0, E = 0;
|
|
280
|
+
return typeof p[0] == "number" && (T = p[0]), typeof p[1] == "number" && (E = p[1]), `//${d}/m/${T}x${E}${i} ${T}w`;
|
|
281
281
|
}
|
|
282
282
|
}).join(", "),
|
|
283
|
-
sizes: (u = t.sizes) == null ? void 0 : u.map((
|
|
283
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((p) => p).join(", ")
|
|
284
284
|
};
|
|
285
|
-
let
|
|
286
|
-
return
|
|
285
|
+
let f = "";
|
|
286
|
+
return m.srcset && (f += `srcset="${m.srcset}" `), m.sizes && (f += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
|
|
287
287
|
}
|
|
288
288
|
return a;
|
|
289
289
|
})), e;
|
|
@@ -291,15 +291,15 @@ class y {
|
|
|
291
291
|
renderNode(e) {
|
|
292
292
|
const t = [];
|
|
293
293
|
e.marks && e.marks.forEach((r) => {
|
|
294
|
-
const
|
|
295
|
-
|
|
294
|
+
const o = this.getMatchingMark(r);
|
|
295
|
+
o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
|
|
296
296
|
});
|
|
297
297
|
const s = this.getMatchingNode(e);
|
|
298
298
|
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
|
299
299
|
t.push(this.renderNode(r));
|
|
300
|
-
}) : e.text ? t.push(
|
|
301
|
-
const
|
|
302
|
-
|
|
300
|
+
}) : e.text ? t.push(ae(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) => {
|
|
301
|
+
const o = this.getMatchingMark(r);
|
|
302
|
+
o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
|
|
303
303
|
}), t.join("");
|
|
304
304
|
}
|
|
305
305
|
renderTag(e, t) {
|
|
@@ -309,9 +309,9 @@ class y {
|
|
|
309
309
|
{
|
|
310
310
|
let r = `<${s.tag}`;
|
|
311
311
|
if (s.attrs)
|
|
312
|
-
for (const
|
|
313
|
-
const
|
|
314
|
-
|
|
312
|
+
for (const o in s.attrs) {
|
|
313
|
+
const i = s.attrs[o];
|
|
314
|
+
i !== null && (r += ` ${o}="${i}"`);
|
|
315
315
|
}
|
|
316
316
|
return `${r}${t}>`;
|
|
317
317
|
}
|
|
@@ -358,7 +358,7 @@ class k {
|
|
|
358
358
|
page: s
|
|
359
359
|
})), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
|
|
360
360
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
361
|
-
return this.arrayFrom(s, (
|
|
361
|
+
return this.arrayFrom(s, (o, i) => i * r + e);
|
|
362
362
|
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []));
|
|
363
363
|
}
|
|
364
364
|
/**
|
|
@@ -370,16 +370,16 @@ class k {
|
|
|
370
370
|
*/
|
|
371
371
|
stringify(e, t, s) {
|
|
372
372
|
const r = [];
|
|
373
|
-
for (const
|
|
374
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
373
|
+
for (const o in e) {
|
|
374
|
+
if (!Object.prototype.hasOwnProperty.call(e, o))
|
|
375
375
|
continue;
|
|
376
|
-
const
|
|
376
|
+
const i = e[o], c = s ? "" : encodeURIComponent(o);
|
|
377
377
|
let a;
|
|
378
|
-
typeof
|
|
379
|
-
|
|
378
|
+
typeof i == "object" ? a = this.stringify(
|
|
379
|
+
i,
|
|
380
380
|
t ? t + encodeURIComponent("[" + c + "]") : c,
|
|
381
|
-
Array.isArray(
|
|
382
|
-
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(
|
|
381
|
+
Array.isArray(i)
|
|
382
|
+
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(i), r.push(a);
|
|
383
383
|
}
|
|
384
384
|
return r.join("&");
|
|
385
385
|
}
|
|
@@ -400,7 +400,7 @@ class k {
|
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
class
|
|
403
|
+
class le {
|
|
404
404
|
constructor(e) {
|
|
405
405
|
h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), 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 = false, this.url = "", this.parameters = {};
|
|
406
406
|
}
|
|
@@ -445,15 +445,15 @@ class oe {
|
|
|
445
445
|
)}`;
|
|
446
446
|
} else
|
|
447
447
|
s = JSON.stringify(this.parameters);
|
|
448
|
-
const r = new URL(t),
|
|
448
|
+
const r = new URL(t), o = new AbortController(), { signal: i } = o;
|
|
449
449
|
let c;
|
|
450
|
-
this.timeout && (c = setTimeout(() =>
|
|
450
|
+
this.timeout && (c = setTimeout(() => o.abort(), this.timeout));
|
|
451
451
|
try {
|
|
452
452
|
const a = await this.fetch(`${r}`, {
|
|
453
453
|
method: e,
|
|
454
454
|
headers: this.headers,
|
|
455
455
|
body: s,
|
|
456
|
-
signal:
|
|
456
|
+
signal: i
|
|
457
457
|
});
|
|
458
458
|
this.timeout && clearTimeout(c);
|
|
459
459
|
const l = await this._responseHandler(a);
|
|
@@ -472,18 +472,23 @@ class oe {
|
|
|
472
472
|
return new Promise((s, r) => {
|
|
473
473
|
if (t.test(`${e.status}`))
|
|
474
474
|
return s(e);
|
|
475
|
-
const
|
|
475
|
+
const o = {
|
|
476
476
|
message: new Error(e.statusText),
|
|
477
477
|
status: e.status,
|
|
478
478
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
479
479
|
};
|
|
480
|
-
r(
|
|
480
|
+
r(o);
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
const N = "SB-Agent", y = {
|
|
485
|
+
defaultAgentName: "SB-JS-CLIENT",
|
|
486
|
+
defaultAgentVersion: "SB-Agent-Version",
|
|
487
|
+
packageVersion: "2.2.3"
|
|
488
|
+
};
|
|
489
|
+
let g = {};
|
|
490
|
+
const _ = {};
|
|
491
|
+
class ce {
|
|
487
492
|
/**
|
|
488
493
|
*
|
|
489
494
|
* @param config ISbConfig interface
|
|
@@ -493,15 +498,16 @@ class ae {
|
|
|
493
498
|
h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations");
|
|
494
499
|
let s = e.endpoint || t;
|
|
495
500
|
if (!s) {
|
|
496
|
-
const
|
|
497
|
-
e.oauthToken ? s = `${c}://${
|
|
501
|
+
const i = new k().getRegionURL, c = e.https === false ? "http" : "https";
|
|
502
|
+
e.oauthToken ? s = `${c}://${i(e.region)}/v1` : s = `${c}://${i(e.region)}/v2`;
|
|
498
503
|
}
|
|
499
504
|
const r = new Headers();
|
|
500
|
-
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"),
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
+
if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
|
|
506
|
+
for (const i in e.headers)
|
|
507
|
+
r.set(i, e.headers[i]);
|
|
508
|
+
r.has(N) || (r.set(N, y.defaultAgentName), r.set(y.defaultAgentVersion, y.packageVersion));
|
|
509
|
+
let o = 5;
|
|
510
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new b(e.richTextSchema) : this.richTextResolver = new b(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = H(this.throttledRequest, o, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new k(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || true, this.client = new le({
|
|
505
511
|
baseURL: s,
|
|
506
512
|
timeout: e.timeout || 0,
|
|
507
513
|
headers: r,
|
|
@@ -520,17 +526,17 @@ class ae {
|
|
|
520
526
|
});
|
|
521
527
|
}
|
|
522
528
|
parseParams(e) {
|
|
523
|
-
return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
529
|
+
return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = _[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
|
|
524
530
|
}
|
|
525
531
|
factoryParamOptions(e, t) {
|
|
526
532
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
527
533
|
}
|
|
528
534
|
makeRequest(e, t, s, r) {
|
|
529
|
-
const
|
|
535
|
+
const o = this.factoryParamOptions(
|
|
530
536
|
e,
|
|
531
537
|
this.helpers.getOptionsPage(t, s, r)
|
|
532
538
|
);
|
|
533
|
-
return this.cacheResponse(e,
|
|
539
|
+
return this.cacheResponse(e, o);
|
|
534
540
|
}
|
|
535
541
|
get(e, t) {
|
|
536
542
|
t || (t = {});
|
|
@@ -538,13 +544,13 @@ class ae {
|
|
|
538
544
|
return this.cacheResponse(s, r);
|
|
539
545
|
}
|
|
540
546
|
async getAll(e, t, s) {
|
|
541
|
-
const r = (t == null ? void 0 : t.per_page) || 25,
|
|
547
|
+
const r = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`, i = o.split("/"), c = s || i[i.length - 1], a = 1, l = await this.makeRequest(o, t, r, a), u = l.total ? Math.ceil(l.total / r) : 1, d = await this.helpers.asyncMap(
|
|
542
548
|
this.helpers.range(a, u),
|
|
543
|
-
(
|
|
549
|
+
(m) => this.makeRequest(o, t, r, m + 1)
|
|
544
550
|
);
|
|
545
551
|
return this.helpers.flatMap(
|
|
546
|
-
[l, ...
|
|
547
|
-
(
|
|
552
|
+
[l, ...d],
|
|
553
|
+
(m) => Object.values(m.data[c])
|
|
548
554
|
);
|
|
549
555
|
}
|
|
550
556
|
post(e, t) {
|
|
@@ -585,33 +591,33 @@ class ae {
|
|
|
585
591
|
this.relations[r][e[t]]
|
|
586
592
|
));
|
|
587
593
|
else if (e[t] && e[t].constructor === Array) {
|
|
588
|
-
const
|
|
589
|
-
e[t].forEach((
|
|
590
|
-
this.relations[r][
|
|
591
|
-
}), e[t] =
|
|
594
|
+
const o = [];
|
|
595
|
+
e[t].forEach((i) => {
|
|
596
|
+
this.relations[r][i] && o.push(this._cleanCopy(this.relations[r][i]));
|
|
597
|
+
}), e[t] = o;
|
|
592
598
|
}
|
|
593
599
|
}
|
|
594
600
|
}
|
|
595
601
|
iterateTree(e, t, s) {
|
|
596
|
-
const r = (
|
|
597
|
-
if (
|
|
598
|
-
if (
|
|
599
|
-
for (let
|
|
600
|
-
r(i
|
|
601
|
-
else if (
|
|
602
|
-
if (
|
|
602
|
+
const r = (o) => {
|
|
603
|
+
if (o != null) {
|
|
604
|
+
if (o.constructor === Array)
|
|
605
|
+
for (let i = 0; i < o.length; i++)
|
|
606
|
+
r(o[i]);
|
|
607
|
+
else if (o.constructor === Object) {
|
|
608
|
+
if (o._stopResolving)
|
|
603
609
|
return;
|
|
604
|
-
for (const
|
|
605
|
-
(
|
|
606
|
-
i,
|
|
610
|
+
for (const i in o)
|
|
611
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(
|
|
607
612
|
o,
|
|
613
|
+
i,
|
|
608
614
|
t,
|
|
609
615
|
s
|
|
610
616
|
), this._insertLinks(
|
|
611
|
-
i,
|
|
612
617
|
o,
|
|
618
|
+
i,
|
|
613
619
|
s
|
|
614
|
-
)), r(i
|
|
620
|
+
)), r(o[i]);
|
|
615
621
|
}
|
|
616
622
|
}
|
|
617
623
|
};
|
|
@@ -620,17 +626,17 @@ class ae {
|
|
|
620
626
|
async resolveLinks(e, t, s) {
|
|
621
627
|
let r = [];
|
|
622
628
|
if (e.link_uuids) {
|
|
623
|
-
const
|
|
624
|
-
for (let a = 0; a <
|
|
625
|
-
const l = Math.min(
|
|
626
|
-
|
|
629
|
+
const o = e.link_uuids.length, i = [], c = 50;
|
|
630
|
+
for (let a = 0; a < o; a += c) {
|
|
631
|
+
const l = Math.min(o, a + c);
|
|
632
|
+
i.push(e.link_uuids.slice(a, l));
|
|
627
633
|
}
|
|
628
|
-
for (let a = 0; a <
|
|
634
|
+
for (let a = 0; a < i.length; a++)
|
|
629
635
|
(await this.getStories({
|
|
630
636
|
per_page: c,
|
|
631
637
|
language: t.language,
|
|
632
638
|
version: t.version,
|
|
633
|
-
by_uuids:
|
|
639
|
+
by_uuids: i[a].join(",")
|
|
634
640
|
})).data.stories.forEach(
|
|
635
641
|
(l) => {
|
|
636
642
|
r.push(l);
|
|
@@ -638,9 +644,9 @@ class ae {
|
|
|
638
644
|
);
|
|
639
645
|
} else
|
|
640
646
|
r = e.links;
|
|
641
|
-
r.forEach((
|
|
642
|
-
this.links[s][
|
|
643
|
-
...
|
|
647
|
+
r.forEach((o) => {
|
|
648
|
+
this.links[s][o.uuid] = {
|
|
649
|
+
...o,
|
|
644
650
|
_stopResolving: true
|
|
645
651
|
};
|
|
646
652
|
});
|
|
@@ -648,51 +654,51 @@ class ae {
|
|
|
648
654
|
async resolveRelations(e, t, s) {
|
|
649
655
|
let r = [];
|
|
650
656
|
if (e.rel_uuids) {
|
|
651
|
-
const
|
|
652
|
-
for (let a = 0; a <
|
|
653
|
-
const l = Math.min(
|
|
654
|
-
|
|
657
|
+
const o = e.rel_uuids.length, i = [], c = 50;
|
|
658
|
+
for (let a = 0; a < o; a += c) {
|
|
659
|
+
const l = Math.min(o, a + c);
|
|
660
|
+
i.push(e.rel_uuids.slice(a, l));
|
|
655
661
|
}
|
|
656
|
-
for (let a = 0; a <
|
|
662
|
+
for (let a = 0; a < i.length; a++)
|
|
657
663
|
(await this.getStories({
|
|
658
664
|
per_page: c,
|
|
659
665
|
language: t.language,
|
|
660
666
|
version: t.version,
|
|
661
|
-
by_uuids:
|
|
667
|
+
by_uuids: i[a].join(",")
|
|
662
668
|
})).data.stories.forEach((l) => {
|
|
663
669
|
r.push(l);
|
|
664
670
|
});
|
|
665
671
|
} else
|
|
666
672
|
r = e.rels;
|
|
667
|
-
r && r.length > 0 && r.forEach((
|
|
668
|
-
this.relations[s][
|
|
669
|
-
...
|
|
673
|
+
r && r.length > 0 && r.forEach((o) => {
|
|
674
|
+
this.relations[s][o.uuid] = {
|
|
675
|
+
...o,
|
|
670
676
|
_stopResolving: true
|
|
671
677
|
};
|
|
672
678
|
});
|
|
673
679
|
}
|
|
674
680
|
async resolveStories(e, t, s) {
|
|
675
|
-
var r,
|
|
676
|
-
let
|
|
677
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (
|
|
681
|
+
var r, o;
|
|
682
|
+
let i = [];
|
|
683
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
678
684
|
for (const c in this.relations[s])
|
|
679
685
|
this.iterateTree(
|
|
680
686
|
this.relations[s][c],
|
|
681
|
-
|
|
687
|
+
i,
|
|
682
688
|
s
|
|
683
689
|
);
|
|
684
|
-
e.story ? this.iterateTree(e.story,
|
|
685
|
-
this.iterateTree(c,
|
|
690
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((c) => {
|
|
691
|
+
this.iterateTree(c, i, s);
|
|
686
692
|
}), delete this.links[s], delete this.relations[s];
|
|
687
693
|
}
|
|
688
694
|
async cacheResponse(e, t, s) {
|
|
689
|
-
const r = this.helpers.stringify({ url: e, params: t }),
|
|
695
|
+
const r = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
|
|
690
696
|
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
693
|
-
return Promise.resolve(
|
|
697
|
+
const i = await o.get(r);
|
|
698
|
+
if (i)
|
|
699
|
+
return Promise.resolve(i);
|
|
694
700
|
}
|
|
695
|
-
return new Promise((
|
|
701
|
+
return new Promise((i, c) => {
|
|
696
702
|
try {
|
|
697
703
|
(async () => {
|
|
698
704
|
var a;
|
|
@@ -705,10 +711,10 @@ class ae {
|
|
|
705
711
|
})), l.status != 200)
|
|
706
712
|
return c(l);
|
|
707
713
|
if (u.data.story || u.data.stories) {
|
|
708
|
-
const
|
|
709
|
-
await this.resolveStories(u.data, t, `${
|
|
714
|
+
const d = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
715
|
+
await this.resolveStories(u.data, t, `${d}`);
|
|
710
716
|
}
|
|
711
|
-
return t.version === "published" && e != "/cdn/spaces/me" && await
|
|
717
|
+
return t.version === "published" && e != "/cdn/spaces/me" && await o.set(r, u), u.data.cv && t.token && (t.version == "draft" && _[t.token] != u.data.cv && await this.flushCache(), _[t.token] = u.data.cv), i(u);
|
|
712
718
|
} catch (l) {
|
|
713
719
|
return c(l);
|
|
714
720
|
}
|
|
@@ -721,29 +727,29 @@ class ae {
|
|
|
721
727
|
return this.client[e](t, s);
|
|
722
728
|
}
|
|
723
729
|
cacheVersions() {
|
|
724
|
-
return
|
|
730
|
+
return _;
|
|
725
731
|
}
|
|
726
732
|
cacheVersion() {
|
|
727
|
-
return
|
|
733
|
+
return _[this.accessToken];
|
|
728
734
|
}
|
|
729
735
|
setCacheVersion(e) {
|
|
730
|
-
this.accessToken && (
|
|
736
|
+
this.accessToken && (_[this.accessToken] = e);
|
|
731
737
|
}
|
|
732
738
|
cacheProvider() {
|
|
733
739
|
switch (this.cache.type) {
|
|
734
740
|
case "memory":
|
|
735
741
|
return {
|
|
736
742
|
get(e) {
|
|
737
|
-
return Promise.resolve(
|
|
743
|
+
return Promise.resolve(g[e]);
|
|
738
744
|
},
|
|
739
745
|
getAll() {
|
|
740
|
-
return Promise.resolve(
|
|
746
|
+
return Promise.resolve(g);
|
|
741
747
|
},
|
|
742
748
|
set(e, t) {
|
|
743
|
-
return
|
|
749
|
+
return g[e] = t, Promise.resolve(void 0);
|
|
744
750
|
},
|
|
745
751
|
flush() {
|
|
746
|
-
return
|
|
752
|
+
return g = {}, Promise.resolve(void 0);
|
|
747
753
|
}
|
|
748
754
|
};
|
|
749
755
|
case "custom":
|
|
@@ -770,7 +776,7 @@ class ae {
|
|
|
770
776
|
return await this.cacheProvider().flush(), this;
|
|
771
777
|
}
|
|
772
778
|
}
|
|
773
|
-
const
|
|
779
|
+
const ue = (n = {}) => {
|
|
774
780
|
const { apiOptions: e } = n;
|
|
775
781
|
if (!e.accessToken) {
|
|
776
782
|
console.error(
|
|
@@ -778,8 +784,8 @@ const ce = (n = {}) => {
|
|
|
778
784
|
);
|
|
779
785
|
return;
|
|
780
786
|
}
|
|
781
|
-
return { storyblokApi: new
|
|
782
|
-
},
|
|
787
|
+
return { storyblokApi: new ce(e) };
|
|
788
|
+
}, de = (n) => {
|
|
783
789
|
if (typeof n != "object" || typeof n._editable > "u")
|
|
784
790
|
return {};
|
|
785
791
|
const e = JSON.parse(
|
|
@@ -790,13 +796,13 @@ const ce = (n = {}) => {
|
|
|
790
796
|
"data-blok-uid": e.id + "-" + e.uid
|
|
791
797
|
};
|
|
792
798
|
};
|
|
793
|
-
let
|
|
794
|
-
const
|
|
799
|
+
let R;
|
|
800
|
+
const w = "https://app.storyblok.com/f/storyblok-v2-latest.js", pe = (n, e, t = {}) => {
|
|
795
801
|
var c;
|
|
796
|
-
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u",
|
|
802
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
|
|
797
803
|
"_storyblok"
|
|
798
804
|
) === n;
|
|
799
|
-
if (!(!r || !
|
|
805
|
+
if (!(!r || !i)) {
|
|
800
806
|
if (!n) {
|
|
801
807
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
802
808
|
return;
|
|
@@ -807,24 +813,24 @@ const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", ue = (n, e, t =
|
|
|
807
813
|
});
|
|
808
814
|
});
|
|
809
815
|
}
|
|
810
|
-
},
|
|
811
|
-
var u,
|
|
816
|
+
}, me = (n = {}) => {
|
|
817
|
+
var u, d;
|
|
812
818
|
const {
|
|
813
819
|
bridge: e,
|
|
814
820
|
accessToken: t,
|
|
815
821
|
use: s = [],
|
|
816
822
|
apiOptions: r = {},
|
|
817
|
-
richText:
|
|
823
|
+
richText: o = {}
|
|
818
824
|
} = n;
|
|
819
825
|
r.accessToken = r.accessToken || t;
|
|
820
|
-
const
|
|
826
|
+
const i = { bridge: e, apiOptions: r };
|
|
821
827
|
let c = {};
|
|
822
|
-
s.forEach((
|
|
823
|
-
c = { ...c, ...
|
|
828
|
+
s.forEach((m) => {
|
|
829
|
+
c = { ...c, ...m(i) };
|
|
824
830
|
});
|
|
825
|
-
const l = !(typeof window > "u") && ((
|
|
826
|
-
return e !== false && l &&
|
|
827
|
-
},
|
|
831
|
+
const l = !(typeof window > "u") && ((d = (u = window.location) == null ? void 0 : u.search) == null ? void 0 : d.includes("_storyblok_tk"));
|
|
832
|
+
return e !== false && l && A(w), R = new b(o.schema), o.resolver && S(R, o.resolver), c;
|
|
833
|
+
}, S = (n, e) => {
|
|
828
834
|
n.addNode("blok", (t) => {
|
|
829
835
|
let s = "";
|
|
830
836
|
return t.attrs.body.forEach((r) => {
|
|
@@ -833,26 +839,26 @@ const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", ue = (n, e, t =
|
|
|
833
839
|
html: s
|
|
834
840
|
};
|
|
835
841
|
});
|
|
836
|
-
},
|
|
842
|
+
}, he = (n) => {
|
|
837
843
|
var e, t;
|
|
838
844
|
return !n || ((e = n == null ? void 0 : n.content) == null ? void 0 : e[0].type) !== "blok" && !((t = n == null ? void 0 : n.content) != null && t[0].content);
|
|
839
|
-
},
|
|
840
|
-
let s = t ||
|
|
845
|
+
}, _e = (n, e, t) => {
|
|
846
|
+
let s = t || R;
|
|
841
847
|
if (!s) {
|
|
842
848
|
console.error(
|
|
843
849
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
844
850
|
);
|
|
845
851
|
return;
|
|
846
852
|
}
|
|
847
|
-
return
|
|
848
|
-
}, ge = () =>
|
|
853
|
+
return he(n) ? "" : (e && (s = new b(e.schema), e.resolver && S(s, e.resolver)), s.render(n));
|
|
854
|
+
}, ge = () => A(w);
|
|
849
855
|
export {
|
|
850
|
-
|
|
856
|
+
_e as _,
|
|
857
|
+
b,
|
|
851
858
|
de as d,
|
|
852
859
|
ge as g,
|
|
853
|
-
he as h,
|
|
854
860
|
ie as i,
|
|
861
|
+
me as m,
|
|
855
862
|
pe as p,
|
|
856
|
-
ue as u
|
|
857
|
-
y
|
|
863
|
+
ue as u
|
|
858
864
|
};
|
package/dist/storyblok-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-1fc8cce4.js"),t=require("./index-f2312f95.js"),r=require("./client-8bf0d228.js");exports.RichTextResolver=o.b,exports.RichTextSchema=o.ie,exports.apiPlugin=o.ue,exports.loadStoryblokBridge=o.ge,exports.registerStoryblokBridge=o.pe,exports.renderRichText=o._e,exports.storyblokEditable=o.de,exports.useStoryblokBridge=o.pe,exports.StoryblokComponent=t.StoryblokComponent,exports.getComponent=t.getComponent,exports.getStoryblokApi=t.useStoryblokApi,exports.setComponents=t.setComponents,exports.storyblokInit=t.storyblokInit,exports.useStoryblokApi=t.useStoryblokApi,exports.useStoryblokState=r.useStoryblokState,exports.useStoryblok=(r,s={},i={})=>{const n=t.useStoryblokApi();if(!n)return console.error("You can't use useStoryblok if you're not loading apiPlugin."),null;let[p,l]=e.useState({});const u="undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent;return e.useEffect((()=>{!async function(){const{data:e}=await n.get(`cdn/stories/${r}`,s);l(e.story),u&&e.story.id&&o.pe(e.story.id,(e=>l(e)),i)}()}),[r,JSON.stringify(s)]),p};
|
package/dist/storyblok-react.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { u as useStoryblokApi } from "./index-
|
|
5
|
-
import { S, g as g2, s, a } from "./index-
|
|
6
|
-
import { u } from "./client-
|
|
2
|
+
import { p as pe } from "./storyblok-js-82c403db.mjs";
|
|
3
|
+
import { b, i, u, g, _, d } from "./storyblok-js-82c403db.mjs";
|
|
4
|
+
import { u as useStoryblokApi } from "./index-9ce0eb0d.mjs";
|
|
5
|
+
import { S, g as g2, s, a } from "./index-9ce0eb0d.mjs";
|
|
6
|
+
import { u as u2 } from "./client-d552e212.mjs";
|
|
7
7
|
const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
|
|
8
8
|
const storyblokApiInstance = useStoryblokApi();
|
|
9
9
|
if (!storyblokApiInstance) {
|
|
@@ -22,7 +22,7 @@ const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
|
|
|
22
22
|
);
|
|
23
23
|
setStory(data.story);
|
|
24
24
|
if (isBridgeEnable && data.story.id) {
|
|
25
|
-
|
|
25
|
+
pe(
|
|
26
26
|
data.story.id,
|
|
27
27
|
(story2) => setStory(story2),
|
|
28
28
|
bridgeOptions
|
|
@@ -34,20 +34,20 @@ const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
|
|
|
34
34
|
return story;
|
|
35
35
|
};
|
|
36
36
|
export {
|
|
37
|
-
|
|
37
|
+
b as RichTextResolver,
|
|
38
38
|
i as RichTextSchema,
|
|
39
39
|
S as StoryblokComponent,
|
|
40
|
-
|
|
40
|
+
u as apiPlugin,
|
|
41
41
|
g2 as getComponent,
|
|
42
42
|
useStoryblokApi as getStoryblokApi,
|
|
43
43
|
g as loadStoryblokBridge,
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
pe as registerStoryblokBridge,
|
|
45
|
+
_ as renderRichText,
|
|
46
46
|
s as setComponents,
|
|
47
|
-
|
|
47
|
+
d as storyblokEditable,
|
|
48
48
|
a as storyblokInit,
|
|
49
49
|
useStoryblok,
|
|
50
50
|
useStoryblokApi,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
pe as useStoryblokBridge,
|
|
52
|
+
u2 as useStoryblokState
|
|
53
53
|
};
|
package/dist/storyblok-react2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-f2312f95.js"),o=require("./storyblok-js-1fc8cce4.js");require("react"),exports.StoryblokComponent=e.StoryblokComponent,exports.getComponent=e.getComponent,exports.getStoryblokApi=e.useStoryblokApi,exports.setComponents=e.setComponents,exports.storyblokInit=e.storyblokInit,exports.useStoryblokApi=e.useStoryblokApi,exports.RichTextResolver=o.b,exports.RichTextSchema=o.ie,exports.apiPlugin=o.ue,exports.loadStoryblokBridge=o.ge,exports.registerStoryblokBridge=o.pe,exports.renderRichText=o._e,exports.storyblokEditable=o.de,exports.useStoryblokBridge=o.pe;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { S, g, u, s, a, u as u2 } from "./index-
|
|
2
|
-
import {
|
|
1
|
+
import { S, g, u, s, a, u as u2 } from "./index-9ce0eb0d.mjs";
|
|
2
|
+
import { b, i, u as u3, g as g2, p, _, d, p as p2 } from "./storyblok-js-82c403db.mjs";
|
|
3
3
|
import "react";
|
|
4
4
|
export {
|
|
5
|
-
|
|
5
|
+
b as RichTextResolver,
|
|
6
6
|
i as RichTextSchema,
|
|
7
7
|
S as StoryblokComponent,
|
|
8
|
-
|
|
8
|
+
u3 as apiPlugin,
|
|
9
9
|
g as getComponent,
|
|
10
10
|
u as getStoryblokApi,
|
|
11
11
|
g2 as loadStoryblokBridge,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
p as registerStoryblokBridge,
|
|
13
|
+
_ as renderRichText,
|
|
14
14
|
s as setComponents,
|
|
15
|
-
|
|
15
|
+
d as storyblokEditable,
|
|
16
16
|
a as storyblokInit,
|
|
17
17
|
u2 as useStoryblokApi,
|
|
18
|
-
|
|
18
|
+
p2 as useStoryblokBridge
|
|
19
19
|
};
|
package/dist/storyblok-react3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";const e=require("react"),o=require("./storyblok-js-
|
|
1
|
+
"use strict";"use client";const e=require("react"),o=require("./storyblok-js-1fc8cce4.js");module.exports=({options:t})=>((async e=>{await o.ge(),new window.StoryblokBridge(e).on(["published","change"],(()=>{window.location.reload()}))})(t),e.createElement(e.Fragment,null));
|
package/dist/storyblok-react4.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";const e=require("react"),t=require("./client-
|
|
1
|
+
"use strict";"use client";const e=require("react"),t=require("./client-8bf0d228.js"),r=require("./index-f2312f95.js");require("./storyblok-js-1fc8cce4.js");const o=e.forwardRef((({story:o,bridgeOptions:n,...s},c)=>("string"==typeof o.content&&(o.content=JSON.parse(o.content)),o=t.useStoryblokState(o,n),e.createElement(r.StoryblokComponent,{ref:c,blok:o.content,...s}))));module.exports=o;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
-
import { u as useStoryblokState } from "./client-
|
|
4
|
-
import { S as StoryblokComponent } from "./index-
|
|
5
|
-
import "./storyblok-js-
|
|
3
|
+
import { u as useStoryblokState } from "./client-d552e212.mjs";
|
|
4
|
+
import { S as StoryblokComponent } from "./index-9ce0eb0d.mjs";
|
|
5
|
+
import "./storyblok-js-82c403db.mjs";
|
|
6
6
|
const StoryblokStory = forwardRef(
|
|
7
7
|
({ story, bridgeOptions, ...restProps }, ref) => {
|
|
8
8
|
if (typeof story.content === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
5
5
|
"main": "./dist/storyblok-react.js",
|
|
6
6
|
"module": "./dist/storyblok-react.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prepublishOnly": "npm run build && cp ../README.md ./"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@storyblok/js": "^2.2.
|
|
47
|
+
"@storyblok/js": "^2.2.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/core": "^7.22.9",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@cypress/react": "^5.12.5",
|
|
53
53
|
"@cypress/vite-dev-server": "^2.2.3",
|
|
54
54
|
"@tsconfig/recommended": "^1.0.2",
|
|
55
|
-
"@types/react": "18.2.
|
|
55
|
+
"@types/react": "18.2.16",
|
|
56
56
|
"@vitejs/plugin-react": "^4.0.3",
|
|
57
57
|
"babel-jest": "^29.6.1",
|
|
58
58
|
"cypress": "^9.7.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"react": "^18.2.0",
|
|
63
63
|
"react-dom": "^18.2.0",
|
|
64
64
|
"start-server-and-test": "^2.0.0",
|
|
65
|
-
"terser": "^5.19.
|
|
65
|
+
"terser": "^5.19.2",
|
|
66
66
|
"vite": "^4.1.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|