@markuplint/ml-spec 4.10.2 → 5.0.0-alpha.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 (75) hide show
  1. package/ARCHITECTURE.ja.md +24 -10
  2. package/ARCHITECTURE.md +24 -10
  3. package/CHANGELOG.md +18 -0
  4. package/README.md +2 -2
  5. package/docs/aria-algorithms.ja.md +180 -33
  6. package/docs/aria-algorithms.md +183 -34
  7. package/docs/html-algorithms.ja.md +2 -2
  8. package/docs/html-algorithms.md +2 -2
  9. package/docs/maintenance.ja.md +13 -22
  10. package/docs/maintenance.md +13 -22
  11. package/docs/spec-resolution.ja.md +37 -9
  12. package/docs/spec-resolution.md +45 -16
  13. package/docs/type-definitions.ja.md +8 -4
  14. package/docs/type-definitions.md +8 -4
  15. package/lib/algorithm/aria/accname/__tests__/test-helpers.d.ts +45 -0
  16. package/lib/algorithm/aria/accname/__tests__/test-helpers.js +120 -0
  17. package/lib/algorithm/aria/accname/aria-steps.d.ts +51 -0
  18. package/lib/algorithm/aria/accname/aria-steps.js +104 -0
  19. package/lib/algorithm/aria/accname/compute.d.ts +51 -0
  20. package/lib/algorithm/aria/accname/compute.js +101 -0
  21. package/lib/algorithm/aria/accname/element-names.d.ts +36 -0
  22. package/lib/algorithm/aria/accname/element-names.js +342 -0
  23. package/lib/algorithm/aria/accname/helpers.d.ts +98 -0
  24. package/lib/algorithm/aria/accname/helpers.js +330 -0
  25. package/lib/algorithm/aria/accname/index.d.ts +4 -0
  26. package/lib/algorithm/aria/accname/index.js +3 -0
  27. package/lib/algorithm/aria/accname/label-steps.d.ts +25 -0
  28. package/lib/algorithm/aria/accname/label-steps.js +66 -0
  29. package/lib/algorithm/aria/accname/svg-helpers.d.ts +17 -0
  30. package/lib/algorithm/aria/accname/svg-helpers.js +30 -0
  31. package/lib/algorithm/aria/accname/types.d.ts +70 -0
  32. package/lib/algorithm/aria/accname/types.js +2 -0
  33. package/lib/algorithm/aria/accname-computation.d.ts +14 -3
  34. package/lib/algorithm/aria/accname-computation.js +131 -8
  35. package/lib/algorithm/aria/aria-specs.d.ts +1 -0
  36. package/lib/algorithm/aria/get-aria.js +30 -4
  37. package/lib/algorithm/aria/get-computed-role.js +106 -26
  38. package/lib/algorithm/aria/get-explicit-role.d.ts +12 -0
  39. package/lib/algorithm/aria/get-explicit-role.js +12 -0
  40. package/lib/algorithm/aria/get-non-presentational-ancestor.d.ts +12 -0
  41. package/lib/algorithm/aria/get-non-presentational-ancestor.js +14 -2
  42. package/lib/algorithm/aria/get-permitted-roles-spec.d.ts +8 -4
  43. package/lib/algorithm/aria/get-permitted-roles-spec.js +19 -6
  44. package/lib/algorithm/aria/get-role-spec.js +10 -3
  45. package/lib/algorithm/aria/has-required-owned-elements.d.ts +2 -1
  46. package/lib/algorithm/aria/has-required-owned-elements.js +18 -15
  47. package/lib/algorithm/aria/is-presentational.d.ts +24 -0
  48. package/lib/algorithm/aria/is-presentational.js +31 -0
  49. package/lib/algorithm/aria/matches-context-role.d.ts +12 -4
  50. package/lib/algorithm/aria/matches-context-role.js +39 -6
  51. package/lib/algorithm/html/content-model-category-to-tag-names.js +1 -1
  52. package/lib/algorithm/html/get-content-model.d.ts +4 -2
  53. package/lib/algorithm/html/get-content-model.js +6 -7
  54. package/lib/const/accname.d.ts +29 -0
  55. package/lib/const/accname.js +76 -0
  56. package/lib/const/dom.d.ts +8 -0
  57. package/lib/const/dom.js +8 -0
  58. package/lib/const/index.d.ts +2 -0
  59. package/lib/const/index.js +2 -0
  60. package/lib/index.d.ts +3 -0
  61. package/lib/index.js +4 -0
  62. package/lib/types/index.d.ts +65 -0
  63. package/lib/utils/directive-resolver.d.ts +23 -0
  64. package/lib/utils/directive-resolver.js +50 -0
  65. package/lib/utils/get-attr-specs-spec.js +4 -3
  66. package/lib/utils/get-ns.d.ts +7 -0
  67. package/lib/utils/get-ns.js +7 -0
  68. package/lib/utils/get-spec-by-tag-name.d.ts +1 -1
  69. package/lib/utils/merge-array.d.ts +10 -0
  70. package/lib/utils/merge-array.js +10 -0
  71. package/lib/utils/resolve-version.d.ts +11 -0
  72. package/lib/utils/resolve-version.js +11 -0
  73. package/lib/utils/schema-to-spec.d.ts +2 -0
  74. package/lib/utils/schema-to-spec.js +15 -4
  75. package/package.json +9 -7
