vite-uni-dev-tool 0.0.13 → 0.0.15

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 (130) hide show
  1. package/dist/core.js +1 -1
  2. package/dist/devIntercept/index.d.ts +3 -3
  3. package/dist/devIntercept/index.d.ts.map +1 -1
  4. package/dist/devIntercept/index.js +117 -114
  5. package/dist/plugins/uniDevTool/transform/transformApp.d.ts +32 -0
  6. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -0
  7. package/dist/plugins/uniDevTool/transform/transformApp.js +32 -0
  8. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +26 -0
  9. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -0
  10. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -0
  11. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +41 -0
  12. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -0
  13. package/dist/plugins/uniDevTool/transform/transformVue.js +9 -0
  14. package/dist/plugins/uniDevTool/uniDevTool.d.ts +7 -3
  15. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  16. package/dist/plugins/uniDevTool/uniDevTool.js +3 -33
  17. package/dist/plugins/utils/index.d.ts +32 -0
  18. package/dist/plugins/utils/index.d.ts.map +1 -1
  19. package/dist/plugins/utils/index.js +1 -1
  20. package/dist/type.d.ts +2 -2
  21. package/dist/type.d.ts.map +1 -1
  22. package/dist/v2/AppInfo/index.vue +41 -0
  23. package/dist/v2/AutoSizer/index.vue +189 -0
  24. package/dist/v2/AutoSizer/index1.vue +193 -0
  25. package/dist/v2/AutoSizer/utils.ts +49 -0
  26. package/dist/v2/CaptureScreen/index.vue +78 -0
  27. package/dist/v2/CloseButton/index.vue +32 -0
  28. package/dist/v2/Connection/index.vue +94 -0
  29. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  30. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  31. package/dist/v2/ConsoleList/index.vue +164 -0
  32. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  33. package/dist/v2/DevTool/index.vue +162 -0
  34. package/dist/v2/DevToolButton/index.vue +228 -0
  35. package/dist/v2/DevToolTitle/index.vue +28 -0
  36. package/dist/v2/DevToolWindow/index.vue +1051 -0
  37. package/dist/v2/DeviceInfo/index.vue +48 -0
  38. package/dist/v2/Empty/empty.png +0 -0
  39. package/dist/v2/Empty/index.vue +40 -0
  40. package/dist/v2/FilterInput/index.vue +100 -0
  41. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  42. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  43. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  44. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  45. package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
  46. package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
  47. package/dist/v2/JsonPretty/index.vue +531 -0
  48. package/dist/v2/JsonPretty/type.ts +125 -0
  49. package/dist/v2/JsonPretty/utils/index.js +211 -0
  50. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  51. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  52. package/dist/v2/NetworkList/index.vue +148 -0
  53. package/dist/v2/PiniaList/index.vue +79 -0
  54. package/dist/v2/RouteList/index.vue +137 -0
  55. package/dist/v2/RunJS/index.vue +128 -0
  56. package/dist/v2/SettingList/index.vue +318 -0
  57. package/dist/v2/SourceCode/index.vue +237 -0
  58. package/dist/v2/StorageList/index.vue +165 -0
  59. package/dist/v2/SystemInfo/index.vue +49 -0
  60. package/dist/v2/Tabs/index.vue +127 -0
  61. package/dist/v2/Tag/index.vue +91 -0
  62. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  63. package/dist/v2/UniEvent/index.vue +127 -0
  64. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  65. package/dist/v2/UploadList/UploadItem.vue +134 -0
  66. package/dist/v2/UploadList/index.vue +143 -0
  67. package/dist/v2/VirtualList/index.vue +140 -0
  68. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  69. package/dist/v2/VirtualListPro/index.vue +255 -0
  70. package/dist/v2/VirtualListPro/readme.md +40 -0
  71. package/dist/v2/VuexList/index.vue +80 -0
  72. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  73. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  74. package/dist/v2/WebSocket/index.vue +155 -0
  75. package/dist/v2/WindowInfo/index.vue +49 -0
  76. package/dist/v3/AppInfo/index.vue +35 -0
  77. package/dist/v3/AutoSizer/index.vue +193 -0
  78. package/dist/v3/AutoSizer/index1.vue +186 -0
  79. package/dist/v3/AutoSizer/utils.ts +49 -0
  80. package/dist/v3/CaptureScreen/index.vue +62 -0
  81. package/dist/v3/CloseButton/index.vue +29 -0
  82. package/dist/v3/Connection/index.vue +88 -0
  83. package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
  84. package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
  85. package/dist/v3/ConsoleList/index.vue +139 -0
  86. package/dist/v3/ConsoleList/staticTips.ts +1145 -0
  87. package/dist/v3/DevTool/index.vue +217 -0
  88. package/dist/v3/DevToolButton/index.vue +210 -0
  89. package/dist/v3/DevToolTitle/index.vue +21 -0
  90. package/dist/v3/DevToolWindow/index.vue +1116 -0
  91. package/dist/v3/DeviceInfo/index.vue +32 -0
  92. package/dist/v3/Empty/empty.png +0 -0
  93. package/dist/v3/Empty/index.vue +28 -0
  94. package/dist/v3/FilterInput/index.vue +87 -0
  95. package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
  96. package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
  97. package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
  98. package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
  99. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  100. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  101. package/dist/v3/JsonPretty/index.vue +476 -0
  102. package/dist/v3/JsonPretty/type.ts +125 -0
  103. package/dist/v3/JsonPretty/utils/index.ts +172 -0
  104. package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
  105. package/dist/v3/NetworkList/NetworkItem.vue +120 -0
  106. package/dist/v3/NetworkList/index.vue +128 -0
  107. package/dist/v3/PiniaList/index.vue +64 -0
  108. package/dist/v3/RouteList/index.vue +121 -0
  109. package/dist/v3/RunJS/index.vue +128 -0
  110. package/dist/v3/SettingList/index.vue +313 -0
  111. package/dist/v3/SourceCode/index.vue +231 -0
  112. package/dist/v3/StorageList/index.vue +170 -0
  113. package/dist/v3/SystemInfo/index.vue +34 -0
  114. package/dist/v3/Tabs/index.vue +123 -0
  115. package/dist/v3/Tag/index.vue +89 -0
  116. package/dist/v3/UniEvent/UniEventItem.vue +126 -0
  117. package/dist/v3/UniEvent/index.vue +98 -0
  118. package/dist/v3/UploadList/UploadDetail.vue +192 -0
  119. package/dist/v3/UploadList/UploadItem.vue +117 -0
  120. package/dist/v3/UploadList/index.vue +117 -0
  121. package/dist/v3/VirtualList/index.vue +112 -0
  122. package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
  123. package/dist/v3/VirtualListPro/index.vue +238 -0
  124. package/dist/v3/VirtualListPro/readme.md +40 -0
  125. package/dist/v3/VuexList/index.vue +54 -0
  126. package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
  127. package/dist/v3/WebSocket/WebSocketList.vue +161 -0
  128. package/dist/v3/WebSocket/index.vue +124 -0
  129. package/dist/v3/WindowInfo/index.vue +33 -0
  130. package/package.json +1 -1
