native-fn 1.0.74 → 1.0.76
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/dist/index.d.ts +5 -5
- package/dist/native.cjs +1 -1
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +1 -1
- package/dist/native.umd.js +1 -1
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/app/index.cjs +355 -176
- package/dist/plugin/app/index.min.cjs +1 -1
- package/dist/plugin/app/index.min.mjs +1 -1
- package/dist/plugin/app/index.mjs +355 -176
- package/dist/plugin/app/index.umd.js +355 -176
- package/dist/plugin/app/index.umd.min.js +1 -1
- package/dist/plugin/app/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/app/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/app/src/types/native.d.ts +5 -5
- package/dist/plugin/appearance/index.cjs +344 -165
- package/dist/plugin/appearance/index.min.cjs +1 -1
- package/dist/plugin/appearance/index.min.mjs +1 -1
- package/dist/plugin/appearance/index.mjs +344 -165
- package/dist/plugin/appearance/index.umd.js +344 -165
- package/dist/plugin/appearance/index.umd.min.js +1 -1
- package/dist/plugin/appearance/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/appearance/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/appearance/src/types/native.d.ts +5 -5
- package/dist/plugin/clipboard/index.cjs +339 -160
- package/dist/plugin/clipboard/index.min.cjs +1 -1
- package/dist/plugin/clipboard/index.min.mjs +1 -1
- package/dist/plugin/clipboard/index.mjs +339 -160
- package/dist/plugin/clipboard/index.umd.js +339 -160
- package/dist/plugin/clipboard/index.umd.min.js +1 -1
- package/dist/plugin/clipboard/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/clipboard/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/clipboard/src/types/native.d.ts +5 -5
- package/dist/plugin/fullscreen/index.cjs +348 -169
- package/dist/plugin/fullscreen/index.min.cjs +1 -1
- package/dist/plugin/fullscreen/index.min.mjs +1 -1
- package/dist/plugin/fullscreen/index.mjs +348 -169
- package/dist/plugin/fullscreen/index.umd.js +348 -169
- package/dist/plugin/fullscreen/index.umd.min.js +1 -1
- package/dist/plugin/fullscreen/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/fullscreen/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/fullscreen/src/types/native.d.ts +5 -5
- package/dist/plugin/platform/index.cjs +339 -160
- package/dist/plugin/platform/index.d.ts +17 -7
- package/dist/plugin/platform/index.min.cjs +1 -1
- package/dist/plugin/platform/index.min.mjs +1 -1
- package/dist/plugin/platform/index.mjs +339 -160
- package/dist/plugin/platform/index.umd.js +339 -160
- package/dist/plugin/platform/index.umd.min.js +1 -1
- package/dist/plugin/platform/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/platform/src/types/native.d.ts +5 -5
- package/dist/plugin/theme/index.cjs +339 -160
- package/dist/plugin/theme/index.min.cjs +1 -1
- package/dist/plugin/theme/index.min.mjs +1 -1
- package/dist/plugin/theme/index.mjs +339 -160
- package/dist/plugin/theme/index.umd.js +339 -160
- package/dist/plugin/theme/index.umd.min.js +1 -1
- package/dist/plugin/theme/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/plugin/theme/src/types/native.d.ts +5 -5
- package/dist/src/plugin/platform/cores/index.d.ts +12 -0
- package/dist/src/plugin/platform/types/platform.d.ts +16 -6
- package/dist/src/types/native.d.ts +5 -5
- package/package.json +8 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Browsers, CrossPlatformFramework, Devices, Engines, OS } from "../constants";
|
|
2
2
|
export declare interface PlatformInstance {
|
|
3
|
-
os: OS
|
|
3
|
+
os: NameVersionPair<OS>;
|
|
4
|
+
engine: NameVersionPair<Engines>;
|
|
5
|
+
browser: NameVersionPair<Browsers>;
|
|
4
6
|
device: Devices;
|
|
5
|
-
engine: Engines;
|
|
6
|
-
browser: Browsers;
|
|
7
7
|
crossPlatformFramework: CrossPlatformFramework;
|
|
8
|
-
|
|
9
|
-
engineVersion: string;
|
|
10
|
-
browserVersion: string;
|
|
8
|
+
network: Network;
|
|
11
9
|
renderer: string;
|
|
12
10
|
userAgent: string;
|
|
13
11
|
isNode: boolean;
|
|
@@ -16,3 +14,15 @@ export declare interface PlatformInstance {
|
|
|
16
14
|
isDesktop: boolean;
|
|
17
15
|
isWebview: boolean;
|
|
18
16
|
}
|
|
17
|
+
export declare interface NameVersionPair<T> {
|
|
18
|
+
name: T;
|
|
19
|
+
version: string;
|
|
20
|
+
}
|
|
21
|
+
export declare interface Network {
|
|
22
|
+
isOnline: boolean | null;
|
|
23
|
+
effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | null;
|
|
24
|
+
type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | null;
|
|
25
|
+
downlink: number | null;
|
|
26
|
+
rtt: number | null;
|
|
27
|
+
saveData: boolean | null;
|
|
28
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PluginNotExtendedError } from "../errors/plugin-not-extended-error";
|
|
2
|
-
export interface NativePlugins {
|
|
2
|
+
export declare interface NativePlugins {
|
|
3
3
|
}
|
|
4
|
-
export interface NativeConstants extends Record<string, any> {
|
|
4
|
+
export declare interface NativeConstants extends Record<string, any> {
|
|
5
5
|
}
|
|
6
|
-
export interface NativeErrors extends Record<string, ErrorConstructor> {
|
|
6
|
+
export declare interface NativeErrors extends Record<string, ErrorConstructor> {
|
|
7
7
|
PluginNotExtendedError: typeof PluginNotExtendedError;
|
|
8
8
|
}
|
|
9
9
|
export declare interface NativePlugin<Key extends string, Module, Constants extends Record<string, any> = Record<string, any>, Errors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> {
|
|
@@ -13,10 +13,10 @@ export declare interface NativePlugin<Key extends string, Module, Constants exte
|
|
|
13
13
|
Constants: Constants;
|
|
14
14
|
Errors: Errors;
|
|
15
15
|
}
|
|
16
|
-
export type ExtendedNativeBase<Key extends string, Module, Constants extends Record<string, any> = Record<string, any>, Errors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> = NativeBase<NativePlugins & {
|
|
16
|
+
export declare type ExtendedNativeBase<Key extends string, Module, Constants extends Record<string, any> = Record<string, any>, Errors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> = NativeBase<NativePlugins & {
|
|
17
17
|
[Plugin in Key]: Module;
|
|
18
18
|
}, NativeConstants & Constants, NativeErrors & Errors>;
|
|
19
|
-
export type NativeBase<Plugins, AssignedConstants extends Record<string, any> = Record<string, any>, AssignedErrors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> = {
|
|
19
|
+
export declare type NativeBase<Plugins, AssignedConstants extends Record<string, any> = Record<string, any>, AssignedErrors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> = {
|
|
20
20
|
Version: string;
|
|
21
21
|
Constants: AssignedConstants;
|
|
22
22
|
Errors: AssignedErrors;
|
|
@@ -72,21 +72,43 @@ var CrossPlatformFramework;
|
|
|
72
72
|
var USER_AGENT = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
|
|
73
73
|
|
|
74
74
|
var Platform = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
browser: Browsers.Unknown,
|
|
75
|
+
os: { name: OS.Unknown, version: '' },
|
|
76
|
+
engine: { name: Engines.Unknown, version: '' },
|
|
77
|
+
browser: { name: Browsers.Unknown, version: '' },
|
|
79
78
|
crossPlatformFramework: CrossPlatformFramework.Unknown,
|
|
80
|
-
osVersion: '',
|
|
81
|
-
engineVersion: '',
|
|
82
|
-
browserVersion: '',
|
|
83
|
-
renderer: getRenderer(),
|
|
84
79
|
userAgent: USER_AGENT,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
get network() {
|
|
81
|
+
return getNetwork();
|
|
82
|
+
},
|
|
83
|
+
get device() {
|
|
84
|
+
if (this.os.name === OS.iOS || this.os.name === OS.Android)
|
|
85
|
+
return Devices.Mobile;
|
|
86
|
+
if (this.os.name === OS.Windows || this.os.name === OS.MacOS)
|
|
87
|
+
return Devices.Desktop;
|
|
88
|
+
return Devices.Unknown;
|
|
89
|
+
},
|
|
90
|
+
get renderer() {
|
|
91
|
+
return getRenderer();
|
|
92
|
+
},
|
|
93
|
+
get isMobile() {
|
|
94
|
+
return this.device === Devices.Mobile;
|
|
95
|
+
},
|
|
96
|
+
get isDesktop() {
|
|
97
|
+
return this.device === Devices.Desktop;
|
|
98
|
+
},
|
|
99
|
+
get isWebview() {
|
|
100
|
+
return /; ?wv|applewebkit(?!.*safari)/i.test(this.userAgent);
|
|
101
|
+
},
|
|
102
|
+
get isNode() {
|
|
103
|
+
return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
|
|
104
|
+
},
|
|
105
|
+
get isStandalone() {
|
|
106
|
+
if (this.os.name === OS.iOS)
|
|
107
|
+
return 'standalone' in globalThis.navigator && !!globalThis.navigator.standalone;
|
|
108
|
+
if (!('matchMedia' in globalThis))
|
|
109
|
+
return false;
|
|
110
|
+
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
111
|
+
},
|
|
90
112
|
};
|
|
91
113
|
var OS_RESOLVER_MAP = [
|
|
92
114
|
[/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
|
|
@@ -146,6 +168,14 @@ var BROWSER_RESOLVER_MAP = [
|
|
|
146
168
|
[/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
|
|
147
169
|
[/firefox\/([\w.]+)/i, Browsers.Firefox],
|
|
148
170
|
];
|
|
171
|
+
var HIGH_ENTROPY_BRAND_NAME_MAP = {
|
|
172
|
+
'Google Chrome': 'Chrome',
|
|
173
|
+
'Microsoft Edge': 'Edge',
|
|
174
|
+
'Microsoft Edge WebView2': 'Edge WebView2',
|
|
175
|
+
'Android WebView': 'Chrome WebView',
|
|
176
|
+
'HeadlessChrome': 'Chrome Headless',
|
|
177
|
+
'OperaMobile': 'Opera Mobi',
|
|
178
|
+
};
|
|
149
179
|
function resolveWindowsVersion(string) {
|
|
150
180
|
if (string === undefined)
|
|
151
181
|
return '';
|
|
@@ -320,6 +350,33 @@ function normalizeBrand(entry) {
|
|
|
320
350
|
return { brand: entry, version: '' };
|
|
321
351
|
return { brand: entry.brand, version: entry.version };
|
|
322
352
|
}
|
|
353
|
+
function getSemanticVersion(string) {
|
|
354
|
+
var parts = string.split('.');
|
|
355
|
+
return {
|
|
356
|
+
major: parseInt(parts[0] || '0'),
|
|
357
|
+
minor: parseInt(parts[1] || '0'),
|
|
358
|
+
build: parseInt(parts[2] || '0')
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function parseOSFromCordova() {
|
|
362
|
+
Platform.crossPlatformFramework = CrossPlatformFramework.Cordova;
|
|
363
|
+
if (typeof globalThis.device !== 'undefined') {
|
|
364
|
+
switch (globalThis.device.platform) {
|
|
365
|
+
case 'Android':
|
|
366
|
+
Platform.os = {
|
|
367
|
+
name: OS.Android,
|
|
368
|
+
version: globalThis.device.version,
|
|
369
|
+
};
|
|
370
|
+
break;
|
|
371
|
+
case 'iOS':
|
|
372
|
+
Platform.os = {
|
|
373
|
+
name: OS.iOS,
|
|
374
|
+
version: globalThis.device.version,
|
|
375
|
+
};
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
323
380
|
function getRenderer() {
|
|
324
381
|
if (typeof globalThis.document === 'undefined')
|
|
325
382
|
return '';
|
|
@@ -340,171 +397,293 @@ function getRenderer() {
|
|
|
340
397
|
return '';
|
|
341
398
|
}
|
|
342
399
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
var parts = string.split('.');
|
|
352
|
-
return {
|
|
353
|
-
major: parseInt(parts[0] || '0'),
|
|
354
|
-
minor: parseInt(parts[1] || '0'),
|
|
355
|
-
build: parseInt(parts[2] || '0')
|
|
400
|
+
function getNetwork() {
|
|
401
|
+
var network = {
|
|
402
|
+
isOnline: null,
|
|
403
|
+
effectiveType: null,
|
|
404
|
+
type: null,
|
|
405
|
+
downlink: null,
|
|
406
|
+
rtt: null,
|
|
407
|
+
saveData: null,
|
|
356
408
|
};
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if (typeof
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
break;
|
|
409
|
+
if (typeof globalThis.navigator !== 'undefined') {
|
|
410
|
+
if (typeof globalThis.navigator.onLine !== 'undefined')
|
|
411
|
+
network.isOnline = globalThis.navigator.onLine;
|
|
412
|
+
var connection = globalThis.navigator.connection || globalThis.navigator.mozConnection || globalThis.navigator.webkitConnection;
|
|
413
|
+
if (typeof connection !== 'undefined') {
|
|
414
|
+
if (typeof connection.effectiveType !== 'undefined')
|
|
415
|
+
network.effectiveType = connection.effectiveType;
|
|
416
|
+
if (typeof connection.type !== 'undefined')
|
|
417
|
+
network.type = connection.type;
|
|
418
|
+
if (typeof connection.downlink !== 'undefined')
|
|
419
|
+
network.downlink = connection.downlink;
|
|
420
|
+
if (typeof connection.rtt !== 'undefined')
|
|
421
|
+
network.rtt = connection.rtt;
|
|
422
|
+
if (typeof connection.saveData !== 'undefined')
|
|
423
|
+
network.saveData = connection.saveData;
|
|
424
|
+
}
|
|
374
425
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
426
|
+
if (Platform.isNode) {
|
|
427
|
+
try {
|
|
428
|
+
var os = require('os');
|
|
429
|
+
var networkInterfaces = os.networkInterfaces();
|
|
430
|
+
var networkInterfaceNames = Object.keys(networkInterfaces);
|
|
431
|
+
for (var i = 0; i < networkInterfaceNames.length; i++) {
|
|
432
|
+
var name_1 = networkInterfaceNames[i];
|
|
433
|
+
var networkInterface = networkInterfaces[name_1];
|
|
434
|
+
for (var j = 0; j < networkInterface.length; j++) {
|
|
435
|
+
var address = networkInterface[j];
|
|
436
|
+
if (!address.internal && address.family === 'IPv4')
|
|
437
|
+
network.isOnline = true;
|
|
438
|
+
}
|
|
439
|
+
if (network.isOnline)
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch (_) {
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
var childProcess = require('child_process');
|
|
447
|
+
if (Platform.os.name === OS.Windows) {
|
|
448
|
+
try {
|
|
449
|
+
var output = childProcess.execSync('netsh wlan show interfaces', { encoding: 'utf8', timeout: 5000 });
|
|
450
|
+
if (output.includes('State') && output.includes('connected'))
|
|
451
|
+
network.type = 'wifi';
|
|
452
|
+
}
|
|
453
|
+
catch (_) {
|
|
454
|
+
}
|
|
455
|
+
if (network.type === null) {
|
|
456
|
+
try {
|
|
457
|
+
var output = childProcess.execSync('ipconfig', { encoding: 'utf8', timeout: 5000 });
|
|
458
|
+
if (output.includes('Ethernet adapter'))
|
|
459
|
+
network.type = 'ethernet';
|
|
460
|
+
}
|
|
461
|
+
catch (_) {
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (network.type === null)
|
|
465
|
+
network.type = 'other';
|
|
466
|
+
}
|
|
467
|
+
else if (Platform.os.name === OS.MacOS) {
|
|
468
|
+
try {
|
|
469
|
+
var output = childProcess.execSync('networksetup -listallhardwareports', { encoding: 'utf8', timeout: 5000 });
|
|
470
|
+
var activeInterface = childProcess.execSync('route -n get default | grep interface', { encoding: 'utf8', timeout: 5000 });
|
|
471
|
+
if (activeInterface.includes('en0') && output.includes('Wi-Fi'))
|
|
472
|
+
network.type = 'wifi';
|
|
473
|
+
else if (activeInterface.includes('en') || output.includes('Ethernet'))
|
|
474
|
+
network.type = 'ethernet';
|
|
475
|
+
else
|
|
476
|
+
network.type = 'other';
|
|
477
|
+
}
|
|
478
|
+
catch (_) {
|
|
479
|
+
network.type = 'other';
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
catch (_) {
|
|
484
|
+
}
|
|
391
485
|
}
|
|
486
|
+
return network;
|
|
392
487
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
var regexp = map[0];
|
|
396
|
-
var browser = map[1];
|
|
397
|
-
var resolver = map[2];
|
|
398
|
-
var matched = Platform.userAgent.match(regexp);
|
|
399
|
-
if (matched !== null) {
|
|
400
|
-
Platform.browser = browser;
|
|
401
|
-
Platform.browserVersion = resolveVersion(matched[1], resolver);
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
488
|
+
function canUseHighEntropyValues(navigator) {
|
|
489
|
+
return typeof globalThis.navigator !== 'undefined' && typeof navigator.userAgentData !== 'undefined' && typeof navigator.userAgentData.getHighEntropyValues !== 'undefined';
|
|
404
490
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
Platform.os = OS.Windows;
|
|
423
|
-
Platform.osVersion = resolveSemanticWindowsVersion(version, release);
|
|
424
|
-
break;
|
|
425
|
-
case 'macos':
|
|
426
|
-
Platform.os = OS.MacOS;
|
|
427
|
-
Platform.osVersion = release;
|
|
428
|
-
break;
|
|
491
|
+
function init() {
|
|
492
|
+
if ((typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(USER_AGENT)))
|
|
493
|
+
Platform.crossPlatformFramework = CrossPlatformFramework.Electron;
|
|
494
|
+
if (typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative')
|
|
495
|
+
Platform.crossPlatformFramework = CrossPlatformFramework.ReactNative;
|
|
496
|
+
for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
497
|
+
var map = OS_RESOLVER_MAP[i];
|
|
498
|
+
var regexp = map[0];
|
|
499
|
+
var os = map[1];
|
|
500
|
+
var resolver = map[2];
|
|
501
|
+
var matched = Platform.userAgent.match(regexp);
|
|
502
|
+
if (matched !== null) {
|
|
503
|
+
Platform.os = {
|
|
504
|
+
name: os,
|
|
505
|
+
version: resolveVersion(matched[1], resolver),
|
|
506
|
+
};
|
|
507
|
+
break;
|
|
429
508
|
}
|
|
430
509
|
}
|
|
431
|
-
|
|
510
|
+
if (Platform.os.name === OS.iOS && compareVersion(Platform.os.version, '18.6') === 0) {
|
|
511
|
+
var version = /\) Version\/([\d.]+)/.exec(Platform.userAgent);
|
|
512
|
+
if (version !== null && parseInt(version[1].substring(0, 2), 10) >= 26)
|
|
513
|
+
Platform.os.version = version[1];
|
|
432
514
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
var
|
|
437
|
-
var
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
case 'darwin':
|
|
446
|
-
Platform.os = OS.MacOS;
|
|
447
|
-
Platform.osVersion = resolveSemanticDarwinVersion(version, release);
|
|
448
|
-
break;
|
|
449
|
-
case 'android':
|
|
450
|
-
Platform.os = OS.Android;
|
|
451
|
-
Platform.osVersion = release;
|
|
452
|
-
break;
|
|
453
|
-
case 'linux':
|
|
454
|
-
if (/android/i.test(release)) {
|
|
455
|
-
Platform.os = OS.Android;
|
|
456
|
-
Platform.osVersion = release;
|
|
457
|
-
}
|
|
458
|
-
break;
|
|
515
|
+
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
516
|
+
var map = ENGINE_RESOLVER_MAP[i];
|
|
517
|
+
var regexp = map[0];
|
|
518
|
+
var engine = map[1];
|
|
519
|
+
var resolver = map[2];
|
|
520
|
+
var matched = Platform.userAgent.match(regexp);
|
|
521
|
+
if (matched !== null) {
|
|
522
|
+
Platform.engine = {
|
|
523
|
+
name: engine,
|
|
524
|
+
version: resolveVersion(matched[1], resolver),
|
|
525
|
+
};
|
|
526
|
+
break;
|
|
459
527
|
}
|
|
460
528
|
}
|
|
461
|
-
|
|
529
|
+
for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
530
|
+
var map = BROWSER_RESOLVER_MAP[i];
|
|
531
|
+
var regexp = map[0];
|
|
532
|
+
var browser = map[1];
|
|
533
|
+
var resolver = map[2];
|
|
534
|
+
var matched = Platform.userAgent.match(regexp);
|
|
535
|
+
if (matched !== null) {
|
|
536
|
+
Platform.browser = {
|
|
537
|
+
name: browser,
|
|
538
|
+
version: resolveVersion(matched[1], resolver),
|
|
539
|
+
};
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
462
542
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
543
|
+
if (Platform.crossPlatformFramework === CrossPlatformFramework.ReactNative) {
|
|
544
|
+
try {
|
|
545
|
+
var reactNative = require('react-native');
|
|
546
|
+
var platform = reactNative.Platform;
|
|
547
|
+
var os = platform.OS;
|
|
548
|
+
var release = '' + platform.Version;
|
|
549
|
+
var version = getSemanticVersion(release);
|
|
550
|
+
switch (os) {
|
|
551
|
+
case 'android':
|
|
552
|
+
Platform.os = {
|
|
553
|
+
name: OS.Android,
|
|
554
|
+
version: resolveSemanticAndroidVersion(version, release),
|
|
555
|
+
};
|
|
556
|
+
break;
|
|
557
|
+
case 'ios':
|
|
558
|
+
Platform.os = {
|
|
559
|
+
name: OS.iOS,
|
|
560
|
+
version: release,
|
|
561
|
+
};
|
|
471
562
|
break;
|
|
472
|
-
case '
|
|
473
|
-
Platform.os =
|
|
563
|
+
case 'windows':
|
|
564
|
+
Platform.os = {
|
|
565
|
+
name: OS.Windows,
|
|
566
|
+
version: resolveSemanticWindowsVersion(version, release),
|
|
567
|
+
};
|
|
568
|
+
break;
|
|
569
|
+
case 'macos':
|
|
570
|
+
Platform.os = {
|
|
571
|
+
name: OS.MacOS,
|
|
572
|
+
version: release,
|
|
573
|
+
};
|
|
474
574
|
break;
|
|
475
575
|
}
|
|
476
|
-
Platform.osVersion = globalThis.device.version;
|
|
477
576
|
}
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
var
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
577
|
+
catch (_) {
|
|
578
|
+
}
|
|
579
|
+
finally {
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (Platform.isNode) {
|
|
583
|
+
try {
|
|
584
|
+
var os = require('os');
|
|
585
|
+
var platform = os.platform();
|
|
586
|
+
var release = os.release();
|
|
587
|
+
var version = getSemanticVersion(release);
|
|
588
|
+
switch (platform) {
|
|
589
|
+
case 'win32':
|
|
590
|
+
Platform.os = {
|
|
591
|
+
name: OS.Windows,
|
|
592
|
+
version: resolveSemanticWindowsVersion(version, release),
|
|
593
|
+
};
|
|
594
|
+
break;
|
|
595
|
+
case 'darwin':
|
|
596
|
+
Platform.os = {
|
|
597
|
+
name: OS.MacOS,
|
|
598
|
+
version: resolveSemanticDarwinVersion(version, release),
|
|
599
|
+
};
|
|
600
|
+
break;
|
|
601
|
+
case 'android':
|
|
602
|
+
Platform.os = {
|
|
603
|
+
name: OS.Android,
|
|
604
|
+
version: release,
|
|
605
|
+
};
|
|
606
|
+
break;
|
|
607
|
+
case 'linux':
|
|
608
|
+
if (/android/i.test(release)) {
|
|
609
|
+
Platform.os = {
|
|
610
|
+
name: OS.Android,
|
|
611
|
+
version: release,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
495
616
|
}
|
|
496
|
-
|
|
497
|
-
if (Platform.os === OS.Windows && parseInt(platformVersion.replace(/[^\d.]/g, '').split('.')[0], 10) >= 13)
|
|
498
|
-
Platform.osVersion = '11';
|
|
499
|
-
else
|
|
500
|
-
Platform.osVersion = platformVersion;
|
|
617
|
+
catch (_) {
|
|
501
618
|
}
|
|
502
|
-
|
|
619
|
+
finally {
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (typeof globalThis.document !== 'undefined') {
|
|
623
|
+
if (typeof globalThis.device !== 'undefined') {
|
|
624
|
+
parseOSFromCordova();
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
globalThis.document.addEventListener("deviceready", parseOSFromCordova, false);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (canUseHighEntropyValues(globalThis.navigator)) {
|
|
631
|
+
globalThis
|
|
632
|
+
.navigator
|
|
633
|
+
.userAgentData
|
|
634
|
+
.getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
|
|
635
|
+
.then(function (result) {
|
|
636
|
+
var brands = result.fullVersionList || result.brands || [];
|
|
637
|
+
var platformVersion = result.platformVersion;
|
|
638
|
+
var platform = result.platform;
|
|
639
|
+
var browserName = Platform.browser.name;
|
|
640
|
+
var prevBrandName = null;
|
|
641
|
+
for (var i = 0; i < brands.length; i++) {
|
|
642
|
+
var brand = normalizeBrand(brands[i]);
|
|
643
|
+
var brandVersion = brand.version;
|
|
644
|
+
var brandName = brand.brand;
|
|
645
|
+
if (/not.a.brand/i.test(brandName))
|
|
646
|
+
continue;
|
|
647
|
+
if (prevBrandName === null || (/Chrom/.test(prevBrandName) && brandName !== 'Chromium') || (prevBrandName === 'Edge' && /WebView2/.test(brandName))) {
|
|
648
|
+
brandName = HIGH_ENTROPY_BRAND_NAME_MAP[brandName] || brandName;
|
|
649
|
+
prevBrandName = browserName;
|
|
650
|
+
if (prevBrandName === null || /Chrom/.test(prevBrandName) || !/Chrom/.test(brandName)) {
|
|
651
|
+
browserName = brandName;
|
|
652
|
+
if (browserName === 'Chrome' || browserName === 'Chrome WebView' || browserName === 'Chrome Headless')
|
|
653
|
+
Platform.browser.name = Browsers.Chrome;
|
|
654
|
+
else if (browserName === 'Edge' || browserName === 'Edge WebView2')
|
|
655
|
+
Platform.browser.name = Browsers.Edge;
|
|
656
|
+
else if (browserName === 'Opera Mobi')
|
|
657
|
+
Platform.browser.name = Browsers.Opera;
|
|
658
|
+
Platform.browser.version = brandVersion;
|
|
659
|
+
}
|
|
660
|
+
prevBrandName = brandName;
|
|
661
|
+
}
|
|
662
|
+
if (brandName === 'Chromium')
|
|
663
|
+
Platform.engine.version = brandVersion;
|
|
664
|
+
}
|
|
665
|
+
if (typeof platformVersion === 'string') {
|
|
666
|
+
if (Platform.os.name === OS.Windows)
|
|
667
|
+
Platform.os.version = parseInt(platformVersion.split('.')[0], 10) >= 13 ? '11' : '10';
|
|
668
|
+
else
|
|
669
|
+
Platform.os.version = platformVersion;
|
|
670
|
+
}
|
|
671
|
+
if (typeof platform === 'string') {
|
|
672
|
+
if (/android/i.test(platform))
|
|
673
|
+
Platform.os.name = OS.Android;
|
|
674
|
+
else if (/ios|iphone|ipad/i.test(platform))
|
|
675
|
+
Platform.os.name = OS.iOS;
|
|
676
|
+
else if (/windows|win32/i.test(platform))
|
|
677
|
+
Platform.os.name = OS.Windows;
|
|
678
|
+
else if (/macos|macintel/i.test(platform))
|
|
679
|
+
Platform.os.name = OS.MacOS;
|
|
680
|
+
}
|
|
681
|
+
if (result.mobile === true)
|
|
682
|
+
Platform.device = Devices.Mobile;
|
|
683
|
+
});
|
|
684
|
+
}
|
|
503
685
|
}
|
|
504
|
-
|
|
505
|
-
Platform.isMobile = Platform.device === Devices.Mobile;
|
|
506
|
-
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
507
|
-
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
686
|
+
init();
|
|
508
687
|
|
|
509
688
|
var IS_IE_MOBILE = /iemobile/i.test(Platform.userAgent);
|
|
510
689
|
var IS_WINDOWS_PHONE = /windows phone/i.test(Platform.userAgent);
|