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