@react-email/render 1.1.2 → 1.1.3-canary.0
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.js +19 -36
- package/dist/browser/index.mjs +19 -36
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -158,23 +158,19 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
158
158
|
var decoder = new TextDecoder("utf-8");
|
|
159
159
|
var readStream = (stream) => __async(void 0, null, function* () {
|
|
160
160
|
const chunks = [];
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
yield stream.pipeTo(writableStream);
|
|
168
|
-
} else {
|
|
169
|
-
throw new Error(
|
|
170
|
-
"For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
|
|
171
|
-
{
|
|
161
|
+
const writableStream = new WritableStream({
|
|
162
|
+
write(chunk) {
|
|
163
|
+
chunks.push(chunk);
|
|
164
|
+
},
|
|
165
|
+
abort(reason) {
|
|
166
|
+
throw new Error("Stream aborted", {
|
|
172
167
|
cause: {
|
|
173
|
-
|
|
168
|
+
reason
|
|
174
169
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
yield stream.pipeTo(writableStream);
|
|
178
174
|
let length = 0;
|
|
179
175
|
chunks.forEach((item) => {
|
|
180
176
|
length += item.length;
|
|
@@ -189,30 +185,17 @@ var readStream = (stream) => __async(void 0, null, function* () {
|
|
|
189
185
|
});
|
|
190
186
|
var render = (node, options) => __async(void 0, null, function* () {
|
|
191
187
|
const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: node });
|
|
192
|
-
const reactDOMServer = yield import("react-dom/server").then(
|
|
188
|
+
const reactDOMServer = yield import("react-dom/server.browser").then(
|
|
193
189
|
// This is beacuse react-dom/server is CJS
|
|
194
190
|
(m) => m.default
|
|
195
191
|
);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
204
|
-
onAllReady() {
|
|
205
|
-
return __async(this, null, function* () {
|
|
206
|
-
html2 = yield readStream(stream);
|
|
207
|
-
resolve();
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
onError(error) {
|
|
211
|
-
reject(error);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
}
|
|
192
|
+
const html2 = yield new Promise((resolve, reject) => {
|
|
193
|
+
reactDOMServer.renderToReadableStream(suspendedElement, {
|
|
194
|
+
onError(error) {
|
|
195
|
+
reject(error);
|
|
196
|
+
}
|
|
197
|
+
}).then(readStream).then(resolve).catch(reject);
|
|
198
|
+
});
|
|
216
199
|
if (options == null ? void 0 : options.plainText) {
|
|
217
200
|
return (0, import_html_to_text.convert)(html2, __spreadValues({
|
|
218
201
|
selectors: plainTextSelectors
|
package/dist/browser/index.mjs
CHANGED
|
@@ -122,23 +122,19 @@ import { jsx } from "react/jsx-runtime";
|
|
|
122
122
|
var decoder = new TextDecoder("utf-8");
|
|
123
123
|
var readStream = (stream) => __async(void 0, null, function* () {
|
|
124
124
|
const chunks = [];
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
yield stream.pipeTo(writableStream);
|
|
132
|
-
} else {
|
|
133
|
-
throw new Error(
|
|
134
|
-
"For some reason, the Node version of `react-dom/server` has been imported instead of the browser one.",
|
|
135
|
-
{
|
|
125
|
+
const writableStream = new WritableStream({
|
|
126
|
+
write(chunk) {
|
|
127
|
+
chunks.push(chunk);
|
|
128
|
+
},
|
|
129
|
+
abort(reason) {
|
|
130
|
+
throw new Error("Stream aborted", {
|
|
136
131
|
cause: {
|
|
137
|
-
|
|
132
|
+
reason
|
|
138
133
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
yield stream.pipeTo(writableStream);
|
|
142
138
|
let length = 0;
|
|
143
139
|
chunks.forEach((item) => {
|
|
144
140
|
length += item.length;
|
|
@@ -153,30 +149,17 @@ var readStream = (stream) => __async(void 0, null, function* () {
|
|
|
153
149
|
});
|
|
154
150
|
var render = (node, options) => __async(void 0, null, function* () {
|
|
155
151
|
const suspendedElement = /* @__PURE__ */ jsx(Suspense, { children: node });
|
|
156
|
-
const reactDOMServer = yield import("react-dom/server").then(
|
|
152
|
+
const reactDOMServer = yield import("react-dom/server.browser").then(
|
|
157
153
|
// This is beacuse react-dom/server is CJS
|
|
158
154
|
(m) => m.default
|
|
159
155
|
);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const stream = reactDOMServer.renderToPipeableStream(suspendedElement, {
|
|
168
|
-
onAllReady() {
|
|
169
|
-
return __async(this, null, function* () {
|
|
170
|
-
html2 = yield readStream(stream);
|
|
171
|
-
resolve();
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
onError(error) {
|
|
175
|
-
reject(error);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
156
|
+
const html2 = yield new Promise((resolve, reject) => {
|
|
157
|
+
reactDOMServer.renderToReadableStream(suspendedElement, {
|
|
158
|
+
onError(error) {
|
|
159
|
+
reject(error);
|
|
160
|
+
}
|
|
161
|
+
}).then(readStream).then(resolve).catch(reject);
|
|
162
|
+
});
|
|
180
163
|
if (options == null ? void 0 : options.plainText) {
|
|
181
164
|
return convert(html2, __spreadValues({
|
|
182
165
|
selectors: plainTextSelectors
|