@evitcastudio/kit 3.3.1 → 3.4.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 +209 -127
- package/lib/bundle/cli/cli.js +1101 -984
- package/lib/bundle/cli/kit-game-templates/multi/dist/src/client/index.js +286 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/index.ts +1 -1
- package/lib/cli/app-bundler.d.ts.map +1 -1
- package/lib/cli/app-bundler.js +60 -8
- package/lib/cli/create.d.ts.map +1 -1
- package/lib/cli/create.js +7 -6
- package/lib/cli/doctor.d.ts.map +1 -1
- package/lib/cli/doctor.js +57 -30
- package/lib/cli/host.d.ts.map +1 -1
- package/lib/cli/host.js +19 -12
- package/lib/cli/init.d.ts.map +1 -1
- package/lib/cli/init.js +20 -17
- package/lib/cli/resource-builder.d.ts.map +1 -1
- package/lib/cli/resource-builder.js +11 -8
- package/lib/cli/theme.d.ts +36 -0
- package/lib/cli/theme.d.ts.map +1 -0
- package/lib/cli/theme.js +41 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/plugins/camera/index.d.ts +3 -0
- package/lib/plugins/camera/index.d.ts.map +1 -0
- package/lib/plugins/camera/index.js +2 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1,27 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./evitcastudio_round_branding.png" width="128" height="128" alt="Evitca Studio Logo" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">@evitcastudio/kit</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A lightweight, extensible framework and developer toolkit for the Vylocity Game Engine.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@evitcastudio/kit"><img src="https://img.shields.io/npm/v/@evitcastudio/kit.svg?color=10b981" alt="npm version" /></a>
|
|
13
|
+
<a href="https://github.com/EvitcaStudio/Kit/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" /></a>
|
|
14
|
+
<a href="https://github.com/EvitcaStudio/Kit"><img src="https://img.shields.io/badge/TypeScript-Ready-3178c6.svg" alt="TypeScript" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Modular Plugin Architecture**: Centralized service locator (`Kit.registerPlugin`, `Kit.getPlugin`) with lifecycle hooks and a decoupled typed event bus (`Kit.on`, `Kit.off`).
|
|
22
|
+
- **Official Plugins Included**:
|
|
23
|
+
- **`Camera` (Lens)**: 5 specialized camera types (`Follow`, `Pan`, `Spectate`, `Influence`, `Transition`), 29 shake presets, smooth zoom, zero-pop transitions, and native 2D canvas debug overlays.
|
|
24
|
+
- **`Network`**: Structured client-server packet communication with registered names and automatic indexing for bandwidth optimization.
|
|
25
|
+
- **Developer CLI (`kit`)**:
|
|
26
|
+
- **`kit init`**: Interactive scaffolding for Singleplayer and Multiplayer game templates.
|
|
27
|
+
- **`kit build`**: Zero-config compilation, asset hashing (`.vyr`), metadata manifest generation, and production minification/obfuscation.
|
|
28
|
+
- **`kit host`**: Built-in local HTTP and game server hosting with hot-reloading and LAN network URLs.
|
|
29
|
+
- **`kit create`**: Instant boilerplate generator for typed plugins.
|
|
30
|
+
- **`kit doctor`**: Comprehensive environment and project health diagnostics.
|
|
31
|
+
- **Smart Asset Pipeline**: Fast hashing, automatic passthrough for subdirectories, and automatic metadata manifest generation (`resource.json`, `bounds.json`, `sizes.json`, `icon-points.json`).
|
|
32
|
+
- **Zero-Config TypeScript**: Powered by Bun for blazing fast bundling, incremental watch mode, and complete type safety.
|
|
33
|
+
|
|
34
|
+
---
|
|
4
35
|
|
|
5
36
|
## Installation
|
|
6
37
|
|
|
7
38
|
```bash
|
|
39
|
+
# Global CLI installation (recommended)
|
|
8
40
|
bun install -g @evitcastudio/kit
|
|
41
|
+
|
|
42
|
+
# Or as a project dependency
|
|
43
|
+
bun add @evitcastudio/kit
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Quickstart
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 1. Initialize a new project
|
|
52
|
+
kit init my-game --single --install
|
|
53
|
+
|
|
54
|
+
# 2. Build game and assets
|
|
55
|
+
cd my-game && kit build
|
|
56
|
+
|
|
57
|
+
# 3. Host locally
|
|
58
|
+
kit host
|
|
9
59
|
```
|
|
10
|
-
|
|
60
|
+
|
|
61
|
+
Your game will immediately be accessible at `http://localhost:8090` (or `http://localhost:30000` for multiplayer).
|
|
62
|
+
|
|
63
|
+
---
|
|
11
64
|
|
|
12
65
|
## CLI Reference & Usage
|
|
13
66
|
|
|
14
|
-
Kit includes
|
|
67
|
+
Kit includes the `kit` CLI for scaffolding, asset compilation, boilerplate generation, and local testing.
|
|
15
68
|
|
|
16
69
|
### Global Options
|
|
17
70
|
- `-v, --verbose`: Enables verbose output and detailed debugging logs.
|
|
18
|
-
- `-h, --help`: Displays help and usage information
|
|
71
|
+
- `-h, --help`: Displays help and usage information.
|
|
19
72
|
- `-V, --version`: Displays the installed Kit CLI version.
|
|
20
73
|
|
|
21
74
|
---
|
|
22
75
|
|
|
23
76
|
### `kit init [name]`
|
|
24
|
-
Initializes a new game project
|
|
77
|
+
Initializes a new game project. Run without arguments for an interactive setup prompt.
|
|
25
78
|
|
|
26
79
|
```bash
|
|
27
80
|
# Interactive setup
|
|
@@ -31,195 +84,224 @@ kit init
|
|
|
31
84
|
kit init my-game --single --install
|
|
32
85
|
```
|
|
33
86
|
|
|
34
|
-
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| `
|
|
38
|
-
| `-
|
|
39
|
-
| `-
|
|
40
|
-
| `-
|
|
41
|
-
| `-i, --install` | `boolean` | `false` | Automatically runs `bun install` inside the new project directory after creation. |
|
|
87
|
+
| Option | Description | Default |
|
|
88
|
+
| :--- | :--- | :--- |
|
|
89
|
+
| `[name]` | Project folder name. | `kit-project` |
|
|
90
|
+
| `-s, --single` | Scaffolds a single-player game template. | `false` |
|
|
91
|
+
| `-m, --multi` | Scaffolds a multiplayer game template. | `false` |
|
|
92
|
+
| `-f, --force` | Overwrites destination folder if it already exists. | `false` |
|
|
93
|
+
| `-i, --install` | Automatically runs `bun install` after scaffolding. | `false` |
|
|
42
94
|
|
|
43
95
|
---
|
|
44
96
|
|
|
45
97
|
### `kit build`
|
|
46
|
-
|
|
98
|
+
Compiles TypeScript application code to `dist/`, hashes raw assets into unique identifiers (`.vyr`), mirrors asset subdirectories, and generates metadata manifests.
|
|
47
99
|
|
|
48
100
|
```bash
|
|
49
|
-
# Zero-config build (auto-detects project architecture
|
|
101
|
+
# Zero-config build (auto-detects project architecture)
|
|
50
102
|
kit build
|
|
51
103
|
|
|
52
|
-
#
|
|
53
|
-
kit build -p
|
|
54
|
-
|
|
55
|
-
# Watch mode: auto-rebuilds on source or resource changes
|
|
104
|
+
# Watch mode (incremental rebuilds on source or resource changes)
|
|
56
105
|
kit build --watch
|
|
57
106
|
|
|
58
|
-
#
|
|
59
|
-
kit build -
|
|
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
|
|
107
|
+
# Production build (minified, obfuscated identifiers, stripped sourcemaps)
|
|
108
|
+
kit build -p
|
|
105
109
|
```
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
| Option | Description | Default |
|
|
112
|
+
| :--- | :--- | :--- |
|
|
113
|
+
| `-i, --in <path>` | Input resource directory containing raw game assets. | `./src/resources` |
|
|
114
|
+
| `-o, --out <path>` | Output directory for processed assets and bundled code. | `./dist` |
|
|
115
|
+
| `-m, --manifest <path>` | Custom destination path for `resource.json`. | `./resource.json` |
|
|
116
|
+
| `-w, --watch` | Watches source and resource folders for auto-rebuilding. | `false` |
|
|
117
|
+
| `-p, --prod` | Production mode (minification, mangled identifiers, no maps). | `false` |
|
|
118
|
+
| `--minify` / `--obfuscate` | Granular syntax minification or identifier mangling. | `false` |
|
|
119
|
+
| `--sourcemap <mode>` | Sourcemap mode (`none`, `linked`, `inline`, `external`). | `linked` |
|
|
120
|
+
| `--app` / `--no-app` | Toggles application code bundling. | `true` |
|
|
121
|
+
|
|
122
|
+
#### Generated Metadata Manifests
|
|
123
|
+
During build, Kit produces optimized metadata indices in your project:
|
|
124
|
+
- **`resource.json`**: Maps original human-readable asset filenames to obfuscated engine identifiers (`uuid.vyr`).
|
|
125
|
+
- **`bounds.json` & `sizes.json`**: Pre-calculated collision boundaries and dimensions for icons and tiles.
|
|
126
|
+
- **`icon-points.json`**: Defined anchor points and equipment attachment coordinates for sprites.
|
|
109
127
|
|
|
110
128
|
---
|
|
111
129
|
|
|
112
130
|
### `kit host`
|
|
113
|
-
Hosts
|
|
131
|
+
Hosts your compiled game project locally for browser or multiplayer testing.
|
|
114
132
|
|
|
115
133
|
```bash
|
|
116
|
-
# Host
|
|
134
|
+
# Host dist folder on default port 8090
|
|
117
135
|
kit host
|
|
118
136
|
|
|
119
137
|
# Build before hosting and specify custom port
|
|
120
138
|
kit host -b -p 8080
|
|
121
139
|
```
|
|
122
140
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
| Option | Description | Default |
|
|
142
|
+
| :--- | :--- | :--- |
|
|
143
|
+
| `-p, --port <number>` | Port to bind the server to. | `8090` |
|
|
144
|
+
| `-d, --dir <path>` | Directory of built files to serve. | `./dist` |
|
|
145
|
+
| `-b, --build` | Runs `kit build` prior to starting server. | `false` |
|
|
127
146
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `kit create <type> <name>`
|
|
150
|
+
Scaffolds typed boilerplate into an existing Kit project.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
kit create plugin Inventory
|
|
154
|
+
```
|
|
155
|
+
Generates `src/plugins/inventory.ts` subclassing `KitPlugin` with lifecycle hooks ready to extend.
|
|
131
156
|
|
|
132
157
|
---
|
|
133
158
|
|
|
134
159
|
### `kit doctor`
|
|
135
|
-
Inspects your local environment and
|
|
160
|
+
Inspects your local environment and project health (Bun runtime, Git availability, `package.json`, project architecture, and build pipeline).
|
|
136
161
|
|
|
137
162
|
```bash
|
|
138
163
|
kit doctor
|
|
139
164
|
```
|
|
140
165
|
|
|
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
166
|
---
|
|
149
167
|
|
|
150
168
|
## Runtime Resource Loading
|
|
151
169
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
`Kit.setResources()` should be called **before** `VYLO.load()`.
|
|
170
|
+
`Kit.setResources()` loads the generated `resource.json` manifest into the Vylocity engine prior to calling `VYLO.load()`:
|
|
155
171
|
|
|
156
172
|
```typescript
|
|
157
173
|
import resourceJSON from 'resource.json';
|
|
158
174
|
|
|
159
|
-
// Initialize
|
|
175
|
+
// Initialize engine with mapped resource identifiers
|
|
160
176
|
await Kit.setResources(resourceJSON);
|
|
177
|
+
await VYLO.load();
|
|
161
178
|
```
|
|
162
179
|
|
|
180
|
+
---
|
|
163
181
|
|
|
164
|
-
##
|
|
182
|
+
## Plugins
|
|
165
183
|
|
|
166
|
-
|
|
184
|
+
Kit features a modular plugin architecture. Plugins register via `Kit.registerPlugin()`, are retrievable globally through `Kit.getPlugin(name)`, and communicate across decoupled systems using Kit's typed event bus.
|
|
167
185
|
|
|
168
|
-
|
|
186
|
+
```typescript
|
|
187
|
+
import { Kit } from '@evitcastudio/kit';
|
|
188
|
+
import { CustomPlugin } from 'custom-plugin';
|
|
169
189
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
// Register with Kit
|
|
191
|
+
const plugin = Kit.registerPlugin(CustomPlugin);
|
|
192
|
+
|
|
193
|
+
// Retrieve anywhere by plugin name
|
|
194
|
+
const plugin = Kit.getPlugin<CustomPlugin>('CustomPlugin');
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### Official Plugins
|
|
200
|
+
|
|
201
|
+
#### 1. Camera Plugin (`Camera` / `@evitcastudio/lens`)
|
|
202
|
+
High-performance 2D camera system powered by [`@evitcastudio/lens`](https://github.com/EvitcaStudio/Lens). Supports 5 specialized camera types, 29 shake presets, smooth zoom, zero-pop transitions, native canvas debug overlays, and automatic event dispatching.
|
|
203
|
+
|
|
204
|
+
##### Setup & Quickstart
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { Kit, Camera } from '@evitcastudio/kit';
|
|
208
|
+
|
|
209
|
+
// 1. Register with Kit (indexes under name 'Camera')
|
|
210
|
+
const camera = Kit.registerPlugin(Camera);
|
|
211
|
+
|
|
212
|
+
// 2. Track player entity with smooth lerping & deadzone
|
|
213
|
+
camera.createFollowCamera('main', playerMob, {
|
|
214
|
+
lerp: 0.1,
|
|
215
|
+
deadzone: { width: 64, height: 64 }
|
|
216
|
+
});
|
|
173
217
|
```
|
|
174
218
|
|
|
175
|
-
|
|
219
|
+
##### Seamless Transitions
|
|
220
|
+
Blend smoothly between cameras or targets with Hermite spline interpolation and spring-damping (zero visual pop):
|
|
176
221
|
|
|
177
|
-
|
|
222
|
+
```typescript
|
|
223
|
+
await camera.switchTo(bossCamera, {
|
|
224
|
+
duration: 800,
|
|
225
|
+
smoothing: 'smoothDamp', // or 'cubicSpline'
|
|
226
|
+
springTension: 170,
|
|
227
|
+
springFriction: 26
|
|
228
|
+
});
|
|
229
|
+
```
|
|
178
230
|
|
|
179
|
-
|
|
180
|
-
|
|
231
|
+
##### Screen Shake & Zoom
|
|
232
|
+
```typescript
|
|
233
|
+
// Trigger built-in presets or infinite ambient shakes
|
|
234
|
+
camera.shakePreset('explosion-large');
|
|
235
|
+
camera.shakePreset('rumble', undefined, true);
|
|
181
236
|
|
|
182
|
-
|
|
183
|
-
|
|
237
|
+
// Smooth zoom animations with 30+ easing equations
|
|
238
|
+
camera.zoom(2, 500, 'easeOutCubic');
|
|
239
|
+
camera.zoom(1, 400, 'easeInOutQuad'); // Reset
|
|
240
|
+
```
|
|
184
241
|
|
|
242
|
+
##### Camera Event Bus
|
|
243
|
+
All camera lifecycle events automatically dispatch to Kit's global event bus (`Kit.on`), allowing audio, gamepad vibration, or UI systems to decouple from camera logic:
|
|
185
244
|
|
|
186
|
-
|
|
245
|
+
```typescript
|
|
246
|
+
Kit.on('Camera', 'shake-start', (event) => {
|
|
247
|
+
console.log('Camera shaking:', event.data.preset);
|
|
248
|
+
});
|
|
187
249
|
|
|
188
|
-
|
|
189
|
-
|
|
250
|
+
Kit.on('Camera', 'transition-start', () => {
|
|
251
|
+
// e.g. animate cinematic bars
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
##### Native Debug Overlay & Gizmos
|
|
256
|
+
Built-in 2D canvas overlay for debugging cameras, bounds, target vectors, and crosshairs:
|
|
190
257
|
|
|
191
|
-
|
|
192
|
-
|
|
258
|
+
```typescript
|
|
259
|
+
camera.setDebugMode({
|
|
260
|
+
enabled: true,
|
|
261
|
+
showCameraMarkers: true,
|
|
262
|
+
showTargetLines: true,
|
|
263
|
+
showBounds: true,
|
|
264
|
+
showCenterCrosshair: true,
|
|
265
|
+
bounds: { minX: 0, maxX: 2000, minY: 0, maxY: 2000 }
|
|
266
|
+
});
|
|
193
267
|
```
|
|
194
268
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
#### 2. Network Plugin (`Network`)
|
|
272
|
+
Handles client-server packet communication with registered packet names, automatic indexing, and minimal bandwidth usage.
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import { Kit, Network } from '@evitcastudio/kit';
|
|
199
276
|
|
|
200
|
-
const
|
|
277
|
+
const network = Kit.registerPlugin(Network);
|
|
201
278
|
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
279
|
+
// Client-side: register server packet definitions & listen
|
|
280
|
+
network.registerPackets(['CHAT_MESSAGE', 'PLAYER_HEAL'] as const);
|
|
281
|
+
|
|
282
|
+
network.on('CHAT_MESSAGE', (client, senderName, message) => {
|
|
283
|
+
console.log(`[${senderName}]: ${message}`);
|
|
284
|
+
});
|
|
205
285
|
```
|
|
206
286
|
|
|
207
|
-
|
|
287
|
+
---
|
|
208
288
|
|
|
209
|
-
|
|
210
|
-
By listening to these events you can act on this data.
|
|
289
|
+
### Plugin Events
|
|
211
290
|
|
|
212
|
-
|
|
213
|
-
const listener = (pEvent: EmitterEvent) => {
|
|
214
|
-
const { data, timestamp } = pEvent;
|
|
215
|
-
// Here you can use the data that the event sent down.
|
|
216
|
-
}
|
|
291
|
+
Plugins can emit and listen to events across the entire application:
|
|
217
292
|
|
|
218
|
-
|
|
219
|
-
|
|
293
|
+
```typescript
|
|
294
|
+
// Listen for an event from any plugin
|
|
295
|
+
Kit.on('plugin-name', 'event-name', (event) => {
|
|
296
|
+
console.log(event.data, event.timestamp);
|
|
297
|
+
});
|
|
220
298
|
|
|
221
|
-
//
|
|
299
|
+
// Remove listener
|
|
222
300
|
Kit.off('plugin-name', 'event-name', listener);
|
|
223
301
|
```
|
|
224
302
|
|
|
225
|
-
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT © [Evitca Studio](https://evitcastudio.com) & [doubleactii](https://github.com/doubleactii)
|