@jsenv/terminal-recorder 1.3.7 → 1.4.1

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.
@@ -1204,14 +1204,17 @@ const createXmlGenerator = ({
1204
1204
 
1205
1205
  for (const attributeName of attributeNames) {
1206
1206
  let attributeValue = node.attributes[attributeName];
1207
+ if (attributeValue === undefined) {
1208
+ continue;
1209
+ }
1207
1210
  if (typeof attributeValue === "number") {
1208
1211
  attributeValue = round(attributeValue);
1209
1212
  }
1210
1213
  if (attributeName === "viewBox") {
1211
1214
  attributeValue = attributeValue
1212
- .split(",")
1215
+ .split(" ")
1213
1216
  .map((v) => round(parseFloat(v.trim())))
1214
- .join(", ");
1217
+ .join(" ");
1215
1218
  }
1216
1219
  attributesSingleLine += ` ${attributeName}="${attributeValue}"`;
1217
1220
  attributesMultiLine += `\n `;
@@ -1363,6 +1366,7 @@ const renderTerminalSvg = (
1363
1366
  height,
1364
1367
  maxWidth,
1365
1368
  maxHeight,
1369
+ preserveAspectRatio, // "xMidYMid slice",
1366
1370
 
1367
1371
  head = true,
1368
1372
  } = {},
@@ -1416,8 +1420,9 @@ const renderTerminalSvg = (
1416
1420
  "xmlns": "http://www.w3.org/2000/svg",
1417
1421
  "font-family": font.family,
1418
1422
  "font-size": font.size,
1419
- "width": computedWidth,
1420
- "height": computedHeight,
1423
+ "width": "100%",
1424
+ "viewBox": `0 0 ${computedWidth} ${computedHeight}`,
1425
+ preserveAspectRatio,
1421
1426
  "background-color": backgroundColor,
1422
1427
  });
1423
1428
 
@@ -1607,4 +1612,4 @@ const leadingWhitespaceWidth = (text) => {
1607
1612
  return leadingSpace[0].length;
1608
1613
  };
1609
1614
 
1610
- export { renderTerminalSvg };
1615
+ export { parseAnsi, renderTerminalSvg };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/terminal-recorder",
3
- "version": "1.3.7",
3
+ "version": "1.4.1",
4
4
  "description": "Record terminal output as .svg, .gif, .webm, .mp4",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +1,2 @@
1
+ export { parseAnsi } from "./svg/parse_ansi.js";
1
2
  export { renderTerminalSvg } from "./svg/render_terminal_svg.js";
@@ -63,6 +63,7 @@ export const renderTerminalSvg = (
63
63
  height,
64
64
  maxWidth,
65
65
  maxHeight,
66
+ preserveAspectRatio, // "xMidYMid slice",
66
67
 
67
68
  head = true,
68
69
  } = {},
@@ -116,8 +117,9 @@ export const renderTerminalSvg = (
116
117
  "xmlns": "http://www.w3.org/2000/svg",
117
118
  "font-family": font.family,
118
119
  "font-size": font.size,
119
- "width": computedWidth,
120
- "height": computedHeight,
120
+ "width": "100%",
121
+ "viewBox": `0 0 ${computedWidth} ${computedHeight}`,
122
+ preserveAspectRatio,
121
123
  "background-color": backgroundColor,
122
124
  });
123
125
 
@@ -57,14 +57,17 @@ export const createXmlGenerator = ({
57
57
 
58
58
  for (const attributeName of attributeNames) {
59
59
  let attributeValue = node.attributes[attributeName];
60
+ if (attributeValue === undefined) {
61
+ continue;
62
+ }
60
63
  if (typeof attributeValue === "number") {
61
64
  attributeValue = round(attributeValue);
62
65
  }
63
66
  if (attributeName === "viewBox") {
64
67
  attributeValue = attributeValue
65
- .split(",")
68
+ .split(" ")
66
69
  .map((v) => round(parseFloat(v.trim())))
67
- .join(", ");
70
+ .join(" ");
68
71
  }
69
72
  attributesSingleLine += ` ${attributeName}="${attributeValue}"`;
70
73
  attributesMultiLine += `\n `;