mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-21 12:18:24 +08:00
refactor: reorganize codebase — move browse CLI to browse/ directory
Restructure project layout: src/ → browse/src/, test/ → browse/test/. Add snapshot testing. Update docs, package.json, and skills integration. Add setup script and TODO tracking. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
37
browse/src/buffers.ts
Normal file
37
browse/src/buffers.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Shared buffers and types — extracted to break circular dependency
|
||||
* between server.ts and browser-manager.ts
|
||||
*/
|
||||
|
||||
export interface LogEntry {
|
||||
timestamp: number;
|
||||
level: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface NetworkEntry {
|
||||
timestamp: number;
|
||||
method: string;
|
||||
url: string;
|
||||
status?: number;
|
||||
duration?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export const consoleBuffer: LogEntry[] = [];
|
||||
export const networkBuffer: NetworkEntry[] = [];
|
||||
const HIGH_WATER_MARK = 50_000;
|
||||
|
||||
export function addConsoleEntry(entry: LogEntry) {
|
||||
consoleBuffer.push(entry);
|
||||
if (consoleBuffer.length === HIGH_WATER_MARK) {
|
||||
console.warn(`[browse] Console buffer reached ${HIGH_WATER_MARK} entries`);
|
||||
}
|
||||
}
|
||||
|
||||
export function addNetworkEntry(entry: NetworkEntry) {
|
||||
networkBuffer.push(entry);
|
||||
if (networkBuffer.length === HIGH_WATER_MARK) {
|
||||
console.warn(`[browse] Network buffer reached ${HIGH_WATER_MARK} entries`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user