@leeguoo/pwtk-network-debugger 1.3.3 → 1.3.4
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.cjs.js +4 -4
- package/dist/index.esm.js +137 -17
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/types/ui/panel.d.ts.map +1 -1
- package/types/webgl/core/scene.d.ts +13 -0
- package/types/webgl/core/scene.d.ts.map +1 -1
- package/types/webgl/manager.d.ts +2 -1
- package/types/webgl/manager.d.ts.map +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -17423,10 +17423,19 @@ class LiquidGlassScene {
|
|
|
17423
17423
|
this.mutationObserver = null;
|
|
17424
17424
|
this.snapshotCanvas = null;
|
|
17425
17425
|
this.snapshotScale = 1;
|
|
17426
|
+
this.maxSnapshotPixels = 3e6;
|
|
17427
|
+
this.minSnapshotScale = 0.35;
|
|
17428
|
+
this.minSnapshotInterval = 1500;
|
|
17429
|
+
this.lastSnapshotCapture = -Infinity;
|
|
17426
17430
|
this.capturePromise = null;
|
|
17427
17431
|
this.snapshotNeedsUpdate = true;
|
|
17428
17432
|
this.refreshTimeout = null;
|
|
17429
17433
|
this.destroyed = false;
|
|
17434
|
+
this.interactionActive = false;
|
|
17435
|
+
this.manualInteractionActive = false;
|
|
17436
|
+
this.transientInteractionCount = 0;
|
|
17437
|
+
this.transientInteractionTimers = [];
|
|
17438
|
+
this.pendingBackgroundRefresh = false;
|
|
17430
17439
|
this.sceneStats = {
|
|
17431
17440
|
averageFps: 60,
|
|
17432
17441
|
lowestFps: 60,
|
|
@@ -17446,6 +17455,7 @@ class LiquidGlassScene {
|
|
|
17446
17455
|
this.markSnapshotDirty = () => {
|
|
17447
17456
|
if (this.destroyed) return;
|
|
17448
17457
|
this.snapshotNeedsUpdate = true;
|
|
17458
|
+
this.beginTransientInteraction();
|
|
17449
17459
|
this.scheduleBackgroundRefresh();
|
|
17450
17460
|
};
|
|
17451
17461
|
this.handleDOMChange = () => {
|
|
@@ -17601,7 +17611,7 @@ class LiquidGlassScene {
|
|
|
17601
17611
|
this.layers.set(id, layer);
|
|
17602
17612
|
renderer.setUniformProvider(() => this.getDynamicUniforms(layer));
|
|
17603
17613
|
this.applyPlaceholderBackground(layer);
|
|
17604
|
-
this.refreshLayerBackground(layer).catch((err) => {
|
|
17614
|
+
this.refreshLayerBackground(layer, true).catch((err) => {
|
|
17605
17615
|
});
|
|
17606
17616
|
return layer;
|
|
17607
17617
|
}
|
|
@@ -17708,6 +17718,7 @@ class LiquidGlassScene {
|
|
|
17708
17718
|
layer.borderRadius = this.getBorderRadius(layer.element);
|
|
17709
17719
|
this.applyPlaceholderBackground(layer);
|
|
17710
17720
|
});
|
|
17721
|
+
this.beginTransientInteraction(600);
|
|
17711
17722
|
this.scheduleBackgroundRefresh();
|
|
17712
17723
|
}
|
|
17713
17724
|
updateBackgrounds(forceSnapshot = false) {
|
|
@@ -17772,6 +17783,11 @@ class LiquidGlassScene {
|
|
|
17772
17783
|
}
|
|
17773
17784
|
this.idleCallbackId = null;
|
|
17774
17785
|
}
|
|
17786
|
+
this.transientInteractionTimers.forEach((id) => window.clearTimeout(id));
|
|
17787
|
+
this.transientInteractionTimers = [];
|
|
17788
|
+
this.transientInteractionCount = 0;
|
|
17789
|
+
this.manualInteractionActive = false;
|
|
17790
|
+
this.interactionActive = false;
|
|
17775
17791
|
window.removeEventListener("scroll", this.markSnapshotDirty);
|
|
17776
17792
|
window.removeEventListener("resize", this.markSnapshotDirty);
|
|
17777
17793
|
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
@@ -17809,6 +17825,42 @@ class LiquidGlassScene {
|
|
|
17809
17825
|
enableAutoQuality(enabled) {
|
|
17810
17826
|
this.autoQualityEnabled = enabled;
|
|
17811
17827
|
}
|
|
17828
|
+
setInteractionState(active) {
|
|
17829
|
+
if (this.destroyed) return;
|
|
17830
|
+
if (active) {
|
|
17831
|
+
if (this.manualInteractionActive) return;
|
|
17832
|
+
this.manualInteractionActive = true;
|
|
17833
|
+
} else {
|
|
17834
|
+
if (!this.manualInteractionActive) return;
|
|
17835
|
+
this.manualInteractionActive = false;
|
|
17836
|
+
}
|
|
17837
|
+
this.updateInteractionState();
|
|
17838
|
+
}
|
|
17839
|
+
beginTransientInteraction(duration2 = 400) {
|
|
17840
|
+
if (this.destroyed) return;
|
|
17841
|
+
this.transientInteractionCount++;
|
|
17842
|
+
this.updateInteractionState();
|
|
17843
|
+
const timerId = window.setTimeout(() => {
|
|
17844
|
+
this.transientInteractionTimers = this.transientInteractionTimers.filter((id) => id !== timerId);
|
|
17845
|
+
if (this.destroyed) return;
|
|
17846
|
+
this.transientInteractionCount = Math.max(0, this.transientInteractionCount - 1);
|
|
17847
|
+
this.updateInteractionState();
|
|
17848
|
+
}, duration2);
|
|
17849
|
+
this.transientInteractionTimers.push(timerId);
|
|
17850
|
+
}
|
|
17851
|
+
updateInteractionState() {
|
|
17852
|
+
const wasActive = this.interactionActive;
|
|
17853
|
+
this.interactionActive = this.manualInteractionActive || this.transientInteractionCount > 0;
|
|
17854
|
+
if (this.interactionActive && !wasActive) {
|
|
17855
|
+
if (this.pendingBackgroundRefresh || this.snapshotNeedsUpdate) {
|
|
17856
|
+
this.updateBackgrounds();
|
|
17857
|
+
}
|
|
17858
|
+
} else if (!this.interactionActive && wasActive) {
|
|
17859
|
+
if (this.pendingBackgroundRefresh || this.snapshotNeedsUpdate) {
|
|
17860
|
+
this.scheduleBackgroundRefresh(true);
|
|
17861
|
+
}
|
|
17862
|
+
}
|
|
17863
|
+
}
|
|
17812
17864
|
applyPlaceholderBackground(layer) {
|
|
17813
17865
|
const rect = layer.element.getBoundingClientRect();
|
|
17814
17866
|
const width = Math.max(1, Math.round(rect.width || layer.canvas.clientWidth || 1));
|
|
@@ -17852,13 +17904,63 @@ class LiquidGlassScene {
|
|
|
17852
17904
|
}
|
|
17853
17905
|
async refreshLayerBackground(layer, forceSnapshot = false) {
|
|
17854
17906
|
const startTime = performance.now();
|
|
17907
|
+
if (!forceSnapshot && !this.interactionActive) {
|
|
17908
|
+
this.pendingBackgroundRefresh = true;
|
|
17909
|
+
return;
|
|
17910
|
+
}
|
|
17855
17911
|
await this.ensurePageSnapshot(forceSnapshot);
|
|
17856
17912
|
if (!this.snapshotCanvas) return;
|
|
17857
17913
|
layer.renderer.setBackgroundTexture(this.snapshotCanvas);
|
|
17914
|
+
this.pendingBackgroundRefresh = false;
|
|
17858
17915
|
const refreshTime = performance.now() - startTime;
|
|
17859
17916
|
this.sceneStats.backgroundRefreshCount++;
|
|
17860
17917
|
this.sceneStats.backgroundRefreshTime = refreshTime;
|
|
17861
17918
|
}
|
|
17919
|
+
calculateSnapshotScale() {
|
|
17920
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
17921
|
+
return 1;
|
|
17922
|
+
}
|
|
17923
|
+
const doc = document.documentElement;
|
|
17924
|
+
const body = document.body;
|
|
17925
|
+
const width = Math.max(
|
|
17926
|
+
doc?.scrollWidth ?? 0,
|
|
17927
|
+
body?.scrollWidth ?? 0,
|
|
17928
|
+
window.innerWidth || 0
|
|
17929
|
+
);
|
|
17930
|
+
const height = Math.max(
|
|
17931
|
+
doc?.scrollHeight ?? 0,
|
|
17932
|
+
body?.scrollHeight ?? 0,
|
|
17933
|
+
window.innerHeight || 0
|
|
17934
|
+
);
|
|
17935
|
+
if (width <= 0 || height <= 0) {
|
|
17936
|
+
return 1;
|
|
17937
|
+
}
|
|
17938
|
+
const area = width * height;
|
|
17939
|
+
let scale = area > this.maxSnapshotPixels ? Math.sqrt(this.maxSnapshotPixels / area) : 1;
|
|
17940
|
+
if (!Number.isFinite(scale) || scale <= 0) {
|
|
17941
|
+
scale = 1;
|
|
17942
|
+
}
|
|
17943
|
+
switch (this.performanceMode) {
|
|
17944
|
+
case "low":
|
|
17945
|
+
scale = Math.min(scale, 0.55);
|
|
17946
|
+
break;
|
|
17947
|
+
case "balanced":
|
|
17948
|
+
scale = Math.min(scale, 0.75);
|
|
17949
|
+
break;
|
|
17950
|
+
case "high":
|
|
17951
|
+
scale = Math.min(1, scale * 1.15);
|
|
17952
|
+
break;
|
|
17953
|
+
default:
|
|
17954
|
+
if (this.sceneStats.lowestFps < 45) {
|
|
17955
|
+
scale = Math.min(scale, 0.7);
|
|
17956
|
+
}
|
|
17957
|
+
break;
|
|
17958
|
+
}
|
|
17959
|
+
if (this.layers.size > 1) {
|
|
17960
|
+
scale = Math.min(scale, 0.8);
|
|
17961
|
+
}
|
|
17962
|
+
return Math.max(this.minSnapshotScale, Math.min(1, scale));
|
|
17963
|
+
}
|
|
17862
17964
|
async ensurePageSnapshot(force = false) {
|
|
17863
17965
|
if (this.destroyed) return;
|
|
17864
17966
|
if (this.snapshotCanvas && !this.snapshotNeedsUpdate && !force) return;
|
|
@@ -17866,7 +17968,13 @@ class LiquidGlassScene {
|
|
|
17866
17968
|
await this.capturePromise;
|
|
17867
17969
|
return;
|
|
17868
17970
|
}
|
|
17869
|
-
|
|
17971
|
+
if (!force) {
|
|
17972
|
+
const elapsed = performance.now() - this.lastSnapshotCapture;
|
|
17973
|
+
if (elapsed < this.minSnapshotInterval) {
|
|
17974
|
+
await new Promise((resolve) => window.setTimeout(resolve, this.minSnapshotInterval - elapsed));
|
|
17975
|
+
}
|
|
17976
|
+
}
|
|
17977
|
+
const scale = this.calculateSnapshotScale();
|
|
17870
17978
|
this.capturePromise = html2canvas(document.body, {
|
|
17871
17979
|
scale,
|
|
17872
17980
|
backgroundColor: null,
|
|
@@ -17878,23 +17986,27 @@ class LiquidGlassScene {
|
|
|
17878
17986
|
this.snapshotCanvas = canvas;
|
|
17879
17987
|
this.snapshotScale = scale;
|
|
17880
17988
|
this.snapshotNeedsUpdate = false;
|
|
17989
|
+
this.lastSnapshotCapture = performance.now();
|
|
17881
17990
|
}).catch((error) => {
|
|
17882
17991
|
this.snapshotCanvas = null;
|
|
17992
|
+
this.lastSnapshotCapture = performance.now();
|
|
17993
|
+
this.pendingBackgroundRefresh = true;
|
|
17883
17994
|
}).finally(() => {
|
|
17884
17995
|
this.capturePromise = null;
|
|
17885
17996
|
});
|
|
17886
17997
|
await this.capturePromise;
|
|
17887
17998
|
}
|
|
17888
|
-
scheduleBackgroundRefresh() {
|
|
17999
|
+
scheduleBackgroundRefresh(force = false) {
|
|
17889
18000
|
if (this.refreshTimeout !== null) {
|
|
17890
18001
|
clearTimeout(this.refreshTimeout);
|
|
17891
18002
|
}
|
|
18003
|
+
const delay = force ? 16 : 150;
|
|
17892
18004
|
this.refreshTimeout = window.setTimeout(() => {
|
|
17893
18005
|
this.refreshTimeout = null;
|
|
17894
18006
|
if (!this.destroyed) {
|
|
17895
|
-
this.updateBackgrounds();
|
|
18007
|
+
this.updateBackgrounds(force);
|
|
17896
18008
|
}
|
|
17897
|
-
},
|
|
18009
|
+
}, delay);
|
|
17898
18010
|
}
|
|
17899
18011
|
scheduleBackgroundRefreshIdle() {
|
|
17900
18012
|
if (this.idleCallbackId !== null) {
|
|
@@ -18133,9 +18245,14 @@ const _WebGLManager = class _WebGLManager {
|
|
|
18133
18245
|
this.scene.setPreset(this.config.preset);
|
|
18134
18246
|
}
|
|
18135
18247
|
}
|
|
18136
|
-
updateBackgrounds() {
|
|
18248
|
+
updateBackgrounds(forceSnapshot = false) {
|
|
18249
|
+
if (this.scene) {
|
|
18250
|
+
this.scene.updateBackgrounds(forceSnapshot);
|
|
18251
|
+
}
|
|
18252
|
+
}
|
|
18253
|
+
setInteractionState(active) {
|
|
18137
18254
|
if (this.scene) {
|
|
18138
|
-
this.scene.
|
|
18255
|
+
this.scene.setInteractionState(active);
|
|
18139
18256
|
}
|
|
18140
18257
|
}
|
|
18141
18258
|
isWebGLEnabled() {
|
|
@@ -18256,7 +18373,7 @@ const _DebugPanel = class _DebugPanel {
|
|
|
18256
18373
|
this.container.style.pointerEvents = "auto";
|
|
18257
18374
|
this.container.innerHTML = `
|
|
18258
18375
|
<div class="debugger-header">
|
|
18259
|
-
<div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.
|
|
18376
|
+
<div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.4"}</span></div>
|
|
18260
18377
|
<div class="debugger-controls">
|
|
18261
18378
|
<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
18379
|
<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>
|
|
@@ -18724,7 +18841,7 @@ Created by Leo (@leeguoo)`);
|
|
|
18724
18841
|
this.container.style.right = "auto";
|
|
18725
18842
|
this.container.style.bottom = "auto";
|
|
18726
18843
|
}
|
|
18727
|
-
this.scheduleWebGLBackgroundUpdate();
|
|
18844
|
+
this.scheduleWebGLBackgroundUpdate(true);
|
|
18728
18845
|
}
|
|
18729
18846
|
// 移除 handleToolAction 方法 - 不再需要工具功能
|
|
18730
18847
|
// 移除 handleParseCurl 方法
|
|
@@ -18733,12 +18850,14 @@ Created by Leo (@leeguoo)`);
|
|
|
18733
18850
|
this.isDragging = true;
|
|
18734
18851
|
this.dragStart = { x: e2.clientX, y: e2.clientY };
|
|
18735
18852
|
this.container.style.transition = "none";
|
|
18853
|
+
this.webglManager?.setInteractionState(true);
|
|
18736
18854
|
}
|
|
18737
18855
|
startResize(e2, direction2) {
|
|
18738
18856
|
this.isResizing = true;
|
|
18739
18857
|
this.resizeDirection = direction2;
|
|
18740
18858
|
this.dragStart = { x: e2.clientX, y: e2.clientY };
|
|
18741
18859
|
this.container.style.transition = "none";
|
|
18860
|
+
this.webglManager?.setInteractionState(true);
|
|
18742
18861
|
}
|
|
18743
18862
|
handleMouseMove(e2) {
|
|
18744
18863
|
if (this.isDragging) {
|
|
@@ -18796,11 +18915,12 @@ Created by Leo (@leeguoo)`);
|
|
|
18796
18915
|
if (this.isDragging) {
|
|
18797
18916
|
this.savePosition();
|
|
18798
18917
|
}
|
|
18799
|
-
this.scheduleWebGLBackgroundUpdate();
|
|
18918
|
+
this.scheduleWebGLBackgroundUpdate(true);
|
|
18800
18919
|
}
|
|
18801
18920
|
this.isDragging = false;
|
|
18802
18921
|
this.isResizing = false;
|
|
18803
18922
|
this.resizeDirection = "";
|
|
18923
|
+
this.webglManager?.setInteractionState(false);
|
|
18804
18924
|
}
|
|
18805
18925
|
handleWindowResize() {
|
|
18806
18926
|
if (this.resizeTimeout) {
|
|
@@ -18855,7 +18975,7 @@ Created by Leo (@leeguoo)`);
|
|
|
18855
18975
|
this.container.style.height = `${newHeight}px`;
|
|
18856
18976
|
}
|
|
18857
18977
|
this.savePosition();
|
|
18858
|
-
this.scheduleWebGLBackgroundUpdate();
|
|
18978
|
+
this.scheduleWebGLBackgroundUpdate(true);
|
|
18859
18979
|
}
|
|
18860
18980
|
}
|
|
18861
18981
|
show() {
|
|
@@ -19304,7 +19424,7 @@ Created by Leo (@leeguoo)`);
|
|
|
19304
19424
|
setTimeout(() => {
|
|
19305
19425
|
this.enableWebGLForRequestItems();
|
|
19306
19426
|
}, 500);
|
|
19307
|
-
this.scheduleWebGLBackgroundUpdate();
|
|
19427
|
+
this.scheduleWebGLBackgroundUpdate(true);
|
|
19308
19428
|
logger.debug("✨ WebGL liquid glass effects initialized");
|
|
19309
19429
|
} else {
|
|
19310
19430
|
logger.debug("🔄 WebGL initialization failed, using CSS fallback");
|
|
@@ -19327,15 +19447,15 @@ Created by Leo (@leeguoo)`);
|
|
|
19327
19447
|
}
|
|
19328
19448
|
});
|
|
19329
19449
|
}
|
|
19330
|
-
scheduleWebGLBackgroundUpdate() {
|
|
19450
|
+
scheduleWebGLBackgroundUpdate(force = false) {
|
|
19331
19451
|
if (!this.webglManager) return;
|
|
19332
19452
|
if (this.webglBackgroundUpdateTimer !== null) {
|
|
19333
19453
|
window.clearTimeout(this.webglBackgroundUpdateTimer);
|
|
19334
19454
|
}
|
|
19335
|
-
const delay = this.isDragging || this.isResizing ? 120 : 0;
|
|
19455
|
+
const delay = this.isDragging || this.isResizing ? 120 : force ? 30 : 0;
|
|
19336
19456
|
this.webglBackgroundUpdateTimer = window.setTimeout(() => {
|
|
19337
19457
|
this.webglBackgroundUpdateTimer = null;
|
|
19338
|
-
this.webglManager?.updateBackgrounds();
|
|
19458
|
+
this.webglManager?.updateBackgrounds(force);
|
|
19339
19459
|
}, delay);
|
|
19340
19460
|
}
|
|
19341
19461
|
/**
|
|
@@ -19549,7 +19669,7 @@ const _NetworkDebugger = class _NetworkDebugger {
|
|
|
19549
19669
|
}
|
|
19550
19670
|
async checkForUpdates() {
|
|
19551
19671
|
try {
|
|
19552
|
-
const currentVersion = "1.3.
|
|
19672
|
+
const currentVersion = "1.3.4";
|
|
19553
19673
|
logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
|
|
19554
19674
|
const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
|
|
19555
19675
|
const data = await response.json();
|
|
@@ -19569,7 +19689,7 @@ const _NetworkDebugger = class _NetworkDebugger {
|
|
|
19569
19689
|
logger.error("[PWTK Update] Failed to check for updates:", error);
|
|
19570
19690
|
return {
|
|
19571
19691
|
hasUpdate: false,
|
|
19572
|
-
currentVersion: "1.3.
|
|
19692
|
+
currentVersion: "1.3.4"
|
|
19573
19693
|
};
|
|
19574
19694
|
}
|
|
19575
19695
|
}
|