aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/ui/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'packages/ui/src/lib')
-rw-r--r--packages/ui/src/lib/effects/saturn.ts (renamed from packages/ui/src/lib/effects/SaturnEffect.ts)18
-rw-r--r--packages/ui/src/lib/tsrs-utils.ts67
2 files changed, 0 insertions, 85 deletions
diff --git a/packages/ui/src/lib/effects/SaturnEffect.ts b/packages/ui/src/lib/effects/saturn.ts
index 497a340..f7fcfe5 100644
--- a/packages/ui/src/lib/effects/SaturnEffect.ts
+++ b/packages/ui/src/lib/effects/saturn.ts
@@ -1,21 +1,3 @@
-/**
- * Ported SaturnEffect for the React UI (ui-new).
- * Adapted from the original Svelte implementation but written as a standalone
- * TypeScript class that manages a 2D canvas particle effect resembling a
- * rotating "Saturn" with rings. Designed to be instantiated and controlled
- * from a React component (e.g. ParticleBackground).
- *
- * Usage:
- * const effect = new SaturnEffect(canvasElement);
- * effect.handleMouseDown(clientX);
- * effect.handleMouseMove(clientX);
- * effect.handleMouseUp();
- * // on resize:
- * effect.resize(width, height);
- * // on unmount:
- * effect.destroy();
- */
-
export class SaturnEffect {
private canvas: HTMLCanvasElement;
private ctx: CanvasRenderingContext2D;
diff --git a/packages/ui/src/lib/tsrs-utils.ts b/packages/ui/src/lib/tsrs-utils.ts
deleted file mode 100644
index f48f851..0000000
--- a/packages/ui/src/lib/tsrs-utils.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-export type Maybe<T> = T | null | undefined;
-
-export function toNumber(
- value: Maybe<number | bigint | string>,
- fallback = 0,
-): number {
- if (value === null || value === undefined) return fallback;
-
- if (typeof value === "number") {
- if (Number.isFinite(value)) return value;
- return fallback;
- }
-
- if (typeof value === "bigint") {
- // safe conversion for typical values (timestamps, sizes). Might overflow for huge bigint.
- return Number(value);
- }
-
- if (typeof value === "string") {
- const n = Number(value);
- return Number.isFinite(n) ? n : fallback;
- }
-
- return fallback;
-}
-
-/**
- * Like `toNumber` but ensures non-negative result (clamps at 0).
- */
-export function toNonNegativeNumber(
- value: Maybe<number | bigint | string>,
- fallback = 0,
-): number {
- const n = toNumber(value, fallback);
- return n < 0 ? 0 : n;
-}
-
-export function toDate(
- value: Maybe<number | bigint | string>,
- opts?: { isSeconds?: boolean },
-): Date | null {
- if (value === null || value === undefined) return null;
-
- const isSeconds = opts?.isSeconds ?? true;
-
- // accept bigint, number, numeric string
- const n = toNumber(value, NaN);
- if (Number.isNaN(n)) return null;
-
- const ms = isSeconds ? Math.floor(n) * 1000 : Math.floor(n);
- return new Date(ms);
-}
-
-/**
- * Convert a binding boolean-ish value (0/1, "true"/"false", boolean) to boolean.
- */
-export function toBoolean(value: unknown, fallback = false): boolean {
- if (value === null || value === undefined) return fallback;
- if (typeof value === "boolean") return value;
- if (typeof value === "number") return value !== 0;
- if (typeof value === "string") {
- const s = value.toLowerCase().trim();
- if (s === "true" || s === "1") return true;
- if (s === "false" || s === "0") return false;
- }
- return fallback;
-}