@evitcastudio/kit 3.1.1 → 3.2.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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +224 -123
  3. package/lib/bundle/cli/cli.js +379 -56
  4. package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
  5. package/lib/bundle/cli/kit-game-templates/multi/package.json +3 -3
  6. package/lib/bundle/cli/kit-game-templates/multi/resource.json +1 -0
  7. package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +4 -4
  8. package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +4 -4
  9. package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -180
  10. package/lib/bundle/cli/kit-game-templates/single/package.json +3 -3
  11. package/lib/bundle/cli/kit-game-templates/single/resource.json +1 -0
  12. package/lib/cli/app-bundler.d.ts +29 -0
  13. package/lib/cli/app-bundler.d.ts.map +1 -0
  14. package/lib/cli/app-bundler.js +230 -0
  15. package/lib/cli/create.d.ts +11 -0
  16. package/lib/cli/create.d.ts.map +1 -0
  17. package/lib/cli/create.js +88 -0
  18. package/lib/cli/doctor.d.ts +9 -0
  19. package/lib/cli/doctor.d.ts.map +1 -0
  20. package/lib/cli/doctor.js +179 -0
  21. package/lib/cli/host.d.ts +49 -0
  22. package/lib/cli/host.d.ts.map +1 -0
  23. package/lib/cli/host.js +127 -0
  24. package/lib/cli/init.d.ts +2 -0
  25. package/lib/cli/init.d.ts.map +1 -1
  26. package/lib/cli/init.js +42 -15
  27. package/lib/cli/main.d.ts +22 -1
  28. package/lib/cli/main.d.ts.map +1 -1
  29. package/lib/cli/main.js +28 -1
  30. package/lib/cli/resource-builder.d.ts +1 -1
  31. package/lib/cli/resource-builder.d.ts.map +1 -1
  32. package/lib/cli/resource-builder.js +139 -19
  33. package/lib/cli/types.d.ts +12 -6
  34. package/lib/cli/types.d.ts.map +1 -1
  35. package/lib/types/vylo.d.ts +3848 -3848
  36. package/lib/vendor/vyi/index.js +26 -26
  37. package/package.json +73 -73
  38. package/lib/bundle/cli/kit-game-templates/multi/bun-build.ts +0 -109
  39. package/lib/bundle/cli/kit-game-templates/single/bun-build.ts +0 -33
  40. package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +0 -28
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Jared Bates, Evitca Studio, "doubleactii"
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jared Bates, Evitca Studio, "doubleactii"
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,124 +1,225 @@
1
- # Kit
2
-
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 empowers developers to build complex projects quickly through a robust plugin-driven architecture.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- bun install -g @evitcastudio/kit
9
- ```
10
- > **Note:** The `-g` flag ensures the `kit` CLI tool is globally available in your PATH.
11
-
12
- ## Scaffolding a New Project
13
-
14
- The `kit init` command provides an interactive walkthrough to quickly scaffold a new project for the Vylocity Game Engine.
15
-
16
- ```bash
17
- # Start the interactive walkthrough
18
- kit init
19
-
20
- # Or scaffold a project with flags
21
- kit init <project-name> --single # For single-player
22
- kit init <project-name> --multi # For multiplayer
23
- ```
24
-
25
- The command will create a structured directory for your project, including pre-configured `package.json`, essential Vylocity files, and a local development environment.
26
-
27
- After scaffolding, follow these steps to get started:
28
- 1. `cd <project-name>`
29
- 2. `bun install`
30
- 3. `bun run build`
31
-
32
- ## Building the Project
33
-
34
- > **Note:** This process is preconfigured for you if you used `kit init`
35
-
36
- The `kit build` command locates all Vylocity engine-related resources in your source directory, anonymizes them, and moves them to a deploy-ready output directory.
37
-
38
- ```bash
39
- kit build -i ./<in-dir> -o ./<out-dir>
40
- ```
41
-
42
- ```bash
43
- # To learn more about this command
44
- kit build --help
45
- ```
46
-
47
- Executing this command automatically generates a `resource.json` map in your project's directory.
48
- **Best Practice:** Exclude `resource.json` from version control (`.gitignore`), as it is a build artifact.
49
-
50
- ## Runtime Resource Loading
51
-
52
- > **Note:** This process is preconfigured for you if you used `kit init`
53
-
54
- > `Kit.setResources()` should be called **before** `VYLO.load()`.
55
-
56
- ```typescript
57
- import resourceJSON from 'resource.json';
58
-
59
- // Initialize the engine with mapped resources
60
- await Kit.setResources(resourceJSON);
61
- ```
62
-
63
- ## Local Development & Testing
64
-
65
- Once your project is scaffolded and dependencies are installed and the project has been built, you can run your game locally.
66
-
67
- ### Running the Game
68
-
69
- ```bash
70
- # For Single-Player or Multiplayer games
71
- bun run host
72
- ```
73
-
74
- ### Accessing the Game
75
-
76
- The server will be available at the following locations after being hosted:
77
-
78
- > **Singleplayer**
79
- [http://localhost:8090](http://localhost:8090) defined in `./bun-serve.ts`
80
-
81
- > **Multiplayer or Singleplayer & Multiplayer**
82
- [http://localhost:30000](http://localhost:30000) defined in `./src/server/settings.json`
83
-
84
-
85
- ## Plugin Architecture
86
-
87
- ```ts
88
- import { Plugin } from 'custom-plugin';
89
-
90
- // Register a single plugin
91
- const plugin = Kit.registerPlugin(Plugin);
92
- ```
93
-
94
- ```ts
95
- // Register multiple plugins
96
- import { Plugin1 } from 'custom-plugin1';
97
- import { Plugin2 } from 'custom-plugin2';
98
-
99
- const plugins = Kit.registerPlugins([Plugin1, Plugin2]);
100
-
101
- // After being registered, kit can find the plugin by name.
102
- const plugin1 = Kit.getPlugin('plugin1-name');
103
- const plugin2 = Kit.getPlugin('plugin2-name');
104
- ```
105
-
106
- ### Listening for plugin events
107
-
108
- Plugins emit events, this is how they pass relevant data to other plugins or the main thread.
109
- By listening to these events you can act on this data.
110
-
111
- ```js
112
- const listener = (pEvent: EmitterEvent) => {
113
- const { data, timestamp } = pEvent;
114
- // Here you can use the data that the event sent down.
115
- }
116
-
117
- // Choose to listen to specific event from a plugin
118
- Kit.on('plugin-name', 'event-name', listener);
119
-
120
- // You can also stop listening for an event
121
- Kit.off('plugin-name', 'event-name', listener);
122
- ```
123
-
1
+ # Kit
2
+
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 empowers developers to build complex projects quickly through a robust plugin-driven architecture.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun install -g @evitcastudio/kit
9
+ ```
10
+ > **Note:** The `-g` flag ensures the `kit` CLI tool is globally available in your PATH.
11
+
12
+ ## CLI Reference & Usage
13
+
14
+ Kit includes a CLI tool (`kit`) for scaffolding projects, building game assets, generating plugin boilerplate, and diagnosing your environment.
15
+
16
+ ### Global Options
17
+ - `-v, --verbose`: Enables verbose output and detailed debugging logs.
18
+ - `-h, --help`: Displays help and usage information for any command.
19
+ - `-V, --version`: Displays the installed Kit CLI version.
20
+
21
+ ---
22
+
23
+ ### `kit init [name]`
24
+ Initializes a new game project for the Vylocity Game Engine. If run without arguments or flags, an interactive prompt will guide you through project setup.
25
+
26
+ ```bash
27
+ # Interactive setup
28
+ kit init
29
+
30
+ # Quick start with flags
31
+ kit init my-game --single --install
32
+ ```
33
+
34
+ #### Flags & Options:
35
+ | Flag / Option | Type | Default | Description |
36
+ | :--- | :--- | :--- | :--- |
37
+ | `[name]` | `string` | `kit-project` | The name of the project folder to create. |
38
+ | `-s, --single` | `boolean` | `false` | Quick-starts a single-player game template. |
39
+ | `-m, --multi` | `boolean` | `false` | Quick-starts a multiplayer game template (pass both `-s` and `-m` for both). |
40
+ | `-f, --force` | `boolean` | `false` | Overwrites the destination folder if it already exists without aborting. |
41
+ | `-i, --install` | `boolean` | `false` | Automatically runs `bun install` inside the new project directory after creation. |
42
+
43
+ ---
44
+
45
+ ### `kit build`
46
+ Builds resources and compiles game application code. Automatically detects whether your project is **Singleplayer** or **Multiplayer**, compiles TypeScript entrypoints to `dist/`, copies static web files (`.html`, `.css`, `.ico`, vendor directories), hashes raw assets into unique identifiers (`.vyr`), mirrors custom subdirectories, and exports metadata manifests (`resource.json`, `bounds.json`, `icon-points.json`, and `sizes.json`).
47
+
48
+ ```bash
49
+ # Zero-config build (auto-detects project architecture, builds ./src to ./dist)
50
+ kit build
51
+
52
+ # Production ready build (minified, obfuscated identifiers, stripped sourcemaps)
53
+ kit build -p
54
+
55
+ # Watch mode: auto-rebuilds on source or resource changes
56
+ kit build --watch
57
+
58
+ # Build only raw resources with custom directories
59
+ kit build -i ./src/resources -o ./dist --no-app
60
+
61
+ # Save the resource manifest to a custom location
62
+ kit build --manifest ./dist/resource.json
63
+ ```
64
+
65
+ #### Flags & Options:
66
+ | Flag / Option | Type | Required | Default | Description |
67
+ | :--- | :--- | :--- | :--- | :--- |
68
+ | `-i, --in <path>` | `string` | No | `./src/resources` | Input directory containing raw game assets (`.vyi`, `.vym`, `.vyint`, audio, etc.). |
69
+ | `-o, --out <path>` | `string` | No | `./dist` | Destination directory where processed `resources/` and bundled app files will be written. |
70
+ | `-m, --manifest <path>` | `string` | No | `./resource.json` | Path where the resource lookup JSON should be saved. If omitted, defaults to `./resource.json` in the current working directory. |
71
+ | `-w, --watch` | `boolean` | No | `false` | Watches the source and resource directories for changes and triggers automatic incremental rebuilds. |
72
+ | `-is, --ignore-sound` | `boolean` | No | `false` | Skips processing and copying sound and music files (`.mp3`, `.ogg`, `.wav`, etc.). |
73
+ | `-p, --prod` | `boolean` | No | `false` | Production mode: enables full minification, identifier obfuscation/mangling, and strips sourcemaps. |
74
+ | `--minify` | `boolean` | No | `false` | Minifies bundled JavaScript syntax, whitespace, and variable names. |
75
+ | `--obfuscate` | `boolean` | No | `false` | Mangles and obfuscates identifiers across bundled output. |
76
+ | `--sourcemap <mode>` | `string` | No | `linked` (`none` in prod) | Sourcemap mode (`none`, `linked`, `inline`, `external`). |
77
+ | `--app` / `--no-app` | `boolean` | No | `true` (auto) | Toggles application code bundling. Enabled automatically if `src/index.ts` or `src/client/index.ts` exists. |
78
+
79
+ #### What is the Resource Manifest (`resource.json`)?
80
+ A manifest is an index or lookup table. `kit build` obfuscates asset names into unique identifiers (`uuid.vyr`) as a security benefit to protect and hide original asset filenames in production. It generates `resource.json` mapping your original human-readable asset names to their engine identifiers:
81
+ ```json
82
+ {
83
+ "icon": [
84
+ {
85
+ "fileName": "player.vyi",
86
+ "resourceIdentifier": "3cf72322-6b92-4ea5-bbca-b96fae1fe440.vyr"
87
+ }
88
+ ],
89
+ "map": [ ... ],
90
+ "sound": [ ... ]
91
+ }
92
+ ```
93
+
94
+ #### Custom Asset Subdirectories (Automatic Pass-Through)
95
+ Any subdirectories inside your resource folder (e.g. `src/resources/images`, `src/resources/fonts`, `src/resources/emitters`, `src/resources/particles`, etc.) are automatically mirrored to `<out>/resources/<folder>/`. Non-engine files remain in their original form.
96
+
97
+ ---
98
+
99
+ ### `kit create <type> <name>`
100
+ Scaffolds boilerplate files inside an existing Kit project following standard architectural conventions.
101
+
102
+ ```bash
103
+ # Generate a typed plugin
104
+ kit create plugin Inventory
105
+ ```
106
+
107
+ #### Types:
108
+ - `plugin`: Creates a new TypeScript file at `src/plugins/<name>.ts` that subclasses `KitPlugin` with typed lifecycle hooks (`onRegistered()`) ready to extend.
109
+
110
+ ---
111
+
112
+ ### `kit host`
113
+ Hosts the game project locally for development and testing.
114
+
115
+ ```bash
116
+ # Host the dist folder on port 8090
117
+ kit host
118
+
119
+ # Build before hosting and specify custom port
120
+ kit host -b -p 8080
121
+ ```
122
+
123
+ #### Options:
124
+ - `-p, --port <number>`: Port to bind the server to (default: `8090`).
125
+ - `-d, --dir <path>`: Directory containing built files to serve (default: `./dist`).
126
+ - `-b, --build`: Trigger a `kit build` before starting the server.
127
+
128
+ #### Behavior:
129
+ - **Singleplayer / Client Projects:** Spawns a lightweight local HTTP server powered by Bun that serves `dist/index.html` and static assets with local and network LAN URLs.
130
+ - **Multiplayer Projects:** Automatically launches the backend node server (`dist/server.js`) with configured settings (`dist/settings.json`).
131
+
132
+ ---
133
+
134
+ ### `kit doctor`
135
+ Inspects your local environment and current project health.
136
+
137
+ ```bash
138
+ kit doctor
139
+ ```
140
+
141
+ #### What it checks:
142
+ - **Bun Runtime:** Verifies that Bun is installed and detects the version.
143
+ - **Git Installation:** Verifies that Git is accessible in your `PATH`.
144
+ - **Project Structure:** If executed within a game project, checks `package.json`, `@evitcastudio/kit` framework dependencies, and asset folders (`src/resources`).
145
+ - **Project Architecture:** Detects whether the project is **Singleplayer** (`src/index.ts`), **Multiplayer** (`src/client` & `src/server`), or **Dedicated Server**.
146
+ - **Build Pipeline:** Verifies that a valid build pipeline is configured (either native `kit build` in `package.json` or legacy `bun-build.ts`).
147
+
148
+ ---
149
+
150
+ ## Runtime Resource Loading
151
+
152
+ > **Note:** This process is preconfigured for you if you used `kit init`.
153
+
154
+ `Kit.setResources()` should be called **before** `VYLO.load()`.
155
+
156
+ ```typescript
157
+ import resourceJSON from 'resource.json';
158
+
159
+ // Initialize the engine with mapped resources
160
+ await Kit.setResources(resourceJSON);
161
+ ```
162
+
163
+
164
+ ## Local Development & Testing
165
+
166
+ Once your project is scaffolded and dependencies are installed and the project has been built, you can run your game locally.
167
+
168
+ ### Running the Game
169
+
170
+ ```bash
171
+ # For Single-Player or Multiplayer games
172
+ bun run host
173
+ ```
174
+
175
+ ### Accessing the Game
176
+
177
+ The server will be available at the following locations after being hosted:
178
+
179
+ > **Singleplayer**
180
+ [http://localhost:8090](http://localhost:8090) defined in `./bun-serve.ts`
181
+
182
+ > **Multiplayer or Singleplayer & Multiplayer**
183
+ [http://localhost:30000](http://localhost:30000) defined in `./src/server/settings.json`
184
+
185
+
186
+ ## Plugin Architecture
187
+
188
+ ```ts
189
+ import { Plugin } from 'custom-plugin';
190
+
191
+ // Register a single plugin
192
+ const plugin = Kit.registerPlugin(Plugin);
193
+ ```
194
+
195
+ ```ts
196
+ // Register multiple plugins
197
+ import { Plugin1 } from 'custom-plugin1';
198
+ import { Plugin2 } from 'custom-plugin2';
199
+
200
+ const plugins = Kit.registerPlugins([Plugin1, Plugin2]);
201
+
202
+ // After being registered, kit can find the plugin by name.
203
+ const plugin1 = Kit.getPlugin('plugin1-name');
204
+ const plugin2 = Kit.getPlugin('plugin2-name');
205
+ ```
206
+
207
+ ### Listening for plugin events
208
+
209
+ Plugins emit events, this is how they pass relevant data to other plugins or the main thread.
210
+ By listening to these events you can act on this data.
211
+
212
+ ```js
213
+ const listener = (pEvent: EmitterEvent) => {
214
+ const { data, timestamp } = pEvent;
215
+ // Here you can use the data that the event sent down.
216
+ }
217
+
218
+ // Choose to listen to specific event from a plugin
219
+ Kit.on('plugin-name', 'event-name', listener);
220
+
221
+ // You can also stop listening for an event
222
+ Kit.off('plugin-name', 'event-name', listener);
223
+ ```
224
+
124
225
  For more information check out the [wiki](https://github.com/EvitcaStudio/Kit/wiki)