@markuplint/ml-core 3.11.0 → 4.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.
- package/lib/configs.browser.js +1 -5
- package/lib/configs.js +33 -30
- package/lib/convert-ruleset.d.ts +1 -1
- package/lib/convert-ruleset.js +3 -8
- package/lib/debug.js +9 -14
- package/lib/index.d.ts +12 -12
- package/lib/index.js +13 -29
- package/lib/ml-core.d.ts +2 -2
- package/lib/ml-core.js +60 -66
- package/lib/ml-dom/helper/accname.d.ts +1 -1
- package/lib/ml-dom/helper/accname.js +9 -16
- package/lib/ml-dom/helper/create-node.d.ts +2 -2
- package/lib/ml-dom/helper/create-node.js +11 -15
- package/lib/ml-dom/helper/debug.d.ts +1 -1
- package/lib/ml-dom/helper/debug.js +2 -7
- package/lib/ml-dom/helper/getIndent.d.ts +2 -2
- package/lib/ml-dom/helper/getIndent.js +15 -19
- package/lib/ml-dom/helper/walkers.d.ts +1 -1
- package/lib/ml-dom/helper/walkers.js +2 -7
- package/lib/ml-dom/index.d.ts +9 -9
- package/lib/ml-dom/index.js +1 -5
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +2 -2
- package/lib/ml-dom/manipulations/child-node-methods.js +13 -25
- package/lib/ml-dom/manipulations/get-children.d.ts +2 -2
- package/lib/ml-dom/manipulations/get-children.js +3 -7
- package/lib/ml-dom/node/attr.d.ts +5 -5
- package/lib/ml-dom/node/attr.js +28 -33
- package/lib/ml-dom/node/block.d.ts +4 -4
- package/lib/ml-dom/node/block.js +7 -11
- package/lib/ml-dom/node/character-data.d.ts +2 -2
- package/lib/ml-dom/node/character-data.js +11 -16
- package/lib/ml-dom/node/child-node.d.ts +6 -6
- package/lib/ml-dom/node/child-node.js +1 -5
- package/lib/ml-dom/node/comment.d.ts +2 -2
- package/lib/ml-dom/node/comment.js +2 -6
- package/lib/ml-dom/node/document-fragment.d.ts +2 -2
- package/lib/ml-dom/node/document-fragment.js +4 -9
- package/lib/ml-dom/node/document-type.d.ts +4 -4
- package/lib/ml-dom/node/document-type.js +7 -11
- package/lib/ml-dom/node/document.d.ts +13 -13
- package/lib/ml-dom/node/document.js +233 -241
- package/lib/ml-dom/node/dom-token-list.d.ts +1 -1
- package/lib/ml-dom/node/dom-token-list.js +25 -31
- package/lib/ml-dom/node/element.d.ts +8 -8
- package/lib/ml-dom/node/element.js +278 -296
- package/lib/ml-dom/node/named-node-map.d.ts +1 -1
- package/lib/ml-dom/node/named-node-map.js +10 -18
- package/lib/ml-dom/node/node-list.d.ts +2 -2
- package/lib/ml-dom/node/node-list.js +6 -14
- package/lib/ml-dom/node/node-store.d.ts +2 -2
- package/lib/ml-dom/node/node-store.js +9 -12
- package/lib/ml-dom/node/node.d.ts +8 -8
- package/lib/ml-dom/node/node.js +58 -66
- package/lib/ml-dom/node/parent-node.d.ts +2 -2
- package/lib/ml-dom/node/parent-node.js +22 -29
- package/lib/ml-dom/node/rule-mapper.d.ts +2 -2
- package/lib/ml-dom/node/rule-mapper.js +11 -16
- package/lib/ml-dom/node/text.d.ts +2 -2
- package/lib/ml-dom/node/text.js +6 -11
- package/lib/ml-dom/node/types.d.ts +10 -10
- package/lib/ml-dom/node/types.js +1 -2
- package/lib/ml-dom/node/unexpected-call-error.js +1 -4
- package/lib/ml-dom/token/token.js +19 -23
- package/lib/ml-rule/create-rule.d.ts +1 -1
- package/lib/ml-rule/create-rule.js +1 -5
- package/lib/ml-rule/create-test-rule.d.ts +2 -2
- package/lib/ml-rule/create-test-rule.js +3 -7
- package/lib/ml-rule/index.d.ts +3 -3
- package/lib/ml-rule/index.js +3 -6
- package/lib/ml-rule/ml-rule-context.d.ts +2 -2
- package/lib/ml-rule/ml-rule-context.js +7 -11
- package/lib/ml-rule/ml-rule.d.ts +3 -3
- package/lib/ml-rule/ml-rule.js +23 -30
- package/lib/ml-rule/types.d.ts +2 -2
- package/lib/ml-rule/types.js +1 -2
- package/lib/plugin/index.d.ts +2 -2
- package/lib/plugin/index.js +2 -5
- package/lib/plugin/plugin.d.ts +1 -1
- package/lib/plugin/plugin.js +1 -5
- package/lib/plugin/types.d.ts +1 -1
- package/lib/plugin/types.js +1 -2
- package/lib/ruleset/index.js +4 -8
- package/lib/test/index.d.ts +4 -4
- package/lib/test/index.js +13 -23
- package/lib/types.d.ts +2 -2
- package/lib/types.js +1 -2
- package/lib/utils/get-location-from-chars.js +1 -5
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -5
- package/lib/utils/string-splice.js +1 -5
- package/package.json +20 -15
- package/test/ml-dom/helper/accname.spec.js +0 -85
- package/test/ml-dom/helper/create-node.spec.js +0 -18
- package/test/ml-dom/index.spec.js +0 -680
- package/test/ml-dom/ml-rule/create-rule.spec.js +0 -108
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLParentNode_children, _MLParentNode_selectedElements;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const node_list_1 = require("./node-list");
|
|
10
|
-
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import { syncWalk } from '../helper/walkers.js';
|
|
4
|
+
import { getChildren } from '../manipulations/get-children.js';
|
|
5
|
+
import { toNodeList } from './node-list.js';
|
|
6
|
+
import { MLNode } from './node.js';
|
|
7
|
+
import UnexpectedCallError from './unexpected-call-error.js';
|
|
11
8
|
/**
|
|
12
9
|
*
|
|
13
10
|
* @see https://dom.spec.whatwg.org/#interface-parentnode
|
|
14
11
|
*/
|
|
15
|
-
class MLParentNode extends
|
|
12
|
+
export class MLParentNode extends MLNode {
|
|
16
13
|
constructor() {
|
|
17
14
|
super(...arguments);
|
|
18
15
|
/**
|
|
@@ -36,28 +33,26 @@ class MLParentNode extends node_1.MLNode {
|
|
|
36
33
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-children%E2%91%A0
|
|
37
34
|
*/
|
|
38
35
|
get children() {
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
36
|
+
if (__classPrivateFieldGet(this, _MLParentNode_children, "f")) {
|
|
37
|
+
return __classPrivateFieldGet(this, _MLParentNode_children, "f");
|
|
41
38
|
}
|
|
42
|
-
const children =
|
|
43
|
-
|
|
44
|
-
return
|
|
39
|
+
const children = getChildren(this);
|
|
40
|
+
__classPrivateFieldSet(this, _MLParentNode_children, children, "f");
|
|
41
|
+
return __classPrivateFieldGet(this, _MLParentNode_children, "f");
|
|
45
42
|
}
|
|
46
43
|
/**
|
|
47
44
|
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
48
45
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-firstelementchild%E2%91%A0
|
|
49
46
|
*/
|
|
50
47
|
get firstElementChild() {
|
|
51
|
-
|
|
52
|
-
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|
48
|
+
return this.children[0] ?? null;
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
51
|
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
56
52
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-lastelementchild%E2%91%A0
|
|
57
53
|
*/
|
|
58
54
|
get lastElementChild() {
|
|
59
|
-
|
|
60
|
-
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|
55
|
+
return this.children[0] ?? null;
|
|
61
56
|
}
|
|
62
57
|
/**
|
|
63
58
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -69,7 +64,7 @@ class MLParentNode extends node_1.MLNode {
|
|
|
69
64
|
append(
|
|
70
65
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
71
66
|
...nodes) {
|
|
72
|
-
throw new
|
|
67
|
+
throw new UnexpectedCallError('Not supported "append" method');
|
|
73
68
|
}
|
|
74
69
|
/**
|
|
75
70
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -81,32 +76,31 @@ class MLParentNode extends node_1.MLNode {
|
|
|
81
76
|
prepend(
|
|
82
77
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
83
78
|
...nodes) {
|
|
84
|
-
throw new
|
|
79
|
+
throw new UnexpectedCallError('Not supported "prepend" method');
|
|
85
80
|
}
|
|
86
81
|
/**
|
|
87
82
|
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
88
83
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
|
|
89
84
|
*/
|
|
90
85
|
querySelector(selectors) {
|
|
91
|
-
var _a;
|
|
92
86
|
const selected = this.querySelectorAll(selectors);
|
|
93
|
-
return
|
|
87
|
+
return selected[0] ?? null;
|
|
94
88
|
}
|
|
95
89
|
/**
|
|
96
90
|
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
97
91
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselectorall%E2%91%A0
|
|
98
92
|
*/
|
|
99
93
|
querySelectorAll(selectors) {
|
|
100
|
-
const selected =
|
|
94
|
+
const selected = __classPrivateFieldGet(this, _MLParentNode_selectedElements, "f").get(selectors);
|
|
101
95
|
if (selected) {
|
|
102
96
|
return selected;
|
|
103
97
|
}
|
|
104
|
-
const elements =
|
|
98
|
+
const elements = toNodeList(this._descendantsToArray(node => {
|
|
105
99
|
if (node.is(node.ELEMENT_NODE) && node.matches(selectors)) {
|
|
106
100
|
return node;
|
|
107
101
|
}
|
|
108
102
|
}));
|
|
109
|
-
|
|
103
|
+
__classPrivateFieldGet(this, _MLParentNode_selectedElements, "f").set(selectors, elements);
|
|
110
104
|
return elements;
|
|
111
105
|
}
|
|
112
106
|
/**
|
|
@@ -119,11 +113,11 @@ class MLParentNode extends node_1.MLNode {
|
|
|
119
113
|
replaceChildren(
|
|
120
114
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
121
115
|
...nodes) {
|
|
122
|
-
throw new
|
|
116
|
+
throw new UnexpectedCallError('Not supported "replaceChildren" method');
|
|
123
117
|
}
|
|
124
118
|
_descendantsToArray(filter) {
|
|
125
119
|
const nodeList = [];
|
|
126
|
-
|
|
120
|
+
syncWalk(Array.from(this.childNodes), node => {
|
|
127
121
|
if (filter) {
|
|
128
122
|
const filtered = filter(node);
|
|
129
123
|
if (filtered) {
|
|
@@ -136,5 +130,4 @@ class MLParentNode extends node_1.MLNode {
|
|
|
136
130
|
return Object.freeze(nodeList);
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
|
-
exports.MLParentNode = MLParentNode;
|
|
140
133
|
_MLParentNode_children = new WeakMap(), _MLParentNode_selectedElements = new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MLDocument } from './document';
|
|
2
|
-
import type { MLNode } from './node';
|
|
1
|
+
import type { MLDocument } from './document.js';
|
|
2
|
+
import type { MLNode } from './node.js';
|
|
3
3
|
import type { AnyRule } from '@markuplint/ml-config';
|
|
4
4
|
import type { Specificity } from '@markuplint/selector';
|
|
5
5
|
type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _RuleMapper_nodeList, _RuleMapper_ruleMap;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const debug_1 = require("../../debug");
|
|
8
|
-
const ruleMapperLog = debug_1.log.extend('rule-mapper');
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import { compareSpecificity } from '@markuplint/selector';
|
|
4
|
+
import { log as coreLog } from '../../debug.js';
|
|
5
|
+
const ruleMapperLog = coreLog.extend('rule-mapper');
|
|
9
6
|
const ruleMapperNodeLog = ruleMapperLog.extend('node');
|
|
10
7
|
const ruleMapperNodeRuleLog = ruleMapperNodeLog.extend('rule');
|
|
11
|
-
class RuleMapper {
|
|
8
|
+
export class RuleMapper {
|
|
12
9
|
constructor(
|
|
13
10
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
14
11
|
document) {
|
|
15
12
|
_RuleMapper_nodeList.set(this, void 0);
|
|
16
13
|
_RuleMapper_ruleMap.set(this, new Map());
|
|
17
|
-
|
|
14
|
+
__classPrivateFieldSet(this, _RuleMapper_nodeList, Object.freeze([document, ...document.nodeList]), "f");
|
|
18
15
|
}
|
|
19
16
|
apply() {
|
|
20
17
|
ruleMapperLog('ruleTree:');
|
|
21
|
-
|
|
22
|
-
const rules =
|
|
18
|
+
__classPrivateFieldGet(this, _RuleMapper_nodeList, "f").forEach(node => {
|
|
19
|
+
const rules = __classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid);
|
|
23
20
|
if (!rules) {
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
@@ -37,11 +34,10 @@ class RuleMapper {
|
|
|
37
34
|
set(
|
|
38
35
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
39
36
|
node, ruleName, rule) {
|
|
40
|
-
|
|
41
|
-
const rules = (_a = tslib_1.__classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid)) !== null && _a !== void 0 ? _a : {};
|
|
37
|
+
const rules = __classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid) ?? {};
|
|
42
38
|
const currentRule = rules[ruleName];
|
|
43
39
|
if (currentRule) {
|
|
44
|
-
const order =
|
|
40
|
+
const order = compareSpecificity(currentRule.specificity, rule.specificity);
|
|
45
41
|
if (order === 1) {
|
|
46
42
|
ruleMapperLog("Don't set %o ([%s] vs [%s])", rule, currentRule.specificity, rule.specificity);
|
|
47
43
|
return;
|
|
@@ -49,9 +45,8 @@ class RuleMapper {
|
|
|
49
45
|
ruleMapperLog('Unset %o from %s', currentRule, node);
|
|
50
46
|
}
|
|
51
47
|
rules[ruleName] = rule;
|
|
52
|
-
|
|
48
|
+
__classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").set(node.uuid, rules);
|
|
53
49
|
ruleMapperLog('Set to %s from %s (%o): %O', node.nodeName, rule.from, rule.specificity, rule.rule);
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
|
-
exports.RuleMapper = RuleMapper;
|
|
57
52
|
_RuleMapper_nodeList = new WeakMap(), _RuleMapper_ruleMap = new WeakMap();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TextNodeType } from './types';
|
|
1
|
+
import type { TextNodeType } from './types.js';
|
|
2
2
|
import type { MLASTText } from '@markuplint/ml-ast';
|
|
3
3
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
-
import { MLCharacterData } from './character-data';
|
|
4
|
+
import { MLCharacterData } from './character-data.js';
|
|
5
5
|
export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined> extends MLCharacterData<T, O, MLASTText> implements Text {
|
|
6
6
|
/**
|
|
7
7
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
package/lib/ml-dom/node/text.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MLText = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const character_data_1 = require("./character-data");
|
|
6
|
-
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
1
|
+
import { MLCharacterData } from './character-data.js';
|
|
2
|
+
import UnexpectedCallError from './unexpected-call-error.js';
|
|
7
3
|
/**
|
|
8
4
|
* Raw text elements
|
|
9
5
|
*
|
|
10
6
|
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
|
11
7
|
*/
|
|
12
8
|
const rawTextElements = ['script', 'style'];
|
|
13
|
-
class MLText extends
|
|
9
|
+
export class MLText extends MLCharacterData {
|
|
14
10
|
/**
|
|
15
11
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
16
12
|
*
|
|
@@ -18,7 +14,7 @@ class MLText extends character_data_1.MLCharacterData {
|
|
|
18
14
|
* @implements DOM API: `Text`
|
|
19
15
|
*/
|
|
20
16
|
get assignedSlot() {
|
|
21
|
-
throw new
|
|
17
|
+
throw new UnexpectedCallError('Not supported "assignedSlot" property');
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
20
|
* Returns a string appropriate for the type of node as `Text`
|
|
@@ -45,7 +41,7 @@ class MLText extends character_data_1.MLCharacterData {
|
|
|
45
41
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-text-splittext%E2%91%A0
|
|
46
42
|
*/
|
|
47
43
|
get wholeText() {
|
|
48
|
-
throw new
|
|
44
|
+
throw new UnexpectedCallError('Not supported "wholeText" property');
|
|
49
45
|
}
|
|
50
46
|
/**
|
|
51
47
|
* Returns `true` if a parent element is `<script>` or `<style>`
|
|
@@ -70,7 +66,6 @@ class MLText extends character_data_1.MLCharacterData {
|
|
|
70
66
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-text-wholetext%E2%91%A0
|
|
71
67
|
*/
|
|
72
68
|
splitText(offset) {
|
|
73
|
-
throw new
|
|
69
|
+
throw new UnexpectedCallError('Not supported "splitText" method');
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
|
-
exports.MLText = MLText;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { MLAttr } from './attr';
|
|
2
|
-
import type { MLBlock } from './block';
|
|
3
|
-
import type { MLComment } from './comment';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { MLElement } from './element';
|
|
8
|
-
import type { MLNode } from './node';
|
|
9
|
-
import type { MLText } from './text';
|
|
10
|
-
import type { MLToken } from '../token/token';
|
|
1
|
+
import type { MLAttr } from './attr.js';
|
|
2
|
+
import type { MLBlock } from './block.js';
|
|
3
|
+
import type { MLComment } from './comment.js';
|
|
4
|
+
import type { MLDocumentFragment } from './document-fragment.js';
|
|
5
|
+
import type { MLDocumentType } from './document-type.js';
|
|
6
|
+
import type { MLDocument } from './document.js';
|
|
7
|
+
import type { MLElement } from './element.js';
|
|
8
|
+
import type { MLNode } from './node.js';
|
|
9
|
+
import type { MLText } from './text.js';
|
|
10
|
+
import type { MLToken } from '../token/token.js';
|
|
11
11
|
import type { MLASTAbstractNode, MLASTAttr, MLASTComment, MLASTDoctype, MLASTElement, MLASTParentNode, MLASTPreprocessorSpecificBlock, MLASTText, MLToken as MLASTToken } from '@markuplint/ml-ast/';
|
|
12
12
|
import type { PlainData, PretenderARIA, RuleConfigValue } from '@markuplint/ml-config';
|
|
13
13
|
export type MappedNode<N, T extends RuleConfigValue, O extends PlainData = undefined> = N extends MLASTElement ? MLElement<T, O> : N extends MLASTParentNode ? MLElement<T, O> : N extends MLASTComment ? MLComment<T, O> : N extends MLASTText ? MLText<T, O> : N extends MLASTDoctype ? MLDocumentType<T, O> : N extends MLASTPreprocessorSpecificBlock ? MLBlock<T, O> : N extends MLASTAbstractNode ? MLNode<T, O, MLASTAbstractNode> : N extends MLASTAttr ? MLAttr<T, O> : N extends MLASTToken ? MLToken : never;
|
package/lib/ml-dom/node/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLToken_endCol, _MLToken_endLine, _MLToken_endOffset, _MLToken_fixed, _MLToken_raw, _MLToken_startCol, _MLToken_startLine, _MLToken_startOffset;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
class MLToken {
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
export class MLToken {
|
|
7
4
|
constructor(astToken) {
|
|
8
5
|
_MLToken_endCol.set(this, void 0);
|
|
9
6
|
_MLToken_endLine.set(this, void 0);
|
|
@@ -14,69 +11,69 @@ class MLToken {
|
|
|
14
11
|
_MLToken_startLine.set(this, void 0);
|
|
15
12
|
_MLToken_startOffset.set(this, void 0);
|
|
16
13
|
this._astToken = astToken;
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
__classPrivateFieldSet(this, _MLToken_raw, astToken.raw, "f");
|
|
15
|
+
__classPrivateFieldSet(this, _MLToken_fixed, astToken.raw, "f");
|
|
19
16
|
this.uuid = astToken.uuid;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
__classPrivateFieldSet(this, _MLToken_startLine, astToken.startLine, "f");
|
|
18
|
+
__classPrivateFieldSet(this, _MLToken_endLine, astToken.endLine, "f");
|
|
19
|
+
__classPrivateFieldSet(this, _MLToken_startCol, astToken.startCol, "f");
|
|
20
|
+
__classPrivateFieldSet(this, _MLToken_endCol, astToken.endCol, "f");
|
|
21
|
+
__classPrivateFieldSet(this, _MLToken_startOffset, astToken.startOffset, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _MLToken_endOffset, astToken.endOffset, "f");
|
|
26
23
|
}
|
|
27
24
|
/**
|
|
28
25
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
29
26
|
*/
|
|
30
27
|
get endCol() {
|
|
31
|
-
return
|
|
28
|
+
return __classPrivateFieldGet(this, _MLToken_endCol, "f");
|
|
32
29
|
}
|
|
33
30
|
/**
|
|
34
31
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
35
32
|
*/
|
|
36
33
|
get endLine() {
|
|
37
|
-
return
|
|
34
|
+
return __classPrivateFieldGet(this, _MLToken_endLine, "f");
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
37
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
41
38
|
*/
|
|
42
39
|
get endOffset() {
|
|
43
|
-
return
|
|
40
|
+
return __classPrivateFieldGet(this, _MLToken_endOffset, "f");
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
43
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
47
44
|
*/
|
|
48
45
|
get originRaw() {
|
|
49
|
-
return
|
|
46
|
+
return __classPrivateFieldGet(this, _MLToken_raw, "f");
|
|
50
47
|
}
|
|
51
48
|
/**
|
|
52
49
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
53
50
|
*/
|
|
54
51
|
get raw() {
|
|
55
|
-
return
|
|
52
|
+
return __classPrivateFieldGet(this, _MLToken_fixed, "f");
|
|
56
53
|
}
|
|
57
54
|
/**
|
|
58
55
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
59
56
|
*/
|
|
60
57
|
get startCol() {
|
|
61
|
-
return
|
|
58
|
+
return __classPrivateFieldGet(this, _MLToken_startCol, "f");
|
|
62
59
|
}
|
|
63
60
|
/**
|
|
64
61
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
65
62
|
*/
|
|
66
63
|
get startLine() {
|
|
67
|
-
return
|
|
64
|
+
return __classPrivateFieldGet(this, _MLToken_startLine, "f");
|
|
68
65
|
}
|
|
69
66
|
/**
|
|
70
67
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
71
68
|
*/
|
|
72
69
|
get startOffset() {
|
|
73
|
-
return
|
|
70
|
+
return __classPrivateFieldGet(this, _MLToken_startOffset, "f");
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
76
73
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
77
74
|
*/
|
|
78
75
|
fix(raw) {
|
|
79
|
-
|
|
76
|
+
__classPrivateFieldSet(this, _MLToken_fixed, raw, "f");
|
|
80
77
|
}
|
|
81
78
|
/**
|
|
82
79
|
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
@@ -85,5 +82,4 @@ class MLToken {
|
|
|
85
82
|
return this.raw;
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
exports.MLToken = MLToken;
|
|
89
85
|
_MLToken_endCol = new WeakMap(), _MLToken_endLine = new WeakMap(), _MLToken_endOffset = new WeakMap(), _MLToken_fixed = new WeakMap(), _MLToken_raw = new WeakMap(), _MLToken_startCol = new WeakMap(), _MLToken_startLine = new WeakMap(), _MLToken_startOffset = new WeakMap();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RuleSeed } from './types';
|
|
1
|
+
import type { RuleSeed } from './types.js';
|
|
2
2
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
3
|
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>>): Readonly<RuleSeed<T, O>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RuleSeed } from './types';
|
|
1
|
+
import type { RuleSeed } from './types.js';
|
|
2
2
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
import { MLRule } from './ml-rule';
|
|
3
|
+
import { MLRule } from './ml-rule.js';
|
|
4
4
|
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>> & {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
}): MLRule<T, O>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ml_rule_1 = require("./ml-rule");
|
|
5
|
-
function createRule(seed) {
|
|
6
|
-
return new ml_rule_1.MLRule(seed);
|
|
1
|
+
import { MLRule } from './ml-rule.js';
|
|
2
|
+
export function createRule(seed) {
|
|
3
|
+
return new MLRule(seed);
|
|
7
4
|
}
|
|
8
|
-
exports.createRule = createRule;
|
package/lib/ml-rule/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './create-rule';
|
|
2
|
-
export * from './ml-rule';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './create-rule.js';
|
|
2
|
+
export * from './ml-rule.js';
|
|
3
|
+
export * from './types.js';
|
package/lib/ml-rule/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./create-rule"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ml-rule"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
1
|
+
export * from './create-rule.js';
|
|
2
|
+
export * from './ml-rule.js';
|
|
3
|
+
export * from './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CheckerReport } from './types';
|
|
2
|
-
import type { MLDocument } from '../ml-dom/node/document';
|
|
1
|
+
import type { CheckerReport } from './types.js';
|
|
2
|
+
import type { MLDocument } from '../ml-dom/node/document.js';
|
|
3
3
|
import type { LocaleSet, Translator } from '@markuplint/i18n';
|
|
4
4
|
import type { PlainData, Report, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
5
|
export declare class MLRuleContext<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLRuleContext_reports;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const i18n_1 = require("@markuplint/i18n");
|
|
7
|
-
class MLRuleContext {
|
|
2
|
+
import { __classPrivateFieldGet } from "tslib";
|
|
3
|
+
import { translator } from '@markuplint/i18n';
|
|
4
|
+
export class MLRuleContext {
|
|
8
5
|
constructor(
|
|
9
6
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
7
|
document, locale) {
|
|
11
8
|
_MLRuleContext_reports.set(this, []);
|
|
12
9
|
this.document = document;
|
|
13
|
-
this.translate =
|
|
10
|
+
this.translate = translator(locale);
|
|
14
11
|
this.locale = locale.locale;
|
|
15
12
|
}
|
|
16
13
|
get reports() {
|
|
17
|
-
return
|
|
14
|
+
return __classPrivateFieldGet(this, _MLRuleContext_reports, "f").map(report => ({
|
|
18
15
|
...report,
|
|
19
16
|
message: finish(report.message, this.locale),
|
|
20
17
|
}));
|
|
@@ -40,12 +37,11 @@ class MLRuleContext {
|
|
|
40
37
|
this._push(report);
|
|
41
38
|
}
|
|
42
39
|
_push(report) {
|
|
43
|
-
if (!
|
|
44
|
-
|
|
40
|
+
if (!__classPrivateFieldGet(this, _MLRuleContext_reports, "f").find(r => is(r, report))) {
|
|
41
|
+
__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
exports.MLRuleContext = MLRuleContext;
|
|
49
45
|
_MLRuleContext_reports = new WeakMap();
|
|
50
46
|
function finish(message, locale = 'en') {
|
|
51
47
|
switch (locale) {
|
package/lib/ml-rule/ml-rule.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RuleSeed } from './types';
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
1
|
+
import type { RuleSeed } from './types.js';
|
|
2
|
+
import type { MLDocument } from '../ml-dom/node/document.js';
|
|
3
|
+
import type Ruleset from '../ruleset/index.js';
|
|
4
4
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
5
5
|
import type { GlobalRuleInfo, PlainData, Rule, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
|
|
6
6
|
export declare class MLRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|