ee-core 4.1.3 → 4.1.4

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 +151 -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 -98
  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 +10 -10
  119. package/utils/index.js +167 -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
@@ -1,126 +1,126 @@
1
- 'use strict';
2
- const net = require('net');
3
- const os = require('os');
4
-
5
- class Locked extends Error {
6
- constructor(port) {
7
- super(`${port} is locked`);
8
- }
9
- }
10
-
11
- const lockedPorts = {
12
- old: new Set(),
13
- young: new Set()
14
- };
15
-
16
- // On this interval, the old locked ports are discarded,
17
- // the young locked ports are moved to old locked ports,
18
- // and a new young set for locked ports are created.
19
- const releaseOldLockedPortsIntervalMs = 1000 * 15;
20
-
21
- // Lazily create interval on first use
22
- let interval;
23
-
24
- const getLocalHosts = () => {
25
- const interfaces = os.networkInterfaces();
26
-
27
- // Add undefined value for createServer function to use default host,
28
- // and default IPv4 host in case createServer defaults to IPv6.
29
- const results = new Set([undefined, '0.0.0.0']);
30
-
31
- for (const _interface of Object.values(interfaces)) {
32
- for (const config of _interface) {
33
- results.add(config.address);
34
- }
35
- }
36
-
37
- return results;
38
- };
39
-
40
- const checkAvailablePort = options =>
41
- new Promise((resolve, reject) => {
42
- const server = net.createServer();
43
- server.unref();
44
- server.on('error', reject);
45
-
46
- server.listen(options, () => {
47
- const {port} = server.address();
48
- server.close(() => {
49
- resolve(port);
50
- });
51
- });
52
- });
53
-
54
- const getAvailablePort = async (options, hosts) => {
55
- if (options.host || options.port === 0) {
56
- return checkAvailablePort(options);
57
- }
58
-
59
- for (const host of hosts) {
60
- try {
61
- await checkAvailablePort({port: options.port, host}); // eslint-disable-line no-await-in-loop
62
- } catch (error) {
63
- if (!['EADDRNOTAVAIL', 'EINVAL'].includes(error.code)) {
64
- throw error;
65
- }
66
- }
67
- }
68
-
69
- return options.port;
70
- };
71
-
72
- const portCheckSequence = function * (ports) {
73
- if (ports) {
74
- yield * ports;
75
- }
76
-
77
- yield 0; // Fall back to 0 if anything else failed
78
- };
79
-
80
- async function getPort(options) {
81
- let ports;
82
-
83
- if (options) {
84
- ports = typeof options.port === 'number' ? [options.port] : options.port;
85
- }
86
-
87
- if (interval === undefined) {
88
- interval = setInterval(() => {
89
- lockedPorts.old = lockedPorts.young;
90
- lockedPorts.young = new Set();
91
- }, releaseOldLockedPortsIntervalMs);
92
-
93
- // Does not exist in some environments (Electron, Jest jsdom env, browser, etc).
94
- if (interval.unref) {
95
- interval.unref();
96
- }
97
- }
98
-
99
- const hosts = getLocalHosts();
100
-
101
- for (const port of portCheckSequence(ports)) {
102
- try {
103
- let availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop
104
- while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
105
- if (port !== 0) {
106
- throw new Locked(port);
107
- }
108
-
109
- availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop
110
- }
111
-
112
- lockedPorts.young.add(availablePort);
113
- return availablePort;
114
- } catch (error) {
115
- if (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {
116
- throw error;
117
- }
118
- }
119
- }
120
-
121
- throw new Error('No available ports found');
122
- };
123
-
124
- module.exports = {
125
- getPort
1
+ 'use strict';
2
+ const net = require('net');
3
+ const os = require('os');
4
+
5
+ class Locked extends Error {
6
+ constructor(port) {
7
+ super(`${port} is locked`);
8
+ }
9
+ }
10
+
11
+ const lockedPorts = {
12
+ old: new Set(),
13
+ young: new Set()
14
+ };
15
+
16
+ // On this interval, the old locked ports are discarded,
17
+ // the young locked ports are moved to old locked ports,
18
+ // and a new young set for locked ports are created.
19
+ const releaseOldLockedPortsIntervalMs = 1000 * 15;
20
+
21
+ // Lazily create interval on first use
22
+ let interval;
23
+
24
+ const getLocalHosts = () => {
25
+ const interfaces = os.networkInterfaces();
26
+
27
+ // Add undefined value for createServer function to use default host,
28
+ // and default IPv4 host in case createServer defaults to IPv6.
29
+ const results = new Set([undefined, '0.0.0.0']);
30
+
31
+ for (const _interface of Object.values(interfaces)) {
32
+ for (const config of _interface) {
33
+ results.add(config.address);
34
+ }
35
+ }
36
+
37
+ return results;
38
+ };
39
+
40
+ const checkAvailablePort = options =>
41
+ new Promise((resolve, reject) => {
42
+ const server = net.createServer();
43
+ server.unref();
44
+ server.on('error', reject);
45
+
46
+ server.listen(options, () => {
47
+ const {port} = server.address();
48
+ server.close(() => {
49
+ resolve(port);
50
+ });
51
+ });
52
+ });
53
+
54
+ const getAvailablePort = async (options, hosts) => {
55
+ if (options.host || options.port === 0) {
56
+ return checkAvailablePort(options);
57
+ }
58
+
59
+ for (const host of hosts) {
60
+ try {
61
+ await checkAvailablePort({port: options.port, host}); // eslint-disable-line no-await-in-loop
62
+ } catch (error) {
63
+ if (!['EADDRNOTAVAIL', 'EINVAL'].includes(error.code)) {
64
+ throw error;
65
+ }
66
+ }
67
+ }
68
+
69
+ return options.port;
70
+ };
71
+
72
+ const portCheckSequence = function * (ports) {
73
+ if (ports) {
74
+ yield * ports;
75
+ }
76
+
77
+ yield 0; // Fall back to 0 if anything else failed
78
+ };
79
+
80
+ async function getPort(options) {
81
+ let ports;
82
+
83
+ if (options) {
84
+ ports = typeof options.port === 'number' ? [options.port] : options.port;
85
+ }
86
+
87
+ if (interval === undefined) {
88
+ interval = setInterval(() => {
89
+ lockedPorts.old = lockedPorts.young;
90
+ lockedPorts.young = new Set();
91
+ }, releaseOldLockedPortsIntervalMs);
92
+
93
+ // Does not exist in some environments (Electron, Jest jsdom env, browser, etc).
94
+ if (interval.unref) {
95
+ interval.unref();
96
+ }
97
+ }
98
+
99
+ const hosts = getLocalHosts();
100
+
101
+ for (const port of portCheckSequence(ports)) {
102
+ try {
103
+ let availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop
104
+ while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
105
+ if (port !== 0) {
106
+ throw new Locked(port);
107
+ }
108
+
109
+ availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop
110
+ }
111
+
112
+ lockedPorts.young.add(availablePort);
113
+ return availablePort;
114
+ } catch (error) {
115
+ if (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {
116
+ throw error;
117
+ }
118
+ }
119
+ }
120
+
121
+ throw new Error('No available ports found');
122
+ };
123
+
124
+ module.exports = {
125
+ getPort
126
126
  }
package/utils/wrap.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare function getProperties(filepath: any, { caseStyle }: {
2
- caseStyle: any;
3
- }): any;
4
- export declare function defaultCamelize(filepath: any, caseStyle: any): any;
1
+ export declare function getProperties(filepath: any, { caseStyle }: {
2
+ caseStyle: any;
3
+ }): any;
4
+ export declare function defaultCamelize(filepath: any, caseStyle: any): any;
package/utils/wrap.js CHANGED
@@ -1,41 +1,41 @@
1
- const assert = require('assert');
2
- const is = require('is-type-of');
3
-
4
- function getProperties(filepath, { caseStyle }) {
5
- // if caseStyle is function, return the result of function
6
- if (is.function(caseStyle)) {
7
- const result = caseStyle(filepath);
8
- assert(is.array(result), `caseStyle expect an array, but got ${result}`);
9
- return result;
10
- }
11
- // use default camelize
12
- return defaultCamelize(filepath, caseStyle);
13
- }
14
-
15
- function defaultCamelize(filepath, caseStyle) {
16
- const properties = filepath.substring(0, filepath.lastIndexOf('.')).split('/');
17
- return properties.map(property => {
18
- if (!/^[a-z][a-z0-9_-]*$/i.test(property)) {
19
- throw new Error(`${property} is not match 'a-z0-9_-' in ${filepath}`);
20
- }
21
-
22
- property = property.replace(/[_-][a-z]/ig, s => s.substring(1).toUpperCase());
23
- let first = property[0];
24
- switch (caseStyle) {
25
- case 'lower':
26
- first = first.toLowerCase();
27
- break;
28
- case 'upper':
29
- first = first.toUpperCase();
30
- break;
31
- case 'camel':
32
- default:
33
- }
34
- return first + property.substring(1);
35
- });
36
- }
37
-
38
- module.exports = {
39
- getProperties,
40
- defaultCamelize,
1
+ const assert = require('assert');
2
+ const is = require('is-type-of');
3
+
4
+ function getProperties(filepath, { caseStyle }) {
5
+ // if caseStyle is function, return the result of function
6
+ if (is.function(caseStyle)) {
7
+ const result = caseStyle(filepath);
8
+ assert(is.array(result), `caseStyle expect an array, but got ${result}`);
9
+ return result;
10
+ }
11
+ // use default camelize
12
+ return defaultCamelize(filepath, caseStyle);
13
+ }
14
+
15
+ function defaultCamelize(filepath, caseStyle) {
16
+ const properties = filepath.substring(0, filepath.lastIndexOf('.')).split('/');
17
+ return properties.map(property => {
18
+ if (!/^[a-z][a-z0-9_-]*$/i.test(property)) {
19
+ throw new Error(`${property} is not match 'a-z0-9_-' in ${filepath}`);
20
+ }
21
+
22
+ property = property.replace(/[_-][a-z]/ig, s => s.substring(1).toUpperCase());
23
+ let first = property[0];
24
+ switch (caseStyle) {
25
+ case 'lower':
26
+ first = first.toLowerCase();
27
+ break;
28
+ case 'upper':
29
+ first = first.toUpperCase();
30
+ break;
31
+ case 'camel':
32
+ default:
33
+ }
34
+ return first + property.substring(1);
35
+ });
36
+ }
37
+
38
+ module.exports = {
39
+ getProperties,
40
+ defaultCamelize,
41
41
  }