tuiweather 0.3.4 → 0.3.7

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/README.md CHANGED
@@ -16,7 +16,9 @@ Keyboard-driven terminal weather app: Dark Sky-style rain nowcasting, hourly and
16
16
 
17
17
  ## Install
18
18
 
19
- Requires Node.js >= 26.4.0 to run. Install globally with npm:
19
+ Requires Node.js to run: the package declares `engines.node >= 20`, and the command-line
20
+ paths (`--version`, `--help`, `--one-line`) work on any such Node; the interactive TUI
21
+ needs Node >= 26.4.0, enforced at runtime by the launcher. Install globally with npm:
20
22
 
21
23
  ```sh
22
24
  npm install --global tuiweather
package/bin/tuiweather.js CHANGED
@@ -1,2 +1,39 @@
1
- #!/usr/bin/env -S node --experimental-ffi --disable-warning=ExperimentalWarning
2
- import "../dist/index.js";
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const FFI_FLAGS = ["--experimental-ffi", "--disable-warning=ExperimentalWarning"];
6
+ const FFI_MIN_NODE = [26, 4, 0];
7
+
8
+ function nodeAtLeast(min) {
9
+ const parts = process.versions.node.split(".").map(Number);
10
+ for (let i = 0; i < min.length; i++) {
11
+ const have = parts[i] ?? 0;
12
+ if (have !== min[i]) return have > min[i];
13
+ }
14
+ return true;
15
+ }
16
+
17
+ const underBun = Boolean(process.versions.bun);
18
+ const hasFlags = FFI_FLAGS.every((flag) => process.execArgv.includes(flag));
19
+
20
+ if (underBun || hasFlags || !nodeAtLeast(FFI_MIN_NODE)) {
21
+ await import("../dist/index.js");
22
+ } else {
23
+ const script = fileURLToPath(new URL("../dist/index.js", import.meta.url));
24
+ const child = spawnSync(process.execPath, [...FFI_FLAGS, script, ...process.argv.slice(2)], {
25
+ stdio: "inherit",
26
+ });
27
+ if (child.error) {
28
+ console.error(child.error.message);
29
+ process.exitCode = 1;
30
+ } else if (child.signal) {
31
+ try {
32
+ process.kill(process.pid, child.signal);
33
+ } catch {
34
+ process.exitCode = child.status ?? 1;
35
+ }
36
+ } else {
37
+ process.exitCode = child.status ?? 1;
38
+ }
39
+ }
package/dist/index.js CHANGED
@@ -94633,7 +94633,7 @@ async function searchLocations(query, count = 8) {
94633
94633
  // package.json
94634
94634
  var package_default2 = {
94635
94635
  name: "tuiweather",
94636
- version: "0.3.4",
94636
+ version: "0.3.7",
94637
94637
  description: "Keyboard-driven terminal weather app powered by Open-Meteo",
94638
94638
  license: "MIT",
94639
94639
  type: "module",
@@ -94662,7 +94662,7 @@ var package_default2 = {
94662
94662
  access: "public"
94663
94663
  },
94664
94664
  engines: {
94665
- node: ">=26.4.0"
94665
+ node: ">=20"
94666
94666
  },
94667
94667
  scripts: {
94668
94668
  dev: "bun run src/index.tsx",
@@ -95627,10 +95627,21 @@ function parseAqEnvelope(raw) {
95627
95627
  return null;
95628
95628
  return result.data;
95629
95629
  }
95630
+ function cacheRoot(platform, env2) {
95631
+ const xdg = env2.XDG_CACHE_HOME?.trim();
95632
+ if (xdg)
95633
+ return xdg;
95634
+ if (platform === "win32") {
95635
+ const localAppData = env2.LOCALAPPDATA?.trim();
95636
+ if (localAppData)
95637
+ return localAppData;
95638
+ }
95639
+ return join7(homedir2(), ".cache");
95640
+ }
95630
95641
 
95631
95642
  class FsCacheIo {
95632
95643
  async baseDir() {
95633
- const root = process.env.XDG_CACHE_HOME?.trim() || join7(homedir2(), ".cache");
95644
+ const root = cacheRoot(process.platform, process.env);
95634
95645
  const dir = join7(root, "tuiweather");
95635
95646
  await mkdir3(dir, { recursive: true, mode: 448 });
95636
95647
  return dir;
@@ -96606,19 +96617,21 @@ function FirstRun({ store, width, height, quit }) {
96606
96617
  // src/theme/detect.ts
96607
96618
  var FALLBACK_APPEARANCE = { ink: "dark", background: null };
96608
96619
  async function detectTerminalAppearance(query, timeoutMs = 300) {
96620
+ let timer;
96609
96621
  try {
96610
96622
  const colors = await Promise.race([
96611
96623
  query.getPalette({ timeout: timeoutMs }),
96612
96624
  new Promise((_2, reject) => {
96613
- const timer = setTimeout(() => reject(new Error("palette query timed out")), timeoutMs);
96614
- if (typeof timer === "object" && "unref" in timer)
96615
- timer.unref();
96625
+ timer = setTimeout(() => reject(new Error("palette query timed out")), timeoutMs);
96616
96626
  })
96617
96627
  ]);
96618
96628
  const background = colors?.defaultBackground ?? null;
96619
96629
  return { ink: isDarkBackground(background) ? "dark" : "light", background };
96620
96630
  } catch {
96621
96631
  return FALLBACK_APPEARANCE;
96632
+ } finally {
96633
+ if (timer !== undefined)
96634
+ clearTimeout(timer);
96622
96635
  }
96623
96636
  }
96624
96637
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuiweather",
3
- "version": "0.3.4",
3
+ "version": "0.3.7",
4
4
  "description": "Keyboard-driven terminal weather app powered by Open-Meteo",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "engines": {
32
- "node": ">=26.4.0"
32
+ "node": ">=20"
33
33
  },
34
34
  "scripts": {
35
35
  "dev": "bun run src/index.tsx",