@storyblok/astro 7.0.2-rc.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,14 +16,14 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://discord.gg/jKrbAMz">
20
- <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
19
+ <a href="https://storyblok.com/join-discord">
20
+ <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=8d60ff">
21
21
  </a>
22
22
  <a href="https://twitter.com/intent/follow?screen_name=storyblok">
23
- <img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
23
+ <img src="https://img.shields.io/badge/Follow-%40storyblok-8d60ff?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
24
24
  </a><br/>
25
25
  <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro">
26
- <img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
26
+ <img src="https://img.shields.io/badge/Try%20Storyblok-Free-8d60ff?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
27
27
  </a>
28
28
  </p>
29
29
 
@@ -415,7 +415,7 @@ Our heartfelt thanks go to [Virtual Identity](https://www.virtual-identity.com/)
415
415
 
416
416
  - Bugs or Feature Requests? [Submit an issue](/../../issues/new);
417
417
  - Do you have questions about this SDK? Or would you like to join the growing community of `@storyblok/astro` users? [Join the Astro Discord Community](https://discord.com/channels/830184174198718474/1002802280267001858)
418
- - Do you have questions about Storyblok or do you need help? [Join the Storyblok Discord Community](https://discord.gg/jKrbAMz).
418
+ - Do you have questions about Storyblok or do you need help? [Join the Storyblok Discord Community](https://storyblok.com/join-discord).
419
419
 
420
420
  ## Contributing
421
421
 
@@ -423,4 +423,4 @@ Please review our [Contributing Guidelines](https://github.com/storyblok/.github
423
423
 
424
424
  This project employs [semantic-release](https://semantic-release.gitbook.io/semantic-release/) to generate new versions based on commit messages, following the Angular Commit Message Convention.
425
425
 
426
- When using playgrounds during development, ensure the build is running in watch mode for an efficient workflow.
426
+ When using playgrounds during development, ensure the build is running in watch mode for an efficient workflow.
@@ -324,10 +324,10 @@ function me(e = {}) {
324
324
  const { src: c, alt: d, title: y, srcset: m, sizes: h } = o.attrs || {};
325
325
  let k = c, w = {};
326
326
  if (r) {
327
- const { src: Z, attrs: Q } = fe(c, r);
328
- k = Z, w = Q;
327
+ const { src: V, attrs: Q } = fe(c, r);
328
+ k = V, w = Q;
329
329
  }
330
- const X = {
330
+ const Z = {
331
331
  src: k,
332
332
  alt: d,
333
333
  title: y,
@@ -335,7 +335,7 @@ function me(e = {}) {
335
335
  sizes: h,
336
336
  ...w
337
337
  };
338
- return a.render("img", S(X));
338
+ return a.render("img", S(Z));
339
339
  }, f = (o, a) => {
340
340
  const { level: c, ...d } = o.attrs || {};
341
341
  return a.render(`h${c}`, d, o.children);
@@ -410,17 +410,17 @@ function me(e = {}) {
410
410
  }, J = (o, a) => {
411
411
  const c = {}, d = a.render("tbody", {}, o.children);
412
412
  return a.render("table", c, d);
413
- }, q = (o, a) => {
413
+ }, W = (o, a) => {
414
414
  const c = {};
415
415
  return a.render("tr", c, o.children);
416
- }, W = (o, a) => {
416
+ }, Y = (o, a) => {
417
417
  const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
418
418
  ...h
419
419
  };
420
420
  c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
421
421
  const w = [];
422
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) => {
423
+ }, q = (o, a) => {
424
424
  const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
425
425
  ...h
426
426
  };
@@ -455,13 +455,13 @@ function me(e = {}) {
455
455
  [v.SUBSCRIPT, C("sub")],
456
456
  [v.HIGHLIGHT, C("mark")],
457
457
  [g.TABLE, J],
458
- [g.TABLE_ROW, q],
459
- [g.TABLE_CELL, W],
460
- [g.TABLE_HEADER, Y]
458
+ [g.TABLE_ROW, W],
459
+ [g.TABLE_CELL, Y],
460
+ [g.TABLE_HEADER, q]
461
461
  ]), B = new Map([
462
462
  ..._,
463
463
  ...Object.entries(l).map(([o, a]) => [o, a])
464
- ]), V = () => ({
464
+ ]), X = () => ({
465
465
  render: (o, a = {}, c) => {
466
466
  if (b && o) {
467
467
  const d = t.get(o) || 0;
@@ -476,7 +476,7 @@ function me(e = {}) {
476
476
  const a = B.get(o.type);
477
477
  if (!a)
478
478
  return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
479
- const c = V();
479
+ const c = X();
480
480
  if (o.type === "text")
481
481
  return a(o, c);
482
482
  const d = o.content ? o.content.map(R) : void 0;
@@ -1,4 +1,4 @@
1
- (function(w,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(w=typeof globalThis<"u"?globalThis:w||self,$(w.storyblokAstro={}))})(this,function(w){"use strict";const $=`<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(w,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(w=typeof globalThis<"u"?globalThis:w||self,T(w.storyblokAstro={}))})(this,function(w){"use strict";const T=`<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,7 +7,7 @@
7
7
  </g>
8
8
  </g>
9
9
  </g>
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.
10
+ </svg>`,Y=/[\p{Lu}]/u,q=/[\p{Ll}]/u,B=/^[\p{Lu}](?![\p{Lu}])/gu,N=/([\p{Alpha}\p{N}_]|$)/u,x=/[_.\- ]+/,X=new RegExp("^"+x.source),j=new RegExp(x.source+N.source,"gu"),P=new RegExp("\\d+"+N.source,"gu"),Z=(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&&Y.test(u)?(e=e.slice(0,i)+"-"+e.slice(i),l=!1,b=r,r=!0,i++):r&&b&&q.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},V=(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=Z(e,s,n,t.preserveConsecutiveUppercase)),e=e.replace(X,""),e=t.preserveConsecutiveUppercase?V(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
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";
@@ -36,4 +36,4 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
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 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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}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"})});
39
+ `),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),r({id:"storyblok",name:"Storyblok",icon:T,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||{}),$=(e=>(e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e))($||{});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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}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 $e={src:m,alt:d,title:y,srcset:k,sizes:g,...v};return a.render("img",I($e))},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 $.ASSET:case $.URL:g=d;break;case $.EMAIL:g=`mailto:${d}`;break;case $.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]]),W=new Map([...J,...Object.entries(l).map(([o,a])=>[o,a])]),Te=()=>({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:W});function O(o){const a=W.get(o.type);if(!a)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const c=Te();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,17 +1,19 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "7.0.2-rc.0",
4
+ "version": "7.1.1",
5
5
  "private": false,
6
6
  "description": "Official Astro integration for the Storyblok Headless CMS",
7
7
  "author": "Storyblok",
8
8
  "license": "MIT",
9
+ "homepage": "https://github.com/storyblok/monoblok/tree/main/packages/astro#readme",
9
10
  "repository": {
10
11
  "type": "git",
11
- "url": "https://github.com/storyblok/storyblok-astro"
12
+ "url": "https://github.com/storyblok/monoblok.git",
13
+ "directory": "packages/astro"
12
14
  },
13
15
  "bugs": {
14
- "url": "https://github.com/storyblok/storyblok-astro/issues"
16
+ "url": "https://github.com/storyblok/monoblok/issues"
15
17
  },
16
18
  "keywords": [
17
19
  "astro",
@@ -54,14 +56,14 @@
54
56
  },
55
57
  "dependencies": {
56
58
  "camelcase": "^8.0.0",
57
- "@storyblok/js": "4.0.4-rc.0"
59
+ "@storyblok/js": "4.1.1"
58
60
  },
59
61
  "devDependencies": {
60
62
  "@cypress/vite-dev-server": "^6.0.3",
61
63
  "@rollup/plugin-dynamic-import-vars": "^2.1.5",
62
64
  "@storyblok/eslint-config": "^0.3.0",
63
65
  "@types/lodash.mergewith": "^4.6.9",
64
- "@types/node": "^22.15.1",
66
+ "@types/node": "^22.15.18",
65
67
  "astro": "^5.0.9",
66
68
  "cypress": "^14.3.3",
67
69
  "eslint": "^9.26.0",