@fluid-topics/ft-app-context 2.2.4 → 2.2.5
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/build/ft-app-context.js +2 -1
- package/build/ft-app-context.light.js +3 -3
- package/build/ft-app-context.min.js +16 -16
- package/build/redux-stores/FtAppInfoStore.d.ts +2 -1
- package/build/redux-stores/FtAppInfoStore.js +1 -0
- package/build/redux-stores/FtAppStateManager.d.ts +5 -3
- package/build/redux-stores/FtAppStateManager.js +11 -7
- package/build/services/history/HistoryService.d.ts +3 -1
- package/build/services/history/HistoryService.js +12 -4
- package/build/services/history/HistoryService.models.d.ts +11 -0
- package/build/services/history/HistoryService.models.js +10 -0
- package/build/services/history/index.d.ts +2 -0
- package/build/services/history/index.js +2 -0
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FtReduxStore, Optional } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import { FtLocalesConfiguration, FtMetadataConfiguration, FtPrivacyPolicyConfiguration, FtSearchLocale, FtSession, FtUserLocaleSummary } from "@fluid-topics/public-api";
|
|
2
|
+
import { FtLocalesConfiguration, FtMetadataConfiguration, FtPrivacyPolicyConfiguration, FtSearchLocale, FtSession, FtStickyFiltersSummary, FtUserLocaleSummary } from "@fluid-topics/public-api";
|
|
3
3
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
4
4
|
export declare const FtAppInfoStoreName = "ft-app-info";
|
|
5
5
|
export interface FtAppInfoState {
|
|
@@ -21,6 +21,7 @@ export interface FtAppInfoState {
|
|
|
21
21
|
navigatorOnline: boolean;
|
|
22
22
|
forcedOffline: boolean;
|
|
23
23
|
authenticationRequired: boolean;
|
|
24
|
+
stickyFilters: Optional<FtStickyFiltersSummary>;
|
|
24
25
|
}
|
|
25
26
|
export declare class AuthenticationChangeEvent extends CustomEvent<Optional<FtSession>> {
|
|
26
27
|
static eventName: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Debouncer, FtReduxStore, FtStateManager } from "@fluid-topics/ft-wc-utils";
|
|
1
|
+
import { Debouncer, FtReduxStore, FtStateManager, Optional } from "@fluid-topics/ft-wc-utils";
|
|
2
2
|
import { FtAppInfoState, FtAppInfoStateReducers } from "./FtAppInfoStore";
|
|
3
|
-
import { FluidTopicsApi, FtMetadataConfiguration, FtSession } from "@fluid-topics/public-api";
|
|
3
|
+
import { FluidTopicsApi, FtMetadataConfiguration, FtSession, FtStickyFiltersSummary } from "@fluid-topics/public-api";
|
|
4
4
|
import { UserLocaleService } from "../services/user/UserLocaleService";
|
|
5
5
|
export declare class FtAppStateManager extends FtStateManager {
|
|
6
6
|
readonly store: FtReduxStore<FtAppInfoState, FtAppInfoStateReducers>;
|
|
@@ -11,7 +11,8 @@ export declare class FtAppStateManager extends FtStateManager {
|
|
|
11
11
|
userLocaleService: UserLocaleService;
|
|
12
12
|
constructor(store: FtReduxStore<FtAppInfoState, FtAppInfoStateReducers>, apiProvider?: () => FluidTopicsApi | undefined);
|
|
13
13
|
setWithManualResources(withManualResources: boolean): void;
|
|
14
|
-
|
|
14
|
+
addListeners(): void;
|
|
15
|
+
removeListeners(): void;
|
|
15
16
|
updateIfNeeded(): Promise<void>;
|
|
16
17
|
private cleanSessionDebouncer;
|
|
17
18
|
private updateSession;
|
|
@@ -19,6 +20,7 @@ export declare class FtAppStateManager extends FtStateManager {
|
|
|
19
20
|
updateLocalesConfiguration(): Promise<void>;
|
|
20
21
|
updateAvailableContentLocales(): Promise<void>;
|
|
21
22
|
private reloadConfiguration;
|
|
23
|
+
setStickyFilters(stickyFilters: Optional<FtStickyFiltersSummary>): void;
|
|
22
24
|
setBaseUrl(baseUrl?: string): void;
|
|
23
25
|
setTenantId(tenantId?: string): void;
|
|
24
26
|
setApiIntegrationIdentifier(apiIntegrationIdentifier: string): void;
|
|
@@ -14,6 +14,11 @@ export class FtAppStateManager extends FtStateManager {
|
|
|
14
14
|
this.withManualResources = true;
|
|
15
15
|
this.userLocaleService = new UserLocaleService();
|
|
16
16
|
this.cleanSessionDebouncer = new Debouncer();
|
|
17
|
+
this.reloadConfiguration = () => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = this.cache) === null || _a === void 0 ? void 0 : _a.clear("availableContentLocales");
|
|
20
|
+
this.updateAvailableContentLocales();
|
|
21
|
+
};
|
|
17
22
|
this.reloadDebouncer = new Debouncer(500);
|
|
18
23
|
this.apiProvider = apiProvider !== null && apiProvider !== void 0 ? apiProvider : (() => FluidTopicsApiProvider.get());
|
|
19
24
|
}
|
|
@@ -21,9 +26,12 @@ export class FtAppStateManager extends FtStateManager {
|
|
|
21
26
|
this.withManualResources = withManualResources;
|
|
22
27
|
this.updateIfNeeded();
|
|
23
28
|
}
|
|
24
|
-
|
|
29
|
+
addListeners() {
|
|
25
30
|
this.store.addEventListener(AuthenticationChangeEvent.eventName, this.reloadConfiguration);
|
|
26
31
|
}
|
|
32
|
+
removeListeners() {
|
|
33
|
+
this.store.removeEventListener(AuthenticationChangeEvent.eventName, this.reloadConfiguration);
|
|
34
|
+
}
|
|
27
35
|
async updateIfNeeded() {
|
|
28
36
|
if (this.apiProvider()) {
|
|
29
37
|
if (!this.withManualResources) {
|
|
@@ -66,12 +74,8 @@ export class FtAppStateManager extends FtStateManager {
|
|
|
66
74
|
const availableContentLocales = await this.cache.get("availableContentLocales", () => getOrDefaultIfMissingRequiredAuthentication(() => this.apiProvider().getAvailableSearchLocales(), { contentLocales: [] }));
|
|
67
75
|
this.setAvailableContentLocales((_a = availableContentLocales.contentLocales) !== null && _a !== void 0 ? _a : []);
|
|
68
76
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
(_a = this.cache) === null || _a === void 0 ? void 0 : _a.clear("availableContentLocales");
|
|
72
|
-
if (typeof this.updateAvailableContentLocales === "function") {
|
|
73
|
-
this.updateAvailableContentLocales();
|
|
74
|
-
}
|
|
77
|
+
setStickyFilters(stickyFilters) {
|
|
78
|
+
this.store.actions.stickyFilters(stickyFilters);
|
|
75
79
|
}
|
|
76
80
|
setBaseUrl(baseUrl) {
|
|
77
81
|
this.store.actions.baseUrl(baseUrl);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WithEventBus } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import { HistoryChangeEvent, HistoryState, HistoryStateUpdate } from "./HistoryService.models";
|
|
2
|
+
import { BeforeLocationChangeEvent, HistoryChangeEvent, HistoryState, HistoryStateUpdate } from "./HistoryService.models";
|
|
3
3
|
import { HistorySessionStorage } from "./HistorySessionStorage";
|
|
4
4
|
export declare class HistoryService extends WithEventBus {
|
|
5
5
|
private history;
|
|
@@ -18,6 +18,8 @@ export declare class HistoryService extends WithEventBus {
|
|
|
18
18
|
private initEventListeners;
|
|
19
19
|
private initData;
|
|
20
20
|
updateCurrentState(update?: HistoryStateUpdate): void;
|
|
21
|
+
addBeforeLocationChangeListener(listener: (event: BeforeLocationChangeEvent) => void): void;
|
|
22
|
+
removeBeforeLocationChangeListener(listener: (event: BeforeLocationChangeEvent) => void): void;
|
|
21
23
|
addHistoryChangeListener(listener: (event: HistoryChangeEvent) => void): void;
|
|
22
24
|
removeHistoryChangeListener(listener: (event: HistoryChangeEvent) => void): void;
|
|
23
25
|
currentItem(): HistoryState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepCopy, deepEqual, WithEventBus, } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import { HistoryChangeEvent, } from "./HistoryService.models";
|
|
2
|
+
import { BeforeLocationChangeEvent, HistoryChangeEvent, } from "./HistoryService.models";
|
|
3
3
|
import { historyStorage, } from "./HistorySessionStorage";
|
|
4
4
|
export class HistoryService extends WithEventBus {
|
|
5
5
|
static build() {
|
|
@@ -31,20 +31,22 @@ export class HistoryService extends WithEventBus {
|
|
|
31
31
|
}
|
|
32
32
|
this.historyStorage.set(this.currentIndex, this.currentState);
|
|
33
33
|
if (!deepEqual(this.currentState, this.history.state)) {
|
|
34
|
-
this.realReplaceState.apply(this.history, [this.currentState, this.currentState.title,
|
|
34
|
+
this.realReplaceState.apply(this.history, [this.currentState, this.currentState.title, this.windowLocation().href]);
|
|
35
35
|
}
|
|
36
36
|
setTimeout(() => this.dispatchEvent(new HistoryChangeEvent(this.currentItem())), 0);
|
|
37
37
|
}
|
|
38
38
|
installProxies() {
|
|
39
39
|
const editStateProxy = (indexProvider) => (method, history, [data, title, url]) => {
|
|
40
|
+
const beforeEvent = new BeforeLocationChangeEvent(new URL(typeof url === "string" ? url : (url !== null && url !== void 0 ? url : this.windowLocation()).href, window.location.origin));
|
|
41
|
+
this.dispatchEvent(beforeEvent);
|
|
40
42
|
const index = indexProvider();
|
|
41
43
|
const state = {
|
|
42
44
|
...(index === this.currentIndex ? this.currentState : undefined),
|
|
43
45
|
...data,
|
|
44
46
|
index: index,
|
|
45
|
-
href:
|
|
47
|
+
href: beforeEvent.detail.nextLocation.href,
|
|
46
48
|
};
|
|
47
|
-
method.apply(history, [state, title,
|
|
49
|
+
method.apply(history, [state, title, state.href]);
|
|
48
50
|
this.setCurrentState(state, true);
|
|
49
51
|
};
|
|
50
52
|
this.history.pushState = new Proxy(this.history.pushState, { apply: editStateProxy(() => this.currentIndex + 1) });
|
|
@@ -78,6 +80,12 @@ export class HistoryService extends WithEventBus {
|
|
|
78
80
|
};
|
|
79
81
|
this.setCurrentState(newState);
|
|
80
82
|
}
|
|
83
|
+
addBeforeLocationChangeListener(listener) {
|
|
84
|
+
this.addEventListener(BeforeLocationChangeEvent.eventName, listener);
|
|
85
|
+
}
|
|
86
|
+
removeBeforeLocationChangeListener(listener) {
|
|
87
|
+
this.removeEventListener(BeforeLocationChangeEvent.eventName, listener);
|
|
88
|
+
}
|
|
81
89
|
addHistoryChangeListener(listener) {
|
|
82
90
|
this.addEventListener(HistoryChangeEvent.eventName, listener);
|
|
83
91
|
}
|
|
@@ -14,6 +14,17 @@ export interface HistoryStateUpdate {
|
|
|
14
14
|
category?: string;
|
|
15
15
|
[additionalInfo: string]: any;
|
|
16
16
|
}
|
|
17
|
+
export interface BeforeLocationChangeEventDetail {
|
|
18
|
+
nextLocation: URL;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Event fired when the location is changed by the application.
|
|
22
|
+
* This event is **deliberately** not fired when navigating through history.
|
|
23
|
+
*/
|
|
24
|
+
export declare class BeforeLocationChangeEvent extends CustomEvent<BeforeLocationChangeEventDetail> {
|
|
25
|
+
static eventName: string;
|
|
26
|
+
constructor(nextLocation: URL);
|
|
27
|
+
}
|
|
17
28
|
export declare class HistoryChangeEvent extends CustomEvent<{
|
|
18
29
|
currentItem: HistoryState;
|
|
19
30
|
}> {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event fired when the location is changed by the application.
|
|
3
|
+
* This event is **deliberately** not fired when navigating through history.
|
|
4
|
+
*/
|
|
5
|
+
export class BeforeLocationChangeEvent extends CustomEvent {
|
|
6
|
+
constructor(nextLocation) {
|
|
7
|
+
super(BeforeLocationChangeEvent.eventName, { detail: { nextLocation } });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
BeforeLocationChangeEvent.eventName = "before-location-change";
|
|
1
11
|
export class HistoryChangeEvent extends CustomEvent {
|
|
2
12
|
constructor(currentItem) {
|
|
3
13
|
super(HistoryChangeEvent.eventName, { detail: { currentItem } });
|
|
@@ -11,6 +11,8 @@ declare global {
|
|
|
11
11
|
backwardItemMatching: HistoryService["backwardItemMatching"];
|
|
12
12
|
addHistoryChangeListener: HistoryService["addHistoryChangeListener"];
|
|
13
13
|
removeHistoryChangeListener: HistoryService["removeHistoryChangeListener"];
|
|
14
|
+
addBeforeLocationChangeListener: HistoryService["addBeforeLocationChangeListener"];
|
|
15
|
+
removeBeforeLocationChangeListener: HistoryService["removeBeforeLocationChangeListener"];
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -10,5 +10,7 @@ if (window.FluidTopicsInternalHistoryService == null) {
|
|
|
10
10
|
backwardItemMatching: (predicate) => window.FluidTopicsInternalHistoryService.backwardItemMatching(predicate),
|
|
11
11
|
addHistoryChangeListener: (listener) => window.FluidTopicsInternalHistoryService.addHistoryChangeListener(listener),
|
|
12
12
|
removeHistoryChangeListener: (listener) => window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(listener),
|
|
13
|
+
addBeforeLocationChangeListener: (listener) => window.FluidTopicsInternalHistoryService.addBeforeLocationChangeListener(listener),
|
|
14
|
+
removeBeforeLocationChangeListener: (listener) => window.FluidTopicsInternalHistoryService.removeBeforeLocationChangeListener(listener),
|
|
13
15
|
};
|
|
14
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-app-context",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Global application context for Fluid Topics integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,12 +19,12 @@
|
|
|
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": "2.2.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "2.2.5",
|
|
23
23
|
"@lit/context": "1.1.6",
|
|
24
24
|
"lit": "3.3.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-topics/public-api": "1.0.
|
|
27
|
+
"@fluid-topics/public-api": "1.0.138"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "49802c8417d9eb8b329f8187f08c05af4d546c93"
|
|
30
30
|
}
|