@react-email/render 1.0.3-canary.1 → 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.
@@ -75,16 +75,16 @@ var import_html_to_text = require("html-to-text");
75
75
  var import_react = require("react");
76
76
 
77
77
  // src/shared/utils/pretty.ts
78
- var import_js_beautify = __toESM(require("js-beautify"));
78
+ var import_standalone = require("prettier/standalone");
79
+ var import_html = __toESM(require("prettier/plugins/html"));
79
80
  var defaults = {
80
- unformatted: ["code", "pre", "em", "strong", "span"],
81
- indent_inner_html: true,
82
- indent_char: " ",
83
- indent_size: 2,
84
- sep: "\n"
81
+ endOfLine: "lf",
82
+ tabWidth: 2,
83
+ plugins: [import_html.default],
84
+ parser: "html"
85
85
  };
86
86
  var pretty = (str, options = {}) => {
87
- return import_js_beautify.default.html(str, __spreadValues(__spreadValues({}, defaults), options));
87
+ return (0, import_standalone.format)(str, __spreadValues(__spreadValues({}, defaults), options));
88
88
  };
89
89
 
90
90
  // src/shared/plain-text-selectors.ts
@@ -134,9 +134,9 @@ var readStream = (stream) => __async(void 0, null, function* () {
134
134
  var render = (element, options) => __async(void 0, null, function* () {
135
135
  const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: element });
136
136
  const reactDOMServer = yield import("react-dom/server");
137
- let html;
137
+ let html2;
138
138
  if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
139
- html = yield readStream(
139
+ html2 = yield readStream(
140
140
  yield reactDOMServer.renderToReadableStream(suspendedElement)
141
141
  );
142
142
  } else {
@@ -144,7 +144,7 @@ var render = (element, options) => __async(void 0, null, function* () {
144
144
  const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
145
145
  onAllReady() {
146
146
  return __async(this, null, function* () {
147
- html = yield readStream(stream);
147
+ html2 = yield readStream(stream);
148
148
  resolve();
149
149
  });
150
150
  },
@@ -155,12 +155,12 @@ var render = (element, options) => __async(void 0, null, function* () {
155
155
  });
156
156
  }
157
157
  if (options == null ? void 0 : options.plainText) {
158
- return (0, import_html_to_text.convert)(html, __spreadValues({
158
+ return (0, import_html_to_text.convert)(html2, __spreadValues({
159
159
  selectors: plainTextSelectors
160
160
  }, options.htmlToTextOptions));
161
161
  }
162
162
  const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
163
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
163
+ const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
164
164
  if (options == null ? void 0 : options.pretty) {
165
165
  return pretty(document);
166
166
  }
@@ -210,9 +210,9 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
210
210
  var renderAsync = (element, options) => __async(void 0, null, function* () {
211
211
  const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { children: element });
212
212
  const reactDOMServer = yield import("react-dom/server");
213
- let html;
213
+ let html2;
214
214
  if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
215
- html = yield readStream2(
215
+ html2 = yield readStream2(
216
216
  yield reactDOMServer.renderToReadableStream(suspendedElement)
217
217
  );
218
218
  } else {
@@ -220,7 +220,7 @@ var renderAsync = (element, options) => __async(void 0, null, function* () {
220
220
  const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
221
221
  onAllReady() {
222
222
  return __async(this, null, function* () {
223
- html = yield readStream2(stream);
223
+ html2 = yield readStream2(stream);
224
224
  resolve();
225
225
  });
226
226
  },
@@ -231,12 +231,12 @@ var renderAsync = (element, options) => __async(void 0, null, function* () {
231
231
  });
232
232
  }
233
233
  if (options == null ? void 0 : options.plainText) {
234
- return (0, import_html_to_text2.convert)(html, __spreadValues({
234
+ return (0, import_html_to_text2.convert)(html2, __spreadValues({
235
235
  selectors: plainTextSelectors
236
236
  }, options.htmlToTextOptions));
237
237
  }
238
238
  const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
239
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
239
+ const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
240
240
  if (options == null ? void 0 : options.pretty) {
241
241
  return pretty(document);
242
242
  }
@@ -40,16 +40,16 @@ import { convert } from "html-to-text";
40
40
  import { Suspense } from "react";
41
41
 
42
42
  // src/shared/utils/pretty.ts
43
- import jsBeautify from "js-beautify";
43
+ import { format } from "prettier/standalone";
44
+ import html from "prettier/plugins/html";
44
45
  var defaults = {
45
- unformatted: ["code", "pre", "em", "strong", "span"],
46
- indent_inner_html: true,
47
- indent_char: " ",
48
- indent_size: 2,
49
- sep: "\n"
46
+ endOfLine: "lf",
47
+ tabWidth: 2,
48
+ plugins: [html],
49
+ parser: "html"
50
50
  };
51
51
  var pretty = (str, options = {}) => {
52
- return jsBeautify.html(str, __spreadValues(__spreadValues({}, defaults), options));
52
+ return format(str, __spreadValues(__spreadValues({}, defaults), options));
53
53
  };
54
54
 
55
55
  // src/shared/plain-text-selectors.ts
@@ -99,9 +99,9 @@ var readStream = (stream) => __async(void 0, null, function* () {
99
99
  var render = (element, options) => __async(void 0, null, function* () {
100
100
  const suspendedElement = /* @__PURE__ */ jsx(Suspense, { children: element });
101
101
  const reactDOMServer = yield import("react-dom/server");
102
- let html;
102
+ let html2;
103
103
  if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
104
- html = yield readStream(
104
+ html2 = yield readStream(
105
105
  yield reactDOMServer.renderToReadableStream(suspendedElement)
106
106
  );
107
107
  } else {
@@ -109,7 +109,7 @@ var render = (element, options) => __async(void 0, null, function* () {
109
109
  const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
110
110
  onAllReady() {
111
111
  return __async(this, null, function* () {
112
- html = yield readStream(stream);
112
+ html2 = yield readStream(stream);
113
113
  resolve();
114
114
  });
115
115
  },
@@ -120,12 +120,12 @@ var render = (element, options) => __async(void 0, null, function* () {
120
120
  });
121
121
  }
122
122
  if (options == null ? void 0 : options.plainText) {
123
- return convert(html, __spreadValues({
123
+ return convert(html2, __spreadValues({
124
124
  selectors: plainTextSelectors
125
125
  }, options.htmlToTextOptions));
126
126
  }
127
127
  const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
128
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
128
+ const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
129
129
  if (options == null ? void 0 : options.pretty) {
130
130
  return pretty(document);
131
131
  }
@@ -175,9 +175,9 @@ import { jsx as jsx2 } from "react/jsx-runtime";
175
175
  var renderAsync = (element, options) => __async(void 0, null, function* () {
176
176
  const suspendedElement = /* @__PURE__ */ jsx2(Suspense2, { children: element });
177
177
  const reactDOMServer = yield import("react-dom/server");
178
- let html;
178
+ let html2;
179
179
  if (Object.hasOwn(reactDOMServer, "renderToReadableStream")) {
180
- html = yield readStream2(
180
+ html2 = yield readStream2(
181
181
  yield reactDOMServer.renderToReadableStream(suspendedElement)
182
182
  );
183
183
  } else {
@@ -185,7 +185,7 @@ var renderAsync = (element, options) => __async(void 0, null, function* () {
185
185
  const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
186
186
  onAllReady() {
187
187
  return __async(this, null, function* () {
188
- html = yield readStream2(stream);
188
+ html2 = yield readStream2(stream);
189
189
  resolve();
190
190
  });
191
191
  },
@@ -196,12 +196,12 @@ var renderAsync = (element, options) => __async(void 0, null, function* () {
196
196
  });
197
197
  }
198
198
  if (options == null ? void 0 : options.plainText) {
199
- return convert2(html, __spreadValues({
199
+ return convert2(html2, __spreadValues({
200
200
  selectors: plainTextSelectors
201
201
  }, options.htmlToTextOptions));
202
202
  }
203
203
  const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
204
- const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
204
+ const document = `${doctype}${html2.replace(/<!DOCTYPE.*?>/, "")}`;
205
205
  if (options == null ? void 0 : options.pretty) {
206
206
  return pretty(document);
207
207
  }
@@ -0,0 +1,23 @@
1
+ import { HtmlToTextOptions } from 'html-to-text';
2
+ import { Options as Options$1 } from 'prettier';
3
+
4
+ type Options = {
5
+ pretty?: boolean;
6
+ } & ({
7
+ plainText?: false;
8
+ } | {
9
+ plainText?: true;
10
+ /**
11
+ * These are options you can pass down directly to the library we use for
12
+ * converting the rendered email's HTML into plain text.
13
+ *
14
+ * @see https://github.com/html-to-text/node-html-to-text
15
+ */
16
+ htmlToTextOptions?: HtmlToTextOptions;
17
+ });
18
+
19
+ declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
20
+
21
+ declare const pretty: (str: string, options?: Options$1) => Promise<string>;
22
+
23
+ export { Options, pretty, render };
@@ -0,0 +1,23 @@
1
+ import { HtmlToTextOptions } from 'html-to-text';
2
+ import { Options as Options$1 } from 'prettier';
3
+
4
+ type Options = {
5
+ pretty?: boolean;
6
+ } & ({
7
+ plainText?: false;
8
+ } | {
9
+ plainText?: true;
10
+ /**
11
+ * These are options you can pass down directly to the library we use for
12
+ * converting the rendered email's HTML into plain text.
13
+ *
14
+ * @see https://github.com/html-to-text/node-html-to-text
15
+ */
16
+ htmlToTextOptions?: HtmlToTextOptions;
17
+ });
18
+
19
+ declare const render: (element: React.ReactElement, options?: Options) => Promise<string>;
20
+
21
+ declare const pretty: (str: string, options?: Options$1) => Promise<string>;
22
+
23
+ export { Options, pretty, render };