@leeguoo/pwtk-network-debugger 1.3.1 → 1.3.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.esm.js CHANGED
@@ -18256,7 +18256,7 @@ const _DebugPanel = class _DebugPanel {
18256
18256
  this.container.style.pointerEvents = "auto";
18257
18257
  this.container.innerHTML = `
18258
18258
  <div class="debugger-header">
18259
- <div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.1"}</span></div>
18259
+ <div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.3"}</span></div>
18260
18260
  <div class="debugger-controls">
18261
18261
  <button class="debugger-btn" data-action="clear" title="清空"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>
18262
18262
  <button class="debugger-btn" data-action="export" title="导出"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>
@@ -18863,6 +18863,7 @@ Created by Leo (@leeguoo)`);
18863
18863
  this.config.isClosed = false;
18864
18864
  this.saveConfig();
18865
18865
  this.removeReopenButton();
18866
+ this.scheduleLiquidGlassRefresh(true, 50);
18866
18867
  }
18867
18868
  hide() {
18868
18869
  this.hostElement.style.display = "none";
@@ -18871,6 +18872,8 @@ Created by Leo (@leeguoo)`);
18871
18872
  this.createReopenButton().catch((error) => {
18872
18873
  logger.error("[PWTK] Failed to create reopen button:", error);
18873
18874
  this.createFallbackButton();
18875
+ }).finally(() => {
18876
+ this.scheduleLiquidGlassRefresh(true, 50);
18874
18877
  });
18875
18878
  }
18876
18879
  async createReopenButton() {
@@ -18881,6 +18884,10 @@ Created by Leo (@leeguoo)`);
18881
18884
  );
18882
18885
  await Promise.race([liquidGlassPromise, timeout]);
18883
18886
  if (typeof window !== "undefined" && window.Button) {
18887
+ const ContainerClass = window.Container;
18888
+ if (ContainerClass && typeof ContainerClass.invalidateSnapshot === "function") {
18889
+ ContainerClass.invalidateSnapshot({ clearQueue: true });
18890
+ }
18884
18891
  this.createGlassButton();
18885
18892
  } else {
18886
18893
  logger.debug("[PWTK] Button class not available, using fallback");
@@ -18953,6 +18960,7 @@ Created by Leo (@leeguoo)`);
18953
18960
  this.addDragFunctionality(glassButton.element);
18954
18961
  this.reopenButton = glassButton;
18955
18962
  logger.debug("[PWTK] Glass button created successfully");
18963
+ this.scheduleLiquidGlassRefresh(true, 30);
18956
18964
  } catch (error) {
18957
18965
  logger.error("[PWTK] Failed to create glass button:", error);
18958
18966
  this.createFallbackButton();
@@ -18998,31 +19006,32 @@ Created by Leo (@leeguoo)`);
18998
19006
  this.addDragFunctionality(btn);
18999
19007
  document.body.appendChild(btn);
19000
19008
  logger.debug("[PWTK] Fallback button created successfully");
19009
+ this.scheduleLiquidGlassRefresh(true, 30);
19001
19010
  } catch (error) {
19002
19011
  logger.error("[PWTK] Failed to create fallback button:", error);
19003
19012
  }
19004
19013
  }
