Release v1.1.0: Reports, Scheduling, and Mobile Optimization

This commit is contained in:
2025-11-24 20:48:47 +01:00
parent 2fad5d88ab
commit f1af574eb9
12 changed files with 2480 additions and 46 deletions

547
main.js
View File

@@ -27,7 +27,7 @@ __export(main_exports, {
default: () => ImmersePlugin
});
module.exports = __toCommonJS(main_exports);
var import_obsidian3 = require("obsidian");
var import_obsidian4 = require("obsidian");
// src/types.ts
var DEFAULT_SETTINGS = {
@@ -57,7 +57,9 @@ var DEFAULT_DATA = {
totalFocusMinutesToday: 0,
streak: 0,
lastActiveDate: "",
pomodorosCompleted: 0
pomodorosCompleted: 0,
dailyStats: [],
completedTasksArchive: []
};
var VIEW_TYPE_IMMERSE = "immerse-view";
var CELEBRATION_MESSAGES = [
@@ -347,6 +349,11 @@ var ImmerseView = class extends import_obsidian2.ItemView {
const dateStr = today.toLocaleDateString("en-US", { weekday: "long", month: "short", day: "numeric" });
titleSection.createEl("div", { text: dateStr, cls: "immerse-date" });
const actions = header.createEl("div", { cls: "immerse-header-actions" });
const reportsBtn = actions.createEl("button", { cls: "immerse-btn" });
reportsBtn.innerHTML = "\u{1F4CA} Reports";
reportsBtn.addEventListener("click", () => {
this.plugin.activateReportView();
});
const addBtn = actions.createEl("button", { cls: "immerse-btn immerse-btn-primary" });
addBtn.innerHTML = "+ Add Task";
addBtn.addEventListener("click", () => {
@@ -359,7 +366,7 @@ var ImmerseView = class extends import_obsidian2.ItemView {
const statItems = [
{ label: "Pending", value: stats.pendingCount.toString(), icon: "\u{1F4CB}" },
{ label: "Done Today", value: stats.completedToday.toString(), icon: "\u2705" },
{ label: "Focus Time", value: this.plugin.formatTimeHuman(stats.totalFocusMinutesToday), icon: "\u23F1\uFE0F" },
{ label: "Today's Focus", value: this.plugin.formatTimeHuman(stats.totalFocusMinutesToday), icon: "\u23F1\uFE0F" },
{ label: "Streak", value: `${stats.streak} days`, icon: "\u{1F525}" }
];
statItems.forEach((stat) => {
@@ -600,8 +607,281 @@ var ImmerseView = class extends import_obsidian2.ItemView {
}
};
// src/reportView.ts
var import_obsidian3 = require("obsidian");
var VIEW_TYPE_REPORT = "immerse-report-view";
var ReportView = class extends import_obsidian3.ItemView {
constructor(leaf, plugin) {
super(leaf);
this.selectedListIds = [];
this.plugin = plugin;
const today = new Date();
this.endDate = today.toISOString().split("T")[0];
const weekAgo = new Date(today);
weekAgo.setDate(weekAgo.getDate() - 7);
this.startDate = weekAgo.toISOString().split("T")[0];
}
getViewType() {
return VIEW_TYPE_REPORT;
}
getDisplayText() {
return "\u{1F4CA} Reports";
}
getIcon() {
return "bar-chart-2";
}
async onOpen() {
const container = this.containerEl.children[1];
container.empty();
container.addClass("immerse-report-view");
this.renderContent();
}
async onClose() {
}
renderContent() {
const container = this.containerEl.children[1];
container.empty();
const header = container.createEl("div", { cls: "immerse-report-header" });
header.createEl("h2", { text: "\u{1F4CA} Reports", cls: "immerse-report-title" });
this.renderFilters(container);
const generateBtn = container.createEl("button", {
text: "\u{1F504} Generate Report",
cls: "immerse-btn immerse-btn-primary immerse-report-generate-btn"
});
generateBtn.addEventListener("click", () => this.renderReport(container));
this.renderReport(container);
}
renderFilters(container) {
const filtersSection = container.createEl("div", { cls: "immerse-report-filters" });
const dateRow = filtersSection.createEl("div", { cls: "immerse-report-filter-row" });
new import_obsidian3.Setting(dateRow).setName("Start Date").addText((text) => {
text.setValue(this.startDate).onChange((value) => this.startDate = value);
text.inputEl.type = "date";
});
new import_obsidian3.Setting(dateRow).setName("End Date").addText((text) => {
text.setValue(this.endDate).onChange((value) => this.endDate = value);
text.inputEl.type = "date";
});
const quickFilters = filtersSection.createEl("div", { cls: "immerse-report-quick-filters" });
quickFilters.createEl("span", { text: "Quick select: ", cls: "immerse-filter-label" });
const filters = [
{ label: "Today", days: 0 },
{ label: "Last 7 days", days: 7 },
{ label: "Last 30 days", days: 30 },
{ label: "Last 90 days", days: 90 }
];
filters.forEach((filter) => {
const btn = quickFilters.createEl("button", {
text: filter.label,
cls: "immerse-quick-filter-btn"
});
btn.addEventListener("click", () => {
const today = new Date();
this.endDate = today.toISOString().split("T")[0];
const startDate = new Date(today);
startDate.setDate(startDate.getDate() - filter.days);
this.startDate = startDate.toISOString().split("T")[0];
this.renderReport(container);
});
});
}
renderReport(container) {
const oldReport = container.querySelector(".immerse-report-content");
if (oldReport)
oldReport.remove();
const filters = {
startDate: this.startDate,
endDate: this.endDate,
listIds: this.selectedListIds.length > 0 ? this.selectedListIds : void 0
};
const reportData = this.plugin.generateReport(filters);
const reportContent = container.createEl("div", { cls: "immerse-report-content" });
if (reportData.totalTasks === 0) {
reportContent.createEl("div", {
text: "No data available for the selected period. Complete some tasks to see your stats!",
cls: "immerse-no-data-message"
});
return;
}
this.renderSummaryStats(reportContent, reportData);
if (reportData.timeByList.length > 0) {
this.renderTimeByList(reportContent, reportData);
}
this.renderInsights(reportContent, reportData);
if (reportData.dailyBreakdown.length > 0) {
this.renderDailyBreakdown(reportContent, reportData);
}
}
renderSummaryStats(container, data) {
const statsGrid = container.createEl("div", { cls: "immerse-stats-grid" });
const stats = [
{ label: "TASKS DONE", value: data.totalTasks.toString(), icon: "\u2713" },
{ label: "TASKS PER DAY", value: data.tasksPerDay.toFixed(1), icon: "\u{1F4C5}" },
{ label: "HOURS PER DAY", value: data.hoursPerDay.toFixed(1), icon: "\u23F0" },
{ label: "MINS PER TASK", value: data.minsPerTask.toString(), icon: "\u23F1\uFE0F" },
{ label: "DAY STREAK", value: data.currentStreak.toString(), icon: "\u{1F525}" },
{ label: "TOTAL HOURS", value: (data.totalMinutes / 60).toFixed(1), icon: "\u231A" }
];
stats.forEach((stat) => {
const statCard = statsGrid.createEl("div", { cls: "immerse-stat-card" });
statCard.createEl("div", { text: stat.label, cls: "immerse-stat-label" });
const valueRow = statCard.createEl("div", { cls: "immerse-stat-value-row" });
valueRow.createEl("span", { text: stat.icon, cls: "immerse-stat-icon" });
valueRow.createEl("span", { text: stat.value, cls: "immerse-stat-value" });
});
}
renderTimeByList(container, data) {
const section = container.createEl("div", { cls: "immerse-report-section" });
section.createEl("h3", { text: "Time by List", cls: "immerse-report-section-title" });
const listContainer = section.createEl("div", { cls: "immerse-time-by-list" });
data.timeByList.forEach((item) => {
const listItem = listContainer.createEl("div", { cls: "immerse-list-stat-item" });
const listInfo = listItem.createEl("div", { cls: "immerse-list-info" });
listInfo.createEl("span", { text: item.listIcon, cls: "immerse-list-icon" });
listInfo.createEl("span", { text: item.listName, cls: "immerse-list-name" });
const progressBar = listItem.createEl("div", { cls: "immerse-list-progress" });
const progress = progressBar.createEl("div", { cls: "immerse-list-progress-fill" });
progress.style.width = `${item.percentage}%`;
progress.style.background = item.listColor;
const stats = listItem.createEl("div", { cls: "immerse-list-stats" });
stats.createEl("span", {
text: `${item.taskCount} tasks`,
cls: "immerse-list-stat-text"
});
stats.createEl("span", {
text: `${this.plugin.formatTimeHuman(item.minutes)}`,
cls: "immerse-list-stat-text"
});
stats.createEl("span", {
text: `${item.percentage.toFixed(1)}%`,
cls: "immerse-list-stat-percentage"
});
});
}
renderInsights(container, data) {
const section = container.createEl("div", { cls: "immerse-report-section" });
section.createEl("h3", { text: "Productivity Insights", cls: "immerse-report-section-title" });
const insightsGrid = section.createEl("div", { cls: "immerse-insights-grid" });
if (data.mostProductiveHour !== void 0) {
const card = insightsGrid.createEl("div", { cls: "immerse-insight-card" });
card.createEl("span", { text: "\u{1F550}", cls: "immerse-insight-icon" });
card.createEl("span", { text: "MOST PRODUCTIVE HOUR", cls: "immerse-insight-label" });
card.createEl("span", {
text: `${data.mostProductiveHour}:00 - ${data.mostProductiveHour + 1}:00`,
cls: "immerse-insight-value"
});
}
if (data.mostProductiveDay) {
const card = insightsGrid.createEl("div", { cls: "immerse-insight-card" });
card.createEl("span", { text: "\u{1F4C5}", cls: "immerse-insight-icon" });
card.createEl("span", { text: "MOST PRODUCTIVE DAY", cls: "immerse-insight-label" });
card.createEl("span", { text: data.mostProductiveDay, cls: "immerse-insight-value" });
}
if (data.mostProductiveMonth) {
const card = insightsGrid.createEl("div", { cls: "immerse-insight-card" });
card.createEl("span", { text: "\u{1F5D3}\uFE0F", cls: "immerse-insight-icon" });
card.createEl("span", { text: "MOST PRODUCTIVE MONTH", cls: "immerse-insight-label" });
card.createEl("span", { text: data.mostProductiveMonth, cls: "immerse-insight-value" });
}
}
renderPieChart(container, data) {
const pieContainer = container.createEl("div", { cls: "immerse-daily-pie-container" });
const totalTasks = data.totalTasks;
const totalMinutes = data.totalMinutes;
const totalPomodoros = data.totalPomodoros;
const taskMinutes = totalTasks * data.minsPerTask;
const pomodoroMinutes = totalPomodoros * 25;
const totalTime = taskMinutes + totalMinutes + pomodoroMinutes;
if (totalTime === 0)
return;
const tasksPercent = taskMinutes / totalTime * 100;
const hoursPercent = totalMinutes / totalTime * 100;
const pomodorosPercent = pomodoroMinutes / totalTime * 100;
const tasksDeg = tasksPercent / 100 * 360;
const hoursDeg = tasksDeg + hoursPercent / 100 * 360;
const pieChart = pieContainer.createEl("div", { cls: "immerse-daily-pie-chart" });
const gradient = `conic-gradient(from 0deg, #6366f1 0deg ${tasksDeg}deg, #22c55e ${tasksDeg}deg ${hoursDeg}deg, #f59e0b ${hoursDeg}deg 360deg)`;
pieChart.style.background = gradient;
const center = pieChart.createEl("div", { cls: "immerse-daily-pie-center" });
center.createEl("div", { text: data.totalTasks.toString(), cls: "immerse-daily-pie-center-value" });
center.createEl("div", { text: "TOTAL TASKS", cls: "immerse-daily-pie-center-label" });
const legend = pieContainer.createEl("div", { cls: "immerse-daily-pie-legend" });
const tasksItem = legend.createEl("div", { cls: "immerse-daily-pie-legend-item" });
const tasksColor = tasksItem.createEl("div", { cls: "immerse-daily-pie-legend-color" });
tasksColor.style.background = "#6366f1";
const tasksInfo = tasksItem.createEl("div", { cls: "immerse-daily-pie-legend-info" });
const tasksLabel = tasksInfo.createEl("div", { cls: "immerse-daily-pie-legend-label" });
tasksLabel.createEl("span", { text: "\u2713" });
tasksLabel.appendText("Tasks Completed");
tasksInfo.createEl("div", { text: totalTasks.toString(), cls: "immerse-daily-pie-legend-value" });
tasksInfo.createEl("div", { text: `${tasksPercent.toFixed(1)}%`, cls: "immerse-daily-pie-legend-percentage" });
const hoursItem = legend.createEl("div", { cls: "immerse-daily-pie-legend-item" });
const hoursColor = hoursItem.createEl("div", { cls: "immerse-daily-pie-legend-color" });
hoursColor.style.background = "#22c55e";
const hoursInfo = hoursItem.createEl("div", { cls: "immerse-daily-pie-legend-info" });
const hoursLabel = hoursInfo.createEl("div", { cls: "immerse-daily-pie-legend-label" });
hoursLabel.createEl("span", { text: "\u23F1\uFE0F" });
hoursLabel.appendText("Total Hours");
hoursInfo.createEl("div", { text: (totalMinutes / 60).toFixed(1), cls: "immerse-daily-pie-legend-value" });
hoursInfo.createEl("div", { text: `${hoursPercent.toFixed(1)}%`, cls: "immerse-daily-pie-legend-percentage" });
const pomodorosItem = legend.createEl("div", { cls: "immerse-daily-pie-legend-item" });
const pomodorosColor = pomodorosItem.createEl("div", { cls: "immerse-daily-pie-legend-color" });
pomodorosColor.style.background = "#f59e0b";
const pomodorosInfo = pomodorosItem.createEl("div", { cls: "immerse-daily-pie-legend-info" });
const pomodorosLabel = pomodorosInfo.createEl("div", { cls: "immerse-daily-pie-legend-label" });
pomodorosLabel.createEl("span", { text: "\u{1F345}" });
pomodorosLabel.appendText("Pomodoros");
pomodorosInfo.createEl("div", { text: totalPomodoros.toString(), cls: "immerse-daily-pie-legend-value" });
pomodorosInfo.createEl("div", { text: `${pomodorosPercent.toFixed(1)}%`, cls: "immerse-daily-pie-legend-percentage" });
}
renderDailyBreakdown(container, data) {
const section = container.createEl("div", { cls: "immerse-report-section" });
section.createEl("h3", { text: "Daily Breakdown", cls: "immerse-report-section-title" });
this.renderPieChart(section, data);
const breakdownContainer = section.createEl("div", { cls: "immerse-daily-breakdown-container" });
const recentData = data.dailyBreakdown.slice(-10);
const maxTasks = Math.max(...recentData.map((d) => d.tasks), 1);
const maxHours = Math.max(...recentData.map((d) => d.hours), 1);
const maxPomodoros = Math.max(...recentData.map((d) => d.pomodoros), 1);
recentData.forEach((day) => {
const row = breakdownContainer.createEl("div", { cls: "immerse-daily-row" });
const dateEl = row.createEl("div", { cls: "immerse-daily-date" });
const date = new Date(day.date + "T00:00:00");
const dayName = date.toLocaleDateString("en-US", { weekday: "short" }).toUpperCase();
const monthDay = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
dateEl.createEl("div", { text: dayName, cls: "immerse-daily-date-day" });
dateEl.createEl("div", { text: monthDay, cls: "immerse-daily-date-num" });
const barsContainer = row.createEl("div", { cls: "immerse-daily-bars" });
const tasksRow = barsContainer.createEl("div", { cls: "immerse-daily-bar-row" });
const tasksLabel = tasksRow.createEl("span", { cls: "immerse-daily-bar-label" });
tasksLabel.createEl("span", { text: "\u2713", cls: "immerse-daily-bar-icon" });
tasksLabel.appendText("Tasks");
const tasksTrack = tasksRow.createEl("div", { cls: "immerse-daily-bar-track" });
const tasksFill = tasksTrack.createEl("div", { cls: "immerse-daily-bar-fill tasks" });
tasksFill.style.width = `${day.tasks / maxTasks * 100}%`;
tasksRow.createEl("span", { text: day.tasks.toString(), cls: "immerse-daily-bar-value" });
const hoursRow = barsContainer.createEl("div", { cls: "immerse-daily-bar-row" });
const hoursLabel = hoursRow.createEl("span", { cls: "immerse-daily-bar-label" });
hoursLabel.createEl("span", { text: "\u23F1\uFE0F", cls: "immerse-daily-bar-icon" });
hoursLabel.appendText("Hours");
const hoursTrack = hoursRow.createEl("div", { cls: "immerse-daily-bar-track" });
const hoursFill = hoursTrack.createEl("div", { cls: "immerse-daily-bar-fill hours" });
hoursFill.style.width = `${day.hours / maxHours * 100}%`;
hoursRow.createEl("span", { text: day.hours.toFixed(1), cls: "immerse-daily-bar-value" });
const pomodorosRow = barsContainer.createEl("div", { cls: "immerse-daily-bar-row" });
const pomodorosLabel = pomodorosRow.createEl("span", { cls: "immerse-daily-bar-label" });
pomodorosLabel.createEl("span", { text: "\u{1F345}", cls: "immerse-daily-bar-icon" });
pomodorosLabel.appendText("Pomodoros");
const pomodorosTrack = pomodorosRow.createEl("div", { cls: "immerse-daily-bar-track" });
const pomodorosFill = pomodorosTrack.createEl("div", { cls: "immerse-daily-bar-fill pomodoros" });
pomodorosFill.style.width = `${day.pomodoros / maxPomodoros * 100}%`;
pomodorosRow.createEl("span", { text: day.pomodoros.toString(), cls: "immerse-daily-bar-value" });
});
}
};
// src/main.ts
var ImmersePlugin = class extends import_obsidian3.Plugin {
var ImmersePlugin = class extends import_obsidian4.Plugin {
constructor() {
super(...arguments);
// Timer state
@@ -636,6 +916,10 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
VIEW_TYPE_IMMERSE,
(leaf) => new ImmerseView(leaf, this)
);
this.registerView(
VIEW_TYPE_REPORT,
(leaf) => new ReportView(leaf, this)
);
this.addRibbonIcon("zap", "Open Immerse", () => {
this.activateView();
});
@@ -664,6 +948,11 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
name: "Complete Current Task",
callback: () => this.completeActiveTask()
});
this.addCommand({
id: "view-reports",
name: "View Reports",
callback: () => this.activateReportView()
});
this.addSettingTab(new ImmerseSettingTab(this.app, this));
this.createStatusBar();
if (this.settings.enableReminders) {
@@ -723,6 +1012,20 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
workspace.revealLeaf(leaf);
}
}
async activateReportView() {
const { workspace } = this.app;
const existingLeaves = workspace.getLeavesOfType(VIEW_TYPE_REPORT);
if (existingLeaves.length > 0) {
workspace.revealLeaf(existingLeaves[0]);
} else {
const leaf = workspace.getLeaf("tab");
await leaf.setViewState({
type: VIEW_TYPE_REPORT,
active: true
});
workspace.revealLeaf(leaf);
}
}
// ============ Task Management ============
createTask(text, estimatedMinutes = this.settings.defaultEstimateMinutes, list = "work") {
return {
@@ -770,6 +1073,8 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
task.isActive = false;
this.data.completedToday++;
this.data.lastActiveDate = new Date().toDateString();
this.archiveCompletedTask(task);
this.updateDailyStats(task);
if (this.settings.enableCelebrations) {
this.showCelebration(task);
}
@@ -791,9 +1096,185 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (this.activeTaskId) {
this.completeTask(this.activeTaskId);
} else {
new import_obsidian3.Notice("No active task to complete");
new import_obsidian4.Notice("No active task to complete");
}
}
// ============ Data Archiving & Statistics ============
archiveCompletedTask(task) {
const wasOverdue = task.scheduledDate && task.scheduledTime && new Date(`${task.scheduledDate}T${task.scheduledTime}`).getTime() < (task.completedAt || Date.now());
const record = {
id: task.id,
text: task.text,
list: task.list,
estimatedMinutes: task.estimatedMinutes,
actualMinutes: task.actualMinutes,
createdAt: task.createdAt,
completedAt: task.completedAt || Date.now(),
scheduledDate: task.scheduledDate,
wasOverdue: wasOverdue || false
};
this.data.completedTasksArchive.push(record);
}
updateDailyStats(task) {
const today = new Date().toISOString().split("T")[0];
let todayStats = this.data.dailyStats.find((s) => s.date === today);
if (!todayStats) {
todayStats = {
date: today,
tasksCompleted: 0,
totalMinutes: 0,
pomodorosCompleted: 0,
tasksByList: {},
minutesByList: {}
};
this.data.dailyStats.push(todayStats);
}
todayStats.tasksCompleted++;
todayStats.totalMinutes += task.actualMinutes;
todayStats.pomodorosCompleted = this.data.pomodorosCompleted;
todayStats.tasksByList[task.list] = (todayStats.tasksByList[task.list] || 0) + 1;
todayStats.minutesByList[task.list] = (todayStats.minutesByList[task.list] || 0) + task.actualMinutes;
if (this.data.dailyStats.length > 365) {
this.data.dailyStats.sort((a, b) => b.date.localeCompare(a.date));
this.data.dailyStats = this.data.dailyStats.slice(0, 365);
}
}
// ============ Report Generation ============
generateReport(filters) {
const { startDate, endDate, listIds } = filters;
const filteredStats = this.data.dailyStats.filter((stat) => {
return stat.date >= startDate && stat.date <= endDate;
});
const filteredTasks = this.data.completedTasksArchive.filter((task) => {
const taskDate = new Date(task.completedAt).toISOString().split("T")[0];
const inDateRange = taskDate >= startDate && taskDate <= endDate;
const inList = !listIds || listIds.includes(task.list);
return inDateRange && inList;
});
const totalTasks = filteredTasks.length;
const totalMinutes = filteredTasks.reduce((sum, task) => sum + task.actualMinutes, 0);
const totalPomodoros = filteredStats.reduce((sum, stat) => sum + stat.pomodorosCompleted, 0);
const daysWithData = filteredStats.length || 1;
const tasksPerDay = totalTasks / daysWithData;
const hoursPerDay = totalMinutes / 60 / daysWithData;
const minsPerTask = totalTasks > 0 ? totalMinutes / totalTasks : 0;
const timeByListMap = {};
filteredTasks.forEach((task) => {
if (!timeByListMap[task.list]) {
timeByListMap[task.list] = { minutes: 0, taskCount: 0 };
}
timeByListMap[task.list].minutes += task.actualMinutes;
timeByListMap[task.list].taskCount++;
});
const timeByList = this.settings.lists.map((list) => {
const data = timeByListMap[list.id] || { minutes: 0, taskCount: 0 };
const percentage = totalMinutes > 0 ? data.minutes / totalMinutes * 100 : 0;
return {
listId: list.id,
listName: list.name,
listIcon: list.icon,
listColor: list.color,
minutes: data.minutes,
taskCount: data.taskCount,
percentage: Math.round(percentage * 10) / 10
// Round to 1 decimal
};
}).filter((item) => item.minutes > 0);
const dailyBreakdown = filteredStats.map((stat) => ({
date: stat.date,
tasks: stat.tasksCompleted,
hours: Math.round(stat.totalMinutes / 60 * 10) / 10,
pomodoros: stat.pomodorosCompleted
}));
const mostProductiveHour = this.calculateMostProductiveHour(filteredTasks);
const mostProductiveDay = this.calculateMostProductiveDay(filteredStats);
const mostProductiveMonth = this.calculateMostProductiveMonth(filteredStats);
return {
totalTasks,
totalMinutes,
totalPomodoros,
tasksPerDay: Math.round(tasksPerDay * 10) / 10,
hoursPerDay: Math.round(hoursPerDay * 10) / 10,
minsPerTask: Math.round(minsPerTask),
currentStreak: this.data.streak,
timeByList,
dailyBreakdown,
mostProductiveHour,
mostProductiveDay,
mostProductiveMonth
};
}
calculateMostProductiveHour(tasks) {
if (tasks.length === 0)
return void 0;
const hourCounts = {};
tasks.forEach((task) => {
const hour = new Date(task.completedAt).getHours();
hourCounts[hour] = (hourCounts[hour] || 0) + 1;
});
let maxHour = 0;
let maxCount = 0;
for (const [hour, count] of Object.entries(hourCounts)) {
if (count > maxCount) {
maxCount = count;
maxHour = parseInt(hour);
}
}
return maxCount > 0 ? maxHour : void 0;
}
calculateMostProductiveDay(stats) {
if (stats.length === 0)
return void 0;
const dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
const dayCounts = {};
stats.forEach((stat) => {
const dayOfWeek = new Date(stat.date).getDay();
const dayName = dayNames[dayOfWeek];
dayCounts[dayName] = (dayCounts[dayName] || 0) + stat.tasksCompleted;
});
let maxDay = "";
let maxCount = 0;
for (const [day, count] of Object.entries(dayCounts)) {
if (count > maxCount) {
maxCount = count;
maxDay = day;
}
}
return maxCount > 0 ? maxDay : void 0;
}
calculateMostProductiveMonth(stats) {
if (stats.length === 0)
return void 0;
const monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
const monthCounts = {};
stats.forEach((stat) => {
const month = new Date(stat.date).getMonth();
const monthName = monthNames[month];
monthCounts[monthName] = (monthCounts[monthName] || 0) + stat.tasksCompleted;
});
let maxMonth = "";
let maxCount = 0;
for (const [month, count] of Object.entries(monthCounts)) {
if (count > maxCount) {
maxCount = count;
maxMonth = month;
}
}
return maxCount > 0 ? maxMonth : void 0;
}
// ============ Timer Management ============
// Sync timer based on timestamp when app returns from background
syncTimerFromTimestamp() {
@@ -835,7 +1316,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (this.settings.enableSounds) {
this.playAlertSound();
}
new import_obsidian3.Notice(`\u23F0 Time's up for: ${task.text}`);
new import_obsidian4.Notice(`\u23F0 Time's up for: ${task.text}`);
}
}, 1e3);
this.saveAllData();
@@ -892,7 +1373,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (this.settings.enableSounds) {
this.playAlertSound();
}
new import_obsidian3.Notice("\u{1F345} Pomodoro complete! Time for a break.");
new import_obsidian4.Notice("\u{1F345} Pomodoro complete! Time for a break.");
if (this.settings.autoStartBreak) {
this.startBreak();
} else {
@@ -902,7 +1383,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (this.settings.enableSounds) {
this.playAlertSound();
}
new import_obsidian3.Notice("\u26A1 Break over! Ready to focus?");
new import_obsidian4.Notice("\u26A1 Break over! Ready to focus?");
this.refreshView();
}
this.saveAllData();
@@ -914,7 +1395,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
this.currentTimerSeconds = (isLongBreak ? this.settings.longBreakMinutes : this.settings.pomodoroBreakMinutes) * 60;
this.timerStartTimestamp = Date.now();
this.pausedTimeRemaining = this.currentTimerSeconds;
new import_obsidian3.Notice(isLongBreak ? "\u2615 Long break time!" : "\u2615 Short break time!");
new import_obsidian4.Notice(isLongBreak ? "\u2615 Long break time!" : "\u2615 Short break time!");
this.refreshView();
if (!this.timerInterval) {
this.timerInterval = window.setInterval(() => {
@@ -960,7 +1441,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
}
}, 1e3);
} else {
new import_obsidian3.Notice("No active task. Select a task first.");
new import_obsidian4.Notice("No active task. Select a task first.");
}
this.updateStatusBar();
this.refreshView();
@@ -991,7 +1472,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (pendingTasks.length > 0) {
this.startPomodoro(pendingTasks[0].id);
} else {
new import_obsidian3.Notice("No pending tasks. Add a task first!");
new import_obsidian4.Notice("No pending tasks. Add a task first!");
}
}
// ============ Status Bar Timer ============
@@ -1058,7 +1539,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
}
showReminder(task) {
const timeStr = task.scheduledTime;
new import_obsidian3.Notice(`\u{1F514} Reminder: "${task.text}" is scheduled for ${timeStr}`, 8e3);
new import_obsidian4.Notice(`\u{1F514} Reminder: "${task.text}" is scheduled for ${timeStr}`, 8e3);
if (this.settings.enableSounds) {
this.playAlertSound();
}
@@ -1066,7 +1547,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
showOverdueNotice(task) {
const dateStr = task.scheduledDate;
const timeStr = task.scheduledTime;
new import_obsidian3.Notice(`\u26A0\uFE0F Overdue: "${task.text}" was scheduled for ${dateStr} ${timeStr}`, 1e4);
new import_obsidian4.Notice(`\u26A0\uFE0F Overdue: "${task.text}" was scheduled for ${dateStr} ${timeStr}`, 1e4);
if (this.settings.enableSounds) {
this.playAlertSound();
}
@@ -1083,7 +1564,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
messages = OVERTIME_MESSAGES;
}
const celebration = messages[Math.floor(Math.random() * messages.length)];
new import_obsidian3.Notice(`${celebration.emoji} ${celebration.message}${extraMessage}`);
new import_obsidian4.Notice(`${celebration.emoji} ${celebration.message}${extraMessage}`);
}
playCompletionSound() {
try {
@@ -1145,7 +1626,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
await this.appendToDailyNote(taskEntry);
} catch (e) {
console.error("Failed to log task to daily note:", e);
new import_obsidian3.Notice("Failed to log task to daily note. Make sure Daily Notes core plugin is enabled.");
new import_obsidian4.Notice("Failed to log task to daily note. Make sure Daily Notes core plugin is enabled.");
}
}
getDailyNoteSettings() {
@@ -1183,14 +1664,14 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
const { vault } = this.app;
const dailySettings = this.getDailyNoteSettings();
if (!dailySettings) {
new import_obsidian3.Notice("Daily Notes core plugin is not enabled. Please enable it in Settings \u2192 Core plugins.");
new import_obsidian4.Notice("Daily Notes core plugin is not enabled. Please enable it in Settings \u2192 Core plugins.");
return null;
}
const filename = this.formatDailyNoteDate(dailySettings.format);
const folder = dailySettings.folder ? `${dailySettings.folder}/` : "";
const path = `${folder}${filename}.md`;
let file = vault.getAbstractFileByPath(path);
if (file && file instanceof import_obsidian3.TFile) {
if (file && file instanceof import_obsidian4.TFile) {
return file;
}
try {
@@ -1204,17 +1685,17 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
if (dailySettings.template) {
const templatePath = dailySettings.template.endsWith(".md") ? dailySettings.template : `${dailySettings.template}.md`;
const templateFile = vault.getAbstractFileByPath(templatePath);
if (templateFile && templateFile instanceof import_obsidian3.TFile) {
if (templateFile && templateFile instanceof import_obsidian4.TFile) {
content = await vault.read(templateFile);
content = content.replace(/{{date}}/g, filename).replace(/{{time}}/g, new Date().toLocaleTimeString()).replace(/{{title}}/g, filename);
}
}
const newFile = await vault.create(path, content);
new import_obsidian3.Notice(`\u{1F4DD} Created daily note: ${filename}`);
new import_obsidian4.Notice(`\u{1F4DD} Created daily note: ${filename}`);
return newFile;
} catch (e) {
console.error("Failed to create daily note:", e);
new import_obsidian3.Notice("Failed to create daily note");
new import_obsidian4.Notice("Failed to create daily note");
return null;
}
}
@@ -1227,7 +1708,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
const existingContent = await vault.read(file);
const newContent = existingContent.trimEnd() + "\n" + content + "\n";
await vault.modify(file, newContent);
new import_obsidian3.Notice("\u{1F4DD} Task logged to daily note");
new import_obsidian4.Notice("\u{1F4DD} Task logged to daily note");
}
// ============ Utilities ============
formatTime(seconds) {
@@ -1293,7 +1774,7 @@ var ImmersePlugin = class extends import_obsidian3.Plugin {
};
}
};
var ImmerseSettingTab = class extends import_obsidian3.PluginSettingTab {
var ImmerseSettingTab = class extends import_obsidian4.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
@@ -1303,41 +1784,41 @@ var ImmerseSettingTab = class extends import_obsidian3.PluginSettingTab {
containerEl.empty();
containerEl.createEl("h1", { text: "\u26A1 Immerse Settings" });
containerEl.createEl("h2", { text: "\u{1F345} Pomodoro Timer" });
new import_obsidian3.Setting(containerEl).setName("Work Duration").setDesc("Length of each work session in minutes").addSlider((slider) => slider.setLimits(5, 60, 5).setValue(this.plugin.settings.pomodoroWorkMinutes).setDynamicTooltip().onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Work Duration").setDesc("Length of each work session in minutes").addSlider((slider) => slider.setLimits(5, 60, 5).setValue(this.plugin.settings.pomodoroWorkMinutes).setDynamicTooltip().onChange(async (value) => {
this.plugin.settings.pomodoroWorkMinutes = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Short Break Duration").setDesc("Length of short breaks in minutes").addSlider((slider) => slider.setLimits(1, 15, 1).setValue(this.plugin.settings.pomodoroBreakMinutes).setDynamicTooltip().onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Short Break Duration").setDesc("Length of short breaks in minutes").addSlider((slider) => slider.setLimits(1, 15, 1).setValue(this.plugin.settings.pomodoroBreakMinutes).setDynamicTooltip().onChange(async (value) => {
this.plugin.settings.pomodoroBreakMinutes = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Long Break Duration").setDesc("Length of long breaks in minutes").addSlider((slider) => slider.setLimits(5, 30, 5).setValue(this.plugin.settings.longBreakMinutes).setDynamicTooltip().onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Long Break Duration").setDesc("Length of long breaks in minutes").addSlider((slider) => slider.setLimits(5, 30, 5).setValue(this.plugin.settings.longBreakMinutes).setDynamicTooltip().onChange(async (value) => {
this.plugin.settings.longBreakMinutes = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Long Break Interval").setDesc("Number of pomodoros before a long break").addSlider((slider) => slider.setLimits(2, 6, 1).setValue(this.plugin.settings.longBreakInterval).setDynamicTooltip().onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Long Break Interval").setDesc("Number of pomodoros before a long break").addSlider((slider) => slider.setLimits(2, 6, 1).setValue(this.plugin.settings.longBreakInterval).setDynamicTooltip().onChange(async (value) => {
this.plugin.settings.longBreakInterval = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Auto-start Breaks").setDesc("Automatically start break timer after work session").addToggle((toggle) => toggle.setValue(this.plugin.settings.autoStartBreak).onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Auto-start Breaks").setDesc("Automatically start break timer after work session").addToggle((toggle) => toggle.setValue(this.plugin.settings.autoStartBreak).onChange(async (value) => {
this.plugin.settings.autoStartBreak = value;
await this.plugin.saveAllData();
}));
containerEl.createEl("h2", { text: "\u2699\uFE0F General" });
new import_obsidian3.Setting(containerEl).setName("Default Time Estimate").setDesc("Default estimated time for new tasks in minutes").addSlider((slider) => slider.setLimits(5, 120, 5).setValue(this.plugin.settings.defaultEstimateMinutes).setDynamicTooltip().onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Default Time Estimate").setDesc("Default estimated time for new tasks in minutes").addSlider((slider) => slider.setLimits(5, 120, 5).setValue(this.plugin.settings.defaultEstimateMinutes).setDynamicTooltip().onChange(async (value) => {
this.plugin.settings.defaultEstimateMinutes = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Enable Sounds").setDesc("Play sounds for timer completion and task completion").addToggle((toggle) => toggle.setValue(this.plugin.settings.enableSounds).onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Enable Sounds").setDesc("Play sounds for timer completion and task completion").addToggle((toggle) => toggle.setValue(this.plugin.settings.enableSounds).onChange(async (value) => {
this.plugin.settings.enableSounds = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Enable Celebrations").setDesc("Show celebration messages when completing tasks").addToggle((toggle) => toggle.setValue(this.plugin.settings.enableCelebrations).onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Enable Celebrations").setDesc("Show celebration messages when completing tasks").addToggle((toggle) => toggle.setValue(this.plugin.settings.enableCelebrations).onChange(async (value) => {
this.plugin.settings.enableCelebrations = value;
await this.plugin.saveAllData();
}));
containerEl.createEl("h2", { text: "\u{1F4DD} Daily Note Integration" });
new import_obsidian3.Setting(containerEl).setName("Log completed tasks to daily note").setDesc("When you complete a task, add an entry to your daily note. Uses the core Daily Notes plugin settings.").addToggle((toggle) => toggle.setValue(this.plugin.settings.logToDaily).onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName("Log completed tasks to daily note").setDesc("When you complete a task, add an entry to your daily note. Uses the core Daily Notes plugin settings.").addToggle((toggle) => toggle.setValue(this.plugin.settings.logToDaily).onChange(async (value) => {
this.plugin.settings.logToDaily = value;
await this.plugin.saveAllData();
}));
@@ -1353,7 +1834,7 @@ var ImmerseSettingTab = class extends import_obsidian3.PluginSettingTab {
`;
containerEl.createEl("h2", { text: "\u{1F4CB} Lists" });
this.plugin.settings.lists.forEach((list, index) => {
new import_obsidian3.Setting(containerEl).setName(`${list.icon} ${list.name}`).addText((text) => text.setValue(list.name).setPlaceholder("List name").onChange(async (value) => {
new import_obsidian4.Setting(containerEl).setName(`${list.icon} ${list.name}`).addText((text) => text.setValue(list.name).setPlaceholder("List name").onChange(async (value) => {
this.plugin.settings.lists[index].name = value;
await this.plugin.saveAllData();
})).addText((text) => text.setValue(list.icon).setPlaceholder("Emoji").onChange(async (value) => {
@@ -1368,7 +1849,7 @@ var ImmerseSettingTab = class extends import_obsidian3.PluginSettingTab {
this.display();
}));
});
new import_obsidian3.Setting(containerEl).addButton((btn) => btn.setButtonText("+ Add List").onClick(async () => {
new import_obsidian4.Setting(containerEl).addButton((btn) => btn.setButtonText("+ Add List").onClick(async () => {
this.plugin.settings.lists.push({
id: this.plugin.generateId(),
name: "New List",