@progressive-development/pd-spa-helper 0.8.1-a → 0.8.1-c
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/dist/PdSpaHelper.d.ts.map +1 -1
- package/dist/PdSpaHelper.js +29 -26
- package/dist/model/spa-model.d.ts +7 -0
- package/dist/model/spa-model.d.ts.map +1 -1
- package/dist/router/PdRouterService.d.ts +0 -1
- package/dist/router/PdRouterService.d.ts.map +1 -1
- package/dist/router/PdRouterService.js +43 -6
- package/dist/router/rout-types.d.ts +1 -0
- package/dist/router/rout-types.d.ts.map +1 -1
- package/dist/service-provider/firebase/auth.js +1 -1
- package/dist/service-provider/service-provider-impl.js +1 -9
- package/dist/store/spa-app-actions.d.ts +9 -2
- package/dist/store/spa-app-actions.d.ts.map +1 -1
- package/dist/store/spa-app-actions.js +3 -1
- package/dist/store/spa-app-reducer.d.ts +11 -3
- package/dist/store/spa-app-reducer.d.ts.map +1 -1
- package/dist/store/spa-app-reducer.js +15 -4
- package/dist/store/spa-app-selector.d.ts +5 -1
- package/dist/store/spa-app-selector.d.ts.map +1 -1
- package/dist/store/spa-app-selector.js +10 -2
- package/dist/stories/routing.stories.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdSpaHelper.d.ts","sourceRoot":"","sources":["../src/PdSpaHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,0CAA0C,CAAC;AAClD,OAAO,4CAA4C,CAAC;AACpD,OAAO,qDAAqD,CAAC;AAC7D,OAAO,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"PdSpaHelper.d.ts","sourceRoot":"","sources":["../src/PdSpaHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,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
|
|
7
7
|
import "@progressive-development/pd-content/pd-panel";
|
|
8
8
|
import { pdStore, initializeStore } from "./store/mini-rx.store.js";
|
|
9
|
-
import { authStateChangedImpl, setServiceProvider, initAppImpl
|
|
9
|
+
import { authStateChangedImpl, setServiceProvider, initAppImpl } from "./service-provider/service-provider-impl.js";
|
|
10
10
|
import { getLoadingSelector } from "./store/spa-app-selector.js";
|
|
11
11
|
import { setRouteElement } from "./store/spa-app-effects.js";
|
|
12
12
|
import { APP_CONF_EVENT } from "./model/spa-model.js";
|
|
@@ -25,7 +25,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
if (result) __defProp(target, key, result);
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
|
-
const POST_LOGIN_REDIRECT_KEY = "postLoginRedirect";
|
|
29
28
|
const MADE_BY = {
|
|
30
29
|
txt: "made by PD Progressive Development",
|
|
31
30
|
email: "info@progressive-development.com"
|
|
@@ -46,11 +45,6 @@ const transformRoutes = () => {
|
|
|
46
45
|
};
|
|
47
46
|
routeDefs.push(routeDef);
|
|
48
47
|
});
|
|
49
|
-
routeDefs.push({
|
|
50
|
-
name: "not-found",
|
|
51
|
-
pattern: "/:path(.*)",
|
|
52
|
-
auth: false
|
|
53
|
-
});
|
|
54
48
|
return routeDefs;
|
|
55
49
|
};
|
|
56
50
|
const startInit = (config) => {
|
|
@@ -64,13 +58,12 @@ const startInit = (config) => {
|
|
|
64
58
|
config.navigationConfigParam.pages.push({
|
|
65
59
|
name: "login",
|
|
66
60
|
menu: [{ key: "login", name: "Login" }],
|
|
67
|
-
pattern: ["login"],
|
|
61
|
+
pattern: ["/login"],
|
|
68
62
|
auth: false
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
navigationConfig = config.navigationConfigParam;
|
|
72
66
|
transformedRoutes = transformRoutes();
|
|
73
|
-
pdRouterService.isAuthenticatedWithSessionRedirect = isAuthenticatedWithSessionRedirect;
|
|
74
67
|
pdRouterService.configureRoutes(transformedRoutes);
|
|
75
68
|
document.dispatchEvent(new CustomEvent("init-app-event"));
|
|
76
69
|
console.log("Init done, Event created");
|
|
@@ -152,12 +145,21 @@ const _PdSpaHelper = (_a = class extends LitElement {
|
|
|
152
145
|
*/
|
|
153
146
|
activateLoginHandler() {
|
|
154
147
|
console.log("Activate Login Handler");
|
|
155
|
-
const callback = (user) => {
|
|
148
|
+
const callback = async (user) => {
|
|
149
|
+
var _a2;
|
|
156
150
|
console.log("My callback user:", user);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
151
|
+
if (user) {
|
|
152
|
+
const tokenResult = await user.getIdTokenResult();
|
|
153
|
+
const claims = tokenResult.claims;
|
|
154
|
+
pdStore().dispatch(
|
|
155
|
+
loginSucess({
|
|
156
|
+
uid: user.uid,
|
|
157
|
+
email: user.email,
|
|
158
|
+
emailVerified: user.emailVerified,
|
|
159
|
+
claims,
|
|
160
|
+
providerId: ((_a2 = user.providerData[0]) == null ? void 0 : _a2.providerId) ?? "firebase"
|
|
161
|
+
})
|
|
162
|
+
);
|
|
161
163
|
} else {
|
|
162
164
|
pdStore().dispatch(nologin());
|
|
163
165
|
}
|
|
@@ -185,7 +187,7 @@ const _PdSpaHelper = (_a = class extends LitElement {
|
|
|
185
187
|
(ls) => html`<pd-loading-state .loadingState="${ls}"></pd-loading-state>`
|
|
186
188
|
)}
|
|
187
189
|
${this._renderRoutePages()}
|
|
188
|
-
${
|
|
190
|
+
${this._route === "login" ? html` <default-login
|
|
189
191
|
?active="${this._route === "login"}"
|
|
190
192
|
></default-login>` : ""}
|
|
191
193
|
</main>
|
|
@@ -269,17 +271,19 @@ const _PdSpaHelper = (_a = class extends LitElement {
|
|
|
269
271
|
`;
|
|
270
272
|
}
|
|
271
273
|
_loginSuccess(e) {
|
|
272
|
-
const redirectRoute = sessionStorage.getItem(
|
|
274
|
+
const redirectRoute = sessionStorage.getItem("postLoginRedirect");
|
|
275
|
+
if (redirectRoute) {
|
|
276
|
+
const routeToNavigate = redirectRoute && redirectRoute !== "/login" ? redirectRoute : "";
|
|
277
|
+
sessionStorage.removeItem("postLoginRedirect");
|
|
278
|
+
this.dispatchEvent(
|
|
279
|
+
new CustomEvent("route-event", {
|
|
280
|
+
detail: { route: routeToNavigate },
|
|
281
|
+
bubbles: true,
|
|
282
|
+
composed: true
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
}
|
|
273
286
|
console.debug("Login Event: ", e, window.location.href, redirectRoute);
|
|
274
|
-
const routeToNavigate = redirectRoute && redirectRoute !== "/login" ? redirectRoute : navigationConfig.defaultPostLoginRoute || "";
|
|
275
|
-
sessionStorage.removeItem(POST_LOGIN_REDIRECT_KEY);
|
|
276
|
-
this.dispatchEvent(
|
|
277
|
-
new CustomEvent("route-event", {
|
|
278
|
-
detail: { route: routeToNavigate },
|
|
279
|
-
bubbles: true,
|
|
280
|
-
composed: true
|
|
281
|
-
})
|
|
282
|
-
);
|
|
283
287
|
}
|
|
284
288
|
_localeChange(e) {
|
|
285
289
|
const newLocale = e.detail;
|
|
@@ -461,7 +465,6 @@ __decorateClass([
|
|
|
461
465
|
], _PdSpaHelper.prototype, "_selectedLocale");
|
|
462
466
|
let PdSpaHelper = _PdSpaHelper;
|
|
463
467
|
export {
|
|
464
|
-
POST_LOGIN_REDIRECT_KEY,
|
|
465
468
|
PdSpaHelper,
|
|
466
469
|
startInit
|
|
467
470
|
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export declare const APP_CONF_EVENT = "get-app-conf";
|
|
2
2
|
export declare const RUNNING_WIZARD_STORAGE_ELEMENTS = "pd.spa.local.wizard.storage";
|
|
3
3
|
export declare const UNDEF = "UNDEF";
|
|
4
|
+
export interface AppUser {
|
|
5
|
+
uid: string;
|
|
6
|
+
email: string | null;
|
|
7
|
+
emailVerified: boolean;
|
|
8
|
+
providerId: string;
|
|
9
|
+
claims: Record<string, any>;
|
|
10
|
+
}
|
|
4
11
|
export interface LoadingSubTask {
|
|
5
12
|
actionKey: string;
|
|
6
13
|
completed: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-model.d.ts","sourceRoot":"","sources":["../../src/model/spa-model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,eAAO,MAAM,KAAK,UAAU,CAAC;AAE7B,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B"}
|
|
1
|
+
{"version":3,"file":"spa-model.d.ts","sourceRoot":"","sources":["../../src/model/spa-model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,eAAO,MAAM,KAAK,UAAU,CAAC;AAE7B,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B"}
|
|
@@ -5,7 +5,6 @@ declare class PdRouterService {
|
|
|
5
5
|
private onChangeHandlers;
|
|
6
6
|
private currentRoute;
|
|
7
7
|
constructor();
|
|
8
|
-
isAuthenticatedWithSessionRedirect: (routeName: string) => Promise<boolean>;
|
|
9
8
|
/**
|
|
10
9
|
* Setzt die Routen-Konfiguration. Muss vor Verwendung von navigate() aufgerufen werden.
|
|
11
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdRouterService.d.ts","sourceRoot":"","sources":["../../src/router/PdRouterService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"PdRouterService.d.ts","sourceRoot":"","sources":["../../src/router/PdRouterService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMnE,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;AAE1D,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAqC;IAEnD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,YAAY,CAAc;;IAQlC;;OAEG;IACI,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE;IA0ErD;;OAEG;IACU,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ;IAejD;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,kBAAkB;IAIhD;;OAEG;YACW,OAAO;CAwDtB;AAaD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import UniversalRouter from "universal-router";
|
|
2
|
+
import { selectAuthUser } from "../store/spa-app-selector.js";
|
|
3
|
+
import { pdStore } from "../store/mini-rx.store.js";
|
|
4
|
+
import { firstValueFrom, first, filter } from "rxjs";
|
|
2
5
|
class PdRouterService {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.router = null;
|
|
5
8
|
this.onChangeHandlers = [];
|
|
6
9
|
this.currentRoute = "";
|
|
7
|
-
this.isAuthenticatedWithSessionRedirect = async () => true;
|
|
8
10
|
window.addEventListener("popstate", () => {
|
|
9
11
|
this.resolve(location.pathname + location.search);
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
|
-
// Default-Fallback, falls nicht überschrieben
|
|
13
14
|
/**
|
|
14
15
|
* Setzt die Routen-Konfiguration. Muss vor Verwendung von navigate() aufgerufen werden.
|
|
15
16
|
*/
|
|
@@ -33,9 +34,25 @@ class PdRouterService {
|
|
|
33
34
|
return patterns.map((pattern) => ({
|
|
34
35
|
path: pattern,
|
|
35
36
|
action: async (context) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (def.auth) {
|
|
39
|
+
let authResult;
|
|
40
|
+
if (!((_a = context.userCheck) == null ? void 0 : _a.loginCheckFinish)) {
|
|
41
|
+
authResult = await waitForFinalAuthState();
|
|
42
|
+
context.userCheck = authResult;
|
|
43
|
+
}
|
|
44
|
+
if (!((_b = context.userCheck) == null ? void 0 : _b.user)) {
|
|
45
|
+
const fallbackRoute = def.authFallback ?? "/login";
|
|
46
|
+
return { redirect: fallbackRoute };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (def.roles && !def.roles.some(
|
|
50
|
+
(role) => {
|
|
51
|
+
var _a2;
|
|
52
|
+
return ((_a2 = context.userCheck.user.claims) == null ? void 0 : _a2[role]) === true;
|
|
53
|
+
}
|
|
54
|
+
)) {
|
|
55
|
+
return { redirect: "/unauthorized" };
|
|
39
56
|
}
|
|
40
57
|
if (def.action) {
|
|
41
58
|
const result = await def.action();
|
|
@@ -50,6 +67,7 @@ class PdRouterService {
|
|
|
50
67
|
}
|
|
51
68
|
}));
|
|
52
69
|
});
|
|
70
|
+
console.log("######### Universal routes: ", universalRoutes);
|
|
53
71
|
this.router = new UniversalRouter(universalRoutes);
|
|
54
72
|
this.resolve(location.pathname + location.search);
|
|
55
73
|
}
|
|
@@ -88,7 +106,18 @@ class PdRouterService {
|
|
|
88
106
|
"[PdRouter] bevore resolve Current location:",
|
|
89
107
|
location.pathname
|
|
90
108
|
);
|
|
91
|
-
const
|
|
109
|
+
const userCheck = await firstValueFrom(
|
|
110
|
+
pdStore().select(selectAuthUser).pipe(first())
|
|
111
|
+
);
|
|
112
|
+
const result = await this.router.resolve({
|
|
113
|
+
pathname,
|
|
114
|
+
userCheck
|
|
115
|
+
});
|
|
116
|
+
if (result.redirect) {
|
|
117
|
+
history.replaceState({}, "", result.redirect);
|
|
118
|
+
await this.resolve(result.redirect);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
92
121
|
if (!result || typeof result !== "object" || !result.route) {
|
|
93
122
|
console.warn("[PdRouter] Invalid route result:", result);
|
|
94
123
|
return;
|
|
@@ -106,6 +135,14 @@ class PdRouterService {
|
|
|
106
135
|
}
|
|
107
136
|
}
|
|
108
137
|
}
|
|
138
|
+
async function waitForFinalAuthState() {
|
|
139
|
+
return await firstValueFrom(
|
|
140
|
+
pdStore().select(selectAuthUser).pipe(
|
|
141
|
+
filter((res) => res.loginCheckFinish === true),
|
|
142
|
+
first()
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
109
146
|
const pdRouterService = new PdRouterService();
|
|
110
147
|
export {
|
|
111
148
|
pdRouterService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rout-types.d.ts","sourceRoot":"","sources":["../../src/router/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,7 @@ const authStateChanged = (callback) => {
|
|
|
44
44
|
if (!auth) {
|
|
45
45
|
throw new Error("authStateChanged: Auth was not initialized");
|
|
46
46
|
}
|
|
47
|
-
onAuthStateChanged(auth,
|
|
47
|
+
onAuthStateChanged(auth, callback);
|
|
48
48
|
};
|
|
49
49
|
const authIdTokenStateChanged = (callback) => {
|
|
50
50
|
onIdTokenChanged(auth, (user) => callback(user));
|
|
@@ -7,7 +7,7 @@ import { initMockResponse, callFunctionMock } from "./mock/function-client.js";
|
|
|
7
7
|
import { initFirestorage, uploadFirestorageFile, getFirestorageFileList, getFirestorageFile, downloadFileFirestorage, deleteFirestorageDocument, getFirestorageConf } from "./firebase/firestorage-client.js";
|
|
8
8
|
import { initStorageMock, uploadStorageFileMock, getMockFileList, downloadFileMock } from "./mock/storage-client.js";
|
|
9
9
|
import { prepareMessaging, activateTokenChangeHandler, registerDevice, getFirebaseMessaging } from "./firebase/messagingFirebaseClient.js";
|
|
10
|
-
import
|
|
10
|
+
import "../PdSpaHelper.js";
|
|
11
11
|
let provider;
|
|
12
12
|
let app;
|
|
13
13
|
const throwUndefinedProviderError = () => {
|
|
@@ -82,13 +82,6 @@ const isAuthenticatedImpl = () => {
|
|
|
82
82
|
}
|
|
83
83
|
return throwUndefinedProviderError();
|
|
84
84
|
};
|
|
85
|
-
const isAuthenticatedWithSessionRedirect = (routeName) => {
|
|
86
|
-
const isAuth = isAuthenticatedImpl();
|
|
87
|
-
if (!isAuth && routeName !== "login") {
|
|
88
|
-
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, routeName);
|
|
89
|
-
}
|
|
90
|
-
return Promise.resolve(isAuth);
|
|
91
|
-
};
|
|
92
85
|
const loginImpl = (user, sec) => {
|
|
93
86
|
if (!user) {
|
|
94
87
|
const returnError = new Error("empty user");
|
|
@@ -236,7 +229,6 @@ export {
|
|
|
236
229
|
getUserIdToken,
|
|
237
230
|
initAppImpl,
|
|
238
231
|
isAuthenticatedImpl,
|
|
239
|
-
isAuthenticatedWithSessionRedirect,
|
|
240
232
|
loginImpl,
|
|
241
233
|
logoutImpl,
|
|
242
234
|
registerAppDeviceForNotification,
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { TemplateResult } from 'lit';
|
|
2
|
-
import { LoadingState, LoadingSubTask } from '../model/spa-model.js';
|
|
2
|
+
import { AppUser, LoadingState, LoadingSubTask } from '../model/spa-model.js';
|
|
3
3
|
export declare const initIndexDBSucess: (() => {
|
|
4
4
|
type: "SPA_INIT_INDEX_DB_SUCCESS";
|
|
5
5
|
}) & {
|
|
6
6
|
type: "SPA_INIT_INDEX_DB_SUCCESS";
|
|
7
7
|
};
|
|
8
|
-
export declare const loginSucess: (() => {
|
|
8
|
+
export declare const loginSucess: ((payload: AppUser) => {
|
|
9
|
+
payload: AppUser;
|
|
10
|
+
} & {
|
|
11
|
+
type: "SPA_LOGIN_SUCCESS";
|
|
12
|
+
}) & {
|
|
13
|
+
type: "SPA_LOGIN_SUCCESS";
|
|
14
|
+
};
|
|
15
|
+
export declare const logoutSucess: (() => {
|
|
9
16
|
type: "SPA_LOGIN_SUCCESS";
|
|
10
17
|
}) & {
|
|
11
18
|
type: "SPA_LOGIN_SUCCESS";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-app-actions.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"spa-app-actions.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;CAAsC,CAAC;AACrE,eAAO,MAAM,WAAW;;;;;;CAAkD,CAAC;AAC3E,eAAO,MAAM,YAAY;;;;CAA8B,CAAC;AACxD,eAAO,MAAM,OAAO;;;;CAAyB,CAAC;AAE9C,eAAO,MAAM,WAAW;;;;;;CAA6C,CAAC;AAEtE,eAAO,MAAM,WAAW;SAGf,MAAM,GAAG,cAAc;aACnB,OAAO;eACL,OAAO;eACP,MAAM;;;aAHZ,MAAM,GAAG,cAAc;iBACnB,OAAO;mBACL,OAAO;mBACP,MAAM;;;;;;CAEpB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;CAGjC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;CAG3B,CAAC;AACF,eAAO,MAAM,aAAa;qBAGL,MAAM;kBACT,cAAc;;;yBADX,MAAM;sBACT,cAAc;;;;;;CAE/B,CAAC;AACF,eAAO,MAAM,kBAAkB;;;;;;CAG9B,CAAC;AAEF,eAAO,MAAM,0BAA0B;oBAGnB,MAAM;;;wBAAN,MAAM;;;;;;CAEzB,CAAC;AACF,eAAO,MAAM,iCAAiC;oBAG1B,MAAM;;;wBAAN,MAAM;;;;;;CAEzB,CAAC;AACF,eAAO,MAAM,8BAA8B;;;;;;CAG1C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { action, payload } from "ts-action";
|
|
2
2
|
const initIndexDBSucess = action("SPA_INIT_INDEX_DB_SUCCESS");
|
|
3
|
-
const loginSucess = action("SPA_LOGIN_SUCCESS");
|
|
3
|
+
const loginSucess = action("SPA_LOGIN_SUCCESS", payload());
|
|
4
|
+
const logoutSucess = action("SPA_LOGIN_SUCCESS");
|
|
4
5
|
const nologin = action("SPA_NO_LOGIN");
|
|
5
6
|
const routeAction = action("SPA_APP_ROUTE", payload());
|
|
6
7
|
const toastAction = action(
|
|
@@ -40,6 +41,7 @@ export {
|
|
|
40
41
|
changeSubTask,
|
|
41
42
|
initIndexDBSucess,
|
|
42
43
|
loginSucess,
|
|
44
|
+
logoutSucess,
|
|
43
45
|
nologin,
|
|
44
46
|
removeLoadingState,
|
|
45
47
|
routeAction,
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { LoadingState } from '../model/spa-model.js';
|
|
1
|
+
import { AppUser, LoadingState } from '../model/spa-model.js';
|
|
2
2
|
export interface SpaAppState {
|
|
3
3
|
offline?: boolean;
|
|
4
4
|
loadingState: LoadingState[];
|
|
5
5
|
lastRoutes?: any[];
|
|
6
6
|
initIndexDB?: boolean;
|
|
7
|
-
|
|
7
|
+
userLoginDone: boolean;
|
|
8
|
+
user: AppUser | undefined;
|
|
8
9
|
}
|
|
9
|
-
export declare const spaAppReducer: import('ts-action').Reducer<
|
|
10
|
+
export declare const spaAppReducer: import('ts-action').Reducer<{
|
|
11
|
+
userLoginDone: boolean;
|
|
12
|
+
offline?: boolean;
|
|
13
|
+
loadingState: LoadingState[];
|
|
14
|
+
lastRoutes?: any[];
|
|
15
|
+
initIndexDB?: boolean;
|
|
16
|
+
user: AppUser | undefined;
|
|
17
|
+
}>;
|
|
10
18
|
//# sourceMappingURL=spa-app-reducer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-app-reducer.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-reducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spa-app-reducer.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-reducer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B;AAQD,eAAO,MAAM,aAAa;;cAdd,OAAO;kBACH,YAAY,EAAE;iBACf,GAAG,EAAE;kBACJ,OAAO;UAEf,OAAO,GAAG,SAAS;EAoE1B,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { reducer, on } from "ts-action";
|
|
2
|
-
import { updateInternetOffline, addLoadingState, changeSubTask, removeLoadingState, routeAction, initIndexDBSucess, loginSucess } from "./spa-app-actions.js";
|
|
2
|
+
import { updateInternetOffline, addLoadingState, changeSubTask, removeLoadingState, routeAction, initIndexDBSucess, loginSucess, nologin, logoutSucess } from "./spa-app-actions.js";
|
|
3
3
|
const initialState = {
|
|
4
|
-
loadingState: []
|
|
4
|
+
loadingState: [],
|
|
5
|
+
userLoginDone: false,
|
|
6
|
+
user: void 0
|
|
5
7
|
};
|
|
6
8
|
const spaAppReducer = reducer(
|
|
7
9
|
initialState,
|
|
@@ -43,9 +45,18 @@ const spaAppReducer = reducer(
|
|
|
43
45
|
...state,
|
|
44
46
|
initIndexDB: true
|
|
45
47
|
})),
|
|
46
|
-
on(loginSucess, (state) => ({
|
|
48
|
+
on(loginSucess, (state, { payload }) => ({
|
|
47
49
|
...state,
|
|
48
|
-
|
|
50
|
+
userLoginDone: true,
|
|
51
|
+
user: payload
|
|
52
|
+
})),
|
|
53
|
+
on(nologin, (state) => ({
|
|
54
|
+
...state,
|
|
55
|
+
userLoginDone: true
|
|
56
|
+
})),
|
|
57
|
+
on(logoutSucess, () => ({
|
|
58
|
+
...initialState,
|
|
59
|
+
userLoginDone: true
|
|
49
60
|
}))
|
|
50
61
|
);
|
|
51
62
|
export {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare const getLoadingSelector: import('mini-rx-store/lib/selector.js').Selector<object, import('../model/spa-model.js').LoadingState[]>;
|
|
2
2
|
export declare const getOfflineSelector: import('mini-rx-store/lib/selector.js').Selector<object, boolean>;
|
|
3
3
|
export declare const getInitStatusSelector: import('mini-rx-store/lib/selector.js').Selector<object, {
|
|
4
|
-
login: boolean
|
|
4
|
+
login: boolean;
|
|
5
5
|
indexedDB: boolean | undefined;
|
|
6
6
|
}>;
|
|
7
|
+
export declare const selectAuthUser: import('mini-rx-store/lib/selector.js').Selector<object, {
|
|
8
|
+
user: import('../model/spa-model.js').AppUser | undefined;
|
|
9
|
+
loginCheckFinish: boolean;
|
|
10
|
+
}>;
|
|
7
11
|
//# sourceMappingURL=spa-app-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-app-selector.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,0GAuB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,mEAG9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;EAMjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"spa-app-selector.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,0GAuB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,mEAG9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;EAMjC,CAAC;AAEF,eAAO,MAAM,cAAc;;;EAM1B,CAAC"}
|
|
@@ -28,12 +28,20 @@ const getOfflineSelector = createSelector(
|
|
|
28
28
|
const getInitStatusSelector = createSelector(
|
|
29
29
|
getSpaAppFeatureState,
|
|
30
30
|
(state) => ({
|
|
31
|
-
login: state.
|
|
31
|
+
login: state.user !== void 0,
|
|
32
32
|
indexedDB: state.initIndexDB
|
|
33
33
|
})
|
|
34
34
|
);
|
|
35
|
+
const selectAuthUser = createSelector(
|
|
36
|
+
getSpaAppFeatureState,
|
|
37
|
+
(state) => ({
|
|
38
|
+
user: state.user,
|
|
39
|
+
loginCheckFinish: state.userLoginDone
|
|
40
|
+
})
|
|
41
|
+
);
|
|
35
42
|
export {
|
|
36
43
|
getInitStatusSelector,
|
|
37
44
|
getLoadingSelector,
|
|
38
|
-
getOfflineSelector
|
|
45
|
+
getOfflineSelector,
|
|
46
|
+
selectAuthUser
|
|
39
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.stories.d.ts","sourceRoot":"","sources":["../../src/stories/routing.stories.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,+BAA+B,CAAC;AAGvC,eAAO,MAAM,SAAS,EAAE,cAAc,EA4CrC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAe5B,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"routing.stories.d.ts","sourceRoot":"","sources":["../../src/stories/routing.stories.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,+BAA+B,CAAC;AAGvC,eAAO,MAAM,SAAS,EAAE,cAAc,EA4CrC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAe5B,CAAC;;;;AAOF,wBAEE;AAEF,eAAO,MAAM,YAAY,4CAcxB,CAAC"}
|
package/package.json
CHANGED