mm_machine 3.0.0 → 3.0.1

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/drive.js CHANGED
@@ -501,7 +501,7 @@ Drive.prototype.loadFile = function (file, name) {
501
501
  let final_config = this._findConfigByName(config, name);
502
502
  return final_config;
503
503
  } catch (err) {
504
- this.log('error', `[${this.config.name}] 加载配置文件失败`, err);
504
+ this.log('error', `加载配置文件失败`, err);
505
505
  return null;
506
506
  }
507
507
  };
@@ -583,7 +583,7 @@ Drive.prototype.delFile = function () {
583
583
  script_file.delFile();
584
584
  }
585
585
  } catch (err) {
586
- this.log('error', `[${this.config.name}] 删除文件失败`, err);
586
+ this.log('error', `删除文件失败`, err);
587
587
  error_message = error_message || `删除失败: ${err.message}`;
588
588
  }
589
589
  return error_message;
@@ -658,7 +658,7 @@ Drive.prototype.loadBefore = function () {
658
658
  this._is_loaded = true;
659
659
  }
660
660
  } catch (err) {
661
- this.log('error', `[${this.config.name}] 加载前处理失败`, err);
661
+ this.log('error', `加载前处理失败`, err);
662
662
  this._is_loaded = false;
663
663
  }
664
664
  };
@@ -701,7 +701,7 @@ Drive.prototype.save = function () {
701
701
  // 单对象格式配置,直接保存
702
702
  file.saveText(JSON.stringify(this.config, null, 2));
703
703
  } catch (err) {
704
- this.log('error', `[${this.config.name}] 保存配置失败`, err);
704
+ this.log('error', `保存配置失败`, err);
705
705
  }
706
706
  };
707
707
 
package/manager.js CHANGED
@@ -696,7 +696,7 @@ Manager.prototype._runMod = async function (mod, method, ...params) {
696
696
  try {
697
697
  await mod.call('loadScript');
698
698
  } catch (err) {
699
- $.log.error(`加载模块脚本失败: `, err);
699
+ this.log('error', `加载模块脚本失败: `, err);
700
700
  }
701
701
  // 加载失败则不再执行,避免无方法调用
702
702
  if (!mod.isLoaded()) {
package/mod.js CHANGED
@@ -636,7 +636,7 @@ Mod.prototype.call = async function (method, ...params) {
636
636
  result = await this._callMain(method_func, params, before_result);
637
637
  result = await this._callAfter(method, params, result);
638
638
  } catch (err) {
639
- this.log('error', `[${this.config.name}] 执行 ${method} 失败: ${err.message}`, err);
639
+ this.log('error', `执行 ${method} 失败: ${err.message}`, err);
640
640
  return null;
641
641
  }
642
642
 
@@ -659,7 +659,7 @@ Mod.prototype._callBefore = async function (method, params) {
659
659
  let result = await before_func.call(this, ...params);
660
660
  return result;
661
661
  } catch (err) {
662
- this.log('error', `[${this.config.name}] 执行前置钩子 ${before_method} 失败`, err);
662
+ this.log('error', `执行前置钩子 ${before_method} 失败`, err);
663
663
  return undefined;
664
664
  }
665
665
  };
@@ -694,7 +694,7 @@ Mod.prototype._callAfter = async function (method, params, result) {
694
694
  let after = await after_func.call(this, result, ...params);
695
695
  return after !== undefined ? after : result;
696
696
  } catch (err) {
697
- this.log('error', `[${this.config.name}] 执行后置钩子 ${after_method} 失败`, err);
697
+ this.log('error', `执行后置钩子 ${after_method} 失败`, err);
698
698
  return result;
699
699
  }
700
700
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
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": {
package/registry.js CHANGED
@@ -313,22 +313,22 @@ Registry.prototype.checkConfig = function (config) {
313
313
  cg.parent = '';
314
314
  }
315
315
  if (!name) {
316
- throw new Error('模块名称不能为空');
316
+ throw new TypeError('模块名称不能为空');
317
317
  }
318
318
  if (!title) {
319
- throw new Error('模块标题不能为空');
319
+ throw new TypeError('模块标题不能为空');
320
320
  }
321
321
  if (!description) {
322
- throw new Error('模块描述不能为空');
322
+ throw new TypeError('模块描述不能为空');
323
323
  }
324
324
  if (!config_file) {
325
- throw new Error('模块配置文件不能为空');
325
+ throw new TypeError('模块配置文件不能为空');
326
326
  }
327
327
  if (!['true', 'false', 'auto'].includes(auto_start)) {
328
- throw new Error('模块自动启动配置错误,只能为true、false、auto');
328
+ throw new TypeError('模块自动启动配置错误,只能为true、false、auto');
329
329
  }
330
330
  if (!this.class_dict[class_name]) {
331
- throw new Error('模块类不存在');
331
+ throw new TypeError('模块类不存在');
332
332
  }
333
333
  if (!enabled) {
334
334
  cg.enabled = false;
@@ -355,7 +355,7 @@ Registry.prototype.checkConfig = function (config) {
355
355
  Registry.prototype.getClassFile = function (class_name) {
356
356
  let file_name = this.config.name + '_class.json';
357
357
  let file = file_name.fullname(this.config.dir);
358
- file.addDir();
358
+ // file.addDir();
359
359
  return file;
360
360
  };
361
361
 
@@ -366,7 +366,7 @@ Registry.prototype.getClassFile = function (class_name) {
366
366
  Registry.prototype.getModuleFile = function () {
367
367
  let file_name = this.config.name + '_module.json';
368
368
  let file = file_name.fullname(this.config.dir);
369
- file.addDir();
369
+ // file.addDir();
370
370
  return file;
371
371
  };
372
372