ee-core 2.12.0 → 4.0.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.
Files changed (159) hide show
  1. package/app/application.d.ts +5 -0
  2. package/app/application.js +31 -0
  3. package/app/boot.d.ts +5 -0
  4. package/app/boot.js +74 -0
  5. package/app/dir.d.ts +1 -0
  6. package/app/dir.js +27 -0
  7. package/app/events.d.ts +14 -0
  8. package/app/events.js +56 -0
  9. package/app/index.d.ts +2 -0
  10. package/app/index.js +7 -0
  11. package/config/config_loader.d.ts +13 -0
  12. package/config/config_loader.js +19 -23
  13. package/config/default_config.d.ts +95 -0
  14. package/config/default_config.js +111 -0
  15. package/config/index.d.ts +28 -0
  16. package/config/index.js +20 -37
  17. package/const/channel.d.ts +16 -0
  18. package/const/channel.js +26 -16
  19. package/controller/controller_loader.d.ts +9 -0
  20. package/controller/controller_loader.js +78 -0
  21. package/controller/index.d.ts +2 -0
  22. package/controller/index.js +18 -19
  23. package/core/index.d.ts +2 -0
  24. package/core/index.js +6 -5
  25. package/core/loader/file_loader.d.ts +66 -0
  26. package/core/{lib/loader → loader}/file_loader.js +39 -156
  27. package/core/utils/index.d.ts +12 -0
  28. package/core/utils/index.js +83 -0
  29. package/core/utils/timing.d.ts +22 -0
  30. package/core/{lib/utils → utils}/timing.js +3 -2
  31. package/cross/cross.d.ts +19 -0
  32. package/cross/cross.js +152 -0
  33. package/cross/crossProcess.d.ts +29 -0
  34. package/cross/{spawnProcess.js → crossProcess.js} +36 -53
  35. package/cross/index.d.ts +2 -0
  36. package/cross/index.js +6 -181
  37. package/electron/app/index.d.ts +5 -0
  38. package/electron/app/index.js +38 -54
  39. package/electron/index.d.ts +3 -0
  40. package/electron/index.js +13 -17
  41. package/electron/window/index.d.ts +6 -0
  42. package/electron/window/index.js +260 -65
  43. package/exception/index.d.ts +9 -0
  44. package/exception/index.js +42 -54
  45. package/html/index.d.ts +1 -0
  46. package/html/index.js +7 -10
  47. package/index.d.ts +2 -0
  48. package/index.js +4 -52
  49. package/jobs/child/app.d.ts +1 -0
  50. package/jobs/child/app.js +10 -10
  51. package/jobs/child/index.d.ts +13 -0
  52. package/jobs/child/index.js +14 -11
  53. package/jobs/child/jobProcess.d.ts +16 -0
  54. package/jobs/child/{forkProcess.js → jobProcess.js} +31 -62
  55. package/jobs/child-pool/index.d.ts +26 -0
  56. package/jobs/child-pool/index.js +25 -48
  57. package/jobs/index.d.ts +3 -0
  58. package/jobs/index.js +2 -4
  59. package/jobs/load-balancer/algorithm/index.d.ts +4 -0
  60. package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -0
  61. package/jobs/load-balancer/algorithm/polling.d.ts +2 -0
  62. package/jobs/load-balancer/algorithm/random.d.ts +2 -0
  63. package/jobs/load-balancer/algorithm/specify.d.ts +2 -0
  64. package/jobs/load-balancer/algorithm/weights.d.ts +2 -0
  65. package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -0
  66. package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -0
  67. package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -0
  68. package/jobs/load-balancer/consts.d.ts +8 -0
  69. package/jobs/load-balancer/index.d.ts +96 -0
  70. package/jobs/load-balancer/scheduler.d.ts +16 -0
  71. package/loader/index.d.ts +9 -0
  72. package/loader/index.js +73 -143
  73. package/log/index.d.ts +5 -0
  74. package/log/index.js +74 -57
  75. package/log/logger.d.ts +2 -0
  76. package/log/logger.js +75 -80
  77. package/message/childMessage.d.ts +10 -0
  78. package/message/childMessage.js +15 -25
  79. package/message/index.d.ts +3 -0
  80. package/message/index.js +7 -16
  81. package/package.json +8 -2
  82. package/ps/index.d.ts +37 -0
  83. package/ps/index.js +135 -238
  84. package/socket/httpServer.d.ts +8 -0
  85. package/socket/httpServer.js +55 -45
  86. package/socket/index.d.ts +10 -0
  87. package/socket/index.js +52 -69
  88. package/socket/ipcServer.d.ts +9 -0
  89. package/socket/ipcServer.js +87 -94
  90. package/socket/socketServer.d.ts +10 -0
  91. package/socket/socketServer.js +37 -25
  92. package/storage/index.d.ts +5 -0
  93. package/storage/index.js +5 -37
  94. package/storage/sqliteStorage.d.ts +16 -0
  95. package/storage/sqliteStorage.js +20 -20
  96. package/tsconfig.json +14 -0
  97. package/utils/extend.d.ts +2 -0
  98. package/utils/extend.js +10 -5
  99. package/utils/helper.d.ts +14 -0
  100. package/utils/helper.js +39 -53
  101. package/utils/index.d.ts +10 -0
  102. package/utils/index.js +47 -40
  103. package/utils/ip.d.ts +2 -0
  104. package/utils/ip.js +5 -45
  105. package/utils/is.d.ts +14 -0
  106. package/utils/is.js +107 -141
  107. package/utils/json.d.ts +5 -0
  108. package/utils/json.js +15 -7
  109. package/utils/pargv.d.ts +3 -0
  110. package/utils/pargv.js +5 -1
  111. package/utils/port/index.d.ts +1 -0
  112. package/utils/{get-port → port}/index.js +4 -26
  113. package/utils/wrap.d.ts +4 -0
  114. package/utils/wrap.js +8 -3
  115. package/addon/index.js +0 -35
  116. package/addon/window/index.js +0 -99
  117. package/bin/tools.js +0 -8
  118. package/config/cache.js +0 -62
  119. package/config/config.default.js +0 -331
  120. package/const/index.js +0 -9
  121. package/controller/baseContextClass.js +0 -25
  122. package/core/lib/ee.js +0 -216
  123. package/core/lib/loader/context_loader.js +0 -106
  124. package/core/lib/loader/ee_loader.js +0 -435
  125. package/core/lib/loader/mixin/addon.js +0 -32
  126. package/core/lib/loader/mixin/config.js +0 -130
  127. package/core/lib/loader/mixin/controller.js +0 -125
  128. package/core/lib/loader/mixin/service.js +0 -28
  129. package/core/lib/utils/base_context_class.js +0 -34
  130. package/core/lib/utils/function.js +0 -30
  131. package/core/lib/utils/index.js +0 -133
  132. package/core/lib/utils/sequencify.js +0 -59
  133. package/ee/appLoader.js +0 -48
  134. package/ee/application.js +0 -101
  135. package/ee/baseApp.js +0 -99
  136. package/ee/eeApp.js +0 -406
  137. package/ee/index.js +0 -58
  138. package/electron/window/winState.js +0 -186
  139. package/httpclient/index.js +0 -161
  140. package/jobs/baseJobClass.js +0 -16
  141. package/jobs/renderer/index.js +0 -141
  142. package/jobs/renderer/loadView.js +0 -41
  143. package/jobs/unification.js +0 -64
  144. package/main/index.js +0 -57
  145. package/old-utils/index.js +0 -91
  146. package/services/baseContextClass.js +0 -24
  147. package/services/index.js +0 -41
  148. package/socket/io.js +0 -28
  149. package/storage/jsondb/adapters/Base.js +0 -23
  150. package/storage/jsondb/adapters/FileSync.js +0 -64
  151. package/storage/jsondb/main.js +0 -55
  152. package/storage/jsondbStorage.js +0 -196
  153. package/utils/co.js +0 -237
  154. package/utils/copyto.js +0 -161
  155. package/utils/depd/index.js +0 -538
  156. package/utils/depd/lib/browser/index.js +0 -77
  157. package/utils/get-port/index.d.ts +0 -64
  158. package/utils/time/index.js +0 -20
  159. package/utils/time/ms.js +0 -162
