From ac69a454d7297a1e1154997e74ac342d16f17ec9 Mon Sep 17 00:00:00 2001 From: cmoniz-ocean <159864719+cmoniz-ocean@users.noreply.github.com> Date: Thu, 16 May 2024 20:56:41 -1000 Subject: [PATCH 1/2] Update is-browser.ts Fixes electron 12.2.3, which doesn't have navigator defined https://github.com/mqttjs/MQTT.js/commit/6a03d29b86dc4fe8eae04eaf0f9fc661f1c3d1ea#commitcomment-142114121 --- src/lib/is-browser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/is-browser.ts b/src/lib/is-browser.ts index 7961aa20d..6dabe6ebe 100644 --- a/src/lib/is-browser.ts +++ b/src/lib/is-browser.ts @@ -4,6 +4,7 @@ const isStandardBrowserEnv = () => { // Is the process an electron application // check if we are in electron `renderer` const electronRenderCheck = + (typeof navigator !== "undefined") && navigator?.userAgent?.toLowerCase().indexOf(' electron/') > -1 if (electronRenderCheck && process?.versions) { const electronMainCheck = Object.prototype.hasOwnProperty.call( From 611f5acc60a4de130f679bec183309727d7c2fc3 Mon Sep 17 00:00:00 2001 From: Cody Moniz Date: Thu, 16 May 2024 21:24:34 -1000 Subject: [PATCH 2/2] Making recommended changes https://github.com/mqttjs/MQTT.js/pull/1868#pullrequestreview-2062507553 --- src/lib/is-browser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/is-browser.ts b/src/lib/is-browser.ts index 6dabe6ebe..cdf926a3e 100644 --- a/src/lib/is-browser.ts +++ b/src/lib/is-browser.ts @@ -4,8 +4,8 @@ const isStandardBrowserEnv = () => { // Is the process an electron application // check if we are in electron `renderer` const electronRenderCheck = - (typeof navigator !== "undefined") && - navigator?.userAgent?.toLowerCase().indexOf(' electron/') > -1 + typeof navigator !== 'undefined' && + navigator.userAgent?.toLowerCase().indexOf(' electron/') > -1 if (electronRenderCheck && process?.versions) { const electronMainCheck = Object.prototype.hasOwnProperty.call( process.versions,