@flare-engine/events 0.4.6 → 0.4.7

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/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/emitter.d.ts
2
1
  /** Unsubscribe function returned by on/once. */
3
2
  type Unsubscribe = () => void;
4
3
  /** Map of event names to handler signatures. */
@@ -14,7 +13,7 @@ type EventMap = Record<string, (...args: never[]) => void>;
14
13
  * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing
15
14
  * handler propagates to the caller but never wedges deferred removal.
16
15
  */
17
- declare class EventEmitter<E extends EventMap> {
16
+ export declare class EventEmitter<E extends EventMap> {
18
17
  private listeners;
19
18
  private emitDepth;
20
19
  private pendingRemove;
@@ -33,8 +32,6 @@ declare class EventEmitter<E extends EventMap> {
33
32
  /** Remove all listeners for a specific event, or all listeners. */
34
33
  removeAll(event?: keyof E): void;
35
34
  }
36
- //#endregion
37
- //#region src/signal.d.ts
38
35
  /**
39
36
  * Lightweight single-event emitter. Less overhead than EventEmitter.
40
37
  *
@@ -46,7 +43,7 @@ declare class EventEmitter<E extends EventMap> {
46
43
  * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing
47
44
  * handler propagates to the caller but never wedges deferred removal.
48
45
  */
49
- declare class Signal<T = void> {
46
+ export declare class Signal<T = void> {
50
47
  private handlers;
51
48
  private emitDepth;
52
49
  private pendingRemove;
@@ -65,6 +62,5 @@ declare class Signal<T = void> {
65
62
  /** Remove all handlers. */
66
63
  clear(): void;
67
64
  }
68
- //#endregion
69
- export { EventEmitter, type EventMap, Signal, type Unsubscribe };
65
+ export type { EventMap, Unsubscribe };
70
66
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"mappings":";;KACY;;KAGA,WAAW,mBAAmB;;;;;;;;;;;;cAa7B,aAAa,UAAU;UAC1B;UACA;UACA;;EAGR,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAahD,KAAK,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAWlD,IAAI,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE;;;;;EAgB5C,KAAK,gBAAgB,GAAG,OAAO,MAAM,MAAM,WAAW,EAAE;UAkBhD;;EAaR,UAAU,cAAc;;;;;;;;;;;;;;;cCjFb,OAAO;UACV;UACA;UACA;;EAGR,IAAI,UAAU,OAAO,aAAa;;EAQlC,KAAK,UAAU,OAAO,aAAa;;EAUnC,OAAO,UAAU,OAAO;;;;;EAYxB,QAAQ,MAAM,uBAAuB,OAAO;UAgBpC;;EAQR"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"mappings":";KACY;;KAGA,WAAW,mBAAmB;;;;;;;;;;;;qBAa7B,aAAa,UAAU;UAC1B;UACA;UACA;;EAGR,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAahD,KAAK,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAWlD,IAAI,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE;;;;;EAgB5C,KAAK,gBAAgB,GAAG,OAAO,MAAM,MAAM,WAAW,EAAE;UAkBhD;;EAaR,UAAU,cAAc;;;;;;;;;;;;;qBCjFb,OAAO;UACV;UACA;UACA;;EAGR,IAAI,UAAU,OAAO,aAAa;;EAQlC,KAAK,UAAU,OAAO,aAAa;;EAUnC,OAAO,UAAU,OAAO;;;;;EAYxB,QAAQ,MAAM,uBAAuB,OAAO;UAgBpC;;EAQR"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/emitter.d.ts
2
1
  /** Unsubscribe function returned by on/once. */
3
2
  type Unsubscribe = () => void;
4
3
  /** Map of event names to handler signatures. */
@@ -14,7 +13,7 @@ type EventMap = Record<string, (...args: never[]) => void>;
14
13
  * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing
15
14
  * handler propagates to the caller but never wedges deferred removal.
16
15
  */
17
- declare class EventEmitter<E extends EventMap> {
16
+ export declare class EventEmitter<E extends EventMap> {
18
17
  private listeners;
19
18
  private emitDepth;
20
19
  private pendingRemove;
@@ -33,8 +32,6 @@ declare class EventEmitter<E extends EventMap> {
33
32
  /** Remove all listeners for a specific event, or all listeners. */
34
33
  removeAll(event?: keyof E): void;
35
34
  }
36
- //#endregion
37
- //#region src/signal.d.ts
38
35
  /**
39
36
  * Lightweight single-event emitter. Less overhead than EventEmitter.
40
37
  *
@@ -46,7 +43,7 @@ declare class EventEmitter<E extends EventMap> {
46
43
  * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing
47
44
  * handler propagates to the caller but never wedges deferred removal.
48
45
  */
49
- declare class Signal<T = void> {
46
+ export declare class Signal<T = void> {
50
47
  private handlers;
51
48
  private emitDepth;
52
49
  private pendingRemove;
@@ -65,6 +62,5 @@ declare class Signal<T = void> {
65
62
  /** Remove all handlers. */
66
63
  clear(): void;
67
64
  }
68
- //#endregion
69
- export { EventEmitter, type EventMap, Signal, type Unsubscribe };
65
+ export type { EventMap, Unsubscribe };
70
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"mappings":";;KACY;;KAGA,WAAW,mBAAmB;;;;;;;;;;;;cAa7B,aAAa,UAAU;UAC1B;UACA;UACA;;EAGR,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAahD,KAAK,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAWlD,IAAI,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE;;;;;EAgB5C,KAAK,gBAAgB,GAAG,OAAO,MAAM,MAAM,WAAW,EAAE;UAkBhD;;EAaR,UAAU,cAAc;;;;;;;;;;;;;;;cCjFb,OAAO;UACV;UACA;UACA;;EAGR,IAAI,UAAU,OAAO,aAAa;;EAQlC,KAAK,UAAU,OAAO,aAAa;;EAUnC,OAAO,UAAU,OAAO;;;;;EAYxB,QAAQ,MAAM,uBAAuB,OAAO;UAgBpC;;EAQR"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"mappings":";KACY;;KAGA,WAAW,mBAAmB;;;;;;;;;;;;qBAa7B,aAAa,UAAU;UAC1B;UACA;UACA;;EAGR,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAahD,KAAK,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE,KAAK;;EAWlD,IAAI,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAAE;;;;;EAgB5C,KAAK,gBAAgB,GAAG,OAAO,MAAM,MAAM,WAAW,EAAE;UAkBhD;;EAaR,UAAU,cAAc;;;;;;;;;;;;;qBCjFb,OAAO;UACV;UACA;UACA;;EAGR,IAAI,UAAU,OAAO,aAAa;;EAQlC,KAAK,UAAU,OAAO,aAAa;;EAUnC,OAAO,UAAU,OAAO;;;;;EAYxB,QAAQ,MAAM,uBAAuB,OAAO;UAgBpC;;EAQR"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/emitter.ts
2
+ // src/emitter.ts
3
3
  /**
4
4
  * Type-safe event emitter.
5
5
  *
@@ -87,8 +87,7 @@ var EventEmitter = class {
87
87
  this.pendingRemove.length = 0;
88
88
  }
89
89
  };
90
- //#endregion
91
- //#region src/signal.ts
90
+ // src/signal.ts
92
91
  /**
93
92
  * Lightweight single-event emitter. Less overhead than EventEmitter.
94
93
  *
@@ -149,7 +148,6 @@ var Signal = class {
149
148
  this.pendingRemove.length = 0;
150
149
  }
151
150
  };
152
- //#endregion
153
151
  exports.EventEmitter = EventEmitter;
154
152
  exports.Signal = Signal;
155
153
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"sourcesContent":["/** Unsubscribe function returned by on/once. */\nexport type Unsubscribe = () => void;\n\n/** Map of event names to handler signatures. */\nexport type EventMap = Record<string, (...args: never[]) => void>;\n\n/**\n * Type-safe event emitter.\n *\n * Emit semantics (shared with Signal):\n * - A handler **added** during an emit runs in that **same** emit — the listener\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class EventEmitter<E extends EventMap> {\n private listeners = new Map<keyof E, Set<E[keyof E]>>();\n private emitDepth = 0;\n private pendingRemove: Array<{ event: keyof E; handler: E[keyof E] }> = [];\n\n /** Subscribe to an event. Returns unsubscribe function. */\n on<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(handler);\n return () => {\n this.off(event, handler);\n };\n }\n\n /** Subscribe to an event once. Returns unsubscribe function. */\n once<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n const wrapper = ((...args: never[]) => {\n unsub();\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }) as E[K];\n const unsub = this.on(event, wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n off<K extends keyof E>(event: K, handler: E[K]): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push({ event, handler });\n return;\n }\n const set = this.listeners.get(event);\n if (set) {\n set.delete(handler);\n if (set.size === 0) this.listeners.delete(event);\n }\n }\n\n /**\n * Emit an event to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n this.emitDepth++;\n try {\n for (const handler of set) {\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n const { event: ev, handler: h } = this.pendingRemove[i]!;\n const s = this.listeners.get(ev);\n if (s) {\n s.delete(h);\n if (s.size === 0) this.listeners.delete(ev);\n }\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all listeners for a specific event, or all listeners. */\n removeAll(event?: keyof E): void {\n if (event !== undefined) {\n this.listeners.delete(event);\n // Don't clear the shared pendingRemove here: mid-emit it may hold deferred\n // removals for OTHER events. Entries for this event become harmless no-ops\n // at flush (their Set is already gone).\n return;\n }\n this.listeners.clear();\n this.pendingRemove.length = 0;\n }\n}\n","import type { Unsubscribe } from './emitter.js';\n\n/**\n * Lightweight single-event emitter. Less overhead than EventEmitter.\n *\n * Emit semantics (shared with EventEmitter):\n * - A handler **added** during an emit runs in that **same** emit — the handler\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class Signal<T = void> {\n private handlers = new Set<(value: T) => void>();\n private emitDepth = 0;\n private pendingRemove: Array<(value: T) => void> = [];\n\n /** Subscribe to the signal. Returns unsubscribe function. */\n add(handler: (value: T) => void): Unsubscribe {\n this.handlers.add(handler);\n return () => {\n this.remove(handler);\n };\n }\n\n /** Subscribe once. Returns unsubscribe function. */\n once(handler: (value: T) => void): Unsubscribe {\n const wrapper = (value: T) => {\n unsub();\n handler(value);\n };\n const unsub = this.add(wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n remove(handler: (value: T) => void): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push(handler);\n } else {\n this.handlers.delete(handler);\n }\n }\n\n /**\n * Emit a value to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit(...args: T extends void ? [] : [value: T]): void {\n const value = args[0] as T;\n this.emitDepth++;\n try {\n for (const handler of this.handlers) {\n handler(value);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n this.handlers.delete(this.pendingRemove[i]!);\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all handlers. */\n clear(): void {\n this.handlers.clear();\n this.pendingRemove.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAa,eAAb,MAA8C;CAC5C,4BAAoB,IAAI,IAA8B;CACtD,YAAoB;CACpB,gBAAwE,CAAC;;CAGzE,GAAsB,OAAU,SAA4B;EAC1D,IAAI,MAAM,KAAK,UAAU,IAAI,KAAK;EAClC,IAAI,CAAC,KAAK;GACR,sBAAM,IAAI,IAAI;GACd,KAAK,UAAU,IAAI,OAAO,GAAG;EAC/B;EACA,IAAI,IAAI,OAAO;EACf,aAAa;GACX,KAAK,IAAI,OAAO,OAAO;EACzB;CACF;;CAGA,KAAwB,OAAU,SAA4B;EAC5D,MAAM,YAAY,GAAG,SAAkB;GACrC,MAAM;GAEN,QAAsB,GAAG,IAAI;EAC/B;EACA,MAAM,QAAQ,KAAK,GAAG,OAAO,OAAO;EACpC,OAAO;CACT;;CAGA,IAAuB,OAAU,SAAqB;EACpD,IAAI,KAAK,YAAY,GAAG;GACtB,KAAK,cAAc,KAAK;IAAE;IAAO;GAAQ,CAAC;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;CACT;;CAGA,OAAO,SAAmC;EACxC,IAAI,KAAK,YAAY,GACnB,KAAK,cAAc,KAAK,OAAO;OAE/B,KAAK,SAAS,OAAO,OAAO;CAEhC;;;;;CAMA,KAAK,GAAG,MAA8C;EACpD,MAAM,QAAQ,KAAK;EACnB,KAAK;EACL,IAAI;GACF,KAAK,MAAM,WAAW,KAAK,UACzB,QAAQ,KAAK;EAEjB,UAAU;GACR,KAAK;GAEL,IAAI,KAAK,cAAc,KAAK,KAAK,cAAc,SAAS,GACtD,KAAK,aAAa;EAEtB;CACF;CAEA,eAA6B;EAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ,KAC7C,KAAK,SAAS,OAAO,KAAK,cAAc,EAAG;EAE7C,KAAK,cAAc,SAAS;CAC9B;;CAGA,QAAc;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,cAAc,SAAS;CAC9B;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"sourcesContent":["/** Unsubscribe function returned by on/once. */\nexport type Unsubscribe = () => void;\n\n/** Map of event names to handler signatures. */\nexport type EventMap = Record<string, (...args: never[]) => void>;\n\n/**\n * Type-safe event emitter.\n *\n * Emit semantics (shared with Signal):\n * - A handler **added** during an emit runs in that **same** emit — the listener\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class EventEmitter<E extends EventMap> {\n private listeners = new Map<keyof E, Set<E[keyof E]>>();\n private emitDepth = 0;\n private pendingRemove: Array<{ event: keyof E; handler: E[keyof E] }> = [];\n\n /** Subscribe to an event. Returns unsubscribe function. */\n on<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(handler);\n return () => {\n this.off(event, handler);\n };\n }\n\n /** Subscribe to an event once. Returns unsubscribe function. */\n once<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n const wrapper = ((...args: never[]) => {\n unsub();\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }) as E[K];\n const unsub = this.on(event, wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n off<K extends keyof E>(event: K, handler: E[K]): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push({ event, handler });\n return;\n }\n const set = this.listeners.get(event);\n if (set) {\n set.delete(handler);\n if (set.size === 0) this.listeners.delete(event);\n }\n }\n\n /**\n * Emit an event to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n this.emitDepth++;\n try {\n for (const handler of set) {\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n const { event: ev, handler: h } = this.pendingRemove[i]!;\n const s = this.listeners.get(ev);\n if (s) {\n s.delete(h);\n if (s.size === 0) this.listeners.delete(ev);\n }\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all listeners for a specific event, or all listeners. */\n removeAll(event?: keyof E): void {\n if (event !== undefined) {\n this.listeners.delete(event);\n // Don't clear the shared pendingRemove here: mid-emit it may hold deferred\n // removals for OTHER events. Entries for this event become harmless no-ops\n // at flush (their Set is already gone).\n return;\n }\n this.listeners.clear();\n this.pendingRemove.length = 0;\n }\n}\n","import type { Unsubscribe } from './emitter.js';\n\n/**\n * Lightweight single-event emitter. Less overhead than EventEmitter.\n *\n * Emit semantics (shared with EventEmitter):\n * - A handler **added** during an emit runs in that **same** emit — the handler\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class Signal<T = void> {\n private handlers = new Set<(value: T) => void>();\n private emitDepth = 0;\n private pendingRemove: Array<(value: T) => void> = [];\n\n /** Subscribe to the signal. Returns unsubscribe function. */\n add(handler: (value: T) => void): Unsubscribe {\n this.handlers.add(handler);\n return () => {\n this.remove(handler);\n };\n }\n\n /** Subscribe once. Returns unsubscribe function. */\n once(handler: (value: T) => void): Unsubscribe {\n const wrapper = (value: T) => {\n unsub();\n handler(value);\n };\n const unsub = this.add(wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n remove(handler: (value: T) => void): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push(handler);\n } else {\n this.handlers.delete(handler);\n }\n }\n\n /**\n * Emit a value to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit(...args: T extends void ? [] : [value: T]): void {\n const value = args[0] as T;\n this.emitDepth++;\n try {\n for (const handler of this.handlers) {\n handler(value);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n this.handlers.delete(this.pendingRemove[i]!);\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all handlers. */\n clear(): void {\n this.handlers.clear();\n this.pendingRemove.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAa,eAAb,MAA8C;CAC5C,4BAAoB,IAAI,IAA8B;CACtD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@ var EventEmitter = class {
86
86
  this.pendingRemove.length = 0;
87
87
  }
88
88
  };
89
- //#endregion
90
- //#region src/signal.ts
89
+ // src/signal.ts
91
90
  /**
92
91
  * Lightweight single-event emitter. Less overhead than EventEmitter.
93
92
  *
@@ -148,7 +147,6 @@ var Signal = class {
148
147
  this.pendingRemove.length = 0;
149
148
  }
150
149
  };
151
- //#endregion
152
150
  export { EventEmitter, Signal };
153
151
 
154
152
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"sourcesContent":["/** Unsubscribe function returned by on/once. */\nexport type Unsubscribe = () => void;\n\n/** Map of event names to handler signatures. */\nexport type EventMap = Record<string, (...args: never[]) => void>;\n\n/**\n * Type-safe event emitter.\n *\n * Emit semantics (shared with Signal):\n * - A handler **added** during an emit runs in that **same** emit — the listener\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class EventEmitter<E extends EventMap> {\n private listeners = new Map<keyof E, Set<E[keyof E]>>();\n private emitDepth = 0;\n private pendingRemove: Array<{ event: keyof E; handler: E[keyof E] }> = [];\n\n /** Subscribe to an event. Returns unsubscribe function. */\n on<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(handler);\n return () => {\n this.off(event, handler);\n };\n }\n\n /** Subscribe to an event once. Returns unsubscribe function. */\n once<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n const wrapper = ((...args: never[]) => {\n unsub();\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }) as E[K];\n const unsub = this.on(event, wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n off<K extends keyof E>(event: K, handler: E[K]): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push({ event, handler });\n return;\n }\n const set = this.listeners.get(event);\n if (set) {\n set.delete(handler);\n if (set.size === 0) this.listeners.delete(event);\n }\n }\n\n /**\n * Emit an event to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n this.emitDepth++;\n try {\n for (const handler of set) {\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n const { event: ev, handler: h } = this.pendingRemove[i]!;\n const s = this.listeners.get(ev);\n if (s) {\n s.delete(h);\n if (s.size === 0) this.listeners.delete(ev);\n }\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all listeners for a specific event, or all listeners. */\n removeAll(event?: keyof E): void {\n if (event !== undefined) {\n this.listeners.delete(event);\n // Don't clear the shared pendingRemove here: mid-emit it may hold deferred\n // removals for OTHER events. Entries for this event become harmless no-ops\n // at flush (their Set is already gone).\n return;\n }\n this.listeners.clear();\n this.pendingRemove.length = 0;\n }\n}\n","import type { Unsubscribe } from './emitter.js';\n\n/**\n * Lightweight single-event emitter. Less overhead than EventEmitter.\n *\n * Emit semantics (shared with EventEmitter):\n * - A handler **added** during an emit runs in that **same** emit — the handler\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class Signal<T = void> {\n private handlers = new Set<(value: T) => void>();\n private emitDepth = 0;\n private pendingRemove: Array<(value: T) => void> = [];\n\n /** Subscribe to the signal. Returns unsubscribe function. */\n add(handler: (value: T) => void): Unsubscribe {\n this.handlers.add(handler);\n return () => {\n this.remove(handler);\n };\n }\n\n /** Subscribe once. Returns unsubscribe function. */\n once(handler: (value: T) => void): Unsubscribe {\n const wrapper = (value: T) => {\n unsub();\n handler(value);\n };\n const unsub = this.add(wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n remove(handler: (value: T) => void): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push(handler);\n } else {\n this.handlers.delete(handler);\n }\n }\n\n /**\n * Emit a value to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit(...args: T extends void ? [] : [value: T]): void {\n const value = args[0] as T;\n this.emitDepth++;\n try {\n for (const handler of this.handlers) {\n handler(value);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n this.handlers.delete(this.pendingRemove[i]!);\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all handlers. */\n clear(): void {\n this.handlers.clear();\n this.pendingRemove.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAa,eAAb,MAA8C;CAC5C,4BAAoB,IAAI,IAA8B;CACtD,YAAoB;CACpB,gBAAwE,CAAC;;CAGzE,GAAsB,OAAU,SAA4B;EAC1D,IAAI,MAAM,KAAK,UAAU,IAAI,KAAK;EAClC,IAAI,CAAC,KAAK;GACR,sBAAM,IAAI,IAAI;GACd,KAAK,UAAU,IAAI,OAAO,GAAG;EAC/B;EACA,IAAI,IAAI,OAAO;EACf,aAAa;GACX,KAAK,IAAI,OAAO,OAAO;EACzB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IAAI,IAAwB;CAC/C,YAAoB;CACpB,gBAAmD,CAAC;;CAGpD,IAAI,SAA0C;EAC5C,KAAK,SAAS,IAAI,OAAO;EACzB,aAAa;GACX,KAAK,OAAO,OAAO;EACrB;CACF;;CAGA,KAAK,SAA0C;EAC7C,MAAM,WAAW,UAAa;GAC5B,MAAM;GACN,QAAQ,KAAK;EACf;EACA,MAAM,QAAQ,KAAK,IAAI,OAAO;EAC9B,OAAO;CACT;;CAGA,OAAO,SAAmC;EACxC,IAAI,KAAK,YAAY,GACnB,KAAK,cAAc,KAAK,OAAO;OAE/B,KAAK,SAAS,OAAO,OAAO;CAEhC;;;;;CAMA,KAAK,GAAG,MAA8C;EACpD,MAAM,QAAQ,KAAK;EACnB,KAAK;EACL,IAAI;GACF,KAAK,MAAM,WAAW,KAAK,UACzB,QAAQ,KAAK;EAEjB,UAAU;GACR,KAAK;GAEL,IAAI,KAAK,cAAc,KAAK,KAAK,cAAc,SAAS,GACtD,KAAK,aAAa;EAEtB;CACF;CAEA,eAA6B;EAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ,KAC7C,KAAK,SAAS,OAAO,KAAK,cAAc,EAAG;EAE7C,KAAK,cAAc,SAAS;CAC9B;;CAGA,QAAc;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,cAAc,SAAS;CAC9B;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/emitter.ts","../src/signal.ts"],"sourcesContent":["/** Unsubscribe function returned by on/once. */\nexport type Unsubscribe = () => void;\n\n/** Map of event names to handler signatures. */\nexport type EventMap = Record<string, (...args: never[]) => void>;\n\n/**\n * Type-safe event emitter.\n *\n * Emit semantics (shared with Signal):\n * - A handler **added** during an emit runs in that **same** emit — the listener\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class EventEmitter<E extends EventMap> {\n private listeners = new Map<keyof E, Set<E[keyof E]>>();\n private emitDepth = 0;\n private pendingRemove: Array<{ event: keyof E; handler: E[keyof E] }> = [];\n\n /** Subscribe to an event. Returns unsubscribe function. */\n on<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(handler);\n return () => {\n this.off(event, handler);\n };\n }\n\n /** Subscribe to an event once. Returns unsubscribe function. */\n once<K extends keyof E>(event: K, handler: E[K]): Unsubscribe {\n const wrapper = ((...args: never[]) => {\n unsub();\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }) as E[K];\n const unsub = this.on(event, wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n off<K extends keyof E>(event: K, handler: E[K]): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push({ event, handler });\n return;\n }\n const set = this.listeners.get(event);\n if (set) {\n set.delete(handler);\n if (set.size === 0) this.listeners.delete(event);\n }\n }\n\n /**\n * Emit an event to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n this.emitDepth++;\n try {\n for (const handler of set) {\n // biome-ignore lint/complexity/noBannedTypes: generic handler call\n (handler as Function)(...args);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n const { event: ev, handler: h } = this.pendingRemove[i]!;\n const s = this.listeners.get(ev);\n if (s) {\n s.delete(h);\n if (s.size === 0) this.listeners.delete(ev);\n }\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all listeners for a specific event, or all listeners. */\n removeAll(event?: keyof E): void {\n if (event !== undefined) {\n this.listeners.delete(event);\n // Don't clear the shared pendingRemove here: mid-emit it may hold deferred\n // removals for OTHER events. Entries for this event become harmless no-ops\n // at flush (their Set is already gone).\n return;\n }\n this.listeners.clear();\n this.pendingRemove.length = 0;\n }\n}\n","import type { Unsubscribe } from './emitter.js';\n\n/**\n * Lightweight single-event emitter. Less overhead than EventEmitter.\n *\n * Emit semantics (shared with EventEmitter):\n * - A handler **added** during an emit runs in that **same** emit — the handler\n * set is iterated live (no per-emit snapshot allocation).\n * - A handler **removed** during an emit still runs for that emit (and any nested\n * emit); the removal takes effect once the outermost emit completes.\n * - `emit` is re-entrant (a handler may emit again) and throw-safe: a throwing\n * handler propagates to the caller but never wedges deferred removal.\n */\nexport class Signal<T = void> {\n private handlers = new Set<(value: T) => void>();\n private emitDepth = 0;\n private pendingRemove: Array<(value: T) => void> = [];\n\n /** Subscribe to the signal. Returns unsubscribe function. */\n add(handler: (value: T) => void): Unsubscribe {\n this.handlers.add(handler);\n return () => {\n this.remove(handler);\n };\n }\n\n /** Subscribe once. Returns unsubscribe function. */\n once(handler: (value: T) => void): Unsubscribe {\n const wrapper = (value: T) => {\n unsub();\n handler(value);\n };\n const unsub = this.add(wrapper);\n return unsub;\n }\n\n /** Unsubscribe a specific handler. Deferred to the outermost emit if called during one. */\n remove(handler: (value: T) => void): void {\n if (this.emitDepth > 0) {\n this.pendingRemove.push(handler);\n } else {\n this.handlers.delete(handler);\n }\n }\n\n /**\n * Emit a value to all subscribers. Zero-alloc on the hot path; re-entrant and\n * throw-safe (see the class docstring for the add/remove-during-emit semantics).\n */\n emit(...args: T extends void ? [] : [value: T]): void {\n const value = args[0] as T;\n this.emitDepth++;\n try {\n for (const handler of this.handlers) {\n handler(value);\n }\n } finally {\n this.emitDepth--;\n // Flush deferred removes only when the outermost emit has unwound (rare path).\n if (this.emitDepth === 0 && this.pendingRemove.length > 0) {\n this.flushPending();\n }\n }\n }\n\n private flushPending(): void {\n for (let i = 0; i < this.pendingRemove.length; i++) {\n this.handlers.delete(this.pendingRemove[i]!);\n }\n this.pendingRemove.length = 0;\n }\n\n /** Remove all handlers. */\n clear(): void {\n this.handlers.clear();\n this.pendingRemove.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAa,eAAb,MAA8C;CAC5C,4BAAoB,IAAI,IAA8B;CACtD,YAAoB;CACpB,gBAAwE,CAAC;;CAGzE,GAAsB,OAAU,SAA4B;EAC1D,IAAI,MAAM,KAAK,UAAU,IAAI,KAAK;EAClC,IAAI,CAAC,KAAK;GACR,sBAAM,IAAI,IAAI;GACd,KAAK,UAAU,IAAI,OAAO,GAAG;EAC/B;EACA,IAAI,IAAI,OAAO;EACf,aAAa;GACX,KAAK,IAAI,OAAO,OAAO;EACzB;CACF;;CAGA,KAAwB,OAAU,SAA4B;EAC5D,MAAM,YAAY,GAAG,SAAkB;GACrC,MAAM;GAEN,QAAsB,GAAG,IAAI;EAC/B;EACA,MAAM,QAAQ,KAAK,GAAG,OAAO,OAAO;EACpC,OAAO;CACT;;CAGA,IAAuB,OAAU,SAAqB;EACpD,IAAI,KAAK,YAAY,GAAG;GACtB,KAAK,cAAc,KAAK;IAAE;IAAO;GAAQ,CAAC;GAC1C;EACF;EACA,MAAM,MAAM,KAAK,UAAU,IAAI,KAAK;EACpC,IAAI,KAAK;GACP,IAAI,OAAO,OAAO;GAClB,IAAI,IAAI,SAAS,GAAG,KAAK,UAAU,OAAO,KAAK;EACjD;CACF;;;;;CAMA,KAAwB,OAAU,GAAG,MAA8B;EACjE,MAAM,MAAM,KAAK,UAAU,IAAI,KAAK;EACpC,IAAI,CAAC,KAAK;EACV,KAAK;EACL,IAAI;GACF,KAAK,MAAM,WAAW,KAEpB,QAAsB,GAAG,IAAI;EAEjC,UAAU;GACR,KAAK;GAEL,IAAI,KAAK,cAAc,KAAK,KAAK,cAAc,SAAS,GACtD,KAAK,a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C7C,KAAK,SAAS,OAAO,KAAK,cAAc,EAAG;EAE7C,KAAK,cAAc,SAAS;CAC9B;;CAGA,QAAc;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,cAAc,SAAS;CAC9B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/events",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Type-safe EventEmitter and Signal",
5
5
  "keywords": ["flare-engine", "events", "signal", "emitter"],
6
6
  "license": "Apache-2.0",