mm_machine 2.3.0 → 2.3.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.
- package/index.js +21 -17
- package/mod.js +7 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,6 +5,10 @@ const { Drive } = require('./drive.js');
|
|
|
5
5
|
* 管理器类
|
|
6
6
|
*/
|
|
7
7
|
class Manager extends Mod {
|
|
8
|
+
/**
|
|
9
|
+
* 配置项
|
|
10
|
+
* @type {object}
|
|
11
|
+
*/
|
|
8
12
|
static config = {
|
|
9
13
|
/**
|
|
10
14
|
* 管理器名称
|
|
@@ -21,6 +25,11 @@ class Manager extends Mod {
|
|
|
21
25
|
* @type {string}
|
|
22
26
|
*/
|
|
23
27
|
description: '用于管理驱动',
|
|
28
|
+
/**
|
|
29
|
+
* 检索文件名
|
|
30
|
+
* @type {string}
|
|
31
|
+
*/
|
|
32
|
+
filename: 'manager.json',
|
|
24
33
|
/**
|
|
25
34
|
* 模板目录
|
|
26
35
|
* @type {string}
|
|
@@ -37,40 +46,35 @@ class Manager extends Mod {
|
|
|
37
46
|
*/
|
|
38
47
|
dir: './ai/manager'.fullname(),
|
|
39
48
|
/**
|
|
40
|
-
*
|
|
49
|
+
* 类型 script脚本 | json配置 | drive驱动
|
|
41
50
|
* @type {string}
|
|
42
51
|
*/
|
|
43
|
-
|
|
52
|
+
type: 'drive',
|
|
44
53
|
/**
|
|
45
54
|
* 是否懒加载
|
|
46
55
|
* @type {boolean}
|
|
47
56
|
*/
|
|
48
57
|
lazy_load: true,
|
|
49
58
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
59
|
+
* 模式
|
|
60
|
+
* 1.生产模式,改变文件不会重新加载
|
|
61
|
+
* 2.热更新模式,改变配置文件会重新加载配置,不重新加载脚本
|
|
62
|
+
* 3.热重载模式,改变配置文件都会加载配置和脚本
|
|
63
|
+
* 4.热更新+重载模式,改变配置文件重新加载配置和脚本,执行完后重新加载脚本
|
|
64
|
+
* 5.重载模式,执行完后重新加载脚本,避免变量污染
|
|
65
|
+
* @type {number}
|
|
52
66
|
*/
|
|
53
|
-
|
|
67
|
+
mode: 3,
|
|
54
68
|
/**
|
|
55
69
|
* 排序项
|
|
56
70
|
* @type {string}
|
|
57
71
|
*/
|
|
58
72
|
sort_key: 'sort',
|
|
59
73
|
/**
|
|
60
|
-
*
|
|
74
|
+
* 作用域(同时作为检索的后缀名)
|
|
61
75
|
* @type {string}
|
|
62
76
|
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 模式
|
|
66
|
-
* 1.生产模式,改变文件不会重新加载
|
|
67
|
-
* 2.热更新模式,改变配置文件会重新加载配置,不重新加载脚本
|
|
68
|
-
* 3.热重载模式,改变配置文件都会加载配置和脚本
|
|
69
|
-
* 4.热更新+重载模式,改变配置文件重新加载配置和脚本,执行完后重新加载脚本
|
|
70
|
-
* 5.重载模式,执行完后重新加载脚本,避免变量污染
|
|
71
|
-
* @type {number}
|
|
72
|
-
*/
|
|
73
|
-
mode: 3
|
|
77
|
+
scope: ($.val && $.val.scope) ? $.val.scope + '' : 'server'
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
/**
|
package/mod.js
CHANGED
|
@@ -336,25 +336,25 @@ Mod.prototype.emitEvent = function (event, ...args) {
|
|
|
336
336
|
|
|
337
337
|
/**
|
|
338
338
|
* 运行方法
|
|
339
|
-
* @param {string} method 方法名
|
|
340
339
|
* @param {...any} args 方法参数
|
|
341
340
|
* @returns {Promise<any>} 方法执行结果
|
|
342
341
|
*/
|
|
343
|
-
Mod.prototype.run = async function (
|
|
344
|
-
return this.main(
|
|
342
|
+
Mod.prototype.run = async function (...args) {
|
|
343
|
+
return this.main(...args);
|
|
345
344
|
};
|
|
346
345
|
|
|
347
346
|
/**
|
|
348
|
-
*
|
|
349
|
-
* @param {string} method 方法名
|
|
347
|
+
* 主方法名
|
|
350
348
|
* @param {...any} args 方法参数
|
|
351
349
|
* @returns {Promise<any>} 方法执行结果
|
|
352
350
|
*/
|
|
353
|
-
Mod.prototype.main = async function (
|
|
351
|
+
Mod.prototype.main = async function (...args) {
|
|
352
|
+
let method = args[0];
|
|
354
353
|
if (!this.methods?.[method]) {
|
|
355
354
|
throw new Error(`方法${method}不存在`);
|
|
356
355
|
}
|
|
357
|
-
|
|
356
|
+
let params = args.slice(1);
|
|
357
|
+
return await this.methods[method](...params);
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.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": {
|