@oxog/react-check 1.0.3 → 1.1.0
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 +58 -0
- package/README.md +54 -0
- package/dist/browser-inject.global.js +3 -3
- package/dist/cli.js +1447 -101
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { dirname, resolve, join, extname, basename } from 'path';
|
|
|
5
5
|
import { createServer } from 'http';
|
|
6
6
|
import { createHash } from 'crypto';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
+
import { exec } from 'child_process';
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -277,7 +278,7 @@ function generateHTMLReport(report) {
|
|
|
277
278
|
<meta charset="UTF-8">
|
|
278
279
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
279
280
|
<title>ReactCheck Report - ${escapeHtml(report.session.url)}</title>
|
|
280
|
-
<style>${
|
|
281
|
+
<style>${getStyles2()}</style>
|
|
281
282
|
</head>
|
|
282
283
|
<body>
|
|
283
284
|
<div class="container">
|
|
@@ -289,11 +290,11 @@ function generateHTMLReport(report) {
|
|
|
289
290
|
${renderAllComponents(report)}
|
|
290
291
|
${renderFooter(report)}
|
|
291
292
|
</div>
|
|
292
|
-
<script>${
|
|
293
|
+
<script>${getScript2()}</script>
|
|
293
294
|
</body>
|
|
294
295
|
</html>`;
|
|
295
296
|
}
|
|
296
|
-
function
|
|
297
|
+
function getStyles2() {
|
|
297
298
|
return `
|
|
298
299
|
:root {
|
|
299
300
|
--bg-primary: #0a0a0a;
|
|
@@ -567,7 +568,7 @@ function getStyles() {
|
|
|
567
568
|
}
|
|
568
569
|
`;
|
|
569
570
|
}
|
|
570
|
-
function
|
|
571
|
+
function getScript2() {
|
|
571
572
|
return `
|
|
572
573
|
// Toggle collapsible sections
|
|
573
574
|
document.querySelectorAll('.collapsible').forEach(el => {
|
|
@@ -1200,6 +1201,16 @@ var FLAG_DEFINITIONS = {
|
|
|
1200
1201
|
short: "w",
|
|
1201
1202
|
description: "Watch mode - keep scanning until quit",
|
|
1202
1203
|
default: false
|
|
1204
|
+
},
|
|
1205
|
+
webui: {
|
|
1206
|
+
short: "W",
|
|
1207
|
+
description: "Enable WebUI dashboard",
|
|
1208
|
+
default: false
|
|
1209
|
+
},
|
|
1210
|
+
"webui-port": {
|
|
1211
|
+
description: "WebUI dashboard port",
|
|
1212
|
+
takesValue: true,
|
|
1213
|
+
default: "3100"
|
|
1203
1214
|
}
|
|
1204
1215
|
};
|
|
1205
1216
|
function buildShortFlagMap() {
|
|
@@ -1232,6 +1243,11 @@ function parseArgs(argv) {
|
|
|
1232
1243
|
continue;
|
|
1233
1244
|
}
|
|
1234
1245
|
if (i === 0 || result.positional.length === 0 && !result.target) {
|
|
1246
|
+
if (arg === "scan") {
|
|
1247
|
+
result.command = "scan";
|
|
1248
|
+
i++;
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1235
1251
|
if (arg === "init") {
|
|
1236
1252
|
result.command = "init";
|
|
1237
1253
|
i++;
|
|
@@ -4870,6 +4886,8 @@ var TUI = class extends EventEmitter {
|
|
|
4870
4886
|
renderInterval = null;
|
|
4871
4887
|
/** Spinner frame */
|
|
4872
4888
|
spinnerFrame = 0;
|
|
4889
|
+
/** Data provider function for polling */
|
|
4890
|
+
dataProvider = null;
|
|
4873
4891
|
/**
|
|
4874
4892
|
* Create a new TUI
|
|
4875
4893
|
* @param target - Target URL
|
|
@@ -4926,10 +4944,28 @@ var TUI = class extends EventEmitter {
|
|
|
4926
4944
|
});
|
|
4927
4945
|
this.renderInterval = setInterval(() => {
|
|
4928
4946
|
this.spinnerFrame++;
|
|
4947
|
+
if (this.dataProvider) {
|
|
4948
|
+
try {
|
|
4949
|
+
const data = this.dataProvider();
|
|
4950
|
+
this.state = { ...this.state, ...data };
|
|
4951
|
+
if (data.components && data.components.length > 0) {
|
|
4952
|
+
const items = createComponentListItems(data.components);
|
|
4953
|
+
this.componentList.setItems(items);
|
|
4954
|
+
}
|
|
4955
|
+
} catch {
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4929
4958
|
this.render();
|
|
4930
4959
|
}, 250);
|
|
4931
4960
|
this.render();
|
|
4932
4961
|
}
|
|
4962
|
+
/**
|
|
4963
|
+
* Set data provider for polling
|
|
4964
|
+
* @param provider - Function that returns current data
|
|
4965
|
+
*/
|
|
4966
|
+
setDataProvider(provider) {
|
|
4967
|
+
this.dataProvider = provider;
|
|
4968
|
+
}
|
|
4933
4969
|
/**
|
|
4934
4970
|
* Stop the TUI
|
|
4935
4971
|
*/
|
|
@@ -4989,7 +5025,7 @@ var TUI = class extends EventEmitter {
|
|
|
4989
5025
|
}
|
|
4990
5026
|
drawDivider(this.screen, 0, height - 3, width, "single", colors.gray);
|
|
4991
5027
|
this.renderFooter(1, height - 2, width - 2);
|
|
4992
|
-
this.screen.render();
|
|
5028
|
+
this.screen.render(true);
|
|
4993
5029
|
}
|
|
4994
5030
|
/**
|
|
4995
5031
|
* Render header
|
|
@@ -5738,105 +5774,1366 @@ async function isPuppeteerAvailable() {
|
|
|
5738
5774
|
|
|
5739
5775
|
// src/cli/commands/scan.ts
|
|
5740
5776
|
init_fs();
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5777
|
+
|
|
5778
|
+
// src/webui/dashboard.ts
|
|
5779
|
+
function generateDashboardHTML(wsPort, target) {
|
|
5780
|
+
return `<!DOCTYPE html>
|
|
5781
|
+
<html lang="en">
|
|
5782
|
+
<head>
|
|
5783
|
+
<meta charset="UTF-8">
|
|
5784
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5785
|
+
<title>ReactCheck Dashboard</title>
|
|
5786
|
+
<style>${getStyles()}</style>
|
|
5787
|
+
</head>
|
|
5788
|
+
<body>
|
|
5789
|
+
<div class="container">
|
|
5790
|
+
<header class="header">
|
|
5791
|
+
<div class="header-left">
|
|
5792
|
+
<h1>
|
|
5793
|
+
<span class="logo">\u269B\uFE0F</span>
|
|
5794
|
+
ReactCheck
|
|
5795
|
+
<span class="status" id="status">
|
|
5796
|
+
<span class="status-dot"></span>
|
|
5797
|
+
<span class="status-text">Connecting...</span>
|
|
5798
|
+
</span>
|
|
5799
|
+
</h1>
|
|
5800
|
+
<div class="header-meta">
|
|
5801
|
+
<span id="target">Target: ${escapeHtml2(target)}</span>
|
|
5802
|
+
<span class="separator">\u2022</span>
|
|
5803
|
+
<span id="duration">Duration: 0s</span>
|
|
5804
|
+
</div>
|
|
5805
|
+
</div>
|
|
5806
|
+
<div class="header-right">
|
|
5807
|
+
<button id="export-btn" class="btn btn-secondary" disabled>Export Report</button>
|
|
5808
|
+
</div>
|
|
5809
|
+
</header>
|
|
5810
|
+
|
|
5811
|
+
<section class="summary">
|
|
5812
|
+
<div class="summary-grid">
|
|
5813
|
+
<div class="summary-card">
|
|
5814
|
+
<div class="summary-value info" id="components">0</div>
|
|
5815
|
+
<div class="summary-label">Components</div>
|
|
5816
|
+
</div>
|
|
5817
|
+
<div class="summary-card">
|
|
5818
|
+
<div class="summary-value" id="renders">0</div>
|
|
5819
|
+
<div class="summary-label">Total Renders</div>
|
|
5820
|
+
</div>
|
|
5821
|
+
<div class="summary-card">
|
|
5822
|
+
<div class="summary-value critical" id="critical">0</div>
|
|
5823
|
+
<div class="summary-label">Critical</div>
|
|
5824
|
+
</div>
|
|
5825
|
+
<div class="summary-card">
|
|
5826
|
+
<div class="summary-value warning" id="warnings">0</div>
|
|
5827
|
+
<div class="summary-label">Warnings</div>
|
|
5828
|
+
</div>
|
|
5829
|
+
<div class="summary-card">
|
|
5830
|
+
<div class="summary-value healthy" id="healthy">0</div>
|
|
5831
|
+
<div class="summary-label">Healthy</div>
|
|
5832
|
+
</div>
|
|
5833
|
+
<div class="summary-card">
|
|
5834
|
+
<div class="summary-value" id="fps">60</div>
|
|
5835
|
+
<div class="summary-label">Avg FPS</div>
|
|
5836
|
+
</div>
|
|
5837
|
+
</div>
|
|
5838
|
+
</section>
|
|
5839
|
+
|
|
5840
|
+
<section class="content">
|
|
5841
|
+
<div class="panel components-panel">
|
|
5842
|
+
<div class="panel-header">
|
|
5843
|
+
<h2>Components</h2>
|
|
5844
|
+
<input type="text" id="search" placeholder="Search components..." class="search-input">
|
|
5845
|
+
</div>
|
|
5846
|
+
<div class="table-container">
|
|
5847
|
+
<table class="component-table">
|
|
5848
|
+
<thead>
|
|
5849
|
+
<tr>
|
|
5850
|
+
<th class="sortable" data-sort="name">Component</th>
|
|
5851
|
+
<th class="sortable" data-sort="renders">Renders</th>
|
|
5852
|
+
<th class="sortable" data-sort="unnecessary">Unnecessary</th>
|
|
5853
|
+
<th class="sortable" data-sort="avgTime">Avg Time</th>
|
|
5854
|
+
<th class="sortable" data-sort="severity">Severity</th>
|
|
5855
|
+
</tr>
|
|
5856
|
+
</thead>
|
|
5857
|
+
<tbody id="component-list">
|
|
5858
|
+
<tr class="empty-row">
|
|
5859
|
+
<td colspan="5">Waiting for data...</td>
|
|
5860
|
+
</tr>
|
|
5861
|
+
</tbody>
|
|
5862
|
+
</table>
|
|
5863
|
+
</div>
|
|
5864
|
+
</div>
|
|
5865
|
+
|
|
5866
|
+
<div class="panel events-panel">
|
|
5867
|
+
<div class="panel-header">
|
|
5868
|
+
<h2>Live Events</h2>
|
|
5869
|
+
<span class="event-count" id="event-count">0 events</span>
|
|
5870
|
+
</div>
|
|
5871
|
+
<div class="events-container" id="events">
|
|
5872
|
+
<div class="empty-message">Waiting for render events...</div>
|
|
5873
|
+
</div>
|
|
5874
|
+
</div>
|
|
5875
|
+
</section>
|
|
5876
|
+
|
|
5877
|
+
<section class="chains-section">
|
|
5878
|
+
<div class="panel">
|
|
5879
|
+
<div class="panel-header">
|
|
5880
|
+
<h2>Render Chains</h2>
|
|
5881
|
+
</div>
|
|
5882
|
+
<div class="chains-container" id="chains">
|
|
5883
|
+
<div class="empty-message">No render chains detected yet...</div>
|
|
5884
|
+
</div>
|
|
5885
|
+
</div>
|
|
5886
|
+
</section>
|
|
5887
|
+
</div>
|
|
5888
|
+
<script>${getScript(wsPort)}</script>
|
|
5889
|
+
</body>
|
|
5890
|
+
</html>`;
|
|
5762
5891
|
}
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5892
|
+
function escapeHtml2(str) {
|
|
5893
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5894
|
+
}
|
|
5895
|
+
function getStyles() {
|
|
5896
|
+
return `
|
|
5897
|
+
:root {
|
|
5898
|
+
--bg-primary: #0a0a0a;
|
|
5899
|
+
--bg-secondary: #141414;
|
|
5900
|
+
--bg-tertiary: #1f1f1f;
|
|
5901
|
+
--text-primary: #ffffff;
|
|
5902
|
+
--text-secondary: #a1a1aa;
|
|
5903
|
+
--accent-red: #ef4444;
|
|
5904
|
+
--accent-yellow: #eab308;
|
|
5905
|
+
--accent-green: #22c55e;
|
|
5906
|
+
--accent-blue: #3b82f6;
|
|
5907
|
+
--accent-purple: #a855f7;
|
|
5908
|
+
--border-color: #27272a;
|
|
5909
|
+
}
|
|
5778
5910
|
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5911
|
+
* {
|
|
5912
|
+
box-sizing: border-box;
|
|
5913
|
+
margin: 0;
|
|
5914
|
+
padding: 0;
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5917
|
+
body {
|
|
5918
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
5919
|
+
background: var(--bg-primary);
|
|
5920
|
+
color: var(--text-primary);
|
|
5921
|
+
line-height: 1.6;
|
|
5922
|
+
min-height: 100vh;
|
|
5923
|
+
}
|
|
5924
|
+
|
|
5925
|
+
.container {
|
|
5926
|
+
max-width: 1400px;
|
|
5927
|
+
margin: 0 auto;
|
|
5928
|
+
padding: 1.5rem;
|
|
5929
|
+
}
|
|
5930
|
+
|
|
5931
|
+
/* Header */
|
|
5932
|
+
.header {
|
|
5933
|
+
display: flex;
|
|
5934
|
+
justify-content: space-between;
|
|
5935
|
+
align-items: flex-start;
|
|
5936
|
+
margin-bottom: 1.5rem;
|
|
5937
|
+
padding-bottom: 1rem;
|
|
5938
|
+
border-bottom: 1px solid var(--border-color);
|
|
5939
|
+
}
|
|
5940
|
+
|
|
5941
|
+
.header h1 {
|
|
5942
|
+
font-size: 1.75rem;
|
|
5943
|
+
color: var(--accent-green);
|
|
5944
|
+
display: flex;
|
|
5945
|
+
align-items: center;
|
|
5946
|
+
gap: 0.5rem;
|
|
5947
|
+
}
|
|
5948
|
+
|
|
5949
|
+
.logo {
|
|
5950
|
+
font-size: 1.5rem;
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5953
|
+
.status {
|
|
5954
|
+
font-size: 0.875rem;
|
|
5955
|
+
font-weight: normal;
|
|
5956
|
+
display: inline-flex;
|
|
5957
|
+
align-items: center;
|
|
5958
|
+
gap: 0.375rem;
|
|
5959
|
+
padding: 0.25rem 0.75rem;
|
|
5960
|
+
background: var(--bg-tertiary);
|
|
5961
|
+
border-radius: 9999px;
|
|
5962
|
+
margin-left: 0.75rem;
|
|
5963
|
+
}
|
|
5964
|
+
|
|
5965
|
+
.status-dot {
|
|
5966
|
+
width: 8px;
|
|
5967
|
+
height: 8px;
|
|
5968
|
+
border-radius: 50%;
|
|
5969
|
+
background: var(--accent-yellow);
|
|
5970
|
+
animation: pulse 2s infinite;
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5973
|
+
.status.connected .status-dot {
|
|
5974
|
+
background: var(--accent-green);
|
|
5975
|
+
animation: none;
|
|
5976
|
+
}
|
|
5977
|
+
|
|
5978
|
+
.status.scanning .status-dot {
|
|
5979
|
+
background: var(--accent-blue);
|
|
5980
|
+
animation: pulse 1s infinite;
|
|
5981
|
+
}
|
|
5982
|
+
|
|
5983
|
+
.status.paused .status-dot {
|
|
5984
|
+
background: var(--accent-yellow);
|
|
5985
|
+
animation: none;
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5988
|
+
@keyframes pulse {
|
|
5989
|
+
0%, 100% { opacity: 1; }
|
|
5990
|
+
50% { opacity: 0.5; }
|
|
5991
|
+
}
|
|
5992
|
+
|
|
5993
|
+
.header-meta {
|
|
5994
|
+
color: var(--text-secondary);
|
|
5995
|
+
font-size: 0.875rem;
|
|
5996
|
+
margin-top: 0.5rem;
|
|
5997
|
+
}
|
|
5998
|
+
|
|
5999
|
+
.separator {
|
|
6000
|
+
margin: 0 0.5rem;
|
|
6001
|
+
}
|
|
6002
|
+
|
|
6003
|
+
.btn {
|
|
6004
|
+
padding: 0.5rem 1rem;
|
|
6005
|
+
border-radius: 6px;
|
|
6006
|
+
border: none;
|
|
6007
|
+
font-size: 0.875rem;
|
|
6008
|
+
font-weight: 500;
|
|
6009
|
+
cursor: pointer;
|
|
6010
|
+
transition: all 0.2s;
|
|
6011
|
+
}
|
|
6012
|
+
|
|
6013
|
+
.btn:disabled {
|
|
6014
|
+
opacity: 0.5;
|
|
6015
|
+
cursor: not-allowed;
|
|
6016
|
+
}
|
|
6017
|
+
|
|
6018
|
+
.btn-secondary {
|
|
6019
|
+
background: var(--bg-tertiary);
|
|
6020
|
+
color: var(--text-primary);
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
.btn-secondary:hover:not(:disabled) {
|
|
6024
|
+
background: var(--border-color);
|
|
6025
|
+
}
|
|
6026
|
+
|
|
6027
|
+
/* Summary */
|
|
6028
|
+
.summary {
|
|
6029
|
+
margin-bottom: 1.5rem;
|
|
6030
|
+
}
|
|
6031
|
+
|
|
6032
|
+
.summary-grid {
|
|
6033
|
+
display: grid;
|
|
6034
|
+
grid-template-columns: repeat(6, 1fr);
|
|
6035
|
+
gap: 1rem;
|
|
6036
|
+
}
|
|
6037
|
+
|
|
6038
|
+
@media (max-width: 900px) {
|
|
6039
|
+
.summary-grid {
|
|
6040
|
+
grid-template-columns: repeat(3, 1fr);
|
|
5796
6041
|
}
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
const { config, configPath, fromFile } = await loadConfig(options.configPath);
|
|
5803
|
-
if (fromFile) {
|
|
5804
|
-
logger4.info(`Using config: ${configPath}`);
|
|
5805
|
-
}
|
|
5806
|
-
const configOptions = configToOptions(config);
|
|
5807
|
-
const mergedOptions = {
|
|
5808
|
-
...options,
|
|
5809
|
-
thresholdCritical: options.thresholdCritical ?? configOptions.thresholds.critical,
|
|
5810
|
-
thresholdWarning: options.thresholdWarning ?? configOptions.thresholds.warning,
|
|
5811
|
-
fpsThreshold: options.fpsThreshold ?? configOptions.thresholds.fps,
|
|
5812
|
-
output: options.output ?? configOptions.report.output
|
|
5813
|
-
};
|
|
5814
|
-
const session = {
|
|
5815
|
-
id: generateId("scan"),
|
|
5816
|
-
startTime: Date.now(),
|
|
5817
|
-
scanner: new Scanner({
|
|
5818
|
-
thresholds: {
|
|
5819
|
-
critical: mergedOptions.thresholdCritical,
|
|
5820
|
-
warning: mergedOptions.thresholdWarning,
|
|
5821
|
-
fps: mergedOptions.fpsThreshold
|
|
6042
|
+
}
|
|
6043
|
+
|
|
6044
|
+
@media (max-width: 500px) {
|
|
6045
|
+
.summary-grid {
|
|
6046
|
+
grid-template-columns: repeat(2, 1fr);
|
|
5822
6047
|
}
|
|
5823
|
-
}
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
6048
|
+
}
|
|
6049
|
+
|
|
6050
|
+
.summary-card {
|
|
6051
|
+
background: var(--bg-secondary);
|
|
6052
|
+
border-radius: 8px;
|
|
6053
|
+
padding: 1rem;
|
|
6054
|
+
text-align: center;
|
|
6055
|
+
transition: transform 0.2s;
|
|
6056
|
+
}
|
|
6057
|
+
|
|
6058
|
+
.summary-card:hover {
|
|
6059
|
+
transform: translateY(-2px);
|
|
6060
|
+
}
|
|
6061
|
+
|
|
6062
|
+
.summary-value {
|
|
6063
|
+
font-size: 2rem;
|
|
6064
|
+
font-weight: bold;
|
|
6065
|
+
transition: all 0.3s;
|
|
6066
|
+
}
|
|
6067
|
+
|
|
6068
|
+
.summary-value.updated {
|
|
6069
|
+
transform: scale(1.1);
|
|
6070
|
+
}
|
|
6071
|
+
|
|
6072
|
+
.summary-label {
|
|
6073
|
+
color: var(--text-secondary);
|
|
6074
|
+
font-size: 0.75rem;
|
|
6075
|
+
text-transform: uppercase;
|
|
6076
|
+
letter-spacing: 0.05em;
|
|
6077
|
+
}
|
|
6078
|
+
|
|
6079
|
+
.critical { color: var(--accent-red); }
|
|
6080
|
+
.warning { color: var(--accent-yellow); }
|
|
6081
|
+
.healthy { color: var(--accent-green); }
|
|
6082
|
+
.info { color: var(--accent-blue); }
|
|
6083
|
+
|
|
6084
|
+
/* Content */
|
|
6085
|
+
.content {
|
|
6086
|
+
display: grid;
|
|
6087
|
+
grid-template-columns: 2fr 1fr;
|
|
6088
|
+
gap: 1.5rem;
|
|
6089
|
+
margin-bottom: 1.5rem;
|
|
6090
|
+
}
|
|
6091
|
+
|
|
6092
|
+
@media (max-width: 900px) {
|
|
6093
|
+
.content {
|
|
6094
|
+
grid-template-columns: 1fr;
|
|
6095
|
+
}
|
|
6096
|
+
}
|
|
6097
|
+
|
|
6098
|
+
.panel {
|
|
6099
|
+
background: var(--bg-secondary);
|
|
6100
|
+
border-radius: 8px;
|
|
6101
|
+
overflow: hidden;
|
|
6102
|
+
}
|
|
6103
|
+
|
|
6104
|
+
.panel-header {
|
|
6105
|
+
display: flex;
|
|
6106
|
+
justify-content: space-between;
|
|
6107
|
+
align-items: center;
|
|
6108
|
+
padding: 1rem;
|
|
6109
|
+
border-bottom: 1px solid var(--border-color);
|
|
6110
|
+
}
|
|
6111
|
+
|
|
6112
|
+
.panel-header h2 {
|
|
6113
|
+
font-size: 1rem;
|
|
6114
|
+
font-weight: 600;
|
|
6115
|
+
}
|
|
6116
|
+
|
|
6117
|
+
.search-input {
|
|
6118
|
+
padding: 0.5rem 0.75rem;
|
|
6119
|
+
background: var(--bg-tertiary);
|
|
6120
|
+
border: 1px solid var(--border-color);
|
|
6121
|
+
border-radius: 6px;
|
|
6122
|
+
color: var(--text-primary);
|
|
6123
|
+
font-size: 0.875rem;
|
|
6124
|
+
width: 200px;
|
|
6125
|
+
}
|
|
6126
|
+
|
|
6127
|
+
.search-input:focus {
|
|
6128
|
+
outline: none;
|
|
6129
|
+
border-color: var(--accent-blue);
|
|
6130
|
+
}
|
|
6131
|
+
|
|
6132
|
+
.search-input::placeholder {
|
|
6133
|
+
color: var(--text-secondary);
|
|
6134
|
+
}
|
|
6135
|
+
|
|
6136
|
+
/* Table */
|
|
6137
|
+
.table-container {
|
|
6138
|
+
max-height: 400px;
|
|
6139
|
+
overflow-y: auto;
|
|
6140
|
+
}
|
|
6141
|
+
|
|
6142
|
+
.component-table {
|
|
6143
|
+
width: 100%;
|
|
6144
|
+
border-collapse: collapse;
|
|
6145
|
+
}
|
|
6146
|
+
|
|
6147
|
+
.component-table th,
|
|
6148
|
+
.component-table td {
|
|
6149
|
+
padding: 0.75rem 1rem;
|
|
6150
|
+
text-align: left;
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6153
|
+
.component-table th {
|
|
6154
|
+
background: var(--bg-tertiary);
|
|
6155
|
+
font-size: 0.75rem;
|
|
6156
|
+
text-transform: uppercase;
|
|
6157
|
+
color: var(--text-secondary);
|
|
6158
|
+
position: sticky;
|
|
6159
|
+
top: 0;
|
|
6160
|
+
z-index: 1;
|
|
6161
|
+
}
|
|
6162
|
+
|
|
6163
|
+
.component-table th.sortable {
|
|
6164
|
+
cursor: pointer;
|
|
6165
|
+
}
|
|
6166
|
+
|
|
6167
|
+
.component-table th.sortable:hover {
|
|
6168
|
+
color: var(--text-primary);
|
|
6169
|
+
}
|
|
6170
|
+
|
|
6171
|
+
.component-table th.sorted-asc::after {
|
|
6172
|
+
content: ' \u2191';
|
|
6173
|
+
}
|
|
6174
|
+
|
|
6175
|
+
.component-table th.sorted-desc::after {
|
|
6176
|
+
content: ' \u2193';
|
|
6177
|
+
}
|
|
6178
|
+
|
|
6179
|
+
.component-table tbody tr {
|
|
6180
|
+
border-bottom: 1px solid var(--border-color);
|
|
6181
|
+
transition: background 0.2s;
|
|
6182
|
+
}
|
|
6183
|
+
|
|
6184
|
+
.component-table tbody tr:hover {
|
|
6185
|
+
background: var(--bg-tertiary);
|
|
6186
|
+
}
|
|
6187
|
+
|
|
6188
|
+
.component-table tbody tr.new-row {
|
|
6189
|
+
animation: highlight 1s ease-out;
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6192
|
+
@keyframes highlight {
|
|
6193
|
+
from { background: rgba(59, 130, 246, 0.2); }
|
|
6194
|
+
to { background: transparent; }
|
|
6195
|
+
}
|
|
6196
|
+
|
|
6197
|
+
.component-name {
|
|
6198
|
+
font-weight: 500;
|
|
6199
|
+
display: flex;
|
|
6200
|
+
align-items: center;
|
|
6201
|
+
gap: 0.5rem;
|
|
6202
|
+
}
|
|
6203
|
+
|
|
6204
|
+
.severity-badge {
|
|
6205
|
+
display: inline-block;
|
|
6206
|
+
padding: 0.125rem 0.5rem;
|
|
6207
|
+
border-radius: 9999px;
|
|
6208
|
+
font-size: 0.75rem;
|
|
6209
|
+
font-weight: 500;
|
|
6210
|
+
}
|
|
6211
|
+
|
|
6212
|
+
.severity-badge.critical {
|
|
6213
|
+
background: rgba(239, 68, 68, 0.2);
|
|
6214
|
+
}
|
|
6215
|
+
|
|
6216
|
+
.severity-badge.warning {
|
|
6217
|
+
background: rgba(234, 179, 8, 0.2);
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
.severity-badge.healthy {
|
|
6221
|
+
background: rgba(34, 197, 94, 0.2);
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
.empty-row td {
|
|
6225
|
+
text-align: center;
|
|
6226
|
+
color: var(--text-secondary);
|
|
6227
|
+
padding: 2rem;
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
/* Events */
|
|
6231
|
+
.events-container {
|
|
6232
|
+
max-height: 400px;
|
|
6233
|
+
overflow-y: auto;
|
|
6234
|
+
padding: 0.5rem;
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
.event-count {
|
|
6238
|
+
font-size: 0.75rem;
|
|
6239
|
+
color: var(--text-secondary);
|
|
6240
|
+
}
|
|
6241
|
+
|
|
6242
|
+
.event-item {
|
|
6243
|
+
display: flex;
|
|
6244
|
+
align-items: center;
|
|
6245
|
+
gap: 0.5rem;
|
|
6246
|
+
padding: 0.5rem;
|
|
6247
|
+
border-radius: 4px;
|
|
6248
|
+
font-size: 0.875rem;
|
|
6249
|
+
animation: slideIn 0.3s ease-out;
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
@keyframes slideIn {
|
|
6253
|
+
from {
|
|
6254
|
+
opacity: 0;
|
|
6255
|
+
transform: translateX(-10px);
|
|
6256
|
+
}
|
|
6257
|
+
to {
|
|
6258
|
+
opacity: 1;
|
|
6259
|
+
transform: translateX(0);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
|
|
6263
|
+
.event-item:nth-child(odd) {
|
|
6264
|
+
background: var(--bg-tertiary);
|
|
6265
|
+
}
|
|
6266
|
+
|
|
6267
|
+
.event-dot {
|
|
6268
|
+
width: 6px;
|
|
6269
|
+
height: 6px;
|
|
6270
|
+
border-radius: 50%;
|
|
6271
|
+
flex-shrink: 0;
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
.event-name {
|
|
6275
|
+
flex: 1;
|
|
6276
|
+
overflow: hidden;
|
|
6277
|
+
text-overflow: ellipsis;
|
|
6278
|
+
white-space: nowrap;
|
|
6279
|
+
}
|
|
6280
|
+
|
|
6281
|
+
.event-time {
|
|
6282
|
+
font-size: 0.75rem;
|
|
6283
|
+
color: var(--text-secondary);
|
|
6284
|
+
}
|
|
6285
|
+
|
|
6286
|
+
.empty-message {
|
|
6287
|
+
color: var(--text-secondary);
|
|
6288
|
+
text-align: center;
|
|
6289
|
+
padding: 2rem;
|
|
6290
|
+
font-size: 0.875rem;
|
|
6291
|
+
}
|
|
6292
|
+
|
|
6293
|
+
/* Chains */
|
|
6294
|
+
.chains-section .panel {
|
|
6295
|
+
min-height: 150px;
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
.chains-container {
|
|
6299
|
+
padding: 1rem;
|
|
6300
|
+
max-height: 300px;
|
|
6301
|
+
overflow-y: auto;
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
.chain-item {
|
|
6305
|
+
background: var(--bg-tertiary);
|
|
6306
|
+
border-radius: 6px;
|
|
6307
|
+
padding: 1rem;
|
|
6308
|
+
margin-bottom: 0.75rem;
|
|
6309
|
+
animation: slideIn 0.3s ease-out;
|
|
6310
|
+
}
|
|
6311
|
+
|
|
6312
|
+
.chain-trigger {
|
|
6313
|
+
font-weight: 500;
|
|
6314
|
+
margin-bottom: 0.5rem;
|
|
6315
|
+
color: var(--accent-purple);
|
|
6316
|
+
}
|
|
6317
|
+
|
|
6318
|
+
.chain-flow {
|
|
6319
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
6320
|
+
font-size: 0.875rem;
|
|
6321
|
+
color: var(--text-secondary);
|
|
6322
|
+
overflow-x: auto;
|
|
6323
|
+
white-space: nowrap;
|
|
6324
|
+
padding: 0.5rem 0;
|
|
6325
|
+
}
|
|
6326
|
+
|
|
6327
|
+
.chain-flow span {
|
|
6328
|
+
color: var(--text-primary);
|
|
6329
|
+
}
|
|
6330
|
+
|
|
6331
|
+
.chain-flow .arrow {
|
|
6332
|
+
color: var(--accent-yellow);
|
|
6333
|
+
margin: 0 0.25rem;
|
|
6334
|
+
}
|
|
6335
|
+
|
|
6336
|
+
.chain-meta {
|
|
6337
|
+
font-size: 0.75rem;
|
|
6338
|
+
color: var(--text-secondary);
|
|
6339
|
+
margin-top: 0.5rem;
|
|
6340
|
+
}
|
|
6341
|
+
|
|
6342
|
+
/* Scrollbar */
|
|
6343
|
+
::-webkit-scrollbar {
|
|
6344
|
+
width: 8px;
|
|
6345
|
+
height: 8px;
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6348
|
+
::-webkit-scrollbar-track {
|
|
6349
|
+
background: var(--bg-primary);
|
|
6350
|
+
}
|
|
6351
|
+
|
|
6352
|
+
::-webkit-scrollbar-thumb {
|
|
6353
|
+
background: var(--border-color);
|
|
6354
|
+
border-radius: 4px;
|
|
6355
|
+
}
|
|
6356
|
+
|
|
6357
|
+
::-webkit-scrollbar-thumb:hover {
|
|
6358
|
+
background: var(--text-secondary);
|
|
6359
|
+
}
|
|
6360
|
+
`;
|
|
6361
|
+
}
|
|
6362
|
+
function getScript(wsPort) {
|
|
6363
|
+
return `
|
|
6364
|
+
(function() {
|
|
6365
|
+
// State
|
|
6366
|
+
let ws = null;
|
|
6367
|
+
let state = null;
|
|
6368
|
+
let startTime = Date.now();
|
|
6369
|
+
let eventCount = 0;
|
|
6370
|
+
let sortColumn = 'renders';
|
|
6371
|
+
let sortDirection = 'desc';
|
|
6372
|
+
let searchQuery = '';
|
|
6373
|
+
|
|
6374
|
+
// Elements
|
|
6375
|
+
const statusEl = document.getElementById('status');
|
|
6376
|
+
const statusTextEl = statusEl.querySelector('.status-text');
|
|
6377
|
+
const durationEl = document.getElementById('duration');
|
|
6378
|
+
const componentsEl = document.getElementById('components');
|
|
6379
|
+
const rendersEl = document.getElementById('renders');
|
|
6380
|
+
const criticalEl = document.getElementById('critical');
|
|
6381
|
+
const warningsEl = document.getElementById('warnings');
|
|
6382
|
+
const healthyEl = document.getElementById('healthy');
|
|
6383
|
+
const fpsEl = document.getElementById('fps');
|
|
6384
|
+
const componentListEl = document.getElementById('component-list');
|
|
6385
|
+
const eventsEl = document.getElementById('events');
|
|
6386
|
+
const eventCountEl = document.getElementById('event-count');
|
|
6387
|
+
const chainsEl = document.getElementById('chains');
|
|
6388
|
+
const searchEl = document.getElementById('search');
|
|
6389
|
+
const exportBtn = document.getElementById('export-btn');
|
|
6390
|
+
|
|
6391
|
+
// Connect to WebSocket
|
|
6392
|
+
function connect() {
|
|
6393
|
+
ws = new WebSocket('ws://localhost:${wsPort}');
|
|
6394
|
+
|
|
6395
|
+
ws.onopen = () => {
|
|
6396
|
+
statusEl.className = 'status connected';
|
|
6397
|
+
statusTextEl.textContent = 'Connected';
|
|
6398
|
+
exportBtn.disabled = false;
|
|
6399
|
+
};
|
|
6400
|
+
|
|
6401
|
+
ws.onclose = () => {
|
|
6402
|
+
statusEl.className = 'status';
|
|
6403
|
+
statusTextEl.textContent = 'Disconnected';
|
|
6404
|
+
exportBtn.disabled = true;
|
|
6405
|
+
setTimeout(connect, 2000);
|
|
6406
|
+
};
|
|
6407
|
+
|
|
6408
|
+
ws.onerror = () => {
|
|
6409
|
+
ws.close();
|
|
6410
|
+
};
|
|
6411
|
+
|
|
6412
|
+
ws.onmessage = (event) => {
|
|
6413
|
+
try {
|
|
6414
|
+
const msg = JSON.parse(event.data);
|
|
6415
|
+
handleMessage(msg);
|
|
6416
|
+
} catch (e) {
|
|
6417
|
+
console.error('Failed to parse message:', e);
|
|
6418
|
+
}
|
|
6419
|
+
};
|
|
6420
|
+
}
|
|
6421
|
+
|
|
6422
|
+
// Handle incoming messages
|
|
6423
|
+
function handleMessage(msg) {
|
|
6424
|
+
switch (msg.type) {
|
|
6425
|
+
case 'state':
|
|
6426
|
+
state = msg.payload;
|
|
6427
|
+
startTime = msg.payload.startTime;
|
|
6428
|
+
updateStatus(msg.payload);
|
|
6429
|
+
updateSummary(msg.payload.summary);
|
|
6430
|
+
renderComponents(msg.payload.components);
|
|
6431
|
+
renderChains(msg.payload.chains);
|
|
6432
|
+
break;
|
|
6433
|
+
|
|
6434
|
+
case 'summary-update':
|
|
6435
|
+
updateSummary(msg.payload);
|
|
6436
|
+
break;
|
|
6437
|
+
|
|
6438
|
+
case 'component-update':
|
|
6439
|
+
updateComponent(msg.payload);
|
|
6440
|
+
break;
|
|
6441
|
+
|
|
6442
|
+
case 'render-event':
|
|
6443
|
+
addEvent(msg.payload);
|
|
6444
|
+
break;
|
|
6445
|
+
|
|
6446
|
+
case 'chain-detected':
|
|
6447
|
+
addChain(msg.payload);
|
|
6448
|
+
break;
|
|
6449
|
+
|
|
6450
|
+
case 'scanning-status':
|
|
6451
|
+
updateScanningStatus(msg.payload);
|
|
6452
|
+
break;
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
|
|
6456
|
+
// Update status
|
|
6457
|
+
function updateStatus(data) {
|
|
6458
|
+
if (data.scanning && !data.paused) {
|
|
6459
|
+
statusEl.className = 'status scanning';
|
|
6460
|
+
statusTextEl.textContent = 'Scanning';
|
|
6461
|
+
} else if (data.paused) {
|
|
6462
|
+
statusEl.className = 'status paused';
|
|
6463
|
+
statusTextEl.textContent = 'Paused';
|
|
6464
|
+
} else {
|
|
6465
|
+
statusEl.className = 'status connected';
|
|
6466
|
+
statusTextEl.textContent = 'Connected';
|
|
6467
|
+
}
|
|
6468
|
+
}
|
|
6469
|
+
|
|
6470
|
+
function updateScanningStatus(data) {
|
|
6471
|
+
if (data.scanning && !data.paused) {
|
|
6472
|
+
statusEl.className = 'status scanning';
|
|
6473
|
+
statusTextEl.textContent = 'Scanning';
|
|
6474
|
+
} else if (data.paused) {
|
|
6475
|
+
statusEl.className = 'status paused';
|
|
6476
|
+
statusTextEl.textContent = 'Paused';
|
|
6477
|
+
} else {
|
|
6478
|
+
statusEl.className = 'status connected';
|
|
6479
|
+
statusTextEl.textContent = 'Connected';
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
6482
|
+
|
|
6483
|
+
// Update summary with animation
|
|
6484
|
+
function updateSummary(summary) {
|
|
6485
|
+
animateValue(componentsEl, summary.totalComponents);
|
|
6486
|
+
animateValue(rendersEl, summary.totalRenders);
|
|
6487
|
+
animateValue(criticalEl, summary.criticalIssues);
|
|
6488
|
+
animateValue(warningsEl, summary.warnings);
|
|
6489
|
+
animateValue(healthyEl, summary.healthy);
|
|
6490
|
+
animateValue(fpsEl, summary.avgFps);
|
|
6491
|
+
}
|
|
6492
|
+
|
|
6493
|
+
function animateValue(el, value) {
|
|
6494
|
+
const current = parseInt(el.textContent) || 0;
|
|
6495
|
+
if (current !== value) {
|
|
6496
|
+
el.textContent = value;
|
|
6497
|
+
el.classList.add('updated');
|
|
6498
|
+
setTimeout(() => el.classList.remove('updated'), 300);
|
|
6499
|
+
}
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6502
|
+
// Update single component
|
|
6503
|
+
function updateComponent(component) {
|
|
6504
|
+
if (!state) state = { components: [] };
|
|
6505
|
+
const idx = state.components.findIndex(c => c.name === component.name);
|
|
6506
|
+
if (idx >= 0) {
|
|
6507
|
+
state.components[idx] = component;
|
|
6508
|
+
} else {
|
|
6509
|
+
state.components.push(component);
|
|
6510
|
+
}
|
|
6511
|
+
renderComponents(state.components);
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
// Render components table
|
|
6515
|
+
function renderComponents(components) {
|
|
6516
|
+
if (!components || components.length === 0) {
|
|
6517
|
+
componentListEl.innerHTML = '<tr class="empty-row"><td colspan="5">No components detected yet...</td></tr>';
|
|
6518
|
+
return;
|
|
6519
|
+
}
|
|
6520
|
+
|
|
6521
|
+
// Filter
|
|
6522
|
+
let filtered = components;
|
|
6523
|
+
if (searchQuery) {
|
|
6524
|
+
filtered = components.filter(c =>
|
|
6525
|
+
c.name.toLowerCase().includes(searchQuery.toLowerCase())
|
|
6526
|
+
);
|
|
6527
|
+
}
|
|
6528
|
+
|
|
6529
|
+
// Sort
|
|
6530
|
+
filtered.sort((a, b) => {
|
|
6531
|
+
let aVal, bVal;
|
|
6532
|
+
switch (sortColumn) {
|
|
6533
|
+
case 'name': aVal = a.name; bVal = b.name; break;
|
|
6534
|
+
case 'renders': aVal = a.renders; bVal = b.renders; break;
|
|
6535
|
+
case 'unnecessary': aVal = a.unnecessary; bVal = b.unnecessary; break;
|
|
6536
|
+
case 'avgTime': aVal = a.avgRenderTime; bVal = b.avgRenderTime; break;
|
|
6537
|
+
case 'severity':
|
|
6538
|
+
const order = { critical: 0, warning: 1, info: 2, healthy: 3 };
|
|
6539
|
+
aVal = order[a.severity] ?? 4;
|
|
6540
|
+
bVal = order[b.severity] ?? 4;
|
|
6541
|
+
break;
|
|
6542
|
+
default: aVal = a.renders; bVal = b.renders;
|
|
6543
|
+
}
|
|
6544
|
+
if (typeof aVal === 'string') {
|
|
6545
|
+
return sortDirection === 'asc' ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
|
|
6546
|
+
}
|
|
6547
|
+
return sortDirection === 'asc' ? aVal - bVal : bVal - aVal;
|
|
6548
|
+
});
|
|
6549
|
+
|
|
6550
|
+
componentListEl.innerHTML = filtered.slice(0, 100).map(c => \`
|
|
6551
|
+
<tr data-name="\${escapeHtml(c.name)}">
|
|
6552
|
+
<td class="component-name">
|
|
6553
|
+
<span class="severity-indicator \${c.severity}"></span>
|
|
6554
|
+
\${escapeHtml(c.name)}
|
|
6555
|
+
</td>
|
|
6556
|
+
<td>\${c.renders}</td>
|
|
6557
|
+
<td>\${c.unnecessary}</td>
|
|
6558
|
+
<td>\${c.avgRenderTime.toFixed(2)}ms</td>
|
|
6559
|
+
<td><span class="severity-badge \${c.severity}">\${c.severity}</span></td>
|
|
6560
|
+
</tr>
|
|
6561
|
+
\`).join('');
|
|
6562
|
+
}
|
|
6563
|
+
|
|
6564
|
+
// Add event to timeline
|
|
6565
|
+
function addEvent(render) {
|
|
6566
|
+
eventCount++;
|
|
6567
|
+
eventCountEl.textContent = eventCount + ' events';
|
|
6568
|
+
|
|
6569
|
+
const isEmpty = eventsEl.querySelector('.empty-message');
|
|
6570
|
+
if (isEmpty) isEmpty.remove();
|
|
6571
|
+
|
|
6572
|
+
const severityColor = {
|
|
6573
|
+
critical: 'var(--accent-red)',
|
|
6574
|
+
warning: 'var(--accent-yellow)',
|
|
6575
|
+
info: 'var(--accent-blue)',
|
|
6576
|
+
healthy: 'var(--accent-green)'
|
|
6577
|
+
};
|
|
6578
|
+
|
|
6579
|
+
const color = render.renderCount > 50 ? severityColor.critical :
|
|
6580
|
+
render.renderCount > 20 ? severityColor.warning :
|
|
6581
|
+
severityColor.healthy;
|
|
6582
|
+
|
|
6583
|
+
const time = new Date(render.timestamp || Date.now()).toLocaleTimeString();
|
|
6584
|
+
|
|
6585
|
+
const eventHtml = \`
|
|
6586
|
+
<div class="event-item">
|
|
6587
|
+
<div class="event-dot" style="background: \${color}"></div>
|
|
6588
|
+
<span class="event-name">\${escapeHtml(render.componentName)}</span>
|
|
6589
|
+
<span class="event-time">\${time}</span>
|
|
6590
|
+
</div>
|
|
6591
|
+
\`;
|
|
6592
|
+
|
|
6593
|
+
eventsEl.insertAdjacentHTML('afterbegin', eventHtml);
|
|
6594
|
+
|
|
6595
|
+
// Keep only last 100 events
|
|
6596
|
+
while (eventsEl.children.length > 100) {
|
|
6597
|
+
eventsEl.lastChild.remove();
|
|
6598
|
+
}
|
|
6599
|
+
}
|
|
6600
|
+
|
|
6601
|
+
// Render chains
|
|
6602
|
+
function renderChains(chains) {
|
|
6603
|
+
if (!chains || chains.length === 0) {
|
|
6604
|
+
chainsEl.innerHTML = '<div class="empty-message">No render chains detected yet...</div>';
|
|
6605
|
+
return;
|
|
6606
|
+
}
|
|
6607
|
+
|
|
6608
|
+
chainsEl.innerHTML = chains.slice(0, 10).map(chain => \`
|
|
6609
|
+
<div class="chain-item">
|
|
6610
|
+
<div class="chain-trigger">Trigger: \${escapeHtml(chain.trigger)}</div>
|
|
6611
|
+
<div class="chain-flow">
|
|
6612
|
+
\${chain.chain.map((c, i) =>
|
|
6613
|
+
i === 0 ? \`<span style="color: var(--accent-red)">\${escapeHtml(c)}</span>\` :
|
|
6614
|
+
\`<span class="arrow">\u2192</span><span>\${escapeHtml(c)}</span>\`
|
|
6615
|
+
).join('')}
|
|
6616
|
+
</div>
|
|
6617
|
+
<div class="chain-meta">Depth: \${chain.depth} \u2022 Renders: \${chain.totalRenders}</div>
|
|
6618
|
+
</div>
|
|
6619
|
+
\`).join('');
|
|
6620
|
+
}
|
|
6621
|
+
|
|
6622
|
+
// Add chain
|
|
6623
|
+
function addChain(chain) {
|
|
6624
|
+
if (!state) state = { chains: [] };
|
|
6625
|
+
state.chains.unshift(chain);
|
|
6626
|
+
if (state.chains.length > 20) state.chains.pop();
|
|
6627
|
+
renderChains(state.chains);
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
// Escape HTML
|
|
6631
|
+
function escapeHtml(str) {
|
|
6632
|
+
if (!str) return '';
|
|
6633
|
+
return str.replace(/&/g, '&')
|
|
6634
|
+
.replace(/</g, '<')
|
|
6635
|
+
.replace(/>/g, '>')
|
|
6636
|
+
.replace(/"/g, '"');
|
|
6637
|
+
}
|
|
6638
|
+
|
|
6639
|
+
// Update duration
|
|
6640
|
+
function updateDuration() {
|
|
6641
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
6642
|
+
const mins = Math.floor(elapsed / 60);
|
|
6643
|
+
const secs = elapsed % 60;
|
|
6644
|
+
durationEl.textContent = 'Duration: ' + (mins > 0 ? mins + 'm ' : '') + secs + 's';
|
|
6645
|
+
}
|
|
6646
|
+
|
|
6647
|
+
// Setup sorting
|
|
6648
|
+
document.querySelectorAll('.sortable').forEach(th => {
|
|
6649
|
+
th.addEventListener('click', () => {
|
|
6650
|
+
const column = th.dataset.sort;
|
|
6651
|
+
if (sortColumn === column) {
|
|
6652
|
+
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
|
|
6653
|
+
} else {
|
|
6654
|
+
sortColumn = column;
|
|
6655
|
+
sortDirection = 'desc';
|
|
6656
|
+
}
|
|
6657
|
+
|
|
6658
|
+
document.querySelectorAll('.sortable').forEach(el => {
|
|
6659
|
+
el.classList.remove('sorted-asc', 'sorted-desc');
|
|
6660
|
+
});
|
|
6661
|
+
th.classList.add(sortDirection === 'asc' ? 'sorted-asc' : 'sorted-desc');
|
|
6662
|
+
|
|
6663
|
+
if (state && state.components) {
|
|
6664
|
+
renderComponents(state.components);
|
|
6665
|
+
}
|
|
6666
|
+
});
|
|
6667
|
+
});
|
|
6668
|
+
|
|
6669
|
+
// Setup search
|
|
6670
|
+
searchEl.addEventListener('input', (e) => {
|
|
6671
|
+
searchQuery = e.target.value;
|
|
6672
|
+
if (state && state.components) {
|
|
6673
|
+
renderComponents(state.components);
|
|
6674
|
+
}
|
|
6675
|
+
});
|
|
6676
|
+
|
|
6677
|
+
// Setup export
|
|
6678
|
+
exportBtn.addEventListener('click', () => {
|
|
6679
|
+
if (!state) return;
|
|
6680
|
+
const data = JSON.stringify(state, null, 2);
|
|
6681
|
+
const blob = new Blob([data], { type: 'application/json' });
|
|
6682
|
+
const url = URL.createObjectURL(blob);
|
|
6683
|
+
const a = document.createElement('a');
|
|
6684
|
+
a.href = url;
|
|
6685
|
+
a.download = 'reactcheck-export-' + Date.now() + '.json';
|
|
6686
|
+
a.click();
|
|
6687
|
+
URL.revokeObjectURL(url);
|
|
6688
|
+
});
|
|
6689
|
+
|
|
6690
|
+
// Start
|
|
6691
|
+
connect();
|
|
6692
|
+
setInterval(updateDuration, 1000);
|
|
6693
|
+
|
|
6694
|
+
// Mark initial sort column
|
|
6695
|
+
document.querySelector('[data-sort="renders"]').classList.add('sorted-desc');
|
|
6696
|
+
})();
|
|
6697
|
+
`;
|
|
6698
|
+
}
|
|
6699
|
+
|
|
6700
|
+
// src/webui/server.ts
|
|
6701
|
+
var OPCODE2 = {
|
|
6702
|
+
CLOSE: 8,
|
|
6703
|
+
PING: 9};
|
|
6704
|
+
var WS_GUID2 = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
6705
|
+
var DashboardClient = class {
|
|
6706
|
+
socket;
|
|
6707
|
+
isOpen = true;
|
|
6708
|
+
constructor(socket) {
|
|
6709
|
+
this.socket = socket;
|
|
6710
|
+
this.socket.on("close", () => {
|
|
6711
|
+
this.isOpen = false;
|
|
6712
|
+
});
|
|
6713
|
+
this.socket.on("error", () => {
|
|
6714
|
+
this.isOpen = false;
|
|
6715
|
+
});
|
|
6716
|
+
}
|
|
6717
|
+
/**
|
|
6718
|
+
* Send a message to the client
|
|
6719
|
+
*/
|
|
6720
|
+
send(message) {
|
|
6721
|
+
if (!this.isOpen) return;
|
|
6722
|
+
try {
|
|
6723
|
+
const data = JSON.stringify(message);
|
|
6724
|
+
const frame = this.createFrame(data);
|
|
6725
|
+
this.socket.write(frame);
|
|
6726
|
+
} catch {
|
|
6727
|
+
}
|
|
6728
|
+
}
|
|
6729
|
+
/**
|
|
6730
|
+
* Create a WebSocket frame
|
|
6731
|
+
*/
|
|
6732
|
+
createFrame(data) {
|
|
6733
|
+
const payload = Buffer.from(data, "utf8");
|
|
6734
|
+
const length = payload.length;
|
|
6735
|
+
let frame;
|
|
6736
|
+
if (length < 126) {
|
|
6737
|
+
frame = Buffer.alloc(2 + length);
|
|
6738
|
+
frame[0] = 129;
|
|
6739
|
+
frame[1] = length;
|
|
6740
|
+
payload.copy(frame, 2);
|
|
6741
|
+
} else if (length < 65536) {
|
|
6742
|
+
frame = Buffer.alloc(4 + length);
|
|
6743
|
+
frame[0] = 129;
|
|
6744
|
+
frame[1] = 126;
|
|
6745
|
+
frame.writeUInt16BE(length, 2);
|
|
6746
|
+
payload.copy(frame, 4);
|
|
6747
|
+
} else {
|
|
6748
|
+
frame = Buffer.alloc(10 + length);
|
|
6749
|
+
frame[0] = 129;
|
|
6750
|
+
frame[1] = 127;
|
|
6751
|
+
frame.writeBigUInt64BE(BigInt(length), 2);
|
|
6752
|
+
payload.copy(frame, 10);
|
|
6753
|
+
}
|
|
6754
|
+
return frame;
|
|
6755
|
+
}
|
|
6756
|
+
/**
|
|
6757
|
+
* Close the connection
|
|
6758
|
+
*/
|
|
6759
|
+
close() {
|
|
6760
|
+
if (!this.isOpen) return;
|
|
6761
|
+
this.isOpen = false;
|
|
6762
|
+
try {
|
|
6763
|
+
const frame = Buffer.alloc(2);
|
|
6764
|
+
frame[0] = 136;
|
|
6765
|
+
frame[1] = 0;
|
|
6766
|
+
this.socket.write(frame);
|
|
6767
|
+
this.socket.end();
|
|
6768
|
+
} catch {
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
/**
|
|
6772
|
+
* Check if client is connected
|
|
6773
|
+
*/
|
|
6774
|
+
isConnected() {
|
|
6775
|
+
return this.isOpen;
|
|
6776
|
+
}
|
|
6777
|
+
};
|
|
6778
|
+
var WebUIServer = class extends EventEmitter {
|
|
6779
|
+
server = null;
|
|
6780
|
+
clients = /* @__PURE__ */ new Set();
|
|
6781
|
+
port;
|
|
6782
|
+
target;
|
|
6783
|
+
currentState;
|
|
6784
|
+
constructor(port = 3100, target = "") {
|
|
6785
|
+
super();
|
|
6786
|
+
this.port = port;
|
|
6787
|
+
this.target = target;
|
|
6788
|
+
this.currentState = this.createInitialState();
|
|
6789
|
+
}
|
|
6790
|
+
/**
|
|
6791
|
+
* Create initial dashboard state
|
|
6792
|
+
*/
|
|
6793
|
+
createInitialState() {
|
|
6794
|
+
return {
|
|
6795
|
+
target: this.target,
|
|
6796
|
+
startTime: Date.now(),
|
|
6797
|
+
scanning: false,
|
|
6798
|
+
paused: false,
|
|
6799
|
+
fps: 60,
|
|
6800
|
+
summary: {
|
|
6801
|
+
totalComponents: 0,
|
|
6802
|
+
totalRenders: 0,
|
|
6803
|
+
criticalIssues: 0,
|
|
6804
|
+
warnings: 0,
|
|
6805
|
+
healthy: 0,
|
|
6806
|
+
avgFps: 60,
|
|
6807
|
+
minFps: 60,
|
|
6808
|
+
unnecessaryRenders: 0
|
|
6809
|
+
},
|
|
6810
|
+
components: [],
|
|
6811
|
+
chains: [],
|
|
6812
|
+
recentRenders: []
|
|
6813
|
+
};
|
|
6814
|
+
}
|
|
6815
|
+
/**
|
|
6816
|
+
* Start the server
|
|
6817
|
+
*/
|
|
6818
|
+
async start() {
|
|
6819
|
+
return new Promise((resolve3, reject) => {
|
|
6820
|
+
this.server = createServer((req, res) => {
|
|
6821
|
+
this.handleHttpRequest(req, res);
|
|
6822
|
+
});
|
|
6823
|
+
this.server.on("upgrade", (req, socket, head) => {
|
|
6824
|
+
this.handleUpgrade(req, socket);
|
|
6825
|
+
});
|
|
6826
|
+
this.server.on("error", (error) => {
|
|
6827
|
+
if (error.code === "EADDRINUSE") {
|
|
6828
|
+
this.port++;
|
|
6829
|
+
this.server?.close();
|
|
6830
|
+
this.start().then(resolve3).catch(reject);
|
|
6831
|
+
} else {
|
|
6832
|
+
this.emit("error", error);
|
|
6833
|
+
reject(error);
|
|
6834
|
+
}
|
|
6835
|
+
});
|
|
6836
|
+
this.server.listen(this.port, () => {
|
|
6837
|
+
this.emit("listening", this.port);
|
|
6838
|
+
resolve3(this.port);
|
|
6839
|
+
});
|
|
6840
|
+
});
|
|
6841
|
+
}
|
|
6842
|
+
/**
|
|
6843
|
+
* Stop the server
|
|
6844
|
+
*/
|
|
6845
|
+
stop() {
|
|
6846
|
+
for (const client of this.clients) {
|
|
6847
|
+
client.close();
|
|
6848
|
+
}
|
|
6849
|
+
this.clients.clear();
|
|
6850
|
+
if (this.server) {
|
|
6851
|
+
this.server.close();
|
|
6852
|
+
this.server = null;
|
|
6853
|
+
}
|
|
6854
|
+
this.emit("close", void 0);
|
|
6855
|
+
}
|
|
6856
|
+
/**
|
|
6857
|
+
* Handle HTTP requests
|
|
6858
|
+
*/
|
|
6859
|
+
handleHttpRequest(req, res) {
|
|
6860
|
+
const url = req.url ?? "/";
|
|
6861
|
+
if (url === "/" || url === "/index.html") {
|
|
6862
|
+
const html = generateDashboardHTML(this.port, this.target);
|
|
6863
|
+
res.writeHead(200, {
|
|
6864
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
6865
|
+
"Cache-Control": "no-cache"
|
|
6866
|
+
});
|
|
6867
|
+
res.end(html);
|
|
6868
|
+
} else if (url === "/health") {
|
|
6869
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
6870
|
+
res.end(JSON.stringify({ status: "ok", clients: this.clients.size }));
|
|
6871
|
+
} else {
|
|
6872
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
6873
|
+
res.end("Not Found");
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
/**
|
|
6877
|
+
* Handle WebSocket upgrade
|
|
6878
|
+
*/
|
|
6879
|
+
handleUpgrade(req, socket) {
|
|
6880
|
+
const key = req.headers["sec-websocket-key"];
|
|
6881
|
+
if (!key) {
|
|
6882
|
+
socket.destroy();
|
|
6883
|
+
return;
|
|
6884
|
+
}
|
|
6885
|
+
const acceptKey = createHash("sha1").update(key + WS_GUID2).digest("base64");
|
|
6886
|
+
const headers = [
|
|
6887
|
+
"HTTP/1.1 101 Switching Protocols",
|
|
6888
|
+
"Upgrade: websocket",
|
|
6889
|
+
"Connection: Upgrade",
|
|
6890
|
+
`Sec-WebSocket-Accept: ${acceptKey}`,
|
|
6891
|
+
"",
|
|
6892
|
+
""
|
|
6893
|
+
].join("\r\n");
|
|
6894
|
+
socket.write(headers);
|
|
6895
|
+
const client = new DashboardClient(socket);
|
|
6896
|
+
this.clients.add(client);
|
|
6897
|
+
this.emit("client-connected", void 0);
|
|
6898
|
+
client.send({ type: "state", payload: this.currentState });
|
|
6899
|
+
socket.on("close", () => {
|
|
6900
|
+
this.clients.delete(client);
|
|
6901
|
+
this.emit("client-disconnected", void 0);
|
|
6902
|
+
});
|
|
6903
|
+
socket.on("data", (data) => {
|
|
6904
|
+
this.handleClientData(client, socket, data);
|
|
6905
|
+
});
|
|
6906
|
+
}
|
|
6907
|
+
/**
|
|
6908
|
+
* Handle data from client
|
|
6909
|
+
*/
|
|
6910
|
+
handleClientData(client, socket, data) {
|
|
6911
|
+
if (data.length < 2) return;
|
|
6912
|
+
const opcode = data[0] & 15;
|
|
6913
|
+
if (opcode === OPCODE2.PING) {
|
|
6914
|
+
const pong = Buffer.alloc(2);
|
|
6915
|
+
pong[0] = 138;
|
|
6916
|
+
pong[1] = 0;
|
|
6917
|
+
socket.write(pong);
|
|
6918
|
+
} else if (opcode === OPCODE2.CLOSE) {
|
|
6919
|
+
this.clients.delete(client);
|
|
6920
|
+
client.close();
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
6923
|
+
/**
|
|
6924
|
+
* Update target URL
|
|
6925
|
+
*/
|
|
6926
|
+
setTarget(target) {
|
|
6927
|
+
this.target = target;
|
|
6928
|
+
this.currentState.target = target;
|
|
6929
|
+
}
|
|
6930
|
+
/**
|
|
6931
|
+
* Update scanning status
|
|
6932
|
+
*/
|
|
6933
|
+
setScanning(scanning, paused = false) {
|
|
6934
|
+
this.currentState.scanning = scanning;
|
|
6935
|
+
this.currentState.paused = paused;
|
|
6936
|
+
this.broadcast({ type: "scanning-status", payload: { scanning, paused } });
|
|
6937
|
+
}
|
|
6938
|
+
/**
|
|
6939
|
+
* Update summary
|
|
6940
|
+
*/
|
|
6941
|
+
updateSummary(summary) {
|
|
6942
|
+
this.currentState.summary = summary;
|
|
6943
|
+
this.broadcast({ type: "summary-update", payload: summary });
|
|
6944
|
+
}
|
|
6945
|
+
/**
|
|
6946
|
+
* Update components
|
|
6947
|
+
*/
|
|
6948
|
+
updateComponents(components) {
|
|
6949
|
+
this.currentState.components = components;
|
|
6950
|
+
}
|
|
6951
|
+
/**
|
|
6952
|
+
* Update FPS
|
|
6953
|
+
*/
|
|
6954
|
+
updateFps(fps) {
|
|
6955
|
+
this.currentState.fps = fps;
|
|
6956
|
+
}
|
|
6957
|
+
/**
|
|
6958
|
+
* Add render event
|
|
6959
|
+
*/
|
|
6960
|
+
addRenderEvent(render) {
|
|
6961
|
+
this.currentState.recentRenders.unshift(render);
|
|
6962
|
+
if (this.currentState.recentRenders.length > 50) {
|
|
6963
|
+
this.currentState.recentRenders.pop();
|
|
6964
|
+
}
|
|
6965
|
+
this.broadcast({ type: "render-event", payload: render });
|
|
6966
|
+
}
|
|
6967
|
+
/**
|
|
6968
|
+
* Add chain detected
|
|
6969
|
+
*/
|
|
6970
|
+
addChain(chain) {
|
|
6971
|
+
this.currentState.chains.unshift(chain);
|
|
6972
|
+
if (this.currentState.chains.length > 20) {
|
|
6973
|
+
this.currentState.chains.pop();
|
|
6974
|
+
}
|
|
6975
|
+
this.broadcast({ type: "chain-detected", payload: chain });
|
|
6976
|
+
}
|
|
6977
|
+
/**
|
|
6978
|
+
* Update component
|
|
6979
|
+
*/
|
|
6980
|
+
updateComponent(component) {
|
|
6981
|
+
const index = this.currentState.components.findIndex((c) => c.name === component.name);
|
|
6982
|
+
if (index >= 0) {
|
|
6983
|
+
this.currentState.components[index] = component;
|
|
6984
|
+
} else {
|
|
6985
|
+
this.currentState.components.push(component);
|
|
6986
|
+
}
|
|
6987
|
+
this.broadcast({ type: "component-update", payload: component });
|
|
6988
|
+
}
|
|
6989
|
+
/**
|
|
6990
|
+
* Broadcast full state to all clients
|
|
6991
|
+
*/
|
|
6992
|
+
broadcastState() {
|
|
6993
|
+
this.broadcast({ type: "state", payload: this.currentState });
|
|
6994
|
+
}
|
|
6995
|
+
/**
|
|
6996
|
+
* Broadcast message to all clients
|
|
6997
|
+
*/
|
|
6998
|
+
broadcast(message) {
|
|
6999
|
+
for (const client of this.clients) {
|
|
7000
|
+
if (client.isConnected()) {
|
|
7001
|
+
client.send(message);
|
|
7002
|
+
} else {
|
|
7003
|
+
this.clients.delete(client);
|
|
7004
|
+
}
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
/**
|
|
7008
|
+
* Get current port
|
|
7009
|
+
*/
|
|
7010
|
+
getPort() {
|
|
7011
|
+
return this.port;
|
|
7012
|
+
}
|
|
7013
|
+
/**
|
|
7014
|
+
* Get client count
|
|
7015
|
+
*/
|
|
7016
|
+
getClientCount() {
|
|
7017
|
+
return this.clients.size;
|
|
7018
|
+
}
|
|
7019
|
+
/**
|
|
7020
|
+
* Get dashboard URL
|
|
7021
|
+
*/
|
|
7022
|
+
getUrl() {
|
|
7023
|
+
return `http://localhost:${this.port}`;
|
|
7024
|
+
}
|
|
7025
|
+
};
|
|
7026
|
+
var logger4 = new Logger({ prefix: "scan", level: 1 /* INFO */ });
|
|
7027
|
+
function parseScanOptions(args) {
|
|
7028
|
+
return {
|
|
7029
|
+
target: normalizeTarget(args.target ?? "localhost:3000"),
|
|
7030
|
+
proxy: getBooleanFlag(args, "proxy"),
|
|
7031
|
+
tui: getBooleanFlag(args, "tui"),
|
|
7032
|
+
silent: getBooleanFlag(args, "silent"),
|
|
7033
|
+
report: getBooleanFlag(args, "report"),
|
|
7034
|
+
format: getStringFlag(args, "format") ?? "all",
|
|
7035
|
+
output: getStringFlag(args, "output") ?? "./reactcheck-reports",
|
|
7036
|
+
fix: getBooleanFlag(args, "fix"),
|
|
7037
|
+
verbose: getBooleanFlag(args, "verbose"),
|
|
7038
|
+
port: getNumberFlag(args, "port") ?? 3099,
|
|
7039
|
+
thresholdCritical: getNumberFlag(args, "threshold-critical") ?? 50,
|
|
7040
|
+
thresholdWarning: getNumberFlag(args, "threshold-warning") ?? 20,
|
|
7041
|
+
fpsThreshold: getNumberFlag(args, "fps-threshold") ?? 30,
|
|
7042
|
+
headless: getBooleanFlag(args, "headless"),
|
|
7043
|
+
duration: getNumberFlag(args, "duration"),
|
|
7044
|
+
watch: getBooleanFlag(args, "watch"),
|
|
7045
|
+
configPath: getStringFlag(args, "config"),
|
|
7046
|
+
webui: getBooleanFlag(args, "webui"),
|
|
7047
|
+
webuiPort: getNumberFlag(args, "webui-port") ?? 3100
|
|
7048
|
+
};
|
|
7049
|
+
}
|
|
7050
|
+
async function getInjectionScript(wsPort) {
|
|
7051
|
+
try {
|
|
7052
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
7053
|
+
const currentDir = dirname(currentFile);
|
|
7054
|
+
const scriptPath = resolve(currentDir, "browser-inject.global.js");
|
|
7055
|
+
logger4.debug(`Loading injection script from: ${scriptPath}`);
|
|
7056
|
+
const script = await readTextFile(scriptPath);
|
|
7057
|
+
return `window.__REACTCHECK_PORT__ = ${wsPort};
|
|
7058
|
+
${script}`;
|
|
7059
|
+
} catch (error) {
|
|
7060
|
+
logger4.debug(`Failed to load injection script: ${error}`);
|
|
7061
|
+
logger4.warn("Could not load injection script, using minimal version");
|
|
7062
|
+
return `
|
|
7063
|
+
window.__REACTCHECK_PORT__ = ${wsPort};
|
|
7064
|
+
window.__REACTCHECK_INJECTED__ = true;
|
|
7065
|
+
|
|
7066
|
+
// Install React DevTools hook
|
|
7067
|
+
if (!window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
|
7068
|
+
const hook = {
|
|
7069
|
+
renderers: new Map(),
|
|
7070
|
+
supportsFiber: true,
|
|
7071
|
+
inject: function(renderer) {
|
|
7072
|
+
const id = this.renderers.size + 1;
|
|
7073
|
+
this.renderers.set(id, renderer);
|
|
7074
|
+
return id;
|
|
7075
|
+
},
|
|
7076
|
+
onCommitFiberRoot: function(id, root) {
|
|
7077
|
+
// Will be overwritten by full script
|
|
7078
|
+
},
|
|
7079
|
+
onCommitFiberUnmount: function() {},
|
|
7080
|
+
};
|
|
7081
|
+
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
7082
|
+
console.log('[ReactCheck] DevTools hook installed (minimal)');
|
|
7083
|
+
}
|
|
7084
|
+
`;
|
|
7085
|
+
}
|
|
7086
|
+
}
|
|
7087
|
+
async function runScanCommand(args) {
|
|
7088
|
+
const options = parseScanOptions(args);
|
|
7089
|
+
const { config, configPath, fromFile } = await loadConfig(options.configPath);
|
|
7090
|
+
if (fromFile) {
|
|
7091
|
+
logger4.info(`Using config: ${configPath}`);
|
|
7092
|
+
}
|
|
7093
|
+
const configOptions = configToOptions(config);
|
|
7094
|
+
const mergedOptions = {
|
|
7095
|
+
...options,
|
|
7096
|
+
thresholdCritical: options.thresholdCritical ?? configOptions.thresholds.critical,
|
|
7097
|
+
thresholdWarning: options.thresholdWarning ?? configOptions.thresholds.warning,
|
|
7098
|
+
fpsThreshold: options.fpsThreshold ?? configOptions.thresholds.fps,
|
|
7099
|
+
output: options.output ?? configOptions.report.output
|
|
7100
|
+
};
|
|
7101
|
+
const session = {
|
|
7102
|
+
id: generateId("scan"),
|
|
7103
|
+
startTime: Date.now(),
|
|
7104
|
+
scanner: new Scanner({
|
|
7105
|
+
thresholds: {
|
|
7106
|
+
critical: mergedOptions.thresholdCritical,
|
|
7107
|
+
warning: mergedOptions.thresholdWarning,
|
|
7108
|
+
fps: mergedOptions.fpsThreshold
|
|
7109
|
+
}
|
|
7110
|
+
}),
|
|
7111
|
+
tui: null,
|
|
7112
|
+
wsServer: null,
|
|
7113
|
+
browser: null,
|
|
7114
|
+
webui: null,
|
|
7115
|
+
options: mergedOptions,
|
|
7116
|
+
active: true,
|
|
7117
|
+
chains: [],
|
|
7118
|
+
suggestions: []
|
|
7119
|
+
};
|
|
7120
|
+
setupScannerEvents(session);
|
|
7121
|
+
const useTUI = !mergedOptions.silent && !mergedOptions.proxy;
|
|
7122
|
+
if (useTUI) {
|
|
7123
|
+
session.tui = new TUI(mergedOptions.target);
|
|
7124
|
+
setupTUIEvents(session);
|
|
7125
|
+
session.tui.setDataProvider(() => ({
|
|
7126
|
+
components: session.scanner.getSnapshot(),
|
|
7127
|
+
summary: session.scanner.getSummary(),
|
|
7128
|
+
fps: session.scanner.getFps()
|
|
7129
|
+
}));
|
|
7130
|
+
session.tui.start();
|
|
7131
|
+
}
|
|
7132
|
+
if (mergedOptions.webui) {
|
|
7133
|
+
session.webui = new WebUIServer(mergedOptions.webuiPort, mergedOptions.target);
|
|
7134
|
+
setupWebUIEvents(session);
|
|
7135
|
+
}
|
|
7136
|
+
if (!useTUI) {
|
|
5840
7137
|
logger4.info(`Starting scan of ${mergedOptions.target}`);
|
|
5841
7138
|
}
|
|
5842
7139
|
if (useTUI) {
|
|
@@ -5867,6 +7164,13 @@ async function runScanCommand(args) {
|
|
|
5867
7164
|
});
|
|
5868
7165
|
});
|
|
5869
7166
|
session.scanner.start();
|
|
7167
|
+
if (session.webui) {
|
|
7168
|
+
const webuiPort = await session.webui.start();
|
|
7169
|
+
session.webui.setScanning(true);
|
|
7170
|
+
const webuiUrl = session.webui.getUrl();
|
|
7171
|
+
logger4.info(`WebUI dashboard: ${webuiUrl}`);
|
|
7172
|
+
openBrowser(webuiUrl);
|
|
7173
|
+
}
|
|
5870
7174
|
if (mergedOptions.proxy) {
|
|
5871
7175
|
console.log("");
|
|
5872
7176
|
console.log(colors.cyan + colors.bold + "\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557" + colors.reset);
|
|
@@ -5940,6 +7244,9 @@ async function cleanupSession(session) {
|
|
|
5940
7244
|
if (session.tui) {
|
|
5941
7245
|
session.tui.stop();
|
|
5942
7246
|
}
|
|
7247
|
+
if (session.webui) {
|
|
7248
|
+
session.webui.stop();
|
|
7249
|
+
}
|
|
5943
7250
|
if (session.browser) {
|
|
5944
7251
|
await session.browser.close();
|
|
5945
7252
|
}
|
|
@@ -5949,7 +7256,7 @@ async function cleanupSession(session) {
|
|
|
5949
7256
|
}
|
|
5950
7257
|
function setupScannerEvents(session) {
|
|
5951
7258
|
const { scanner } = session;
|
|
5952
|
-
scanner.on("render", (
|
|
7259
|
+
scanner.on("render", () => {
|
|
5953
7260
|
if (session.tui) {
|
|
5954
7261
|
const snapshot = scanner.getSnapshot();
|
|
5955
7262
|
const summary = scanner.getSummary();
|
|
@@ -6131,6 +7438,45 @@ function printFixSuggestions(suggestions) {
|
|
|
6131
7438
|
console.log("");
|
|
6132
7439
|
}
|
|
6133
7440
|
}
|
|
7441
|
+
function setupWebUIEvents(session) {
|
|
7442
|
+
const { scanner, webui } = session;
|
|
7443
|
+
if (!webui) return;
|
|
7444
|
+
scanner.on("render", (render) => {
|
|
7445
|
+
webui.addRenderEvent(render);
|
|
7446
|
+
webui.updateSummary(scanner.getSummary());
|
|
7447
|
+
webui.updateComponents(scanner.getSnapshot());
|
|
7448
|
+
webui.updateFps(scanner.getFps());
|
|
7449
|
+
});
|
|
7450
|
+
scanner.on("chain", (chain) => {
|
|
7451
|
+
webui.addChain(chain);
|
|
7452
|
+
});
|
|
7453
|
+
scanner.on("severityChange", ({ component }) => {
|
|
7454
|
+
const stats = scanner.getSnapshot().find((c) => c.name === component);
|
|
7455
|
+
if (stats) {
|
|
7456
|
+
webui.updateComponent(stats);
|
|
7457
|
+
}
|
|
7458
|
+
});
|
|
7459
|
+
}
|
|
7460
|
+
function openBrowser(url) {
|
|
7461
|
+
const platform = process.platform;
|
|
7462
|
+
let command;
|
|
7463
|
+
switch (platform) {
|
|
7464
|
+
case "darwin":
|
|
7465
|
+
command = `open "${url}"`;
|
|
7466
|
+
break;
|
|
7467
|
+
case "win32":
|
|
7468
|
+
command = `start "" "${url}"`;
|
|
7469
|
+
break;
|
|
7470
|
+
default:
|
|
7471
|
+
command = `xdg-open "${url}"`;
|
|
7472
|
+
break;
|
|
7473
|
+
}
|
|
7474
|
+
exec(command, (error) => {
|
|
7475
|
+
if (error) {
|
|
7476
|
+
logger4.debug(`Failed to open browser: ${error.message}`);
|
|
7477
|
+
}
|
|
7478
|
+
});
|
|
7479
|
+
}
|
|
6134
7480
|
|
|
6135
7481
|
// src/cli/commands/init.ts
|
|
6136
7482
|
init_fs();
|