@markuplint/ml-core 2.3.4 → 2.3.5

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 (47) hide show
  1. package/lib/ml-core.d.ts +1 -1
  2. package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
  3. package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
  4. package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
  5. package/lib/ml-dom/manipulations/get-children.js +10 -0
  6. package/lib/ml-dom/node/attr.d.ts +98 -0
  7. package/lib/ml-dom/node/attr.js +157 -0
  8. package/lib/ml-dom/node/block.d.ts +38 -0
  9. package/lib/ml-dom/node/block.js +53 -0
  10. package/lib/ml-dom/node/character-data.d.ts +57 -0
  11. package/lib/ml-dom/node/character-data.js +87 -0
  12. package/lib/ml-dom/node/child-node.d.ts +9 -0
  13. package/lib/ml-dom/node/child-node.js +10 -0
  14. package/lib/ml-dom/node/comment.d.ts +17 -0
  15. package/lib/ml-dom/node/comment.js +24 -0
  16. package/lib/ml-dom/node/document-fragment.d.ts +24 -0
  17. package/lib/ml-dom/node/document-fragment.js +33 -0
  18. package/lib/ml-dom/node/document-type.d.ts +38 -0
  19. package/lib/ml-dom/node/document-type.js +52 -0
  20. package/lib/ml-dom/node/document.d.ts +1599 -0
  21. package/lib/ml-dom/node/document.js +2172 -0
  22. package/lib/ml-dom/node/dom-token-list.d.ts +33 -0
  23. package/lib/ml-dom/node/dom-token-list.js +137 -0
  24. package/lib/ml-dom/node/element.d.ts +1900 -0
  25. package/lib/ml-dom/node/element.js +2683 -0
  26. package/lib/ml-dom/node/named-node-map.d.ts +42 -0
  27. package/lib/ml-dom/node/named-node-map.js +64 -0
  28. package/lib/ml-dom/node/node-list.d.ts +6 -0
  29. package/lib/ml-dom/node/node-list.js +39 -0
  30. package/lib/ml-dom/node/node-store.d.ts +14 -0
  31. package/lib/ml-dom/node/node-store.js +32 -0
  32. package/lib/ml-dom/node/node.d.ts +482 -0
  33. package/lib/ml-dom/node/node.js +675 -0
  34. package/lib/ml-dom/node/parent-node.d.ts +66 -0
  35. package/lib/ml-dom/node/parent-node.js +131 -0
  36. package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
  37. package/lib/ml-dom/node/rule-mapper.js +49 -0
  38. package/lib/ml-dom/node/text.d.ts +51 -0
  39. package/lib/ml-dom/node/text.js +76 -0
  40. package/lib/ml-dom/node/types.d.ts +35 -0
  41. package/lib/ml-dom/node/types.js +2 -0
  42. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -0
  43. package/lib/ml-dom/node/unexpected-call-error.js +5 -0
  44. package/lib/ml-dom/token/token.d.ts +47 -0
  45. package/lib/ml-dom/token/token.js +89 -0
  46. package/package.json +4 -4
  47. package/tsconfig.tsbuildinfo +1 -1
package/lib/ml-core.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare type MLCoreParams = {
10
10
  export declare class MLCore {
11
11
  #private;
12
12
  constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, filename, debug }: MLCoreParams);
13
- get document(): Document<RuleConfigValue, unknown> | ParserError;
13
+ get document(): ParserError | Document<RuleConfigValue, unknown>;
14
14
  verify(fix?: boolean): Promise<Violation[]>;
15
15
  setCode(sourceCode: string): void;
16
16
  update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
