@markuplint/ml-core 3.0.0-dev.25 → 3.0.0-dev.300

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 (95) hide show
  1. package/lib/configs.browser.js +1 -5
  2. package/lib/configs.js +33 -31
  3. package/lib/convert-ruleset.d.ts +1 -1
  4. package/lib/convert-ruleset.js +3 -8
  5. package/lib/debug.js +9 -14
  6. package/lib/index.d.ts +13 -12
  7. package/lib/index.js +13 -29
  8. package/lib/ml-core.d.ts +7 -7
  9. package/lib/ml-core.js +60 -66
  10. package/lib/ml-dom/helper/accname.d.ts +1 -1
  11. package/lib/ml-dom/helper/accname.js +23 -19
  12. package/lib/ml-dom/helper/create-node.d.ts +4 -4
  13. package/lib/ml-dom/helper/create-node.js +13 -15
  14. package/lib/ml-dom/helper/debug.d.ts +1 -1
  15. package/lib/ml-dom/helper/debug.js +8 -8
  16. package/lib/ml-dom/helper/getIndent.d.ts +2 -2
  17. package/lib/ml-dom/helper/getIndent.js +30 -28
  18. package/lib/ml-dom/helper/walkers.d.ts +6 -6
  19. package/lib/ml-dom/helper/walkers.js +23 -22
  20. package/lib/ml-dom/index.d.ts +9 -9
  21. package/lib/ml-dom/index.js +1 -5
  22. package/lib/ml-dom/manipulations/child-node-methods.d.ts +9 -9
  23. package/lib/ml-dom/manipulations/child-node-methods.js +31 -25
  24. package/lib/ml-dom/manipulations/get-children.d.ts +4 -4
  25. package/lib/ml-dom/manipulations/get-children.js +5 -7
  26. package/lib/ml-dom/node/attr.d.ts +7 -7
  27. package/lib/ml-dom/node/attr.js +33 -34
  28. package/lib/ml-dom/node/block.d.ts +6 -6
  29. package/lib/ml-dom/node/block.js +21 -15
  30. package/lib/ml-dom/node/character-data.d.ts +4 -4
  31. package/lib/ml-dom/node/character-data.js +20 -19
  32. package/lib/ml-dom/node/child-node.d.ts +9 -9
  33. package/lib/ml-dom/node/child-node.js +3 -5
  34. package/lib/ml-dom/node/comment.d.ts +4 -4
  35. package/lib/ml-dom/node/comment.js +2 -6
  36. package/lib/ml-dom/node/document-fragment.d.ts +4 -4
  37. package/lib/ml-dom/node/document-fragment.js +4 -9
  38. package/lib/ml-dom/node/document-type.d.ts +6 -6
  39. package/lib/ml-dom/node/document-type.js +21 -15
  40. package/lib/ml-dom/node/document.d.ts +32 -29
  41. package/lib/ml-dom/node/document.js +329 -246
  42. package/lib/ml-dom/node/dom-token-list.d.ts +3 -3
  43. package/lib/ml-dom/node/dom-token-list.js +29 -33
  44. package/lib/ml-dom/node/element.d.ts +65 -16
  45. package/lib/ml-dom/node/element.js +396 -306
  46. package/lib/ml-dom/node/named-node-map.d.ts +4 -4
  47. package/lib/ml-dom/node/named-node-map.js +18 -18
  48. package/lib/ml-dom/node/node-list.d.ts +6 -6
  49. package/lib/ml-dom/node/node-list.js +25 -13
  50. package/lib/ml-dom/node/node-store.d.ts +5 -5
  51. package/lib/ml-dom/node/node-store.js +25 -10
  52. package/lib/ml-dom/node/node.d.ts +12 -12
  53. package/lib/ml-dom/node/node.js +101 -76
  54. package/lib/ml-dom/node/parent-node.d.ts +6 -6
  55. package/lib/ml-dom/node/parent-node.js +31 -29
  56. package/lib/ml-dom/node/rule-mapper.d.ts +5 -5
  57. package/lib/ml-dom/node/rule-mapper.js +20 -17
  58. package/lib/ml-dom/node/text.d.ts +4 -4
  59. package/lib/ml-dom/node/text.js +6 -11
  60. package/lib/ml-dom/node/types.d.ts +30 -16
  61. package/lib/ml-dom/node/types.js +1 -2
  62. package/lib/ml-dom/node/unexpected-call-error.js +1 -4
  63. package/lib/ml-dom/token/token.js +19 -23
  64. package/lib/ml-rule/create-rule.d.ts +3 -3
  65. package/lib/ml-rule/create-rule.js +1 -5
  66. package/lib/ml-rule/create-test-rule.d.ts +5 -5
  67. package/lib/ml-rule/create-test-rule.js +3 -7
  68. package/lib/ml-rule/index.d.ts +3 -3
  69. package/lib/ml-rule/index.js +3 -6
  70. package/lib/ml-rule/ml-rule-context.d.ts +4 -4
  71. package/lib/ml-rule/ml-rule-context.js +11 -13
  72. package/lib/ml-rule/ml-rule.d.ts +9 -9
  73. package/lib/ml-rule/ml-rule.js +48 -45
  74. package/lib/ml-rule/types.d.ts +12 -12
  75. package/lib/ml-rule/types.js +1 -2
  76. package/lib/plugin/index.d.ts +2 -2
  77. package/lib/plugin/index.js +2 -5
  78. package/lib/plugin/plugin.d.ts +2 -2
  79. package/lib/plugin/plugin.js +1 -5
  80. package/lib/plugin/types.d.ts +6 -6
  81. package/lib/plugin/types.js +1 -2
  82. package/lib/ruleset/index.d.ts +3 -3
  83. package/lib/ruleset/index.js +4 -8
  84. package/lib/test/index.d.ts +9 -9
  85. package/lib/test/index.js +14 -24
  86. package/lib/types.d.ts +11 -10
  87. package/lib/types.js +1 -2
  88. package/lib/utils/get-location-from-chars.d.ts +1 -1
  89. package/lib/utils/get-location-from-chars.js +1 -5
  90. package/lib/utils/index.d.ts +1 -1
  91. package/lib/utils/index.js +1 -5
  92. package/lib/utils/string-splice.js +1 -5
  93. package/package.json +25 -16
  94. package/tsconfig.test.json +0 -3
  95. package/tsconfig.tsbuildinfo +0 -1
