@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.
- package/ARCHITECTURE.ja.md +24 -10
- package/ARCHITECTURE.md +24 -10
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/docs/aria-algorithms.ja.md +180 -33
- package/docs/aria-algorithms.md +183 -34
- package/docs/html-algorithms.ja.md +2 -2
- package/docs/html-algorithms.md +2 -2
- package/docs/maintenance.ja.md +13 -22
- package/docs/maintenance.md +13 -22
- package/docs/spec-resolution.ja.md +37 -9
- package/docs/spec-resolution.md +45 -16
- package/docs/type-definitions.ja.md +8 -4
- package/docs/type-definitions.md +8 -4
- package/lib/algorithm/aria/accname/__tests__/test-helpers.d.ts +45 -0
- package/lib/algorithm/aria/accname/__tests__/test-helpers.js +120 -0
- package/lib/algorithm/aria/accname/aria-steps.d.ts +51 -0
- package/lib/algorithm/aria/accname/aria-steps.js +104 -0
- package/lib/algorithm/aria/accname/compute.d.ts +51 -0
- package/lib/algorithm/aria/accname/compute.js +101 -0
- package/lib/algorithm/aria/accname/element-names.d.ts +36 -0
- package/lib/algorithm/aria/accname/element-names.js +342 -0
- package/lib/algorithm/aria/accname/helpers.d.ts +98 -0
- package/lib/algorithm/aria/accname/helpers.js +330 -0
- package/lib/algorithm/aria/accname/index.d.ts +4 -0
- package/lib/algorithm/aria/accname/index.js +3 -0
- package/lib/algorithm/aria/accname/label-steps.d.ts +25 -0
- package/lib/algorithm/aria/accname/label-steps.js +66 -0
- package/lib/algorithm/aria/accname/svg-helpers.d.ts +17 -0
- package/lib/algorithm/aria/accname/svg-helpers.js +30 -0
- package/lib/algorithm/aria/accname/types.d.ts +70 -0
- package/lib/algorithm/aria/accname/types.js +2 -0
- package/lib/algorithm/aria/accname-computation.d.ts +14 -3
- package/lib/algorithm/aria/accname-computation.js +131 -8
- package/lib/algorithm/aria/aria-specs.d.ts +1 -0
- package/lib/algorithm/aria/get-aria.js +30 -4
- package/lib/algorithm/aria/get-computed-role.js +106 -26
- package/lib/algorithm/aria/get-explicit-role.d.ts +12 -0
- package/lib/algorithm/aria/get-explicit-role.js +12 -0
- package/lib/algorithm/aria/get-non-presentational-ancestor.d.ts +12 -0
- package/lib/algorithm/aria/get-non-presentational-ancestor.js +14 -2
- package/lib/algorithm/aria/get-permitted-roles-spec.d.ts +8 -4
- package/lib/algorithm/aria/get-permitted-roles-spec.js +19 -6
- package/lib/algorithm/aria/get-role-spec.js +10 -3
- package/lib/algorithm/aria/has-required-owned-elements.d.ts +2 -1
- package/lib/algorithm/aria/has-required-owned-elements.js +18 -15
- package/lib/algorithm/aria/is-presentational.d.ts +24 -0
- package/lib/algorithm/aria/is-presentational.js +31 -0
- package/lib/algorithm/aria/matches-context-role.d.ts +12 -4
- package/lib/algorithm/aria/matches-context-role.js +39 -6
- package/lib/algorithm/html/content-model-category-to-tag-names.js +1 -1
- package/lib/algorithm/html/get-content-model.d.ts +4 -2
- package/lib/algorithm/html/get-content-model.js +6 -7
- package/lib/const/accname.d.ts +29 -0
- package/lib/const/accname.js +76 -0
- package/lib/const/dom.d.ts +8 -0
- package/lib/const/dom.js +8 -0
- package/lib/const/index.d.ts +2 -0
- package/lib/const/index.js +2 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +4 -0
- package/lib/types/index.d.ts +65 -0
- package/lib/utils/directive-resolver.d.ts +23 -0
- package/lib/utils/directive-resolver.js +50 -0
- package/lib/utils/get-attr-specs-spec.js +4 -3
- package/lib/utils/get-ns.d.ts +7 -0
- package/lib/utils/get-ns.js +7 -0
- package/lib/utils/get-spec-by-tag-name.d.ts +1 -1
- package/lib/utils/merge-array.d.ts +10 -0
- package/lib/utils/merge-array.js +10 -0
- package/lib/utils/resolve-version.d.ts +11 -0
- package/lib/utils/resolve-version.js +11 -0
- package/lib/utils/schema-to-spec.d.ts +2 -0
- package/lib/utils/schema-to-spec.js +15 -4
- package/package.json +9 -7
package/lib/utils/get-ns.d.ts
CHANGED
|
@@ -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;
|
package/lib/utils/get-ns.js
CHANGED
|
@@ -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"
|
|
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 {};
|
package/lib/utils/merge-array.js
CHANGED
|
@@ -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 = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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": "
|
|
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": "
|
|
35
|
-
"@markuplint/types": "
|
|
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.
|
|
40
|
+
"type-fest": "5.4.4"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@markuplint/test-tools": "
|
|
43
|
+
"@markuplint/test-tools": "5.0.0-alpha.0",
|
|
42
44
|
"json-schema-to-typescript": "15.0.4"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "13dcfc84ec83d87360c720e253383b60767e1b56"
|
|
45
47
|
}
|