@yumerijs/loader 1.1.0-alpha.5 → 1.1.1
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/dist/index.js +12 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41,13 +41,13 @@ const child_process_1 = require("child_process");
|
|
|
41
41
|
const tsNode = __importStar(require("ts-node"));
|
|
42
42
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
43
43
|
class PluginLoader {
|
|
44
|
+
pluginCache = {};
|
|
45
|
+
core = null;
|
|
46
|
+
config = null;
|
|
47
|
+
isDev = false;
|
|
48
|
+
pluginsDir = 'plugins'; // Default plugins directory
|
|
49
|
+
logger = new core_1.Logger('loader');
|
|
44
50
|
constructor(core, config, pluginsDir = 'plugins') {
|
|
45
|
-
this.pluginCache = {};
|
|
46
|
-
this.core = null;
|
|
47
|
-
this.config = null;
|
|
48
|
-
this.isDev = false;
|
|
49
|
-
this.pluginsDir = 'plugins'; // Default plugins directory
|
|
50
|
-
this.logger = new core_1.Logger('loader');
|
|
51
51
|
this.pluginCache = {};
|
|
52
52
|
this.core = core || null;
|
|
53
53
|
this.config = config || null;
|
|
@@ -71,10 +71,11 @@ class PluginLoader {
|
|
|
71
71
|
* @throws 如果插件加载失败.
|
|
72
72
|
*/
|
|
73
73
|
async load(pluginName) {
|
|
74
|
-
if (this.pluginCache[pluginName]) {
|
|
75
|
-
this.logger.info(`Returning cached plugin: ${pluginName}`);
|
|
74
|
+
if (this.pluginCache[pluginName] && !this.isDev) {
|
|
75
|
+
// this.logger.info(`Returning cached plugin: ${pluginName}`);
|
|
76
76
|
return this.pluginCache[pluginName];
|
|
77
77
|
}
|
|
78
|
+
// this.logger.info('test')
|
|
78
79
|
let pluginPath;
|
|
79
80
|
let isLocalPlugin = false;
|
|
80
81
|
// 1. 检查是否是本地插件目录下的插件
|
|
@@ -117,6 +118,9 @@ class PluginLoader {
|
|
|
117
118
|
this.logger.error(`Failed to load plugin from ${pluginPath}:`, e);
|
|
118
119
|
throw e;
|
|
119
120
|
}
|
|
121
|
+
// const plugin = require(pluginName);
|
|
122
|
+
// this.pluginCache[pluginName] = plugin;
|
|
123
|
+
// return plugin;
|
|
120
124
|
}
|
|
121
125
|
/**
|
|
122
126
|
* 从指定路径加载插件.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yumerijs/loader",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Module loader for yumeri",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.8.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@yumerijs/core": "1.1.0
|
|
34
|
+
"@yumerijs/core": "^1.1.0",
|
|
35
35
|
"chokidar": "^4.0.3",
|
|
36
36
|
"semver": "^7.7.1",
|
|
37
37
|
"ts-node": "^10.9.2"
|