mm_machine 2.3.6 → 2.3.8

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 (2) hide show
  1. package/drive.js +18 -9
  2. package/package.json +1 -1
package/drive.js CHANGED
@@ -52,7 +52,7 @@ class Drive extends Mod {
52
52
  * @class
53
53
  */
54
54
  constructor(config, parent) {
55
- super(config, parent);
55
+ super({ ...Drive.config, ...config }, parent);
56
56
  // 当前配置文件路径
57
57
  this.config_file = '';
58
58
 
@@ -267,7 +267,7 @@ Drive.prototype._getScriptFile = function () {
267
267
  * @param {string} file 目标文件路径
268
268
  */
269
269
  Drive.prototype.newScript = function (file) {
270
- this._createScriptFile(file, this.config);
270
+ this._createScriptFile(file);
271
271
  };
272
272
 
273
273
  /**
@@ -276,9 +276,9 @@ Drive.prototype.newScript = function (file) {
276
276
  * @param {object} model 模板数据
277
277
  * @returns {boolean} 创建是否成功
278
278
  */
279
- Drive.prototype._createScriptFile = function (file, model = {}) {
279
+ Drive.prototype._createScriptFile = function (file) {
280
280
  var tpl = this._getScriptTpl();
281
- var content = $.tpl.render(tpl, model);
281
+ var content = $.tpl.render(tpl, this.getModel('script'));
282
282
  if (!content) {
283
283
  return '';
284
284
  }
@@ -411,6 +411,15 @@ Drive.prototype.prettyCode = function (code, type = 'json5') {
411
411
  return new_code;
412
412
  };
413
413
 
414
+ /**
415
+ * 获取模块模型
416
+ * @param {string} type 模型类型,可选"config"或"script"
417
+ * @returns {object} 模块模型
418
+ */
419
+ Drive.prototype.getModel = function (type) {
420
+ return this.config;
421
+ }
422
+
414
423
  /**
415
424
  * 创建配置文件
416
425
  * @param {string} file 目标文件路径
@@ -418,7 +427,7 @@ Drive.prototype.prettyCode = function (code, type = 'json5') {
418
427
  */
419
428
  Drive.prototype._createConfigFile = function (file) {
420
429
  var tpl = this._getConfigTpl();
421
- var content = $.tpl.render(tpl, this.config);
430
+ var content = $.tpl.render(tpl, this.getModel('config'));
422
431
  let code = this.prettyCode(content, 'json');
423
432
  file.saveText(code);
424
433
  return file;
@@ -605,7 +614,7 @@ Drive.prototype._getName = function (file) {
605
614
  /**
606
615
  * 加载前处理
607
616
  */
608
- Drive.prototype.loadBefore = async function () {
617
+ Drive.prototype.loadBefore = function () {
609
618
  try {
610
619
  let module = this.loadScript();
611
620
  if (module) {
@@ -620,9 +629,9 @@ Drive.prototype.loadBefore = async function () {
620
629
  /**
621
630
  * 加载处理
622
631
  */
623
- Drive.prototype._loadCore = async function () {
624
- await this.loadConfig();
625
- await this.loadScript();
632
+ Drive.prototype._loadCore = function () {
633
+ this.loadConfig();
634
+ this.loadScript();
626
635
  };
627
636
 
628
637
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
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": {