@leeguoo/pwtk-network-debugger 1.2.41 β†’ 1.2.42

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
@@ -8286,7 +8286,7 @@ const _DebugPanel = class _DebugPanel {
8286
8286
  <div class="about-panel" data-panel="about" style="display: none;">
8287
8287
  <div style="padding: 20px; color: #fff; text-align: center;">
8288
8288
  <h2 style="margin: 0 0 20px 0;">πŸ”“ PWTK 解密小ε·₯ε…·</h2>
8289
- <p style="margin: 10px 0;">Version: ${"1.2.41"}</p>
8289
+ <p style="margin: 10px 0;">Version: ${"1.2.42"}</p>
8290
8290
  <p style="margin: 10px 0;">πŸ‘¨β€πŸ’» Created by <strong>Leo (@leeguoo)</strong></p>
8291
8291
  <p style="margin: 10px 0;">πŸ“§ ζŠ€ζœ―ζ”―ζŒοΌšθ―·θ”η³» Leo</p>
8292
8292
  <p style="margin: 10px 0;">🌐 εˆ†δΊ«ζœεŠ‘οΌšcurl.bwg.leeguoo.com</p>
@@ -9175,7 +9175,7 @@ class NetworkDebugger {
9175
9175
  this.initialized = true;
9176
9176
  logger.consoleDirect(`
9177
9177
  ╔════════════════════════════════════════╗
9178
- β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v${"1.2.41"} β•‘
9178
+ β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v${"1.2.42"} β•‘
9179
9179
  β•‘ Created by Leo (@leeguoo) β•‘
9180
9180
  β•‘ ζŠ€ζœ―ζ”―ζŒ: 请联系 Leo β•‘
9181
9181
  β•‘ εˆ†δΊ«ζœεŠ‘: curl.bwg.leeguoo.com β•‘
@@ -9236,7 +9236,7 @@ class NetworkDebugger {
9236
9236
  }
9237
9237
  async checkForUpdates() {
9238
9238
  try {
9239
- const currentVersion = "1.2.41";
9239
+ const currentVersion = "1.2.42";
9240
9240
  logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
9241
9241
  const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
9242
9242
  const data = await response.json();
@@ -9256,11 +9256,11 @@ class NetworkDebugger {
9256
9256
  logger.error("[PWTK Update] Failed to check for updates:", error);
9257
9257
  return {
9258
9258
  hasUpdate: false,
9259
- currentVersion: "1.2.41"
9259
+ currentVersion: "1.2.42"
9260
9260
  };
9261
9261
  }
9262
9262
  }
9263
- async autoUpdate() {
9263
+ async autoUpdate(reloadPage = false) {
9264
9264
  try {
9265
9265
  const updateInfo = await this.checkForUpdates();
9266
9266
  if (!updateInfo.hasUpdate) {
@@ -9268,12 +9268,42 @@ class NetworkDebugger {
9268
9268
  return false;
9269
9269
  }
9270
9270
  logger.info(`[PWTK Update] Auto-updating to version ${updateInfo.latestVersion}...`);
9271
+ const currentConfig = { ...this.config };
9272
+ this.destroy();
9273
+ if (globalInstance === this) {
9274
+ globalInstance = null;
9275
+ if (typeof window !== "undefined") {
9276
+ delete window.NetworkDebugger;
9277
+ }
9278
+ }
9279
+ if (reloadPage) {
9280
+ logger.info("[PWTK Update] Reloading page to apply update...");
9281
+ window.location.reload();
9282
+ return true;
9283
+ }
9271
9284
  const script = document.createElement("script");
9272
9285
  script.src = `https://unpkg.com/@leeguoo/pwtk-network-debugger@${updateInfo.latestVersion}/dist/index.js`;
9273
9286
  return new Promise((resolve, reject) => {
9274
- script.onload = () => {
9275
- logger.info(`[PWTK Update] βœ… Successfully updated to version ${updateInfo.latestVersion}`);
9276
- resolve(true);
9287
+ script.onload = async () => {
9288
+ try {
9289
+ logger.info(`[PWTK Update] βœ… Script loaded, reinitializing with previous config...`);
9290
+ setTimeout(async () => {
9291
+ try {
9292
+ if (window.NetworkDebugger && window.NetworkDebugger.init) {
9293
+ await window.NetworkDebugger.init(currentConfig);
9294
+ logger.info(`[PWTK Update] βœ… Successfully updated to version ${updateInfo.latestVersion}`);
9295
+ resolve(true);
9296
+ } else {
9297
+ throw new Error("New version not properly loaded");
9298
+ }
9299
+ } catch (initError) {
9300
+ logger.error("[PWTK Update] ❌ Failed to initialize new version:", initError);
9301
+ reject(initError);
9302
+ }
9303
+ }, 100);
9304
+ } catch (error) {
9305
+ reject(error);
9306
+ }
9277
9307
  };
9278
9308
  script.onerror = () => {
9279
9309
  logger.error("[PWTK Update] ❌ Failed to load updated version");
@@ -9354,8 +9384,8 @@ const NetworkDebuggerGlobal = {
9354
9384
  async checkForUpdates() {
9355
9385
  return globalInstance?.checkForUpdates() || { hasUpdate: false, currentVersion: "unknown" };
9356
9386
  },
9357
- async autoUpdate() {
9358
- return globalInstance?.autoUpdate() || false;
9387
+ async autoUpdate(reloadPage = false) {
9388
+ return globalInstance?.autoUpdate(reloadPage) || false;
9359
9389
  }
9360
9390
  };
9361
9391
  if (typeof window !== "undefined") {