mm_machine 2.7.4 → 2.7.6
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 +8 -14
- package/index.js +4 -4
- package/mod.js +11 -1
- package/package.json +3 -3
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
|
// 如果文件不存在,创建新的配置文件
|
|
@@ -630,9 +630,9 @@ Drive.prototype._getName = function (file) {
|
|
|
630
630
|
};
|
|
631
631
|
|
|
632
632
|
/**
|
|
633
|
-
*
|
|
633
|
+
* 加载处理
|
|
634
634
|
*/
|
|
635
|
-
Drive.prototype.
|
|
635
|
+
Drive.prototype._loadCore = function () {
|
|
636
636
|
try {
|
|
637
637
|
let module = this.loadScript();
|
|
638
638
|
if (module) {
|
|
@@ -642,12 +642,6 @@ Drive.prototype.loadBefore = function () {
|
|
|
642
642
|
this.log('error', `加载前处理失败: `, err);
|
|
643
643
|
this.is_loaded = false;
|
|
644
644
|
}
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* 加载处理
|
|
649
|
-
*/
|
|
650
|
-
Drive.prototype._loadCore = function () {
|
|
651
645
|
// this.loadConfig();
|
|
652
646
|
// this.loadScript();
|
|
653
647
|
};
|
|
@@ -659,7 +653,7 @@ Drive.prototype.save = function () {
|
|
|
659
653
|
try {
|
|
660
654
|
if (!this.script_file) return;
|
|
661
655
|
|
|
662
|
-
let file = this.script_file.fullname(this.
|
|
656
|
+
let file = this.script_file.fullname(this.getDir());
|
|
663
657
|
let text = file.loadText();
|
|
664
658
|
|
|
665
659
|
if (text && text.trim().startsWith('[')) {
|
|
@@ -690,7 +684,7 @@ Drive.prototype.save = function () {
|
|
|
690
684
|
* 删除项目
|
|
691
685
|
*/
|
|
692
686
|
Drive.prototype.remove = function () {
|
|
693
|
-
let dir = this.
|
|
687
|
+
let dir = this.getDir();
|
|
694
688
|
if (dir) {
|
|
695
689
|
dir.delDir();
|
|
696
690
|
}
|
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
|
@@ -429,6 +429,16 @@ Mod.prototype.emitEventRace = async function (event, ...args) {
|
|
|
429
429
|
return await this.getEventer()?.emitRace(event, ...args);
|
|
430
430
|
};
|
|
431
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);
|
|
440
|
+
};
|
|
441
|
+
|
|
432
442
|
/**
|
|
433
443
|
* 注册事件监听
|
|
434
444
|
* @param {string} event 事件名
|
|
@@ -691,7 +701,7 @@ Mod.prototype._destroyCore = async function () {
|
|
|
691
701
|
* 获取模块目录
|
|
692
702
|
* @returns {string} 模块目录
|
|
693
703
|
*/
|
|
694
|
-
Mod.prototype.
|
|
704
|
+
Mod.prototype.getDir = function () {
|
|
695
705
|
if (!this.getParent) return '';
|
|
696
706
|
return this.getParent()?.getDir() || '';
|
|
697
707
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
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": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"mm_tpl": "^2.5.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"eslint": "^10.
|
|
43
|
-
"eslint-plugin-jsdoc": "^
|
|
42
|
+
"eslint": "^10.4.1",
|
|
43
|
+
"eslint-plugin-jsdoc": "^63.0.2",
|
|
44
44
|
"mm_eslint": "^1.7.1"
|
|
45
45
|
}
|
|
46
46
|
}
|