@nbtca/prompt 1.4.2 → 1.5.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/README.md +27 -58
- package/SECURITY.md +16 -45
- package/dist/app/app.js +53 -55
- package/dist/app/chrome.js +67 -50
- package/dist/app/fields/list-field.js +12 -25
- package/dist/app/fields/text-field.js +3 -8
- package/dist/app/frame.js +2 -21
- package/dist/app/keys.js +10 -2
- package/dist/app/views/docs-render.js +31 -24
- package/dist/app/views/docs.js +211 -60
- package/dist/app/views/events-render.js +19 -26
- package/dist/app/views/events.js +44 -31
- package/dist/app/views/home.js +28 -30
- package/dist/app/views/schedule-grid-cursor.js +9 -18
- package/dist/app/views/schedule-render.js +47 -71
- package/dist/app/views/schedule.js +158 -81
- package/dist/app/views/settings-render.js +8 -19
- package/dist/app/views/settings.js +92 -17
- package/dist/auth/cookie-transport.js +31 -32
- package/dist/auth/errors.js +3 -1
- package/dist/auth/nbt-auth.js +42 -25
- package/dist/auth/session-store.js +17 -9
- package/dist/config/data.js +9 -11
- package/dist/config/preferences.js +14 -7
- package/dist/core/calendar-day.js +37 -0
- package/dist/core/capabilities.js +6 -3
- package/dist/core/components/confirm.js +9 -8
- package/dist/core/components/menu.js +41 -16
- package/dist/core/components/messages.js +12 -4
- package/dist/core/components/painter.js +3 -1
- package/dist/core/components/spinner.js +17 -6
- package/dist/core/components/text-input.js +24 -18
- package/dist/core/icons.js +2 -2
- package/dist/core/logo.js +23 -5
- package/dist/core/motion.js +25 -19
- package/dist/core/text.js +182 -69
- package/dist/core/theme.js +0 -28
- package/dist/core/transitions.js +2 -2
- package/dist/core/ui.js +15 -13
- package/dist/core/vim-keys.js +9 -15
- package/dist/features/about.js +23 -0
- package/dist/features/calendar-heatmap.js +16 -40
- package/dist/features/calendar-query.js +1 -2
- package/dist/features/calendar.js +12 -185
- package/dist/features/docs.js +436 -275
- package/dist/features/schedule-render.js +65 -101
- package/dist/features/schedule-store.js +51 -9
- package/dist/features/schedule-view.js +46 -213
- package/dist/features/status.js +44 -56
- package/dist/features/student-timetable.js +73 -95
- package/dist/features/theme.js +6 -2
- package/dist/features/timetable-sanitize.js +40 -0
- package/dist/features/update.js +9 -27
- package/dist/i18n/index.js +83 -19
- package/dist/i18n/locales/en.json +1 -1
- package/dist/i18n/locales/zh.json +1 -1
- package/dist/index.js +83 -58
- package/dist/logo/ca-dotmatrix.txt +16 -18
- package/dist/main.js +7 -48
- package/package.json +27 -18
- package/bin/nbtca-welcome.js +0 -2
- package/dist/core/components/screen.js +0 -18
- package/dist/core/menu.js +0 -68
- package/dist/features/links.js +0 -36
- package/dist/features/schedule-query.js +0 -47
- package/dist/features/settings.js +0 -127
- package/dist/logo/ca-logo.png +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { applyColorModePreference, loadPreferences, resetPreferences, setColorMode, setIconMode, } from '../config/preferences.js';
|
|
3
|
-
import { pickIcon } from '../core/icons.js';
|
|
4
|
-
import { resetIconCache } from '../core/icons.js';
|
|
5
|
-
import { padEndV } from '../core/text.js';
|
|
6
|
-
import { success, warning } from '../core/ui.js';
|
|
7
|
-
import { APP_INFO, URLS } from '../config/data.js';
|
|
8
|
-
import { t, getCurrentLanguage, saveLanguagePreference, clearTranslationCache } from '../i18n/index.js';
|
|
9
|
-
import { runMenu, menuFooter } from '../core/components/menu.js';
|
|
10
|
-
import { note } from '../core/components/note.js';
|
|
11
|
-
import { enterScreen, breadcrumb } from '../core/transitions.js';
|
|
12
|
-
function notifyResult(saved, successMsg, warningMsg) {
|
|
13
|
-
if (saved) {
|
|
14
|
-
success(successMsg);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
warning(warningMsg);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function showAbout() {
|
|
21
|
-
const trans = t();
|
|
22
|
-
const pad = 12;
|
|
23
|
-
const row = (label, value) => `${chalk.dim(padEndV(label, pad))}${value}`;
|
|
24
|
-
const link = (label, url) => row(label, chalk.cyan(url));
|
|
25
|
-
const content = [
|
|
26
|
-
row(trans.about.project, APP_INFO.name),
|
|
27
|
-
row(trans.about.version, `v${APP_INFO.version}`),
|
|
28
|
-
row(trans.about.description, trans.about.descriptionText),
|
|
29
|
-
'',
|
|
30
|
-
link(trans.about.github, APP_INFO.repository),
|
|
31
|
-
link(trans.about.website, URLS.homepage),
|
|
32
|
-
link(trans.about.email, URLS.email),
|
|
33
|
-
'',
|
|
34
|
-
row(trans.about.license, `MIT ${pickIcon('·', '|')} ${trans.about.author}: m1ngsama`),
|
|
35
|
-
].join('\n');
|
|
36
|
-
note(content, trans.about.title);
|
|
37
|
-
}
|
|
38
|
-
export async function showSettingsMenu() {
|
|
39
|
-
await enterScreen(breadcrumb(t().menu.settings));
|
|
40
|
-
while (true) {
|
|
41
|
-
const trans = t();
|
|
42
|
-
const prefs = loadPreferences();
|
|
43
|
-
const currentLang = getCurrentLanguage();
|
|
44
|
-
const footer = menuFooter();
|
|
45
|
-
const action = await runMenu({
|
|
46
|
-
title: trans.theme.chooseAction,
|
|
47
|
-
options: [
|
|
48
|
-
{ value: 'language', label: trans.language.selectLanguage, hint: currentLang === 'zh' ? trans.language.zh : trans.language.en },
|
|
49
|
-
{ value: 'icon', label: trans.theme.iconMode, hint: prefs.iconMode },
|
|
50
|
-
{ value: 'color', label: trans.theme.colorMode, hint: prefs.colorMode },
|
|
51
|
-
{ value: 'reset', label: trans.theme.resetLabel },
|
|
52
|
-
{ value: 'about', label: trans.about.title },
|
|
53
|
-
],
|
|
54
|
-
footer,
|
|
55
|
-
});
|
|
56
|
-
if (action === null)
|
|
57
|
-
return;
|
|
58
|
-
if (action === 'about') {
|
|
59
|
-
showAbout();
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (action === 'language') {
|
|
63
|
-
const langOptions = [
|
|
64
|
-
{ value: 'zh', label: trans.language.zh, hint: currentLang === 'zh' ? trans.common.current : undefined },
|
|
65
|
-
{ value: 'en', label: trans.language.en, hint: currentLang === 'en' ? trans.common.current : undefined },
|
|
66
|
-
];
|
|
67
|
-
const language = await runMenu({
|
|
68
|
-
title: trans.language.selectLanguage,
|
|
69
|
-
options: langOptions,
|
|
70
|
-
footer,
|
|
71
|
-
initialIndex: Math.max(0, langOptions.findIndex(o => o.value === currentLang)),
|
|
72
|
-
});
|
|
73
|
-
if (language === null)
|
|
74
|
-
continue;
|
|
75
|
-
if (language !== currentLang) {
|
|
76
|
-
const saved = saveLanguagePreference(language);
|
|
77
|
-
clearTranslationCache();
|
|
78
|
-
notifyResult(saved, t().language.changed, t().language.changedSessionOnly);
|
|
79
|
-
}
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (action === 'icon') {
|
|
83
|
-
const iconOptions = [
|
|
84
|
-
{ value: 'auto', label: trans.theme.modeAuto, hint: prefs.iconMode === 'auto' ? trans.common.current : undefined },
|
|
85
|
-
{ value: 'ascii', label: trans.theme.modeAscii, hint: prefs.iconMode === 'ascii' ? trans.common.current : undefined },
|
|
86
|
-
{ value: 'unicode', label: trans.theme.modeUnicode, hint: prefs.iconMode === 'unicode' ? trans.common.current : undefined },
|
|
87
|
-
];
|
|
88
|
-
const mode = await runMenu({
|
|
89
|
-
title: trans.theme.chooseIconMode,
|
|
90
|
-
options: iconOptions,
|
|
91
|
-
footer,
|
|
92
|
-
initialIndex: Math.max(0, iconOptions.findIndex(o => o.value === prefs.iconMode)),
|
|
93
|
-
});
|
|
94
|
-
if (mode === null)
|
|
95
|
-
continue;
|
|
96
|
-
const saved = setIconMode(mode);
|
|
97
|
-
resetIconCache();
|
|
98
|
-
notifyResult(saved, trans.theme.updated, trans.theme.updatedSessionOnly);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (action === 'color') {
|
|
102
|
-
const colorOptions = [
|
|
103
|
-
{ value: 'auto', label: trans.theme.modeAuto, hint: prefs.colorMode === 'auto' ? trans.common.current : undefined },
|
|
104
|
-
{ value: 'on', label: trans.theme.modeOn, hint: prefs.colorMode === 'on' ? trans.common.current : undefined },
|
|
105
|
-
{ value: 'off', label: trans.theme.modeOff, hint: prefs.colorMode === 'off' ? trans.common.current : undefined },
|
|
106
|
-
];
|
|
107
|
-
const mode = await runMenu({
|
|
108
|
-
title: trans.theme.chooseColorMode,
|
|
109
|
-
options: colorOptions,
|
|
110
|
-
footer,
|
|
111
|
-
initialIndex: Math.max(0, colorOptions.findIndex(o => o.value === prefs.colorMode)),
|
|
112
|
-
});
|
|
113
|
-
if (mode === null)
|
|
114
|
-
continue;
|
|
115
|
-
const saved = setColorMode(mode);
|
|
116
|
-
applyColorModePreference(false);
|
|
117
|
-
notifyResult(saved, trans.theme.updated, trans.theme.updatedSessionOnly);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (action === 'reset') {
|
|
121
|
-
const saved = resetPreferences();
|
|
122
|
-
resetIconCache();
|
|
123
|
-
applyColorModePreference(false);
|
|
124
|
-
notifyResult(saved, trans.theme.reset, trans.theme.resetSessionOnly);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
package/dist/logo/ca-logo.png
DELETED
|
Binary file
|