@jsenv/terminal-recorder 1.3.6 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/terminal-recorder",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
4
  "description": "Record terminal output as .svg, .gif, .webm, .mp4",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,9 +17,16 @@
17
17
  },
18
18
  "type": "module",
19
19
  "exports": {
20
- ".": "./src/main.js",
20
+ ".": {
21
+ "node": "./src/main.js",
22
+ "browser": {
23
+ "development": "./src/main_browser.js",
24
+ "default": "./dist/terminal_recorder_browser.js"
25
+ }
26
+ },
21
27
  "./*": "./*"
22
28
  },
29
+ "main": "./dist/terminal_recorder_browser.js",
23
30
  "files": [
24
31
  "/dist/",
25
32
  "/src/"
@@ -0,0 +1 @@
1
+ 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 `;