mm_machine 2.7.3 → 2.7.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.
- package/drive.js +6 -6
- package/index.js +4 -4
- package/mod.js +14 -3
- package/package.json +4 -4
package/drive.js
CHANGED
|
@@ -76,7 +76,7 @@ Drive.prototype.getEventer = function () {
|
|
|
76
76
|
Drive.prototype._preset = function () {
|
|
77
77
|
let file = this.config.main;
|
|
78
78
|
if (file) {
|
|
79
|
-
this.script_file = file.fullname(this.
|
|
79
|
+
this.script_file = file.fullname(this.getDir());
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
@@ -152,7 +152,7 @@ Drive.prototype.getConfig = function () {
|
|
|
152
152
|
* 获取当前文件
|
|
153
153
|
* @returns {object} 当前文件对象
|
|
154
154
|
*/
|
|
155
|
-
Drive.prototype.
|
|
155
|
+
Drive.prototype.getDir = function () {
|
|
156
156
|
let dir = this._dir;
|
|
157
157
|
if (!dir) {
|
|
158
158
|
if (this.script_file) {
|
|
@@ -242,7 +242,7 @@ Drive.prototype._getScriptFile = function () {
|
|
|
242
242
|
let main = this.config.main || '';
|
|
243
243
|
if (!main) return null;
|
|
244
244
|
|
|
245
|
-
let filename = main.fullname(this.
|
|
245
|
+
let filename = main.fullname(this.getDir());
|
|
246
246
|
if (!filename.hasFile()) {
|
|
247
247
|
this.newScript(filename);
|
|
248
248
|
}
|
|
@@ -484,7 +484,7 @@ Drive.prototype._getConfigTpl = function () {
|
|
|
484
484
|
*/
|
|
485
485
|
Drive.prototype.loadFile = function (file, name) {
|
|
486
486
|
try {
|
|
487
|
-
let filename = file.fullname(this.
|
|
487
|
+
let filename = file.fullname(this.getDir());
|
|
488
488
|
let text = filename.loadText();
|
|
489
489
|
|
|
490
490
|
// 如果文件不存在,创建新的配置文件
|
|
@@ -659,7 +659,7 @@ Drive.prototype.save = function () {
|
|
|
659
659
|
try {
|
|
660
660
|
if (!this.script_file) return;
|
|
661
661
|
|
|
662
|
-
let file = this.script_file.fullname(this.
|
|
662
|
+
let file = this.script_file.fullname(this.getDir());
|
|
663
663
|
let text = file.loadText();
|
|
664
664
|
|
|
665
665
|
if (text && text.trim().startsWith('[')) {
|
|
@@ -690,7 +690,7 @@ Drive.prototype.save = function () {
|
|
|
690
690
|
* 删除项目
|
|
691
691
|
*/
|
|
692
692
|
Drive.prototype.remove = function () {
|
|
693
|
-
let dir = this.
|
|
693
|
+
let dir = this.getDir();
|
|
694
694
|
if (dir) {
|
|
695
695
|
dir.delDir();
|
|
696
696
|
}
|
package/index.js
CHANGED
|
@@ -418,7 +418,7 @@ Manager.prototype.loadMods = async function () {
|
|
|
418
418
|
* 获取目录名
|
|
419
419
|
* @returns {string} 目录名
|
|
420
420
|
*/
|
|
421
|
-
Manager.prototype.
|
|
421
|
+
Manager.prototype.getDirName = function () {
|
|
422
422
|
// 前缀,为当前类名
|
|
423
423
|
let prefix = this.constructor.name.toLowerCase();
|
|
424
424
|
// 后缀,为配置项名称
|
|
@@ -434,7 +434,7 @@ Manager.prototype._getDirName = function () {
|
|
|
434
434
|
*/
|
|
435
435
|
Manager.prototype._getAllDirFiles = function (dir) {
|
|
436
436
|
let files = [];
|
|
437
|
-
let dirs = $.dir.getAll(dir, this.
|
|
437
|
+
let dirs = $.dir.getAll(dir, this.getDirName());
|
|
438
438
|
for (let i = 0; i < dirs.length; i++) {
|
|
439
439
|
let d = dirs[i];
|
|
440
440
|
let lt = $.file.getAll(d, this.config.filename);
|
|
@@ -621,7 +621,7 @@ Manager.prototype.getBaseDir = function () {
|
|
|
621
621
|
* @returns {string} 二次开发模块目录
|
|
622
622
|
*/
|
|
623
623
|
Manager.prototype.getDir = function () {
|
|
624
|
-
return this.config.dir || this.
|
|
624
|
+
return this.config.dir || this.getDir();
|
|
625
625
|
};
|
|
626
626
|
|
|
627
627
|
/**
|
|
@@ -955,7 +955,7 @@ Manager.prototype.createFile = function (config, file) {
|
|
|
955
955
|
if (!f) {
|
|
956
956
|
f = `${config.name}/${this.config.filename}`;
|
|
957
957
|
if (this.config.search_way === 'dir') {
|
|
958
|
-
let dir_name = this.
|
|
958
|
+
let dir_name = this.getDirName();
|
|
959
959
|
f = `${dir_name}/${f}`;
|
|
960
960
|
}
|
|
961
961
|
}
|
package/mod.js
CHANGED
|
@@ -423,9 +423,20 @@ Mod.prototype.emitEvent = function (event, ...args) {
|
|
|
423
423
|
* 触发事件 - 随机触发
|
|
424
424
|
* @param {string} event 事件名
|
|
425
425
|
* @param {...any} args 事件参数
|
|
426
|
+
* @returns {Promise<any>} 事件触发结果
|
|
426
427
|
*/
|
|
427
|
-
Mod.prototype.emitEventRace = function (event, ...args) {
|
|
428
|
-
this.getEventer()?.emitRace(event, ...args);
|
|
428
|
+
Mod.prototype.emitEventRace = async function (event, ...args) {
|
|
429
|
+
return await this.getEventer()?.emitRace(event, ...args);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* 触发事件 - 返回第一个非空结果
|
|
434
|
+
* @param {string} event 事件名
|
|
435
|
+
* @param {...any} args 事件参数
|
|
436
|
+
* @returns {Promise<any>} 事件触发结果
|
|
437
|
+
*/
|
|
438
|
+
Mod.prototype.emitEventFirst = async function (event, ...args) {
|
|
439
|
+
return await this.getEventer()?.emitFirst(event, ...args);
|
|
429
440
|
};
|
|
430
441
|
|
|
431
442
|
/**
|
|
@@ -690,7 +701,7 @@ Mod.prototype._destroyCore = async function () {
|
|
|
690
701
|
* 获取模块目录
|
|
691
702
|
* @returns {string} 模块目录
|
|
692
703
|
*/
|
|
693
|
-
Mod.prototype.
|
|
704
|
+
Mod.prototype.getDir = function () {
|
|
694
705
|
if (!this.getParent) return '';
|
|
695
706
|
return this.getParent()?.getDir() || '';
|
|
696
707
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.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": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@prettier/sync": "^0.6.1",
|
|
37
|
-
"mm_config": "^2.3.
|
|
38
|
-
"mm_hot_reload": "^1.3.
|
|
39
|
-
"mm_tpl": "^2.5.
|
|
37
|
+
"mm_config": "^2.3.7",
|
|
38
|
+
"mm_hot_reload": "^1.3.4",
|
|
39
|
+
"mm_tpl": "^2.5.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"eslint": "^10.3.0",
|