mm_machine 3.3.4 → 3.3.5

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 (2) hide show
  1. package/lib/manager.js +25 -14
  2. package/package.json +1 -1
package/lib/manager.js CHANGED
@@ -504,7 +504,7 @@ Manager.prototype._runAllEnabled = async function (method, ...params) {
504
504
  for (let i = 0; i < infos.length; i++) {
505
505
  let info = infos[i];
506
506
  // 直接用 info.state 过滤,避免无效实例化
507
- if (info.state !== 1) continue;
507
+ if (!info.state) continue;
508
508
 
509
509
  let mod = this.getMod(info.name);
510
510
  if (!mod) continue;
@@ -539,7 +539,7 @@ Manager.prototype.doAll = async function (method, ...params) {
539
539
  for (let i = 0; i < infos.length; i++) {
540
540
  let info = infos[i];
541
541
  // 直接用 info.state 过滤,避免无效实例化
542
- if (info.state !== 1) continue;
542
+ if (!info.state) continue;
543
543
 
544
544
  let mod = this.getMod(info.name);
545
545
  if (!mod) continue;
@@ -749,12 +749,14 @@ Manager.prototype._ensureAllLoaded = async function (method) {
749
749
  let infos = this._getInfos();
750
750
 
751
751
  for (let i = 0; i < infos.length; i++) {
752
- let mod = this.getMod(infos[i].name);
752
+ let info = infos[i];
753
+ if (!info.state) continue;
754
+ let mod = this.getMod(info.name);
753
755
  if (!mod) continue;
754
756
  try {
755
757
  promises.push(this._ensureModLoaded(mod, method));
756
758
  } catch (error) {
757
- this._logModError(infos[i].name, method, error);
759
+ this._logModError(info.name, method, error);
758
760
  }
759
761
  }
760
762
 
@@ -776,8 +778,9 @@ Manager.prototype.runWait = async function (method, ...params) {
776
778
  let infos = this._getInfos();
777
779
 
778
780
  for (let i = 0; i < infos.length; i++) {
779
- let name = infos[i].name;
780
- let mod = this.getMod(name);
781
+ let info = infos[i];
782
+ if (!info.state) continue;
783
+ let mod = this.getMod(info.name);
781
784
  if (!mod) continue;
782
785
  try {
783
786
  mod = await this._ensureModLoaded(mod, method);
@@ -786,7 +789,7 @@ Manager.prototype.runWait = async function (method, ...params) {
786
789
  result = ret;
787
790
  }
788
791
  } catch (error) {
789
- this._logModError(name, method, error);
792
+ this._logModError(info.name, method, error);
790
793
  }
791
794
  }
792
795
 
@@ -810,11 +813,13 @@ Manager.prototype.runAsync = async function (method, ...params) {
810
813
  let infos = this._getInfos();
811
814
 
812
815
  for (let i = 0; i < infos.length; i++) {
813
- let mod = this.getMod(infos[i].name);
816
+ let info = infos[i];
817
+ if (!info.state) continue;
818
+ let mod = this.getMod(info.name);
814
819
  if (!mod) continue;
815
820
 
816
821
  mod.do(method, ...params).catch((error) => {
817
- this._logModError(infos[i].name, method, error);
822
+ this._logModError(info.name, method, error);
818
823
  });
819
824
  }
820
825
 
@@ -835,13 +840,15 @@ Manager.prototype.runAll = async function (method, ...params) {
835
840
  const promises = [];
836
841
  let infos = this._getInfos();
837
842
  for (let i = 0; i < infos.length; i++) {
838
- let mod = this.getMod(infos[i].name);
843
+ let info = infos[i];
844
+ if (!info.state) continue;
845
+ let mod = this.getMod(info.name);
839
846
  if (!mod) continue;
840
847
  try {
841
848
  mod = await this._ensureModLoaded(mod, method);
842
849
  promises.push(mod.do(method, ...params));
843
850
  } catch (error) {
844
- this._logModError(infos[i].name, method, error);
851
+ this._logModError(info.name, method, error);
845
852
  }
846
853
  }
847
854
 
@@ -866,7 +873,9 @@ Manager.prototype.runRace = async function (method, ...params) {
866
873
  let infos = this._getInfos();
867
874
 
868
875
  for (let i = 0; i < infos.length; i++) {
869
- let mod = this.getMod(infos[i].name);
876
+ let info = infos[i];
877
+ if (!info.state) continue;
878
+ let mod = this.getMod(info.name);
870
879
  if (!mod) continue;
871
880
 
872
881
  promises.push(
@@ -894,7 +903,9 @@ Manager.prototype.runWaterfall = async function (method, result, ...params) {
894
903
  let infos = this._getInfos();
895
904
 
896
905
  for (let i = 0; i < infos.length; i++) {
897
- let mod = this.getMod(infos[i].name);
906
+ let info = infos[i];
907
+ if (!info.state) continue;
908
+ let mod = this.getMod(info.name);
898
909
  if (!mod) continue;
899
910
  try {
900
911
  mod = await this._ensureModLoaded(mod, method);
@@ -903,7 +914,7 @@ Manager.prototype.runWaterfall = async function (method, result, ...params) {
903
914
  result = ret;
904
915
  }
905
916
  } catch (error) {
906
- this._logModError(infos[i].name, method, error);
917
+ this._logModError(info.name, method, error);
907
918
  }
908
919
  }
909
920
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
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": {