19005
19014
  addDragFunctionality(element) {
19015
+ if (element.__pwtkDragAttached) {
19016
+ return;
19017
+ }
19018
+ element.__pwtkDragAttached = true;
19006
19019
  let isDragging = false;
19007
19020
  let dragStart = { x: 0, y: 0 };
19008
- let clickTimer = null;
19009
- element.addEventListener("mousedown", (e2) => {
19010
- if (e2.button === 0) {
19011
- isDragging = false;
19012
- dragStart = { x: e2.clientX, y: e2.clientY };
19013
- clickTimer = window.setTimeout(() => {
19014
- isDragging = true;
19015
- element.style.cursor = "grabbing";
19016
- }, 150);
19017
- document.addEventListener("mousemove", handleMouseMove);
19018
- document.addEventListener("mouseup", handleMouseUp);
19019
- e2.preventDefault();
19020
- }
19021
- });
19021
+ let suppressNextClick = false;
19022
+ const originalCursor = element.style.cursor;
19022
19023
  const handleMouseMove = (e2) => {
19023
- if (!isDragging) return;
19024
19024
  const deltaX = e2.clientX - dragStart.x;
19025
19025
  const deltaY = e2.clientY - dragStart.y;
19026
+ if (!isDragging) {
19027
+ const distance2 = Math.hypot(deltaX, deltaY);
19028
+ if (distance2 < 4) {
19029
+ return;
19030
+ }
19031
+ isDragging = true;
19032
+ element.style.cursor = "grabbing";
19033
+ }
19034
+ suppressNextClick = true;
19026
19035
  const rect = element.getBoundingClientRect();
19027
19036
  const newLeft = rect.left + deltaX;
19028
19037
  const newTop = rect.top + deltaY;
@@ -19030,25 +19039,54 @@ Created by Leo (@leeguoo)`);
19030
19039
  const maxY = window.innerHeight - rect.height;
19031
19040
  const clampedX = Math.max(0, Math.min(maxX, newLeft));
19032
19041
  const clampedY = Math.max(0, Math.min(maxY, newTop));
19033
- element.style.position = "fixed";
19034
19042
  element.style.left = `${clampedX}px`;
19035
19043
  element.style.top = `${clampedY}px`;
19036
- element.style.right = "auto";
19037
- element.style.bottom = "auto";
19038
19044
  dragStart = { x: e2.clientX, y: e2.clientY };
19039
19045
  };
19040
19046
  const handleMouseUp = () => {
19041
- if (clickTimer) {
19042
- clearTimeout(clickTimer);
19043
- clickTimer = null;
19044
- }
19045
- if (isDragging) {
19046
- isDragging = false;
19047
- element.style.cursor = "pointer";
19048
- }
19049
19047
  document.removeEventListener("mousemove", handleMouseMove);
19050
19048
  document.removeEventListener("mouseup", handleMouseUp);
19049
+ element.style.cursor = originalCursor;
19050
+ isDragging = false;
19051
+ if (suppressNextClick) {
19052
+ window.setTimeout(() => {
19053
+ suppressNextClick = false;
19054
+ }, 0);
19055
+ }
19051
19056
  };
19057
+ element.addEventListener("mousedown", (e2) => {
19058
+ if (e2.button !== 0) {
19059
+ return;
19060
+ }
19061
+ isDragging = false;
19062
+ suppressNextClick = false;
19063
+ dragStart = { x: e2.clientX, y: e2.clientY };
19064
+ element.style.cursor = "grab";
19065
+ const rectBeforeFix = element.getBoundingClientRect();
19066
+ const computedStyle = window.getComputedStyle(element);
19067
+ if (computedStyle.position !== "fixed") {
19068
+ element.style.position = "fixed";
19069
+ }
19070
+ element.style.left = `${rectBeforeFix.left}px`;
19071
+ element.style.top = `${rectBeforeFix.top}px`;
19072
+ element.style.right = "auto";
19073
+ element.style.bottom = "auto";
19074
+ document.addEventListener("mousemove", handleMouseMove);
19075
+ document.addEventListener("mouseup", handleMouseUp);
19076
+ e2.preventDefault();
19077
+ });
19078
+ element.addEventListener(
19079
+ "click",
19080
+ (e2) => {
19081
+ if (!suppressNextClick) {
19082
+ return;
19083
+ }
19084
+ suppressNextClick = false;
19085
+ e2.stopImmediatePropagation();
19086
+ e2.preventDefault();
19087
+ },
19088
+ true
19089
+ );
19052
19090
  }
19053
19091
  removeReopenButton() {
19054
19092
  try {
@@ -19068,6 +19106,27 @@ Created by Leo (@leeguoo)`);
19068
19106
  logger.error("[PWTK] Error removing reopen button:", error);
19069
19107
  }
19070
19108
  }
19109
+ scheduleLiquidGlassRefresh(force = false, delay = 0) {
19110
+ if (typeof window === "undefined") {
19111
+ return;
19112
+ }
19113
+ const ContainerClass = window.Container;
19114
+ if (!ContainerClass || typeof ContainerClass.refreshAll !== "function") {
19115
+ return;
19116
+ }
19117
+ const triggerRefresh = () => {
19118
+ try {
19119
+ ContainerClass.refreshAll(force);
19120
+ } catch (error) {
19121
+ logger.debug("[PWTK] Liquid glass refresh failed:", error);
19122
+ }
19123
+ };
19124
+ if (delay > 0) {
19125
+ window.setTimeout(() => window.requestAnimationFrame(triggerRefresh), delay);
19126
+ } else {
19127
+ window.requestAnimationFrame(triggerRefresh);
19128
+ }
19129
+ }
19071
19130
  /**
19072
19131
  * 添加可清理的事件监听器
19073
19132
  */
@@ -19349,7 +19408,7 @@ if (typeof window !== "undefined") {
19349
19408
  }
19350
19409
  function loadLiquidGlass() {
19351
19410
  return new Promise((resolve) => {
19352
- import("./container-BiE06oNd.mjs").then(() => {
19411
+ import("./container-Cy51KA7q.mjs").then(() => {
19353
19412
  return import("./button-Dt1KsQb6.mjs");
19354
19413
  }).then(() => {
19355
19414
  resolve();
@@ -19490,7 +19549,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19490
19549
  }
19491
19550
  async checkForUpdates() {
19492
19551
  try {
19493
- const currentVersion = "1.3.1";
19552
+ const currentVersion = "1.3.3";
19494
19553
  logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
19495
19554
  const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
19496
19555
  const data = await response.json();
@@ -19510,7 +19569,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19510
19569
  logger.error("[PWTK Update] Failed to check for updates:", error);
19511
19570
  return {
19512
19571
  hasUpdate: false,
19513
- currentVersion: "1.3.1"
19572
+ currentVersion: "1.3.3"
19514
19573
  };
19515
19574
  }
19516
19575
  }
@@ -19606,7 +19665,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19606
19665
  return headers.slk || headers["x-slk"] || "";
19607
19666
  }
19608
19667
  };
19609
- _NetworkDebugger.version = "1.3.1";
19668
+ _NetworkDebugger.version = "1.3.2";
19610
19669
  let NetworkDebugger = _NetworkDebugger;
19611
19670
  let globalInstance = null;
19612
19671
  const NetworkDebuggerGlobal = {