UNPKG

43.3 kBTypeScriptView Raw
1/// <reference path="../build/vendor.d.ts" />
2
3declare module "core/options.interface" {
4 export interface VConsoleLogOptions {
5 maxLogNumber?: number;
6 showTimestamps?: boolean;
7 }
8 export interface VConsoleNetworkOptions {
9 maxNetworkNumber?: number;
10 ignoreUrlRegExp?: RegExp;
11 }
12 export type VConsoleAvailableStorage = 'cookies' | 'localStorage' | 'sessionStorage' | 'wxStorage';
13 export interface VConsoleStorageOptions {
14 defaultStorages?: VConsoleAvailableStorage[];
15 }
16 export interface VConsoleOptions {
17 target?: string | HTMLElement;
18 defaultPlugins?: ('system' | 'network' | 'element' | 'storage')[];
19 theme?: '' | 'dark' | 'light';
20 disableLogScrolling?: boolean;
21 pluginOrder?: string[];
22 onReady?: () => void;
23 log?: VConsoleLogOptions;
24 network?: VConsoleNetworkOptions;
25 storage?: VConsoleStorageOptions;
26 /**
27 * @deprecated Since v3.12.0, use `log.maxLogNumber`.
28 */
29 maxLogNumber?: number;
30 /**
31 * @deprecated Since v3.12.0, use `network.maxNetworkNumber`.
32 */
33 maxNetworkNumber?: number;
34 /**
35 * @deprecated Since v3.12.0.
36 */
37 onClearLog?: () => void;
38 }
39}
40declare module "lib/tool" {
41 /**
42 * Utility Functions
43 */
44 /**
45 * get formatted date by timestamp
46 */
47 export function getDate(time: number): {
48 time: number;
49 year: number;
50 month: string | number;
51 day: string | number;
52 hour: string | number;
53 minute: string | number;
54 second: string | number;
55 millisecond: string | number;
56 };
57 /**
58 * Determine whether a value is of a specific type.
59 */
60 export function isNumber(value: any): boolean;
61 export function isBigInt(value: any): boolean;
62 export function isString(value: any): boolean;
63 export function isArray(value: any): boolean;
64 export function isBoolean(value: any): boolean;
65 export function isUndefined(value: any): boolean;
66 export function isNull(value: any): boolean;
67 export function isSymbol(value: any): boolean;
68 export function isObject(value: any): boolean;
69 export function isFunction(value: any): boolean;
70 export function isElement(value: any): boolean;
71 export function isWindow(value: any): boolean;
72 export function isIterable(value: any): boolean;
73 /**
74 * Get the prototype name of an object
75 */
76 export function getPrototypeName(value: any): string;
77 /**
78 * Get an object's constructor name.
79 */
80 export function getObjName(obj: any): string;
81 /**
82 * check whether an object is plain (using {})
83 * @param object obj
84 * @return boolean
85 */
86 export function isPlainObject(obj: any): boolean;
87 /**
88 * Escape HTML to XSS-safe text.
89 */
90 export function htmlEncode(text: string | number): string;
91 /**
92 * Convert a text's invisible characters to visible characters.
93 */
94 export function getVisibleText(text: string): string;
95 /**
96 * A safe `JSON.stringify` method.
97 */
98 export function safeJSONStringify(obj: any, opt?: {
99 maxDepth?: number;
100 keyMaxLen?: number;
101 pretty?: boolean;
102 standardJSON?: boolean;
103 }): string;
104 /**
105 * Call original `JSON.stringify` and catch unknown exceptions.
106 */
107 export function JSONStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
108 /**
109 * Get the bytes of a string.
110 * @example 'a' = 1
111 * @example '好' = 3
112 */
113 export function getStringBytes(str: string): number;
114 /**
115 * Convert bytes number to 'MB' or 'KB' string.
116 */
117 export function getBytesText(bytes: number): string;
118 /**
119 * Get a string within a limited max length.
120 * The byte size of the string will be appended to the string when reached the limit.
121 * @return 'some string...(3.1 MB)'
122 */
123 export function getStringWithinLength(str: string, maxLen: number): string;
124 /**
125 * Sore an `string[]` by string.
126 */
127 export function sortArray(arr: string[]): string[];
128 /**
129 * Get enumerable keys of an object or array.
130 */
131 export function getEnumerableKeys(obj: any): string[];
132 /**
133 * Get enumerable and non-enumerable keys of an object or array.
134 */
135 export function getEnumerableAndNonEnumerableKeys(obj: any): string[];
136 /**
137 * Get non-enumerable keys of an object or array.
138 */
139 export function getNonEnumerableKeys(obj: any): string[];
140 export function getSymbolKeys(obj: any): symbol[];
141 /**
142 * localStorage methods
143 */
144 export function setStorage(key: string, value: string): void;
145 export function getStorage(key: string): string;
146 /**
147 * Generate a 6-digit unique string with prefix `"__vc_" + ${prefix}`
148 */
149 export function getUniqueID(prefix?: string): string;
150 /**
151 * Determine whether it is inside a WeChat Miniprogram.
152 */
153 export function isWxEnv(): boolean;
154 /**
155 * Call a WeChat Miniprogram method. E.g: `wx.getStorageSync()`.
156 */
157 export function callWx(method: string, ...args: any[]): any;
158}
159declare module "lib/query" {
160 const $: {
161 /**
162 * get single element
163 * @public
164 */
165 one: (selector: string, contextElement?: Element | Document) => HTMLElement;
166 /**
167 * get multiple elements
168 * @public
169 */
170 all: (selector: string, contextElement?: Element | Document) => HTMLElement[];
171 /**
172 * add className(s) to an or multiple element(s)
173 * @public
174 */
175 addClass: ($el: Element | Element[], className: string) => void;
176 /**
177 * remove className(s) from an or multiple element(s)
178 * @public
179 */
180 removeClass: ($el: Element | Element[], className: string) => void;
181 /**
182 * see whether an element contains a className
183 * @public
184 */
185 hasClass: ($el: Element, className: string) => boolean;
186 /**
187 * bind an event to element(s)
188 * @public
189 */
190 bind: ($el: Element | Element[], eventType: any, fn: any, useCapture?: boolean) => void;
191 /**
192 * delegate an event to a parent element
193 * @public
194 * @param $el parent element
195 * @param eventType name of the event
196 * @param selector target's selector
197 * @param fn callback function
198 */
199 delegate: ($el: Element, eventType: string, selector: string, fn: (event: Event, $target: HTMLElement) => void) => void;
200 /**
201 * Remove all child elements of an element.
202 */
203 removeChildren($el: Element): Element;
204 };
205 /**
206 * export
207 */
208 export default $;
209}
210declare module "lib/model" {
211 type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T;
212 export class VConsoleModel {
213 static singleton: {
214 [ctorName: string]: VConsoleModel;
215 };
216 protected _onDataUpdateCallbacks: Function[];
217 /**
218 * Get a singleton of a model.
219 */
220 static getSingleton<T extends VConsoleModel>(ctor: AConstructorTypeOf<T>, ctorName: string): T;
221 }
222 export default VConsoleModel;
223}
224declare module "lib/pluginExporter" {
225 import type { VConsoleModel } from "lib/model";
226 export class VConsolePluginExporter {
227 protected model: VConsoleModel;
228 protected pluginId: string;
229 constructor(pluginId: string);
230 destroy(): void;
231 }
232}
233declare module "lib/plugin" {
234 import { VConsolePluginExporter } from "lib/pluginExporter";
235 import type { VConsole } from "core/core";
236 export type IVConsolePluginEvent = (data?: any) => void;
237 export type IVConsolePluginEventName = 'init' | 'renderTab' | 'addTopBar' | 'addTool' | 'ready' | 'remove' | 'updateOption' | 'showConsole' | 'hideConsole' | 'show' | 'hide';
238 export interface IVConsoleTopbarOptions {
239 name: string;
240 className: string;
241 actived?: boolean;
242 data?: {
243 [key: string]: string;
244 };
245 onClick?: (e: Event, data?: any) => any;
246 }
247 export interface IVConsoleToolbarOptions {
248 name: string;
249 global?: boolean;
250 data?: {
251 [key: string]: string;
252 };
253 onClick?: (e: Event, data?: any) => any;
254 }
255 export interface IVConsoleTabOptions {
256 fixedHeight?: boolean;
257 }
258 /**
259 * vConsole Plugin Base Class
260 */
261 export class VConsolePlugin {
262 isReady: boolean;
263 eventMap: Map<IVConsolePluginEventName, IVConsolePluginEvent>;
264 exporter?: VConsolePluginExporter;
265 protected _id: string;
266 protected _name: string;
267 protected _vConsole: VConsole;
268 constructor(...args: any[]);
269 get id(): string;
270 set id(value: string);
271 get name(): string;
272 set name(value: string);
273 get vConsole(): VConsole;
274 set vConsole(value: VConsole);
275 /**
276 * Register an event
277 * @public
278 * @param IVConsolePluginEventName
279 * @param IVConsolePluginEvent
280 */
281 on(eventName: IVConsolePluginEventName, callback: IVConsolePluginEvent): this;
282 onRemove(): void;
283 /**
284 * Trigger an event.
285 */
286 trigger(eventName: IVConsolePluginEventName, data?: any): this;
287 protected bindExporter(): void;
288 protected unbindExporter(): void;
289 protected getUniqueID(prefix?: string): string;
290 }
291 export default VConsolePlugin;
292}
293declare module "lib/sveltePlugin" {
294 import VConsolePlugin from "lib/plugin";
295 import { SvelteComponent } from "vendor/svelte";
296 export class VConsoleSveltePlugin<T extends {} = {}> extends VConsolePlugin {
297 CompClass: typeof SvelteComponent;
298 compInstance?: SvelteComponent;
299 initialProps: T;
300 constructor(id: string, name: string, CompClass: typeof SvelteComponent, initialProps: T);
301 onReady(): void;
302 onRenderTab(callback: any): void;
303 onRemove(): void;
304 }
305}
306declare module "core/core.model" {
307 export const contentStore: {
308 subscribe: (this: void, run: import("vendor/svelte/store").Subscriber<{
309 updateTime: number;
310 }>, invalidate?: (value?: {
311 updateTime: number;
312 }) => void) => import("vendor/svelte/store").Unsubscriber;
313 set: (this: void, value: {
314 updateTime: number;
315 }) => void;
316 update: (this: void, updater: import("vendor/svelte/store").Updater<{
317 updateTime: number;
318 }>) => void;
319 updateTime: () => void;
320 };
321}
322declare module "log/logTool" {
323 import type { IVConsoleLog, IVConsoleLogData } from "log/log.model";
324 /**
325 * Get a value's text content and its type.
326 */
327 export const getValueTextAndType: (val: any, wrapString?: boolean) => {
328 text: any;
329 valueType: string;
330 };
331 /**
332 * A simple parser to get `[` or `]` information.
333 */
334 export const getLastIdentifier: (text: string) => {
335 front: {
336 text: string;
337 pos: number;
338 before: string;
339 after: string;
340 };
341 back: {
342 text: string;
343 pos: number;
344 before: string;
345 after: string;
346 };
347 };
348 export const isMatchedFilterText: (log: IVConsoleLog, filterText: string) => boolean;
349 /**
350 * Styling log output (`%c`), or string substitutions (`%s`, `%d`, `%o`).
351 * Apply to the first log only.
352 */
353 export const getLogDatasWithFormatting: (origDatas: any[]) => IVConsoleLogData[];
354 /**
355 * An empty class for rendering views.
356 */
357 export class VConsoleUninvocatableObject {
358 }
359}
360declare module "log/log.store" {
361 import type { Writable } from "vendor/svelte/store";
362 import type { IVConsoleLog } from "log/log.model";
363 export interface IVConsoleLogStore {
364 logList: IVConsoleLog[];
365 }
366 /**
367 * Log Store Factory
368 */
369 export class VConsoleLogStore {
370 static storeMap: {
371 [pluginId: string]: Writable<IVConsoleLogStore>;
372 };
373 /**
374 * Create a store.
375 */
376 static create(pluginId: string): Writable<IVConsoleLogStore>;
377 /**
378 * Delete a store.
379 */
380 static delete(pluginId: string): void;
381 /**
382 * Get a store by pluginId,
383 */
384 static get(pluginId: string): Writable<IVConsoleLogStore>;
385 /**
386 * Get a store's raw data.
387 */
388 static getRaw(pluginId: string): IVConsoleLogStore;
389 /**
390 * Get all stores.
391 */
392 static getAll(): {
393 [pluginId: string]: Writable<IVConsoleLogStore>;
394 };
395 }
396}
397declare module "log/log.model" {
398 import { VConsoleModel } from "lib/model";
399 /**********************************
400 * Interfaces
401 **********************************/
402 export type IConsoleLogMethod = 'log' | 'info' | 'debug' | 'warn' | 'error';
403 export interface IVConsoleLogData {
404 origData: any;
405 style?: string;
406 }
407 export interface IVConsoleLog {
408 _id: string;
409 type: IConsoleLogMethod;
410 cmdType?: 'input' | 'output';
411 repeated: number;
412 toggle: Record<string, boolean>;
413 date: number;
414 data: IVConsoleLogData[];
415 groupLevel: number;
416 groupLabel?: symbol;
417 groupHeader?: 0 | 1 | 2;
418 groupCollapsed?: boolean;
419 }
420 export type IVConsoleLogListMap = {
421 [pluginId: string]: IVConsoleLog[];
422 };
423 export type IVConsoleLogFilter = {
424 [pluginId: string]: string;
425 };
426 export interface IVConsoleAddLogOptions {
427 noOrig?: boolean;
428 cmdType?: 'input' | 'output';
429 }
430 /**********************************
431 * Model
432 **********************************/
433 export class VConsoleLogModel extends VConsoleModel {
434 readonly LOG_METHODS: IConsoleLogMethod[];
435 ADDED_LOG_PLUGIN_ID: string[];
436 maxLogNumber: number;
437 protected logCounter: number;
438 protected groupLevel: number;
439 protected groupLabelCollapsedStack: {
440 label: symbol;
441 collapsed: boolean;
442 }[];
443 protected pluginPattern: RegExp;
444 protected logQueue: IVConsoleLog[];
445 protected flushLogScheduled: boolean;
446 /**
447 * The original `window.console` methods.
448 */
449 origConsole: {
450 [method: string]: Function;
451 };
452 /**
453 * Bind a Log plugin.
454 * When binding first plugin, `window.console` will be hooked.
455 */
456 bindPlugin(pluginId: string): boolean;
457 /**
458 * Unbind a Log plugin.
459 * When no binded plugin exists, hooked `window.console` will be recovered.
460 */
461 unbindPlugin(pluginId: string): boolean;
462 /**
463 * Hook `window.console` with vConsole log method.
464 * Methods will be hooked only once.
465 */
466 mockConsole(): void;
467 protected _mockConsoleLog(): void;
468 protected _mockConsoleTime(): void;
469 protected _mockConsoleGroup(): void;
470 protected _mockConsoleClear(): void;
471 /**
472 * Recover `window.console`.
473 */
474 unmockConsole(): void;
475 /**
476 * Call origin `window.console[method](...args)`
477 */
478 callOriginalConsole(method: string, ...args: any[]): void;
479 /**
480 * Reset groups by `console.group()`.
481 */
482 resetGroup(): void;
483 /**
484 * Remove all logs.
485 */
486 clearLog(): void;
487 /**
488 * Remove a plugin's logs.
489 */
490 clearPluginLog(pluginId: string): void;
491 /**
492 * Add a vConsole log.
493 */
494 addLog(item?: {
495 type: IConsoleLogMethod;
496 origData: any[];
497 isGroupHeader?: 0 | 1 | 2;
498 isGroupCollapsed?: boolean;
499 }, opt?: IVConsoleAddLogOptions): void;
500 /**
501 * Execute a JS command.
502 */
503 evalCommand(cmd: string): void;
504 protected _signalLog(log: IVConsoleLog): void;
505 protected _flushLogs(): void;
506 protected _extractPluginIdByLog(log: IVConsoleLog): string;
507 protected _isRepeatedLog(logList: IVConsoleLog[], log: IVConsoleLog): boolean;
508 protected _updateLastLogRepeated(logList: IVConsoleLog[]): IVConsoleLog[];
509 protected _limitLogListLength(logList: IVConsoleLog[]): IVConsoleLog[];
510 }
511}
512declare module "log/log.exporter" {
513 import { VConsolePluginExporter } from "lib/pluginExporter";
514 import { VConsoleLogModel } from "log/log.model";
515 import type { IConsoleLogMethod } from "log/log.model";
516 export class VConsoleLogExporter extends VConsolePluginExporter {
517 model: VConsoleLogModel;
518 log(...args: any[]): void;
519 info(...args: any[]): void;
520 debug(...args: any[]): void;
521 warn(...args: any[]): void;
522 error(...args: any[]): void;
523 clear(): void;
524 protected addLog(method: IConsoleLogMethod, ...args: any[]): void;
525 }
526}
527declare module "log/log" {
528 import { VConsoleSveltePlugin } from "lib/sveltePlugin";
529 import { VConsoleLogModel } from "log/log.model";
530 /**
531 * vConsole Log Plugin (base class).
532 */
533 export class VConsoleLogPlugin extends VConsoleSveltePlugin {
534 model: VConsoleLogModel;
535 isReady: boolean;
536 isShow: boolean;
537 isInBottom: boolean;
538 constructor(id: string, name: string);
539 onReady(): void;
540 onRemove(): void;
541 onAddTopBar(callback: Function): void;
542 onAddTool(callback: Function): void;
543 onUpdateOption(): void;
544 }
545 export default VConsoleLogPlugin;
546}
547declare module "log/default" {
548 import { VConsoleLogPlugin } from "log/log";
549 export class VConsoleDefaultPlugin extends VConsoleLogPlugin {
550 protected onErrorHandler: any;
551 protected resourceErrorHandler: any;
552 protected rejectionHandler: any;
553 onReady(): void;
554 onRemove(): void;
555 /**
556 * Catch window errors.
557 */
558 protected bindErrors(): void;
559 /**
560 * Not catch window errors.
561 */
562 protected unbindErrors(): void;
563 /**
564 * Catch `window.onerror`.
565 */
566 protected catchWindowOnError(): void;
567 /**
568 * Catch resource loading error: image, video, link, script.
569 */
570 protected catchResourceError(): void;
571 /**
572 * Catch `Promise.reject`.
573 * @reference https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event
574 */
575 private catchUnhandledRejection;
576 }
577 export default VConsoleDefaultPlugin;
578}
579declare module "log/system" {
580 import { VConsoleLogPlugin } from "log/log";
581 export class VConsoleSystemPlugin extends VConsoleLogPlugin {
582 onReady(): void;
583 printSystemInfo(): void;
584 }
585 export default VConsoleSystemPlugin;
586}
587declare module "network/helper" {
588 import type { VConsoleNetworkRequestItem } from "network/requestItem";
589 export type IOnUpdateCallback = (item: VConsoleNetworkRequestItem) => void;
590 /**
591 * Generate `getData` by url.
592 */
593 export const genGetDataByUrl: (url: string, getData?: {}) => {};
594 /**
595 * Generate formatted response data by responseType.
596 */
597 export const genResonseByResponseType: (responseType: string, response: any) => string;
598 /**
599 * Generate formatted response body by XMLHttpRequestBodyInit.
600 */
601 export const genFormattedBody: (body?: BodyInit) => string | {
602 [key: string]: string;
603 };
604 /**
605 * Get formatted URL object by string.
606 */
607 export const getURL: (urlString?: string) => URL;
608}
609declare module "network/requestItem" {
610 export type VConsoleRequestMethod = '' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
611 export class VConsoleNetworkRequestItem {
612 id: string;
613 name?: string;
614 method: VConsoleRequestMethod;
615 url: string;
616 status: number | string;
617 statusText?: string;
618 cancelState?: 0 | 1 | 2 | 3;
619 readyState?: XMLHttpRequest['readyState'];
620 header: {
621 [key: string]: string;
622 };
623 responseType: XMLHttpRequest['responseType'];
624 requestType: 'xhr' | 'fetch' | 'ping' | 'custom';
625 requestHeader: HeadersInit;
626 response: any;
627 responseSize: number;
628 responseSizeText: string;
629 startTime: number;
630 startTimeText: string;
631 endTime: number;
632 costTime?: number;
633 getData: {
634 [key: string]: string;
635 };
636 postData: {
637 [key: string]: string;
638 } | string;
639 actived: boolean;
640 noVConsole?: boolean;
641 constructor();
642 }
643 export class VConsoleNetworkRequestItemProxy extends VConsoleNetworkRequestItem {
644 static Handler: {
645 get(item: VConsoleNetworkRequestItemProxy, prop: string): any;
646 set(item: VConsoleNetworkRequestItemProxy, prop: string, value: any): boolean;
647 };
648 protected _response?: any;
649 constructor(item: VConsoleNetworkRequestItem);
650 }
651}
652declare module "network/xhr.proxy" {
653 import { VConsoleNetworkRequestItem } from "network/requestItem";
654 import type { IOnUpdateCallback } from "network/helper";
655 export class XHRProxyHandler<T extends XMLHttpRequest> implements ProxyHandler<T> {
656 XMLReq: XMLHttpRequest;
657 item: VConsoleNetworkRequestItem;
658 protected onUpdateCallback: IOnUpdateCallback;
659 constructor(XMLReq: XMLHttpRequest, onUpdateCallback: IOnUpdateCallback);
660 get(target: T, key: string): any;
661 set(target: T, key: string, value: any): boolean;
662 onReadyStateChange(): void;
663 onAbort(): void;
664 onTimeout(): void;
665 protected triggerUpdate(): void;
666 protected getOpen(target: T): (...args: any[]) => any;
667 protected getSend(target: T): (...args: any[]) => any;
668 protected getSetRequestHeader(target: T): (...args: any[]) => any;
669 protected setOnReadyStateChange(target: T, key: string, value: any): boolean;
670 protected setOnAbort(target: T, key: string, value: any): boolean;
671 protected setOnTimeout(target: T, key: string, value: any): boolean;
672 /**
673 * Update item's properties according to readyState.
674 */
675 protected updateItemByReadyState(): void;
676 }
677 export class XHRProxy {
678 static origXMLHttpRequest: {
679 new (): XMLHttpRequest;
680 prototype: XMLHttpRequest;
681 readonly DONE: number;
682 readonly HEADERS_RECEIVED: number;
683 readonly LOADING: number;
684 readonly OPENED: number;
685 readonly UNSENT: number;
686 };
687 static create(onUpdateCallback: IOnUpdateCallback): {
688 new (): XMLHttpRequest;
689 prototype: XMLHttpRequest;
690 readonly DONE: number;
691 readonly HEADERS_RECEIVED: number;
692 readonly LOADING: number;
693 readonly OPENED: number;
694 readonly UNSENT: number;
695 };
696 }
697}
698declare module "network/fetch.proxy" {
699 import { VConsoleNetworkRequestItem } from "network/requestItem";
700 import type { IOnUpdateCallback } from "network/helper";
701 export class ResponseProxyHandler<T extends Response> implements ProxyHandler<T> {
702 resp: Response;
703 item: VConsoleNetworkRequestItem;
704 protected onUpdateCallback: IOnUpdateCallback;
705 constructor(resp: T, item: VConsoleNetworkRequestItem, onUpdateCallback: IOnUpdateCallback);
706 set(target: T, key: string, value: any): boolean;
707 get(target: T, key: string): any;
708 protected mockReader(): void;
709 }
710 export class FetchProxyHandler<T extends typeof fetch> implements ProxyHandler<T> {
711 protected onUpdateCallback: IOnUpdateCallback;
712 constructor(onUpdateCallback: IOnUpdateCallback);
713 apply(target: T, thisArg: typeof window, argsList: any): Promise<Response>;
714 protected beforeFetch(item: VConsoleNetworkRequestItem, input: RequestInfo, init?: RequestInit): void;
715 protected afterFetch(item: any): (resp: Response) => Response;
716 protected handleResponseBody(resp: Response, item: VConsoleNetworkRequestItem): Promise<ArrayBuffer> | Promise<string>;
717 }
718 export class FetchProxy {
719 static origFetch: typeof fetch;
720 static create(onUpdateCallback: IOnUpdateCallback): typeof fetch;
721 }
722}
723declare module "network/beacon.proxy" {
724 import type { IOnUpdateCallback } from "network/helper";
725 export class BeaconProxyHandler<T extends typeof navigator.sendBeacon> implements ProxyHandler<T> {
726 protected onUpdateCallback: IOnUpdateCallback;
727 constructor(onUpdateCallback: IOnUpdateCallback);
728 apply(target: T, thisArg: T, argsList: any[]): any;
729 }
730 export class BeaconProxy {
731 static origSendBeacon: (url: string | URL, data?: BodyInit) => boolean;
732 static create(onUpdateCallback: IOnUpdateCallback): any;
733 }
734}
735declare module "network/network.model" {
736 import { VConsoleModel } from "lib/model";
737 import { VConsoleNetworkRequestItem } from "network/requestItem";
738 /**
739 * Network Store
740 */
741 export const requestList: import("vendor/svelte/store").Writable<{
742 [id: string]: VConsoleNetworkRequestItem;
743 }>;
744 /**
745 * Network Model
746 */
747 export class VConsoleNetworkModel extends VConsoleModel {
748 maxNetworkNumber: number;
749 ignoreUrlRegExp: RegExp;
750 protected itemCounter: number;
751 constructor();
752 unMock(): void;
753 clearLog(): void;
754 /**
755 * Add or update a request item by request ID.
756 */
757 updateRequest(id: string, data: VConsoleNetworkRequestItem): void;
758 /**
759 * mock XMLHttpRequest
760 * @private
761 */
762 private mockXHR;
763 /**
764 * mock fetch request
765 * @private
766 */
767 private mockFetch;
768 /**
769 * mock navigator.sendBeacon
770 * @private
771 */
772 private mockSendBeacon;
773 protected limitListLength(): void;
774 }
775 export default VConsoleNetworkModel;
776}
777declare module "network/network.exporter" {
778 import { VConsolePluginExporter } from "lib/pluginExporter";
779 import { VConsoleNetworkModel } from "network/network.model";
780 import { VConsoleNetworkRequestItem, VConsoleNetworkRequestItemProxy } from "network/requestItem";
781 export class VConsoleNetworkExporter extends VConsolePluginExporter {
782 model: VConsoleNetworkModel;
783 add(item: VConsoleNetworkRequestItem): VConsoleNetworkRequestItemProxy;
784 update(id: string, item: VConsoleNetworkRequestItem): void;
785 clear(): void;
786 }
787}
788declare module "network/network" {
789 import { VConsoleSveltePlugin } from "lib/sveltePlugin";
790 import { VConsoleNetworkModel } from "network/network.model";
791 import { VConsoleNetworkExporter } from "network/network.exporter";
792 export class VConsoleNetworkPlugin extends VConsoleSveltePlugin {
793 model: VConsoleNetworkModel;
794 exporter: VConsoleNetworkExporter;
795 constructor(id: string, name: string, renderProps?: {});
796 onReady(): void;
797 onAddTool(callback: any): void;
798 onRemove(): void;
799 onUpdateOption(): void;
800 }
801}
802declare module "element/element.model" {
803 export interface IVConsoleNode {
804 nodeType: typeof Node.prototype.nodeType;
805 nodeName: typeof Node.prototype.nodeName;
806 textContent: typeof Node.prototype.textContent;
807 id: typeof Element.prototype.id;
808 className: typeof Element.prototype.className;
809 attributes: {
810 [name: string]: string;
811 }[];
812 childNodes: IVConsoleNode[];
813 _isExpand?: boolean;
814 _isActived?: boolean;
815 _isSingleLine?: boolean;
816 _isNullEndTag?: boolean;
817 }
818 /**
819 * Element Store
820 */
821 export const rootNode: import("vendor/svelte/store").Writable<IVConsoleNode>;
822 export const activedNode: import("vendor/svelte/store").Writable<IVConsoleNode>;
823}
824declare module "element/element" {
825 import MutationObserver from "vendor/mutation-observer";
826 import { VConsoleSveltePlugin } from "lib/sveltePlugin";
827 import type { IVConsoleNode } from "element/element.model";
828 /**
829 * vConsole Element Panel
830 */
831 export class VConsoleElementPlugin extends VConsoleSveltePlugin {
832 protected isInited: boolean;
833 protected observer: MutationObserver;
834 protected nodeMap: WeakMap<Node, IVConsoleNode>;
835 constructor(id: string, name: string, renderProps?: {});
836 onShow(): void;
837 onRemove(): void;
838 onAddTool(callback: any): void;
839 protected _init(): void;
840 protected _handleMutation(mutation: MutationRecord): void;
841 protected _onChildRemove(mutation: MutationRecord): void;
842 protected _onChildAdd(mutation: MutationRecord): void;
843 protected _onAttributesChange(mutation: MutationRecord): void;
844 protected _onCharacterDataChange(mutation: MutationRecord): void;
845 /**
846 * Generate an VNode for rendering views. VNode will be updated if existing.
847 * VNode will be stored in a WeakMap.
848 */
849 protected _generateVNode(elem: Node): IVConsoleNode;
850 protected _updateVNodeAttributes(elem: Node): void;
851 /**
852 * Expand the actived node.
853 * If the node is collapsed, expand it.
854 * If the node is expanded, expand it's child nodes.
855 */
856 protected _expandActivedNode(): void;
857 /**
858 * Collapse the actived node.
859 * If the node is expanded, and has expanded child nodes, collapse it's child nodes.
860 * If the node is expanded, and has no expanded child node, collapse it self.
861 * If the node is collapsed, do nothing.
862 */
863 protected _collapseActivedNode(): void;
864 protected _isIgnoredNode(elem: Node): boolean;
865 protected _isInVConsole(elem: Element): boolean;
866 protected _refreshStore(): void;
867 }
868}
869declare module "storage/storage.cookie" {
870 import type { IStorage } from "storage/storage.model";
871 export interface CookieOptions {
872 path?: string | null;
873 domain?: string | null;
874 expires?: Date | null;
875 secure?: boolean;
876 sameSite?: 'Strict' | 'Lax' | 'None';
877 }
878 export class CookieStorage implements IStorage {
879 get length(): number;
880 /**
881 * Returns sorted keys.
882 */
883 get keys(): string[];
884 key(index: number): string;
885 setItem(key: string, data: string, cookieOptions?: CookieOptions): void;
886 getItem(key: string): string;
887 removeItem(key: string, cookieOptions?: CookieOptions): void;
888 clear(): void;
889 }
890}
891declare module "storage/storage.wx" {
892 import type { IStorage } from "storage/storage.model";
893 export class WxStorage implements IStorage {
894 keys: string[];
895 currentSize: number;
896 limitSize: number;
897 get length(): number;
898 key(index: number): string;
899 /**
900 * Prepare for async data.
901 */
902 prepare(): Promise<boolean>;
903 getItem(key: string): Promise<string>;
904 setItem(key: string, data: any): Promise<void>;
905 removeItem(key: string): Promise<void>;
906 clear(): Promise<void>;
907 }
908}
909declare module "storage/storage.model" {
910 import type { VConsoleAvailableStorage } from "core/options.interface";
911 import { VConsoleModel } from "lib/model";
912 export interface IStorage {
913 length: number;
914 key: (index: number) => string | null;
915 getItem: (key: string) => string | null | Promise<string | null>;
916 setItem: (key: string, data: any) => void | Promise<void>;
917 removeItem: (key: string) => void | Promise<void>;
918 clear: () => void | Promise<void>;
919 prepare?: () => Promise<boolean>;
920 }
921 /**
922 * Storage Store
923 */
924 export const storageStore: {
925 updateTime: import("vendor/svelte/store").Writable<number>;
926 activedName: import("vendor/svelte/store").Writable<VConsoleAvailableStorage>;
927 defaultStorages: import("vendor/svelte/store").Writable<VConsoleAvailableStorage[]>;
928 };
929 export class VConsoleStorageModel extends VConsoleModel {
930 protected storage: Map<VConsoleAvailableStorage, IStorage>;
931 constructor();
932 get activedStorage(): IStorage;
933 getItem(key: string): Promise<string>;
934 setItem(key: string, data: any): Promise<void>;
935 removeItem(key: string): Promise<void>;
936 clear(): Promise<void>;
937 refresh(): void;
938 /**
939 * Get key-value data.
940 */
941 getEntries(): Promise<[string, string][]>;
942 updateEnabledStorages(): void;
943 protected promisify<T extends string | void>(ret: T | Promise<T>): T | Promise<T>;
944 protected deleteStorage(key: VConsoleAvailableStorage): void;
945 }
946}
947declare module "storage/storage" {
948 import { VConsoleSveltePlugin } from "lib/sveltePlugin";
949 import { VConsoleStorageModel } from "storage/storage.model";
950 export class VConsoleStoragePlugin extends VConsoleSveltePlugin {
951 protected model: VConsoleStorageModel;
952 protected onAddTopBarCallback: Function;
953 constructor(id: string, name: string, renderProps?: {});
954 onReady(): void;
955 onShow(): void;
956 onAddTopBar(callback: Function): void;
957 onAddTool(callback: Function): void;
958 onUpdateOption(): void;
959 protected updateTopBar(): void;
960 }
961}
962declare module "core/core" {
963 /**
964 * vConsole core class
965 */
966 import type { SvelteComponent } from "vendor/svelte";
967 import type { VConsoleOptions } from "core/options.interface";
968 import { VConsolePlugin } from "lib/plugin";
969 import { VConsoleLogPlugin } from "log/log";
970 import { VConsoleDefaultPlugin } from "log/default";
971 import { VConsoleSystemPlugin } from "log/system";
972 import { VConsoleNetworkPlugin } from "network/network";
973 import { VConsoleElementPlugin } from "element/element";
974 import { VConsoleStoragePlugin } from "storage/storage";
975 import { VConsoleLogExporter } from "log/log.exporter";
976 import { VConsoleNetworkExporter } from "network/network.exporter";
977 export class VConsole {
978 version: string;
979 isInited: boolean;
980 option: VConsoleOptions;
981 protected compInstance: SvelteComponent;
982 protected pluginList: {
983 [id: string]: VConsolePlugin;
984 };
985 log: VConsoleLogExporter;
986 system: VConsoleLogExporter;
987 network: VConsoleNetworkExporter;
988 static VConsolePlugin: typeof VConsolePlugin;
989 static VConsoleLogPlugin: typeof VConsoleLogPlugin;
990 static VConsoleDefaultPlugin: typeof VConsoleDefaultPlugin;
991 static VConsoleSystemPlugin: typeof VConsoleSystemPlugin;
992 static VConsoleNetworkPlugin: typeof VConsoleNetworkPlugin;
993 static VConsoleElementPlugin: typeof VConsoleElementPlugin;
994 static VConsoleStoragePlugin: typeof VConsoleStoragePlugin;
995 constructor(opt?: VConsoleOptions);
996 /**
997 * Get singleton instance.
998 **/
999 static get instance(): VConsole | undefined;
1000 /**
1001 * Set singleton instance.
1002 **/
1003 static set instance(value: VConsole | undefined);
1004 /**
1005 * Add built-in plugins.
1006 */
1007 private _addBuiltInPlugins;
1008 /**
1009 * Init svelte component.
1010 */
1011 private _initComponent;
1012 private _updateComponentByOptions;
1013 /**
1014 * Update the position of Switch button.
1015 */
1016 setSwitchPosition(x: number, y: number): void;
1017 /**
1018 * Auto run after initialization.
1019 * @private
1020 */
1021 private _autoRun;
1022 private _showFirstPluginWhenEmpty;
1023 /**
1024 * Trigger a `vConsole.option` event.
1025 */
1026 triggerEvent(eventName: string, param?: any): void;
1027 /**
1028 * Init a plugin.
1029 */
1030 private _initPlugin;
1031 /**
1032 * Trigger an event for each plugin.
1033 */
1034 private _triggerPluginsEvent;
1035 /**
1036 * Trigger an event by plugin's id.
1037 * @private
1038 */
1039 private _triggerPluginEvent;
1040 /**
1041 * Sorting plugin list by option `pluginOrder`.
1042 * Plugin not listed in `pluginOrder` will be put last.
1043 */
1044 private _reorderPluginList;
1045 /**
1046 * Add a new plugin.
1047 */
1048 addPlugin(plugin: VConsolePlugin): boolean;
1049 /**
1050 * Remove a plugin.
1051 */
1052 removePlugin(pluginID: string): boolean;
1053 /**
1054 * Show console panel.
1055 */
1056 show(): void;
1057 /**
1058 * Hide console panel.
1059 */
1060 hide(): void;
1061 /**
1062 * Show switch button
1063 */
1064 showSwitch(): void;
1065 /**
1066 * Hide switch button.
1067 */
1068 hideSwitch(): void;
1069 /**
1070 * Show a plugin panel.
1071 */
1072 showPlugin(pluginId: string): void;
1073 /**
1074 * Update option(s).
1075 * @example `setOption('log.maxLogNumber', 20)`: set 'maxLogNumber' field only.
1076 * @example `setOption({ log: { maxLogNumber: 20 }})`: overwrite 'log' object.
1077 */
1078 setOption(keyOrObj: any, value?: any): void;
1079 /**
1080 * Remove vConsole.
1081 */
1082 destroy(): void;
1083 }
1084}
1085declare module "vconsole" {
1086 /**
1087 * A Front-End Console Panel for Mobile Webpage
1088 */
1089 import "vendor/core-js/stable/symbol";
1090 import 'core-js/stable/promise';
1091 import { VConsole } from "core/core";
1092 export default VConsole;
1093}
1094declare module "component/recycleScroller/recycleManager" {
1095 const createRecycleManager: () => (itemCount: number, start: number, end: number) => {
1096 key: number;
1097 index: number;
1098 show: boolean;
1099 }[];
1100 export default createRecycleManager;
1101}
1102declare module "component/recycleScroller/resizeObserver" {
1103 /**
1104 * A ResizeObserver polyfill.
1105 * ResizeObserver is not support in iOS 13.3
1106 */
1107 class EmptyResizeObserver {
1108 constructor(callback: (entries: any[], observer?: EmptyResizeObserver) => void);
1109 disconnect(): void;
1110 observe(target: Element | SVGElement, options?: any): void;
1111 unobserve(target: Element | SVGElement): void;
1112 }
1113 export const hasResizeObserver: () => boolean;
1114 export const useResizeObserver: () => {
1115 new (callback: ResizeObserverCallback): ResizeObserver;
1116 prototype: ResizeObserver;
1117 } | typeof EmptyResizeObserver;
1118}
1119declare module "component/recycleScroller/scroll/friction" {
1120 /** *
1121 * Friction physics simulation. Friction is actually just a simple
1122 * power curve; the only trick is taking the natural log of the
1123 * initial drag so that we can express the answer in terms of time.
1124 */
1125 class Friction {
1126 private _drag;
1127 private _dragLog;
1128 private _x;
1129 private _v;
1130 private _startTime;
1131 constructor(drag: number);
1132 set(x: number, v: number, t?: number): void;
1133 x(t: number): number;
1134 dx(t: number): number;
1135 done(t: number): boolean;
1136 }
1137 export default Friction;
1138}
1139declare module "component/recycleScroller/scroll/linear" {
1140 class Linear {
1141 private _x;
1142 private _endX;
1143 private _v;
1144 private _startTime;
1145 private _endTime;
1146 set(x: number, endX: number, dt: number, t?: number): void;
1147 x(t: number): number;
1148 dx(t: number): number;
1149 done(t: number): boolean;
1150 }
1151 export default Linear;
1152}
1153declare module "component/recycleScroller/scroll/spring" {
1154 class Spring {
1155 private _solver;
1156 private _solution;
1157 private _endPosition;
1158 private _startTime;
1159 constructor(mass: number, springConstant: number, damping: number);
1160 x(t: number): number;
1161 dx(t: number): number;
1162 set(endPosition: number, x: number, velocity: number, t?: number): void;
1163 done(t: number): boolean;
1164 }
1165 export default Spring;
1166}
1167declare module "component/recycleScroller/scroll/scroll" {
1168 /** *
1169 * Scroll combines Friction and Spring to provide the
1170 * classic "flick-with-bounce" behavior.
1171 */
1172 class Scroll {
1173 private _enableSpring;
1174 private _getExtend;
1175 private _friction;
1176 private _spring;
1177 private _toEdge;
1178 constructor(getExtend: () => number, _enableSpring: boolean);
1179 set(x: number, v: number, t?: number): void;
1180 x(t: number): number;
1181 dx(t: number): number;
1182 done(t: number): boolean;
1183 }
1184 export default Scroll;
1185}
1186declare module "component/recycleScroller/scroll/touchTracker" {
1187 export interface TrackerHandler {
1188 onTouchStart(): void;
1189 onTouchMove(x: number, y: number): void;
1190 onTouchEnd(x: number, y: number, velocityX: number, velocityY: number): void;
1191 onTouchCancel(): void;
1192 onWheel(x: number, y: number): void;
1193 }
1194 class TouchTracker {
1195 private _handler;
1196 private _touchId;
1197 private _startX;
1198 private _startY;
1199 private _historyX;
1200 private _historyY;
1201 private _historyTime;
1202 private _wheelDeltaX;
1203 private _wheelDeltaY;
1204 constructor(_handler: TrackerHandler);
1205 private _getTouchDelta;
1206 private _onTouchMove;
1207 private _onWheel;
1208 handleTouchStart: (e: TouchEvent) => void;
1209 handleTouchMove: (e: TouchEvent) => void;
1210 handleTouchEnd: (e: TouchEvent) => void;
1211 handleTouchCancel: (e: TouchEvent) => void;
1212 handleWheel: (e: WheelEvent) => void;
1213 }
1214 export default TouchTracker;
1215}
1216declare module "component/recycleScroller/scroll/scrollHandler" {
1217 import { TrackerHandler } from "component/recycleScroller/scroll/touchTracker";
1218 class ScrollHandler implements TrackerHandler {
1219 private _updatePosition;
1220 private _scrollModel;
1221 private _linearModel;
1222 private _startPosition;
1223 private _position;
1224 private _animate;
1225 private _getExtent;
1226 constructor(getExtent: () => number, _updatePosition: (pos: number) => void);
1227 onTouchStart(): void;
1228 onTouchMove(dx: number, dy: number): void;
1229 onTouchEnd(dx: number, dy: number, velocityX: number, velocityY: number): void;
1230 onTouchCancel(): void;
1231 onWheel(x: number, y: number): void;
1232 getPosition(): number;
1233 updatePosition(position: number): void;
1234 scrollTo(position: number, duration?: number): void;
1235 }
1236 export default ScrollHandler;
1237}