ee-core 4.1.4 → 4.1.5

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.
Files changed (131) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/app/application.d.ts +5 -5
  4. package/app/application.js +30 -30
  5. package/app/boot.d.ts +5 -5
  6. package/app/boot.js +80 -80
  7. package/app/dir.d.ts +1 -1
  8. package/app/dir.js +26 -26
  9. package/app/events.d.ts +14 -14
  10. package/app/events.js +55 -55
  11. package/app/index.d.ts +2 -2
  12. package/app/index.js +6 -6
  13. package/config/config_loader.d.ts +13 -13
  14. package/config/config_loader.js +65 -65
  15. package/config/default_config.d.ts +95 -95
  16. package/config/default_config.js +111 -111
  17. package/config/index.d.ts +28 -28
  18. package/config/index.js +24 -24
  19. package/const/channel.d.ts +16 -16
  20. package/const/channel.js +27 -27
  21. package/controller/controller_loader.d.ts +9 -9
  22. package/controller/controller_loader.js +77 -77
  23. package/controller/index.d.ts +2 -2
  24. package/controller/index.js +24 -24
  25. package/core/index.d.ts +2 -2
  26. package/core/index.js +11 -11
  27. package/core/loader/file_loader.d.ts +66 -66
  28. package/core/loader/file_loader.js +211 -211
  29. package/core/utils/index.d.ts +12 -12
  30. package/core/utils/index.js +83 -83
  31. package/core/utils/timing.d.ts +22 -22
  32. package/core/utils/timing.js +78 -78
  33. package/cross/cross.d.ts +19 -19
  34. package/cross/cross.js +152 -151
  35. package/cross/crossProcess.d.ts +29 -29
  36. package/cross/crossProcess.js +172 -172
  37. package/cross/index.d.ts +2 -2
  38. package/cross/index.js +8 -8
  39. package/electron/app/index.d.ts +5 -5
  40. package/electron/app/index.js +48 -48
  41. package/electron/index.d.ts +3 -3
  42. package/electron/index.js +15 -15
  43. package/electron/window/index.d.ts +6 -6
  44. package/electron/window/index.js +268 -268
  45. package/exception/index.d.ts +9 -9
  46. package/exception/index.js +100 -100
  47. package/html/boot.html +98 -98
  48. package/html/cross-failure.html +28 -28
  49. package/html/failure.html +28 -28
  50. package/html/index.d.ts +1 -1
  51. package/html/index.js +10 -10
  52. package/index.d.ts +2 -2
  53. package/index.js +6 -6
  54. package/jobs/child/app.d.ts +1 -1
  55. package/jobs/child/app.js +69 -69
  56. package/jobs/child/index.d.ts +13 -13
  57. package/jobs/child/index.js +85 -85
  58. package/jobs/child/jobProcess.d.ts +16 -16
  59. package/jobs/child/jobProcess.js +133 -133
  60. package/jobs/child-pool/index.d.ts +26 -26
  61. package/jobs/child-pool/index.js +190 -190
  62. package/jobs/index.d.ts +3 -3
  63. package/jobs/index.js +6 -6
  64. package/jobs/load-balancer/algorithm/index.d.ts +4 -4
  65. package/jobs/load-balancer/algorithm/index.js +11 -11
  66. package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
  67. package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
  68. package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
  69. package/jobs/load-balancer/algorithm/polling.js +11 -11
  70. package/jobs/load-balancer/algorithm/random.d.ts +2 -2
  71. package/jobs/load-balancer/algorithm/random.js +9 -9
  72. package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
  73. package/jobs/load-balancer/algorithm/specify.js +14 -14
  74. package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
  75. package/jobs/load-balancer/algorithm/weights.js +21 -21
  76. package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
  77. package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
  78. package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
  79. package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
  80. package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
  81. package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
  82. package/jobs/load-balancer/consts.d.ts +8 -8
  83. package/jobs/load-balancer/consts.js +9 -9
  84. package/jobs/load-balancer/index.d.ts +96 -96
  85. package/jobs/load-balancer/index.js +201 -201
  86. package/jobs/load-balancer/scheduler.d.ts +16 -16
  87. package/jobs/load-balancer/scheduler.js +31 -31
  88. package/loader/index.d.ts +9 -9
  89. package/loader/index.js +99 -99
  90. package/log/index.d.ts +5 -5
  91. package/log/index.js +85 -85
  92. package/log/logger.d.ts +1 -1
  93. package/log/logger.js +94 -94
  94. package/message/childMessage.d.ts +10 -10
  95. package/message/childMessage.js +43 -43
  96. package/message/index.d.ts +3 -3
  97. package/message/index.js +9 -9
  98. package/package.json +42 -42
  99. package/ps/index.d.ts +39 -39
  100. package/ps/index.js +294 -294
  101. package/socket/httpServer.d.ts +8 -8
  102. package/socket/httpServer.js +199 -199
  103. package/socket/index.d.ts +10 -10
  104. package/socket/index.js +64 -64
  105. package/socket/ipcServer.d.ts +9 -9
  106. package/socket/ipcServer.js +105 -105
  107. package/socket/socketServer.d.ts +10 -10
  108. package/socket/socketServer.js +81 -81
  109. package/storage/index.d.ts +4 -4
  110. package/storage/index.js +6 -6
  111. package/storage/sqliteStorage.d.ts +16 -16
  112. package/storage/sqliteStorage.js +123 -123
  113. package/tsconfig.json +13 -13
  114. package/utils/extend.d.ts +2 -2
  115. package/utils/extend.js +77 -77
  116. package/utils/helper.d.ts +14 -14
  117. package/utils/helper.js +206 -206
  118. package/utils/index.d.ts +11 -10
  119. package/utils/index.js +198 -167
  120. package/utils/ip.d.ts +2 -2
  121. package/utils/ip.js +221 -221
  122. package/utils/is.d.ts +14 -14
  123. package/utils/is.js +111 -111
  124. package/utils/json.d.ts +5 -5
  125. package/utils/json.js +79 -79
  126. package/utils/pargv.d.ts +3 -3
  127. package/utils/pargv.js +267 -267
  128. package/utils/port/index.d.ts +1 -1
  129. package/utils/port/index.js +125 -125
  130. package/utils/wrap.d.ts +4 -4
  131. package/utils/wrap.js +40 -40
