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

Function exportBundle

packages/core/src/debug/debugController.ts:496–644  ·  view source on GitHub ↗
(options?: DebugBundleExportOptions)

Source from the content-addressed store, hash-verified

494 }
495
496 async function exportBundle(options?: DebugBundleExportOptions): Promise<DebugBundle> {
497 const maxRecords = normalizeBound(options?.maxRecords, DEBUG_BUNDLE_DEFAULT_MAX_RECORDS);
498 const maxPayloadBytes = normalizeBound(
499 options?.maxPayloadBytes,
500 DEBUG_BUNDLE_DEFAULT_MAX_PAYLOAD_BYTES,
501 );
502 const maxTotalPayloadBytes = normalizeBound(
503 options?.maxTotalPayloadBytes,
504 DEBUG_BUNDLE_DEFAULT_MAX_TOTAL_PAYLOAD_BYTES,
505 );
506 const maxRecentFrames = normalizeBound(
507 options?.maxRecentFrames,
508 DEBUG_BUNDLE_DEFAULT_MAX_RECENT_FRAMES,
509 );
510 const includeRecentFrames = options?.includeRecentFrames !== false;
511
512 const captureRawEvents = options?.includeRawEvents ?? currentConfig?.captureRawEvents ?? false;
513 const captureDrawlistBytes =
514 options?.includeDrawlistBytes ?? currentConfig?.captureDrawlistBytes ?? false;
515
516 const stats = await backend.debugGetStats();
517 const statsSnapshot = toBundleStats(stats);
518 const terminalCaps = await resolveTerminalCaps(options?.terminalCaps);
519
520 let queryResult: DebugQueryResult = {
521 recordsReturned: 0,
522 recordsAvailable: 0,
523 oldestRecordId: 0n,
524 newestRecordId: 0n,
525 recordsDropped: 0,
526 };
527 let headersBytes: Uint8Array<ArrayBufferLike> = new Uint8Array(0);
528
529 if (maxRecords > 0) {
530 const queried = await backend.debugQuery({ maxRecords });
531 headersBytes = queried.headers;
532 queryResult = queried.result;
533 }
534
535 const parsedHeaders: DebugRecordHeader[] = [];
536 const count = Math.min(
537 queryResult.recordsReturned,
538 Math.floor(headersBytes.byteLength / DEBUG_RECORD_HEADER_SIZE),
539 );
540
541 for (let i = 0; i < count; i++) {
542 const offset = i * DEBUG_RECORD_HEADER_SIZE;
543 const parsed = parseRecordHeader(headersBytes, offset);
544 if (parsed.ok) {
545 parsedHeaders.push(parsed.value);
546 }
547 }
548
549 parsedHeaders.sort((a, b) => compareBigInt(a.recordId, b.recordId));
550
551 let payloadBudgetRemaining = maxTotalPayloadBytes;
552 const trace: Array<{
553 header: DebugBundleHeader;

Callers 1

exportBundleBytesFunction · 0.85

Calls 15

normalizeBoundFunction · 0.85
toBundleStatsFunction · 0.85
parseRecordHeaderFunction · 0.85
compareBigIntFunction · 0.85
toBundleHeaderFunction · 0.85
toBundleQueryWindowFunction · 0.85
debugGetStatsMethod · 0.80
debugQueryMethod · 0.80
debugGetPayloadMethod · 0.80
getSnapshotsMethod · 0.80

Tested by

no test coverage detected