@arcgis/toolkit 4.34.0-next.61

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.
Files changed (43) hide show
  1. package/LICENSE.md +13 -0
  2. package/README.md +21 -0
  3. package/dist/array/index.cjs +12 -0
  4. package/dist/array/index.d.cts +12 -0
  5. package/dist/array/index.d.ts +12 -0
  6. package/dist/array/index.js +12 -0
  7. package/dist/dom/index.cjs +161 -0
  8. package/dist/dom/index.d.cts +115 -0
  9. package/dist/dom/index.d.ts +115 -0
  10. package/dist/dom/index.js +161 -0
  11. package/dist/error/index.cjs +36 -0
  12. package/dist/error/index.d.cts +32 -0
  13. package/dist/error/index.d.ts +32 -0
  14. package/dist/error/index.js +36 -0
  15. package/dist/function/index.cjs +16 -0
  16. package/dist/function/index.d.cts +19 -0
  17. package/dist/function/index.d.ts +19 -0
  18. package/dist/function/index.js +16 -0
  19. package/dist/intl/index.cjs +103 -0
  20. package/dist/intl/index.d.cts +121 -0
  21. package/dist/intl/index.d.ts +121 -0
  22. package/dist/intl/index.js +103 -0
  23. package/dist/predicate/index.cjs +8 -0
  24. package/dist/predicate/index.d.cts +24 -0
  25. package/dist/predicate/index.d.ts +24 -0
  26. package/dist/predicate/index.js +8 -0
  27. package/dist/promise/index.cjs +30 -0
  28. package/dist/promise/index.d.cts +46 -0
  29. package/dist/promise/index.d.ts +46 -0
  30. package/dist/promise/index.js +30 -0
  31. package/dist/string/index.cjs +91 -0
  32. package/dist/string/index.d.cts +102 -0
  33. package/dist/string/index.d.ts +102 -0
  34. package/dist/string/index.js +91 -0
  35. package/dist/tests/utils.d.cts +1 -0
  36. package/dist/tests/utils.d.ts +1 -0
  37. package/dist/type/index.d.cts +15 -0
  38. package/dist/type/index.d.ts +15 -0
  39. package/dist/url/index.cjs +26 -0
  40. package/dist/url/index.d.cts +18 -0
  41. package/dist/url/index.d.ts +18 -0
  42. package/dist/url/index.js +26 -0
  43. package/package.json +66 -0