@@ -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
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MLCharacterData = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const child_node_methods_1 = require("../manipulations/child-node-methods");
6
+ const node_1 = require("./node");
7
+ const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
8
+ class MLCharacterData extends node_1.MLNode {
9
+ /**
10
+ * @implements DOM API: `CharacterData`
11
+ * @see https://dom.spec.whatwg.org/#dom-characterdata-data
12
+ */
13
+ get data() {
14
+ // TODO:
15
+ return this.raw;
16
+ }
17
+ /**
18
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
19
+ *
20
+ * @unsupported
21
+ * @implements DOM API: `CharacterData`
22
+ * @see https://dom.spec.whatwg.org/#dom-characterdata-length
23
+ */
24
+ get length() {
25
+ throw new unexpected_call_error_1.default('Not supported "length" property');
26
+ }
27
+ /**
28
+ * The element immediately following the specified one in its parent's children list.
29
+ *
30
+ * @readonly
31
+ * @implements DOM API: `CharacterData`
32
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A1
33
+ */
34
+ get nextElementSibling() {
35
+ return (0, child_node_methods_1.nextElementSibling)(this);
36
+ }
37
+ get nodeValue() {
38
+ return this.data;
39
+ }
40
+ /**
41
+ * The element immediately prior the specified one in its parent's children list.
42
+ *
43
+ * @readonly
44
+ * @implements DOM API: `CharacterData`
45
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A1
46
+ */
47
+ get previousElementSibling() {
48
+ return (0, child_node_methods_1.previousElementSibling)(this);
49
+ }
50
+ /**
51
+ * @implements DOM API: `CharacterData`
52
+ */
53
+ after(...nodes) {
54
+ (0, child_node_methods_1.after)(this, ...nodes);
55
+ }
56
+ // TODO
57
+ appendData(data) { }
58
+ /**
59
+ * @implements DOM API: `CharacterData`
60
+ */
61
+ before(...nodes) {
62
+ (0, child_node_methods_1.before)(this, ...nodes);
63
+ }
64
+ // TODO
65
+ deleteData(offset, count) { }
66
+ // TODO
67
+ insertData(offset, data) { }
68
+ /**
69
+ * @implements DOM API: `CharacterData`
70
+ */
71
+ remove() {
72
+ (0, child_node_methods_1.remove)(this);
73
+ }
74
+ // TODO
75
+ replaceData(offset, count, data) { }
76
+ /**
77
+ * @implements DOM API: `CharacterData`
78
+ */
79
+ replaceWith(...nodes) {
80
+ (0, child_node_methods_1.replaceWith)(this, ...nodes);
81
+ }
82
+ // TODO
83
+ substringData(offset, count) {
84
+ return '';
85
+ }
86
+ }
87
+ exports.MLCharacterData = MLCharacterData;
@@ -0,0 +1,9 @@
1
+ import type { MLBlock } from './block';
2
+ import type { MLCharacterData } from './character-data';
3
+ import type { MLDocumentType } from './document-type';
4
+ import type { MLElement } from './element';
5
+ import type { MLNode } from './node';
6
+ import type { MLText } from './text';
7
+ import type { RuleConfigValue } from '@markuplint/ml-config';
8
+ export type MLChildNode<T extends RuleConfigValue, O = null> = MLDocumentType<T, O> | MLCharacterData<T, O> | MLText<T, O> | MLElement<T, O> | MLBlock<T, O>;
9
+ export declare function isChildNode<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): node is MLChildNode<T, O>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isChildNode = void 0;
4
+ function isChildNode(node) {
5
+ return (node.is(node.DOCUMENT_TYPE_NODE) ||
6
+ node.is(node.TEXT_NODE) ||
7
+ node.is(node.ELEMENT_NODE) ||
8
+ node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK));
9
+ }
10
+ exports.isChildNode = isChildNode;
@@ -0,0 +1,17 @@
1
+ import type { CommentNodeType } from './types';
2
+ import type { MLASTComment } from '@markuplint/ml-ast';
3
+ import type { RuleConfigValue } from '@markuplint/ml-config';
4
+ import { MLCharacterData } from './character-data';
5
+ export declare class MLComment<T extends RuleConfigValue, O = null> extends MLCharacterData<T, O, MLASTComment> implements Comment {
6
+ /**
7
+ * Returns a string appropriate for the type of node as `Attr`
8
+ *
9
+ * @see https://dom.spec.whatwg.org/#ref-for-exclusive-text-node%E2%91%A0
10
+ */
11
+ get nodeName(): "#comment";
12
+ /**
13
+ * Returns a number appropriate for the type of `Comment`
14
+ */
15
+ get nodeType(): CommentNodeType;
16
+ get textContent(): string | null;
17
+ }