diff --git a/package.json b/package.json index 4ca0609..3c4a11a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reactivexcomponent.js", - "version": "7.0.7", + "version": "7.0.8", "description": "Javascript reactive client API for XComponent", "module": "dist/index.js", "main": "dist/index.js", diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts index ceac18e..24ef220 100644 --- a/src/utils/uuid.ts +++ b/src/utils/uuid.ts @@ -1,3 +1,12 @@ export function generateUUID(): string { - return crypto.randomUUID(); + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } + + // Fallback (non cryptographique) + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c: string): string { + const r = Math.floor(Math.random() * 16); // évite l'opérateur bitwise + const v = c === 'x' ? r : (r % 4) + 8; // remplace (r & 0x3 | 0x8) + return v.toString(16); + }); }