@storyblok/vue 8.2.2 → 9.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.
- package/README.md +0 -66
- package/dist/index.d.ts +1 -1
- package/dist/storyblok-vue.js +2 -25
- package/dist/storyblok-vue.mjs +619 -950
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -4,439 +4,337 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { defineComponent as q, ref as x, resolveDynamicComponent as N, inject as ue, createBlock as J, openBlock as K, mergeProps as he, h as Y, createTextVNode as de, watch as pe, onMounted as fe, defineAsyncComponent as ye } from "vue";
|
|
8
|
+
function me(s, e) {
|
|
9
|
+
if (!e)
|
|
10
|
+
return { src: s, attrs: {} };
|
|
11
|
+
let t = 0, o = 0;
|
|
12
|
+
const r = {}, n = [];
|
|
13
|
+
function i(c, u, f, y, _) {
|
|
14
|
+
typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : _.push(`${y}(${c})`);
|
|
15
|
+
}
|
|
16
|
+
if (typeof e == "object") {
|
|
17
|
+
if (typeof e.width == "number" && e.width > 0 ? (r.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 ? (r.height = e.height, o = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (r.loading = e.loading), e.class && (r.class = e.class), e.filters) {
|
|
18
|
+
const { filters: c } = e || {}, { blur: u, brightness: f, fill: y, format: _, grayscale: E, quality: R, rotate: S } = c || {};
|
|
19
|
+
u && i(u, 0, 100, "blur", n), R && i(R, 0, 100, "quality", n), f && i(f, 0, 100, "brightness", n), y && n.push(`fill(${y})`), E && n.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${S})`), _ && ["webp", "png", "jpeg"].includes(_) && n.push(`format(${_})`);
|
|
20
|
+
}
|
|
21
|
+
e.srcset && (r.srcset = e.srcset.map((c) => {
|
|
22
|
+
if (typeof c == "number")
|
|
23
|
+
return `${s}/m/${c}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
|
|
24
|
+
if (Array.isArray(c) && c.length === 2) {
|
|
25
|
+
const [u, f] = c;
|
|
26
|
+
return `${s}/m/${u}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
|
27
|
+
} else {
|
|
28
|
+
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}).join(", ")), e.sizes && (r.sizes = e.sizes.join(", "));
|
|
32
|
+
}
|
|
33
|
+
let l = `${s}/m/`;
|
|
34
|
+
return t > 0 && o > 0 && (l = `${l}${t}x${o}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
35
|
+
src: l,
|
|
36
|
+
attrs: r
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var g = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s.TABLE = "table", s.TABLE_ROW = "tableRow", s.TABLE_CELL = "tableCell", s.TABLE_HEADER = "tableHeader", s))(g || {}), $ = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))($ || {}), W = /* @__PURE__ */ ((s) => (s.TEXT = "text", s))(W || {}), I = /* @__PURE__ */ ((s) => (s.URL = "url", s.STORY = "story", s.ASSET = "asset", s.EMAIL = "email", s))(I || {});
|
|
40
|
+
const be = [
|
|
41
|
+
"area",
|
|
42
|
+
"base",
|
|
43
|
+
"br",
|
|
44
|
+
"col",
|
|
45
|
+
"embed",
|
|
46
|
+
"hr",
|
|
47
|
+
"img",
|
|
48
|
+
"input",
|
|
49
|
+
"link",
|
|
50
|
+
"meta",
|
|
51
|
+
"param",
|
|
52
|
+
"source",
|
|
53
|
+
"track",
|
|
54
|
+
"wbr"
|
|
55
|
+
], ge = (s = {}) => Object.keys(s).map((e) => `${e}="${s[e]}"`).join(" "), ve = (s = {}) => Object.keys(s).map((e) => `${e}: ${s[e]}`).join("; ");
|
|
56
|
+
function ke(s) {
|
|
57
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
58
|
+
}
|
|
59
|
+
const O = (s) => Object.fromEntries(Object.entries(s).filter(([e, t]) => t !== void 0));
|
|
60
|
+
function B(s, e = {}, t) {
|
|
61
|
+
const o = ge(e), r = o ? `${s} ${o}` : s, n = Array.isArray(t) ? t.join("") : t || "";
|
|
62
|
+
if (s) {
|
|
63
|
+
if (be.includes(s))
|
|
64
|
+
return `<${r}>`;
|
|
65
|
+
} else return n;
|
|
66
|
+
return `<${r}>${n}</${s}>`;
|
|
67
|
+
}
|
|
68
|
+
function X(s = {}) {
|
|
69
|
+
const e = /* @__PURE__ */ new Map(), {
|
|
70
|
+
renderFn: t = B,
|
|
71
|
+
textFn: o = ke,
|
|
72
|
+
resolvers: r = {},
|
|
73
|
+
optimizeImages: n = !1,
|
|
74
|
+
keyedResolvers: i = !1
|
|
75
|
+
} = s, l = t !== B, c = () => ({ render: (a, h = {}, d) => {
|
|
76
|
+
if (i && a) {
|
|
77
|
+
const p = e.get(a) || 0;
|
|
78
|
+
e.set(a, p + 1), h.key = `${a}-${p}`;
|
|
79
|
+
}
|
|
80
|
+
return t(a, h, d);
|
|
81
|
+
} }), u = (a) => (h, d) => {
|
|
82
|
+
const p = h.attrs || {};
|
|
83
|
+
return d.render(a, p, h.children || null);
|
|
84
|
+
}, f = (a, h) => {
|
|
85
|
+
const { src: d, alt: p, title: b, srcset: w, sizes: v } = a.attrs || {};
|
|
86
|
+
let k = d, T = {};
|
|
87
|
+
if (n) {
|
|
88
|
+
const { src: le, attrs: ce } = me(d, n);
|
|
89
|
+
k = le, T = ce;
|
|
90
|
+
}
|
|
91
|
+
const ae = {
|
|
92
|
+
src: k,
|
|
93
|
+
alt: p,
|
|
94
|
+
title: b,
|
|
95
|
+
srcset: w,
|
|
96
|
+
sizes: v,
|
|
97
|
+
...T
|
|
98
|
+
};
|
|
99
|
+
return h.render("img", O(ae));
|
|
100
|
+
}, y = (a, h) => {
|
|
101
|
+
const { level: d, ...p } = a.attrs || {};
|
|
102
|
+
return h.render(`h${d}`, p, a.children);
|
|
103
|
+
}, _ = (a, h) => {
|
|
104
|
+
var d, p, b, w;
|
|
105
|
+
const v = h.render("img", {
|
|
106
|
+
src: (d = a.attrs) == null ? void 0 : d.fallbackImage,
|
|
107
|
+
alt: (p = a.attrs) == null ? void 0 : p.alt,
|
|
108
|
+
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
109
|
+
draggable: "false",
|
|
110
|
+
loading: "lazy"
|
|
111
|
+
});
|
|
112
|
+
return h.render("span", {
|
|
113
|
+
"data-type": "emoji",
|
|
114
|
+
"data-name": (b = a.attrs) == null ? void 0 : b.name,
|
|
115
|
+
"data-emoji": (w = a.attrs) == null ? void 0 : w.emoji
|
|
116
|
+
}, v);
|
|
117
|
+
}, E = (a, h) => h.render(
|
|
118
|
+
"pre",
|
|
119
|
+
a.attrs || {},
|
|
120
|
+
h.render("code", {}, a.children || "")
|
|
121
|
+
), R = (a, h = !1) => ({ text: d, attrs: p }, b) => {
|
|
122
|
+
const { class: w, id: v, ...k } = p || {}, T = h ? {
|
|
123
|
+
class: w,
|
|
124
|
+
id: v,
|
|
125
|
+
style: ve(k) || void 0
|
|
126
|
+
} : p || {};
|
|
127
|
+
return b.render(a, O(T), d);
|
|
128
|
+
}, S = (a) => P(a), ee = (a) => {
|
|
129
|
+
const { marks: h, ...d } = a;
|
|
130
|
+
if ("text" in a) {
|
|
131
|
+
if (h)
|
|
132
|
+
return h.reduce(
|
|
133
|
+
(b, w) => S({ ...w, text: b }),
|
|
134
|
+
S({ ...d, children: d.children })
|
|
135
|
+
);
|
|
136
|
+
const p = a.attrs || {};
|
|
137
|
+
if (i) {
|
|
138
|
+
const b = e.get("txt") || 0;
|
|
139
|
+
e.set("txt", b + 1), p.key = `txt-${b}`;
|
|
140
|
+
}
|
|
141
|
+
return o(d.text, p);
|
|
142
|
+
}
|
|
143
|
+
return "";
|
|
144
|
+
}, U = (a, h) => {
|
|
145
|
+
const { linktype: d, href: p, anchor: b, ...w } = a.attrs || {};
|
|
146
|
+
let v = "";
|
|
147
|
+
switch (d) {
|
|
148
|
+
case I.ASSET:
|
|
149
|
+
case I.URL:
|
|
150
|
+
v = p;
|
|
151
|
+
break;
|
|
152
|
+
case I.EMAIL:
|
|
153
|
+
v = `mailto:${p}`;
|
|
154
|
+
break;
|
|
155
|
+
case I.STORY:
|
|
156
|
+
v = p, b && (v = `${v}#${b}`);
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
v = p;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
const k = { ...w };
|
|
163
|
+
return v && (k.href = v), h.render("a", k, a.text);
|
|
164
|
+
}, te = (a, h) => {
|
|
165
|
+
var d, p;
|
|
166
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
|
|
167
|
+
blok: (d = a == null ? void 0 : a.attrs) == null ? void 0 : d.body[0],
|
|
168
|
+
id: (p = a.attrs) == null ? void 0 : p.id,
|
|
169
|
+
style: "display: none"
|
|
170
|
+
});
|
|
171
|
+
}, se = (a, h) => {
|
|
172
|
+
const d = {}, p = h.render("tbody", {}, a.children);
|
|
173
|
+
return h.render("table", d, p);
|
|
174
|
+
}, re = (a, h) => {
|
|
175
|
+
const d = {};
|
|
176
|
+
return h.render("tr", d, a.children);
|
|
177
|
+
}, oe = (a, h) => {
|
|
178
|
+
const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = a.attrs || {}, k = {
|
|
179
|
+
...v
|
|
180
|
+
};
|
|
181
|
+
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
182
|
+
const T = [];
|
|
183
|
+
return b && T.push(`width: ${b}px;`), w && T.push(`background-color: ${w};`), T.length > 0 && (k.style = T.join(" ")), h.render("td", O(k), a.children);
|
|
184
|
+
}, ne = (a, h) => {
|
|
185
|
+
const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = a.attrs || {}, k = {
|
|
186
|
+
...v
|
|
187
|
+
};
|
|
188
|
+
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
189
|
+
const T = [];
|
|
190
|
+
return b && T.push(`width: ${b}px;`), w && T.push(`background-color: ${w};`), T.length > 0 && (k.style = T.join(" ")), h.render("th", O(k), a.children);
|
|
191
|
+
}, ie = new Map([
|
|
192
|
+
[g.DOCUMENT, u("")],
|
|
193
|
+
[g.HEADING, y],
|
|
194
|
+
[g.PARAGRAPH, u("p")],
|
|
195
|
+
[g.UL_LIST, u("ul")],
|
|
196
|
+
[g.OL_LIST, u("ol")],
|
|
197
|
+
[g.LIST_ITEM, u("li")],
|
|
198
|
+
[g.IMAGE, f],
|
|
199
|
+
[g.EMOJI, _],
|
|
200
|
+
[g.CODE_BLOCK, E],
|
|
201
|
+
[g.HR, u("hr")],
|
|
202
|
+
[g.BR, u("br")],
|
|
203
|
+
[g.QUOTE, u("blockquote")],
|
|
204
|
+
[g.COMPONENT, te],
|
|
205
|
+
[W.TEXT, ee],
|
|
206
|
+
[$.LINK, U],
|
|
207
|
+
[$.ANCHOR, U],
|
|
208
|
+
[$.STYLED, R("span", !0)],
|
|
209
|
+
[$.BOLD, R("strong")],
|
|
210
|
+
[$.TEXT_STYLE, R("span", !0)],
|
|
211
|
+
[$.ITALIC, R("em")],
|
|
212
|
+
[$.UNDERLINE, R("u")],
|
|
213
|
+
[$.STRIKE, R("s")],
|
|
214
|
+
[$.CODE, R("code")],
|
|
215
|
+
[$.SUPERSCRIPT, R("sup")],
|
|
216
|
+
[$.SUBSCRIPT, R("sub")],
|
|
217
|
+
[$.HIGHLIGHT, R("mark")],
|
|
218
|
+
[g.TABLE, se],
|
|
219
|
+
[g.TABLE_ROW, re],
|
|
220
|
+
[g.TABLE_CELL, oe],
|
|
221
|
+
[g.TABLE_HEADER, ne],
|
|
222
|
+
...Object.entries(r).map(([a, h]) => [a, h])
|
|
223
|
+
]);
|
|
224
|
+
function C(a) {
|
|
225
|
+
const h = ie.get(a.type);
|
|
226
|
+
if (!h)
|
|
227
|
+
return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
|
|
228
|
+
const d = c();
|
|
229
|
+
if (a.type === "text")
|
|
230
|
+
return h(a, d);
|
|
231
|
+
const p = a.content ? a.content.map(P) : void 0;
|
|
232
|
+
return h({
|
|
233
|
+
...a,
|
|
234
|
+
children: p
|
|
235
|
+
}, d);
|
|
236
|
+
}
|
|
237
|
+
function P(a) {
|
|
238
|
+
return a.type === "doc" ? l ? a.content.map(C) : a.content.map(C).join("") : Array.isArray(a) ? a.map(C) : C(a);
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
render: P
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
let M = !1;
|
|
245
|
+
const F = [], we = (s) => new Promise((e, t) => {
|
|
246
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
11
247
|
if (window.location === window.parent.location) {
|
|
12
248
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
13
249
|
return;
|
|
14
250
|
}
|
|
15
|
-
|
|
251
|
+
M ? r() : F.push(r);
|
|
16
252
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
17
253
|
return;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
F.forEach((n) => n()),
|
|
21
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
254
|
+
const o = document.createElement("script");
|
|
255
|
+
o.async = !0, o.src = s, o.id = "storyblok-javascript-bridge", o.onerror = (r) => t(r), o.onload = (r) => {
|
|
256
|
+
F.forEach((n) => n()), M = !0, e(r);
|
|
257
|
+
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
22
258
|
});
|
|
23
|
-
var
|
|
24
|
-
class
|
|
259
|
+
var Te = Object.defineProperty, _e = (s, e, t) => e in s ? Te(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, m = (s, e, t) => _e(s, typeof e != "symbol" ? e + "" : e, t);
|
|
260
|
+
class Re extends Error {
|
|
25
261
|
constructor(e) {
|
|
26
262
|
super(e), this.name = "AbortError";
|
|
27
263
|
}
|
|
28
264
|
}
|
|
29
|
-
function
|
|
265
|
+
function $e(s, e, t) {
|
|
30
266
|
if (!Number.isFinite(e))
|
|
31
267
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
32
268
|
if (!Number.isFinite(t))
|
|
33
269
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
34
|
-
const
|
|
35
|
-
let
|
|
36
|
-
const
|
|
270
|
+
const o = [];
|
|
271
|
+
let r = [], n = 0, i = !1;
|
|
272
|
+
const l = async () => {
|
|
37
273
|
n++;
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
274
|
+
const u = o.shift();
|
|
275
|
+
if (u)
|
|
40
276
|
try {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
} catch (
|
|
44
|
-
|
|
277
|
+
const y = await s(...u.args);
|
|
278
|
+
u.resolve(y);
|
|
279
|
+
} catch (y) {
|
|
280
|
+
u.reject(y);
|
|
45
281
|
}
|
|
46
|
-
const
|
|
47
|
-
n--,
|
|
282
|
+
const f = setTimeout(() => {
|
|
283
|
+
n--, o.length > 0 && l(), r = r.filter((y) => y !== f);
|
|
48
284
|
}, t);
|
|
49
|
-
|
|
50
|
-
},
|
|
285
|
+
r.includes(f) || r.push(f);
|
|
286
|
+
}, c = (...u) => i ? Promise.reject(
|
|
51
287
|
new Error(
|
|
52
288
|
"Throttled function is already aborted and not accepting new promises"
|
|
53
289
|
)
|
|
54
|
-
) : new Promise((
|
|
55
|
-
|
|
56
|
-
resolve:
|
|
57
|
-
reject:
|
|
58
|
-
args:
|
|
59
|
-
}), n < e &&
|
|
290
|
+
) : new Promise((f, y) => {
|
|
291
|
+
o.push({
|
|
292
|
+
resolve: f,
|
|
293
|
+
reject: y,
|
|
294
|
+
args: u
|
|
295
|
+
}), n < e && l();
|
|
60
296
|
});
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
),
|
|
65
|
-
},
|
|
66
|
-
}
|
|
67
|
-
class P {
|
|
68
|
-
constructor() {
|
|
69
|
-
m(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), m(this, "getOptionsPage", (e, t = 25, s = 1) => ({
|
|
70
|
-
...e,
|
|
71
|
-
per_page: t,
|
|
72
|
-
page: s
|
|
73
|
-
})), m(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), m(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), m(this, "range", (e = 0, t = e) => {
|
|
74
|
-
const s = Math.abs(t - e) || 0, o = e < t ? 1 : -1;
|
|
75
|
-
return this.arrayFrom(s, (n, a) => a * o + e);
|
|
76
|
-
}), m(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), m(this, "flatMap", (e = [], t) => e.map(t).reduce((s, o) => [...s, ...o], [])), m(this, "escapeHTML", function(e) {
|
|
77
|
-
const t = {
|
|
78
|
-
"&": "&",
|
|
79
|
-
"<": "<",
|
|
80
|
-
">": ">",
|
|
81
|
-
'"': """,
|
|
82
|
-
"'": "'"
|
|
83
|
-
}, s = /[&<>"']/g, o = new RegExp(s.source);
|
|
84
|
-
return e && o.test(e) ? e.replace(s, (n) => t[n]) : e;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @method stringify
|
|
89
|
-
* @param {object} params
|
|
90
|
-
* @param {string} prefix
|
|
91
|
-
* @param {boolean} isArray
|
|
92
|
-
* @return {string} Stringified object
|
|
93
|
-
*/
|
|
94
|
-
stringify(e, t, s) {
|
|
95
|
-
const o = [];
|
|
96
|
-
for (const n in e) {
|
|
97
|
-
if (!Object.prototype.hasOwnProperty.call(e, n))
|
|
98
|
-
continue;
|
|
99
|
-
const a = e[n];
|
|
100
|
-
if (a == null)
|
|
101
|
-
continue;
|
|
102
|
-
const i = s ? "" : encodeURIComponent(n);
|
|
103
|
-
let l;
|
|
104
|
-
typeof a == "object" ? l = this.stringify(
|
|
105
|
-
a,
|
|
106
|
-
t ? t + encodeURIComponent(`[${i}]`) : i,
|
|
107
|
-
Array.isArray(a)
|
|
108
|
-
) : l = `${t ? t + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(a)}`, o.push(l);
|
|
109
|
-
}
|
|
110
|
-
return o.join("&");
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* @method getRegionURL
|
|
114
|
-
* @param {string} regionCode region code, could be eu, us, cn, ap or ca
|
|
115
|
-
* @return {string} The base URL of the region
|
|
116
|
-
*/
|
|
117
|
-
getRegionURL(e) {
|
|
118
|
-
const t = "api.storyblok.com", s = "api-us.storyblok.com", o = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
|
|
119
|
-
switch (e) {
|
|
120
|
-
case "us":
|
|
121
|
-
return s;
|
|
122
|
-
case "cn":
|
|
123
|
-
return o;
|
|
124
|
-
case "ap":
|
|
125
|
-
return n;
|
|
126
|
-
case "ca":
|
|
127
|
-
return a;
|
|
128
|
-
default:
|
|
129
|
-
return t;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
297
|
+
return c.abort = () => {
|
|
298
|
+
i = !0, r.forEach(clearTimeout), r = [], o.forEach(
|
|
299
|
+
(u) => u.reject(() => new Re("Throttle function aborted"))
|
|
300
|
+
), o.length = 0;
|
|
301
|
+
}, c;
|
|
132
302
|
}
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return t;
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
singleTag: "br"
|
|
156
|
-
}), Ae = (r) => ({
|
|
157
|
-
tag: `h${r.attrs.level}`
|
|
158
|
-
}), Ie = (r) => ({
|
|
159
|
-
singleTag: [
|
|
160
|
-
{
|
|
161
|
-
tag: "img",
|
|
162
|
-
attrs: we(r.attrs, ["src", "alt", "title"])
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}), Ce = () => ({
|
|
166
|
-
tag: "li"
|
|
167
|
-
}), Le = () => ({
|
|
168
|
-
tag: "ol"
|
|
169
|
-
}), Oe = () => ({
|
|
170
|
-
tag: "p"
|
|
171
|
-
}), Pe = (r) => ({
|
|
172
|
-
tag: [
|
|
173
|
-
{
|
|
174
|
-
tag: "span",
|
|
175
|
-
attrs: {
|
|
176
|
-
"data-type": "emoji",
|
|
177
|
-
"data-name": r.attrs.name,
|
|
178
|
-
emoji: r.attrs.emoji
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
}), Ne = () => ({
|
|
183
|
-
tag: "b"
|
|
184
|
-
}), Me = () => ({
|
|
185
|
-
tag: "s"
|
|
186
|
-
}), He = () => ({
|
|
187
|
-
tag: "u"
|
|
188
|
-
}), De = () => ({
|
|
189
|
-
tag: "strong"
|
|
190
|
-
}), Ue = () => ({
|
|
191
|
-
tag: "code"
|
|
192
|
-
}), Be = () => ({
|
|
193
|
-
tag: "i"
|
|
194
|
-
}), ze = (r) => {
|
|
195
|
-
if (!r.attrs)
|
|
196
|
-
return {
|
|
197
|
-
tag: ""
|
|
198
|
-
};
|
|
199
|
-
const e = new P().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
|
|
200
|
-
if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), Re(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
201
|
-
for (const o in t.custom)
|
|
202
|
-
t[o] = t.custom[o];
|
|
203
|
-
delete t.custom;
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
tag: [
|
|
207
|
-
{
|
|
208
|
-
tag: "a",
|
|
209
|
-
attrs: t
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
};
|
|
213
|
-
}, Fe = (r) => ({
|
|
214
|
-
tag: [
|
|
215
|
-
{
|
|
216
|
-
tag: "span",
|
|
217
|
-
attrs: r.attrs
|
|
218
|
-
}
|
|
219
|
-
]
|
|
220
|
-
}), qe = () => ({
|
|
221
|
-
tag: "sub"
|
|
222
|
-
}), Ve = () => ({
|
|
223
|
-
tag: "sup"
|
|
224
|
-
}), Ge = (r) => ({
|
|
225
|
-
tag: [
|
|
226
|
-
{
|
|
227
|
-
tag: "span",
|
|
228
|
-
attrs: r.attrs
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
}), Ke = (r) => {
|
|
232
|
-
var e;
|
|
233
|
-
return (e = r.attrs) != null && e.color ? {
|
|
234
|
-
tag: [
|
|
235
|
-
{
|
|
236
|
-
tag: "span",
|
|
237
|
-
attrs: {
|
|
238
|
-
style: `background-color:${r.attrs.color};`
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
]
|
|
242
|
-
} : {
|
|
243
|
-
tag: ""
|
|
244
|
-
};
|
|
245
|
-
}, Je = (r) => {
|
|
246
|
-
var e;
|
|
247
|
-
return (e = r.attrs) != null && e.color ? {
|
|
248
|
-
tag: [
|
|
249
|
-
{
|
|
250
|
-
tag: "span",
|
|
251
|
-
attrs: {
|
|
252
|
-
style: `color:${r.attrs.color}`
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
} : {
|
|
257
|
-
tag: ""
|
|
258
|
-
};
|
|
259
|
-
}, Ye = {
|
|
260
|
-
nodes: {
|
|
261
|
-
horizontal_rule: _e,
|
|
262
|
-
blockquote: Se,
|
|
263
|
-
bullet_list: Ee,
|
|
264
|
-
code_block: xe,
|
|
265
|
-
hard_break: je,
|
|
266
|
-
heading: Ae,
|
|
267
|
-
image: Ie,
|
|
268
|
-
list_item: Ce,
|
|
269
|
-
ordered_list: Le,
|
|
270
|
-
paragraph: Oe,
|
|
271
|
-
emoji: Pe
|
|
272
|
-
},
|
|
273
|
-
marks: {
|
|
274
|
-
bold: Ne,
|
|
275
|
-
strike: Me,
|
|
276
|
-
underline: He,
|
|
277
|
-
strong: De,
|
|
278
|
-
code: Ue,
|
|
279
|
-
italic: Be,
|
|
280
|
-
link: ze,
|
|
281
|
-
styled: Fe,
|
|
282
|
-
subscript: qe,
|
|
283
|
-
superscript: Ve,
|
|
284
|
-
anchor: Ge,
|
|
285
|
-
highlight: Ke,
|
|
286
|
-
textStyle: Je
|
|
303
|
+
const Ae = (s = "") => s.includes("/cdn/"), Ee = (s, e = 25, t = 1) => ({
|
|
304
|
+
...s,
|
|
305
|
+
per_page: e,
|
|
306
|
+
page: t
|
|
307
|
+
}), Se = (s) => new Promise((e) => setTimeout(e, s)), Ie = (s = 0, e) => Array.from({ length: s }, e), Le = (s = 0, e = s) => {
|
|
308
|
+
const t = Math.abs(e - s) || 0, o = s < e ? 1 : -1;
|
|
309
|
+
return Ie(t, (r, n) => n * o + s);
|
|
310
|
+
}, Ce = async (s, e) => Promise.all(s.map(e)), Oe = (s = [], e) => s.map(e).reduce((t, o) => [...t, ...o], []), D = (s, e, t) => {
|
|
311
|
+
const o = [];
|
|
312
|
+
for (const r in s) {
|
|
313
|
+
if (!Object.prototype.hasOwnProperty.call(s, r))
|
|
314
|
+
continue;
|
|
315
|
+
const n = s[r];
|
|
316
|
+
if (n == null)
|
|
317
|
+
continue;
|
|
318
|
+
const i = t ? "" : encodeURIComponent(r);
|
|
319
|
+
let l;
|
|
320
|
+
typeof n == "object" ? l = D(
|
|
321
|
+
n,
|
|
322
|
+
e ? e + encodeURIComponent(`[${i}]`) : i,
|
|
323
|
+
Array.isArray(n)
|
|
324
|
+
) : l = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, o.push(l);
|
|
287
325
|
}
|
|
288
|
-
|
|
326
|
+
return o.join("&");
|
|
327
|
+
}, V = (s) => {
|
|
289
328
|
const e = {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
return
|
|
297
|
-
};
|
|
298
|
-
let q = !1, N = class {
|
|
299
|
-
constructor(r) {
|
|
300
|
-
m(this, "marks"), m(this, "nodes"), r || (r = Ye), this.marks = r.marks || [], this.nodes = r.nodes || [];
|
|
301
|
-
}
|
|
302
|
-
addNode(r, e) {
|
|
303
|
-
this.nodes[r] = e;
|
|
304
|
-
}
|
|
305
|
-
addMark(r, e) {
|
|
306
|
-
this.marks[r] = e;
|
|
307
|
-
}
|
|
308
|
-
render(r, e = { optimizeImages: !1 }, t = !0) {
|
|
309
|
-
if (!q && t && (console.warn(
|
|
310
|
-
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
|
311
|
-
), q = !0), r && r.content && Array.isArray(r.content)) {
|
|
312
|
-
let s = "";
|
|
313
|
-
return r.content.forEach((o) => {
|
|
314
|
-
s += this.renderNode(o);
|
|
315
|
-
}), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
|
|
316
|
-
}
|
|
317
|
-
return console.warn(
|
|
318
|
-
`The render method must receive an Object with a "content" field.
|
|
319
|
-
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
320
|
-
ISbRichtext:
|
|
321
|
-
content?: ISbRichtext[]
|
|
322
|
-
marks?: ISbRichtext[]
|
|
323
|
-
attrs?: any
|
|
324
|
-
text?: string
|
|
325
|
-
type: string
|
|
326
|
-
|
|
327
|
-
Example:
|
|
328
|
-
{
|
|
329
|
-
content: [
|
|
330
|
-
{
|
|
331
|
-
content: [
|
|
332
|
-
{
|
|
333
|
-
text: 'Hello World',
|
|
334
|
-
type: 'text'
|
|
335
|
-
}
|
|
336
|
-
],
|
|
337
|
-
type: 'paragraph'
|
|
338
|
-
}
|
|
339
|
-
],
|
|
340
|
-
type: 'doc'
|
|
341
|
-
}`
|
|
342
|
-
), "";
|
|
343
|
-
}
|
|
344
|
-
optimizeImages(r, e) {
|
|
345
|
-
let t = 0, s = 0, o = "", n = "";
|
|
346
|
-
typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (o += `width="${e.width}" `, t = e.width), typeof e.height == "number" && e.height > 0 && (o += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (o += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (o += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (n += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (n += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-F]{6}/gi) || e.filters.fill === "transparent") && (n += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (n += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (n += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (n += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (n += `:rotate(${e.filters.rotate})`), n.length > 0 && (n = `/filters${n}`))), o.length > 0 && (r = r.replace(/<img/g, `<img ${o.trim()}`));
|
|
347
|
-
const a = t > 0 || s > 0 || n.length > 0 ? `${t}x${s}${n}` : "";
|
|
348
|
-
return r = r.replace(
|
|
349
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
350
|
-
`a.storyblok.com/f/$1/$2.$3/m/${a}`
|
|
351
|
-
), typeof e != "boolean" && (e.sizes || e.srcset) && (r = r.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
|
|
352
|
-
var l, h;
|
|
353
|
-
const u = i.match(
|
|
354
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
355
|
-
);
|
|
356
|
-
if (u && u.length > 0) {
|
|
357
|
-
const p = {
|
|
358
|
-
srcset: (l = e.srcset) == null ? void 0 : l.map(($) => {
|
|
359
|
-
if (typeof $ == "number")
|
|
360
|
-
return `//${u}/m/${$}x0${n} ${$}w`;
|
|
361
|
-
if (typeof $ == "object" && $.length === 2) {
|
|
362
|
-
let T = 0, E = 0;
|
|
363
|
-
return typeof $[0] == "number" && (T = $[0]), typeof $[1] == "number" && (E = $[1]), `//${u}/m/${T}x${E}${n} ${T}w`;
|
|
364
|
-
}
|
|
365
|
-
return "";
|
|
366
|
-
}).join(", "),
|
|
367
|
-
sizes: (h = e.sizes) == null ? void 0 : h.map(($) => $).join(", ")
|
|
368
|
-
};
|
|
369
|
-
let b = "";
|
|
370
|
-
return p.srcset && (b += `srcset="${p.srcset}" `), p.sizes && (b += `sizes="${p.sizes}" `), i.replace(/<img/g, `<img ${b.trim()}`);
|
|
371
|
-
}
|
|
372
|
-
return i;
|
|
373
|
-
})), r;
|
|
374
|
-
}
|
|
375
|
-
renderNode(r) {
|
|
376
|
-
const e = [];
|
|
377
|
-
r.marks && r.marks.forEach((s) => {
|
|
378
|
-
const o = this.getMatchingMark(s);
|
|
379
|
-
o && o.tag !== "" && e.push(this.renderOpeningTag(o.tag));
|
|
380
|
-
});
|
|
381
|
-
const t = this.getMatchingNode(r);
|
|
382
|
-
return t && t.tag && e.push(this.renderOpeningTag(t.tag)), r.content ? r.content.forEach((s) => {
|
|
383
|
-
e.push(this.renderNode(s));
|
|
384
|
-
}) : r.text ? e.push(We(r.text)) : t && t.singleTag ? e.push(this.renderTag(t.singleTag, " /")) : t && t.html ? e.push(t.html) : r.type === "emoji" && e.push(this.renderEmoji(r)), t && t.tag && e.push(this.renderClosingTag(t.tag)), r.marks && r.marks.slice(0).reverse().forEach((s) => {
|
|
385
|
-
const o = this.getMatchingMark(s);
|
|
386
|
-
o && o.tag !== "" && e.push(this.renderClosingTag(o.tag));
|
|
387
|
-
}), e.join("");
|
|
388
|
-
}
|
|
389
|
-
renderTag(r, e) {
|
|
390
|
-
return r.constructor === String ? `<${r}${e}>` : r.map((t) => {
|
|
391
|
-
if (t.constructor === String)
|
|
392
|
-
return `<${t}${e}>`;
|
|
393
|
-
{
|
|
394
|
-
let s = `<${t.tag}`;
|
|
395
|
-
if (t.attrs) {
|
|
396
|
-
for (const o in t.attrs)
|
|
397
|
-
if (Object.prototype.hasOwnProperty.call(t.attrs, o)) {
|
|
398
|
-
const n = t.attrs[o];
|
|
399
|
-
n !== null && (s += ` ${o}="${n}"`);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return `${s}${e}>`;
|
|
403
|
-
}
|
|
404
|
-
}).join("");
|
|
405
|
-
}
|
|
406
|
-
renderOpeningTag(r) {
|
|
407
|
-
return this.renderTag(r, "");
|
|
408
|
-
}
|
|
409
|
-
renderClosingTag(r) {
|
|
410
|
-
return r.constructor === String ? `</${r}>` : r.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
411
|
-
}
|
|
412
|
-
getMatchingNode(r) {
|
|
413
|
-
const e = this.nodes[r.type];
|
|
414
|
-
if (typeof e == "function")
|
|
415
|
-
return e(r);
|
|
416
|
-
}
|
|
417
|
-
getMatchingMark(r) {
|
|
418
|
-
const e = this.marks[r.type];
|
|
419
|
-
if (typeof e == "function")
|
|
420
|
-
return e(r);
|
|
421
|
-
}
|
|
422
|
-
renderEmoji(r) {
|
|
423
|
-
if (r.attrs.emoji)
|
|
424
|
-
return r.attrs.emoji;
|
|
425
|
-
const e = [
|
|
426
|
-
{
|
|
427
|
-
tag: "img",
|
|
428
|
-
attrs: {
|
|
429
|
-
src: r.attrs.fallbackImage,
|
|
430
|
-
draggable: "false",
|
|
431
|
-
loading: "lazy",
|
|
432
|
-
align: "absmiddle"
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
];
|
|
436
|
-
return this.renderTag(e, " /");
|
|
437
|
-
}
|
|
329
|
+
eu: "api.storyblok.com",
|
|
330
|
+
us: "api-us.storyblok.com",
|
|
331
|
+
cn: "app.storyblokchina.cn",
|
|
332
|
+
ap: "api-ap.storyblok.com",
|
|
333
|
+
ca: "api-ca.storyblok.com"
|
|
334
|
+
};
|
|
335
|
+
return e[s] ?? e.eu;
|
|
438
336
|
};
|
|
439
|
-
class
|
|
337
|
+
class je {
|
|
440
338
|
constructor(e) {
|
|
441
339
|
m(this, "baseURL"), m(this, "timeout"), m(this, "headers"), m(this, "responseInterceptor"), m(this, "fetch"), m(this, "ejectInterceptor"), m(this, "url"), m(this, "parameters"), m(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 = {};
|
|
442
340
|
}
|
|
@@ -459,47 +357,41 @@ class Xe {
|
|
|
459
357
|
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
|
460
358
|
}
|
|
461
359
|
async _responseHandler(e) {
|
|
462
|
-
const t = [],
|
|
360
|
+
const t = [], o = {
|
|
463
361
|
data: {},
|
|
464
362
|
headers: {},
|
|
465
363
|
status: 0,
|
|
466
364
|
statusText: ""
|
|
467
365
|
};
|
|
468
|
-
e.status !== 204 && await e.json().then((
|
|
469
|
-
|
|
366
|
+
e.status !== 204 && await e.json().then((r) => {
|
|
367
|
+
o.data = r;
|
|
470
368
|
});
|
|
471
|
-
for (const
|
|
472
|
-
t[
|
|
473
|
-
return
|
|
369
|
+
for (const r of e.headers.entries())
|
|
370
|
+
t[r[0]] = r[1];
|
|
371
|
+
return o.headers = { ...t }, o.status = e.status, o.statusText = e.statusText, o;
|
|
474
372
|
}
|
|
475
373
|
async _methodHandler(e) {
|
|
476
|
-
let t = `${this.baseURL}${this.url}`,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
)}`;
|
|
482
|
-
} else
|
|
483
|
-
s = JSON.stringify(this.parameters);
|
|
484
|
-
const o = new URL(t), n = new AbortController(), { signal: a } = n;
|
|
485
|
-
let i;
|
|
486
|
-
this.timeout && (i = setTimeout(() => n.abort(), this.timeout));
|
|
374
|
+
let t = `${this.baseURL}${this.url}`, o = null;
|
|
375
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${D(this.parameters)}` : o = JSON.stringify(this.parameters);
|
|
376
|
+
const r = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
377
|
+
let l;
|
|
378
|
+
this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
|
|
487
379
|
try {
|
|
488
|
-
const
|
|
380
|
+
const c = await this.fetch(`${r}`, {
|
|
489
381
|
method: e,
|
|
490
382
|
headers: this.headers,
|
|
491
|
-
body:
|
|
492
|
-
signal:
|
|
383
|
+
body: o,
|
|
384
|
+
signal: i,
|
|
493
385
|
...this.fetchOptions
|
|
494
386
|
});
|
|
495
|
-
this.timeout && clearTimeout(
|
|
496
|
-
const
|
|
497
|
-
|
|
387
|
+
this.timeout && clearTimeout(l);
|
|
388
|
+
const u = await this._responseHandler(
|
|
389
|
+
c
|
|
498
390
|
);
|
|
499
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
|
500
|
-
} catch (
|
|
391
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
|
|
392
|
+
} catch (c) {
|
|
501
393
|
return {
|
|
502
|
-
message:
|
|
394
|
+
message: c
|
|
503
395
|
};
|
|
504
396
|
}
|
|
505
397
|
}
|
|
@@ -509,125 +401,137 @@ class Xe {
|
|
|
509
401
|
eject() {
|
|
510
402
|
this.ejectInterceptor = !0;
|
|
511
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Normalizes error messages from different response structures
|
|
406
|
+
* @param data The response data that might contain error information
|
|
407
|
+
* @returns A normalized error message string
|
|
408
|
+
*/
|
|
409
|
+
_normalizeErrorMessage(e) {
|
|
410
|
+
if (Array.isArray(e))
|
|
411
|
+
return e[0] || "Unknown error";
|
|
412
|
+
if (e && typeof e == "object") {
|
|
413
|
+
if (e.error)
|
|
414
|
+
return e.error;
|
|
415
|
+
for (const t in e) {
|
|
416
|
+
if (Array.isArray(e[t]))
|
|
417
|
+
return `${t}: ${e[t][0]}`;
|
|
418
|
+
if (typeof e[t] == "string")
|
|
419
|
+
return `${t}: ${e[t]}`;
|
|
420
|
+
}
|
|
421
|
+
if (e.slug)
|
|
422
|
+
return e.slug;
|
|
423
|
+
}
|
|
424
|
+
return "Unknown error";
|
|
425
|
+
}
|
|
512
426
|
_statusHandler(e) {
|
|
513
427
|
const t = /20[0-6]/g;
|
|
514
|
-
return new Promise((
|
|
428
|
+
return new Promise((o, r) => {
|
|
515
429
|
if (t.test(`${e.status}`))
|
|
516
|
-
return
|
|
430
|
+
return o(e);
|
|
517
431
|
const n = {
|
|
518
|
-
message: e.
|
|
432
|
+
message: this._normalizeErrorMessage(e.data),
|
|
519
433
|
status: e.status,
|
|
520
|
-
response:
|
|
434
|
+
response: e
|
|
521
435
|
};
|
|
522
|
-
|
|
436
|
+
r(n);
|
|
523
437
|
});
|
|
524
438
|
}
|
|
525
439
|
}
|
|
526
|
-
const
|
|
440
|
+
const z = "SB-Agent", H = {
|
|
527
441
|
defaultAgentName: "SB-JS-CLIENT",
|
|
528
442
|
defaultAgentVersion: "SB-Agent-Version",
|
|
529
443
|
packageVersion: "6.0.0"
|
|
444
|
+
}, xe = {
|
|
445
|
+
DRAFT: "draft"
|
|
530
446
|
};
|
|
531
|
-
let
|
|
532
|
-
const
|
|
533
|
-
class
|
|
447
|
+
let j = {};
|
|
448
|
+
const A = {};
|
|
449
|
+
class Pe {
|
|
534
450
|
/**
|
|
535
451
|
*
|
|
536
452
|
* @param config ISbConfig interface
|
|
537
453
|
* @param pEndpoint string, optional
|
|
538
454
|
*/
|
|
539
455
|
constructor(e, t) {
|
|
540
|
-
m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "
|
|
541
|
-
let
|
|
542
|
-
if (!
|
|
543
|
-
const
|
|
544
|
-
e.oauthToken ?
|
|
456
|
+
m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "resolveCounter"), m(this, "relations"), m(this, "links"), m(this, "version"), m(this, "richTextResolver"), m(this, "resolveNestedRelations"), m(this, "stringifiedStoriesCache"), m(this, "inlineAssets");
|
|
457
|
+
let o = e.endpoint || t;
|
|
458
|
+
if (!o) {
|
|
459
|
+
const i = e.https === !1 ? "http" : "https";
|
|
460
|
+
e.oauthToken ? o = `${i}://${V(e.region)}/v1` : o = `${i}://${V(e.region)}/v2`;
|
|
545
461
|
}
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}),
|
|
550
|
-
|
|
551
|
-
|
|
462
|
+
const r = new Headers();
|
|
463
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
|
|
464
|
+
r.set(i, l);
|
|
465
|
+
}), r.has(z) || (r.set(z, H.defaultAgentName), r.set(
|
|
466
|
+
H.defaultAgentVersion,
|
|
467
|
+
H.packageVersion
|
|
552
468
|
));
|
|
553
469
|
let n = 5;
|
|
554
|
-
e.oauthToken && (
|
|
470
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = $e(
|
|
555
471
|
this.throttledRequest.bind(this),
|
|
556
472
|
n,
|
|
557
473
|
1e3
|
|
558
|
-
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.
|
|
559
|
-
baseURL:
|
|
474
|
+
), 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 || xe.DRAFT, this.inlineAssets = e.inlineAssets || !1, this.client = new je({
|
|
475
|
+
baseURL: o,
|
|
560
476
|
timeout: e.timeout || 0,
|
|
561
|
-
headers:
|
|
477
|
+
headers: r,
|
|
562
478
|
responseInterceptor: e.responseInterceptor,
|
|
563
479
|
fetch: e.fetch
|
|
564
480
|
});
|
|
565
481
|
}
|
|
566
|
-
setComponentResolver(e) {
|
|
567
|
-
this.richTextResolver.addNode("blok", (t) => {
|
|
568
|
-
let s = "";
|
|
569
|
-
return t.attrs.body && t.attrs.body.forEach((o) => {
|
|
570
|
-
s += e(o.component, o);
|
|
571
|
-
}), {
|
|
572
|
-
html: s
|
|
573
|
-
};
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
482
|
parseParams(e) {
|
|
577
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
483
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = A[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
578
484
|
}
|
|
579
485
|
factoryParamOptions(e, t) {
|
|
580
|
-
return
|
|
486
|
+
return Ae(e) ? this.parseParams(t) : t;
|
|
581
487
|
}
|
|
582
|
-
makeRequest(e, t,
|
|
583
|
-
const
|
|
488
|
+
makeRequest(e, t, o, r, n) {
|
|
489
|
+
const i = this.factoryParamOptions(
|
|
584
490
|
e,
|
|
585
|
-
|
|
491
|
+
Ee(t, o, r)
|
|
586
492
|
);
|
|
587
|
-
return this.cacheResponse(e,
|
|
493
|
+
return this.cacheResponse(e, i, void 0, n);
|
|
588
494
|
}
|
|
589
|
-
get(e, t,
|
|
495
|
+
get(e, t = {}, o) {
|
|
590
496
|
t || (t = {});
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
497
|
+
const r = `/${e}`;
|
|
498
|
+
t.version = t.version || this.version;
|
|
499
|
+
const n = this.factoryParamOptions(r, t);
|
|
500
|
+
return this.cacheResponse(r, n, void 0, o);
|
|
501
|
+
}
|
|
502
|
+
async getAll(e, t = {}, o, r) {
|
|
503
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = o ?? i.substring(i.lastIndexOf("/") + 1);
|
|
504
|
+
t.version = t.version || this.version;
|
|
505
|
+
const c = 1, u = await this.makeRequest(
|
|
506
|
+
i,
|
|
597
507
|
t,
|
|
598
508
|
n,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
),
|
|
602
|
-
|
|
603
|
-
(
|
|
509
|
+
c,
|
|
510
|
+
r
|
|
511
|
+
), f = u.total ? Math.ceil(u.total / n) : 1, y = await Ce(
|
|
512
|
+
Le(c, f),
|
|
513
|
+
(_) => this.makeRequest(i, t, n, _ + 1, r)
|
|
604
514
|
);
|
|
605
|
-
return
|
|
515
|
+
return Oe([u, ...y], (_) => Object.values(_.data[l]));
|
|
606
516
|
}
|
|
607
|
-
post(e, t,
|
|
608
|
-
const
|
|
609
|
-
return
|
|
610
|
-
this.throttle("post", o, t, s)
|
|
611
|
-
);
|
|
517
|
+
post(e, t = {}, o) {
|
|
518
|
+
const r = `/${e}`;
|
|
519
|
+
return this.throttle("post", r, t, o);
|
|
612
520
|
}
|
|
613
|
-
put(e, t,
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
this.throttle("put", o, t, s)
|
|
617
|
-
);
|
|
521
|
+
put(e, t = {}, o) {
|
|
522
|
+
const r = `/${e}`;
|
|
523
|
+
return this.throttle("put", r, t, o);
|
|
618
524
|
}
|
|
619
|
-
delete(e, t,
|
|
525
|
+
delete(e, t = {}, o) {
|
|
620
526
|
t || (t = {});
|
|
621
|
-
const
|
|
622
|
-
return
|
|
623
|
-
this.throttle("delete", o, t, s)
|
|
624
|
-
);
|
|
527
|
+
const r = `/${e}`;
|
|
528
|
+
return this.throttle("delete", r, t, o);
|
|
625
529
|
}
|
|
626
|
-
getStories(e, t) {
|
|
530
|
+
getStories(e = {}, t) {
|
|
627
531
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
628
532
|
}
|
|
629
|
-
getStory(e, t,
|
|
630
|
-
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t,
|
|
533
|
+
getStory(e, t = {}, o) {
|
|
534
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, o);
|
|
631
535
|
}
|
|
632
536
|
getToken() {
|
|
633
537
|
return this.accessToken;
|
|
@@ -641,9 +545,9 @@ class Qe {
|
|
|
641
545
|
_cleanCopy(e) {
|
|
642
546
|
return JSON.parse(JSON.stringify(e));
|
|
643
547
|
}
|
|
644
|
-
_insertLinks(e, t,
|
|
645
|
-
const
|
|
646
|
-
|
|
548
|
+
_insertLinks(e, t, o) {
|
|
549
|
+
const r = e[t];
|
|
550
|
+
r && r.fieldtype === "multilink" && r.linktype === "story" && typeof r.id == "string" && this.links[o][r.id] ? r.story = this._cleanCopy(this.links[o][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[o][r.uuid] && (r.story = this._cleanCopy(this.links[o][r.uuid]));
|
|
647
551
|
}
|
|
648
552
|
/**
|
|
649
553
|
*
|
|
@@ -664,10 +568,10 @@ class Qe {
|
|
|
664
568
|
* - For single strings: directly replaces the UUID with the story reference
|
|
665
569
|
* - For arrays: maps through each UUID and replaces with corresponding story references
|
|
666
570
|
*/
|
|
667
|
-
_resolveField(e, t,
|
|
668
|
-
const
|
|
669
|
-
typeof
|
|
670
|
-
(n) => this.getStoryReference(
|
|
571
|
+
_resolveField(e, t, o) {
|
|
572
|
+
const r = e[t];
|
|
573
|
+
typeof r == "string" ? e[t] = this.getStoryReference(o, r) : Array.isArray(r) && (e[t] = r.map(
|
|
574
|
+
(n) => this.getStoryReference(o, n)
|
|
671
575
|
).filter(Boolean));
|
|
672
576
|
}
|
|
673
577
|
/**
|
|
@@ -687,13 +591,13 @@ class Qe {
|
|
|
687
591
|
* The method supports both string and array formats for the fields parameter,
|
|
688
592
|
* allowing flexible specification of relation patterns.
|
|
689
593
|
*/
|
|
690
|
-
_insertRelations(e, t,
|
|
691
|
-
if (Array.isArray(
|
|
692
|
-
this._resolveField(e, t,
|
|
594
|
+
_insertRelations(e, t, o, r) {
|
|
595
|
+
if (Array.isArray(o) ? o.find((i) => i.endsWith(`.${t}`)) : o.endsWith(`.${t}`)) {
|
|
596
|
+
this._resolveField(e, t, r);
|
|
693
597
|
return;
|
|
694
598
|
}
|
|
695
599
|
const n = e.component ? `${e.component}.${t}` : t;
|
|
696
|
-
(Array.isArray(
|
|
600
|
+
(Array.isArray(o) ? o.includes(n) : o === n) && this._resolveField(e, t, r);
|
|
697
601
|
}
|
|
698
602
|
/**
|
|
699
603
|
* Recursively traverses and resolves relations in the story content tree
|
|
@@ -701,72 +605,73 @@ class Qe {
|
|
|
701
605
|
* @param fields - The relation patterns to resolve
|
|
702
606
|
* @param resolveId - The unique identifier for the current resolution context
|
|
703
607
|
*/
|
|
704
|
-
iterateTree(e, t,
|
|
705
|
-
const
|
|
608
|
+
iterateTree(e, t, o) {
|
|
609
|
+
const r = (n, i = "") => {
|
|
706
610
|
if (!(!n || n._stopResolving)) {
|
|
707
611
|
if (Array.isArray(n))
|
|
708
|
-
n.forEach((
|
|
612
|
+
n.forEach((l, c) => r(l, `${i}[${c}]`));
|
|
709
613
|
else if (typeof n == "object")
|
|
710
|
-
for (const
|
|
711
|
-
const
|
|
712
|
-
(n.component && n._uid || n.type === "link") && (this._insertRelations(n,
|
|
614
|
+
for (const l in n) {
|
|
615
|
+
const c = i ? `${i}.${l}` : l;
|
|
616
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, o), this._insertLinks(n, l, o)), r(n[l], c);
|
|
713
617
|
}
|
|
714
618
|
}
|
|
715
619
|
};
|
|
716
|
-
|
|
620
|
+
r(e.content);
|
|
717
621
|
}
|
|
718
|
-
async resolveLinks(e, t,
|
|
719
|
-
let
|
|
622
|
+
async resolveLinks(e, t, o) {
|
|
623
|
+
let r = [];
|
|
720
624
|
if (e.link_uuids) {
|
|
721
|
-
const n = e.link_uuids.length,
|
|
722
|
-
for (let
|
|
723
|
-
const
|
|
724
|
-
|
|
625
|
+
const n = e.link_uuids.length, i = [], l = 50;
|
|
626
|
+
for (let c = 0; c < n; c += l) {
|
|
627
|
+
const u = Math.min(n, c + l);
|
|
628
|
+
i.push(e.link_uuids.slice(c, u));
|
|
725
629
|
}
|
|
726
|
-
for (let
|
|
630
|
+
for (let c = 0; c < i.length; c++)
|
|
727
631
|
(await this.getStories({
|
|
728
|
-
per_page:
|
|
632
|
+
per_page: l,
|
|
729
633
|
language: t.language,
|
|
730
634
|
version: t.version,
|
|
731
635
|
starts_with: t.starts_with,
|
|
732
|
-
by_uuids:
|
|
636
|
+
by_uuids: i[c].join(",")
|
|
733
637
|
})).data.stories.forEach(
|
|
734
|
-
(
|
|
735
|
-
|
|
638
|
+
(u) => {
|
|
639
|
+
r.push(u);
|
|
736
640
|
}
|
|
737
641
|
);
|
|
738
642
|
} else
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
this.links[
|
|
643
|
+
r = e.links;
|
|
644
|
+
r.forEach((n) => {
|
|
645
|
+
this.links[o][n.uuid] = {
|
|
742
646
|
...n,
|
|
743
647
|
_stopResolving: !0
|
|
744
648
|
};
|
|
745
649
|
});
|
|
746
650
|
}
|
|
747
|
-
async resolveRelations(e, t,
|
|
748
|
-
let
|
|
651
|
+
async resolveRelations(e, t, o) {
|
|
652
|
+
let r = [];
|
|
749
653
|
if (e.rel_uuids) {
|
|
750
|
-
const n = e.rel_uuids.length,
|
|
751
|
-
for (let
|
|
752
|
-
const
|
|
753
|
-
|
|
654
|
+
const n = e.rel_uuids.length, i = [], l = 50;
|
|
655
|
+
for (let c = 0; c < n; c += l) {
|
|
656
|
+
const u = Math.min(n, c + l);
|
|
657
|
+
i.push(e.rel_uuids.slice(c, u));
|
|
754
658
|
}
|
|
755
|
-
for (let
|
|
659
|
+
for (let c = 0; c < i.length; c++)
|
|
756
660
|
(await this.getStories({
|
|
757
|
-
per_page:
|
|
661
|
+
per_page: l,
|
|
758
662
|
language: t.language,
|
|
759
663
|
version: t.version,
|
|
760
664
|
starts_with: t.starts_with,
|
|
761
|
-
by_uuids:
|
|
665
|
+
by_uuids: i[c].join(","),
|
|
762
666
|
excluding_fields: t.excluding_fields
|
|
763
|
-
})).data.stories.forEach((
|
|
764
|
-
|
|
667
|
+
})).data.stories.forEach((u) => {
|
|
668
|
+
r.push(u);
|
|
765
669
|
});
|
|
670
|
+
r.length > 0 && (e.rels = r, delete e.rel_uuids);
|
|
766
671
|
} else
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
this.relations[
|
|
672
|
+
r = e.rels;
|
|
673
|
+
r && r.length > 0 && r.forEach((n) => {
|
|
674
|
+
this.relations[o][n.uuid] = {
|
|
770
675
|
...n,
|
|
771
676
|
_stopResolving: !0
|
|
772
677
|
};
|
|
@@ -781,94 +686,93 @@ class Qe {
|
|
|
781
686
|
* @returns Promise<void>
|
|
782
687
|
*
|
|
783
688
|
*/
|
|
784
|
-
async resolveStories(e, t,
|
|
785
|
-
var
|
|
786
|
-
let
|
|
787
|
-
if (this.links[
|
|
788
|
-
for (const
|
|
689
|
+
async resolveStories(e, t, o) {
|
|
690
|
+
var r, n;
|
|
691
|
+
let i = [];
|
|
692
|
+
if (this.links[o] = {}, this.relations[o] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, o)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, o), this.resolveNestedRelations)
|
|
693
|
+
for (const l in this.relations[o])
|
|
789
694
|
this.iterateTree(
|
|
790
|
-
this.relations[
|
|
791
|
-
|
|
792
|
-
|
|
695
|
+
this.relations[o][l],
|
|
696
|
+
i,
|
|
697
|
+
o
|
|
793
698
|
);
|
|
794
|
-
e.story ? this.iterateTree(e.story,
|
|
795
|
-
this.iterateTree(
|
|
796
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
|
699
|
+
e.story ? this.iterateTree(e.story, i, o) : e.stories.forEach((l) => {
|
|
700
|
+
this.iterateTree(l, i, o);
|
|
701
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[o], delete this.relations[o];
|
|
797
702
|
}
|
|
798
|
-
async cacheResponse(e, t,
|
|
799
|
-
const n =
|
|
703
|
+
async cacheResponse(e, t, o, r) {
|
|
704
|
+
const n = D({ url: e, params: t }), i = this.cacheProvider();
|
|
800
705
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
return Promise.resolve(
|
|
706
|
+
const l = await i.get(n);
|
|
707
|
+
if (l)
|
|
708
|
+
return Promise.resolve(l);
|
|
804
709
|
}
|
|
805
|
-
return new Promise(async (
|
|
806
|
-
var
|
|
710
|
+
return new Promise(async (l, c) => {
|
|
711
|
+
var u;
|
|
807
712
|
try {
|
|
808
|
-
const
|
|
713
|
+
const f = await this.throttle(
|
|
809
714
|
"get",
|
|
810
715
|
e,
|
|
811
716
|
t,
|
|
812
|
-
|
|
717
|
+
r
|
|
813
718
|
);
|
|
814
|
-
if (
|
|
815
|
-
return
|
|
816
|
-
let
|
|
817
|
-
if ((
|
|
818
|
-
perPage:
|
|
819
|
-
total:
|
|
820
|
-
})),
|
|
821
|
-
const
|
|
822
|
-
await this.resolveStories(
|
|
719
|
+
if (f.status !== 200)
|
|
720
|
+
return c(f);
|
|
721
|
+
let y = { data: f.data, headers: f.headers };
|
|
722
|
+
if ((u = f.headers) != null && u["per-page"] && (y = Object.assign({}, y, {
|
|
723
|
+
perPage: f.headers["per-page"] ? Number.parseInt(f.headers["per-page"]) : 0,
|
|
724
|
+
total: f.headers["per-page"] ? Number.parseInt(f.headers.total) : 0
|
|
725
|
+
})), y.data.story || y.data.stories) {
|
|
726
|
+
const E = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
727
|
+
await this.resolveStories(y.data, t, `${E}`), y = await this.processInlineAssets(y);
|
|
823
728
|
}
|
|
824
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await
|
|
825
|
-
const
|
|
826
|
-
return t.token &&
|
|
827
|
-
} catch (
|
|
828
|
-
if (
|
|
729
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, y);
|
|
730
|
+
const _ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
731
|
+
return t.token && y.data.cv && (_ && A[t.token] && A[t.token] !== y.data.cv && await this.flushCache(), A[t.token] = y.data.cv), l(y);
|
|
732
|
+
} catch (f) {
|
|
733
|
+
if (f.response && f.status === 429 && (o = typeof o > "u" ? 0 : o + 1, o < this.maxRetries))
|
|
829
734
|
return console.log(
|
|
830
735
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
831
|
-
), await
|
|
832
|
-
|
|
736
|
+
), await Se(this.retriesDelay), this.cacheResponse(e, t, o).then(l).catch(c);
|
|
737
|
+
c(f);
|
|
833
738
|
}
|
|
834
739
|
});
|
|
835
740
|
}
|
|
836
|
-
throttledRequest(e, t,
|
|
837
|
-
return this.client.setFetchOptions(
|
|
741
|
+
throttledRequest(e, t, o, r) {
|
|
742
|
+
return this.client.setFetchOptions(r), this.client[e](t, o);
|
|
838
743
|
}
|
|
839
744
|
cacheVersions() {
|
|
840
|
-
return
|
|
745
|
+
return A;
|
|
841
746
|
}
|
|
842
747
|
cacheVersion() {
|
|
843
|
-
return
|
|
748
|
+
return A[this.accessToken];
|
|
844
749
|
}
|
|
845
750
|
setCacheVersion(e) {
|
|
846
|
-
this.accessToken && (
|
|
751
|
+
this.accessToken && (A[this.accessToken] = e);
|
|
847
752
|
}
|
|
848
753
|
clearCacheVersion() {
|
|
849
|
-
this.accessToken && (
|
|
754
|
+
this.accessToken && (A[this.accessToken] = 0);
|
|
850
755
|
}
|
|
851
756
|
cacheProvider() {
|
|
852
757
|
switch (this.cache.type) {
|
|
853
758
|
case "memory":
|
|
854
759
|
return {
|
|
855
760
|
get(e) {
|
|
856
|
-
return Promise.resolve(
|
|
761
|
+
return Promise.resolve(j[e]);
|
|
857
762
|
},
|
|
858
763
|
getAll() {
|
|
859
|
-
return Promise.resolve(
|
|
764
|
+
return Promise.resolve(j);
|
|
860
765
|
},
|
|
861
766
|
set(e, t) {
|
|
862
|
-
return
|
|
767
|
+
return j[e] = t, Promise.resolve(void 0);
|
|
863
768
|
},
|
|
864
769
|
flush() {
|
|
865
|
-
return
|
|
770
|
+
return j = {}, Promise.resolve(void 0);
|
|
866
771
|
}
|
|
867
772
|
};
|
|
868
773
|
case "custom":
|
|
869
774
|
if (this.cache.custom)
|
|
870
775
|
return this.cache.custom;
|
|
871
|
-
// eslint-disable-next-line no-fallthrough
|
|
872
776
|
default:
|
|
873
777
|
return {
|
|
874
778
|
get() {
|
|
@@ -889,22 +793,41 @@ class Qe {
|
|
|
889
793
|
async flushCache() {
|
|
890
794
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
891
795
|
}
|
|
796
|
+
async processInlineAssets(e) {
|
|
797
|
+
if (!this.inlineAssets)
|
|
798
|
+
return e;
|
|
799
|
+
const t = (o) => {
|
|
800
|
+
if (!o || typeof o != "object")
|
|
801
|
+
return o;
|
|
802
|
+
if (Array.isArray(o))
|
|
803
|
+
return o.map((n) => t(n));
|
|
804
|
+
let r = { ...o };
|
|
805
|
+
r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
|
|
806
|
+
...r,
|
|
807
|
+
...e.data.assets.find((n) => n.id === r.id)
|
|
808
|
+
});
|
|
809
|
+
for (const n in r)
|
|
810
|
+
typeof r[n] == "object" && (r[n] = t(r[n]));
|
|
811
|
+
return r;
|
|
812
|
+
};
|
|
813
|
+
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((o) => (o.content = t(o.content), o))), e;
|
|
814
|
+
}
|
|
892
815
|
}
|
|
893
|
-
const
|
|
894
|
-
const { apiOptions: e } =
|
|
816
|
+
const ze = (s = {}) => {
|
|
817
|
+
const { apiOptions: e } = s;
|
|
895
818
|
if (!e || !e.accessToken) {
|
|
896
819
|
console.error(
|
|
897
820
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
898
821
|
);
|
|
899
822
|
return;
|
|
900
823
|
}
|
|
901
|
-
return { storyblokApi: new
|
|
902
|
-
},
|
|
903
|
-
if (typeof
|
|
824
|
+
return { storyblokApi: new Pe(e) };
|
|
825
|
+
}, Ne = (s) => {
|
|
826
|
+
if (typeof s != "object" || typeof s._editable > "u")
|
|
904
827
|
return {};
|
|
905
828
|
try {
|
|
906
829
|
const e = JSON.parse(
|
|
907
|
-
|
|
830
|
+
s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
908
831
|
);
|
|
909
832
|
return e ? {
|
|
910
833
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -914,413 +837,159 @@ const gt = (r = {}) => {
|
|
|
914
837
|
return {};
|
|
915
838
|
}
|
|
916
839
|
};
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const o = {}, n = [];
|
|
922
|
-
function a(l, h, u, p, b) {
|
|
923
|
-
typeof l != "number" || l <= h || l >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : b.push(`${p}(${l})`);
|
|
924
|
-
}
|
|
925
|
-
if (typeof e == "object") {
|
|
926
|
-
if (typeof e.width == "number" && e.width > 0 ? (o.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 ? (o.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
|
|
927
|
-
const { filters: l } = e || {}, { blur: h, brightness: u, fill: p, format: b, grayscale: $, quality: T, rotate: E } = l || {};
|
|
928
|
-
h && a(h, 0, 100, "blur", n), T && a(T, 0, 100, "quality", n), u && a(u, 0, 100, "brightness", n), p && n.push(`fill(${p})`), $ && n.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
|
|
929
|
-
}
|
|
930
|
-
e.srcset && (o.srcset = e.srcset.map((l) => {
|
|
931
|
-
if (typeof l == "number")
|
|
932
|
-
return `${r}/m/${l}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${l}w`;
|
|
933
|
-
if (Array.isArray(l) && l.length === 2) {
|
|
934
|
-
const [h, u] = l;
|
|
935
|
-
return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
936
|
-
} else {
|
|
937
|
-
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
941
|
-
}
|
|
942
|
-
let i = `${r}/m/`;
|
|
943
|
-
return t > 0 && s > 0 && (i = `${i}${t}x${s}/`), n.length > 0 && (i = `${i}filters:${n.join(":")}`), {
|
|
944
|
-
src: i,
|
|
945
|
-
attrs: o
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r.TABLE = "table", r.TABLE_ROW = "tableRow", r.TABLE_CELL = "tableCell", r.TABLE_HEADER = "tableHeader", r))(k || {}), S = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(S || {}), Q = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(Q || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
|
|
949
|
-
const tt = [
|
|
950
|
-
"area",
|
|
951
|
-
"base",
|
|
952
|
-
"br",
|
|
953
|
-
"col",
|
|
954
|
-
"embed",
|
|
955
|
-
"hr",
|
|
956
|
-
"img",
|
|
957
|
-
"input",
|
|
958
|
-
"link",
|
|
959
|
-
"meta",
|
|
960
|
-
"param",
|
|
961
|
-
"source",
|
|
962
|
-
"track",
|
|
963
|
-
"wbr"
|
|
964
|
-
], rt = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), st = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
|
|
965
|
-
function ot(r) {
|
|
966
|
-
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
967
|
-
}
|
|
968
|
-
const L = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
|
|
969
|
-
function G(r, e = {}, t) {
|
|
970
|
-
const s = rt(e), o = s ? `${r} ${s}` : r, n = Array.isArray(t) ? t.join("") : t || "";
|
|
971
|
-
if (r) {
|
|
972
|
-
if (tt.includes(r))
|
|
973
|
-
return `<${o}>`;
|
|
974
|
-
} else return n;
|
|
975
|
-
return `<${o}>${n}</${r}>`;
|
|
976
|
-
}
|
|
977
|
-
function nt(r = {}) {
|
|
978
|
-
const e = /* @__PURE__ */ new Map(), {
|
|
979
|
-
renderFn: t = G,
|
|
980
|
-
textFn: s = ot,
|
|
981
|
-
resolvers: o = {},
|
|
982
|
-
optimizeImages: n = !1,
|
|
983
|
-
keyedResolvers: a = !1
|
|
984
|
-
} = r, i = t !== G, l = () => ({ render: (c, d = {}, g) => {
|
|
985
|
-
if (a && c) {
|
|
986
|
-
const f = e.get(c) || 0;
|
|
987
|
-
e.set(c, f + 1), d.key = `${c}-${f}`;
|
|
988
|
-
}
|
|
989
|
-
return t(c, d, g);
|
|
990
|
-
} }), h = (c) => (d, g) => {
|
|
991
|
-
const f = d.attrs || {};
|
|
992
|
-
return g.render(c, f, d.children || null);
|
|
993
|
-
}, u = (c, d) => {
|
|
994
|
-
const { src: g, alt: f, title: y, srcset: R, sizes: v } = c.attrs || {};
|
|
995
|
-
let w = g, _ = {};
|
|
996
|
-
if (n) {
|
|
997
|
-
const { src: he, attrs: ue } = et(g, n);
|
|
998
|
-
w = he, _ = ue;
|
|
999
|
-
}
|
|
1000
|
-
const ce = {
|
|
1001
|
-
src: w,
|
|
1002
|
-
alt: f,
|
|
1003
|
-
title: y,
|
|
1004
|
-
srcset: R,
|
|
1005
|
-
sizes: v,
|
|
1006
|
-
..._
|
|
1007
|
-
};
|
|
1008
|
-
return d.render("img", L(ce));
|
|
1009
|
-
}, p = (c, d) => {
|
|
1010
|
-
const { level: g, ...f } = c.attrs || {};
|
|
1011
|
-
return d.render(`h${g}`, f, c.children);
|
|
1012
|
-
}, b = (c, d) => {
|
|
1013
|
-
var g, f, y, R;
|
|
1014
|
-
const v = d.render("img", {
|
|
1015
|
-
src: (g = c.attrs) == null ? void 0 : g.fallbackImage,
|
|
1016
|
-
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
1017
|
-
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
1018
|
-
draggable: "false",
|
|
1019
|
-
loading: "lazy"
|
|
1020
|
-
});
|
|
1021
|
-
return d.render("span", {
|
|
1022
|
-
"data-type": "emoji",
|
|
1023
|
-
"data-name": (y = c.attrs) == null ? void 0 : y.name,
|
|
1024
|
-
"data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
|
|
1025
|
-
}, v);
|
|
1026
|
-
}, $ = (c, d) => d.render(
|
|
1027
|
-
"pre",
|
|
1028
|
-
c.attrs || {},
|
|
1029
|
-
d.render("code", {}, c.children || "")
|
|
1030
|
-
), T = (c, d = !1) => ({ text: g, attrs: f }, y) => {
|
|
1031
|
-
const { class: R, id: v, ...w } = f || {}, _ = d ? {
|
|
1032
|
-
class: R,
|
|
1033
|
-
id: v,
|
|
1034
|
-
style: st(w) || void 0
|
|
1035
|
-
} : f || {};
|
|
1036
|
-
return y.render(c, L(_), g);
|
|
1037
|
-
}, E = (c) => M(c), re = (c) => {
|
|
1038
|
-
const { marks: d, ...g } = c;
|
|
1039
|
-
if ("text" in c) {
|
|
1040
|
-
if (d)
|
|
1041
|
-
return d.reduce(
|
|
1042
|
-
(y, R) => E({ ...R, text: y }),
|
|
1043
|
-
E({ ...g, children: g.children })
|
|
1044
|
-
);
|
|
1045
|
-
const f = c.attrs || {};
|
|
1046
|
-
if (a) {
|
|
1047
|
-
const y = e.get("txt") || 0;
|
|
1048
|
-
e.set("txt", y + 1), f.key = `txt-${y}`;
|
|
1049
|
-
}
|
|
1050
|
-
return s(g.text, f);
|
|
1051
|
-
}
|
|
1052
|
-
return "";
|
|
1053
|
-
}, B = (c, d) => {
|
|
1054
|
-
const { linktype: g, href: f, anchor: y, ...R } = c.attrs || {};
|
|
1055
|
-
let v = "";
|
|
1056
|
-
switch (g) {
|
|
1057
|
-
case j.ASSET:
|
|
1058
|
-
case j.URL:
|
|
1059
|
-
v = f;
|
|
1060
|
-
break;
|
|
1061
|
-
case j.EMAIL:
|
|
1062
|
-
v = `mailto:${f}`;
|
|
1063
|
-
break;
|
|
1064
|
-
case j.STORY:
|
|
1065
|
-
v = f, y && (v = `${v}#${y}`);
|
|
1066
|
-
break;
|
|
1067
|
-
default:
|
|
1068
|
-
v = f;
|
|
1069
|
-
break;
|
|
1070
|
-
}
|
|
1071
|
-
const w = { ...R };
|
|
1072
|
-
return v && (w.href = v), d.render("a", w, c.text);
|
|
1073
|
-
}, se = (c, d) => {
|
|
1074
|
-
var g, f;
|
|
1075
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
|
|
1076
|
-
blok: (g = c == null ? void 0 : c.attrs) == null ? void 0 : g.body[0],
|
|
1077
|
-
id: (f = c.attrs) == null ? void 0 : f.id,
|
|
1078
|
-
style: "display: none"
|
|
1079
|
-
});
|
|
1080
|
-
}, oe = (c, d) => {
|
|
1081
|
-
const g = {}, f = d.render("tbody", {}, c.children);
|
|
1082
|
-
return d.render("table", g, f);
|
|
1083
|
-
}, ne = (c, d) => {
|
|
1084
|
-
const g = {};
|
|
1085
|
-
return d.render("tr", g, c.children);
|
|
1086
|
-
}, ae = (c, d) => {
|
|
1087
|
-
const { colspan: g, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, w = {
|
|
1088
|
-
...v
|
|
1089
|
-
};
|
|
1090
|
-
g > 1 && (w.colspan = g), f > 1 && (w.rowspan = f);
|
|
1091
|
-
const _ = [];
|
|
1092
|
-
return y && _.push(`width: ${y}px;`), R && _.push(`background-color: ${R};`), _.length > 0 && (w.style = _.join(" ")), d.render("td", L(w), c.children);
|
|
1093
|
-
}, ie = (c, d) => {
|
|
1094
|
-
const { colspan: g, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, w = {
|
|
1095
|
-
...v
|
|
1096
|
-
};
|
|
1097
|
-
g > 1 && (w.colspan = g), f > 1 && (w.rowspan = f);
|
|
1098
|
-
const _ = [];
|
|
1099
|
-
return y && _.push(`width: ${y}px;`), R && _.push(`background-color: ${R};`), _.length > 0 && (w.style = _.join(" ")), d.render("th", L(w), c.children);
|
|
1100
|
-
}, le = new Map([
|
|
1101
|
-
[k.DOCUMENT, h("")],
|
|
1102
|
-
[k.HEADING, p],
|
|
1103
|
-
[k.PARAGRAPH, h("p")],
|
|
1104
|
-
[k.UL_LIST, h("ul")],
|
|
1105
|
-
[k.OL_LIST, h("ol")],
|
|
1106
|
-
[k.LIST_ITEM, h("li")],
|
|
1107
|
-
[k.IMAGE, u],
|
|
1108
|
-
[k.EMOJI, b],
|
|
1109
|
-
[k.CODE_BLOCK, $],
|
|
1110
|
-
[k.HR, h("hr")],
|
|
1111
|
-
[k.BR, h("br")],
|
|
1112
|
-
[k.QUOTE, h("blockquote")],
|
|
1113
|
-
[k.COMPONENT, se],
|
|
1114
|
-
[Q.TEXT, re],
|
|
1115
|
-
[S.LINK, B],
|
|
1116
|
-
[S.ANCHOR, B],
|
|
1117
|
-
[S.STYLED, T("span", !0)],
|
|
1118
|
-
[S.BOLD, T("strong")],
|
|
1119
|
-
[S.TEXT_STYLE, T("span", !0)],
|
|
1120
|
-
[S.ITALIC, T("em")],
|
|
1121
|
-
[S.UNDERLINE, T("u")],
|
|
1122
|
-
[S.STRIKE, T("s")],
|
|
1123
|
-
[S.CODE, T("code")],
|
|
1124
|
-
[S.SUPERSCRIPT, T("sup")],
|
|
1125
|
-
[S.SUBSCRIPT, T("sub")],
|
|
1126
|
-
[S.HIGHLIGHT, T("mark")],
|
|
1127
|
-
[k.TABLE, oe],
|
|
1128
|
-
[k.TABLE_ROW, ne],
|
|
1129
|
-
[k.TABLE_CELL, ae],
|
|
1130
|
-
[k.TABLE_HEADER, ie],
|
|
1131
|
-
...Object.entries(o).map(([c, d]) => [c, d])
|
|
1132
|
-
]);
|
|
1133
|
-
function I(c) {
|
|
1134
|
-
const d = le.get(c.type);
|
|
1135
|
-
if (!d)
|
|
1136
|
-
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
1137
|
-
const g = l();
|
|
1138
|
-
if (c.type === "text")
|
|
1139
|
-
return d(c, g);
|
|
1140
|
-
const f = c.content ? c.content.map(M) : void 0;
|
|
1141
|
-
return d({
|
|
1142
|
-
...c,
|
|
1143
|
-
children: f
|
|
1144
|
-
}, g);
|
|
1145
|
-
}
|
|
1146
|
-
function M(c) {
|
|
1147
|
-
return c.type === "doc" ? i ? c.content.map(I) : c.content.map(I).join("") : Array.isArray(c) ? c.map(I) : I(c);
|
|
1148
|
-
}
|
|
1149
|
-
return {
|
|
1150
|
-
render: M
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
let U, K = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1154
|
-
const at = (r, e, t = {}) => {
|
|
1155
|
-
var s;
|
|
1156
|
-
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
840
|
+
let G = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
841
|
+
const He = (s, e, t = {}) => {
|
|
842
|
+
var o;
|
|
843
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((o = window.location) == null ? void 0 : o.href).searchParams.get(
|
|
1157
844
|
"_storyblok"
|
|
1158
|
-
),
|
|
1159
|
-
if (!(!
|
|
1160
|
-
if (!
|
|
845
|
+
), i = n !== null && +n === s;
|
|
846
|
+
if (!(!r || !i)) {
|
|
847
|
+
if (!s) {
|
|
1161
848
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
1162
849
|
return;
|
|
1163
850
|
}
|
|
1164
851
|
window.storyblokRegisterEvent(() => {
|
|
1165
|
-
new window.StoryblokBridge(t).on(["input", "published", "change"], (
|
|
1166
|
-
var
|
|
1167
|
-
|
|
852
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
|
|
853
|
+
var c;
|
|
854
|
+
l && (l.action === "input" && ((c = l.story) == null ? void 0 : c.id) === s ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === s && window.location.reload());
|
|
1168
855
|
});
|
|
1169
856
|
});
|
|
1170
857
|
}
|
|
1171
|
-
},
|
|
1172
|
-
r.addNode("blok", (t) => {
|
|
1173
|
-
let s = "";
|
|
1174
|
-
return t.attrs.body.forEach((o) => {
|
|
1175
|
-
s += e(o.component, o);
|
|
1176
|
-
}), {
|
|
1177
|
-
html: s
|
|
1178
|
-
};
|
|
1179
|
-
});
|
|
1180
|
-
}, it = (r = {}) => {
|
|
858
|
+
}, De = (s = {}) => {
|
|
1181
859
|
var e, t;
|
|
1182
860
|
const {
|
|
1183
|
-
bridge:
|
|
1184
|
-
accessToken:
|
|
861
|
+
bridge: o,
|
|
862
|
+
accessToken: r,
|
|
1185
863
|
use: n = [],
|
|
1186
|
-
apiOptions:
|
|
1187
|
-
richText: i = {},
|
|
864
|
+
apiOptions: i = {},
|
|
1188
865
|
bridgeUrl: l
|
|
1189
|
-
} =
|
|
1190
|
-
|
|
1191
|
-
const
|
|
866
|
+
} = s;
|
|
867
|
+
i.accessToken = i.accessToken || r;
|
|
868
|
+
const c = { bridge: o, apiOptions: i };
|
|
1192
869
|
let u = {};
|
|
1193
|
-
n.forEach((
|
|
1194
|
-
u = { ...u, ...
|
|
1195
|
-
}), l && (
|
|
1196
|
-
const
|
|
1197
|
-
return
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
return
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
if (!s) {
|
|
1204
|
-
console.error(
|
|
1205
|
-
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1206
|
-
);
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
return lt(r) ? "" : (e && (s = new N(e.schema), e.resolver && Z(s, e.resolver)), s.render(r, {}, !1));
|
|
1210
|
-
}, ee = /* @__PURE__ */ J({
|
|
870
|
+
n.forEach((y) => {
|
|
871
|
+
u = { ...u, ...y(c) };
|
|
872
|
+
}), l && (G = l);
|
|
873
|
+
const f = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
874
|
+
return o !== !1 && f && we(G), u;
|
|
875
|
+
};
|
|
876
|
+
function Ge(s, e) {
|
|
877
|
+
return X(e).render(s);
|
|
878
|
+
}
|
|
879
|
+
const Q = /* @__PURE__ */ q({
|
|
1211
880
|
__name: "StoryblokComponent",
|
|
1212
881
|
props: {
|
|
1213
882
|
blok: {}
|
|
1214
883
|
},
|
|
1215
|
-
setup(
|
|
1216
|
-
const t =
|
|
884
|
+
setup(s, { expose: e }) {
|
|
885
|
+
const t = s, o = x();
|
|
1217
886
|
e({
|
|
1218
|
-
value:
|
|
887
|
+
value: o
|
|
1219
888
|
});
|
|
1220
|
-
const
|
|
1221
|
-
return !
|
|
1222
|
-
`Is the Fallback component "${
|
|
889
|
+
const r = typeof N(t.blok.component) != "string", n = ue("VueSDKOptions"), i = x(t.blok.component);
|
|
890
|
+
return !r && n && (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
|
|
891
|
+
`Is the Fallback component "${i.value}" registered properly?`
|
|
1223
892
|
)) : console.error(
|
|
1224
893
|
`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
|
|
1225
|
-
)), (
|
|
894
|
+
)), (l, c) => (K(), J(N(i.value), he({
|
|
1226
895
|
ref_key: "blokRef",
|
|
1227
|
-
ref:
|
|
1228
|
-
}, { ...
|
|
896
|
+
ref: o
|
|
897
|
+
}, { ...l.$props, ...l.$attrs }), null, 16));
|
|
1229
898
|
}
|
|
1230
|
-
}),
|
|
899
|
+
}), Ue = (s) => {
|
|
1231
900
|
var e, t;
|
|
1232
|
-
return
|
|
1233
|
-
|
|
901
|
+
return Y(
|
|
902
|
+
Q,
|
|
1234
903
|
{
|
|
1235
|
-
blok: (e =
|
|
1236
|
-
id: (t =
|
|
904
|
+
blok: (e = s == null ? void 0 : s.attrs) == null ? void 0 : e.body[0],
|
|
905
|
+
id: (t = s.attrs) == null ? void 0 : t.id
|
|
1237
906
|
},
|
|
1238
|
-
|
|
907
|
+
s.children
|
|
1239
908
|
);
|
|
1240
909
|
};
|
|
1241
|
-
function
|
|
910
|
+
function Be(s) {
|
|
1242
911
|
const e = {
|
|
1243
|
-
renderFn:
|
|
1244
|
-
|
|
912
|
+
renderFn: Y,
|
|
913
|
+
// TODO: Check why this changed.
|
|
914
|
+
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
915
|
+
textFn: de,
|
|
1245
916
|
keyedResolvers: !0,
|
|
1246
917
|
resolvers: {
|
|
1247
|
-
[
|
|
1248
|
-
...
|
|
918
|
+
[g.COMPONENT]: Ue,
|
|
919
|
+
...s.resolvers
|
|
1249
920
|
}
|
|
1250
921
|
};
|
|
1251
|
-
return
|
|
922
|
+
return X(e);
|
|
1252
923
|
}
|
|
1253
|
-
const
|
|
924
|
+
const Me = /* @__PURE__ */ q({
|
|
1254
925
|
__name: "StoryblokRichText",
|
|
1255
926
|
props: {
|
|
1256
927
|
doc: {},
|
|
1257
928
|
resolvers: {}
|
|
1258
929
|
},
|
|
1259
|
-
setup(
|
|
1260
|
-
const e =
|
|
1261
|
-
return
|
|
1262
|
-
const { render:
|
|
930
|
+
setup(s) {
|
|
931
|
+
const e = s, t = x(), o = () => t.value;
|
|
932
|
+
return pe([() => e.doc, () => e.resolvers], ([r, n]) => {
|
|
933
|
+
const { render: i } = Be({
|
|
1263
934
|
resolvers: n ?? {}
|
|
1264
935
|
});
|
|
1265
|
-
t.value =
|
|
936
|
+
t.value = i(r);
|
|
1266
937
|
}, {
|
|
1267
938
|
immediate: !0,
|
|
1268
939
|
deep: !0
|
|
1269
|
-
}), (
|
|
940
|
+
}), (r, n) => (K(), J(o));
|
|
1270
941
|
}
|
|
1271
|
-
}),
|
|
1272
|
-
beforeMount(
|
|
942
|
+
}), Fe = {
|
|
943
|
+
beforeMount(s, e) {
|
|
1273
944
|
if (e.value) {
|
|
1274
|
-
const t =
|
|
1275
|
-
Object.keys(t).length > 0 && (
|
|
945
|
+
const t = Ne(e.value);
|
|
946
|
+
Object.keys(t).length > 0 && (s.setAttribute("data-blok-c", t["data-blok-c"]), s.setAttribute("data-blok-uid", t["data-blok-uid"]), s.classList.add("storyblok__outline"));
|
|
1276
947
|
}
|
|
1277
948
|
}
|
|
1278
|
-
},
|
|
1279
|
-
console.error(`You can't use ${
|
|
949
|
+
}, Z = (s) => {
|
|
950
|
+
console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1280
951
|
`);
|
|
1281
952
|
};
|
|
1282
|
-
let
|
|
1283
|
-
const
|
|
1284
|
-
const
|
|
1285
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
(
|
|
953
|
+
let L = null;
|
|
954
|
+
const qe = () => (L || Z("useStoryblokApi"), L), Je = async (s, e = {}, t = {}) => {
|
|
955
|
+
const o = x(null);
|
|
956
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, fe(() => {
|
|
957
|
+
o.value && o.value.id && He(
|
|
958
|
+
o.value.id,
|
|
959
|
+
(r) => o.value = r,
|
|
1289
960
|
t
|
|
1290
961
|
);
|
|
1291
|
-
}),
|
|
1292
|
-
const { data:
|
|
1293
|
-
`cdn/stories/${
|
|
962
|
+
}), L) {
|
|
963
|
+
const { data: r } = await L.get(
|
|
964
|
+
`cdn/stories/${s}`,
|
|
1294
965
|
e
|
|
1295
966
|
);
|
|
1296
|
-
|
|
967
|
+
o.value = r.story;
|
|
1297
968
|
} else
|
|
1298
|
-
|
|
1299
|
-
return
|
|
1300
|
-
},
|
|
1301
|
-
install(
|
|
1302
|
-
|
|
969
|
+
Z("useStoryblok");
|
|
970
|
+
return o;
|
|
971
|
+
}, Ke = {
|
|
972
|
+
install(s, e = {}) {
|
|
973
|
+
s.directive("editable", Fe), s.component("StoryblokComponent", Q), s.component("StoryblokRichText", Me), e.enableFallbackComponent && !e.customFallbackComponent && s.component(
|
|
1303
974
|
"FallbackComponent",
|
|
1304
975
|
ye(() => import("./FallbackComponent-Dky11gEu.js"))
|
|
1305
976
|
);
|
|
1306
|
-
const { storyblokApi: t } =
|
|
1307
|
-
|
|
977
|
+
const { storyblokApi: t } = De(e);
|
|
978
|
+
L = t || null, s.provide("VueSDKOptions", e);
|
|
1308
979
|
}
|
|
1309
980
|
};
|
|
1310
981
|
export {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
at as useStoryblokBridge,
|
|
1325
|
-
ht as useStoryblokRichText
|
|
982
|
+
g as BlockTypes,
|
|
983
|
+
$ as MarkTypes,
|
|
984
|
+
Q as StoryblokComponent,
|
|
985
|
+
Me as StoryblokRichText,
|
|
986
|
+
Ke as StoryblokVue,
|
|
987
|
+
W as TextTypes,
|
|
988
|
+
ze as apiPlugin,
|
|
989
|
+
Ge as renderRichText,
|
|
990
|
+
X as richTextResolver,
|
|
991
|
+
Je as useStoryblok,
|
|
992
|
+
qe as useStoryblokApi,
|
|
993
|
+
He as useStoryblokBridge,
|
|
994
|
+
Be as useStoryblokRichText
|
|
1326
995
|
};
|