mm_machine 2.9.0 → 2.9.2

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 +7 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -180,9 +180,10 @@ Manager.prototype.setInfo = function (info) {
180
180
 
181
181
  /**
182
182
  * 获取所有模块对象
183
+ * @param {string} keyword 查询关键词,判断name、title、description之一是否包含关键词,包含的才返回
183
184
  * @returns {object[]} 模块对象数组
184
185
  */
185
- Manager.prototype.getList = function () {
186
+ Manager.prototype.getList = function (keyword) {
186
187
  let list = [];
187
188
  for (let i = 0; i < this.infos.length; i++) {
188
189
  let info = this.infos[i];
@@ -193,6 +194,9 @@ Manager.prototype.getList = function () {
193
194
  mod.config.state = info.state;
194
195
  list.push(mod);
195
196
  }
197
+ if (keyword) {
198
+ list = list.filter((o) => o.name.includes(keyword) || o.title.includes(keyword) || o.description.includes(keyword));
199
+ }
196
200
  return list;
197
201
  };
198
202
 
@@ -914,8 +918,8 @@ Manager.prototype._loadSources = async function () {
914
918
  // 快照存在,用config快速加载模块
915
919
  this._loadFromSnapshot(snapshot.mods_map);
916
920
  // this.log('info', '已从快照快速加载模块,正在后台同步文件变更...');
917
- // 异步增量同步,不阻塞启动
918
- this._syncFromFile(snapshot);
921
+ // 同步等待文件同步完成,确保模块已全部注册后再执行初始化,防止竞态条件
922
+ await this._syncFromFile(snapshot);
919
923
  return;
920
924
  }
921
925
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
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": {
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "eslint": "^10.6.0",
43
- "eslint-plugin-jsdoc": "^63.0.12",
43
+ "eslint-plugin-jsdoc": "^63.0.13",
44
44
  "mm_eslint": "^1.7.5"
45
45
  }
46
46
  }