Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storyblok/js

Package Overview
Dependencies
Maintainers
7
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storyblok/js - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

4

dist/storyblok-js.js

@@ -1,2 +0,2 @@

(function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.storyblok={}))})(this,function(d){"use strict";let f=!1;const v=[],N=i=>new Promise((e,t)=>{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}f?s():v.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=i,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{v.forEach(o=>o()),f=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var C=Object.defineProperty,x=(i,e,t)=>e in i?C(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,h=(i,e,t)=>(x(i,typeof e!="symbol"?e+"":e,t),t);function A(i){return!(i!==i||i===1/0||i===-1/0)}function G(i,e,t){if(!A(e))throw new TypeError("Expected `limit` to be a finite number");if(!A(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0;const n=function(){o++;const a=setTimeout(function(){o--,r.length>0&&n(),s=s.filter(function(u){return u!==a})},t);s.indexOf(a)<0&&s.push(a);const l=r.shift();l.resolve(i.apply(l.self,l.args))},c=function(...a){const l=this;return new Promise(function(u,p){r.push({resolve:u,reject:p,args:a,self:l}),o<e&&n()})};return c.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),r.length=0},c}class T{constructor(){h(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),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)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(o,n)=>n*s+e)}),h(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),h(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),h(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,s=RegExp(r.source);return e&&s.test(e)?e.replace(r,o=>t[o]):e})}stringify(e,t,r){const s=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const n=e[o],c=r?"":encodeURIComponent(o);let a;typeof n=="object"?a=this.stringify(n,t?t+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):a=(t?t+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),s.push(a)}return s.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",s="app.storyblokchina.cn",o="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return s;case"ap":return o;case"ca":return n;default:return t}}}const B=function(i,e){const t={};for(const r in i){const s=i[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t},L=i=>i==="email",M=()=>({singleTag:"hr"}),$=()=>({tag:"blockquote"}),D=()=>({tag:"ul"}),V=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),F=()=>({singleTag:"br"}),z=i=>({tag:`h${i.attrs.level}`}),W=i=>({singleTag:[{tag:"img",attrs:B(i.attrs,["src","alt","title"])}]}),K=()=>({tag:"li"}),X=()=>({tag:"ol"}),J=()=>({tag:"p"}),Y=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),q=()=>({tag:"b"}),Q=()=>({tag:"s"}),Z=()=>({tag:"u"}),ee=()=>({tag:"strong"}),te=()=>({tag:"code"}),re=()=>({tag:"i"}),se=i=>{if(!i.attrs)return{tag:""};const e=new T().escapeHTML,t={...i.attrs},{linktype:r="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),L(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},oe=i=>({tag:[{tag:"span",attrs:i.attrs}]}),ne=()=>({tag:"sub"}),ie=()=>({tag:"sup"}),ae=i=>({tag:[{tag:"span",attrs:i.attrs}]}),le=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},ce=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},S={nodes:{horizontal_rule:M,blockquote:$,bullet_list:D,code_block:V,hard_break:F,heading:z,image:W,list_item:K,ordered_list:X,paragraph:J,emoji:Y},marks:{bold:q,strike:Q,underline:Z,strong:ee,code:te,italic:re,link:se,styled:oe,subscript:ne,superscript:ie,anchor:ae,highlight:le,textStyle:ce}},he=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=RegExp(t.source);return i&&r.test(i)?i.replace(t,s=>e[s]):i};class y{constructor(e){h(this,"marks"),h(this,"nodes"),e||(e=S),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(s=>{r+=this.renderNode(s)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
(function(d,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(d=typeof globalThis<"u"?globalThis:d||self,y(d.storyblok={}))})(this,function(d){"use strict";let y=!1;const S=[],j=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}y?r():S.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{S.forEach(i=>i()),y=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var N=Object.defineProperty,L=(o,e,t)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,h=(o,e,t)=>(L(o,typeof e!="symbol"?e+"":e,t),t);function O(o){return!(o!==o||o===1/0||o===-1/0)}function M(o,e,t){if(!O(e))throw new TypeError("Expected `limit` to be a finite number");if(!O(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const a=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==a})},t);r.indexOf(a)<0&&r.push(a);const l=s.shift();l.resolve(o.apply(l.self,l.args))},c=function(...a){const l=this;return new Promise(function(u,p){s.push({resolve:u,reject:p,args:a,self:l}),i<e&&n()})};return c.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},c}class v{constructor(){h(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),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)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(i,n)=>n*r+e)}),h(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),h(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),h(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return e&&r.test(e)?e.replace(s,i=>t[i]):e})}stringify(e,t,s){const r=[];for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const n=e[i],c=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=this.stringify(n,t?t+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):a=(t?t+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",i="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return i;case"ca":return n;default:return t}}}const z=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},U=o=>o==="email",B=()=>({singleTag:"hr"}),H=()=>({tag:"blockquote"}),q=()=>({tag:"ul"}),F=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),V=()=>({singleTag:"br"}),J=o=>({tag:`h${o.attrs.level}`}),D=o=>({singleTag:[{tag:"img",attrs:z(o.attrs,["src","alt","title"])}]}),Y=()=>({tag:"li"}),K=()=>({tag:"ol"}),W=()=>({tag:"p"}),G=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Q=()=>({tag:"b"}),X=()=>({tag:"s"}),Z=()=>({tag:"u"}),ee=()=>({tag:"strong"}),te=()=>({tag:"code"}),se=()=>({tag:"i"}),re=o=>{if(!o.attrs)return{tag:""};const e=new v().escapeHTML,t={...o.attrs},{linktype:s="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),U(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ie=o=>({tag:[{tag:"span",attrs:o.attrs}]}),ne=()=>({tag:"sub"}),oe=()=>({tag:"sup"}),ae=o=>({tag:[{tag:"span",attrs:o.attrs}]}),le=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},ce=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},x={nodes:{horizontal_rule:B,blockquote:H,bullet_list:q,code_block:F,hard_break:V,heading:J,image:D,list_item:Y,ordered_list:K,paragraph:W,emoji:G},marks:{bold:Q,strike:X,underline:Z,strong:ee,code:te,italic:se,link:re,styled:ie,subscript:ne,superscript:oe,anchor:ae,highlight:le,textStyle:ce}},he=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};class k{constructor(e){h(this,"marks"),h(this,"nodes"),e||(e=x),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(r=>{s+=this.renderNode(r)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
The "content" field must be an array of nodes as the type ISbRichtext.

@@ -24,2 +24,2 @@ ISbRichtext:

type: 'doc'
}`),""}optimizeImages(e,t){let r=0,s=0,o="",n="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(o+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(o+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(o+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(o+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(n+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(n+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(n+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(n+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(n+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(n+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(n+=`:rotate(${t.filters.rotate})`),n.length>0&&(n="/filters"+n))),o.length>0&&(e=e.replace(/<img/g,`<img ${o.trim()}`));const c=r>0||s>0||n.length>0?`${r}x${s}${n}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var l,u;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(p&&p.length>0){const _={srcset:(l=t.srcset)==null?void 0:l.map(m=>{if(typeof m=="number")return`//${p}/m/${m}x0${n} ${m}w`;if(typeof m=="object"&&m.length===2){let I=0,P=0;return typeof m[0]=="number"&&(I=m[0]),typeof m[1]=="number"&&(P=m[1]),`//${p}/m/${I}x${P}${n} ${I}w`}}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(m=>m).join(", ")};let g="";return _.srcset&&(g+=`srcset="${_.srcset}" `),_.sizes&&(g+=`sizes="${_.sizes}" `),a.replace(/<img/g,`<img ${g.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(he(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs)for(const o in r.attrs){const n=r.attrs[o];n!==null&&(s+=` ${o}="${n}"`)}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class ue{constructor(e){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),h(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const a=new T;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:n}=o;let c;this.timeout&&(c=setTimeout(()=>o.abort(),this.timeout));try{const a=await fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:n,...this.fetchOptions});this.timeout&&clearTimeout(c);const l=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};s(o)})}}var de={GITHUB_TOKEN:"ghs_SY9hAvLQ8nuSfh6VtsLyQYlPrM7NAw095mxm",GITHUB_STATE:"/home/runner/work/_temp/_runner_file_commands/save_state_0680fa51-273e-4603-9ba8-00c19d52aa53",GIT_COMMITTER_NAME:"semantic-release-bot",STATS_TRP:"true",DEPLOYMENT_BASEPATH:"/opt/runner",DOTNET_NOLOGO:"1",USER:"runner",npm_config_user_agent:"npm/10.2.3 node/v18.19.0 linux x64 workspaces/false ci/github-actions",GIT_AUTHOR_EMAIL:"semantic-release-bot@martynus.net",CI:"true",RUNNER_ENVIRONMENT:"github-hosted",GITHUB_ENV:"/home/runner/work/_temp/_runner_file_commands/set_env_0680fa51-273e-4603-9ba8-00c19d52aa53",PIPX_HOME:"/opt/pipx",npm_node_execpath:"/opt/hostedtoolcache/node/18.19.0/x64/bin/node",GIT_ASKPASS:"echo",npm_package_resolved:"/home/runner/work/storyblok-js-client/storyblok-js-client",JAVA_HOME_8_X64:"/usr/lib/jvm/temurin-8-jdk-amd64",SHLVL:"1",npm_config_noproxy:"",HOME:"/home/runner",RUNNER_TEMP:"/home/runner/work/_temp",GITHUB_EVENT_PATH:"/home/runner/work/_temp/_github_workflow/event.json",npm_package_json:"/home/runner/work/storyblok-js-client/storyblok-js-client/package.json",JAVA_HOME_11_X64:"/usr/lib/jvm/temurin-11-jdk-amd64",PIPX_BIN_DIR:"/opt/pipx_bin",GITHUB_REPOSITORY_OWNER:"storyblok",GRADLE_HOME:"/usr/share/gradle-8.5",ANDROID_NDK_LATEST_HOME:"/usr/local/lib/android/sdk/ndk/26.1.10909125",JAVA_HOME_21_X64:"/usr/lib/jvm/temurin-21-jdk-amd64",STATS_RDCL:"true",GITHUB_RETENTION_DAYS:"90",GIT_AUTHOR_NAME:"semantic-release-bot",GITHUB_REPOSITORY_OWNER_ID:"13880908",POWERSHELL_DISTRIBUTION_CHANNEL:"GitHub-Actions-ubuntu22",AZURE_EXTENSION_DIR:"/opt/az/azcliextensions",GITHUB_HEAD_REF:"",npm_config_userconfig:"/tmp/f9cb367b92d80a35a8a750840547b152/.npmrc",npm_config_local_prefix:"/home/runner/work/storyblok-js-client/storyblok-js-client",npm_package_integrity:"null",SYSTEMD_EXEC_PID:"593",GITHUB_GRAPHQL_URL:"https://api.github.com/graphql",COLOR:"0",GOROOT_1_20_X64:"/opt/hostedtoolcache/go/1.20.12/x64",NVM_DIR:"/home/runner/.nvm",NPM_TOKEN:"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",DOTNET_SKIP_FIRST_TIME_EXPERIENCE:"1",GOROOT_1_21_X64:"/opt/hostedtoolcache/go/1.21.5/x64",JAVA_HOME_17_X64:"/usr/lib/jvm/temurin-17-jdk-amd64",ImageVersion:"20240107.1.0",RUNNER_OS:"Linux",GITHUB_API_URL:"https://api.github.com",SWIFT_PATH:"/usr/share/swift/usr/bin",RUNNER_USER:"runner",STATS_V3PS:"true",CHROMEWEBDRIVER:"/usr/local/share/chromedriver-linux64",JOURNAL_STREAM:"8:17159",GITHUB_WORKFLOW:"release",_:"/opt/hostedtoolcache/node/18.19.0/x64/bin/npx",npm_config_prefix:"/opt/hostedtoolcache/node/18.19.0/x64",npm_config_npm_version:"10.2.3",ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE:"/opt/actionarchivecache",GITHUB_RUN_ID:"7493474777",npm_config_cache:"/home/runner/.npm",GITHUB_REF_TYPE:"branch",BOOTSTRAP_HASKELL_NONINTERACTIVE:"1",GITHUB_WORKFLOW_SHA:"b51aed5f473d8899277db2413a431150934793bc",GITHUB_BASE_REF:"",ImageOS:"ubuntu22",GITHUB_WORKFLOW_REF:"storyblok/storyblok-js-client/.github/workflows/release.yml@refs/heads/main",PERFLOG_LOCATION_SETTING:"RUNNER_PERFLOG",GITHUB_ACTION_REPOSITORY:"",npm_config_node_gyp:"/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/bin:/home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/.bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/opt/hostedtoolcache/node/18.19.0/x64/bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",ANT_HOME:"/usr/share/ant",DOTNET_MULTILEVEL_LOOKUP:"0",RUNNER_TRACKING_ID:"github_bcef4b2d-d4af-4ca4-91ab-56a4509bf353",INVOCATION_ID:"6c9f22e5fd0d4fc98bc67fbac8a9476c",RUNNER_TOOL_CACHE:"/opt/hostedtoolcache",GOROOT_1_19_X64:"/opt/hostedtoolcache/go/1.19.13/x64",NODE:"/opt/hostedtoolcache/node/18.19.0/x64/bin/node",npm_package_name:"storyblok-js-client",GITHUB_ACTION:"__run_2",GITHUB_RUN_NUMBER:"16",GITHUB_TRIGGERING_ACTOR:"thiagosaife",RUNNER_ARCH:"X64",XDG_RUNTIME_DIR:"/run/user/1001",AGENT_TOOLSDIRECTORY:"/opt/hostedtoolcache",LANG:"C.UTF-8",VCPKG_INSTALLATION_ROOT:"/usr/local/share/vcpkg",CONDA:"/usr/share/miniconda",RUNNER_NAME:"GitHub Actions 3",XDG_CONFIG_HOME:"/home/runner/.config",STATS_VMD:"true",GITHUB_REF_NAME:"main",GITHUB_REPOSITORY:"storyblok/storyblok-js-client",npm_lifecycle_script:"node vite.build.mjs && tsc",STATS_UE:"true",ANDROID_NDK_ROOT:"/usr/local/lib/android/sdk/ndk/25.2.9519653",GITHUB_ACTION_REF:"",DEBIAN_FRONTEND:"noninteractive",GITHUB_REPOSITORY_ID:"116555786",GITHUB_ACTIONS:"true",npm_package_version:"6.5.0",npm_lifecycle_event:"build",GIT_TERMINAL_PROMPT:"0",GITHUB_REF_PROTECTED:"true",GITHUB_WORKSPACE:"/home/runner/work/storyblok-js-client/storyblok-js-client",ACCEPT_EULA:"Y",GITHUB_JOB:"release",RUNNER_PERFLOG:"/home/runner/perflog",GITHUB_SHA:"b51aed5f473d8899277db2413a431150934793bc",GITHUB_RUN_ATTEMPT:"3",GITHUB_REF:"refs/heads/main",GITHUB_ACTOR:"thiagosaife",ANDROID_SDK_ROOT:"/usr/local/lib/android/sdk",LEIN_HOME:"/usr/local/lib/lein",npm_config_globalconfig:"/opt/hostedtoolcache/node/18.19.0/x64/etc/npmrc",npm_config_init_module:"/home/runner/.npm-init.js",GIT_COMMITTER_EMAIL:"semantic-release-bot@martynus.net",GITHUB_PATH:"/home/runner/work/_temp/_runner_file_commands/add_path_0680fa51-273e-4603-9ba8-00c19d52aa53",JAVA_HOME:"/usr/lib/jvm/temurin-11-jdk-amd64",PWD:"/home/runner/work/storyblok-js-client/storyblok-js-client",GITHUB_ACTOR_ID:"10601682",RUNNER_WORKSPACE:"/home/runner/work/storyblok-js-client",npm_execpath:"/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/bin/npm-cli.js",HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS:"3650",STATS_TIS:"mining",GITHUB_EVENT_NAME:"push",HOMEBREW_NO_AUTO_UPDATE:"1",ANDROID_HOME:"/usr/local/lib/android/sdk",GITHUB_SERVER_URL:"https://github.com",GECKOWEBDRIVER:"/usr/local/share/gecko_driver",LEIN_JAR:"/usr/local/lib/lein/self-installs/leiningen-2.10.0-standalone.jar",GHCUP_INSTALL_BASE_PREFIX:"/usr/local",GITHUB_OUTPUT:"/home/runner/work/_temp/_runner_file_commands/set_output_0680fa51-273e-4603-9ba8-00c19d52aa53",npm_config_global_prefix:"/opt/hostedtoolcache/node/18.19.0/x64",EDGEWEBDRIVER:"/usr/local/share/edge_driver",STATS_EXT:"true",npm_command:"run-script",ANDROID_NDK:"/usr/local/lib/android/sdk/ndk/25.2.9519653",SGX_AESM_ADDR:"1",CHROME_BIN:"/usr/bin/google-chrome",SELENIUM_JAR_PATH:"/usr/share/java/selenium-server.jar",STATS_EXTP:"https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.154/provjobd.data",ANDROID_NDK_HOME:"/usr/local/lib/android/sdk/ndk/25.2.9519653",GITHUB_STEP_SUMMARY:"/home/runner/work/_temp/_runner_file_commands/step_summary_0680fa51-273e-4603-9ba8-00c19d52aa53",INIT_CWD:"/home/runner/work/storyblok-js-client/storyblok-js-client",EDITOR:"vi",NODE_ENV:"production"};const w="SB-Agent",k={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:de.npm_package_version};let R={};const b={};class pe{constructor(e,t){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"),h(this,"stringifiedStoriesCache");let r=e.endpoint||t;const s=new T().getRegionURL,o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${s(e.region)}/v1`:r=`${o}://${s(e.region)}/v2`;const n=new Headers;if(n.set("Content-Type","application/json"),n.set("Accept","application/json"),e.headers)for(const a in e.headers)n.set(a,e.headers[a]);n.has(w)||(n.set(w,k.defaultAgentName),n.set(k.defaultAgentVersion,k.packageVersion));let c=5;e.oauthToken&&(n.set("Authorization",e.oauthToken),c=3),e.rateLimit&&(c=e.rateLimit),e.richTextSchema?this.richTextResolver=new y(e.richTextSchema):this.richTextResolver=new y,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=G(this.throttledRequest,c,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new T,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new ue({baseURL:r,timeout:e.timeout||0,headers:n,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=b[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const o=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,s));return this.cacheResponse(e,o)}get(e,t,r){t||(t={});const s=`/${e}`,o=this.factoryParamOptions(s,t);return this.client.setFetchOptions(r),this.cacheResponse(s,o)}async getAll(e,t,r,s){const o=(t==null?void 0:t.per_page)||25,n=`/${e}`,c=n.split("/"),a=r||c[c.length-1],l=1,u=await this.makeRequest(n,t,o,l),p=u.total?Math.ceil(u.total/o):1;this.client.setFetchOptions(s);const _=await this.helpers.asyncMap(this.helpers.range(l,p),g=>this.makeRequest(n,t,o,g+1));return this.helpers.flatMap([u,..._],g=>Object.values(g.data[a]))}post(e,t,r){const s=`/${e}`;return this.client.setFetchOptions(r),Promise.resolve(this.throttle("post",s,t))}put(e,t,r){const s=`/${e}`;return this.client.setFetchOptions(r),Promise.resolve(this.throttle("put",s,t))}delete(e,t,r){const s=`/${e}`;return this.client.setFetchOptions(r),Promise.resolve(this.throttle("delete",s,t))}getStories(e,t){return this.client.setFetchOptions(t),this.get("cdn/stories",e)}getStory(e,t,r){return this.client.setFetchOptions(r),this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype=="multilink"&&s.linktype=="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,r,s){r.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(s,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(o=>this.getStoryReference(s,o)).filter(Boolean)))}iterateTree(e,t,r){const s=o=>{if(o!=null){if(o.constructor===Array)for(let n=0;n<o.length;n++)s(o[n]);else if(o.constructor===Object){if(o._stopResolving)return;for(const n in o)(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,n,t,r),this._insertLinks(o,n,r)),s(o[n])}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,n=[],c=50;for(let a=0;a<o;a+=c){const l=Math.min(o,a+c);n.push(e.link_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{s.push(l)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,n=[],c=50;for(let a=0;a<o;a+=c){const l=Math.min(o,a+c);n.push(e.rel_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(l=>{s.push(l)})}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let n=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const c in this.relations[r])this.iterateTree(this.relations[r][c],n,r);e.story?this.iterateTree(e.story,n,r):e.stories.forEach(c=>{this.iterateTree(c,n,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r){(typeof r>"u"||!r)&&(r=0);const s=this.helpers.stringify({url:e,params:t}),o=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const n=await o.get(s);if(n)return Promise.resolve(n)}return new Promise(async(n,c)=>{var a;try{const l=await this.throttle("get",e,t);if(l.status===429&&(r=r?r+1:0,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await this.helpers.delay(1e3*r),this.cacheResponse(e,t,r).then(n).catch(c);if(l.status!==200)return c(l);let u={data:l.data,headers:l.headers};if((a=l.headers)!=null&&a["per-page"]&&(u=Object.assign({},u,{perPage:l.headers["per-page"]?parseInt(l.headers["per-page"]):0,total:l.headers["per-page"]?parseInt(l.headers.total):0})),u.data.story||u.data.stories){const p=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,t,`${p}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await o.set(s,u),u.data.cv&&t.token&&(t.version==="draft"&&b[t.token]!=u.data.cv&&await this.flushCache(),b[t.token]=t.cv?t.cv:u.data.cv),n(u)}catch(l){c(l)}})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return b}cacheVersion(){return b[this.accessToken]}setCacheVersion(e){this.accessToken&&(b[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(R[e])},getAll(){return Promise.resolve(R)},set(e,t){return R[e]=t,Promise.resolve(void 0)},flush(){return R={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this}}const me=(i={})=>{const{apiOptions:e}=i;if(!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new pe(e)}},_e=i=>{if(typeof i!="object"||typeof i._editable>"u")return{};try{const e=JSON.parse(i._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let E,O="https://app.storyblok.com/f/storyblok-v2-latest.js";const j=(i,e,t={})=>{var c;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok")===i;if(!(!s||!n)){if(!i){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{l.action==="input"&&l.story.id===i?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===i&&window.location.reload()})})}},ge=(i={})=>{var p,_;const{bridge:e,accessToken:t,use:r=[],apiOptions:s={},richText:o={},bridgeUrl:n}=i;s.accessToken=s.accessToken||t;const c={bridge:e,apiOptions:s};let a={};r.forEach(g=>{a={...a,...g(c)}}),n&&(O=n);const u=!(typeof window>"u")&&((_=(p=window.location)==null?void 0:p.search)==null?void 0:_.includes("_storyblok_tk"));return e!==!1&&u&&N(O),E=new y(o.schema),o.resolver&&U(E,o.resolver),a},U=(i,e)=>{i.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},H=i=>!i||!(i!=null&&i.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),fe=(i,e,t)=>{let r=t||E;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return H(i)?"":(e&&(r=new y(e.schema),e.resolver&&U(r,e.resolver)),r.render(i))},be=()=>N(O);d.RichTextResolver=y,d.RichTextSchema=S,d.apiPlugin=me,d.isRichTextEmpty=H,d.loadStoryblokBridge=be,d.registerStoryblokBridge=j,d.renderRichText=fe,d.storyblokEditable=_e,d.storyblokInit=ge,d.useStoryblokBridge=j,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
}`),""}optimizeImages(e,t){let s=0,r=0,i="",n="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(i+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(i+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(i+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(i+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(n+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(n+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(n+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(n+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(n+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(n+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(n+=`:rotate(${t.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(e=e.replace(/<img/g,`<img ${i.trim()}`));const c=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var l,u;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(p&&p.length>0){const f={srcset:(l=t.srcset)==null?void 0:l.map(g=>{if(typeof g=="number")return`//${p}/m/${g}x0${n} ${g}w`;if(typeof g=="object"&&g.length===2){let _=0,A=0;return typeof g[0]=="number"&&(_=g[0]),typeof g[1]=="number"&&(A=g[1]),`//${p}/m/${_}x${A}${n} ${_}w`}}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(g=>g).join(", ")};let m="";return f.srcset&&(m+=`srcset="${f.srcset}" `),f.sizes&&(m+=`sizes="${f.sizes}" `),a.replace(/<img/g,`<img ${m.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&t.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(he(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&t.push(this.renderClosingTag(i.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class ue{constructor(e){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),h(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new v;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),i=new AbortController,{signal:n}=i;let c;this.timeout&&(c=setTimeout(()=>i.abort(),this.timeout));try{const a=await fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n,...this.fetchOptions});this.timeout&&clearTimeout(c);const l=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const i={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(i)})}}var de={npm_package_version:"6.6.1"};const E="SB-Agent",R={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:de.npm_package_version};let w={};const b={};class pe{constructor(e,t){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"),h(this,"stringifiedStoriesCache");let s=e.endpoint||t;const r=new v().getRegionURL,i=e.https===!1?"http":"https";e.oauthToken?s=`${i}://${r(e.region)}/v1`:s=`${i}://${r(e.region)}/v2`;const n=new Headers;if(n.set("Content-Type","application/json"),n.set("Accept","application/json"),e.headers)for(const a in e.headers)n.set(a,e.headers[a]);n.has(E)||(n.set(E,R.defaultAgentName),n.set(R.defaultAgentVersion,R.packageVersion));let c=5;e.oauthToken&&(n.set("Authorization",e.oauthToken),c=3),e.rateLimit&&(c=e.rateLimit),e.richTextSchema?this.richTextResolver=new k(e.richTextSchema):this.richTextResolver=new k,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=M(this.throttledRequest,c,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new ue({baseURL:s,timeout:e.timeout||0,headers:n,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=b[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,i)}get(e,t,s){t||(t={});const r=`/${e}`,i=this.factoryParamOptions(r,t);return this.client.setFetchOptions(s),this.cacheResponse(r,i)}async getAll(e,t,s,r){const i=(t==null?void 0:t.per_page)||25,n=`/${e}`,c=n.split("/"),a=s||c[c.length-1],l=1,u=await this.makeRequest(n,t,i,l),p=u.total?Math.ceil(u.total/i):1;this.client.setFetchOptions(r);const f=await this.helpers.asyncMap(this.helpers.range(l,p),m=>this.makeRequest(n,t,i,m+1));return this.helpers.flatMap([u,...f],m=>Object.values(m.data[a]))}post(e,t,s){const r=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("post",r,t))}put(e,t,s){const r=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("put",r,t))}delete(e,t,s){const r=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("delete",r,t))}getStories(e,t){return this.client.setFetchOptions(t),this.get("cdn/stories",e)}getStory(e,t,s){return this.client.setFetchOptions(s),this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(i=>this.getStoryReference(r,i)).filter(Boolean)))}iterateTree(e,t,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,t,s),this._insertLinks(i,n,s)),r(i[n])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const i=e.link_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(e.link_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=e.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const i=e.rel_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(e.rel_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(l=>{r.push(l)})}else r=e.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(e,t,s){var r,i;let n=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(i=e.link_uuids)!=null&&i.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],n,s);e.story?this.iterateTree(e.story,n,s):e.stories.forEach(c=>{this.iterateTree(c,n,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const r=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise(async(n,c)=>{var a;try{const l=await this.throttle("get",e,t);if(l.status===429&&(s=s?s+1:0,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${s} seconds.`),await this.helpers.delay(1e3*s),this.cacheResponse(e,t,s).then(n).catch(c);if(l.status!==200)return c(l);let u={data:l.data,headers:l.headers};if((a=l.headers)!=null&&a["per-page"]&&(u=Object.assign({},u,{perPage:l.headers["per-page"]?parseInt(l.headers["per-page"]):0,total:l.headers["per-page"]?parseInt(l.headers.total):0})),u.data.story||u.data.stories){const p=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,t,`${p}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&t.token&&(t.version==="draft"&&b[t.token]!=u.data.cv&&await this.flushCache(),b[t.token]=t.cv?t.cv:u.data.cv),n(u)}catch(l){c(l)}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return b}cacheVersion(){return b[this.accessToken]}setCacheVersion(e){this.accessToken&&(b[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(w[e])},getAll(){return Promise.resolve(w)},set(e,t){return w[e]=t,Promise.resolve(void 0)},flush(){return w={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this}}const ge=(o={})=>{const{apiOptions:e}=o;if(!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new pe(e)}},fe=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let T,$="https://app.storyblok.com/f/storyblok-v2-latest.js";const I=(o,e,t={})=>{var c;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok")===o;if(!(!r||!n)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{l.action==="input"&&l.story.id===o?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===o&&window.location.reload()})})}},me=(o={})=>{var p,f;const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:i={},bridgeUrl:n}=o;r.accessToken=r.accessToken||t;const c={bridge:e,apiOptions:r};let a={};s.forEach(m=>{a={...a,...m(c)}}),n&&($=n);const u=!(typeof window>"u")&&((f=(p=window.location)==null?void 0:p.search)==null?void 0:f.includes("_storyblok_tk"));return e!==!1&&u&&j($),T=new k(i.schema),i.resolver&&P(T,i.resolver),a},P=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},C=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),ye=(o,e,t)=>{let s=t||T;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return C(o)?"":(e&&(s=new k(e.schema),e.resolver&&P(s,e.resolver)),s.render(o))},be=()=>j($);d.RichTextResolver=k,d.RichTextSchema=x,d.apiPlugin=ge,d.isRichTextEmpty=C,d.loadStoryblokBridge=be,d.registerStoryblokBridge=I,d.renderRichText=ye,d.storyblokEditable=fe,d.storyblokInit=me,d.useStoryblokBridge=I,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
{
"name": "@storyblok/js",
"version": "3.0.3",
"version": "3.0.4",
"description": "SDK to integrate Storyblok into your project using JavaScript.",

@@ -31,3 +31,3 @@ "main": "./dist/storyblok-js.js",

"dependencies": {
"storyblok-js-client": "^6.5.0"
"storyblok-js-client": "^6.6.1"
},

@@ -34,0 +34,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc