@happy-dom/server-renderer 20.3.6 → 20.3.7
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 +35 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -23,18 +23,20 @@ You will find the documentation in the [Happy DOM Wiki](https://github.com/capri
|
|
|
23
23
|
|
|
24
24
|
See all available command line arguments in the [Command Line Documentation](https://github.com/capricorn86/happy-dom/wiki/Server-Renderer-CLI-Arguments).
|
|
25
25
|
|
|
26
|
+
Note that JavaScript is disabled by default. To enable JavaScript, use the flag `--javascript`. A VM Context is not an isolated environment, and if you run untrusted JavaScript code you are at risk of RCE (Remote Code Execution) attacks. [Read more about risks and recommended security precautions here](https://github.com/capricorn86/happy-dom/wiki/JavaScript-Evaluation-Warning).
|
|
27
|
+
|
|
26
28
|
**Example 1**
|
|
27
29
|
|
|
28
30
|
Render to the file `./happy-dom/render/gb/en/index.html`.
|
|
29
31
|
|
|
30
32
|
```bash
|
|
31
|
-
npx @happy-dom/server-renderer "https://example.com/gb/en/"
|
|
33
|
+
npx @happy-dom/server-renderer --javascript "https://example.com/gb/en/"
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
or if you have it installed
|
|
35
37
|
|
|
36
38
|
```bash
|
|
37
|
-
happy-dom-sr "https://example.com/gb/en/"
|
|
39
|
+
happy-dom-sr --javascript "https://example.com/gb/en/"
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
**Example 2**
|
|
@@ -42,26 +44,54 @@ happy-dom-sr "https://example.com/gb/en/"
|
|
|
42
44
|
Start proxy server.
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
|
-
happy-dom-sr --server --server.targetOrigin="https://example.com"
|
|
47
|
+
happy-dom-sr --javascript --server --server.targetOrigin="https://example.com"
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
### JavaScript
|
|
49
51
|
|
|
50
52
|
See all available configuration options in the [Javascript API Documentation](https://github.com/capricorn86/happy-dom/wiki/ServerRenderer).
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
Note that JavaScript is disabled by default. To enable JavaScript, set the configuration `browser.enableJavaScriptEvaluation` to true. A VM Context is not an isolated environment, and if you run untrusted JavaScript code you are at risk of RCE (Remote Code Execution) attacks. [Read more about risks and recommended security precautions here](https://github.com/capricorn86/happy-dom/wiki/JavaScript-Evaluation-Warning).
|
|
55
|
+
|
|
56
|
+
**Example 1**
|
|
53
57
|
|
|
54
58
|
```javascript
|
|
55
59
|
import { ServerRenderer } from '@happy-dom/server-renderer';
|
|
56
60
|
|
|
57
61
|
const renderer = new ServerRenderer({
|
|
58
|
-
|
|
62
|
+
// Your configuration options
|
|
63
|
+
browser: {
|
|
64
|
+
enableJavaScriptEvaluation: true,
|
|
65
|
+
},
|
|
59
66
|
});
|
|
60
67
|
|
|
61
68
|
const result = await renderer.render(['https://example.com/gb/en/']);
|
|
62
69
|
|
|
70
|
+
// URL of the rendered page
|
|
71
|
+
console.log(result[0].url);
|
|
72
|
+
|
|
63
73
|
// The rendered HTML
|
|
74
|
+
console.log(result[0].content);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Example 2**
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
import { ServerRenderer } from '@happy-dom/server-renderer';
|
|
81
|
+
|
|
82
|
+
const renderer = new ServerRenderer({
|
|
83
|
+
// Your configuration options
|
|
84
|
+
browser: {
|
|
85
|
+
enableJavaScriptEvaluation: true,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const result = await renderer.render([{ url: 'https://example.com/gb/en/', html: '<div id="app"></div><script>document.getElementById("app").innerHTML = "Hello World!";</script>' }]);
|
|
90
|
+
|
|
91
|
+
// URL of the rendered page
|
|
64
92
|
console.log(result[0].url);
|
|
93
|
+
|
|
94
|
+
// The rendered HTML
|
|
65
95
|
console.log(result[0].content);
|
|
66
96
|
```
|
|
67
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happy-dom/server-renderer",
|
|
3
|
-
"version": "20.3.
|
|
3
|
+
"version": "20.3.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom/tree/master/packages/@happy-dom/server-renderer",
|
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"test:debug": "vitest run --inspect-brk --no-file-parallelism"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"happy-dom": "^20.3.
|
|
46
|
-
"@happy-dom/global-registrator": "^20.3.
|
|
45
|
+
"happy-dom": "^20.3.7",
|
|
46
|
+
"@happy-dom/global-registrator": "^20.3.7",
|
|
47
47
|
"chalk": "^5.4.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|