vite-uni-dev-tool 1.2.0 → 1.2.2

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 (104) hide show
  1. package/README.md +17 -1
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +1 -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 +1 -1
  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 +1 -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 +1 -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 +33 -5
  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.d.ts +0 -1
  34. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +0 -1
  35. package/dist/plugins/uniDevTool/uniDevTool.d.ts +0 -1
  36. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -1
  37. package/dist/plugins/utils/index.d.ts +0 -1
  38. package/dist/shims-uni.d.ts +26 -22
  39. package/dist/type.d.ts +44 -43
  40. package/dist/utils/array.d.ts +0 -1
  41. package/dist/utils/date.d.ts +0 -1
  42. package/dist/utils/file.d.ts +0 -1
  43. package/dist/utils/function.d.ts +0 -1
  44. package/dist/utils/index.d.ts +0 -1
  45. package/dist/utils/ip.d.ts +0 -1
  46. package/dist/utils/language.d.ts +14 -15
  47. package/dist/utils/object.cjs +1 -1
  48. package/dist/utils/object.d.ts +7 -8
  49. package/dist/utils/object.js +1 -1
  50. package/dist/utils/openLink.d.ts +0 -1
  51. package/dist/utils/page.d.ts +0 -1
  52. package/dist/utils/platform.d.ts +0 -1
  53. package/dist/utils/string.d.ts +0 -1
  54. package/dist/utils/utils.d.ts +0 -1
  55. package/dist/v3/DevTool/components/DevToolButton/index.vue +42 -6
  56. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +36 -12
  57. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +16 -1
  58. package/dist/v3/DevTool/components/DevToolWindow/index.vue +27 -64
  59. package/dist/v3/DevTool/components/Instance/transformTree.ts +156 -138
  60. package/dist/v3/DevTool/components/SettingList/index.vue +8 -0
  61. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +16 -0
  62. package/dist/v3/DevTool/index.vue +87 -138
  63. package/dist/v3/components/AppTransition/index.vue +33 -53
  64. package/dist/v3/components/Barrage/BarrageItem.vue +66 -9
  65. package/dist/v3/components/Barrage/index.vue +3 -0
  66. package/dist/v3/components/DevErrorBoundary/index.vue +13 -5
  67. package/dist/v3/components/DraggableContainer/index.vue +186 -73
  68. package/dist/v3/components/MovableContainer/index.vue +2 -0
  69. package/dist/v3/components/Pick/index.vue +29 -30
  70. package/dist/v3/hooks/useContainerStyle.ts +15 -73
  71. package/package.json +4 -1
  72. package/dist/const.d.ts.map +0 -1
  73. package/dist/core-shared.d.ts.map +0 -1
  74. package/dist/core.d.ts.map +0 -1
  75. package/dist/i18n/index.d.ts.map +0 -1
  76. package/dist/i18n/instance.d.ts.map +0 -1
  77. package/dist/i18n/locales/en.d.ts.map +0 -1
  78. package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/modules/devConsole/index.d.ts.map +0 -1
  81. package/dist/modules/devEvent/index.d.ts.map +0 -1
  82. package/dist/modules/devIntercept/index.d.ts.map +0 -1
  83. package/dist/modules/devStore/index.d.ts.map +0 -1
  84. package/dist/modules/devToolInfo/index.d.ts.map +0 -1
  85. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +0 -1
  86. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +0 -1
  87. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +0 -1
  88. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  89. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -1
  90. package/dist/plugins/utils/index.d.ts.map +0 -1
  91. package/dist/type.d.ts.map +0 -1
  92. package/dist/utils/array.d.ts.map +0 -1
  93. package/dist/utils/date.d.ts.map +0 -1
  94. package/dist/utils/file.d.ts.map +0 -1
  95. package/dist/utils/function.d.ts.map +0 -1
  96. package/dist/utils/index.d.ts.map +0 -1
  97. package/dist/utils/ip.d.ts.map +0 -1
  98. package/dist/utils/language.d.ts.map +0 -1
  99. package/dist/utils/object.d.ts.map +0 -1
  100. package/dist/utils/openLink.d.ts.map +0 -1
  101. package/dist/utils/page.d.ts.map +0 -1
  102. package/dist/utils/platform.d.ts.map +0 -1
  103. package/dist/utils/string.d.ts.map +0 -1
  104. package/dist/utils/utils.d.ts.map +0 -1
