@storyblok/astro 6.0.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,5 @@ export declare function useStoryblokApi(): StoryblokClient;
4
4
  export declare function getLiveStory(Astro: Readonly<AstroGlobal>): Promise<ISbStoryData<import('@storyblok/js').StoryblokComponentType<string> & {
5
5
  [index: string]: any;
6
6
  }> | null>;
7
- export declare function renderRichText(data?: ISbRichtext, options?: SbRichTextOptions): string;
7
+ export declare function renderRichText(data?: ISbRichtext, options?: SbRichTextOptions): string | undefined;
8
8
  export declare function initStoryblokBridge(config: boolean | StoryblokBridgeConfigV2): string;
@@ -7,30 +7,30 @@ const A = `<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>`, E = /[\p{Lu}]/u, L = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, x = /([\p{Alpha}\p{N}_]|$)/u, y = /[_.\- ]+/, R = new RegExp("^" + y.source), w = new RegExp(y.source + x.source, "gu"), $ = new RegExp("\\d+" + x.source, "gu"), j = (r, e, t, o) => {
10
+ </svg>`, E = /[\p{Lu}]/u, L = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, x = /([\p{Alpha}\p{N}_]|$)/u, b = /[_.\- ]+/, j = new RegExp("^" + b.source), w = new RegExp(b.source + x.source, "gu"), $ = new RegExp("\\d+" + x.source, "gu"), R = (r, t, e, o) => {
11
11
  let s = !1, n = !1, a = !1, l = !1;
12
12
  for (let i = 0; i < r.length; i++) {
13
13
  const c = r[i];
14
- l = i > 2 ? r[i - 3] === "-" : !0, s && E.test(c) ? (r = r.slice(0, i) + "-" + r.slice(i), s = !1, a = n, n = !0, i++) : n && a && L.test(c) && (!l || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), a = n, n = !1, s = !0) : (s = e(c) === c && t(c) !== c, a = n, n = t(c) === c && e(c) !== c);
14
+ l = i > 2 ? r[i - 3] === "-" : !0, s && E.test(c) ? (r = r.slice(0, i) + "-" + r.slice(i), s = !1, a = n, n = !0, i++) : n && a && L.test(c) && (!l || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), a = n, n = !1, s = !0) : (s = t(c) === c && e(c) !== c, a = n, n = e(c) === c && t(c) !== c);
15
15
  }
16
16
  return r;
17
- }, M = (r, e) => (k.lastIndex = 0, r.replaceAll(k, (t) => e(t))), P = (r, e) => (w.lastIndex = 0, $.lastIndex = 0, r.replaceAll($, (t, o, s) => ["_", "-"].includes(r.charAt(s + t.length)) ? t : e(t)).replaceAll(w, (t, o) => e(o)));
18
- function O(r, e) {
17
+ }, M = (r, t) => (k.lastIndex = 0, r.replaceAll(k, (e) => t(e))), P = (r, t) => (w.lastIndex = 0, $.lastIndex = 0, r.replaceAll($, (e, o, s) => ["_", "-"].includes(r.charAt(s + e.length)) ? e : t(e)).replaceAll(w, (e, o) => t(o)));
18
+ function O(r, t) {
19
19
  if (!(typeof r == "string" || Array.isArray(r)))
20
20
  throw new TypeError("Expected the input to be `string | string[]`");
21
- if (e = {
21
+ if (t = {
22
22
  pascalCase: !1,
23
23
  preserveConsecutiveUppercase: !1,
24
- ...e
24
+ ...t
25
25
  }, Array.isArray(r) ? r = r.map((n) => n.trim()).filter((n) => n.length).join("-") : r = r.trim(), r.length === 0)
26
26
  return "";
27
- const t = e.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(e.locale);
28
- return r.length === 1 ? y.test(r) ? "" : e.pascalCase ? o(r) : t(r) : (r !== t(r) && (r = j(r, t, o, e.preserveConsecutiveUppercase)), r = r.replace(R, ""), r = e.preserveConsecutiveUppercase ? M(r, t) : t(r), e.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), P(r, o));
27
+ const e = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), o = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
28
+ return r.length === 1 ? b.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r = R(r, e, o, t.preserveConsecutiveUppercase)), r = r.replace(j, ""), r = t.preserveConsecutiveUppercase ? M(r, e) : e(r), t.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), P(r, o));
29
29
  }
30
30
  function v(r) {
31
31
  return O(r);
32
32
  }
33
- function _(r, e = {}, t, o) {
33
+ function _(r, t = {}, e, o) {
34
34
  const s = "virtual:storyblok-components", n = `\0${s}`;
35
35
  return {
36
36
  name: "vite-plugin-storyblok-components",
@@ -41,13 +41,13 @@ function _(r, e = {}, t, o) {
41
41
  async load(a) {
42
42
  if (a === n) {
43
43
  const l = [], i = [];
44
- for await (const [u, p] of Object.entries(e)) {
44
+ for await (const [u, p] of Object.entries(t)) {
45
45
  const f = await this.resolve(
46
46
  `/${r}/${p}.astro`
47
47
  );
48
48
  if (f)
49
49
  l.push(`import ${v(u)} from "${f.id}"`);
50
- else if (t)
50
+ else if (e)
51
51
  i.push(u);
52
52
  else
53
53
  throw new Error(
@@ -55,7 +55,7 @@ function _(r, e = {}, t, o) {
55
55
  );
56
56
  }
57
57
  let c = "";
58
- if (t)
58
+ if (e)
59
59
  if (c = ",FallbackComponent", o) {
60
60
  const u = await this.resolve(
61
61
  `/${r}/${o}.astro`
@@ -71,9 +71,9 @@ function _(r, e = {}, t, o) {
71
71
  l.push(
72
72
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
73
73
  );
74
- if (Object.values(e).length)
75
- return `${l.join(";")};export default {${Object.keys(e).filter((u) => !i.includes(u)).map((u) => v(u)).join(",")}${c}}`;
76
- if (t)
74
+ if (Object.values(t).length)
75
+ return `${l.join(";")};export default {${Object.keys(t).filter((u) => !i.includes(u)).map((u) => v(u)).join(",")}${c}}`;
76
+ if (e)
77
77
  return `${l[0]}; export default {${c.replace(",", "")}}`;
78
78
  throw new Error(
79
79
  `Currently, no Storyblok components are registered in astro.config.mjs.
@@ -84,7 +84,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
84
84
  }
85
85
  };
86
86
  }
