@evitcastudio/kit 2.0.1 → 2.1.0

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/README.md CHANGED
@@ -39,11 +39,8 @@ await Kit.setResources(resourceJSON);
39
39
  ```ts
40
40
  import { Plugin } from 'custom-plugin';
41
41
 
42
- // Initialize an array of plugins.
43
- Kit.init([Plugin]);
44
-
45
42
  // or you can just register one plugin
46
- Kit.registerPlugin(Plugin);
43
+ const plugin = Kit.registerPlugin(Plugin);
47
44
  ```
48
45
 
49
46
  # Listening for plugin events
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /*!
4
- * @evitcastudio/kit@2.0.1 git+https://github.com/EvitcaStudio/Kit.git
5
- * Compiled Fri, 10 Jan 2025 09:36:26 UTC
4
+ * @evitcastudio/kit@2.1.0 git+https://github.com/EvitcaStudio/Kit.git
5
+ * Compiled Fri, 10 Jan 2025 16:40:21 UTC
6
6
  * Copyright (c) 2025 Jared Bates, Evitca Studio, "doubleactii"
7
7
  *
8
8
  * @evitcastudio/kit is licensed under the MIT License.
@@ -2573,7 +2573,7 @@ class KitCLI {
2573
2573
  // package.json
2574
2574
  var package_default = {
2575
2575
  name: "@evitcastudio/kit",
2576
- version: "2.0.1",
2576
+ version: "2.1.0",
2577
2577
  author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
2578
2578
  main: "./lib/index.js",
2579
2579
  types: "./lib/index.d.ts",
package/lib/kit.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare class Kit {
16
16
  private constructor();
17
17
  /**
18
18
  * Initialize the Kit class with plugins.
19
+ * @deprecated Use `registerPlugin` instead.
19
20
  * @param pPlugins - An array of plugins to initialize.
20
21
  */
21
22
  static init<T extends KitPlugin>(pPlugins: KitPluginConstructor<T>[]): void;
@@ -23,7 +24,8 @@ export declare class Kit {
23
24
  * Register a plugin with the Kit class.
24
25
  * @param pPlugin - The plugin to register.
25
26
  */
26
- static registerPlugin<T extends KitPlugin>(pPlugin: KitPluginConstructor<T>): void;
27
+ static registerPlugin<T extends KitPlugin>(pPlugin: KitPluginConstructor<T>): T;
28
+ static registerPlugin<T extends KitPlugin>(pPlugin: KitPluginConstructor<T>[]): T[];
27
29
  /**
28
30
  * Gets a plugin by name.
29
31
  * @param pName - String name of the plugin to retrieve.
package/lib/kit.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAgB,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAgBvG,qBAAa,GAAG;IACZ;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmC;IAC1D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM,CAAuC;IAE5D,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAM3E;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAyBlF;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAQnE;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;IAI7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAWlB;;;;;MAKE;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAA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IAQnE;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;IAI7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAWlB;;;;;MAKE;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI;IAQ7E;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI;IAO9E;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B;;OAEG;WACU,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAa1F"}
package/lib/kit.js CHANGED
@@ -29,6 +29,7 @@ export class Kit {
29
29
  }
30
30
  /**
31
31
  * Initialize the Kit class with plugins.
32
+ * @deprecated Use `registerPlugin` instead.
32
33
  * @param pPlugins - An array of plugins to initialize.
33
34
  */
34
35
  static init(pPlugins) {
@@ -36,27 +37,36 @@ export class Kit {
36
37
  this.registerPlugin(pPlugin);
37
38
  });
38
39
  }
39
- /**
40
- * Register a plugin with the Kit class.
41
- * @param pPlugin - The plugin to register.
42
- */
43
40
  static registerPlugin(pPlugin) {
44
- const plugin = new pPlugin();
45
- const pluginName = plugin.name;
46
- if (!pluginName || typeof pluginName !== 'string' || !/^[a-zA-Z0-9-_]+$/.test(pluginName)) {
47
- throw new Error(`[Kit] Invalid plugin name: '${pluginName}'. The name must be a non-empty string containing only alphanumeric characters, dashes, or underscores.`);
41
+ if (Array.isArray(pPlugin)) {
42
+ const plugins = [];
43
+ pPlugin.forEach(pPlugin => {
44
+ const plugin = this.registerPlugin(pPlugin);
45
+ if (plugin && !Array.isArray(plugin)) {
46
+ plugins.push(plugin);
47
+ }
48
+ });
49
+ return plugins;
48
50
  }
49
- if (Kit.plugins[pluginName]) {
50
- throw new Error(`[Kit] plugin with name '${pluginName}' is already registered.`);
51
+ else {
52
+ const plugin = new pPlugin();
53
+ const pluginName = plugin.name;
54
+ if (!pluginName || typeof pluginName !== 'string' || !/^[a-zA-Z0-9-_]+$/.test(pluginName)) {
55
+ throw new Error(`[Kit] Invalid plugin name: '${pluginName}'. The name must be a non-empty string containing only alphanumeric characters, dashes, or underscores.`);
56
+ }
57
+ if (Kit.plugins[pluginName]) {
58
+ throw new Error(`[Kit] plugin with name '${pluginName}' is already registered.`);
59
+ }
60
+ const listener = function (pEvent) {
61
+ Kit.emit(pEvent);
62
+ };
63
+ const emitter = new EventEmitter(listener, plugin);
64
+ Kit.emitters.set(pluginName, emitter);
65
+ Kit.plugins[pluginName] = plugin;
66
+ plugin._register(emitter);
67
+ plugin.onRegistered();
68
+ return plugin;
51
69
  }
52
- const listener = function (pEvent) {
53
- Kit.emit(pEvent);
54
- };
55
- const emitter = new EventEmitter(listener, plugin);
56
- Kit.emitters.set(pluginName, emitter);
57
- Kit.plugins[pluginName] = plugin;
58
- plugin._register(emitter);
59
- plugin.onRegistered();
60
70
  }
61
71
  /**
62
72
  * Gets a plugin by name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evitcastudio/kit",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "author": "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",