@storyblok/js 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +196 -0
- package/dist/storyblok-js.js +6 -0
- package/dist/storyblok-js.mjs +1527 -0
- package/package.json +81 -0
package/README.md
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" align="center">
|
3
|
+
<img src="https://a.storyblok.com/f/88751/1776x360/296788fb19/sb-js.png" alt="Storyblok Logo">
|
4
|
+
</a>
|
5
|
+
<h1 align="center">@storyblok/js</h1>
|
6
|
+
<p align="center">
|
7
|
+
The JavaScript plugin you need to interact with <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Real-time Visual Editing Experience</a>.
|
8
|
+
</p>
|
9
|
+
<br />
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<p align="center">
|
13
|
+
<a href="https://npmjs.com/package/@storyblok/js">
|
14
|
+
<img src="https://img.shields.io/npm/v/@storyblok/js/latest.svg?style=flat-square" alt="Storyblok JS" />
|
15
|
+
</a>
|
16
|
+
<a href="https://npmjs.com/package/@storyblok/js" rel="nofollow">
|
17
|
+
<img src="https://img.shields.io/npm/dt/@storyblok/js.svg?style=flat-square" alt="npm">
|
18
|
+
</a>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p align="center">
|
22
|
+
<a href="https://discord.gg/jKrbAMz">
|
23
|
+
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
|
24
|
+
</a>
|
25
|
+
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
|
26
|
+
<img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
|
27
|
+
</a>
|
28
|
+
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js">
|
29
|
+
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
|
30
|
+
</a>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
## đ Usage
|
34
|
+
|
35
|
+
> If you are first-time user of the Storyblok, read the [Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) guide to get a project ready in less than 5 minutes.
|
36
|
+
|
37
|
+
### Installation
|
38
|
+
|
39
|
+
Install `@storyblok/js`:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
npm install --save-dev @storyblok/js
|
43
|
+
// yarn add -D @storyblok/js
|
44
|
+
```
|
45
|
+
|
46
|
+
#### From a CDN
|
47
|
+
|
48
|
+
Install the file from the CDN:
|
49
|
+
|
50
|
+
```html
|
51
|
+
<script src="https://unpkg.com/@storyblok/js"></script>
|
52
|
+
```
|
53
|
+
|
54
|
+
### Initialization
|
55
|
+
|
56
|
+
Register the plugin on your application and add the [access token](https://www.storyblok.com/docs/api/content-delivery#topics/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) of your Storyblok space. You can also add the `apiPlugin` in case that you want to use the Storyblok API Client:
|
57
|
+
|
58
|
+
```js
|
59
|
+
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
60
|
+
|
61
|
+
const { storyblokApi } = storyblokInit({
|
62
|
+
accessToken: "YOUR_ACCESS_TOKEN",
|
63
|
+
use: [apiPlugin],
|
64
|
+
});
|
65
|
+
```
|
66
|
+
|
67
|
+
That's it! All the features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery#topics/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js), and _Storyblok Bridge_ for [real-time visual editing experience](https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
|
68
|
+
|
69
|
+
> You can enable/disable some of these features if you don't need them, so you save some KB. Please read the "Features and API" section
|
70
|
+
|
71
|
+
### Getting Started
|
72
|
+
|
73
|
+
`@storyblok/js` does three actions when you initialize it:
|
74
|
+
|
75
|
+
- Provides a `storyblokApi` object in your app, which is an instance of [storyblok-js-client](https://github.com/storyblok/storyblok-js-client).
|
76
|
+
- Loads [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) for real-time visual updates.
|
77
|
+
- Provides a `storyblokEditable` function to link editable components to the Storyblok Visual Editor.
|
78
|
+
|
79
|
+
#### 1. Fetching Content
|
80
|
+
|
81
|
+
Inject `storyblokApi`:
|
82
|
+
|
83
|
+
```js
|
84
|
+
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
85
|
+
|
86
|
+
const { storyblokApi } = storyblokInit({
|
87
|
+
accessToken: "YOUR_ACCESS_TOKEN",
|
88
|
+
use: [apiPlugin],
|
89
|
+
});
|
90
|
+
|
91
|
+
const { data } = await storyblokApi.get("cdn/stories", { version: "draft" });
|
92
|
+
```
|
93
|
+
|
94
|
+
> Note: if you don't use `apiPlugin`, you can use your prefered method or function to fetch your data.
|
95
|
+
|
96
|
+
#### 2. Listen to Storyblok Visual Editor events
|
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:
|
99
|
+
|
100
|
+
```js
|
101
|
+
import { storyblokInit, apiPlugin, useStoryblokBridge } from "@storyblok/js";
|
102
|
+
|
103
|
+
const { storyblokApi } = storyblokInit({
|
104
|
+
accessToken: "YOUR_ACCESS_TOKEN",
|
105
|
+
use: [apiPlugin],
|
106
|
+
});
|
107
|
+
|
108
|
+
const { data } = await storyblokApi.get("cdn/stories", { version: "draft" });
|
109
|
+
|
110
|
+
const story = data ? data.story : null;
|
111
|
+
|
112
|
+
useStoryblokBridge(story.id, (story) => (state.story = story));
|
113
|
+
```
|
114
|
+
|
115
|
+
You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) as a third parameter as well:
|
116
|
+
|
117
|
+
```js
|
118
|
+
useStoryblokBridge(story.id, (story) => (state.story = story), {
|
119
|
+
resolveRelations: ["Article.author"],
|
120
|
+
});
|
121
|
+
```
|
122
|
+
|
123
|
+
#### 3. Link your components to Storyblok Visual Editor
|
124
|
+
|
125
|
+
For every component you've defined in your Storyblok space, call the `storyblokEditable` function with the blok content:
|
126
|
+
|
127
|
+
```js
|
128
|
+
import { storyblokEditable } from "@storyblok/js";
|
129
|
+
|
130
|
+
storyblokEditable(blok);
|
131
|
+
```
|
132
|
+
|
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).
|
134
|
+
|
135
|
+
### Features and API
|
136
|
+
|
137
|
+
You can **choose the features to use** when you initialize the plugin. In that way, you can improve Web Performance by optimizing your page load and save some bytes.
|
138
|
+
|
139
|
+
#### Storyblok API
|
140
|
+
|
141
|
+
You can use an `apiOptions` object. This is passed down to the (storyblok-js-client config object](https://github.com/storyblok/storyblok-js-client#class-storyblok):
|
142
|
+
|
143
|
+
```js
|
144
|
+
const { storyblokApi } = storyblokInit({
|
145
|
+
accessToken: "YOUR_ACCESS_TOKEN",
|
146
|
+
apiOptions: {
|
147
|
+
// storyblok-js-client config object
|
148
|
+
cache: { type: "memory" },
|
149
|
+
},
|
150
|
+
use: [apiPlugin],
|
151
|
+
});
|
152
|
+
```
|
153
|
+
|
154
|
+
If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application.
|
155
|
+
|
156
|
+
```js
|
157
|
+
storyblokInit({});
|
158
|
+
```
|
159
|
+
|
160
|
+
#### Storyblok Bridge
|
161
|
+
|
162
|
+
You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
|
163
|
+
|
164
|
+
```js
|
165
|
+
const { storyblokApi } = storyblokInit({
|
166
|
+
bridge: process.env.NODE_ENV !== "production",
|
167
|
+
});
|
168
|
+
```
|
169
|
+
|
170
|
+
If you don't use `useStoryblokBridge`, you have still access to the raw `window.StoryblokBridge`:
|
171
|
+
|
172
|
+
```js
|
173
|
+
const sbBridge = new window.StoryblokBridge(options);
|
174
|
+
|
175
|
+
sbBridge.on(["input", "published", "change"], (event) => {
|
176
|
+
// ...
|
177
|
+
});
|
178
|
+
```
|
179
|
+
|
180
|
+
## đ Related Links
|
181
|
+
|
182
|
+
- **[Storyblok Technology Hub](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Storyblok integrates with every framework so that you are free to choose the best fit for your project. We prepared the technology hub so that you can find selected beginner tutorials, videos, boilerplates, and even cheatsheets all in one place.
|
183
|
+
- **[Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Get a project ready in less than 5 minutes.
|
184
|
+
- **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.
|
185
|
+
|
186
|
+
## âšī¸ More Resources
|
187
|
+
|
188
|
+
### Support
|
189
|
+
|
190
|
+
- Bugs or Feature Requests? [Submit an issue](/../../issues/new).
|
191
|
+
- Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
|
192
|
+
|
193
|
+
### Contributing
|
194
|
+
|
195
|
+
Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/main/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
|
196
|
+
This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.
|
@@ -0,0 +1,6 @@
|
|
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(`
|
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
|
+
* storyblok-js-client v0.0.0-development
|
4
|
+
* Universal JavaScript SDK for Storyblok's API
|
5
|
+
* (c) 2020-2022 Stobylok Team
|
6
|
+
*/function Re(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function xe(n,e,t){if(!Re(e))throw new TypeError("Expected `limit` to be a finite number");if(!Re(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],i=0,o=function(){i++;var a=setTimeout(function(){i--,r.length>0&&o(),s=s.filter(function(f){return f!==a})},t);s.indexOf(a)<0&&s.push(a);var l=r.shift();l.resolve(n.apply(l.self,l.args))},u=function(){var a=arguments,l=this;return new Promise(function(f,h){r.push({resolve:f,reject:h,args:a,self:l}),i<e&&o()})};return u.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(a){a.reject(new throttle.AbortError)}),r.length=0},u}xe.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const Bt=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t};var Lt={nodes:{horizontal_rule:n=>({singleTag:"hr"}),blockquote:n=>({tag:"blockquote"}),bullet_list:n=>({tag:"ul"}),code_block:n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),hard_break:n=>({singleTag:"br"}),heading:n=>({tag:"h"+n.attrs.level}),image:n=>({singleTag:[{tag:"img",attrs:Bt(n.attrs,["src","alt","title"])}]}),list_item:n=>({tag:"li"}),ordered_list:n=>({tag:"ol"}),paragraph:n=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const e=x({},n.attrs),{linktype:t="url"}=n.attrs;return t==="email"&&(e.href="mailto:"+e.href),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class qt{constructor(e){e||(e=Lt),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const i=this.getMatchingMark(s);i&&t.push(this.renderOpeningTag(i.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(function(s){const i={"&":"&","<":"<",">":">",'"':""","'":"'"},o=/[&<>"']/g,u=RegExp(o.source);return s&&u.test(s)?s.replace(o,a=>i[a]):s}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const i=this.getMatchingMark(s);i&&t.push(this.renderClosingTag(i.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(let i in r.attrs){let o=r.attrs[i];o!==null&&(s+=` ${i}="${o}"`)}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){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const Dt=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return((s=0,i)=>[...Array(s)].map(i))(t,(s,i)=>i*r+n)},Z=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const i=n[s],o=t?"":encodeURIComponent(s);let u;u=typeof i=="object"?Z(i,e?e+encodeURIComponent("["+o+"]"):o,Array.isArray(i)):(e?e+encodeURIComponent("["+o+"]"):o)+"="+encodeURIComponent(i),r.push(u)}return r.join("&")};let q={},O={};class Mt{constructor(e,t){if(!t){let i=e.region?"-"+e.region:"",o=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${o}://api${i}.storyblok.com/v2`:`${o}://api${i}.storyblok.com/v1`}let r=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new qt(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=xe(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=Ut.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(i=>e.responseInterceptor(i))}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=O[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const i=this.factoryParamOptions(e,((o={},u=25,a=1)=>D(x({},o),{per_page:u,page:a}))(t,r,s));return this.cacheResponse(e,i)}get(e,t){let r="/"+e;const s=this.factoryParamOptions(r,t);return this.cacheResponse(r,s)}async getAll(e,t={},r){const s=t.per_page||25,i="/"+e,o=i.split("/");r=r||o[o.length-1];const u=await this.makeRequest(i,t,s,1),a=Math.ceil(u.total/s);return((l=[],f)=>l.map(f).reduce((h,d)=>[...h,...d],[]))([u,...await(async(l=[],f)=>Promise.all(l.map(f)))(Dt(1,a),async l=>this.makeRequest(i,t,s,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r="/"+e;return this.throttle("post",r,t)}put(e,t){let r="/"+e;return this.throttle("put",r,t)}delete(e,t){let r="/"+e;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get("cdn/stories/"+e,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let s=[];e[t].forEach(i=>{this.relations[i]&&s.push(this._cleanCopy(this.relations[i]))}),e[t]=s}}}iterateTree(e,t){let r=s=>{if(s!=null){if(s.constructor===Array)for(let i=0;i<s.length;i++)r(s[i]);else if(s.constructor===Object){if(s._stopResolving)return;for(let i in s)(s.component&&s._uid||s.type==="link")&&(this._insertRelations(s,i,t),this._insertLinks(s,i)),r(s[i])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const s=e.link_uuids.length;let i=[];const o=50;for(let u=0;u<s;u+=o){const a=Math.min(s,u+o);i.push(e.link_uuids.slice(u,a))}for(let u=0;u<i.length;u++)(await this.getStories({per_page:o,language:t.language,version:t.version,by_uuids:i[u].join(",")})).data.stories.forEach(a=>{r.push(a)})}else r=e.links;r.forEach(s=>{this.links[s.uuid]=D(x({},s),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const s=e.rel_uuids.length;let i=[];const o=50;for(let u=0;u<s;u+=o){const a=Math.min(s,u+o);i.push(e.rel_uuids.slice(u,a))}for(let u=0;u<i.length;u++)(await this.getStories({per_page:o,language:t.language,version:t.version,by_uuids:i[u].join(",")})).data.stories.forEach(a=>{r.push(a)})}else r=e.rels;r.forEach(s=>{this.relations[s.uuid]=D(x({},s),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&await this.resolveLinks(e,t);for(const s in this.relations)this.iterateTree(this.relations[s],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(s=>{this.iterateTree(s,r)})}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(s,i)=>{let o=Z({url:e,params:t}),u=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await u.get(o);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:h=>Z(h)}),f={data:l.data,headers:l.headers};if(l.headers["per-page"]&&(f=Object.assign({},f,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return i(l);(f.data.story||f.data.stories)&&await this.resolveStories(f.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&u.set(o,f),f.data.cv&&(t.version=="draft"&&O[t.token]!=f.data.cv&&this.flushCache(),O[t.token]=f.data.cv),s(f)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(a=1e3*r,new Promise(f=>setTimeout(f,a))),this.cacheResponse(e,t,r).then(s).catch(i);i(l)}var a})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return O}cacheVersion(){return O[this.accessToken]}setCacheVersion(e){this.accessToken&&(O[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>q[e],getAll:()=>q,set(e,t){q[e]=t},flush(){q={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var It=(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 Mt(e)}},Ft=n=>{if(typeof n!="object"||typeof n._editable=="undefined")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const Ht=(n,e,t={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],s=>{s.action=="input"&&s.story.id===n?e(s.story):window.location.reload()})})}},Jt=(n={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:s={}}=n;s.accessToken=s.accessToken||t;const i={bridge:e,apiOptions:s};let o={};return r.forEach(u=>{o=x(x({},o),u(i))}),e!==!1&&Oe("https://app.storyblok.com/f/storyblok-v2-latest.js"),o};p.apiPlugin=It,p.storyblokEditable=Ft,p.storyblokInit=Jt,p.useStoryblokBridge=Ht,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module"});
|