@markuplint/ml-core 4.13.2 → 5.0.0-alpha.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 (92) hide show
  1. package/ARCHITECTURE.ja.md +524 -0
  2. package/ARCHITECTURE.md +524 -0
  3. package/CHANGELOG.md +52 -2
  4. package/README.md +5 -0
  5. package/SKILL.md +61 -0
  6. package/docs/linting-pipeline.ja.md +307 -0
  7. package/docs/linting-pipeline.md +307 -0
  8. package/docs/maintenance.ja.md +210 -0
  9. package/docs/maintenance.md +210 -0
  10. package/docs/ml-dom/attr.ja.md +103 -0
  11. package/docs/ml-dom/attr.md +103 -0
  12. package/docs/ml-dom/block.ja.md +272 -0
  13. package/docs/ml-dom/block.md +272 -0
  14. package/docs/ml-dom/document.ja.md +141 -0
  15. package/docs/ml-dom/document.md +141 -0
  16. package/docs/ml-dom/element.ja.md +176 -0
  17. package/docs/ml-dom/element.md +176 -0
  18. package/docs/ml-dom/helpers.ja.md +203 -0
  19. package/docs/ml-dom/helpers.md +203 -0
  20. package/docs/ml-dom/node.ja.md +199 -0
  21. package/docs/ml-dom/node.md +199 -0
  22. package/docs/ml-dom/others.ja.md +120 -0
  23. package/docs/ml-dom/others.md +120 -0
  24. package/docs/ml-dom/overview.ja.md +102 -0
  25. package/docs/ml-dom/overview.md +102 -0
  26. package/docs/ml-dom/pretender.ja.md +269 -0
  27. package/docs/ml-dom/pretender.md +269 -0
  28. package/docs/ml-dom/rule-mapping.ja.md +371 -0
  29. package/docs/ml-dom/rule-mapping.md +371 -0
  30. package/docs/ml-dom.ja.md +18 -0
  31. package/docs/ml-dom.md +18 -0
  32. package/docs/rule-system.ja.md +287 -0
  33. package/docs/rule-system.md +287 -0
  34. package/lib/convert-ruleset.d.ts +7 -0
  35. package/lib/convert-ruleset.js +7 -0
  36. package/lib/debug.d.ts +4 -0
  37. package/lib/debug.js +4 -0
  38. package/lib/index.d.ts +4 -3
  39. package/lib/index.js +1 -1
  40. package/lib/ml-core.d.ts +37 -1
  41. package/lib/ml-core.js +171 -82
  42. package/lib/ml-dom/helper/accname.d.ts +8 -0
  43. package/lib/ml-dom/helper/accname.js +71 -55
  44. package/lib/ml-dom/helper/create-node.js +1 -0
  45. package/lib/ml-dom/helper/get-indent.d.ts +4 -1
  46. package/lib/ml-dom/helper/get-indent.js +21 -30
  47. package/lib/ml-dom/node/attr.d.ts +65 -4
  48. package/lib/ml-dom/node/attr.js +151 -53
  49. package/lib/ml-dom/node/block.d.ts +23 -2
  50. package/lib/ml-dom/node/block.js +24 -1
  51. package/lib/ml-dom/node/child-node.d.ts +9 -0
  52. package/lib/ml-dom/node/child-node.js +9 -0
  53. package/lib/ml-dom/node/comment.d.ts +7 -0
  54. package/lib/ml-dom/node/comment.js +7 -0
  55. package/lib/ml-dom/node/document-fragment.d.ts +8 -0
  56. package/lib/ml-dom/node/document-fragment.js +8 -0
  57. package/lib/ml-dom/node/document-type.d.ts +22 -0
  58. package/lib/ml-dom/node/document-type.js +25 -0
  59. package/lib/ml-dom/node/document.d.ts +88 -7
  60. package/lib/ml-dom/node/document.js +128 -32
  61. package/lib/ml-dom/node/dom-token-list.js +17 -30
  62. package/lib/ml-dom/node/element-close-tag.js +1 -0
  63. package/lib/ml-dom/node/element.d.ts +151 -5
  64. package/lib/ml-dom/node/element.js +242 -50
  65. package/lib/ml-dom/node/node-store.js +6 -15
  66. package/lib/ml-dom/node/node.d.ts +19 -1
  67. package/lib/ml-dom/node/node.js +175 -166
  68. package/lib/ml-dom/node/parent-node.js +14 -30
  69. package/lib/ml-dom/node/rule-mapper.js +7 -20
  70. package/lib/ml-dom/node/text.d.ts +19 -0
  71. package/lib/ml-dom/node/text.js +21 -0
  72. package/lib/ml-dom/node/types.d.ts +68 -0
  73. package/lib/ml-dom/token/token.d.ts +42 -0
  74. package/lib/ml-dom/token/token.js +59 -39
  75. package/lib/ml-rule/create-rule.d.ts +17 -1
  76. package/lib/ml-rule/ml-rule-context.js +7 -11
  77. package/lib/ml-rule/ml-rule.d.ts +66 -1
  78. package/lib/ml-rule/ml-rule.js +95 -25
  79. package/lib/ml-rule/types.d.ts +41 -0
  80. package/lib/plugin/plugin.d.ts +8 -0
  81. package/lib/plugin/plugin.js +8 -0
  82. package/lib/plugin/types.d.ts +21 -0
  83. package/lib/ruleset/index.d.ts +10 -0
  84. package/lib/ruleset/index.js +13 -0
  85. package/lib/test/index.d.ts +42 -1
  86. package/lib/test/index.js +39 -2
  87. package/lib/types.d.ts +10 -1
  88. package/lib/violation-collector.d.ts +33 -0
  89. package/lib/violation-collector.js +48 -28
  90. package/lib/virtual-rule.d.ts +72 -0
  91. package/lib/virtual-rule.js +233 -0
  92. package/package.json +16 -13
