@eggjs/core 7.0.0-beta.35 → 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.
@@ -1,369 +1,373 @@
1
- import type { Logger } from 'egg-logger';
2
- import type { EggCore } from '../egg.ts';
3
- import type { Lifecycle } from '../lifecycle.ts';
4
- import type { EggAppConfig, EggAppInfo, EggPluginInfo } from '../types.ts';
5
- import { Timing } from '../utils/timing.ts';
6
- import { type ContextLoaderOptions, ContextLoader } from './context_loader.ts';
7
- import { type FileLoaderOptions, FileLoader } from './file_loader.ts';
8
- export interface EggLoaderOptions {
9
- /** server env */
10
- env: string;
11
- /** Application instance */
12
- app: EggCore;
13
- EggCoreClass?: typeof EggCore;
14
- /** the directory of application */
15
- baseDir: string;
16
- /** egg logger */
17
- logger: Logger;
18
- /** server scope */
19
- serverScope?: string;
20
- /** custom plugins */
21
- plugins?: Record<string, EggPluginInfo>;
1
+ import { Timing } from "../utils/timing.js";
2
+ import { Lifecycle } from "../lifecycle.js";
3
+ import { EggAppConfig, EggAppInfo, EggPluginInfo } from "../types.js";
4
+ import { FileLoader, FileLoaderOptions } from "./file_loader.js";
5
+ import { ContextLoader, ContextLoaderOptions } from "./context_loader.js";
6
+ import { EggCore } from "../egg.js";
7
+ import { Logger } from "egg-logger";
8
+
9
+ //#region src/loader/egg_loader.d.ts
10
+ interface EggLoaderOptions {
11
+ /** server env */
12
+ env: string;
13
+ /** Application instance */
14
+ app: EggCore;
15
+ EggCoreClass?: typeof EggCore;
16
+ /** the directory of application */
17
+ baseDir: string;
18
+ /** egg logger */
19
+ logger: Logger;
20
+ /** server scope */
21
+ serverScope?: string;
22
+ /** custom plugins */
23
+ plugins?: Record<string, EggPluginInfo>;
22
24
  }
23
- export type EggDirInfoType = 'app' | 'plugin' | 'framework';
24
- export interface EggDirInfo {
25
- path: string;
26
- type: EggDirInfoType;
25
+ type EggDirInfoType = "app" | "plugin" | "framework";
26
+ interface EggDirInfo {
27
+ path: string;
28
+ type: EggDirInfoType;
27
29
  }
28
- export declare class EggLoader {
29
- #private;
30
- readonly options: EggLoaderOptions;
31
- readonly timing: Timing;
32
- readonly pkg: Record<string, any>;
33
- readonly eggPaths: string[];
34
- readonly serverEnv: string;
35
- readonly serverScope: string;
36
- readonly appInfo: EggAppInfo;
37
- dirs?: EggDirInfo[];
38
- /**
39
- * @class
40
- * @param {Object} options - options
41
- * @param {String} options.baseDir - the directory of application
42
- * @param {EggCore} options.app - Application instance
43
- * @param {Logger} options.logger - logger
44
- * @param {Object} [options.plugins] - custom plugins
45
- * @since 1.0.0
46
- */
47
- constructor(options: EggLoaderOptions);
48
- get app(): EggCore;
49
- get lifecycle(): Lifecycle;
50
- get logger(): Logger;
51
- /**
52
- * Get {@link AppInfo#env}
53
- * @returns {String} env
54
- * @see AppInfo#env
55
- * @private
56
- * @since 1.0.0
57
- */
58
- protected getServerEnv(): string;
59
- /**
60
- * Get {@link AppInfo#scope}
61
- * @returns {String} serverScope
62
- * @private
63
- */
64
- protected getServerScope(): string;
65
- /**
66
- * Get {@link AppInfo#name}
67
- * @returns {String} appname
68
- * @private
69
- * @since 1.0.0
70
- */
71
- getAppname(): string;
72
- /**
73
- * Get home directory
74
- * @returns {String} home directory
75
- * @since 3.4.0
76
- */
77
- getHomedir(): string;
78
- /**
79
- * Get app info
80
- * @returns {AppInfo} appInfo
81
- * @since 1.0.0
82
- */
83
- protected getAppInfo(): EggAppInfo;
84
- /**
85
- * Get {@link EggLoader#eggPaths}
86
- * @returns {Array} framework directories
87
- * @see {@link EggLoader#eggPaths}
88
- * @private
89
- * @since 1.0.0
90
- */
91
- protected getEggPaths(): string[];
92
- /** start Plugin loader */
93
- lookupDirs: Set<string>;
94
- eggPlugins: Record<string, EggPluginInfo>;
95
- appPlugins: Record<string, EggPluginInfo>;
96
- customPlugins: Record<string, EggPluginInfo>;
97
- allPlugins: Record<string, EggPluginInfo>;
98
- orderPlugins: EggPluginInfo[];
99
- /** enable plugins */
100
- plugins: Record<string, EggPluginInfo>;
101
- /**
102
- * Load config/plugin.js from {EggLoader#loadUnits}
103
- *
104
- * plugin.js is written below
105
- *
106
- * ```js
107
- * {
108
- * 'xxx-client': {
109
- * enable: true,
110
- * package: 'xxx-client',
111
- * dep: [],
112
- * env: [],
113
- * },
114
- * // short hand
115
- * 'rds': false,
116
- * 'depd': {
117
- * enable: true,
118
- * path: 'path/to/depd'
119
- * }
120
- * }
121
- * ```
122
- *
123
- * If the plugin has path, Loader will find the module from it.
124
- *
125
- * Otherwise Loader will lookup follow the order by packageName
126
- *
127
- * 1. $APP_BASE/node_modules/${package}
128
- * 2. $EGG_BASE/node_modules/${package}
129
- *
130
- * You can call `loader.plugins` that retrieve enabled plugins.
131
- *
132
- * ```js
133
- * loader.plugins['xxx-client'] = {
134
- * name: 'xxx-client', // the plugin name, it can be used in `dep`
135
- * package: 'xxx-client', // the package name of plugin
136
- * enable: true, // whether enabled
137
- * path: 'path/to/xxx-client', // the directory of the plugin package
138
- * dep: [], // the dependent plugins, you can use the plugin name
139
- * env: [ 'local', 'unittest' ], // specify the serverEnv that only enable the plugin in it
140
- * }
141
- * ```
142
- *
143
- * `loader.allPlugins` can be used when retrieve all plugins.
144
- * @function EggLoader#loadPlugin
145
- * @since 1.0.0
146
- */
147
- loadPlugin(): Promise<void>;
148
- protected loadAppPlugins(): Promise<Record<string, EggPluginInfo>>;
149
- protected loadEggPlugins(): Promise<Record<string, EggPluginInfo>>;
150
- protected loadCustomPlugins(): Record<string, EggPluginInfo>;
151
- protected readPluginConfigs(configPaths: string[] | string): Promise<Record<string, EggPluginInfo>>;
152
- protected getOrderPlugins(allPlugins: Record<string, EggPluginInfo>, enabledPluginNames: string[], appPlugins: Record<string, EggPluginInfo>): EggPluginInfo[];
153
- protected getLookupDirs(): Set<string>;
154
- protected getPluginPath(plugin: EggPluginInfo): string;
155
- /** end Plugin loader */
156
- /** start Config loader */
157
- configMeta: Record<string, any>;
158
- config: EggAppConfig;
159
- /**
160
- * Load config/config.js
161
- *
162
- * Will merge config.default.js 和 config.${env}.js
163
- *
164
- * @function EggLoader#loadConfig
165
- * @since 1.0.0
166
- */
167
- loadConfig(): Promise<void>;
168
- /** end Config loader */
169
- /** start Extend loader */
170
- /**
171
- * mixin Agent.prototype
172
- * @function EggLoader#loadAgentExtend
173
- * @since 1.0.0
174
- */
175
- loadAgentExtend(): Promise<void>;
176
- /**
177
- * mixin Application.prototype
178
- * @function EggLoader#loadApplicationExtend
179
- * @since 1.0.0
180
- */
181
- loadApplicationExtend(): Promise<void>;
182
- /**
183
- * mixin Request.prototype
184
- * @function EggLoader#loadRequestExtend
185
- * @since 1.0.0
186
- */
187
- loadRequestExtend(): Promise<void>;
188
- /**
189
- * mixin Response.prototype
190
- * @function EggLoader#loadResponseExtend
191
- * @since 1.0.0
192
- */
193
- loadResponseExtend(): Promise<void>;
194
- /**
195
- * mixin Context.prototype
196
- * @function EggLoader#loadContextExtend
197
- * @since 1.0.0
198
- */
199
- loadContextExtend(): Promise<void>;
200
- /**
201
- * mixin app.Helper.prototype
202
- * @function EggLoader#loadHelperExtend
203
- * @since 1.0.0
204
- */
205
- loadHelperExtend(): Promise<void>;
206
- /**
207
- * Find all extend file paths by name
208
- * can be override in top level framework to support load `app/extends/{name}.js`
209
- *
210
- * @param {String} name - filename which may be `app/extend/{name}.js`
211
- * @returns {Array} filepaths extend file paths
212
- * @private
213
- */
214
- protected getExtendFilePaths(name: string): string[];
215
- /**
216
- * Loader app/extend/xx.js to `prototype`,
217
- * @function loadExtend
218
- * @param {String} name - filename which may be `app/extend/{name}.js`
219
- * @param {Object} proto - prototype that mixed
220
- * @since 1.0.0
221
- */
222
- loadExtend(name: string, proto: object): Promise<void>;
223
- /** end Extend loader */
224
- /** start Custom loader */
225
- /**
226
- * load app.js
227
- *
228
- * @example
229
- * - old:
230
- *
231
- * ```js
232
- * module.exports = function(app) {
233
- * doSomething();
234
- * }
235
- * ```
236
- *
237
- * - new:
238
- *
239
- * ```js
240
- * module.exports = class Boot {
241
- * constructor(app) {
242
- * this.app = app;
243
- * }
244
- * configDidLoad() {
245
- * doSomething();
246
- * }
247
- * }
248
- * @since 1.0.0
249
- */
250
- loadCustomApp(): Promise<void>;
251
- /**
252
- * Load agent.js, same as {@link EggLoader#loadCustomApp}
253
- */
254
- loadCustomAgent(): Promise<void>;
255
- loadBootHook(): void;
256
- /** end Custom loader */
257
- /** start Service loader */
258
- /**
259
- * Load app/service
260
- * @function EggLoader#loadService
261
- * @param {Object} options - LoaderOptions
262
- * @since 1.0.0
263
- */
264
- loadService(options?: Partial<ContextLoaderOptions>): Promise<void>;
265
- /** end Service loader */
266
- /** start Middleware loader */
267
- /**
268
- * Load app/middleware
269
- *
270
- * app.config.xx is the options of the middleware xx that has same name as config
271
- *
272
- * @function EggLoader#loadMiddleware
273
- * @param {Object} opt - LoaderOptions
274
- * @example
275
- * ```js
276
- * // app/middleware/status.js
277
- * module.exports = function(options, app) {
278
- * // options == app.config.status
279
- * return async next => {
280
- * await next();
281
- * }
282
- * }
283
- * ```
284
- * @since 1.0.0
285
- */
286
- loadMiddleware(opt?: Partial<FileLoaderOptions>): Promise<void>;
287
- /** end Middleware loader */
288
- /** start Controller loader */
289
- /**
290
- * Load app/controller
291
- * @param {Object} opt - LoaderOptions
292
- * @since 1.0.0
293
- */
294
- loadController(opt?: Partial<FileLoaderOptions>): Promise<void>;
295
- /** end Controller loader */
296
- /** start Router loader */
297
- /**
298
- * Load app/router.js
299
- * @function EggLoader#loadRouter
300
- * @since 1.0.0
301
- */
302
- loadRouter(): Promise<void>;
303
- /** end Router loader */
304
- /** start CustomLoader loader */
305
- loadCustomLoader(): Promise<void>;
306
- /** end CustomLoader loader */
307
- /**
308
- * Load single file, will invoke when export is function
309
- *
310
- * @param {String} filepath - fullpath
311
- * @param {Array} inject - pass rest arguments into the function when invoke
312
- * @returns {Object} exports
313
- * @example
314
- * ```js
315
- * app.loader.loadFile(path.join(app.options.baseDir, 'config/router.js'));
316
- * ```
317
- * @since 1.0.0
318
- */
319
- loadFile(filepath: string, ...inject: unknown[]): Promise<any>;
320
- /**
321
- * @param {String} filepath - fullpath
322
- * @private
323
- */
324
- requireFile(filepath: string): Promise<any>;
325
- /**
326
- * Get all loadUnit
327
- *
328
- * loadUnit is a directory that can be loaded by EggLoader, it has the same structure.
329
- * loadUnit has a path and a type(app, framework, plugin).
330
- *
331
- * The order of the loadUnits:
332
- *
333
- * 1. plugin
334
- * 2. framework
335
- * 3. app
336
- *
337
- * @returns {Array} loadUnits
338
- * @since 1.0.0
339
- */
340
- getLoadUnits(): EggDirInfo[];
341
- /**
342
- * Load files using {@link FileLoader}, inject to {@link Application}
343
- * @param {String|Array} directory - see {@link FileLoader}
344
- * @param {String} property - see {@link FileLoader}, e.g.: 'controller', 'middlewares'
345
- * @param {Object} options - see {@link FileLoader}
346
- * @since 1.0.0
347
- */
348
- loadToApp(directory: string | string[], property: string | symbol, options?: Omit<FileLoaderOptions, 'inject' | 'target'>): Promise<void>;
349
- /**
350
- * Load files using {@link ContextLoader}
351
- * @param {String|Array} directory - see {@link ContextLoader}
352
- * @param {String} property - see {@link ContextLoader}
353
- * @param {Object} options - see {@link ContextLoader}
354
- * @since 1.0.0
355
- */
356
- loadToContext(directory: string | string[], property: string | symbol, options?: Omit<ContextLoaderOptions, 'inject' | 'property'>): Promise<void>;
357
- /**
358
- * @member {FileLoader} EggLoader#FileLoader
359
- * @since 1.0.0
360
- */
361
- get FileLoader(): typeof FileLoader;
362
- /**
363
- * @member {ContextLoader} EggLoader#ContextLoader
364
- * @since 1.0.0
365
- */
366
- get ContextLoader(): typeof ContextLoader;
367
- getTypeFiles(filename: string): string[];
368
- resolveModule(filepath: string): string | undefined;
30
+ declare class EggLoader {
31
+ #private;
32
+ readonly options: EggLoaderOptions;
33
+ readonly timing: Timing;
34
+ readonly pkg: Record<string, any>;
35
+ readonly eggPaths: string[];
36
+ readonly serverEnv: string;
37
+ readonly serverScope: string;
38
+ readonly appInfo: EggAppInfo;
39
+ dirs?: EggDirInfo[];
40
+ /**
41
+ * @class
42
+ * @param {Object} options - options
43
+ * @param {String} options.baseDir - the directory of application
44
+ * @param {EggCore} options.app - Application instance
45
+ * @param {Logger} options.logger - logger
46
+ * @param {Object} [options.plugins] - custom plugins
47
+ * @since 1.0.0
48
+ */
49
+ constructor(options: EggLoaderOptions);
50
+ get app(): EggCore;
51
+ get lifecycle(): Lifecycle;
52
+ get logger(): Logger;
53
+ /**
54
+ * Get {@link AppInfo#env}
55
+ * @returns {String} env
56
+ * @see AppInfo#env
57
+ * @private
58
+ * @since 1.0.0
59
+ */
60
+ protected getServerEnv(): string;
61
+ /**
62
+ * Get {@link AppInfo#scope}
63
+ * @returns {String} serverScope
64
+ * @private
65
+ */
66
+ protected getServerScope(): string;
67
+ /**
68
+ * Get {@link AppInfo#name}
69
+ * @returns {String} appname
70
+ * @private
71
+ * @since 1.0.0
72
+ */
73
+ getAppname(): string;
74
+ /**
75
+ * Get home directory
76
+ * @returns {String} home directory
77
+ * @since 3.4.0
78
+ */
79
+ getHomedir(): string;
80
+ /**
81
+ * Get app info
82
+ * @returns {AppInfo} appInfo
83
+ * @since 1.0.0
84
+ */
85
+ protected getAppInfo(): EggAppInfo;
86
+ /**
87
+ * Get {@link EggLoader#eggPaths}
88
+ * @returns {Array} framework directories
89
+ * @see {@link EggLoader#eggPaths}
90
+ * @private
91
+ * @since 1.0.0
92
+ */
93
+ protected getEggPaths(): string[];
94
+ /** start Plugin loader */
95
+ lookupDirs: Set<string>;
96
+ eggPlugins: Record<string, EggPluginInfo>;
97
+ appPlugins: Record<string, EggPluginInfo>;
98
+ customPlugins: Record<string, EggPluginInfo>;
99
+ allPlugins: Record<string, EggPluginInfo>;
100
+ orderPlugins: EggPluginInfo[];
101
+ /** enable plugins */
102
+ plugins: Record<string, EggPluginInfo>;
103
+ /**
104
+ * Load config/plugin.js from {EggLoader#loadUnits}
105
+ *
106
+ * plugin.js is written below
107
+ *
108
+ * ```js
109
+ * {
110
+ * 'xxx-client': {
111
+ * enable: true,
112
+ * package: 'xxx-client',
113
+ * dep: [],
114
+ * env: [],
115
+ * },
116
+ * // short hand
117
+ * 'rds': false,
118
+ * 'depd': {
119
+ * enable: true,
120
+ * path: 'path/to/depd'
121
+ * }
122
+ * }
123
+ * ```
124
+ *
125
+ * If the plugin has path, Loader will find the module from it.
126
+ *
127
+ * Otherwise Loader will lookup follow the order by packageName
128
+ *
129
+ * 1. $APP_BASE/node_modules/${package}
130
+ * 2. $EGG_BASE/node_modules/${package}
131
+ *
132
+ * You can call `loader.plugins` that retrieve enabled plugins.
133
+ *
134
+ * ```js
135
+ * loader.plugins['xxx-client'] = {
136
+ * name: 'xxx-client', // the plugin name, it can be used in `dep`
137
+ * package: 'xxx-client', // the package name of plugin
138
+ * enable: true, // whether enabled
139
+ * path: 'path/to/xxx-client', // the directory of the plugin package
140
+ * dep: [], // the dependent plugins, you can use the plugin name
141
+ * env: [ 'local', 'unittest' ], // specify the serverEnv that only enable the plugin in it
142
+ * }
143
+ * ```
144
+ *
145
+ * `loader.allPlugins` can be used when retrieve all plugins.
146
+ * @function EggLoader#loadPlugin
147
+ * @since 1.0.0
148
+ */
149
+ loadPlugin(): Promise<void>;
150
+ protected loadAppPlugins(): Promise<Record<string, EggPluginInfo>>;
151
+ protected loadEggPlugins(): Promise<Record<string, EggPluginInfo>>;
152
+ protected loadCustomPlugins(): Record<string, EggPluginInfo>;
153
+ protected readPluginConfigs(configPaths: string[] | string): Promise<Record<string, EggPluginInfo>>;
154
+ protected getOrderPlugins(allPlugins: Record<string, EggPluginInfo>, enabledPluginNames: string[], appPlugins: Record<string, EggPluginInfo>): EggPluginInfo[];
155
+ protected getLookupDirs(): Set<string>;
156
+ protected getPluginPath(plugin: EggPluginInfo): string;
157
+ /** end Plugin loader */
158
+ /** start Config loader */
159
+ configMeta: Record<string, any>;
160
+ config: EggAppConfig;
161
+ /**
162
+ * Load config/config.js
163
+ *
164
+ * Will merge config.default.js 和 config.${env}.js
165
+ *
166
+ * @function EggLoader#loadConfig
167
+ * @since 1.0.0
168
+ */
169
+ loadConfig(): Promise<void>;
170
+ /** end Config loader */
171
+ /** start Extend loader */
172
+ /**
173
+ * mixin Agent.prototype
174
+ * @function EggLoader#loadAgentExtend
175
+ * @since 1.0.0
176
+ */
177
+ loadAgentExtend(): Promise<void>;
178
+ /**
179
+ * mixin Application.prototype
180
+ * @function EggLoader#loadApplicationExtend
181
+ * @since 1.0.0
182
+ */
183
+ loadApplicationExtend(): Promise<void>;
184
+ /**
185
+ * mixin Request.prototype
186
+ * @function EggLoader#loadRequestExtend
187
+ * @since 1.0.0
188
+ */
189
+ loadRequestExtend(): Promise<void>;
190
+ /**
191
+ * mixin Response.prototype
192
+ * @function EggLoader#loadResponseExtend
193
+ * @since 1.0.0
194
+ */
195
+ loadResponseExtend(): Promise<void>;
196
+ /**
197
+ * mixin Context.prototype
198
+ * @function EggLoader#loadContextExtend
199
+ * @since 1.0.0
200
+ */
201
+ loadContextExtend(): Promise<void>;
202
+ /**
203
+ * mixin app.Helper.prototype
204
+ * @function EggLoader#loadHelperExtend
205
+ * @since 1.0.0
206
+ */
207
+ loadHelperExtend(): Promise<void>;
208
+ /**
209
+ * Find all extend file paths by name
210
+ * can be override in top level framework to support load `app/extends/{name}.js`
211
+ *
212
+ * @param {String} name - filename which may be `app/extend/{name}.js`
213
+ * @returns {Array} filepaths extend file paths
214
+ * @private
215
+ */
216
+ protected getExtendFilePaths(name: string): string[];
217
+ /**
218
+ * Loader app/extend/xx.js to `prototype`,
219
+ * @function loadExtend
220
+ * @param {String} name - filename which may be `app/extend/{name}.js`
221
+ * @param {Object} proto - prototype that mixed
222
+ * @since 1.0.0
223
+ */
224
+ loadExtend(name: string, proto: object): Promise<void>;
225
+ /** end Extend loader */
226
+ /** start Custom loader */
227
+ /**
228
+ * load app.js
229
+ *
230
+ * @example
231
+ * - old:
232
+ *
233
+ * ```js
234
+ * module.exports = function(app) {
235
+ * doSomething();
236
+ * }
237
+ * ```
238
+ *
239
+ * - new:
240
+ *
241
+ * ```js
242
+ * module.exports = class Boot {
243
+ * constructor(app) {
244
+ * this.app = app;
245
+ * }
246
+ * configDidLoad() {
247
+ * doSomething();
248
+ * }
249
+ * }
250
+ * @since 1.0.0
251
+ */
252
+ loadCustomApp(): Promise<void>;
253
+ /**
254
+ * Load agent.js, same as {@link EggLoader#loadCustomApp}
255
+ */
256
+ loadCustomAgent(): Promise<void>;
257
+ loadBootHook(): void;
258
+ /** end Custom loader */
259
+ /** start Service loader */
260
+ /**
261
+ * Load app/service
262
+ * @function EggLoader#loadService
263
+ * @param {Object} options - LoaderOptions
264
+ * @since 1.0.0
265
+ */
266
+ loadService(options?: Partial<ContextLoaderOptions>): Promise<void>;
267
+ /** end Service loader */
268
+ /** start Middleware loader */
269
+ /**
270
+ * Load app/middleware
271
+ *
272
+ * app.config.xx is the options of the middleware xx that has same name as config
273
+ *
274
+ * @function EggLoader#loadMiddleware
275
+ * @param {Object} opt - LoaderOptions
276
+ * @example
277
+ * ```js
278
+ * // app/middleware/status.js
279
+ * module.exports = function(options, app) {
280
+ * // options == app.config.status
281
+ * return async next => {
282
+ * await next();
283
+ * }
284
+ * }
285
+ * ```
286
+ * @since 1.0.0
287
+ */
288
+ loadMiddleware(opt?: Partial<FileLoaderOptions>): Promise<void>;
289
+ /** end Middleware loader */
290
+ /** start Controller loader */
291
+ /**
292
+ * Load app/controller
293
+ * @param {Object} opt - LoaderOptions
294
+ * @since 1.0.0
295
+ */
296
+ loadController(opt?: Partial<FileLoaderOptions>): Promise<void>;
297
+ /** end Controller loader */
298
+ /** start Router loader */
299
+ /**
300
+ * Load app/router.js
301
+ * @function EggLoader#loadRouter
302
+ * @since 1.0.0
303
+ */
304
+ loadRouter(): Promise<void>;
305
+ /** end Router loader */
306
+ /** start CustomLoader loader */
307
+ loadCustomLoader(): Promise<void>;
308
+ /** end CustomLoader loader */
309
+ /**
310
+ * Load single file, will invoke when export is function
311
+ *
312
+ * @param {String} filepath - fullpath
313
+ * @param {Array} inject - pass rest arguments into the function when invoke
314
+ * @returns {Object} exports
315
+ * @example
316
+ * ```js
317
+ * app.loader.loadFile(path.join(app.options.baseDir, 'config/router.js'));
318
+ * ```
319
+ * @since 1.0.0
320
+ */
321
+ loadFile(filepath: string, ...inject: unknown[]): Promise<any>;
322
+ /**
323
+ * @param {String} filepath - fullpath
324
+ * @private
325
+ */
326
+ requireFile(filepath: string): Promise<any>;
327
+ /**
328
+ * Get all loadUnit
329
+ *
330
+ * loadUnit is a directory that can be loaded by EggLoader, it has the same structure.
331
+ * loadUnit has a path and a type(app, framework, plugin).
332
+ *
333
+ * The order of the loadUnits:
334
+ *
335
+ * 1. plugin
336
+ * 2. framework
337
+ * 3. app
338
+ *
339
+ * @returns {Array} loadUnits
340
+ * @since 1.0.0
341
+ */
342
+ getLoadUnits(): EggDirInfo[];
343
+ /**
344
+ * Load files using {@link FileLoader}, inject to {@link Application}
345
+ * @param {String|Array} directory - see {@link FileLoader}
346
+ * @param {String} property - see {@link FileLoader}, e.g.: 'controller', 'middlewares'
347
+ * @param {Object} options - see {@link FileLoader}
348
+ * @since 1.0.0
349
+ */
350
+ loadToApp(directory: string | string[], property: string | symbol, options?: Omit<FileLoaderOptions, "inject" | "target">): Promise<void>;
351
+ /**
352
+ * Load files using {@link ContextLoader}
353
+ * @param {String|Array} directory - see {@link ContextLoader}
354
+ * @param {String} property - see {@link ContextLoader}
355
+ * @param {Object} options - see {@link ContextLoader}
356
+ * @since 1.0.0
357
+ */
358
+ loadToContext(directory: string | string[], property: string | symbol, options?: Omit<ContextLoaderOptions, "inject" | "property">): Promise<void>;
359
+ /**
360
+ * @member {FileLoader} EggLoader#FileLoader
361
+ * @since 1.0.0
362
+ */
363
+ get FileLoader(): typeof FileLoader;
364
+ /**
365
+ * @member {ContextLoader} EggLoader#ContextLoader
366
+ * @since 1.0.0
367
+ */
368
+ get ContextLoader(): typeof ContextLoader;
369
+ getTypeFiles(filename: string): string[];
370
+ resolveModule(filepath: string): string | undefined;
369
371
  }
372
+ //#endregion
373
+ export { EggDirInfo, EggDirInfoType, EggLoader, EggLoaderOptions };