@storyblok/vue 9.0.0 → 9.0.1
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 +295 -289
- 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,128 @@ 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
|
|
250
|
+
let V = !1;
|
|
251
|
+
const z = [], Te = (s) => new Promise((e, t) => {
|
|
246
252
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
247
253
|
if (window.location === window.parent.location) {
|
|
248
254
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
249
255
|
return;
|
|
250
256
|
}
|
|
251
|
-
|
|
257
|
+
V ? r() : z.push(r);
|
|
252
258
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
253
259
|
return;
|
|
254
260
|
const o = document.createElement("script");
|
|
255
261
|
o.async = !0, o.src = s, o.id = "storyblok-javascript-bridge", o.onerror = (r) => t(r), o.onload = (r) => {
|
|
256
|
-
|
|
262
|
+
z.forEach((n) => n()), V = !0, e(r);
|
|
257
263
|
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
258
264
|
});
|
|
259
|
-
var
|
|
260
|
-
class
|
|
265
|
+
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);
|
|
266
|
+
class $e extends Error {
|
|
261
267
|
constructor(e) {
|
|
262
268
|
super(e), this.name = "AbortError";
|
|
263
269
|
}
|
|
264
270
|
}
|
|
265
|
-
function
|
|
271
|
+
function Ae(s, e, t) {
|
|
266
272
|
if (!Number.isFinite(e))
|
|
267
273
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
268
274
|
if (!Number.isFinite(t))
|
|
269
275
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
270
276
|
const o = [];
|
|
271
|
-
let r = [], n = 0,
|
|
272
|
-
const
|
|
277
|
+
let r = [], n = 0, a = !1;
|
|
278
|
+
const c = async () => {
|
|
273
279
|
n++;
|
|
274
280
|
const u = o.shift();
|
|
275
281
|
if (u)
|
|
@@ -280,10 +286,10 @@ function $e(s, e, t) {
|
|
|
280
286
|
u.reject(y);
|
|
281
287
|
}
|
|
282
288
|
const f = setTimeout(() => {
|
|
283
|
-
n--, o.length > 0 &&
|
|
289
|
+
n--, o.length > 0 && c(), r = r.filter((y) => y !== f);
|
|
284
290
|
}, t);
|
|
285
291
|
r.includes(f) || r.push(f);
|
|
286
|
-
},
|
|
292
|
+
}, i = (...u) => a ? Promise.reject(
|
|
287
293
|
new Error(
|
|
288
294
|
"Throttled function is already aborted and not accepting new promises"
|
|
289
295
|
)
|
|
@@ -292,22 +298,22 @@ function $e(s, e, t) {
|
|
|
292
298
|
resolve: f,
|
|
293
299
|
reject: y,
|
|
294
300
|
args: u
|
|
295
|
-
}), n < e &&
|
|
301
|
+
}), n < e && c();
|
|
296
302
|
});
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
(u) => u.reject(() => new
|
|
303
|
+
return i.abort = () => {
|
|
304
|
+
a = !0, r.forEach(clearTimeout), r = [], o.forEach(
|
|
305
|
+
(u) => u.reject(() => new $e("Throttle function aborted"))
|
|
300
306
|
), o.length = 0;
|
|
301
|
-
},
|
|
307
|
+
}, i;
|
|
302
308
|
}
|
|
303
|
-
const
|
|
309
|
+
const Ee = (s = "") => s.includes("/cdn/"), Se = (s, e = 25, t = 1) => ({
|
|
304
310
|
...s,
|
|
305
311
|
per_page: e,
|
|
306
312
|
page: t
|
|
307
|
-
}),
|
|
313
|
+
}), Ie = (s) => new Promise((e) => setTimeout(e, s)), Le = (s = 0, e) => Array.from({ length: s }, e), Ce = (s = 0, e = s) => {
|
|
308
314
|
const t = Math.abs(e - s) || 0, o = s < e ? 1 : -1;
|
|
309
|
-
return
|
|
310
|
-
},
|
|
315
|
+
return Le(t, (r, n) => n * o + s);
|
|
316
|
+
}, 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
317
|
const o = [];
|
|
312
318
|
for (const r in s) {
|
|
313
319
|
if (!Object.prototype.hasOwnProperty.call(s, r))
|
|
@@ -315,16 +321,16 @@ const Ae = (s = "") => s.includes("/cdn/"), Ee = (s, e = 25, t = 1) => ({
|
|
|
315
321
|
const n = s[r];
|
|
316
322
|
if (n == null)
|
|
317
323
|
continue;
|
|
318
|
-
const
|
|
319
|
-
let
|
|
320
|
-
typeof n == "object" ?
|
|
324
|
+
const a = t ? "" : encodeURIComponent(r);
|
|
325
|
+
let c;
|
|
326
|
+
typeof n == "object" ? c = D(
|
|
321
327
|
n,
|
|
322
|
-
e ? e + encodeURIComponent(`[${
|
|
328
|
+
e ? e + encodeURIComponent(`[${a}]`) : a,
|
|
323
329
|
Array.isArray(n)
|
|
324
|
-
) :
|
|
330
|
+
) : c = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(c);
|
|
325
331
|
}
|
|
326
332
|
return o.join("&");
|
|
327
|
-
},
|
|
333
|
+
}, G = (s) => {
|
|
328
334
|
const e = {
|
|
329
335
|
eu: "api.storyblok.com",
|
|
330
336
|
us: "api-us.storyblok.com",
|
|
@@ -334,7 +340,7 @@ const Ae = (s = "") => s.includes("/cdn/"), Ee = (s, e = 25, t = 1) => ({
|
|
|
334
340
|
};
|
|
335
341
|
return e[s] ?? e.eu;
|
|
336
342
|
};
|
|
337
|
-
class
|
|
343
|
+
class xe {
|
|
338
344
|
constructor(e) {
|
|
339
345
|
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
346
|
}
|
|
@@ -373,25 +379,25 @@ class je {
|
|
|
373
379
|
async _methodHandler(e) {
|
|
374
380
|
let t = `${this.baseURL}${this.url}`, o = null;
|
|
375
381
|
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 && (
|
|
382
|
+
const r = new URL(t), n = new AbortController(), { signal: a } = n;
|
|
383
|
+
let c;
|
|
384
|
+
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
|
379
385
|
try {
|
|
380
|
-
const
|
|
386
|
+
const i = await this.fetch(`${r}`, {
|
|
381
387
|
method: e,
|
|
382
388
|
headers: this.headers,
|
|
383
389
|
body: o,
|
|
384
|
-
signal:
|
|
390
|
+
signal: a,
|
|
385
391
|
...this.fetchOptions
|
|
386
392
|
});
|
|
387
|
-
this.timeout && clearTimeout(
|
|
393
|
+
this.timeout && clearTimeout(c);
|
|
388
394
|
const u = await this._responseHandler(
|
|
389
|
-
|
|
395
|
+
i
|
|
390
396
|
);
|
|
391
397
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
|
|
392
|
-
} catch (
|
|
398
|
+
} catch (i) {
|
|
393
399
|
return {
|
|
394
|
-
message:
|
|
400
|
+
message: i
|
|
395
401
|
};
|
|
396
402
|
}
|
|
397
403
|
}
|
|
@@ -437,16 +443,16 @@ class je {
|
|
|
437
443
|
});
|
|
438
444
|
}
|
|
439
445
|
}
|
|
440
|
-
const
|
|
446
|
+
const q = "SB-Agent", H = {
|
|
441
447
|
defaultAgentName: "SB-JS-CLIENT",
|
|
442
448
|
defaultAgentVersion: "SB-Agent-Version",
|
|
443
449
|
packageVersion: "6.0.0"
|
|
444
|
-
},
|
|
450
|
+
}, Pe = {
|
|
445
451
|
DRAFT: "draft"
|
|
446
452
|
};
|
|
447
453
|
let j = {};
|
|
448
454
|
const A = {};
|
|
449
|
-
class
|
|
455
|
+
class Ne {
|
|
450
456
|
/**
|
|
451
457
|
*
|
|
452
458
|
* @param config ISbConfig interface
|
|
@@ -456,22 +462,22 @@ class Pe {
|
|
|
456
462
|
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
463
|
let o = e.endpoint || t;
|
|
458
464
|
if (!o) {
|
|
459
|
-
const
|
|
460
|
-
e.oauthToken ? o = `${
|
|
465
|
+
const a = e.https === !1 ? "http" : "https";
|
|
466
|
+
e.oauthToken ? o = `${a}://${G(e.region)}/v1` : o = `${a}://${G(e.region)}/v2`;
|
|
461
467
|
}
|
|
462
468
|
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(
|
|
469
|
+
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]) => {
|
|
470
|
+
r.set(a, c);
|
|
471
|
+
}), r.has(q) || (r.set(q, H.defaultAgentName), r.set(
|
|
466
472
|
H.defaultAgentVersion,
|
|
467
473
|
H.packageVersion
|
|
468
474
|
));
|
|
469
475
|
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 =
|
|
476
|
+
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
477
|
this.throttledRequest.bind(this),
|
|
472
478
|
n,
|
|
473
479
|
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 ||
|
|
480
|
+
), 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
481
|
baseURL: o,
|
|
476
482
|
timeout: e.timeout || 0,
|
|
477
483
|
headers: r,
|
|
@@ -483,14 +489,14 @@ class Pe {
|
|
|
483
489
|
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
490
|
}
|
|
485
491
|
factoryParamOptions(e, t) {
|
|
486
|
-
return
|
|
492
|
+
return Ee(e) ? this.parseParams(t) : t;
|
|
487
493
|
}
|
|
488
494
|
makeRequest(e, t, o, r, n) {
|
|
489
|
-
const
|
|
495
|
+
const a = this.factoryParamOptions(
|
|
490
496
|
e,
|
|
491
|
-
|
|
497
|
+
Se(t, o, r)
|
|
492
498
|
);
|
|
493
|
-
return this.cacheResponse(e,
|
|
499
|
+
return this.cacheResponse(e, a, void 0, n);
|
|
494
500
|
}
|
|
495
501
|
get(e, t = {}, o) {
|
|
496
502
|
t || (t = {});
|
|
@@ -500,19 +506,19 @@ class Pe {
|
|
|
500
506
|
return this.cacheResponse(r, n, void 0, o);
|
|
501
507
|
}
|
|
502
508
|
async getAll(e, t = {}, o, r) {
|
|
503
|
-
const n = (t == null ? void 0 : t.per_page) || 25,
|
|
509
|
+
const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), c = o ?? a.substring(a.lastIndexOf("/") + 1);
|
|
504
510
|
t.version = t.version || this.version;
|
|
505
|
-
const
|
|
506
|
-
|
|
511
|
+
const i = 1, u = await this.makeRequest(
|
|
512
|
+
a,
|
|
507
513
|
t,
|
|
508
514
|
n,
|
|
509
|
-
|
|
515
|
+
i,
|
|
510
516
|
r
|
|
511
|
-
), f = u.total ? Math.ceil(u.total / n) : 1, y = await
|
|
512
|
-
|
|
513
|
-
(
|
|
517
|
+
), f = u.total ? Math.ceil(u.total / n) : 1, y = await Oe(
|
|
518
|
+
Ce(i, f),
|
|
519
|
+
(R) => this.makeRequest(a, t, n, R + 1, r)
|
|
514
520
|
);
|
|
515
|
-
return
|
|
521
|
+
return je([u, ...y], (R) => Object.values(R.data[c]));
|
|
516
522
|
}
|
|
517
523
|
post(e, t = {}, o) {
|
|
518
524
|
const r = `/${e}`;
|
|
@@ -592,7 +598,7 @@ class Pe {
|
|
|
592
598
|
* allowing flexible specification of relation patterns.
|
|
593
599
|
*/
|
|
594
600
|
_insertRelations(e, t, o, r) {
|
|
595
|
-
if (Array.isArray(o) ? o.find((
|
|
601
|
+
if (Array.isArray(o) ? o.find((a) => a.endsWith(`.${t}`)) : o.endsWith(`.${t}`)) {
|
|
596
602
|
this._resolveField(e, t, r);
|
|
597
603
|
return;
|
|
598
604
|
}
|
|
@@ -606,14 +612,14 @@ class Pe {
|
|
|
606
612
|
* @param resolveId - The unique identifier for the current resolution context
|
|
607
613
|
*/
|
|
608
614
|
iterateTree(e, t, o) {
|
|
609
|
-
const r = (n,
|
|
615
|
+
const r = (n, a = "") => {
|
|
610
616
|
if (!(!n || n._stopResolving)) {
|
|
611
617
|
if (Array.isArray(n))
|
|
612
|
-
n.forEach((
|
|
618
|
+
n.forEach((c, i) => r(c, `${a}[${i}]`));
|
|
613
619
|
else if (typeof n == "object")
|
|
614
|
-
for (const
|
|
615
|
-
const
|
|
616
|
-
(n.component && n._uid || n.type === "link") && (this._insertRelations(n,
|
|
620
|
+
for (const c in n) {
|
|
621
|
+
const i = a ? `${a}.${c}` : c;
|
|
622
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t, o), this._insertLinks(n, c, o)), r(n[c], i);
|
|
617
623
|
}
|
|
618
624
|
}
|
|
619
625
|
};
|
|
@@ -622,18 +628,18 @@ class Pe {
|
|
|
622
628
|
async resolveLinks(e, t, o) {
|
|
623
629
|
let r = [];
|
|
624
630
|
if (e.link_uuids) {
|
|
625
|
-
const n = e.link_uuids.length,
|
|
626
|
-
for (let
|
|
627
|
-
const u = Math.min(n,
|
|
628
|
-
|
|
631
|
+
const n = e.link_uuids.length, a = [], c = 50;
|
|
632
|
+
for (let i = 0; i < n; i += c) {
|
|
633
|
+
const u = Math.min(n, i + c);
|
|
634
|
+
a.push(e.link_uuids.slice(i, u));
|
|
629
635
|
}
|
|
630
|
-
for (let
|
|
636
|
+
for (let i = 0; i < a.length; i++)
|
|
631
637
|
(await this.getStories({
|
|
632
|
-
per_page:
|
|
638
|
+
per_page: c,
|
|
633
639
|
language: t.language,
|
|
634
640
|
version: t.version,
|
|
635
641
|
starts_with: t.starts_with,
|
|
636
|
-
by_uuids: i
|
|
642
|
+
by_uuids: a[i].join(",")
|
|
637
643
|
})).data.stories.forEach(
|
|
638
644
|
(u) => {
|
|
639
645
|
r.push(u);
|
|
@@ -651,18 +657,18 @@ class Pe {
|
|
|
651
657
|
async resolveRelations(e, t, o) {
|
|
652
658
|
let r = [];
|
|
653
659
|
if (e.rel_uuids) {
|
|
654
|
-
const n = e.rel_uuids.length,
|
|
655
|
-
for (let
|
|
656
|
-
const u = Math.min(n,
|
|
657
|
-
|
|
660
|
+
const n = e.rel_uuids.length, a = [], c = 50;
|
|
661
|
+
for (let i = 0; i < n; i += c) {
|
|
662
|
+
const u = Math.min(n, i + c);
|
|
663
|
+
a.push(e.rel_uuids.slice(i, u));
|
|
658
664
|
}
|
|
659
|
-
for (let
|
|
665
|
+
for (let i = 0; i < a.length; i++)
|
|
660
666
|
(await this.getStories({
|
|
661
|
-
per_page:
|
|
667
|
+
per_page: c,
|
|
662
668
|
language: t.language,
|
|
663
669
|
version: t.version,
|
|
664
670
|
starts_with: t.starts_with,
|
|
665
|
-
by_uuids: i
|
|
671
|
+
by_uuids: a[i].join(","),
|
|
666
672
|
excluding_fields: t.excluding_fields
|
|
667
673
|
})).data.stories.forEach((u) => {
|
|
668
674
|
r.push(u);
|
|
@@ -688,26 +694,26 @@ class Pe {
|
|
|
688
694
|
*/
|
|
689
695
|
async resolveStories(e, t, o) {
|
|
690
696
|
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
|
|
697
|
+
let a = [];
|
|
698
|
+
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)
|
|
699
|
+
for (const c in this.relations[o])
|
|
694
700
|
this.iterateTree(
|
|
695
|
-
this.relations[o][
|
|
696
|
-
|
|
701
|
+
this.relations[o][c],
|
|
702
|
+
a,
|
|
697
703
|
o
|
|
698
704
|
);
|
|
699
|
-
e.story ? this.iterateTree(e.story,
|
|
700
|
-
this.iterateTree(
|
|
705
|
+
e.story ? this.iterateTree(e.story, a, o) : e.stories.forEach((c) => {
|
|
706
|
+
this.iterateTree(c, a, o);
|
|
701
707
|
}), this.stringifiedStoriesCache = {}, delete this.links[o], delete this.relations[o];
|
|
702
708
|
}
|
|
703
709
|
async cacheResponse(e, t, o, r) {
|
|
704
|
-
const n = D({ url: e, params: t }),
|
|
710
|
+
const n = D({ url: e, params: t }), a = this.cacheProvider();
|
|
705
711
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
706
|
-
const
|
|
707
|
-
if (
|
|
708
|
-
return Promise.resolve(
|
|
712
|
+
const c = await a.get(n);
|
|
713
|
+
if (c)
|
|
714
|
+
return Promise.resolve(c);
|
|
709
715
|
}
|
|
710
|
-
return new Promise(async (
|
|
716
|
+
return new Promise(async (c, i) => {
|
|
711
717
|
var u;
|
|
712
718
|
try {
|
|
713
719
|
const f = await this.throttle(
|
|
@@ -717,24 +723,24 @@ class Pe {
|
|
|
717
723
|
r
|
|
718
724
|
);
|
|
719
725
|
if (f.status !== 200)
|
|
720
|
-
return
|
|
726
|
+
return i(f);
|
|
721
727
|
let y = { data: f.data, headers: f.headers };
|
|
722
728
|
if ((u = f.headers) != null && u["per-page"] && (y = Object.assign({}, y, {
|
|
723
729
|
perPage: f.headers["per-page"] ? Number.parseInt(f.headers["per-page"]) : 0,
|
|
724
730
|
total: f.headers["per-page"] ? Number.parseInt(f.headers.total) : 0
|
|
725
731
|
})), y.data.story || y.data.stories) {
|
|
726
|
-
const
|
|
727
|
-
await this.resolveStories(y.data, t, `${
|
|
732
|
+
const T = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
733
|
+
await this.resolveStories(y.data, t, `${T}`), y = await this.processInlineAssets(y);
|
|
728
734
|
}
|
|
729
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await
|
|
730
|
-
const
|
|
731
|
-
return t.token && y.data.cv && (
|
|
735
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, y);
|
|
736
|
+
const R = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
737
|
+
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
738
|
} catch (f) {
|
|
733
739
|
if (f.response && f.status === 429 && (o = typeof o > "u" ? 0 : o + 1, o < this.maxRetries))
|
|
734
740
|
return console.log(
|
|
735
741
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
736
|
-
), await
|
|
737
|
-
|
|
742
|
+
), await Ie(this.retriesDelay), this.cacheResponse(e, t, o).then(c).catch(i);
|
|
743
|
+
i(f);
|
|
738
744
|
}
|
|
739
745
|
});
|
|
740
746
|
}
|
|
@@ -813,7 +819,7 @@ class Pe {
|
|
|
813
819
|
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
820
|
}
|
|
815
821
|
}
|
|
816
|
-
const
|
|
822
|
+
const Ge = (s = {}) => {
|
|
817
823
|
const { apiOptions: e } = s;
|
|
818
824
|
if (!e || !e.accessToken) {
|
|
819
825
|
console.error(
|
|
@@ -821,8 +827,8 @@ const ze = (s = {}) => {
|
|
|
821
827
|
);
|
|
822
828
|
return;
|
|
823
829
|
}
|
|
824
|
-
return { storyblokApi: new
|
|
825
|
-
},
|
|
830
|
+
return { storyblokApi: new Ne(e) };
|
|
831
|
+
}, He = (s) => {
|
|
826
832
|
if (typeof s != "object" || typeof s._editable > "u")
|
|
827
833
|
return {};
|
|
828
834
|
try {
|
|
@@ -837,46 +843,46 @@ const ze = (s = {}) => {
|
|
|
837
843
|
return {};
|
|
838
844
|
}
|
|
839
845
|
};
|
|
840
|
-
let
|
|
841
|
-
const
|
|
846
|
+
let J = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
847
|
+
const De = (s, e, t = {}) => {
|
|
842
848
|
var o;
|
|
843
849
|
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((o = window.location) == null ? void 0 : o.href).searchParams.get(
|
|
844
850
|
"_storyblok"
|
|
845
|
-
),
|
|
846
|
-
if (!(!r || !
|
|
851
|
+
), a = n !== null && +n === s;
|
|
852
|
+
if (!(!r || !a)) {
|
|
847
853
|
if (!s) {
|
|
848
854
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
849
855
|
return;
|
|
850
856
|
}
|
|
851
857
|
window.storyblokRegisterEvent(() => {
|
|
852
|
-
new window.StoryblokBridge(t).on(["input", "published", "change"], (
|
|
853
|
-
var
|
|
854
|
-
|
|
858
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (c) => {
|
|
859
|
+
var i;
|
|
860
|
+
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
861
|
});
|
|
856
862
|
});
|
|
857
863
|
}
|
|
858
|
-
},
|
|
864
|
+
}, Ue = (s = {}) => {
|
|
859
865
|
var e, t;
|
|
860
866
|
const {
|
|
861
867
|
bridge: o,
|
|
862
868
|
accessToken: r,
|
|
863
869
|
use: n = [],
|
|
864
|
-
apiOptions:
|
|
865
|
-
bridgeUrl:
|
|
870
|
+
apiOptions: a = {},
|
|
871
|
+
bridgeUrl: c
|
|
866
872
|
} = s;
|
|
867
|
-
|
|
868
|
-
const
|
|
873
|
+
a.accessToken = a.accessToken || r;
|
|
874
|
+
const i = { bridge: o, apiOptions: a };
|
|
869
875
|
let u = {};
|
|
870
876
|
n.forEach((y) => {
|
|
871
|
-
u = { ...u, ...y(
|
|
872
|
-
}),
|
|
877
|
+
u = { ...u, ...y(i) };
|
|
878
|
+
}), c && (J = c);
|
|
873
879
|
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 &&
|
|
880
|
+
return o !== !1 && f && Te(J), u;
|
|
875
881
|
};
|
|
876
|
-
function
|
|
877
|
-
return
|
|
882
|
+
function qe(s, e) {
|
|
883
|
+
return Z(e).render(s);
|
|
878
884
|
}
|
|
879
|
-
const
|
|
885
|
+
const ee = /* @__PURE__ */ K({
|
|
880
886
|
__name: "StoryblokComponent",
|
|
881
887
|
props: {
|
|
882
888
|
blok: {}
|
|
@@ -886,20 +892,20 @@ const Q = /* @__PURE__ */ q({
|
|
|
886
892
|
e({
|
|
887
893
|
value: o
|
|
888
894
|
});
|
|
889
|
-
const r = typeof N(t.blok.component) != "string", n =
|
|
890
|
-
return !r && n && (n.enableFallbackComponent ? (
|
|
891
|
-
`Is the Fallback component "${
|
|
895
|
+
const r = typeof N(t.blok.component) != "string", n = he("VueSDKOptions"), a = x(t.blok.component);
|
|
896
|
+
return !r && n && (n.enableFallbackComponent ? (a.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(a.value) == "string" && console.error(
|
|
897
|
+
`Is the Fallback component "${a.value}" registered properly?`
|
|
892
898
|
)) : console.error(
|
|
893
899
|
`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
|
-
)), (
|
|
900
|
+
)), (c, i) => (W(), Y(N(a.value), de({
|
|
895
901
|
ref_key: "blokRef",
|
|
896
902
|
ref: o
|
|
897
|
-
}, { ...
|
|
903
|
+
}, { ...c.$props, ...c.$attrs }), null, 16));
|
|
898
904
|
}
|
|
899
|
-
}),
|
|
905
|
+
}), Be = (s) => {
|
|
900
906
|
var e, t;
|
|
901
|
-
return
|
|
902
|
-
|
|
907
|
+
return X(
|
|
908
|
+
ee,
|
|
903
909
|
{
|
|
904
910
|
blok: (e = s == null ? void 0 : s.attrs) == null ? void 0 : e.body[0],
|
|
905
911
|
id: (t = s.attrs) == null ? void 0 : t.id
|
|
@@ -907,21 +913,21 @@ const Q = /* @__PURE__ */ q({
|
|
|
907
913
|
s.children
|
|
908
914
|
);
|
|
909
915
|
};
|
|
910
|
-
function
|
|
916
|
+
function Me(s) {
|
|
911
917
|
const e = {
|
|
912
|
-
renderFn:
|
|
918
|
+
renderFn: X,
|
|
913
919
|
// TODO: Check why this changed.
|
|
914
920
|
// @ts-expect-error - createTextVNode types has been recently changed.
|
|
915
|
-
textFn:
|
|
921
|
+
textFn: pe,
|
|
916
922
|
keyedResolvers: !0,
|
|
917
923
|
resolvers: {
|
|
918
|
-
[g.COMPONENT]:
|
|
924
|
+
[g.COMPONENT]: Be,
|
|
919
925
|
...s.resolvers
|
|
920
926
|
}
|
|
921
927
|
};
|
|
922
|
-
return
|
|
928
|
+
return Z(e);
|
|
923
929
|
}
|
|
924
|
-
const
|
|
930
|
+
const Fe = /* @__PURE__ */ K({
|
|
925
931
|
__name: "StoryblokRichText",
|
|
926
932
|
props: {
|
|
927
933
|
doc: {},
|
|
@@ -929,67 +935,67 @@ const Me = /* @__PURE__ */ q({
|
|
|
929
935
|
},
|
|
930
936
|
setup(s) {
|
|
931
937
|
const e = s, t = x(), o = () => t.value;
|
|
932
|
-
return
|
|
933
|
-
const { render:
|
|
938
|
+
return fe([() => e.doc, () => e.resolvers], ([r, n]) => {
|
|
939
|
+
const { render: a } = Me({
|
|
934
940
|
resolvers: n ?? {}
|
|
935
941
|
});
|
|
936
|
-
t.value =
|
|
942
|
+
t.value = a(r);
|
|
937
943
|
}, {
|
|
938
944
|
immediate: !0,
|
|
939
945
|
deep: !0
|
|
940
|
-
}), (r, n) => (
|
|
946
|
+
}), (r, n) => (W(), Y(o));
|
|
941
947
|
}
|
|
942
|
-
}),
|
|
948
|
+
}), Ve = {
|
|
943
949
|
beforeMount(s, e) {
|
|
944
950
|
if (e.value) {
|
|
945
|
-
const t =
|
|
951
|
+
const t = He(e.value);
|
|
946
952
|
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
953
|
}
|
|
948
954
|
}
|
|
949
|
-
},
|
|
955
|
+
}, te = (s) => {
|
|
950
956
|
console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
951
957
|
`);
|
|
952
958
|
};
|
|
953
|
-
let
|
|
954
|
-
const
|
|
959
|
+
let I = null;
|
|
960
|
+
const Je = () => (I || te("useStoryblokApi"), I), Ke = async (s, e = {}, t = {}) => {
|
|
955
961
|
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 &&
|
|
962
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, ye(() => {
|
|
963
|
+
o.value && o.value.id && De(
|
|
958
964
|
o.value.id,
|
|
959
965
|
(r) => o.value = r,
|
|
960
966
|
t
|
|
961
967
|
);
|
|
962
|
-
}),
|
|
963
|
-
const { data: r } = await
|
|
968
|
+
}), I) {
|
|
969
|
+
const { data: r } = await I.get(
|
|
964
970
|
`cdn/stories/${s}`,
|
|
965
971
|
e
|
|
966
972
|
);
|
|
967
973
|
o.value = r.story;
|
|
968
974
|
} else
|
|
969
|
-
|
|
975
|
+
te("useStoryblok");
|
|
970
976
|
return o;
|
|
971
|
-
},
|
|
977
|
+
}, Ye = {
|
|
972
978
|
install(s, e = {}) {
|
|
973
|
-
s.directive("editable",
|
|
979
|
+
s.directive("editable", Ve), s.component("StoryblokComponent", ee), s.component("StoryblokRichText", Fe), e.enableFallbackComponent && !e.customFallbackComponent && s.component(
|
|
974
980
|
"FallbackComponent",
|
|
975
|
-
|
|
981
|
+
me(() => import("./FallbackComponent-Dky11gEu.js"))
|
|
976
982
|
);
|
|
977
|
-
const { storyblokApi: t } =
|
|
978
|
-
|
|
983
|
+
const { storyblokApi: t } = Ue(e);
|
|
984
|
+
I = t || null, s.provide("VueSDKOptions", e);
|
|
979
985
|
}
|
|
980
986
|
};
|
|
981
987
|
export {
|
|
982
988
|
g as BlockTypes,
|
|
983
989
|
$ as MarkTypes,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
990
|
+
ee as StoryblokComponent,
|
|
991
|
+
Fe as StoryblokRichText,
|
|
992
|
+
Ye as StoryblokVue,
|
|
993
|
+
Q as TextTypes,
|
|
994
|
+
Ge as apiPlugin,
|
|
995
|
+
qe as renderRichText,
|
|
996
|
+
Z as richTextResolver,
|
|
997
|
+
Ke as useStoryblok,
|
|
998
|
+
Je as useStoryblokApi,
|
|
999
|
+
De as useStoryblokBridge,
|
|
1000
|
+
Me as useStoryblokRichText
|
|
995
1001
|
};
|