ee-core 4.0.1 → 4.1.1

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.
package/app/boot.js CHANGED
@@ -4,7 +4,7 @@ const debug = require('debug')('ee-core:app:boot');
4
4
  const path = require('path');
5
5
  const { loadException } = require('../exception');
6
6
  const { electronApp } = require('../electron/app');
7
- const { getArgumentByName, getBundleDir } = require('../ps');
7
+ const { getArgumentByName, getBundleDir, getElectronCodeDir } = require('../ps');
8
8
  const { loadConfig } = require('../config');
9
9
  const { loadLog } = require('../log');
10
10
  const { app } = require('./application');
@@ -15,11 +15,18 @@ class ElectronEgg {
15
15
  const baseDir = electronApp.getAppPath();
16
16
  const { env } = process;
17
17
  const environmet = getArgumentByName('env') || 'prod';
18
+ const debugging = getArgumentByName('debuger') == 'true'? true : false;
19
+
20
+ // Debugging source code
21
+ let electronDir = getBundleDir(baseDir);
22
+ if (debugging) {
23
+ electronDir = getElectronCodeDir(baseDir);
24
+ }
18
25
 
19
26
  const options = {
20
27
  env: environmet,
21
28
  baseDir,
22
- electronDir: getBundleDir(baseDir),
29
+ electronDir,
23
30
  appName: electronApp.getName(),
24
31
  userHome: electronApp.getPath('home'),
25
32
  appData: electronApp.getPath('appData'),
package/jobs/child/app.js CHANGED
@@ -47,15 +47,20 @@ class ChildApp {
47
47
  const {jobPath, jobParams, jobFunc, jobFuncParams} = msg;
48
48
  let mod = requireFile(jobPath);
49
49
  if (is.class(mod) || isBytecodeClass(mod)) {
50
+ let instance;
50
51
  if (!this.jobMap.has(jobPath)) {
51
- const instance = new mod(...jobParams);
52
- instance.handle(...jobParams);
52
+ instance = new mod(...jobParams);
53
53
  this.jobMap.set(jobPath, instance);
54
54
  } else {
55
- const instance = this.jobMap.get(jobPath);
56
- instance[jobFunc](...jobFuncParams);
55
+ instance = this.jobMap.get(jobPath);
57
56
  }
58
57
 
58
+ // 如果指定了函数名,则调用指定的函数
59
+ if (jobFunc) {
60
+ instance[jobFunc](...jobFuncParams);
61
+ } else {
62
+ instance.handle(...jobParams);
63
+ }
59
64
  } else if (is.function(mod)) {
60
65
  mod(jobParams);
61
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "4.0.1",
3
+ "version": "4.1.1",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/ps/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export declare function appVersion(): string;
11
11
  export declare function getDataDir(): string;
12
12
  export declare function getLogDir(): string;
13
13
  export declare function getBundleDir(basePath: string): string;
14
+ export declare function getElectronCodeDir(basePath: string): string;
15
+ export declare function getFrontendCodeDir(basePath: string): string;
14
16
  export declare function getRootDir(): string;
15
17
  export declare function getBaseDir(): string;
16
18
  export declare function getElectronDir(): string;
@@ -34,4 +36,4 @@ export declare function makeMessage(msg?: {}): {
34
36
  export declare function exitChildJob(code?: number): void;
35
37
  export declare function isChildJob(): boolean;
36
38
  export declare function isChildPoolJob(): boolean;
37
- export declare function getArgumentByName(name: string): string;
39
+ export declare function getArgumentByName(name: string, args?: any): string;
package/ps/index.js CHANGED
@@ -90,10 +90,18 @@ function getBundleDir(basePath) {
90
90
  return dir;
91
91
  }
92
92
 
93
- // 获取root目录 (dev-项目根目录,pro-app user data目录)
94
- function getRootDir() {
95
- const appDir = isDev() ? getBaseDir() : getAppUserDataDir();
96
- return appDir;
93
+ // 获取electron 源码文件路径
94
+ function getElectronCodeDir(basePath) {
95
+ const base = basePath || process.cwd();
96
+ const dir = path.join(base, 'electron');
97
+ return dir;
98
+ }
99
+
100
+ // 获取frontend 源码文件路径
101
+ function getFrontendCodeDir(basePath) {
102
+ const base = basePath || process.cwd();
103
+ const dir = path.join(base, 'frontend');
104
+ return dir;
97
105
  }
98
106
 
99
107
  // 获取base目录
@@ -133,6 +141,12 @@ function getExtraResourcesDir() {
133
141
  return dir;
134
142
  }
135
143
 
144
+ // 获取root目录 (dev-项目根目录,pro-app user data目录)
145
+ function getRootDir() {
146
+ const appDir = isDev() ? getBaseDir() : getAppUserDataDir();
147
+ return appDir;
148
+ }
149
+
136
150
  // 获取 appUserData目录
137
151
  function getAppUserDataDir() {
138
152
  return process.env.EE_APP_USER_DATA;
@@ -230,9 +244,12 @@ function isChildPoolJob() {
230
244
  }
231
245
 
232
246
  // Get cmd parameter by name
233
- function getArgumentByName(name) {
234
- for (let i = 0; i < process.argv.length; i++) {
235
- const item = process.argv[i]
247
+ function getArgumentByName(name, args) {
248
+ if (!args) {
249
+ args = process.argv;
250
+ }
251
+ for (let i = 0; i < args.length; i++) {
252
+ const item = args[i];
236
253
  const prefixKey = `--${name}=`;
237
254
  if (item.indexOf(prefixKey) !== -1) {
238
255
  return item.substring(prefixKey.length);
@@ -254,6 +271,8 @@ module.exports = {
254
271
  getDataDir,
255
272
  getLogDir,
256
273
  getBundleDir,
274
+ getElectronCodeDir,
275
+ getFrontendCodeDir,
257
276
  getRootDir,
258
277
  getBaseDir,
259
278
  getElectronDir,