@@ -1,5 +1,5 @@
1
- import type { MLNode } from '../node/node';
2
- import type { MLText } from '../node/text';
1
+ import type { MLNode } from '../node/node.js';
2
+ import type { MLText } from '../node/text.js';
3
3
  /**
4
4
  *
5
5
  * @deprecated
@@ -1,14 +1,13 @@
1
- "use strict";
2
1
  var _MLDOMIndentation_fixed, _MLDOMIndentation_node, _MLDOMIndentation_parent;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getIndent = void 0;
5
- const tslib_1 = require("tslib");
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
6
3
  /**
7
4
  *
8
5
  * @deprecated
9
6
  * @param node
10
7
  */
11
- function getIndent(node) {
8
+ export function getIndent(
9
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
+ node) {
12
11
  const prevToken = node.prevToken;
13
12
  if (!prevToken) {
14
13
  return null;
@@ -49,52 +48,55 @@ function getIndent(node) {
49
48
  }
50
49
  return null;
51
50
  }
52
- exports.getIndent = getIndent;
53
51
  class MLDOMIndentation {
54
- constructor(originTextNode, raw, line, parentNode) {
52
+ constructor(
53
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
54
+ originTextNode, raw, line,
55
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
56
+ parentNode) {
55
57
  _MLDOMIndentation_fixed.set(this, void 0);
56
58
  _MLDOMIndentation_node.set(this, void 0);
57
59
  _MLDOMIndentation_parent.set(this, void 0);
58
60
  this.line = line;
59
- tslib_1.__classPrivateFieldSet(this, _MLDOMIndentation_node, originTextNode, "f");
60
- tslib_1.__classPrivateFieldSet(this, _MLDOMIndentation_parent, parentNode, "f");
61
- tslib_1.__classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
61
+ __classPrivateFieldSet(this, _MLDOMIndentation_node, originTextNode, "f");
62
+ __classPrivateFieldSet(this, _MLDOMIndentation_parent, parentNode, "f");
63
+ __classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
62
64
  }
63
65
  get raw() {
64
- if (!tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
66
+ if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
65
67
  return '';
66
68
  }
67
- return tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
69
+ return __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
68
70
  }
69
71
  get type() {
70
- if (!tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
72
+ if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
71
73
  return 'none';
72
74
  }
73
- const raw = tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
75
+ const raw = __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
74
76
  return raw === '' ? 'none' : /^\t+$/.test(raw) ? 'tab' : /^[^\t]+$/.test(raw) ? 'space' : 'mixed';
75
77
  }
76
78
  get width() {
77
- if (!tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
79
+ if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
78
80
  return 0;
79
81
  }
80
- return tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f").length;
82
+ return __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f").length;
81
83
  }
82
84
  fix(raw) {
83
- const current = tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
84
- tslib_1.__classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
85
- if (tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_node, "f")) {
86
- const node = tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_node, "f");
87
- const line = node.startLine;
88
- const lines = node.raw.split(/\r?\n/);
89
- const index = this.line - line;
90
- if (lines[index] != null) {
91
- lines[index] = lines[index].replace(current, tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f"));
92
- }
93
- node.fix(lines.join('\n'));
85
+ const current = __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
86
+ __classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
87
+ const node = __classPrivateFieldGet(this, _MLDOMIndentation_node, "f");
88
+ const line = node.startLine;
89
+ const lines = node.raw.split(/\r?\n/);
90
+ const index = this.line - line;
91
+ if (lines[index] != null) {
92
+ lines[index] = lines[index].replace(current, __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f"));
94
93
  }
94
+ node.fix(lines.join('\n'));
95
95
  }
96
96
  }
97
97
  _MLDOMIndentation_fixed = new WeakMap(), _MLDOMIndentation_node = new WeakMap(), _MLDOMIndentation_parent = new WeakMap();
98
- function isFirstToken(node) {
98
+ function isFirstToken(
99
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
100
+ node) {
99
101
  return !node.prevToken;
100
102
  }
@@ -1,6 +1,6 @@
1
- import type { MLNode } from '../node/node';
2
- import type { RuleConfigValue } from '@markuplint/ml-config';
3
- export type Walker<T extends RuleConfigValue, O = null, N = MLNode<T, O>> = (node: N) => void | Promise<void> | Promise<void>[];
4
- export type SyncWalker<T extends RuleConfigValue, O = null, N = MLNode<T, O>> = (node: N) => void;
5
- export declare function syncWalk<T extends RuleConfigValue, O = null>(nodeList: ReadonlyArray<MLNode<T, O>>, walker: SyncWalker<T, O>): void;
6
- export declare function sequentialWalker<T extends RuleConfigValue, O = null, N = MLNode<T, O>>(list: ReadonlyArray<N>, walker: Walker<T, O, N>): Promise<void>;
1
+ import type { MLNode } from '../node/node.js';
2
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
3
+ export type Walker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void | Promise<void> | Promise<void>[];
4
+ export type SyncWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void;
5
+ export declare function syncWalk<T extends RuleConfigValue, O extends PlainData = undefined>(nodeList: ReadonlyArray<MLNode<T, O>>, walker: SyncWalker<T, O>): void;
6
+ export declare function sequentialWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>>(list: ReadonlyArray<N>, walker: Walker<T, O, N>): Promise<void>;
@@ -1,7 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sequentialWalker = exports.syncWalk = void 0;
4
- function syncWalk(nodeList, walker) {
1
+ export function syncWalk(
2
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
3
+ nodeList, walker) {
5
4
  for (const node of nodeList) {
6
5
  if (node.is(node.ELEMENT_NODE) || node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK)) {
7
6
  syncWalk(Array.from(node.childNodes), walker);
@@ -9,8 +8,7 @@ function syncWalk(nodeList, walker) {
9
8
  walker(node);
10
9
  }
11
10
  }
12
- exports.syncWalk = syncWalk;
13
- function sequentialWalker(list, walker) {
11
+ export function sequentialWalker(list, walker) {
14
12
  if (list.length === 0) {
15
13
  return Promise.resolve();
16
14
  }
@@ -25,24 +23,27 @@ function sequentialWalker(list, walker) {
25
23
  _reject = reject;
26
24
  });
27
25
  const loop = (index = 0) => {
28
- if (index >= list.length) {
29
- _resolve();
30
- return;
31
- }
32
- const node = list[index];
33
- if (!node) {
34
- _resolve();
35
- return;
36
- }
37
- const result = walker(node);
38
- if (result instanceof Promise) {
39
- result.then(() => loop(index + 1)).catch(_reject);
40
- }
41
- else {
42
- loop(index + 1);
26
+ // eslint-disable-next-line no-constant-condition
27
+ while (true) {
28
+ if (index >= list.length) {
29
+ _resolve();
30
+ return;
31
+ }
32
+ const node = list[index];
33
+ if (node == null) {
34
+ _resolve();
35
+ return;
36
+ }
37
+ const result = walker(node);
38
+ if (result instanceof Promise) {
39
+ result.then(() => loop(index + 1)).catch(_reject);
40
+ return;
41
+ }
42
+ else {
43
+ index = index + 1;
44
+ }
43
45
  }
44
46
  };
45
47
  loop();
46
48
  return promise;
47
49
  }
48
- exports.sequentialWalker = sequentialWalker;
@@ -1,9 +1,9 @@
1
- export type { MLAttr as Attr } from './node/attr';
2
- export type { MLBlock as Block } from './node/block';
3
- export type { MLComment as Comment } from './node/comment';
4
- export type { MLDocumentFragment as DocumentFragment } from './node/document-fragment';
5
- export type { MLDocumentType as DocumentType } from './node/document-type';
6
- export type { MLElement as Element } from './node/element';
7
- export type { MLText as Text } from './node/text';
8
- export type { MLChildNode as ChildNode } from './node/child-node';
9
- export { MLDocument as Document } from './node/document';
1
+ export type { MLAttr as Attr } from './node/attr.js';
2
+ export type { MLBlock as Block } from './node/block.js';
3
+ export type { MLComment as Comment } from './node/comment.js';
4
+ export type { MLDocumentFragment as DocumentFragment } from './node/document-fragment.js';
5
+ export type { MLDocumentType as DocumentType } from './node/document-type.js';
6
+ export type { MLElement as Element } from './node/element.js';
7
+ export type { MLText as Text } from './node/text.js';
8
+ export type { MLChildNode as ChildNode } from './node/child-node.js';
9
+ export { MLDocument as Document } from './node/document.js';
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var document_1 = require("./node/document");
5
- Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.MLDocument; } });
1
+ export { MLDocument as Document } from './node/document.js';
@@ -1,33 +1,33 @@
1
- import type { MLElement } from '../node/element';
2
- import type { MLNode } from '../node/node';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
1
+ import type { MLElement } from '../node/element.js';
2
+ import type { MLNode } from '../node/node.js';
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  /**
5
5
  *
6
6
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
7
7
  */
8
- export declare function before<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
8
+ export declare function before<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
9
9
  /**
10
10
  *
11
11
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
12
12
  */
13
- export declare function after<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
13
+ export declare function after<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
14
14
  /**
15
15
  *
16
16
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
17
17
  */
18
- export declare function replaceWith<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
18
+ export declare function replaceWith<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
19
19
  /**
20
20
  *
21
21
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
22
22
  */
23
- export declare function remove<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): void;
23
+ export declare function remove<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): void;
24
24
  /**
25
25
  *
26
26
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
27
27
  */
28
- export declare function previousElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
28
+ export declare function previousElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
29
29
  /**
30
30
  *
31
31
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
32
32
  */
33
- export declare function nextElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
33
+ export declare function nextElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
@@ -1,50 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nextElementSibling = exports.previousElementSibling = exports.remove = exports.replaceWith = exports.after = exports.before = void 0;
4
- const tslib_1 = require("tslib");
5
- const unexpected_call_error_1 = tslib_1.__importDefault(require("../node/unexpected-call-error"));
1
+ import UnexpectedCallError from '../node/unexpected-call-error.js';
6
2
  /**
7
3
  *
8
4
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
9
5
  */
10
- function before(node, ...additionalNodes) {
11
- throw new unexpected_call_error_1.default('Not supported "before" method');
6
+ export function before(
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ node,
9
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
+ ...additionalNodes) {
11
+ throw new UnexpectedCallError('Not supported "before" method');
12
12
  }
13
- exports.before = before;
14
13
  /**
15
14
  *
16
15
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
17
16
  */
18
- function after(node, ...additionalNodes) {
19
- throw new unexpected_call_error_1.default('Not supported "after" method');
17
+ export function after(
18
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
19
+ node,
20
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
21
+ ...additionalNodes) {
22
+ throw new UnexpectedCallError('Not supported "after" method');
20
23
  }
21
- exports.after = after;
22
24
  /**
23
25
  *
24
26
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
25
27
  */
26
- function replaceWith(node, ...additionalNodes) {
27
- throw new unexpected_call_error_1.default('Not supported "replaceWith" method');
28
+ export function replaceWith(
29
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
30
+ node,
31
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
32
+ ...additionalNodes) {
33
+ throw new UnexpectedCallError('Not supported "replaceWith" method');
28
34
  }
29
- exports.replaceWith = replaceWith;
30
35
  /**
31
36
  *
32
37
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
33
38
  */
34
- function remove(node) {
35
- throw new unexpected_call_error_1.default('Not supported "remove" method');
39
+ export function remove(
40
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
41
+ node) {
42
+ throw new UnexpectedCallError('Not supported "remove" method');
36
43
  }
37
- exports.remove = remove;
38
44
  /**
39
45
  *
40
46
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
41
47
  */
42
- function previousElementSibling(node) {
43
- var _a, _b;
48
+ export function previousElementSibling(
49
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
50
+ node) {
44
51
  let prevNode = node.prevNode;
45
52
  while (prevNode) {
46
53
  if (((node.parentNode === null && prevNode.parentNode === null) ||
47
- ((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = prevNode.parentNode) === null || _b === void 0 ? void 0 : _b.uuid)) &&
54
+ node.parentNode?.uuid === prevNode.parentNode?.uuid) &&
48
55
  prevNode.is(prevNode.ELEMENT_NODE)) {
49
56
  return prevNode;
50
57
  }
@@ -52,17 +59,17 @@ function previousElementSibling(node) {
52
59
  }
53
60
  return null;
54
61
  }
55
- exports.previousElementSibling = previousElementSibling;
56
62
  /**
57
63
  *
58
64
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
59
65
  */
60
- function nextElementSibling(node) {
61
- var _a, _b;
66
+ export function nextElementSibling(
67
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
68
+ node) {
62
69
  let nextNode = node.nextNode;
63
70
  while (nextNode) {
64
71
  if (((node.parentNode === null && nextNode.parentNode === null) ||
65
- ((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = nextNode.parentNode) === null || _b === void 0 ? void 0 : _b.uuid)) &&
72
+ node.parentNode?.uuid === nextNode.parentNode?.uuid) &&
66
73
  nextNode.is(nextNode.ELEMENT_NODE)) {
67
74
  return nextNode;
68
75
  }
@@ -70,4 +77,3 @@ function nextElementSibling(node) {
70
77
  }
71
78
  return null;
72
79
  }
73
- exports.nextElementSibling = nextElementSibling;
@@ -1,4 +1,4 @@
1
- import type { MLElement } from '../node/element';
2
- import type { MLNode } from '../node/node';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
4
- export declare function getChildren<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): HTMLCollectionOf<MLElement<T, O>>;
1
+ import type { MLElement } from '../node/element.js';
2
+ import type { MLNode } from '../node/node.js';
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
+ export declare function getChildren<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): HTMLCollectionOf<MLElement<T, O>>;
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChildren = void 0;
4
- const node_list_1 = require("../node/node-list");
5
- function getChildren(node) {
6
- return (0, node_list_1.toHTMLCollection)(Array.from(node.childNodes).filter((child) => {
1
+ import { toHTMLCollection } from '../node/node-list.js';
2
+ export function getChildren(
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ node) {
5
+ return toHTMLCollection(Array.from(node.childNodes).filter((child) => {
7
6
  return child.nodeType === child.ELEMENT_NODE;
8
7
  }));
9
8
  }
10
- exports.getChildren = getChildren;
@@ -1,11 +1,11 @@
1
- import type { MLElement } from './element';
2
- import type { AttributeNodeType } from './types';
1
+ import type { MLElement } from './element.js';
2
+ import type { AttributeNodeType } from './types.js';
3
3
  import type { MLASTAttr } from '@markuplint/ml-ast';
4
- import type { RuleConfigValue } from '@markuplint/ml-config';
5
- import { MLToken } from '../token/token';
6
- import { MLDomTokenList } from './dom-token-list';
7
- import { MLNode } from './node';
8
- export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTAttr> implements Attr {
4
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
5
+ import { MLToken } from '../token/token.js';
6
+ import { MLDomTokenList } from './dom-token-list.js';
7
+ import { MLNode } from './node.js';
8
+ export declare class MLAttr<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTAttr> implements Attr {
9
9
  #private;
10
10
  readonly candidate?: string;
11
11
  readonly endQuote: MLToken | null;
@@ -1,16 +1,16 @@
1
- "use strict";
2
1
  var _MLAttr_localName, _MLAttr_namespaceURI, _MLAttr_potentialName, _MLAttr_potentialValue;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MLAttr = void 0;
5
- const tslib_1 = require("tslib");
6
- const ml_spec_1 = require("@markuplint/ml-spec");
7
- const token_1 = require("../token/token");
8
- const dom_token_list_1 = require("./dom-token-list");
9
- const node_1 = require("./node");
10
- const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
11
- class MLAttr extends node_1.MLNode {
12
- constructor(astToken, ownElement) {
13
- var _a;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { resolveNamespace } from '@markuplint/ml-spec';
4
+ import { MLToken } from '../token/token.js';
5
+ import { MLDomTokenList } from './dom-token-list.js';
6
+ import { MLNode } from './node.js';
7
+ import UnexpectedCallError from './unexpected-call-error.js';
8
+ export class MLAttr extends MLNode {
9
+ constructor(
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ astToken,
12
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
+ ownElement) {
14
14
  super(astToken, ownElement.ownerMLDocument);
15
15
  this.endQuote = null;
16
16
  this.equal = null;
@@ -32,29 +32,29 @@ class MLAttr extends node_1.MLNode {
32
32
  */
33
33
  this.valueType = 'string';
34
34
  if (this._astToken.type === 'html-attr') {
35
- this.spacesBeforeName = new token_1.MLToken(this._astToken.spacesBeforeName);
36
- this.nameNode = new token_1.MLToken(this._astToken.name);
37
- this.spacesBeforeEqual = new token_1.MLToken(this._astToken.spacesBeforeEqual);
38
- this.equal = new token_1.MLToken(this._astToken.equal);
39
- this.spacesAfterEqual = new token_1.MLToken(this._astToken.spacesAfterEqual);
40
- this.startQuote = new token_1.MLToken(this._astToken.startQuote);
41
- this.valueNode = new token_1.MLToken(this._astToken.value);
42
- this.endQuote = new token_1.MLToken(this._astToken.endQuote);
35
+ this.spacesBeforeName = new MLToken(this._astToken.spacesBeforeName);
36
+ this.nameNode = new MLToken(this._astToken.name);
37
+ this.spacesBeforeEqual = new MLToken(this._astToken.spacesBeforeEqual);
38
+ this.equal = new MLToken(this._astToken.equal);
39
+ this.spacesAfterEqual = new MLToken(this._astToken.spacesAfterEqual);
40
+ this.startQuote = new MLToken(this._astToken.startQuote);
41
+ this.valueNode = new MLToken(this._astToken.value);
42
+ this.endQuote = new MLToken(this._astToken.endQuote);
43
43
  this.isDynamicValue = this._astToken.isDynamicValue;
44
44
  this.isDirective = this._astToken.isDirective;
45
45
  this.candidate = this._astToken.candidate;
46
- tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName || ((_a = this.nameNode) === null || _a === void 0 ? void 0 : _a.raw) || '', "f");
47
- tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw || '', "f");
46
+ __classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName ?? this.nameNode?.raw ?? '', "f");
47
+ __classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw ?? '', "f");
48
48
  }
49
49
  else {
50
50
  this.valueType = this._astToken.valueType;
51
51
  this.isDuplicatable = this._astToken.isDuplicatable;
52
- tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
53
- tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
52
+ __classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
53
+ __classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
54
54
  }
55
- const ns = (0, ml_spec_1.resolveNamespace)(tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f"), ownElement.namespaceURI);
56
- tslib_1.__classPrivateFieldSet(this, _MLAttr_localName, ns.localName, "f");
57
- tslib_1.__classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
55
+ const ns = resolveNamespace(__classPrivateFieldGet(this, _MLAttr_potentialName, "f"), ownElement.namespaceURI);
56
+ __classPrivateFieldSet(this, _MLAttr_localName, ns.localName, "f");
57
+ __classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
58
58
  this.ownerElement = ownElement;
59
59
  this.isDuplicatable = this._astToken.isDuplicatable;
60
60
  }
@@ -66,7 +66,7 @@ class MLAttr extends node_1.MLNode {
66
66
  * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
67
67
  */
68
68
  get localName() {
69
- return tslib_1.__classPrivateFieldGet(this, _MLAttr_localName, "f");
69
+ return __classPrivateFieldGet(this, _MLAttr_localName, "f");
70
70
  }
71
71
  /**
72
72
  *
@@ -74,7 +74,7 @@ class MLAttr extends node_1.MLNode {
74
74
  * @see https://dom.spec.whatwg.org/#dom-attr-name
75
75
  */
76
76
  get name() {
77
- return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f");
77
+ return __classPrivateFieldGet(this, _MLAttr_potentialName, "f");
78
78
  }
79
79
  /**
80
80
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -84,7 +84,7 @@ class MLAttr extends node_1.MLNode {
84
84
  * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
85
85
  */
86
86
  get namespaceURI() {
87
- return tslib_1.__classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
87
+ return __classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
88
88
  }
89
89
  /**
90
90
  * Returns a string appropriate for the type of node as `Attr`
@@ -111,7 +111,7 @@ class MLAttr extends node_1.MLNode {
111
111
  * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
112
112
  */
113
113
  get prefix() {
114
- throw new unexpected_call_error_1.default('Not supported "prefix" property');
114
+ throw new UnexpectedCallError('Not supported "prefix" property');
115
115
  }
116
116
  /**
117
117
  * @implements `@markuplint/ml-core` API: `MLAttr`
@@ -130,14 +130,14 @@ class MLAttr extends node_1.MLNode {
130
130
  * @implements `@markuplint/ml-core` API: `MLAttr`
131
131
  */
132
132
  get tokenList() {
133
- return this.isDynamicValue ? null : new dom_token_list_1.MLDomTokenList(this.value, [this]);
133
+ return this.isDynamicValue ? null : new MLDomTokenList(this.value, [this]);
134
134
  }
135
135
  /**
136
136
  * @implements DOM API: `Attr`
137
137
  * @see https://dom.spec.whatwg.org/#dom-attr-value
138
138
  */
139
139
  get value() {
140
- return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
140
+ return __classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
141
141
  }
142
142
  /**
143
143
  * @implements `@markuplint/ml-core` API: `MLAttr`
@@ -153,5 +153,4 @@ class MLAttr extends node_1.MLNode {
153
153
  return this.raw;
154
154
  }
155
155
  }
156
- exports.MLAttr = MLAttr;
157
156
  _MLAttr_localName = new WeakMap(), _MLAttr_namespaceURI = new WeakMap(), _MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
@@ -1,10 +1,10 @@
1
- import type { MLDocument } from './document';
2
- import type { MLElement } from './element';
3
- import type { MarkuplintPreprocessorBlockType } from './types';
1
+ import type { MLDocument } from './document.js';
2
+ import type { MLElement } from './element.js';
3
+ import type { MarkuplintPreprocessorBlockType } from './types.js';
4
4
  import type { MLASTPreprocessorSpecificBlock } from '@markuplint/ml-ast';
5
- import type { RuleConfigValue } from '@markuplint/ml-config';
6
- import { MLNode } from './node';
7
- export declare class MLBlock<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
5
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
6
+ import { MLNode } from './node.js';
7
+ export declare class MLBlock<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
8
8
  readonly isTransparent: boolean;
9
9
  constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
10
10
  /**
@@ -1,10 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MLBlock = void 0;
4
- const child_node_methods_1 = require("../manipulations/child-node-methods");
5
- const node_1 = require("./node");
6
- class MLBlock extends node_1.MLNode {
7
- constructor(astNode, document) {
1
+ import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
2
+ import { MLNode } from './node.js';
3
+ export class MLBlock extends MLNode {
4
+ constructor(
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ astNode,
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ document) {
8
9
  super(astNode, document);
9
10
  // TODO:
10
11
  this.isTransparent = true;
@@ -28,26 +29,31 @@ class MLBlock extends node_1.MLNode {
28
29
  /**
29
30
  * @implements DOM API: `ChildNode`
30
31
  */
31
- after(...nodes) {
32
- (0, child_node_methods_1.after)(this, ...nodes);
32
+ after(
33
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
34
+ ...nodes) {
35
+ after(this, ...nodes);
33
36
  }
34
37
  /**
35
38
  * @implements DOM API: `ChildNode`
36
39
  */
37
- before(...nodes) {
38
- (0, child_node_methods_1.before)(this, ...nodes);
40
+ before(
41
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
42
+ ...nodes) {
43
+ before(this, ...nodes);
39
44
  }
40
45
  /**
41
46
  * @implements DOM API: `ChildNode`
42
47
  */
43
48
  remove() {
44
- (0, child_node_methods_1.remove)(this);
49
+ remove(this);
45
50
  }
46
51
  /**
47
52
  * @implements DOM API: `ChildNode`
48
53
  */
49
- replaceWith(...nodes) {
50
- (0, child_node_methods_1.replaceWith)(this, ...nodes);
54
+ replaceWith(
55
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
56
+ ...nodes) {
57
+ replaceWith(this, ...nodes);
51
58
  }
52
59
  }
53
- exports.MLBlock = MLBlock;