@@ -1,14 +1,19 @@
1
1
  <template>
2
+ <!-- are you ok ? -->
2
3
  <MovableContainer
3
4
  width="100px"
4
5
  height="32px"
5
6
  :x="x"
6
7
  :y="y"
7
8
  :zIndex="zIndex"
8
- :customStyle="customStyle"
9
+ :customStyle="innerStyle"
9
10
  :contentHeight="contentHeight"
10
11
  @change="onDebounceChange">
11
- <view class="dev-tool-button" @click="onClick">
12
+ <view
13
+ class="dev-tool-button"
14
+ @touchstart="handleTouchStart"
15
+ @mousedown="handleTouchStart"
16
+ @click="onClick">
12
17
  devtool
13
18
  <view class="dev-tool-version">{{ devToolVersion }}</view>
14
19
  </view>
@@ -16,29 +21,50 @@
16
21
  </template>
17
22
  <script lang="ts" setup>
18
23
  import { onShow } from '@dcloudio/uni-app';
19
- import { ref } from 'vue';
24
+ import { computed, ref } from 'vue';
20
25
  import {
21
26
  getDevToolInfo,
22
27
  setDevToolInfo,
23
28
  } from '../../../../modules/devToolInfo';
24
29
  import MovableContainer from '../../../components/MovableContainer/index.vue';
25
30
 
31
+ // 优化 Key:每当组件被重新加载(v-if 由 false 变 true)时,生成一个新的唯一标识。
32
+
26
33
  const x = ref(300);
27
34
  const y = ref(500);
28
35
 
36
+ // 坐标记录,用于判定拖拽与点击冲突
37
+ let startX = 0;
38
+ let startY = 0;
39
+
29
40
  const emit = defineEmits<{
30
41
  (e: 'click', pos: { x: number; y: number }): void;
31
42
  }>();
