@maily-to/render 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface JSONContent {
4
+ type?: string;
5
+ attrs?: Record<string, any>;
6
+ content?: JSONContent[];
7
+ marks?: {
8
+ type: string;
9
+ attrs?: Record<string, any>;
10
+ [key: string]: any;
11
+ }[];
12
+ text?: string;
13
+ [key: string]: any;
14
+ }
15
+ interface RenderOptions {
16
+ pretty?: boolean;
17
+ plainText?: boolean;
18
+ }
19
+ interface MarkType {
20
+ [key: string]: any;
21
+ type: string;
22
+ attrs?: Record<string, any> | undefined;
23
+ }
24
+ declare const allowedSpacers: readonly ["sm", "md", "lg", "xl"];
25
+ type AllowedSpacers = (typeof allowedSpacers)[number];
26
+ interface MailyConfig {
27
+ /**
28
+ * The options object allows you to customize the output of the rendered
29
+ * email.
30
+ * - `pretty` - If `true`, the output will be formatted with indentation and
31
+ * line breaks.
32
+ * - `plainText` - If `true`, the output will be plain text instead of HTML.
33
+ * This is useful for testing purposes.
34
+ *
35
+ * Default: `{ pretty: false, plainText: false }`
36
+ *
37
+ * @example
38
+ * ```js
39
+ * const maily = new Maily(content, {
40
+ * options: {
41
+ * pretty: true,
42
+ * plainText: true,
43
+ * },
44
+ * });
45
+ * ```
46
+ */
47
+ options?: RenderOptions;
48
+ /**
49
+ * The preview text is the snippet of text that is pulled into the inbox
50
+ * preview of an email client, usually right after the subject line.
51
+ *
52
+ * Default: `undefined`
53
+ */
54
+ preview?: string;
55
+ /**
56
+ * The theme object allows you to customize the colors and font sizes of the
57
+ * rendered email.
58
+ *
59
+ * Default:
60
+ * ```js
61
+ * {
62
+ * colors: {
63
+ * heading: 'rgb(17, 24, 39)',
64
+ * paragraph: 'rgb(55, 65, 81)',
65
+ * horizontal: 'rgb(234, 234, 234)',
66
+ * footer: 'rgb(100, 116, 139)',
67
+ * },
68
+ * fontSize: {
69
+ * paragraph: '15px',
70
+ * footer: {
71
+ * size: '14px',
72
+ * lineHeight: '24px',
73
+ * },
74
+ * },
75
+ * }
76
+ * ```
77
+ *
78
+ * @example
79
+ * ```js
80
+ * const maily = new Maily(content, {
81
+ * theme: {
82
+ * colors: {
83
+ * heading: 'rgb(17, 24, 39)',
84
+ * },
85
+ * fontSize: {
86
+ * footer: {
87
+ * size: '14px',
88
+ * lineHeight: '24px',
89
+ * },
90
+ * },
91
+ * },
92
+ * });
93
+ * ```
94
+ */
95
+ theme?: {
96
+ colors?: {
97
+ heading?: string;
98
+ paragraph?: string;
99
+ horizontal?: string;
100
+ footer?: string;
101
+ };
102
+ fontSize?: {
103
+ paragraph?: string;
104
+ footer?: {
105
+ size?: string;
106
+ lineHeight?: string;
107
+ };
108
+ };
109
+ };
110
+ }
111
+ declare class Maily {
112
+ private readonly content;
113
+ private config;
114
+ constructor(content?: JSONContent, config?: Partial<MailyConfig>);
115
+ render(): string;
116
+ renderAsync(): Promise<string>;
117
+ markup(): react_jsx_runtime.JSX.Element;
118
+ private getMappedContent;
119
+ private renderNode;
120
+ private renderMark;
121
+ private paragraph;
122
+ private text;
123
+ private bold;
124
+ private italic;
125
+ private underline;
126
+ private strike;
127
+ private link;
128
+ private heading;
129
+ private variable;
130
+ private horizontalRule;
131
+ private orderedList;
132
+ private bulletList;
133
+ private listItem;
134
+ private button;
135
+ private spacer;
136
+ private hardBreak;
137
+ private logo;
138
+ private image;
139
+ private footer;
140
+ }
141
+
142
+ declare function render(content: JSONContent, config?: MailyConfig): string;
143
+
144
+ declare function renderAsync(content: JSONContent, config?: MailyConfig): Promise<string>;
145
+
146
+ export { type AllowedSpacers, type JSONContent, Maily, type MailyConfig, type MarkType, type RenderOptions, render, renderAsync };
@@ -0,0 +1,146 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface JSONContent {
4
+ type?: string;
5
+ attrs?: Record<string, any>;
6
+ content?: JSONContent[];
7
+ marks?: {
8
+ type: string;
9
+ attrs?: Record<string, any>;
10
+ [key: string]: any;
11
+ }[];
12
+ text?: string;
13
+ [key: string]: any;
14
+ }
15
+ interface RenderOptions {
16
+ pretty?: boolean;
17
+ plainText?: boolean;
18
+ }
19
+ interface MarkType {
20
+ [key: string]: any;
21
+ type: string;
22
+ attrs?: Record<string, any> | undefined;
23
+ }
24
+ declare const allowedSpacers: readonly ["sm", "md", "lg", "xl"];
25
+ type AllowedSpacers = (typeof allowedSpacers)[number];
26
+ interface MailyConfig {
27
+ /**
28
+ * The options object allows you to customize the output of the rendered
29
+ * email.
30
+ * - `pretty` - If `true`, the output will be formatted with indentation and
31
+ * line breaks.
32
+ * - `plainText` - If `true`, the output will be plain text instead of HTML.
33
+ * This is useful for testing purposes.
34
+ *
35
+ * Default: `{ pretty: false, plainText: false }`
36
+ *
37
+ * @example
38
+ * ```js
39
+ * const maily = new Maily(content, {
40
+ * options: {
41
+ * pretty: true,
42
+ * plainText: true,
43
+ * },
44
+ * });
45
+ * ```
46
+ */
47
+ options?: RenderOptions;
48
+ /**
49
+ * The preview text is the snippet of text that is pulled into the inbox
50
+ * preview of an email client, usually right after the subject line.
51
+ *
52
+ * Default: `undefined`
53
+ */
54
+ preview?: string;
55
+ /**
56
+ * The theme object allows you to customize the colors and font sizes of the
57
+ * rendered email.
58
+ *
59
+ * Default:
60
+ * ```js
61
+ * {
62
+ * colors: {
63
+ * heading: 'rgb(17, 24, 39)',
64
+ * paragraph: 'rgb(55, 65, 81)',
65
+ * horizontal: 'rgb(234, 234, 234)',
66
+ * footer: 'rgb(100, 116, 139)',
67
+ * },
68
+ * fontSize: {
69
+ * paragraph: '15px',
70
+ * footer: {
71
+ * size: '14px',
72
+ * lineHeight: '24px',
73
+ * },
74
+ * },
75
+ * }
76
+ * ```
77
+ *
78
+ * @example
79
+ * ```js
80
+ * const maily = new Maily(content, {
81
+ * theme: {
82
+ * colors: {
83
+ * heading: 'rgb(17, 24, 39)',
84
+ * },
85
+ * fontSize: {
86
+ * footer: {
87
+ * size: '14px',
88
+ * lineHeight: '24px',
89
+ * },
90
+ * },
91
+ * },
92
+ * });
93
+ * ```
94
+ */
95
+ theme?: {
96
+ colors?: {
97
+ heading?: string;
98
+ paragraph?: string;
99
+ horizontal?: string;
100
+ footer?: string;
101
+ };
102
+ fontSize?: {
103
+ paragraph?: string;
104
+ footer?: {
105
+ size?: string;
106
+ lineHeight?: string;
107
+ };
108
+ };
109
+ };
110
+ }
111
+ declare class Maily {
112
+ private readonly content;
113
+ private config;
114
+ constructor(content?: JSONContent, config?: Partial<MailyConfig>);
115
+ render(): string;
116
+ renderAsync(): Promise<string>;
117
+ markup(): react_jsx_runtime.JSX.Element;
118
+ private getMappedContent;
119
+ private renderNode;
120
+ private renderMark;
121
+ private paragraph;
122
+ private text;
123
+ private bold;
124
+ private italic;
125
+ private underline;
126
+ private strike;
127
+ private link;
128
+ private heading;
129
+ private variable;
130
+ private horizontalRule;
131
+ private orderedList;
132
+ private bulletList;
133
+ private listItem;
134
+ private button;
135
+ private spacer;
136
+ private hardBreak;
137
+ private logo;
138
+ private image;
139
+ private footer;
140
+ }
141
+
142
+ declare function render(content: JSONContent, config?: MailyConfig): string;
143
+
144
+ declare function renderAsync(content: JSONContent, config?: MailyConfig): Promise<string>;
145
+
146
+ export { type AllowedSpacers, type JSONContent, Maily, type MailyConfig, type MarkType, type RenderOptions, render, renderAsync };
package/dist/index.js ADDED
@@ -0,0 +1 @@
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});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
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};
package/license ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Arik Chakma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@maily-to/render",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "description": "A transformer that converts Maily content into HTML email templates.",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist/**"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "import": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.mjs"
18
+ },
19
+ "require": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ }
23
+ }
24
+ },
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "dev": "tsup --watch",
28
+ "clean": "rm -rf dist",
29
+ "build": "tsup",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix",
32
+ "test:watch": "vitest",
33
+ "test": "vitest run"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/arikchakma/maily.to.git",
38
+ "directory": "packages/render"
39
+ },
40
+ "author": "Arik Chakma <arikchangma@gmail.com>",
41
+ "keywords": [
42
+ "maily.to",
43
+ "react",
44
+ "email"
45
+ ],
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "devDependencies": {
50
+ "eslint-config-custom": "workspace:*",
51
+ "tsconfig": "workspace:*",
52
+ "typescript": "^5.0.0"
53
+ },
54
+ "dependencies": {
55
+ "@react-email/components": "^0.0.11",
56
+ "@react-email/render": "^0.0.9"
57
+ },
58
+ "peerDependencies": {
59
+ "react": "latest"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ }
64
+ }
package/readme.md ADDED
@@ -0,0 +1,63 @@
1
+ <div align="center"><img height="150" src="https://maily.to/brand/icon.svg" /></div>
2
+ <br>
3
+
4
+ <div align="center"><strong>@arikchakma/maily</strong></div>
5
+ <div align="center">Transform <a href="https://maily.to">Maily</a> content into HTML email templates.</div>
6
+ <br />
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/arikchakma/maily/blob/main/license">
10
+ <img src="https://img.shields.io/badge/License-MIT-yellow.svg" />
11
+ </a>
12
+ <a href="https://maily.to">
13
+ <img src="https://img.shields.io/badge/%E2%9C%A8-Get%20Editor-0a0a0a.svg?style=flat&colorA=0a0a0a" alt="Get Maily Editor" />
14
+ </a>
15
+ </p>
16
+
17
+ <br>
18
+
19
+ ## Install
20
+
21
+ Install `maily` from your command line.
22
+
23
+ #### With bun
24
+
25
+ ```sh
26
+ pnpm add @maily-to/render
27
+ bun add @maily-to/render
28
+ yarn add @maily-to/render
29
+ npm install @maily-to/render
30
+ ```
31
+
32
+ <br>
33
+
34
+ ## Getting started
35
+
36
+ Convert React components into a HTML string.
37
+
38
+ ```jsx
39
+ import { render } from '@maily-to/render';
40
+
41
+ const html = render({
42
+ type: 'doc',
43
+ content: [
44
+ {
45
+ type: 'paragraph',
46
+ content: [
47
+ {
48
+ type: 'text',
49
+ text: 'Hello World!',
50
+ },
51
+ ],
52
+ },
53
+ ],
54
+ });
55
+ ```
56
+
57
+ ## Contributions
58
+
59
+ Feel free to submit pull requests, create issues, or spread the word.
60
+
61
+ ## License
62
+
63
+ MIT &copy; [Arik Chakma](https://twitter.com/imarikchakma)