Files
waha/src/version.ts
T
devlikepro 495857ee41
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / GOWS - none - amd64 - gows (push) Waiting to run
Release / GOWS - none - linux/arm64 - gows-arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run
[core] 2026.4.2
2026-04-17 12:48:34 +07:00

64 lines
1.5 KiB
TypeScript

// eslint-disable-next-line @typescript-eslint/no-var-requires
import { getEngineName } from '@waha/config';
import {
getBrowserExecutablePath,
isChromeExecutablePath,
} from './core/abc/session.browser';
import { WAHAEngine } from './structures/enums.dto';
import { WAHAEnvironment } from './structures/environment.dto';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
export enum WAHAVersion {
PLUS = 'PLUS',
CORE = 'CORE',
}
export function getWAHAVersion(): WAHAVersion {
// force core version if env variables set
const waha_version = process.env.WAHA_VERSION;
if (waha_version && waha_version === WAHAVersion.CORE) {
return WAHAVersion.CORE;
}
// Check the plus directory exists
const plusExists = fs.existsSync(`${__dirname}/plus`);
if (plusExists) {
return WAHAVersion.PLUS;
}
return WAHAVersion.CORE;
}
export function getWorker() {
return { id: process.env.WAHA_WORKER_ID || null };
}
function getBrowser() {
return getEngineName() === WAHAEngine.WEBJS ||
getEngineName() === WAHAEngine.WPP
? getBrowserExecutablePath()
: null;
}
function getPlatform() {
return `${process.platform}/${process.arch}`;
}
export const VERSION: WAHAEnvironment = {
version: '2026.4.2',
engine: getEngineName(),
tier: getWAHAVersion(),
browser: getBrowser(),
platform: getPlatform(),
worker: getWorker(),
};
export const IsChrome = VERSION.browser
? isChromeExecutablePath(VERSION.browser)
: false;
export { getEngineName };