@flighthq/useragent 0.5.1-next.973.788d3d7 → 0.6.0
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.md +2 -2
- package/dist/contract.d.ts +4 -2
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -2
- package/dist/contract.js.map +1 -1
- package/dist/deviceFormFactor.d.ts +35 -0
- package/dist/deviceFormFactor.d.ts.map +1 -0
- package/dist/deviceFormFactor.js +31 -0
- package/dist/deviceFormFactor.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jsPattern.d.ts +65 -0
- package/dist/jsPattern.d.ts.map +1 -0
- package/dist/jsPattern.js +247 -0
- package/dist/jsPattern.js.map +1 -0
- package/dist/rustTestSupport.d.ts +12 -0
- package/dist/rustTestSupport.d.ts.map +1 -0
- package/dist/rustTestSupport.js +24 -0
- package/dist/rustTestSupport.js.map +1 -0
- package/dist/userAgent.d.ts +53 -3
- package/dist/userAgent.d.ts.map +1 -1
- package/dist/userAgent.js +162 -146
- package/dist/userAgent.js.map +1 -1
- package/dist/userAgentNative.d.ts +12 -0
- package/dist/userAgentNative.d.ts.map +1 -0
- package/dist/userAgentNative.js +46 -0
- package/dist/userAgentNative.js.map +1 -0
- package/dist/userAgentParse.d.ts +17 -1
- package/dist/userAgentParse.d.ts.map +1 -1
- package/dist/userAgentParse.js +195 -93
- package/dist/userAgentParse.js.map +1 -1
- package/dist/userAgentTruthy.d.ts +3 -0
- package/dist/userAgentTruthy.d.ts.map +1 -0
- package/dist/userAgentTruthy.js +64 -0
- package/dist/userAgentTruthy.js.map +1 -0
- package/package.json +5 -5
- package/src/jsPattern.test.ts +136 -0
- package/src/userAgent.test.ts +217 -370
- package/src/userAgentNative.test.ts +55 -0
- package/src/userAgentParse.test.ts +111 -132
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/useragent`. The `@fl
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/useragent@0.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/useragent@0.6.0](https://github.com/flighthq/flight/tree/ead804bfaef3e691a2e6e43e9711ddd3fd8a84a2/packages/useragent)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/ead804bfaef3e691a2e6e43e9711ddd3fd8a84a2/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { DeviceFormFactorCar, DeviceFormFactorDesktop, DeviceFormFactorPhone, DeviceFormFactorTV, DeviceFormFactorTablet, DeviceFormFactorUnknown, DeviceFormFactorWatch, } from './deviceFormFactor.ts';
|
|
2
|
+
export type { DeviceFormFactor } from './deviceFormFactor.ts';
|
|
3
|
+
export { detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentKind, parseUserAgentName, parseUserAgentPointerWidth, parseUserAgentRuntime, parseUserAgentVersion, } from './userAgent.ts';
|
|
4
|
+
export { parseUserAgentFormFactor, parseUserAgentOsName, parseUserAgentOsVersion } from './userAgentParse.ts';
|
|
3
5
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { DeviceFormFactorCar, DeviceFormFactorDesktop, DeviceFormFactorPhone, DeviceFormFactorTV, DeviceFormFactorTablet, DeviceFormFactorUnknown, DeviceFormFactorWatch, } from './deviceFormFactor.js';
|
|
2
|
+
export { detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentKind, parseUserAgentName, parseUserAgentPointerWidth, parseUserAgentRuntime, parseUserAgentVersion, } from './userAgent.js';
|
|
3
|
+
export { parseUserAgentFormFactor, parseUserAgentOsName, parseUserAgentOsVersion } from './userAgentParse.js';
|
|
3
4
|
//# sourceMappingURL=contract.js.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device form-factor identifier (TS `DeviceFormFactor`): the physical class of device a host runs
|
|
3
|
+
* on. An OPEN string domain, as in TS: the seven constants below are the known values, and a
|
|
4
|
+
* custom form factor uses a vendor-prefixed string (e.g. "acme.Console").
|
|
5
|
+
*/
|
|
6
|
+
export type DeviceFormFactor = string;
|
|
7
|
+
/**
|
|
8
|
+
* TS `DeviceFormFactorCar`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DeviceFormFactorCar: 'Car';
|
|
11
|
+
/**
|
|
12
|
+
* TS `DeviceFormFactorDesktop`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DeviceFormFactorDesktop: 'Desktop';
|
|
15
|
+
/**
|
|
16
|
+
* TS `DeviceFormFactorPhone`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DeviceFormFactorPhone: 'Phone';
|
|
19
|
+
/**
|
|
20
|
+
* TS `DeviceFormFactorTablet`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DeviceFormFactorTablet: 'Tablet';
|
|
23
|
+
/**
|
|
24
|
+
* TS `DeviceFormFactorTV`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DeviceFormFactorTV: 'TV';
|
|
27
|
+
/**
|
|
28
|
+
* TS `DeviceFormFactorUnknown`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DeviceFormFactorUnknown: 'Unknown';
|
|
31
|
+
/**
|
|
32
|
+
* TS `DeviceFormFactorWatch`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DeviceFormFactorWatch: 'Watch';
|
|
35
|
+
//# sourceMappingURL=deviceFormFactor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceFormFactor.d.ts","sourceRoot":"","sources":["../src/deviceFormFactor.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAG,KAAc,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,SAAkB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAG,OAAgB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAG,QAAiB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAG,IAAa,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,SAAkB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAG,OAAgB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Generated from crates/flight-useragent/src/device_form_factor.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
3
|
+
/**
|
|
4
|
+
* TS `DeviceFormFactorCar`.
|
|
5
|
+
*/
|
|
6
|
+
export const DeviceFormFactorCar = 'Car';
|
|
7
|
+
/**
|
|
8
|
+
* TS `DeviceFormFactorDesktop`.
|
|
9
|
+
*/
|
|
10
|
+
export const DeviceFormFactorDesktop = 'Desktop';
|
|
11
|
+
/**
|
|
12
|
+
* TS `DeviceFormFactorPhone`.
|
|
13
|
+
*/
|
|
14
|
+
export const DeviceFormFactorPhone = 'Phone';
|
|
15
|
+
/**
|
|
16
|
+
* TS `DeviceFormFactorTablet`.
|
|
17
|
+
*/
|
|
18
|
+
export const DeviceFormFactorTablet = 'Tablet';
|
|
19
|
+
/**
|
|
20
|
+
* TS `DeviceFormFactorTV`.
|
|
21
|
+
*/
|
|
22
|
+
export const DeviceFormFactorTV = 'TV';
|
|
23
|
+
/**
|
|
24
|
+
* TS `DeviceFormFactorUnknown`.
|
|
25
|
+
*/
|
|
26
|
+
export const DeviceFormFactorUnknown = 'Unknown';
|
|
27
|
+
/**
|
|
28
|
+
* TS `DeviceFormFactorWatch`.
|
|
29
|
+
*/
|
|
30
|
+
export const DeviceFormFactorWatch = 'Watch';
|
|
31
|
+
//# sourceMappingURL=deviceFormFactor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceFormFactor.js","sourceRoot":"","sources":["../src/deviceFormFactor.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,mEAAmE;AASnE;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAc,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAgB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAiB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAa,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAgB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentFormFactor, parseUserAgentKind, parseUserAgentName, parseUserAgentOsName, parseUserAgentOsVersion, parseUserAgentPointerWidth, parseUserAgentVersion, } from './contract';
|
|
1
|
+
export { DeviceFormFactorCar, DeviceFormFactorDesktop, DeviceFormFactorPhone, DeviceFormFactorTV, DeviceFormFactorTablet, DeviceFormFactorUnknown, DeviceFormFactorWatch, detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentFormFactor, parseUserAgentKind, parseUserAgentName, parseUserAgentOsName, parseUserAgentOsVersion, parseUserAgentPointerWidth, parseUserAgentRuntime, parseUserAgentVersion, } from './contract.ts';
|
|
2
|
+
export type { DeviceFormFactor } from './contract.ts';
|
|
2
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentFormFactor, parseUserAgentKind, parseUserAgentName, parseUserAgentOsName, parseUserAgentOsVersion, parseUserAgentPointerWidth, parseUserAgentVersion, } from './contract';
|
|
1
|
+
export { DeviceFormFactorCar, DeviceFormFactorDesktop, DeviceFormFactorPhone, DeviceFormFactorTV, DeviceFormFactorTablet, DeviceFormFactorUnknown, DeviceFormFactorWatch, detectEndianness, parseUserAgentArch, parseUserAgentEngine, parseUserAgentEngineVersion, parseUserAgentFormFactor, parseUserAgentKind, parseUserAgentName, parseUserAgentOsName, parseUserAgentOsVersion, parseUserAgentPointerWidth, parseUserAgentRuntime, parseUserAgentVersion, } from './contract.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS `/prefix(class+)/i.exec(text)?.[1]`: the first occurrence of `prefix` followed by at least
|
|
3
|
+
* one `class` char, capturing that greedy run.
|
|
4
|
+
*/
|
|
5
|
+
declare function captureAfter(text: Readonly<number[]>, prefix: string, predicate: (arg0: number) => boolean): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* JS `/prefix\s+(class+)/i`: `prefix`, at least one JS whitespace, then at least one `class` char.
|
|
8
|
+
*/
|
|
9
|
+
declare function captureAfterWhitespace(text: Readonly<number[]>, prefix: string, predicate: (arg0: number) => boolean): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The UA as JavaScript UTF-16 code units, for position-based matching.
|
|
12
|
+
*/
|
|
13
|
+
declare function charsOf(text: string): number[];
|
|
14
|
+
/**
|
|
15
|
+
* JS `/needle/i.test(text)`.
|
|
16
|
+
*/
|
|
17
|
+
declare function contains(text: Readonly<number[]>, needle: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* JS `/a|b|.../i.test(text)`.
|
|
20
|
+
*/
|
|
21
|
+
declare function containsAny(text: Readonly<number[]>, needles: Readonly<string[]>): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* JS `/first.*second/i.test(text)`: `second` follows some `first` on the same line.
|
|
24
|
+
*/
|
|
25
|
+
declare function containsThenOnLine(text: Readonly<number[]>, first: string, second: string): boolean;
|
|
26
|
+
declare function isAsciiDigit(c: number): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `[\d.]`
|
|
29
|
+
*/
|
|
30
|
+
declare function isDigitOrDot(c: number): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* `[\d]`
|
|
33
|
+
*/
|
|
34
|
+
declare function isDigitOrUnderscore(c: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `[\d.]`
|
|
37
|
+
*/
|
|
38
|
+
declare function isDigitUnderscoreOrDot(c: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* JS LineTerminator: the characters `.` does not match.
|
|
41
|
+
*/
|
|
42
|
+
declare function isJsLineTerminator(c: number): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* JS `\s`: WhiteSpace (TAB, VT, FF, U+FEFF and the Zs category) plus LineTerminator.
|
|
45
|
+
*/
|
|
46
|
+
declare function isJsWhitespace(c: number): boolean;
|
|
47
|
+
declare function isNotJsWhitespace(c: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* True when `needle` (ASCII, lowercase) matches `text` at `at` under JS non-unicode `/i` folding.
|
|
50
|
+
*/
|
|
51
|
+
declare function matchesAt(text: Readonly<number[]>, at: number, needle: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Every position where `needle` matches, in order (the regex's leftmost start positions).
|
|
54
|
+
*/
|
|
55
|
+
declare function positions(text: Readonly<number[]>, needle: string): number[];
|
|
56
|
+
/**
|
|
57
|
+
* Count of consecutive chars from `at` satisfying `class`.
|
|
58
|
+
*/
|
|
59
|
+
declare function runLen(text: Readonly<number[]>, at: number, predicate: (arg0: number) => boolean): number;
|
|
60
|
+
/**
|
|
61
|
+
* Replaces ASCII underscores with dots in a capture made only of digits, underscores, and dots.
|
|
62
|
+
*/
|
|
63
|
+
declare function underscoresToDots(value: string): string;
|
|
64
|
+
export { captureAfter, captureAfterWhitespace, charsOf, contains, containsAny, containsThenOnLine, isAsciiDigit, isDigitOrDot, isDigitOrUnderscore, isDigitUnderscoreOrDot, isJsLineTerminator, isJsWhitespace, isNotJsWhitespace, matchesAt, positions, runLen, underscoresToDots, };
|
|
65
|
+
//# sourceMappingURL=jsPattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsPattern.d.ts","sourceRoot":"","sources":["../src/jsPattern.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,iBAAS,YAAY,CACnB,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EACxB,MAAM,EAAE,MAAM,E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C,CAAC,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAShF;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBrE;AAED;;GAEG;AACH,iBAAS,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAOlG;AAED;;GAEG;AACH,iBAAS,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAOD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,OAAO,EACP,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,MAAM,EACN,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Generated from crates/flight-useragent/src/js_pattern.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
3
|
+
function asciiLower(value) {
|
|
4
|
+
if (value >= 0x0041 && value <= 0x005a) {
|
|
5
|
+
return value + 0x0020;
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function asciiSliceToString(text, start, end) {
|
|
10
|
+
let out = '';
|
|
11
|
+
for (let i = start; i < end; i++) {
|
|
12
|
+
let value;
|
|
13
|
+
switch (text[i]) {
|
|
14
|
+
case 0x002e:
|
|
15
|
+
value = '.';
|
|
16
|
+
break;
|
|
17
|
+
case 0x0030:
|
|
18
|
+
value = '0';
|
|
19
|
+
break;
|
|
20
|
+
case 0x0031:
|
|
21
|
+
value = '1';
|
|
22
|
+
break;
|
|
23
|
+
case 0x0032:
|
|
24
|
+
value = '2';
|
|
25
|
+
break;
|
|
26
|
+
case 0x0033:
|
|
27
|
+
value = '3';
|
|
28
|
+
break;
|
|
29
|
+
case 0x0034:
|
|
30
|
+
value = '4';
|
|
31
|
+
break;
|
|
32
|
+
case 0x0035:
|
|
33
|
+
value = '5';
|
|
34
|
+
break;
|
|
35
|
+
case 0x0036:
|
|
36
|
+
value = '6';
|
|
37
|
+
break;
|
|
38
|
+
case 0x0037:
|
|
39
|
+
value = '7';
|
|
40
|
+
break;
|
|
41
|
+
case 0x0038:
|
|
42
|
+
value = '8';
|
|
43
|
+
break;
|
|
44
|
+
case 0x0039:
|
|
45
|
+
value = '9';
|
|
46
|
+
break;
|
|
47
|
+
case 0x005f:
|
|
48
|
+
value = '_';
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
value = '';
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
out = `${out}${value}`;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* JS `/prefix(class+)/i.exec(text)?.[1]`: the first occurrence of `prefix` followed by at least
|
|
60
|
+
* one `class` char, capturing that greedy run.
|
|
61
|
+
*/
|
|
62
|
+
function captureAfter(text, prefix, predicate) {
|
|
63
|
+
const prefixLen = utf16Len(prefix);
|
|
64
|
+
for (const at of positions(text, prefix)) {
|
|
65
|
+
const start = at + prefixLen;
|
|
66
|
+
const len = runLen(text, start, predicate);
|
|
67
|
+
if (len > 0) {
|
|
68
|
+
return asciiSliceToString(text, start, start + len);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* JS `/prefix\s+(class+)/i`: `prefix`, at least one JS whitespace, then at least one `class` char.
|
|
75
|
+
*/
|
|
76
|
+
function captureAfterWhitespace(text, prefix, predicate) {
|
|
77
|
+
const prefixLen = utf16Len(prefix);
|
|
78
|
+
for (const at of positions(text, prefix)) {
|
|
79
|
+
const ws = runLen(text, at + prefixLen, isJsWhitespace);
|
|
80
|
+
if (ws === 0) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const start = at + prefixLen + ws;
|
|
84
|
+
const len = runLen(text, start, predicate);
|
|
85
|
+
if (len > 0) {
|
|
86
|
+
return asciiSliceToString(text, start, start + len);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The UA as JavaScript UTF-16 code units, for position-based matching.
|
|
93
|
+
*/
|
|
94
|
+
function charsOf(text) {
|
|
95
|
+
return Array.from({ length: text.length }, (_, index) => text.charCodeAt(index));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* JS `/needle/i.test(text)`.
|
|
99
|
+
*/
|
|
100
|
+
function contains(text, needle) {
|
|
101
|
+
return findFrom(text, 0, needle) !== undefined;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* JS `/a|b|.../i.test(text)`.
|
|
105
|
+
*/
|
|
106
|
+
function containsAny(text, needles) {
|
|
107
|
+
return needles.some((needle) => contains(text, needle));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* JS `/first.*second/i.test(text)`: `second` follows some `first` on the same line.
|
|
111
|
+
*/
|
|
112
|
+
function containsThenOnLine(text, first, second) {
|
|
113
|
+
const firstLen = utf16Len(first);
|
|
114
|
+
return positions(text, first).some((at) => {
|
|
115
|
+
let k = at + firstLen;
|
|
116
|
+
for (;;) {
|
|
117
|
+
if (matchesAt(text, k, second)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (k >= text.length || isJsLineTerminator(text[k])) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
k++;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The first position at or after `from` where `needle` matches.
|
|
129
|
+
*/
|
|
130
|
+
function findFrom(text, from, needle) {
|
|
131
|
+
const len = utf16Len(needle);
|
|
132
|
+
if (len > text.length) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return Array.from({ length: text.length - len - from + 1 }, (_, index) => from + index).find((i) => matchesAt(text, i, needle));
|
|
136
|
+
}
|
|
137
|
+
function isAsciiDigit(c) {
|
|
138
|
+
return c >= 0x0030 && c <= 0x0039;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* `[\d.]`
|
|
142
|
+
*/
|
|
143
|
+
function isDigitOrDot(c) {
|
|
144
|
+
return isAsciiDigit(c) || c === 0x002e;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* `[\d]`
|
|
148
|
+
*/
|
|
149
|
+
function isDigitOrUnderscore(c) {
|
|
150
|
+
return isAsciiDigit(c) || c === 0x005f;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* `[\d.]`
|
|
154
|
+
*/
|
|
155
|
+
function isDigitUnderscoreOrDot(c) {
|
|
156
|
+
return isAsciiDigit(c) || c === 0x005f || c === 0x002e;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* JS LineTerminator: the characters `.` does not match.
|
|
160
|
+
*/
|
|
161
|
+
function isJsLineTerminator(c) {
|
|
162
|
+
return c === 0x000a || c === 0x000d || c === 0x2028 || c === 0x2029;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* JS `\s`: WhiteSpace (TAB, VT, FF, U+FEFF and the Zs category) plus LineTerminator.
|
|
166
|
+
*/
|
|
167
|
+
function isJsWhitespace(c) {
|
|
168
|
+
return (c === 0x0009 ||
|
|
169
|
+
c === 0x000b ||
|
|
170
|
+
c === 0x000c ||
|
|
171
|
+
c === 0x0020 ||
|
|
172
|
+
c === 0x00a0 ||
|
|
173
|
+
c === 0x1680 ||
|
|
174
|
+
(c >= 0x2000 && c <= 0x200a) ||
|
|
175
|
+
c === 0x202f ||
|
|
176
|
+
c === 0x205f ||
|
|
177
|
+
c === 0x3000 ||
|
|
178
|
+
c === 0xfeff ||
|
|
179
|
+
isJsLineTerminator(c));
|
|
180
|
+
}
|
|
181
|
+
function isNotJsWhitespace(c) {
|
|
182
|
+
return !isJsWhitespace(c);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* True when `needle` (ASCII, lowercase) matches `text` at `at` under JS non-unicode `/i` folding.
|
|
186
|
+
*/
|
|
187
|
+
function matchesAt(text, at, needle) {
|
|
188
|
+
let i = at;
|
|
189
|
+
for (const p of Array.from({ length: needle.length }, (_, index) => needle.charCodeAt(index))) {
|
|
190
|
+
if (i >= text.length || asciiLower(text[i]) !== p) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
i++;
|
|
194
|
+
}
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Every position where `needle` matches, in order (the regex's leftmost start positions).
|
|
199
|
+
*/
|
|
200
|
+
function positions(text, needle) {
|
|
201
|
+
let out = [0];
|
|
202
|
+
out.length = 0;
|
|
203
|
+
let from = 0;
|
|
204
|
+
for (;;) {
|
|
205
|
+
const found = findFrom(text, from, needle);
|
|
206
|
+
{
|
|
207
|
+
if (found !== undefined) {
|
|
208
|
+
const at = found;
|
|
209
|
+
out.push(at);
|
|
210
|
+
from = at + 1;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Count of consecutive chars from `at` satisfying `class`.
|
|
221
|
+
*/
|
|
222
|
+
function runLen(text, at, predicate) {
|
|
223
|
+
const start = Math.min(at, text.length);
|
|
224
|
+
let end = start;
|
|
225
|
+
while (end < text.length && predicate(text[end])) {
|
|
226
|
+
end++;
|
|
227
|
+
}
|
|
228
|
+
return end - start;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Replaces ASCII underscores with dots in a capture made only of digits, underscores, and dots.
|
|
232
|
+
*/
|
|
233
|
+
function underscoresToDots(value) {
|
|
234
|
+
let units = Array.from({ length: value.length }, (_, index) => value.charCodeAt(index));
|
|
235
|
+
for (let i = 0; i < units.length; i++) {
|
|
236
|
+
if (units[i] === 0x005f) {
|
|
237
|
+
units[i] = 0x002e;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return asciiSliceToString(units, 0, units.length);
|
|
241
|
+
}
|
|
242
|
+
function utf16Len(value) {
|
|
243
|
+
const units = Array.from({ length: value.length }, (_, index) => value.charCodeAt(index));
|
|
244
|
+
return units.length;
|
|
245
|
+
}
|
|
246
|
+
export { captureAfter, captureAfterWhitespace, charsOf, contains, containsAny, containsThenOnLine, isAsciiDigit, isDigitOrDot, isDigitOrUnderscore, isDigitUnderscoreOrDot, isJsLineTerminator, isJsWhitespace, isNotJsWhitespace, matchesAt, positions, runLen, underscoresToDots, };
|
|
247
|
+
//# sourceMappingURL=jsPattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsPattern.js","sourceRoot":"","sources":["../src/jsPattern.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,mEAAmE;AAEnE,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;QACvC,OAAO,KAAK,GAAG,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAwB,EAAE,KAAa,EAAE,GAAW;IAC9E,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,KAAK,EA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,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,MAAM,EACN,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function isLittleEndian(): boolean;
|
|
2
|
+
declare function record(entries: ReadonlyArray<readonly [string, unknown]>): Record<string, unknown>;
|
|
3
|
+
declare function object(entries: ReadonlyArray<readonly [string, unknown]>): unknown;
|
|
4
|
+
declare function text(value: string): unknown;
|
|
5
|
+
export declare const rustTestSupport: {
|
|
6
|
+
isLittleEndian: typeof isLittleEndian;
|
|
7
|
+
object: typeof object;
|
|
8
|
+
record: typeof record;
|
|
9
|
+
text: typeof text;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=rustTestSupport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rustTestSupport.d.ts","sourceRoot":"","sources":["../src/rustTestSupport.ts"],"names":[],"mappings":"AAAA,iBAAS,cAAc,IAAI,OAAO,CAIjC;AAED,iBAAS,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI3F;AAED,iBAAS,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAE3E;AAED,iBAAS,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpC;AAED,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function isLittleEndian() {
|
|
2
|
+
const buffer = new ArrayBuffer(2);
|
|
3
|
+
new Uint16Array(buffer)[0] = 0x0102;
|
|
4
|
+
return new Uint8Array(buffer)[0] === 0x02;
|
|
5
|
+
}
|
|
6
|
+
function record(entries) {
|
|
7
|
+
const out = {};
|
|
8
|
+
for (const [key, value] of entries)
|
|
9
|
+
out[key] = value;
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
function object(entries) {
|
|
13
|
+
return record(entries);
|
|
14
|
+
}
|
|
15
|
+
function text(value) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export const rustTestSupport = {
|
|
19
|
+
isLittleEndian,
|
|
20
|
+
object,
|
|
21
|
+
record,
|
|
22
|
+
text,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=rustTestSupport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rustTestSupport.js","sourceRoot":"","sources":["../src/rustTestSupport.ts"],"names":[],"mappings":"AAAA,SAAS,cAAc;IACrB,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAClC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IACpC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,OAAkD;IAChE,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO;QAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACrD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,MAAM,CAAC,OAAkD;IAChE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,cAAc;IACd,MAAM;IACN,MAAM;IACN,IAAI;CACL,CAAC"}
|
package/dist/userAgent.d.ts
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
import type { PlatformEndianness, PlatformEngine, PlatformKind, PlatformName, PlatformRuntime } from '
|
|
1
|
+
import type { PlatformEndianness, PlatformEngine, PlatformKind, PlatformName, PlatformRuntime, Unknown } from './userAgentNative.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Pointer width in bits, or `Unknown` when the architecture does not identify one.
|
|
4
|
+
*/
|
|
5
|
+
export type UserAgentPointerWidth = 32 | 64 | -1;
|
|
6
|
+
/**
|
|
7
|
+
* Probes host CPU byte order with a local two-byte write-then-read (the source's
|
|
8
|
+
* `Uint16Array`/`Uint8Array` view of one buffer): `Big` when the high byte comes first, `Little`
|
|
9
|
+
* when the low byte does. The source's `Unknown` arm is for runtimes without ArrayBuffer, which
|
|
10
|
+
* cannot occur here.
|
|
11
|
+
*/
|
|
2
12
|
export declare function detectEndianness(): PlatformEndianness;
|
|
13
|
+
/**
|
|
14
|
+
* Parses the canonical CPU architecture token from a UA string: "x64", "arm64", "x86", "arm",
|
|
15
|
+
* "riscv64", "mips64", "mips", or "" when undetectable. A truthy `uadPlatform` (the UA-CH
|
|
16
|
+
* `navigator.userAgentData.platform` hint) is consulted first, case-folded as JS `toLowerCase`
|
|
17
|
+
* does; `undefined` and `Some("")` both skip it, as an empty string is falsy in TS. arm64/aarch64 is
|
|
18
|
+
* tested before arm.
|
|
19
|
+
*/
|
|
3
20
|
export declare function parseUserAgentArch(ua: string, uadPlatform?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parses the browser engine from a UA string. iOS/iPadOS decide first (every browser there runs on
|
|
23
|
+
* the system WebKit); then Firefox (gecko); legacy EdgeHTML (`Edge/<digit>`) is `Unknown`, not
|
|
24
|
+
* blink; then Chrome/Chromium/Edg/OPR/Samsung (blink); then Safari/WebKit; else `Unknown`.
|
|
25
|
+
*/
|
|
4
26
|
export declare function parseUserAgentEngine(ua: string): PlatformEngine;
|
|
27
|
+
/**
|
|
28
|
+
* Extracts the raw browser/engine version token for `engine` ("" when absent or `Unknown`): gecko
|
|
29
|
+
* `Firefox/`; blink `Edg/`, then `OPR/`, then `Chrome/`; webkit `Version/`, then `AppleWebKit/`.
|
|
30
|
+
* Never parsed for semantics.
|
|
31
|
+
*/
|
|
5
32
|
export declare function parseUserAgentEngineVersion(ua: string, engine: PlatformEngine): string;
|
|
33
|
+
/**
|
|
34
|
+
* The platform kind derived from a name: iOS and Android are `Mobile`; everything else is `Web`.
|
|
35
|
+
*/
|
|
6
36
|
export declare function parseUserAgentKind(name: PlatformName): PlatformKind;
|
|
37
|
+
/**
|
|
38
|
+
* The platform name from a UA string, in source precedence (android, iOS devices, `win`, `mac`,
|
|
39
|
+
* linux); `Web` when no known OS is detected.
|
|
40
|
+
*/
|
|
7
41
|
export declare function parseUserAgentName(ua: string): PlatformName;
|
|
8
|
-
|
|
9
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Pointer width in bits from a canonical arch token: 64 for "x64"/"arm64", 32 for "x86"/"arm", -1
|
|
44
|
+
* otherwise (TS `32 | 64 | -1`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseUserAgentPointerWidth(arch: string): UserAgentPointerWidth;
|
|
47
|
+
/**
|
|
48
|
+
* The host shell from browser-global probes on an optional window-like record (TS
|
|
49
|
+
* `win?: Readonly<Record<unknown>>`; `undefined` is omitted/undefined). `Unknown` for no window;
|
|
50
|
+
* `Electron` when `process.versions.electron` is truthy; `Tauri` when `__TAURI__` is truthy;
|
|
51
|
+
* `Capacitor` when `Capacitor` is truthy; else `Web`. Truthiness and property access follow JS (see
|
|
52
|
+
* `isTruthy`): a nested object is a `Record<Unknown>` stored in the `Unknown`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseUserAgentRuntime(win?: Readonly<Record<string, Unknown>>): PlatformRuntime;
|
|
55
|
+
/**
|
|
56
|
+
* The raw dotted OS version for `name`: "" for `Linux` (no kernel version in a browser UA), for
|
|
57
|
+
* the `Web` fallback, and when `name` is not the platform the UA describes; otherwise
|
|
58
|
+
* `parseUserAgentOsVersion`.
|
|
59
|
+
*/
|
|
10
60
|
export declare function parseUserAgentVersion(ua: string, name: PlatformName): string;
|
|
11
61
|
//# sourceMappingURL=userAgent.d.ts.map
|
package/dist/userAgent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAgent.d.ts","sourceRoot":"","sources":["../src/userAgent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"userAgent.d.ts","sourceRoot":"","sources":["../src/userAgent.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,OAAO,EACR,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAErD;AAcD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAoC3E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAkB/D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAyCtF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAKnE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAkB3D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAQ9E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,eAAe,CAE9F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAQ5E"}
|