Cleanup imports and formatting in bridge
Reorder and tidy imports, re-export types, and apply minor formatting fixes across the bridge package. Changes include: - Reordered imports and grouped related imports in hook-manager, hook-session, pipe-watcher, qq-hook-client, qq-port-probe and others. - Moved several type re-exports (HookProcessBaseInfo, QqPortLoginInfo, HookProcessInfo/Status) in hook-manager and consolidated exports in package entry index.ts. - Minor whitespace/style tweaks: constructor spacing, for-loop formatting, empty catch handlers, and small refactors that do not change runtime behavior. These are non-functional housekeeping changes to improve consistency and readability.
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
import fs from 'fs';
|
||||
import { createLogger, type Logger } from '@snowluma/common/logger';
|
||||
import type { PacketSender } from '@snowluma/common/packet-sender';
|
||||
import type { PacketInfo, PacketSink } from '@snowluma/common/protocol-types';
|
||||
import { createLogger, type Logger } from '@snowluma/common/logger';
|
||||
import fs from 'fs';
|
||||
import { HookSession, type HookSessionDeps } from './hook-session';
|
||||
import {
|
||||
injectHookProcess,
|
||||
listHookProcesses,
|
||||
unloadHookProcess,
|
||||
type HookProcessBaseInfo,
|
||||
} from './injector';
|
||||
import { HookSession, type HookSessionDeps } from './hook-session';
|
||||
import { PipeWatcher } from './pipe-watcher';
|
||||
import { QqHookClient } from './qq-hook-client';
|
||||
import type { HookProcessInfo } from './types';
|
||||
import { probeQqLoginInfo, type QqPortLoginInfo } from './qq-port-probe';
|
||||
import type { HookProcessInfo } from './types';
|
||||
|
||||
|
||||
export type { HookProcessInfo, HookProcessStatus } from './types';
|
||||
export type { HookProcessBaseInfo } from './injector';
|
||||
export type { QqPortLoginInfo } from './qq-port-probe';
|
||||
|
||||
/**
|
||||
* Sink that the hook layer calls back into when it observes a new login,
|
||||
@@ -229,7 +227,7 @@ export class HookManager {
|
||||
if (this.disposed) return;
|
||||
for (const session of this.sessions.values()) {
|
||||
if ((session.status === 'connecting' || session.status === 'disconnected')
|
||||
&& this.pipeWatcher.isPipeLive(session.pid)) {
|
||||
&& this.pipeWatcher.isPipeLive(session.pid)) {
|
||||
session.onPipeUp();
|
||||
}
|
||||
}
|
||||
@@ -311,3 +309,6 @@ export function shouldAutoLoadPid(pid: number, log: Logger): boolean {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
export type { HookProcessBaseInfo } from './injector';
|
||||
export type { QqPortLoginInfo } from './qq-port-probe';
|
||||
export type { HookProcessInfo, HookProcessStatus } from './types';
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { PacketSender, SendPacketResult } from '@snowluma/common/packet-sen
|
||||
import { QqHookClient, type QqHookSendReply } from './qq-hook-client';
|
||||
|
||||
export class HookPacketClient implements PacketSender {
|
||||
constructor(private readonly client: QqHookClient) {}
|
||||
constructor(private readonly client: QqHookClient) { }
|
||||
|
||||
async sendPacket(serviceCmd: string, body: Buffer, timeoutMs = 15000): Promise<SendPacketResult> {
|
||||
if (!this.client.isLoggedIn) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import type { PacketSink } from '@snowluma/common/protocol-types';
|
||||
import { createLogger, type Logger } from '@snowluma/common/logger';
|
||||
import type { PacketSink } from '@snowluma/common/protocol-types';
|
||||
import { EventEmitter } from 'events';
|
||||
import { HookPacketClient } from './hook-packet-client';
|
||||
import type { HookInjectResult } from './injector';
|
||||
import type { QqHookClient, QqHookLoginState, QqHookPacket } from './qq-hook-client';
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
// Public entry — re-exports the hook orchestration surface that the
|
||||
// top-level app (and webui readers) consume. Everything else is
|
||||
// internal to the package.
|
||||
|
||||
export {
|
||||
HookManager,
|
||||
type HookManagerDeps,
|
||||
type BridgeManagerSink,
|
||||
type HookProcessInfo,
|
||||
type HookProcessStatus,
|
||||
type HookProcessBaseInfo,
|
||||
type QqPortLoginInfo,
|
||||
HookManager, type BridgeManagerSink, type HookManagerDeps, type HookProcessBaseInfo, type HookProcessInfo,
|
||||
type HookProcessStatus, type QqPortLoginInfo
|
||||
} from './hook-manager';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { createLogger, type Logger } from '@snowluma/common/logger';
|
||||
import { EventEmitter } from 'events';
|
||||
import type { HookProcessBaseInfo } from './injector';
|
||||
|
||||
const DEFAULT_INTERVAL_MS = 1500;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { promises as fs } from 'fs';
|
||||
import net from 'net';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { promises as fs } from 'fs';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export const PIPE_MAGIC = 0x31504851;
|
||||
export const PIPE_VERSION = 1;
|
||||
@@ -235,7 +235,7 @@ function encodeFrame({
|
||||
class FrameReader {
|
||||
private buffer = Buffer.alloc(0);
|
||||
|
||||
constructor(private readonly onFrame: (frame: PipeFrame) => void) {}
|
||||
constructor(private readonly onFrame: (frame: PipeFrame) => void) { }
|
||||
|
||||
push(chunk: Buffer): void {
|
||||
this.buffer = Buffer.concat([this.buffer, chunk]);
|
||||
@@ -513,7 +513,7 @@ export class QqHookClient extends EventEmitter {
|
||||
const workerCount = Math.max(1, Math.min(concurrency | 0, items.length || 1));
|
||||
|
||||
const worker = async () => {
|
||||
for (;;) {
|
||||
for (; ;) {
|
||||
const index = nextIndex;
|
||||
nextIndex += 1;
|
||||
if (index >= items.length) return;
|
||||
@@ -624,7 +624,7 @@ export class QqHookClient extends EventEmitter {
|
||||
else resolve();
|
||||
});
|
||||
}));
|
||||
this.controlWriteChain = writePromise.catch(() => {});
|
||||
this.controlWriteChain = writePromise.catch(() => { });
|
||||
return writePromise;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import net from 'net';
|
||||
import { exec } from 'child_process';
|
||||
import net from 'net';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
Reference in New Issue
Block a user