ee-core 1.2.7-beta → 1.2.7-beta.3

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 (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -2
  3. package/bin/tools.js +22 -22
  4. package/config/config.default.js +247 -247
  5. package/core/index.js +12 -12
  6. package/core/lib/ee.js +209 -209
  7. package/core/lib/loader/context_loader.js +105 -105
  8. package/core/lib/loader/ee_loader.js +451 -451
  9. package/core/lib/loader/file_loader.js +262 -262
  10. package/core/lib/loader/mixin/config.js +138 -138
  11. package/core/lib/loader/mixin/controller.js +123 -123
  12. package/core/lib/loader/mixin/service.js +29 -29
  13. package/core/lib/utils/base_context_class.js +34 -34
  14. package/core/lib/utils/index.js +100 -100
  15. package/core/lib/utils/sequencify.js +59 -59
  16. package/core/lib/utils/timing.js +77 -77
  17. package/index.js +49 -49
  18. package/lib/appLoader.js +45 -45
  19. package/lib/application.js +80 -80
  20. package/lib/baseApp.js +118 -118
  21. package/lib/constant.js +28 -28
  22. package/lib/eeApp.js +326 -326
  23. package/lib/helper.js +51 -51
  24. package/lib/httpclient.js +136 -136
  25. package/lib/logger.js +46 -46
  26. package/lib/socket/httpServer.js +104 -104
  27. package/lib/socket/io.js +23 -23
  28. package/lib/socket/ipcServer.js +128 -128
  29. package/lib/socket/socketClient.js +50 -50
  30. package/lib/socket/socketServer.js +76 -76
  31. package/lib/socket/start.js +22 -22
  32. package/lib/storage/appStorage.js +13 -13
  33. package/lib/storage/index.js +21 -21
  34. package/lib/storage/lowdbStorage.js +143 -143
  35. package/package.json +45 -45
  36. package/resource/loading.html +21 -21
  37. package/resource/view_example.html +21 -21
  38. package/tools/codeCompress.js +204 -204
  39. package/tools/replaceDist.js +76 -76
  40. package/utils/common.js +30 -30
  41. package/utils/index.js +206 -202
  42. package/utils/wrap.js +37 -37
@@ -1,22 +1,22 @@
1
- 'use strict';
2
-
3
- const JsonDB = {};
4
-
5
- JsonDB.connection = function (database) {
6
-
7
- // console.log('this::::::', this);
8
- // todo
9
- // if (typeof this.instance === 'object') {
10
- // return this.instance;
11
- // }
12
-
13
- const LowdbStorage = require('./lowdbStorage');
14
- const storage = new LowdbStorage(database);
15
-
16
- // this.instance = storage;
17
- return storage;
18
- }
19
-
20
- module.exports = {
21
- JsonDB
1
+ 'use strict';
2
+
3
+ const JsonDB = {};
4
+
5
+ JsonDB.connection = function (database) {
6
+
7
+ // console.log('this::::::', this);
8
+ // todo
9
+ // if (typeof this.instance === 'object') {
10
+ // return this.instance;
11
+ // }
12
+
13
+ const LowdbStorage = require('./lowdbStorage');
14
+ const storage = new LowdbStorage(database);
15
+
16
+ // this.instance = storage;
17
+ return storage;
18
+ }
19
+
20
+ module.exports = {
21
+ JsonDB
22
22
  };
@@ -1,144 +1,144 @@
1
- 'use strict';
2
-
3
- const assert = require('assert');
4
- const fs = require('fs');
5
- const path = require('path');
6
- const lowdb = require('lowdb');
7
- const FileSync = require('lowdb/adapters/FileSync');
8
- const _ = require('lodash');
9
- const constant = require('../constant');
10
-
11
- class LowdbStorage {
12
- constructor (name, opt = {}) {
13
- assert(name, `db name ${name} Cannot be empty`);
14
-
15
- this.name = name;
16
-
17
- // 数据库key列表
18
- this.storageKey = constant.storageKey;
19
-
20
- const storageDir = this.getStorageDir();
21
- if (!fs.existsSync(storageDir)) {
22
- this.mkdir(storageDir);
23
- this.chmodPath(storageDir, '777');
24
- }
25
-
26
- this.db = this.table(name);
27
- }
28
-
29
- /**
30
- * 创建 table
31
- */
32
- table (name) {
33
- assert(name, 'table name is required');
34
-
35
- const dbFile = this.getFilePath(name);
36
- const adapter = new FileSync(dbFile);
37
- const db = lowdb(adapter);
38
-
39
- assert(fs.existsSync(dbFile), `error: storage ${dbFile} not exists`);
40
-
41
- return db;
42
- }
43
-
44
- /**
45
- * 获取db文件名
46
- */
47
- getFileName (name) {
48
- return name + ".json";
49
- }
50
-
51
- /**
52
- * 获取db文件名
53
- */
54
- getFilePath (name) {
55
- const storageDir = this.getStorageDir();
56
- const dbFile = path.join(storageDir, this.getFileName(name));
57
- return dbFile;
58
- }
59
-
60
- /**
61
- * 获取数据存储路径
62
- */
63
- getStorageDir () {
64
- let env = process.env.EE_SERVER_ENV;
65
- const appDir = env === 'local' || env === 'unittest' ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
66
- const storageDir = path.join(appDir, 'data');
67
- return storageDir;
68
- }
69
-
70
- /**
71
- * 为指定的 name 设置一个对应的值
72
- */
73
- setItem (key, value) {
74
- assert(_.isString(key), `key must be a string`);
75
- assert(key.length != 0, `key cannot be empty`);
76
- assert(!this.storageKey.hasOwnProperty(key), `${key} is not allowed`);
77
-
78
- let cacheKey = this.storageKey.cache;
79
- if (!this.db.has(cacheKey).value()) {
80
- this.db.set(cacheKey, {}).write();
81
- }
82
-
83
- let keyId = cacheKey + "." + key;
84
- this.db
85
- .set(keyId, value)
86
- .write();
87
-
88
- return true;
89
- }
90
-
91
- /**
92
- * 根据指定的名字 name 获取对应的值
93
- */
94
- getItem (key) {
95
- assert(_.isString(key), `key must be a string`);
96
- assert(key.length != 0, `key cannot be empty`);
97
-
98
- let cacheKey = this.storageKey.cache;
99
- let keyId = cacheKey + "." + key;
100
- const data = this.db
101
- .get(keyId)
102
- .value();
103
-
104
- return data;
105
- }
106
-
107
- mkdir (dirpath, dirname) {
108
- if (typeof dirname === 'undefined') {
109
- if (fs.existsSync(dirpath)) {
110
- return;
111
- }
112
- this.mkdir(dirpath, path.dirname(dirpath));
113
- } else {
114
- if (dirname !== path.dirname(dirpath)) {
115
- this.mkdir(dirpath);
116
- return;
117
- }
118
- if (fs.existsSync(dirname)) {
119
- fs.mkdirSync(dirpath);
120
- } else {
121
- this.mkdir(dirname, path.dirname(dirname));
122
- fs.mkdirSync(dirpath);
123
- }
124
- }
125
- };
126
-
127
- chmodPath (path, mode) {
128
- let files = [];
129
- if (fs.existsSync(path)) {
130
- files = fs.readdirSync(path);
131
- files.forEach((file, index) => {
132
- const curPath = path + '/' + file;
133
- if (fs.statSync(curPath).isDirectory()) {
134
- this.chmodPath(curPath, mode);
135
- } else {
136
- fs.chmodSync(curPath, mode);
137
- }
138
- });
139
- fs.chmodSync(path, mode);
140
- }
141
- };
142
- }
143
-
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const lowdb = require('lowdb');
7
+ const FileSync = require('lowdb/adapters/FileSync');
8
+ const _ = require('lodash');
9
+ const constant = require('../constant');
10
+
11
+ class LowdbStorage {
12
+ constructor (name, opt = {}) {
13
+ assert(name, `db name ${name} Cannot be empty`);
14
+
15
+ this.name = name;
16
+
17
+ // 数据库key列表
18
+ this.storageKey = constant.storageKey;
19
+
20
+ const storageDir = this.getStorageDir();
21
+ if (!fs.existsSync(storageDir)) {
22
+ this.mkdir(storageDir);
23
+ this.chmodPath(storageDir, '777');
24
+ }
25
+
26
+ this.db = this.table(name);
27
+ }
28
+
29
+ /**
30
+ * 创建 table
31
+ */
32
+ table (name) {
33
+ assert(name, 'table name is required');
34
+
35
+ const dbFile = this.getFilePath(name);
36
+ const adapter = new FileSync(dbFile);
37
+ const db = lowdb(adapter);
38
+
39
+ assert(fs.existsSync(dbFile), `error: storage ${dbFile} not exists`);
40
+
41
+ return db;
42
+ }
43
+
44
+ /**
45
+ * 获取db文件名
46
+ */
47
+ getFileName (name) {
48
+ return name + ".json";
49
+ }
50
+
51
+ /**
52
+ * 获取db文件名
53
+ */
54
+ getFilePath (name) {
55
+ const storageDir = this.getStorageDir();
56
+ const dbFile = path.join(storageDir, this.getFileName(name));
57
+ return dbFile;
58
+ }
59
+
60
+ /**
61
+ * 获取数据存储路径
62
+ */
63
+ getStorageDir () {
64
+ let env = process.env.EE_SERVER_ENV;
65
+ const appDir = env === 'local' || env === 'unittest' ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
66
+ const storageDir = path.join(appDir, 'data');
67
+ return storageDir;
68
+ }
69
+
70
+ /**
71
+ * 为指定的 name 设置一个对应的值
72
+ */
73
+ setItem (key, value) {
74
+ assert(_.isString(key), `key must be a string`);
75
+ assert(key.length != 0, `key cannot be empty`);
76
+ assert(!this.storageKey.hasOwnProperty(key), `${key} is not allowed`);
77
+
78
+ let cacheKey = this.storageKey.cache;
79
+ if (!this.db.has(cacheKey).value()) {
80
+ this.db.set(cacheKey, {}).write();
81
+ }
82
+
83
+ let keyId = cacheKey + "." + key;
84
+ this.db
85
+ .set(keyId, value)
86
+ .write();
87
+
88
+ return true;
89
+ }
90
+
91
+ /**
92
+ * 根据指定的名字 name 获取对应的值
93
+ */
94
+ getItem (key) {
95
+ assert(_.isString(key), `key must be a string`);
96
+ assert(key.length != 0, `key cannot be empty`);
97
+
98
+ let cacheKey = this.storageKey.cache;
99
+ let keyId = cacheKey + "." + key;
100
+ const data = this.db
101
+ .get(keyId)
102
+ .value();
103
+
104
+ return data;
105
+ }
106
+
107
+ mkdir (dirpath, dirname) {
108
+ if (typeof dirname === 'undefined') {
109
+ if (fs.existsSync(dirpath)) {
110
+ return;
111
+ }
112
+ this.mkdir(dirpath, path.dirname(dirpath));
113
+ } else {
114
+ if (dirname !== path.dirname(dirpath)) {
115
+ this.mkdir(dirpath);
116
+ return;
117
+ }
118
+ if (fs.existsSync(dirname)) {
119
+ fs.mkdirSync(dirpath);
120
+ } else {
121
+ this.mkdir(dirname, path.dirname(dirname));
122
+ fs.mkdirSync(dirpath);
123
+ }
124
+ }
125
+ };
126
+
127
+ chmodPath (path, mode) {
128
+ let files = [];
129
+ if (fs.existsSync(path)) {
130
+ files = fs.readdirSync(path);
131
+ files.forEach((file, index) => {
132
+ const curPath = path + '/' + file;
133
+ if (fs.statSync(curPath).isDirectory()) {
134
+ this.chmodPath(curPath, mode);
135
+ } else {
136
+ fs.chmodSync(curPath, mode);
137
+ }
138
+ });
139
+ fs.chmodSync(path, mode);
140
+ }
141
+ };
142
+ }
143
+
144
144
  module.exports = LowdbStorage;
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "ee-core",
3
- "version": "1.2.7-beta",
4
- "description": "ee core",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "",
10
- "license": "ISC",
11
- "bin": {
12
- "ee-core": "./bin/tools.js"
13
- },
14
- "dependencies": {
15
- "agentkeepalive": "^4.2.0",
16
- "co": "^4.6.0",
17
- "debug": "^4.3.3",
18
- "depd": "^2.0.0",
19
- "egg-errors": "^2.3.0",
20
- "egg-logger": "^2.7.1",
21
- "electron-is": "^3.0.0",
22
- "electron-updater": "^4.6.1",
23
- "extend2": "^1.0.1",
24
- "fs-extra": "^10.0.0",
25
- "get-port": "^5.1.1",
26
- "globby": "^10.0.0",
27
- "humanize-ms": "^1.2.1",
28
- "is-type-of": "^1.2.1",
29
- "koa": "^2.13.4",
30
- "koa-bodyparser": "^4.3.0",
31
- "koa-convert": "^2.0.0",
32
- "koa-static": "^5.0.0",
33
- "koa2-cors": "^2.0.6",
34
- "lodash": "^4.17.21",
35
- "lowdb": "^1.0.0",
36
- "path-to-regexp": "^6.2.0",
37
- "socket.io": "^4.4.1",
38
- "socket.io-client": "^4.4.1",
39
- "uglify-js": "^3.14.5",
40
- "unzip-crx-3": "^0.2.0",
41
- "urllib": "^2.38.0",
42
- "utility": "^1.17.0"
43
- },
44
- "devDependencies": {}
45
- }
1
+ {
2
+ "name": "ee-core",
3
+ "version": "1.2.7-beta.3",
4
+ "description": "ee core",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "bin": {
12
+ "ee-core": "./bin/tools.js"
13
+ },
14
+ "dependencies": {
15
+ "agentkeepalive": "^4.2.0",
16
+ "co": "^4.6.0",
17
+ "debug": "^4.3.3",
18
+ "depd": "^2.0.0",
19
+ "egg-errors": "^2.3.0",
20
+ "egg-logger": "^2.7.1",
21
+ "electron-is": "^3.0.0",
22
+ "electron-updater": "^4.6.1",
23
+ "extend2": "^1.0.1",
24
+ "fs-extra": "^10.0.0",
25
+ "get-port": "^5.1.1",
26
+ "globby": "^10.0.0",
27
+ "humanize-ms": "^1.2.1",
28
+ "is-type-of": "^1.2.1",
29
+ "koa": "^2.13.4",
30
+ "koa-bodyparser": "^4.3.0",
31
+ "koa-convert": "^2.0.0",
32
+ "koa-static": "^5.0.0",
33
+ "koa2-cors": "^2.0.6",
34
+ "lodash": "^4.17.21",
35
+ "lowdb": "^1.0.0",
36
+ "path-to-regexp": "^6.2.0",
37
+ "socket.io": "^4.4.1",
38
+ "socket.io-client": "^4.4.1",
39
+ "uglify-js": "^3.14.5",
40
+ "unzip-crx-3": "^0.2.0",
41
+ "urllib": "^2.38.0",
42
+ "utility": "^1.17.0"
43
+ },
44
+ "devDependencies": {}
45
+ }
@@ -1,22 +1,22 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
- <style type="text/css">
5
- body{
6
- margin:0px auto;
7
- }
8
- #picture1 {
9
- position: absolute;
10
- left: 50%;
11
- top: 35%;
12
- transform: translate(-50%, -50%);
13
- }
14
- </style>
15
- <title></title>
16
- </head>
17
- <body>
18
- <div id="picture1">
19
- <img src="./images/loding.gif" />
20
- </div>
21
- </body>
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <style type="text/css">
5
+ body{
6
+ margin:0px auto;
7
+ }
8
+ #picture1 {
9
+ position: absolute;
10
+ left: 50%;
11
+ top: 35%;
12
+ transform: translate(-50%, -50%);
13
+ }
14
+ </style>
15
+ <title></title>
16
+ </head>
17
+ <body>
18
+ <div id="picture1">
19
+ <img src="./images/loding.gif" />
20
+ </div>
21
+ </body>
22
22
  </html>
@@ -1,22 +1,22 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
- <style type="text/css">
5
- body{
6
- margin:0px auto;
7
- }
8
- #content {
9
- position: absolute;
10
- left: 50%;
11
- top: 35%;
12
- transform: translate(-50%, -50%);
13
- }
14
- </style>
15
- <title></title>
16
- </head>
17
- <body>
18
- <div id="content">
19
- 这是一个html页面
20
- </div>
21
- </body>
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <style type="text/css">
5
+ body{
6
+ margin:0px auto;
7
+ }
8
+ #content {
9
+ position: absolute;
10
+ left: 50%;
11
+ top: 35%;
12
+ transform: translate(-50%, -50%);
13
+ }
14
+ </style>
15
+ <title></title>
16
+ </head>
17
+ <body>
18
+ <div id="content">
19
+ 这是一个html页面
20
+ </div>
21
+ </body>
22
22
  </html>