@eggjs/core 7.0.0-beta.34 → 7.0.0-beta.36
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/dist/base_context_class.d.ts +19 -14
- package/dist/base_context_class.js +39 -36
- package/dist/egg.d.ts +279 -277
- package/dist/egg.js +394 -426
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -12
- package/dist/lifecycle.d.ts +79 -75
- package/dist/lifecycle.js +280 -306
- package/dist/loader/context_loader.d.ts +34 -30
- package/dist/loader/context_loader.js +76 -99
- package/dist/loader/egg_loader.d.ts +370 -366
- package/dist/loader/egg_loader.js +1170 -1568
- package/dist/loader/file_loader.d.ts +99 -95
- package/dist/loader/file_loader.js +190 -241
- package/dist/singleton.d.ts +31 -27
- package/dist/singleton.js +107 -117
- package/dist/types.d.ts +54 -51
- package/dist/utils/index.d.ts +16 -14
- package/dist/utils/index.js +96 -105
- package/dist/utils/sequencify.d.ts +13 -10
- package/dist/utils/sequencify.js +44 -58
- package/dist/utils/timing.d.ts +22 -19
- package/dist/utils/timing.js +85 -92
- package/package.json +36 -41
- package/dist/types.js +0 -2
|
@@ -1,101 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Fun } from "../utils/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/loader/file_loader.d.ts
|
|
4
|
+
declare const FULLPATH: unique symbol;
|
|
5
|
+
declare const EXPORTS: unique symbol;
|
|
6
|
+
declare const CaseStyle: {
|
|
7
|
+
readonly camel: "camel";
|
|
8
|
+
readonly lower: "lower";
|
|
9
|
+
readonly upper: "upper";
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
type CaseStyle = (typeof CaseStyle)[keyof typeof CaseStyle];
|
|
12
|
+
type CaseStyleFunction = (filepath: string) => string[];
|
|
13
|
+
type FileLoaderInitializer = (exports: unknown, options: {
|
|
14
|
+
path: string;
|
|
15
|
+
pathName: string;
|
|
14
16
|
}) => unknown;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
type FileLoaderFilter = (exports: unknown) => boolean;
|
|
18
|
+
interface FileLoaderOptions {
|
|
19
|
+
/** directories to be loaded */
|
|
20
|
+
directory: string | string[];
|
|
21
|
+
/** attach the target object from loaded files */
|
|
22
|
+
target: Record<string, any>;
|
|
23
|
+
/** match the files when load, support glob, default to all js files */
|
|
24
|
+
match?: string | string[];
|
|
25
|
+
/** ignore the files when load, support glob */
|
|
26
|
+
ignore?: string | string[];
|
|
27
|
+
/** 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` */
|
|
28
|
+
initializer?: FileLoaderInitializer;
|
|
29
|
+
/** determine whether invoke when exports is function */
|
|
30
|
+
call?: boolean;
|
|
31
|
+
/** determine whether override the property when get the same name */
|
|
32
|
+
override?: boolean;
|
|
33
|
+
/** an object that be the argument when invoke the function */
|
|
34
|
+
inject?: Record<string, any>;
|
|
35
|
+
/** a function that filter the exports which can be loaded */
|
|
36
|
+
filter?: FileLoaderFilter;
|
|
37
|
+
/** set property's case when converting a filepath to property list. */
|
|
38
|
+
caseStyle?: CaseStyle | CaseStyleFunction;
|
|
39
|
+
lowercaseFirst?: boolean;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
interface FileLoaderParseItem {
|
|
42
|
+
fullpath: string;
|
|
43
|
+
properties: string[];
|
|
44
|
+
exports: object | Fun;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
47
|
+
* Load files from directory to target object.
|
|
48
|
+
* @since 1.0.0
|
|
49
|
+
*/
|
|
50
|
+
declare class FileLoader {
|
|
51
|
+
static get FULLPATH(): typeof FULLPATH;
|
|
52
|
+
static get EXPORTS(): typeof EXPORTS;
|
|
53
|
+
readonly options: FileLoaderOptions & Required<Pick<FileLoaderOptions, "caseStyle">>;
|
|
54
|
+
/**
|
|
55
|
+
* @class
|
|
56
|
+
* @param {Object} options - options
|
|
57
|
+
* @param {String|Array} options.directory - directories to be loaded
|
|
58
|
+
* @param {Object} options.target - attach the target object from loaded files
|
|
59
|
+
* @param {String} options.match - match the files when load, support glob, default to all js files
|
|
60
|
+
* @param {String} options.ignore - ignore the files when load, support glob
|
|
61
|
+
* @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`
|
|
62
|
+
* @param {Boolean} options.call - determine whether invoke when exports is function
|
|
63
|
+
* @param {Boolean} options.override - determine whether override the property when get the same name
|
|
64
|
+
* @param {Object} options.inject - an object that be the argument when invoke the function
|
|
65
|
+
* @param {Function} options.filter - a function that filter the exports which can be loaded
|
|
66
|
+
* @param {String|Function} options.caseStyle - set property's case when converting a filepath to property list.
|
|
67
|
+
*/
|
|
68
|
+
constructor(options: FileLoaderOptions);
|
|
69
|
+
/**
|
|
70
|
+
* attach items to target object. Mapping the directory to properties.
|
|
71
|
+
* `app/controller/group/repository.js` => `target.group.repository`
|
|
72
|
+
* @returns {Object} target
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*/
|
|
75
|
+
load(): Promise<object>;
|
|
76
|
+
/**
|
|
77
|
+
* Parse files from given directories, then return an items list, each item contains properties and exports.
|
|
78
|
+
*
|
|
79
|
+
* For example, parse `app/controller/group/repository.js`
|
|
80
|
+
*
|
|
81
|
+
* ```
|
|
82
|
+
* module.exports = app => {
|
|
83
|
+
* return class RepositoryController extends app.Controller {};
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* It returns a item
|
|
88
|
+
*
|
|
89
|
+
* ```
|
|
90
|
+
* {
|
|
91
|
+
* properties: [ 'group', 'repository' ],
|
|
92
|
+
* exports: app => { ... },
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* `Properties` is an array that contains the directory of a filepath.
|
|
97
|
+
*
|
|
98
|
+
* `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.
|
|
99
|
+
* @returns {Array} items
|
|
100
|
+
* @since 1.0.0
|
|
101
|
+
*/
|
|
102
|
+
protected parse(): Promise<FileLoaderParseItem[]>;
|
|
101
103
|
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { CaseStyle, CaseStyleFunction, EXPORTS, FULLPATH, FileLoader, FileLoaderFilter, FileLoaderInitializer, FileLoaderOptions, FileLoaderParseItem };
|