@arcgis/toolkit 4.34.0-next.85 → 4.34.0-next.88

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.
@@ -55,17 +55,17 @@ const addLtrMark = (value) => (
55
55
  // Make sure the string value is LTR. This prevent issues with RTL language used in LTR containers.
56
56
  `‎${value ?? ""}‎`
57
57
  );
58
- const getGuidPart = (segmentCount) => {
59
- let out = "";
60
- for (let i = 0; i < segmentCount; i++) {
61
- out += ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
58
+ const hasRandomUUID = "randomUUID" in crypto;
59
+ const generateGuid = () => {
60
+ if (hasRandomUUID) {
61
+ return crypto.randomUUID();
62
62
  }
63
- return out;
63
+ const values = crypto.getRandomValues(new Uint16Array(8));
64
+ values[3] = values[3] & 4095 | 16384;
65
+ values[4] = values[4] & 16383 | 32768;
66
+ const p = (i) => values[i].toString(16).padStart(4, "0");
67
+ return `${p(0) + p(1)}-${p(2)}-${p(3)}-${p(4)}-${p(5)}${p(6)}${p(7)}`;
64
68
  };
65
- const generateGuid = () => (
66
- //#endregion generateGuid
67
- [getGuidPart(2), getGuidPart(1), getGuidPart(1), getGuidPart(1), getGuidPart(3)].join("-")
68
- );
69
69
  const getMinorVersion = (version) => {
70
70
  const [major, minor] = version.split(".");
71
71
  return `${major}.${minor}`;
@@ -56,6 +56,10 @@ export declare const createFilterExpression: (filterWord: string) => RegExp;
56
56
  * return <div>{addLtrMark("$arcadeVariable")}</div>;
57
57
  */
58
58
  export declare const addLtrMark: (value: string | undefined) => string;
59
+ /**
60
+ * A string containing a randomly generated, 36 character long v4 UUID.
61
+ */
62
+ export type UUID = ReturnType<typeof crypto.randomUUID>;
59
63
  /**
60
64
  * Generate a GUID string.
61
65
  * @example
@@ -68,7 +72,7 @@ export declare const addLtrMark: (value: string | undefined) => string;
68
72
  * If your component is using shadow root, the DOM element IDs do not need
69
73
  * to be globally unique.
70
74
  */
71
- export declare const generateGuid: () => string;
75
+ export declare const generateGuid: () => UUID;
72
76
  /**
73
77
  * Extract the major and minor version from a full version string.
74
78
  *
@@ -56,6 +56,10 @@ export declare const createFilterExpression: (filterWord: string) => RegExp;
56
56
  * return <div>{addLtrMark("$arcadeVariable")}</div>;
57
57
  */
58
58
  export declare const addLtrMark: (value: string | undefined) => string;
59
+ /**
60
+ * A string containing a randomly generated, 36 character long v4 UUID.
61
+ */
62
+ export type UUID = ReturnType<typeof crypto.randomUUID>;
59
63
  /**
60
64
  * Generate a GUID string.
61
65
  * @example
@@ -68,7 +72,7 @@ export declare const addLtrMark: (value: string | undefined) => string;
68
72
  * If your component is using shadow root, the DOM element IDs do not need
69
73
  * to be globally unique.
70
74
  */
71
- export declare const generateGuid: () => string;
75
+ export declare const generateGuid: () => UUID;
72
76
  /**
73
77
  * Extract the major and minor version from a full version string.
74
78
  *
@@ -53,17 +53,17 @@ const addLtrMark = (value) => (
53
53
  // Make sure the string value is LTR. This prevent issues with RTL language used in LTR containers.
54
54
  `‎${value ?? ""}‎`
55
55
  );
56
- const getGuidPart = (segmentCount) => {
57
- let out = "";
58
- for (let i = 0; i < segmentCount; i++) {
59
- out += ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
56
+ const hasRandomUUID = "randomUUID" in crypto;
57
+ const generateGuid = () => {
58
+ if (hasRandomUUID) {
59
+ return crypto.randomUUID();
60
60
  }
61
- return out;
61
+ const values = crypto.getRandomValues(new Uint16Array(8));
62
+ values[3] = values[3] & 4095 | 16384;
63
+ values[4] = values[4] & 16383 | 32768;
64
+ const p = (i) => values[i].toString(16).padStart(4, "0");
65
+ return `${p(0) + p(1)}-${p(2)}-${p(3)}-${p(4)}-${p(5)}${p(6)}${p(7)}`;
62
66
  };
63
- const generateGuid = () => (
64
- //#endregion generateGuid
65
- [getGuidPart(2), getGuidPart(1), getGuidPart(1), getGuidPart(1), getGuidPart(3)].join("-")
66
- );
67
67
  const getMinorVersion = (version) => {
68
68
  const [major, minor] = version.split(".");
69
69
  return `${major}.${minor}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/toolkit",
3
- "version": "4.34.0-next.85",
3
+ "version": "4.34.0-next.88",
4
4
  "description": "Collection of common internal patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "sideEffects": false,