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
@@ -0,0 +1,5 @@
1
+ export declare class Appliaction {
2
+ register(eventName: string, handler: Function): void;
3
+ run(): void;
4
+ }
5
+ export declare const app: Appliaction;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:app:appliaction');
4
+ const { loadController } = require('../controller');
5
+ const { eventBus, Ready } = require('./events');
6
+ const { loadSocket } = require('../socket');
7
+ const { loadElectron } = require('../electron');
8
+
9
+ class Appliaction {
10
+ constructor() {
11
+
12
+ }
13
+
14
+ register(eventName, handler) {
15
+ return eventBus.register(eventName, handler);
16
+ }
17
+
18
+ run() {
19
+ loadController();
20
+ loadSocket();
21
+ eventBus.emitLifecycle(Ready);
22
+ loadElectron();
23
+ }
24
+ }
25
+
26
+ const app = new Appliaction();
27
+
28
+ module.exports = {
29
+ Appliaction,
30
+ app,
31
+ };
package/app/boot.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare class ElectronEgg {
2
+ init(): void;
3
+ register(eventName: string, handler: Function): void;
4
+ run(): void;
5
+ }
package/app/boot.js ADDED
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:app:boot');
4
+ const path = require('path');
5
+ const { loadException } = require('../exception');
6
+ const { electronApp } = require('../electron/app');
7
+ const { getArgumentByName, getBundleDir } = require('../ps');
8
+ const { loadConfig } = require('../config');
9
+ const { loadLog } = require('../log');
10
+ const { app } = require('./application');
11
+ const { loadDir } = require('./dir');
12
+
13
+ class ElectronEgg {
14
+ constructor() {
15
+ const baseDir = electronApp.getAppPath();
16
+ const { env } = process;
17
+ const environmet = getArgumentByName('env') || 'prod';
18
+
19
+ const options = {
20
+ env: environmet,
21
+ baseDir,
22
+ electronDir: getBundleDir(baseDir),
23
+ appName: electronApp.getName(),
24
+ userHome: electronApp.getPath('home'),
25
+ appData: electronApp.getPath('appData'),
26
+ appUserData: electronApp.getPath('userData'),
27
+ appVersion: electronApp.getVersion(),
28
+ isPackaged: electronApp.isPackaged,
29
+ execDir: baseDir,
30
+ }
31
+
32
+ // exec directory (exe dmg dep) for prod
33
+ if (environmet == 'prod' && options.isPackaged) {
34
+ options.execDir = path.dirname(electronApp.getPath('exe'));
35
+ }
36
+
37
+ // normalize env
38
+ env.EE_ENV = environmet;
39
+ env.EE_APP_NAME = options.appName;
40
+ env.EE_APP_VERSION = options.appVersion;
41
+ env.EE_BASE_DIR = options.baseDir;
42
+ env.EE_ELECTRON_DIR = options.electronDir;
43
+ env.EE_USER_HOME = options.userHome;
44
+ env.EE_APP_DATA = options.appData;
45
+ env.EE_APP_USER_DATA = options.appUserData;
46
+ env.EE_EXEC_DIR = options.execDir;
47
+ env.EE_IS_PACKAGED = options.isPackaged;
48
+ env.EE_SOCKET_PORT = null;
49
+ env.EE_HTTP_PORT = null;
50
+ debug('[constructor] options:%j', options)
51
+
52
+ this.init();
53
+ }
54
+
55
+ init() {
56
+ // basic functions
57
+ loadException();
58
+ loadConfig();
59
+ loadDir();
60
+ loadLog();
61
+ }
62
+
63
+ register(eventName, handler) {
64
+ return app.register(eventName, handler);
65
+ }
66
+
67
+ run() {
68
+ app.run();
69
+ }
70
+ }
71
+
72
+ module.exports = {
73
+ ElectronEgg,
74
+ };
package/app/dir.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function loadDir(): void;
package/app/dir.js ADDED
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const { getUserHomeHiddenAppDir, getLogDir, getDataDir } = require('../ps');
5
+ const { mkdir } = require('../utils/helper');
6
+ function loadDir() {
7
+ initDir();
8
+ }
9
+
10
+ function initDir() {
11
+ const homeHiddenAppDir = getUserHomeHiddenAppDir();
12
+ if (!fs.existsSync(homeHiddenAppDir)) {
13
+ mkdir(homeHiddenAppDir, { mode: 0o755 });
14
+ }
15
+ const dataDir = getDataDir();
16
+ if (!fs.existsSync(dataDir)) {
17
+ mkdir(dataDir, { mode: 0o755 });
18
+ }
19
+ const logDir = getLogDir();
20
+ if (!fs.existsSync(logDir)) {
21
+ mkdir(logDir, { mode: 0o755 });
22
+ }
23
+ }
24
+
25
+ module.exports = {
26
+ loadDir
27
+ };
@@ -0,0 +1,14 @@
1
+ export declare class EventBus {
2
+ lifecycleEvents: {};
3
+ eventsMap: {};
4
+ register(eventName: string, handler: Function): void;
5
+ emitLifecycle(eventName: string, ...args: any[]): void;
6
+ on(eventName: string, handler: Function): void;
7
+ emit(eventName: string, ...args: any[]): void;
8
+ }
9
+ export declare const eventBus: EventBus;
10
+ export declare const Ready: "ready";
11
+ export declare const ElectronAppReady: "electron-app-ready";
12
+ export declare const WindowReady: "window-ready";
13
+ export declare const Preload: "preload";
14
+ export declare const BeforeClose: "before-close";
package/app/events.js ADDED
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ const Ready = "ready";
4
+ const ElectronAppReady = "electron-app-ready";
5
+ const WindowReady = "window-ready";
6
+ const BeforeClose = "before-close";
7
+ const Preload = "preload";
8
+
9
+ class EventBus {
10
+ constructor() {
11
+ this.lifecycleEvents = {};
12
+ this.eventsMap = {};
13
+ }
14
+
15
+ // add lifecycle event
16
+ register(eventName, handler) {
17
+ if (!this.lifecycleEvents[eventName]) {
18
+ this.lifecycleEvents[eventName] = handler;
19
+ }
20
+ }
21
+
22
+ // call lifecycle event
23
+ emitLifecycle(eventName, ...args) {
24
+ const eventFn = this.lifecycleEvents[eventName];
25
+ if (eventFn) {
26
+ eventFn(...args);
27
+ }
28
+ }
29
+
30
+ // add listener
31
+ on(eventName, handler) {
32
+ if (!this.eventsMap[eventName]) {
33
+ this.eventsMap[eventName] = handler;
34
+ }
35
+ }
36
+
37
+ // emit listener
38
+ emit(eventName, ...args) {
39
+ const eventFn = this.eventsMap[eventName];
40
+ if (eventFn) {
41
+ eventFn(...args);
42
+ }
43
+ }
44
+ }
45
+
46
+ const eventBus = new EventBus();
47
+
48
+ module.exports = {
49
+ EventBus,
50
+ eventBus,
51
+ Ready,
52
+ ElectronAppReady,
53
+ WindowReady,
54
+ Preload,
55
+ BeforeClose
56
+ };
package/app/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ElectronEgg };
2
+ import { ElectronEgg } from "./boot";
package/app/index.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const { ElectronEgg } = require('./boot');
4
+
5
+ module.exports = {
6
+ ElectronEgg,
7
+ };
@@ -0,0 +1,13 @@
1
+ import { Timing } from "../core/utils/timing";
2
+ import { EEConfig } from "./default_config";
3
+ export declare class ConfigLoader {
4
+ timing: Timing;
5
+ /**
6
+ * Load config/config.xxx.js
7
+ */
8
+ load(): EEConfig;
9
+ _AppConfig(): EEConfig;
10
+ _loadConfig(dirpath: string, filename: string): EEConfig;
11
+ }
12
+
13
+
@@ -2,15 +2,15 @@
2
2
 
