@snack-kit/lib 0.5.0 → 0.6.0

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.
Files changed (37) hide show
  1. package/README.md +10 -0
  2. package/dist/cjs/{chunk-ZJMTV2GJ.cjs → chunk-HGUNPVKD.cjs} +23 -18
  3. package/dist/cjs/chunk-HGUNPVKD.cjs.map +1 -0
  4. package/dist/cjs/chunk-UM4J7HF4.cjs +123 -0
  5. package/dist/cjs/chunk-UM4J7HF4.cjs.map +1 -0
  6. package/dist/cjs/{chunk-XEQEQWDB.cjs → chunk-UNFUIZVY.cjs} +4 -109
  7. package/dist/cjs/chunk-UNFUIZVY.cjs.map +1 -0
  8. package/dist/cjs/debugger.cjs +4 -4
  9. package/dist/cjs/http.cjs +29 -29
  10. package/dist/cjs/index.cjs +35 -35
  11. package/dist/cjs/index.cjs.map +1 -1
  12. package/dist/es/chunk-2YYI2T2B.js +105 -0
  13. package/dist/es/chunk-2YYI2T2B.js.map +1 -0
  14. package/dist/es/{chunk-4SGFAIRT.js → chunk-FB42OGY3.js} +16 -15
  15. package/dist/es/chunk-FB42OGY3.js.map +1 -0
  16. package/dist/es/{chunk-YV6SGXUJ.js → chunk-M5R2NQYU.js} +6 -103
  17. package/dist/es/chunk-M5R2NQYU.js.map +1 -0
  18. package/dist/es/debugger.js +2 -2
  19. package/dist/es/http.js +2 -2
  20. package/dist/es/index.js +4 -4
  21. package/dist/es/index.js.map +1 -1
  22. package/dist/types/index.d.ts +1 -1
  23. package/dist/umd/debugger.global.js +32 -93
  24. package/dist/umd/debugger.global.js.map +1 -1
  25. package/dist/umd/http.global.js +2 -1
  26. package/dist/umd/http.global.js.map +1 -1
  27. package/dist/umd/index.global.js +15 -13
  28. package/dist/umd/index.global.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/cjs/chunk-IMHC6CTK.cjs +0 -13
  31. package/dist/cjs/chunk-IMHC6CTK.cjs.map +0 -1
  32. package/dist/cjs/chunk-XEQEQWDB.cjs.map +0 -1
  33. package/dist/cjs/chunk-ZJMTV2GJ.cjs.map +0 -1
  34. package/dist/es/chunk-4SGFAIRT.js.map +0 -1
  35. package/dist/es/chunk-MHCY2PIP.js +0 -3
  36. package/dist/es/chunk-MHCY2PIP.js.map +0 -1
  37. package/dist/es/chunk-YV6SGXUJ.js.map +0 -1
@@ -11625,7 +11625,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
11625
11625
  });
11626
11626
 
11627
11627
  // package.json
11628
- var version = "0.5.0";
11628
+ var version = "0.6.0";
11629
11629
 
11630
11630
  // node_modules/axios/lib/helpers/bind.js
11631
11631
  function bind(fn, thisArg) {
@@ -15376,6 +15376,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
15376
15376
  } = axios_default;
15377
15377
 
15378
15378
  // src/http/context.ts
15379
+ var _http = axios_default.create();
15379
15380
  var DEBUGGER_ACTIVE_KEY = "__snackkit_debugger__active";
15380
15381
  var HttpContext = class {
15381
15382
  constructor() {
@@ -15420,7 +15421,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
15420
15421
  }
15421
15422
  if (typeof source === "string") {
15422
15423
  const url2 = `${source}/ngw/context`;
15423
- const res = await axios_default.get(url2, { timeout });
15424
+ const res = await _http.get(url2, { timeout });
15424
15425
  const data = res.data;
15425
15426
  if (data && typeof data === "object") {
15426
15427
  this._store.clear();
@@ -15603,6 +15604,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
15603
15604
  }
15604
15605
 
15605
15606
  // src/debugger/debugger.ts
15607
+ var _http2 = axios_default.create();
15606
15608
  var STORAGE_PREFIX = "__snackkit_debugger__";
15607
15609
  var KEY_GATEWAY = `${STORAGE_PREFIX}gateway`;
15608
15610
  var KEY_TYPE = `${STORAGE_PREFIX}type`;
@@ -16323,19 +16325,19 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
16323
16325
  async loadServers(gwUrl) {
16324
16326
  this.setHeader("loading");
16325
16327
  this.setFooter(T.loading(), "");
16326
- const result = await Get(`${gwUrl}/web-debug/host/list`, {
16327
- cache: true,
16328
- timeout: this.options.timeout
16329
- });
16330
- if (result.error) {
16328
+ try {
16329
+ const res = await _http2.get(`${gwUrl}/web-debug/host/list`, {
16330
+ timeout: this.options.timeout
16331
+ });
16332
+ this.servers = res.data ?? [];
16333
+ this.renderTypeOptions();
16334
+ this.setHeader("ok");
16335
+ this.setFooter(T.loaded(this.servers.length), "ok");
16336
+ } catch (err) {
16337
+ const message = err instanceof Error ? err.message : String(err);
16331
16338
  this.setHeader("err");
16332
- this.setFooter(T.loadFailed(result.error.message), "err");
16333
- return;
16339
+ this.setFooter(T.loadFailed(message), "err");
16334
16340
  }
16335
- this.servers = result.data ?? [];
16336
- this.renderTypeOptions();
16337
- this.setHeader("ok");
16338
- this.setFooter(T.loaded(this.servers.length), "ok");
16339
16341
  }
16340
16342
  /** 渲染标签选项 */
16341
16343
  renderTypeOptions() {