@@ -27,60 +27,62 @@ const {
27
27
} = internalBinding ( 'os' ) ;
28
28
29
29
const kInitialize = Symbol ( 'kInitialize' ) ;
30
- const nodeVersion = process . version ;
30
+ const nodeVersion = require ( 'internal/process/version' ) ;
31
+ const platform = require ( 'internal/process/platform' ) ;
32
+ const arch = require ( 'internal/process/arch' ) ;
31
33
32
34
/**
33
35
* @param {object } process
34
36
* @param {string } process.platform
35
37
* @param {string } process.arch
36
38
* @returns {string }
37
39
*/
38
- function getNavigatorPlatform ( process ) {
39
- if ( process . platform === 'darwin' ) {
40
+ function getNavigatorPlatform ( { platform , arch } ) {
41
+ if ( platform === 'darwin' ) {
40
42
// On macOS, modern browsers return 'MacIntel' even if running on Apple Silicon.
41
43
return 'MacIntel' ;
42
- } else if ( process . platform === 'win32' ) {
44
+ } else if ( platform === 'win32' ) {
43
45
// On Windows, modern browsers return 'Win32' even if running on a 64-bit version of Windows.
44
46
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform#usage_notes
45
47
return 'Win32' ;
46
- } else if ( process . platform === 'linux' ) {
47
- if ( process . arch === 'ia32' ) {
48
+ } else if ( platform === 'linux' ) {
49
+ if ( arch === 'ia32' ) {
48
50
return 'Linux i686' ;
49
- } else if ( process . arch === 'x64' ) {
51
+ } else if ( arch === 'x64' ) {
50
52
return 'Linux x86_64' ;
51
53
}
52
- return `Linux ${ process . arch } ` ;
53
- } else if ( process . platform === 'freebsd' ) {
54
- if ( process . arch === 'ia32' ) {
54
+ return `Linux ${ arch } ` ;
55
+ } else if ( platform === 'freebsd' ) {
56
+ if ( arch === 'ia32' ) {
55
57
return 'FreeBSD i386' ;
56
- } else if ( process . arch === 'x64' ) {
58
+ } else if ( arch === 'x64' ) {
57
59
return 'FreeBSD amd64' ;
58
60
}
59
- return `FreeBSD ${ process . arch } ` ;
60
- } else if ( process . platform === 'openbsd' ) {
61
- if ( process . arch === 'ia32' ) {
61
+ return `FreeBSD ${ arch } ` ;
62
+ } else if ( platform === 'openbsd' ) {
63
+ if ( arch === 'ia32' ) {
62
64
return 'OpenBSD i386' ;
63
- } else if ( process . arch === 'x64' ) {
65
+ } else if ( arch === 'x64' ) {
64
66
return 'OpenBSD amd64' ;
65
67
}
66
- return `OpenBSD ${ process . arch } ` ;
67
- } else if ( process . platform === 'sunos' ) {
68
- if ( process . arch === 'ia32' ) {
68
+ return `OpenBSD ${ arch } ` ;
69
+ } else if ( platform === 'sunos' ) {
70
+ if ( arch === 'ia32' ) {
69
71
return 'SunOS i86pc' ;
70
72
}
71
- return `SunOS ${ process . arch } ` ;
72
- } else if ( process . platform === 'aix' ) {
73
+ return `SunOS ${ arch } ` ;
74
+ } else if ( platform === 'aix' ) {
73
75
return 'AIX' ;
74
76
}
75
- return `${ StringPrototypeToUpperCase ( process . platform [ 0 ] ) } ${ StringPrototypeSlice ( process . platform , 1 ) } ${ process . arch } ` ;
77
+ return `${ StringPrototypeToUpperCase ( platform [ 0 ] ) } ${ StringPrototypeSlice ( platform , 1 ) } ${ arch } ` ;
76
78
}
77
79
78
80
class Navigator {
79
81
// Private properties are used to avoid brand validations.
80
82
#availableParallelism;
81
83
#userAgent;
82
84
#platform;
83
- #language;
85
+ #language = Intl ?. Collator ( ) . resolvedOptions ( ) . locale || 'en-US' ;
84
86
#languages;
85
87
86
88
constructor ( ) {
@@ -102,7 +104,6 @@ class Navigator {
102
104
* @return {string }
103
105
*/
104
106
get language ( ) {
105
- this . #language ??= Intl ?. Collator ( ) . resolvedOptions ( ) . locale || 'en-US' ;
106
107
return this . #language;
107
108
}
108
109
@@ -126,7 +127,7 @@ class Navigator {
126
127
* @return {string }
127
128
*/
128
129
get platform ( ) {
129
- this . #platform ??= getNavigatorPlatform ( process ) ;
130
+ this . #platform ??= getNavigatorPlatform ( { arch , platform } ) ;
130
131
return this . #platform;
131
132
}
132
133
}
0 commit comments