@oxog/react-check 1.1.0 → 1.1.2
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 +36 -0
- package/README.md +36 -0
- package/dist/browser-inject.global.js +68 -6
- package/dist/chain.d.cts +1 -1
- package/dist/chain.d.ts +1 -1
- package/dist/cli.js +73 -18
- package/dist/cli.js.map +1 -1
- package/dist/detect.d.cts +1 -1
- package/dist/detect.d.ts +1 -1
- package/dist/fix.d.cts +1 -1
- package/dist/fix.d.ts +1 -1
- package/dist/index.cjs +557 -340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -142
- package/dist/index.d.ts +187 -142
- package/dist/index.js +557 -340
- package/dist/index.js.map +1 -1
- package/dist/{scanner-BsBnFki5.d.cts → scanner-5j2LEM-q.d.cts} +1 -1
- package/dist/{scanner-bpT7eMcv.d.ts → scanner-CTBraprQ.d.ts} +1 -1
- package/dist/scanner.d.cts +2 -2
- package/dist/scanner.d.ts +2 -2
- package/dist/{types-CVcIoqzs.d.cts → types-xAXT9cir.d.cts} +5 -0
- package/dist/{types-CVcIoqzs.d.ts → types-xAXT9cir.d.ts} +5 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -739,6 +739,8 @@ var init_browser = __esm({
|
|
|
739
739
|
"--disable-setuid-sandbox",
|
|
740
740
|
"--disable-dev-shm-usage",
|
|
741
741
|
"--disable-gpu",
|
|
742
|
+
"--ignore-certificate-errors",
|
|
743
|
+
"--ignore-certificate-errors-spki-list",
|
|
742
744
|
`--window-size=${this.options.width},${this.options.height}`,
|
|
743
745
|
...this.options.args
|
|
744
746
|
];
|
|
@@ -795,25 +797,37 @@ var init_browser = __esm({
|
|
|
795
797
|
});
|
|
796
798
|
}
|
|
797
799
|
/**
|
|
798
|
-
* Navigate to a URL
|
|
800
|
+
* Navigate to a URL with retry support
|
|
799
801
|
* @param url - URL to navigate to
|
|
802
|
+
* @param retries - Number of retries (default: 3)
|
|
803
|
+
* @param retryDelay - Delay between retries in ms (default: 2000)
|
|
800
804
|
*/
|
|
801
|
-
async navigate(url) {
|
|
805
|
+
async navigate(url, retries = 3, retryDelay = 2e3) {
|
|
802
806
|
if (!this.page) {
|
|
803
807
|
throw new Error("Browser not launched");
|
|
804
808
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
809
|
+
let lastError = null;
|
|
810
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
811
|
+
try {
|
|
812
|
+
await this.page.goto(url, {
|
|
813
|
+
waitUntil: "networkidle2",
|
|
814
|
+
timeout: this.options.timeout
|
|
815
|
+
});
|
|
816
|
+
this.emit("navigated", { url });
|
|
817
|
+
logger3.info(`Navigated to ${url}`);
|
|
818
|
+
return;
|
|
819
|
+
} catch (error) {
|
|
820
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
821
|
+
this.emit("error", lastError);
|
|
822
|
+
if (lastError.message.includes("ERR_CONNECTION_REFUSED") && attempt < retries) {
|
|
823
|
+
logger3.warn(`Connection refused, retrying in ${retryDelay}ms... (${attempt}/${retries})`);
|
|
824
|
+
await new Promise((resolve2) => setTimeout(resolve2, retryDelay));
|
|
825
|
+
continue;
|
|
826
|
+
}
|
|
827
|
+
throw lastError;
|
|
828
|
+
}
|
|
816
829
|
}
|
|
830
|
+
throw lastError ?? new Error("Navigation failed");
|
|
817
831
|
}
|
|
818
832
|
/**
|
|
819
833
|
* Execute script in page context
|
|
@@ -4554,348 +4568,103 @@ init_browser();
|
|
|
4554
4568
|
|
|
4555
4569
|
// src/browser/scanner.ts
|
|
4556
4570
|
init_event_emitter();
|
|
4571
|
+
|
|
4572
|
+
// src/browser/overlay.ts
|
|
4557
4573
|
var DEFAULT_CONFIG2 = {
|
|
4558
|
-
|
|
4559
|
-
fpsThreshold: 30,
|
|
4574
|
+
enabled: true,
|
|
4560
4575
|
highlightRenders: true,
|
|
4561
|
-
animationSpeed: "fast"
|
|
4576
|
+
animationSpeed: "fast",
|
|
4577
|
+
showBadges: true,
|
|
4578
|
+
showToolbar: true
|
|
4562
4579
|
};
|
|
4563
|
-
var
|
|
4564
|
-
|
|
4580
|
+
var SEVERITY_COLORS = {
|
|
4581
|
+
critical: "#ef4444",
|
|
4582
|
+
warning: "#eab308",
|
|
4583
|
+
info: "#3b82f6",
|
|
4584
|
+
healthy: "#22c55e",
|
|
4585
|
+
unnecessary: "#6b7280"
|
|
4586
|
+
};
|
|
4587
|
+
var ANIMATION_DURATIONS = {
|
|
4588
|
+
slow: 1e3,
|
|
4589
|
+
fast: 300,
|
|
4590
|
+
off: 0
|
|
4591
|
+
};
|
|
4592
|
+
var FLASH_COLORS = {
|
|
4593
|
+
critical: "rgba(239, 68, 68, 0.35)",
|
|
4594
|
+
warning: "rgba(234, 179, 8, 0.3)",
|
|
4595
|
+
info: "rgba(59, 130, 246, 0.25)",
|
|
4596
|
+
healthy: "rgba(34, 197, 94, 0.2)",
|
|
4597
|
+
unnecessary: "rgba(107, 114, 128, 0.15)"
|
|
4598
|
+
};
|
|
4599
|
+
var Overlay = class {
|
|
4600
|
+
/** Shadow root for isolation */
|
|
4601
|
+
shadowRoot = null;
|
|
4602
|
+
/** Host element */
|
|
4603
|
+
host = null;
|
|
4604
|
+
/** Overlay configuration */
|
|
4565
4605
|
config;
|
|
4566
|
-
/**
|
|
4567
|
-
|
|
4568
|
-
/**
|
|
4569
|
-
|
|
4570
|
-
/**
|
|
4571
|
-
prevFiberStates = /* @__PURE__ */ new WeakMap();
|
|
4572
|
-
/** Component render counts */
|
|
4606
|
+
/** Highlight elements */
|
|
4607
|
+
highlights = /* @__PURE__ */ new Map();
|
|
4608
|
+
/** Badge elements */
|
|
4609
|
+
badges = /* @__PURE__ */ new Map();
|
|
4610
|
+
/** Render counts for badges */
|
|
4573
4611
|
renderCounts = /* @__PURE__ */ new Map();
|
|
4574
|
-
/**
|
|
4575
|
-
|
|
4576
|
-
/**
|
|
4577
|
-
|
|
4612
|
+
/** Toolbar element */
|
|
4613
|
+
toolbar = null;
|
|
4614
|
+
/** Whether overlay is visible */
|
|
4615
|
+
visible = true;
|
|
4578
4616
|
/**
|
|
4579
|
-
* Create a new
|
|
4580
|
-
* @param config -
|
|
4581
|
-
* @param win - Window object (for testing)
|
|
4617
|
+
* Create a new overlay
|
|
4618
|
+
* @param config - Overlay configuration
|
|
4582
4619
|
*/
|
|
4583
|
-
constructor(config = {}
|
|
4584
|
-
super();
|
|
4620
|
+
constructor(config = {}) {
|
|
4585
4621
|
this.config = { ...DEFAULT_CONFIG2, ...config };
|
|
4586
|
-
this.win = win ?? (typeof window !== "undefined" ? window : {});
|
|
4587
4622
|
}
|
|
4588
4623
|
/**
|
|
4589
|
-
*
|
|
4624
|
+
* Initialize the overlay
|
|
4590
4625
|
*/
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4626
|
+
init() {
|
|
4627
|
+
this.host = document.createElement("div");
|
|
4628
|
+
this.host.id = "reactcheck-overlay-host";
|
|
4629
|
+
this.host.style.cssText = `
|
|
4630
|
+
position: fixed;
|
|
4631
|
+
top: 0;
|
|
4632
|
+
left: 0;
|
|
4633
|
+
width: 100%;
|
|
4634
|
+
height: 100%;
|
|
4635
|
+
pointer-events: none;
|
|
4636
|
+
z-index: 2147483647;
|
|
4637
|
+
`;
|
|
4638
|
+
this.shadowRoot = this.host.attachShadow({ mode: "closed" });
|
|
4639
|
+
this.injectStyles();
|
|
4640
|
+
if (this.config.showToolbar) {
|
|
4641
|
+
this.createToolbar();
|
|
4598
4642
|
}
|
|
4643
|
+
document.body.appendChild(this.host);
|
|
4599
4644
|
}
|
|
4600
4645
|
/**
|
|
4601
|
-
*
|
|
4602
|
-
*/
|
|
4603
|
-
stop() {
|
|
4604
|
-
if (!this.running) return;
|
|
4605
|
-
this.unhookFromReact();
|
|
4606
|
-
this.running = false;
|
|
4607
|
-
}
|
|
4608
|
-
/**
|
|
4609
|
-
* Reset the scanner state
|
|
4646
|
+
* Destroy the overlay
|
|
4610
4647
|
*/
|
|
4611
|
-
|
|
4648
|
+
destroy() {
|
|
4649
|
+
this.highlights.clear();
|
|
4650
|
+
this.badges.clear();
|
|
4612
4651
|
this.renderCounts.clear();
|
|
4613
|
-
this.
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
* Hook into React DevTools global hook
|
|
4617
|
-
*/
|
|
4618
|
-
hookIntoReact() {
|
|
4619
|
-
const hook = this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
4620
|
-
if (!hook) {
|
|
4621
|
-
this.installHook();
|
|
4622
|
-
return;
|
|
4652
|
+
if (this.host) {
|
|
4653
|
+
this.host.remove();
|
|
4654
|
+
this.host = null;
|
|
4623
4655
|
}
|
|
4624
|
-
this.
|
|
4625
|
-
|
|
4626
|
-
if (this.originalOnCommitFiberRoot) {
|
|
4627
|
-
this.originalOnCommitFiberRoot(rendererID, root, priorityLevel);
|
|
4628
|
-
}
|
|
4629
|
-
this.processCommit(root.current);
|
|
4630
|
-
};
|
|
4631
|
-
this.reactVersion = this.detectReactVersion(hook);
|
|
4632
|
-
this.emit("ready", { reactVersion: this.reactVersion });
|
|
4656
|
+
this.shadowRoot = null;
|
|
4657
|
+
this.toolbar = null;
|
|
4633
4658
|
}
|
|
4634
4659
|
/**
|
|
4635
|
-
*
|
|
4660
|
+
* Inject CSS styles into shadow DOM
|
|
4636
4661
|
*/
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
hook.renderers.set(id, renderer);
|
|
4644
|
-
return id;
|
|
4645
|
-
},
|
|
4646
|
-
onCommitFiberRoot: (_rendererID, root, _priorityLevel) => {
|
|
4647
|
-
this.processCommit(root.current);
|
|
4648
|
-
},
|
|
4649
|
-
onCommitFiberUnmount: () => {
|
|
4650
|
-
}
|
|
4651
|
-
};
|
|
4652
|
-
this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
4653
|
-
this.emit("ready", { reactVersion: "unknown (hook installed)" });
|
|
4654
|
-
}
|
|
4655
|
-
/**
|
|
4656
|
-
* Unhook from React
|
|
4657
|
-
*/
|
|
4658
|
-
unhookFromReact() {
|
|
4659
|
-
const hook = this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
4660
|
-
if (hook && this.originalOnCommitFiberRoot) {
|
|
4661
|
-
hook.onCommitFiberRoot = this.originalOnCommitFiberRoot;
|
|
4662
|
-
this.originalOnCommitFiberRoot = null;
|
|
4663
|
-
}
|
|
4664
|
-
}
|
|
4665
|
-
/**
|
|
4666
|
-
* Detect React version from hook
|
|
4667
|
-
* @param hook - DevTools hook
|
|
4668
|
-
* @returns React version string
|
|
4669
|
-
*/
|
|
4670
|
-
detectReactVersion(hook) {
|
|
4671
|
-
if (hook.renderers.size === 0) {
|
|
4672
|
-
return "unknown";
|
|
4673
|
-
}
|
|
4674
|
-
const renderer = hook.renderers.values().next().value;
|
|
4675
|
-
if (renderer && typeof renderer === "object" && "version" in renderer) {
|
|
4676
|
-
return String(renderer.version);
|
|
4677
|
-
}
|
|
4678
|
-
return "unknown";
|
|
4679
|
-
}
|
|
4680
|
-
/**
|
|
4681
|
-
* Process a fiber commit
|
|
4682
|
-
* @param rootFiber - Root fiber of the committed tree
|
|
4683
|
-
*/
|
|
4684
|
-
processCommit(rootFiber) {
|
|
4685
|
-
this.walkFiber(rootFiber, null);
|
|
4686
|
-
}
|
|
4687
|
-
/**
|
|
4688
|
-
* Walk the fiber tree
|
|
4689
|
-
* @param fiber - Current fiber
|
|
4690
|
-
* @param parent - Parent component name
|
|
4691
|
-
*/
|
|
4692
|
-
walkFiber(fiber, parent) {
|
|
4693
|
-
if (!fiber) return;
|
|
4694
|
-
if (isUserComponent(fiber)) {
|
|
4695
|
-
this.processFiber(fiber, parent);
|
|
4696
|
-
parent = getComponentName(fiber);
|
|
4697
|
-
}
|
|
4698
|
-
this.walkFiber(fiber.child, parent);
|
|
4699
|
-
this.walkFiber(fiber.sibling, parent);
|
|
4700
|
-
}
|
|
4701
|
-
/**
|
|
4702
|
-
* Process a single fiber
|
|
4703
|
-
* @param fiber - Fiber to process
|
|
4704
|
-
* @param parent - Parent component name
|
|
4705
|
-
*/
|
|
4706
|
-
processFiber(fiber, _parent) {
|
|
4707
|
-
const componentName = getComponentName(fiber);
|
|
4708
|
-
if (this.shouldFilterComponent(componentName)) {
|
|
4709
|
-
return;
|
|
4710
|
-
}
|
|
4711
|
-
const prevState = this.prevFiberStates.get(fiber);
|
|
4712
|
-
const phase = prevState ? "update" : "mount";
|
|
4713
|
-
const renderInfo = createRenderInfo(
|
|
4714
|
-
fiber,
|
|
4715
|
-
phase,
|
|
4716
|
-
prevState?.props,
|
|
4717
|
-
prevState?.state
|
|
4718
|
-
);
|
|
4719
|
-
const currentCount = this.renderCounts.get(componentName) ?? 0;
|
|
4720
|
-
const newCount = currentCount + 1;
|
|
4721
|
-
this.renderCounts.set(componentName, newCount);
|
|
4722
|
-
renderInfo.renderCount = newCount;
|
|
4723
|
-
this.prevFiberStates.set(fiber, {
|
|
4724
|
-
props: fiber.memoizedProps,
|
|
4725
|
-
state: fiber.memoizedState
|
|
4726
|
-
});
|
|
4727
|
-
this.emit("render", renderInfo);
|
|
4728
|
-
}
|
|
4729
|
-
/**
|
|
4730
|
-
* Check if component should be filtered out
|
|
4731
|
-
* @param name - Component name
|
|
4732
|
-
* @returns true if should be filtered
|
|
4733
|
-
*/
|
|
4734
|
-
shouldFilterComponent(name) {
|
|
4735
|
-
if (name.startsWith("__")) return true;
|
|
4736
|
-
if (name === "Fragment") return true;
|
|
4737
|
-
if (name === "Suspense") return true;
|
|
4738
|
-
if (name === "Profiler") return true;
|
|
4739
|
-
const { include, exclude } = this.config;
|
|
4740
|
-
if (include && include.length > 0) {
|
|
4741
|
-
const included = include.some((pattern) => this.matchPattern(name, pattern));
|
|
4742
|
-
if (!included) return true;
|
|
4743
|
-
}
|
|
4744
|
-
if (exclude && exclude.length > 0) {
|
|
4745
|
-
const excluded = exclude.some((pattern) => this.matchPattern(name, pattern));
|
|
4746
|
-
if (excluded) return true;
|
|
4747
|
-
}
|
|
4748
|
-
return false;
|
|
4749
|
-
}
|
|
4750
|
-
/**
|
|
4751
|
-
* Simple glob pattern matching
|
|
4752
|
-
* @param name - Component name
|
|
4753
|
-
* @param pattern - Glob pattern
|
|
4754
|
-
* @returns true if matches
|
|
4755
|
-
*/
|
|
4756
|
-
matchPattern(name, pattern) {
|
|
4757
|
-
const regexPattern = pattern.replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
4758
|
-
try {
|
|
4759
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
4760
|
-
return regex.test(name);
|
|
4761
|
-
} catch {
|
|
4762
|
-
return false;
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
/**
|
|
4766
|
-
* Get current configuration
|
|
4767
|
-
* @returns Scanner configuration
|
|
4768
|
-
*/
|
|
4769
|
-
getConfig() {
|
|
4770
|
-
return { ...this.config };
|
|
4771
|
-
}
|
|
4772
|
-
/**
|
|
4773
|
-
* Update configuration
|
|
4774
|
-
* @param config - Partial configuration
|
|
4775
|
-
*/
|
|
4776
|
-
configure(config) {
|
|
4777
|
-
this.config = { ...this.config, ...config };
|
|
4778
|
-
}
|
|
4779
|
-
/**
|
|
4780
|
-
* Check if scanner is running
|
|
4781
|
-
* @returns true if running
|
|
4782
|
-
*/
|
|
4783
|
-
isRunning() {
|
|
4784
|
-
return this.running;
|
|
4785
|
-
}
|
|
4786
|
-
/**
|
|
4787
|
-
* Get detected React version
|
|
4788
|
-
* @returns React version string
|
|
4789
|
-
*/
|
|
4790
|
-
getReactVersion() {
|
|
4791
|
-
return this.reactVersion;
|
|
4792
|
-
}
|
|
4793
|
-
/**
|
|
4794
|
-
* Get render count for a component
|
|
4795
|
-
* @param name - Component name
|
|
4796
|
-
* @returns Render count
|
|
4797
|
-
*/
|
|
4798
|
-
getRenderCount(name) {
|
|
4799
|
-
return this.renderCounts.get(name) ?? 0;
|
|
4800
|
-
}
|
|
4801
|
-
/**
|
|
4802
|
-
* Get all render counts
|
|
4803
|
-
* @returns Map of component names to render counts
|
|
4804
|
-
*/
|
|
4805
|
-
getAllRenderCounts() {
|
|
4806
|
-
return new Map(this.renderCounts);
|
|
4807
|
-
}
|
|
4808
|
-
};
|
|
4809
|
-
|
|
4810
|
-
// src/browser/overlay.ts
|
|
4811
|
-
var DEFAULT_CONFIG3 = {
|
|
4812
|
-
enabled: true,
|
|
4813
|
-
highlightRenders: true,
|
|
4814
|
-
animationSpeed: "fast",
|
|
4815
|
-
showBadges: true,
|
|
4816
|
-
showToolbar: true
|
|
4817
|
-
};
|
|
4818
|
-
var SEVERITY_COLORS = {
|
|
4819
|
-
critical: "#ef4444",
|
|
4820
|
-
warning: "#eab308",
|
|
4821
|
-
info: "#3b82f6",
|
|
4822
|
-
healthy: "#22c55e",
|
|
4823
|
-
unnecessary: "#6b7280"
|
|
4824
|
-
};
|
|
4825
|
-
var ANIMATION_DURATIONS = {
|
|
4826
|
-
slow: 1e3,
|
|
4827
|
-
fast: 300,
|
|
4828
|
-
off: 0
|
|
4829
|
-
};
|
|
4830
|
-
var Overlay = class {
|
|
4831
|
-
/** Shadow root for isolation */
|
|
4832
|
-
shadowRoot = null;
|
|
4833
|
-
/** Host element */
|
|
4834
|
-
host = null;
|
|
4835
|
-
/** Overlay configuration */
|
|
4836
|
-
config;
|
|
4837
|
-
/** Highlight elements */
|
|
4838
|
-
highlights = /* @__PURE__ */ new Map();
|
|
4839
|
-
/** Badge elements */
|
|
4840
|
-
badges = /* @__PURE__ */ new Map();
|
|
4841
|
-
/** Render counts for badges */
|
|
4842
|
-
renderCounts = /* @__PURE__ */ new Map();
|
|
4843
|
-
/** Toolbar element */
|
|
4844
|
-
toolbar = null;
|
|
4845
|
-
/** Whether overlay is visible */
|
|
4846
|
-
visible = true;
|
|
4847
|
-
/**
|
|
4848
|
-
* Create a new overlay
|
|
4849
|
-
* @param config - Overlay configuration
|
|
4850
|
-
*/
|
|
4851
|
-
constructor(config = {}) {
|
|
4852
|
-
this.config = { ...DEFAULT_CONFIG3, ...config };
|
|
4853
|
-
}
|
|
4854
|
-
/**
|
|
4855
|
-
* Initialize the overlay
|
|
4856
|
-
*/
|
|
4857
|
-
init() {
|
|
4858
|
-
this.host = document.createElement("div");
|
|
4859
|
-
this.host.id = "reactcheck-overlay-host";
|
|
4860
|
-
this.host.style.cssText = `
|
|
4861
|
-
position: fixed;
|
|
4862
|
-
top: 0;
|
|
4863
|
-
left: 0;
|
|
4864
|
-
width: 100%;
|
|
4865
|
-
height: 100%;
|
|
4866
|
-
pointer-events: none;
|
|
4867
|
-
z-index: 2147483647;
|
|
4868
|
-
`;
|
|
4869
|
-
this.shadowRoot = this.host.attachShadow({ mode: "closed" });
|
|
4870
|
-
this.injectStyles();
|
|
4871
|
-
if (this.config.showToolbar) {
|
|
4872
|
-
this.createToolbar();
|
|
4873
|
-
}
|
|
4874
|
-
document.body.appendChild(this.host);
|
|
4875
|
-
}
|
|
4876
|
-
/**
|
|
4877
|
-
* Destroy the overlay
|
|
4878
|
-
*/
|
|
4879
|
-
destroy() {
|
|
4880
|
-
this.highlights.clear();
|
|
4881
|
-
this.badges.clear();
|
|
4882
|
-
this.renderCounts.clear();
|
|
4883
|
-
if (this.host) {
|
|
4884
|
-
this.host.remove();
|
|
4885
|
-
this.host = null;
|
|
4886
|
-
}
|
|
4887
|
-
this.shadowRoot = null;
|
|
4888
|
-
this.toolbar = null;
|
|
4889
|
-
}
|
|
4890
|
-
/**
|
|
4891
|
-
* Inject CSS styles into shadow DOM
|
|
4892
|
-
*/
|
|
4893
|
-
injectStyles() {
|
|
4894
|
-
if (!this.shadowRoot) return;
|
|
4895
|
-
const style = document.createElement("style");
|
|
4896
|
-
style.textContent = `
|
|
4897
|
-
* {
|
|
4898
|
-
box-sizing: border-box;
|
|
4662
|
+
injectStyles() {
|
|
4663
|
+
if (!this.shadowRoot) return;
|
|
4664
|
+
const style = document.createElement("style");
|
|
4665
|
+
style.textContent = `
|
|
4666
|
+
* {
|
|
4667
|
+
box-sizing: border-box;
|
|
4899
4668
|
}
|
|
4900
4669
|
|
|
4901
4670
|
.highlight {
|
|
@@ -4903,12 +4672,65 @@ var Overlay = class {
|
|
|
4903
4672
|
pointer-events: none;
|
|
4904
4673
|
border-width: 2px;
|
|
4905
4674
|
border-style: solid;
|
|
4906
|
-
transition: opacity 0.3s ease-out;
|
|
4907
4675
|
z-index: 1;
|
|
4676
|
+
animation: highlight-pulse 0.5s ease-out;
|
|
4908
4677
|
}
|
|
4909
4678
|
|
|
4910
4679
|
.highlight.fade {
|
|
4911
4680
|
opacity: 0;
|
|
4681
|
+
transition: opacity 0.3s ease-out;
|
|
4682
|
+
}
|
|
4683
|
+
|
|
4684
|
+
.flash-overlay {
|
|
4685
|
+
position: fixed;
|
|
4686
|
+
pointer-events: none;
|
|
4687
|
+
z-index: 0;
|
|
4688
|
+
animation: flash-pulse 0.4s ease-out forwards;
|
|
4689
|
+
border-radius: 4px;
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
@keyframes flash-pulse {
|
|
4693
|
+
0% {
|
|
4694
|
+
opacity: 1;
|
|
4695
|
+
transform: scale(1);
|
|
4696
|
+
}
|
|
4697
|
+
50% {
|
|
4698
|
+
opacity: 0.8;
|
|
4699
|
+
transform: scale(1.02);
|
|
4700
|
+
}
|
|
4701
|
+
100% {
|
|
4702
|
+
opacity: 0;
|
|
4703
|
+
transform: scale(1);
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4707
|
+
@keyframes highlight-pulse {
|
|
4708
|
+
0% {
|
|
4709
|
+
opacity: 0;
|
|
4710
|
+
box-shadow: 0 0 0 0 currentColor;
|
|
4711
|
+
}
|
|
4712
|
+
30% {
|
|
4713
|
+
opacity: 1;
|
|
4714
|
+
box-shadow: 0 0 8px 2px currentColor;
|
|
4715
|
+
}
|
|
4716
|
+
100% {
|
|
4717
|
+
opacity: 1;
|
|
4718
|
+
box-shadow: 0 0 0 0 transparent;
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4721
|
+
|
|
4722
|
+
@keyframes badge-pop {
|
|
4723
|
+
0% {
|
|
4724
|
+
transform: scale(0.8);
|
|
4725
|
+
opacity: 0;
|
|
4726
|
+
}
|
|
4727
|
+
50% {
|
|
4728
|
+
transform: scale(1.1);
|
|
4729
|
+
}
|
|
4730
|
+
100% {
|
|
4731
|
+
transform: scale(1);
|
|
4732
|
+
opacity: 1;
|
|
4733
|
+
}
|
|
4912
4734
|
}
|
|
4913
4735
|
|
|
4914
4736
|
.badge {
|
|
@@ -5126,7 +4948,7 @@ var Overlay = class {
|
|
|
5126
4948
|
});
|
|
5127
4949
|
}
|
|
5128
4950
|
/**
|
|
5129
|
-
* Highlight a component render
|
|
4951
|
+
* Highlight a component render with flash effect
|
|
5130
4952
|
* @param render - Render information
|
|
5131
4953
|
* @param element - DOM element to highlight
|
|
5132
4954
|
*/
|
|
@@ -5135,7 +4957,9 @@ var Overlay = class {
|
|
|
5135
4957
|
const rect = element.getBoundingClientRect();
|
|
5136
4958
|
if (rect.width === 0 || rect.height === 0) return;
|
|
5137
4959
|
const severity = this.getSeverity(render);
|
|
5138
|
-
const
|
|
4960
|
+
const borderColor = SEVERITY_COLORS[severity];
|
|
4961
|
+
const flashColor = FLASH_COLORS[severity];
|
|
4962
|
+
this.createFlashOverlay(rect, flashColor);
|
|
5139
4963
|
let highlight = this.highlights.get(render.componentName);
|
|
5140
4964
|
if (!highlight) {
|
|
5141
4965
|
highlight = document.createElement("div");
|
|
@@ -5143,15 +4967,20 @@ var Overlay = class {
|
|
|
5143
4967
|
this.shadowRoot.appendChild(highlight);
|
|
5144
4968
|
this.highlights.set(render.componentName, highlight);
|
|
5145
4969
|
}
|
|
4970
|
+
highlight.style.animation = "none";
|
|
4971
|
+
highlight.offsetHeight;
|
|
4972
|
+
highlight.style.animation = "";
|
|
5146
4973
|
highlight.style.cssText = `
|
|
5147
4974
|
position: fixed;
|
|
5148
4975
|
left: ${rect.left}px;
|
|
5149
4976
|
top: ${rect.top}px;
|
|
5150
4977
|
width: ${rect.width}px;
|
|
5151
4978
|
height: ${rect.height}px;
|
|
5152
|
-
border: 2px solid ${
|
|
4979
|
+
border: 2px solid ${borderColor};
|
|
4980
|
+
color: ${borderColor};
|
|
5153
4981
|
pointer-events: none;
|
|
5154
4982
|
z-index: 1;
|
|
4983
|
+
animation: highlight-pulse 0.5s ease-out;
|
|
5155
4984
|
`;
|
|
5156
4985
|
highlight.classList.remove("fade");
|
|
5157
4986
|
const duration = ANIMATION_DURATIONS[this.config.animationSpeed];
|
|
@@ -5161,10 +4990,31 @@ var Overlay = class {
|
|
|
5161
4990
|
}, duration);
|
|
5162
4991
|
}
|
|
5163
4992
|
if (this.config.showBadges) {
|
|
5164
|
-
this.updateBadge(render, rect,
|
|
4993
|
+
this.updateBadge(render, rect, borderColor);
|
|
5165
4994
|
}
|
|
5166
4995
|
this.updateStats();
|
|
5167
4996
|
}
|
|
4997
|
+
/**
|
|
4998
|
+
* Create a flash overlay effect on the element
|
|
4999
|
+
* @param rect - Element bounding rectangle
|
|
5000
|
+
* @param color - Flash color
|
|
5001
|
+
*/
|
|
5002
|
+
createFlashOverlay(rect, color) {
|
|
5003
|
+
if (!this.shadowRoot) return;
|
|
5004
|
+
const flash = document.createElement("div");
|
|
5005
|
+
flash.className = "flash-overlay";
|
|
5006
|
+
flash.style.cssText = `
|
|
5007
|
+
left: ${rect.left}px;
|
|
5008
|
+
top: ${rect.top}px;
|
|
5009
|
+
width: ${rect.width}px;
|
|
5010
|
+
height: ${rect.height}px;
|
|
5011
|
+
background: ${color};
|
|
5012
|
+
`;
|
|
5013
|
+
this.shadowRoot.appendChild(flash);
|
|
5014
|
+
setTimeout(() => {
|
|
5015
|
+
flash.remove();
|
|
5016
|
+
}, 500);
|
|
5017
|
+
}
|
|
5168
5018
|
/**
|
|
5169
5019
|
* Update or create a badge for a component
|
|
5170
5020
|
* @param render - Render information
|
|
@@ -5182,6 +5032,7 @@ var Overlay = class {
|
|
|
5182
5032
|
this.shadowRoot.appendChild(badge);
|
|
5183
5033
|
this.badges.set(render.componentName, badge);
|
|
5184
5034
|
}
|
|
5035
|
+
const isNewBadge = !this.badges.has(render.componentName);
|
|
5185
5036
|
badge.textContent = `${render.componentName}: ${count}`;
|
|
5186
5037
|
badge.style.cssText = `
|
|
5187
5038
|
position: fixed;
|
|
@@ -5197,7 +5048,14 @@ var Overlay = class {
|
|
|
5197
5048
|
pointer-events: none;
|
|
5198
5049
|
z-index: 2;
|
|
5199
5050
|
white-space: nowrap;
|
|
5051
|
+
${isNewBadge ? "animation: badge-pop 0.3s ease-out;" : ""}
|
|
5200
5052
|
`;
|
|
5053
|
+
if (!isNewBadge) {
|
|
5054
|
+
badge.style.transform = "scale(1.15)";
|
|
5055
|
+
setTimeout(() => {
|
|
5056
|
+
if (badge) badge.style.transform = "scale(1)";
|
|
5057
|
+
}, 150);
|
|
5058
|
+
}
|
|
5201
5059
|
}
|
|
5202
5060
|
/**
|
|
5203
5061
|
* Get severity level for a render
|
|
@@ -5316,6 +5174,331 @@ var Overlay = class {
|
|
|
5316
5174
|
}
|
|
5317
5175
|
};
|
|
5318
5176
|
|
|
5177
|
+
// src/browser/scanner.ts
|
|
5178
|
+
var DEFAULT_CONFIG3 = {
|
|
5179
|
+
trackUnnecessary: true,
|
|
5180
|
+
fpsThreshold: 30,
|
|
5181
|
+
highlightRenders: true,
|
|
5182
|
+
animationSpeed: "fast"
|
|
5183
|
+
};
|
|
5184
|
+
var BrowserScanner = class extends exports.EventEmitter {
|
|
5185
|
+
/** Scanner configuration */
|
|
5186
|
+
config;
|
|
5187
|
+
/** Whether scanner is running */
|
|
5188
|
+
running = false;
|
|
5189
|
+
/** React version detected */
|
|
5190
|
+
reactVersion = "unknown";
|
|
5191
|
+
/** Previous fiber states for comparison */
|
|
5192
|
+
prevFiberStates = /* @__PURE__ */ new WeakMap();
|
|
5193
|
+
/** Component render counts */
|
|
5194
|
+
renderCounts = /* @__PURE__ */ new Map();
|
|
5195
|
+
/** Original DevTools hook methods */
|
|
5196
|
+
originalOnCommitFiberRoot = null;
|
|
5197
|
+
/** Window reference */
|
|
5198
|
+
win;
|
|
5199
|
+
/** Overlay for visual feedback */
|
|
5200
|
+
overlay = null;
|
|
5201
|
+
/**
|
|
5202
|
+
* Create a new browser scanner
|
|
5203
|
+
* @param config - Scanner configuration
|
|
5204
|
+
* @param win - Window object (for testing)
|
|
5205
|
+
*/
|
|
5206
|
+
constructor(config = {}, win) {
|
|
5207
|
+
super();
|
|
5208
|
+
this.config = { ...DEFAULT_CONFIG3, ...config };
|
|
5209
|
+
this.win = win ?? (typeof window !== "undefined" ? window : {});
|
|
5210
|
+
}
|
|
5211
|
+
/**
|
|
5212
|
+
* Get DOM element from fiber node
|
|
5213
|
+
* React stores the DOM node in fiber.stateNode for host components
|
|
5214
|
+
* or we need to walk down to find the first DOM node
|
|
5215
|
+
* @param fiber - Fiber node
|
|
5216
|
+
* @returns DOM Element or null
|
|
5217
|
+
*/
|
|
5218
|
+
getDOMElement(fiber) {
|
|
5219
|
+
if (fiber.stateNode instanceof Element) {
|
|
5220
|
+
return fiber.stateNode;
|
|
5221
|
+
}
|
|
5222
|
+
let current = fiber.child;
|
|
5223
|
+
while (current) {
|
|
5224
|
+
if (current.stateNode instanceof Element) {
|
|
5225
|
+
return current.stateNode;
|
|
5226
|
+
}
|
|
5227
|
+
if (current.child) {
|
|
5228
|
+
current = current.child;
|
|
5229
|
+
} else if (current.sibling) {
|
|
5230
|
+
current = current.sibling;
|
|
5231
|
+
} else {
|
|
5232
|
+
let parent = current.return;
|
|
5233
|
+
while (parent && parent !== fiber && !parent.sibling) {
|
|
5234
|
+
parent = parent.return;
|
|
5235
|
+
}
|
|
5236
|
+
current = parent && parent !== fiber ? parent.sibling : null;
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
return null;
|
|
5240
|
+
}
|
|
5241
|
+
/**
|
|
5242
|
+
* Enable visual overlay for render highlighting
|
|
5243
|
+
*/
|
|
5244
|
+
enableOverlay() {
|
|
5245
|
+
if (this.overlay) return;
|
|
5246
|
+
this.overlay = new Overlay({
|
|
5247
|
+
enabled: true,
|
|
5248
|
+
highlightRenders: this.config.highlightRenders ?? true,
|
|
5249
|
+
animationSpeed: this.config.animationSpeed ?? "fast",
|
|
5250
|
+
showBadges: true,
|
|
5251
|
+
showToolbar: true
|
|
5252
|
+
});
|
|
5253
|
+
this.overlay.init();
|
|
5254
|
+
}
|
|
5255
|
+
/**
|
|
5256
|
+
* Disable visual overlay
|
|
5257
|
+
*/
|
|
5258
|
+
disableOverlay() {
|
|
5259
|
+
if (this.overlay) {
|
|
5260
|
+
this.overlay.destroy();
|
|
5261
|
+
this.overlay = null;
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
/**
|
|
5265
|
+
* Get overlay instance
|
|
5266
|
+
* @returns Overlay instance or null
|
|
5267
|
+
*/
|
|
5268
|
+
getOverlay() {
|
|
5269
|
+
return this.overlay;
|
|
5270
|
+
}
|
|
5271
|
+
/**
|
|
5272
|
+
* Start the scanner
|
|
5273
|
+
*/
|
|
5274
|
+
start() {
|
|
5275
|
+
if (this.running) return;
|
|
5276
|
+
try {
|
|
5277
|
+
this.hookIntoReact();
|
|
5278
|
+
this.running = true;
|
|
5279
|
+
} catch (error) {
|
|
5280
|
+
this.emit("error", error instanceof Error ? error : new Error(String(error)));
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
/**
|
|
5284
|
+
* Stop the scanner
|
|
5285
|
+
*/
|
|
5286
|
+
stop() {
|
|
5287
|
+
if (!this.running) return;
|
|
5288
|
+
this.unhookFromReact();
|
|
5289
|
+
this.disableOverlay();
|
|
5290
|
+
this.running = false;
|
|
5291
|
+
}
|
|
5292
|
+
/**
|
|
5293
|
+
* Reset the scanner state
|
|
5294
|
+
*/
|
|
5295
|
+
reset() {
|
|
5296
|
+
this.renderCounts.clear();
|
|
5297
|
+
this.prevFiberStates = /* @__PURE__ */ new WeakMap();
|
|
5298
|
+
}
|
|
5299
|
+
/**
|
|
5300
|
+
* Hook into React DevTools global hook
|
|
5301
|
+
*/
|
|
5302
|
+
hookIntoReact() {
|
|
5303
|
+
const hook = this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
5304
|
+
if (!hook) {
|
|
5305
|
+
this.installHook();
|
|
5306
|
+
return;
|
|
5307
|
+
}
|
|
5308
|
+
this.originalOnCommitFiberRoot = hook.onCommitFiberRoot.bind(hook);
|
|
5309
|
+
hook.onCommitFiberRoot = (rendererID, root, priorityLevel) => {
|
|
5310
|
+
if (this.originalOnCommitFiberRoot) {
|
|
5311
|
+
this.originalOnCommitFiberRoot(rendererID, root, priorityLevel);
|
|
5312
|
+
}
|
|
5313
|
+
this.processCommit(root.current);
|
|
5314
|
+
};
|
|
5315
|
+
this.reactVersion = this.detectReactVersion(hook);
|
|
5316
|
+
this.emit("ready", { reactVersion: this.reactVersion });
|
|
5317
|
+
}
|
|
5318
|
+
/**
|
|
5319
|
+
* Install our own hook if DevTools hook is not present
|
|
5320
|
+
*/
|
|
5321
|
+
installHook() {
|
|
5322
|
+
const hook = {
|
|
5323
|
+
renderers: /* @__PURE__ */ new Map(),
|
|
5324
|
+
supportsFiber: true,
|
|
5325
|
+
inject: (renderer) => {
|
|
5326
|
+
const id = hook.renderers.size + 1;
|
|
5327
|
+
hook.renderers.set(id, renderer);
|
|
5328
|
+
return id;
|
|
5329
|
+
},
|
|
5330
|
+
onCommitFiberRoot: (_rendererID, root, _priorityLevel) => {
|
|
5331
|
+
this.processCommit(root.current);
|
|
5332
|
+
},
|
|
5333
|
+
onCommitFiberUnmount: () => {
|
|
5334
|
+
}
|
|
5335
|
+
};
|
|
5336
|
+
this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
5337
|
+
this.emit("ready", { reactVersion: "unknown (hook installed)" });
|
|
5338
|
+
}
|
|
5339
|
+
/**
|
|
5340
|
+
* Unhook from React
|
|
5341
|
+
*/
|
|
5342
|
+
unhookFromReact() {
|
|
5343
|
+
const hook = this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
5344
|
+
if (hook && this.originalOnCommitFiberRoot) {
|
|
5345
|
+
hook.onCommitFiberRoot = this.originalOnCommitFiberRoot;
|
|
5346
|
+
this.originalOnCommitFiberRoot = null;
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
/**
|
|
5350
|
+
* Detect React version from hook
|
|
5351
|
+
* @param hook - DevTools hook
|
|
5352
|
+
* @returns React version string
|
|
5353
|
+
*/
|
|
5354
|
+
detectReactVersion(hook) {
|
|
5355
|
+
if (hook.renderers.size === 0) {
|
|
5356
|
+
return "unknown";
|
|
5357
|
+
}
|
|
5358
|
+
const renderer = hook.renderers.values().next().value;
|
|
5359
|
+
if (renderer && typeof renderer === "object" && "version" in renderer) {
|
|
5360
|
+
return String(renderer.version);
|
|
5361
|
+
}
|
|
5362
|
+
return "unknown";
|
|
5363
|
+
}
|
|
5364
|
+
/**
|
|
5365
|
+
* Process a fiber commit
|
|
5366
|
+
* @param rootFiber - Root fiber of the committed tree
|
|
5367
|
+
*/
|
|
5368
|
+
processCommit(rootFiber) {
|
|
5369
|
+
this.walkFiber(rootFiber, null);
|
|
5370
|
+
}
|
|
5371
|
+
/**
|
|
5372
|
+
* Walk the fiber tree
|
|
5373
|
+
* @param fiber - Current fiber
|
|
5374
|
+
* @param parent - Parent component name
|
|
5375
|
+
*/
|
|
5376
|
+
walkFiber(fiber, parent) {
|
|
5377
|
+
if (!fiber) return;
|
|
5378
|
+
if (isUserComponent(fiber)) {
|
|
5379
|
+
this.processFiber(fiber, parent);
|
|
5380
|
+
parent = getComponentName(fiber);
|
|
5381
|
+
}
|
|
5382
|
+
this.walkFiber(fiber.child, parent);
|
|
5383
|
+
this.walkFiber(fiber.sibling, parent);
|
|
5384
|
+
}
|
|
5385
|
+
/**
|
|
5386
|
+
* Process a single fiber
|
|
5387
|
+
* @param fiber - Fiber to process
|
|
5388
|
+
* @param parent - Parent component name
|
|
5389
|
+
*/
|
|
5390
|
+
processFiber(fiber, _parent) {
|
|
5391
|
+
const componentName = getComponentName(fiber);
|
|
5392
|
+
if (this.shouldFilterComponent(componentName)) {
|
|
5393
|
+
return;
|
|
5394
|
+
}
|
|
5395
|
+
const prevState = this.prevFiberStates.get(fiber);
|
|
5396
|
+
const phase = prevState ? "update" : "mount";
|
|
5397
|
+
const renderInfo = createRenderInfo(
|
|
5398
|
+
fiber,
|
|
5399
|
+
phase,
|
|
5400
|
+
prevState?.props,
|
|
5401
|
+
prevState?.state
|
|
5402
|
+
);
|
|
5403
|
+
const currentCount = this.renderCounts.get(componentName) ?? 0;
|
|
5404
|
+
const newCount = currentCount + 1;
|
|
5405
|
+
this.renderCounts.set(componentName, newCount);
|
|
5406
|
+
renderInfo.renderCount = newCount;
|
|
5407
|
+
this.prevFiberStates.set(fiber, {
|
|
5408
|
+
props: fiber.memoizedProps,
|
|
5409
|
+
state: fiber.memoizedState
|
|
5410
|
+
});
|
|
5411
|
+
if (this.overlay && this.config.highlightRenders) {
|
|
5412
|
+
const domElement = this.getDOMElement(fiber);
|
|
5413
|
+
if (domElement) {
|
|
5414
|
+
this.overlay.highlight(renderInfo, domElement);
|
|
5415
|
+
} else {
|
|
5416
|
+
this.overlay.recordRender(renderInfo);
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
this.emit("render", renderInfo);
|
|
5420
|
+
}
|
|
5421
|
+
/**
|
|
5422
|
+
* Check if component should be filtered out
|
|
5423
|
+
* @param name - Component name
|
|
5424
|
+
* @returns true if should be filtered
|
|
5425
|
+
*/
|
|
5426
|
+
shouldFilterComponent(name) {
|
|
5427
|
+
if (name.startsWith("__")) return true;
|
|
5428
|
+
if (name === "Fragment") return true;
|
|
5429
|
+
if (name === "Suspense") return true;
|
|
5430
|
+
if (name === "Profiler") return true;
|
|
5431
|
+
const { include, exclude } = this.config;
|
|
5432
|
+
if (include && include.length > 0) {
|
|
5433
|
+
const included = include.some((pattern) => this.matchPattern(name, pattern));
|
|
5434
|
+
if (!included) return true;
|
|
5435
|
+
}
|
|
5436
|
+
if (exclude && exclude.length > 0) {
|
|
5437
|
+
const excluded = exclude.some((pattern) => this.matchPattern(name, pattern));
|
|
5438
|
+
if (excluded) return true;
|
|
5439
|
+
}
|
|
5440
|
+
return false;
|
|
5441
|
+
}
|
|
5442
|
+
/**
|
|
5443
|
+
* Simple glob pattern matching
|
|
5444
|
+
* @param name - Component name
|
|
5445
|
+
* @param pattern - Glob pattern
|
|
5446
|
+
* @returns true if matches
|
|
5447
|
+
*/
|
|
5448
|
+
matchPattern(name, pattern) {
|
|
5449
|
+
const regexPattern = pattern.replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
5450
|
+
try {
|
|
5451
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
5452
|
+
return regex.test(name);
|
|
5453
|
+
} catch {
|
|
5454
|
+
return false;
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
/**
|
|
5458
|
+
* Get current configuration
|
|
5459
|
+
* @returns Scanner configuration
|
|
5460
|
+
*/
|
|
5461
|
+
getConfig() {
|
|
5462
|
+
return { ...this.config };
|
|
5463
|
+
}
|
|
5464
|
+
/**
|
|
5465
|
+
* Update configuration
|
|
5466
|
+
* @param config - Partial configuration
|
|
5467
|
+
*/
|
|
5468
|
+
configure(config) {
|
|
5469
|
+
this.config = { ...this.config, ...config };
|
|
5470
|
+
}
|
|
5471
|
+
/**
|
|
5472
|
+
* Check if scanner is running
|
|
5473
|
+
* @returns true if running
|
|
5474
|
+
*/
|
|
5475
|
+
isRunning() {
|
|
5476
|
+
return this.running;
|
|
5477
|
+
}
|
|
5478
|
+
/**
|
|
5479
|
+
* Get detected React version
|
|
5480
|
+
* @returns React version string
|
|
5481
|
+
*/
|
|
5482
|
+
getReactVersion() {
|
|
5483
|
+
return this.reactVersion;
|
|
5484
|
+
}
|
|
5485
|
+
/**
|
|
5486
|
+
* Get render count for a component
|
|
5487
|
+
* @param name - Component name
|
|
5488
|
+
* @returns Render count
|
|
5489
|
+
*/
|
|
5490
|
+
getRenderCount(name) {
|
|
5491
|
+
return this.renderCounts.get(name) ?? 0;
|
|
5492
|
+
}
|
|
5493
|
+
/**
|
|
5494
|
+
* Get all render counts
|
|
5495
|
+
* @returns Map of component names to render counts
|
|
5496
|
+
*/
|
|
5497
|
+
getAllRenderCounts() {
|
|
5498
|
+
return new Map(this.renderCounts);
|
|
5499
|
+
}
|
|
5500
|
+
};
|
|
5501
|
+
|
|
5319
5502
|
// src/browser/inject.ts
|
|
5320
5503
|
var ReactCheckInjector = class {
|
|
5321
5504
|
/** Browser scanner instance */
|
|
@@ -5459,8 +5642,42 @@ var ReactCheckInjector = class {
|
|
|
5459
5642
|
case "config":
|
|
5460
5643
|
this.handleConfig(message.payload);
|
|
5461
5644
|
break;
|
|
5645
|
+
case "highlight":
|
|
5646
|
+
break;
|
|
5647
|
+
case "toggle-overlay":
|
|
5648
|
+
this.handleToggleOverlay(message.payload.enabled);
|
|
5649
|
+
break;
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
/**
|
|
5653
|
+
* Toggle overlay visibility
|
|
5654
|
+
* @param enabled - Whether overlay should be visible
|
|
5655
|
+
*/
|
|
5656
|
+
handleToggleOverlay(enabled) {
|
|
5657
|
+
if (enabled) {
|
|
5658
|
+
this.overlay.show();
|
|
5659
|
+
this.overlay.configure({ highlightRenders: true });
|
|
5660
|
+
console.log("[ReactCheck] Overlay enabled");
|
|
5661
|
+
} else {
|
|
5662
|
+
this.overlay.hide();
|
|
5663
|
+
this.overlay.configure({ highlightRenders: false });
|
|
5664
|
+
console.log("[ReactCheck] Overlay disabled");
|
|
5462
5665
|
}
|
|
5463
5666
|
}
|
|
5667
|
+
/**
|
|
5668
|
+
* Get overlay visibility status
|
|
5669
|
+
* @returns Whether overlay is visible
|
|
5670
|
+
*/
|
|
5671
|
+
isOverlayEnabled() {
|
|
5672
|
+
return this.overlay.isVisible();
|
|
5673
|
+
}
|
|
5674
|
+
/**
|
|
5675
|
+
* Toggle overlay (public method for console access)
|
|
5676
|
+
*/
|
|
5677
|
+
toggleOverlay() {
|
|
5678
|
+
const enabled = !this.overlay.isVisible();
|
|
5679
|
+
this.handleToggleOverlay(enabled);
|
|
5680
|
+
}
|
|
5464
5681
|
/**
|
|
5465
5682
|
* Handle config update
|
|
5466
5683
|
* @param config - New configuration
|