@oxog/react-check 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +42 -19
- package/dist/browser-inject.global.js +5 -5
- package/dist/chain.d.cts +1 -1
- package/dist/chain.d.ts +1 -1
- package/dist/{chunk-7YYMP3PP.js → chunk-35I3PLS3.js} +33 -5
- package/dist/chunk-35I3PLS3.js.map +1 -0
- package/dist/{chunk-GE2ZX7I7.cjs → chunk-DSXOHC6R.cjs} +34 -6
- package/dist/chunk-DSXOHC6R.cjs.map +1 -0
- package/dist/{chunk-G7YVIPS7.cjs → chunk-LFY7MUHJ.cjs} +10 -2
- package/dist/chunk-LFY7MUHJ.cjs.map +1 -0
- package/dist/{chunk-3K2AER5M.cjs → chunk-NLWGB4IE.cjs} +27 -3
- package/dist/chunk-NLWGB4IE.cjs.map +1 -0
- package/dist/{chunk-27R56V2S.js → chunk-PIXJPQO7.js} +10 -2
- package/dist/chunk-PIXJPQO7.js.map +1 -0
- package/dist/{chunk-IM6OG2IC.js → chunk-REEPUD73.js} +27 -3
- package/dist/chunk-REEPUD73.js.map +1 -0
- package/dist/cli.js +236 -109
- package/dist/cli.js.map +1 -1
- package/dist/detect.cjs +6 -6
- package/dist/detect.d.cts +1 -1
- package/dist/detect.d.ts +1 -1
- package/dist/detect.js +1 -1
- package/dist/fix.cjs +2 -2
- package/dist/fix.d.cts +7 -1
- package/dist/fix.d.ts +7 -1
- package/dist/fix.js +1 -1
- package/dist/index.cjs +134 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -13
- package/dist/index.d.ts +77 -13
- package/dist/index.js +110 -36
- package/dist/index.js.map +1 -1
- package/dist/{scanner-D0mBQGTx.d.ts → scanner-BJFA0354.d.ts} +11 -2
- package/dist/{scanner-DUBgwztZ.d.cts → scanner-DZL2rIFv.d.cts} +11 -2
- package/dist/scanner.cjs +3 -3
- package/dist/scanner.d.cts +2 -2
- package/dist/scanner.d.ts +2 -2
- package/dist/scanner.js +2 -2
- package/dist/{types-BZ3OeZ-5.d.ts → types-BMDemwIs.d.cts} +7 -0
- package/dist/{types-BZ3OeZ-5.d.cts → types-BMDemwIs.d.ts} +7 -0
- package/package.json +1 -1
- package/dist/chunk-27R56V2S.js.map +0 -1
- package/dist/chunk-3K2AER5M.cjs.map +0 -1
- package/dist/chunk-7YYMP3PP.js.map +0 -1
- package/dist/chunk-G7YVIPS7.cjs.map +0 -1
- package/dist/chunk-GE2ZX7I7.cjs.map +0 -1
- package/dist/chunk-IM6OG2IC.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as RenderChainInfo, d as ScannerConfig, W as WindowWithReactDevTools } from './types-
|
|
2
|
-
export { r as ComponentNode, h as ComponentStats, E as ErrorCode, u as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, q as ReactCheckConfig, s as ReactCheckError, t as ReactCheckEvents, p as ReactCheckOptions, n as RuleLevel, o as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-
|
|
3
|
-
import { S as Scanner } from './scanner-
|
|
4
|
-
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-
|
|
1
|
+
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as RenderChainInfo, d as ScannerConfig, W as WindowWithReactDevTools } from './types-BMDemwIs.cjs';
|
|
2
|
+
export { r as ComponentNode, h as ComponentStats, E as ErrorCode, u as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, q as ReactCheckConfig, s as ReactCheckError, t as ReactCheckEvents, p as ReactCheckOptions, n as RuleLevel, o as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-BMDemwIs.cjs';
|
|
3
|
+
import { S as Scanner } from './scanner-DZL2rIFv.cjs';
|
|
4
|
+
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-DZL2rIFv.cjs';
|
|
5
5
|
export { ChainAnalyzer, ChainEvents } from './chain.cjs';
|
|
6
6
|
export { FixEvents, FixSuggester } from './fix.cjs';
|
|
7
7
|
export { detectFramework, detectFrameworkFromWindow, frameworkDetectors, getFrameworkTips } from './detect.cjs';
|
|
8
8
|
import { E as EventEmitter } from './event-emitter-BVYUPYLd.cjs';
|
|
9
9
|
import * as node_net from 'node:net';
|
|
10
|
-
import * as puppeteer from 'puppeteer';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* React Fiber utilities for interacting with React internals
|
|
@@ -911,6 +910,11 @@ declare class ProxyServer extends EventEmitter<ProxyServerEvents> {
|
|
|
911
910
|
setInjectionScript(script: string): void;
|
|
912
911
|
}
|
|
913
912
|
|
|
913
|
+
/**
|
|
914
|
+
* Browser launcher using Puppeteer
|
|
915
|
+
* @packageDocumentation
|
|
916
|
+
*/
|
|
917
|
+
|
|
914
918
|
/**
|
|
915
919
|
* Browser launch options
|
|
916
920
|
*/
|
|
@@ -956,8 +960,46 @@ interface BrowserEvents {
|
|
|
956
960
|
/** Browser closed */
|
|
957
961
|
closed: void;
|
|
958
962
|
}
|
|
959
|
-
|
|
960
|
-
|
|
963
|
+
/**
|
|
964
|
+
* The commonly used part of Puppeteer's `Page`, typed structurally so that the
|
|
965
|
+
* package's types work without Puppeteer installed. For the full API pass
|
|
966
|
+
* Puppeteer's type: `launcher.getPage<import('puppeteer').Page>()`.
|
|
967
|
+
*/
|
|
968
|
+
interface PuppeteerPageLike {
|
|
969
|
+
/** Navigate to a URL */
|
|
970
|
+
goto(url: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
971
|
+
/** Click the first element matching a selector */
|
|
972
|
+
click(selector: string, options?: Record<string, unknown>): Promise<void>;
|
|
973
|
+
/** Type text into the element matching a selector */
|
|
974
|
+
type(selector: string, text: string, options?: Record<string, unknown>): Promise<void>;
|
|
975
|
+
/** Focus the element matching a selector */
|
|
976
|
+
focus(selector: string): Promise<void>;
|
|
977
|
+
/** Hover the element matching a selector */
|
|
978
|
+
hover(selector: string): Promise<void>;
|
|
979
|
+
/** Wait for an element matching a selector */
|
|
980
|
+
waitForSelector(selector: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
981
|
+
/** Evaluate a function or expression in the page */
|
|
982
|
+
evaluate<T>(fn: string | (() => T)): Promise<T>;
|
|
983
|
+
/** Take a screenshot */
|
|
984
|
+
screenshot(options?: Record<string, unknown>): Promise<unknown>;
|
|
985
|
+
/** Reload the page */
|
|
986
|
+
reload(options?: Record<string, unknown>): Promise<unknown>;
|
|
987
|
+
/** Current URL */
|
|
988
|
+
url(): string;
|
|
989
|
+
/** Close the page */
|
|
990
|
+
close(): Promise<void>;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* The commonly used part of Puppeteer's `Browser` (see {@link PuppeteerPageLike})
|
|
994
|
+
*/
|
|
995
|
+
interface PuppeteerBrowserLike {
|
|
996
|
+
/** Whether the browser is still connected */
|
|
997
|
+
readonly connected: boolean;
|
|
998
|
+
/** Open a new page */
|
|
999
|
+
newPage(): Promise<PuppeteerPageLike>;
|
|
1000
|
+
/** Close the browser */
|
|
1001
|
+
close(): Promise<void>;
|
|
1002
|
+
}
|
|
961
1003
|
/**
|
|
962
1004
|
* Browser launcher wrapper around Puppeteer
|
|
963
1005
|
*/
|
|
@@ -1031,15 +1073,17 @@ declare class BrowserLauncher extends EventEmitter<BrowserEvents> {
|
|
|
1031
1073
|
*/
|
|
1032
1074
|
isOpen(): boolean;
|
|
1033
1075
|
/**
|
|
1034
|
-
* Get the page instance (for advanced usage)
|
|
1076
|
+
* Get the page instance (for advanced usage). The return type is a
|
|
1077
|
+
* structural subset of Puppeteer's `Page`; pass the real type for the full
|
|
1078
|
+
* API: `getPage<import('puppeteer').Page>()`.
|
|
1035
1079
|
* @returns Puppeteer page or null
|
|
1036
1080
|
*/
|
|
1037
|
-
getPage():
|
|
1081
|
+
getPage<TPage = PuppeteerPageLike>(): TPage | null;
|
|
1038
1082
|
/**
|
|
1039
|
-
* Get the browser instance (for advanced usage)
|
|
1083
|
+
* Get the browser instance (for advanced usage); see {@link getPage}
|
|
1040
1084
|
* @returns Puppeteer browser or null
|
|
1041
1085
|
*/
|
|
1042
|
-
getBrowser():
|
|
1086
|
+
getBrowser<TBrowser = PuppeteerBrowserLike>(): TBrowser | null;
|
|
1043
1087
|
}
|
|
1044
1088
|
/**
|
|
1045
1089
|
* Check if Puppeteer is available
|
|
@@ -1072,6 +1116,14 @@ interface OverlayConfig {
|
|
|
1072
1116
|
showToolbar: boolean;
|
|
1073
1117
|
/** Highlight duration in ms (0 = persistent until cleared) */
|
|
1074
1118
|
highlightDuration: number;
|
|
1119
|
+
/**
|
|
1120
|
+
* Render-count thresholds used for the highlight colours and toolbar counts
|
|
1121
|
+
* (same meaning as the scanner thresholds; default warning 20, critical 50)
|
|
1122
|
+
*/
|
|
1123
|
+
thresholds?: {
|
|
1124
|
+
warning: number;
|
|
1125
|
+
critical: number;
|
|
1126
|
+
};
|
|
1075
1127
|
}
|
|
1076
1128
|
/**
|
|
1077
1129
|
* Overlay for visualizing React renders in the browser
|
|
@@ -1206,6 +1258,12 @@ declare class Overlay {
|
|
|
1206
1258
|
* Get severity level
|
|
1207
1259
|
*/
|
|
1208
1260
|
private getSeverity;
|
|
1261
|
+
/**
|
|
1262
|
+
* Severity for a render count using the configured thresholds (a count at or
|
|
1263
|
+
* above a threshold reaches that level, like the scanner's stats)
|
|
1264
|
+
* @param count - Render count
|
|
1265
|
+
*/
|
|
1266
|
+
private severityForCount;
|
|
1209
1267
|
/**
|
|
1210
1268
|
* Record a render event
|
|
1211
1269
|
*/
|
|
@@ -1458,6 +1516,8 @@ declare class ReactCheckInjector {
|
|
|
1458
1516
|
private restoreHook;
|
|
1459
1517
|
/** Window reference */
|
|
1460
1518
|
private win;
|
|
1519
|
+
/** React version last reported to the CLI in a `ready` message */
|
|
1520
|
+
private reportedReactVersion;
|
|
1461
1521
|
/**
|
|
1462
1522
|
* Create the injector
|
|
1463
1523
|
* @param win - Window object (defaults to the global window)
|
|
@@ -1521,6 +1581,10 @@ declare class ReactCheckInjector {
|
|
|
1521
1581
|
* @param config - New configuration
|
|
1522
1582
|
*/
|
|
1523
1583
|
private handleConfig;
|
|
1584
|
+
/**
|
|
1585
|
+
* Send a `ready` message with the React version detected so far
|
|
1586
|
+
*/
|
|
1587
|
+
private sendReady;
|
|
1524
1588
|
/**
|
|
1525
1589
|
* Send message to CLI
|
|
1526
1590
|
* @param message - Browser message
|
|
@@ -1556,7 +1620,7 @@ declare function installReactCheck(win: WindowWithReactDevTools): ReactCheckInje
|
|
|
1556
1620
|
* Package version (kept in sync with package.json; checked by tests)
|
|
1557
1621
|
* @packageDocumentation
|
|
1558
1622
|
*/
|
|
1559
|
-
declare const VERSION = "1.3.
|
|
1623
|
+
declare const VERSION = "1.3.1";
|
|
1560
1624
|
|
|
1561
1625
|
/**
|
|
1562
1626
|
* One-call programmatic scan of a URL
|
|
@@ -1669,4 +1733,4 @@ declare function createReportGenerator(options?: {
|
|
|
1669
1733
|
includeSourceCode?: boolean;
|
|
1670
1734
|
}): ReportGenerator;
|
|
1671
1735
|
|
|
1672
|
-
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, type QuickScanOptions, ReactCheckInjector, ReactDevToolsHook, RenderChainInfo, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, installReactCheck, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, loadInjectionScript, matchComponentPattern, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|
|
1736
|
+
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, type PuppeteerBrowserLike, type PuppeteerPageLike, type QuickScanOptions, ReactCheckInjector, ReactDevToolsHook, RenderChainInfo, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, installReactCheck, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, loadInjectionScript, matchComponentPattern, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as RenderChainInfo, d as ScannerConfig, W as WindowWithReactDevTools } from './types-
|
|
2
|
-
export { r as ComponentNode, h as ComponentStats, E as ErrorCode, u as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, q as ReactCheckConfig, s as ReactCheckError, t as ReactCheckEvents, p as ReactCheckOptions, n as RuleLevel, o as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-
|
|
3
|
-
import { S as Scanner } from './scanner-
|
|
4
|
-
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-
|
|
1
|
+
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as RenderChainInfo, d as ScannerConfig, W as WindowWithReactDevTools } from './types-BMDemwIs.js';
|
|
2
|
+
export { r as ComponentNode, h as ComponentStats, E as ErrorCode, u as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, q as ReactCheckConfig, s as ReactCheckError, t as ReactCheckEvents, p as ReactCheckOptions, n as RuleLevel, o as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-BMDemwIs.js';
|
|
3
|
+
import { S as Scanner } from './scanner-BJFA0354.js';
|
|
4
|
+
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-BJFA0354.js';
|
|
5
5
|
export { ChainAnalyzer, ChainEvents } from './chain.js';
|
|
6
6
|
export { FixEvents, FixSuggester } from './fix.js';
|
|
7
7
|
export { detectFramework, detectFrameworkFromWindow, frameworkDetectors, getFrameworkTips } from './detect.js';
|
|
8
8
|
import { E as EventEmitter } from './event-emitter-BVYUPYLd.js';
|
|
9
9
|
import * as node_net from 'node:net';
|
|
10
|
-
import * as puppeteer from 'puppeteer';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* React Fiber utilities for interacting with React internals
|
|
@@ -911,6 +910,11 @@ declare class ProxyServer extends EventEmitter<ProxyServerEvents> {
|
|
|
911
910
|
setInjectionScript(script: string): void;
|
|
912
911
|
}
|
|
913
912
|
|
|
913
|
+
/**
|
|
914
|
+
* Browser launcher using Puppeteer
|
|
915
|
+
* @packageDocumentation
|
|
916
|
+
*/
|
|
917
|
+
|
|
914
918
|
/**
|
|
915
919
|
* Browser launch options
|
|
916
920
|
*/
|
|
@@ -956,8 +960,46 @@ interface BrowserEvents {
|
|
|
956
960
|
/** Browser closed */
|
|
957
961
|
closed: void;
|
|
958
962
|
}
|
|
959
|
-
|
|
960
|
-
|
|
963
|
+
/**
|
|
964
|
+
* The commonly used part of Puppeteer's `Page`, typed structurally so that the
|
|
965
|
+
* package's types work without Puppeteer installed. For the full API pass
|
|
966
|
+
* Puppeteer's type: `launcher.getPage<import('puppeteer').Page>()`.
|
|
967
|
+
*/
|
|
968
|
+
interface PuppeteerPageLike {
|
|
969
|
+
/** Navigate to a URL */
|
|
970
|
+
goto(url: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
971
|
+
/** Click the first element matching a selector */
|
|
972
|
+
click(selector: string, options?: Record<string, unknown>): Promise<void>;
|
|
973
|
+
/** Type text into the element matching a selector */
|
|
974
|
+
type(selector: string, text: string, options?: Record<string, unknown>): Promise<void>;
|
|
975
|
+
/** Focus the element matching a selector */
|
|
976
|
+
focus(selector: string): Promise<void>;
|
|
977
|
+
/** Hover the element matching a selector */
|
|
978
|
+
hover(selector: string): Promise<void>;
|
|
979
|
+
/** Wait for an element matching a selector */
|
|
980
|
+
waitForSelector(selector: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
981
|
+
/** Evaluate a function or expression in the page */
|
|
982
|
+
evaluate<T>(fn: string | (() => T)): Promise<T>;
|
|
983
|
+
/** Take a screenshot */
|
|
984
|
+
screenshot(options?: Record<string, unknown>): Promise<unknown>;
|
|
985
|
+
/** Reload the page */
|
|
986
|
+
reload(options?: Record<string, unknown>): Promise<unknown>;
|
|
987
|
+
/** Current URL */
|
|
988
|
+
url(): string;
|
|
989
|
+
/** Close the page */
|
|
990
|
+
close(): Promise<void>;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* The commonly used part of Puppeteer's `Browser` (see {@link PuppeteerPageLike})
|
|
994
|
+
*/
|
|
995
|
+
interface PuppeteerBrowserLike {
|
|
996
|
+
/** Whether the browser is still connected */
|
|
997
|
+
readonly connected: boolean;
|
|
998
|
+
/** Open a new page */
|
|
999
|
+
newPage(): Promise<PuppeteerPageLike>;
|
|
1000
|
+
/** Close the browser */
|
|
1001
|
+
close(): Promise<void>;
|
|
1002
|
+
}
|
|
961
1003
|
/**
|
|
962
1004
|
* Browser launcher wrapper around Puppeteer
|
|
963
1005
|
*/
|
|
@@ -1031,15 +1073,17 @@ declare class BrowserLauncher extends EventEmitter<BrowserEvents> {
|
|
|
1031
1073
|
*/
|
|
1032
1074
|
isOpen(): boolean;
|
|
1033
1075
|
/**
|
|
1034
|
-
* Get the page instance (for advanced usage)
|
|
1076
|
+
* Get the page instance (for advanced usage). The return type is a
|
|
1077
|
+
* structural subset of Puppeteer's `Page`; pass the real type for the full
|
|
1078
|
+
* API: `getPage<import('puppeteer').Page>()`.
|
|
1035
1079
|
* @returns Puppeteer page or null
|
|
1036
1080
|
*/
|
|
1037
|
-
getPage():
|
|
1081
|
+
getPage<TPage = PuppeteerPageLike>(): TPage | null;
|
|
1038
1082
|
/**
|
|
1039
|
-
* Get the browser instance (for advanced usage)
|
|
1083
|
+
* Get the browser instance (for advanced usage); see {@link getPage}
|
|
1040
1084
|
* @returns Puppeteer browser or null
|
|
1041
1085
|
*/
|
|
1042
|
-
getBrowser():
|
|
1086
|
+
getBrowser<TBrowser = PuppeteerBrowserLike>(): TBrowser | null;
|
|
1043
1087
|
}
|
|
1044
1088
|
/**
|
|
1045
1089
|
* Check if Puppeteer is available
|
|
@@ -1072,6 +1116,14 @@ interface OverlayConfig {
|
|
|
1072
1116
|
showToolbar: boolean;
|
|
1073
1117
|
/** Highlight duration in ms (0 = persistent until cleared) */
|
|
1074
1118
|
highlightDuration: number;
|
|
1119
|
+
/**
|
|
1120
|
+
* Render-count thresholds used for the highlight colours and toolbar counts
|
|
1121
|
+
* (same meaning as the scanner thresholds; default warning 20, critical 50)
|
|
1122
|
+
*/
|
|
1123
|
+
thresholds?: {
|
|
1124
|
+
warning: number;
|
|
1125
|
+
critical: number;
|
|
1126
|
+
};
|
|
1075
1127
|
}
|
|
1076
1128
|
/**
|
|
1077
1129
|
* Overlay for visualizing React renders in the browser
|
|
@@ -1206,6 +1258,12 @@ declare class Overlay {
|
|
|
1206
1258
|
* Get severity level
|
|
1207
1259
|
*/
|
|
1208
1260
|
private getSeverity;
|
|
1261
|
+
/**
|
|
1262
|
+
* Severity for a render count using the configured thresholds (a count at or
|
|
1263
|
+
* above a threshold reaches that level, like the scanner's stats)
|
|
1264
|
+
* @param count - Render count
|
|
1265
|
+
*/
|
|
1266
|
+
private severityForCount;
|
|
1209
1267
|
/**
|
|
1210
1268
|
* Record a render event
|
|
1211
1269
|
*/
|
|
@@ -1458,6 +1516,8 @@ declare class ReactCheckInjector {
|
|
|
1458
1516
|
private restoreHook;
|
|
1459
1517
|
/** Window reference */
|
|
1460
1518
|
private win;
|
|
1519
|
+
/** React version last reported to the CLI in a `ready` message */
|
|
1520
|
+
private reportedReactVersion;
|
|
1461
1521
|
/**
|
|
1462
1522
|
* Create the injector
|
|
1463
1523
|
* @param win - Window object (defaults to the global window)
|
|
@@ -1521,6 +1581,10 @@ declare class ReactCheckInjector {
|
|
|
1521
1581
|
* @param config - New configuration
|
|
1522
1582
|
*/
|
|
1523
1583
|
private handleConfig;
|
|
1584
|
+
/**
|
|
1585
|
+
* Send a `ready` message with the React version detected so far
|
|
1586
|
+
*/
|
|
1587
|
+
private sendReady;
|
|
1524
1588
|
/**
|
|
1525
1589
|
* Send message to CLI
|
|
1526
1590
|
* @param message - Browser message
|
|
@@ -1556,7 +1620,7 @@ declare function installReactCheck(win: WindowWithReactDevTools): ReactCheckInje
|
|
|
1556
1620
|
* Package version (kept in sync with package.json; checked by tests)
|
|
1557
1621
|
* @packageDocumentation
|
|
1558
1622
|
*/
|
|
1559
|
-
declare const VERSION = "1.3.
|
|
1623
|
+
declare const VERSION = "1.3.1";
|
|
1560
1624
|
|
|
1561
1625
|
/**
|
|
1562
1626
|
* One-call programmatic scan of a URL
|
|
@@ -1669,4 +1733,4 @@ declare function createReportGenerator(options?: {
|
|
|
1669
1733
|
includeSourceCode?: boolean;
|
|
1670
1734
|
}): ReportGenerator;
|
|
1671
1735
|
|
|
1672
|
-
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, type QuickScanOptions, ReactCheckInjector, ReactDevToolsHook, RenderChainInfo, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, installReactCheck, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, loadInjectionScript, matchComponentPattern, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|
|
1736
|
+
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, type PuppeteerBrowserLike, type PuppeteerPageLike, type QuickScanOptions, ReactCheckInjector, ReactDevToolsHook, RenderChainInfo, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, installReactCheck, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, loadInjectionScript, matchComponentPattern, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { matchComponentPattern, Scanner } from './chunk-
|
|
2
|
-
export { Scanner, StatsCollector, matchComponentPattern } from './chunk-
|
|
1
|
+
import { matchComponentPattern, Scanner } from './chunk-35I3PLS3.js';
|
|
2
|
+
export { Scanner, StatsCollector, matchComponentPattern } from './chunk-35I3PLS3.js';
|
|
3
3
|
export { ChainAnalyzer } from './chunk-RQYHXWUC.js';
|
|
4
|
-
export { FixSuggester } from './chunk-
|
|
4
|
+
export { FixSuggester } from './chunk-PIXJPQO7.js';
|
|
5
5
|
import { EventEmitter } from './chunk-WLN7ZVO4.js';
|
|
6
6
|
export { EventEmitter } from './chunk-WLN7ZVO4.js';
|
|
7
|
-
import { ensureDir, joinPath, writeTextFile } from './chunk-
|
|
8
|
-
export { detectFramework, detectFrameworkFromWindow, ensureDir, exists, findUp, FRAMEWORK_DETECTORS as frameworkDetectors, getBaseName, getDirName, getExtension, getFrameworkTips, joinPath, readJsonFile, readTextFile, resolvePath, writeJsonFile, writeTextFile } from './chunk-
|
|
7
|
+
import { ensureDir, joinPath, writeTextFile } from './chunk-REEPUD73.js';
|
|
8
|
+
export { detectFramework, detectFrameworkFromWindow, ensureDir, exists, findUp, FRAMEWORK_DETECTORS as frameworkDetectors, getBaseName, getDirName, getExtension, getFrameworkTips, joinPath, readJsonFile, readTextFile, resolvePath, writeJsonFile, writeTextFile } from './chunk-REEPUD73.js';
|
|
9
9
|
import { createServer, request as request$1 } from 'http';
|
|
10
10
|
import { createHash } from 'crypto';
|
|
11
11
|
import { request } from 'https';
|
|
12
12
|
import { URL, fileURLToPath } from 'url';
|
|
13
13
|
import { readFile } from 'fs/promises';
|
|
14
|
-
import { dirname, resolve } from 'path';
|
|
14
|
+
import { dirname, resolve, join } from 'path';
|
|
15
|
+
import { createRequire } from 'module';
|
|
16
|
+
import { homedir } from 'os';
|
|
15
17
|
|
|
16
18
|
// src/types.ts
|
|
17
19
|
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
@@ -242,7 +244,7 @@ function createRenderInfo(fiber, phase, prevProps, prevState) {
|
|
|
242
244
|
const renderTime = fiber.actualDuration ?? 0;
|
|
243
245
|
const changedProps = prevProps ? getChangedProps(prevProps, fiber.memoizedProps) : void 0;
|
|
244
246
|
const propsChanged = changedProps && changedProps.length > 0;
|
|
245
|
-
const stateChanged = prevState !== fiber.memoizedState;
|
|
247
|
+
const stateChanged = phase === "update" && prevState !== fiber.memoizedState;
|
|
246
248
|
const necessary = phase === "mount" || propsChanged || stateChanged;
|
|
247
249
|
const result = {
|
|
248
250
|
componentName,
|
|
@@ -2335,6 +2337,38 @@ var ProxyServer = class extends EventEmitter {
|
|
|
2335
2337
|
this.injectionScript = script;
|
|
2336
2338
|
}
|
|
2337
2339
|
};
|
|
2340
|
+
function getPuppeteerInstallDir(env = process.env, platform = process.platform, home = homedir()) {
|
|
2341
|
+
const explicit = env["REACTCHECK_PUPPETEER_DIR"];
|
|
2342
|
+
if (explicit !== void 0 && explicit !== "") return explicit;
|
|
2343
|
+
const cacheRoot = platform === "win32" ? env["LOCALAPPDATA"] !== void 0 && env["LOCALAPPDATA"] !== "" ? env["LOCALAPPDATA"] : join(home, "AppData", "Local") : env["XDG_CACHE_HOME"] !== void 0 && env["XDG_CACHE_HOME"] !== "" ? env["XDG_CACHE_HOME"] : join(home, ".cache");
|
|
2344
|
+
return join(cacheRoot, "react-check", "puppeteer");
|
|
2345
|
+
}
|
|
2346
|
+
function toPuppeteer(loaded) {
|
|
2347
|
+
const candidates = [
|
|
2348
|
+
loaded?.default,
|
|
2349
|
+
loaded,
|
|
2350
|
+
loaded?.default?.default
|
|
2351
|
+
];
|
|
2352
|
+
for (const candidate of candidates) {
|
|
2353
|
+
if (candidate !== null && typeof candidate === "object" && typeof candidate.launch === "function") {
|
|
2354
|
+
return candidate;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
return null;
|
|
2358
|
+
}
|
|
2359
|
+
async function loadPuppeteer(installDir = getPuppeteerInstallDir()) {
|
|
2360
|
+
try {
|
|
2361
|
+
const found = toPuppeteer(await import('puppeteer'));
|
|
2362
|
+
if (found) return found;
|
|
2363
|
+
} catch {
|
|
2364
|
+
}
|
|
2365
|
+
try {
|
|
2366
|
+
const requireFromDir = createRequire(join(installDir, "package.json"));
|
|
2367
|
+
return toPuppeteer(requireFromDir("puppeteer"));
|
|
2368
|
+
} catch {
|
|
2369
|
+
return null;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2338
2372
|
|
|
2339
2373
|
// src/server/browser.ts
|
|
2340
2374
|
var logger3 = new Logger({ prefix: "browser", level: 1 /* INFO */ });
|
|
@@ -2376,7 +2410,10 @@ var BrowserLauncher = class extends EventEmitter {
|
|
|
2376
2410
|
*/
|
|
2377
2411
|
async launch() {
|
|
2378
2412
|
try {
|
|
2379
|
-
const puppeteer = await
|
|
2413
|
+
const puppeteer = await loadPuppeteer();
|
|
2414
|
+
if (!puppeteer) {
|
|
2415
|
+
throw new Error("Puppeteer is not installed. Install it with: npm install puppeteer");
|
|
2416
|
+
}
|
|
2380
2417
|
const args = [
|
|
2381
2418
|
"--no-sandbox",
|
|
2382
2419
|
"--disable-setuid-sandbox",
|
|
@@ -2387,7 +2424,7 @@ var BrowserLauncher = class extends EventEmitter {
|
|
|
2387
2424
|
`--window-size=${this.options.width},${this.options.height}`,
|
|
2388
2425
|
...this.options.args
|
|
2389
2426
|
];
|
|
2390
|
-
this.browser = await puppeteer.
|
|
2427
|
+
this.browser = await puppeteer.launch({
|
|
2391
2428
|
headless: this.options.headless,
|
|
2392
2429
|
args,
|
|
2393
2430
|
slowMo: this.options.slowMo,
|
|
@@ -2540,14 +2577,16 @@ var BrowserLauncher = class extends EventEmitter {
|
|
|
2540
2577
|
return this.browser !== null && this.browser.connected;
|
|
2541
2578
|
}
|
|
2542
2579
|
/**
|
|
2543
|
-
* Get the page instance (for advanced usage)
|
|
2580
|
+
* Get the page instance (for advanced usage). The return type is a
|
|
2581
|
+
* structural subset of Puppeteer's `Page`; pass the real type for the full
|
|
2582
|
+
* API: `getPage<import('puppeteer').Page>()`.
|
|
2544
2583
|
* @returns Puppeteer page or null
|
|
2545
2584
|
*/
|
|
2546
2585
|
getPage() {
|
|
2547
2586
|
return this.page;
|
|
2548
2587
|
}
|
|
2549
2588
|
/**
|
|
2550
|
-
* Get the browser instance (for advanced usage)
|
|
2589
|
+
* Get the browser instance (for advanced usage); see {@link getPage}
|
|
2551
2590
|
* @returns Puppeteer browser or null
|
|
2552
2591
|
*/
|
|
2553
2592
|
getBrowser() {
|
|
@@ -2555,18 +2594,14 @@ var BrowserLauncher = class extends EventEmitter {
|
|
|
2555
2594
|
}
|
|
2556
2595
|
};
|
|
2557
2596
|
async function isPuppeteerAvailable() {
|
|
2558
|
-
|
|
2559
|
-
await import('puppeteer');
|
|
2560
|
-
return true;
|
|
2561
|
-
} catch {
|
|
2562
|
-
return false;
|
|
2563
|
-
}
|
|
2597
|
+
return await loadPuppeteer() !== null;
|
|
2564
2598
|
}
|
|
2565
2599
|
|
|
2566
2600
|
// src/browser/overlay.ts
|
|
2567
2601
|
function escapeOverlayHtml(value) {
|
|
2568
2602
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2569
2603
|
}
|
|
2604
|
+
var DEFAULT_OVERLAY_THRESHOLDS = { warning: 20, critical: 50 };
|
|
2570
2605
|
var DEFAULT_CONFIG = {
|
|
2571
2606
|
enabled: true,
|
|
2572
2607
|
highlightRenders: true,
|
|
@@ -3808,8 +3843,17 @@ var Overlay = class _Overlay {
|
|
|
3808
3843
|
*/
|
|
3809
3844
|
getSeverity(render) {
|
|
3810
3845
|
if (!render.necessary) return "unnecessary";
|
|
3811
|
-
|
|
3812
|
-
|
|
3846
|
+
return this.severityForCount(render.renderCount);
|
|
3847
|
+
}
|
|
3848
|
+
/**
|
|
3849
|
+
* Severity for a render count using the configured thresholds (a count at or
|
|
3850
|
+
* above a threshold reaches that level, like the scanner's stats)
|
|
3851
|
+
* @param count - Render count
|
|
3852
|
+
*/
|
|
3853
|
+
severityForCount(count) {
|
|
3854
|
+
const { warning, critical } = this.config.thresholds ?? DEFAULT_OVERLAY_THRESHOLDS;
|
|
3855
|
+
if (count >= critical) return "critical";
|
|
3856
|
+
if (count >= warning) return "warning";
|
|
3813
3857
|
return "healthy";
|
|
3814
3858
|
}
|
|
3815
3859
|
/**
|
|
@@ -3837,8 +3881,9 @@ var Overlay = class _Overlay {
|
|
|
3837
3881
|
let warning = 0;
|
|
3838
3882
|
let healthy = 0;
|
|
3839
3883
|
for (const tracked of this.trackedComponents.values()) {
|
|
3840
|
-
|
|
3841
|
-
|
|
3884
|
+
const level = this.severityForCount(tracked.count);
|
|
3885
|
+
if (level === "critical") critical++;
|
|
3886
|
+
else if (level === "warning") warning++;
|
|
3842
3887
|
else healthy++;
|
|
3843
3888
|
}
|
|
3844
3889
|
const criticalEl = this.shadowRoot.getElementById("rc-critical");
|
|
@@ -4231,7 +4276,7 @@ var BrowserScanner = class extends EventEmitter {
|
|
|
4231
4276
|
* @param fiber - Fiber to process
|
|
4232
4277
|
* @param parent - Parent component name
|
|
4233
4278
|
*/
|
|
4234
|
-
processFiber(fiber,
|
|
4279
|
+
processFiber(fiber, parent) {
|
|
4235
4280
|
const componentName = getComponentName(fiber);
|
|
4236
4281
|
if (this.shouldFilterComponent(componentName)) {
|
|
4237
4282
|
return;
|
|
@@ -4248,6 +4293,9 @@ var BrowserScanner = class extends EventEmitter {
|
|
|
4248
4293
|
const newCount = currentCount + 1;
|
|
4249
4294
|
this.renderCounts.set(componentName, newCount);
|
|
4250
4295
|
renderInfo.renderCount = newCount;
|
|
4296
|
+
if (parent) {
|
|
4297
|
+
renderInfo.parent = parent;
|
|
4298
|
+
}
|
|
4251
4299
|
const domElement = this.getDOMElement(fiber);
|
|
4252
4300
|
if (this.overlay && this.config.highlightRenders) {
|
|
4253
4301
|
if (domElement) {
|
|
@@ -4314,6 +4362,15 @@ var BrowserScanner = class extends EventEmitter {
|
|
|
4314
4362
|
* @returns React version string
|
|
4315
4363
|
*/
|
|
4316
4364
|
getReactVersion() {
|
|
4365
|
+
if (this.reactVersion.startsWith("unknown")) {
|
|
4366
|
+
const hook = this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
4367
|
+
if (hook?.renderers instanceof Map) {
|
|
4368
|
+
const version = this.detectReactVersion(hook);
|
|
4369
|
+
if (version !== "unknown") {
|
|
4370
|
+
this.reactVersion = version;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4317
4374
|
return this.reactVersion;
|
|
4318
4375
|
}
|
|
4319
4376
|
/**
|
|
@@ -4364,6 +4421,8 @@ var ReactCheckInjector = class {
|
|
|
4364
4421
|
restoreHook = null;
|
|
4365
4422
|
/** Window reference */
|
|
4366
4423
|
win;
|
|
4424
|
+
/** React version last reported to the CLI in a `ready` message */
|
|
4425
|
+
reportedReactVersion = "unknown";
|
|
4367
4426
|
/**
|
|
4368
4427
|
* Create the injector
|
|
4369
4428
|
* @param win - Window object (defaults to the global window)
|
|
@@ -4420,6 +4479,12 @@ var ReactCheckInjector = class {
|
|
|
4420
4479
|
*/
|
|
4421
4480
|
setupScannerEvents() {
|
|
4422
4481
|
this.scanner.on("render", ({ render, element }) => {
|
|
4482
|
+
if (this.reportedReactVersion.startsWith("unknown") && this.ws?.readyState === WebSocket.OPEN) {
|
|
4483
|
+
const version = this.scanner.getReactVersion();
|
|
4484
|
+
if (!version.startsWith("unknown")) {
|
|
4485
|
+
this.sendReady();
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4423
4488
|
this.send({ type: "render", payload: render });
|
|
4424
4489
|
this.overlay.recordRender(render);
|
|
4425
4490
|
if (element) {
|
|
@@ -4481,10 +4546,7 @@ var ReactCheckInjector = class {
|
|
|
4481
4546
|
clearTimeout(this.reconnectTimeout);
|
|
4482
4547
|
this.reconnectTimeout = null;
|
|
4483
4548
|
}
|
|
4484
|
-
this.
|
|
4485
|
-
type: "ready",
|
|
4486
|
-
payload: { reactVersion: this.scanner.getReactVersion() }
|
|
4487
|
-
});
|
|
4549
|
+
this.sendReady();
|
|
4488
4550
|
this.flushMessageQueue();
|
|
4489
4551
|
};
|
|
4490
4552
|
ws.onmessage = (event) => {
|
|
@@ -4595,6 +4657,20 @@ var ReactCheckInjector = class {
|
|
|
4595
4657
|
if (config.highlightRenders !== void 0) {
|
|
4596
4658
|
this.overlay.configure({ highlightRenders: config.highlightRenders });
|
|
4597
4659
|
}
|
|
4660
|
+
const thresholds = config.thresholds;
|
|
4661
|
+
if (thresholds && Number.isFinite(thresholds.warning) && Number.isFinite(thresholds.critical)) {
|
|
4662
|
+
this.overlay.configure({ thresholds: { warning: thresholds.warning, critical: thresholds.critical } });
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
/**
|
|
4666
|
+
* Send a `ready` message with the React version detected so far
|
|
4667
|
+
*/
|
|
4668
|
+
sendReady() {
|
|
4669
|
+
this.reportedReactVersion = this.scanner.getReactVersion();
|
|
4670
|
+
this.send({
|
|
4671
|
+
type: "ready",
|
|
4672
|
+
payload: { reactVersion: this.reportedReactVersion }
|
|
4673
|
+
});
|
|
4598
4674
|
}
|
|
4599
4675
|
/**
|
|
4600
4676
|
* Send message to CLI
|
|
@@ -4720,7 +4796,7 @@ function installReactCheck(win) {
|
|
|
4720
4796
|
}
|
|
4721
4797
|
|
|
4722
4798
|
// src/version.ts
|
|
4723
|
-
var VERSION = "1.3.
|
|
4799
|
+
var VERSION = "1.3.1";
|
|
4724
4800
|
|
|
4725
4801
|
// src/quick-scan.ts
|
|
4726
4802
|
async function quickScan(url, options = {}) {
|
|
@@ -4733,10 +4809,12 @@ async function quickScan(url, options = {}) {
|
|
|
4733
4809
|
const target = url.includes("://") ? url : `http://${url}`;
|
|
4734
4810
|
const duration = options.duration ?? 3e4;
|
|
4735
4811
|
const startTime = Date.now();
|
|
4812
|
+
const critical = options.thresholds?.critical ?? 50;
|
|
4813
|
+
const warning = options.thresholds?.warning ?? 20;
|
|
4736
4814
|
const scanner = new Scanner({
|
|
4737
4815
|
thresholds: {
|
|
4738
|
-
critical
|
|
4739
|
-
warning
|
|
4816
|
+
critical,
|
|
4817
|
+
warning,
|
|
4740
4818
|
...options.thresholds?.fps !== void 0 ? { fps: options.thresholds.fps } : {}
|
|
4741
4819
|
},
|
|
4742
4820
|
config: {
|
|
@@ -4745,15 +4823,9 @@ async function quickScan(url, options = {}) {
|
|
|
4745
4823
|
}
|
|
4746
4824
|
});
|
|
4747
4825
|
const chains = [];
|
|
4748
|
-
const suggestions = [];
|
|
4749
4826
|
scanner.on("chain", (chain) => {
|
|
4750
4827
|
chains.push(chain);
|
|
4751
4828
|
});
|
|
4752
|
-
scanner.on("fix", (suggestion) => {
|
|
4753
|
-
if (!suggestions.some((s) => s.componentName === suggestion.componentName && s.fix === suggestion.fix)) {
|
|
4754
|
-
suggestions.push(suggestion);
|
|
4755
|
-
}
|
|
4756
|
-
});
|
|
4757
4829
|
const wsServer = new WebSocketServer(options.port ?? 0);
|
|
4758
4830
|
let launcher = null;
|
|
4759
4831
|
try {
|
|
@@ -4769,6 +4841,7 @@ async function quickScan(url, options = {}) {
|
|
|
4769
4841
|
break;
|
|
4770
4842
|
case "ready":
|
|
4771
4843
|
client.send(JSON.stringify({ type: "start" }));
|
|
4844
|
+
client.send(JSON.stringify({ type: "config", payload: { thresholds: { warning, critical } } }));
|
|
4772
4845
|
break;
|
|
4773
4846
|
default:
|
|
4774
4847
|
break;
|
|
@@ -4822,7 +4895,8 @@ async function quickScan(url, options = {}) {
|
|
|
4822
4895
|
chains,
|
|
4823
4896
|
timeline: [],
|
|
4824
4897
|
framework: null,
|
|
4825
|
-
suggestions
|
|
4898
|
+
// Regenerated from the final stats (suggestions made mid-scan go stale)
|
|
4899
|
+
suggestions: exported.suggestions
|
|
4826
4900
|
};
|
|
4827
4901
|
if (options.output) {
|
|
4828
4902
|
const generator = new ReportGenerator({
|