1- import { throttle } from " @web-utils/helpers" ;
2- import { ReactScanInternals } from " ../../index" ;
3- import { type Render } from " ../../instrumentation" ;
4- import { getLabelText } from " ../../utils" ;
1+ import { throttle } from ' @web-utils/helpers' ;
2+ import { ReactScanInternals } from ' ../../index' ;
3+ import { type Render } from ' ../../instrumentation' ;
4+ import { getLabelText } from ' ../../utils' ;
55
66export interface PendingOutline {
77 domNode : HTMLElement ;
@@ -21,7 +21,7 @@ export interface OutlineLabel {
2121 alpha : number ;
2222 outline : PendingOutline ;
2323 color : { r : number ; g : number ; b : number } ;
24- reasons : Array < " unstable" | " commit" | " unnecessary" > ;
24+ reasons : Array < ' unstable' | ' commit' | ' unnecessary' > ;
2525 labelText : string ;
2626 textWidth : number ;
2727 rect : DOMRect ;
@@ -32,7 +32,7 @@ const DEFAULT_THROTTLE_TIME = 32; // 2 frames
3232const START_COLOR = { r : 115 , g : 97 , b : 230 } ;
3333const END_COLOR = { r : 185 , g : 49 , b : 115 } ;
3434const MONO_FONT =
35- " Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace" ;
35+ ' Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace' ;
3636
3737export const getOutlineKey = ( rect : DOMRect ) : string => {
3838 return `${ rect . top } -${ rect . left } -${ rect . width } -${ rect . height } ` ;
@@ -45,7 +45,7 @@ function incrementFrameId() {
4545 requestAnimationFrame ( incrementFrameId ) ;
4646}
4747
48- if ( typeof window !== " undefined" ) {
48+ if ( typeof window !== ' undefined' ) {
4949 incrementFrameId ( ) ;
5050}
5151
@@ -81,7 +81,7 @@ const boundingRectCache = new Map<
8181const CACHE_LIFETIME = 200 ;
8282
8383export const batchGetBoundingRects = (
84- elements : Array < HTMLElement >
84+ elements : Array < HTMLElement > ,
8585) : Promise < Map < HTMLElement , DOMRect > > => {
8686 idempotent_startBoundingRectGC ( ) ;
8787 return new Promise ( ( resolve ) => {
@@ -143,7 +143,7 @@ const idempotent_startBoundingRectGC = () => {
143143
144144export const flushOutlines = async (
145145 ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D ,
146- previousOutlines : Map < string , PendingOutline > = new Map ( )
146+ previousOutlines : Map < string , PendingOutline > = new Map ( ) ,
147147) => {
148148 if ( ! ReactScanInternals . scheduledOutlines . length ) {
149149 return ;
@@ -152,15 +152,15 @@ export const flushOutlines = async (
152152 const scheduledOutlines = ReactScanInternals . scheduledOutlines ;
153153 const newPreviousOutlines = await activateOutlines (
154154 scheduledOutlines ,
155- previousOutlines
155+ previousOutlines ,
156156 ) ;
157157 ReactScanInternals . scheduledOutlines = [ ] ;
158158
159159 recalcOutlines ( ) ;
160160
161161 void paintOutlines (
162162 ctx ,
163- scheduledOutlines // this only matters for API back compat we aren't using it in this func
163+ scheduledOutlines , // this only matters for API back compat we aren't using it in this func
164164 ) ;
165165
166166 if ( ReactScanInternals . scheduledOutlines . length ) {
@@ -178,13 +178,13 @@ function getCachedLabelText(outline: PendingOutline): string {
178178 if ( labelTextCache . has ( outline ) ) {
179179 return labelTextCache . get ( outline ) ! ;
180180 }
181- const text = getLabelText ( outline . renders ) ?? "" ;
181+ const text = getLabelText ( outline . renders ) ?? '' ;
182182 labelTextCache . set ( outline , text ) ;
183183 return text ;
184184}
185185
186186export const fadeOutOutline = (
187- ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
187+ ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D ,
188188) => {
189189 const { activeOutlines } = ReactScanInternals ;
190190 const options = ReactScanInternals . options . value ;
@@ -219,7 +219,7 @@ export const fadeOutOutline = (
219219 existing . frame = Math . min ( existing . frame , activeOutline . frame ) ;
220220 existing . totalFrames = Math . max (
221221 existing . totalFrames ,
222- activeOutline . totalFrames
222+ activeOutline . totalFrames ,
223223 ) ;
224224 }
225225
@@ -247,7 +247,7 @@ export const fadeOutOutline = (
247247 const renderCountThreshold = options . renderCountThreshold ?? 0 ;
248248
249249 const phases = new Set < string > ( ) ;
250- const reasons : Array < " unstable" | " commit" | " unnecessary" > = [ ] ;
250+ const reasons : Array < ' unstable' | ' commit' | ' unnecessary' > = [ ] ;
251251
252252 for ( const activeOutline of groupedOutlines . values ( ) ) {
253253 const { outline, frame, totalFrames, rect } = activeOutline ;
@@ -267,7 +267,7 @@ export const fadeOutOutline = (
267267 const avgFps = totalFps / renderLen ;
268268 const averageScore = Math . max (
269269 ( THRESHOLD_FPS - Math . min ( avgFps , THRESHOLD_FPS ) ) / THRESHOLD_FPS ,
270- totalTime / totalCount / 16
270+ totalTime / totalCount / 16 ,
271271 ) ;
272272
273273 const t = Math . min ( averageScore , 1 ) ;
@@ -304,10 +304,10 @@ export const fadeOutOutline = (
304304 }
305305 }
306306
307- if ( didCommit ) reasons . push ( " commit" ) ;
308- if ( isUnstable ) reasons . push ( " unstable" ) ;
307+ if ( didCommit ) reasons . push ( ' commit' ) ;
308+ if ( isUnstable ) reasons . push ( ' unstable' ) ;
309309 if ( isUnnecessary ) {
310- reasons . push ( " unnecessary" ) ;
310+ reasons . push ( ' unnecessary' ) ;
311311 if ( reasons . length === 1 ) {
312312 color = { r : 128 , g : 128 , b : 128 } ;
313313 }
@@ -344,7 +344,7 @@ export const fadeOutOutline = (
344344 if (
345345 reasons . length &&
346346 labelText &&
347- ! ( phases . has ( " mount" ) && phases . size === 1 )
347+ ! ( phases . has ( ' mount' ) && phases . size === 1 )
348348 ) {
349349 const measured = measureTextCached ( labelText , ctx ) ;
350350 pendingLabeledOutlines . push ( {
@@ -370,8 +370,8 @@ export const fadeOutOutline = (
370370 const { alpha, outline, color, reasons, rect } = mergedLabels [ i ] ;
371371 const text = getCachedLabelText ( outline ) ;
372372 const conditionalText =
373- reasons . includes ( " unstable" ) &&
374- ( reasons . includes ( " commit" ) || reasons . includes ( " unnecessary" ) )
373+ reasons . includes ( ' unstable' ) &&
374+ ( reasons . includes ( ' commit' ) || reasons . includes ( ' unnecessary' ) )
375375 ? `⚠️${ text } `
376376 : text ;
377377
@@ -405,7 +405,7 @@ export interface PendingOutline {
405405
406406const activateOutlines = async (
407407 outlines : Array < PendingOutline > ,
408- previousOutlines : Map < string , PendingOutline >
408+ previousOutlines : Map < string , PendingOutline > ,
409409) => {
410410 const newPreviousOutlines = new Map < string , PendingOutline > ( ) ;
411411
@@ -462,7 +462,7 @@ const activateOutlines = async (
462462
463463async function paintOutlines (
464464 ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D ,
465- outlines : Array < PendingOutline >
465+ outlines : Array < PendingOutline > ,
466466) : Promise < void > {
467467 const { options } = ReactScanInternals ;
468468 options . value . onPaintStart ?.( outlines ) ; // maybe we should start passing activeOutlines to onPaintStart, since we have the activeOutlines at painStart
@@ -491,7 +491,7 @@ export const getLabelRect = (label: OutlineLabel): DOMRect => {
491491
492492export const mergeOverlappingLabels = (
493493 labels : Array < OutlineLabel > ,
494- maxMergeOps = 2000
494+ maxMergeOps = 2000 ,
495495) : Array < OutlineLabel > => {
496496 const sortedByX = labels . map ( ( label ) => ( {
497497 ...label ,
@@ -533,7 +533,7 @@ export const mergeOverlappingLabels = (
533533 nextLabel . rect = combinedOutline . rect ;
534534 nextLabel . outline = combinedOutline ;
535535 nextLabel . reasons = Array . from (
536- new Set ( nextLabel . reasons . concat ( label . reasons ) )
536+ new Set ( nextLabel . reasons . concat ( label . reasons ) ) ,
537537 ) ;
538538
539539 isMerged = true ;
@@ -553,7 +553,7 @@ const textMeasurementCache = new Map<string, TextMetrics>();
553553
554554export const measureTextCached = (
555555 text : string ,
556- ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
556+ ctx : CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D ,
557557) : TextMetrics => {
558558 if ( textMeasurementCache . has ( text ) ) {
559559 return textMeasurementCache . get ( text ) ! ;
@@ -567,18 +567,18 @@ export const measureTextCached = (
567567export const getOverlapArea = ( rect1 : DOMRect , rect2 : DOMRect ) : number => {
568568 const xOverlap = Math . max (
569569 0 ,
570- Math . min ( rect1 . right , rect2 . right ) - Math . max ( rect1 . left , rect2 . left )
570+ Math . min ( rect1 . right , rect2 . right ) - Math . max ( rect1 . left , rect2 . left ) ,
571571 ) ;
572572 const yOverlap = Math . max (
573573 0 ,
574- Math . min ( rect1 . bottom , rect2 . bottom ) - Math . max ( rect1 . top , rect2 . top )
574+ Math . min ( rect1 . bottom , rect2 . bottom ) - Math . max ( rect1 . top , rect2 . top ) ,
575575 ) ;
576576 return xOverlap * yOverlap ;
577577} ;
578578
579579export const getOutermostLabel = (
580580 label1 : OutlineLabel ,
581- label2 : OutlineLabel
581+ label2 : OutlineLabel ,
582582) : OutlineLabel => {
583583 const area1 = label1 . rect . width * label1 . rect . height ;
584584 const area2 = label2 . rect . width * label2 . rect . height ;
0 commit comments