mm_machine 3.2.8 → 3.2.9
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/lib/manager.js +18 -42
- package/package.json +1 -1
package/lib/manager.js
CHANGED
|
@@ -548,33 +548,7 @@ Manager.prototype._runAllEnabled = async function (method, ...params) {
|
|
|
548
548
|
* @private
|
|
549
549
|
*/
|
|
550
550
|
Manager.prototype._runMod = async function (mod, method, ...params) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
// 确保模块已加载
|
|
554
|
-
if (!mod.isLoaded()) {
|
|
555
|
-
try {
|
|
556
|
-
await mod.do('load');
|
|
557
|
-
} catch (err) {
|
|
558
|
-
this.log('error', `加载模块脚本失败: `, err);
|
|
559
|
-
}
|
|
560
|
-
// 加载失败则不再执行,避免无方法调用
|
|
561
|
-
if (!mod.isLoaded()) {
|
|
562
|
-
return null;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// 确保模块已初始化
|
|
567
|
-
if (!mod.isInited() && method !== 'init') {
|
|
568
|
-
try {
|
|
569
|
-
await mod.do('init');
|
|
570
|
-
} catch (err) {
|
|
571
|
-
this.log('error', `初始化模块脚本失败: `, err);
|
|
572
|
-
}
|
|
573
|
-
// 初始化失败则不再执行,避免无方法调用
|
|
574
|
-
if (!mod.isInited()) {
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
551
|
+
mod = this._ensureModLoaded(mod, method);
|
|
578
552
|
|
|
579
553
|
// 执行方法
|
|
580
554
|
let ret = await mod.call(method, ...params);
|
|
@@ -696,24 +670,26 @@ Manager.prototype.exec = async function (name, method, ...params) {
|
|
|
696
670
|
*/
|
|
697
671
|
Manager.prototype._ensureModLoaded = async function (mod, method) {
|
|
698
672
|
if (!mod) return null;
|
|
699
|
-
if (!
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
673
|
+
if (!['load', 'init'].includes(method)) {
|
|
674
|
+
if (!mod.isLoaded()) {
|
|
675
|
+
try {
|
|
676
|
+
await mod.do('load');
|
|
677
|
+
} catch (error) {
|
|
678
|
+
this.log('error', `模块${mod.config.name}加载失败`, error);
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
705
681
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
682
|
+
if (!mod.isInited()) {
|
|
683
|
+
try {
|
|
684
|
+
await mod.do('init');
|
|
685
|
+
} catch (error) {
|
|
686
|
+
this.log('error', `模块${mod.config.name}初始化失败`, error);
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
713
689
|
}
|
|
714
|
-
}
|
|
690
|
+
};
|
|
715
691
|
return mod;
|
|
716
|
-
}
|
|
692
|
+
}
|
|
717
693
|
|
|
718
694
|
/**
|
|
719
695
|
* 确保所有模块都已加载
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.9",
|
|
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": {
|