@tap-payments/os-micro-frontend-shared 0.1.407 → 0.1.409-hotfix.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/components/AnimatedSpinnerIcon/style.d.ts +0 -1
- package/build/components/Chip/style.d.ts +0 -1
- package/build/components/CountBadge/style.d.ts +0 -1
- package/build/components/Dialog/style.d.ts +0 -1
- package/build/components/FlippingCard/style.d.ts +0 -1
- package/build/components/ImageWrapper/ImageWrapper.d.ts +0 -1
- package/build/components/JSONViewer/style.d.ts +0 -1
- package/build/components/LeftPeekRightExpandingChip/style.d.ts +0 -1
- package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -1
- package/build/components/SearchButton/styles.d.ts +0 -1
- package/build/components/StatusIcons/AuthIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +0 -1
- package/build/components/StatusIcons/SourceIcons/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AgreementCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DueDateCell/DueDateCell.js +4 -4
- package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IDButton/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/PayoutReportCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/style.d.ts +0 -1
- package/build/components/TableReports/components/DownloadButton/style.d.ts +0 -1
- package/build/components/TableReports/style.d.ts +0 -1
- package/build/components/VirtualTables/components/style.d.ts +0 -1
- package/build/constants/server.js +3 -4
- package/build/hooks/index.d.ts +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/useNetworkState.d.ts +12 -0
- package/build/hooks/useNetworkState.js +112 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -0
- package/build/types/window.d.ts +4 -0
- package/build/types/window.js +1 -0
- package/package.json +1 -1
- package/build/hooks/useCheckInternetConnection.d.ts +0 -1
- package/build/hooks/useCheckInternetConnection.js +0 -17
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
import { GetSourceAnimationFunction } from './type';
|
|
4
3
|
export declare const ChipStyled: import("@emotion/styled").StyledComponent<import("react").RefAttributes<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
4
|
variant?: import("./type").ChipVariant | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
import { TableMode } from '../../../../types/index.js';
|
|
4
3
|
export declare const ActionCellContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
5
4
|
tableMode?: TableMode | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const AgreementCellContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledAgreementCardIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const CardContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledAppsCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const AppsStatusContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const AuthIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
4
3
|
export declare const AuthCellContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -19,10 +19,10 @@ function DueDateCell(_a) {
|
|
|
19
19
|
var { dueDate, expiryDate } = _a, props = __rest(_a, ["dueDate", "expiryDate"]);
|
|
20
20
|
const dueMeta = useMemo(() => ({ label: formatDate(dayjs(dueDate).valueOf()), tooltip: 'Due Date' }), [dueDate]);
|
|
21
21
|
const expiryMeta = useMemo(() => ({ label: formatDate(dayjs(expiryDate).valueOf()), tooltip: 'Expiry Date' }), [expiryDate]);
|
|
22
|
-
const
|
|
23
|
-
const centerIcon = useMemo(() => (
|
|
24
|
-
const rightIcons = useMemo(() => (
|
|
25
|
-
if (!
|
|
22
|
+
const renderChipContent = (meta) => (_jsx(Tooltip, Object.assign({ title: meta.tooltip }, { children: _jsx(TextLabel, { children: meta.label }) })));
|
|
23
|
+
const centerIcon = useMemo(() => (dueDate ? renderChipContent(dueMeta) : expiryDate ? renderChipContent(expiryMeta) : null), [dueMeta, expiryMeta, dueDate, expiryDate]);
|
|
24
|
+
const rightIcons = useMemo(() => (expiryDate && dueDate ? [renderChipContent(expiryMeta)] : []), [dueMeta, expiryMeta, dueDate, expiryDate]);
|
|
25
|
+
if (!dueDate && !expiryDate)
|
|
26
26
|
return null;
|
|
27
27
|
return (_jsx(TableCell, Object.assign({}, props, { sx: { position: 'relative', overflow: 'visible' } }, { children: _jsx(RightLeftExpandingCenterChip, { sx: { justifyContent: 'flex-start' }, centerIcon: centerIcon, rightIcons: rightIcons }) })));
|
|
28
28
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledDownloadFileImageWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
4
3
|
isTextShown?: boolean | undefined;
|
|
5
4
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const SalesChannelsContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const GeographyBox: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
4
3
|
variant?: "Global" | "Regional" | "Local" | undefined;
|
|
5
4
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
export const BASE_URL = (_a = (isSAOCI ? 'https://mw-os.tap.com.sa' : import.meta.env.VITE_MW_BASE_URL)) !== null && _a !== void 0 ? _a : import.meta.env.VITE_BASE_URL;
|
|
1
|
+
var _a, _b;
|
|
2
|
+
const runtimeConfig = (_a = window.__GLOBAL_CONFIG__) !== null && _a !== void 0 ? _a : {};
|
|
3
|
+
export const BASE_URL = (_b = runtimeConfig.MW_BASE_URL) !== null && _b !== void 0 ? _b : import.meta.env.VITE_BASE_URL;
|
|
5
4
|
export const API_URL = `${BASE_URL}/api`;
|
|
6
5
|
export const ENV = import.meta.env.VITE_ENV;
|
|
7
6
|
export const TEST_SECRET_KEY = import.meta.env.VITE_TEST_FIXED_SK;
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './useMouseState';
|
|
|
3
3
|
export * from './useDelayToSetValue';
|
|
4
4
|
export * from './useActionMenu';
|
|
5
5
|
export * from './useBadgesCount';
|
|
6
|
-
export * from './useCheckInternetConnection';
|
|
7
6
|
export * from './useCheckUserLoggedIn';
|
|
8
7
|
export * from './useIsParameterSelected';
|
|
9
8
|
export * from './useStickyHeaderShadow';
|
|
@@ -15,3 +14,4 @@ export * from './useAppEventListener';
|
|
|
15
14
|
export * from './useSelectedMerchantDetails';
|
|
16
15
|
export * from './useToast';
|
|
17
16
|
export * from './useScrolledTo';
|
|
17
|
+
export * from './useNetworkState';
|
package/build/hooks/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export * from './useMouseState';
|
|
|
3
3
|
export * from './useDelayToSetValue';
|
|
4
4
|
export * from './useActionMenu';
|
|
5
5
|
export * from './useBadgesCount';
|
|
6
|
-
export * from './useCheckInternetConnection';
|
|
7
6
|
export * from './useCheckUserLoggedIn';
|
|
8
7
|
export * from './useIsParameterSelected';
|
|
9
8
|
export * from './useStickyHeaderShadow';
|
|
@@ -15,3 +14,4 @@ export * from './useAppEventListener';
|
|
|
15
14
|
export * from './useSelectedMerchantDetails';
|
|
16
15
|
export * from './useToast';
|
|
17
16
|
export * from './useScrolledTo';
|
|
17
|
+
export * from './useNetworkState';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UseNetworkStateOptions {
|
|
2
|
+
checkUrl?: string;
|
|
3
|
+
checkIntervalMs?: number;
|
|
4
|
+
debounceMs?: number;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface OnlineState {
|
|
8
|
+
isOnline: boolean;
|
|
9
|
+
isChecking: boolean;
|
|
10
|
+
error: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const useNetworkState: (options?: UseNetworkStateOptions) => OnlineState;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
+
export const useNetworkState = (options = {}) => {
|
|
12
|
+
const { checkUrl = '/status', checkIntervalMs = 30000, // poll /status only while offline
|
|
13
|
+
debounceMs = 800, timeoutMs = 5000, } = options;
|
|
14
|
+
const isBrowser = typeof window !== 'undefined' && typeof navigator !== 'undefined';
|
|
15
|
+
const [isOnline, setIsOnline] = useState(isBrowser ? navigator.onLine : true);
|
|
16
|
+
const [isChecking, setIsChecking] = useState(false);
|
|
17
|
+
const [error, setError] = useState(null);
|
|
18
|
+
const debounceTimer = useRef(null);
|
|
19
|
+
const intervalId = useRef(null);
|
|
20
|
+
const applyStatusWithDebounce = useCallback((nextOnline) => {
|
|
21
|
+
if (debounceTimer.current !== null) {
|
|
22
|
+
window.clearTimeout(debounceTimer.current);
|
|
23
|
+
}
|
|
24
|
+
debounceTimer.current = window.setTimeout(() => {
|
|
25
|
+
setIsOnline(nextOnline);
|
|
26
|
+
debounceTimer.current = null;
|
|
27
|
+
}, debounceMs);
|
|
28
|
+
}, [debounceMs]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!isBrowser) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let abortController = null;
|
|
34
|
+
const clearPolling = () => {
|
|
35
|
+
if (intervalId.current !== null) {
|
|
36
|
+
window.clearInterval(intervalId.current);
|
|
37
|
+
intervalId.current = null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const checkConnectivity = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
setIsChecking(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
44
|
+
abortController = new AbortController();
|
|
45
|
+
try {
|
|
46
|
+
const timeout = window.setTimeout(() => {
|
|
47
|
+
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
48
|
+
}, timeoutMs);
|
|
49
|
+
const res = yield fetch(checkUrl, {
|
|
50
|
+
method: 'GET',
|
|
51
|
+
cache: 'no-store',
|
|
52
|
+
signal: abortController.signal,
|
|
53
|
+
});
|
|
54
|
+
window.clearTimeout(timeout);
|
|
55
|
+
const ok = res.ok;
|
|
56
|
+
applyStatusWithDebounce(ok);
|
|
57
|
+
if (ok)
|
|
58
|
+
clearPolling();
|
|
59
|
+
else
|
|
60
|
+
setError(`Health check failed with status ${res.status}`);
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
}
|
|
63
|
+
catch (_err) {
|
|
64
|
+
applyStatusWithDebounce(false);
|
|
65
|
+
setError('Unable to reach network');
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
setIsChecking(false);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const handleOnline = () => {
|
|
72
|
+
// Browser says we're online: trust it, no /status request
|
|
73
|
+
clearPolling();
|
|
74
|
+
applyStatusWithDebounce(true);
|
|
75
|
+
};
|
|
76
|
+
const handleOffline = () => {
|
|
77
|
+
// Browser says we're offline: reflect that and poll /status until back
|
|
78
|
+
applyStatusWithDebounce(false);
|
|
79
|
+
clearPolling();
|
|
80
|
+
checkConnectivity();
|
|
81
|
+
intervalId.current = window.setInterval(checkConnectivity, checkIntervalMs);
|
|
82
|
+
};
|
|
83
|
+
window.addEventListener('online', handleOnline);
|
|
84
|
+
window.addEventListener('offline', handleOffline);
|
|
85
|
+
// If initially offline, start polling /status; if online, do not hit /status
|
|
86
|
+
if (!navigator.onLine) {
|
|
87
|
+
checkConnectivity();
|
|
88
|
+
intervalId.current = window.setInterval(checkConnectivity, checkIntervalMs);
|
|
89
|
+
}
|
|
90
|
+
return () => {
|
|
91
|
+
window.removeEventListener('online', handleOnline);
|
|
92
|
+
window.removeEventListener('offline', handleOffline);
|
|
93
|
+
if (debounceTimer.current !== null) {
|
|
94
|
+
window.clearTimeout(debounceTimer.current);
|
|
95
|
+
}
|
|
96
|
+
clearPolling();
|
|
97
|
+
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
98
|
+
};
|
|
99
|
+
}, [isBrowser, checkUrl, checkIntervalMs, debounceMs, timeoutMs, applyStatusWithDebounce]);
|
|
100
|
+
if (!isBrowser) {
|
|
101
|
+
return {
|
|
102
|
+
isOnline: false,
|
|
103
|
+
isChecking: false,
|
|
104
|
+
error: 'Online status is only available in a browser environment.',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
isOnline,
|
|
109
|
+
isChecking,
|
|
110
|
+
error,
|
|
111
|
+
};
|
|
112
|
+
};
|
package/build/types/index.d.ts
CHANGED
package/build/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useCheckInternetConnection: () => boolean;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
export const useCheckInternetConnection = () => {
|
|
3
|
-
const [isOnline, setIsOnline] = useState(navigator.onLine);
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const handleOnlineStatus = () => {
|
|
6
|
-
setIsOnline(navigator.onLine);
|
|
7
|
-
};
|
|
8
|
-
window.addEventListener('online', handleOnlineStatus);
|
|
9
|
-
window.addEventListener('offline', handleOnlineStatus);
|
|
10
|
-
return () => {
|
|
11
|
-
window.removeEventListener('online', handleOnlineStatus);
|
|
12
|
-
window.removeEventListener('offline', handleOnlineStatus);
|
|
13
|
-
};
|
|
14
|
-
}, []);
|
|
15
|
-
const isOffline = !isOnline;
|
|
16
|
-
return isOffline;
|
|
17
|
-
};
|