From 93776d060f373b6477d87ae83d57c4619c7e3216 Mon Sep 17 00:00:00 2001 From: ansbbrooks Date: Fri, 12 Jun 2026 16:06:37 -0500 Subject: [PATCH] chore(js-lib): replace 'beforeunload' by calling lifeCycleUpdate on disconnect/exit call --- js-lib/package.json | 2 +- js-lib/src/trame.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js-lib/package.json b/js-lib/package.json index 801d395..bd61255 100644 --- a/js-lib/package.json +++ b/js-lib/package.json @@ -1,6 +1,6 @@ { "name": "@kitware/trame", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "main": "./dist/trame.umd.js", "unpkg": "./dist/trame.umd.js", diff --git a/js-lib/src/trame.js b/js-lib/src/trame.js index 7dfc355..3bb535e 100644 --- a/js-lib/src/trame.js +++ b/js-lib/src/trame.js @@ -160,9 +160,6 @@ export class Trame { this.client?.getRemote()?.Trame.unsubscribe(wslinkSub), ); this.client?.getRemote()?.Trame?.lifeCycleUpdate("client_connected"); - window.addEventListener("beforeunload", () => - this.client?.getRemote()?.Trame?.lifeCycleUpdate("client_exited"), - ); return this.config; } @@ -172,6 +169,7 @@ export class Trame { */ disconnect() { if (this.isConnected()) { + this.client.getRemote()?.Trame?.lifeCycleUpdate("client_exited"); this.client.disconnect(0); } } @@ -188,6 +186,7 @@ export class Trame { */ exit(timeout = 60) { if (this.isConnected()) { + this.client.getRemote()?.Trame?.lifeCycleUpdate("client_exited"); this.client.disconnect(timeout); } }