@react-email/render 1.0.3-canary.2 → 1.0.3-canary.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-email/render",
3
- "version": "1.0.3-canary.2",
3
+ "version": "1.0.3-canary.3",
4
4
  "description": "Transform React components into HTML email templates",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/browser/index.js",
@@ -79,16 +79,18 @@
79
79
  "dependencies": {
80
80
  "html-to-text": "9.0.5",
81
81
  "prettier": "3.3.3",
82
- "react": "^18.0 || ^19.0 || ^19.0.0-rc",
83
- "react-dom": "^18.0 || ^19.0 || ^19.0.0-rc",
84
82
  "react-promise-suspense": "0.3.4"
85
83
  },
84
+ "peerDependencies": {
85
+ "react": "^18.0 || ^19.0 || ^19.0.0-rc",
86
+ "react-dom": "^18.0 || ^19.0 || ^19.0.0-rc"
87
+ },
86
88
  "devDependencies": {
87
89
  "@edge-runtime/vm": "3.1.8",
88
90
  "@types/html-to-text": "9.0.4",
89
91
  "@types/prettier": "3.0.0",
90
92
  "@types/react": "npm:types-react@19.0.0-rc.1",
91
- "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
93
+ "@types/react-dom": "npm:types-react-dom@19.0.0",
92
94
  "jsdom": "23.0.1",
93
95
  "tsup": "7.2.0",
94
96
  "typescript": "5.1.6",
@@ -1,27 +0,0 @@
1
- import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
2
-
3
- type Options = {
4
- pretty?: boolean;
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
-
18
- declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
19
-
20
- /**
21
- * @deprecated use `render`
22
- */
23
- declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
24
-
25
- declare const plainTextSelectors: SelectorDefinition[];
26
-
27
- export { Options, plainTextSelectors, render, renderAsync };
@@ -1,27 +0,0 @@
1
- import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
2
-
3
- type Options = {
4
- pretty?: boolean;
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
-
18
- declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
19
-
20
- /**
21
- * @deprecated use `render`
22
- */
23
- declare const renderAsync: (element: React.ReactElement, options?: Options) => Promise<string>;
24
-
25
- declare const plainTextSelectors: SelectorDefinition[];
26
-
27
- export { Options, plainTextSelectors, render, renderAsync };
@@ -1,216 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __export = (target, all) => {
23
- for (var name in all)
24
- __defProp(target, name, { get: all[name], enumerable: true });
25
- };
26
- var __copyProps = (to, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from))
29
- if (!__hasOwnProp.call(to, key) && key !== except)
30
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
- }
32
- return to;
33
- };
34
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
- // If the importer is in node compatibility mode or this is not an ESM
36
- // file that has been converted to a CommonJS file using a Babel-
37
- // compatible transform (i.e. "__esModule" has not been set), then set
38
- // "default" to the CommonJS "module.exports" for node compatibility.
39
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
- mod
41
- ));
42
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
- var __async = (__this, __arguments, generator) => {
44
- return new Promise((resolve, reject) => {
45
- var fulfilled = (value) => {
46
- try {
47
- step(generator.next(value));
48
- } catch (e) {
49
- reject(e);
50
- }
51
- };
52
- var rejected = (value) => {
53
- try {
54
- step(generator.throw(value));
55
- } catch (e) {
56
- reject(e);
57
- }
58
- };
59
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
60
- step((generator = generator.apply(__this, __arguments)).next());
61
- });
62
- };
63
-
64
- // src/edge-light/index.ts
65
- var edge_light_exports = {};
66
- __export(edge_light_exports, {
67
- plainTextSelectors: () => plainTextSelectors,
68
- render: () => render,
69
- renderAsync: () => renderAsync
70
- });
71
- module.exports = __toCommonJS(edge_light_exports);
72
-
73
- // src/edge-light/render.tsx
74
- var import_html_to_text = require("html-to-text");
75
- var import_react = require("react");
76
-
77
- // src/shared/utils/pretty.ts
78
- var import_js_beautify = __toESM(require("js-beautify"));
79
- var defaults = {
80
- unformatted: ["code", "pre", "em", "strong", "span"],
81
- indent_inner_html: true,
82
- indent_char: " ",
83
- indent_size: 2,
84
- sep: "\n"
85
- };
86
- var pretty = (str, options = {}) => {
87
- return import_js_beautify.default.html(str, __spreadValues(__spreadValues({}, defaults), options));
88
- };
89
-
90
- // src/shared/plain-text-selectors.ts
91
- var plainTextSelectors = [
92
- { selector: "img", format: "skip" },
93
- { selector: "#__react-email-preview", format: "skip" },
94
- {
95
- selector: "a",
96
- options: { linkBrackets: false }
97
- }
98
- ];
99
-
100
- // src/shared/read-stream.browser.ts
101
- var decoder = new TextDecoder("utf-8");
102
- var readStream = (stream) => __async(void 0, null, function* () {
103
- const chunks = [];
104
- if ("pipeTo" in stream) {
105
- const writableStream = new WritableStream({
106
- write(chunk) {
107
- chunks.push(chunk);
108
- }
109
- });
110
- yield stream.pipeTo(writableStream);
111
- } else {
112
- throw new Error(
113
- "For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
114
- {
115
- cause: {
116
- stream
117
- }
118
- }
119
- );
120
- }
121
- let length = 0;
122
- chunks.forEach((item) => {
123
- length += item.length;
124
- });
125
- const mergedChunks = new Uint8Array(length);
126
- let offset = 0;
127
- chunks.forEach((item) => {
128
- mergedChunks.set(item, offset);
129
- offset += item.length;
130
- });
131
- return decoder.decode(mergedChunks);
132
- });
133
-
134
- // src/edge-light/render.tsx
135
- var import_jsx_runtime = require("react/jsx-runtime");
136
- var render = (element, options) => __async(void 0, null, function* () {
137
- const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: element });
138
- const { default: reactDOMServer } = yield import("react-dom/server.edge");
139
- let html;
140
- if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
141
- html = yield readStream(
142
- yield reactDOMServer.renderToReadableStream(suspendedElement)
143
- );
144
- } else {
145
- yield new Promise((resolve, reject) => {
146
- const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
147
- onAllReady() {
148
- return __async(this, null, function* () {
149
- html = yield readStream(stream);
150
- resolve();
151
- });
152
- },
153
- onError(error) {
154
- reject(error);
155
- }
156
- });
157
- });
158
- }
159
- if (options == null ? void 0 : options.plainText) {
160
- return (0, import_html_to_text.convert)(html, __spreadValues({
161
- selectors: plainTextSelectors
162
- }, options.htmlToTextOptions));
163
- }
164
- const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
165
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
166
- if (options == null ? void 0 : options.pretty) {
167
- return pretty(document);
168
- }
169
- return document;
170
- });
171
-
172
- // src/edge-light/render-async.tsx
173
- var import_html_to_text2 = require("html-to-text");
174
- var import_react2 = require("react");
175
- var import_jsx_runtime2 = require("react/jsx-runtime");
176
- var renderAsync = (element, options) => __async(void 0, null, function* () {
177
- const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { children: element });
178
- const { default: reactDOMServer } = yield import("react-dom/server.edge");
179
- let html;
180
- if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
181
- html = yield readStream(
182
- yield reactDOMServer.renderToReadableStream(suspendedElement)
183
- );
184
- } else {
185
- yield new Promise((resolve, reject) => {
186
- const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
187
- onAllReady() {
188
- return __async(this, null, function* () {
189
- html = yield readStream(stream);
190
- resolve();
191
- });
192
- },
193
- onError(error) {
194
- reject(error);
195
- }
196
- });
197
- });
198
- }
199
- if (options == null ? void 0 : options.plainText) {
200
- return (0, import_html_to_text2.convert)(html, __spreadValues({
201
- selectors: plainTextSelectors
202
- }, options.htmlToTextOptions));
203
- }
204
- const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
205
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
206
- if (options == null ? void 0 : options.pretty) {
207
- return pretty(document);
208
- }
209
- return document;
210
- });
211
- // Annotate the CommonJS export names for ESM import in node:
212
- 0 && (module.exports = {
213
- plainTextSelectors,
214
- render,
215
- renderAsync
216
- });
@@ -1,180 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __async = (__this, __arguments, generator) => {
18
- return new Promise((resolve, reject) => {
19
- var fulfilled = (value) => {
20
- try {
21
- step(generator.next(value));
22
- } catch (e) {
23
- reject(e);
24
- }
25
- };
26
- var rejected = (value) => {
27
- try {
28
- step(generator.throw(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
- step((generator = generator.apply(__this, __arguments)).next());
35
- });
36
- };
37
-
38
- // src/edge-light/render.tsx
39
- import { convert } from "html-to-text";
40
- import { Suspense } from "react";
41
-
42
- // src/shared/utils/pretty.ts
43
- import jsBeautify from "js-beautify";
44
- var defaults = {
45
- unformatted: ["code", "pre", "em", "strong", "span"],
46
- indent_inner_html: true,
47
- indent_char: " ",
48
- indent_size: 2,
49
- sep: "\n"
50
- };
51
- var pretty = (str, options = {}) => {
52
- return jsBeautify.html(str, __spreadValues(__spreadValues({}, defaults), options));
53
- };
54
-
55
- // src/shared/plain-text-selectors.ts
56
- var plainTextSelectors = [
57
- { selector: "img", format: "skip" },
58
- { selector: "#__react-email-preview", format: "skip" },
59
- {
60
- selector: "a",
61
- options: { linkBrackets: false }
62
- }
63
- ];
64
-
65
- // src/shared/read-stream.browser.ts
66
- var decoder = new TextDecoder("utf-8");
67
- var readStream = (stream) => __async(void 0, null, function* () {
68
- const chunks = [];
69
- if ("pipeTo" in stream) {
70
- const writableStream = new WritableStream({
71
- write(chunk) {
72
- chunks.push(chunk);
73
- }
74
- });
75
- yield stream.pipeTo(writableStream);
76
- } else {
77
- throw new Error(
78
- "For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
79
- {
80
- cause: {
81
- stream
82
- }
83
- }
84
- );
85
- }
86
- let length = 0;
87
- chunks.forEach((item) => {
88
- length += item.length;
89
- });
90
- const mergedChunks = new Uint8Array(length);
91
- let offset = 0;
92
- chunks.forEach((item) => {
93
- mergedChunks.set(item, offset);
94
- offset += item.length;
95
- });
96
- return decoder.decode(mergedChunks);
97
- });
98
-
99
- // src/edge-light/render.tsx
100
- import { jsx } from "react/jsx-runtime";
101
- var render = (element, options) => __async(void 0, null, function* () {
102
- const suspendedElement = /* @__PURE__ */ jsx(Suspense, { children: element });
103
- const { default: reactDOMServer } = yield import("react-dom/server.edge");
104
- let html;
105
- if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
106
- html = yield readStream(
107
- yield reactDOMServer.renderToReadableStream(suspendedElement)
108
- );
109
- } else {
110
- yield new Promise((resolve, reject) => {
111
- const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
112
- onAllReady() {
113
- return __async(this, null, function* () {
114
- html = yield readStream(stream);
115
- resolve();
116
- });
117
- },
118
- onError(error) {
119
- reject(error);
120
- }
121
- });
122
- });
123
- }
124
- if (options == null ? void 0 : options.plainText) {
125
- return convert(html, __spreadValues({
126
- selectors: plainTextSelectors
127
- }, options.htmlToTextOptions));
128
- }
129
- const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
130
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
131
- if (options == null ? void 0 : options.pretty) {
132
- return pretty(document);
133
- }
134
- return document;
135
- });
136
-
137
- // src/edge-light/render-async.tsx
138
- import { convert as convert2 } from "html-to-text";
139
- import { Suspense as Suspense2 } from "react";
140
- import { jsx as jsx2 } from "react/jsx-runtime";
141
- var renderAsync = (element, options) => __async(void 0, null, function* () {
142
- const suspendedElement = /* @__PURE__ */ jsx2(Suspense2, { children: element });
143
- const { default: reactDOMServer } = yield import("react-dom/server.edge");
144
- let html;
145
- if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
146
- html = yield readStream(
147
- yield reactDOMServer.renderToReadableStream(suspendedElement)
148
- );
149
- } else {
150
- yield new Promise((resolve, reject) => {
151
- const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
152
- onAllReady() {
153
- return __async(this, null, function* () {
154
- html = yield readStream(stream);
155
- resolve();
156
- });
157
- },
158
- onError(error) {
159
- reject(error);
160
- }
161
- });
162
- });
163
- }
164
- if (options == null ? void 0 : options.plainText) {
165
- return convert2(html, __spreadValues({
166
- selectors: plainTextSelectors
167
- }, options.htmlToTextOptions));
168
- }
169
- const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
170
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
171
- if (options == null ? void 0 : options.pretty) {
172
- return pretty(document);
173
- }
174
- return document;
175
- });
176
- export {
177
- plainTextSelectors,
178
- render,
179
- renderAsync
180
- };