@maily-to/render 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -18,6 +18,11 @@ interface ThemeOptions {
18
18
  blockquoteBorder?: string;
19
19
  codeBackground?: string;
20
20
  codeText?: string;
21
+ linkCardTitle?: string;
22
+ linkCardDescription?: string;
23
+ linkCardBadgeText?: string;
24
+ linkCardBadgeBackground?: string;
25
+ linkCardSubTitle: string;
21
26
  };
22
27
  fontSize?: {
23
28
  paragraph?: string;
@@ -181,6 +186,7 @@ declare class Maily {
181
186
  private footer;
182
187
  private blockquote;
183
188
  private code;
189
+ private linkCard;
184
190
  }
185
191
 
186
192
  declare function renderSync(content: JSONContent, config?: MailyConfig & RenderOptions): string;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,11 @@ interface ThemeOptions {
18
18
  blockquoteBorder?: string;
19
19
  codeBackground?: string;
20
20
  codeText?: string;
21
+ linkCardTitle?: string;
22
+ linkCardDescription?: string;
23
+ linkCardBadgeText?: string;
24
+ linkCardBadgeBackground?: string;
25
+ linkCardSubTitle: string;
21
26
  };
22
27
  fontSize?: {
23
28
  paragraph?: string;
@@ -181,6 +186,7 @@ declare class Maily {
181
186
  private footer;
182
187
  private blockquote;
183
188
  private code;
189
+ private linkCard;
184
190
  }
185
191
 
186
192
  declare function renderSync(content: JSONContent, config?: MailyConfig & RenderOptions): string;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // @ts-nocheck
2
2
 
3
- "use strict";var _=Object.create;var S=Object.defineProperty,z=Object.defineProperties,A=Object.getOwnPropertyDescriptor,F=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols,H=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var E=(l,e,t)=>e in l?S(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,y=(l,e)=>{for(var t in e||(e={}))v.call(e,t)&&E(l,t,e[t]);if(b)for(var t of b(e))V.call(e,t)&&E(l,t,e[t]);return l},T=(l,e)=>z(l,F(e));var k=(l,e)=>{var t={};for(var n in l)v.call(l,n)&&e.indexOf(n)<0&&(t[n]=l[n]);if(l!=null&&b)for(var n of b(l))e.indexOf(n)<0&&V.call(l,n)&&(t[n]=l[n]);return t};var W=(l,e)=>{for(var t in e)S(l,t,{get:e[t],enumerable:!0})},L=(l,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of B(e))!v.call(l,r)&&r!==t&&S(l,r,{get:()=>e[r],enumerable:!(n=A(e,r))||n.enumerable});return l};var P=(l,e,t)=>(t=l!=null?_(H(l)):{},L(e||!l||!l.__esModule?S(t,"default",{value:l,enumerable:!0}):t,l)),I=l=>L(S({},"__esModule",{value:!0}),l);var O=(l,e,t)=>new Promise((n,r)=>{var o=c=>{try{s(t.next(c))}catch(g){r(g)}},a=c=>{try{s(t.throw(c))}catch(g){r(g)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((t=t.apply(l,e)).next())});var Y={};W(Y,{Maily:()=>x,renderAsync:()=>K,renderSync:()=>j});module.exports=I(Y);var w=require("react"),p=require("@react-email/components"),C=require("@react-email/render"),X=P(require("lodash/merge"));function N(){return Math.random().toString(36).substr(2,6)}var i=require("react/jsx-runtime");var D={sm:"8px",md:"16px",lg:"32px",xl:"64px"},J={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var q={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var M={sm:"40px",md:"48px",lg:"64px"},R={pretty:!1,plainText:!1},U={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},$='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',x=class{constructor(e={type:"doc",content:[]}){this.config={theme:U};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=(0,X.default)(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var a;if(o.type==="button"){let s=(a=o.attrs)==null?void 0:a.url;n(s)&&s&&t.add(s)}else o.content&&o.content.forEach(s=>{s.marks&&s.marks.forEach(c=>{var m;let g=(m=c.attrs)==null?void 0:m.href;c.type==="link"&&n(g)&&t.add(g)}),s.content&&r(s)})};return e.forEach(o=>{r(o)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=R){let t=this.markup();return(0,C.render)(t,e)}renderAsync(){return O(this,arguments,function*(e=R){let t=this.markup();return(0,C.renderAsync)(t,e)})}markup(){let e=this.content.content||[],t=e.map((o,a)=>{let s={prev:e[a-1],next:e[a+1],parent:o},c=this.renderNode(o,s);return c?(0,i.jsx)(w.Fragment,{children:c},N()):null}),{preview:n}=this.config;return(0,i.jsxs)(p.Html,{children:[(0,i.jsxs)(p.Head,{children:[(0,i.jsx)(p.Font,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),(0,i.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),(0,i.jsx)("meta",{content:"width=device-width",name:"viewport"}),(0,i.jsx)("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),(0,i.jsx)("meta",{name:"x-apple-disable-message-reformatting"}),(0,i.jsx)("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),(0,i.jsx)("meta",{content:"light",name:"color-scheme"}),(0,i.jsx)("meta",{content:"light",name:"supported-color-schemes"})]}),(0,i.jsxs)(p.Body,{children:[n?(0,i.jsx)(p.Preview,{id:"__react-email-preview",children:n}):null,(0,i.jsx)(p.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?(0,i.jsx)(p.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(r=>{let o=this.renderNode(r,t);return o?(0,i.jsx)(w.Fragment,{children:o},N()):null}).filter(r=>r!==null)}renderNode(e,t={}){var r;let n=e.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||(0,i.jsx)(i.Fragment,{children:"\xA0"});return(e.marks||[]).reduce((r,o)=>{var s;let a=o.type;if(a in this)return(s=this[a])==null?void 0:s.call(this,o,r);throw new Error(`Mark type "${a}" is not supported.`)},(0,i.jsx)(i.Fragment,{children:t}))}paragraph(e,t){var g,m,d,h;let{attrs:n}=e,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:a}=t||{},s=(o==null?void 0:o.type)==="listItem",c=(a==null?void 0:a.type)==="spacer";return(0,i.jsx)(p.Text,{style:y({textAlign:r,marginBottom:s||c?"0px":"20px",marginTop:"0px",fontSize:(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.paragraph,color:(h=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:h.paragraph},J),children:e.content?this.getMappedContent(e):(0,i.jsx)(i.Fragment,{children:"\xA0"})})}text(e,t){let n=e.text||"&nbsp";return e.marks?this.renderMark(e):(0,i.jsx)(i.Fragment,{children:n})}bold(e,t){return(0,i.jsx)("strong",{children:t})}italic(e,t){return(0,i.jsx)("em",{children:t})}underline(e,t){return(0,i.jsx)("u",{children:t})}strike(e,t){return(0,i.jsx)("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var s,c;let{attrs:n}=e,r=(n==null?void 0:n.href)||"#",o=(n==null?void 0:n.target)||"_blank",a=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),(0,i.jsx)(p.Link,{href:r,rel:a,style:{fontWeight:500,textDecoration:"underline",color:(c=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:c.heading},target:o,children:t})}heading(e,t){var u,f;let{attrs:n}=e,{next:r,prev:o}=t||{},a=`h${Number(n==null?void 0:n.level)||1}`,s=(n==null?void 0:n.textAlign)||"left",c=(r==null?void 0:r.type)==="spacer",g=(o==null?void 0:o.type)==="spacer",{fontSize:m,lineHeight:d,fontWeight:h}=q[a];return(0,i.jsx)(p.Heading,{as:a,style:{textAlign:s,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.heading,marginBottom:c?"0px":"12px",marginTop:"0px",fontSize:m,lineHeight:d,fontWeight:h},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:r}=e.attrs||{},o=this.variableFormatter({variable:n,fallback:r});return this.shouldReplaceVariableValues&&(o=this.variableValues.get(n)||r||o),(0,i.jsx)(i.Fragment,{children:o})}horizontalRule(e,t){return(0,i.jsx)(p.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return(0,i.jsx)(p.Container,{children:(0,i.jsx)("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return(0,i.jsx)(p.Container,{style:{maxWidth:"100%"},children:(0,i.jsx)("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return(0,i.jsx)(p.Container,{style:{maxWidth:"100%"},children:(0,i.jsx)("li",{style:y({marginBottom:"8px",paddingLeft:"6px"},J),children:this.getMappedContent(e,T(y({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:r,url:o,variant:a,buttonColor:s,textColor:c,borderRadius:g,alignment:m="left"}=n||{},d="0px";g==="round"?d="9999px":g==="smooth"&&(d="6px");let{next:h}=t||{},u=(h==null?void 0:h.type)==="spacer",f=this.linkValues.get(o)||this.variableValues.get(o)||o;return(0,i.jsx)(p.Container,{style:{textAlign:m,maxWidth:"100%",marginBottom:u?"0px":"20px"},children:(0,i.jsx)(p.Button,{href:f,style:{color:String(c),backgroundColor:a==="filled"?String(s):"transparent",borderColor:String(s),padding:a==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:r})})}spacer(e,t){let{attrs:n}=e,{height:r="auto"}=n||{};return(0,i.jsx)(p.Container,{style:{height:D[r]||r}})}hardBreak(e,t){return(0,i.jsx)("br",{})}logo(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,size:s,alignment:c="left"}=n||{},{next:g}=t||{},m=(g==null?void 0:g.type)==="spacer";return(0,i.jsx)(p.Row,{style:{marginTop:"0px",marginBottom:m?"0px":"32px"},children:(0,i.jsx)(p.Column,{align:c,children:(0,i.jsx)(p.Img,{alt:o||a||"Logo",src:r,style:{width:M[s]||s,height:M[s]||s},title:a||o||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,width:s="auto",height:c="auto",alignment:g="center",externalLink:m=""}=n||{},{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=(0,i.jsx)(p.Img,{alt:o||a||"Image",src:r,style:{height:c,width:s,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:a||o||"Image"});return(0,i.jsx)(p.Row,{style:{marginTop:"0px",marginBottom:h?"0px":"32px"},children:(0,i.jsx)(p.Column,{align:g,children:m?(0,i.jsx)("a",{href:m,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:u}):u})})}footer(e,t){var s,c,g,m,d,h,u,f;let{attrs:n}=e,{textAlign:r="left"}=n||{},{next:o}=t||{},a=(o==null?void 0:o.type)==="spacer";return(0,i.jsx)(p.Text,{style:y({fontSize:(g=(c=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:c.footer)==null?void 0:g.size,lineHeight:(h=(d=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:d.footer)==null?void 0:h.lineHeight,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:a?"0px":"20px",textAlign:r},J),children:this.getMappedContent(e)})}blockquote(e,t){var s,c;let{next:n,prev:r}=t||{},o=(n==null?void 0:n.type)==="spacer",a=(r==null?void 0:r.type)==="spacer";return(0,i.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(c=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:c.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:a?"0px":"20px",marginBottom:o?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,r,o,a;return(0,i.jsx)("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(a=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:a.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:$,fontWeight:400,letterSpacing:0},children:t})}};function j(l,e){let a=e||{},{theme:t,preview:n}=a,r=k(a,["theme","preview"]),o=new x(l);return o.setPreviewText(n),o.setTheme(t),o.renderSync(r)}function K(l,e){return O(this,null,function*(){let a=e||{},{theme:t,preview:n}=a,r=k(a,["theme","preview"]),o=new x(l);return o.setPreviewText(n),o.setTheme(t),o.renderAsync(r)})}0&&(module.exports={Maily,renderAsync,renderSync});
3
+ "use strict";var K=Object.create;var S=Object.defineProperty,Y=Object.defineProperties,G=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols,ee=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var P=(p,e,t)=>e in p?S(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,x=(p,e)=>{for(var t in e||(e={}))J.call(e,t)&&P(p,t,e[t]);if(k)for(var t of k(e))D.call(e,t)&&P(p,t,e[t]);return p},I=(p,e)=>Y(p,Q(e));var C=(p,e)=>{var t={};for(var n in p)J.call(p,n)&&e.indexOf(n)<0&&(t[n]=p[n]);if(p!=null&&k)for(var n of k(p))e.indexOf(n)<0&&D.call(p,n)&&(t[n]=p[n]);return t};var te=(p,e)=>{for(var t in e)S(p,t,{get:e[t],enumerable:!0})},q=(p,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!J.call(p,i)&&i!==t&&S(p,i,{get:()=>e[i],enumerable:!(n=G(e,i))||n.enumerable});return p};var ne=(p,e,t)=>(t=p!=null?K(ee(p)):{},q(e||!p||!p.__esModule?S(t,"default",{value:p,enumerable:!0}):t,p)),oe=p=>q(S({},"__esModule",{value:!0}),p);var O=(p,e,t)=>new Promise((n,i)=>{var r=c=>{try{l(t.next(c))}catch(g){i(g)}},s=c=>{try{l(t.throw(c))}catch(g){i(g)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(r,s);l((t=t.apply(p,e)).next())});var ce={};te(ce,{Maily:()=>y,renderAsync:()=>pe,renderSync:()=>le});module.exports=oe(ce);var w=require("react"),a=require("@react-email/components"),v=require("@react-email/render"),j=ne(require("lodash/merge"));function T(){return Math.random().toString(36).substr(2,6)}var o=require("react/jsx-runtime");var re={sm:"8px",md:"16px",lg:"32px",xl:"64px"},b={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var ie={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var $={sm:"40px",md:"48px",lg:"64px"},U={pretty:!1,plainText:!1},ae={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)",linkCardTitle:"rgb(17, 24, 39)",linkCardDescription:"rgb(107, 114, 128)",linkCardBadgeText:"rgb(17, 24, 39)",linkCardBadgeBackground:"rgb(254, 240, 138)",linkCardSubTitle:"rgb(107, 114, 128)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},se='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',y=class{constructor(e={type:"doc",content:[]}){this.config={theme:ae};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=(0,j.default)(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=r=>r&&this.isValidUrl(r)&&!r.startsWith("#")&&!r.startsWith("mailto:")&&!r.startsWith("tel:")&&typeof r=="string",i=r=>{var s;if(r.type==="button"){let l=(s=r.attrs)==null?void 0:s.url;n(l)&&l&&t.add(l)}else r.content&&r.content.forEach(l=>{l.marks&&l.marks.forEach(c=>{var m;let g=(m=c.attrs)==null?void 0:m.href;c.type==="link"&&n(g)&&t.add(g)}),l.content&&i(l)})};return e.forEach(r=>{i(r)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=U){let t=this.markup();return(0,v.render)(t,e)}renderAsync(){return O(this,arguments,function*(e=U){let t=this.markup();return(0,v.renderAsync)(t,e)})}markup(){let e=this.content.content||[],t=e.map((r,s)=>{let l={prev:e[s-1],next:e[s+1],parent:r},c=this.renderNode(r,l);return c?(0,o.jsx)(w.Fragment,{children:c},T()):null}),{preview:n}=this.config;return(0,o.jsxs)(a.Html,{children:[(0,o.jsxs)(a.Head,{children:[(0,o.jsx)(a.Font,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),(0,o.jsx)("meta",{content:"width=device-width",name:"viewport"}),(0,o.jsx)("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),(0,o.jsx)("meta",{name:"x-apple-disable-message-reformatting"}),(0,o.jsx)("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),(0,o.jsx)("meta",{content:"light",name:"color-scheme"}),(0,o.jsx)("meta",{content:"light",name:"supported-color-schemes"})]}),(0,o.jsxs)(a.Body,{children:[n?(0,o.jsx)(a.Preview,{id:"__react-email-preview",children:n}):null,(0,o.jsx)(a.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?(0,o.jsx)(a.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(i=>{let r=this.renderNode(i,t);return r?(0,o.jsx)(w.Fragment,{children:r},T()):null}).filter(i=>i!==null)}renderNode(e,t={}){var i;let n=e.type||"";if(n in this)return(i=this[n])==null?void 0:i.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||(0,o.jsx)(o.Fragment,{children:"\xA0"});return(e.marks||[]).reduce((i,r)=>{var l;let s=r.type;if(s in this)return(l=this[s])==null?void 0:l.call(this,r,i);throw new Error(`Mark type "${s}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:t}))}paragraph(e,t){var g,m,d,h;let{attrs:n}=e,i=(n==null?void 0:n.textAlign)||"left",{parent:r,next:s}=t||{},l=(r==null?void 0:r.type)==="listItem",c=(s==null?void 0:s.type)==="spacer";return(0,o.jsx)(a.Text,{style:x({textAlign:i,marginBottom:l||c?"0px":"20px",marginTop:"0px",fontSize:(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.paragraph,color:(h=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:h.paragraph},b),children:e.content?this.getMappedContent(e):(0,o.jsx)(o.Fragment,{children:"\xA0"})})}text(e,t){let n=e.text||"&nbsp";return e.marks?this.renderMark(e):(0,o.jsx)(o.Fragment,{children:n})}bold(e,t){return(0,o.jsx)("strong",{children:t})}italic(e,t){return(0,o.jsx)("em",{children:t})}underline(e,t){return(0,o.jsx)("u",{children:t})}strike(e,t){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var l,c;let{attrs:n}=e,i=(n==null?void 0:n.href)||"#",r=(n==null?void 0:n.target)||"_blank",s=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(i=this.linkValues.get(i)||this.variableValues.get(i)||i),(0,o.jsx)(a.Link,{href:i,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(c=(l=this.config.theme)==null?void 0:l.colors)==null?void 0:c.heading},target:r,children:t})}heading(e,t){var u,f;let{attrs:n}=e,{next:i,prev:r}=t||{},s=`h${Number(n==null?void 0:n.level)||1}`,l=(n==null?void 0:n.textAlign)||"left",c=(i==null?void 0:i.type)==="spacer",g=(r==null?void 0:r.type)==="spacer",{fontSize:m,lineHeight:d,fontWeight:h}=ie[s];return(0,o.jsx)(a.Heading,{as:s,style:{textAlign:l,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.heading,marginBottom:c?"0px":"12px",marginTop:"0px",fontSize:m,lineHeight:d,fontWeight:h},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:i}=e.attrs||{},r=this.variableFormatter({variable:n,fallback:i});return this.shouldReplaceVariableValues&&(r=this.variableValues.get(n)||i||r),(0,o.jsx)(o.Fragment,{children:r})}horizontalRule(e,t){return(0,o.jsx)(a.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return(0,o.jsx)(a.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return(0,o.jsx)(a.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return(0,o.jsx)(a.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("li",{style:x({marginBottom:"8px",paddingLeft:"6px"},b),children:this.getMappedContent(e,I(x({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:i,url:r,variant:s,buttonColor:l,textColor:c,borderRadius:g,alignment:m="left"}=n||{},d="0px";g==="round"?d="9999px":g==="smooth"&&(d="6px");let{next:h}=t||{},u=(h==null?void 0:h.type)==="spacer",f=this.linkValues.get(r)||this.variableValues.get(r)||r;return(0,o.jsx)(a.Container,{style:{textAlign:m,maxWidth:"100%",marginBottom:u?"0px":"20px"},children:(0,o.jsx)(a.Button,{href:f,style:{color:String(c),backgroundColor:s==="filled"?String(l):"transparent",borderColor:String(l),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:i})})}spacer(e,t){let{attrs:n}=e,{height:i="auto"}=n||{};return(0,o.jsx)(a.Container,{style:{height:re[i]||i}})}hardBreak(e,t){return(0,o.jsx)("br",{})}logo(e,t){let{attrs:n}=e,{src:i,alt:r,title:s,size:l,alignment:c="left"}=n||{},{next:g}=t||{},m=(g==null?void 0:g.type)==="spacer";return(0,o.jsx)(a.Row,{style:{marginTop:"0px",marginBottom:m?"0px":"32px"},children:(0,o.jsx)(a.Column,{align:c,children:(0,o.jsx)(a.Img,{alt:r||s||"Logo",src:i,style:{width:$[l]||l,height:$[l]||l},title:s||r||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:i,alt:r,title:s,width:l="auto",height:c="auto",alignment:g="center",externalLink:m=""}=n||{},{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=(0,o.jsx)(a.Img,{alt:r||s||"Image",src:i,style:{height:c,width:l,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:s||r||"Image"});return(0,o.jsx)(a.Row,{style:{marginTop:"0px",marginBottom:h?"0px":"32px"},children:(0,o.jsx)(a.Column,{align:g,children:m?(0,o.jsx)("a",{href:m,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:u}):u})})}footer(e,t){var l,c,g,m,d,h,u,f;let{attrs:n}=e,{textAlign:i="left"}=n||{},{next:r}=t||{},s=(r==null?void 0:r.type)==="spacer";return(0,o.jsx)(a.Text,{style:x({fontSize:(g=(c=(l=this.config.theme)==null?void 0:l.fontSize)==null?void 0:c.footer)==null?void 0:g.size,lineHeight:(h=(d=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:d.footer)==null?void 0:h.lineHeight,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:s?"0px":"20px",textAlign:i},b),children:this.getMappedContent(e)})}blockquote(e,t){var l,c;let{next:n,prev:i}=t||{},r=(n==null?void 0:n.type)==="spacer",s=(i==null?void 0:i.type)==="spacer";return(0,o.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(c=(l=this.config.theme)==null?void 0:l.colors)==null?void 0:c.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:s?"0px":"20px",marginBottom:r?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,i,r,s;return(0,o.jsx)("code",{style:{backgroundColor:(i=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:i.codeBackground,color:(s=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:se,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){var V,R,L,M,B,X,z,_,A,F,W,H;let{attrs:n}=e,{next:i}=t||{},r=(i==null?void 0:i.type)==="spacer",s=600,l=16/9,c=s/l,{title:g,description:m,link:d,linkTitle:h,image:u,badgeText:f,subTitle:N}=n||{},E=this.linkValues.get(d)||this.variableValues.get(d)||d||"#";return(0,o.jsxs)("a",{href:E,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r?"0px":"20px"},target:"_blank",children:[u?(0,o.jsx)(a.Row,{style:{marginBottom:"6px"},children:(0,o.jsx)(a.Column,{style:{width:`${s}px`,height:`${c}px`},children:(0,o.jsx)(a.Img,{alt:g||"Link Card",src:u,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:g||"Link Card"})})}):null,(0,o.jsx)(a.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,o.jsxs)(a.Column,{style:{verticalAlign:"top"},children:[(0,o.jsxs)(a.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,o.jsx)(a.Column,{children:(0,o.jsx)(a.Text,{style:x({fontSize:"18px",fontWeight:600,color:(R=(V=this.config.theme)==null?void 0:V.colors)==null?void 0:R.linkCardTitle,margin:"0px"},b),children:g})}),f||N?(0,o.jsxs)(a.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[f?(0,o.jsx)("span",{style:{fontWeight:600,color:(M=(L=this.config.theme)==null?void 0:L.colors)==null?void 0:M.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(X=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:X.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:f}):null," ",N&&!f?(0,o.jsx)("span",{style:{fontWeight:"normal",color:(_=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:_.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:N}):null]}):null]}),(0,o.jsxs)(a.Text,{style:x({fontSize:"16px",color:(F=(A=this.config.theme)==null?void 0:A.colors)==null?void 0:F.linkCardDescription,marginTop:"0px",marginBottom:"0px"},b),children:[m," ",h?(0,o.jsx)("a",{href:E,rel:"noopener noreferrer",style:{color:(H=(W=this.config.theme)==null?void 0:W.colors)==null?void 0:H.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:h}):null]})]})})]})}};function le(p,e){let s=e||{},{theme:t,preview:n}=s,i=C(s,["theme","preview"]),r=new y(p);return r.setPreviewText(n),r.setTheme(t),r.renderSync(i)}function pe(p,e){return O(this,null,function*(){let s=e||{},{theme:t,preview:n}=s,i=C(s,["theme","preview"]),r=new y(p);return r.setPreviewText(n),r.setTheme(t),r.renderAsync(i)})}0&&(module.exports={Maily,renderAsync,renderSync});
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  // @ts-nocheck
2
2
 
3
- var A=Object.defineProperty,F=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var w=(p,e,t)=>e in p?A(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,S=(p,e)=>{for(var t in e||(e={}))E.call(e,t)&&w(p,t,e[t]);if(b)for(var t of b(e))V.call(e,t)&&w(p,t,e[t]);return p},T=(p,e)=>F(p,B(e));var k=(p,e)=>{var t={};for(var n in p)E.call(p,n)&&e.indexOf(n)<0&&(t[n]=p[n]);if(p!=null&&b)for(var n of b(p))e.indexOf(n)<0&&V.call(p,n)&&(t[n]=p[n]);return t};var O=(p,e,t)=>new Promise((n,r)=>{var o=l=>{try{s(t.next(l))}catch(c){r(c)}},a=l=>{try{s(t.throw(l))}catch(c){r(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((t=t.apply(p,e)).next())});import{Fragment as L}from"react";import{Text as M,Html as H,Head as W,Body as P,Font as I,Container as f,Link as D,Heading as q,Hr as U,Button as $,Img as v,Preview as j,Row as R,Column as X}from"@react-email/components";import{render as K,renderAsync as Y}from"@react-email/render";import G from"lodash/merge";function C(){return Math.random().toString(36).substr(2,6)}import{Fragment as y,jsx as i,jsxs as J}from"react/jsx-runtime";var Q={sm:"8px",md:"16px",lg:"32px",xl:"64px"},N={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var Z={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var _={sm:"40px",md:"48px",lg:"64px"},z={pretty:!1,plainText:!1},ee={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},te='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',x=class{constructor(e={type:"doc",content:[]}){this.config={theme:ee};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=G(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var a;if(o.type==="button"){let s=(a=o.attrs)==null?void 0:a.url;n(s)&&s&&t.add(s)}else o.content&&o.content.forEach(s=>{s.marks&&s.marks.forEach(l=>{var g;let c=(g=l.attrs)==null?void 0:g.href;l.type==="link"&&n(c)&&t.add(c)}),s.content&&r(s)})};return e.forEach(o=>{r(o)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=z){let t=this.markup();return K(t,e)}renderAsync(){return O(this,arguments,function*(e=z){let t=this.markup();return Y(t,e)})}markup(){let e=this.content.content||[],t=e.map((o,a)=>{let s={prev:e[a-1],next:e[a+1],parent:o},l=this.renderNode(o,s);return l?i(L,{children:l},C()):null}),{preview:n}=this.config;return J(H,{children:[J(W,{children:[i(I,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),i("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),i("meta",{content:"width=device-width",name:"viewport"}),i("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),i("meta",{name:"x-apple-disable-message-reformatting"}),i("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),i("meta",{content:"light",name:"color-scheme"}),i("meta",{content:"light",name:"supported-color-schemes"})]}),J(P,{children:[n?i(j,{id:"__react-email-preview",children:n}):null,i(f,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?i(v,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(r=>{let o=this.renderNode(r,t);return o?i(L,{children:o},C()):null}).filter(r=>r!==null)}renderNode(e,t={}){var r;let n=e.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||i(y,{children:"\xA0"});return(e.marks||[]).reduce((r,o)=>{var s;let a=o.type;if(a in this)return(s=this[a])==null?void 0:s.call(this,o,r);throw new Error(`Mark type "${a}" is not supported.`)},i(y,{children:t}))}paragraph(e,t){var c,g,m,d;let{attrs:n}=e,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:a}=t||{},s=(o==null?void 0:o.type)==="listItem",l=(a==null?void 0:a.type)==="spacer";return i(M,{style:S({textAlign:r,marginBottom:s||l?"0px":"20px",marginTop:"0px",fontSize:(g=(c=this.config.theme)==null?void 0:c.fontSize)==null?void 0:g.paragraph,color:(d=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:d.paragraph},N),children:e.content?this.getMappedContent(e):i(y,{children:"\xA0"})})}text(e,t){let n=e.text||"&nbsp";return e.marks?this.renderMark(e):i(y,{children:n})}bold(e,t){return i("strong",{children:t})}italic(e,t){return i("em",{children:t})}underline(e,t){return i("u",{children:t})}strike(e,t){return i("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var s,l;let{attrs:n}=e,r=(n==null?void 0:n.href)||"#",o=(n==null?void 0:n.target)||"_blank",a=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),i(D,{href:r,rel:a,style:{fontWeight:500,textDecoration:"underline",color:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.heading},target:o,children:t})}heading(e,t){var h,u;let{attrs:n}=e,{next:r,prev:o}=t||{},a=`h${Number(n==null?void 0:n.level)||1}`,s=(n==null?void 0:n.textAlign)||"left",l=(r==null?void 0:r.type)==="spacer",c=(o==null?void 0:o.type)==="spacer",{fontSize:g,lineHeight:m,fontWeight:d}=Z[a];return i(q,{as:a,style:{textAlign:s,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.heading,marginBottom:l?"0px":"12px",marginTop:"0px",fontSize:g,lineHeight:m,fontWeight:d},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:r}=e.attrs||{},o=this.variableFormatter({variable:n,fallback:r});return this.shouldReplaceVariableValues&&(o=this.variableValues.get(n)||r||o),i(y,{children:o})}horizontalRule(e,t){return i(U,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return i(f,{children:i("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return i(f,{style:{maxWidth:"100%"},children:i("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return i(f,{style:{maxWidth:"100%"},children:i("li",{style:S({marginBottom:"8px",paddingLeft:"6px"},N),children:this.getMappedContent(e,T(S({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:r,url:o,variant:a,buttonColor:s,textColor:l,borderRadius:c,alignment:g="left"}=n||{},m="0px";c==="round"?m="9999px":c==="smooth"&&(m="6px");let{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=this.linkValues.get(o)||this.variableValues.get(o)||o;return i(f,{style:{textAlign:g,maxWidth:"100%",marginBottom:h?"0px":"20px"},children:i($,{href:u,style:{color:String(l),backgroundColor:a==="filled"?String(s):"transparent",borderColor:String(s),padding:a==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:m},children:r})})}spacer(e,t){let{attrs:n}=e,{height:r="auto"}=n||{};return i(f,{style:{height:Q[r]||r}})}hardBreak(e,t){return i("br",{})}logo(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,size:s,alignment:l="left"}=n||{},{next:c}=t||{},g=(c==null?void 0:c.type)==="spacer";return i(R,{style:{marginTop:"0px",marginBottom:g?"0px":"32px"},children:i(X,{align:l,children:i(v,{alt:o||a||"Logo",src:r,style:{width:_[s]||s,height:_[s]||s},title:a||o||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,width:s="auto",height:l="auto",alignment:c="center",externalLink:g=""}=n||{},{next:m}=t||{},d=(m==null?void 0:m.type)==="spacer",h=i(v,{alt:o||a||"Image",src:r,style:{height:l,width:s,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:a||o||"Image"});return i(R,{style:{marginTop:"0px",marginBottom:d?"0px":"32px"},children:i(X,{align:c,children:g?i("a",{href:g,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:h}):h})})}footer(e,t){var s,l,c,g,m,d,h,u;let{attrs:n}=e,{textAlign:r="left"}=n||{},{next:o}=t||{},a=(o==null?void 0:o.type)==="spacer";return i(M,{style:S({fontSize:(c=(l=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:l.footer)==null?void 0:c.size,lineHeight:(d=(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.footer)==null?void 0:d.lineHeight,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.footer,marginTop:"0px",marginBottom:a?"0px":"20px",textAlign:r},N),children:this.getMappedContent(e)})}blockquote(e,t){var s,l;let{next:n,prev:r}=t||{},o=(n==null?void 0:n.type)==="spacer",a=(r==null?void 0:r.type)==="spacer";return i("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:a?"0px":"20px",marginBottom:o?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,r,o,a;return i("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(a=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:a.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:te,fontWeight:400,letterSpacing:0},children:t})}};function de(p,e){let a=e||{},{theme:t,preview:n}=a,r=k(a,["theme","preview"]),o=new x(p);return o.setPreviewText(n),o.setTheme(t),o.renderSync(r)}function xe(p,e){return O(this,null,function*(){let a=e||{},{theme:t,preview:n}=a,r=k(a,["theme","preview"]),o=new x(p);return o.setPreviewText(n),o.setTheme(t),o.renderAsync(r)})}export{x as Maily,xe as renderAsync,de as renderSync};
3
+ var G=Object.defineProperty,Q=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var I=(c,e,t)=>e in c?G(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,x=(c,e)=>{for(var t in e||(e={}))q.call(e,t)&&I(c,t,e[t]);if(v)for(var t of v(e))$.call(e,t)&&I(c,t,e[t]);return c},U=(c,e)=>Q(c,Z(e));var N=(c,e)=>{var t={};for(var n in c)q.call(c,n)&&e.indexOf(n)<0&&(t[n]=c[n]);if(c!=null&&v)for(var n of v(c))e.indexOf(n)<0&&$.call(c,n)&&(t[n]=c[n]);return t};var J=(c,e,t)=>new Promise((n,r)=>{var o=l=>{try{s(t.next(l))}catch(p){r(p)}},a=l=>{try{s(t.throw(l))}catch(p){r(p)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((t=t.apply(c,e)).next())});import{Fragment as j}from"react";import{Text as T,Html as ee,Head as te,Body as ne,Font as oe,Container as y,Link as re,Heading as ie,Hr as ae,Button as se,Img as w,Preview as le,Row as k,Column as S}from"@react-email/components";import{render as pe,renderAsync as ce}from"@react-email/render";import ge from"lodash/merge";function V(){return Math.random().toString(36).substr(2,6)}import{Fragment as O,jsx as i,jsxs as f}from"react/jsx-runtime";var me={sm:"8px",md:"16px",lg:"32px",xl:"64px"},C={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var de={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var K={sm:"40px",md:"48px",lg:"64px"},Y={pretty:!1,plainText:!1},he={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)",linkCardTitle:"rgb(17, 24, 39)",linkCardDescription:"rgb(107, 114, 128)",linkCardBadgeText:"rgb(17, 24, 39)",linkCardBadgeBackground:"rgb(254, 240, 138)",linkCardSubTitle:"rgb(107, 114, 128)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},ue='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',b=class{constructor(e={type:"doc",content:[]}){this.config={theme:he};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=ge(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var a;if(o.type==="button"){let s=(a=o.attrs)==null?void 0:a.url;n(s)&&s&&t.add(s)}else o.content&&o.content.forEach(s=>{s.marks&&s.marks.forEach(l=>{var g;let p=(g=l.attrs)==null?void 0:g.href;l.type==="link"&&n(p)&&t.add(p)}),s.content&&r(s)})};return e.forEach(o=>{r(o)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=Y){let t=this.markup();return pe(t,e)}renderAsync(){return J(this,arguments,function*(e=Y){let t=this.markup();return ce(t,e)})}markup(){let e=this.content.content||[],t=e.map((o,a)=>{let s={prev:e[a-1],next:e[a+1],parent:o},l=this.renderNode(o,s);return l?i(j,{children:l},V()):null}),{preview:n}=this.config;return f(ee,{children:[f(te,{children:[i(oe,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),i("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),i("meta",{content:"width=device-width",name:"viewport"}),i("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),i("meta",{name:"x-apple-disable-message-reformatting"}),i("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),i("meta",{content:"light",name:"color-scheme"}),i("meta",{content:"light",name:"supported-color-schemes"})]}),f(ne,{children:[n?i(le,{id:"__react-email-preview",children:n}):null,i(y,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?i(w,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(r=>{let o=this.renderNode(r,t);return o?i(j,{children:o},V()):null}).filter(r=>r!==null)}renderNode(e,t={}){var r;let n=e.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||i(O,{children:"\xA0"});return(e.marks||[]).reduce((r,o)=>{var s;let a=o.type;if(a in this)return(s=this[a])==null?void 0:s.call(this,o,r);throw new Error(`Mark type "${a}" is not supported.`)},i(O,{children:t}))}paragraph(e,t){var p,g,m,d;let{attrs:n}=e,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:a}=t||{},s=(o==null?void 0:o.type)==="listItem",l=(a==null?void 0:a.type)==="spacer";return i(T,{style:x({textAlign:r,marginBottom:s||l?"0px":"20px",marginTop:"0px",fontSize:(g=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:g.paragraph,color:(d=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:d.paragraph},C),children:e.content?this.getMappedContent(e):i(O,{children:"\xA0"})})}text(e,t){let n=e.text||"&nbsp";return e.marks?this.renderMark(e):i(O,{children:n})}bold(e,t){return i("strong",{children:t})}italic(e,t){return i("em",{children:t})}underline(e,t){return i("u",{children:t})}strike(e,t){return i("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var s,l;let{attrs:n}=e,r=(n==null?void 0:n.href)||"#",o=(n==null?void 0:n.target)||"_blank",a=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),i(re,{href:r,rel:a,style:{fontWeight:500,textDecoration:"underline",color:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.heading},target:o,children:t})}heading(e,t){var h,u;let{attrs:n}=e,{next:r,prev:o}=t||{},a=`h${Number(n==null?void 0:n.level)||1}`,s=(n==null?void 0:n.textAlign)||"left",l=(r==null?void 0:r.type)==="spacer",p=(o==null?void 0:o.type)==="spacer",{fontSize:g,lineHeight:m,fontWeight:d}=de[a];return i(ie,{as:a,style:{textAlign:s,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.heading,marginBottom:l?"0px":"12px",marginTop:"0px",fontSize:g,lineHeight:m,fontWeight:d},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:r}=e.attrs||{},o=this.variableFormatter({variable:n,fallback:r});return this.shouldReplaceVariableValues&&(o=this.variableValues.get(n)||r||o),i(O,{children:o})}horizontalRule(e,t){return i(ae,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return i(y,{children:i("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return i(y,{style:{maxWidth:"100%"},children:i("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return i(y,{style:{maxWidth:"100%"},children:i("li",{style:x({marginBottom:"8px",paddingLeft:"6px"},C),children:this.getMappedContent(e,U(x({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:r,url:o,variant:a,buttonColor:s,textColor:l,borderRadius:p,alignment:g="left"}=n||{},m="0px";p==="round"?m="9999px":p==="smooth"&&(m="6px");let{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=this.linkValues.get(o)||this.variableValues.get(o)||o;return i(y,{style:{textAlign:g,maxWidth:"100%",marginBottom:h?"0px":"20px"},children:i(se,{href:u,style:{color:String(l),backgroundColor:a==="filled"?String(s):"transparent",borderColor:String(s),padding:a==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:m},children:r})})}spacer(e,t){let{attrs:n}=e,{height:r="auto"}=n||{};return i(y,{style:{height:me[r]||r}})}hardBreak(e,t){return i("br",{})}logo(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,size:s,alignment:l="left"}=n||{},{next:p}=t||{},g=(p==null?void 0:p.type)==="spacer";return i(k,{style:{marginTop:"0px",marginBottom:g?"0px":"32px"},children:i(S,{align:l,children:i(w,{alt:o||a||"Logo",src:r,style:{width:K[s]||s,height:K[s]||s},title:a||o||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,width:s="auto",height:l="auto",alignment:p="center",externalLink:g=""}=n||{},{next:m}=t||{},d=(m==null?void 0:m.type)==="spacer",h=i(w,{alt:o||a||"Image",src:r,style:{height:l,width:s,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:a||o||"Image"});return i(k,{style:{marginTop:"0px",marginBottom:d?"0px":"32px"},children:i(S,{align:p,children:g?i("a",{href:g,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:h}):h})})}footer(e,t){var s,l,p,g,m,d,h,u;let{attrs:n}=e,{textAlign:r="left"}=n||{},{next:o}=t||{},a=(o==null?void 0:o.type)==="spacer";return i(T,{style:x({fontSize:(p=(l=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:l.footer)==null?void 0:p.size,lineHeight:(d=(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.footer)==null?void 0:d.lineHeight,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.footer,marginTop:"0px",marginBottom:a?"0px":"20px",textAlign:r},C),children:this.getMappedContent(e)})}blockquote(e,t){var s,l;let{next:n,prev:r}=t||{},o=(n==null?void 0:n.type)==="spacer",a=(r==null?void 0:r.type)==="spacer";return i("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:a?"0px":"20px",marginBottom:o?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,r,o,a;return i("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(a=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:a.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:ue,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){var L,M,B,X,z,_,A,F,W,H,P,D;let{attrs:n}=e,{next:r}=t||{},o=(r==null?void 0:r.type)==="spacer",a=600,s=16/9,l=a/s,{title:p,description:g,link:m,linkTitle:d,image:h,badgeText:u,subTitle:E}=n||{},R=this.linkValues.get(m)||this.variableValues.get(m)||m||"#";return f("a",{href:R,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:o?"0px":"20px"},target:"_blank",children:[h?i(k,{style:{marginBottom:"6px"},children:i(S,{style:{width:`${a}px`,height:`${l}px`},children:i(w,{alt:p||"Link Card",src:h,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:p||"Link Card"})})}):null,i(k,{style:{padding:"15px",marginTop:0,marginBottom:0},children:f(S,{style:{verticalAlign:"top"},children:[f(k,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[i(S,{children:i(T,{style:x({fontSize:"18px",fontWeight:600,color:(M=(L=this.config.theme)==null?void 0:L.colors)==null?void 0:M.linkCardTitle,margin:"0px"},C),children:p})}),u||E?f(S,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[u?i("span",{style:{fontWeight:600,color:(X=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:X.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(_=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:_.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:u}):null," ",E&&!u?i("span",{style:{fontWeight:"normal",color:(F=(A=this.config.theme)==null?void 0:A.colors)==null?void 0:F.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:E}):null]}):null]}),f(T,{style:x({fontSize:"16px",color:(H=(W=this.config.theme)==null?void 0:W.colors)==null?void 0:H.linkCardDescription,marginTop:"0px",marginBottom:"0px"},C),children:[g," ",d?i("a",{href:R,rel:"noopener noreferrer",style:{color:(D=(P=this.config.theme)==null?void 0:P.colors)==null?void 0:D.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:d}):null]})]})})]})}};function Te(c,e){let a=e||{},{theme:t,preview:n}=a,r=N(a,["theme","preview"]),o=new b(c);return o.setPreviewText(n),o.setTheme(t),o.renderSync(r)}function Re(c,e){return J(this,null,function*(){let a=e||{},{theme:t,preview:n}=a,r=N(a,["theme","preview"]),o=new b(c);return o.setPreviewText(n),o.setTheme(t),o.renderAsync(r)})}export{b as Maily,Re as renderAsync,Te as renderSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maily-to/render",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "private": false,
5
5
  "description": "A transformer that converts Maily content into HTML email templates.",
6
6
  "sideEffects": false,