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,243 @@
1
+ <template>
2
+ <view class="run-js-input-wrapper">
3
+ <view class="run-js-input-icon"></view>
4
+ <input
5
+ v-model="code"
6
+ class="run-js-input"
7
+ placeholder="run..."
8
+ @confirm="onConfirm"
9
+ @input="onChange"
10
+ />
11
+ <view class="run-js-tips">
12
+ <view
13
+ class="run-js-tips-item"
14
+ v-for="(item, index) in tips"
15
+ :key="index"
16
+ @click="onChoose(item.name)"
17
+ >
18
+ {{ item.name }}{{ item.description ? ': ' : ' ' }}{{ item.description }}
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import {
26
+ staticTips,
27
+ singleTips,
28
+ flatStaticTips,
29
+ baseSymbols,
30
+ } from './staticTips.js';
31
+
32
+ export default {
33
+ data() {
34
+ return {
35
+ code: '',
36
+ tips: [],
37
+ };
38
+ },
39
+ methods: {
40
+ onConfirm() {
41
+ this.tips = [];
42
+ const value = this.code;
43
+ if (!value) return;
44
+ this.code = '';
45
+ setTimeout(() => {
46
+ this.$emit('run', value);
47
+ }, 100);
48
+ },
49
+ /**
50
+ * 1.对象,方法,变量 在 ; ( , =,==,=== , + , - , * , / , && , || ?? 之后 开始提示
51
+ *
52
+ * Math
53
+ * console
54
+ *
55
+ * 2.在 . 之后 提示
56
+ *
57
+ * Math.a
58
+ * console.a
59
+ *
60
+ *
61
+ * 3.对方法,属性返回值进行提示
62
+ *
63
+ * Math.abc().
64
+ *
65
+ *
66
+ * any, void 不进行提示
67
+ *
68
+ * 4. [] 数组提示
69
+ *
70
+ * [1,2].concat([2,3].map(parseInt))
71
+ *
72
+ * 5. (值) 推断提示
73
+ * ({}).valueOf()
74
+ *
75
+ *
76
+ * @param e 输入框内容
77
+ */
78
+ onChange(e) {
79
+ const { value, cursor } = e.detail;
80
+ // 光标之前的内容
81
+ const content = value.slice(0, cursor);
82
+
83
+ // 获取符号之后的内容
84
+ const lastIndex = this.getBaseSymbolLastIndex(content);
85
+
86
+ const con = lastIndex > -1 ? value.substring(lastIndex + 1) : value;
87
+
88
+ if (!con) {
89
+ // 不存在内容
90
+ this.tips = [];
91
+ } else {
92
+ // 存在内容
93
+
94
+ // 一级点之后的内容
95
+ const [main, sub] = con.split('.');
96
+
97
+ if (singleTips.includes(main) && con.includes('.')) {
98
+ const list = [
99
+ ...(staticTips[main]?.attr ?? []),
100
+ ...(staticTips[main]?.fun ?? []),
101
+ ];
102
+
103
+ if (sub) {
104
+ this.tips = list.filter((item) => item.name.startsWith(sub));
105
+ } else {
106
+ this.tips = list;
107
+ }
108
+ } else {
109
+ if (main.includes(')') && con.includes('.')) {
110
+ // 方法调用之后的提示
111
+
112
+ // 获取方法名称 倒数第二个 . 到最后一个 ( 之间为方法名称
113
+ const s = this.getSecondLastDotPosition(content);
114
+ const e = content.lastIndexOf('(');
115
+ const methodName = content.substring(s + 1, e);
116
+
117
+ const fn = this.findFunction(methodName);
118
+ // 获取方法返回值
119
+ const result = fn?.[0]?.result?.[0];
120
+ if (result && result !== 'any' && result !== 'void') {
121
+ this.tips = Object.values(staticTips?.[result] ?? {}).flat(2);
122
+ } else {
123
+ this.tips = [];
124
+ }
125
+ } else {
126
+ // 基础提示
127
+ this.tips = singleTips
128
+ .filter((item) => item.startsWith(con))
129
+ .map((item) => ({
130
+ name: item,
131
+ description: '',
132
+ result: ['any'],
133
+ }));
134
+ }
135
+ }
136
+ }
137
+ },
138
+
139
+ onChoose(name) {
140
+ // 选择提示项的逻辑
141
+ // 原逻辑注释保留,可根据实际需求完善
142
+ // const lastIndex = this.code.lastIndexOf(';');
143
+ // const con = lastIndex > -1 ? this.code.substring(lastIndex + 1) : this.code;
144
+ // const lastCon = con.lastIndexOf('.');
145
+ // if (lastCon > -1) {
146
+ // this.code = con.substring(0, lastCon + 1) + name;
147
+ // } else {
148
+ // this.code = name;
149
+ // }
150
+ // this.tips = [];
151
+ },
152
+
153
+ getBaseSymbolLastIndex(code) {
154
+ for (let i = code.length - 1; i >= 0; i--) {
155
+ if (baseSymbols.includes(code[i])) {
156
+ return i; // 找到最后一个符号的位置
157
+ }
158
+ }
159
+ return -1; // 未找到任何符号
160
+ },
161
+
162
+ getSecondLastDotPosition(str) {
163
+ let dotCount = 0;
164
+ for (let i = str.length - 1; i >= 0; i--) {
165
+ if (str[i] === '.') {
166
+ dotCount++;
167
+ if (dotCount === 2) {
168
+ return i;
169
+ }
170
+ }
171
+ }
172
+ return -1; // 未找到足够的点号
173
+ },
174
+
175
+ findFunction(fn) {
176
+ return flatStaticTips.filter((item) => item.name.startsWith(fn));
177
+ },
178
+ },
179
+ };
180
+ </script>
181
+
182
+ <style scoped>
183
+ .run-js-input-wrapper {
184
+ position: relative;
185
+ display: flex;
186
+ align-items: center;
187
+ padding: 0 16px;
188
+ height: 32px;
189
+ border-top: 1px solid var(--dev-tool-border-color);
190
+ border-bottom: 1px solid var(--dev-tool-border-color);
191
+ box-sizing: border-box;
192
+ }
193
+
194
+ .run-js-input-icon {
195
+ margin: 10px 0 10px -4px;
196
+ width: 8px;
197
+ height: 8px;
198
+ border: 1px solid var(--dev-tool-text-color);
199
+ border-bottom-color: transparent;
200
+ border-left-color: transparent;
201
+ overflow: hidden;
202
+ transform: rotate(45deg);
203
+ transition: border 0.3s;
204
+ }
205
+
206
+ .run-js-input {
207
+ margin: 1px 0 1px 16px;
208
+ min-height: 26px;
209
+ width: 100%;
210
+ border: 1px solid transparent;
211
+ font-size: var(--dev-tool-base-font-size);
212
+ color: var(--dev-tool-text-color);
213
+ transition: color 0.3s;
214
+ }
215
+
216
+ .run-js-tips {
217
+ position: absolute;
218
+ bottom: 31px;
219
+ left: 0;
220
+ background-color: var(--dev-tool-bg-color);
221
+ width: 100%;
222
+ max-height: 200px;
223
+ padding: 0 16px 0 36px;
224
+ box-sizing: border-box;
225
+ overflow-y: auto;
226
+ overflow-x: hidden;
227
+ box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
228
+ }
229
+ .run-js-tips-item {
230
+ display: flex;
231
+ align-items: center;
232
+ height: 28px;
233
+ width: 100%;
234
+ white-space: nowrap;
235
+ border: 1px solid transparent;
236
+ border-bottom: 1px solid var(--dev-tool-border-color);
237
+ overflow: hidden;
238
+ text-overflow: ellipsis;
239
+ }
240
+ .run-js-tips-item-active {
241
+ border: 1px solid var(--dev-tool-main-color);
242
+ }
243
+ </style>
@@ -0,0 +1,164 @@
1
+ <template>
2
+ <view class="console-content">
3
+ <view class="console-control">
4
+ <FilterInput
5
+ :modelValue="modelValue"
6
+ @search="$emit('search', $event)"
7
+ @update:modelValue="$emit('update:modelValue', $event)"
8
+ />
9
+ <Tag
10
+ v-for="item in consoleFilterItems"
11
+ :mode="item.value"
12
+ :key="item.value"
13
+ :active="currentConsoleType === item.value"
14
+ @click="$emit('choose', item.value)"
15
+ >
16
+ {{ item.label }}
17
+ </Tag>
18
+ </view>
19
+
20
+ <VirtualListPro
21
+ :dataSource="consoleList"
22
+ :pageSize="15"
23
+ :scrollIntoView="scrollIntoView"
24
+ :scrollWithAnimation="true"
25
+ :height="height"
26
+ className="console-list"
27
+ >
28
+ <template #default="{ list, current, start }">
29
+ <AutoSize
30
+ v-for="(item, index) in list"
31
+ :index="start + index"
32
+ :key="start + index"
33
+ >
34
+ <ConsoleItem
35
+ :consoleItem="item"
36
+ :sourceFileServers="sourceFileServers"
37
+ :mode="mode"
38
+ :useDevSource="useDevSource"
39
+ :id="`dev-console-${start + index}`"
40
+ :zIndex="zIndex"
41
+ />
42
+ </AutoSize>
43
+ <Empty v-if="!consoleList || consoleList.length === 0" />
44
+ </template>
45
+ </VirtualListPro>
46
+ <RunJSInput @run="$emit('run', $event)" />
47
+ </view>
48
+ </template>
49
+
50
+ <script>
51
+ import ConsoleItem from './ConsoleItem.vue';
52
+ import Tag from '../Tag/index.vue';
53
+ import Empty from '../Empty/index.vue';
54
+ import FilterInput from '../FilterInput/index.vue';
55
+ import RunJSInput from './RunJSInput.vue';
56
+ import VirtualListPro from '../VirtualListPro/index.vue';
57
+ import AutoSize from '../VirtualListPro/AutoSize.vue';
58
+ import { debounce } from '../../utils';
59
+
60
+ export default {
61
+ components: {
62
+ ConsoleItem,
63
+ Tag,
64
+ Empty,
65
+ FilterInput,
66
+ RunJSInput,
67
+ VirtualListPro,
68
+ AutoSize,
69
+ },
70
+ props: {
71
+ consoleList: {
72
+ type: Array,
73
+ default: () => [],
74
+ },
75
+ currentConsoleType: {
76
+ type: String,
77
+ default: 'all',
78
+ },
79
+ modelValue: {
80
+ type: String,
81
+ default: '',
82
+ },
83
+ sourceFileServers: {
84
+ type: Array,
85
+ default: () => [],
86
+ },
87
+ mode: {
88
+ type: String,
89
+ default: '',
90
+ },
91
+ useDevSource: {
92
+ type: Boolean,
93
+ default: false,
94
+ },
95
+ zIndex: {
96
+ type: Number,
97
+ default: 0,
98
+ },
99
+ },
100
+ data() {
101
+ return {
102
+ scrollIntoView: '',
103
+ height: 0,
104
+ consoleFilterItems: [
105
+ { label: '全部', value: 'all' },
106
+ { label: 'info', value: 'info' },
107
+ { label: 'log', value: 'log' },
108
+ { label: 'warn', value: 'warn' },
109
+ { label: 'error', value: 'error' },
110
+ { label: '清除', value: 'clear' },
111
+ ],
112
+ };
113
+ },
114
+ mounted() {
115
+ const { windowHeight } = uni.getWindowInfo();
116
+
117
+ this.height = windowHeight - 32 - 32 - 32;
118
+
119
+ // this.initWatch();
120
+ },
121
+ watch: {
122
+ consoleList: {
123
+ handler(val) {
124
+ // console.log('val: ', val);
125
+ // this.consoleList = val;
126
+ },
127
+ deep: true,
128
+ },
129
+ },
130
+ methods: {
131
+ // initWatch() {
132
+ // // Vue2 中使用 $watch 监听 props 变化
133
+ // this.$watch(
134
+ // 'consoleList',
135
+ // debounce(() => {
136
+ // if (this.consoleList.length) {
137
+ // this.scrollIntoView = `dev-console-${this.consoleList.length - 1}`;
138
+ // }
139
+ // }, 200),
140
+ // );
141
+ // },
142
+ },
143
+ };
144
+ </script>
145
+
146
+ <style scoped>
147
+ .console-content {
148
+ height: 100%;
149
+ font-size: var(--dev-tool-base-font-size);
150
+ }
151
+ .console-list {
152
+ height: calc(100% - 32px - 32px);
153
+ }
154
+ .console-control {
155
+ display: flex;
156
+ align-items: center;
157
+ justify-content: space-between;
158
+ gap: 8px;
159
+ padding: 0 16px;
160
+ height: 32px;
161
+ border-bottom: 1px solid var(--dev-tool-border-color);
162
+ box-sizing: border-box;
163
+ }
164
+ </style>