@snack-kit/lib 0.6.0 → 0.7.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.
@@ -16036,24 +16036,21 @@ var SnackKit = (function (exports, crypto, url, http, https, http2, util2, zlib,
16036
16036
  /**
16037
16037
  * 初始化并渲染调试面板
16038
16038
  *
16039
+ * 支持两种调用形式:
16040
+ * - **配置对象**:传入 `DebuggerOptions`,可配置网关列表和超时时间
16041
+ * - **数组简写**:直接传入网关 URL 数组,等价于 `{ gateways: [...] }`
16042
+ *
16039
16043
  * 调用后在页面右下角插入浮动按钮,点击展开调试面板。
16040
16044
  * 面板支持:选择调试网关、切换目标服务、查看并复制路由 ctx。
16041
16045
  * 网关/服务选择通过 `localStorage` 持久化,刷新后自动恢复。
16042
16046
  *
16043
- * @param options 配置项
16047
+ * @param options 配置对象 或 网关 URL 数组
16044
16048
  *
16045
- * @example 单网关
16049
+ * @example 配置对象形式
16046
16050
  * ```ts
16047
16051
  * import { Debugger } from '@snack-kit/lib/debugger'
16048
16052
  *
16049
16053
  * await Debugger.init({
16050
- * gateways: 'http://dev-gateway.example.com',
16051
- * })
16052
- * ```
16053
- *
16054
- * @example 多网关(开发/测试环境切换)
16055
- * ```ts
16056
- * await Debugger.init({
16057
16054
  * gateways: [
16058
16055
  * 'http://dev-gateway.example.com',
16059
16056
  * 'http://test-gateway.example.com',
@@ -16062,17 +16059,26 @@ var SnackKit = (function (exports, crypto, url, http, https, http2, util2, zlib,
16062
16059
  * })
16063
16060
  * ```
16064
16061
  *
16062
+ * @example 数组简写形式
16063
+ * ```ts
16064
+ * await Debugger.init([
16065
+ * 'http://dev-gateway.example.com',
16066
+ * 'http://test-gateway.example.com',
16067
+ * ])
16068
+ * ```
16069
+ *
16065
16070
  * @example 仅在非生产环境加载
16066
16071
  * ```ts
16067
16072
  * if (import.meta.env.DEV) {
16068
16073
  * const { Debugger } = await import('@snack-kit/lib/debugger')
16069
- * await Debugger.init({ gateways: 'http://dev-gateway.example.com' })
16074
+ * await Debugger.init(['http://dev-gateway.example.com'])
16070
16075
  * }
16071
16076
  * ```
16072
16077
  */
16073
16078
  static async init(options) {
16074
16079
  globalThis[DEBUGGER_ACTIVE_KEY] = true;
16075
- const instance = new _Debugger({ timeout: 1e4, ...options });
16080
+ const normalized = Array.isArray(options) ? { gateways: options } : options;
16081
+ const instance = new _Debugger({ timeout: 1e4, ...normalized });
16076
16082
  instance.injectStyle();
16077
16083
  instance.buildDOM();
16078
16084
  await instance.restoreState();