MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / createDebugController

Function createDebugController

packages/core/src/debug/debugController.ts:371–753  ·  view source on GitHub ↗
(options: CreateDebugControllerOptions = {})

Source from the content-addressed store, hash-verified

369 * Create a debug controller instance.
370 */
371export function createDebugController(options: CreateDebugControllerOptions = {}): DebugController {
372 const backend = options.backend ?? NULL_BACKEND;
373 const terminalCapsProvider = options.terminalCapsProvider;
374 const frameInspector = createFrameInspector(options.maxFrames);
375 const eventTrace = createEventTrace(options.maxEvents);
376 const errorAggregator = createErrorAggregator();
377 const stateTimeline = createStateTimeline(options.maxStateChanges);
378
379 let isEnabled = false;
380 let currentConfig: DebugConfig | null = null;
381 const recordHandlers: Set<DebugRecordHandler> = new Set();
382
383 function notifyRecordHandlers(record: DebugRecord): void {
384 for (const handler of recordHandlers) {
385 try {
386 handler(record);
387 } catch {
388 // Ignore handler errors
389 }
390 }
391 }
392
393 async function resolveTerminalCaps(
394 override: TerminalCaps | null | undefined,
395 ): Promise<TerminalCaps | null> {
396 if (override !== undefined) return override;
397 if (!terminalCapsProvider) return null;
398 try {
399 return (await terminalCapsProvider()) ?? null;
400 } catch {
401 return null;
402 }
403 }
404
405 async function enable(config?: Partial<DebugConfig>): Promise<void> {
406 const fullConfig: DebugConfig = {
407 enabled: true,
408 ...(config?.ringCapacity !== undefined && { ringCapacity: config.ringCapacity }),
409 ...(config?.minSeverity !== undefined && { minSeverity: config.minSeverity }),
410 ...(config?.categoryMask !== undefined && { categoryMask: config.categoryMask }),
411 ...(config?.captureRawEvents !== undefined && { captureRawEvents: config.captureRawEvents }),
412 ...(config?.captureDrawlistBytes !== undefined && {
413 captureDrawlistBytes: config.captureDrawlistBytes,
414 }),
415 };
416
417 await backend.debugEnable(fullConfig);
418 isEnabled = true;
419 currentConfig = fullConfig;
420 }
421
422 async function disable(): Promise<void> {
423 await backend.debugDisable();
424 isEnabled = false;
425 currentConfig = null;
426 }
427
428 async function reset(): Promise<void> {

Callers 2

setupDebugTraceFunction · 0.90

Calls 4

createFrameInspectorFunction · 0.85
createEventTraceFunction · 0.85
createErrorAggregatorFunction · 0.85
createStateTimelineFunction · 0.85

Tested by

no test coverage detected