mm_machine 2.6.7 → 2.6.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.
Files changed (2) hide show
  1. package/index.js +28 -1
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -103,6 +103,10 @@ class Manager extends Mod {
103
103
  this.Drive = Drive;
104
104
  }
105
105
  }
106
+
107
+ get list() {
108
+ return this.getList();
109
+ }
106
110
  }
107
111
 
108
112
  /**
@@ -726,7 +730,9 @@ Manager.prototype.runWait = async function (method, ...params) {
726
730
  for (let i = 0; i < infos.length; i++) {
727
731
  let info = infos[i];
728
732
  let mod = this.getMod(info.name);
729
-
733
+ if (!mod) {
734
+ continue; // 跳过不存在的模块
735
+ }
730
736
  // 确保模块已加载
731
737
  if (!mod.isLoaded()) {
732
738
  try {
@@ -891,6 +897,27 @@ Manager.prototype.runWaterfall = async function (method, result, ...params) {
891
897
  return result;
892
898
  };
893
899
 
900
+ /**
901
+ * 异步触发事件,子模块执行
902
+ * @param {string} name 子模块名称
903
+ * @param {string} method 方法名称
904
+ * @param {...any} params 事件参数
905
+ * @returns {Promise} 事件触发结果
906
+ */
907
+ Manager.prototype.runSub = async function (name, method, ...params) {
908
+ // 参数校验
909
+ if (typeof method !== 'string') {
910
+ throw new TypeError('方法名称必须是字符串');
911
+ }
912
+ let mod = this.getMod(name);
913
+ if (!mod) {
914
+ throw new Error(`模块${name}不存在`);
915
+ }
916
+
917
+ await mod.call('loadScript');
918
+ return await mod.do(method, ...params);
919
+ };
920
+
894
921
  /**
895
922
  * 触发事件
896
923
  * @param {string} event 事件名
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.6.7",
3
+ "version": "2.6.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": {
@@ -35,11 +35,11 @@
35
35
  "dependencies": {
36
36
  "@prettier/sync": "^0.6.1",
37
37
  "mm_config": "^2.3.6",
38
- "mm_hot_reload": "^1.3.2",
39
- "mm_tpl": "^2.5.4"
38
+ "mm_hot_reload": "^1.3.3",
39
+ "mm_tpl": "^2.5.5"
40
40
  },
41
41
  "devDependencies": {
42
- "eslint": "^10.2.1",
42
+ "eslint": "^10.3.0",
43
43
  "eslint-plugin-jsdoc": "^62.9.0",
44
44
  "mm_eslint": "^1.7.1"
45
45
  }