Replace all crypto.randomUUID() calls with a uuid() utility that falls back to Math.random-based generation when the Web Crypto API is unavailable (plain HTTP contexts). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,16 @@ export function formatFlops(n: number): string {
|
||||
return `${formatNumber(n)} FLOPS`;
|
||||
}
|
||||
|
||||
export function uuid(): string {
|
||||
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0;
|
||||
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
export function formatDuration(ticks: number): string {
|
||||
if (ticks < 60) return `${ticks}s`;
|
||||
if (ticks < 3600) return `${Math.floor(ticks / 60)}m ${ticks % 60}s`;
|
||||
|
||||
Reference in New Issue
Block a user