vite-uni-dev-tool 0.0.20 → 0.0.22

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 (40) hide show
  1. package/README.md +14 -3
  2. package/dist/const.d.ts +12 -0
  3. package/dist/const.d.ts.map +1 -1
  4. package/dist/const.js +23 -20
  5. package/dist/core.d.ts +3 -3
  6. package/dist/core.d.ts.map +1 -1
  7. package/dist/core.js +89 -49
  8. package/dist/devEvent/index.d.ts +34 -0
  9. package/dist/devEvent/index.d.ts.map +1 -1
  10. package/dist/devEvent/index.js +71 -27
  11. package/dist/devIntercept/index.d.ts.map +1 -1
  12. package/dist/devIntercept/index.js +171 -145
  13. package/dist/devStore/index.d.ts +9 -0
  14. package/dist/devStore/index.d.ts.map +1 -1
  15. package/dist/devStore/index.js +54 -20
  16. package/dist/plugins/uniDevTool/uniDevTool.d.ts +1 -1
  17. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  18. package/dist/type.d.ts +18 -1
  19. package/dist/type.d.ts.map +1 -1
  20. package/dist/v2/DevTool/index.vue +8 -8
  21. package/dist/v3/DevTool/index.vue +13 -12
  22. package/dist/v3/DevToolWindow/const.d.ts +30 -0
  23. package/dist/v3/DevToolWindow/const.d.ts.map +1 -0
  24. package/dist/v3/DevToolWindow/const.ts +123 -0
  25. package/dist/v3/DevToolWindow/index.vue +186 -107
  26. package/dist/v3/NetworkList/InterceptConfig.vue +835 -0
  27. package/dist/v3/NetworkList/InterceptItem.vue +132 -0
  28. package/dist/v3/NetworkList/NetworkDetail.vue +86 -31
  29. package/dist/v3/NetworkList/NetworkIntercept.vue +85 -0
  30. package/dist/v3/NetworkList/NetworkItem.vue +18 -18
  31. package/dist/v3/NetworkList/NetworkSend.vue +61 -45
  32. package/dist/v3/NetworkList/index.vue +11 -67
  33. package/dist/v3/SettingList/index.vue +23 -2
  34. package/dist/v3/SourceCode/Line.vue +101 -0
  35. package/dist/v3/SourceCode/index.vue +35 -62
  36. package/dist/v3/SourceCode/parseCode.d.ts +27 -0
  37. package/dist/v3/SourceCode/parseCode.d.ts.map +1 -0
  38. package/dist/v3/SourceCode/parseCode.ts +643 -0
  39. package/dist/v3/Tag/index.vue +1 -0
  40. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ type Word = {
2
+ /** 字符 */
3
+ word: string;
4
+ /** css 样式 */
5
+ class: string;
6
+ /** 分类
7
+ * - space: 空格
8
+ * - bracket: 括号
9
+ * - quotation: 引号
10
+ * - string: 字符串
11
+ * - function: 函数
12
+ * - attribute: 属性
13
+ * - operator: 操作符
14
+ * - symbol: 符号
15
+ * - keyword: 关键字
16
+ * - other: 其他
17
+ */
18
+ type: 'space' | 'bracket' | 'quotation' | 'string' | 'function' | 'attribute' | 'operator' | 'symbol' | 'keyword' | 'other';
19
+ };
20
+ export type LineInfo = {
21
+ type: 'empty' | 'tag' | 'script' | 'style' | 'note';
22
+ class: string;
23
+ words: Word[];
24
+ };
25
+ export declare function parseCode(code: string): LineInfo[];
26
+ export {};
27
+ //# sourceMappingURL=parseCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCode.d.ts","sourceRoot":"","sources":["../../../dev/v3/SourceCode/parseCode.ts"],"names":[],"mappings":"AA0IA,KAAK,IAAI,GAAG;IACV,SAAS;IACT,IAAI,EAAE,MAAM,CAAC;IACb,aAAa;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;OAWG;IACH,IAAI,EACA,OAAO,GACP,SAAS,GACT,WAAW,GACX,QAAQ,GACR,UAAU,GACV,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,GACT,OAAO,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAobF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAkClD"}
@@ -0,0 +1,643 @@
1
+ /** 行前空格匹配 */
2
+ const startSpaceReg = /^(\s*)/;
3
+
4
+ /** 括号 */
5
+ const bracketList = ['<', '>', '(', ')', '{', '}', '[', ']'];
6
+
7
+ /** 引号 */
8
+ const quotationList = ["'", '"', '‘', '’', '`'];
9
+
10
+ /** 操作符 */
11
+ const operatorList = ['+', '-', '*', '/', '%', '=', '!', '&'];
12
+
13
+ /** 符号 */
14
+ const symbolList = [
15
+ ' ',
16
+ '<',
17
+ '>',
18
+ '(',
19
+ ')',
20
+ '{',
21
+ '}',
22
+ '[',
23
+ ']',
24
+ ';',
25
+ ':',
26
+ ',',
27
+ '.',
28
+ '=',
29
+ '?',
30
+ '+',
31
+ '-',
32
+ '*',
33
+ '/',
34
+ '\\',
35
+ "'",
36
+ '"',
37
+ '@',
38
+ '#',
39
+ '$',
40
+ ];
41
+
42
+ /** 关键字 */
43
+ const keywordList = [
44
+ // JavaScript 关键字
45
+ 'var',
46
+ 'let',
47
+ 'const',
48
+ 'function',
49
+ 'class',
50
+ 'import',
51
+ 'export',
52
+ 'from',
53
+ 'as',
54
+ 'this',
55
+ 'super',
56
+ 'console',
57
+ 'window',
58
+ 'document',
59
+ 'if',
60
+ 'else',
61
+ 'for',
62
+ 'while',
63
+ 'do',
64
+ 'switch',
65
+ 'case',
66
+ 'default',
67
+ 'break',
68
+ 'continue',
69
+ 'return',
70
+ 'try',
71
+ 'catch',
72
+ 'finally',
73
+ 'throw',
74
+ 'new',
75
+ 'delete',
76
+ 'typeof',
77
+ 'instanceof',
78
+ 'in',
79
+ 'of',
80
+ 'void',
81
+ 'yield',
82
+ 'await',
83
+ 'async',
84
+ 'extends',
85
+ 'implements',
86
+ 'interface',
87
+ 'package',
88
+ 'private',
89
+ 'protected',
90
+ 'public',
91
+ 'static',
92
+ 'yield',
93
+ 'null',
94
+ 'undefined',
95
+ 'true',
96
+ 'false',
97
+ 'get',
98
+
99
+ // Vue 特定关键字
100
+ // 'ref',
101
+ // 'reactive',
102
+ // 'computed',
103
+ // 'watch',
104
+ // 'watchEffect',
105
+ // 'provide',
106
+ // 'inject',
107
+ // 'setup',
108
+ // 'onMounted',
109
+ // 'onUnmounted',
110
+ // 'onUpdated',
111
+ // 'onBeforeMount',
112
+ // 'onBeforeUpdate',
113
+ // 'onBeforeUnmount',
114
+ // 'nextTick',
115
+ // 'defineComponent',
116
+ // 'defineProps',
117
+ // 'defineEmits',
118
+ // 'defineExpose',
119
+ // 'withDefaults',
120
+
121
+ // // UniApp 特定关键字
122
+ // 'uni',
123
+ // 'getCurrentInstance',
124
+ // 'onLoad',
125
+ // 'onShow',
126
+ // 'onReady',
127
+ // 'onHide',
128
+ // 'onUnload',
129
+ // 'onPullDownRefresh',
130
+ // 'onReachBottom',
131
+ // 'onShareAppMessage',
132
+ // 'onShareTimeline',
133
+ // 'onAddToFavorites',
134
+ // 'onPageScroll',
135
+ // 'onResize',
136
+ // 'onTabItemTap',
137
+ ];
138
+
139
+ type Word = {
140
+ /** 字符 */
141
+ word: string;
142
+ /** css 样式 */
143
+ class: string;
144
+ /** 分类
145
+ * - space: 空格
146
+ * - bracket: 括号
147
+ * - quotation: 引号
148
+ * - string: 字符串
149
+ * - function: 函数
150
+ * - attribute: 属性
151
+ * - operator: 操作符
152
+ * - symbol: 符号
153
+ * - keyword: 关键字
154
+ * - other: 其他
155
+ */
156
+ type:
157
+ | 'space'
158
+ | 'bracket'
159
+ | 'quotation'
160
+ | 'string'
161
+ | 'function'
162
+ | 'attribute'
163
+ | 'operator'
164
+ | 'symbol'
165
+ | 'keyword'
166
+ | 'other';
167
+ };
168
+
169
+ export type LineInfo = {
170
+ type: 'empty' | 'tag' | 'script' | 'style' | 'note';
171
+ class: string;
172
+ words: Word[];
173
+ };
174
+
175
+ const scriptStartReg = /<script(\s[^>]*)?>/i;
176
+ const scriptEndReg = /<\/script>/i;
177
+
178
+ const styleStartReg = /<style(\s[^>]*)?>/i;
179
+ const styleEndReg = /<\/style>/i;
180
+
181
+ const preClass = 'source-code-pre';
182
+
183
+ /**
184
+ * 获取代码中所有 <script> 块的起止行号(不包含标签本身)
185
+ * @param lines 源码按行分割后的字符串数组
186
+ * @returns 起止行号组成的二维数组,每个子数组为 [startRow, endRow]
187
+ */
188
+ function getScriptStartAndEndRow(lines: string[]): number[][] {
189
+ // 如果没有找到任何<script>标签,则认为整段代码都是script代码
190
+ let hasScriptTags = false;
191
+ const groups: number[][] = [];
192
+ let currentStart: number | null = null; // 记录当前 <script> 开始行号
193
+
194
+ lines.forEach((line, index) => {
195
+ if (scriptStartReg.test(line)) {
196
+ hasScriptTags = true;
197
+ // 遇到开始标签,记录下一行作为内容开始位置
198
+ currentStart = index + 1;
199
+ } else if (scriptEndReg.test(line) && currentStart !== null) {
200
+ // 遇到结束标签且已有开始位置,则记录为一个有效块
201
+ // 如果开始行大于等于结束行(即<script></script>在同一行或相邻行),则不构成有效内容区间
202
+ if (currentStart <= index - 1) {
203
+ groups.push([currentStart, index - 1]); // 结束行为上一行(排除 </script>)
204
+ }
205
+ currentStart = null; // 重置等待下一个 <script>
206
+ }
207
+ });
208
+
209
+ // 如果完全没有<script>标签,则整段代码都算作script内容
210
+ if (!hasScriptTags && lines.length > 0) {
211
+ // 整个文件都是script代码
212
+ groups.push([0, lines.length - 1]);
213
+ }
214
+
215
+ return groups;
216
+ }
217
+
218
+ /**
219
+ * 获取代码中所有 <style> 块的起止行号(不包含标签本身)
220
+ * @param lines 源码按行分割后的字符串数组
221
+ * @returns 起止行号组成的二维数组,每个子数组为 [startRow, endRow]
222
+ */
223
+
224
+ function getStyleStartAndEndRow(lines: string[]): number[][] {
225
+ const groups: number[][] = [];
226
+ let currentStart: number | null = null; // 记录当前 <style> 开始行号
227
+
228
+ lines.forEach((line, index) => {
229
+ if (styleStartReg.test(line)) {
230
+ // 遇到开始标签,记录下一行作为内容开始位置
231
+ currentStart = index + 1;
232
+ } else if (styleEndReg.test(line) && currentStart !== null) {
233
+ // 遇到结束标签且已有开始位置,则记录为一个有效块
234
+ // 如果开始行大于等于结束行(即<style></style>在同一行或相邻行),则不构成有效内容区间
235
+ if (currentStart <= index - 1) {
236
+ groups.push([currentStart, index - 1]); // 结束行为上一行(排除 </style>)
237
+ }
238
+ currentStart = null; // 重置等待下一个 <style>
239
+ }
240
+ });
241
+
242
+ return groups;
243
+ }
244
+
245
+ /**
246
+ * 获取代码中所有注释块的起止行号
247
+ * @param lines 源码按行分割后的字符串数组
248
+ * @returns 起止行号组成的二维数组,每个子数组为 [startRow, endRow]
249
+ */
250
+ function getNoteStartAndEndRow(lines: string[]): number[][] {
251
+ const groups: number[][] = [];
252
+ let currentStart: number | null = null; // 记录当前注释块开始行号
253
+ let inMultiLineComment = false; // 是否在多行注释 /* */ 中
254
+ let inHtmlComment = false; // 是否在HTML注释 <!-- --> 中
255
+
256
+ lines.forEach((line, index) => {
257
+ const trimLine = line.trim();
258
+
259
+ // 处理 /* */ 多行注释
260
+ if (!inMultiLineComment && !inHtmlComment && trimLine.startsWith('/*')) {
261
+ inMultiLineComment = true;
262
+ currentStart = index;
263
+
264
+ // 检查是否在同一行内结束多行注释
265
+ if (
266
+ trimLine.includes('*/') &&
267
+ trimLine.indexOf('*/') > trimLine.indexOf('/*')
268
+ ) {
269
+ groups.push([currentStart, index]);
270
+ inMultiLineComment = false;
271
+ currentStart = null;
272
+ }
273
+ } else if (inMultiLineComment && trimLine.includes('*/')) {
274
+ // 结束多行注释
275
+ groups.push([currentStart!, index]);
276
+ inMultiLineComment = false;
277
+ currentStart = null;
278
+ }
279
+ // 处理 <!-- --> HTML注释
280
+ else if (
281
+ !inMultiLineComment &&
282
+ !inHtmlComment &&
283
+ trimLine.startsWith('<!--')
284
+ ) {
285
+ inHtmlComment = true;
286
+ currentStart = index;
287
+
288
+ // 检查是否在同一行内结束HTML注释
289
+ if (
290
+ trimLine.includes('-->') &&
291
+ trimLine.indexOf('-->') > trimLine.indexOf('<!--')
292
+ ) {
293
+ groups.push([currentStart, index]);
294
+ inHtmlComment = false;
295
+ currentStart = null;
296
+ }
297
+ } else if (inHtmlComment && trimLine.includes('-->')) {
298
+ // 结束HTML注释
299
+ groups.push([currentStart!, index]);
300
+ inHtmlComment = false;
301
+ currentStart = null;
302
+ }
303
+ // 处理单行注释 // 或 /** */
304
+ else if (
305
+ !inMultiLineComment &&
306
+ !inHtmlComment &&
307
+ trimLine.startsWith('//')
308
+ ) {
309
+ groups.push([index, index]);
310
+ }
311
+ });
312
+
313
+ return groups;
314
+ }
315
+
316
+ /**
317
+ * 获取代码中的 标签起始行,不包含script 中的内容,不包含style中的内容
318
+ * @param lines 源码按行分割后的字符串数组
319
+ * @returns 包含标签、脚本、样式和注释范围的对象
320
+ */
321
+ function getTagStartAndEndRow(lines: string[]): {
322
+ tagRanges: number[][];
323
+ scriptRanges: number[][];
324
+ styleRanges: number[][];
325
+ noteRanges: number[][];
326
+ } {
327
+ // 先找出 script 和 style 的内容区域
328
+ const scriptRanges = getScriptStartAndEndRow(lines);
329
+ const styleRanges = getStyleStartAndEndRow(lines);
330
+ const noteRanges = getNoteStartAndEndRow(lines);
331
+
332
+ // 合并并排序所有需要排除的区间
333
+ const excludeRanges = [...scriptRanges, ...styleRanges, ...noteRanges].sort(
334
+ (a, b) => a[0] - b[0],
335
+ );
336
+
337
+ const tagRanges: number[][] = [];
338
+
339
+ if (excludeRanges.length === 0) {
340
+ // 如果没有 script 或 style 块,则整个文件都是 html 区域
341
+ if (lines.length > 0) {
342
+ tagRanges.push([0, lines.length - 1]);
343
+ }
344
+ } else {
345
+ let currentStart = 0;
346
+
347
+ for (let i = 0; i < excludeRanges.length; i++) {
348
+ const [start, end] = excludeRanges[i];
349
+
350
+ // 检查当前起始点到这个排除区间的开始是否有内容
351
+ if (currentStart <= start - 1) {
352
+ tagRanges.push([currentStart, start - 1]);
353
+ }
354
+
355
+ // 更新下一个可能的起始点为排除区间之后
356
+ currentStart = end + 1;
357
+ }
358
+
359
+ // 检查最后一个排除区间结束后是否还有剩余内容
360
+ if (currentStart < lines.length) {
361
+ tagRanges.push([currentStart, lines.length - 1]);
362
+ }
363
+ }
364
+
365
+ return {
366
+ tagRanges,
367
+ scriptRanges,
368
+ styleRanges,
369
+ noteRanges,
370
+ };
371
+ }
372
+
373
+ /**
374
+ * 获取指定行号对应的代码块类型
375
+ *
376
+ * @param {number} index
377
+ * @param {{
378
+ * tagRanges: number[][];
379
+ * scriptRanges: number[][];
380
+ * styleRanges: number[][];
381
+ * }} {
382
+ * tagRanges,
383
+ * scriptRanges,
384
+ * styleRanges,
385
+ * }
386
+ * @return {*}
387
+ */
388
+ function getLineIndexType(
389
+ index: number,
390
+ {
391
+ tagRanges,
392
+ scriptRanges,
393
+ styleRanges,
394
+ noteRanges,
395
+ }: {
396
+ tagRanges: number[][];
397
+ scriptRanges: number[][];
398
+ styleRanges: number[][];
399
+ noteRanges: number[][];
400
+ },
401
+ ) {
402
+ // 检查是否在注释区间内
403
+ for (const [start, end] of noteRanges) {
404
+ if (index >= start && index <= end) {
405
+ return 'note';
406
+ }
407
+ }
408
+
409
+ // 检查是否在 script 区间内
410
+ for (const [start, end] of scriptRanges) {
411
+ if (index >= start && index <= end) {
412
+ return 'script';
413
+ }
414
+ }
415
+
416
+ // 检查是否在 style 区间内
417
+ for (const [start, end] of styleRanges) {
418
+ if (index >= start && index <= end) {
419
+ return 'style';
420
+ }
421
+ }
422
+
423
+ // 检查是否在 tag 区间内
424
+ for (const [start, end] of tagRanges) {
425
+ if (index >= start && index <= end) {
426
+ return 'tag';
427
+ }
428
+ }
429
+
430
+ return 'empty';
431
+ }
432
+
433
+ /**
434
+ * 获取代码中的单词信息
435
+ *
436
+ * TODO: 属性 , 方法
437
+ *
438
+ * @param {string[]} words
439
+ * @return {*} {Word[]}
440
+ */
441
+ function getWordsInfo(words: string[]): Word[] {
442
+ let quotation = '';
443
+ return words.map((w, index) => {
444
+ // 空格
445
+ const isSpace = w === ' ';
446
+ if (isSpace) {
447
+ return {
448
+ word: w,
449
+ type: 'space',
450
+ class: `${preClass}-space`,
451
+ };
452
+ }
453
+
454
+ // 箭头函数
455
+ const isArrow =
456
+ (w === '=' && words?.[index + 1] === '>') ||
457
+ (w === '>' && words?.[index - 1] === '=');
458
+ if (isArrow) {
459
+ return {
460
+ word: w,
461
+ type: 'keyword',
462
+ class: `${preClass}-keyword`,
463
+ };
464
+ }
465
+
466
+ // 括号
467
+ const isBracket = bracketList.includes(w);
468
+ if (isBracket) {
469
+ return {
470
+ word: w,
471
+ type: 'bracket',
472
+ class: `${preClass}-bracket`,
473
+ };
474
+ }
475
+
476
+ // 引号
477
+ const isQuotation = quotationList.includes(w);
478
+ if (isQuotation) {
479
+ quotation = quotation !== '' && quotation === w ? '' : w;
480
+ return {
481
+ word: w,
482
+ type: 'quotation',
483
+ class: `${preClass}-quotation`,
484
+ };
485
+ }
486
+
487
+ if (quotation != '') {
488
+ return {
489
+ word: w,
490
+ type: 'string',
491
+ class: `${preClass}-string`,
492
+ };
493
+ }
494
+
495
+ // 字符串
496
+ const isStr = quotationList.includes(words?.[index - 1]);
497
+ if (isStr) {
498
+ return {
499
+ word: w,
500
+ type: 'string',
501
+ class: `${preClass}-string`,
502
+ };
503
+ }
504
+
505
+ // 函数
506
+ const isFunction =
507
+ (words?.[index - 1] === ' ' && words?.[index - 2] === 'function') ||
508
+ words?.[index + 1] === '(';
509
+ if (isFunction) {
510
+ return {
511
+ word: w,
512
+ type: 'function',
513
+ class: `${preClass}-function`,
514
+ };
515
+ }
516
+
517
+ const preW = symbolList.includes(words?.[index - 1]);
518
+ const isAttribute = words?.[index + 1] === '.' && !preW;
519
+ if (isAttribute) {
520
+ return {
521
+ word: w,
522
+ type: 'attribute',
523
+ class: `${preClass}-attribute`,
524
+ };
525
+ }
526
+
527
+ // 操作符
528
+ const isOperator = operatorList.includes(w);
529
+ if (isOperator) {
530
+ return {
531
+ word: w,
532
+ type: 'operator',
533
+ class: `${preClass}-operator`,
534
+ };
535
+ }
536
+
537
+ // 符号
538
+ const isSymbol = symbolList.includes(w);
539
+ if (isSymbol) {
540
+ return {
541
+ word: w,
542
+ type: 'symbol',
543
+ class: `${preClass}-symbol`,
544
+ };
545
+ }
546
+
547
+ // 关键字
548
+ const isKeyword =
549
+ keywordList.includes(w) &&
550
+ (words?.[index + 1] === ' ' || words?.[index + 1] === ';');
551
+ if (isKeyword) {
552
+ return {
553
+ word: w,
554
+ type: 'keyword',
555
+ class: `${preClass}-keyword`,
556
+ };
557
+ }
558
+
559
+ // 其他
560
+ return {
561
+ word: w,
562
+ type: 'other',
563
+ class: `${preClass}-other`,
564
+ };
565
+ });
566
+ }
567
+
568
+ /**
569
+ * 按符号列表分割字符串
570
+ * @param lineTrim 需要分割的字符串
571
+ * @param symbols 符号列表
572
+ * @returns 分割后的词元数组
573
+ /**
574
+ *
575
+ *
576
+ * @param {string} lineTrim
577
+ * @param {string[]} symbols
578
+ * @return {*} {string[]}
579
+ */
580
+ function splitBySymbols(lineTrim: string, symbols: string[]): string[] {
581
+ if (!lineTrim) return [];
582
+
583
+ // 跳过注释行的处理
584
+ if (
585
+ lineTrim.startsWith('/*') ||
586
+ lineTrim.startsWith('*') ||
587
+ lineTrim.startsWith('//') ||
588
+ lineTrim.startsWith('<!--') ||
589
+ lineTrim.startsWith('-->') ||
590
+ lineTrim.length > 5000
591
+ ) {
592
+ return [lineTrim];
593
+ }
594
+
595
+ // 转义特殊字符并构建正则表达式
596
+ const escapedSymbols = symbols.map((s) =>
597
+ s.replace(/[.*+?^${}()|[\]\\@\$]/g, '\\$&'),
598
+ );
599
+ const regexPattern = `(${escapedSymbols.join('|')})`;
600
+ const regex = new RegExp(regexPattern, 'g');
601
+
602
+ // 使用正则表达式分割字符串并保留分隔符
603
+ const parts = lineTrim.split(regex);
604
+
605
+ // 过滤掉空字符串并返回结果
606
+ return parts.filter((part) => part !== '');
607
+ }
608
+
609
+ export function parseCode(code: string): LineInfo[] {
610
+ // 按行进行重新解析
611
+ const lines = code.split('\n');
612
+
613
+ const { tagRanges, scriptRanges, styleRanges, noteRanges } =
614
+ getTagStartAndEndRow(lines);
615
+
616
+ const parseLine = lines.map((line, index) => {
617
+ // 解析行之前的空格
618
+ const space =
619
+ line?.length < 500
620
+ ? (line.match(startSpaceReg)?.[1] || '')?.split('')
621
+ : [];
622
+ // 获取行类型
623
+
624
+ const type = getLineIndexType(index, {
625
+ tagRanges,
626
+ scriptRanges,
627
+ styleRanges,
628
+ noteRanges,
629
+ });
630
+
631
+ const lineTrim = line.trim();
632
+
633
+ // 按符号分割行内容
634
+ const segments = splitBySymbols(lineTrim, symbolList);
635
+
636
+ const words = getWordsInfo([...space, ...segments]);
637
+
638
+ const lineInfo: LineInfo = { type, words, class: `${preClass}-${type}` };
639
+ return lineInfo;
640
+ });
641
+
642
+ return parseLine;
643
+ }
@@ -59,6 +59,7 @@ function onClick(event: MouseEvent) {
59
59
  border: 1px solid var(--dev-tool-success-color);
60
60
  }
61
61
  .tag-error {
62
+ color: #fff;
62
63
  background-color: var(--dev-tool-error-color);
63
64
  border: 1px solid var(--dev-tool-error-color);
64
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-uni-dev-tool",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
5
5
  "keywords": [
6
6
  "vite",