@based/client
Advanced tools
Comparing version 6.3.1 to 6.4.0
@@ -9,2 +9,19 @@ import urlLoader from './urlLoader.js'; | ||
if (typeof document !== 'undefined') { | ||
let putToOffline = false; | ||
window.addEventListener('offline', () => { | ||
activityListeners.forEach((fn) => { | ||
putToOffline = true; | ||
fn(false, true); | ||
}); | ||
}); | ||
window.addEventListener('online', () => { | ||
if (putToOffline) { | ||
putToOffline = false; | ||
if (!document.hidden) { | ||
activityListeners.forEach((fn) => { | ||
fn(true, false); | ||
}); | ||
} | ||
} | ||
}); | ||
document.addEventListener('visibilitychange', function () { | ||
@@ -15,3 +32,3 @@ clearTimeout(activeTimer); | ||
activityListeners.forEach((fn) => { | ||
fn(false); | ||
fn(false, false); | ||
}); | ||
@@ -22,3 +39,3 @@ }, 30e3); | ||
activityListeners.forEach((fn) => { | ||
fn(true); | ||
fn(true, false); | ||
}); | ||
@@ -39,5 +56,11 @@ } | ||
let isActive = true; | ||
activityListeners.set(connection, (active) => { | ||
activityListeners.set(connection, (active, isOffline) => { | ||
if (!connection.disconnected) { | ||
if (!active && isActive) { | ||
if (!active && isOffline) { | ||
isActive = false; | ||
client.onClose(); | ||
ws.close(); | ||
// add online listener as well | ||
} | ||
else if (!active && isActive) { | ||
if (client.functionResponseListeners.size || | ||
@@ -49,3 +72,3 @@ isStreaming.streaming) { | ||
activityListeners.forEach((fn) => { | ||
fn(false); | ||
fn(false, false); | ||
}); | ||
@@ -52,0 +75,0 @@ }, 10e3); |
{ | ||
"name": "@based/client", | ||
"version": "6.3.1", | ||
"version": "6.4.0", | ||
"license": "MIT", | ||
@@ -9,3 +9,5 @@ "scripts": { | ||
"clean": "rimraf {.turbo,dist,node_modules}", | ||
"test": "npx ava" | ||
"test": "npx ava", | ||
"browser": "npx vite ./test/browser", | ||
"browser-server": "node ./test/browser/server.js" | ||
}, | ||
@@ -46,5 +48,4 @@ "type": "module", | ||
"devDependencies": { | ||
"vite": "^5.2.8", | ||
"get-port": "7.0.0", | ||
"@aws-sdk/lib-storage": "^3.304.0", | ||
"@aws-sdk/client-s3": "^3.304.0", | ||
"@based/functions": "^3.0.2", | ||
@@ -51,0 +52,0 @@ "cross-fetch": "4.0.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202763
7
3239