Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]>
40 lines
1.2 KiB
TypeScript
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());
|