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