mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
[submodule:extensions] Breaking change: rename module
to library
This commit is contained in:
parent
19e5d322e2
commit
3b3361fe53
@ -159,7 +159,7 @@ const BrowserType = Object.freeze({
|
|||||||
FETCHER: 'fetcher',
|
FETCHER: 'fetcher',
|
||||||
INAPP: 'inapp',
|
INAPP: 'inapp',
|
||||||
MEDIAPLAYER: 'mediaplayer',
|
MEDIAPLAYER: 'mediaplayer',
|
||||||
MODULE: 'module'
|
LIBRARY: 'library'
|
||||||
});
|
});
|
||||||
|
|
||||||
const CPU = Object.freeze({
|
const CPU = Object.freeze({
|
||||||
|
2
src/extensions/ua-parser-extensions.d.ts
vendored
2
src/extensions/ua-parser-extensions.d.ts
vendored
@ -11,5 +11,5 @@ export const ExtraDevices: UAParserExt;
|
|||||||
export const Emails: UAParserExt;
|
export const Emails: UAParserExt;
|
||||||
export const Fetchers: UAParserExt;
|
export const Fetchers: UAParserExt;
|
||||||
export const InApps: UAParserExt;
|
export const InApps: UAParserExt;
|
||||||
|
export const Libraries: UAParserExt;
|
||||||
export const MediaPlayers: UAParserExt;
|
export const MediaPlayers: UAParserExt;
|
||||||
export const Modules: UAParserExt;
|
|
@ -20,7 +20,7 @@ const EMAIL = 'email';
|
|||||||
const FETCHER = 'fetcher';
|
const FETCHER = 'fetcher';
|
||||||
const INAPP = 'inapp';
|
const INAPP = 'inapp';
|
||||||
const MEDIAPLAYER = 'mediaplayer';
|
const MEDIAPLAYER = 'mediaplayer';
|
||||||
const MODULE = 'module';
|
const LIBRARY = 'library';
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// COMMAND LINE APPS
|
// COMMAND LINE APPS
|
||||||
@ -332,14 +332,14 @@ const MediaPlayers = Object.freeze({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
////////////////////////
|
/////////////
|
||||||
// MODULES / LIBRARIES
|
// LIBRARIES
|
||||||
///////////////////////
|
//////////////
|
||||||
|
|
||||||
const Modules = Object.freeze({
|
const Libraries = Object.freeze({
|
||||||
browser : [
|
browser : [
|
||||||
// Axios/jsdom/Scrapy
|
// Axios/jsdom/Scrapy
|
||||||
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, MODULE]]
|
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ const Bots = Object.freeze({
|
|||||||
...CLIs.browser,
|
...CLIs.browser,
|
||||||
...Crawlers.browser,
|
...Crawlers.browser,
|
||||||
...Fetchers.browser,
|
...Fetchers.browser,
|
||||||
...Modules.browser
|
...Libraries.browser
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -364,6 +364,6 @@ module.exports = {
|
|||||||
Emails,
|
Emails,
|
||||||
Fetchers,
|
Fetchers,
|
||||||
InApps,
|
InApps,
|
||||||
MediaPlayers,
|
Libraries,
|
||||||
Modules
|
MediaPlayers
|
||||||
};
|
};
|
@ -37,7 +37,7 @@ const isAppleSilicon = (res, useFeatureDetection) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'module'].includes(res.browser.type);
|
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'library'].includes(res.browser.type);
|
||||||
|
|
||||||
const isChromeFamily = (res) => res.engine.is(Engine.BLINK);
|
const isChromeFamily = (res) => res.engine.is(Engine.BLINK);
|
||||||
|
|
||||||
|
2
src/main/ua-parser.d.ts
vendored
2
src/main/ua-parser.d.ts
vendored
@ -15,7 +15,7 @@ declare namespace UAParser {
|
|||||||
name?: string;
|
name?: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
major?: string;
|
major?: string;
|
||||||
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'module';
|
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'library';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ICPU extends IData<ICPU> {
|
interface ICPU extends IData<ICPU> {
|
||||||
|
@ -28,7 +28,7 @@ expectType<IBrowser>(browser);
|
|||||||
expectType<string | undefined>(browser.name);
|
expectType<string | undefined>(browser.name);
|
||||||
expectType<string | undefined>(browser.version);
|
expectType<string | undefined>(browser.version);
|
||||||
expectType<string | undefined>(browser.major);
|
expectType<string | undefined>(browser.major);
|
||||||
expectType<'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'module' | undefined>(browser.type);
|
expectType<'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'library' | undefined>(browser.type);
|
||||||
expectType<boolean>(browser.is(''));
|
expectType<boolean>(browser.is(''));
|
||||||
expectType<string>(browser.toString());
|
expectType<string>(browser.toString());
|
||||||
expectType<IBrowser | PromiseLike<IBrowser>>(browser.withClientHints());
|
expectType<IBrowser | PromiseLike<IBrowser>>(browser.withClientHints());
|
||||||
|
@ -8,8 +8,8 @@ const clis = require('./specs/browser-clis.json');
|
|||||||
const crawlers = require('./specs/browser-crawlers.json');
|
const crawlers = require('./specs/browser-crawlers.json');
|
||||||
const emails = require('./specs/browser-emails.json');
|
const emails = require('./specs/browser-emails.json');
|
||||||
const fetchers = require('./specs/browser-fetchers.json');
|
const fetchers = require('./specs/browser-fetchers.json');
|
||||||
const modules = require('./specs/browser-modules.json');
|
const libraries = require('./specs/browser-libraries.json');
|
||||||
const { Bots, CLIs, Crawlers, Emails, Fetchers, Modules } = require('../src/extensions/ua-parser-extensions');
|
const { Bots, CLIs, Crawlers, Emails, Fetchers, Libraries } = require('../src/extensions/ua-parser-extensions');
|
||||||
|
|
||||||
describe('Extensions', () => {
|
describe('Extensions', () => {
|
||||||
[
|
[
|
||||||
@ -17,7 +17,7 @@ describe('Extensions', () => {
|
|||||||
['Crawlers', crawlers, Crawlers],
|
['Crawlers', crawlers, Crawlers],
|
||||||
['Emails', emails, Emails],
|
['Emails', emails, Emails],
|
||||||
['Fetchers', fetchers, Fetchers],
|
['Fetchers', fetchers, Fetchers],
|
||||||
['Modules', modules, Modules]
|
['Libraries', libraries, Libraries]
|
||||||
]
|
]
|
||||||
.forEach((list) => {
|
.forEach((list) => {
|
||||||
describe(list[0], () => {
|
describe(list[0], () => {
|
||||||
@ -44,10 +44,10 @@ describe('Extensions', () => {
|
|||||||
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
||||||
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
||||||
|
|
||||||
const moduleParser = new UAParser(Modules);
|
const libraryParser = new UAParser(Libraries);
|
||||||
assert.deepEqual(moduleParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "module"});
|
assert.deepEqual(libraryParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "library"});
|
||||||
assert.deepEqual(moduleParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "module"});
|
assert.deepEqual(libraryParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "library"});
|
||||||
assert.deepEqual(moduleParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "module"});
|
assert.deepEqual(libraryParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "library"});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Merge', () => {
|
describe('Merge', () => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{
|
{
|
||||||
"name" : "Scrapy",
|
"name" : "Scrapy",
|
||||||
"version" : "1.5.0",
|
"version" : "1.5.0",
|
||||||
"type" : "module"
|
"type" : "library"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
x
Reference in New Issue
Block a user