Skip to content

Releases: maxherrmann/jaset

2.0.0

23 Jun 19:46

Choose a tag to compare

🚨 Breaking changes

Stricter type checking

emit() and dispatchEvent() are now strictly typed to the provided EventMap. Dispatching an event whose type or shape is not declared in the EventMap now throws a TypeScript error. Previously any Event was accepted.

Improved muting behavior

Muting is now independent of listeners and persists when a type has no listeners. mute("*") now mutes all current and future events, including types with no listeners yet. mute("*") also no longer populates mutedEventTypes.

Clearing event listeners

clear() no longer accepts an options parameter. It now removes all listeners for a type regardless of the options they were added with.

🚀 Features

Options support for wildcard event type

  • The wildcard event type ("*") now supports the once, capture, and signal options.

✨ Enhancements

  • Improved type strictness across the whole Jaset interface.
  • Wildcard listeners are now dispatched through the native EventTarget, so they observe the correct currentTarget and eventPhase.
  • mutedEventTypes is now a ReadonlySet instead of a mutable Set.
  • The eventListeners map now accurately reports listener objects instead of casting them to functions.

✅ Bug fixes

  • Fixed: emit() and dispatchEvent() could accept any Event instead of only events declared in the provided EventMap.
  • Fixed: clear() did not remove capturing listeners.
  • Fixed: Throwing wildcard listeners aborted remaining listeners and pending emits.
  • Fixed: once listeners were not being cleaned up properly, which could lead to memory leaks.
  • Fixed: Using AbortSignal could lead to stale eventListeners entries and block re-registration after abort.
  • Fixed: capture flag was being ignored when de-duplicating and removing listeners, which was different to the native EventTarget.

🔄 Refactoring

  • Rewrote the internal listener store to track each listener’s native wrapper, capture flag, and abort cleanup, keyed by callback and capture.
  • Renamed the internal EventListener type to EventListenerFn to stop shadowing the global DOM EventListener type.
  • Reduced internal as never casts.
  • Migrated the build process from esbuild and dts-bundle-generator to tsdown.

Other

  • Added tests.
  • Updated dependencies.
  • Updated documentation.
  • Improved package.json by adding sideEffects and engine configuration.
  • Updated to ESLint 10.
  • Updated to TypeScript 6.
  • Set up additional linting with attw (for packaged types) and publint (for the NPM packge).
  • Improved the “Build and Publish” workflow.
  • Added a “CI” workflow that runs on every push and PR to main.

1.1.0

28 Feb 19:03

Choose a tag to compare

Initial release