package/utils/ip.js CHANGED
@@ -1,221 +1,221 @@
1
- const { promisify } = require('util');
2
- const dgram = require('dgram');
3
- const { isIPv6, isIPv4 } = require('net');
4
- const dns = require('dns-socket');
5
- const HttpClient = require('../httpclient');
6
-
7
- const emptyIP = '';
8
- const defaults = {
9
- timeout: 3000,
10
- type: 'http', // 'http' | 'dns' | 'all'
11
- };
12
-
13
- const dnsServers = [
14
- {
15
- v4: {
16
- servers: [
17
- '208.67.222.222',
18
- '208.67.220.220',
19
- '208.67.222.220',
20
- '208.67.220.222',
21
- ],
22
- name: 'myip.opendns.com',
23
- type: 'A',
24
- },
25
- v6: {
26
- servers: [
27
- '2620:0:ccc::2',
28
- '2620:0:ccd::2',
29
- ],
30
- name: 'myip.opendns.com',
31
- type: 'AAAA',
32
- },
33
- },
34
- ];
35
-
36
- const type = {
37
- v4: {
38
- dnsServers: dnsServers.map(({v4: {servers, ...question}}) => ({
39
- servers, question,
40
- })),
41
- httpsUrls: [
42
- 'https://icanhazip.com/',
43
- 'https://api.ipify.org/',
44
- ],
45
- },
46
- v6: {
47
- dnsServers: dnsServers.map(({v6: {servers, ...question}}) => ({
48
- servers, question,
49
- })),
50
- httpsUrls: [
51
- 'https://icanhazip.com/',
52
- 'https://api6.ipify.org/',
53
- ],
54
- },
55
- };
56
-
57
- const queryDns = (version, options) => {
58
- const data = type[version];
59
- const socket = dns({
60
- retries: 0,
61
- maxQueries: 1,
62
- socket: dgram.createSocket(version === 'v6' ? 'udp6' : 'udp4'),
63
- timeout: options.timeout,
64
- });
65
-
66
- const socketQuery = promisify(socket.query.bind(socket));
67
- const promise = (async () => {
68
- for (const dnsServerInfo of data.dnsServers) {
69
- const {servers, question} = dnsServerInfo;
70
- for (const server of servers) {
71
- if (socket.destroyed) {
72
- return emptyIP;
73
- }
74
-
75
- try {
76
- const {name, type, transform} = question;
77
- const dnsResponse = await socketQuery({questions: [{name, type}]}, 53, server);
78
-
79
- const {
80
- answers: {
81
- 0: {
82
- data,
83
- },
84
- },
85
- } = dnsResponse;
86
- const response = (typeof data === 'string' ? data : data.toString()).trim();
87
- const ip = (transform && version === 'v6') ? transform(response) : response;
88
- const method = version === 'v6' ? isIPv6 : isIPv4;
89
-
90
- if (ip && method(ip)) {
91
- socket.destroy();
92
- return ip;
93
- }
94
- } catch (error) {
95
- // Log.coreLogger.error('[ee-core] [utils/ip] queryDns error:', error);
96
- }
97
- }
98
- }
99
-
100
- socket.destroy();
101
- return emptyIP;
102
- })();
103
-
104
- promise.cancel = () => {
105
- socket.destroy();
106
- };
107
-
108
- return promise;
109
- };
110
-
111
- const queryHttps = (version, options) => {
112
- let cancel;
113
- const hc = new HttpClient();
114
-
115
- const promise = (async () => {
116
- const requestOptions = {
117
- method: 'GET',
118
- timeout: options.timeout,
119
- dataType: 'text',
120
- };
121
-
122
- const urls = [
123
- ...type[version].httpsUrls,
124
- ...(options.fallbackUrls ?? []),
125
- ];
126
-
127
- for (const url of urls) {
128
- try {
129
- const gotPromise = hc.request(url, requestOptions);
130
- gotPromise.cancel = () => {
131
- // ..
132
- }
133
- cancel = gotPromise.cancel;
134
-
135
- const response = await gotPromise;
136
- let result = response.status == 200 ? response.data : '';
137
- const ip = result.trim();
138
-
139
- const method = version === 'v6' ? isIPv6 : isIPv4;
140
-
141
- if (ip && method(ip)) {
142
- return ip;
143
- }
144
- } catch (error) {
145
- //Log.coreLogger.error('[ee-core] [utils/ip] queryHttps error:', error);
146
- }
147
- }
148
-
149
- return emptyIP;
150
- })();
151
-
152
- promise.cancel = function () {
153
- return cancel.apply(this);
154
- };
155
-
156
- return promise;
157
- };
158
-
159
- const queryAll = (version, options) => {
160
- let cancel;
161
- const promise = (async () => {
162
- let response;
163
- const dnsPromise = queryDns(version, options);
164
- cancel = dnsPromise.cancel;
165
- try {
166
- response = await dnsPromise;
167
- } catch {
168
- const httpsPromise = queryHttps(version, options);
169
- cancel = httpsPromise.cancel;
170
- response = await httpsPromise;
171
- }
172
-
173
- return response;
174
- })();
175
-
176
- promise.cancel = cancel;
177
-
178
- return promise;
179
- };
180
-
181
- // 查询 public ipv4
182
- function publicIpv4(options) {
183
- options = {
184
- ...defaults,
185
- ...options,
186
- };
187
-
188
- if (options.type == 'http') {
189
- return queryHttps('v4', options);
190
- }
191
-
192
- if (options.type == 'dns') {
193
- return queryDns('v4', options);
194
- }
195
-
196
- return queryAll('v4', options);
197
- }
198
-
199
- // 查询public ipv6
200
- function publicIpv6(options) {
201
- options = {
202
- ...defaults,
203
- ...options,
204
- };
205
-
206
- if (options.type == 'http') {
207
- return queryHttps('v6', options);
208
- }
209
-
210
- if (options.type == 'dns') {
211
- return queryDns('v6', options);
212
- }
213
-
214
- return queryAll('v6', options);
215
- }
216
-
217
- module.exports = {
218
- publicIpv4,
219
- publicIpv6
220
- };
221
-
1
+ const { promisify } = require('util');
2
+ const dgram = require('dgram');
3
+ const { isIPv6, isIPv4 } = require('net');
4
+ const dns = require('dns-socket');
5
+ const HttpClient = require('../httpclient');
6
+
7
+ const emptyIP = '';
8
+ const defaults = {
9
+ timeout: 3000,
10
+ type: 'http', // 'http' | 'dns' | 'all'
11
+ };
12
+
13
+ const dnsServers = [
14
+ {
15
+ v4: {
16
+ servers: [
17
+ '208.67.222.222',
18
+ '208.67.220.220',
19
+ '208.67.222.220',
20
+ '208.67.220.222',
21
+ ],
22
+ name: 'myip.opendns.com',
23
+ type: 'A',
24
+ },
25
+ v6: {
26
+ servers: [
27
+ '2620:0:ccc::2',
28
+ '2620:0:ccd::2',
29
+ ],
30
+ name: 'myip.opendns.com',
31
+ type: 'AAAA',
32
+ },
33
+ },
34
+ ];
35
+
36
+ const type = {
37
+ v4: {
38
+ dnsServers: dnsServers.map(({v4: {servers, ...question}}) => ({
39
+ servers, question,
40
+ })),
41
+ httpsUrls: [
42
+ 'https://icanhazip.com/',
43
+ 'https://api.ipify.org/',
44
+ ],
45
+ },
46
+ v6: {
47
+ dnsServers: dnsServers.map(({v6: {servers, ...question}}) => ({
48
+ servers, question,
49
+ })),
50
+ httpsUrls: [
51
+ 'https://icanhazip.com/',
52
+ 'https://api6.ipify.org/',
53
+ ],
54
+ },
55
+ };
56
+
57
+ const queryDns = (version, options) => {
58
+ const data = type[version];
59
+ const socket = dns({
60
+ retries: 0,
61
+ maxQueries: 1,
62
+ socket: dgram.createSocket(version === 'v6' ? 'udp6' : 'udp4'),
63
+ timeout: options.timeout,
64
+ });
65
+
66
+ const socketQuery = promisify(socket.query.bind(socket));
67
+ const promise = (async () => {
68
+ for (const dnsServerInfo of data.dnsServers) {
69
+ const {servers, question} = dnsServerInfo;
70
+ for (const server of servers) {
71
+ if (socket.destroyed) {
72
+ return emptyIP;
73
+ }
74
+
75
+ try {
76
+ const {name, type, transform} = question;
77
+ const dnsResponse = await socketQuery({questions: [{name, type}]}, 53, server);
78
+
79
+ const {
80
+ answers: {
81
+ 0: {
82
+ data,
83
+ },
84
+ },
85
+ } = dnsResponse;
86
+ const response = (typeof data === 'string' ? data : data.toString()).trim();
87
+ const ip = (transform && version === 'v6') ? transform(response) : response;
88
+ const method = version === 'v6' ? isIPv6 : isIPv4;
89
+
90
+ if (ip && method(ip)) {
91
+ socket.destroy();
92
+ return ip;
93
+ }
94
+ } catch (error) {
95
+ // Log.coreLogger.error('[ee-core] [utils/ip] queryDns error:', error);
96
+ }
97
+ }
98
+ }
99
+
100
+ socket.destroy();
101
+ return emptyIP;
102
+ })();
103
+
104
+ promise.cancel = () => {
105
+ socket.destroy();
106
+ };
107
+
108
+ return promise;
109
+ };
110
+
111
+ const queryHttps = (version, options) => {
112
+ let cancel;
113
+ const hc = new HttpClient();
114
+
115
+ const promise = (async () => {
116
+ const requestOptions = {
117
+ method: 'GET',
118
+ timeout: options.timeout,
119
+ dataType: 'text',
120
+ };
121
+
122
+ const urls = [
123
+ ...type[version].httpsUrls,
124
+ ...(options.fallbackUrls ?? []),
125
+ ];
126
+
127
+ for (const url of urls) {
128
+ try {
129
+ const gotPromise = hc.request(url, requestOptions);
130
+ gotPromise.cancel = () => {
131
+ // ..
132
+ }
133
+ cancel = gotPromise.cancel;
134
+
135
+ const response = await gotPromise;
136
+ let result = response.status == 200 ? response.data : '';
137
+ const ip = result.trim();
138
+
139
+ const method = version === 'v6' ? isIPv6 : isIPv4;
140
+
141
+ if (ip && method(ip)) {
142
+ return ip;
143
+ }
144
+ } catch (error) {
145
+ //Log.coreLogger.error('[ee-core] [utils/ip] queryHttps error:', error);
146
+ }
147
+ }
148
+
149
+ return emptyIP;
150
+ })();
151
+
152
+ promise.cancel = function () {
153
+ return cancel.apply(this);
154
+ };
155
+
156
+ return promise;
157
+ };
158
+
159
+ const queryAll = (version, options) => {
160
+ let cancel;
161
+ const promise = (async () => {
162
+ let response;
163
+ const dnsPromise = queryDns(version, options);
164
+ cancel = dnsPromise.cancel;
165
+ try {
166
+ response = await dnsPromise;
167
+ } catch {
168
+ const httpsPromise = queryHttps(version, options);
169
+ cancel = httpsPromise.cancel;
170
+ response = await httpsPromise;
171
+ }
172
+
173
+ return response;
174
+ })();
175
+
176
+ promise.cancel = cancel;
177
+
178
+ return promise;
179
+ };
180
+
181
+ // 查询 public ipv4
182
+ function publicIpv4(options) {
183
+ options = {
184
+ ...defaults,
185
+ ...options,
186
+ };
187
+
188
+ if (options.type == 'http') {
189
+ return queryHttps('v4', options);
190
+ }
191
+
192
+ if (options.type == 'dns') {
193
+ return queryDns('v4', options);
194
+ }
195
+
196
+ return queryAll('v4', options);
197
+ }
198
+
199
+ // 查询public ipv6
200
+ function publicIpv6(options) {
201
+ options = {
202
+ ...defaults,
203
+ ...options,
204
+ };
205
+
206
+ if (options.type == 'http') {
207
+ return queryHttps('v6', options);
208
+ }
209
+
210
+ if (options.type == 'dns') {
211
+ return queryDns('v6', options);
212
+ }
213
+
214
+ return queryAll('v6', options);
215
+ }
216
+
217
+ module.exports = {
218
+ publicIpv4,
219
+ publicIpv6
220
+ };
221
+
package/utils/is.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export declare function renderer(): boolean;
2
- export declare function main(): boolean;
3
- export declare function osx(): boolean;
4
- export declare function macOS(): boolean;
5
- export declare function windows(): boolean;
6
- export declare function linux(): boolean;
7
- export declare function x86(): boolean;
8
- export declare function x64(): boolean;
9
- export declare function sandbox(): boolean;
10
- export declare function mas(): boolean;
11
- export declare function windowsStore(): boolean;
12
- export declare function all(...args: any[]): boolean;
13
- export declare function none(...args: any[]): boolean;
14
- export declare function one(...args: any[]): boolean;
1
+ export declare function renderer(): boolean;
2
+ export declare function main(): boolean;
3
+ export declare function osx(): boolean;
4
+ export declare function macOS(): boolean;
5
+ export declare function windows(): boolean;
6
+ export declare function linux(): boolean;
7
+ export declare function x86(): boolean;
8
+ export declare function x64(): boolean;
9
+ export declare function sandbox(): boolean;
10
+ export declare function mas(): boolean;
11
+ export declare function windowsStore(): boolean;
12
+ export declare function all(...args: any[]): boolean;
13
+ export declare function none(...args: any[]): boolean;
14
+ export declare function one(...args: any[]): boolean;
package/utils/is.js CHANGED
@@ -1,112 +1,112 @@
1
- 'use strict';
2
-
3
- // Checks if we are in renderer process
4
- function renderer () {
5
- return process.type === 'renderer'
6
- }
7
-
8
- // Checks if we are in main process
9
- function main() {
10
- return process.type === 'browser'
11
- }
12
-
13
- // Checks if we are under Mac OS
14
- function osx() {
15
- return process.platform === 'darwin'
16
- }
17
-
18
- // Checks if we are under Mac OS
19
- function macOS() {
20
- return osx()
21
- }
22
-
23
- // Checks if we are under Windows OS
24
- function windows() {
25
- return process.platform === 'win32'
26
- }
27
-
28
- // Checks if we are under Linux OS
29
- function linux() {
30
- return process.platform === 'linux'
31
- }
32
-
33
- // Checks if we are the processor's arch is x86
34
- function x86() {
35
- return process.arch === 'ia32'
36
- }
37
-
38
- // Checks if we are the processor's arch is x64
39
- function x64() {
40
- return process.arch === 'x64'
41
- }
42
-
43
- // Checks if the app is running in a sandbox on macOS
44
- function sandbox() {
45
- return 'APP_SANDBOX_CONTAINER_ID' in process.env
46
- }
47
-
48
- // Checks if the app is running as a Mac App Store build
49
- function mas() {
50
- return process.mas === true
51
- }
52
-
53
- // Checks if the app is running as a Windows Store (appx) build
54
- function windowsStore() {
55
- return process.windowsStore === true
56
- }
57
-
58
- // checks if all the 'is functions' passed as arguments are true
59
- function all() {
60
- const isFunctions = new Array(arguments.length)
61
- for (var i = 0; i < isFunctions.length; i++) {
62
- isFunctions[i] = arguments[i]
63
- }
64
- if (!isFunctions.length) return
65
- for (i = 0; i < isFunctions.length; i++) {
66
- if (!isFunctions[i]()) return false
67
- }
68
- return true
69
- }
70
-
71
- // checks if all the 'is functions' passed as arguments are false
72
- function none() {
73
- const isFunctions = new Array(arguments.length)
74
- for (var i = 0; i < isFunctions.length; i++) {
75
- isFunctions[i] = arguments[i]
76
- }
77
- if (!isFunctions.length) return
78
- for (i = 0; i < isFunctions.length; i++) {
79
- if (isFunctions[i]()) return false
80
- }
81
- return true
82
- }
83
-
84
- // returns true if one of the 'is functions' passed as argument is true
85
- function one() {
86
- const isFunctions = new Array(arguments.length)
87
- for (var i = 0; i < isFunctions.length; i++) {
88
- isFunctions[i] = arguments[i]
89
- }
90
- if (!isFunctions.length) return
91
- for (i = 0; i < isFunctions.length; i++) {
92
- if (isFunctions[i]()) return true
93
- }
94
- return false
95
- }
96
-
97
- module.exports = {
98
- renderer,
99
- main,
100
- osx,
101
- macOS,
102
- windows,
103
- linux,
104
- x86,
105
- x64,
106
- sandbox,
107
- mas,
108
- windowsStore,
109
- all,
110
- none,
111
- one,
1
+ 'use strict';
2
+
3
+ // Checks if we are in renderer process
4
+ function renderer () {
5
+ return process.type === 'renderer'
6
+ }
7
+
8
+ // Checks if we are in main process
9
+ function main() {
10
+ return process.type === 'browser'
11
+ }
12
+
13
+ // Checks if we are under Mac OS
14
+ function osx() {
15
+ return process.platform === 'darwin'
16
+ }
17
+
18
+ // Checks if we are under Mac OS
19
+ function macOS() {
20
+ return osx()
21
+ }
22
+
23
+ // Checks if we are under Windows OS
24
+ function windows() {
25
+ return process.platform === 'win32'
26
+ }
27
+
28
+ // Checks if we are under Linux OS
29
+ function linux() {
30
+ return process.platform === 'linux'
31
+ }
32
+
33
+ // Checks if we are the processor's arch is x86
34
+ function x86() {
35
+ return process.arch === 'ia32'
36
+ }
37
+
38
+ // Checks if we are the processor's arch is x64
39
+ function x64() {
40
+ return process.arch === 'x64'
41
+ }
42
+
43
+ // Checks if the app is running in a sandbox on macOS
44
+ function sandbox() {
45
+ return 'APP_SANDBOX_CONTAINER_ID' in process.env
46
+ }
47
+
48
+ // Checks if the app is running as a Mac App Store build
49
+ function mas() {
50
+ return process.mas === true
51
+ }
52
+
53
+ // Checks if the app is running as a Windows Store (appx) build
54
+ function windowsStore() {
55
+ return process.windowsStore === true
56
+ }
57
+
58
+ // checks if all the 'is functions' passed as arguments are true
59
+ function all() {
60
+ const isFunctions = new Array(arguments.length)
61
+ for (var i = 0; i < isFunctions.length; i++) {
62
+ isFunctions[i] = arguments[i]
63
+ }
64
+ if (!isFunctions.length) return
65
+ for (i = 0; i < isFunctions.length; i++) {
66
+ if (!isFunctions[i]()) return false
67
+ }
68
+ return true
69
+ }
70
+
71
+ // checks if all the 'is functions' passed as arguments are false
72
+ function none() {
73
+ const isFunctions = new Array(arguments.length)
74
+ for (var i = 0; i < isFunctions.length; i++) {
75
+ isFunctions[i] = arguments[i]
76
+ }
77
+ if (!isFunctions.length) return
78
+ for (i = 0; i < isFunctions.length; i++) {
79
+ if (isFunctions[i]()) return false
80
+ }
81
+ return true
82
+ }
83
+
84
+ // returns true if one of the 'is functions' passed as argument is true
85
+ function one() {
86
+ const isFunctions = new Array(arguments.length)
87
+ for (var i = 0; i < isFunctions.length; i++) {
88
+ isFunctions[i] = arguments[i]
89
+ }
90
+ if (!isFunctions.length) return
91
+ for (i = 0; i < isFunctions.length; i++) {
92
+ if (isFunctions[i]()) return true
93
+ }
94
+ return false
95
+ }
96
+
97
+ module.exports = {
98
+ renderer,
99
+ main,
100
+ osx,
101
+ macOS,
102
+ windows,
103
+ linux,
104
+ x86,
105
+ x64,
106
+ sandbox,
107
+ mas,
108
+ windowsStore,
109
+ all,
110
+ none,
111
+ one,
112
112
  };