vite-uni-dev-tool
Version:
vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试
292 lines (272 loc) • 6.83 kB
text/typescript
import { DevEvent } from './devEvent';
export declare namespace DevTool {
type Page = {
index?: number;
path: string;
sort?: number;
name?: string;
type?: string;
style: {
navigationBarTitleText?: string;
};
};
type Message = {
type: 'success' | 'error';
data: string;
time: number;
};
type WS = {
url: string;
/**
* -1: error
* 0:connecting
* 1:open
* 2:closing
* 3:closed
*/
readyState?: string;
headers?: { key: string; value: string }[];
method?: string;
protocols?: string[];
message: Message[];
};
type Nav = {
pagePath: string;
text: string;
};
type PagesJSON = {
pages: Page[];
subPackages?: { root: string; pages: Page[] }[];
tabBar: {
list: Nav[];
};
};
type DevToolOptions = {
/** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
enableInterceptPromiseReject?: boolean;
/** 打开窗口时隐藏按钮 */
openWindowHideButton?: boolean;
/** 最大的console条数 */
consoleMaxSize?: number;
/** 最大的网络请求条数 */
networkMaxSize?: number;
/** 最大的上传文件条数 */
uploadMaxSize?: number;
/** 最大的套接字消息条数 */
wsDataMaxSize?: number;
/** 最大的时间列表条数 */
eventListMaxSize?: number;
/** 最大截屏记录条数 */
captureScreenMaxSize?: number;
/** 最大占用缓存空间 */
cacheMaxSize?: number;
/** 所有路由信息 */
pagesJson?: PagesJSON;
/** 源文件服务地址 */
sourceFileServers?: string[];
/** 用于区分生产环境和开发环境,开发环境下,为了获取 Android 异常栈源码会获取本地源码进行展示 */
mode: string;
/** 用于捕获 vue3 抛出的错误和警告 */
vue3instance?: any;
/**
* 该属性处于实验当中,谨慎使用
* 读取开发环境 source file,source map,默认 禁用
*/
useDevSource?: boolean;
/** 层级默认 1000 */
zIndex?: number;
} & ButtonOptions;
type ButtonOptions = Partial<{
/** 按钮大小 */
buttonSize: number;
/** 按钮文本 */
buttonText: string;
/** 按钮文本颜色 */
buttonColor: string;
/** 按钮字体大小 */
buttonFontSize: string;
/** 按钮背景颜色 */
buttonBackgroundColor: string;
/** 初始化时是否显示调试按钮,默认显示 */
initShowDevTool: boolean;
}>;
type NetworkItem = {
index: number;
url: string;
name: string;
method: string;
status: number | string;
time: string;
startTime: number;
endTime: number;
size: string;
headers: {
requestHeader: { key: string; value: any }[];
responseHeader: { key: string; value: any }[];
};
response: string;
payload: any;
};
type StorageItem = {
key: string;
_oldKey: string;
value: string;
};
/** 调试工具目前支持处理的console类型 */
type ConsoleType =
| 'log'
| 'info'
| 'warn'
| 'error'
| 'timeEnd'
| 'time'
| 'clear'
| 'count';
/** 不支持处理的console类型 */
type OriginalConsoleType =
| 'assert'
| 'count'
| 'countReset'
| 'debug'
| 'dir'
| 'dirxml'
| 'group'
| 'groupCollapsed'
| 'groupEnd'
| 'table'
| 'trace'
| 'profile'
| 'profileEnd'
| 'timeStamp';
type ValueType =
| 'number'
| 'string'
| 'boolean'
| 'null'
| 'undefined'
| 'symbol'
| 'array'
| 'object';
type Arg = {
type: ValueType;
value: any;
};
type ConsoleItem = {
type: string;
args: Arg[];
position: string;
time: string;
stack?: string;
/**
* input 输入
* output 输出
*/
mode?: 'input' | 'output';
};
type UploadItem = {
index: number;
url?: string;
filePath?: string;
formData?: Record<string, any>;
method?: string;
headers?: {
requestHeader?: { key: string; value: unknown }[];
responseHeader?: { key: string; value: unknown }[];
};
response?: Record<string, any>;
files?: any[];
fileType?: string;
name?: string;
status: number | string;
timeout?: number;
startTime?: number;
endTime?: number;
/** 上传进度 */
progress?: number;
/** 已上传长度 */
totalBytesSent?: number;
/** 预计上传总长度 */
totalBytesExpectedToSend?: number;
};
type EventCount = {
on: number;
once: number;
emit: number;
off: number;
};
type EventCountKey = keyof EventCount;
type EventItem = {
/** 事件名称 */
eventName?: string;
/** 触发事件 */
timer?: string;
/** 调用位置 */
stack?: string;
/** 事件类型 */
type?: string;
};
type RunJSItem = {
/** 代码 */
code?: string;
/** 结果 */
result?: any;
/** 开始时间 */
timer?: string;
/** 执行用时 */
duration?: number;
/** 执行状态 */
type?: string;
mode?: 'input' | 'output';
};
type CaptureScreenItem = {
position: string;
timer: string;
};
type WindowData = {
devToolVisible?: boolean;
consoleList?: ConsoleItem[];
networkList?: NetworkItem[];
storageList?: StorageItem[];
routeList?: Page[];
vuexList?: Record<string, any>;
piniaList?: Record<string, any>;
systemInfo?: Record<string, any>;
deviceInfo?: Record<string, any>;
windowInfo?: Record<string, any>;
netWorkStatus?: Record<string, any>;
appInfo?: Record<string, any>;
wsList?: WS[];
size?: number;
sizeFormat?: string;
uploadList?: UploadItem[];
eventCount?: EventCount;
eventList?: EventItem[];
captureScreenList?: CaptureScreenItem[];
};
type DevInterceptOptions = {
event: DevEvent;
enableInterceptPromiseReject?: boolean;
};
type DevToolInfo = {
/** 是否销毁 */
devToolDestroy?: boolean;
/** 按钮状态 */
devToolButtonVisible?: boolean;
/** 窗口状态 */
devToolWindowVisible?: boolean;
/** 按钮位置 */
top?: string;
/** 按钮位置 */
left?: string;
/** 当前活动tab */
activeTab?: number;
/** 当前console类型 */
currentConsoleType?: string;
/** 当前network类型 */
currentNetworkType?: string;
/** 当前websocket类型 */
currentWebSocketType?: string;
/** table滚动位置 */
tabScrollLeft?: number;
};
}