vite-uni-dev-tool 0.0.48 → 1.0.0
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/README.md +20 -0
- package/dist/const.cjs +1 -0
- package/dist/const.d.ts +78 -161
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +1 -47
- package/dist/core-shared.d.ts +44 -0
- package/dist/core-shared.d.ts.map +1 -0
- package/dist/core-shared.js +1 -0
- package/dist/core.d.ts +2 -40
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +4 -159
- package/dist/i18n/index.cjs +1 -0
- package/dist/i18n/index.d.ts +9 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/instance.cjs +1 -0
- package/dist/i18n/instance.d.ts +15 -0
- package/dist/i18n/instance.d.ts.map +1 -0
- package/dist/i18n/instance.js +1 -0
- package/dist/i18n/locales/en.cjs +1 -0
- package/dist/i18n/locales/en.d.ts +470 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/en.js +1 -0
- package/dist/i18n/locales/zh-Hans.cjs +1 -0
- package/dist/i18n/locales/zh-Hans.d.ts +476 -0
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -0
- package/dist/i18n/locales/zh-Hans.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/devConsole/index.cjs +4 -0
- package/dist/{devConsole → modules/devConsole}/index.d.ts +1 -1
- package/dist/modules/devConsole/index.d.ts.map +1 -0
- package/dist/modules/devConsole/index.js +4 -0
- package/dist/modules/devEvent/index.cjs +5 -0
- package/dist/modules/devEvent/index.d.ts +115 -0
- package/dist/modules/devEvent/index.d.ts.map +1 -0
- package/dist/modules/devEvent/index.js +5 -0
- package/dist/modules/devIntercept/index.cjs +13 -0
- package/dist/modules/devIntercept/index.d.ts +71 -0
- package/dist/modules/devIntercept/index.d.ts.map +1 -0
- package/dist/modules/devIntercept/index.js +13 -0
- package/dist/modules/devStore/index.cjs +1 -0
- package/dist/modules/devStore/index.d.ts +159 -0
- package/dist/modules/devStore/index.d.ts.map +1 -0
- package/dist/modules/devStore/index.js +1 -0
- package/dist/modules/devToolInfo/index.cjs +1 -0
- package/dist/modules/devToolInfo/index.d.ts +27 -0
- package/dist/modules/devToolInfo/index.d.ts.map +1 -0
- package/dist/modules/devToolInfo/index.js +1 -0
- package/dist/plugins/uniDevTool/transform/transformApp.cjs +44 -0
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformApp.js +17 -17
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -0
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
- package/dist/plugins/uniDevTool/transform/transformVue.cjs +41 -0
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +1 -2
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformVue.js +32 -19
- package/dist/plugins/uniDevTool/uniDevTool.cjs +5 -0
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -11
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.cjs +19 -0
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.js +11 -19
- package/dist/plugins/uniParseStock/index.d.ts +10 -0
- package/dist/plugins/uniParseStock/index.d.ts.map +1 -0
- package/dist/plugins/utils/index.cjs +2 -0
- package/dist/plugins/utils/index.d.ts +1 -3
- package/dist/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +2 -2
- package/dist/shims-uni.d.ts +140 -0
- package/dist/type.d.ts +174 -16
- package/dist/type.d.ts.map +1 -1
- package/dist/utils/array.cjs +1 -0
- package/dist/utils/array.d.ts.map +1 -1
- package/dist/utils/array.js +1 -12
- package/dist/utils/date.cjs +1 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +1 -59
- package/dist/utils/file.cjs +1 -0
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +1 -85
- package/dist/utils/function.cjs +1 -0
- package/dist/utils/function.d.ts +13 -0
- package/dist/utils/function.d.ts.map +1 -1
- package/dist/utils/function.js +1 -68
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -63
- package/dist/utils/ip.cjs +1 -0
- package/dist/utils/ip.d.ts +1 -1
- package/dist/utils/ip.d.ts.map +1 -1
- package/dist/utils/ip.js +1 -45
- package/dist/utils/language.cjs +1 -0
- package/dist/utils/language.d.ts +2 -1
- package/dist/utils/language.d.ts.map +1 -1
- package/dist/utils/language.js +1 -63
- package/dist/utils/object.cjs +1 -0
- package/dist/utils/object.d.ts +4 -5
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/object.js +1 -136
- package/dist/utils/openLink.cjs +1 -0
- package/dist/utils/openLink.d.ts.map +1 -1
- package/dist/utils/openLink.js +1 -28
- package/dist/utils/page.cjs +1 -0
- package/dist/utils/page.d.ts.map +1 -1
- package/dist/utils/page.js +1 -7
- package/dist/utils/platform.cjs +1 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +1 -17
- package/dist/utils/string.cjs +1 -0
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js +1 -114
- package/dist/utils/utils.cjs +1 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +1 -126
- package/dist/v3/AppTransition/index.vue +170 -0
- package/dist/v3/AutoSizer/index.vue +4 -5
- package/dist/v3/AutoSizer/index1.vue +4 -6
- package/dist/v3/AutoSizer/utils.ts +1 -1
- package/dist/v3/CaptureScreen/index.vue +19 -8
- package/dist/v3/CircularButton/index.vue +64 -13
- package/dist/v3/ConsoleList/ConsoleItem.vue +56 -5
- package/dist/v3/ConsoleList/RunJSInput.vue +10 -6
- package/dist/v3/ConsoleList/index.vue +51 -35
- package/dist/v3/CustomSwiper/CustomSwiperItem.vue +49 -0
- package/dist/v3/CustomSwiper/index.vue +104 -0
- package/dist/v3/DevTool/fps-collector.render.ts +148 -0
- package/dist/v3/DevTool/index.vue +209 -102
- package/dist/v3/DevToolButton/index.vue +40 -59
- package/dist/v3/DevToolTitle/index.vue +4 -1
- package/dist/v3/DevToolWindow/DevToolOverlay.vue +182 -0
- package/dist/v3/DevToolWindow/const.ts +47 -69
- package/dist/v3/DevToolWindow/hooks/dataUtils.ts +48 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolData.ts +338 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolHandlers.ts +549 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolOverlay.ts +184 -0
- package/dist/v3/DevToolWindow/index.css +89 -0
- package/dist/v3/DevToolWindow/index.vue +800 -1450
- package/dist/v3/DraggableContainer/index.vue +456 -0
- package/dist/v3/ElEvent/ElEventItem.vue +4 -3
- package/dist/v3/ElEvent/index.vue +26 -9
- package/dist/v3/Empty/index.vue +1 -0
- package/dist/v3/FilterInput/index.vue +8 -22
- package/dist/v3/FilterSelect/index.vue +37 -24
- package/dist/v3/Instance/components/InstanceTreeNode.vue +265 -0
- package/dist/v3/Instance/flatten.ts +226 -0
- package/dist/v3/Instance/index.vue +94 -0
- package/dist/v3/Instance/registry.ts +49 -0
- package/dist/v3/Instance/transformTree.ts +375 -0
- package/dist/v3/Instance/transformTreeCtx.ts +268 -0
- package/dist/v3/{InstanceTree → Instance}/typing.d.ts +15 -2
- package/dist/v3/InstanceDetail/index.vue +433 -44
- package/dist/v3/JsonDetail/index.vue +12 -8
- package/dist/v3/JsonPretty/components/Brackets/index.vue +1 -0
- package/dist/v3/JsonPretty/components/Carets/index.vue +2 -1
- package/dist/v3/JsonPretty/components/CheckController/index.vue +26 -15
- package/dist/v3/JsonPretty/components/TreeNode/index.vue +42 -20
- package/dist/v3/JsonPretty/index.vue +60 -37
- package/dist/v3/JsonPretty/utils/index.ts +41 -44
- package/dist/v3/MovableContainer/index.vue +89 -0
- package/dist/v3/NFCList/NFCItem.vue +14 -14
- package/dist/v3/NFCList/NFCTool.vue +99 -81
- package/dist/v3/NFCList/index.vue +14 -10
- package/dist/v3/NetworkList/InterceptConfig.vue +154 -364
- package/dist/v3/NetworkList/InterceptItem.vue +14 -6
- package/dist/v3/NetworkList/NetworkDetail.vue +34 -29
- package/dist/v3/NetworkList/NetworkIntercept.vue +11 -8
- package/dist/v3/NetworkList/NetworkItem.vue +27 -11
- package/dist/v3/NetworkList/NetworkSend.vue +132 -290
- package/dist/v3/NetworkList/hooks/useNetworkForm.ts +86 -0
- package/dist/v3/NetworkList/index.vue +32 -24
- package/dist/v3/NetworkList/utils.ts +101 -0
- package/dist/v3/Performance/index.vue +495 -0
- package/dist/v3/Performance/modules/PerformanceMetrics.vue +153 -0
- package/dist/v3/Performance/modules/PerformanceWidget.vue +249 -0
- package/dist/v3/Performance/modules/usePerformanceChart.ts +460 -0
- package/dist/v3/Performance/modules/usePerformanceData.ts +258 -0
- package/dist/v3/Pick/index.vue +322 -0
- package/dist/v3/PiniaList/index.vue +38 -17
- package/dist/v3/RouteList/index.vue +32 -15
- package/dist/v3/RunJS/index.vue +30 -10
- package/dist/v3/ScanCodeList/ScanCodeItem.vue +2 -9
- package/dist/v3/ScanCodeList/index.vue +12 -9
- package/dist/v3/SettingButton/index.vue +45 -0
- package/dist/v3/SettingList/index.css +120 -0
- package/dist/v3/SettingList/index.vue +96 -537
- package/dist/v3/SettingList/modules/SettingDevTool.vue +208 -0
- package/dist/v3/SettingList/modules/SettingInfo.vue +119 -0
- package/dist/v3/SettingList/modules/SettingLanguage.vue +74 -0
- package/dist/v3/SettingList/modules/SettingLog.vue +230 -0
- package/dist/v3/SettingList/modules/SettingNetwork.vue +120 -0
- package/dist/v3/SettingList/modules/SettingTheme.vue +312 -0
- package/dist/v3/SourceCode/Line.vue +15 -2
- package/dist/v3/SourceCode/index.vue +25 -24
- package/dist/v3/SourceCode/parseCode.ts +114 -56
- package/dist/v3/StorageList/index.vue +33 -33
- package/dist/v3/Tabs/index.vue +31 -28
- package/dist/v3/Tag/index.vue +39 -20
- package/dist/v3/TransferList/TransferDetail.vue +268 -0
- package/dist/v3/TransferList/TransferItem.vue +125 -0
- package/dist/v3/TransferList/index.vue +181 -0
- package/dist/v3/UniEvent/UniEventItem.vue +1 -0
- package/dist/v3/UniEvent/index.vue +28 -29
- package/dist/v3/{VirtualListPro → VirtualList}/AutoSize.vue +1 -1
- package/dist/v3/VirtualList/index.vue +382 -82
- package/dist/v3/VuexList/index.vue +38 -17
- package/dist/v3/WebSocket/WebSocketDetail.vue +142 -80
- package/dist/v3/WebSocket/WebSocketItem.vue +10 -4
- package/dist/v3/WebSocket/index.vue +44 -30
- package/dist/v3/hooks/useNFC/index.ts +6 -6
- package/dist/v3/hooks/useNFC/typing.d.ts +2 -2
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +215 -626
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +54 -85
- package/dist/v3/hooks/useNFC/utils.ts +3 -3
- package/dist/v3/hooks/useRequest/index.ts +2 -2
- package/dist/v3/hooks/useScanCode/index.ts +10 -8
- package/dist/v3/styles/theme.css +290 -0
- package/dist/v3/styles/theme.ts +12 -0
- package/package.json +25 -5
- package/dist/devConsole/index.d.ts.map +0 -1
- package/dist/devConsole/index.js +0 -273
- package/dist/devEvent/index.d.ts +0 -328
- package/dist/devEvent/index.d.ts.map +0 -1
- package/dist/devEvent/index.js +0 -697
- package/dist/devEventBus/index.d.ts +0 -42
- package/dist/devEventBus/index.d.ts.map +0 -1
- package/dist/devEventBus/index.js +0 -70
- package/dist/devIntercept/index.d.ts +0 -281
- package/dist/devIntercept/index.d.ts.map +0 -1
- package/dist/devIntercept/index.js +0 -949
- package/dist/devRunJS/index.d.ts +0 -67
- package/dist/devRunJS/index.d.ts.map +0 -1
- package/dist/devStore/index.d.ts +0 -199
- package/dist/devStore/index.d.ts.map +0 -1
- package/dist/devStore/index.js +0 -562
- package/dist/devToolInfo/index.d.ts +0 -17
- package/dist/devToolInfo/index.d.ts.map +0 -1
- package/dist/devToolInfo/index.js +0 -15
- package/dist/v3/AutoSizer/utils.d.ts +0 -5
- package/dist/v3/AutoSizer/utils.d.ts.map +0 -1
- package/dist/v3/ConsoleList/staticTips.d.ts +0 -13
- package/dist/v3/ConsoleList/staticTips.d.ts.map +0 -1
- package/dist/v3/DevToolWindow/const.d.ts +0 -46
- package/dist/v3/DevToolWindow/const.d.ts.map +0 -1
- package/dist/v3/InstanceTree/components/InstanceTreeNode.vue +0 -81
- package/dist/v3/InstanceTree/flatten.d.ts +0 -10
- package/dist/v3/InstanceTree/flatten.d.ts.map +0 -1
- package/dist/v3/InstanceTree/flatten.ts +0 -75
- package/dist/v3/InstanceTree/index.vue +0 -51
- package/dist/v3/InstanceTree/transformTree.d.ts +0 -17
- package/dist/v3/InstanceTree/transformTree.d.ts.map +0 -1
- package/dist/v3/InstanceTree/transformTree.ts +0 -237
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +0 -4
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +0 -1
- package/dist/v3/JsonPretty/hooks/useError.d.ts +0 -8
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +0 -1
- package/dist/v3/JsonPretty/type.d.ts +0 -94
- package/dist/v3/JsonPretty/type.d.ts.map +0 -1
- package/dist/v3/JsonPretty/utils/index.d.ts +0 -10
- package/dist/v3/JsonPretty/utils/index.d.ts.map +0 -1
- package/dist/v3/NFCList/const.d.ts +0 -13
- package/dist/v3/NFCList/const.d.ts.map +0 -1
- package/dist/v3/NetworkList/const.d.ts +0 -5
- package/dist/v3/NetworkList/const.d.ts.map +0 -1
- package/dist/v3/SourceCode/parseCode.d.ts +0 -27
- package/dist/v3/SourceCode/parseCode.d.ts.map +0 -1
- package/dist/v3/UploadList/UploadDetail.vue +0 -255
- package/dist/v3/UploadList/UploadItem.vue +0 -122
- package/dist/v3/UploadList/index.vue +0 -125
- package/dist/v3/VirtualListPro/index.vue +0 -229
- package/dist/v3/hooks/useContainerStyle.d.ts +0 -15
- package/dist/v3/hooks/useContainerStyle.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/index.d.ts +0 -5
- package/dist/v3/hooks/useNFC/index.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts +0 -2
- package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts +0 -2
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/utils.d.ts +0 -95
- package/dist/v3/hooks/useNFC/utils.d.ts.map +0 -1
- package/dist/v3/hooks/useRequest/index.d.ts +0 -126
- package/dist/v3/hooks/useRequest/index.d.ts.map +0 -1
- package/dist/v3/hooks/useRequest/utils.d.ts +0 -35
- package/dist/v3/hooks/useRequest/utils.d.ts.map +0 -1
- package/dist/v3/hooks/useScanCode/index.d.ts +0 -36
- package/dist/v3/hooks/useScanCode/index.d.ts.map +0 -1
- /package/dist/v3/{VirtualListPro → VirtualList}/readme.md +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { DevStore } from '../devStore';
|
|
2
|
+
import { DevTool } from '../../type';
|
|
3
|
+
import { DevIntercept } from '../devIntercept';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 事件中心
|
|
7
|
+
*
|
|
8
|
+
* 使用两个主要通信通道:
|
|
9
|
+
* - DEV_CORE_MESSAGE: 核心模块 → UI 的消息
|
|
10
|
+
* - DEV_UI_MESSAGE: UI → 核心模块 的消息
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @class DevEvent
|
|
14
|
+
*/
|
|
15
|
+
export declare class DevEvent implements DevTool.DevEventInterface {
|
|
16
|
+
private store;
|
|
17
|
+
private intercept;
|
|
18
|
+
private abnormalUploadCount;
|
|
19
|
+
private abnormalUploadTimer;
|
|
20
|
+
private isAbnormalUploadActive;
|
|
21
|
+
private tapEventBound;
|
|
22
|
+
private throttleTouchStartEvent;
|
|
23
|
+
private throttleTouchMoveEvent;
|
|
24
|
+
private throttleTouchEndEvent;
|
|
25
|
+
private messageBound;
|
|
26
|
+
private isListening;
|
|
27
|
+
constructor({ store }: {
|
|
28
|
+
store: DevStore;
|
|
29
|
+
});
|
|
30
|
+
setIntercept(intercept: DevIntercept): void;
|
|
31
|
+
/**
|
|
32
|
+
* 向 UI 发送消息
|
|
33
|
+
*/
|
|
34
|
+
private emitToUI;
|
|
35
|
+
addEventListener(): void;
|
|
36
|
+
removeEventListener(): void;
|
|
37
|
+
createDevTool(info?: {
|
|
38
|
+
devToolVersion?: string;
|
|
39
|
+
devToolBuildTime?: string;
|
|
40
|
+
}): void;
|
|
41
|
+
destroyDevTool(): void;
|
|
42
|
+
restartDevTool(): void;
|
|
43
|
+
private postMessageFn;
|
|
44
|
+
postMessage: () => void | undefined;
|
|
45
|
+
openDevToolWindow(): void;
|
|
46
|
+
closeDevToolWindow(): void;
|
|
47
|
+
showDevToolButton(): void;
|
|
48
|
+
hideDevToolButton(): void;
|
|
49
|
+
sendDevToolOption(): void;
|
|
50
|
+
devToolScanCode(code: string, type: string): void;
|
|
51
|
+
devToolNFC(res: any): void;
|
|
52
|
+
private executeJS;
|
|
53
|
+
devRunJS(code: string): void;
|
|
54
|
+
addElEvent(item: DevTool.ElEventItem): void;
|
|
55
|
+
clearElEventList(): void;
|
|
56
|
+
private hasCaptureEvent;
|
|
57
|
+
private formatEventCoordinates;
|
|
58
|
+
private tapEvent;
|
|
59
|
+
private touchStartEvent;
|
|
60
|
+
private touchMoveEvent;
|
|
61
|
+
private touchEndEvent;
|
|
62
|
+
private addCaptureEventListener;
|
|
63
|
+
private removeCaptureEventListener;
|
|
64
|
+
getAbnormalData(): Promise<{
|
|
65
|
+
consoleList: DevTool.ConsoleItem[];
|
|
66
|
+
networkList: DevTool.NetworkItem[];
|
|
67
|
+
transferList: DevTool.TransferItem[];
|
|
68
|
+
elEventList: DevTool.ElEventItem[];
|
|
69
|
+
uniEventList: DevTool.UniEventItem[];
|
|
70
|
+
screenList: DevTool.ScreenItem[];
|
|
71
|
+
systemInfo: Record<string, any> | undefined;
|
|
72
|
+
deviceInfo: Record<string, any> | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
performAbnormalUpload(uploadAbnormalUV: DevTool.UploadAbnormalUV): Promise<void>;
|
|
75
|
+
uploadAbnormal(params?: {
|
|
76
|
+
immediately?: boolean;
|
|
77
|
+
}): void;
|
|
78
|
+
startAbnormalUpload(params?: {
|
|
79
|
+
immediately?: boolean;
|
|
80
|
+
}): void;
|
|
81
|
+
stopAbnormalUpload(): void;
|
|
82
|
+
updateConsoleList(items: DevTool.ConsoleItem[], index?: number): void;
|
|
83
|
+
updateNetworkList(items: DevTool.NetworkItem[], index?: number): void;
|
|
84
|
+
updateWsList(item: DevTool.WS): void;
|
|
85
|
+
addWsTask(url: string, task: any): void;
|
|
86
|
+
removeWsTask(url: string): void;
|
|
87
|
+
updateStorage(items: DevTool.StorageItem[]): void;
|
|
88
|
+
updateTransfer(items: DevTool.TransferItem[], index?: number): void;
|
|
89
|
+
updateUniEvent(items: DevTool.UniEventItem[]): void;
|
|
90
|
+
updateScreen(items: DevTool.ScreenItem[], index?: number): void;
|
|
91
|
+
updateScanCode(items: DevTool.ScanCodeItem[]): void;
|
|
92
|
+
updateNfc(items: DevTool.NFCItem[]): void;
|
|
93
|
+
updateRouteList(path?: string): void;
|
|
94
|
+
updateUniEventCount(type: DevTool.EventCountKey): void;
|
|
95
|
+
getInterceptNetworkMap(): Map<string, DevTool.NetworkItem>;
|
|
96
|
+
getRequestIndex(): number;
|
|
97
|
+
setRequestIndex(index: number): number;
|
|
98
|
+
getDevToolDestroy(): boolean;
|
|
99
|
+
getDevToolOptions(): DevTool.DevToolOptions | undefined;
|
|
100
|
+
setVuexList(list: Record<string, any>): void;
|
|
101
|
+
setVueStore(store: any): void;
|
|
102
|
+
setPiniaList(list: Record<string, any>): void;
|
|
103
|
+
setPiniaStore(piniaStore: any): void;
|
|
104
|
+
clearStorage(local?: boolean): void;
|
|
105
|
+
removeStorage(key: string, local?: boolean): void;
|
|
106
|
+
addTransferTask(index: number | string, task: any): void;
|
|
107
|
+
removeTransferTask(index: number | string): void;
|
|
108
|
+
exportLog(data: any): void;
|
|
109
|
+
sendWsMessage(url: string, message: any): void;
|
|
110
|
+
restartApp(): void;
|
|
111
|
+
private handleUIMessage;
|
|
112
|
+
/** 向后兼容 */
|
|
113
|
+
acceptMessage(): void;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/devEvent/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{DEV_CORE_MESSAGE as D,DEV_UI_MESSAGE as S,MSG_TYPE as h,DEV_CAPTURE_TAP_EVENT as _,DEV_CAPTURE_TOUCH_START as L,DEV_CAPTURE_TOUCH_MOVE as C,DEV_CAPTURE_TOUCH_END as b,CMD_TYPE as o}from"../../const.js";import"../../utils/index.js";import{throttle as g}from"../../utils/function.js";import{serializeCircular as O,calculateObjectSize as A,formatStorageSize as R,parseValue as I}from"../../utils/object.js";import{getCurrentPagePath as p}from"../../utils/page.js";import{getCurrentDate as M}from"../../utils/date.js";import{transformValueToView as k,transformValueToShortString as y}from"../../utils/language.js";import{saveTextFileMicro as U,saveTextFileH5 as N,saveTxtFileApp as w}from"../../utils/file.js";class H{constructor({store:t}){this.abnormalUploadCount=0,this.abnormalUploadTimer=null,this.isAbnormalUploadActive=!1,this.isListening=!1,this.postMessage=g(()=>{this.postMessageFn()},2e3),this.store=t,this.messageBound=e=>{try{const s=typeof e=="string"?JSON.parse(e):e;this.handleUIMessage(s)}catch(s){console.error("[DevEvent] Failed to parse UI message",s)}},this.tapEventBound=this.tapEvent.bind(this),this.throttleTouchStartEvent=g(this.touchStartEvent.bind(this),1e3),this.throttleTouchMoveEvent=g(this.touchMoveEvent.bind(this),1e3),this.throttleTouchEndEvent=g(this.touchEndEvent.bind(this),1e3)}setIntercept(t){this.intercept=t}emitToUI(t,e={}){try{const s=O({type:t,data:e});if(s.length>500*1024){console.warn(`[DevTool] Data too large to emit (${(s.length/1024).toFixed(2)}KB). Dropped to prevent crash.`),uni.$emit(D,JSON.stringify({type:t,data:{_warning:"Data too large, transmission dropped.",size:s.length}}));return}uni.$emit(D,s)}catch(s){console.error("[DevTool] emitToUI serialize error",s);try{uni.$emit(D,JSON.stringify({type:t,data:{}}))}catch{}}}addEventListener(){this.isListening||(uni.$on(S,this.messageBound),this.addCaptureEventListener(),this.isListening=!0)}removeEventListener(){this.isListening&&(uni.$off(S,this.messageBound),this.removeCaptureEventListener(),this.isListening=!1)}createDevTool(t){var s;if(!this.store.getDevToolDestroy()){console.log("[DevTool] 调试器已创建,不再创建");return}const e=this.store.getDevToolOptions();(s=this.intercept)==null||s.init({enableCaptureScreen:e==null?void 0:e.enableCaptureScreen,enableInterceptPromiseReject:e==null?void 0:e.enableInterceptPromiseReject}),this.store.setDevToolDestroy(!1),this.store.updateRouteList(),this.emitToUI(h.BUTTON_VISIBLE,!0),this.store.setDevToolVisible(!0),setTimeout(()=>{console.log(`[DevTool] 创建成功
|
|
2
|
+
当前版本:${t==null?void 0:t.devToolVersion}
|
|
3
|
+
构建时间:${t==null?void 0:t.devToolBuildTime}
|
|
4
|
+
一处编写,到处调试 😂`)},500),this.addEventListener(),this.postMessage()}destroyDevTool(){var t;this.store.getDevToolDestroy()||(this.emitToUI(h.BUTTON_VISIBLE,!1),this.store.setDevToolVisible(!1),this.emitToUI(h.WINDOW_VISIBLE,!1),this.store.setRequestIndex(-1),this.store.setTransferIndex(-1),this.store.setDevToolDestroy(!0),this.store.clearAll(),(t=this.intercept)==null||t.reset(),this.removeEventListener(),console.log("[DevTool] 调试器已销毁"))}restartDevTool(){this.destroyDevTool(),this.createDevTool({devToolBuildTime:this.store.devToolBuildTime,devToolVersion:this.store.devToolVersion}),this.emitToUI(h.WINDOW_VISIBLE,!0)}async postMessageFn(){if(this.store.getDevToolDestroy())return;const t=await this.store.getDevData(),e=A(t),s=R(e);t.size=e,t.sizeFormat=s,this.emitToUI(h.DATA_UPDATE,t),e>this.store.cacheMaxSize&&this.store.clearDevCache()}openDevToolWindow(){this.store.getDevToolDestroy()||(setTimeout(()=>this.postMessage(),100),this.emitToUI(h.WINDOW_VISIBLE,!0))}closeDevToolWindow(){this.store.getDevToolDestroy()||this.emitToUI(h.WINDOW_VISIBLE,!1)}showDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(h.BUTTON_VISIBLE,!0),this.store.setDevToolVisible(!0))}hideDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(h.BUTTON_VISIBLE,!1),this.store.setDevToolVisible(!1))}sendDevToolOption(){const t=this.store.getDevToolOptions();this.emitToUI(h.OPTION_UPDATE,t)}devToolScanCode(t,e){this.updateScanCode([{timer:Date.now(),result:t,scanType:e,charSet:"",rawData:"",errMsg:"",path:p()}])}devToolNFC(t){this.updateNfc([{timer:Date.now(),path:p(),...t}])}executeJS(t){const e="_e_v_a_l_".replace(/_/g,""),s="_e_v_a_l_F_n_".replace(/_/g,"");if(globalThis!=null&&globalThis[s])return Promise.resolve(globalThis==null?void 0:globalThis[s](t));if(globalThis!=null&&globalThis[e])return Promise.resolve(globalThis==null?void 0:globalThis[e](t));throw new Error("[DevTool] DevRunJS 当前环境不支持执行js")}devRunJS(t){var n,l;const e=(l=(n=new Error)==null?void 0:n.stack)==null?void 0:l.split(`
|
|
5
|
+
`),s=e==null?void 0:e[1],i=Date.now(),a={type:"log",args:[{type:"string",value:t}],position:p(),time:M(),stack:s,mode:"input"};this.updateConsoleList([{...a}]),this.executeJS(t).then(u=>{const c=k(u),d=I(u),v=c==="object"||c==="array"?y(d,c):"";a.args=[{type:c,value:d,shortValue:v}],a.time=M(),a.mode="output",a.executionTime=Date.now()-i,this.updateConsoleList([{...a}])})}addElEvent(t){this.store.addElEvent(t),this.postMessage()}clearElEventList(){this.store.clearElEventList(),this.postMessage()}hasCaptureEvent(t){const{includeCaptureElDataSet:e=[],excludeCaptureElDataSet:s=[]}=this.store.getDevToolOptions()??{includeCaptureElDataSet:[],excludeCaptureElDataSet:[]};return e&&e.length?e.some(i=>{var a;return Object.keys(((a=t==null?void 0:t.target)==null?void 0:a.dataset)??{}).includes(i)}):s&&s.length?!s.some(i=>{var a;return Object.keys(((a=t==null?void 0:t.target)==null?void 0:a.dataset)??{}).includes(i)}):!0}formatEventCoordinates(t){return!t||!Array.isArray(t)?t:t.map(e=>{const s={...e};return["clientX","clientY","pageX","pageY","x","y"].forEach(i=>{typeof e[i]=="number"&&(s[i]=parseFloat(e[i].toFixed(2)))}),s})}tapEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchStartEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchMoveEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchEndEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}addCaptureEventListener(){var e;const t=((e=this.store.getDevToolOptions())==null?void 0:e.captureList)??[];t.includes("tap")&&uni.$on(_,this.tapEventBound),t.includes("touchstart")&&uni.$on(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$on(C,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$on(b,this.throttleTouchEndEvent)}removeCaptureEventListener(){var e;const t=((e=this.store.getDevToolOptions())==null?void 0:e.captureList)??[];t.includes("tap")&&uni.$off(_,this.tapEventBound),t.includes("touchstart")&&uni.$off(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$off(C,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$off(b,this.throttleTouchEndEvent)}async getAbnormalData(){var u,c,d,m,v,f;const t=await this.store.getDevData(),e=((u=t.consoleList)==null?void 0:u.filter(r=>["error","warn"].includes(r.type)&&!r.hasUpload))??[],s=((c=t.networkList)==null?void 0:c.filter(r=>{var T,E;return r.sponsor==="user"&&!((E=(T=r.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!r.hasUpload}))??[],i=((d=t.transferList)==null?void 0:d.filter(r=>{var T,E;return!((E=(T=r.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!r.hasUpload}))??[],a=((m=t.elEventList)==null?void 0:m.filter(r=>!r.hasUpload))??[],n=((v=t.uniEventList)==null?void 0:v.filter(r=>!r.hasUpload))??[],l=((f=t.screenList)==null?void 0:f.filter(r=>!r.hasUpload))??[];return{consoleList:e,networkList:s,transferList:i,elEventList:a,uniEventList:n,screenList:l,systemInfo:t.systemInfo,deviceInfo:t.deviceInfo}}async performAbnormalUpload(t){const{consoleList:e,networkList:s,transferList:i,systemInfo:a,elEventList:n,uniEventList:l,screenList:u,deviceInfo:c}=await this.getAbnormalData();e.length||s.length||i.length||n.length||l.length||u.length?uni.request({method:"POST",url:t.url,header:{...(t==null?void 0:t.header)??{},"dev-tool-sponsor":Date.now()},timeout:(t==null?void 0:t.timerOut)??3*1e3,data:{...(t==null?void 0:t.payload)??{},consoleList:e,networkList:s,transferList:i,elEventList:n,uniEventList:l,screenList:u,deviceInfo:c,systemInfo:a,platform:uni.__dev_tool_platform__},success:()=>{this.store.updateHasUpload(),this.uploadAbnormal(),this.abnormalUploadCount=0},fail:()=>{this.uploadAbnormal(),this.abnormalUploadCount++}}):this.uploadAbnormal()}uploadAbnormal(t){if(!this.isAbnormalUploadActive)return;const{uploadAbnormalUV:e}=this.store.getDevToolOptions()??{uploadAbnormalUV:{url:"",header:{},payload:{},duration:10*1e3,timerOut:3*1e3}};if(!(e!=null&&e.url))return;const s=e.duration??10*1e3,i=5*60*1e3,a=Math.min(s*Math.pow(2,this.abnormalUploadCount),i),n=Math.max(a,s);this.abnormalUploadTimer&&clearTimeout(this.abnormalUploadTimer),t!=null&&t.immediately?this.performAbnormalUpload(e):this.abnormalUploadTimer=setTimeout(()=>{this.performAbnormalUpload(e)},n)}startAbnormalUpload(t){this.isAbnormalUploadActive=!0,this.abnormalUploadCount=0,this.uploadAbnormal(t)}stopAbnormalUpload(){this.isAbnormalUploadActive=!1,this.abnormalUploadTimer&&(clearTimeout(this.abnormalUploadTimer),this.abnormalUploadTimer=null)}updateConsoleList(t,e){this.store.updateConsoleList(t,e),this.postMessage()}updateNetworkList(t,e){this.store.updateNetworkList(t,e),this.postMessage()}updateWsList(t){this.store.updateWsList(t),this.postMessage()}addWsTask(t,e){this.store.addWsTask(t,e)}removeWsTask(t){this.store.removeWsTask(t)}updateStorage(t){this.store.updateStoreList(t),this.postMessage()}updateTransfer(t,e){this.store.updateTransferList(t,e),this.postMessage()}updateUniEvent(t){this.store.updateUniEventList(t),this.postMessage()}updateScreen(t,e){this.store.updateScreenList(t,e),this.postMessage()}updateScanCode(t){this.store.updateScanCodeList(t),this.postMessage()}updateNfc(t){this.store.updateNfcList(t),this.postMessage()}updateRouteList(t){this.store.updateRouteList(t),this.postMessage()}updateUniEventCount(t){this.store.updateUniEventCount(t),this.postMessage()}getInterceptNetworkMap(){return this.store.getInterceptNetworkMap()}getRequestIndex(){return this.store.getRequestIndex()}setRequestIndex(t){return this.store.setRequestIndex(t)}getDevToolDestroy(){return this.store.getDevToolDestroy()}getDevToolOptions(){return this.store.getDevToolOptions()}setVuexList(t){this.store.setVuexList(t),this.postMessage()}setVueStore(t){this.store.setVuexStore(t)}setPiniaList(t){this.store.setPiniaList(t),this.postMessage()}setPiniaStore(t){this.store.setPiniaStore(t)}clearStorage(t){this.store.clearStorageList(t),this.postMessage()}removeStorage(t,e){this.store.removeStorage(t,e),this.postMessage()}addTransferTask(t,e){this.store.addTransferTask(t,e),this.postMessage()}removeTransferTask(t){this.store.removeTransferTask(t),this.postMessage()}exportLog(t){const e=this.store.getExportData(t),s=JSON.stringify(e,null,2),i="dev-tool-log";switch(uni.__dev_tool_platform__){case"app":w(s,i);break;case"web":N(s,i);break;case"mp-weixin":case"mp-alipay":case"mp-toutiao":U(s,i);break}}sendWsMessage(t,e){const s=this.store.getWsTask(t);if(s)s.send({data:e});else{const i=k(e),a=I(e),l=i==="object"||i==="array"?y(a,i):typeof e=="string"?e.slice(0,50):String(e);this.updateWsList({url:t,readyState:"closed",message:[{value:a,valueType:i,shortValue:l,status:"error",time:Date.now(),type:"send"}]})}}restartApp(){switch(uni.__dev_tool_platform__){case"app":plus.runtime.restart();break;case"web":window.location.reload();break;case"mp-weixin":try{wx!=null&&wx.restartMiniProgram&&wx.restartMiniProgram({path:"/"+p()})}catch{}break}}handleUIMessage(t){const{type:e,data:s}=t;switch(e){case o.CONSOLE_CLEAR:this.store.clearConsoleList();break;case o.NETWORK_CLEAR:this.store.clearInterceptNetworkList(),this.postMessage();break;case o.INTERCEPT_UPDATE:this.store.updateInterceptNetworkList(s);break;case o.WS_CLEAR:this.store.clearWsList(),this.postMessage();break;case o.WS_CLEAR_MESSAGE:this.store.clearWsMessage(s.url),this.postMessage();break;case o.WS_SEND:this.sendWsMessage(s.url,s.message);break;case o.TRANSFER_CLEAR:this.store.updateTransferList([]),this.postMessage();break;case o.STORAGE_CLEAR:this.store.clearStorageList(!0),this.postMessage();break;case o.STORAGE_REFRESH:this.store.refreshStore(),this.postMessage();break;case o.STORAGE_REMOVE:this.store.removeStorage(s.key,!0),this.postMessage();break;case o.STORAGE_ADD:this.store.addStorage(s,!0),this.postMessage();break;case o.STORAGE_UPDATE:this.store.updateStore(s),this.postMessage();break;case o.VUEX_CHANGE:this.store.updateVuexStore(s),this.postMessage();break;case o.PINIA_CHANGE:this.store.updatePiniaStore(s),this.postMessage();break;case o.EL_EVENT_CLEAR:this.clearElEventList();break;case o.UNI_EVENT_CLEAR:this.store.clearUniEventList(),this.postMessage();break;case o.SCAN_CODE_CLEAR:this.store.clearScanCodeList();break;case o.NFC_CLEAR:this.store.clearNfcList();break;case o.SCREEN_CLEAR:break;case o.BUTTON_TOGGLE:s.show?this.showDevToolButton():this.hideDevToolButton(),this.postMessage();break;case o.WINDOW_OPEN:this.openDevToolWindow();break;case o.WINDOW_CLOSE:this.closeDevToolWindow();break;case o.RESTART_DEBUGGER:this.restartDevTool();break;case o.RESTART_APP:this.restartApp();break;case o.DESTROY:this.destroyDevTool();break;case o.EXPORT_LOG:this.exportLog(s);break;case o.RUN_JS:this.devRunJS(s.code);break;case o.ROUTE_REFRESH:this.postMessage();break;case o.OPTION_GET:this.sendDevToolOption();break;case o.CACHE_CLEAR:this.store.clearDevCache();break;case o.SET_CACHE_INTERCEPT:this.store.setCacheInterceptConfig(s.cacheInterceptConfig);break;case o.SET_CACHE_NETWORK_LOG:this.store.setCacheNetworkLog(s.cacheNetworkLog);break;case o.SET_CACHE_CONSOLE_LOG:this.store.setCacheConsoleLog(s.cacheConsoleLog);break;case o.SET_TRANSITION:this.store.setUseTransition(s.useTransition);break;case o.SET_FONT:this.store.setBaseFontSize(s.baseFontSize),this.store.setTagFontSize(s.tagFontSize),this.store.setTipsFontSize(s.tipsFontSize),this.store.setFontFamily(s.fontFamily),this.store.setFontWeight(s.fontWeight),this.postMessage();break;case o.TAB_CHANGE:this.closeDevToolWindow(),this.updateRouteList(s.path);break}}acceptMessage(){this.addEventListener()}}export{H as DevEvent};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../core-shared.cjs"),W=require("../../const.cjs");require("../../utils/index.cjs");const v=require("../../utils/date.cjs"),I=require("../../utils/page.cjs"),C=require("../../utils/language.cjs"),_=require("../../utils/object.cjs"),M=require("../../utils/string.cjs");class N{constructor(e){this.initPinia=!1,this.captureScreen=r=>{if(!this.hooks.getDevToolDestroy()){const t=this.hooks.getScreenIndex(),o=this.hooks.setScreenIndex(t+1);this.hooks.updateScreen([{index:o,position:I.getCurrentPagePath(),startTime:v.getCurrentDate(),endTime:v.getCurrentDate(),type:"captureScreen",path:(r==null?void 0:r.path)??""}])}},this.hooks=e.hooks,typeof uni<"u"&&(uni.$on(W.DEV_TOOL_ON_INIT,r=>this.init(r)),uni.$on(W.DEV_TOOL_ON_DESTROY,()=>this.reset()))}safeDefineProperty(e,r,t){if(!e)return!1;try{const o=Object.getOwnPropertyDescriptor(e,r);return o&&o.configurable===!1?(console.warn(`[DevTool] ${r} 属性不可配置,已跳过拦截`),!1):(Object.defineProperty(e,r,{...t,configurable:!0}),!0)}catch(o){return console.warn(`[DevTool] 拦截 ${r} 失败,环境可能受限:`,o),!1}}init({enableCaptureScreen:e,enableInterceptPromiseReject:r}){this.enableCaptureScreen=e,this.enableInterceptPromiseReject=r,this.interceptAppConsole(),this.interceptAppError(),this.interceptSetStorage(),this.interceptRemoveStorage(),this.interceptClearStorage(),this.interceptRequest(),this.interceptSocket(),this.interceptUploadFile(),this.interceptDownloadFile(),this.interceptSwitchTab(),this.interceptRedirectTo(),this.interceptReLaunch(),this.interceptNavigateBack(),this.interceptNavigateTo(),this.interceptUniEvent(),this.interceptScanCode(),this.enableCaptureScreen&&this.interceptCaptureScreen(),this.interceptScreenRecording(),this.enableInterceptPromiseReject&&this.interceptPromiseReject()}reset(){this.resetInterceptAppConsole(),this.resetInterceptErrorApp(),this.resetInterceptPromiseReject(),this.resetInterceptStorage(),this.resetInterceptRemoveStorage(),this.resetInterceptClearStorage(),this.resetInterceptRequest(),this.resetInterceptSocket(),this.resetInterceptUploadFile(),this.resetInterceptDownloadFile(),this.resetInterceptSwitchTab(),this.resetInterceptRedirectTo(),this.resetInterceptReLaunch(),this.resetInterceptNavigateBack(),this.resetInterceptNavigateTo(),this.resetUniEvent(),this.resetInterceptScanCode(),this.enableCaptureScreen&&this.resetInterceptCaptureScreen(),this.resetInterceptScreenRecording()}interceptAppConsole(){if(!uni.__log__)return;const e=this;this.safeDefineProperty(uni,"__log__",{writable:!1,value:function(r,t,...o){d.backup.__log__(r,t,...o);const n=I.getCurrentPagePath();e.hooks.updateConsole([{type:r,position:n,time:v.getCurrentDate(),args:o.map(c=>{const l=C.transformValueToView(c),a=_.parseValue(c),f=l==="object"||l==="array"?C.transformValueToShortString(a,l):"";return{type:l,value:a,shortValue:f}}),stack:t}])}})}resetInterceptAppConsole(){uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!0,value:d.backup.__log__})}interceptVue(e){if(!e)return;const r=(o,n,c)=>{this.hooks.getDevToolDestroy()||this.interceptErrorVue(o)},t=(o,n,c)=>{this.hooks.getDevToolDestroy()||this.interceptWarnVue(o+`
|
|
2
|
+
`+c)};e.appContext?(e.appContext.config.errorHandler=r,e.appContext.config.warnHandler=t):(e.config.errorHandler=r,e.config.warnHandler=t)}interceptAppError(){uni.onError(e=>{var o,n;if(this.hooks.getDevToolDestroy())return;const r=e.toString(),t=((n=(o=e==null?void 0:e.stack)==null?void 0:o.split(`
|
|
3
|
+
`))==null?void 0:n[1])??"";this.hooks.updateConsole([{type:"error",args:[{type:"string",value:r}],position:I.getCurrentPagePath(),time:v.getCurrentDate(),stack:t}])})}resetInterceptErrorApp(){uni.onError(()=>{})}interceptErrorVue(e){var o;const r=(o=e==null?void 0:e.stack)==null?void 0:o.split(`
|
|
4
|
+
`),t=r==null?void 0:r[1];console.error(e),this.hooks.updateConsole([{type:"error",args:[{type:"string",value:e.toString()}],position:I.getCurrentPagePath(),time:v.getCurrentDate(),stack:t}])}interceptWarnVue(e){var c,l,a,h;if(this.preWarn===e)return;this.preWarn=e;const r=I.getCurrentPagePath(),t=(l=(c=new Error)==null?void 0:c.stack)==null?void 0:l.split(`
|
|
5
|
+
`),o=(a=t==null?void 0:t.slice(2))==null?void 0:a[0];console.warn(e);const n=(h=e.split(`
|
|
6
|
+
`))==null?void 0:h.map(f=>M.escapeHTML(f)).join(`
|
|
7
|
+
`);this.hooks.updateConsole([{type:"warn",args:[{type:"string",value:n}],position:r,time:v.getCurrentDate(),stack:o}])}interceptPromiseReject(){const e=this;this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(r){var n,c;const t=r.toString(),o=((c=(n=r==null?void 0:r.stack)==null?void 0:n.split(`
|
|
8
|
+
`))==null?void 0:c[1])??"";return e.hooks.updateConsole([{type:"error",args:[{type:"string",value:t}],position:I.getCurrentPagePath(),time:v.getCurrentDate(),stack:o}]),d.backup.reject.call(Promise,r)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return d.backup.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(r,t){d.backup.setStorageSync(r.toString(),t),e.hooks.updateStorage([{key:r.toString(),_oldKey:r.toString(),value:t}])}}),uni.addInterceptor("setStorage",{invoke(r){const t=r.complete;r.complete=function(o){var n,c;t&&t(o),e.hooks.updateStorage([{key:(n=r.key)==null?void 0:n.toString(),_oldKey:(c=r.key)==null?void 0:c.toString(),value:r.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:d.backup.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){d.backup.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(r){d.backup.removeStorageSync(r),e.hooks.removeStorage(r)}}),uni.addInterceptor("removeStorage",{invoke(r){const t=r.complete;r.complete=function(o){t&&t(o),e.hooks.removeStorage(r.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var t;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(t=e==null?void 0:e.subscribe)==null||t.call(e,(o,n)=>{this.hooks.setVuexList(n)}))}interceptPiniaStore(e){var t;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(t=e==null?void 0:e.store)==null||t.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(r){var P,E,w,j,q,F,V;const t=e.hooks.getRequestIndex(),o=e.hooks.setRequestIndex(t+1),n=r.url,c=(P=n==null?void 0:n.split("?"))==null?void 0:P[0],l=c==null?void 0:c.lastIndexOf("/"),a=(c==null?void 0:c.slice(l+1))??"",h=(w=(E=new Error)==null?void 0:E.stack)==null?void 0:w.split(`
|
|
9
|
+
`),f=uni.__dev_tool_platform__==="app"?h==null?void 0:h[2]:h==null?void 0:h[5],i=e.hooks.getInterceptNetworkMap(),s=`${(j=r.method)==null?void 0:j.toUpperCase()}|${c}`,u=i==null?void 0:i.get(s),g=Object.keys(r.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";r.header={..._.omit(r.header,["dev-tool-sponsor"])};const p={index:o,stack:f,url:r.url,name:a,startTime:Date.now(),endTime:0,time:"-",headers:{requestHeader:Object.entries(r.header??{}).map(([S,D])=>({key:S,value:D})),responseHeader:[]},method:r.method||"GET",status:"pending",payload:r!=null&&r.data?JSON.stringify(r.data):"",response:{data:void 0,statusCode:0,header:{},cookies:[],errMsg:""},size:"",sponsor:g};u&&(p.headers.requestHeader={...p.headers.requestHeader,...u.headers.requestHeader},p.payload={...u.payload},p.intercepted=!0,Object.assign(r,{timeout:u.timeout})),e.hooks.updateNetwork([p]);const k={errMsg:""};let T=!0;u&&(k.statusCode=u.status,(F=(q=u==null?void 0:u.status)==null?void 0:q.toString())!=null&&F.startsWith("2")?(T=!0,k.errMsg="request:ok",k.header=(V=u.headers.responseHeader)==null?void 0:V.reduce((S,D)=>({...S,[D.key]:D.value}),{}),k.data=u.response.data):(T=!1,k.errMsg="request:fail"));const m=r.fail,y=r.success,b=r.complete;r.fail=function(S){u?T?y==null||y(k):m==null||m(k):m==null||m(S)},r.success=function(S){u?T?y==null||y(k):m==null||m(k):y==null||y(S)},r.complete=function(S){var x,H;const D=Date.now()-p.startTime;p.time=D<1e3?D+"ms":D/1e3+"s",p.endTime=Date.now();const R=((x=S==null?void 0:S.header)==null?void 0:x["Content-Length"])||((H=S==null?void 0:S.header)==null?void 0:H["content-length"])||0;p.size=R>1024?(R/1024).toFixed(2)+"k":R+"b",u?(b==null||b(k),p.status=u.status,p.response=k,p.headers.responseHeader=u.headers.responseHeader):(b==null||b(S),p.status=S.statusCode??"error",p.response=S,p.headers.responseHeader=Object.entries(S.header??{}).map(([$,B])=>({key:$,value:B}))),e.hooks.updateNetwork([p],o)}}})}resetInterceptRequest(){uni.removeInterceptor("request")}interceptSocket(){const e=this,r=function(t){const o=t.url,n=Object.entries(t.header??{}).map(([s,u])=>({key:s,value:u})),c=(t.method??"GET").toLowerCase(),l=t.protocols??[];e.hooks.updateWs({url:o,headers:n,method:c,protocols:l,readyState:"connection",message:[]});const a=d.backup.connectSocket({...t,multiple:!0,complete:s=>{var u;(u=t==null?void 0:t.complete)==null||u.call(t,s)}});e.hooks.addWsTask(o,a);function h(s,u,g,p){let k=s;if(typeof s=="string")try{const P=JSON.parse(s);typeof P=="object"&&P!==null&&(k=P)}catch{}const T=C.transformValueToView(k),m=_.parseValue(k),b=T==="object"||T==="array"?C.transformValueToShortString(m,T):"";e.hooks.updateWs({url:o,readyState:g,headers:n,protocols:l,message:[{value:m,valueType:T,shortValue:b,status:p,time:Date.now(),type:u}]})}const f=a.send;a.send=s=>{let u=s.data;if(typeof u=="object"&&u!==null)try{u=JSON.stringify(u)}catch{}f.call(a,{...s,data:u,fail:g=>{var p;(p=s==null?void 0:s.fail)==null||p.call(s,g),h(s.data,"send","error","error")},success:g=>{var p;(p=s==null?void 0:s.success)==null||p.call(s,g),h(s.data,"send","open","success")},complete:g=>{var p;(p=s==null?void 0:s.complete)==null||p.call(s,g)}})};const i=a.close;return a.close=s=>{e.hooks.updateWs({url:o,readyState:"closing",headers:n,protocols:l,message:[]}),i.call(a,{...s,fail:u=>{var g;(g=s==null?void 0:s.fail)==null||g.call(s,u),h(u,"send","closing","error")},success:u=>{var g;(g=s==null?void 0:s.success)==null||g.call(s,u),h(u,"send","closed","success")},complete:u=>{var g;(g=s==null?void 0:s.complete)==null||g.call(s,u)}})},a.onOpen(()=>{e.hooks.updateWs({url:o,readyState:"open",headers:n,protocols:l,message:[]})}),a.onError(s=>{h(s,"receive","error","error")}),a.onMessage(s=>{h(s.data,"receive","open","success")}),a.onClose(s=>{h(s,"receive","closed","success"),e.hooks.removeWsTask(o)}),a};this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:r})}resetInterceptSocket(){this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:d.backup.connectSocket})}interceptUploadFile(){const e=this,r=t=>{var h,f;const o=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(o+1),c=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
10
|
+
`),l=c==null?void 0:c[2];e.hooks.updateTransfer([{index:n,type:"upload",stack:l,name:t.name,url:t.url,filePath:t.filePath,fileType:t.fileType,headers:{requestHeader:Object.entries(t.header||{}).map(([i,s])=>({key:i,value:s})),responseHeader:[]},formData:t.formData,status:"pending",progress:0,totalBytesSent:0,totalBytesExpectedToSend:0,startTime:Date.now()}],n);const a=d.backup.uploadFile({...t,success:i=>{var s;(s=t==null?void 0:t.success)==null||s.call(t,i),e.hooks.updateTransfer([{index:n,type:"upload",status:"success",endTime:Date.now(),response:{...i,data:JSON.parse(i.data)}}],n),e.hooks.removeTransferTask(n)},fail:i=>{var s;(s=t==null?void 0:t.fail)==null||s.call(t,i),e.hooks.updateTransfer([{index:n,type:"upload",status:"error",response:i,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return a.onProgressUpdate(i=>{e.hooks.updateTransfer([{index:n,type:"upload",progress:i.progress,totalBytesSent:i.totalBytesSent,totalBytesExpectedToSend:i.totalBytesExpectedToSend,status:"uploading"}],n)}),e.hooks.addTransferTask(n,a),a};this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:r})}resetInterceptUploadFile(){this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:d.backup.uploadFile})}interceptDownloadFile(){const e=this,r=t=>{var h,f;const o=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(o+1),c=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
11
|
+
`),l=c==null?void 0:c[2];e.hooks.updateTransfer([{index:n,type:"download",stack:l,url:t.url,filePath:t.filePath,headers:{requestHeader:Object.entries(t.header||{}).map(([i,s])=>({key:i,value:s})),responseHeader:[]},status:"pending",progress:0,totalBytesWritten:0,totalBytesExpectedToWrite:0,startTime:Date.now()}],n);const a=d.backup.downloadFile({...t,success:i=>{var s;(s=t==null?void 0:t.success)==null||s.call(t,i),e.hooks.updateTransfer([{index:n,type:"download",status:"success",endTime:Date.now(),response:{...i,statusCode:i.statusCode,tempFilePath:i.tempFilePath}}],n),e.hooks.removeTransferTask(n)},fail:i=>{var s;(s=t==null?void 0:t.fail)==null||s.call(t,i),e.hooks.updateTransfer([{index:n,type:"download",status:"error",response:i,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return a.onProgressUpdate(i=>{e.hooks.updateTransfer([{index:n,type:"download",progress:i.progress,totalBytesWritten:i.totalBytesWritten,totalBytesExpectedToWrite:i.totalBytesExpectedToWrite,status:"downloading"}],n)}),e.hooks.addTransferTask(n,a),a};this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:r})}resetInterceptDownloadFile(){this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:d.backup.downloadFile})}interceptRouterMethod(e){const r=this;uni.addInterceptor(e,{invoke(t){const o=t.complete;t.complete=function(n){var l,a,h;o==null||o(n);const c=((h=(a=(l=t.url)==null?void 0:l.slice(1))==null?void 0:a.split("?"))==null?void 0:h[0])||"/";r.hooks.updateRoute(c),r.hooks.closeWindow()}}})}interceptSwitchTab(){this.interceptRouterMethod("switchTab")}resetInterceptSwitchTab(){uni.removeInterceptor("switchTab")}interceptRedirectTo(){this.interceptRouterMethod("redirectTo")}resetInterceptRedirectTo(){uni.removeInterceptor("redirectTo")}interceptReLaunch(){this.interceptRouterMethod("reLaunch")}resetInterceptReLaunch(){uni.removeInterceptor("reLaunch")}interceptNavigateBack(){this.interceptRouterMethod("navigateBack")}resetInterceptNavigateBack(){uni.removeInterceptor("navigateBack")}interceptNavigateTo(){this.interceptRouterMethod("navigateTo")}resetInterceptNavigateTo(){uni.removeInterceptor("navigateTo")}uniEventFactory(e,r=!0){const t=`$${e}`,o=this;Object.defineProperty(uni,t,{configurable:!0,value:function(n,...c){var l,a,h,f;if((a=(l=d.backup)==null?void 0:l[t])==null||a.call(l,n,...c),r&&!n.startsWith("dev-")&&!n.startsWith("perf-")){const i=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
12
|
+
`),s=i==null?void 0:i[2];o.hooks.updateUniEvent([{eventName:n,timer:v.getCurrentDate(),stack:s,type:e}]),o.hooks.updateUniEventCount(e)}}})}interceptUniEvent(){this.uniEventFactory("on"),this.uniEventFactory("once"),this.uniEventFactory("emit"),this.uniEventFactory("off")}resetUniEvent(){Object.defineProperty(uni,"$on",{configurable:!0,value:d.backup.$on}),Object.defineProperty(uni,"$once",{configurable:!0,value:d.backup.$once}),Object.defineProperty(uni,"$emit",{configurable:!0,value:d.backup.$emit}),Object.defineProperty(uni,"$off",{configurable:!0,value:d.backup.$off})}interceptScanCode(){const e=this;uni.addInterceptor("scanCode",{invoke(r){var c,l;const t=r.complete,o=(l=(c=new Error)==null?void 0:c.stack)==null?void 0:l.split(`
|
|
13
|
+
`),n=o==null?void 0:o[5];r.complete=function(a){t&&t(a);let h={},f="";try{h=JSON.parse(a==null?void 0:a.result);const i=C.transformValueToView(h);f=C.transformValueToShortString(h,i)}catch{h={},f=C.transformValueToShortString(a==null?void 0:a.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:a==null?void 0:a.charSet,rawData:a==null?void 0:a.rawData,result:a==null?void 0:a.result,resultObject:h,scanType:a==null?void 0:a.scanType,errMsg:a==null?void 0:a.errMsg,path:I.getCurrentPagePath(),stack:n,shortValue:f}])}}})}resetInterceptScanCode(){uni.removeInterceptor("scanCode")}interceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.onUserCaptureScreen(this.captureScreen)}resetInterceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.offUserCaptureScreen(this.captureScreen)}listenerScreenRecording(e){const{state:r}=e,t=this.hooks.getScreenIndex(),o=this.hooks.setScreenIndex(t+1),n={index:o,position:I.getCurrentPagePath(),startTime:v.getCurrentDate(),endTime:"",type:"recordingScreen"};r==="start"?this.hooks.updateScreen([n]):(n.endTime=v.getCurrentDate(),this.hooks.updateScreen([n],o))}interceptScreenRecording(){uni.onScreenRecordingStateChanged&&(this.boundListenerScreenRecording=this.listenerScreenRecording.bind(this),uni.onScreenRecordingStateChanged(this.boundListenerScreenRecording))}resetInterceptScreenRecording(){uni.offScreenRecordingStateChanged&&this.boundListenerScreenRecording&&uni.offScreenRecordingStateChanged(this.boundListenerScreenRecording)}}exports.DevIntercept=N;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DevTool } from '../../type';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 拦截器
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class DevIntercept
|
|
8
|
+
*/
|
|
9
|
+
export declare class DevIntercept implements DevTool.DevInterceptInterface {
|
|
10
|
+
private hooks;
|
|
11
|
+
private enableCaptureScreen;
|
|
12
|
+
private enableInterceptPromiseReject;
|
|
13
|
+
private preWarn;
|
|
14
|
+
private initPinia;
|
|
15
|
+
private boundListenerScreenRecording;
|
|
16
|
+
constructor(options: DevTool.DevInterceptOptions);
|
|
17
|
+
private safeDefineProperty;
|
|
18
|
+
init({ enableCaptureScreen, enableInterceptPromiseReject, }: {
|
|
19
|
+
enableCaptureScreen?: boolean;
|
|
20
|
+
enableInterceptPromiseReject?: boolean;
|
|
21
|
+
}): void;
|
|
22
|
+
reset(): void;
|
|
23
|
+
interceptAppConsole(): void;
|
|
24
|
+
resetInterceptAppConsole(): void;
|
|
25
|
+
interceptVue(vueInstance: any): void;
|
|
26
|
+
interceptAppError(): void;
|
|
27
|
+
resetInterceptErrorApp(): void;
|
|
28
|
+
interceptErrorVue(error: Error): void;
|
|
29
|
+
interceptWarnVue(warn: string): void;
|
|
30
|
+
interceptPromiseReject(): void;
|
|
31
|
+
resetInterceptPromiseReject(): void;
|
|
32
|
+
interceptSetStorage(): void;
|
|
33
|
+
resetInterceptStorage(): void;
|
|
34
|
+
interceptClearStorage(): void;
|
|
35
|
+
resetInterceptClearStorage(): void;
|
|
36
|
+
interceptRemoveStorage(): void;
|
|
37
|
+
resetInterceptRemoveStorage(): void;
|
|
38
|
+
interceptVuexStorage(store: any): void;
|
|
39
|
+
interceptPiniaStore(context: any): any;
|
|
40
|
+
interceptRequest(): void;
|
|
41
|
+
resetInterceptRequest(): void;
|
|
42
|
+
interceptSocket(): void;
|
|
43
|
+
resetInterceptSocket(): void;
|
|
44
|
+
interceptUploadFile(): void;
|
|
45
|
+
resetInterceptUploadFile(): void;
|
|
46
|
+
interceptDownloadFile(): void;
|
|
47
|
+
resetInterceptDownloadFile(): void;
|
|
48
|
+
private interceptRouterMethod;
|
|
49
|
+
interceptSwitchTab(): void;
|
|
50
|
+
resetInterceptSwitchTab(): void;
|
|
51
|
+
interceptRedirectTo(): void;
|
|
52
|
+
resetInterceptRedirectTo(): void;
|
|
53
|
+
interceptReLaunch(): void;
|
|
54
|
+
resetInterceptReLaunch(): void;
|
|
55
|
+
interceptNavigateBack(): void;
|
|
56
|
+
resetInterceptNavigateBack(): void;
|
|
57
|
+
interceptNavigateTo(): void;
|
|
58
|
+
resetInterceptNavigateTo(): void;
|
|
59
|
+
private uniEventFactory;
|
|
60
|
+
interceptUniEvent(): void;
|
|
61
|
+
resetUniEvent(): void;
|
|
62
|
+
interceptScanCode(): void;
|
|
63
|
+
resetInterceptScanCode(): void;
|
|
64
|
+
private captureScreen;
|
|
65
|
+
interceptCaptureScreen(): void;
|
|
66
|
+
resetInterceptCaptureScreen(): void;
|
|
67
|
+
private listenerScreenRecording;
|
|
68
|
+
interceptScreenRecording(): void;
|
|
69
|
+
resetInterceptScreenRecording(): void;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/devIntercept/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAY1C;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,OAAO,CAAC,qBAAqB;IAChE,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,4BAA4B,CAAsB;IAC1D,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,4BAA4B,CAAM;gBAE9B,OAAO,EAAE,OAAO,CAAC,mBAAmB;IAShD,OAAO,CAAC,kBAAkB;IAuB1B,IAAI,CAAC,EACH,mBAAmB,EACnB,4BAA4B,GAC7B,EAAE;QACD,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,4BAA4B,CAAC,EAAE,OAAO,CAAC;KACxC;IA2CD,KAAK;IAsCL,mBAAmB;IAgCnB,wBAAwB;IASxB,YAAY,CAAC,WAAW,EAAE,GAAG;IAsB7B,iBAAiB;IAmBjB,sBAAsB;IAItB,iBAAiB,CAAC,KAAK,EAAE,KAAK;IAiB9B,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAyB7B,sBAAsB;IAuBtB,2BAA2B;IAU3B,mBAAmB;IA8BnB,qBAAqB;IAoBrB,qBAAqB;IAkBrB,0BAA0B;IAQ1B,sBAAsB;IAsBtB,2BAA2B;IAQ3B,oBAAoB,CAAC,KAAK,EAAE,GAAG;IAY/B,mBAAmB,CAAC,OAAO,EAAE,GAAG;IAoBhC,gBAAgB;IAgJhB,qBAAqB;IAIrB,eAAe;IA2Jf,oBAAoB;IAOpB,mBAAmB;IAoGnB,wBAAwB;IAOxB,qBAAqB;IAqGrB,0BAA0B;IAQ1B,OAAO,CAAC,qBAAqB;IAsB7B,kBAAkB;IAGlB,uBAAuB;IAIvB,mBAAmB;IAGnB,wBAAwB;IAIxB,iBAAiB;IAGjB,sBAAsB;IAItB,qBAAqB;IAGrB,0BAA0B;IAI1B,mBAAmB;IAGnB,wBAAwB;IAKxB,OAAO,CAAC,eAAe;IAyBvB,iBAAiB;IAOjB,aAAa;IAoBb,iBAAiB;IAwCjB,sBAAsB;IAKtB,OAAO,CAAC,aAAa,CAgBnB;IAEF,sBAAsB;IAMtB,2BAA2B;IAM3B,OAAO,CAAC,uBAAuB;IAqB/B,wBAAwB;IASxB,6BAA6B;CAU9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{backup as d}from"../../core-shared.js";import{DEV_TOOL_ON_INIT as M,DEV_TOOL_ON_DESTROY as N}from"../../const.js";import"../../utils/index.js";import{getCurrentDate as v}from"../../utils/date.js";import{getCurrentPagePath as b}from"../../utils/page.js";import{transformValueToView as _,transformValueToShortString as C}from"../../utils/language.js";import{parseValue as q,omit as U}from"../../utils/object.js";import{escapeHTML as L}from"../../utils/string.js";class O{constructor(e){this.initPinia=!1,this.captureScreen=r=>{if(!this.hooks.getDevToolDestroy()){const t=this.hooks.getScreenIndex(),a=this.hooks.setScreenIndex(t+1);this.hooks.updateScreen([{index:a,position:b(),startTime:v(),endTime:v(),type:"captureScreen",path:(r==null?void 0:r.path)??""}])}},this.hooks=e.hooks,typeof uni<"u"&&(uni.$on(M,r=>this.init(r)),uni.$on(N,()=>this.reset()))}safeDefineProperty(e,r,t){if(!e)return!1;try{const a=Object.getOwnPropertyDescriptor(e,r);return a&&a.configurable===!1?(console.warn(`[DevTool] ${r} 属性不可配置,已跳过拦截`),!1):(Object.defineProperty(e,r,{...t,configurable:!0}),!0)}catch(a){return console.warn(`[DevTool] 拦截 ${r} 失败,环境可能受限:`,a),!1}}init({enableCaptureScreen:e,enableInterceptPromiseReject:r}){this.enableCaptureScreen=e,this.enableInterceptPromiseReject=r,this.interceptAppConsole(),this.interceptAppError(),this.interceptSetStorage(),this.interceptRemoveStorage(),this.interceptClearStorage(),this.interceptRequest(),this.interceptSocket(),this.interceptUploadFile(),this.interceptDownloadFile(),this.interceptSwitchTab(),this.interceptRedirectTo(),this.interceptReLaunch(),this.interceptNavigateBack(),this.interceptNavigateTo(),this.interceptUniEvent(),this.interceptScanCode(),this.enableCaptureScreen&&this.interceptCaptureScreen(),this.interceptScreenRecording(),this.enableInterceptPromiseReject&&this.interceptPromiseReject()}reset(){this.resetInterceptAppConsole(),this.resetInterceptErrorApp(),this.resetInterceptPromiseReject(),this.resetInterceptStorage(),this.resetInterceptRemoveStorage(),this.resetInterceptClearStorage(),this.resetInterceptRequest(),this.resetInterceptSocket(),this.resetInterceptUploadFile(),this.resetInterceptDownloadFile(),this.resetInterceptSwitchTab(),this.resetInterceptRedirectTo(),this.resetInterceptReLaunch(),this.resetInterceptNavigateBack(),this.resetInterceptNavigateTo(),this.resetUniEvent(),this.resetInterceptScanCode(),this.enableCaptureScreen&&this.resetInterceptCaptureScreen(),this.resetInterceptScreenRecording()}interceptAppConsole(){if(!uni.__log__)return;const e=this;this.safeDefineProperty(uni,"__log__",{writable:!1,value:function(r,t,...a){d.__log__(r,t,...a);const n=b();e.hooks.updateConsole([{type:r,position:n,time:v(),args:a.map(i=>{const l=_(i),o=q(i),f=l==="object"||l==="array"?C(o,l):"";return{type:l,value:o,shortValue:f}}),stack:t}])}})}resetInterceptAppConsole(){uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!0,value:d.__log__})}interceptVue(e){if(!e)return;const r=(a,n,i)=>{this.hooks.getDevToolDestroy()||this.interceptErrorVue(a)},t=(a,n,i)=>{this.hooks.getDevToolDestroy()||this.interceptWarnVue(a+`
|
|
2
|
+
`+i)};e.appContext?(e.appContext.config.errorHandler=r,e.appContext.config.warnHandler=t):(e.config.errorHandler=r,e.config.warnHandler=t)}interceptAppError(){uni.onError(e=>{var a,n;if(this.hooks.getDevToolDestroy())return;const r=e.toString(),t=((n=(a=e==null?void 0:e.stack)==null?void 0:a.split(`
|
|
3
|
+
`))==null?void 0:n[1])??"";this.hooks.updateConsole([{type:"error",args:[{type:"string",value:r}],position:b(),time:v(),stack:t}])})}resetInterceptErrorApp(){uni.onError(()=>{})}interceptErrorVue(e){var a;const r=(a=e==null?void 0:e.stack)==null?void 0:a.split(`
|
|
4
|
+
`),t=r==null?void 0:r[1];console.error(e),this.hooks.updateConsole([{type:"error",args:[{type:"string",value:e.toString()}],position:b(),time:v(),stack:t}])}interceptWarnVue(e){var i,l,o,h;if(this.preWarn===e)return;this.preWarn=e;const r=b(),t=(l=(i=new Error)==null?void 0:i.stack)==null?void 0:l.split(`
|
|
5
|
+
`),a=(o=t==null?void 0:t.slice(2))==null?void 0:o[0];console.warn(e);const n=(h=e.split(`
|
|
6
|
+
`))==null?void 0:h.map(f=>L(f)).join(`
|
|
7
|
+
`);this.hooks.updateConsole([{type:"warn",args:[{type:"string",value:n}],position:r,time:v(),stack:a}])}interceptPromiseReject(){const e=this;this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(r){var n,i;const t=r.toString(),a=((i=(n=r==null?void 0:r.stack)==null?void 0:n.split(`
|
|
8
|
+
`))==null?void 0:i[1])??"";return e.hooks.updateConsole([{type:"error",args:[{type:"string",value:t}],position:b(),time:v(),stack:a}]),d.reject.call(Promise,r)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return d.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(r,t){d.setStorageSync(r.toString(),t),e.hooks.updateStorage([{key:r.toString(),_oldKey:r.toString(),value:t}])}}),uni.addInterceptor("setStorage",{invoke(r){const t=r.complete;r.complete=function(a){var n,i;t&&t(a),e.hooks.updateStorage([{key:(n=r.key)==null?void 0:n.toString(),_oldKey:(i=r.key)==null?void 0:i.toString(),value:r.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:d.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){d.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(r){d.removeStorageSync(r),e.hooks.removeStorage(r)}}),uni.addInterceptor("removeStorage",{invoke(r){const t=r.complete;r.complete=function(a){t&&t(a),e.hooks.removeStorage(r.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var t;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(t=e==null?void 0:e.subscribe)==null||t.call(e,(a,n)=>{this.hooks.setVuexList(n)}))}interceptPiniaStore(e){var t;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(t=e==null?void 0:e.store)==null||t.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(r){var P,E,w,j,x,F,H;const t=e.hooks.getRequestIndex(),a=e.hooks.setRequestIndex(t+1),n=r.url,i=(P=n==null?void 0:n.split("?"))==null?void 0:P[0],l=i==null?void 0:i.lastIndexOf("/"),o=(i==null?void 0:i.slice(l+1))??"",h=(w=(E=new Error)==null?void 0:E.stack)==null?void 0:w.split(`
|
|
9
|
+
`),f=uni.__dev_tool_platform__==="app"?h==null?void 0:h[2]:h==null?void 0:h[5],c=e.hooks.getInterceptNetworkMap(),s=`${(j=r.method)==null?void 0:j.toUpperCase()}|${i}`,u=c==null?void 0:c.get(s),g=Object.keys(r.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";r.header={...U(r.header,["dev-tool-sponsor"])};const p={index:a,stack:f,url:r.url,name:o,startTime:Date.now(),endTime:0,time:"-",headers:{requestHeader:Object.entries(r.header??{}).map(([S,D])=>({key:S,value:D})),responseHeader:[]},method:r.method||"GET",status:"pending",payload:r!=null&&r.data?JSON.stringify(r.data):"",response:{data:void 0,statusCode:0,header:{},cookies:[],errMsg:""},size:"",sponsor:g};u&&(p.headers.requestHeader={...p.headers.requestHeader,...u.headers.requestHeader},p.payload={...u.payload},p.intercepted=!0,Object.assign(r,{timeout:u.timeout})),e.hooks.updateNetwork([p]);const m={errMsg:""};let T=!0;u&&(m.statusCode=u.status,(F=(x=u==null?void 0:u.status)==null?void 0:x.toString())!=null&&F.startsWith("2")?(T=!0,m.errMsg="request:ok",m.header=(H=u.headers.responseHeader)==null?void 0:H.reduce((S,D)=>({...S,[D.key]:D.value}),{}),m.data=u.response.data):(T=!1,m.errMsg="request:fail"));const k=r.fail,y=r.success,I=r.complete;r.fail=function(S){u?T?y==null||y(m):k==null||k(m):k==null||k(S)},r.success=function(S){u?T?y==null||y(m):k==null||k(m):y==null||y(S)},r.complete=function(S){var W,$;const D=Date.now()-p.startTime;p.time=D<1e3?D+"ms":D/1e3+"s",p.endTime=Date.now();const R=((W=S==null?void 0:S.header)==null?void 0:W["Content-Length"])||(($=S==null?void 0:S.header)==null?void 0:$["content-length"])||0;p.size=R>1024?(R/1024).toFixed(2)+"k":R+"b",u?(I==null||I(m),p.status=u.status,p.response=m,p.headers.responseHeader=u.headers.responseHeader):(I==null||I(S),p.status=S.statusCode??"error",p.response=S,p.headers.responseHeader=Object.entries(S.header??{}).map(([B,V])=>({key:B,value:V}))),e.hooks.updateNetwork([p],a)}}})}resetInterceptRequest(){uni.removeInterceptor("request")}interceptSocket(){const e=this,r=function(t){const a=t.url,n=Object.entries(t.header??{}).map(([s,u])=>({key:s,value:u})),i=(t.method??"GET").toLowerCase(),l=t.protocols??[];e.hooks.updateWs({url:a,headers:n,method:i,protocols:l,readyState:"connection",message:[]});const o=d.connectSocket({...t,multiple:!0,complete:s=>{var u;(u=t==null?void 0:t.complete)==null||u.call(t,s)}});e.hooks.addWsTask(a,o);function h(s,u,g,p){let m=s;if(typeof s=="string")try{const P=JSON.parse(s);typeof P=="object"&&P!==null&&(m=P)}catch{}const T=_(m),k=q(m),I=T==="object"||T==="array"?C(k,T):"";e.hooks.updateWs({url:a,readyState:g,headers:n,protocols:l,message:[{value:k,valueType:T,shortValue:I,status:p,time:Date.now(),type:u}]})}const f=o.send;o.send=s=>{let u=s.data;if(typeof u=="object"&&u!==null)try{u=JSON.stringify(u)}catch{}f.call(o,{...s,data:u,fail:g=>{var p;(p=s==null?void 0:s.fail)==null||p.call(s,g),h(s.data,"send","error","error")},success:g=>{var p;(p=s==null?void 0:s.success)==null||p.call(s,g),h(s.data,"send","open","success")},complete:g=>{var p;(p=s==null?void 0:s.complete)==null||p.call(s,g)}})};const c=o.close;return o.close=s=>{e.hooks.updateWs({url:a,readyState:"closing",headers:n,protocols:l,message:[]}),c.call(o,{...s,fail:u=>{var g;(g=s==null?void 0:s.fail)==null||g.call(s,u),h(u,"send","closing","error")},success:u=>{var g;(g=s==null?void 0:s.success)==null||g.call(s,u),h(u,"send","closed","success")},complete:u=>{var g;(g=s==null?void 0:s.complete)==null||g.call(s,u)}})},o.onOpen(()=>{e.hooks.updateWs({url:a,readyState:"open",headers:n,protocols:l,message:[]})}),o.onError(s=>{h(s,"receive","error","error")}),o.onMessage(s=>{h(s.data,"receive","open","success")}),o.onClose(s=>{h(s,"receive","closed","success"),e.hooks.removeWsTask(a)}),o};this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:r})}resetInterceptSocket(){this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:d.connectSocket})}interceptUploadFile(){const e=this,r=t=>{var h,f;const a=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(a+1),i=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
10
|
+
`),l=i==null?void 0:i[2];e.hooks.updateTransfer([{index:n,type:"upload",stack:l,name:t.name,url:t.url,filePath:t.filePath,fileType:t.fileType,headers:{requestHeader:Object.entries(t.header||{}).map(([c,s])=>({key:c,value:s})),responseHeader:[]},formData:t.formData,status:"pending",progress:0,totalBytesSent:0,totalBytesExpectedToSend:0,startTime:Date.now()}],n);const o=d.uploadFile({...t,success:c=>{var s;(s=t==null?void 0:t.success)==null||s.call(t,c),e.hooks.updateTransfer([{index:n,type:"upload",status:"success",endTime:Date.now(),response:{...c,data:JSON.parse(c.data)}}],n),e.hooks.removeTransferTask(n)},fail:c=>{var s;(s=t==null?void 0:t.fail)==null||s.call(t,c),e.hooks.updateTransfer([{index:n,type:"upload",status:"error",response:c,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return o.onProgressUpdate(c=>{e.hooks.updateTransfer([{index:n,type:"upload",progress:c.progress,totalBytesSent:c.totalBytesSent,totalBytesExpectedToSend:c.totalBytesExpectedToSend,status:"uploading"}],n)}),e.hooks.addTransferTask(n,o),o};this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:r})}resetInterceptUploadFile(){this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:d.uploadFile})}interceptDownloadFile(){const e=this,r=t=>{var h,f;const a=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(a+1),i=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
11
|
+
`),l=i==null?void 0:i[2];e.hooks.updateTransfer([{index:n,type:"download",stack:l,url:t.url,filePath:t.filePath,headers:{requestHeader:Object.entries(t.header||{}).map(([c,s])=>({key:c,value:s})),responseHeader:[]},status:"pending",progress:0,totalBytesWritten:0,totalBytesExpectedToWrite:0,startTime:Date.now()}],n);const o=d.downloadFile({...t,success:c=>{var s;(s=t==null?void 0:t.success)==null||s.call(t,c),e.hooks.updateTransfer([{index:n,type:"download",status:"success",endTime:Date.now(),response:{...c,statusCode:c.statusCode,tempFilePath:c.tempFilePath}}],n),e.hooks.removeTransferTask(n)},fail:c=>{var s;(s=t==null?void 0:t.fail)==null||s.call(t,c),e.hooks.updateTransfer([{index:n,type:"download",status:"error",response:c,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return o.onProgressUpdate(c=>{e.hooks.updateTransfer([{index:n,type:"download",progress:c.progress,totalBytesWritten:c.totalBytesWritten,totalBytesExpectedToWrite:c.totalBytesExpectedToWrite,status:"downloading"}],n)}),e.hooks.addTransferTask(n,o),o};this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:r})}resetInterceptDownloadFile(){this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:d.downloadFile})}interceptRouterMethod(e){const r=this;uni.addInterceptor(e,{invoke(t){const a=t.complete;t.complete=function(n){var l,o,h;a==null||a(n);const i=((h=(o=(l=t.url)==null?void 0:l.slice(1))==null?void 0:o.split("?"))==null?void 0:h[0])||"/";r.hooks.updateRoute(i),r.hooks.closeWindow()}}})}interceptSwitchTab(){this.interceptRouterMethod("switchTab")}resetInterceptSwitchTab(){uni.removeInterceptor("switchTab")}interceptRedirectTo(){this.interceptRouterMethod("redirectTo")}resetInterceptRedirectTo(){uni.removeInterceptor("redirectTo")}interceptReLaunch(){this.interceptRouterMethod("reLaunch")}resetInterceptReLaunch(){uni.removeInterceptor("reLaunch")}interceptNavigateBack(){this.interceptRouterMethod("navigateBack")}resetInterceptNavigateBack(){uni.removeInterceptor("navigateBack")}interceptNavigateTo(){this.interceptRouterMethod("navigateTo")}resetInterceptNavigateTo(){uni.removeInterceptor("navigateTo")}uniEventFactory(e,r=!0){const t=`$${e}`,a=this;Object.defineProperty(uni,t,{configurable:!0,value:function(n,...i){var l,o,h,f;if((o=(l=d)==null?void 0:l[t])==null||o.call(l,n,...i),r&&!n.startsWith("dev-")&&!n.startsWith("perf-")){const c=(f=(h=new Error)==null?void 0:h.stack)==null?void 0:f.split(`
|
|
12
|
+
`),s=c==null?void 0:c[2];a.hooks.updateUniEvent([{eventName:n,timer:v(),stack:s,type:e}]),a.hooks.updateUniEventCount(e)}}})}interceptUniEvent(){this.uniEventFactory("on"),this.uniEventFactory("once"),this.uniEventFactory("emit"),this.uniEventFactory("off")}resetUniEvent(){Object.defineProperty(uni,"$on",{configurable:!0,value:d.$on}),Object.defineProperty(uni,"$once",{configurable:!0,value:d.$once}),Object.defineProperty(uni,"$emit",{configurable:!0,value:d.$emit}),Object.defineProperty(uni,"$off",{configurable:!0,value:d.$off})}interceptScanCode(){const e=this;uni.addInterceptor("scanCode",{invoke(r){var i,l;const t=r.complete,a=(l=(i=new Error)==null?void 0:i.stack)==null?void 0:l.split(`
|
|
13
|
+
`),n=a==null?void 0:a[5];r.complete=function(o){t&&t(o);let h={},f="";try{h=JSON.parse(o==null?void 0:o.result);const c=_(h);f=C(h,c)}catch{h={},f=C(o==null?void 0:o.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:o==null?void 0:o.charSet,rawData:o==null?void 0:o.rawData,result:o==null?void 0:o.result,resultObject:h,scanType:o==null?void 0:o.scanType,errMsg:o==null?void 0:o.errMsg,path:b(),stack:n,shortValue:f}])}}})}resetInterceptScanCode(){uni.removeInterceptor("scanCode")}interceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.onUserCaptureScreen(this.captureScreen)}resetInterceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.offUserCaptureScreen(this.captureScreen)}listenerScreenRecording(e){const{state:r}=e,t=this.hooks.getScreenIndex(),a=this.hooks.setScreenIndex(t+1),n={index:a,position:b(),startTime:v(),endTime:"",type:"recordingScreen"};r==="start"?this.hooks.updateScreen([n]):(n.endTime=v(),this.hooks.updateScreen([n],a))}interceptScreenRecording(){uni.onScreenRecordingStateChanged&&(this.boundListenerScreenRecording=this.listenerScreenRecording.bind(this),uni.onScreenRecordingStateChanged(this.boundListenerScreenRecording))}resetInterceptScreenRecording(){uni.offScreenRecordingStateChanged&&this.boundListenerScreenRecording&&uni.offScreenRecordingStateChanged(this.boundListenerScreenRecording)}}export{O as DevIntercept};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("../../const.cjs");require("../../utils/index.cjs");const n=require("../devToolInfo/index.cjs"),x=require("../../utils/function.cjs"),I=require("../../utils/language.cjs"),z=require("../../utils/object.cjs"),S=require("../../utils/page.cjs"),w=require("../../utils/ip.cjs");class y{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.networkList=[],this.networkMaxSize=1e3,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.saveConsoleLogThrottled=x.throttle(()=>{this.cacheConsoleLog&&n.setDevToolConsoleList(this.consoleList)},1e3),this.saveNetworkLogThrottled=x.throttle(()=>{this.cacheNetworkLog&&n.setDevToolNetworkList(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:o=!1,cacheConsoleLog:i=!1,useTransition:c=!0,baseFontSize:r=12,tagFontSize:l=10,tipsFontSize:p=10,fontFamily:h="",fontWeight:L="normal",interceptNetworkList:f=[]}=uni.getStorageSync(D.DEV_TOOL_INFO)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=c,this.baseFontSize=r,this.tagFontSize=l,this.tipsFontSize=p,this.fontFamily=h,this.fontWeight=L,this.updateInterceptNetworkList(f),this.cacheNetworkLog&&(this.networkList=n.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(g=>g.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=n.getDevToolConsoleList())}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,n.setDevToolInfo({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,n.setDevToolInfo({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,n.setDevToolInfo({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,n.setDevToolInfo({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,n.setDevToolInfo({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,n.setDevToolInfo({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,n.setDevToolInfo({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,n.setDevToolInfo({fontFamily:t})}setFontWeight(t){this.fontWeight=t,n.setDevToolInfo({fontWeight:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,n.setDevToolInfo({cacheConsoleLog:t}),t?n.setDevToolConsoleList(this.consoleList):n.setDevToolConsoleList([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,n.setDevToolInfo({cacheNetworkLog:t}),t?n.setDevToolNetworkList(this.networkList):n.setDevToolNetworkList([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.cacheConsoleLog&&n.setDevToolConsoleList([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.cacheNetworkLog&&n.setDevToolNetworkList([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var o;const s=`${(o=e.method)==null?void 0:o.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:o}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,o),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(o){console.error("[DevTool] updateVuexStore error",o)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(I.isNil(e))return{};z.setValueByPath(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:o}=t;return this.storageList.unshift({key:s,_oldKey:s,value:o}),e&&uni.setStorageSync(s,o),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(o=>o.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var o;const s=e||((o=t==null?void 0:t[0])==null?void 0:o.path)||"";return this.routeList=t.map((i,c)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&c===0?4:i.path===s?3:c===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?S.getCurrentPagePath():t:S.getCurrentPagePath(),s=this.prePath;this.routeList=this.routeList.map((r,l)=>({...r,index:r.path===e&&l===0?4:r.path===e?3:l===0?2:1}));const o=(r,l,p)=>{var f,g;if(!r[l])return r;r[l].uvList||(r[l].uvList=[]);const h=r[l],L=h.uvList??[];if(L.length){const u=L.length-1,v=L[u];if(v&&v.inTime&&!v.outTime){const a=Date.now();h.outTime=a,L[u].outTime=a,L[u].duration=a-v.inTime,h.duration=L[u].duration,h.totalDuration=L.reduce((d,T)=>d+(T.duration||0),0),p&&(h.visitTimes=L.length)}else{const a=Date.now();h.inTime=a,h.outTime=0,h.duration=0,(f=h.uvList)==null||f.push({index:u+1,inTime:a,outTime:0,duration:0}),p&&(h.visitTimes=(g=h.uvList)==null?void 0:g.length)}}else{const u=Date.now();h.inTime=u,h.outTime=0,h.duration=0,h.totalDuration=0,h.visitTimes=1,h.uvList=[{index:0,inTime:u,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),c=this.routeList.findIndex(r=>r.path===e);return i>-1&&o(this.routeList,i),c>-1&&o(this.routeList,c,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,o;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const c=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>c&&((o=i.message)==null||o.splice(0,r-c))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;let s;return this.wsTaskMap.forEach((o,i)=>{s||(i.includes(t)||t.includes(i))&&(s=o)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],o=this.transferList.findIndex(i=>i.index===e);o>-1?this.transferList[o]={...this.transferList[o],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var g,u,v;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:o=12,tagFontSize:i=10,tipsFontSize:c=10,fontFamily:r="",fontWeight:l="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:h=!1,cacheConsoleLog:L=!1}=n.getDevToolInfo();this.devToolVisible=I.isBoolean(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=c,this.fontFamily=r,this.fontWeight=l,this.cacheInterceptConfig=p,this.cacheNetworkLog=h,this.cacheConsoleLog=L,this.cacheNetworkLog&&(this.networkList=n.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(a=>a.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=n.getDevToolConsoleList()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const f=((g=t.pagesJson)==null?void 0:g.pages.map(a=>{var d,T,k;return{...a,type:(k=(T=(d=t.pagesJson)==null?void 0:d.tabBar)==null?void 0:T.list)!=null&&k.some(C=>C.pagePath===a.path)?"nav":"main"}}))??[];(v=(u=t.pagesJson)==null?void 0:u.subPackages)==null||v.forEach(a=>{a.pages.forEach(d=>{f.push({...d,path:`${a.root}/${d.path}`,type:"sub",uvList:[]})})}),this.setRouteList(f)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=w.getWifiIp()||w.getLanIp()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await w.getMicroAppIp())}catch(s){console.error("[DevTool] Get IP error",s)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.cacheConsoleLog&&n.setDevToolConsoleList([]),this.cacheNetworkLog&&n.setDevToolNetworkList([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return S.getCurrentPagePath()}}exports.DevStore=y;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { DevTool } from '../../type';
|
|
2
|
+
|
|
3
|
+
/** 数据存储中心 */
|
|
4
|
+
export declare class DevStore {
|
|
5
|
+
private consoleList;
|
|
6
|
+
private consoleMaxSize;
|
|
7
|
+
private networkList;
|
|
8
|
+
private networkMaxSize;
|
|
9
|
+
private interceptNetworkMap;
|
|
10
|
+
private requestIndex;
|
|
11
|
+
private storageList;
|
|
12
|
+
private vuexList;
|
|
13
|
+
private piniaList;
|
|
14
|
+
private vuexStore;
|
|
15
|
+
private piniaStore;
|
|
16
|
+
private routeList;
|
|
17
|
+
private prePath;
|
|
18
|
+
private wsList;
|
|
19
|
+
private wsDataMaxSize;
|
|
20
|
+
private wsTaskMap;
|
|
21
|
+
private transferList;
|
|
22
|
+
private transferMaxSize;
|
|
23
|
+
private transferIndex;
|
|
24
|
+
private transferTaskMap;
|
|
25
|
+
private elEventList;
|
|
26
|
+
private uniEventList;
|
|
27
|
+
private eventCount;
|
|
28
|
+
private elEventListMaxSize;
|
|
29
|
+
private uniEventListMaxSize;
|
|
30
|
+
private screenList;
|
|
31
|
+
private scanCodeList;
|
|
32
|
+
private nfcList;
|
|
33
|
+
private screenIndex;
|
|
34
|
+
private screenMaxSize;
|
|
35
|
+
private scanCodeListMaxSize;
|
|
36
|
+
private nfcListMaxSize;
|
|
37
|
+
private systemInfo;
|
|
38
|
+
private deviceInfo;
|
|
39
|
+
private windowInfo;
|
|
40
|
+
private netWorkStatus;
|
|
41
|
+
devToolVersion: string;
|
|
42
|
+
devToolBuildTime: string;
|
|
43
|
+
devToolGit: string;
|
|
44
|
+
private devToolOptions;
|
|
45
|
+
private devToolVisible;
|
|
46
|
+
private devToolDestroy;
|
|
47
|
+
private cacheInterceptConfig;
|
|
48
|
+
private useTransition;
|
|
49
|
+
private cacheNetworkLog;
|
|
50
|
+
private cacheConsoleLog;
|
|
51
|
+
private baseFontSize;
|
|
52
|
+
private tagFontSize;
|
|
53
|
+
private tipsFontSize;
|
|
54
|
+
private fontFamily;
|
|
55
|
+
private fontWeight;
|
|
56
|
+
private saveConsoleLogThrottled;
|
|
57
|
+
private saveNetworkLogThrottled;
|
|
58
|
+
cacheMaxSize: number;
|
|
59
|
+
constructor();
|
|
60
|
+
updateHasUpload(): void;
|
|
61
|
+
setDevToolVisible(visible: boolean): void;
|
|
62
|
+
getDevToolVisible(): boolean;
|
|
63
|
+
setDevToolDestroy(destroy: boolean): void;
|
|
64
|
+
getDevToolDestroy(): boolean;
|
|
65
|
+
setCacheInterceptConfig(value: boolean): void;
|
|
66
|
+
getCacheNetworkLog(): boolean;
|
|
67
|
+
setUseTransition(value: boolean): void;
|
|
68
|
+
setBaseFontSize(value: number): void;
|
|
69
|
+
setTagFontSize(value: number): void;
|
|
70
|
+
setTipsFontSize(value: number): void;
|
|
71
|
+
setFontFamily(value: string): void;
|
|
72
|
+
setFontWeight(value: string): void;
|
|
73
|
+
setCacheConsoleLog(value: boolean): void;
|
|
74
|
+
setCacheNetworkLog(value: boolean): void;
|
|
75
|
+
getConsoleList(): DevTool.ConsoleItem[];
|
|
76
|
+
updateConsoleList(addItems: DevTool.ConsoleItem[], index?: number): void;
|
|
77
|
+
clearConsoleList(): void;
|
|
78
|
+
getNetworkList(): DevTool.NetworkItem[];
|
|
79
|
+
updateNetworkList(addItems: DevTool.NetworkItem[], index?: number): void;
|
|
80
|
+
clearNetworkList(): void;
|
|
81
|
+
getInterceptNetworkMap(): Map<string, DevTool.NetworkItem>;
|
|
82
|
+
getRequestIndex(): number;
|
|
83
|
+
setRequestIndex(index: number): number;
|
|
84
|
+
updateInterceptNetworkList(items: DevTool.NetworkItem[]): void;
|
|
85
|
+
clearInterceptNetworkList(): void;
|
|
86
|
+
getStorageList(): DevTool.StorageItem[];
|
|
87
|
+
setStorageList(items: DevTool.StorageItem[]): DevTool.StorageItem[];
|
|
88
|
+
getVuexList(): Record<string, any>;
|
|
89
|
+
getPiniaList(): Record<string, any>;
|
|
90
|
+
setVuexStore(store: any): void;
|
|
91
|
+
setVuexList(list: Record<string, any>): void;
|
|
92
|
+
setPiniaStore(store: any): void;
|
|
93
|
+
setPiniaList(list: Record<string, any>): void;
|
|
94
|
+
updateStore(data: {
|
|
95
|
+
key: string;
|
|
96
|
+
_oldKey: string;
|
|
97
|
+
value: any;
|
|
98
|
+
}): DevTool.StorageItem[];
|
|
99
|
+
updateVuexStore(data: Record<string, any>): Record<string, any>;
|
|
100
|
+
updatePiniaStore(data: Record<string, any>): Record<string, any>;
|
|
101
|
+
clearStorageList(local?: boolean): DevTool.StorageItem[];
|
|
102
|
+
removeStorage(key: string, local?: boolean): DevTool.StorageItem[];
|
|
103
|
+
addStorage(data: {
|
|
104
|
+
key: string;
|
|
105
|
+
value: any;
|
|
106
|
+
}, local?: boolean): DevTool.StorageItem[];
|
|
107
|
+
refreshStore(): DevTool.StorageItem[];
|
|
108
|
+
updateStoreList(addItems: DevTool.StorageItem[]): DevTool.StorageItem[];
|
|
109
|
+
getRouteList(): DevTool.Page[];
|
|
110
|
+
setRouteList(pages: DevTool.Page[], currentPath?: string): DevTool.Page[];
|
|
111
|
+
updateRouteList(path?: string): DevTool.Page[];
|
|
112
|
+
getWsList(): DevTool.WS[];
|
|
113
|
+
updateWsList(item: DevTool.WS): DevTool.WS[];
|
|
114
|
+
clearWsList(): void;
|
|
115
|
+
clearWsMessage(url: string): void;
|
|
116
|
+
addWsTask(url: string, task: any): void;
|
|
117
|
+
removeWsTask(url: string): void;
|
|
118
|
+
getWsTask(url: string): any;
|
|
119
|
+
getTransferList(): DevTool.TransferItem[];
|
|
120
|
+
updateTransferList(addItems: DevTool.TransferItem[], index?: number): void;
|
|
121
|
+
getTransferIndex(): number;
|
|
122
|
+
setTransferIndex(index: number): number;
|
|
123
|
+
addTransferTask(index: number | string, task: UniApp.UploadTask | UniApp.DownloadTask): void;
|
|
124
|
+
removeTransferTask(index: number | string): void;
|
|
125
|
+
clearTransferTask(): void;
|
|
126
|
+
getElEventList(): DevTool.ElEventItem[];
|
|
127
|
+
getUniEventList(): DevTool.UniEventItem[];
|
|
128
|
+
getEventCount(): DevTool.EventCount;
|
|
129
|
+
addElEvent(item: DevTool.ElEventItem): void;
|
|
130
|
+
clearElEventList(): void;
|
|
131
|
+
updateUniEventList(items: DevTool.UniEventItem[]): void;
|
|
132
|
+
updateUniEventCount(type: DevTool.EventCountKey): void;
|
|
133
|
+
clearUniEventList(): void;
|
|
134
|
+
getScreenList(): DevTool.ScreenItem[];
|
|
135
|
+
getScanCodeList(): DevTool.ScanCodeItem[];
|
|
136
|
+
getNfcList(): DevTool.NFCItem[];
|
|
137
|
+
getScreenIndex(): number;
|
|
138
|
+
setScreenIndex(index: number): number;
|
|
139
|
+
getSystemInfo(): Record<string, any>;
|
|
140
|
+
getDeviceInfo(): Record<string, any>;
|
|
141
|
+
getWindowInfo(): Record<string, any>;
|
|
142
|
+
setSystemInfo(info: Record<string, any>): void;
|
|
143
|
+
setDeviceInfo(info: Record<string, any>): void;
|
|
144
|
+
setWindowInfo(info: Record<string, any>): void;
|
|
145
|
+
setNetWorkStatus(info: Record<string, any>): void;
|
|
146
|
+
updateScreenList(addItems: DevTool.ScreenItem[], index?: number): void;
|
|
147
|
+
updateScanCodeList(addItems: DevTool.ScanCodeItem[]): void;
|
|
148
|
+
updateNfcList(addItems: DevTool.NFCItem[]): void;
|
|
149
|
+
clearScanCodeList(): void;
|
|
150
|
+
clearNfcList(): void;
|
|
151
|
+
getDevToolOptions(): DevTool.DevToolOptions | undefined;
|
|
152
|
+
setDevToolOptions(options: DevTool.DevToolOptions): void;
|
|
153
|
+
getDevData(): Promise<DevTool.WindowData>;
|
|
154
|
+
getExportData(exports: any): DevTool.WindowData;
|
|
155
|
+
clearDevCache(): void;
|
|
156
|
+
clearAll(): void;
|
|
157
|
+
getCurrentPagePath(): string;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/devStore/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEV_TOOL_INFO as M}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as S,setDevToolNetworkList as T,getDevToolNetworkList as m,getDevToolConsoleList as z,setDevToolInfo as u,getDevToolInfo as y}from"../devToolInfo/index.js";import{throttle as C}from"../../utils/function.js";import{isNil as E,isBoolean as D}from"../../utils/language.js";import{setValueByPath as N}from"../../utils/object.js";import{getCurrentPagePath as k}from"../../utils/page.js";import{getWifiIp as F,getLanIp as b,getMicroAppIp as W}from"../../utils/ip.js";class K{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.networkList=[],this.networkMaxSize=1e3,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.saveConsoleLogThrottled=C(()=>{this.cacheConsoleLog&&S(this.consoleList)},1e3),this.saveNetworkLogThrottled=C(()=>{this.cacheNetworkLog&&T(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:o=!1,cacheConsoleLog:i=!1,useTransition:a=!0,baseFontSize:n=12,tagFontSize:L=10,tipsFontSize:v=10,fontFamily:r="",fontWeight:c="normal",interceptNetworkList:f=[]}=uni.getStorageSync(M)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=a,this.baseFontSize=n,this.tagFontSize=L,this.tipsFontSize=v,this.fontFamily=r,this.fontWeight=c,this.updateInterceptNetworkList(f),this.cacheNetworkLog&&(this.networkList=m(),this.requestIndex=Math.max(...this.networkList.map(g=>g.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=z())}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,u({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,u({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,u({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,u({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,u({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,u({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,u({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,u({fontFamily:t})}setFontWeight(t){this.fontWeight=t,u({fontWeight:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,u({cacheConsoleLog:t}),t?S(this.consoleList):S([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,u({cacheNetworkLog:t}),t?T(this.networkList):T([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.cacheConsoleLog&&S([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.cacheNetworkLog&&T([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var o;const s=`${(o=e.method)==null?void 0:o.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:o}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,o),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(o){console.error("[DevTool] updateVuexStore error",o)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(E(e))return{};N(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:o}=t;return this.storageList.unshift({key:s,_oldKey:s,value:o}),e&&uni.setStorageSync(s,o),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(o=>o.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var o;const s=e||((o=t==null?void 0:t[0])==null?void 0:o.path)||"";return this.routeList=t.map((i,a)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&a===0?4:i.path===s?3:a===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?k():t:k(),s=this.prePath;this.routeList=this.routeList.map((n,L)=>({...n,index:n.path===e&&L===0?4:n.path===e?3:L===0?2:1}));const o=(n,L,v)=>{var f,g;if(!n[L])return n;n[L].uvList||(n[L].uvList=[]);const r=n[L],c=r.uvList??[];if(c.length){const l=c.length-1,p=c[l];if(p&&p.inTime&&!p.outTime){const h=Date.now();r.outTime=h,c[l].outTime=h,c[l].duration=h-p.inTime,r.duration=c[l].duration,r.totalDuration=c.reduce((d,w)=>d+(w.duration||0),0),v&&(r.visitTimes=c.length)}else{const h=Date.now();r.inTime=h,r.outTime=0,r.duration=0,(f=r.uvList)==null||f.push({index:l+1,inTime:h,outTime:0,duration:0}),v&&(r.visitTimes=(g=r.uvList)==null?void 0:g.length)}}else{const l=Date.now();r.inTime=l,r.outTime=0,r.duration=0,r.totalDuration=0,r.visitTimes=1,r.uvList=[{index:0,inTime:l,outTime:0,duration:0}]}return n},i=this.routeList.findIndex(n=>n.path===s),a=this.routeList.findIndex(n=>n.path===e);return i>-1&&o(this.routeList,i),a>-1&&o(this.routeList,a,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,o;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const a=this.wsDataMaxSize,n=((s=i.message)==null?void 0:s.length)??0;n>a&&((o=i.message)==null||o.splice(0,n-a))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;let s;return this.wsTaskMap.forEach((o,i)=>{s||(i.includes(t)||t.includes(i))&&(s=o)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],o=this.transferList.findIndex(i=>i.index===e);o>-1?this.transferList[o]={...this.transferList[o],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var g,l,p;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:o=12,tagFontSize:i=10,tipsFontSize:a=10,fontFamily:n="",fontWeight:L="normal",cacheInterceptConfig:v=!0,cacheNetworkLog:r=!1,cacheConsoleLog:c=!1}=y();this.devToolVisible=D(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=a,this.fontFamily=n,this.fontWeight=L,this.cacheInterceptConfig=v,this.cacheNetworkLog=r,this.cacheConsoleLog=c,this.cacheNetworkLog&&(this.networkList=m(),this.requestIndex=Math.max(...this.networkList.map(h=>h.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=z()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const f=((g=t.pagesJson)==null?void 0:g.pages.map(h=>{var d,w,x;return{...h,type:(x=(w=(d=t.pagesJson)==null?void 0:d.tabBar)==null?void 0:w.list)!=null&&x.some(I=>I.pagePath===h.path)?"nav":"main"}}))??[];(p=(l=t.pagesJson)==null?void 0:l.subPackages)==null||p.forEach(h=>{h.pages.forEach(d=>{f.push({...d,path:`${h.root}/${d.path}`,type:"sub",uvList:[]})})}),this.setRouteList(f)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=F()||b()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await W())}catch(s){console.error("[DevTool] Get IP error",s)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.cacheConsoleLog&&S([]),this.cacheNetworkLog&&T([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return k()}}export{K as DevStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../const.cjs"),n="dev-tool-network-list",i="dev-tool-console-list";function u(e){if(typeof uni>"u")return;const t=uni.getStorageSync(o.DEV_TOOL_INFO)||{};uni.setStorageSync(o.DEV_TOOL_INFO,{...t,...e})}function s(){return typeof uni>"u"?{}:uni.getStorageSync(o.DEV_TOOL_INFO)}function r(e){if(typeof uni>"u")return;const t=e.slice(-200);uni.setStorageSync(n,t)}function f(){return typeof uni>"u"?[]:uni.getStorageSync(n)||[]}function c(e){if(typeof uni>"u")return;const t=e.slice(-200);uni.setStorageSync(i,t)}function l(){return typeof uni>"u"?[]:uni.getStorageSync(i)||[]}exports.getDevToolConsoleList=l;exports.getDevToolInfo=s;exports.getDevToolNetworkList=f;exports.setDevToolConsoleList=c;exports.setDevToolInfo=u;exports.setDevToolNetworkList=r;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DevTool } from '../../type';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 缓存调试工具信息到本地
|
|
5
|
+
*/
|
|
6
|
+
export declare function setDevToolInfo(info: DevTool.DevToolInfo): void;
|
|
7
|
+
/**
|
|
8
|
+
* 获取本地缓存信息
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDevToolInfo(): DevTool.DevToolInfo;
|
|
11
|
+
/**
|
|
12
|
+
* 缓存网络日志
|
|
13
|
+
*/
|
|
14
|
+
export declare function setDevToolNetworkList(list: DevTool.NetworkItem[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* 获取缓存的网络日志
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDevToolNetworkList(): DevTool.NetworkItem[];
|
|
19
|
+
/**
|
|
20
|
+
* 缓存控制台日志
|
|
21
|
+
*/
|
|
22
|
+
export declare function setDevToolConsoleList(list: DevTool.ConsoleItem[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* 获取缓存的控制台日志
|
|
25
|
+
*/
|
|
26
|
+
export declare function getDevToolConsoleList(): DevTool.ConsoleItem[];
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|