@markuplint/ml-core 3.0.0-alpha.66 → 3.0.0-dev.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/lib/configs.browser.d.ts +2 -0
- package/lib/configs.browser.js +12 -0
- package/lib/configs.js +5 -1
- package/lib/ml-core.d.ts +3 -3
- package/lib/ml-core.js +13 -7
- package/lib/ml-dom/helper/accname.d.ts +2 -1
- package/lib/ml-dom/helper/accname.js +51 -2
- package/lib/ml-dom/helper/create-node.d.ts +2 -2
- package/lib/ml-dom/helper/create-node.js +1 -1
- package/lib/ml-dom/helper/debug.js +1 -1
- package/lib/ml-dom/helper/getIndent.d.ts +1 -1
- package/lib/ml-dom/helper/walkers.d.ts +2 -2
- package/lib/ml-dom/index.d.ts +1 -0
- package/lib/ml-dom/node/attr.d.ts +5 -5
- package/lib/ml-dom/node/attr.js +18 -12
- package/lib/ml-dom/node/block.d.ts +1 -1
- package/lib/ml-dom/node/character-data.d.ts +2 -2
- package/lib/ml-dom/node/child-node.d.ts +1 -1
- package/lib/ml-dom/node/document-fragment.d.ts +2 -2
- package/lib/ml-dom/node/document-type.d.ts +1 -1
- package/lib/ml-dom/node/document.d.ts +66 -21
- package/lib/ml-dom/node/document.js +72 -17
- package/lib/ml-dom/node/dom-token-list.d.ts +3 -3
- package/lib/ml-dom/node/dom-token-list.js +6 -6
- package/lib/ml-dom/node/element.d.ts +105 -30
- package/lib/ml-dom/node/element.js +279 -58
- package/lib/ml-dom/node/node-list.d.ts +1 -1
- package/lib/ml-dom/node/node-store.d.ts +3 -3
- package/lib/ml-dom/node/node.d.ts +21 -14
- package/lib/ml-dom/node/node.js +38 -29
- package/lib/ml-dom/node/parent-node.d.ts +2 -2
- package/lib/ml-dom/node/rule-mapper.d.ts +2 -2
- package/lib/ml-dom/node/types.d.ts +25 -15
- package/lib/ml-dom/token/token.d.ts +1 -1
- package/lib/ml-rule/ml-rule-context.d.ts +2 -1
- package/lib/ml-rule/ml-rule-context.js +19 -2
- package/lib/ml-rule/ml-rule.d.ts +5 -5
- package/lib/ml-rule/ml-rule.js +11 -12
- package/lib/ml-rule/types.d.ts +7 -7
- package/lib/plugin/types.d.ts +3 -3
- package/lib/test/index.d.ts +3 -2
- package/lib/test/index.js +5 -3
- package/lib/types.d.ts +5 -4
- package/package.json +14 -12
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/ml-dom/document.d.ts +0 -94
- package/lib/ml-dom/document.js +0 -273
- package/lib/ml-dom/helper/index.d.ts +0 -4
- package/lib/ml-dom/helper/index.js +0 -12
- package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
- package/lib/ml-dom/helper/mapped-nodes.js +0 -2
- package/lib/ml-dom/helper/match-selector.d.ts +0 -20
- package/lib/ml-dom/helper/match-selector.js +0 -233
- package/lib/ml-dom/helper/node-store.d.ts +0 -12
- package/lib/ml-dom/helper/node-store.js +0 -28
- package/lib/ml-dom/helper/selector.d.ts +0 -11
- package/lib/ml-dom/helper/selector.js +0 -549
- package/lib/ml-dom/rule-mapper.d.ts +0 -16
- package/lib/ml-dom/rule-mapper.js +0 -57
- package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
- package/lib/ml-dom/tokens/abstract-element.js +0 -249
- package/lib/ml-dom/tokens/attribute.d.ts +0 -42
- package/lib/ml-dom/tokens/attribute.js +0 -85
- package/lib/ml-dom/tokens/comment.d.ts +0 -12
- package/lib/ml-dom/tokens/comment.js +0 -15
- package/lib/ml-dom/tokens/doctype.d.ts +0 -18
- package/lib/ml-dom/tokens/doctype.js +0 -32
- package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
- package/lib/ml-dom/tokens/element-close-tag.js +0 -45
- package/lib/ml-dom/tokens/element.d.ts +0 -26
- package/lib/ml-dom/tokens/element.js +0 -66
- package/lib/ml-dom/tokens/index.d.ts +0 -10
- package/lib/ml-dom/tokens/index.js +0 -26
- package/lib/ml-dom/tokens/node.d.ts +0 -46
- package/lib/ml-dom/tokens/node.js +0 -126
- package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
- package/lib/ml-dom/tokens/omitted-element.js +0 -12
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
- package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
- package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
- package/lib/ml-dom/tokens/text.d.ts +0 -19
- package/lib/ml-dom/tokens/text.js +0 -26
- package/lib/ml-dom/tokens/token.d.ts +0 -16
- package/lib/ml-dom/tokens/token.js +0 -55
- package/lib/ml-dom/types.d.ts +0 -49
- package/lib/ml-dom/types.js +0 -2
- package/lib/selector/is-pure-html-element.d.ts +0 -1
- package/lib/selector/is-pure-html-element.js +0 -7
- package/lib/selector/match-selector.d.ts +0 -14
- package/lib/selector/match-selector.js +0 -230
- package/lib/selector/selector.d.ts +0 -9
- package/lib/selector/selector.js +0 -561
package/README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# @markuplint/ml-core
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@markuplint/ml-core)
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [API Document](https://markuplint.dev/api-docs)
|
|
6
8
|
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
[`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package.
|
|
12
|
+
|
|
13
|
+
<details>
|
|
14
|
+
<summary>If you are installing purposely, how below:</summary>
|
|
15
|
+
|
|
16
|
+
```shell
|
|
10
17
|
$ npm install @markuplint/ml-core
|
|
11
18
|
|
|
12
19
|
$ yarn add @markuplint/ml-core
|
|
13
20
|
```
|
|
21
|
+
|
|
22
|
+
</details>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreset = void 0;
|
|
4
|
+
async function getPreset(name) {
|
|
5
|
+
const res = await fetch(`@markuplint/config-presets/preset.${name}.json`).catch(() => new Error());
|
|
6
|
+
if (res instanceof Error) {
|
|
7
|
+
throw new ReferenceError(`Preset markuplint:${name} is not found`);
|
|
8
|
+
}
|
|
9
|
+
const json = await res.json();
|
|
10
|
+
return json;
|
|
11
|
+
}
|
|
12
|
+
exports.getPreset = getPreset;
|
package/lib/configs.js
CHANGED
|
@@ -22,10 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var _a;
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
27
|
exports.getPreset = void 0;
|
|
27
28
|
async function getPreset(name) {
|
|
28
|
-
const json = await Promise.resolve().then(() => __importStar(require(
|
|
29
|
+
const json = await (_a = `@markuplint/config-presets/preset.${name}.json`, Promise.resolve().then(() => __importStar(require(_a)))).catch(() => new Error());
|
|
30
|
+
if (json instanceof Error) {
|
|
31
|
+
throw new ReferenceError(`Preset markuplint:${name} is not found`);
|
|
32
|
+
}
|
|
29
33
|
return json.default;
|
|
30
34
|
}
|
|
31
35
|
exports.getPreset = getPreset;
|
package/lib/ml-core.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ import type { MLFabric } from './types';
|
|
|
2
2
|
import type { RuleConfigValue, Violation } from '@markuplint/ml-config';
|
|
3
3
|
import { ParserError } from '@markuplint/parser-utils';
|
|
4
4
|
import { Document } from './ml-dom';
|
|
5
|
-
export
|
|
5
|
+
export type MLCoreParams = {
|
|
6
6
|
sourceCode: string;
|
|
7
7
|
filename: string;
|
|
8
8
|
debug?: boolean;
|
|
9
9
|
} & MLFabric;
|
|
10
10
|
export declare class MLCore {
|
|
11
11
|
#private;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }: MLCoreParams);
|
|
13
|
+
get document(): Document<RuleConfigValue, unknown> | ParserError;
|
|
14
14
|
setCode(sourceCode: string): void;
|
|
15
15
|
update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
|
|
16
16
|
verify(fix?: boolean): Promise<Violation[]>;
|
package/lib/ml-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _MLCore_ast, _MLCore_document, _MLCore_filename,
|
|
2
|
+
var _MLCore_ast, _MLCore_document, _MLCore_filename, _MLCore_locale, _MLCore_parser, _MLCore_parserOptions, _MLCore_pretenders, _MLCore_rules, _MLCore_ruleset, _MLCore_schemas, _MLCore_sourceCode;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MLCore = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -8,14 +8,15 @@ const debug_1 = require("./debug");
|
|
|
8
8
|
const ml_dom_1 = require("./ml-dom");
|
|
9
9
|
const resultLog = debug_1.log.extend('result');
|
|
10
10
|
class MLCore {
|
|
11
|
-
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, filename, debug }) {
|
|
11
|
+
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }) {
|
|
12
12
|
var _a, _b, _c;
|
|
13
13
|
_MLCore_ast.set(this, null);
|
|
14
14
|
_MLCore_document.set(this, void 0);
|
|
15
15
|
_MLCore_filename.set(this, void 0);
|
|
16
|
-
_MLCore_ignoreFrontMatter.set(this, void 0);
|
|
17
16
|
_MLCore_locale.set(this, void 0);
|
|
18
17
|
_MLCore_parser.set(this, void 0);
|
|
18
|
+
_MLCore_parserOptions.set(this, void 0);
|
|
19
|
+
_MLCore_pretenders.set(this, void 0);
|
|
19
20
|
_MLCore_rules.set(this, void 0);
|
|
20
21
|
_MLCore_ruleset.set(this, void 0);
|
|
21
22
|
_MLCore_schemas.set(this, void 0);
|
|
@@ -25,7 +26,7 @@ class MLCore {
|
|
|
25
26
|
}
|
|
26
27
|
tslib_1.__classPrivateFieldSet(this, _MLCore_parser, parser, "f");
|
|
27
28
|
tslib_1.__classPrivateFieldSet(this, _MLCore_sourceCode, sourceCode, "f");
|
|
28
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
29
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_parserOptions, parserOptions, "f");
|
|
29
30
|
tslib_1.__classPrivateFieldSet(this, _MLCore_ruleset, {
|
|
30
31
|
rules: (_a = ruleset.rules) !== null && _a !== void 0 ? _a : {},
|
|
31
32
|
nodeRules: (_b = ruleset.nodeRules) !== null && _b !== void 0 ? _b : [],
|
|
@@ -35,6 +36,7 @@ class MLCore {
|
|
|
35
36
|
tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas, "f");
|
|
36
37
|
tslib_1.__classPrivateFieldSet(this, _MLCore_filename, filename, "f");
|
|
37
38
|
tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules, "f");
|
|
39
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_pretenders, pretenders, "f");
|
|
38
40
|
this._parse();
|
|
39
41
|
this._createDocument();
|
|
40
42
|
}
|
|
@@ -57,7 +59,9 @@ class MLCore {
|
|
|
57
59
|
tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules !== null && rules !== void 0 ? rules : tslib_1.__classPrivateFieldGet(this, _MLCore_rules, "f"), "f");
|
|
58
60
|
tslib_1.__classPrivateFieldSet(this, _MLCore_locale, locale !== null && locale !== void 0 ? locale : tslib_1.__classPrivateFieldGet(this, _MLCore_locale, "f"), "f");
|
|
59
61
|
tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas !== null && schemas !== void 0 ? schemas : tslib_1.__classPrivateFieldGet(this, _MLCore_schemas, "f"), "f");
|
|
60
|
-
if (parserOptions &&
|
|
62
|
+
if (parserOptions &&
|
|
63
|
+
(parserOptions.ignoreFrontMatter !== tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f").ignoreFrontMatter ||
|
|
64
|
+
parserOptions.authoredElementName !== tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f").authoredElementName)) {
|
|
61
65
|
this._parse();
|
|
62
66
|
}
|
|
63
67
|
this._createDocument();
|
|
@@ -130,6 +134,8 @@ class MLCore {
|
|
|
130
134
|
tslib_1.__classPrivateFieldSet(this, _MLCore_document, new ml_dom_1.Document(tslib_1.__classPrivateFieldGet(this, _MLCore_ast, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_ruleset, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_schemas, "f"), {
|
|
131
135
|
filename: tslib_1.__classPrivateFieldGet(this, _MLCore_filename, "f"),
|
|
132
136
|
endTag: tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").endTag,
|
|
137
|
+
booleanish: tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").booleanish,
|
|
138
|
+
pretenders: tslib_1.__classPrivateFieldGet(this, _MLCore_pretenders, "f"),
|
|
133
139
|
}), "f");
|
|
134
140
|
}
|
|
135
141
|
catch (err) {
|
|
@@ -143,7 +149,7 @@ class MLCore {
|
|
|
143
149
|
}
|
|
144
150
|
_parse() {
|
|
145
151
|
try {
|
|
146
|
-
tslib_1.__classPrivateFieldSet(this, _MLCore_ast, tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").parse(tslib_1.__classPrivateFieldGet(this, _MLCore_sourceCode, "f"),
|
|
152
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_ast, tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").parse(tslib_1.__classPrivateFieldGet(this, _MLCore_sourceCode, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f")), "f");
|
|
147
153
|
}
|
|
148
154
|
catch (err) {
|
|
149
155
|
(0, debug_1.log)('Caught the parse error: %O', err);
|
|
@@ -158,4 +164,4 @@ class MLCore {
|
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
166
|
exports.MLCore = MLCore;
|
|
161
|
-
_MLCore_ast = new WeakMap(), _MLCore_document = new WeakMap(), _MLCore_filename = new WeakMap(),
|
|
167
|
+
_MLCore_ast = new WeakMap(), _MLCore_document = new WeakMap(), _MLCore_filename = new WeakMap(), _MLCore_locale = new WeakMap(), _MLCore_parser = new WeakMap(), _MLCore_parserOptions = new WeakMap(), _MLCore_pretenders = new WeakMap(), _MLCore_rules = new WeakMap(), _MLCore_ruleset = new WeakMap(), _MLCore_schemas = new WeakMap(), _MLCore_sourceCode = new WeakMap();
|
|
@@ -4,7 +4,35 @@ exports.getAccname = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const debug_1 = require("../../debug");
|
|
6
6
|
const accnameLog = debug_1.log.extend('accname');
|
|
7
|
-
function getAccname(el) {
|
|
7
|
+
function getAccname(el, version) {
|
|
8
|
+
let accname = safeGet(el);
|
|
9
|
+
if (accname) {
|
|
10
|
+
return accname;
|
|
11
|
+
}
|
|
12
|
+
accname = getAccnameFromPretender(el);
|
|
13
|
+
if (accname) {
|
|
14
|
+
return accname;
|
|
15
|
+
}
|
|
16
|
+
if (isHidden(el)) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
if (isFromContent(el, version)) {
|
|
20
|
+
return Array.from(el.childNodes)
|
|
21
|
+
.map(child => {
|
|
22
|
+
if (child.is(child.ELEMENT_NODE)) {
|
|
23
|
+
return getAccname(child, version);
|
|
24
|
+
}
|
|
25
|
+
if (child.is(child.TEXT_NODE)) {
|
|
26
|
+
return child.textContent || '';
|
|
27
|
+
}
|
|
28
|
+
return '';
|
|
29
|
+
})
|
|
30
|
+
.join('');
|
|
31
|
+
}
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
exports.getAccname = getAccname;
|
|
35
|
+
function safeGet(el) {
|
|
8
36
|
try {
|
|
9
37
|
const name = (0, ml_spec_1.getAccname)(el);
|
|
10
38
|
return name;
|
|
@@ -15,4 +43,25 @@ function getAccname(el) {
|
|
|
15
43
|
return '';
|
|
16
44
|
}
|
|
17
45
|
}
|
|
18
|
-
|
|
46
|
+
function getAccnameFromPretender(el) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (((_a = el.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' && ((_b = el.pretenderContext.aria) === null || _b === void 0 ? void 0 : _b.name)) {
|
|
49
|
+
if (typeof el.pretenderContext.aria.name === 'boolean') {
|
|
50
|
+
return 'some-name(Pretender Options)';
|
|
51
|
+
}
|
|
52
|
+
const attrName = el.pretenderContext.aria.name.fromAttr;
|
|
53
|
+
const attrValue = el.getAttributePretended(attrName);
|
|
54
|
+
if (attrValue) {
|
|
55
|
+
return attrValue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
function isHidden(el) {
|
|
61
|
+
return el.getAttribute('aria-hidden') === 'true' || el.hasAttribute('hidden');
|
|
62
|
+
}
|
|
63
|
+
function isFromContent(el, version) {
|
|
64
|
+
var _a;
|
|
65
|
+
const role = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, el, version);
|
|
66
|
+
return !!((_a = role.role) === null || _a === void 0 ? void 0 : _a.accessibleNameFromContent);
|
|
67
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MLDocument } from '../node/document';
|
|
2
2
|
import type { MappedNode } from '../node/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
4
4
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
-
export declare function createNode<N extends
|
|
5
|
+
export declare function createNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: N, document: MLDocument<T, O>): MappedNode<N, T, O>;
|
|
@@ -25,6 +25,6 @@ function createNode(astNode, document) {
|
|
|
25
25
|
return new text_1.MLText(_astNode, document);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
throw new TypeError(`Invalid AST node
|
|
28
|
+
throw new TypeError(`Invalid AST node types "${astNode.type}"`);
|
|
29
29
|
}
|
|
30
30
|
exports.createNode = createNode;
|
|
@@ -12,9 +12,9 @@ function nodeListToDebugMaps(nodeList, withAttr = false) {
|
|
|
12
12
|
r.push(tokenDebug(n));
|
|
13
13
|
if (n.is(n.ELEMENT_NODE)) {
|
|
14
14
|
r.push(` namespaceURI: ${!!n.namespaceURI}`);
|
|
15
|
+
r.push(` elementType: ${n.elementType}`);
|
|
15
16
|
r.push(` isInFragmentDocument: ${!!n.isInFragmentDocument}`);
|
|
16
17
|
r.push(` isForeignElement: ${!!n.isForeignElement}`);
|
|
17
|
-
r.push(` isCustomElement: ${!!n.isCustomElement}`);
|
|
18
18
|
if (withAttr) {
|
|
19
19
|
r.push(...attributesToDebugMaps(n.attributes)
|
|
20
20
|
.flat()
|
|
@@ -9,10 +9,10 @@ export declare function getIndent(node: MLNode<any, any>): MLDOMIndentation | nu
|
|
|
9
9
|
declare class MLDOMIndentation {
|
|
10
10
|
#private;
|
|
11
11
|
readonly line: number;
|
|
12
|
+
constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
|
|
12
13
|
get raw(): string;
|
|
13
14
|
get type(): 'tab' | 'space' | 'mixed' | 'none';
|
|
14
15
|
get width(): number;
|
|
15
|
-
constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
|
|
16
16
|
fix(raw: string): void;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MLNode } from '../node/node';
|
|
2
2
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
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
5
|
export declare function syncWalk<T extends RuleConfigValue, O = null>(nodeList: ReadonlyArray<MLNode<T, O>>, walker: SyncWalker<T, O>): void;
|
|
6
6
|
export declare function sequentialWalker<T extends RuleConfigValue, O = null, N = MLNode<T, O>>(list: ReadonlyArray<N>, walker: Walker<T, O, N>): Promise<void>;
|
package/lib/ml-dom/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export type { MLDocumentFragment as DocumentFragment } from './node/document-fra
|
|
|
5
5
|
export type { MLDocumentType as DocumentType } from './node/document-type';
|
|
6
6
|
export type { MLElement as Element } from './node/element';
|
|
7
7
|
export type { MLText as Text } from './node/text';
|
|
8
|
+
export type { MLChildNode as ChildNode } from './node/child-node';
|
|
8
9
|
export { MLDocument as Document } from './node/document';
|
|
@@ -31,6 +31,7 @@ export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<
|
|
|
31
31
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
32
32
|
*/
|
|
33
33
|
readonly valueType: 'string' | 'number' | 'boolean' | 'code';
|
|
34
|
+
constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
|
|
34
35
|
/**
|
|
35
36
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
36
37
|
*
|
|
@@ -81,16 +82,15 @@ export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<
|
|
|
81
82
|
* @see https://dom.spec.whatwg.org/#dom-attr-specified
|
|
82
83
|
*/
|
|
83
84
|
get specified(): true;
|
|
85
|
+
/**
|
|
86
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
87
|
+
*/
|
|
88
|
+
get tokenList(): MLDomTokenList | null;
|
|
84
89
|
/**
|
|
85
90
|
* @implements DOM API: `Attr`
|
|
86
91
|
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
87
92
|
*/
|
|
88
93
|
get value(): string;
|
|
89
|
-
/**
|
|
90
|
-
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
91
|
-
*/
|
|
92
|
-
get tokenList(): MLDomTokenList | null;
|
|
93
|
-
constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
|
|
94
94
|
/**
|
|
95
95
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
96
96
|
*/
|
package/lib/ml-dom/node/attr.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _MLAttr_potentialName, _MLAttr_potentialValue;
|
|
2
|
+
var _MLAttr_localName, _MLAttr_namespaceURI, _MLAttr_potentialName, _MLAttr_potentialValue;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MLAttr = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
6
7
|
const token_1 = require("../token/token");
|
|
7
8
|
const dom_token_list_1 = require("./dom-token-list");
|
|
8
9
|
const node_1 = require("./node");
|
|
@@ -11,11 +12,13 @@ class MLAttr extends node_1.MLNode {
|
|
|
11
12
|
constructor(astToken, ownElement) {
|
|
12
13
|
var _a;
|
|
13
14
|
super(astToken, ownElement.ownerMLDocument);
|
|
14
|
-
_MLAttr_potentialName.set(this, void 0);
|
|
15
|
-
_MLAttr_potentialValue.set(this, void 0);
|
|
16
15
|
this.endQuote = null;
|
|
17
16
|
this.equal = null;
|
|
17
|
+
_MLAttr_localName.set(this, void 0);
|
|
18
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);
|
|
19
22
|
this.spacesAfterEqual = null;
|
|
20
23
|
this.spacesBeforeEqual = null;
|
|
21
24
|
this.spacesBeforeName = null;
|
|
@@ -49,6 +52,9 @@ class MLAttr extends node_1.MLNode {
|
|
|
49
52
|
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
|
|
50
53
|
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
|
|
51
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");
|
|
52
58
|
this.ownerElement = ownElement;
|
|
53
59
|
this.isDuplicatable = this._astToken.isDuplicatable;
|
|
54
60
|
}
|
|
@@ -60,7 +66,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
60
66
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
|
|
61
67
|
*/
|
|
62
68
|
get localName() {
|
|
63
|
-
|
|
69
|
+
return tslib_1.__classPrivateFieldGet(this, _MLAttr_localName, "f");
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
*
|
|
@@ -78,7 +84,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
78
84
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
|
|
79
85
|
*/
|
|
80
86
|
get namespaceURI() {
|
|
81
|
-
|
|
87
|
+
return tslib_1.__classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
|
|
82
88
|
}
|
|
83
89
|
/**
|
|
84
90
|
* Returns a string appropriate for the type of node as `Attr`
|
|
@@ -120,6 +126,12 @@ class MLAttr extends node_1.MLNode {
|
|
|
120
126
|
get specified() {
|
|
121
127
|
return true;
|
|
122
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
|
+
}
|
|
123
135
|
/**
|
|
124
136
|
* @implements DOM API: `Attr`
|
|
125
137
|
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
@@ -127,12 +139,6 @@ class MLAttr extends node_1.MLNode {
|
|
|
127
139
|
get value() {
|
|
128
140
|
return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
|
|
129
141
|
}
|
|
130
|
-
/**
|
|
131
|
-
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
132
|
-
*/
|
|
133
|
-
get tokenList() {
|
|
134
|
-
return this.isDynamicValue ? null : new dom_token_list_1.MLDomTokenList(this.value, [this]);
|
|
135
|
-
}
|
|
136
142
|
/**
|
|
137
143
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
138
144
|
*/
|
|
@@ -148,4 +154,4 @@ class MLAttr extends node_1.MLNode {
|
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
156
|
exports.MLAttr = MLAttr;
|
|
151
|
-
_MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
|
|
157
|
+
_MLAttr_localName = new WeakMap(), _MLAttr_namespaceURI = new WeakMap(), _MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
|
|
@@ -6,6 +6,7 @@ import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
|
6
6
|
import { MLNode } from './node';
|
|
7
7
|
export declare class MLBlock<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
|
|
8
8
|
readonly isTransparent: boolean;
|
|
9
|
+
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
9
10
|
/**
|
|
10
11
|
* Returns a string appropriate for the type of node as `MLBlock`
|
|
11
12
|
*
|
|
@@ -18,7 +19,6 @@ export declare class MLBlock<T extends RuleConfigValue, O = null> extends MLNode
|
|
|
18
19
|
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
19
20
|
*/
|
|
20
21
|
get nodeType(): MarkuplintPreprocessorBlockType;
|
|
21
|
-
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
22
22
|
/**
|
|
23
23
|
* @implements DOM API: `ChildNode`
|
|
24
24
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MLElement } from './element';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLNode } from './node';
|
|
5
|
-
export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends
|
|
5
|
+
export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLNode<T, O, A> implements CharacterData {
|
|
6
6
|
/**
|
|
7
7
|
* @implements DOM API: `CharacterData`
|
|
8
8
|
* @see https://dom.spec.whatwg.org/#dom-characterdata-data
|
|
@@ -5,5 +5,5 @@ import type { MLElement } from './element';
|
|
|
5
5
|
import type { MLNode } from './node';
|
|
6
6
|
import type { MLText } from './text';
|
|
7
7
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
8
|
-
export
|
|
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
9
|
export declare function isChildNode<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): node is MLChildNode<T, O>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DocumentFragmentNodeType } from './types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLParentNode } from './parent-node';
|
|
5
|
-
export declare class MLDocumentFragment<T extends RuleConfigValue, O = null> extends MLParentNode<T, O,
|
|
5
|
+
export declare class MLDocumentFragment<T extends RuleConfigValue, O = null> extends MLParentNode<T, O, MLASTAbstractNode> implements DocumentFragment {
|
|
6
6
|
/**
|
|
7
7
|
* Returns a string appropriate for the type of node as `DocumentFragment`
|
|
8
8
|
*
|
|
@@ -8,6 +8,7 @@ export declare class MLDocumentType<T extends RuleConfigValue, O = null> extends
|
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly publicId: string;
|
|
10
10
|
readonly systemId: string;
|
|
11
|
+
constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
|
|
11
12
|
/**
|
|
12
13
|
* Returns a string appropriate for the type of node as `DocumentType`
|
|
13
14
|
*
|
|
@@ -18,7 +19,6 @@ export declare class MLDocumentType<T extends RuleConfigValue, O = null> extends
|
|
|
18
19
|
* Returns a number appropriate for the type of `DocumentType`
|
|
19
20
|
*/
|
|
20
21
|
get nodeType(): DocumentTypeNodeType;
|
|
21
|
-
constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
|
|
22
22
|
/**
|
|
23
23
|
* @implements DOM API: `CharacterData`
|
|
24
24
|
*/
|
|
@@ -9,20 +9,35 @@ import type { MLElement } from './element';
|
|
|
9
9
|
import type { MLNode } from './node';
|
|
10
10
|
import type { MLText } from './text';
|
|
11
11
|
import type { DocumentNodeType } from './types';
|
|
12
|
-
import type { MLASTDocument } from '@markuplint/ml-ast';
|
|
13
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
12
|
+
import type { EndTagType, MLASTDocument } from '@markuplint/ml-ast';
|
|
13
|
+
import type { Pretender, RuleConfigValue } from '@markuplint/ml-config';
|
|
14
14
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
15
15
|
import { MLParentNode } from './parent-node';
|
|
16
16
|
export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLParentNode<T, O> implements Document {
|
|
17
17
|
#private;
|
|
18
|
+
/**
|
|
19
|
+
* Detect value as a true if its attribute is booleanish value and omitted.
|
|
20
|
+
*
|
|
21
|
+
* Ex:
|
|
22
|
+
* ```jsx
|
|
23
|
+
* <Component aria-hidden />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* In the above, the `aria-hidden` is `true`.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
readonly booleanish: boolean;
|
|
18
31
|
/**
|
|
19
32
|
*
|
|
20
33
|
*/
|
|
21
34
|
currentRule: MLRule<T, O> | null;
|
|
22
35
|
/**
|
|
36
|
+
* This is defined by the parser.
|
|
23
37
|
*
|
|
38
|
+
* @default "omittable"
|
|
24
39
|
*/
|
|
25
|
-
readonly endTag:
|
|
40
|
+
readonly endTag: EndTagType;
|
|
26
41
|
/**
|
|
27
42
|
*
|
|
28
43
|
*/
|
|
@@ -39,6 +54,24 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
39
54
|
*
|
|
40
55
|
*/
|
|
41
56
|
readonly specs: Readonly<MLMLSpec>;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param ast node list of markuplint AST
|
|
60
|
+
* @param ruleset ruleset object
|
|
61
|
+
*/
|
|
62
|
+
constructor(ast: MLASTDocument, ruleset: Ruleset, schemas: readonly [MLMLSpec, ...ExtendedSpec[]], options?: {
|
|
63
|
+
filename?: string;
|
|
64
|
+
endTag?: 'xml' | 'omittable' | 'never';
|
|
65
|
+
booleanish?: boolean;
|
|
66
|
+
pretenders?: Pretender[];
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
70
|
+
*
|
|
71
|
+
* @unsupported
|
|
72
|
+
* @implements DOM API: `Document`
|
|
73
|
+
*/
|
|
74
|
+
get URL(): string;
|
|
42
75
|
/**
|
|
43
76
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
44
77
|
*
|
|
@@ -46,6 +79,13 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
46
79
|
* @implements DOM API: `Document`
|
|
47
80
|
*/
|
|
48
81
|
get activeElement(): Element | null;
|
|
82
|
+
/**
|
|
83
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
84
|
+
*
|
|
85
|
+
* @unsupported
|
|
86
|
+
* @implements DOM API: `Document`
|
|
87
|
+
*/
|
|
88
|
+
get adoptedStyleSheets(): CSSStyleSheet[];
|
|
49
89
|
/**
|
|
50
90
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
51
91
|
*
|
|
@@ -364,6 +404,14 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
364
404
|
* @implements DOM API: `Document`
|
|
365
405
|
*/
|
|
366
406
|
get onauxclick(): ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
407
|
+
/**
|
|
408
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
409
|
+
*
|
|
410
|
+
* @deprecated
|
|
411
|
+
* @unsupported
|
|
412
|
+
* @implements DOM API: `Document`
|
|
413
|
+
*/
|
|
414
|
+
get onbeforeinput(): ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
|
|
367
415
|
/**
|
|
368
416
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
369
417
|
*
|
|
@@ -372,6 +420,14 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
372
420
|
* @implements DOM API: `Document`
|
|
373
421
|
*/
|
|
374
422
|
get onblur(): ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
423
|
+
/**
|
|
424
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
425
|
+
*
|
|
426
|
+
* @deprecated
|
|
427
|
+
* @unsupported
|
|
428
|
+
* @implements DOM API: `Document`
|
|
429
|
+
*/
|
|
430
|
+
get oncancel(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
375
431
|
/**
|
|
376
432
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
377
433
|
*
|
|
@@ -1160,13 +1216,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1160
1216
|
* @implements DOM API: `Document`
|
|
1161
1217
|
*/
|
|
1162
1218
|
get title(): string;
|
|
1163
|
-
/**
|
|
1164
|
-
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1165
|
-
*
|
|
1166
|
-
* @unsupported
|
|
1167
|
-
* @implements DOM API: `Document`
|
|
1168
|
-
*/
|
|
1169
|
-
get URL(): string;
|
|
1170
1219
|
/**
|
|
1171
1220
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1172
1221
|
*
|
|
@@ -1182,15 +1231,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1182
1231
|
* @implements DOM API: `Document`
|
|
1183
1232
|
*/
|
|
1184
1233
|
get vlinkColor(): string;
|
|
1185
|
-
/**
|
|
1186
|
-
*
|
|
1187
|
-
* @param ast node list of markuplint AST
|
|
1188
|
-
* @param ruleset ruleset object
|
|
1189
|
-
*/
|
|
1190
|
-
constructor(ast: MLASTDocument, ruleset: Ruleset, schemas: readonly [MLMLSpec, ...ExtendedSpec[]], options?: {
|
|
1191
|
-
filename?: string;
|
|
1192
|
-
endTag?: 'xml' | 'omittable' | 'never';
|
|
1193
|
-
});
|
|
1194
1234
|
/**
|
|
1195
1235
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1196
1236
|
*
|
|
@@ -1297,14 +1337,14 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1297
1337
|
* @unsupported
|
|
1298
1338
|
* @implements DOM API: `Document`
|
|
1299
1339
|
*/
|
|
1300
|
-
|
|
1340
|
+
createNSResolver(nodeResolver: Node): XPathNSResolver;
|
|
1301
1341
|
/**
|
|
1302
1342
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1303
1343
|
*
|
|
1304
1344
|
* @unsupported
|
|
1305
1345
|
* @implements DOM API: `Document`
|
|
1306
1346
|
*/
|
|
1307
|
-
|
|
1347
|
+
createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter | null): NodeIterator;
|
|
1308
1348
|
/**
|
|
1309
1349
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1310
1350
|
*
|
|
@@ -1520,6 +1560,10 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1520
1560
|
* @implements DOM API: `Document`
|
|
1521
1561
|
*/
|
|
1522
1562
|
requestStorageAccess(): Promise<void>;
|
|
1563
|
+
/**
|
|
1564
|
+
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1565
|
+
*/
|
|
1566
|
+
searchNodeByLocation(line: number, col: number): MLNode<T, O, import("@markuplint/ml-ast").MLASTAbstractNode> | null;
|
|
1523
1567
|
/**
|
|
1524
1568
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1525
1569
|
*/
|
|
@@ -1550,5 +1594,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1550
1594
|
* @implements DOM API: `Document`
|
|
1551
1595
|
*/
|
|
1552
1596
|
writeln(...text: string[]): void;
|
|
1597
|
+
private _pretending;
|
|
1553
1598
|
private _ruleMapping;
|
|
1554
1599
|
}
|