@arcgis/toolkit 5.2.0-next.1 → 5.2.0-next.11

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.
@@ -1,117 +0,0 @@
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
- `COPYRIGHT Esri - https://js.arcgis.com/${getMinorVersion(version)}/LICENSE.txt`
76
- );
77
- const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
78
- const regionStartPattern = /^\s*\/\/\s*#region(?::)?\s*(?<regionName>.*?)\s*$/u;
79
- const regionAnyStartPattern = /^\s*\/\/\s*#region(?::)?\s*.*$/u;
80
- const regionEndPattern = /^\s*\/\/\s*#endregion(?::)?(?:\s+.*)?\s*$/u;
81
- const extractRegion = (source, regionName) => {
82
- const lines = source.split(/\r?\n/gu);
83
- const startLineIndex = lines.findIndex((line) => regionStartPattern.exec(line)?.groups?.regionName === regionName);
84
- if (startLineIndex === -1) {
85
- throw new Error(`Unable to locate source region "${regionName}".`);
86
- }
87
- let nestedRegionDepth = 0;
88
- for (let lineIndex = startLineIndex + 1; lineIndex < lines.length; lineIndex++) {
89
- const line = lines[lineIndex];
90
- if (regionAnyStartPattern.test(line)) {
91
- nestedRegionDepth++;
92
- continue;
93
- }
94
- if (!regionEndPattern.test(line)) {
95
- continue;
96
- }
97
- if (nestedRegionDepth > 0) {
98
- nestedRegionDepth--;
99
- continue;
100
- }
101
- return lines.slice(startLineIndex + 1, lineIndex).join("\n").trim();
102
- }
103
- throw new Error(`Unable to locate source region end for "${regionName}".`);
104
- };
105
- exports.addLtrMark = addLtrMark;
106
- exports.camelToHuman = camelToHuman;
107
- exports.camelToKebab = camelToKebab;
108
- exports.capitalize = capitalize;
109
- exports.createFilterExpression = createFilterExpression;
110
- exports.extractRegion = extractRegion;
111
- exports.generateGuid = generateGuid;
112
- exports.getMinorVersion = getMinorVersion;
113
- exports.getPreamble = getPreamble;
114
- exports.kebabToPascal = kebabToPascal;
115
- exports.quoteString = quoteString;
116
- exports.setValuesInString = setValuesInString;
117
- exports.uncapitalize = uncapitalize;
@@ -1,130 +0,0 @@
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
- * @privateRemarks 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
- *
66
- * If your component is using shadow root, the DOM element IDs do not need
67
- * to be globally unique - IDs are scoped to the shadow root.
68
- *
69
- * Avoid using GUID and other non-deterministic output in render() as they
70
- * cause SSR hydration issues and snapshot test instability.
71
- *
72
- * @example
73
- * ```ts
74
- * const id = generateGuid();
75
- * // 00000000-0000-0000-0000-000000000000.
76
- * ```
77
- */
78
- export declare const generateGuid: () => UUID;
79
- /**
80
- * Extract the major and minor version from a full version string.
81
- *
82
- * @example
83
- * ```ts
84
- * const minorVersion = getMinorVersion("4.34.0-next.123");
85
- * // "4.34"
86
- * ```
87
- */
88
- export declare const getMinorVersion: (version: string) => string;
89
- /**
90
- * Create a preamble text from a version number. Preamble text is used as legal
91
- * notice at the top of a file.
92
- * The preamble text contains the version number and a link to the license.
93
- * The version number should normally come from package.json.
94
- *
95
- * @see https://webgis.esri.com/sdk/contributing/licensing
96
- * @example
97
- * ```ts
98
- * const preamble = getPreamble("5.0.1-next.456");
99
- * // COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt
100
- * ```
101
- */
102
- export declare const getPreamble: (version: string) => string;
103
- /**
104
- * Replace values in a string using the format {valueName} with the value from the values object.
105
- * If the value is not found in the values object, then the value is not replaced.
106
- *
107
- * @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/references/core/intl/#substitute instead
108
- */
109
- export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
110
- /**
111
- * Use `extractRegion` when you need to read a named `#region` block from a JavaScript/TypeScript source string,
112
- * such as docs or MDX snippets that should stay in sync with the real implementation.
113
- *
114
- * Throws when the named region cannot be found or is missing its closing marker.
115
- *
116
- * @example
117
- * ```ts
118
- * import code from "my-code-file.ts?raw";
119
- * const snippet = extractRegion(code, "myRegion");
120
- *
121
- * // where code is:
122
- * `
123
- * //#region myRegion
124
- * const value = 1;
125
- * //#endregion
126
- * `
127
- * // const value = 1;
128
- * ```
129
- */
130
- export declare const extractRegion: (source: string, regionName: string) => string;
@@ -1 +0,0 @@
1
- export declare function captureConsoleErrors(): unknown[][];
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const typeTest = 0;
4
- exports.typeTest = typeTest;
@@ -1,29 +0,0 @@
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 type { ResourceHandle } from "@arcgis/core/core/Handles.js";
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;
16
- /**
17
- * A helper for doing TypeScript type tests.
18
- * This complements the TypeScript's `satisfies` operator.
19
- *
20
- * See usage examples:
21
- * https://webgis.esri.com/sdk/resources/typescript-tips#use-satisfies-operator-for-type-tests
22
- *
23
- * During production end-application build, such type tests will be removed as
24
- * they have no runtime impact.
25
- *
26
- * @privateRemarks
27
- * Using `0` over `undefined` to take fewer bytes if minifier is disabled.
28
- */
29
- export declare const typeTest: unknown;
@@ -1,26 +0,0 @@
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;
@@ -1,18 +0,0 @@
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
- * @privateRemarks TODO: DEPRECATE
17
- */
18
- export declare const isURL: (url: string) => boolean;