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.
Files changed (195) hide show
  1. package/README.md +21 -1
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +2 -1
  4. package/dist/const.js +1 -1
  5. package/dist/core-shared.d.ts +2 -3
  6. package/dist/core.d.ts +8 -8
  7. package/dist/core.js +2 -2
  8. package/dist/i18n/index.d.ts +0 -1
  9. package/dist/i18n/instance.d.ts +0 -1
  10. package/dist/i18n/locales/en.cjs +1 -1
  11. package/dist/i18n/locales/en.d.ts +6 -1
  12. package/dist/i18n/locales/en.js +1 -1
  13. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  14. package/dist/i18n/locales/zh-Hans.d.ts +6 -1
  15. package/dist/i18n/locales/zh-Hans.js +1 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/modules/devConsole/index.cjs +4 -4
  18. package/dist/modules/devConsole/index.d.ts +6 -107
  19. package/dist/modules/devConsole/index.js +4 -4
  20. package/dist/modules/devEvent/index.cjs +3 -3
  21. package/dist/modules/devEvent/index.d.ts +2 -3
  22. package/dist/modules/devEvent/index.js +3 -3
  23. package/dist/modules/devIntercept/index.cjs +14 -14
  24. package/dist/modules/devIntercept/index.d.ts +34 -6
  25. package/dist/modules/devIntercept/index.js +14 -14
  26. package/dist/modules/devStore/index.cjs +1 -1
  27. package/dist/modules/devStore/index.d.ts +48 -40
  28. package/dist/modules/devStore/index.js +1 -1
  29. package/dist/modules/devToolInfo/index.cjs +1 -1
  30. package/dist/modules/devToolInfo/index.d.ts +6 -25
  31. package/dist/modules/devToolInfo/index.js +1 -1
  32. package/dist/plugins/uniDevTool/transform/transformApp.d.ts +0 -1
  33. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
  34. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -2
  35. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  36. package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
  37. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -2
  38. package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
  39. package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
  40. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -2
  41. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  42. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -1
  43. package/dist/plugins/utils/index.d.ts +0 -1
  44. package/dist/shims-uni.d.ts +26 -22
  45. package/dist/type.d.ts +47 -43
  46. package/dist/utils/array.d.ts +0 -1
  47. package/dist/utils/date.d.ts +0 -1
  48. package/dist/utils/file.d.ts +0 -1
  49. package/dist/utils/function.d.ts +0 -1
  50. package/dist/utils/index.d.ts +0 -1
  51. package/dist/utils/ip.d.ts +0 -1
  52. package/dist/utils/language.d.ts +14 -15
  53. package/dist/utils/object.cjs +1 -1
  54. package/dist/utils/object.d.ts +7 -8
  55. package/dist/utils/object.js +1 -1
  56. package/dist/utils/openLink.d.ts +0 -1
  57. package/dist/utils/page.d.ts +0 -1
  58. package/dist/utils/platform.d.ts +0 -1
  59. package/dist/utils/string.d.ts +0 -1
  60. package/dist/utils/utils.d.ts +0 -1
  61. package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -199
  62. package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -730
  63. package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -167
  64. package/dist/v3/DevTool/components/CaptureScreen/index.vue +109 -109
  65. package/dist/v3/DevTool/components/ConsoleList/ConsoleItem.vue +230 -225
  66. package/dist/v3/DevTool/components/ConsoleList/RunJSInput.vue +247 -247
  67. package/dist/v3/DevTool/components/ConsoleList/index.vue +171 -171
  68. package/dist/v3/DevTool/components/ConsoleList/staticTips.ts +1145 -1145
  69. package/dist/v3/DevTool/components/DevToolButton/index.vue +42 -6
  70. package/dist/v3/DevTool/components/DevToolTitle/index.vue +24 -24
  71. package/dist/v3/DevTool/components/DevToolWindow/DevToolOverlay.vue +197 -197
  72. package/dist/v3/DevTool/components/DevToolWindow/hooks/dataUtils.ts +48 -48
  73. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +411 -387
  74. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +644 -629
  75. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolOverlay.ts +201 -197
  76. package/dist/v3/DevTool/components/DevToolWindow/index.vue +27 -64
  77. package/dist/v3/DevTool/components/ElEvent/ElEventItem.vue +105 -105
  78. package/dist/v3/DevTool/components/ElEvent/index.vue +106 -106
  79. package/dist/v3/DevTool/components/Instance/components/InstanceTreeNode.vue +265 -265
  80. package/dist/v3/DevTool/components/Instance/flatten.ts +226 -226
  81. package/dist/v3/DevTool/components/Instance/index.vue +94 -94
  82. package/dist/v3/DevTool/components/Instance/registry.ts +49 -49
  83. package/dist/v3/DevTool/components/Instance/transformTree.ts +393 -375
  84. package/dist/v3/DevTool/components/Instance/transformTreeCtx.ts +268 -268
  85. package/dist/v3/DevTool/components/Instance/typing.d.ts +43 -43
  86. package/dist/v3/DevTool/components/InstanceDetail/index.vue +485 -485
  87. package/dist/v3/DevTool/components/JsonDetail/index.vue +70 -70
  88. package/dist/v3/DevTool/components/NFCList/NFCItem.vue +112 -112
  89. package/dist/v3/DevTool/components/NFCList/NFCTool.vue +454 -454
  90. package/dist/v3/DevTool/components/NFCList/const.ts +56 -56
  91. package/dist/v3/DevTool/components/NFCList/index.vue +94 -94
  92. package/dist/v3/DevTool/components/NetworkList/InterceptConfig.vue +624 -624
  93. package/dist/v3/DevTool/components/NetworkList/InterceptItem.vue +140 -140
  94. package/dist/v3/DevTool/components/NetworkList/NetworkDetail.vue +287 -287
  95. package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +88 -88
  96. package/dist/v3/DevTool/components/NetworkList/NetworkItem.vue +163 -163
  97. package/dist/v3/DevTool/components/NetworkList/NetworkSend.vue +589 -589
  98. package/dist/v3/DevTool/components/NetworkList/const.ts +4 -4
  99. package/dist/v3/DevTool/components/NetworkList/hooks/useNetworkForm.ts +86 -86
  100. package/dist/v3/DevTool/components/NetworkList/index.vue +160 -160
  101. package/dist/v3/DevTool/components/NetworkList/utils.ts +101 -101
  102. package/dist/v3/DevTool/components/Performance/index.vue +498 -498
  103. package/dist/v3/DevTool/components/Performance/modules/PerformanceMetrics.vue +153 -153
  104. package/dist/v3/DevTool/components/Performance/modules/usePerformanceChart.ts +460 -460
  105. package/dist/v3/DevTool/components/Performance/modules/usePerformanceData.ts +258 -258
  106. package/dist/v3/DevTool/components/PiniaList/index.vue +93 -93
  107. package/dist/v3/DevTool/components/RunJS/index.vue +148 -148
  108. package/dist/v3/DevTool/components/ScanCodeList/ScanCodeItem.vue +97 -97
  109. package/dist/v3/DevTool/components/ScanCodeList/index.vue +100 -100
  110. package/dist/v3/DevTool/components/SettingButton/index.vue +45 -45
  111. package/dist/v3/DevTool/components/SettingList/index.vue +226 -218
  112. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +320 -304
  113. package/dist/v3/DevTool/components/SettingList/modules/SettingDevTool.vue +212 -212
  114. package/dist/v3/DevTool/components/SettingList/modules/SettingInfo.vue +157 -157
  115. package/dist/v3/DevTool/components/SettingList/modules/SettingLanguage.vue +74 -74
  116. package/dist/v3/DevTool/components/SettingList/modules/SettingLog.vue +230 -230
  117. package/dist/v3/DevTool/components/SettingList/typing.d.ts +2 -2
  118. package/dist/v3/DevTool/components/SourceCode/Line.vue +127 -127
  119. package/dist/v3/DevTool/components/SourceCode/parseCode.ts +609 -609
  120. package/dist/v3/DevTool/components/StorageList/index.vue +174 -174
  121. package/dist/v3/DevTool/components/TransferList/TransferDetail.vue +268 -268
  122. package/dist/v3/DevTool/components/VuexList/index.vue +84 -84
  123. package/dist/v3/DevTool/index.vue +85 -138
  124. package/dist/v3/components/AppTransition/index.vue +156 -176
  125. package/dist/v3/components/AutoSizer/index.vue +192 -192
  126. package/dist/v3/components/AutoSizer/index1.vue +184 -184
  127. package/dist/v3/components/AutoSizer/utils.ts +49 -49
  128. package/dist/v3/components/Barrage/BarrageItem.vue +194 -137
  129. package/dist/v3/components/Barrage/index.vue +205 -202
  130. package/dist/v3/components/CircularButton/index.vue +84 -84
  131. package/dist/v3/components/CustomSwiper/CustomSwiperItem.vue +49 -49
  132. package/dist/v3/components/CustomSwiper/index.vue +104 -104
  133. package/dist/v3/components/DevErrorBoundary/index.vue +388 -0
  134. package/dist/v3/components/DraggableContainer/index.vue +186 -73
  135. package/dist/v3/components/Empty/index.vue +29 -29
  136. package/dist/v3/components/FilterSelect/index.vue +179 -179
  137. package/dist/v3/components/JsonPretty/components/Brackets/index.vue +27 -27
  138. package/dist/v3/components/JsonPretty/components/Carets/index.vue +59 -59
  139. package/dist/v3/components/JsonPretty/components/CheckController/index.vue +136 -136
  140. package/dist/v3/components/JsonPretty/components/TreeNode/index.vue +387 -387
  141. package/dist/v3/components/JsonPretty/hooks/useClipboard.ts +21 -21
  142. package/dist/v3/components/JsonPretty/hooks/useError.ts +21 -21
  143. package/dist/v3/components/JsonPretty/type.ts +127 -127
  144. package/dist/v3/components/JsonPretty/utils/index.ts +169 -169
  145. package/dist/v3/components/MovableContainer/index.vue +10 -4
  146. package/dist/v3/components/Pick/index.vue +321 -322
  147. package/dist/v3/components/Tag/index.vue +113 -113
  148. package/dist/v3/components/VirtualList/AutoSize.vue +40 -40
  149. package/dist/v3/components/VirtualList/index.vue +416 -416
  150. package/dist/v3/hooks/useBluetooth/index.ts +561 -561
  151. package/dist/v3/hooks/useContainerStyle.ts +95 -153
  152. package/dist/v3/hooks/useNFC/index.ts +107 -107
  153. package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
  154. package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
  155. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
  156. package/dist/v3/hooks/useNFC/utils.ts +754 -754
  157. package/dist/v3/hooks/useRequest/index.ts +586 -586
  158. package/dist/v3/hooks/useRequest/utils.ts +267 -267
  159. package/dist/v3/hooks/useScanCode/index.ts +206 -206
  160. package/dist/v3/hooks/useWebsocket/index.ts +253 -253
  161. package/dist/v3/styles/theme.ts +12 -12
  162. package/package.json +70 -59
  163. package/dist/const.d.ts.map +0 -1
  164. package/dist/core-shared.d.ts.map +0 -1
  165. package/dist/core.d.ts.map +0 -1
  166. package/dist/i18n/index.d.ts.map +0 -1
  167. package/dist/i18n/instance.d.ts.map +0 -1
  168. package/dist/i18n/locales/en.d.ts.map +0 -1
  169. package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
  170. package/dist/index.d.ts.map +0 -1
  171. package/dist/modules/devConsole/index.d.ts.map +0 -1
  172. package/dist/modules/devEvent/index.d.ts.map +0 -1
  173. package/dist/modules/devIntercept/index.d.ts.map +0 -1
  174. package/dist/modules/devStore/index.d.ts.map +0 -1
  175. package/dist/modules/devToolInfo/index.d.ts.map +0 -1
  176. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +0 -1
  177. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +0 -1
  178. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +0 -1
  179. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  180. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -1
  181. package/dist/plugins/utils/index.d.ts.map +0 -1
  182. package/dist/type.d.ts.map +0 -1
  183. package/dist/utils/array.d.ts.map +0 -1
  184. package/dist/utils/date.d.ts.map +0 -1
  185. package/dist/utils/file.d.ts.map +0 -1
  186. package/dist/utils/function.d.ts.map +0 -1
  187. package/dist/utils/index.d.ts.map +0 -1
  188. package/dist/utils/ip.d.ts.map +0 -1
  189. package/dist/utils/language.d.ts.map +0 -1
  190. package/dist/utils/object.d.ts.map +0 -1
  191. package/dist/utils/openLink.d.ts.map +0 -1
  192. package/dist/utils/page.d.ts.map +0 -1
  193. package/dist/utils/platform.d.ts.map +0 -1
  194. package/dist/utils/string.d.ts.map +0 -1
  195. 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 devToolVisible;
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
- setDevToolVisible(visible: boolean): void;
73
- getDevToolVisible(): boolean;
74
- setDevToolDestroy(destroy: boolean): void;
73
+ private setAndSync;
74
+ setDevToolButtonVisible(v: boolean): void;
75
+ getDevToolButtonVisible(): boolean;
76
+ setDevToolDestroy(v: boolean): void;
75
77
  getDevToolDestroy(): boolean;
