@oxog/react-check 1.0.2 → 1.0.3
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/browser-inject.global.js +3 -3
- package/dist/cli.js +735 -53
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5345,7 +5345,12 @@ var ReactCheckInjector = class {
|
|
|
5345
5345
|
this.initialized = true;
|
|
5346
5346
|
this.overlay.init();
|
|
5347
5347
|
this.setupScannerEvents();
|
|
5348
|
+
this.scanner.start();
|
|
5348
5349
|
this.connect();
|
|
5350
|
+
const markHookReady = this._markHookReady;
|
|
5351
|
+
if (markHookReady) {
|
|
5352
|
+
markHookReady();
|
|
5353
|
+
}
|
|
5349
5354
|
console.log("[ReactCheck] Initialized");
|
|
5350
5355
|
}
|
|
5351
5356
|
/**
|
|
@@ -5388,6 +5393,7 @@ var ReactCheckInjector = class {
|
|
|
5388
5393
|
type: "ready",
|
|
5389
5394
|
payload: { reactVersion: this.scanner.getReactVersion() }
|
|
5390
5395
|
});
|
|
5396
|
+
this.flushMessageQueue();
|
|
5391
5397
|
this.scanner.start();
|
|
5392
5398
|
};
|
|
5393
5399
|
this.ws.onmessage = (event) => {
|
|
@@ -5456,6 +5462,8 @@ var ReactCheckInjector = class {
|
|
|
5456
5462
|
this.overlay.configure({ animationSpeed: config.animationSpeed });
|
|
5457
5463
|
}
|
|
5458
5464
|
}
|
|
5465
|
+
/** Message queue for messages sent before connection */
|
|
5466
|
+
messageQueue = [];
|
|
5459
5467
|
/**
|
|
5460
5468
|
* Send message to CLI
|
|
5461
5469
|
* @param message - Browser message
|
|
@@ -5463,6 +5471,19 @@ var ReactCheckInjector = class {
|
|
|
5463
5471
|
send(message) {
|
|
5464
5472
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
5465
5473
|
this.ws.send(JSON.stringify(message));
|
|
5474
|
+
} else {
|
|
5475
|
+
this.messageQueue.push(message);
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
/**
|
|
5479
|
+
* Flush queued messages after connection
|
|
5480
|
+
*/
|
|
5481
|
+
flushMessageQueue() {
|
|
5482
|
+
if (this.ws && this.ws.readyState === WebSocket.OPEN && this.messageQueue.length > 0) {
|
|
5483
|
+
for (const message of this.messageQueue) {
|
|
5484
|
+
this.ws.send(JSON.stringify(message));
|
|
5485
|
+
}
|
|
5486
|
+
this.messageQueue = [];
|
|
5466
5487
|
}
|
|
5467
5488
|
}
|
|
5468
5489
|
/**
|
|
@@ -5498,7 +5519,10 @@ var ReactCheckInjector = class {
|
|
|
5498
5519
|
return;
|
|
5499
5520
|
}
|
|
5500
5521
|
win.__REACTCHECK_INJECTED__ = true;
|
|
5522
|
+
const injector = new ReactCheckInjector();
|
|
5501
5523
|
if (!win.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
|
5524
|
+
const pendingCommits = [];
|
|
5525
|
+
let injectorReady = false;
|
|
5502
5526
|
const hook = {
|
|
5503
5527
|
renderers: /* @__PURE__ */ new Map(),
|
|
5504
5528
|
supportsFiber: true,
|
|
@@ -5507,15 +5531,36 @@ var ReactCheckInjector = class {
|
|
|
5507
5531
|
this.renderers.set(id, renderer);
|
|
5508
5532
|
return id;
|
|
5509
5533
|
},
|
|
5510
|
-
onCommitFiberRoot: function() {
|
|
5534
|
+
onCommitFiberRoot: function(rendererID, root) {
|
|
5535
|
+
if (injectorReady) {
|
|
5536
|
+
const scanner = injector.scanner;
|
|
5537
|
+
if (scanner) {
|
|
5538
|
+
scanner["processCommit"](root.current);
|
|
5539
|
+
}
|
|
5540
|
+
} else {
|
|
5541
|
+
pendingCommits.push({ rendererID, root });
|
|
5542
|
+
}
|
|
5511
5543
|
},
|
|
5512
5544
|
onCommitFiberUnmount: function() {
|
|
5545
|
+
},
|
|
5546
|
+
// Method to process pending commits when injector is ready
|
|
5547
|
+
_processPending: function() {
|
|
5548
|
+
injectorReady = true;
|
|
5549
|
+
const scanner = injector.scanner;
|
|
5550
|
+
if (scanner) {
|
|
5551
|
+
for (const { root } of pendingCommits) {
|
|
5552
|
+
scanner["processCommit"](root.current);
|
|
5553
|
+
}
|
|
5554
|
+
pendingCommits.length = 0;
|
|
5555
|
+
}
|
|
5513
5556
|
}
|
|
5514
5557
|
};
|
|
5515
5558
|
win.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
5516
5559
|
console.log("[ReactCheck] DevTools hook installed");
|
|
5560
|
+
injector._markHookReady = () => {
|
|
5561
|
+
hook._processPending();
|
|
5562
|
+
};
|
|
5517
5563
|
}
|
|
5518
|
-
const injector = new ReactCheckInjector();
|
|
5519
5564
|
if (document.readyState === "loading") {
|
|
5520
5565
|
document.addEventListener("DOMContentLoaded", () => {
|
|
5521
5566
|
injector.init();
|