@evitcastudio/kit 2.2.0 → 2.3.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 (49) hide show
  1. package/README.md +76 -13
  2. package/lib/bundle/cli/cli.js +14 -3
  3. package/lib/bundle/cli/kit-game-templates/multi/README.md +3 -13
  4. package/lib/bundle/cli/kit-game-templates/multi/package.json +4 -3
  5. package/lib/bundle/cli/kit-game-templates/multi/src/server/settings.json +1 -1
  6. package/lib/bundle/cli/kit-game-templates/single/README.md +3 -13
  7. package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +2 -1
  8. package/lib/bundle/cli/kit-game-templates/single/package.json +3 -3
  9. package/lib/cli/init.d.ts.map +1 -0
  10. package/lib/{src/cli → cli}/init.js +14 -0
  11. package/lib/cli/main.d.ts +5 -0
  12. package/lib/cli/main.d.ts.map +1 -1
  13. package/lib/cli/main.js +7 -0
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/plugins/network/index.d.ts +7 -0
  17. package/lib/plugins/network/index.d.ts.map +1 -1
  18. package/lib/plugins/network/index.js +18 -5
  19. package/package.json +1 -1
  20. package/lib/package.json +0 -72
  21. package/lib/src/cli/init.d.ts.map +0 -1
  22. package/lib/src/cli/main.d.ts +0 -13
  23. package/lib/src/cli/main.d.ts.map +0 -1
  24. package/lib/src/cli/main.js +0 -16
  25. package/lib/src/cli/resource-builder.d.ts +0 -6
  26. package/lib/src/cli/resource-builder.d.ts.map +0 -1
  27. package/lib/src/cli/resource-builder.js +0 -191
  28. package/lib/src/cli/types.d.ts +0 -11
  29. package/lib/src/cli/types.d.ts.map +0 -1
  30. package/lib/src/cli/types.js +0 -1
  31. package/lib/src/events/event-system.d.ts +0 -13
  32. package/lib/src/events/event-system.d.ts.map +0 -1
  33. package/lib/src/events/event-system.js +0 -25
  34. package/lib/src/index.d.ts +0 -8
  35. package/lib/src/index.d.ts.map +0 -1
  36. package/lib/src/index.js +0 -5
  37. package/lib/src/kit.d.ts +0 -67
  38. package/lib/src/kit.d.ts.map +0 -1
  39. package/lib/src/kit.js +0 -158
  40. package/lib/src/plugins/kit-plugin.d.ts +0 -27
  41. package/lib/src/plugins/kit-plugin.d.ts.map +0 -1
  42. package/lib/src/plugins/kit-plugin.js +0 -24
  43. package/lib/src/plugins/network/index.d.ts +0 -55
  44. package/lib/src/plugins/network/index.d.ts.map +0 -1
  45. package/lib/src/plugins/network/index.js +0 -101
  46. package/lib/src/types/shared-types.d.ts +0 -30
  47. package/lib/src/types/shared-types.d.ts.map +0 -1
  48. package/lib/src/types/shared-types.js +0 -1
  49. /package/lib/{src/cli → cli}/init.d.ts +0 -0
