@fluid-topics/ft-app-context 1.3.16 → 1.3.18
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.
|
@@ -7,8 +7,15 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export type Unsubscribe = () => void;
|
|
10
|
+
type I18nContextLoadedEventDetails = {
|
|
11
|
+
loadedContexts: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare class I18nContextLoadedEvent extends CustomEvent<I18nContextLoadedEventDetails> {
|
|
14
|
+
constructor(detail: I18nContextLoadedEventDetails);
|
|
15
|
+
}
|
|
10
16
|
export declare const clearAfterUnitTest: unique symbol;
|
|
11
|
-
|
|
17
|
+
declare const FtI18nServiceInternalClass_base: typeof FtServiceWithCache & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").WithEventBusInterface>;
|
|
18
|
+
export declare class FtI18nServiceInternalClass extends FtI18nServiceInternalClass_base {
|
|
12
19
|
private messageContextProvider;
|
|
13
20
|
private defaultMessages;
|
|
14
21
|
private listeners;
|
|
@@ -34,3 +41,4 @@ export declare class FtI18nServiceInternalClass extends FtServiceWithCache {
|
|
|
34
41
|
export type FtI18nService = FtI18nServiceInternalClass;
|
|
35
42
|
export declare const ftI18nService: FtI18nService;
|
|
36
43
|
export declare const ftCustomI18nService: FtI18nService;
|
|
44
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { ftAppInfoStore } from "../redux-stores/FtAppInfoStore";
|
|
3
|
-
import { CacheRegistry, CanceledPromiseError, deepEqual, delay, ParametrizedLabelResolver } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { CacheRegistry, CanceledPromiseError, deepEqual, delay, ParametrizedLabelResolver, withEventBus } from "@fluid-topics/ft-wc-utils";
|
|
4
4
|
import { FtServiceWithCache } from "./FtServiceWithCache";
|
|
5
|
+
export class I18nContextLoadedEvent extends CustomEvent {
|
|
6
|
+
constructor(detail) {
|
|
7
|
+
super("ft-i18n-context-loaded", { detail });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
5
10
|
export const clearAfterUnitTest = Symbol("clearAfterUnitTest");
|
|
6
|
-
export class FtI18nServiceInternalClass extends FtServiceWithCache {
|
|
11
|
+
export class FtI18nServiceInternalClass extends withEventBus(FtServiceWithCache) {
|
|
7
12
|
constructor(messageContextProvider) {
|
|
8
13
|
super();
|
|
9
14
|
this.messageContextProvider = messageContextProvider;
|
|
@@ -44,7 +49,7 @@ export class FtI18nServiceInternalClass extends FtServiceWithCache {
|
|
|
44
49
|
if (defaultMessages && Object.keys(defaultMessages).length > 0) {
|
|
45
50
|
const newDefaultMessages = {
|
|
46
51
|
...((_b = this.defaultMessages[name]) !== null && _b !== void 0 ? _b : {}),
|
|
47
|
-
...defaultMessages
|
|
52
|
+
...defaultMessages,
|
|
48
53
|
};
|
|
49
54
|
if (!deepEqual(this.defaultMessages[name], newDefaultMessages)) {
|
|
50
55
|
this.defaultMessages[name] = newDefaultMessages;
|
|
@@ -93,12 +98,19 @@ export class FtI18nServiceInternalClass extends FtServiceWithCache {
|
|
|
93
98
|
return () => { var _b; return (_b = this.listeners[contextName]) === null || _b === void 0 ? void 0 : _b.delete(callback); };
|
|
94
99
|
}
|
|
95
100
|
async notifyAll() {
|
|
96
|
-
|
|
101
|
+
const loadedContexts = Object.keys(this.listeners);
|
|
102
|
+
document.body.dispatchEvent(new I18nContextLoadedEvent({ loadedContexts: loadedContexts }));
|
|
103
|
+
this.dispatchEvent(new I18nContextLoadedEvent({ loadedContexts: loadedContexts }));
|
|
104
|
+
await Promise.all(loadedContexts.map((context) => this.notify(context, false)));
|
|
97
105
|
}
|
|
98
|
-
async notify(contextName) {
|
|
106
|
+
async notify(contextName, sendEvents = true) {
|
|
107
|
+
if (sendEvents) {
|
|
108
|
+
document.body.dispatchEvent(new I18nContextLoadedEvent({ loadedContexts: [contextName] }));
|
|
109
|
+
this.dispatchEvent(new I18nContextLoadedEvent({ loadedContexts: [contextName] }));
|
|
110
|
+
}
|
|
99
111
|
if (this.listeners[contextName] != null) {
|
|
100
112
|
await Promise.all([...this.listeners[contextName].values()]
|
|
101
|
-
.map(listener => delay(0).then(() => listener()).catch(() => null)));
|
|
113
|
+
.map((listener) => delay(0).then(() => listener()).catch(() => null)));
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
}
|
|
@@ -108,14 +120,14 @@ if (window.FluidTopicsI18nService == null) {
|
|
|
108
120
|
constructor() {
|
|
109
121
|
super(async (locale, name) => (await this.awaitApi).getFluidTopicsMessageContext(locale, name));
|
|
110
122
|
}
|
|
111
|
-
};
|
|
123
|
+
}();
|
|
112
124
|
}
|
|
113
125
|
if (window.FluidTopicsCustomI18nService == null) {
|
|
114
126
|
window.FluidTopicsCustomI18nService = new class extends FtI18nServiceInternalClass {
|
|
115
127
|
constructor() {
|
|
116
128
|
super(async (locale, name) => (await this.awaitApi).getCustomMessageContext(locale, name));
|
|
117
129
|
}
|
|
118
|
-
};
|
|
130
|
+
}();
|
|
119
131
|
}
|
|
120
132
|
export const ftI18nService = window.FluidTopicsI18nService;
|
|
121
133
|
export const ftCustomI18nService = window.FluidTopicsCustomI18nService;
|
|
@@ -2,11 +2,9 @@ import { SearchPlaceConverter } from "@fluid-topics/ft-wc-utils";
|
|
|
2
2
|
import { ftAppInfoStore } from "../redux-stores/FtAppInfoStore";
|
|
3
3
|
export class SearchPlaceConverterProvider {
|
|
4
4
|
static get(defaultPerPage, defaultContentLocale) {
|
|
5
|
-
var _a, _b
|
|
5
|
+
var _a, _b;
|
|
6
6
|
const appInfo = ftAppInfoStore.getState();
|
|
7
7
|
const { lang, region } = (_b = (_a = appInfo.defaultLocales) === null || _a === void 0 ? void 0 : _a.defaultContentLocale) !== null && _b !== void 0 ? _b : { lang: "en", region: "US" };
|
|
8
|
-
return new SearchPlaceConverter(appInfo.baseUrl,
|
|
9
|
-
// TODO: Refacto during the story on custom sorts
|
|
10
|
-
(_d = (_c = window.FluidTopicsClientConfiguration) === null || _c === void 0 ? void 0 : _c.predefinedSorts) !== null && _d !== void 0 ? _d : {}, defaultPerPage !== null && defaultPerPage !== void 0 ? defaultPerPage : 20, appInfo.searchInAllLanguagesAllowed, defaultContentLocale !== null && defaultContentLocale !== void 0 ? defaultContentLocale : `${lang}-${region}`);
|
|
8
|
+
return new SearchPlaceConverter(appInfo.baseUrl, defaultPerPage !== null && defaultPerPage !== void 0 ? defaultPerPage : 20, appInfo.searchInAllLanguagesAllowed, defaultContentLocale !== null && defaultContentLocale !== void 0 ? defaultContentLocale : `${lang}-${region}`);
|
|
11
9
|
}
|
|
12
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-app-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.18",
|
|
4
4
|
"description": "Global application context for Fluid Topics integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "1.3.18",
|
|
23
23
|
"lit": "3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@fluid-topics/public-api": "1.0.
|
|
26
|
+
"@fluid-topics/public-api": "1.0.102"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "f0b88802ac4978bfb8561ded6af8de7c559051a2"
|
|
29
29
|
}
|