Files
t3code/apps/web/src/lib/utils.ts
T
3405a64dd8 bump effect to latest beta (#1866)
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: codex <[email protected]>
2026-04-10 01:51:31 -07:00

40 lines
1.2 KiB
TypeScript

import { CommandId, MessageId, ProjectId, ThreadId } from "@t3tools/contracts";
import { type CxOptions, cx } from "class-variance-authority";
import { twMerge } from "tailwind-merge";
import * as Random from "effect/Random";
import * as Effect from "effect/Effect";
import { DraftId } from "../composerDraftStore";
export function cn(...inputs: CxOptions) {
return twMerge(cx(inputs));
}
export function isMacPlatform(platform: string): boolean {
return /mac|iphone|ipad|ipod/i.test(platform);
}
export function isWindowsPlatform(platform: string): boolean {
return /^win(dows)?/i.test(platform);
}
export function isLinuxPlatform(platform: string): boolean {
return /linux/i.test(platform);
}
export function randomUUID(): string {
if (typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
return Effect.runSync(Random.nextUUIDv4);
}
export const newCommandId = (): CommandId => CommandId.make(randomUUID());
export const newProjectId = (): ProjectId => ProjectId.make(randomUUID());
export const newThreadId = (): ThreadId => ThreadId.make(randomUUID());
export const newDraftId = (): DraftId => DraftId.make(randomUUID());
export const newMessageId = (): MessageId => MessageId.make(randomUUID());