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