fixdog 0.0.8 → 0.0.9

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.
@@ -1,4 +1,4 @@
1
- /* fixdog v0.0.8 | MIT License | https://github.com/username/fixdog-sdk */
1
+ /* fixdog v0.0.9 | MIT License | https://github.com/username/fixdog-sdk */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -4721,10 +4721,23 @@
4721
4721
  */
4722
4722
  let singleton = null;
4723
4723
  let devModeWarningShown = false;
4724
+ let pendingOptions = null;
4725
+ /**
4726
+ * Actually initialize the inspector (called when DOM is ready)
4727
+ */
4728
+ function doInit(options) {
4729
+ if (singleton)
4730
+ return singleton;
4731
+ singleton = new Inspector({ ...DEFAULT_OPTIONS, ...options });
4732
+ singleton.activate();
4733
+ console.info("[fixdog] initialized - hold Option/Alt and hover to inspect, Option/Alt+click to select");
4734
+ return singleton;
4735
+ }
4724
4736
  /**
4725
4737
  * Initialize the fixdog inspector
4738
+ * Automatically waits for DOM ready if called before document.body exists
4726
4739
  * @param options - Configuration options
4727
- * @returns Inspector instance or null if not in dev mode
4740
+ * @returns Inspector instance, null if not in dev mode, or undefined if waiting for DOM
4728
4741
  */
4729
4742
  function init(options = {}) {
4730
4743
  // Strict dev mode check - only work in development
@@ -4737,10 +4750,31 @@
4737
4750
  }
4738
4751
  if (singleton)
4739
4752
  return singleton;
4740
- singleton = new Inspector({ ...DEFAULT_OPTIONS, ...options });
4741
- singleton.activate();
4742
- console.info("[fixdog] initialized - hold Option/Alt and hover to inspect, Option/Alt+click to select");
4743
- return singleton;
4753
+ // If document.body doesn't exist yet, wait for DOM ready
4754
+ if (typeof document !== "undefined" && !document.body) {
4755
+ pendingOptions = options;
4756
+ if (document.readyState === "loading") {
4757
+ document.addEventListener("DOMContentLoaded", onDOMReady);
4758
+ }
4759
+ else {
4760
+ // readyState is "interactive" or "complete" but body still null (edge case)
4761
+ // Use a small delay to let the browser finish parsing
4762
+ setTimeout(() => doInit(options), 0);
4763
+ }
4764
+ console.info("[fixdog] waiting for DOM ready...");
4765
+ return undefined;
4766
+ }
4767
+ return doInit(options);
4768
+ }
4769
+ /**
4770
+ * Called when DOM is ready
4771
+ */
4772
+ function onDOMReady() {
4773
+ document.removeEventListener("DOMContentLoaded", onDOMReady);
4774
+ if (pendingOptions !== null) {
4775
+ doInit(pendingOptions);
4776
+ pendingOptions = null;
4777
+ }
4744
4778
  }
4745
4779
  /**
4746
4780
  * Enable debug logging for troubleshooting source resolution
@@ -4768,7 +4802,7 @@
4768
4802
  /**
4769
4803
  * SDK version - replaced at build time
4770
4804
  */
4771
- const version = "0.0.8";
4805
+ const version = "0.0.9";
4772
4806
 
4773
4807
  exports.Inspector = Inspector;
4774
4808
  exports.debug = debug;