Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser-detection/BrowserDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function _getJitsiBrowserInfo(browserInfo: IBrowserInfo): IBrowserInfo {
return {
name: PARSER_TO_JITSI_NAME[name],
version,
engine: ENGINES[engine],
engine: engine ? ENGINES[engine] : undefined,
engineVersion: engineVersion
};
}
Expand Down
134 changes: 134 additions & 0 deletions dist/BrowserDetection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
interface IBrowserInfo {
name: string;
version: string;
engine?: string;
engineVersion?: string;
}
/**
* Implements browser detection.
*/
export default class BrowserDetection {
_parser: any;
_name: string;
_version: any;
_engine: string | undefined;
_engineVersion: string | undefined;
/**
* Creates new BrowserDetection instance.
*
* @param {Object} [browserInfo] - Information about the browser.
* @param {string} browserInfo.name - The name of the browser.
* @param {string} browserInfo.version - The version of the browser.
* @param {string} browserInfo.engine - The engine of the browser.
* @param {string} browserInfo.engineVersion - The version of the engine of the browser.
* @param {string} browserInfo.os - The os of the browser.
* @param {string} browserInfo.osVersion - The os version of the browser.
*/
constructor(browserInfo: IBrowserInfo);
/**
* Checks if current browser is Chrome.
* @returns {boolean}
*/
isChrome(): boolean;
/**
* Checks if current browser is Firefox.
* @returns {boolean}
*/
isFirefox(): boolean;
/**
* Checks if current browser is Safari.
* @returns {boolean}
*/
isSafari(): boolean;
/**
* Checks if current environment is Electron.
* @returns {boolean}
*/
isElectron(): boolean;
/**
* Checks if current environment is React Native.
* @returns {boolean}
*/
isReactNative(): boolean;
/**
* Checks if current browser is based on chromium.
* @returns {boolean}
*/
isChromiumBased(): boolean;
/**
* Checks if current browser is based on webkit.
* @returns {boolean}
*/
isWebKitBased(): boolean;
/**
* Gets current browser name.
* @returns {string}
*/
getName(): string;
/**
* Returns the version of the current browser.
* @returns {string}
*/
getVersion(): string;
/**
* Gets current engine name of the browser.
* @returns {string}
*/
getEngine(): string | undefined;
/**
* Returns the engine version of the current browser.
* @returns the engine version
*/
getEngineVersion(): string | undefined;
/**
* Returns the operating system.
*/
getOS(): string;
/**
* Return the os version.
*/
getOSVersion(): string;
/**
* Compares the passed version with the current browser version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is greater than the passed version and false otherwise.
*/
isVersionGreaterThan(version: number): boolean;
/**
* Compares the passed version with the current browser version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is lower than the passed version and false otherwise.
*/
isVersionLessThan(version: number): boolean;
/**
* Compares the passed version with the current browser version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is equal to the passed version and false otherwise.
*/
isVersionEqualTo(version: number): boolean;
/**
* Compares the passed version with the current engine version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is greater than the passed version and false otherwise.
*/
isEngineVersionGreaterThan(version: number): boolean;
/**
* Compares the passed version with the current engine version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is lower than the passed version and false otherwise.
*/
isEngineVersionLessThan(version: number): boolean;
/**
* Compares the passed version with the current engine version.
*
* @param {number} version - The version to compare with.
* @returns {boolean} - Returns true if the current version is equal to the passed version and false otherwise.
*/
isEngineVersionEqualTo(version: number): boolean;
}
export {};
23 changes: 23 additions & 0 deletions dist/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export declare enum Browser {
CHROME = "chrome",
FIREFOX = "firefox",
SAFARI = "safari",
ELECTRON = "electron",
REACT_NATIVE = "react-native",
WEBKIT_BROWSER = "webkit-browser"
}
/**
* Maps the names of the browsers from ua-parser to the internal names defined in
* ./browsers.js
*/
export declare const PARSER_TO_JITSI_NAME: {
[key: string]: Browser;
};
export declare enum Engine {
BLINK = "blink",
WEBKIT = "webkit",
GECKO = "gecko"
}
export declare const ENGINES: {
[key: string]: Engine;
};
23 changes: 22 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"@babel/eslint-parser": "7.22.15",
"@types/ua-parser-js": "0.7.39",
"eslint": "8.50.0",
"eslint-plugin-import": "2.28.1"
"eslint-plugin-import": "2.28.1",
"typescript": "^5.8.3"
},
"scripts": {
"lint": "eslint ."
Expand Down
24 changes: 24 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"declaration": true, // Generate .d.ts files
"emitDeclarationOnly": true, // Emit only .d.ts files (optional for type generation)
"outDir": "./dist", // Output directory for compiled files and declarations
"moduleResolution": "node",
"target": "ES6",
"module": "ES6",
"strict": true
},
"include": [
"./browser-detection/BrowserDetection.ts"
],
"exclude": [
"node_modules",
"dist",
"docs",
"test",
"**/*.spec.ts",
"**/*.spec.js",
"*.conf*.js",
"index.js"
]
}