@storyblok/astro 7.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/helpers.d.ts +1 -1
- package/dist/storyblok-astro.es.js +186 -174
- package/dist/storyblok-astro.umd.js +9 -9
- package/package.json +42 -59
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ISbStoryData, StoryblokBridgeConfigV2, StoryblokClient } from '../types';
|
|
2
2
|
import { AstroGlobal } from 'astro';
|
|
3
3
|
export declare function useStoryblokApi(): StoryblokClient;
|
|
4
|
-
export declare function getLiveStory(Astro: Readonly<AstroGlobal>): Promise<ISbStoryData<import('
|
|
4
|
+
export declare function getLiveStory(Astro: Readonly<AstroGlobal>): Promise<ISbStoryData<import('storyblok-js-client').ISbComponentType<string> & {
|
|
5
5
|
[index: string]: any;
|
|
6
6
|
}> | null>;
|
|
7
7
|
export declare function initStoryblokBridge(config: boolean | StoryblokBridgeConfigV2): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ee = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
2
2
|
<g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
3
3
|
<g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
|
|
4
4
|
<g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
|
|
@@ -7,15 +7,15 @@ const Q = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xml
|
|
|
7
7
|
</g>
|
|
8
8
|
</g>
|
|
9
9
|
</g>
|
|
10
|
-
</svg>`,
|
|
10
|
+
</svg>`, te = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, re = new RegExp("^" + O.source), N = new RegExp(O.source + G.source, "gu"), j = new RegExp("\\d+" + G.source, "gu"), se = (e, t, s, n) => {
|
|
11
11
|
let l = !1, r = !1, b = !1, p = !1;
|
|
12
|
-
for (let
|
|
13
|
-
const
|
|
14
|
-
p =
|
|
12
|
+
for (let i = 0; i < e.length; i++) {
|
|
13
|
+
const u = e[i];
|
|
14
|
+
p = i > 2 ? e[i - 3] === "-" : !0, l && te.test(u) ? (e = e.slice(0, i) + "-" + e.slice(i), l = !1, b = r, r = !0, i++) : r && b && oe.test(u) && (!p || n) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), b = r, r = !1, l = !0) : (l = t(u) === u && s(u) !== u, b = r, r = s(u) === u && t(u) !== u);
|
|
15
15
|
}
|
|
16
16
|
return e;
|
|
17
|
-
},
|
|
18
|
-
function
|
|
17
|
+
}, ne = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (s) => t(s))), le = (e, t) => (N.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (s, n, l) => ["_", "-"].includes(e.charAt(l + s.length)) ? s : t(s)).replaceAll(N, (s, n) => t(n)));
|
|
18
|
+
function ae(e, t) {
|
|
19
19
|
if (!(typeof e == "string" || Array.isArray(e)))
|
|
20
20
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
21
21
|
if (t = {
|
|
@@ -25,12 +25,12 @@ function le(e, t) {
|
|
|
25
25
|
}, Array.isArray(e) ? e = e.map((r) => r.trim()).filter((r) => r.length).join("-") : e = e.trim(), e.length === 0)
|
|
26
26
|
return "";
|
|
27
27
|
const s = t.locale === !1 ? (r) => r.toLowerCase() : (r) => r.toLocaleLowerCase(t.locale), n = t.locale === !1 ? (r) => r.toUpperCase() : (r) => r.toLocaleUpperCase(t.locale);
|
|
28
|
-
return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : s(e) : (e !== s(e) && (e =
|
|
28
|
+
return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : s(e) : (e !== s(e) && (e = se(e, s, n, t.preserveConsecutiveUppercase)), e = e.replace(re, ""), e = t.preserveConsecutiveUppercase ? ne(e, s) : s(e), t.pascalCase && (e = n(e.charAt(0)) + e.slice(1)), le(e, n));
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function P(e) {
|
|
31
|
+
return ae(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ie(e, t = {}, s, n) {
|
|
34
34
|
const l = "virtual:storyblok-components", r = `\0${l}`;
|
|
35
35
|
return {
|
|
36
36
|
name: "vite-plugin-storyblok-components",
|
|
@@ -40,23 +40,23 @@ function ae(e, t = {}, s, n) {
|
|
|
40
40
|
},
|
|
41
41
|
async load(b) {
|
|
42
42
|
if (b === r) {
|
|
43
|
-
const p = [],
|
|
44
|
-
for await (const [f,
|
|
45
|
-
const
|
|
46
|
-
`/${e}/${
|
|
43
|
+
const p = [], i = [];
|
|
44
|
+
for await (const [f, E] of Object.entries(t)) {
|
|
45
|
+
const L = await this.resolve(
|
|
46
|
+
`/${e}/${E}.astro`
|
|
47
47
|
);
|
|
48
|
-
if (
|
|
49
|
-
p.push(`import ${
|
|
48
|
+
if (L)
|
|
49
|
+
p.push(`import ${P(f)} from "${L.id}"`);
|
|
50
50
|
else if (s)
|
|
51
|
-
|
|
51
|
+
i.push(f);
|
|
52
52
|
else
|
|
53
53
|
throw new Error(
|
|
54
|
-
`Component could not be found for blok "${f}"! Does "${`/${e}/${
|
|
54
|
+
`Component could not be found for blok "${f}"! Does "${`/${e}/${E}`}.astro" exist?`
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
let
|
|
57
|
+
let u = "";
|
|
58
58
|
if (s)
|
|
59
|
-
if (
|
|
59
|
+
if (u = ",FallbackComponent", n) {
|
|
60
60
|
const f = await this.resolve(
|
|
61
61
|
`/${e}/${n}.astro`
|
|
62
62
|
);
|
|
@@ -72,9 +72,9 @@ function ae(e, t = {}, s, n) {
|
|
|
72
72
|
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
73
73
|
);
|
|
74
74
|
if (Object.values(t).length)
|
|
75
|
-
return `${p.join(";")};export default {${Object.keys(t).filter((f) => !
|
|
75
|
+
return `${p.join(";")};export default {${Object.keys(t).filter((f) => !i.includes(f)).map((f) => P(f)).join(",")}${u}}`;
|
|
76
76
|
if (s)
|
|
77
|
-
return `${p[0]}; export default {${
|
|
77
|
+
return `${p[0]}; export default {${u.replace(",", "")}}`;
|
|
78
78
|
throw new Error(
|
|
79
79
|
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
80
80
|
Please register your components or enable the fallback component.
|
|
@@ -84,7 +84,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function ce(e, t, s) {
|
|
88
88
|
const n = "virtual:storyblok-init", l = `\0${n}`;
|
|
89
89
|
return {
|
|
90
90
|
name: "vite-plugin-storyblok-init",
|
|
@@ -106,7 +106,7 @@ function ie(e, t, s) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function de(e) {
|
|
110
110
|
const t = "virtual:storyblok-options", s = `\0${t}`;
|
|
111
111
|
return {
|
|
112
112
|
name: "vite-plugin-storyblok-options",
|
|
@@ -129,7 +129,7 @@ async function Ee(e) {
|
|
|
129
129
|
let t = null;
|
|
130
130
|
return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ue(e) {
|
|
133
133
|
return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
|
|
134
134
|
}
|
|
135
135
|
function Le(e) {
|
|
@@ -140,7 +140,7 @@ function Le(e) {
|
|
|
140
140
|
enableFallbackComponent: !1,
|
|
141
141
|
livePreview: !1,
|
|
142
142
|
...e
|
|
143
|
-
}, s =
|
|
143
|
+
}, s = ue(t.bridge);
|
|
144
144
|
return {
|
|
145
145
|
name: "@storyblok/astro",
|
|
146
146
|
hooks: {
|
|
@@ -154,18 +154,18 @@ function Le(e) {
|
|
|
154
154
|
if (l({
|
|
155
155
|
vite: {
|
|
156
156
|
plugins: [
|
|
157
|
-
|
|
157
|
+
ce(
|
|
158
158
|
t.accessToken,
|
|
159
159
|
t.useCustomApi,
|
|
160
160
|
t.apiOptions
|
|
161
161
|
),
|
|
162
|
-
|
|
162
|
+
ie(
|
|
163
163
|
t.componentsDir,
|
|
164
164
|
t.components,
|
|
165
165
|
t.enableFallbackComponent,
|
|
166
166
|
t.customFallbackComponent
|
|
167
167
|
),
|
|
168
|
-
|
|
168
|
+
de(t)
|
|
169
169
|
]
|
|
170
170
|
}
|
|
171
171
|
}), t.livePreview && (p == null ? void 0 : p.output) !== "server")
|
|
@@ -206,29 +206,29 @@ function Le(e) {
|
|
|
206
206
|
})), r({
|
|
207
207
|
id: "storyblok",
|
|
208
208
|
name: "Storyblok",
|
|
209
|
-
icon:
|
|
209
|
+
icon: ee,
|
|
210
210
|
entrypoint: "@storyblok/astro/toolbarApp.ts"
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
let
|
|
216
|
+
let D;
|
|
217
217
|
async function $e(e) {
|
|
218
218
|
const { action: t, story: s } = e || {};
|
|
219
219
|
if (t === "input" && s) {
|
|
220
220
|
const n = async () => {
|
|
221
|
-
const r = await
|
|
221
|
+
const r = await be(s), b = document.body;
|
|
222
222
|
if (r.outerHTML === b.outerHTML)
|
|
223
223
|
return;
|
|
224
224
|
const p = document.querySelector('[data-blok-focused="true"]');
|
|
225
|
-
|
|
225
|
+
pe(b, r, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
|
|
226
226
|
};
|
|
227
|
-
clearTimeout(
|
|
227
|
+
clearTimeout(D), D = setTimeout(n, 500);
|
|
228
228
|
}
|
|
229
229
|
["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function pe(e, t, s) {
|
|
232
232
|
if (s) {
|
|
233
233
|
const n = s.getAttribute("data-blok-uid"), l = t.querySelector(
|
|
234
234
|
`[data-blok-uid="${n}"]`
|
|
@@ -237,7 +237,7 @@ function ue(e, t, s) {
|
|
|
237
237
|
} else
|
|
238
238
|
e.replaceWith(t);
|
|
239
239
|
}
|
|
240
|
-
async function
|
|
240
|
+
async function be(e) {
|
|
241
241
|
const s = await (await fetch(location.href, {
|
|
242
242
|
method: "POST",
|
|
243
243
|
body: JSON.stringify({
|
|
@@ -250,25 +250,25 @@ async function pe(e) {
|
|
|
250
250
|
})).text();
|
|
251
251
|
return new DOMParser().parseFromString(s, "text/html").body;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function fe(e, t) {
|
|
254
254
|
if (!t)
|
|
255
255
|
return { src: e, attrs: {} };
|
|
256
256
|
let s = 0, n = 0;
|
|
257
257
|
const l = {}, r = [];
|
|
258
|
-
function b(
|
|
259
|
-
typeof
|
|
258
|
+
function b(i, u, f, E, L) {
|
|
259
|
+
typeof i != "number" || i <= u || i >= f ? console.warn(`[StoryblokRichText] - ${E.charAt(0).toUpperCase() + E.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : L.push(`${E}(${i})`);
|
|
260
260
|
}
|
|
261
261
|
if (typeof t == "object") {
|
|
262
262
|
if (typeof t.width == "number" && t.width > 0 ? (l.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (l.height = t.height, n = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (l.loading = t.loading), t.class && (l.class = t.class), t.filters) {
|
|
263
|
-
const { filters:
|
|
264
|
-
|
|
263
|
+
const { filters: i } = t || {}, { blur: u, brightness: f, fill: E, format: L, grayscale: C, quality: $, rotate: T } = i || {};
|
|
264
|
+
u && b(u, 0, 100, "blur", r), $ && b($, 0, 100, "quality", r), f && b(f, 0, 100, "brightness", r), E && r.push(`fill(${E})`), C && r.push("grayscale()"), T && [0, 90, 180, 270].includes(t.filters.rotate || 0) && r.push(`rotate(${T})`), L && ["webp", "png", "jpeg"].includes(L) && r.push(`format(${L})`);
|
|
265
265
|
}
|
|
266
|
-
t.srcset && (l.srcset = t.srcset.map((
|
|
267
|
-
if (typeof
|
|
268
|
-
return `${e}/m/${
|
|
269
|
-
if (Array.isArray(
|
|
270
|
-
const [
|
|
271
|
-
return `${e}/m/${
|
|
266
|
+
t.srcset && (l.srcset = t.srcset.map((i) => {
|
|
267
|
+
if (typeof i == "number")
|
|
268
|
+
return `${e}/m/${i}x0/${r.length > 0 ? `filters:${r.join(":")}` : ""} ${i}w`;
|
|
269
|
+
if (Array.isArray(i) && i.length === 2) {
|
|
270
|
+
const [u, f] = i;
|
|
271
|
+
return `${e}/m/${u}x${f}/${r.length > 0 ? `filters:${r.join(":")}` : ""} ${u}w`;
|
|
272
272
|
} else {
|
|
273
273
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
274
274
|
return;
|
|
@@ -281,8 +281,8 @@ function be(e, t) {
|
|
|
281
281
|
attrs: l
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
var g = /* @__PURE__ */ ((e) => (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))(g || {}),
|
|
285
|
-
const
|
|
284
|
+
var g = /* @__PURE__ */ ((e) => (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))(g || {}), v = /* @__PURE__ */ ((e) => (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))(v || {}), z = /* @__PURE__ */ ((e) => (e.TEXT = "text", e))(z || {}), I = /* @__PURE__ */ ((e) => (e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e))(I || {});
|
|
285
|
+
const ye = [
|
|
286
286
|
"area",
|
|
287
287
|
"base",
|
|
288
288
|
"br",
|
|
@@ -297,59 +297,53 @@ const fe = [
|
|
|
297
297
|
"source",
|
|
298
298
|
"track",
|
|
299
299
|
"wbr"
|
|
300
|
-
],
|
|
301
|
-
function
|
|
300
|
+
], he = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), ge = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
|
301
|
+
function ke(e) {
|
|
302
302
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
303
303
|
}
|
|
304
|
-
const
|
|
305
|
-
function
|
|
306
|
-
const n =
|
|
304
|
+
const S = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
|
|
305
|
+
function U(e, t = {}, s) {
|
|
306
|
+
const n = he(t), l = n ? `${e} ${n}` : e, r = Array.isArray(s) ? s.join("") : s || "";
|
|
307
307
|
if (e) {
|
|
308
|
-
if (
|
|
308
|
+
if (ye.includes(e))
|
|
309
309
|
return `<${l}>`;
|
|
310
310
|
} else return r;
|
|
311
311
|
return `<${l}>${r}</${e}>`;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function me(e = {}) {
|
|
314
314
|
const t = /* @__PURE__ */ new Map(), {
|
|
315
|
-
renderFn: s =
|
|
316
|
-
textFn: n =
|
|
315
|
+
renderFn: s = U,
|
|
316
|
+
textFn: n = ke,
|
|
317
317
|
resolvers: l = {},
|
|
318
318
|
optimizeImages: r = !1,
|
|
319
319
|
keyedResolvers: b = !1
|
|
320
|
-
} = e, p = s !==
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
} }), d = (o) => (a, i) => {
|
|
327
|
-
const c = a.attrs || {};
|
|
328
|
-
return i.render(o, c, a.children || null);
|
|
329
|
-
}, f = (o, a) => {
|
|
330
|
-
const { src: i, alt: c, title: y, srcset: m, sizes: h } = o.attrs || {};
|
|
331
|
-
let k = i, w = {};
|
|
320
|
+
} = e, p = s !== U, i = (o) => (a, c) => {
|
|
321
|
+
const d = a.attrs || {};
|
|
322
|
+
return c.render(o, d, a.children || null);
|
|
323
|
+
}, u = (o, a) => {
|
|
324
|
+
const { src: c, alt: d, title: y, srcset: m, sizes: h } = o.attrs || {};
|
|
325
|
+
let k = c, w = {};
|
|
332
326
|
if (r) {
|
|
333
|
-
const { src:
|
|
334
|
-
k =
|
|
327
|
+
const { src: Z, attrs: Q } = fe(c, r);
|
|
328
|
+
k = Z, w = Q;
|
|
335
329
|
}
|
|
336
|
-
const
|
|
330
|
+
const X = {
|
|
337
331
|
src: k,
|
|
338
|
-
alt:
|
|
332
|
+
alt: d,
|
|
339
333
|
title: y,
|
|
340
334
|
srcset: m,
|
|
341
335
|
sizes: h,
|
|
342
336
|
...w
|
|
343
337
|
};
|
|
344
|
-
return a.render("img",
|
|
345
|
-
},
|
|
346
|
-
const { level:
|
|
347
|
-
return a.render(`h${
|
|
348
|
-
},
|
|
349
|
-
var
|
|
338
|
+
return a.render("img", S(X));
|
|
339
|
+
}, f = (o, a) => {
|
|
340
|
+
const { level: c, ...d } = o.attrs || {};
|
|
341
|
+
return a.render(`h${c}`, d, o.children);
|
|
342
|
+
}, E = (o, a) => {
|
|
343
|
+
var c, d, y, m;
|
|
350
344
|
const h = a.render("img", {
|
|
351
|
-
src: (
|
|
352
|
-
alt: (
|
|
345
|
+
src: (c = o.attrs) == null ? void 0 : c.fallbackImage,
|
|
346
|
+
alt: (d = o.attrs) == null ? void 0 : d.alt,
|
|
353
347
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
354
348
|
draggable: "false",
|
|
355
349
|
loading: "lazy"
|
|
@@ -359,148 +353,166 @@ function ke(e = {}) {
|
|
|
359
353
|
"data-name": (y = o.attrs) == null ? void 0 : y.name,
|
|
360
354
|
"data-emoji": (m = o.attrs) == null ? void 0 : m.emoji
|
|
361
355
|
}, h);
|
|
362
|
-
},
|
|
356
|
+
}, L = (o, a) => a.render(
|
|
363
357
|
"pre",
|
|
364
358
|
o.attrs || {},
|
|
365
359
|
a.render("code", {}, o.children || "")
|
|
366
|
-
), C = (o, a = !1) => ({ text:
|
|
367
|
-
const { class: m, id: h, ...k } =
|
|
360
|
+
), C = (o, a = !1) => ({ text: c, attrs: d }, y) => {
|
|
361
|
+
const { class: m, id: h, ...k } = d || {}, w = a ? {
|
|
368
362
|
class: m,
|
|
369
363
|
id: h,
|
|
370
|
-
style:
|
|
371
|
-
} :
|
|
372
|
-
return y.render(o,
|
|
373
|
-
},
|
|
374
|
-
const { marks: a, ...
|
|
364
|
+
style: ge(k) || void 0
|
|
365
|
+
} : d || {};
|
|
366
|
+
return y.render(o, S(w), c);
|
|
367
|
+
}, $ = (o) => R(o), T = (o) => {
|
|
368
|
+
const { marks: a, ...c } = o;
|
|
375
369
|
if ("text" in o) {
|
|
376
370
|
if (a)
|
|
377
371
|
return a.reduce(
|
|
378
|
-
(y, m) =>
|
|
379
|
-
|
|
372
|
+
(y, m) => $({ ...m, text: y }),
|
|
373
|
+
$({ ...c, children: c.children })
|
|
380
374
|
);
|
|
381
|
-
const
|
|
375
|
+
const d = o.attrs || {};
|
|
382
376
|
if (b) {
|
|
383
377
|
const y = t.get("txt") || 0;
|
|
384
|
-
t.set("txt", y + 1),
|
|
378
|
+
t.set("txt", y + 1), d.key = `txt-${y}`;
|
|
385
379
|
}
|
|
386
|
-
return n(
|
|
380
|
+
return n(c.text, d);
|
|
387
381
|
}
|
|
388
382
|
return "";
|
|
389
383
|
}, x = (o, a) => {
|
|
390
|
-
const { linktype:
|
|
384
|
+
const { linktype: c, href: d, anchor: y, ...m } = o.attrs || {};
|
|
391
385
|
let h = "";
|
|
392
|
-
switch (
|
|
386
|
+
switch (c) {
|
|
393
387
|
case I.ASSET:
|
|
394
388
|
case I.URL:
|
|
395
|
-
h =
|
|
389
|
+
h = d;
|
|
396
390
|
break;
|
|
397
391
|
case I.EMAIL:
|
|
398
|
-
h = `mailto:${
|
|
392
|
+
h = `mailto:${d}`;
|
|
399
393
|
break;
|
|
400
394
|
case I.STORY:
|
|
401
|
-
h =
|
|
395
|
+
h = d, y && (h = `${h}#${y}`);
|
|
402
396
|
break;
|
|
403
397
|
default:
|
|
404
|
-
h =
|
|
398
|
+
h = d;
|
|
405
399
|
break;
|
|
406
400
|
}
|
|
407
401
|
const k = { ...m };
|
|
408
402
|
return h && (k.href = h), a.render("a", k, o.text);
|
|
409
|
-
},
|
|
410
|
-
var
|
|
403
|
+
}, K = (o, a) => {
|
|
404
|
+
var c, d;
|
|
411
405
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), a.render("span", {
|
|
412
|
-
blok: (
|
|
413
|
-
id: (
|
|
406
|
+
blok: (c = o == null ? void 0 : o.attrs) == null ? void 0 : c.body[0],
|
|
407
|
+
id: (d = o.attrs) == null ? void 0 : d.id,
|
|
414
408
|
style: "display: none"
|
|
415
409
|
});
|
|
416
|
-
}, K = (o, a) => {
|
|
417
|
-
const i = {}, c = a.render("tbody", {}, o.children);
|
|
418
|
-
return a.render("table", i, c);
|
|
419
410
|
}, J = (o, a) => {
|
|
420
|
-
const
|
|
421
|
-
return a.render("
|
|
411
|
+
const c = {}, d = a.render("tbody", {}, o.children);
|
|
412
|
+
return a.render("table", c, d);
|
|
422
413
|
}, q = (o, a) => {
|
|
423
|
-
const
|
|
414
|
+
const c = {};
|
|
415
|
+
return a.render("tr", c, o.children);
|
|
416
|
+
}, W = (o, a) => {
|
|
417
|
+
const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
|
|
424
418
|
...h
|
|
425
419
|
};
|
|
426
|
-
|
|
420
|
+
c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
|
|
427
421
|
const w = [];
|
|
428
|
-
return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("td",
|
|
429
|
-
},
|
|
430
|
-
const { colspan:
|
|
422
|
+
return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("td", S(k), o.children);
|
|
423
|
+
}, Y = (o, a) => {
|
|
424
|
+
const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
|
|
431
425
|
...h
|
|
432
426
|
};
|
|
433
|
-
|
|
427
|
+
c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
|
|
434
428
|
const w = [];
|
|
435
|
-
return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("th",
|
|
436
|
-
},
|
|
437
|
-
[g.DOCUMENT,
|
|
438
|
-
[g.HEADING,
|
|
439
|
-
[g.PARAGRAPH,
|
|
440
|
-
[g.UL_LIST,
|
|
441
|
-
[g.OL_LIST,
|
|
442
|
-
[g.LIST_ITEM,
|
|
443
|
-
[g.IMAGE,
|
|
444
|
-
[g.EMOJI,
|
|
445
|
-
[g.CODE_BLOCK,
|
|
446
|
-
[g.HR,
|
|
447
|
-
[g.BR,
|
|
448
|
-
[g.QUOTE,
|
|
449
|
-
[g.COMPONENT,
|
|
450
|
-
[
|
|
451
|
-
[
|
|
452
|
-
[
|
|
453
|
-
[
|
|
454
|
-
[
|
|
455
|
-
[
|
|
456
|
-
[
|
|
457
|
-
[
|
|
458
|
-
[
|
|
459
|
-
[
|
|
460
|
-
[
|
|
461
|
-
[
|
|
462
|
-
[
|
|
463
|
-
[g.TABLE,
|
|
464
|
-
[g.TABLE_ROW,
|
|
465
|
-
[g.TABLE_CELL,
|
|
466
|
-
[g.TABLE_HEADER,
|
|
429
|
+
return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("th", S(k), o.children);
|
|
430
|
+
}, _ = /* @__PURE__ */ new Map([
|
|
431
|
+
[g.DOCUMENT, i("")],
|
|
432
|
+
[g.HEADING, f],
|
|
433
|
+
[g.PARAGRAPH, i("p")],
|
|
434
|
+
[g.UL_LIST, i("ul")],
|
|
435
|
+
[g.OL_LIST, i("ol")],
|
|
436
|
+
[g.LIST_ITEM, i("li")],
|
|
437
|
+
[g.IMAGE, u],
|
|
438
|
+
[g.EMOJI, E],
|
|
439
|
+
[g.CODE_BLOCK, L],
|
|
440
|
+
[g.HR, i("hr")],
|
|
441
|
+
[g.BR, i("br")],
|
|
442
|
+
[g.QUOTE, i("blockquote")],
|
|
443
|
+
[g.COMPONENT, K],
|
|
444
|
+
[z.TEXT, T],
|
|
445
|
+
[v.LINK, x],
|
|
446
|
+
[v.ANCHOR, x],
|
|
447
|
+
[v.STYLED, C("span", !0)],
|
|
448
|
+
[v.BOLD, C("strong")],
|
|
449
|
+
[v.TEXT_STYLE, C("span", !0)],
|
|
450
|
+
[v.ITALIC, C("em")],
|
|
451
|
+
[v.UNDERLINE, C("u")],
|
|
452
|
+
[v.STRIKE, C("s")],
|
|
453
|
+
[v.CODE, C("code")],
|
|
454
|
+
[v.SUPERSCRIPT, C("sup")],
|
|
455
|
+
[v.SUBSCRIPT, C("sub")],
|
|
456
|
+
[v.HIGHLIGHT, C("mark")],
|
|
457
|
+
[g.TABLE, J],
|
|
458
|
+
[g.TABLE_ROW, q],
|
|
459
|
+
[g.TABLE_CELL, W],
|
|
460
|
+
[g.TABLE_HEADER, Y]
|
|
461
|
+
]), B = new Map([
|
|
462
|
+
..._,
|
|
467
463
|
...Object.entries(l).map(([o, a]) => [o, a])
|
|
468
|
-
])
|
|
469
|
-
|
|
470
|
-
|
|
464
|
+
]), V = () => ({
|
|
465
|
+
render: (o, a = {}, c) => {
|
|
466
|
+
if (b && o) {
|
|
467
|
+
const d = t.get(o) || 0;
|
|
468
|
+
t.set(o, d + 1), a.key = `${o}-${d}`;
|
|
469
|
+
}
|
|
470
|
+
return s(o, a, c);
|
|
471
|
+
},
|
|
472
|
+
originalResolvers: _,
|
|
473
|
+
mergedResolvers: B
|
|
474
|
+
});
|
|
475
|
+
function A(o) {
|
|
476
|
+
const a = B.get(o.type);
|
|
471
477
|
if (!a)
|
|
472
478
|
return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
|
|
473
|
-
const
|
|
479
|
+
const c = V();
|
|
474
480
|
if (o.type === "text")
|
|
475
|
-
return a(o,
|
|
476
|
-
const
|
|
481
|
+
return a(o, c);
|
|
482
|
+
const d = o.content ? o.content.map(R) : void 0;
|
|
477
483
|
return a({
|
|
478
484
|
...o,
|
|
479
|
-
children:
|
|
480
|
-
},
|
|
485
|
+
children: d
|
|
486
|
+
}, c);
|
|
481
487
|
}
|
|
482
488
|
function R(o) {
|
|
483
|
-
return o.type === "doc" ? p ? o.content.map(
|
|
489
|
+
return o.type === "doc" ? p ? o.content.map(A) : o.content.map(A).join("") : Array.isArray(o) ? o.map(A) : A(o);
|
|
484
490
|
}
|
|
485
491
|
return {
|
|
486
492
|
render: R
|
|
487
493
|
};
|
|
488
494
|
}
|
|
489
|
-
let
|
|
490
|
-
const
|
|
491
|
-
if (typeof window > "u"
|
|
495
|
+
let H = !1;
|
|
496
|
+
const F = [], we = (e) => new Promise((t, s) => {
|
|
497
|
+
if (typeof window > "u") {
|
|
498
|
+
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (window.storyblokRegisterEvent = (l) => {
|
|
492
502
|
if (window.location === window.parent.location) {
|
|
493
503
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
494
504
|
return;
|
|
495
505
|
}
|
|
496
|
-
|
|
497
|
-
}, document.getElementById("storyblok-javascript-bridge"))
|
|
506
|
+
H ? l() : F.push(l);
|
|
507
|
+
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
508
|
+
t(void 0);
|
|
498
509
|
return;
|
|
510
|
+
}
|
|
499
511
|
const n = document.createElement("script");
|
|
500
512
|
n.async = !0, n.src = e, n.id = "storyblok-javascript-bridge", n.onerror = (l) => s(l), n.onload = (l) => {
|
|
501
|
-
|
|
513
|
+
F.forEach((r) => r()), H = !0, t(l);
|
|
502
514
|
}, document.getElementsByTagName("head")[0].appendChild(n);
|
|
503
|
-
}),
|
|
515
|
+
}), Ie = (e) => {
|
|
504
516
|
if (typeof e != "object" || typeof e._editable > "u")
|
|
505
517
|
return {};
|
|
506
518
|
try {
|
|
@@ -515,19 +527,19 @@ const U = [], me = (e) => new Promise((t, s) => {
|
|
|
515
527
|
return {};
|
|
516
528
|
}
|
|
517
529
|
};
|
|
518
|
-
let
|
|
519
|
-
function
|
|
520
|
-
return
|
|
530
|
+
let ve = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
531
|
+
function Te(e, t) {
|
|
532
|
+
return me(t).render(e);
|
|
521
533
|
}
|
|
522
|
-
const
|
|
534
|
+
const Ae = () => we(ve);
|
|
523
535
|
export {
|
|
524
536
|
Ee as getLiveStory,
|
|
525
537
|
$e as handleStoryblokMessage,
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
538
|
+
Ae as loadStoryblokBridge,
|
|
539
|
+
Te as renderRichText,
|
|
540
|
+
me as richTextResolver,
|
|
529
541
|
Le as storyblok,
|
|
530
|
-
|
|
531
|
-
|
|
542
|
+
Ie as storyblokEditable,
|
|
543
|
+
P as toCamelCase,
|
|
532
544
|
Ce as useStoryblokApi
|
|
533
545
|
};
|
|
@@ -7,33 +7,33 @@
|
|
|
7
7
|
</g>
|
|
8
8
|
</g>
|
|
9
9
|
</g>
|
|
10
|
-
</svg>`,
|
|
10
|
+
</svg>`,W=/[\p{Lu}]/u,Y=/[\p{Ll}]/u,B=/^[\p{Lu}](?![\p{Lu}])/gu,N=/([\p{Alpha}\p{N}_]|$)/u,x=/[_.\- ]+/,V=new RegExp("^"+x.source),j=new RegExp(x.source+N.source,"gu"),P=new RegExp("\\d+"+N.source,"gu"),X=(e,t,s,n)=>{let l=!1,r=!1,b=!1,p=!1;for(let i=0;i<e.length;i++){const u=e[i];p=i>2?e[i-3]==="-":!0,l&&W.test(u)?(e=e.slice(0,i)+"-"+e.slice(i),l=!1,b=r,r=!0,i++):r&&b&&Y.test(u)&&(!p||n)?(e=e.slice(0,i-1)+"-"+e.slice(i-1),b=r,r=!1,l=!0):(l=t(u)===u&&s(u)!==u,b=r,r=s(u)===u&&t(u)!==u)}return e},Z=(e,t)=>(B.lastIndex=0,e.replaceAll(B,s=>t(s))),Q=(e,t)=>(j.lastIndex=0,P.lastIndex=0,e.replaceAll(P,(s,n,l)=>["_","-"].includes(e.charAt(l+s.length))?s:t(s)).replaceAll(j,(s,n)=>t(n)));function ee(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(r=>r.trim()).filter(r=>r.length).join("-"):e=e.trim(),e.length===0)return"";const s=t.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(t.locale),n=t.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(t.locale);return e.length===1?x.test(e)?"":t.pascalCase?n(e):s(e):(e!==s(e)&&(e=X(e,s,n,t.preserveConsecutiveUppercase)),e=e.replace(V,""),e=t.preserveConsecutiveUppercase?Z(e,s):s(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),Q(e,n))}function _(e){return ee(e)}function te(e,t={},s,n){const l="virtual:storyblok-components",r=`\0${l}`;return{name:"vite-plugin-storyblok-components",async resolveId(b){if(b===l)return r},async load(b){if(b===r){const p=[],i=[];for await(const[f,L]of Object.entries(t)){const S=await this.resolve(`/${e}/${L}.astro`);if(S)p.push(`import ${_(f)} from "${S.id}"`);else if(s)i.push(f);else throw new Error(`Component could not be found for blok "${f}"! Does "${`/${e}/${L}`}.astro" exist?`)}let u="";if(s)if(u=",FallbackComponent",n){const f=await this.resolve(`/${e}/${n}.astro`);if(!f)throw new Error(`Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`);p.push(`import FallbackComponent from "${f.id}"`)}else p.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${p.join(";")};export default {${Object.keys(t).filter(f=>!i.includes(f)).map(f=>_(f)).join(",")}${u}}`;if(s)return`${p[0]}; export default {${u.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
11
11
|
Please register your components or enable the fallback component.
|
|
12
|
-
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function
|
|
12
|
+
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function oe(e,t,s){const n="virtual:storyblok-init",l=`\0${n}`;return{name:"vite-plugin-storyblok-init",async resolveId(r){if(r===n)return l},async load(r){if(r===l)return`
|
|
13
13
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
14
14
|
const { storyblokApi } = storyblokInit({
|
|
15
15
|
accessToken: "${e}",
|
|
16
16
|
use: ${t?"[]":"[apiPlugin]"},
|
|
17
|
-
apiOptions: ${JSON.stringify(
|
|
17
|
+
apiOptions: ${JSON.stringify(s)},
|
|
18
18
|
});
|
|
19
19
|
export const storyblokApiInstance = storyblokApi;
|
|
20
|
-
`}}}function
|
|
20
|
+
`}}}function re(e){const t="virtual:storyblok-options",s=`\0${t}`;return{name:"vite-plugin-storyblok-options",async resolveId(n){if(n===t)return s},async load(n){if(n===s)return`export default ${JSON.stringify(e)}`}}}function se(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function ne(e){let t=null;return e&&e.locals._storyblok_preview_data&&(t=e.locals._storyblok_preview_data),t}function le(e){return typeof e=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});`:"const storyblokInstance = new StoryblokBridge();"}function ae(e){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...e},s=le(t.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:n,updateConfig:l,addDevToolbarApp:r,addMiddleware:b,config:p})=>{if(l({vite:{plugins:[oe(t.accessToken,t.useCustomApi,t.apiOptions),te(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),re(t)]}}),t.livePreview&&(p==null?void 0:p.output)!=="server")throw new Error("To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode.");n("page-ssr",`
|
|
21
21
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
22
22
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
23
|
-
`),t.bridge&&!t.livePreview&&
|
|
23
|
+
`),t.bridge&&!t.livePreview&&n("page",`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
24
24
|
loadStoryblokBridge().then(() => {
|
|
25
25
|
const { StoryblokBridge, location } = window;
|
|
26
|
-
${
|
|
26
|
+
${s}
|
|
27
27
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
28
28
|
if (!event.slugChanged) {
|
|
29
29
|
location.reload(true);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
-
`),t.livePreview&&(
|
|
33
|
+
`),t.livePreview&&(n("page",`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
34
34
|
loadStoryblokBridge().then(() => {
|
|
35
35
|
const { StoryblokBridge, location } = window;
|
|
36
|
-
${
|
|
36
|
+
${s}
|
|
37
37
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
38
38
|
});
|
|
39
|
-
`),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),r({id:"storyblok",name:"Storyblok",icon:$,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let D;async function
|
|
39
|
+
`),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),r({id:"storyblok",name:"Storyblok",icon:$,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let D;async function ie(e){const{action:t,story:s}=e||{};if(t==="input"&&s){const n=async()=>{const r=await de(s),b=document.body;if(r.outerHTML===b.outerHTML)return;const p=document.querySelector('[data-blok-focused="true"]');ce(b,r,p),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(D),D=setTimeout(n,500)}["published","change"].includes(e==null?void 0:e.action)&&location.reload()}function ce(e,t,s){if(s){const n=s.getAttribute("data-blok-uid"),l=t.querySelector(`[data-blok-uid="${n}"]`);l&&(l.setAttribute("data-blok-focused","true"),s.replaceWith(l))}else e.replaceWith(t)}async function de(e){const s=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...e,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(s,"text/html").body}function ue(e,t){if(!t)return{src:e,attrs:{}};let s=0,n=0;const l={},r=[];function b(i,u,f,L,S){typeof i!="number"||i<=u||i>=f?console.warn(`[StoryblokRichText] - ${L.charAt(0).toUpperCase()+L.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):S.push(`${L}(${i})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(l.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(l.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(l.loading=t.loading),t.class&&(l.class=t.class),t.filters){const{filters:i}=t||{},{blur:u,brightness:f,fill:L,format:S,grayscale:E,quality:A,rotate:R}=i||{};u&&b(u,0,100,"blur",r),A&&b(A,0,100,"quality",r),f&&b(f,0,100,"brightness",r),L&&r.push(`fill(${L})`),E&&r.push("grayscale()"),R&&[0,90,180,270].includes(t.filters.rotate||0)&&r.push(`rotate(${R})`),S&&["webp","png","jpeg"].includes(S)&&r.push(`format(${S})`)}t.srcset&&(l.srcset=t.srcset.map(i=>{if(typeof i=="number")return`${e}/m/${i}x0/${r.length>0?`filters:${r.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,f]=i;return`${e}/m/${u}x${f}/${r.length>0?`filters:${r.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(l.sizes=t.sizes.join(", "))}let p=`${e}/m/`;return s>0&&n>0&&(p=`${p}${s}x${n}/`),r.length>0&&(p=`${p}filters:${r.join(":")}`),{src:p,attrs:l}}var h=(e=>(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))(h||{}),C=(e=>(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))(C||{}),U=(e=>(e.TEXT="text",e))(U||{}),T=(e=>(e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e))(T||{});const pe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],be=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),fe=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ye(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function H(e,t={},s){const n=be(t),l=n?`${e} ${n}`:e,r=Array.isArray(s)?s.join(""):s||"";if(e){if(pe.includes(e))return`<${l}>`}else return r;return`<${l}>${r}</${e}>`}function F(e={}){const t=new Map,{renderFn:s=H,textFn:n=ye,resolvers:l={},optimizeImages:r=!1,keyedResolvers:b=!1}=e,p=s!==H,i=o=>(a,c)=>{const d=a.attrs||{};return c.render(o,d,a.children||null)},u=(o,a)=>{const{src:c,alt:d,title:y,srcset:k,sizes:g}=o.attrs||{};let m=c,v={};if(r){const{src:Ae,attrs:Ie}=ue(c,r);m=Ae,v=Ie}const Te={src:m,alt:d,title:y,srcset:k,sizes:g,...v};return a.render("img",I(Te))},f=(o,a)=>{const{level:c,...d}=o.attrs||{};return a.render(`h${c}`,d,o.children)},L=(o,a)=>{var c,d,y,k;const g=a.render("img",{src:(c=o.attrs)==null?void 0:c.fallbackImage,alt:(d=o.attrs)==null?void 0:d.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return a.render("span",{"data-type":"emoji","data-name":(y=o.attrs)==null?void 0:y.name,"data-emoji":(k=o.attrs)==null?void 0:k.emoji},g)},S=(o,a)=>a.render("pre",o.attrs||{},a.render("code",{},o.children||"")),E=(o,a=!1)=>({text:c,attrs:d},y)=>{const{class:k,id:g,...m}=d||{},v=a?{class:k,id:g,style:fe(m)||void 0}:d||{};return y.render(o,I(v),c)},A=o=>M(o),R=o=>{const{marks:a,...c}=o;if("text"in o){if(a)return a.reduce((y,k)=>A({...k,text:y}),A({...c,children:c.children}));const d=o.attrs||{};if(b){const y=t.get("txt")||0;t.set("txt",y+1),d.key=`txt-${y}`}return n(c.text,d)}return""},K=(o,a)=>{const{linktype:c,href:d,anchor:y,...k}=o.attrs||{};let g="";switch(c){case T.ASSET:case T.URL:g=d;break;case T.EMAIL:g=`mailto:${d}`;break;case T.STORY:g=d,y&&(g=`${g}#${y}`);break;default:g=d;break}const m={...k};return g&&(m.href=g),a.render("a",m,o.text)},ve=(o,a)=>{var c,d;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),a.render("span",{blok:(c=o==null?void 0:o.attrs)==null?void 0:c.body[0],id:(d=o.attrs)==null?void 0:d.id,style:"display: none"})},Ce=(o,a)=>{const c={},d=a.render("tbody",{},o.children);return a.render("table",c,d)},Ee=(o,a)=>{const c={};return a.render("tr",c,o.children)},Le=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:k,...g}=o.attrs||{},m={...g};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),k&&v.push(`background-color: ${k};`),v.length>0&&(m.style=v.join(" ")),a.render("td",I(m),o.children)},Se=(o,a)=>{const{colspan:c,rowspan:d,colwidth:y,backgroundColor:k,...g}=o.attrs||{},m={...g};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const v=[];return y&&v.push(`width: ${y}px;`),k&&v.push(`background-color: ${k};`),v.length>0&&(m.style=v.join(" ")),a.render("th",I(m),o.children)},J=new Map([[h.DOCUMENT,i("")],[h.HEADING,f],[h.PARAGRAPH,i("p")],[h.UL_LIST,i("ul")],[h.OL_LIST,i("ol")],[h.LIST_ITEM,i("li")],[h.IMAGE,u],[h.EMOJI,L],[h.CODE_BLOCK,S],[h.HR,i("hr")],[h.BR,i("br")],[h.QUOTE,i("blockquote")],[h.COMPONENT,ve],[U.TEXT,R],[C.LINK,K],[C.ANCHOR,K],[C.STYLED,E("span",!0)],[C.BOLD,E("strong")],[C.TEXT_STYLE,E("span",!0)],[C.ITALIC,E("em")],[C.UNDERLINE,E("u")],[C.STRIKE,E("s")],[C.CODE,E("code")],[C.SUPERSCRIPT,E("sup")],[C.SUBSCRIPT,E("sub")],[C.HIGHLIGHT,E("mark")],[h.TABLE,Ce],[h.TABLE_ROW,Ee],[h.TABLE_CELL,Le],[h.TABLE_HEADER,Se]]),q=new Map([...J,...Object.entries(l).map(([o,a])=>[o,a])]),$e=()=>({render:(o,a={},c)=>{if(b&&o){const d=t.get(o)||0;t.set(o,d+1),a.key=`${o}-${d}`}return s(o,a,c)},originalResolvers:J,mergedResolvers:q});function O(o){const a=q.get(o.type);if(!a)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const c=$e();if(o.type==="text")return a(o,c);const d=o.content?o.content.map(M):void 0;return a({...o,children:d},c)}function M(o){return o.type==="doc"?p?o.content.map(O):o.content.map(O).join(""):Array.isArray(o)?o.map(O):O(o)}return{render:M}}let G=!1;const z=[],he=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=l=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?l():z.push(l)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=l=>s(l),n.onload=l=>{z.forEach(r=>r()),G=!0,t(l)},document.getElementsByTagName("head")[0].appendChild(n)}),ge=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let me="https://app.storyblok.com/f/storyblok-v2-latest.js";function ke(e,t){return F(t).render(e)}const we=()=>he(me);w.getLiveStory=ne,w.handleStoryblokMessage=ie,w.loadStoryblokBridge=we,w.renderRichText=ke,w.richTextResolver=F,w.storyblok=ae,w.storyblokEditable=ge,w.toCamelCase=_,w.useStoryblokApi=se,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.1",
|
|
5
5
|
"private": false,
|
|
6
|
-
"packageManager": "pnpm@9.13.2",
|
|
7
6
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
8
7
|
"author": "Storyblok",
|
|
9
8
|
"license": "MIT",
|
|
@@ -50,75 +49,33 @@
|
|
|
50
49
|
"*.d.ts",
|
|
51
50
|
"dist"
|
|
52
51
|
],
|
|
53
|
-
"scripts": {
|
|
54
|
-
"dev": "vite",
|
|
55
|
-
"build": "vite build && tsc --project tsconfig.json",
|
|
56
|
-
"playground": "pnpm run --filter ./playground/ssg dev",
|
|
57
|
-
"playground:ssr": "pnpm run --filter ./playground/ssr dev",
|
|
58
|
-
"playground:test": "pnpm run --filter ./playground/test dev",
|
|
59
|
-
"lint": "eslint .",
|
|
60
|
-
"lint:fix": "eslint . --fix",
|
|
61
|
-
"lint:playground": "pnpm -r --parallel --filter='./playground/*' run lint",
|
|
62
|
-
"lint:playground:fix": "pnpm -r --parallel --filter='./playground/*' run lint:fix",
|
|
63
|
-
"test": "pnpm run test:unit:ci && pnpm run test:e2e",
|
|
64
|
-
"test:unit": "vitest",
|
|
65
|
-
"test:unit:ci": "vitest run",
|
|
66
|
-
"test:e2e": "start-server-and-test playground:test http://localhost:4321/ cy:run",
|
|
67
|
-
"test:e2e-watch": "start-server-and-test playground:test http://localhost:4321/ cy:open",
|
|
68
|
-
"cy:run": "cypress run",
|
|
69
|
-
"cy:open": "cypress open",
|
|
70
|
-
"check-licenses": "node scripts/license-checker.mjs"
|
|
71
|
-
},
|
|
72
52
|
"peerDependencies": {
|
|
73
53
|
"astro": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
74
54
|
},
|
|
75
55
|
"dependencies": {
|
|
76
|
-
"
|
|
77
|
-
"
|
|
56
|
+
"camelcase": "^8.0.0",
|
|
57
|
+
"@storyblok/js": "4.0.3"
|
|
78
58
|
},
|
|
79
59
|
"devDependencies": {
|
|
80
|
-
"@
|
|
81
|
-
"@commitlint/config-conventional": "^19.5.0",
|
|
82
|
-
"@cypress/vite-dev-server": "^5.2.0",
|
|
60
|
+
"@cypress/vite-dev-server": "^6.0.3",
|
|
83
61
|
"@rollup/plugin-dynamic-import-vars": "^2.1.5",
|
|
84
62
|
"@storyblok/eslint-config": "^0.3.0",
|
|
85
63
|
"@types/lodash.mergewith": "^4.6.9",
|
|
86
|
-
"@types/node": "22.
|
|
64
|
+
"@types/node": "^22.15.1",
|
|
87
65
|
"astro": "^5.0.9",
|
|
88
|
-
"cypress": "^
|
|
89
|
-
"eslint": "^9.
|
|
90
|
-
"eslint-config-prettier": "^
|
|
66
|
+
"cypress": "^14.3.3",
|
|
67
|
+
"eslint": "^9.26.0",
|
|
68
|
+
"eslint-config-prettier": "^10.0.1",
|
|
91
69
|
"eslint-plugin-astro": "^1.3.1",
|
|
92
|
-
"eslint-plugin-cypress": "^4.
|
|
93
|
-
"
|
|
94
|
-
"lint-staged": "^15.2.10",
|
|
95
|
-
"prettier": "^3.3.3",
|
|
70
|
+
"eslint-plugin-cypress": "^4.3.0",
|
|
71
|
+
"prettier": "^3.4.2",
|
|
96
72
|
"prettier-plugin-astro": "^0.13.0",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"vite": "^
|
|
101
|
-
"vite-plugin-dts": "^4.3.0",
|
|
73
|
+
"start-server-and-test": "^2.0.11",
|
|
74
|
+
"typescript": "5.8.3",
|
|
75
|
+
"vite": "^6.3.5",
|
|
76
|
+
"vite-plugin-dts": "^4.5.3",
|
|
102
77
|
"vite-plugin-static-copy": "^2.2.0",
|
|
103
|
-
"vitest": "^
|
|
104
|
-
},
|
|
105
|
-
"simple-git-hooks": {
|
|
106
|
-
"pre-commit": "pnpm lint",
|
|
107
|
-
"pre-push": "pnpm commitlint --last --verbose"
|
|
108
|
-
},
|
|
109
|
-
"lint-staged": {
|
|
110
|
-
"*.{astro,js,css}": [
|
|
111
|
-
"prettier --write",
|
|
112
|
-
"eslint"
|
|
113
|
-
],
|
|
114
|
-
"*.md": [
|
|
115
|
-
"prettier --write"
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
"commitlint": {
|
|
119
|
-
"extends": [
|
|
120
|
-
"@commitlint/config-conventional"
|
|
121
|
-
]
|
|
78
|
+
"vitest": "^3.1.3"
|
|
122
79
|
},
|
|
123
80
|
"eslintConfig": {
|
|
124
81
|
"env": {
|
|
@@ -163,5 +120,31 @@
|
|
|
163
120
|
},
|
|
164
121
|
"publishConfig": {
|
|
165
122
|
"access": "public"
|
|
123
|
+
},
|
|
124
|
+
"nx": {
|
|
125
|
+
"implicitDependencies": [
|
|
126
|
+
"!@storyblok/playground-*"
|
|
127
|
+
],
|
|
128
|
+
"tags": [
|
|
129
|
+
"type:lib"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"scripts": {
|
|
133
|
+
"dev": "vite",
|
|
134
|
+
"build": "vite build && tsc --project tsconfig.json",
|
|
135
|
+
"playground": "pnpm run --filter ./playground/ssg dev",
|
|
136
|
+
"playground:ssr": "pnpm run --filter ./playground/ssr dev",
|
|
137
|
+
"playground:test": "pnpm run --filter ./playground/test dev",
|
|
138
|
+
"lint": "eslint .",
|
|
139
|
+
"lint:fix": "eslint . --fix",
|
|
140
|
+
"lint:playground": "pnpm -r --parallel --filter='./playground/*' run lint",
|
|
141
|
+
"lint:playground:fix": "pnpm -r --parallel --filter='./playground/*' run lint:fix",
|
|
142
|
+
"test": "pnpm run test:unit:ci && pnpm run test:e2e",
|
|
143
|
+
"test:unit": "vitest",
|
|
144
|
+
"test:unit:ci": "vitest run",
|
|
145
|
+
"test:e2e": "start-server-and-test playground:test http://localhost:4321/ cy:run",
|
|
146
|
+
"test:e2e-watch": "start-server-and-test playground:test http://localhost:4321/ cy:open",
|
|
147
|
+
"cy:run": "cypress run",
|
|
148
|
+
"cy:open": "cypress open"
|
|
166
149
|
}
|
|
167
|
-
}
|
|
150
|
+
}
|