@jsenv/terminal-recorder 1.4.5 → 1.4.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/dist/js/terminal_recorder.js +67 -58
- package/package.json +4 -3
- package/src/.jsenv/chrome@128.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs +1 -1
- package/src/.jsenv/chrome@128.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs.map +11 -11
- package/src/.jsenv/chrome@128.00/terminal_recorder.js +68 -50
- package/src/.jsenv/chrome@128.00/terminal_recorder.js.map +2 -2
- package/src/client/terminal_recorder.js +67 -59
- package/src/client/xterm_dev.html +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t();}(self,(()=>(()=>{var e={};return (()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e;}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows));}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return {cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}};})(),e})()));
|
|
2
|
+
|
|
1
3
|
!function (e, t) {
|
|
2
4
|
"object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.SerializeAddon = t() : e.SerializeAddon = t();
|
|
3
5
|
}(window, () => (() => {
|
|
@@ -1916,6 +1918,7 @@ https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts
|
|
|
1916
1918
|
|
|
1917
1919
|
|
|
1918
1920
|
const { Terminal } = window;
|
|
1921
|
+
const { FitAddon } = window.FitAddon;
|
|
1919
1922
|
const { WebglAddon } = window.WebglAddon;
|
|
1920
1923
|
const { SerializeAddon } = window.SerializeAddon;
|
|
1921
1924
|
|
|
@@ -1972,74 +1975,80 @@ const initTerminal = ({
|
|
|
1972
1975
|
brightBlue: "#87CEEB",
|
|
1973
1976
|
},
|
|
1974
1977
|
});
|
|
1975
|
-
term.loadAddon(
|
|
1976
|
-
new WebglAddon(
|
|
1977
|
-
// we pass true to enable preserveDrawingBuffer
|
|
1978
|
-
// it's not actually useful thanks to term.write callback +
|
|
1979
|
-
// call on _innerRefresh() before context.drawImage
|
|
1980
|
-
// but let's keep it nevertheless
|
|
1981
|
-
true,
|
|
1982
|
-
),
|
|
1983
|
-
);
|
|
1984
1978
|
const serializeAddon = new SerializeAddon();
|
|
1985
1979
|
term.loadAddon(serializeAddon);
|
|
1986
|
-
|
|
1987
|
-
|
|
1980
|
+
const fitAddon = new FitAddon();
|
|
1981
|
+
term.loadAddon(fitAddon);
|
|
1982
|
+
const webglAddon = new WebglAddon(
|
|
1983
|
+
// we pass true to enable preserveDrawingBuffer
|
|
1984
|
+
// it's not actually useful thanks to term.write callback +
|
|
1985
|
+
// call on _innerRefresh() before context.drawImage
|
|
1986
|
+
// but let's keep it nevertheless
|
|
1987
|
+
true,
|
|
1988
|
+
);
|
|
1989
|
+
term.loadAddon(webglAddon);
|
|
1990
|
+
const terminalElement = document.querySelector("#terminal");
|
|
1988
1991
|
term.open(terminalElement);
|
|
1992
|
+
fitAddon.fit();
|
|
1989
1993
|
|
|
1990
1994
|
const canvas = document.querySelector("#canvas");
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
);
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
canvas.height = headerHeight + xtermCanvas.height;
|
|
1999
|
-
|
|
2000
|
-
{
|
|
2001
|
-
drawRectangle(context, {
|
|
2002
|
-
x: 0,
|
|
2003
|
-
y: 0,
|
|
2004
|
-
width: canvas.width,
|
|
2005
|
-
height: canvas.height,
|
|
2006
|
-
fill: "#282c34",
|
|
2007
|
-
stroke: "rgba(255,255,255,0.35)",
|
|
2008
|
-
strokeWidth: 10,
|
|
2009
|
-
radius: 8,
|
|
2010
|
-
});
|
|
2011
|
-
drawCircle(context, {
|
|
2012
|
-
x: 20,
|
|
2013
|
-
y: headerHeight / 2,
|
|
2014
|
-
radius: 6,
|
|
2015
|
-
fill: "#ff5f57",
|
|
2016
|
-
});
|
|
2017
|
-
drawCircle(context, {
|
|
2018
|
-
x: 40,
|
|
2019
|
-
y: headerHeight / 2,
|
|
2020
|
-
radius: 6,
|
|
2021
|
-
fill: "#febc2e",
|
|
2022
|
-
});
|
|
2023
|
-
drawCircle(context, {
|
|
2024
|
-
x: 60,
|
|
2025
|
-
y: headerHeight / 2,
|
|
2026
|
-
radius: 6,
|
|
2027
|
-
fill: "#28c840",
|
|
2028
|
-
});
|
|
2029
|
-
|
|
2030
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text
|
|
2031
|
-
const text = "Terminal";
|
|
2032
|
-
context.font = `${fontSize}px ${fontFamily}`;
|
|
2033
|
-
context.textBaseline = "middle";
|
|
2034
|
-
context.textAlign = "center";
|
|
2035
|
-
// const textSize = context.measureText(text);
|
|
2036
|
-
context.fillStyle = "#abb2bf";
|
|
2037
|
-
context.fillText(text, canvas.width / 2, headerHeight / 2);
|
|
1995
|
+
if (!canvas) {
|
|
1996
|
+
throw new Error('Cannot find <canvas id="canvas"> in the document');
|
|
1997
|
+
}
|
|
1998
|
+
const xTermCanvasSelector = "#terminal canvas.xterm-link-layer + canvas";
|
|
1999
|
+
const xtermCanvas = document.querySelector(xTermCanvasSelector);
|
|
2000
|
+
if (!xtermCanvas) {
|
|
2001
|
+
throw new Error(`Cannot find xterm canvas (${xTermCanvasSelector})`);
|
|
2038
2002
|
}
|
|
2039
2003
|
|
|
2040
2004
|
return {
|
|
2041
2005
|
term,
|
|
2042
2006
|
startRecording: async () => {
|
|
2007
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
2008
|
+
context.imageSmoothingEnabled = true;
|
|
2009
|
+
const headerHeight = 40;
|
|
2010
|
+
canvas.width = paddingLeft + xtermCanvas.width + paddingRight;
|
|
2011
|
+
canvas.height = headerHeight + xtermCanvas.height;
|
|
2012
|
+
{
|
|
2013
|
+
drawRectangle(context, {
|
|
2014
|
+
x: 0,
|
|
2015
|
+
y: 0,
|
|
2016
|
+
width: canvas.width,
|
|
2017
|
+
height: canvas.height,
|
|
2018
|
+
fill: "#282c34",
|
|
2019
|
+
stroke: "rgba(255,255,255,0.35)",
|
|
2020
|
+
strokeWidth: 10,
|
|
2021
|
+
radius: 8,
|
|
2022
|
+
});
|
|
2023
|
+
drawCircle(context, {
|
|
2024
|
+
x: 20,
|
|
2025
|
+
y: headerHeight / 2,
|
|
2026
|
+
radius: 6,
|
|
2027
|
+
fill: "#ff5f57",
|
|
2028
|
+
});
|
|
2029
|
+
drawCircle(context, {
|
|
2030
|
+
x: 40,
|
|
2031
|
+
y: headerHeight / 2,
|
|
2032
|
+
radius: 6,
|
|
2033
|
+
fill: "#febc2e",
|
|
2034
|
+
});
|
|
2035
|
+
drawCircle(context, {
|
|
2036
|
+
x: 60,
|
|
2037
|
+
y: headerHeight / 2,
|
|
2038
|
+
radius: 6,
|
|
2039
|
+
fill: "#28c840",
|
|
2040
|
+
});
|
|
2041
|
+
|
|
2042
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text
|
|
2043
|
+
const text = "Terminal";
|
|
2044
|
+
context.font = `${fontSize}px ${fontFamily}`;
|
|
2045
|
+
context.textBaseline = "middle";
|
|
2046
|
+
context.textAlign = "center";
|
|
2047
|
+
// const textSize = context.measureText(text);
|
|
2048
|
+
context.fillStyle = "#abb2bf";
|
|
2049
|
+
context.fillText(text, canvas.width / 2, headerHeight / 2);
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2043
2052
|
const records = {};
|
|
2044
2053
|
let writePromise = Promise.resolve();
|
|
2045
2054
|
const frameCallbackSet = new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/terminal-recorder",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "Record terminal output as .svg, .gif, .webm, .mp4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"webm-to-mp4": "1.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@xterm/addon-fit": "0.10.0",
|
|
52
53
|
"@xterm/addon-serialize": "0.13.0",
|
|
53
|
-
"@xterm/
|
|
54
|
-
"@xterm/
|
|
54
|
+
"@xterm/addon-webgl": "0.18.0",
|
|
55
|
+
"@xterm/xterm": "5.5.0"
|
|
55
56
|
}
|
|
56
57
|
}
|