@arcgis/toolkit 4.34.0-next.100
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.
- package/LICENSE.md +13 -0
- package/README.md +25 -0
- package/dist/array/index.cjs +12 -0
- package/dist/array/index.d.cts +12 -0
- package/dist/array/index.d.ts +12 -0
- package/dist/array/index.js +12 -0
- package/dist/dom/index.cjs +198 -0
- package/dist/dom/index.d.cts +116 -0
- package/dist/dom/index.d.ts +116 -0
- package/dist/dom/index.js +198 -0
- package/dist/dom/slots.d.cts +93 -0
- package/dist/dom/slots.d.ts +93 -0
- package/dist/error/index.cjs +36 -0
- package/dist/error/index.d.cts +32 -0
- package/dist/error/index.d.ts +32 -0
- package/dist/error/index.js +36 -0
- package/dist/function/index.cjs +16 -0
- package/dist/function/index.d.cts +19 -0
- package/dist/function/index.d.ts +19 -0
- package/dist/function/index.js +16 -0
- package/dist/intl/index.cjs +103 -0
- package/dist/intl/index.d.cts +121 -0
- package/dist/intl/index.d.ts +121 -0
- package/dist/intl/index.js +103 -0
- package/dist/predicate/index.cjs +8 -0
- package/dist/predicate/index.d.cts +24 -0
- package/dist/predicate/index.d.ts +24 -0
- package/dist/predicate/index.js +8 -0
- package/dist/promise/index.cjs +30 -0
- package/dist/promise/index.d.cts +46 -0
- package/dist/promise/index.d.ts +46 -0
- package/dist/promise/index.js +30 -0
- package/dist/string/index.cjs +91 -0
- package/dist/string/index.d.cts +106 -0
- package/dist/string/index.d.ts +106 -0
- package/dist/string/index.js +91 -0
- package/dist/tests/utils.d.cts +1 -0
- package/dist/tests/utils.d.ts +1 -0
- package/dist/type/index.d.cts +15 -0
- package/dist/type/index.d.ts +15 -0
- package/dist/url/index.cjs +26 -0
- package/dist/url/index.d.cts +18 -0
- package/dist/url/index.d.ts +18 -0
- package/dist/url/index.js +26 -0
- package/package.json +66 -0
|
@@ -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 hasRandomUUID = "randomUUID" in crypto;
|
|
59
|
+
const generateGuid = () => {
|
|
60
|
+
if (hasRandomUUID) {
|
|
61
|
+
return crypto.randomUUID();
|
|
62
|
+
}
|
|
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)}`;
|
|
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,106 @@
|
|
|
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
|
+
* A string containing a randomly generated, 36 character long v4 UUID.
|
|
61
|
+
*/
|
|
62
|
+
export type UUID = ReturnType<typeof crypto.randomUUID>;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a GUID string.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const id = generateGuid();
|
|
68
|
+
* // 00000000-0000-0000-0000-000000000000.
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* If your component is using shadow root, the DOM element IDs do not need
|
|
73
|
+
* to be globally unique.
|
|
74
|
+
*/
|
|
75
|
+
export declare const generateGuid: () => UUID;
|
|
76
|
+
/**
|
|
77
|
+
* Extract the major and minor version from a full version string.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const minorVersion = getMinorVersion("4.34.0-next.123");
|
|
82
|
+
* // "4.34"
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const getMinorVersion: (version: string) => string;
|
|
86
|
+
/**
|
|
87
|
+
* Create a preamble text from a version number. Preamble text is used as legal
|
|
88
|
+
* notice at the top of a file.
|
|
89
|
+
* The preamble text contains the version number and a link to the license.
|
|
90
|
+
* The version number should normally come from package.json.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const preamble = getPreamble("4.34.0-next.123");
|
|
94
|
+
* // All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
95
|
+
* // See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
96
|
+
* // v4.34.0-next.123
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const getPreamble: (version: string) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Replace values in a string using the format {valueName} with the value from the values object.
|
|
102
|
+
* If the value is not found in the values object, then the value is not replaced.
|
|
103
|
+
*
|
|
104
|
+
* @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/api-reference/esri-intl.html#substitute instead
|
|
105
|
+
*/
|
|
106
|
+
export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
* A string containing a randomly generated, 36 character long v4 UUID.
|
|
61
|
+
*/
|
|
62
|
+
export type UUID = ReturnType<typeof crypto.randomUUID>;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a GUID string.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const id = generateGuid();
|
|
68
|
+
* // 00000000-0000-0000-0000-000000000000.
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* If your component is using shadow root, the DOM element IDs do not need
|
|
73
|
+
* to be globally unique.
|
|
74
|
+
*/
|
|
75
|
+
export declare const generateGuid: () => UUID;
|
|
76
|
+
/**
|
|
77
|
+
* Extract the major and minor version from a full version string.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const minorVersion = getMinorVersion("4.34.0-next.123");
|
|
82
|
+
* // "4.34"
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const getMinorVersion: (version: string) => string;
|
|
86
|
+
/**
|
|
87
|
+
* Create a preamble text from a version number. Preamble text is used as legal
|
|
88
|
+
* notice at the top of a file.
|
|
89
|
+
* The preamble text contains the version number and a link to the license.
|
|
90
|
+
* The version number should normally come from package.json.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const preamble = getPreamble("4.34.0-next.123");
|
|
94
|
+
* // All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
95
|
+
* // See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
96
|
+
* // v4.34.0-next.123
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const getPreamble: (version: string) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Replace values in a string using the format {valueName} with the value from the values object.
|
|
102
|
+
* If the value is not found in the values object, then the value is not replaced.
|
|
103
|
+
*
|
|
104
|
+
* @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/api-reference/esri-intl.html#substitute instead
|
|
105
|
+
*/
|
|
106
|
+
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 hasRandomUUID = "randomUUID" in crypto;
|
|
57
|
+
const generateGuid = () => {
|
|
58
|
+
if (hasRandomUUID) {
|
|
59
|
+
return crypto.randomUUID();
|
|
60
|
+
}
|
|
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)}`;
|
|
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;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const hasSameOrigin = (url1, url2, ignoreProtocol = false) => {
|
|
2
|
+
if (!url1 || !url2) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const url1Obj = new URL(url1);
|
|
6
|
+
const url2Obj = new URL(url2);
|
|
7
|
+
if (!ignoreProtocol && url1Obj.protocol !== url2Obj.protocol) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (url1Obj.host == null || url2Obj.host == null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return url1Obj.host.toLowerCase() === url2Obj.host.toLowerCase() && url1Obj.port === url2Obj.port;
|
|
14
|
+
};
|
|
15
|
+
const isURL = (url) => {
|
|
16
|
+
try {
|
|
17
|
+
new URL(url);
|
|
18
|
+
return true;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
hasSameOrigin,
|
|
25
|
+
isURL
|
|
26
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arcgis/toolkit",
|
|
3
|
+
"version": "4.34.0-next.100",
|
|
4
|
+
"description": "Collection of common internal patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
|
|
5
|
+
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./array": {
|
|
10
|
+
"types": "./dist/array/index.d.ts",
|
|
11
|
+
"import": "./dist/array/index.js",
|
|
12
|
+
"require": "./dist/array/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./dom": {
|
|
15
|
+
"types": "./dist/dom/index.d.ts",
|
|
16
|
+
"import": "./dist/dom/index.js",
|
|
17
|
+
"require": "./dist/dom/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./error": {
|
|
20
|
+
"types": "./dist/error/index.d.ts",
|
|
21
|
+
"import": "./dist/error/index.js",
|
|
22
|
+
"require": "./dist/error/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./function": {
|
|
25
|
+
"types": "./dist/function/index.d.ts",
|
|
26
|
+
"import": "./dist/function/index.js",
|
|
27
|
+
"require": "./dist/function/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./intl": {
|
|
30
|
+
"types": "./dist/intl/index.d.ts",
|
|
31
|
+
"import": "./dist/intl/index.js",
|
|
32
|
+
"require": "./dist/intl/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./predicate": {
|
|
35
|
+
"types": "./dist/predicate/index.d.ts",
|
|
36
|
+
"import": "./dist/predicate/index.js",
|
|
37
|
+
"require": "./dist/predicate/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./promise": {
|
|
40
|
+
"types": "./dist/promise/index.d.ts",
|
|
41
|
+
"import": "./dist/promise/index.js",
|
|
42
|
+
"require": "./dist/promise/index.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./string": {
|
|
45
|
+
"types": "./dist/string/index.d.ts",
|
|
46
|
+
"import": "./dist/string/index.js",
|
|
47
|
+
"require": "./dist/string/index.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./type": {
|
|
50
|
+
"types": "./dist/type/index.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./url": {
|
|
53
|
+
"types": "./dist/url/index.d.ts",
|
|
54
|
+
"import": "./dist/url/index.js",
|
|
55
|
+
"require": "./dist/url/index.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"dist/"
|
|
61
|
+
],
|
|
62
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"tslib": "^2.8.1"
|
|
65
|
+
}
|
|
66
|
+
}
|