32
- withDefaults(
43
+ const props = withDefaults(
33
44
  defineProps<{
34
45
  zIndex?: number;
35
46
  customStyle?: Record<string, any>;
36
47
  contentHeight: number;
37
48
  devToolVersion?: string;
49
+ devToolButtonVisible?: boolean;
38
50
  }>(),
39
- { zIndex: 1000 },
51
+ { zIndex: 1000, devToolButtonVisible: true },
40
52
  );
41
53
 
54
+ const innerStyle = computed(() => {
55
+ return {
56
+ ...props.customStyle,
57
+ display: props.devToolButtonVisible ? 'block' : 'none',
58
+ };
59
+ });
60
+
61
+ // 记录下手的起点
62
+ const handleTouchStart = (e: any) => {
63
+ const touch = e.touches ? e.touches[0] : e;
64
+ startX = touch.clientX || touch.pageX;
65
+ startY = touch.clientY || touch.pageY;
66
+ };
67
+
42
68
  const onDebounceChange = (e: any) => {
43
69
  setDevToolInfo({
44
70
  left: e.detail.x,
@@ -46,7 +72,17 @@ const onDebounceChange = (e: any) => {
46
72
  });
47
73
  };
48
74
 
49
- const onClick = () => {
75
+ const onClick = (e: any) => {
76
+ // 获取抬手时的坐标
77
+ const touch = e.changedTouches ? e.changedTouches[0] : e;
78
+ const endX = touch.clientX || touch.pageX;
79
+ const endY = touch.clientY || touch.pageY;
80
+
81
+ // 如果位移超过 5 像素,说明这是一次拖拽后的释放,拦截点击回调
82
+ if (Math.abs(endX - startX) > 5 || Math.abs(endY - startY) > 5) {
83
+ return;
84
+ }
85
+
50
86
  emit('click', { x: x.value + 50, y: y.value + 16 });
51
87
  };
52
88
 
@@ -4,7 +4,19 @@ import type { DevTool } from '../../../../../type';
4
4
  import { hightLight } from '../../../../../utils/index';
5
5
  import { calcLineStartAndEnd, calcNetworkTimeline } from './dataUtils';
6
6
 
7
- export function useDevToolData(props: any) {
7
+ export interface DevToolWindowProps {
8
+ open?: boolean;
9
+ data?: DevTool.WindowData;
10
+ sourceFileServers?: string[];
11
+ mode?: string;
12
+ useDevSource?: boolean;
13
+ zIndex?: number;
14
+ contentHeight: number;
15
+ customStyle?: Record<string, string | number>;
16
+ origin?: { x: number; y: number };
17
+ }
18
+
19
+ export function useDevToolData(props: DevToolWindowProps) {
8
20
  const consoleList = shallowRef<DevTool.ConsoleItem[]>([]);
9
21
  const networkList = shallowRef<DevTool.NetworkItem[]>([]);
10
22
  const transferList = shallowRef<DevTool.TransferItem[]>([]);
@@ -46,6 +58,7 @@ export function useDevToolData(props: any) {
46
58
  const barrageStartTop = shallowRef(40);
47
59
  const barrageDuration = shallowRef(6);
48
60
  const barrageMaxLength = shallowRef(100);
61
+ const barrageAllowDrag = shallowRef(true);
49
62
  const barrageTypes = shallowRef([
50
63
  'log',
51
64
  'info',
@@ -141,6 +154,8 @@ export function useDevToolData(props: any) {
141
154
  barrageDuration.value = data.barrageDuration;
142
155
  if (data.barrageMaxLength !== undefined)
143
156
  barrageMaxLength.value = data.barrageMaxLength;
157
+ if (data.barrageAllowDrag !== undefined)
158
+ barrageAllowDrag.value = data.barrageAllowDrag;
144
159
  if (data.barrageTypes !== undefined) {
145
160
  if (Array.isArray(data.barrageTypes)) {
146
161
  barrageTypes.value = data.barrageTypes;
@@ -163,26 +178,31 @@ export function useDevToolData(props: any) {
163
178
  return item;
164
179
  })
165
180
  .filter((item) => {
181
+ const content =
182
+ item.args
183
+ ?.map((arg) => (arg.type === 'string' ? arg.value : ''))
184
+ .join('') || '';
166
185
  return (
167
- item.args?.some(
168
- (arg) =>
169
- arg.type === 'string' &&
170
- arg.value?.includes?.(searchConsole.value),
171
- ) ||
186
+ content.includes(searchConsole.value) ||
172
187
  item.position.includes(searchConsole.value) ||
173
- item?.stack?.includes(searchConsole.value)
188
+ (item.stack && item.stack.includes(searchConsole.value))
174
189
  );
175
190
  })
176
191
  ?.map((item) => {
177
192
  return {
178
193
  ...item,
179
194
  _positionHtml: hightLight(item.position, searchConsole.value),
180
- _stackHtml: hightLight(item.stack, searchConsole.value),
195
+ _stackHtml: item.stack
196
+ ? hightLight(item.stack, searchConsole.value)
197
+ : '',
181
198
  args: item.args.map((arg) => {
182
199
  if (arg.type === 'string') {
183
200
  return {
184
201
  ...arg,
185
- _valueHtml: hightLight(arg.value, searchConsole.value),
202
+ _valueHtml: hightLight(
203
+ arg.value as string,
204
+ searchConsole.value,
205
+ ),
186
206
  };
187
207
  }
188
208
  return arg;
@@ -209,7 +229,7 @@ export function useDevToolData(props: any) {
209
229
  ?.map((item) => {
210
230
  return {
211
231
  ...item,
212
- url: hightLight(item.url, searchNetwork.value),
232
+ url: hightLight(item.url || '', searchNetwork.value),
213
233
  };
214
234
  })
215
235
  ?.sort((a, b) => {
@@ -251,11 +271,14 @@ export function useDevToolData(props: any) {
251
271
 
252
272
  if (data.storageList) {
253
273
  storageList.value = [...(data.storageList ?? [])]
254
- ?.filter((item) => item._oldKey.includes(searchStorage.value))
274
+ ?.filter(
275
+ (item) => item._oldKey && item._oldKey.includes(searchStorage.value),
276
+ )
255
277
  ?.map((item) => {
278
+ const oldKey = item._oldKey || '';
256
279
  return {
257
280
  ...item,
258
- _oldKey: hightLight(item._oldKey, searchStorage.value),
281
+ _oldKey: hightLight(oldKey, searchStorage.value),
259
282
  };
260
283
  });
261
284
  backup.storageList = [...data.storageList];
@@ -358,6 +381,7 @@ export function useDevToolData(props: any) {
358
381
  barrageStartTop,
359
382
  barrageDuration,
360
383
  barrageMaxLength,
384
+ barrageAllowDrag,
361
385
  barrageTypes,
362
386
  backup,
363
387
  buildInfo,
@@ -4,7 +4,13 @@ import type { DevTool } from '../../../../../type';
4
4
  import { CMD_TYPE, MSG_TYPE, DEV_CORE_MESSAGE } from '../../../../../const';
5
5
  import { hightLight } from '../../../../../utils/index';
6
6
 
7
- export function useDevToolHandlers(props: any, emits: any, state: any) {
7
+ import type { DevToolWindowProps } from './useDevToolData';
8
+
9
+ export function useDevToolHandlers(
10
+ props: DevToolWindowProps,
11
+ emits: (e: any, ...args: any[]) => void, // 此由于 defineEmits 的复杂性暂留少量 any,但主要逻辑已显式化
12
+ state: any,
13
+ ) {
8
14
  const {
9
15
  activeTab,
10
16
  currentConsoleType,
@@ -549,6 +555,14 @@ export function useDevToolHandlers(props: any, emits: any, state: any) {
549
555
  });
550
556
  }
551
557
 
558
+ function onChangeBarrageAllowDrag(val: boolean) {
559
+ state.barrageAllowDrag.value = val;
560
+ basicSendMessage({
561
+ type: CMD_TYPE.BARRAGE_ALLOW_DRAG,
562
+ data: { value: val },
563
+ });
564
+ }
565
+
552
566
  function onChangeBarrageTypes(val: string[]) {
553
567
  state.barrageTypes.value = val;
554
568
  basicSendMessage({
@@ -622,6 +636,7 @@ export function useDevToolHandlers(props: any, emits: any, state: any) {
622
636
  onChangeBarrageStartTop,
623
637
  onChangeBarrageDuration,
624
638
  onChangeBarrageMaxLength,
639
+ onChangeBarrageAllowDrag,
625
640
  onChangeBarrageTypes,
626
641
  onChangeBarrageShowWhenOpen,
627
642
  basicSendMessage,
@@ -18,7 +18,9 @@
18
18
  :resizable="true"
19
19
  :isFullScreen="isFullScreen"
20
20
  :maxWidth="100"
21
- handle=".drag-handle"
21
+ :safeTop="0"
22
+ :safeBottom="0"
23
+ :theme="theme"
22
24
  @update:x="onUpdateWindowX"
23
25
  @update:y="onUpdateWindowY"
24
26
  @update:width="onUpdateWindowWidth"
@@ -31,41 +33,20 @@
31
33
  isFullScreen ? 'is-full-screen' : 'is-window',
32
34
  ]">
33
35
  <view class="dev-tool-window-bg"></view>
34
-
35
- <view
36
- class="window-header drag-handle"
36
+ <Tabs
37
37
  data-drag-handle="1"
38
- @touchstart="onInitDrag"
39
- @mousedown="onInitDrag">
40
- <view
41
- class="drag-indicator"
42
- v-if="!isFullScreen"
43
- data-drag-handle="1"></view>
44
-
45
- <!--
46
- 你能想象,没有这条注释会报错???
47
- 我甚至都不知道错在哪里???
48
- 凸(艹皿艹 )
49
- 总有一些莫名其妙的错误
50
- Uncaught TypeError: Cannot read property 'children' of null at uni-app-view.umd.js:7
51
- Uncaught TypeError: Cannot read property '$' of undefined at uni-app-view.umd.js:7
52
- -->
53
-
54
- <Tabs
55
- data-drag-handle="1"
56
- :model-value="activeTab"
57
- :items="tabItems"
58
- :scroll-left="tabScrollLeft"
59
- @close="onCloseWindow"
60
- @scroll="debounceScrollTabs"
61
- @change="onChangeTabs">
62
- <template #extra>
63
- <CircularButton
64
- :text="isFullScreen ? '❐' : '⛶'"
65
- @click="toggleFullScreen" />
66
- </template>
67
- </Tabs>
68
- </view>
38
+ :model-value="activeTab"
39
+ :items="tabItems"
40
+ :scroll-left="tabScrollLeft"
41
+ @close="onCloseWindow"
42
+ @scroll="debounceScrollTabs"
43
+ @change="onChangeTabs">
44
+ <template #extra>
45
+ <CircularButton
46
+ :text="isFullScreen ? '❐' : '⛶'"
47
+ @click="toggleFullScreen" />
48
+ </template>
49
+ </Tabs>
69
50
 
70
51
  <CustomSwiper
71
52
  v-if="isReady"
@@ -358,6 +339,7 @@
358
339
  :barrage-start-top="barrageStartTop"
359
340
  :barrage-duration="barrageDuration"
360
341
  :barrage-max-length="barrageMaxLength"
342
+ :barrage-allow-drag="barrageAllowDrag"
361
343
  :barrage-types="barrageTypes"
362
344
  :barrage-show-when-open="barrageShowWhenOpen"
363
345
  :sizeFormat="sizeFormat"
@@ -390,6 +372,7 @@
390
372
  @change-barrage-start-top="onChangeBarrageStartTop"
391
373
  @change-barrage-duration="onChangeBarrageDuration"
392
374
  @change-barrage-max-length="onChangeBarrageMaxLength"
375
+ @change-barrage-allow-drag="onChangeBarrageAllowDrag"
393
376
  @change-barrage-types="onChangeBarrageTypes"
394
377
  @change-barrage-show-when-open="onChangeBarrageShowWhenOpen"
395
378
  @change-use-transition="onChangeUseTransition"
@@ -490,7 +473,7 @@ const props = withDefaults(
490
473
  useDevSource?: boolean;
491
474
  zIndex?: number;
492
475
  contentHeight: number;
493
- customStyle?: Record<string, any>;
476
+ customStyle?: Record<string, string | number>;
494
477
  origin?: { x: number; y: number };
495
478
  }>(),
496
479
  {
@@ -500,7 +483,10 @@ const props = withDefaults(
500
483
 
501
484
  const emits = defineEmits<{
502
485
  (e: 'close'): void;
503
- (e: 'sendMessage', data: { type: string; data: Record<string, any> }): void;
486
+ (
487
+ e: 'sendMessage',
488
+ data: { type: string; data: Record<string, unknown> },
489
+ ): void;
504
490
  (e: 'changeTheme', theme: string): void;
505
491
  }>();
506
492
 
@@ -569,6 +555,7 @@ const {
569
555
  barrageStartTop,
570
556
  barrageDuration,
571
557
  barrageMaxLength,
558
+ barrageAllowDrag,
572
559
  barrageTypes,
573
560
  barrageShowWhenOpen,
574
561
  isFullScreen,
@@ -578,15 +565,6 @@ const {
578
565
  windowHeight,
579
566
  } = data;
580
567
 
581
- const draggableRef = ref();
582
-
583
- /**
584
- * 初始化拖拽
585
- */
586
- function onInitDrag(e: MouseEvent | TouchEvent) {
587
- draggableRef.value?.initDrag(e);
588
- }
589
-
590
568
  function toggleFullScreen() {
591
569
  isFullScreen.value = !isFullScreen.value;
592
570
  saveSettings();
@@ -685,6 +663,7 @@ const {
685
663
  onChangeBarrageStartTop,
686
664
  onChangeBarrageDuration,
687
665
  onChangeBarrageMaxLength,
666
+ onChangeBarrageAllowDrag,
688
667
  onChangeBarrageTypes,
689
668
  onChangeBarrageShowWhenOpen,
690
669
  basicSendMessage,
@@ -770,14 +749,14 @@ function onUpdateStorageList(val: DevTool.StorageItem[]) {
770
749
  /**
771
750
  * 更新 Vuex 数据
772
751
  */
773
- function onUpdateVuexList(val: Record<string, any>) {
752
+ function onUpdateVuexList(val: Record<string, unknown>) {
774
753
  vuexList.value = val;
775
754
  }
776
755
 
777
756
  /**
778
757
  * 更新 Pinia 数据
779
758
  */
780
- function onUpdatePiniaList(val: Record<string, any>) {
759
+ function onUpdatePiniaList(val: Record<string, unknown>) {
781
760
  piniaList.value = val;
782
761
  }
783
762
 
@@ -942,25 +921,9 @@ onTabItemTap((option) => {
942
921
  height: 100%;
943
922
  color: var(--dev-tool-text-color);
944
923
  box-sizing: border-box;
945
- transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
946
924
  pointer-events: auto;
947
925
  }
948
926
 
949
- .is-window {
950
- border-radius: 12px;
951
- overflow: hidden;
952
- box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
953
- border: 1px solid var(--dev-tool-border-color);
954
- }
955
-
956
- .is-window .dev-tool-window-bg {
957
- border-radius: 12px;
958
- }
959
-
960
- .is-full-screen {
961
- border-radius: 0;
962
- }
963
-
964
927
  .window-header {
965
928
  width: 100%;
966
929
  cursor: move;