package/utils/is.js CHANGED
@@ -1,146 +1,112 @@
1
- 'use strict'
1
+ 'use strict';
2
2
 
3
- const semver = require('semver')
4
- const gt = semver.gt
5
- const lt = semver.lt
6
- const release = require('os').release
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
+ }
7
57
 
8
- const IS = {
9
- // Checks if we are in renderer process
10
- renderer() {
11
- return process.type === 'renderer'
12
- },
13
- // Checks if we are in main process
14
- main() {
15
- return process.type === 'browser'
16
- },
17
- // Checks if we are under Mac OS
18
- osx() {
19
- return process.platform === 'darwin'
20
- },
21
- // Checks if we are under Mac OS
22
- macOS() {
23
- return this.osx()
24
- },
25
- // Checks if we are under Windows OS
26
- windows() {
27
- return process.platform === 'win32'
28
- },
29
- // Checks if we are under Linux OS
30
- linux() {
31
- return process.platform === 'linux'
32
- },
33
- // Checks if we are the processor's arch is x86
34
- x86() {
35
- return process.arch === 'ia32'
36
- },
37
- // Checks if we are the processor's arch is x64
38
- x64() {
39
- return process.arch === 'x64'
40
- },
41
- // Checks if the app is running in a sandbox on macOS
42
- sandbox() {
43
- return 'APP_SANDBOX_CONTAINER_ID' in process.env
44
- },
45
- // Checks if the app is running as a Mac App Store build
46
- mas() {
47
- return process.mas === true
48
- },
49
- // Checks if the app is running as a Windows Store (appx) build
50
- windowsStore() {
51
- return process.windowsStore === true
52
- },
53
- // checks if all the 'is functions' passed as arguments are true
54
- all() {
55
- const isFunctions = new Array(arguments.length)
56
- for (var i = 0; i < isFunctions.length; i++) {
57
- isFunctions[i] = arguments[i]
58
- }
59
- if (!isFunctions.length) return
60
- for (i = 0; i < isFunctions.length; i++) {
61
- if (!isFunctions[i]()) return false
62
- }
63
- return true
64
- },
65
- // checks if all the 'is functions' passed as arguments are false
66
- none() {
67
- const isFunctions = new Array(arguments.length)
68
- for (var i = 0; i < isFunctions.length; i++) {
69
- isFunctions[i] = arguments[i]
70
- }
71
- if (!isFunctions.length) return
72
- for (i = 0; i < isFunctions.length; i++) {
73
- if (isFunctions[i]()) return false
74
- }
75
- return true
76
- },
77
- // returns true if one of the 'is functions' passed as argument is true
78
- one() {
79
- const isFunctions = new Array(arguments.length)
80
- for (var i = 0; i < isFunctions.length; i++) {
81
- isFunctions[i] = arguments[i]
82
- }
83
- if (!isFunctions.length) return
84
- for (i = 0; i < isFunctions.length; i++) {
85
- if (isFunctions[i]()) return true
86
- }
87
- return false
88
- },
89
- // checks the if the given release is the same of the OS
90
- release(requested) {
91
- if (this.osx()) {
92
- return requested === this._osxRelease()
93
- } else if (this.windows()) {
94
- requested = requested.split('.')
95
- const actual = release().split('.')
96
- if (requested.length === 2) {
97
- return `${actual[0]}.${actual[1]}` === `${requested[0]}.${requested[1]}`
98
- }
99
- return `${actual[0]}.${actual[1]}.${actual[2]}` === `${requested[0]}.${requested[1]}.${requested[2]}`
100
- } else {
101
- // Not implemented for Linux yet
102
- return null
103
- }
104
- },
105
- // checks if the given release is greater than the current OS release
106
- gtRelease(requested) {
107
- if (this.osx()) {
108
- return gt(requested, this._osxRelease())
109
- } else if (this.windows()) {
110
- requested = requested.split('.')
111
- const actual = release().split('.')
112
- if (requested.length === 2) {
113
- return gt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
114
- }
115
- return gt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
116
- } else {
117
- // Not implemented for Linux yet
118
- return null
119
- }
120
- },
121
- // checks if the given release is less than the current OS release
122
- ltRelease(requested) {
123
- if (this.osx()) {
124
- return lt(requested, this._osxRelease())
125
- } else if (this.windows()) {
126
- requested = requested.split('.')
127
- const actual = release().split('.')
128
- if (requested.length === 2) {
129
- return lt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
130
- }
131
- return lt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
132
- } else {
133
- // Not implemented for Linux yet
134
- return null
135
- }
136
- },
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
+ }
137
83
 
