nekostream 2026.2.11 → 2026.3.1
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/LICENSE +21 -0
- package/dist/index.js +14 -0
- package/dist/logger.js +26 -8
- package/dist/prompts-wrapper.js +11 -10
- package/dist/storage.js +1 -0
- package/dist/ui.js +3 -9
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NekoTech LLC.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ const player_1 = require("./player");
|
|
|
47
47
|
const ui_1 = require("./ui");
|
|
48
48
|
const storage_1 = require("./storage");
|
|
49
49
|
const discord_1 = require("./discord");
|
|
50
|
+
const logger_1 = require("./logger");
|
|
50
51
|
const auth_service_1 = require("./scrapers/auth-service");
|
|
51
52
|
const NPM_PACKAGE_NAME = 'nekostream';
|
|
52
53
|
async function sleep(ms) {
|
|
@@ -77,11 +78,13 @@ async function showSettingsMenu() {
|
|
|
77
78
|
{ title: `Chất lượng mặc định: ${chalk_1.default.green(settings.defaultQuality)}`, value: 'quality' },
|
|
78
79
|
{ title: `Tự phát tập tiếp theo: ${formatToggle(settings.autoPlayNext)}`, value: 'autoplay' },
|
|
79
80
|
{ title: `Discord RPC: ${formatToggle(settings.discordRpcEnabled)}`, value: 'discord' },
|
|
81
|
+
{ title: `Debug mode: ${formatToggle(settings.debugMode || settings.developerMode)}`, value: 'debug' },
|
|
80
82
|
{ title: 'Cấu hình domain provider', value: 'domains' },
|
|
81
83
|
{ separator: 'TRỞ VỀ' },
|
|
82
84
|
{ title: chalk_1.default.gray('Quay lại Home'), value: 'back' }
|
|
83
85
|
]
|
|
84
86
|
});
|
|
87
|
+
(0, logger_1.debugTrace)('settings action selected', action);
|
|
85
88
|
if (!action || action === 'back')
|
|
86
89
|
break;
|
|
87
90
|
if (action === 'provider') {
|
|
@@ -112,6 +115,15 @@ async function showSettingsMenu() {
|
|
|
112
115
|
(0, storage_1.saveSettings)({ discordRpcEnabled: nextVal });
|
|
113
116
|
(0, discord_1.toggleDiscordPresence)(nextVal);
|
|
114
117
|
}
|
|
118
|
+
if (action === 'debug') {
|
|
119
|
+
const nextVal = !(settings.debugMode || settings.developerMode);
|
|
120
|
+
(0, storage_1.saveSettings)({ debugMode: nextVal, developerMode: nextVal });
|
|
121
|
+
(0, logger_1.debugLog)('debug mode changed', nextVal ? 'enabled' : 'disabled');
|
|
122
|
+
(0, ui_1.printSuccess)(nextVal
|
|
123
|
+
? 'Debug mode đã bật: log debug/trace sẽ hiển thị và CLI sẽ không tự dọn màn hình.'
|
|
124
|
+
: 'Debug mode đã tắt: CLI sẽ dọn màn hình như bình thường.');
|
|
125
|
+
await sleep(1000);
|
|
126
|
+
}
|
|
115
127
|
if (action === 'domains') {
|
|
116
128
|
while (true) {
|
|
117
129
|
(0, ui_1.clearScreen)();
|
|
@@ -608,6 +620,7 @@ async function checkUpdate() {
|
|
|
608
620
|
async function main() {
|
|
609
621
|
await checkUpdate();
|
|
610
622
|
await (0, discord_1.initDiscord)();
|
|
623
|
+
(0, logger_1.debugLog)('NekoStream CLI started');
|
|
611
624
|
let settings = (0, storage_1.loadSettings)();
|
|
612
625
|
let currentProviderName = settings.defaultProvider;
|
|
613
626
|
while (true) {
|
|
@@ -622,6 +635,7 @@ async function main() {
|
|
|
622
635
|
{ label: 'Tài khoản', value: usernameDisplay },
|
|
623
636
|
{ label: 'Provider', value: chalk_1.default.green(currentProviderName) }
|
|
624
637
|
]);
|
|
638
|
+
(0, logger_1.debugTrace)('home rendered', { provider: currentProviderName, loggedIn: authStatus.loggedIn });
|
|
625
639
|
const dynamicChoices = [
|
|
626
640
|
{ separator: 'KHÁM PHÁ' },
|
|
627
641
|
{ title: 'Tìm anime', value: 'search', description: 'Tìm theo tên phim' },
|
package/dist/logger.js
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDebugModeEnabled = isDebugModeEnabled;
|
|
3
4
|
exports.isDeveloperLoggingEnabled = isDeveloperLoggingEnabled;
|
|
4
5
|
exports.debugLog = debugLog;
|
|
5
6
|
exports.debugWarn = debugWarn;
|
|
6
7
|
exports.debugError = debugError;
|
|
7
|
-
|
|
8
|
+
exports.debugTrace = debugTrace;
|
|
9
|
+
const storage_1 = require("./storage");
|
|
10
|
+
function isDebugModeEnabled() {
|
|
8
11
|
if (process.env.NEKOSTREAM_DEBUG === '1')
|
|
9
12
|
return true;
|
|
10
|
-
|
|
13
|
+
if (process.env.NEKOSTREAM_PRESERVE_LOGS === '1')
|
|
14
|
+
return true;
|
|
15
|
+
try {
|
|
16
|
+
const settings = (0, storage_1.loadSettings)();
|
|
17
|
+
return Boolean(settings.debugMode || settings.developerMode);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isDeveloperLoggingEnabled() {
|
|
24
|
+
return isDebugModeEnabled();
|
|
11
25
|
}
|
|
12
26
|
function debugLog(...args) {
|
|
13
|
-
if (
|
|
14
|
-
console.log(...args);
|
|
27
|
+
if (isDebugModeEnabled())
|
|
28
|
+
console.log('[debug]', ...args);
|
|
15
29
|
}
|
|
16
30
|
function debugWarn(...args) {
|
|
17
|
-
if (
|
|
18
|
-
console.warn(...args);
|
|
31
|
+
if (isDebugModeEnabled())
|
|
32
|
+
console.warn('[debug]', ...args);
|
|
19
33
|
}
|
|
20
34
|
function debugError(...args) {
|
|
21
|
-
if (
|
|
22
|
-
console.error(...args);
|
|
35
|
+
if (isDebugModeEnabled())
|
|
36
|
+
console.error('[debug]', ...args);
|
|
37
|
+
}
|
|
38
|
+
function debugTrace(...args) {
|
|
39
|
+
if (isDebugModeEnabled())
|
|
40
|
+
console.trace('[debug:trace]', ...args);
|
|
23
41
|
}
|
package/dist/prompts-wrapper.js
CHANGED
|
@@ -11,6 +11,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
11
11
|
const readline_1 = __importDefault(require("readline"));
|
|
12
12
|
const theme_1 = require("./cli/theme");
|
|
13
13
|
const text_1 = require("./cli/text");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
14
15
|
function shouldOfferBack(message) {
|
|
15
16
|
return /esc|back|quay lại|thoát/i.test(message);
|
|
16
17
|
}
|
|
@@ -32,6 +33,14 @@ function formatSeparator(label, leadingBreak = true) {
|
|
|
32
33
|
function promptMessage(message) {
|
|
33
34
|
return `${theme_1.uiText.title(message)} ${theme_1.uiText.subtle('(Esc quay lại)')}`;
|
|
34
35
|
}
|
|
36
|
+
function clearPromptLines(renderedLines) {
|
|
37
|
+
if (renderedLines <= 0 || (0, logger_1.isDebugModeEnabled)())
|
|
38
|
+
return false;
|
|
39
|
+
readline_1.default.moveCursor(process.stdout, 0, -renderedLines);
|
|
40
|
+
readline_1.default.cursorTo(process.stdout, 0);
|
|
41
|
+
readline_1.default.clearScreenDown(process.stdout);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
35
44
|
function mapChoices(choices, includeBack) {
|
|
36
45
|
const hasBackChoice = choices.some((choice) => {
|
|
37
46
|
const value = String(choice.value ?? '').toLowerCase();
|
|
@@ -111,11 +120,7 @@ async function selectGrid(options, signal) {
|
|
|
111
120
|
let renderedLines = 0;
|
|
112
121
|
const message = normalizeMessage(options.message || 'Chọn');
|
|
113
122
|
const render = () => {
|
|
114
|
-
|
|
115
|
-
readline_1.default.moveCursor(process.stdout, 0, -renderedLines);
|
|
116
|
-
readline_1.default.cursorTo(process.stdout, 0);
|
|
117
|
-
readline_1.default.clearScreenDown(process.stdout);
|
|
118
|
-
}
|
|
123
|
+
clearPromptLines(renderedLines);
|
|
119
124
|
const filtered = filterGridChoices(choices, query);
|
|
120
125
|
const { columnWidth, columns, rows, pageSize } = gridLayout(filtered);
|
|
121
126
|
const pageCount = Math.max(1, Math.ceil(filtered.length / pageSize));
|
|
@@ -155,11 +160,7 @@ async function selectGrid(options, signal) {
|
|
|
155
160
|
};
|
|
156
161
|
const done = (value) => {
|
|
157
162
|
cleanup();
|
|
158
|
-
|
|
159
|
-
readline_1.default.moveCursor(process.stdout, 0, -renderedLines);
|
|
160
|
-
readline_1.default.cursorTo(process.stdout, 0);
|
|
161
|
-
readline_1.default.clearScreenDown(process.stdout);
|
|
162
|
-
}
|
|
163
|
+
clearPromptLines(renderedLines);
|
|
163
164
|
resolve(value);
|
|
164
165
|
};
|
|
165
166
|
const onAbort = () => {
|
package/dist/storage.js
CHANGED
package/dist/ui.js
CHANGED
|
@@ -49,18 +49,12 @@ exports.printError = printError;
|
|
|
49
49
|
const chalk_1 = __importDefault(require("chalk"));
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
|
-
const
|
|
52
|
+
const logger_1 = require("./logger");
|
|
53
53
|
const theme_1 = require("./cli/theme");
|
|
54
54
|
const text_1 = require("./cli/text");
|
|
55
55
|
function clearScreen() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (settings.developerMode && process.env.NEKOSTREAM_PRESERVE_LOGS === '1')
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// Storage may not be initialized during early startup.
|
|
63
|
-
}
|
|
56
|
+
if ((0, logger_1.isDebugModeEnabled)())
|
|
57
|
+
return;
|
|
64
58
|
process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
|
|
65
59
|
if (process.stdin.isTTY) {
|
|
66
60
|
try {
|