mm_machine 2.7.1 → 2.7.3

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 (4) hide show
  1. package/drive.js +0 -26
  2. package/index.js +3 -19
  3. package/mod.js +26 -0
  4. package/package.json +1 -1
package/drive.js CHANGED
@@ -686,32 +686,6 @@ Drive.prototype.save = function () {
686
686
  }
687
687
  };
688
688
 
689
- /**
690
- * 触发事件
691
- * @param {string} event 事件名
692
- * @param {...any} args 事件参数
693
- */
694
- Drive.prototype.emitEvent = function (event, ...args) {
695
- this.getEventer()?.emit(event, ...args);
696
- };
697
-
698
- /**
699
- * 注册事件监听
700
- * @param {string} event 事件名
701
- * @param {Function} callback 事件回调函数
702
- */
703
- Drive.prototype.onEvent = function (event, callback) {
704
- this.getEventer()?.on(event, callback);
705
- };
706
-
707
- /**
708
- * 移除事件监听
709
- * @param {string} event 事件名
710
- */
711
- Drive.prototype.offEvent = function (event) {
712
- this.getEventer()?.off(event);
713
- };
714
-
715
689
  /**
716
690
  * 删除项目
717
691
  */
package/index.js CHANGED
@@ -241,7 +241,9 @@ Manager.prototype.sort = function () {
241
241
  * 清除所有模块
242
242
  */
243
243
  Manager.prototype.clearMods = function () {
244
- this.mods = {};
244
+ for (let name in this.mods) {
245
+ delete this.mods[name];
246
+ }
245
247
  };
246
248
 
247
249
  /**
@@ -921,24 +923,6 @@ Manager.prototype.runSubMod = async function (name, method, ...params) {
921
923
  return await mod.do(method, ...params);
922
924
  };
923
925
 
924
- /**
925
- * 触发事件
926
- * @param {string} event 事件名
927
- * @param {...any} args 事件参数
928
- */
929
- Manager.prototype.emitEvent = function (event, ...args) {
930
- this.getEventer()?.emit(event, ...args);
931
- };
932
-
933
- /**
934
- * 注册事件监听
935
- * @param {string} event 事件名
936
- * @param {Function} callback 事件回调函数
937
- */
938
- Manager.prototype.onEvent = function (event, callback) {
939
- this.getEventer()?.on(event, callback);
940
- };
941
-
942
926
  /**
943
927
  * 移除事件监听
944
928
  * @param {string} event 事件名
package/mod.js CHANGED
@@ -419,6 +419,32 @@ Mod.prototype.emitEvent = function (event, ...args) {
419
419
  this.getEventer()?.emit(event, ...args);
420
420
  };
421
421
 
422
+ /**
423
+ * 触发事件 - 随机触发
424
+ * @param {string} event 事件名
425
+ * @param {...any} args 事件参数
426
+ */
427
+ Mod.prototype.emitEventRace = function (event, ...args) {
428
+ this.getEventer()?.emitRace(event, ...args);
429
+ };
430
+
431
+ /**
432
+ * 注册事件监听
433
+ * @param {string} event 事件名
434
+ * @param {Function} callback 事件回调函数
435
+ */
436
+ Mod.prototype.onEvent = function (event, callback) {
437
+ this.getEventer()?.on(event, callback);
438
+ };
439
+
440
+ /**
441
+ * 移除事件监听
442
+ * @param {string} event 事件名
443
+ */
444
+ Mod.prototype.offEvent = function (event) {
445
+ this.getEventer()?.off(event);
446
+ };
447
+
422
448
  /**
423
449
  * 主方法名
424
450
  * @param {...any} args 方法参数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
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": {