@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.
Files changed (71) hide show
  1. package/ARCHITECTURE.ja.md +253 -0
  2. package/ARCHITECTURE.md +253 -0
  3. package/CHANGELOG.md +7 -4
  4. package/README.md +4 -186
  5. package/SKILL.md +116 -0
  6. package/docs/aria-algorithms.ja.md +651 -0
  7. package/docs/aria-algorithms.md +651 -0
  8. package/docs/html-algorithms.ja.md +469 -0
  9. package/docs/html-algorithms.md +469 -0
  10. package/docs/maintenance.ja.md +340 -0
  11. package/docs/maintenance.md +340 -0
  12. package/docs/spec-resolution.ja.md +540 -0
  13. package/docs/spec-resolution.md +551 -0
  14. package/docs/type-definitions.ja.md +561 -0
  15. package/docs/type-definitions.md +561 -0
  16. package/lib/algorithm/aria/accname-computation.d.ts +7 -0
  17. package/lib/algorithm/aria/accname-computation.js +7 -0
  18. package/lib/algorithm/aria/aria-specs.d.ts +7 -0
  19. package/lib/algorithm/aria/aria-specs.js +7 -0
  20. package/lib/algorithm/aria/get-aria.d.ts +12 -0
  21. package/lib/algorithm/aria/get-aria.js +12 -0
  22. package/lib/algorithm/aria/get-computed-aria-props.d.ts +22 -0
  23. package/lib/algorithm/aria/get-computed-aria-props.js +10 -0
  24. package/lib/algorithm/aria/get-computed-role.d.ts +12 -0
  25. package/lib/algorithm/aria/get-computed-role.js +12 -0
  26. package/lib/algorithm/aria/get-implicit-role.d.ts +18 -0
  27. package/lib/algorithm/aria/get-implicit-role.js +18 -0
  28. package/lib/algorithm/aria/get-permitted-roles.d.ts +9 -0
  29. package/lib/algorithm/aria/get-permitted-roles.js +9 -0
  30. package/lib/algorithm/aria/get-role-spec.d.ts +11 -0
  31. package/lib/algorithm/aria/get-role-spec.js +11 -0
  32. package/lib/algorithm/aria/has-required-owned-elements.d.ts +23 -0
  33. package/lib/algorithm/aria/has-required-owned-elements.js +23 -0
  34. package/lib/algorithm/aria/is-exposed.d.ts +7 -4
  35. package/lib/algorithm/aria/is-exposed.js +7 -4
  36. package/lib/algorithm/aria/is-presentational.d.ts +8 -0
  37. package/lib/algorithm/aria/is-presentational.js +8 -0
  38. package/lib/algorithm/aria/matches-context-role.d.ts +11 -0
  39. package/lib/algorithm/aria/matches-context-role.js +11 -0
  40. package/lib/algorithm/html/content-model-category-to-tag-names.d.ts +9 -0
  41. package/lib/algorithm/html/content-model-category-to-tag-names.js +9 -0
  42. package/lib/algorithm/html/get-content-model.d.ts +9 -0
  43. package/lib/algorithm/html/get-content-model.js +9 -0
  44. package/lib/algorithm/html/get-selectors-by-content-model-category.d.ts +8 -0
  45. package/lib/algorithm/html/get-selectors-by-content-model-category.js +8 -0
  46. package/lib/algorithm/html/is-nothing-content-model.d.ts +7 -0
  47. package/lib/algorithm/html/is-nothing-content-model.js +7 -0
  48. package/lib/algorithm/html/is-palpable-elements.d.ts +13 -0
  49. package/lib/algorithm/html/is-palpable-elements.js +13 -0
  50. package/lib/algorithm/html/is-void-element.d.ts +9 -0
  51. package/lib/algorithm/html/is-void-element.js +9 -0
  52. package/lib/algorithm/html/may-be-focusable.d.ts +10 -0
  53. package/lib/algorithm/html/may-be-focusable.js +10 -0
  54. package/lib/types/index.d.ts +54 -0
  55. package/lib/utils/aria-version.d.ts +6 -0
  56. package/lib/utils/aria-version.js +6 -0
  57. package/lib/utils/get-attr-specs-spec.d.ts +18 -0
  58. package/lib/utils/get-attr-specs-spec.js +18 -0
  59. package/lib/utils/get-attr-specs.d.ts +9 -0
  60. package/lib/utils/get-attr-specs.js +9 -0
  61. package/lib/utils/get-spec-by-tag-name.d.ts +11 -0
  62. package/lib/utils/get-spec-by-tag-name.js +11 -0
  63. package/lib/utils/get-spec.d.ts +11 -1
  64. package/lib/utils/get-spec.js +10 -0
  65. package/lib/utils/resolve-namespace.d.ts +13 -0
  66. package/lib/utils/resolve-namespace.js +10 -0
  67. package/lib/utils/schema-to-spec.d.ts +5 -2
  68. package/lib/utils/schema-to-spec.js +5 -2
  69. package/lib/utils/validate-aria-version.d.ts +7 -0
  70. package/lib/utils/validate-aria-version.js +7 -0
  71. package/package.json +6 -6
