@itwin/core-i18n 5.8.1 → 5.8.3
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/CHANGELOG.md +11 -1
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js +210 -144
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.js +79 -13
- package/lib/cjs/test/webpack/bundled-tests.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.js.map +1 -1
- package/package.json +6 -6
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
/** @packageDocumentation
|
|
18
18
|
* @module Localization
|
|
19
19
|
*/
|
|
20
|
-
function
|
|
21
|
-
var path = "C:\\agent\\_work\\
|
|
22
|
-
var hash = "
|
|
20
|
+
function cov_ogldeftyv() {
|
|
21
|
+
var path = "C:\\agent\\_work\\1\\s\\core\\i18n\\lib\\cjs\\ITwinLocalization.js";
|
|
22
|
+
var hash = "d940188727f7c3f13464903c9fef76d730c540e6";
|
|
23
23
|
var global = new Function("return this")();
|
|
24
24
|
var gcv = "__coverage__";
|
|
25
25
|
var coverageData = {
|
|
26
|
-
path: "C:\\agent\\_work\\
|
|
26
|
+
path: "C:\\agent\\_work\\1\\s\\core\\i18n\\lib\\cjs\\ITwinLocalization.js",
|
|
27
27
|
statementMap: {
|
|
28
28
|
"0": {
|
|
29
29
|
start: {
|
|
@@ -2120,13 +2120,13 @@ function cov_1pm70a31qk() {
|
|
|
2120
2120
|
inputSourceMap: {
|
|
2121
2121
|
version: 3,
|
|
2122
2122
|
file: "ITwinLocalization.js",
|
|
2123
|
-
sources: ["C:\\agent\\_work\\
|
|
2123
|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AG,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC3C,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,mBAAmB,CAAC,IAAY;QACrC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AA7MD,8CA6MC;AAED,MAAM,iBAAiB;IACd,MAAM,CAAU,IAAI,GAAG,QAAQ,CAAC;IAChC,GAAG,CAAC,IAAc,IAAI,qBAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,IAAc,IAAI,qBAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,KAAK,CAAC,IAAc,IAAI,qBAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,gBAAgB,CAAC,IAAc;QACrC,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACrC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAC7B,OAAO,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC",
|
|
2126
2126
|
sourcesContent: ["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Localization\n */\n\nimport i18next, { i18n, InitOptions, Module, TOptionsBase } from \"i18next\";\nimport i18nextBrowserLanguageDetector, { DetectorOptions } from \"i18next-browser-languagedetector\";\nimport Backend, { HttpBackendOptions as BackendOptions } from \"i18next-http-backend\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\n\nconst DEFAULT_MAX_RETRIES: number = 1; // a low number prevents wasted time and potential timeouts when requesting localization files throws an error\n\n/** Options for ITwinLocalization\n * @public\n */\nexport interface LocalizationOptions {\n urlTemplate?: string;\n backendPlugin?: Module;\n detectorPlugin?: Module;\n initOptions?: InitOptions;\n backendHttpOptions?: BackendOptions;\n detectorOptions?: DetectorOptions;\n}\n\n/** Supplies localizations for iTwin.js\n * @note this class uses the [i18next](https://www.i18next.com/) package.\n * @public\n */\nexport class ITwinLocalization implements Localization {\n public i18next: i18n;\n private readonly _initOptions: InitOptions;\n private readonly _backendOptions: BackendOptions;\n private readonly _detectionOptions: DetectorOptions;\n private readonly _namespaces = new Map<string, Promise<void>>();\n\n public constructor(options?: LocalizationOptions) {\n this.i18next = i18next.createInstance();\n\n this._backendOptions = {\n loadPath: options?.urlTemplate ?? \"locales/{{lng}}/{{ns}}.json\",\n crossDomain: true,\n ...options?.backendHttpOptions,\n };\n\n this._detectionOptions = {\n order: [\"querystring\", \"navigator\", \"htmlTag\"],\n lookupQuerystring: \"lng\",\n caches: [],\n ...options?.detectorOptions,\n };\n\n this._initOptions = {\n interpolation: { escapeValue: true },\n fallbackLng: \"en\",\n maxRetries: DEFAULT_MAX_RETRIES,\n backend: this._backendOptions,\n detection: this._detectionOptions,\n ...options?.initOptions,\n };\n\n this.i18next\n .use(options?.detectorPlugin ?? i18nextBrowserLanguageDetector)\n .use(options?.backendPlugin ?? Backend)\n .use(TranslationLogger);\n }\n\n public async initialize(namespaces: string[]): Promise<void> {\n\n // Also consider namespaces passed into constructor\n const initNamespaces: string[] = [this._initOptions.ns || []].flat();\n const combinedNamespaces: Set<string> = new Set([...namespaces, ...initNamespaces]); // without duplicates\n\n const defaultNamespace: string | false | readonly string[] = this._initOptions.defaultNS ?? namespaces[0];\n if (defaultNamespace)\n combinedNamespaces.add(defaultNamespace as string); // Make sure default namespace is in namespaces list\n\n const initOptions: InitOptions = {\n ...this._initOptions,\n defaultNS: defaultNamespace,\n ns: [...combinedNamespaces],\n };\n\n // if in a development environment, set debugging\n if (process.env.NODE_ENV === \"development\")\n initOptions.debug = true;\n\n const initPromise = this.i18next.init(initOptions) as unknown as Promise<void>;\n\n for (const ns of namespaces)\n this._namespaces.set(ns, initPromise);\n\n return initPromise;\n }\n\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\n * For example:\n * ``` ts\n * \"MyKeys\": {\n * \"Key1\": \"First value\",\n * \"Key2\": \"Second value\"\n * }\n * ```\n *\n * ``` ts\n * i18.translateKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\n * ```\n * @param line The input line, potentially containing %{keys}.\n * @returns The line with all %{keys} translated\n * @public\n */\n public getLocalizedKeys(line: string): string {\n return line.replace(/\\%\\{(.+?)\\}/g, (_match, tag) => this.getLocalizedString(tag));\n }\n\n /** Return the translated value of a key.\n * @param key - the key that matches a property in the JSON localization file.\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\n * followed by a colon, followed by the property in the JSON file.\n * For example:\n * ``` ts\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\n * ```\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\n * @returns The string corresponding to the first key that resolves.\n * @throws Error if no keys resolve to a string.\n * @public\n */\n public getLocalizedString(key: string | string[], options?: TOptionsBase): string {\n if (options?.returnDetails || options?.returnObjects) {\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\n }\n\n const value = this.i18next.t(key, options);\n\n if (typeof value !== \"string\") {\n throw new Error(\"Translation key(s) string not found\");\n }\n\n return value;\n }\n\n /** Gets the English translation.\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\n * @param key - the key that matches a property in the JSON localization file.\n * @returns The string corresponding to the first key that resolves.\n * @throws Error if no keys resolve to a string.\n * @internal\n */\n public getEnglishString(namespace: string, key: string | string[], options?: TOptionsBase): string {\n if (options?.returnDetails || options?.returnObjects) {\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\n }\n\n options = {\n ...options,\n ns: namespace, // ensure namespace argument is used\n };\n\n const en = this.i18next.getFixedT(\"en\", namespace);\n const str = en(key, options);\n if (typeof str !== \"string\")\n throw new Error(\"Translation key(s) not found\");\n\n return str;\n }\n\n /** Get the promise for an already registered Namespace.\n * @param name - the name of the namespace\n * @public\n */\n public getNamespacePromise(name: string): Promise<void> | undefined {\n return this._namespaces.get(name);\n }\n\n /** @internal */\n public getLanguageList(): readonly string[] {\n return this.i18next.languages;\n }\n\n /** override the language detected in the browser */\n public async changeLanguage(language: string) {\n return this.i18next.changeLanguage(language) as unknown as Promise<void>;\n }\n\n /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.\n * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\n * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\n * @public\n */\n public async registerNamespace(name: string): Promise<void> {\n const existing = this._namespaces.get(name);\n if (existing !== undefined)\n return existing;\n\n const theReadPromise = new Promise<void>((resolve) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.i18next.loadNamespaces(name, (err) => {\n if (!err)\n return resolve();\n\n // Here we got a non-null err object.\n // This method is called when the system has attempted to load the resources for the namespaces for each possible locale.\n // For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.\n // Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.\n // There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.\n let locales = this.getLanguageList().map((thisLocale: any) => `/${thisLocale}/`);\n\n try {\n for (const thisError of err) {\n if (typeof thisError === \"string\")\n locales = locales.filter((thisLocale) => !thisError.includes(thisLocale));\n }\n } catch {\n locales = [];\n }\n // if we removed every locale from the array, it wasn't loaded.\n if (locales.length === 0)\n Logger.logError(\"i18n\", `No resources for namespace ${name} could be loaded`);\n\n resolve();\n });\n });\n this._namespaces.set(name, theReadPromise);\n return theReadPromise;\n }\n\n /** @internal */\n public unregisterNamespace(name: string): void {\n this._namespaces.delete(name);\n }\n}\n\nclass TranslationLogger {\n public static readonly type = \"logger\";\n public log(args: string[]) { Logger.logInfo(\"i18n\", this.createLogMessage(args)); }\n public warn(args: string[]) { Logger.logWarning(\"i18n\", this.createLogMessage(args)); }\n public error(args: string[]) { Logger.logError(\"i18n\", this.createLogMessage(args)); }\n private createLogMessage(args: string[]) {\n let message = args[0];\n for (let i = 1; i < args.length; ++i) {\n if (typeof args[i] === \"string\")\n message += `\\n ${args[i]}`;\n }\n return message;\n }\n}\n"]
|
|
2127
2127
|
},
|
|
2128
2128
|
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
|
|
2129
|
-
hash: "
|
|
2129
|
+
hash: "d940188727f7c3f13464903c9fef76d730c540e6"
|
|
2130
2130
|
};
|
|
2131
2131
|
var coverage = global[gcv] || (global[gcv] = {});
|
|
2132
2132
|
if (!coverage[path] || coverage[path].hash !== hash) {
|
|
@@ -2135,31 +2135,31 @@ function cov_1pm70a31qk() {
|
|
|
2135
2135
|
var actualCoverage = coverage[path];
|
|
2136
2136
|
{
|
|
2137
2137
|
// @ts-ignore
|
|
2138
|
-
|
|
2138
|
+
cov_ogldeftyv = function () {
|
|
2139
2139
|
return actualCoverage;
|
|
2140
2140
|
};
|
|
2141
2141
|
}
|
|
2142
2142
|
return actualCoverage;
|
|
2143
2143
|
}
|
|
2144
|
-
|
|
2145
|
-
var __importDefault = (
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
return (
|
|
2144
|
+
cov_ogldeftyv();
|
|
2145
|
+
var __importDefault = (cov_ogldeftyv().s[0]++, (cov_ogldeftyv().b[0][0]++, this) && (cov_ogldeftyv().b[0][1]++, this.__importDefault) || (cov_ogldeftyv().b[0][2]++, function (mod) {
|
|
2146
|
+
cov_ogldeftyv().f[0]++;
|
|
2147
|
+
cov_ogldeftyv().s[1]++;
|
|
2148
|
+
return (cov_ogldeftyv().b[2][0]++, mod) && (cov_ogldeftyv().b[2][1]++, mod.__esModule) ? (cov_ogldeftyv().b[1][0]++, mod) : (cov_ogldeftyv().b[1][1]++, {
|
|
2149
2149
|
"default": mod
|
|
2150
2150
|
});
|
|
2151
2151
|
}));
|
|
2152
|
-
|
|
2152
|
+
cov_ogldeftyv().s[2]++;
|
|
2153
2153
|
Object.defineProperty(exports, "__esModule", ({
|
|
2154
2154
|
value: true
|
|
2155
2155
|
}));
|
|
2156
|
-
|
|
2156
|
+
cov_ogldeftyv().s[3]++;
|
|
2157
2157
|
exports.ITwinLocalization = void 0;
|
|
2158
|
-
const i18next_1 = (
|
|
2159
|
-
const i18next_browser_languagedetector_1 = (
|
|
2160
|
-
const i18next_http_backend_1 = (
|
|
2161
|
-
const core_bentley_1 = (
|
|
2162
|
-
const DEFAULT_MAX_RETRIES = (
|
|
2158
|
+
const i18next_1 = (cov_ogldeftyv().s[4]++, __importDefault(__webpack_require__(/*! i18next */ "../../common/temp/node_modules/.pnpm/i18next@21.9.1/node_modules/i18next/dist/cjs/i18next.js")));
|
|
2159
|
+
const i18next_browser_languagedetector_1 = (cov_ogldeftyv().s[5]++, __importDefault(__webpack_require__(/*! i18next-browser-languagedetector */ "../../common/temp/node_modules/.pnpm/i18next-browser-languagedetector@6.1.2/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js")));
|
|
2160
|
+
const i18next_http_backend_1 = (cov_ogldeftyv().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.2/node_modules/i18next-http-backend/esm/index.js")));
|
|
2161
|
+
const core_bentley_1 = (cov_ogldeftyv().s[7]++, __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js"));
|
|
2162
|
+
const DEFAULT_MAX_RETRIES = (cov_ogldeftyv().s[8]++, 1); // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
|
|
2163
2163
|
/** Supplies localizations for iTwin.js
|
|
2164
2164
|
* @note this class uses the [i18next](https://www.i18next.com/) package.
|
|
2165
2165
|
* @public
|
|
@@ -2169,25 +2169,25 @@ class ITwinLocalization {
|
|
|
2169
2169
|
_initOptions;
|
|
2170
2170
|
_backendOptions;
|
|
2171
2171
|
_detectionOptions;
|
|
2172
|
-
_namespaces = (
|
|
2172
|
+
_namespaces = (cov_ogldeftyv().s[9]++, new Map());
|
|
2173
2173
|
constructor(options) {
|
|
2174
|
-
|
|
2175
|
-
|
|
2174
|
+
cov_ogldeftyv().f[1]++;
|
|
2175
|
+
cov_ogldeftyv().s[10]++;
|
|
2176
2176
|
this.i18next = i18next_1.default.createInstance();
|
|
2177
|
-
|
|
2177
|
+
cov_ogldeftyv().s[11]++;
|
|
2178
2178
|
this._backendOptions = {
|
|
2179
|
-
loadPath: (
|
|
2179
|
+
loadPath: (cov_ogldeftyv().b[3][0]++, options?.urlTemplate) ?? (cov_ogldeftyv().b[3][1]++, "locales/{{lng}}/{{ns}}.json"),
|
|
2180
2180
|
crossDomain: true,
|
|
2181
2181
|
...options?.backendHttpOptions
|
|
2182
2182
|
};
|
|
2183
|
-
|
|
2183
|
+
cov_ogldeftyv().s[12]++;
|
|
2184
2184
|
this._detectionOptions = {
|
|
2185
2185
|
order: ["querystring", "navigator", "htmlTag"],
|
|
2186
2186
|
lookupQuerystring: "lng",
|
|
2187
2187
|
caches: [],
|
|
2188
2188
|
...options?.detectorOptions
|
|
2189
2189
|
};
|
|
2190
|
-
|
|
2190
|
+
cov_ogldeftyv().s[13]++;
|
|
2191
2191
|
this._initOptions = {
|
|
2192
2192
|
interpolation: {
|
|
2193
2193
|
escapeValue: true
|
|
@@ -2198,40 +2198,40 @@ class ITwinLocalization {
|
|
|
2198
2198
|
detection: this._detectionOptions,
|
|
2199
2199
|
...options?.initOptions
|
|
2200
2200
|
};
|
|
2201
|
-
|
|
2202
|
-
this.i18next.use((
|
|
2201
|
+
cov_ogldeftyv().s[14]++;
|
|
2202
|
+
this.i18next.use((cov_ogldeftyv().b[4][0]++, options?.detectorPlugin) ?? (cov_ogldeftyv().b[4][1]++, i18next_browser_languagedetector_1.default)).use((cov_ogldeftyv().b[5][0]++, options?.backendPlugin) ?? (cov_ogldeftyv().b[5][1]++, i18next_http_backend_1.default)).use(TranslationLogger);
|
|
2203
2203
|
}
|
|
2204
2204
|
async initialize(namespaces) {
|
|
2205
|
-
|
|
2205
|
+
cov_ogldeftyv().f[2]++;
|
|
2206
2206
|
// Also consider namespaces passed into constructor
|
|
2207
|
-
const initNamespaces = (
|
|
2208
|
-
const combinedNamespaces = (
|
|
2209
|
-
const defaultNamespace = (
|
|
2210
|
-
|
|
2207
|
+
const initNamespaces = (cov_ogldeftyv().s[15]++, [(cov_ogldeftyv().b[6][0]++, this._initOptions.ns) || (cov_ogldeftyv().b[6][1]++, [])].flat());
|
|
2208
|
+
const combinedNamespaces = (cov_ogldeftyv().s[16]++, new Set([...namespaces, ...initNamespaces])); // without duplicates
|
|
2209
|
+
const defaultNamespace = (cov_ogldeftyv().s[17]++, (cov_ogldeftyv().b[7][0]++, this._initOptions.defaultNS) ?? (cov_ogldeftyv().b[7][1]++, namespaces[0]));
|
|
2210
|
+
cov_ogldeftyv().s[18]++;
|
|
2211
2211
|
if (defaultNamespace) {
|
|
2212
|
-
|
|
2213
|
-
|
|
2212
|
+
cov_ogldeftyv().b[8][0]++;
|
|
2213
|
+
cov_ogldeftyv().s[19]++;
|
|
2214
2214
|
combinedNamespaces.add(defaultNamespace);
|
|
2215
2215
|
} else {
|
|
2216
|
-
|
|
2216
|
+
cov_ogldeftyv().b[8][1]++;
|
|
2217
2217
|
} // Make sure default namespace is in namespaces list
|
|
2218
|
-
const initOptions = (
|
|
2218
|
+
const initOptions = (cov_ogldeftyv().s[20]++, {
|
|
2219
2219
|
...this._initOptions,
|
|
2220
2220
|
defaultNS: defaultNamespace,
|
|
2221
2221
|
ns: [...combinedNamespaces]
|
|
2222
2222
|
});
|
|
2223
2223
|
// if in a development environment, set debugging
|
|
2224
|
-
|
|
2224
|
+
cov_ogldeftyv().s[21]++;
|
|
2225
2225
|
if (false) {} else {
|
|
2226
|
-
|
|
2226
|
+
cov_ogldeftyv().b[9][1]++;
|
|
2227
2227
|
}
|
|
2228
|
-
const initPromise = (
|
|
2229
|
-
|
|
2228
|
+
const initPromise = (cov_ogldeftyv().s[23]++, this.i18next.init(initOptions));
|
|
2229
|
+
cov_ogldeftyv().s[24]++;
|
|
2230
2230
|
for (const ns of namespaces) {
|
|
2231
|
-
|
|
2231
|
+
cov_ogldeftyv().s[25]++;
|
|
2232
2232
|
this._namespaces.set(ns, initPromise);
|
|
2233
2233
|
}
|
|
2234
|
-
|
|
2234
|
+
cov_ogldeftyv().s[26]++;
|
|
2235
2235
|
return initPromise;
|
|
2236
2236
|
}
|
|
2237
2237
|
/** Replace all instances of `%{key}` within a string with the translations of those keys.
|
|
@@ -2251,11 +2251,11 @@ class ITwinLocalization {
|
|
|
2251
2251
|
* @public
|
|
2252
2252
|
*/
|
|
2253
2253
|
getLocalizedKeys(line) {
|
|
2254
|
-
|
|
2255
|
-
|
|
2254
|
+
cov_ogldeftyv().f[3]++;
|
|
2255
|
+
cov_ogldeftyv().s[27]++;
|
|
2256
2256
|
return line.replace(/\%\{(.+?)\}/g, (_match, tag) => {
|
|
2257
|
-
|
|
2258
|
-
|
|
2257
|
+
cov_ogldeftyv().f[4]++;
|
|
2258
|
+
cov_ogldeftyv().s[28]++;
|
|
2259
2259
|
return this.getLocalizedString(tag);
|
|
2260
2260
|
});
|
|
2261
2261
|
}
|
|
@@ -2273,25 +2273,25 @@ class ITwinLocalization {
|
|
|
2273
2273
|
* @public
|
|
2274
2274
|
*/
|
|
2275
2275
|
getLocalizedString(key, options) {
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
if ((
|
|
2279
|
-
|
|
2280
|
-
|
|
2276
|
+
cov_ogldeftyv().f[5]++;
|
|
2277
|
+
cov_ogldeftyv().s[29]++;
|
|
2278
|
+
if ((cov_ogldeftyv().b[11][0]++, options?.returnDetails) || (cov_ogldeftyv().b[11][1]++, options?.returnObjects)) {
|
|
2279
|
+
cov_ogldeftyv().b[10][0]++;
|
|
2280
|
+
cov_ogldeftyv().s[30]++;
|
|
2281
2281
|
throw new Error("Translation key must map to a string, but the given options will result in an object");
|
|
2282
2282
|
} else {
|
|
2283
|
-
|
|
2283
|
+
cov_ogldeftyv().b[10][1]++;
|
|
2284
2284
|
}
|
|
2285
|
-
const value = (
|
|
2286
|
-
|
|
2285
|
+
const value = (cov_ogldeftyv().s[31]++, this.i18next.t(key, options));
|
|
2286
|
+
cov_ogldeftyv().s[32]++;
|
|
2287
2287
|
if (typeof value !== "string") {
|
|
2288
|
-
|
|
2289
|
-
|
|
2288
|
+
cov_ogldeftyv().b[12][0]++;
|
|
2289
|
+
cov_ogldeftyv().s[33]++;
|
|
2290
2290
|
throw new Error("Translation key(s) string not found");
|
|
2291
2291
|
} else {
|
|
2292
|
-
|
|
2292
|
+
cov_ogldeftyv().b[12][1]++;
|
|
2293
2293
|
}
|
|
2294
|
-
|
|
2294
|
+
cov_ogldeftyv().s[34]++;
|
|
2295
2295
|
return value;
|
|
2296
2296
|
}
|
|
2297
2297
|
/** Gets the English translation.
|
|
@@ -2302,31 +2302,31 @@ class ITwinLocalization {
|
|
|
2302
2302
|
* @internal
|
|
2303
2303
|
*/
|
|
2304
2304
|
getEnglishString(namespace, key, options) {
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
if ((
|
|
2308
|
-
|
|
2309
|
-
|
|
2305
|
+
cov_ogldeftyv().f[6]++;
|
|
2306
|
+
cov_ogldeftyv().s[35]++;
|
|
2307
|
+
if ((cov_ogldeftyv().b[14][0]++, options?.returnDetails) || (cov_ogldeftyv().b[14][1]++, options?.returnObjects)) {
|
|
2308
|
+
cov_ogldeftyv().b[13][0]++;
|
|
2309
|
+
cov_ogldeftyv().s[36]++;
|
|
2310
2310
|
throw new Error("Translation key must map to a string, but the given options will result in an object");
|
|
2311
2311
|
} else {
|
|
2312
|
-
|
|
2312
|
+
cov_ogldeftyv().b[13][1]++;
|
|
2313
2313
|
}
|
|
2314
|
-
|
|
2314
|
+
cov_ogldeftyv().s[37]++;
|
|
2315
2315
|
options = {
|
|
2316
2316
|
...options,
|
|
2317
2317
|
ns: namespace // ensure namespace argument is used
|
|
2318
2318
|
};
|
|
2319
|
-
const en = (
|
|
2320
|
-
const str = (
|
|
2321
|
-
|
|
2319
|
+
const en = (cov_ogldeftyv().s[38]++, this.i18next.getFixedT("en", namespace));
|
|
2320
|
+
const str = (cov_ogldeftyv().s[39]++, en(key, options));
|
|
2321
|
+
cov_ogldeftyv().s[40]++;
|
|
2322
2322
|
if (typeof str !== "string") {
|
|
2323
|
-
|
|
2324
|
-
|
|
2323
|
+
cov_ogldeftyv().b[15][0]++;
|
|
2324
|
+
cov_ogldeftyv().s[41]++;
|
|
2325
2325
|
throw new Error("Translation key(s) not found");
|
|
2326
2326
|
} else {
|
|
2327
|
-
|
|
2327
|
+
cov_ogldeftyv().b[15][1]++;
|
|
2328
2328
|
}
|
|
2329
|
-
|
|
2329
|
+
cov_ogldeftyv().s[42]++;
|
|
2330
2330
|
return str;
|
|
2331
2331
|
}
|
|
2332
2332
|
/** Get the promise for an already registered Namespace.
|
|
@@ -2334,20 +2334,20 @@ class ITwinLocalization {
|
|
|
2334
2334
|
* @public
|
|
2335
2335
|
*/
|
|
2336
2336
|
getNamespacePromise(name) {
|
|
2337
|
-
|
|
2338
|
-
|
|
2337
|
+
cov_ogldeftyv().f[7]++;
|
|
2338
|
+
cov_ogldeftyv().s[43]++;
|
|
2339
2339
|
return this._namespaces.get(name);
|
|
2340
2340
|
}
|
|
2341
2341
|
/** @internal */
|
|
2342
2342
|
getLanguageList() {
|
|
2343
|
-
|
|
2344
|
-
|
|
2343
|
+
cov_ogldeftyv().f[8]++;
|
|
2344
|
+
cov_ogldeftyv().s[44]++;
|
|
2345
2345
|
return this.i18next.languages;
|
|
2346
2346
|
}
|
|
2347
2347
|
/** override the language detected in the browser */
|
|
2348
2348
|
async changeLanguage(language) {
|
|
2349
|
-
|
|
2350
|
-
|
|
2349
|
+
cov_ogldeftyv().f[9]++;
|
|
2350
|
+
cov_ogldeftyv().s[45]++;
|
|
2351
2351
|
return this.i18next.changeLanguage(language);
|
|
2352
2352
|
}
|
|
2353
2353
|
/** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
|
|
@@ -2359,120 +2359,120 @@ class ITwinLocalization {
|
|
|
2359
2359
|
* @public
|
|
2360
2360
|
*/
|
|
2361
2361
|
async registerNamespace(name) {
|
|
2362
|
-
|
|
2363
|
-
const existing = (
|
|
2364
|
-
|
|
2362
|
+
cov_ogldeftyv().f[10]++;
|
|
2363
|
+
const existing = (cov_ogldeftyv().s[46]++, this._namespaces.get(name));
|
|
2364
|
+
cov_ogldeftyv().s[47]++;
|
|
2365
2365
|
if (existing !== undefined) {
|
|
2366
|
-
|
|
2367
|
-
|
|
2366
|
+
cov_ogldeftyv().b[16][0]++;
|
|
2367
|
+
cov_ogldeftyv().s[48]++;
|
|
2368
2368
|
return existing;
|
|
2369
2369
|
} else {
|
|
2370
|
-
|
|
2370
|
+
cov_ogldeftyv().b[16][1]++;
|
|
2371
2371
|
}
|
|
2372
|
-
const theReadPromise = (
|
|
2373
|
-
|
|
2374
|
-
|
|
2372
|
+
const theReadPromise = (cov_ogldeftyv().s[49]++, new Promise(resolve => {
|
|
2373
|
+
cov_ogldeftyv().f[11]++;
|
|
2374
|
+
cov_ogldeftyv().s[50]++;
|
|
2375
2375
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2376
2376
|
this.i18next.loadNamespaces(name, err => {
|
|
2377
|
-
|
|
2378
|
-
|
|
2377
|
+
cov_ogldeftyv().f[12]++;
|
|
2378
|
+
cov_ogldeftyv().s[51]++;
|
|
2379
2379
|
if (!err) {
|
|
2380
|
-
|
|
2381
|
-
|
|
2380
|
+
cov_ogldeftyv().b[17][0]++;
|
|
2381
|
+
cov_ogldeftyv().s[52]++;
|
|
2382
2382
|
return resolve();
|
|
2383
2383
|
} else {
|
|
2384
|
-
|
|
2384
|
+
cov_ogldeftyv().b[17][1]++;
|
|
2385
2385
|
}
|
|
2386
2386
|
// Here we got a non-null err object.
|
|
2387
2387
|
// This method is called when the system has attempted to load the resources for the namespaces for each possible locale.
|
|
2388
2388
|
// For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.
|
|
2389
2389
|
// Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.
|
|
2390
2390
|
// There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.
|
|
2391
|
-
let locales = (
|
|
2392
|
-
|
|
2393
|
-
|
|
2391
|
+
let locales = (cov_ogldeftyv().s[53]++, this.getLanguageList().map(thisLocale => {
|
|
2392
|
+
cov_ogldeftyv().f[13]++;
|
|
2393
|
+
cov_ogldeftyv().s[54]++;
|
|
2394
2394
|
return `/${thisLocale}/`;
|
|
2395
2395
|
}));
|
|
2396
|
-
|
|
2396
|
+
cov_ogldeftyv().s[55]++;
|
|
2397
2397
|
try {
|
|
2398
|
-
|
|
2398
|
+
cov_ogldeftyv().s[56]++;
|
|
2399
2399
|
for (const thisError of err) {
|
|
2400
|
-
|
|
2400
|
+
cov_ogldeftyv().s[57]++;
|
|
2401
2401
|
if (typeof thisError === "string") {
|
|
2402
|
-
|
|
2403
|
-
|
|
2402
|
+
cov_ogldeftyv().b[18][0]++;
|
|
2403
|
+
cov_ogldeftyv().s[58]++;
|
|
2404
2404
|
locales = locales.filter(thisLocale => {
|
|
2405
|
-
|
|
2406
|
-
|
|
2405
|
+
cov_ogldeftyv().f[14]++;
|
|
2406
|
+
cov_ogldeftyv().s[59]++;
|
|
2407
2407
|
return !thisError.includes(thisLocale);
|
|
2408
2408
|
});
|
|
2409
2409
|
} else {
|
|
2410
|
-
|
|
2410
|
+
cov_ogldeftyv().b[18][1]++;
|
|
2411
2411
|
}
|
|
2412
2412
|
}
|
|
2413
2413
|
} catch {
|
|
2414
|
-
|
|
2414
|
+
cov_ogldeftyv().s[60]++;
|
|
2415
2415
|
locales = [];
|
|
2416
2416
|
}
|
|
2417
2417
|
// if we removed every locale from the array, it wasn't loaded.
|
|
2418
|
-
|
|
2418
|
+
cov_ogldeftyv().s[61]++;
|
|
2419
2419
|
if (locales.length === 0) {
|
|
2420
|
-
|
|
2421
|
-
|
|
2420
|
+
cov_ogldeftyv().b[19][0]++;
|
|
2421
|
+
cov_ogldeftyv().s[62]++;
|
|
2422
2422
|
core_bentley_1.Logger.logError("i18n", `No resources for namespace ${name} could be loaded`);
|
|
2423
2423
|
} else {
|
|
2424
|
-
|
|
2424
|
+
cov_ogldeftyv().b[19][1]++;
|
|
2425
2425
|
}
|
|
2426
|
-
|
|
2426
|
+
cov_ogldeftyv().s[63]++;
|
|
2427
2427
|
resolve();
|
|
2428
2428
|
});
|
|
2429
2429
|
}));
|
|
2430
|
-
|
|
2430
|
+
cov_ogldeftyv().s[64]++;
|
|
2431
2431
|
this._namespaces.set(name, theReadPromise);
|
|
2432
|
-
|
|
2432
|
+
cov_ogldeftyv().s[65]++;
|
|
2433
2433
|
return theReadPromise;
|
|
2434
2434
|
}
|
|
2435
2435
|
/** @internal */
|
|
2436
2436
|
unregisterNamespace(name) {
|
|
2437
|
-
|
|
2438
|
-
|
|
2437
|
+
cov_ogldeftyv().f[15]++;
|
|
2438
|
+
cov_ogldeftyv().s[66]++;
|
|
2439
2439
|
this._namespaces.delete(name);
|
|
2440
2440
|
}
|
|
2441
2441
|
}
|
|
2442
|
-
|
|
2442
|
+
cov_ogldeftyv().s[67]++;
|
|
2443
2443
|
exports.ITwinLocalization = ITwinLocalization;
|
|
2444
2444
|
class TranslationLogger {
|
|
2445
|
-
static type = (
|
|
2445
|
+
static type = (cov_ogldeftyv().s[68]++, "logger");
|
|
2446
2446
|
log(args) {
|
|
2447
|
-
|
|
2448
|
-
|
|
2447
|
+
cov_ogldeftyv().f[16]++;
|
|
2448
|
+
cov_ogldeftyv().s[69]++;
|
|
2449
2449
|
core_bentley_1.Logger.logInfo("i18n", this.createLogMessage(args));
|
|
2450
2450
|
}
|
|
2451
2451
|
warn(args) {
|
|
2452
|
-
|
|
2453
|
-
|
|
2452
|
+
cov_ogldeftyv().f[17]++;
|
|
2453
|
+
cov_ogldeftyv().s[70]++;
|
|
2454
2454
|
core_bentley_1.Logger.logWarning("i18n", this.createLogMessage(args));
|
|
2455
2455
|
}
|
|
2456
2456
|
error(args) {
|
|
2457
|
-
|
|
2458
|
-
|
|
2457
|
+
cov_ogldeftyv().f[18]++;
|
|
2458
|
+
cov_ogldeftyv().s[71]++;
|
|
2459
2459
|
core_bentley_1.Logger.logError("i18n", this.createLogMessage(args));
|
|
2460
2460
|
}
|
|
2461
2461
|
createLogMessage(args) {
|
|
2462
|
-
|
|
2463
|
-
let message = (
|
|
2464
|
-
|
|
2465
|
-
for (let i = (
|
|
2466
|
-
|
|
2462
|
+
cov_ogldeftyv().f[19]++;
|
|
2463
|
+
let message = (cov_ogldeftyv().s[72]++, args[0]);
|
|
2464
|
+
cov_ogldeftyv().s[73]++;
|
|
2465
|
+
for (let i = (cov_ogldeftyv().s[74]++, 1); i < args.length; ++i) {
|
|
2466
|
+
cov_ogldeftyv().s[75]++;
|
|
2467
2467
|
if (typeof args[i] === "string") {
|
|
2468
|
-
|
|
2469
|
-
|
|
2468
|
+
cov_ogldeftyv().b[20][0]++;
|
|
2469
|
+
cov_ogldeftyv().s[76]++;
|
|
2470
2470
|
message += `\n ${args[i]}`;
|
|
2471
2471
|
} else {
|
|
2472
|
-
|
|
2472
|
+
cov_ogldeftyv().b[20][1]++;
|
|
2473
2473
|
}
|
|
2474
2474
|
}
|
|
2475
|
-
|
|
2475
|
+
cov_ogldeftyv().s[77]++;
|
|
2476
2476
|
return message;
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
@@ -23821,6 +23821,69 @@ class UnexpectedErrors {
|
|
|
23821
23821
|
}
|
|
23822
23822
|
|
|
23823
23823
|
|
|
23824
|
+
/***/ }),
|
|
23825
|
+
|
|
23826
|
+
/***/ "../bentley/lib/esm/UtilityFunctions.js":
|
|
23827
|
+
/*!**********************************************!*\
|
|
23828
|
+
!*** ../bentley/lib/esm/UtilityFunctions.js ***!
|
|
23829
|
+
\**********************************************/
|
|
23830
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
23831
|
+
|
|
23832
|
+
"use strict";
|
|
23833
|
+
__webpack_require__.r(__webpack_exports__);
|
|
23834
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23835
|
+
/* harmony export */ wrapTimerCallback: () => (/* binding */ wrapTimerCallback)
|
|
23836
|
+
/* harmony export */ });
|
|
23837
|
+
/*---------------------------------------------------------------------------------------------
|
|
23838
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
23839
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
23840
|
+
*--------------------------------------------------------------------------------------------*/
|
|
23841
|
+
/** @packageDocumentation
|
|
23842
|
+
* @module Utils
|
|
23843
|
+
*/
|
|
23844
|
+
/**
|
|
23845
|
+
* Wrapper function designed to be used for callbacks called by setInterval or setTimeout in order to propagate any
|
|
23846
|
+
* exceptions thrown in the callback to the main promise chain. It does this by creating a new promise for the callback
|
|
23847
|
+
* invocation and adding it to the timerPromises set. The main promise chain can then await
|
|
23848
|
+
* Promise.all(timerPromises) to catch any exceptions thrown in any of the callbacks. Note that if the callback
|
|
23849
|
+
* completes successfully, the promise is resolved and removed from the set. If it throws an exception, the promise is
|
|
23850
|
+
* rejected but not removed from the set, so that the main promise chain can detect that an error occurred and handle
|
|
23851
|
+
* it appropriately.
|
|
23852
|
+
* @param timerPromises A set of promises representing the currently active timer callbacks.
|
|
23853
|
+
* @param callback The async callback to be executed within the timer.
|
|
23854
|
+
* @beta
|
|
23855
|
+
*/
|
|
23856
|
+
async function wrapTimerCallback(timerPromises, callback) {
|
|
23857
|
+
let resolvePromise;
|
|
23858
|
+
let rejectPromise;
|
|
23859
|
+
// The callback of the Promise constructor does not have access to the promise itself, so all we do there is
|
|
23860
|
+
// capture the resolve and reject functions for use in the async callback that would have otherwise been
|
|
23861
|
+
// placed in the setInterval or setTimeout callback.
|
|
23862
|
+
const timerPromise = new Promise((resolve, reject) => {
|
|
23863
|
+
resolvePromise = resolve;
|
|
23864
|
+
rejectPromise = reject;
|
|
23865
|
+
});
|
|
23866
|
+
// Note: when we get here, resolvePromise and rejectPromise will always be defined, but there is no way to
|
|
23867
|
+
// convince TS of that fact without extra unnecessary checks, so we use ?. when accessing them.
|
|
23868
|
+
// Prevent unhandled rejection warnings. The rejection is still observable
|
|
23869
|
+
// when the consumer awaits Promise.all(promises).
|
|
23870
|
+
timerPromise.catch(() => { });
|
|
23871
|
+
timerPromises.add(timerPromise);
|
|
23872
|
+
const cleanupAndResolve = () => {
|
|
23873
|
+
resolvePromise?.();
|
|
23874
|
+
// No need to keep track of this promise anymore since it's resolved.
|
|
23875
|
+
timerPromises.delete(timerPromise);
|
|
23876
|
+
};
|
|
23877
|
+
try {
|
|
23878
|
+
await callback();
|
|
23879
|
+
cleanupAndResolve();
|
|
23880
|
+
}
|
|
23881
|
+
catch (err) {
|
|
23882
|
+
rejectPromise?.(err);
|
|
23883
|
+
}
|
|
23884
|
+
}
|
|
23885
|
+
|
|
23886
|
+
|
|
23824
23887
|
/***/ }),
|
|
23825
23888
|
|
|
23826
23889
|
/***/ "../bentley/lib/esm/UtilityTypes.js":
|
|
@@ -23950,12 +24013,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23950
24013
|
/* harmony export */ ByteStream: () => (/* reexport safe */ _ByteStream__WEBPACK_IMPORTED_MODULE_7__.ByteStream),
|
|
23951
24014
|
/* harmony export */ ChangeSetStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.ChangeSetStatus),
|
|
23952
24015
|
/* harmony export */ CompressedId64Set: () => (/* reexport safe */ _CompressedId64Set__WEBPACK_IMPORTED_MODULE_10__.CompressedId64Set),
|
|
23953
|
-
/* harmony export */ DbChangeStage: () => (/* reexport safe */
|
|
23954
|
-
/* harmony export */ DbConflictCause: () => (/* reexport safe */
|
|
23955
|
-
/* harmony export */ DbConflictResolution: () => (/* reexport safe */
|
|
24016
|
+
/* harmony export */ DbChangeStage: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__.DbChangeStage),
|
|
24017
|
+
/* harmony export */ DbConflictCause: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__.DbConflictCause),
|
|
24018
|
+
/* harmony export */ DbConflictResolution: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__.DbConflictResolution),
|
|
23956
24019
|
/* harmony export */ DbOpcode: () => (/* reexport safe */ _BeSQLite__WEBPACK_IMPORTED_MODULE_6__.DbOpcode),
|
|
23957
24020
|
/* harmony export */ DbResult: () => (/* reexport safe */ _BeSQLite__WEBPACK_IMPORTED_MODULE_6__.DbResult),
|
|
23958
|
-
/* harmony export */ DbValueType: () => (/* reexport safe */
|
|
24021
|
+
/* harmony export */ DbValueType: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__.DbValueType),
|
|
23959
24022
|
/* harmony export */ Dictionary: () => (/* reexport safe */ _Dictionary__WEBPACK_IMPORTED_MODULE_11__.Dictionary),
|
|
23960
24023
|
/* harmony export */ DisposableList: () => (/* reexport safe */ _Disposable__WEBPACK_IMPORTED_MODULE_12__.DisposableList),
|
|
23961
24024
|
/* harmony export */ DuplicatePolicy: () => (/* reexport safe */ _SortedArray__WEBPACK_IMPORTED_MODULE_27__.DuplicatePolicy),
|
|
@@ -23989,7 +24052,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23989
24052
|
/* harmony export */ ReadonlyOrderedSet: () => (/* reexport safe */ _OrderedSet__WEBPACK_IMPORTED_MODULE_23__.ReadonlyOrderedSet),
|
|
23990
24053
|
/* harmony export */ ReadonlySortedArray: () => (/* reexport safe */ _SortedArray__WEBPACK_IMPORTED_MODULE_27__.ReadonlySortedArray),
|
|
23991
24054
|
/* harmony export */ RealityDataStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.RealityDataStatus),
|
|
23992
|
-
/* harmony export */ RepositoryStatus: () => (/* reexport safe */
|
|
24055
|
+
/* harmony export */ RepositoryStatus: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__.RepositoryStatus),
|
|
23993
24056
|
/* harmony export */ RpcInterfaceStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.RpcInterfaceStatus),
|
|
23994
24057
|
/* harmony export */ SortedArray: () => (/* reexport safe */ _SortedArray__WEBPACK_IMPORTED_MODULE_27__.SortedArray),
|
|
23995
24058
|
/* harmony export */ SpanKind: () => (/* reexport safe */ _Tracing__WEBPACK_IMPORTED_MODULE_30__.SpanKind),
|
|
@@ -24005,9 +24068,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24005
24068
|
/* harmony export */ Uint8ArrayBuilder: () => (/* reexport safe */ _TypedArrayBuilder__WEBPACK_IMPORTED_MODULE_32__.Uint8ArrayBuilder),
|
|
24006
24069
|
/* harmony export */ UintArrayBuilder: () => (/* reexport safe */ _TypedArrayBuilder__WEBPACK_IMPORTED_MODULE_32__.UintArrayBuilder),
|
|
24007
24070
|
/* harmony export */ UnexpectedErrors: () => (/* reexport safe */ _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_33__.UnexpectedErrors),
|
|
24008
|
-
/* harmony export */ YieldManager: () => (/* reexport safe */
|
|
24071
|
+
/* harmony export */ YieldManager: () => (/* reexport safe */ _YieldManager__WEBPACK_IMPORTED_MODULE_36__.YieldManager),
|
|
24009
24072
|
/* harmony export */ areEqualPossiblyUndefined: () => (/* reexport safe */ _Compare__WEBPACK_IMPORTED_MODULE_9__.areEqualPossiblyUndefined),
|
|
24010
|
-
/* harmony export */ asInstanceOf: () => (/* reexport safe */
|
|
24073
|
+
/* harmony export */ asInstanceOf: () => (/* reexport safe */ _UtilityTypes__WEBPACK_IMPORTED_MODULE_35__.asInstanceOf),
|
|
24011
24074
|
/* harmony export */ assert: () => (/* reexport safe */ _Assert__WEBPACK_IMPORTED_MODULE_1__.assert),
|
|
24012
24075
|
/* harmony export */ base64StringToUint8Array: () => (/* reexport safe */ _StringUtils__WEBPACK_IMPORTED_MODULE_28__.base64StringToUint8Array),
|
|
24013
24076
|
/* harmony export */ compareArrays: () => (/* reexport safe */ _Compare__WEBPACK_IMPORTED_MODULE_9__.compareArrays),
|
|
@@ -24027,15 +24090,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24027
24090
|
/* harmony export */ expectNotNull: () => (/* reexport safe */ _Expect__WEBPACK_IMPORTED_MODULE_13__.expectNotNull),
|
|
24028
24091
|
/* harmony export */ isDisposable: () => (/* reexport safe */ _Disposable__WEBPACK_IMPORTED_MODULE_12__.isDisposable),
|
|
24029
24092
|
/* harmony export */ isIDisposable: () => (/* reexport safe */ _Disposable__WEBPACK_IMPORTED_MODULE_12__.isIDisposable),
|
|
24030
|
-
/* harmony export */ isInstanceOf: () => (/* reexport safe */
|
|
24093
|
+
/* harmony export */ isInstanceOf: () => (/* reexport safe */ _UtilityTypes__WEBPACK_IMPORTED_MODULE_35__.isInstanceOf),
|
|
24031
24094
|
/* harmony export */ isProperSubclassOf: () => (/* reexport safe */ _ClassUtils__WEBPACK_IMPORTED_MODULE_8__.isProperSubclassOf),
|
|
24032
24095
|
/* harmony export */ isSubclassOf: () => (/* reexport safe */ _ClassUtils__WEBPACK_IMPORTED_MODULE_8__.isSubclassOf),
|
|
24033
24096
|
/* harmony export */ lowerBound: () => (/* reexport safe */ _SortedArray__WEBPACK_IMPORTED_MODULE_27__.lowerBound),
|
|
24034
|
-
/* harmony export */ omit: () => (/* reexport safe */
|
|
24097
|
+
/* harmony export */ omit: () => (/* reexport safe */ _UtilityTypes__WEBPACK_IMPORTED_MODULE_35__.omit),
|
|
24035
24098
|
/* harmony export */ partitionArray: () => (/* reexport safe */ _partitionArray__WEBPACK_IMPORTED_MODULE_24__.partitionArray),
|
|
24036
24099
|
/* harmony export */ shallowClone: () => (/* reexport safe */ _SortedArray__WEBPACK_IMPORTED_MODULE_27__.shallowClone),
|
|
24037
24100
|
/* harmony export */ using: () => (/* reexport safe */ _Disposable__WEBPACK_IMPORTED_MODULE_12__.using),
|
|
24038
|
-
/* harmony export */ utf8ToString: () => (/* reexport safe */ _StringUtils__WEBPACK_IMPORTED_MODULE_28__.utf8ToString)
|
|
24101
|
+
/* harmony export */ utf8ToString: () => (/* reexport safe */ _StringUtils__WEBPACK_IMPORTED_MODULE_28__.utf8ToString),
|
|
24102
|
+
/* harmony export */ wrapTimerCallback: () => (/* reexport safe */ _UtilityFunctions__WEBPACK_IMPORTED_MODULE_34__.wrapTimerCallback)
|
|
24039
24103
|
/* harmony export */ });
|
|
24040
24104
|
/* harmony import */ var _AccessToken__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AccessToken */ "../bentley/lib/esm/AccessToken.js");
|
|
24041
24105
|
/* harmony import */ var _Assert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Assert */ "../bentley/lib/esm/Assert.js");
|
|
@@ -24071,9 +24135,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24071
24135
|
/* harmony import */ var _TupleKeyedMap__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./TupleKeyedMap */ "../bentley/lib/esm/TupleKeyedMap.js");
|
|
24072
24136
|
/* harmony import */ var _TypedArrayBuilder__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./TypedArrayBuilder */ "../bentley/lib/esm/TypedArrayBuilder.js");
|
|
24073
24137
|
/* harmony import */ var _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./UnexpectedErrors */ "../bentley/lib/esm/UnexpectedErrors.js");
|
|
24074
|
-
/* harmony import */ var
|
|
24075
|
-
/* harmony import */ var
|
|
24076
|
-
/* harmony import */ var
|
|
24138
|
+
/* harmony import */ var _UtilityFunctions__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./UtilityFunctions */ "../bentley/lib/esm/UtilityFunctions.js");
|
|
24139
|
+
/* harmony import */ var _UtilityTypes__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./UtilityTypes */ "../bentley/lib/esm/UtilityTypes.js");
|
|
24140
|
+
/* harmony import */ var _YieldManager__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./YieldManager */ "../bentley/lib/esm/YieldManager.js");
|
|
24141
|
+
/* harmony import */ var _internal_cross_package__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./internal/cross-package */ "../bentley/lib/esm/internal/cross-package.js");
|
|
24077
24142
|
/*---------------------------------------------------------------------------------------------
|
|
24078
24143
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
24079
24144
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -24112,6 +24177,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24112
24177
|
|
|
24113
24178
|
|
|
24114
24179
|
|
|
24180
|
+
|
|
24115
24181
|
|
|
24116
24182
|
|
|
24117
24183
|
// Temporarily (until 5.0) export top-level internal APIs to avoid breaking callers.
|