@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
- await startPromise;
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.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.4",
36
- "@playwright/browser-chromium": "1.45.0",
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.0",
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
+ ------------ 3 executions to run ------------
2
+ 1 with chromium (chromium@120.0.6099.28)
3
+ 1 with firefox (firefox@119.0)
4
+ 1 with webkit (webkit@17.4)
5
+ ---------------------------------------------
6
+
7
+ ✔ console.spec.html [chromium/<mock>/<mock>] 1/3 (1 completed, 2 remaining)
8
+ ----- console (✖ 1 ⚠ 3 ℹ 1 ◆ 1) ------
9
+ ⚠ toto
10
+ ✖ hey
11
+ ⚠ hey
12
+ ho
13
+ ℹ info
14
+ ⚠ test
15
+ multiline
16
+ ◆ verbose log
17
+ la
18
+ --------------------------------------
19
+ ✔ console.spec.html [firefox/<mock>] 2/3 (2 completed, 1 remaining)
20
+ ----- console (✖ 1 ⚠ 3 ℹ 1 ◆ 1) ------
21
+ ⚠ toto
22
+ ✖ hey
23
+ ⚠ hey
24
+ ho
25
+ ℹ info
26
+ ⚠ test
27
+ multiline
28
+ ◆ verbose log
29
+ la
30
+ --------------------------------------
31
+ ✔ console.spec.html [webkit/<mock>] 3/3 (all completed)
32
+ ----- console (✖ 1 ⚠ 3 ℹ 1 ◆ 1) ------
33
+ ⚠ toto
34
+ ✖ hey
35
+ ⚠ hey
36
+ ho
37
+ ℹ info
38
+ ⚠ test
39
+ multiline
40
+ ◆ verbose log
41
+ la
42
+ --------------------------------------
43
+
44
+ ------------------ summary ------------------
45
+ 3 executions: all completed
46
+ duration: <mock>
47
+ ---------------------------------------------
@@ -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
- await startPromise;
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
- video: true,
22
+ logs: true,
23
+ // video: true,
23
24
  });
24
25
  const { writeIntoTerminal, stopRecording } = await startRecording();
25
- writeIntoTerminal("hello\n");
26
- await new Promise((resolve) => setTimeout(resolve, 500));
27
- writeIntoTerminal("world");
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 { chromium } = await import("playwright");
93
+ const { webkit } = await import("playwright");
94
94
  const server = await startLocalServer();
95
- const browser = await chromium.launch({
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"],