@storyblok/js 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,7 +95,7 @@ const { data } = await storyblokApi.get("cdn/stories", { version: "draft" });
95
95
 
96
96
  #### 2. Listen to Storyblok Visual Editor events
97
97
 
98
- Use `useStoryBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
98
+ Use `useStoryblokBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
99
99
 
100
100
  ```js
101
101
  import { storyblokInit, apiPlugin, useStoryblokBridge } from "@storyblok/js";
@@ -122,15 +122,26 @@ useStoryblokBridge(story.id, (story) => (state.story = story), {
122
122
 
123
123
  #### 3. Link your components to Storyblok Visual Editor
124
124
 
125
- For every component you've defined in your Storyblok space, call the `storyblokEditable` function with the blok content:
125
+ To link your app and Storyblok components together will depend on the framework you are using. But, in the end, you must add the `data-blok-c` and `data-blok-uid` attributes, and the `storyblok__outline` class.
126
+
127
+ We provide you a `storyblokEditable` function to make that easier. As an example, you can check in [@storyblok/vue](https://github.com/storyblok/storyblok-vue/blob/master/lib/index.js#L7-L9) how we use a `v-editable` directive for that:
126
128
 
127
129
  ```js
128
130
  import { storyblokEditable } from "@storyblok/js";
129
131
 
130
- storyblokEditable(blok);
132
+ const vEditableDirective = {
133
+ bind(el, binding) {
134
+ if (binding.value) {
135
+ const options = storyblokEditable(binding.value);
136
+ el.setAttribute("data-blok-c", options["data-blok-c"]);
137
+ el.setAttribute("data-blok-uid", options["data-blok-uid"]);
138
+ el.classList.add("storyblok__outline");
139
+ }
140
+ },
141
+ };
131
142
  ```
132
143
 
133
- Where `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
144
+ At this point, you'll have your app connected to Storyblok with the real-time editing experience fully enabled.
134
145
 
135
146
  ### Features and API
136
147
 
