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