@@ -0,0 +1,561 @@
1
+ # Type Definitions Reference
2
+
3
+ This document describes the type definitions and JSON schemas used by `@markuplint/ml-spec`.
4
+
5
+ ## Overview
6
+
7
+ `@markuplint/ml-spec` employs a two-layer type system:
8
+
9
+ 1. **Hand-written types** in `src/types/index.ts` -- define the runtime interfaces used throughout markuplint for element specs, ARIA roles, attributes, and role computation results.
10
+ 2. **Generated types** from JSON schemas -- define schema-validated structures that are auto-generated from `.schema.json` files using `json-schema-to-typescript`. These files carry "DO NOT MODIFY" headers.
11
+
12
+ Hand-written types import and extend generated types where needed (for example, `Attribute` extends `AttributeJSON`), creating a clean separation between the schema-validated data layer and the runtime API layer.
13
+
14
+ ## Core Specification Types
15
+
16
+ These types are defined in `src/types/index.ts` and form the backbone of markuplint's spec system.
17
+
18
+ ### `MLMLSpec`
19
+
20
+ The root specification type representing a complete markup language spec.
21
+
22
+ ```ts
23
+ interface MLMLSpec {
24
+ readonly cites: Cites; // Reference URLs (readonly string[])
25
+ readonly def: SpecDefs; // Internal definitions (global attrs, ARIA, content models)
26
+ readonly specs: readonly ElementSpec[]; // Element specifications array
27
+ }
28
+ ```
29
+
30
+ ### `ExtendedSpec`
31
+
32
+ A partial specification used by framework-specific packages to extend or customize the base spec. Used by `@markuplint/vue-spec`, `@markuplint/react-spec`, and similar packages.
33
+
34
+ ```ts
35
+ type ExtendedSpec = {
36
+ readonly cites?: Cites;
37
+ readonly def?: Partial<SpecDefs>;
38
+ readonly specs?: readonly ExtendedElementSpec[];
39
+ };
40
+ ```
41
+
42
+ `ExtendedElementSpec` is a partial version of `ElementSpec` where only `name` is required. All other properties are optional overrides. Attributes use `Partial<Attribute>` to allow specifying only changed fields:
43
+
44
+ ```ts
45
+ type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
46
+ readonly name: ElementSpec['name'];
47
+ readonly attributes?: Readonly<Record<string, Partial<Attribute>>>;
48
+ };
49
+ ```
50
+
51
+ ### `SpecDefs`
52
+
53
+ Internal definition data within a markup language spec, containing global attributes, ARIA role/property definitions, and content model category mappings.
54
+
55
+ ```ts
56
+ type SpecDefs = {
57
+ readonly '#globalAttrs': {
58
+ readonly [category: string]: Readonly<Record<string, Partial<Attribute>>>;
59
+ };
60
+ readonly '#aria': {
61
+ readonly '1.3': ARIASpec;
62
+ readonly '1.2': ARIASpec;
63
+ readonly '1.1': ARIASpec;
64
+ };
65
+ readonly '#contentModels': {
66
+ readonly [model in Category]?: readonly string[];
67
+ };
68
+ };
69
+ ```
70
+
71
+ - **`#globalAttrs`** -- Category-keyed attribute definitions. Each category (e.g., `#HTMLGlobalAttrs`, `#ARIAAttrs`) maps to a record of partial attribute definitions.
72
+ - **`#aria`** -- ARIA role/property definitions for each specification version (1.1, 1.2, 1.3). Each version contains `roles`, `graphicsRoles`, and `props` arrays.
73
+ - **`#contentModels`** -- Content model category to selector array mappings. Maps `Category` values (like `#flow`, `#phrasing`) to arrays of CSS selectors that match elements belonging to that category.
74
+
75
+ ### `ElementSpec`
76
+
77
+ A complete element specification describing all aspects of a single HTML or SVG element.
78
+
79
+ ```ts
80
+ type ElementSpec = {
81
+ readonly name: string; // Tag name
82
+ readonly namespace?: NamespaceURI; // XML namespace URI
83
+ readonly cite: string; // Reference URL
84
+ readonly description?: string; // Human-readable description
85
+
86
+ // Status flags
87
+ readonly experimental?: true; // Experimental technology
88
+ readonly obsolete?: true | { readonly alt: string }; // Obsolete (optionally with alternative)
89
+ readonly deprecated?: true; // Deprecated
90
+ readonly nonStandard?: true; // Non-standard
91
+
92
+ // Structural properties
93
+ readonly categories: readonly Category[]; // Element categories
94
+ readonly contentModel: ReadonlyDeep<ContentModel>; // Permitted content patterns
95
+ readonly omission: ElementSpecOmission; // Tag omission rules
96
+
97
+ // Attributes and ARIA
98
+ readonly globalAttrs: ReadonlyDeep<GlobalAttributes>; // Global attribute selection
99
+ readonly attributes: Readonly<Record<string, Attribute>>; // Element-specific attributes
100
+ readonly aria: ReadonlyDeep<ARIA>; // WAI-ARIA role and property mappings
101
+
102
+ // Template engine support
103
+ readonly possibleToAddProperties?: true; // Allow arbitrary properties (for template engines)
104
+ };
105
+ ```
106
+
107
+ `ElementSpecOmission` is either `false` (no omission allowed) or an object with `startTag` and `endTag` fields indicating whether tag omission is permitted.
108
+
109
+ ### `Attribute`
110
+
111
+ Describes a single HTML/SVG attribute with its type, description, and status flags.
112
+
113
+ ```ts
114
+ type Attribute = {
115
+ readonly name: string;
116
+ readonly type: ReadonlyDeep<AttributeType> | readonly ReadonlyDeep<AttributeType>[];
117
+ readonly description?: string;
118
+ readonly caseSensitive?: true;
119
+ readonly experimental?: boolean;
120
+ readonly obsolete?: true;
121
+ readonly deprecated?: boolean;
122
+ readonly nonStandard?: true;
123
+ } & ExtendableAttributeSpec;
124
+ ```
125
+
126
+ The `& ExtendableAttributeSpec` intersection adds fields from the generated `AttributeJSON` type (excluding `type`, which is overridden with the `ReadonlyDeep` wrapper): `defaultValue`, `required`, `requiredEither`, `noUse`, `condition`, `ineffective`, `animatable`.
127
+
128
+ ## ARIA Types
129
+
130
+ ### `ARIARole`
131
+
132
+ A fully resolved ARIA role with all its properties, requirements, and naming constraints.
133
+
134
+ ```ts
135
+ type ARIARole = {
136
+ readonly name: string; // Role name (e.g., 'button', 'navigation')
137
+ readonly isAbstract: boolean; // Whether this is an abstract role
138
+ readonly deprecated: boolean; // Whether this role is deprecated
139
+
140
+ // Context requirements
141
+ readonly requiredContextRole: readonly string[]; // Required parent roles
142
+ readonly requiredOwnedElements: readonly string[]; // Required child roles
143
+
144
+ // Accessible name constraints
145
+ readonly accessibleNameRequired: boolean; // Must have an accessible name
146
+ readonly accessibleNameFromAuthor: boolean; // Name can come from author (aria-label, etc.)
147
+ readonly accessibleNameFromContent: boolean; // Name can come from element content
148
+ readonly accessibleNameProhibited: boolean; // Name is prohibited
149
+
150
+ // Properties
151
+ readonly childrenPresentational: boolean; // Children are presentational
152
+ readonly ownedProperties: readonly ARIARoleOwnedProperties[];
153
+ readonly prohibitedProperties: readonly string[];
154
+ };
155
+ ```
156
+
157
+ ### `ARIARoleInSchema`
158
+
159
+ An ARIA role as defined in the raw schema data. All properties are optional except `name`, since the schema may provide only partial role information. Also includes optional `description` and `generalization` (super-class roles) fields.
160
+
161
+ ```ts
162
+ type ARIARoleInSchema = Partial<
163
+ ARIARole & {
164
+ readonly description: string;
165
+ readonly generalization: readonly string[];
166
+ }
167
+ > & {
168
+ readonly name: string;
169
+ };
170
+ ```
171
+
172
+ ### `ARIARoleOwnedProperties`
173
+
174
+ Describes a property owned by an ARIA role, including whether it is inherited, required, or deprecated.
175
+
176
+ ```ts
177
+ type ARIARoleOwnedProperties = {
178
+ readonly name: string; // Property name (e.g., 'aria-expanded')
179
+ readonly inherited?: true; // Inherited from a superclass role
180
+ readonly required?: true; // Required for this role
181
+ readonly deprecated?: true; // Deprecated for this role
182
+ };
183
+ ```
184
+
185
+ ### `ARIAProperty`
186
+
187
+ Describes an ARIA property or state, including its value type, enumeration values, and equivalent HTML attributes.
188
+
189
+ ```ts
190
+ type ARIAProperty = {
191
+ readonly name: string; // Property name (e.g., 'aria-hidden')
192
+ readonly type: 'property' | 'state'; // Whether this is a property or state
193
+ readonly deprecated?: true;
194
+ readonly isGlobal?: true; // Whether this is a global ARIA attribute
195
+ readonly value: ARIAAttributeValue; // Value type
196
+ readonly conditionalValue?: readonly {
197
+ // Role-specific value overrides
198
+ readonly role: readonly string[];
199
+ readonly value: ARIAAttributeValue;
200
+ }[];
201
+ readonly enum: readonly string[]; // Allowed token values
202
+ readonly defaultValue?: string;
203
+ readonly equivalentHtmlAttrs?: readonly EquivalentHtmlAttr[];
204
+ readonly valueDescriptions?: Readonly<Record<string, string>>;
205
+ };
206
+ ```
207
+
208
+ ### `ARIAAttributeValue`
209
+
210
+ The possible value types for ARIA attributes, as defined by the WAI-ARIA specification.
211
+
212
+ ```ts
213
+ type ARIAAttributeValue =
214
+ | 'true/false'
215
+ | 'tristate'
216
+ | 'true/false/undefined'
217
+ | 'ID reference'
218
+ | 'ID reference list'
219
+ | 'integer'
220
+ | 'number'
221
+ | 'string'
222
+ | 'token'
223
+ | 'token list'
224
+ | 'URI';
225
+ ```
226
+
227
+ ### `ARIAVersion`
228
+
229
+ A union type of supported ARIA specification version strings, derived from the `ariaVersions` tuple (`['1.1', '1.2', '1.3'] as const`).
230
+
231
+ ```ts
232
+ type ARIAVersion = '1.1' | '1.2' | '1.3';
233
+ ```
234
+
235
+ The recommended default version is `'1.2'` (defined as `ARIA_RECOMMENDED_VERSION` in `src/utils/aria-version.ts`).
236
+
237
+ ### `ComputedRole`
238
+
239
+ The result of computing an element's ARIA role.
240
+
241
+ ```ts
242
+ type ComputedRole = {
243
+ readonly el: Element;
244
+ readonly role:
245
+ | (ARIARole & {
246
+ readonly superClassRoles: readonly ARIARoleInSchema[];
247
+ readonly isImplicit?: boolean;
248
+ })
249
+ | null;
250
+ readonly errorType?: RoleComputationError;
251
+ };
252
+ ```
253
+
254
+ - **`el`** -- The DOM element reference.
255
+ - **`role`** -- The resolved role (with super-class chain and implicit flag), or `null` if no role applies.
256
+ - **`errorType`** -- Optional error code indicating issues during role computation.
257
+
258
+ ### `RoleComputationError`
259
+
260
+ Error codes that may arise during ARIA role computation, indicating specific issues such as abstract roles, invalid context, or presentational conflicts.
261
+
262
+ | Error Code | Description |
263
+ | --------------------------------------------------- | ------------------------------------------------------------------------ |
264
+ | `ABSTRACT` | An abstract role was assigned (abstract roles must not be used directly) |
265
+ | `GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL` | Element with global ARIA properties must not be presentational |
266
+ | `IMPLICIT_ROLE_NAMESPACE_ERROR` | Implicit role does not match the element's namespace |
267
+ | `INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL` | Interactive element must not be presentational |
268
+ | `INVALID_LANDMARK` | Invalid landmark role usage |
269
+ | `INVALID_REQUIRED_CONTEXT_ROLE` | Required context role is not satisfied |
270
+ | `NO_EXPLICIT` | No explicit role was assigned |
271
+ | `NO_OWNER` | No owning element found for required context |
272
+ | `NO_PERMITTED` | The role is not permitted on this element |
273
+ | `REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL` | Required owned element must not be presentational |
274
+ | `ROLE_NO_EXISTS` | The specified role does not exist |
275
+
276
+ ## Utility Types
277
+
278
+ ### `Matches`
279
+
280
+ A function type that tests whether an element matches a given CSS selector string. Typically bound to `Element.prototype.matches`.
281
+
282
+ ```ts
283
+ type Matches = (selector: string) => boolean;
284
+ ```
285
+
286
+ ### `Cites`
287
+
288
+ Reference URL array type used throughout the spec.
289
+
290
+ ```ts
291
+ type Cites = readonly string[];
292
+ ```
293
+
294
+ ### `EquivalentHtmlAttr`
295
+
296
+ Describes an HTML attribute that is semantically equivalent to an ARIA property, enabling automatic mapping from HTML attributes to ARIA states/properties.
297
+
298
+ ```ts
299
+ type EquivalentHtmlAttr = {
300
+ readonly htmlAttrName: string;
301
+ readonly isNotStrictEquivalent?: true;
302
+ readonly value: string | null;
303
+ };
304
+ ```
305
+
306
+ ## Generated Types
307
+
308
+ These types are automatically generated from JSON schema files by `json-schema-to-typescript`. They carry "DO NOT MODIFY" headers and should not be edited directly.
309
+
310
+ ### From `aria.schema.json` -- `src/types/aria.ts`
311
+
312
+ **`ARIA`** -- Element-level ARIA specification with conditions and version overrides.
313
+
314
+ ```ts
315
+ interface ARIA {
316
+ implicitRole: ImplicitRole;
317
+ permittedRoles: PermittedRoles;
318
+ namingProhibited?: true;
319
+ implicitProperties?: ImplicitProperties;
320
+ properties?: PermittedARIAProperties;
321
+ conditions?: {
322
+ [selector: string]: {
323
+ /* per-condition overrides */
324
+ };
325
+ };
326
+ '1.3'?: {
327
+ /* version-specific overrides */
328
+ };
329
+ '1.2'?: {
330
+ /* version-specific overrides */
331
+ };
332
+ '1.1'?: {
333
+ /* version-specific overrides */
334
+ };
335
+ }
336
+ ```
337
+
338
+ **`ImplicitRole`** -- The element's implicit (default) role.
339
+
340
+ ```ts
341
+ type ImplicitRole = false | string; // false means "No corresponding role"
342
+ ```
343
+
344
+ **`PermittedRoles`** -- Which roles are permitted on the element.
345
+
346
+ ```ts
347
+ type PermittedRoles =
348
+ | boolean // true = "Any role", false = "No role"
349
+ | (string | { name: string; deprecated?: true })[] // Specific role list
350
+ | PermittedARIAAAMInfo; // AAM-delegated (core-aam or graphics-aam)
351
+ ```
352
+
353
+ **`PermittedARIAProperties`** -- ARIA property constraints for an element.
354
+
355
+ ```ts
356
+ type PermittedARIAProperties =
357
+ | false // "No role or aria-* attributes"
358
+ | {
359
+ global?: true; // Allow global ARIA properties
360
+ role?: true | string | [string, ...string[]]; // Properties applicable to allowed roles
361
+ only?: [
362
+ /* specific properties */
363
+ ]; // Whitelist of allowed properties
364
+ without?: [
365
+ /* prohibited properties with severity */
366
+ ]; // Blacklist with severity levels
367
+ };
368
+ ```
369
+
370
+ **`ImplicitProperties`** -- Default ARIA property values (keys matching `^aria-.+`).
371
+
372
+ ```ts
373
+ interface ImplicitProperties {
374
+ [ariaProperty: string]: string; // e.g., { 'aria-checked': 'false' }
375
+ }
376
+ ```
377
+
378
+ ### From `attributes.schema.json` -- `src/types/attributes.ts`
379
+
380
+ **`AttributeType`** -- A large union type covering all recognized attribute value types. Includes:
381
+
382
+ - **CSS property names**: `<'color'>`, `<'display'>`, `<'font-size'>`, etc. (hundreds of standard, vendor-prefixed, and deprecated CSS properties)
383
+ - **CSS value types**: `<color>`, `<length>`, `<number>`, `<url>`, `<integer>`, etc.
384
+ - **SVG-specific types**: `<svg-path>`, `<view-box>`, `<preserve-aspect-ratio>`, etc.
385
+ - **markuplint custom types**: `DOMID`, `URL`, `BCP47`, `MIMEType`, `DateTime`, `AutoComplete`, `Int`, `Uint`, `Number`, `Boolean`, `Any`, `JSON`, `FunctionBody`, etc.
386
+ - **Structured type variants**: `List`, `Enum`, `Number`, `Directive`
387
+
388
+ **`GlobalAttributes`** -- Attribute category selection specifying which global attribute categories apply to an element.
389
+
390
+ ```ts
391
+ interface GlobalAttributes {
392
+ '#HTMLGlobalAttrs'?: boolean;
393
+ '#GlobalEventAttrs'?: boolean | string[];
394
+ '#HTMLLinkAndFetchingAttrs'?: string[];
395
+ '#HTMLEmbededAndMediaContentAttrs'?: string[];
396
+ '#HTMLFormControlElementAttrs'?: string[];
397
+ '#HTMLTableCellElementAttrs'?: string[];
398
+ '#ARIAAttrs'?: boolean;
399
+ '#SVGAnimationAdditionAttrs'?: string[];
400
+ '#SVGAnimationAttributeTargetAttrs'?: string[];
401
+ '#SVGAnimationEventAttrs'?: string[];
402
+ '#SVGAnimationTargetElementAttrs'?: string[];
403
+ '#SVGAnimationTimingAttrs'?: string[];
404
+ '#SVGAnimationValueAttrs'?: string[];
405
+ '#SVGConditionalProcessingAttrs'?: string[];
406
+ '#SVGCoreAttrs'?: string[];
407
+ '#SVGFilterPrimitiveAttrs'?: string[];
408
+ '#SVGPresentationAttrs'?: string[];
409
+ '#SVGTransferFunctionAttrs'?: string[];
410
+ '#XLinkAttrs'?: string[];
411
+ }
412
+ ```
413
+
414
+ **`AttributeJSON`** -- Raw attribute definition with type, conditions, and flags.
415
+
416
+ ```ts
417
+ interface AttributeJSON {
418
+ type?: AttributeType | [AttributeType, ...AttributeType[]];
419
+ defaultValue?: string;
420
+ deprecated?: boolean;
421
+ required?: boolean | AttributeCondition;
422
+ requiredEither?: string[];
423
+ noUse?: boolean;
424
+ condition?: AttributeCondition;
425
+ ineffective?: AttributeCondition;
426
+ animatable?: boolean;
427
+ experimental?: boolean;
428
+ }
429
+ ```
430
+
431
+ **`List`** -- Structured type for space-separated or comma-separated token lists.
432
+
433
+ ```ts
434
+ interface List {
435
+ token: string | Enum; // Token type or enum definition
436
+ separator: 'space' | 'comma'; // Separator type
437
+ disallowToSurroundBySpaces?: boolean;
438
+ allowEmpty?: boolean;
439
+ ordered?: boolean;
440
+ unique?: boolean;
441
+ caseInsensitive?: boolean;
442
+ number?: ('zeroOrMore' | 'oneOrMore') | { min: number; max: number };
443
+ }
444
+ ```
445
+
446
+ **`Enum`** -- Enumerated attribute values.
447
+
448
+ ```ts
449
+ interface Enum {
450
+ enum: [string, ...string[]]; // At least one value required
451
+ disallowToSurroundBySpaces?: boolean;
452
+ caseInsensitive?: boolean;
453
+ invalidValueDefault?: string; // Default when value is invalid
454
+ missingValueDefault?: string; // Default when attribute is missing
455
+ sameStates?: { [k: string]: unknown };
456
+ }
457
+ ```
458
+
459
+ **`Number`** -- Numeric attribute constraints.
460
+
461
+ ```ts
462
+ interface Number {
463
+ type: 'float' | 'integer';
464
+ gt?: number; // Greater than
465
+ gte?: number; // Greater than or equal
466
+ lt?: number; // Less than
467
+ lte?: number; // Less than or equal
468
+ clampable?: boolean;
469
+ }
470
+ ```
471
+
472
+ **`Directive`** -- Directive-based attribute validation for complex attributes containing both directives and tokens.
473
+
474
+ ```ts
475
+ interface Directive {
476
+ directive: [string, ...string[]]; // At least one directive
477
+ token: AttributeType; // Token type to validate
478
+ ref?: string; // Reference URL
479
+ }
480
+ ```
481
+
482
+ ### From `content-models.schema.json` -- `src/types/permitted-structures.ts`
483
+
484
+ **`PermittedContentPattern`** -- A union of all content model pattern types.
485
+
486
+ ```ts
487
+ type PermittedContentPattern =
488
+ | PermittedContentRequire // Required content
489
+ | PermittedContentOptional // Optional content
490
+ | PermittedContentOneOrMore // One or more occurrences
491
+ | PermittedContentZeroOrMore // Zero or more occurrences
492
+ | PermittedContentChoice // Choice between content alternatives
493
+ | PermittedContentTransparent; // Transparent content model
494
+ ```
495
+
496
+ Each pattern variant (except `PermittedContentTransparent`) accepts either a `Model` or a nested `PermittedContentPattern[]` and supports an optional `max` count.
497
+
498
+ **`ContentModel`** -- Complete content model for an element.
499
+
500
+ ```ts
501
+ interface ContentModel {
502
+ contents: PermittedContentPattern[] | boolean; // Content patterns or boolean
503
+ descendantOf?: string; // Context restriction
504
+ conditional?: {
505
+ // Condition-dependent content
506
+ condition: string;
507
+ contents: PermittedContentPattern[] | boolean;
508
+ }[];
509
+ }
510
+ ```
511
+
512
+ **`Category`** -- Content model category. Includes 13 HTML categories and 19 SVG categories.
513
+
514
+ HTML categories:
515
+
516
+ - `#text`, `#phrasing`, `#flow`, `#interactive`, `#heading`
517
+ - `#sectioning`, `#metadata`, `#embedded`, `#palpable`, `#script-supporting`
518
+
519
+ SVG categories:
520
+
521
+ - `#SVGAnimation`, `#SVGBasicShapes`, `#SVGContainer`, `#SVGDescriptive`
522
+ - `#SVGFilterPrimitive`, `#SVGFont`, `#SVGGradient`, `#SVGGraphics`
523
+ - `#SVGGraphicsReferencing`, `#SVGLightSource`, `#SVGNeverRendered`
524
+ - `#SVGNone`, `#SVGPaintServer`, `#SVGRenderable`, `#SVGShape`
525
+ - `#SVGStructural`, `#SVGStructurallyExternal`, `#SVGTextContent`, `#SVGTextContentChild`
526
+
527
+ **`Model`** and **`ContentType`**:
528
+
529
+ ```ts
530
+ type Model = ContentType | ContentType[];
531
+ type ContentType = string | Category;
532
+ ```
533
+
534
+ ## JSON Schema Files
535
+
536
+ The following JSON schema files are located in the `schemas/` directory.
537
+
538
+ | Schema File | Lines | Description |
539
+ | ------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------- |
540
+ | `element.schema.json` | 11 | Top-level element schema combining `$ref` pointers to content models, attributes, global attributes, and ARIA |
541
+ | `aria.schema.json` | 291 | ARIA role/property definitions including implicit roles, permitted roles, properties, and version overrides |
542
+ | `attributes.schema.json` | 190 | Attribute type unions, attribute JSON definitions, global attribute category selection, and attribute name patterns |
543
+ | `content-models.schema.json` | 215 | Content model patterns (require, optional, oneOrMore, zeroOrMore, choice, transparent) and category definitions |
544
+ | `global-attributes.schema.json` | 787 | Global attribute categories for HTML and SVG (auto-generated from `gen/global-attribute.data.ts`) |
545
+
546
+ ## Schema Generation Workflow
547
+
548
+ The schema generation pipeline works as follows:
549
+
550
+ 1. **`gen/global-attribute.data.ts`** defines the source-of-truth data for global attribute categories, listing all attribute names per category.
551
+
552
+ 2. **`gen/gen.ts`** reads the global attribute data and generates two schema files:
553
+ - `schemas/global-attributes.schema.json` -- The full global attributes schema with category definitions and per-category enums.
554
+ - `schemas/attributes.schema.json` -- The attributes schema including `GlobalAttributes` type with category-specific property selectors.
555
+
556
+ 3. **`json-schema-to-typescript`** converts each `.schema.json` file into corresponding TypeScript files:
557
+ - `schemas/aria.schema.json` --> `src/types/aria.ts`
558
+ - `schemas/attributes.schema.json` --> `src/types/attributes.ts`
559
+ - `schemas/content-models.schema.json` --> `src/types/permitted-structures.ts`
560
+
561
+ 4. Generated TypeScript files include "DO NOT MODIFY" headers. To update generated types, modify the source JSON schema (or the generation script for auto-generated schemas), then re-run the generation pipeline.
@@ -1 +1,8 @@
1
+ /**
2
+ * Computes the accessible name for an element using the WAI-ARIA accessible name computation algorithm.
3
+ * Falls back to the placeholder attribute value for input elements when no accessible name is found.
4
+ *
5
+ * @param el - The DOM element to compute the accessible name for
6
+ * @returns The computed accessible name string, or an empty string if none is found
7
+ */
1
8
  export declare function getAccname(el: Element): string;
