@react-email/render 1.0.5 → 1.1.0-canary.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.
- package/dist/browser/index.d.mts +12 -3
- package/dist/browser/index.d.ts +12 -3
- package/dist/browser/index.js +6 -75
- package/dist/browser/index.mjs +5 -75
- package/dist/node/index.d.mts +10 -4
- package/dist/node/index.d.ts +10 -4
- package/dist/node/index.js +6 -39
- package/dist/node/index.mjs +5 -39
- package/package.json +4 -5
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
import { Options as Options$1 } from 'prettier';
|
|
2
3
|
|
|
3
4
|
type Options = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use {@link pretty} instead
|
|
7
|
+
*/
|
|
4
8
|
pretty?: boolean;
|
|
5
9
|
} & ({
|
|
6
10
|
plainText?: false;
|
|
@@ -17,8 +21,13 @@ type Options = {
|
|
|
17
21
|
|
|
18
22
|
declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
19
23
|
|
|
20
|
-
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
21
|
-
|
|
22
24
|
declare const plainTextSelectors: SelectorDefinition[];
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
declare const pretty: (str: string, options?: Options$1) => Promise<string>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated use {@link render}
|
|
30
|
+
*/
|
|
31
|
+
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
32
|
+
|
|
33
|
+
export { Options, plainTextSelectors, pretty, render, renderAsync };
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
import { Options as Options$1 } from 'prettier';
|
|
2
3
|
|
|
3
4
|
type Options = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use {@link pretty} instead
|
|
7
|
+
*/
|
|
4
8
|
pretty?: boolean;
|
|
5
9
|
} & ({
|
|
6
10
|
plainText?: false;
|
|
@@ -17,8 +21,13 @@ type Options = {
|
|
|
17
21
|
|
|
18
22
|
declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
19
23
|
|
|
20
|
-
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
21
|
-
|
|
22
24
|
declare const plainTextSelectors: SelectorDefinition[];
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
declare const pretty: (str: string, options?: Options$1) => Promise<string>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated use {@link render}
|
|
30
|
+
*/
|
|
31
|
+
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
32
|
+
|
|
33
|
+
export { Options, plainTextSelectors, pretty, render, renderAsync };
|
package/dist/browser/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
68
68
|
var browser_exports = {};
|
|
69
69
|
__export(browser_exports, {
|
|
70
70
|
plainTextSelectors: () => plainTextSelectors,
|
|
71
|
+
pretty: () => pretty,
|
|
71
72
|
render: () => render,
|
|
72
73
|
renderAsync: () => renderAsync
|
|
73
74
|
});
|
|
@@ -222,84 +223,14 @@ var render = (element, options) => __async(void 0, null, function* () {
|
|
|
222
223
|
return document;
|
|
223
224
|
});
|
|
224
225
|
|
|
225
|
-
// src/browser/
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// src/browser/read-stream.ts
|
|
230
|
-
var decoder2 = new TextDecoder("utf-8");
|
|
231
|
-
var readStream2 = (stream) => __async(void 0, null, function* () {
|
|
232
|
-
const chunks = [];
|
|
233
|
-
if ("pipeTo" in stream) {
|
|
234
|
-
const writableStream = new WritableStream({
|
|
235
|
-
write(chunk) {
|
|
236
|
-
chunks.push(chunk);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
yield stream.pipeTo(writableStream);
|
|
240
|
-
} else {
|
|
241
|
-
throw new Error(
|
|
242
|
-
"For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
|
|
243
|
-
{
|
|
244
|
-
cause: {
|
|
245
|
-
stream
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
let length = 0;
|
|
251
|
-
chunks.forEach((item) => {
|
|
252
|
-
length += item.length;
|
|
253
|
-
});
|
|
254
|
-
const mergedChunks = new Uint8Array(length);
|
|
255
|
-
let offset = 0;
|
|
256
|
-
chunks.forEach((item) => {
|
|
257
|
-
mergedChunks.set(item, offset);
|
|
258
|
-
offset += item.length;
|
|
259
|
-
});
|
|
260
|
-
return decoder2.decode(mergedChunks);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// src/browser/render-async.tsx
|
|
264
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
265
|
-
var renderAsync = (element, options) => __async(void 0, null, function* () {
|
|
266
|
-
const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { children: element });
|
|
267
|
-
const reactDOMServer = yield import("react-dom/server");
|
|
268
|
-
let html2;
|
|
269
|
-
if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
|
|
270
|
-
html2 = yield readStream2(
|
|
271
|
-
yield reactDOMServer.renderToReadableStream(suspendedElement)
|
|
272
|
-
);
|
|
273
|
-
} else {
|
|
274
|
-
yield new Promise((resolve, reject) => {
|
|
275
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
276
|
-
onAllReady() {
|
|
277
|
-
return __async(this, null, function* () {
|
|
278
|
-
html2 = yield readStream2(stream);
|
|
279
|
-
resolve();
|
|
280
|
-
});
|
|
281
|
-
},
|
|
282
|
-
onError(error) {
|
|
283
|
-
reject(error);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (options == null ? void 0 : options.plainText) {
|
|
289
|
-
return (0, import_html_to_text2.convert)(html2, __spreadValues({
|
|
290
|
-
selectors: plainTextSelectors
|
|
291
|
-
}, options.htmlToTextOptions));
|
|
292
|
-
}
|
|
293
|
-
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
294
|
-
const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
295
|
-
if (options == null ? void 0 : options.pretty) {
|
|
296
|
-
return pretty(document);
|
|
297
|
-
}
|
|
298
|
-
return document;
|
|
299
|
-
});
|
|
226
|
+
// src/browser/index.ts
|
|
227
|
+
var renderAsync = (element, options) => {
|
|
228
|
+
return render(element, options);
|
|
229
|
+
};
|
|
300
230
|
// Annotate the CommonJS export names for ESM import in node:
|
|
301
231
|
0 && (module.exports = {
|
|
302
232
|
plainTextSelectors,
|
|
233
|
+
pretty,
|
|
303
234
|
render,
|
|
304
235
|
renderAsync
|
|
305
236
|
});
|
package/dist/browser/index.mjs
CHANGED
|
@@ -187,83 +187,13 @@ var render = (element, options) => __async(void 0, null, function* () {
|
|
|
187
187
|
return document;
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
// src/browser/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// src/browser/read-stream.ts
|
|
195
|
-
var decoder2 = new TextDecoder("utf-8");
|
|
196
|
-
var readStream2 = (stream) => __async(void 0, null, function* () {
|
|
197
|
-
const chunks = [];
|
|
198
|
-
if ("pipeTo" in stream) {
|
|
199
|
-
const writableStream = new WritableStream({
|
|
200
|
-
write(chunk) {
|
|
201
|
-
chunks.push(chunk);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
yield stream.pipeTo(writableStream);
|
|
205
|
-
} else {
|
|
206
|
-
throw new Error(
|
|
207
|
-
"For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
|
|
208
|
-
{
|
|
209
|
-
cause: {
|
|
210
|
-
stream
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
let length = 0;
|
|
216
|
-
chunks.forEach((item) => {
|
|
217
|
-
length += item.length;
|
|
218
|
-
});
|
|
219
|
-
const mergedChunks = new Uint8Array(length);
|
|
220
|
-
let offset = 0;
|
|
221
|
-
chunks.forEach((item) => {
|
|
222
|
-
mergedChunks.set(item, offset);
|
|
223
|
-
offset += item.length;
|
|
224
|
-
});
|
|
225
|
-
return decoder2.decode(mergedChunks);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// src/browser/render-async.tsx
|
|
229
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
230
|
-
var renderAsync = (element, options) => __async(void 0, null, function* () {
|
|
231
|
-
const suspendedElement = /* @__PURE__ */ jsx2(Suspense2, { children: element });
|
|
232
|
-
const reactDOMServer = yield import("react-dom/server");
|
|
233
|
-
let html2;
|
|
234
|
-
if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
|
|
235
|
-
html2 = yield readStream2(
|
|
236
|
-
yield reactDOMServer.renderToReadableStream(suspendedElement)
|
|
237
|
-
);
|
|
238
|
-
} else {
|
|
239
|
-
yield new Promise((resolve, reject) => {
|
|
240
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
241
|
-
onAllReady() {
|
|
242
|
-
return __async(this, null, function* () {
|
|
243
|
-
html2 = yield readStream2(stream);
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
onError(error) {
|
|
248
|
-
reject(error);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
if (options == null ? void 0 : options.plainText) {
|
|
254
|
-
return convert2(html2, __spreadValues({
|
|
255
|
-
selectors: plainTextSelectors
|
|
256
|
-
}, options.htmlToTextOptions));
|
|
257
|
-
}
|
|
258
|
-
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
259
|
-
const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
260
|
-
if (options == null ? void 0 : options.pretty) {
|
|
261
|
-
return pretty(document);
|
|
262
|
-
}
|
|
263
|
-
return document;
|
|
264
|
-
});
|
|
190
|
+
// src/browser/index.ts
|
|
191
|
+
var renderAsync = (element, options) => {
|
|
192
|
+
return render(element, options);
|
|
193
|
+
};
|
|
265
194
|
export {
|
|
266
195
|
plainTextSelectors,
|
|
196
|
+
pretty,
|
|
267
197
|
render,
|
|
268
198
|
renderAsync
|
|
269
199
|
};
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
import { Options as Options$1 } from 'prettier';
|
|
2
3
|
|
|
3
4
|
type Options = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use {@link pretty} instead
|
|
7
|
+
*/
|
|
4
8
|
pretty?: boolean;
|
|
5
9
|
} & ({
|
|
6
10
|
plainText?: false;
|
|
@@ -17,11 +21,13 @@ type Options = {
|
|
|
17
21
|
|
|
18
22
|
declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
19
23
|
|
|
24
|
+
declare const plainTextSelectors: SelectorDefinition[];
|
|
25
|
+
|
|
26
|
+
declare const pretty: (str: string, options?: Options$1) => Promise<string>;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
|
-
* @deprecated use
|
|
29
|
+
* @deprecated use {@link render}
|
|
22
30
|
*/
|
|
23
31
|
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export { Options, plainTextSelectors, render, renderAsync };
|
|
33
|
+
export { Options, plainTextSelectors, pretty, render, renderAsync };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
|
|
2
|
+
import { Options as Options$1 } from 'prettier';
|
|
2
3
|
|
|
3
4
|
type Options = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use {@link pretty} instead
|
|
7
|
+
*/
|
|
4
8
|
pretty?: boolean;
|
|
5
9
|
} & ({
|
|
6
10
|
plainText?: false;
|
|
@@ -17,11 +21,13 @@ type Options = {
|
|
|
17
21
|
|
|
18
22
|
declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
19
23
|
|
|
24
|
+
declare const plainTextSelectors: SelectorDefinition[];
|
|
25
|
+
|
|
26
|
+
declare const pretty: (str: string, options?: Options$1) => Promise<string>;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
|
-
* @deprecated use
|
|
29
|
+
* @deprecated use {@link render}
|
|
22
30
|
*/
|
|
23
31
|
declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export { Options, plainTextSelectors, render, renderAsync };
|
|
33
|
+
export { Options, plainTextSelectors, pretty, render, renderAsync };
|
package/dist/node/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
68
68
|
var node_exports = {};
|
|
69
69
|
__export(node_exports, {
|
|
70
70
|
plainTextSelectors: () => plainTextSelectors,
|
|
71
|
+
pretty: () => pretty,
|
|
71
72
|
render: () => render,
|
|
72
73
|
renderAsync: () => renderAsync
|
|
73
74
|
});
|
|
@@ -220,48 +221,14 @@ var render = (element, options) => __async(void 0, null, function* () {
|
|
|
220
221
|
return document;
|
|
221
222
|
});
|
|
222
223
|
|
|
223
|
-
// src/node/
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var renderAsync = (element, options) => __async(void 0, null, function* () {
|
|
228
|
-
const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { children: element });
|
|
229
|
-
const reactDOMServer = yield import("react-dom/server");
|
|
230
|
-
let html2;
|
|
231
|
-
if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
|
|
232
|
-
html2 = yield readStream(
|
|
233
|
-
yield reactDOMServer.renderToReadableStream(suspendedElement)
|
|
234
|
-
);
|
|
235
|
-
} else {
|
|
236
|
-
yield new Promise((resolve, reject) => {
|
|
237
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
238
|
-
onAllReady() {
|
|
239
|
-
return __async(this, null, function* () {
|
|
240
|
-
html2 = yield readStream(stream);
|
|
241
|
-
resolve();
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
onError(error) {
|
|
245
|
-
reject(error);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
if (options == null ? void 0 : options.plainText) {
|
|
251
|
-
return (0, import_html_to_text2.convert)(html2, __spreadValues({
|
|
252
|
-
selectors: plainTextSelectors
|
|
253
|
-
}, options.htmlToTextOptions));
|
|
254
|
-
}
|
|
255
|
-
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
256
|
-
const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
257
|
-
if (options == null ? void 0 : options.pretty) {
|
|
258
|
-
return pretty(document);
|
|
259
|
-
}
|
|
260
|
-
return document;
|
|
261
|
-
});
|
|
224
|
+
// src/node/index.ts
|
|
225
|
+
var renderAsync = (element, options) => {
|
|
226
|
+
return render(element, options);
|
|
227
|
+
};
|
|
262
228
|
// Annotate the CommonJS export names for ESM import in node:
|
|
263
229
|
0 && (module.exports = {
|
|
264
230
|
plainTextSelectors,
|
|
231
|
+
pretty,
|
|
265
232
|
render,
|
|
266
233
|
renderAsync
|
|
267
234
|
});
|
package/dist/node/index.mjs
CHANGED
|
@@ -185,47 +185,13 @@ var render = (element, options) => __async(void 0, null, function* () {
|
|
|
185
185
|
return document;
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
// src/node/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
var renderAsync = (element, options) => __async(void 0, null, function* () {
|
|
193
|
-
const suspendedElement = /* @__PURE__ */ jsx2(Suspense2, { children: element });
|
|
194
|
-
const reactDOMServer = yield import("react-dom/server");
|
|
195
|
-
let html2;
|
|
196
|
-
if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
|
|
197
|
-
html2 = yield readStream(
|
|
198
|
-
yield reactDOMServer.renderToReadableStream(suspendedElement)
|
|
199
|
-
);
|
|
200
|
-
} else {
|
|
201
|
-
yield new Promise((resolve, reject) => {
|
|
202
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
203
|
-
onAllReady() {
|
|
204
|
-
return __async(this, null, function* () {
|
|
205
|
-
html2 = yield readStream(stream);
|
|
206
|
-
resolve();
|
|
207
|
-
});
|
|
208
|
-
},
|
|
209
|
-
onError(error) {
|
|
210
|
-
reject(error);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
if (options == null ? void 0 : options.plainText) {
|
|
216
|
-
return convert2(html2, __spreadValues({
|
|
217
|
-
selectors: plainTextSelectors
|
|
218
|
-
}, options.htmlToTextOptions));
|
|
219
|
-
}
|
|
220
|
-
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
221
|
-
const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
222
|
-
if (options == null ? void 0 : options.pretty) {
|
|
223
|
-
return pretty(document);
|
|
224
|
-
}
|
|
225
|
-
return document;
|
|
226
|
-
});
|
|
188
|
+
// src/node/index.ts
|
|
189
|
+
var renderAsync = (element, options) => {
|
|
190
|
+
return render(element, options);
|
|
191
|
+
};
|
|
227
192
|
export {
|
|
228
193
|
plainTextSelectors,
|
|
194
|
+
pretty,
|
|
229
195
|
render,
|
|
230
196
|
renderAsync
|
|
231
197
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-email/render",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-canary.1",
|
|
4
4
|
"description": "Transform React components into HTML email templates",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/browser/index.js",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"node": ">=18.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"html-to-text": "9.0.5",
|
|
81
|
-
"prettier": "3.
|
|
82
|
-
"react-promise-suspense": "0.3.4"
|
|
80
|
+
"html-to-text": "^9.0.5",
|
|
81
|
+
"prettier": "^3.5.3",
|
|
82
|
+
"react-promise-suspense": "^0.3.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"react": "^18.0 || ^19.0 || ^19.0.0-rc",
|
|
@@ -94,7 +94,6 @@
|
|
|
94
94
|
"jsdom": "23.0.1",
|
|
95
95
|
"tsup": "7.2.0",
|
|
96
96
|
"typescript": "5.1.6",
|
|
97
|
-
"vitest": "1.1.2",
|
|
98
97
|
"tsconfig": "0.0.0"
|
|
99
98
|
},
|
|
100
99
|
"publishConfig": {
|