@jsenv/terminal-recorder 1.1.1 → 1.1.3
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.
|
@@ -1194,6 +1194,8 @@ const initTerminal = ({
|
|
|
1194
1194
|
}
|
|
1195
1195
|
};
|
|
1196
1196
|
|
|
1197
|
+
log("init", { cols, rows, fontFamily, fontSize, convertEol, gif, video });
|
|
1198
|
+
|
|
1197
1199
|
const cssUrl = new URL("/css/xterm.css", import.meta.url);
|
|
1198
1200
|
const link = document.createElement("link");
|
|
1199
1201
|
link.rel = "stylesheet";
|
|
@@ -1314,7 +1316,24 @@ const initTerminal = ({
|
|
|
1314
1316
|
};
|
|
1315
1317
|
mediaRecorder.start();
|
|
1316
1318
|
});
|
|
1317
|
-
|
|
1319
|
+
let timeout;
|
|
1320
|
+
let hasTimedout = false;
|
|
1321
|
+
const MS_ALLOCATED_TO_MEDIA_RECORDER = 2_000;
|
|
1322
|
+
await Promise.race([
|
|
1323
|
+
startPromise,
|
|
1324
|
+
new Promise((resolve) => {
|
|
1325
|
+
timeout = setTimeout(() => {
|
|
1326
|
+
hasTimedout = true;
|
|
1327
|
+
resolve();
|
|
1328
|
+
}, MS_ALLOCATED_TO_MEDIA_RECORDER);
|
|
1329
|
+
}),
|
|
1330
|
+
]);
|
|
1331
|
+
if (hasTimedout) {
|
|
1332
|
+
throw new Error(
|
|
1333
|
+
`media recorder did not start in less than ${MS_ALLOCATED_TO_MEDIA_RECORDER}ms`,
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
clearTimeout(timeout);
|
|
1318
1337
|
log("media recorder started");
|
|
1319
1338
|
|
|
1320
1339
|
stopCallbackSet.add(async () => {
|
|
@@ -1410,6 +1429,7 @@ const initTerminal = ({
|
|
|
1410
1429
|
return {
|
|
1411
1430
|
writeIntoTerminal: async (data) => {
|
|
1412
1431
|
await new Promise((resolve) => {
|
|
1432
|
+
log(`write data: "${data}"`);
|
|
1413
1433
|
term.write(data, () => {
|
|
1414
1434
|
term._core._renderService._renderDebouncer._innerRefresh();
|
|
1415
1435
|
replicateXterm();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/terminal-recorder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Record terminal output as .svg, .gif, .webm, .mp4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"prepublishOnly": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@jsenv/server": "15.2.
|
|
36
|
-
"@playwright/browser-
|
|
35
|
+
"@jsenv/server": "15.2.6",
|
|
36
|
+
"@playwright/browser-webkit": "1.45.1",
|
|
37
37
|
"ansi-regex": "6.0.1",
|
|
38
38
|
"he": "1.2.0",
|
|
39
|
-
"playwright": "1.45.
|
|
39
|
+
"playwright": "1.45.1",
|
|
40
40
|
"strip-ansi": "7.1.0",
|
|
41
41
|
"string-width": "5.1.2",
|
|
42
42
|
"webm-to-mp4": "1.0.0"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[90m------------[0m 3 executions to run [90m------------[0m
|
|
2
|
+
1 with chromium (chromium@120.0.6099.28)
|
|
3
|
+
1 with firefox (firefox@119.0)
|
|
4
|
+
1 with webkit (webkit@17.4)
|
|
5
|
+
[90m---------------------------------------------[0m
|
|
6
|
+
|
|
7
|
+
[32m✔ console.spec.html[0m [[90mchromium[0m[90m/[0m[90m<mock>[0m[90m/[0m[90m<mock>[0m] 1/3 (1 [32mcompleted[0m, 2 remaining)
|
|
8
|
+
[90m-----[0m console ([31m✖[0m 1 [33m⚠[0m 3 [34mℹ[0m 1 [90m◆[0m 1) [90m------[0m
|
|
9
|
+
[33m⚠[0m toto
|
|
10
|
+
[31m✖[0m hey
|
|
11
|
+
[33m⚠[0m hey
|
|
12
|
+
ho
|
|
13
|
+
[34mℹ[0m info
|
|
14
|
+
[33m⚠[0m test
|
|
15
|
+
multiline
|
|
16
|
+
[90m◆[0m verbose log
|
|
17
|
+
la
|
|
18
|
+
[90m--------------------------------------[0m
|
|
19
|
+
[32m✔ console.spec.html[0m [[90mfirefox[0m[90m/[0m[90m<mock>[0m] 2/3 (2 [32mcompleted[0m, 1 remaining)
|
|
20
|
+
[90m-----[0m console ([31m✖[0m 1 [33m⚠[0m 3 [34mℹ[0m 1 [90m◆[0m 1) [90m------[0m
|
|
21
|
+
[33m⚠[0m toto
|
|
22
|
+
[31m✖[0m hey
|
|
23
|
+
[33m⚠[0m hey
|
|
24
|
+
ho
|
|
25
|
+
[34mℹ[0m info
|
|
26
|
+
[33m⚠[0m test
|
|
27
|
+
multiline
|
|
28
|
+
[90m◆[0m verbose log
|
|
29
|
+
la
|
|
30
|
+
[90m--------------------------------------[0m
|
|
31
|
+
[32m✔ console.spec.html[0m [[90mwebkit[0m[90m/[0m[90m<mock>[0m] 3/3 (all [32mcompleted[0m)
|
|
32
|
+
[90m-----[0m console ([31m✖[0m 1 [33m⚠[0m 3 [34mℹ[0m 1 [90m◆[0m 1) [90m------[0m
|
|
33
|
+
[33m⚠[0m toto
|
|
34
|
+
[31m✖[0m hey
|
|
35
|
+
[33m⚠[0m hey
|
|
36
|
+
ho
|
|
37
|
+
[34mℹ[0m info
|
|
38
|
+
[33m⚠[0m test
|
|
39
|
+
multiline
|
|
40
|
+
[90m◆[0m verbose log
|
|
41
|
+
la
|
|
42
|
+
[90m--------------------------------------[0m
|
|
43
|
+
|
|
44
|
+
[90m------------------[0m summary [90m------------------[0m
|
|
45
|
+
3 executions: all [32mcompleted[0m
|
|
46
|
+
duration: <mock>
|
|
47
|
+
[90m---------------------------------------------[0m
|
|
@@ -43,6 +43,8 @@ export const initTerminal = ({
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
log("init", { cols, rows, fontFamily, fontSize, convertEol, gif, video });
|
|
47
|
+
|
|
46
48
|
const cssUrl = new URL("xterm/css/xterm.css", import.meta.url);
|
|
47
49
|
const link = document.createElement("link");
|
|
48
50
|
link.rel = "stylesheet";
|
|
@@ -163,7 +165,24 @@ export const initTerminal = ({
|
|
|
163
165
|
};
|
|
164
166
|
mediaRecorder.start();
|
|
165
167
|
});
|
|
166
|
-
|
|
168
|
+
let timeout;
|
|
169
|
+
let hasTimedout = false;
|
|
170
|
+
const MS_ALLOCATED_TO_MEDIA_RECORDER = 2_000;
|
|
171
|
+
await Promise.race([
|
|
172
|
+
startPromise,
|
|
173
|
+
new Promise((resolve) => {
|
|
174
|
+
timeout = setTimeout(() => {
|
|
175
|
+
hasTimedout = true;
|
|
176
|
+
resolve();
|
|
177
|
+
}, MS_ALLOCATED_TO_MEDIA_RECORDER);
|
|
178
|
+
}),
|
|
179
|
+
]);
|
|
180
|
+
if (hasTimedout) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`media recorder did not start in less than ${MS_ALLOCATED_TO_MEDIA_RECORDER}ms`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
clearTimeout(timeout);
|
|
167
186
|
log("media recorder started");
|
|
168
187
|
|
|
169
188
|
stopCallbackSet.add(async () => {
|
|
@@ -259,6 +278,7 @@ export const initTerminal = ({
|
|
|
259
278
|
return {
|
|
260
279
|
writeIntoTerminal: async (data) => {
|
|
261
280
|
await new Promise((resolve) => {
|
|
281
|
+
log(`write data: "${data}"`);
|
|
262
282
|
term.write(data, () => {
|
|
263
283
|
term._core._renderService._renderDebouncer._innerRefresh();
|
|
264
284
|
replicateXterm();
|
|
@@ -19,12 +19,17 @@
|
|
|
19
19
|
repeat: true,
|
|
20
20
|
msAddedAtTheEnd: 3_000,
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
logs: true,
|
|
23
|
+
// video: true,
|
|
23
24
|
});
|
|
24
25
|
const { writeIntoTerminal, stopRecording } = await startRecording();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const sourceResponse = await fetch("./source.txt");
|
|
27
|
+
const source = await sourceResponse.text();
|
|
28
|
+
const lines = source.split("\n");
|
|
29
|
+
for (const line of lines) {
|
|
30
|
+
writeIntoTerminal(`${line}\n`);
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
32
|
+
}
|
|
28
33
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
29
34
|
const terminalRecords = await stopRecording();
|
|
30
35
|
const video = terminalRecords.video;
|
|
@@ -90,10 +90,10 @@ export const startTerminalRecording = async ({
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
if (gif || video) {
|
|
93
|
-
const {
|
|
93
|
+
const { webkit } = await import("playwright");
|
|
94
94
|
const server = await startLocalServer();
|
|
95
|
-
const browser = await
|
|
96
|
-
channel: "chrome", // https://github.com/microsoft/playwright/issues/7716#issuecomment-882634893
|
|
95
|
+
const browser = await webkit.launch({
|
|
96
|
+
// channel: "chrome", // https://github.com/microsoft/playwright/issues/7716#issuecomment-882634893
|
|
97
97
|
headless: !debug,
|
|
98
98
|
// needed because https-localhost fails to trust cert on chrome + linux (ubuntu 20.04)
|
|
99
99
|
args: ["--ignore-certificate-errors"],
|