@leeguoo/pwtk-network-debugger 1.3.1-beta.0 → 1.3.1

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
@@ -17031,14 +17031,23 @@ class LiquidGlassRenderer {
17031
17031
  this.preset = config.preset || "normal";
17032
17032
  this.liquidConfig = this.computeLiquidConfig(this.preset, this.quality);
17033
17033
  this.timeStep = this.getTimeStepForQuality(this.quality);
17034
- const gl = this.canvas.getContext("webgl2", {
17034
+ let gl = this.canvas.getContext("webgl2", {
17035
17035
  alpha: true,
17036
17036
  antialias: true,
17037
17037
  premultipliedAlpha: false,
17038
17038
  preserveDrawingBuffer: true
17039
17039
  });
17040
17040
  if (!gl) {
17041
- throw new Error("WebGL2 not supported");
17041
+ console.log("[PWTK WebGL] WebGL2 not available, falling back to WebGL1");
17042
+ gl = this.canvas.getContext("webgl", {
17043
+ alpha: true,
17044
+ antialias: true,
17045
+ premultipliedAlpha: false,
17046
+ preserveDrawingBuffer: true
17047
+ });
17048
+ }
17049
+ if (!gl) {
17050
+ throw new Error("Neither WebGL2 nor WebGL1 is supported");
17042
17051
  }
17043
17052
  this.gl = gl;
17044
17053
  this.setupGL();
@@ -17411,6 +17420,7 @@ class LiquidGlassScene {
17411
17420
  constructor(container) {
17412
17421
  this.layers = /* @__PURE__ */ new Map();
17413
17422
  this.isActive = false;
17423
+ this.mutationObserver = null;
17414
17424
  this.snapshotCanvas = null;
17415
17425
  this.snapshotScale = 1;
17416
17426
  this.capturePromise = null;
@@ -17429,11 +17439,26 @@ class LiquidGlassScene {
17429
17439
  this.autoQualityEnabled = true;
17430
17440
  this.lastPerformanceCheck = 0;
17431
17441
  this.performanceCheckInterval = 3e3;
17442
+ this.lastDOMChangeTime = 0;
17443
+ this.domChangeDebounceDelay = 500;
17444
+ this.pendingRefresh = false;
17445
+ this.idleCallbackId = null;
17432
17446
  this.markSnapshotDirty = () => {
17433
17447
  if (this.destroyed) return;
17434
17448
  this.snapshotNeedsUpdate = true;
17435
17449
  this.scheduleBackgroundRefresh();
17436
17450
  };
17451
+ this.handleDOMChange = () => {
17452
+ if (this.destroyed || this.pendingRefresh) return;
17453
+ const now = performance.now();
17454
+ if (now - this.lastDOMChangeTime < this.domChangeDebounceDelay) {
17455
+ return;
17456
+ }
17457
+ this.lastDOMChangeTime = now;
17458
+ this.pendingRefresh = true;
17459
+ this.snapshotNeedsUpdate = true;
17460
+ this.scheduleBackgroundRefreshIdle();
17461
+ };
17437
17462
  this.handleVisibilityChange = () => {
17438
17463
  if (!document.hidden) {
17439
17464
  this.sceneStats.visibilityChangeCount++;
@@ -17467,6 +17492,35 @@ class LiquidGlassScene {
17467
17492
  window.addEventListener("scroll", this.markSnapshotDirty, { passive: true });
17468
17493
  window.addEventListener("resize", this.markSnapshotDirty);
17469
17494
  document.addEventListener("visibilitychange", this.handleVisibilityChange);
17495
+ this.setupDOMMutationObserver();
17496
+ }
17497
+ setupDOMMutationObserver() {
17498
+ this.mutationObserver = new MutationObserver((mutations) => {
17499
+ const hasSignificantChange = mutations.some((mutation) => {
17500
+ if (this.container.contains(mutation.target)) {
17501
+ return false;
17502
+ }
17503
+ return mutation.type === "childList" && (mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0) || mutation.type === "attributes" || mutation.type === "characterData";
17504
+ });
17505
+ if (hasSignificantChange) {
17506
+ this.handleDOMChange();
17507
+ }
17508
+ });
17509
+ const observerConfig = {
17510
+ childList: true,
17511
+ // 监听子节点的添加和移除
17512
+ attributes: true,
17513
+ // 监听属性变化
17514
+ characterData: true,
17515
+ // 监听文本内容变化
17516
+ subtree: true,
17517
+ // 监听所有后代节点
17518
+ attributeOldValue: false,
17519
+ characterDataOldValue: false,
17520
+ // 只监听可能影响视觉的属性
17521
+ attributeFilter: ["class", "style", "src", "href", "hidden", "disabled"]
17522
+ };
17523
+ this.mutationObserver.observe(document.body, observerConfig);
17470
17524
  }
17471
17525
  setupContainer() {
17472
17526
  const computedStyle = getComputedStyle(this.container);
@@ -17706,6 +17760,18 @@ class LiquidGlassScene {
17706
17760
  this.refreshTimeout = null;
17707
17761
  }
17708
17762
  this.resizeObserver.disconnect();
17763
+ if (this.mutationObserver) {
17764
+ this.mutationObserver.disconnect();
17765
+ this.mutationObserver = null;
17766
+ }
17767
+ if (this.idleCallbackId !== null) {
17768
+ if (typeof cancelIdleCallback !== "undefined") {
17769
+ cancelIdleCallback(this.idleCallbackId);
17770
+ } else {
17771
+ clearTimeout(this.idleCallbackId);
17772
+ }
17773
+ this.idleCallbackId = null;
17774
+ }
17709
17775
  window.removeEventListener("scroll", this.markSnapshotDirty);
17710
17776
  window.removeEventListener("resize", this.markSnapshotDirty);
17711
17777
  document.removeEventListener("visibilitychange", this.handleVisibilityChange);
@@ -17820,13 +17886,49 @@ class LiquidGlassScene {
17820
17886
  await this.capturePromise;
17821
17887
  }
17822
17888
  scheduleBackgroundRefresh() {
17823
- if (this.refreshTimeout !== null) return;
17889
+ if (this.refreshTimeout !== null) {
17890
+ clearTimeout(this.refreshTimeout);
17891
+ }
17824
17892
  this.refreshTimeout = window.setTimeout(() => {
17825
17893
  this.refreshTimeout = null;
17826
17894
  if (!this.destroyed) {
17827
17895
  this.updateBackgrounds();
17828
17896
  }
17829
- }, 120);
17897
+ }, 150);
17898
+ }
17899
+ scheduleBackgroundRefreshIdle() {
17900
+ if (this.idleCallbackId !== null) {
17901
+ if (typeof cancelIdleCallback !== "undefined") {
17902
+ cancelIdleCallback(this.idleCallbackId);
17903
+ } else {
17904
+ clearTimeout(this.idleCallbackId);
17905
+ }
17906
+ this.idleCallbackId = null;
17907
+ }
17908
+ if (typeof requestIdleCallback !== "undefined") {
17909
+ this.idleCallbackId = requestIdleCallback(
17910
+ (deadline) => {
17911
+ this.idleCallbackId = null;
17912
+ if (this.destroyed) return;
17913
+ if (deadline.timeRemaining() > 10 || deadline.didTimeout) {
17914
+ this.pendingRefresh = false;
17915
+ this.updateBackgrounds();
17916
+ } else {
17917
+ this.scheduleBackgroundRefreshIdle();
17918
+ }
17919
+ },
17920
+ { timeout: 2e3 }
17921
+ // 最多等待 2 秒,避免无限延迟
17922
+ );
17923
+ } else {
17924
+ this.idleCallbackId = window.setTimeout(() => {
17925
+ this.idleCallbackId = null;
17926
+ if (!this.destroyed) {
17927
+ this.pendingRefresh = false;
17928
+ this.updateBackgrounds();
17929
+ }
17930
+ }, 200);
17931
+ }
17830
17932
  }
17831
17933
  }
17832
17934
  const _WebGLManager = class _WebGLManager {
@@ -17853,10 +17955,26 @@ const _WebGLManager = class _WebGLManager {
17853
17955
  checkWebGLSupport() {
17854
17956
  try {
17855
17957
  const canvas = document.createElement("canvas");
17856
- const gl = canvas.getContext("webgl2", { failIfMajorPerformanceCaveat: true });
17857
- this.isSupported = !!gl;
17858
- return this.isSupported;
17958
+ let gl = canvas.getContext("webgl2", { failIfMajorPerformanceCaveat: true });
17959
+ if (gl) {
17960
+ this.isSupported = true;
17961
+ return true;
17962
+ }
17963
+ gl = canvas.getContext("webgl", {
17964
+ alpha: true,
17965
+ antialias: true,
17966
+ premultipliedAlpha: true
17967
+ });
17968
+ if (gl) {
17969
+ console.log("[PWTK WebGL] WebGL2 not available, using WebGL1");
17970
+ this.isSupported = true;
17971
+ return true;
17972
+ }
17973
+ console.warn("[PWTK WebGL] Neither WebGL2 nor WebGL1 is supported");
17974
+ this.isSupported = false;
17975
+ return false;
17859
17976
  } catch (error) {
17977
+ console.error("[PWTK WebGL] Error checking WebGL support:", error);
17860
17978
  this.isSupported = false;
17861
17979
  return false;
17862
17980
  }
@@ -18138,7 +18256,7 @@ const _DebugPanel = class _DebugPanel {
18138
18256
  this.container.style.pointerEvents = "auto";
18139
18257
  this.container.innerHTML = `
18140
18258
  <div class="debugger-header">
18141
- <div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.1-beta.0"}</span></div>
18259
+ <div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.1"}</span></div>
18142
18260
  <div class="debugger-controls">
18143
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>
18144
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>
@@ -19231,8 +19349,8 @@ if (typeof window !== "undefined") {
19231
19349
  }
19232
19350
  function loadLiquidGlass() {
19233
19351
  return new Promise((resolve) => {
19234
- import("./container-DZOQFeJd.mjs").then(() => {
19235
- return import("./button-DfB5OFDC.mjs");
19352
+ import("./container-BiE06oNd.mjs").then(() => {
19353
+ return import("./button-Dt1KsQb6.mjs");
19236
19354
  }).then(() => {
19237
19355
  resolve();
19238
19356
  }).catch((error) => {
@@ -19372,7 +19490,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19372
19490
  }
19373
19491
  async checkForUpdates() {
19374
19492
  try {
19375
- const currentVersion = "1.3.1-beta.0";
19493
+ const currentVersion = "1.3.1";
19376
19494
  logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
19377
19495
  const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
19378
19496
  const data = await response.json();
@@ -19392,7 +19510,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19392
19510
  logger.error("[PWTK Update] Failed to check for updates:", error);
19393
19511
  return {
19394
19512
  hasUpdate: false,
19395
- currentVersion: "1.3.1-beta.0"
19513
+ currentVersion: "1.3.1"
19396
19514
  };
19397
19515
  }
19398
19516
  }
@@ -19488,7 +19606,7 @@ const _NetworkDebugger = class _NetworkDebugger {
19488
19606
  return headers.slk || headers["x-slk"] || "";
19489
19607
  }
19490
19608
  };
19491
- _NetworkDebugger.version = "1.3.1-beta.0";
19609
+ _NetworkDebugger.version = "1.3.1";
19492
19610
  let NetworkDebugger = _NetworkDebugger;
19493
19611
  let globalInstance = null;
19494
19612
  const NetworkDebuggerGlobal = {