Add BridgeEventBus and network manager

Introduce a typed per-kind BridgeEventBus and migrate away from the legacy single-callback firehose. Bridge now exposes `events` and emits via the bus; BridgeManager/OneBotManager no longer wire a global event callback. Add a focused onebot event pipeline (event-pipeline.ts) that subscribes per-kind handlers on instance construction. Replace the in-memory MediaCache with a persistent MediaStore and update all lookups accordingly. Replace the old Http/Ws/HttpPost transport implementations with a unified OneBotNetworkManager and pluggable adapters (server/client/post), and update OneBotInstance to install and manage adapters from config. Remove several legacy files (http-transport, http-post-transport, ws-transport, media-cache) and update imports across the codebase. Also add tests for the bridge event bus, event pipeline, network manager, and rename media tests to reflect MediaStore usage. The bus dispatches handlers in parallel and reports handler errors via an onError hook to avoid one faulty listener blocking others.
This commit is contained in:
手瓜一十雪 committed 2026-05-09 16:30:06 +08:00
1 parent 1565749105
commit 144e0fdd59
27 files changed
+2357 -1234

No files matched your search

+2 -10
View File
@@ -1,4 +1,3 @@
import type { QQEventVariant } from '../bridge/events';
import type { Bridge } from '../bridge/bridge';
import type { QQInfo } from '../bridge/qq-info';
import type { BridgeManager } from '../bridge/manager';
@@ -21,9 +20,8 @@ export class OneBotManager {
this.onSessionClosed(uin);
});
bridgeManager.setEventCallback((uin, event) => {
this.onBridgeEvent(uin, event);
});
// Per-kind subscriptions to `bridge.events` happen inside
// `OneBotInstance` itself; no global firehose to wire here.
}
getInstance(uin: string): OneBotInstance | null {
@@ -80,12 +78,6 @@ export class OneBotManager {
log.info('session closed: UIN=%s', uin);
}
private onBridgeEvent(uin: string, event: QQEventVariant): void {
const instance = this.instances.get(uin);
if (!instance) return;
instance.onBridgeEvent(event);
}
}
async function warmUpBridgeState(uin: string, qqInfo: QQInfo, bridge: Bridge): Promise<void> {