@markuplint/ml-spec 3.3.0 → 3.5.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 (47) hide show
  1. package/lib/dom-traverse/accname-computation.js +3 -1
  2. package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
  3. package/lib/dom-traverse/get-attr-specs.js +3 -1
  4. package/lib/dom-traverse/get-computed-aria-props.d.ts +1 -1
  5. package/lib/dom-traverse/get-computed-aria-props.js +3 -1
  6. package/lib/dom-traverse/get-computed-role.d.ts +1 -1
  7. package/lib/dom-traverse/get-computed-role.js +10 -4
  8. package/lib/dom-traverse/get-content-model.d.ts +3 -2
  9. package/lib/dom-traverse/get-content-model.js +3 -1
  10. package/lib/dom-traverse/get-explicit-role.js +6 -2
  11. package/lib/dom-traverse/get-implicit-role.d.ts +2 -2
  12. package/lib/dom-traverse/get-implicit-role.js +6 -2
  13. package/lib/dom-traverse/get-non-presentational-ancestor.js +3 -1
  14. package/lib/dom-traverse/get-permitted-roles.d.ts +3 -3
  15. package/lib/dom-traverse/get-permitted-roles.js +3 -1
  16. package/lib/dom-traverse/get-spec.d.ts +1 -1
  17. package/lib/dom-traverse/get-spec.js +3 -1
  18. package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -2
  19. package/lib/dom-traverse/has-required-owned-elements.js +14 -8
  20. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  21. package/lib/dom-traverse/is-exposed.js +18 -6
  22. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  23. package/lib/dom-traverse/may-be-focusable.js +3 -1
  24. package/lib/index.d.ts +1 -0
  25. package/lib/index.js +1 -0
  26. package/lib/specs/aria-specs.d.ts +4 -4
  27. package/lib/specs/get-aria.d.ts +2 -1
  28. package/lib/specs/get-aria.js +7 -1
  29. package/lib/specs/get-attr-specs.d.ts +2 -2
  30. package/lib/specs/get-implicit-role.d.ts +1 -1
  31. package/lib/specs/get-permitted-roles.d.ts +3 -3
  32. package/lib/specs/get-permitted-roles.js +15 -11
  33. package/lib/specs/get-role-spec.d.ts +1 -1
  34. package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
  35. package/lib/specs/get-spec-by-tag-name.d.ts +1 -1
  36. package/lib/specs/is-nothing-content-model.js +3 -1
  37. package/lib/specs/is-palpable-elements.d.ts +3 -3
  38. package/lib/specs/is-palpable-elements.js +3 -1
  39. package/lib/specs/is-void-element.js +3 -1
  40. package/lib/specs/resolve-version.d.ts +2 -1
  41. package/lib/specs/schema-to-spec.d.ts +1 -1
  42. package/lib/specs/schema-to-spec.js +23 -17
  43. package/lib/types/aria.d.ts +5 -4
  44. package/lib/types/index.d.ts +87 -88
  45. package/lib/utils/merge-array.d.ts +2 -2
  46. package/lib/utils/resolve-namespace.js +2 -1
  47. package/package.json +8 -6
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAccname = void 0;
4
4
  const dom_accessibility_api_1 = require("dom-accessibility-api");
