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";
6import { DraftId } from "../composerDraftStore";
7
8export function cn(...inputs: CxOptions) {
9 return twMerge(cx(inputs));
10}
11
12export function isMacPlatform(platform: string): boolean {
13 return /mac|iphone|ipad|ipod/i.test(platform);
14}
15
16export function isWindowsPlatform(platform: string): boolean {
17 return /^win(dows)?/i.test(platform);
18}
19
20export function isLinuxPlatform(platform: string): boolean {
21 return /linux/i.test(platform);
22}
23
24export function randomUUID(): string {
25 if (typeof crypto.randomUUID === "function") {
26 return crypto.randomUUID();
27 }
28 return Effect.runSync(Random.nextUUIDv4);
29}
30
31export const newCommandId = (): CommandId => CommandId.make(randomUUID());
32
33export const newProjectId = (): ProjectId => ProjectId.make(randomUUID());
34
35export const newThreadId = (): ThreadId => ThreadId.make(randomUUID());
36
37export const newDraftId = (): DraftId => DraftId.make(randomUUID());
38
39export const newMessageId = (): MessageId => MessageId.make(randomUUID());