[submodule:extensions] Breaking change: rename module to library

This commit is contained in:
Faisal Salman 2024-11-10 08:15:39 +07:00
parent 19e5d322e2
commit 3b3361fe53
8 changed files with 23 additions and 23 deletions

View File

@ -159,7 +159,7 @@ const BrowserType = Object.freeze({
FETCHER: 'fetcher',
INAPP: 'inapp',
MEDIAPLAYER: 'mediaplayer',
MODULE: 'module'
LIBRARY: 'library'
});
const CPU = Object.freeze({

View File

@ -11,5 +11,5 @@ export const ExtraDevices: UAParserExt;
export const Emails: UAParserExt;
export const Fetchers: UAParserExt;
export const InApps: UAParserExt;
export const Libraries: UAParserExt;
export const MediaPlayers: UAParserExt;
export const Modules: UAParserExt;

View File

@ -20,7 +20,7 @@ const EMAIL = 'email';
const FETCHER = 'fetcher';
const INAPP = 'inapp';
const MEDIAPLAYER = 'mediaplayer';
const MODULE = 'module';
const LIBRARY = 'library';
//////////////////////
// COMMAND LINE APPS
@ -332,14 +332,14 @@ const MediaPlayers = Object.freeze({
]
});
////////////////////////
// MODULES / LIBRARIES
///////////////////////
/////////////
// LIBRARIES
//////////////
const Modules = Object.freeze({
const Libraries = Object.freeze({
browser : [
// 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,
...Crawlers.browser,
...Fetchers.browser,
...Modules.browser
...Libraries.browser
]
});
@ -364,6 +364,6 @@ module.exports = {
Emails,
Fetchers,
InApps,
MediaPlayers,
Modules
Libraries,
MediaPlayers
};

View File

@ -37,7 +37,7 @@ const isAppleSilicon = (res, useFeatureDetection) => {
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);

View File

@ -15,7 +15,7 @@ declare namespace UAParser {
name?: string;
version?: string;
major?: string;
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'module';
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'library';
}
interface ICPU extends IData<ICPU> {

View File

@ -28,7 +28,7 @@ expectType<IBrowser>(browser);
expectType<string | undefined>(browser.name);
expectType<string | undefined>(browser.version);
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<string>(browser.toString());
expectType<IBrowser | PromiseLike<IBrowser>>(browser.withClientHints());

View File

@ -8,8 +8,8 @@ const clis = require('./specs/browser-clis.json');
const crawlers = require('./specs/browser-crawlers.json');
const emails = require('./specs/browser-emails.json');
const fetchers = require('./specs/browser-fetchers.json');
const modules = require('./specs/browser-modules.json');
const { Bots, CLIs, Crawlers, Emails, Fetchers, Modules } = require('../src/extensions/ua-parser-extensions');
const libraries = require('./specs/browser-libraries.json');
const { Bots, CLIs, Crawlers, Emails, Fetchers, Libraries } = require('../src/extensions/ua-parser-extensions');
describe('Extensions', () => {
[
@ -17,7 +17,7 @@ describe('Extensions', () => {
['Crawlers', crawlers, Crawlers],
['Emails', emails, Emails],
['Fetchers', fetchers, Fetchers],
['Modules', modules, Modules]
['Libraries', libraries, Libraries]
]
.forEach((list) => {
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(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
const moduleParser = new UAParser(Modules);
assert.deepEqual(moduleParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "module"});
assert.deepEqual(moduleParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "module"});
assert.deepEqual(moduleParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "module"});
const libraryParser = new UAParser(Libraries);
assert.deepEqual(libraryParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "library"});
assert.deepEqual(libraryParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "library"});
assert.deepEqual(libraryParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "library"});
});
describe('Merge', () => {

View File

@ -6,7 +6,7 @@
{
"name" : "Scrapy",
"version" : "1.5.0",
"type" : "module"
"type" : "library"
}
}
]