declare module "lib/tool" { /** * Utility Functions */ /** * get formatted date by timestamp */ export function getDate(time: number): { time: number; year: number; month: string | number; day: string | number; hour: string | number; minute: string | number; second: string | number; millisecond: string | number; }; /** * Determine whether a value is of a specific type. */ export function isNumber(value: any): boolean; export function isBigInt(value: any): boolean; export function isString(value: any): boolean; export function isArray(value: any): boolean; export function isBoolean(value: any): boolean; export function isUndefined(value: any): boolean; export function isNull(value: any): boolean; export function isSymbol(value: any): boolean; export function isObject(value: any): boolean; export function isFunction(value: any): boolean; export function isElement(value: any): boolean; export function isWindow(value: any): boolean; export function isIterable(value: any): boolean; /** * Get the prototype name of an object */ export function getPrototypeName(value: any): string; /** * Get an object's constructor name. */ export function getObjName(obj: any): string; /** * check whether an object is plain (using {}) * @param object obj * @return boolean */ export function isPlainObject(obj: any): boolean; /** * Escape HTML to XSS-safe text. */ export function htmlEncode(text: string | number): string; /** * Convert a text's invisible characters to visible characters. */ export function getVisibleText(text: string): string; /** * A safe `JSON.stringify` method. */ export function safeJSONStringify(obj: any, opt?: { maxDepth?: number; keyMaxLen?: number; pretty?: boolean; }): string; /** * Call original `JSON.stringify` and catch unknown exceptions. */ export function JSONStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; export function getStringBytes(str: string): number; export function getBytesText(bytes: number): string; export function subString(str: string, len: number): string; /** * Sore an `string[]` by string. */ export function sortArray(arr: string[]): string[]; /** * Get enumerable keys of an object or array. */ export function getEnumerableKeys(obj: any): string[]; /** * Get enumerable and non-enumerable keys of an object or array. */ export function getEnumerableAndNonEnumerableKeys(obj: any): string[]; /** * Get non-enumerable keys of an object or array. */ export function getNonEnumerableKeys(obj: any): string[]; export function getSymbolKeys(obj: any): symbol[]; /** * localStorage methods */ export function setStorage(key: string, value: string): void; export function getStorage(key: string): string; /** * Generate a 6-digit unique string with prefix `"__vc_" + ${prefix}` */ export function getUniqueID(prefix?: string): string; } declare module "lib/query" { const $: { /** * get single element * @public */ one: (selector: string, contextElement?: Element | Document) => HTMLElement; /** * get multiple elements * @public */ all: (selector: string, contextElement?: Element | Document) => HTMLElement[]; /** * add className(s) to an or multiple element(s) * @public */ addClass: ($el: Element | Element[], className: string) => void; /** * remove className(s) from an or multiple element(s) * @public */ removeClass: ($el: Element | Element[], className: string) => void; /** * see whether an element contains a className * @public */ hasClass: ($el: Element, className: string) => boolean; /** * bind an event to element(s) * @public */ bind: ($el: Element | Element[], eventType: any, fn: any, useCapture?: boolean) => void; /** * delegate an event to a parent element * @public * @param $el parent element * @param eventType name of the event * @param selector target's selector * @param fn callback function */ delegate: ($el: Element, eventType: string, selector: string, fn: (event: Event, $target: HTMLElement) => void) => void; /** * Remove all child elements of an element. */ removeChildren($el: Element): Element; }; /** * export */ export default $; } declare module "lib/model" { type AConstructorTypeOf = new (...args: U) => T; export class VConsoleModel { static singleton: { [ctorName: string]: VConsoleModel; }; protected _onDataUpdateCallbacks: Function[]; /** * Get a singleton of a model. */ static getSingleton(ctor: AConstructorTypeOf, ctorName: string): T; } export default VConsoleModel; } declare module "lib/pluginExporter" { import type { VConsoleModel } from "lib/model"; export class VConsolePluginExporter { protected model: VConsoleModel; protected pluginId: string; constructor(pluginId: string); destroy(): void; } } declare module "lib/plugin" { import { VConsolePluginExporter } from "lib/pluginExporter"; import type { VConsole } from "core/core"; export type IVConsolePluginEvent = (data?: any) => void; export type IVConsolePluginEventName = 'init' | 'renderTab' | 'addTopBar' | 'addTool' | 'ready' | 'remove' | 'updateOption' | 'showConsole' | 'hideConsole' | 'show' | 'hide'; export interface IVConsoleTopbarOptions { name: string; className: string; actived?: boolean; data?: { [key: string]: string; }; onClick?: (e: Event, data?: any) => any; } export interface IVConsoleToolbarOptions { name: string; global?: boolean; data?: { [key: string]: string; }; onClick?: (e: Event, data?: any) => any; } /** * vConsole Plugin Base Class */ export class VConsolePlugin { isReady: boolean; eventMap: Map; exporter?: VConsolePluginExporter; protected _id: string; protected _name: string; protected _vConsole: VConsole; constructor(...args: any[]); get id(): string; set id(value: string); get name(): string; set name(value: string); get vConsole(): VConsole; set vConsole(value: VConsole); /** * Register an event * @public * @param IVConsolePluginEventName * @param IVConsolePluginEvent */ on(eventName: IVConsolePluginEventName, callback: IVConsolePluginEvent): this; onRemove(): void; /** * Trigger an event. */ trigger(eventName: IVConsolePluginEventName, data?: any): this; protected bindExporter(): void; protected unbindExporter(): void; protected getUniqueID(prefix?: string): string; } export default VConsolePlugin; } declare module "lib/sveltePlugin" { import VConsolePlugin from "lib/plugin"; import { SvelteComponent } from 'svelte'; export class VConsoleSveltePlugin extends VConsolePlugin { CompClass: typeof SvelteComponent; compInstance?: SvelteComponent; initialProps: T; constructor(id: string, name: string, CompClass: typeof SvelteComponent, initialProps: T); onReady(): void; onRenderTab(callback: any): void; onRemove(): void; } } declare module "core/core.model" { export const contentStore: { subscribe: (this: void, run: import("svelte/store").Subscriber<{ updateTime: number; }>, invalidate?: (value?: { updateTime: number; }) => void) => import("svelte/store").Unsubscriber; set: (this: void, value: { updateTime: number; }) => void; update: (this: void, updater: import("svelte/store").Updater<{ updateTime: number; }>) => void; updateTime: () => void; }; } declare module "log/logTool" { import type { IVConsoleLog, IVConsoleLogData } from "log/log.model"; /** * Get a value's text content and its type. */ export const getValueTextAndType: (val: any, wrapString?: boolean) => { text: any; valueType: string; }; /** * A simple parser to get `[` or `]` information. */ export const getLastIdentifier: (text: string) => { front: { text: string; pos: number; before: string; after: string; }; back: { text: string; pos: number; before: string; after: string; }; }; export const isMatchedFilterText: (log: IVConsoleLog, filterText: string) => boolean; /** * Styling log output (`%c`), or string substitutions (`%s`, `%d`, `%o`). * Apply to the first log only. */ export const getLogDatasWithFormatting: (origDatas: any[]) => IVConsoleLogData[]; /** * An empty class for rendering views. */ export class VConsoleUninvocatableObject { } } declare module "log/log.store" { import type { Writable } from 'svelte/store'; import type { IVConsoleLog } from "log/log.model"; export interface IVConsoleLogStore { logList: IVConsoleLog[]; } /** * Log Store Factory */ export class VConsoleLogStore { static storeMap: { [pluginId: string]: Writable; }; /** * Create a store. */ static create(pluginId: string): Writable; /** * Delete a store. */ static delete(pluginId: string): void; /** * Get a store by pluginId, */ static get(pluginId: string): Writable; /** * Get a store's raw data. */ static getRaw(pluginId: string): IVConsoleLogStore; /** * Get all stores. */ static getAll(): { [pluginId: string]: Writable; }; } } declare module "log/log.model" { import { VConsoleModel } from "lib/model"; /********************************** * Interfaces **********************************/ export type IConsoleLogMethod = 'log' | 'info' | 'debug' | 'warn' | 'error'; export interface IVConsoleLogData { origData: any; style?: string; } export interface IVConsoleLog { _id: string; type: IConsoleLogMethod; cmdType?: 'input' | 'output'; repeated?: number; date: number; data: IVConsoleLogData[]; } export type IVConsoleLogListMap = { [pluginId: string]: IVConsoleLog[]; }; export type IVConsoleLogFilter = { [pluginId: string]: string; }; export interface IVConsoleAddLogOptions { noOrig?: boolean; cmdType?: 'input' | 'output'; } /********************************** * Stores **********************************/ /********************************** * Model **********************************/ export class VConsoleLogModel extends VConsoleModel { readonly LOG_METHODS: IConsoleLogMethod[]; ADDED_LOG_PLUGIN_ID: string[]; maxLogNumber: number; protected logCounter: number; protected pluginPattern: RegExp; /** * The original `window.console` methods. */ origConsole: { [method: string]: Function; }; /** * Bind a Log plugin. * When binding first plugin, `window.console` will be hooked. */ bindPlugin(pluginId: string): boolean; /** * Unbind a Log plugin. * When no binded plugin exists, hooked `window.console` will be recovered. */ unbindPlugin(pluginId: string): boolean; /** * Hook `window.console` with vConsole log method. * Methods will be hooked only once. */ mockConsole(): void; /** * Recover `window.console`. */ unmockConsole(): void; /** * Call origin `window.console[method](...args)` */ callOriginalConsole(method: string, ...args: any[]): void; /** * Remove all logs. */ clearLog(): void; /** * Remove a plugin's logs. */ clearPluginLog(pluginId: string): void; /** * Add a vConsole log. */ addLog(item?: { type: IConsoleLogMethod; origData: any[]; }, opt?: IVConsoleAddLogOptions): void; /** * Execute a JS command. */ evalCommand(cmd: string): void; protected _extractPluginIdByLog(log: IVConsoleLog): string; protected _isRepeatedLog(pluginId: string, log: IVConsoleLog): boolean; protected _updateLastLogRepeated(pluginId: string): void; protected _pushLogList(pluginId: string, log: IVConsoleLog): void; protected _limitLogListLength(): void; } } declare module "log/log.exporter" { import { VConsolePluginExporter } from "lib/pluginExporter"; import { VConsoleLogModel } from "log/log.model"; import type { IConsoleLogMethod } from "log/log.model"; export class VConsoleLogExporter extends VConsolePluginExporter { model: VConsoleLogModel; log(...args: any[]): void; info(...args: any[]): void; debug(...args: any[]): void; warn(...args: any[]): void; error(...args: any[]): void; clear(): void; protected addLog(method: IConsoleLogMethod, ...args: any[]): void; } } declare module "log/log" { import { VConsoleSveltePlugin } from "lib/sveltePlugin"; import { VConsoleLogModel } from "log/log.model"; /** * vConsole Log Plugin (base class). */ export class VConsoleLogPlugin extends VConsoleSveltePlugin { model: VConsoleLogModel; isReady: boolean; isShow: boolean; isInBottom: boolean; constructor(id: string, name: string); onReady(): void; onRemove(): void; onAddTopBar(callback: Function): void; onAddTool(callback: Function): void; onUpdateOption(): void; } export default VConsoleLogPlugin; } declare module "log/default" { import { VConsoleLogPlugin } from "log/log"; export class VConsoleDefaultPlugin extends VConsoleLogPlugin { protected onErrorHandler: any; protected resourceErrorHandler: any; protected rejectionHandler: any; onReady(): void; onRemove(): void; /** * Catch window errors. */ protected bindErrors(): void; /** * Not catch window errors. */ protected unbindErrors(): void; /** * Catch `window.onerror`. */ protected catchWindowOnError(): void; /** * Catch resource loading error: image, video, link, script. */ protected catchResourceError(): void; /** * Catch `Promise.reject`. * @reference https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event */ private catchUnhandledRejection; } export default VConsoleDefaultPlugin; } declare module "log/system" { import { VConsoleLogPlugin } from "log/log"; export class VConsoleSystemPlugin extends VConsoleLogPlugin { onReady(): void; printSystemInfo(): void; } export default VConsoleSystemPlugin; } declare module "network/requestItem" { export type VConsoleRequestMethod = '' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'; export class VConsoleNetworkRequestItem { id: string; name?: string; method: VConsoleRequestMethod; url: string; status: number | string; statusText?: string; readyState?: XMLHttpRequest['readyState']; header: { [key: string]: string; }; responseType: XMLHttpRequest['responseType']; requestType: 'xhr' | 'fetch' | 'ping' | 'custom'; requestHeader: HeadersInit; response: any; startTime: number; endTime: number; costTime?: number; getData: { [key: string]: string; }; postData: { [key: string]: string; } | string; actived: boolean; constructor(); } export class VConsoleNetworkRequestItemProxy extends VConsoleNetworkRequestItem { static Handler: { get(item: VConsoleNetworkRequestItemProxy, prop: string): any; set(item: VConsoleNetworkRequestItemProxy, prop: string, value: any): boolean; }; protected _response?: any; constructor(item: VConsoleNetworkRequestItem); } export const RequestItemHelper: { /** * Generate `getData` by url. */ genGetDataByUrl(url: string, getData?: {}): {}; /** * Generate formatted response data by responseType. */ genResonseByResponseType(responseType: string, response: any): any; }; } declare module "network/network.model" { import { VConsoleModel } from "lib/model"; import { VConsoleNetworkRequestItem } from "network/requestItem"; /** * Network Store */ export const requestList: import("svelte/store").Writable<{ [id: string]: VConsoleNetworkRequestItem; }>; /** * Network Model */ export class VConsoleNetworkModel extends VConsoleModel { maxNetworkNumber: number; protected itemCounter: number; private _xhrOpen; private _xhrSend; private _xhrSetRequestHeader; private _fetch; private _sendBeacon; constructor(); unMock(): void; clearLog(): void; /** * Add or update a request item by request ID. */ updateRequest(id: string, data: VConsoleNetworkRequestItem): void; /** * mock XMLHttpRequest * @private */ private mockXHR; /** * mock fetch request * @private */ private mockFetch; /** * mock navigator.sendBeacon * @private */ private mockSendBeacon; private getFormattedBody; private getURL; protected limitListLength(): void; } export default VConsoleNetworkModel; } declare module "network/network.exporter" { import { VConsolePluginExporter } from "lib/pluginExporter"; import { VConsoleNetworkModel } from "network/network.model"; import { VConsoleNetworkRequestItem, VConsoleNetworkRequestItemProxy } from "network/requestItem"; export class VConsoleNetworkExporter extends VConsolePluginExporter { model: VConsoleNetworkModel; add(item: VConsoleNetworkRequestItem): VConsoleNetworkRequestItemProxy; update(id: string, item: VConsoleNetworkRequestItem): void; clear(): void; } } declare module "network/network" { import { VConsoleSveltePlugin } from "lib/sveltePlugin"; import { VConsoleNetworkModel } from "network/network.model"; import { VConsoleNetworkExporter } from "network/network.exporter"; export class VConsoleNetworkPlugin extends VConsoleSveltePlugin { model: VConsoleNetworkModel; exporter: VConsoleNetworkExporter; constructor(id: string, name: string, renderProps?: {}); onReady(): void; onAddTool(callback: any): void; onRemove(): void; onUpdateOption(): void; } } declare module "element/element.model" { export interface IVConsoleNode { nodeType: typeof Node.prototype.nodeType; nodeName: typeof Node.prototype.nodeName; textContent: typeof Node.prototype.textContent; id: typeof Element.prototype.id; className: typeof Element.prototype.className; attributes: { [name: string]: string; }[]; childNodes: IVConsoleNode[]; _isExpand?: boolean; _isActived?: boolean; _isSingleLine?: boolean; _isNullEndTag?: boolean; } /** * Element Store */ export const rootNode: import("svelte/store").Writable; export const activedNode: import("svelte/store").Writable; } declare module "element/element" { import MutationObserver from 'mutation-observer'; import { VConsoleSveltePlugin } from "lib/sveltePlugin"; import type { IVConsoleNode } from "element/element.model"; /** * vConsole Element Panel */ export class VConsoleElementPlugin extends VConsoleSveltePlugin { protected isInited: boolean; protected observer: MutationObserver; protected nodeMap: WeakMap; constructor(id: string, name: string, renderProps?: {}); onShow(): void; onRemove(): void; onAddTool(callback: any): void; protected _init(): void; protected _handleMutation(mutation: MutationRecord): void; protected _onChildRemove(mutation: MutationRecord): void; protected _onChildAdd(mutation: MutationRecord): void; protected _onAttributesChange(mutation: MutationRecord): void; protected _onCharacterDataChange(mutation: MutationRecord): void; /** * Generate an VNode for rendering views. VNode will be updated if existing. * VNode will be stored in a WeakMap. */ protected _generateVNode(elem: Node): IVConsoleNode; protected _updateVNodeAttributes(elem: Node): void; /** * Expand the actived node. * If the node is collapsed, expand it. * If the node is expanded, expand it's child nodes. */ protected _expandActivedNode(): void; /** * Collapse the actived node. * If the node is expanded, and has expanded child nodes, collapse it's child nodes. * If the node is expanded, and has no expanded child node, collapse it self. * If the node is collapsed, do nothing. */ protected _collapseActivedNode(): void; protected _isIgnoredNode(elem: Node): boolean; protected _isInVConsole(elem: Element): boolean; protected _refreshStore(): void; } } declare module "storage/cookieStorage" { import { CookieStorage } from 'cookie-storage'; import type { CookieOptions } from 'cookie-storage/lib/cookie-options'; export class VConsoleCookieStorage extends CookieStorage { /** * Deep remove a cookie. */ removeItem(key: string, cookieOptions?: CookieOptions): void; /** * Deep clear all cookies. */ clear(): void; } } declare module "storage/storage.model" { import { VConsoleCookieStorage } from "storage/cookieStorage"; import { VConsoleModel } from "lib/model"; interface IStorageItem { name: string; storage: Storage; } export class VConsoleStorageModel extends VConsoleModel { protected cookiesStorage: VConsoleCookieStorage; protected storages: IStorageItem[]; /** * Get the singleton of storage list. */ getAllStorages(): IStorageItem[]; } } declare module "storage/storage" { import { VConsoleSveltePlugin } from "lib/sveltePlugin"; import { VConsoleStorageModel } from "storage/storage.model"; export class VConsoleStoragePlugin extends VConsoleSveltePlugin { protected model: VConsoleStorageModel; constructor(id: string, name: string, renderProps?: {}); onShow(): void; onAddTopBar(callback: Function): void; onAddTool(callback: Function): void; } } declare module "core/core" { /** * vConsole core class */ import type { SvelteComponent } from 'svelte'; import { VConsolePlugin } from "lib/plugin"; import { VConsoleLogPlugin } from "log/log"; import { VConsoleDefaultPlugin } from "log/default"; import { VConsoleSystemPlugin } from "log/system"; import { VConsoleNetworkPlugin } from "network/network"; import { VConsoleElementPlugin } from "element/element"; import { VConsoleStoragePlugin } from "storage/storage"; import { VConsoleLogExporter } from "log/log.exporter"; import { VConsoleNetworkExporter } from "network/network.exporter"; interface VConsoleOptions { target?: string | HTMLElement; defaultPlugins?: ('system' | 'network' | 'element' | 'storage')[]; maxLogNumber?: number; maxNetworkNumber?: number; theme?: '' | 'dark' | 'light'; disableLogScrolling?: boolean; onReady?: () => void; onClearLog?: () => void; } export class VConsole { version: string; isInited: boolean; option: VConsoleOptions; protected compInstance: SvelteComponent; protected pluginList: { [id: string]: VConsolePlugin; }; log: VConsoleLogExporter; system: VConsoleLogExporter; network: VConsoleNetworkExporter; static VConsolePlugin: typeof VConsolePlugin; static VConsoleLogPlugin: typeof VConsoleLogPlugin; static VConsoleDefaultPlugin: typeof VConsoleDefaultPlugin; static VConsoleSystemPlugin: typeof VConsoleSystemPlugin; static VConsoleNetworkPlugin: typeof VConsoleNetworkPlugin; static VConsoleElementPlugin: typeof VConsoleElementPlugin; static VConsoleStoragePlugin: typeof VConsoleStoragePlugin; constructor(opt?: VConsoleOptions); /** * Add built-in plugins. */ private _addBuiltInPlugins; /** * Init svelte component. */ private _initComponent; private _updateComponentByOptions; /** * Update the position of Switch button. */ setSwitchPosition(x: number, y: number): void; /** * Auto run after initialization. * @private */ private _autoRun; private _showFirstPluginWhenEmpty; /** * Trigger a `vConsole.option` event. */ triggerEvent(eventName: string, param?: any): void; /** * Init a plugin. */ private _initPlugin; /** * Trigger an event for each plugin. */ private _triggerPluginsEvent; /** * Trigger an event by plugin's id. * @private */ private _triggerPluginEvent; /** * Add a new plugin. */ addPlugin(plugin: VConsolePlugin): boolean; /** * Remove a plugin. */ removePlugin(pluginID: string): boolean; /** * Show console panel. */ show(): void; /** * Hide console panel. */ hide(): void; /** * Show switch button */ showSwitch(): void; /** * Hide switch button. */ hideSwitch(): void; /** * Show a plugin panel. */ showPlugin(pluginId: string): void; /** * Update option(s). */ setOption(keyOrObj: any, value?: any): void; /** * Remove vConsole. */ destroy(): void; } export default VConsole; } declare module "vconsole" { /** * A Front-End Console Panel for Mobile Webpage */ import 'core-js/stable/symbol'; import { VConsole } from "core/core"; export default VConsole; } declare module "lib/mito" { /** * Mito.js * A simple template engine * * @author Maiz */ export default class Mito { /** * Render `tpl` with `data` into a HTML string. */ render(tpl: string, data: any, toString: T): string; /** * Render `tpl` with `data` into a HTML element. */ render(tpl: string, data: any, toString?: T): Element; } }