terminfo.dev 1.6.2 → 2.0.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": "terminfo.dev",
3
- "version": "1.6.2",
3
+ "version": "2.0.0",
4
4
  "description": "Test your terminal's feature support and contribute to terminfo.dev",
5
5
  "keywords": [
6
6
  "ansi",
package/src/detect.ts CHANGED
@@ -56,7 +56,10 @@ export function detectTerminal(): TerminalInfo {
56
56
  const bundleId = process.env.__CFBundleIdentifier
57
57
  if (bundleId && os === "macos") {
58
58
  for (const [termName, bid] of Object.entries(BUNDLE_IDS)) {
59
- if (bundleId === bid) { name = termName; break }
59
+ if (bundleId === bid) {
60
+ name = termName
61
+ break
62
+ }
60
63
  }
61
64
  // If bundle ID didn't match known terminals, use it as-is
62
65
  if (name === "unknown" && bundleId) {
@@ -117,15 +120,18 @@ function getMacOSAppVersion(terminalName: string): string {
117
120
  const appPath = execFileSync("mdfind", [`kMDItemCFBundleIdentifier == '${bundleId}'`], {
118
121
  encoding: "utf-8",
119
122
  timeout: 3000,
120
- }).trim().split("\n")[0]
123
+ })
124
+ .trim()
125
+ .split("\n")[0]
121
126
 
122
127
  if (!appPath) return ""
123
128
 
124
129
  // Read version from Info.plist
125
- const version = execFileSync("/usr/libexec/PlistBuddy", [
126
- "-c", "Print :CFBundleShortVersionString",
127
- `${appPath}/Contents/Info.plist`,
128
- ], { encoding: "utf-8", timeout: 2000 }).trim()
130
+ const version = execFileSync(
131
+ "/usr/libexec/PlistBuddy",
132
+ ["-c", "Print :CFBundleShortVersionString", `${appPath}/Contents/Info.plist`],
133
+ { encoding: "utf-8", timeout: 2000 },
134
+ ).trim()
129
135
 
130
136
  return version
131
137
  } catch {
@@ -135,10 +141,14 @@ function getMacOSAppVersion(terminalName: string): string {
135
141
 
136
142
  function detectOS(): string {
137
143
  switch (process.platform) {
138
- case "darwin": return "macos"
139
- case "linux": return "linux"
140
- case "win32": return "windows"
141
- default: return process.platform
144
+ case "darwin":
145
+ return "macos"
146
+ case "linux":
147
+ return "linux"
148
+ case "win32":
149
+ return "windows"
150
+ default:
151
+ return process.platform
142
152
  }
143
153
  }
144
154
 
package/src/index.ts CHANGED
@@ -61,13 +61,11 @@ async function runProbes(): Promise<ProbeResults> {
61
61
  const responses: Record<string, string> = {}
62
62
  let passed = 0
63
63
 
64
- await withRawMode(async () => {
65
- // Use alt screen to contain all probe output
66
- process.stdout.write("\x1b[?1049h")
64
+ // Save cursor + scroll position, run probes, restore
65
+ process.stdout.write("\x1b7") // save cursor (DECSC)
67
66
 
67
+ await withRawMode(async () => {
68
68
  for (const probe of ALL_PROBES) {
69
- // Reset SGR + clear screen before each probe
70
- process.stdout.write("\x1b[0m\x1b[2J\x1b[H")
71
69
  try {
72
70
  const result = await probe.run()
73
71
  results[probe.id] = result.pass
@@ -78,25 +76,19 @@ async function runProbes(): Promise<ProbeResults> {
78
76
  results[probe.id] = false
79
77
  notes[probe.id] = `error: ${err instanceof Error ? err.message : String(err)}`
80
78
  }
81
- // Reset SGR after each probe to prevent style leaking
82
- process.stdout.write("\x1b[0m")
83
79
  }
84
-
85
- // Clean up alt screen completely before switching back
86
- process.stdout.write("\x1b[0m") // reset SGR
87
- process.stdout.write("\x1b[?7h") // re-enable auto-wrap (DECAWM)
88
- process.stdout.write("\x1b[?25h") // show cursor (DECTCEM)
89
- process.stdout.write("\x1b[r") // reset scroll region (DECSTBM)
90
- await drainStdin(500)
91
- process.stdout.write("\x1b[?1049l") // exit alt screen
80
+ await drainStdin(1000)
92
81
  })
93
82
 
83
+ // Restore terminal state completely
84
+ process.stdout.write("\x1b8") // restore cursor (DECRC)
85
+ process.stdout.write("\x1bc") // RIS — full terminal reset
86
+ // RIS moves cursor to 1,1 — that's fine, we're about to print results
87
+
94
88
  return { terminal, results, notes, responses, passed, total: ALL_PROBES.length }
95
89
  }
96
90
 
97
91
  function printHeader(terminal: ReturnType<typeof detectTerminal>) {
98
- // Reset ALL SGR on main screen — probes may have left underline/style active
99
- process.stdout.write("\x1b[0m\x1b[24m\x1b[4:0m\x1b[59m\x1b[55m\x1b[29m\x1b[28m\x1b[27m\x1b[25m\x1b[23m\x1b[22m")
100
92
  const siteLink = link("https://terminfo.dev", "terminfo.dev")
101
93
  console.log(`\x1b[1m${siteLink}\x1b[0m — can your terminal do that?\n`)
102
94
  console.log(` Terminal: \x1b[1m${terminal.name}\x1b[0m${terminal.version ? ` ${terminal.version}` : ""}`)
@@ -223,7 +215,7 @@ program
223
215
  notes: data.notes,
224
216
  responses: data.responses,
225
217
  generated: new Date().toISOString(),
226
- cliVersion: "1.6.0",
218
+ cliVersion: "2.0.0",
227
219
  probeCount: ALL_PROBES.length,
228
220
  })
229
221
  if (url) {