@markuplint/ml-spec 4.10.0 → 4.10.2
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 +253 -0
- package/ARCHITECTURE.md +253 -0
- package/CHANGELOG.md +7 -4
- package/README.md +4 -186
- package/SKILL.md +116 -0
- package/docs/aria-algorithms.ja.md +651 -0
- package/docs/aria-algorithms.md +651 -0
- package/docs/html-algorithms.ja.md +469 -0
- package/docs/html-algorithms.md +469 -0
- package/docs/maintenance.ja.md +340 -0
- package/docs/maintenance.md +340 -0
- package/docs/spec-resolution.ja.md +540 -0
- package/docs/spec-resolution.md +551 -0
- package/docs/type-definitions.ja.md +561 -0
- package/docs/type-definitions.md +561 -0
- package/lib/algorithm/aria/accname-computation.d.ts +7 -0
- package/lib/algorithm/aria/accname-computation.js +7 -0
- package/lib/algorithm/aria/aria-specs.d.ts +7 -0
- package/lib/algorithm/aria/aria-specs.js +7 -0
- package/lib/algorithm/aria/get-aria.d.ts +12 -0
- package/lib/algorithm/aria/get-aria.js +12 -0
- package/lib/algorithm/aria/get-computed-aria-props.d.ts +22 -0
- package/lib/algorithm/aria/get-computed-aria-props.js +10 -0
- package/lib/algorithm/aria/get-computed-role.d.ts +12 -0
- package/lib/algorithm/aria/get-computed-role.js +12 -0
- package/lib/algorithm/aria/get-implicit-role.d.ts +18 -0
- package/lib/algorithm/aria/get-implicit-role.js +18 -0
- package/lib/algorithm/aria/get-permitted-roles.d.ts +9 -0
- package/lib/algorithm/aria/get-permitted-roles.js +9 -0
- package/lib/algorithm/aria/get-role-spec.d.ts +11 -0
- package/lib/algorithm/aria/get-role-spec.js +11 -0
- package/lib/algorithm/aria/has-required-owned-elements.d.ts +23 -0
- package/lib/algorithm/aria/has-required-owned-elements.js +23 -0
- package/lib/algorithm/aria/is-exposed.d.ts +7 -4
- package/lib/algorithm/aria/is-exposed.js +7 -4
- package/lib/algorithm/aria/is-presentational.d.ts +8 -0
- package/lib/algorithm/aria/is-presentational.js +8 -0
- package/lib/algorithm/aria/matches-context-role.d.ts +11 -0
- package/lib/algorithm/aria/matches-context-role.js +11 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.d.ts +9 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.js +9 -0
- package/lib/algorithm/html/get-content-model.d.ts +9 -0
- package/lib/algorithm/html/get-content-model.js +9 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.d.ts +8 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.js +8 -0
- package/lib/algorithm/html/is-nothing-content-model.d.ts +7 -0
- package/lib/algorithm/html/is-nothing-content-model.js +7 -0
- package/lib/algorithm/html/is-palpable-elements.d.ts +13 -0
- package/lib/algorithm/html/is-palpable-elements.js +13 -0
- package/lib/algorithm/html/is-void-element.d.ts +9 -0
- package/lib/algorithm/html/is-void-element.js +9 -0
- package/lib/algorithm/html/may-be-focusable.d.ts +10 -0
- package/lib/algorithm/html/may-be-focusable.js +10 -0
- package/lib/types/index.d.ts +54 -0
- package/lib/utils/aria-version.d.ts +6 -0
- package/lib/utils/aria-version.js +6 -0
- package/lib/utils/get-attr-specs-spec.d.ts +18 -0
- package/lib/utils/get-attr-specs-spec.js +18 -0
- package/lib/utils/get-attr-specs.d.ts +9 -0
- package/lib/utils/get-attr-specs.js +9 -0
- package/lib/utils/get-spec-by-tag-name.d.ts +11 -0
- package/lib/utils/get-spec-by-tag-name.js +11 -0
- package/lib/utils/get-spec.d.ts +11 -1
- package/lib/utils/get-spec.js +10 -0
- package/lib/utils/resolve-namespace.d.ts +13 -0
- package/lib/utils/resolve-namespace.js +10 -0
- package/lib/utils/schema-to-spec.d.ts +5 -2
- package/lib/utils/schema-to-spec.js +5 -2
- package/lib/utils/validate-aria-version.d.ts +7 -0
- package/lib/utils/validate-aria-version.js +7 -0
- package/package.json +6 -6
package/lib/types/index.d.ts
CHANGED
|
@@ -12,10 +12,19 @@ export interface MLMLSpec {
|
|
|
12
12
|
readonly def: SpecDefs;
|
|
13
13
|
readonly specs: readonly ElementSpec[];
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* An element specification for extending or overriding parts of the base spec.
|
|
17
|
+
* Only the `name` property is required; all other properties are optional partial overrides.
|
|
18
|
+
* Attributes use `Partial<Attribute>` to allow specifying only changed fields.
|
|
19
|
+
*/
|
|
15
20
|
export type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
|
|
16
21
|
readonly name: ElementSpec['name'];
|
|
17
22
|
readonly attributes?: Readonly<Record<string, Partial<Attribute>>>;
|
|
18
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* A partial specification used for extending or customizing the base markup language spec.
|
|
26
|
+
* Typically provided by parser plugins or framework-specific spec packages (e.g., `@markuplint/vue-spec`).
|
|
27
|
+
*/
|
|
19
28
|
export type ExtendedSpec = {
|
|
20
29
|
readonly cites?: Cites;
|
|
21
30
|
readonly def?: Partial<SpecDefs>;
|
|
@@ -25,6 +34,10 @@ export type ExtendedSpec = {
|
|
|
25
34
|
* Reference URLs
|
|
26
35
|
*/
|
|
27
36
|
export type Cites = readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Internal definition data within a markup language spec, containing global attributes,
|
|
39
|
+
* ARIA role/property definitions for each version, and content model category mappings.
|
|
40
|
+
*/
|
|
28
41
|
export type SpecDefs = {
|
|
29
42
|
readonly '#globalAttrs': {
|
|
30
43
|
readonly [category: string]: Readonly<Record<string, Partial<Attribute>>>;
|
|
@@ -124,6 +137,9 @@ type ElementSpecOmissionTags = {
|
|
|
124
137
|
type ElementCondition = {
|
|
125
138
|
readonly __WIP__: 'WORK_IN_PROGRESS';
|
|
126
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Describes a single HTML/SVG attribute with its type, description, and status flags.
|
|
142
|
+
*/
|
|
127
143
|
export type Attribute = {
|
|
128
144
|
readonly name: string;
|
|
129
145
|
readonly type: ReadonlyDeep<AttributeType> | readonly ReadonlyDeep<AttributeType>[];
|
|
@@ -135,6 +151,9 @@ export type Attribute = {
|
|
|
135
151
|
readonly nonStandard?: true;
|
|
136
152
|
} & ExtendableAttributeSpec;
|
|
137
153
|
type ExtendableAttributeSpec = Omit<ReadonlyDeep<AttributeJSON>, 'type'>;
|
|
154
|
+
/**
|
|
155
|
+
* A fully resolved ARIA role with all its properties, requirements, and naming constraints.
|
|
156
|
+
*/
|
|
138
157
|
export type ARIARole = {
|
|
139
158
|
readonly name: string;
|
|
140
159
|
readonly isAbstract: boolean;
|
|
@@ -149,18 +168,30 @@ export type ARIARole = {
|
|
|
149
168
|
readonly ownedProperties: readonly ARIARoleOwnedProperties[];
|
|
150
169
|
readonly prohibitedProperties: readonly string[];
|
|
151
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* An ARIA role as defined in the raw schema data. All properties are optional
|
|
173
|
+
* except `name`, since the schema may provide only partial role information.
|
|
174
|
+
*/
|
|
152
175
|
export type ARIARoleInSchema = Partial<ARIARole & {
|
|
153
176
|
readonly description: string;
|
|
154
177
|
readonly generalization: readonly string[];
|
|
155
178
|
}> & {
|
|
156
179
|
readonly name: string;
|
|
157
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Describes a property owned by an ARIA role, including whether it is inherited,
|
|
183
|
+
* required, or deprecated.
|
|
184
|
+
*/
|
|
158
185
|
export type ARIARoleOwnedProperties = {
|
|
159
186
|
readonly name: string;
|
|
160
187
|
readonly inherited?: true;
|
|
161
188
|
readonly required?: true;
|
|
162
189
|
readonly deprecated?: true;
|
|
163
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Describes an ARIA property or state, including its value type, enumeration values,
|
|
193
|
+
* global status, default value, conditional values per role, and equivalent HTML attributes.
|
|
194
|
+
*/
|
|
164
195
|
export type ARIAProperty = {
|
|
165
196
|
readonly name: string;
|
|
166
197
|
readonly type: 'property' | 'state';
|
|
@@ -176,14 +207,33 @@ export type ARIAProperty = {
|
|
|
176
207
|
readonly equivalentHtmlAttrs?: readonly EquivalentHtmlAttr[];
|
|
177
208
|
readonly valueDescriptions?: Readonly<Record<string, string>>;
|
|
178
209
|
};
|
|
210
|
+
/**
|
|
211
|
+
* The possible value types for ARIA attributes, as defined by the WAI-ARIA specification.
|
|
212
|
+
*/
|
|
179
213
|
export type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI';
|
|
214
|
+
/**
|
|
215
|
+
* A union type of supported ARIA specification version strings, derived from the `ariaVersions` tuple.
|
|
216
|
+
*/
|
|
180
217
|
export type ARIAVersion = (typeof ariaVersions)[number];
|
|
218
|
+
/**
|
|
219
|
+
* Describes an HTML attribute that is semantically equivalent to an ARIA property,
|
|
220
|
+
* enabling automatic mapping from HTML attributes to ARIA states/properties.
|
|
221
|
+
*/
|
|
181
222
|
export type EquivalentHtmlAttr = {
|
|
182
223
|
readonly htmlAttrName: string;
|
|
183
224
|
readonly isNotStrictEquivalent?: true;
|
|
184
225
|
readonly value: string | null;
|
|
185
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* A function that tests whether an element matches a given CSS selector string.
|
|
229
|
+
* Typically bound to `Element.prototype.matches`.
|
|
230
|
+
*/
|
|
186
231
|
export type Matches = (selector: string) => boolean;
|
|
232
|
+
/**
|
|
233
|
+
* The result of computing an element's ARIA role, containing the element reference,
|
|
234
|
+
* the resolved role specification (or null if no role applies), and an optional
|
|
235
|
+
* error type indicating issues during role computation.
|
|
236
|
+
*/
|
|
187
237
|
export type ComputedRole = {
|
|
188
238
|
readonly el: Element;
|
|
189
239
|
readonly role: (ARIARole & {
|
|
@@ -192,5 +242,9 @@ export type ComputedRole = {
|
|
|
192
242
|
}) | null;
|
|
193
243
|
readonly errorType?: RoleComputationError;
|
|
194
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* Error codes that may arise during ARIA role computation, indicating specific
|
|
247
|
+
* issues such as abstract roles, invalid context, or presentational conflicts.
|
|
248
|
+
*/
|
|
195
249
|
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';
|
|
196
250
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The supported ARIA specification versions as a readonly tuple.
|
|
3
|
+
*/
|
|
1
4
|
export declare const ariaVersions: readonly ["1.1", "1.2", "1.3"];
|
|
5
|
+
/**
|
|
6
|
+
* The recommended default ARIA specification version to use when none is explicitly specified.
|
|
7
|
+
*/
|
|
2
8
|
export declare const ARIA_RECOMMENDED_VERSION = "1.2";
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The supported ARIA specification versions as a readonly tuple.
|
|
3
|
+
*/
|
|
1
4
|
export const ariaVersions = ['1.1', '1.2', '1.3'];
|
|
5
|
+
/**
|
|
6
|
+
* The recommended default ARIA specification version to use when none is explicitly specified.
|
|
7
|
+
*/
|
|
2
8
|
export const ARIA_RECOMMENDED_VERSION = '1.2';
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import type { MLMLSpec, Attribute } from '../types/index.js';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the merged attribute specifications for an element identified by its local name
|
|
5
|
+
* and namespace. Combines global attributes from the relevant categories with the element's
|
|
6
|
+
* own attribute definitions. Results are cached by the namespace-qualified element name.
|
|
7
|
+
*
|
|
8
|
+
* @param localName - The local tag name of the element
|
|
9
|
+
* @param namespace - The namespace URI of the element, or null for HTML namespace
|
|
10
|
+
* @param schema - The full markup language specification containing attribute definitions
|
|
11
|
+
* @returns A sorted array of attribute specifications for the element, or null if the element is not found in the schema
|
|
12
|
+
*/
|
|
3
13
|
export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
|
|
4
14
|
type HasName = {
|
|
5
15
|
readonly name: string;
|
|
6
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Compares two items by name in a case-insensitive manner, suitable for use as
|
|
19
|
+
* a sort comparator. Accepts either objects with a `name` property or plain strings.
|
|
20
|
+
*
|
|
21
|
+
* @param a - The first item to compare (object with `name` property or a string)
|
|
22
|
+
* @param b - The second item to compare (object with `name` property or a string)
|
|
23
|
+
* @returns A negative number if `a` comes before `b`, positive if after, or 0 if equal
|
|
24
|
+
*/
|
|
7
25
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
8
26
|
export {};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { resolveNamespace } from './resolve-namespace.js';
|
|
2
2
|
const cacheMap = new Map();
|
|
3
3
|
const schemaCache = new WeakSet();
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the merged attribute specifications for an element identified by its local name
|
|
6
|
+
* and namespace. Combines global attributes from the relevant categories with the element's
|
|
7
|
+
* own attribute definitions. Results are cached by the namespace-qualified element name.
|
|
8
|
+
*
|
|
9
|
+
* @param localName - The local tag name of the element
|
|
10
|
+
* @param namespace - The namespace URI of the element, or null for HTML namespace
|
|
11
|
+
* @param schema - The full markup language specification containing attribute definitions
|
|
12
|
+
* @returns A sorted array of attribute specifications for the element, or null if the element is not found in the schema
|
|
13
|
+
*/
|
|
4
14
|
export function getAttrSpecs(localName, namespace, schema) {
|
|
5
15
|
if (!schemaCache.has(schema)) {
|
|
6
16
|
cacheMap.clear();
|
|
@@ -67,6 +77,14 @@ export function getAttrSpecs(localName, namespace, schema) {
|
|
|
67
77
|
cacheMap.set(localNameWithNS, attrList);
|
|
68
78
|
return attrList;
|
|
69
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Compares two items by name in a case-insensitive manner, suitable for use as
|
|
82
|
+
* a sort comparator. Accepts either objects with a `name` property or plain strings.
|
|
83
|
+
*
|
|
84
|
+
* @param a - The first item to compare (object with `name` property or a string)
|
|
85
|
+
* @param b - The second item to compare (object with `name` property or a string)
|
|
86
|
+
* @returns A negative number if `a` comes before `b`, positive if after, or 0 if equal
|
|
87
|
+
*/
|
|
70
88
|
export function nameCompare(a, b) {
|
|
71
89
|
const nameA = typeof a === 'string' ? a : a.name.toUpperCase();
|
|
72
90
|
const nameB = typeof b === 'string' ? b : b.name.toUpperCase();
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the attribute specifications for a DOM element by resolving its
|
|
4
|
+
* local name and namespace URI from the provided schema. This is a convenience
|
|
5
|
+
* wrapper around the spec-based `getAttrSpecs` that accepts a DOM element directly.
|
|
6
|
+
*
|
|
7
|
+
* @param el - The DOM element whose attribute specifications to retrieve
|
|
8
|
+
* @param schema - The full markup language specification containing attribute definitions
|
|
9
|
+
* @returns The array of attribute specifications for the element, or null if no spec exists
|
|
10
|
+
*/
|
|
2
11
|
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types/index.js").Attribute[] | null;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { getAttrSpecs as _getAttrSpecs } from './get-attr-specs-spec.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the attribute specifications for a DOM element by resolving its
|
|
4
|
+
* local name and namespace URI from the provided schema. This is a convenience
|
|
5
|
+
* wrapper around the spec-based `getAttrSpecs` that accepts a DOM element directly.
|
|
6
|
+
*
|
|
7
|
+
* @param el - The DOM element whose attribute specifications to retrieve
|
|
8
|
+
* @param schema - The full markup language specification containing attribute definitions
|
|
9
|
+
* @returns The array of attribute specifications for the element, or null if no spec exists
|
|
10
|
+
*/
|
|
2
11
|
export function getAttrSpecs(
|
|
3
12
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
13
|
el, schema) {
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Looks up an element specification by its local tag name and namespace. The tag name
|
|
4
|
+
* is resolved to a namespace-qualified form (e.g., `"svg:circle"`) before searching.
|
|
5
|
+
* Results are cached by the namespace-qualified name for subsequent lookups.
|
|
6
|
+
*
|
|
7
|
+
* @template K - The keys of `ElementSpec` to include in the returned spec object (defaults to all keys)
|
|
8
|
+
* @param specs - The array of element specifications to search
|
|
9
|
+
* @param localName - The local tag name of the element
|
|
10
|
+
* @param namespace - The namespace URI string, or null for HTML namespace
|
|
11
|
+
* @returns The matching element specification, or null if not found
|
|
12
|
+
*/
|
|
2
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;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { resolveNamespace } from './resolve-namespace.js';
|
|
2
2
|
const cache = new Map();
|
|
3
|
+
/**
|
|
4
|
+
* Looks up an element specification by its local tag name and namespace. The tag name
|
|
5
|
+
* is resolved to a namespace-qualified form (e.g., `"svg:circle"`) before searching.
|
|
6
|
+
* Results are cached by the namespace-qualified name for subsequent lookups.
|
|
7
|
+
*
|
|
8
|
+
* @template K - The keys of `ElementSpec` to include in the returned spec object (defaults to all keys)
|
|
9
|
+
* @param specs - The array of element specifications to search
|
|
10
|
+
* @param localName - The local tag name of the element
|
|
11
|
+
* @param namespace - The namespace URI string, or null for HTML namespace
|
|
12
|
+
* @returns The matching element specification, or null if not found
|
|
13
|
+
*/
|
|
3
14
|
export function getSpecByTagName(specs, localName, namespace) {
|
|
4
15
|
const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
|
|
5
16
|
let spec = cache.get(localNameWithNS);
|
package/lib/utils/get-spec.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types/index.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the element specification for a DOM element by looking up its local name
|
|
4
|
+
* and namespace URI in the provided specs array. This is a convenience wrapper around
|
|
5
|
+
* `getSpecByTagName` that accepts a DOM element directly.
|
|
6
|
+
*
|
|
7
|
+
* @template K - The keys of `ElementSpec` to include in the returned spec object
|
|
8
|
+
* @param el - The DOM element to look up
|
|
9
|
+
* @param specs - The array of element specifications to search
|
|
10
|
+
* @returns The matching element specification, or null if not found
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, K | "name"> | null;
|
package/lib/utils/get-spec.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { getSpecByTagName } from './get-spec-by-tag-name.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the element specification for a DOM element by looking up its local name
|
|
4
|
+
* and namespace URI in the provided specs array. This is a convenience wrapper around
|
|
5
|
+
* `getSpecByTagName` that accepts a DOM element directly.
|
|
6
|
+
*
|
|
7
|
+
* @template K - The keys of `ElementSpec` to include in the returned spec object
|
|
8
|
+
* @param el - The DOM element to look up
|
|
9
|
+
* @param specs - The array of element specifications to search
|
|
10
|
+
* @returns The matching element specification, or null if not found
|
|
11
|
+
*/
|
|
2
12
|
export function getSpec(
|
|
3
13
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
14
|
el, specs) {
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import type { NamespaceURI, Namespace } from '@markuplint/ml-ast';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a fully resolved element name with its namespace information.
|
|
4
|
+
*/
|
|
2
5
|
type NamespacedElementName = {
|
|
3
6
|
localNameWithNS: string;
|
|
4
7
|
localName: string;
|
|
5
8
|
namespace: Namespace;
|
|
6
9
|
namespaceURI: NamespaceURI;
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Resolves an element name and namespace URI into a normalized form containing
|
|
13
|
+
* the namespace-qualified name, bare local name, namespace shorthand, and full
|
|
14
|
+
* namespace URI. Handles explicit namespace prefixes (e.g., `"svg:circle"`) and
|
|
15
|
+
* falls back to HTML namespace when not specified. Results are cached.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The element name, optionally prefixed with a namespace (e.g., `"svg:circle"` or `"div"`)
|
|
18
|
+
* @param namespaceURI - The namespace URI string, or null (defaults to XHTML namespace)
|
|
19
|
+
* @returns The resolved namespace information including qualified name, local name, namespace shorthand, and full URI
|
|
20
|
+
*/
|
|
8
21
|
export declare function resolveNamespace(name: string, namespaceURI?: string | null): NamespacedElementName;
|
|
9
22
|
export {};
|
|
@@ -6,6 +6,16 @@ const namespaceURIMap = {
|
|
|
6
6
|
mml: 'http://www.w3.org/1998/Math/MathML',
|
|
7
7
|
xlink: 'http://www.w3.org/1999/xlink',
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Resolves an element name and namespace URI into a normalized form containing
|
|
11
|
+
* the namespace-qualified name, bare local name, namespace shorthand, and full
|
|
12
|
+
* namespace URI. Handles explicit namespace prefixes (e.g., `"svg:circle"`) and
|
|
13
|
+
* falls back to HTML namespace when not specified. Results are cached.
|
|
14
|
+
*
|
|
15
|
+
* @param name - The element name, optionally prefixed with a namespace (e.g., `"svg:circle"` or `"div"`)
|
|
16
|
+
* @param namespaceURI - The namespace URI string, or null (defaults to XHTML namespace)
|
|
17
|
+
* @returns The resolved namespace information including qualified name, local name, namespace shorthand, and full URI
|
|
18
|
+
*/
|
|
9
19
|
export function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
10
20
|
const cached = cache.get(name + namespaceURI);
|
|
11
21
|
if (cached) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Merges an HTML-spec schema with zero or more extended spec schemas into a single
|
|
4
|
+
* unified specification. Extended specs can add or override global attributes,
|
|
5
|
+
* ARIA definitions, content models, and element specifications.
|
|
4
6
|
*
|
|
5
7
|
* Ex: `@markuplint/html-spec` + `{ specs: { "\\.vue$": "@markuplint/vue-spec" } }` in configure files.
|
|
6
8
|
*
|
|
7
|
-
* @param schemas `
|
|
9
|
+
* @param schemas - A tuple where the first element is the base `MLMLSpec` and subsequent elements are extended specs to merge
|
|
10
|
+
* @returns The merged specification combining the base spec with all extensions
|
|
8
11
|
*/
|
|
9
12
|
export declare function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]): {
|
|
10
13
|
cites: import("../types/index.js").Cites;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { mergeArray } from './merge-array.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Merges an HTML-spec schema with zero or more extended spec schemas into a single
|
|
4
|
+
* unified specification. Extended specs can add or override global attributes,
|
|
5
|
+
* ARIA definitions, content models, and element specifications.
|
|
4
6
|
*
|
|
5
7
|
* Ex: `@markuplint/html-spec` + `{ specs: { "\\.vue$": "@markuplint/vue-spec" } }` in configure files.
|
|
6
8
|
*
|
|
7
|
-
* @param schemas `
|
|
9
|
+
* @param schemas - A tuple where the first element is the base `MLMLSpec` and subsequent elements are extended specs to merge
|
|
10
|
+
* @returns The merged specification combining the base spec with all extensions
|
|
8
11
|
*/
|
|
9
12
|
export function schemaToSpec(schemas) {
|
|
10
13
|
const [main, ...extendedSpecs] = schemas;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates whether a string is a supported ARIA specification version.
|
|
4
|
+
* Acts as a type guard, narrowing the input to the `ARIAVersion` type when `true`.
|
|
5
|
+
*
|
|
6
|
+
* @param version - The version string to validate
|
|
7
|
+
* @returns `true` if the version is a supported ARIA version (e.g., '1.1', '1.2', '1.3')
|
|
8
|
+
*/
|
|
2
9
|
export declare function validateAriaVersion(version: string): version is ARIAVersion;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ariaVersions } from './aria-version.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates whether a string is a supported ARIA specification version.
|
|
4
|
+
* Acts as a type guard, narrowing the input to the `ARIAVersion` type when `true`.
|
|
5
|
+
*
|
|
6
|
+
* @param version - The version string to validate
|
|
7
|
+
* @returns `true` if the version is a supported ARIA version (e.g., '1.1', '1.2', '1.3')
|
|
8
|
+
*/
|
|
2
9
|
export function validateAriaVersion(version) {
|
|
3
10
|
return ariaVersions.includes(version);
|
|
4
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.2",
|
|
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>",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"schema:prettier": "npx prettier --write \"./schemas/*.json\" \"./src/types/*.ts\" --log-level warn"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@markuplint/ml-ast": "4.4.
|
|
35
|
-
"@markuplint/types": "4.8.
|
|
36
|
-
"dom-accessibility-api": "0.7.
|
|
34
|
+
"@markuplint/ml-ast": "4.4.11",
|
|
35
|
+
"@markuplint/types": "4.8.2",
|
|
36
|
+
"dom-accessibility-api": "0.7.1",
|
|
37
37
|
"is-plain-object": "5.0.0",
|
|
38
38
|
"type-fest": "4.41.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@markuplint/test-tools": "4.5.
|
|
41
|
+
"@markuplint/test-tools": "4.5.23",
|
|
42
42
|
"json-schema-to-typescript": "15.0.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "193ee7c1262bbed95424e38efdf1a8e56ff049f4"
|
|
45
45
|
}
|