@jsenv/terminal-recorder 1.4.5 → 1.4.6
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 -49
- package/package.json +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 +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 -49
|
@@ -1987,59 +1987,77 @@ const initTerminal = ({
|
|
|
1987
1987
|
const terminalElement = document.getElementById("terminal");
|
|
1988
1988
|
term.open(terminalElement);
|
|
1989
1989
|
|
|
1990
|
-
const
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
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);
|
|
2038
|
-
}
|
|
1990
|
+
const canvasPromise = (async () => {
|
|
1991
|
+
const canvas = document.querySelector("#canvas");
|
|
1992
|
+
if (!canvas) {
|
|
1993
|
+
throw new Error('Cannot find <canvas id="canvas"> in the document');
|
|
1994
|
+
}
|
|
1995
|
+
let xtermCanvas = document.querySelector(
|
|
1996
|
+
"#terminal canvas.xterm-link-layer + canvas",
|
|
1997
|
+
);
|
|
1998
|
+
if (!xtermCanvas) {
|
|
1999
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2000
|
+
xtermCanvas = document.querySelector(
|
|
2001
|
+
"#terminal canvas.xterm-link-layer + canvas",
|
|
2002
|
+
);
|
|
2003
|
+
if (!xtermCanvas) {
|
|
2004
|
+
throw new Error(
|
|
2005
|
+
"Cannot find xterm canvas (canvas.xterm-link-layer + canvas)",
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
return { canvas, xtermCanvas };
|
|
2010
|
+
})();
|
|
2039
2011
|
|
|
2040
2012
|
return {
|
|
2041
2013
|
term,
|
|
2042
2014
|
startRecording: async () => {
|
|
2015
|
+
const { canvas, xtermCanvas } = await canvasPromise;
|
|
2016
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
2017
|
+
context.imageSmoothingEnabled = true;
|
|
2018
|
+
const headerHeight = 40;
|
|
2019
|
+
canvas.width = paddingLeft + xtermCanvas.width + paddingRight;
|
|
2020
|
+
canvas.height = headerHeight + xtermCanvas.height;
|
|
2021
|
+
{
|
|
2022
|
+
drawRectangle(context, {
|
|
2023
|
+
x: 0,
|
|
2024
|
+
y: 0,
|
|
2025
|
+
width: canvas.width,
|
|
2026
|
+
height: canvas.height,
|
|
2027
|
+
fill: "#282c34",
|
|
2028
|
+
stroke: "rgba(255,255,255,0.35)",
|
|
2029
|
+
strokeWidth: 10,
|
|
2030
|
+
radius: 8,
|
|
2031
|
+
});
|
|
2032
|
+
drawCircle(context, {
|
|
2033
|
+
x: 20,
|
|
2034
|
+
y: headerHeight / 2,
|
|
2035
|
+
radius: 6,
|
|
2036
|
+
fill: "#ff5f57",
|
|
2037
|
+
});
|
|
2038
|
+
drawCircle(context, {
|
|
2039
|
+
x: 40,
|
|
2040
|
+
y: headerHeight / 2,
|
|
2041
|
+
radius: 6,
|
|
2042
|
+
fill: "#febc2e",
|
|
2043
|
+
});
|
|
2044
|
+
drawCircle(context, {
|
|
2045
|
+
x: 60,
|
|
2046
|
+
y: headerHeight / 2,
|
|
2047
|
+
radius: 6,
|
|
2048
|
+
fill: "#28c840",
|
|
2049
|
+
});
|
|
2050
|
+
|
|
2051
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text
|
|
2052
|
+
const text = "Terminal";
|
|
2053
|
+
context.font = `${fontSize}px ${fontFamily}`;
|
|
2054
|
+
context.textBaseline = "middle";
|
|
2055
|
+
context.textAlign = "center";
|
|
2056
|
+
// const textSize = context.measureText(text);
|
|
2057
|
+
context.fillStyle = "#abb2bf";
|
|
2058
|
+
context.fillText(text, canvas.width / 2, headerHeight / 2);
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2043
2061
|
const records = {};
|
|
2044
2062
|
let writePromise = Promise.resolve();
|
|
2045
2063
|
const frameCallbackSet = new Set();
|