vite-uni-dev-tool 1.0.0 → 1.2.0

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 (170) hide show
  1. package/README.md +54 -0
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +13 -0
  4. package/dist/const.d.ts.map +1 -1
  5. package/dist/const.js +1 -1
  6. package/dist/core-shared.d.ts +1 -1
  7. package/dist/core-shared.d.ts.map +1 -1
  8. package/dist/core-shared.js +1 -1
  9. package/dist/core.d.ts +10 -3
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +2 -2
  12. package/dist/i18n/locales/en.cjs +1 -1
  13. package/dist/i18n/locales/en.d.ts +86 -0
  14. package/dist/i18n/locales/en.d.ts.map +1 -1
  15. package/dist/i18n/locales/en.js +1 -1
  16. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  17. package/dist/i18n/locales/zh-Hans.d.ts +87 -1
  18. package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
  19. package/dist/i18n/locales/zh-Hans.js +1 -1
  20. package/dist/modules/devConsole/index.cjs +1 -1
  21. package/dist/modules/devConsole/index.js +3 -3
  22. package/dist/modules/devEvent/index.cjs +3 -3
  23. package/dist/modules/devEvent/index.d.ts +1 -0
  24. package/dist/modules/devEvent/index.d.ts.map +1 -1
  25. package/dist/modules/devEvent/index.js +3 -3
  26. package/dist/modules/devIntercept/index.cjs +14 -13
  27. package/dist/modules/devIntercept/index.d.ts +20 -1
  28. package/dist/modules/devIntercept/index.d.ts.map +1 -1
  29. package/dist/modules/devIntercept/index.js +14 -13
  30. package/dist/modules/devStore/index.cjs +1 -1
  31. package/dist/modules/devStore/index.d.ts +21 -0
  32. package/dist/modules/devStore/index.d.ts.map +1 -1
  33. package/dist/modules/devStore/index.js +1 -1
  34. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
  35. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -1
  36. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
  37. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  38. package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
  39. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -1
  40. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
  41. package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
  42. package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
  43. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -1
  44. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  45. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  46. package/dist/type.d.ts +50 -2
  47. package/dist/type.d.ts.map +1 -1
  48. package/dist/utils/language.cjs +1 -1
  49. package/dist/utils/language.d.ts.map +1 -1
  50. package/dist/utils/language.js +1 -1
  51. package/dist/utils/object.cjs +1 -1
  52. package/dist/utils/object.d.ts.map +1 -1
  53. package/dist/utils/object.js +1 -1
  54. package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -0
  55. package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -0
  56. package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -0
  57. package/dist/v3/{CaptureScreen → DevTool/components/CaptureScreen}/index.vue +4 -4
  58. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/ConsoleItem.vue +22 -16
  59. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/RunJSInput.vue +4 -6
  60. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/index.vue +21 -10
  61. package/dist/v3/{DevToolButton → DevTool/components/DevToolButton}/index.vue +7 -4
  62. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/DevToolOverlay.vue +17 -2
  63. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/const.ts +28 -5
  64. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/dataUtils.ts +1 -1
  65. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolData.ts +55 -6
  66. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolHandlers.ts +85 -5
  67. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolOverlay.ts +25 -8
  68. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.vue +67 -16
  69. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/ElEventItem.vue +3 -3
  70. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/index.vue +10 -13
  71. package/dist/v3/{Instance → DevTool/components/Instance}/index.vue +1 -1
  72. package/dist/v3/{Instance → DevTool/components/Instance}/transformTree.ts +1 -1
  73. package/dist/v3/{Instance → DevTool/components/Instance}/transformTreeCtx.ts +1 -1
  74. package/dist/v3/{InstanceDetail → DevTool/components/InstanceDetail}/index.vue +4 -4
  75. package/dist/v3/{JsonDetail → DevTool/components/JsonDetail}/index.vue +4 -4
  76. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCItem.vue +4 -5
  77. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCTool.vue +33 -57
  78. package/dist/v3/{NFCList → DevTool/components/NFCList}/index.vue +12 -16
  79. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptConfig.vue +20 -4
  80. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptItem.vue +3 -3
  81. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkDetail.vue +18 -27
  82. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkIntercept.vue +11 -16
  83. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkItem.vue +10 -14
  84. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkSend.vue +67 -34
  85. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/index.vue +8 -8
  86. package/dist/v3/{Performance → DevTool/components/Performance}/index.vue +7 -4
  87. package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceWidget.vue +12 -9
  88. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceChart.ts +1 -1
  89. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceData.ts +2 -2
  90. package/dist/v3/{PiniaList → DevTool/components/PiniaList}/index.vue +5 -6
  91. package/dist/v3/{RouteList → DevTool/components/RouteList}/index.vue +21 -24
  92. package/dist/v3/{RunJS → DevTool/components/RunJS}/index.vue +3 -3
  93. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/ScanCodeItem.vue +3 -4
  94. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/index.vue +12 -16
  95. package/dist/v3/{SettingList → DevTool/components/SettingList}/index.vue +68 -0
  96. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -0
  97. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingDevTool.vue +8 -4
  98. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingInfo.vue +47 -9
  99. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLanguage.vue +2 -2
  100. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLog.vue +2 -2
  101. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingNetwork.vue +3 -3
  102. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingTheme.vue +37 -7
  103. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/Line.vue +22 -11
  104. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/index.vue +8 -8
  105. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/parseCode.ts +136 -228
  106. package/dist/v3/{StorageList → DevTool/components/StorageList}/index.vue +7 -7
  107. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferDetail.vue +6 -6
  108. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferItem.vue +4 -4
  109. package/dist/v3/{TransferList → DevTool/components/TransferList}/index.vue +8 -8
  110. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/UniEventItem.vue +6 -7
  111. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/index.vue +6 -6
  112. package/dist/v3/{VuexList → DevTool/components/VuexList}/index.vue +3 -3
  113. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketDetail.vue +8 -8
  114. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketItem.vue +4 -4
  115. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/index.vue +8 -8
  116. package/dist/v3/DevTool/index.vue +179 -4
  117. package/dist/v3/{AppTransition → components/AppTransition}/index.vue +6 -0
  118. package/dist/v3/components/Barrage/BarrageItem.vue +137 -0
  119. package/dist/v3/components/Barrage/index.vue +202 -0
  120. package/dist/v3/components/DevErrorBoundary/index.vue +380 -0
  121. package/dist/v3/{DraggableContainer → components/DraggableContainer}/index.vue +1 -1
  122. package/dist/v3/{FilterInput → components/FilterInput}/index.vue +1 -1
  123. package/dist/v3/{JsonPretty → components/JsonPretty}/components/CheckController/index.vue +1 -1
  124. package/dist/v3/{JsonPretty → components/JsonPretty}/components/TreeNode/index.vue +11 -5
  125. package/dist/v3/{JsonPretty → components/JsonPretty}/index.vue +16 -13
  126. package/dist/v3/{JsonPretty → components/JsonPretty}/type.ts +1 -0
  127. package/dist/v3/{JsonPretty → components/JsonPretty}/utils/index.ts +1 -1
  128. package/dist/v3/{MovableContainer → components/MovableContainer}/index.vue +9 -5
  129. package/dist/v3/{Pick → components/Pick}/index.vue +1 -1
  130. package/dist/v3/{Tabs → components/Tabs}/index.vue +30 -4
  131. package/dist/v3/{VirtualList → components/VirtualList}/AutoSize.vue +1 -1
  132. package/dist/v3/{VirtualList → components/VirtualList}/index.vue +4 -0
  133. package/dist/v3/hooks/useBluetooth/index.ts +561 -0
  134. package/dist/v3/hooks/useRequest/index.ts +33 -20
  135. package/dist/v3/hooks/useWebsocket/README.md +79 -0
  136. package/dist/v3/hooks/useWebsocket/index.ts +253 -0
  137. package/dist/v3/styles/theme.css +17 -10
  138. package/package.json +67 -64
  139. package/dist/plugins/uniParseStock/index.d.ts +0 -10
  140. package/dist/plugins/uniParseStock/index.d.ts.map +0 -1
  141. /package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/staticTips.ts +0 -0
  142. /package/dist/v3/{DevToolTitle → DevTool/components/DevToolTitle}/index.vue +0 -0
  143. /package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.css +0 -0
  144. /package/dist/v3/{Instance → DevTool/components/Instance}/components/InstanceTreeNode.vue +0 -0
  145. /package/dist/v3/{Instance → DevTool/components/Instance}/flatten.ts +0 -0
  146. /package/dist/v3/{Instance → DevTool/components/Instance}/registry.ts +0 -0
  147. /package/dist/v3/{Instance → DevTool/components/Instance}/typing.d.ts +0 -0
  148. /package/dist/v3/{NFCList → DevTool/components/NFCList}/const.ts +0 -0
  149. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/const.ts +0 -0
  150. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/hooks/useNetworkForm.ts +0 -0
  151. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/utils.ts +0 -0
  152. /package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceMetrics.vue +0 -0
  153. /package/dist/v3/{SettingButton → DevTool/components/SettingButton}/index.vue +0 -0
  154. /package/dist/v3/{SettingList → DevTool/components/SettingList}/index.css +0 -0
  155. /package/dist/v3/{SettingList → DevTool/components/SettingList}/typing.d.ts +0 -0
  156. /package/dist/v3/{AutoSizer → components/AutoSizer}/index.vue +0 -0
  157. /package/dist/v3/{AutoSizer → components/AutoSizer}/index1.vue +0 -0
  158. /package/dist/v3/{AutoSizer → components/AutoSizer}/utils.ts +0 -0
  159. /package/dist/v3/{CircularButton → components/CircularButton}/index.vue +0 -0
  160. /package/dist/v3/{CustomSwiper → components/CustomSwiper}/CustomSwiperItem.vue +0 -0
  161. /package/dist/v3/{CustomSwiper → components/CustomSwiper}/index.vue +0 -0
  162. /package/dist/v3/{Empty → components/Empty}/empty.png +0 -0
  163. /package/dist/v3/{Empty → components/Empty}/index.vue +0 -0
  164. /package/dist/v3/{FilterSelect → components/FilterSelect}/index.vue +0 -0
  165. /package/dist/v3/{JsonPretty → components/JsonPretty}/components/Brackets/index.vue +0 -0
  166. /package/dist/v3/{JsonPretty → components/JsonPretty}/components/Carets/index.vue +0 -0
  167. /package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useClipboard.ts +0 -0
  168. /package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useError.ts +0 -0
  169. /package/dist/v3/{Tag → components/Tag}/index.vue +0 -0
  170. /package/dist/v3/{VirtualList → components/VirtualList}/readme.md +0 -0
