@bereasoftware/nexa 1.3.0 → 1.4.0

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/nexa.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Nexa v1.3.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/Nexa */
1
+ /*! Nexa v1.4.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/Nexa */
2
2
  //#region src/types/index.ts
3
3
  var e = (e) => ({
4
4
  ok: !0,
@@ -1893,11 +1893,14 @@ var J = class {
1893
1893
  selectedRequest = null;
1894
1894
  config;
1895
1895
  searchQuery = "";
1896
+ removeTrackerListener = null;
1897
+ keyboardShortcutHandler = null;
1898
+ globalKeyboardHandler = null;
1896
1899
  constructor(e) {
1897
- this.tracker = e, this.config = e.getConfig(), this.setupKeyboardShortcut(), this.createPanel();
1900
+ this.tracker = e, this.config = e.getConfig(), this.canUseDOM() && (this.setupKeyboardShortcut(), this.createPanel());
1898
1901
  }
1899
1902
  show() {
1900
- this.panel && (this.panel.style.display = "flex", this.panel.style.opacity = "0", this.panel.style.transform = "scale(0.96) translateY(8px)", requestAnimationFrame(() => {
1903
+ this.panel && (this.panel.style.display = "flex", this.panel.style.opacity = "0", this.panel.style.transform = "scale(0.96) translateY(8px)", (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (e) => setTimeout(e, 0))(() => {
1901
1904
  this.panel.style.transition = "all 0.25s cubic-bezier(0.16, 1, 0.3, 1)", this.panel.style.opacity = "1", this.panel.style.transform = "scale(1) translateY(0)";
1902
1905
  }), this.visible = !0);
1903
1906
  }
@@ -1910,11 +1913,11 @@ var J = class {
1910
1913
  this.visible ? this.hide() : this.show();
1911
1914
  }
1912
1915
  destroy() {
1913
- this.panel?.remove(), this.panel = null;
1916
+ this.keyboardShortcutHandler &&= (document.removeEventListener("keydown", this.keyboardShortcutHandler), null), this.globalKeyboardHandler &&= (document.removeEventListener("keydown", this.globalKeyboardHandler), null), this.removeTrackerListener?.(), this.removeTrackerListener = null, this.panel?.remove(), this.panel = null, this.visible = !1, this.selectedRequest = null;
1914
1917
  }
1915
1918
  setupKeyboardShortcut() {
1916
1919
  let e = this.config.keyboardShortcut.split("+"), t = new Set(e.map((e) => e.toLowerCase()));
1917
- document.addEventListener("keydown", (e) => {
1920
+ this.keyboardShortcutHandler = (e) => {
1918
1921
  let n = /* @__PURE__ */ new Set();
1919
1922
  e.ctrlKey && n.add("ctrl"), e.metaKey && (n.add("meta"), n.add("cmd"), n.add("ctrl")), e.shiftKey && n.add("shift"), e.altKey && n.add("alt"), (e.key && e.key.length === 1 || e.key.length > 1) && n.add(e.key.toLowerCase());
1920
1923
  let r = !0;
@@ -1923,9 +1926,10 @@ var J = class {
1923
1926
  break;
1924
1927
  }
1925
1928
  r && n.size === t.size && (e.preventDefault(), this.toggle());
1926
- });
1929
+ }, document.addEventListener("keydown", this.keyboardShortcutHandler);
1927
1930
  }
1928
1931
  createPanel() {
1932
+ if (!this.canUseDOM()) return;
1929
1933
  this.panel = document.createElement("div"), this.panel.id = "nexa-dev-overlay";
1930
1934
  let e = this.config.position, t = e.includes("bottom"), n = e.includes("right");
1931
1935
  this.panel.style.cssText = `
@@ -1943,8 +1947,7 @@ var J = class {
1943
1947
  <div class="nexa-header">
1944
1948
  <div class="nexa-header-left">
1945
1949
  <div class="nexa-logo">
1946
- <img src="/src/assets/faviconNew.png" width="18" height="18" style="border-radius:4px;object-fit:contain;display:block;" alt="Nexa" onerror="this.style.display='none';this.nextElementSibling.style.display='flex';" />
1947
- <span style="display:none;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:#fff;background:linear-gradient(135deg,#3b82f6,#238636);width:18px;height:18px;border-radius:4px;">N</span>
1950
+ <span style="display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:#fff;background:linear-gradient(135deg,#3b82f6,#238636);width:18px;height:18px;border-radius:4px;">N</span>
1948
1951
  </div>
1949
1952
  <span class="nexa-title">Nexa DevTools</span>
1950
1953
  </div>
@@ -1984,7 +1987,7 @@ var J = class {
1984
1987
  </div>
1985
1988
  <div class="nexa-detail-body"></div>
1986
1989
  </div>
1987
- `, document.body.appendChild(this.panel), this.bindEvents(), this.tracker.onChange(() => this.render()), this.hide(), document.addEventListener("keydown", (e) => {
1990
+ `, document.body.appendChild(this.panel), this.bindEvents(), this.removeTrackerListener = this.tracker.onChange(() => this.render()), this.hide(), this.globalKeyboardHandler = (e) => {
1988
1991
  if (e.key === "Escape" && this.visible) {
1989
1992
  this.hide();
1990
1993
  return;
@@ -1994,7 +1997,7 @@ var J = class {
1994
1997
  let t = this.panel?.querySelector(".nexa-search-input");
1995
1998
  t?.focus(), t?.select();
1996
1999
  }
1997
- });
2000
+ }, document.addEventListener("keydown", this.globalKeyboardHandler);
1998
2001
  }
1999
2002
  bindEvents() {
2000
2003
  this.panel && (this.panel.querySelector(".nexa-btn-close")?.addEventListener("click", () => this.hide()), this.panel.querySelector(".nexa-btn-clear")?.addEventListener("click", () => {
@@ -2145,6 +2148,9 @@ var J = class {
2145
2148
  return String(e);
2146
2149
  }
2147
2150
  }
2151
+ canUseDOM() {
2152
+ return typeof document < "u" && typeof document.createElement == "function" && !!document.body;
2153
+ }
2148
2154
  }, Q = null, $ = null;
2149
2155
  function be(e = {}) {
2150
2156
  return Q ? {