From 34f0a6abec44e93da7fcc65fa6cdfead33ad05f5 Mon Sep 17 00:00:00 2001 From: sadaf Date: Sun, 25 Feb 2024 04:03:18 +0530 Subject: [PATCH 1/2] fix: fixing spelling mistake in index.ts --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8d2c5d4..13fe5dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,7 @@ interface Window { NL_PATH: string; /** Returns true if extensions are enabled */ NL_EXTENABLED: boolean; - /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Uknown */ + /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Unknown */ NL_OS: string; /** CPU architecture: x64, arm, itanium, ia32, or unknown */ NL_ARCH: string; From e6f3a18efdc962126e8e835cf173f656c1ccbbfa Mon Sep 17 00:00:00 2001 From: sadaf Date: Sun, 25 Feb 2024 04:11:20 +0530 Subject: [PATCH 2/2] feat: using enums instead of string for constants --- src/enums.ts | 22 ++++++++++++++++++++++ src/index.ts | 8 +++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/enums.ts diff --git a/src/enums.ts b/src/enums.ts new file mode 100644 index 0000000..252911b --- /dev/null +++ b/src/enums.ts @@ -0,0 +1,22 @@ +export enum MODE { + Window, + Browser, + Cloud, + Chrome +} + +export enum OS { + Linux, + Windows, + Darwin, + FreeBSD, + Unknown +} + +export enum ARCH { + x64, + Arm, + Itanium, + ia32, + Unknown +} diff --git a/src/index.ts b/src/index.ts index 13fe5dd..1d5b67a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,10 @@ +import { MODE, OS, ARCH } from './enums'; + declare global { interface Window { // --- globals --- /** Mode of the application: window, browser, cloud, or chrome */ - NL_MODE: string; + NL_MODE: MODE; /** Application port */ NL_PORT: number; /** Command-line arguments */ @@ -20,9 +22,9 @@ interface Window { /** Returns true if extensions are enabled */ NL_EXTENABLED: boolean; /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Unknown */ - NL_OS: string; + NL_OS: OS; /** CPU architecture: x64, arm, itanium, ia32, or unknown */ - NL_ARCH: string; + NL_ARCH: ARCH; /** Neutralinojs server version */ NL_VERSION: string; /** Current working directory */