@markuplint/ml-core 3.3.0 → 3.4.0

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 (45) hide show
  1. package/lib/index.d.ts +11 -1
  2. package/lib/ml-core.d.ts +22 -11
  3. package/lib/ml-dom/helper/create-node.d.ts +4 -1
  4. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  5. package/lib/ml-dom/helper/walkers.d.ts +11 -3
  6. package/lib/ml-dom/helper/walkers.js +1 -0
  7. package/lib/ml-dom/manipulations/child-node-methods.d.ts +18 -5
  8. package/lib/ml-dom/manipulations/get-children.d.ts +3 -1
  9. package/lib/ml-dom/node/attr.d.ts +89 -89
  10. package/lib/ml-dom/node/block.d.ts +30 -30
  11. package/lib/ml-dom/node/character-data.d.ts +59 -52
  12. package/lib/ml-dom/node/child-node.d.ts +6 -1
  13. package/lib/ml-dom/node/comment.d.ts +15 -12
  14. package/lib/ml-dom/node/document-fragment.d.ts +22 -19
  15. package/lib/ml-dom/node/document-type.d.ts +34 -31
  16. package/lib/ml-dom/node/document.d.ts +1600 -1586
  17. package/lib/ml-dom/node/document.js +12 -0
  18. package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
  19. package/lib/ml-dom/node/dom-token-list.js +5 -5
  20. package/lib/ml-dom/node/element.d.ts +1894 -1888
  21. package/lib/ml-dom/node/named-node-map.d.ts +44 -39
  22. package/lib/ml-dom/node/named-node-map.js +2 -1
  23. package/lib/ml-dom/node/node-list.d.ts +9 -3
  24. package/lib/ml-dom/node/node-list.js +17 -2
  25. package/lib/ml-dom/node/node-store.d.ts +3 -3
  26. package/lib/ml-dom/node/node.d.ts +492 -472
  27. package/lib/ml-dom/node/node.js +4 -2
  28. package/lib/ml-dom/node/parent-node.d.ts +66 -57
  29. package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
  30. package/lib/ml-dom/node/rule-mapper.js +3 -0
  31. package/lib/ml-dom/node/text.d.ts +49 -46
  32. package/lib/ml-dom/node/types.d.ts +67 -11
  33. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
  34. package/lib/ml-dom/token/token.d.ts +44 -44
  35. package/lib/ml-rule/create-test-rule.d.ts +5 -3
  36. package/lib/ml-rule/ml-rule-context.d.ts +56 -48
  37. package/lib/ml-rule/ml-rule.d.ts +25 -23
  38. package/lib/ml-rule/types.d.ts +19 -13
  39. package/lib/plugin/types.d.ts +5 -5
  40. package/lib/ruleset/index.d.ts +4 -4
  41. package/lib/test/index.d.ts +19 -7
  42. package/lib/test/index.js +1 -1
  43. package/lib/types.d.ts +7 -7
  44. package/lib/utils/get-location-from-chars.d.ts +9 -4
  45. package/package.json +9 -7
