@storyblok/vue 9.2.1 → 9.2.3
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 +17 -16
- package/dist/storyblok-vue.js +2 -2
- package/dist/storyblok-vue.mjs +401 -366
- package/package.json +2 -2
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -4,40 +4,94 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent as
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { defineComponent as Z, ref as P, resolveDynamicComponent as D, inject as pe, createBlock as W, openBlock as X, mergeProps as fe, h as Q, createTextVNode as ye, watch as me, onMounted as ge, defineAsyncComponent as be } from "vue";
|
|
8
|
+
function I(r, e, t) {
|
|
9
|
+
this.type = r, this.tag = e, this.attrs = null, this.map = null, this.nesting = t, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
|
10
|
+
}
|
|
11
|
+
I.prototype.attrIndex = function(r) {
|
|
12
|
+
if (!this.attrs)
|
|
13
|
+
return -1;
|
|
14
|
+
const e = this.attrs;
|
|
15
|
+
for (let t = 0, s = e.length; t < s; t++)
|
|
16
|
+
if (e[t][0] === r)
|
|
17
|
+
return t;
|
|
18
|
+
return -1;
|
|
19
|
+
};
|
|
20
|
+
I.prototype.attrPush = function(r) {
|
|
21
|
+
this.attrs ? this.attrs.push(r) : this.attrs = [r];
|
|
22
|
+
};
|
|
23
|
+
I.prototype.attrSet = function(r, e) {
|
|
24
|
+
const t = this.attrIndex(r), s = [r, e];
|
|
25
|
+
t < 0 ? this.attrPush(s) : this.attrs[t] = s;
|
|
26
|
+
};
|
|
27
|
+
I.prototype.attrGet = function(r) {
|
|
28
|
+
const e = this.attrIndex(r);
|
|
29
|
+
let t = null;
|
|
30
|
+
return e >= 0 && (t = this.attrs[e][1]), t;
|
|
31
|
+
};
|
|
32
|
+
I.prototype.attrJoin = function(r, e) {
|
|
33
|
+
const t = this.attrIndex(r);
|
|
34
|
+
t < 0 ? this.attrPush([r, e]) : this.attrs[t][1] = this.attrs[t][1] + " " + e;
|
|
35
|
+
};
|
|
36
|
+
const ve = "[a-zA-Z_:][a-zA-Z0-9:._-]*", ke = "[^\"'=<>`\\x00-\\x20]+", we = "'[^']*'", _e = '"[^"]*"', Te = "(?:" + ke + "|" + we + "|" + _e + ")", Re = "(?:\\s+" + ve + "(?:\\s*=\\s*" + Te + ")?)", $e = "<[A-Za-z][A-Za-z0-9\\-]*" + Re + "*\\s*\\/?>", Ee = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", Ae = new RegExp("^(?:" + $e + "|" + Ee + ")");
|
|
37
|
+
new RegExp(Ae.source + "\\s*$");
|
|
38
|
+
const ee = [];
|
|
39
|
+
for (let r = 0; r < 256; r++)
|
|
40
|
+
ee.push(0);
|
|
41
|
+
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r) {
|
|
42
|
+
ee[r.charCodeAt(0)] = 1;
|
|
43
|
+
});
|
|
44
|
+
let v = /* @__PURE__ */ function(r) {
|
|
45
|
+
return 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;
|
|
46
|
+
}({}), $ = /* @__PURE__ */ function(r) {
|
|
47
|
+
return 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;
|
|
48
|
+
}({}), Se = /* @__PURE__ */ function(r) {
|
|
49
|
+
return r.TEXT = "text", r;
|
|
50
|
+
}({}), j = /* @__PURE__ */ function(r) {
|
|
51
|
+
return r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r;
|
|
52
|
+
}({});
|
|
53
|
+
function Ie(r, e) {
|
|
54
|
+
if (!e) return {
|
|
55
|
+
src: r,
|
|
56
|
+
attrs: {}
|
|
57
|
+
};
|
|
58
|
+
let t = 0, s = 0;
|
|
59
|
+
const o = {}, n = [];
|
|
13
60
|
function a(i, u, f, y, R) {
|
|
14
61
|
typeof i != "number" || i <= u || i >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : R.push(`${y}(${i})`);
|
|
15
62
|
}
|
|
16
63
|
if (typeof e == "object") {
|
|
17
|
-
if (typeof e.width == "number" && e.width > 0 ? (
|
|
18
|
-
const { filters: i } = e || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: _, quality: A, rotate:
|
|
19
|
-
u && a(u, 0, 100, "blur", n), A && a(A, 0, 100, "quality", n), f && a(f, 0, 100, "brightness", n), y && n.push(`fill(${y})`), _ && n.push("grayscale()"),
|
|
64
|
+
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) {
|
|
65
|
+
const { filters: i } = e || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: _, quality: A, rotate: C } = i || {};
|
|
66
|
+
u && a(u, 0, 100, "blur", n), A && a(A, 0, 100, "quality", n), f && a(f, 0, 100, "brightness", n), y && n.push(`fill(${y})`), _ && n.push("grayscale()"), C && [
|
|
67
|
+
0,
|
|
68
|
+
90,
|
|
69
|
+
180,
|
|
70
|
+
270
|
|
71
|
+
].includes(e.filters.rotate || 0) && n.push(`rotate(${C})`), R && [
|
|
72
|
+
"webp",
|
|
73
|
+
"png",
|
|
74
|
+
"jpeg"
|
|
75
|
+
].includes(R) && n.push(`format(${R})`);
|
|
20
76
|
}
|
|
21
|
-
e.srcset && (
|
|
22
|
-
if (typeof i == "number")
|
|
23
|
-
return `${s}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
|
|
77
|
+
e.srcset && (o.srcset = e.srcset.map((i) => {
|
|
78
|
+
if (typeof i == "number") return `${r}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
|
|
24
79
|
if (Array.isArray(i) && i.length === 2) {
|
|
25
80
|
const [u, f] = i;
|
|
26
|
-
return `${
|
|
81
|
+
return `${r}/m/${u}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
|
27
82
|
} else {
|
|
28
83
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
29
84
|
return;
|
|
30
85
|
}
|
|
31
|
-
}).join(", ")), e.sizes && (
|
|
86
|
+
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
32
87
|
}
|
|
33
|
-
let c = `${
|
|
34
|
-
return t > 0 &&
|
|
88
|
+
let c = `${r}/m/`;
|
|
89
|
+
return t > 0 && s > 0 && (c = `${c}${t}x${s}/`), n.length > 0 && (c = `${c}filters:${n.join(":")}`), {
|
|
35
90
|
src: c,
|
|
36
|
-
attrs:
|
|
91
|
+
attrs: o
|
|
37
92
|
};
|
|
38
93
|
}
|
|
39
|
-
|
|
40
|
-
const ve = [
|
|
94
|
+
const Ce = [
|
|
41
95
|
"area",
|
|
42
96
|
"base",
|
|
43
97
|
"br",
|
|
@@ -52,51 +106,44 @@ const ve = [
|
|
|
52
106
|
"source",
|
|
53
107
|
"track",
|
|
54
108
|
"wbr"
|
|
55
|
-
],
|
|
56
|
-
function
|
|
57
|
-
return
|
|
109
|
+
], Le = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), je = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
|
|
110
|
+
function Oe(r) {
|
|
111
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
58
112
|
}
|
|
59
|
-
const O = (
|
|
60
|
-
function
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
64
|
-
return `<${r}>`;
|
|
113
|
+
const O = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
|
|
114
|
+
function V(r, e = {}, t) {
|
|
115
|
+
const s = Le(e), o = s ? `${r} ${s}` : r, n = Array.isArray(t) ? t.join("") : t || "";
|
|
116
|
+
if (r) {
|
|
117
|
+
if (Ce.includes(r)) return `<${o}>`;
|
|
65
118
|
} else return n;
|
|
66
|
-
return `<${
|
|
119
|
+
return `<${o}>${n}</${r}>`;
|
|
67
120
|
}
|
|
68
|
-
function
|
|
69
|
-
const e = /* @__PURE__ */ new Map(), {
|
|
70
|
-
renderFn: t = F,
|
|
71
|
-
textFn: o = _e,
|
|
72
|
-
resolvers: r = {},
|
|
73
|
-
optimizeImages: n = !1,
|
|
74
|
-
keyedResolvers: a = !1
|
|
75
|
-
} = s, c = t !== F, i = (l) => (h, d) => {
|
|
121
|
+
function te(r = {}) {
|
|
122
|
+
const e = /* @__PURE__ */ new Map(), { renderFn: t = V, textFn: s = Oe, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: a = !1 } = r, c = t !== V, i = (l) => (h, d) => {
|
|
76
123
|
const p = h.attrs || {};
|
|
77
124
|
return d.render(l, p, h.children || null);
|
|
78
125
|
}, u = (l, h) => {
|
|
79
|
-
const { src: d, alt: p, title:
|
|
126
|
+
const { src: d, alt: p, title: g, srcset: w, sizes: b } = l.attrs || {};
|
|
80
127
|
let k = d, T = {};
|
|
81
128
|
if (n) {
|
|
82
|
-
const { src:
|
|
83
|
-
k =
|
|
129
|
+
const { src: he, attrs: de } = Ie(d, n);
|
|
130
|
+
k = he, T = de;
|
|
84
131
|
}
|
|
85
|
-
const
|
|
132
|
+
const ue = {
|
|
86
133
|
src: k,
|
|
87
134
|
alt: p,
|
|
88
|
-
title:
|
|
135
|
+
title: g,
|
|
89
136
|
srcset: w,
|
|
90
|
-
sizes:
|
|
137
|
+
sizes: b,
|
|
91
138
|
...T
|
|
92
139
|
};
|
|
93
|
-
return h.render("img", O(
|
|
140
|
+
return h.render("img", O(ue));
|
|
94
141
|
}, f = (l, h) => {
|
|
95
142
|
const { level: d, ...p } = l.attrs || {};
|
|
96
143
|
return h.render(`h${d}`, p, l.children);
|
|
97
144
|
}, y = (l, h) => {
|
|
98
|
-
var d, p,
|
|
99
|
-
const
|
|
145
|
+
var d, p, g, w;
|
|
146
|
+
const b = h.render("img", {
|
|
100
147
|
src: (d = l.attrs) == null ? void 0 : d.fallbackImage,
|
|
101
148
|
alt: (p = l.attrs) == null ? void 0 : p.alt,
|
|
102
149
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
@@ -105,100 +152,94 @@ function ee(s = {}) {
|
|
|
105
152
|
});
|
|
106
153
|
return h.render("span", {
|
|
107
154
|
"data-type": "emoji",
|
|
108
|
-
"data-name": (
|
|
155
|
+
"data-name": (g = l.attrs) == null ? void 0 : g.name,
|
|
109
156
|
"data-emoji": (w = l.attrs) == null ? void 0 : w.emoji
|
|
110
|
-
},
|
|
111
|
-
}, R = (l, h) => h.render(
|
|
112
|
-
|
|
113
|
-
l.attrs || {},
|
|
114
|
-
h.render("code", {}, l.children || "")
|
|
115
|
-
), _ = (l, h = !1) => ({ text: d, attrs: p }, b) => {
|
|
116
|
-
const { class: w, id: v, ...k } = p || {}, T = h ? {
|
|
157
|
+
}, b);
|
|
158
|
+
}, R = (l, h) => h.render("pre", l.attrs || {}, h.render("code", {}, l.children || "")), _ = (l, h = !1) => ({ text: d, attrs: p }, g) => {
|
|
159
|
+
const { class: w, id: b, ...k } = p || {}, T = h ? {
|
|
117
160
|
class: w,
|
|
118
|
-
id:
|
|
119
|
-
style:
|
|
161
|
+
id: b,
|
|
162
|
+
style: je(k) || void 0
|
|
120
163
|
} : p || {};
|
|
121
|
-
return
|
|
122
|
-
}, A = (l) =>
|
|
164
|
+
return g.render(l, O(T), d);
|
|
165
|
+
}, A = (l) => N(l), C = (l) => {
|
|
123
166
|
const { marks: h, ...d } = l;
|
|
124
167
|
if ("text" in l) {
|
|
125
|
-
if (h)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
168
|
+
if (h) return h.reduce((g, w) => A({
|
|
169
|
+
...w,
|
|
170
|
+
text: g
|
|
171
|
+
}), A({
|
|
172
|
+
...d,
|
|
173
|
+
children: d.children
|
|
174
|
+
}));
|
|
130
175
|
const p = l.attrs || {};
|
|
131
176
|
if (a) {
|
|
132
|
-
const
|
|
133
|
-
e.set("txt",
|
|
177
|
+
const g = e.get("txt") || 0;
|
|
178
|
+
e.set("txt", g + 1), p.key = `txt-${g}`;
|
|
134
179
|
}
|
|
135
|
-
return
|
|
180
|
+
return s(d.text, p);
|
|
136
181
|
}
|
|
137
182
|
return "";
|
|
138
|
-
},
|
|
139
|
-
const { linktype: d, href: p, anchor:
|
|
140
|
-
let
|
|
183
|
+
}, B = (l, h) => {
|
|
184
|
+
const { linktype: d, href: p, anchor: g, ...w } = l.attrs || {};
|
|
185
|
+
let b = "";
|
|
141
186
|
switch (d) {
|
|
142
|
-
case
|
|
143
|
-
case
|
|
144
|
-
|
|
187
|
+
case j.ASSET:
|
|
188
|
+
case j.URL:
|
|
189
|
+
b = p;
|
|
145
190
|
break;
|
|
146
|
-
case
|
|
147
|
-
|
|
191
|
+
case j.EMAIL:
|
|
192
|
+
b = `mailto:${p}`;
|
|
148
193
|
break;
|
|
149
|
-
case
|
|
150
|
-
|
|
194
|
+
case j.STORY:
|
|
195
|
+
b = p, g && (b = `${b}#${g}`);
|
|
151
196
|
break;
|
|
152
197
|
default:
|
|
153
|
-
|
|
198
|
+
b = p;
|
|
154
199
|
break;
|
|
155
200
|
}
|
|
156
201
|
const k = { ...w };
|
|
157
|
-
return
|
|
158
|
-
},
|
|
202
|
+
return b && (k.href = b), h.render("a", k, l.text);
|
|
203
|
+
}, oe = (l, h) => {
|
|
159
204
|
var d, p;
|
|
160
205
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
|
|
161
206
|
blok: (d = l == null ? void 0 : l.attrs) == null ? void 0 : d.body[0],
|
|
162
207
|
id: (p = l.attrs) == null ? void 0 : p.id,
|
|
163
208
|
style: "display: none"
|
|
164
209
|
});
|
|
165
|
-
},
|
|
210
|
+
}, ne = (l, h) => {
|
|
166
211
|
const d = {}, p = h.render("tbody", {}, l.children);
|
|
167
212
|
return h.render("table", d, p);
|
|
168
|
-
},
|
|
213
|
+
}, ie = (l, h) => {
|
|
169
214
|
const d = {};
|
|
170
215
|
return h.render("tr", d, l.children);
|
|
171
|
-
},
|
|
172
|
-
const { colspan: d, rowspan: p, colwidth:
|
|
173
|
-
...v
|
|
174
|
-
};
|
|
216
|
+
}, ae = (l, h) => {
|
|
217
|
+
const { colspan: d, rowspan: p, colwidth: g, backgroundColor: w, ...b } = l.attrs || {}, k = { ...b };
|
|
175
218
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
176
219
|
const T = [];
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
const { colspan: d, rowspan: p, colwidth:
|
|
180
|
-
...v
|
|
181
|
-
};
|
|
220
|
+
return g && T.push(`width: ${g}px;`), w && T.push(`background-color: ${w};`), T.length > 0 && (k.style = T.join(" ")), h.render("td", O(k), l.children);
|
|
221
|
+
}, le = (l, h) => {
|
|
222
|
+
const { colspan: d, rowspan: p, colwidth: g, backgroundColor: w, ...b } = l.attrs || {}, k = { ...b };
|
|
182
223
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
183
224
|
const T = [];
|
|
184
|
-
return
|
|
185
|
-
},
|
|
186
|
-
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
[
|
|
190
|
-
[
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
194
|
-
[
|
|
195
|
-
[
|
|
196
|
-
[
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[$.LINK,
|
|
201
|
-
[$.ANCHOR,
|
|
225
|
+
return g && T.push(`width: ${g}px;`), w && T.push(`background-color: ${w};`), T.length > 0 && (k.style = T.join(" ")), h.render("th", O(k), l.children);
|
|
226
|
+
}, M = /* @__PURE__ */ new Map([
|
|
227
|
+
[v.DOCUMENT, i("")],
|
|
228
|
+
[v.HEADING, f],
|
|
229
|
+
[v.PARAGRAPH, i("p")],
|
|
230
|
+
[v.UL_LIST, i("ul")],
|
|
231
|
+
[v.OL_LIST, i("ol")],
|
|
232
|
+
[v.LIST_ITEM, i("li")],
|
|
233
|
+
[v.IMAGE, u],
|
|
234
|
+
[v.EMOJI, y],
|
|
235
|
+
[v.CODE_BLOCK, R],
|
|
236
|
+
[v.HR, i("hr")],
|
|
237
|
+
[v.BR, i("br")],
|
|
238
|
+
[v.QUOTE, i("blockquote")],
|
|
239
|
+
[v.COMPONENT, oe],
|
|
240
|
+
[Se.TEXT, C],
|
|
241
|
+
[$.LINK, B],
|
|
242
|
+
[$.ANCHOR, B],
|
|
202
243
|
[$.STYLED, _("span", !0)],
|
|
203
244
|
[$.BOLD, _("strong")],
|
|
204
245
|
[$.TEXT_STYLE, _("span", !0)],
|
|
@@ -209,14 +250,11 @@ function ee(s = {}) {
|
|
|
209
250
|
[$.SUPERSCRIPT, _("sup")],
|
|
210
251
|
[$.SUBSCRIPT, _("sub")],
|
|
211
252
|
[$.HIGHLIGHT, _("mark")],
|
|
212
|
-
[
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
]),
|
|
217
|
-
...B,
|
|
218
|
-
...Object.entries(r).map(([l, h]) => [l, h])
|
|
219
|
-
]), le = () => ({
|
|
253
|
+
[v.TABLE, ne],
|
|
254
|
+
[v.TABLE_ROW, ie],
|
|
255
|
+
[v.TABLE_CELL, ae],
|
|
256
|
+
[v.TABLE_HEADER, le]
|
|
257
|
+
]), z = new Map([...M, ...Object.entries(o).map(([l, h]) => [l, h])]), ce = () => ({
|
|
220
258
|
render: (l, h = {}, d) => {
|
|
221
259
|
if (a && l) {
|
|
222
260
|
const p = e.get(l) || 0;
|
|
@@ -224,119 +262,116 @@ function ee(s = {}) {
|
|
|
224
262
|
}
|
|
225
263
|
return t(l, h, d);
|
|
226
264
|
},
|
|
227
|
-
originalResolvers:
|
|
228
|
-
mergedResolvers:
|
|
265
|
+
originalResolvers: M,
|
|
266
|
+
mergedResolvers: z
|
|
229
267
|
});
|
|
230
|
-
function
|
|
231
|
-
const h =
|
|
268
|
+
function L(l) {
|
|
269
|
+
const h = z.get(l.type);
|
|
232
270
|
if (!h)
|
|
233
271
|
return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
|
|
234
|
-
const d =
|
|
235
|
-
if (l.type === "text")
|
|
236
|
-
|
|
237
|
-
const p = l.content ? l.content.map(x) : void 0;
|
|
272
|
+
const d = ce();
|
|
273
|
+
if (l.type === "text") return h(l, d);
|
|
274
|
+
const p = l.content ? l.content.map(N) : void 0;
|
|
238
275
|
return h({
|
|
239
276
|
...l,
|
|
240
277
|
children: p
|
|
241
278
|
}, d);
|
|
242
279
|
}
|
|
243
|
-
function
|
|
244
|
-
return l.type === "doc" ? c ? l.content.map(
|
|
280
|
+
function N(l) {
|
|
281
|
+
return l.type === "doc" ? c ? l.content.map(L) : l.content.map(L).join("") : Array.isArray(l) ? l.map(L) : L(l);
|
|
245
282
|
}
|
|
246
|
-
return {
|
|
247
|
-
render: x
|
|
248
|
-
};
|
|
283
|
+
return { render: N };
|
|
249
284
|
}
|
|
250
|
-
let
|
|
251
|
-
const
|
|
285
|
+
let F = !1;
|
|
286
|
+
const G = [], xe = (r) => new Promise((e, t) => {
|
|
252
287
|
if (typeof window > "u") {
|
|
253
288
|
t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
254
289
|
return;
|
|
255
290
|
}
|
|
256
|
-
if (window.storyblokRegisterEvent = (
|
|
291
|
+
if (window.storyblokRegisterEvent = (o) => {
|
|
257
292
|
if (!window.location.search.includes("_storyblok")) {
|
|
258
293
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
259
294
|
return;
|
|
260
295
|
}
|
|
261
|
-
|
|
296
|
+
F ? o() : G.push(o);
|
|
262
297
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
263
298
|
e(void 0);
|
|
264
299
|
return;
|
|
265
300
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
301
|
+
const s = document.createElement("script");
|
|
302
|
+
s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
|
|
303
|
+
G.forEach((n) => n()), F = !0, e(o);
|
|
304
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
270
305
|
});
|
|
271
|
-
var
|
|
272
|
-
class
|
|
306
|
+
var Pe = Object.defineProperty, Ne = (r, e, t) => e in r ? Pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e, t) => Ne(r, typeof e != "symbol" ? e + "" : e, t);
|
|
307
|
+
class De extends Error {
|
|
273
308
|
constructor(e) {
|
|
274
309
|
super(e), this.name = "AbortError";
|
|
275
310
|
}
|
|
276
311
|
}
|
|
277
|
-
function
|
|
312
|
+
function He(r, e, t) {
|
|
278
313
|
if (!Number.isFinite(e))
|
|
279
314
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
280
315
|
if (!Number.isFinite(t))
|
|
281
316
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
282
|
-
const
|
|
283
|
-
let
|
|
317
|
+
const s = [];
|
|
318
|
+
let o = [], n = 0, a = !1;
|
|
284
319
|
const c = async () => {
|
|
285
320
|
n++;
|
|
286
|
-
const u =
|
|
321
|
+
const u = s.shift();
|
|
287
322
|
if (u)
|
|
288
323
|
try {
|
|
289
|
-
const y = await
|
|
324
|
+
const y = await r(...u.args);
|
|
290
325
|
u.resolve(y);
|
|
291
326
|
} catch (y) {
|
|
292
327
|
u.reject(y);
|
|
293
328
|
}
|
|
294
329
|
const f = setTimeout(() => {
|
|
295
|
-
n--,
|
|
330
|
+
n--, s.length > 0 && c(), o = o.filter((y) => y !== f);
|
|
296
331
|
}, t);
|
|
297
|
-
|
|
332
|
+
o.includes(f) || o.push(f);
|
|
298
333
|
}, i = (...u) => a ? Promise.reject(
|
|
299
334
|
new Error(
|
|
300
335
|
"Throttled function is already aborted and not accepting new promises"
|
|
301
336
|
)
|
|
302
337
|
) : new Promise((f, y) => {
|
|
303
|
-
|
|
338
|
+
s.push({
|
|
304
339
|
resolve: f,
|
|
305
340
|
reject: y,
|
|
306
341
|
args: u
|
|
307
342
|
}), n < e && c();
|
|
308
343
|
});
|
|
309
344
|
return i.abort = () => {
|
|
310
|
-
a = !0,
|
|
311
|
-
(u) => u.reject(() => new
|
|
312
|
-
),
|
|
345
|
+
a = !0, o.forEach(clearTimeout), o = [], s.forEach(
|
|
346
|
+
(u) => u.reject(() => new De("Throttle function aborted"))
|
|
347
|
+
), s.length = 0;
|
|
313
348
|
}, i;
|
|
314
349
|
}
|
|
315
|
-
const
|
|
316
|
-
...
|
|
350
|
+
const J = (r = "") => r.includes("/cdn/"), Ue = (r, e = 25, t = 1) => ({
|
|
351
|
+
...r,
|
|
317
352
|
per_page: e,
|
|
318
353
|
page: t
|
|
319
|
-
}),
|
|
320
|
-
const t = Math.abs(e -
|
|
321
|
-
return
|
|
322
|
-
},
|
|
323
|
-
const
|
|
324
|
-
for (const
|
|
325
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
354
|
+
}), Be = (r) => new Promise((e) => setTimeout(e, r)), Me = (r = 0, e) => Array.from({ length: r }, e), ze = (r = 0, e = r) => {
|
|
355
|
+
const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
356
|
+
return Me(t, (o, n) => n * s + r);
|
|
357
|
+
}, Ve = async (r, e) => Promise.all(r.map(e)), Fe = (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], []), U = (r, e, t) => {
|
|
358
|
+
const s = [];
|
|
359
|
+
for (const o in r) {
|
|
360
|
+
if (!Object.prototype.hasOwnProperty.call(r, o))
|
|
326
361
|
continue;
|
|
327
|
-
const n =
|
|
362
|
+
const n = r[o];
|
|
328
363
|
if (n == null)
|
|
329
364
|
continue;
|
|
330
|
-
const a = t ? "" : encodeURIComponent(
|
|
365
|
+
const a = t ? "" : encodeURIComponent(o);
|
|
331
366
|
let c;
|
|
332
367
|
typeof n == "object" ? c = U(
|
|
333
368
|
n,
|
|
334
369
|
e ? e + encodeURIComponent(`[${a}]`) : a,
|
|
335
370
|
Array.isArray(n)
|
|
336
|
-
) : c = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`,
|
|
371
|
+
) : c = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, s.push(c);
|
|
337
372
|
}
|
|
338
|
-
return
|
|
339
|
-
}, q = (
|
|
373
|
+
return s.join("&");
|
|
374
|
+
}, q = (r) => {
|
|
340
375
|
const e = {
|
|
341
376
|
eu: "api.storyblok.com",
|
|
342
377
|
us: "api-us.storyblok.com",
|
|
@@ -344,9 +379,9 @@ const G = (s = "") => s.includes("/cdn/"), Se = (s, e = 25, t = 1) => ({
|
|
|
344
379
|
ap: "api-ap.storyblok.com",
|
|
345
380
|
ca: "api-ca.storyblok.com"
|
|
346
381
|
};
|
|
347
|
-
return e[
|
|
382
|
+
return e[r] ?? e.eu;
|
|
348
383
|
};
|
|
349
|
-
class
|
|
384
|
+
class Ge {
|
|
350
385
|
constructor(e) {
|
|
351
386
|
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 = {};
|
|
352
387
|
}
|
|
@@ -369,30 +404,30 @@ class Pe {
|
|
|
369
404
|
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
|
370
405
|
}
|
|
371
406
|
async _responseHandler(e) {
|
|
372
|
-
const t = [],
|
|
407
|
+
const t = [], s = {
|
|
373
408
|
data: {},
|
|
374
409
|
headers: {},
|
|
375
410
|
status: 0,
|
|
376
411
|
statusText: ""
|
|
377
412
|
};
|
|
378
|
-
e.status !== 204 && await e.json().then((
|
|
379
|
-
|
|
413
|
+
e.status !== 204 && await e.json().then((o) => {
|
|
414
|
+
s.data = o;
|
|
380
415
|
});
|
|
381
|
-
for (const
|
|
382
|
-
t[
|
|
383
|
-
return
|
|
416
|
+
for (const o of e.headers.entries())
|
|
417
|
+
t[o[0]] = o[1];
|
|
418
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
384
419
|
}
|
|
385
420
|
async _methodHandler(e) {
|
|
386
|
-
let t = `${this.baseURL}${this.url}`,
|
|
387
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${U(this.parameters)}` :
|
|
388
|
-
const
|
|
421
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
|
422
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${U(this.parameters)}` : s = JSON.stringify(this.parameters);
|
|
423
|
+
const o = new URL(t), n = new AbortController(), { signal: a } = n;
|
|
389
424
|
let c;
|
|
390
425
|
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
|
391
426
|
try {
|
|
392
|
-
const i = await this.fetch(`${
|
|
427
|
+
const i = await this.fetch(`${o}`, {
|
|
393
428
|
method: e,
|
|
394
429
|
headers: this.headers,
|
|
395
|
-
body:
|
|
430
|
+
body: s,
|
|
396
431
|
signal: a,
|
|
397
432
|
...this.fetchOptions
|
|
398
433
|
});
|
|
@@ -437,28 +472,28 @@ class Pe {
|
|
|
437
472
|
}
|
|
438
473
|
_statusHandler(e) {
|
|
439
474
|
const t = /20[0-6]/g;
|
|
440
|
-
return new Promise((
|
|
475
|
+
return new Promise((s, o) => {
|
|
441
476
|
if (t.test(`${e.status}`))
|
|
442
|
-
return
|
|
477
|
+
return s(e);
|
|
443
478
|
const n = {
|
|
444
479
|
message: this._normalizeErrorMessage(e.data),
|
|
445
480
|
status: e.status,
|
|
446
481
|
response: e
|
|
447
482
|
};
|
|
448
|
-
|
|
483
|
+
o(n);
|
|
449
484
|
});
|
|
450
485
|
}
|
|
451
486
|
}
|
|
452
|
-
const
|
|
487
|
+
const K = "SB-Agent", H = {
|
|
453
488
|
defaultAgentName: "SB-JS-CLIENT",
|
|
454
489
|
defaultAgentVersion: "SB-Agent-Version",
|
|
455
490
|
packageVersion: "7.0.0"
|
|
456
|
-
},
|
|
491
|
+
}, Je = {
|
|
457
492
|
PUBLISHED: "published"
|
|
458
493
|
};
|
|
459
|
-
let
|
|
494
|
+
let x = {};
|
|
460
495
|
const E = {};
|
|
461
|
-
class
|
|
496
|
+
class qe {
|
|
462
497
|
/**
|
|
463
498
|
*
|
|
464
499
|
* @param config ISbConfig interface
|
|
@@ -466,27 +501,27 @@ class Ne {
|
|
|
466
501
|
*/
|
|
467
502
|
constructor(e, t) {
|
|
468
503
|
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");
|
|
469
|
-
let
|
|
470
|
-
if (!
|
|
504
|
+
let s = e.endpoint || t;
|
|
505
|
+
if (!s) {
|
|
471
506
|
const a = e.https === !1 ? "http" : "https";
|
|
472
|
-
e.oauthToken ?
|
|
507
|
+
e.oauthToken ? s = `${a}://${q(e.region)}/v1` : s = `${a}://${q(e.region)}/v2`;
|
|
473
508
|
}
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}),
|
|
509
|
+
const o = new Headers();
|
|
510
|
+
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([a, c]) => {
|
|
511
|
+
o.set(a, c);
|
|
512
|
+
}), o.has(K) || (o.set(K, H.defaultAgentName), o.set(
|
|
478
513
|
H.defaultAgentVersion,
|
|
479
514
|
H.packageVersion
|
|
480
515
|
));
|
|
481
516
|
let n = 5;
|
|
482
|
-
e.oauthToken && (
|
|
517
|
+
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = He(
|
|
483
518
|
this.throttledRequest.bind(this),
|
|
484
519
|
n,
|
|
485
520
|
1e3
|
|
486
|
-
), 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 ||
|
|
487
|
-
baseURL:
|
|
521
|
+
), 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 || Je.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ge({
|
|
522
|
+
baseURL: s,
|
|
488
523
|
timeout: e.timeout || 0,
|
|
489
|
-
headers:
|
|
524
|
+
headers: o,
|
|
490
525
|
responseInterceptor: e.responseInterceptor,
|
|
491
526
|
fetch: e.fetch
|
|
492
527
|
});
|
|
@@ -495,55 +530,55 @@ class Ne {
|
|
|
495
530
|
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;
|
|
496
531
|
}
|
|
497
532
|
factoryParamOptions(e, t) {
|
|
498
|
-
return
|
|
533
|
+
return J(e) ? this.parseParams(t) : t;
|
|
499
534
|
}
|
|
500
|
-
makeRequest(e, t,
|
|
535
|
+
makeRequest(e, t, s, o, n) {
|
|
501
536
|
const a = this.factoryParamOptions(
|
|
502
537
|
e,
|
|
503
|
-
|
|
538
|
+
Ue(t, s, o)
|
|
504
539
|
);
|
|
505
540
|
return this.cacheResponse(e, a, void 0, n);
|
|
506
541
|
}
|
|
507
|
-
get(e, t = {},
|
|
542
|
+
get(e, t = {}, s) {
|
|
508
543
|
t || (t = {});
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
const n = this.factoryParamOptions(
|
|
512
|
-
return this.cacheResponse(
|
|
544
|
+
const o = `/${e}`;
|
|
545
|
+
J(o) && (t.version = t.version || this.version);
|
|
546
|
+
const n = this.factoryParamOptions(o, t);
|
|
547
|
+
return this.cacheResponse(o, n, void 0, s);
|
|
513
548
|
}
|
|
514
|
-
async getAll(e, t = {},
|
|
515
|
-
const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), c =
|
|
549
|
+
async getAll(e, t = {}, s, o) {
|
|
550
|
+
const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), c = s ?? a.substring(a.lastIndexOf("/") + 1);
|
|
516
551
|
t.version = t.version || this.version;
|
|
517
552
|
const i = 1, u = await this.makeRequest(
|
|
518
553
|
a,
|
|
519
554
|
t,
|
|
520
555
|
n,
|
|
521
556
|
i,
|
|
522
|
-
|
|
523
|
-
), f = u.total ? Math.ceil(u.total / n) : 1, y = await
|
|
524
|
-
|
|
525
|
-
(R) => this.makeRequest(a, t, n, R + 1,
|
|
557
|
+
o
|
|
558
|
+
), f = u.total ? Math.ceil(u.total / (u.perPage || n)) : 1, y = await Ve(
|
|
559
|
+
ze(i, f),
|
|
560
|
+
(R) => this.makeRequest(a, t, n, R + 1, o)
|
|
526
561
|
);
|
|
527
|
-
return
|
|
562
|
+
return Fe([u, ...y], (R) => Object.values(R.data[c]));
|
|
528
563
|
}
|
|
529
|
-
post(e, t = {},
|
|
530
|
-
const
|
|
531
|
-
return this.throttle("post",
|
|
564
|
+
post(e, t = {}, s) {
|
|
565
|
+
const o = `/${e}`;
|
|
566
|
+
return this.throttle("post", o, t, s);
|
|
532
567
|
}
|
|
533
|
-
put(e, t = {},
|
|
534
|
-
const
|
|
535
|
-
return this.throttle("put",
|
|
568
|
+
put(e, t = {}, s) {
|
|
569
|
+
const o = `/${e}`;
|
|
570
|
+
return this.throttle("put", o, t, s);
|
|
536
571
|
}
|
|
537
|
-
delete(e, t = {},
|
|
572
|
+
delete(e, t = {}, s) {
|
|
538
573
|
t || (t = {});
|
|
539
|
-
const
|
|
540
|
-
return this.throttle("delete",
|
|
574
|
+
const o = `/${e}`;
|
|
575
|
+
return this.throttle("delete", o, t, s);
|
|
541
576
|
}
|
|
542
577
|
getStories(e = {}, t) {
|
|
543
578
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
544
579
|
}
|
|
545
|
-
getStory(e, t = {},
|
|
546
|
-
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t,
|
|
580
|
+
getStory(e, t = {}, s) {
|
|
581
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
|
|
547
582
|
}
|
|
548
583
|
getToken() {
|
|
549
584
|
return this.accessToken;
|
|
@@ -557,9 +592,9 @@ class Ne {
|
|
|
557
592
|
_cleanCopy(e) {
|
|
558
593
|
return JSON.parse(JSON.stringify(e));
|
|
559
594
|
}
|
|
560
|
-
_insertLinks(e, t,
|
|
561
|
-
const
|
|
562
|
-
|
|
595
|
+
_insertLinks(e, t, s) {
|
|
596
|
+
const o = e[t];
|
|
597
|
+
o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
|
|
563
598
|
}
|
|
564
599
|
/**
|
|
565
600
|
*
|
|
@@ -580,10 +615,10 @@ class Ne {
|
|
|
580
615
|
* - For single strings: directly replaces the UUID with the story reference
|
|
581
616
|
* - For arrays: maps through each UUID and replaces with corresponding story references
|
|
582
617
|
*/
|
|
583
|
-
_resolveField(e, t,
|
|
584
|
-
const
|
|
585
|
-
typeof
|
|
586
|
-
(n) => this.getStoryReference(
|
|
618
|
+
_resolveField(e, t, s) {
|
|
619
|
+
const o = e[t];
|
|
620
|
+
typeof o == "string" ? e[t] = this.getStoryReference(s, o) : Array.isArray(o) && (e[t] = o.map(
|
|
621
|
+
(n) => this.getStoryReference(s, n)
|
|
587
622
|
).filter(Boolean));
|
|
588
623
|
}
|
|
589
624
|
/**
|
|
@@ -603,13 +638,13 @@ class Ne {
|
|
|
603
638
|
* The method supports both string and array formats for the fields parameter,
|
|
604
639
|
* allowing flexible specification of relation patterns.
|
|
605
640
|
*/
|
|
606
|
-
_insertRelations(e, t,
|
|
607
|
-
if (Array.isArray(
|
|
608
|
-
this._resolveField(e, t,
|
|
641
|
+
_insertRelations(e, t, s, o) {
|
|
642
|
+
if (Array.isArray(s) ? s.find((a) => a.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
|
|
643
|
+
this._resolveField(e, t, o);
|
|
609
644
|
return;
|
|
610
645
|
}
|
|
611
646
|
const n = e.component ? `${e.component}.${t}` : t;
|
|
612
|
-
(Array.isArray(
|
|
647
|
+
(Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, o);
|
|
613
648
|
}
|
|
614
649
|
/**
|
|
615
650
|
* Recursively traverses and resolves relations in the story content tree
|
|
@@ -617,22 +652,22 @@ class Ne {
|
|
|
617
652
|
* @param fields - The relation patterns to resolve
|
|
618
653
|
* @param resolveId - The unique identifier for the current resolution context
|
|
619
654
|
*/
|
|
620
|
-
iterateTree(e, t,
|
|
621
|
-
const
|
|
655
|
+
iterateTree(e, t, s) {
|
|
656
|
+
const o = (n, a = "") => {
|
|
622
657
|
if (!(!n || n._stopResolving)) {
|
|
623
658
|
if (Array.isArray(n))
|
|
624
|
-
n.forEach((c, i) =>
|
|
659
|
+
n.forEach((c, i) => o(c, `${a}[${i}]`));
|
|
625
660
|
else if (typeof n == "object")
|
|
626
661
|
for (const c in n) {
|
|
627
662
|
const i = a ? `${a}.${c}` : c;
|
|
628
|
-
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t,
|
|
663
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t, s), this._insertLinks(n, c, s)), o(n[c], i);
|
|
629
664
|
}
|
|
630
665
|
}
|
|
631
666
|
};
|
|
632
|
-
|
|
667
|
+
o(e.content);
|
|
633
668
|
}
|
|
634
|
-
async resolveLinks(e, t,
|
|
635
|
-
let
|
|
669
|
+
async resolveLinks(e, t, s) {
|
|
670
|
+
let o = [];
|
|
636
671
|
if (e.link_uuids) {
|
|
637
672
|
const n = e.link_uuids.length, a = [], c = 50;
|
|
638
673
|
for (let i = 0; i < n; i += c) {
|
|
@@ -648,20 +683,20 @@ class Ne {
|
|
|
648
683
|
by_uuids: a[i].join(",")
|
|
649
684
|
})).data.stories.forEach(
|
|
650
685
|
(u) => {
|
|
651
|
-
|
|
686
|
+
o.push(u);
|
|
652
687
|
}
|
|
653
688
|
);
|
|
654
689
|
} else
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
this.links[
|
|
690
|
+
o = e.links;
|
|
691
|
+
o.forEach((n) => {
|
|
692
|
+
this.links[s][n.uuid] = {
|
|
658
693
|
...n,
|
|
659
694
|
_stopResolving: !0
|
|
660
695
|
};
|
|
661
696
|
});
|
|
662
697
|
}
|
|
663
|
-
async resolveRelations(e, t,
|
|
664
|
-
let
|
|
698
|
+
async resolveRelations(e, t, s) {
|
|
699
|
+
let o = [];
|
|
665
700
|
if (e.rel_uuids) {
|
|
666
701
|
const n = e.rel_uuids.length, a = [], c = 50;
|
|
667
702
|
for (let i = 0; i < n; i += c) {
|
|
@@ -677,13 +712,13 @@ class Ne {
|
|
|
677
712
|
by_uuids: a[i].join(","),
|
|
678
713
|
excluding_fields: t.excluding_fields
|
|
679
714
|
})).data.stories.forEach((u) => {
|
|
680
|
-
|
|
715
|
+
o.push(u);
|
|
681
716
|
});
|
|
682
|
-
|
|
717
|
+
o.length > 0 && (e.rels = o, delete e.rel_uuids);
|
|
683
718
|
} else
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
this.relations[
|
|
719
|
+
o = e.rels;
|
|
720
|
+
o && o.length > 0 && o.forEach((n) => {
|
|
721
|
+
this.relations[s][n.uuid] = {
|
|
687
722
|
...n,
|
|
688
723
|
_stopResolving: !0
|
|
689
724
|
};
|
|
@@ -698,21 +733,21 @@ class Ne {
|
|
|
698
733
|
* @returns Promise<void>
|
|
699
734
|
*
|
|
700
735
|
*/
|
|
701
|
-
async resolveStories(e, t,
|
|
702
|
-
var
|
|
736
|
+
async resolveStories(e, t, s) {
|
|
737
|
+
var o, n;
|
|
703
738
|
let a = [];
|
|
704
|
-
if (this.links[
|
|
705
|
-
for (const c in this.relations[
|
|
739
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
740
|
+
for (const c in this.relations[s])
|
|
706
741
|
this.iterateTree(
|
|
707
|
-
this.relations[
|
|
742
|
+
this.relations[s][c],
|
|
708
743
|
a,
|
|
709
|
-
|
|
744
|
+
s
|
|
710
745
|
);
|
|
711
|
-
e.story ? this.iterateTree(e.story, a,
|
|
712
|
-
this.iterateTree(c, a,
|
|
713
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
|
746
|
+
e.story ? this.iterateTree(e.story, a, s) : e.stories.forEach((c) => {
|
|
747
|
+
this.iterateTree(c, a, s);
|
|
748
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
714
749
|
}
|
|
715
|
-
async cacheResponse(e, t,
|
|
750
|
+
async cacheResponse(e, t, s, o) {
|
|
716
751
|
const n = U({ url: e, params: t }), a = this.cacheProvider();
|
|
717
752
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
718
753
|
const c = await a.get(n);
|
|
@@ -726,7 +761,7 @@ class Ne {
|
|
|
726
761
|
"get",
|
|
727
762
|
e,
|
|
728
763
|
t,
|
|
729
|
-
|
|
764
|
+
o
|
|
730
765
|
);
|
|
731
766
|
if (f.status !== 200)
|
|
732
767
|
return i(f);
|
|
@@ -742,16 +777,16 @@ class Ne {
|
|
|
742
777
|
const R = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
743
778
|
return t.token && y.data.cv && (R && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), c(y);
|
|
744
779
|
} catch (f) {
|
|
745
|
-
if (f.response && f.status === 429 && (
|
|
780
|
+
if (f.response && f.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
746
781
|
return console.log(
|
|
747
782
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
748
|
-
), await
|
|
783
|
+
), await Be(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(i);
|
|
749
784
|
i(f);
|
|
750
785
|
}
|
|
751
786
|
});
|
|
752
787
|
}
|
|
753
|
-
throttledRequest(e, t,
|
|
754
|
-
return this.client.setFetchOptions(
|
|
788
|
+
throttledRequest(e, t, s, o) {
|
|
789
|
+
return this.client.setFetchOptions(o), this.client[e](t, s);
|
|
755
790
|
}
|
|
756
791
|
cacheVersions() {
|
|
757
792
|
return E;
|
|
@@ -770,16 +805,16 @@ class Ne {
|
|
|
770
805
|
case "memory":
|
|
771
806
|
return {
|
|
772
807
|
get(e) {
|
|
773
|
-
return Promise.resolve(
|
|
808
|
+
return Promise.resolve(x[e]);
|
|
774
809
|
},
|
|
775
810
|
getAll() {
|
|
776
|
-
return Promise.resolve(
|
|
811
|
+
return Promise.resolve(x);
|
|
777
812
|
},
|
|
778
813
|
set(e, t) {
|
|
779
|
-
return
|
|
814
|
+
return x[e] = t, Promise.resolve(void 0);
|
|
780
815
|
},
|
|
781
816
|
flush() {
|
|
782
|
-
return
|
|
817
|
+
return x = {}, Promise.resolve(void 0);
|
|
783
818
|
}
|
|
784
819
|
};
|
|
785
820
|
case "custom":
|
|
@@ -809,38 +844,38 @@ class Ne {
|
|
|
809
844
|
async processInlineAssets(e) {
|
|
810
845
|
if (!this.inlineAssets)
|
|
811
846
|
return e;
|
|
812
|
-
const t = (
|
|
813
|
-
if (!
|
|
814
|
-
return
|
|
815
|
-
if (Array.isArray(
|
|
816
|
-
return
|
|
817
|
-
let
|
|
818
|
-
|
|
819
|
-
...
|
|
820
|
-
...e.data.assets.find((n) => n.id ===
|
|
847
|
+
const t = (s) => {
|
|
848
|
+
if (!s || typeof s != "object")
|
|
849
|
+
return s;
|
|
850
|
+
if (Array.isArray(s))
|
|
851
|
+
return s.map((n) => t(n));
|
|
852
|
+
let o = { ...s };
|
|
853
|
+
o.fieldtype === "asset" && Array.isArray(e.data.assets) && (o = {
|
|
854
|
+
...o,
|
|
855
|
+
...e.data.assets.find((n) => n.id === o.id)
|
|
821
856
|
});
|
|
822
|
-
for (const n in
|
|
823
|
-
typeof
|
|
824
|
-
return
|
|
857
|
+
for (const n in o)
|
|
858
|
+
typeof o[n] == "object" && (o[n] = t(o[n]));
|
|
859
|
+
return o;
|
|
825
860
|
};
|
|
826
|
-
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((
|
|
861
|
+
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((s) => (s.content = t(s.content), s))), e;
|
|
827
862
|
}
|
|
828
863
|
}
|
|
829
|
-
const
|
|
830
|
-
const { apiOptions: e } =
|
|
864
|
+
const rt = (r = {}) => {
|
|
865
|
+
const { apiOptions: e } = r;
|
|
831
866
|
if (!e || !e.accessToken) {
|
|
832
867
|
console.error(
|
|
833
868
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
834
869
|
);
|
|
835
870
|
return;
|
|
836
871
|
}
|
|
837
|
-
return { storyblokApi: new
|
|
838
|
-
},
|
|
839
|
-
if (typeof
|
|
872
|
+
return { storyblokApi: new qe(e) };
|
|
873
|
+
}, Ke = (r) => {
|
|
874
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
840
875
|
return {};
|
|
841
876
|
try {
|
|
842
877
|
const e = JSON.parse(
|
|
843
|
-
|
|
878
|
+
r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
844
879
|
);
|
|
845
880
|
return e ? {
|
|
846
881
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -850,160 +885,160 @@ const Ge = (s = {}) => {
|
|
|
850
885
|
return {};
|
|
851
886
|
}
|
|
852
887
|
};
|
|
853
|
-
let
|
|
854
|
-
const
|
|
855
|
-
var
|
|
856
|
-
const
|
|
888
|
+
let Y = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
889
|
+
const Ye = (r, e, t = {}) => {
|
|
890
|
+
var s;
|
|
891
|
+
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
857
892
|
"_storyblok"
|
|
858
|
-
), a = n !== null && +n ===
|
|
859
|
-
if (!(!
|
|
860
|
-
if (!
|
|
893
|
+
), a = n !== null && +n === r;
|
|
894
|
+
if (!(!o || !a)) {
|
|
895
|
+
if (!r) {
|
|
861
896
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
862
897
|
return;
|
|
863
898
|
}
|
|
864
899
|
window.storyblokRegisterEvent(() => {
|
|
865
900
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (c) => {
|
|
866
901
|
var i;
|
|
867
|
-
c && (c.action === "input" && ((i = c.story) == null ? void 0 : i.id) ===
|
|
902
|
+
c && (c.action === "input" && ((i = c.story) == null ? void 0 : i.id) === r ? e(c.story) : (c.action === "change" || c.action === "published") && c.storyId === r && window.location.reload());
|
|
868
903
|
});
|
|
869
904
|
});
|
|
870
905
|
}
|
|
871
|
-
},
|
|
906
|
+
}, Ze = (r = {}) => {
|
|
872
907
|
var e, t;
|
|
873
908
|
const {
|
|
874
|
-
bridge:
|
|
875
|
-
accessToken:
|
|
909
|
+
bridge: s,
|
|
910
|
+
accessToken: o,
|
|
876
911
|
use: n = [],
|
|
877
912
|
apiOptions: a = {},
|
|
878
913
|
bridgeUrl: c
|
|
879
|
-
} =
|
|
880
|
-
a.accessToken = a.accessToken ||
|
|
881
|
-
const i = { bridge:
|
|
914
|
+
} = r;
|
|
915
|
+
a.accessToken = a.accessToken || o;
|
|
916
|
+
const i = { bridge: s, apiOptions: a };
|
|
882
917
|
let u = {};
|
|
883
918
|
n.forEach((y) => {
|
|
884
919
|
u = { ...u, ...y(i) };
|
|
885
|
-
}), c && (
|
|
920
|
+
}), c && (Y = c);
|
|
886
921
|
const f = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
887
|
-
return
|
|
922
|
+
return s !== !1 && f && xe(Y), u;
|
|
888
923
|
};
|
|
889
|
-
function
|
|
890
|
-
return
|
|
924
|
+
function st(r, e) {
|
|
925
|
+
return te(e).render(r);
|
|
891
926
|
}
|
|
892
|
-
const
|
|
927
|
+
const re = /* @__PURE__ */ Z({
|
|
893
928
|
__name: "StoryblokComponent",
|
|
894
929
|
props: {
|
|
895
930
|
blok: {}
|
|
896
931
|
},
|
|
897
|
-
setup(
|
|
932
|
+
setup(r, { expose: e }) {
|
|
898
933
|
var c;
|
|
899
|
-
const t =
|
|
934
|
+
const t = r, s = P();
|
|
900
935
|
e({
|
|
901
|
-
value:
|
|
936
|
+
value: s
|
|
902
937
|
});
|
|
903
|
-
const
|
|
904
|
-
return !
|
|
938
|
+
const o = typeof D(t.blok.component) != "string", n = pe("VueSDKOptions"), a = P((c = t.blok.component) == null ? void 0 : c.replace(/_/g, "-"));
|
|
939
|
+
return !o && n && (n.enableFallbackComponent ? (a.value = n.customFallbackComponent ?? "FallbackComponent", typeof D(a.value) == "string" && console.error(
|
|
905
940
|
`Is the Fallback component "${a.value}" registered properly?`
|
|
906
941
|
)) : console.error(
|
|
907
942
|
`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});"?`
|
|
908
|
-
)), (i, u) => (X(), W(
|
|
943
|
+
)), (i, u) => (X(), W(D(a.value), fe({
|
|
909
944
|
ref_key: "blokRef",
|
|
910
|
-
ref:
|
|
945
|
+
ref: s
|
|
911
946
|
}, { ...i.$props, ...i.$attrs }), null, 16));
|
|
912
947
|
}
|
|
913
|
-
}),
|
|
948
|
+
}), We = (r) => {
|
|
914
949
|
var e, t;
|
|
915
950
|
return Q(
|
|
916
|
-
|
|
951
|
+
re,
|
|
917
952
|
{
|
|
918
|
-
blok: (e =
|
|
919
|
-
id: (t =
|
|
953
|
+
blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
|
|
954
|
+
id: (t = r.attrs) == null ? void 0 : t.id
|
|
920
955
|
},
|
|
921
|
-
|
|
956
|
+
r.children
|
|
922
957
|
);
|
|
923
958
|
};
|
|
924
|
-
function
|
|
959
|
+
function Xe(r) {
|
|
925
960
|
const e = {
|
|
926
961
|
renderFn: Q,
|
|
927
962
|
// TODO: Check why this changed.
|
|
928
963
|
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
929
|
-
textFn:
|
|
964
|
+
textFn: ye,
|
|
930
965
|
keyedResolvers: !0,
|
|
931
966
|
resolvers: {
|
|
932
|
-
[
|
|
933
|
-
...
|
|
967
|
+
[v.COMPONENT]: We,
|
|
968
|
+
...r.resolvers
|
|
934
969
|
}
|
|
935
970
|
};
|
|
936
|
-
return
|
|
971
|
+
return te(e);
|
|
937
972
|
}
|
|
938
|
-
const
|
|
973
|
+
const Qe = /* @__PURE__ */ Z({
|
|
939
974
|
__name: "StoryblokRichText",
|
|
940
975
|
props: {
|
|
941
976
|
doc: {},
|
|
942
977
|
resolvers: {}
|
|
943
978
|
},
|
|
944
|
-
setup(
|
|
945
|
-
const e =
|
|
946
|
-
return
|
|
947
|
-
const { render: a } =
|
|
979
|
+
setup(r) {
|
|
980
|
+
const e = r, t = P(), s = () => t.value;
|
|
981
|
+
return me([() => e.doc, () => e.resolvers], ([o, n]) => {
|
|
982
|
+
const { render: a } = Xe({
|
|
948
983
|
resolvers: n ?? {}
|
|
949
984
|
});
|
|
950
|
-
t.value = a(
|
|
985
|
+
t.value = a(o);
|
|
951
986
|
}, {
|
|
952
987
|
immediate: !0,
|
|
953
988
|
deep: !0
|
|
954
|
-
}), (
|
|
989
|
+
}), (o, n) => (X(), W(s));
|
|
955
990
|
}
|
|
956
|
-
}),
|
|
957
|
-
beforeMount(
|
|
991
|
+
}), et = {
|
|
992
|
+
beforeMount(r, e) {
|
|
958
993
|
if (e.value) {
|
|
959
|
-
const t =
|
|
960
|
-
Object.keys(t).length > 0 && (
|
|
994
|
+
const t = Ke(e.value);
|
|
995
|
+
Object.keys(t).length > 0 && (r.setAttribute("data-blok-c", t["data-blok-c"]), r.setAttribute("data-blok-uid", t["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
961
996
|
}
|
|
962
997
|
}
|
|
963
|
-
}, se = (
|
|
964
|
-
console.error(`You can't use ${
|
|
998
|
+
}, se = (r) => {
|
|
999
|
+
console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
965
1000
|
`);
|
|
966
1001
|
};
|
|
967
|
-
let
|
|
968
|
-
const
|
|
969
|
-
const
|
|
970
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
(
|
|
1002
|
+
let S = null;
|
|
1003
|
+
const ot = () => (S || se("useStoryblokApi"), S), nt = async (r, e = {}, t = {}) => {
|
|
1004
|
+
const s = P(null);
|
|
1005
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, ge(() => {
|
|
1006
|
+
s.value && s.value.id && Ye(
|
|
1007
|
+
s.value.id,
|
|
1008
|
+
(o) => s.value = o,
|
|
974
1009
|
t
|
|
975
1010
|
);
|
|
976
|
-
}),
|
|
977
|
-
const { data:
|
|
978
|
-
`cdn/stories/${
|
|
1011
|
+
}), S) {
|
|
1012
|
+
const { data: o } = await S.get(
|
|
1013
|
+
`cdn/stories/${r}`,
|
|
979
1014
|
e
|
|
980
1015
|
);
|
|
981
|
-
|
|
1016
|
+
s.value = o.story;
|
|
982
1017
|
} else
|
|
983
1018
|
se("useStoryblok");
|
|
984
|
-
return
|
|
985
|
-
},
|
|
986
|
-
install(
|
|
987
|
-
|
|
1019
|
+
return s;
|
|
1020
|
+
}, it = {
|
|
1021
|
+
install(r, e = {}) {
|
|
1022
|
+
r.directive("editable", et), r.component("StoryblokComponent", re), r.component("StoryblokRichText", Qe), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
|
|
988
1023
|
"FallbackComponent",
|
|
989
1024
|
be(() => import("./FallbackComponent-Dky11gEu.js"))
|
|
990
1025
|
);
|
|
991
|
-
const { storyblokApi: t } =
|
|
992
|
-
|
|
1026
|
+
const { storyblokApi: t } = Ze(e);
|
|
1027
|
+
S = t || null, r.provide("VueSDKOptions", e);
|
|
993
1028
|
}
|
|
994
1029
|
};
|
|
995
1030
|
export {
|
|
996
|
-
|
|
1031
|
+
v as BlockTypes,
|
|
997
1032
|
$ as MarkTypes,
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1033
|
+
re as StoryblokComponent,
|
|
1034
|
+
Qe as StoryblokRichText,
|
|
1035
|
+
it as StoryblokVue,
|
|
1036
|
+
Se as TextTypes,
|
|
1037
|
+
rt as apiPlugin,
|
|
1038
|
+
st as renderRichText,
|
|
1039
|
+
te as richTextResolver,
|
|
1040
|
+
nt as useStoryblok,
|
|
1041
|
+
ot as useStoryblokApi,
|
|
1042
|
+
Ye as useStoryblokBridge,
|
|
1043
|
+
Xe as useStoryblokRichText
|
|
1009
1044
|
};
|