@leeguoo/pwtk-network-debugger 1.3.0 → 1.3.1-beta.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/README.md +125 -4
- package/dist/container-CSrLX9-_.js +1 -0
- package/dist/{container-DZOQFeJd.mjs → container-Ll0bZChs.mjs} +8 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.esm.js +320 -20
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/webgl/core/renderer.d.ts +20 -0
- package/types/webgl/core/renderer.d.ts.map +1 -1
- package/types/webgl/core/scene.d.ts +20 -0
- package/types/webgl/core/scene.d.ts.map +1 -1
- package/dist/container-00gbUmcM.js +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -17005,6 +17005,20 @@ class LiquidGlassRenderer {
|
|
|
17005
17005
|
this.usingFallbackShader = false;
|
|
17006
17006
|
this.uniformsDirty = true;
|
|
17007
17007
|
this.time = 0;
|
|
17008
|
+
this.stats = {
|
|
17009
|
+
fps: 60,
|
|
17010
|
+
frameTime: 16.67,
|
|
17011
|
+
droppedFrames: 0,
|
|
17012
|
+
totalFrames: 0,
|
|
17013
|
+
contextLostCount: 0,
|
|
17014
|
+
lastUpdateTime: 0
|
|
17015
|
+
};
|
|
17016
|
+
this.frameTimes = [];
|
|
17017
|
+
this.lastFrameTime = 0;
|
|
17018
|
+
this.fpsUpdateInterval = 1e3;
|
|
17019
|
+
this.lastFpsUpdate = 0;
|
|
17020
|
+
this.blendEnabled = false;
|
|
17021
|
+
this.currentProgram = null;
|
|
17008
17022
|
this.uniformLocations = {};
|
|
17009
17023
|
this.canvas = config.canvas;
|
|
17010
17024
|
this.cssWidth = config.width;
|
|
@@ -17017,26 +17031,48 @@ class LiquidGlassRenderer {
|
|
|
17017
17031
|
this.preset = config.preset || "normal";
|
|
17018
17032
|
this.liquidConfig = this.computeLiquidConfig(this.preset, this.quality);
|
|
17019
17033
|
this.timeStep = this.getTimeStepForQuality(this.quality);
|
|
17020
|
-
|
|
17034
|
+
let gl = this.canvas.getContext("webgl2", {
|
|
17021
17035
|
alpha: true,
|
|
17022
17036
|
antialias: true,
|
|
17023
17037
|
premultipliedAlpha: false,
|
|
17024
17038
|
preserveDrawingBuffer: true
|
|
17025
17039
|
});
|
|
17026
17040
|
if (!gl) {
|
|
17027
|
-
|
|
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");
|
|
17028
17051
|
}
|
|
17029
17052
|
this.gl = gl;
|
|
17030
17053
|
this.setupGL();
|
|
17031
17054
|
}
|
|
17032
17055
|
setupGL() {
|
|
17033
17056
|
const { gl } = this;
|
|
17034
|
-
|
|
17035
|
-
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
17057
|
+
this.enableBlend();
|
|
17036
17058
|
gl.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
17037
17059
|
this.createShaderProgram();
|
|
17038
17060
|
this.createGeometry();
|
|
17039
17061
|
}
|
|
17062
|
+
enableBlend() {
|
|
17063
|
+
if (!this.blendEnabled) {
|
|
17064
|
+
const { gl } = this;
|
|
17065
|
+
gl.enable(gl.BLEND);
|
|
17066
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
17067
|
+
this.blendEnabled = true;
|
|
17068
|
+
}
|
|
17069
|
+
}
|
|
17070
|
+
useProgram(program) {
|
|
17071
|
+
if (this.currentProgram !== program) {
|
|
17072
|
+
this.gl.useProgram(program);
|
|
17073
|
+
this.currentProgram = program;
|
|
17074
|
+
}
|
|
17075
|
+
}
|
|
17040
17076
|
createShaderProgram() {
|
|
17041
17077
|
const { gl } = this;
|
|
17042
17078
|
const vertexShaderSource = `#version 300 es
|
|
@@ -17183,6 +17219,11 @@ class LiquidGlassRenderer {
|
|
|
17183
17219
|
render() {
|
|
17184
17220
|
if (!this.program || !this.backgroundTexture) return;
|
|
17185
17221
|
const { gl } = this;
|
|
17222
|
+
const frameStartTime = performance.now();
|
|
17223
|
+
if (gl.isContextLost()) {
|
|
17224
|
+
this.stats.contextLostCount++;
|
|
17225
|
+
return;
|
|
17226
|
+
}
|
|
17186
17227
|
if (!this.usingFallbackShader) {
|
|
17187
17228
|
const dynamic = this.uniformProvider ? this.uniformProvider() : null;
|
|
17188
17229
|
if (!dynamic) {
|
|
@@ -17193,7 +17234,8 @@ class LiquidGlassRenderer {
|
|
|
17193
17234
|
this.time += this.timeStep;
|
|
17194
17235
|
gl.clearColor(0, 0, 0, 0);
|
|
17195
17236
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
17196
|
-
|
|
17237
|
+
this.enableBlend();
|
|
17238
|
+
this.useProgram(this.program);
|
|
17197
17239
|
if (this.uniformsDirty && !this.usingFallbackShader) {
|
|
17198
17240
|
this.applyLiquidUniforms();
|
|
17199
17241
|
this.uniformsDirty = false;
|
|
@@ -17217,6 +17259,41 @@ class LiquidGlassRenderer {
|
|
|
17217
17259
|
gl.uniform1i(this.uniformLocations.u_background, 0);
|
|
17218
17260
|
}
|
|
17219
17261
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
17262
|
+
this.updatePerformanceStats(frameStartTime);
|
|
17263
|
+
}
|
|
17264
|
+
updatePerformanceStats(frameStartTime) {
|
|
17265
|
+
const now = performance.now();
|
|
17266
|
+
const frameTime = now - frameStartTime;
|
|
17267
|
+
this.stats.totalFrames++;
|
|
17268
|
+
if (frameTime > 33) {
|
|
17269
|
+
this.stats.droppedFrames++;
|
|
17270
|
+
}
|
|
17271
|
+
this.frameTimes.push(frameTime);
|
|
17272
|
+
if (this.frameTimes.length > 60) {
|
|
17273
|
+
this.frameTimes.shift();
|
|
17274
|
+
}
|
|
17275
|
+
if (now - this.lastFpsUpdate > this.fpsUpdateInterval) {
|
|
17276
|
+
const avgFrameTime = this.frameTimes.reduce((a2, b) => a2 + b, 0) / this.frameTimes.length;
|
|
17277
|
+
this.stats.frameTime = avgFrameTime;
|
|
17278
|
+
this.stats.fps = Math.round(1e3 / avgFrameTime);
|
|
17279
|
+
this.stats.lastUpdateTime = now;
|
|
17280
|
+
this.lastFpsUpdate = now;
|
|
17281
|
+
}
|
|
17282
|
+
}
|
|
17283
|
+
getPerformanceStats() {
|
|
17284
|
+
return { ...this.stats };
|
|
17285
|
+
}
|
|
17286
|
+
resetPerformanceStats() {
|
|
17287
|
+
this.stats = {
|
|
17288
|
+
fps: 60,
|
|
17289
|
+
frameTime: 16.67,
|
|
17290
|
+
droppedFrames: 0,
|
|
17291
|
+
totalFrames: 0,
|
|
17292
|
+
contextLostCount: this.stats.contextLostCount,
|
|
17293
|
+
// 保留 context lost 计数
|
|
17294
|
+
lastUpdateTime: performance.now()
|
|
17295
|
+
};
|
|
17296
|
+
this.frameTimes = [];
|
|
17220
17297
|
}
|
|
17221
17298
|
applyDynamicUniforms(dynamic) {
|
|
17222
17299
|
const { gl } = this;
|
|
@@ -17270,7 +17347,11 @@ class LiquidGlassRenderer {
|
|
|
17270
17347
|
this.canvas.height = height * dpr;
|
|
17271
17348
|
this.canvas.style.width = `${width}px`;
|
|
17272
17349
|
this.canvas.style.height = `${height}px`;
|
|
17273
|
-
|
|
17350
|
+
const { gl } = this;
|
|
17351
|
+
gl.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
17352
|
+
this.blendEnabled = false;
|
|
17353
|
+
this.currentProgram = null;
|
|
17354
|
+
this.enableBlend();
|
|
17274
17355
|
this.uniformsDirty = true;
|
|
17275
17356
|
}
|
|
17276
17357
|
setQuality(quality) {
|
|
@@ -17339,17 +17420,62 @@ class LiquidGlassScene {
|
|
|
17339
17420
|
constructor(container) {
|
|
17340
17421
|
this.layers = /* @__PURE__ */ new Map();
|
|
17341
17422
|
this.isActive = false;
|
|
17423
|
+
this.mutationObserver = null;
|
|
17342
17424
|
this.snapshotCanvas = null;
|
|
17343
17425
|
this.snapshotScale = 1;
|
|
17344
17426
|
this.capturePromise = null;
|
|
17345
17427
|
this.snapshotNeedsUpdate = true;
|
|
17346
17428
|
this.refreshTimeout = null;
|
|
17347
17429
|
this.destroyed = false;
|
|
17430
|
+
this.sceneStats = {
|
|
17431
|
+
averageFps: 60,
|
|
17432
|
+
lowestFps: 60,
|
|
17433
|
+
totalDroppedFrames: 0,
|
|
17434
|
+
backgroundRefreshCount: 0,
|
|
17435
|
+
backgroundRefreshTime: 0,
|
|
17436
|
+
visibilityChangeCount: 0
|
|
17437
|
+
};
|
|
17438
|
+
this.performanceMode = "auto";
|
|
17439
|
+
this.autoQualityEnabled = true;
|
|
17440
|
+
this.lastPerformanceCheck = 0;
|
|
17441
|
+
this.performanceCheckInterval = 3e3;
|
|
17442
|
+
this.lastDOMChangeTime = 0;
|
|
17443
|
+
this.domChangeDebounceDelay = 500;
|
|
17444
|
+
this.pendingRefresh = false;
|
|
17445
|
+
this.idleCallbackId = null;
|
|
17348
17446
|
this.markSnapshotDirty = () => {
|
|
17349
17447
|
if (this.destroyed) return;
|
|
17350
17448
|
this.snapshotNeedsUpdate = true;
|
|
17351
17449
|
this.scheduleBackgroundRefresh();
|
|
17352
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
|
+
};
|
|
17462
|
+
this.handleVisibilityChange = () => {
|
|
17463
|
+
if (!document.hidden) {
|
|
17464
|
+
this.sceneStats.visibilityChangeCount++;
|
|
17465
|
+
this.snapshotNeedsUpdate = true;
|
|
17466
|
+
this.updateBackgrounds(true);
|
|
17467
|
+
if (this.isActive) {
|
|
17468
|
+
this.layers.forEach((layer) => {
|
|
17469
|
+
if (layer.visible) {
|
|
17470
|
+
layer.renderer.stopAnimation();
|
|
17471
|
+
layer.renderer.resetPerformanceStats();
|
|
17472
|
+
layer.renderer.startAnimation();
|
|
17473
|
+
}
|
|
17474
|
+
});
|
|
17475
|
+
}
|
|
17476
|
+
this.lastPerformanceCheck = performance.now();
|
|
17477
|
+
}
|
|
17478
|
+
};
|
|
17353
17479
|
this.container = container;
|
|
17354
17480
|
this.backgroundCanvas = document.createElement("canvas");
|
|
17355
17481
|
const ctx = this.backgroundCanvas.getContext("2d");
|
|
@@ -17365,6 +17491,36 @@ class LiquidGlassScene {
|
|
|
17365
17491
|
this.resizeObserver.observe(container);
|
|
17366
17492
|
window.addEventListener("scroll", this.markSnapshotDirty, { passive: true });
|
|
17367
17493
|
window.addEventListener("resize", this.markSnapshotDirty);
|
|
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);
|
|
17368
17524
|
}
|
|
17369
17525
|
setupContainer() {
|
|
17370
17526
|
const computedStyle = getComputedStyle(this.container);
|
|
@@ -17482,6 +17638,60 @@ class LiquidGlassScene {
|
|
|
17482
17638
|
layer.renderer.startAnimation();
|
|
17483
17639
|
}
|
|
17484
17640
|
});
|
|
17641
|
+
if (this.autoQualityEnabled) {
|
|
17642
|
+
this.startPerformanceMonitoring();
|
|
17643
|
+
}
|
|
17644
|
+
}
|
|
17645
|
+
startPerformanceMonitoring() {
|
|
17646
|
+
const checkPerformance = () => {
|
|
17647
|
+
if (!this.isActive || this.destroyed || document.hidden) {
|
|
17648
|
+
setTimeout(checkPerformance, this.performanceCheckInterval);
|
|
17649
|
+
return;
|
|
17650
|
+
}
|
|
17651
|
+
const now = performance.now();
|
|
17652
|
+
if (now - this.lastPerformanceCheck < this.performanceCheckInterval) {
|
|
17653
|
+
setTimeout(checkPerformance, this.performanceCheckInterval);
|
|
17654
|
+
return;
|
|
17655
|
+
}
|
|
17656
|
+
this.lastPerformanceCheck = now;
|
|
17657
|
+
this.updateSceneStats();
|
|
17658
|
+
if (this.autoQualityEnabled && this.performanceMode === "auto") {
|
|
17659
|
+
this.autoAdjustQuality();
|
|
17660
|
+
}
|
|
17661
|
+
setTimeout(checkPerformance, this.performanceCheckInterval);
|
|
17662
|
+
};
|
|
17663
|
+
setTimeout(checkPerformance, this.performanceCheckInterval);
|
|
17664
|
+
}
|
|
17665
|
+
updateSceneStats() {
|
|
17666
|
+
let totalFps = 0;
|
|
17667
|
+
let lowestFps = 60;
|
|
17668
|
+
let totalDroppedFrames = 0;
|
|
17669
|
+
let layerCount = 0;
|
|
17670
|
+
this.layers.forEach((layer) => {
|
|
17671
|
+
if (layer.visible) {
|
|
17672
|
+
const stats = layer.renderer.getPerformanceStats();
|
|
17673
|
+
totalFps += stats.fps;
|
|
17674
|
+
lowestFps = Math.min(lowestFps, stats.fps);
|
|
17675
|
+
totalDroppedFrames += stats.droppedFrames;
|
|
17676
|
+
layerCount++;
|
|
17677
|
+
}
|
|
17678
|
+
});
|
|
17679
|
+
if (layerCount > 0) {
|
|
17680
|
+
this.sceneStats.averageFps = Math.round(totalFps / layerCount);
|
|
17681
|
+
this.sceneStats.lowestFps = lowestFps;
|
|
17682
|
+
this.sceneStats.totalDroppedFrames = totalDroppedFrames;
|
|
17683
|
+
}
|
|
17684
|
+
}
|
|
17685
|
+
autoAdjustQuality() {
|
|
17686
|
+
const { averageFps, lowestFps, totalDroppedFrames } = this.sceneStats;
|
|
17687
|
+
if (lowestFps < 25 || averageFps < 30 && totalDroppedFrames > 50) {
|
|
17688
|
+
this.setQuality("low");
|
|
17689
|
+
console.warn("[PWTK WebGL] Performance poor, auto-switched to low quality");
|
|
17690
|
+
} else if (lowestFps < 45 || averageFps < 50 && totalDroppedFrames > 20) {
|
|
17691
|
+
this.setQuality("medium");
|
|
17692
|
+
} else if (lowestFps > 55 && totalDroppedFrames < 5) {
|
|
17693
|
+
this.setQuality("high");
|
|
17694
|
+
}
|
|
17485
17695
|
}
|
|
17486
17696
|
stopAnimation() {
|
|
17487
17697
|
this.isActive = false;
|
|
@@ -17550,8 +17760,21 @@ class LiquidGlassScene {
|
|
|
17550
17760
|
this.refreshTimeout = null;
|
|
17551
17761
|
}
|
|
17552
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
|
+
}
|
|
17553
17775
|
window.removeEventListener("scroll", this.markSnapshotDirty);
|
|
17554
17776
|
window.removeEventListener("resize", this.markSnapshotDirty);
|
|
17777
|
+
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
17555
17778
|
}
|
|
17556
17779
|
getLayer(id) {
|
|
17557
17780
|
return this.layers.get(id);
|
|
@@ -17568,6 +17791,24 @@ class LiquidGlassScene {
|
|
|
17568
17791
|
return false;
|
|
17569
17792
|
}
|
|
17570
17793
|
}
|
|
17794
|
+
getPerformanceStats() {
|
|
17795
|
+
this.updateSceneStats();
|
|
17796
|
+
return { ...this.sceneStats };
|
|
17797
|
+
}
|
|
17798
|
+
setPerformanceMode(mode) {
|
|
17799
|
+
this.performanceMode = mode;
|
|
17800
|
+
this.autoQualityEnabled = mode === "auto";
|
|
17801
|
+
if (mode === "high") {
|
|
17802
|
+
this.setQuality("high");
|
|
17803
|
+
} else if (mode === "low") {
|
|
17804
|
+
this.setQuality("low");
|
|
17805
|
+
} else if (mode === "balanced") {
|
|
17806
|
+
this.setQuality("medium");
|
|
17807
|
+
}
|
|
17808
|
+
}
|
|
17809
|
+
enableAutoQuality(enabled) {
|
|
17810
|
+
this.autoQualityEnabled = enabled;
|
|
17811
|
+
}
|
|
17571
17812
|
applyPlaceholderBackground(layer) {
|
|
17572
17813
|
const rect = layer.element.getBoundingClientRect();
|
|
17573
17814
|
const width = Math.max(1, Math.round(rect.width || layer.canvas.clientWidth || 1));
|
|
@@ -17610,9 +17851,13 @@ class LiquidGlassScene {
|
|
|
17610
17851
|
};
|
|
17611
17852
|
}
|
|
17612
17853
|
async refreshLayerBackground(layer, forceSnapshot = false) {
|
|
17854
|
+
const startTime = performance.now();
|
|
17613
17855
|
await this.ensurePageSnapshot(forceSnapshot);
|
|
17614
17856
|
if (!this.snapshotCanvas) return;
|
|
17615
17857
|
layer.renderer.setBackgroundTexture(this.snapshotCanvas);
|
|
17858
|
+
const refreshTime = performance.now() - startTime;
|
|
17859
|
+
this.sceneStats.backgroundRefreshCount++;
|
|
17860
|
+
this.sceneStats.backgroundRefreshTime = refreshTime;
|
|
17616
17861
|
}
|
|
17617
17862
|
async ensurePageSnapshot(force = false) {
|
|
17618
17863
|
if (this.destroyed) return;
|
|
@@ -17641,13 +17886,49 @@ class LiquidGlassScene {
|
|
|
17641
17886
|
await this.capturePromise;
|
|
17642
17887
|
}
|
|
17643
17888
|
scheduleBackgroundRefresh() {
|
|
17644
|
-
if (this.refreshTimeout !== null)
|
|
17889
|
+
if (this.refreshTimeout !== null) {
|
|
17890
|
+
clearTimeout(this.refreshTimeout);
|
|
17891
|
+
}
|
|
17645
17892
|
this.refreshTimeout = window.setTimeout(() => {
|
|
17646
17893
|
this.refreshTimeout = null;
|
|
17647
17894
|
if (!this.destroyed) {
|
|
17648
17895
|
this.updateBackgrounds();
|
|
17649
17896
|
}
|
|
17650
|
-
},
|
|
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
|
+
}
|
|
17651
17932
|
}
|
|
17652
17933
|
}
|
|
17653
17934
|
const _WebGLManager = class _WebGLManager {
|
|
@@ -17674,10 +17955,26 @@ const _WebGLManager = class _WebGLManager {
|
|
|
17674
17955
|
checkWebGLSupport() {
|
|
17675
17956
|
try {
|
|
17676
17957
|
const canvas = document.createElement("canvas");
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
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;
|
|
17680
17976
|
} catch (error) {
|
|
17977
|
+
console.error("[PWTK WebGL] Error checking WebGL support:", error);
|
|
17681
17978
|
this.isSupported = false;
|
|
17682
17979
|
return false;
|
|
17683
17980
|
}
|
|
@@ -17959,7 +18256,7 @@ const _DebugPanel = class _DebugPanel {
|
|
|
17959
18256
|
this.container.style.pointerEvents = "auto";
|
|
17960
18257
|
this.container.innerHTML = `
|
|
17961
18258
|
<div class="debugger-header">
|
|
17962
|
-
<div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.
|
|
18259
|
+
<div class="debugger-title">🔓 PWTK 解密小工具 <span style="font-size: 10px; opacity: 0.7;">by Leo v${"1.3.1-beta.1"}</span></div>
|
|
17963
18260
|
<div class="debugger-controls">
|
|
17964
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>
|
|
17965
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>
|
|
@@ -19052,7 +19349,7 @@ if (typeof window !== "undefined") {
|
|
|
19052
19349
|
}
|
|
19053
19350
|
function loadLiquidGlass() {
|
|
19054
19351
|
return new Promise((resolve) => {
|
|
19055
|
-
import("./container-
|
|
19352
|
+
import("./container-Ll0bZChs.mjs").then(() => {
|
|
19056
19353
|
return import("./button-DfB5OFDC.mjs");
|
|
19057
19354
|
}).then(() => {
|
|
19058
19355
|
resolve();
|
|
@@ -19063,7 +19360,7 @@ function loadLiquidGlass() {
|
|
|
19063
19360
|
});
|
|
19064
19361
|
}
|
|
19065
19362
|
const liquidGlassPromise = loadLiquidGlass();
|
|
19066
|
-
class
|
|
19363
|
+
const _NetworkDebugger = class _NetworkDebugger {
|
|
19067
19364
|
constructor() {
|
|
19068
19365
|
this.interceptor = null;
|
|
19069
19366
|
this.panel = null;
|
|
@@ -19076,6 +19373,7 @@ class NetworkDebugger {
|
|
|
19076
19373
|
logger.warn("NetworkDebugger already initialized");
|
|
19077
19374
|
return;
|
|
19078
19375
|
}
|
|
19376
|
+
logger.info(`🚀 PWTK Network Debugger v${_NetworkDebugger.version} initializing...`);
|
|
19079
19377
|
this.config = {
|
|
19080
19378
|
autoStart: true,
|
|
19081
19379
|
position: "bottom-right",
|
|
@@ -19131,13 +19429,13 @@ class NetworkDebugger {
|
|
|
19131
19429
|
this.initialized = true;
|
|
19132
19430
|
logger.consoleDirect(`
|
|
19133
19431
|
╔════════════════════════════════════════╗
|
|
19134
|
-
║ 🔓 PWTK 解密小工具 v${
|
|
19432
|
+
║ 🔓 PWTK 解密小工具 v${_NetworkDebugger.version} ║
|
|
19135
19433
|
║ Created by Leo (@leeguoo) ║
|
|
19136
19434
|
║ 技术支持: 请联系 Leo ║
|
|
19137
19435
|
║ 分享服务: curl.bwg.leeguoo.com ║
|
|
19138
19436
|
╚════════════════════════════════════════╝
|
|
19139
19437
|
`);
|
|
19140
|
-
logger.info(
|
|
19438
|
+
logger.info(`✅ PWTK Network Debugger v${_NetworkDebugger.version} initialized successfully`);
|
|
19141
19439
|
} catch (error) {
|
|
19142
19440
|
logger.error("NetworkDebugger initialization failed:", error);
|
|
19143
19441
|
throw error;
|
|
@@ -19192,7 +19490,7 @@ class NetworkDebugger {
|
|
|
19192
19490
|
}
|
|
19193
19491
|
async checkForUpdates() {
|
|
19194
19492
|
try {
|
|
19195
|
-
const currentVersion = "1.3.
|
|
19493
|
+
const currentVersion = "1.3.1-beta.1";
|
|
19196
19494
|
logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
|
|
19197
19495
|
const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
|
|
19198
19496
|
const data = await response.json();
|
|
@@ -19212,7 +19510,7 @@ class NetworkDebugger {
|
|
|
19212
19510
|
logger.error("[PWTK Update] Failed to check for updates:", error);
|
|
19213
19511
|
return {
|
|
19214
19512
|
hasUpdate: false,
|
|
19215
|
-
currentVersion: "1.3.
|
|
19513
|
+
currentVersion: "1.3.1-beta.1"
|
|
19216
19514
|
};
|
|
19217
19515
|
}
|
|
19218
19516
|
}
|
|
@@ -19286,7 +19584,7 @@ class NetworkDebugger {
|
|
|
19286
19584
|
}
|
|
19287
19585
|
// 静态方法,用于全局访问
|
|
19288
19586
|
static create(config) {
|
|
19289
|
-
const instance = new
|
|
19587
|
+
const instance = new _NetworkDebugger();
|
|
19290
19588
|
return instance.init(config).then(() => instance);
|
|
19291
19589
|
}
|
|
19292
19590
|
createPanel() {
|
|
@@ -19307,7 +19605,9 @@ class NetworkDebugger {
|
|
|
19307
19605
|
defaultSlkExtractor(headers) {
|
|
19308
19606
|
return headers.slk || headers["x-slk"] || "";
|
|
19309
19607
|
}
|
|
19310
|
-
}
|
|
19608
|
+
};
|
|
19609
|
+
_NetworkDebugger.version = "1.3.1-beta.1";
|
|
19610
|
+
let NetworkDebugger = _NetworkDebugger;
|
|
19311
19611
|
let globalInstance = null;
|
|
19312
19612
|
const NetworkDebuggerGlobal = {
|
|
19313
19613
|
async init(config) {
|