@monkey2582/thinconsole 1.3.5 → 1.3.6
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/en.thinConsole.min.js +1 -1
- package/package.json +1 -1
- package/thinConsole.d.ts +182 -8
- package/thinConsole.min.js +1 -1
package/package.json
CHANGED
package/thinConsole.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for thinConsole v1.3.
|
|
1
|
+
// Type definitions for thinConsole v1.3.6
|
|
2
2
|
// Project: thinConsole - A lightweight mobile web debugging console
|
|
3
3
|
// UMD module: supports CommonJS, AMD, and global (browser window.thinConsole)
|
|
4
4
|
|
|
@@ -35,10 +35,49 @@ declare class thinConsole {
|
|
|
35
35
|
copyElementHTML(element: Element): void;
|
|
36
36
|
expandToElement(element: Node): void;
|
|
37
37
|
getShadowRoot(element: Element): thinConsole.ShadowRootInfo | null;
|
|
38
|
-
registerPlugin(id: string, pluginClass: any
|
|
38
|
+
registerPlugin(id: string, pluginClass: any): thinConsole;
|
|
39
39
|
disablePlugin(id: string): thinConsole;
|
|
40
40
|
enablePlugin(id: string): thinConsole;
|
|
41
41
|
destroyPlugin(id: string): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Override existing icons or add new ones.
|
|
45
|
+
* Icons are shared globally — overrides affect all panels.
|
|
46
|
+
*
|
|
47
|
+
* @param icons Object mapping icon names to "viewBox|path.d" strings
|
|
48
|
+
* @throws Error if `icons` is not an object, or any value doesn't contain "|"
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* tC.applyIcon({
|
|
52
|
+
* "my-icon": "0 0 24 24|M10 2L4 8",
|
|
53
|
+
* "info-circle": "0 0 512 512|..." // override existing
|
|
54
|
+
* })
|
|
55
|
+
*/
|
|
56
|
+
applyIcon(icons: Record<string, string>): void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set the icon for a filter button by its filter ID.
|
|
60
|
+
* The icon name must already exist in the icon map
|
|
61
|
+
* (use `applyIcon` to add new icons first).
|
|
62
|
+
*
|
|
63
|
+
* @param filterId The filter button's id (data-type, data-ls-type, data-orig, or data-net-filter)
|
|
64
|
+
* @param iconName An existing icon name from the icon map
|
|
65
|
+
* @returns true if the filter was found and updated, false otherwise
|
|
66
|
+
* @throws Error if the icon name doesn't exist
|
|
67
|
+
*/
|
|
68
|
+
setFilterIcon(filterId: string, iconName: string): boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create a sandboxed proxy of the thinConsole instance.
|
|
72
|
+
* Blocks get/set/delete on `options` and `pluginOption` properties.
|
|
73
|
+
* All other methods are available with proper `this` binding.
|
|
74
|
+
* Used internally when instantiating plugins.
|
|
75
|
+
* @param tC The real thinConsole instance
|
|
76
|
+
* @returns Sandboxed proxy
|
|
77
|
+
*/
|
|
78
|
+
createSandbox(tC: thinConsole): thinConsole.Sandbox;
|
|
79
|
+
|
|
80
|
+
|
|
42
81
|
triggerGlobalHook(name: thinConsole.HookName, ...args: any[]): thinConsole;
|
|
43
82
|
renderJSONTree(
|
|
44
83
|
obj: any,
|
|
@@ -80,6 +119,107 @@ declare class thinConsole {
|
|
|
80
119
|
isPlugin: boolean
|
|
81
120
|
): void;
|
|
82
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Apply custom CSS inside the Shadow DOM scope.
|
|
124
|
+
* Plugin authors use this to add styles that won't leak to the host page
|
|
125
|
+
* and won't be affected by host page styles.
|
|
126
|
+
* @param css CSS string to inject into the shadow root
|
|
127
|
+
* @returns The created <style> element (can be removed later if needed)
|
|
128
|
+
*/
|
|
129
|
+
applyCSS(css: string): HTMLStyleElement;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Create a virtual scrolling list for efficient rendering of large datasets.
|
|
133
|
+
* Only visible items (plus a small buffer) are rendered in the DOM.
|
|
134
|
+
* Internally uses vsInit + vsUpdate + vsRender for the same smooth scrolling
|
|
135
|
+
* experience as the built-in console, localStorage, and network panels.
|
|
136
|
+
*
|
|
137
|
+
* @param container The scrollable container element (plugin's own container)
|
|
138
|
+
* @param options Configuration object
|
|
139
|
+
* @param options.renderItem Function that creates a DOM element (or HTML string) for a data item
|
|
140
|
+
* @param options.initialData Initial array of data items (default: [])
|
|
141
|
+
* @param options.itemHeight Estimated item height in px (auto-measured if omitted)
|
|
142
|
+
* @param options.emptyHTML HTML to show when items array is empty (default: "")
|
|
143
|
+
* @param options.trackBy Key extraction function for precise item identity comparison
|
|
144
|
+
* (default: item => item.id). Avoids unnecessary full re-renders when data
|
|
145
|
+
* changes only partially.
|
|
146
|
+
* @returns Virtual list controller with update/render/destroy methods
|
|
147
|
+
*/
|
|
148
|
+
createVirtualList(
|
|
149
|
+
container: HTMLElement,
|
|
150
|
+
options: {
|
|
151
|
+
renderItem: (item: any) => HTMLElement | string;
|
|
152
|
+
initialData?: any[];
|
|
153
|
+
itemHeight?: number;
|
|
154
|
+
emptyHTML?: string;
|
|
155
|
+
trackBy?: (item: any) => string | number;
|
|
156
|
+
}
|
|
157
|
+
): {
|
|
158
|
+
/** Update items (and optionally change renderFn). Empty items shows emptyHTML. */
|
|
159
|
+
update(items: any[], renderFn?: (item: any) => HTMLElement | string): void;
|
|
160
|
+
/** Force re-render (e.g. after tree expand/collapse or resize) */
|
|
161
|
+
render(): void;
|
|
162
|
+
/** Cleanup: remove scroll listener, delete _vs state, prevent memory leaks */
|
|
163
|
+
destroy(): void;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Initialize virtual scrolling infrastructure for a container.
|
|
168
|
+
* Creates spacer elements, content element, and scroll listener.
|
|
169
|
+
* Merges isNearBottom logic as an inline internal check.
|
|
170
|
+
* @param container The container element to apply virtual scrolling to
|
|
171
|
+
*/
|
|
172
|
+
vsInit(container: HTMLElement): void;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Core render loop for a virtual scroll container.
|
|
176
|
+
* Calculates visible range, measures heights, renders items, updates spacers.
|
|
177
|
+
* Merges vsRefreshHeights: re-measures rendered children on each call,
|
|
178
|
+
* and updates spacers even when visible range is unchanged.
|
|
179
|
+
* @param container The virtual scroll container
|
|
180
|
+
*/
|
|
181
|
+
vsRender(container: HTMLElement): void;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Unified update entry for virtual scroll containers.
|
|
185
|
+
* Merges vsSetItems + vsUpdateItems + vsShowMessage into one function.
|
|
186
|
+
*
|
|
187
|
+
* - If items is empty: shows emptyHTML (from opts), resets state.
|
|
188
|
+
* - If opts.force: full reset (scroll to top, re-render).
|
|
189
|
+
* - If user is at bottom: re-render and auto-scroll to bottom.
|
|
190
|
+
* - If items grew (same first item key): incremental bottom spacer update.
|
|
191
|
+
* - Otherwise: full re-render preserving scroll position.
|
|
192
|
+
*
|
|
193
|
+
* @param container The virtual scroll container
|
|
194
|
+
* @param items The array of items to display
|
|
195
|
+
* @param renderItem Function to render an item as HTML string (null when items is empty)
|
|
196
|
+
* @param avgHeight Average item height (optional)
|
|
197
|
+
* @param opts Options: { force?, emptyHTML?, trackBy?, preserveScroll? }
|
|
198
|
+
*/
|
|
199
|
+
vsUpdate(
|
|
200
|
+
container: HTMLElement,
|
|
201
|
+
items: any[],
|
|
202
|
+
renderItem: ((item: any, index: number) => string) | null,
|
|
203
|
+
avgHeight?: number,
|
|
204
|
+
opts?: {
|
|
205
|
+
/** Force full reset (scroll to top, re-render) */
|
|
206
|
+
force?: boolean;
|
|
207
|
+
/** HTML to show when items array is empty */
|
|
208
|
+
emptyHTML?: string;
|
|
209
|
+
/** Key extraction function for item identity (default: item => item.id).
|
|
210
|
+
* Stored in _vs after first call; used to detect if first item changed. */
|
|
211
|
+
trackBy?: (item: any) => string | number;
|
|
212
|
+
/** Preserve current scroll position (don't scroll to top or bottom).
|
|
213
|
+
* Useful when loading more data or inserting items at the top. */
|
|
214
|
+
preserveScroll?: boolean;
|
|
215
|
+
}
|
|
216
|
+
): void;
|
|
217
|
+
|
|
218
|
+
/** Shadow DOM host element (style isolation root) */
|
|
219
|
+
host: HTMLDivElement;
|
|
220
|
+
/** Shadow root for style isolation */
|
|
221
|
+
shadowRoot: ShadowRoot;
|
|
222
|
+
|
|
83
223
|
// ---- Static properties ----
|
|
84
224
|
static readonly version: string;
|
|
85
225
|
static tC: thinConsole | null;
|
|
@@ -94,7 +234,7 @@ declare class thinConsole {
|
|
|
94
234
|
static info(...args: any[]): typeof thinConsole;
|
|
95
235
|
static warn(...args: any[]): typeof thinConsole;
|
|
96
236
|
static error(...args: any[]): typeof thinConsole;
|
|
97
|
-
static addPlugin(id: string, pluginClass: any
|
|
237
|
+
static addPlugin(id: string, pluginClass: any): typeof thinConsole;
|
|
98
238
|
static addTabs(
|
|
99
239
|
tabs: thinConsole.TabConfig | thinConsole.TabConfig[]
|
|
100
240
|
): typeof thinConsole;
|
|
@@ -139,6 +279,12 @@ declare namespace thinConsole {
|
|
|
139
279
|
maxNetwork?: number;
|
|
140
280
|
/** Custom console filter definitions */
|
|
141
281
|
filters?: Filter[];
|
|
282
|
+
/**
|
|
283
|
+
* Per-plugin options, keyed by plugin ID.
|
|
284
|
+
* Values are passed through as-is (only object check).
|
|
285
|
+
* Plugins can access their options via `this.tC.options.pluginOption[this.id]`.
|
|
286
|
+
*/
|
|
287
|
+
pluginOption?: Record<string, Record<string, any>>;
|
|
142
288
|
}
|
|
143
289
|
|
|
144
290
|
interface Filter {
|
|
@@ -237,14 +383,28 @@ declare namespace thinConsole {
|
|
|
237
383
|
|
|
238
384
|
type HookCallback = (...args: any[]) => void;
|
|
239
385
|
|
|
386
|
+
// ============= Virtual List =============
|
|
387
|
+
|
|
240
388
|
// ============= Plugin Base Class =============
|
|
241
389
|
|
|
242
390
|
class tCPlugin {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
391
|
+
/**
|
|
392
|
+
* @param tC A sandboxed thinConsole instance. The sandbox blocks
|
|
393
|
+
* access to `options` and `pluginOption` on tC, preventing plugins
|
|
394
|
+
* from reading or modifying global configuration. Plugins should
|
|
395
|
+
* use `this.pluginOption` for their own config instead.
|
|
396
|
+
*/
|
|
397
|
+
constructor(tC: thinConsole.Sandbox);
|
|
398
|
+
/** Sandboxed thinConsole instance (options/pluginOption blocked) */
|
|
399
|
+
tC: thinConsole.Sandbox;
|
|
400
|
+
/**
|
|
401
|
+
* This plugin's isolated config from options.pluginOption[pluginId].
|
|
402
|
+
* Set automatically before init() is called.
|
|
403
|
+
* Must be an object — non-object values are replaced with {}.
|
|
404
|
+
* Mutable: plugins can freely read and modify their own config.
|
|
405
|
+
* Default: {} if not configured or not an object.
|
|
406
|
+
*/
|
|
407
|
+
pluginOption: Record<string, any>;
|
|
248
408
|
/** Plugin ID (auto-derived from class name, lowercased) */
|
|
249
409
|
id: string;
|
|
250
410
|
/** Initialize plugin — override in subclass */
|
|
@@ -266,6 +426,20 @@ declare namespace thinConsole {
|
|
|
266
426
|
/** Define a tab for this plugin — override in subclass */
|
|
267
427
|
addTab?(): PluginTab;
|
|
268
428
|
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Sandboxed thinConsole proxy. Blocks access to `options` and
|
|
432
|
+
* `pluginOption` properties. All other methods work normally with
|
|
433
|
+
* proper `this` binding. Attempts to set/delete `options` or
|
|
434
|
+
* `pluginOption` are silently blocked; other property writes
|
|
435
|
+
* trigger a console warning.
|
|
436
|
+
*/
|
|
437
|
+
interface Sandbox {
|
|
438
|
+
/** Marker: always true — check if a tC reference is sandboxed */
|
|
439
|
+
__isSandbox: true;
|
|
440
|
+
// All thinConsole instance methods are available except options/pluginOption
|
|
441
|
+
[key: string]: any;
|
|
442
|
+
}
|
|
269
443
|
}
|
|
270
444
|
|
|
271
445
|
export = thinConsole;
|