@monkey2582/thinconsole 1.3.3 → 1.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkey2582/thinconsole",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "thinConsole是一个轻量级、功能丰富的浏览器端 JavaScript 控制台增强库。它提供了一个可浮动的按钮,点击后可以展开一个功能强大的控制台面板,用于捕获和查看日志、管理本地存储(LocalStorage)、记录系统事件,并支持通过插件系统进行扩展。",
5
5
  "keywords": [
6
6
  "console",
package/thinConsole.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for thinConsole v1.3.0
1
+ // Type definitions for thinConsole v1.3.5
2
2
  // Project: thinConsole - A lightweight mobile web debugging console
3
3
  // UMD module: supports CommonJS, AMD, and global (browser window.thinConsole)
4
4
 
@@ -18,6 +18,8 @@ declare class thinConsole {
18
18
  logs: thinConsole.LogEntry[];
19
19
  networkRequests: thinConsole.NetworkRequest[];
20
20
  maxLog: number;
21
+ /** Maximum number of network requests to retain (default: 1000) */
22
+ maxNetwork: number;
21
23
 
22
24
  // ---- Instance methods ----
23
25
  show(tab?: string): thinConsole;
@@ -55,6 +57,29 @@ declare class thinConsole {
55
57
  escapeHtml(str: string): string;
56
58
  captureConsole(type: string, ...args: any[]): void;
57
59
 
60
+ /**
61
+ * Format a count number into compact display.
62
+ * - <= 999: returns the number as-is
63
+ * - 1000-99999: returns K format with 1 decimal (e.g. "1K", "1.1K")
64
+ * - >= 100000: returns "XK+" (e.g. "100K+")
65
+ * @param n The exact count
66
+ * @param plusK If true, append "+" for K values (used by network/storage)
67
+ * @returns Object with filterCount (display string/number) and exactCount (raw number)
68
+ */
69
+ _fmtCount(n: number, plusK?: boolean): thinConsole.FilterCountResult;
70
+
71
+ /**
72
+ * Unified filter count updater for both built-in (console) and plugin tabs.
73
+ * @param container Filter button container (filterButtons or plugin view container)
74
+ * @param counts Count lookup object (type -> number | FilterCountResult)
75
+ * @param isPlugin If true, use plugin rendering (icon + orig); else console (cached HTML)
76
+ */
77
+ _updateFilterCounts(
78
+ container: HTMLElement | NodeListOf<Element> | null,
79
+ counts: Record<string, number | thinConsole.FilterCountResult> | null,
80
+ isPlugin: boolean
81
+ ): void;
82
+
58
83
  // ---- Static properties ----
59
84
  static readonly version: string;
60
85
  static tC: thinConsole | null;
@@ -81,7 +106,9 @@ declare class thinConsole {
81
106
  name: thinConsole.HookName,
82
107
  callback: thinConsole.HookCallback
83
108
  ): typeof thinConsole;
84
- static setFilterCounts(counts: Record<string, number>): typeof thinConsole;
109
+ static setFilterCounts(
110
+ counts: Record<string, number | thinConsole.FilterCountResult>
111
+ ): typeof thinConsole;
85
112
  }
86
113
 
87
114
  declare namespace thinConsole {
@@ -108,6 +135,8 @@ declare namespace thinConsole {
108
135
  pos?: { x: number; y: number };
109
136
  /** Maximum number of log entries to retain (default: 1000) */
110
137
  maxLog?: number;
138
+ /** Maximum number of network requests to retain (default: 1000) */
139
+ maxNetwork?: number;
111
140
  /** Custom console filter definitions */
112
141
  filters?: Filter[];
113
142
  }
@@ -171,6 +200,25 @@ declare namespace thinConsole {
171
200
  mode: "open" | "closed";
172
201
  }
173
202
 
203
+ // ============= Filter Count =============
204
+
205
+ /**
206
+ * Result of count formatting. Used by filter buttons to display
207
+ * a compact count in parentheses and the exact value on hover.
208
+ *
209
+ * - `filterCount`: displayed inside () on active filters
210
+ * (string like "1K" / "1K+" / "100K+", or the raw number if <= 999)
211
+ * - `exactCount`: shown in the title (tooltip) on hover
212
+ *
213
+ * For built-in tabs (console, network, storage) this is auto-generated
214
+ * by `_fmtCount()`. For extension/plugin tabs, developers can pass
215
+ * custom objects via `setFilterCounts()` to control both values.
216
+ */
217
+ interface FilterCountResult {
218
+ filterCount: string | number;
219
+ exactCount: number;
220
+ }
221
+
174
222
  // ============= Hooks =============
175
223
 
176
224
  type HookName =