@storyblok/vue 8.1.5 → 8.1.6
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 +25 -25
- package/dist/storyblok-vue.mjs +279 -261
- package/dist/types.d.ts +1 -1
- package/package.json +8 -8
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as G, ref as O, resolveDynamicComponent as N, inject as oe, openBlock as K, createBlock as J, mergeProps as ne, h as Y, createTextVNode as ie, watch as ae, onMounted as le, defineAsyncComponent as ce } from "vue";
|
|
2
2
|
let D = !1;
|
|
3
|
-
const z = [],
|
|
3
|
+
const z = [], he = (r) => new Promise((e, t) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
|
|
5
5
|
if (window.location === window.parent.location) {
|
|
6
6
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
@@ -13,53 +13,57 @@ const z = [], ue = (r) => new Promise((e, t) => {
|
|
|
13
13
|
z.forEach((n) => n()), D = !0, e(o);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var ue = Object.defineProperty, de = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
|
|
17
|
+
class pe extends Error {
|
|
18
|
+
constructor(e) {
|
|
19
|
+
super(e), this.name = "AbortError";
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
function ge(r, e, t) {
|
|
21
|
-
if (!
|
|
23
|
+
if (!Number.isFinite(e))
|
|
22
24
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
-
if (!
|
|
25
|
+
if (!Number.isFinite(t))
|
|
24
26
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
27
|
const s = [];
|
|
26
|
-
let o = [], n = 0;
|
|
27
|
-
const
|
|
28
|
+
let o = [], n = 0, i = !1;
|
|
29
|
+
const a = async () => {
|
|
28
30
|
n++;
|
|
29
|
-
const a = setTimeout(function() {
|
|
30
|
-
n--, s.length > 0 && i(), o = o.filter(function(u) {
|
|
31
|
-
return u !== a;
|
|
32
|
-
});
|
|
33
|
-
}, t);
|
|
34
|
-
o.indexOf(a) < 0 && o.push(a);
|
|
35
31
|
const h = s.shift();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
if (h)
|
|
33
|
+
try {
|
|
34
|
+
const d = await r(...h.args);
|
|
35
|
+
h.resolve(d);
|
|
36
|
+
} catch (d) {
|
|
37
|
+
h.reject(d);
|
|
38
|
+
}
|
|
39
|
+
const u = setTimeout(() => {
|
|
40
|
+
n--, s.length > 0 && a(), o = o.filter((d) => d !== u);
|
|
41
|
+
}, t);
|
|
42
|
+
o.includes(u) || o.push(u);
|
|
43
|
+
}, l = (...h) => i ? Promise.reject(
|
|
44
|
+
new Error(
|
|
45
|
+
"Throttled function is already aborted and not accepting new promises"
|
|
46
|
+
)
|
|
47
|
+
) : new Promise((u, d) => {
|
|
48
|
+
s.push({
|
|
49
|
+
resolve: u,
|
|
50
|
+
reject: d,
|
|
51
|
+
args: h
|
|
52
|
+
}), n < e && a();
|
|
53
|
+
});
|
|
54
|
+
return l.abort = () => {
|
|
55
|
+
i = !0, o.forEach(clearTimeout), o = [], s.forEach(
|
|
56
|
+
(h) => h.reject(() => new pe("Throttle function aborted"))
|
|
57
|
+
), s.length = 0;
|
|
54
58
|
}, l;
|
|
55
59
|
}
|
|
56
60
|
let A = class {
|
|
57
61
|
constructor() {
|
|
58
|
-
p(this, "isCDNUrl", (r = "") => r.
|
|
62
|
+
p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
|
|
59
63
|
...r,
|
|
60
64
|
per_page: e,
|
|
61
65
|
page: t
|
|
62
|
-
})), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) =>
|
|
66
|
+
})), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
|
|
63
67
|
const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
64
68
|
return this.arrayFrom(t, (o, n) => n * s + r);
|
|
65
69
|
}), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
|
|
@@ -69,16 +73,16 @@ let A = class {
|
|
|
69
73
|
">": ">",
|
|
70
74
|
'"': """,
|
|
71
75
|
"'": "'"
|
|
72
|
-
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
76
|
+
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
73
77
|
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* @method stringify
|
|
78
|
-
* @param {
|
|
79
|
-
* @param {
|
|
80
|
-
* @param {
|
|
81
|
-
* @return {
|
|
82
|
+
* @param {object} params
|
|
83
|
+
* @param {string} prefix
|
|
84
|
+
* @param {boolean} isArray
|
|
85
|
+
* @return {string} Stringified object
|
|
82
86
|
*/
|
|
83
87
|
stringify(r, e, t) {
|
|
84
88
|
const s = [];
|
|
@@ -86,19 +90,19 @@ let A = class {
|
|
|
86
90
|
if (!Object.prototype.hasOwnProperty.call(r, o))
|
|
87
91
|
continue;
|
|
88
92
|
const n = r[o], i = t ? "" : encodeURIComponent(o);
|
|
89
|
-
let
|
|
90
|
-
typeof n == "object" ?
|
|
93
|
+
let a;
|
|
94
|
+
typeof n == "object" ? a = this.stringify(
|
|
91
95
|
n,
|
|
92
|
-
e ? e + encodeURIComponent(
|
|
96
|
+
e ? e + encodeURIComponent(`[${i}]`) : i,
|
|
93
97
|
Array.isArray(n)
|
|
94
|
-
) :
|
|
98
|
+
) : a = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(a);
|
|
95
99
|
}
|
|
96
100
|
return s.join("&");
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
103
|
* @method getRegionURL
|
|
100
|
-
* @param {
|
|
101
|
-
* @return {
|
|
104
|
+
* @param {string} regionCode region code, could be eu, us, cn, ap or ca
|
|
105
|
+
* @return {string} The base URL of the region
|
|
102
106
|
*/
|
|
103
107
|
getRegionURL(r) {
|
|
104
108
|
const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
@@ -120,7 +124,7 @@ const me = function(r, e) {
|
|
|
120
124
|
const t = {};
|
|
121
125
|
for (const s in r) {
|
|
122
126
|
const o = r[s];
|
|
123
|
-
e.
|
|
127
|
+
e.includes(s) && o !== null && (t[s] = o);
|
|
124
128
|
}
|
|
125
129
|
return t;
|
|
126
130
|
}, fe = (r) => r === "email", ye = () => ({
|
|
@@ -141,14 +145,14 @@ const me = function(r, e) {
|
|
|
141
145
|
singleTag: "br"
|
|
142
146
|
}), Te = (r) => ({
|
|
143
147
|
tag: `h${r.attrs.level}`
|
|
144
|
-
}),
|
|
148
|
+
}), we = (r) => ({
|
|
145
149
|
singleTag: [
|
|
146
150
|
{
|
|
147
151
|
tag: "img",
|
|
148
152
|
attrs: me(r.attrs, ["src", "alt", "title"])
|
|
149
153
|
}
|
|
150
154
|
]
|
|
151
|
-
}),
|
|
155
|
+
}), Re = () => ({
|
|
152
156
|
tag: "li"
|
|
153
157
|
}), Se = () => ({
|
|
154
158
|
tag: "ol"
|
|
@@ -165,15 +169,15 @@ const me = function(r, e) {
|
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
]
|
|
168
|
-
}), xe = () => ({
|
|
169
|
-
tag: "b"
|
|
170
172
|
}), je = () => ({
|
|
171
|
-
tag: "
|
|
173
|
+
tag: "b"
|
|
172
174
|
}), Ie = () => ({
|
|
175
|
+
tag: "s"
|
|
176
|
+
}), xe = () => ({
|
|
173
177
|
tag: "u"
|
|
174
|
-
}), Oe = () => ({
|
|
175
|
-
tag: "strong"
|
|
176
178
|
}), Ce = () => ({
|
|
179
|
+
tag: "strong"
|
|
180
|
+
}), Oe = () => ({
|
|
177
181
|
tag: "code"
|
|
178
182
|
}), Ae = () => ({
|
|
179
183
|
tag: "i"
|
|
@@ -250,18 +254,18 @@ const me = function(r, e) {
|
|
|
250
254
|
code_block: ve,
|
|
251
255
|
hard_break: $e,
|
|
252
256
|
heading: Te,
|
|
253
|
-
image:
|
|
254
|
-
list_item:
|
|
257
|
+
image: we,
|
|
258
|
+
list_item: Re,
|
|
255
259
|
ordered_list: Se,
|
|
256
260
|
paragraph: _e,
|
|
257
261
|
emoji: Ee
|
|
258
262
|
},
|
|
259
263
|
marks: {
|
|
260
|
-
bold:
|
|
261
|
-
strike:
|
|
262
|
-
underline:
|
|
263
|
-
strong:
|
|
264
|
-
code:
|
|
264
|
+
bold: je,
|
|
265
|
+
strike: Ie,
|
|
266
|
+
underline: xe,
|
|
267
|
+
strong: Ce,
|
|
268
|
+
code: Oe,
|
|
265
269
|
italic: Ae,
|
|
266
270
|
link: Le,
|
|
267
271
|
styled: Pe,
|
|
@@ -278,10 +282,10 @@ const me = function(r, e) {
|
|
|
278
282
|
">": ">",
|
|
279
283
|
'"': """,
|
|
280
284
|
"'": "'"
|
|
281
|
-
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
285
|
+
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
282
286
|
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
283
287
|
};
|
|
284
|
-
let
|
|
288
|
+
let B = !1;
|
|
285
289
|
class qe {
|
|
286
290
|
constructor(e) {
|
|
287
291
|
p(this, "marks"), p(this, "nodes"), e || (e = ze), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
@@ -293,9 +297,9 @@ class qe {
|
|
|
293
297
|
this.marks[e] = t;
|
|
294
298
|
}
|
|
295
299
|
render(e, t = { optimizeImages: !1 }, s = !0) {
|
|
296
|
-
if (!
|
|
300
|
+
if (!B && s && (console.warn(
|
|
297
301
|
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
|
298
|
-
),
|
|
302
|
+
), B = !0), e && e.content && Array.isArray(e.content)) {
|
|
299
303
|
let o = "";
|
|
300
304
|
return e.content.forEach((n) => {
|
|
301
305
|
o += this.renderNode(n);
|
|
@@ -303,42 +307,42 @@ class qe {
|
|
|
303
307
|
}
|
|
304
308
|
return console.warn(
|
|
305
309
|
`The render method must receive an Object with a "content" field.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
310
|
+
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
311
|
+
ISbRichtext:
|
|
312
|
+
content?: ISbRichtext[]
|
|
313
|
+
marks?: ISbRichtext[]
|
|
314
|
+
attrs?: any
|
|
315
|
+
text?: string
|
|
316
|
+
type: string
|
|
317
|
+
|
|
318
|
+
Example:
|
|
319
|
+
{
|
|
320
|
+
content: [
|
|
321
|
+
{
|
|
322
|
+
content: [
|
|
323
|
+
{
|
|
324
|
+
text: 'Hello World',
|
|
325
|
+
type: 'text'
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
type: 'paragraph'
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
type: 'doc'
|
|
332
|
+
}`
|
|
329
333
|
), "";
|
|
330
334
|
}
|
|
331
335
|
optimizeImages(e, t) {
|
|
332
336
|
let s = 0, o = 0, n = "", i = "";
|
|
333
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-
|
|
334
|
-
const
|
|
337
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
|
338
|
+
const a = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
|
|
335
339
|
return e = e.replace(
|
|
336
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|
|
|
337
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
338
|
-
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (
|
|
340
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
341
|
+
`a.storyblok.com/f/$1/$2.$3/m/${a}`
|
|
342
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (l) => {
|
|
339
343
|
var h, u;
|
|
340
|
-
const d =
|
|
341
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|
|
|
344
|
+
const d = l.match(
|
|
345
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
342
346
|
);
|
|
343
347
|
if (d && d.length > 0) {
|
|
344
348
|
const g = {
|
|
@@ -346,16 +350,17 @@ class qe {
|
|
|
346
350
|
if (typeof y == "number")
|
|
347
351
|
return `//${d}/m/${y}x0${i} ${y}w`;
|
|
348
352
|
if (typeof y == "object" && y.length === 2) {
|
|
349
|
-
let w = 0,
|
|
350
|
-
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (
|
|
353
|
+
let w = 0, x = 0;
|
|
354
|
+
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (x = y[1]), `//${d}/m/${w}x${x}${i} ${w}w`;
|
|
351
355
|
}
|
|
356
|
+
return "";
|
|
352
357
|
}).join(", "),
|
|
353
358
|
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
|
354
359
|
};
|
|
355
|
-
let
|
|
356
|
-
return g.srcset && (
|
|
360
|
+
let R = "";
|
|
361
|
+
return g.srcset && (R += `srcset="${g.srcset}" `), g.sizes && (R += `sizes="${g.sizes}" `), l.replace(/<img/g, `<img ${R.trim()}`);
|
|
357
362
|
}
|
|
358
|
-
return
|
|
363
|
+
return l;
|
|
359
364
|
})), e;
|
|
360
365
|
}
|
|
361
366
|
renderNode(e) {
|
|
@@ -423,7 +428,7 @@ class qe {
|
|
|
423
428
|
}
|
|
424
429
|
}
|
|
425
430
|
const L = qe;
|
|
426
|
-
class
|
|
431
|
+
class Fe {
|
|
427
432
|
constructor(e) {
|
|
428
433
|
p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(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 = {};
|
|
429
434
|
}
|
|
@@ -462,31 +467,31 @@ class Ve {
|
|
|
462
467
|
async _methodHandler(e) {
|
|
463
468
|
let t = `${this.baseURL}${this.url}`, s = null;
|
|
464
469
|
if (e === "get") {
|
|
465
|
-
const
|
|
466
|
-
t = `${this.baseURL}${this.url}?${
|
|
470
|
+
const l = new A();
|
|
471
|
+
t = `${this.baseURL}${this.url}?${l.stringify(
|
|
467
472
|
this.parameters
|
|
468
473
|
)}`;
|
|
469
474
|
} else
|
|
470
475
|
s = JSON.stringify(this.parameters);
|
|
471
476
|
const o = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
472
|
-
let
|
|
473
|
-
this.timeout && (
|
|
477
|
+
let a;
|
|
478
|
+
this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
|
|
474
479
|
try {
|
|
475
|
-
const
|
|
480
|
+
const l = await this.fetch(`${o}`, {
|
|
476
481
|
method: e,
|
|
477
482
|
headers: this.headers,
|
|
478
483
|
body: s,
|
|
479
484
|
signal: i,
|
|
480
485
|
...this.fetchOptions
|
|
481
486
|
});
|
|
482
|
-
this.timeout && clearTimeout(
|
|
487
|
+
this.timeout && clearTimeout(a);
|
|
483
488
|
const h = await this._responseHandler(
|
|
484
|
-
|
|
489
|
+
l
|
|
485
490
|
);
|
|
486
491
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
|
|
487
|
-
} catch (
|
|
492
|
+
} catch (l) {
|
|
488
493
|
return {
|
|
489
|
-
message:
|
|
494
|
+
message: l
|
|
490
495
|
};
|
|
491
496
|
}
|
|
492
497
|
}
|
|
@@ -510,35 +515,39 @@ class Ve {
|
|
|
510
515
|
});
|
|
511
516
|
}
|
|
512
517
|
}
|
|
513
|
-
const
|
|
518
|
+
const Ve = Fe, q = "SB-Agent", M = {
|
|
514
519
|
defaultAgentName: "SB-JS-CLIENT",
|
|
515
520
|
defaultAgentVersion: "SB-Agent-Version",
|
|
516
521
|
packageVersion: "6.0.0"
|
|
517
522
|
};
|
|
518
|
-
let
|
|
523
|
+
let C = {};
|
|
519
524
|
const E = {};
|
|
520
525
|
class Ge {
|
|
521
526
|
/**
|
|
522
527
|
*
|
|
523
528
|
* @param config ISbConfig interface
|
|
524
|
-
* @param
|
|
529
|
+
* @param pEndpoint string, optional
|
|
525
530
|
*/
|
|
526
531
|
constructor(e, t) {
|
|
527
532
|
p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
|
|
528
533
|
let s = e.endpoint || t;
|
|
529
534
|
if (!s) {
|
|
530
|
-
const i = new A().getRegionURL,
|
|
531
|
-
e.oauthToken ? s = `${
|
|
535
|
+
const i = new A().getRegionURL, a = e.https === !1 ? "http" : "https";
|
|
536
|
+
e.oauthToken ? s = `${a}://${i(e.region)}/v1` : s = `${a}://${i(e.region)}/v2`;
|
|
532
537
|
}
|
|
533
538
|
const o = new Headers();
|
|
534
|
-
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i,
|
|
535
|
-
o.set(i,
|
|
536
|
-
}), o.has(
|
|
539
|
+
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, a]) => {
|
|
540
|
+
o.set(i, a);
|
|
541
|
+
}), o.has(q) || (o.set(q, M.defaultAgentName), o.set(
|
|
537
542
|
M.defaultAgentVersion,
|
|
538
543
|
M.packageVersion
|
|
539
544
|
));
|
|
540
545
|
let n = 5;
|
|
541
|
-
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(
|
|
546
|
+
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(
|
|
547
|
+
this.throttledRequest.bind(this),
|
|
548
|
+
n,
|
|
549
|
+
1e3
|
|
550
|
+
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ve({
|
|
542
551
|
baseURL: s,
|
|
543
552
|
timeout: e.timeout || 0,
|
|
544
553
|
headers: o,
|
|
@@ -575,32 +584,35 @@ class Ge {
|
|
|
575
584
|
return this.cacheResponse(o, n, void 0, s);
|
|
576
585
|
}
|
|
577
586
|
async getAll(e, t, s, o) {
|
|
578
|
-
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}
|
|
587
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), a = s ?? i.substring(i.lastIndexOf("/") + 1), l = 1, h = await this.makeRequest(
|
|
579
588
|
i,
|
|
580
589
|
t,
|
|
581
590
|
n,
|
|
582
|
-
|
|
591
|
+
l,
|
|
583
592
|
o
|
|
584
|
-
),
|
|
585
|
-
this.helpers.range(
|
|
586
|
-
(
|
|
587
|
-
);
|
|
588
|
-
return this.helpers.flatMap(
|
|
589
|
-
[u, ...g],
|
|
590
|
-
($) => Object.values($.data[a])
|
|
593
|
+
), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
|
|
594
|
+
this.helpers.range(l, u),
|
|
595
|
+
(g) => this.makeRequest(i, t, n, g + 1, o)
|
|
591
596
|
);
|
|
597
|
+
return this.helpers.flatMap([h, ...d], (g) => Object.values(g.data[a]));
|
|
592
598
|
}
|
|
593
599
|
post(e, t, s) {
|
|
594
600
|
const o = `/${e}`;
|
|
595
|
-
return Promise.resolve(
|
|
601
|
+
return Promise.resolve(
|
|
602
|
+
this.throttle("post", o, t, s)
|
|
603
|
+
);
|
|
596
604
|
}
|
|
597
605
|
put(e, t, s) {
|
|
598
606
|
const o = `/${e}`;
|
|
599
|
-
return Promise.resolve(
|
|
607
|
+
return Promise.resolve(
|
|
608
|
+
this.throttle("put", o, t, s)
|
|
609
|
+
);
|
|
600
610
|
}
|
|
601
611
|
delete(e, t, s) {
|
|
602
612
|
const o = `/${e}`;
|
|
603
|
-
return Promise.resolve(
|
|
613
|
+
return Promise.resolve(
|
|
614
|
+
this.throttle("delete", o, t, s)
|
|
615
|
+
);
|
|
604
616
|
}
|
|
605
617
|
getStories(e, t) {
|
|
606
618
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
@@ -622,7 +634,7 @@ class Ge {
|
|
|
622
634
|
}
|
|
623
635
|
_insertLinks(e, t, s) {
|
|
624
636
|
const o = e[t];
|
|
625
|
-
o && o.fieldtype
|
|
637
|
+
o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
|
|
626
638
|
}
|
|
627
639
|
/**
|
|
628
640
|
*
|
|
@@ -636,7 +648,7 @@ class Ge {
|
|
|
636
648
|
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
|
637
649
|
}
|
|
638
650
|
_insertRelations(e, t, s, o) {
|
|
639
|
-
s.
|
|
651
|
+
s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
|
|
640
652
|
}
|
|
641
653
|
iterateTree(e, t, s) {
|
|
642
654
|
const o = (n) => {
|
|
@@ -666,17 +678,17 @@ class Ge {
|
|
|
666
678
|
async resolveLinks(e, t, s) {
|
|
667
679
|
let o = [];
|
|
668
680
|
if (e.link_uuids) {
|
|
669
|
-
const n = e.link_uuids.length, i = [],
|
|
670
|
-
for (let
|
|
671
|
-
const h = Math.min(n,
|
|
672
|
-
i.push(e.link_uuids.slice(
|
|
681
|
+
const n = e.link_uuids.length, i = [], a = 50;
|
|
682
|
+
for (let l = 0; l < n; l += a) {
|
|
683
|
+
const h = Math.min(n, l + a);
|
|
684
|
+
i.push(e.link_uuids.slice(l, h));
|
|
673
685
|
}
|
|
674
|
-
for (let
|
|
686
|
+
for (let l = 0; l < i.length; l++)
|
|
675
687
|
(await this.getStories({
|
|
676
|
-
per_page:
|
|
688
|
+
per_page: a,
|
|
677
689
|
language: t.language,
|
|
678
690
|
version: t.version,
|
|
679
|
-
by_uuids: i[
|
|
691
|
+
by_uuids: i[l].join(",")
|
|
680
692
|
})).data.stories.forEach(
|
|
681
693
|
(h) => {
|
|
682
694
|
o.push(h);
|
|
@@ -694,17 +706,17 @@ class Ge {
|
|
|
694
706
|
async resolveRelations(e, t, s) {
|
|
695
707
|
let o = [];
|
|
696
708
|
if (e.rel_uuids) {
|
|
697
|
-
const n = e.rel_uuids.length, i = [],
|
|
698
|
-
for (let
|
|
699
|
-
const h = Math.min(n,
|
|
700
|
-
i.push(e.rel_uuids.slice(
|
|
709
|
+
const n = e.rel_uuids.length, i = [], a = 50;
|
|
710
|
+
for (let l = 0; l < n; l += a) {
|
|
711
|
+
const h = Math.min(n, l + a);
|
|
712
|
+
i.push(e.rel_uuids.slice(l, h));
|
|
701
713
|
}
|
|
702
|
-
for (let
|
|
714
|
+
for (let l = 0; l < i.length; l++)
|
|
703
715
|
(await this.getStories({
|
|
704
|
-
per_page:
|
|
716
|
+
per_page: a,
|
|
705
717
|
language: t.language,
|
|
706
718
|
version: t.version,
|
|
707
|
-
by_uuids: i[
|
|
719
|
+
by_uuids: i[l].join(","),
|
|
708
720
|
excluding_fields: t.excluding_fields
|
|
709
721
|
})).data.stories.forEach((h) => {
|
|
710
722
|
o.push(h);
|
|
@@ -730,45 +742,50 @@ class Ge {
|
|
|
730
742
|
async resolveStories(e, t, s) {
|
|
731
743
|
var o, n;
|
|
732
744
|
let i = [];
|
|
733
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].
|
|
734
|
-
for (const
|
|
745
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
746
|
+
for (const a in this.relations[s])
|
|
735
747
|
this.iterateTree(
|
|
736
|
-
this.relations[s][
|
|
748
|
+
this.relations[s][a],
|
|
737
749
|
i,
|
|
738
750
|
s
|
|
739
751
|
);
|
|
740
|
-
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((
|
|
741
|
-
this.iterateTree(
|
|
752
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((a) => {
|
|
753
|
+
this.iterateTree(a, i, s);
|
|
742
754
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
743
755
|
}
|
|
744
756
|
async cacheResponse(e, t, s, o) {
|
|
745
757
|
const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
746
|
-
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
749
|
-
return Promise.resolve(
|
|
758
|
+
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
|
|
759
|
+
const a = await i.get(n);
|
|
760
|
+
if (a)
|
|
761
|
+
return Promise.resolve(a);
|
|
750
762
|
}
|
|
751
|
-
return new Promise(async (
|
|
763
|
+
return new Promise(async (a, l) => {
|
|
752
764
|
var h;
|
|
753
765
|
try {
|
|
754
|
-
const u = await this.throttle(
|
|
766
|
+
const u = await this.throttle(
|
|
767
|
+
"get",
|
|
768
|
+
e,
|
|
769
|
+
t,
|
|
770
|
+
o
|
|
771
|
+
);
|
|
755
772
|
if (u.status !== 200)
|
|
756
|
-
return
|
|
773
|
+
return l(u);
|
|
757
774
|
let d = { data: u.data, headers: u.headers };
|
|
758
775
|
if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
|
|
759
|
-
perPage: u.headers["per-page"] ? parseInt(u.headers["per-page"]) : 0,
|
|
760
|
-
total: u.headers["per-page"] ? parseInt(u.headers.total) : 0
|
|
776
|
+
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
|
777
|
+
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
|
761
778
|
})), d.data.story || d.data.stories) {
|
|
762
779
|
const g = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
763
780
|
await this.resolveStories(d.data, t, `${g}`);
|
|
764
781
|
}
|
|
765
|
-
return t.version === "published" && e
|
|
782
|
+
return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), a(d);
|
|
766
783
|
} catch (u) {
|
|
767
784
|
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
768
785
|
return console.log(
|
|
769
786
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
770
|
-
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(
|
|
771
|
-
|
|
787
|
+
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(a).catch(l);
|
|
788
|
+
l(u);
|
|
772
789
|
}
|
|
773
790
|
});
|
|
774
791
|
}
|
|
@@ -792,20 +809,21 @@ class Ge {
|
|
|
792
809
|
case "memory":
|
|
793
810
|
return {
|
|
794
811
|
get(e) {
|
|
795
|
-
return Promise.resolve(
|
|
812
|
+
return Promise.resolve(C[e]);
|
|
796
813
|
},
|
|
797
814
|
getAll() {
|
|
798
|
-
return Promise.resolve(
|
|
815
|
+
return Promise.resolve(C);
|
|
799
816
|
},
|
|
800
817
|
set(e, t) {
|
|
801
|
-
return
|
|
818
|
+
return C[e] = t, Promise.resolve(void 0);
|
|
802
819
|
},
|
|
803
820
|
flush() {
|
|
804
|
-
return
|
|
821
|
+
return C = {}, Promise.resolve(void 0);
|
|
805
822
|
}
|
|
806
823
|
};
|
|
807
824
|
case "custom":
|
|
808
|
-
if (this.cache.custom)
|
|
825
|
+
if (this.cache.custom)
|
|
826
|
+
return this.cache.custom;
|
|
809
827
|
default:
|
|
810
828
|
return {
|
|
811
829
|
get() {
|
|
@@ -856,19 +874,19 @@ function Je(r, e) {
|
|
|
856
874
|
return { src: r, attrs: {} };
|
|
857
875
|
let t = 0, s = 0;
|
|
858
876
|
const o = {}, n = [];
|
|
859
|
-
function i(
|
|
860
|
-
typeof
|
|
877
|
+
function i(l, h, u, d, g) {
|
|
878
|
+
typeof l != "number" || l <= h || l >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${l})`);
|
|
861
879
|
}
|
|
862
880
|
if (typeof e == "object") {
|
|
863
881
|
if (typeof e.width == "number" && e.width > 0 ? (o.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 ? (o.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
|
|
864
|
-
const { filters:
|
|
865
|
-
h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`),
|
|
882
|
+
const { filters: l } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: R, quality: y, rotate: w } = l || {};
|
|
883
|
+
h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
|
|
866
884
|
}
|
|
867
|
-
e.srcset && (o.srcset = e.srcset.map((
|
|
868
|
-
if (typeof
|
|
869
|
-
return `${r}/m/${
|
|
870
|
-
if (Array.isArray(
|
|
871
|
-
const [h, u] =
|
|
885
|
+
e.srcset && (o.srcset = e.srcset.map((l) => {
|
|
886
|
+
if (typeof l == "number")
|
|
887
|
+
return `${r}/m/${l}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${l}w`;
|
|
888
|
+
if (Array.isArray(l) && l.length === 2) {
|
|
889
|
+
const [h, u] = l;
|
|
872
890
|
return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
873
891
|
} else {
|
|
874
892
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
@@ -876,13 +894,13 @@ function Je(r, e) {
|
|
|
876
894
|
}
|
|
877
895
|
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
878
896
|
}
|
|
879
|
-
let
|
|
880
|
-
return t > 0 && s > 0 && (
|
|
881
|
-
src:
|
|
897
|
+
let a = `${r}/m/`;
|
|
898
|
+
return t > 0 && s > 0 && (a = `${a}${t}x${s}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
|
|
899
|
+
src: a,
|
|
882
900
|
attrs: o
|
|
883
901
|
};
|
|
884
902
|
}
|
|
885
|
-
var k = /* @__PURE__ */ ((r) => (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))(k || {}), v = /* @__PURE__ */ ((r) => (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))(v || {}),
|
|
903
|
+
var k = /* @__PURE__ */ ((r) => (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))(k || {}), v = /* @__PURE__ */ ((r) => (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))(v || {}), X = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(X || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
|
|
886
904
|
const Ye = [
|
|
887
905
|
"area",
|
|
888
906
|
"base",
|
|
@@ -915,37 +933,37 @@ function et(r = {}) {
|
|
|
915
933
|
resolvers: o = {},
|
|
916
934
|
optimizeImages: n = !1,
|
|
917
935
|
keyedResolvers: i = !1
|
|
918
|
-
} = r,
|
|
936
|
+
} = r, a = (c) => (m) => {
|
|
919
937
|
const f = m.attrs || {};
|
|
920
938
|
return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
|
|
921
|
-
},
|
|
922
|
-
const { src: m, alt: f, title: b, srcset:
|
|
939
|
+
}, l = (c) => {
|
|
940
|
+
const { src: m, alt: f, title: b, srcset: T, sizes: $ } = c.attrs || {};
|
|
923
941
|
let S = m, _ = {};
|
|
924
942
|
if (n) {
|
|
925
|
-
const { src:
|
|
926
|
-
S =
|
|
943
|
+
const { src: re, attrs: se } = Je(m, n);
|
|
944
|
+
S = re, _ = se;
|
|
927
945
|
}
|
|
928
946
|
i && (_ = {
|
|
929
947
|
..._,
|
|
930
948
|
key: `img-${e}`
|
|
931
949
|
});
|
|
932
|
-
const
|
|
950
|
+
const te = {
|
|
933
951
|
src: S,
|
|
934
952
|
alt: f,
|
|
935
953
|
title: b,
|
|
936
|
-
srcset:
|
|
937
|
-
sizes:
|
|
954
|
+
srcset: T,
|
|
955
|
+
sizes: $,
|
|
938
956
|
..._
|
|
939
957
|
};
|
|
940
|
-
return t("img", F(
|
|
958
|
+
return t("img", F(te));
|
|
941
959
|
}, h = (c) => {
|
|
942
960
|
const { level: m, ...f } = c.attrs || {}, b = {
|
|
943
961
|
...f
|
|
944
962
|
};
|
|
945
963
|
return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
|
|
946
964
|
}, u = (c) => {
|
|
947
|
-
var m, f, b,
|
|
948
|
-
const
|
|
965
|
+
var m, f, b, T;
|
|
966
|
+
const $ = t("img", {
|
|
949
967
|
src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
|
|
950
968
|
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
951
969
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
@@ -954,44 +972,44 @@ function et(r = {}) {
|
|
|
954
972
|
}), S = {
|
|
955
973
|
"data-type": "emoji",
|
|
956
974
|
"data-name": (b = c.attrs) == null ? void 0 : b.name,
|
|
957
|
-
"data-emoji": (
|
|
975
|
+
"data-emoji": (T = c.attrs) == null ? void 0 : T.emoji
|
|
958
976
|
};
|
|
959
|
-
return i && (S.key = `emoji-${e}`), t("span", S,
|
|
977
|
+
return i && (S.key = `emoji-${e}`), t("span", S, $);
|
|
960
978
|
}, d = (c) => t("pre", {
|
|
961
979
|
...c.attrs,
|
|
962
980
|
key: `code-${e}`
|
|
963
981
|
}, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
|
|
964
|
-
const { class:
|
|
965
|
-
class:
|
|
966
|
-
id:
|
|
982
|
+
const { class: T, id: $, ...S } = b || {}, _ = m ? {
|
|
983
|
+
class: T,
|
|
984
|
+
id: $,
|
|
967
985
|
style: We(S) || void 0
|
|
968
986
|
} : b || {};
|
|
969
987
|
return i && (_.key = `${c}-${e}`), t(c, F(_), f);
|
|
970
|
-
},
|
|
988
|
+
}, R = (c) => P(c), y = (c) => {
|
|
971
989
|
const { marks: m, ...f } = c;
|
|
972
990
|
return "text" in c ? m ? m.reduce(
|
|
973
|
-
(b,
|
|
991
|
+
(b, T) => R({ ...T, text: b }),
|
|
974
992
|
// Fix: Ensure render function returns a string
|
|
975
|
-
|
|
993
|
+
R({ ...f, children: f.children })
|
|
976
994
|
// Fix: Cast children to string
|
|
977
995
|
) : s(f.text) : "";
|
|
978
996
|
}, w = (c) => {
|
|
979
|
-
const { linktype: m, href: f, anchor: b, ...
|
|
980
|
-
let
|
|
997
|
+
const { linktype: m, href: f, anchor: b, ...T } = c.attrs || {};
|
|
998
|
+
let $ = "";
|
|
981
999
|
switch (m) {
|
|
982
|
-
case
|
|
983
|
-
case
|
|
984
|
-
|
|
1000
|
+
case j.ASSET:
|
|
1001
|
+
case j.URL:
|
|
1002
|
+
$ = f;
|
|
985
1003
|
break;
|
|
986
|
-
case
|
|
987
|
-
|
|
1004
|
+
case j.EMAIL:
|
|
1005
|
+
$ = `mailto:${f}`;
|
|
988
1006
|
break;
|
|
989
|
-
case
|
|
990
|
-
|
|
1007
|
+
case j.STORY:
|
|
1008
|
+
$ = f;
|
|
991
1009
|
break;
|
|
992
1010
|
}
|
|
993
|
-
return b && (
|
|
994
|
-
},
|
|
1011
|
+
return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
|
|
1012
|
+
}, x = (c) => {
|
|
995
1013
|
var m, f;
|
|
996
1014
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
997
1015
|
blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
|
|
@@ -999,21 +1017,21 @@ function et(r = {}) {
|
|
|
999
1017
|
key: `component-${e}`,
|
|
1000
1018
|
style: "display: none"
|
|
1001
1019
|
});
|
|
1002
|
-
},
|
|
1003
|
-
[k.DOCUMENT,
|
|
1020
|
+
}, ee = new Map([
|
|
1021
|
+
[k.DOCUMENT, a("div")],
|
|
1004
1022
|
[k.HEADING, h],
|
|
1005
|
-
[k.PARAGRAPH,
|
|
1006
|
-
[k.UL_LIST,
|
|
1007
|
-
[k.OL_LIST,
|
|
1008
|
-
[k.LIST_ITEM,
|
|
1009
|
-
[k.IMAGE,
|
|
1023
|
+
[k.PARAGRAPH, a("p")],
|
|
1024
|
+
[k.UL_LIST, a("ul")],
|
|
1025
|
+
[k.OL_LIST, a("ol")],
|
|
1026
|
+
[k.LIST_ITEM, a("li")],
|
|
1027
|
+
[k.IMAGE, l],
|
|
1010
1028
|
[k.EMOJI, u],
|
|
1011
1029
|
[k.CODE_BLOCK, d],
|
|
1012
|
-
[k.HR,
|
|
1013
|
-
[k.BR,
|
|
1014
|
-
[k.QUOTE,
|
|
1015
|
-
[k.COMPONENT,
|
|
1016
|
-
[
|
|
1030
|
+
[k.HR, a("hr")],
|
|
1031
|
+
[k.BR, a("br")],
|
|
1032
|
+
[k.QUOTE, a("blockquote")],
|
|
1033
|
+
[k.COMPONENT, x],
|
|
1034
|
+
[X.TEXT, y],
|
|
1017
1035
|
[v.LINK, w],
|
|
1018
1036
|
[v.ANCHOR, w],
|
|
1019
1037
|
[v.STYLED, g("span", !0)],
|
|
@@ -1030,7 +1048,7 @@ function et(r = {}) {
|
|
|
1030
1048
|
]);
|
|
1031
1049
|
function U(c) {
|
|
1032
1050
|
e += 1;
|
|
1033
|
-
const m =
|
|
1051
|
+
const m = ee.get(c.type);
|
|
1034
1052
|
if (!m)
|
|
1035
1053
|
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
1036
1054
|
if (c.type === "text")
|
|
@@ -1049,7 +1067,7 @@ function et(r = {}) {
|
|
|
1049
1067
|
render: P
|
|
1050
1068
|
};
|
|
1051
1069
|
}
|
|
1052
|
-
let H,
|
|
1070
|
+
let H, V = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1053
1071
|
const tt = (r, e, t = {}) => {
|
|
1054
1072
|
var s;
|
|
1055
1073
|
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
@@ -1073,18 +1091,18 @@ const tt = (r, e, t = {}) => {
|
|
|
1073
1091
|
accessToken: o,
|
|
1074
1092
|
use: n = [],
|
|
1075
1093
|
apiOptions: i = {},
|
|
1076
|
-
richText:
|
|
1077
|
-
bridgeUrl:
|
|
1094
|
+
richText: a = {},
|
|
1095
|
+
bridgeUrl: l
|
|
1078
1096
|
} = r;
|
|
1079
1097
|
i.accessToken = i.accessToken || o;
|
|
1080
1098
|
const h = { bridge: s, apiOptions: i };
|
|
1081
1099
|
let u = {};
|
|
1082
1100
|
n.forEach((g) => {
|
|
1083
1101
|
u = { ...u, ...g(h) };
|
|
1084
|
-
}),
|
|
1102
|
+
}), l && (V = l);
|
|
1085
1103
|
const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1086
|
-
return s !== !1 && d &&
|
|
1087
|
-
},
|
|
1104
|
+
return s !== !1 && d && he(V), H = new L(a.schema), a.resolver && W(H, a.resolver), u;
|
|
1105
|
+
}, W = (r, e) => {
|
|
1088
1106
|
r.addNode("blok", (t) => {
|
|
1089
1107
|
let s = "";
|
|
1090
1108
|
return t.attrs.body.forEach((o) => {
|
|
@@ -1101,31 +1119,31 @@ const tt = (r, e, t = {}) => {
|
|
|
1101
1119
|
);
|
|
1102
1120
|
return;
|
|
1103
1121
|
}
|
|
1104
|
-
return st(r) ? "" : (e && (s = new L(e.schema), e.resolver &&
|
|
1105
|
-
},
|
|
1122
|
+
return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && W(s, e.resolver)), s.render(r, {}, !1));
|
|
1123
|
+
}, Q = /* @__PURE__ */ G({
|
|
1106
1124
|
__name: "StoryblokComponent",
|
|
1107
1125
|
props: {
|
|
1108
1126
|
blok: {}
|
|
1109
1127
|
},
|
|
1110
1128
|
setup(r, { expose: e }) {
|
|
1111
|
-
const t = r, s =
|
|
1129
|
+
const t = r, s = O();
|
|
1112
1130
|
e({
|
|
1113
1131
|
value: s
|
|
1114
1132
|
});
|
|
1115
|
-
const o = typeof N(t.blok.component) != "string", n =
|
|
1133
|
+
const o = typeof N(t.blok.component) != "string", n = oe("VueSDKOptions"), i = O(t.blok.component);
|
|
1116
1134
|
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
|
|
1117
1135
|
`Is the Fallback component "${i.value}" registered properly?`
|
|
1118
1136
|
)) : console.error(
|
|
1119
1137
|
`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});"?`
|
|
1120
|
-
)), (
|
|
1138
|
+
)), (a, l) => (K(), J(N(i.value), ne({
|
|
1121
1139
|
ref_key: "blokRef",
|
|
1122
1140
|
ref: s
|
|
1123
|
-
}, { ...
|
|
1141
|
+
}, { ...a.$props, ...a.$attrs }), null, 16));
|
|
1124
1142
|
}
|
|
1125
1143
|
}), ot = (r) => {
|
|
1126
1144
|
var e, t;
|
|
1127
|
-
return
|
|
1128
|
-
|
|
1145
|
+
return Y(
|
|
1146
|
+
Q,
|
|
1129
1147
|
{
|
|
1130
1148
|
blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
|
|
1131
1149
|
id: (t = r.attrs) == null ? void 0 : t.id
|
|
@@ -1135,8 +1153,8 @@ const tt = (r, e, t = {}) => {
|
|
|
1135
1153
|
};
|
|
1136
1154
|
function nt(r) {
|
|
1137
1155
|
const e = {
|
|
1138
|
-
renderFn:
|
|
1139
|
-
textFn:
|
|
1156
|
+
renderFn: Y,
|
|
1157
|
+
textFn: ie,
|
|
1140
1158
|
keyedResolvers: !0,
|
|
1141
1159
|
resolvers: {
|
|
1142
1160
|
[k.COMPONENT]: ot,
|
|
@@ -1145,15 +1163,15 @@ function nt(r) {
|
|
|
1145
1163
|
};
|
|
1146
1164
|
return et(e);
|
|
1147
1165
|
}
|
|
1148
|
-
const it = /* @__PURE__ */
|
|
1166
|
+
const it = /* @__PURE__ */ G({
|
|
1149
1167
|
__name: "StoryblokRichText",
|
|
1150
1168
|
props: {
|
|
1151
1169
|
doc: {},
|
|
1152
1170
|
resolvers: {}
|
|
1153
1171
|
},
|
|
1154
1172
|
setup(r) {
|
|
1155
|
-
const e = r, t =
|
|
1156
|
-
return
|
|
1173
|
+
const e = r, t = O(), s = () => t.value;
|
|
1174
|
+
return ae(
|
|
1157
1175
|
[e.doc, e.resolvers],
|
|
1158
1176
|
([o, n]) => {
|
|
1159
1177
|
const { render: i } = nt({
|
|
@@ -1164,7 +1182,7 @@ const it = /* @__PURE__ */ K({
|
|
|
1164
1182
|
{
|
|
1165
1183
|
immediate: !0
|
|
1166
1184
|
}
|
|
1167
|
-
), (o, n) => (
|
|
1185
|
+
), (o, n) => (K(), J(s));
|
|
1168
1186
|
}
|
|
1169
1187
|
}), at = {
|
|
1170
1188
|
beforeMount(r, e) {
|
|
@@ -1173,35 +1191,35 @@ const it = /* @__PURE__ */ K({
|
|
|
1173
1191
|
Object.keys(t).length > 0 && (r.setAttribute("data-blok-c", t["data-blok-c"]), r.setAttribute("data-blok-uid", t["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
1174
1192
|
}
|
|
1175
1193
|
}
|
|
1176
|
-
},
|
|
1194
|
+
}, Z = (r) => {
|
|
1177
1195
|
console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1178
1196
|
`);
|
|
1179
1197
|
};
|
|
1180
|
-
let
|
|
1181
|
-
const ut = () => (
|
|
1182
|
-
const s =
|
|
1183
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
1198
|
+
let I = null;
|
|
1199
|
+
const ut = () => (I || Z("useStoryblokApi"), I), dt = async (r, e = {}, t = {}) => {
|
|
1200
|
+
const s = O(null);
|
|
1201
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, le(() => {
|
|
1184
1202
|
s.value && s.value.id && tt(
|
|
1185
1203
|
s.value.id,
|
|
1186
1204
|
(o) => s.value = o,
|
|
1187
1205
|
t
|
|
1188
1206
|
);
|
|
1189
|
-
}),
|
|
1190
|
-
const { data: o } = await
|
|
1207
|
+
}), I) {
|
|
1208
|
+
const { data: o } = await I.get(
|
|
1191
1209
|
`cdn/stories/${r}`,
|
|
1192
1210
|
e
|
|
1193
1211
|
);
|
|
1194
1212
|
s.value = o.story;
|
|
1195
|
-
} else
|
|
1213
|
+
} else Z("useStoryblok");
|
|
1196
1214
|
return s;
|
|
1197
|
-
},
|
|
1215
|
+
}, pt = {
|
|
1198
1216
|
install(r, e = {}) {
|
|
1199
|
-
r.directive("editable", at), r.component("StoryblokComponent",
|
|
1217
|
+
r.directive("editable", at), r.component("StoryblokComponent", Q), r.component("StoryblokRichText", it), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
|
|
1200
1218
|
"FallbackComponent",
|
|
1201
|
-
|
|
1219
|
+
ce(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
|
|
1202
1220
|
);
|
|
1203
1221
|
const { storyblokApi: t } = rt(e);
|
|
1204
|
-
|
|
1222
|
+
I = t, r.provide("VueSDKOptions", e);
|
|
1205
1223
|
}
|
|
1206
1224
|
};
|
|
1207
1225
|
export {
|
|
@@ -1209,14 +1227,14 @@ export {
|
|
|
1209
1227
|
v as MarkTypes,
|
|
1210
1228
|
L as RichTextResolver,
|
|
1211
1229
|
ze as RichTextSchema,
|
|
1212
|
-
|
|
1230
|
+
Q as StoryblokComponent,
|
|
1213
1231
|
it as StoryblokRichText,
|
|
1214
|
-
|
|
1215
|
-
|
|
1232
|
+
pt as StoryblokVue,
|
|
1233
|
+
X as TextTypes,
|
|
1216
1234
|
ct as apiPlugin,
|
|
1217
1235
|
ht as renderRichText,
|
|
1218
1236
|
et as richTextResolver,
|
|
1219
|
-
|
|
1237
|
+
dt as useStoryblok,
|
|
1220
1238
|
ut as useStoryblokApi,
|
|
1221
1239
|
tt as useStoryblokBridge,
|
|
1222
1240
|
nt as useStoryblokRichText
|