Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ const buildOptions = {
],
format: "cjs",
target: "es2018",
// Compile import() of external modules to a deferred require(). Node
// built-ins (http, net, url) are imported lazily on desktop only, and a
// native import("http") would not resolve in Obsidian's renderer.
supported: { "dynamic-import": false },
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
Expand Down
15 changes: 8 additions & 7 deletions src/components/features/calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import type {
ExtendedCalendarConfig,
EventRenderContext,
DateCellContext,
ViewConfig,
} from "@taskgenius/calendar";
import * as dateFns from "date-fns";
import { addDays, startOfDay, differenceInDays, isBefore } from "date-fns";
Expand Down Expand Up @@ -74,9 +75,9 @@ type AgendaCalendarConfig = CustomCalendarViewConfig["calendarConfig"] &
Pick<AgendaViewOptions, "daysToShow" | "showEmptyDays">;

// Calendar config with the top-level maxEventsPerRow key set for month-based custom views
type CustomViewCalendarConfig = ExtendedCalendarConfig & {
interface CustomViewCalendarConfig extends ExtendedCalendarConfig {
maxEventsPerRow?: number;
};
}

// Metadata patch passed to WriteAPI.updateTask, which merges it into the task's metadata
type TaskMetadataUpdates = { metadata: Partial<StandardTaskMetadata> };
Expand Down Expand Up @@ -109,7 +110,7 @@ export class CalendarComponent extends Component {
private plugin: TaskProgressBarPlugin;

// @taskgenius/calendar instance (for all views including agenda/year)
private tgCalendar: Calendar | null = null;
private tgCalendar?: Calendar;

// View registry for custom views (agenda, year, and user-defined)
private viewRegistry: ViewRegistry = new ViewRegistry();
Expand Down Expand Up @@ -248,7 +249,7 @@ export class CalendarComponent extends Component {
// Clean up @taskgenius/calendar
if (this.tgCalendar) {
this.tgCalendar.destroy();
this.tgCalendar = null;
this.tgCalendar = undefined;
}

this.containerEl.empty();
Expand Down Expand Up @@ -597,7 +598,7 @@ export class CalendarComponent extends Component {
// Clean up previous views
if (this.tgCalendar) {
this.tgCalendar.destroy();
this.tgCalendar = null;
this.tgCalendar = undefined;
}

// Update view class
Expand Down Expand Up @@ -731,7 +732,7 @@ export class CalendarComponent extends Component {

// Build dayFilter based on config
// The filter functions return DayFilterResult which is accepted by the view config
let dayFilter: ReturnType<typeof hideWeekends> | undefined;
let dayFilter: ViewConfig["dayFilter"];
if (cc.dayFilter) {
switch (cc.dayFilter.type) {
case "hideWeekends":
Expand All @@ -754,7 +755,7 @@ export class CalendarComponent extends Component {

// Build timeFilter based on config (only for week/day views)
// The filter functions return TimeFilterResult which is accepted by the view config
let timeFilter: ReturnType<typeof workingHours> | undefined;
let timeFilter: ViewConfig["timeFilter"];
if (
cc.timeFilter?.enabled &&
(customConfig.baseViewType === "week" ||
Expand Down
12 changes: 6 additions & 6 deletions src/components/features/calendar/views/tg-agenda-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ export class TGAgendaView<T = unknown> extends BaseView<T> {
const currentDate = this.context.adapter.create(
this.context.currentDate,
);
const rangeStart = moment(currentDate as unknown as Date).startOf(
"day",
);
const rangeStart = moment(currentDate).startOf("day");
const rangeEnd = rangeStart
.clone()
.add(this.daysToShow - 1, "days")
Expand Down Expand Up @@ -160,14 +158,16 @@ export class TGAgendaView<T = unknown> extends BaseView<T> {
* Convert TGCalendarEvent to CalendarEvent
*/
protected convertEvents(events: TGCalendarEvent[]): CalendarEvent[] {
return events.map((e) => ({
// The TG events are built from tasks, so the results carry every task field
const converted: unknown = events.map((e) => ({
...e,
start: new Date(e.start),
end: e.end ? new Date(e.end) : undefined,
// Preserve original allDay value; default to true if not specified (most tasks are date-only)
allDay: (e as unknown as CalendarEvent).allDay ?? true,
metadata: e.metadata as CalendarEvent["metadata"],
})) as unknown as CalendarEvent[];
}));
return converted as CalendarEvent[];
}

/**
Expand Down Expand Up @@ -350,7 +350,7 @@ export class TGAgendaView<T = unknown> extends BaseView<T> {
const currentDate = this.context.adapter.create(
this.context.currentDate,
);
const start = moment(currentDate as unknown as Date);
const start = moment(currentDate);
const end = start.clone().add(this.daysToShow - 1, "days");

if (start.isSame(end, "month")) {
Expand Down
10 changes: 6 additions & 4 deletions src/components/features/calendar/views/tg-year-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class TGYearView<T = unknown> extends BaseView<T> {
const currentDate = this.context.adapter.create(
this.context.currentDate,
);
const year = moment(currentDate as unknown as Date).year();
const year = moment(currentDate).year();

container.empty();
container.addClass("view-year", "tg-year-view");
Expand Down Expand Up @@ -168,14 +168,16 @@ export class TGYearView<T = unknown> extends BaseView<T> {
* Convert TGCalendarEvent to CalendarEvent
*/
protected convertEvents(events: TGCalendarEvent[]): CalendarEvent[] {
return events.map((e) => ({
// The TG events are built from tasks, so the results carry every task field
const converted: unknown = events.map((e) => ({
...e,
start: new Date(e.start),
end: e.end ? new Date(e.end) : undefined,
// Preserve original allDay value; default to true if not specified (most tasks are date-only)
allDay: (e as unknown as CalendarEvent).allDay ?? true,
metadata: e.metadata as CalendarEvent["metadata"],
})) as unknown as CalendarEvent[];
}));
return converted as CalendarEvent[];
}

/**
Expand Down Expand Up @@ -550,7 +552,7 @@ export class TGYearView<T = unknown> extends BaseView<T> {
const currentDate = this.context.adapter.create(
this.context.currentDate,
);
return moment(currentDate as unknown as Date).format("YYYY");
return moment(currentDate).format("YYYY");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/features/fluent/FluentIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class FluentIntegration {
ws.rightSplit.expand();
// Restore focus to the currently active (incoming) leaf
if (leaf) ws.setActiveLeaf(leaf, { focus: true });
} catch (_) {
} catch {
// noop
} finally {
this.revealingSideLeaves = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export class FluentLayoutManager extends Component {
this.sidebar?.setCollapsed(true);
this.rootContainerEl?.addClass("fluent-sidebar-collapsed");
}
} catch (_) {
} catch {
// Ignore errors
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/features/settings/tabs/CalendarSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,7 @@ class TextReplacementModal extends Modal {
});

// Store references to update test output
let testInput: TextComponent;
let testInput: TextComponent | undefined;
let testOutput: HTMLElement;

// Colour the test output by state (.test-result.is-* in ics-settings.scss)
Expand Down Expand Up @@ -2207,7 +2207,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.pattern)
.onChange((value) => {
this.rule.pattern = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand All @@ -2226,7 +2226,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.replacement)
.onChange((value) => {
this.rule.replacement = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand All @@ -2245,7 +2245,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.flags || "")
.onChange((value) => {
this.rule.flags = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/components/features/settings/tabs/IcsSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ class TextReplacementModal extends Modal {
});

// Store references to update test output
let testInput: TextComponent;
let testInput: TextComponent | undefined;
let testOutput: HTMLElement;

// Colour the test output by state (.test-result.is-* in ics-settings.scss)
Expand Down Expand Up @@ -1433,7 +1433,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.pattern)
.onChange((value) => {
this.rule.pattern = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand All @@ -1452,7 +1452,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.replacement)
.onChange((value) => {
this.rule.replacement = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand All @@ -1471,7 +1471,7 @@ class TextReplacementModal extends Modal {
.setValue(this.rule.flags || "")
.onChange((value) => {
this.rule.flags = value;
if (testInput && testInput.getValue()) {
if (testInput?.getValue()) {
updateTestOutput(testInput.getValue());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ export function renderMcpIntegrationSettingsTab(

const toolsGrid = toolsSection.createDiv("mcp-tools-grid");
const toolsInfo = toolsSection.createDiv("mcp-tools-info");
toolsInfo.setText(t("Loading tools...") as string);
toolsInfo.setText(t("Loading tools..."));

async function renderDynamicTools() {
try {
Expand Down Expand Up @@ -1081,7 +1081,7 @@ export function renderMcpIntegrationSettingsTab(

toolsInfo.setText("");
if (!tools.length) {
toolsInfo.setText(t("No tools available") as string);
toolsInfo.setText(t("No tools available"));
return;
}

Expand All @@ -1100,7 +1100,7 @@ export function renderMcpIntegrationSettingsTab(
} catch (e) {
console.error("[MCP Tools] Failed to load tools:", e);
toolsInfo.setText(
t("Failed to load tools. Is the MCP server running?") as string
t("Failed to load tools. Is the MCP server running?"),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export function renderTaskStatusSettingsTab(
notStarted: [],
planned: [],
};
for (const [symbol, _, type] of statuses) {
for (const [symbol, , type] of statuses) {
if (type in statusMap) {
statusMap[type].push(symbol);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ export function renderTaskStatusSettingsTab(
notStarted: [],
planned: [],
};
for (const [symbol, _, type] of statuses) {
for (const [symbol, , type] of statuses) {
if (type in statusMap) {
statusMap[type].push(symbol);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/features/task/filter/ViewTaskFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,9 @@ export class TaskFilterComponent extends Component {
}

conditionSelect.selectEl.empty();
conditionOptions.forEach((opt) =>
conditionSelect.addOption(opt.value, opt.text),
);
conditionOptions.forEach((opt) => {
conditionSelect.addOption(opt.value, opt.text);
});

const currentSelectedCondition = filterData.condition;
let conditionChanged = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ export class TimelineSidebarView extends ItemView {
: `${minutes}m`;
timeEl.setAttribute("data-duration", duration);
}
} catch (_) {
} catch {
// The duration badge is optional; skip it if the times can't be compared
}
} else {
Expand Down
8 changes: 6 additions & 2 deletions src/components/ui/date-picker/DatePickerComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export class DatePickerComponent extends Component {
});

// Add quick date options
const quickOptions = [
const quickOptions: {
amount: number;
unit: moment.unitOfTime.DurationConstructor;
label: string;
}[] = [
{ amount: 0, unit: "days", label: t("Today") },
{ amount: 1, unit: "days", label: t("Tomorrow") },
{ amount: 2, unit: "days", label: t("In 2 days") },
Expand Down Expand Up @@ -119,7 +123,7 @@ export class DatePickerComponent extends Component {

const date = moment().add(
option.amount,
option.unit as moment.unitOfTime.DurationConstructor
option.unit
);
const formattedDate = date.format("YYYY-MM-DD");

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/modals/CalendarViewConfigModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export class CalendarViewConfigModal extends Modal {
if (!timeFilter) return;

const formatHour = (h: number) => `${h.toString().padStart(2, "0")}:00`;
(el as HTMLElement).textContent =
el.textContent =
`${formatHour(timeFilter.startHour)} - ${formatHour(timeFilter.endHour)}`;
}

Expand Down
8 changes: 4 additions & 4 deletions src/dataflow/workers/ProjectDataWorkerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,26 +388,26 @@ export class ProjectDataWorkerManager {
message: WorkerMessage
): Promise<WorkerResponse<T>> {
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
const timeout = window.setTimeout(() => {
this.pendingRequests.delete(message.requestId);
reject(new Error("Worker request timeout"));
}, 30000); // 30 second timeout

this.pendingRequests.set(message.requestId, {
resolve: (response) => {
clearTimeout(timeout);
window.clearTimeout(timeout);
resolve(response as WorkerResponse<T>);
},
reject: (error) => {
clearTimeout(timeout);
window.clearTimeout(timeout);
reject(error instanceof Error ? error : new Error(String(error)));
},
});

try {
worker.postMessage(message);
} catch (error) {
clearTimeout(timeout);
window.clearTimeout(timeout);
this.pendingRequests.delete(message.requestId);
reject(error instanceof Error ? error : new Error(String(error)));
}
Expand Down
Loading
Loading