@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 +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
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||" ";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
|
-
|
|
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||" ";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.
|
|
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.
|
|
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": "
|
|
61
|
+
"react": "18.2.0"
|
|
60
62
|
},
|
|
61
63
|
"publishConfig": {
|
|
62
64
|
"access": "public"
|