@jsenv/terminal-recorder 1.5.17 → 1.5.20
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 +164 -15
- package/dist/jsenv_terminal_recorder_node_modules.js +3 -4
- package/package.json +14 -7
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs.map +11 -11
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-serialize/lib/addon-serialize7as_js_module=.mjs +749 -0
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/xterm/lib/xterm.js.map +1 -0
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/packages/internal/plugin-supervisor/src/client/supervisor.js +9 -8
- package/src/.jsenv/chrome@134.00/gif_encoder.js +1 -1
- package/src/.jsenv/chrome@134.00/gif_encoder.js.map +1 -1
- package/src/.jsenv/chrome@134.00/terminal_recorder.js +6 -6
- package/src/.jsenv/chrome@134.00/terminal_recorder.js.map +2 -2
- package/src/.jsenv/chrome@134.00/xterm.html +3 -3
- package/src/.jsenv/chrome@134.00/xterm.html@L19C5-L24C14.js +1 -1
- package/src/.jsenv/chrome@134.00/xterm.html@L19C5-L24C14.js.map +1 -1
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/core/node_modules/@xterm/addon-serialize/lib/addon-serialize7as_js_module=.mjs +0 -749
- package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/core/node_modules/@xterm/xterm/lib/xterm.js.map +0 -2558
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-fit/lib/addon-fit.js +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-fit/lib/addon-fit.js.map +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-serialize/lib/addon-serialize.js +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-serialize/lib/addon-serialize.js.map +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-webgl/lib/addon-webgl.js +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/addon-webgl/lib/addon-webgl.js.map +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/xterm/css/xterm.css +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core → jsenv/core}/node_modules/@xterm/xterm/lib/xterm.js +0 -0
- /package/src/.jsenv/chrome@134.00/@fs/Users/dmail/Documents/dev/{core/packages/independent → jsenv/core/packages}/backend/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js +0 -0
package/README.md
CHANGED
|
@@ -1,20 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Terminal Recorder [](https://www.npmjs.com/package/@jsenv/terminal-recorder)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create beautiful terminal recordings in multiple formats for documentation and demos.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
🎬 Generate static SVGs of terminal output
|
|
6
|
+
🎭 Create animated GIF recordings
|
|
7
|
+
🎥 Export MP4 and WebM videos
|
|
8
|
+
🎨 Full ANSI color and Unicode support
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## Output Examples
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
### SVG (Static)
|
|
10
13
|
|
|
11
|
-

|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
### GIF (Animated)
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
npm install @jsenv/terminal-recorder
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
14
27
|
|
|
15
28
|
```js
|
|
16
29
|
import { writeFileSync } from "node:fs";
|
|
30
|
+
import { startTerminalRecording } from "@jsenv/terminal-recorder";
|
|
17
31
|
|
|
32
|
+
// Start recording with multiple output formats
|
|
33
|
+
const recorder = await startTerminalRecording({
|
|
34
|
+
svg: { title: "Terminal Demo" },
|
|
35
|
+
gif: true,
|
|
36
|
+
video: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Write terminal content with ANSI color codes
|
|
40
|
+
recorder.write("[1;32mHello[0m [1;34mWorld![0m");
|
|
41
|
+
|
|
42
|
+
// Wait a moment for animation
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
44
|
+
|
|
45
|
+
// Stop recording and get results
|
|
46
|
+
const result = await recorder.stop();
|
|
47
|
+
|
|
48
|
+
// Save in different formats
|
|
49
|
+
writeFileSync("./terminal.svg", await result.svg());
|
|
50
|
+
writeFileSync("./terminal.gif", await result.gif());
|
|
51
|
+
writeFileSync("./terminal.mp4", await result.mp4());
|
|
52
|
+
writeFileSync("./terminal.webm", await result.webm());
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Full Example
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { writeFileSync } from "node:fs";
|
|
18
59
|
import { startTerminalRecording } from "@jsenv/terminal-recorder";
|
|
19
60
|
|
|
20
61
|
const terminalRecorder = await startTerminalRecording({
|
|
@@ -24,28 +65,136 @@ const terminalRecorder = await startTerminalRecording({
|
|
|
24
65
|
video: true,
|
|
25
66
|
gif: true,
|
|
26
67
|
});
|
|
68
|
+
|
|
69
|
+
// Show colorful text with delays between each line
|
|
27
70
|
const datas = [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
71
|
+
`[31mred[39m `,
|
|
72
|
+
`[33myellow[39m `,
|
|
73
|
+
`[32mgreen[39m `,
|
|
74
|
+
`[36mcyan[39m `,
|
|
75
|
+
`[34mblue[39m `,
|
|
76
|
+
`[35mmagenta[39m`,
|
|
34
77
|
];
|
|
78
|
+
|
|
35
79
|
for (const data of datas) {
|
|
36
80
|
terminalRecorder.write(data);
|
|
37
81
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
38
82
|
}
|
|
83
|
+
|
|
84
|
+
// Stop recording and export all formats
|
|
39
85
|
const result = await terminalRecorder.stop();
|
|
86
|
+
|
|
87
|
+
// Save outputs
|
|
40
88
|
const svg = await result.svg();
|
|
41
89
|
writeFileSync(new URL("./terminal.svg", import.meta.url), svg);
|
|
90
|
+
|
|
42
91
|
const gif = await result.gif();
|
|
43
92
|
writeFileSync(new URL("./terminal.gif", import.meta.url), gif);
|
|
93
|
+
|
|
44
94
|
const webm = await result.webm();
|
|
45
95
|
writeFileSync(new URL("./terminal.webm", import.meta.url), webm);
|
|
96
|
+
|
|
46
97
|
const mp4 = await result.mp4();
|
|
47
98
|
writeFileSync(new URL("./terminal.mp4", import.meta.url), mp4);
|
|
48
99
|
```
|
|
49
100
|
|
|
50
|
-
|
|
51
|
-
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### startTerminalRecording(options)
|
|
104
|
+
|
|
105
|
+
Starts a terminal recording session with the specified options.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const recorder = await startTerminalRecording({
|
|
109
|
+
// SVG options (set to false to disable)
|
|
110
|
+
svg: {
|
|
111
|
+
title: "My Terminal", // Title shown in the terminal window
|
|
112
|
+
width: 800, // Width in pixels
|
|
113
|
+
height: 400, // Height in pixels
|
|
114
|
+
fontSize: 14, // Font size in pixels
|
|
115
|
+
fontFamily: "monospace", // Font family
|
|
116
|
+
theme: {
|
|
117
|
+
// Terminal color theme
|
|
118
|
+
background: "#1e1e1e",
|
|
119
|
+
foreground: "#ffffff",
|
|
120
|
+
// Additional theme options...
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// Enable video output formats (WebM, MP4)
|
|
125
|
+
video: true,
|
|
126
|
+
|
|
127
|
+
// Enable GIF output
|
|
128
|
+
gif: {
|
|
129
|
+
fps: 10, // Frames per second
|
|
130
|
+
quality: 80, // Quality (1-100)
|
|
131
|
+
repeat: 0, // 0 = loop forever, -1 = no repeat, n = repeat n times
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// Terminal configuration
|
|
135
|
+
cols: 80, // Number of columns
|
|
136
|
+
rows: 24, // Number of rows
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### recorder.write(data)
|
|
141
|
+
|
|
142
|
+
Writes data to the terminal. Supports ANSI color codes and escape sequences.
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
// Simple text
|
|
146
|
+
recorder.write("Hello World");
|
|
147
|
+
|
|
148
|
+
// With ANSI colors
|
|
149
|
+
recorder.write("\x1b[31mRed Text\x1b[0m");
|
|
150
|
+
|
|
151
|
+
// With SGR parameters
|
|
152
|
+
recorder.write("[1;32mBold Green[0m");
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### recorder.stop()
|
|
156
|
+
|
|
157
|
+
Stops the recording and returns a result object with methods to generate different output formats.
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
const result = await recorder.stop();
|
|
161
|
+
|
|
162
|
+
// Get SVG string
|
|
163
|
+
const svg = await result.svg();
|
|
164
|
+
|
|
165
|
+
// Get GIF buffer
|
|
166
|
+
const gif = await result.gif();
|
|
167
|
+
|
|
168
|
+
// Get WebM video buffer
|
|
169
|
+
const webm = await result.webm();
|
|
170
|
+
|
|
171
|
+
// Get MP4 video buffer
|
|
172
|
+
const mp4 = await result.mp4();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## How It Works
|
|
176
|
+
|
|
177
|
+
- **SVG generation**: Direct rendering of terminal state to SVG
|
|
178
|
+
- **Animated formats**: Uses [xterm.js](https://xtermjs.org/) in Chrome headless via Playwright
|
|
179
|
+
- **Video encoding**: Leverages browser's video encoding capabilities
|
|
180
|
+
|
|
181
|
+
## Compatibility
|
|
182
|
+
|
|
183
|
+
- Node.js: 16.x and above
|
|
184
|
+
- Requires Playwright for animated formats
|
|
185
|
+
- Works on macOS, Linux, and Windows
|
|
186
|
+
|
|
187
|
+
## Use Cases
|
|
188
|
+
|
|
189
|
+
- Create documentation with terminal examples
|
|
190
|
+
- Record CLI tool demos for README files
|
|
191
|
+
- Generate terminal screenshots for blog posts
|
|
192
|
+
- Create animated terminal presentations
|
|
193
|
+
|
|
194
|
+
## Contributing
|
|
195
|
+
|
|
196
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
[MIT](./LICENSE)
|
|
@@ -22,10 +22,9 @@ function stripAnsi(string) {
|
|
|
22
22
|
return string.replace(regex, '');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const r = String.raw
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const emojiRegex = () => new RegExp(r`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${sTags}]{2}[\u{E0030}-\u{E0039}${sTags}]{1,3}\u{E007F}|${seq}(?:\u200D${seq})*`, 'gu');
|
|
25
|
+
const r = String.raw,
|
|
26
|
+
e = r`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`;
|
|
27
|
+
const emojiRegex = () => new RegExp(r`\p{RI}{2}|(?)${e}(?:\u200D${e})*`, 'gu');
|
|
29
28
|
|
|
30
29
|
// Generated code.
|
|
31
30
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/terminal-recorder",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.20",
|
|
4
4
|
"description": "Record terminal output as .svg, .gif, .webm, .mp4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/jsenv/core",
|
|
9
|
-
"directory": "packages/
|
|
9
|
+
"directory": "packages/tooling/terminal-recorder"
|
|
10
10
|
},
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "dmail",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jsenv/humanize": "1.
|
|
40
|
+
"@jsenv/humanize": "1.6.0",
|
|
41
41
|
"@jsenv/server": "16.1.2",
|
|
42
|
-
"@playwright/browser-chromium": "1.
|
|
43
|
-
"@jsenv/terminal-text-size": "0.0.
|
|
42
|
+
"@playwright/browser-chromium": "1.52.0",
|
|
43
|
+
"@jsenv/terminal-text-size": "0.0.2",
|
|
44
44
|
"ansi-regex": "6.1.0",
|
|
45
45
|
"he": "1.2.0",
|
|
46
|
-
"playwright": "1.
|
|
46
|
+
"playwright": "1.52.0",
|
|
47
47
|
"strip-ansi": "7.1.0",
|
|
48
48
|
"eastasianwidth": "0.3.0",
|
|
49
49
|
"webm-to-mp4": "1.0.0"
|
|
@@ -52,6 +52,13 @@
|
|
|
52
52
|
"@xterm/addon-fit": "0.10.0",
|
|
53
53
|
"@xterm/addon-serialize": "0.13.0",
|
|
54
54
|
"@xterm/addon-webgl": "0.18.0",
|
|
55
|
-
"@xterm/xterm": "5.5.0"
|
|
55
|
+
"@xterm/xterm": "5.5.0",
|
|
56
|
+
"@jsenv/core": "../../../",
|
|
57
|
+
"@jsenv/assert": "../assert",
|
|
58
|
+
"@jsenv/https-local": "../https-local",
|
|
59
|
+
"@jsenv/filesystem": "../filesystem",
|
|
60
|
+
"@jsenv/snapshot": "../snapshot",
|
|
61
|
+
"@jsenv/terminal-recorder": "./",
|
|
62
|
+
"@jsenv/plugin-commonjs": "../../related/plugin-commonjs"
|
|
56
63
|
}
|
|
57
64
|
}
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"webpack://SerializeAddon/src/common/services/Services.ts",
|
|
13
13
|
"webpack://SerializeAddon/webpack/bootstrap",
|
|
14
14
|
"webpack://SerializeAddon/src/SerializeAddon.ts",
|
|
15
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/webpack/universalModuleDefinition",
|
|
16
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/browser/ColorContrastCache.ts",
|
|
17
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/browser/services/ThemeService.ts",
|
|
18
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/Color.ts",
|
|
19
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/EventEmitter.ts",
|
|
20
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/Lifecycle.ts",
|
|
21
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/MultiKeyMap.ts",
|
|
22
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/services/ServiceRegistry.ts",
|
|
23
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/common/services/Services.ts",
|
|
24
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/webpack/bootstrap",
|
|
25
|
-
"file:///Users/dmail/Documents/dev/core/webpack:/SerializeAddon/src/SerializeAddon.ts"
|
|
15
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/webpack/universalModuleDefinition",
|
|
16
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/browser/ColorContrastCache.ts",
|
|
17
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/browser/services/ThemeService.ts",
|
|
18
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/Color.ts",
|
|
19
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/EventEmitter.ts",
|
|
20
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/Lifecycle.ts",
|
|
21
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/MultiKeyMap.ts",
|
|
22
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/services/ServiceRegistry.ts",
|
|
23
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/common/services/Services.ts",
|
|
24
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/webpack/bootstrap",
|
|
25
|
+
"file:///Users/dmail/Documents/dev/jsenv/core/webpack:/SerializeAddon/src/SerializeAddon.ts"
|
|
26
26
|
],
|
|
27
27
|
"names": [
|
|
28
28
|
"root",
|