mirror of
https://github.com/basketikun/infinite-canvas.git
synced 2026-08-04 16:14:22 +08:00
feat(id): replace crypto.randomUUID with nanoid for unique ID generation
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique id.
|
||||
*
|
||||
* Avoid `crypto.randomUUID`, which is only exposed in secure contexts (HTTPS or
|
||||
* localhost) — over plain HTTP it is undefined and throws. `nanoid` works in any
|
||||
* context.
|
||||
*/
|
||||
export function randomId(): string {
|
||||
return nanoid();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user