mm_machine 3.4.7 → 3.4.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/lib/drive.js +19 -1
  2. package/package.json +1 -1
package/lib/drive.js CHANGED
@@ -62,6 +62,24 @@ class Drive extends Mod {
62
62
  }
63
63
  }
64
64
 
65
+ /**
66
+ * 监听初始化事件
67
+ */
68
+ Drive.prototype._onInit = function () {
69
+ // 初始化
70
+ this.on('init:before', async (ctx) => {
71
+ this.setState('initing');
72
+ this._initOptions();
73
+ await this._initCore(...ctx.params);
74
+ });
75
+ this.on('init:success', (ctx) => {
76
+ this.isInited(true);
77
+ });
78
+ this.on('init:after', (ctx) => {
79
+ this.setState('inited');
80
+ });
81
+ };
82
+
65
83
  /**
66
84
  * 监听加载事件
67
85
  * @param {object} ctx 上下文对象
@@ -152,7 +170,6 @@ Drive.prototype.setConfig = function (config) {
152
170
  this.isLoaded(false);
153
171
  }
154
172
  this._preset();
155
- this._initOptions();
156
173
  return this.config;
157
174
  };
158
175
 
@@ -250,6 +267,7 @@ Drive.prototype._getOptionsFileName = function () {
250
267
  */
251
268
  Drive.prototype._getOptionsDirName = function () {
252
269
  let parent = this.getParent();
270
+ if (!parent) return '';
253
271
  var current_name = parent.constructor.name + '_' + (parent.config.name || 'default');
254
272
  return current_name.toLowerCase();
255
273
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "3.4.7",
3
+ "version": "3.4.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": {