diff --git a/src/scripts/ui/spinner.js b/src/scripts/ui/spinner.js index d049786f6a..07a19d70c6 100644 --- a/src/scripts/ui/spinner.js +++ b/src/scripts/ui/spinner.js @@ -1,4 +1,4 @@ -import { addStylesheet } from "../utils.js"; +import { addStylesheet } from "../utils"; addStylesheet(import.meta.url); diff --git a/src/scripts/ui/userSelection.js b/src/scripts/ui/userSelection.js index 273809191b..b6fa581135 100644 --- a/src/scripts/ui/userSelection.js +++ b/src/scripts/ui/userSelection.js @@ -1,6 +1,6 @@ import { api } from "../api.js"; import { $el } from "../ui"; -import { addStylesheet } from "../utils.js"; +import { addStylesheet } from "../utils"; import { createSpinner } from "./spinner.js"; export class UserSelectionScreen { diff --git a/src/scripts/utils.js b/src/scripts/utils.ts similarity index 84% rename from src/scripts/utils.js rename to src/scripts/utils.ts index 91bc9a28ed..fe05ffe983 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.ts @@ -1,3 +1,4 @@ +import type { ComfyApp } from "./app"; import { $el } from "./ui"; // Simple date formatter @@ -13,10 +14,10 @@ const format = .map((k) => k + k + "?") .join("|") + "|yyy?y?"; -function formatDate(text, date) { - return text.replace(new RegExp(format, "g"), function (text) { +function formatDate(text: string, date: Date) { + return text.replace(new RegExp(format, "g"), (text: string): string => { if (text === "yy") return (date.getFullYear() + "").substring(2); - if (text === "yyyy") return date.getFullYear(); + if (text === "yyyy") return date.getFullYear().toString(); if (text[0] in parts) { const p = parts[text[0]](date); return (p + "").padStart(text.length, "0"); @@ -25,7 +26,7 @@ function formatDate(text, date) { }); } -export function applyTextReplacements(app, value) { +export function applyTextReplacements(app: ComfyApp, value: string): string { return value.replace(/%([^%]+)%/g, function (match, text) { const split = text.split("."); if (split.length !== 2) { @@ -68,7 +69,7 @@ export function applyTextReplacements(app, value) { }); } -export async function addStylesheet(urlOrFile, relativeTo) { +export async function addStylesheet(urlOrFile: string, relativeTo?: string): Promise { return new Promise((res, rej) => { let url; if (urlOrFile.endsWith(".js")) {