@jsenv/terminal-recorder 1.4.0 → 1.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.
|
@@ -2156,24 +2156,19 @@ const initTerminal = ({
|
|
|
2156
2156
|
repeat: repeat === true ? 0 : repeat === false ? -1 : repeat,
|
|
2157
2157
|
quality,
|
|
2158
2158
|
});
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
frameCallbackSet.add(() => {
|
|
2164
|
-
const now = Date.now();
|
|
2165
|
-
const msSincePreviousFrame = now - previousTime;
|
|
2166
|
-
previousTime = now;
|
|
2167
|
-
log(`add frame to gif with delay of ${msSincePreviousFrame}ms`);
|
|
2168
|
-
gifEncoder.addFrame(context, { delay: msSincePreviousFrame });
|
|
2159
|
+
frameCallbackSet.add(({ delay }) => {
|
|
2160
|
+
log(`add frame to gif with delay of ${delay}ms`);
|
|
2161
|
+
gifEncoder.addFrame(context, { delay });
|
|
2169
2162
|
});
|
|
2170
2163
|
stopCallbackSet.add(async () => {
|
|
2164
|
+
const now = Date.now();
|
|
2165
|
+
drawFrame({
|
|
2166
|
+
delay: now - previousTime,
|
|
2167
|
+
});
|
|
2171
2168
|
if (msAddedAtTheEnd) {
|
|
2172
|
-
drawFrame(
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
} else {
|
|
2176
|
-
drawFrame();
|
|
2169
|
+
drawFrame({
|
|
2170
|
+
delay: now - msAddedAtTheEnd,
|
|
2171
|
+
});
|
|
2177
2172
|
}
|
|
2178
2173
|
gifEncoder.finish();
|
|
2179
2174
|
log("gif recording stopped");
|
|
@@ -2183,9 +2178,12 @@ const initTerminal = ({
|
|
|
2183
2178
|
log("gif recorder started");
|
|
2184
2179
|
}
|
|
2185
2180
|
|
|
2186
|
-
const
|
|
2181
|
+
const startTime = Date.now();
|
|
2182
|
+
let previousTime = startTime;
|
|
2183
|
+
let isFirstDraw = true;
|
|
2184
|
+
const drawFrame = (options) => {
|
|
2187
2185
|
for (const frameCallback of frameCallbackSet) {
|
|
2188
|
-
frameCallback();
|
|
2186
|
+
frameCallback(options);
|
|
2189
2187
|
}
|
|
2190
2188
|
};
|
|
2191
2189
|
|
|
@@ -2204,16 +2202,24 @@ const initTerminal = ({
|
|
|
2204
2202
|
};
|
|
2205
2203
|
|
|
2206
2204
|
replicateXterm();
|
|
2207
|
-
drawFrame();
|
|
2208
2205
|
|
|
2209
2206
|
return {
|
|
2210
|
-
writeIntoTerminal: async (data) => {
|
|
2207
|
+
writeIntoTerminal: async (data, options = {}) => {
|
|
2208
|
+
if (isFirstDraw) {
|
|
2209
|
+
isFirstDraw = false;
|
|
2210
|
+
drawFrame({ delay: 0 });
|
|
2211
|
+
}
|
|
2212
|
+
let { delay } = options;
|
|
2213
|
+
if (delay === undefined) {
|
|
2214
|
+
const now = Date.now();
|
|
2215
|
+
delay = now - previousTime;
|
|
2216
|
+
}
|
|
2211
2217
|
writePromise = new Promise((resolve) => {
|
|
2212
2218
|
log(`write data:`, data);
|
|
2213
2219
|
term.write(data, () => {
|
|
2214
2220
|
term._core._renderService._renderDebouncer._innerRefresh();
|
|
2215
2221
|
replicateXterm();
|
|
2216
|
-
drawFrame();
|
|
2222
|
+
drawFrame({ delay });
|
|
2217
2223
|
resolve();
|
|
2218
2224
|
});
|
|
2219
2225
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/terminal-recorder",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Record terminal output as .svg, .gif, .webm, .mp4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jsenv/humanize": "1.2.
|
|
42
|
-
"@jsenv/server": "15.2.
|
|
41
|
+
"@jsenv/humanize": "1.2.7",
|
|
42
|
+
"@jsenv/server": "15.2.17",
|
|
43
43
|
"@playwright/browser-chromium": "1.45.3",
|
|
44
44
|
"ansi-regex": "6.0.1",
|
|
45
45
|
"he": "1.2.0",
|
|
@@ -258,24 +258,19 @@ export const initTerminal = ({
|
|
|
258
258
|
repeat: repeat === true ? 0 : repeat === false ? -1 : repeat,
|
|
259
259
|
quality,
|
|
260
260
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
frameCallbackSet.add(() => {
|
|
266
|
-
const now = Date.now();
|
|
267
|
-
const msSincePreviousFrame = now - previousTime;
|
|
268
|
-
previousTime = now;
|
|
269
|
-
log(`add frame to gif with delay of ${msSincePreviousFrame}ms`);
|
|
270
|
-
gifEncoder.addFrame(context, { delay: msSincePreviousFrame });
|
|
261
|
+
frameCallbackSet.add(({ delay }) => {
|
|
262
|
+
log(`add frame to gif with delay of ${delay}ms`);
|
|
263
|
+
gifEncoder.addFrame(context, { delay });
|
|
271
264
|
});
|
|
272
265
|
stopCallbackSet.add(async () => {
|
|
266
|
+
const now = Date.now();
|
|
267
|
+
drawFrame({
|
|
268
|
+
delay: now - previousTime,
|
|
269
|
+
});
|
|
273
270
|
if (msAddedAtTheEnd) {
|
|
274
|
-
drawFrame(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
} else {
|
|
278
|
-
drawFrame();
|
|
271
|
+
drawFrame({
|
|
272
|
+
delay: now - msAddedAtTheEnd,
|
|
273
|
+
});
|
|
279
274
|
}
|
|
280
275
|
gifEncoder.finish();
|
|
281
276
|
log("gif recording stopped");
|
|
@@ -285,9 +280,12 @@ export const initTerminal = ({
|
|
|
285
280
|
log("gif recorder started");
|
|
286
281
|
}
|
|
287
282
|
|
|
288
|
-
const
|
|
283
|
+
const startTime = Date.now();
|
|
284
|
+
let previousTime = startTime;
|
|
285
|
+
let isFirstDraw = true;
|
|
286
|
+
const drawFrame = (options) => {
|
|
289
287
|
for (const frameCallback of frameCallbackSet) {
|
|
290
|
-
frameCallback();
|
|
288
|
+
frameCallback(options);
|
|
291
289
|
}
|
|
292
290
|
};
|
|
293
291
|
|
|
@@ -306,16 +304,24 @@ export const initTerminal = ({
|
|
|
306
304
|
};
|
|
307
305
|
|
|
308
306
|
replicateXterm();
|
|
309
|
-
drawFrame();
|
|
310
307
|
|
|
311
308
|
return {
|
|
312
|
-
writeIntoTerminal: async (data) => {
|
|
309
|
+
writeIntoTerminal: async (data, options = {}) => {
|
|
310
|
+
if (isFirstDraw) {
|
|
311
|
+
isFirstDraw = false;
|
|
312
|
+
drawFrame({ delay: 0 });
|
|
313
|
+
}
|
|
314
|
+
let { delay } = options;
|
|
315
|
+
if (delay === undefined) {
|
|
316
|
+
const now = Date.now();
|
|
317
|
+
delay = now - previousTime;
|
|
318
|
+
}
|
|
313
319
|
writePromise = new Promise((resolve) => {
|
|
314
320
|
log(`write data:`, data);
|
|
315
321
|
term.write(data, () => {
|
|
316
322
|
term._core._renderService._renderDebouncer._innerRefresh();
|
|
317
323
|
replicateXterm();
|
|
318
|
-
drawFrame();
|
|
324
|
+
drawFrame({ delay });
|
|
319
325
|
resolve();
|
|
320
326
|
});
|
|
321
327
|
});
|
package/src/main_browser.js
CHANGED
|
@@ -133,13 +133,13 @@ export const startTerminalRecording = async ({
|
|
|
133
133
|
},
|
|
134
134
|
/* eslint-env node */
|
|
135
135
|
);
|
|
136
|
-
writeCallbackSet.add(async (data) => {
|
|
136
|
+
writeCallbackSet.add(async (data, options) => {
|
|
137
137
|
await page.evaluate(
|
|
138
138
|
/* eslint-env browser */
|
|
139
|
-
async (data) => {
|
|
140
|
-
await window.terminalRecording.writeIntoTerminal(data);
|
|
139
|
+
async ({ data, options }) => {
|
|
140
|
+
await window.terminalRecording.writeIntoTerminal(data, options);
|
|
141
141
|
},
|
|
142
|
-
data,
|
|
142
|
+
{ data, options },
|
|
143
143
|
/* eslint-env node */
|
|
144
144
|
);
|
|
145
145
|
});
|
|
@@ -181,13 +181,13 @@ export const startTerminalRecording = async ({
|
|
|
181
181
|
});
|
|
182
182
|
let stopped = false;
|
|
183
183
|
return {
|
|
184
|
-
write: async (data) => {
|
|
184
|
+
write: async (data, options) => {
|
|
185
185
|
if (stopped) {
|
|
186
186
|
throw new Error("write after stop()");
|
|
187
187
|
}
|
|
188
188
|
const promises = [];
|
|
189
189
|
for (const writeCallback of writeCallbackSet) {
|
|
190
|
-
promises.push(writeCallback(data));
|
|
190
|
+
promises.push(writeCallback(data, options));
|
|
191
191
|
}
|
|
192
192
|
await Promise.all(promises);
|
|
193
193
|
},
|