@markuplint/ml-core 2.3.3 → 3.0.0-alpha.1

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 (113) hide show
  1. package/lib/configs.d.ts +1 -1
  2. package/lib/configs.js +29 -9
  3. package/lib/index.d.ts +8 -8
  4. package/lib/index.js +18 -10
  5. package/lib/ml-core.d.ts +3 -3
  6. package/lib/ml-core.js +48 -44
  7. package/lib/ml-dom/helper/accname.d.ts +3 -2
  8. package/lib/ml-dom/helper/accname.js +53 -5
  9. package/lib/ml-dom/helper/create-node.d.ts +4 -5
  10. package/lib/ml-dom/helper/create-node.js +12 -16
  11. package/lib/ml-dom/helper/debug.d.ts +2 -2
  12. package/lib/ml-dom/helper/debug.js +35 -21
  13. package/lib/ml-dom/helper/getIndent.d.ts +5 -5
  14. package/lib/ml-dom/helper/getIndent.js +14 -14
  15. package/lib/ml-dom/helper/walkers.d.ts +5 -4
  16. package/lib/ml-dom/helper/walkers.js +39 -3
  17. package/lib/ml-dom/index.d.ts +8 -3
  18. package/lib/ml-dom/index.js +3 -15
  19. package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
  20. package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
  21. package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
  22. package/lib/ml-dom/manipulations/get-children.js +10 -0
  23. package/lib/ml-dom/node/attr.d.ts +98 -0
  24. package/lib/ml-dom/node/attr.js +157 -0
  25. package/lib/ml-dom/node/block.d.ts +38 -0
  26. package/lib/ml-dom/node/block.js +53 -0
  27. package/lib/ml-dom/node/character-data.d.ts +57 -0
  28. package/lib/ml-dom/node/character-data.js +87 -0
  29. package/lib/ml-dom/node/child-node.d.ts +9 -0
  30. package/lib/ml-dom/node/child-node.js +10 -0
  31. package/lib/ml-dom/node/comment.d.ts +17 -0
  32. package/lib/ml-dom/node/comment.js +24 -0
  33. package/lib/ml-dom/node/document-fragment.d.ts +24 -0
  34. package/lib/ml-dom/node/document-fragment.js +33 -0
  35. package/lib/ml-dom/node/document-type.d.ts +38 -0
  36. package/lib/ml-dom/node/document-type.js +52 -0
  37. package/lib/ml-dom/node/document.d.ts +1563 -0
  38. package/lib/ml-dom/node/document.js +2140 -0
  39. package/lib/ml-dom/node/dom-token-list.d.ts +33 -0
  40. package/lib/ml-dom/node/dom-token-list.js +137 -0
  41. package/lib/ml-dom/node/element.d.ts +1844 -0
  42. package/lib/ml-dom/node/element.js +2601 -0
  43. package/lib/ml-dom/node/named-node-map.d.ts +42 -0
  44. package/lib/ml-dom/node/named-node-map.js +64 -0
  45. package/lib/ml-dom/node/node-list.d.ts +6 -0
  46. package/lib/ml-dom/node/node-list.js +39 -0
  47. package/lib/ml-dom/node/node-store.d.ts +14 -0
  48. package/lib/ml-dom/{helper → node}/node-store.js +8 -4
  49. package/lib/ml-dom/node/node.d.ts +482 -0
  50. package/lib/ml-dom/node/node.js +675 -0
  51. package/lib/ml-dom/node/parent-node.d.ts +66 -0
  52. package/lib/ml-dom/node/parent-node.js +131 -0
  53. package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
  54. package/lib/ml-dom/{rule-mapper.js → node/rule-mapper.js} +20 -28
  55. package/lib/ml-dom/node/text.d.ts +51 -0
  56. package/lib/ml-dom/node/text.js +76 -0
  57. package/lib/ml-dom/node/types.d.ts +35 -0
  58. package/lib/ml-dom/{types.js → node/types.js} +0 -0
  59. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -0
  60. package/lib/ml-dom/node/unexpected-call-error.js +5 -0
  61. package/lib/ml-dom/token/token.d.ts +47 -0
  62. package/lib/ml-dom/token/token.js +89 -0
  63. package/lib/ml-rule/ml-rule-context.d.ts +14 -10
  64. package/lib/ml-rule/ml-rule-context.js +29 -6
  65. package/lib/ml-rule/ml-rule.d.ts +12 -12
  66. package/lib/ml-rule/ml-rule.js +63 -63
  67. package/lib/ml-rule/types.d.ts +12 -2
  68. package/lib/ruleset/index.d.ts +2 -2
  69. package/lib/test/index.d.ts +3 -1
  70. package/lib/test/index.js +12 -5
  71. package/lib/types.d.ts +3 -2
  72. package/package.json +11 -10
  73. package/tsconfig.tsbuildinfo +1 -1
  74. package/lib/ml-dom/document.d.ts +0 -85
  75. package/lib/ml-dom/document.js +0 -273
  76. package/lib/ml-dom/helper/index.d.ts +0 -4
  77. package/lib/ml-dom/helper/index.js +0 -12
  78. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -4
  79. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  80. package/lib/ml-dom/helper/match-selector.d.ts +0 -16
  81. package/lib/ml-dom/helper/match-selector.js +0 -233
  82. package/lib/ml-dom/helper/node-store.d.ts +0 -9
  83. package/lib/ml-dom/helper/selector.d.ts +0 -11
  84. package/lib/ml-dom/helper/selector.js +0 -549
  85. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  86. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -49
  87. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  88. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  89. package/lib/ml-dom/tokens/attribute.js +0 -85
  90. package/lib/ml-dom/tokens/comment.d.ts +0 -9
  91. package/lib/ml-dom/tokens/comment.js +0 -15
  92. package/lib/ml-dom/tokens/doctype.d.ts +0 -15
  93. package/lib/ml-dom/tokens/doctype.js +0 -32
  94. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -24
  95. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  96. package/lib/ml-dom/tokens/element.d.ts +0 -23
  97. package/lib/ml-dom/tokens/element.js +0 -66
  98. package/lib/ml-dom/tokens/index.d.ts +0 -10
  99. package/lib/ml-dom/tokens/index.js +0 -26
  100. package/lib/ml-dom/tokens/node.d.ts +0 -39
  101. package/lib/ml-dom/tokens/node.js +0 -126
  102. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -10
  103. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  104. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  105. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  106. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -11
  107. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  108. package/lib/ml-dom/tokens/text.d.ts +0 -15
  109. package/lib/ml-dom/tokens/text.js +0 -26
  110. package/lib/ml-dom/tokens/token.d.ts +0 -16
  111. package/lib/ml-dom/tokens/token.js +0 -55
  112. package/lib/ml-dom/types.d.ts +0 -27
  113. package/markuplint-recommended.json +0 -196
