@linsxyx/kamusic 0.0.0-stage → 0.1.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.
Files changed (3) hide show
  1. package/README.md +25 -2
  2. package/bin/kamusic.js +115 -0
  3. package/package.json +41 -4
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @linsxyx/kamusic (KA Music CLI)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 最好用、最轻量的酷狗音乐概念版终端 TUI 播放器(NativeAOT 原生编译,跨 Windows / macOS / Linux 全平台)。
4
+
5
+ ## 安装与启动
6
+
7
+ ```bash
8
+ # 全局安装(推荐)
9
+ npm install -g @linsxyx/kamusic
10
+
11
+ # 启动播放器
12
+ kamusic
13
+ ```
14
+
15
+ 或者免安装直接运行:
16
+
17
+ ```bash
18
+ npx @linsxyx/kamusic
19
+ ```
20
+
21
+ ## 特性
22
+
23
+ - **多协议终端高清图片**:自动检测并支持 Kitty Graphics Protocol、iTerm2 (`OSC 1337`)、Sixel 与 UTF-8 半块字符(`▀`),终端内直接渲染登录二维码、专辑封面与歌单封面。
24
+ - **全功能音频播放与音效**:支持每日推荐、私人 FM、发现歌单、排行榜、搜索、我的歌单、KRC 逐字高亮歌词、频谱可视化、10 段均衡器与智能无缝过渡。
25
+ - **鼠标与键盘双交互**:支持键盘快捷键与终端鼠标点击/双击/滚轮交互。
26
+ - **独立安全会话**:与桌面端分离存储(`KgTestSession.json`),Windows 下采用系统 DPAPI 加密保护登录态。
package/bin/kamusic.js ADDED
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+
3
+ // kamusic CLI 启动入口:根据当前 OS 与 CPU 架构定位对应平台子包中的 NativeAOT 可执行文件并透传终端标准流与信号。
4
+
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+ const { spawn } = require("node:child_process");
8
+
9
+ const PLATFORM_PACKAGES = {
10
+ "win32-x64": {
11
+ pkg: "@linsxyx/kamusic-win32-x64",
12
+ dir: "kamusic-win32-x64",
13
+ bin: "KaMusic.Cli.exe",
14
+ },
15
+ "win32-arm64": {
16
+ pkg: "@linsxyx/kamusic-win32-arm64",
17
+ dir: "kamusic-win32-arm64",
18
+ bin: "KaMusic.Cli.exe",
19
+ },
20
+ "linux-x64": {
21
+ pkg: "@linsxyx/kamusic-linux-x64",
22
+ dir: "kamusic-linux-x64",
23
+ bin: "KaMusic.Cli",
24
+ },
25
+ "linux-arm64": {
26
+ pkg: "@linsxyx/kamusic-linux-arm64",
27
+ dir: "kamusic-linux-arm64",
28
+ bin: "KaMusic.Cli",
29
+ },
30
+ "darwin-arm64": {
31
+ pkg: "@linsxyx/kamusic-darwin-arm64",
32
+ dir: "kamusic-darwin-arm64",
33
+ bin: "KaMusic.Cli",
34
+ },
35
+ "darwin-x64": {
36
+ pkg: "@linsxyx/kamusic-darwin-x64",
37
+ dir: "kamusic-darwin-x64",
38
+ bin: "KaMusic.Cli",
39
+ },
40
+ };
41
+
42
+ // 解析当前平台对应的 KaMusic.Cli 原生二进制绝对路径(兼容 npm 全局安装、npx 与本地工作区目录)。
43
+ function resolveBinaryPath() {
44
+ const key = `${process.platform}-${process.arch}`;
45
+ const target = PLATFORM_PACKAGES[key];
46
+ if (!target) {
47
+ console.error(
48
+ `[kamusic] 当前平台暂不支持: ${key}(支持平台: ${Object.keys(PLATFORM_PACKAGES).join(", ")})`
49
+ );
50
+ process.exit(1);
51
+ }
52
+
53
+ const candidates = [];
54
+
55
+ try {
56
+ const pkgJsonPath = require.resolve(`${target.pkg}/package.json`);
57
+ candidates.push(path.join(path.dirname(pkgJsonPath), "vendor", target.bin));
58
+ } catch {
59
+ // fallback to workspace sibling directory
60
+ }
61
+
62
+ candidates.push(
63
+ path.resolve(__dirname, "..", "..", target.dir, "vendor", target.bin)
64
+ );
65
+
66
+ for (const candidate of candidates) {
67
+ if (fs.existsSync(candidate)) {
68
+ return candidate;
69
+ }
70
+ }
71
+
72
+ console.error(
73
+ `[kamusic] 未找到当前平台 (${key}) 的原生可执行文件,请确认可选依赖包 "${target.pkg}" 已安装(检查是否启用了 --no-optional)。`
74
+ );
75
+ process.exit(1);
76
+ }
77
+
78
+ const binPath = resolveBinaryPath();
79
+ if (process.platform !== "win32") {
80
+ try {
81
+ fs.chmodSync(binPath, 0o755);
82
+ } catch {
83
+ // ignore chmod errors on read-only mounts
84
+ }
85
+ }
86
+
87
+ const child = spawn(binPath, process.argv.slice(2), {
88
+ stdio: "inherit",
89
+ windowsHide: false,
90
+ });
91
+
92
+ for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
93
+ process.on(sig, () => {
94
+ if (!child.killed) {
95
+ try {
96
+ child.kill(sig);
97
+ } catch {
98
+ // ignore
99
+ }
100
+ }
101
+ });
102
+ }
103
+
104
+ child.on("error", (err) => {
105
+ console.error(`[kamusic] 启动失败: ${err.message}`);
106
+ process.exit(1);
107
+ });
108
+
109
+ child.on("exit", (code, signal) => {
110
+ if (signal) {
111
+ process.kill(process.pid, signal);
112
+ return;
113
+ }
114
+ process.exit(code ?? 0);
115
+ });
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@linsxyx/kamusic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "KA Music 终端 TUI 播放器(NativeAOT 跨平台命令行版,支持终端专辑封面、KRC 逐字歌词、频谱与酷狗账号登录)",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Linsxyx/KugouMusic.NET.git"
9
+ },
10
+ "homepage": "https://github.com/Linsxyx/KugouMusic.NET",
11
+ "bugs": {
12
+ "url": "https://github.com/Linsxyx/KugouMusic.NET/issues"
13
+ },
14
+ "keywords": [
15
+ "kamusic",
16
+ "kugou",
17
+ "music",
18
+ "player",
19
+ "tui",
20
+ "cli",
21
+ "terminal"
22
+ ],
23
+ "bin": {
24
+ "kamusic": "bin/kamusic.js"
25
+ },
26
+ "files": [
27
+ "bin/"
28
+ ],
29
+ "engines": {
30
+ "node": ">=16.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "optionalDependencies": {
36
+ "@linsxyx/kamusic-darwin-arm64": "0.1.0",
37
+ "@linsxyx/kamusic-darwin-x64": "0.1.0",
38
+ "@linsxyx/kamusic-linux-arm64": "0.1.0",
39
+ "@linsxyx/kamusic-linux-x64": "0.1.0",
40
+ "@linsxyx/kamusic-win32-arm64": "0.1.0",
41
+ "@linsxyx/kamusic-win32-x64": "0.1.0"
42
+ }
43
+ }