From 65449336fb5f28bb8e7ca066f414c545c8b9819d Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 16 Jan 2023 22:56:21 +0000 Subject: [PATCH] ClockFace.d.ts --- typescript/types/ClockFace.d.ts | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 typescript/types/ClockFace.d.ts diff --git a/typescript/types/ClockFace.d.ts b/typescript/types/ClockFace.d.ts new file mode 100644 index 000000000..173b83c39 --- /dev/null +++ b/typescript/types/ClockFace.d.ts @@ -0,0 +1,56 @@ +declare module ClockFace_ { + export class ClockFace { + constructor(options: Options | Draw); + + is12Hour: boolean; + paused: boolean; + showDate: boolean; // default true + loadWidgets: boolean; // default true + + start(): void; + + tick(): void; + pause(): void; + resume(): void; + remove(): void; + redraw(): void; + } + + type Options = { + precision?: number, // seconds + + init?: () => void, + + pause?: () => void, + resume?: () => void, + remove?: () => void, + + settingsFile?: string, + } & ( + { + draw: Draw + } | { + update: Update, + } | { + draw: Draw, + update: Update, + } + ) & ( + { + up?: () => void, + down?: () => void, + } | { + upDown?: (dir: -1 | 1) => void, + } + ); + + type Draw = (d: Date, changed: Changed) => void; + type Update = (d: Date, changed: Changed) => void; + + type Changed = { + d: T, + h: T, + m: T, + s: T, + } +}