@digilogiclabs/saas-factory-ui 0.26.1 → 0.27.0
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/index.js +88 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -48
- package/dist/index.mjs.map +1 -1
- package/dist/native/index.js +1821 -481
- package/dist/native/index.js.map +1 -1
- package/dist/native/index.mjs +1831 -451
- package/dist/native/index.mjs.map +1 -1
- package/package.json +14 -2
package/dist/index.js
CHANGED
|
@@ -23418,75 +23418,115 @@ function useMounted() {
|
|
|
23418
23418
|
|
|
23419
23419
|
// src/hooks/network/use-network-info.ts
|
|
23420
23420
|
var import_react44 = require("react");
|
|
23421
|
+
var isReactNative = typeof navigator === "undefined";
|
|
23421
23422
|
function useNetworkInfo() {
|
|
23422
23423
|
const [networkInfo, setNetworkInfo] = (0, import_react44.useState)(() => ({
|
|
23423
|
-
isOnline: typeof navigator !== "undefined" ? navigator.onLine : true,
|
|
23424
|
+
isOnline: isReactNative ? true : typeof navigator !== "undefined" ? navigator.onLine : true,
|
|
23424
23425
|
isSlowConnection: false,
|
|
23425
23426
|
connectionType: "unknown",
|
|
23426
23427
|
effectiveType: "unknown"
|
|
23427
23428
|
}));
|
|
23428
23429
|
(0, import_react44.useEffect)(() => {
|
|
23429
|
-
if (
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23430
|
+
if (isReactNative) {
|
|
23431
|
+
let NetInfo;
|
|
23432
|
+
try {
|
|
23433
|
+
NetInfo = require("@react-native-netinfo/netinfo");
|
|
23434
|
+
} catch (error) {
|
|
23435
|
+
console.warn("NetInfo not available, install @react-native-netinfo/netinfo for network detection in React Native");
|
|
23436
|
+
return;
|
|
23437
|
+
}
|
|
23438
|
+
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
23439
|
+
setNetworkInfo({
|
|
23440
|
+
isOnline: state.isConnected ?? false,
|
|
23441
|
+
isSlowConnection: state.details?.effectiveType === "slow-2g" || state.details?.effectiveType === "2g",
|
|
23442
|
+
connectionType: state.type === "wifi" ? "wifi" : state.type === "cellular" ? "cellular" : "unknown",
|
|
23443
|
+
effectiveType: state.details?.effectiveType || "unknown"
|
|
23444
|
+
});
|
|
23437
23445
|
});
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
|
|
23444
|
-
|
|
23445
|
-
|
|
23446
|
-
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23446
|
+
return unsubscribe;
|
|
23447
|
+
} else {
|
|
23448
|
+
if (typeof navigator === "undefined") return;
|
|
23449
|
+
const updateNetworkInfo = () => {
|
|
23450
|
+
const connection2 = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
|
|
23451
|
+
setNetworkInfo({
|
|
23452
|
+
isOnline: navigator.onLine,
|
|
23453
|
+
isSlowConnection: connection2 ? connection2.effectiveType === "slow-2g" || connection2.effectiveType === "2g" : false,
|
|
23454
|
+
connectionType: connection2 ? connection2.type || "unknown" : "unknown",
|
|
23455
|
+
effectiveType: connection2 ? connection2.effectiveType || "unknown" : "unknown"
|
|
23456
|
+
});
|
|
23457
|
+
};
|
|
23458
|
+
updateNetworkInfo();
|
|
23459
|
+
const handleOnline = () => updateNetworkInfo();
|
|
23460
|
+
const handleOffline = () => updateNetworkInfo();
|
|
23461
|
+
const handleConnectionChange = () => updateNetworkInfo();
|
|
23462
|
+
window.addEventListener("online", handleOnline);
|
|
23463
|
+
window.addEventListener("offline", handleOffline);
|
|
23464
|
+
const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
|
|
23452
23465
|
if (connection) {
|
|
23453
|
-
connection.
|
|
23466
|
+
connection.addEventListener("change", handleConnectionChange);
|
|
23454
23467
|
}
|
|
23455
|
-
|
|
23468
|
+
return () => {
|
|
23469
|
+
window.removeEventListener("online", handleOnline);
|
|
23470
|
+
window.removeEventListener("offline", handleOffline);
|
|
23471
|
+
if (connection) {
|
|
23472
|
+
connection.removeEventListener("change", handleConnectionChange);
|
|
23473
|
+
}
|
|
23474
|
+
};
|
|
23475
|
+
}
|
|
23456
23476
|
}, []);
|
|
23457
23477
|
return networkInfo;
|
|
23458
23478
|
}
|
|
23459
23479
|
|
|
23460
23480
|
// src/hooks/network/use-offline-state.ts
|
|
23461
23481
|
var import_react45 = require("react");
|
|
23482
|
+
var isReactNative2 = typeof navigator === "undefined";
|
|
23462
23483
|
function useOfflineState() {
|
|
23463
23484
|
const [state, setState] = (0, import_react45.useState)(() => ({
|
|
23464
|
-
isOffline: typeof navigator !== "undefined" ? !navigator.onLine : false,
|
|
23465
|
-
isOnline: typeof navigator !== "undefined" ? navigator.onLine : true,
|
|
23485
|
+
isOffline: isReactNative2 ? false : typeof navigator !== "undefined" ? !navigator.onLine : false,
|
|
23486
|
+
isOnline: isReactNative2 ? true : typeof navigator !== "undefined" ? navigator.onLine : true,
|
|
23466
23487
|
wasOffline: false
|
|
23467
23488
|
}));
|
|
23468
23489
|
(0, import_react45.useEffect)(() => {
|
|
23469
|
-
if (
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
23481
|
-
|
|
23482
|
-
|
|
23483
|
-
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23489
|
-
|
|
23490
|
+
if (isReactNative2) {
|
|
23491
|
+
let NetInfo;
|
|
23492
|
+
try {
|
|
23493
|
+
NetInfo = require("@react-native-netinfo/netinfo");
|
|
23494
|
+
} catch (error) {
|
|
23495
|
+
console.warn("NetInfo not available, install @react-native-netinfo/netinfo for offline detection in React Native");
|
|
23496
|
+
return;
|
|
23497
|
+
}
|
|
23498
|
+
const unsubscribe = NetInfo.addEventListener((netState) => {
|
|
23499
|
+
const isConnected = netState.isConnected ?? false;
|
|
23500
|
+
setState((prev) => ({
|
|
23501
|
+
isOffline: !isConnected,
|
|
23502
|
+
isOnline: isConnected,
|
|
23503
|
+
wasOffline: prev.isOffline || !isConnected
|
|
23504
|
+
}));
|
|
23505
|
+
});
|
|
23506
|
+
return unsubscribe;
|
|
23507
|
+
} else {
|
|
23508
|
+
if (typeof navigator === "undefined") return;
|
|
23509
|
+
const handleOnline = () => {
|
|
23510
|
+
setState((prev) => ({
|
|
23511
|
+
isOffline: false,
|
|
23512
|
+
isOnline: true,
|
|
23513
|
+
wasOffline: prev.isOffline
|
|
23514
|
+
}));
|
|
23515
|
+
};
|
|
23516
|
+
const handleOffline = () => {
|
|
23517
|
+
setState((prev) => ({
|
|
23518
|
+
isOffline: true,
|
|
23519
|
+
isOnline: false,
|
|
23520
|
+
wasOffline: prev.wasOffline
|
|
23521
|
+
}));
|
|
23522
|
+
};
|
|
23523
|
+
window.addEventListener("online", handleOnline);
|
|
23524
|
+
window.addEventListener("offline", handleOffline);
|
|
23525
|
+
return () => {
|
|
23526
|
+
window.removeEventListener("online", handleOnline);
|
|
23527
|
+
window.removeEventListener("offline", handleOffline);
|
|
23528
|
+
};
|
|
23529
|
+
}
|
|
23490
23530
|
}, []);
|
|
23491
23531
|
return state;
|
|
23492
23532
|
}
|