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

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
@@ -8165,7 +8165,30 @@ function formatAsCurl(requestData) {
8165
8165
  return curl;
8166
8166
  }
8167
8167
  function formatAsApiCurl(requestData) {
8168
- let curl = `curl 'https://api.httpmisonote.com'`;
8168
+ let baseUrl = "https://api.httpmisonote.com";
8169
+ const requestBody = requestData.decryptedRequest || requestData.requestBody;
8170
+ if (requestData.method === "GET" && requestBody) {
8171
+ try {
8172
+ let params = {};
8173
+ if (typeof requestBody === "string") {
8174
+ params = JSON.parse(requestBody);
8175
+ } else {
8176
+ params = requestBody;
8177
+ }
8178
+ const queryParams = new URLSearchParams();
8179
+ Object.entries(params).forEach(([key, value]) => {
8180
+ queryParams.append(key, String(value));
8181
+ });
8182
+ if (queryParams.toString()) {
8183
+ baseUrl += "?" + queryParams.toString();
8184
+ }
8185
+ } catch (error) {
8186
+ if (typeof requestBody === "string" && requestBody.trim()) {
8187
+ baseUrl += "?" + requestBody;
8188
+ }
8189
+ }
8190
+ }
8191
+ let curl = `curl '${baseUrl}'`;
8169
8192
  if (requestData.method !== "GET") {
8170
8193
  curl += ` -X ${requestData.method}`;
8171
8194
  }
@@ -8195,8 +8218,7 @@ function formatAsApiCurl(requestData) {
8195
8218
  });
8196
8219
  }
8197
8220
  curl += ` -H 'X-API-Key: test-api-key-123'`;
8198
- const requestBody = requestData.decryptedRequest || requestData.requestBody;
8199
- if (requestBody) {
8221
+ if (requestData.method !== "GET" && requestBody) {
8200
8222
  const body = typeof requestBody === "string" ? requestBody : JSON.stringify(requestBody);
8201
8223
  curl += ` --data '${body}'`;
8202
8224
  }
@@ -8286,7 +8308,7 @@ const _DebugPanel = class _DebugPanel {
8286
8308
  <div class="about-panel" data-panel="about" style="display: none;">
8287
8309
  <div style="padding: 20px; color: #fff; text-align: center;">
8288
8310
  <h2 style="margin: 0 0 20px 0;">πŸ”“ PWTK 解密小ε·₯ε…·</h2>
8289
- <p style="margin: 10px 0;">Version: ${"1.2.41"}</p>
8311
+ <p style="margin: 10px 0;">Version: ${"1.2.43"}</p>
8290
8312
  <p style="margin: 10px 0;">πŸ‘¨β€πŸ’» Created by <strong>Leo (@leeguoo)</strong></p>
8291
8313
  <p style="margin: 10px 0;">πŸ“§ ζŠ€ζœ―ζ”―ζŒοΌšθ―·θ”η³» Leo</p>
8292
8314
  <p style="margin: 10px 0;">🌐 εˆ†δΊ«ζœεŠ‘οΌšcurl.bwg.leeguoo.com</p>
@@ -9175,7 +9197,7 @@ class NetworkDebugger {
9175
9197
  this.initialized = true;
9176
9198
  logger.consoleDirect(`
9177
9199
  ╔════════════════════════════════════════╗
9178
- β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v${"1.2.41"} β•‘
9200
+ β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v${"1.2.43"} β•‘
9179
9201
  β•‘ Created by Leo (@leeguoo) β•‘
9180
9202
  β•‘ ζŠ€ζœ―ζ”―ζŒ: 请联系 Leo β•‘
9181
9203
  β•‘ εˆ†δΊ«ζœεŠ‘: curl.bwg.leeguoo.com β•‘
@@ -9236,7 +9258,7 @@ class NetworkDebugger {
9236
9258
  }
9237
9259
  async checkForUpdates() {
9238
9260
  try {
9239
- const currentVersion = "1.2.41";
9261
+ const currentVersion = "1.2.43";
9240
9262
  logger.info(`[PWTK Update] Checking for updates... Current version: ${currentVersion}`);
9241
9263
  const response = await fetch("https://registry.npmjs.org/@leeguoo/pwtk-network-debugger/latest");
9242
9264
  const data = await response.json();
@@ -9256,11 +9278,11 @@ class NetworkDebugger {
9256
9278
  logger.error("[PWTK Update] Failed to check for updates:", error);
9257
9279
  return {
9258
9280
  hasUpdate: false,
9259
- currentVersion: "1.2.41"
9281
+ currentVersion: "1.2.43"
9260
9282
  };
9261
9283
  }
9262
9284
  }
9263
- async autoUpdate() {
9285
+ async autoUpdate(reloadPage = false) {
9264
9286
  try {
9265
9287
  const updateInfo = await this.checkForUpdates();
9266
9288
  if (!updateInfo.hasUpdate) {
@@ -9268,12 +9290,42 @@ class NetworkDebugger {
9268
9290
  return false;
9269
9291
  }
9270
9292
  logger.info(`[PWTK Update] Auto-updating to version ${updateInfo.latestVersion}...`);
9293
+ const currentConfig = { ...this.config };
9294
+ this.destroy();
9295
+ if (globalInstance === this) {
9296
+ globalInstance = null;
9297
+ if (typeof window !== "undefined") {
9298
+ delete window.NetworkDebugger;
9299
+ }
9300
+ }
9301
+ if (reloadPage) {
9302
+ logger.info("[PWTK Update] Reloading page to apply update...");
9303
+ window.location.reload();
9304
+ return true;
9305
+ }
9271
9306
  const script = document.createElement("script");
9272
9307
  script.src = `https://unpkg.com/@leeguoo/pwtk-network-debugger@${updateInfo.latestVersion}/dist/index.js`;
9273
9308
  return new Promise((resolve, reject) => {
9274
- script.onload = () => {
9275
- logger.info(`[PWTK Update] βœ… Successfully updated to version ${updateInfo.latestVersion}`);
9276
- resolve(true);
9309
+ script.onload = async () => {
9310
+ try {
9311
+ logger.info(`[PWTK Update] βœ… Script loaded, reinitializing with previous config...`);
9312
+ setTimeout(async () => {
9313
+ try {
9314
+ if (window.NetworkDebugger && window.NetworkDebugger.init) {
9315
+ await window.NetworkDebugger.init(currentConfig);
9316
+ logger.info(`[PWTK Update] βœ… Successfully updated to version ${updateInfo.latestVersion}`);
9317
+ resolve(true);
9318
+ } else {
9319
+ throw new Error("New version not properly loaded");
9320
+ }
9321
+ } catch (initError) {
9322
+ logger.error("[PWTK Update] ❌ Failed to initialize new version:", initError);
9323
+ reject(initError);
9324
+ }
9325
+ }, 100);
9326
+ } catch (error) {
9327
+ reject(error);
9328
+ }
9277
9329
  };
9278
9330
  script.onerror = () => {
9279
9331
  logger.error("[PWTK Update] ❌ Failed to load updated version");
@@ -9354,8 +9406,8 @@ const NetworkDebuggerGlobal = {
9354
9406
  async checkForUpdates() {
9355
9407
  return globalInstance?.checkForUpdates() || { hasUpdate: false, currentVersion: "unknown" };
9356
9408
  },
9357
- async autoUpdate() {
9358
- return globalInstance?.autoUpdate() || false;
9409
+ async autoUpdate(reloadPage = false) {
9410
+ return globalInstance?.autoUpdate(reloadPage) || false;
9359
9411
  }
9360
9412
  };
9361
9413
  if (typeof window !== "undefined") {