@open-pioneer/runtime 4.7.0-dev.20260623135435 → 4.7.0-dev.20260625125130
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 +15 -1
- package/CustomElement.d.ts +27 -2
- package/CustomElement.js.map +1 -1
- package/_virtual/source-info.js +2 -2
- package/api.d.ts +55 -2
- package/app/AppInstance.d.ts +1 -0
- package/app/AppInstance.js +50 -33
- package/app/AppInstance.js.map +1 -1
- package/app/gatherConfig.js +1 -0
- package/app/gatherConfig.js.map +1 -1
- package/builtin-services/ApplicationContextImpl.d.ts +11 -7
- package/builtin-services/ApplicationContextImpl.js +51 -10
- package/builtin-services/ApplicationContextImpl.js.map +1 -1
- package/builtin-services/LocaleServiceImpl.d.ts +18 -0
- package/builtin-services/LocaleServiceImpl.js +29 -0
- package/builtin-services/LocaleServiceImpl.js.map +1 -0
- package/builtin-services/NumberParserServiceImpl.d.ts +8 -3
- package/builtin-services/NumberParserServiceImpl.js +17 -12
- package/builtin-services/NumberParserServiceImpl.js.map +1 -1
- package/builtin-services/index.d.ts +3 -1
- package/builtin-services/index.js +34 -4
- package/builtin-services/index.js.map +1 -1
- package/dom/index.d.ts +1 -1
- package/dom/index.js +1 -4
- package/dom/index.js.map +1 -1
- package/i18n/AppIntl.d.ts +49 -11
- package/i18n/AppIntl.js +201 -108
- package/i18n/AppIntl.js.map +1 -1
- package/i18n/index.d.ts +3 -2
- package/i18n/index.js +2 -1
- package/i18n/index.js.map +1 -1
- package/i18n/intl-locale.d.ts +13 -0
- package/i18n/intl-locale.js +17 -0
- package/i18n/intl-locale.js.map +1 -0
- package/i18n/pick.d.ts +29 -16
- package/i18n/pick.js +78 -51
- package/i18n/pick.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/package.json +5 -4
- package/react-integration/ChakraProvider.d.ts +1 -1
- package/react-integration/ChakraProvider.js +3 -2
- package/react-integration/ChakraProvider.js.map +1 -1
- package/react-integration/ReactIntegration.d.ts +1 -1
- package/react-integration/ReactIntegration.js.map +1 -1
- package/test-support/index.js +2 -1
- package/test-support/index.js.map +1 -1
|
@@ -1,19 +1,42 @@
|
|
|
1
|
+
import { createLogger, deprecated, Error, isAbortError } from '@open-pioneer/core';
|
|
2
|
+
import { sourceId$1 as sourceId } from '../_virtual/source-info.js';
|
|
1
3
|
import { isShadowRoot } from '../dom/index.js';
|
|
4
|
+
import { ErrorId } from '../errors.js';
|
|
5
|
+
import '../i18n/AppIntl.js';
|
|
6
|
+
import { tryParseLocale } from '../i18n/intl-locale.js';
|
|
7
|
+
import '@formatjs/intl';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@formatjs/intl-localematcher';
|
|
2
10
|
|
|
11
|
+
const LOG = createLogger(sourceId);
|
|
12
|
+
const setLocaleDeprecationMessage = deprecated({
|
|
13
|
+
name: "ApplicationContext.setLocale",
|
|
14
|
+
packageName: "@open-pioneer/runtime",
|
|
15
|
+
since: "v4.7.0",
|
|
16
|
+
alternative: "Use `runtime.LocaleService.changeLocale` instead."
|
|
17
|
+
});
|
|
18
|
+
const getLocaleDeprecationMessage = deprecated({
|
|
19
|
+
name: "ApplicationContext.getLocale",
|
|
20
|
+
packageName: "@open-pioneer/runtime",
|
|
21
|
+
since: "v4.7.0",
|
|
22
|
+
alternative: "Use `runtime.LocaleService.locale` instead."
|
|
23
|
+
});
|
|
24
|
+
const getSupportedLocalesDeprecationMessage = deprecated({
|
|
25
|
+
name: "ApplicationContext.getSupportedLocales",
|
|
26
|
+
packageName: "@open-pioneer/runtime",
|
|
27
|
+
since: "v4.7.0",
|
|
28
|
+
alternative: "Use `runtime.LocaleService.supportedMessageLocales` instead."
|
|
29
|
+
});
|
|
3
30
|
class ApplicationContextImpl {
|
|
4
31
|
#host;
|
|
5
32
|
#rootNode;
|
|
6
33
|
#container;
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
#changeLocale;
|
|
10
|
-
constructor(_options, properties) {
|
|
34
|
+
#localeService;
|
|
35
|
+
constructor(options, properties) {
|
|
11
36
|
this.#host = properties.host;
|
|
12
37
|
this.#rootNode = properties.rootNode;
|
|
13
38
|
this.#container = properties.container;
|
|
14
|
-
this.#
|
|
15
|
-
this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));
|
|
16
|
-
this.#changeLocale = properties.changeLocale;
|
|
39
|
+
this.#localeService = options.references.localeService;
|
|
17
40
|
}
|
|
18
41
|
getHostElement() {
|
|
19
42
|
return this.#host;
|
|
@@ -27,14 +50,32 @@ class ApplicationContextImpl {
|
|
|
27
50
|
getApplicationContainer() {
|
|
28
51
|
return this.#container;
|
|
29
52
|
}
|
|
53
|
+
/** @deprecated Use `runtime.LocaleService` instead. */
|
|
30
54
|
getLocale() {
|
|
31
|
-
|
|
55
|
+
getLocaleDeprecationMessage();
|
|
56
|
+
return this.#localeService.locale.baseName;
|
|
32
57
|
}
|
|
58
|
+
/** @deprecated Use `runtime.LocaleService` instead. */
|
|
33
59
|
setLocale(locale) {
|
|
34
|
-
|
|
60
|
+
setLocaleDeprecationMessage();
|
|
61
|
+
const targetLocale = tryParseLocale(locale);
|
|
62
|
+
if (targetLocale && !this.#localeService.supportsLocale(targetLocale)) {
|
|
63
|
+
const localesList = this.#localeService.supportedMessageLocales.map((l) => l.baseName).join(", ");
|
|
64
|
+
throw new Error(
|
|
65
|
+
ErrorId.UNSUPPORTED_LOCALE,
|
|
66
|
+
`Unsupported locale '${targetLocale.baseName}' (supported locales: ${localesList}).`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
this.#localeService.changeLocale(targetLocale).catch((e) => {
|
|
70
|
+
if (!isAbortError(e)) {
|
|
71
|
+
LOG.error(`Failed to switch locale to '${targetLocale?.baseName}'.`, e);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
35
74
|
}
|
|
75
|
+
/** @deprecated Use `runtime.LocaleService` instead. */
|
|
36
76
|
getSupportedLocales() {
|
|
37
|
-
|
|
77
|
+
getSupportedLocalesDeprecationMessage();
|
|
78
|
+
return this.#localeService.supportedMessageLocales.map((l) => l.baseName);
|
|
38
79
|
}
|
|
39
80
|
}
|
|
40
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { isShadowRoot, RootNode } from \"../dom\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n rootNode: RootNode;\n container: HTMLElement;\n
|
|
1
|
+
{"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, Error, deprecated, isAbortError } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ApplicationContext, LocaleService } from \"../api\";\nimport { isShadowRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { tryParseLocale } from \"../i18n\";\nimport { ServiceOptions } from \"../Service\";\n\nconst LOG = createLogger(sourceId);\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n rootNode: RootNode;\n container: HTMLElement;\n}\n\ninterface ServiceReferences {\n localeService: LocaleService;\n}\n\nexport type ApplicationContextServiceOptions = ServiceOptions<ServiceReferences>;\n\nconst setLocaleDeprecationMessage = deprecated({\n name: \"ApplicationContext.setLocale\",\n packageName: \"@open-pioneer/runtime\",\n since: \"v4.7.0\",\n alternative: \"Use `runtime.LocaleService.changeLocale` instead.\"\n});\nconst getLocaleDeprecationMessage = deprecated({\n name: \"ApplicationContext.getLocale\",\n packageName: \"@open-pioneer/runtime\",\n since: \"v4.7.0\",\n alternative: \"Use `runtime.LocaleService.locale` instead.\"\n});\nconst getSupportedLocalesDeprecationMessage = deprecated({\n name: \"ApplicationContext.getSupportedLocales\",\n packageName: \"@open-pioneer/runtime\",\n since: \"v4.7.0\",\n alternative: \"Use `runtime.LocaleService.supportedMessageLocales` instead.\"\n});\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #rootNode: RootNode;\n #container: HTMLElement;\n #localeService: LocaleService;\n\n constructor(\n options: ApplicationContextServiceOptions,\n properties: ApplicationContextProperties\n ) {\n this.#host = properties.host;\n this.#rootNode = properties.rootNode;\n this.#container = properties.container;\n this.#localeService = options.references.localeService;\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getRoot(): RootNode {\n return this.#rootNode;\n }\n\n getShadowRoot(): ShadowRoot | undefined {\n return isShadowRoot(this.#rootNode) ? this.#rootNode : undefined;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n /** @deprecated Use `runtime.LocaleService` instead. */\n getLocale(): string {\n getLocaleDeprecationMessage();\n return this.#localeService.locale.baseName;\n }\n\n /** @deprecated Use `runtime.LocaleService` instead. */\n setLocale(locale: string | undefined): void {\n setLocaleDeprecationMessage();\n const targetLocale = tryParseLocale(locale);\n // to be backwards compatible, we check here synchronously\n // same check is done in AppIntl.changeLocale\n if (targetLocale && !this.#localeService.supportsLocale(targetLocale)) {\n const localesList = this.#localeService.supportedMessageLocales\n .map((l) => l.baseName)\n .join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Unsupported locale '${targetLocale.baseName}' (supported locales: ${localesList}).`\n );\n }\n this.#localeService.changeLocale(targetLocale).catch((e) => {\n if (!isAbortError(e)) {\n LOG.error(`Failed to switch locale to '${targetLocale?.baseName}'.`, e);\n }\n });\n }\n\n /** @deprecated Use `runtime.LocaleService` instead. */\n getSupportedLocales(): readonly string[] {\n getSupportedLocalesDeprecationMessage();\n return this.#localeService.supportedMessageLocales.map((l) => l.baseName);\n }\n}\n"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n";
|
|
3
|
+
export interface LocaleServiceProperties {
|
|
4
|
+
appIntl: AppIntl;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of the `runtime.LocaleService` builtin service.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LocaleServiceImpl implements LocaleService {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(properties: LocaleServiceProperties);
|
|
12
|
+
get locale(): Intl.Locale;
|
|
13
|
+
get messageLocale(): Intl.Locale;
|
|
14
|
+
get supportedMessageLocales(): readonly Intl.Locale[];
|
|
15
|
+
get supportsLiveChanges(): boolean;
|
|
16
|
+
changeLocale(targetLocale: Intl.Locale | undefined): Promise<void>;
|
|
17
|
+
supportsLocale(locale: Intl.Locale): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class LocaleServiceImpl {
|
|
2
|
+
// this is the source of truth.
|
|
3
|
+
// Carries the real reactive state.
|
|
4
|
+
#appIntl;
|
|
5
|
+
constructor(properties) {
|
|
6
|
+
this.#appIntl = properties.appIntl;
|
|
7
|
+
}
|
|
8
|
+
get locale() {
|
|
9
|
+
return this.#appIntl.locale;
|
|
10
|
+
}
|
|
11
|
+
get messageLocale() {
|
|
12
|
+
return this.#appIntl.messageLocale;
|
|
13
|
+
}
|
|
14
|
+
get supportedMessageLocales() {
|
|
15
|
+
return this.#appIntl.supportedMessageLocales;
|
|
16
|
+
}
|
|
17
|
+
get supportsLiveChanges() {
|
|
18
|
+
return this.#appIntl.supportsLiveChanges;
|
|
19
|
+
}
|
|
20
|
+
changeLocale(targetLocale) {
|
|
21
|
+
return this.#appIntl.changeLocale(targetLocale);
|
|
22
|
+
}
|
|
23
|
+
supportsLocale(locale) {
|
|
24
|
+
return this.#appIntl.supportsLocale(locale);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { LocaleServiceImpl };
|
|
29
|
+
//# sourceMappingURL=LocaleServiceImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocaleServiceImpl.js","sources":["LocaleServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { type LocaleService } from \"../api\";\nimport { AppIntl } from \"../i18n\";\n\nexport interface LocaleServiceProperties {\n appIntl: AppIntl;\n}\n\n/**\n * Implementation of the `runtime.LocaleService` builtin service.\n */\nexport class LocaleServiceImpl implements LocaleService {\n // this is the source of truth.\n // Carries the real reactive state.\n #appIntl: AppIntl;\n\n constructor(properties: LocaleServiceProperties) {\n this.#appIntl = properties.appIntl;\n }\n\n get locale(): Intl.Locale {\n return this.#appIntl.locale;\n }\n\n get messageLocale(): Intl.Locale {\n return this.#appIntl.messageLocale;\n }\n\n get supportedMessageLocales(): readonly Intl.Locale[] {\n return this.#appIntl.supportedMessageLocales;\n }\n\n get supportsLiveChanges(): boolean {\n return this.#appIntl.supportsLiveChanges;\n }\n\n changeLocale(targetLocale: Intl.Locale | undefined): Promise<void> {\n return this.#appIntl.changeLocale(targetLocale);\n }\n\n supportsLocale(locale: Intl.Locale): boolean {\n return this.#appIntl.supportsLocale(locale);\n }\n}\n"],"names":[],"mappings":"AAYO,MAAM,iBAAA,CAA2C;AAAA;AAAA;AAAA,EAGpD,QAAA;AAAA,EAEA,YAAY,UAAA,EAAqC;AAC7C,IAAA,IAAA,CAAK,WAAW,UAAA,CAAW,OAAA;AAAA,EAC/B;AAAA,EAEA,IAAI,MAAA,GAAsB;AACtB,IAAA,OAAO,KAAK,QAAA,CAAS,MAAA;AAAA,EACzB;AAAA,EAEA,IAAI,aAAA,GAA6B;AAC7B,IAAA,OAAO,KAAK,QAAA,CAAS,aAAA;AAAA,EACzB;AAAA,EAEA,IAAI,uBAAA,GAAkD;AAClD,IAAA,OAAO,KAAK,QAAA,CAAS,uBAAA;AAAA,EACzB;AAAA,EAEA,IAAI,mBAAA,GAA+B;AAC/B,IAAA,OAAO,KAAK,QAAA,CAAS,mBAAA;AAAA,EACzB;AAAA,EAEA,aAAa,YAAA,EAAsD;AAC/D,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,YAAA,CAAa,YAAY,CAAA;AAAA,EAClD;AAAA,EAEA,eAAe,MAAA,EAA8B;AACzC,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,cAAA,CAAe,MAAM,CAAA;AAAA,EAC9C;AACJ;;;;"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { NumberParserService } from "../api";
|
|
1
|
+
import { LocaleService, NumberParserService } from "../api";
|
|
2
2
|
import { ServiceOptions } from "../Service";
|
|
3
|
+
interface ServiceReferences {
|
|
4
|
+
localeService: Pick<LocaleService, "locale">;
|
|
5
|
+
}
|
|
6
|
+
export type NumberParserServiceOptions = ServiceOptions<ServiceReferences>;
|
|
3
7
|
export declare class NumberParserServiceImpl implements NumberParserService {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
8
|
+
#private;
|
|
9
|
+
constructor(_serviceOptions: NumberParserServiceOptions);
|
|
6
10
|
parseNumber(numberString: string): number;
|
|
7
11
|
}
|
|
12
|
+
export {};
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
+
import { computed } from '@conterra/reactivity-core';
|
|
1
2
|
import { createLogger, NumberParser } from '@open-pioneer/core';
|
|
2
3
|
import { sourceId$3 as sourceId } from '../_virtual/source-info.js';
|
|
3
4
|
|
|
4
5
|
const LOG = createLogger(sourceId);
|
|
5
6
|
class NumberParserServiceImpl {
|
|
6
|
-
numberParser;
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
#numberParser;
|
|
8
|
+
constructor(_serviceOptions) {
|
|
9
|
+
const localeService = _serviceOptions.references.localeService;
|
|
10
|
+
this.#numberParser = computed(() => {
|
|
11
|
+
const tag = localeService.locale.baseName;
|
|
12
|
+
try {
|
|
13
|
+
return new NumberParser(tag);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
LOG.warn(
|
|
16
|
+
`Failed to create NumberParser with locale '${tag}'. Falling back to 'en-US'.`,
|
|
17
|
+
e
|
|
18
|
+
);
|
|
19
|
+
return new NumberParser("en-US");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
17
22
|
}
|
|
18
23
|
parseNumber(numberString) {
|
|
19
|
-
return this
|
|
24
|
+
return this.#numberParser.value.parse(numberString);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nconst LOG = createLogger(sourceId);\n\nexport class NumberParserServiceImpl implements NumberParserService {\n
|
|
1
|
+
{"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { computed, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { LocaleService, NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nconst LOG = createLogger(sourceId);\n\ninterface ServiceReferences {\n localeService: Pick<LocaleService, \"locale\">;\n}\n\nexport type NumberParserServiceOptions = ServiceOptions<ServiceReferences>;\n\nexport class NumberParserServiceImpl implements NumberParserService {\n #numberParser: ReadonlyReactive<NumberParser>;\n\n constructor(_serviceOptions: NumberParserServiceOptions) {\n const localeService = _serviceOptions.references.localeService;\n this.#numberParser = computed(() => {\n // reactive\n const tag = localeService.locale.baseName;\n try {\n return new NumberParser(tag);\n } catch (e) {\n LOG.warn(\n `Failed to create NumberParser with locale '${tag}'. Falling back to 'en-US'.`,\n e\n );\n return new NumberParser(\"en-US\");\n }\n });\n }\n\n parseNumber(numberString: string): number {\n return this.#numberParser.value.parse(numberString);\n }\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAQ1B,MAAM,uBAAA,CAAuD;AAAA,EAChE,aAAA;AAAA,EAEA,YAAY,eAAA,EAA6C;AACrD,IAAA,MAAM,aAAA,GAAgB,gBAAgB,UAAA,CAAW,aAAA;AACjD,IAAA,IAAA,CAAK,aAAA,GAAgB,SAAS,MAAM;AAEhC,MAAA,MAAM,GAAA,GAAM,cAAc,MAAA,CAAO,QAAA;AACjC,MAAA,IAAI;AACA,QAAA,OAAO,IAAI,aAAa,GAAG,CAAA;AAAA,MAC/B,SAAS,CAAA,EAAG;AACR,QAAA,GAAA,CAAI,IAAA;AAAA,UACA,8CAA8C,GAAG,CAAA,2BAAA,CAAA;AAAA,UACjD;AAAA,SACJ;AACA,QAAA,OAAO,IAAI,aAAa,OAAO,CAAA;AAAA,MACnC;AAAA,IACJ,CAAC,CAAA;AAAA,EACL;AAAA,EAEA,YAAY,YAAA,EAA8B;AACtC,IAAA,OAAO,IAAA,CAAK,aAAA,CAAc,KAAA,CAAM,KAAA,CAAM,YAAY,CAAA;AAAA,EACtD;AACJ;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PackageRepr } from "../service-layer/PackageRepr";
|
|
2
2
|
import { ApplicationContextProperties } from "./ApplicationContextImpl";
|
|
3
|
+
import { LocaleServiceProperties } from "./LocaleServiceImpl";
|
|
3
4
|
import { ThemeServiceProperties } from "./ThemeServiceImpl";
|
|
4
5
|
export declare const RUNTIME_PACKAGE_NAME = "@open-pioneer/runtime";
|
|
5
6
|
export declare const RUNTIME_API_EXTENSION = "integration.ApiExtension";
|
|
@@ -9,7 +10,8 @@ export declare const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.Appl
|
|
|
9
10
|
export declare const RUNTIME_NUMBER_PARSER_SERVICE = "runtime.NumberParserService";
|
|
10
11
|
export declare const RUNTIME_AUTO_START = "runtime.AutoStart";
|
|
11
12
|
export declare const RUNTIME_THEME_SERVICE = "runtime.ThemeService";
|
|
12
|
-
export
|
|
13
|
+
export declare const RUNTIME_LOCALE_SERVICE = "runtime.LocaleService";
|
|
14
|
+
export type BuiltinPackageProperties = ApplicationContextProperties & ThemeServiceProperties & LocaleServiceProperties;
|
|
13
15
|
/**
|
|
14
16
|
* Creates the builtin package containing the builtin services.
|
|
15
17
|
*
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { constant } from '@conterra/reactivity-core';
|
|
2
2
|
import '../i18n/AppIntl.js';
|
|
3
3
|
import { createEmptyPackageIntl } from '../i18n/PackageIntl.js';
|
|
4
|
-
import '
|
|
4
|
+
import '@formatjs/intl-localematcher';
|
|
5
|
+
import '@open-pioneer/core';
|
|
5
6
|
import { PackageRepr } from '../service-layer/PackageRepr.js';
|
|
6
|
-
import { ServiceRepr,
|
|
7
|
+
import { ServiceRepr, createFunctionFactory, createConstructorFactory } from '../service-layer/ServiceRepr.js';
|
|
7
8
|
import { ApiServiceImpl } from './ApiServiceImpl.js';
|
|
8
9
|
import { ApplicationContextImpl } from './ApplicationContextImpl.js';
|
|
9
10
|
import { ApplicationLifecycleEventService } from './ApplicationLifecycleEventService.js';
|
|
11
|
+
import { LocaleServiceImpl } from './LocaleServiceImpl.js';
|
|
10
12
|
import { NumberParserServiceImpl } from './NumberParserServiceImpl.js';
|
|
11
13
|
import { ThemeServiceImpl } from './ThemeServiceImpl.js';
|
|
12
14
|
|
|
@@ -18,8 +20,21 @@ const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycl
|
|
|
18
20
|
const RUNTIME_NUMBER_PARSER_SERVICE = "runtime.NumberParserService";
|
|
19
21
|
const RUNTIME_AUTO_START = "runtime.AutoStart";
|
|
20
22
|
const RUNTIME_THEME_SERVICE = "runtime.ThemeService";
|
|
23
|
+
const RUNTIME_LOCALE_SERVICE = "runtime.LocaleService";
|
|
21
24
|
function createBuiltinPackage(properties) {
|
|
22
25
|
const intl = createEmptyPackageIntl();
|
|
26
|
+
const localeService = new ServiceRepr({
|
|
27
|
+
name: "LocaleServiceImpl",
|
|
28
|
+
packageName: RUNTIME_PACKAGE_NAME,
|
|
29
|
+
factory: createFunctionFactory(() => new LocaleServiceImpl(properties)),
|
|
30
|
+
intl: constant(intl),
|
|
31
|
+
interfaces: [
|
|
32
|
+
{
|
|
33
|
+
interfaceName: RUNTIME_LOCALE_SERVICE,
|
|
34
|
+
qualifier: "builtin"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
23
38
|
const apiService = new ServiceRepr({
|
|
24
39
|
name: "ApiServiceImpl",
|
|
25
40
|
packageName: RUNTIME_PACKAGE_NAME,
|
|
@@ -51,6 +66,13 @@ function createBuiltinPackage(properties) {
|
|
|
51
66
|
interfaceName: RUNTIME_APPLICATION_CONTEXT,
|
|
52
67
|
qualifier: "builtin"
|
|
53
68
|
}
|
|
69
|
+
],
|
|
70
|
+
dependencies: [
|
|
71
|
+
{
|
|
72
|
+
referenceName: "localeService",
|
|
73
|
+
interfaceName: RUNTIME_LOCALE_SERVICE,
|
|
74
|
+
qualifier: "builtin"
|
|
75
|
+
}
|
|
54
76
|
]
|
|
55
77
|
});
|
|
56
78
|
const lifecycleEventService = new ServiceRepr({
|
|
@@ -76,7 +98,7 @@ function createBuiltinPackage(properties) {
|
|
|
76
98
|
name: "NumberParserServiceImpl",
|
|
77
99
|
packageName: RUNTIME_PACKAGE_NAME,
|
|
78
100
|
factory: createFunctionFactory(
|
|
79
|
-
(options) => new NumberParserServiceImpl(options
|
|
101
|
+
(options) => new NumberParserServiceImpl(options)
|
|
80
102
|
),
|
|
81
103
|
intl: constant(intl),
|
|
82
104
|
interfaces: [
|
|
@@ -84,6 +106,13 @@ function createBuiltinPackage(properties) {
|
|
|
84
106
|
interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,
|
|
85
107
|
qualifier: "builtin"
|
|
86
108
|
}
|
|
109
|
+
],
|
|
110
|
+
dependencies: [
|
|
111
|
+
{
|
|
112
|
+
referenceName: "localeService",
|
|
113
|
+
interfaceName: RUNTIME_LOCALE_SERVICE,
|
|
114
|
+
qualifier: "builtin"
|
|
115
|
+
}
|
|
87
116
|
]
|
|
88
117
|
});
|
|
89
118
|
const themeService = new ServiceRepr({
|
|
@@ -111,6 +140,7 @@ function createBuiltinPackage(properties) {
|
|
|
111
140
|
apiService,
|
|
112
141
|
appContext,
|
|
113
142
|
lifecycleEventService,
|
|
143
|
+
localeService,
|
|
114
144
|
numberParserService,
|
|
115
145
|
themeService
|
|
116
146
|
],
|
|
@@ -118,5 +148,5 @@ function createBuiltinPackage(properties) {
|
|
|
118
148
|
});
|
|
119
149
|
}
|
|
120
150
|
|
|
121
|
-
export { RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START, RUNTIME_PACKAGE_NAME, RUNTIME_THEME_SERVICE, createBuiltinPackage };
|
|
151
|
+
export { RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START, RUNTIME_LOCALE_SERVICE, RUNTIME_PACKAGE_NAME, RUNTIME_THEME_SERVICE, createBuiltinPackage };
|
|
122
152
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { constant } from \"@conterra/reactivity-core\";\nimport { createEmptyPackageIntl } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { constant } from \"@conterra/reactivity-core\";\nimport { createEmptyPackageIntl } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport {\n ApplicationContextImpl,\n ApplicationContextProperties,\n ApplicationContextServiceOptions\n} from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { LocaleServiceImpl, LocaleServiceProperties } from \"./LocaleServiceImpl\";\nimport { NumberParserServiceImpl, NumberParserServiceOptions } from \"./NumberParserServiceImpl\";\nimport { ThemeServiceImpl, ThemeServiceProperties } from \"./ThemeServiceImpl\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_NUMBER_PARSER_SERVICE = \"runtime.NumberParserService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\nexport const RUNTIME_THEME_SERVICE = \"runtime.ThemeService\";\nexport const RUNTIME_LOCALE_SERVICE = \"runtime.LocaleService\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties &\n ThemeServiceProperties &\n LocaleServiceProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const intl = createEmptyPackageIntl();\n\n const localeService = new ServiceRepr({\n name: \"LocaleServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(() => new LocaleServiceImpl(properties)),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) =>\n new ApplicationContextImpl(options as ApplicationContextServiceOptions, properties)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n const numberParserService = new ServiceRepr({\n name: \"NumberParserServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new NumberParserServiceImpl(options as NumberParserServiceOptions)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n\n const themeService = new ServiceRepr({\n name: \"ThemeServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(() => new ThemeServiceImpl(properties)),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_THEME_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"applicationContext\",\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [\n apiService,\n appContext,\n lifecycleEventService,\n localeService,\n numberParserService,\n themeService\n ],\n intl: constant(intl)\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,qBAAA,GAAwB,0BAAA;AAC9B,MAAM,mBAAA,GAAsB;AAC5B,MAAM,2BAAA,GAA8B,4BAAA;AACpC,MAAM,2CAAA,GACT;AACG,MAAM,6BAAA,GAAgC,6BAAA;AACtC,MAAM,kBAAA,GAAqB;AAC3B,MAAM,qBAAA,GAAwB;AAC9B,MAAM,sBAAA,GAAyB;AAgB/B,SAAS,qBAAqB,UAAA,EAAmD;AACpF,EAAA,MAAM,OAAO,sBAAA,EA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AA;AAAA,IACnB,UAAA,EAAY;AAAA,MACR;AAAA,QACI,aAAA,EAAe,qBAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf,KACJ;AAAA,IACA,YAAA,EAAc;AAAA,MACV;AAAA,QACI,aAAA,EAAe,oBAAA;AAAA,QACf,aAAA,EAAe,2BAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,OAAO,IAAI,WAAA,CAAY;AAAA,IACnB,IAAA,EAAM,oBAAA;AAAA,IACN,QAAA,EAAU;AAAA,MACN,UAAA;AAAA,MACA,UAAA;AAAA,MACA,qBAAA;AAAA,MACA,aAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA,IAAA,EAAM,SAAS,IAAI;AAAA,GACtB,CAAA;AACL;;;;"}
|
package/dom/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElem
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates the node that contains all other application content.
|
|
17
17
|
*/
|
|
18
|
-
export declare function createAppRoot(
|
|
18
|
+
export declare function createAppRoot(): HTMLDivElement;
|
|
19
19
|
/**
|
|
20
20
|
* Returns the styles for host element (the web component node).
|
|
21
21
|
*/
|
package/dom/index.js
CHANGED
|
@@ -5,14 +5,11 @@ function isShadowRoot(node) {
|
|
|
5
5
|
function getStylesRoot(node) {
|
|
6
6
|
return isShadowRoot(node) ? node : node.head;
|
|
7
7
|
}
|
|
8
|
-
function createAppRoot(
|
|
8
|
+
function createAppRoot() {
|
|
9
9
|
const container = document.createElement("div");
|
|
10
10
|
container.classList.add("pioneer-root");
|
|
11
11
|
container.style.minHeight = "100%";
|
|
12
12
|
container.style.height = "100%";
|
|
13
|
-
if (locale) {
|
|
14
|
-
container.lang = locale;
|
|
15
|
-
}
|
|
16
13
|
return container;
|
|
17
14
|
}
|
|
18
15
|
function getBuiltinStyles(rootNode, hostElement) {
|
package/dom/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The root node of an application.\n */\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\nexport function isDocument(node: RootNode): node is Document {\n return !isShadowRoot(node);\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(
|
|
1
|
+
{"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The root node of an application.\n */\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\nexport function isDocument(node: RootNode): node is Document {\n return !isShadowRoot(node);\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(): HTMLDivElement {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n return container;\n}\n\n/**\n * Returns the styles for host element (the web component node).\n */\nexport function getBuiltinStyles(rootNode: RootNode, hostElement: HTMLElement | undefined) {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n // NOTE: layer base comes from chakra (used for css resets etc).\n const selector =\n isShadowRoot(rootNode) || !hostElement ? \":host\" : hostElement.tagName.toLowerCase();\n return `@layer base { ${selector} { all: initial; display: block; } }`;\n}\n"],"names":[],"mappings":"AAWO,MAAM,cAAA,GAAiB;AAEvB,SAAS,aAAa,IAAA,EAAoC;AAC7D,EAAA,OAAO,IAAA,CAAK,QAAA,KAAa,IAAA,CAAK,sBAAA,IAA0B,MAAA,IAAU,IAAA;AACtE;AASO,SAAS,cAAc,IAAA,EAA8C;AACxE,EAAA,OAAO,YAAA,CAAa,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,CAAK,IAAA;AAC5C;AAKO,SAAS,aAAA,GAAgC;AAE5C,EAAA,MAAM,SAAA,GAAY,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC9C,EAAA,SAAA,CAAU,SAAA,CAAU,IAAI,cAAc,CAAA;AACtC,EAAA,SAAA,CAAU,MAAM,SAAA,GAAY,MAAA;AAC5B,EAAA,SAAA,CAAU,MAAM,MAAA,GAAS,MAAA;AACzB,EAAA,OAAO,SAAA;AACX;AAKO,SAAS,gBAAA,CAAiB,UAAoB,WAAA,EAAsC;AAIvF,EAAA,MAAM,QAAA,GACF,aAAa,QAAQ,CAAA,IAAK,CAAC,WAAA,GAAc,OAAA,GAAU,WAAA,CAAY,OAAA,CAAQ,WAAA,EAAY;AACvF,EAAA,OAAO,iBAAiB,QAAQ,CAAA,oCAAA,CAAA;AACpC;;;;"}
|
package/i18n/AppIntl.d.ts
CHANGED
|
@@ -1,22 +1,60 @@
|
|
|
1
1
|
import { ReadonlyReactive } from "@conterra/reactivity-core";
|
|
2
2
|
import { ApplicationMetadata } from "../metadata";
|
|
3
3
|
import { PackageIntl } from "./PackageIntl";
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link AppIntl.create}.
|
|
6
|
+
*/
|
|
7
|
+
export interface I18nOptions {
|
|
8
|
+
appMetadata: ApplicationMetadata | undefined;
|
|
9
|
+
forcedLocale?: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Restriction on supported locales.
|
|
12
|
+
* If provided, only these locales are considered for locale picking and switching.
|
|
13
|
+
* If not provided, all locales from app metadata are supported.
|
|
14
|
+
*/
|
|
15
|
+
restrictSupportedLocales?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* If true, locale switching via {@link AppIntl.changeLocale} is supported and
|
|
18
|
+
* applied in place (locale, messageLocale and PackageIntl instances become reactive).
|
|
19
|
+
*
|
|
20
|
+
* If false (default), {@link AppIntl.changeLocale} triggers an application
|
|
21
|
+
* restart via {@link restartWithLocale}.
|
|
22
|
+
*/
|
|
23
|
+
supportsLiveChanges?: boolean;
|
|
24
|
+
/** hook given by AppInstance to trigger restart of the application. Called by changeLocale when reactive switching is OFF. */
|
|
25
|
+
restartWithLocale(locale: Intl.Locale | undefined): void;
|
|
26
|
+
}
|
|
4
27
|
/**
|
|
5
28
|
* Represents i18n info for the entire application.
|
|
6
|
-
*
|
|
29
|
+
* Not exposed to user code.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
7
32
|
*/
|
|
8
|
-
export
|
|
33
|
+
export declare class AppIntl {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Initializes the application's locale and fetches the appropriate i18n messages.
|
|
37
|
+
*/
|
|
38
|
+
static create(options: I18nOptions): Promise<AppIntl>;
|
|
39
|
+
private constructor();
|
|
9
40
|
destroy(): void;
|
|
10
|
-
/**
|
|
11
|
-
|
|
41
|
+
/** Locale for Intl formatting. */
|
|
42
|
+
get locale(): Intl.Locale;
|
|
43
|
+
/**
|
|
44
|
+
* The locale of the currently loaded message bundle.
|
|
45
|
+
* Always one of {@link supportedMessageLocales}.
|
|
46
|
+
*/
|
|
47
|
+
get messageLocale(): Intl.Locale;
|
|
12
48
|
/** Supported locales from app metadata. */
|
|
13
|
-
|
|
14
|
-
/** True if
|
|
15
|
-
|
|
49
|
+
get supportedMessageLocales(): Intl.Locale[];
|
|
50
|
+
/** True if reactive locale switching is enabled. */
|
|
51
|
+
get supportsLiveChanges(): boolean;
|
|
52
|
+
/** True iff `locale` best-fits a supported bundle. */
|
|
53
|
+
supportsLocale(locale: Intl.Locale): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Switches to `locale`. Best-fit match; throws `UNSUPPORTED_LOCALE` on no match.
|
|
56
|
+
*/
|
|
57
|
+
changeLocale(targetLocale: Intl.Locale | undefined): Promise<void>;
|
|
16
58
|
/** Given the package name, constructs a package i18n instance. */
|
|
17
59
|
createPackageI18n(packageName: string): ReadonlyReactive<PackageIntl>;
|
|
18
60
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the application's locale and fetches the appropriate i18n messages.
|
|
21
|
-
*/
|
|
22
|
-
export declare function initI18n(appMetadata: ApplicationMetadata | undefined, forcedLocale: string | undefined): Promise<AppIntl>;
|