mm_machine 2.5.2 → 2.5.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.
- package/drive.js +26 -1
- package/index.js +34 -0
- package/package.json +1 -1
package/drive.js
CHANGED
|
@@ -63,6 +63,14 @@ class Drive extends Mod {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* 获取事件触发器
|
|
68
|
+
* @returns {object} 事件触发器
|
|
69
|
+
*/
|
|
70
|
+
Drive.prototype.getEventer = function () {
|
|
71
|
+
return $.eventer;
|
|
72
|
+
};
|
|
73
|
+
|
|
66
74
|
/**
|
|
67
75
|
* 配置驱动
|
|
68
76
|
*/
|
|
@@ -692,7 +700,24 @@ Drive.prototype.save = function () {
|
|
|
692
700
|
* @param {...any} args 事件参数
|
|
693
701
|
*/
|
|
694
702
|
Drive.prototype.emitEvent = function (event, ...args) {
|
|
695
|
-
this.
|
|
703
|
+
this.getEventer()?.emit(event, ...args);
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* 注册事件监听
|
|
708
|
+
* @param {string} event 事件名
|
|
709
|
+
* @param {function} callback 事件回调函数
|
|
710
|
+
*/
|
|
711
|
+
Drive.prototype.onEvent = function (event, callback) {
|
|
712
|
+
this.getEventer()?.on(event, callback);
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* 移除事件监听
|
|
717
|
+
* @param {string} event 事件名
|
|
718
|
+
*/
|
|
719
|
+
Drive.prototype.offEvent = function (event) {
|
|
720
|
+
this.getEventer()?.off(event);
|
|
696
721
|
};
|
|
697
722
|
|
|
698
723
|
/**
|
package/index.js
CHANGED
|
@@ -105,6 +105,14 @@ class Manager extends Mod {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* 获取事件触发器
|
|
110
|
+
* @returns {object} 事件触发器
|
|
111
|
+
*/
|
|
112
|
+
Manager.prototype.getEventer = function () {
|
|
113
|
+
return $.eventer;
|
|
114
|
+
};
|
|
115
|
+
|
|
108
116
|
/**
|
|
109
117
|
* 获取所有模块信息
|
|
110
118
|
* @returns {object[]} 模块信息数组
|
|
@@ -852,6 +860,32 @@ Manager.prototype.runWaterfall = async function (method, result, ...params) {
|
|
|
852
860
|
return result;
|
|
853
861
|
};
|
|
854
862
|
|
|
863
|
+
/**
|
|
864
|
+
* 触发事件
|
|
865
|
+
* @param {string} event 事件名
|
|
866
|
+
* @param {...any} args 事件参数
|
|
867
|
+
*/
|
|
868
|
+
Manager.prototype.emitEvent = function (event, ...args) {
|
|
869
|
+
this.getEventer()?.emit(event, ...args);
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* 注册事件监听
|
|
874
|
+
* @param {string} event 事件名
|
|
875
|
+
* @param {function} callback 事件回调函数
|
|
876
|
+
*/
|
|
877
|
+
Manager.prototype.onEvent = function (event, callback) {
|
|
878
|
+
this.getEventer()?.on(event, callback);
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* 移除事件监听
|
|
883
|
+
* @param {string} event 事件名
|
|
884
|
+
*/
|
|
885
|
+
Manager.prototype.offEvent = function (event) {
|
|
886
|
+
this.getEventer()?.off(event);
|
|
887
|
+
};
|
|
888
|
+
|
|
855
889
|
module.exports = {
|
|
856
890
|
Manager,
|
|
857
891
|
Drive,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.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": {
|