@monkey2582/thinconsole 1.3.3 → 1.3.4

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.4",
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.4
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,17 @@ 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
+
58
71
  // ---- Static properties ----
59
72
  static readonly version: string;
60
73
  static tC: thinConsole | null;
@@ -81,7 +94,9 @@ declare class thinConsole {
81
94
  name: thinConsole.HookName,
82
95
  callback: thinConsole.HookCallback
83
96
  ): typeof thinConsole;
84
- static setFilterCounts(counts: Record<string, number>): typeof thinConsole;
97
+ static setFilterCounts(
98
+ counts: Record<string, number | thinConsole.FilterCountResult>
99
+ ): typeof thinConsole;
85
100
  }
86
101
 
87
102
  declare namespace thinConsole {
@@ -108,6 +123,8 @@ declare namespace thinConsole {
108
123
  pos?: { x: number; y: number };
109
124
  /** Maximum number of log entries to retain (default: 1000) */
110
125
  maxLog?: number;
126
+ /** Maximum number of network requests to retain (default: 1000) */
127
+ maxNetwork?: number;
111
128
  /** Custom console filter definitions */
112
129
  filters?: Filter[];
113
130
  }
@@ -171,6 +188,25 @@ declare namespace thinConsole {
171
188
  mode: "open" | "closed";
172
189
  }
173
190
 
191
+ // ============= Filter Count =============
192
+
193
+ /**
194
+ * Result of count formatting. Used by filter buttons to display
195
+ * a compact count in parentheses and the exact value on hover.
196
+ *
197
+ * - `filterCount`: displayed inside () on active filters
198
+ * (string like "1K" / "1K+" / "100K+", or the raw number if <= 999)
199
+ * - `exactCount`: shown in the title (tooltip) on hover
200
+ *
201
+ * For built-in tabs (console, network, storage) this is auto-generated
202
+ * by `_fmtCount()`. For extension/plugin tabs, developers can pass
203
+ * custom objects via `setFilterCounts()` to control both values.
204
+ */
205
+ interface FilterCountResult {
206
+ filterCount: string | number;
207
+ exactCount: number;
208
+ }
209
+
174
210
  // ============= Hooks =============
175
211
 
176
212
  type HookName =