@markuplint/parser-utils 4.7.1 → 4.8.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.
package/CHANGELOG.md CHANGED
@@ -3,16 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [4.7.1](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.7.0...@markuplint/parser-utils@4.7.1) (2024-10-27)
6
+ # [4.8.0](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.7.2...@markuplint/parser-utils@4.8.0) (2024-10-31)
7
7
 
8
+ ### Features
8
9
 
9
- ### Performance Improvements
10
+ - **parser-utils:** add filter option to `nodeTreeDebugView` ([8c3d618](https://github.com/markuplint/markuplint/commit/8c3d618ef50902b379c50c7b43b13d242dfe3b2b))
10
11
 
11
- * **parser-utils:** adjusted siblings correction timing to reduce exponential complexity ([676357c](https://github.com/markuplint/markuplint/commit/676357c438df7545f472787c9032463f9fdba515))
12
+ ## [4.7.2](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.7.1...@markuplint/parser-utils@4.7.2) (2024-10-28)
12
13
 
14
+ **Note:** Version bump only for package @markuplint/parser-utils
13
15
 
16
+ ## [4.7.1](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.7.0...@markuplint/parser-utils@4.7.1) (2024-10-27)
14
17
 
18
+ ### Performance Improvements
15
19
 
20
+ - **parser-utils:** adjusted siblings correction timing to reduce exponential complexity ([676357c](https://github.com/markuplint/markuplint/commit/676357c438df7545f472787c9032463f9fdba515))
16
21
 
17
22
  # [4.7.0](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.8...@markuplint/parser-utils@4.7.0) (2024-10-15)
18
23
 
package/lib/debugger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { MLASTAttr, MLASTNode } from '@markuplint/ml-ast';
2
2
  export declare function nodeListToDebugMaps(nodeList: readonly (MLASTNode | null)[], withAttr?: boolean): string[];
3
3
  export declare function attributesToDebugMaps(attributes: readonly MLASTAttr[]): string[][];
4
- export declare function nodeTreeDebugView(nodeTree: readonly MLASTNode[]): (string | undefined)[];
4
+ export declare function nodeTreeDebugView(nodeTree: readonly MLASTNode[], idFilter?: boolean): (string | undefined)[];
package/lib/debugger.js CHANGED
@@ -36,19 +36,20 @@ export function attributesToDebugMaps(attributes) {
36
36
  return r;
37
37
  });
38
38
  }
39
- export function nodeTreeDebugView(nodeTree) {
39
+ export function nodeTreeDebugView(nodeTree, idFilter = false) {
40
+ const filter = idFilter ? uuidFilter : (id) => id;
40
41
  return nodeTree
41
42
  .map((n, i) => {
42
43
  const lines = [];
43
44
  if (n.type === 'attr' || n.type === 'spread') {
44
45
  return;
45
46
  }
46
- lines.push(`${i.toString().padStart(3, '0')}: [${n.uuid.slice(0, 8)}] ${' '.repeat(Math.max(n.depth, 0))}${n.type === 'endtag' ? '/' : ''}${n.nodeName}(${n.uuid.slice(0, 8)})${n.type === 'starttag' && n.isGhost ? '[👻]' : ''}${n.type === 'starttag'
47
- ? ` => ${n.pairNode ? `/${n.pairNode.nodeName}(${n.pairNode.uuid.slice(0, 8)})` : '💀'}`
47
+ lines.push(`${i.toString().padStart(3, '0')}: [${filter(n.uuid)}] ${' '.repeat(Math.max(n.depth, 0))}${n.type === 'endtag' ? '/' : ''}${n.nodeName}(${filter(n.uuid)})${n.type === 'starttag' && n.isGhost ? '[👻]' : ''}${n.type === 'starttag'
48
+ ? ` => ${n.pairNode ? `/${n.pairNode.nodeName}(${filter(n.pairNode.uuid)})` : '💀'}`
48
49
  : ''}`);
49
50
  if (n.type === 'starttag' || n.type === 'psblock') {
50
51
  for (const c of n.childNodes ?? []) {
51
- lines.push(`${' '.repeat(15)} ${' '.repeat(Math.max(n.depth, 0))}┗━ ${c.type === 'endtag' ? '/' : ''}${c.nodeName}(${c.uuid.slice(0, 8)})`);
52
+ lines.push(`${' '.repeat(15)} ${' '.repeat(Math.max(n.depth, 0))}┗━ ${c.type === 'endtag' ? '/' : ''}${c.nodeName}(${filter(c.uuid)})`);
52
53
  }
53
54
  }
54
55
  return lines;
@@ -67,3 +68,13 @@ function tokenDebug(n, type = '') {
67
68
  function visibleWhiteSpace(chars) {
68
69
  return chars.replaceAll('\n', '⏎').replaceAll('\t', '→').replaceAll(/\s/g, '␣');
69
70
  }
71
+ const uuidFilterMap = new Map();
72
+ let increment = 0;
73
+ function uuidFilter(uuid) {
74
+ if (!uuidFilterMap.has(uuid)) {
75
+ const filteredId = increment.toString(16).padStart(4, '0');
76
+ increment++;
77
+ uuidFilterMap.set(uuid, filteredId);
78
+ }
79
+ return uuidFilterMap.get(uuid);
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "4.7.1",
3
+ "version": "4.8.0",
4
4
  "description": "Utility module for markuplint parser plugin",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -28,17 +28,17 @@
28
28
  "clean": "tsc --build --clean"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/ml-ast": "4.4.7",
32
- "@markuplint/ml-spec": "4.8.0",
33
- "@markuplint/types": "4.6.3",
31
+ "@markuplint/ml-ast": "4.4.8",
32
+ "@markuplint/ml-spec": "4.8.2",
33
+ "@markuplint/types": "4.6.4",
34
34
  "@types/uuid": "10.0.0",
35
35
  "debug": "4.3.7",
36
- "espree": "10.2.0",
36
+ "espree": "10.3.0",
37
37
  "type-fest": "4.26.1",
38
- "uuid": "10.0.0"
38
+ "uuid": "11.0.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@typescript-eslint/typescript-estree": "8.11.0"
41
+ "@typescript-eslint/typescript-estree": "8.12.2"
42
42
  },
43
- "gitHead": "fab5b494f0bdc491aa83cb2c8722738d557fbefd"
43
+ "gitHead": "c35e0beb5e14093a41cee7634221dbe7f7d577f9"
44
44
  }