ee-core 1.5.2-beta.1 → 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.
Files changed (72) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -2
  3. package/addon/window/index.js +91 -91
  4. package/bin/tools.js +18 -18
  5. package/config/config.default.js +287 -280
  6. package/core/index.js +12 -12
  7. package/core/lib/ee.js +218 -218
  8. package/core/lib/loader/context_loader.js +106 -106
  9. package/core/lib/loader/ee_loader.js +461 -457
  10. package/core/lib/loader/file_loader.js +325 -325
  11. package/core/lib/loader/mixin/addon.js +32 -32
  12. package/core/lib/loader/mixin/config.js +135 -135
  13. package/core/lib/loader/mixin/controller.js +125 -124
  14. package/core/lib/loader/mixin/service.js +28 -28
  15. package/core/lib/utils/base_context_class.js +34 -34
  16. package/core/lib/utils/function.js +30 -0
  17. package/core/lib/utils/index.js +127 -127
  18. package/core/lib/utils/sequencify.js +59 -59
  19. package/core/lib/utils/timing.js +77 -77
  20. package/index.js +49 -49
  21. package/lib/appLoader.js +48 -53
  22. package/lib/application.js +85 -84
  23. package/lib/baseApp.js +114 -131
  24. package/lib/eeApp.js +325 -359
  25. package/{lib/constant.js → module/const/index.js} +12 -9
  26. package/{lib/httpclient.js → module/httpclient/index.js} +170 -136
  27. package/module/jobs/child/forkProcess.js +99 -0
  28. package/module/jobs/child/index.js +33 -0
  29. package/module/jobs/index.js +55 -0
  30. package/module/jobs/renderer/index.js +140 -0
  31. package/module/jobs/renderer/loadView.js +40 -0
  32. package/module/loader/index.js +78 -0
  33. package/module/log/index.js +53 -0
  34. package/module/log/logger.js +61 -0
  35. package/module/message/index.js +13 -0
  36. package/module/message/ipcMain.js +160 -0
  37. package/module/message/ipcRender.js +0 -0
  38. package/{lib → module}/socket/httpServer.js +142 -142
  39. package/{lib → module}/socket/io.js +23 -23
  40. package/{lib → module}/socket/ipcServer.js +106 -108
  41. package/{lib → module}/socket/socketClient.js +51 -50
  42. package/{lib → module}/socket/socketServer.js +77 -76
  43. package/module/socket/start.js +22 -0
  44. package/{lib → module}/storage/index.js +35 -34
  45. package/module/storage/jsondb/adapters/Base.js +14 -0
  46. package/module/storage/jsondb/adapters/FileSync.js +32 -0
  47. package/{lib/storage/lowdb → module/storage/jsondb}/main.js +42 -46
  48. package/{lib/storage/lowdbStorage.js → module/storage/jsondbStorage.js} +98 -99
  49. package/{lib → module}/storage/sqliteStorage.js +123 -127
  50. package/module/utils/copyto.js +161 -0
  51. package/module/utils/helper.js +117 -0
  52. package/module/utils/index.js +120 -0
  53. package/module/utils/json.js +72 -0
  54. package/module/utils/ps.js +175 -0
  55. package/{utils → module/utils}/wrap.js +35 -37
  56. package/package.json +44 -48
  57. package/tools/encrypt.js +274 -274
  58. package/tools/replaceDist.js +61 -61
  59. package/utils/index.js +128 -246
  60. package/lib/logger.js +0 -47
  61. package/lib/socket/start.js +0 -22
  62. package/lib/storage/lowdb/adapters/Base.js +0 -15
  63. package/lib/storage/lowdb/adapters/FileAsync.js +0 -41
  64. package/lib/storage/lowdb/adapters/FileSync.js +0 -39
  65. package/lib/storage/lowdb/adapters/LocalStorage.js +0 -20
  66. package/lib/storage/lowdb/adapters/Memory.js +0 -8
  67. package/lib/storage/lowdb/adapters/_stringify.js +0 -4
  68. package/lib/storage/lowdb/common.js +0 -33
  69. package/lib/storage/lowdb/fp.js +0 -23
  70. package/lib/storage/lowdb/is-promise.js +0 -6
  71. package/lib/storage/lowdb/nano.js +0 -5
  72. package/utils/common.js +0 -91
@@ -1,8 +0,0 @@
1
- const Base = require('./Base')
2
-
3
- module.exports = class Memory extends Base {
4
- read() {
5
- return this.defaultValue
6
- }
7
- write() {}
8
- }
@@ -1,4 +0,0 @@
1
- // Pretty stringify
2
- module.exports = function stringify(obj) {
3
- return JSON.stringify(obj, null, 2)
4
- }
@@ -1,33 +0,0 @@
1
- const isPromise = require('./is-promise')
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
- }
@@ -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
- }
@@ -1,6 +0,0 @@
1
- module.exports = isPromise;
2
- module.exports.default = isPromise;
3
-
4
- function isPromise(obj) {
5
- return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
6
- }
@@ -1,5 +0,0 @@
1
- const common = require('./common')
2
-
3
- module.exports = function(adapter) {
4
- return common.init({}, '__state__', adapter)
5
- }
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
- }