From 6c5fb36c36d194f8ca990eb68556069f970159ec Mon Sep 17 00:00:00 2001 From: David Fiala Date: Thu, 19 Oct 2023 09:52:29 -0700 Subject: [PATCH 1/2] proper isNode detection for node v21.0.0 --- src/common/Platform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/Platform.ts b/src/common/Platform.ts index 41d8552e..2f329199 100644 --- a/src/common/Platform.ts +++ b/src/common/Platform.ts @@ -13,7 +13,7 @@ interface INavigator { // we want this module to live in common. declare const navigator: INavigator; -export const isNode = (typeof navigator === 'undefined') ? true : false; +export const isNode = (typeof process !== 'undefined') ? true : false; const userAgent = (isNode) ? 'node' : navigator.userAgent; const platform = (isNode) ? 'node' : navigator.platform; From 0d0166b4bcae1db109baf3691d4472ea16171589 Mon Sep 17 00:00:00 2001 From: David Fiala Date: Thu, 19 Oct 2023 11:19:27 -0700 Subject: [PATCH 2/2] provide a declaration for 'process' needed for nodejs detect We provide no further type information as it will not be used except for a presence check for nodejs detection. --- src/common/Platform.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/Platform.ts b/src/common/Platform.ts index 2f329199..1007fc0a 100644 --- a/src/common/Platform.ts +++ b/src/common/Platform.ts @@ -12,6 +12,7 @@ interface INavigator { // We're declaring a navigator global here as we expect it in all runtimes (node and browser), but // we want this module to live in common. declare const navigator: INavigator; +declare const process: unknown; export const isNode = (typeof process !== 'undefined') ? true : false; const userAgent = (isNode) ? 'node' : navigator.userAgent;