vite-uni-dev-tool 0.0.11 → 0.0.12

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 (38) hide show
  1. package/README.md +55 -1
  2. package/dev/components/ConsoleList/ConsoleItem.vue +24 -3
  3. package/dev/components/ConsoleList/RunJSInput.vue +3 -1
  4. package/dev/components/ConsoleList/index.vue +11 -2
  5. package/dev/components/DevTool/index.vue +37 -31
  6. package/dev/components/DevToolButton/index.vue +9 -12
  7. package/dev/components/DevToolTitle/index.vue +2 -2
  8. package/dev/components/DevToolWindow/index.vue +32 -16
  9. package/dev/components/JsonPretty/index.vue +2 -0
  10. package/dev/components/NetworkList/NetworkDetail.vue +3 -6
  11. package/dev/components/NetworkList/NetworkItem.vue +21 -8
  12. package/dev/components/NetworkList/index.vue +15 -2
  13. package/dev/components/RouteList/index.vue +12 -1
  14. package/dev/components/SettingList/index.vue +2 -5
  15. package/dev/components/SourceCode/index.vue +231 -0
  16. package/dev/components/UniEvent/UniEventItem.vue +4 -2
  17. package/dev/components/UniEvent/index.vue +7 -3
  18. package/dev/components/UploadList/UploadDetail.vue +3 -7
  19. package/dev/components/UploadList/UploadItem.vue +7 -1
  20. package/dev/components/UploadList/index.vue +15 -2
  21. package/dev/components/VirtualListPro/index.vue +67 -4
  22. package/dev/components/VuexList/index.vue +2 -2
  23. package/dev/components/WebSocket/WebSocketItem.vue +7 -2
  24. package/dev/components/WebSocket/WebSocketList.vue +3 -6
  25. package/dev/components/WebSocket/index.vue +15 -2
  26. package/dev/const.ts +11 -13
  27. package/dev/devEvent/index.ts +20 -16
  28. package/dev/devStore/index.ts +27 -13
  29. package/dev/devToolInfo/index.ts +26 -0
  30. package/dev/plugins/uniDevTool/uniDevTool.d.ts +9 -1
  31. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  32. package/dev/plugins/uniDevTool/uniDevTool.js +36 -36
  33. package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
  34. package/dev/type.ts +27 -0
  35. package/dev/utils/index.ts +5 -0
  36. package/dev/utils/language.ts +8 -3
  37. package/dev/utils/object.ts +10 -2
  38. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="web-socket-list-container">
2
+ <view class="web-socket-list-container" :style="{ zIndex: zIndex }">
3
3
  <view class="web-socket-top">
4
4
  请求url:
5
5
 
@@ -48,7 +48,7 @@ import CloseButton from '../CloseButton/index.vue';
48
48
  import { formatDate } from '../../utils/index';
49
49
  import type { DevTool } from '../../type';
50
50
 
51
- defineProps<{ ws: DevTool.WS }>();
51
+ defineProps<{ ws: DevTool.WS; zIndex?: number }>();
52
52
  const emit = defineEmits<{ (e: 'close'): void }>();
53
53
 
