Open History to see the last commit
1import { CommandId, MessageId, ProjectId, ThreadId } from "@t3tools/contracts";
2import { type CxOptions, cx } from "class-variance-authority";
3import { twMerge } from "tailwind-merge";
4import * as Random from "effect/Random";
5import * as Effect from "effect/Effect";
6
7export function cn(...inputs: CxOptions) {
8 return twMerge(cx(inputs));
9}
10
11export function isMacPlatform(platform: string): boolean {
12 return /mac|iphone|ipad|ipod/i.test(platform);
13}
14
15export function isWindowsPlatform(platform: string): boolean {
16 return /^win(dows)?/i.test(platform);
17}
18
19export function isLinuxPlatform(platform: string): boolean {
20 return /linux/i.test(platform);
21}
22
23export function randomUUID(): string {
24 if (typeof crypto.randomUUID === "function") {
25 return crypto.randomUUID();
26 }
27 return Effect.runSync(Random.nextUUIDv4);
28}
29
30export const newCommandId = (): CommandId => CommandId.makeUnsafe(randomUUID());
31
32export const newProjectId = (): ProjectId => ProjectId.makeUnsafe(randomUUID());
33
34export const newThreadId = (): ThreadId => ThreadId.makeUnsafe(randomUUID());
35
36export const newMessageId = (): MessageId => MessageId.makeUnsafe(randomUUID());