87
- function N(r, e, t) {
87
+ function N(r, t, e) {
88
88
  const o = "virtual:storyblok-init", s = `\0${o}`;
89
89
  return {
90
90
  name: "vite-plugin-storyblok-init",
@@ -98,8 +98,8 @@ function N(r, e, t) {
98
98
  import { storyblokInit, apiPlugin } from "@storyblok/js";
99
99
  const { storyblokApi } = storyblokInit({
100
100
  accessToken: "${r}",
101
- use: ${e ? "[]" : "[apiPlugin]"},
102
- apiOptions: ${JSON.stringify(t)},
101
+ use: ${t ? "[]" : "[apiPlugin]"},
102
+ apiOptions: ${JSON.stringify(e)},
103
103
  });
104
104
  export const storyblokApiInstance = storyblokApi;
105
105
  `;
@@ -107,52 +107,53 @@ function N(r, e, t) {
107
107
  };
108
108
  }
109
109
  function z(r) {
110
- const e = "virtual:storyblok-options", t = `\0${e}`;
110
+ const t = "virtual:storyblok-options", e = `\0${t}`;
111
111
  return {
112
112
  name: "vite-plugin-storyblok-options",
113
113
  async resolveId(o) {
114
- if (o === e)
115
- return t;
114
+ if (o === t)
115
+ return e;
116
116
  },
117
117
  async load(o) {
118
- if (o === t)
118
+ if (o === e)
119
119
  return `export default ${JSON.stringify(r)}`;
120
120
  }
121
121
  };
122
122
  }
123
123
  let C = !1;
124
- const I = [], B = (r) => new Promise((e, t) => {
124
+ const I = [], B = (r) => new Promise((t, e) => {
125
125
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
126
126
  if (window.location === window.parent.location) {
127
127
  console.warn("You are not in Draft Mode or in the Visual Editor.");
128
128
  return;
129
129
  }
130
130
  C ? s() : I.push(s);
131
- }, document.getElementById("storyblok-javascript-bridge"))) return;
131
+ }, document.getElementById("storyblok-javascript-bridge")))
132
+ return;
132
133
  const o = document.createElement("script");
133
- o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => t(s), o.onload = (s) => {
134
- I.forEach((n) => n()), C = !0, e(s);
134
+ o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => e(s), o.onload = (s) => {
135
+ I.forEach((n) => n()), C = !0, t(s);
135
136
  }, document.getElementsByTagName("head")[0].appendChild(o);
136
137
  });
137
- var F = Object.defineProperty, D = (r, e, t) => e in r ? F(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, g = (r, e, t) => D(r, typeof e != "symbol" ? e + "" : e, t);
138
+ var F = Object.defineProperty, D = (r, t, e) => t in r ? F(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, g = (r, t, e) => D(r, typeof t != "symbol" ? t + "" : t, e);
138
139
  let U = class {
139
140
  constructor() {
140
- g(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), g(this, "getOptionsPage", (r, e = 25, t = 1) => ({
141
+ g(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), g(this, "getOptionsPage", (r, t = 25, e = 1) => ({
141
142
  ...r,
142
- per_page: e,
143
- page: t
144
- })), g(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), g(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), g(this, "range", (r = 0, e = r) => {
145
- const t = Math.abs(e - r) || 0, o = r < e ? 1 : -1;
146
- return this.arrayFrom(t, (s, n) => n * o + r);
147
- }), g(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), g(this, "flatMap", (r = [], e) => r.map(e).reduce((t, o) => [...t, ...o], [])), g(this, "escapeHTML", function(r) {
148
- const e = {
143
+ per_page: t,
144
+ page: e
145
+ })), g(this, "delay", (r) => new Promise((t) => setTimeout(t, r))), g(this, "arrayFrom", (r = 0, t) => Array.from({ length: r }, t)), g(this, "range", (r = 0, t = r) => {
146
+ const e = Math.abs(t - r) || 0, o = r < t ? 1 : -1;
147
+ return this.arrayFrom(e, (s, n) => n * o + r);
148
+ }), g(this, "asyncMap", async (r, t) => Promise.all(r.map(t))), g(this, "flatMap", (r = [], t) => r.map(t).reduce((e, o) => [...e, ...o], [])), g(this, "escapeHTML", function(r) {
149
+ const t = {
149
150
  "&": "&amp;",
150
151
  "<": "&lt;",
151
152
  ">": "&gt;",
152
153
  '"': "&quot;",
153
154
  "'": "&#39;"
154
- }, t = /[&<>"']/g, o = new RegExp(t.source);
155
- return r && o.test(r) ? r.replace(t, (s) => e[s]) : r;
155
+ }, e = /[&<>"']/g, o = new RegExp(e.source);
156
+ return r && o.test(r) ? r.replace(e, (s) => t[s]) : r;
156
157
  });
157
158
  }
158
159
  /**
@@ -162,18 +163,18 @@ let U = class {
162
163
  * @param {boolean} isArray
163
164
  * @return {string} Stringified object
164
165
  */
165
- stringify(r, e, t) {
166
+ stringify(r, t, e) {
166
167
  const o = [];
167
168
  for (const s in r) {
168
169
  if (!Object.prototype.hasOwnProperty.call(r, s))
169
170
  continue;
170
- const n = r[s], a = t ? "" : encodeURIComponent(s);
171
+ const n = r[s], a = e ? "" : encodeURIComponent(s);
171
172
  let l;
172
173
  typeof n == "object" ? l = this.stringify(
173
174
  n,
174
- e ? e + encodeURIComponent(`[${a}]`) : a,
175
+ t ? t + encodeURIComponent(`[${a}]`) : a,
175
176
  Array.isArray(n)
176
- ) : l = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(l);
177
+ ) : l = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(l);
177
178
  }
178
179
  return o.join("&");
179
180
  }
@@ -183,10 +184,10 @@ let U = class {
183
184
  * @return {string} The base URL of the region
184
185
  */
185
186
  getRegionURL(r) {
186
- const e = "api.storyblok.com", t = "api-us.storyblok.com", o = "app.storyblokchina.cn", s = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
187
+ const t = "api.storyblok.com", e = "api-us.storyblok.com", o = "app.storyblokchina.cn", s = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
187
188
  switch (r) {
188
189
  case "us":
189
- return t;
190
+ return e;
190
191
  case "cn":
191
192
  return o;
192
193
  case "ap":
@@ -194,24 +195,24 @@ let U = class {
194
195
  case "ca":
195
196
  return n;
196
197
  default:
197
- return e;
198
+ return t;
198
199
  }
199
200
  }
200
201
  };
201
- const q = function(r, e) {
202
- const t = {};
202
+ const q = function(r, t) {
203
+ const e = {};
203
204
  for (const o in r) {
204
205
  const s = r[o];
205
- e.includes(o) && s !== null && (t[o] = s);
206
+ t.includes(o) && s !== null && (e[o] = s);
206
207
  }
207
- return t;
208
- }, H = (r) => r === "email", W = () => ({
208
+ return e;
209
+ }, H = (r) => r === "email", J = () => ({
209
210
  singleTag: "hr"
210
- }), J = () => ({
211
+ }), W = () => ({
211
212
  tag: "blockquote"
212
213
  }), V = () => ({
213
214
  tag: "ul"
214
- }), K = (r) => ({
215
+ }), Z = (r) => ({
215
216
  tag: [
216
217
  "pre",
217
218
  {
@@ -219,11 +220,11 @@ const q = function(r, e) {
219
220
  attrs: r.attrs
220
221
  }
221
222
  ]
222
- }), Z = () => ({
223
+ }), G = () => ({
223
224
  singleTag: "br"
224
- }), G = (r) => ({
225
+ }), K = (r) => ({
225
226
  tag: `h${r.attrs.level}`
226
- }), X = (r) => ({
227
+ }), Q = (r) => ({
227
228
  singleTag: [
228
229
  {
229
230
  tag: "img",
@@ -232,7 +233,7 @@ const q = function(r, e) {
232
233
  ]
233
234
  }), Y = () => ({
234
235
  tag: "li"
235
- }), Q = () => ({
236
+ }), X = () => ({
236
237
  tag: "ol"
237
238
  }), ee = () => ({
238
239
  tag: "p"
@@ -264,17 +265,17 @@ const q = function(r, e) {
264
265
  return {
265
266
  tag: ""
266
267
  };
267
- const e = new U().escapeHTML, t = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
268
- if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), H(o) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
269
- for (const s in t.custom)
270
- t[s] = t.custom[s];
271
- delete t.custom;
268
+ const t = new U().escapeHTML, e = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
269
+ if (delete e.linktype, e.href && (e.href = t(r.attrs.href || "")), H(o) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
270
+ for (const s in e.custom)
271
+ e[s] = e.custom[s];
272
+ delete e.custom;
272
273
  }
273
274
  return {
274
275
  tag: [
275
276
  {
276
277
  tag: "a",
277
- attrs: t
278
+ attrs: e
278
279
  }
279
280
  ]
280
281
  };
@@ -297,8 +298,8 @@ const q = function(r, e) {
297
298
  }
298
299
  ]
299
300
  }), pe = (r) => {
300
- var e;
301
- return (e = r.attrs) != null && e.color ? {
301
+ var t;
302
+ return (t = r.attrs) != null && t.color ? {
302
303
  tag: [
303
304
  {
304
305
  tag: "span",
@@ -311,8 +312,8 @@ const q = function(r, e) {
311
312
  tag: ""
312
313
  };
313
314
  }, fe = (r) => {
314
- var e;
315
- return (e = r.attrs) != null && e.color ? {
315
+ var t;
316
+ return (t = r.attrs) != null && t.color ? {
316
317
  tag: [
317
318
  {
318
319
  tag: "span",
@@ -326,15 +327,15 @@ const q = function(r, e) {
326
327
  };
327
328
  }, he = {
328
329
  nodes: {
329
- horizontal_rule: W,
330
- blockquote: J,
330
+ horizontal_rule: J,
331
+ blockquote: W,
331
332
  bullet_list: V,
332
- code_block: K,
333
- hard_break: Z,
334
- heading: G,
335
- image: X,
333
+ code_block: Z,
334
+ hard_break: G,
335
+ heading: K,
336
+ image: Q,
336
337
  list_item: Y,
337
- ordered_list: Q,
338
+ ordered_list: X,
338
339
  paragraph: ee,
339
340
  emoji: te
340
341
  },
@@ -353,35 +354,35 @@ const q = function(r, e) {
353
354
  highlight: pe,
354
355
  textStyle: fe
355
356
  }
356
- }, be = function(r) {
357
- const e = {
357
+ }, ye = function(r) {
358
+ const t = {
358
359
  "&": "&amp;",
359
360
  "<": "&lt;",
360
361
  ">": "&gt;",
361
362
  '"': "&quot;",
362
363
  "'": "&#39;"
363
- }, t = /[&<>"']/g, o = new RegExp(t.source);
364
- return r && o.test(r) ? r.replace(t, (s) => e[s]) : r;
364
+ }, e = /[&<>"']/g, o = new RegExp(e.source);
365
+ return r && o.test(r) ? r.replace(e, (s) => t[s]) : r;
365
366
  };
366
367
  let S = !1;
367
- class ye {
368
- constructor(e) {
369
- g(this, "marks"), g(this, "nodes"), e || (e = he), this.marks = e.marks || [], this.nodes = e.nodes || [];
368
+ class be {
369
+ constructor(t) {
370
+ g(this, "marks"), g(this, "nodes"), t || (t = he), this.marks = t.marks || [], this.nodes = t.nodes || [];
370
371
  }
371
- addNode(e, t) {
372
- this.nodes[e] = t;
372
+ addNode(t, e) {
373
+ this.nodes[t] = e;
373
374
  }
374
- addMark(e, t) {
375
- this.marks[e] = t;
375
+ addMark(t, e) {
376
+ this.marks[t] = e;
376
377
  }
377
- render(e, t = { optimizeImages: !1 }, o = !0) {
378
+ render(t, e = { optimizeImages: !1 }, o = !0) {
378
379
  if (!S && o && (console.warn(
379
380
  "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/"
380
- ), S = !0), e && e.content && Array.isArray(e.content)) {
381
+ ), S = !0), t && t.content && Array.isArray(t.content)) {
381
382
  let s = "";
382
- return e.content.forEach((n) => {
383
+ return t.content.forEach((n) => {
383
384
  s += this.renderNode(n);
384
- }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
385
+ }), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
385
386
  }
386
387
  return console.warn(
387
388
  `The render method must receive an Object with a "content" field.
@@ -410,55 +411,55 @@ class ye {
410
411
  }`
411
412
  ), "";
412
413
  }
413
- optimizeImages(e, t) {
414
+ optimizeImages(t, e) {
414
415
  let o = 0, s = 0, n = "", a = "";
415
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, o = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, s = 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 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
416
+ typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (n += `width="${e.width}" `, o = e.width), typeof e.height == "number" && e.height > 0 && (n += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (n += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (n += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (a += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (a += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-F]{6}/gi) || e.filters.fill === "transparent") && (a += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (a += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (a += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (a += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (a += `:rotate(${e.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (t = t.replace(/<img/g, `<img ${n.trim()}`));
416
417
  const l = o > 0 || s > 0 || a.length > 0 ? `${o}x${s}${a}` : "";
417
- return e = e.replace(
418
+ return t = t.replace(
418
419
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
419
420
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
420
- ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
421
+ ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
421
422
  var c, u;
422
423
  const p = i.match(
423
424
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
424
425
  );
425
426
  if (p && p.length > 0) {
426
427
  const f = {
427
- srcset: (c = t.srcset) == null ? void 0 : c.map((d) => {
428
+ srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
428
429
  if (typeof d == "number")
429
430
  return `//${p}/m/${d}x0${a} ${d}w`;
430
431
  if (typeof d == "object" && d.length === 2) {
431
- let b = 0, m = 0;
432
- return typeof d[0] == "number" && (b = d[0]), typeof d[1] == "number" && (m = d[1]), `//${p}/m/${b}x${m}${a} ${b}w`;
432
+ let y = 0, m = 0;
433
+ return typeof d[0] == "number" && (y = d[0]), typeof d[1] == "number" && (m = d[1]), `//${p}/m/${y}x${m}${a} ${y}w`;
433
434
  }
434
435
  return "";
435
436
  }).join(", "),
436
- sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
437
+ sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
437
438
  };
438
439
  let h = "";
439
440
  return f.srcset && (h += `srcset="${f.srcset}" `), f.sizes && (h += `sizes="${f.sizes}" `), i.replace(/<img/g, `<img ${h.trim()}`);
440
441
  }
441
442
  return i;
442
- })), e;
443
+ })), t;
443
444
  }
444
- renderNode(e) {
445
- const t = [];
446
- e.marks && e.marks.forEach((s) => {
445
+ renderNode(t) {
446
+ const e = [];
447
+ t.marks && t.marks.forEach((s) => {
447
448
  const n = this.getMatchingMark(s);
448
- n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
449
+ n && n.tag !== "" && e.push(this.renderOpeningTag(n.tag));
449
450
  });
450
- const o = this.getMatchingNode(e);
451
- return o && o.tag && t.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((s) => {
452
- t.push(this.renderNode(s));
453
- }) : e.text ? t.push(be(e.text)) : o && o.singleTag ? t.push(this.renderTag(o.singleTag, " /")) : o && o.html ? t.push(o.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), o && o.tag && t.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
451
+ const o = this.getMatchingNode(t);
452
+ return o && o.tag && e.push(this.renderOpeningTag(o.tag)), t.content ? t.content.forEach((s) => {
453
+ e.push(this.renderNode(s));
454
+ }) : t.text ? e.push(ye(t.text)) : o && o.singleTag ? e.push(this.renderTag(o.singleTag, " /")) : o && o.html ? e.push(o.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), o && o.tag && e.push(this.renderClosingTag(o.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
454
455
  const n = this.getMatchingMark(s);
455
- n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
456
- }), t.join("");
456
+ n && n.tag !== "" && e.push(this.renderClosingTag(n.tag));
457
+ }), e.join("");
457
458
  }
458
- renderTag(e, t) {
459
- return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
459
+ renderTag(t, e) {
460
+ return t.constructor === String ? `<${t}${e}>` : t.map((o) => {
460
461
  if (o.constructor === String)
461
- return `<${o}${t}>`;
462
+ return `<${o}${e}>`;
462
463
  {
463
464
  let s = `<${o.tag}`;
464
465
  if (o.attrs) {
@@ -468,108 +469,111 @@ class ye {
468
469
  a !== null && (s += ` ${n}="${a}"`);
469
470
  }
470
471
  }
471
- return `${s}${t}>`;
472
+ return `${s}${e}>`;
472
473
  }
473
474
  }).join("");
474
475
  }
475
- renderOpeningTag(e) {
476
- return this.renderTag(e, "");
476
+ renderOpeningTag(t) {
477
+ return this.renderTag(t, "");
477
478
  }
478
- renderClosingTag(e) {
479
- return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
479
+ renderClosingTag(t) {
480
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
480
481
  }
481
- getMatchingNode(e) {
482
- const t = this.nodes[e.type];
483
- if (typeof t == "function")
484
- return t(e);
482
+ getMatchingNode(t) {
483
+ const e = this.nodes[t.type];
484
+ if (typeof e == "function")
485
+ return e(t);
485
486
  }
486
- getMatchingMark(e) {
487
- const t = this.marks[e.type];
488
- if (typeof t == "function")
489
- return t(e);
487
+ getMatchingMark(t) {
488
+ const e = this.marks[t.type];
489
+ if (typeof e == "function")
490
+ return e(t);
490
491
  }
491
- renderEmoji(e) {
492
- if (e.attrs.emoji)
493
- return e.attrs.emoji;
494
- const t = [
492
+ renderEmoji(t) {
493
+ if (t.attrs.emoji)
494
+ return t.attrs.emoji;
495
+ const e = [
495
496
  {
496
497
  tag: "img",
497
498
  attrs: {
498
- src: e.attrs.fallbackImage,
499
+ src: t.attrs.fallbackImage,
499
500
  draggable: "false",
500
501
  loading: "lazy",
501
502
  align: "absmiddle"
502
503
  }
503
504
  }
504
505
  ];
505
- return this.renderTag(t, " /");
506
+ return this.renderTag(e, " /");
506
507
  }
507
508
  }
508
- const me = ye, xe = (r) => {
509
+ const Te = (r) => {
509
510
  if (typeof r != "object" || typeof r._editable > "u")
510
511
  return {};
511
512
  try {
512
- const e = JSON.parse(
513
+ const t = JSON.parse(
513
514
  r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
514
515
  );
515
- return e ? {
516
- "data-blok-c": JSON.stringify(e),
517
- "data-blok-uid": e.id + "-" + e.uid
516
+ return t ? {
517
+ "data-blok-c": JSON.stringify(t),
518
+ "data-blok-uid": `${t.id}-${t.uid}`
518
519
  } : {};
519
520
  } catch {
520
521
  return {};
521
522
  }
522
523
  };
523
- let ke, we = "https://app.storyblok.com/f/storyblok-v2-latest.js";
524
- const $e = (r, e) => {
525
- r.addNode("blok", (t) => {
524
+ let me, ke = "https://app.storyblok.com/f/storyblok-v2-latest.js";
525
+ const we = (r, t) => {
526
+ r.addNode("blok", (e) => {
526
527
  let o = "";
527
- return t.attrs.body.forEach((s) => {
528
- o += e(s.component, s);
528
+ return e.attrs.body.forEach((s) => {
529
+ o += t(s.component, s);
529
530
  }), {
530
531
  html: o
531
532
  };
532
533
  });
533
- }, ve = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ce = (r, e, t) => {
534
- let o = t || ke;
534
+ }, $e = (r) => {
535
+ var t;
536
+ return !r || !((t = r == null ? void 0 : r.content) != null && t.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule"));
537
+ }, ve = (r, t, e) => {
538
+ let o = e || me;
535
539
  if (!o) {
536
540
  console.error(
537
541
  "Please initialize the Storyblok SDK before calling the renderRichText function"
538
542
  );
539
543
  return;
540
544
  }
541
- return ve(r) ? "" : (e && (o = new me(e.schema), e.resolver && $e(o, e.resolver)), o.render(r, {}, !1));
542
- }, Ae = () => B(we);
543
- function Ee() {
545
+ return $e(r) ? "" : (t && (o = new be(t.schema), t.resolver && we(o, t.resolver)), o.render(r, {}, !1));
546
+ }, xe = () => B(ke);
547
+ function Ae() {
544
548
  if (!(globalThis != null && globalThis.storyblokApiInstance))
545
549
  throw new Error("storyblokApiInstance has not been initialized correctly");
546
550
  return globalThis.storyblokApiInstance;
547
551
  }
548
- async function Le(r) {
549
- let e = null;
550
- return r && r.locals._storyblok_preview_data && (e = r.locals._storyblok_preview_data), e;
552
+ async function Ee(r) {
553
+ let t = null;
554
+ return r && r.locals._storyblok_preview_data && (t = r.locals._storyblok_preview_data), t;
551
555
  }
552
- function Re(r, e) {
556
+ function Le(r, t) {
553
557
  var o;
554
- const t = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
555
- if (!t)
558
+ const e = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
559
+ if (!e)
556
560
  throw new Error(
557
561
  "Please initialize the Storyblok SDK before calling the renderRichText function"
558
562
  );
559
- return Ce(r, e, t);
563
+ return ve(r, t, e);
560
564
  }
561
- function Ie(r) {
565
+ function Ce(r) {
562
566
  return typeof r == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});` : "const storyblokInstance = new StoryblokBridge();";
563
567
  }
564
568
  function je(r) {
565
- const e = {
569
+ const t = {
566
570
  useCustomApi: !1,
567
571
  bridge: !0,
568
572
  componentsDir: "src",
569
573
  enableFallbackComponent: !1,
570
574
  livePreview: !1,
571
575
  ...r
572
- }, t = Ie(e.bridge);
576
+ }, e = Ce(t.bridge);
573
577
  return {
574
578
  name: "@storyblok/astro",
575
579
  hooks: {
@@ -584,20 +588,20 @@ function je(r) {
584
588
  vite: {
585
589
  plugins: [
586
590
  N(
587
- e.accessToken,
588
- e.useCustomApi,
589
- e.apiOptions
591
+ t.accessToken,
592
+ t.useCustomApi,
593
+ t.apiOptions
590
594
  ),
591
595
  _(
592
- e.componentsDir,
593
- e.components,
594
- e.enableFallbackComponent,
595
- e.customFallbackComponent
596
+ t.componentsDir,
597
+ t.components,
598
+ t.enableFallbackComponent,
599
+ t.customFallbackComponent
596
600
  ),
597
- z(e)
601
+ z(t)
598
602
  ]
599
603
  }
600
- }), e.livePreview && (l == null ? void 0 : l.output) !== "server")
604
+ }), t.livePreview && (l == null ? void 0 : l.output) !== "server")
601
605
  throw new Error(
602
606
  "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."
603
607
  );
@@ -607,12 +611,12 @@ function je(r) {
607
611
  import { storyblokApiInstance } from "virtual:storyblok-init";
608
612
  globalThis.storyblokApiInstance = storyblokApiInstance;
609
613
  `
610
- ), e.bridge && !e.livePreview && o(
614
+ ), t.bridge && !t.livePreview && o(
611
615
  "page",
612
616
  `import { loadStoryblokBridge } from "@storyblok/astro";
613
617
  loadStoryblokBridge().then(() => {
614
618
  const { StoryblokBridge, location } = window;
615
- ${t}
619
+ ${e}
616
620
  storyblokInstance.on(["published", "change"], (event) => {
617
621
  if (!event.slugChanged) {
618
622
  location.reload(true);
@@ -620,12 +624,12 @@ function je(r) {
620
624
  });
621
625
  });
622
626
  `
623
- ), e.livePreview && (o(
627
+ ), t.livePreview && (o(
624
628
  "page",
625
629
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
626
630
  loadStoryblokBridge().then(() => {
627
631
  const { StoryblokBridge, location } = window;
628
- ${t}
632
+ ${e}
629
633
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
630
634
  });
631
635
  `
@@ -643,31 +647,31 @@ function je(r) {
643
647
  };
644
648
  }
645
649
  let T;
646
- async function Me(r) {
647
- const { action: e, story: t } = r || {};
648
- if (e === "input" && t) {
650
+ async function Re(r) {
651
+ const { action: t, story: e } = r || {};
652
+ if (t === "input" && e) {
649
653
  const o = async () => {
650
- const n = await Te(t), a = document.body;
654
+ const n = await Se(e), a = document.body;
651
655
  if (n.outerHTML === a.outerHTML)
652
656
  return;
653
657
  const l = document.querySelector('[data-blok-focused="true"]');
654
- Se(a, n, l), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
658
+ Ie(a, n, l), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
655
659
  };
656
660
  clearTimeout(T), T = setTimeout(o, 500);
657
661
  }
658
662
  ["published", "change"].includes(r == null ? void 0 : r.action) && location.reload();
659
663
  }
660
- function Se(r, e, t) {
661
- if (t) {
662
- const o = t.getAttribute("data-blok-uid"), s = e.querySelector(
664
+ function Ie(r, t, e) {
665
+ if (e) {
666
+ const o = e.getAttribute("data-blok-uid"), s = t.querySelector(
663
667
  `[data-blok-uid="${o}"]`
664
668
  );
665
- s && (s.setAttribute("data-blok-focused", "true"), t.replaceWith(s));
669
+ s && (s.setAttribute("data-blok-focused", "true"), e.replaceWith(s));
666
670
  } else
667
- r.replaceWith(e);
671
+ r.replaceWith(t);
668
672
  }
669
- async function Te(r) {
670
- const t = await (await fetch(location.href, {
673
+ async function Se(r) {
674
+ const e = await (await fetch(location.href, {
671
675
  method: "POST",
672
676
  body: JSON.stringify({
673
677
  ...r,
@@ -677,17 +681,17 @@ async function Te(r) {
677
681
  "Content-Type": "application/json"
678
682
  }
679
683
  })).text();
680
- return new DOMParser().parseFromString(t, "text/html").body;
684
+ return new DOMParser().parseFromString(e, "text/html").body;
681
685
  }
682
686
  export {
683
- me as RichTextResolver,
687
+ be as RichTextResolver,
684
688
  he as RichTextSchema,
685
- Le as getLiveStory,
686
- Me as handleStoryblokMessage,
687
- Ae as loadStoryblokBridge,
688
- Re as renderRichText,
689
+ Ee as getLiveStory,
690
+ Re as handleStoryblokMessage,
691
+ xe as loadStoryblokBridge,
692
+ Le as renderRichText,
689
693
  je as storyblok,
690
- xe as storyblokEditable,
694
+ Te as storyblokEditable,
691
695
  v as toCamelCase,
692
- Ee as useStoryblokApi
696
+ Ae as useStoryblokApi
693
697
  };
@@ -1,4 +1,4 @@
1
- (function(u,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(u=typeof globalThis<"u"?globalThis:u||self,b(u.storyblokAstro={}))})(this,function(u){"use strict";const b=`<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">
1
+ (function(u,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(u=typeof globalThis<"u"?globalThis:u||self,y(u.storyblokAstro={}))})(this,function(u){"use strict";const y=`<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,17 +7,17 @@
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`,j=/[\p{Lu}]/u,M=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,y=/[_.\- ]+/,P=new RegExp("^"+y.source),C=new RegExp(y.source+v.source,"gu"),S=new RegExp("\\d+"+v.source,"gu"),O=(r,e,t,o)=>{let s=!1,n=!1,a=!1,l=!1;for(let i=0;i<r.length;i++){const c=r[i];l=i>2?r[i-3]==="-":!0,s&&j.test(c)?(r=r.slice(0,i)+"-"+r.slice(i),s=!1,a=n,n=!0,i++):n&&a&&M.test(c)&&(!l||o)?(r=r.slice(0,i-1)+"-"+r.slice(i-1),a=n,n=!1,s=!0):(s=e(c)===c&&t(c)!==c,a=n,n=t(c)===c&&e(c)!==c)}return r},_=(r,e)=>($.lastIndex=0,r.replaceAll($,t=>e(t))),N=(r,e)=>(C.lastIndex=0,S.lastIndex=0,r.replaceAll(S,(t,o,s)=>["_","-"].includes(r.charAt(s+t.length))?t:e(t)).replaceAll(C,(t,o)=>e(o)));function z(r,e){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(n=>n.trim()).filter(n=>n.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),o=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return r.length===1?y.test(r)?"":e.pascalCase?o(r):t(r):(r!==t(r)&&(r=O(r,t,o,e.preserveConsecutiveUppercase)),r=r.replace(P,""),r=e.preserveConsecutiveUppercase?_(r,t):t(r),e.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),N(r,o))}function m(r){return z(r)}function B(r,e={},t,o){const s="virtual:storyblok-components",n=`\0${s}`;return{name:"vite-plugin-storyblok-components",async resolveId(a){if(a===s)return n},async load(a){if(a===n){const l=[],i=[];for await(const[d,f]of Object.entries(e)){const h=await this.resolve(`/${r}/${f}.astro`);if(h)l.push(`import ${m(d)} from "${h.id}"`);else if(t)i.push(d);else throw new Error(`Component could not be found for blok "${d}"! Does "${`/${r}/${f}`}.astro" exist?`)}let c="";if(t)if(c=",FallbackComponent",o){const d=await this.resolve(`/${r}/${o}.astro`);if(!d)throw new Error(`Custom fallback component could not be found. Does "${`/${r}/${o}`}.astro" exist?`);l.push(`import FallbackComponent from "${d.id}"`)}else l.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(e).length)return`${l.join(";")};export default {${Object.keys(e).filter(d=>!i.includes(d)).map(d=>m(d)).join(",")}${c}}`;if(t)return`${l[0]}; export default {${c.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
+ </svg>`,R=/[\p{Lu}]/u,M=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,b=/[_.\- ]+/,P=new RegExp("^"+b.source),C=new RegExp(b.source+v.source,"gu"),S=new RegExp("\\d+"+v.source,"gu"),O=(r,t,e,o)=>{let s=!1,n=!1,a=!1,l=!1;for(let i=0;i<r.length;i++){const c=r[i];l=i>2?r[i-3]==="-":!0,s&&R.test(c)?(r=r.slice(0,i)+"-"+r.slice(i),s=!1,a=n,n=!0,i++):n&&a&&M.test(c)&&(!l||o)?(r=r.slice(0,i-1)+"-"+r.slice(i-1),a=n,n=!1,s=!0):(s=t(c)===c&&e(c)!==c,a=n,n=e(c)===c&&t(c)!==c)}return r},_=(r,t)=>($.lastIndex=0,r.replaceAll($,e=>t(e))),N=(r,t)=>(C.lastIndex=0,S.lastIndex=0,r.replaceAll(S,(e,o,s)=>["_","-"].includes(r.charAt(s+e.length))?e:t(e)).replaceAll(C,(e,o)=>t(o)));function z(r,t){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(r)?r=r.map(n=>n.trim()).filter(n=>n.length).join("-"):r=r.trim(),r.length===0)return"";const e=t.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(t.locale),o=t.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(t.locale);return r.length===1?b.test(r)?"":t.pascalCase?o(r):e(r):(r!==e(r)&&(r=O(r,e,o,t.preserveConsecutiveUppercase)),r=r.replace(P,""),r=t.preserveConsecutiveUppercase?_(r,e):e(r),t.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),N(r,o))}function m(r){return z(r)}function B(r,t={},e,o){const s="virtual:storyblok-components",n=`\0${s}`;return{name:"vite-plugin-storyblok-components",async resolveId(a){if(a===s)return n},async load(a){if(a===n){const l=[],i=[];for await(const[d,f]of Object.entries(t)){const h=await this.resolve(`/${r}/${f}.astro`);if(h)l.push(`import ${m(d)} from "${h.id}"`);else if(e)i.push(d);else throw new Error(`Component could not be found for blok "${d}"! Does "${`/${r}/${f}`}.astro" exist?`)}let c="";if(e)if(c=",FallbackComponent",o){const d=await this.resolve(`/${r}/${o}.astro`);if(!d)throw new Error(`Custom fallback component could not be found. Does "${`/${r}/${o}`}.astro" exist?`);l.push(`import FallbackComponent from "${d.id}"`)}else l.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${l.join(";")};export default {${Object.keys(t).filter(d=>!i.includes(d)).map(d=>m(d)).join(",")}${c}}`;if(e)return`${l[0]}; export default {${c.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 F(r,e,t){const o="virtual:storyblok-init",s=`\0${o}`;return{name:"vite-plugin-storyblok-init",async resolveId(n){if(n===o)return s},async load(n){if(n===s)return`
12
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function F(r,t,e){const o="virtual:storyblok-init",s=`\0${o}`;return{name:"vite-plugin-storyblok-init",async resolveId(n){if(n===o)return s},async load(n){if(n===s)return`
13
13
  import { storyblokInit, apiPlugin } from "@storyblok/js";
14
14
  const { storyblokApi } = storyblokInit({
15
15
  accessToken: "${r}",
16
- use: ${e?"[]":"[apiPlugin]"},
17
- apiOptions: ${JSON.stringify(t)},
16
+ use: ${t?"[]":"[apiPlugin]"},
17
+ apiOptions: ${JSON.stringify(e)},
18
18
  });
19
19
  export const storyblokApiInstance = storyblokApi;
20
- `}}}function D(r){const e="virtual:storyblok-options",t=`\0${e}`;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===e)return t},async load(o){if(o===t)return`export default ${JSON.stringify(r)}`}}}let I=!1;const T=[],U=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?s():T.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>t(s),o.onload=s=>{T.forEach(n=>n()),I=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(o)});var q=Object.defineProperty,H=(r,e,t)=>e in r?q(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>H(r,typeof e!="symbol"?e+"":e,t);let W=class{constructor(){p(this,"isCDNUrl",(r="")=>r.includes("/cdn/")),p(this,"getOptionsPage",(r,e=25,t=1)=>({...r,per_page:e,page:t})),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)=>{const t=Math.abs(e-r)||0,o=r<e?1:-1;return this.arrayFrom(t,(s,n)=>n*o+r)}),p(this,"asyncMap",async(r,e)=>Promise.all(r.map(e))),p(this,"flatMap",(r=[],e)=>r.map(e).reduce((t,o)=>[...t,...o],[])),p(this,"escapeHTML",function(r){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,o=new RegExp(t.source);return r&&o.test(r)?r.replace(t,s=>e[s]):r})}stringify(r,e,t){const o=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const n=r[s],a=t?"":encodeURIComponent(s);let l;typeof n=="object"?l=this.stringify(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):l=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")}getRegionURL(r){const e="api.storyblok.com",t="api-us.storyblok.com",o="app.storyblokchina.cn",s="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(r){case"us":return t;case"cn":return o;case"ap":return s;case"ca":return n;default:return e}}};const J=function(r,e){const t={};for(const o in r){const s=r[o];e.includes(o)&&s!==null&&(t[o]=s)}return t},V=r=>r==="email",K=()=>({singleTag:"hr"}),Z=()=>({tag:"blockquote"}),G=()=>({tag:"ul"}),X=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),Y=()=>({singleTag:"br"}),Q=r=>({tag:`h${r.attrs.level}`}),ee=r=>({singleTag:[{tag:"img",attrs:J(r.attrs,["src","alt","title"])}]}),te=()=>({tag:"li"}),re=()=>({tag:"ol"}),oe=()=>({tag:"p"}),se=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),ne=()=>({tag:"b"}),ae=()=>({tag:"s"}),le=()=>({tag:"u"}),ie=()=>({tag:"strong"}),ce=()=>({tag:"code"}),ue=()=>({tag:"i"}),de=r=>{if(!r.attrs)return{tag:""};const e=new W().escapeHTML,t={...r.attrs},{linktype:o="url"}=r.attrs;if(delete t.linktype,t.href&&(t.href=e(r.attrs.href||"")),V(o)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ge=r=>({tag:[{tag:"span",attrs:r.attrs}]}),pe=()=>({tag:"sub"}),fe=()=>({tag:"sup"}),he=r=>({tag:[{tag:"span",attrs:r.attrs}]}),be=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},ye=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},A={nodes:{horizontal_rule:K,blockquote:Z,bullet_list:G,code_block:X,hard_break:Y,heading:Q,image:ee,list_item:te,ordered_list:re,paragraph:oe,emoji:se},marks:{bold:ne,strike:ae,underline:le,strong:ie,code:ce,italic:ue,link:de,styled:ge,subscript:pe,superscript:fe,anchor:he,highlight:be,textStyle:ye}},me=function(r){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,o=new RegExp(t.source);return r&&o.test(r)?r.replace(t,s=>e[s]):r};let E=!1;class ke{constructor(e){p(this,"marks"),p(this,"nodes"),e||(e=A),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},o=!0){if(!E&&o&&(console.warn("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/"),E=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(n=>{s+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
20
+ `}}}function D(r){const t="virtual:storyblok-options",e=`\0${t}`;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===t)return e},async load(o){if(o===e)return`export default ${JSON.stringify(r)}`}}}let I=!1;const T=[],U=r=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?s():T.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>e(s),o.onload=s=>{T.forEach(n=>n()),I=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(o)});var q=Object.defineProperty,H=(r,t,e)=>t in r?q(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,p=(r,t,e)=>H(r,typeof t!="symbol"?t+"":t,e);let J=class{constructor(){p(this,"isCDNUrl",(r="")=>r.includes("/cdn/")),p(this,"getOptionsPage",(r,t=25,e=1)=>({...r,per_page:t,page:e})),p(this,"delay",r=>new Promise(t=>setTimeout(t,r))),p(this,"arrayFrom",(r=0,t)=>Array.from({length:r},t)),p(this,"range",(r=0,t=r)=>{const e=Math.abs(t-r)||0,o=r<t?1:-1;return this.arrayFrom(e,(s,n)=>n*o+r)}),p(this,"asyncMap",async(r,t)=>Promise.all(r.map(t))),p(this,"flatMap",(r=[],t)=>r.map(t).reduce((e,o)=>[...e,...o],[])),p(this,"escapeHTML",function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,o=new RegExp(e.source);return r&&o.test(r)?r.replace(e,s=>t[s]):r})}stringify(r,t,e){const o=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const n=r[s],a=e?"":encodeURIComponent(s);let l;typeof n=="object"?l=this.stringify(n,t?t+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):l=`${t?t+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")}getRegionURL(r){const t="api.storyblok.com",e="api-us.storyblok.com",o="app.storyblokchina.cn",s="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(r){case"us":return e;case"cn":return o;case"ap":return s;case"ca":return n;default:return t}}};const W=function(r,t){const e={};for(const o in r){const s=r[o];t.includes(o)&&s!==null&&(e[o]=s)}return e},V=r=>r==="email",Z=()=>({singleTag:"hr"}),G=()=>({tag:"blockquote"}),K=()=>({tag:"ul"}),Q=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),Y=()=>({singleTag:"br"}),X=r=>({tag:`h${r.attrs.level}`}),ee=r=>({singleTag:[{tag:"img",attrs:W(r.attrs,["src","alt","title"])}]}),te=()=>({tag:"li"}),re=()=>({tag:"ol"}),oe=()=>({tag:"p"}),se=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),ne=()=>({tag:"b"}),ae=()=>({tag:"s"}),le=()=>({tag:"u"}),ie=()=>({tag:"strong"}),ce=()=>({tag:"code"}),ue=()=>({tag:"i"}),de=r=>{if(!r.attrs)return{tag:""};const t=new J().escapeHTML,e={...r.attrs},{linktype:o="url"}=r.attrs;if(delete e.linktype,e.href&&(e.href=t(r.attrs.href||"")),V(o)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const s in e.custom)e[s]=e.custom[s];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},ge=r=>({tag:[{tag:"span",attrs:r.attrs}]}),pe=()=>({tag:"sub"}),fe=()=>({tag:"sup"}),he=r=>({tag:[{tag:"span",attrs:r.attrs}]}),ye=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},be=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},A={nodes:{horizontal_rule:Z,blockquote:G,bullet_list:K,code_block:Q,hard_break:Y,heading:X,image:ee,list_item:te,ordered_list:re,paragraph:oe,emoji:se},marks:{bold:ne,strike:ae,underline:le,strong:ie,code:ce,italic:ue,link:de,styled:ge,subscript:pe,superscript:fe,anchor:he,highlight:ye,textStyle:be}},me=function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,o=new RegExp(e.source);return r&&o.test(r)?r.replace(e,s=>t[s]):r};let E=!1;class L{constructor(t){p(this,"marks"),p(this,"nodes"),t||(t=A),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1},o=!0){if(!E&&o&&(console.warn("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/"),E=!0),t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(n=>{s+=this.renderNode(n)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
21
21
  The "content" field must be an array of nodes as the type ISbRichtext.
22
22
  ISbRichtext:
23
23
  content?: ISbRichtext[]
@@ -40,23 +40,23 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
40
40
  }
41
41
  ],
42
42
  type: 'doc'
43
- }`),""}optimizeImages(e,t){let o=0,s=0,n="",a="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,o=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,s=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&&(a+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(a+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(a+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(a+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(a+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(a+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(a+=`:rotate(${t.filters.rotate})`),a.length>0&&(a=`/filters${a}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=o>0||s>0||a.length>0?`${o}x${s}${a}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,i=>{var c,d;const f=i.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(f&&f.length>0){const h={srcset:(c=t.srcset)==null?void 0:c.map(g=>{if(typeof g=="number")return`//${f}/m/${g}x0${a} ${g}w`;if(typeof g=="object"&&g.length===2){let w=0,R=0;return typeof g[0]=="number"&&(w=g[0]),typeof g[1]=="number"&&(R=g[1]),`//${f}/m/${w}x${R}${a} ${w}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(g=>g).join(", ")};let k="";return h.srcset&&(k+=`srcset="${h.srcset}" `),h.sizes&&(k+=`sizes="${h.sizes}" `),i.replace(/<img/g,`<img ${k.trim()}`)}return i})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&t.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(me(e.text)):o&&o.singleTag?t.push(this.renderTag(o.singleTag," /")):o&&o.html?t.push(o.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),o&&o.tag&&t.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(o=>{if(o.constructor===String)return`<${o}${t}>`;{let s=`<${o.tag}`;if(o.attrs){for(const n in o.attrs)if(Object.prototype.hasOwnProperty.call(o.attrs,n)){const a=o.attrs[n];a!==null&&(s+=` ${n}="${a}"`)}}return`${s}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const L=ke,we=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let $e,ve="https://app.storyblok.com/f/storyblok-v2-latest.js";const Ce=(r,e)=>{r.addNode("blok",t=>{let o="";return t.attrs.body.forEach(s=>{o+=e(s.component,s)}),{html:o}})},Se=r=>!r||!(r!=null&&r.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ie=(r,e,t)=>{let o=t||$e;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Se(r)?"":(e&&(o=new L(e.schema),e.resolver&&Ce(o,e.resolver)),o.render(r,{},!1))},Te=()=>U(ve);function Ae(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function Ee(r){let e=null;return r&&r.locals._storyblok_preview_data&&(e=r.locals._storyblok_preview_data),e}function Le(r,e){var o;const t=(o=globalThis==null?void 0:globalThis.storyblokApiInstance)==null?void 0:o.richTextResolver;if(!t)throw new Error("Please initialize the Storyblok SDK before calling the renderRichText function");return Ie(r,e,t)}function xe(r){return typeof r=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});`:"const storyblokInstance = new StoryblokBridge();"}function Re(r){const e={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...r},t=xe(e.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:o,updateConfig:s,addDevToolbarApp:n,addMiddleware:a,config:l})=>{if(s({vite:{plugins:[F(e.accessToken,e.useCustomApi,e.apiOptions),B(e.componentsDir,e.components,e.enableFallbackComponent,e.customFallbackComponent),D(e)]}}),e.livePreview&&(l==null?void 0:l.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.");o("page-ssr",`
43
+ }`),""}optimizeImages(t,e){let o=0,s=0,n="",a="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(n+=`width="${e.width}" `,o=e.width),typeof e.height=="number"&&e.height>0&&(n+=`height="${e.height}" `,s=e.height),(e.loading==="lazy"||e.loading==="eager")&&(n+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(n+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(a+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(a+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-F]{6}/gi)||e.filters.fill==="transparent")&&(a+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(a+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(a+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(a+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(a+=`:rotate(${e.filters.rotate})`),a.length>0&&(a=`/filters${a}`))),n.length>0&&(t=t.replace(/<img/g,`<img ${n.trim()}`));const l=o>0||s>0||a.length>0?`${o}x${s}${a}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,i=>{var c,d;const f=i.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(f&&f.length>0){const h={srcset:(c=e.srcset)==null?void 0:c.map(g=>{if(typeof g=="number")return`//${f}/m/${g}x0${a} ${g}w`;if(typeof g=="object"&&g.length===2){let w=0,j=0;return typeof g[0]=="number"&&(w=g[0]),typeof g[1]=="number"&&(j=g[1]),`//${f}/m/${w}x${j}${a} ${w}w`}return""}).join(", "),sizes:(d=e.sizes)==null?void 0:d.map(g=>g).join(", ")};let k="";return h.srcset&&(k+=`srcset="${h.srcset}" `),h.sizes&&(k+=`sizes="${h.sizes}" `),i.replace(/<img/g,`<img ${k.trim()}`)}return i})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&e.push(this.renderOpeningTag(n.tag))});const o=this.getMatchingNode(t);return o&&o.tag&&e.push(this.renderOpeningTag(o.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(me(t.text)):o&&o.singleTag?e.push(this.renderTag(o.singleTag," /")):o&&o.html?e.push(o.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),o&&o.tag&&e.push(this.renderClosingTag(o.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&e.push(this.renderClosingTag(n.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(o=>{if(o.constructor===String)return`<${o}${e}>`;{let s=`<${o.tag}`;if(o.attrs){for(const n in o.attrs)if(Object.prototype.hasOwnProperty.call(o.attrs,n)){const a=o.attrs[n];a!==null&&(s+=` ${n}="${a}"`)}}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}const ke=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let we,$e="https://app.storyblok.com/f/storyblok-v2-latest.js";const ve=(r,t)=>{r.addNode("blok",e=>{let o="";return e.attrs.body.forEach(s=>{o+=t(s.component,s)}),{html:o}})},Ce=r=>{var t;return!r||!((t=r==null?void 0:r.content)!=null&&t.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule"))},Se=(r,t,e)=>{let o=e||we;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ce(r)?"":(t&&(o=new L(t.schema),t.resolver&&ve(o,t.resolver)),o.render(r,{},!1))},Ie=()=>U($e);function Te(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function Ae(r){let t=null;return r&&r.locals._storyblok_preview_data&&(t=r.locals._storyblok_preview_data),t}function Ee(r,t){var o;const e=(o=globalThis==null?void 0:globalThis.storyblokApiInstance)==null?void 0:o.richTextResolver;if(!e)throw new Error("Please initialize the Storyblok SDK before calling the renderRichText function");return Se(r,t,e)}function Le(r){return typeof r=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});`:"const storyblokInstance = new StoryblokBridge();"}function xe(r){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...r},e=Le(t.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:o,updateConfig:s,addDevToolbarApp:n,addMiddleware:a,config:l})=>{if(s({vite:{plugins:[F(t.accessToken,t.useCustomApi,t.apiOptions),B(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),D(t)]}}),t.livePreview&&(l==null?void 0:l.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.");o("page-ssr",`
44
44
  import { storyblokApiInstance } from "virtual:storyblok-init";
45
45
  globalThis.storyblokApiInstance = storyblokApiInstance;
46
- `),e.bridge&&!e.livePreview&&o("page",`import { loadStoryblokBridge } from "@storyblok/astro";
46
+ `),t.bridge&&!t.livePreview&&o("page",`import { loadStoryblokBridge } from "@storyblok/astro";
47
47
  loadStoryblokBridge().then(() => {
48
48
  const { StoryblokBridge, location } = window;
49
- ${t}
49
+ ${e}
50
50
  storyblokInstance.on(["published", "change"], (event) => {
51
51
  if (!event.slugChanged) {
52
52
  location.reload(true);
53
53
  }
54
54
  });
55
55
  });
56
- `),e.livePreview&&(o("page",`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
56
+ `),t.livePreview&&(o("page",`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
57
57
  loadStoryblokBridge().then(() => {
58
58
  const { StoryblokBridge, location } = window;
59
- ${t}
59
+ ${e}
60
60
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
61
61
  });
62
- `),a({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),n({id:"storyblok",name:"Storyblok",icon:b,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let x;async function je(r){const{action:e,story:t}=r||{};if(e==="input"&&t){const o=async()=>{const n=await Pe(t),a=document.body;if(n.outerHTML===a.outerHTML)return;const l=document.querySelector('[data-blok-focused="true"]');Me(a,n,l),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(x),x=setTimeout(o,500)}["published","change"].includes(r==null?void 0:r.action)&&location.reload()}function Me(r,e,t){if(t){const o=t.getAttribute("data-blok-uid"),s=e.querySelector(`[data-blok-uid="${o}"]`);s&&(s.setAttribute("data-blok-focused","true"),t.replaceWith(s))}else r.replaceWith(e)}async function Pe(r){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...r,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}u.RichTextResolver=L,u.RichTextSchema=A,u.getLiveStory=Ee,u.handleStoryblokMessage=je,u.loadStoryblokBridge=Te,u.renderRichText=Le,u.storyblok=Re,u.storyblokEditable=we,u.toCamelCase=m,u.useStoryblokApi=Ae,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
62
+ `),a({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),n({id:"storyblok",name:"Storyblok",icon:y,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let x;async function je(r){const{action:t,story:e}=r||{};if(t==="input"&&e){const o=async()=>{const n=await Me(e),a=document.body;if(n.outerHTML===a.outerHTML)return;const l=document.querySelector('[data-blok-focused="true"]');Re(a,n,l),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(x),x=setTimeout(o,500)}["published","change"].includes(r==null?void 0:r.action)&&location.reload()}function Re(r,t,e){if(e){const o=e.getAttribute("data-blok-uid"),s=t.querySelector(`[data-blok-uid="${o}"]`);s&&(s.setAttribute("data-blok-focused","true"),e.replaceWith(s))}else r.replaceWith(t)}async function Me(r){const e=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...r,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(e,"text/html").body}u.RichTextResolver=L,u.RichTextSchema=A,u.getLiveStory=Ae,u.handleStoryblokMessage=je,u.loadStoryblokBridge=Ie,u.renderRichText=Ee,u.storyblok=xe,u.storyblokEditable=ke,u.toCamelCase=m,u.useStoryblokApi=Te,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "6.0.1",
4
+ "version": "6.0.2",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@9.13.2",
7
7
  "description": "Official Astro integration for the Storyblok Headless CMS",
@@ -72,7 +72,7 @@
72
72
  "astro": "^3.0.0 || ^4.0.0 || ^5.0.0"
73
73
  },
74
74
  "dependencies": {
75
- "@storyblok/js": "3.1.9",
75
+ "@storyblok/js": "3.2.3",
76
76
  "camelcase": "^8.0.0"
77
77
  },
78
78
  "devDependencies": {