3
3
  const debug = require('debug')('ee-core:config:config_loader');
4
4
  const path = require('path');
5
- const Ps = require('../ps');
6
- const extend = require('../utils/extend');
7
- const Timing = require('../core/lib/utils/timing');
8
- const Loader= require('../loader');
5
+ const { appName, env, getElectronDir, getBaseDir, getRootDir } = require('../ps');
6
+ const { extend } = require('../utils/extend');
7
+ const { loadFile } = require('../loader');
8
+ const { Timing } = require('../core/utils/timing');
9
+ const defaultConfig = require('./default_config');
9
10
 
10
11
  class ConfigLoader {
11
12
  constructor() {
12
13
  this.timing = new Timing();
13
- this.config = {};
14
14
  }
15
15
 
16
16
  /**
@@ -21,21 +21,24 @@ class ConfigLoader {
21
21
 
22
22
  // Load Application config
23
23
  const appConfig = this._AppConfig();
24
- debug("[load] appConfig: %o", appConfig);
25
- this.config = appConfig;
24
+ // debug("[load] appConfig: %O", appConfig);
25
+
26
+ const defaultConf = defaultConfig();
27
+ const config = extend(true, defaultConf, appConfig);
28
+ debug("[load] config: %o", config);
26
29
 
27
30
  this.timing.end('Load Config');
28
- return this.config;
31
+ return config;
29
32
  }
30
33
 
31
34
  _AppConfig() {
32
35
  const names = [
33
36
  'config.default',
34
- `config.${Ps.env()}`,
37
+ `config.${env()}`,
35
38
  ];
36
39
  const target = {};
37
40
  for (const filename of names) {
38
- const config = this._loadConfig(Ps.getElectronDir(), filename);
41
+ const config = this._loadConfig(getElectronDir(), filename);
39
42
  extend(true, target, config);
40
43
  }
41
44
  return target;
@@ -43,21 +46,14 @@ class ConfigLoader {
43
46
 
44
47
  _loadConfig(dirpath, filename) {
45
48
  const appInfo = {
46
- name: Ps.appName(),
47
- baseDir: Ps.getElectronDir(),
48
- electronDir: Ps.getElectronDir(),
49
- env: Ps.env(),
50
- home: Ps.getHomeDir(),
51
- root: Ps.getRootDir(),
52
- appUserDataDir: Ps.getAppUserDataDir(),
53
- userHome: Ps.getUserHomeDir(),
54
- appVersion: Ps.appVersion(),
55
- isPackaged: Ps.isPackaged(),
56
- isEncrypted: Ps.isEncrypted(),
57
- execDir: Ps.getExecDir(),
49
+ name: appName(),
50
+ baseDir: getBaseDir(),
51
+ electronDir: getElectronDir(),
52
+ env: env(),
53
+ root: getRootDir(),
58
54
  }
59
55
  const filepath = path.join(dirpath, 'config', filename);
60
- const config = Loader.loadOneFile(filepath, appInfo);
56
+ const config = loadFile(filepath, appInfo);
61
57
  debug("[_loadConfig] filepath: %s", filepath);
62
58
  if (!config) return null;
63
59
 
@@ -0,0 +1,95 @@
1
+ import { BrowserWindowConstructorOptions } from 'electron';
2
+
3
+ export declare interface AppConfig {
4
+ openDevTools?: boolean | Object;
5
+ singleLock?: boolean;
6
+ windowsOption?: BrowserWindowConstructorOptions;
7
+ logger?: LoggerConfig;
8
+ socketServer?: SocketConfig;
9
+ httpServer?: HttpConfig;
10
+ remote?: RemoteConfig;
11
+ mainServer?: MainConfig;
12
+ exception?: ExceptionConfig;
13
+ job?: JobConfig;
14
+ cross?: CrossConfig;
15
+ }
16
+ export declare interface LoggerConfig {
17
+ type?: string;
18
+ dir?: string;
19
+ encoding?: string;
20
+ env?: string;
21
+ level?: string;
22
+ consoleLevel?: string;
23
+ disableConsoleAfterReady?: boolean;
24
+ outputJSON?: boolean;
25
+ buffer?: boolean;
26
+ appLogName: string;
27
+ coreLogName?: string;
28
+ agentLogName?: string;
29
+ errorLogName: string;
30
+ coreLogger?: {};
31
+ allowDebugAtProd?: boolean;
32
+ enablePerformanceTimer?: boolean;
33
+ rotator?: string;
34
+ }
35
+ export declare interface SocketConfig {
36
+ enable: boolean;
37
+ port: number;
38
+ path?: string;
39
+ connectTimeout?: number;
40
+ pingTimeout?: number;
41
+ pingInterval?: number;
42
+ maxHttpBufferSize?: number;
43
+ transports?: string[];
44
+ cors?: {
45
+ origin?: boolean;
46
+ };
47
+ channel?: string;
48
+ }
49
+ export declare interface HttpConfig {
50
+ enable: boolean;
51
+ https?: {
52
+ enable: boolean;
53
+ key: string;
54
+ cert: string;
55
+ };
56
+ protocol?: string;
57
+ host?: string;
58
+ port: number;
59
+ cors?: {
60
+ origin?: string;
61
+ };
62
+ body?: {
63
+ multipart?: boolean;
64
+ formidable?: {
65
+ keepExtensions?: boolean;
66
+ };
67
+ };
68
+ filterRequest?: {
69
+ uris?: string[];
70
+ returnData?: string;
71
+ };
72
+ }
73
+ export declare interface RemoteConfig {
74
+ enable: boolean;
75
+ url: string;
76
+ }
77
+ export declare interface MainConfig {
78
+ protocol?: string;
79
+ indexPath: string;
80
+ options?: {};
81
+ takeover?: string;
82
+ loadingPage?: string;
83
+ channelSeparator?: string;
84
+ }
85
+ export declare interface ExceptionConfig {
86
+ mainExit?: boolean;
87
+ childExit?: boolean;
88
+ rendererExit?: boolean;
89
+ }
90
+ export declare interface JobConfig {
91
+ messageLog: boolean;
92
+ }
93
+ export declare interface CrossConfig {}
94
+ declare function config(): AppConfig;
95
+ export = config;
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { env, getBaseDir, getLogDir } = require('../ps');
5
+ const { SocketIO } = require('../const/channel');
6
+
7
+ /**
8
+ * default
9
+ */
10
+ module.exports = () => {
11
+ return {
12
+ openDevTools: false,
13
+ singleLock: true,
14
+ windowsOption: {
15
+ title: 'electron-egg',
16
+ width: 980,
17
+ height: 650,
18
+ minWidth: 400,
19
+ minHeight: 300,
20
+ webPreferences: {
21
+ //webSecurity: false,
22
+ contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
23
+ nodeIntegration: true,
24
+ //preload: path.join(appInfo.electronDir, 'preload', 'bridge.js'),
25
+ },
26
+ frame: true,
27
+ show: false,
28
+ icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
29
+ },
30
+ logger: {
31
+ type: 'application',
32
+ dir: getLogDir(),
33
+ encoding: 'utf8',
34
+ env: env(),
35
+ level: 'INFO',
36
+ consoleLevel: 'INFO',
37
+ disableConsoleAfterReady: env() !== 'local',
38
+ outputJSON: false,
39
+ buffer: true,
40
+ appLogName: `ee.log`,
41
+ coreLogName: 'ee-core.log',
42
+ agentLogName: 'ee-agent.log',
43
+ errorLogName: `ee-error.log`,
44
+ coreLogger: {},
45
+ allowDebugAtProd: false,
46
+ enablePerformanceTimer: false,
47
+ rotator: 'day',
48
+ },
49
+ socketServer: {
50
+ enable: false, // is it enabled
51
+ port: 7070, // default port (if the port is in use, randomly select one)
52
+ path: "/socket.io/", // path
53
+ connectTimeout: 45000, // client connection timeout
54
+ pingTimeout: 30000, // heartbeat detection timeout
55
+ pingInterval: 25000, // heartbeat detection interval
56
+ maxHttpBufferSize: 1e8, // the data size of each message 1M
57
+ transports: ["polling", "websocket"], // http polling or websocket
58
+ cors: {
59
+ origin: true, // http协议时,要设置跨域 类型 Boolean String RegExp Array Function
60
+ },
61
+ channel: SocketIO.partySoftware
62
+ },
63
+ httpServer: {
64
+ enable: false, // Is it enabled
65
+ https: {
66
+ enable: false,
67
+ key: '/public/ssl/localhost+1.key',
68
+ cert: '/public/ssl/localhost+1.pem'
69
+ },
70
+ protocol: 'http://',
71
+ host: '127.0.0.1',
72
+ port: 7071, // Default port (if the port is in use, randomly select one)
73
+ cors: {
74
+ origin: "*"
75
+ },
76
+ body: {
77
+ multipart: true,
78
+ formidable: {
79
+ keepExtensions: true
80
+ }
81
+ },
82
+ filterRequest: {
83
+ uris: [
84
+ 'favicon.ico'
85
+ ],
86
+ returnData: ''
87
+ }
88
+ },
89
+ remote: {
90
+ enable: false,
91
+ url: ''
92
+ },
93
+ mainServer: {
94
+ protocol: 'file://', // file://
95
+ indexPath: '/public/dist/index.html',
96
+ options: {},
97
+ takeover: '',
98
+ loadingPage: '',
99
+ channelSeparator: '/',
100
+ },
101
+ exception: {
102
+ mainExit: false,
103
+ childExit: false,
104
+ rendererExit: true,
105
+ },
106
+ jobs: {
107
+ messageLog: false
108
+ },
109
+ cross: {}
110
+ }
111
+ }
@@ -0,0 +1,28 @@
1
+ import {
2
+ AppConfig,
3
+ WindowsConfig,
4
+ LoggerConfig,
5
+ SocketConfig,
6
+ HttpConfig,
7
+ RemoteConfig,
8
+ MainConfig,
9
+ ExceptionConfig,
10
+ JobConfig,
11
+ CrossConfig
12
+ } from "./default_config";
13
+ declare function loadConfig(): AppConfig;
14
+ declare function getConfig(): AppConfig;
15
+ export {
16
+ AppConfig,
17
+ WindowsConfig,
18
+ LoggerConfig,
19
+ SocketConfig,
20
+ HttpConfig,
21
+ RemoteConfig,
22
+ MainConfig,
23
+ ExceptionConfig,
24
+ JobConfig,
25
+ CrossConfig,
26
+ loadConfig,
27
+ getConfig
28
+ }
package/config/index.js CHANGED
@@ -1,42 +1,25 @@
1
- const ConfigCache = require('./cache');
1
+ 'use strict';
2
2
 
3
- const Cfg = {
3
+ const { ConfigLoader } = require('./config_loader');
4
4
 
5
- /**
6
- * all
7
- */
8
- all() {
9
- const cacheValue = ConfigCache.all();
10
- return cacheValue;
11
- },
12
-
13
- /**
14
- * getValue
15
- */
16
- getValue(key) {
17
- const cacheValue = ConfigCache.getValue(key);
18
- return cacheValue;
19
- },
5
+ const Instance = {
6
+ config: null,
7
+ };
20
8
 
21
- /**
22
- * isFileProtocol
23
- */
24
- isFileProtocol(config) {
25
- if (config.protocol == 'file://') {
26
- return true;
27
- }
28
- return false;
29
- },
9
+ function loadConfig() {
10
+ const configLoader = new ConfigLoader();
11
+ Instance["config"] = configLoader.load();
12
+ return Instance["config"];
13
+ }
30
14
 
31
- /**
32
- * isWebProtocol
33
- */
34
- isWebProtocol(config) {
35
- if (['http://', 'https://'].includes(config.protocol)) {
36
- return true;
37
- }
38
- return false;
39
- },
40
- };
15
+ function getConfig() {
16
+ if (!Instance["config"]) {
17
+ loadConfig();
18
+ };
19
+ return Instance["config"];
20
+ }
41
21
 
42
- module.exports = Cfg;
22
+ module.exports = {
23
+ loadConfig,
24
+ getConfig,
25
+ };
@@ -0,0 +1,16 @@
1
+ export declare namespace Processes {
2
+ let showException: string;
3
+ let sendToMain: string;
4
+ }
5
+ export declare namespace SocketIO {
6
+ let partySoftware: string;
7
+ }
8
+ export declare namespace Events {
9
+ let childProcessExit: string;
10
+ let childProcessError: string;
11
+ }
12
+ export declare namespace Receiver {
13
+ let childJob: string;
14
+ let forkProcess: string;
15
+ let all: string;
16
+ }
package/const/channel.js CHANGED
@@ -1,18 +1,28 @@
1
+ 'use strict';
2
+
3
+ const Processes = {
4
+ showException: 'ee#showException',
5
+ sendToMain: 'ee#sendToMain'
6
+ }
7
+
8
+ const SocketIO = {
9
+ partySoftware: 'socket-channel',
10
+ }
11
+
12
+ const Events = {
13
+ childProcessExit: 'ee#childProcess#exit',
14
+ childProcessError: 'ee#childProcess#error',
15
+ }
16
+
17
+ const Receiver = {
18
+ childJob: 'job',
19
+ forkProcess: 'task',
20
+ all: 'all'
21
+ }
22
+
1
23
  module.exports = {
2
- process: {
3
- showException: 'ee#showException',
4
- sendToMain: 'ee#sendToMain'
5
- },
6
- socketIo: {
7
- partySoftware: 'c1',
8
- },
9
- events: {
10
- childProcessExit: 'ee#childProcess#exit',
11
- childProcessError: 'ee#childProcess#error',
12
- },
13
- receiver: {
14
- childJob: 'job',
15
- forkProcess: 'task',
16
- all: 'all'
17
- }
24
+ Processes,
25
+ SocketIO,
26
+ Events,
27
+ Receiver
18
28
  };