ee-core 1.5.2-beta.2 → 2.0.0-beta.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/config/config.default.js +8 -1
- package/core/lib/ee.js +1 -1
- package/core/lib/loader/ee_loader.js +7 -3
- package/core/lib/loader/mixin/controller.js +3 -2
- package/core/lib/utils/function.js +30 -0
- package/index.js +2 -2
- package/lib/appLoader.js +0 -5
- package/lib/application.js +7 -6
- package/lib/baseApp.js +9 -26
- package/lib/eeApp.js +18 -52
- package/{lib/constant.js → module/const/index.js} +3 -0
- package/{lib/httpclient.js → module/httpclient/index.js} +45 -11
- package/module/jobs/child/forkProcess.js +99 -0
- package/module/jobs/child/index.js +33 -0
- package/module/jobs/index.js +55 -0
- package/module/jobs/renderer/index.js +140 -0
- package/module/jobs/renderer/loadView.js +40 -0
- package/module/loader/index.js +78 -0
- package/module/log/index.js +53 -0
- package/module/log/logger.js +61 -0
- package/module/message/index.js +13 -0
- package/module/message/ipcMain.js +160 -0
- package/module/message/ipcRender.js +0 -0
- package/{lib → module}/socket/httpServer.js +0 -0
- package/{lib → module}/socket/io.js +0 -0
- package/{lib → module}/socket/ipcServer.js +6 -8
- package/{lib → module}/socket/socketClient.js +4 -3
- package/{lib → module}/socket/socketServer.js +4 -3
- package/module/socket/start.js +22 -0
- package/{lib → module}/storage/index.js +13 -12
- package/module/storage/jsondb/adapters/Base.js +14 -0
- package/module/storage/jsondb/adapters/FileSync.js +32 -0
- package/{lib/storage/lowdb → module/storage/jsondb}/main.js +6 -10
- package/{lib/storage/lowdbStorage.js → module/storage/jsondbStorage.js} +13 -14
- package/{lib → module}/storage/sqliteStorage.js +7 -11
- package/module/utils/copyto.js +161 -0
- package/module/utils/helper.js +117 -0
- package/module/utils/index.js +120 -0
- package/module/utils/json.js +72 -0
- package/module/utils/ps.js +175 -0
- package/{utils → module/utils}/wrap.js +0 -2
- package/package.json +3 -7
- package/tools/encrypt.js +2 -2
- package/utils/index.js +17 -135
- package/lib/logger.js +0 -47
- package/lib/socket/start.js +0 -22
- package/lib/storage/lowdb/adapters/Base.js +0 -15
- package/lib/storage/lowdb/adapters/FileAsync.js +0 -41
- package/lib/storage/lowdb/adapters/FileSync.js +0 -39
- package/lib/storage/lowdb/adapters/LocalStorage.js +0 -20
- package/lib/storage/lowdb/adapters/Memory.js +0 -8
- package/lib/storage/lowdb/adapters/_stringify.js +0 -4
- package/lib/storage/lowdb/common.js +0 -33
- package/lib/storage/lowdb/fp.js +0 -23
- package/lib/storage/lowdb/isPromise.js +0 -6
- package/lib/storage/lowdb/nano.js +0 -5
- package/utils/common.js +0 -91
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const isPromise = require('./isPromise')
|
|
2
|
-
|
|
3
|
-
const init = (db, key, adapter) => {
|
|
4
|
-
db.read = () => {
|
|
5
|
-
const r = adapter.read()
|
|
6
|
-
|
|
7
|
-
return isPromise(r) ? r.then(db.plant) : db.plant(r)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
db.write = (value = db.getState()) => {
|
|
11
|
-
const w = adapter.write(db.getState())
|
|
12
|
-
|
|
13
|
-
return isPromise(w) ? w.then(() => value) : value
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
db.plant = state => {
|
|
17
|
-
db[key] = state
|
|
18
|
-
return db
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
db.getState = () => db[key]
|
|
22
|
-
|
|
23
|
-
db.setState = state => {
|
|
24
|
-
db.plant(state)
|
|
25
|
-
return db
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return db.read()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
init
|
|
33
|
-
}
|
package/lib/storage/lowdb/fp.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const flow = require('lodash/flow')
|
|
2
|
-
const get = require('lodash/get')
|
|
3
|
-
const set = require('lodash/set')
|
|
4
|
-
const common = require('./common')
|
|
5
|
-
|
|
6
|
-
module.exports = function(adapter) {
|
|
7
|
-
function db(path, defaultValue) {
|
|
8
|
-
function getValue(funcs) {
|
|
9
|
-
const result = get(db.getState(), path, defaultValue)
|
|
10
|
-
return flow(funcs)(result)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getValue.write = (...funcs) => {
|
|
14
|
-
const result = getValue(...funcs)
|
|
15
|
-
set(db.getState(), path, result)
|
|
16
|
-
return db.write()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return getValue
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return common.init(db, '__state__', adapter)
|
|
23
|
-
}
|
package/utils/common.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ee-core使用
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 版本号比较
|
|
12
|
-
*/
|
|
13
|
-
exports.compareVersion = function (v1, v2) {
|
|
14
|
-
v1 = v1.split('.')
|
|
15
|
-
v2 = v2.split('.')
|
|
16
|
-
const len = Math.max(v1.length, v2.length)
|
|
17
|
-
|
|
18
|
-
while (v1.length < len) {
|
|
19
|
-
v1.push('0')
|
|
20
|
-
}
|
|
21
|
-
while (v2.length < len) {
|
|
22
|
-
v2.push('0')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
for (let i = 0; i < len; i++) {
|
|
26
|
-
const num1 = parseInt(v1[i])
|
|
27
|
-
const num2 = parseInt(v2[i])
|
|
28
|
-
|
|
29
|
-
if (num1 > num2) {
|
|
30
|
-
return 1
|
|
31
|
-
} else if (num1 < num2) {
|
|
32
|
-
return -1
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return 0
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 创建文件夹
|
|
41
|
-
*/
|
|
42
|
-
exports.mkdir = function(dirpath, dirname) {
|
|
43
|
-
// 判断是否是第一次调用
|
|
44
|
-
if (typeof dirname === 'undefined') {
|
|
45
|
-
if (fs.existsSync(dirpath)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.mkdir(dirpath, path.dirname(dirpath));
|
|
49
|
-
} else {
|
|
50
|
-
// 判断第二个参数是否正常,避免调用时传入错误参数
|
|
51
|
-
if (dirname !== path.dirname(dirpath)) {
|
|
52
|
-
this.mkdir(dirpath);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (fs.existsSync(dirname)) {
|
|
56
|
-
fs.mkdirSync(dirpath);
|
|
57
|
-
} else {
|
|
58
|
-
this.mkdir(dirname, path.dirname(dirname));
|
|
59
|
-
fs.mkdirSync(dirpath);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 修改文件权限
|
|
66
|
-
*/
|
|
67
|
-
exports.chmodPath = function(path, mode) {
|
|
68
|
-
let files = [];
|
|
69
|
-
if (fs.existsSync(path)) {
|
|
70
|
-
files = fs.readdirSync(path);
|
|
71
|
-
files.forEach((file, index) => {
|
|
72
|
-
const curPath = path + '/' + file;
|
|
73
|
-
if (fs.statSync(curPath).isDirectory()) {
|
|
74
|
-
this.chmodPath(curPath, mode); // 递归删除文件夹
|
|
75
|
-
} else {
|
|
76
|
-
fs.chmodSync(curPath, mode);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
fs.chmodSync(path, mode);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 获取数据存储路径
|
|
85
|
-
*/
|
|
86
|
-
exports.getStorageDir = function () {
|
|
87
|
-
let env = process.env.EE_SERVER_ENV;
|
|
88
|
-
const appDir = env === 'local' || env === 'unittest' ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
|
|
89
|
-
const storageDir = path.join(appDir, 'data');
|
|
90
|
-
return storageDir;
|
|
91
|
-
}
|