preact-render-to-string 6.4.0 → 6.4.2
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/README.md +5 -12
- package/dist/commonjs.js +1 -1
- package/dist/commonjs.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +157 -151
- package/src/index.js +29 -12
package/package.json
CHANGED
|
@@ -1,153 +1,159 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
2
|
+
"name": "preact-render-to-string",
|
|
3
|
+
"amdName": "preactRenderToString",
|
|
4
|
+
"version": "6.4.2",
|
|
5
|
+
"description": "Render JSX to an HTML string, with support for Preact components.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"umd:main": "dist/index.umd.js",
|
|
8
|
+
"module": "dist/index.module.js",
|
|
9
|
+
"jsnext:main": "dist/index.module.js",
|
|
10
|
+
"types": "src/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"browser": "./dist/index.module.js",
|
|
15
|
+
"umd": "./dist/index.umd.js",
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./jsx": {
|
|
20
|
+
"types": "./jsx.d.ts",
|
|
21
|
+
"browser": "./dist/jsx.module.js",
|
|
22
|
+
"umd": "./dist/jsx.umd.js",
|
|
23
|
+
"import": "./dist/jsx.mjs",
|
|
24
|
+
"require": "./dist/jsx.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"bench": "BABEL_ENV=test node -r @babel/register benchmarks index.js",
|
|
30
|
+
"bench:v8": "BABEL_ENV=test microbundle benchmarks/index.js -f modern --alias benchmarkjs-pretty=benchmarks/lib/benchmark-lite.js --external none --target node --no-compress --no-sourcemap --raw -o benchmarks/.v8.mjs && v8 --module benchmarks/.v8.mjs",
|
|
31
|
+
"build": "npm run -s transpile && npm run -s transpile:jsx && npm run -s copy-typescript-definition",
|
|
32
|
+
"postbuild": "node ./config/node-13-exports.js && node ./config/node-commonjs.js && node ./config/node-verify-exports.js",
|
|
33
|
+
"transpile": "microbundle src/index.js -f es,cjs,umd --target web --external preact",
|
|
34
|
+
"transpile:jsx": "microbundle src/jsx.js -o dist/jsx.js --target web --external preact && microbundle dist/jsx.js -o dist/jsx.js -f cjs --external preact",
|
|
35
|
+
"copy-typescript-definition": "copyfiles -f src/*.d.ts dist",
|
|
36
|
+
"test": "eslint src test && tsc && npm run test:mocha && npm run test:mocha:compat && npm run test:mocha:debug && npm run bench",
|
|
37
|
+
"test:mocha": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/*.test.js test/*.test.jsx",
|
|
38
|
+
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/compat/*.test.js' 'test/compat/*.test.jsx'",
|
|
39
|
+
"test:mocha:debug": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/debug/index.test.js' 'test/debug/index.test.jsx'",
|
|
40
|
+
"format": "prettier src/**/*.{d.ts,js,jsx} test/**/*.js test/**/*.jsx --write",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"preact",
|
|
46
|
+
"render",
|
|
47
|
+
"universal",
|
|
48
|
+
"isomorphic"
|
|
49
|
+
],
|
|
50
|
+
"files": [
|
|
51
|
+
"src",
|
|
52
|
+
"dist",
|
|
53
|
+
"jsx.js",
|
|
54
|
+
"jsx.d.ts",
|
|
55
|
+
"typings.json"
|
|
56
|
+
],
|
|
57
|
+
"eslintConfig": {
|
|
58
|
+
"extends": "developit",
|
|
59
|
+
"rules": {
|
|
60
|
+
"react/prefer-stateless-function": 0,
|
|
61
|
+
"react/jsx-no-bind": 0,
|
|
62
|
+
"react/no-danger": 0,
|
|
63
|
+
"jest/valid-expect": 0,
|
|
64
|
+
"new-cap": 0,
|
|
65
|
+
"curly": "off",
|
|
66
|
+
"brace-style": "off",
|
|
67
|
+
"indent": "off"
|
|
68
|
+
},
|
|
69
|
+
"settings": {
|
|
70
|
+
"react": {
|
|
71
|
+
"version": "16.8"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"babel": {
|
|
76
|
+
"env": {
|
|
77
|
+
"test": {
|
|
78
|
+
"presets": [
|
|
79
|
+
[
|
|
80
|
+
"@babel/preset-env",
|
|
81
|
+
{
|
|
82
|
+
"targets": {
|
|
83
|
+
"node": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
],
|
|
88
|
+
"plugins": [
|
|
89
|
+
[
|
|
90
|
+
"@babel/plugin-transform-react-jsx",
|
|
91
|
+
{
|
|
92
|
+
"pragma": "h"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"minify": {
|
|
100
|
+
"compress": {
|
|
101
|
+
"reduce_funcs": false
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"author": "Jason Miller <jason@developit.ca>",
|
|
105
|
+
"license": "MIT",
|
|
106
|
+
"repository": {
|
|
107
|
+
"type": "git",
|
|
108
|
+
"url": "https://github.com/preactjs/preact-render-to-string"
|
|
109
|
+
},
|
|
110
|
+
"bugs": "https://github.com/developit/preact-render-to-string/issues",
|
|
111
|
+
"homepage": "https://github.com/developit/preact-render-to-string",
|
|
112
|
+
"peerDependencies": {
|
|
113
|
+
"preact": ">=10"
|
|
114
|
+
},
|
|
115
|
+
"devDependencies": {
|
|
116
|
+
"@babel/plugin-transform-react-jsx": "^7.22.15",
|
|
117
|
+
"@babel/preset-env": "^7.23.2",
|
|
118
|
+
"@babel/register": "^7.22.15",
|
|
119
|
+
"@changesets/changelog-github": "^0.4.1",
|
|
120
|
+
"@changesets/cli": "^2.18.0",
|
|
121
|
+
"benchmarkjs-pretty": "^2.0.1",
|
|
122
|
+
"chai": "^4.3.10",
|
|
123
|
+
"copyfiles": "^2.4.1",
|
|
124
|
+
"eslint": "^7.16.0",
|
|
125
|
+
"eslint-config-developit": "^1.2.0",
|
|
126
|
+
"husky": "^4.3.6",
|
|
127
|
+
"lint-staged": "^10.5.3",
|
|
128
|
+
"microbundle": "^0.15.1",
|
|
129
|
+
"mocha": "^10.2.0",
|
|
130
|
+
"baseline-rts": "npm:preact-render-to-string@latest",
|
|
131
|
+
"preact": "^10.13.0",
|
|
132
|
+
"prettier": "^2.2.1",
|
|
133
|
+
"sinon": "^17.0.1",
|
|
134
|
+
"sinon-chai": "^3.7.0",
|
|
135
|
+
"typescript": "^5.0.0"
|
|
136
|
+
},
|
|
137
|
+
"dependencies": {
|
|
138
|
+
"pretty-format": "^3.8.0"
|
|
139
|
+
},
|
|
140
|
+
"prettier": {
|
|
141
|
+
"singleQuote": true,
|
|
142
|
+
"trailingComma": "none",
|
|
143
|
+
"useTabs": true,
|
|
144
|
+
"tabWidth": 2
|
|
145
|
+
},
|
|
146
|
+
"lint-staged": {
|
|
147
|
+
"**/*.{js,jsx,ts,tsx,yml}": [
|
|
148
|
+
"prettier --write"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"husky": {
|
|
152
|
+
"hooks": {
|
|
153
|
+
"pre-commit": "lint-staged"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"publishConfig": {
|
|
157
|
+
"provenance": true
|
|
158
|
+
}
|
|
153
159
|
}
|
package/src/index.js
CHANGED
|
@@ -425,7 +425,7 @@ function _renderToString(
|
|
|
425
425
|
return str;
|
|
426
426
|
} finally {
|
|
427
427
|
if (afterDiff) afterDiff(vnode);
|
|
428
|
-
vnode[PARENT] =
|
|
428
|
+
vnode[PARENT] = null;
|
|
429
429
|
|
|
430
430
|
if (ummountHook) ummountHook(vnode);
|
|
431
431
|
}
|
|
@@ -435,11 +435,15 @@ function _renderToString(
|
|
|
435
435
|
// When a component returns a Fragment node we flatten it in core, so we
|
|
436
436
|
// need to mirror that logic here too
|
|
437
437
|
let isTopLevelFragment =
|
|
438
|
-
rendered != null &&
|
|
438
|
+
rendered != null &&
|
|
439
|
+
rendered.type === Fragment &&
|
|
440
|
+
rendered.key == null &&
|
|
441
|
+
rendered.props.tpl == null;
|
|
439
442
|
rendered = isTopLevelFragment ? rendered.props.children : rendered;
|
|
440
443
|
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
try {
|
|
445
|
+
// Recurse into children before invoking the after-diff hook
|
|
446
|
+
const str = _renderToString(
|
|
443
447
|
rendered,
|
|
444
448
|
context,
|
|
445
449
|
isSvgMode,
|
|
@@ -448,12 +452,8 @@ function _renderToString(
|
|
|
448
452
|
asyncMode
|
|
449
453
|
);
|
|
450
454
|
|
|
451
|
-
try {
|
|
452
|
-
// Recurse into children before invoking the after-diff hook
|
|
453
|
-
const str = renderChildren();
|
|
454
|
-
|
|
455
455
|
if (afterDiff) afterDiff(vnode);
|
|
456
|
-
vnode[PARENT] =
|
|
456
|
+
vnode[PARENT] = null;
|
|
457
457
|
|
|
458
458
|
if (ummountHook) ummountHook(vnode);
|
|
459
459
|
|
|
@@ -465,10 +465,27 @@ function _renderToString(
|
|
|
465
465
|
|
|
466
466
|
const renderNestedChildren = () => {
|
|
467
467
|
try {
|
|
468
|
-
return
|
|
468
|
+
return _renderToString(
|
|
469
|
+
rendered,
|
|
470
|
+
context,
|
|
471
|
+
isSvgMode,
|
|
472
|
+
selectValue,
|
|
473
|
+
vnode,
|
|
474
|
+
asyncMode
|
|
475
|
+
);
|
|
469
476
|
} catch (e) {
|
|
477
|
+
if (!e || typeof e.then !== 'function') throw e;
|
|
478
|
+
|
|
470
479
|
return e.then(
|
|
471
|
-
() =>
|
|
480
|
+
() =>
|
|
481
|
+
_renderToString(
|
|
482
|
+
rendered,
|
|
483
|
+
context,
|
|
484
|
+
isSvgMode,
|
|
485
|
+
selectValue,
|
|
486
|
+
vnode,
|
|
487
|
+
asyncMode
|
|
488
|
+
),
|
|
472
489
|
() => renderNestedChildren()
|
|
473
490
|
);
|
|
474
491
|
}
|
|
@@ -616,7 +633,7 @@ function _renderToString(
|
|
|
616
633
|
}
|
|
617
634
|
|
|
618
635
|
if (afterDiff) afterDiff(vnode);
|
|
619
|
-
vnode[PARENT] =
|
|
636
|
+
vnode[PARENT] = null;
|
|
620
637
|
if (ummountHook) ummountHook(vnode);
|
|
621
638
|
|
|
622
639
|
// Emit self-closing tag for empty void elements:
|