@nbtca/prompt 1.5.3 → 1.5.4
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.
|
@@ -4,7 +4,6 @@ import { pickIcon } from '../../core/icons.js';
|
|
|
4
4
|
import { t, fmt } from '../../i18n/index.js';
|
|
5
5
|
import { renderListFieldWithContext } from '../fields/list-field.js';
|
|
6
6
|
import { renderNextClassBanner, renderWeekGrid, renderUnresolvedItems, renderTodayTimeline, weekdayShortLabel, renderTermDensity, renderMeetingDetail, renderDayTimeline, renderDaySwitcher, } from '../../features/schedule-render.js';
|
|
7
|
-
import { renderEventBrief } from '../../features/calendar.js';
|
|
8
7
|
import { sanitizeTerminalLine, visualWidth, wrapAnsiWithIndent } from '../../core/text.js';
|
|
9
8
|
import { localDayDifference, parseLocalDate, parseLocalMonday } from '../../core/calendar-day.js';
|
|
10
9
|
import { loadingLines } from '../../core/components/spinner.js';
|
|
@@ -23,10 +22,6 @@ function headingLines(label, cols) {
|
|
|
23
22
|
function hintLines(label, cols) {
|
|
24
23
|
return wrappedIndentedLines(label, cols, type.hint);
|
|
25
24
|
}
|
|
26
|
-
function wrappedRenderedLine(line, cols) {
|
|
27
|
-
const content = line.startsWith(space.indent) ? line.slice(space.indent.length) : line;
|
|
28
|
-
return wrappedIndentedLines(content, cols, (value) => value);
|
|
29
|
-
}
|
|
30
25
|
export function hubShortcuts(tt) {
|
|
31
26
|
const trans = t();
|
|
32
27
|
const shortcuts = [
|
|
@@ -212,27 +207,7 @@ function renderPublicBody(state, now, bodyRows, cols) {
|
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
209
|
lines.push('');
|
|
215
|
-
|
|
216
|
-
const rows = Number.isFinite(bodyRows)
|
|
217
|
-
? Math.max(0, Math.floor(bodyRows))
|
|
218
|
-
: Number.POSITIVE_INFINITY;
|
|
219
|
-
const fieldRows = state.publicField
|
|
220
|
-
? Math.min(3, rows, state.publicField.render(Number.POSITIVE_INFINITY, cols).length)
|
|
221
|
-
: 0;
|
|
222
|
-
if (state.publicUpcoming && state.publicUpcoming.length > 0) {
|
|
223
|
-
const activityHeading = headingLines(trans.calendar.recentActivity, cols);
|
|
224
|
-
const eventBudget = Math.max(0, rows - lines.length - activityHeading.length - 1 - loginLines.length - fieldRows);
|
|
225
|
-
const eventLines = [];
|
|
226
|
-
for (const event of state.publicUpcoming) {
|
|
227
|
-
const wrapped = wrappedRenderedLine(renderEventBrief(event, now), cols);
|
|
228
|
-
if (eventLines.length + wrapped.length > eventBudget)
|
|
229
|
-
break;
|
|
230
|
-
eventLines.push(...wrapped);
|
|
231
|
-
}
|
|
232
|
-
if (eventLines.length > 0)
|
|
233
|
-
lines.push(...activityHeading, ...eventLines, '');
|
|
234
|
-
}
|
|
235
|
-
lines.push(...loginLines);
|
|
210
|
+
lines.push(...hintLines(trans.timetable.publicLoginHint, cols), '');
|
|
236
211
|
return state.publicField
|
|
237
212
|
? renderListFieldWithContext(lines, state.publicField, bodyRows, cols)
|
|
238
213
|
: lines;
|
|
@@ -12,8 +12,8 @@ import { loginWithStudentPassword, restoreNbtSession, } from '../../auth/nbt-aut
|
|
|
12
12
|
import { createSessionStore } from '../../auth/session-store.js';
|
|
13
13
|
import { resolveTerm, relevantTerms, writePrivateIcs, isSessionExpired, JWXT_ORIGIN, safeMessage, } from '../../features/student-timetable.js';
|
|
14
14
|
import { termKey, loadWeekOne, saveWeekOne, saveTimetableCache, saveCurrentPointer, loadCurrentPointer, loadTimetableCache, clearScheduleCache, } from '../../features/schedule-store.js';
|
|
15
|
-
import { loadCalendarOrThrow
|
|
16
|
-
import { currentAcademicWindow, inferWeekOneMonday,
|
|
15
|
+
import { loadCalendarOrThrow } from '../../features/calendar.js';
|
|
16
|
+
import { currentAcademicWindow, inferWeekOneMonday, } from '@nbtca/nbtcal';
|
|
17
17
|
import { sanitizeAcademicTerm, sanitizeTimetable } from '../../features/timetable-sanitize.js';
|
|
18
18
|
import { addLocalDays, parseLocalMonday } from '../../core/calendar-day.js';
|
|
19
19
|
let state = { mode: 'loading' };
|
|
@@ -96,10 +96,8 @@ function buildPublicField() {
|
|
|
96
96
|
return new ListField({
|
|
97
97
|
title: trans.timetable.menuEntry,
|
|
98
98
|
options: [{ value: 'login', label: trans.timetable.publicLoginAction }],
|
|
99
|
-
footer: trans.menu.hintMove,
|
|
100
99
|
});
|
|
101
100
|
}
|
|
102
|
-
const PUBLIC_UPCOMING_FETCH_CAP = 15;
|
|
103
101
|
async function goToPublic(ctx, generation = lifecycleGeneration) {
|
|
104
102
|
if (!isLifecycleActive(ctx, generation))
|
|
105
103
|
return;
|
|
@@ -113,12 +111,7 @@ async function goToPublic(ctx, generation = lifecycleGeneration) {
|
|
|
113
111
|
const now = new Date();
|
|
114
112
|
const windowEvents = cal.inRange(addLocalDays(now, -400), addLocalDays(now, 400));
|
|
115
113
|
const publicWindow = currentAcademicWindow(windowEvents, now);
|
|
116
|
-
|
|
117
|
-
.upcoming({ days: 30 })
|
|
118
|
-
.filter((e) => !isAcademicBreakEvent(e))
|
|
119
|
-
.slice(0, PUBLIC_UPCOMING_FETCH_CAP)
|
|
120
|
-
.map(toDisplayEvent);
|
|
121
|
-
state = { ...state, publicWindow, publicUpcoming };
|
|
114
|
+
state = { ...state, publicWindow };
|
|
122
115
|
}
|
|
123
116
|
catch {
|
|
124
117
|
if (!isLifecycleActive(ctx, generation))
|