@@ -1,5 +1,6 @@
1
- import type { AnonymousNode } from '../types';
1
+ import type { MLNode } from '../node/node';
2
2
  import type { RuleConfigValue } from '@markuplint/ml-config';
3
- export declare type Walker<T extends RuleConfigValue, O = null, N = AnonymousNode<T, O>> = (node: N) => void | Promise<void>;
4
- export declare type SyncWalker<T extends RuleConfigValue, O = null, N = AnonymousNode<T, O>> = (node: N) => void;
5
- export declare function syncWalk<T extends RuleConfigValue, O = null>(nodeList: AnonymousNode<T, O>[], walker: SyncWalker<T, O>): void;
3
+ export declare type Walker<T extends RuleConfigValue, O = null, N = MLNode<T, O>> = (node: N) => void | Promise<void> | Promise<void>[];
4
+ export declare 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,12 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncWalk = void 0;
3
+ exports.sequentialWalker = exports.syncWalk = void 0;
4
4
  function syncWalk(nodeList, walker) {
5
5
  for (const node of nodeList) {
6
- if (node.type === 'Element' || node.type === 'OmittedElement' || node.type === 'PSBlock') {
7
- syncWalk(node.childNodes, walker);
6
+ if (node.is(node.ELEMENT_NODE) || node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK)) {
7
+ syncWalk(Array.from(node.childNodes), walker);
8
8
  }
9
9
  walker(node);
10
10
  }
11
11
  }
12
12
  exports.syncWalk = syncWalk;
