MCPcopy
hub / github.com/chenglou/pretext / buildProbeReport

Function buildProbeReport

pages/probe.ts:756–838  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

754}
755
756function buildProbeReport(): ProbeReport {
757 document.title = 'Pretext — Text Probe'
758 document.documentElement.lang = lang
759 document.documentElement.dir = direction
760
761 book.textContent = text
762 book.lang = lang
763 book.dir = direction
764 book.style.font = font
765 book.style.letterSpacing = `${letterSpacing}px`
766 book.style.lineHeight = `${lineHeight}px`
767 book.style.padding = `${PADDING}px`
768 book.style.width = `${width}px`
769 book.style.whiteSpace = cssWhiteSpace
770 book.style.wordBreak = cssWordBreak
771
772 diagnosticDiv.textContent = text
773 diagnosticDiv.lang = lang
774 diagnosticDiv.dir = direction
775 diagnosticDiv.style.font = font
776 diagnosticDiv.style.letterSpacing = `${letterSpacing}px`
777 diagnosticDiv.style.lineHeight = `${lineHeight}px`
778 diagnosticDiv.style.padding = `${PADDING}px`
779 diagnosticDiv.style.width = `${width}px`
780 diagnosticDiv.style.whiteSpace = cssWhiteSpace
781 diagnosticDiv.style.wordBreak = cssWordBreak
782
783 const prepared = prepareWithSegments(text, font, { whiteSpace, wordBreak, letterSpacing })
784 const normalizedText = prepared.segments.join('')
785 const contentWidth = width - PADDING * 2
786 const predicted = layout(prepared, contentWidth, lineHeight)
787 const actualHeight = book.getBoundingClientRect().height
788 const ourLines = getPublicLines(prepared, normalizedText, contentWidth, lineHeight, font)
789 const alternateBrowserLineMethod = browserLineMethod === 'span' ? 'range' : 'span'
790 const browserLines = getBrowserLines(prepared, font, direction, browserLineMethod)
791 const alternateBrowserLines = getBrowserLines(prepared, font, direction, alternateBrowserLineMethod)
792 const firstBreakMismatch = getFirstBreakMismatch(normalizedText, contentWidth, ourLines, browserLines)
793 const alternateFirstBreakMismatch = getFirstBreakMismatch(normalizedText, contentWidth, ourLines, alternateBrowserLines)
794 const breakTrace = firstBreakMismatch === null
795 ? null
796 : getBreakTrace(
797 prepared,
798 font,
799 contentWidth,
800 ourLines[firstBreakMismatch.line - 1],
801 browserLines[firstBreakMismatch.line - 1],
802 firstBreakMismatch,
803 )
804 const extractorSensitivity =
805 firstBreakMismatch !== null && alternateFirstBreakMismatch === null
806 ? `${browserLineMethod} mismatch disappears with ${alternateBrowserLineMethod}`
807 : null
808
809 return withRequestId({
810 status: 'ready',
811 text,
812 whiteSpace,
813 wordBreak,

Callers 2

initFunction · 0.85
runProbeBatchFunction · 0.85

Calls 8

prepareWithSegmentsFunction · 0.90
layoutFunction · 0.90
getPublicLinesFunction · 0.85
getBreakTraceFunction · 0.85
summarizeLinesFunction · 0.85
getBrowserLinesFunction · 0.70
getFirstBreakMismatchFunction · 0.70
withRequestIdFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…