@@ -0,0 +1,162 @@
1
+ <template>
2
+ <view class="dev-tool">
3
+ <DevToolButton
4
+ v-if="devToolButtonVisible"
5
+ :buttonSize="buttonProps.buttonSize"
6
+ :buttonText="buttonProps.buttonText"
7
+ :buttonColor="buttonProps.buttonColor"
8
+ :buttonFontSize="buttonProps.buttonFontSize"
9
+ :buttonBackgroundColor="buttonProps.buttonBackgroundColor"
10
+ :zIndex="zIndex"
11
+ @click="onDevToolButtonClick"
12
+ />
13
+ <DevToolWindow
14
+ :open="devToolWindowVisible"
15
+ :data="windowData"
16
+ :sourceFileServers="sourceFileServers"
17
+ :mode="mode"
18
+ :useDevSource="useDevSource"
19
+ :zIndex="zIndex + 1"
20
+ @close="onShowDevToolWindow(false)"
21
+ @sendMessage="onSendMessage"
22
+ />
23
+ </view>
24
+ </template>
25
+
26
+ <script>
27
+ import DevToolButton from '../DevToolButton/index.vue';
28
+ import DevToolWindow from '../DevToolWindow/index.vue';
29
+ import { eventBus } from '../../core';
30
+ import {
31
+ DEV_BUTTON_VISIBLE,
32
+ DEV_WINDOW_VISIBLE,
33
+ DEV_WINDOW_MESSAGE,
34
+ DEV_WINDOW_OPEN,
35
+ DEV_WINDOW_CLOSE,
36
+ DEV_OPTION_GET,
37
+ DEV_OPTION_SEND,
38
+ } from '../../const';
39
+ import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
40
+
41
+ export default {
42
+ components: {
43
+ DevToolButton,
44
+ DevToolWindow,
45
+ },
46
+ data() {
47
+ return {
48
+ isActive: false,
49
+ buttonProps: {
50
+ buttonSize: 50,
51
+ buttonText: '🐜',
52
+ buttonColor: '#fff',
53
+ buttonFontSize: '16px',
54
+ buttonBackgroundColor: 'rgba(255, 255, 255, 0)',
55
+ },
56
+ windowData: {},
57
+ devToolWindowVisible: false,
58
+ devToolButtonVisible: false,
59
+ sourceFileServers: [],
60
+ mode: '',
61
+ zIndex: 1000,
62
+ useDevSource: false,
63
+ };
64
+ },
65
+ beforeMount() {
66
+ // 初始化状态
67
+ const {
68
+ devToolButtonVisible: showButton = false,
69
+ devToolWindowVisible: showWindow = false,
70
+ } = getDevToolInfo();
71
+
72
+ this.isActive = true;
73
+ this.devToolButtonVisible = showButton;
74
+ this.devToolWindowVisible = showWindow;
75
+
76
+ // 注册事件监听
77
+ eventBus.on(DEV_BUTTON_VISIBLE, this.onShowDevToolButton);
78
+ eventBus.on(DEV_WINDOW_VISIBLE, this.onShowDevToolWindow);
79
+ eventBus.on(DEV_OPTION_SEND, this.onDevOptionSend);
80
+
81
+ // 下一帧发送获取配置请求
82
+ this.$nextTick(() => {
83
+ eventBus.emit(DEV_WINDOW_MESSAGE, { type: DEV_OPTION_GET, data: {} });
84
+ });
85
+ },
86
+ beforeUnmount() {
87
+ // 触发关闭事件并移除监听
88
+ eventBus.emit(DEV_WINDOW_MESSAGE, {
89
+ type: DEV_WINDOW_CLOSE,
90
+ data: {},
91
+ });
92
+ eventBus.off(DEV_BUTTON_VISIBLE, this.onShowDevToolButton);
93
+ eventBus.off(DEV_WINDOW_VISIBLE, this.onShowDevToolWindow);
94
+ },
95
+ onShow() {
96
+ this.isActive = true;
97
+ const {
98
+ devToolButtonVisible: showButton = false,
99
+ devToolWindowVisible: showWindow = false,
100
+ } = getDevToolInfo();
101
+
102
+ this.devToolWindowVisible = showWindow;
103
+ this.devToolButtonVisible = showButton;
104
+
105
+ // 如果窗口可见,触发打开事件
106
+ if (this.devToolWindowVisible) {
107
+ this.onSendMessage({
108
+ type: DEV_WINDOW_OPEN,
109
+ data: {},
110
+ });
111
+ }
112
+ },
113
+ onHide() {
114
+ this.isActive = false;
115
+ this.devToolWindowVisible = false;
116
+ },
117
+ methods: {
118
+ onDevToolButtonClick() {
119
+ this.onShowDevToolWindow(true);
120
+ this.onSendMessage({
121
+ type: DEV_WINDOW_OPEN,
122
+ data: {},
123
+ });
124
+ },
125
+ onShowDevToolButton(show) {
126
+ if (!this.isActive) return;
127
+ const { devToolButtonVisible: showButton = false } = getDevToolInfo();
128
+ this.devToolButtonVisible = show ?? showButton;
129
+ },
130
+ onShowDevToolWindow(show) {
131
+ if (!this.isActive) return;
132
+
133
+ this.devToolWindowVisible = show;
134
+ setDevToolInfo({
135
+ devToolWindowVisible: show,
136
+ });
137
+ },
138
+ onSendMessage(param) {
139
+ eventBus.emit(DEV_WINDOW_MESSAGE, param);
140
+ },
141
+ onDevOptionSend(options) {
142
+ if (options) {
143
+ // 更新按钮配置
144
+ this.buttonProps.buttonSize = options.buttonSize ?? 50;
145
+ this.buttonProps.buttonText = options.buttonText ?? '🐜';
146
+ this.buttonProps.buttonColor = options.buttonColor ?? '#fff';
147
+ this.buttonProps.buttonFontSize = options.buttonFontSize ?? '16px';
148
+ this.buttonProps.buttonBackgroundColor =
149
+ options.buttonBackgroundColor ?? 'rgba(255, 255, 255, 0)';
150
+
151
+ // 更新其他配置
152
+ this.sourceFileServers = options.sourceFileServers ?? [];
153
+ this.mode = options.mode ?? '';
154
+ this.useDevSource = options.useDevSource ?? false;
155
+ this.zIndex = options.zIndex ?? 1000;
156
+ }
157
+ },
158
+ },
159
+ };
160
+ </script>
161
+
162
+ <style scoped></style>
@@ -0,0 +1,228 @@
1
+ <template>
2
+ <view
3
+ ref="buttonRef"
4
+ class="dev-tool-button"
5
+ :style="{
6
+ fontSize: buttonFontSize,
7
+ backgroundColor: buttonBackgroundColor,
8
+ color: buttonColor,
9
+ width: buttonSize + 'px',
10
+ height: buttonSize + 'px',
11
+ cursor: isDragging ? 'move' : 'pointer',
12
+ zIndex: zIndex,
13
+ ...buttonPosition,
14
+ }"
15
+ @touchstart="onTouchStart"
16
+ @touchmove="onTouchMove"
17
+ @touchend="onTouchEnd"
18
+ @mousedown="onMouseDown"
19
+ >
20
+ {{ buttonText }}
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
26
+
27
+ export default {
28
+ props: {
29
+ buttonSize: {
30
+ type: Number,
31
+ default: 50,
32
+ },
33
+ buttonText: {
34
+ type: String,
35
+ default: '',
36
+ },
37
+ buttonColor: {
38
+ type: String,
39
+ default: '#fff',
40
+ },
41
+ buttonFontSize: {
42
+ type: String,
43
+ default: '16px',
44
+ },
45
+ buttonBackgroundColor: {
46
+ type: String,
47
+ default: 'rgba(255, 255, 255, 0)',
48
+ },
49
+ zIndex: {
50
+ type: Number,
51
+ default: 1000,
52
+ },
53
+ },
54
+
55
+ data() {
56
+ return {
57
+ buttonPosition: {
58
+ left: '',
59
+ top: '',
60
+ transition: 'none',
61
+ },
62
+ isDragging: false,
63
+ page: { pageX: 0, pageY: 0 },
64
+ startTime: 0,
65
+ timer: null,
66
+ mouseUpTimer: null,
67
+ windowWidth: 0,
68
+ windowHeight: 0,
69
+ sizeHalf: 0,
70
+ };
71
+ },
72
+
73
+ computed: {
74
+ isTouchDevice() {
75
+ return typeof window !== 'undefined' && 'ontouchstart' in window;
76
+ },
77
+ },
78
+
79
+ mounted() {
80
+ const sysInfo = uni.getSystemInfoSync();
81
+ this.windowWidth = sysInfo.windowWidth;
82
+ this.windowHeight = sysInfo.windowHeight;
83
+ this.sizeHalf = this.buttonSize / 2;
84
+
85
+ // 初始化位置
86
+ const { left, top } = getDevToolInfo();
87
+ this.buttonPosition.left =
88
+ left || this.windowWidth - this.buttonSize + 'px';
89
+ this.buttonPosition.top = top || '80vh';
90
+ },
91
+
92
+ onShow() {
93
+ // H5 环境下注册鼠标事件
94
+ // #ifdef H5
95
+ window.addEventListener('mousemove', this.onMouseMove);
96
+ window.addEventListener('mouseup', this.onMouseUp);
97
+ window.addEventListener('resize', this.onResize);
98
+ // #endif
99
+ },
100
+
101
+ onHide() {
102
+ // #ifdef H5
103
+ window.removeEventListener('mousemove', this.onMouseMove);
104
+ window.removeEventListener('mouseup', this.onMouseUp);
105
+ window.removeEventListener('resize', this.onResize);
106
+ // #endif
107
+ },
108
+
109
+ methods: {
110
+ onTouchStart(touch) {
111
+ touch.stopPropagation();
112
+ this.page.pageX = touch.touches?.[0]?.pageX;
113
+ this.page.pageY = touch.touches?.[0]?.pageY;
114
+ this.startTime = Date.now();
115
+ this.buttonPosition.transition = 'none';
116
+ },
117
+
118
+ onTouchMove(touch) {
119
+ touch?.preventDefault?.();
120
+ touch?.stopPropagation?.();
121
+ if (!this.page) return;
122
+ if (Date.now() - this.startTime < 150) return;
123
+
124
+ if (this.mouseUpTimer) {
125
+ clearTimeout(this.mouseUpTimer);
126
+ }
127
+ this.updatePosition(
128
+ touch.touches[0].pageX,
129
+ touch.touches[0].pageY,
130
+ this.isTouchDevice,
131
+ );
132
+ },
133
+
134
+ onTouchEnd(e) {
135
+ e.stopPropagation();
136
+ if (Date.now() - this.startTime < 100) {
137
+ this.$emit('click');
138
+ }
139
+
140
+ if (this.mouseUpTimer) {
141
+ clearTimeout(this.mouseUpTimer);
142
+ }
143
+ this.mouseUpTimer = setTimeout(() => {
144
+ this.onResize();
145
+ }, 3000);
146
+ },
147
+
148
+ onMouseDown(event) {
149
+ if (this.isTouchDevice) return;
150
+ this.page.pageX = event.pageX;
151
+ this.page.pageY = event.pageY;
152
+ this.startTime = Date.now();
153
+ this.isDragging = true;
154
+ event.preventDefault();
155
+ event.stopPropagation();
156
+ this.buttonPosition.transition = 'none';
157
+ },
158
+
159
+ onMouseMove(event) {
160
+ if (!this.isDragging) return;
161
+ event.preventDefault();
162
+ const mouseX = event.pageX;
163
+ const mouseY = event.pageY;
164
+ if (this.mouseUpTimer) {
165
+ clearTimeout(this.mouseUpTimer);
166
+ }
167
+ this.updatePosition(mouseX, mouseY);
168
+ },
169
+
170
+ onMouseUp() {
171
+ this.isDragging = false;
172
+ if (Date.now() - this.startTime < 150) {
173
+ this.$emit('click');
174
+ }
175
+ if (this.mouseUpTimer) {
176
+ clearTimeout(this.mouseUpTimer);
177
+ }
178
+ this.mouseUpTimer = setTimeout(() => {
179
+ this.onResize();
180
+ }, 3000);
181
+ },
182
+
183
+ onResize() {
184
+ const { windowWidth } = uni.getSystemInfoSync();
185
+
186
+ this.buttonPosition.transition = 'all 0.3s ease-in-out';
187
+ this.buttonPosition.left = windowWidth - this.buttonSize + 'px';
188
+
189
+ if (this.timer) {
190
+ clearTimeout(this.timer);
191
+ }
192
+ this.timer = setTimeout(() => {
193
+ this.buttonPosition.transition = 'none';
194
+ setDevToolInfo({
195
+ left: this.buttonPosition.left,
196
+ top: this.buttonPosition.top,
197
+ });
198
+ }, 350);
199
+ },
200
+
201
+ updatePosition(x, y, isTouch = false) {
202
+ // 限制 Y 轴位置
203
+ if (y - this.sizeHalf > 0 && y < this.windowHeight - this.sizeHalf) {
204
+ if (isTouch) {
205
+ this.buttonPosition.top = y + this.sizeHalf + 'px';
206
+ } else {
207
+ this.buttonPosition.top = y - this.sizeHalf + 'px';
208
+ }
209
+ }
210
+ // 限制 X 轴位置
211
+ if (x - this.sizeHalf > 0 && x < this.windowWidth - this.sizeHalf) {
212
+ this.buttonPosition.left = x - this.sizeHalf + 'px';
213
+ }
214
+ },
215
+ },
216
+ };
217
+ </script>
218
+
219
+ <style scoped>
220
+ .dev-tool-button {
221
+ position: fixed;
222
+ display: flex;
223
+ align-items: center;
224
+ justify-content: center;
225
+ border-radius: 50%;
226
+ cursor: pointer;
227
+ }
228
+ </style>
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <view class="dev-tool-title" :style="innerStyle"> <slot /> </view>
3
+ </template>
4
+ <script>
5
+ export default {
6
+ props: {
7
+ innerStyle: {
8
+ type: [Object, String],
9
+ default: () => ({}),
10
+ },
11
+ },
12
+ };
13
+ </script>
14
+ <style scoped>
15
+ .dev-tool-title {
16
+ display: flex;
17
+ align-items: center;
18
+ height: 32px;
19
+ }
20
+ .dev-tool-title::before {
21
+ content: '';
22
+ margin-right: 8px;
23
+ width: 2px;
24
+ height: 18px;
25
+ border-radius: 2px;
26
+ background-color: var(--dev-tool-main-color);
27
+ }
28
+ </style>