@@ -1,148 +1,150 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _MLNode_pureChildNodesCache, _MLNode_ownerDocument, _MLNode_prevToken, _MLNode_conditionalChildNodes;
13
1
  import { branchesToPatterns } from '@markuplint/shared';
14
2
  import { MLToken } from '../token/token.js';
15
3
  import { isChildNode } from './child-node.js';
16
4
  import { toNodeList } from './node-list.js';
17
5
  import { nodeStore } from './node-store.js';
18
6
  import { UnexpectedCallError } from './unexpected-call-error.js';
7
+ /**
8
+ * Abstract base class for all markuplint DOM node wrappers.
9
+ * Extends `MLToken` with DOM `Node` interface compliance, tree traversal,
10
+ * rule configuration access, and child node management.
11
+ *
12
+ * @template T - The rule configuration value type
13
+ * @template O - The rule options type
14
+ * @template A - The underlying AST node type
15
+ */
19
16
  export class MLNode extends MLToken {
17
+ /**
18
+ * @implements DOM API: `Node`
19
+ * @see https://dom.spec.whatwg.org/#interface-node
20
+ */
21
+ ATTRIBUTE_NODE = 2;
22
+ /**
23
+ * @implements DOM API: `Node`
24
+ * @see https://dom.spec.whatwg.org/#interface-node
25
+ */
26
+ CDATA_SECTION_NODE = 4;
27
+ /**
28
+ * @implements DOM API: `Node`
29
+ * @see https://dom.spec.whatwg.org/#interface-node
30
+ */
31
+ COMMENT_NODE = 8;
32
+ /**
33
+ * @implements DOM API: `Node`
34
+ * @see https://dom.spec.whatwg.org/#interface-node
35
+ */
36
+ DOCUMENT_FRAGMENT_NODE = 11;
37
+ /**
38
+ * @implements DOM API: `Node`
39
+ * @see https://dom.spec.whatwg.org/#interface-node
40
+ */
41
+ DOCUMENT_NODE = 9;
42
+ /**
43
+ * @implements DOM API: `Node`
44
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_contained_by
45
+ */
46
+ DOCUMENT_POSITION_CONTAINED_BY = 0b1_0000;
47
+ /**
48
+ * @implements DOM API: `Node`
49
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_contains
50
+ */
51
+ DOCUMENT_POSITION_CONTAINS = 0b1000;
52
+ /**
53
+ * @implements DOM API: `Node`
54
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_disconnected
55
+ */
56
+ DOCUMENT_POSITION_DISCONNECTED = 0b1;
57
+ /**
58
+ * @implements DOM API: `Node`
59
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_following
60
+ */
61
+ DOCUMENT_POSITION_FOLLOWING = 0b100;
62
+ /**
63
+ * @implements DOM API: `Node`
64
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_implementation_specific
65
+ */
66
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0b10_0000;
67
+ /**
68
+ * @implements DOM API: `Node`
69
+ * @see https://dom.spec.whatwg.org/#dom-node-document_position_preceding
70
+ */
71
+ DOCUMENT_POSITION_PRECEDING = 0b10;
72
+ /**
73
+ * @implements DOM API: `Node`
74
+ * @see https://dom.spec.whatwg.org/#interface-node
75
+ */
76
+ DOCUMENT_TYPE_NODE = 10;
77
+ /**
78
+ * @implements DOM API: `Node`
79
+ * @see https://dom.spec.whatwg.org/#interface-node
80
+ */
81
+ ELEMENT_NODE = 1;
82
+ /**
83
+ * @deprecated
84
+ * @implements DOM API: `Node`
85
+ * @see https://dom.spec.whatwg.org/#interface-node
86
+ */
87
+ ENTITY_NODE = 6;
88
+ /**
89
+ * @deprecated
90
+ * @implements DOM API: `Node`
91
+ * @see https://dom.spec.whatwg.org/#interface-node
92
+ */
93
+ ENTITY_REFERENCE_NODE = 5;
94
+ /**
95
+ * @implements `@markuplint/ml-core` API: `MLNode`
96
+ */
97
+ MARKUPLINT_PREPROCESSOR_BLOCK = 101;
98
+ /**
99
+ * @deprecated
100
+ * @implements DOM API: `Node`
101
+ * @see https://dom.spec.whatwg.org/#interface-node
102
+ */
103
+ NOTATION_NODE = 12;
104
+ /**
105
+ * @implements DOM API: `Node`
106
+ * @see https://dom.spec.whatwg.org/#interface-node
107
+ */
108
+ PROCESSING_INSTRUCTION_NODE = 7;
109
+ /**
110
+ * @implements DOM API: `Node`
111
+ * @see https://dom.spec.whatwg.org/#interface-node
112
+ */
113
+ TEXT_NODE = 3;
114
+ /**
115
+ * Cached `childNodes` property
116
+ */
117
+ #pureChildNodesCache;
118
+ /**
119
+ * Returns child nodes when parent node access by `childNodes` property.
120
+ */
121
+ isFragment;
122
+ /**
123
+ * Owner `Document`
124
+ *
125
+ * @implements DOM API: `Node`
126
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
127
+ */
128
+ #ownerDocument;
129
+ /**
130
+ * Cached `prevToken` property
131
+ */
132
+ #prevToken;
133
+ /**
134
+ * Cached `conditionalChildNodes` method
135
+ */
136
+ #conditionalChildNodes;
137
+ /**
138
+ *
139
+ */
140
+ rules = {};
141
+ _astToken;
20
142
  constructor(astNode,
21
143
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
22
144
  document, isFragment) {
23
145
  super(astNode);
24
- /**
25
- * @implements DOM API: `Node`
26
- * @see https://dom.spec.whatwg.org/#interface-node
27
- */
28
- this.ATTRIBUTE_NODE = 2;
29
- /**
30
- * @implements DOM API: `Node`
31
- * @see https://dom.spec.whatwg.org/#interface-node
32
- */
33
- this.CDATA_SECTION_NODE = 4;
34
- /**
35
- * @implements DOM API: `Node`
36
- * @see https://dom.spec.whatwg.org/#interface-node
37
- */
38
- this.COMMENT_NODE = 8;
39
- /**
40
- * @implements DOM API: `Node`
41
- * @see https://dom.spec.whatwg.org/#interface-node
42
- */
43
- this.DOCUMENT_FRAGMENT_NODE = 11;
44
- /**
45
- * @implements DOM API: `Node`
46
- * @see https://dom.spec.whatwg.org/#interface-node
47
- */
48
- this.DOCUMENT_NODE = 9;
49
- /**
50
- * @implements DOM API: `Node`
51
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_contained_by
52
- */
53
- this.DOCUMENT_POSITION_CONTAINED_BY = 16;
54
- /**
55
- * @implements DOM API: `Node`
56
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_contains
57
- */
58
- this.DOCUMENT_POSITION_CONTAINS = 0b1000;
59
- /**
60
- * @implements DOM API: `Node`
61
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_disconnected
62
- */
63
- this.DOCUMENT_POSITION_DISCONNECTED = 0b1;
64
- /**
65
- * @implements DOM API: `Node`
66
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_following
67
- */
68
- this.DOCUMENT_POSITION_FOLLOWING = 0b100;
69
- /**
70
- * @implements DOM API: `Node`
71
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_implementation_specific
72
- */
73
- this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
74
- /**
75
- * @implements DOM API: `Node`
76
- * @see https://dom.spec.whatwg.org/#dom-node-document_position_preceding
77
- */
78
- this.DOCUMENT_POSITION_PRECEDING = 0b10;
79
- /**
80
- * @implements DOM API: `Node`
81
- * @see https://dom.spec.whatwg.org/#interface-node
82
- */
83
- this.DOCUMENT_TYPE_NODE = 10;
84
- /**
85
- * @implements DOM API: `Node`
86
- * @see https://dom.spec.whatwg.org/#interface-node
87
- */
88
- this.ELEMENT_NODE = 1;
89
- /**
90
- * @deprecated
91
- * @implements DOM API: `Node`
92
- * @see https://dom.spec.whatwg.org/#interface-node
93
- */
94
- this.ENTITY_NODE = 6;
95
- /**
96
- * @deprecated
97
- * @implements DOM API: `Node`
98
- * @see https://dom.spec.whatwg.org/#interface-node
99
- */
100
- this.ENTITY_REFERENCE_NODE = 5;
101
- /**
102
- * @implements `@markuplint/ml-core` API: `MLNode`
103
- */
104
- this.MARKUPLINT_PREPROCESSOR_BLOCK = 101;
105
- /**
106
- * @deprecated
107
- * @implements DOM API: `Node`
108
- * @see https://dom.spec.whatwg.org/#interface-node
109
- */
110
- this.NOTATION_NODE = 12;
111
- /**
112
- * @implements DOM API: `Node`
113
- * @see https://dom.spec.whatwg.org/#interface-node
114
- */
115
- this.PROCESSING_INSTRUCTION_NODE = 7;
116
- /**
117
- * @implements DOM API: `Node`
118
- * @see https://dom.spec.whatwg.org/#interface-node
119
- */
120
- this.TEXT_NODE = 3;
121
- /**
122
- * Cached `childNodes` property
123
- */
124
- _MLNode_pureChildNodesCache.set(this, void 0);
125
- /**
126
- * Owner `Document`
127
- *
128
- * @implements DOM API: `Node`
129
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
130
- */
131
- _MLNode_ownerDocument.set(this, void 0);
132
- /**
133
- * Cached `prevToken` property
134
- */
135
- _MLNode_prevToken.set(this, void 0);
136
- /**
137
- * Cached `conditionalChildNodes` mothod
138
- */
139
- _MLNode_conditionalChildNodes.set(this, void 0);
140
- /**
141
- *
142
- */
143
- this.rules = {};
144
146
  this._astToken = astNode;
145
- __classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
147
+ this.#ownerDocument = document;
146
148
  this.isFragment = !!isFragment;
147
149
  nodeStore.setNode(astNode, this);
148
150
  }
@@ -158,6 +160,8 @@ export class MLNode extends MLToken {
158
160
  }
159
161
  /**
160
162
  * The list of child nodes that contains `Element`, `Text`, and `Comment`.
163
+ * Fragment nodes and preprocessor blocks with `each` or `end` block behavior
164
+ * are transparent — their child nodes are flattened into this list.
161
165
  *
162
166
  * @readonly
163
167
  * @implements DOM API: `Node`
@@ -166,7 +170,9 @@ export class MLNode extends MLToken {
166
170
  get childNodes() {
167
171
  const pureChildNodes = [...this.getPureChildNodes()];
168
172
  const childNodes = pureChildNodes.flatMap(node => {
169
- if (node.isFragment) {
173
+ if (node.isFragment ||
174
+ (node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK) &&
175
+ ['each', 'end'].includes(node.blockBehavior?.type ?? ''))) {
170
176
  return [...node.childNodes];
171
177
  }
172
178
  return [node];
@@ -208,7 +214,7 @@ export class MLNode extends MLToken {
208
214
  * @implements `@markuplint/ml-core` API: `MLNode`
209
215
  */
210
216
  get nextNode() {
211
- const siblings = [...(this.syntacticalParentNode?.childNodes ?? __classPrivateFieldGet(this, _MLNode_ownerDocument, "f").nodeList)];
217
+ const siblings = [...(this.syntacticalParentNode?.childNodes ?? this.#ownerDocument.nodeList)];
212
218
  const index = siblings.findIndex(node => node.uuid === this.uuid);
213
219
  return siblings[index + 1] ?? null;
214
220
  }
@@ -269,10 +275,17 @@ export class MLNode extends MLToken {
269
275
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument%E2%91%A0
270
276
  */
271
277
  get ownerDocument() {
272
- return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
278
+ return this.#ownerDocument;
273
279
  }
280
+ /**
281
+ * The owning `MLDocument` instance with proper generic types,
282
+ * providing type-safe access to the document without the `any` type
283
+ * used by the DOM-compatible `ownerDocument`.
284
+ *
285
+ * @implements `@markuplint/ml-core` API: `MLNode`
286
+ */
274
287
  get ownerMLDocument() {
275
- return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
288
+ return this.#ownerDocument;
276
289
  }
277
290
  /**
278
291
  * The parent element.
@@ -360,7 +373,7 @@ export class MLNode extends MLToken {
360
373
  * @implements `@markuplint/ml-core` API: `MLNode`
361
374
  */
362
375
  get prevNode() {
363
- const siblings = [...(this.syntacticalParentNode?.childNodes ?? __classPrivateFieldGet(this, _MLNode_ownerDocument, "f").nodeList)];
376
+ const siblings = [...(this.syntacticalParentNode?.childNodes ?? this.#ownerDocument.nodeList)];
364
377
  const index = siblings.findIndex(node => node.uuid === this.uuid);
365
378
  return siblings[index - 1] ?? null;
366
379
  }
@@ -368,8 +381,8 @@ export class MLNode extends MLToken {
368
381
  * @implements `@markuplint/ml-core` API: `MLNode`
369
382
  */
370
383
  get prevToken() {
371
- if (__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
372
- return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
384
+ if (this.#prevToken !== undefined) {
385
+ return this.#prevToken;
373
386
  }
374
387
  let index = -1;
375
388
  for (let i = 0; i < this.ownerMLDocument.nodeList.length; i++) {
@@ -386,11 +399,11 @@ export class MLNode extends MLToken {
386
399
  }
387
400
  }
388
401
  if (index === -1) {
389
- __classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
390
- return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
402
+ this.#prevToken = null;
403
+ return this.#prevToken;
391
404
  }
392
- __classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] ?? null, "f");
393
- return __classPrivateFieldGet(this, _MLNode_prevToken, "f") ?? null;
405
+ this.#prevToken = this.ownerMLDocument.nodeList[index - 1] ?? null;
406
+ return this.#prevToken ?? null;
394
407
  }
395
408
  /**
396
409
  * The previous sibling of an object is its first preceding sibling or null if it has no preceding sibling.
@@ -532,7 +545,7 @@ export class MLNode extends MLToken {
532
545
  /**
533
546
  * Returns an array of NodeLists representing the conditional child nodes of the current node.
534
547
  * Conditional child nodes are nodes that are nested within
535
- * **preprocessor blocks** such as `if`, `each`, or `switch`.
548
+ * **preprocessor blocks** such as `if` or `switch`.
536
549
  * Each NodeList represents a branch of conditional child nodes.
537
550
  *
538
551
  * Note: NodeList doesn't include whitespace nodes.
@@ -543,8 +556,8 @@ export class MLNode extends MLToken {
543
556
  * @implements `@markuplint/ml-core` API: `MLNode`
544
557
  */
545
558
  conditionalChildNodes() {
546
- if (__classPrivateFieldGet(this, _MLNode_conditionalChildNodes, "f") != null) {
547
- return __classPrivateFieldGet(this, _MLNode_conditionalChildNodes, "f");
559
+ if (this.#conditionalChildNodes != null) {
560
+ return this.#conditionalChildNodes;
548
561
  }
549
562
  const branches = [];
550
563
  let mode = null;
@@ -552,22 +565,19 @@ export class MLNode extends MLToken {
552
565
  let subBranches = [];
553
566
  for (const child of this.childNodes) {
554
567
  if (child.is(child.MARKUPLINT_PREPROCESSOR_BLOCK)) {
555
- switch (child.conditionalType) {
568
+ switch (child.blockBehavior?.type) {
556
569
  case 'if':
557
570
  case 'if:elseif': {
558
571
  mode = 'if';
559
572
  break;
560
573
  }
561
- case 'each': {
562
- mode = 'each';
563
- break;
564
- }
565
574
  case 'switch:case': {
566
575
  mode = 'switch';
567
576
  break;
568
577
  }
569
578
  /* No default mode */
570
579
  case 'if:else':
580
+ case 'each':
571
581
  case 'each:empty':
572
582
  case 'switch:default':
573
583
  case 'await':
@@ -585,7 +595,7 @@ export class MLNode extends MLToken {
585
595
  continue;
586
596
  }
587
597
  if (openConditional) {
588
- if (['if', 'each', 'switch'].includes(mode)) {
598
+ if (['if', 'switch'].includes(mode)) {
589
599
  subBranches.push(null);
590
600
  }
591
601
  branches.push(subBranches);
@@ -599,13 +609,13 @@ export class MLNode extends MLToken {
599
609
  branches.push(child);
600
610
  }
601
611
  if (subBranches.length > 0) {
602
- if (['if', 'each', 'switch'].includes(mode)) {
612
+ if (['if', 'switch'].includes(mode)) {
603
613
  subBranches.push(null);
604
614
  }
605
615
  branches.push(subBranches);
606
616
  }
607
617
  const cache = branchesToPatterns(branches).map(array => toNodeList(array));
608
- __classPrivateFieldSet(this, _MLNode_conditionalChildNodes, cache, "f");
618
+ this.#conditionalChildNodes = cache;
609
619
  return cache;
610
620
  }
611
621
  /**
@@ -669,8 +679,8 @@ export class MLNode extends MLToken {
669
679
  * @implements DOM API: `MLNode`
670
680
  */
671
681
  getPureChildNodes() {
672
- if (__classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f") != null) {
673
- return __classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f");
682
+ if (this.#pureChildNodesCache != null) {
683
+ return this.#pureChildNodesCache;
674
684
  }
675
685
  if (this.is(this.DOCUMENT_NODE)) {
676
686
  const childNodes = [];
@@ -680,8 +690,8 @@ export class MLNode extends MLToken {
680
690
  }
681
691
  }
682
692
  // Cache
683
- __classPrivateFieldSet(this, _MLNode_pureChildNodesCache, toNodeList(childNodes), "f");
684
- return __classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f");
693
+ this.#pureChildNodesCache = toNodeList(childNodes);
694
+ return this.#pureChildNodesCache;
685
695
  }
686
696
  if (this.is(this.DOCUMENT_FRAGMENT_NODE) ||
687
697
  this.is(this.ELEMENT_NODE) ||
@@ -698,12 +708,12 @@ export class MLNode extends MLToken {
698
708
  .map(node => nodeStore.getNode(node))
699
709
  .filter(node => isChildNode(node));
700
710
  // Cache
701
- __classPrivateFieldSet(this, _MLNode_pureChildNodesCache, toNodeList(childNodes), "f");
702
- return __classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f");
711
+ this.#pureChildNodesCache = toNodeList(childNodes);
712
+ return this.#pureChildNodesCache;
703
713
  }
704
714
  // Cache
705
- __classPrivateFieldSet(this, _MLNode_pureChildNodesCache, toNodeList([]), "f");
706
- return __classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f");
715
+ this.#pureChildNodesCache = toNodeList([]);
716
+ return this.#pureChildNodesCache;
707
717
  }
708
718
  /**
709
719
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -719,7 +729,7 @@ export class MLNode extends MLToken {
719
729
  throw new UnexpectedCallError('Not supported options');
720
730
  }
721
731
  // The original DOM API returns a document fragment if the element is a fragment.
722
- return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
732
+ return this.#ownerDocument;
723
733
  }
724
734
  /**
725
735
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -859,7 +869,6 @@ export class MLNode extends MLToken {
859
869
  resetChildren(
860
870
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
861
871
  childNodes) {
862
- __classPrivateFieldSet(this, _MLNode_pureChildNodesCache, childNodes ?? __classPrivateFieldGet(this, _MLNode_pureChildNodesCache, "f"), "f");
872
+ this.#pureChildNodesCache = childNodes ?? this.#pureChildNodesCache;
863
873
  }
864
874
  }
865
- _MLNode_pureChildNodesCache = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap(), _MLNode_conditionalChildNodes = new WeakMap();
@@ -1,15 +1,3 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _MLParentNode_children, _MLParentNode_selectedElements;
13
1
  import { syncWalk } from '../helper/walkers.js';
14
2
  import { getChildren } from '../manipulations/get-children.js';
15
3
  import { toNodeList } from './node-list.js';
@@ -20,17 +8,14 @@ import { UnexpectedCallError } from './unexpected-call-error.js';
20
8
  * @see https://dom.spec.whatwg.org/#interface-parentnode
21
9
  */
22
10
  export class MLParentNode extends MLNode {
23
- constructor() {
24
- super(...arguments);
25
- /**
26
- * Cached `children`
27
- */
28
- _MLParentNode_children.set(this, null);
29
- /**
30
- * Cached elements that created from `querySelectorAll`
31
- */
32
- _MLParentNode_selectedElements.set(this, new Map());
33
- }
11
+ /**
12
+ * Cached `children`
13
+ */
14
+ #children = null;
15
+ /**
16
+ * Cached elements that created from `querySelectorAll`
17
+ */
18
+ #selectedElements = new Map();
34
19
  /**
35
20
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
36
21
  * @see https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
@@ -43,12 +28,12 @@ export class MLParentNode extends MLNode {
43
28
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-children%E2%91%A0
44
29
  */
45
30
  get children() {
46
- if (__classPrivateFieldGet(this, _MLParentNode_children, "f")) {
47
- return __classPrivateFieldGet(this, _MLParentNode_children, "f");
31
+ if (this.#children) {
32
+ return this.#children;
48
33
  }
49
34
  const children = getChildren(this);
50
- __classPrivateFieldSet(this, _MLParentNode_children, children, "f");
51
- return __classPrivateFieldGet(this, _MLParentNode_children, "f");
35
+ this.#children = children;
36
+ return this.#children;
52
37
  }
53
38
  /**
54
39
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
@@ -101,7 +86,7 @@ export class MLParentNode extends MLNode {
101
86
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselectorall%E2%91%A0
102
87
  */
103
88
  querySelectorAll(selectors) {
104
- const selected = __classPrivateFieldGet(this, _MLParentNode_selectedElements, "f").get(selectors);
89
+ const selected = this.#selectedElements.get(selectors);
105
90
  if (selected) {
106
91
  return selected;
107
92
  }
@@ -110,7 +95,7 @@ export class MLParentNode extends MLNode {
110
95
  return node;
111
96
  }
112
97
  }));
113
- __classPrivateFieldGet(this, _MLParentNode_selectedElements, "f").set(selectors, elements);
98
+ this.#selectedElements.set(selectors, elements);
114
99
  return elements;
115
100
  }
116
101
  /**
@@ -140,4 +125,3 @@ export class MLParentNode extends MLNode {
140
125
  return Object.freeze(nodeList);
141
126
  }
142
127
  }
143
- _MLParentNode_children = new WeakMap(), _MLParentNode_selectedElements = new WeakMap();
@@ -1,32 +1,20 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _RuleMapper_nodeList, _RuleMapper_ruleMap;
13
1
  import { compareSpecificity } from '@markuplint/selector';
14
2
  import { log as coreLog } from '../../debug.js';
15
3
  const ruleMapperLog = coreLog.extend('rule-mapper');
16
4
  const ruleMapperNodeLog = ruleMapperLog.extend('node');
17
5
  const ruleMapperNodeRuleLog = ruleMapperNodeLog.extend('rule');
18
6
  export class RuleMapper {
7
+ #nodeList;
8
+ #ruleMap = new Map();
19
9
  constructor(
20
10
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
21
11
  document) {
22
- _RuleMapper_nodeList.set(this, void 0);
23
- _RuleMapper_ruleMap.set(this, new Map());
24
- __classPrivateFieldSet(this, _RuleMapper_nodeList, Object.freeze([document, ...document.nodeList]), "f");
12
+ this.#nodeList = Object.freeze([document, ...document.nodeList]);
25
13
  }
26
14
  apply() {
27
15
  ruleMapperLog('ruleTree:');
28
- for (const node of __classPrivateFieldGet(this, _RuleMapper_nodeList, "f")) {
29
- const rules = __classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid);
16
+ for (const node of this.#nodeList) {
17
+ const rules = this.#ruleMap.get(node.uuid);
30
18
  if (!rules) {
31
19
  continue;
32
20
  }
@@ -44,7 +32,7 @@ export class RuleMapper {
44
32
  set(
45
33
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
46
34
  node, ruleName, rule) {
47
- const rules = __classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid) ?? {};
35
+ const rules = this.#ruleMap.get(node.uuid) ?? {};
48
36
  const currentRule = rules[ruleName];
49
37
  if (currentRule) {
50
38
  const order = compareSpecificity(currentRule.specificity, rule.specificity);
@@ -55,8 +43,7 @@ export class RuleMapper {
55
43
  ruleMapperLog('Unset %o from %s', currentRule, node);
56
44
  }
57
45
  rules[ruleName] = rule;
58
- __classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").set(node.uuid, rules);
46
+ this.#ruleMap.set(node.uuid, rules);
59
47
  ruleMapperLog('Set to %s from %s (%o): %O', node.nodeName, rule.from, rule.specificity, rule.rule);
60
48
  }
61
49
  }
62
- _RuleMapper_nodeList = new WeakMap(), _RuleMapper_ruleMap = new WeakMap();
@@ -2,6 +2,14 @@ import type { TextNodeType } from './types.js';
2
2
  import type { MLASTText } from '@markuplint/ml-ast';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLCharacterData } from './character-data.js';
5
+ /**
6
+ * Represents a DOM Text node wrapper in the markuplint DOM tree.
7
+ * Wraps an AST text token and provides text-specific operations such as
8
+ * detecting raw text element content and whitespace-only nodes.
9
+ *
10
+ * @template T - The rule configuration value type
11
+ * @template O - The rule options type
12
+ */
5
13
  export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined> extends MLCharacterData<T, O, MLASTText> implements Text {
6
14
  /**
7
15
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -10,6 +18,13 @@ export declare class MLText<T extends RuleConfigValue, O extends PlainData = und
10
18
  * @implements DOM API: `Text`
11
19
  */
12
20
  get assignedSlot(): HTMLSlotElement;
21
+ /**
22
+ * Returns `true` if this text node originated from an invalid (bogus) AST
23
+ * node, such as an orphaned end tag.
24
+ *
25
+ * @implements `@markuplint/ml-core` API: `MLText`
26
+ */
27
+ get isBogus(): boolean;
13
28
  /**
14
29
  * Returns a string appropriate for the type of node as `Text`
15
30
  *
@@ -33,10 +48,14 @@ export declare class MLText<T extends RuleConfigValue, O extends PlainData = und
33
48
  *
34
49
  * @implements `@markuplint/ml-core` API: `MLText`
35
50
  * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
51
+ * @returns True if this text node is the content of a raw text element
36
52
  */
37
53
  isRawTextElementContent(): boolean;
38
54
  /**
55
+ * Checks whether this text node contains only whitespace characters.
56
+ *
39
57
  * @implements `@markuplint/ml-core` API: `MLText`
58
+ * @returns True if the raw content is composed entirely of whitespace
40
59
  */
41
60
  isWhitespace(): boolean;
42
61
  /**