@serenityjs/plugins 0.5.0-beta-20240831023513 → 0.5.0-beta-20240831074557
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.d.ts +6 -0
- package/dist/index.js +30 -2
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,12 @@ declare class Plugins extends Emitter<PluginEvents> {
|
|
|
55
55
|
* Stops all plugins.
|
|
56
56
|
*/
|
|
57
57
|
stop(...arguments_: Array<unknown>): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Reloads a plugin by its name.
|
|
60
|
+
* @param name - The name of the plugin.
|
|
61
|
+
* @param arguments_ - The arguments to pass to the plugin.
|
|
62
|
+
*/
|
|
63
|
+
reload(name: string, ...arguments_: Array<unknown>): Promise<void>;
|
|
58
64
|
/**
|
|
59
65
|
* Gets all the currently loaded plugins.
|
|
60
66
|
* @returns All the currently loaded plugins.
|
package/dist/index.js
CHANGED
|
@@ -172,8 +172,7 @@ var Plugins = class extends import_emitter.default {
|
|
|
172
172
|
);
|
|
173
173
|
continue;
|
|
174
174
|
}
|
|
175
|
-
const
|
|
176
|
-
const module2 = instance["default"];
|
|
175
|
+
const module2 = require(`${(0, import_node_path3.resolve)(path, pak.main)}`);
|
|
177
176
|
const logger = new import_logger.Logger(
|
|
178
177
|
`${pak.name}@${pak.version}`,
|
|
179
178
|
import_logger.LoggerColors.Blue
|
|
@@ -212,6 +211,35 @@ var Plugins = class extends import_emitter.default {
|
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Reloads a plugin by its name.
|
|
216
|
+
* @param name - The name of the plugin.
|
|
217
|
+
* @param arguments_ - The arguments to pass to the plugin.
|
|
218
|
+
*/
|
|
219
|
+
async reload(name, ...arguments_) {
|
|
220
|
+
const plugin = this.entries.get(name);
|
|
221
|
+
if (!plugin) throw new Error(`Plugin ${name} not found!`);
|
|
222
|
+
if (plugin.module.onShutdown) {
|
|
223
|
+
await plugin.module.onShutdown(...arguments_, plugin);
|
|
224
|
+
}
|
|
225
|
+
const { path, package: pak } = plugin;
|
|
226
|
+
this.entries.delete(name);
|
|
227
|
+
delete require.cache[require.resolve(path)];
|
|
228
|
+
const module2 = require(`${(0, import_node_path3.resolve)(path, pak.main)}`);
|
|
229
|
+
const logger = new import_logger.Logger(
|
|
230
|
+
`${pak.name}@${pak.version}.r`,
|
|
231
|
+
import_logger.LoggerColors.Blue
|
|
232
|
+
);
|
|
233
|
+
const reloaded = { package: pak, module: module2, logger, path };
|
|
234
|
+
this.entries.set(pak.name, reloaded);
|
|
235
|
+
this.logger.success(`Reloaded plugin \xA71${pak.name}\xA78@\xA71${pak.version}\xA7r.`);
|
|
236
|
+
if (module2.onInitialize) {
|
|
237
|
+
await module2.onInitialize(...arguments_, reloaded);
|
|
238
|
+
}
|
|
239
|
+
if (module2.onStartup) {
|
|
240
|
+
await module2.onStartup(...arguments_, reloaded);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
215
243
|
/**
|
|
216
244
|
* Gets all the currently loaded plugins.
|
|
217
245
|
* @returns All the currently loaded plugins.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenityjs/plugins",
|
|
3
|
-
"version": "0.5.0-beta-
|
|
3
|
+
"version": "0.5.0-beta-20240831074557",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/SerenityJS/serenity",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"preset": "@serenityjs/jest-presets/jest/node"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@serenityjs/eslint-config": "0.5.0-beta-
|
|
22
|
-
"@serenityjs/jest-presets": "0.5.0-beta-
|
|
23
|
-
"@serenityjs/typescript-config": "0.5.0-beta-
|
|
21
|
+
"@serenityjs/eslint-config": "0.5.0-beta-20240831074557",
|
|
22
|
+
"@serenityjs/jest-presets": "0.5.0-beta-20240831074557",
|
|
23
|
+
"@serenityjs/typescript-config": "0.5.0-beta-20240831074557",
|
|
24
24
|
"@types/adm-zip": "^0",
|
|
25
25
|
"@types/jest": "^29.5.12",
|
|
26
26
|
"@types/node": "^20.11.24",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"typescript": "^5.4.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@serenityjs/emitter": "0.5.0-beta-
|
|
33
|
-
"@serenityjs/logger": "0.5.0-beta-
|
|
32
|
+
"@serenityjs/emitter": "0.5.0-beta-20240831074557",
|
|
33
|
+
"@serenityjs/logger": "0.5.0-beta-20240831074557",
|
|
34
34
|
"adm-zip": "^0.5.16"
|
|
35
35
|
}
|
|
36
36
|
}
|