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