@react-email/render 1.0.4 → 1.0.5-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 +27 -12
- package/dist/browser/index.mjs +27 -12
- package/dist/edge-light/index.d.mts +27 -0
- package/dist/edge-light/index.d.ts +27 -0
- package/dist/edge-light/index.js +216 -0
- package/dist/edge-light/index.mjs +180 -0
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +44 -668
- package/dist/index.mjs +41 -666
- package/dist/node/index.js +27 -12
- package/dist/node/index.mjs +27 -12
- package/package.json +1 -3
package/dist/index.js
CHANGED
|
@@ -64,28 +64,31 @@ var __async = (__this, __arguments, generator) => {
|
|
|
64
64
|
// src/index.ts
|
|
65
65
|
var src_exports = {};
|
|
66
66
|
__export(src_exports, {
|
|
67
|
-
|
|
68
|
-
render: () => render
|
|
67
|
+
plainTextSelectors: () => plainTextSelectors,
|
|
68
|
+
render: () => render,
|
|
69
|
+
renderAsync: () => renderAsync
|
|
69
70
|
});
|
|
70
71
|
module.exports = __toCommonJS(src_exports);
|
|
71
72
|
|
|
72
73
|
// src/render.tsx
|
|
73
74
|
var import_html_to_text = require("html-to-text");
|
|
75
|
+
var import_react_markup = require("react-markup");
|
|
76
|
+
var import_react = require("react");
|
|
74
77
|
|
|
75
|
-
// src/utils/pretty.ts
|
|
76
|
-
var
|
|
77
|
-
var import_html = __toESM(require("prettier/plugins/html"));
|
|
78
|
+
// src/shared/utils/pretty.ts
|
|
79
|
+
var import_js_beautify = __toESM(require("js-beautify"));
|
|
78
80
|
var defaults = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
unformatted: ["code", "pre", "em", "strong", "span"],
|
|
82
|
+
indent_inner_html: true,
|
|
83
|
+
indent_char: " ",
|
|
84
|
+
indent_size: 2,
|
|
85
|
+
sep: "\n"
|
|
83
86
|
};
|
|
84
87
|
var pretty = (str, options = {}) => {
|
|
85
|
-
return
|
|
88
|
+
return import_js_beautify.default.html(str, __spreadValues(__spreadValues({}, defaults), options));
|
|
86
89
|
};
|
|
87
90
|
|
|
88
|
-
// src/plain-text-selectors.ts
|
|
91
|
+
// src/shared/plain-text-selectors.ts
|
|
89
92
|
var plainTextSelectors = [
|
|
90
93
|
{ selector: "img", format: "skip" },
|
|
91
94
|
{ selector: "#__react-email-preview", format: "skip" },
|
|
@@ -95,674 +98,47 @@ var plainTextSelectors = [
|
|
|
95
98
|
}
|
|
96
99
|
];
|
|
97
100
|
|
|
98
|
-
// src/
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return str;
|
|
108
|
-
}
|
|
109
|
-
let escape;
|
|
110
|
-
let html2 = "";
|
|
111
|
-
let index;
|
|
112
|
-
let lastIndex = 0;
|
|
113
|
-
for (index = match.index; index < str.length; index++) {
|
|
114
|
-
switch (str.charCodeAt(index)) {
|
|
115
|
-
case 34:
|
|
116
|
-
escape = """;
|
|
117
|
-
break;
|
|
118
|
-
case 38:
|
|
119
|
-
escape = "&";
|
|
120
|
-
break;
|
|
121
|
-
case 39:
|
|
122
|
-
escape = "'";
|
|
123
|
-
break;
|
|
124
|
-
case 60:
|
|
125
|
-
escape = "<";
|
|
126
|
-
break;
|
|
127
|
-
case 62:
|
|
128
|
-
escape = ">";
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
if (lastIndex !== index) {
|
|
134
|
-
html2 += str.slice(lastIndex, index);
|
|
135
|
-
}
|
|
136
|
-
lastIndex = index + 1;
|
|
137
|
-
html2 += escape;
|
|
138
|
-
}
|
|
139
|
-
return lastIndex !== index ? html2 + str.slice(lastIndex, index) : html2;
|
|
140
|
-
}
|
|
141
|
-
function escapeTextForBrowser(text) {
|
|
142
|
-
if (typeof text === "object")
|
|
143
|
-
return JSON.stringify(text);
|
|
144
|
-
if (typeof text === "boolean" || typeof text === "number" || typeof text === "bigint") {
|
|
145
|
-
return "" + text;
|
|
146
|
-
}
|
|
147
|
-
return escapeHtml(text);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/renderer/attribute-processing/boolean-prop-to-html-attribute.ts
|
|
151
|
-
function booleanPropToHtmlAttribute(name, value) {
|
|
152
|
-
if (value === true) {
|
|
153
|
-
return ` ${name}=""`;
|
|
154
|
-
}
|
|
155
|
-
return "";
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/renderer/attribute-processing/get-attribute-alias.ts
|
|
159
|
-
var aliases = /* @__PURE__ */ new Map([
|
|
160
|
-
["acceptCharset", "accept-charset"],
|
|
161
|
-
["htmlFor", "for"],
|
|
162
|
-
["httpEquiv", "http-equiv"],
|
|
163
|
-
// HTML and SVG attributes, but the SVG attribute is case sensitive.],
|
|
164
|
-
["crossOrigin", "crossorigin"],
|
|
165
|
-
// This is a list of all SVG attributes that need special casing.
|
|
166
|
-
// Regular attributes that just accept strings.],
|
|
167
|
-
["accentHeight", "accent-height"],
|
|
168
|
-
["alignmentBaseline", "alignment-baseline"],
|
|
169
|
-
["arabicForm", "arabic-form"],
|
|
170
|
-
["baselineShift", "baseline-shift"],
|
|
171
|
-
["capHeight", "cap-height"],
|
|
172
|
-
["clipPath", "clip-path"],
|
|
173
|
-
["clipRule", "clip-rule"],
|
|
174
|
-
["colorInterpolation", "color-interpolation"],
|
|
175
|
-
["colorInterpolationFilters", "color-interpolation-filters"],
|
|
176
|
-
["colorProfile", "color-profile"],
|
|
177
|
-
["colorRendering", "color-rendering"],
|
|
178
|
-
["dominantBaseline", "dominant-baseline"],
|
|
179
|
-
["enableBackground", "enable-background"],
|
|
180
|
-
["fillOpacity", "fill-opacity"],
|
|
181
|
-
["fillRule", "fill-rule"],
|
|
182
|
-
["floodColor", "flood-color"],
|
|
183
|
-
["floodOpacity", "flood-opacity"],
|
|
184
|
-
["fontFamily", "font-family"],
|
|
185
|
-
["fontSize", "font-size"],
|
|
186
|
-
["fontSizeAdjust", "font-size-adjust"],
|
|
187
|
-
["fontStretch", "font-stretch"],
|
|
188
|
-
["fontStyle", "font-style"],
|
|
189
|
-
["fontVariant", "font-variant"],
|
|
190
|
-
["fontWeight", "font-weight"],
|
|
191
|
-
["glyphName", "glyph-name"],
|
|
192
|
-
["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
|
|
193
|
-
["glyphOrientationVertical", "glyph-orientation-vertical"],
|
|
194
|
-
["horizAdvX", "horiz-adv-x"],
|
|
195
|
-
["horizOriginX", "horiz-origin-x"],
|
|
196
|
-
["imageRendering", "image-rendering"],
|
|
197
|
-
["letterSpacing", "letter-spacing"],
|
|
198
|
-
["lightingColor", "lighting-color"],
|
|
199
|
-
["markerEnd", "marker-end"],
|
|
200
|
-
["markerMid", "marker-mid"],
|
|
201
|
-
["markerStart", "marker-start"],
|
|
202
|
-
["overlinePosition", "overline-position"],
|
|
203
|
-
["overlineThickness", "overline-thickness"],
|
|
204
|
-
["paintOrder", "paint-order"],
|
|
205
|
-
["panose-1", "panose-1"],
|
|
206
|
-
["pointerEvents", "pointer-events"],
|
|
207
|
-
["renderingIntent", "rendering-intent"],
|
|
208
|
-
["shapeRendering", "shape-rendering"],
|
|
209
|
-
["stopColor", "stop-color"],
|
|
210
|
-
["stopOpacity", "stop-opacity"],
|
|
211
|
-
["strikethroughPosition", "strikethrough-position"],
|
|
212
|
-
["strikethroughThickness", "strikethrough-thickness"],
|
|
213
|
-
["strokeDasharray", "stroke-dasharray"],
|
|
214
|
-
["strokeDashoffset", "stroke-dashoffset"],
|
|
215
|
-
["strokeLinecap", "stroke-linecap"],
|
|
216
|
-
["strokeLinejoin", "stroke-linejoin"],
|
|
217
|
-
["strokeMiterlimit", "stroke-miterlimit"],
|
|
218
|
-
["strokeOpacity", "stroke-opacity"],
|
|
219
|
-
["strokeWidth", "stroke-width"],
|
|
220
|
-
["textAnchor", "text-anchor"],
|
|
221
|
-
["textDecoration", "text-decoration"],
|
|
222
|
-
["textRendering", "text-rendering"],
|
|
223
|
-
["transformOrigin", "transform-origin"],
|
|
224
|
-
["underlinePosition", "underline-position"],
|
|
225
|
-
["underlineThickness", "underline-thickness"],
|
|
226
|
-
["unicodeBidi", "unicode-bidi"],
|
|
227
|
-
["unicodeRange", "unicode-range"],
|
|
228
|
-
["unitsPerEm", "units-per-em"],
|
|
229
|
-
["vAlphabetic", "v-alphabetic"],
|
|
230
|
-
["vHanging", "v-hanging"],
|
|
231
|
-
["vIdeographic", "v-ideographic"],
|
|
232
|
-
["vMathematical", "v-mathematical"],
|
|
233
|
-
["vectorEffect", "vector-effect"],
|
|
234
|
-
["vertAdvY", "vert-adv-y"],
|
|
235
|
-
["vertOriginX", "vert-origin-x"],
|
|
236
|
-
["vertOriginY", "vert-origin-y"],
|
|
237
|
-
["wordSpacing", "word-spacing"],
|
|
238
|
-
["writingMode", "writing-mode"],
|
|
239
|
-
["xmlnsXlink", "xmlns:xlink"],
|
|
240
|
-
["xHeight", "x-height"]
|
|
241
|
-
]);
|
|
242
|
-
function getAttributeAlias(name) {
|
|
243
|
-
return aliases.get(name) || name;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/renderer/attribute-processing/is-attribute-name-safe.ts
|
|
247
|
-
var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
248
|
-
var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
249
|
-
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp(
|
|
250
|
-
"^[" + ATTRIBUTE_NAME_START_CHAR + "][" + ATTRIBUTE_NAME_CHAR + "]*$"
|
|
251
|
-
);
|
|
252
|
-
var illegalAttributeNameCache = {};
|
|
253
|
-
var validatedAttributeNameCache = {};
|
|
254
|
-
function isAttributeNameSafe(attributeName) {
|
|
255
|
-
if (Object.hasOwn(validatedAttributeNameCache, attributeName)) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
if (Object.hasOwn(illegalAttributeNameCache, attributeName)) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
|
262
|
-
validatedAttributeNameCache[attributeName] = true;
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
illegalAttributeNameCache[attributeName] = true;
|
|
266
|
-
console.error("Invalid attribute name: `%s`", attributeName);
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// src/renderer/attribute-processing/string-prop-to-html-attribute.ts
|
|
271
|
-
function stringPropToHtmlAttribute(name, value) {
|
|
272
|
-
if (typeof value !== "function" && typeof value !== "symbol" && typeof value !== "boolean") {
|
|
273
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
274
|
-
}
|
|
275
|
-
return "";
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// src/renderer/attribute-processing/style/is-unitless-number.ts
|
|
279
|
-
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
280
|
-
"animationIterationCount",
|
|
281
|
-
"aspectRatio",
|
|
282
|
-
"borderImageOutset",
|
|
283
|
-
"borderImageSlice",
|
|
284
|
-
"borderImageWidth",
|
|
285
|
-
"boxFlex",
|
|
286
|
-
"boxFlexGroup",
|
|
287
|
-
"boxOrdinalGroup",
|
|
288
|
-
"columnCount",
|
|
289
|
-
"columns",
|
|
290
|
-
"flex",
|
|
291
|
-
"flexGrow",
|
|
292
|
-
"flexPositive",
|
|
293
|
-
"flexShrink",
|
|
294
|
-
"flexNegative",
|
|
295
|
-
"flexOrder",
|
|
296
|
-
"gridArea",
|
|
297
|
-
"gridRow",
|
|
298
|
-
"gridRowEnd",
|
|
299
|
-
"gridRowSpan",
|
|
300
|
-
"gridRowStart",
|
|
301
|
-
"gridColumn",
|
|
302
|
-
"gridColumnEnd",
|
|
303
|
-
"gridColumnSpan",
|
|
304
|
-
"gridColumnStart",
|
|
305
|
-
"fontWeight",
|
|
306
|
-
"lineClamp",
|
|
307
|
-
"lineHeight",
|
|
308
|
-
"opacity",
|
|
309
|
-
"order",
|
|
310
|
-
"orphans",
|
|
311
|
-
"scale",
|
|
312
|
-
"tabSize",
|
|
313
|
-
"widows",
|
|
314
|
-
"zIndex",
|
|
315
|
-
"zoom",
|
|
316
|
-
"fillOpacity",
|
|
317
|
-
// SVG-related properties
|
|
318
|
-
"floodOpacity",
|
|
319
|
-
"stopOpacity",
|
|
320
|
-
"strokeDasharray",
|
|
321
|
-
"strokeDashoffset",
|
|
322
|
-
"strokeMiterlimit",
|
|
323
|
-
"strokeOpacity",
|
|
324
|
-
"strokeWidth",
|
|
325
|
-
"MozAnimationIterationCount",
|
|
326
|
-
// Known Prefixed Properties
|
|
327
|
-
"MozBoxFlex",
|
|
328
|
-
// TODO: Remove these since they shouldn't be used in modern code
|
|
329
|
-
"MozBoxFlexGroup",
|
|
330
|
-
"MozLineClamp",
|
|
331
|
-
"msAnimationIterationCount",
|
|
332
|
-
"msFlex",
|
|
333
|
-
"msZoom",
|
|
334
|
-
"msFlexGrow",
|
|
335
|
-
"msFlexNegative",
|
|
336
|
-
"msFlexOrder",
|
|
337
|
-
"msFlexPositive",
|
|
338
|
-
"msFlexShrink",
|
|
339
|
-
"msGridColumn",
|
|
340
|
-
"msGridColumnSpan",
|
|
341
|
-
"msGridRow",
|
|
342
|
-
"msGridRowSpan",
|
|
343
|
-
"WebkitAnimationIterationCount",
|
|
344
|
-
"WebkitBoxFlex",
|
|
345
|
-
"WebKitBoxFlexGroup",
|
|
346
|
-
"WebkitBoxOrdinalGroup",
|
|
347
|
-
"WebkitColumnCount",
|
|
348
|
-
"WebkitColumns",
|
|
349
|
-
"WebkitFlex",
|
|
350
|
-
"WebkitFlexGrow",
|
|
351
|
-
"WebkitFlexPositive",
|
|
352
|
-
"WebkitFlexShrink",
|
|
353
|
-
"WebkitLineClamp"
|
|
354
|
-
]);
|
|
355
|
-
function isUnitlessNumber(name) {
|
|
356
|
-
return unitlessNumbers.has(name);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// src/renderer/attribute-processing/style/hyphenate-style-name.ts
|
|
360
|
-
var uppercasePattern = /([A-Z])/g;
|
|
361
|
-
var msPattern = /^ms-/;
|
|
362
|
-
function hyphenateStyleName(name) {
|
|
363
|
-
return name.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-");
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// src/renderer/attribute-processing/style/process-style-name.ts
|
|
367
|
-
var styleNameCache = /* @__PURE__ */ new Map();
|
|
368
|
-
function processStyleName(styleName) {
|
|
369
|
-
if (!styleNameCache.has(styleName)) {
|
|
370
|
-
styleNameCache.set(styleName, hyphenateStyleName(styleName));
|
|
371
|
-
}
|
|
372
|
-
return styleNameCache.get(styleName);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// src/renderer/attribute-processing/style-prop-to-html-attribute.ts
|
|
376
|
-
function stylePropToHtmlAttribute(style) {
|
|
377
|
-
if (typeof style !== "object") {
|
|
378
|
-
throw new Error(
|
|
379
|
-
"The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
let styles = [];
|
|
383
|
-
for (const [styleName, styleValue] of Object.entries(style)) {
|
|
384
|
-
if (styleValue == null || typeof styleValue === "boolean" || styleValue === "") {
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
let nameChunk;
|
|
388
|
-
let valueChunk;
|
|
389
|
-
const isCustomProperty = styleName.indexOf("--") === 0;
|
|
390
|
-
if (isCustomProperty) {
|
|
391
|
-
nameChunk = styleName;
|
|
392
|
-
valueChunk = ("" + styleValue).trim();
|
|
393
|
-
} else {
|
|
394
|
-
nameChunk = processStyleName(styleName);
|
|
395
|
-
if (typeof styleValue === "number") {
|
|
396
|
-
if (styleValue !== 0 && !isUnitlessNumber(styleName)) {
|
|
397
|
-
valueChunk = styleValue + "px";
|
|
398
|
-
} else {
|
|
399
|
-
valueChunk = "" + styleValue;
|
|
400
|
-
}
|
|
401
|
-
} else {
|
|
402
|
-
valueChunk = ("" + styleValue).trim();
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
styles.push(`${nameChunk}:${valueChunk}`);
|
|
406
|
-
}
|
|
407
|
-
return ` style="${styles.join(";").replaceAll('"', "'")}"`;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// src/renderer/attribute-processing/prop-to-html-attribute.ts
|
|
411
|
-
function propToHtmlAttribute(name, value) {
|
|
412
|
-
if (value === void 0)
|
|
413
|
-
return "";
|
|
414
|
-
switch (name) {
|
|
415
|
-
case "className": {
|
|
416
|
-
return stringPropToHtmlAttribute("class", value);
|
|
417
|
-
}
|
|
418
|
-
case "tabIndex": {
|
|
419
|
-
return stringPropToHtmlAttribute("tabindex", value);
|
|
420
|
-
}
|
|
421
|
-
case "dir":
|
|
422
|
-
case "role":
|
|
423
|
-
case "viewBox":
|
|
424
|
-
case "width":
|
|
425
|
-
case "height": {
|
|
426
|
-
return stringPropToHtmlAttribute(name, value);
|
|
427
|
-
}
|
|
428
|
-
case "style": {
|
|
429
|
-
return stylePropToHtmlAttribute(value);
|
|
430
|
-
}
|
|
431
|
-
case "defaultValue":
|
|
432
|
-
case "defaultChecked":
|
|
433
|
-
case "innerHTML":
|
|
434
|
-
case "suppressContentEditableWarning":
|
|
435
|
-
case "suppressHydrationWarning":
|
|
436
|
-
case "ref":
|
|
437
|
-
return "";
|
|
438
|
-
case "autoFocus":
|
|
439
|
-
case "multiple":
|
|
440
|
-
case "muted": {
|
|
441
|
-
return booleanPropToHtmlAttribute(name, value);
|
|
442
|
-
}
|
|
443
|
-
case "xlinkHref": {
|
|
444
|
-
if (typeof value === "function" || typeof value === "symbol" || typeof value === "boolean") {
|
|
445
|
-
return "";
|
|
446
|
-
}
|
|
447
|
-
return ` xlink:href="${escapeTextForBrowser(value)}"`;
|
|
448
|
-
}
|
|
449
|
-
case "contentEditable":
|
|
450
|
-
case "spellCheck":
|
|
451
|
-
case "draggable":
|
|
452
|
-
case "value":
|
|
453
|
-
case "autoReverse":
|
|
454
|
-
case "externalResourcesRequired":
|
|
455
|
-
case "focusable":
|
|
456
|
-
case "preserveAlpha": {
|
|
457
|
-
if (typeof value !== "function" && typeof value !== "symbol") {
|
|
458
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
459
|
-
}
|
|
460
|
-
return "";
|
|
461
|
-
}
|
|
462
|
-
case "allowFullScreen":
|
|
463
|
-
case "async":
|
|
464
|
-
case "autoPlay":
|
|
465
|
-
case "controls":
|
|
466
|
-
case "default":
|
|
467
|
-
case "defer":
|
|
468
|
-
case "disabled":
|
|
469
|
-
case "disablePictureInPicture":
|
|
470
|
-
case "disableRemotePlayback":
|
|
471
|
-
case "formNoValidate":
|
|
472
|
-
case "hidden":
|
|
473
|
-
case "loop":
|
|
474
|
-
case "noModule":
|
|
475
|
-
case "noValidate":
|
|
476
|
-
case "open":
|
|
477
|
-
case "playsInline":
|
|
478
|
-
case "readOnly":
|
|
479
|
-
case "required":
|
|
480
|
-
case "reversed":
|
|
481
|
-
case "scoped":
|
|
482
|
-
case "seamless":
|
|
483
|
-
case "itemScope": {
|
|
484
|
-
if (value && typeof value !== "function" && typeof value !== "symbol") {
|
|
485
|
-
return ` ${name}=""`;
|
|
486
|
-
}
|
|
487
|
-
return "";
|
|
488
|
-
}
|
|
489
|
-
case "capture":
|
|
490
|
-
case "download": {
|
|
491
|
-
if (value === true) {
|
|
492
|
-
return ` ${name}=""`;
|
|
493
|
-
} else if (value === false) {
|
|
494
|
-
} else if (typeof value !== "function" && typeof value !== "symbol") {
|
|
495
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
496
|
-
}
|
|
497
|
-
return "";
|
|
498
|
-
}
|
|
499
|
-
case "cols":
|
|
500
|
-
case "rows":
|
|
501
|
-
case "size":
|
|
502
|
-
case "span": {
|
|
503
|
-
if (typeof value !== "function" && typeof value !== "symbol" && !isNaN(value) && value >= 1) {
|
|
504
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
505
|
-
}
|
|
506
|
-
return "";
|
|
507
|
-
}
|
|
508
|
-
case "rowSpan":
|
|
509
|
-
case "start": {
|
|
510
|
-
if (typeof value !== "function" && typeof value !== "symbol" && !isNaN(value)) {
|
|
511
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
512
|
-
}
|
|
513
|
-
return "";
|
|
514
|
-
}
|
|
515
|
-
case "xlinkActuate":
|
|
516
|
-
return stringPropToHtmlAttribute("xlink:actuate", escapeTextForBrowser(value));
|
|
517
|
-
case "xlinkArcrole":
|
|
518
|
-
return stringPropToHtmlAttribute("xlink:arcrole", escapeTextForBrowser(value));
|
|
519
|
-
case "xlinkRole":
|
|
520
|
-
return stringPropToHtmlAttribute("xlink:role", escapeTextForBrowser(value));
|
|
521
|
-
case "xlinkShow":
|
|
522
|
-
return stringPropToHtmlAttribute("xlink:show", escapeTextForBrowser(value));
|
|
523
|
-
case "xlinkTitle":
|
|
524
|
-
return stringPropToHtmlAttribute("xlink:title", escapeTextForBrowser(value));
|
|
525
|
-
case "xlinkType":
|
|
526
|
-
return stringPropToHtmlAttribute("xlink:type", escapeTextForBrowser(value));
|
|
527
|
-
case "xmlBase":
|
|
528
|
-
return stringPropToHtmlAttribute("xml:base", escapeTextForBrowser(value));
|
|
529
|
-
case "xmlLang":
|
|
530
|
-
return stringPropToHtmlAttribute("xml:lang", escapeTextForBrowser(value));
|
|
531
|
-
case "xmlSpace":
|
|
532
|
-
return stringPropToHtmlAttribute("xml:space", escapeTextForBrowser(value));
|
|
533
|
-
default:
|
|
534
|
-
if (
|
|
535
|
-
// shouldIgnoreAttribute
|
|
536
|
-
// We have already filtered out null/undefined and reserved words.
|
|
537
|
-
name.length > 2 && (name[0] === "o" || name[0] === "O") && (name[1] === "n" || name[1] === "N")
|
|
538
|
-
) {
|
|
539
|
-
return "";
|
|
540
|
-
}
|
|
541
|
-
const attributeName = getAttributeAlias(name);
|
|
542
|
-
if (isAttributeNameSafe(attributeName)) {
|
|
543
|
-
switch (typeof value) {
|
|
544
|
-
case "function":
|
|
545
|
-
case "symbol":
|
|
546
|
-
return "";
|
|
547
|
-
case "boolean": {
|
|
548
|
-
const prefix = attributeName.toLowerCase().slice(0, 5);
|
|
549
|
-
if (prefix !== "data-" && prefix !== "aria-") {
|
|
550
|
-
return "";
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return ` ${name}="${escapeTextForBrowser(value)}"`;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return "";
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// src/renderer/renderer.tsx
|
|
561
|
-
var Destination = class {
|
|
562
|
-
constructor() {
|
|
563
|
-
this.html = "";
|
|
564
|
-
this.decoder = new TextDecoder("utf8", {
|
|
565
|
-
fatal: true
|
|
566
|
-
});
|
|
567
|
-
this.listeners = [];
|
|
568
|
-
}
|
|
569
|
-
write(content) {
|
|
570
|
-
this.html += content;
|
|
571
|
-
}
|
|
572
|
-
writeEncoded(buffer) {
|
|
573
|
-
this.html += this.decoder.decode(buffer, { stream: true });
|
|
574
|
-
}
|
|
575
|
-
promise() {
|
|
576
|
-
return new Promise((resolve, reject) => {
|
|
577
|
-
this.listeners.push([resolve, reject]);
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
completeWithError(error) {
|
|
581
|
-
this.listeners.forEach(([_, reject]) => reject(error));
|
|
582
|
-
}
|
|
583
|
-
complete() {
|
|
584
|
-
this.listeners.forEach(([resolve]) => resolve(this.html));
|
|
101
|
+
// src/render.tsx
|
|
102
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
103
|
+
var render = (element, options) => __async(void 0, null, function* () {
|
|
104
|
+
const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: element });
|
|
105
|
+
const html = yield (0, import_react_markup.experimental_renderToHTML)(suspendedElement);
|
|
106
|
+
if (options == null ? void 0 : options.plainText) {
|
|
107
|
+
return (0, import_html_to_text.convert)(html, __spreadValues({
|
|
108
|
+
selectors: plainTextSelectors
|
|
109
|
+
}, options.htmlToTextOptions));
|
|
585
110
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
queueMicrotask(() => callback());
|
|
591
|
-
},
|
|
592
|
-
scheduleWork(callback) {
|
|
593
|
-
setTimeout(() => {
|
|
594
|
-
callback();
|
|
595
|
-
});
|
|
596
|
-
},
|
|
597
|
-
beginWriting(destination) {
|
|
598
|
-
},
|
|
599
|
-
writeChunk(destination, buffer) {
|
|
600
|
-
destination.writeEncoded(buffer);
|
|
601
|
-
},
|
|
602
|
-
writeChunkAndReturn(destination, buffer) {
|
|
603
|
-
destination.writeEncoded(buffer);
|
|
604
|
-
return true;
|
|
605
|
-
},
|
|
606
|
-
completeWriting(destination) {
|
|
607
|
-
},
|
|
608
|
-
close(destination) {
|
|
609
|
-
destination.complete();
|
|
610
|
-
},
|
|
611
|
-
closeWithError(destination, error) {
|
|
612
|
-
destination.completeWithError(error);
|
|
613
|
-
},
|
|
614
|
-
flushBuffered(destination) {
|
|
615
|
-
},
|
|
616
|
-
getChildFormatContext() {
|
|
617
|
-
return null;
|
|
618
|
-
},
|
|
619
|
-
resetResumableState() {
|
|
620
|
-
},
|
|
621
|
-
completeResumableState() {
|
|
622
|
-
},
|
|
623
|
-
pushTextInstance(target, text, renderState, textEmbedded) {
|
|
624
|
-
target.push(encoder.encode(escapeTextForBrowser(text)));
|
|
625
|
-
return true;
|
|
626
|
-
},
|
|
627
|
-
pushStartInstance(target, type, props) {
|
|
628
|
-
target.push(encoder.encode(`<${type}`));
|
|
629
|
-
let dangerouslySetInnerHTML = void 0;
|
|
630
|
-
let children = void 0;
|
|
631
|
-
for (const [name, value] of Object.entries(props)) {
|
|
632
|
-
if (name === "children") {
|
|
633
|
-
children = value;
|
|
634
|
-
continue;
|
|
635
|
-
} else if (name === "dangerouslySetInnerHTML") {
|
|
636
|
-
dangerouslySetInnerHTML = value;
|
|
637
|
-
continue;
|
|
638
|
-
}
|
|
639
|
-
target.push(encoder.encode(propToHtmlAttribute(name, value)));
|
|
640
|
-
}
|
|
641
|
-
target.push(encoder.encode(">"));
|
|
642
|
-
if (dangerouslySetInnerHTML !== void 0) {
|
|
643
|
-
if (children !== void 0) {
|
|
644
|
-
throw new Error(
|
|
645
|
-
"Can only set one of `children` or `props.dangerouslySetInnerHTML`."
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
if (typeof dangerouslySetInnerHTML !== "object" || !("__html" in dangerouslySetInnerHTML)) {
|
|
649
|
-
throw new Error(
|
|
650
|
-
"`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://react.dev/link/dangerously-set-inner-html for more information."
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
const html2 = dangerouslySetInnerHTML.__html;
|
|
654
|
-
if (html2 !== null && html2 !== void 0) {
|
|
655
|
-
target.push(encoder.encode("" + html2));
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
if (typeof children === "string" || typeof children === "number" || typeof children === "boolean" || typeof children === "bigint") {
|
|
659
|
-
target.push(encoder.encode(escapeTextForBrowser("" + children)));
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
662
|
-
return children;
|
|
663
|
-
},
|
|
664
|
-
pushEndInstance(target, type) {
|
|
665
|
-
switch (type) {
|
|
666
|
-
case "area":
|
|
667
|
-
case "base":
|
|
668
|
-
case "br":
|
|
669
|
-
case "col":
|
|
670
|
-
case "embed":
|
|
671
|
-
case "hr":
|
|
672
|
-
case "img":
|
|
673
|
-
case "input":
|
|
674
|
-
case "keygen":
|
|
675
|
-
case "link":
|
|
676
|
-
case "meta":
|
|
677
|
-
case "param":
|
|
678
|
-
case "source":
|
|
679
|
-
case "track":
|
|
680
|
-
case "wbr": {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
target.push(encoder.encode(`</${type}>`));
|
|
685
|
-
},
|
|
686
|
-
pushSegmentFinale(target, _, lastPushedText, textEmbedded) {
|
|
687
|
-
},
|
|
688
|
-
writeCompletedRoot() {
|
|
689
|
-
return true;
|
|
690
|
-
},
|
|
691
|
-
writePlaceholder() {
|
|
692
|
-
return true;
|
|
693
|
-
},
|
|
694
|
-
writeStartCompletedSuspenseBoundary() {
|
|
695
|
-
return true;
|
|
696
|
-
},
|
|
697
|
-
writeStartPendingSuspenseBoundary() {
|
|
698
|
-
return true;
|
|
699
|
-
},
|
|
700
|
-
writeStartClientRenderedSuspenseBoundary() {
|
|
701
|
-
return true;
|
|
702
|
-
},
|
|
703
|
-
writeEndCompletedSuspenseBoundary(destination) {
|
|
704
|
-
return true;
|
|
705
|
-
},
|
|
706
|
-
writeEndPendingSuspenseBoundary(destination) {
|
|
707
|
-
return true;
|
|
708
|
-
},
|
|
709
|
-
writeEndClientRenderedSuspenseBoundary(destination) {
|
|
710
|
-
return true;
|
|
711
|
-
},
|
|
712
|
-
writeStartSegment(destination, renderState, formatContext, id) {
|
|
713
|
-
return true;
|
|
714
|
-
},
|
|
715
|
-
writeEndSegment(destination, formatContext) {
|
|
716
|
-
return true;
|
|
717
|
-
},
|
|
718
|
-
writeCompletedSegmentInstruction(destination, renderState, contentSegmentID) {
|
|
719
|
-
return true;
|
|
720
|
-
},
|
|
721
|
-
writeCompletedBoundaryInstruction() {
|
|
722
|
-
return true;
|
|
723
|
-
},
|
|
724
|
-
writeClientRenderBoundaryInstruction() {
|
|
725
|
-
return true;
|
|
726
|
-
},
|
|
727
|
-
writePreamble(destination) {
|
|
728
|
-
destination.write(
|
|
729
|
-
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
|
730
|
-
);
|
|
731
|
-
},
|
|
732
|
-
writeHoistables() {
|
|
733
|
-
},
|
|
734
|
-
writeHoistablesForBoundary() {
|
|
735
|
-
},
|
|
736
|
-
writePostamble() {
|
|
737
|
-
},
|
|
738
|
-
hoistHoistables(parent, child) {
|
|
739
|
-
},
|
|
740
|
-
createHoistableState() {
|
|
741
|
-
return null;
|
|
742
|
-
},
|
|
743
|
-
emitEarlyPreloads() {
|
|
111
|
+
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
112
|
+
const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
113
|
+
if (options == null ? void 0 : options.pretty) {
|
|
114
|
+
return pretty(document);
|
|
744
115
|
}
|
|
116
|
+
return document;
|
|
745
117
|
});
|
|
746
118
|
|
|
747
|
-
// src/render.tsx
|
|
748
|
-
var
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
const
|
|
119
|
+
// src/render-async.tsx
|
|
120
|
+
var import_html_to_text2 = require("html-to-text");
|
|
121
|
+
var import_react2 = require("react");
|
|
122
|
+
var import_react_markup2 = require("react-markup");
|
|
123
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
124
|
+
var renderAsync = (element, options) => __async(void 0, null, function* () {
|
|
125
|
+
const suspendedElement = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { children: element });
|
|
126
|
+
const html = yield (0, import_react_markup2.experimental_renderToHTML)(suspendedElement);
|
|
754
127
|
if (options == null ? void 0 : options.plainText) {
|
|
755
|
-
return (0,
|
|
128
|
+
return (0, import_html_to_text2.convert)(html, __spreadValues({
|
|
756
129
|
selectors: plainTextSelectors
|
|
757
130
|
}, options.htmlToTextOptions));
|
|
758
131
|
}
|
|
132
|
+
const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
|
133
|
+
const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, "")}`;
|
|
759
134
|
if (options == null ? void 0 : options.pretty) {
|
|
760
|
-
return pretty(
|
|
135
|
+
return pretty(document);
|
|
761
136
|
}
|
|
762
|
-
return
|
|
137
|
+
return document;
|
|
763
138
|
});
|
|
764
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
765
140
|
0 && (module.exports = {
|
|
766
|
-
|
|
767
|
-
render
|
|
141
|
+
plainTextSelectors,
|
|
142
|
+
render,
|
|
143
|
+
renderAsync
|
|
768
144
|
});
|