@oxog/react-check 1.1.6 → 1.2.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/dist/index.cjs CHANGED
@@ -757,12 +757,10 @@ var init_browser = __esm({
757
757
  this.page = pages[0] ?? await this.browser.newPage();
758
758
  this.setupPageHandlers();
759
759
  if (this.injectionScript) {
760
+ logger3.debug("Injecting ReactCheck script into page...");
760
761
  await this.page.evaluateOnNewDocument(this.injectionScript);
762
+ logger3.debug("Injection script registered");
761
763
  }
762
- const wsPort = this.options.wsPort;
763
- await this.page.evaluateOnNewDocument(`
764
- window.__REACTCHECK_PORT__ = ${wsPort};
765
- `);
766
764
  this.emit("launched", void 0);
767
765
  logger3.info("Browser launched");
768
766
  await this.navigate(this.options.url);
@@ -2393,9 +2391,17 @@ function getComponentName(fiber) {
2393
2391
  case FiberTag.IncompleteClassComponent:
2394
2392
  return getTypeName(type) || "Anonymous";
2395
2393
  case FiberTag.ForwardRef:
2396
- if (type && typeof type === "object" && "render" in type) {
2397
- const render = type.render;
2398
- return `ForwardRef(${getTypeName(render) || "Anonymous"})`;
2394
+ if (type && typeof type === "object") {
2395
+ const typeObj = type;
2396
+ if (typeObj.displayName) {
2397
+ return typeObj.displayName;
2398
+ }
2399
+ if ("render" in typeObj && typeObj.render) {
2400
+ const renderName = getTypeName(typeObj.render);
2401
+ if (renderName && renderName !== "Anonymous") {
2402
+ return renderName;
2403
+ }
2404
+ }
2399
2405
  }
2400
2406
  return "ForwardRef";
2401
2407
  case FiberTag.MemoComponent:
@@ -4572,46 +4578,47 @@ init_event_emitter();
4572
4578
  var DEFAULT_CONFIG2 = {
4573
4579
  enabled: true,
4574
4580
  highlightRenders: true,
4575
- animationSpeed: "fast",
4576
- showBadges: true,
4577
- showToolbar: true
4581
+ showToolbar: true,
4582
+ highlightDuration: 2e3
4578
4583
  };
4579
4584
  var SEVERITY_COLORS = {
4580
4585
  critical: "#ef4444",
4581
- warning: "#eab308",
4586
+ warning: "#f97316",
4582
4587
  info: "#3b82f6",
4583
4588
  healthy: "#22c55e",
4584
4589
  unnecessary: "#6b7280"
4585
4590
  };
4586
- var ANIMATION_DURATIONS = {
4587
- slow: 1e3,
4588
- fast: 300,
4589
- off: 0
4590
- };
4591
- var FLASH_COLORS = {
4592
- critical: "rgba(239, 68, 68, 0.35)",
4593
- warning: "rgba(234, 179, 8, 0.3)",
4594
- info: "rgba(59, 130, 246, 0.25)",
4595
- healthy: "rgba(34, 197, 94, 0.2)",
4596
- unnecessary: "rgba(107, 114, 128, 0.15)"
4597
- };
4598
- var Overlay = class {
4591
+ var Overlay = class _Overlay {
4599
4592
  /** Shadow root for isolation */
4600
4593
  shadowRoot = null;
4601
4594
  /** Host element */
4602
4595
  host = null;
4603
4596
  /** Overlay configuration */
4604
4597
  config;
4605
- /** Highlight elements */
4606
- highlights = /* @__PURE__ */ new Map();
4607
- /** Badge elements */
4608
- badges = /* @__PURE__ */ new Map();
4609
- /** Render counts for badges */
4610
- renderCounts = /* @__PURE__ */ new Map();
4598
+ /** Tracked components (deduplication) */
4599
+ trackedComponents = /* @__PURE__ */ new Map();
4600
+ /** Render chains */
4601
+ renderChains = [];
4611
4602
  /** Toolbar element */
4612
4603
  toolbar = null;
4613
4604
  /** Whether overlay is visible */
4614
4605
  visible = true;
4606
+ /** Whether panel is collapsed to icon */
4607
+ collapsed = false;
4608
+ /** Total render count */
4609
+ totalRenders = 0;
4610
+ /** FPS value */
4611
+ fps = 60;
4612
+ /** Scan start time */
4613
+ startTime = Date.now();
4614
+ /** Fade timeout handles */
4615
+ fadeTimeouts = /* @__PURE__ */ new Map();
4616
+ /** Bound scroll handler for cleanup */
4617
+ scrollHandler = null;
4618
+ /** Scroll update pending flag (for throttling) */
4619
+ scrollUpdatePending = false;
4620
+ /** Stats update interval */
4621
+ statsInterval = null;
4615
4622
  /**
4616
4623
  * Create a new overlay
4617
4624
  * @param config - Overlay configuration
@@ -4619,10 +4626,22 @@ var Overlay = class {
4619
4626
  constructor(config = {}) {
4620
4627
  this.config = { ...DEFAULT_CONFIG2, ...config };
4621
4628
  }
4629
+ /** Retry count for init */
4630
+ initRetryCount = 0;
4622
4631
  /**
4623
4632
  * Initialize the overlay
4624
4633
  */
4625
4634
  init() {
4635
+ if (this.host) {
4636
+ return;
4637
+ }
4638
+ if (!document.body) {
4639
+ if (this.initRetryCount < 10) {
4640
+ this.initRetryCount++;
4641
+ setTimeout(() => this.init(), 100);
4642
+ }
4643
+ return;
4644
+ }
4626
4645
  this.host = document.createElement("div");
4627
4646
  this.host.id = "reactcheck-overlay-host";
4628
4647
  this.host.style.cssText = `
@@ -4640,14 +4659,31 @@ var Overlay = class {
4640
4659
  this.createToolbar();
4641
4660
  }
4642
4661
  document.body.appendChild(this.host);
4662
+ this.scrollHandler = () => this.onScroll();
4663
+ window.addEventListener("scroll", this.scrollHandler, { passive: true, capture: true });
4664
+ window.addEventListener("resize", this.scrollHandler, { passive: true });
4665
+ this.statsInterval = setInterval(() => this.updateStats(), 500);
4666
+ console.log("[ReactCheck] Overlay initialized");
4643
4667
  }
4644
4668
  /**
4645
4669
  * Destroy the overlay
4646
4670
  */
4647
4671
  destroy() {
4648
- this.highlights.clear();
4649
- this.badges.clear();
4650
- this.renderCounts.clear();
4672
+ if (this.statsInterval) {
4673
+ clearInterval(this.statsInterval);
4674
+ this.statsInterval = null;
4675
+ }
4676
+ if (this.scrollHandler) {
4677
+ window.removeEventListener("scroll", this.scrollHandler, { capture: true });
4678
+ window.removeEventListener("resize", this.scrollHandler);
4679
+ this.scrollHandler = null;
4680
+ }
4681
+ for (const timeout of this.fadeTimeouts.values()) {
4682
+ clearTimeout(timeout);
4683
+ }
4684
+ this.fadeTimeouts.clear();
4685
+ this.trackedComponents.clear();
4686
+ this.renderChains = [];
4651
4687
  if (this.host) {
4652
4688
  this.host.remove();
4653
4689
  this.host = null;
@@ -4655,6 +4691,34 @@ var Overlay = class {
4655
4691
  this.shadowRoot = null;
4656
4692
  this.toolbar = null;
4657
4693
  }
4694
+ /**
4695
+ * Handle scroll/resize events - update all highlight positions
4696
+ */
4697
+ onScroll() {
4698
+ if (this.scrollUpdatePending) return;
4699
+ this.scrollUpdatePending = true;
4700
+ requestAnimationFrame(() => {
4701
+ this.updateAllPositions();
4702
+ this.scrollUpdatePending = false;
4703
+ });
4704
+ }
4705
+ /**
4706
+ * Update positions of all tracked highlights
4707
+ */
4708
+ updateAllPositions() {
4709
+ for (const tracked of this.trackedComponents.values()) {
4710
+ const rect = tracked.element.getBoundingClientRect();
4711
+ if (rect.width === 0 || rect.height === 0) {
4712
+ tracked.highlightEl.style.display = "none";
4713
+ continue;
4714
+ }
4715
+ tracked.highlightEl.style.display = this.config.highlightRenders ? "block" : "none";
4716
+ tracked.highlightEl.style.left = `${rect.left}px`;
4717
+ tracked.highlightEl.style.top = `${rect.top}px`;
4718
+ tracked.highlightEl.style.width = `${rect.width}px`;
4719
+ tracked.highlightEl.style.height = `${rect.height}px`;
4720
+ }
4721
+ }
4658
4722
  /**
4659
4723
  * Inject CSS styles into shadow DOM
4660
4724
  */
@@ -4664,249 +4728,796 @@ var Overlay = class {
4664
4728
  style.textContent = `
4665
4729
  * {
4666
4730
  box-sizing: border-box;
4731
+ margin: 0;
4732
+ padding: 0;
4733
+ }
4734
+
4735
+ /* Ensure all interactive elements are clickable */
4736
+ button, input, .toggle, .tab, .action-btn, .component-item, .panel-btn {
4737
+ pointer-events: auto !important;
4738
+ cursor: pointer;
4667
4739
  }
4668
4740
 
4669
- .highlight {
4741
+ /* Highlight styles */
4742
+ .highlight-container {
4670
4743
  position: fixed;
4671
4744
  pointer-events: none;
4672
- border-width: 2px;
4673
- border-style: solid;
4674
4745
  z-index: 1;
4675
- animation: highlight-pulse 0.5s ease-out;
4676
4746
  }
4677
4747
 
4678
- .highlight.fade {
4679
- opacity: 0;
4748
+ .highlight-border {
4749
+ position: absolute;
4750
+ inset: 0;
4751
+ border: 2px solid currentColor;
4752
+ border-radius: 4px;
4680
4753
  transition: opacity 0.3s ease-out;
4681
4754
  }
4682
4755
 
4683
- .flash-overlay {
4684
- position: fixed;
4685
- pointer-events: none;
4686
- z-index: 0;
4687
- animation: flash-pulse 0.4s ease-out forwards;
4688
- border-radius: 4px;
4756
+ .highlight-container.fade .highlight-border {
4757
+ opacity: 0.3;
4689
4758
  }
4690
4759
 
4691
- @keyframes flash-pulse {
4692
- 0% {
4693
- opacity: 1;
4694
- transform: scale(1);
4695
- }
4696
- 50% {
4697
- opacity: 0.8;
4698
- transform: scale(1.02);
4699
- }
4700
- 100% {
4701
- opacity: 0;
4702
- transform: scale(1);
4703
- }
4760
+ .label {
4761
+ position: absolute;
4762
+ font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
4763
+ font-size: 11px;
4764
+ font-weight: 600;
4765
+ padding: 2px 6px;
4766
+ border-radius: 3px;
4767
+ color: white;
4768
+ white-space: nowrap;
4769
+ line-height: 1.2;
4704
4770
  }
4705
4771
 
4706
- @keyframes highlight-pulse {
4707
- 0% {
4708
- opacity: 0;
4709
- box-shadow: 0 0 0 0 currentColor;
4710
- }
4711
- 30% {
4712
- opacity: 1;
4713
- box-shadow: 0 0 8px 2px currentColor;
4714
- }
4715
- 100% {
4716
- opacity: 1;
4717
- box-shadow: 0 0 0 0 transparent;
4718
- }
4772
+ .label-name {
4773
+ top: -20px;
4774
+ left: 0;
4719
4775
  }
4720
4776
 
4721
- @keyframes badge-pop {
4722
- 0% {
4723
- transform: scale(0.8);
4724
- opacity: 0;
4725
- }
4726
- 50% {
4727
- transform: scale(1.1);
4728
- }
4729
- 100% {
4730
- transform: scale(1);
4731
- opacity: 1;
4732
- }
4777
+ .label-count {
4778
+ top: -20px;
4779
+ right: 0;
4733
4780
  }
4734
4781
 
4735
- .badge {
4736
- position: fixed;
4737
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
4738
- font-size: 10px;
4739
- font-weight: bold;
4740
- padding: 2px 6px;
4741
- border-radius: 4px;
4742
- color: white;
4743
- pointer-events: none;
4744
- z-index: 2;
4745
- white-space: nowrap;
4782
+ .label-count.bump {
4783
+ animation: bump 0.2s ease-out;
4784
+ }
4785
+
4786
+ @keyframes bump {
4787
+ 0% { transform: scale(1); }
4788
+ 50% { transform: scale(1.2); }
4789
+ 100% { transform: scale(1); }
4746
4790
  }
4747
4791
 
4748
- .toolbar {
4792
+ /* Panel styles */
4793
+ .panel {
4749
4794
  position: fixed;
4750
- top: 10px;
4751
- right: 10px;
4752
- background: rgba(0, 0, 0, 0.9);
4753
- border-radius: 8px;
4754
- padding: 8px 12px;
4795
+ top: 12px;
4796
+ right: 12px;
4797
+ background: linear-gradient(135deg, rgba(17, 17, 23, 0.98) 0%, rgba(12, 12, 18, 0.98) 100%);
4798
+ border: 1px solid rgba(255, 255, 255, 0.08);
4799
+ border-radius: 12px;
4755
4800
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
4756
4801
  font-size: 12px;
4757
- color: white;
4802
+ color: #e5e7eb;
4758
4803
  pointer-events: auto;
4759
4804
  z-index: 10;
4760
- cursor: move;
4761
4805
  user-select: none;
4806
+ width: 320px;
4807
+ max-height: 480px;
4808
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
4809
+ backdrop-filter: blur(12px);
4810
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
4811
+ overflow: hidden;
4812
+ }
4813
+
4814
+ .panel.collapsed {
4815
+ width: 48px;
4816
+ height: 48px;
4817
+ border-radius: 50%;
4818
+ cursor: pointer;
4819
+ display: flex;
4820
+ align-items: center;
4821
+ justify-content: center;
4822
+ }
4823
+
4824
+ .panel.collapsed:hover {
4825
+ transform: scale(1.08);
4826
+ box-shadow: 0 8px 32px rgba(34, 197, 94, 0.3);
4827
+ }
4828
+
4829
+ .panel.collapsed .panel-content {
4830
+ display: none;
4831
+ }
4832
+
4833
+ .panel-icon {
4834
+ display: none;
4835
+ width: 28px;
4836
+ height: 28px;
4837
+ fill: #22c55e;
4838
+ filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.5));
4762
4839
  }
4763
4840
 
4764
- .toolbar-header {
4841
+ .panel.collapsed .panel-icon {
4842
+ display: block;
4843
+ }
4844
+
4845
+ .panel-content {
4846
+ display: flex;
4847
+ flex-direction: column;
4848
+ pointer-events: auto;
4849
+ }
4850
+
4851
+ /* Header */
4852
+ .panel-header {
4765
4853
  display: flex;
4766
4854
  align-items: center;
4767
4855
  justify-content: space-between;
4768
- margin-bottom: 8px;
4856
+ padding: 12px 14px;
4857
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
4858
+ cursor: move;
4859
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
4769
4860
  }
4770
4861
 
4771
- .toolbar-title {
4772
- font-weight: bold;
4773
- color: #22c55e;
4862
+ .panel-brand {
4863
+ display: flex;
4864
+ align-items: center;
4865
+ gap: 8px;
4774
4866
  }
4775
4867
 
4776
- .toolbar-close {
4777
- background: none;
4868
+ .panel-logo {
4869
+ width: 20px;
4870
+ height: 20px;
4871
+ fill: #22c55e;
4872
+ }
4873
+
4874
+ .panel-title {
4875
+ font-weight: 700;
4876
+ font-size: 13px;
4877
+ background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);
4878
+ -webkit-background-clip: text;
4879
+ -webkit-text-fill-color: transparent;
4880
+ background-clip: text;
4881
+ }
4882
+
4883
+ .panel-status {
4884
+ display: flex;
4885
+ align-items: center;
4886
+ gap: 6px;
4887
+ font-size: 10px;
4888
+ color: #6b7280;
4889
+ }
4890
+
4891
+ .status-dot {
4892
+ width: 6px;
4893
+ height: 6px;
4894
+ border-radius: 50%;
4895
+ background: #22c55e;
4896
+ box-shadow: 0 0 8px #22c55e;
4897
+ animation: pulse 2s infinite;
4898
+ }
4899
+
4900
+ @keyframes pulse {
4901
+ 0%, 100% { opacity: 1; }
4902
+ 50% { opacity: 0.5; }
4903
+ }
4904
+
4905
+ .panel-actions {
4906
+ display: flex;
4907
+ gap: 4px;
4908
+ }
4909
+
4910
+ .panel-btn {
4911
+ background: rgba(255, 255, 255, 0.05);
4778
4912
  border: none;
4913
+ border-radius: 6px;
4779
4914
  color: #9ca3af;
4915
+ width: 28px;
4916
+ height: 28px;
4780
4917
  cursor: pointer;
4781
- font-size: 16px;
4782
- padding: 0;
4783
- line-height: 1;
4918
+ display: flex;
4919
+ align-items: center;
4920
+ justify-content: center;
4921
+ transition: all 0.15s;
4784
4922
  }
4785
4923
 
4786
- .toolbar-close:hover {
4924
+ .panel-btn:hover {
4925
+ background: rgba(255, 255, 255, 0.1);
4787
4926
  color: white;
4788
4927
  }
4789
4928
 
4790
- .toolbar-stats {
4929
+ .panel-btn svg {
4930
+ width: 14px;
4931
+ height: 14px;
4932
+ fill: currentColor;
4933
+ }
4934
+
4935
+ /* Tabs */
4936
+ .panel-tabs {
4937
+ display: flex;
4938
+ padding: 0 8px;
4939
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
4940
+ background: rgba(0, 0, 0, 0.2);
4941
+ }
4942
+
4943
+ .tab {
4944
+ flex: 1;
4945
+ padding: 10px 8px;
4946
+ background: none;
4947
+ border: none;
4948
+ color: #6b7280;
4949
+ font-size: 11px;
4950
+ font-weight: 500;
4951
+ cursor: pointer;
4952
+ transition: all 0.15s;
4953
+ position: relative;
4954
+ display: flex;
4955
+ flex-direction: column;
4956
+ align-items: center;
4957
+ gap: 4px;
4958
+ }
4959
+
4960
+ .tab svg {
4961
+ width: 16px;
4962
+ height: 16px;
4963
+ fill: currentColor;
4964
+ opacity: 0.7;
4965
+ }
4966
+
4967
+ .tab:hover {
4968
+ color: #d1d5db;
4969
+ }
4970
+
4971
+ .tab.active {
4972
+ color: #22c55e;
4973
+ }
4974
+
4975
+ .tab.active svg {
4976
+ opacity: 1;
4977
+ }
4978
+
4979
+ .tab.active::after {
4980
+ content: '';
4981
+ position: absolute;
4982
+ bottom: 0;
4983
+ left: 50%;
4984
+ transform: translateX(-50%);
4985
+ width: 24px;
4986
+ height: 2px;
4987
+ background: linear-gradient(90deg, #22c55e, #4ade80);
4988
+ border-radius: 2px;
4989
+ }
4990
+
4991
+ /* Tab content */
4992
+ .tab-content {
4993
+ display: none;
4994
+ padding: 12px;
4995
+ overflow-y: auto;
4996
+ max-height: 340px;
4997
+ pointer-events: auto;
4998
+ }
4999
+
5000
+ .tab-content.active {
5001
+ display: block;
5002
+ }
5003
+
5004
+ .tab-content::-webkit-scrollbar {
5005
+ width: 4px;
5006
+ }
5007
+
5008
+ .tab-content::-webkit-scrollbar-track {
5009
+ background: transparent;
5010
+ }
5011
+
5012
+ .tab-content::-webkit-scrollbar-thumb {
5013
+ background: rgba(255, 255, 255, 0.1);
5014
+ border-radius: 2px;
5015
+ }
5016
+
5017
+ /* Overview tab */
5018
+ .stats-grid {
4791
5019
  display: grid;
4792
5020
  grid-template-columns: repeat(2, 1fr);
4793
5021
  gap: 8px;
5022
+ margin-bottom: 12px;
4794
5023
  }
4795
5024
 
4796
- .stat {
5025
+ .stat-card {
5026
+ background: rgba(255, 255, 255, 0.03);
5027
+ border: 1px solid rgba(255, 255, 255, 0.05);
5028
+ border-radius: 8px;
5029
+ padding: 12px;
4797
5030
  text-align: center;
4798
5031
  }
4799
5032
 
5033
+ .stat-card.wide {
5034
+ grid-column: span 2;
5035
+ }
5036
+
4800
5037
  .stat-value {
4801
- font-size: 18px;
4802
- font-weight: bold;
5038
+ font-size: 24px;
5039
+ font-weight: 700;
5040
+ font-family: ui-monospace, monospace;
5041
+ line-height: 1;
5042
+ margin-bottom: 4px;
4803
5043
  }
4804
5044
 
4805
5045
  .stat-label {
4806
5046
  font-size: 10px;
4807
- color: #9ca3af;
5047
+ color: #6b7280;
4808
5048
  text-transform: uppercase;
5049
+ letter-spacing: 0.5px;
4809
5050
  }
4810
5051
 
4811
- .stat-critical .stat-value { color: #ef4444; }
4812
- .stat-warning .stat-value { color: #eab308; }
4813
- .stat-healthy .stat-value { color: #22c55e; }
5052
+ .stat-card.critical .stat-value { color: #ef4444; }
5053
+ .stat-card.warning .stat-value { color: #f97316; }
5054
+ .stat-card.healthy .stat-value { color: #22c55e; }
5055
+ .stat-card.info .stat-value { color: #3b82f6; }
4814
5056
 
4815
- .toolbar-controls {
5057
+ .fps-bar {
5058
+ height: 4px;
5059
+ background: rgba(255, 255, 255, 0.1);
5060
+ border-radius: 2px;
4816
5061
  margin-top: 8px;
5062
+ overflow: hidden;
5063
+ }
5064
+
5065
+ .fps-bar-fill {
5066
+ height: 100%;
5067
+ border-radius: 2px;
5068
+ transition: width 0.3s, background 0.3s;
5069
+ }
5070
+
5071
+ .quick-actions {
4817
5072
  display: flex;
4818
- gap: 4px;
5073
+ gap: 8px;
5074
+ margin-top: 12px;
5075
+ }
5076
+
5077
+ .action-btn {
5078
+ flex: 1;
5079
+ padding: 10px;
5080
+ background: rgba(255, 255, 255, 0.05);
5081
+ border: 1px solid rgba(255, 255, 255, 0.08);
5082
+ border-radius: 8px;
5083
+ color: #d1d5db;
5084
+ font-size: 11px;
5085
+ font-weight: 500;
5086
+ cursor: pointer;
5087
+ transition: all 0.15s;
5088
+ display: flex;
5089
+ align-items: center;
5090
+ justify-content: center;
5091
+ gap: 6px;
4819
5092
  }
4820
5093
 
4821
- .toolbar-btn {
5094
+ .action-btn:hover {
4822
5095
  background: rgba(255, 255, 255, 0.1);
4823
- border: none;
5096
+ border-color: rgba(255, 255, 255, 0.15);
5097
+ }
5098
+
5099
+ .action-btn.active {
5100
+ background: rgba(34, 197, 94, 0.15);
5101
+ border-color: rgba(34, 197, 94, 0.3);
5102
+ color: #22c55e;
5103
+ }
5104
+
5105
+ .action-btn svg {
5106
+ width: 14px;
5107
+ height: 14px;
5108
+ fill: currentColor;
5109
+ }
5110
+
5111
+ /* Components tab */
5112
+ .component-list {
5113
+ display: flex;
5114
+ flex-direction: column;
5115
+ gap: 6px;
5116
+ }
5117
+
5118
+ .component-item {
5119
+ display: flex;
5120
+ align-items: center;
5121
+ padding: 10px;
5122
+ background: rgba(255, 255, 255, 0.02);
5123
+ border: 1px solid rgba(255, 255, 255, 0.05);
5124
+ border-radius: 8px;
5125
+ cursor: pointer;
5126
+ transition: all 0.15s;
5127
+ }
5128
+
5129
+ .component-item:hover {
5130
+ background: rgba(255, 255, 255, 0.05);
5131
+ border-color: rgba(255, 255, 255, 0.1);
5132
+ }
5133
+
5134
+ .component-severity {
5135
+ width: 4px;
5136
+ height: 32px;
5137
+ border-radius: 2px;
5138
+ margin-right: 10px;
5139
+ }
5140
+
5141
+ .component-info {
5142
+ flex: 1;
5143
+ min-width: 0;
5144
+ }
5145
+
5146
+ .component-name {
5147
+ font-weight: 600;
5148
+ font-size: 12px;
5149
+ color: #e5e7eb;
5150
+ white-space: nowrap;
5151
+ overflow: hidden;
5152
+ text-overflow: ellipsis;
5153
+ }
5154
+
5155
+ .component-meta {
5156
+ font-size: 10px;
5157
+ color: #6b7280;
5158
+ margin-top: 2px;
5159
+ }
5160
+
5161
+ .component-count {
5162
+ font-family: ui-monospace, monospace;
5163
+ font-size: 14px;
5164
+ font-weight: 700;
5165
+ padding: 4px 10px;
5166
+ border-radius: 6px;
5167
+ background: rgba(255, 255, 255, 0.05);
5168
+ }
5169
+
5170
+ .empty-state {
5171
+ text-align: center;
5172
+ padding: 32px 16px;
5173
+ color: #6b7280;
5174
+ }
5175
+
5176
+ .empty-state svg {
5177
+ width: 40px;
5178
+ height: 40px;
5179
+ fill: currentColor;
5180
+ opacity: 0.3;
5181
+ margin-bottom: 12px;
5182
+ }
5183
+
5184
+ /* Chains tab */
5185
+ .chain-item {
5186
+ padding: 12px;
5187
+ background: rgba(255, 255, 255, 0.02);
5188
+ border: 1px solid rgba(255, 255, 255, 0.05);
5189
+ border-radius: 8px;
5190
+ margin-bottom: 8px;
5191
+ }
5192
+
5193
+ .chain-header {
5194
+ display: flex;
5195
+ align-items: center;
5196
+ justify-content: space-between;
5197
+ margin-bottom: 8px;
5198
+ }
5199
+
5200
+ .chain-trigger {
5201
+ font-weight: 600;
5202
+ color: #f97316;
5203
+ }
5204
+
5205
+ .chain-count {
5206
+ font-size: 10px;
5207
+ color: #6b7280;
5208
+ background: rgba(255, 255, 255, 0.05);
5209
+ padding: 2px 8px;
4824
5210
  border-radius: 4px;
4825
- color: white;
5211
+ }
5212
+
5213
+ .chain-flow {
5214
+ display: flex;
5215
+ flex-wrap: wrap;
5216
+ align-items: center;
5217
+ gap: 4px;
5218
+ font-size: 11px;
5219
+ }
5220
+
5221
+ .chain-node {
4826
5222
  padding: 4px 8px;
5223
+ background: rgba(255, 255, 255, 0.05);
5224
+ border-radius: 4px;
5225
+ color: #d1d5db;
5226
+ }
5227
+
5228
+ .chain-arrow {
5229
+ color: #6b7280;
5230
+ }
5231
+
5232
+ /* Settings tab */
5233
+ .setting-group {
5234
+ margin-bottom: 16px;
5235
+ }
5236
+
5237
+ .setting-label {
5238
+ font-size: 11px;
5239
+ font-weight: 500;
5240
+ color: #9ca3af;
5241
+ margin-bottom: 8px;
5242
+ text-transform: uppercase;
5243
+ letter-spacing: 0.5px;
5244
+ }
5245
+
5246
+ .setting-row {
5247
+ display: flex;
5248
+ align-items: center;
5249
+ justify-content: space-between;
5250
+ padding: 10px 12px;
5251
+ background: rgba(255, 255, 255, 0.02);
5252
+ border: 1px solid rgba(255, 255, 255, 0.05);
5253
+ border-radius: 8px;
5254
+ margin-bottom: 6px;
5255
+ }
5256
+
5257
+ .setting-name {
5258
+ font-size: 12px;
5259
+ color: #e5e7eb;
5260
+ }
5261
+
5262
+ .setting-desc {
4827
5263
  font-size: 10px;
5264
+ color: #6b7280;
5265
+ margin-top: 2px;
5266
+ }
5267
+
5268
+ /* Toggle switch */
5269
+ .toggle {
5270
+ position: relative;
5271
+ width: 40px;
5272
+ height: 22px;
5273
+ background: rgba(255, 255, 255, 0.1);
5274
+ border-radius: 11px;
4828
5275
  cursor: pointer;
5276
+ transition: background 0.2s;
5277
+ }
5278
+
5279
+ .toggle.active {
5280
+ background: #22c55e;
5281
+ }
5282
+
5283
+ .toggle::after {
5284
+ content: '';
5285
+ position: absolute;
5286
+ top: 3px;
5287
+ left: 3px;
5288
+ width: 16px;
5289
+ height: 16px;
5290
+ background: white;
5291
+ border-radius: 50%;
5292
+ transition: transform 0.2s;
5293
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
5294
+ }
5295
+
5296
+ .toggle.active::after {
5297
+ transform: translateX(18px);
5298
+ }
5299
+
5300
+ /* Range slider */
5301
+ .range-container {
5302
+ display: flex;
5303
+ align-items: center;
5304
+ gap: 12px;
5305
+ }
5306
+
5307
+ .range-value {
5308
+ font-family: ui-monospace, monospace;
5309
+ font-size: 12px;
5310
+ color: #22c55e;
5311
+ min-width: 40px;
5312
+ text-align: right;
4829
5313
  }
4830
5314
 
4831
- .toolbar-btn:hover {
4832
- background: rgba(255, 255, 255, 0.2);
5315
+ input[type="range"] {
5316
+ flex: 1;
5317
+ height: 4px;
5318
+ -webkit-appearance: none;
5319
+ background: rgba(255, 255, 255, 0.1);
5320
+ border-radius: 2px;
5321
+ outline: none;
4833
5322
  }
4834
5323
 
4835
- .toolbar-btn.active {
4836
- background: #3b82f6;
5324
+ input[type="range"]::-webkit-slider-thumb {
5325
+ -webkit-appearance: none;
5326
+ width: 14px;
5327
+ height: 14px;
5328
+ background: #22c55e;
5329
+ border-radius: 50%;
5330
+ cursor: pointer;
5331
+ box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
4837
5332
  }
4838
5333
  `;
4839
5334
  this.shadowRoot.appendChild(style);
4840
5335
  }
4841
5336
  /**
4842
- * Create the floating toolbar
5337
+ * Create the floating panel
4843
5338
  */
4844
5339
  createToolbar() {
4845
5340
  if (!this.shadowRoot) return;
4846
5341
  this.toolbar = document.createElement("div");
4847
- this.toolbar.className = "toolbar";
5342
+ this.toolbar.className = "panel";
4848
5343
  this.toolbar.innerHTML = `
4849
- <div class="toolbar-header">
4850
- <span class="toolbar-title">ReactCheck</span>
4851
- <button class="toolbar-close" title="Close">\xD7</button>
4852
- </div>
4853
- <div class="toolbar-stats">
4854
- <div class="stat stat-critical">
4855
- <div class="stat-value" id="rc-critical">0</div>
4856
- <div class="stat-label">Critical</div>
5344
+ <!-- Collapsed icon -->
5345
+ <svg class="panel-icon" viewBox="0 0 24 24">
5346
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
5347
+ </svg>
5348
+
5349
+ <div class="panel-content">
5350
+ <!-- Header -->
5351
+ <div class="panel-header">
5352
+ <div class="panel-brand">
5353
+ <svg class="panel-logo" viewBox="0 0 24 24">
5354
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
5355
+ </svg>
5356
+ <span class="panel-title">ReactCheck</span>
5357
+ </div>
5358
+ <div class="panel-status">
5359
+ <span class="status-dot"></span>
5360
+ <span id="rc-duration">0:00</span>
5361
+ </div>
5362
+ <div class="panel-actions">
5363
+ <button class="panel-btn" id="rc-collapse" title="Minimize">
5364
+ <svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>
5365
+ </button>
5366
+ </div>
5367
+ </div>
5368
+
5369
+ <!-- Tabs -->
5370
+ <div class="panel-tabs">
5371
+ <button class="tab active" data-tab="overview">
5372
+ <svg viewBox="0 0 24 24"><path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/></svg>
5373
+ Overview
5374
+ </button>
5375
+ <button class="tab" data-tab="components">
5376
+ <svg viewBox="0 0 24 24"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/></svg>
5377
+ Components
5378
+ </button>
5379
+ <button class="tab" data-tab="chains">
5380
+ <svg viewBox="0 0 24 24"><path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5zm-1 4h-2.19l2 2H16zM2 4.27l3.11 3.11C3.29 8.12 2 9.91 2 12c0 2.76 2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1 0-1.59 1.21-2.9 2.76-3.07L8.73 11H8v2h2.73L13 15.27V17h1.73l4.01 4.01 1.41-1.41L3.41 2.86 2 4.27z"/></svg>
5381
+ Chains
5382
+ </button>
5383
+ <button class="tab" data-tab="settings">
5384
+ <svg viewBox="0 0 24 24"><path d="M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></svg>
5385
+ Settings
5386
+ </button>
4857
5387
  </div>
4858
- <div class="stat stat-warning">
4859
- <div class="stat-value" id="rc-warning">0</div>
4860
- <div class="stat-label">Warning</div>
5388
+
5389
+ <!-- Overview Tab -->
5390
+ <div class="tab-content active" data-content="overview">
5391
+ <div class="stats-grid">
5392
+ <div class="stat-card critical">
5393
+ <div class="stat-value" id="rc-critical">0</div>
5394
+ <div class="stat-label">Critical</div>
5395
+ </div>
5396
+ <div class="stat-card warning">
5397
+ <div class="stat-value" id="rc-warning">0</div>
5398
+ <div class="stat-label">Warning</div>
5399
+ </div>
5400
+ <div class="stat-card healthy">
5401
+ <div class="stat-value" id="rc-healthy">0</div>
5402
+ <div class="stat-label">Healthy</div>
5403
+ </div>
5404
+ <div class="stat-card info">
5405
+ <div class="stat-value" id="rc-renders">0</div>
5406
+ <div class="stat-label">Renders</div>
5407
+ </div>
5408
+ <div class="stat-card wide">
5409
+ <div class="stat-value" id="rc-fps">60</div>
5410
+ <div class="stat-label">FPS</div>
5411
+ <div class="fps-bar">
5412
+ <div class="fps-bar-fill" id="rc-fps-bar" style="width: 100%; background: #22c55e;"></div>
5413
+ </div>
5414
+ </div>
5415
+ </div>
5416
+
5417
+ <div class="quick-actions">
5418
+ <button class="action-btn active" id="rc-toggle-highlights">
5419
+ <svg viewBox="0 0 24 24"><path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7z"/></svg>
5420
+ Highlights
5421
+ </button>
5422
+ <button class="action-btn" id="rc-clear">
5423
+ <svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
5424
+ Clear
5425
+ </button>
5426
+ </div>
4861
5427
  </div>
4862
- <div class="stat stat-healthy">
4863
- <div class="stat-value" id="rc-healthy">0</div>
4864
- <div class="stat-label">Healthy</div>
5428
+
5429
+ <!-- Components Tab -->
5430
+ <div class="tab-content" data-content="components">
5431
+ <div class="component-list" id="rc-component-list">
5432
+ <div class="empty-state">
5433
+ <svg viewBox="0 0 24 24"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/></svg>
5434
+ <div>No components rendered yet</div>
5435
+ </div>
5436
+ </div>
4865
5437
  </div>
4866
- <div class="stat">
4867
- <div class="stat-value" id="rc-renders">0</div>
4868
- <div class="stat-label">Renders</div>
5438
+
5439
+ <!-- Chains Tab -->
5440
+ <div class="tab-content" data-content="chains">
5441
+ <div id="rc-chain-list">
5442
+ <div class="empty-state">
5443
+ <svg viewBox="0 0 24 24"><path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5z"/></svg>
5444
+ <div>No render chains detected</div>
5445
+ </div>
5446
+ </div>
5447
+ </div>
5448
+
5449
+ <!-- Settings Tab -->
5450
+ <div class="tab-content" data-content="settings">
5451
+ <div class="setting-group">
5452
+ <div class="setting-label">Display</div>
5453
+ <div class="setting-row">
5454
+ <div>
5455
+ <div class="setting-name">Show Highlights</div>
5456
+ <div class="setting-desc">Outline rendered components</div>
5457
+ </div>
5458
+ <div class="toggle active" id="rc-setting-highlights"></div>
5459
+ </div>
5460
+ </div>
5461
+
5462
+ <div class="setting-group">
5463
+ <div class="setting-label">Timing</div>
5464
+ <div class="setting-row">
5465
+ <div>
5466
+ <div class="setting-name">Highlight Duration</div>
5467
+ <div class="setting-desc">How long highlights stay visible</div>
5468
+ </div>
5469
+ <div class="range-container">
5470
+ <input type="range" id="rc-setting-duration" min="500" max="10000" step="500" value="2000">
5471
+ <span class="range-value" id="rc-duration-value">2s</span>
5472
+ </div>
5473
+ </div>
5474
+ </div>
5475
+
5476
+ <div class="setting-group">
5477
+ <div class="setting-label">About</div>
5478
+ <div class="setting-row" style="flex-direction: column; align-items: flex-start; gap: 4px;">
5479
+ <div class="setting-name">ReactCheck v1.1.6</div>
5480
+ <div class="setting-desc">React performance scanner</div>
5481
+ </div>
5482
+ </div>
4869
5483
  </div>
4870
- </div>
4871
- <div class="toolbar-controls">
4872
- <button class="toolbar-btn active" id="rc-highlights">Highlights</button>
4873
- <button class="toolbar-btn active" id="rc-badges">Badges</button>
4874
- <button class="toolbar-btn" id="rc-clear">Clear</button>
4875
5484
  </div>
4876
5485
  `;
5486
+ this.shadowRoot.appendChild(this.toolbar);
4877
5487
  this.setupToolbarEvents();
4878
5488
  this.makeDraggable(this.toolbar);
4879
- this.shadowRoot.appendChild(this.toolbar);
4880
5489
  }
4881
5490
  /**
4882
5491
  * Set up toolbar event listeners
4883
5492
  */
4884
5493
  setupToolbarEvents() {
4885
5494
  if (!this.toolbar || !this.shadowRoot) return;
4886
- const closeBtn = this.toolbar.querySelector(".toolbar-close");
4887
- if (closeBtn) {
4888
- closeBtn.addEventListener("click", () => {
4889
- this.hide();
5495
+ const collapseBtn = this.shadowRoot.getElementById("rc-collapse");
5496
+ if (collapseBtn) {
5497
+ collapseBtn.addEventListener("click", (e) => {
5498
+ e.stopPropagation();
5499
+ this.toggleCollapse();
4890
5500
  });
4891
5501
  }
4892
- const highlightsBtn = this.shadowRoot.getElementById("rc-highlights");
5502
+ this.toolbar.addEventListener("click", (e) => {
5503
+ const target = e.target;
5504
+ if (this.collapsed && (target === this.toolbar || target.closest(".panel-icon"))) {
5505
+ this.toggleCollapse();
5506
+ }
5507
+ });
5508
+ const tabs = this.toolbar.querySelectorAll(".tab");
5509
+ tabs.forEach((tab) => {
5510
+ tab.addEventListener("click", () => {
5511
+ const tabName = tab.getAttribute("data-tab");
5512
+ this.switchTab(tabName);
5513
+ });
5514
+ });
5515
+ const highlightsBtn = this.shadowRoot.getElementById("rc-toggle-highlights");
4893
5516
  if (highlightsBtn) {
4894
5517
  highlightsBtn.addEventListener("click", () => {
4895
5518
  this.config.highlightRenders = !this.config.highlightRenders;
4896
5519
  highlightsBtn.classList.toggle("active", this.config.highlightRenders);
4897
- if (!this.config.highlightRenders) {
4898
- this.clearHighlights();
4899
- }
4900
- });
4901
- }
4902
- const badgesBtn = this.shadowRoot.getElementById("rc-badges");
4903
- if (badgesBtn) {
4904
- badgesBtn.addEventListener("click", () => {
4905
- this.config.showBadges = !this.config.showBadges;
4906
- badgesBtn.classList.toggle("active", this.config.showBadges);
4907
- if (!this.config.showBadges) {
4908
- this.clearBadges();
4909
- }
5520
+ this.updateHighlightsVisibility();
4910
5521
  });
4911
5522
  }
4912
5523
  const clearBtn = this.shadowRoot.getElementById("rc-clear");
@@ -4915,10 +5526,65 @@ var Overlay = class {
4915
5526
  this.clear();
4916
5527
  });
4917
5528
  }
5529
+ const settingHighlights = this.shadowRoot.getElementById("rc-setting-highlights");
5530
+ if (settingHighlights) {
5531
+ settingHighlights.addEventListener("click", () => {
5532
+ this.config.highlightRenders = !this.config.highlightRenders;
5533
+ settingHighlights.classList.toggle("active", this.config.highlightRenders);
5534
+ highlightsBtn?.classList.toggle("active", this.config.highlightRenders);
5535
+ this.updateHighlightsVisibility();
5536
+ });
5537
+ }
5538
+ const durationSlider = this.shadowRoot.getElementById("rc-setting-duration");
5539
+ const durationValue = this.shadowRoot.getElementById("rc-duration-value");
5540
+ if (durationSlider && durationValue) {
5541
+ durationSlider.addEventListener("input", () => {
5542
+ const value = parseInt(durationSlider.value, 10);
5543
+ this.config.highlightDuration = value;
5544
+ durationValue.textContent = value >= 1e3 ? `${value / 1e3}s` : `${value}ms`;
5545
+ });
5546
+ }
5547
+ }
5548
+ /**
5549
+ * Toggle collapse state
5550
+ */
5551
+ toggleCollapse() {
5552
+ this.collapsed = !this.collapsed;
5553
+ if (this.toolbar) {
5554
+ this.toolbar.classList.toggle("collapsed", this.collapsed);
5555
+ }
5556
+ }
5557
+ /**
5558
+ * Switch active tab
5559
+ */
5560
+ switchTab(tabName) {
5561
+ if (!this.toolbar) return;
5562
+ const tabs = this.toolbar.querySelectorAll(".tab");
5563
+ tabs.forEach((tab) => {
5564
+ const isActive = tab.getAttribute("data-tab") === tabName;
5565
+ tab.classList.toggle("active", isActive);
5566
+ });
5567
+ const contents = this.toolbar.querySelectorAll(".tab-content");
5568
+ contents.forEach((content) => {
5569
+ const isActive = content.getAttribute("data-content") === tabName;
5570
+ content.classList.toggle("active", isActive);
5571
+ });
5572
+ if (tabName === "components") {
5573
+ this.updateComponentList();
5574
+ } else if (tabName === "chains") {
5575
+ this.updateChainList();
5576
+ }
5577
+ }
5578
+ /**
5579
+ * Update highlights visibility
5580
+ */
5581
+ updateHighlightsVisibility() {
5582
+ for (const tracked of this.trackedComponents.values()) {
5583
+ tracked.highlightEl.style.display = this.config.highlightRenders ? "block" : "none";
5584
+ }
4918
5585
  }
4919
5586
  /**
4920
5587
  * Make an element draggable
4921
- * @param element - Element to make draggable
4922
5588
  */
4923
5589
  makeDraggable(element) {
4924
5590
  let isDragging = false;
@@ -4926,11 +5592,14 @@ var Overlay = class {
4926
5592
  let startY = 0;
4927
5593
  let initialX = 0;
4928
5594
  let initialY = 0;
4929
- element.addEventListener("mousedown", (e) => {
4930
- if (e.target.tagName === "BUTTON") return;
5595
+ const header = element.querySelector(".panel-header");
5596
+ if (!header) return;
5597
+ header.addEventListener("mousedown", (e) => {
5598
+ const mouseEvent = e;
5599
+ if (mouseEvent.target.closest(".panel-btn")) return;
4931
5600
  isDragging = true;
4932
- startX = e.clientX;
4933
- startY = e.clientY;
5601
+ startX = mouseEvent.clientX;
5602
+ startY = mouseEvent.clientY;
4934
5603
  initialX = element.offsetLeft;
4935
5604
  initialY = element.offsetTop;
4936
5605
  });
@@ -4946,120 +5615,187 @@ var Overlay = class {
4946
5615
  isDragging = false;
4947
5616
  });
4948
5617
  }
4949
- /**
4950
- * Highlight a component render with flash effect
4951
- * @param render - Render information
4952
- * @param element - DOM element to highlight
5618
+ /** Maximum number of highlights to show at once */
5619
+ static MAX_HIGHLIGHTS = 50;
5620
+ /** Component names to skip (generic/internal) */
5621
+ static SKIP_COMPONENTS = /* @__PURE__ */ new Set([
5622
+ "ForwardRef",
5623
+ "Anonymous",
5624
+ "Unknown",
5625
+ "Fragment",
5626
+ "Suspense",
5627
+ "Context.Provider",
5628
+ "Context.Consumer",
5629
+ "Profiler",
5630
+ "Root",
5631
+ "#text"
5632
+ ]);
5633
+ /**
5634
+ * Highlight a component render
4953
5635
  */
4954
5636
  highlight(render, element) {
4955
- if (!this.config.highlightRenders || !this.shadowRoot || !this.visible) return;
5637
+ if (!this.shadowRoot || !this.visible) return;
5638
+ if (_Overlay.SKIP_COMPONENTS.has(render.componentName)) {
5639
+ return;
5640
+ }
4956
5641
  const rect = element.getBoundingClientRect();
4957
5642
  if (rect.width === 0 || rect.height === 0) return;
5643
+ if (this.trackedComponents.size >= _Overlay.MAX_HIGHLIGHTS && !this.trackedComponents.has(render.componentName)) {
5644
+ const oldest = this.getOldestTrackedComponent();
5645
+ if (oldest) {
5646
+ this.removeHighlight(oldest);
5647
+ }
5648
+ }
5649
+ this.totalRenders++;
4958
5650
  const severity = this.getSeverity(render);
4959
- const borderColor = SEVERITY_COLORS[severity];
4960
- const flashColor = FLASH_COLORS[severity];
4961
- this.createFlashOverlay(rect, flashColor);
4962
- let highlight = this.highlights.get(render.componentName);
4963
- if (!highlight) {
4964
- highlight = document.createElement("div");
4965
- highlight.className = "highlight";
4966
- this.shadowRoot.appendChild(highlight);
4967
- this.highlights.set(render.componentName, highlight);
4968
- }
4969
- highlight.style.animation = "none";
4970
- highlight.offsetHeight;
4971
- highlight.style.animation = "";
4972
- highlight.style.cssText = `
4973
- position: fixed;
4974
- left: ${rect.left}px;
4975
- top: ${rect.top}px;
4976
- width: ${rect.width}px;
4977
- height: ${rect.height}px;
4978
- border: 2px solid ${borderColor};
4979
- color: ${borderColor};
4980
- pointer-events: none;
4981
- z-index: 1;
4982
- animation: highlight-pulse 0.5s ease-out;
4983
- `;
4984
- highlight.classList.remove("fade");
4985
- const duration = ANIMATION_DURATIONS[this.config.animationSpeed];
4986
- if (duration > 0) {
4987
- setTimeout(() => {
4988
- highlight?.classList.add("fade");
4989
- }, duration);
5651
+ const color = SEVERITY_COLORS[severity];
5652
+ let tracked = this.trackedComponents.get(render.componentName);
5653
+ if (tracked) {
5654
+ tracked.count++;
5655
+ tracked.element = element;
5656
+ tracked.lastRender = Date.now();
5657
+ tracked.severity = severity;
5658
+ tracked.renderTimes.push(render.renderTime);
5659
+ if (tracked.renderTimes.length > 100) tracked.renderTimes.shift();
5660
+ this.updateHighlightPosition(tracked, rect, color);
5661
+ const countLabel2 = tracked.highlightEl.querySelector(".label-count");
5662
+ if (countLabel2) {
5663
+ countLabel2.classList.remove("bump");
5664
+ void countLabel2.offsetWidth;
5665
+ countLabel2.classList.add("bump");
5666
+ }
5667
+ } else {
5668
+ const container = this.createHighlightElement(render.componentName, rect, color);
5669
+ tracked = {
5670
+ element,
5671
+ highlightEl: container,
5672
+ lastRender: Date.now(),
5673
+ count: 1,
5674
+ severity,
5675
+ renderTimes: [render.renderTime]
5676
+ };
5677
+ this.trackedComponents.set(render.componentName, tracked);
5678
+ this.shadowRoot.appendChild(container);
4990
5679
  }
4991
- if (this.config.showBadges) {
4992
- this.updateBadge(render, rect, borderColor);
5680
+ const countLabel = tracked.highlightEl.querySelector(".label-count");
5681
+ if (countLabel) {
5682
+ countLabel.textContent = `\xD7${tracked.count}`;
4993
5683
  }
4994
- this.updateStats();
5684
+ this.updateHighlightColor(tracked.highlightEl, color);
5685
+ this.resetFadeTimeout(render.componentName, tracked);
4995
5686
  }
4996
5687
  /**
4997
- * Create a flash overlay effect on the element
4998
- * @param rect - Element bounding rectangle
4999
- * @param color - Flash color
5688
+ * Add a render chain
5000
5689
  */
5001
- createFlashOverlay(rect, color) {
5002
- if (!this.shadowRoot) return;
5003
- const flash = document.createElement("div");
5004
- flash.className = "flash-overlay";
5005
- flash.style.cssText = `
5690
+ addChain(chain) {
5691
+ this.renderChains.unshift(chain);
5692
+ if (this.renderChains.length > 50) {
5693
+ this.renderChains.pop();
5694
+ }
5695
+ }
5696
+ /**
5697
+ * Update FPS value
5698
+ */
5699
+ updateFps(fps) {
5700
+ this.fps = fps;
5701
+ }
5702
+ /**
5703
+ * Create a highlight element
5704
+ */
5705
+ createHighlightElement(name, rect, color) {
5706
+ const container = document.createElement("div");
5707
+ container.className = "highlight-container";
5708
+ container.style.cssText = `
5006
5709
  left: ${rect.left}px;
5007
5710
  top: ${rect.top}px;
5008
5711
  width: ${rect.width}px;
5009
5712
  height: ${rect.height}px;
5010
- background: ${color};
5713
+ color: ${color};
5714
+ display: ${this.config.highlightRenders ? "block" : "none"};
5011
5715
  `;
5012
- this.shadowRoot.appendChild(flash);
5013
- setTimeout(() => {
5014
- flash.remove();
5015
- }, 500);
5716
+ const border = document.createElement("div");
5717
+ border.className = "highlight-border";
5718
+ container.appendChild(border);
5719
+ const nameLabel = document.createElement("div");
5720
+ nameLabel.className = "label label-name";
5721
+ nameLabel.style.background = color;
5722
+ nameLabel.textContent = name;
5723
+ container.appendChild(nameLabel);
5724
+ const countLabel = document.createElement("div");
5725
+ countLabel.className = "label label-count";
5726
+ countLabel.style.background = color;
5727
+ countLabel.textContent = "\xD71";
5728
+ container.appendChild(countLabel);
5729
+ return container;
5730
+ }
5731
+ /**
5732
+ * Update highlight position
5733
+ */
5734
+ updateHighlightPosition(tracked, rect, color) {
5735
+ tracked.highlightEl.style.left = `${rect.left}px`;
5736
+ tracked.highlightEl.style.top = `${rect.top}px`;
5737
+ tracked.highlightEl.style.width = `${rect.width}px`;
5738
+ tracked.highlightEl.style.height = `${rect.height}px`;
5739
+ tracked.highlightEl.style.color = color;
5740
+ tracked.highlightEl.classList.remove("fade");
5741
+ }
5742
+ /**
5743
+ * Update highlight color
5744
+ */
5745
+ updateHighlightColor(container, color) {
5746
+ container.style.color = color;
5747
+ const labels = container.querySelectorAll(".label");
5748
+ labels.forEach((label) => {
5749
+ label.style.background = color;
5750
+ });
5016
5751
  }
5017
5752
  /**
5018
- * Update or create a badge for a component
5019
- * @param render - Render information
5020
- * @param rect - Bounding rectangle
5021
- * @param color - Badge color
5753
+ * Reset fade timeout
5022
5754
  */
5023
- updateBadge(render, rect, color) {
5024
- if (!this.shadowRoot) return;
5025
- const count = (this.renderCounts.get(render.componentName) ?? 0) + 1;
5026
- this.renderCounts.set(render.componentName, count);
5027
- let badge = this.badges.get(render.componentName);
5028
- if (!badge) {
5029
- badge = document.createElement("div");
5030
- badge.className = "badge";
5031
- this.shadowRoot.appendChild(badge);
5032
- this.badges.set(render.componentName, badge);
5033
- }
5034
- const isNewBadge = !this.badges.has(render.componentName);
5035
- badge.textContent = `${render.componentName}: ${count}`;
5036
- badge.style.cssText = `
5037
- position: fixed;
5038
- left: ${rect.left}px;
5039
- top: ${Math.max(0, rect.top - 20)}px;
5040
- background: ${color};
5041
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
5042
- font-size: 10px;
5043
- font-weight: bold;
5044
- padding: 2px 6px;
5045
- border-radius: 4px;
5046
- color: white;
5047
- pointer-events: none;
5048
- z-index: 2;
5049
- white-space: nowrap;
5050
- ${isNewBadge ? "animation: badge-pop 0.3s ease-out;" : ""}
5051
- `;
5052
- if (!isNewBadge) {
5053
- badge.style.transform = "scale(1.15)";
5054
- setTimeout(() => {
5055
- if (badge) badge.style.transform = "scale(1)";
5056
- }, 150);
5755
+ resetFadeTimeout(name, tracked) {
5756
+ const existing = this.fadeTimeouts.get(name);
5757
+ if (existing) {
5758
+ clearTimeout(existing);
5759
+ }
5760
+ if (this.config.highlightDuration > 0) {
5761
+ const timeout = setTimeout(() => {
5762
+ tracked.highlightEl.classList.add("fade");
5763
+ this.fadeTimeouts.delete(name);
5764
+ }, this.config.highlightDuration);
5765
+ this.fadeTimeouts.set(name, timeout);
5057
5766
  }
5058
5767
  }
5059
5768
  /**
5060
- * Get severity level for a render
5061
- * @param render - Render information
5062
- * @returns Severity level
5769
+ * Get the oldest tracked component by last render time
5770
+ */
5771
+ getOldestTrackedComponent() {
5772
+ let oldest = null;
5773
+ let oldestTime = Infinity;
5774
+ for (const [name, tracked] of this.trackedComponents) {
5775
+ if (tracked.lastRender < oldestTime) {
5776
+ oldestTime = tracked.lastRender;
5777
+ oldest = name;
5778
+ }
5779
+ }
5780
+ return oldest;
5781
+ }
5782
+ /**
5783
+ * Remove a highlight by component name
5784
+ */
5785
+ removeHighlight(name) {
5786
+ const tracked = this.trackedComponents.get(name);
5787
+ if (tracked) {
5788
+ tracked.highlightEl.remove();
5789
+ this.trackedComponents.delete(name);
5790
+ const timeout = this.fadeTimeouts.get(name);
5791
+ if (timeout) {
5792
+ clearTimeout(timeout);
5793
+ this.fadeTimeouts.delete(name);
5794
+ }
5795
+ }
5796
+ }
5797
+ /**
5798
+ * Get severity level
5063
5799
  */
5064
5800
  getSeverity(render) {
5065
5801
  if (!render.necessary) return "unnecessary";
@@ -5068,66 +5804,145 @@ var Overlay = class {
5068
5804
  return "healthy";
5069
5805
  }
5070
5806
  /**
5071
- * Record a render event (updates stats even without DOM element)
5072
- * @param render - Render information
5807
+ * Record a render event
5073
5808
  */
5074
5809
  recordRender(render) {
5075
- const count = (this.renderCounts.get(render.componentName) ?? 0) + 1;
5076
- this.renderCounts.set(render.componentName, count);
5810
+ const tracked = this.trackedComponents.get(render.componentName);
5811
+ if (tracked) {
5812
+ tracked.count++;
5813
+ tracked.lastRender = Date.now();
5814
+ tracked.severity = this.getSeverity(render);
5815
+ const countLabel = tracked.highlightEl.querySelector(".label-count");
5816
+ if (countLabel) {
5817
+ countLabel.textContent = `\xD7${tracked.count}`;
5818
+ }
5819
+ }
5077
5820
  this.totalRenders++;
5078
- this.updateStats();
5079
5821
  }
5080
- /** Total render count */
5081
- totalRenders = 0;
5082
5822
  /**
5083
- * Update toolbar stats
5823
+ * Update all stats
5084
5824
  */
5085
5825
  updateStats() {
5086
5826
  if (!this.shadowRoot) return;
5087
5827
  let critical = 0;
5088
5828
  let warning = 0;
5089
5829
  let healthy = 0;
5090
- for (const [, count] of this.renderCounts) {
5091
- if (count > 50) critical++;
5092
- else if (count > 20) warning++;
5830
+ for (const tracked of this.trackedComponents.values()) {
5831
+ if (tracked.count > 50) critical++;
5832
+ else if (tracked.count > 20) warning++;
5093
5833
  else healthy++;
5094
5834
  }
5095
5835
  const criticalEl = this.shadowRoot.getElementById("rc-critical");
5096
5836
  const warningEl = this.shadowRoot.getElementById("rc-warning");
5097
5837
  const healthyEl = this.shadowRoot.getElementById("rc-healthy");
5098
5838
  const rendersEl = this.shadowRoot.getElementById("rc-renders");
5839
+ const fpsEl = this.shadowRoot.getElementById("rc-fps");
5840
+ const fpsBar = this.shadowRoot.getElementById("rc-fps-bar");
5841
+ const durationEl = this.shadowRoot.getElementById("rc-duration");
5099
5842
  if (criticalEl) criticalEl.textContent = String(critical);
5100
5843
  if (warningEl) warningEl.textContent = String(warning);
5101
5844
  if (healthyEl) healthyEl.textContent = String(healthy);
5102
5845
  if (rendersEl) rendersEl.textContent = String(this.totalRenders);
5846
+ if (fpsEl) fpsEl.textContent = String(Math.round(this.fps));
5847
+ if (fpsBar) {
5848
+ const percent = Math.min(100, this.fps / 60 * 100);
5849
+ fpsBar.style.width = `${percent}%`;
5850
+ if (this.fps >= 50) {
5851
+ fpsBar.style.background = "#22c55e";
5852
+ } else if (this.fps >= 30) {
5853
+ fpsBar.style.background = "#f97316";
5854
+ } else {
5855
+ fpsBar.style.background = "#ef4444";
5856
+ }
5857
+ }
5858
+ if (durationEl) {
5859
+ const elapsed = Math.floor((Date.now() - this.startTime) / 1e3);
5860
+ const mins = Math.floor(elapsed / 60);
5861
+ const secs = elapsed % 60;
5862
+ durationEl.textContent = `${mins}:${secs.toString().padStart(2, "0")}`;
5863
+ }
5103
5864
  }
5104
5865
  /**
5105
- * Clear all highlights
5866
+ * Update component list in Components tab
5106
5867
  */
5107
- clearHighlights() {
5108
- for (const highlight of this.highlights.values()) {
5109
- highlight.remove();
5868
+ updateComponentList() {
5869
+ if (!this.shadowRoot) return;
5870
+ const list = this.shadowRoot.getElementById("rc-component-list");
5871
+ if (!list) return;
5872
+ const components = Array.from(this.trackedComponents.entries()).sort((a, b) => b[1].count - a[1].count);
5873
+ if (components.length === 0) {
5874
+ list.innerHTML = `
5875
+ <div class="empty-state">
5876
+ <svg viewBox="0 0 24 24"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/></svg>
5877
+ <div>No components rendered yet</div>
5878
+ </div>
5879
+ `;
5880
+ return;
5110
5881
  }
5111
- this.highlights.clear();
5882
+ list.innerHTML = components.map(([name, tracked]) => {
5883
+ const color = SEVERITY_COLORS[tracked.severity];
5884
+ const avgTime = tracked.renderTimes.length > 0 ? (tracked.renderTimes.reduce((a, b) => a + b, 0) / tracked.renderTimes.length).toFixed(1) : "0";
5885
+ const timeSince = Math.floor((Date.now() - tracked.lastRender) / 1e3);
5886
+ const timeStr = timeSince < 60 ? `${timeSince}s ago` : `${Math.floor(timeSince / 60)}m ago`;
5887
+ return `
5888
+ <div class="component-item">
5889
+ <div class="component-severity" style="background: ${color}"></div>
5890
+ <div class="component-info">
5891
+ <div class="component-name">${name}</div>
5892
+ <div class="component-meta">${avgTime}ms avg \xB7 ${timeStr}</div>
5893
+ </div>
5894
+ <div class="component-count" style="color: ${color}">${tracked.count}</div>
5895
+ </div>
5896
+ `;
5897
+ }).join("");
5112
5898
  }
5113
5899
  /**
5114
- * Clear all badges
5900
+ * Update chain list in Chains tab
5115
5901
  */
5116
- clearBadges() {
5117
- for (const badge of this.badges.values()) {
5118
- badge.remove();
5902
+ updateChainList() {
5903
+ if (!this.shadowRoot) return;
5904
+ const list = this.shadowRoot.getElementById("rc-chain-list");
5905
+ if (!list) return;
5906
+ if (this.renderChains.length === 0) {
5907
+ list.innerHTML = `
5908
+ <div class="empty-state">
5909
+ <svg viewBox="0 0 24 24"><path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5z"/></svg>
5910
+ <div>No render chains detected</div>
5911
+ </div>
5912
+ `;
5913
+ return;
5119
5914
  }
5120
- this.badges.clear();
5915
+ list.innerHTML = this.renderChains.slice(0, 10).map((chain) => {
5916
+ const flow = chain.chain.map((c) => `<span class="chain-node">${c}</span>`).join('<span class="chain-arrow">\u2192</span>');
5917
+ return `
5918
+ <div class="chain-item">
5919
+ <div class="chain-header">
5920
+ <span class="chain-trigger">${chain.trigger}</span>
5921
+ <span class="chain-count">${chain.chain.length} components</span>
5922
+ </div>
5923
+ <div class="chain-flow">${flow}</div>
5924
+ </div>
5925
+ `;
5926
+ }).join("");
5121
5927
  }
5122
5928
  /**
5123
5929
  * Clear all visualizations
5124
5930
  */
5125
5931
  clear() {
5126
- this.clearHighlights();
5127
- this.clearBadges();
5128
- this.renderCounts.clear();
5932
+ for (const timeout of this.fadeTimeouts.values()) {
5933
+ clearTimeout(timeout);
5934
+ }
5935
+ this.fadeTimeouts.clear();
5936
+ for (const tracked of this.trackedComponents.values()) {
5937
+ tracked.highlightEl.remove();
5938
+ }
5939
+ this.trackedComponents.clear();
5940
+ this.renderChains = [];
5129
5941
  this.totalRenders = 0;
5942
+ this.startTime = Date.now();
5130
5943
  this.updateStats();
5944
+ this.updateComponentList();
5945
+ this.updateChainList();
5131
5946
  }
5132
5947
  /**
5133
5948
  * Show the overlay
@@ -5159,18 +5974,26 @@ var Overlay = class {
5159
5974
  }
5160
5975
  /**
5161
5976
  * Update configuration
5162
- * @param config - Partial configuration
5163
5977
  */
5164
5978
  configure(config) {
5165
5979
  this.config = { ...this.config, ...config };
5166
5980
  }
5167
5981
  /**
5168
5982
  * Check if overlay is visible
5169
- * @returns true if visible
5170
5983
  */
5171
5984
  isVisible() {
5172
5985
  return this.visible;
5173
5986
  }
5987
+ /**
5988
+ * Get render counts
5989
+ */
5990
+ getRenderCounts() {
5991
+ const counts = /* @__PURE__ */ new Map();
5992
+ for (const [name, tracked] of this.trackedComponents) {
5993
+ counts.set(name, tracked.count);
5994
+ }
5995
+ return counts;
5996
+ }
5174
5997
  };
5175
5998
 
5176
5999
  // src/browser/scanner.ts
@@ -5245,8 +6068,6 @@ var BrowserScanner = class extends exports.EventEmitter {
5245
6068
  this.overlay = new Overlay({
5246
6069
  enabled: true,
5247
6070
  highlightRenders: this.config.highlightRenders ?? true,
5248
- animationSpeed: this.config.animationSpeed ?? "fast",
5249
- showBadges: true,
5250
6071
  showToolbar: true
5251
6072
  });
5252
6073
  this.overlay.init();
@@ -5526,7 +6347,6 @@ var ReactCheckInjector = class {
5526
6347
  this.overlay = new Overlay({
5527
6348
  enabled: true,
5528
6349
  highlightRenders: true,
5529
- showBadges: true,
5530
6350
  showToolbar: true
5531
6351
  });
5532
6352
  }
@@ -5683,9 +6503,6 @@ var ReactCheckInjector = class {
5683
6503
  if (config.highlightRenders !== void 0) {
5684
6504
  this.overlay.configure({ highlightRenders: config.highlightRenders });
5685
6505
  }
5686
- if (config.animationSpeed !== void 0) {
5687
- this.overlay.configure({ animationSpeed: config.animationSpeed });
5688
- }
5689
6506
  }
5690
6507
  /** Message queue for messages sent before connection */
5691
6508
  messageQueue = [];
@@ -5727,6 +6544,10 @@ var ReactCheckInjector = class {
5727
6544
  }
5728
6545
  };
5729
6546
  (function() {
6547
+ const currentUrl = window.location.href;
6548
+ if (currentUrl === "about:blank" || currentUrl.startsWith("chrome://") || currentUrl.startsWith("chrome-extension://") || currentUrl.startsWith("devtools://")) {
6549
+ return;
6550
+ }
5730
6551
  const win = window;
5731
6552
  if (win.__REACTCHECK_INJECTED__) {
5732
6553
  return;