kittyhtml 0.3.1 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/cli.js +14 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kittyhtml",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Render HTML to an image and display it inline in Kitty/iTerm2-capable terminals. No browser — Rust + Blitz layout, headless CPU rasterization.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,9 +25,9 @@
25
25
  "node": ">=20"
26
26
  },
27
27
  "optionalDependencies": {
28
- "kittyhtml-darwin-arm64": "0.3.1",
29
- "kittyhtml-darwin-x64": "0.3.1",
30
- "kittyhtml-linux-x64-gnu": "0.3.1"
28
+ "kittyhtml-darwin-arm64": "0.3.2",
29
+ "kittyhtml-darwin-x64": "0.3.2",
30
+ "kittyhtml-linux-x64-gnu": "0.3.2"
31
31
  },
32
32
  "scripts": {
33
33
  "demo": "node src/cli.js --demo",
package/src/cli.js CHANGED
@@ -16,7 +16,8 @@ OPTIONS
16
16
  --width N Viewport width in CSS px (default: terminal width when
17
17
  rendered to a TTY, else 1200).
18
18
  --height N Fixed canvas height; omit to auto-fit content.
19
- --scale N Pixel ratio for crisper output (default 1; try 2).
19
+ --scale N Pixel ratio for crisper output (default: 2 when piping
20
+ to a graphics-capable terminal, 1 when writing to file).
20
21
  --background CSS Fill canvas background before painting (e.g. "#fff").
21
22
  --format FMT Output protocol: auto | kitty | iterm2 (default auto).
22
23
  --out, -o PATH Write PNG to PATH instead of stdout. ("-" = stdout PNG)
@@ -46,7 +47,8 @@ function parseArgs(argv) {
46
47
  const opts = {
47
48
  width: defaultWidth(),
48
49
  height: null,
49
- scale: 1,
50
+ // null sentinel: filled in after arg parse based on output destination.
51
+ scale: null,
50
52
  background: null,
51
53
  format: 'auto',
52
54
  out: null,
@@ -86,6 +88,16 @@ function parseArgs(argv) {
86
88
  process.exit(2);
87
89
  }
88
90
  if (positional[0]) opts.file = positional[0];
91
+
92
+ if (opts.scale == null) {
93
+ // Going to a graphics-capable terminal → assume HiDPI (every modern
94
+ // mac and most linux laptops). The terminal will downscale the larger
95
+ // PNG to fill the same on-screen area, giving retina-sharp text. File
96
+ // output stays at 1:1 since the user knows they want the literal pixel
97
+ // count they asked for.
98
+ opts.scale = opts.out == null && process.stdout.isTTY ? 2 : 1;
99
+ }
100
+
89
101
  return opts;
90
102
  }
91
103