@evitcastudio/kit 2.0.0 → 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 +7 -13
- package/lib/bundle/cli/cli.js +4 -4
- package/lib/kit.d.ts +3 -1
- package/lib/kit.d.ts.map +1 -1
- package/lib/kit.js +28 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# Kit
|
|
2
2
|
|
|
3
|
-
**Kit** is a lightweight, extensible 2D framework for game development in
|
|
4
|
-
|
|
5
|
-
**Lightweight and modular**: Core functionality is minimal; plugins add power.
|
|
6
|
-
**Plugin support**: Easily extend Kit with official or third-party plugins.
|
|
7
|
-
**Event system**: Decouple functionality with a robust event-driven API.
|
|
8
|
-
**TypeScript-first**: Full TypeScript support for strong typing and modern workflows.
|
|
3
|
+
**Kit** is a lightweight, extensible 2D framework for game development in the [Vylocity Game Engine](https://www.vylocity.com/). Designed to be simple and modular, Kit lets you build powerful projects through a plugin-driven architecture.
|
|
9
4
|
|
|
10
5
|
# Install
|
|
11
6
|
```bash
|
|
@@ -28,10 +23,10 @@ It is recommended to exclude this file from your version control system, as it i
|
|
|
28
23
|
|
|
29
24
|
|
|
30
25
|
> [!IMPORTANT]
|
|
31
|
-
|
|
26
|
+
This API should be ran BEFORE `VYLO.load()` is called.
|
|
32
27
|
|
|
33
28
|
> [!WARNING]
|
|
34
|
-
|
|
29
|
+
Depending on your environment the following [import syntax](https://github.com/EvitcaStudio/Kit/wiki/FAQ#importing-json-resources) for json may not work.
|
|
35
30
|
|
|
36
31
|
|
|
37
32
|
```js
|
|
@@ -44,11 +39,8 @@ await Kit.setResources(resourceJSON);
|
|
|
44
39
|
```ts
|
|
45
40
|
import { Plugin } from 'custom-plugin';
|
|
46
41
|
|
|
47
|
-
// Initialize an array of plugins.
|
|
48
|
-
Kit.init([Plugin]);
|
|
49
|
-
|
|
50
42
|
// or you can just register one plugin
|
|
51
|
-
Kit.registerPlugin(Plugin);
|
|
43
|
+
const plugin = Kit.registerPlugin(Plugin);
|
|
52
44
|
```
|
|
53
45
|
|
|
54
46
|
# Listening for plugin events
|
|
@@ -64,4 +56,6 @@ Kit.on('Plugin', 'eventName', listener);
|
|
|
64
56
|
|
|
65
57
|
// You can also stop listening for an event
|
|
66
58
|
Kit.off('Plugin', 'eventName', listener);
|
|
67
|
-
```
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For more information check out the [wiki](https://github.com/EvitcaStudio/Kit/wiki)
|
package/lib/bundle/cli/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* @evitcastudio/kit@2.
|
|
5
|
-
* Compiled
|
|
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.
|
|
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",
|
|
@@ -2604,7 +2604,7 @@ var package_default = {
|
|
|
2604
2604
|
pack: "bun pm pack --dry-run",
|
|
2605
2605
|
"build-types": "bun tsc",
|
|
2606
2606
|
build: "bun bun-build.ts",
|
|
2607
|
-
"build-docs": "bun typedoc
|
|
2607
|
+
"build-docs": "bun typedoc",
|
|
2608
2608
|
"build-all": "bun run build-types && bun run build && bun run build-docs"
|
|
2609
2609
|
},
|
|
2610
2610
|
bin: {
|
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>):
|
|
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
|
|
1
|
+
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"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,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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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.
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"pack": "bun pm pack --dry-run",
|
|
32
32
|
"build-types": "bun tsc",
|
|
33
33
|
"build": "bun bun-build.ts",
|
|
34
|
-
"build-docs": "bun typedoc
|
|
34
|
+
"build-docs": "bun typedoc",
|
|
35
35
|
"build-all": "bun run build-types && bun run build && bun run build-docs"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|