5
- function getAccname(el) {
5
+ function getAccname(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el) {
6
8
  return (0, dom_accessibility_api_1.computeAccessibleName)(el);
7
9
  }
8
10
  exports.getAccname = getAccname;
@@ -1,2 +1,2 @@
1
1
  import type { MLMLSpec } from '../types';
2
- export declare function getAttrSpecs(el: Element, schema: MLMLSpec): import("../types").Attribute[] | null;
2
+ export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types").Attribute[] | null;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAttrSpecs = void 0;
4
4
  const get_attr_specs_1 = require("../specs/get-attr-specs");
5
- function getAttrSpecs(el, schema) {
5
+ function getAttrSpecs(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el, schema) {
6
8
  return (0, get_attr_specs_1.getAttrSpecs)(el.localName, el.namespaceURI, schema);
7
9
  }
8
10
  exports.getAttrSpecs = getAttrSpecs;
@@ -8,5 +8,5 @@ type ARIAProp = {
8
8
  from: ARIAPropReferenceType;
9
9
  };
10
10
  type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
11
- export declare function getComputedAriaProps(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ARIAProps;
11
+ export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
12
12
  export {};
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getComputedAriaProps = void 0;
4
4
  const aria_specs_1 = require("../specs/aria-specs");
5
5
  const get_computed_role_1 = require("./get-computed-role");
6
- function getComputedAriaProps(specs, el, version) {
6
+ function getComputedAriaProps(specs,
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ el, version) {
7
9
  const ariaSpecs = (0, aria_specs_1.ariaSpecs)(specs, version);
8
10
  const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
9
11
  if (!role) {
@@ -1,2 +1,2 @@
1
1
  import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function getComputedRole(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ComputedRole;
2
+ export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
@@ -9,7 +9,9 @@ const get_implicit_role_1 = require("./get-implicit-role");
9
9
  const get_non_presentational_ancestor_1 = require("./get-non-presentational-ancestor");
10
10
  const has_required_owned_elements_1 = require("./has-required-owned-elements");
11
11
  const may_be_focusable_1 = require("./may-be-focusable");
12
- function getComputedRole(specs, el, version) {
12
+ function getComputedRole(specs,
13
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
+ el, version) {
13
15
  var _a, _b, _c, _d;
14
16
  const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
15
17
  const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
@@ -116,7 +118,7 @@ function getComputedRole(specs, el, version) {
116
118
  // const ancestor = nonPresentationalAncestor.el;
117
119
  // const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
118
120
  // console.log({ nonPresentationalAncestor, ancestorImplicitRole });
119
- return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole, expected, specs, version);
121
+ return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole.el, implicitRole.role, expected, specs, version);
120
122
  })) {
121
123
  return {
122
124
  ...implicitRole,
@@ -151,7 +153,9 @@ exports.getComputedRole = getComputedRole;
151
153
  * The attribute is available in its owner element,
152
154
  * it has the attribute.
153
155
  */
154
- function isEnabledAttr(el, specs, attrName) {
156
+ function isEnabledAttr(
157
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
158
+ el, specs, attrName) {
155
159
  const attrs = (0, get_attr_specs_1.getAttrSpecs)(el, specs);
156
160
  const attr = attrs === null || attrs === void 0 ? void 0 : attrs.find(attr => attr.name === attrName);
157
161
  return !!attr && el.hasAttribute(attrName);
@@ -159,7 +163,9 @@ function isEnabledAttr(el, specs, attrName) {
159
163
  /**
160
164
  * Determines whether some ancestors match the condition that the specified callback function.
161
165
  */
162
- function someAncestors(el, predicate) {
166
+ function someAncestors(
167
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
168
+ el, predicate) {
163
169
  const list = [];
164
170
  let current = el;
165
171
  while (current) {
@@ -1,3 +1,4 @@
1
1
  import type { ElementSpec } from '../types';
2
- import type { PermittedContentPattern } from '../types/permitted-structures';
3
- export declare function getContentModel(el: Element, specs: Pick<ElementSpec, 'name' | 'contentModel'>[]): boolean | PermittedContentPattern[] | null;
2
+ type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
3
+ export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentRequire> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOptional> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentChoice> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentTransparent>)[] | null;
4
+ export {};
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getContentModel = void 0;
4
4
  const get_spec_1 = require("./get-spec");
5
5
  const cachesBySpecs = new Map();
6
- function getContentModel(el, specs) {
6
+ function getContentModel(
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ el, specs) {
7
9
  var _a, _b;
8
10
  const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
9
11
  const cached = cacheByEl.get(el);
@@ -4,7 +4,9 @@ exports.getExplicitRole = void 0;
4
4
  const get_role_spec_1 = require("../specs/get-role-spec");
5
5
  const resolve_namespace_1 = require("../utils/resolve-namespace");
6
6
  const get_permitted_roles_1 = require("./get-permitted-roles");
7
- function getExplicitRole(specs, el, version) {
7
+ function getExplicitRole(specs,
8
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
+ el, version) {
8
10
  const roleValue = el.getAttribute('role');
9
11
  const roleNames = (roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) || [];
10
12
  const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
@@ -83,7 +85,9 @@ exports.getExplicitRole = getExplicitRole;
83
85
  function isLandmarkRole(role) {
84
86
  return role === null || role === void 0 ? void 0 : role.superClassRoles.some(su => su.name === 'landmark');
85
87
  }
86
- function isValidLandmarkRole(el, role) {
88
+ function isValidLandmarkRole(
89
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
90
+ el, role) {
87
91
  if (!role.accessibleNameRequired) {
88
92
  return true;
89
93
  }
@@ -1,3 +1,3 @@
1
1
  import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function getImplicitRole(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ComputedRole;
3
- export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: Readonly<MLMLSpec>): import("..").ImplicitRole;
2
+ export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
3
+ export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("..").ImplicitRole;
@@ -4,7 +4,9 @@ exports.getImplicitRoleName = exports.getImplicitRole = void 0;
4
4
  const get_implicit_role_1 = require("../specs/get-implicit-role");
5
5
  const get_role_spec_1 = require("../specs/get-role-spec");
6
6
  const resolve_namespace_1 = require("../utils/resolve-namespace");
7
- function getImplicitRole(specs, el, version) {
7
+ function getImplicitRole(specs,
8
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
+ el, version) {
8
10
  const implicitRole = getImplicitRoleName(el, version, specs);
9
11
  if (implicitRole === false) {
10
12
  // No Corresponding Role
@@ -31,7 +33,9 @@ function getImplicitRole(specs, el, version) {
31
33
  };
32
34
  }
33
35
  exports.getImplicitRole = getImplicitRole;
34
- function getImplicitRoleName(el, version, specs) {
36
+ function getImplicitRoleName(
37
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
38
+ el, version, specs) {
35
39
  return (0, get_implicit_role_1.getImplicitRole)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
36
40
  }
37
41
  exports.getImplicitRoleName = getImplicitRoleName;
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNonPresentationalAncestor = void 0;
4
4
  const is_presentational_1 = require("../specs/is-presentational");
5
5
  const get_computed_role_1 = require("./get-computed-role");
6
- function getNonPresentationalAncestor(el, specs, version) {
6
+ function getNonPresentationalAncestor(
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ el, specs, version) {
7
9
  var _a;
8
10
  let ancestor = el.parentElement;
9
11
  while (ancestor) {
@@ -1,5 +1,5 @@
1
1
  import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: Readonly<MLMLSpec>): {
3
- name: string;
4
- deprecated?: boolean | undefined;
2
+ export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
3
+ readonly name: string;
4
+ readonly deprecated?: boolean | undefined;
5
5
  }[];
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPermittedRoles = void 0;
4
4
  const get_permitted_roles_1 = require("../specs/get-permitted-roles");
5
- function getPermittedRoles(el, version, specs) {
5
+ function getPermittedRoles(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el, version, specs) {
6
8
  return (0, get_permitted_roles_1.getPermittedRoles)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
7
9
  }
8
10
  exports.getPermittedRoles = getPermittedRoles;
@@ -1,2 +1,2 @@
1
1
  import type { ElementSpec } from '../types';
2
- export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
2
+ export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSpec = void 0;
4
4
  const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
5
- function getSpec(el, specs) {
5
+ function getSpec(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el, specs) {
6
8
  return (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, el.localName, el.namespaceURI);
7
9
  }
8
10
  exports.getSpec = getSpec;
@@ -1,3 +1,3 @@
1
1
  import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function hasRequiredOwnedElement(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
3
- export declare function isRequiredOwnedElement(owned: ComputedRole, query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
2
+ export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
3
+ export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -5,7 +5,9 @@ const is_presentational_1 = require("../specs/is-presentational");
5
5
  const get_computed_role_1 = require("./get-computed-role");
6
6
  const get_explicit_role_1 = require("./get-explicit-role");
7
7
  const get_implicit_role_1 = require("./get-implicit-role");
8
- function hasRequiredOwnedElement(el, specs, version) {
8
+ function hasRequiredOwnedElement(
9
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
+ el, specs, version) {
9
11
  /**
10
12
  * The element has aria-owns which means it may have owned elements.
11
13
  *
@@ -24,7 +26,7 @@ function hasRequiredOwnedElement(el, specs, version) {
24
26
  }
25
27
  for (const expectRole of computed.role.requiredOwnedElements) {
26
28
  for (const owned of getClosestNonPresentationalDescendants(el, specs, version)) {
27
- if (isRequiredOwnedElement(owned, expectRole, specs, version)) {
29
+ if (isRequiredOwnedElement(owned.el, owned.role, expectRole, specs, version)) {
28
30
  return true;
29
31
  }
30
32
  }
@@ -32,17 +34,19 @@ function hasRequiredOwnedElement(el, specs, version) {
32
34
  return false;
33
35
  }
34
36
  exports.hasRequiredOwnedElement = hasRequiredOwnedElement;
35
- function isRequiredOwnedElement(owned, query, specs, version) {
36
- var _a, _b;
37
+ function isRequiredOwnedElement(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ el, role, query, specs, version) {
40
+ var _a;
37
41
  const [baseRole, owningRole] = query.split(' > ');
38
- if (((_a = owned.role) === null || _a === void 0 ? void 0 : _a.name) !== baseRole) {
42
+ if ((role === null || role === void 0 ? void 0 : role.name) !== baseRole) {
39
43
  return false;
40
44
  }
41
45
  if (!owningRole) {
42
46
  return true;
43
47
  }
44
- for (const owning of getClosestNonPresentationalDescendants(owned.el, specs, version)) {
45
- if (((_b = owning.role) === null || _b === void 0 ? void 0 : _b.name) === owningRole) {
48
+ for (const owning of getClosestNonPresentationalDescendants(el, specs, version)) {
49
+ if (((_a = owning.role) === null || _a === void 0 ? void 0 : _a.name) === owningRole) {
46
50
  return true;
47
51
  }
48
52
  }
@@ -64,7 +68,9 @@ exports.isRequiredOwnedElement = isRequiredOwnedElement;
64
68
  * However, the presentational role behaves transparently
65
69
  * according to the sample code in WAI-ARIA specification.
66
70
  */
67
- function getClosestNonPresentationalDescendants(el, specs, version) {
71
+ function getClosestNonPresentationalDescendants(
72
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
73
+ el, specs, version) {
68
74
  var _a;
69
75
  const owned = [];
70
76
  for (const child of Array.from(el.children)) {
@@ -8,4 +8,4 @@ import type { ARIAVersion, MLMLSpec } from '../types';
8
8
  * @param el
9
9
  * @param version
10
10
  */
11
- export declare function isExposed(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
11
+ export declare function isExposed(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -15,7 +15,9 @@ const get_computed_role_1 = require("./get-computed-role");
15
15
  * @param el
16
16
  * @param version
17
17
  */
18
- function isExposed(el, specs, version) {
18
+ function isExposed(
19
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
20
+ el, specs, version) {
19
21
  // According to WAI-ARIA
20
22
  if (isExcluding(el, specs, version)) {
21
23
  return false;
@@ -52,7 +54,9 @@ exports.isExposed = isExposed;
52
54
  * @param el
53
55
  * @param version
54
56
  */
55
- function isExcluding(el, specs, version) {
57
+ function isExcluding(
58
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
59
+ el, specs, version) {
56
60
  /**
57
61
  * The following elements are not exposed via the accessibility API and
58
62
  * user agents MUST NOT include them in the accessibility tree:
@@ -131,7 +135,9 @@ function isExcluding(el, specs, version) {
131
135
  * @param el
132
136
  * @param version
133
137
  */
134
- function isIncluding(el, specs, version) {
138
+ function isIncluding(
139
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
140
+ el, specs, version) {
135
141
  /**
136
142
  * > **meet any** of the following criteria:
137
143
  */
@@ -178,7 +184,9 @@ function isIncluding(el, specs, version) {
178
184
  // results.push(true);
179
185
  return results.includes(true);
180
186
  }
181
- function hasDisplayNodeOrVisibilityHidden(el) {
187
+ function hasDisplayNodeOrVisibilityHidden(
188
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
189
+ el) {
182
190
  const style = el.getAttribute('style');
183
191
  if (!style) {
184
192
  return false;
@@ -186,7 +194,9 @@ function hasDisplayNodeOrVisibilityHidden(el) {
186
194
  // TODO: Improve accuracy
187
195
  return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
188
196
  }
189
- function isExposedElement(el, specs) {
197
+ function isExposedElement(
198
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
199
+ el, specs) {
190
200
  var _a;
191
201
  const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
192
202
  if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
@@ -194,7 +204,9 @@ function isExposedElement(el, specs) {
194
204
  }
195
205
  return isNotMetaOrHiddenHTMLElement(el, specs);
196
206
  }
197
- function isNotMetaOrHiddenHTMLElement(el, specs) {
207
+ function isNotMetaOrHiddenHTMLElement(
208
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
209
+ el, specs) {
198
210
  var _a;
199
211
  const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
200
212
  if (metadataConditions && el.matches(metadataConditions)) {
@@ -1,2 +1,2 @@
1
1
  import type { MLMLSpec } from '../types';
2
- export declare function mayBeFocusable(el: Element, specs: Readonly<MLMLSpec>): boolean;
2
+ export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mayBeFocusable = void 0;
4
4
  const get_selectors_by_content_model_category_1 = require("../specs/get-selectors-by-content-model-category");
5
- function mayBeFocusable(el, specs) {
5
+ function mayBeFocusable(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el, specs) {
6
8
  return [
7
9
  /**
8
10
  * Interactive content
package/lib/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './dom-traverse/is-exposed';
11
11
  export * from './dom-traverse/may-be-focusable';
12
12
  export * from './specs/aria-specs';
13
13
  export * from './specs/content-model-category-to-tag-names';
14
+ export * from './specs/get-aria';
14
15
  export * from './specs/get-role-spec';
15
16
  export * from './specs/get-spec-by-tag-name';
16
17
  export * from './specs/is-nothing-content-model';
package/lib/index.js CHANGED
@@ -14,6 +14,7 @@ tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
14
14
  tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
15
15
  tslib_1.__exportStar(require("./specs/aria-specs"), exports);
16
16
  tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
17
+ tslib_1.__exportStar(require("./specs/get-aria"), exports);
17
18
  tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
18
19
  tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
19
20
  tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
@@ -1,6 +1,6 @@
1
1
  import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function ariaSpecs(specs: Readonly<MLMLSpec>, version: ARIAVersion): {
3
- roles: import("../types").ARIARoleInSchema[];
4
- graphicsRoles: import("../types").ARIARoleInSchema[];
5
- props: import("../types").ARIAProperty[];
2
+ export declare function ariaSpecs(specs: MLMLSpec, version: ARIAVersion): {
3
+ readonly roles: readonly import("../types").ARIARoleInSchema[];
4
+ readonly graphicsRoles: readonly import("../types").ARIARoleInSchema[];
5
+ readonly props: readonly import("../types").ARIAProperty[];
6
6
  };
@@ -1,3 +1,4 @@
1
1
  import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
2
  import type { ARIA } from '../types/aria';
3
- export declare function getARIA(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ARIA, ARIAVersion | 'conditions'> | null;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function getARIA(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
@@ -21,6 +21,9 @@ function getARIA(specs, localName, namespace, version, matches) {
21
21
  continue;
22
22
  }
23
23
  const condARIA = conditions[cond];
24
+ if (!condARIA) {
25
+ continue;
26
+ }
24
27
  implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
25
28
  permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
26
29
  implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
@@ -50,7 +53,10 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
50
53
  }
51
54
  aria = (0, resolve_version_1.resolveVersion)(spec, version);
52
55
  if (aria.permittedRoles) {
53
- aria.permittedRoles = optimizePermittedRoles(aria.permittedRoles);
56
+ aria = {
57
+ ...aria,
58
+ permittedRoles: optimizePermittedRoles(aria.permittedRoles),
59
+ };
54
60
  }
55
61
  cache.set(key, aria);
56
62
  return aria;
@@ -1,8 +1,8 @@
1
1
  import type { MLMLSpec, Attribute } from '../types';
2
2
  import type { NamespaceURI } from '@markuplint/ml-ast';
3
- export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): Attribute[] | null;
3
+ export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
4
4
  type HasName = {
5
- name: string;
5
+ readonly name: string;
6
6
  };
7
7
  export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
8
8
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
- export declare function getImplicitRole(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("..").ImplicitRole;
2
+ export declare function getImplicitRole(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("..").ImplicitRole;
@@ -6,7 +6,7 @@ import type { ARIAVersion, Matches, MLMLSpec } from '../types';
6
6
  * - If `true`, this mean is "Any".
7
7
  * - If `false`, this mean is "No".
8
8
  */
9
- export declare function getPermittedRoles(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): {
10
- name: string;
11
- deprecated?: boolean;
9
+ export declare function getPermittedRoles(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): readonly {
10
+ readonly name: string;
11
+ readonly deprecated?: boolean;
12
12
  }[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPermittedRoles = void 0;
4
+ const is_plain_object_1 = require("is-plain-object");
4
5
  const merge_array_1 = require("../utils/merge-array");
5
6
  const aria_specs_1 = require("./aria-specs");
6
7
  const get_aria_1 = require("./get-aria");
@@ -26,17 +27,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
26
27
  name: role.name,
27
28
  })));
28
29
  }
29
- if (Array.isArray(permittedRoles)) {
30
- permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
31
- if (typeof role === 'string') {
32
- return {
33
- name: role,
34
- };
35
- }
36
- return role;
37
- }));
38
- }
39
- else if (!(typeof permittedRoles === 'boolean')) {
30
+ if (isAAMInfo(permittedRoles)) {
40
31
  if (permittedRoles['core-aam']) {
41
32
  permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
42
33
  .filter(role => !role.isAbstract)
@@ -52,6 +43,16 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
52
43
  })));
53
44
  }
54
45
  }
46
+ else if (typeof permittedRoles !== 'boolean') {
47
+ permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
48
+ if (typeof role === 'string') {
49
+ return {
50
+ name: role,
51
+ };
52
+ }
53
+ return role;
54
+ }));
55
+ }
55
56
  if (implicitRole) {
56
57
  const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
57
58
  return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
@@ -59,3 +60,6 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
59
60
  return permittedRoleList;
60
61
  }
61
62
  exports.getPermittedRoles = getPermittedRoles;
63
+ function isAAMInfo(permittedRoles) {
64
+ return (0, is_plain_object_1.isPlainObject)(permittedRoles);
65
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
2
2
  import type { NamespaceURI } from '@markuplint/ml-ast';
3
- export declare function getRoleSpec(specs: Readonly<MLMLSpec>, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
3
+ export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
4
4
  superClassRoles: ARIARoleInSchema[];
5
5
  }) | null;
@@ -1,3 +1,3 @@
1
1
  import type { MLMLSpec } from '../types';
2
2
  import type { Category } from '../types/permitted-structures';
3
- export declare function getSelectorsByContentModelCategory(specs: Readonly<MLMLSpec>, category: Category): ReadonlyArray<string>;
3
+ export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
@@ -1,2 +1,2 @@
1
1
  import type { ElementSpec } from '../types';
2
- export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(specs: Readonly<Pick<ElementSpec, 'name' | K>[]>, localName: string, namespace: string | null): Pick<ElementSpec, "name" | K> | null;
2
+ export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(specs: readonly Pick<ElementSpec, 'name' | K>[], localName: string, namespace: string | null): Pick<ElementSpec, "name" | K> | null;
@@ -6,7 +6,9 @@ const is_void_element_1 = require("./is-void-element");
6
6
  * @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
7
7
  * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
8
8
  */
9
- function isNothingContentModel(el) {
9
+ function isNothingContentModel(
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ el) {
10
12
  return (0, is_void_element_1.isVoidElement)(el) || ['iframe', 'template'].includes(el.localName);
11
13
  }
12
14
  exports.isNothingContentModel = isNothingContentModel;
@@ -1,5 +1,5 @@
1
1
  import type { MLMLSpec } from '../types';
2
- export declare function isPalpableElement(el: Element, specs: Readonly<MLMLSpec>, options?: {
3
- extendsSvg?: boolean;
4
- extendsExposableElements?: boolean;
2
+ export declare function isPalpableElement(el: Element, specs: MLMLSpec, options?: {
3
+ readonly extendsSvg?: boolean;
4
+ readonly extendsExposableElements?: boolean;
5
5
  }): boolean;
@@ -31,7 +31,9 @@ const exposableElementsThatAreNoBelongingAModel = [
31
31
  'thead',
32
32
  'tr',
33
33
  ];
34
- function isPalpableElement(el, specs, options) {
34
+ function isPalpableElement(
35
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
36
+ el, specs, options) {
35
37
  var _a, _b;
36
38
  const conditions = [((_a = specs.def['#contentModels']['#palpable']) === null || _a === void 0 ? void 0 : _a.join(',')) || ''];
37
39
  if ((options === null || options === void 0 ? void 0 : options.extendsSvg) !== false /* default true */) {
@@ -19,7 +19,9 @@ const voidElements = [
19
19
  'track',
20
20
  'wbr',
21
21
  ];
22
- function isVoidElement(el) {
22
+ function isVoidElement(
23
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
24
+ el) {
23
25
  return voidElements.includes(el.localName);
24
26
  }
25
27
  exports.isVoidElement = isVoidElement;
@@ -1,3 +1,4 @@
1
1
  import type { ARIAVersion } from '../types';
2
2
  import type { ARIA } from '../types/aria';
3
- export declare function resolveVersion(aria: ARIA, version: ARIAVersion): Omit<ARIA, ARIAVersion>;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function resolveVersion(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
@@ -9,5 +9,5 @@ import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types';
9
9
  export declare function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]): {
10
10
  cites: import("../types").Cites;
11
11
  def: import("../types").SpecDefs;
12
- specs: ElementSpec[];
12
+ specs: readonly ElementSpec[];
13
13
  };
@@ -10,7 +10,7 @@ const merge_array_1 = require("../utils/merge-array");
10
10
  * @param schemas `MLDocument.schemas`
11
11
  */
12
12
  function schemaToSpec(schemas) {
13
- var _a, _b, _c;
13
+ var _a, _b, _c, _d, _e;
14
14
  const [main, ...extendedSpecs] = schemas;
15
15
  const result = { ...main };
16
16
  for (const extendedSpec of extendedSpecs) {
@@ -18,37 +18,43 @@ function schemaToSpec(schemas) {
18
18
  result.cites = [...result.cites, ...extendedSpec.cites];
19
19
  }
20
20
  if (extendedSpec.def) {
21
+ const def = { ...result.def };
21
22
  if ((_a = extendedSpec.def['#globalAttrs']) === null || _a === void 0 ? void 0 : _a['#extends']) {
22
- result.def['#globalAttrs']['#HTMLGlobalAttrs'] = {
23
- ...(((_b = result.def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) || {}),
24
- ...(((_c = extendedSpec.def['#globalAttrs']) === null || _c === void 0 ? void 0 : _c['#extends']) || {}),
23
+ const gAttrs = { ...def['#globalAttrs'] };
24
+ gAttrs['#HTMLGlobalAttrs'] = {
25
+ ...((_c = (_b = def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) !== null && _c !== void 0 ? _c : {}),
26
+ ...((_e = (_d = extendedSpec.def['#globalAttrs']) === null || _d === void 0 ? void 0 : _d['#extends']) !== null && _e !== void 0 ? _e : {}),
25
27
  };
28
+ def['#globalAttrs'] = gAttrs;
26
29
  }
27
30
  if (extendedSpec.def['#aria']) {
28
- result.def['#aria'] = {
31
+ def['#aria'] = {
29
32
  '1.1': {
30
- roles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
31
- props: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
32
- graphicsRoles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].graphicsRoles),
33
+ roles: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
34
+ props: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
35
+ graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].graphicsRoles),
33
36
  },
34
37
  '1.2': {
35
- roles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
36
- props: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
37
- graphicsRoles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
38
+ roles: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
39
+ props: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
40
+ graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
38
41
  },
39
42
  };
40
43
  }
41
44
  if (extendedSpec.def['#contentModels']) {
45
+ const models = { ...def['#contentModels'] };
42
46
  const keys = new Set([
43
- ...Object.keys(result.def['#contentModels']),
47
+ ...Object.keys(def['#contentModels']),
44
48
  ...Object.keys(extendedSpec.def['#contentModels']),
45
49
  ]);
46
50
  for (const modelName of keys) {
47
- const mainModel = result.def['#contentModels'][modelName];
51
+ const mainModel = def['#contentModels'][modelName];
48
52
  const exModel = extendedSpec.def['#contentModels'][modelName];
49
- result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
53
+ models[modelName] = [...(mainModel !== null && mainModel !== void 0 ? mainModel : []), ...(exModel !== null && exModel !== void 0 ? exModel : [])];
50
54
  }
55
+ def['#contentModels'] = models;
51
56
  }
57
+ result.def = def;
52
58
  }
53
59
  if (extendedSpec.specs) {
54
60
  const exSpecs = extendedSpec.specs.slice();
@@ -66,10 +72,10 @@ function schemaToSpec(schemas) {
66
72
  ...exSpec,
67
73
  globalAttrs: {
68
74
  ...elSpec.globalAttrs,
69
- ...exSpec.globalAttrs,
75
+ ...exSpec === null || exSpec === void 0 ? void 0 : exSpec.globalAttrs,
70
76
  },
71
- attributes: mergeAttrSpec(elSpec.attributes, exSpec.attributes),
72
- categories: (0, merge_array_1.mergeArray)(elSpec.categories, exSpec.categories),
77
+ attributes: mergeAttrSpec(elSpec.attributes, exSpec === null || exSpec === void 0 ? void 0 : exSpec.attributes),
78
+ categories: (0, merge_array_1.mergeArray)(elSpec.categories, exSpec === null || exSpec === void 0 ? void 0 : exSpec.categories),
73
79
  });
74
80
  }
75
81
  result.specs = specs;
@@ -14,10 +14,7 @@ export type PermittedRoles = boolean | (string | {
14
14
  name: string;
15
15
  deprecated?: true;
16
16
  [k: string]: unknown;
17
- })[] | {
18
- 'core-aam'?: true;
19
- 'graphics-aam'?: true;
20
- };
17
+ })[] | PermittedARIAAAMInfo;
21
18
  /**
22
19
  * If set false:
23
20
  * > No role or aria-* attributes
@@ -127,6 +124,10 @@ export interface ARIA {
127
124
  };
128
125
  };
129
126
  }
127
+ export interface PermittedARIAAAMInfo {
128
+ 'core-aam'?: true;
129
+ 'graphics-aam'?: true;
130
+ }
130
131
  export interface ImplicitProperties {
131
132
  /**
132
133
  * This interface was referenced by `ImplicitProperties`'s JSON-Schema definition
@@ -2,45 +2,44 @@ import type { ARIA } from './aria';
2
2
  import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
3
3
  import type { ContentModel, Category } from './permitted-structures';
4
4
  import type { NamespaceURI } from '@markuplint/ml-ast';
5
+ import type { ReadonlyDeep } from 'type-fest';
5
6
  /**
6
7
  * markuplint Markup-language spec
7
8
  */
8
9
  export interface MLMLSpec {
9
- cites: Cites;
10
- def: SpecDefs;
11
- specs: ElementSpec[];
10
+ readonly cites: Cites;
11
+ readonly def: SpecDefs;
12
+ readonly specs: readonly ElementSpec[];
12
13
  }
13
14
  export type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
14
- name: ElementSpec['name'];
15
- attributes?: Record<string, Partial<Attribute>>;
15
+ readonly name: ElementSpec['name'];
16
+ readonly attributes?: Readonly<Record<string, Partial<Attribute>>>;
16
17
  };
17
18
  export type ExtendedSpec = {
18
- cites?: Cites;
19
- def?: Partial<SpecDefs>;
20
- specs?: ExtendedElementSpec[];
19
+ readonly cites?: Cites;
20
+ readonly def?: Partial<SpecDefs>;
21
+ readonly specs?: readonly ExtendedElementSpec[];
21
22
  };
22
23
  /**
23
24
  * Reference URLs
24
25
  */
25
- export type Cites = string[];
26
+ export type Cites = readonly string[];
26
27
  export type SpecDefs = {
27
- '#globalAttrs': Partial<{
28
- '#extends': Record<string, Partial<Attribute>>;
29
- '#HTMLGlobalAttrs': Record<string, Partial<Attribute>>;
30
- [OtherGlobalAttrs: string]: Record<string, Partial<Attribute>>;
31
- }>;
32
- '#aria': {
33
- '1.2': ARIASpec;
34
- '1.1': ARIASpec;
28
+ readonly '#globalAttrs': {
29
+ readonly [category: string]: Readonly<Record<string, Partial<Attribute>>>;
35
30
  };
36
- '#contentModels': {
37
- [model in Category]?: string[];
31
+ readonly '#aria': {
32
+ readonly '1.2': ARIASpec;
33
+ readonly '1.1': ARIASpec;
34
+ };
35
+ readonly '#contentModels': {
36
+ readonly [model in Category]?: readonly string[];
38
37
  };
39
38
  };
40
39
  type ARIASpec = {
41
- roles: ARIARoleInSchema[];
42
- graphicsRoles: ARIARoleInSchema[];
43
- props: ARIAProperty[];
40
+ readonly roles: readonly ARIARoleInSchema[];
41
+ readonly graphicsRoles: readonly ARIARoleInSchema[];
42
+ readonly props: readonly ARIAProperty[];
44
43
  };
45
44
  /**
46
45
  * Element spec
@@ -49,62 +48,62 @@ export type ElementSpec = {
49
48
  /**
50
49
  * Tag name
51
50
  */
52
- name: string;
51
+ readonly name: string;
53
52
  /**
54
53
  * Namespaces in XML
55
54
  * @see https://www.w3.org/TR/xml-names/
56
55
  */
57
- namespace?: NamespaceURI;
56
+ readonly namespace?: NamespaceURI;
58
57
  /**
59
58
  * Reference URL
60
59
  */
61
- cite: string;
60
+ readonly cite: string;
62
61
  /**
63
62
  * Description
64
63
  */
65
- description?: string;
64
+ readonly description?: string;
66
65
  /**
67
66
  * Experimental technology
68
67
  */
69
- experimental?: true;
68
+ readonly experimental?: true;
70
69
  /**
71
70
  * Obsolete or alternative elements
72
71
  */
73
- obsolete?: true | {
74
- alt: string;
72
+ readonly obsolete?: true | {
73
+ readonly alt: string;
75
74
  };
76
75
  /**
77
76
  * Deprecated
78
77
  */
79
- deprecated?: true;
78
+ readonly deprecated?: true;
80
79
  /**
81
80
  * Non-standard
82
81
  */
83
- nonStandard?: true;
82
+ readonly nonStandard?: true;
84
83
  /**
85
84
  * Element categories
86
85
  */
87
- categories: Category[];
86
+ readonly categories: readonly Category[];
88
87
  /**
89
88
  * Permitted contents and permitted parents
90
89
  */
91
- contentModel: ContentModel;
90
+ readonly contentModel: ReadonlyDeep<ContentModel>;
92
91
  /**
93
92
  * Tag omission
94
93
  */
95
- omission: ElementSpecOmission;
94
+ readonly omission: ElementSpecOmission;
96
95
  /**
97
96
  * Global Attributes
98
97
  */
99
- globalAttrs: GlobalAttributes;
98
+ readonly globalAttrs: ReadonlyDeep<GlobalAttributes>;
100
99
  /**
101
100
  * Attributes
102
101
  */
103
- attributes: Record<string, Attribute>;
102
+ readonly attributes: Readonly<Record<string, Attribute>>;
104
103
  /**
105
104
  * WAI-ARIA role and properties
106
105
  */
107
- aria: ARIA;
106
+ readonly aria: ReadonlyDeep<ARIA>;
108
107
  /**
109
108
  * If true, it is possible to add any properties as attributes,
110
109
  * for example, when using a template engine or a view language.
@@ -113,82 +112,82 @@ export type ElementSpec = {
113
112
  *
114
113
  * **It assumes to specify it on the parser plugin.**
115
114
  */
116
- possibleToAddProperties?: true;
115
+ readonly possibleToAddProperties?: true;
117
116
  };
118
117
  type ElementSpecOmission = false | ElementSpecOmissionTags;
119
118
  type ElementSpecOmissionTags = {
120
- startTag: boolean | ElementCondition;
121
- endTag: boolean | ElementCondition;
119
+ readonly startTag: boolean | ElementCondition;
120
+ readonly endTag: boolean | ElementCondition;
122
121
  };
123
122
  type ElementCondition = {
124
- __WIP__: 'WORK_IN_PROGRESS';
123
+ readonly __WIP__: 'WORK_IN_PROGRESS';
125
124
  };
126
125
  export type Attribute = {
127
- name: string;
128
- type: AttributeType | AttributeType[];
129
- description?: string;
130
- caseSensitive?: true;
131
- experimental?: boolean;
132
- obsolete?: true;
133
- deprecated?: boolean;
134
- nonStandard?: true;
126
+ readonly name: string;
127
+ readonly type: ReadonlyDeep<AttributeType> | readonly ReadonlyDeep<AttributeType>[];
128
+ readonly description?: string;
129
+ readonly caseSensitive?: true;
130
+ readonly experimental?: boolean;
131
+ readonly obsolete?: true;
132
+ readonly deprecated?: boolean;
133
+ readonly nonStandard?: true;
135
134
  } & ExtendableAttributeSpec;
136
- type ExtendableAttributeSpec = Omit<AttributeJSON, 'type'>;
135
+ type ExtendableAttributeSpec = Omit<ReadonlyDeep<AttributeJSON>, 'type'>;
137
136
  export type ARIARole = {
138
- name: string;
139
- isAbstract: boolean;
140
- requiredContextRole: string[];
141
- requiredOwnedElements: string[];
142
- accessibleNameRequired: boolean;
143
- accessibleNameFromAuthor: boolean;
144
- accessibleNameFromContent: boolean;
145
- accessibleNameProhibited: boolean;
146
- childrenPresentational: boolean;
147
- ownedProperties: ARIARoleOwnedProperties[];
148
- prohibitedProperties: string[];
137
+ readonly name: string;
138
+ readonly isAbstract: boolean;
139
+ readonly requiredContextRole: readonly string[];
140
+ readonly requiredOwnedElements: readonly string[];
141
+ readonly accessibleNameRequired: boolean;
142
+ readonly accessibleNameFromAuthor: boolean;
143
+ readonly accessibleNameFromContent: boolean;
144
+ readonly accessibleNameProhibited: boolean;
145
+ readonly childrenPresentational: boolean;
146
+ readonly ownedProperties: readonly ARIARoleOwnedProperties[];
147
+ readonly prohibitedProperties: readonly string[];
149
148
  };
150
149
  export type ARIARoleInSchema = Partial<ARIARole & {
151
- description: string;
152
- generalization: string[];
150
+ readonly description: string;
151
+ readonly generalization: readonly string[];
153
152
  }> & {
154
- name: string;
153
+ readonly name: string;
155
154
  };
156
155
  export type ARIARoleOwnedProperties = {
157
- name: string;
158
- inherited?: true;
159
- required?: true;
160
- deprecated?: true;
156
+ readonly name: string;
157
+ readonly inherited?: true;
158
+ readonly required?: true;
159
+ readonly deprecated?: true;
161
160
  };
162
161
  export type ARIAProperty = {
163
- name: string;
164
- type: 'property' | 'state';
165
- deprecated?: true;
166
- isGlobal?: true;
167
- value: ARIAAttributeValue;
168
- conditionalValue?: {
169
- role: string[];
170
- value: ARIAAttributeValue;
162
+ readonly name: string;
163
+ readonly type: 'property' | 'state';
164
+ readonly deprecated?: true;
165
+ readonly isGlobal?: true;
166
+ readonly value: ARIAAttributeValue;
167
+ readonly conditionalValue?: readonly {
168
+ readonly role: readonly string[];
169
+ readonly value: ARIAAttributeValue;
171
170
  }[];
172
- enum: string[];
173
- defaultValue?: string;
174
- equivalentHtmlAttrs?: EquivalentHtmlAttr[];
175
- valueDescriptions?: Record<string, string>;
171
+ readonly enum: readonly string[];
172
+ readonly defaultValue?: string;
173
+ readonly equivalentHtmlAttrs?: readonly EquivalentHtmlAttr[];
174
+ readonly valueDescriptions?: Readonly<Record<string, string>>;
176
175
  };
177
176
  export type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI';
178
177
  export type ARIAVersion = '1.1' | '1.2';
179
178
  export type EquivalentHtmlAttr = {
180
- htmlAttrName: string;
181
- isNotStrictEquivalent?: true;
182
- value: string | null;
179
+ readonly htmlAttrName: string;
180
+ readonly isNotStrictEquivalent?: true;
181
+ readonly value: string | null;
183
182
  };
184
183
  export type Matches = (selector: string) => boolean;
185
184
  export type ComputedRole = {
186
- el: Element;
187
- role: (ARIARole & {
188
- superClassRoles: ARIARoleInSchema[];
189
- isImplicit?: boolean;
185
+ readonly el: Element;
186
+ readonly role: (ARIARole & {
187
+ readonly superClassRoles: readonly ARIARoleInSchema[];
188
+ readonly isImplicit?: boolean;
190
189
  }) | null;
191
- errorType?: RoleComputationError;
190
+ readonly errorType?: RoleComputationError;
192
191
  };
193
192
  export type RoleComputationError = 'ABSTRACT' | 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL' | 'IMPLICIT_ROLE_NAMESPACE_ERROR' | 'INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL' | 'INVALID_LANDMARK' | 'INVALID_REQUIRED_CONTEXT_ROLE' | 'NO_EXPLICIT' | 'NO_OWNER' | 'NO_PERMITTED' | 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL' | 'ROLE_NO_EXISTS';
194
193
  export {};
@@ -1,5 +1,5 @@
1
1
  type NamedDefinition = string | {
2
- name: string;
2
+ readonly name: string;
3
3
  };
4
- export declare function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[];
4
+ export declare function mergeArray<T extends NamedDefinition>(a: readonly T[], b: readonly T[] | null | undefined): readonly T[];
5
5
  export {};
@@ -10,13 +10,14 @@ const namespaceURIMap = {
10
10
  xlink: 'http://www.w3.org/1999/xlink',
11
11
  };
12
12
  function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
13
+ var _a;
13
14
  const cached = cache.get(name + namespaceURI);
14
15
  if (cached) {
15
16
  return cached;
16
17
  }
17
18
  const [_explicitNS, _localName] = name.split(':');
18
19
  const explicitNS = _localName ? _explicitNS : null;
19
- const localName = _localName !== null && _localName !== void 0 ? _localName : _explicitNS;
20
+ const localName = (_a = _localName !== null && _localName !== void 0 ? _localName : _explicitNS) !== null && _a !== void 0 ? _a : '';
20
21
  const namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS || (0, get_ns_1.getNS)(namespaceURI || null))) ||
21
22
  'html';
22
23
  const result = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-spec",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Types and schema that specs of the Markup languages for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -25,14 +25,16 @@
25
25
  "schema": "run-s schema:*"
26
26
  },
27
27
  "dependencies": {
28
- "@markuplint/ml-ast": "3.0.0",
28
+ "@markuplint/ml-ast": "3.1.0",
29
29
  "dom-accessibility-api": "^0.5.14",
30
+ "is-plain-object": "^5.0.0",
30
31
  "tslib": "^2.4.1"
31
32
  },
32
33
  "devDependencies": {
33
- "@markuplint/test-tools": "3.0.0",
34
- "@markuplint/types": "3.2.0",
35
- "json-schema-to-typescript": "^11.0.2"
34
+ "@markuplint/test-tools": "3.1.0",
35
+ "@markuplint/types": "3.4.0",
36
+ "json-schema-to-typescript": "11.0.2",
37
+ "type-fest": "^3.6.1"
36
38
  },
37
- "gitHead": "791fb22a4df7acb985ced3808923fba0cd95c28a"
39
+ "gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
38
40
  }