@@ -1,2 +1,9 @@
1
1
  import type { Namespace } from '@markuplint/ml-ast';
2
+ /**
3
+ * Maps a full namespace URI string to its shorthand `Namespace` identifier.
4
+ * Returns `'html'` as the default for any unrecognized or null namespace.
5
+ *
6
+ * @param namespaceURI - The full namespace URI, or null
7
+ * @returns The shorthand namespace identifier (`'html'`, `'svg'`, `'mml'`, or `'xlink'`)
8
+ */
2
9
  export declare function getNS(namespaceURI: string | null): Namespace;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Maps a full namespace URI string to its shorthand `Namespace` identifier.
3
+ * Returns `'html'` as the default for any unrecognized or null namespace.
4
+ *
5
+ * @param namespaceURI - The full namespace URI, or null
6
+ * @returns The shorthand namespace identifier (`'html'`, `'svg'`, `'mml'`, or `'xlink'`)
7
+ */
1
8
  export function getNS(namespaceURI) {
2
9
  switch (namespaceURI) {
3
10
  case 'http://www.w3.org/2000/svg': {
@@ -10,4 +10,4 @@ import type { ElementSpec } from '../types/index.js';
10
10
  * @param namespace - The namespace URI string, or null for HTML namespace
11
11
  * @returns The matching element specification, or null if not found
12
12
  */
13
- 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;
13
+ export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(specs: readonly Pick<ElementSpec, 'name' | K>[], localName: string, namespace: string | null): Pick<ElementSpec, K | "name"> | null;
@@ -1,5 +1,15 @@
1
1
  type NamedDefinition = string | {
2
2
  readonly name: string;
3
3
  };
4
+ /**
5
+ * Merges two arrays of named definitions by name, with items from `b` overriding
6
+ * matching items in `a`. When both items are objects, their properties are merged;
7
+ * when the overriding item is a string, the existing item is kept as-is.
8
+ *
9
+ * @template T - A named definition type (string or object with a `name` property)
10
+ * @param a - The base array of named definitions
11
+ * @param b - The array of named definitions to merge in, or null/undefined to skip
12
+ * @returns A new array with items from `b` merged into `a` by name
13
+ */
4
14
  export declare function mergeArray<T extends NamedDefinition>(a: readonly T[], b: readonly T[] | null | undefined): readonly T[];
5
15
  export {};
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Merges two arrays of named definitions by name, with items from `b` overriding
3
+ * matching items in `a`. When both items are objects, their properties are merged;
4
+ * when the overriding item is a string, the existing item is kept as-is.
5
+ *
6
+ * @template T - A named definition type (string or object with a `name` property)
7
+ * @param a - The base array of named definitions
8
+ * @param b - The array of named definitions to merge in, or null/undefined to skip
9
+ * @returns A new array with items from `b` merged into `a` by name
10
+ */
1
11
  export function mergeArray(a, b) {
2
12
  if (!b) {
3
13
  return a;
@@ -1,4 +1,15 @@
1
1
  import type { ARIA } from '../types/aria.js';
2
2
  import type { ARIAVersion } from '../types/index.js';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
+ /**
5
+ * Resolves an element's ARIA specification by merging version-specific overrides
6
+ * on top of the base properties. For each ARIA property (implicitRole, permittedRoles,
7
+ * etc.), the version-specific value takes precedence over the base value.
8
+ * `namingProhibited` is special-cased: ARIA 1.1 always uses the base value since
9
+ * `namingProhibited` was introduced in ARIA 1.2.
10
+ *
11
+ * @param aria - The element's full ARIA specification including version-specific blocks
12
+ * @param version - The ARIA specification version to resolve for
13
+ * @returns The resolved ARIA specification with version-specific overrides applied
14
+ */
4
15
  export declare function resolveVersion(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Resolves an element's ARIA specification by merging version-specific overrides
3
+ * on top of the base properties. For each ARIA property (implicitRole, permittedRoles,
4
+ * etc.), the version-specific value takes precedence over the base value.
5
+ * `namingProhibited` is special-cased: ARIA 1.1 always uses the base value since
6
+ * `namingProhibited` was introduced in ARIA 1.2.
7
+ *
8
+ * @param aria - The element's full ARIA specification including version-specific blocks
9
+ * @param version - The ARIA specification version to resolve for
10
+ * @returns The resolved ARIA specification with version-specific overrides applied
11
+ */
1
12
  export function resolveVersion(aria, version) {
2
13
  const implicitRole = aria[version]?.implicitRole ?? aria.implicitRole;
3
14
  const permittedRoles = aria[version]?.permittedRoles ?? aria.permittedRoles;
@@ -13,4 +13,6 @@ export declare function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpe
13
13
  cites: import("../types/index.js").Cites;
14
14
  def: import("../types/index.js").SpecDefs;
15
15
  specs: readonly ElementSpec[];
16
+ directivePatterns?: readonly import("../types/index.js").DirectivePattern[];
17
+ useIDLAttributeNames?: boolean;
16
18
  };
@@ -19,10 +19,12 @@ export function schemaToSpec(schemas) {
19
19
  if (extendedSpec.def) {
20
20
  const def = { ...result.def };
21
21
  if (extendedSpec.def['#globalAttrs']?.['#extends']) {
22
- const gAttrs = { ...def['#globalAttrs'] };
23
- gAttrs['#HTMLGlobalAttrs'] = {
24
- ...def['#globalAttrs']?.['#HTMLGlobalAttrs'],
25
- ...extendedSpec.def['#globalAttrs']?.['#extends'],
22
+ const gAttrs = {
23
+ ...def['#globalAttrs'],
24
+ '#HTMLGlobalAttrs': {
25
+ ...def['#globalAttrs']?.['#HTMLGlobalAttrs'],
26
+ ...extendedSpec.def['#globalAttrs']?.['#extends'],
27
+ },
26
28
  };
27
29
  def['#globalAttrs'] = gAttrs;
28
30
  }
@@ -32,16 +34,19 @@ export function schemaToSpec(schemas) {
32
34
  roles: mergeArray(def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
33
35
  props: mergeArray(def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
34
36
  graphicsRoles: mergeArray(def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].graphicsRoles),
37
+ dpubRoles: mergeArray(def['#aria']['1.1'].dpubRoles, extendedSpec.def['#aria']['1.1'].dpubRoles),
35
38
  },
36
39
  '1.2': {
37
40
  roles: mergeArray(def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
38
41
  props: mergeArray(def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
39
42
  graphicsRoles: mergeArray(def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
43
+ dpubRoles: mergeArray(def['#aria']['1.2'].dpubRoles, extendedSpec.def['#aria']['1.2'].dpubRoles),
40
44
  },
41
45
  '1.3': {
42
46
  roles: mergeArray(def['#aria']['1.3'].roles, extendedSpec.def['#aria']['1.3'].roles),
43
47
  props: mergeArray(def['#aria']['1.3'].props, extendedSpec.def['#aria']['1.3'].props),
44
48
  graphicsRoles: mergeArray(def['#aria']['1.3'].graphicsRoles, extendedSpec.def['#aria']['1.3'].graphicsRoles),
49
+ dpubRoles: mergeArray(def['#aria']['1.3'].dpubRoles, extendedSpec.def['#aria']['1.3'].dpubRoles),
45
50
  },
46
51
  };
47
52
  }
@@ -60,6 +65,12 @@ export function schemaToSpec(schemas) {
60
65
  }
61
66
  result.def = def;
62
67
  }
68
+ if (extendedSpec.directivePatterns) {
69
+ result.directivePatterns = [...(result.directivePatterns ?? []), ...extendedSpec.directivePatterns];
70
+ }
71
+ if (extendedSpec.useIDLAttributeNames != null) {
72
+ result.useIDLAttributeNames = extendedSpec.useIDLAttributeNames;
73
+ }
63
74
  if (extendedSpec.specs) {
64
75
  const exSpecs = [...extendedSpec.specs];
65
76
  const specs = [];
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@markuplint/ml-spec",
3
- "version": "4.10.2",
3
+ "version": "5.0.0-alpha.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>",
7
7
  "license": "MIT",
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
8
11
  "type": "module",
9
12
  "exports": {
10
13
  ".": {
@@ -31,15 +34,14 @@
31
34
  "schema:prettier": "npx prettier --write \"./schemas/*.json\" \"./src/types/*.ts\" --log-level warn"
32
35
  },
33
36
  "dependencies": {
34
- "@markuplint/ml-ast": "4.4.11",
35
- "@markuplint/types": "4.8.2",
36
- "dom-accessibility-api": "0.7.1",
37
+ "@markuplint/ml-ast": "5.0.0-alpha.0",
38
+ "@markuplint/types": "5.0.0-alpha.0",
37
39
  "is-plain-object": "5.0.0",
38
- "type-fest": "4.41.0"
40
+ "type-fest": "5.4.4"
39
41
  },
40
42
  "devDependencies": {
41
- "@markuplint/test-tools": "4.5.23",
43
+ "@markuplint/test-tools": "5.0.0-alpha.0",
42
44
  "json-schema-to-typescript": "15.0.4"
43
45
  },
44
- "gitHead": "193ee7c1262bbed95424e38efdf1a8e56ff049f4"
46
+ "gitHead": "13dcfc84ec83d87360c720e253383b60767e1b56"
45
47
  }