@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
package/dist/dom/slots.d.cts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has any content (text or elements).
|
|
3
|
-
*
|
|
4
|
-
* @param event The event.
|
|
5
|
-
* @returns Whether the slot has any content.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <slot onSlotchange={(event) => this.mySlotHasContent = slotChangeHasContent(event)} />}
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare function slotChangeHasContent(event: Event): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Returns a string of textContent if the target `slot` element from the `onSlotchange` event has any text content.
|
|
15
|
-
*
|
|
16
|
-
* @param event The event.
|
|
17
|
-
* @returns The slots text.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <slot onSlotchange={(event) => this.mySlotText = slotChangeGetTextContent(event)} />}
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function slotChangeGetTextContent(event: Event): string;
|
|
25
|
-
/**
|
|
26
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has any text content.
|
|
27
|
-
*
|
|
28
|
-
* @param event The event.
|
|
29
|
-
* @returns Whether the slot has any text content.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <slot onSlotchange={(event) => this.mySlotHasTextContent = slotChangeHasTextContent(event)} />}
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function slotChangeHasTextContent(event: Event): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned node.
|
|
39
|
-
*
|
|
40
|
-
* @param event The event.
|
|
41
|
-
* @returns Whether the slot has any assigned nodes.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* <slot onSlotchange={(event) => this.mySlotHasNode = slotChangeHasAssignedNode(event)} />}
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare function slotChangeHasAssignedNode(event: Event): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the assigned nodes on a `slot` element from the `onSlotchange` event.
|
|
51
|
-
*
|
|
52
|
-
* @param event The event.
|
|
53
|
-
* @returns Whether the slot has any assigned nodes.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```tsx
|
|
57
|
-
* <slot onSlotchange={(event) => this.mySlotNodes = slotChangeGetAssignedNodes(event)} />}
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function slotChangeGetAssignedNodes(event: Event): Node[];
|
|
61
|
-
/**
|
|
62
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned element.
|
|
63
|
-
*
|
|
64
|
-
* @param event The event.
|
|
65
|
-
* @returns Whether the slot has any assigned elements.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* <slot onSlotchange={(event) => this.mySlotHasElement = slotChangeHasAssignedElement(event)} />}
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export declare function slotChangeHasAssignedElement(event: Event): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the assigned elements on a `slot` element from the `onSlotchange` event.
|
|
75
|
-
*
|
|
76
|
-
* @param event The event.
|
|
77
|
-
* @param selector The CSS selector string to filter the returned elements by.
|
|
78
|
-
* @returns An array of elements.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* <slot onSlotchange={(event) => this.mySlotElements = slotChangeGetAssignedElements(event)} />}
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare function slotChangeGetAssignedElements<T extends Element>(event: Event, selector?: string): T[];
|
|
86
|
-
/**
|
|
87
|
-
* Returns the assigned elements on a `slot` element, filtered by an optional css selector.
|
|
88
|
-
*
|
|
89
|
-
* @param slot The slot element.
|
|
90
|
-
* @param selector CSS selector string to filter the returned elements by.
|
|
91
|
-
* @returns An array of elements.
|
|
92
|
-
*/
|
|
93
|
-
export declare function getSlotAssignedElements<T extends Element>(slot: HTMLSlotElement, selector?: string): T[];
|
package/dist/error/index.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const isEsriInternalEnv = () => (
|
|
4
|
-
//#endregion isEsriInternalEnv
|
|
5
|
-
/*
|
|
6
|
-
* `globalThis.` is important here. Some bundlers remove the `typeof process`
|
|
7
|
-
* checks, but don't remove the usages of undefined variables - this can cause
|
|
8
|
-
* runtime error. By adding `globalThis.`, we avoid having `typeof process`
|
|
9
|
-
* check removed by the bundler.
|
|
10
|
-
* This does meant tree-shaking won't happen for the isEsriInternalEnv()
|
|
11
|
-
* check, but this is ok since this check is meant to always be behind the
|
|
12
|
-
* development/test guard.
|
|
13
|
-
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/pull/2087#issuecomment-5152454
|
|
14
|
-
*/
|
|
15
|
-
typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL
|
|
16
|
-
);
|
|
17
|
-
const safeCall = (callback, thisContext, ...rest) => {
|
|
18
|
-
try {
|
|
19
|
-
return callback?.call(thisContext, ...rest);
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error(error, callback);
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
};
|
|
25
|
-
const safeAsyncCall = async (callback, thisContext, ...rest) => {
|
|
26
|
-
try {
|
|
27
|
-
const result = callback?.call(thisContext, ...rest);
|
|
28
|
-
return await result;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(error, callback);
|
|
31
|
-
}
|
|
32
|
-
return void 0;
|
|
33
|
-
};
|
|
34
|
-
exports.isEsriInternalEnv = isEsriInternalEnv;
|
|
35
|
-
exports.safeAsyncCall = safeAsyncCall;
|
|
36
|
-
exports.safeCall = safeCall;
|
package/dist/error/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check whether the code is executing in an Esri internal environment (for
|
|
3
|
-
* example, Lumina dev server). When true, your code can enable extra validation
|
|
4
|
-
* to detect incorrect usages or do runtime bug detection.
|
|
5
|
-
*
|
|
6
|
-
* The call to isEsriInternalEnv() MUST always appear behind one of the
|
|
7
|
-
* following guards to ensure it is correctly eliminated in production bundles:
|
|
8
|
-
*
|
|
9
|
-
* - `process.env.NODE_ENV !== "production"`
|
|
10
|
-
* - `process.env.NODE_ENV === "development"`
|
|
11
|
-
* - `process.env.NODE_ENV === "test"`
|
|
12
|
-
*
|
|
13
|
-
* [Documentation](https://webgis.esri.com/references/lumina/publishing#internal-esri-environment)
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* This function is primary for usage in support packages. In Lumina component
|
|
17
|
-
* packages, simpler alternatives are provided:
|
|
18
|
-
* https://webgis.esri.com/references/lumina/publishing#bundling-code-conditionally
|
|
19
|
-
*/
|
|
20
|
-
export declare const isEsriInternalEnv: () => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Calls a sync method and catch any errors. Returns undefined if error occurred.
|
|
23
|
-
*
|
|
24
|
-
* Can also provide a thisContext and rest arguments
|
|
25
|
-
*/
|
|
26
|
-
export declare const safeCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => ReturnType<Callback> | void;
|
|
27
|
-
/**
|
|
28
|
-
* Calls an async method and catch any errors. Returns undefined if error occurred.
|
|
29
|
-
*
|
|
30
|
-
* Can also provide a thisContext and rest arguments
|
|
31
|
-
*/
|
|
32
|
-
export declare const safeAsyncCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => Promise<Awaited<ReturnType<Callback>> | void>;
|
package/dist/function/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const identity = (value) => value;
|
|
4
|
-
const debounce = (func, waitFor = 100) => {
|
|
5
|
-
let timeout;
|
|
6
|
-
return (...args) => {
|
|
7
|
-
const later = () => {
|
|
8
|
-
clearTimeout(timeout);
|
|
9
|
-
func(...args);
|
|
10
|
-
};
|
|
11
|
-
clearTimeout(timeout);
|
|
12
|
-
timeout = setTimeout(later, waitFor);
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
exports.debounce = debounce;
|
|
16
|
-
exports.identity = identity;
|
package/dist/function/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identity function - returns back the first parameter
|
|
3
|
-
*
|
|
4
|
-
* Useful when providing a "mapping function" is required, but you have no need
|
|
5
|
-
* to change the value
|
|
6
|
-
*
|
|
7
|
-
* @privateRemarks
|
|
8
|
-
* This is a trivial function, but it helps workaround a TypeScript bug:
|
|
9
|
-
* https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/2047
|
|
10
|
-
*/
|
|
11
|
-
export declare const identity: <T>(value: T) => T;
|
|
12
|
-
/**
|
|
13
|
-
* Allows to debounce a function.
|
|
14
|
-
*
|
|
15
|
-
* @param func Function to be debounced
|
|
16
|
-
* @param waitFor Debounce time in milliseconds
|
|
17
|
-
* @returns Returns a function that can be called to debounce the original function
|
|
18
|
-
*/
|
|
19
|
-
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(func: F, waitFor?: number) => ((...args: Parameters<F>) => void);
|
package/dist/intl/index.cjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const dom_index = require("../dom/index.cjs");
|
|
4
|
-
const log_index = require("../log/index.cjs");
|
|
5
|
-
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(
|
|
6
|
-
","
|
|
7
|
-
);
|
|
8
|
-
const supportedLocales = (
|
|
9
|
-
//#endregion supportedLocales
|
|
10
|
-
/* @__PURE__ */ new Set(supportedLocalesArray)
|
|
11
|
-
);
|
|
12
|
-
const defaultLocale = "en";
|
|
13
|
-
const localeEquivalencies = {
|
|
14
|
-
//#region localeEquivalencies
|
|
15
|
-
// Locale equivalencies aligned with ArcGIS Maps SDK for JavaScript:
|
|
16
|
-
// https://developers.arcgis.com/javascript/latest/localization/#locale-support
|
|
17
|
-
// We resolve to `pt-BR` as it will have the same translations as `pt`, which has no corresponding bundle
|
|
18
|
-
pt: "pt-BR",
|
|
19
|
-
// We support both 'nb' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
20
|
-
nb: "no",
|
|
21
|
-
// We support both 'nn' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
22
|
-
// See https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/4667
|
|
23
|
-
nn: "no",
|
|
24
|
-
// We use `zh-CN` as base translation for chinese locales which has no corresponding bundle.
|
|
25
|
-
zh: "zh-CN"
|
|
26
|
-
//#endregion localeEquivalencies
|
|
27
|
-
};
|
|
28
|
-
const fetchT9nStringsBundle = async (locale, assetsPath, prefix = "") => {
|
|
29
|
-
const path = `${assetsPath}/${prefix}`;
|
|
30
|
-
const filePath = `${path}${locale}.json`;
|
|
31
|
-
t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
|
|
32
|
-
return await t9nStringsCache[filePath];
|
|
33
|
-
};
|
|
34
|
-
const t9nStringsCache = {};
|
|
35
|
-
const fetchBundle = async (locale, path) => {
|
|
36
|
-
const filePath = `${path}${locale}.json`;
|
|
37
|
-
try {
|
|
38
|
-
const response = await fetch(filePath);
|
|
39
|
-
if (response.ok) {
|
|
40
|
-
return await response.json();
|
|
41
|
-
}
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (process.env.NODE_ENV !== "production") {
|
|
44
|
-
const is404ViteFallback = String(error).includes(`Unexpected token '<', "<!doctype "... is not valid JSON`);
|
|
45
|
-
if (is404ViteFallback) {
|
|
46
|
-
log_index.log("error", "intl", `Localization strings not found at ${filePath}`);
|
|
47
|
-
} else {
|
|
48
|
-
log_index.log("error", "intl", `Error fetching localization strings at ${filePath}`, { detail: { error } });
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
log_index.log("error", "intl", `An unknown error occurred while fetching localization strings at ${filePath}`, {
|
|
52
|
-
detail: { error }
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
if (locale === defaultLocale) {
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
return await fetchBundle(defaultLocale, path);
|
|
61
|
-
};
|
|
62
|
-
const getElementLocale = (element) => {
|
|
63
|
-
const lang = dom_index.getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
64
|
-
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
65
|
-
};
|
|
66
|
-
const normalizeLocale = (lang) => {
|
|
67
|
-
const [rawLanguageCode, regionCode] = lang.split("-");
|
|
68
|
-
const languageCode = rawLanguageCode.toLowerCase();
|
|
69
|
-
let normalizedLocale = languageCode;
|
|
70
|
-
if (regionCode) {
|
|
71
|
-
normalizedLocale = `${languageCode}-${regionCode.toUpperCase()}`;
|
|
72
|
-
}
|
|
73
|
-
normalizedLocale = localeEquivalencies[normalizedLocale] ?? normalizedLocale;
|
|
74
|
-
if (supportedLocales.has(normalizedLocale)) {
|
|
75
|
-
return normalizedLocale;
|
|
76
|
-
}
|
|
77
|
-
if (regionCode) {
|
|
78
|
-
return normalizeLocale(languageCode);
|
|
79
|
-
}
|
|
80
|
-
return defaultLocale;
|
|
81
|
-
};
|
|
82
|
-
const startLocaleObserver = (element, getAssetsPath, onUpdated, assetName) => {
|
|
83
|
-
let result = void 0;
|
|
84
|
-
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
85
|
-
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
86
|
-
onUpdated(newResult);
|
|
87
|
-
}
|
|
88
|
-
result = newResult;
|
|
89
|
-
}).catch((error) => {
|
|
90
|
-
log_index.log("error", "intl", "Error updating component locale state", { detail: { error } });
|
|
91
|
-
});
|
|
92
|
-
queueMicrotask(callback);
|
|
93
|
-
return dom_index.observeAncestorsMutation(element, ["lang"], callback);
|
|
94
|
-
};
|
|
95
|
-
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
96
|
-
const { lang, t9nLocale } = getElementLocale(element);
|
|
97
|
-
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
98
|
-
const prefix = `messages.`;
|
|
99
|
-
const t9nStrings = (
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
101
|
-
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
102
|
-
);
|
|
103
|
-
return { lang, t9nLocale, t9nStrings };
|
|
104
|
-
};
|
|
105
|
-
exports.defaultLocale = defaultLocale;
|
|
106
|
-
exports.fetchT9nStringsBundle = fetchT9nStringsBundle;
|
|
107
|
-
exports.getElementLocale = getElementLocale;
|
|
108
|
-
exports.normalizeLocale = normalizeLocale;
|
|
109
|
-
exports.startLocaleObserver = startLocaleObserver;
|
|
110
|
-
exports.supportedLocales = supportedLocales;
|
package/dist/intl/index.d.cts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
declare 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"];
|
|
2
|
-
/**
|
|
3
|
-
* The list of supported locales for ArcGIS Maps SDK for JavaScript components.
|
|
4
|
-
*/
|
|
5
|
-
export declare const supportedLocales: Set<"hr" | "th" | "tr" | "el" | "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nl" | "nb" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW">;
|
|
6
|
-
/**
|
|
7
|
-
* TypeScript union type for each locale supported by WebGIS SDK
|
|
8
|
-
*/
|
|
9
|
-
export type SupportedLocale = (typeof supportedLocalesArray)[number];
|
|
10
|
-
/**
|
|
11
|
-
* The default locale for WebGIS SDK.
|
|
12
|
-
*/
|
|
13
|
-
export declare const defaultLocale = "en";
|
|
14
|
-
/**
|
|
15
|
-
* Fetch the T9N strings bundle for the given locale, assets path and prefix.
|
|
16
|
-
* The locale must be one of the supported locales.
|
|
17
|
-
* If the locale is not supported, it will default to 'en'.
|
|
18
|
-
* If the T9N strings bundle cannot be found, it will default to 'en'.
|
|
19
|
-
*
|
|
20
|
-
* @param locale The locale for which to fetch the T9N strings
|
|
21
|
-
* @param assetsPath The path to the assets folder where the T9N strings are located
|
|
22
|
-
* @param prefix The prefix to use for the T9N strings file name.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Rather than using this function directly, prefer the
|
|
26
|
-
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
27
|
-
* controller.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* The function implements cache. Frequent calls are safe.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* // Will make a request for ./assets/coding-editor/t9n/messages.en.json
|
|
35
|
-
* const t9nStrings = await fetchT9nStringsBundle(
|
|
36
|
-
* "en",
|
|
37
|
-
* getAssetPath("./assets/coding-editor/t9n"),
|
|
38
|
-
* "messages."
|
|
39
|
-
* );
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @see [Lumina asset handling](https://webgis.esri.com/references/lumina/assets)
|
|
43
|
-
*/
|
|
44
|
-
export declare const fetchT9nStringsBundle: <Strings extends GenericT9nStrings>(locale: string, assetsPath: string, prefix?: string) => Promise<Strings>;
|
|
45
|
-
/**
|
|
46
|
-
* The interface for translated strings.
|
|
47
|
-
*/
|
|
48
|
-
export interface GenericT9nStrings {
|
|
49
|
-
[key: string]: GenericT9nStrings | string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the locale of the given element.
|
|
53
|
-
* It will look for the lang attribute on the element and its ancestors.
|
|
54
|
-
* If not lang is found, it will default to 'en'.
|
|
55
|
-
*
|
|
56
|
-
* @returns an object with the `lang` and `t9nLocale` properties.
|
|
57
|
-
*
|
|
58
|
-
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
|
|
59
|
-
*/
|
|
60
|
-
export declare const getElementLocale: (element: HTMLElement) => {
|
|
61
|
-
readonly lang: string;
|
|
62
|
-
readonly t9nLocale: SupportedLocale;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Try to parse any language string into one of the locales supported by WebGIS SDK.
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
* Follows the ArcGIS Maps SDK for JavaScript locale support:
|
|
69
|
-
* https://developers.arcgis.com/javascript/latest/localization/#locale-support
|
|
70
|
-
*
|
|
71
|
-
* If language includes a region code, but we don't have a bundle for it, the
|
|
72
|
-
* language is normalized to the language code only.
|
|
73
|
-
*/
|
|
74
|
-
export declare const normalizeLocale: (lang: string) => SupportedLocale;
|
|
75
|
-
export interface LocaleObserverResult<Strings extends GenericT9nStrings = GenericT9nStrings> {
|
|
76
|
-
/** The T9N strings of the component */
|
|
77
|
-
t9nStrings: Strings;
|
|
78
|
-
/**
|
|
79
|
-
* The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
|
|
80
|
-
*/
|
|
81
|
-
lang: string;
|
|
82
|
-
/**
|
|
83
|
-
* The locale used by the component to load the T9N strings.
|
|
84
|
-
* It may be different than the locale of the component host element that was set by the `lang` attribute.
|
|
85
|
-
*/
|
|
86
|
-
t9nLocale: SupportedLocale;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Start the locale observer for the given component.
|
|
90
|
-
* The callback will be called when the locale changes for the component.
|
|
91
|
-
* It will observe the lang attribute on the component and its ancestors.
|
|
92
|
-
* The callback is called once at the beginning.
|
|
93
|
-
*
|
|
94
|
-
* @param element The HTML element that is doing the fetching
|
|
95
|
-
* This is used to determine the locale to fetch, observe the `lang` attribute
|
|
96
|
-
* changes, and is used as the default value for the `assetName` parameter.
|
|
97
|
-
* @param getAssetsPath The callback to get path to the assets folder where the
|
|
98
|
-
* T9N strings are located.
|
|
99
|
-
* @param onUpdated The callback to call when the locale changes.
|
|
100
|
-
* @param assetName Optionally override the asset file name.
|
|
101
|
-
* Default file name is the element tag name without the part before the
|
|
102
|
-
* first dash (e.g. `arcgis-map` becomes `map`).
|
|
103
|
-
*
|
|
104
|
-
* Set to null if the component has no localization strings, but you still
|
|
105
|
-
* wish to use `startLocaleObserver` to get the locale information.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* Rather than using this function directly, prefer the
|
|
109
|
-
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
110
|
-
* controller.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* const observer = startLocaleObserver(
|
|
115
|
-
* element,
|
|
116
|
-
* () => getAssetPath("./assets"),
|
|
117
|
-
* ({ strings, lang, t9nLocale }) => console.log({ strings, lang, t9nLocale }),
|
|
118
|
-
* );
|
|
119
|
-
* // Later: cleanup
|
|
120
|
-
* observer();
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResult<Strings>) => void, assetName?: string | null) => (() => void);
|
|
124
|
-
export {};
|
package/dist/intl/index.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
declare 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"];
|
|
2
|
-
/**
|
|
3
|
-
* The list of supported locales for ArcGIS Maps SDK for JavaScript components.
|
|
4
|
-
*/
|
|
5
|
-
export declare const supportedLocales: Set<"hr" | "th" | "tr" | "el" | "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nl" | "nb" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW">;
|
|
6
|
-
/**
|
|
7
|
-
* TypeScript union type for each locale supported by WebGIS SDK
|
|
8
|
-
*/
|
|
9
|
-
export type SupportedLocale = (typeof supportedLocalesArray)[number];
|
|
10
|
-
/**
|
|
11
|
-
* The default locale for WebGIS SDK.
|
|
12
|
-
*/
|
|
13
|
-
export declare const defaultLocale = "en";
|
|
14
|
-
/**
|
|
15
|
-
* Fetch the T9N strings bundle for the given locale, assets path and prefix.
|
|
16
|
-
* The locale must be one of the supported locales.
|
|
17
|
-
* If the locale is not supported, it will default to 'en'.
|
|
18
|
-
* If the T9N strings bundle cannot be found, it will default to 'en'.
|
|
19
|
-
*
|
|
20
|
-
* @param locale The locale for which to fetch the T9N strings
|
|
21
|
-
* @param assetsPath The path to the assets folder where the T9N strings are located
|
|
22
|
-
* @param prefix The prefix to use for the T9N strings file name.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Rather than using this function directly, prefer the
|
|
26
|
-
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
27
|
-
* controller.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* The function implements cache. Frequent calls are safe.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* // Will make a request for ./assets/coding-editor/t9n/messages.en.json
|
|
35
|
-
* const t9nStrings = await fetchT9nStringsBundle(
|
|
36
|
-
* "en",
|
|
37
|
-
* getAssetPath("./assets/coding-editor/t9n"),
|
|
38
|
-
* "messages."
|
|
39
|
-
* );
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @see [Lumina asset handling](https://webgis.esri.com/references/lumina/assets)
|
|
43
|
-
*/
|
|
44
|
-
export declare const fetchT9nStringsBundle: <Strings extends GenericT9nStrings>(locale: string, assetsPath: string, prefix?: string) => Promise<Strings>;
|
|
45
|
-
/**
|
|
46
|
-
* The interface for translated strings.
|
|
47
|
-
*/
|
|
48
|
-
export interface GenericT9nStrings {
|
|
49
|
-
[key: string]: GenericT9nStrings | string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the locale of the given element.
|
|
53
|
-
* It will look for the lang attribute on the element and its ancestors.
|
|
54
|
-
* If not lang is found, it will default to 'en'.
|
|
55
|
-
*
|
|
56
|
-
* @returns an object with the `lang` and `t9nLocale` properties.
|
|
57
|
-
*
|
|
58
|
-
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
|
|
59
|
-
*/
|
|
60
|
-
export declare const getElementLocale: (element: HTMLElement) => {
|
|
61
|
-
readonly lang: string;
|
|
62
|
-
readonly t9nLocale: SupportedLocale;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Try to parse any language string into one of the locales supported by WebGIS SDK.
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
* Follows the ArcGIS Maps SDK for JavaScript locale support:
|
|
69
|
-
* https://developers.arcgis.com/javascript/latest/localization/#locale-support
|
|
70
|
-
*
|
|
71
|
-
* If language includes a region code, but we don't have a bundle for it, the
|
|
72
|
-
* language is normalized to the language code only.
|
|
73
|
-
*/
|
|
74
|
-
export declare const normalizeLocale: (lang: string) => SupportedLocale;
|
|
75
|
-
export interface LocaleObserverResult<Strings extends GenericT9nStrings = GenericT9nStrings> {
|
|
76
|
-
/** The T9N strings of the component */
|
|
77
|
-
t9nStrings: Strings;
|
|
78
|
-
/**
|
|
79
|
-
* The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
|
|
80
|
-
*/
|
|
81
|
-
lang: string;
|
|
82
|
-
/**
|
|
83
|
-
* The locale used by the component to load the T9N strings.
|
|
84
|
-
* It may be different than the locale of the component host element that was set by the `lang` attribute.
|
|
85
|
-
*/
|
|
86
|
-
t9nLocale: SupportedLocale;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Start the locale observer for the given component.
|
|
90
|
-
* The callback will be called when the locale changes for the component.
|
|
91
|
-
* It will observe the lang attribute on the component and its ancestors.
|
|
92
|
-
* The callback is called once at the beginning.
|
|
93
|
-
*
|
|
94
|
-
* @param element The HTML element that is doing the fetching
|
|
95
|
-
* This is used to determine the locale to fetch, observe the `lang` attribute
|
|
96
|
-
* changes, and is used as the default value for the `assetName` parameter.
|
|
97
|
-
* @param getAssetsPath The callback to get path to the assets folder where the
|
|
98
|
-
* T9N strings are located.
|
|
99
|
-
* @param onUpdated The callback to call when the locale changes.
|
|
100
|
-
* @param assetName Optionally override the asset file name.
|
|
101
|
-
* Default file name is the element tag name without the part before the
|
|
102
|
-
* first dash (e.g. `arcgis-map` becomes `map`).
|
|
103
|
-
*
|
|
104
|
-
* Set to null if the component has no localization strings, but you still
|
|
105
|
-
* wish to use `startLocaleObserver` to get the locale information.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* Rather than using this function directly, prefer the
|
|
109
|
-
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
110
|
-
* controller.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* const observer = startLocaleObserver(
|
|
115
|
-
* element,
|
|
116
|
-
* () => getAssetPath("./assets"),
|
|
117
|
-
* ({ strings, lang, t9nLocale }) => console.log({ strings, lang, t9nLocale }),
|
|
118
|
-
* );
|
|
119
|
-
* // Later: cleanup
|
|
120
|
-
* observer();
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResult<Strings>) => void, assetName?: string | null) => (() => void);
|
|
124
|
-
export {};
|
package/dist/log/index.cjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const loggedMessages = /* @__PURE__ */ new Set();
|
|
4
|
-
let esriConfig;
|
|
5
|
-
const setEsriConfig = (config) => {
|
|
6
|
-
esriConfig = config;
|
|
7
|
-
};
|
|
8
|
-
const getContextString = (context) => {
|
|
9
|
-
if (typeof context === "string") {
|
|
10
|
-
return context;
|
|
11
|
-
}
|
|
12
|
-
if ("el" in context) {
|
|
13
|
-
return context.el.localName;
|
|
14
|
-
}
|
|
15
|
-
if ("localName" in context) {
|
|
16
|
-
return context.localName;
|
|
17
|
-
}
|
|
18
|
-
return context.declaredClass;
|
|
19
|
-
};
|
|
20
|
-
const log = (level, context, message, options) => {
|
|
21
|
-
const contextString = getContextString(context);
|
|
22
|
-
if (options?.once) {
|
|
23
|
-
const key = `${level}${contextString}${message}`;
|
|
24
|
-
if (loggedMessages.has(key)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
loggedMessages.add(key);
|
|
28
|
-
}
|
|
29
|
-
let memorySafeDetail;
|
|
30
|
-
if (options?.detail) {
|
|
31
|
-
memorySafeDetail = {};
|
|
32
|
-
for (const [key, value] of Object.entries(options.detail)) {
|
|
33
|
-
if ((typeof value === "object" || typeof value === "function") && value !== null) {
|
|
34
|
-
const weakRefValue = new WeakRef(value);
|
|
35
|
-
Object.defineProperty(memorySafeDetail, key, {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get() {
|
|
38
|
-
return weakRefValue.deref();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
memorySafeDetail[key] = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
esriConfig?.log.interceptors?.forEach(
|
|
46
|
-
(interceptor) => interceptor(level, contextString, message, memorySafeDetail)
|
|
47
|
-
);
|
|
48
|
-
console[level](`[${contextString}]: ${message}`, memorySafeDetail);
|
|
49
|
-
} else {
|
|
50
|
-
esriConfig?.log.interceptors?.forEach((interceptor) => interceptor(level, contextString, message));
|
|
51
|
-
console[level](`[${contextString}]: ${message}`);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const rethrowError = (context) => {
|
|
55
|
-
const prefix = `[${getContextString(context)}] `;
|
|
56
|
-
return (error) => {
|
|
57
|
-
const errorToRethrow = error instanceof Error && error.message ? error : new Error(String(error));
|
|
58
|
-
errorToRethrow.message = `${prefix}${errorToRethrow.message}`;
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
throw error;
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
const composeMissingPropertyMessage = (property) => (
|
|
65
|
-
//#endregion composeMissingPropertyMessage
|
|
66
|
-
`The property \`${property.toString()}\` is required but missing.`
|
|
67
|
-
);
|
|
68
|
-
const composeEmptyPropertyMessage = (property) => (
|
|
69
|
-
//#endregion composeEmptyPropertyMessage
|
|
70
|
-
`The property \`${property.toString()}\` is empty but must have at least one element.`
|
|
71
|
-
);
|
|
72
|
-
const logDeprecatedProperty = (context, oldName, newName, options) => (
|
|
73
|
-
//#endregion logDeprecatedProperty
|
|
74
|
-
log("warn", context, `\`${oldName.toString()}\` is deprecated. Use \`${newName.toString()}\` instead.`, options)
|
|
75
|
-
);
|
|
76
|
-
exports.composeEmptyPropertyMessage = composeEmptyPropertyMessage;
|
|
77
|
-
exports.composeMissingPropertyMessage = composeMissingPropertyMessage;
|
|
78
|
-
exports.log = log;
|
|
79
|
-
exports.logDeprecatedProperty = logDeprecatedProperty;
|
|
80
|
-
exports.rethrowError = rethrowError;
|
|
81
|
-
exports.setEsriConfig = setEsriConfig;
|