Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
/**
|
|
* Small, pure display helpers shared by the creator profile + leaderboard UI.
|
|
* They only ever read SAFE public fields (handle / display_name + public
|
|
* aggregates) — never any private datum — so they are safe to use on every
|
|
* public surface.
|
|
*/
|
|
|
|
/** Identity subset shared by {@link CreatorProfile} and {@link LeaderboardEntry}. */
|
|
export interface CreatorIdentity {
|
|
handle: string;
|
|
display_name: string;
|
|
}
|
|
|
|
/** Primary label for a creator: display name → "@handle" → generic fallback. */
|
|
export function creatorTitle(identity: CreatorIdentity): string {
|
|
const name = (identity.display_name || "").trim();
|
|
if (name) return name;
|
|
const handle = (identity.handle || "").trim();
|
|
if (handle) return `@${handle}`;
|
|
return "Creator";
|
|
}
|
|
|
|
/**
|
|
* Secondary label ("@handle") shown under the title — blank when the handle is
|
|
* unset or would just duplicate the title.
|
|
*/
|
|
export function creatorSubtitle(identity: CreatorIdentity): string {
|
|
const handle = (identity.handle || "").trim();
|
|
if (!handle) return "";
|
|
const name = (identity.display_name || "").trim();
|
|
return name ? `@${handle}` : "";
|
|
}
|
|
|
|
/** Compact count, e.g. 1200 → "1.2k", 3_400_000 → "3.4M". Non-finite → "0". */
|
|
export function formatCompact(value: number): string {
|
|
if (!Number.isFinite(value)) return "0";
|
|
const abs = Math.abs(value);
|
|
if (abs >= 1_000_000) {
|
|
return `${(value / 1_000_000).toFixed(abs >= 10_000_000 ? 0 : 1)}M`;
|
|
}
|
|
if (abs >= 1_000) {
|
|
return `${(value / 1_000).toFixed(abs >= 10_000 ? 0 : 1)}k`;
|
|
}
|
|
return `${Math.round(value)}`;
|
|
}
|
|
|
|
/** Rating in [0,5] as one decimal, or an em dash when never rated. */
|
|
export function formatRating(value: number): string {
|
|
return Number.isFinite(value) && value > 0 ? value.toFixed(1) : "—";
|
|
}
|