@oxog/react-check 1.1.3 → 1.1.5
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 +12 -0
- package/dist/browser-inject.global.js +8 -8
- package/dist/cli.js +25 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +39 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +39 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -762,7 +762,6 @@ var init_browser = __esm({
|
|
|
762
762
|
const wsPort = this.options.wsPort;
|
|
763
763
|
await this.page.evaluateOnNewDocument(`
|
|
764
764
|
window.__REACTCHECK_PORT__ = ${wsPort};
|
|
765
|
-
window.__REACTCHECK_INJECTED__ = true;
|
|
766
765
|
`);
|
|
767
766
|
this.emit("launched", void 0);
|
|
768
767
|
logger3.info("Browser launched");
|
|
@@ -5362,7 +5361,7 @@ var BrowserScanner = class extends exports.EventEmitter {
|
|
|
5362
5361
|
return "unknown";
|
|
5363
5362
|
}
|
|
5364
5363
|
/**
|
|
5365
|
-
* Process a fiber commit
|
|
5364
|
+
* Process a fiber commit (public for IIFE hook integration)
|
|
5366
5365
|
* @param rootFiber - Root fiber of the committed tree
|
|
5367
5366
|
*/
|
|
5368
5367
|
processCommit(rootFiber) {
|
|
@@ -5408,15 +5407,15 @@ var BrowserScanner = class extends exports.EventEmitter {
|
|
|
5408
5407
|
props: fiber.memoizedProps,
|
|
5409
5408
|
state: fiber.memoizedState
|
|
5410
5409
|
});
|
|
5410
|
+
const domElement = this.getDOMElement(fiber);
|
|
5411
5411
|
if (this.overlay && this.config.highlightRenders) {
|
|
5412
|
-
const domElement = this.getDOMElement(fiber);
|
|
5413
5412
|
if (domElement) {
|
|
5414
5413
|
this.overlay.highlight(renderInfo, domElement);
|
|
5415
5414
|
} else {
|
|
5416
5415
|
this.overlay.recordRender(renderInfo);
|
|
5417
5416
|
}
|
|
5418
5417
|
}
|
|
5419
|
-
this.emit("render", renderInfo);
|
|
5418
|
+
this.emit("render", { render: renderInfo, element: domElement });
|
|
5420
5419
|
}
|
|
5421
5420
|
/**
|
|
5422
5421
|
* Check if component should be filtered out
|
|
@@ -5539,7 +5538,6 @@ var ReactCheckInjector = class {
|
|
|
5539
5538
|
this.initialized = true;
|
|
5540
5539
|
this.overlay.init();
|
|
5541
5540
|
this.setupScannerEvents();
|
|
5542
|
-
this.scanner.start();
|
|
5543
5541
|
this.connect();
|
|
5544
5542
|
const markHookReady = this._markHookReady;
|
|
5545
5543
|
if (markHookReady) {
|
|
@@ -5551,10 +5549,9 @@ var ReactCheckInjector = class {
|
|
|
5551
5549
|
* Set up scanner event handlers
|
|
5552
5550
|
*/
|
|
5553
5551
|
setupScannerEvents() {
|
|
5554
|
-
this.scanner.on("render", (render) => {
|
|
5552
|
+
this.scanner.on("render", ({ render, element }) => {
|
|
5555
5553
|
this.send({ type: "render", payload: render });
|
|
5556
5554
|
this.overlay.recordRender(render);
|
|
5557
|
-
const element = this.findDOMElement(render.componentName);
|
|
5558
5555
|
if (element) {
|
|
5559
5556
|
this.overlay.highlight(render, element);
|
|
5560
5557
|
}
|
|
@@ -5589,7 +5586,6 @@ var ReactCheckInjector = class {
|
|
|
5589
5586
|
payload: { reactVersion: this.scanner.getReactVersion() }
|
|
5590
5587
|
});
|
|
5591
5588
|
this.flushMessageQueue();
|
|
5592
|
-
this.scanner.start();
|
|
5593
5589
|
};
|
|
5594
5590
|
this.ws.onmessage = (event) => {
|
|
5595
5591
|
try {
|
|
@@ -5715,18 +5711,6 @@ var ReactCheckInjector = class {
|
|
|
5715
5711
|
this.messageQueue = [];
|
|
5716
5712
|
}
|
|
5717
5713
|
}
|
|
5718
|
-
/**
|
|
5719
|
-
* Find DOM element for a component
|
|
5720
|
-
* @param componentName - Component name
|
|
5721
|
-
* @returns DOM element or null
|
|
5722
|
-
*/
|
|
5723
|
-
findDOMElement(componentName) {
|
|
5724
|
-
const byAttr = document.querySelector(`[data-component="${componentName}"]`);
|
|
5725
|
-
if (byAttr) return byAttr;
|
|
5726
|
-
const allElements = document.querySelectorAll('[class*="' + componentName + '"]');
|
|
5727
|
-
if (allElements.length > 0) return allElements[0] ?? null;
|
|
5728
|
-
return null;
|
|
5729
|
-
}
|
|
5730
5714
|
/**
|
|
5731
5715
|
* Destroy the injector
|
|
5732
5716
|
*/
|
|
@@ -5749,9 +5733,30 @@ var ReactCheckInjector = class {
|
|
|
5749
5733
|
}
|
|
5750
5734
|
win.__REACTCHECK_INJECTED__ = true;
|
|
5751
5735
|
const injector = new ReactCheckInjector();
|
|
5736
|
+
const pendingCommits = [];
|
|
5737
|
+
let injectorReady = false;
|
|
5738
|
+
const handleCommit = (root) => {
|
|
5739
|
+
if (injectorReady) {
|
|
5740
|
+
const scanner = injector.scanner;
|
|
5741
|
+
if (scanner) {
|
|
5742
|
+
const fiber = root.current;
|
|
5743
|
+
scanner.processCommit(fiber);
|
|
5744
|
+
}
|
|
5745
|
+
} else {
|
|
5746
|
+
pendingCommits.push({ rendererID: 0, root });
|
|
5747
|
+
}
|
|
5748
|
+
};
|
|
5749
|
+
const processPendingCommits = () => {
|
|
5750
|
+
injectorReady = true;
|
|
5751
|
+
const scanner = injector.scanner;
|
|
5752
|
+
if (scanner) {
|
|
5753
|
+
for (const { root } of pendingCommits) {
|
|
5754
|
+
scanner.processCommit(root.current);
|
|
5755
|
+
}
|
|
5756
|
+
pendingCommits.length = 0;
|
|
5757
|
+
}
|
|
5758
|
+
};
|
|
5752
5759
|
if (!win.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
|
5753
|
-
const pendingCommits = [];
|
|
5754
|
-
let injectorReady = false;
|
|
5755
5760
|
const hook = {
|
|
5756
5761
|
renderers: /* @__PURE__ */ new Map(),
|
|
5757
5762
|
supportsFiber: true,
|
|
@@ -5760,36 +5765,26 @@ var ReactCheckInjector = class {
|
|
|
5760
5765
|
this.renderers.set(id, renderer);
|
|
5761
5766
|
return id;
|
|
5762
5767
|
},
|
|
5763
|
-
onCommitFiberRoot: function(
|
|
5764
|
-
|
|
5765
|
-
const scanner = injector.scanner;
|
|
5766
|
-
if (scanner) {
|
|
5767
|
-
scanner["processCommit"](root.current);
|
|
5768
|
-
}
|
|
5769
|
-
} else {
|
|
5770
|
-
pendingCommits.push({ rendererID, root });
|
|
5771
|
-
}
|
|
5768
|
+
onCommitFiberRoot: function(_rendererID, root) {
|
|
5769
|
+
handleCommit(root);
|
|
5772
5770
|
},
|
|
5773
5771
|
onCommitFiberUnmount: function() {
|
|
5774
|
-
},
|
|
5775
|
-
// Method to process pending commits when injector is ready
|
|
5776
|
-
_processPending: function() {
|
|
5777
|
-
injectorReady = true;
|
|
5778
|
-
const scanner = injector.scanner;
|
|
5779
|
-
if (scanner) {
|
|
5780
|
-
for (const { root } of pendingCommits) {
|
|
5781
|
-
scanner["processCommit"](root.current);
|
|
5782
|
-
}
|
|
5783
|
-
pendingCommits.length = 0;
|
|
5784
|
-
}
|
|
5785
5772
|
}
|
|
5786
5773
|
};
|
|
5787
5774
|
win.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
5788
5775
|
console.log("[ReactCheck] DevTools hook installed");
|
|
5789
|
-
|
|
5790
|
-
|
|
5776
|
+
} else {
|
|
5777
|
+
const existingHook = win.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
5778
|
+
const originalOnCommit = existingHook.onCommitFiberRoot.bind(existingHook);
|
|
5779
|
+
existingHook.onCommitFiberRoot = (rendererID, root, priorityLevel) => {
|
|
5780
|
+
originalOnCommit(rendererID, root, priorityLevel);
|
|
5781
|
+
handleCommit(root);
|
|
5791
5782
|
};
|
|
5783
|
+
console.log("[ReactCheck] Wrapped existing DevTools hook");
|
|
5792
5784
|
}
|
|
5785
|
+
injector._markHookReady = () => {
|
|
5786
|
+
processPendingCommits();
|
|
5787
|
+
};
|
|
5793
5788
|
if (document.readyState === "loading") {
|
|
5794
5789
|
document.addEventListener("DOMContentLoaded", () => {
|
|
5795
5790
|
injector.init();
|