@@ -1,101 +0,0 @@
1
- import { KitPlugin } from '../kit-plugin';
2
- export class Network extends KitPlugin {
3
- name = 'Network';
4
- /**
5
- * If this plugin is initiated.
6
- */
7
- initiated = false;
8
- /**
9
- * The packets that this plugin has registered. It is in the format of name: index
10
- */
11
- packets = new Map();
12
- /**
13
- * The packets that this plugin has registered. It is in the format of index: name
14
- */
15
- reversedPacketMap = new Map();
16
- onRegistered() {
17
- this.initiated = true;
18
- }
19
- /**
20
- * The listeners that are registered.
21
- */
22
- listeners = new Map();
23
- /**
24
- * Register a listener for a packet.
25
- * @param pPacketName - The name of the packet that will be listened to.
26
- * @param pListener - The listener that will be called when the packet is received.
27
- */
28
- onPacket(pPacketName, pListener) {
29
- if (!this.packets.has(pPacketName)) {
30
- throw new Error(`Packet name '${pPacketName}' is not registered.`);
31
- }
32
- this.listeners.set(pPacketName, pListener);
33
- }
34
- /**
35
- * Register a listener for a packet.
36
- * @deprecated Use `onPacket` instead.
37
- * @param pPacketName - The name of the packet that will be listened to.
38
- * @param pListener - The listener that will be called when the packet is received.
39
- */
40
- on(pPacketName, pListener) {
41
- this.onPacket(pPacketName, pListener);
42
- }
43
- /**
44
- * API for receiving data from the server.
45
- * @param pClient - The client involved with this packet.
46
- * @param pPacketName - The name of the packet that was sent.
47
- * @param pData - The data that was sent.
48
- * @param [pVerbose] - If the plugin should log packets.
49
- */
50
- onNetwork(pClient, pPacketName, pData = [], pVerbose) {
51
- if (!this.initiated)
52
- return;
53
- if (typeof pPacketName === 'number') {
54
- const packetName = this.reversedPacketMap.get(pPacketName);
55
- if (!packetName) {
56
- if (pVerbose) {
57
- console.group(`Kit.${this.name}Plugin.onNetwork`);
58
- console.warn(`Unknown packet index: ${pPacketName}`);
59
- console.groupEnd();
60
- }
61
- return;
62
- }
63
- const listener = this.listeners.get(packetName);
64
- if (pVerbose) {
65
- console.group(`Kit.${this.name}Plugin.onNetwork`);
66
- if (!listener) {
67
- console.warn(`No listener was registered for this packet: ${packetName}`);
68
- }
69
- console.log(`Packet name: ${pPacketName}`);
70
- console.log(`Resolved packet name: ${packetName}`);
71
- console.log(`Data:`, pData);
72
- console.groupEnd();
73
- }
74
- listener?.(pClient, ...pData);
75
- }
76
- }
77
- /**
78
- * Register the packets registry.
79
- * @param pPackets - An array of strings that represent the packet names.
80
- */
81
- registerPackets(pPackets) {
82
- this.packets.clear();
83
- this.reversedPacketMap.clear();
84
- pPackets.forEach((name, index) => {
85
- this.packets.set(name, index);
86
- this.reversedPacketMap.set(index, name);
87
- });
88
- }
89
- /**
90
- * Gets the index of a packet.
91
- * @param pPacketName - The name of the packet.
92
- */
93
- getPacket(pPacketName) {
94
- const packet = this.packets.get(pPacketName);
95
- if (packet === undefined) {
96
- console.warn(`Packet '${pPacketName}' is not registered.`);
97
- }
98
- ;
99
- return packet;
100
- }
101
- }
@@ -1,30 +0,0 @@
1
- import type { KitPlugin } from '../plugins/kit-plugin';
2
- import type { VyloType } from './vylo.d.ts';
3
- /**
4
- * The EmitterEvent type is used to define the shape of the data that is passed to the event listeners.
5
- */
6
- type EmitterEvent = {
7
- /**
8
- * The event name, e.g., "draw-frame".
9
- */
10
- event: string;
11
- /**
12
- * The data associated with the event.
13
- */
14
- data?: Record<string, unknown>;
15
- [key: string]: unknown;
16
- };
17
- type ResourceData = {
18
- resourceIdentifier: string;
19
- fileName: string;
20
- };
21
- type Listener = (pData: EmitterEvent) => void;
22
- type KitPluginConstructor<T extends KitPlugin> = new () => T;
23
- declare global {
24
- /**
25
- * The Vylocity engine.
26
- */
27
- var VYLO: VyloType;
28
- }
29
- export type { EmitterEvent, ResourceData, Listener, KitPluginConstructor };
30
- //# sourceMappingURL=shared-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared-types.d.ts","sourceRoot":"","sources":["../../../src/types/shared-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C;;GAEG;AACH,KAAK,YAAY,GAAG;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAA;AAED,KAAK,YAAY,GAAG;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAC;AAEF,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAE9C,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,IAAI,UAAU,CAAC,CAAC;AAC7D,OAAO,CAAC,MAAM,CAAC;IACX;;OAEG;IAEH,IAAI,IAAI,EAAE,QAAQ,CAAC;CACtB;AAED,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- export {};
File without changes