@canlooks/can-ui 0.0.149 → 0.0.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { Id, Obj } from '../types';
3
3
  /**
4
4
  * 获取UUID
5
5
  */
6
- export declare function getRandomId(): `${string}-${string}-${string}-${string}-${string}`;
6
+ export declare function getRandomId(): string;
7
7
  /**
8
8
  * 拼接元素的类名
9
9
  * @param classes
@@ -28,7 +28,11 @@ exports.mergeComponentProps = mergeComponentProps;
28
28
  * 获取UUID
29
29
  */
30
30
  function getRandomId() {
31
- return crypto.randomUUID();
31
+ if (typeof crypto.randomUUID === 'function') {
32
+ return crypto.randomUUID();
33
+ }
34
+ // polyfill for uuid v4
35
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c => (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16));
32
36
  }
33
37
  /**
34
38
  * 拼接元素的类名
@@ -3,7 +3,7 @@ import { Id, Obj } from '../types';
3
3
  /**
4
4
  * 获取UUID
5
5
  */
6
- export declare function getRandomId(): `${string}-${string}-${string}-${string}-${string}`;
6
+ export declare function getRandomId(): string;
7
7
  /**
8
8
  * 拼接元素的类名
9
9
  * @param classes
@@ -2,7 +2,11 @@
2
2
  * 获取UUID
3
3
  */
4
4
  export function getRandomId() {
5
- return crypto.randomUUID();
5
+ if (typeof crypto.randomUUID === 'function') {
6
+ return crypto.randomUUID();
7
+ }
8
+ // polyfill for uuid v4
9
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c => (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16));
6
10
  }
7
11
  /**
8
12
  * 拼接元素的类名
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.149",
3
+ "version": "0.0.150",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",