@fluid-topics/ft-app-context 1.2.73 → 1.3.1
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.light.js +4 -4
- package/build/ft-app-context.min.js +13 -13
- package/build/redux-stores/FtAppInfoStore.d.ts +2 -1
- package/build/redux-stores/FtAppInfoStore.js +6 -4
- package/build/redux-stores/FtUserAssetsStore.js +2 -2
- package/build/services/FtI18nService.d.ts +1 -1
- package/build/services/history/HistoryService.d.ts +4 -4
- package/build/services/history/HistoryService.js +45 -30
- package/build/services/history/HistoryService.models.d.ts +2 -2
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FtReduxStore, Optional } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import { FtDefaultLocales, FtMetadataConfiguration, FtSession, FtUiLocale
|
|
2
|
+
import { FtDefaultLocales, FtMetadataConfiguration, FtPrivacyPolicyConfiguration, FtSession, FtUiLocale } 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 {
|
|
@@ -20,6 +20,7 @@ export interface FtAppInfoState {
|
|
|
20
20
|
forcedOffline: boolean;
|
|
21
21
|
}
|
|
22
22
|
export declare class AuthenticationChangeEvent extends CustomEvent<Optional<FtSession>> {
|
|
23
|
+
static eventName: string;
|
|
23
24
|
constructor(session: Optional<FtSession>);
|
|
24
25
|
}
|
|
25
26
|
declare const reducers: {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { deepEqual, FtReduxStore } from "@fluid-topics/ft-wc-utils";
|
|
2
2
|
export const FtAppInfoStoreName = "ft-app-info";
|
|
3
|
-
|
|
3
|
+
class AuthenticationChangeEvent extends CustomEvent {
|
|
4
4
|
constructor(session) {
|
|
5
|
-
super(
|
|
5
|
+
super(AuthenticationChangeEvent.eventName, { detail: session });
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
AuthenticationChangeEvent.eventName = "authentication-change";
|
|
9
|
+
export { AuthenticationChangeEvent };
|
|
8
10
|
const reducers = {
|
|
9
11
|
session: (state, action) => {
|
|
10
12
|
if (!deepEqual(state.session, action.payload)) {
|
|
11
13
|
state.session = action.payload;
|
|
12
14
|
setTimeout(() => ftAppInfoStore.dispatchEvent(new AuthenticationChangeEvent(action.payload)), 0);
|
|
13
15
|
}
|
|
14
|
-
}
|
|
16
|
+
},
|
|
15
17
|
};
|
|
16
18
|
export const ftAppInfoStore = FtReduxStore.get({
|
|
17
19
|
name: FtAppInfoStoreName,
|
|
@@ -32,5 +34,5 @@ export const ftAppInfoStore = FtReduxStore.get({
|
|
|
32
34
|
openExternalDocumentInNewTab: false,
|
|
33
35
|
navigatorOnline: true,
|
|
34
36
|
forcedOffline: false,
|
|
35
|
-
}
|
|
37
|
+
},
|
|
36
38
|
});
|
|
@@ -24,7 +24,7 @@ export declare class FtI18nServiceInternalClass extends FtServiceWithCache {
|
|
|
24
24
|
getAllContexts(): Array<FtMessageContext>;
|
|
25
25
|
prepareContext(name: string, defaultMessages?: Record<string, string>): Promise<FtMessageContext | undefined>;
|
|
26
26
|
private resolveContext;
|
|
27
|
-
resolveRawMessage(contextName: string, messageKey: string):
|
|
27
|
+
resolveRawMessage(contextName: string, messageKey: string): string;
|
|
28
28
|
resolveMessage(contextName: string, message: string, ...args: any[]): string;
|
|
29
29
|
private fetchContext;
|
|
30
30
|
subscribe(contextName: string, callback: Function): Unsubscribe;
|
|
@@ -17,18 +17,18 @@ export declare class HistoryService extends WithEventBus {
|
|
|
17
17
|
private installProxies;
|
|
18
18
|
private initEventListeners;
|
|
19
19
|
private initData;
|
|
20
|
-
updateCurrentState(update?: HistoryStateUpdate
|
|
20
|
+
updateCurrentState(update?: HistoryStateUpdate): void;
|
|
21
21
|
addHistoryChangeListener(listener: (event: HistoryChangeEvent) => void): void;
|
|
22
22
|
removeHistoryChangeListener(listener: (event: HistoryChangeEvent) => void): void;
|
|
23
23
|
currentItem(): HistoryState;
|
|
24
24
|
back(): void;
|
|
25
25
|
backwardItem(): HistoryState | undefined;
|
|
26
|
-
private
|
|
26
|
+
private previousDifferentMajorPosition;
|
|
27
27
|
forward(): void;
|
|
28
28
|
forwardItem(): HistoryState | undefined;
|
|
29
29
|
private nextMajorPosition;
|
|
30
|
-
private
|
|
30
|
+
private getHigherPositionInTheSameState;
|
|
31
31
|
private buildCurrentState;
|
|
32
32
|
private hasState;
|
|
33
|
-
private
|
|
33
|
+
private isDifferentMajorState;
|
|
34
34
|
}
|
|
@@ -68,20 +68,14 @@ export class HistoryService extends WithEventBus {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
updateCurrentState(update
|
|
72
|
-
var _a
|
|
71
|
+
updateCurrentState(update) {
|
|
72
|
+
var _a;
|
|
73
73
|
const newState = {
|
|
74
74
|
...this.buildCurrentState(),
|
|
75
75
|
...update,
|
|
76
76
|
index: this.currentIndex,
|
|
77
77
|
title: (_a = update === null || update === void 0 ? void 0 : update.title) !== null && _a !== void 0 ? _a : this.currentState.title,
|
|
78
78
|
};
|
|
79
|
-
const majorState = forceMajorStateFromUpdate
|
|
80
|
-
? ((_b = update === null || update === void 0 ? void 0 : update.majorState) !== null && _b !== void 0 ? _b : this.currentState.majorState)
|
|
81
|
-
: ((_c = this.currentState.majorState) !== null && _c !== void 0 ? _c : update === null || update === void 0 ? void 0 : update.majorState);
|
|
82
|
-
if (majorState != undefined) {
|
|
83
|
-
newState.majorState = majorState;
|
|
84
|
-
}
|
|
85
79
|
this.setCurrentState(newState);
|
|
86
80
|
}
|
|
87
81
|
addHistoryChangeListener(listener) {
|
|
@@ -94,7 +88,7 @@ export class HistoryService extends WithEventBus {
|
|
|
94
88
|
return deepCopy(this.currentState);
|
|
95
89
|
}
|
|
96
90
|
back() {
|
|
97
|
-
const previousMajorPosition = this.
|
|
91
|
+
const previousMajorPosition = this.previousDifferentMajorPosition();
|
|
98
92
|
if (previousMajorPosition >= 0) {
|
|
99
93
|
this.history.go(previousMajorPosition - this.currentIndex);
|
|
100
94
|
}
|
|
@@ -106,18 +100,18 @@ export class HistoryService extends WithEventBus {
|
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
102
|
backwardItem() {
|
|
109
|
-
return deepCopy(this.states[this.
|
|
103
|
+
return deepCopy(this.states[this.previousDifferentMajorPosition()]);
|
|
110
104
|
}
|
|
111
|
-
|
|
112
|
-
let position = this.currentIndex;
|
|
113
|
-
while (position > 0 && !this.
|
|
105
|
+
previousDifferentMajorPosition() {
|
|
106
|
+
let position = this.currentIndex > 0 ? this.currentIndex - 1 : 0;
|
|
107
|
+
while (position > 0 && !this.isDifferentMajorState(position)) {
|
|
114
108
|
position--;
|
|
115
109
|
}
|
|
116
|
-
return
|
|
110
|
+
return position;
|
|
117
111
|
}
|
|
118
112
|
forward() {
|
|
119
113
|
const nextMajorPosition = this.nextMajorPosition();
|
|
120
|
-
if (nextMajorPosition < this.states.length) {
|
|
114
|
+
if (nextMajorPosition && nextMajorPosition < this.states.length) {
|
|
121
115
|
this.history.go(nextMajorPosition - this.currentIndex);
|
|
122
116
|
}
|
|
123
117
|
else {
|
|
@@ -125,24 +119,40 @@ export class HistoryService extends WithEventBus {
|
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
forwardItem() {
|
|
128
|
-
|
|
122
|
+
const nextMajorPosition = this.nextMajorPosition();
|
|
123
|
+
if (!nextMajorPosition) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return deepCopy(this.states[nextMajorPosition]);
|
|
129
127
|
}
|
|
130
128
|
nextMajorPosition() {
|
|
131
129
|
let position = this.currentIndex;
|
|
130
|
+
if (position >= this.states.length) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
132
133
|
do {
|
|
133
134
|
position++;
|
|
134
|
-
} while (position < this.states.length && !this.
|
|
135
|
-
|
|
135
|
+
} while (position < this.states.length && !this.isDifferentMajorState(position));
|
|
136
|
+
return this.getHigherPositionInTheSameState(position);
|
|
137
|
+
}
|
|
138
|
+
getHigherPositionInTheSameState(fromPosition) {
|
|
139
|
+
var _a;
|
|
140
|
+
const majorStateIdRef = (_a = this.states[fromPosition]) === null || _a === void 0 ? void 0 : _a.majorStateId;
|
|
141
|
+
if (!majorStateIdRef) {
|
|
142
|
+
// When no major Id, the state is alone on its "Major" reference
|
|
143
|
+
return fromPosition;
|
|
144
|
+
}
|
|
145
|
+
let higherDefinedStatePositionInTheSameMajorState = fromPosition;
|
|
146
|
+
let position = fromPosition + 1;
|
|
147
|
+
// Go to the last state with the same majorStateId
|
|
148
|
+
while (this.states.length > position && !this.isDifferentMajorState(position, majorStateIdRef)) {
|
|
149
|
+
// If state is undefined, still check next position until different majorState but do not update higherDefinedStatePositionInTheSameMajorState
|
|
150
|
+
if (this.hasState(position)) {
|
|
151
|
+
higherDefinedStatePositionInTheSameMajorState = position;
|
|
152
|
+
}
|
|
136
153
|
position++;
|
|
137
|
-
}
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
previousExistingPosition(fromIndex) {
|
|
141
|
-
let position = fromIndex;
|
|
142
|
-
do {
|
|
143
|
-
position--;
|
|
144
|
-
} while (position > 0 && !this.hasState(position));
|
|
145
|
-
return position;
|
|
154
|
+
}
|
|
155
|
+
return higherDefinedStatePositionInTheSameMajorState;
|
|
146
156
|
}
|
|
147
157
|
buildCurrentState() {
|
|
148
158
|
var _a, _b;
|
|
@@ -156,8 +166,13 @@ export class HistoryService extends WithEventBus {
|
|
|
156
166
|
hasState(index) {
|
|
157
167
|
return this.states[index] != undefined;
|
|
158
168
|
}
|
|
159
|
-
|
|
160
|
-
var _a
|
|
161
|
-
|
|
169
|
+
isDifferentMajorState(index, majorStateId) {
|
|
170
|
+
var _a;
|
|
171
|
+
if (!this.hasState(index)) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const referenceMajorStateId = (majorStateId !== null && majorStateId !== void 0 ? majorStateId : this.currentState.majorStateId);
|
|
175
|
+
const evaluatedMajorStateId = (_a = this.states[index]) === null || _a === void 0 ? void 0 : _a.majorStateId;
|
|
176
|
+
return evaluatedMajorStateId == undefined || evaluatedMajorStateId != referenceMajorStateId;
|
|
162
177
|
}
|
|
163
178
|
}
|
|
@@ -3,14 +3,14 @@ export interface HistoryState {
|
|
|
3
3
|
href: string;
|
|
4
4
|
token?: string;
|
|
5
5
|
title: string;
|
|
6
|
-
|
|
6
|
+
majorStateId?: string;
|
|
7
7
|
category?: string;
|
|
8
8
|
[additionalInfo: string]: any;
|
|
9
9
|
}
|
|
10
10
|
export interface HistoryStateUpdate {
|
|
11
11
|
token?: string;
|
|
12
12
|
title?: string;
|
|
13
|
-
|
|
13
|
+
majorStateId?: string;
|
|
14
14
|
category?: string;
|
|
15
15
|
[additionalInfo: string]: any;
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-app-context",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
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.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "1.3.1",
|
|
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.99"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "ba07775e09d57ec38038f07f9c03b52aea08376b"
|
|
29
29
|
}
|