ee-core 4.1.2 → 4.1.4
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/LICENSE +21 -21
- package/README.md +65 -65
- package/app/application.d.ts +5 -5
- package/app/application.js +30 -30
- package/app/boot.d.ts +5 -5
- package/app/boot.js +80 -80
- package/app/dir.d.ts +1 -1
- package/app/dir.js +26 -26
- package/app/events.d.ts +14 -14
- package/app/events.js +55 -55
- package/app/index.d.ts +2 -2
- package/app/index.js +6 -6
- package/config/config_loader.d.ts +13 -13
- package/config/config_loader.js +65 -65
- package/config/default_config.d.ts +95 -95
- package/config/default_config.js +111 -111
- package/config/index.d.ts +28 -28
- package/config/index.js +24 -24
- package/const/channel.d.ts +16 -16
- package/const/channel.js +27 -27
- package/controller/controller_loader.d.ts +9 -9
- package/controller/controller_loader.js +77 -77
- package/controller/index.d.ts +2 -2
- package/controller/index.js +24 -24
- package/core/index.d.ts +2 -2
- package/core/index.js +11 -11
- package/core/loader/file_loader.d.ts +66 -66
- package/core/loader/file_loader.js +211 -211
- package/core/utils/index.d.ts +12 -12
- package/core/utils/index.js +83 -83
- package/core/utils/timing.d.ts +22 -22
- package/core/utils/timing.js +78 -78
- package/cross/cross.d.ts +19 -19
- package/cross/cross.js +151 -151
- package/cross/crossProcess.d.ts +29 -29
- package/cross/crossProcess.js +172 -172
- package/cross/index.d.ts +2 -2
- package/cross/index.js +8 -8
- package/electron/app/index.d.ts +5 -5
- package/electron/app/index.js +48 -48
- package/electron/index.d.ts +3 -3
- package/electron/index.js +15 -15
- package/electron/window/index.d.ts +6 -6
- package/electron/window/index.js +268 -268
- package/exception/index.d.ts +9 -9
- package/exception/index.js +100 -100
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.d.ts +1 -1
- package/html/index.js +10 -10
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/jobs/child/app.d.ts +1 -1
- package/jobs/child/app.js +69 -69
- package/jobs/child/index.d.ts +13 -13
- package/jobs/child/index.js +85 -85
- package/jobs/child/jobProcess.d.ts +16 -16
- package/jobs/child/jobProcess.js +133 -133
- package/jobs/child-pool/index.d.ts +26 -26
- package/jobs/child-pool/index.js +190 -190
- package/jobs/index.d.ts +3 -3
- package/jobs/index.js +6 -6
- package/jobs/load-balancer/algorithm/index.d.ts +4 -4
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.d.ts +2 -2
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.d.ts +8 -8
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.d.ts +96 -96
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.d.ts +16 -16
- package/jobs/load-balancer/scheduler.js +31 -31
- package/loader/index.d.ts +9 -9
- package/loader/index.js +99 -98
- package/log/index.d.ts +5 -5
- package/log/index.js +85 -85
- package/log/logger.d.ts +1 -1
- package/log/logger.js +94 -94
- package/message/childMessage.d.ts +10 -10
- package/message/childMessage.js +43 -43
- package/message/index.d.ts +3 -3
- package/message/index.js +9 -9
- package/package.json +42 -42
- package/ps/index.d.ts +39 -39
- package/ps/index.js +294 -294
- package/socket/httpServer.d.ts +8 -8
- package/socket/httpServer.js +199 -199
- package/socket/index.d.ts +10 -10
- package/socket/index.js +64 -64
- package/socket/ipcServer.d.ts +9 -9
- package/socket/ipcServer.js +105 -105
- package/socket/socketServer.d.ts +10 -10
- package/socket/socketServer.js +81 -81
- package/storage/index.d.ts +4 -4
- package/storage/index.js +6 -6
- package/storage/sqliteStorage.d.ts +16 -16
- package/storage/sqliteStorage.js +123 -123
- package/tsconfig.json +13 -13
- package/utils/extend.d.ts +2 -2
- package/utils/extend.js +77 -77
- package/utils/helper.d.ts +14 -14
- package/utils/helper.js +206 -206
- package/utils/index.d.ts +10 -10
- package/utils/index.js +167 -167
- package/utils/ip.d.ts +2 -2
- package/utils/ip.js +221 -221
- package/utils/is.d.ts +14 -14
- package/utils/is.js +111 -111
- package/utils/json.d.ts +5 -5
- package/utils/json.js +79 -79
- package/utils/pargv.d.ts +3 -3
- package/utils/pargv.js +267 -267
- package/utils/port/index.d.ts +1 -1
- package/utils/port/index.js +125 -125
- package/utils/wrap.d.ts +4 -4
- package/utils/wrap.js +40 -40
package/const/channel.js
CHANGED
|
@@ -1,28 +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
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
Processes,
|
|
25
|
-
SocketIO,
|
|
26
|
-
Events,
|
|
27
|
-
Receiver
|
|
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
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
Processes,
|
|
25
|
+
SocketIO,
|
|
26
|
+
Events,
|
|
27
|
+
Receiver
|
|
28
28
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Timing } from "../core/utils/timing";
|
|
2
|
-
export declare class ControllerLoader {
|
|
3
|
-
timing: Timing;
|
|
4
|
-
/**
|
|
5
|
-
* Load controller/xxx.js
|
|
6
|
-
*/
|
|
7
|
-
load(): any;
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
import { Timing } from "../core/utils/timing";
|
|
2
|
+
export declare class ControllerLoader {
|
|
3
|
+
timing: Timing;
|
|
4
|
+
/**
|
|
5
|
+
* Load controller/xxx.js
|
|
6
|
+
*/
|
|
7
|
+
load(): any;
|
|
8
|
+
}
|
|
9
|
+
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')('ee-core:controller:controller_loader');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const is = require('is-type-of');
|
|
6
|
-
const { getElectronDir } = require('../ps');
|
|
7
|
-
const { Timing } = require('../core/utils/timing');
|
|
8
|
-
const { FileLoader, FULLPATH } = require('../core/loader/file_loader');
|
|
9
|
-
const { isBytecodeClass, callFn } = require('../core/utils');
|
|
10
|
-
|
|
11
|
-
class ControllerLoader {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.timing = new Timing();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Load controller/xxx.js
|
|
18
|
-
*/
|
|
19
|
-
load() {
|
|
20
|
-
this.timing.start('Load Controller');
|
|
21
|
-
|
|
22
|
-
const opt = {
|
|
23
|
-
caseStyle: 'lower',
|
|
24
|
-
directory: path.join(getElectronDir(), 'controller'),
|
|
25
|
-
initializer: (obj, opt) => {
|
|
26
|
-
if (is.class(obj) || isBytecodeClass(obj)) {
|
|
27
|
-
obj.prototype.pathName = opt.pathName;
|
|
28
|
-
obj.prototype.fullPath = opt.path;
|
|
29
|
-
return wrapClass(obj);
|
|
30
|
-
}
|
|
31
|
-
return obj;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
const target = new FileLoader(opt).load();
|
|
35
|
-
debug("[load] controllers: %o", target);
|
|
36
|
-
this.timing.end('Load Controller');
|
|
37
|
-
return target;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// wrap the class, yield a object with middlewares
|
|
42
|
-
function wrapClass(Controller) {
|
|
43
|
-
let proto = Controller.prototype;
|
|
44
|
-
const ret = {};
|
|
45
|
-
// tracing the prototype chain
|
|
46
|
-
while (proto !== Object.prototype) {
|
|
47
|
-
const keys = Object.getOwnPropertyNames(proto);
|
|
48
|
-
// debug("[wrapClass] keys:", keys);
|
|
49
|
-
for (const key of keys) {
|
|
50
|
-
// getOwnPropertyNames will return constructor
|
|
51
|
-
// that should be ignored
|
|
52
|
-
if (key === 'constructor') {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
// skip getter, setter & non-function properties
|
|
56
|
-
const d = Object.getOwnPropertyDescriptor(proto, key);
|
|
57
|
-
// prevent to override sub method
|
|
58
|
-
if (is.function(d.value) && !ret.hasOwnProperty(key)) {
|
|
59
|
-
ret[key] = methodToMiddleware(Controller, key);
|
|
60
|
-
ret[key][FULLPATH] = Controller.prototype.fullPath + '#' + Controller.name + '.' + key + '()';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
proto = Object.getPrototypeOf(proto);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return ret;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function methodToMiddleware(Controller, key) {
|
|
70
|
-
return function classControllerMiddleware(...args) {
|
|
71
|
-
const controller = new Controller();
|
|
72
|
-
return callFn(controller[key], args, controller);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
ControllerLoader
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ee-core:controller:controller_loader');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const is = require('is-type-of');
|
|
6
|
+
const { getElectronDir } = require('../ps');
|
|
7
|
+
const { Timing } = require('../core/utils/timing');
|
|
8
|
+
const { FileLoader, FULLPATH } = require('../core/loader/file_loader');
|
|
9
|
+
const { isBytecodeClass, callFn } = require('../core/utils');
|
|
10
|
+
|
|
11
|
+
class ControllerLoader {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.timing = new Timing();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Load controller/xxx.js
|
|
18
|
+
*/
|
|
19
|
+
load() {
|
|
20
|
+
this.timing.start('Load Controller');
|
|
21
|
+
|
|
22
|
+
const opt = {
|
|
23
|
+
caseStyle: 'lower',
|
|
24
|
+
directory: path.join(getElectronDir(), 'controller'),
|
|
25
|
+
initializer: (obj, opt) => {
|
|
26
|
+
if (is.class(obj) || isBytecodeClass(obj)) {
|
|
27
|
+
obj.prototype.pathName = opt.pathName;
|
|
28
|
+
obj.prototype.fullPath = opt.path;
|
|
29
|
+
return wrapClass(obj);
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const target = new FileLoader(opt).load();
|
|
35
|
+
debug("[load] controllers: %o", target);
|
|
36
|
+
this.timing.end('Load Controller');
|
|
37
|
+
return target;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// wrap the class, yield a object with middlewares
|
|
42
|
+
function wrapClass(Controller) {
|
|
43
|
+
let proto = Controller.prototype;
|
|
44
|
+
const ret = {};
|
|
45
|
+
// tracing the prototype chain
|
|
46
|
+
while (proto !== Object.prototype) {
|
|
47
|
+
const keys = Object.getOwnPropertyNames(proto);
|
|
48
|
+
// debug("[wrapClass] keys:", keys);
|
|
49
|
+
for (const key of keys) {
|
|
50
|
+
// getOwnPropertyNames will return constructor
|
|
51
|
+
// that should be ignored
|
|
52
|
+
if (key === 'constructor') {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// skip getter, setter & non-function properties
|
|
56
|
+
const d = Object.getOwnPropertyDescriptor(proto, key);
|
|
57
|
+
// prevent to override sub method
|
|
58
|
+
if (is.function(d.value) && !ret.hasOwnProperty(key)) {
|
|
59
|
+
ret[key] = methodToMiddleware(Controller, key);
|
|
60
|
+
ret[key][FULLPATH] = Controller.prototype.fullPath + '#' + Controller.name + '.' + key + '()';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
proto = Object.getPrototypeOf(proto);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return ret;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function methodToMiddleware(Controller, key) {
|
|
70
|
+
return function classControllerMiddleware(...args) {
|
|
71
|
+
const controller = new Controller();
|
|
72
|
+
return callFn(controller[key], args, controller);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
ControllerLoader
|
|
78
78
|
};
|
package/controller/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function loadController(): void;
|
|
2
|
-
export declare function getController(): any;
|
|
1
|
+
export declare function loadController(): void;
|
|
2
|
+
export declare function getController(): any;
|
package/controller/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { ControllerLoader } = require('./controller_loader');
|
|
4
|
-
|
|
5
|
-
const Instance = {
|
|
6
|
-
controller: null,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
function loadController() {
|
|
10
|
-
const controllerLoader = new ControllerLoader();
|
|
11
|
-
Instance.controller = controllerLoader.load();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function getController() {
|
|
15
|
-
if (!Instance.controller) {
|
|
16
|
-
loadController();
|
|
17
|
-
}
|
|
18
|
-
return Instance.controller;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
loadController,
|
|
23
|
-
getController
|
|
24
|
-
};
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { ControllerLoader } = require('./controller_loader');
|
|
4
|
+
|
|
5
|
+
const Instance = {
|
|
6
|
+
controller: null,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function loadController() {
|
|
10
|
+
const controllerLoader = new ControllerLoader();
|
|
11
|
+
Instance.controller = controllerLoader.load();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getController() {
|
|
15
|
+
if (!Instance.controller) {
|
|
16
|
+
loadController();
|
|
17
|
+
}
|
|
18
|
+
return Instance.controller;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
loadController,
|
|
23
|
+
getController
|
|
24
|
+
};
|
package/core/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import utils = require("./utils");
|
|
2
|
-
export { EeLoader, BaseContextClass, utils };
|
|
1
|
+
import utils = require("./utils");
|
|
2
|
+
export { EeLoader, BaseContextClass, utils };
|
package/core/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const EeLoader = require('./loader/ee_loader');
|
|
4
|
-
const BaseContextClass = require('./utils/base_context_class');
|
|
5
|
-
const utils = require('./utils');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
EeLoader,
|
|
10
|
-
BaseContextClass,
|
|
11
|
-
utils,
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EeLoader = require('./loader/ee_loader');
|
|
4
|
+
const BaseContextClass = require('./utils/base_context_class');
|
|
5
|
+
const utils = require('./utils');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
EeLoader,
|
|
10
|
+
BaseContextClass,
|
|
11
|
+
utils,
|
|
12
12
|
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load files from directory to target object.
|
|
3
|
-
*/
|
|
4
|
-
export declare class FileLoader {
|
|
5
|
-
/**
|
|
6
|
-
* @class
|
|
7
|
-
* @param {Object} options - options
|
|
8
|
-
* @param {String|Array} options.directory - directories to be loaded
|
|
9
|
-
* @param {Object} options.target - attach the target object from loaded files
|
|
10
|
-
* @param {String} options.match - match the files when load, support glob, default to all js files
|
|
11
|
-
* @param {Function} options.initializer - custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an `options` object that contain `path`
|
|
12
|
-
* @param {Boolean} options.call - determine whether invoke when exports is function
|
|
13
|
-
* @param {Object} options.inject - an object that be the argument when invoke the function
|
|
14
|
-
* @param {String|Function} options.caseStyle - set property's case when converting a filepath to property list.
|
|
15
|
-
*/
|
|
16
|
-
constructor(options: {
|
|
17
|
-
directory: string | any[];
|
|
18
|
-
target: any;
|
|
19
|
-
match: string;
|
|
20
|
-
initializer: Function;
|
|
21
|
-
call: boolean;
|
|
22
|
-
inject: any;
|
|
23
|
-
caseStyle: string | Function;
|
|
24
|
-
});
|
|
25
|
-
options: {
|
|
26
|
-
directory: any;
|
|
27
|
-
target: any;
|
|
28
|
-
match: any;
|
|
29
|
-
caseStyle: string;
|
|
30
|
-
initializer: any;
|
|
31
|
-
call: boolean;
|
|
32
|
-
inject: any;
|
|
33
|
-
} & {
|
|
34
|
-
directory: string | any[];
|
|
35
|
-
target: any;
|
|
36
|
-
match: string;
|
|
37
|
-
initializer: Function;
|
|
38
|
-
call: boolean;
|
|
39
|
-
inject: any;
|
|
40
|
-
caseStyle: string | Function;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* attach items to target object. Mapping the directory to properties.
|
|
44
|
-
* `xxx/group/repository.js` => `target.group.repository`
|
|
45
|
-
* @return {Object} target
|
|
46
|
-
*/
|
|
47
|
-
load(): any;
|
|
48
|
-
/**
|
|
49
|
-
* Parse files from given directories, then return an items list, each item contains properties and exports.
|
|
50
|
-
* For example, parse `controller/group/repository.js`
|
|
51
|
-
* It returns a item
|
|
52
|
-
* ```
|
|
53
|
-
* {
|
|
54
|
-
* fullpath: '',
|
|
55
|
-
* properties: [ 'group', 'repository' ],
|
|
56
|
-
* exports: { ... },
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
* `Properties` is an array that contains the directory of a filepath.
|
|
60
|
-
* `Exports` depends on type, if exports is a function, it will be called. if initializer is specified, it will be called with exports for customizing.
|
|
61
|
-
* @return {Array} items
|
|
62
|
-
*/
|
|
63
|
-
parse(): any[];
|
|
64
|
-
}
|
|
65
|
-
export declare const EXPORTS: unique symbol;
|
|
66
|
-
export declare const FULLPATH: unique symbol;
|
|
1
|
+
/**
|
|
2
|
+
* Load files from directory to target object.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FileLoader {
|
|
5
|
+
/**
|
|
6
|
+
* @class
|
|
7
|
+
* @param {Object} options - options
|
|
8
|
+
* @param {String|Array} options.directory - directories to be loaded
|
|
9
|
+
* @param {Object} options.target - attach the target object from loaded files
|
|
10
|
+
* @param {String} options.match - match the files when load, support glob, default to all js files
|
|
11
|
+
* @param {Function} options.initializer - custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an `options` object that contain `path`
|
|
12
|
+
* @param {Boolean} options.call - determine whether invoke when exports is function
|
|
13
|
+
* @param {Object} options.inject - an object that be the argument when invoke the function
|
|
14
|
+
* @param {String|Function} options.caseStyle - set property's case when converting a filepath to property list.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options: {
|
|
17
|
+
directory: string | any[];
|
|
18
|
+
target: any;
|
|
19
|
+
match: string;
|
|
20
|
+
initializer: Function;
|
|
21
|
+
call: boolean;
|
|
22
|
+
inject: any;
|
|
23
|
+
caseStyle: string | Function;
|
|
24
|
+
});
|
|
25
|
+
options: {
|
|
26
|
+
directory: any;
|
|
27
|
+
target: any;
|
|
28
|
+
match: any;
|
|
29
|
+
caseStyle: string;
|
|
30
|
+
initializer: any;
|
|
31
|
+
call: boolean;
|
|
32
|
+
inject: any;
|
|
33
|
+
} & {
|
|
34
|
+
directory: string | any[];
|
|
35
|
+
target: any;
|
|
36
|
+
match: string;
|
|
37
|
+
initializer: Function;
|
|
38
|
+
call: boolean;
|
|
39
|
+
inject: any;
|
|
40
|
+
caseStyle: string | Function;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* attach items to target object. Mapping the directory to properties.
|
|
44
|
+
* `xxx/group/repository.js` => `target.group.repository`
|
|
45
|
+
* @return {Object} target
|
|
46
|
+
*/
|
|
47
|
+
load(): any;
|
|
48
|
+
/**
|
|
49
|
+
* Parse files from given directories, then return an items list, each item contains properties and exports.
|
|
50
|
+
* For example, parse `controller/group/repository.js`
|
|
51
|
+
* It returns a item
|
|
52
|
+
* ```
|
|
53
|
+
* {
|
|
54
|
+
* fullpath: '',
|
|
55
|
+
* properties: [ 'group', 'repository' ],
|
|
56
|
+
* exports: { ... },
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
* `Properties` is an array that contains the directory of a filepath.
|
|
60
|
+
* `Exports` depends on type, if exports is a function, it will be called. if initializer is specified, it will be called with exports for customizing.
|
|
61
|
+
* @return {Array} items
|
|
62
|
+
*/
|
|
63
|
+
parse(): any[];
|
|
64
|
+
}
|
|
65
|
+
export declare const EXPORTS: unique symbol;
|
|
66
|
+
export declare const FULLPATH: unique symbol;
|