• Wraps a plugin with automatic listener-reference tracking.

    When a middleware plugin intercepts addListener and wraps the listener function, the adapter stores the wrapped reference. If the caller later invokes removeListener with the original listener, the adapter cannot find it — the reference has changed.

    withListenerTracking solves this by wrapping the original listener with a tracking wrapper in addListener and storing the original → wrapper mapping. On removeListener, it resolves the original listener back to the tracking wrapper before forwarding the call to the chain.

    Parameters

    Returns PluginFn<IEventBusAdapter>

    A plugin function that applies both the given plugin and listener tracking.

    IMPORT_PATH: "@daiso-tech/core/event-bus/plugins"