Fix #660 - Add new helper method: getDeviceVendor() to guess the device vendor from a model name

This commit is contained in:
Faisal Salman
2024-07-27 22:47:27 +07:00
parent c391d8a73c
commit 62fb6c2925
3 changed files with 24 additions and 1 deletions

View File

@@ -4,12 +4,14 @@
import { IResult } from "../main/ua-parser";
declare function getDeviceVendor(model: string): string | undefined;
declare function isAppleSilicon(res: IResult): boolean;
declare function isChromeFamily(res: IResult): boolean;
declare function isFrozenUA(ua: string): boolean;
declare function isStandalonePWA(): boolean;
export {
getDeviceVendor,
isAppleSilicon,
isChromeFamily,
isFrozenUA,

View File

@@ -8,6 +8,9 @@
/*jshint esversion: 6 */
const { CPU, OS, Engine } = require('../enums/ua-parser-enums');
const { UAParser } = require('../main/ua-parser');
const getDeviceVendor = (model) => UAParser(`Mozilla/5.0 (Linux; Android 10; ${model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36`).device.vendor;
const isAppleSilicon = (res) => {
if (res.os.is(OS.MACOS)) {
@@ -44,6 +47,7 @@ const isStandalonePWA = () => window && (window.matchMedia('(display-mode: stand
document.referrer.startsWith('app-info://platform/microsoft-store'));
module.exports = {
getDeviceVendor,
isAppleSilicon,
isChromeFamily,
isFrozenUA,