vite-uni-dev-tool 1.1.0 → 1.2.1
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 +21 -1
- package/dist/const.cjs +1 -1
- package/dist/const.d.ts +2 -1
- package/dist/const.js +1 -1
- package/dist/core-shared.d.ts +2 -3
- package/dist/core.d.ts +8 -8
- package/dist/core.js +2 -2
- package/dist/i18n/index.d.ts +0 -1
- package/dist/i18n/instance.d.ts +0 -1
- package/dist/i18n/locales/en.cjs +1 -1
- package/dist/i18n/locales/en.d.ts +6 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.cjs +1 -1
- package/dist/i18n/locales/zh-Hans.d.ts +6 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modules/devConsole/index.cjs +4 -4
- package/dist/modules/devConsole/index.d.ts +6 -107
- package/dist/modules/devConsole/index.js +4 -4
- package/dist/modules/devEvent/index.cjs +3 -3
- package/dist/modules/devEvent/index.d.ts +2 -3
- package/dist/modules/devEvent/index.js +3 -3
- package/dist/modules/devIntercept/index.cjs +14 -14
- package/dist/modules/devIntercept/index.d.ts +34 -6
- package/dist/modules/devIntercept/index.js +14 -14
- package/dist/modules/devStore/index.cjs +1 -1
- package/dist/modules/devStore/index.d.ts +48 -40
- package/dist/modules/devStore/index.js +1 -1
- package/dist/modules/devToolInfo/index.cjs +1 -1
- package/dist/modules/devToolInfo/index.d.ts +6 -25
- package/dist/modules/devToolInfo/index.js +1 -1
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts +0 -1
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -2
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
- package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -2
- package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
- package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -2
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -1
- package/dist/plugins/utils/index.d.ts +0 -1
- package/dist/shims-uni.d.ts +26 -22
- package/dist/type.d.ts +47 -43
- package/dist/utils/array.d.ts +0 -1
- package/dist/utils/date.d.ts +0 -1
- package/dist/utils/file.d.ts +0 -1
- package/dist/utils/function.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/ip.d.ts +0 -1
- package/dist/utils/language.d.ts +14 -15
- package/dist/utils/object.cjs +1 -1
- package/dist/utils/object.d.ts +7 -8
- package/dist/utils/object.js +1 -1
- package/dist/utils/openLink.d.ts +0 -1
- package/dist/utils/page.d.ts +0 -1
- package/dist/utils/platform.d.ts +0 -1
- package/dist/utils/string.d.ts +0 -1
- package/dist/utils/utils.d.ts +0 -1
- package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -199
- package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -730
- package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -167
- package/dist/v3/DevTool/components/CaptureScreen/index.vue +109 -109
- package/dist/v3/DevTool/components/ConsoleList/ConsoleItem.vue +230 -225
- package/dist/v3/DevTool/components/ConsoleList/RunJSInput.vue +247 -247
- package/dist/v3/DevTool/components/ConsoleList/index.vue +171 -171
- package/dist/v3/DevTool/components/ConsoleList/staticTips.ts +1145 -1145
- package/dist/v3/DevTool/components/DevToolButton/index.vue +42 -6
- package/dist/v3/DevTool/components/DevToolTitle/index.vue +24 -24
- package/dist/v3/DevTool/components/DevToolWindow/DevToolOverlay.vue +197 -197
- package/dist/v3/DevTool/components/DevToolWindow/hooks/dataUtils.ts +48 -48
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +411 -387
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +644 -629
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolOverlay.ts +201 -197
- package/dist/v3/DevTool/components/DevToolWindow/index.vue +27 -64
- package/dist/v3/DevTool/components/ElEvent/ElEventItem.vue +105 -105
- package/dist/v3/DevTool/components/ElEvent/index.vue +106 -106
- package/dist/v3/DevTool/components/Instance/components/InstanceTreeNode.vue +265 -265
- package/dist/v3/DevTool/components/Instance/flatten.ts +226 -226
- package/dist/v3/DevTool/components/Instance/index.vue +94 -94
- package/dist/v3/DevTool/components/Instance/registry.ts +49 -49
- package/dist/v3/DevTool/components/Instance/transformTree.ts +393 -375
- package/dist/v3/DevTool/components/Instance/transformTreeCtx.ts +268 -268
- package/dist/v3/DevTool/components/Instance/typing.d.ts +43 -43
- package/dist/v3/DevTool/components/InstanceDetail/index.vue +485 -485
- package/dist/v3/DevTool/components/JsonDetail/index.vue +70 -70
- package/dist/v3/DevTool/components/NFCList/NFCItem.vue +112 -112
- package/dist/v3/DevTool/components/NFCList/NFCTool.vue +454 -454
- package/dist/v3/DevTool/components/NFCList/const.ts +56 -56
- package/dist/v3/DevTool/components/NFCList/index.vue +94 -94
- package/dist/v3/DevTool/components/NetworkList/InterceptConfig.vue +624 -624
- package/dist/v3/DevTool/components/NetworkList/InterceptItem.vue +140 -140
- package/dist/v3/DevTool/components/NetworkList/NetworkDetail.vue +287 -287
- package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +88 -88
- package/dist/v3/DevTool/components/NetworkList/NetworkItem.vue +163 -163
- package/dist/v3/DevTool/components/NetworkList/NetworkSend.vue +589 -589
- package/dist/v3/DevTool/components/NetworkList/const.ts +4 -4
- package/dist/v3/DevTool/components/NetworkList/hooks/useNetworkForm.ts +86 -86
- package/dist/v3/DevTool/components/NetworkList/index.vue +160 -160
- package/dist/v3/DevTool/components/NetworkList/utils.ts +101 -101
- package/dist/v3/DevTool/components/Performance/index.vue +498 -498
- package/dist/v3/DevTool/components/Performance/modules/PerformanceMetrics.vue +153 -153
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceChart.ts +460 -460
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceData.ts +258 -258
- package/dist/v3/DevTool/components/PiniaList/index.vue +93 -93
- package/dist/v3/DevTool/components/RunJS/index.vue +148 -148
- package/dist/v3/DevTool/components/ScanCodeList/ScanCodeItem.vue +97 -97
- package/dist/v3/DevTool/components/ScanCodeList/index.vue +100 -100
- package/dist/v3/DevTool/components/SettingButton/index.vue +45 -45
- package/dist/v3/DevTool/components/SettingList/index.vue +226 -218
- package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +320 -304
- package/dist/v3/DevTool/components/SettingList/modules/SettingDevTool.vue +212 -212
- package/dist/v3/DevTool/components/SettingList/modules/SettingInfo.vue +157 -157
- package/dist/v3/DevTool/components/SettingList/modules/SettingLanguage.vue +74 -74
- package/dist/v3/DevTool/components/SettingList/modules/SettingLog.vue +230 -230
- package/dist/v3/DevTool/components/SettingList/typing.d.ts +2 -2
- package/dist/v3/DevTool/components/SourceCode/Line.vue +127 -127
- package/dist/v3/DevTool/components/SourceCode/parseCode.ts +609 -609
- package/dist/v3/DevTool/components/StorageList/index.vue +174 -174
- package/dist/v3/DevTool/components/TransferList/TransferDetail.vue +268 -268
- package/dist/v3/DevTool/components/VuexList/index.vue +84 -84
- package/dist/v3/DevTool/index.vue +85 -138
- package/dist/v3/components/AppTransition/index.vue +156 -176
- package/dist/v3/components/AutoSizer/index.vue +192 -192
- package/dist/v3/components/AutoSizer/index1.vue +184 -184
- package/dist/v3/components/AutoSizer/utils.ts +49 -49
- package/dist/v3/components/Barrage/BarrageItem.vue +194 -137
- package/dist/v3/components/Barrage/index.vue +205 -202
- package/dist/v3/components/CircularButton/index.vue +84 -84
- package/dist/v3/components/CustomSwiper/CustomSwiperItem.vue +49 -49
- package/dist/v3/components/CustomSwiper/index.vue +104 -104
- package/dist/v3/components/DevErrorBoundary/index.vue +388 -0
- package/dist/v3/components/DraggableContainer/index.vue +186 -73
- package/dist/v3/components/Empty/index.vue +29 -29
- package/dist/v3/components/FilterSelect/index.vue +179 -179
- package/dist/v3/components/JsonPretty/components/Brackets/index.vue +27 -27
- package/dist/v3/components/JsonPretty/components/Carets/index.vue +59 -59
- package/dist/v3/components/JsonPretty/components/CheckController/index.vue +136 -136
- package/dist/v3/components/JsonPretty/components/TreeNode/index.vue +387 -387
- package/dist/v3/components/JsonPretty/hooks/useClipboard.ts +21 -21
- package/dist/v3/components/JsonPretty/hooks/useError.ts +21 -21
- package/dist/v3/components/JsonPretty/type.ts +127 -127
- package/dist/v3/components/JsonPretty/utils/index.ts +169 -169
- package/dist/v3/components/MovableContainer/index.vue +10 -4
- package/dist/v3/components/Pick/index.vue +321 -322
- package/dist/v3/components/Tag/index.vue +113 -113
- package/dist/v3/components/VirtualList/AutoSize.vue +40 -40
- package/dist/v3/components/VirtualList/index.vue +416 -416
- package/dist/v3/hooks/useBluetooth/index.ts +561 -561
- package/dist/v3/hooks/useContainerStyle.ts +95 -153
- package/dist/v3/hooks/useNFC/index.ts +107 -107
- package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
- package/dist/v3/hooks/useNFC/utils.ts +754 -754
- package/dist/v3/hooks/useRequest/index.ts +586 -586
- package/dist/v3/hooks/useRequest/utils.ts +267 -267
- package/dist/v3/hooks/useScanCode/index.ts +206 -206
- package/dist/v3/hooks/useWebsocket/index.ts +253 -253
- package/dist/v3/styles/theme.ts +12 -12
- package/package.json +70 -59
- package/dist/const.d.ts.map +0 -1
- package/dist/core-shared.d.ts.map +0 -1
- package/dist/core.d.ts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/instance.d.ts.map +0 -1
- package/dist/i18n/locales/en.d.ts.map +0 -1
- package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/devConsole/index.d.ts.map +0 -1
- package/dist/modules/devEvent/index.d.ts.map +0 -1
- package/dist/modules/devIntercept/index.d.ts.map +0 -1
- package/dist/modules/devStore/index.d.ts.map +0 -1
- package/dist/modules/devToolInfo/index.d.ts.map +0 -1
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +0 -1
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +0 -1
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +0 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -1
- package/dist/plugins/utils/index.d.ts.map +0 -1
- package/dist/type.d.ts.map +0 -1
- package/dist/utils/array.d.ts.map +0 -1
- package/dist/utils/date.d.ts.map +0 -1
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/function.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/ip.d.ts.map +0 -1
- package/dist/utils/language.d.ts.map +0 -1
- package/dist/utils/object.d.ts.map +0 -1
- package/dist/utils/openLink.d.ts.map +0 -1
- package/dist/utils/page.d.ts.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/string.d.ts.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
|
@@ -13,8 +13,8 @@ export declare class DevStore {
|
|
|
13
13
|
private storageList;
|
|
14
14
|
private vuexList;
|
|
15
15
|
private piniaList;
|
|
16
|
-
private vuexStore
|
|
17
|
-
private piniaStore
|
|
16
|
+
private vuexStore?;
|
|
17
|
+
private piniaStore?;
|
|
18
18
|
private routeList;
|
|
19
19
|
private prePath;
|
|
20
20
|
private wsList;
|
|
@@ -45,7 +45,7 @@ export declare class DevStore {
|
|
|
45
45
|
devToolBuildTime: string;
|
|
46
46
|
devToolGit: string;
|
|
47
47
|
private devToolOptions;
|
|
48
|
-
private
|
|
48
|
+
private devToolButtonVisible;
|
|
49
49
|
private devToolDestroy;
|
|
50
50
|
private cacheInterceptConfig;
|
|
51
51
|
private useTransition;
|
|
@@ -62,6 +62,7 @@ export declare class DevStore {
|
|
|
62
62
|
private barrageStartTop;
|
|
63
63
|
private barrageDuration;
|
|
64
64
|
private barrageMaxLength;
|
|
65
|
+
private barrageAllowDrag;
|
|
65
66
|
private barrageTypes;
|
|
66
67
|
private barrageShowWhenOpen;
|
|
67
68
|
private saveConsoleLogThrottled;
|
|
@@ -69,26 +70,28 @@ export declare class DevStore {
|
|
|
69
70
|
cacheMaxSize: number;
|
|
70
71
|
constructor();
|
|
71
72
|
updateHasUpload(): void;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
private setAndSync;
|
|
74
|
+
setDevToolButtonVisible(v: boolean): void;
|
|
75
|
+
getDevToolButtonVisible(): boolean;
|
|
76
|
+
setDevToolDestroy(v: boolean): void;
|
|
75
77
|
getDevToolDestroy(): boolean;
|
|
76
|
-
setCacheInterceptConfig(
|
|
78
|
+
setCacheInterceptConfig(v: boolean): void;
|
|
77
79
|
getCacheNetworkLog(): boolean;
|
|
78
|
-
setUseTransition(
|
|
79
|
-
setBaseFontSize(
|
|
80
|
-
setTagFontSize(
|
|
81
|
-
setTipsFontSize(
|
|
82
|
-
setFontFamily(
|
|
83
|
-
setFontWeight(
|
|
84
|
-
setBarrageVisible(
|
|
85
|
-
setBarrageMaxTracks(
|
|
86
|
-
setBarrageTrackHeight(
|
|
87
|
-
setBarrageStartTop(
|
|
88
|
-
setBarrageDuration(
|
|
89
|
-
setBarrageMaxLength(
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
setUseTransition(v: boolean): void;
|
|
81
|
+
setBaseFontSize(v: number): void;
|
|
82
|
+
setTagFontSize(v: number): void;
|
|
83
|
+
setTipsFontSize(v: number): void;
|
|
84
|
+
setFontFamily(v: string): void;
|
|
85
|
+
setFontWeight(v: string): void;
|
|
86
|
+
setBarrageVisible(v: boolean): void;
|
|
87
|
+
setBarrageMaxTracks(v: number): void;
|
|
88
|
+
setBarrageTrackHeight(v: number): void;
|
|
89
|
+
setBarrageStartTop(v: number): void;
|
|
90
|
+
setBarrageDuration(v: number): void;
|
|
91
|
+
setBarrageMaxLength(v: number): void;
|
|
92
|
+
setBarrageAllowDrag(v: boolean): void;
|
|
93
|
+
setBarrageTypes(v: string[]): void;
|
|
94
|
+
setBarrageShowWhenOpen(v: boolean): void;
|
|
92
95
|
setCacheConsoleLog(value: boolean): void;
|
|
93
96
|
setCacheNetworkLog(value: boolean): void;
|
|
94
97
|
getConsoleList(): DevTool.ConsoleItem[];
|
|
@@ -104,24 +107,30 @@ export declare class DevStore {
|
|
|
104
107
|
clearInterceptNetworkList(): void;
|
|
105
108
|
getStorageList(): DevTool.StorageItem[];
|
|
106
109
|
setStorageList(items: DevTool.StorageItem[]): DevTool.StorageItem[];
|
|
107
|
-
getVuexList(): Record<string,
|
|
108
|
-
getPiniaList(): Record<string,
|
|
109
|
-
setVuexStore(store:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
getVuexList(): Record<string, unknown>;
|
|
111
|
+
getPiniaList(): Record<string, unknown>;
|
|
112
|
+
setVuexStore(store: {
|
|
113
|
+
state: Record<string, unknown>;
|
|
114
|
+
}): void;
|
|
115
|
+
setVuexList(list: Record<string, unknown>): void;
|
|
116
|
+
setPiniaStore(store: {
|
|
117
|
+
state: {
|
|
118
|
+
value: Record<string, unknown>;
|
|
119
|
+
};
|
|
120
|
+
}): void;
|
|
121
|
+
setPiniaList(list: Record<string, unknown>): void;
|
|
113
122
|
updateStore(data: {
|
|
114
123
|
key: string;
|
|
115
124
|
_oldKey: string;
|
|
116
|
-
value:
|
|
125
|
+
value: unknown;
|
|
117
126
|
}): DevTool.StorageItem[];
|
|
118
|
-
updateVuexStore(data: Record<string,
|
|
119
|
-
updatePiniaStore(data: Record<string,
|
|
127
|
+
updateVuexStore(data: Record<string, unknown>): Record<string, unknown>;
|
|
128
|
+
updatePiniaStore(data: Record<string, unknown>): Record<string, unknown>;
|
|
120
129
|
clearStorageList(local?: boolean): DevTool.StorageItem[];
|
|
121
130
|
removeStorage(key: string, local?: boolean): DevTool.StorageItem[];
|
|
122
131
|
addStorage(data: {
|
|
123
132
|
key: string;
|
|
124
|
-
value:
|
|
133
|
+
value: unknown;
|
|
125
134
|
}, local?: boolean): DevTool.StorageItem[];
|
|
126
135
|
refreshStore(): DevTool.StorageItem[];
|
|
127
136
|
updateStoreList(addItems: DevTool.StorageItem[]): DevTool.StorageItem[];
|
|
@@ -155,13 +164,13 @@ export declare class DevStore {
|
|
|
155
164
|
getNfcList(): DevTool.NFCItem[];
|
|
156
165
|
getScreenIndex(): number;
|
|
157
166
|
setScreenIndex(index: number): number;
|
|
158
|
-
getSystemInfo(): Record<string,
|
|
159
|
-
getDeviceInfo(): Record<string,
|
|
160
|
-
getWindowInfo(): Record<string,
|
|
161
|
-
setSystemInfo(info: Record<string,
|
|
162
|
-
setDeviceInfo(info: Record<string,
|
|
163
|
-
setWindowInfo(info: Record<string,
|
|
164
|
-
setNetWorkStatus(info: Record<string,
|
|
167
|
+
getSystemInfo(): Record<string, unknown>;
|
|
168
|
+
getDeviceInfo(): Record<string, unknown>;
|
|
169
|
+
getWindowInfo(): Record<string, unknown>;
|
|
170
|
+
setSystemInfo(info: Record<string, unknown>): void;
|
|
171
|
+
setDeviceInfo(info: Record<string, unknown>): void;
|
|
172
|
+
setWindowInfo(info: Record<string, unknown>): void;
|
|
173
|
+
setNetWorkStatus(info: Record<string, unknown>): void;
|
|
165
174
|
updateScreenList(addItems: DevTool.ScreenItem[], index?: number): void;
|
|
166
175
|
updateScanCodeList(addItems: DevTool.ScanCodeItem[]): void;
|
|
167
176
|
updateNfcList(addItems: DevTool.NFCItem[]): void;
|
|
@@ -172,9 +181,8 @@ export declare class DevStore {
|
|
|
172
181
|
getDevToolOptions(): DevTool.DevToolOptions | undefined;
|
|
173
182
|
setDevToolOptions(options: DevTool.DevToolOptions): void;
|
|
174
183
|
getDevData(): Promise<DevTool.WindowData>;
|
|
175
|
-
getExportData(exports:
|
|
184
|
+
getExportData(exports: Record<string, boolean>): DevTool.WindowData;
|
|
176
185
|
clearDevCache(): void;
|
|
177
186
|
clearAll(): void;
|
|
178
187
|
getCurrentPagePath(): string;
|
|
179
188
|
}
|
|
180
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as w,setDevToolNetworkList as k,getDevToolNetworkList as M,getDevToolConsoleList as m,setDevToolInfo as a,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as y}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as F}from"../../utils/object.js";import{getCurrentPagePath as C}from"../../utils/page.js";import{getWifiIp as W,getLanIp as V,getMicroAppIp as B}from"../../utils/ip.js";class J{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,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.bluetoothList=[],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.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=y(()=>{this.cacheConsoleLog&&w(this.consoleList)},1e3),this.saveNetworkLogThrottled=y(()=>{this.cacheNetworkLog&&k(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:T=10,fontFamily:n="",fontWeight:L="normal",barrageVisible:d=!0,barrageMaxTracks:S=10,barrageTrackHeight:h=36,barrageStartTop:f=40,barrageDuration:g=6,barrageMaxLength:v=100,barrageTypes:u=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:p=!1,interceptNetworkList:b=[]}=uni.getStorageSync(I)||{};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=T,this.fontFamily=n,this.fontWeight=L,this.barrageVisible=d,this.barrageMaxTracks=S,this.barrageTrackHeight=h,this.barrageStartTop=f,this.barrageDuration=g,this.barrageMaxLength=v,this.barrageTypes=u,this.barrageShowWhenOpen=p,this.updateInterceptNetworkList(b),this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(x=>x.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}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,a({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,a({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,a({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,a({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,a({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,a({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,a({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,a({fontFamily:t})}setFontWeight(t){this.fontWeight=t,a({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,a({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,a({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,a({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,a({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,a({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,a({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,a({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,a({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,a({cacheConsoleLog:t}),t?w(this.consoleList):w([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,a({cacheNetworkLog:t}),t?k(this.networkList):k([])}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.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&w([])}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.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&k([])}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{};F(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==="/"?C():t:C(),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,T)=>{var d,S;if(!r[l])return r;r[l].uvList||(r[l].uvList=[]);const n=r[l],L=n.uvList??[];if(L.length){const h=L.length-1,f=L[h];if(f&&f.inTime&&!f.outTime){const g=Date.now();n.outTime=g,L[h].outTime=g,L[h].duration=g-f.inTime,n.duration=L[h].duration,n.totalDuration=L.reduce((v,u)=>v+(u.duration||0),0),T&&(n.visitTimes=L.length)}else{const g=Date.now();n.inTime=g,n.outTime=0,n.duration=0,(d=n.uvList)==null||d.push({index:h+1,inTime:g,outTime:0,duration:0}),T&&(n.visitTimes=(S=n.uvList)==null?void 0:S.length)}}else{const h=Date.now();n.inTime=h,n.outTime=0,n.duration=0,n.totalDuration=0,n.visitTimes=1,n.uvList=[{index:0,inTime:h,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;if(!t)return;let s;return this.wsTaskMap.forEach((o,i)=>{s||i&&(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)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,g,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:T=!0,cacheNetworkLog:n=!1,cacheConsoleLog:L=!1,barrageVisible:d=!0,barrageShowWhenOpen:S=!1}=D();this.devToolVisible=N(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=T,this.cacheNetworkLog=n,this.cacheConsoleLog=L,this.barrageVisible=d,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const h=((f=t.pagesJson)==null?void 0:f.pages.map(u=>{var p,b,x;return{...u,type:(x=(b=(p=t.pagesJson)==null?void 0:p.tabBar)==null?void 0:b.list)!=null&&x.some(z=>z.pagePath===u.path)?"nav":"main"}}))??[];(v=(g=t.pagesJson)==null?void 0:g.subPackages)==null||v.forEach(u=>{u.pages.forEach(p=>{h.push({...p,path:`${u.root}/${p.path}`,type:"sub",uvList:[]})})}),this.setRouteList(h)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=W()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await B())}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,bluetoothList:this.bluetoothList,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,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}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.bluetoothList=[],this.cacheConsoleLog&&w([]),this.cacheNetworkLog&&k([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return C()}}export{J as DevStore};
|
|
1
|
+
import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as T,setDevToolNetworkList as w,getDevToolNetworkList as y,getDevToolConsoleList as M,setDevToolInfo as k,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as m}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as B}from"../../utils/object.js";import{getCurrentPagePath as x}from"../../utils/page.js";import{getWifiIp as F,getLanIp as V,getMicroAppIp as W}from"../../utils/ip.js";class j{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,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.bluetoothList=[],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.devToolButtonVisible=!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.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageAllowDrag=!0,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=m(()=>{this.cacheConsoleLog&&T(this.consoleList)},1e3),this.saveNetworkLogThrottled=m(()=>{this.cacheNetworkLog&&w(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni>"u")return;const t=uni.getStorageSync(I)||{};Object.assign(this,t),this.devToolButtonVisible=t.devToolButtonVisible??!1,t.interceptNetworkList&&this.updateInterceptNetworkList(t.interceptNetworkList),this.cacheNetworkLog&&(this.networkList=y(),this.requestIndex=Math.max(...this.networkList.map(e=>e.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=M()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}updateHasUpload(){[this.consoleList,this.networkList,this.transferList,this.elEventList,this.uniEventList,this.screenList].forEach(e=>e.forEach(s=>s.hasUpload=!0))}setAndSync(t,e,s){this[t]=e,k({[s||t]:e})}setDevToolButtonVisible(t){this.setAndSync("devToolButtonVisible",t)}getDevToolButtonVisible(){return this.devToolButtonVisible}setDevToolDestroy(t){this.setAndSync("devToolDestroy",t)}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.setAndSync("cacheInterceptConfig",t)}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.setAndSync("useTransition",t)}setBaseFontSize(t){this.setAndSync("baseFontSize",t)}setTagFontSize(t){this.setAndSync("tagFontSize",t)}setTipsFontSize(t){this.setAndSync("tipsFontSize",t)}setFontFamily(t){this.setAndSync("fontFamily",t)}setFontWeight(t){this.setAndSync("fontWeight",t)}setBarrageVisible(t){this.setAndSync("barrageVisible",t)}setBarrageMaxTracks(t){this.setAndSync("barrageMaxTracks",t)}setBarrageTrackHeight(t){this.setAndSync("barrageTrackHeight",t)}setBarrageStartTop(t){this.setAndSync("barrageStartTop",t)}setBarrageDuration(t){this.setAndSync("barrageDuration",t)}setBarrageMaxLength(t){this.setAndSync("barrageMaxLength",t)}setBarrageAllowDrag(t){this.setAndSync("barrageAllowDrag",t)}setBarrageTypes(t){this.setAndSync("barrageTypes",t)}setBarrageShowWhenOpen(t){this.setAndSync("barrageShowWhenOpen",t)}setCacheConsoleLog(t){this.cacheConsoleLog=t,k({cacheConsoleLog:t}),T(t?this.consoleList:[])}setCacheNetworkLog(t){this.cacheNetworkLog=t,k({cacheNetworkLog:t}),w(t?this.networkList:[])}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.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&T([])}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.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&w([])}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{};B(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==="/"?x():t:x(),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,p)=>{var d,S;if(!n[l])return n;n[l].uvList||(n[l].uvList=[]);const r=n[l],c=r.uvList??[];if(c.length){const h=c.length-1,g=c[h];if(g&&g.inTime&&!g.outTime){const L=Date.now();r.outTime=L,c[h].outTime=L,c[h].duration=L-g.inTime,r.duration=c[h].duration,r.totalDuration=c.reduce((v,u)=>v+(u.duration||0),0),p&&(r.visitTimes=c.length)}else{const L=Date.now();r.inTime=L,r.outTime=0,r.duration=0,(d=r.uvList)==null||d.push({index:h+1,inTime:L,outTime:0,duration:0}),p&&(r.visitTimes=(S=r.uvList)==null?void 0:S.length)}}else{const h=Date.now();r.inTime=h,r.outTime=0,r.duration=0,r.totalDuration=0,r.visitTimes=1,r.uvList=[{index:0,inTime:h,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;if(!t)return;let s;return this.wsTaskMap.forEach((o,i)=>{s||i&&(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)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var g,L,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:a=10,fontFamily:n="",fontWeight:l="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:r=!1,cacheConsoleLog:c=!1,barrageVisible:d=!0,barrageShowWhenOpen:S=!1}=D();this.devToolButtonVisible=N(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=p,this.cacheNetworkLog=r,this.cacheConsoleLog=c,this.barrageVisible=d,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=y(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=M()),this.setDevToolButtonVisible(this.devToolButtonVisible),this.setDevToolDestroy(!this.devToolButtonVisible);const h=((g=t.pagesJson)==null?void 0:g.pages.map(u=>{var f,b,C;return{...u,type:(C=(b=(f=t.pagesJson)==null?void 0:f.tabBar)==null?void 0:b.list)!=null&&C.some(z=>z.pagePath===u.path)?"nav":"main"}}))??[];(v=(L=t.pagesJson)==null?void 0:L.subPackages)==null||v.forEach(u=>{u.pages.forEach(f=>{h.push({...f,path:`${u.root}/${f.path}`,type:"sub",uvList:[]})})}),this.setRouteList(h)}async getDevData(){var s,o,i,a;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=F()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await W())}catch(n){console.error("[DevTool] Get IP error",n)}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,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolButtonVisible(),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,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageAllowDrag:this.barrageAllowDrag,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,sourceFileServers:(s=this.devToolOptions)==null?void 0:s.sourceFileServers,mode:(o=this.devToolOptions)==null?void 0:o.mode,useDevSource:(i=this.devToolOptions)==null?void 0:i.useDevSource,zIndex:(a=this.devToolOptions)==null?void 0:a.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return Object.entries({exportLog:["consoleList"],exportNetwork:["networkList"],exportTransfer:["transferList"],exportWebSocket:["wsList"],exportUniEvent:["uniEventList"],exportElEvent:["elEventList"],exportScanCodeList:["scanCodeList"],exportNfcList:["nfcList"],exportStorage:["storageList","vuexList","piniaList"]}).forEach(([i,a])=>{t[i]&&a.forEach(n=>{e[n]=this[n]})}),Object.entries({Window:"windowInfo",Device:"deviceInfo",System:"systemInfo"}).forEach(([i,a])=>{var n;t[`export${i}`]&&(e[a]=((n=uni[`get${i}Info`])==null?void 0:n.call(uni))||{errMsg:"not supported"})}),e}clearDevCache(){["consoleList","networkList","wsList","transferList","elEventList","uniEventList","screenList","scanCodeList","nfcList","bluetoothList"].forEach(e=>{this[e]=[]}),this.cacheConsoleLog&&T([]),this.cacheNetworkLog&&w([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return x()}}export{j as DevStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../const.cjs"),l="dev-tool-network-list",i="dev-tool-console-list",s=o=>({set:e=>uni==null?void 0:uni.setStorageSync(o,e.slice(-200)),get:()=>(uni==null?void 0:uni.getStorageSync(o))||[]}),n=s(l),c=s(i),T=o=>{const e=(uni==null?void 0:uni.getStorageSync(t.DEV_TOOL_INFO))||{};uni==null||uni.setStorageSync(t.DEV_TOOL_INFO,{...e,...o})},g=()=>(uni==null?void 0:uni.getStorageSync(t.DEV_TOOL_INFO))||{},r=n.set,D=n.get,O=c.set,v=c.get;exports.getDevToolConsoleList=v;exports.getDevToolInfo=g;exports.getDevToolNetworkList=D;exports.setDevToolConsoleList=O;exports.setDevToolInfo=T;exports.setDevToolNetworkList=r;
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
import { DevTool } from '../../type';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
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
|
|
3
|
+
export declare const setDevToolInfo: (info: DevTool.DevToolInfo) => void;
|
|
4
|
+
export declare const getDevToolInfo: () => DevTool.DevToolInfo;
|
|
5
|
+
export declare const setDevToolNetworkList: (list: DevTool.NetworkItem[]) => void;
|
|
6
|
+
export declare const getDevToolNetworkList: () => DevTool.NetworkItem[];
|
|
7
|
+
export declare const setDevToolConsoleList: (list: DevTool.ConsoleItem[]) => void;
|
|
8
|
+
export declare const getDevToolConsoleList: () => DevTool.ConsoleItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEV_TOOL_INFO as
|
|
1
|
+
import{DEV_TOOL_INFO as e}from"../../const.js";const l="dev-tool-network-list",g="dev-tool-console-list",s=o=>({set:t=>uni==null?void 0:uni.setStorageSync(o,t.slice(-200)),get:()=>(uni==null?void 0:uni.getStorageSync(o))||[]}),n=s(l),c=s(g),S=o=>{const t=(uni==null?void 0:uni.getStorageSync(e))||{};uni==null||uni.setStorageSync(e,{...t,...o})},r=()=>(uni==null?void 0:uni.getStorageSync(e))||{},T=n.set,L=n.get,O=c.set,v=c.get;export{v as getDevToolConsoleList,r as getDevToolInfo,L as getDevToolNetworkList,O as setDevToolConsoleList,S as setDevToolInfo,T as setDevToolNetworkList};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`),t=
|
|
3
|
-
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../utils/index.cjs");function p(r){const{lines:s,useErrorBoundary:e}=r,n=[...s],t=c.findInsertionIndex(n,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(t!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),n.splice(t,0,...o)}const i=c.findInsertionIndex(n,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),n.splice(i+1,0,...o)}return n}const d=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
|
|
2
|
+
`),t=p({lines:e,useErrorBoundary:!!s});return t.length===e.length&&t.every((i,o)=>i===e[o])?{code:r,map:null}:{code:t.join(`
|
|
3
|
+
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};exports.transformMain=d;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface TransformMainOptions {
|
|
2
2
|
code: string;
|
|
3
|
+
useErrorBoundary: boolean;
|
|
3
4
|
}
|
|
4
5
|
/**
|
|
5
6
|
* 转换 main.ts|js 文件
|
|
@@ -15,9 +16,8 @@ interface TransformMainOptions {
|
|
|
15
16
|
* map: any;
|
|
16
17
|
* }}
|
|
17
18
|
*/
|
|
18
|
-
export declare const transformMain: ({ code, }: TransformMainOptions) => {
|
|
19
|
+
export declare const transformMain: ({ code, useErrorBoundary, }: TransformMainOptions) => {
|
|
19
20
|
code: string;
|
|
20
21
|
map: any;
|
|
21
22
|
};
|
|
22
23
|
export {};
|
|
23
|
-
//# sourceMappingURL=transformMain.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{findInsertionIndex as
|
|
2
|
-
`),
|
|
3
|
-
`),map:null}}catch(
|
|
1
|
+
import{findInsertionIndex as p}from"../../utils/index.js";function c(r){const{lines:s,useErrorBoundary:e}=r,t=[...s],n=p(t,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(n!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),t.splice(n,0,...o)}const i=p(t,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),t.splice(i+1,0,...o)}return t}const u=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
|
|
2
|
+
`),n=c({lines:e,useErrorBoundary:!!s});return n.length===e.length&&n.every((i,o)=>i===e[o])?{code:r,map:null}:{code:n.join(`
|
|
3
|
+
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};export{u as transformMain};
|
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
${
|
|
3
|
-
${
|
|
4
|
-
`.trim();return e.replace(
|
|
5
|
-
${
|
|
6
|
-
<\/script>`)}function
|
|
7
|
-
function devCaptureTapEvent(e${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../utils/index.cjs");let v=null;function m(e){var o;if(v)return v;const t=new Set;return e.pages.forEach(n=>t.add(n.path)),(o=e.subPackages)==null||o.forEach(n=>{n.pages.forEach(a=>t.add(`${n.root}/${a.path}`))}),v=t,t}function h(e,t){const o=m(t);return{isPage:Array.from(o).some(a=>e.includes(a.replace(/\\/g,"/"))),isSubPage:!1}}function f(e,t,o,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:c.hasImportConsole(e),usesConsole:c.hasUseConsole(e),isExcludedFromConsole:!c.hasDirOrFile(t,o)}}function C(e,t,o,n){const{isPage:a}=h(e,o);return a?{isPageOrSubPage:!0,hasTemplate:t.indexOf("<template>")!==-1,isExcludedFromDevTool:!c.hasDirOrFile(e,n)}:{isPageOrSubPage:!1,hasTemplate:!1,isExcludedFromDevTool:!0}}function g(e,t,o){const n=e.match(c.regScript);if(!n||!n[1])return e;const a=n[1];let r="";o&&(r="import { console } from 'vite-uni-dev-tool/dist/core';");const s=`
|
|
2
|
+
${r}
|
|
3
|
+
${a}
|
|
4
|
+
`.trim();return e.replace(c.regScript,()=>`${t}
|
|
5
|
+
${s}
|
|
6
|
+
<\/script>`)}function T(e,t){const o=e.match(c.regScript);if(!o||!o[1])return e;const n=o[1];if(n.includes("devCaptureTapEvent"))return e;const r=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",s=`
|
|
7
|
+
function devCaptureTapEvent(e${r}) {
|
|
8
8
|
uni?.$emit('dev-capture-tap-event', e);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function devCaptureTouchStartEvent(e${
|
|
11
|
+
function devCaptureTouchStartEvent(e${r}) {
|
|
12
12
|
uni?.$emit('dev-capture-touch-start-event', e);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function devCaptureTouchMoveEvent(e${
|
|
15
|
+
function devCaptureTouchMoveEvent(e${r}) {
|
|
16
16
|
uni?.$emit('dev-capture-touch-move-event', e);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function devCaptureTouchEndEvent(e${
|
|
19
|
+
function devCaptureTouchEndEvent(e${r}) {
|
|
20
20
|
uni?.$emit('dev-capture-touch-end-event', e);
|
|
21
21
|
}
|
|
22
|
-
`,
|
|
22
|
+
`,p=`
|
|
23
23
|
${n}
|
|
24
|
-
${u}
|
|
25
|
-
`.trim();return e.replace(i.regScript,()=>`${t}
|
|
26
24
|
${s}
|
|
27
|
-
|
|
28
|
-
${
|
|
25
|
+
`.trim();return e.replace(c.regScript,()=>`${t}
|
|
26
|
+
${p}
|
|
27
|
+
<\/script>`)}function E(e,t){const o=c.getTemplateContent(e);if(!o)return e;const{pageMetas:n,resetContent:a}=c.extractTopLevelPageMeta(o);let r=`
|
|
28
|
+
<view
|
|
29
|
+
data-dev-capture
|
|
30
|
+
@tap.capture="devCaptureTapEvent"
|
|
31
|
+
@touchstart.capture="devCaptureTouchStartEvent"
|
|
32
|
+
@touchmove.capture="devCaptureTouchMoveEvent"
|
|
33
|
+
@touchend.capture="devCaptureTouchEndEvent"
|
|
34
|
+
>
|
|
35
|
+
${a}
|
|
36
|
+
</view>
|
|
37
|
+
`;t&&(r=`
|
|
38
|
+
<DevErrorBoundary>
|
|
39
|
+
${r}
|
|
40
|
+
</DevErrorBoundary>
|
|
41
|
+
`);const s=`
|
|
42
|
+
${n}
|
|
29
43
|
<view data-dev-page>
|
|
30
|
-
|
|
31
|
-
data-dev-capture
|
|
32
|
-
@tap.capture="devCaptureTapEvent"
|
|
33
|
-
@touchstart.capture="devCaptureTouchStartEvent"
|
|
34
|
-
@touchmove.capture="devCaptureTouchMoveEvent"
|
|
35
|
-
@touchend.capture="devCaptureTouchEndEvent"
|
|
36
|
-
>
|
|
37
|
-
${n}
|
|
38
|
-
</view>
|
|
44
|
+
${r}
|
|
39
45
|
<DevTool />
|
|
40
46
|
</view>
|
|
41
|
-
`;return e.replace(
|
|
47
|
+
`;return e.replace(o,()=>s)}const $=({id:e,code:t,pages:o,scriptRow:n,importConsole:a,excludeImportConsole:r,excludeImportDevTool:s,useErrorBoundary:p})=>{try{let i=t;const u=f(t,e,r,a),d=u.shouldInjectConsole&&!u.hasExistingConsoleImport&&u.usesConsole&&u.isExcludedFromConsole;d&&(i=g(i,n,d));const l=C(e,t,o,s);return l.isPageOrSubPage&&l.hasTemplate&&l.isExcludedFromDevTool&&(i=E(i,p),i=T(i,n)),{code:i,map:null}}catch(i){return console.error("[DevTool] 转换 Vue 文件时出错:",i),{code:t,map:null}}};exports.transformVue=$;
|
|
@@ -16,6 +16,7 @@ interface TransformVueOptions {
|
|
|
16
16
|
importConsole?: boolean;
|
|
17
17
|
excludeImportConsole: string[];
|
|
18
18
|
excludeImportDevTool: string[];
|
|
19
|
+
useErrorBoundary: boolean;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
*
|
|
@@ -33,9 +34,8 @@ interface TransformVueOptions {
|
|
|
33
34
|
* }
|
|
34
35
|
* @return {*} {{ code: string; map: any }}
|
|
35
36
|
*/
|
|
36
|
-
export declare const transformVue: ({ id, code, pages, scriptRow, importConsole, excludeImportConsole, excludeImportDevTool, }: TransformVueOptions) => {
|
|
37
|
+
export declare const transformVue: ({ id, code, pages, scriptRow, importConsole, excludeImportConsole, excludeImportDevTool, useErrorBoundary, }: TransformVueOptions) => {
|
|
37
38
|
code: string;
|
|
38
39
|
map: any;
|
|
39
40
|
};
|
|
40
41
|
export {};
|
|
41
|
-
//# sourceMappingURL=transformVue.d.ts.map
|
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
import{hasDirOrFile as
|
|
2
|
-
${
|
|
3
|
-
${
|
|
1
|
+
import{hasDirOrFile as m,hasUseConsole as h,hasImportConsole as f,regScript as i,getTemplateContent as C,extractTopLevelPageMeta as g}from"../../utils/index.js";let v=null;function T(e){var o;if(v)return v;const t=new Set;return e.pages.forEach(n=>t.add(n.path)),(o=e.subPackages)==null||o.forEach(n=>{n.pages.forEach(a=>t.add(`${n.root}/${a.path}`))}),v=t,t}function E(e,t){const o=T(t);return{isPage:Array.from(o).some(a=>e.includes(a.replace(/\\/g,"/"))),isSubPage:!1}}function $(e,t,o,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:f(e),usesConsole:h(e),isExcludedFromConsole:!m(t,o)}}function S(e,t,o,n){const{isPage:a}=E(e,o);return a?{isPageOrSubPage:!0,hasTemplate:t.indexOf("<template>")!==-1,isExcludedFromDevTool:!m(e,n)}:{isPageOrSubPage:!1,hasTemplate:!1,isExcludedFromDevTool:!0}}function P(e,t,o){const n=e.match(i);if(!n||!n[1])return e;const a=n[1];let r="";o&&(r="import { console } from 'vite-uni-dev-tool/dist/core';");const s=`
|
|
2
|
+
${r}
|
|
3
|
+
${a}
|
|
4
4
|
`.trim();return e.replace(i,()=>`${t}
|
|
5
|
-
${
|
|
6
|
-
<\/script>`)}function
|
|
7
|
-
function devCaptureTapEvent(e${
|
|
5
|
+
${s}
|
|
6
|
+
<\/script>`)}function x(e,t){const o=e.match(i);if(!o||!o[1])return e;const n=o[1];if(n.includes("devCaptureTapEvent"))return e;const r=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",s=`
|
|
7
|
+
function devCaptureTapEvent(e${r}) {
|
|
8
8
|
uni?.$emit('dev-capture-tap-event', e);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function devCaptureTouchStartEvent(e${
|
|
11
|
+
function devCaptureTouchStartEvent(e${r}) {
|
|
12
12
|
uni?.$emit('dev-capture-touch-start-event', e);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function devCaptureTouchMoveEvent(e${
|
|
15
|
+
function devCaptureTouchMoveEvent(e${r}) {
|
|
16
16
|
uni?.$emit('dev-capture-touch-move-event', e);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function devCaptureTouchEndEvent(e${
|
|
19
|
+
function devCaptureTouchEndEvent(e${r}) {
|
|
20
20
|
uni?.$emit('dev-capture-touch-end-event', e);
|
|
21
21
|
}
|
|
22
|
-
`,
|
|
22
|
+
`,p=`
|
|
23
23
|
${n}
|
|
24
|
-
${u}
|
|
25
|
-
`.trim();return e.replace(i,()=>`${t}
|
|
26
24
|
${s}
|
|
27
|
-
|
|
28
|
-
${
|
|
25
|
+
`.trim();return e.replace(i,()=>`${t}
|
|
26
|
+
${p}
|
|
27
|
+
<\/script>`)}function D(e,t){const o=C(e);if(!o)return e;const{pageMetas:n,resetContent:a}=g(o);let r=`
|
|
28
|
+
<view
|
|
29
|
+
data-dev-capture
|
|
30
|
+
@tap.capture="devCaptureTapEvent"
|
|
31
|
+
@touchstart.capture="devCaptureTouchStartEvent"
|
|
32
|
+
@touchmove.capture="devCaptureTouchMoveEvent"
|
|
33
|
+
@touchend.capture="devCaptureTouchEndEvent"
|
|
34
|
+
>
|
|
35
|
+
${a}
|
|
36
|
+
</view>
|
|
37
|
+
`;t&&(r=`
|
|
38
|
+
<DevErrorBoundary>
|
|
39
|
+
${r}
|
|
40
|
+
</DevErrorBoundary>
|
|
41
|
+
`);const s=`
|
|
42
|
+
${n}
|
|
29
43
|
<view data-dev-page>
|
|
30
|
-
|
|
31
|
-
data-dev-capture
|
|
32
|
-
@tap.capture="devCaptureTapEvent"
|
|
33
|
-
@touchstart.capture="devCaptureTouchStartEvent"
|
|
34
|
-
@touchmove.capture="devCaptureTouchMoveEvent"
|
|
35
|
-
@touchend.capture="devCaptureTouchEndEvent"
|
|
36
|
-
>
|
|
37
|
-
${n}
|
|
38
|
-
</view>
|
|
44
|
+
${r}
|
|
39
45
|
<DevTool />
|
|
40
46
|
</view>
|
|
41
|
-
`;return e.replace(
|
|
47
|
+
`;return e.replace(o,()=>s)}const F=({id:e,code:t,pages:o,scriptRow:n,importConsole:a,excludeImportConsole:r,excludeImportDevTool:s,useErrorBoundary:p})=>{try{let c=t;const u=$(t,e,r,a),d=u.shouldInjectConsole&&!u.hasExistingConsoleImport&&u.usesConsole&&u.isExcludedFromConsole;d&&(c=P(c,n,d));const l=S(e,t,o,s);return l.isPageOrSubPage&&l.hasTemplate&&l.isExcludedFromDevTool&&(c=D(c,p),c=x(c,n)),{code:c,map:null}}catch(c){return console.error("[DevTool] 转换 Vue 文件时出错:",c),{code:t,map:null}}};export{F as transformVue};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const A=require("path"),b=require("fs"),c=require("../utils/index.cjs"),q=require("./transform/transformMain.cjs"),w=require("./transform/transformApp.cjs"),T=require("./transform/transformVue.cjs");function v(a){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const _=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(f,l,_.get?_:{enumerable:!0,get:()=>a[l]})}}return f.default=a,Object.freeze(f)}const L=v(A),M=v(b),m={isReady:!1,urls:[]};function O({pages:a,sourceFileServers:f,importConsole:l,excludeImportConsole:_=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:S=["uni_modules","node_modules"],captureList:y=[],injectDevTool:h=!0,useErrorBoundary:g=!0,...d}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var t;e.middlewares.use((n,o,i)=>{const{originalUrl:r}=n;if(d.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const u=r.replace("/__dev_sourcefile__","");try{const p=e.config.root,s=L.join(p,u),j=M.readFileSync(s,"utf-8");o.setHeader("Content-Type",c.getContentType(s)),o.end(j)}catch{i()}}else i()}),(t=e.httpServer)==null||t.once("listening",()=>{var i;const n=(i=e.httpServer)==null?void 0:i.address(),o=c.getLocalIPs();if(n&&!Array.isArray(n)&&typeof n!="string"){const r=o.map(u=>`http://${u}:${n.port}/__dev_sourcefile__`);m.isReady=!0,m.urls=r,console.warn(`
|
|
2
2
|
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
-
${
|
|
3
|
+
${o.map(u=>`➜ Source File Network: http://${u}:${n==null?void 0:n.port}/__dev_sourcefile__`).join(`
|
|
4
4
|
`)}
|
|
5
|
-
`)}})},transform(t
|
|
5
|
+
`)}})},transform(e,t){if(!h||t.includes("node_modules")||t.includes("?vue&type=style")||t.includes(".scss")||t.includes(".css")||t.includes(".json"))return;const n=c.isVueFile(t),o=c.isMainFile(t),i=c.isAppVue(t);if(!n&&!o&&!i)return;const r=c.hasLangTS(e),u=c.hasLangJS(e),p=c.hasSetup(e);let s="<script>";return r&&p?s='<script lang="ts" setup>':u&&p?s='<script lang="js" setup>':u?s='<script lang="js">':r?s='<script lang="ts">':p&&(s="<script setup>"),o?q.transformMain({code:e,useErrorBoundary:g}):i?w.transformApp({code:e,isSetup:p,importConsole:l,scriptRow:s,netWorkInfo:m,sourceFileServers:f,reset:{...d,captureList:y}}):n?T.transformVue({id:t,code:e,pages:a,scriptRow:s,importConsole:l,excludeImportConsole:_,excludeImportDevTool:S,useErrorBoundary:g}):{code:e,map:null}}}}module.exports=O;
|
|
@@ -43,7 +43,7 @@ type UploadAbnormalUV = {
|
|
|
43
43
|
* }
|
|
44
44
|
* @return {*} {Plugin}
|
|
45
45
|
*/
|
|
46
|
-
export default function uniDevTool({ pages, sourceFileServers, importConsole, excludeImportConsole, excludeImportDevTool, captureList, injectDevTool, ...reset }: {
|
|
46
|
+
export default function uniDevTool({ pages, sourceFileServers, importConsole, excludeImportConsole, excludeImportDevTool, captureList, injectDevTool, useErrorBoundary, ...reset }: {
|
|
47
47
|
/** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
|
|
48
48
|
enableInterceptPromiseReject?: boolean;
|
|
49
49
|
/** 打开窗口时隐藏按钮 */
|
|
@@ -106,8 +106,9 @@ export default function uniDevTool({ pages, sourceFileServers, importConsole, ex
|
|
|
106
106
|
injectDevTool?: boolean;
|
|
107
107
|
/** 异常上报 */
|
|
108
108
|
uploadAbnormalUV?: UploadAbnormalUV;
|
|
109
|
+
/** 是否开启错误边界,默认开启 */
|
|
110
|
+
useErrorBoundary?: boolean;
|
|
109
111
|
/** 环境模式 */
|
|
110
112
|
mode?: string;
|
|
111
113
|
}): Plugin;
|
|
112
114
|
export {};
|
|
113
|
-
//# sourceMappingURL=uniDevTool.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as y from"path";import*as A from"fs";import{isVueFile as j,isMainFile as w,isAppVue as L,hasLangTS as T,hasLangJS as $,hasSetup as F,getContentType as V,getLocalIPs as M}from"../utils/index.js";import{transformMain as P}from"./transform/transformMain.js";import{transformApp as R}from"./transform/transformApp.js";import{transformVue as k}from"./transform/transformVue.js";const c={isReady:!1,urls:[]};function H({pages:_,sourceFileServers:m,importConsole:p,excludeImportConsole:g=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:d=["uni_modules","node_modules"],captureList:v=[],injectDevTool:S=!0,useErrorBoundary:a=!0,...f}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var t;e.middlewares.use((s,o,i)=>{const{originalUrl:r}=s;if(f.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const u=r.replace("/__dev_sourcefile__","");try{const l=e.config.root,n=y.join(l,u),h=A.readFileSync(n,"utf-8");o.setHeader("Content-Type",V(n)),o.end(h)}catch{i()}}else i()}),(t=e.httpServer)==null||t.once("listening",()=>{var i;const s=(i=e.httpServer)==null?void 0:i.address(),o=M();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=o.map(u=>`http://${u}:${s.port}/__dev_sourcefile__`);c.isReady=!0,c.urls=r,console.warn(`
|
|
2
2
|
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
-
${
|
|
3
|
+
${o.map(u=>`➜ Source File Network: http://${u}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
|
|
4
4
|
`)}
|
|
5
|
-
`)}})},transform(t
|
|
5
|
+
`)}})},transform(e,t){if(!S||t.includes("node_modules")||t.includes("?vue&type=style")||t.includes(".scss")||t.includes(".css")||t.includes(".json"))return;const s=j(t),o=w(t),i=L(t);if(!s&&!o&&!i)return;const r=T(e),u=$(e),l=F(e);let n="<script>";return r&&l?n='<script lang="ts" setup>':u&&l?n='<script lang="js" setup>':u?n='<script lang="js">':r?n='<script lang="ts">':l&&(n="<script setup>"),o?P({code:e,useErrorBoundary:a}):i?R({code:e,isSetup:l,importConsole:p,scriptRow:n,netWorkInfo:c,sourceFileServers:m,reset:{...f,captureList:v}}):s?k({id:t,code:e,pages:_,scriptRow:n,importConsole:p,excludeImportConsole:g,excludeImportDevTool:d,useErrorBoundary:a}):{code:e,map:null}}}}export{H as default};
|