@storyblok/js 1.8.6 → 2.0.0

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.
@@ -5,19 +5,18 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a2, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a2, prop, b[prop]);
8
+ var __spreadValues = (a, b2) => {
9
+ for (var prop in b2 || (b2 = {}))
10
+ if (__hasOwnProp.call(b2, prop))
11
+ __defNormalProp(a, prop, b2[prop]);
12
12
  if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a2, prop, b[prop]);
13
+ for (var prop of __getOwnPropSymbols(b2)) {
14
+ if (__propIsEnum.call(b2, prop))
15
+ __defNormalProp(a, prop, b2[prop]);
16
16
  }
17
- return a2;
17
+ return a;
18
18
  };
19
- var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
20
- import e from "axios";
19
+ var __spreadProps = (a, b2) => __defProps(a, __getOwnPropDescs(b2));
21
20
  let loaded = false;
22
21
  const callbacks = [];
23
22
  const loadBridge = (src) => {
@@ -49,619 +48,555 @@ const loadBridge = (src) => {
49
48
  document.getElementsByTagName("head")[0].appendChild(script);
50
49
  });
51
50
  };
52
- const pick = function(attrs, allowed) {
53
- if (!attrs) {
54
- return null;
55
- }
56
- let h2 = {};
57
- for (let key in attrs) {
58
- let value = attrs[key];
59
- if (allowed.indexOf(key) > -1 && value !== null) {
60
- h2[key] = value;
51
+ var m = Object.defineProperty;
52
+ var R = (i, t, e) => t in i ? m(i, t, { enumerable: true, configurable: true, writable: true, value: e }) : i[t] = e;
53
+ var l = (i, t, e) => (R(i, typeof t != "symbol" ? t + "" : t, e), e);
54
+ function y(i) {
55
+ return !(i !== i || i === 1 / 0 || i === -1 / 0);
56
+ }
57
+ function _(i, t, e) {
58
+ if (!y(t))
59
+ throw new TypeError("Expected `limit` to be a finite number");
60
+ if (!y(e))
61
+ throw new TypeError("Expected `interval` to be a finite number");
62
+ const s = [];
63
+ let r = [], n = 0;
64
+ const c = function() {
65
+ n++;
66
+ const a = setTimeout(function() {
67
+ n--, s.length > 0 && c(), r = r.filter(function(u) {
68
+ return u !== a;
69
+ });
70
+ }, e);
71
+ r.indexOf(a) < 0 && r.push(a);
72
+ const h = s.shift();
73
+ h.resolve(i.apply(h.self, h.args));
74
+ }, o = function(...a) {
75
+ const h = this;
76
+ return new Promise(function(u, g) {
77
+ s.push({
78
+ resolve: u,
79
+ reject: g,
80
+ args: a,
81
+ self: h
82
+ }), n < t && c();
83
+ });
84
+ };
85
+ return o.abort = function() {
86
+ r.forEach(clearTimeout), r = [], s.forEach(function(a) {
87
+ a.reject(function() {
88
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
89
+ });
90
+ }), s.length = 0;
91
+ }, o;
92
+ }
93
+ const b = function(i, t) {
94
+ const e = {};
95
+ for (const s in i) {
96
+ const r = i[s];
97
+ t.indexOf(s) > -1 && r !== null && (e[s] = r);
98
+ }
99
+ return e;
100
+ }, $ = (i) => i === "email", w = () => ({
101
+ singleTag: "hr"
102
+ }), E = () => ({
103
+ tag: "blockquote"
104
+ }), x = () => ({
105
+ tag: "ul"
106
+ }), P = (i) => ({
107
+ tag: [
108
+ "pre",
109
+ {
110
+ tag: "code",
111
+ attrs: i.attrs
61
112
  }
62
- }
63
- return h2;
64
- };
65
- const isEmailLinkType = (type) => type === "email";
66
- var defaultHtmlSerializer = {
67
- nodes: {
68
- horizontal_rule() {
69
- return {
70
- singleTag: "hr"
71
- };
72
- },
73
- blockquote() {
74
- return {
75
- tag: "blockquote"
76
- };
77
- },
78
- bullet_list() {
79
- return {
80
- tag: "ul"
81
- };
82
- },
83
- code_block(node) {
84
- return {
85
- tag: [
86
- "pre",
87
- {
88
- tag: "code",
89
- attrs: node.attrs
90
- }
91
- ]
92
- };
93
- },
94
- hard_break() {
95
- return {
96
- singleTag: "br"
97
- };
98
- },
99
- heading(node) {
100
- return {
101
- tag: `h${node.attrs.level}`
102
- };
103
- },
104
- image(node) {
105
- return {
106
- singleTag: [
107
- {
108
- tag: "img",
109
- attrs: pick(node.attrs, ["src", "alt", "title"])
110
- }
111
- ]
112
- };
113
- },
114
- list_item() {
115
- return {
116
- tag: "li"
117
- };
118
- },
119
- ordered_list() {
120
- return {
121
- tag: "ol"
122
- };
123
- },
124
- paragraph() {
125
- return {
126
- tag: "p"
127
- };
113
+ ]
114
+ }), O = () => ({
115
+ singleTag: "br"
116
+ }), S = (i) => ({
117
+ tag: `h${i.attrs.level}`
118
+ }), C = (i) => ({
119
+ singleTag: [
120
+ {
121
+ tag: "img",
122
+ attrs: b(i.attrs, ["src", "alt", "title"])
128
123
  }
129
- },
130
- marks: {
131
- bold() {
132
- return {
133
- tag: "b"
134
- };
135
- },
136
- strike() {
137
- return {
138
- tag: "strike"
139
- };
140
- },
141
- underline() {
142
- return {
143
- tag: "u"
144
- };
145
- },
146
- strong() {
147
- return {
148
- tag: "strong"
149
- };
150
- },
151
- code() {
152
- return {
153
- tag: "code"
154
- };
155
- },
156
- italic() {
157
- return {
158
- tag: "i"
159
- };
160
- },
161
- link(node) {
162
- const attrs = __spreadValues({}, node.attrs);
163
- const { linktype = "url" } = node.attrs;
164
- if (isEmailLinkType(linktype)) {
165
- attrs.href = `mailto:${attrs.href}`;
166
- }
167
- if (attrs.anchor) {
168
- attrs.href = `${attrs.href}#${attrs.anchor}`;
169
- delete attrs.anchor;
124
+ ]
125
+ }), L = () => ({
126
+ tag: "li"
127
+ }), U = () => ({
128
+ tag: "ol"
129
+ }), H = () => ({
130
+ tag: "p"
131
+ }), A = () => ({
132
+ tag: "b"
133
+ }), I = () => ({
134
+ tag: "strike"
135
+ }), M = () => ({
136
+ tag: "u"
137
+ }), N = () => ({
138
+ tag: "strong"
139
+ }), q = () => ({
140
+ tag: "code"
141
+ }), z = () => ({
142
+ tag: "i"
143
+ }), F = (i) => {
144
+ const t = __spreadValues({}, i.attrs), { linktype: e = "url" } = i.attrs;
145
+ return $(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
146
+ tag: [
147
+ {
148
+ tag: "a",
149
+ attrs: t
170
150
  }
171
- return {
172
- tag: [
173
- {
174
- tag: "a",
175
- attrs
176
- }
177
- ]
178
- };
179
- },
180
- styled(node) {
181
- return {
182
- tag: [
183
- {
184
- tag: "span",
185
- attrs: node.attrs
186
- }
187
- ]
188
- };
151
+ ]
152
+ };
153
+ }, V = (i) => ({
154
+ tag: [
155
+ {
156
+ tag: "span",
157
+ attrs: i.attrs
189
158
  }
190
- }
191
- };
192
- const escapeHTML = function(string) {
193
- const htmlEscapes = {
159
+ ]
160
+ }), j = {
161
+ nodes: {
162
+ horizontal_rule: w,
163
+ blockquote: E,
164
+ bullet_list: x,
165
+ code_block: P,
166
+ hard_break: O,
167
+ heading: S,
168
+ image: C,
169
+ list_item: L,
170
+ ordered_list: U,
171
+ paragraph: H
172
+ },
173
+ marks: {
174
+ bold: A,
175
+ strike: I,
176
+ underline: M,
177
+ strong: N,
178
+ code: q,
179
+ italic: z,
180
+ link: F,
181
+ styled: V
182
+ }
183
+ }, J = function(i) {
184
+ const t = {
194
185
  "&": "&amp;",
195
186
  "<": "&lt;",
196
187
  ">": "&gt;",
197
188
  '"': "&quot;",
198
189
  "'": "&#39;"
199
- };
200
- const reUnescapedHtml = /[&<>"']/g;
201
- const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
202
- return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) : string;
190
+ }, e = /[&<>"']/g, s = RegExp(e.source);
191
+ return i && s.test(i) ? i.replace(e, (r) => t[r]) : i;
203
192
  };
204
- class RichTextResolver {
205
- constructor(schema) {
206
- if (!schema) {
207
- schema = defaultHtmlSerializer;
208
- }
209
- this.marks = schema.marks || [];
210
- this.nodes = schema.nodes || [];
211
- }
212
- addNode(key, schema) {
213
- this.nodes[key] = schema;
214
- }
215
- addMark(key, schema) {
216
- this.marks[key] = schema;
217
- }
218
- render(data = {}) {
219
- if (data.content && Array.isArray(data.content)) {
220
- let html = "";
221
- data.content.forEach((node) => {
222
- html += this.renderNode(node);
223
- });
224
- return html;
225
- }
226
- console.warn("The render method must receive an object with a content field, which is an array");
227
- return "";
228
- }
229
- renderNode(item) {
230
- let html = [];
231
- if (item.marks) {
232
- item.marks.forEach((m) => {
233
- const mark = this.getMatchingMark(m);
234
- if (mark) {
235
- html.push(this.renderOpeningTag(mark.tag));
236
- }
237
- });
238
- }
239
- const node = this.getMatchingNode(item);
240
- if (node && node.tag) {
241
- html.push(this.renderOpeningTag(node.tag));
193
+ class v {
194
+ constructor(t) {
195
+ l(this, "marks");
196
+ l(this, "nodes");
197
+ t || (t = j), this.marks = t.marks || [], this.nodes = t.nodes || [];
198
+ }
199
+ addNode(t, e) {
200
+ this.nodes[t] = e;
201
+ }
202
+ addMark(t, e) {
203
+ this.marks[t] = e;
204
+ }
205
+ render(t) {
206
+ if (t && t.content && Array.isArray(t.content)) {
207
+ let e = "";
208
+ return t.content.forEach((s) => {
209
+ e += this.renderNode(s);
210
+ }), e;
242
211
  }
243
- if (item.content) {
244
- item.content.forEach((content) => {
245
- html.push(this.renderNode(content));
246
- });
247
- } else if (item.text) {
248
- html.push(escapeHTML(item.text));
249
- } else if (node && node.singleTag) {
250
- html.push(this.renderTag(node.singleTag, " /"));
251
- } else if (node && node.html) {
252
- html.push(node.html);
253
- }
254
- if (node && node.tag) {
255
- html.push(this.renderClosingTag(node.tag));
256
- }
257
- if (item.marks) {
258
- item.marks.slice(0).reverse().forEach((m) => {
259
- const mark = this.getMatchingMark(m);
260
- if (mark) {
261
- html.push(this.renderClosingTag(mark.tag));
262
- }
263
- });
264
- }
265
- return html.join("");
212
+ return console.warn("The render method must receive an object with a content field, which is an array"), "";
266
213
  }
267
- renderTag(tags, ending) {
268
- if (tags.constructor === String) {
269
- return `<${tags}${ending}>`;
270
- }
271
- const all = tags.map((tag) => {
272
- if (tag.constructor === String) {
273
- return `<${tag}${ending}>`;
274
- } else {
275
- let h2 = `<${tag.tag}`;
276
- if (tag.attrs) {
277
- for (let key in tag.attrs) {
278
- let value = tag.attrs[key];
279
- if (value !== null) {
280
- h2 += ` ${key}="${value}"`;
281
- }
214
+ renderNode(t) {
215
+ const e = [];
216
+ t.marks && t.marks.forEach((r) => {
217
+ const n = this.getMatchingMark(r);
218
+ n && e.push(this.renderOpeningTag(n.tag));
219
+ });
220
+ const s = this.getMatchingNode(t);
221
+ return s && s.tag && e.push(this.renderOpeningTag(s.tag)), t.content ? t.content.forEach((r) => {
222
+ e.push(this.renderNode(r));
223
+ }) : t.text ? e.push(J(t.text)) : s && s.singleTag ? e.push(this.renderTag(s.singleTag, " /")) : s && s.html && e.push(s.html), s && s.tag && e.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((r) => {
224
+ const n = this.getMatchingMark(r);
225
+ n && e.push(this.renderClosingTag(n.tag));
226
+ }), e.join("");
227
+ }
228
+ renderTag(t, e) {
229
+ return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
230
+ if (r.constructor === String)
231
+ return `<${r}${e}>`;
232
+ {
233
+ let n = `<${r.tag}`;
234
+ if (r.attrs)
235
+ for (const c in r.attrs) {
236
+ const o = r.attrs[c];
237
+ o !== null && (n += ` ${c}="${o}"`);
282
238
  }
283
- }
284
- return `${h2}${ending}>`;
239
+ return `${n}${e}>`;
285
240
  }
286
- });
287
- return all.join("");
241
+ }).join("");
288
242
  }
289
- renderOpeningTag(tags) {
290
- return this.renderTag(tags, "");
243
+ renderOpeningTag(t) {
244
+ return this.renderTag(t, "");
291
245
  }
292
- renderClosingTag(tags) {
293
- if (tags.constructor === String) {
294
- return `</${tags}>`;
295
- }
296
- const all = tags.slice(0).reverse().map((tag) => {
297
- if (tag.constructor === String) {
298
- return `</${tag}>`;
299
- } else {
300
- return `</${tag.tag}>`;
301
- }
302
- });
303
- return all.join("");
246
+ renderClosingTag(t) {
247
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((s) => s.constructor === String ? `</${s}>` : `</${s.tag}>`).join("");
304
248
  }
305
- getMatchingNode(item) {
306
- if (typeof this.nodes[item.type] !== "function") {
307
- return;
308
- }
309
- return this.nodes[item.type](item);
249
+ getMatchingNode(t) {
250
+ const e = this.nodes[t.type];
251
+ if (typeof e == "function")
252
+ return e(t);
310
253
  }
311
- getMatchingMark(item) {
312
- if (typeof this.marks[item.type] !== "function") {
313
- return;
314
- }
315
- return this.marks[item.type](item);
254
+ getMatchingMark(t) {
255
+ const e = this.marks[t.type];
256
+ if (typeof e == "function")
257
+ return e(t);
316
258
  }
317
259
  }
318
- /*!
319
- * storyblok-js-client v4.5.2
320
- * Universal JavaScript SDK for Storyblok's API
321
- * (c) 2020-2022 Stobylok Team
322
- */
323
- function t(e2) {
324
- return typeof e2 == "number" && (e2 == e2 && e2 !== 1 / 0 && e2 !== -1 / 0);
325
- }
326
- function s(e2, s2, r2) {
327
- if (!t(s2))
328
- throw new TypeError("Expected `limit` to be a finite number");
329
- if (!t(r2))
330
- throw new TypeError("Expected `interval` to be a finite number");
331
- var i2 = [], n2 = [], o2 = 0, a2 = function() {
332
- o2++;
333
- var t2 = setTimeout(function() {
334
- o2--, i2.length > 0 && a2(), n2 = n2.filter(function(e3) {
335
- return e3 !== t2;
336
- });
337
- }, r2);
338
- n2.indexOf(t2) < 0 && n2.push(t2);
339
- var s3 = i2.shift();
340
- s3.resolve(e2.apply(s3.self, s3.args));
341
- }, l2 = function() {
342
- var e3 = arguments, t2 = this;
343
- return new Promise(function(r3, n3) {
344
- i2.push({ resolve: r3, reject: n3, args: e3, self: t2 }), o2 < s2 && a2();
260
+ class T {
261
+ constructor() {
262
+ l(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1);
263
+ l(this, "getOptionsPage", (t, e = 25, s = 1) => __spreadProps(__spreadValues({}, t), {
264
+ per_page: e,
265
+ page: s
266
+ }));
267
+ l(this, "delay", (t) => new Promise((e) => setTimeout(e, t)));
268
+ l(this, "arrayFrom", (t = 0, e) => [...Array(t)].map(e));
269
+ l(this, "range", (t = 0, e = t) => {
270
+ const s = Math.abs(e - t) || 0, r = t < e ? 1 : -1;
271
+ return this.arrayFrom(s, (n, c) => c * r + t);
345
272
  });
346
- };
347
- return l2.abort = function() {
348
- n2.forEach(clearTimeout), n2 = [], i2.forEach(function(e3) {
349
- e3.reject(new throttle.AbortError());
350
- }), i2.length = 0;
351
- }, l2;
352
- }
353
- s.AbortError = function() {
354
- Error.call(this, "Throttled function aborted"), this.name = "AbortError";
355
- };
356
- const r = function(e2, t2) {
357
- if (!e2)
358
- return null;
359
- let s2 = {};
360
- for (let r2 in e2) {
361
- let i2 = e2[r2];
362
- t2.indexOf(r2) > -1 && i2 !== null && (s2[r2] = i2);
363
- }
364
- return s2;
365
- };
366
- var i = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (e2) => ({ tag: ["pre", { tag: "code", attrs: e2.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (e2) => ({ tag: `h${e2.attrs.level}` }), image: (e2) => ({ singleTag: [{ tag: "img", attrs: r(e2.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(e2) {
367
- const t2 = __spreadValues({}, e2.attrs), { linktype: s2 = "url" } = e2.attrs;
368
- return s2 === "email" && (t2.href = `mailto:${t2.href}`), t2.anchor && (t2.href = `${t2.href}#${t2.anchor}`, delete t2.anchor), { tag: [{ tag: "a", attrs: t2 }] };
369
- }, styled: (e2) => ({ tag: [{ tag: "span", attrs: e2.attrs }] }) } };
370
- class n {
371
- constructor(e2) {
372
- e2 || (e2 = i), this.marks = e2.marks || [], this.nodes = e2.nodes || [];
373
- }
374
- addNode(e2, t2) {
375
- this.nodes[e2] = t2;
376
- }
377
- addMark(e2, t2) {
378
- this.marks[e2] = t2;
379
- }
380
- render(e2 = {}) {
381
- if (e2.content && Array.isArray(e2.content)) {
382
- let t2 = "";
383
- return e2.content.forEach((e3) => {
384
- t2 += this.renderNode(e3);
385
- }), t2;
273
+ l(this, "asyncMap", async (t, e) => Promise.all(t.map(e)));
274
+ l(this, "flatMap", (t = [], e) => t.map(e).reduce((s, r) => [...s, ...r], []));
275
+ }
276
+ stringify(t, e, s) {
277
+ const r = [];
278
+ for (const n in t) {
279
+ if (!Object.prototype.hasOwnProperty.call(t, n))
280
+ continue;
281
+ const c = t[n], o = s ? "" : encodeURIComponent(n);
282
+ let a;
283
+ typeof c == "object" ? a = this.stringify(c, e ? e + encodeURIComponent("[" + o + "]") : o, Array.isArray(c)) : a = (e ? e + encodeURIComponent("[" + o + "]") : o) + "=" + encodeURIComponent(c), r.push(a);
386
284
  }
387
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
285
+ return r.join("&");
388
286
  }
389
- renderNode(e2) {
390
- let t2 = [];
391
- e2.marks && e2.marks.forEach((e3) => {
392
- const s3 = this.getMatchingMark(e3);
393
- s3 && t2.push(this.renderOpeningTag(s3.tag));
287
+ }
288
+ var f = /* @__PURE__ */ ((i) => (i.GET = "get", i.DELETE = "delete", i.POST = "post", i.PUT = "put", i))(f || {});
289
+ class G {
290
+ constructor(t) {
291
+ l(this, "baseURL");
292
+ l(this, "timeout");
293
+ l(this, "headers");
294
+ l(this, "responseInterceptor");
295
+ l(this, "ejectInterceptor");
296
+ l(this, "url");
297
+ l(this, "parameters");
298
+ this.baseURL = t.baseURL, this.timeout = t.timeout ? t.timeout * 1e3 : 1e3, this.headers = t.headers || [], this.responseInterceptor = t.responseInterceptor, this.ejectInterceptor = false, this.url = "", this.parameters = {};
299
+ }
300
+ get(t, e) {
301
+ return this.url = t, this.parameters = e, this._methodHandler(f.GET);
302
+ }
303
+ post(t, e) {
304
+ return this.url = t, this.parameters = e, this._methodHandler(f.POST);
305
+ }
306
+ put(t, e) {
307
+ return this.url = t, this.parameters = e, this._methodHandler(f.PUT);
308
+ }
309
+ delete(t, e) {
310
+ return this.url = t, this.parameters = e, this._methodHandler(f.DELETE);
311
+ }
312
+ async _responseHandler(t) {
313
+ const e = [], s = {
314
+ data: {},
315
+ headers: {},
316
+ status: 0,
317
+ statusText: ""
318
+ };
319
+ await t.json().then((r) => {
320
+ s.data = r;
394
321
  });
395
- const s2 = this.getMatchingNode(e2);
396
- return s2 && s2.tag && t2.push(this.renderOpeningTag(s2.tag)), e2.content ? e2.content.forEach((e3) => {
397
- t2.push(this.renderNode(e3));
398
- }) : e2.text ? t2.push(function(e3) {
399
- const t3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, s3 = /[&<>"']/g, r2 = RegExp(s3.source);
400
- return e3 && r2.test(e3) ? e3.replace(s3, (e4) => t3[e4]) : e3;
401
- }(e2.text)) : s2 && s2.singleTag ? t2.push(this.renderTag(s2.singleTag, " /")) : s2 && s2.html && t2.push(s2.html), s2 && s2.tag && t2.push(this.renderClosingTag(s2.tag)), e2.marks && e2.marks.slice(0).reverse().forEach((e3) => {
402
- const s3 = this.getMatchingMark(e3);
403
- s3 && t2.push(this.renderClosingTag(s3.tag));
404
- }), t2.join("");
405
- }
406
- renderTag(e2, t2) {
407
- if (e2.constructor === String)
408
- return `<${e2}${t2}>`;
409
- return e2.map((e3) => {
410
- if (e3.constructor === String)
411
- return `<${e3}${t2}>`;
412
- {
413
- let s2 = `<${e3.tag}`;
414
- if (e3.attrs)
415
- for (let t3 in e3.attrs) {
416
- let r2 = e3.attrs[t3];
417
- r2 !== null && (s2 += ` ${t3}="${r2}"`);
418
- }
419
- return `${s2}${t2}>`;
420
- }
421
- }).join("");
422
- }
423
- renderOpeningTag(e2) {
424
- return this.renderTag(e2, "");
425
- }
426
- renderClosingTag(e2) {
427
- if (e2.constructor === String)
428
- return `</${e2}>`;
429
- return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
322
+ for (const r of t.headers.entries())
323
+ e[r[0]] = r[1];
324
+ return s.headers = __spreadValues({}, e), s.status = t.status, s.statusText = t.statusText, s;
325
+ }
326
+ async _methodHandler(t) {
327
+ const e = new URL(`${this.baseURL}${this.url}`);
328
+ let s = null;
329
+ if (t === "get") {
330
+ const o = new T();
331
+ e.search = o.stringify(this.parameters);
332
+ } else
333
+ s = JSON.stringify(this.parameters);
334
+ const r = new AbortController(), { signal: n } = r, c = setTimeout(() => r.abort(), this.timeout);
335
+ try {
336
+ const o = await fetch(`${e}`, {
337
+ method: t,
338
+ headers: this.headers,
339
+ body: s,
340
+ signal: n
341
+ });
342
+ clearTimeout(c);
343
+ const a = await this._responseHandler(o);
344
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(a)) : this._statusHandler(a);
345
+ } catch (o) {
346
+ return o;
347
+ }
430
348
  }
431
- getMatchingNode(e2) {
432
- if (typeof this.nodes[e2.type] == "function")
433
- return this.nodes[e2.type](e2);
349
+ eject() {
350
+ this.ejectInterceptor = true;
434
351
  }
435
- getMatchingMark(e2) {
436
- if (typeof this.marks[e2.type] == "function")
437
- return this.marks[e2.type](e2);
352
+ _statusHandler(t) {
353
+ if (/20[01]/g.test(`${t.status}`))
354
+ return t;
355
+ throw {
356
+ message: new Error(t.statusText || `status: ${t.status}`),
357
+ response: t
358
+ };
438
359
  }
439
360
  }
440
- const o = (e2 = 0, t2 = e2) => {
441
- const s2 = Math.abs(t2 - e2) || 0, r2 = e2 < t2 ? 1 : -1;
442
- return ((e3 = 0, t3) => [...Array(e3)].map(t3))(s2, (t3, s3) => s3 * r2 + e2);
443
- }, a = (e2, t2, s2) => {
444
- const r2 = [];
445
- for (const i2 in e2) {
446
- if (!Object.prototype.hasOwnProperty.call(e2, i2))
447
- continue;
448
- const n2 = e2[i2], o2 = s2 ? "" : encodeURIComponent(i2);
449
- let l2;
450
- l2 = typeof n2 == "object" ? a(n2, t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(n2)) : (t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(n2), r2.push(l2);
451
- }
452
- return r2.join("&");
453
- };
454
- let l = {}, c = {};
455
- class h {
456
- constructor(t2, r2) {
457
- if (!r2) {
458
- let e2 = t2.region ? `-${t2.region}` : "", s2 = t2.https === false ? "http" : "https";
459
- r2 = t2.oauthToken === void 0 ? `${s2}://api${e2}.storyblok.com/v2` : `${s2}://api${e2}.storyblok.com/v1`;
361
+ let p = {};
362
+ const d = {};
363
+ class Q {
364
+ constructor(t, e) {
365
+ l(this, "client");
366
+ l(this, "maxRetries");
367
+ l(this, "throttle");
368
+ l(this, "accessToken");
369
+ l(this, "cache");
370
+ l(this, "helpers");
371
+ l(this, "relations");
372
+ l(this, "links");
373
+ l(this, "richTextResolver");
374
+ l(this, "resolveNestedRelations");
375
+ if (!e) {
376
+ const n = t.region ? `-${t.region}` : "", c = t.https ? "https" : "http";
377
+ t.oauthToken ? e = `${c}://api${n}.storyblok.com/v1` : e = `${c}://api${n}.storyblok.com/v2`;
460
378
  }
461
- let i2 = Object.assign({}, t2.headers), o2 = 5;
462
- t2.oauthToken !== void 0 && (i2.Authorization = t2.oauthToken, o2 = 3), t2.rateLimit !== void 0 && (o2 = t2.rateLimit), this.richTextResolver = new n(t2.richTextSchema), typeof t2.componentResolver == "function" && this.setComponentResolver(t2.componentResolver), this.maxRetries = t2.maxRetries || 5, this.throttle = s(this.throttledRequest, o2, 1e3), this.accessToken = t2.accessToken, this.relations = {}, this.links = {}, this.cache = t2.cache || { clear: "manual" }, this.client = e.create({ baseURL: r2, timeout: t2.timeout || 0, headers: i2, proxy: t2.proxy || false }), t2.responseInterceptor && this.client.interceptors.response.use((e2) => t2.responseInterceptor(e2)), this.resolveNestedRelations = t2.resolveNestedRelations || true;
463
- }
464
- setComponentResolver(e2) {
465
- this.richTextResolver.addNode("blok", (t2) => {
466
- let s2 = "";
467
- return t2.attrs.body.forEach((t3) => {
468
- s2 += e2(t3.component, t3);
469
- }), { html: s2 };
379
+ const s = Object.assign({}, t.headers);
380
+ let r = 5;
381
+ t.oauthToken && (s.Authorization = t.oauthToken, r = 3), t.rateLimit && (r = t.rateLimit), t.richTextSchema ? this.richTextResolver = new v(t.richTextSchema) : this.richTextResolver = new v(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries, this.throttle = _(this.throttledRequest, r, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new T(), this.resolveNestedRelations = false, this.client = new G({
382
+ baseURL: e,
383
+ timeout: t.timeout || 0,
384
+ headers: s,
385
+ responseInterceptor: t.responseInterceptor
470
386
  });
471
387
  }
472
- parseParams(e2 = {}) {
473
- return e2.version || (e2.version = "published"), e2.token || (e2.token = this.getToken()), e2.cv || (e2.cv = c[e2.token]), Array.isArray(e2.resolve_relations) && (e2.resolve_relations = e2.resolve_relations.join(",")), e2;
388
+ setComponentResolver(t) {
389
+ this.richTextResolver.addNode("blok", (e) => {
390
+ let s = "";
391
+ return e.attrs.body.forEach((r) => {
392
+ s += t(r.component, r);
393
+ }), {
394
+ html: s
395
+ };
396
+ });
474
397
  }
475
- factoryParamOptions(e2, t2 = {}) {
476
- return ((e3 = "") => e3.indexOf("/cdn/") > -1)(e2) ? this.parseParams(t2) : t2;
398
+ parseParams(t) {
399
+ return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
477
400
  }
478
- makeRequest(e2, t2, s2, r2) {
479
- const i2 = this.factoryParamOptions(e2, ((e3 = {}, t3 = 25, s3 = 1) => __spreadProps(__spreadValues({}, e3), { per_page: t3, page: s3 }))(t2, s2, r2));
480
- return this.cacheResponse(e2, i2);
401
+ factoryParamOptions(t, e) {
402
+ return this.helpers.isCDNUrl(t) ? this.parseParams(e) : e;
481
403
  }
482
- get(e2, t2) {
483
- let s2 = `/${e2}`;
484
- const r2 = this.factoryParamOptions(s2, t2);
485
- return this.cacheResponse(s2, r2);
404
+ makeRequest(t, e, s, r) {
405
+ const n = this.factoryParamOptions(t, this.helpers.getOptionsPage(e, s, r));
406
+ return this.cacheResponse(t, n);
486
407
  }
487
- async getAll(e2, t2 = {}, s2) {
488
- const r2 = t2.per_page || 25, i2 = `/${e2}`, n2 = i2.split("/");
489
- s2 = s2 || n2[n2.length - 1];
490
- const a2 = await this.makeRequest(i2, t2, r2, 1), l2 = a2.total ? Math.ceil(a2.total / r2) : 1;
491
- return ((e3 = [], t3) => e3.map(t3).reduce((e4, t4) => [...e4, ...t4], []))([a2, ...await (async (e3 = [], t3) => Promise.all(e3.map(t3)))(o(1, l2), async (e3) => this.makeRequest(i2, t2, r2, e3 + 1))], (e3) => Object.values(e3.data[s2]));
408
+ get(t, e) {
409
+ e || (e = {});
410
+ const s = `/${t}`, r = this.factoryParamOptions(s, e);
411
+ return this.cacheResponse(s, r);
492
412
  }
493
- post(e2, t2) {
494
- let s2 = `/${e2}`;
495
- return this.throttle("post", s2, t2);
413
+ async getAll(t, e, s) {
414
+ const r = (e == null ? void 0 : e.per_page) || 25, n = `/${t}`, c = n.split("/"), o = s || c[c.length - 1], a = 1, h = await this.makeRequest(n, e, r, a), u = h.total ? Math.ceil(h.total / r) : 1, g = await this.helpers.asyncMap(this.helpers.range(a, u), (k) => this.makeRequest(n, e, r, k + 1));
415
+ return this.helpers.flatMap([h, ...g], (k) => Object.values(k.data[o]));
496
416
  }
497
- put(e2, t2) {
498
- let s2 = `/${e2}`;
499
- return this.throttle("put", s2, t2);
417
+ post(t, e) {
418
+ const s = `/${t}`;
419
+ return Promise.resolve(this.throttle("post", s, e));
500
420
  }
501
- delete(e2, t2) {
502
- let s2 = `/${e2}`;
503
- return this.throttle("delete", s2, t2);
421
+ put(t, e) {
422
+ const s = `/${t}`;
423
+ return Promise.resolve(this.throttle("put", s, e));
504
424
  }
505
- getStories(e2) {
506
- return this.get("cdn/stories", e2);
425
+ delete(t, e) {
426
+ const s = `/${t}`;
427
+ return Promise.resolve(this.throttle("delete", s, e));
507
428
  }
508
- getStory(e2, t2) {
509
- return this.get(`cdn/stories/${e2}`, t2);
429
+ getStories(t) {
430
+ return this.get("cdn/stories", t);
510
431
  }
511
- setToken(e2) {
512
- this.accessToken = e2;
432
+ getStory(t, e) {
433
+ return this.get(`cdn/stories/${t}`, e);
513
434
  }
514
435
  getToken() {
515
436
  return this.accessToken;
516
437
  }
517
- _cleanCopy(e2) {
518
- return JSON.parse(JSON.stringify(e2));
519
- }
520
- _insertLinks(e2, t2) {
521
- const s2 = e2[t2];
522
- s2 && s2.fieldtype == "multilink" && s2.linktype == "story" && typeof s2.id == "string" && this.links[s2.id] ? s2.story = this._cleanCopy(this.links[s2.id]) : s2 && s2.linktype === "story" && typeof s2.uuid == "string" && this.links[s2.uuid] && (s2.story = this._cleanCopy(this.links[s2.uuid]));
523
- }
524
- _insertRelations(e2, t2, s2) {
525
- if (s2.indexOf(e2.component + "." + t2) > -1) {
526
- if (typeof e2[t2] == "string")
527
- this.relations[e2[t2]] && (e2[t2] = this._cleanCopy(this.relations[e2[t2]]));
528
- else if (e2[t2].constructor === Array) {
529
- let s3 = [];
530
- e2[t2].forEach((e3) => {
531
- this.relations[e3] && s3.push(this._cleanCopy(this.relations[e3]));
532
- }), e2[t2] = s3;
438
+ ejectInterceptor() {
439
+ this.client.eject();
440
+ }
441
+ _cleanCopy(t) {
442
+ return JSON.parse(JSON.stringify(t));
443
+ }
444
+ _insertLinks(t, e) {
445
+ const s = t[e];
446
+ s && s.fieldtype == "multilink" && s.linktype == "story" && typeof s.id == "string" && this.links[s.id] ? s.story = this._cleanCopy(this.links[s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[s.uuid] && (s.story = this._cleanCopy(this.links[s.uuid]));
447
+ }
448
+ _insertRelations(t, e, s) {
449
+ if (s.indexOf(`${t.component}.${e}`) > -1) {
450
+ if (typeof t[e] == "string")
451
+ this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
452
+ else if (t[e] && t[e].constructor === Array) {
453
+ const r = [];
454
+ t[e].forEach((n) => {
455
+ this.relations[n] && r.push(this._cleanCopy(this.relations[n]));
456
+ }), t[e] = r;
533
457
  }
534
458
  }
535
459
  }
536
- _insertAssetsRelations(e2, t2) {
537
- t2.forEach((t3) => {
538
- e2.id === t3.id && (e2.original = t3, e2.original.filename = e2.filename, e2.original.filename = e2.original.filename.includes("https://s3.amazonaws.com/") ? e2.original.filename : e2.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e2.original.s3_filename);
539
- });
540
- }
541
- iterateTree(e2, t2) {
542
- let s2 = (e3) => {
543
- if (e3 != null) {
544
- if (e3.constructor === Array)
545
- for (let t3 = 0; t3 < e3.length; t3++)
546
- s2(e3[t3]);
547
- else if (e3.constructor === Object) {
548
- if (e3._stopResolving)
460
+ iterateTree(t, e) {
461
+ const s = (r) => {
462
+ if (r != null) {
463
+ if (r.constructor === Array)
464
+ for (let n = 0; n < r.length; n++)
465
+ s(r[n]);
466
+ else if (r.constructor === Object) {
467
+ if (r._stopResolving)
549
468
  return;
550
- for (let r2 in e3)
551
- e3.component && e3._uid || e3.type === "link" ? (this._insertRelations(e3, r2, t2), this._insertLinks(e3, r2)) : "id" in e3 && e3.fieldtype === "asset" && this._insertAssetsRelations(e3, t2), s2(e3[r2]);
469
+ for (const n in r)
470
+ (r.component && r._uid || r.type === "link") && (this._insertRelations(r, n, e), this._insertLinks(r, n)), s(r[n]);
552
471
  }
553
472
  }
554
473
  };
555
- s2(e2.content);
556
- }
557
- async resolveLinks(e2, t2) {
558
- let s2 = [];
559
- if (e2.link_uuids) {
560
- const r2 = e2.link_uuids.length;
561
- let i2 = [];
562
- const n2 = 50;
563
- for (let t3 = 0; t3 < r2; t3 += n2) {
564
- const s3 = Math.min(r2, t3 + n2);
565
- i2.push(e2.link_uuids.slice(t3, s3));
474
+ s(t.content);
475
+ }
476
+ async resolveLinks(t, e) {
477
+ let s = [];
478
+ if (t.link_uuids) {
479
+ const r = t.link_uuids.length, n = [], c = 50;
480
+ for (let o = 0; o < r; o += c) {
481
+ const a = Math.min(r, o + c);
482
+ n.push(t.link_uuids.slice(o, a));
566
483
  }
567
- for (let e3 = 0; e3 < i2.length; e3++) {
568
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
569
- s2.push(e4);
484
+ for (let o = 0; o < n.length; o++)
485
+ (await this.getStories({
486
+ per_page: c,
487
+ language: e.language,
488
+ version: e.version,
489
+ by_uuids: n[o].join(",")
490
+ })).data.stories.forEach((h) => {
491
+ s.push(h);
570
492
  });
571
- }
572
493
  } else
573
- s2 = e2.links;
574
- s2.forEach((e3) => {
575
- this.links[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
494
+ s = t.links;
495
+ s.forEach((r) => {
496
+ this.links[r.uuid] = __spreadProps(__spreadValues({}, r), { _stopResolving: true });
576
497
  });
577
498
  }
578
- async resolveRelations(e2, t2) {
579
- let s2 = [];
580
- if (e2.rel_uuids) {
581
- const r2 = e2.rel_uuids.length;
582
- let i2 = [];
583
- const n2 = 50;
584
- for (let t3 = 0; t3 < r2; t3 += n2) {
585
- const s3 = Math.min(r2, t3 + n2);
586
- i2.push(e2.rel_uuids.slice(t3, s3));
499
+ async resolveRelations(t, e) {
500
+ let s = [];
501
+ if (t.rel_uuids) {
502
+ const r = t.rel_uuids.length, n = [], c = 50;
503
+ for (let o = 0; o < r; o += c) {
504
+ const a = Math.min(r, o + c);
505
+ n.push(t.rel_uuids.slice(o, a));
587
506
  }
588
- for (let e3 = 0; e3 < i2.length; e3++) {
589
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
590
- s2.push(e4);
507
+ for (let o = 0; o < n.length; o++)
508
+ (await this.getStories({
509
+ per_page: c,
510
+ language: e.language,
511
+ version: e.version,
512
+ by_uuids: n[o].join(",")
513
+ })).data.stories.forEach((h) => {
514
+ s.push(h);
591
515
  });
592
- }
593
516
  } else
594
- s2 = e2.rels;
595
- s2.forEach((e3) => {
596
- this.relations[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
517
+ s = t.rels;
518
+ s && s.length > 0 && s.forEach((r) => {
519
+ this.relations[r.uuid] = __spreadProps(__spreadValues({}, r), { _stopResolving: true });
597
520
  });
598
521
  }
599
- async resolveStories(e2, t2) {
600
- let s2 = [];
601
- if (t2.resolve_relations !== void 0 && t2.resolve_relations.length > 0 && (e2.rels || e2.rel_uuids) && (s2 = t2.resolve_relations.split(","), await this.resolveRelations(e2, t2)), ["1", "story", "url"].indexOf(t2.resolve_links) > -1 && (e2.links || e2.link_uuids) && await this.resolveLinks(e2, t2), this.resolveNestedRelations)
602
- for (const e3 in this.relations)
603
- this.iterateTree(this.relations[e3], s2);
604
- e2.story ? this.iterateTree(e2.story, s2) : e2.stories.forEach((e3) => {
605
- this.iterateTree(e3, s2);
522
+ async resolveStories(t, e) {
523
+ var r, n;
524
+ let s = [];
525
+ if (typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (s = e.resolve_relations.split(","), await this.resolveRelations(t, e)), e.resolve_links && ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (((r = t.links) == null ? void 0 : r.length) || ((n = t.link_uuids) == null ? void 0 : n.length)) && await this.resolveLinks(t, e), this.resolveNestedRelations)
526
+ for (const c in this.relations)
527
+ this.iterateTree(this.relations[c], s);
528
+ t.story ? this.iterateTree(t.story, s) : t.stories.forEach((c) => {
529
+ this.iterateTree(c, s);
606
530
  });
607
531
  }
608
- resolveAssetsRelations(e2) {
609
- const { assets: t2, stories: s2, story: r2 } = e2;
610
- if (s2)
611
- for (const e3 of s2)
612
- this.iterateTree(e3, t2);
613
- else {
614
- if (!r2)
615
- return e2;
616
- this.iterateTree(r2, t2);
617
- }
618
- }
619
- cacheResponse(e2, t2, s2) {
620
- return s2 === void 0 && (s2 = 0), new Promise(async (r2, i2) => {
621
- let n2 = a({ url: e2, params: t2 }), o2 = this.cacheProvider();
622
- if (this.cache.clear === "auto" && t2.version === "draft" && await this.flushCache(), t2.version === "published" && e2 != "/cdn/spaces/me") {
623
- const e3 = await o2.get(n2);
624
- if (e3)
625
- return r2(e3);
532
+ cacheResponse(t, e, s) {
533
+ return new Promise((r, n) => {
534
+ const c = this.helpers.stringify({ url: t, params: e }), o = this.cacheProvider();
535
+ if (this.cache.clear === "auto" && e.version === "draft" && this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
536
+ const a = o.get(c);
537
+ if (a)
538
+ return r(a);
626
539
  }
627
540
  try {
628
- let s3 = await this.throttle("get", e2, { params: t2, paramsSerializer: (e3) => a(e3) }), l3 = { data: s3.data, headers: s3.headers };
629
- if (l3.data.assets && l3.data.assets.length && this.resolveAssetsRelations(l3.data), l3 = Object.assign({}, l3, { perPage: s3.headers["per-page"] ? parseInt(s3.headers["per-page"]) : 0, total: s3.headers["per-page"] ? parseInt(s3.headers.total) : 0 }), s3.status != 200)
630
- return i2(s3);
631
- (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, t2), t2.version === "published" && e2 != "/cdn/spaces/me" && o2.set(n2, l3), l3.data.cv && (t2.version == "draft" && c[t2.token] != l3.data.cv && this.flushCache(), c[t2.token] = l3.data.cv), r2(l3);
632
- } catch (n3) {
633
- if (n3.response && n3.response.status === 429 && (s2 += 1) < this.maxRetries)
634
- return console.log(`Hit rate limit. Retrying in ${s2} seconds.`), await (l2 = 1e3 * s2, new Promise((e3) => setTimeout(e3, l2))), this.cacheResponse(e2, t2, s2).then(r2).catch(i2);
635
- i2(n3);
541
+ (async () => {
542
+ var u;
543
+ const a = await this.throttle("get", t, e);
544
+ let h = { data: a.data, headers: a.headers };
545
+ if ((u = a.headers) != null && u["per-page"] && (h = Object.assign({}, h, {
546
+ perPage: a.headers["per-page"] ? parseInt(a.headers["per-page"]) : 0,
547
+ total: a.headers["per-page"] ? parseInt(a.headers.total) : 0
548
+ })), a.status != 200)
549
+ return n(a);
550
+ (h.data.story || h.data.stories) && await this.resolveStories(h.data, e), e.version === "published" && t != "/cdn/spaces/me" && o.set(c, h), h.data.cv && e.token && (e.version == "draft" && d[e.token] != h.data.cv && this.flushCache(), d[e.token] = h.data.cv), r(h);
551
+ })();
552
+ } catch {
636
553
  }
637
- var l2;
638
554
  });
639
555
  }
640
- throttledRequest(e2, t2, s2) {
641
- return this.client[e2](t2, s2);
556
+ throttledRequest(t, e, s) {
557
+ return this.client[t](e, s);
642
558
  }
643
559
  cacheVersions() {
644
- return c;
560
+ return d;
645
561
  }
646
562
  cacheVersion() {
647
- return c[this.accessToken];
563
+ return d[this.accessToken];
648
564
  }
649
- setCacheVersion(e2) {
650
- this.accessToken && (c[this.accessToken] = e2);
565
+ setCacheVersion(t) {
566
+ this.accessToken && (d[this.accessToken] = t);
651
567
  }
652
568
  cacheProvider() {
653
- return this.cache.type === "memory" ? { get: (e2) => l[e2], getAll: () => l, set(e2, t2) {
654
- l[e2] = t2;
655
- }, flush() {
656
- l = {};
657
- } } : { get() {
658
- }, getAll() {
659
- }, set() {
660
- }, flush() {
661
- } };
662
- }
663
- async flushCache() {
664
- return await this.cacheProvider().flush(), this;
569
+ switch (this.cache.type) {
570
+ case "memory":
571
+ return {
572
+ get(t) {
573
+ return p[t];
574
+ },
575
+ getAll() {
576
+ return p;
577
+ },
578
+ set(t, e) {
579
+ p[t] = e;
580
+ },
581
+ flush() {
582
+ p = {};
583
+ }
584
+ };
585
+ default:
586
+ return {
587
+ get() {
588
+ },
589
+ getAll() {
590
+ },
591
+ set() {
592
+ },
593
+ flush() {
594
+ }
595
+ };
596
+ }
597
+ }
598
+ flushCache() {
599
+ return this.cacheProvider().flush(), this;
665
600
  }
666
601
  }
667
602
  const apiFactory = (options = {}) => {
@@ -670,7 +605,7 @@ const apiFactory = (options = {}) => {
670
605
  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");
671
606
  return;
672
607
  }
673
- const storyblokApi = new h(apiOptions);
608
+ const storyblokApi = new Q(apiOptions);
674
609
  return { storyblokApi };
675
610
  };
676
611
  var editable = (blok) => {
@@ -725,7 +660,7 @@ const storyblokInit = (pluginOptions = {}) => {
725
660
  if (bridge !== false) {
726
661
  loadBridge(bridgeLatest);
727
662
  }
728
- richTextResolver = new RichTextResolver(richText.schema);
663
+ richTextResolver = new v(richText.schema);
729
664
  if (richText.resolver) {
730
665
  setComponentResolver(richTextResolver, richText.resolver);
731
666
  }
@@ -757,7 +692,7 @@ const renderRichText = (data, options, resolverInstance) => {
757
692
  return "";
758
693
  }
759
694
  if (options) {
760
- localResolver = new RichTextResolver(options.schema);
695
+ localResolver = new v(options.schema);
761
696
  if (options.resolver) {
762
697
  setComponentResolver(localResolver, options.resolver);
763
698
  }
@@ -765,4 +700,4 @@ const renderRichText = (data, options, resolverInstance) => {
765
700
  return localResolver.render(data);
766
701
  };
767
702
  const loadStoryblokBridge = () => loadBridge(bridgeLatest);
768
- export { defaultHtmlSerializer as RichTextSchema, apiFactory as apiPlugin, loadStoryblokBridge, useStoryblokBridge as registerStoryblokBridge, renderRichText, editable as storyblokEditable, storyblokInit, useStoryblokBridge };
703
+ export { apiFactory as apiPlugin, loadStoryblokBridge, useStoryblokBridge as registerStoryblokBridge, renderRichText, editable as storyblokEditable, storyblokInit, useStoryblokBridge };