@oxog/react-check 1.0.1 → 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/index.d.cts CHANGED
@@ -1349,11 +1349,17 @@ declare class ReactCheckInjector {
1349
1349
  * @param config - New configuration
1350
1350
  */
1351
1351
  private handleConfig;
1352
+ /** Message queue for messages sent before connection */
1353
+ private messageQueue;
1352
1354
  /**
1353
1355
  * Send message to CLI
1354
1356
  * @param message - Browser message
1355
1357
  */
1356
1358
  private send;
1359
+ /**
1360
+ * Flush queued messages after connection
1361
+ */
1362
+ private flushMessageQueue;
1357
1363
  /**
1358
1364
  * Find DOM element for a component
1359
1365
  * @param componentName - Component name
package/dist/index.d.ts CHANGED
@@ -1349,11 +1349,17 @@ declare class ReactCheckInjector {
1349
1349
  * @param config - New configuration
1350
1350
  */
1351
1351
  private handleConfig;
1352
+ /** Message queue for messages sent before connection */
1353
+ private messageQueue;
1352
1354
  /**
1353
1355
  * Send message to CLI
1354
1356
  * @param message - Browser message
1355
1357
  */
1356
1358
  private send;
1359
+ /**
1360
+ * Flush queued messages after connection
1361
+ */
1362
+ private flushMessageQueue;
1357
1363
  /**
1358
1364
  * Find DOM element for a component
1359
1365
  * @param componentName - Component name
package/dist/index.js CHANGED
@@ -5343,7 +5343,12 @@ var ReactCheckInjector = class {
5343
5343
  this.initialized = true;
5344
5344
  this.overlay.init();
5345
5345
  this.setupScannerEvents();
5346
+ this.scanner.start();
5346
5347
  this.connect();
5348
+ const markHookReady = this._markHookReady;
5349
+ if (markHookReady) {
5350
+ markHookReady();
5351
+ }
5347
5352
  console.log("[ReactCheck] Initialized");
5348
5353
  }
5349
5354
  /**
@@ -5386,6 +5391,7 @@ var ReactCheckInjector = class {
5386
5391
  type: "ready",
5387
5392
  payload: { reactVersion: this.scanner.getReactVersion() }
5388
5393
  });
5394
+ this.flushMessageQueue();
5389
5395
  this.scanner.start();
5390
5396
  };
5391
5397
  this.ws.onmessage = (event) => {
@@ -5454,6 +5460,8 @@ var ReactCheckInjector = class {
5454
5460
  this.overlay.configure({ animationSpeed: config.animationSpeed });
5455
5461
  }
5456
5462
  }
5463
+ /** Message queue for messages sent before connection */
5464
+ messageQueue = [];
5457
5465
  /**
5458
5466
  * Send message to CLI
5459
5467
  * @param message - Browser message
@@ -5461,6 +5469,19 @@ var ReactCheckInjector = class {
5461
5469
  send(message) {
5462
5470
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
5463
5471
  this.ws.send(JSON.stringify(message));
5472
+ } else {
5473
+ this.messageQueue.push(message);
5474
+ }
5475
+ }
5476
+ /**
5477
+ * Flush queued messages after connection
5478
+ */
5479
+ flushMessageQueue() {
5480
+ if (this.ws && this.ws.readyState === WebSocket.OPEN && this.messageQueue.length > 0) {
5481
+ for (const message of this.messageQueue) {
5482
+ this.ws.send(JSON.stringify(message));
5483
+ }
5484
+ this.messageQueue = [];
5464
5485
  }
5465
5486
  }
5466
5487
  /**
@@ -5497,6 +5518,47 @@ var ReactCheckInjector = class {
5497
5518
  }
5498
5519
  win.__REACTCHECK_INJECTED__ = true;
5499
5520
  const injector = new ReactCheckInjector();
5521
+ if (!win.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
5522
+ const pendingCommits = [];
5523
+ let injectorReady = false;
5524
+ const hook = {
5525
+ renderers: /* @__PURE__ */ new Map(),
5526
+ supportsFiber: true,
5527
+ inject: function(renderer) {
5528
+ const id = this.renderers.size + 1;
5529
+ this.renderers.set(id, renderer);
5530
+ return id;
5531
+ },
5532
+ onCommitFiberRoot: function(rendererID, root) {
5533
+ if (injectorReady) {
5534
+ const scanner = injector.scanner;
5535
+ if (scanner) {
5536
+ scanner["processCommit"](root.current);
5537
+ }
5538
+ } else {
5539
+ pendingCommits.push({ rendererID, root });
5540
+ }
5541
+ },
5542
+ onCommitFiberUnmount: function() {
5543
+ },
5544
+ // Method to process pending commits when injector is ready
5545
+ _processPending: function() {
5546
+ injectorReady = true;
5547
+ const scanner = injector.scanner;
5548
+ if (scanner) {
5549
+ for (const { root } of pendingCommits) {
5550
+ scanner["processCommit"](root.current);
5551
+ }
5552
+ pendingCommits.length = 0;
5553
+ }
5554
+ }
5555
+ };
5556
+ win.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
5557
+ console.log("[ReactCheck] DevTools hook installed");
5558
+ injector._markHookReady = () => {
5559
+ hook._processPending();
5560
+ };
5561
+ }
5500
5562
  if (document.readyState === "loading") {
5501
5563
  document.addEventListener("DOMContentLoaded", () => {
5502
5564
  injector.init();