Migrate project to pnpm monorepo
Restructure the repository into a pnpm workspace under packages/ (core, webui, runtime). Move source files for core and webui into packages/*, add package manifests for @snowluma/core and @snowluma/runtime, and remove the old launcher package.json. Update root package.json to be a monorepo controller (scripts delegate to pnpm filters, set packageManager and Node engine). Configure build outputs to emit into the repo-root dist/ (vite config changes) so the existing release pipeline continues to work. Add .npmrc with mirrors, expand .gitignore for monorepo layout, add tsconfig base and package-level tsconfigs, and add vitest config for the core package. Adjust injector native search paths and update tests import paths to the new package layout. Small CI/workflow comment added to clarify build behavior and README updated with monorepo structure and common commands.
This commit is contained in:
1 parent
6bba36bba6
commit
39f1672b29
122 files changed
+279
-85
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { createLogger } from '../utils/logger';
|
||||
import type { PacketInfo } from './types';
|
||||
|
||||
const log = createLogger('NTQQ');
|
||||
|
||||
export type CmdCallback = (pkt: PacketInfo) => void;
|
||||
|
||||
export interface HookPacketInput {
|
||||
seq: number;
|
||||
error: number;
|
||||
cmd: string;
|
||||
uin: string;
|
||||
body: Uint8Array;
|
||||
}
|
||||
|
||||
export class NtqqHandler {
|
||||
private cmdHandlers = new Map<string, CmdCallback[]>();
|
||||
private cmdAllHandlers: CmdCallback[] = [];
|
||||
|
||||
registerCmd(cmd: string, cb: CmdCallback): void {
|
||||
const arr = this.cmdHandlers.get(cmd) ?? [];
|
||||
arr.push(cb);
|
||||
this.cmdHandlers.set(cmd, arr);
|
||||
}
|
||||
registerCmdAll(cb: CmdCallback): void { this.cmdAllHandlers.push(cb); }
|
||||
|
||||
onHookPacket(pid: number, packet: HookPacketInput): void {
|
||||
this.dispatchPacket({
|
||||
pid,
|
||||
uin: packet.uin,
|
||||
serviceCmd: packet.cmd,
|
||||
seqId: packet.seq,
|
||||
retCode: packet.error,
|
||||
fromClient: false,
|
||||
body: Buffer.from(packet.body),
|
||||
});
|
||||
}
|
||||
|
||||
private dispatchPacket(pkt: PacketInfo): void {
|
||||
const specific = this.cmdHandlers.get(pkt.serviceCmd);
|
||||
if (specific) {
|
||||
for (const cb of specific) {
|
||||
try { cb(pkt); } catch (e) {
|
||||
log.error('dispatch error for %s: %s', pkt.serviceCmd, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const cb of this.cmdAllHandlers) {
|
||||
try { cb(pkt); } catch (e) {
|
||||
log.error('dispatch error for %s: %s', pkt.serviceCmd, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface SendPacketResult {
|
||||
success: boolean;
|
||||
gotResponse: boolean;
|
||||
errorCode: number;
|
||||
errorMessage: string;
|
||||
responseData: Buffer | null;
|
||||
}
|
||||
|
||||
export interface PacketSender {
|
||||
sendPacket(serviceCmd: string, body: Buffer, timeoutMs?: number): Promise<SendPacketResult>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface PacketInfo {
|
||||
pid: number;
|
||||
uin: string;
|
||||
packetType?: number;
|
||||
serviceCmd: string;
|
||||
seqId: number;
|
||||
retCode: number;
|
||||
fromClient: boolean;
|
||||
body: Uint8Array;
|
||||
}
|
||||
Reference in new issue
Block a user