@visin/frontend-core 0.1.2 → 0.1.4
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/auth/AuthProvider.d.ts +24 -0
- package/dist/auth/AuthProvider.d.ts.map +1 -0
- package/dist/auth/AuthProvider.js +48 -0
- package/dist/auth/AuthProvider.js.map +1 -0
- package/dist/auth/authService.d.ts +47 -0
- package/dist/auth/authService.d.ts.map +1 -0
- package/dist/auth/authService.js +74 -0
- package/dist/auth/authService.js.map +1 -0
- package/dist/components/ErrorPage/ErrorPage.d.ts +18 -0
- package/dist/components/ErrorPage/ErrorPage.d.ts.map +1 -0
- package/dist/components/ErrorPage/ErrorPage.js +20 -0
- package/dist/components/ErrorPage/ErrorPage.js.map +1 -0
- package/dist/components/ErrorPage/index.d.ts +3 -0
- package/dist/components/ErrorPage/index.d.ts.map +1 -0
- package/dist/components/ErrorPage/index.js +2 -0
- package/dist/components/ErrorPage/index.js.map +1 -0
- package/dist/components/Loader/Loader.d.ts +13 -0
- package/dist/components/Loader/Loader.d.ts.map +1 -0
- package/dist/components/Loader/Loader.js +16 -0
- package/dist/components/Loader/Loader.js.map +1 -0
- package/dist/components/Loader/index.d.ts +3 -0
- package/dist/components/Loader/index.d.ts.map +1 -0
- package/dist/components/Loader/index.js +2 -0
- package/dist/components/Loader/index.js.map +1 -0
- package/dist/config/createConfigProvider.d.ts +22 -0
- package/dist/config/createConfigProvider.d.ts.map +1 -0
- package/dist/config/createConfigProvider.js +70 -0
- package/dist/config/createConfigProvider.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +17 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { AuthCheckResult, AuthService, AuthUser } from './authService';
|
|
3
|
+
export interface AuthContextValue {
|
|
4
|
+
user: AuthUser | null;
|
|
5
|
+
isAuthenticated: boolean;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
/** Redirects to auth-front's login page, returning to the current page after. */
|
|
8
|
+
login: () => void;
|
|
9
|
+
logout: () => Promise<void>;
|
|
10
|
+
/** Re-runs the session check and updates the shared context state; returns the fresh result. */
|
|
11
|
+
refresh: () => Promise<AuthCheckResult>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Builds a Context + `useAuth()` hook backed by a single `authService`
|
|
15
|
+
* instance, so every consumer in the app shares one session check instead
|
|
16
|
+
* of each component independently re-fetching `/auth/verify` on mount.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createAuthContext(authService: AuthService): {
|
|
19
|
+
AuthProvider: ({ children }: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) => import("react").JSX.Element;
|
|
22
|
+
useAuth: () => AuthContextValue;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=AuthProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,gGAAgG;IAChG,OAAO,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW;iCAGpB;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE;mBAsCvC,gBAAgB;EASrC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Context + `useAuth()` hook backed by a single `authService`
|
|
5
|
+
* instance, so every consumer in the app shares one session check instead
|
|
6
|
+
* of each component independently re-fetching `/auth/verify` on mount.
|
|
7
|
+
*/
|
|
8
|
+
export function createAuthContext(authService) {
|
|
9
|
+
const AuthContext = createContext(undefined);
|
|
10
|
+
function AuthProvider({ children }) {
|
|
11
|
+
const [user, setUser] = useState(null);
|
|
12
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
13
|
+
const refresh = useCallback(async () => {
|
|
14
|
+
const result = await authService.checkAuth();
|
|
15
|
+
setUser(result.user);
|
|
16
|
+
return result;
|
|
17
|
+
}, []);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let cancelled = false;
|
|
20
|
+
setIsLoading(true);
|
|
21
|
+
refresh().finally(() => {
|
|
22
|
+
if (!cancelled)
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
cancelled = true;
|
|
27
|
+
};
|
|
28
|
+
}, [refresh]);
|
|
29
|
+
const login = useCallback(() => {
|
|
30
|
+
authService.redirectToLogin();
|
|
31
|
+
}, []);
|
|
32
|
+
const logout = useCallback(async () => {
|
|
33
|
+
await authService.logout();
|
|
34
|
+
setUser(null);
|
|
35
|
+
window.location.reload();
|
|
36
|
+
}, []);
|
|
37
|
+
return (_jsx(AuthContext.Provider, { value: { user, isAuthenticated: !!user, isLoading, login, logout, refresh }, children: children }));
|
|
38
|
+
}
|
|
39
|
+
function useAuth() {
|
|
40
|
+
const context = useContext(AuthContext);
|
|
41
|
+
if (context === undefined) {
|
|
42
|
+
throw new Error('useAuth must be used within an AuthProvider');
|
|
43
|
+
}
|
|
44
|
+
return context;
|
|
45
|
+
}
|
|
46
|
+
return { AuthProvider, useAuth };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=AuthProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../../src/auth/AuthProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAcpG;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAwB;IACxD,MAAM,WAAW,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;IAE3E,SAAS,YAAY,CAAC,EAAE,QAAQ,EAA2B;QACzD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAkB,IAAI,CAAC,CAAC;QACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEjD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAA8B,EAAE;YAC/D,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,SAAS,CAAC,GAAG,EAAE;YACb,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACrB,IAAI,CAAC,SAAS;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,EAAE;gBACV,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAEd,MAAM,KAAK,GAAG,WAAW,CAAC,GAAS,EAAE;YACnC,WAAW,CAAC,eAAe,EAAE,CAAC;QAChC,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,IAAmB,EAAE;YACnD,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC3B,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAC9F,QAAQ,GACY,CACxB,CAAC;IACJ,CAAC;IAED,SAAS,OAAO;QACd,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fields observed across the auth-service endpoints frontends call:
|
|
3
|
+
* `/auth/verify` always returns `groups` (JWT-derived); `/auth/profile`
|
|
4
|
+
* returns `firstName`/`lastName` (DB-derived) but not `groups`. Optional
|
|
5
|
+
* fields reflect which endpoint populated the result, not that the field
|
|
6
|
+
* is unreliable.
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthUser {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
name: string;
|
|
12
|
+
picture?: string;
|
|
13
|
+
firstName?: string;
|
|
14
|
+
lastName?: string;
|
|
15
|
+
username?: string;
|
|
16
|
+
groups?: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface AuthCheckResult {
|
|
19
|
+
authenticated: boolean;
|
|
20
|
+
user: AuthUser | null;
|
|
21
|
+
}
|
|
22
|
+
export interface AuthServiceOptions {
|
|
23
|
+
/** Base URL of auth-service, e.g. `() => getGlobalConfig().AUTH_SERVICE_URL`. */
|
|
24
|
+
authServiceUrl: () => string;
|
|
25
|
+
/** Base URL of the auth-front login page, e.g. `() => getGlobalConfig().AUTH_FRONT_URL`. */
|
|
26
|
+
authFrontUrl: () => string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Session-management logic shared by every Visin frontend: token storage,
|
|
30
|
+
* `/auth/verify` + `/auth/profile` checks, logout, and the redirect to
|
|
31
|
+
* auth-front's login page. Each app previously hand-rolled this
|
|
32
|
+
* (`account-front/services/authService.ts`, `vision-front/contexts/AuthContext.tsx`)
|
|
33
|
+
* with near-identical but subtly diverging logic; wrap the result in
|
|
34
|
+
* `createAuthContext` for a React Context/hook, or use it directly for a
|
|
35
|
+
* plain-object service.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createAuthService({ authServiceUrl, authFrontUrl }: AuthServiceOptions): {
|
|
38
|
+
getToken: () => string | null;
|
|
39
|
+
checkAuth: () => Promise<AuthCheckResult>;
|
|
40
|
+
getCurrentUser: () => Promise<AuthUser | null>;
|
|
41
|
+
getProfile: () => Promise<AuthUser | null>;
|
|
42
|
+
isAuthenticated: () => Promise<boolean>;
|
|
43
|
+
logout: () => Promise<boolean>;
|
|
44
|
+
redirectToLogin: (returnUrl?: string) => void;
|
|
45
|
+
};
|
|
46
|
+
export type AuthService = ReturnType<typeof createAuthService>;
|
|
47
|
+
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../src/auth/authService.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,YAAY,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE,kBAAkB;oBAM/D,MAAM,GAAG,IAAI;qBAIN,OAAO,CAAC,eAAe,CAAC;0BAsBnB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;sBAK5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;2BAUnB,OAAO,CAAC,OAAO,CAAC;kBAKzB,OAAO,CAAC,OAAO,CAAC;kCAaJ,MAAM,KAAG,IAAI;EAMnD;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createApiClient } from '../apiClient';
|
|
2
|
+
/**
|
|
3
|
+
* Session-management logic shared by every Visin frontend: token storage,
|
|
4
|
+
* `/auth/verify` + `/auth/profile` checks, logout, and the redirect to
|
|
5
|
+
* auth-front's login page. Each app previously hand-rolled this
|
|
6
|
+
* (`account-front/services/authService.ts`, `vision-front/contexts/AuthContext.tsx`)
|
|
7
|
+
* with near-identical but subtly diverging logic; wrap the result in
|
|
8
|
+
* `createAuthContext` for a React Context/hook, or use it directly for a
|
|
9
|
+
* plain-object service.
|
|
10
|
+
*/
|
|
11
|
+
export function createAuthService({ authServiceUrl, authFrontUrl }) {
|
|
12
|
+
const client = createApiClient({
|
|
13
|
+
baseUrl: authServiceUrl,
|
|
14
|
+
getToken: () => localStorage.getItem('authToken')
|
|
15
|
+
});
|
|
16
|
+
function getToken() {
|
|
17
|
+
return localStorage.getItem('authToken');
|
|
18
|
+
}
|
|
19
|
+
async function checkAuth() {
|
|
20
|
+
try {
|
|
21
|
+
const data = await client.get('/auth/verify', { credentials: 'include', skipAuthRedirect: true });
|
|
22
|
+
if (data.success) {
|
|
23
|
+
if (data.token) {
|
|
24
|
+
localStorage.setItem('authToken', data.token);
|
|
25
|
+
}
|
|
26
|
+
return { authenticated: data.authenticated, user: data.user ?? null };
|
|
27
|
+
}
|
|
28
|
+
localStorage.removeItem('authToken');
|
|
29
|
+
return { authenticated: false, user: null };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Auth check failed:', error);
|
|
33
|
+
localStorage.removeItem('authToken');
|
|
34
|
+
return { authenticated: false, user: null };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function getCurrentUser() {
|
|
38
|
+
const result = await checkAuth();
|
|
39
|
+
return result.user;
|
|
40
|
+
}
|
|
41
|
+
async function getProfile() {
|
|
42
|
+
try {
|
|
43
|
+
const data = await client.get('/auth/profile', { credentials: 'include' });
|
|
44
|
+
return data.success ? (data.user ?? null) : null;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Get profile failed:', error);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function isAuthenticated() {
|
|
52
|
+
const result = await checkAuth();
|
|
53
|
+
return result.authenticated;
|
|
54
|
+
}
|
|
55
|
+
async function logout() {
|
|
56
|
+
try {
|
|
57
|
+
const data = await client.post('/auth/logout', undefined, { credentials: 'include' });
|
|
58
|
+
if (data.success) {
|
|
59
|
+
localStorage.removeItem('authToken');
|
|
60
|
+
}
|
|
61
|
+
return data.success;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('Logout failed:', error);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function redirectToLogin(returnUrl) {
|
|
69
|
+
const currentUrl = returnUrl || window.location.href;
|
|
70
|
+
window.location.href = `${authFrontUrl()}?redirect_uri=${encodeURIComponent(currentUrl)}`;
|
|
71
|
+
}
|
|
72
|
+
return { getToken, checkAuth, getCurrentUser, getProfile, isAuthenticated, logout, redirectToLogin };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=authService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authService.js","sourceRoot":"","sources":["../../src/auth/authService.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the ErrorPage component
|
|
4
|
+
*/
|
|
5
|
+
export interface ErrorPageProps {
|
|
6
|
+
/** The main error title to display */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** The error message content (can be text or React elements) */
|
|
9
|
+
message?: string | ReactNode;
|
|
10
|
+
/** Custom icon to display (defaults to error icon) */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Whether to show the retry button */
|
|
13
|
+
showRetry?: boolean;
|
|
14
|
+
/** Callback function when retry button is clicked */
|
|
15
|
+
onRetry?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ErrorPage({ title, message, icon, showRetry, onRetry }: ErrorPageProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=ErrorPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorPage.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorPage/ErrorPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,sDAAsD;IACtD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,EACxB,KAA6B,EAC7B,OAMC,EACD,IAAsE,EACtE,SAAgB,EAChB,OAAwC,EACzC,EAAE,cAAc,+BAkChB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography, Button } from '@mui/material';
|
|
3
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutlined';
|
|
4
|
+
export function ErrorPage({ title = 'Configuration Error', message = (_jsxs(_Fragment, { children: ["Failed to load application configuration.", _jsx("br", {}), "Please check your network connection and try again."] })), icon = _jsx(ErrorOutlineIcon, { sx: { fontSize: 80, color: 'error.main' } }), showRetry = true, onRetry = () => window.location.reload() }) {
|
|
5
|
+
return (_jsxs(Box, { sx: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexDirection: 'column',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
height: '100vh',
|
|
11
|
+
gap: 2
|
|
12
|
+
}, children: [icon, _jsx(Typography, { variant: "h4", color: "error", gutterBottom: true, sx: {
|
|
13
|
+
fontWeight: 600
|
|
14
|
+
}, children: title }), _jsx(Typography, { variant: "body1", sx: {
|
|
15
|
+
color: "text.secondary",
|
|
16
|
+
textAlign: "center",
|
|
17
|
+
mb: showRetry ? 2 : 0
|
|
18
|
+
}, children: message }), showRetry && (_jsx(Button, { variant: "contained", color: "primary", onClick: onRetry, children: "Retry" }))] }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ErrorPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorPage.js","sourceRoot":"","sources":["../../../src/components/ErrorPage/ErrorPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AAkBjE,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,GAAG,qBAAqB,EAC7B,OAAO,GAAG,CACR,2EAEE,cAAM,2DAEL,CACJ,EACD,IAAI,GAAG,KAAC,gBAAgB,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,GAAI,EACtE,SAAS,GAAG,IAAI,EAChB,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EACzB;IACf,OAAO,CACL,MAAC,GAAG,IACF,EAAE,EAAE;YACF,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,MAAM,EAAE,OAAO;YACf,GAAG,EAAE,CAAC;SACP,aAEA,IAAI,EACL,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,EAAC,YAAY,QAAC,EAAE,EAAE;oBACtD,UAAU,EAAE,GAAG;iBAChB,YACE,KAAK,GACK,EACb,KAAC,UAAU,IACT,OAAO,EAAC,OAAO,EACf,EAAE,EAAE;oBACF,KAAK,EAAE,gBAAgB;oBACvB,SAAS,EAAE,QAAQ;oBACnB,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACtB,YACA,OAAO,GACG,EACZ,SAAS,IAAI,CACZ,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,SAAS,EAAC,OAAO,EAAE,OAAO,sBAEnD,CACV,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ErrorPage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ErrorPage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the Loader component
|
|
3
|
+
*/
|
|
4
|
+
export interface LoaderProps {
|
|
5
|
+
/** The loading message to display below the spinner */
|
|
6
|
+
message?: string;
|
|
7
|
+
/** Size of the loading spinner in pixels */
|
|
8
|
+
size?: number;
|
|
9
|
+
/** Whether to take full viewport height or auto height */
|
|
10
|
+
fullHeight?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function Loader({ message, size, fullHeight }: LoaderProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=Loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loader.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/Loader.tsx"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,MAAM,CAAC,EAAE,OAAsB,EAAE,IAAS,EAAE,UAAiB,EAAE,EAAE,WAAW,+BAqB3F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, CircularProgress, Typography } from '@mui/material';
|
|
3
|
+
export function Loader({ message = 'Loading...', size = 48, fullHeight = true }) {
|
|
4
|
+
return (_jsxs(Box, { sx: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
height: fullHeight ? '100vh' : 'auto',
|
|
10
|
+
gap: 2,
|
|
11
|
+
py: fullHeight ? 0 : 8
|
|
12
|
+
}, children: [_jsx(CircularProgress, { size: size }), _jsx(Typography, { variant: "body1", sx: {
|
|
13
|
+
color: "text.secondary"
|
|
14
|
+
}, children: message })] }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=Loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loader.js","sourceRoot":"","sources":["../../../src/components/Loader/Loader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAclE,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,EAAE,IAAI,GAAG,EAAE,EAAE,UAAU,GAAG,IAAI,EAAe;IAC1F,OAAO,CACL,MAAC,GAAG,IACF,EAAE,EAAE;YACF,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;YACrC,GAAG,EAAE,CAAC;YACN,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACvB,aAED,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,GAAI,EAChC,KAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,EAAE,EAAE;oBAC9B,KAAK,EAAE,gBAAgB;iBACxB,YACE,OAAO,GACG,IACT,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Loader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export interface CreateConfigProviderOptions<T> {
|
|
3
|
+
/** Builds a config object from build-time env vars. Used in dev, during HMR fallback, and (with onFetchError: 'fallback') if /config.json fails to load in production. */
|
|
4
|
+
createDevConfig: () => T;
|
|
5
|
+
/** Whether the app is running in dev mode (pass `import.meta.env.DEV` from the calling app so Vite can statically replace it). */
|
|
6
|
+
isDev: boolean;
|
|
7
|
+
/** 'error-page' (default) renders ErrorPage if /config.json fails to load. 'fallback' falls back to createDevConfig() so the app can still render with build-time env vars. */
|
|
8
|
+
onFetchError?: 'error-page' | 'fallback';
|
|
9
|
+
/** Wraps the resolved config's children, e.g. with CssBaseline/ThemeProvider. Defaults to rendering children unwrapped. */
|
|
10
|
+
renderChildren?: (children: ReactNode) => ReactNode;
|
|
11
|
+
/** Rendered while config is loading. Defaults to the shared Loader. */
|
|
12
|
+
loadingFallback?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function createConfigProvider<T extends Record<string, any>>(options: CreateConfigProviderOptions<T>): {
|
|
15
|
+
ConfigProvider: ({ children }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}) => React.JSX.Element;
|
|
18
|
+
ConfigContext: React.Context<T>;
|
|
19
|
+
useConfig: () => T;
|
|
20
|
+
getGlobalConfig: () => T;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=createConfigProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createConfigProvider.d.ts","sourceRoot":"","sources":["../../src/config/createConfigProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAkD,SAAS,EAAE,MAAM,OAAO,CAAC;AAIzF,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C,0KAA0K;IAC1K,eAAe,EAAE,MAAM,CAAC,CAAC;IACzB,kIAAkI;IAClI,KAAK,EAAE,OAAO,CAAC;IACf,+KAA+K;IAC/K,YAAY,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACzC,2HAA2H;IAC3H,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,CAAC;IACpD,uEAAuE;IACvE,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC;mCA8BnE;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE;;qBAJvC,CAAC;2BAbK,CAAC;EAsE9B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { Loader } from '../components/Loader';
|
|
4
|
+
import { ErrorPage } from '../components/ErrorPage';
|
|
5
|
+
export function createConfigProvider(options) {
|
|
6
|
+
const { createDevConfig, isDev, onFetchError = 'error-page', renderChildren = (children) => children, loadingFallback = _jsx(Loader, {}) } = options;
|
|
7
|
+
let globalConfig = null;
|
|
8
|
+
const ConfigContext = createContext({});
|
|
9
|
+
function getGlobalConfig() {
|
|
10
|
+
if (!globalConfig) {
|
|
11
|
+
if (isDev) {
|
|
12
|
+
// During HMR in development, config might be temporarily unavailable
|
|
13
|
+
const fallbackConfig = createDevConfig();
|
|
14
|
+
console.warn('Using fallback configuration during HMR:', fallbackConfig);
|
|
15
|
+
return fallbackConfig;
|
|
16
|
+
}
|
|
17
|
+
throw new Error('Configuration not initialized. Make sure ConfigProvider is mounted.');
|
|
18
|
+
}
|
|
19
|
+
return globalConfig;
|
|
20
|
+
}
|
|
21
|
+
function useConfig() {
|
|
22
|
+
return useContext(ConfigContext);
|
|
23
|
+
}
|
|
24
|
+
function ConfigProvider({ children }) {
|
|
25
|
+
const [config, setConfig] = useState(null);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
// In development, use environment variables directly
|
|
29
|
+
if (isDev) {
|
|
30
|
+
const devConfig = createDevConfig();
|
|
31
|
+
console.log('Using development configuration from environment variables:', devConfig);
|
|
32
|
+
setConfig(devConfig);
|
|
33
|
+
globalConfig = devConfig;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// In production, fetch config.json
|
|
37
|
+
fetch('/config.json')
|
|
38
|
+
.then((res) => {
|
|
39
|
+
if (!res.ok)
|
|
40
|
+
throw new Error('Config fetch failed');
|
|
41
|
+
return res.json();
|
|
42
|
+
})
|
|
43
|
+
.then((loadedConfig) => {
|
|
44
|
+
console.log('Using production configuration from config.json:', loadedConfig);
|
|
45
|
+
setConfig(loadedConfig);
|
|
46
|
+
globalConfig = loadedConfig;
|
|
47
|
+
})
|
|
48
|
+
.catch((err) => {
|
|
49
|
+
console.error('Configuration load error:', err);
|
|
50
|
+
if (onFetchError === 'fallback') {
|
|
51
|
+
const fallback = createDevConfig();
|
|
52
|
+
setConfig(fallback);
|
|
53
|
+
globalConfig = fallback;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
setError(err.message);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}, []);
|
|
60
|
+
if (error) {
|
|
61
|
+
return _jsx(ErrorPage, {});
|
|
62
|
+
}
|
|
63
|
+
if (!config) {
|
|
64
|
+
return _jsx(_Fragment, { children: loadingFallback });
|
|
65
|
+
}
|
|
66
|
+
return (_jsx(ConfigContext.Provider, { value: config, children: renderChildren(children) }));
|
|
67
|
+
}
|
|
68
|
+
return { ConfigProvider, ConfigContext, useConfig, getGlobalConfig };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=createConfigProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createConfigProvider.js","sourceRoot":"","sources":["../../src/config/createConfigProvider.tsx"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export { createApiClient, ApiError } from './apiClient';
|
|
2
2
|
export type { ApiClientOptions, ApiRequestOptions, ApiClient } from './apiClient';
|
|
3
|
+
export { Loader } from './components/Loader';
|
|
4
|
+
export type { LoaderProps } from './components/Loader';
|
|
5
|
+
export { ErrorPage } from './components/ErrorPage';
|
|
6
|
+
export type { ErrorPageProps } from './components/ErrorPage';
|
|
7
|
+
export { createAuthService } from './auth/authService';
|
|
8
|
+
export type { AuthService, AuthServiceOptions, AuthUser, AuthCheckResult } from './auth/authService';
|
|
9
|
+
export { createAuthContext } from './auth/AuthProvider';
|
|
10
|
+
export type { AuthContextValue } from './auth/AuthProvider';
|
|
11
|
+
export { createConfigProvider } from './config/createConfigProvider';
|
|
12
|
+
export type { CreateConfigProviderOptions } from './config/createConfigProvider';
|
|
3
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @visin/frontend-core - Shared frontend auth/API-client logic for Visin frontends
|
|
2
2
|
export { createApiClient, ApiError } from './apiClient';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export { Loader } from './components/Loader';
|
|
4
|
+
export { ErrorPage } from './components/ErrorPage';
|
|
5
|
+
export { createAuthService } from './auth/authService';
|
|
6
|
+
export { createAuthContext } from './auth/AuthProvider';
|
|
7
|
+
export { createConfigProvider } from './config/createConfigProvider';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGxD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visin/frontend-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Shared frontend auth/API-client logic for Visin frontends",
|
|
5
5
|
"author": "Toomas Tahves",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,15 +33,27 @@
|
|
|
33
33
|
"auth",
|
|
34
34
|
"api-client"
|
|
35
35
|
],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@mui/icons-material": "^9.2.0",
|
|
38
|
+
"@mui/material": "^9.2.0",
|
|
39
|
+
"react": "^19.2.7"
|
|
40
|
+
},
|
|
36
41
|
"devDependencies": {
|
|
37
42
|
"@eslint/js": "^10.0.1",
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
43
|
+
"@mui/icons-material": "^9.2.0",
|
|
44
|
+
"@mui/material": "^9.2.0",
|
|
45
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
46
|
+
"@testing-library/react": "^16.3.0",
|
|
47
|
+
"@types/node": "^26.1.0",
|
|
48
|
+
"@types/react": "^19.2.17",
|
|
49
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
40
50
|
"eslint": "^10.6.0",
|
|
41
|
-
"jsdom": "^
|
|
51
|
+
"jsdom": "^29.1.1",
|
|
52
|
+
"react": "^19.2.7",
|
|
53
|
+
"react-dom": "^19.2.7",
|
|
42
54
|
"standard-version": "^9.5.0",
|
|
43
55
|
"typescript": "^6.0.3",
|
|
44
56
|
"typescript-eslint": "^8.62.1",
|
|
45
|
-
"vitest": "^
|
|
57
|
+
"vitest": "^4.1.9"
|
|
46
58
|
}
|
|
47
59
|
}
|