@storyblok/react 5.0.0 → 5.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 +147 -88
- package/dist/index.d.ts +1 -1
- package/dist/richtext.mjs +4 -4
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +260 -247
- package/package.json +32 -51
package/dist/storyblok-js.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
function
|
|
1
|
+
function se(n, e) {
|
|
2
2
|
if (!e)
|
|
3
3
|
return { src: n, attrs: {} };
|
|
4
4
|
let t = 0, r = 0;
|
|
5
5
|
const s = {}, o = [];
|
|
6
|
-
function
|
|
7
|
-
typeof
|
|
6
|
+
function c(i, h, f, y, _) {
|
|
7
|
+
typeof i != "number" || i <= h || i >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`) : _.push(`${y}(${i})`);
|
|
8
8
|
}
|
|
9
9
|
if (typeof e == "object") {
|
|
10
10
|
if (typeof e.width == "number" && e.width > 0 ? (s.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (s.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
|
|
11
|
-
const { filters:
|
|
12
|
-
h &&
|
|
11
|
+
const { filters: i } = e || {}, { blur: h, brightness: f, fill: y, format: _, grayscale: T, quality: A, rotate: S } = i || {};
|
|
12
|
+
h && c(h, 0, 100, "blur", o), A && c(A, 0, 100, "quality", o), f && c(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), T && o.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${S})`), _ && ["webp", "png", "jpeg"].includes(_) && o.push(`format(${_})`);
|
|
13
13
|
}
|
|
14
|
-
e.srcset && (s.srcset = e.srcset.map((
|
|
15
|
-
if (typeof
|
|
16
|
-
return `${n}/m/${
|
|
17
|
-
if (Array.isArray(
|
|
18
|
-
const [h, f] =
|
|
14
|
+
e.srcset && (s.srcset = e.srcset.map((i) => {
|
|
15
|
+
if (typeof i == "number")
|
|
16
|
+
return `${n}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
|
|
17
|
+
if (Array.isArray(i) && i.length === 2) {
|
|
18
|
+
const [h, f] = i;
|
|
19
19
|
return `${n}/m/${h}x${f}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
|
|
20
20
|
} else {
|
|
21
21
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
@@ -23,14 +23,14 @@ function te(n, e) {
|
|
|
23
23
|
}
|
|
24
24
|
}).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
|
|
25
25
|
}
|
|
26
|
-
let
|
|
27
|
-
return t > 0 && r > 0 && (
|
|
28
|
-
src:
|
|
26
|
+
let l = `${n}/m/`;
|
|
27
|
+
return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
|
|
28
|
+
src: l,
|
|
29
29
|
attrs: s
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}),
|
|
33
|
-
const
|
|
32
|
+
var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), $ = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))($ || {}), V = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(V || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
|
|
33
|
+
const re = [
|
|
34
34
|
"area",
|
|
35
35
|
"base",
|
|
36
36
|
"br",
|
|
@@ -45,97 +45,91 @@ const se = [
|
|
|
45
45
|
"source",
|
|
46
46
|
"track",
|
|
47
47
|
"wbr"
|
|
48
|
-
],
|
|
49
|
-
function
|
|
48
|
+
], ne = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), oe = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
|
|
49
|
+
function ie(n) {
|
|
50
50
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
51
51
|
}
|
|
52
52
|
const O = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
|
|
53
|
-
function
|
|
54
|
-
const r =
|
|
53
|
+
function D(n, e = {}, t) {
|
|
54
|
+
const r = ne(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
|
|
55
55
|
if (n) {
|
|
56
|
-
if (
|
|
56
|
+
if (re.includes(n))
|
|
57
57
|
return `<${s}>`;
|
|
58
58
|
} else return o;
|
|
59
59
|
return `<${s}>${o}</${n}>`;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function ae(n = {}) {
|
|
62
62
|
const e = /* @__PURE__ */ new Map(), {
|
|
63
|
-
renderFn: t =
|
|
64
|
-
textFn: r =
|
|
63
|
+
renderFn: t = D,
|
|
64
|
+
textFn: r = ie,
|
|
65
65
|
resolvers: s = {},
|
|
66
66
|
optimizeImages: o = !1,
|
|
67
|
-
keyedResolvers:
|
|
68
|
-
} = n,
|
|
69
|
-
if (l && i) {
|
|
70
|
-
const p = e.get(i) || 0;
|
|
71
|
-
e.set(i, p + 1), u.key = `${i}-${p}`;
|
|
72
|
-
}
|
|
73
|
-
return t(i, u, d);
|
|
74
|
-
} }), h = (i) => (u, d) => {
|
|
67
|
+
keyedResolvers: c = !1
|
|
68
|
+
} = n, l = t !== D, i = (a) => (u, d) => {
|
|
75
69
|
const p = u.attrs || {};
|
|
76
|
-
return d.render(
|
|
77
|
-
},
|
|
78
|
-
const { src: d, alt: p, title: m, srcset: w, sizes: b } =
|
|
79
|
-
let k = d,
|
|
70
|
+
return d.render(a, p, u.children || null);
|
|
71
|
+
}, h = (a, u) => {
|
|
72
|
+
const { src: d, alt: p, title: m, srcset: w, sizes: b } = a.attrs || {};
|
|
73
|
+
let k = d, R = {};
|
|
80
74
|
if (o) {
|
|
81
|
-
const { src:
|
|
82
|
-
k =
|
|
75
|
+
const { src: ee, attrs: te } = se(d, o);
|
|
76
|
+
k = ee, R = te;
|
|
83
77
|
}
|
|
84
|
-
const
|
|
78
|
+
const Z = {
|
|
85
79
|
src: k,
|
|
86
80
|
alt: p,
|
|
87
81
|
title: m,
|
|
88
82
|
srcset: w,
|
|
89
83
|
sizes: b,
|
|
90
|
-
...
|
|
84
|
+
...R
|
|
91
85
|
};
|
|
92
|
-
return u.render("img", O(
|
|
93
|
-
},
|
|
94
|
-
const { level: d, ...p } =
|
|
95
|
-
return u.render(`h${d}`, p,
|
|
96
|
-
},
|
|
86
|
+
return u.render("img", O(Z));
|
|
87
|
+
}, f = (a, u) => {
|
|
88
|
+
const { level: d, ...p } = a.attrs || {};
|
|
89
|
+
return u.render(`h${d}`, p, a.children);
|
|
90
|
+
}, y = (a, u) => {
|
|
97
91
|
var d, p, m, w;
|
|
98
92
|
const b = u.render("img", {
|
|
99
|
-
src: (d =
|
|
100
|
-
alt: (p =
|
|
93
|
+
src: (d = a.attrs) == null ? void 0 : d.fallbackImage,
|
|
94
|
+
alt: (p = a.attrs) == null ? void 0 : p.alt,
|
|
101
95
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
102
96
|
draggable: "false",
|
|
103
97
|
loading: "lazy"
|
|
104
98
|
});
|
|
105
99
|
return u.render("span", {
|
|
106
100
|
"data-type": "emoji",
|
|
107
|
-
"data-name": (m =
|
|
108
|
-
"data-emoji": (w =
|
|
101
|
+
"data-name": (m = a.attrs) == null ? void 0 : m.name,
|
|
102
|
+
"data-emoji": (w = a.attrs) == null ? void 0 : w.emoji
|
|
109
103
|
}, b);
|
|
110
|
-
},
|
|
104
|
+
}, _ = (a, u) => u.render(
|
|
111
105
|
"pre",
|
|
112
|
-
|
|
113
|
-
u.render("code", {},
|
|
114
|
-
),
|
|
115
|
-
const { class: w, id: b, ...k } = p || {},
|
|
106
|
+
a.attrs || {},
|
|
107
|
+
u.render("code", {}, a.children || "")
|
|
108
|
+
), T = (a, u = !1) => ({ text: d, attrs: p }, m) => {
|
|
109
|
+
const { class: w, id: b, ...k } = p || {}, R = u ? {
|
|
116
110
|
class: w,
|
|
117
111
|
id: b,
|
|
118
|
-
style:
|
|
112
|
+
style: oe(k) || void 0
|
|
119
113
|
} : p || {};
|
|
120
|
-
return m.render(
|
|
121
|
-
},
|
|
122
|
-
const { marks: u, ...d } =
|
|
123
|
-
if ("text" in
|
|
114
|
+
return m.render(a, O(R), d);
|
|
115
|
+
}, A = (a) => C(a), S = (a) => {
|
|
116
|
+
const { marks: u, ...d } = a;
|
|
117
|
+
if ("text" in a) {
|
|
124
118
|
if (u)
|
|
125
119
|
return u.reduce(
|
|
126
|
-
(m, w) =>
|
|
127
|
-
|
|
120
|
+
(m, w) => A({ ...w, text: m }),
|
|
121
|
+
A({ ...d, children: d.children })
|
|
128
122
|
);
|
|
129
|
-
const p =
|
|
130
|
-
if (
|
|
123
|
+
const p = a.attrs || {};
|
|
124
|
+
if (c) {
|
|
131
125
|
const m = e.get("txt") || 0;
|
|
132
126
|
e.set("txt", m + 1), p.key = `txt-${m}`;
|
|
133
127
|
}
|
|
134
128
|
return r(d.text, p);
|
|
135
129
|
}
|
|
136
130
|
return "";
|
|
137
|
-
}, H = (
|
|
138
|
-
const { linktype: d, href: p, anchor: m, ...w } =
|
|
131
|
+
}, H = (a, u) => {
|
|
132
|
+
const { linktype: d, href: p, anchor: m, ...w } = a.attrs || {};
|
|
139
133
|
let b = "";
|
|
140
134
|
switch (d) {
|
|
141
135
|
case I.ASSET:
|
|
@@ -153,116 +147,134 @@ function ie(n = {}) {
|
|
|
153
147
|
break;
|
|
154
148
|
}
|
|
155
149
|
const k = { ...w };
|
|
156
|
-
return b && (k.href = b), u.render("a", k,
|
|
157
|
-
},
|
|
150
|
+
return b && (k.href = b), u.render("a", k, a.text);
|
|
151
|
+
}, J = (a, u) => {
|
|
158
152
|
var d, p;
|
|
159
153
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
|
|
160
|
-
blok: (d =
|
|
161
|
-
id: (p =
|
|
154
|
+
blok: (d = a == null ? void 0 : a.attrs) == null ? void 0 : d.body[0],
|
|
155
|
+
id: (p = a.attrs) == null ? void 0 : p.id,
|
|
162
156
|
style: "display: none"
|
|
163
157
|
});
|
|
164
|
-
},
|
|
165
|
-
const d = {}, p = u.render("tbody", {},
|
|
158
|
+
}, Y = (a, u) => {
|
|
159
|
+
const d = {}, p = u.render("tbody", {}, a.children);
|
|
166
160
|
return u.render("table", d, p);
|
|
167
|
-
},
|
|
161
|
+
}, K = (a, u) => {
|
|
168
162
|
const d = {};
|
|
169
|
-
return u.render("tr", d,
|
|
170
|
-
},
|
|
171
|
-
const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } =
|
|
163
|
+
return u.render("tr", d, a.children);
|
|
164
|
+
}, W = (a, u) => {
|
|
165
|
+
const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } = a.attrs || {}, k = {
|
|
172
166
|
...b
|
|
173
167
|
};
|
|
174
168
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
175
|
-
const
|
|
176
|
-
return m &&
|
|
177
|
-
},
|
|
178
|
-
const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } =
|
|
169
|
+
const R = [];
|
|
170
|
+
return m && R.push(`width: ${m}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (k.style = R.join(" ")), u.render("td", O(k), a.children);
|
|
171
|
+
}, X = (a, u) => {
|
|
172
|
+
const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } = a.attrs || {}, k = {
|
|
179
173
|
...b
|
|
180
174
|
};
|
|
181
175
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
182
|
-
const
|
|
183
|
-
return m &&
|
|
184
|
-
},
|
|
185
|
-
[v.DOCUMENT,
|
|
186
|
-
[v.HEADING,
|
|
187
|
-
[v.PARAGRAPH,
|
|
188
|
-
[v.UL_LIST,
|
|
189
|
-
[v.OL_LIST,
|
|
190
|
-
[v.LIST_ITEM,
|
|
191
|
-
[v.IMAGE,
|
|
192
|
-
[v.EMOJI,
|
|
193
|
-
[v.CODE_BLOCK,
|
|
194
|
-
[v.HR,
|
|
195
|
-
[v.BR,
|
|
196
|
-
[v.QUOTE,
|
|
197
|
-
[v.COMPONENT,
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[
|
|
205
|
-
[
|
|
206
|
-
[
|
|
207
|
-
[
|
|
208
|
-
[
|
|
209
|
-
[
|
|
210
|
-
[
|
|
211
|
-
[v.TABLE,
|
|
212
|
-
[v.TABLE_ROW,
|
|
213
|
-
[v.TABLE_CELL,
|
|
214
|
-
[v.TABLE_HEADER,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
176
|
+
const R = [];
|
|
177
|
+
return m && R.push(`width: ${m}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (k.style = R.join(" ")), u.render("th", O(k), a.children);
|
|
178
|
+
}, U = /* @__PURE__ */ new Map([
|
|
179
|
+
[v.DOCUMENT, i("")],
|
|
180
|
+
[v.HEADING, f],
|
|
181
|
+
[v.PARAGRAPH, i("p")],
|
|
182
|
+
[v.UL_LIST, i("ul")],
|
|
183
|
+
[v.OL_LIST, i("ol")],
|
|
184
|
+
[v.LIST_ITEM, i("li")],
|
|
185
|
+
[v.IMAGE, h],
|
|
186
|
+
[v.EMOJI, y],
|
|
187
|
+
[v.CODE_BLOCK, _],
|
|
188
|
+
[v.HR, i("hr")],
|
|
189
|
+
[v.BR, i("br")],
|
|
190
|
+
[v.QUOTE, i("blockquote")],
|
|
191
|
+
[v.COMPONENT, J],
|
|
192
|
+
[V.TEXT, S],
|
|
193
|
+
[$.LINK, H],
|
|
194
|
+
[$.ANCHOR, H],
|
|
195
|
+
[$.STYLED, T("span", !0)],
|
|
196
|
+
[$.BOLD, T("strong")],
|
|
197
|
+
[$.TEXT_STYLE, T("span", !0)],
|
|
198
|
+
[$.ITALIC, T("em")],
|
|
199
|
+
[$.UNDERLINE, T("u")],
|
|
200
|
+
[$.STRIKE, T("s")],
|
|
201
|
+
[$.CODE, T("code")],
|
|
202
|
+
[$.SUPERSCRIPT, T("sup")],
|
|
203
|
+
[$.SUBSCRIPT, T("sub")],
|
|
204
|
+
[$.HIGHLIGHT, T("mark")],
|
|
205
|
+
[v.TABLE, Y],
|
|
206
|
+
[v.TABLE_ROW, K],
|
|
207
|
+
[v.TABLE_CELL, W],
|
|
208
|
+
[v.TABLE_HEADER, X]
|
|
209
|
+
]), B = new Map([
|
|
210
|
+
...U,
|
|
211
|
+
...Object.entries(s).map(([a, u]) => [a, u])
|
|
212
|
+
]), Q = () => ({
|
|
213
|
+
render: (a, u = {}, d) => {
|
|
214
|
+
if (c && a) {
|
|
215
|
+
const p = e.get(a) || 0;
|
|
216
|
+
e.set(a, p + 1), u.key = `${a}-${p}`;
|
|
217
|
+
}
|
|
218
|
+
return t(a, u, d);
|
|
219
|
+
},
|
|
220
|
+
originalResolvers: U,
|
|
221
|
+
mergedResolvers: B
|
|
222
|
+
});
|
|
223
|
+
function L(a) {
|
|
224
|
+
const u = B.get(a.type);
|
|
219
225
|
if (!u)
|
|
220
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
|
221
|
-
const d =
|
|
222
|
-
if (
|
|
223
|
-
return u(
|
|
224
|
-
const p =
|
|
226
|
+
return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
|
|
227
|
+
const d = Q();
|
|
228
|
+
if (a.type === "text")
|
|
229
|
+
return u(a, d);
|
|
230
|
+
const p = a.content ? a.content.map(C) : void 0;
|
|
225
231
|
return u({
|
|
226
|
-
...
|
|
232
|
+
...a,
|
|
227
233
|
children: p
|
|
228
234
|
}, d);
|
|
229
235
|
}
|
|
230
|
-
function C(
|
|
231
|
-
return
|
|
236
|
+
function C(a) {
|
|
237
|
+
return a.type === "doc" ? l ? a.content.map(L) : a.content.map(L).join("") : Array.isArray(a) ? a.map(L) : L(a);
|
|
232
238
|
}
|
|
233
239
|
return {
|
|
234
240
|
render: C
|
|
235
241
|
};
|
|
236
242
|
}
|
|
237
|
-
let
|
|
238
|
-
const
|
|
239
|
-
if (typeof window > "u"
|
|
243
|
+
let M = !1;
|
|
244
|
+
const z = [], q = (n) => new Promise((e, t) => {
|
|
245
|
+
if (typeof window > "u") {
|
|
246
|
+
t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (window.storyblokRegisterEvent = (s) => {
|
|
240
250
|
if (window.location === window.parent.location) {
|
|
241
251
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
242
252
|
return;
|
|
243
253
|
}
|
|
244
|
-
|
|
245
|
-
}, document.getElementById("storyblok-javascript-bridge"))
|
|
254
|
+
M ? s() : z.push(s);
|
|
255
|
+
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
256
|
+
e(void 0);
|
|
246
257
|
return;
|
|
258
|
+
}
|
|
247
259
|
const r = document.createElement("script");
|
|
248
260
|
r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
|
|
249
|
-
|
|
261
|
+
z.forEach((o) => o()), M = !0, e(s);
|
|
250
262
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
251
263
|
});
|
|
252
|
-
var
|
|
253
|
-
class
|
|
264
|
+
var le = Object.defineProperty, ce = (n, e, t) => e in n ? le(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
|
|
265
|
+
class he extends Error {
|
|
254
266
|
constructor(e) {
|
|
255
267
|
super(e), this.name = "AbortError";
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
|
-
function
|
|
270
|
+
function ue(n, e, t) {
|
|
259
271
|
if (!Number.isFinite(e))
|
|
260
272
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
261
273
|
if (!Number.isFinite(t))
|
|
262
274
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
263
275
|
const r = [];
|
|
264
|
-
let s = [], o = 0,
|
|
265
|
-
const
|
|
276
|
+
let s = [], o = 0, c = !1;
|
|
277
|
+
const l = async () => {
|
|
266
278
|
o++;
|
|
267
279
|
const h = r.shift();
|
|
268
280
|
if (h)
|
|
@@ -273,10 +285,10 @@ function he(n, e, t) {
|
|
|
273
285
|
h.reject(y);
|
|
274
286
|
}
|
|
275
287
|
const f = setTimeout(() => {
|
|
276
|
-
o--, r.length > 0 &&
|
|
288
|
+
o--, r.length > 0 && l(), s = s.filter((y) => y !== f);
|
|
277
289
|
}, t);
|
|
278
290
|
s.includes(f) || s.push(f);
|
|
279
|
-
},
|
|
291
|
+
}, i = (...h) => c ? Promise.reject(
|
|
280
292
|
new Error(
|
|
281
293
|
"Throttled function is already aborted and not accepting new promises"
|
|
282
294
|
)
|
|
@@ -285,22 +297,22 @@ function he(n, e, t) {
|
|
|
285
297
|
resolve: f,
|
|
286
298
|
reject: y,
|
|
287
299
|
args: h
|
|
288
|
-
}), o < e &&
|
|
300
|
+
}), o < e && l();
|
|
289
301
|
});
|
|
290
|
-
return
|
|
291
|
-
|
|
292
|
-
(h) => h.reject(() => new
|
|
302
|
+
return i.abort = () => {
|
|
303
|
+
c = !0, s.forEach(clearTimeout), s = [], r.forEach(
|
|
304
|
+
(h) => h.reject(() => new he("Throttle function aborted"))
|
|
293
305
|
), r.length = 0;
|
|
294
|
-
},
|
|
306
|
+
}, i;
|
|
295
307
|
}
|
|
296
|
-
const
|
|
308
|
+
const de = (n = "") => n.includes("/cdn/"), pe = (n, e = 25, t = 1) => ({
|
|
297
309
|
...n,
|
|
298
310
|
per_page: e,
|
|
299
311
|
page: t
|
|
300
|
-
}),
|
|
312
|
+
}), fe = (n) => new Promise((e) => setTimeout(e, n)), ye = (n = 0, e) => Array.from({ length: n }, e), ge = (n = 0, e = n) => {
|
|
301
313
|
const t = Math.abs(e - n) || 0, r = n < e ? 1 : -1;
|
|
302
|
-
return
|
|
303
|
-
},
|
|
314
|
+
return ye(t, (s, o) => o * r + n);
|
|
315
|
+
}, me = async (n, e) => Promise.all(n.map(e)), be = (n = [], e) => n.map(e).reduce((t, r) => [...t, ...r], []), N = (n, e, t) => {
|
|
304
316
|
const r = [];
|
|
305
317
|
for (const s in n) {
|
|
306
318
|
if (!Object.prototype.hasOwnProperty.call(n, s))
|
|
@@ -308,16 +320,16 @@ const ue = (n = "") => n.includes("/cdn/"), de = (n, e = 25, t = 1) => ({
|
|
|
308
320
|
const o = n[s];
|
|
309
321
|
if (o == null)
|
|
310
322
|
continue;
|
|
311
|
-
const
|
|
312
|
-
let
|
|
313
|
-
typeof o == "object" ?
|
|
323
|
+
const c = t ? "" : encodeURIComponent(s);
|
|
324
|
+
let l;
|
|
325
|
+
typeof o == "object" ? l = N(
|
|
314
326
|
o,
|
|
315
|
-
e ? e + encodeURIComponent(`[${
|
|
327
|
+
e ? e + encodeURIComponent(`[${c}]`) : c,
|
|
316
328
|
Array.isArray(o)
|
|
317
|
-
) :
|
|
329
|
+
) : l = `${e ? e + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(o)}`, r.push(l);
|
|
318
330
|
}
|
|
319
331
|
return r.join("&");
|
|
320
|
-
},
|
|
332
|
+
}, F = (n) => {
|
|
321
333
|
const e = {
|
|
322
334
|
eu: "api.storyblok.com",
|
|
323
335
|
us: "api-us.storyblok.com",
|
|
@@ -327,7 +339,7 @@ const ue = (n = "") => n.includes("/cdn/"), de = (n, e = 25, t = 1) => ({
|
|
|
327
339
|
};
|
|
328
340
|
return e[n] ?? e.eu;
|
|
329
341
|
};
|
|
330
|
-
class
|
|
342
|
+
class ve {
|
|
331
343
|
constructor(e) {
|
|
332
344
|
g(this, "baseURL"), g(this, "timeout"), g(this, "headers"), g(this, "responseInterceptor"), g(this, "fetch"), g(this, "ejectInterceptor"), g(this, "url"), g(this, "parameters"), g(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
|
333
345
|
}
|
|
@@ -366,25 +378,25 @@ class be {
|
|
|
366
378
|
async _methodHandler(e) {
|
|
367
379
|
let t = `${this.baseURL}${this.url}`, r = null;
|
|
368
380
|
e === "get" ? t = `${this.baseURL}${this.url}?${N(this.parameters)}` : r = JSON.stringify(this.parameters);
|
|
369
|
-
const s = new URL(t), o = new AbortController(), { signal:
|
|
370
|
-
let
|
|
371
|
-
this.timeout && (
|
|
381
|
+
const s = new URL(t), o = new AbortController(), { signal: c } = o;
|
|
382
|
+
let l;
|
|
383
|
+
this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
|
|
372
384
|
try {
|
|
373
|
-
const
|
|
385
|
+
const i = await this.fetch(`${s}`, {
|
|
374
386
|
method: e,
|
|
375
387
|
headers: this.headers,
|
|
376
388
|
body: r,
|
|
377
|
-
signal:
|
|
389
|
+
signal: c,
|
|
378
390
|
...this.fetchOptions
|
|
379
391
|
});
|
|
380
|
-
this.timeout && clearTimeout(
|
|
392
|
+
this.timeout && clearTimeout(l);
|
|
381
393
|
const h = await this._responseHandler(
|
|
382
|
-
|
|
394
|
+
i
|
|
383
395
|
);
|
|
384
396
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
|
|
385
|
-
} catch (
|
|
397
|
+
} catch (i) {
|
|
386
398
|
return {
|
|
387
|
-
message:
|
|
399
|
+
message: i
|
|
388
400
|
};
|
|
389
401
|
}
|
|
390
402
|
}
|
|
@@ -430,16 +442,16 @@ class be {
|
|
|
430
442
|
});
|
|
431
443
|
}
|
|
432
444
|
}
|
|
433
|
-
const
|
|
445
|
+
const G = "SB-Agent", P = {
|
|
434
446
|
defaultAgentName: "SB-JS-CLIENT",
|
|
435
447
|
defaultAgentVersion: "SB-Agent-Version",
|
|
436
448
|
packageVersion: "6.0.0"
|
|
437
|
-
},
|
|
449
|
+
}, ke = {
|
|
438
450
|
DRAFT: "draft"
|
|
439
451
|
};
|
|
440
452
|
let j = {};
|
|
441
453
|
const E = {};
|
|
442
|
-
class
|
|
454
|
+
class we {
|
|
443
455
|
/**
|
|
444
456
|
*
|
|
445
457
|
* @param config ISbConfig interface
|
|
@@ -449,22 +461,22 @@ class ke {
|
|
|
449
461
|
g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "version"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache"), g(this, "inlineAssets");
|
|
450
462
|
let r = e.endpoint || t;
|
|
451
463
|
if (!r) {
|
|
452
|
-
const
|
|
453
|
-
e.oauthToken ? r = `${
|
|
464
|
+
const c = e.https === !1 ? "http" : "https";
|
|
465
|
+
e.oauthToken ? r = `${c}://${F(e.region)}/v1` : r = `${c}://${F(e.region)}/v2`;
|
|
454
466
|
}
|
|
455
467
|
const s = new Headers();
|
|
456
|
-
s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([
|
|
457
|
-
s.set(
|
|
458
|
-
}), s.has(
|
|
468
|
+
s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([c, l]) => {
|
|
469
|
+
s.set(c, l);
|
|
470
|
+
}), s.has(G) || (s.set(G, P.defaultAgentName), s.set(
|
|
459
471
|
P.defaultAgentVersion,
|
|
460
472
|
P.packageVersion
|
|
461
473
|
));
|
|
462
474
|
let o = 5;
|
|
463
|
-
e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle =
|
|
475
|
+
e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ue(
|
|
464
476
|
this.throttledRequest.bind(this),
|
|
465
477
|
o,
|
|
466
478
|
1e3
|
|
467
|
-
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version ||
|
|
479
|
+
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.DRAFT, this.inlineAssets = e.inlineAssets || !1, this.client = new ve({
|
|
468
480
|
baseURL: r,
|
|
469
481
|
timeout: e.timeout || 0,
|
|
470
482
|
headers: s,
|
|
@@ -476,14 +488,14 @@ class ke {
|
|
|
476
488
|
return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
477
489
|
}
|
|
478
490
|
factoryParamOptions(e, t) {
|
|
479
|
-
return
|
|
491
|
+
return de(e) ? this.parseParams(t) : t;
|
|
480
492
|
}
|
|
481
493
|
makeRequest(e, t, r, s, o) {
|
|
482
|
-
const
|
|
494
|
+
const c = this.factoryParamOptions(
|
|
483
495
|
e,
|
|
484
|
-
|
|
496
|
+
pe(t, r, s)
|
|
485
497
|
);
|
|
486
|
-
return this.cacheResponse(e,
|
|
498
|
+
return this.cacheResponse(e, c, void 0, o);
|
|
487
499
|
}
|
|
488
500
|
get(e, t = {}, r) {
|
|
489
501
|
t || (t = {});
|
|
@@ -493,19 +505,19 @@ class ke {
|
|
|
493
505
|
return this.cacheResponse(s, o, void 0, r);
|
|
494
506
|
}
|
|
495
507
|
async getAll(e, t = {}, r, s) {
|
|
496
|
-
const o = (t == null ? void 0 : t.per_page) || 25,
|
|
508
|
+
const o = (t == null ? void 0 : t.per_page) || 25, c = `/${e}`.replace(/\/$/, ""), l = r ?? c.substring(c.lastIndexOf("/") + 1);
|
|
497
509
|
t.version = t.version || this.version;
|
|
498
|
-
const
|
|
499
|
-
|
|
510
|
+
const i = 1, h = await this.makeRequest(
|
|
511
|
+
c,
|
|
500
512
|
t,
|
|
501
513
|
o,
|
|
502
|
-
|
|
514
|
+
i,
|
|
503
515
|
s
|
|
504
|
-
), f = h.total ? Math.ceil(h.total / o) : 1, y = await
|
|
505
|
-
|
|
506
|
-
(_) => this.makeRequest(
|
|
516
|
+
), f = h.total ? Math.ceil(h.total / o) : 1, y = await me(
|
|
517
|
+
ge(i, f),
|
|
518
|
+
(_) => this.makeRequest(c, t, o, _ + 1, s)
|
|
507
519
|
);
|
|
508
|
-
return
|
|
520
|
+
return be([h, ...y], (_) => Object.values(_.data[l]));
|
|
509
521
|
}
|
|
510
522
|
post(e, t = {}, r) {
|
|
511
523
|
const s = `/${e}`;
|
|
@@ -585,7 +597,7 @@ class ke {
|
|
|
585
597
|
* allowing flexible specification of relation patterns.
|
|
586
598
|
*/
|
|
587
599
|
_insertRelations(e, t, r, s) {
|
|
588
|
-
if (Array.isArray(r) ? r.find((
|
|
600
|
+
if (Array.isArray(r) ? r.find((c) => c.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
|
|
589
601
|
this._resolveField(e, t, s);
|
|
590
602
|
return;
|
|
591
603
|
}
|
|
@@ -599,14 +611,14 @@ class ke {
|
|
|
599
611
|
* @param resolveId - The unique identifier for the current resolution context
|
|
600
612
|
*/
|
|
601
613
|
iterateTree(e, t, r) {
|
|
602
|
-
const s = (o,
|
|
614
|
+
const s = (o, c = "") => {
|
|
603
615
|
if (!(!o || o._stopResolving)) {
|
|
604
616
|
if (Array.isArray(o))
|
|
605
|
-
o.forEach((
|
|
617
|
+
o.forEach((l, i) => s(l, `${c}[${i}]`));
|
|
606
618
|
else if (typeof o == "object")
|
|
607
|
-
for (const
|
|
608
|
-
const
|
|
609
|
-
(o.component && o._uid || o.type === "link") && (this._insertRelations(o,
|
|
619
|
+
for (const l in o) {
|
|
620
|
+
const i = c ? `${c}.${l}` : l;
|
|
621
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, r), this._insertLinks(o, l, r)), s(o[l], i);
|
|
610
622
|
}
|
|
611
623
|
}
|
|
612
624
|
};
|
|
@@ -615,18 +627,18 @@ class ke {
|
|
|
615
627
|
async resolveLinks(e, t, r) {
|
|
616
628
|
let s = [];
|
|
617
629
|
if (e.link_uuids) {
|
|
618
|
-
const o = e.link_uuids.length,
|
|
619
|
-
for (let
|
|
620
|
-
const h = Math.min(o,
|
|
621
|
-
|
|
630
|
+
const o = e.link_uuids.length, c = [], l = 50;
|
|
631
|
+
for (let i = 0; i < o; i += l) {
|
|
632
|
+
const h = Math.min(o, i + l);
|
|
633
|
+
c.push(e.link_uuids.slice(i, h));
|
|
622
634
|
}
|
|
623
|
-
for (let
|
|
635
|
+
for (let i = 0; i < c.length; i++)
|
|
624
636
|
(await this.getStories({
|
|
625
|
-
per_page:
|
|
637
|
+
per_page: l,
|
|
626
638
|
language: t.language,
|
|
627
639
|
version: t.version,
|
|
628
640
|
starts_with: t.starts_with,
|
|
629
|
-
by_uuids:
|
|
641
|
+
by_uuids: c[i].join(",")
|
|
630
642
|
})).data.stories.forEach(
|
|
631
643
|
(h) => {
|
|
632
644
|
s.push(h);
|
|
@@ -644,18 +656,18 @@ class ke {
|
|
|
644
656
|
async resolveRelations(e, t, r) {
|
|
645
657
|
let s = [];
|
|
646
658
|
if (e.rel_uuids) {
|
|
647
|
-
const o = e.rel_uuids.length,
|
|
648
|
-
for (let
|
|
649
|
-
const h = Math.min(o,
|
|
650
|
-
|
|
659
|
+
const o = e.rel_uuids.length, c = [], l = 50;
|
|
660
|
+
for (let i = 0; i < o; i += l) {
|
|
661
|
+
const h = Math.min(o, i + l);
|
|
662
|
+
c.push(e.rel_uuids.slice(i, h));
|
|
651
663
|
}
|
|
652
|
-
for (let
|
|
664
|
+
for (let i = 0; i < c.length; i++)
|
|
653
665
|
(await this.getStories({
|
|
654
|
-
per_page:
|
|
666
|
+
per_page: l,
|
|
655
667
|
language: t.language,
|
|
656
668
|
version: t.version,
|
|
657
669
|
starts_with: t.starts_with,
|
|
658
|
-
by_uuids:
|
|
670
|
+
by_uuids: c[i].join(","),
|
|
659
671
|
excluding_fields: t.excluding_fields
|
|
660
672
|
})).data.stories.forEach((h) => {
|
|
661
673
|
s.push(h);
|
|
@@ -681,26 +693,26 @@ class ke {
|
|
|
681
693
|
*/
|
|
682
694
|
async resolveStories(e, t, r) {
|
|
683
695
|
var s, o;
|
|
684
|
-
let
|
|
685
|
-
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (
|
|
686
|
-
for (const
|
|
696
|
+
let c = [];
|
|
697
|
+
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (c = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
|
|
698
|
+
for (const l in this.relations[r])
|
|
687
699
|
this.iterateTree(
|
|
688
|
-
this.relations[r][
|
|
689
|
-
|
|
700
|
+
this.relations[r][l],
|
|
701
|
+
c,
|
|
690
702
|
r
|
|
691
703
|
);
|
|
692
|
-
e.story ? this.iterateTree(e.story,
|
|
693
|
-
this.iterateTree(
|
|
704
|
+
e.story ? this.iterateTree(e.story, c, r) : e.stories.forEach((l) => {
|
|
705
|
+
this.iterateTree(l, c, r);
|
|
694
706
|
}), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
|
|
695
707
|
}
|
|
696
708
|
async cacheResponse(e, t, r, s) {
|
|
697
|
-
const o = N({ url: e, params: t }),
|
|
709
|
+
const o = N({ url: e, params: t }), c = this.cacheProvider();
|
|
698
710
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
699
|
-
const
|
|
700
|
-
if (
|
|
701
|
-
return Promise.resolve(
|
|
711
|
+
const l = await c.get(o);
|
|
712
|
+
if (l)
|
|
713
|
+
return Promise.resolve(l);
|
|
702
714
|
}
|
|
703
|
-
return new Promise(async (
|
|
715
|
+
return new Promise(async (l, i) => {
|
|
704
716
|
var h;
|
|
705
717
|
try {
|
|
706
718
|
const f = await this.throttle(
|
|
@@ -710,24 +722,24 @@ class ke {
|
|
|
710
722
|
s
|
|
711
723
|
);
|
|
712
724
|
if (f.status !== 200)
|
|
713
|
-
return
|
|
725
|
+
return i(f);
|
|
714
726
|
let y = { data: f.data, headers: f.headers };
|
|
715
727
|
if ((h = f.headers) != null && h["per-page"] && (y = Object.assign({}, y, {
|
|
716
728
|
perPage: f.headers["per-page"] ? Number.parseInt(f.headers["per-page"]) : 0,
|
|
717
729
|
total: f.headers["per-page"] ? Number.parseInt(f.headers.total) : 0
|
|
718
730
|
})), y.data.story || y.data.stories) {
|
|
719
|
-
const
|
|
720
|
-
await this.resolveStories(y.data, t, `${
|
|
731
|
+
const T = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
732
|
+
await this.resolveStories(y.data, t, `${T}`), y = await this.processInlineAssets(y);
|
|
721
733
|
}
|
|
722
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await
|
|
734
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await c.set(o, y);
|
|
723
735
|
const _ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
724
|
-
return t.token && y.data.cv && (_ && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv),
|
|
736
|
+
return t.token && y.data.cv && (_ && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), l(y);
|
|
725
737
|
} catch (f) {
|
|
726
738
|
if (f.response && f.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
727
739
|
return console.log(
|
|
728
740
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
729
|
-
), await
|
|
730
|
-
|
|
741
|
+
), await fe(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(i);
|
|
742
|
+
i(f);
|
|
731
743
|
}
|
|
732
744
|
});
|
|
733
745
|
}
|
|
@@ -766,6 +778,7 @@ class ke {
|
|
|
766
778
|
case "custom":
|
|
767
779
|
if (this.cache.custom)
|
|
768
780
|
return this.cache.custom;
|
|
781
|
+
// eslint-disable-next-line no-fallthrough
|
|
769
782
|
default:
|
|
770
783
|
return {
|
|
771
784
|
get() {
|
|
@@ -806,7 +819,7 @@ class ke {
|
|
|
806
819
|
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((r) => (r.content = t(r.content), r))), e;
|
|
807
820
|
}
|
|
808
821
|
}
|
|
809
|
-
const
|
|
822
|
+
const Te = (n = {}) => {
|
|
810
823
|
const { apiOptions: e } = n;
|
|
811
824
|
if (!e || !e.accessToken) {
|
|
812
825
|
console.error(
|
|
@@ -814,8 +827,8 @@ const we = (n = {}) => {
|
|
|
814
827
|
);
|
|
815
828
|
return;
|
|
816
829
|
}
|
|
817
|
-
return { storyblokApi: new
|
|
818
|
-
},
|
|
830
|
+
return { storyblokApi: new we(e) };
|
|
831
|
+
}, Re = (n) => {
|
|
819
832
|
if (typeof n != "object" || typeof n._editable > "u")
|
|
820
833
|
return {};
|
|
821
834
|
try {
|
|
@@ -835,16 +848,16 @@ const _e = (n, e, t = {}) => {
|
|
|
835
848
|
var r;
|
|
836
849
|
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
837
850
|
"_storyblok"
|
|
838
|
-
),
|
|
839
|
-
if (!(!s || !
|
|
851
|
+
), c = o !== null && +o === n;
|
|
852
|
+
if (!(!s || !c)) {
|
|
840
853
|
if (!n) {
|
|
841
854
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
842
855
|
return;
|
|
843
856
|
}
|
|
844
857
|
window.storyblokRegisterEvent(() => {
|
|
845
|
-
new window.StoryblokBridge(t).on(["input", "published", "change"], (
|
|
846
|
-
var
|
|
847
|
-
|
|
858
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
|
|
859
|
+
var i;
|
|
860
|
+
l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === n ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === n && window.location.reload());
|
|
848
861
|
});
|
|
849
862
|
});
|
|
850
863
|
}
|
|
@@ -854,32 +867,32 @@ const _e = (n, e, t = {}) => {
|
|
|
854
867
|
bridge: r,
|
|
855
868
|
accessToken: s,
|
|
856
869
|
use: o = [],
|
|
857
|
-
apiOptions:
|
|
858
|
-
bridgeUrl:
|
|
870
|
+
apiOptions: c = {},
|
|
871
|
+
bridgeUrl: l
|
|
859
872
|
} = n;
|
|
860
|
-
|
|
861
|
-
const
|
|
873
|
+
c.accessToken = c.accessToken || s;
|
|
874
|
+
const i = { bridge: r, apiOptions: c };
|
|
862
875
|
let h = {};
|
|
863
876
|
o.forEach((y) => {
|
|
864
|
-
h = { ...h, ...y(
|
|
865
|
-
}),
|
|
877
|
+
h = { ...h, ...y(i) };
|
|
878
|
+
}), l && (x = l);
|
|
866
879
|
const f = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
867
|
-
return r !== !1 && f &&
|
|
880
|
+
return r !== !1 && f && q(x), h;
|
|
868
881
|
};
|
|
869
|
-
function
|
|
870
|
-
return
|
|
882
|
+
function Ee(n, e) {
|
|
883
|
+
return ae(e).render(n);
|
|
871
884
|
}
|
|
872
|
-
const
|
|
885
|
+
const Ae = () => q(x);
|
|
873
886
|
export {
|
|
874
887
|
v as BlockTypes,
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
888
|
+
$ as MarkTypes,
|
|
889
|
+
V as TextTypes,
|
|
890
|
+
Te as apiPlugin,
|
|
891
|
+
Ae as loadStoryblokBridge,
|
|
879
892
|
_e as registerStoryblokBridge,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
893
|
+
Ee as renderRichText,
|
|
894
|
+
ae as richTextResolver,
|
|
895
|
+
Re as storyblokEditable,
|
|
883
896
|
$e as storyblokInit,
|
|
884
897
|
_e as useStoryblokBridge
|
|
885
898
|
};
|