mm_machine 2.4.1 → 2.4.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 (3) hide show
  1. package/drive.js +10 -1
  2. package/index.js +11 -11
  3. package/package.json +1 -1
package/drive.js CHANGED
@@ -79,7 +79,7 @@ Drive.prototype._preset = function () {
79
79
  * @param {string} file 配置文件路径
80
80
  * @returns {object} 配置项
81
81
  */
82
- Drive.prototype.loadConfig = function (file) {
82
+ Drive.prototype._loadConfig = function (file) {
83
83
  if (file) {
84
84
  this.config_file = file;
85
85
  };
@@ -99,6 +99,15 @@ Drive.prototype.loadConfig = function (file) {
99
99
  return config;
100
100
  };
101
101
 
102
+ /**
103
+ * 加载配置
104
+ * @param {string} file 配置文件路径
105
+ * @returns {object} 配置项
106
+ */
107
+ Drive.prototype.loadConfig = function (file) {
108
+ this._loadConfig(file);
109
+ };
110
+
102
111
  /**
103
112
  * 设置配置
104
113
  * @param {object} config 配置对象
package/index.js CHANGED
@@ -296,7 +296,7 @@ Manager.prototype.newMod = function (config_file, config, script) {
296
296
  * @param {object} script 模块对象
297
297
  * @returns {object} 模块对象
298
298
  */
299
- Manager.prototype.register = function (config_file, config = {}, script = {}) {
299
+ Manager.prototype.registerMod = function (config_file, config = {}, script = {}) {
300
300
  let mod = this.newMod(config_file, config, script);
301
301
  this.setMod(mod.config.name, mod);
302
302
  return mod;
@@ -307,7 +307,7 @@ Manager.prototype.register = function (config_file, config = {}, script = {}) {
307
307
  * @param {string} name 模块名
308
308
  * @returns {Promise<any>} 加载结果
309
309
  */
310
- Manager.prototype.load = async function (name) {
310
+ Manager.prototype.loadMod = async function (name) {
311
311
  let mod = this.getMod(name);
312
312
  if (mod) {
313
313
  return await mod.do('load');
@@ -320,7 +320,7 @@ Manager.prototype.load = async function (name) {
320
320
  * @param {string} name 模块名
321
321
  * @returns {Promise<any>} 卸载结果
322
322
  */
323
- Manager.prototype.unload = async function (name) {
323
+ Manager.prototype.unloadMod = async function (name) {
324
324
  let mod = this.getMod(name);
325
325
  if (mod) {
326
326
  return await mod.do('unload');
@@ -333,7 +333,7 @@ Manager.prototype.unload = async function (name) {
333
333
  * @param {string} name 模块名
334
334
  * @returns {Promise<any>} 重载结果
335
335
  */
336
- Manager.prototype.reload = async function (name) {
336
+ Manager.prototype.reloadMod = async function (name) {
337
337
  let mod = this.getMod(name);
338
338
  if (mod) {
339
339
  return await mod.do('reload');
@@ -346,11 +346,11 @@ Manager.prototype.reload = async function (name) {
346
346
  * @param {string} name 模块名
347
347
  * @returns {Promise<any>} 注销结果
348
348
  */
349
- Manager.prototype.unregister = function (name) {
349
+ Manager.prototype.unregisterMod = function (name) {
350
350
  // 卸载模块
351
- this.unload(name);
351
+ this.unloadMod(name);
352
352
  // 删除模块
353
- this.delMod(name);
353
+ let mod = this.delMod(name);
354
354
  return mod;
355
355
  };
356
356
 
@@ -360,16 +360,16 @@ Manager.prototype.unregister = function (name) {
360
360
  * @param {object} config 配置项
361
361
  * @param {object} script 模块对象
362
362
  */
363
- Manager.prototype.batchRegister = function (files, config = {}, script = {}) {
363
+ Manager.prototype.registerMods = function (files, config = {}, script = {}) {
364
364
  for (let file of files) {
365
- this.register(file, config, script);
365
+ this.registerMod(file, config, script);
366
366
  }
367
367
  };
368
368
 
369
369
  /**
370
370
  * 加载所有模块
371
371
  */
372
- Manager.prototype.loads = async function () {
372
+ Manager.prototype.loadMods = async function () {
373
373
  var promises = [];
374
374
  for (let name in this.mods) {
375
375
  let mod = this.mods[name];
@@ -473,7 +473,7 @@ Manager.prototype.update = async function (dir, clear = true) {
473
473
  // 查找所有json文件
474
474
  let files = this._findFiles(dir || this.config.dir);
475
475
  // 批量注册模块
476
- this.batchRegister(files);
476
+ this.registerMods(files);
477
477
  // 更新配置信息
478
478
  this.updateInfo();
479
479
  if (!this.config.lazy_load) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
5
5
  "main": "index.js",
6
6
  "scripts": {