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