From afca3eeba98f0e059e5b3a812fca3136de36dea2 Mon Sep 17 00:00:00 2001 From: DecafDev <40307803+decaf-dev@users.noreply.github.com> Date: Fri, 2 May 2025 20:47:14 -0600 Subject: [PATCH 1/2] fix: use correct types for moment.js --- src/svelte/app/services/time-string.ts | 8 +++++--- src/svelte/shared/services/time-utils.ts | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/svelte/app/services/time-string.ts b/src/svelte/app/services/time-string.ts index 8630e43..5944562 100644 --- a/src/svelte/app/services/time-string.ts +++ b/src/svelte/app/services/time-string.ts @@ -1,8 +1,10 @@ -import { moment } from "obsidian"; +import { moment as _moment } from "obsidian"; + +const moment = _moment as unknown as typeof _moment.default; export const formatAsBearTimeString = (milliseconds: number) => { - const now = (moment as any)(); - const time = (moment as any)(milliseconds); + const now = moment(); + const time = moment(milliseconds); const diffInSeconds = now.diff(time, "seconds"); const diffInMinutes = now.diff(time, "minutes"); diff --git a/src/svelte/shared/services/time-utils.ts b/src/svelte/shared/services/time-utils.ts index d2a51b3..71373c8 100644 --- a/src/svelte/shared/services/time-utils.ts +++ b/src/svelte/shared/services/time-utils.ts @@ -1,4 +1,6 @@ -import { moment } from "obsidian"; +import { moment as _moment } from "obsidian"; + +const moment = _moment as unknown as typeof _moment.default; const DATE_FORMATS = ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DDTHH:mm", "YYYY-MM-DD"]; @@ -7,7 +9,7 @@ const DATE_FORMATS = ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DDTHH:mm", "YYYY-MM-DD"]; * @returns - The current time in milliseconds */ export const getStartOfTodayMillis = () => { - return (moment as any)().startOf("day").valueOf(); + return moment().startOf("day").valueOf(); }; /** @@ -16,7 +18,7 @@ export const getStartOfTodayMillis = () => { * @returns - The start of the day in milliseconds */ export const getStartOfDayMillis = (date: string) => { - return (moment as any)(date).startOf("day").valueOf(); + return moment(date).startOf("day").valueOf(); }; /** @@ -24,19 +26,19 @@ export const getStartOfDayMillis = (date: string) => { * @returns - The start of the week in milliseconds */ export const getStartOfThisWeekMillis = () => { - return (moment as any)().startOf("week").valueOf(); + return moment().startOf("week").valueOf(); }; export const getMomentDate = (date: string) => { - return (moment as any)(date, DATE_FORMATS, true); + return moment(date, DATE_FORMATS, true); }; export const getDateDaysAgo = (daysAgo: number) => { - return (moment as any)().subtract(daysAgo, "days").format("YYYY-MM-DD"); + return moment().subtract(daysAgo, "days").format("YYYY-MM-DD"); }; export const getDateDaysAhead = (daysAgo: number) => { - return (moment as any)().add(daysAgo, "days").format("YYYY-MM-DD"); + return moment().add(daysAgo, "days").format("YYYY-MM-DD"); }; /** @@ -45,7 +47,7 @@ export const getDateDaysAhead = (daysAgo: number) => { */ export const getStartOfLastWeekMillis = () => { //This is the Sunday the previous week - return (moment as any)().subtract(1, "weeks").startOf("week").valueOf(); + return moment().subtract(1, "weeks").startOf("week").valueOf(); }; /** @@ -54,7 +56,7 @@ export const getStartOfLastWeekMillis = () => { * @returns - The date in milliseconds */ export const getTimeMillis = (date: string) => { - const momentDate = (moment as any)(date, DATE_FORMATS, true); + const momentDate = moment(date, DATE_FORMATS, true); if (!momentDate.isValid()) { throw new Error(`Date format not handled: ${date}`); @@ -68,7 +70,7 @@ export const getTimeMillis = (date: string) => { * @returns - True if the date is supported, false otherwise */ export const isDateSupported = (date: string) => { - const momentDate = (moment as any)(date, DATE_FORMATS, true); + const momentDate = moment(date, DATE_FORMATS, true); return momentDate.isValid(); }; @@ -78,7 +80,7 @@ export const isDateSupported = (date: string) => { * @returns - The end of the day in milliseconds */ export const getEndOfDayMillis = (date: string) => { - const day = (moment as any)(date); + const day = moment(date); day.set({ hour: 23, minute: 59, From 911695e190ed6dd9473caaf6d233fa596d01eb0f Mon Sep 17 00:00:00 2001 From: DecafDev <40307803+decaf-dev@users.noreply.github.com> Date: Fri, 2 May 2025 20:47:30 -0600 Subject: [PATCH 2/2] chore: bump version --- manifest.json | 2 +- package.json | 2 +- versions.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 46a6077..2c3b884 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-explorer", "name": "Vault Explorer", - "version": "1.47.2", + "version": "1.47.3", "minAppVersion": "1.4.13", "description": "Explore your vault in visual format", "author": "DecafDev", diff --git a/package.json b/package.json index 94078e4..bac241c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vault-explorer", - "version": "1.47.2", + "version": "1.47.3", "description": "Explore your vault in visual format", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index d40cc1b..4b7b41d 100644 --- a/versions.json +++ b/versions.json @@ -152,5 +152,6 @@ "1.46.0": "1.4.13", "1.47.0": "1.4.13", "1.47.1": "1.4.13", - "1.47.2": "1.4.13" + "1.47.2": "1.4.13", + "1.47.3": "1.4.13" }