@vincentzyuapps/winload 0.1.7-rc.6

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 (4) hide show
  1. package/bin.js +28 -0
  2. package/index.js +59 -0
  3. package/package.json +43 -0
  4. package/readme.md +194 -0
package/bin.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * winload-rust-bin — CLI entry point
5
+ *
6
+ * 定位当前平台的预编译二进制并透传所有参数执行。
7
+ * 用户通过 `npx winload-rust-bin` 或全局安装后直接 `winload` 即可运行。
8
+ */
9
+
10
+ "use strict";
11
+
12
+ const { spawnSync } = require("child_process");
13
+ const { getBinaryPath } = require("./index.js");
14
+
15
+ const bin = getBinaryPath();
16
+
17
+ // Show implementation info for help & version flags
18
+ const args = process.argv.slice(2);
19
+ if (args.includes("--help") || args.includes("-h") || args.includes("--version") || args.includes("-V")) {
20
+ console.error("ℹ️ This is the Rust binary edition (installed from npm)\n");
21
+ }
22
+
23
+ const result = spawnSync(bin, args, {
24
+ stdio: "inherit",
25
+ windowsHide: false,
26
+ });
27
+
28
+ process.exit(result.status ?? 1);
package/index.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * winload-rust-bin — binary path resolver
3
+ *
4
+ * npm 安装时会根据 optionalDependencies 中各平台包的 os/cpu 字段,
5
+ * 仅下载与当前平台匹配的那一个。此模块负责定位该平台包中的二进制。
6
+ *
7
+ * 原理同 esbuild / @biomejs/biome / turbo 等项目。
8
+ */
9
+
10
+ "use strict";
11
+
12
+ const path = require("path");
13
+
14
+ /**
15
+ * 平台映射表
16
+ * key: `${process.platform}-${process.arch}`
17
+ * value: npm 平台包名
18
+ */
19
+ const PLATFORMS = {
20
+ "win32-x64": "winload-rust-bin-win32-x64",
21
+ "win32-arm64": "winload-rust-bin-win32-arm64",
22
+ "linux-x64": "winload-rust-bin-linux-x64",
23
+ "linux-arm64": "winload-rust-bin-linux-arm64",
24
+ "darwin-x64": "winload-rust-bin-darwin-x64",
25
+ "darwin-arm64": "winload-rust-bin-darwin-arm64",
26
+ };
27
+
28
+ /**
29
+ * 获取当前平台对应的 winload 二进制绝对路径
30
+ * @returns {string} 二进制路径
31
+ * @throws {Error} 不支持的平台 / 平台包未安装
32
+ */
33
+ function getBinaryPath() {
34
+ const key = `${process.platform}-${process.arch}`;
35
+ const pkg = PLATFORMS[key];
36
+
37
+ if (!pkg) {
38
+ const supported = Object.keys(PLATFORMS).join(", ");
39
+ throw new Error(
40
+ `winload: unsupported platform "${key}"\n` +
41
+ `Supported: ${supported}\n` +
42
+ `Download manually: https://github.com/VincentZyuApps/winload/releases`
43
+ );
44
+ }
45
+
46
+ try {
47
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
48
+ const ext = process.platform === "win32" ? ".exe" : "";
49
+ return path.join(pkgDir, "bin", `winload${ext}`);
50
+ } catch {
51
+ throw new Error(
52
+ `winload: platform package "${pkg}" not found\n` +
53
+ `Try reinstalling: npm install winload-rust-bin\n` +
54
+ `Or download manually: https://github.com/VincentZyuApps/winload/releases`
55
+ );
56
+ }
57
+ }
58
+
59
+ module.exports = { getBinaryPath, PLATFORMS };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vincentzyuapps/winload",
3
+ "version": "0.1.7-rc.6",
4
+ "description": "Network Load Monitor — nload-like TUI tool for Windows/Linux/macOS (prebuilt Rust binary)",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://gitee.com/vincent-zyu/winload"
9
+ },
10
+ "homepage": "https://github.com/VincentZyuApps/winload",
11
+ "author": "VincentZyu <1830540513zyu@gmail.com>",
12
+ "keywords": [
13
+ "network",
14
+ "monitor",
15
+ "nload",
16
+ "tui",
17
+ "bandwidth",
18
+ "traffic",
19
+ "cli",
20
+ "rust"
21
+ ],
22
+ "bin": {
23
+ "winload": "bin.js",
24
+ "win-nload": "bin.js"
25
+ },
26
+ "main": "index.js",
27
+ "files": [
28
+ "bin.js",
29
+ "index.js",
30
+ "readme.md"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "optionalDependencies": {
36
+ "@vincentzyuapps/winload-win32-x64": "0.1.7-rc.6",
37
+ "@vincentzyuapps/winload-win32-arm64": "0.1.7-rc.6",
38
+ "@vincentzyuapps/winload-linux-x64": "0.1.7-rc.6",
39
+ "@vincentzyuapps/winload-linux-arm64": "0.1.7-rc.6",
40
+ "@vincentzyuapps/winload-darwin-x64": "0.1.7-rc.6",
41
+ "@vincentzyuapps/winload-darwin-arm64": "0.1.7-rc.6"
42
+ }
43
+ }
package/readme.md ADDED
@@ -0,0 +1,194 @@
1
+ ![winload](https://socialify.git.ci/VincentZyu233/winload/image?custom_language=Rust&description=1&forks=1&issues=1&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F250448479%3Fs%3D200%26v%3D4&name=1&owner=1&pulls=1&stargazers=1&theme=Auto)
2
+
3
+ # Winload <img src="https://github.com/user-attachments/assets/62fec846-0442-47f6-bbba-78acdc8803ef" height="32px">
4
+
5
+ > A lightweight, real-time CLI tool for monitoring network bandwidth and traffic, inspired by Linux's nload.
6
+
7
+ > **[📖 English](readme.md)**
8
+ > **[📖 简体中文(大陆)](readme.zh-cn.md)**
9
+ > **[📖 繁體中文(台灣)](readme.zh-tw.md)**
10
+ > **[📖 日本語](readme.jp.md)**
11
+ > **[📖 한국어](readme.ko.md)**
12
+
13
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/VincentZyuApps/winload)
14
+ [![Gitee](https://img.shields.io/badge/Gitee-C71D23?style=for-the-badge&logo=gitee&logoColor=white)](https://gitee.com/vincent-zyu/winload)
15
+
16
+ [![Windows x64 | ARM64](https://img.shields.io/badge/Windows-x64_|_ARM64-0078D4?style=for-the-badge&logo=windows&logoColor=white)](https://github.com/VincentZyuApps/winload/releases)
17
+ [![Linux x64 | ARM64](https://img.shields.io/badge/Linux-x64_|_ARM64-FCC624?style=for-the-badge&logo=linux&logoColor=black)](https://github.com/VincentZyuApps/winload/releases)
18
+ [![macOS x64 | ARM64](https://img.shields.io/badge/macOS-x64_|_ARM64-000000?style=for-the-badge&logo=apple&logoColor=white)](https://github.com/VincentZyuApps/winload/releases)
19
+ [![Android x64 | ARM64](https://img.shields.io/badge/Android-x64_|_ARM64-3DDC84?style=for-the-badge&logo=android&logoColor=white)](https://github.com/VincentZyuApps/winload/releases)
20
+
21
+ [![PyPI](https://img.shields.io/badge/PyPI-3776AB?style=for-the-badge&logo=pypi&logoColor=white)](https://pypi.org/project/winload/)
22
+ [![npm](https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@vincentzyuapps/winload)
23
+ [![Crates.io](https://img.shields.io/badge/Crates.io-000000?style=for-the-badge&logo=rust&logoColor=white)](https://crates.io/crates/winload)
24
+
25
+ [![Scoop](https://img.shields.io/badge/Scoop-7B4AE2?style=for-the-badge&logo=scoop&logoColor=white)](https://scoop.sh/#/apps?q=%22https%3A%2F%2Fgithub.com%2FVincentZyuApps%2Fscoop-bucket%22&o=false)
26
+ [![AUR](https://img.shields.io/badge/AUR-1793D1?style=for-the-badge&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/winload-rust-bin)
27
+ [![APT](https://img.shields.io/badge/APT-E95420?style=for-the-badge&logo=debian&logoColor=white)](https://github.com/VincentZyuApps/winload/releases)
28
+ [![RPM](https://img.shields.io/badge/RPM-CB1626?style=for-the-badge&logo=redhat&logoColor=white)](https://github.com/VincentZyuApps/winload/releases)
29
+
30
+ > **[📖 Build Docs](.github/workflows/build.md)**
31
+
32
+ ## 🚀 Introduction
33
+ Winload brings an intuitive, visual network monitor to the modern terminal. It started as a Windows-focused tool to fill the nload gap, and now targets Linux and macOS as well.
34
+
35
+ ## 🙏 Acknowledgements
36
+ Winload is inspired by the classic nload project by Roland Riegel. Many thanks for the original idea and experience.
37
+ https://github.com/rolandriegel/nload
38
+
39
+ ## ✨ Key Features
40
+ - **Dual implementations**
41
+ - **Rust edition**: fast, memory-safe, single static binary—great for everyday monitoring.
42
+ - **Python edition**: easy to hack and extend for prototyping or integrations.
43
+ - **Cross-platform**: Windows, Linux, and macOS (x64 & ARM64).
44
+ - **Real-time visualization**: live incoming/outgoing graphs and throughput stats.
45
+ - **Minimal UI**: clean TUI that mirrors nload's ergonomics.
46
+
47
+ ## 📥 Python Edition Installation
48
+ > 💡 **Implementation Note**: Only PyPI and GitHub/Gitee provide Python edition.
49
+ > Only Cargo provides Rust source code for local compilation.
50
+ > All other package managers (Scoop, AUR, npm, APT, RPM) and GitHub Releases distribute **Rust binaries only**.
51
+ ### Python (pip)
52
+ ```bash
53
+ pip install winload
54
+ # recommend use uv:
55
+ # https://docs.astral.sh/uv/getting-started/installation/
56
+ # https://gitee.com/wangnov/uv-custom/releases
57
+ uv venv
58
+ uv pip install winload
59
+ uv run winload
60
+ uv run python -c "import shutil; print(shutil.which('winload'))"
61
+ ```
62
+
63
+ ## 📥 Rust Edition Installation (recommended)
64
+ ### npm (cross-platform)
65
+ ```bash
66
+ npm install -g @vincentzyuapps/winload
67
+ npm list -g @vincentzyuapps/winload
68
+ # on Windows, use win-nload to avoid conflict with System32\winload.exe
69
+ # on Linux/macOS, both winload and win-nload work
70
+ # or use npx directly
71
+ npx @vincentzyuapps/winload
72
+ ```
73
+ > ⚠️ The old package `winload-rust-bin` has been deprecated. Please use `@vincentzyuapps/winload` instead. The scoped package name is required for [GitHub Packages](https://github.com/features/packages) compatibility.
74
+
75
+ > Includes 6 precompiled binaries for x86_64 & ARM64 across Windows, Linux, and macOS.
76
+
77
+ ### Cargo (Build from source)
78
+ ```bash
79
+ cargo install winload
80
+ cargo install --list
81
+ ```
82
+ ### Windows (Scoop)
83
+ ```powershell
84
+ scoop bucket add vincentzyu https://github.com/VincentZyuApps/scoop-bucket
85
+ scoop install winload
86
+ # execute bin file
87
+ win-nload
88
+ Get-Command win-nload # Powershell
89
+ where win-nload # CMD
90
+ ```
91
+
92
+ ### Arch Linux (AUR):
93
+ ```bash
94
+ paru -S winload-rust-bin
95
+ which winload
96
+ ```
97
+
98
+ ### Linux (one-liner)
99
+ > Supports Debian/Ubuntu and derivatives — Linux Mint, Pop!_OS, Deepin, UOS, etc. (apt)
100
+
101
+ > Supports Fedora/RHEL and derivatives — Rocky Linux, AlmaLinux, CentOS Stream, etc. (dnf)
102
+ ```bash
103
+ curl -fsSL https://raw.githubusercontent.com/VincentZyuApps/winload/main/docs/install_scripts/install.sh | bash
104
+ which winload
105
+ ```
106
+ > 📄 [View install script source](https://github.com/VincentZyuApps/winload/blob/main/docs/install_scripts/install.sh)
107
+
108
+ <details>
109
+ <summary>Manual install</summary>
110
+
111
+ **DEB (Debian/Ubuntu):**
112
+ ```bash
113
+ # Download the latest .deb from GitHub Releases
114
+ sudo dpkg -i ./winload_*_amd64.deb
115
+ # or use apt (auto-resolves dependencies)
116
+ sudo apt install ./winload_*_amd64.deb
117
+ which winload
118
+ ```
119
+
120
+ **RPM (Fedora/RHEL):**
121
+ ```bash
122
+ sudo dnf install ./winload-*-1.x86_64.rpm
123
+ which winload
124
+ ```
125
+
126
+ **Or download binaries directly from [GitHub Releases](https://github.com/VincentZyuApps/winload/releases).**
127
+
128
+ </details>
129
+
130
+ ## ⌨️ Usage
131
+
132
+ ```bash
133
+ winload # Monitor all active network interfaces
134
+ winload -t 200 # Set refresh interval to 200ms
135
+ winload -d "Wi-Fi" # Start with a specific device
136
+ winload -e # Enable emoji decorations 🎉
137
+ winload --npcap # Capture 127.0.0.1 loopback traffic (Windows, requires Npcap)
138
+ ```
139
+
140
+ ### Options
141
+
142
+ | Flag | Description | Default |
143
+ |------|-------------|---------|
144
+ | `-t`, `--interval <MS>` | Refresh interval in milliseconds | `500` |
145
+ | `-a`, `--average <SEC>` | Average calculation window in seconds | `300` |
146
+ | `-d`, `--device <NAME>` | Default device name (partial match) | — |
147
+ | `-e`, `--emoji` | Enable emoji decorations in TUI 🎉 | off |
148
+ | `-U`, `--unicode` | Use Unicode block characters for graph (█▓░·) | off |
149
+ | `-u`, `--unit <UNIT>` | Display unit: `bit` or `byte` | `bit` |
150
+ | `-b`, `--bar-style <STYLE>` | Bar style: `fill`, `color`, or `plain` | `fill` |
151
+ | `--in-color <HEX>` | Incoming graph color, hex RGB (e.g. `0x00d7ff`) | cyan |
152
+ | `--out-color <HEX>` | Outgoing graph color, hex RGB (e.g. `0xffaf00`) | gold |
153
+ | `-m`, `--max <VALUE>` | Fixed Y-axis max (e.g. `10M`, `1G`, `500K`) | auto |
154
+ | `-n`, `--no-graph` | Hide graph, show stats only | off |
155
+ | `--hide-separator` | Hide the separator line (row of equals signs) | off |
156
+ | `--no-color` | Disable all TUI colors (monochrome mode) | off |
157
+ | `--npcap` | **[Windows Rust Only]** Capture loopback traffic via Npcap (recommended) | off |
158
+ | `--debug-info` | **[Rust Only]** Print network interface debug info and exit | — |
159
+ | `-h`, `--help` | Print help (`--help --emoji` for emoji version!) | — |
160
+ | `-V`, `--version` | **[Rust Only]** Print version | — |
161
+
162
+ ### Keyboard Shortcuts
163
+
164
+ | Key | Action |
165
+ |-----|--------|
166
+ | `←` / `→` or `↑` / `↓` | Switch network device |
167
+ | `=` | Toggle separator line visibility |
168
+ | `c` | Toggle color on/off |
169
+ | `q` / `Esc` | Quit |
170
+
171
+ ## 🪟 Windows Loopback (127.0.0.1)
172
+
173
+ Windows cannot report loopback traffic through standard APIs — this is a [functional deficiency in Windows' network stack](docs/win_loopback.md).
174
+
175
+ **To capture loopback traffic on Windows**, use the `--npcap` flag:
176
+
177
+ ```bash
178
+ winload --npcap
179
+ ```
180
+
181
+ This requires [Npcap](https://npcap.com/#download) installed with "Support loopback traffic capture" enabled during setup.
182
+
183
+ > I previously tried polling Windows' own `GetIfEntry` API directly, but the counters are always 0 for loopback — there is simply no NDIS driver behind the loopback pseudo-interface to count anything. That code path has been removed.
184
+
185
+ > 📖 For a deep dive into why Windows loopback is broken, see [docs/win_loopback.md](docs/win_loopback.md)
186
+
187
+ On Linux and macOS, loopback traffic works out of the box — no extra flags needed.
188
+
189
+ ## 🖼️ Previews
190
+ #### Python Edition Preview
191
+ ![docs/preview-py.png](docs/preview-py.png)
192
+
193
+ #### Rust Edition Preview
194
+ ![docs/preview-rust.png](docs/preview-rust.png)