@@ -1,49 +1,6 @@
1
- /** 行前空格匹配 */
2
- const startSpaceReg = /^(\s*)/;
3
-
4
- /** 括号 */
5
- const bracketList = ['<', '>', '(', ')', '{', '}', '[', ']'];
6
-
7
- /** 引号 */
8
- const quotationList = ["'", '"', '‘', '’', '`'];
9
-
10
1
  /** 操作符 */
11
2
  const operatorList = ['+', '-', '*', '/', '%', '=', '!', '&'];
12
3
 
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
- '^',
44
- '%',
45
- ];
46
-
47
4
  /** 关键字 */
48
5
  const keywordList = [
49
6
  // JavaScript 关键字
@@ -466,202 +423,137 @@ function getLineIndexType(
466
423
  }
467
424
 
468
425
  /**
469
- * 获取代码中的单词信息
470
- *
471
- * TODO: 属性 , 方法
472
- *
473
- * @param {string[]} words
474
- * @return {*} {Word[]}
426
+ * 将整行代码字符串分词,带有更精细的词法分析,大大减少DOM元素数量
475
427
  */
476
- function getWordsInfo(words: string[]): Word[] {
477
- let quotation = '';
478
- return words.map((w, index) => {
479
- // 空格
480
- const isSpace = w === ' ';
481
- if (isSpace) {
482
- return {
483
- word: w,
428
+ function tokenizeLine(lineStr: string): Word[] {
429
+ let remain = lineStr;
430
+ const words: Word[] = [];
431
+ let prevWord = '';
432
+
433
+ while (remain.length > 0) {
434
+ let match;
435
+
436
+ // Space
437
+ match = remain.match(/^(\s+)/);
438
+ if (match) {
439
+ // Use different class for inline spaces to prevent indent lines appearing in middle of code
440
+ words.push({
441
+ word: match[0],
484
442
  type: 'space',
485
- class: `${preClass}-space`,
486
- };
487
- }
488
-
489
- // 箭头函数
490
- const isArrow =
491
- (w === '=' && words?.[index + 1] === '>') ||
492
- (w === '>' && words?.[index - 1] === '=');
493
- if (isArrow) {
494
- return {
495
- word: w,
496
- type: 'keyword',
497
- class: `${preClass}-keyword`,
498
- };
443
+ class: `${preClass}-space-inline`,
444
+ });
445
+ remain = remain.slice(match[0].length);
446
+ continue;
499
447
  }
500
448
 
501
- // 括号
502
- const isBracket = bracketList.includes(w);
503
- if (isBracket) {
504
- return {
505
- word: w,
506
- type: 'bracket',
507
- class: `${preClass}-bracket`,
508
- };
449
+ // Comment (inline)
450
+ match = remain.match(/^(\/\/.*)/);
451
+ if (match) {
452
+ words.push({ word: match[0], type: 'symbol', class: `${preClass}-note` });
453
+ remain = remain.slice(match[0].length);
454
+ continue;
509
455
  }
510
456
 
511
- // 引号
512
- const isQuotation = quotationList.includes(w);
513
- if (isQuotation) {
514
- quotation = quotation !== '' && quotation === w ? '' : w;
515
- return {
516
- word: w,
517
- type: 'quotation',
518
- class: `${preClass}-quotation`,
519
- };
457
+ // HTML Comment
458
+ match = remain.match(/^(<!--.*?-->|<!--.*|.*-->)/);
459
+ if (match) {
460
+ words.push({ word: match[0], type: 'symbol', class: `${preClass}-note` });
461
+ remain = remain.slice(match[0].length);
462
+ continue;
520
463
  }
521
464
 
522
- if (quotation != '') {
523
- return {
524
- word: w,
465
+ // Strings (with escapes)
466
+ match = remain.match(
467
+ /^("[^"\\]*(\\.[^"\\]*)*"|'[^'\\]*(\\.[^'\\]*)*'|`[^`\\]*(\\.[^`\\]*)*`)/,
468
+ );
469
+ if (match) {
470
+ words.push({
471
+ word: match[0],
525
472
  type: 'string',
526
473
  class: `${preClass}-string`,
527
- };
474
+ });
475
+ remain = remain.slice(match[0].length);
476
+ prevWord = '""';
477
+ continue;
528
478
  }
529
479
 
530
- // 字符串 (处理引号后的第一个词)
531
- const isStr = quotationList.includes(words?.[index - 1]);
532
- if (isStr) {
533
- return {
534
- word: w,
535
- type: 'string',
536
- class: `${preClass}-string`,
537
- };
480
+ // Identifiers & Keywords
481
+ match = remain.match(/^[a-zA-Z_$@][a-zA-Z0-9_$-]*/);
482
+ if (match) {
483
+ const word = match[0];
484
+ let type: Word['type'] = 'other';
485
+ let cls = `${preClass}-other`;
486
+
487
+ const nextCharMatch = remain.slice(word.length).match(/^\s*(.)/);
488
+ const nextChar = nextCharMatch ? nextCharMatch[1] : '';
489
+
490
+ if (keywordList.includes(word)) {
491
+ type = 'keyword';
492
+ cls = `${preClass}-keyword`;
493
+ } else if (builtInList.includes(word)) {
494
+ type = 'builtin';
495
+ cls = `${preClass}-builtin`;
496
+ } else if (prevWord === '.') {
497
+ type = 'attribute';
498
+ cls = `${preClass}-attribute`;
499
+ } else if (prevWord === '<' || prevWord === '</') {
500
+ type = 'keyword';
501
+ cls = `${preClass}-keyword`; // Tag name
502
+ } else if (nextChar === '(') {
503
+ type = 'function';
504
+ cls = `${preClass}-function`;
505
+ } else if (word.startsWith('v-') || word.startsWith('@')) {
506
+ type = 'keyword';
507
+ cls = `${preClass}-keyword`; // Vue directives
508
+ }
509
+
510
+ words.push({ word, type, class: cls });
511
+ prevWord = word;
512
+ remain = remain.slice(word.length);
513
+ continue;
538
514
  }
539
515
 
540
- // 数字
541
- const isNumber =
542
- /^\d+(\.\d+)?(e\d+)?$/i.test(w) || /^0x[0-9a-f]+$/i.test(w);
543
- if (isNumber) {
544
- return {
545
- word: w,
516
+ // Numbers
517
+ match = remain.match(
518
+ /^(0[xX][0-9a-fA-F]+|\d*\.\d+([eE][+-]?\d+)?|\d+([eE][+-]?\d+)?|\d+n)/,
519
+ );
520
+ if (match) {
521
+ words.push({
522
+ word: match[0],
546
523
  type: 'number',
547
524
  class: `${preClass}-number`,
548
- };
549
- }
550
-
551
- // 函数
552
- const isFunc =
553
- (words?.[index - 1] === ' ' && words?.[index - 2] === 'function') ||
554
- words?.[index + 1] === '(' ||
555
- (words?.[index + 1] === ' ' && words?.[index + 2] === '(');
556
- if (isFunc && !keywordList.includes(w)) {
557
- return {
558
- word: w,
559
- type: 'function',
560
- class: `${preClass}-function`,
561
- };
562
- }
563
-
564
- // 属性提取
565
- const preW = symbolList.includes(words?.[index - 1]);
566
- const isAttribute =
567
- (words?.[index + 1] === '.' || (words?.[index - 1] === '.' && !preW)) &&
568
- !isNumber;
569
- if (isAttribute) {
570
- return {
571
- word: w,
572
- type: 'attribute',
573
- class: `${preClass}-attribute`,
574
- };
575
- }
576
-
577
- // 关键字
578
- const isKeyword = keywordList.includes(w);
579
- if (isKeyword) {
580
- return {
581
- word: w,
582
- type: 'keyword',
583
- class: `${preClass}-keyword`,
584
- };
585
- }
586
-
587
- // 内置对象
588
- const isBuiltin = builtInList.includes(w);
589
- if (isBuiltin) {
590
- return {
591
- word: w,
592
- type: 'builtin',
593
- class: `${preClass}-builtin`,
594
- };
525
+ });
526
+ remain = remain.slice(match[0].length);
527
+ prevWord = '0';
528
+ continue;
595
529
  }
596
530
 
597
- // 操作符
598
- const isOperator = operatorList.includes(w);
599
- if (isOperator) {
600
- return {
601
- word: w,
602
- type: 'operator',
603
- class: `${preClass}-operator`,
604
- };
605
- }
531
+ // Multi-char symbols and Operators
532
+ match = remain.match(
533
+ /^(===|!==|==|!=|>=|<=|=>|\+\+|--|\+=|-=|\*=|\/=|\|\||&&|\?\.|<\/?|\/>|[{}()[\].,;:?+*/%&|^!=<>~#\\@])/,
534
+ );
535
+ if (match) {
536
+ const word = match[0];
537
+ let cls = `${preClass}-symbol`;
538
+ if (['<', '>', '(', ')', '{', '}', '[', ']'].includes(word[0])) {
539
+ cls = `${preClass}-bracket`;
540
+ } else if (operatorList.includes(word[0]) || word.length > 1) {
541
+ cls = `${preClass}-operator`;
542
+ }
606
543
 
607
- // 符号
608
- const isSymbol = symbolList.includes(w);
609
- if (isSymbol) {
610
- return {
611
- word: w,
612
- type: 'symbol',
613
- class: `${preClass}-symbol`,
614
- };
544
+ words.push({ word, type: 'symbol', class: cls });
545
+ prevWord = word;
546
+ remain = remain.slice(word.length);
547
+ continue;
615
548
  }
616
549
 
617
- // 其他
618
- return {
619
- word: w,
620
- type: 'other',
621
- class: `${preClass}-other`,
622
- };
623
- });
624
- }
625
-
626
- /**
627
- * 按符号列表分割字符串
628
- * @param lineTrim 需要分割的字符串
629
- * @param symbols 符号列表
630
- * @returns 分割后的词元数组
631
- /**
632
- *
633
- *
634
- * @param {string} lineTrim
635
- * @param {string[]} symbols
636
- * @return {*} {string[]}
637
- */
638
- function splitBySymbols(lineTrim: string, symbols: string[]): string[] {
639
- if (!lineTrim) return [];
640
-
641
- // 跳过注释行的处理
642
- if (
643
- lineTrim.startsWith('/*') ||
644
- lineTrim.startsWith('*') ||
645
- lineTrim.startsWith('//') ||
646
- lineTrim.startsWith('<!--') ||
647
- lineTrim.startsWith('-->') ||
648
- lineTrim.length > 5000
649
- ) {
650
- return [lineTrim];
550
+ // Fallback one char
551
+ const word = remain[0];
552
+ words.push({ word, type: 'other', class: `${preClass}-other` });
553
+ prevWord = word;
554
+ remain = remain.slice(1);
651
555
  }
652
-
653
- // 转义特殊字符并构建正则表达式
654
- const escapedSymbols = symbols.map((s) =>
655
- s.replace(/[.*+?^${}()|[\]\\@$]/g, '\\$&'),
656
- );
657
- const regexPattern = `(${escapedSymbols.join('|')})`;
658
- const regex = new RegExp(regexPattern, 'g');
659
-
660
- // 使用正则表达式分割字符串并保留分隔符
661
- const parts = lineTrim.split(regex);
662
-
663
- // 过滤掉空字符串并返回结果
664
- return parts.filter((part) => part !== '');
556
+ return words;
665
557
  }
666
558
 
667
559
  export function parseCode(code: string): LineInfo[] {
@@ -672,13 +564,7 @@ export function parseCode(code: string): LineInfo[] {
672
564
  getTagStartAndEndRow(lines);
673
565
 
674
566
  const parseLine = lines.map((line, index) => {
675
- // 解析行之前的空格
676
- const space =
677
- line?.length < 500
678
- ? (line.match(startSpaceReg)?.[1] || '')?.split('')
679
- : [];
680
567
  // 获取行类型
681
-
682
568
  const type = getLineIndexType(index, {
683
569
  tagRanges,
684
570
  scriptRanges,
@@ -686,12 +572,34 @@ export function parseCode(code: string): LineInfo[] {
686
572
  noteRanges,
687
573
  });
688
574
 
689
- const lineTrim = line.trim();
690
-
691
- // 按符号分割行内容
692
- const segments = splitBySymbols(lineTrim, symbolList);
575
+ // 解析行之前的空格,为了保证准确的缩进格式
576
+ const spaceMatch = line.match(/^(\s*)/);
577
+ const spacePrefix = spaceMatch ? spaceMatch[0] : '';
578
+ const lineTrim = line.slice(spacePrefix.length);
579
+
580
+ const words: Word[] = [];
581
+ if (spacePrefix) {
582
+ // Chunk spaces by 2 to add indentation guide lines
583
+ for (let i = 0; i < spacePrefix.length; i += 2) {
584
+ words.push({
585
+ word: spacePrefix.slice(i, i + 2),
586
+ type: 'space',
587
+ class: `${preClass}-space`,
588
+ });
589
+ }
590
+ }
693
591
 
694
- const words = getWordsInfo([...space, ...segments]);
592
+ if (type === 'note') {
593
+ if (lineTrim) {
594
+ words.push({
595
+ word: lineTrim,
596
+ type: 'symbol',
597
+ class: `${preClass}-note`,
598
+ });
599
+ }
600
+ } else {
601
+ words.push(...tokenizeLine(lineTrim));
602
+ }
695
603
 
696
604
  const lineInfo: LineInfo = { type, words, class: `${preClass}-${type}` };
697
605
  return lineInfo;
@@ -46,14 +46,14 @@
46
46
  </view>
47
47
  </template>
48
48
  <script lang="ts" setup>
49
- import Tag from '../Tag/index.vue';
50
- import JsonPretty from '../JsonPretty/index.vue';
51
- import Empty from '../Empty/index.vue';
52
- import CircularButton from '../CircularButton/index.vue';
53
- import FilterInput from '../FilterInput/index.vue';
54
- import type { DevTool } from '../../type';
49
+ import Tag from '../../../components/Tag/index.vue';
50
+ import JsonPretty from '../../../components/JsonPretty/index.vue';
51
+ import Empty from '../../../components/Empty/index.vue';
52
+ import CircularButton from '../../../components/CircularButton/index.vue';
53
+ import FilterInput from '../../../components/FilterInput/index.vue';
54
+ import type { DevTool } from '../../../../type';
55
55
  import DevToolTitle from '../DevToolTitle/index.vue';
56
- import { useI18n } from '../../i18n';
56
+ import { useI18n } from '../../../../i18n';
57
57
  import { computed } from 'vue';
58
58
 
59
59
  const { t } = useI18n();
@@ -104,13 +104,13 @@
104
104
  </template>
105
105
  <script lang="ts" setup>
106
106
  import { ref, computed } from 'vue';
107
- import JsonPretty from '../JsonPretty/index.vue';
108
- import Tag from '../Tag/index.vue';
109
- import Empty from '../Empty/index.vue';
110
- import CircularButton from '../CircularButton/index.vue';
107
+ import JsonPretty from '../../../components/JsonPretty/index.vue';
108
+ import Tag from '../../../components/Tag/index.vue';
109
+ import Empty from '../../../components/Empty/index.vue';
110
+ import CircularButton from '../../../components/CircularButton/index.vue';
111
111
  import DevToolTitle from '../DevToolTitle/index.vue';
112
- import type { DevTool } from '../../type';
113
- import { useI18n } from '../../i18n';
112
+ import type { DevTool } from '../../../../type';
113
+ import { useI18n } from '../../../../i18n';
114
114
 
115
115
  const { t } = useI18n();
116
116
  const props = defineProps<{
@@ -54,10 +54,10 @@
54
54
 
55
55
  <script lang="ts" setup>
56
56
  import { computed } from 'vue';
57
- import Tag from '../Tag/index.vue';
58
- import { formatDate, isMockWX } from '../../utils';
59
- import type { DevTool } from '../../type';
60
- import { useI18n } from '../../i18n';
57
+ import Tag from '../../../components/Tag/index.vue';
58
+ import { formatDate, isMockWX } from '../../../../utils';
59
+ import type { DevTool } from '../../../../type';
60
+ import { useI18n } from '../../../../i18n';
61
61
 
62
62
  const { t } = useI18n();
63
63
  const props = defineProps<{
@@ -56,16 +56,16 @@
56
56
  </template>
57
57
  <script lang="ts" setup>
58
58
  import { computed } from 'vue';
59
- import Tag from '../Tag/index.vue';
59
+ import Tag from '../../../components/Tag/index.vue';
60
60
  import TransferItem from './TransferItem.vue';
61
- import Empty from '../Empty/index.vue';
62
- import FilterInput from '../FilterInput/index.vue';
63
- import Pick from '../Pick/index.vue';
64
- import type { DevTool } from '../../type';
65
- import VirtualList from '../VirtualList/index.vue';
66
- import AutoSize from '../VirtualList/AutoSize.vue';
61
+ import Empty from '../../../components/Empty/index.vue';
62
+ import FilterInput from '../../../components/FilterInput/index.vue';
63
+ import Pick from '../../../components/Pick/index.vue';
64
+ import type { DevTool } from '../../../../type';
65
+ import VirtualList from '../../../components/VirtualList/index.vue';
66
+ import AutoSize from '../../../components/VirtualList/AutoSize.vue';
67
67
  import DevToolTitle from '../DevToolTitle/index.vue';
68
- import { useI18n } from '../../i18n';
68
+ import { useI18n } from '../../../../i18n';
69
69
 
70
70
  const { t } = useI18n();
71
71
 
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view class="uni-event-item">
3
- <view class="uni-event-item-row"> {{ eventItem.eventName }} </view>
3
+ <view class="uni-event-item-row">{{ eventItem.eventName }}</view>
4
4
  <view class="uni-event-item-row">
5
5
  <Tag mode="info" v-if="eventItem.type == 'on'">
6
6
  {{ eventItem.type }}
@@ -14,22 +14,21 @@
14
14
  <Tag mode="error" v-if="eventItem.type == 'off'">
15
15
  {{ eventItem.type }}
16
16
  </Tag>
17
- <view class="uni-event-item-right"> {{ eventItem.timer }}</view>
17
+ <view class="uni-event-item-right">{{ eventItem.timer }}</view>
18
18
  </view>
19
19
 
20
20
  <view
21
21
  :class="`uni-event-item-right ${isUseDevSource ? 'link' : ''}`"
22
- @click="emit('openCode', eventItem.stack)"
23
- >
22
+ @click="emit('openCode', eventItem.stack)">
24
23
  {{ eventItem.stack }}
25
24
  </view>
26
25
  </view>
27
26
  </template>
28
27
  <script lang="ts" setup>
29
- import Tag from '../Tag/index.vue';
30
- import type { DevTool } from '../../type';
28
+ import Tag from '../../../components/Tag/index.vue';
29
+ import type { DevTool } from '../../../../type';
31
30
  import { computed } from 'vue';
32
- import { isMockWX } from '../../utils';
31
+ import { isMockWX } from '../../../../utils';
33
32
 
34
33
  const props = defineProps<{
35
34
  eventItem: DevTool.UniEventItem;
@@ -84,12 +84,12 @@
84
84
  <script lang="ts" setup>
85
85
  import DevToolTitle from '../DevToolTitle/index.vue';
86
86
  import UniEventItem from './UniEventItem.vue';
87
- import Tag from '../Tag/index.vue';
88
- import Empty from '../Empty/index.vue';
89
- import VirtualList from '../VirtualList/index.vue';
90
- import AutoSize from '../VirtualList/AutoSize.vue';
91
- import type { DevTool } from '../../type';
92
- import { useI18n } from '../../i18n';
87
+ import Tag from '../../../components/Tag/index.vue';
88
+ import Empty from '../../../components/Empty/index.vue';
89
+ import VirtualList from '../../../components/VirtualList/index.vue';
90
+ import AutoSize from '../../../components/VirtualList/AutoSize.vue';
91
+ import type { DevTool } from '../../../../type';
92
+ import { useI18n } from '../../../../i18n';
93
93
 
94
94
  const { t } = useI18n();
95
95
 
@@ -23,10 +23,10 @@
23
23
  </template>
24
24
  <script lang="ts" setup>
25
25
  import { computed } from 'vue';
26
- import JsonPretty from '../JsonPretty/index.vue';
27
- import Empty from '../Empty/index.vue';
26
+ import JsonPretty from '../../../components/JsonPretty/index.vue';
27
+ import Empty from '../../../components/Empty/index.vue';
28
28
  import DevToolTitle from '../DevToolTitle/index.vue';
29
- import { useI18n } from '../../i18n';
29
+ import { useI18n } from '../../../../i18n';
30
30
 
31
31
  const { t } = useI18n();
32
32
  const props = defineProps<{
@@ -114,16 +114,16 @@
114
114
  </template>
115
115
  <script setup lang="ts">
116
116
  import { ref, computed, watch } from 'vue';
117
- import Tag from '../Tag/index.vue';
118
- import CircularButton from '../CircularButton/index.vue';
117
+ import Tag from '../../../components/Tag/index.vue';
118
+ import CircularButton from '../../../components/CircularButton/index.vue';
119
119
  import DevToolTitle from '../DevToolTitle/index.vue';
120
- import Empty from '../Empty/index.vue';
121
- import { formatDate } from '../../utils/index';
122
- import type { DevTool } from '../../type';
123
- import { useI18n } from '../../i18n';
120
+ import Empty from '../../../components/Empty/index.vue';
121
+ import { formatDate } from '../../../../utils/index';
122
+ import type { DevTool } from '../../../../type';
123
+ import { useI18n } from '../../../../i18n';
124
124
  import SettingButton from '../SettingButton/index.vue';
125
- import VirtualList from '../VirtualList/index.vue';
126
- import AutoSize from '../VirtualList/AutoSize.vue';
125
+ import VirtualList from '../../../components/VirtualList/index.vue';
126
+ import AutoSize from '../../../components/VirtualList/AutoSize.vue';
127
127
 
128
128
  const { t } = useI18n();
129
129
 
@@ -37,10 +37,10 @@
37
37
  </view>
38
38
  </template>
39
39
  <script lang="ts" setup>
40
- import Tag from '../Tag/index.vue';
41
- import { formatDate } from '../../utils';
42
- import type { DevTool } from '../../type';
43
- import { useI18n } from '../../i18n';
40
+ import Tag from '../../../components/Tag/index.vue';
41
+ import { formatDate } from '../../../../utils';
42
+ import type { DevTool } from '../../../../type';
43
+ import { useI18n } from '../../../../i18n';
44
44
 
45
45
  const { t } = useI18n();
46
46
 
@@ -43,15 +43,15 @@
43
43
  <script lang="ts" setup>
44
44
  import { computed } from 'vue';
45
45
  import WebSocketItem from './WebSocketItem.vue';
46
- import Tag from '../Tag/index.vue';
47
- import Empty from '../Empty/index.vue';
48
- import FilterInput from '../FilterInput/index.vue';
49
- import Pick from '../Pick/index.vue'; // Changed from FilterSelect to Pick
50
- import type { DevTool } from '../../type';
51
- import VirtualList from '../VirtualList/index.vue';
52
- import AutoSize from '../VirtualList/AutoSize.vue';
46
+ import Tag from '../../../components/Tag/index.vue';
47
+ import Empty from '../../../components/Empty/index.vue';
48
+ import FilterInput from '../../../components/FilterInput/index.vue';
49
+ import Pick from '../../../components/Pick/index.vue'; // Changed from FilterSelect to Pick
50
+ import type { DevTool } from '../../../../type';
51
+ import VirtualList from '../../../components/VirtualList/index.vue';
52
+ import AutoSize from '../../../components/VirtualList/AutoSize.vue';
53
53
  import DevToolTitle from '../DevToolTitle/index.vue';
54
- import { useI18n } from '../../i18n';
54
+ import { useI18n } from '../../../../i18n';
55
55
 
56
56
  const { t } = useI18n();
57
57