repo-wrapped 0.0.2

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 (51) hide show
  1. package/README.md +94 -0
  2. package/dist/cli.js +24 -0
  3. package/dist/commands/generate.js +95 -0
  4. package/dist/commands/index.js +24 -0
  5. package/dist/constants/chronotypes.js +23 -0
  6. package/dist/constants/colors.js +18 -0
  7. package/dist/constants/index.js +18 -0
  8. package/dist/formatters/index.js +17 -0
  9. package/dist/formatters/timeFormatter.js +29 -0
  10. package/dist/generators/html/scripts/export.js +125 -0
  11. package/dist/generators/html/scripts/knowledge.js +120 -0
  12. package/dist/generators/html/scripts/modal.js +68 -0
  13. package/dist/generators/html/scripts/navigation.js +156 -0
  14. package/dist/generators/html/scripts/tabs.js +18 -0
  15. package/dist/generators/html/scripts/tooltip.js +21 -0
  16. package/dist/generators/html/styles/achievements.css +387 -0
  17. package/dist/generators/html/styles/base.css +818 -0
  18. package/dist/generators/html/styles/components.css +1391 -0
  19. package/dist/generators/html/styles/knowledge.css +221 -0
  20. package/dist/generators/html/templates/achievementsSection.js +156 -0
  21. package/dist/generators/html/templates/commitQualitySection.js +89 -0
  22. package/dist/generators/html/templates/contributionGraph.js +73 -0
  23. package/dist/generators/html/templates/impactSection.js +117 -0
  24. package/dist/generators/html/templates/knowledgeSection.js +226 -0
  25. package/dist/generators/html/templates/streakSection.js +42 -0
  26. package/dist/generators/html/templates/timePatternsSection.js +110 -0
  27. package/dist/generators/html/utils/colorUtils.js +21 -0
  28. package/dist/generators/html/utils/commitMapBuilder.js +24 -0
  29. package/dist/generators/html/utils/dateRangeCalculator.js +57 -0
  30. package/dist/generators/html/utils/developerStatsCalculator.js +29 -0
  31. package/dist/generators/html/utils/scriptLoader.js +16 -0
  32. package/dist/generators/html/utils/styleLoader.js +18 -0
  33. package/dist/generators/html/utils/weekGrouper.js +28 -0
  34. package/dist/index.js +77 -0
  35. package/dist/types/index.js +2 -0
  36. package/dist/utils/achievementDefinitions.js +433 -0
  37. package/dist/utils/achievementEngine.js +170 -0
  38. package/dist/utils/commitQualityAnalyzer.js +368 -0
  39. package/dist/utils/fileHotspotAnalyzer.js +270 -0
  40. package/dist/utils/gitParser.js +125 -0
  41. package/dist/utils/htmlGenerator.js +449 -0
  42. package/dist/utils/impactAnalyzer.js +248 -0
  43. package/dist/utils/knowledgeDistributionAnalyzer.js +374 -0
  44. package/dist/utils/matrixGenerator.js +350 -0
  45. package/dist/utils/slideGenerator.js +313 -0
  46. package/dist/utils/streakCalculator.js +135 -0
  47. package/dist/utils/timePatternAnalyzer.js +305 -0
  48. package/dist/utils/wrappedDisplay.js +115 -0
  49. package/dist/utils/wrappedGenerator.js +377 -0
  50. package/dist/utils/wrappedHtmlGenerator.js +552 -0
  51. package/package.json +55 -0
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStreakMotivation = exports.calculateStreaks = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ function calculateStreaks(commits, startDate, endDate) {
6
+ // Create set of unique commit dates
7
+ const commitDates = new Set();
8
+ commits.forEach(commit => {
9
+ const commitDate = new Date(commit.date);
10
+ if (commitDate >= startDate && commitDate <= endDate) {
11
+ commitDates.add((0, date_fns_1.format)(commitDate, 'yyyy-MM-dd'));
12
+ }
13
+ });
14
+ // Calculate total days and active days
15
+ const totalDays = (0, date_fns_1.differenceInDays)(endDate, startDate) + 1;
16
+ const totalActiveDays = commitDates.size;
17
+ const activeDayPercentage = totalDays > 0 ? (totalActiveDays / totalDays) * 100 : 0;
18
+ // Find all streaks
19
+ const streaks = [];
20
+ let currentStreakDays = 0;
21
+ let currentStreakStart = null;
22
+ const allDays = (0, date_fns_1.eachDayOfInterval)({ start: startDate, end: endDate });
23
+ for (const date of allDays) {
24
+ const dateKey = (0, date_fns_1.format)(date, 'yyyy-MM-dd');
25
+ if (commitDates.has(dateKey)) {
26
+ if (currentStreakDays === 0) {
27
+ currentStreakStart = date;
28
+ }
29
+ currentStreakDays++;
30
+ }
31
+ else {
32
+ if (currentStreakDays > 0 && currentStreakStart) {
33
+ streaks.push({
34
+ days: currentStreakDays,
35
+ startDate: currentStreakStart,
36
+ endDate: (0, date_fns_1.subDays)(date, 1)
37
+ });
38
+ currentStreakDays = 0;
39
+ currentStreakStart = null;
40
+ }
41
+ }
42
+ }
43
+ // Handle streak that extends to end date
44
+ if (currentStreakDays > 0 && currentStreakStart) {
45
+ streaks.push({
46
+ days: currentStreakDays,
47
+ startDate: currentStreakStart,
48
+ endDate: endDate
49
+ });
50
+ }
51
+ // Find longest streak
52
+ const longestStreak = streaks.length > 0
53
+ ? streaks.reduce((longest, current) => current.days > longest.days ? current : longest)
54
+ : { days: 0, startDate: startDate, endDate: startDate };
55
+ // Determine current streak (from today or most recent commit going backward)
56
+ const today = new Date();
57
+ const todayKey = (0, date_fns_1.format)(today, 'yyyy-MM-dd');
58
+ let currentStreak;
59
+ if (commitDates.has(todayKey)) {
60
+ // Today has a commit, find streak from today backward
61
+ let streakDays = 0;
62
+ let checkDate = today;
63
+ while (commitDates.has((0, date_fns_1.format)(checkDate, 'yyyy-MM-dd'))) {
64
+ streakDays++;
65
+ checkDate = (0, date_fns_1.subDays)(checkDate, 1);
66
+ if (checkDate < startDate)
67
+ break;
68
+ }
69
+ currentStreak = {
70
+ days: streakDays,
71
+ startDate: (0, date_fns_1.subDays)(today, streakDays - 1),
72
+ endDate: today,
73
+ isActive: true
74
+ };
75
+ }
76
+ else {
77
+ // No commit today, check if yesterday had commit (streak just broke)
78
+ const yesterday = (0, date_fns_1.subDays)(today, 1);
79
+ const yesterdayKey = (0, date_fns_1.format)(yesterday, 'yyyy-MM-dd');
80
+ if (commitDates.has(yesterdayKey)) {
81
+ let streakDays = 0;
82
+ let checkDate = yesterday;
83
+ while (commitDates.has((0, date_fns_1.format)(checkDate, 'yyyy-MM-dd'))) {
84
+ streakDays++;
85
+ checkDate = (0, date_fns_1.subDays)(checkDate, 1);
86
+ if (checkDate < startDate)
87
+ break;
88
+ }
89
+ currentStreak = {
90
+ days: streakDays,
91
+ startDate: (0, date_fns_1.subDays)(yesterday, streakDays - 1),
92
+ endDate: yesterday,
93
+ isActive: false
94
+ };
95
+ }
96
+ else {
97
+ // No recent streak
98
+ currentStreak = {
99
+ days: 0,
100
+ startDate: today,
101
+ endDate: today,
102
+ isActive: false
103
+ };
104
+ }
105
+ }
106
+ return {
107
+ currentStreak,
108
+ longestStreak,
109
+ totalActiveDays,
110
+ totalDays,
111
+ activeDayPercentage,
112
+ streaks
113
+ };
114
+ }
115
+ exports.calculateStreaks = calculateStreaks;
116
+ function getStreakMotivation(days, isActive) {
117
+ if (days === 0) {
118
+ return "Start building momentum today";
119
+ }
120
+ if (!isActive) {
121
+ return `Your ${days}-day streak ended. Time for a fresh start.`;
122
+ }
123
+ if (days >= 61)
124
+ return "Outstanding consistency";
125
+ if (days >= 31)
126
+ return "Exceptional dedication";
127
+ if (days >= 15)
128
+ return "Strong momentum 🔥";
129
+ if (days >= 8)
130
+ return "Solid consistency";
131
+ if (days >= 4)
132
+ return "Building momentum";
133
+ return "Just getting started";
134
+ }
135
+ exports.getStreakMotivation = getStreakMotivation;
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChronotypeDescription = exports.getChronotypeLabel = exports.analyzeTimePatterns = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ function analyzeTimePatterns(commits, startDate, endDate) {
6
+ if (commits.length === 0) {
7
+ return getEmptyPattern();
8
+ }
9
+ // Filter commits within the date range
10
+ const filteredCommits = commits.filter(c => {
11
+ const commitDate = new Date(c.date);
12
+ return commitDate >= startDate && commitDate <= endDate;
13
+ });
14
+ if (filteredCommits.length === 0) {
15
+ return getEmptyPattern();
16
+ }
17
+ // 1. Hourly distribution
18
+ const hourlyMap = new Map();
19
+ for (let i = 0; i < 24; i++) {
20
+ hourlyMap.set(i, 0);
21
+ }
22
+ filteredCommits.forEach(commit => {
23
+ const hour = (0, date_fns_1.getHours)(new Date(commit.date));
24
+ hourlyMap.set(hour, (hourlyMap.get(hour) || 0) + 1);
25
+ });
26
+ const hourly = Array.from(hourlyMap.entries()).map(([hour, count]) => ({
27
+ hour,
28
+ commitCount: count,
29
+ percentage: (count / filteredCommits.length) * 100
30
+ }));
31
+ // 2. Daily distribution (day of week)
32
+ const dayMap = new Map();
33
+ for (let i = 0; i < 7; i++) {
34
+ dayMap.set(i, []);
35
+ }
36
+ filteredCommits.forEach(commit => {
37
+ const dayIndex = (0, date_fns_1.getDay)(new Date(commit.date));
38
+ dayMap.get(dayIndex).push(1);
39
+ });
40
+ const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
41
+ const dailyAverage = Array.from(dayMap.entries()).map(([dayIndex, commits]) => ({
42
+ dayOfWeek: dayNames[dayIndex],
43
+ commitCount: commits.length,
44
+ avgCommitsPerDay: commits.length / Math.ceil((endDate.getTime() - startDate.getTime()) / (7 * 24 * 60 * 60 * 1000))
45
+ }));
46
+ // 3. Peak hour
47
+ const peakHourEntry = hourly.reduce((max, curr) => curr.commitCount > max.commitCount ? curr : max);
48
+ const peakHour = {
49
+ hour: peakHourEntry.hour,
50
+ commitCount: peakHourEntry.commitCount
51
+ };
52
+ // 4. Peak day
53
+ const peakDayEntry = dailyAverage.reduce((max, curr) => curr.commitCount > max.commitCount ? curr : max);
54
+ const peakDay = {
55
+ dayOfWeek: peakDayEntry.dayOfWeek,
56
+ avgCommits: peakDayEntry.avgCommitsPerDay
57
+ };
58
+ // 5. Chronotype detection
59
+ const chronotypeData = getChronotype(hourly);
60
+ // 6. Work-life balance
61
+ const workLifeBalance = calculateWorkLifeBalance(dailyAverage);
62
+ // 7. Timing stats
63
+ const timingStats = calculateTimingStats(filteredCommits);
64
+ // 8. Burnout risk
65
+ const burnoutRisk = detectBurnoutRisk(hourly, dailyAverage, filteredCommits);
66
+ // 9. Consistency score
67
+ const consistency = calculateConsistency(filteredCommits);
68
+ return {
69
+ hourly,
70
+ dailyAverage,
71
+ chronotype: chronotypeData.type,
72
+ chronotypeConfidence: chronotypeData.confidence,
73
+ peakHour,
74
+ peakDay,
75
+ workLifeBalance,
76
+ timingStats,
77
+ burnoutRisk,
78
+ consistency
79
+ };
80
+ }
81
+ exports.analyzeTimePatterns = analyzeTimePatterns;
82
+ function getChronotype(hourly) {
83
+ const totalCommits = hourly.reduce((sum, h) => sum + h.commitCount, 0);
84
+ if (totalCommits === 0) {
85
+ return { type: 'balanced', confidence: 0 };
86
+ }
87
+ // Calculate time period percentages
88
+ const morningCommits = hourly.filter(h => h.hour >= 6 && h.hour < 12).reduce((sum, h) => sum + h.commitCount, 0);
89
+ const eveningCommits = hourly.filter(h => h.hour >= 18 && h.hour < 24).reduce((sum, h) => sum + h.commitCount, 0);
90
+ const nightCommits = hourly.filter(h => h.hour >= 0 && h.hour < 6).reduce((sum, h) => sum + h.commitCount, 0);
91
+ const morningPct = (morningCommits / totalCommits) * 100;
92
+ const eveningPct = (eveningCommits / totalCommits) * 100;
93
+ const nightPct = (nightCommits / totalCommits) * 100;
94
+ // Vampire: 30%+ commits between midnight-6am
95
+ if (nightPct >= 30) {
96
+ return { type: 'vampire', confidence: nightPct };
97
+ }
98
+ // Early Bird: 60%+ commits before 12pm
99
+ if (morningPct >= 60) {
100
+ return { type: 'early-bird', confidence: morningPct };
101
+ }
102
+ // Night Owl: 60%+ commits after 6pm
103
+ if (eveningPct >= 60) {
104
+ return { type: 'night-owl', confidence: eveningPct };
105
+ }
106
+ // Balanced: Even distribution
107
+ return { type: 'balanced', confidence: 100 - Math.max(morningPct, eveningPct, nightPct) };
108
+ }
109
+ function calculateWorkLifeBalance(dailyAverage) {
110
+ const weekdayCommits = dailyAverage
111
+ .filter(d => !['Saturday', 'Sunday'].includes(d.dayOfWeek))
112
+ .reduce((sum, d) => sum + d.commitCount, 0);
113
+ const weekendCommits = dailyAverage
114
+ .filter(d => ['Saturday', 'Sunday'].includes(d.dayOfWeek))
115
+ .reduce((sum, d) => sum + d.commitCount, 0);
116
+ const totalCommits = weekdayCommits + weekendCommits;
117
+ const ratio = totalCommits > 0 ? weekdayCommits / weekendCommits : 0;
118
+ // Score: 5 stars = ratio > 10 (very little weekend work)
119
+ // 1 star = ratio < 2 (too much weekend work)
120
+ let score = 5;
121
+ if (ratio < 2)
122
+ score = 1;
123
+ else if (ratio < 4)
124
+ score = 2;
125
+ else if (ratio < 6)
126
+ score = 3;
127
+ else if (ratio < 10)
128
+ score = 4;
129
+ return {
130
+ weekdayCommits,
131
+ weekendCommits,
132
+ ratio,
133
+ score
134
+ };
135
+ }
136
+ function calculateTimingStats(commits) {
137
+ if (commits.length === 0) {
138
+ return {
139
+ avgFirstCommit: '00:00',
140
+ avgLastCommit: '00:00',
141
+ avgSessionLength: 0,
142
+ longestSession: { date: new Date(), hours: 0 }
143
+ };
144
+ }
145
+ // Group commits by date
146
+ const commitsByDate = new Map();
147
+ commits.forEach(commit => {
148
+ const dateKey = (0, date_fns_1.format)(new Date(commit.date), 'yyyy-MM-dd');
149
+ if (!commitsByDate.has(dateKey)) {
150
+ commitsByDate.set(dateKey, []);
151
+ }
152
+ commitsByDate.get(dateKey).push(new Date(commit.date));
153
+ });
154
+ // Calculate first/last commit times and session lengths
155
+ let totalFirstHour = 0;
156
+ let totalLastHour = 0;
157
+ let totalSessionHours = 0;
158
+ let longestSession = { date: new Date(), hours: 0 };
159
+ commitsByDate.forEach((times, dateKey) => {
160
+ times.sort((a, b) => a.getTime() - b.getTime());
161
+ const firstCommit = times[0];
162
+ const lastCommit = times[times.length - 1];
163
+ totalFirstHour += firstCommit.getHours() + (firstCommit.getMinutes() / 60);
164
+ totalLastHour += lastCommit.getHours() + (lastCommit.getMinutes() / 60);
165
+ const sessionLength = (0, date_fns_1.differenceInHours)(lastCommit, firstCommit);
166
+ totalSessionHours += sessionLength;
167
+ if (sessionLength > longestSession.hours) {
168
+ longestSession = { date: (0, date_fns_1.parse)(dateKey, 'yyyy-MM-dd', new Date()), hours: sessionLength };
169
+ }
170
+ });
171
+ const daysWithCommits = commitsByDate.size;
172
+ const avgFirstHour = totalFirstHour / daysWithCommits;
173
+ const avgLastHour = totalLastHour / daysWithCommits;
174
+ const formatTime = (decimalHour) => {
175
+ const hour = Math.floor(decimalHour);
176
+ const minute = Math.floor((decimalHour - hour) * 60);
177
+ return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
178
+ };
179
+ return {
180
+ avgFirstCommit: formatTime(avgFirstHour),
181
+ avgLastCommit: formatTime(avgLastHour),
182
+ avgSessionLength: totalSessionHours / daysWithCommits,
183
+ longestSession
184
+ };
185
+ }
186
+ function detectBurnoutRisk(hourly, dailyAverage, commits) {
187
+ const indicators = [];
188
+ let riskScore = 0;
189
+ // Check for late-night commits (after 11 PM)
190
+ const lateNightCommits = hourly.filter(h => h.hour >= 23).reduce((sum, h) => sum + h.commitCount, 0);
191
+ const veryLateCommits = hourly.filter(h => h.hour >= 0 && h.hour < 6).reduce((sum, h) => sum + h.commitCount, 0);
192
+ if (lateNightCommits > 15) {
193
+ indicators.push(`${lateNightCommits} late-night commits (after 11 PM)`);
194
+ riskScore += 20;
195
+ }
196
+ if (veryLateCommits > 10) {
197
+ indicators.push(`${veryLateCommits} commits between midnight-6am`);
198
+ riskScore += 30;
199
+ }
200
+ // Weekend work is not counted as a burnout indicator since it's ambiguous
201
+ // (could be hobby projects vs. overwork) - focusing on late night patterns instead
202
+ // Check for uneven distribution (working all hours)
203
+ const activeHours = hourly.filter(h => h.commitCount > 0).length;
204
+ if (activeHours > 16) {
205
+ indicators.push('Commits spread across too many hours');
206
+ riskScore += 15;
207
+ }
208
+ // Determine risk level
209
+ let level = 'low';
210
+ if (riskScore >= 50)
211
+ level = 'high';
212
+ else if (riskScore >= 25)
213
+ level = 'medium';
214
+ // Add positive indicators if low risk
215
+ if (riskScore < 25) {
216
+ indicators.push('✅ Regular commit times (±2 hour variance)');
217
+ indicators.push('✅ Healthy work-life balance');
218
+ }
219
+ return {
220
+ level,
221
+ indicators,
222
+ score: Math.min(riskScore, 100)
223
+ };
224
+ }
225
+ function calculateConsistency(commits) {
226
+ if (commits.length === 0) {
227
+ return { score: 0, variance: 0, regularity: 'chaotic' };
228
+ }
229
+ // Calculate variance in commit times (hour of day)
230
+ const hours = commits.map(c => (0, date_fns_1.getHours)(new Date(c.date)));
231
+ const avgHour = hours.reduce((sum, h) => sum + h, 0) / hours.length;
232
+ const variance = hours.reduce((sum, h) => sum + Math.pow(h - avgHour, 2), 0) / hours.length;
233
+ const stdDev = Math.sqrt(variance);
234
+ // Score based on standard deviation (lower = more consistent)
235
+ // stdDev < 2: very consistent (same 2-hour window)
236
+ // stdDev < 4: consistent
237
+ // stdDev < 6: irregular
238
+ // stdDev >= 6: chaotic
239
+ let score = 10;
240
+ let regularity = 'very-consistent';
241
+ if (stdDev >= 6) {
242
+ score = Math.max(0, 10 - stdDev);
243
+ regularity = 'chaotic';
244
+ }
245
+ else if (stdDev >= 4) {
246
+ score = 10 - stdDev;
247
+ regularity = 'irregular';
248
+ }
249
+ else if (stdDev >= 2) {
250
+ score = 10 - (stdDev / 2);
251
+ regularity = 'consistent';
252
+ }
253
+ else {
254
+ score = 10 - (stdDev / 4);
255
+ regularity = 'very-consistent';
256
+ }
257
+ return {
258
+ score: Math.max(0, Math.min(10, score)),
259
+ variance: stdDev,
260
+ regularity
261
+ };
262
+ }
263
+ function getEmptyPattern() {
264
+ return {
265
+ hourly: Array.from({ length: 24 }, (_, i) => ({ hour: i, commitCount: 0, percentage: 0 })),
266
+ dailyAverage: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'].map(day => ({
267
+ dayOfWeek: day,
268
+ commitCount: 0,
269
+ avgCommitsPerDay: 0
270
+ })),
271
+ chronotype: 'balanced',
272
+ chronotypeConfidence: 0,
273
+ peakHour: { hour: 0, commitCount: 0 },
274
+ peakDay: { dayOfWeek: 'Monday', avgCommits: 0 },
275
+ workLifeBalance: { weekdayCommits: 0, weekendCommits: 0, ratio: 0, score: 5 },
276
+ timingStats: {
277
+ avgFirstCommit: '00:00',
278
+ avgLastCommit: '00:00',
279
+ avgSessionLength: 0,
280
+ longestSession: { date: new Date(), hours: 0 }
281
+ },
282
+ burnoutRisk: { level: 'low', indicators: [], score: 0 },
283
+ consistency: { score: 0, variance: 0, regularity: 'chaotic' }
284
+ };
285
+ }
286
+ function getChronotypeLabel(chronotype) {
287
+ const labels = {
288
+ 'early-bird': '🐦 Early Bird',
289
+ 'night-owl': '🦉 Night Owl',
290
+ 'balanced': '⚖️ Balanced',
291
+ 'vampire': '🧛 Vampire'
292
+ };
293
+ return labels[chronotype] || chronotype;
294
+ }
295
+ exports.getChronotypeLabel = getChronotypeLabel;
296
+ function getChronotypeDescription(chronotype) {
297
+ const descriptions = {
298
+ 'early-bird': "You're most productive in the morning. Consider scheduling important work before lunch.",
299
+ 'night-owl': "You're most productive in the evening. Night time is when you shine!",
300
+ 'balanced': "You maintain a well-balanced coding schedule throughout the day.",
301
+ 'vampire': "⚠️ Many late-night commits detected. Consider adjusting your schedule for better work-life balance."
302
+ };
303
+ return descriptions[chronotype] || '';
304
+ }
305
+ exports.getChronotypeDescription = getChronotypeDescription;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.displayWrappedSlideshow = void 0;
30
+ const chalk_1 = __importDefault(require("chalk"));
31
+ const readline = __importStar(require("readline"));
32
+ function displayWrappedSlideshow(slides) {
33
+ let currentSlide = 0;
34
+ const rl = readline.createInterface({
35
+ input: process.stdin,
36
+ output: process.stdout
37
+ });
38
+ // Set raw mode to capture single keystrokes
39
+ if (process.stdin.isTTY) {
40
+ readline.emitKeypressEvents(process.stdin);
41
+ process.stdin.setRawMode(true);
42
+ }
43
+ function displaySlide(index) {
44
+ console.clear();
45
+ console.log(slides[index].content);
46
+ console.log();
47
+ // Show navigation hints
48
+ const hints = [];
49
+ if (index < slides.length - 1)
50
+ hints.push(chalk_1.default.gray('Press ENTER for next'));
51
+ if (index > 0)
52
+ hints.push(chalk_1.default.gray('Press B for back'));
53
+ hints.push(chalk_1.default.gray('Press Q to quit'));
54
+ console.log(chalk_1.default.dim(hints.join(' | ')));
55
+ console.log();
56
+ console.log(chalk_1.default.gray(`Slide ${index + 1}/${slides.length}`));
57
+ }
58
+ function navigate(direction) {
59
+ if (direction === 'quit') {
60
+ cleanup();
61
+ return;
62
+ }
63
+ if (direction === 'next' && currentSlide < slides.length - 1) {
64
+ currentSlide++;
65
+ displaySlide(currentSlide);
66
+ }
67
+ else if (direction === 'next' && currentSlide === slides.length - 1) {
68
+ // At the end
69
+ cleanup();
70
+ }
71
+ else if (direction === 'prev' && currentSlide > 0) {
72
+ currentSlide--;
73
+ displaySlide(currentSlide);
74
+ }
75
+ }
76
+ function cleanup() {
77
+ if (process.stdin.isTTY) {
78
+ process.stdin.setRawMode(false);
79
+ }
80
+ rl.close();
81
+ console.log();
82
+ console.log(chalk_1.default.green('✨ Thanks for exploring your Year in Code!'));
83
+ console.log();
84
+ }
85
+ // Handle keypress events
86
+ process.stdin.on('keypress', (str, key) => {
87
+ if (key.ctrl && key.name === 'c') {
88
+ cleanup();
89
+ process.exit();
90
+ }
91
+ switch (key.name) {
92
+ case 'return':
93
+ case 'enter':
94
+ case 'space':
95
+ navigate('next');
96
+ break;
97
+ case 'b':
98
+ navigate('prev');
99
+ break;
100
+ case 'q':
101
+ case 'escape':
102
+ navigate('quit');
103
+ break;
104
+ case 'left':
105
+ navigate('prev');
106
+ break;
107
+ case 'right':
108
+ navigate('next');
109
+ break;
110
+ }
111
+ });
112
+ // Display first slide
113
+ displaySlide(currentSlide);
114
+ }
115
+ exports.displayWrappedSlideshow = displayWrappedSlideshow;