tgui-core 5.5.1 → 5.5.2

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.
@@ -3,9 +3,6 @@
3
3
  *
4
4
  * Handles different event messages from byond and TGUI.
5
5
  *
6
- * Don't fret! This is a simple class under the hood. Using some typescript-fu,
7
- * it's able to provide type safety for the event types and their payloads.
8
- *
9
6
  * The philosophy: This interacts directly with state managers in vanilla JS,
10
7
  * offering a way to handle browser events. UIs then subscribe to these states
11
8
  * and update accordingly.
@@ -58,12 +55,14 @@
58
55
  * } as const;
59
56
  *
60
57
  */
61
- export declare class EventBus<TListeners extends Readonly<Record<string, (payload: unknown) => void>>> {
58
+ export declare class EventBus<TListeners extends ListenerMap> {
62
59
  private listeners;
63
60
  constructor(initialListeners: TListeners);
64
61
  /** Dispatch a message to the appropriate listener. */
65
- dispatch<TType extends keyof TListeners>(message: {
66
- type: TType;
67
- payload?: Parameters<TListeners[TType]>[0];
68
- }): void;
62
+ dispatch(message: Message): void;
69
63
  }
64
+ export type ListenerMap = Record<string, (payload?: unknown) => void>;
65
+ export type Message = {
66
+ type: string;
67
+ payload?: unknown;
68
+ };
@@ -1 +1 @@
1
- class s{listeners={};constructor(s){this.listeners=s}dispatch(s){this.listeners[s.type]?.(s.payload)}}export{s as EventBus};
1
+ class s{listeners;constructor(s){this.listeners=s}dispatch(s){let t=this.listeners[s.type];"payload"in s?t(s.payload):t()}}export{s as EventBus};
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "test": "bun test"
68
68
  },
69
69
  "type": "module",
70
- "version": "5.5.1"
70
+ "version": "5.5.2"
71
71
  }