@@ -0,0 +1,24 @@
1
+ import { nil } from '../type';
2
+ /**
3
+ * Safeguard to ensure that an item is not undefined.
4
+ * @param item The item to check.
5
+ * @returns Returns true if the item is not undefined.
6
+ * @example
7
+ * ```ts
8
+ * const arr = [1, undefined, 3];
9
+ * const result = arr.filter(isNotUndefined);
10
+ * ```
11
+ */
12
+ export declare const isNotUndefined: <T>(item: T | undefined) => item is T;
13
+ /**
14
+ * Safeguard to ensure that an item is not null.
15
+ * @param item The item to check.
16
+ * @returns Returns true if the item is not null.
17
+ */
18
+ export declare const isNotNull: <T>(item: T | null) => item is T;
19
+ /**
20
+ * Safeguard to ensure that an item is not null.
21
+ * @param item The item to check.
22
+ * @returns Returns true if the item is not and not undefined and not null.
23
+ */
24
+ export declare const isNotNil: <T>(x: nil | T) => x is T;
@@ -0,0 +1,8 @@
1
+ const isNotUndefined = (item) => item !== void 0;
2
+ const isNotNull = (item) => item !== null;
3
+ const isNotNil = (x) => x != null;
4
+ export {
5
+ isNotNil,
6
+ isNotNull,
7
+ isNotUndefined
8
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ class Deferred {
4
+ /**
5
+ * Creates a new deferred promise.
6
+ */
7
+ constructor() {
8
+ this.promise = new Promise((resolve, reject) => {
9
+ this.resolve = resolve;
10
+ this.reject = reject;
11
+ });
12
+ }
13
+ }
14
+ const devToolsAwareTimeout = (callback, timeout) => {
15
+ const interval = timeout > longTimeoutThreshold ? longTimeoutInterval : timeout / shortTimeoutIntervals;
16
+ let elapsed = 0;
17
+ const reference = setInterval(() => {
18
+ elapsed += interval;
19
+ if (elapsed >= timeout) {
20
+ clearInterval(reference);
21
+ callback();
22
+ }
23
+ }, interval);
24
+ return reference;
25
+ };
26
+ const longTimeoutThreshold = 4e3;
27
+ const longTimeoutInterval = 2e3;
28
+ const shortTimeoutIntervals = 4;
29
+ exports.Deferred = Deferred;
30
+ exports.devToolsAwareTimeout = devToolsAwareTimeout;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A deferred promise.
3
+ * Useful for when you want to return a promise but don't have the value yet.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const deferred = new Deferred<string>();
8
+ * setTimeout(() => deferred.resolve("Hello World"), 1000);
9
+ * return deferred.promise;
10
+ * ```
11
+ *
12
+ * @deprecated
13
+ * If browser support permits, prefer using
14
+ * [Promise.withResolvers()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers)
15
+ */
16
+ export declare class Deferred<T> {
17
+ /**
18
+ * The promise that can be awaited.
19
+ */
20
+ promise: Promise<T>;
21
+ /**
22
+ * Creates a new deferred promise.
23
+ */
24
+ constructor();
25
+ }
26
+ export interface Deferred<T> {
27
+ /**
28
+ * Resolves the promise.
29
+ * @param value The value to resolve the promise with.
30
+ *
31
+ * @privateRemarks
32
+ * Defined as a method to disable covariance checks. Overridden in constructor.
33
+ */
34
+ resolve(_value: PromiseLike<T> | T): void;
35
+ /**
36
+ * Rejects the promise.
37
+ */
38
+ reject(_error: unknown): void;
39
+ }
40
+ /**
41
+ * Like setTimeout(), but does not advance the clock if the program is
42
+ * stopped on a debugger breakpoint.
43
+ *
44
+ * @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60405
45
+ */
46
+ export declare const devToolsAwareTimeout: (callback: () => void, timeout: number) => ReturnType<typeof setInterval>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A deferred promise.
3
+ * Useful for when you want to return a promise but don't have the value yet.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const deferred = new Deferred<string>();
8
+ * setTimeout(() => deferred.resolve("Hello World"), 1000);
9
+ * return deferred.promise;
10
+ * ```
11
+ *
12
+ * @deprecated
13
+ * If browser support permits, prefer using
14
+ * [Promise.withResolvers()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers)
15
+ */
16
+ export declare class Deferred<T> {
17
+ /**
18
+ * The promise that can be awaited.
19
+ */
20
+ promise: Promise<T>;
21
+ /**
22
+ * Creates a new deferred promise.
23
+ */
24
+ constructor();
25
+ }
26
+ export interface Deferred<T> {
27
+ /**
28
+ * Resolves the promise.
29
+ * @param value The value to resolve the promise with.
30
+ *
31
+ * @privateRemarks
32
+ * Defined as a method to disable covariance checks. Overridden in constructor.
33
+ */
34
+ resolve(_value: PromiseLike<T> | T): void;
35
+ /**
36
+ * Rejects the promise.
37
+ */
38
+ reject(_error: unknown): void;
39
+ }
40
+ /**
41
+ * Like setTimeout(), but does not advance the clock if the program is
42
+ * stopped on a debugger breakpoint.
43
+ *
44
+ * @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60405
45
+ */
46
+ export declare const devToolsAwareTimeout: (callback: () => void, timeout: number) => ReturnType<typeof setInterval>;
@@ -0,0 +1,30 @@
1
+ class Deferred {
2
+ /**
3
+ * Creates a new deferred promise.
4
+ */
5
+ constructor() {
6
+ this.promise = new Promise((resolve, reject) => {
7
+ this.resolve = resolve;
8
+ this.reject = reject;
9
+ });
10
+ }
11
+ }
12
+ const devToolsAwareTimeout = (callback, timeout) => {
13
+ const interval = timeout > longTimeoutThreshold ? longTimeoutInterval : timeout / shortTimeoutIntervals;
14
+ let elapsed = 0;
15
+ const reference = setInterval(() => {
16
+ elapsed += interval;
17
+ if (elapsed >= timeout) {
18
+ clearInterval(reference);
19
+ callback();
20
+ }
21
+ }, interval);
22
+ return reference;
23
+ };
24
+ const longTimeoutThreshold = 4e3;
25
+ const longTimeoutInterval = 2e3;
26
+ const shortTimeoutIntervals = 4;
27
+ export {
28
+ Deferred,
29
+ devToolsAwareTimeout
30
+ };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const kebabToPascal = (string) => (
4
+ //#endregion kebabToPascal
5
+ string.split("-").map(capitalize).join("")
6
+ );
7
+ const camelToKebab = (string) => (
8
+ //#endregion camelToKebab
9
+ string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`)
10
+ );
11
+ const upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
12
+ const camelToHuman = (string) => (
13
+ //#endregion camelToHuman
14
+ capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`))
15
+ );
16
+ const capitalize = (string) => (
17
+ //#endregion capitalize
18
+ string.charAt(0).toUpperCase() + string.slice(1)
19
+ );
20
+ const uncapitalize = (string) => (
21
+ //#endregion uncapitalize
22
+ string.charAt(0).toLowerCase() + string.slice(1)
23
+ );
24
+ const doubleQuote = '"';
25
+ const singleQuote = "'";
26
+ const repeatString = (value, n) => new Array(n + 1).join(value);
27
+ const quoteString = (value) => {
28
+ let quote = doubleQuote;
29
+ let alternateQuote = singleQuote;
30
+ const avoidEscape = value.includes(quote) && !value.includes(alternateQuote);
31
+ if (avoidEscape) {
32
+ alternateQuote = doubleQuote;
33
+ quote = singleQuote;
34
+ }
35
+ const alternateEscape = new RegExp(`(^|[^\\\\])((?:\\\\{2})*)((?:\\\\${alternateQuote})+)`, "gu");
36
+ value = value.replace(
37
+ alternateEscape,
38
+ (_, boundaryChar, leadingEscapedSlashes, escapedQuoteChars) => (
39
+ // We divide the escapedQuoteChars by 2 since there are 2 characters in each escaped part ('\\"'.length === 2)
40
+ boundaryChar + leadingEscapedSlashes + repeatString(alternateQuote, escapedQuoteChars.length / 2)
41
+ )
42
+ );
43
+ const quoteEscape = new RegExp(`(^|[^\\\\])((?:\\\\{2})*)(${quote}+)`, "gu");
44
+ value = value.replace(
45
+ quoteEscape,
46
+ (_, boundaryChar, leadingEscapedSlashes, quoteChars) => boundaryChar + leadingEscapedSlashes + repeatString(`\\${quote}`, quoteChars.length)
47
+ );
48
+ return quote + value + quote;
49
+ };
50
+ const createFilterExpression = (filterWord) => {
51
+ const sanitizedWord = filterWord ? filterWord.replaceAll(/[-[\]/{}()*+?.\\^$|]/gu, "\\$&") : "^.*$";
52
+ return new RegExp(sanitizedWord, "i");
53
+ };
54
+ const addLtrMark = (value) => (
55
+ // Make sure the string value is LTR. This prevent issues with RTL language used in LTR containers.
56
+ `‎${value ?? ""}‎`
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);
62
+ }
63
+ return out;
64
+ };
65
+ const generateGuid = () => (
66
+ //#endregion generateGuid
67
+ [getGuidPart(2), getGuidPart(1), getGuidPart(1), getGuidPart(1), getGuidPart(3)].join("-")
68
+ );
69
+ const getMinorVersion = (version) => {
70
+ const [major, minor] = version.split(".");
71
+ return `${major}.${minor}`;
72
+ };
73
+ const getPreamble = (version) => (
74
+ //#endregion getPreamble
75
+ `All material copyright Esri, All Rights Reserved, unless otherwise specified.
76
+ See https://js.arcgis.com/${getMinorVersion(version)}/esri/copyright.txt for details.
77
+ v${version}`
78
+ );
79
+ const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
80
+ exports.addLtrMark = addLtrMark;
81
+ exports.camelToHuman = camelToHuman;
82
+ exports.camelToKebab = camelToKebab;
83
+ exports.capitalize = capitalize;
84
+ exports.createFilterExpression = createFilterExpression;
85
+ exports.generateGuid = generateGuid;
86
+ exports.getMinorVersion = getMinorVersion;
87
+ exports.getPreamble = getPreamble;
88
+ exports.kebabToPascal = kebabToPascal;
89
+ exports.quoteString = quoteString;
90
+ exports.setValuesInString = setValuesInString;
91
+ exports.uncapitalize = uncapitalize;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Convert kebab-case string to PascalCase
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const pascal = kebabToPascal("my-component-name");
7
+ * // MyComponentName
8
+ */
9
+ export declare const kebabToPascal: (string: string) => string;
10
+ /**
11
+ * Convert camelCase string to kebab-case
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const kebab = camelToKebab("myComponentName");
16
+ * // my-component-name
17
+ * ```
18
+ */
19
+ export declare const camelToKebab: (string: string) => string;
20
+ /**
21
+ * Convert camelCase string to Sentence case.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const human = camelToHuman("myComponentName");
26
+ * // My component name
27
+ * ```
28
+ */
29
+ export declare const camelToHuman: (string: string) => string;
30
+ /** Capitalize the first letter of a string. */
31
+ export declare const capitalize: <T extends string>(string: T) => Capitalize<T>;
32
+ /** Uncapitalize the first letter of a string. */
33
+ export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
34
+ /**
35
+ * Add quotes to a string for display purposes.
36
+ * If the string contains a double quote, then single quotes will be used.
37
+ * If the string contains a single quote, then double quotes will be used.
38
+ * If the string contains both, then double quotes will be used and the single quotes will be escaped.
39
+ */
40
+ export declare const quoteString: (value: string) => string;
41
+ /**
42
+ * Create a filter expression from a filter word.
43
+ *
44
+ * @remarks Once browser support permits, use `RegExp.escape()` instead.
45
+ * @todo DEPRECATE
46
+ */
47
+ export declare const createFilterExpression: (filterWord: string) => RegExp;
48
+ /**
49
+ * Add LTR marks to a string to ensure it is displayed as LTR even in RTL contexts.
50
+ * @param value The string to add LTR marks to.
51
+ * @returns The string with LTR marks.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // Without addLtrMark, this will render as arcadeVariable$ in RTL languages.
56
+ * return <div>{addLtrMark("$arcadeVariable")}</div>;
57
+ */
58
+ export declare const addLtrMark: (value: string | undefined) => string;
59
+ /**
60
+ * Generate a GUID string.
61
+ * @example
62
+ * ```ts
63
+ * const id = generateGuid();
64
+ * // 00000000-0000-0000-0000-000000000000.
65
+ * ```
66
+ *
67
+ * @remarks
68
+ * If your component is using shadow root, the DOM element IDs do not need
69
+ * to be globally unique.
70
+ */
71
+ export declare const generateGuid: () => string;
72
+ /**
73
+ * Extract the major and minor version from a full version string.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const minorVersion = getMinorVersion("4.34.0-next.123");
78
+ * // "4.34"
79
+ * ```
80
+ */
81
+ export declare const getMinorVersion: (version: string) => string;
82
+ /**
83
+ * Create a preamble text from a version number. Preamble text is used as legal
84
+ * notice at the top of a file.
85
+ * The preamble text contains the version number and a link to the license.
86
+ * The version number should normally come from package.json.
87
+ * @example
88
+ * ```ts
89
+ * const preamble = getPreamble("4.34.0-next.123");
90
+ * // All material copyright Esri, All Rights Reserved, unless otherwise specified.
91
+ * // See https://js.arcgis.com/4.34/esri/copyright.txt for details.
92
+ * // v4.34.0-next.123
93
+ * ```
94
+ */
95
+ export declare const getPreamble: (version: string) => string;
96
+ /**
97
+ * Replace values in a string using the format {valueName} with the value from the values object.
98
+ * If the value is not found in the values object, then the value is not replaced.
99
+ *
100
+ * @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/api-reference/esri-intl.html#substitute instead
101
+ */
102
+ export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Convert kebab-case string to PascalCase
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const pascal = kebabToPascal("my-component-name");
7
+ * // MyComponentName
8
+ */
9
+ export declare const kebabToPascal: (string: string) => string;
10
+ /**
11
+ * Convert camelCase string to kebab-case
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const kebab = camelToKebab("myComponentName");
16
+ * // my-component-name
17
+ * ```
18
+ */
19
+ export declare const camelToKebab: (string: string) => string;
20
+ /**
21
+ * Convert camelCase string to Sentence case.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const human = camelToHuman("myComponentName");
26
+ * // My component name
27
+ * ```
28
+ */
29
+ export declare const camelToHuman: (string: string) => string;
30
+ /** Capitalize the first letter of a string. */
31
+ export declare const capitalize: <T extends string>(string: T) => Capitalize<T>;
32
+ /** Uncapitalize the first letter of a string. */
33
+ export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
34
+ /**
35
+ * Add quotes to a string for display purposes.
36
+ * If the string contains a double quote, then single quotes will be used.
37
+ * If the string contains a single quote, then double quotes will be used.
38
+ * If the string contains both, then double quotes will be used and the single quotes will be escaped.
39
+ */
40
+ export declare const quoteString: (value: string) => string;
41
+ /**
42
+ * Create a filter expression from a filter word.
43
+ *
44
+ * @remarks Once browser support permits, use `RegExp.escape()` instead.
45
+ * @todo DEPRECATE
46
+ */
47
+ export declare const createFilterExpression: (filterWord: string) => RegExp;
48
+ /**
49
+ * Add LTR marks to a string to ensure it is displayed as LTR even in RTL contexts.
50
+ * @param value The string to add LTR marks to.
51
+ * @returns The string with LTR marks.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // Without addLtrMark, this will render as arcadeVariable$ in RTL languages.
56
+ * return <div>{addLtrMark("$arcadeVariable")}</div>;
57
+ */
58
+ export declare const addLtrMark: (value: string | undefined) => string;
59
+ /**
60
+ * Generate a GUID string.
61
+ * @example
62
+ * ```ts
63
+ * const id = generateGuid();
64
+ * // 00000000-0000-0000-0000-000000000000.
65
+ * ```
66
+ *
67
+ * @remarks
68
+ * If your component is using shadow root, the DOM element IDs do not need
69
+ * to be globally unique.
70
+ */
71
+ export declare const generateGuid: () => string;
72
+ /**
73
+ * Extract the major and minor version from a full version string.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const minorVersion = getMinorVersion("4.34.0-next.123");
78
+ * // "4.34"
79
+ * ```
80
+ */
81
+ export declare const getMinorVersion: (version: string) => string;
82
+ /**
83
+ * Create a preamble text from a version number. Preamble text is used as legal
84
+ * notice at the top of a file.
85
+ * The preamble text contains the version number and a link to the license.
86
+ * The version number should normally come from package.json.
87
+ * @example
88
+ * ```ts
89
+ * const preamble = getPreamble("4.34.0-next.123");
90
+ * // All material copyright Esri, All Rights Reserved, unless otherwise specified.
91
+ * // See https://js.arcgis.com/4.34/esri/copyright.txt for details.
92
+ * // v4.34.0-next.123
93
+ * ```
94
+ */
95
+ export declare const getPreamble: (version: string) => string;
96
+ /**
97
+ * Replace values in a string using the format {valueName} with the value from the values object.
98
+ * If the value is not found in the values object, then the value is not replaced.
99
+ *
100
+ * @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/api-reference/esri-intl.html#substitute instead
101
+ */
102
+ export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
@@ -0,0 +1,91 @@
1
+ const kebabToPascal = (string) => (
2
+ //#endregion kebabToPascal
3
+ string.split("-").map(capitalize).join("")
4
+ );
5
+ const camelToKebab = (string) => (
6
+ //#endregion camelToKebab
7
+ string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`)
8
+ );
9
+ const upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
10
+ const camelToHuman = (string) => (
11
+ //#endregion camelToHuman
12
+ capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`))
13
+ );
14
+ const capitalize = (string) => (
15
+ //#endregion capitalize
16
+ string.charAt(0).toUpperCase() + string.slice(1)
17
+ );
18
+ const uncapitalize = (string) => (
19
+ //#endregion uncapitalize
20
+ string.charAt(0).toLowerCase() + string.slice(1)
21
+ );
22
+ const doubleQuote = '"';
23
+ const singleQuote = "'";
24
+ const repeatString = (value, n) => new Array(n + 1).join(value);
25
+ const quoteString = (value) => {
26
+ let quote = doubleQuote;
27
+ let alternateQuote = singleQuote;
28
+ const avoidEscape = value.includes(quote) && !value.includes(alternateQuote);
29
+ if (avoidEscape) {
30
+ alternateQuote = doubleQuote;
31
+ quote = singleQuote;
32
+ }
33
+ const alternateEscape = new RegExp(`(^|[^\\\\])((?:\\\\{2})*)((?:\\\\${alternateQuote})+)`, "gu");
34
+ value = value.replace(
35
+ alternateEscape,
36
+ (_, boundaryChar, leadingEscapedSlashes, escapedQuoteChars) => (
37
+ // We divide the escapedQuoteChars by 2 since there are 2 characters in each escaped part ('\\"'.length === 2)
38
+ boundaryChar + leadingEscapedSlashes + repeatString(alternateQuote, escapedQuoteChars.length / 2)
39
+ )
40
+ );
41
+ const quoteEscape = new RegExp(`(^|[^\\\\])((?:\\\\{2})*)(${quote}+)`, "gu");
42
+ value = value.replace(
43
+ quoteEscape,
44
+ (_, boundaryChar, leadingEscapedSlashes, quoteChars) => boundaryChar + leadingEscapedSlashes + repeatString(`\\${quote}`, quoteChars.length)
45
+ );
46
+ return quote + value + quote;
47
+ };
48
+ const createFilterExpression = (filterWord) => {
49
+ const sanitizedWord = filterWord ? filterWord.replaceAll(/[-[\]/{}()*+?.\\^$|]/gu, "\\$&") : "^.*$";
50
+ return new RegExp(sanitizedWord, "i");
51
+ };
52
+ const addLtrMark = (value) => (
53
+ // Make sure the string value is LTR. This prevent issues with RTL language used in LTR containers.
54
+ `‎${value ?? ""}‎`
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);
60
+ }
61
+ return out;
62
+ };
63
+ const generateGuid = () => (
64
+ //#endregion generateGuid
65
+ [getGuidPart(2), getGuidPart(1), getGuidPart(1), getGuidPart(1), getGuidPart(3)].join("-")
66
+ );
67
+ const getMinorVersion = (version) => {
68
+ const [major, minor] = version.split(".");
69
+ return `${major}.${minor}`;
70
+ };
71
+ const getPreamble = (version) => (
72
+ //#endregion getPreamble
73
+ `All material copyright Esri, All Rights Reserved, unless otherwise specified.
74
+ See https://js.arcgis.com/${getMinorVersion(version)}/esri/copyright.txt for details.
75
+ v${version}`
76
+ );
77
+ const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
78
+ export {
79
+ addLtrMark,
80
+ camelToHuman,
81
+ camelToKebab,
82
+ capitalize,
83
+ createFilterExpression,
84
+ generateGuid,
85
+ getMinorVersion,
86
+ getPreamble,
87
+ kebabToPascal,
88
+ quoteString,
89
+ setValuesInString,
90
+ uncapitalize
91
+ };
@@ -0,0 +1 @@
1
+ export declare function captureConsoleErrors(): unknown[][];
@@ -0,0 +1 @@
1
+ export declare function captureConsoleErrors(): unknown[][];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A convenient alias for `null | undefined`.
3
+ * @remarks Named `nil` over `Nil` as per https://devtopia.esri.com/WebGIS/arcgis-js-api/pull/66920
4
+ */
5
+ export type nil = null | undefined;
6
+ /**
7
+ * @deprecated Import from `__esri.IHandle` instead
8
+ */
9
+ export type IHandle = {
10
+ remove: () => void;
11
+ };
12
+ /**
13
+ * @deprecated Import type { nil } from `@arcgis/toolkit/type` instead
14
+ */
15
+ export type Nil = nil;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A convenient alias for `null | undefined`.
3
+ * @remarks Named `nil` over `Nil` as per https://devtopia.esri.com/WebGIS/arcgis-js-api/pull/66920
4
+ */
5
+ export type nil = null | undefined;
6
+ /**
7
+ * @deprecated Import from `__esri.IHandle` instead
8
+ */
9
+ export type IHandle = {
10
+ remove: () => void;
11
+ };
12
+ /**
13
+ * @deprecated Import type { nil } from `@arcgis/toolkit/type` instead
14
+ */
15
+ export type Nil = nil;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const hasSameOrigin = (url1, url2, ignoreProtocol = false) => {
4
+ if (!url1 || !url2) {
5
+ return false;
6
+ }
7
+ const url1Obj = new URL(url1);
8
+ const url2Obj = new URL(url2);
9
+ if (!ignoreProtocol && url1Obj.protocol !== url2Obj.protocol) {
10
+ return false;
11
+ }
12
+ if (url1Obj.host == null || url2Obj.host == null) {
13
+ return false;
14
+ }
15
+ return url1Obj.host.toLowerCase() === url2Obj.host.toLowerCase() && url1Obj.port === url2Obj.port;
16
+ };
17
+ const isURL = (url) => {
18
+ try {
19
+ new URL(url);
20
+ return true;
21
+ } catch (e) {
22
+ return false;
23
+ }
24
+ };
25
+ exports.hasSameOrigin = hasSameOrigin;
26
+ exports.isURL = isURL;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Compares two url strings for their origin and returns true if they have the same origin.
3
+ *
4
+ * @param url1 First url string
5
+ * @param url2 Second url string
6
+ * @param ignoreProtocol Indicates if protocol comparison should be ignored
7
+ * @returns True if the two url strings have the same origin
8
+ */
9
+ export declare const hasSameOrigin: (url1: string | null | undefined, url2: string | null | undefined, ignoreProtocol?: boolean) => boolean;
10
+ /**
11
+ * Tests if a url string is a URL or not.
12
+ * @param url The url string to test
13
+ * @returns True if the string is a URL.
14
+ *
15
+ * @remarks If browser support permits, use https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static instead
16
+ * @todo DEPRECATE
17
+ */
18
+ export declare const isURL: (url: string) => boolean;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Compares two url strings for their origin and returns true if they have the same origin.
3
+ *
4
+ * @param url1 First url string
5
+ * @param url2 Second url string
6
+ * @param ignoreProtocol Indicates if protocol comparison should be ignored
7
+ * @returns True if the two url strings have the same origin
8
+ */
9
+ export declare const hasSameOrigin: (url1: string | null | undefined, url2: string | null | undefined, ignoreProtocol?: boolean) => boolean;
10
+ /**
11
+ * Tests if a url string is a URL or not.
12
+ * @param url The url string to test
13
+ * @returns True if the string is a URL.
14
+ *
15
+ * @remarks If browser support permits, use https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static instead
16
+ * @todo DEPRECATE
17
+ */
18
+ export declare const isURL: (url: string) => boolean;