138
- // returns the current osx release
139
- _osxRelease () {
140
- const actual = release().split('.')
141
- return `10.${actual[0] - 4}.${actual[1]}`
142
- },
143
-
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
144
95
  }
145
96
 
146
- module.exports = IS;
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
+ };
@@ -0,0 +1,5 @@
1
+ export declare function strictParse(str: string): {};
2
+ export declare function readSync(filepath: string): any;
3
+ export declare function writeSync(filepath: string, str: string, options: any): void;
4
+ export declare function read(filepath: string): any;
5
+ export declare function write(filepath: string, str: string, options: any): Promise<void>;
package/utils/json.js CHANGED
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const mkdirp = require('mkdirp');
4
4
 
5
- exports.strictParse = function (str) {
5
+ function strictParse(str) {
6
6
  const obj = JSON.parse(str);
7
7
  if (!obj || typeof obj !== 'object') {
8
8
  throw new Error('JSON string is not object');
@@ -10,14 +10,14 @@ exports.strictParse = function (str) {
10
10
  return obj;
11
11
  };
12
12
 
13
- exports.readSync = function(filepath) {
13
+ function readSync(filepath) {
14
14
  if (!fs.existsSync(filepath)) {
15
15
  throw new Error(filepath + ' is not found');
16
16
  }
17
17
  return JSON.parse(fs.readFileSync(filepath));
18
18
  };
19
19
 
20
- exports.writeSync = function(filepath, str, options) {
20
+ function writeSync(filepath, str, options) {
21
21
  options = options || {};
22
22
  if (!('space' in options)) {
23
23
  options.space = 2;
@@ -31,7 +31,7 @@ exports.writeSync = function(filepath, str, options) {
31
31
  fs.writeFileSync(filepath, str);
32
32
  };
33
33
 
34
- exports.read = function(filepath) {
34
+ function read(filepath) {
35
35
  return fs.stat(filepath)
36
36
  .then(function(stats) {
37
37
  if (!stats.isFile()) {
@@ -44,7 +44,7 @@ exports.read = function(filepath) {
44
44
  });
45
45
  };
46
46
 
47
- exports.write = function(filepath, str, options) {
47
+ function write(filepath, str, options) {
48
48
  options = options || {};
49
49
  if (!('space' in options)) {
50
50
  options.space = 2;
@@ -54,13 +54,13 @@ exports.write = function(filepath, str, options) {
54
54
  str = JSON.stringify(str, options.replacer, options.space) + '\n';
55
55
  }
56
56
 
57
- return mkdir(path.dirname(filepath))
57
+ return _mkdir(path.dirname(filepath))
58
58
  .then(function() {
59
59
  return fs.writeFile(filepath, str);
60
60
  });
61
61
  };
62
62
 
63
- function mkdir(dir) {
63
+ function _mkdir(dir) {
64
64
  return new Promise(function(resolve, reject) {
65
65
  mkdirp(dir, function(err) {
66
66
  if (err) {
@@ -70,3 +70,11 @@ function mkdir(dir) {
70
70
  });
71
71
  });
72
72
  }
73
+
74
+ module.exports = {
75
+ strictParse,
76
+ readSync,
77
+ writeSync,
78
+ read,
79
+ write
80
+ }
@@ -0,0 +1,3 @@
1
+ export declare function parseArgv(args: any, opts: any): {
2
+ _: any[];
3
+ };
package/utils/pargv.js CHANGED
@@ -20,7 +20,7 @@ function isConstructorOrProto(obj, key) {
20
20
  return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';
21
21
  }
22
22
 
23
- module.exports = function (args, opts) {
23
+ function parseArgv(args, opts) {
24
24
  if (!opts) { opts = {}; }
25
25
 
26
26
  var flags = {
@@ -261,3 +261,7 @@ module.exports = function (args, opts) {
261
261
 
262
262
  return argv;
263
263
  };
264
+
265
+ module.exports = {
266
+ parseArgv
267
+ }
@@ -0,0 +1 @@
1
+ export declare function getPort(options?: any): Promise<any>;
@@ -77,7 +77,7 @@ const portCheckSequence = function * (ports) {
77
77
  yield 0; // Fall back to 0 if anything else failed
78
78
  };
79
79
 
80
- module.exports = async options => {
80
+ async function getPort(options) {
81
81
  let ports;
82
82
 
83
83
  if (options) {
@@ -121,28 +121,6 @@ module.exports = async options => {
121
121
  throw new Error('No available ports found');
122
122
  };
123
123
 
124
- module.exports.makeRange = (from, to) => {
125
- if (!Number.isInteger(from) || !Number.isInteger(to)) {
126
- throw new TypeError('`from` and `to` must be integer numbers');
127
- }
128
-
129
- if (from < 1024 || from > 65535) {
130
- throw new RangeError('`from` must be between 1024 and 65535');
131
- }
132
-
133
- if (to < 1024 || to > 65536) {
134
- throw new RangeError('`to` must be between 1024 and 65536');
135
- }
136
-
137
- if (to < from) {
138
- throw new RangeError('`to` must be greater than or equal to `from`');
139
- }
140
-
141
- const generator = function * (from, to) {
142
- for (let port = from; port <= to; port++) {
143
- yield port;
144
- }
145
- };
146
-
147
- return generator(from, to);
148
- };
124
+ module.exports = {
125
+ getPort
126
+ }
@@ -0,0 +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;
package/utils/wrap.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const assert = require('assert');
2
2
  const is = require('is-type-of');
3
3
 
4
- exports.getProperties = (filepath, { caseStyle }) => {
4
+ function getProperties(filepath, { caseStyle }) {
5
5
  // if caseStyle is function, return the result of function
6
6
  if (is.function(caseStyle)) {
7
7
  const result = caseStyle(filepath);
@@ -9,10 +9,10 @@ exports.getProperties = (filepath, { caseStyle }) => {
9
9
  return result;
10
10
  }
11
11
  // use default camelize
12
- return this.defaultCamelize(filepath, caseStyle);
12
+ return defaultCamelize(filepath, caseStyle);
13
13
  }
14
14
 
15
- exports.defaultCamelize = (filepath, caseStyle) => {
15
+ function defaultCamelize(filepath, caseStyle) {
16
16
  const properties = filepath.substring(0, filepath.lastIndexOf('.')).split('/');
17
17
  return properties.map(property => {
18
18
  if (!/^[a-z][a-z0-9_-]*$/i.test(property)) {
@@ -33,4 +33,9 @@ exports.defaultCamelize = (filepath, caseStyle) => {
33
33
  }
34
34
  return first + property.substring(1);
35
35
  });
36
+ }
37
+
38
+ module.exports = {
39
+ getProperties,
40
+ defaultCamelize,
36
41
  }
package/addon/index.js DELETED
@@ -1,35 +0,0 @@
1
- const EE = require('../ee');
2
-
3
- const Addon = {
4
-
5
- /**
6
- * 获取 all addon instances
7
- */
8
- all() {
9
- const { CoreApp } = EE;
10
- if (!CoreApp) {
11
- throw new Error('An unknown error or Addons cannot be used by the jobs!');
12
- }
13
-
14
- const instances = CoreApp.addon || null;
15
- if (!instances) {
16
- throw new Error('Addons not exists or do not call directly at the top!');
17
- };
18
- return instances;
19
- },
20
-
21
- /**
22
- * 获取 addon instance
23
- */
24
- get(name) {
25
- const instances = this.all();
26
- const instance = instances[name] || null;
27
- if (!instance) {
28
- throw new Error(`Addon class '${name}' not exists or do not call directly at the top!`);
29
- };
30
- return instance;
31
- },
32
-
33
- };
34
-
35
- module.exports = Addon;
@@ -1,99 +0,0 @@
1
- const { BrowserWindow } = require('electron');
2
- const extend = require('../../utils/extend');
3
-
4
- /**
5
- * 窗口插件
6
- * @class
7
- */
8
- class WinAddon {
9
-
10
- constructor(app) {
11
- this.app = app;
12
- this.windowContentsIdMap = {};
13
- }
14
-
15
- /**
16
- * create window
17
- *
18
- * @function
19
- * @since 1.0.0
20
- */
21
- create(name, opt) {
22
-
23
- // todo 判断name是否唯一
24
- // if (this.windowContentsIdMap.hasOwnProperty(name)) {
25
- // throw new Error(`[addon] [window] Name: ${name} already exists!`);
26
- // }
27
-
28
- const options = extend(true, {}, {
29
- x: 10,
30
- y: 10,
31
- width: 980,
32
- height: 650,
33
- webPreferences: {
34
- contextIsolation: false,
35
- nodeIntegration: true,
36
- },
37
- }, opt);
38
- const win = new BrowserWindow(options)
39
-
40
- const winContentsId = win.webContents.id;
41
- win.webContents.on('did-finish-load', () => {
42
- this.registerWCid(name, winContentsId);
43
- })
44
-
45
- win.webContents.on('destroyed', () => {
46
- this.removeWCid(name);
47
- })
48
-
49
- win.webContents.on('render-process-gone', (event, details) => {
50
- this.removeWCid(name);
51
- })
52
-
53
- return win;
54
- }
55
-
56
- /**
57
- * 获取窗口Contents id
58
- *
59
- * @function
60
- * @since 1.0.0
61
- */
62
- getWCid(name) {
63
- const id = this.windowContentsIdMap[name] || null;
64
- return id;
65
- }
66
-
67
- /**
68
- * 获取主窗口Contents id
69
- *
70
- * @function
71
- * @since 1.0.0
72
- */
73
- getMWCid() {
74
- const id = this.windowContentsIdMap['main'] || null;
75
- return id;
76
- }
77
-
78
- /**
79
- * 注册窗口Contents id
80
- *
81
- * @function
82
- * @since 1.0.0
83
- */
84
- registerWCid(name, id) {
85
- this.windowContentsIdMap[name] = id;
86
- }
87
-
88
- /**
89
- * 销毁窗口Contents id
90
- *
91
- * @function
92
- * @since 1.0.0
93
- */
94
- removeWCid(name) {
95
- delete this.windowContentsIdMap[name];
96
- }
97
- }
98
-
99
- module.exports = WinAddon;
package/bin/tools.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const chalk = require('chalk');
4
-
5
- let tip = chalk.bgYellow('Warning') + ' please use ' + chalk.blue('ee-bin') + ', See: ';
6
- tip += chalk.underline('https://www.kaka996.com/pages/e1816f/');
7
-
8
- console.log(tip);
package/config/cache.js DELETED
@@ -1,62 +0,0 @@
1
- const EE = require('../ee');
2
- const { ConfigLoader } = require('./config_loader');
3
-
4
- const Instance = {
5
- config: null,
6
- };
7
-
8
- const conf = {
9
-
10
- loadConfig() {
11
- const configLoader = new ConfigLoader();
12
- Instance["config"] = configLoader.load();
13
- return Instance["config"];
14
- },
15
-
16
- /**
17
- * 获取 内存中的config
18
- */
19
- _getConfig() {
20
- const { CoreApp } = EE;
21
-
22
- if (CoreApp && CoreApp.config) {
23
- return CoreApp.config;
24
- }
25
-
26
- if (Instance["config"]) {
27
- return Instance["config"];
28
- }
29
-
30
- // 重新加载 config
31
- this.loadConfig();
32
-
33
- if (!Instance["config"]) {
34
- throw new Error('[ee-core] [config] config is not loaded!');
35
- }
36
-
37
- return Instance["config"];
38
- },
39
-
40
- /**
41
- * all
42
- */
43
- all() {
44
- return this._getConfig();
45
- },
46
-
47
- /**
48
- * getValue
49
- */
50
- getValue(key) {
51
- const v = this._objectGet(this._getConfig(), key);
52
- return v;
53
- },
54
-
55
- _objectGet(object, path, defaultValue) {
56
- const pathParts = Array.isArray(path) ? path : path.split('.');
57
- const value = pathParts.reduce((obj, key) => obj && key in obj ? obj[key] : undefined, object);
58
- return value === undefined ? defaultValue : value;
59
- }
60
- };
61
-
62
- module.exports = conf;