76
- setCacheInterceptConfig(value: boolean): void;
78
+ setCacheInterceptConfig(v: boolean): void;
77
79
  getCacheNetworkLog(): boolean;
78
- setUseTransition(value: boolean): void;
79
- setBaseFontSize(value: number): void;
80
- setTagFontSize(value: number): void;
81
- setTipsFontSize(value: number): void;
82
- setFontFamily(value: string): void;
83
- setFontWeight(value: string): void;
84
- setBarrageVisible(value: boolean): void;
85
- setBarrageMaxTracks(value: number): void;
86
- setBarrageTrackHeight(value: number): void;
87
- setBarrageStartTop(value: number): void;
88
- setBarrageDuration(value: number): void;
89
- setBarrageMaxLength(value: number): void;
90
- setBarrageTypes(value: string[]): void;
91
- setBarrageShowWhenOpen(value: boolean): void;
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, any>;
108
- getPiniaList(): Record<string, any>;
109
- setVuexStore(store: any): void;
110
- setVuexList(list: Record<string, any>): void;
111
- setPiniaStore(store: any): void;
112
- setPiniaList(list: Record<string, any>): void;
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: any;
125
+ value: unknown;
117
126
  }): DevTool.StorageItem[];
118
- updateVuexStore(data: Record<string, any>): Record<string, any>;
119
- updatePiniaStore(data: Record<string, any>): Record<string, any>;
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: any;
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, any>;
159
- getDeviceInfo(): Record<string, any>;
160
- getWindowInfo(): Record<string, any>;
161
- setSystemInfo(info: Record<string, any>): void;
162
- setDeviceInfo(info: Record<string, any>): void;
163
- setWindowInfo(info: Record<string, any>): void;
164
- setNetWorkStatus(info: Record<string, any>): void;
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: any): DevTool.WindowData;
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 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;
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 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
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 t}from"../../const.js";const o="dev-tool-network-list",i="dev-tool-console-list";function r(e){if(typeof uni>"u")return;const n=uni.getStorageSync(t)||{};uni.setStorageSync(t,{...n,...e})}function f(){return typeof uni>"u"?{}:uni.getStorageSync(t)}function c(e){if(typeof uni>"u")return;const n=e.slice(-200);uni.setStorageSync(o,n)}function s(){return typeof uni>"u"?[]:uni.getStorageSync(o)||[]}function S(e){if(typeof uni>"u")return;const n=e.slice(-200);uni.setStorageSync(i,n)}function d(){return typeof uni>"u"?[]:uni.getStorageSync(i)||[]}export{d as getDevToolConsoleList,f as getDevToolInfo,s as getDevToolNetworkList,S as setDevToolConsoleList,r as setDevToolInfo,c as setDevToolNetworkList};
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};
@@ -29,4 +29,3 @@ export declare const transformApp: ({ code, isSetup, importConsole, scriptRow, n
29
29
  map: any;
30
30
  };
31
31
  export {};
32
- //# sourceMappingURL=transformApp.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../utils/index.cjs");function c(i){const{lines:e}=i,n=[...e],t=s.findInsertionIndex(n,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));t!==-1&&n.splice(t,0,"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';");const r=s.findInsertionIndex(n,o=>o.includes("const app = createSSRApp(App)"));return r!==-1&&n.splice(r+1,0," app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"),n}const p=({code:i})=>{try{const e=i.split(`
2
- `),t=c({lines:e});return t.length===e.length&&t.every((r,o)=>r===e[o])?{code:i,map:null}:{code:t.join(`
3
- `),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:i,map:null}}};exports.transformMain=p;
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 s}from"../../utils/index.js";function c(i){const{lines:t}=i,e=[...t],o=s(e,n=>n.trim().startsWith("import")||n.trim().startsWith("export"));o!==-1&&e.splice(o,0,"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';");const r=s(e,n=>n.includes("const app = createSSRApp(App)"));return r!==-1&&e.splice(r+1,0," app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"),e}const l=({code:i})=>{try{const t=i.split(`
2
- `),o=c({lines:t});return o.length===t.length&&o.every((r,n)=>r===t[n])?{code:i,map:null}:{code:o.join(`
3
- `),map:null}}catch(t){return console.error("[DevTool] 转换 main 文件时出错:",t),{code:i,map:null}}};export{l as transformMain};
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 i=require("../../utils/index.cjs");function v(e,t){var c;const r=t.pages.some(o=>e.includes(o.path)),n=((c=t.subPackages)==null?void 0:c.some(o=>o.pages.some(u=>e.includes(`${o.root}/${u.path}`))))??!1;return{isPage:r,isSubPage:n}}function m(e,t,r,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:i.hasImportConsole(e),usesConsole:i.hasUseConsole(e),isExcludedFromConsole:!i.hasDirOrFile(t,r)}}function d(e,t,r,n){const{isPage:c,isSubPage:o}=v(e,r);return{isPageOrSubPage:c||o,hasTemplate:t.includes("<template>"),isExcludedFromDevTool:!i.hasDirOrFile(e,n)}}function h(e,t,r){const n=e.match(i.regScript);if(!n||!n[1])return e;const c=n[1];let o="";r&&(o="import { console } from 'vite-uni-dev-tool/dist/core';");const u=`
2
- ${o}
3
- ${c}
4
- `.trim();return e.replace(i.regScript,()=>`${t}
5
- ${u}
6
- <\/script>`)}function C(e,t){const r=e.match(i.regScript);if(!r||!r[1])return e;const n=r[1];if(n.includes("devCaptureTapEvent"))return e;const o=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",u=`
7
- function devCaptureTapEvent(e${o}) {
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${o}) {
11
+ function devCaptureTouchStartEvent(e${r}) {
12
12
  uni?.$emit('dev-capture-touch-start-event', e);
13
13
  }
14
14
 
15
- function devCaptureTouchMoveEvent(e${o}) {
15
+ function devCaptureTouchMoveEvent(e${r}) {
16
16
  uni?.$emit('dev-capture-touch-move-event', e);
17
17
  }
18
18
 
19
- function devCaptureTouchEndEvent(e${o}) {
19
+ function devCaptureTouchEndEvent(e${r}) {
20
20
  uni?.$emit('dev-capture-touch-end-event', e);
21
21
  }
22
- `,s=`
22
+ `,p=`
23
23
  ${n}
24
- ${u}
25
- `.trim();return e.replace(i.regScript,()=>`${t}
26
24
  ${s}
27
- <\/script>`)}function f(e){const t=i.getTemplateContent(e);if(!t)return e;const{pageMetas:r,resetContent:n}=i.extractTopLevelPageMeta(t),c=`
28
- ${r}
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
- <view
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(t,()=>c)}const g=({id:e,code:t,pages:r,scriptRow:n,importConsole:c,excludeImportConsole:o,excludeImportDevTool:u})=>{try{let s=t;const a=m(t,e,o,c),l=a.shouldInjectConsole&&!a.hasExistingConsoleImport&&a.usesConsole&&a.isExcludedFromConsole;l&&(s=h(s,n,l));const p=d(e,t,r,u);return p.isPageOrSubPage&&p.hasTemplate&&p.isExcludedFromDevTool&&(s=f(s),s=C(s,n)),{code:s,map:null}}catch(s){return console.error("[DevTool] 转换 Vue 文件时出错:",s),{code:t,map:null}}};exports.transformVue=g;
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 v,hasUseConsole as m,hasImportConsole as d,regScript as i,getTemplateContent as h,extractTopLevelPageMeta as C}from"../../utils/index.js";function f(e,t){var c;const r=t.pages.some(o=>e.includes(o.path)),n=((c=t.subPackages)==null?void 0:c.some(o=>o.pages.some(u=>e.includes(`${o.root}/${u.path}`))))??!1;return{isPage:r,isSubPage:n}}function T(e,t,r,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:d(e),usesConsole:m(e),isExcludedFromConsole:!v(t,r)}}function $(e,t,r,n){const{isPage:c,isSubPage:o}=f(e,r);return{isPageOrSubPage:c||o,hasTemplate:t.includes("<template>"),isExcludedFromDevTool:!v(e,n)}}function g(e,t,r){const n=e.match(i);if(!n||!n[1])return e;const c=n[1];let o="";r&&(o="import { console } from 'vite-uni-dev-tool/dist/core';");const u=`
2
- ${o}
3
- ${c}
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
- ${u}
6
- <\/script>`)}function E(e,t){const r=e.match(i);if(!r||!r[1])return e;const n=r[1];if(n.includes("devCaptureTapEvent"))return e;const o=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",u=`
7
- function devCaptureTapEvent(e${o}) {
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${o}) {
11
+ function devCaptureTouchStartEvent(e${r}) {
12
12
  uni?.$emit('dev-capture-touch-start-event', e);
13
13
  }
14
14
 
15
- function devCaptureTouchMoveEvent(e${o}) {
15
+ function devCaptureTouchMoveEvent(e${r}) {
16
16
  uni?.$emit('dev-capture-touch-move-event', e);
17
17
  }
18
18
 
19
- function devCaptureTouchEndEvent(e${o}) {
19
+ function devCaptureTouchEndEvent(e${r}) {
20
20
  uni?.$emit('dev-capture-touch-end-event', e);
21
21
  }
22
- `,s=`
22
+ `,p=`
23
23
  ${n}
24
- ${u}
25
- `.trim();return e.replace(i,()=>`${t}
26
24
  ${s}
27
- <\/script>`)}function S(e){const t=h(e);if(!t)return e;const{pageMetas:r,resetContent:n}=C(t),c=`
28
- ${r}
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
- <view
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(t,()=>c)}const x=({id:e,code:t,pages:r,scriptRow:n,importConsole:c,excludeImportConsole:o,excludeImportDevTool:u})=>{try{let s=t;const a=T(t,e,o,c),l=a.shouldInjectConsole&&!a.hasExistingConsoleImport&&a.usesConsole&&a.isExcludedFromConsole;l&&(s=g(s,n,l));const p=$(e,t,r,u);return p.isPageOrSubPage&&p.hasTemplate&&p.isExcludedFromDevTool&&(s=S(s),s=E(s,n)),{code:s,map:null}}catch(s){return console.error("[DevTool] 转换 Vue 文件时出错:",s),{code:t,map:null}}};export{x as transformVue};
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 j=require("path"),b=require("fs"),o=require("../utils/index.cjs"),q=require("./transform/transformMain.cjs"),w=require("./transform/transformApp.cjs"),A=require("./transform/transformVue.cjs");function d(i){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const u in i)if(u!=="default"){const f=Object.getOwnPropertyDescriptor(i,u);Object.defineProperty(a,u,f.get?f:{enumerable:!0,get:()=>i[u]})}}return a.default=i,Object.freeze(a)}const T=d(j),L=d(b),p={isReady:!1,urls:[]};function O({pages:i,sourceFileServers:a,importConsole:u,excludeImportConsole:f=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:S=["uni_modules","node_modules"],captureList:v=[],injectDevTool:h=!0,..._}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(t){var c;t.middlewares.use((n,s,r)=>{const{originalUrl:e}=n;if(_.useDevSource&&(e!=null&&e.includes("__dev_sourcefile__"))){const l=e.replace("/__dev_sourcefile__","");try{const m=t.config.root,g=T.join(m,l),y=L.readFileSync(g,"utf-8");s.setHeader("Content-Type",o.getContentType(g)),s.end(y)}catch{r()}}else r()}),(c=t.httpServer)==null||c.once("listening",()=>{var r;const n=(r=t.httpServer)==null?void 0:r.address(),s=o.getLocalIPs();if(n&&!Array.isArray(n)&&typeof n!="string"){const e=s.map(l=>`http://${l}:${n.port}/__dev_sourcefile__`);p.isReady=!0,p.urls=e,console.warn(`
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
- ${s.map(l=>`➜ Source File Network: http://${l}:${n==null?void 0:n.port}/__dev_sourcefile__`).join(`
3
+ ${o.map(u=>`➜ Source File Network: http://${u}:${n==null?void 0:n.port}/__dev_sourcefile__`).join(`
4
4
  `)}
5
- `)}})},transform(t,c){if(h){const n=o.hasLangTS(t),s=o.hasLangJS(t),r=o.hasSetup(t);let e="<script>";if(n&&r?e='<script lang="ts" setup>':s&&r?e='<script lang="js" setup>':s?e='<script lang="js">':n?e='<script lang="ts">':r&&(e="<script setup>"),o.isMainFile(c))return q.transformMain({code:t});if(o.isAppVue(c))return w.transformApp({code:t,isSetup:r,importConsole:u,scriptRow:e,netWorkInfo:p,sourceFileServers:a,reset:{..._,captureList:v}});if(o.isVueFile(c))return A.transformVue({id:c,code:t,pages:i,scriptRow:e,importConsole:u,excludeImportConsole:f,excludeImportDevTool:S})}return{code:t,map:null}}}}module.exports=O;
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 h from"path";import*as y from"fs";import{hasLangTS as w,hasLangJS as A,hasSetup as L,isMainFile as T,isAppVue as $,isVueFile as j,getContentType as F,getLocalIPs as P}from"../utils/index.js";import{transformMain as R}from"./transform/transformMain.js";import{transformApp as V}from"./transform/transformApp.js";import{transformVue as k}from"./transform/transformVue.js";const u={isReady:!1,urls:[]};function M({pages:c,sourceFileServers:_,importConsole:a,excludeImportConsole:m=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:g=["uni_modules","node_modules"],captureList:d=[],injectDevTool:v=!0,...p}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(t){var o;t.middlewares.use((r,n,s)=>{const{originalUrl:e}=r;if(p.useDevSource&&(e!=null&&e.includes("__dev_sourcefile__"))){const i=e.replace("/__dev_sourcefile__","");try{const l=t.config.root,f=h.join(l,i),S=y.readFileSync(f,"utf-8");n.setHeader("Content-Type",F(f)),n.end(S)}catch{s()}}else s()}),(o=t.httpServer)==null||o.once("listening",()=>{var s;const r=(s=t.httpServer)==null?void 0:s.address(),n=P();if(r&&!Array.isArray(r)&&typeof r!="string"){const e=n.map(i=>`http://${i}:${r.port}/__dev_sourcefile__`);u.isReady=!0,u.urls=e,console.warn(`
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
- ${n.map(i=>`➜ Source File Network: http://${i}:${r==null?void 0:r.port}/__dev_sourcefile__`).join(`
3
+ ${o.map(u=>`➜ Source File Network: http://${u}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
4
4
  `)}
5
- `)}})},transform(t,o){if(v){const r=w(t),n=A(t),s=L(t);let e="<script>";if(r&&s?e='<script lang="ts" setup>':n&&s?e='<script lang="js" setup>':n?e='<script lang="js">':r?e='<script lang="ts">':s&&(e="<script setup>"),T(o))return R({code:t});if($(o))return V({code:t,isSetup:s,importConsole:a,scriptRow:e,netWorkInfo:u,sourceFileServers:_,reset:{...p,captureList:d}});if(j(o))return k({id:o,code:t,pages:c,scriptRow:e,importConsole:a,excludeImportConsole:m,excludeImportDevTool:g})}return{code:t,map:null}}}}export{M as default};
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};
@@ -31,4 +31,3 @@ export default function uniGlobalComponents({ pages, components, }: {
31
31
  };
32
32
  components: string[];
33
33
  }): Plugin;
34
- //# sourceMappingURL=uniGlobalComponents.d.ts.map
@@ -131,4 +131,3 @@ export declare const isMainFile: (id: string) => boolean;
131
131
  * @return {*}
132
132
  */
133
133
  export declare const isVueFile: (id: string) => boolean;
134
- //# sourceMappingURL=index.d.ts.map