ua-browser 1.4.0-beta.0 → 1.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/dist/index.cjs +19 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +18 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -182,6 +182,8 @@ import {
|
|
|
182
182
|
detectBot, // standalone bot detection
|
|
183
183
|
detectBrowser, // standalone browser detection
|
|
184
184
|
detectOS, // standalone OS detection
|
|
185
|
+
detectEngine, // standalone rendering engine detection
|
|
186
|
+
detectDevice, // standalone device type detection
|
|
185
187
|
detectArch, // standalone CPU architecture detection
|
|
186
188
|
detectHeadless, // standalone headless browser detection
|
|
187
189
|
satisfies, // condition-matching helper
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
// package.json
|
|
6
6
|
var package_default = {
|
|
7
|
-
version: "1.4.0-beta.
|
|
7
|
+
version: "1.4.0-beta.1"};
|
|
8
8
|
|
|
9
9
|
// src/constants/browsers.ts
|
|
10
10
|
var BROWSER_DEFS = [
|
|
@@ -178,6 +178,11 @@ var ENGINE_DEFS = [
|
|
|
178
178
|
// src/detectors/engine.ts
|
|
179
179
|
function detectEngine(ua, browser, version) {
|
|
180
180
|
var _a, _b;
|
|
181
|
+
if (browser === void 0 || version === void 0) {
|
|
182
|
+
const b = detectBrowser(ua);
|
|
183
|
+
browser = browser != null ? browser : b.browser;
|
|
184
|
+
version = version != null ? version : b.version;
|
|
185
|
+
}
|
|
181
186
|
let engine = "unknown";
|
|
182
187
|
for (const def of ENGINE_DEFS) {
|
|
183
188
|
if (def.detect.test(ua)) {
|
|
@@ -553,14 +558,22 @@ function platformFromUA(ua) {
|
|
|
553
558
|
}
|
|
554
559
|
return "unknown";
|
|
555
560
|
}
|
|
561
|
+
function normalizeBCP47(raw) {
|
|
562
|
+
const parts = raw.replace(/_/g, "-").split("-");
|
|
563
|
+
return parts.map((p, i) => {
|
|
564
|
+
if (i === 0) return p.toLowerCase();
|
|
565
|
+
if (p.length === 4) return p[0].toUpperCase() + p.slice(1).toLowerCase();
|
|
566
|
+
return p.toUpperCase();
|
|
567
|
+
}).join("-");
|
|
568
|
+
}
|
|
556
569
|
function languageFromUA(ua) {
|
|
570
|
+
const kwMatch = /\bLanguage\/([a-zA-Z]{2,3}(?:[-_][a-zA-Z]{2,4}){1,2})\b/i.exec(ua);
|
|
571
|
+
if (kwMatch) return normalizeBCP47(kwMatch[1]);
|
|
557
572
|
const re = /[;(]\s*([a-z]{2,3}(?:[-_][A-Za-z]{2,4})+)\s*[;)]/g;
|
|
558
573
|
let m;
|
|
559
574
|
while ((m = re.exec(ua)) !== null) {
|
|
560
575
|
const parts = m[1].replace(/_/g, "-").split("-");
|
|
561
|
-
if (parts.length >= 2)
|
|
562
|
-
return `${parts[0].toLowerCase()}-${parts.slice(1).map((p) => p.toUpperCase()).join("-")}`;
|
|
563
|
-
}
|
|
576
|
+
if (parts.length >= 2) return normalizeBCP47(m[1]);
|
|
564
577
|
}
|
|
565
578
|
return "unknown";
|
|
566
579
|
}
|
|
@@ -953,6 +966,8 @@ exports.default = src_default;
|
|
|
953
966
|
exports.detectArch = detectArch;
|
|
954
967
|
exports.detectBot = detectBot;
|
|
955
968
|
exports.detectBrowser = detectBrowser;
|
|
969
|
+
exports.detectDevice = detectDevice;
|
|
970
|
+
exports.detectEngine = detectEngine;
|
|
956
971
|
exports.detectHeadless = detectHeadless;
|
|
957
972
|
exports.detectOS = detectOs;
|
|
958
973
|
exports.getEnvContext = getEnvContext;
|