@@ -1,4 +1,4 @@
1
- var zt=Object.defineProperty,Vt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Te=Object.getOwnPropertySymbols;var Wt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var Se=(p,m,y)=>m in p?zt(p,m,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[m]=y,x=(p,m)=>{for(var y in m||(m={}))Wt.call(m,y)&&Se(p,y,m[y]);if(Te)for(var y of Te(m))Xt.call(m,y)&&Se(p,y,m[y]);return p},D=(p,m)=>Vt(p,Kt(m));(function(p,m){typeof exports=="object"&&typeof module!="undefined"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(p=typeof globalThis!="undefined"?globalThis:p||self,m(p.storyblok={}))})(this,function(p){"use strict";let m=!1;const y=[],Oe=n=>(window.storyblokRegisterEvent=e=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}m?e():y.push(e)},new Promise((e,t)=>{if(document.getElementById("storyblok-javascript-bridge"))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{y.forEach(i=>i()),m=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)}));var M={exports:{}},Q=function(e,t){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(t,s)}},Ce=Q,E=Object.prototype.toString;function I(n){return E.call(n)==="[object Array]"}function F(n){return typeof n=="undefined"}function Ae(n){return n!==null&&!F(n)&&n.constructor!==null&&!F(n.constructor)&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function je(n){return E.call(n)==="[object ArrayBuffer]"}function $e(n){return typeof FormData!="undefined"&&n instanceof FormData}function Pe(n){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&n.buffer instanceof ArrayBuffer,e}function Ne(n){return typeof n=="string"}function _e(n){return typeof n=="number"}function ee(n){return n!==null&&typeof n=="object"}function j(n){if(E.call(n)!=="[object Object]")return!1;var e=Object.getPrototypeOf(n);return e===null||e===Object.prototype}function Ue(n){return E.call(n)==="[object Date]"}function Be(n){return E.call(n)==="[object File]"}function Le(n){return E.call(n)==="[object Blob]"}function te(n){return E.call(n)==="[object Function]"}function qe(n){return ee(n)&&te(n.pipe)}function De(n){return typeof URLSearchParams!="undefined"&&n instanceof URLSearchParams}function Me(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Ie(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function H(n,e){if(!(n===null||typeof n=="undefined"))if(typeof n!="object"&&(n=[n]),I(n))for(var t=0,r=n.length;t<r;t++)e.call(null,n[t],t,n);else for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.call(null,n[s],s,n)}function J(){var n={};function e(s,i){j(n[i])&&j(s)?n[i]=J(n[i],s):j(s)?n[i]=J({},s):I(s)?n[i]=s.slice():n[i]=s}for(var t=0,r=arguments.length;t<r;t++)H(arguments[t],e);return n}function Fe(n,e,t){return H(e,function(s,i){t&&typeof s=="function"?n[i]=Ce(s,t):n[i]=s}),n}function He(n){return n.charCodeAt(0)===65279&&(n=n.slice(1)),n}var b={isArray:I,isArrayBuffer:je,isBuffer:Ae,isFormData:$e,isArrayBufferView:Pe,isString:Ne,isNumber:_e,isObject:ee,isPlainObject:j,isUndefined:F,isDate:Ue,isFile:Be,isBlob:Le,isFunction:te,isStream:qe,isURLSearchParams:De,isStandardBrowserEnv:Ie,forEach:H,merge:J,extend:Fe,trim:Me,stripBOM:He},T=b;function re(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ne=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(T.isURLSearchParams(t))s=t.toString();else{var i=[];T.forEach(t,function(a,l){a===null||typeof a=="undefined"||(T.isArray(a)?l=l+"[]":a=[a],T.forEach(a,function(h){T.isDate(h)?h=h.toISOString():T.isObject(h)&&(h=JSON.stringify(h)),i.push(re(l)+"="+re(h))}))}),s=i.join("&")}if(s){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},Je=b;function $(){this.handlers=[]}$.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1},$.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},$.prototype.forEach=function(e){Je.forEach(this.handlers,function(r){r!==null&&e(r)})};var ze=$,Ve=b,Ke=function(e,t){Ve.forEach(e,function(s,i){i!==t&&i.toUpperCase()===t.toUpperCase()&&(e[t]=s,delete e[i])})},se=function(e,t,r,s,i){return e.config=t,r&&(e.code=r),e.request=s,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},We=se,ie=function(e,t,r,s,i){var o=new Error(e);return We(o,t,r,s,i)},Xe=ie,Ge=function(e,t,r){var s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(Xe("Request failed with status code "+r.status,r.config,null,r.request,r))},P=b,Ye=P.isStandardBrowserEnv()?function(){return{write:function(t,r,s,i,o,u){var a=[];a.push(t+"="+encodeURIComponent(r)),P.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),P.isString(i)&&a.push("path="+i),P.isString(o)&&a.push("domain="+o),u===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),Ze=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Qe=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},et=Ze,tt=Qe,rt=function(e,t){return e&&!et(t)?tt(e,t):t},z=b,nt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],st=function(e){var t={},r,s,i;return e&&z.forEach(e.split(`
1
+ var zt=Object.defineProperty,Vt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Te=Object.getOwnPropertySymbols;var Wt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var Se=(p,m,y)=>m in p?zt(p,m,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[m]=y,x=(p,m)=>{for(var y in m||(m={}))Wt.call(m,y)&&Se(p,y,m[y]);if(Te)for(var y of Te(m))Xt.call(m,y)&&Se(p,y,m[y]);return p},D=(p,m)=>Vt(p,Kt(m));(function(p,m){typeof exports=="object"&&typeof module!="undefined"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(p=typeof globalThis!="undefined"?globalThis:p||self,m(p.storyblok={}))})(this,function(p){"use strict";let m=!1;const y=[],Oe=n=>new Promise((e,t)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}m?s():y.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{y.forEach(i=>i()),m=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var M={exports:{}},Q=function(e,t){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(t,s)}},Ce=Q,E=Object.prototype.toString;function I(n){return E.call(n)==="[object Array]"}function F(n){return typeof n=="undefined"}function Ae(n){return n!==null&&!F(n)&&n.constructor!==null&&!F(n.constructor)&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function je(n){return E.call(n)==="[object ArrayBuffer]"}function $e(n){return typeof FormData!="undefined"&&n instanceof FormData}function Pe(n){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&n.buffer instanceof ArrayBuffer,e}function Ne(n){return typeof n=="string"}function _e(n){return typeof n=="number"}function ee(n){return n!==null&&typeof n=="object"}function j(n){if(E.call(n)!=="[object Object]")return!1;var e=Object.getPrototypeOf(n);return e===null||e===Object.prototype}function Ue(n){return E.call(n)==="[object Date]"}function Be(n){return E.call(n)==="[object File]"}function Le(n){return E.call(n)==="[object Blob]"}function te(n){return E.call(n)==="[object Function]"}function qe(n){return ee(n)&&te(n.pipe)}function De(n){return typeof URLSearchParams!="undefined"&&n instanceof URLSearchParams}function Me(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Ie(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function H(n,e){if(!(n===null||typeof n=="undefined"))if(typeof n!="object"&&(n=[n]),I(n))for(var t=0,r=n.length;t<r;t++)e.call(null,n[t],t,n);else for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.call(null,n[s],s,n)}function J(){var n={};function e(s,i){j(n[i])&&j(s)?n[i]=J(n[i],s):j(s)?n[i]=J({},s):I(s)?n[i]=s.slice():n[i]=s}for(var t=0,r=arguments.length;t<r;t++)H(arguments[t],e);return n}function Fe(n,e,t){return H(e,function(s,i){t&&typeof s=="function"?n[i]=Ce(s,t):n[i]=s}),n}function He(n){return n.charCodeAt(0)===65279&&(n=n.slice(1)),n}var b={isArray:I,isArrayBuffer:je,isBuffer:Ae,isFormData:$e,isArrayBufferView:Pe,isString:Ne,isNumber:_e,isObject:ee,isPlainObject:j,isUndefined:F,isDate:Ue,isFile:Be,isBlob:Le,isFunction:te,isStream:qe,isURLSearchParams:De,isStandardBrowserEnv:Ie,forEach:H,merge:J,extend:Fe,trim:Me,stripBOM:He},T=b;function re(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ne=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(T.isURLSearchParams(t))s=t.toString();else{var i=[];T.forEach(t,function(a,l){a===null||typeof a=="undefined"||(T.isArray(a)?l=l+"[]":a=[a],T.forEach(a,function(h){T.isDate(h)?h=h.toISOString():T.isObject(h)&&(h=JSON.stringify(h)),i.push(re(l)+"="+re(h))}))}),s=i.join("&")}if(s){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},Je=b;function $(){this.handlers=[]}$.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1},$.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},$.prototype.forEach=function(e){Je.forEach(this.handlers,function(r){r!==null&&e(r)})};var ze=$,Ve=b,Ke=function(e,t){Ve.forEach(e,function(s,i){i!==t&&i.toUpperCase()===t.toUpperCase()&&(e[t]=s,delete e[i])})},se=function(e,t,r,s,i){return e.config=t,r&&(e.code=r),e.request=s,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},We=se,ie=function(e,t,r,s,i){var o=new Error(e);return We(o,t,r,s,i)},Xe=ie,Ge=function(e,t,r){var s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(Xe("Request failed with status code "+r.status,r.config,null,r.request,r))},P=b,Ye=P.isStandardBrowserEnv()?function(){return{write:function(t,r,s,i,o,u){var a=[];a.push(t+"="+encodeURIComponent(r)),P.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),P.isString(i)&&a.push("path="+i),P.isString(o)&&a.push("domain="+o),u===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),Ze=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Qe=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},et=Ze,tt=Qe,rt=function(e,t){return e&&!et(t)?tt(e,t):t},z=b,nt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],st=function(e){var t={},r,s,i;return e&&z.forEach(e.split(`
2
2
  `),function(u){if(i=u.indexOf(":"),r=z.trim(u.substr(0,i)).toLowerCase(),s=z.trim(u.substr(i+1)),r){if(t[r]&&nt.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([s]):t[r]=t[r]?t[r]+", "+s:s}}),t},ae=b,it=ae.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function s(i){var o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(o){var u=ae.isString(o)?s(o):o;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}(),N=b,at=Ge,ot=Ye,ut=ne,lt=rt,ct=st,dt=it,V=ie,oe=function(e){return new Promise(function(r,s){var i=e.data,o=e.headers,u=e.responseType;N.isFormData(i)&&delete o["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(l+":"+f)}var h=lt(e.baseURL,e.url);a.open(e.method.toUpperCase(),ut(h,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function d(){if(!!a){var R="getAllResponseHeaders"in a?ct(a.getAllResponseHeaders()):null,k=!u||u==="text"||u==="json"?a.responseText:a.response,A={data:k,status:a.status,statusText:a.statusText,headers:R,config:e,request:a};at(r,s,A),a=null}}if("onloadend"in a?a.onloadend=d:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(d)},a.onabort=function(){!a||(s(V("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){s(V("Network Error",e,null,a)),a=null},a.ontimeout=function(){var k="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(k=e.timeoutErrorMessage),s(V(k,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",a)),a=null},N.isStandardBrowserEnv()){var c=(e.withCredentials||dt(h))&&e.xsrfCookieName?ot.read(e.xsrfCookieName):void 0;c&&(o[e.xsrfHeaderName]=c)}"setRequestHeader"in a&&N.forEach(o,function(k,A){typeof i=="undefined"&&A.toLowerCase()==="content-type"?delete o[A]:a.setRequestHeader(A,k)}),N.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),u&&u!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(k){!a||(a.abort(),s(k),a=null)}),i||(i=null),a.send(i)})},v=b,ue=Ke,ft=se,ht={"Content-Type":"application/x-www-form-urlencoded"};function le(n,e){!v.isUndefined(n)&&v.isUndefined(n["Content-Type"])&&(n["Content-Type"]=e)}function pt(){var n;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(n=oe),n}function mt(n,e,t){if(v.isString(n))try{return(e||JSON.parse)(n),v.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}var _={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:pt(),transformRequest:[function(e,t){return ue(t,"Accept"),ue(t,"Content-Type"),v.isFormData(e)||v.isArrayBuffer(e)||v.isBuffer(e)||v.isStream(e)||v.isFile(e)||v.isBlob(e)?e:v.isArrayBufferView(e)?e.buffer:v.isURLSearchParams(e)?(le(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):v.isObject(e)||t&&t["Content-Type"]==="application/json"?(le(t,"application/json"),mt(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,s=t&&t.forcedJSONParsing,i=!r&&this.responseType==="json";if(i||s&&v.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?ft(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};_.headers={common:{Accept:"application/json, text/plain, */*"}},v.forEach(["delete","get","head"],function(e){_.headers[e]={}}),v.forEach(["post","put","patch"],function(e){_.headers[e]=v.merge(ht)});var K=_,vt=b,gt=K,yt=function(e,t,r){var s=this||gt;return vt.forEach(r,function(o){e=o.call(s,e,t)}),e},ce=function(e){return!!(e&&e.__CANCEL__)},de=b,W=yt,bt=ce,wt=K;function X(n){n.cancelToken&&n.cancelToken.throwIfRequested()}var kt=function(e){X(e),e.headers=e.headers||{},e.data=W.call(e,e.data,e.headers,e.transformRequest),e.headers=de.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),de.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var t=e.adapter||wt.adapter;return t(e).then(function(s){return X(e),s.data=W.call(e,s.data,s.headers,e.transformResponse),s},function(s){return bt(s)||(X(e),s&&s.response&&(s.response.data=W.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},g=b,fe=function(e,t){t=t||{};var r={},s=["url","method","data"],i=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],u=["validateStatus"];function a(d,c){return g.isPlainObject(d)&&g.isPlainObject(c)?g.merge(d,c):g.isPlainObject(c)?g.merge({},c):g.isArray(c)?c.slice():c}function l(d){g.isUndefined(t[d])?g.isUndefined(e[d])||(r[d]=a(void 0,e[d])):r[d]=a(e[d],t[d])}g.forEach(s,function(c){g.isUndefined(t[c])||(r[c]=a(void 0,t[c]))}),g.forEach(i,l),g.forEach(o,function(c){g.isUndefined(t[c])?g.isUndefined(e[c])||(r[c]=a(void 0,e[c])):r[c]=a(void 0,t[c])}),g.forEach(u,function(c){c in t?r[c]=a(e[c],t[c]):c in e&&(r[c]=a(void 0,e[c]))});var f=s.concat(i).concat(o).concat(u),h=Object.keys(e).concat(Object.keys(t)).filter(function(c){return f.indexOf(c)===-1});return g.forEach(h,l),r},Et={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},he=Et,G={};["object","boolean","number","function","string","symbol"].forEach(function(n,e){G[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});var pe={},Rt=he.version.split(".");function me(n,e){for(var t=e?e.split("."):Rt,r=n.split("."),s=0;s<3;s++){if(t[s]>r[s])return!0;if(t[s]<r[s])return!1}return!1}G.transitional=function(e,t,r){var s=t&&me(t);function i(o,u){return"[Axios v"+he.version+"] Transitional option '"+o+"'"+u+(r?". "+r:"")}return function(o,u,a){if(e===!1)throw new Error(i(u," has been removed in "+t));return s&&!pe[u]&&(pe[u]=!0,console.warn(i(u," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,u,a):!0}};function xt(n,e,t){if(typeof n!="object")throw new TypeError("options must be an object");for(var r=Object.keys(n),s=r.length;s-- >0;){var i=r[s],o=e[i];if(o){var u=n[i],a=u===void 0||o(u,i,n);if(a!==!0)throw new TypeError("option "+i+" must be "+a);continue}if(t!==!0)throw Error("Unknown option "+i)}}var Tt={isOlderVersion:me,assertOptions:xt,validators:G},ve=b,St=ne,ge=ze,ye=kt,U=fe,be=Tt,S=be.validators;function C(n){this.defaults=n,this.interceptors={request:new ge,response:new ge}}C.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=U(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&be.assertOptions(t,{silentJSONParsing:S.transitional(S.boolean,"1.0.0"),forcedJSONParsing:S.transitional(S.boolean,"1.0.0"),clarifyTimeoutError:S.transitional(S.boolean,"1.0.0")},!1);var r=[],s=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(s=s&&d.synchronous,r.unshift(d.fulfilled,d.rejected))});var i=[];this.interceptors.response.forEach(function(d){i.push(d.fulfilled,d.rejected)});var o;if(!s){var u=[ye,void 0];for(Array.prototype.unshift.apply(u,r),u=u.concat(i),o=Promise.resolve(e);u.length;)o=o.then(u.shift(),u.shift());return o}for(var a=e;r.length;){var l=r.shift(),f=r.shift();try{a=l(a)}catch(h){f(h);break}}try{o=ye(a)}catch(h){return Promise.reject(h)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},C.prototype.getUri=function(e){return e=U(this.defaults,e),St(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ve.forEach(["delete","get","head","options"],function(e){C.prototype[e]=function(t,r){return this.request(U(r||{},{method:e,url:t,data:(r||{}).data}))}}),ve.forEach(["post","put","patch"],function(e){C.prototype[e]=function(t,r,s){return this.request(U(s||{},{method:e,url:t,data:r}))}});var Ot=C;function Y(n){this.message=n}Y.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Y.prototype.__CANCEL__=!0;var we=Y,Ct=we;function B(n){if(typeof n!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var t=this;n(function(s){t.reason||(t.reason=new Ct(s),e(t.reason))})}B.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},B.source=function(){var e,t=new B(function(s){e=s});return{token:t,cancel:e}};var At=B,jt=function(e){return function(r){return e.apply(null,r)}},$t=function(e){return typeof e=="object"&&e.isAxiosError===!0},ke=b,Pt=Q,L=Ot,Nt=fe,_t=K;function Ee(n){var e=new L(n),t=Pt(L.prototype.request,e);return ke.extend(t,L.prototype,e),ke.extend(t,e),t}var w=Ee(_t);w.Axios=L,w.create=function(e){return Ee(Nt(w.defaults,e))},w.Cancel=we,w.CancelToken=At,w.isCancel=ce,w.all=function(e){return Promise.all(e)},w.spread=jt,w.isAxiosError=$t,M.exports=w,M.exports.default=w;var Ut=M.exports;/*!
3
3
  * storyblok-js-client v0.0.0-development
4
4
  * Universal JavaScript SDK for Storyblok's API
@@ -20,17 +20,19 @@ var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
20
20
  let loaded = false;
21
21
  const callbacks = [];
22
22
  const loadBridge = (src) => {
23
- window.storyblokRegisterEvent = (cb) => {
24
- if (window.location === window.parent.location) {
25
- console.warn("You are not in Draft Mode or in the Visual Editor.");
26
- return;
27
- }
28
- if (!loaded)
29
- callbacks.push(cb);
30
- else
31
- cb();
32
- };
33
23
  return new Promise((resolve, reject) => {
24
+ if (typeof window === "undefined")
25
+ return;
26
+ window.storyblokRegisterEvent = (cb) => {
27
+ if (window.location === window.parent.location) {
28
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
29
+ return;
30
+ }
31
+ if (!loaded)
32
+ callbacks.push(cb);
33
+ else
34
+ cb();
35
+ };
34
36
  if (document.getElementById("storyblok-javascript-bridge"))
35
37
  return;
36
38
  const script = document.createElement("script");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
5
5
  "main": "./dist/storyblok-js.js",
6
6
  "module": "./dist/storyblok-js.mjs",