@@ -1,5 +1,12 @@
1
1
  // @ts-ignore
2
2
  import { computeAccessibleName } from 'dom-accessibility-api';
3
+ /**
4
+ * Computes the accessible name for an element using the WAI-ARIA accessible name computation algorithm.
5
+ * Falls back to the placeholder attribute value for input elements when no accessible name is found.
6
+ *
7
+ * @param el - The DOM element to compute the accessible name for
8
+ * @returns The computed accessible name string, or an empty string if none is found
9
+ */
3
10
  export function getAccname(
4
11
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
12
  el) {
@@ -1,4 +1,11 @@
1
1
  import type { ARIAVersion, MLMLSpec } from '../../types/index.js';
2
+ /**
3
+ * Retrieves the ARIA specification data for a given ARIA version from the markup language spec.
4
+ *
5
+ * @param specs - The full markup language specification containing ARIA definitions
6
+ * @param version - The ARIA specification version to retrieve (e.g., '1.1', '1.2', '1.3')
7
+ * @returns The ARIA specification data including roles, properties, and graphics roles for the requested version
8
+ */
2
9
  export declare function ariaSpecs(specs: MLMLSpec, version: ARIAVersion): {
3
10
  readonly roles: readonly import("../../types/index.js").ARIARoleInSchema[];
4
11
  readonly graphicsRoles: readonly import("../../types/index.js").ARIARoleInSchema[];
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Retrieves the ARIA specification data for a given ARIA version from the markup language spec.
3
+ *
4
+ * @param specs - The full markup language specification containing ARIA definitions
5
+ * @param version - The ARIA specification version to retrieve (e.g., '1.1', '1.2', '1.3')
6
+ * @returns The ARIA specification data including roles, properties, and graphics roles for the requested version
7
+ */
1
8
  export function ariaSpecs(specs, version) {
2
9
  const aria = specs.def['#aria'];
3
10
  return aria[version];
@@ -1,4 +1,16 @@
1
1
  import type { ARIA } from '../../types/aria.js';
2
2
  import type { ARIAVersion, Matches, MLMLSpec } from '../../types/index.js';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
+ /**
5
+ * Retrieves the resolved ARIA specification for an element, taking into account
6
+ * ARIA version differences and conditional overrides based on the element's
7
+ * current attribute state (e.g., `input[type=checkbox]` vs `input[type=text]`).
8
+ *
9
+ * @param specs - The full markup language specification
10
+ * @param localName - The local tag name of the element
11
+ * @param namespace - The namespace URI of the element, or null
12
+ * @param version - The ARIA specification version to use
13
+ * @param matches - A function that tests whether the element matches a CSS selector
14
+ * @returns The resolved ARIA specification for the element, or null if no spec exists
15
+ */
4
16
  export declare function getARIA(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
@@ -1,6 +1,18 @@
1
1
  import { getSpecByTagName } from '../../utils/get-spec-by-tag-name.js';
2
2
  import { resolveVersion } from '../../utils/resolve-version.js';
3
3
  const cache = new Map();
4
+ /**
5
+ * Retrieves the resolved ARIA specification for an element, taking into account
6
+ * ARIA version differences and conditional overrides based on the element's
7
+ * current attribute state (e.g., `input[type=checkbox]` vs `input[type=text]`).
8
+ *
9
+ * @param specs - The full markup language specification
10
+ * @param localName - The local tag name of the element
11
+ * @param namespace - The namespace URI of the element, or null
12
+ * @param version - The ARIA specification version to use
13
+ * @param matches - A function that tests whether the element matches a CSS selector
14
+ * @returns The resolved ARIA specification for the element, or null if no spec exists
15
+ */
4
16
  export function getARIA(specs, localName, namespace, version, matches) {
5
17
  const aria = getVersionResolvedARIA(specs, localName, namespace, version);
6
18
  if (!aria) {
@@ -1,5 +1,11 @@
1
1
  import type { ARIAVersion, MLMLSpec } from '../../types/index.js';
2
+ /**
3
+ * A record mapping ARIA property names to their computed property details.
4
+ */
2
5
  type ARIAProps = Record<string, ARIAProp>;
6
+ /**
7
+ * Represents a single computed ARIA property with its resolved value and metadata.
8
+ */
3
9
  type ARIAProp = {
4
10
  name: string;
5
11
  value: string | undefined;
@@ -7,6 +13,22 @@ type ARIAProp = {
7
13
  deprecated: boolean;
8
14
  from: ARIAPropReferenceType;
9
15
  };
16
+ /**
17
+ * Indicates the source from which an ARIA property value was derived:
18
+ * - `'default'`: The property's default value from the ARIA spec
19
+ * - `'html-attr'`: A value mapped from an equivalent HTML attribute
20
+ * - `'aria-attr'`: A value explicitly set via an `aria-*` attribute
21
+ */
10
22
  type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
23
+ /**
24
+ * Computes the resolved ARIA properties for an element based on its computed role.
25
+ * Resolves property values by checking explicit `aria-*` attributes first,
26
+ * then equivalent HTML attributes, and finally falling back to spec-defined defaults.
27
+ *
28
+ * @param specs - The full markup language specification
29
+ * @param el - The DOM element to compute ARIA properties for
30
+ * @param version - The ARIA specification version to use
31
+ * @returns A record of ARIA property names to their computed property details, or an empty record if the element has no computed role
32
+ */
11
33
  export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
12
34
  export {};