@storyblok/vue-2
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -1,2 +0,2 @@ | ||
(function(m,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(m=typeof globalThis<"u"?globalThis:m||self,f(m.storyblokVue={},m.Vue))})(this,function(m,f){"use strict";let I=!1;const A=[],L=n=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?o():A.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=n,s.id="storyblok-javascript-bridge",s.onerror=o=>t(o),s.onload=o=>{A.forEach(r=>r()),I=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(s)});var D=Object.defineProperty,x=(n,e,t)=>e in n?D(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>(x(n,typeof e!="symbol"?e+"":e,t),t);function N(n){return!(n!==n||n===1/0||n===-1/0)}function B(n,e,t){if(!N(e))throw new TypeError("Expected `limit` to be a finite number");if(!N(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let o=[],r=0;const i=function(){r++;const a=setTimeout(function(){r--,s.length>0&&i(),o=o.filter(function(u){return u!==a})},t);o.indexOf(a)<0&&o.push(a);const l=s.shift();l.resolve(n.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}),r<e&&i()})};return c.abort=function(){o.forEach(clearTimeout),o=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},c}class y{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,o=e<t?1:-1;return this.arrayFrom(s,(r,i)=>i*o+e)}),h(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),h(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,o)=>[...s,...o],[])),h(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,o=RegExp(s.source);return e&&o.test(e)?e.replace(s,r=>t[r]):e})}stringify(e,t,s){const o=[];for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const i=e[r],c=s?"":encodeURIComponent(r);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent("["+c+"]"):c,Array.isArray(i)):a=(t?t+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(i),o.push(a)}return o.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",o="app.storyblokchina.cn",r="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return o;case"ap":return r;case"ca":return i;default:return t}}}const V=function(n,e){const t={};for(const s in n){const o=n[s];e.indexOf(s)>-1&&o!==null&&(t[s]=o)}return t},F=n=>n==="email",z=()=>({singleTag:"hr"}),W=()=>({tag:"blockquote"}),X=()=>({tag:"ul"}),K=n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),J=()=>({singleTag:"br"}),Y=n=>({tag:`h${n.attrs.level}`}),q=n=>({singleTag:[{tag:"img",attrs:V(n.attrs,["src","alt","title"])}]}),Q=()=>({tag:"li"}),Z=()=>({tag:"ol"}),ee=()=>({tag:"p"}),te=n=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":n.attrs.name,emoji:n.attrs.emoji}}]}),se=()=>({tag:"b"}),oe=()=>({tag:"s"}),re=()=>({tag:"u"}),ne=()=>({tag:"strong"}),ie=()=>({tag:"code"}),ae=()=>({tag:"i"}),le=n=>{if(!n.attrs)return{tag:""};const e=new y().escapeHTML,t={...n.attrs},{linktype:s="url"}=n.attrs;if(delete t.linktype,t.href&&(t.href=e(n.attrs.href||"")),F(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const o in t.custom)t[o]=t.custom[o];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ce=n=>({tag:[{tag:"span",attrs:n.attrs}]}),he=()=>({tag:"sub"}),ue=()=>({tag:"sup"}),de=n=>({tag:[{tag:"span",attrs:n.attrs}]}),pe=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${n.attrs.color};`}}]}:{tag:""}},me=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${n.attrs.color}`}}]}:{tag:""}},w={nodes:{horizontal_rule:z,blockquote:W,bullet_list:X,code_block:K,hard_break:J,heading:Y,image:q,list_item:Q,ordered_list:Z,paragraph:ee,emoji:te},marks:{bold:se,strike:oe,underline:re,strong:ne,code:ie,italic:ae,link:le,styled:ce,subscript:he,superscript:ue,anchor:de,highlight:pe,textStyle:me}},_e=function(n){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,s=RegExp(t.source);return n&&s.test(n)?n.replace(t,o=>e[o]):n};class T{constructor(e){h(this,"marks"),h(this,"nodes"),e||(e=w),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(o=>{s+=this.renderNode(o)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field. | ||
(function(g,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],y):(g=typeof globalThis<"u"?globalThis:g||self,y(g.storyblokVue={},g.Vue))})(this,function(g,y){"use strict";let S=!1;const j=[],U=n=>new Promise((t,e)=>{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}S?r():j.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=n,s.id="storyblok-javascript-bridge",s.onerror=r=>e(r),s.onload=r=>{j.forEach(i=>i()),S=!0,t(r)},document.getElementsByTagName("head")[0].appendChild(s)});var V=Object.defineProperty,H=(n,t,e)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,h=(n,t,e)=>(H(n,typeof t!="symbol"?t+"":t,e),e);function O(n){return!(n!==n||n===1/0||n===-1/0)}function q(n,t,e){if(!O(t))throw new TypeError("Expected `limit` to be a finite number");if(!O(e))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const o=function(){i++;const a=setTimeout(function(){i--,s.length>0&&o(),r=r.filter(function(u){return u!==a})},e);r.indexOf(a)<0&&r.push(a);const l=s.shift();l.resolve(n.apply(l.self,l.args))},c=function(...a){const l=this;return new Promise(function(u,d){s.push({resolve:u,reject:d,args:a,self:l}),i<t&&o()})};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",(t="")=>t.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(t,e=25,s=1)=>({...t,per_page:e,page:s})),h(this,"delay",t=>new Promise(e=>setTimeout(e,t))),h(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),h(this,"range",(t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,(i,o)=>o*r+t)}),h(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),h(this,"flatMap",(t=[],e)=>t.map(e).reduce((s,r)=>[...s,...r],[])),h(this,"escapeHTML",function(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,r=RegExp(s.source);return t&&r.test(t)?t.replace(s,i=>e[i]):t})}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const o=t[i],c=s?"":encodeURIComponent(i);let a;typeof o=="object"?a=this.stringify(o,e?e+encodeURIComponent("["+c+"]"):c,Array.isArray(o)):a=(e?e+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(o),r.push(a)}return r.join("&")}getRegionURL(t){const e="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",i="api-ap.storyblok.com",o="api-ca.storyblok.com";switch(t){case"us":return s;case"cn":return r;case"ap":return i;case"ca":return o;default:return e}}}const F=function(n,t){const e={};for(const s in n){const r=n[s];t.indexOf(s)>-1&&r!==null&&(e[s]=r)}return e},B=n=>n==="email",J=()=>({singleTag:"hr"}),D=()=>({tag:"blockquote"}),Y=()=>({tag:"ul"}),W=n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),X=()=>({singleTag:"br"}),K=n=>({tag:`h${n.attrs.level}`}),G=n=>({singleTag:[{tag:"img",attrs:F(n.attrs,["src","alt","title"])}]}),Q=()=>({tag:"li"}),Z=()=>({tag:"ol"}),tt=()=>({tag:"p"}),et=n=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":n.attrs.name,emoji:n.attrs.emoji}}]}),st=()=>({tag:"b"}),rt=()=>({tag:"s"}),it=()=>({tag:"u"}),nt=()=>({tag:"strong"}),ot=()=>({tag:"code"}),at=()=>({tag:"i"}),lt=n=>{if(!n.attrs)return{tag:""};const t=new v().escapeHTML,e={...n.attrs},{linktype:s="url"}=n.attrs;if(delete e.linktype,e.href&&(e.href=t(n.attrs.href||"")),B(s)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const r in e.custom)e[r]=e.custom[r];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},ct=n=>({tag:[{tag:"span",attrs:n.attrs}]}),ht=()=>({tag:"sub"}),ut=()=>({tag:"sup"}),pt=n=>({tag:[{tag:"span",attrs:n.attrs}]}),dt=n=>{var t;return(t=n.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${n.attrs.color};`}}]}:{tag:""}},gt=n=>{var t;return(t=n.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${n.attrs.color}`}}]}:{tag:""}},C={nodes:{horizontal_rule:J,blockquote:D,bullet_list:Y,code_block:W,hard_break:X,heading:K,image:G,list_item:Q,ordered_list:Z,paragraph:tt,emoji:et},marks:{bold:st,strike:rt,underline:it,strong:nt,code:ot,italic:at,link:lt,styled:ct,subscript:ht,superscript:ut,anchor:pt,highlight:dt,textStyle:gt}},ft=function(n){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},e=/[&<>"']/g,s=RegExp(e.source);return n&&s.test(n)?n.replace(e,r=>t[r]):n};class k{constructor(t){h(this,"marks"),h(this,"nodes"),t||(t=C),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(r=>{s+=this.renderNode(r)}),e.optimizeImages?this.optimizeImages(s,e.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,3 +24,3 @@ ISbRichtext: | ||
type: 'doc' | ||
}`),""}optimizeImages(e,t){let s=0,o=0,r="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(r+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(r+=`height="${t.height}" `,o=t.height),(t.loading==="lazy"||t.loading==="eager")&&(r+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(r+=`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))),r.length>0&&(e=e.replace(/<img/g,`<img ${r.trim()}`));const c=s>0||o>0||i.length>0?`${s}x${o}${i}`:"";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 d={srcset:(l=t.srcset)==null?void 0:l.map(_=>{if(typeof _=="number")return`//${p}/m/${_}x0${i} ${_}w`;if(typeof _=="object"&&_.length===2){let v=0,M=0;return typeof _[0]=="number"&&(v=_[0]),typeof _[1]=="number"&&(M=_[1]),`//${p}/m/${v}x${M}${i} ${v}w`}}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(_=>_).join(", ")};let g="";return d.srcset&&(g+=`srcset="${d.srcset}" `),d.sizes&&(g+=`sizes="${d.sizes}" `),a.replace(/<img/g,`<img ${g.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(o=>{const r=this.getMatchingMark(o);r&&r.tag!==""&&t.push(this.renderOpeningTag(r.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(o=>{t.push(this.renderNode(o))}):e.text?t.push(_e(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(o=>{const r=this.getMatchingMark(o);r&&r.tag!==""&&t.push(this.renderClosingTag(r.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let o=`<${s.tag}`;if(s.attrs)for(const r in s.attrs){const i=s.attrs[r];i!==null&&(o+=` ${r}="${i}"`)}return`${o}${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 ge{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(o=>{s.data=o});for(const o of e.headers.entries())t[o[0]]=o[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 y;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const o=new URL(t),r=new AbortController,{signal:i}=r;let c;this.timeout&&(c=setTimeout(()=>r.abort(),this.timeout));try{const a=await fetch(`${o}`,{method:e,headers:this.headers,body:s,signal:i,...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,o)=>{if(t.test(`${e.status}`))return s(e);const r={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};o(r)})}}var fe={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 S="SB-Agent",R={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:fe.npm_package_version};let k={};const b={};class be{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 o=new y().getRegionURL,r=e.https===!1?"http":"https";e.oauthToken?s=`${r}://${o(e.region)}/v1`:s=`${r}://${o(e.region)}/v2`;const i=new Headers;if(i.set("Content-Type","application/json"),i.set("Accept","application/json"),e.headers)for(const a in e.headers)i.set(a,e.headers[a]);i.has(S)||(i.set(S,R.defaultAgentName),i.set(R.defaultAgentVersion,R.packageVersion));let c=5;e.oauthToken&&(i.set("Authorization",e.oauthToken),c=3),e.rateLimit&&(c=e.rateLimit),e.richTextSchema?this.richTextResolver=new T(e.richTextSchema):this.richTextResolver=new T,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=B(this.throttledRequest,c,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new y,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new ge({baseURL:s,timeout:e.timeout||0,headers:i,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(o=>{s+=e(o.component,o)}),{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,o){const r=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,o));return this.cacheResponse(e,r)}get(e,t,s){t||(t={});const o=`/${e}`,r=this.factoryParamOptions(o,t);return this.client.setFetchOptions(s),this.cacheResponse(o,r)}async getAll(e,t,s,o){const r=(t==null?void 0:t.per_page)||25,i=`/${e}`,c=i.split("/"),a=s||c[c.length-1],l=1,u=await this.makeRequest(i,t,r,l),p=u.total?Math.ceil(u.total/r):1;this.client.setFetchOptions(o);const d=await this.helpers.asyncMap(this.helpers.range(l,p),g=>this.makeRequest(i,t,r,g+1));return this.helpers.flatMap([u,...d],g=>Object.values(g.data[a]))}post(e,t,s){const o=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("post",o,t))}put(e,t,s){const o=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("put",o,t))}delete(e,t,s){const o=`/${e}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("delete",o,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 o=e[t];o&&o.fieldtype=="multilink"&&o.linktype=="story"&&typeof o.id=="string"&&this.links[s][o.id]?o.story=this._cleanCopy(this.links[s][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[s][o.uuid]&&(o.story=this._cleanCopy(this.links[s][o.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,o){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(o,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(r=>this.getStoryReference(o,r)).filter(Boolean)))}iterateTree(e,t,s){const o=r=>{if(r!=null){if(r.constructor===Array)for(let i=0;i<r.length;i++)o(r[i]);else if(r.constructor===Object){if(r._stopResolving)return;for(const i in r)(r.component&&r._uid||r.type==="link")&&(this._insertRelations(r,i,t,s),this._insertLinks(r,i,s)),o(r[i])}}};o(e.content)}async resolveLinks(e,t,s){let o=[];if(e.link_uuids){const r=e.link_uuids.length,i=[],c=50;for(let a=0;a<r;a+=c){const l=Math.min(r,a+c);i.push(e.link_uuids.slice(a,l))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(l=>{o.push(l)})}else o=e.links;o.forEach(r=>{this.links[s][r.uuid]={...r,_stopResolving:!0}})}async resolveRelations(e,t,s){let o=[];if(e.rel_uuids){const r=e.rel_uuids.length,i=[],c=50;for(let a=0;a<r;a+=c){const l=Math.min(r,a+c);i.push(e.rel_uuids.slice(a,l))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(l=>{o.push(l)})}else o=e.rels;o&&o.length>0&&o.forEach(r=>{this.relations[s][r.uuid]={...r,_stopResolving:!0}})}async resolveStories(e,t,s){var o,r;let i=[];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","link"].indexOf(t.resolve_links)>-1&&((o=e.links)!=null&&o.length||(r=e.link_uuids)!=null&&r.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],i,s);e.story?this.iterateTree(e.story,i,s):e.stories.forEach(c=>{this.iterateTree(c,i,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const o=this.helpers.stringify({url:e,params:t}),r=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const i=await r.get(o);if(i)return Promise.resolve(i)}return new Promise(async(i,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(i).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 r.set(o,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),i(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(k[e])},getAll(){return Promise.resolve(k)},set(e,t){return k[e]=t,Promise.resolve(void 0)},flush(){return k={},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 ye=(n={})=>{const{apiOptions:e}=n;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 be(e)}},Te=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let E,j="https://app.storyblok.com/f/storyblok-v2-latest.js";const U=(n,e,t={})=>{var s;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",r=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===n;if(!(!o||!r)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],i=>{i.action==="input"&&i.story.id===n?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===n&&window.location.reload()})})}},ke=(n={})=>{var e,t;const{bridge:s,accessToken:o,use:r=[],apiOptions:i={},richText:c={},bridgeUrl:a}=n;i.accessToken=i.accessToken||o;const l={bridge:s,apiOptions:i};let u={};r.forEach(d=>{u={...u,...d(l)}}),a&&(j=a);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&p&&L(j),E=new T(c.schema),c.resolver&&H(E,c.resolver),u},H=(n,e)=>{n.addNode("blok",t=>{let s="";return t.attrs.body.forEach(o=>{s+=e(o.component,o)}),{html:s}})},Re=n=>!n||!(n!=null&&n.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ee=(n,e,t)=>{let s=t||E;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Re(n)?"":(e&&(s=new T(e.schema),e.resolver&&H(s,e.resolver)),s.render(n))};function Oe(n,e,t,s,o,r,i,c){var a=typeof n=="function"?n.options:n;e&&(a.render=e,a.staticRenderFns=t,a._compiled=!0),s&&(a.functional=!0),r&&(a._scopeId="data-v-"+r);var l;if(i?(l=function(d){d=d||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!d&&typeof __VUE_SSR_CONTEXT__<"u"&&(d=__VUE_SSR_CONTEXT__),o&&o.call(this,d),d&&d._registeredComponents&&d._registeredComponents.add(i)},a._ssrRegister=l):o&&(l=c?function(){o.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:o),l)if(a.functional){a._injectStyles=l;var u=a.render;a.render=function(g,_){return l.call(_),u(g,_)}}else{var p=a.beforeCreate;a.beforeCreate=p?[].concat(p,l):[l]}return{exports:n,options:a}}const ve={props:{blok:{type:Object}}};var Ie=function(){var e=this,t=e._self._c;return t(e.blok.component,e._g(e._b({tag:"component"},"component",{...e.$props,...e.$attrs},!1),e.$listeners))},Ae=[],Ne=Oe(ve,Ie,Ae,!1,null,null,null,null);const P=Ne.exports,C=n=>{console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization. | ||
`)},we=(n,e={},t={})=>{const s=f.ref(null),o=$();return f.onMounted(async()=>{if(o){const{data:r}=await o.get(`cdn/stories/${n}`,e);s.value=r.story}else C("useStoryblok");s.value&&s.value.id&&U(s.value.id,r=>s.value=r,t)}),s},Se={bind:(n,e)=>{if(e.value){const t=Te(e.value);n.setAttribute("data-blok-c",t["data-blok-c"]),n.setAttribute("data-blok-uid",t["data-blok-uid"]),n.classList.add("storyblok__outline")}}};let O=null;const $=()=>(O||C("useStoryblokApi"),O),G={install(n,e={}){n.directive("editable",Se),n.component("StoryblokComponent",P);const{storyblokApi:t}=ke(e);O=t,n.prototype.$storyblokApi=t}};typeof window<"u"&&window.Vue&&window.Vue.use(G),m.RichTextSchema=w,m.StoryblokComponent=P,m.StoryblokVue=G,m.apiPlugin=ye,m.renderRichText=Ee,m.useStoryblok=we,m.useStoryblokApi=$,m.useStoryblokBridge=U,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
}`),""}optimizeImages(t,e){let s=0,r=0,i="",o="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),typeof e.height=="number"&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),(e.loading==="lazy"||e.loading==="eager")&&(i+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(o+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(o+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(o+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(o+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(o+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(o+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(o+=`:rotate(${e.filters.rotate})`),o.length>0&&(o="/filters"+o))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const c=s>0||r>0||o.length>0?`${s}x${r}${o}`:"";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/${c}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var l,u;const d=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(d&&d.length>0){const p={srcset:(l=e.srcset)==null?void 0:l.map(f=>{if(typeof f=="number")return`//${d}/m/${f}x0${o} ${f}w`;if(typeof f=="object"&&f.length===2){let T=0,z=0;return typeof f[0]=="number"&&(T=f[0]),typeof f[1]=="number"&&(z=f[1]),`//${d}/m/${T}x${z}${o} ${T}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let m="";return p.srcset&&(m+=`srcset="${p.srcset}" `),p.sizes&&(m+=`sizes="${p.sizes}" `),a.replace(/<img/g,`<img ${m.trim()}`)}return a})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach(r=>{e.push(this.renderNode(r))}):t.text?e.push(ft(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderClosingTag(i.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const o=s.attrs[i];o!==null&&(r+=` ${i}="${o}"`)}return`${r}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")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 mt{constructor(t){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=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&t.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}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:""};t.status!==204&&await t.json().then(r=>{s.data=r});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(t==="get"){const a=new v;e=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:o}=i;let c;this.timeout&&(c=setTimeout(()=>i.abort(),this.timeout));try{const a=await fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:o,...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(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}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);const i={message:t.statusText,status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug};r(i)})}}var yt={npm_package_version:"6.6.1"};const P="SB-Agent",w={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:yt.npm_package_version};let _={};const b={};class bt{constructor(t,e){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=t.endpoint||e;const r=new v().getRegionURL,i=t.https===!1?"http":"https";t.oauthToken?s=`${i}://${r(t.region)}/v1`:s=`${i}://${r(t.region)}/v2`;const o=new Headers;if(o.set("Content-Type","application/json"),o.set("Accept","application/json"),t.headers)for(const a in t.headers)o.set(a,t.headers[a]);o.has(P)||(o.set(P,w.defaultAgentName),o.set(w.defaultAgentVersion,w.packageVersion));let c=5;t.oauthToken&&(o.set("Authorization",t.oauthToken),c=3),t.rateLimit&&(c=t.rateLimit),t.richTextSchema?this.richTextResolver=new k(t.richTextSchema):this.richTextResolver=new k,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=q(this.throttledRequest,c,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new mt({baseURL:s,timeout:t.timeout||0,headers:o,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let s="";return e.attrs.body&&e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})}parseParams(t){return t.token||(t.token=this.getToken()),t.cv||(t.cv=b[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 i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e,s){e||(e={});const r=`/${t}`,i=this.factoryParamOptions(r,e);return this.client.setFetchOptions(s),this.cacheResponse(r,i)}async getAll(t,e,s,r){const i=(e==null?void 0:e.per_page)||25,o=`/${t}`,c=o.split("/"),a=s||c[c.length-1],l=1,u=await this.makeRequest(o,e,i,l),d=u.total?Math.ceil(u.total/i):1;this.client.setFetchOptions(r);const p=await this.helpers.asyncMap(this.helpers.range(l,d),m=>this.makeRequest(o,e,i,m+1));return this.helpers.flatMap([u,...p],m=>Object.values(m.data[a]))}post(t,e,s){const r=`/${t}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("post",r,e))}put(t,e,s){const r=`/${t}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("put",r,e))}delete(t,e,s){const r=`/${t}`;return this.client.setFetchOptions(s),Promise.resolve(this.throttle("delete",r,e))}getStories(t,e){return this.client.setFetchOptions(e),this.get("cdn/stories",t)}getStory(t,e,s){return this.client.setFetchOptions(s),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&&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(t,e){return this.relations[t][e]?(this.stringifiedStoriesCache[e]||(this.stringifiedStoriesCache[e]=JSON.stringify(this.relations[t][e])),JSON.parse(this.stringifiedStoriesCache[e])):e}_insertRelations(t,e,s,r){s.indexOf(`${t.component}.${e}`)>-1&&(typeof t[e]=="string"?t[e]=this.getStoryReference(r,t[e]):Array.isArray(t[e])&&(t[e]=t[e].map(i=>this.getStoryReference(r,i)).filter(Boolean)))}iterateTree(t,e,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let o=0;o<i.length;o++)r(i[o]);else if(i.constructor===Object){if(i._stopResolving)return;for(const o in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,o,e,s),this._insertLinks(i,o,s)),r(i[o])}}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const i=t.link_uuids.length,o=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);o.push(t.link_uuids.slice(a,l))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:o[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const i=t.rel_uuids.length,o=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);o.push(t.rel_uuids.slice(a,l))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:o[a].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{r.push(l)})}else r=t.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,s){var r,i;let o=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(o=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url","link"].indexOf(e.resolve_links)>-1&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],o,s);t.story?this.iterateTree(t.story,o,s):t.stories.forEach(c=>{this.iterateTree(c,o,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){(typeof s>"u"||!s)&&(s=0);const r=this.helpers.stringify({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const o=await i.get(r);if(o)return Promise.resolve(o)}return new Promise(async(o,c)=>{var a;try{const l=await this.throttle("get",t,e);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(t,e,s).then(o).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 d=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,e,`${d}`)}return e.version==="published"&&t!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&e.token&&(e.version==="draft"&&b[e.token]!=u.data.cv&&await this.flushCache(),b[e.token]=e.cv?e.cv:u.data.cv),o(u)}catch(l){c(l)}})}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return b}cacheVersion(){return b[this.accessToken]}setCacheVersion(t){this.accessToken&&(b[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(_[t])},getAll(){return Promise.resolve(_)},set(t,e){return _[t]=e,Promise.resolve(void 0)},flush(){return _={},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 vt=(n={})=>{const{apiOptions:t}=n;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new bt(t)}},kt=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const t=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}:{}}catch{return{}}};let $,A="https://app.storyblok.com/f/storyblok-v2-latest.js";const E=(n,t,e={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===n;if(!(!r||!i)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],o=>{o.action==="input"&&o.story.id===n?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===n&&window.location.reload()})})}},_t=(n={})=>{var t,e;const{bridge:s,accessToken:r,use:i=[],apiOptions:o={},richText:c={},bridgeUrl:a}=n;o.accessToken=o.accessToken||r;const l={bridge:s,apiOptions:o};let u={};i.forEach(p=>{u={...u,...p(l)}}),a&&(A=a);const d=!(typeof window>"u")&&((e=(t=window.location)==null?void 0:t.search)==null?void 0:e.includes("_storyblok_tk"));return s!==!1&&d&&U(A),$=new k(c.schema),c.resolver&&I($,c.resolver),u},I=(n,t)=>{n.addNode("blok",e=>{let s="";return e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})},wt=n=>!n||!(n!=null&&n.content.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule")),$t=(n,t,e)=>{let s=e||$;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return wt(n)?"":(t&&(s=new k(t.schema),t.resolver&&I(s,t.resolver)),s.render(n))};function Rt(n,t,e,s,r,i,o,c){var a=typeof n=="function"?n.options:n;t&&(a.render=t,a.staticRenderFns=e,a._compiled=!0),s&&(a.functional=!0),i&&(a._scopeId="data-v-"+i);var l;if(o?(l=function(p){p=p||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!p&&typeof __VUE_SSR_CONTEXT__<"u"&&(p=__VUE_SSR_CONTEXT__),r&&r.call(this,p),p&&p._registeredComponents&&p._registeredComponents.add(o)},a._ssrRegister=l):r&&(l=c?function(){r.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:r),l)if(a.functional){a._injectStyles=l;var u=a.render;a.render=function(m,f){return l.call(f),u(m,f)}}else{var d=a.beforeCreate;a.beforeCreate=d?[].concat(d,l):[l]}return{exports:n,options:a}}const Tt={props:{blok:{type:Object}}};var St=function(){var t=this,e=t._self._c;return e(t.blok.component,t._g(t._b({tag:"component"},"component",{...t.$props,...t.$attrs},!1),t.$listeners))},jt=[],Ot=Rt(Tt,St,jt,!1,null,null,null,null);const x=Ot.exports,N=n=>{console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization. | ||
`)},Ct=(n,t={},e={})=>{const s=y.ref(null),r=M();return y.onMounted(async()=>{if(r){const{data:i}=await r.get(`cdn/stories/${n}`,t);s.value=i.story}else N("useStoryblok");s.value&&s.value.id&&E(s.value.id,i=>s.value=i,e)}),s},Pt={bind:(n,t)=>{if(t.value){const e=kt(t.value);n.setAttribute("data-blok-c",e["data-blok-c"]),n.setAttribute("data-blok-uid",e["data-blok-uid"]),n.classList.add("storyblok__outline")}}};let R=null;const M=()=>(R||N("useStoryblokApi"),R),L={install(n,t={}){n.directive("editable",Pt),n.component("StoryblokComponent",x);const{storyblokApi:e}=_t(t);R=e,n.prototype.$storyblokApi=e}};typeof window<"u"&&window.Vue&&window.Vue.use(L),g.RichTextSchema=C,g.StoryblokComponent=x,g.StoryblokVue=L,g.apiPlugin=vt,g.renderRichText=$t,g.useStoryblok=Ct,g.useStoryblokApi=M,g.useStoryblokBridge=E,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "@storyblok/vue-2", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Storyblok SDK for Vue 2 to interact with Storyblok API and connect to Storyblok Visual Editor", | ||
@@ -29,3 +29,3 @@ "main": "./dist/storyblok-vue-2.js", | ||
"dependencies": { | ||
"@storyblok/js": "^3.0.2" | ||
"@storyblok/js": "^3.0.4" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
0
75365
1086
+ Added@storyblok/js@3.1.7(transitive)
+ Addedstoryblok-js-client@6.10.2(transitive)
- Removed@storyblok/js@3.1.8(transitive)
- Removedstoryblok-js-client@6.10.3(transitive)
Updated@storyblok/js@^3.0.4