@react-email/render 0.0.11-canary.0 → 0.0.11
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 +20 -8
- package/dist/index.d.ts +20 -8
- package/dist/index.js +19 -17
- package/dist/index.mjs +18 -17
- package/package.json +2 -2
- package/readme.md +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
|
|
3
|
+
type Options = {
|
|
2
4
|
pretty?: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
} & ({
|
|
6
|
+
plainText?: false;
|
|
7
|
+
} | {
|
|
8
|
+
plainText?: true;
|
|
9
|
+
/**
|
|
10
|
+
* These are options you can pass down directly to the library we use for
|
|
11
|
+
* converting the rendered email's HTML into plain text.
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/html-to-text/node-html-to-text
|
|
14
|
+
*/
|
|
15
|
+
htmlToTextOptions?: HtmlToTextOptions;
|
|
16
|
+
});
|
|
17
|
+
|
|
5
18
|
declare const render: (component: React.ReactElement, options?: Options) => string;
|
|
6
19
|
|
|
7
|
-
declare const renderAsync: (component: React.ReactElement, options?:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) => Promise<string>;
|
|
20
|
+
declare const renderAsync: (component: React.ReactElement, options?: Options) => Promise<string>;
|
|
21
|
+
|
|
22
|
+
declare const plainTextSelectors: SelectorDefinition[];
|
|
11
23
|
|
|
12
|
-
export { Options, render, renderAsync };
|
|
24
|
+
export { Options, plainTextSelectors, render, renderAsync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
|
|
3
|
+
type Options = {
|
|
2
4
|
pretty?: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
} & ({
|
|
6
|
+
plainText?: false;
|
|
7
|
+
} | {
|
|
8
|
+
plainText?: true;
|
|
9
|
+
/**
|
|
10
|
+
* These are options you can pass down directly to the library we use for
|
|
11
|
+
* converting the rendered email's HTML into plain text.
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/html-to-text/node-html-to-text
|
|
14
|
+
*/
|
|
15
|
+
htmlToTextOptions?: HtmlToTextOptions;
|
|
16
|
+
});
|
|
17
|
+
|
|
5
18
|
declare const render: (component: React.ReactElement, options?: Options) => string;
|
|
6
19
|
|
|
7
|
-
declare const renderAsync: (component: React.ReactElement, options?:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) => Promise<string>;
|
|
20
|
+
declare const renderAsync: (component: React.ReactElement, options?: Options) => Promise<string>;
|
|
21
|
+
|
|
22
|
+
declare const plainTextSelectors: SelectorDefinition[];
|
|
11
23
|
|
|
12
|
-
export { Options, render, renderAsync };
|
|
24
|
+
export { Options, plainTextSelectors, render, renderAsync };
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
70
70
|
// src/index.ts
|
|
71
71
|
var src_exports = {};
|
|
72
72
|
__export(src_exports, {
|
|
73
|
+
plainTextSelectors: () => plainTextSelectors,
|
|
73
74
|
render: () => render,
|
|
74
75
|
renderAsync: () => renderAsync
|
|
75
76
|
});
|
|
@@ -92,6 +93,16 @@ var pretty = (str, options = {}) => {
|
|
|
92
93
|
return (0, import_js_beautify.html)(str, __spreadValues(__spreadValues({}, defaults), options));
|
|
93
94
|
};
|
|
94
95
|
|
|
96
|
+
// src/plain-text-selectors.ts
|
|
97
|
+
var plainTextSelectors = [
|
|
98
|
+
{ selector: "img", format: "skip" },
|
|
99
|
+
{ selector: "#__react-email-preview", format: "skip" },
|
|
100
|
+
{
|
|
101
|
+
selector: "a",
|
|
102
|
+
options: { linkBrackets: false }
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
|
|
95
106
|
// src/render.ts
|
|
96
107
|
var render = (component, options) => {
|
|
97
108
|
if (options == null ? void 0 : options.plainText) {
|
|
@@ -105,17 +116,10 @@ var render = (component, options) => {
|
|
|
105
116
|
}
|
|
106
117
|
return document;
|
|
107
118
|
};
|
|
108
|
-
var renderAsPlainText = (component,
|
|
109
|
-
return (0, import_html_to_text.convert)(ReactDomServer.renderToStaticMarkup(component), {
|
|
110
|
-
selectors:
|
|
111
|
-
|
|
112
|
-
{ selector: "#__react-email-preview", format: "skip" },
|
|
113
|
-
{
|
|
114
|
-
selector: "a",
|
|
115
|
-
options: { linkBrackets: false }
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
});
|
|
119
|
+
var renderAsPlainText = (component, options) => {
|
|
120
|
+
return (0, import_html_to_text.convert)(ReactDomServer.renderToStaticMarkup(component), __spreadValues({
|
|
121
|
+
selectors: plainTextSelectors
|
|
122
|
+
}, (options == null ? void 0 : options.plainText) === true ? options.htmlToTextOptions : {}));
|
|
119
123
|
};
|
|
120
124
|
|
|
121
125
|
// src/render-async.ts
|
|
@@ -159,12 +163,9 @@ var renderAsync = (component, options) => __async(void 0, null, function* () {
|
|
|
159
163
|
const htmlOrReadableStream = yield renderToStream(component);
|
|
160
164
|
const html2 = typeof htmlOrReadableStream === "string" ? htmlOrReadableStream : yield readStream(htmlOrReadableStream);
|
|
161
165
|
if (options == null ? void 0 : options.plainText) {
|
|
162
|
-
return (0, import_html_to_text2.convert)(html2, {
|
|
163
|
-
selectors:
|
|
164
|
-
|
|
165
|
-
{ selector: "#__react-email-preview", format: "skip" }
|
|
166
|
-
]
|
|
167
|
-
});
|
|
166
|
+
return (0, import_html_to_text2.convert)(html2, __spreadValues({
|
|
167
|
+
selectors: plainTextSelectors
|
|
168
|
+
}, options.htmlToTextOptions));
|
|
168
169
|
}
|
|
169
170
|
const document = `${doctype}${html2}`;
|
|
170
171
|
if (options == null ? void 0 : options.pretty) {
|
|
@@ -174,6 +175,7 @@ var renderAsync = (component, options) => __async(void 0, null, function* () {
|
|
|
174
175
|
});
|
|
175
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
176
177
|
0 && (module.exports = {
|
|
178
|
+
plainTextSelectors,
|
|
177
179
|
render,
|
|
178
180
|
renderAsync
|
|
179
181
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,16 @@ var pretty = (str, options = {}) => {
|
|
|
58
58
|
return html(str, __spreadValues(__spreadValues({}, defaults), options));
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
// src/plain-text-selectors.ts
|
|
62
|
+
var plainTextSelectors = [
|
|
63
|
+
{ selector: "img", format: "skip" },
|
|
64
|
+
{ selector: "#__react-email-preview", format: "skip" },
|
|
65
|
+
{
|
|
66
|
+
selector: "a",
|
|
67
|
+
options: { linkBrackets: false }
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
|
|
61
71
|
// src/render.ts
|
|
62
72
|
var render = (component, options) => {
|
|
63
73
|
if (options == null ? void 0 : options.plainText) {
|
|
@@ -71,17 +81,10 @@ var render = (component, options) => {
|
|
|
71
81
|
}
|
|
72
82
|
return document;
|
|
73
83
|
};
|
|
74
|
-
var renderAsPlainText = (component,
|
|
75
|
-
return convert(ReactDomServer.renderToStaticMarkup(component), {
|
|
76
|
-
selectors:
|
|
77
|
-
|
|
78
|
-
{ selector: "#__react-email-preview", format: "skip" },
|
|
79
|
-
{
|
|
80
|
-
selector: "a",
|
|
81
|
-
options: { linkBrackets: false }
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
});
|
|
84
|
+
var renderAsPlainText = (component, options) => {
|
|
85
|
+
return convert(ReactDomServer.renderToStaticMarkup(component), __spreadValues({
|
|
86
|
+
selectors: plainTextSelectors
|
|
87
|
+
}, (options == null ? void 0 : options.plainText) === true ? options.htmlToTextOptions : {}));
|
|
85
88
|
};
|
|
86
89
|
|
|
87
90
|
// src/render-async.ts
|
|
@@ -125,12 +128,9 @@ var renderAsync = (component, options) => __async(void 0, null, function* () {
|
|
|
125
128
|
const htmlOrReadableStream = yield renderToStream(component);
|
|
126
129
|
const html2 = typeof htmlOrReadableStream === "string" ? htmlOrReadableStream : yield readStream(htmlOrReadableStream);
|
|
127
130
|
if (options == null ? void 0 : options.plainText) {
|
|
128
|
-
return convert2(html2, {
|
|
129
|
-
selectors:
|
|
130
|
-
|
|
131
|
-
{ selector: "#__react-email-preview", format: "skip" }
|
|
132
|
-
]
|
|
133
|
-
});
|
|
131
|
+
return convert2(html2, __spreadValues({
|
|
132
|
+
selectors: plainTextSelectors
|
|
133
|
+
}, options.htmlToTextOptions));
|
|
134
134
|
}
|
|
135
135
|
const document = `${doctype}${html2}`;
|
|
136
136
|
if (options == null ? void 0 : options.pretty) {
|
|
@@ -139,6 +139,7 @@ var renderAsync = (component, options) => __async(void 0, null, function* () {
|
|
|
139
139
|
return document;
|
|
140
140
|
});
|
|
141
141
|
export {
|
|
142
|
+
plainTextSelectors,
|
|
142
143
|
render,
|
|
143
144
|
renderAsync
|
|
144
145
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-email/render",
|
|
3
|
-
"version": "0.0.11
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Transform React components into HTML email templates",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/
|
|
27
|
+
"url": "https://github.com/resend/react-email.git",
|
|
28
28
|
"directory": "packages/render"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div align="center">
|
|
7
7
|
<a href="https://react.email">Website</a>
|
|
8
8
|
<span> · </span>
|
|
9
|
-
<a href="https://github.com/
|
|
9
|
+
<a href="https://github.com/resend/react-email">GitHub</a>
|
|
10
10
|
<span> · </span>
|
|
11
11
|
<a href="https://react.email/discord">Discord</a>
|
|
12
12
|
</div>
|