@@ -2064,6 +2064,9 @@ class MLDocument extends parent_node_1.MLParentNode {
2064
2064
  // global rules to #document
2065
2065
  Object.keys(ruleset.rules).forEach(ruleName => {
2066
2066
  const rule = ruleset.rules[ruleName];
2067
+ if (rule == null) {
2068
+ return;
2069
+ }
2067
2070
  ruleMapper.set(this, ruleName, {
2068
2071
  from: 'rules',
2069
2072
  specificity: [0, 0, 0],
@@ -2078,6 +2081,9 @@ class MLDocument extends parent_node_1.MLParentNode {
2078
2081
  // global rules to each element
2079
2082
  Object.keys(ruleset.rules).forEach(ruleName => {
2080
2083
  const rule = ruleset.rules[ruleName];
2084
+ if (rule == null) {
2085
+ return;
2086
+ }
2081
2087
  ruleMapper.set(node, ruleName, {
2082
2088
  from: 'rules',
2083
2089
  specificity: [0, 0, 0],
@@ -2107,6 +2113,9 @@ class MLDocument extends parent_node_1.MLParentNode {
2107
2113
  const ruleList = Object.keys(nodeRule.rules);
2108
2114
  for (const ruleName of ruleList) {
2109
2115
  const rule = nodeRule.rules[ruleName];
2116
+ if (rule == null) {
2117
+ continue;
2118
+ }
2110
2119
  const convertedRule = (0, ml_config_1.exchangeValueOnRule)(rule, matches.data || {});
2111
2120
  if (convertedRule === undefined) {
2112
2121
  continue;
@@ -2147,6 +2156,9 @@ class MLDocument extends parent_node_1.MLParentNode {
2147
2156
  const targetDescendants = nodeRule.inheritance ? descendants : children;
2148
2157
  Object.keys(nodeRuleRules).forEach(ruleName => {
2149
2158
  const rule = nodeRuleRules[ruleName];
2159
+ if (rule == null) {
2160
+ return;
2161
+ }
2150
2162
  const convertedRule = (0, ml_config_1.exchangeValueOnRule)(rule, matches.data || {});
2151
2163
  if (convertedRule === undefined) {
2152
2164
  return;
@@ -1,33 +1,33 @@
1
1
  import type { MLAttr } from './attr';
2
2
  import type { RuleInfo } from '@markuplint/ml-config';
3
3
  type Scope = {
4
- raw: string;
5
- startOffset: number;
6
- startLine: number;
7
- startCol: number;
8
- rule: RuleInfo<any, any>;
4
+ raw: string;
5
+ startOffset: number;
6
+ startLine: number;
7
+ startCol: number;
8
+ rule: RuleInfo<any, any>;
9
9
  };
10
10
  export declare class MLDomTokenList extends Array<string> implements DOMTokenList {
11
- #private;
12
- constructor(tokens: string, ownerAttrs: MLAttr<any, any>[]);
13
- get value(): string;
14
- add(...tokens: string[]): void;
15
- /**
16
- * @implements `@markuplint/ml-core` API: `MLDomTokenList`
17
- */
18
- allTokens(): Scope[];
19
- contains(token: string): boolean;
20
- forEach(callbackfn: (value: string, index: number, parent: any) => void, thisArg?: any): void;
21
- item(index: number): string | null;
22
- /**
23
- * @implements `@markuplint/ml-core` API: `MLDomTokenList`
24
- */
25
- pick(token: string): Scope | null;
26
- remove(...tokens: string[]): void;
27
- replace(token: string, newToken: string): boolean;
28
- supports(token: string): boolean;
29
- toString(): string;
30
- toggle(token: string, force?: boolean): boolean;
31
- private _pick;
11
+ #private;
12
+ constructor(tokens: string, ownerAttrs: MLAttr<any, any>[]);
13
+ get value(): string;
14
+ add(...tokens: string[]): void;
15
+ /**
16
+ * @implements `@markuplint/ml-core` API: `MLDomTokenList`
17
+ */
18
+ allTokens(): Scope[];
19
+ contains(token: string): boolean;
20
+ forEach(callbackfn: (value: string, index: number, parent: any) => void, thisArg?: any): void;
21
+ item(index: number): string | null;
22
+ /**
23
+ * @implements `@markuplint/ml-core` API: `MLDomTokenList`
24
+ */
25
+ pick(token: string): Scope | null;
26
+ remove(...tokens: string[]): void;
27
+ replace(token: string, newToken: string): boolean;
28
+ supports(token: string): boolean;
29
+ toString(): string;
30
+ toggle(token: string, force?: boolean): boolean;
31
+ private _pick;
32
32
  }
33
33
  export {};
@@ -106,8 +106,8 @@ class MLDomTokenList extends Array {
106
106
  throw new unexpected_call_error_1.default('Not supported "toggle" method');
107
107
  }
108
108
  _pick(token, _offset = 0) {
109
- var _a, _b, _c, _d, _e, _f;
110
- token = token.trim().split(/\s+/g)[0];
109
+ var _a, _b, _c, _d, _e, _f, _g;
110
+ token = (_a = token.trim().split(/\s+/g)[0]) !== null && _a !== void 0 ? _a : '';
111
111
  if (!token) {
112
112
  return null;
113
113
  }
@@ -123,9 +123,9 @@ class MLDomTokenList extends Array {
123
123
  const startCol = (0, parser_utils_1.getCol)(tslib_1.__classPrivateFieldGet(this, _MLDomTokenList_origin, "f"), startOffset);
124
124
  return {
125
125
  raw: token,
126
- startOffset: ((_b = (_a = ownerAttr.valueNode) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 0) + startOffset,
127
- startLine: ((_d = (_c = ownerAttr.valueNode) === null || _c === void 0 ? void 0 : _c.startLine) !== null && _d !== void 0 ? _d : 0) + (startLine - 1),
128
- startCol: ((_f = (_e = ownerAttr.valueNode) === null || _e === void 0 ? void 0 : _e.startCol) !== null && _f !== void 0 ? _f : 0) + (startCol - 1),
126
+ startOffset: ((_c = (_b = ownerAttr.valueNode) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0) + startOffset,
127
+ startLine: ((_e = (_d = ownerAttr.valueNode) === null || _d === void 0 ? void 0 : _d.startLine) !== null && _e !== void 0 ? _e : 0) + (startLine - 1),
128
+ startCol: ((_g = (_f = ownerAttr.valueNode) === null || _f === void 0 ? void 0 : _f.startCol) !== null && _g !== void 0 ? _g : 0) + (startCol - 1),
129
129
  rule: ownerAttr.rule,
130
130
  _searchedIndex: startOffset,
131
131
  };