Skip to content

Commit 9bc682d

Browse files
committed
bump
1 parent d892885 commit 9bc682d

File tree

3 files changed

+70
-159
lines changed

3 files changed

+70
-159
lines changed

packages/scan/package.json

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
"name": "react-scan",
33
"version": "0.0.50",
44
"description": "Scan your React app for renders",
5-
"keywords": [
6-
"react",
7-
"react-scan",
8-
"react scan",
9-
"render",
10-
"performance"
11-
],
5+
"keywords": ["react", "react-scan", "react scan", "render", "performance"],
126
"homepage": "https://react-scan.million.dev",
137
"bugs": {
148
"url": "https://github.com/aidenybai/react-scan/issues"
@@ -167,27 +161,17 @@
167161
"types": "dist/index.d.ts",
168162
"typesVersions": {
169163
"*": {
170-
"monitoring": [
171-
"./dist/core/monitor/index.d.ts"
172-
],
173-
"monitoring/next": [
174-
"./dist/core/monitor/params/next.d.ts"
175-
],
164+
"monitoring": ["./dist/core/monitor/index.d.ts"],
165+
"monitoring/next": ["./dist/core/monitor/params/next.d.ts"],
176166
"monitoring/react-router-legacy": [
177167
"./dist/core/monitor/params/react-router-v5.d.ts"
178168
],
179169
"monitoring/react-router": [
180170
"./dist/core/monitor/params/react-router-v6.d.ts"
181171
],
182-
"monitoring/remix": [
183-
"./dist/core/monitor/params/remix.d.ts"
184-
],
185-
"monitoring/astro": [
186-
"./dist/core/monitor/params/astro/index.ts"
187-
],
188-
"react-component-name/vite": [
189-
"./dist/react-component-name/vite.d.ts"
190-
],
172+
"monitoring/remix": ["./dist/core/monitor/params/remix.d.ts"],
173+
"monitoring/astro": ["./dist/core/monitor/params/astro/index.ts"],
174+
"react-component-name/vite": ["./dist/react-component-name/vite.d.ts"],
191175
"react-component-name/webpack": [
192176
"./dist/react-component-name/webpack.d.ts"
193177
],
@@ -203,20 +187,11 @@
203187
"react-component-name/rollup": [
204188
"./dist/react-component-name/rollup.d.ts"
205189
],
206-
"react-component-name/astro": [
207-
"./dist/react-component-name/astro.d.ts"
208-
]
190+
"react-component-name/astro": ["./dist/react-component-name/astro.d.ts"]
209191
}
210192
},
211193
"bin": "bin/cli.js",
212-
"files": [
213-
"dist",
214-
"bin",
215-
"package.json",
216-
"README.md",
217-
"LICENSE",
218-
"auto.d.ts"
219-
],
194+
"files": ["dist", "bin", "package.json", "README.md", "LICENSE", "auto.d.ts"],
220195
"scripts": {
221196
"build": "npm run build:css && NODE_ENV=production tsup",
222197
"postbuild": "pnpm copy-astro && node ../../scripts/version-warning.mjs",
@@ -242,7 +217,7 @@
242217
"@preact/signals": "^1.3.1",
243218
"@rollup/pluginutils": "^5.1.3",
244219
"@types/node": "^20.17.9",
245-
"bippy": "^0.0.23",
220+
"bippy": "^0.0.25",
246221
"esbuild": "^0.24.0",
247222
"estree-walker": "^3.0.3",
248223
"kleur": "^4.1.5",

packages/scan/src/core/web/utils/outline.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

66
export 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
3232
const START_COLOR = { r: 115, g: 97, b: 230 };
3333
const END_COLOR = { r: 185, g: 49, b: 115 };
3434
const MONO_FONT =
35-
"Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace";
35+
'Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace';
3636

3737
export 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<
8181
const CACHE_LIFETIME = 200;
8282

8383
export 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

144144
export 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

186186
export 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

406406
const 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

463463
async 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

492492
export 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

554554
export 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 = (
567567
export 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

579579
export 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

Comments
 (0)