@maily-to/render 0.0.1 → 0.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.
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
- "use strict";var N=Object.defineProperty,A=Object.defineProperties,H=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertyNames,E=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var z=(g,t,e)=>t in g?N(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,S=(g,t)=>{for(var e in t||(t={}))M.call(t,e)&&z(g,e,t[e]);if(E)for(var e of E(t))R.call(t,e)&&z(g,e,t[e]);return g},O=(g,t)=>A(g,T(t));var _=(g,t)=>{for(var e in t)N(g,e,{get:t[e],enumerable:!0})},B=(g,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!M.call(g,r)&&r!==e&&N(g,r,{get:()=>t[r],enumerable:!(n=H(t,r))||n.enumerable});return g};var W=g=>B(N({},"__esModule",{value:!0}),g);var k=(g,t,e)=>new Promise((n,r)=>{var i=l=>{try{s(e.next(l))}catch(c){r(c)}},p=l=>{try{s(e.throw(l))}catch(c){r(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,p);s((e=e.apply(g,t)).next())});var D={};_(D,{Maily:()=>u,render:()=>F,renderAsync:()=>$});module.exports=W(D);var a=require("@react-email/components"),J=require("@react-email/render");function m(){return Math.random().toString(36).substr(2,6)}var o=require("react/jsx-runtime");var P={sm:"8px",md:"16px",lg:"32px",xl:"64px"},v={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var I={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var X={sm:"40px",md:"48px",lg:"64px"},u=class{constructor(t={type:"doc",content:[]},e={}){this.config={options:{pretty:!1,plainText:!1},theme:{colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}}};this.content=t,this.config=S(S({},this.config),e)}render(){let t=this.config.options||{},e=this.markup();return(0,J.render)(e,t)}renderAsync(){return k(this,null,function*(){let t=this.config.options||{},e=this.markup();return(0,J.renderAsync)(e,t)})}markup(){let t=this.content.content||[],e=t.map((i,p)=>{let s={prev:t[p-1],next:t[p+1],parent:i};return this.renderNode(i,s)}),{preview:n}=this.config||{};return(0,o.jsxs)(a.Html,{children:[(0,o.jsx)(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"}})}),n?(0,o.jsx)(a.Preview,{children:n}):null,(0,o.jsx)(a.Body,{children:(0,o.jsx)(a.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:e})})]})}getMappedContent(t,e){var n,r;return((r=(n=t.content)==null?void 0:n.map(i=>this.renderNode(i,e)))==null?void 0:r.filter(i=>i!==null))||[]}renderNode(t,e){var r;let n=t.type||"";if(n in this)return(r=this[t.type])==null?void 0:r.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t){let e=t.text||(0,o.jsx)(o.Fragment,{children:"\xA0"});return(t.marks||[]).reduce((r,i)=>{var s;let p=i.type;if(p in this)return(s=this[p])==null?void 0:s.call(this,i,r);throw new Error(`Mark type "${p}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:e}))}paragraph(t,e){var c,d,y,x,f,h;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{parent:i,next:p}=e||{},s=(i==null?void 0:i.type)==="listItem",l=(p==null?void 0:p.type)==="spacer";return(0,o.jsx)(a.Text,{style:S({textAlign:r,marginBottom:s||l?"0px":"20px",marginTop:"0px",fontSize:(y=(d=(c=this.config)==null?void 0:c.theme)==null?void 0:d.fontSize)==null?void 0:y.paragraph,color:(h=(f=(x=this.config)==null?void 0:x.theme)==null?void 0:f.colors)==null?void 0:h.paragraph},v),children:t!=null&&t.content?this.getMappedContent(t):(0,o.jsx)(o.Fragment,{children:"\xA0"})},m())}text(t){let e=t.text||"&nbsp";return t.marks?this.renderMark(t):e}bold(t,e){return(0,o.jsx)("strong",{children:e},m())}italic(t,e){return(0,o.jsx)("em",{children:e},m())}underline(t,e){return(0,o.jsx)("u",{children:e},m())}strike(t,e){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:e},m())}link(t,e){var s,l,c;let{attrs:n}=t,r=(n==null?void 0:n.href)||"#",i=(n==null?void 0:n.target)||"_blank",p=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(0,o.jsx)(a.Link,{href:r,rel:p,style:{fontWeight:500,textDecoration:"underline",color:(c=(l=(s=this.config)==null?void 0:s.theme)==null?void 0:l.colors)==null?void 0:c.heading},target:i,children:e},m())}heading(t,e){var f,h,C;let{attrs:n}=t,{next:r,prev:i}=e||{},p=`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=(i==null?void 0:i.type)==="spacer",{fontSize:d,lineHeight:y,fontWeight:x}=I[p]||{};return(0,o.jsx)(a.Heading,{as:p,style:{textAlign:s,color:(C=(h=(f=this.config)==null?void 0:f.theme)==null?void 0:h.colors)==null?void 0:C.heading,marginBottom:l?"0px":"12px",marginTop:"0px",fontSize:d,lineHeight:y,fontWeight:x},children:this.getMappedContent(t)},m())}variable(t){let{attrs:e}=t,n=(e==null?void 0:e.id)||"";return(0,o.jsx)(o.Fragment,{children:`{{${n}}}`})}horizontalRule(t,e){return(0,o.jsx)(a.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){return(0,o.jsx)(a.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t)})},m())}bulletList(t,e){return(0,o.jsx)(a.Container,{children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t)})},m())}listItem(t,e){return(0,o.jsx)("li",{style:S({marginBottom:"8px",paddingLeft:"6px"},v),children:this.getMappedContent(t,O(S({},e),{parent:t}))},m())}button(t,e){let{attrs:n}=t,{text:r,url:i,variant:p,buttonColor:s,textColor:l,borderRadius:c,alignment:d="left"}=n||{},y="0px";return c==="round"?y="9999px":c==="smooth"&&(y="6px"),(0,o.jsx)(a.Container,{style:{textAlign:d},children:(0,o.jsx)(a.Button,{href:i,style:{color:String(l),backgroundColor:p==="filled"?String(s):"transparent",borderColor:String(s),padding:p==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:y},children:r})},m())}spacer(t,e){let{attrs:n}=t,{height:r="auto"}=n||{};return(0,o.jsx)(a.Container,{style:{height:P[r]||r}},m())}hardBreak(t,e){return(0,o.jsx)("br",{},m())}logo(t,e){let{attrs:n}=t,{src:r,alt:i,title:p,size:s,alignment:l}=n||{},c={marginRight:"auto"};l==="center"?c={marginRight:"auto",marginLeft:"auto"}:l==="right"&&(c={marginLeft:"auto"});let{next:d}=e||{},y=(d==null?void 0:d.type)==="spacer";return(0,o.jsx)(a.Img,{alt:i||p||"Logo",src:r,style:O(S({width:X[s]||s,height:X[s]||s},c),{marginBottom:y?"0px":"32px"}),title:p||i||"Logo"},m())}image(t,e){let{attrs:n}=t,{src:r,alt:i,title:p}=n||{},{next:s}=e||{},l=(s==null?void 0:s.type)==="spacer";return(0,o.jsx)(a.Img,{alt:i||p||"Image",src:r,style:{height:"auto",width:"auto",maxWidth:"100%",marginBottom:l?"0px":"32px",marginTop:"0px"},title:p||i||"Image"},m())}footer(t,e){var s,l,c,d,y,x,f,h,C,w,b;let{attrs:n}=t,{textAlign:r="left"}=n||{},{next:i}=e||{},p=(i==null?void 0:i.type)==="spacer";return(0,o.jsx)(a.Text,{style:S({fontSize:(d=(c=(l=(s=this.config)==null?void 0:s.theme)==null?void 0:l.fontSize)==null?void 0:c.footer)==null?void 0:d.size,lineHeight:(h=(f=(x=(y=this.config)==null?void 0:y.theme)==null?void 0:x.fontSize)==null?void 0:f.footer)==null?void 0:h.lineHeight,color:(b=(w=(C=this.config)==null?void 0:C.theme)==null?void 0:w.colors)==null?void 0:b.footer,marginTop:"0px",marginBottom:p?"0px":"20px",textAlign:r},v),children:this.getMappedContent(t)},m())}};function F(g,t){return new u(g,t).render()}function $(g,t){return k(this,null,function*(){return new u(g,t).renderAsync()})}0&&(module.exports={Maily,render,renderAsync});
1
+ // @ts-nocheck
2
+
3
+ "use strict";var u=Object.defineProperty,z=Object.defineProperties,M=Object.getOwnPropertyDescriptor,A=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertyNames,E=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var w=(g,t,e)=>t in g?u(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,f=(g,t)=>{for(var e in t||(t={}))b.call(t,e)&&w(g,e,t[e]);if(E)for(var e of E(t))T.call(t,e)&&w(g,e,t[e]);return g},C=(g,t)=>z(g,A(t));var L=(g,t)=>{for(var e in t)u(g,e,{get:t[e],enumerable:!0})},R=(g,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of H(t))!b.call(g,r)&&r!==e&&u(g,r,{get:()=>t[r],enumerable:!(n=M(t,r))||n.enumerable});return g};var _=g=>R(u({},"__esModule",{value:!0}),g);var J=(g,t,e)=>new Promise((n,r)=>{var i=l=>{try{a(e.next(l))}catch(m){r(m)}},s=l=>{try{a(e.throw(l))}catch(m){r(m)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((e=e.apply(g,t)).next())});var I={};L(I,{Maily:()=>S,render:()=>P,renderAsync:()=>F});module.exports=_(I);var k=require("react"),p=require("@react-email/components"),N=require("@react-email/render");function O(){return Math.random().toString(36).substr(2,6)}var o=require("react/jsx-runtime");var B={sm:"8px",md:"16px",lg:"32px",xl:"64px"},v={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var W={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var X={sm:"40px",md:"48px",lg:"64px"},S=class{constructor(t={type:"doc",content:[]},e={}){this.config={options:{pretty:!1,plainText:!1},theme:{colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}}};this.content=t,this.config=f(f({},this.config),e)}render(){let t=this.config.options||{},e=this.markup();return(0,N.render)(e,t)}renderAsync(){return J(this,null,function*(){let t=this.config.options||{},e=this.markup();return(0,N.renderAsync)(e,t)})}markup(){let t=this.content.content||[],e=t.map((i,s)=>{let a={prev:t[s-1],next:t[s+1],parent:i},l=this.renderNode(i,a);return l?(0,o.jsx)(k.Fragment,{children:l},O()):null}),{preview:n}=this.config;return(0,o.jsxs)(p.Html,{children:[(0,o.jsx)(p.Head,{children:(0,o.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"}})}),n?(0,o.jsx)(p.Preview,{children:n}):null,(0,o.jsx)(p.Body,{children:(0,o.jsx)(p.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:e})})]})}getMappedContent(t,e){var n,r;return(r=(n=t.content)==null?void 0:n.map(i=>{let s=this.renderNode(i,e);return s?(0,o.jsx)(k.Fragment,{children:s},O()):null}))==null?void 0:r.filter(i=>i!==null)}renderNode(t,e={}){var r;let n=t.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t){let e=t.text||(0,o.jsx)(o.Fragment,{children:"\xA0"});return(t.marks||[]).reduce((r,i)=>{var a;let s=i.type;if(s in this)return(a=this[s])==null?void 0:a.call(this,i,r);throw new Error(`Mark type "${s}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:e}))}paragraph(t,e){var m,c,d,h;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{parent:i,next:s}=e||{},a=(i==null?void 0:i.type)==="listItem",l=(s==null?void 0:s.type)==="spacer";return(0,o.jsx)(p.Text,{style:f({textAlign:r,marginBottom:a||l?"0px":"20px",marginTop:"0px",fontSize:(c=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:c.paragraph,color:(h=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:h.paragraph},v),children:t.content?this.getMappedContent(t):(0,o.jsx)(o.Fragment,{children:"\xA0"})})}text(t,e){let n=t.text||"&nbsp";return t.marks?this.renderMark(t):(0,o.jsx)(o.Fragment,{children:n})}bold(t,e){return(0,o.jsx)("strong",{children:e})}italic(t,e){return(0,o.jsx)("em",{children:e})}underline(t,e){return(0,o.jsx)("u",{children:e})}strike(t,e){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:e})}link(t,e){var a,l;let{attrs:n}=t,r=(n==null?void 0:n.href)||"#",i=(n==null?void 0:n.target)||"_blank",s=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(0,o.jsx)(p.Link,{href:r,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(l=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:l.heading},target:i,children:e})}heading(t,e){var y,x;let{attrs:n}=t,{next:r,prev:i}=e||{},s=`h${Number(n==null?void 0:n.level)||1}`,a=(n==null?void 0:n.textAlign)||"left",l=(r==null?void 0:r.type)==="spacer",m=(i==null?void 0:i.type)==="spacer",{fontSize:c,lineHeight:d,fontWeight:h}=W[s];return(0,o.jsx)(p.Heading,{as:s,style:{textAlign:a,color:(x=(y=this.config.theme)==null?void 0:y.colors)==null?void 0:x.heading,marginBottom:l?"0px":"12px",marginTop:"0px",fontSize:c,lineHeight:d,fontWeight:h},children:this.getMappedContent(t)})}variable(t,e){let{attrs:n}=t,r=(n==null?void 0:n.id)||"";return(0,o.jsx)(o.Fragment,{children:`{{${r}}}`})}horizontalRule(t,e){return(0,o.jsx)(p.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){return(0,o.jsx)(p.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t)})})}bulletList(t,e){return(0,o.jsx)(p.Container,{children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t)})})}listItem(t,e){return(0,o.jsx)("li",{style:f({marginBottom:"8px",paddingLeft:"6px"},v),children:this.getMappedContent(t,C(f({},e),{parent:t}))})}button(t,e){let{attrs:n}=t,{text:r,url:i,variant:s,buttonColor:a,textColor:l,borderRadius:m,alignment:c="left"}=n||{},d="0px";return m==="round"?d="9999px":m==="smooth"&&(d="6px"),(0,o.jsx)(p.Container,{style:{textAlign:c},children:(0,o.jsx)(p.Button,{href:i,style:{color:String(l),backgroundColor:s==="filled"?String(a):"transparent",borderColor:String(a),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:r})})}spacer(t,e){let{attrs:n}=t,{height:r="auto"}=n||{};return(0,o.jsx)(p.Container,{style:{height:B[r]||r}})}hardBreak(t,e){return(0,o.jsx)("br",{})}logo(t,e){let{attrs:n}=t,{src:r,alt:i,title:s,size:a,alignment:l}=n||{},m={marginRight:"auto"};l==="center"?m={marginRight:"auto",marginLeft:"auto"}:l==="right"&&(m={marginLeft:"auto"});let{next:c}=e||{},d=(c==null?void 0:c.type)==="spacer";return(0,o.jsx)(p.Img,{alt:i||s||"Logo",src:r,style:C(f({width:X[a]||a,height:X[a]||a},m),{marginBottom:d?"0px":"32px"}),title:s||i||"Logo"})}image(t,e){let{attrs:n}=t,{src:r,alt:i,title:s}=n||{},{next:a}=e||{},l=(a==null?void 0:a.type)==="spacer";return(0,o.jsx)(p.Img,{alt:i||s||"Image",src:r,style:{height:"auto",width:"auto",maxWidth:"100%",marginBottom:l?"0px":"32px",marginTop:"0px"},title:s||i||"Image"})}footer(t,e){var a,l,m,c,d,h,y,x;let{attrs:n}=t,{textAlign:r="left"}=n||{},{next:i}=e||{},s=(i==null?void 0:i.type)==="spacer";return(0,o.jsx)(p.Text,{style:f({fontSize:(m=(l=(a=this.config.theme)==null?void 0:a.fontSize)==null?void 0:l.footer)==null?void 0:m.size,lineHeight:(h=(d=(c=this.config.theme)==null?void 0:c.fontSize)==null?void 0:d.footer)==null?void 0:h.lineHeight,color:(x=(y=this.config.theme)==null?void 0:y.colors)==null?void 0:x.footer,marginTop:"0px",marginBottom:s?"0px":"20px",textAlign:r},v),children:this.getMappedContent(t)})}};function P(g,t){return new S(g,t).render()}function F(g,t){return J(this,null,function*(){return new S(g,t).renderAsync()})}0&&(module.exports={Maily,render,renderAsync});
package/dist/index.mjs CHANGED
@@ -1 +1,3 @@
1
- var A=Object.defineProperty,H=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var E=(c,t,e)=>t in c?A(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e,h=(c,t)=>{for(var e in t||(t={}))L.call(t,e)&&E(c,e,t[e]);if(b)for(var e of b(t))R.call(t,e)&&E(c,e,t[e]);return c},J=(c,t)=>H(c,T(t));var N=(c,t,e)=>new Promise((n,r)=>{var o=p=>{try{i(e.next(p))}catch(l){r(l)}},a=p=>{try{i(e.throw(p))}catch(l){r(l)}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(o,a);i((e=e.apply(c,t)).next())});import{Text as z,Html as _,Head as B,Body as W,Font as P,Container as C,Link as I,Heading as F,Hr as $,Button as D,Img as M,Preview as K}from"@react-email/components";import{render as j,renderAsync as q}from"@react-email/render";function g(){return Math.random().toString(36).substr(2,6)}import{Fragment as k,jsx as s,jsxs as U}from"react/jsx-runtime";var G={sm:"8px",md:"16px",lg:"32px",xl:"64px"},O={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 X={sm:"40px",md:"48px",lg:"64px"},x=class{constructor(t={type:"doc",content:[]},e={}){this.config={options:{pretty:!1,plainText:!1},theme:{colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}}};this.content=t,this.config=h(h({},this.config),e)}render(){let t=this.config.options||{},e=this.markup();return j(e,t)}renderAsync(){return N(this,null,function*(){let t=this.config.options||{},e=this.markup();return q(e,t)})}markup(){let t=this.content.content||[],e=t.map((o,a)=>{let i={prev:t[a-1],next:t[a+1],parent:o};return this.renderNode(o,i)}),{preview:n}=this.config||{};return U(_,{children:[s(B,{children:s(P,{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"}})}),n?s(K,{children:n}):null,s(W,{children:s(C,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:e})})]})}getMappedContent(t,e){var n,r;return((r=(n=t.content)==null?void 0:n.map(o=>this.renderNode(o,e)))==null?void 0:r.filter(o=>o!==null))||[]}renderNode(t,e){var r;let n=t.type||"";if(n in this)return(r=this[t.type])==null?void 0:r.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t){let e=t.text||s(k,{children:"\xA0"});return(t.marks||[]).reduce((r,o)=>{var i;let a=o.type;if(a in this)return(i=this[a])==null?void 0:i.call(this,o,r);throw new Error(`Mark type "${a}" is not supported.`)},s(k,{children:e}))}paragraph(t,e){var l,m,d,S,y,f;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:a}=e||{},i=(o==null?void 0:o.type)==="listItem",p=(a==null?void 0:a.type)==="spacer";return s(z,{style:h({textAlign:r,marginBottom:i||p?"0px":"20px",marginTop:"0px",fontSize:(d=(m=(l=this.config)==null?void 0:l.theme)==null?void 0:m.fontSize)==null?void 0:d.paragraph,color:(f=(y=(S=this.config)==null?void 0:S.theme)==null?void 0:y.colors)==null?void 0:f.paragraph},O),children:t!=null&&t.content?this.getMappedContent(t):s(k,{children:"\xA0"})},g())}text(t){let e=t.text||"&nbsp";return t.marks?this.renderMark(t):e}bold(t,e){return s("strong",{children:e},g())}italic(t,e){return s("em",{children:e},g())}underline(t,e){return s("u",{children:e},g())}strike(t,e){return s("s",{style:{textDecoration:"line-through"},children:e},g())}link(t,e){var i,p,l;let{attrs:n}=t,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 s(I,{href:r,rel:a,style:{fontWeight:500,textDecoration:"underline",color:(l=(p=(i=this.config)==null?void 0:i.theme)==null?void 0:p.colors)==null?void 0:l.heading},target:o,children:e},g())}heading(t,e){var y,f,u;let{attrs:n}=t,{next:r,prev:o}=e||{},a=`h${Number(n==null?void 0:n.level)||1}`,i=(n==null?void 0:n.textAlign)||"left",p=(r==null?void 0:r.type)==="spacer",l=(o==null?void 0:o.type)==="spacer",{fontSize:m,lineHeight:d,fontWeight:S}=Q[a]||{};return s(F,{as:a,style:{textAlign:i,color:(u=(f=(y=this.config)==null?void 0:y.theme)==null?void 0:f.colors)==null?void 0:u.heading,marginBottom:p?"0px":"12px",marginTop:"0px",fontSize:m,lineHeight:d,fontWeight:S},children:this.getMappedContent(t)},g())}variable(t){let{attrs:e}=t,n=(e==null?void 0:e.id)||"";return s(k,{children:`{{${n}}}`})}horizontalRule(t,e){return s($,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){return s(C,{children:s("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t)})},g())}bulletList(t,e){return s(C,{children:s("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t)})},g())}listItem(t,e){return s("li",{style:h({marginBottom:"8px",paddingLeft:"6px"},O),children:this.getMappedContent(t,J(h({},e),{parent:t}))},g())}button(t,e){let{attrs:n}=t,{text:r,url:o,variant:a,buttonColor:i,textColor:p,borderRadius:l,alignment:m="left"}=n||{},d="0px";return l==="round"?d="9999px":l==="smooth"&&(d="6px"),s(C,{style:{textAlign:m},children:s(D,{href:o,style:{color:String(p),backgroundColor:a==="filled"?String(i):"transparent",borderColor:String(i),padding:a==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:r})},g())}spacer(t,e){let{attrs:n}=t,{height:r="auto"}=n||{};return s(C,{style:{height:G[r]||r}},g())}hardBreak(t,e){return s("br",{},g())}logo(t,e){let{attrs:n}=t,{src:r,alt:o,title:a,size:i,alignment:p}=n||{},l={marginRight:"auto"};p==="center"?l={marginRight:"auto",marginLeft:"auto"}:p==="right"&&(l={marginLeft:"auto"});let{next:m}=e||{},d=(m==null?void 0:m.type)==="spacer";return s(M,{alt:o||a||"Logo",src:r,style:J(h({width:X[i]||i,height:X[i]||i},l),{marginBottom:d?"0px":"32px"}),title:a||o||"Logo"},g())}image(t,e){let{attrs:n}=t,{src:r,alt:o,title:a}=n||{},{next:i}=e||{},p=(i==null?void 0:i.type)==="spacer";return s(M,{alt:o||a||"Image",src:r,style:{height:"auto",width:"auto",maxWidth:"100%",marginBottom:p?"0px":"32px",marginTop:"0px"},title:a||o||"Image"},g())}footer(t,e){var i,p,l,m,d,S,y,f,u,v,w;let{attrs:n}=t,{textAlign:r="left"}=n||{},{next:o}=e||{},a=(o==null?void 0:o.type)==="spacer";return s(z,{style:h({fontSize:(m=(l=(p=(i=this.config)==null?void 0:i.theme)==null?void 0:p.fontSize)==null?void 0:l.footer)==null?void 0:m.size,lineHeight:(f=(y=(S=(d=this.config)==null?void 0:d.theme)==null?void 0:S.fontSize)==null?void 0:y.footer)==null?void 0:f.lineHeight,color:(w=(v=(u=this.config)==null?void 0:u.theme)==null?void 0:v.colors)==null?void 0:w.footer,marginTop:"0px",marginBottom:a?"0px":"20px",textAlign:r},O),children:this.getMappedContent(t)},g())}};function st(c,t){return new x(c,t).render()}function lt(c,t){return N(this,null,function*(){return new x(c,t).renderAsync()})}export{x as Maily,st as render,lt as renderAsync};
1
+ // @ts-nocheck
2
+
3
+ var z=Object.defineProperty,M=Object.defineProperties;var A=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var k=(g,t,e)=>t in g?z(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,d=(g,t)=>{for(var e in t||(t={}))H.call(t,e)&&k(g,e,t[e]);if(v)for(var e of v(t))T.call(t,e)&&k(g,e,t[e]);return g},N=(g,t)=>M(g,A(t));var J=(g,t,e)=>new Promise((n,r)=>{var o=p=>{try{a(e.next(p))}catch(l){r(l)}},s=p=>{try{a(e.throw(p))}catch(l){r(l)}},a=p=>p.done?n(p.value):Promise.resolve(p.value).then(o,s);a((e=e.apply(g,t)).next())});import{Fragment as E}from"react";import{Text as w,Html as L,Head as R,Body as _,Font as B,Container as x,Link as W,Heading as P,Hr as F,Button as I,Img as b,Preview as $}from"@react-email/components";import{render as D,renderAsync as K}from"@react-email/render";function C(){return Math.random().toString(36).substr(2,6)}import{Fragment as u,jsx as i,jsxs as G}from"react/jsx-runtime";var j={sm:"8px",md:"16px",lg:"32px",xl:"64px"},O={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 X={sm:"40px",md:"48px",lg:"64px"},h=class{constructor(t={type:"doc",content:[]},e={}){this.config={options:{pretty:!1,plainText:!1},theme:{colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}}};this.content=t,this.config=d(d({},this.config),e)}render(){let t=this.config.options||{},e=this.markup();return D(e,t)}renderAsync(){return J(this,null,function*(){let t=this.config.options||{},e=this.markup();return K(e,t)})}markup(){let t=this.content.content||[],e=t.map((o,s)=>{let a={prev:t[s-1],next:t[s+1],parent:o},p=this.renderNode(o,a);return p?i(E,{children:p},C()):null}),{preview:n}=this.config;return G(L,{children:[i(R,{children:i(B,{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"}})}),n?i($,{children:n}):null,i(_,{children:i(x,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:e})})]})}getMappedContent(t,e){var n,r;return(r=(n=t.content)==null?void 0:n.map(o=>{let s=this.renderNode(o,e);return s?i(E,{children:s},C()):null}))==null?void 0:r.filter(o=>o!==null)}renderNode(t,e={}){var r;let n=t.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t){let e=t.text||i(u,{children:"\xA0"});return(t.marks||[]).reduce((r,o)=>{var a;let s=o.type;if(s in this)return(a=this[s])==null?void 0:a.call(this,o,r);throw new Error(`Mark type "${s}" is not supported.`)},i(u,{children:e}))}paragraph(t,e){var l,m,c,f;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:s}=e||{},a=(o==null?void 0:o.type)==="listItem",p=(s==null?void 0:s.type)==="spacer";return i(w,{style:d({textAlign:r,marginBottom:a||p?"0px":"20px",marginTop:"0px",fontSize:(m=(l=this.config.theme)==null?void 0:l.fontSize)==null?void 0:m.paragraph,color:(f=(c=this.config.theme)==null?void 0:c.colors)==null?void 0:f.paragraph},O),children:t.content?this.getMappedContent(t):i(u,{children:"\xA0"})})}text(t,e){let n=t.text||"&nbsp";return t.marks?this.renderMark(t):i(u,{children:n})}bold(t,e){return i("strong",{children:e})}italic(t,e){return i("em",{children:e})}underline(t,e){return i("u",{children:e})}strike(t,e){return i("s",{style:{textDecoration:"line-through"},children:e})}link(t,e){var a,p;let{attrs:n}=t,r=(n==null?void 0:n.href)||"#",o=(n==null?void 0:n.target)||"_blank",s=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return i(W,{href:r,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(p=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:p.heading},target:o,children:e})}heading(t,e){var S,y;let{attrs:n}=t,{next:r,prev:o}=e||{},s=`h${Number(n==null?void 0:n.level)||1}`,a=(n==null?void 0:n.textAlign)||"left",p=(r==null?void 0:r.type)==="spacer",l=(o==null?void 0:o.type)==="spacer",{fontSize:m,lineHeight:c,fontWeight:f}=q[s];return i(P,{as:s,style:{textAlign:a,color:(y=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:y.heading,marginBottom:p?"0px":"12px",marginTop:"0px",fontSize:m,lineHeight:c,fontWeight:f},children:this.getMappedContent(t)})}variable(t,e){let{attrs:n}=t,r=(n==null?void 0:n.id)||"";return i(u,{children:`{{${r}}}`})}horizontalRule(t,e){return i(F,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){return i(x,{children:i("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t)})})}bulletList(t,e){return i(x,{children:i("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t)})})}listItem(t,e){return i("li",{style:d({marginBottom:"8px",paddingLeft:"6px"},O),children:this.getMappedContent(t,N(d({},e),{parent:t}))})}button(t,e){let{attrs:n}=t,{text:r,url:o,variant:s,buttonColor:a,textColor:p,borderRadius:l,alignment:m="left"}=n||{},c="0px";return l==="round"?c="9999px":l==="smooth"&&(c="6px"),i(x,{style:{textAlign:m},children:i(I,{href:o,style:{color:String(p),backgroundColor:s==="filled"?String(a):"transparent",borderColor:String(a),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:c},children:r})})}spacer(t,e){let{attrs:n}=t,{height:r="auto"}=n||{};return i(x,{style:{height:j[r]||r}})}hardBreak(t,e){return i("br",{})}logo(t,e){let{attrs:n}=t,{src:r,alt:o,title:s,size:a,alignment:p}=n||{},l={marginRight:"auto"};p==="center"?l={marginRight:"auto",marginLeft:"auto"}:p==="right"&&(l={marginLeft:"auto"});let{next:m}=e||{},c=(m==null?void 0:m.type)==="spacer";return i(b,{alt:o||s||"Logo",src:r,style:N(d({width:X[a]||a,height:X[a]||a},l),{marginBottom:c?"0px":"32px"}),title:s||o||"Logo"})}image(t,e){let{attrs:n}=t,{src:r,alt:o,title:s}=n||{},{next:a}=e||{},p=(a==null?void 0:a.type)==="spacer";return i(b,{alt:o||s||"Image",src:r,style:{height:"auto",width:"auto",maxWidth:"100%",marginBottom:p?"0px":"32px",marginTop:"0px"},title:s||o||"Image"})}footer(t,e){var a,p,l,m,c,f,S,y;let{attrs:n}=t,{textAlign:r="left"}=n||{},{next:o}=e||{},s=(o==null?void 0:o.type)==="spacer";return i(w,{style:d({fontSize:(l=(p=(a=this.config.theme)==null?void 0:a.fontSize)==null?void 0:p.footer)==null?void 0:l.size,lineHeight:(f=(c=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:c.footer)==null?void 0:f.lineHeight,color:(y=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:y.footer,marginTop:"0px",marginBottom:s?"0px":"20px",textAlign:r},O),children:this.getMappedContent(t)})}};function it(g,t){return new h(g,t).render()}function pt(g,t){return J(this,null,function*(){return new h(g,t).renderAsync()})}export{h as Maily,it as render,pt as renderAsync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maily-to/render",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "description": "A transformer that converts Maily content into HTML email templates.",
6
6
  "sideEffects": false,
@@ -47,16 +47,18 @@
47
47
  "node": ">=18.0.0"
48
48
  },
49
49
  "devDependencies": {
50
+ "@babel/preset-react": "^7.23.3",
51
+ "@types/react": "^18.2.39",
50
52
  "eslint-config-custom": "workspace:*",
51
53
  "tsconfig": "workspace:*",
52
- "typescript": "^5.0.0"
54
+ "typescript": "^5.3.2"
53
55
  },
54
56
  "dependencies": {
55
57
  "@react-email/components": "^0.0.11",
56
58
  "@react-email/render": "^0.0.9"
57
59
  },
58
60
  "peerDependencies": {
59
- "react": "latest"
61
+ "react": "18.2.0"
60
62
  },
61
63
  "publishConfig": {
62
64
  "access": "public"