54
54
  function onClose() {
@@ -82,13 +82,10 @@ function onClick(item: {
82
82
  position: fixed;
83
83
  width: 100vw;
84
84
  height: 100vh;
85
- z-index: 1000;
85
+ z-index: 1001;
86
86
  top: 0;
87
87
  left: 0;
88
88
  padding: 0 16px;
89
- /* #ifdef H5 */
90
- padding: 50px 16px;
91
- /* #endif */
92
89
 
93
90
  background-color: rgba(255, 255, 255, 0.95);
94
91
  box-sizing: border-box;
@@ -18,14 +18,19 @@
18
18
  </Tag>
19
19
  </view>
20
20
 
21
- <VirtualListPro :data="wsList" :pageSize="10" className="websocket-list">
21
+ <VirtualListPro
22
+ :data="wsList"
23
+ :pageSize="10"
24
+ :height="height"
25
+ className="websocket-list"
26
+ >
22
27
  <template v-slot="{ list, start }">
23
28
  <AutoSize
24
29
  v-for="(item, index) in list"
25
30
  :index="start + index"
26
31
  :key="start + index"
27
32
  >
28
- <WebSocketItem :ws="item" />
33
+ <WebSocketItem :ws="item" :zIndex="zIndex" />
29
34
  </AutoSize>
30
35
  <Empty v-if="!wsList || wsList.length === 0" />
31
36
  </template>
@@ -40,11 +45,13 @@ import FilterInput from '../FilterInput/index.vue';
40
45
  import type { DevTool } from '../../type';
41
46
  import VirtualListPro from '../VirtualListPro/index.vue';
42
47
  import AutoSize from '../VirtualListPro/AutoSize.vue';
48
+ import { onMounted, ref } from 'vue';
43
49
 
44
50
  defineProps<{
45
51
  wsList: DevTool.WS[];
46
52
  currentWebSocketType: string;
47
53
  modelValue: string;
54
+ zIndex?: number;
48
55
  }>();
49
56
  const emit = defineEmits<{
50
57
  (e: 'choose', type: string): void;
@@ -87,6 +94,12 @@ const webSocketFilter = [
87
94
  function onChoose(type: string) {
88
95
  emit('choose', type);
89
96
  }
97
+
98
+ const height = ref(0);
99
+ onMounted(() => {
100
+ const { windowHeight } = uni.getWindowInfo();
101
+ height.value = windowHeight - 32 - 32;
102
+ });
90
103
  </script>
91
104
  <style scoped>
92
105
  .websocket-content {
package/dev/const.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * 调试按钮事件
3
- * 缓存调试按钮显示隐藏
4
3
  */
5
- export const EVENT_DEV_BUTTON = 'event-dev-button';
4
+ export const DEV_BUTTON_VISIBLE = 'dev-button-visible';
6
5
 
7
6
  /**
8
7
  * 调试弹窗事件
9
- * 缓存调试弹窗显示隐藏
10
8
  */
11
- export const EVENT_DEV_WINDOW = 'event-dev-window';
9
+ export const DEV_WINDOW_VISIBLE = 'dev-window-visible';
12
10
 
13
11
  /**
14
12
  * app 发出的信息
@@ -21,15 +19,8 @@ export const DEV_APP_MESSAGE = 'dev-app-message';
21
19
  export const DEV_WINDOW_MESSAGE = 'dev-window-message';
22
20
 
23
21
  /**
24
- * 缓存调试按钮信息
22
+ * 调试器销毁
25
23
  */
26
- export const DEV_BUTTON_INFO = 'dev-button-info';
27
-
28
- /**
29
- * 缓存调试弹窗信息
30
- */
31
- export const DEV_WINDOW_INFO = ' dev-window-info';
32
-
33
24
  export const DEV_IS_DESTROY = 'dev-is-destroy';
34
25
 
35
26
  /**
@@ -162,5 +153,12 @@ export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
162
153
  */
163
154
  export const DEV_RUN_JS = 'dev-uni-run-js';
164
155
 
165
- /** 清空截屏列表 */
156
+ /**
157
+ * 清空截屏列表
158
+ */
166
159
  export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
160
+
161
+ /**
162
+ * 存储的dev-tool 信息
163
+ */
164
+ export const DEV_TOOL_INFO = 'dev-tool-info';
@@ -22,8 +22,8 @@ import {
22
22
  DEV_WEBSOCKET_CLEAR,
23
23
  DEV_WINDOW_OPEN,
24
24
  DEV_APP_MESSAGE,
25
- EVENT_DEV_BUTTON,
26
- EVENT_DEV_WINDOW,
25
+ DEV_BUTTON_VISIBLE,
26
+ DEV_WINDOW_VISIBLE,
27
27
  DEV_WINDOW_MESSAGE,
28
28
  DEV_WINDOW_CLOSE,
29
29
  DEV_OPTION_GET,
@@ -72,6 +72,10 @@ export class DevEvent {
72
72
  * @memberof DevEvent
73
73
  */
74
74
  async postMessageFn() {
75
+ if (this.getDevToolDestroy()) {
76
+ return;
77
+ }
78
+
75
79
  const data = await this.store.getDevData();
76
80
  const size = calculateObjectSize(data);
77
81
  const sizeFormat = formatStorageSize(size);
@@ -99,7 +103,7 @@ export class DevEvent {
99
103
  * @memberof DevEvent
100
104
  */
101
105
  createDevTool() {
102
- if (!this.store.getDevToolDestroy()) {
106
+ if (!this.getDevToolDestroy()) {
103
107
  console.warn('[DevTool] 调试器已存在,不在重新创建');
104
108
  return;
105
109
  }
@@ -115,8 +119,8 @@ export class DevEvent {
115
119
  * @memberof DevEvent
116
120
  */
117
121
  destroyDevTool() {
118
- if (this.store.getDevToolDestroy()) {
119
- console.warn('[DevTool] 调试器已存在,不在重新创建');
122
+ if (this.getDevToolDestroy()) {
123
+ console.warn('[DevTool] 调试器已经销毁了,不在重新销毁');
120
124
  return;
121
125
  }
122
126
  this.store.setRequestIndex(-1);
@@ -151,7 +155,7 @@ export class DevEvent {
151
155
 
152
156
  this.store.setDevToolDestroy(true);
153
157
 
154
- this.eventBus.clear();
158
+ // this.eventBus.clear();
155
159
 
156
160
  console.warn('[DevTool] 调试器已销毁');
157
161
  }
@@ -175,10 +179,11 @@ export class DevEvent {
175
179
  * @memberof DevEvent
176
180
  */
177
181
  openDevToolWindow() {
182
+ if (this.getDevToolDestroy()) return;
178
183
  setTimeout(async () => {
179
184
  this.postMessage();
180
185
  }, 100);
181
- this.eventBus.emit(EVENT_DEV_WINDOW, true);
186
+ this.eventBus.emit(DEV_WINDOW_VISIBLE, true);
182
187
  }
183
188
 
184
189
  /**
@@ -187,7 +192,8 @@ export class DevEvent {
187
192
  * @memberof DevEvent
188
193
  */
189
194
  closeDevToolWindow() {
190
- this.eventBus.emit(EVENT_DEV_WINDOW, false);
195
+ if (this.getDevToolDestroy()) return;
196
+ this.eventBus.emit(DEV_WINDOW_VISIBLE, false);
191
197
  }
192
198
 
193
199
  /**
@@ -196,10 +202,10 @@ export class DevEvent {
196
202
  * @export
197
203
  */
198
204
  showDevToolButton() {
199
- const isDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
200
- if (isDestroy) return;
201
- this.eventBus.emit(EVENT_DEV_BUTTON, true);
202
- uni.setStorageSync(EVENT_DEV_BUTTON, true);
205
+ if (this.getDevToolDestroy()) return;
206
+
207
+ this.eventBus.emit(DEV_BUTTON_VISIBLE, true);
208
+
203
209
  this.store.setDevToolVisible(true);
204
210
  }
205
211
 
@@ -209,10 +215,8 @@ export class DevEvent {
209
215
  * @return {*}
210
216
  */
211
217
  hideDevToolButton() {
212
- const isDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
213
- if (isDestroy) return;
214
- this.eventBus.emit(EVENT_DEV_BUTTON, false);
215
- uni.setStorageSync(EVENT_DEV_BUTTON, false);
218
+ if (this.getDevToolDestroy()) return;
219
+ this.eventBus.emit(DEV_BUTTON_VISIBLE, false);
216
220
  this.store.setDevToolVisible(false);
217
221
  }
218
222
 
@@ -1,6 +1,6 @@
1
1
  import type { DevTool } from '../type';
2
2
 
3
- import { DEV_IS_DESTROY, EVENT_DEV_BUTTON } from '../const';
3
+ import { DEV_TOOL_INFO } from '../const';
4
4
 
5
5
  import {
6
6
  isNil,
@@ -12,6 +12,7 @@ import {
12
12
  isBoolean,
13
13
  } from '../utils/index';
14
14
  import { backup } from '../core';
15
+ import { getDevToolInfo, setDevToolInfo } from '../devToolInfo';
15
16
 
16
17
  /** 数据存储中心 */
17
18
  export class DevStore {
@@ -52,8 +53,6 @@ export class DevStore {
52
53
  private wsDataMaxSize = 1000;
53
54
  /** 事件列表最大值 */
54
55
  private eventListMaxSize = 1000;
55
- /** js 最大运行条数 */
56
- private runJsMaxSize = 1000;
57
56
  /** 截屏最大值 */
58
57
  private captureScreenMaxSize = 1000;
59
58
 
@@ -79,14 +78,22 @@ export class DevStore {
79
78
  /** 是否开启拦截Promise reject错误 */
80
79
  enableInterceptPromiseReject = false;
81
80
 
81
+ private zIndex = 1000;
82
+
82
83
  constructor() {
83
- this.devToolDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
84
- this.devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON) ?? false;
84
+ const { devToolDestroy = false, devToolButtonVisible = false } =
85
+ uni.getStorageSync(DEV_TOOL_INFO);
86
+
87
+ this.devToolDestroy = devToolDestroy;
88
+ this.devToolVisible = devToolButtonVisible;
85
89
  }
86
90
 
87
91
  setDevToolVisible(visible: boolean) {
88
92
  this.devToolVisible = visible;
89
- uni.setStorageSync(EVENT_DEV_BUTTON, visible);
93
+
94
+ setDevToolInfo({
95
+ devToolButtonVisible: visible,
96
+ });
90
97
  }
91
98
 
92
99
  getDevToolVisible() {
@@ -150,10 +157,13 @@ export class DevStore {
150
157
  this.wsDataMaxSize = options.wsDataMaxSize || 1000;
151
158
  this.cacheMaxSize = options.cacheMaxSize || 8 * 1024 * 1024 * 10;
152
159
  this.eventListMaxSize = options.eventListMaxSize || 1000;
160
+ this.captureScreenMaxSize = options.captureScreenMaxSize || 1000;
161
+ this.zIndex = options.zIndex || 1000;
162
+
163
+ const { devToolButtonVisible } = getDevToolInfo();
153
164
 
154
- const devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON);
155
- this.devToolVisible = isBoolean(devToolVisible)
156
- ? devToolVisible
165
+ this.devToolVisible = isBoolean(devToolButtonVisible)
166
+ ? devToolButtonVisible
157
167
  : (options.initShowDevTool ?? true);
158
168
 
159
169
  this.setDevToolVisible(this.devToolVisible);
@@ -267,8 +277,6 @@ export class DevStore {
267
277
 
268
278
  setValueByPath(this.piniaStore.state.value, key, value);
269
279
 
270
- console.log('this.piniaStore.state.value: ', this.piniaStore.state.value);
271
-
272
280
  this.setPiniaList({
273
281
  ...(this.piniaStore.state.value ?? {}),
274
282
  });
@@ -349,6 +357,7 @@ export class DevStore {
349
357
  this.state.windowInfo = {};
350
358
  this.state.systemInfo = {};
351
359
  this.state.netWorkStatus = {};
360
+ this.state.appInfo = {};
352
361
 
353
362
  this.state.eventList = [];
354
363
  this.state.eventCount = {
@@ -628,12 +637,17 @@ export class DevStore {
628
637
  }
629
638
 
630
639
  setDevToolDestroy(destroy: boolean) {
631
- uni.setStorageSync(DEV_IS_DESTROY, destroy);
632
640
  this.devToolDestroy = destroy;
641
+
642
+ setDevToolInfo({
643
+ devToolDestroy: destroy,
644
+ });
633
645
  }
634
646
 
635
647
  getDevToolDestroy() {
636
- return this.devToolDestroy ?? (uni.getStorageSync(DEV_IS_DESTROY) || false);
648
+ const { devToolDestroy = false } = uni.getStorageSync(DEV_TOOL_INFO);
649
+
650
+ return this.devToolDestroy ?? devToolDestroy;
637
651
  }
638
652
 
639
653
  getCurrentPagePath() {
@@ -0,0 +1,26 @@
1
+ import { DEV_TOOL_INFO } from '../const';
2
+ import type { DevTool } from '../type';
3
+
4
+ /**
5
+ * 缓存调试工具信息到本地
6
+ *
7
+ * @export
8
+ * @param {DevTool.DevToolInfo} info
9
+ */
10
+ export function setDevToolInfo(info: DevTool.DevToolInfo) {
11
+ const devInfo = uni.getStorageSync(DEV_TOOL_INFO);
12
+ uni.setStorageSync(DEV_TOOL_INFO, {
13
+ ...devInfo,
14
+ ...info,
15
+ });
16
+ }
17
+
18
+ /**
19
+ * 获取本地缓存信息
20
+ *
21
+ * @export
22
+ * @return {*}
23
+ */
24
+ export function getDevToolInfo() {
25
+ return uni.getStorageSync(DEV_TOOL_INFO) as DevTool.DevToolInfo;
26
+ }
@@ -20,7 +20,7 @@ import { Plugin } from 'vite';
20
20
  * }
21
21
  * @return {*} {Plugin}
22
22
  */
23
- export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
23
+ export default function uniDevTool({ pages, sourceFileServers, importConsole, ...reset }: {
24
24
  /** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
25
25
  enableInterceptPromiseReject?: boolean;
26
26
  /** 打开窗口时隐藏按钮 */
@@ -35,6 +35,10 @@ export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
35
35
  wsDataMaxSize?: number;
36
36
  /** 最大占用缓存空间 bytes */
37
37
  cacheMaxSize?: number;
38
+ /** 最大时间列表条数 */
39
+ eventListMaxSize?: number;
40
+ /** 最大截屏记录条数 */
41
+ captureScreenMaxSize?: number;
38
42
  /** 按钮大小 */
39
43
  buttonSize?: number;
40
44
  /** 按钮文本 */
@@ -47,6 +51,8 @@ export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
47
51
  buttonBackgroundColor?: string;
48
52
  /** 初始化时是否显示调试按钮,默认显示 */
49
53
  initShowDevTool?: boolean;
54
+ /** 调试弹窗层级默认 1000 */
55
+ zIndex?: number;
50
56
  /**
51
57
  * 该属性处于实验当中,谨慎使用
52
58
  * 读取开发环境 source file,source map,默认 禁用
@@ -57,6 +63,8 @@ export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
57
63
  * 开发环境 source file 服务器地址,默认 [] ,配合 useDevSource 使用
58
64
  */
59
65
  sourceFileServers?: string[];
66
+ /** 是否导入 console 默认不导入, 只会捕获error 和 warn , */
67
+ importConsole?: boolean;
60
68
  /** 页面配置 用于读取路由 */
61
69
  pages: {
62
70
  pages: {
@@ -1 +1 @@
1
- {"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;CACH,GAAG,MAAM,CAyNT"}
1
+ {"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;CACH,GAAG,MAAM,CAyNT"}
@@ -1,36 +1,36 @@
1
- "use strict";const C=require("path"),I=require("fs"),u=require("../utils/index.js");function _(a){const v=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const e=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(v,l,e.get?e:{enumerable:!0,get:()=>a[l]})}}return v.default=a,Object.freeze(v)}const $=_(C),S=_(I),h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function D({pages:a,sourceFileServers:v,...l}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(l.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,m=$.join(c,i),o=S.readFileSync(m,"utf-8");n.setHeader("Content-Type",u.getContentType(m)),n.end(o)}catch{t()}}else t()}),(p=e.httpServer)==null||p.once("listening",()=>{var t;const s=(t=e.httpServer)==null?void 0:t.address(),n=u.getLocalIPs();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=n.map(i=>`http://${i}:${s.port}/__dev_sourcefile__`);g.isReady=!0,g.urls=r,console.warn(`
2
- ⚡️ vite-uni-dev-tool source file server running at:
3
- ${n.map(i=>`➜ Source File Network: http://${i}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
4
- `)}
5
- `)}})},transform(e,p){var s;if(p.endsWith("/src/main.ts"))try{const n=e.split(`
6
- `);let t=[...n];const r=u.findInsertionIndex(t,c=>c.trim().startsWith("import")||c.trim().startsWith("export"));r!==-1&&t.splice(r,0,"import DevTool from 'vite-uni-dev-tool/dev/components/DevTool/index.vue';");const i=u.findInsertionIndex(t,c=>c.includes(".mount(")||c.includes("createApp("));if(i!==-1&&t.splice(i+1,0," app.component('DevTool', DevTool);"),t.length!==n.length)return{code:t.join(`
7
- `),map:null}}catch(n){return console.error("[DevTool] 转换 main 文件时出错:",n),{code:e,map:null}}if(p.endsWith("/src/App.vue")){const n=e.match(h);if(n&&n[1]){const t=n[1].trim(),r=u.hasImportCurrentInstance(t),i=u.hasImportOnLaunch(t),c=r?"":"import { getCurrentInstance } from 'vue'",m=i?"":"import { onLaunch } from '@dcloudio/uni-app'",o=`
8
- import { initDevTool, console } from 'vite-uni-dev-tool/dev/core';
9
- import pagesJson from './pages.json';
10
- ${t}
11
- onLaunch(() => {
12
- const vue3instance = getCurrentInstance();
13
- initDevTool({
14
- pagesJson,
15
- vue3instance,
16
- mode: import.meta.env.MODE,
17
- sourceFileServers: [
18
- ${[...g.urls??[],...v??[]].map(d=>`'${d}'`)}
19
- ],
20
- useDevSource: ${l.useDevSource},
21
- ...${JSON.stringify(l)},
22
- });
23
- });`;return{code:e.replace(h,`
24
- <script lang="ts" setup>
25
- ${c}
26
- ${m}
27
- ${o}
28
- <\/script>`),map:null}}return{code:e,map:null}}if(p.endsWith(".vue")){const n=e.includes("<template>"),t=a.pages.some(o=>p.includes(o.path)),r=(s=a.subPackages)==null?void 0:s.some(o=>o.pages.some(f=>p.includes(`${o.root}/${f.path}`))),i=["<DevTool />"],c=u.hasImportConsole(e),m=u.hasUseConsole(e);if(!c&&m&&!p.endsWith("/src/App.vue")){const o=e.match(h);if(o&&o[1]){const d=`
29
- import { console } from 'vite-uni-dev-tool/dev/core';
30
- ${o[1]}
31
- `;e=e.replace(h,`
32
- <script lang="ts" setup>
33
- ${d}
34
- <\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let f=e;if(o){const d=`<view>${o}
35
- ${i.join(`
36
- `)}</view>`;f=e.replace(o,d)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=D;
1
+ "use strict";const I=require("path"),C=require("fs"),u=require("../utils/index.js");function $(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const f=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(d,l,f.get?f:{enumerable:!0,get:()=>a[l]})}}return d.default=a,Object.freeze(d)}const S=$(I),D=$(C),g=/<script[^>]*>([\s\S]*?)<\/script>/,_={isReady:!1,urls:[]};function y({pages:a,sourceFileServers:d,importConsole:l,...f}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(f.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,v=S.join(c,i),o=D.readFileSync(v,"utf-8");n.setHeader("Content-Type",u.getContentType(v)),n.end(o)}catch{t()}}else t()}),(p=e.httpServer)==null||p.once("listening",()=>{var t;const s=(t=e.httpServer)==null?void 0:t.address(),n=u.getLocalIPs();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=n.map(i=>`http://${i}:${s.port}/__dev_sourcefile__`);_.isReady=!0,_.urls=r,console.warn(`
2
+ ⚡️ vite-uni-dev-tool source file server running at:
3
+ ${n.map(i=>`➜ Source File Network: http://${i}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
4
+ `)}
5
+ `)}})},transform(e,p){var s;if(p.endsWith("/src/main.ts"))try{const n=e.split(`
6
+ `);let t=[...n];const r=u.findInsertionIndex(t,c=>c.trim().startsWith("import")||c.trim().startsWith("export"));r!==-1&&t.splice(r,0,"import DevTool from 'vite-uni-dev-tool/dev/components/DevTool/index.vue';");const i=u.findInsertionIndex(t,c=>c.includes(".mount(")||c.includes("createApp("));if(i!==-1&&t.splice(i+1,0," app.component('DevTool', DevTool);"),t.length!==n.length)return{code:t.join(`
7
+ `),map:null}}catch(n){return console.error("[DevTool] 转换 main 文件时出错:",n),{code:e,map:null}}if(p.endsWith("/src/App.vue")){const n=e.match(g);if(n&&n[1]){const t=n[1].trim(),r=u.hasImportCurrentInstance(t),i=u.hasImportOnLaunch(t),c=r?"":"import { getCurrentInstance } from 'vue'",v=i?"":"import { onLaunch } from '@dcloudio/uni-app'",o=`
8
+ import { initDevTool${l?", console":""} } from 'vite-uni-dev-tool/dev/core';
9
+ import pagesJson from './pages.json';
10
+ ${t}
11
+ onLaunch(() => {
12
+ const vue3instance = getCurrentInstance();
13
+ initDevTool({
14
+ pagesJson,
15
+ vue3instance,
16
+ mode: import.meta.env.MODE,
17
+ sourceFileServers: [
18
+ ${[..._.urls??[],...d??[]].map(h=>`'${h}'`)}
19
+ ],
20
+ useDevSource: ${f.useDevSource},
21
+ ...${JSON.stringify(f)},
22
+ });
23
+ });`;return{code:e.replace(g,`
24
+ <script lang="ts" setup>
25
+ ${c}
26
+ ${v}
27
+ ${o}
28
+ <\/script>`),map:null}}return{code:e,map:null}}if(p.endsWith(".vue")){const n=e.includes("<template>"),t=a.pages.some(o=>p.includes(o.path)),r=(s=a.subPackages)==null?void 0:s.some(o=>o.pages.some(m=>p.includes(`${o.root}/${m.path}`))),i=["<DevTool />"],c=u.hasImportConsole(e),v=u.hasUseConsole(e);if(!c&&v&&!p.endsWith("/src/App.vue")){const o=e.match(g);if(o&&o[1]){const m=o[1],h=`
29
+ ${l?"import { console } from 'vite-uni-dev-tool/dev/core';":""}
30
+ ${m}
31
+ `;e=e.replace(g,`
32
+ <script lang="ts" setup>
33
+ ${h}
34
+ <\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let m=e;if(o){const h=`<view>${o}
35
+ ${i.join(`
36
+ `)}</view>`;m=e.replace(o,h)}return{code:m,map:null}}}return{code:e,map:null}}}}module.exports=y;
@@ -1,7 +1,7 @@
1
- "use strict";const d=require("path"),m=require("fs"),p=require("../utils/index.js");function f(s){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(u,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return u.default=s,Object.freeze(u)}const g=f(d),h=f(m);function v({pages:s,components:u}){return{name:"uni-global-components",enforce:"pre",configureServer(e){var r;e.middlewares.use((t,c,i)=>{const{originalUrl:n}=t;if(n!=null&&n.includes("__dev_sourcefile__")){const o=n.replace("/__dev_sourcefile__","");try{const a=e.config.root,l=g.join(a,o),_=h.readFileSync(l,"utf-8");c.setHeader("Content-Type",p.getContentType(l)),c.end(_)}catch{i()}}else i()}),(r=e.httpServer)==null||r.once("listening",()=>{var i;const t=(i=e.httpServer)==null?void 0:i.address(),c=p.getLocalIPs();t&&!Array.isArray(t)&&typeof t!="string"&&(c.map(n=>`http://${n}:${t.port}/__dev_sourcefile__`),console.warn(`
2
- ⚡️ vite-uni-dev-tool source file server running at:
3
- ${c.map(n=>`➜ Source File Network: http://${n}:${t==null?void 0:t.port}/__dev_sourcefile__`).join(`
4
- `)}
5
- `))})},transform(e,r){var t;if(r.endsWith(".vue")){const c=e.includes("<template>"),i=s.pages.some(o=>r.includes(o.path)),n=(t=s.subPackages)==null?void 0:t.some(o=>o.pages.some(a=>r.includes(`${o.root}/${a.path}`)));if((i||n)&&c){const o=p.getTemplateContent(e);if(o){const a=`<view>${o}
6
- ${u.join(`
7
- `)}</view>`;return{code:e.replace(o,a),map:null}}}}return{code:e,map:null}}}}module.exports=v;
1
+ "use strict";const d=require("path"),m=require("fs"),p=require("../utils/index.js");function f(s){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(u,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return u.default=s,Object.freeze(u)}const g=f(d),h=f(m);function v({pages:s,components:u}){return{name:"uni-global-components",enforce:"pre",configureServer(e){var r;e.middlewares.use((t,c,i)=>{const{originalUrl:n}=t;if(n!=null&&n.includes("__dev_sourcefile__")){const o=n.replace("/__dev_sourcefile__","");try{const a=e.config.root,l=g.join(a,o),_=h.readFileSync(l,"utf-8");c.setHeader("Content-Type",p.getContentType(l)),c.end(_)}catch{i()}}else i()}),(r=e.httpServer)==null||r.once("listening",()=>{var i;const t=(i=e.httpServer)==null?void 0:i.address(),c=p.getLocalIPs();t&&!Array.isArray(t)&&typeof t!="string"&&(c.map(n=>`http://${n}:${t.port}/__dev_sourcefile__`),console.warn(`
2
+ ⚡️ vite-uni-dev-tool source file server running at:
3
+ ${c.map(n=>`➜ Source File Network: http://${n}:${t==null?void 0:t.port}/__dev_sourcefile__`).join(`
4
+ `)}
5
+ `))})},transform(e,r){var t;if(r.endsWith(".vue")){const c=e.includes("<template>"),i=s.pages.some(o=>r.includes(o.path)),n=(t=s.subPackages)==null?void 0:t.some(o=>o.pages.some(a=>r.includes(`${o.root}/${a.path}`)));if((i||n)&&c){const o=p.getTemplateContent(e);if(o){const a=`<view>${o}
6
+ ${u.join(`
7
+ `)}</view>`;return{code:e.replace(o,a),map:null}}}}return{code:e,map:null}}}}module.exports=v;
package/dev/type.ts CHANGED
@@ -60,6 +60,8 @@ export declare namespace DevTool {
60
60
  wsDataMaxSize?: number;
61
61
  /** 最大的时间列表条数 */
62
62
  eventListMaxSize?: number;
63
+ /** 最大截屏记录条数 */
64
+ captureScreenMaxSize?: number;
63
65
  /** 最大占用缓存空间 */
64
66
  cacheMaxSize?: number;
65
67
  /** 所有路由信息 */
@@ -75,6 +77,8 @@ export declare namespace DevTool {
75
77
  * 读取开发环境 source file,source map,默认 禁用
76
78
  */
77
79
  useDevSource?: boolean;
80
+ /** 层级默认 1000 */
81
+ zIndex?: number;
78
82
  } & ButtonOptions;
79
83
 
80
84
  type ButtonOptions = Partial<{
@@ -261,4 +265,27 @@ export declare namespace DevTool {
261
265
  event: DevEvent;
262
266
  enableInterceptPromiseReject?: boolean;
263
267
  };
268
+
269
+ type DevToolInfo = {
270
+ /** 是否销毁 */
271
+ devToolDestroy?: boolean;
272
+ /** 按钮状态 */
273
+ devToolButtonVisible?: boolean;
274
+ /** 窗口状态 */
275
+ devToolWindowVisible?: boolean;
276
+ /** 按钮位置 */
277
+ top?: string;
278
+ /** 按钮位置 */
279
+ left?: string;
280
+ /** 当前活动tab */
281
+ activeTab?: number;
282
+ /** 当前console类型 */
283
+ currentConsoleType?: string;
284
+ /** 当前network类型 */
285
+ currentNetworkType?: string;
286
+ /** 当前websocket类型 */
287
+ currentWebSocketType?: string;
288
+ /** table滚动位置 */
289
+ tabScrollLeft?: number;
290
+ };
264
291
  }
@@ -4,6 +4,11 @@ export {
4
4
  isNumber,
5
5
  isObject,
6
6
  isArray,
7
+ isFunction,
8
+ isString,
9
+ isNull,
10
+ isSymbol,
11
+ isUndefined,
7
12
  getValueType,
8
13
  transformValueToView,
9
14
  } from './language';
@@ -35,6 +35,10 @@ export function isSymbol(value: any): value is symbol {
35
35
  return typeof value === 'symbol';
36
36
  }
37
37
 
38
+ export function isFunction(value: any): value is Function {
39
+ return typeof value === 'function';
40
+ }
41
+
38
42
  /**
39
43
  *
40
44
  *
@@ -61,12 +65,13 @@ export function getValueType(value: any): DevTool.ValueType {
61
65
  * @return {*} {DevTool.ValueType}
62
66
  */
63
67
  export function transformValueToView(value: any): DevTool.ValueType {
64
- if (isNull(value)) return 'string';
65
- if (isUndefined(value)) return 'string';
68
+ if (isNull(value)) return 'null';
69
+ if (isUndefined(value)) return 'undefined';
66
70
  if (isString(value)) return 'string';
67
71
  if (isNumber(value)) return 'number';
72
+ if (isBoolean(value)) return 'boolean';
73
+ if (isSymbol(value)) return 'symbol';
68
74
  if (isArray(value)) return 'array';
69
75
  if (isObject(value)) return 'object';
70
- if (isSymbol(value)) return 'symbol';
71
76
  return 'string';
72
77
  }
@@ -1,4 +1,4 @@
1
- import { isNil, isObject, isString } from './language';
1
+ import { isBoolean, isNil, isObject, isString, isFunction } from './language';
2
2
 
3
3
  /**
4
4
  * 自定义set函数 - 安全地设置嵌套对象属性
@@ -252,7 +252,15 @@ export function parseValue(value: any, deep: number = 6) {
252
252
 
253
253
  function process(value: any, currentDeep: number, path: string[] = []): any {
254
254
  if (isString(value)) {
255
- return `"${value}"`;
255
+ return `${value}`;
256
+ }
257
+
258
+ if (isBoolean(value)) {
259
+ return `${value}`;
260
+ }
261
+
262
+ if (isFunction(value)) {
263
+ return `f(...) { ... }`;
256
264
  }
257
265
 
258
266
  if (isNil(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-uni-dev-tool",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
5
5
  "keywords": [
6
6
  "vite",