-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathversion.ts
More file actions
369 lines (325 loc) · 11.8 KB
/
Copy pathversion.ts
File metadata and controls
369 lines (325 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
// App version
// Format: MAJOR.MINOR.PATCH
export const APP_VERSION = '2.4.5';
export interface ChangelogNotice {
type: 'info' | 'warning' | 'success' | 'danger';
title: string;
message: string;
animated?: boolean;
link?: {
label: string;
href: string;
suffix?: string;
};
annotation?: {
text: string;
};
}
// Featured video shown at top of changelog (set to null to hide)
export const FEATURED_VIDEO: {
source: string;
title: string;
banner?: ChangelogNotice;
} | null = {
source: '/masterselects_github.mp4',
title: 'MasterSelects Demo',
banner: {
type: 'success',
title: `MasterSelects ${APP_VERSION}`,
message: 'Kernel cutover release: shared private operation contracts, hardened hosted AI recovery, expanded motion design, guided editing and browser-level regression coverage.',
animated: true,
},
};
// Build/Platform notice shown at top of changelog (set to null to hide)
export const BUILD_NOTICE: ChangelogNotice | null = {
type: 'success',
title: `MasterSelects ${APP_VERSION}`,
message: 'Kernel cutover release: shared private operation contracts, hardened hosted AI recovery, expanded motion design, guided editing and browser-level regression coverage.',
animated: true,
};
export const WIP_NOTICE: ChangelogNotice | null = {
type: 'info',
title: 'Universal Media Architecture',
message: 'The next layer is rich renderers for documents, CAD/vector data, point clouds, and external Wasm providers on top of the new Signal IR foundation.',
animated: true,
};
// Change entry type (used by UI)
export interface ChangeEntry {
type: 'new' | 'fix' | 'improve' | 'refactor';
title: string;
description?: string;
section?: string; // Optional section header to create visual dividers
commits?: string[]; // Git commit hashes for linking to GitHub
highlight?: 'community';
contributorName?: string;
contributorUrl?: string;
}
// Time-grouped changelog entry
export interface TimeGroupedChanges {
label: string;
dateRange: string; // "Jan 20" or "Jan 13-19" etc
changes: ChangeEntry[];
}
export interface ChangelogCalendarDay {
date: string;
tooltip: string;
count: number;
communityCount: number;
level: 0 | 1 | 2 | 3 | 4;
communityLevel: 0 | 1 | 2 | 3 | 4;
isFuture: boolean;
isToday: boolean;
isOutOfRange: boolean;
}
// Raw changelog entry as stored in changelog-data.json
export interface RawChangeEntry {
date: string; // ISO date string YYYY-MM-DD
type: 'new' | 'fix' | 'improve' | 'refactor';
title: string;
description?: string;
section?: string;
commits?: string[];
highlight?: 'community';
contributorName?: string;
contributorUrl?: string;
}
export function shouldAutoShowChangelog(
showChangelogOnStartup: boolean,
lastSeenChangelogVersion: string | null | undefined,
appVersion: string = APP_VERSION,
): boolean {
return showChangelogOnStartup || lastSeenChangelogVersion !== appVersion;
}
// Import changelog data from JSON
import changelogData from './changelog-data.json';
const RAW_CHANGELOG: RawChangeEntry[] = changelogData as RawChangeEntry[];
function parseISODateLocal(dateStr: string): Date {
const [year, month, day] = dateStr.split('-').map(Number);
return new Date(year, month - 1, day);
}
function formatDateShort(date: Date): string {
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
}
function formatDateRange(minDate: Date, maxDate: Date): string {
if (minDate.getTime() === maxDate.getTime()) {
return formatDateShort(maxDate);
}
const sameMonth = minDate.getFullYear() === maxDate.getFullYear() && minDate.getMonth() === maxDate.getMonth();
if (sameMonth) {
return `${maxDate.toLocaleDateString('en-US', { month: 'short' })} ${minDate.getDate()}-${maxDate.getDate()}`;
}
return `${formatDateShort(minDate)} - ${formatDateShort(maxDate)}`;
}
function startOfDay(date: Date): Date {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
function startOfWeekMonday(date: Date): Date {
const day = date.getDay();
const offset = (day + 6) % 7;
const normalized = startOfDay(date);
normalized.setDate(normalized.getDate() - offset);
return normalized;
}
function endOfWeekMonday(date: Date): Date {
const normalized = startOfWeekMonday(date);
normalized.setDate(normalized.getDate() + 6);
return normalized;
}
function startOfQuarter(date: Date): Date {
const quarterStartMonth = Math.floor(date.getMonth() / 3) * 3;
return new Date(date.getFullYear(), quarterStartMonth, 1);
}
function startOfYear(date: Date): Date {
return new Date(date.getFullYear(), 0, 1);
}
function formatCalendarTooltip(date: Date, count: number, communityCount: number): string {
const label = date.toLocaleDateString(undefined, {
month: 'short',
day: 'numeric',
year: 'numeric',
});
if (count === 0) {
return label;
}
if (communityCount === 0) {
return `${label}: ${count} ${count === 1 ? 'change' : 'changes'}`;
}
const coreCount = Math.max(0, count - communityCount);
const countLabel = `${count} ${count === 1 ? 'change' : 'changes'}`;
const communityLabel = `${communityCount} community`;
const coreLabel = coreCount > 0 ? `, ${coreCount} core` : '';
return `${label}: ${countLabel} (${communityLabel}${coreLabel})`;
}
function getCalendarLevel(count: number): 0 | 1 | 2 | 3 | 4 {
if (count >= 4) return 4;
if (count === 3) return 3;
if (count === 2) return 2;
if (count === 1) return 1;
return 0;
}
function getMonthDiff(now: Date, date: Date): number {
return (now.getFullYear() - date.getFullYear()) * 12 + (now.getMonth() - date.getMonth());
}
function formatMonthLabel(date: Date, now: Date): string {
const includeYear = date.getFullYear() !== now.getFullYear();
return date.toLocaleDateString('en-US', includeYear
? { month: 'long', year: 'numeric' }
: { month: 'long' });
}
function getInitialCommitDate(entries: RawChangeEntry[]): Date | null {
if (entries.length === 0) {
return null;
}
return entries
.map((entry) => parseISODateLocal(entry.date))
.reduce((earliest, date) => (date < earliest ? date : earliest));
}
// Calculate relative time labels based on current date
function getTimeLabel(
date: Date,
now: Date,
initialCommitDate: Date | null
): { label: string; sortOrder: number } {
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const dayMs = 24 * 60 * 60 * 1000;
const normalizedDate = startOfDay(date);
const dayDiff = Math.round((today.getTime() - normalizedDate.getTime()) / dayMs);
const monthDiff = getMonthDiff(today, normalizedDate);
if (dayDiff <= 0) {
return { label: 'Today', sortOrder: 0 };
}
if (dayDiff === 1) {
return { label: 'Yesterday', sortOrder: 1 };
}
if (dayDiff === 2) {
return { label: 'Day Before Yesterday', sortOrder: 2 };
}
if (dayDiff < 7) {
return { label: 'Last Week', sortOrder: 3 };
}
if (monthDiff === 0) {
return { label: formatMonthLabel(normalizedDate, now), sortOrder: 4 };
}
if (monthDiff === 1) {
return { label: 'Last Month', sortOrder: 5 };
}
if (
initialCommitDate &&
startOfDay(initialCommitDate).getTime() === normalizedDate.getTime()
) {
return { label: 'Initial Commit', sortOrder: 10_000 };
}
return { label: formatMonthLabel(normalizedDate, now), sortOrder: 5 + monthDiff };
}
// Group changes by time period
export function getGroupedChangelog(
entries: RawChangeEntry[] = RAW_CHANGELOG,
now: Date = new Date()
): TimeGroupedChanges[] {
const groups = new Map<string, { sortOrder: number; minDate: Date; maxDate: Date; changes: ChangeEntry[] }>();
const initialCommitDate = getInitialCommitDate(entries);
for (const entry of entries) {
const date = parseISODateLocal(entry.date);
const { label, sortOrder } = getTimeLabel(date, now, initialCommitDate);
if (!groups.has(label)) {
groups.set(label, { sortOrder, minDate: date, maxDate: date, changes: [] });
}
const group = groups.get(label)!;
if (date < group.minDate) group.minDate = date;
if (date > group.maxDate) group.maxDate = date;
group.changes.push({
type: entry.type,
title: entry.title,
description: entry.description,
section: entry.section,
commits: entry.commits,
highlight: entry.highlight,
contributorName: entry.contributorName,
contributorUrl: entry.contributorUrl,
});
}
// Sort groups by sortOrder and return
return Array.from(groups.entries())
.map(([label, data]) => ({
label,
dateRange: formatDateRange(data.minDate, data.maxDate),
changes: data.changes,
}))
.sort((a, b) => {
const orderA = groups.get(a.label)?.sortOrder ?? 99;
const orderB = groups.get(b.label)?.sortOrder ?? 99;
return orderA - orderB;
});
}
export function getChangelogCalendar(
entries: RawChangeEntry[] = RAW_CHANGELOG,
now: Date = new Date(),
scope: 'year' | 'quarter' | number = 'year'
): ChangelogCalendarDay[][] {
const normalizedNow = startOfDay(now);
const countsByDate = new Map<string, number>();
const communityCountsByDate = new Map<string, number>();
for (const entry of entries) {
countsByDate.set(entry.date, (countsByDate.get(entry.date) ?? 0) + 1);
if (entry.highlight === 'community') {
communityCountsByDate.set(entry.date, (communityCountsByDate.get(entry.date) ?? 0) + 1);
}
}
let firstWeekStart: Date;
let weeks: number;
let rangeStart: Date | null = null;
let rangeEnd: Date | null = null;
if (scope === 'quarter' || scope === 'year') {
rangeStart = scope === 'year'
? startOfYear(normalizedNow)
: startOfQuarter(normalizedNow);
rangeEnd = normalizedNow;
firstWeekStart = startOfWeekMonday(rangeStart);
const finalWeekEnd = endOfWeekMonday(rangeEnd);
weeks = Math.ceil((finalWeekEnd.getTime() - firstWeekStart.getTime() + 1) / (7 * 24 * 60 * 60 * 1000));
} else {
const currentWeekStart = startOfWeekMonday(normalizedNow);
firstWeekStart = new Date(currentWeekStart);
firstWeekStart.setDate(firstWeekStart.getDate() - (scope - 1) * 7);
weeks = scope;
}
const weeksGrid: ChangelogCalendarDay[][] = [];
for (let weekIndex = 0; weekIndex < weeks; weekIndex++) {
const weekStart = new Date(firstWeekStart);
weekStart.setDate(firstWeekStart.getDate() + weekIndex * 7);
const days: ChangelogCalendarDay[] = [];
for (let dayIndex = 0; dayIndex < 7; dayIndex++) {
const date = new Date(weekStart);
date.setDate(weekStart.getDate() + dayIndex);
const isoDate = [
date.getFullYear(),
String(date.getMonth() + 1).padStart(2, '0'),
String(date.getDate()).padStart(2, '0'),
].join('-');
const isOutOfRange = !!(rangeStart && rangeEnd && (date < rangeStart || date > rangeEnd));
const isFuture = !isOutOfRange && date.getTime() > normalizedNow.getTime();
const count = isOutOfRange || isFuture ? 0 : (countsByDate.get(isoDate) ?? 0);
const communityCount = isOutOfRange || isFuture ? 0 : (communityCountsByDate.get(isoDate) ?? 0);
days.push({
date: isoDate,
tooltip: isOutOfRange ? '' : formatCalendarTooltip(date, count, communityCount),
count,
communityCount,
level: isOutOfRange || isFuture ? 0 : getCalendarLevel(count),
communityLevel: isOutOfRange || isFuture ? 0 : getCalendarLevel(communityCount),
isFuture,
isToday: !isOutOfRange && date.getTime() === normalizedNow.getTime(),
isOutOfRange,
});
}
weeksGrid.push(days);
}
return weeksGrid;
}
// Known issues and bugs - shown in What's New dialog
// Remove items when fixed
export const KNOWN_ISSUES: string[] = [
'Non-Windows/source Native Helper builds require yt-dlp beside the helper or on PATH',
'Audio waveforms may not display for some video formats',
'Very long videos (>2 hours) may cause performance issues',
];