13
+ function sequentialWalker(list, walker) {
14
+ if (list.length === 0) {
15
+ return Promise.resolve();
16
+ }
17
+ /**
18
+ * The following pattern is used to ensure that all rules run sequentially,
19
+ * no matter it runs asynchronously or synchronously.
20
+ */
21
+ let _resolve;
22
+ let _reject;
23
+ const promise = new Promise((resolve, reject) => {
24
+ _resolve = resolve;
25
+ _reject = reject;
26
+ });
27
+ 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);
43
+ }
44
+ };
45
+ loop();
46
+ return promise;
47
+ }
48
+ exports.sequentialWalker = sequentialWalker;
@@ -1,3 +1,8 @@
1
- export { default as Document } from './document';
2
- export { AnonymousNode, NodeType } from './types';
3
- export { MLDOMAttribute as Attribute, MLDOMComment as Comment, MLDOMDoctype as Doctype, MLDOMElement as Element, MLDOMElementCloseTag as ElementCloseTag, MLDOMNode as Node, MLDOMOmittedElement as OmittedElement, MLDOMText as Text, } from './tokens';
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 { MLDocument as Document } from './node/document';
@@ -1,17 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Text = exports.OmittedElement = exports.Node = exports.ElementCloseTag = exports.Element = exports.Doctype = exports.Comment = exports.Attribute = exports.Document = void 0;
7
- var document_1 = require("./document");
8
- Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return __importDefault(document_1).default; } });
9
- var tokens_1 = require("./tokens");
10
- Object.defineProperty(exports, "Attribute", { enumerable: true, get: function () { return tokens_1.MLDOMAttribute; } });
11
- Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return tokens_1.MLDOMComment; } });
12
- Object.defineProperty(exports, "Doctype", { enumerable: true, get: function () { return tokens_1.MLDOMDoctype; } });
13
- Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return tokens_1.MLDOMElement; } });
14
- Object.defineProperty(exports, "ElementCloseTag", { enumerable: true, get: function () { return tokens_1.MLDOMElementCloseTag; } });
15
- Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return tokens_1.MLDOMNode; } });
16
- Object.defineProperty(exports, "OmittedElement", { enumerable: true, get: function () { return tokens_1.MLDOMOmittedElement; } });
17
- Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return tokens_1.MLDOMText; } });
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; } });
@@ -0,0 +1,33 @@
1
+ import type { MLElement } from '../node/element';
2
+ import type { MLNode } from '../node/node';
3
+ import type { RuleConfigValue } from '@markuplint/ml-config';
4
+ /**
5
+ *
6
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
7
+ */
8
+ export declare function before<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
9
+ /**
10
+ *
11
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
12
+ */
13
+ export declare function after<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
14
+ /**
15
+ *
16
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
17
+ */
18
+ export declare function replaceWith<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
19
+ /**
20
+ *
21
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
22
+ */
23
+ export declare function remove<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): void;
24
+ /**
25
+ *
26
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
27
+ */
28
+ export declare function previousElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
29
+ /**
30
+ *
31
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
32
+ */
33
+ export declare function nextElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
@@ -0,0 +1,73 @@
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"));
6
+ /**
7
+ *
8
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
9
+ */
10
+ function before(node, ...additionalNodes) {
11
+ throw new unexpected_call_error_1.default('Not supported "before" method');
12
+ }
13
+ exports.before = before;
14
+ /**
15
+ *
16
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
17
+ */
18
+ function after(node, ...additionalNodes) {
19
+ throw new unexpected_call_error_1.default('Not supported "after" method');
20
+ }
21
+ exports.after = after;
22
+ /**
23
+ *
24
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
25
+ */
26
+ function replaceWith(node, ...additionalNodes) {
27
+ throw new unexpected_call_error_1.default('Not supported "replaceWith" method');
28
+ }
29
+ exports.replaceWith = replaceWith;
30
+ /**
31
+ *
32
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
33
+ */
34
+ function remove(node) {
35
+ throw new unexpected_call_error_1.default('Not supported "remove" method');
36
+ }
37
+ exports.remove = remove;
38
+ /**
39
+ *
40
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
41
+ */
42
+ function previousElementSibling(node) {
43
+ var _a, _b;
44
+ let prevNode = node.prevNode;
45
+ while (prevNode) {
46
+ 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)) &&
48
+ prevNode.is(prevNode.ELEMENT_NODE)) {
49
+ return prevNode;
50
+ }
51
+ prevNode = prevNode.prevNode;
52
+ }
53
+ return null;
54
+ }
55
+ exports.previousElementSibling = previousElementSibling;
56
+ /**
57
+ *
58
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
59
+ */
60
+ function nextElementSibling(node) {
61
+ var _a, _b;
62
+ let nextNode = node.nextNode;
63
+ while (nextNode) {
64
+ 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)) &&
66
+ nextNode.is(nextNode.ELEMENT_NODE)) {
67
+ return nextNode;
68
+ }
69
+ nextNode = nextNode.nextNode;
70
+ }
71
+ return null;
72
+ }
73
+ exports.nextElementSibling = nextElementSibling;
@@ -0,0 +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>>;
@@ -0,0 +1,10 @@
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) => {
7
+ return child.nodeType === child.ELEMENT_NODE;
8
+ }));
9
+ }
10
+ exports.getChildren = getChildren;
@@ -0,0 +1,98 @@
1
+ import type { MLElement } from './element';
2
+ import type { AttributeNodeType } from './types';
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 {
9
+ #private;
10
+ readonly candidate?: string;
11
+ readonly endQuote: MLToken | null;
12
+ readonly equal: MLToken | null;
13
+ readonly isDirective?: true;
14
+ readonly isDuplicatable: boolean;
15
+ readonly isDynamicValue?: true;
16
+ readonly nameNode: MLToken | null;
17
+ /**
18
+ * @implements DOM API: `Attr`
19
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
20
+ */
21
+ readonly ownerElement: MLElement<T, O>;
22
+ readonly spacesAfterEqual: MLToken | null;
23
+ readonly spacesBeforeEqual: MLToken | null;
24
+ readonly spacesBeforeName: MLToken | null;
25
+ readonly startQuote: MLToken | null;
26
+ readonly valueNode: MLToken | null;
27
+ /**
28
+ * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
29
+ *
30
+ * @default "string"
31
+ * @implements `@markuplint/ml-core` API: `MLAttr`
32
+ */
33
+ readonly valueType: 'string' | 'number' | 'boolean' | 'code';
34
+ constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
35
+ /**
36
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
37
+ *
38
+ * @unsupported
39
+ * @implements DOM API: `Attr`
40
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
41
+ */
42
+ get localName(): string;
43
+ /**
44
+ *
45
+ * @implements DOM API: `Attr`
46
+ * @see https://dom.spec.whatwg.org/#dom-attr-name
47
+ */
48
+ get name(): string;
49
+ /**
50
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
51
+ *
52
+ * @unsupported
53
+ * @implements DOM API: `Attr`
54
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
55
+ */
56
+ get namespaceURI(): string | null;
57
+ /**
58
+ * Returns a string appropriate for the type of node as `Attr`
59
+ *
60
+ * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
61
+ */
62
+ get nodeName(): string;
63
+ /**
64
+ * Returns a number appropriate for the type of `Attr`
65
+ */
66
+ get nodeType(): AttributeNodeType;
67
+ get nodeValue(): string;
68
+ /**
69
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
70
+ *
71
+ * @unsupported
72
+ * @implements DOM API: `Attr`
73
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
74
+ */
75
+ get prefix(): string | null;
76
+ /**
77
+ * @implements `@markuplint/ml-core` API: `MLAttr`
78
+ */
79
+ get rule(): import("@markuplint/ml-config").RuleInfo<T, O>;
80
+ /**
81
+ * @implements DOM API: `Attr`
82
+ * @see https://dom.spec.whatwg.org/#dom-attr-specified
83
+ */
84
+ get specified(): true;
85
+ /**
86
+ * @implements `@markuplint/ml-core` API: `MLAttr`
87
+ */
88
+ get tokenList(): MLDomTokenList | null;
89
+ /**
90
+ * @implements DOM API: `Attr`
91
+ * @see https://dom.spec.whatwg.org/#dom-attr-value
92
+ */
93
+ get value(): string;
94
+ /**
95
+ * @implements `@markuplint/ml-core` API: `MLAttr`
96
+ */
97
+ toNormalizeString(): string;
98
+ }
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ 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;
14
+ super(astToken, ownElement.ownerMLDocument);
15
+ this.endQuote = null;
16
+ this.equal = null;
17
+ _MLAttr_localName.set(this, void 0);
18
+ this.nameNode = null;
19
+ _MLAttr_namespaceURI.set(this, void 0);
20
+ _MLAttr_potentialName.set(this, void 0);
21
+ _MLAttr_potentialValue.set(this, void 0);
22
+ this.spacesAfterEqual = null;
23
+ this.spacesBeforeEqual = null;
24
+ this.spacesBeforeName = null;
25
+ this.startQuote = null;
26
+ this.valueNode = null;
27
+ /**
28
+ * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
29
+ *
30
+ * @default "string"
31
+ * @implements `@markuplint/ml-core` API: `MLAttr`
32
+ */
33
+ this.valueType = 'string';
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);
43
+ this.isDynamicValue = this._astToken.isDynamicValue;
44
+ this.isDirective = this._astToken.isDirective;
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");
48
+ }
49
+ else {
50
+ this.valueType = this._astToken.valueType;
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");
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");
58
+ this.ownerElement = ownElement;
59
+ this.isDuplicatable = this._astToken.isDuplicatable;
60
+ }
61
+ /**
62
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
63
+ *
64
+ * @unsupported
65
+ * @implements DOM API: `Attr`
66
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
67
+ */
68
+ get localName() {
69
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_localName, "f");
70
+ }
71
+ /**
72
+ *
73
+ * @implements DOM API: `Attr`
74
+ * @see https://dom.spec.whatwg.org/#dom-attr-name
75
+ */
76
+ get name() {
77
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f");
78
+ }
79
+ /**
80
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
81
+ *
82
+ * @unsupported
83
+ * @implements DOM API: `Attr`
84
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
85
+ */
86
+ get namespaceURI() {
87
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
88
+ }
89
+ /**
90
+ * Returns a string appropriate for the type of node as `Attr`
91
+ *
92
+ * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
93
+ */
94
+ get nodeName() {
95
+ return this.name;
96
+ }
97
+ /**
98
+ * Returns a number appropriate for the type of `Attr`
99
+ */
100
+ get nodeType() {
101
+ return this.ATTRIBUTE_NODE;
102
+ }
103
+ get nodeValue() {
104
+ return this.value;
105
+ }
106
+ /**
107
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
108
+ *
109
+ * @unsupported
110
+ * @implements DOM API: `Attr`
111
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
112
+ */
113
+ get prefix() {
114
+ throw new unexpected_call_error_1.default('Not supported "prefix" property');
115
+ }
116
+ /**
117
+ * @implements `@markuplint/ml-core` API: `MLAttr`
118
+ */
119
+ get rule() {
120
+ return this.ownerElement.rule;
121
+ }
122
+ /**
123
+ * @implements DOM API: `Attr`
124
+ * @see https://dom.spec.whatwg.org/#dom-attr-specified
125
+ */
126
+ get specified() {
127
+ return true;
128
+ }
129
+ /**
130
+ * @implements `@markuplint/ml-core` API: `MLAttr`
131
+ */
132
+ get tokenList() {
133
+ return this.isDynamicValue ? null : new dom_token_list_1.MLDomTokenList(this.value, [this]);
134
+ }
135
+ /**
136
+ * @implements DOM API: `Attr`
137
+ * @see https://dom.spec.whatwg.org/#dom-attr-value
138
+ */
139
+ get value() {
140
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
141
+ }
142
+ /**
143
+ * @implements `@markuplint/ml-core` API: `MLAttr`
144
+ */
145
+ toNormalizeString() {
146
+ if (this.nameNode && this.equal && this.startQuote && this.valueNode && this.endQuote) {
147
+ return (this.nameNode.originRaw +
148
+ this.equal.originRaw +
149
+ this.startQuote.originRaw +
150
+ this.valueNode.originRaw +
151
+ this.endQuote.originRaw);
152
+ }
153
+ return this.raw;
154
+ }
155
+ }
156
+ exports.MLAttr = MLAttr;
157
+ _MLAttr_localName = new WeakMap(), _MLAttr_namespaceURI = new WeakMap(), _MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
@@ -0,0 +1,38 @@
1
+ import type { MLDocument } from './document';
2
+ import type { MLElement } from './element';
3
+ import type { MarkuplintPreprocessorBlockType } from './types';
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> {
8
+ readonly isTransparent: boolean;
9
+ constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
10
+ /**
11
+ * Returns a string appropriate for the type of node as `MLBlock`
12
+ *
13
+ * @implements `@markuplint/ml-core` API: `MLBlock`
14
+ */
15
+ get nodeName(): "#ml-block";
16
+ /**
17
+ * Returns a number appropriate for the type of `MLBlock`
18
+ *
19
+ * @implements `@markuplint/ml-core` API: `MLBlock`
20
+ */
21
+ get nodeType(): MarkuplintPreprocessorBlockType;
22
+ /**
23
+ * @implements DOM API: `ChildNode`
24
+ */
25
+ after(...nodes: (string | MLElement<any, any>)[]): void;
26
+ /**
27
+ * @implements DOM API: `ChildNode`
28
+ */
29
+ before(...nodes: (string | MLElement<any, any>)[]): void;
30
+ /**
31
+ * @implements DOM API: `ChildNode`
32
+ */
33
+ remove(): void;
34
+ /**
35
+ * @implements DOM API: `ChildNode`
36
+ */
37
+ replaceWith(...nodes: (string | MLElement<any, any>)[]): void;
38
+ }
@@ -0,0 +1,53 @@
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) {
8
+ super(astNode, document);
9
+ // TODO:
10
+ this.isTransparent = true;
11
+ }
12
+ /**
13
+ * Returns a string appropriate for the type of node as `MLBlock`
14
+ *
15
+ * @implements `@markuplint/ml-core` API: `MLBlock`
16
+ */
17
+ get nodeName() {
18
+ return '#ml-block';
19
+ }
20
+ /**
21
+ * Returns a number appropriate for the type of `MLBlock`
22
+ *
23
+ * @implements `@markuplint/ml-core` API: `MLBlock`
24
+ */
25
+ get nodeType() {
26
+ return this.MARKUPLINT_PREPROCESSOR_BLOCK;
27
+ }
28
+ /**
29
+ * @implements DOM API: `ChildNode`
30
+ */
31
+ after(...nodes) {
32
+ (0, child_node_methods_1.after)(this, ...nodes);
33
+ }
34
+ /**
35
+ * @implements DOM API: `ChildNode`
36
+ */
37
+ before(...nodes) {
38
+ (0, child_node_methods_1.before)(this, ...nodes);
39
+ }
40
+ /**
41
+ * @implements DOM API: `ChildNode`
42
+ */
43
+ remove() {
44
+ (0, child_node_methods_1.remove)(this);
45
+ }
46
+ /**
47
+ * @implements DOM API: `ChildNode`
48
+ */
49
+ replaceWith(...nodes) {
50
+ (0, child_node_methods_1.replaceWith)(this, ...nodes);
51
+ }
52
+ }
53
+ exports.MLBlock = MLBlock;
@@ -0,0 +1,57 @@
1
+ import type { MLElement } from './element';
2
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
3
+ import type { RuleConfigValue } from '@markuplint/ml-config';
4
+ import { MLNode } from './node';
5
+ export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLNode<T, O, A> implements CharacterData {
6
+ /**
7
+ * @implements DOM API: `CharacterData`
8
+ * @see https://dom.spec.whatwg.org/#dom-characterdata-data
9
+ */
10
+ get data(): string;
11
+ /**
12
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
13
+ *
14
+ * @unsupported
15
+ * @implements DOM API: `CharacterData`
16
+ * @see https://dom.spec.whatwg.org/#dom-characterdata-length
17
+ */
18
+ get length(): number;
19
+ /**
20
+ * The element immediately following the specified one in its parent's children list.
21
+ *
22
+ * @readonly
23
+ * @implements DOM API: `CharacterData`
24
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A1
25
+ */
26
+ get nextElementSibling(): MLElement<T, O> | null;
27
+ get nodeValue(): string | null;
28
+ /**
29
+ * The element immediately prior the specified one in its parent's children list.
30
+ *
31
+ * @readonly
32
+ * @implements DOM API: `CharacterData`
33
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A1
34
+ */
35
+ get previousElementSibling(): MLElement<T, O> | null;
36
+ /**
37
+ * @implements DOM API: `CharacterData`
38
+ */
39
+ after(...nodes: (string | MLElement<any, any>)[]): void;
40
+ appendData(data: string): void;
41
+ /**
42
+ * @implements DOM API: `CharacterData`
43
+ */
44
+ before(...nodes: (string | MLElement<any, any>)[]): void;
45
+ deleteData(offset: number, count: number): void;
46
+ insertData(offset: number, data: string): void;
47
+ /**
48
+ * @implements DOM API: `CharacterData`
49
+ */
50
+ remove(): void;
51
+ replaceData(offset: number, count: number, data: string): void;
52
+ /**
53
+ * @implements DOM API: `CharacterData`
54
+ */
55
+ replaceWith(...nodes: (string | MLElement<any, any>)[]): void;
56
+ substringData(offset: number, count: number): string;
57
+ }