@arcgis/toolkit 5.2.0-next.9 → 5.2.0-next.91
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 +4 -2
- package/README.md +2 -2
- package/dist/{array/index.d.cts → array.d.ts} +4 -1
- package/dist/dom/referenceElement.d.ts +17 -0
- package/dist/dom/referenceElement.js +5 -0
- package/dist/dom/slots.d.ts +8 -0
- package/dist/dom/slots.js +39 -0
- package/dist/{dom/index.js → dom-Bnc7oSYx.js} +30 -48
- package/dist/dom.d.ts +177 -0
- package/dist/dom.js +21 -0
- package/dist/{error/index.d.cts → error.d.ts} +15 -4
- package/dist/{error/index.js → error.js} +1 -1
- package/dist/{function/index.d.cts → function.d.ts} +4 -1
- package/dist/intl/dom.d.ts +74 -0
- package/dist/intl/{index.js → dom.js} +41 -37
- package/dist/intl.d.ts +89 -0
- package/dist/intl.js +10 -0
- package/dist/{log/index.d.ts → log.d.ts} +38 -6
- package/dist/{number/index.d.cts → number.d.ts} +2 -1
- package/dist/predicate.d.ts +27 -0
- package/dist/predicate.js +8 -0
- package/dist/{promise/index.d.ts → promise.d.ts} +17 -2
- package/dist/{promise/index.js → promise.js} +2 -0
- package/dist/{string/index.d.ts → string.d.ts} +40 -3
- package/dist/{type/index.d.cts → type.d.ts} +11 -1
- package/dist/{url/index.d.cts → url.d.ts} +4 -3
- package/package.json +16 -61
- package/dist/array/index.cjs +0 -13
- package/dist/array/index.d.ts +0 -12
- package/dist/dom/index.cjs +0 -227
- package/dist/dom/index.d.cts +0 -117
- package/dist/dom/index.d.ts +0 -117
- package/dist/dom/reference-element.d.cts +0 -6
- package/dist/dom/reference-element.d.ts +0 -6
- package/dist/dom/slots.d.cts +0 -93
- package/dist/error/index.cjs +0 -36
- package/dist/error/index.d.ts +0 -32
- package/dist/function/index.cjs +0 -16
- package/dist/function/index.d.ts +0 -19
- package/dist/intl/index.cjs +0 -110
- package/dist/intl/index.d.cts +0 -124
- package/dist/intl/index.d.ts +0 -124
- package/dist/log/index.cjs +0 -81
- package/dist/log/index.d.cts +0 -128
- package/dist/number/index.cjs +0 -10
- package/dist/number/index.d.ts +0 -19
- package/dist/predicate/index.cjs +0 -8
- package/dist/predicate/index.d.cts +0 -24
- package/dist/predicate/index.d.ts +0 -24
- package/dist/predicate/index.js +0 -8
- package/dist/promise/index.cjs +0 -45
- package/dist/promise/index.d.cts +0 -60
- package/dist/string/index.cjs +0 -117
- package/dist/string/index.d.cts +0 -130
- package/dist/tests/utils.d.cts +0 -1
- package/dist/type/index.cjs +0 -4
- package/dist/type/index.d.ts +0 -29
- package/dist/url/index.cjs +0 -26
- package/dist/url/index.d.ts +0 -18
- /package/dist/{array/index.js → array.js} +0 -0
- /package/dist/{function/index.js → function.js} +0 -0
- /package/dist/{log/index.js → log.js} +0 -0
- /package/dist/{number/index.js → number.js} +0 -0
- /package/dist/{string/index.js → string.js} +0 -0
- /package/dist/{type/index.js → type.js} +0 -0
- /package/dist/{url/index.js → url.js} +0 -0
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { log } from "../log.js";
|
|
2
|
+
import { g as getElementAttribute, o as observeAncestorsMutation } from "../dom-Bnc7oSYx.js";
|
|
3
|
+
const getElementLocale$1 = (element) => {
|
|
4
|
+
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
5
|
+
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
6
|
+
};
|
|
7
|
+
const startLocaleObserver$1 = (element, getAssetsPath, onUpdated, assetName) => {
|
|
8
|
+
let result = void 0;
|
|
9
|
+
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
10
|
+
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
11
|
+
onUpdated(newResult);
|
|
12
|
+
}
|
|
13
|
+
result = newResult;
|
|
14
|
+
}).catch((error) => {
|
|
15
|
+
log("error", "intl", "Error updating component locale state", { detail: { error } });
|
|
16
|
+
});
|
|
17
|
+
queueMicrotask(callback);
|
|
18
|
+
return observeAncestorsMutation(element, ["lang"], callback);
|
|
19
|
+
};
|
|
20
|
+
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
21
|
+
const { lang, t9nLocale } = getElementLocale$1(element);
|
|
22
|
+
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
23
|
+
const prefix = `messages.`;
|
|
24
|
+
const t9nStrings = (
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
26
|
+
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
27
|
+
);
|
|
28
|
+
return { lang, t9nLocale, t9nStrings };
|
|
29
|
+
};
|
|
30
|
+
const getElementLocale = getElementLocale$1;
|
|
31
|
+
const startLocaleObserver = startLocaleObserver$1;
|
|
3
32
|
const supportedLocalesArray = "ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(
|
|
4
33
|
","
|
|
5
34
|
);
|
|
@@ -17,7 +46,7 @@ const localeEquivalencies = {
|
|
|
17
46
|
// We support both 'nb' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
18
47
|
nb: "no",
|
|
19
48
|
// We support both 'nn' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
20
|
-
// See https://devtopia.esri.com/WebGIS/
|
|
49
|
+
// See https://devtopia.esri.com/WebGIS/webgis-sdk/issues/4667
|
|
21
50
|
nn: "no",
|
|
22
51
|
// We use `zh-CN` as base translation for chinese locales which has no corresponding bundle.
|
|
23
52
|
zh: "zh-CN"
|
|
@@ -26,7 +55,7 @@ const localeEquivalencies = {
|
|
|
26
55
|
const fetchT9nStringsBundle = async (locale, assetsPath, prefix = "") => {
|
|
27
56
|
const path = `${assetsPath}/${prefix}`;
|
|
28
57
|
const filePath = `${path}${locale}.json`;
|
|
29
|
-
t9nStringsCache[filePath]
|
|
58
|
+
t9nStringsCache[filePath] ??= fetchBundle(locale, path);
|
|
30
59
|
return await t9nStringsCache[filePath];
|
|
31
60
|
};
|
|
32
61
|
const t9nStringsCache = {};
|
|
@@ -57,10 +86,6 @@ const fetchBundle = async (locale, path) => {
|
|
|
57
86
|
}
|
|
58
87
|
return await fetchBundle(defaultLocale, path);
|
|
59
88
|
};
|
|
60
|
-
const getElementLocale = (element) => {
|
|
61
|
-
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
62
|
-
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
63
|
-
};
|
|
64
89
|
const normalizeLocale = (lang) => {
|
|
65
90
|
const [rawLanguageCode, regionCode] = lang.split("-");
|
|
66
91
|
const languageCode = rawLanguageCode.toLowerCase();
|
|
@@ -77,34 +102,13 @@ const normalizeLocale = (lang) => {
|
|
|
77
102
|
}
|
|
78
103
|
return defaultLocale;
|
|
79
104
|
};
|
|
80
|
-
const startLocaleObserver = (element, getAssetsPath, onUpdated, assetName) => {
|
|
81
|
-
let result = void 0;
|
|
82
|
-
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
83
|
-
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
84
|
-
onUpdated(newResult);
|
|
85
|
-
}
|
|
86
|
-
result = newResult;
|
|
87
|
-
}).catch((error) => {
|
|
88
|
-
log("error", "intl", "Error updating component locale state", { detail: { error } });
|
|
89
|
-
});
|
|
90
|
-
queueMicrotask(callback);
|
|
91
|
-
return observeAncestorsMutation(element, ["lang"], callback);
|
|
92
|
-
};
|
|
93
|
-
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
94
|
-
const { lang, t9nLocale } = getElementLocale(element);
|
|
95
|
-
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
96
|
-
const prefix = `messages.`;
|
|
97
|
-
const t9nStrings = (
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
99
|
-
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
100
|
-
);
|
|
101
|
-
return { lang, t9nLocale, t9nStrings };
|
|
102
|
-
};
|
|
103
105
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
supportedLocales as a,
|
|
107
|
+
defaultLocale as d,
|
|
108
|
+
fetchT9nStringsBundle as f,
|
|
109
|
+
getElementLocale as g,
|
|
110
|
+
getElementLocale$1 as getElementLocale,
|
|
111
|
+
normalizeLocale as n,
|
|
112
|
+
startLocaleObserver as s,
|
|
113
|
+
startLocaleObserver$1 as startLocaleObserver
|
|
110
114
|
};
|
package/dist/intl.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type LocaleObserverResult as LocaleObserverResultAlias } from "./intl/dom.ts";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* @deprecated import { getElementLocale } from "./intl/dom.ts" instead
|
|
5
|
+
*/
|
|
6
|
+
export declare const getElementLocale: (element: HTMLElement) => {
|
|
7
|
+
readonly lang: string;
|
|
8
|
+
readonly t9nLocale: SupportedLocale;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* @deprecated import { startLocaleObserver } from "./intl/dom.ts" instead
|
|
13
|
+
*/
|
|
14
|
+
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResultAlias<Strings>) => void, assetName?: string | null) => (() => void);
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
* @deprecated import type { LocaleObserverResult } from "./intl/dom.ts" instead
|
|
18
|
+
*/
|
|
19
|
+
export type LocaleObserverResult = LocaleObserverResultAlias;
|
|
20
|
+
/**
|
|
21
|
+
* The list of supported locales for ArcGIS Maps SDK for JavaScript components.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare const supportedLocales: Set<SupportedLocale>;
|
|
26
|
+
/**
|
|
27
|
+
* TypeScript union type for each locale supported by WebGIS SDK
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export type SupportedLocale = "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hr" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nb" | "nl" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "th" | "tr" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW";
|
|
32
|
+
/**
|
|
33
|
+
* The default locale for WebGIS SDK.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const defaultLocale = "en";
|
|
38
|
+
/**
|
|
39
|
+
* Fetch the T9N strings bundle for the given locale, assets path and prefix.
|
|
40
|
+
* The locale must be one of the supported locales.
|
|
41
|
+
* If the locale is not supported, it will default to 'en'.
|
|
42
|
+
* If the T9N strings bundle cannot be found, it will default to 'en'.
|
|
43
|
+
*
|
|
44
|
+
* > Rather than using this function directly, prefer the
|
|
45
|
+
* > [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
46
|
+
* > controller.
|
|
47
|
+
*
|
|
48
|
+
* > The function implements cache. Frequent calls are safe.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @param locale The locale for which to fetch the T9N strings
|
|
52
|
+
* @param assetsPath The path to the assets folder where the T9N strings are located
|
|
53
|
+
* @param prefix The prefix to use for the T9N strings file name.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Will make a request for ./assets/coding-editor/t9n/messages.en.json
|
|
58
|
+
* const t9nStrings = await fetchT9nStringsBundle(
|
|
59
|
+
* "en",
|
|
60
|
+
* getAssetPath("./assets/coding-editor/t9n"),
|
|
61
|
+
* "messages."
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @see [Lumina asset handling](https://webgis.esri.com/references/lumina/assets)
|
|
66
|
+
*/
|
|
67
|
+
export declare const fetchT9nStringsBundle: <Strings extends GenericT9nStrings>(locale: string, assetsPath: string, prefix?: string) => Promise<Strings>;
|
|
68
|
+
/**
|
|
69
|
+
* The interface for translated strings.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export interface GenericT9nStrings {
|
|
74
|
+
/** @public */
|
|
75
|
+
[key: string]: GenericT9nStrings | string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Try to parse any language string into one of the locales supported by WebGIS SDK.
|
|
79
|
+
*
|
|
80
|
+
* > Follows the ArcGIS Maps SDK for JavaScript locale support:
|
|
81
|
+
* > https://developers.arcgis.com/javascript/latest/localization/#locale-support
|
|
82
|
+
*
|
|
83
|
+
* > If language includes a region code, but we don't have a bundle for it, the
|
|
84
|
+
* > language is normalized to the language code only.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
* @param lang
|
|
88
|
+
*/
|
|
89
|
+
export declare const normalizeLocale: (lang: string) => SupportedLocale;
|
package/dist/intl.js
ADDED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** @public */
|
|
1
2
|
export type LogLevel = "error" | "info" | "warn";
|
|
3
|
+
/** @public */
|
|
2
4
|
type CustomElementLike = {
|
|
3
5
|
el: {
|
|
4
6
|
localName: string;
|
|
@@ -6,17 +8,30 @@ type CustomElementLike = {
|
|
|
6
8
|
} | {
|
|
7
9
|
localName: string;
|
|
8
10
|
};
|
|
11
|
+
/** @public */
|
|
9
12
|
type AccessorLike = {
|
|
10
13
|
declaredClass: string;
|
|
11
14
|
};
|
|
15
|
+
/** @public */
|
|
12
16
|
export type LogContext = AccessorLike | CustomElementLike | string;
|
|
17
|
+
/** @public */
|
|
13
18
|
type LogOptions = {
|
|
14
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Whether the message should only be logged once.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
15
24
|
once?: boolean;
|
|
16
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Additional objects to log after `message`. Use this to avoid memory leaks when logging objects to the console. Each object value will be automatically wrapped in a `WeakRef` before logging so it can be garbage-collected.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
17
30
|
detail?: Record<string, unknown>;
|
|
18
31
|
};
|
|
32
|
+
/** @public */
|
|
19
33
|
type EsriConfig = {
|
|
34
|
+
/** @public */
|
|
20
35
|
log: {
|
|
21
36
|
/**
|
|
22
37
|
* @link {https://developers.arcgis.com/javascript/latest/references/core/config/#LogInterceptor}
|
|
@@ -25,9 +40,11 @@ type EsriConfig = {
|
|
|
25
40
|
};
|
|
26
41
|
};
|
|
27
42
|
/**
|
|
28
|
-
* Workaround for setting
|
|
29
|
-
* @see
|
|
30
|
-
*
|
|
43
|
+
* Workaround for setting [log interceptors](https://developers.arcgis.com/javascript/latest/references/core/config/#log) and maintaining compatibility with [js-api's interceptor usage](https://devtopia.esri.com/WebGIS/arcgis-websceneviewer-app/blob/8f0a1bbcf12d1193134d94589d9e187f0afa72fa/src/js/support/ApiLoggerInstrumentation.ts#L17).
|
|
44
|
+
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/74935
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @param config https://developers.arcgis.com/javascript/latest/references/core/config/
|
|
31
48
|
* @example
|
|
32
49
|
* ```ts
|
|
33
50
|
* // IMPORTANT: do this only in config.ts or another early-loaded module
|
|
@@ -45,12 +62,13 @@ export declare const setEsriConfig: (config: EsriConfig) => void;
|
|
|
45
62
|
/**
|
|
46
63
|
* Helper utility for logging messages in a consistent manner.
|
|
47
64
|
*
|
|
65
|
+
* @public
|
|
48
66
|
* @param level The log level
|
|
49
67
|
* @param context The context of the log message (e.g., `this` inside a Lit-like component, or just a custom string)
|
|
50
68
|
* @param message A custom message to log
|
|
51
69
|
* @param options Additional options for logging, such as to provide a context object
|
|
52
70
|
*
|
|
53
|
-
* @see
|
|
71
|
+
* @see {@link log!setEsriConfig}
|
|
54
72
|
*
|
|
55
73
|
* @example
|
|
56
74
|
* ```ts
|
|
@@ -71,6 +89,7 @@ export declare const log: (level: LogLevel, context: LogContext, message: string
|
|
|
71
89
|
* Rethrows an error and prepends context information to the error message. The error is
|
|
72
90
|
* thrown asynchronously to avoid interrupting the current execution stack, so it cannot be caught
|
|
73
91
|
* with `try/catch` and will bubble to the global object.
|
|
92
|
+
* @public
|
|
74
93
|
* @param context From where the error is being thrown (e.g., `this` inside a Lit-like component, or just a custom string)
|
|
75
94
|
* @returns A function that can be used in `try-catch`/`.catch` to rethrow an error
|
|
76
95
|
*
|
|
@@ -89,10 +108,17 @@ export declare const log: (level: LogLevel, context: LogContext, message: string
|
|
|
89
108
|
* ```
|
|
90
109
|
*/
|
|
91
110
|
export declare const rethrowError: (context: LogContext) => ((error: unknown) => void);
|
|
111
|
+
/** @public */
|
|
92
112
|
type LogContextOrObject = Exclude<LogContext, string> | object;
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
* @privateRemarks
|
|
116
|
+
* https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
|
117
|
+
*/
|
|
93
118
|
type InferPropertyType<T extends LogContextOrObject> = [object] extends [T] ? string : keyof T;
|
|
94
119
|
/**
|
|
95
120
|
* Returns a string that can be used in log messages for missing required properties.
|
|
121
|
+
* @public
|
|
96
122
|
* @param property The name of the required property
|
|
97
123
|
* @example
|
|
98
124
|
* ```ts
|
|
@@ -105,6 +131,7 @@ type InferPropertyType<T extends LogContextOrObject> = [object] extends [T] ? st
|
|
|
105
131
|
export declare const composeMissingPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
106
132
|
/**
|
|
107
133
|
* Returns a string that can be used in log messages for empty required arrays.
|
|
134
|
+
* @public
|
|
108
135
|
* @param property The name of the required property
|
|
109
136
|
* @example
|
|
110
137
|
* ```ts
|
|
@@ -117,6 +144,11 @@ export declare const composeMissingPropertyMessage: <T extends LogContextOrObjec
|
|
|
117
144
|
export declare const composeEmptyPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
118
145
|
/**
|
|
119
146
|
* Logs a warning message for deprecated object properties.
|
|
147
|
+
* @public
|
|
148
|
+
* @param context
|
|
149
|
+
* @param oldName
|
|
150
|
+
* @param newName
|
|
151
|
+
* @param options
|
|
120
152
|
* @example
|
|
121
153
|
* ```ts
|
|
122
154
|
* logDeprecatedProperty(this, "oldName", "newName", {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Clamps a value between a minimum and maximum value.
|
|
3
3
|
*
|
|
4
|
+
* @public
|
|
4
5
|
* @param value The number to clamp.
|
|
5
6
|
* @param min The minimum value.
|
|
6
7
|
* @param max The maximum value.
|
|
7
|
-
*
|
|
8
8
|
* @returns The clamped value.
|
|
9
9
|
*/
|
|
10
10
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
11
11
|
/**
|
|
12
12
|
* Linearly interpolates between two numbers.
|
|
13
13
|
*
|
|
14
|
+
* @public
|
|
14
15
|
* @param min - The start value.
|
|
15
16
|
* @param max - The end value.
|
|
16
17
|
* @param t - The interpolation factor, typically between 0 and 1.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { nil } from "./type.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Safeguard to ensure that an value is not undefined.
|
|
4
|
+
* @public
|
|
5
|
+
* @param value The value to check.
|
|
6
|
+
* @returns Returns true if the value is not undefined.
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const arr = [1, undefined, 3];
|
|
10
|
+
* const result = arr.filter(isNotUndefined);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const isNotUndefined: <T>(value: T | undefined) => value is T;
|
|
14
|
+
/**
|
|
15
|
+
* Safeguard to ensure that an value is not null.
|
|
16
|
+
* @public
|
|
17
|
+
* @param value The value to check.
|
|
18
|
+
* @returns Returns true if the value is not null.
|
|
19
|
+
*/
|
|
20
|
+
export declare const isNotNull: <T>(value: T | null) => value is T;
|
|
21
|
+
/**
|
|
22
|
+
* Safeguard to ensure that an value is not null or undefined.
|
|
23
|
+
* @public
|
|
24
|
+
* @param value The value to check.
|
|
25
|
+
* @returns Returns true if the value is not undefined and not null.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isNotNil: <T>(value: nil | T) => value is T;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* A deferred promise.
|
|
3
3
|
* Useful for when you want to return a promise but don't have the value yet.
|
|
4
4
|
*
|
|
5
|
+
* @public
|
|
5
6
|
* @example
|
|
6
7
|
* ```ts
|
|
7
8
|
* const deferred = new Deferred<string>();
|
|
@@ -11,29 +12,36 @@
|
|
|
11
12
|
*
|
|
12
13
|
* @deprecated
|
|
13
14
|
* If browser support permits, prefer using
|
|
14
|
-
* [Promise.withResolvers()](https://developer.mozilla.org/
|
|
15
|
+
* [Promise.withResolvers()](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers)
|
|
15
16
|
*/
|
|
16
17
|
export declare class Deferred<T> {
|
|
17
18
|
/**
|
|
18
19
|
* The promise that can be awaited.
|
|
20
|
+
* @public
|
|
19
21
|
*/
|
|
20
22
|
promise: Promise<T>;
|
|
21
23
|
/**
|
|
22
24
|
* Creates a new deferred promise.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
23
27
|
*/
|
|
24
28
|
constructor();
|
|
25
29
|
}
|
|
30
|
+
/** @public */
|
|
26
31
|
export interface Deferred<T> {
|
|
27
32
|
/**
|
|
28
33
|
* Resolves the promise.
|
|
34
|
+
* @public
|
|
29
35
|
* @param value The value to resolve the promise with.
|
|
30
|
-
*
|
|
31
36
|
* @privateRemarks
|
|
32
37
|
* Defined as a method to disable covariance checks. Overridden in constructor.
|
|
33
38
|
*/
|
|
34
39
|
resolve(_value: PromiseLike<T> | T): void;
|
|
35
40
|
/**
|
|
36
41
|
* Rejects the promise.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
* @param error
|
|
37
45
|
*/
|
|
38
46
|
reject(_error: unknown): void;
|
|
39
47
|
}
|
|
@@ -42,6 +50,10 @@ export interface Deferred<T> {
|
|
|
42
50
|
* operations.
|
|
43
51
|
* Useful for rate-limiting or to avoid overwhelming resources with too many concurrent operations.
|
|
44
52
|
*
|
|
53
|
+
* @public
|
|
54
|
+
* @param items
|
|
55
|
+
* @param concurrency
|
|
56
|
+
* @param callback
|
|
45
57
|
* @example
|
|
46
58
|
* ```ts
|
|
47
59
|
* const items = [...lotsOfItems];
|
|
@@ -55,6 +67,9 @@ export declare function forEachWithConcurrency<T>(items: readonly T[], concurren
|
|
|
55
67
|
* Like setTimeout(), but does not advance the clock if the program is
|
|
56
68
|
* stopped on a debugger breakpoint.
|
|
57
69
|
*
|
|
70
|
+
* @public
|
|
71
|
+
* @param callback
|
|
72
|
+
* @param timeout
|
|
58
73
|
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60405
|
|
59
74
|
*/
|
|
60
75
|
export declare const devToolsAwareTimeout: (callback: () => void, timeout: number) => ReturnType<typeof setInterval>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Convert kebab-case string to PascalCase
|
|
3
3
|
*
|
|
4
|
+
* @public
|
|
5
|
+
* @param string
|
|
4
6
|
* @example
|
|
5
7
|
* ```ts
|
|
6
8
|
* const pascal = kebabToPascal("my-component-name");
|
|
@@ -10,6 +12,8 @@ export declare const kebabToPascal: (string: string) => string;
|
|
|
10
12
|
/**
|
|
11
13
|
* Convert camelCase string to kebab-case
|
|
12
14
|
*
|
|
15
|
+
* @public
|
|
16
|
+
* @param string
|
|
13
17
|
* @example
|
|
14
18
|
* ```ts
|
|
15
19
|
* const kebab = camelToKebab("myComponentName");
|
|
@@ -20,6 +24,8 @@ export declare const camelToKebab: (string: string) => string;
|
|
|
20
24
|
/**
|
|
21
25
|
* Convert camelCase string to Sentence case.
|
|
22
26
|
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param string
|
|
23
29
|
* @example
|
|
24
30
|
* ```ts
|
|
25
31
|
* const human = camelToHuman("myComponentName");
|
|
@@ -27,26 +33,44 @@ export declare const camelToKebab: (string: string) => string;
|
|
|
27
33
|
* ```
|
|
28
34
|
*/
|
|
29
35
|
export declare const camelToHuman: (string: string) => string;
|
|
30
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Capitalize the first letter of a string.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
* @param string
|
|
41
|
+
*/
|
|
31
42
|
export declare const capitalize: <T extends string>(string: T) => Capitalize<T>;
|
|
32
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Uncapitalize the first letter of a string.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @param string
|
|
48
|
+
*/
|
|
33
49
|
export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
|
|
34
50
|
/**
|
|
35
51
|
* Add quotes to a string for display purposes.
|
|
36
52
|
* If the string contains a double quote, then single quotes will be used.
|
|
37
53
|
* If the string contains a single quote, then double quotes will be used.
|
|
38
54
|
* If the string contains both, then double quotes will be used and the single quotes will be escaped.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
* @param value
|
|
39
58
|
*/
|
|
40
59
|
export declare const quoteString: (value: string) => string;
|
|
41
60
|
/**
|
|
42
61
|
* Create a filter expression from a filter word.
|
|
43
62
|
*
|
|
44
|
-
*
|
|
63
|
+
* > Once browser support permits, use `RegExp.escape()` instead.
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
* @param filterWord
|
|
45
67
|
* @privateRemarks TODO: DEPRECATE
|
|
46
68
|
*/
|
|
47
69
|
export declare const createFilterExpression: (filterWord: string) => RegExp;
|
|
48
70
|
/**
|
|
49
71
|
* Add LTR marks to a string to ensure it is displayed as LTR even in RTL contexts.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
50
74
|
* @param value The string to add LTR marks to.
|
|
51
75
|
* @returns The string with LTR marks.
|
|
52
76
|
*
|
|
@@ -58,6 +82,8 @@ export declare const createFilterExpression: (filterWord: string) => RegExp;
|
|
|
58
82
|
export declare const addLtrMark: (value: string | undefined) => string;
|
|
59
83
|
/**
|
|
60
84
|
* A string containing a randomly generated, 36 character long v4 UUID.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
61
87
|
*/
|
|
62
88
|
export type UUID = ReturnType<typeof crypto.randomUUID>;
|
|
63
89
|
/**
|
|
@@ -69,6 +95,7 @@ export type UUID = ReturnType<typeof crypto.randomUUID>;
|
|
|
69
95
|
* Avoid using GUID and other non-deterministic output in render() as they
|
|
70
96
|
* cause SSR hydration issues and snapshot test instability.
|
|
71
97
|
*
|
|
98
|
+
* @public
|
|
72
99
|
* @example
|
|
73
100
|
* ```ts
|
|
74
101
|
* const id = generateGuid();
|
|
@@ -79,6 +106,8 @@ export declare const generateGuid: () => UUID;
|
|
|
79
106
|
/**
|
|
80
107
|
* Extract the major and minor version from a full version string.
|
|
81
108
|
*
|
|
109
|
+
* @public
|
|
110
|
+
* @param version
|
|
82
111
|
* @example
|
|
83
112
|
* ```ts
|
|
84
113
|
* const minorVersion = getMinorVersion("4.34.0-next.123");
|
|
@@ -93,6 +122,8 @@ export declare const getMinorVersion: (version: string) => string;
|
|
|
93
122
|
* The version number should normally come from package.json.
|
|
94
123
|
*
|
|
95
124
|
* @see https://webgis.esri.com/sdk/contributing/licensing
|
|
125
|
+
* @public
|
|
126
|
+
* @param version
|
|
96
127
|
* @example
|
|
97
128
|
* ```ts
|
|
98
129
|
* const preamble = getPreamble("5.0.1-next.456");
|
|
@@ -104,6 +135,9 @@ export declare const getPreamble: (version: string) => string;
|
|
|
104
135
|
* Replace values in a string using the format {valueName} with the value from the values object.
|
|
105
136
|
* If the value is not found in the values object, then the value is not replaced.
|
|
106
137
|
*
|
|
138
|
+
* @public
|
|
139
|
+
* @param message
|
|
140
|
+
* @param values
|
|
107
141
|
* @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/references/core/intl/#substitute instead
|
|
108
142
|
*/
|
|
109
143
|
export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
|
|
@@ -113,6 +147,9 @@ export declare const setValuesInString: (message: string | null | undefined, val
|
|
|
113
147
|
*
|
|
114
148
|
* Throws when the named region cannot be found or is missing its closing marker.
|
|
115
149
|
*
|
|
150
|
+
* @public
|
|
151
|
+
* @param source
|
|
152
|
+
* @param regionName
|
|
116
153
|
* @example
|
|
117
154
|
* ```ts
|
|
118
155
|
* import code from "my-code-file.ts?raw";
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A convenient alias for `null | undefined`.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* > Named `nil` over `Nil` as per https://devtopia.esri.com/WebGIS/arcgis-js-api/pull/66920
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
4
7
|
*/
|
|
5
8
|
export type nil = null | undefined;
|
|
6
9
|
/**
|
|
10
|
+
* @public
|
|
7
11
|
* @deprecated import type { ResourceHandle } from "@arcgis/core/core/Handles.js";
|
|
8
12
|
*/
|
|
9
13
|
export type IHandle = {
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* @deprecated import type { ResourceHandle } from "@arcgis/core/core/Handles.js";
|
|
17
|
+
*/
|
|
10
18
|
remove: () => void;
|
|
11
19
|
};
|
|
12
20
|
/**
|
|
21
|
+
* @public
|
|
13
22
|
* @deprecated Import type { nil } from `@arcgis/toolkit/type` instead
|
|
14
23
|
*/
|
|
15
24
|
export type Nil = nil;
|
|
@@ -23,6 +32,7 @@ export type Nil = nil;
|
|
|
23
32
|
* During production end-application build, such type tests will be removed as
|
|
24
33
|
* they have no runtime impact.
|
|
25
34
|
*
|
|
35
|
+
* @public
|
|
26
36
|
* @privateRemarks
|
|
27
37
|
* Using `0` over `undefined` to take fewer bytes if minifier is disabled.
|
|
28
38
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compares two url strings for their origin and returns true if they have the same origin.
|
|
3
3
|
*
|
|
4
|
+
* @public
|
|
4
5
|
* @param url1 First url string
|
|
5
6
|
* @param url2 Second url string
|
|
6
7
|
* @param ignoreProtocol Indicates if protocol comparison should be ignored
|
|
@@ -9,10 +10,10 @@
|
|
|
9
10
|
export declare const hasSameOrigin: (url1: string | null | undefined, url2: string | null | undefined, ignoreProtocol?: boolean) => boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Tests if a url string is a URL or not.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @deprecated Use https://developer.mozilla.org/docs/Web/API/URL/parse_static instead
|
|
12
16
|
* @param url The url string to test
|
|
13
17
|
* @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
|
*/
|
|
18
19
|
export declare const isURL: (url: string) => boolean;
|