MCPcopy Create free account
hub / github.com/callstack/agent-device / formatScreenshotDiffOcrLines

Function formatScreenshotDiffOcrLines

src/utils/output.ts:436–466  ·  view source on GitHub ↗
(data: ScreenshotDiffResult, useColor: boolean)

Source from the content-addressed store, hash-verified

434}
435
436function formatScreenshotDiffOcrLines(data: ScreenshotDiffResult, useColor: boolean): string[] {
437 const ocrMatches = data.ocr?.matches ?? [];
438 if (ocrMatches.length === 0) return [];
439
440 const shownOcrMatches = ocrMatches.slice(0, 8);
441 const lines = [
442 ` ${formatMuted(
443 `OCR text deltas (${data.ocr?.provider}; baselineBlocks=${data.ocr?.baselineBlocks} ` +
444 `currentBlocks=${data.ocr?.currentBlocks}; showing ${shownOcrMatches.length}/${ocrMatches.length}; px):`,
445 useColor,
446 )}`,
447 ` ${formatMuted(
448 'item | text | movePx | sizeDeltaPx | bboxBaseline | bboxCurrent | confidence | issueHint',
449 useColor,
450 )}`,
451 ];
452
453 for (const [index, ocrMatch] of shownOcrMatches.entries()) {
454 const delta = ocrMatch.delta;
455 lines.push(
456 ` ${index + 1} | ${JSON.stringify(ocrMatch.text)} | ` +
457 `${formatSignedPixels(delta.x)},${formatSignedPixels(delta.y)} | ` +
458 `${formatSignedPixels(delta.width)},${formatSignedPixels(delta.height)} | ` +
459 `${formatRect(ocrMatch.baselineRect)} | ${formatRect(ocrMatch.currentRect)} | ` +
460 `${ocrMatch.confidence} | ` +
461 `${ocrMatch.possibleTextMetricMismatch ? 'ocr-bbox-size-change' : '-'}`,
462 );
463 }
464
465 return lines;
466}
467
468function formatScreenshotDiffNonTextLines(data: ScreenshotDiffResult, useColor: boolean): string[] {
469 const nonTextDeltas = data.nonTextDeltas ?? [];

Callers 1

formatScreenshotDiffTextFunction · 0.85

Calls 4

formatMutedFunction · 0.85
formatSignedPixelsFunction · 0.85
formatRectFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…