@markuplint/ml-spec 3.0.0-canary.5 → 3.0.0-dev.176

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 (128) hide show
  1. package/README.md +1 -1
  2. package/lib/constant/aria-version.d.ts +2 -0
  3. package/lib/constant/aria-version.js +5 -0
  4. package/lib/dom-traverse/accname-computation.js +3 -1
  5. package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
  6. package/lib/dom-traverse/get-attr-specs.js +3 -1
  7. package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
  8. package/lib/dom-traverse/get-computed-aria-props.js +4 -2
  9. package/lib/dom-traverse/get-computed-role.d.ts +6 -1
  10. package/lib/dom-traverse/get-computed-role.js +41 -10
  11. package/lib/dom-traverse/get-content-model.d.ts +28 -2
  12. package/lib/dom-traverse/get-content-model.js +4 -2
  13. package/lib/dom-traverse/get-explicit-role.js +9 -4
  14. package/lib/dom-traverse/get-implicit-role.d.ts +6 -2
  15. package/lib/dom-traverse/get-implicit-role.js +6 -2
  16. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +10 -4
  17. package/lib/dom-traverse/get-non-presentational-ancestor.js +10 -2
  18. package/lib/dom-traverse/get-permitted-roles.d.ts +7 -3
  19. package/lib/dom-traverse/get-permitted-roles.js +3 -1
  20. package/lib/dom-traverse/get-spec.d.ts +4 -1
  21. package/lib/dom-traverse/get-spec.js +3 -1
  22. package/lib/dom-traverse/has-required-owned-elements.d.ts +8 -2
  23. package/lib/dom-traverse/has-required-owned-elements.js +14 -8
  24. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  25. package/lib/dom-traverse/is-exposed.js +43 -7
  26. package/lib/dom-traverse/matches-context-role.d.ts +7 -0
  27. package/lib/dom-traverse/matches-context-role.js +27 -0
  28. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  29. package/lib/dom-traverse/may-be-focusable.js +3 -1
  30. package/lib/index.d.ts +4 -0
  31. package/lib/index.js +4 -0
  32. package/lib/specs/aria-specs.d.ts +7 -4
  33. package/lib/specs/content-model-category-to-tag-names.d.ts +4 -1
  34. package/lib/specs/get-aria.d.ts +8 -1
  35. package/lib/specs/get-aria.js +8 -2
  36. package/lib/specs/get-attr-specs.d.ts +6 -2
  37. package/lib/specs/get-attr-specs.js +2 -14
  38. package/lib/specs/get-implicit-role.d.ts +7 -1
  39. package/lib/specs/get-permitted-roles.d.ts +9 -3
  40. package/lib/specs/get-permitted-roles.js +19 -15
  41. package/lib/specs/get-role-spec.d.ts +10 -3
  42. package/lib/specs/get-role-spec.js +2 -2
  43. package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
  44. package/lib/specs/get-selectors-by-content-model-category.js +1 -1
  45. package/lib/specs/get-spec-by-tag-name.d.ts +5 -1
  46. package/lib/specs/get-spec-by-tag-name.js +3 -2
  47. package/lib/specs/is-nothing-content-model.d.ts +5 -0
  48. package/lib/specs/is-nothing-content-model.js +14 -0
  49. package/lib/specs/is-palpable-elements.d.ts +8 -4
  50. package/lib/specs/is-palpable-elements.js +6 -4
  51. package/lib/specs/is-void-element.js +3 -1
  52. package/lib/specs/resolve-version.d.ts +5 -1
  53. package/lib/specs/resolve-version.js +1 -1
  54. package/lib/specs/schema-to-spec.d.ts +4 -4
  55. package/lib/specs/schema-to-spec.js +29 -18
  56. package/lib/types/aria.d.ts +149 -114
  57. package/lib/types/attributes.d.ts +1490 -111
  58. package/lib/types/index.d.ts +178 -149
  59. package/lib/types/permitted-structures.d.ts +74 -31
  60. package/lib/utils/merge-array.d.ts +9 -4
  61. package/lib/utils/resolve-namespace.d.ts +4 -4
  62. package/lib/utils/resolve-namespace.js +3 -2
  63. package/lib/utils/validateAriaVersion.d.ts +2 -0
  64. package/lib/utils/validateAriaVersion.js +8 -0
  65. package/package.json +13 -8
  66. package/{src/dom-traverse/accname-computation.spec.ts → test/dom-traverse/accname-computation.spec.js} +4 -4
  67. package/test/dom-traverse/get-computed-aria-props.spec.js +758 -0
  68. package/test/dom-traverse/get-computed-role.spec.js +294 -0
  69. package/test/dom-traverse/get-implicit-role.spec.js +40 -0
  70. package/{src/dom-traverse/has-required-owned-elements.spec.ts → test/dom-traverse/has-required-owned-elements.spec.js} +7 -9
  71. package/{src/dom-traverse/is-exposed.spec.ts → test/dom-traverse/is-exposed.spec.js} +29 -9
  72. package/test/dom-traverse/matches-context-role.spec.js +60 -0
  73. package/{src/specs/get-attr-specs.spec.ts → test/specs/get-attr-specs.spec.js} +2 -8
  74. package/{src/specs/get-implicit-role.spec.ts → test/specs/get-implicit-role.spec.js} +9 -11
  75. package/{src/specs/get-permitted-roles.spec.ts → test/specs/get-permitted-roles.spec.js} +8 -10
  76. package/{src/specs/get-role-spec.spec.ts → test/specs/get-role-spec.spec.js} +4 -4
  77. package/{src/specs/get-spec-by-tag-name.spec.ts → test/specs/get-spec-by-tag-name.spec.js} +2 -2
  78. package/test/specs/resolve-version.spec.js +34 -0
  79. package/test/specs/schema-to-spec.spec.js +61 -0
  80. package/{src/utils/resolve-namespace.spec.ts → test/utils/resolve-namespace.spec.js} +1 -1
  81. package/lib/types/permitted-structres.d.ts +0 -58
  82. package/lib/types/permitted-structres.js +0 -8
  83. package/schemas/aria.schema.json +0 -258
  84. package/schemas/attributes.schema.json +0 -204
  85. package/schemas/content-models.schema.json +0 -199
  86. package/schemas/element.schema.json +0 -11
  87. package/schemas/global-attributes.schema.json +0 -761
  88. package/src/dom-traverse/accname-computation.ts +0 -5
  89. package/src/dom-traverse/get-attr-specs.ts +0 -8
  90. package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
  91. package/src/dom-traverse/get-computed-aria-props.ts +0 -130
  92. package/src/dom-traverse/get-computed-role.spec.ts +0 -134
  93. package/src/dom-traverse/get-computed-role.ts +0 -181
  94. package/src/dom-traverse/get-content-model.ts +0 -32
  95. package/src/dom-traverse/get-explicit-role.ts +0 -112
  96. package/src/dom-traverse/get-implicit-role.ts +0 -36
  97. package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
  98. package/src/dom-traverse/get-permitted-roles.ts +0 -7
  99. package/src/dom-traverse/get-spec.ts +0 -7
  100. package/src/dom-traverse/has-required-owned-elements.ts +0 -85
  101. package/src/dom-traverse/is-exposed.ts +0 -196
  102. package/src/dom-traverse/may-be-focusable.ts +0 -21
  103. package/src/index.ts +0 -23
  104. package/src/specs/aria-specs.ts +0 -6
  105. package/src/specs/content-model-category-to-tag-names.ts +0 -15
  106. package/src/specs/get-aria.ts +0 -85
  107. package/src/specs/get-attr-specs.ts +0 -116
  108. package/src/specs/get-implicit-role.ts +0 -17
  109. package/src/specs/get-permitted-roles.ts +0 -87
  110. package/src/specs/get-role-spec.ts +0 -72
  111. package/src/specs/get-selectors-by-content-model-category.ts +0 -10
  112. package/src/specs/get-spec-by-tag-name.ts +0 -20
  113. package/src/specs/is-palpable-elements.ts +0 -55
  114. package/src/specs/is-presentational.ts +0 -6
  115. package/src/specs/is-void-element.ts +0 -22
  116. package/src/specs/resolve-version.ts +0 -20
  117. package/src/specs/schema-to-spec.spec.ts +0 -39
  118. package/src/specs/schema-to-spec.ts +0 -103
  119. package/src/types/aria.ts +0 -153
  120. package/src/types/attributes.ts +0 -1473
  121. package/src/types/index.ts +0 -255
  122. package/src/types/permitted-structres.ts +0 -100
  123. package/src/types/permitted-structures.ts +0 -96
  124. package/src/utils/get-ns.ts +0 -18
  125. package/src/utils/merge-array.ts +0 -35
  126. package/src/utils/resolve-namespace.ts +0 -40
  127. package/tsconfig.test.json +0 -3
  128. package/tsconfig.tsbuildinfo +0 -1
@@ -1,194 +1,223 @@
1
1
  import type { ARIA } from './aria';
2
2
  import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
3
3
  import type { ContentModel, Category } from './permitted-structures';
4
+ import type { ariaVersions } from '../constant/aria-version';
4
5
  import type { NamespaceURI } from '@markuplint/ml-ast';
6
+ import type { ReadonlyDeep } from 'type-fest';
5
7
  /**
6
8
  * markuplint Markup-language spec
7
9
  */
8
10
  export interface MLMLSpec {
9
- cites: Cites;
10
- def: SpecDefs;
11
- specs: ElementSpec[];
11
+ readonly cites: Cites;
12
+ readonly def: SpecDefs;
13
+ readonly specs: readonly ElementSpec[];
12
14
  }
13
15
  export type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
14
- name: ElementSpec['name'];
15
- attributes?: Record<string, Partial<Attribute>>;
16
+ readonly name: ElementSpec['name'];
17
+ readonly attributes?: Readonly<Record<string, Partial<Attribute>>>;
16
18
  };
17
19
  export type ExtendedSpec = {
18
- cites?: Cites;
19
- def?: Partial<SpecDefs>;
20
- specs?: ExtendedElementSpec[];
20
+ readonly cites?: Cites;
21
+ readonly def?: Partial<SpecDefs>;
22
+ readonly specs?: readonly ExtendedElementSpec[];
21
23
  };
22
24
  /**
23
25
  * Reference URLs
24
26
  */
25
- export type Cites = string[];
27
+ export type Cites = readonly string[];
26
28
  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;
35
- };
36
- '#contentModels': {
37
- [model in Category]?: string[];
38
- };
29
+ readonly '#globalAttrs': {
30
+ readonly [category: string]: Readonly<Record<string, Partial<Attribute>>>;
31
+ };
32
+ readonly '#aria': {
33
+ readonly '1.3': ARIASpec;
34
+ readonly '1.2': ARIASpec;
35
+ readonly '1.1': ARIASpec;
36
+ };
37
+ readonly '#contentModels': {
38
+ readonly [model in Category]?: readonly string[];
39
+ };
39
40
  };
40
41
  type ARIASpec = {
41
- roles: ARIARoleInSchema[];
42
- graphicsRoles: ARIARoleInSchema[];
43
- props: ARIAProperty[];
42
+ readonly roles: readonly ARIARoleInSchema[];
43
+ readonly graphicsRoles: readonly ARIARoleInSchema[];
44
+ readonly props: readonly ARIAProperty[];
44
45
  };
45
46
  /**
46
47
  * Element spec
47
48
  */
48
49
  export type ElementSpec = {
49
- /**
50
- * Tag name
51
- */
52
- name: string;
53
- /**
54
- * Namespaces in XML
55
- * @see https://www.w3.org/TR/xml-names/
56
- */
57
- namespace?: NamespaceURI;
58
- /**
59
- * Reference URL
60
- */
61
- cite: string;
62
- /**
63
- * Description
64
- */
65
- description?: string;
66
- /**
67
- * Experimental technology
68
- */
69
- experimental?: true;
70
- /**
71
- * Obsolete or alternative elements
72
- */
73
- obsolete?: true | {
74
- alt: string;
75
- };
76
- /**
77
- * Deprecated
78
- */
79
- deprecated?: true;
80
- /**
81
- * Non-standard
82
- */
83
- nonStandard?: true;
84
- /**
85
- * Element categories
86
- */
87
- categories: Category[];
88
- /**
89
- * Permitted contents and permitted parents
90
- */
91
- contentModel: ContentModel;
92
- /**
93
- * Tag omission
94
- */
95
- omission: ElementSpecOmission;
96
- /**
97
- * Global Attributes
98
- */
99
- globalAttrs: GlobalAttributes;
100
- /**
101
- * Attributes
102
- */
103
- attributes: Record<string, Attribute>;
104
- /**
105
- * WAI-ARIA role and properties
106
- */
107
- aria: ARIA;
108
- /**
109
- * If true, it is possible to add any properties as attributes,
110
- * for example, when using a template engine or a view language.
111
- *
112
- * @see https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots
113
- *
114
- * **It assumes to specify it on the parser plugin.**
115
- */
116
- possibleToAddProperties?: true;
50
+ /**
51
+ * Tag name
52
+ */
53
+ readonly name: string;
54
+ /**
55
+ * Namespaces in XML
56
+ * @see https://www.w3.org/TR/xml-names/
57
+ */
58
+ readonly namespace?: NamespaceURI;
59
+ /**
60
+ * Reference URL
61
+ */
62
+ readonly cite: string;
63
+ /**
64
+ * Description
65
+ */
66
+ readonly description?: string;
67
+ /**
68
+ * Experimental technology
69
+ */
70
+ readonly experimental?: true;
71
+ /**
72
+ * Obsolete or alternative elements
73
+ */
74
+ readonly obsolete?:
75
+ | true
76
+ | {
77
+ readonly alt: string;
78
+ };
79
+ /**
80
+ * Deprecated
81
+ */
82
+ readonly deprecated?: true;
83
+ /**
84
+ * Non-standard
85
+ */
86
+ readonly nonStandard?: true;
87
+ /**
88
+ * Element categories
89
+ */
90
+ readonly categories: readonly Category[];
91
+ /**
92
+ * Permitted contents and permitted parents
93
+ */
94
+ readonly contentModel: ReadonlyDeep<ContentModel>;
95
+ /**
96
+ * Tag omission
97
+ */
98
+ readonly omission: ElementSpecOmission;
99
+ /**
100
+ * Global Attributes
101
+ */
102
+ readonly globalAttrs: ReadonlyDeep<GlobalAttributes>;
103
+ /**
104
+ * Attributes
105
+ */
106
+ readonly attributes: Readonly<Record<string, Attribute>>;
107
+ /**
108
+ * WAI-ARIA role and properties
109
+ */
110
+ readonly aria: ReadonlyDeep<ARIA>;
111
+ /**
112
+ * If true, it is possible to add any properties as attributes,
113
+ * for example, when using a template engine or a view language.
114
+ *
115
+ * @see https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots
116
+ *
117
+ * **It assumes to specify it on the parser plugin.**
118
+ */
119
+ readonly possibleToAddProperties?: true;
117
120
  };
118
121
  type ElementSpecOmission = false | ElementSpecOmissionTags;
119
122
  type ElementSpecOmissionTags = {
120
- startTag: boolean | ElementCondition;
121
- endTag: boolean | ElementCondition;
123
+ readonly startTag: boolean | ElementCondition;
124
+ readonly endTag: boolean | ElementCondition;
122
125
  };
123
126
  type ElementCondition = {
124
- __WIP__: 'WORK_IN_PROGRESS';
127
+ readonly __WIP__: 'WORK_IN_PROGRESS';
125
128
  };
126
129
  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;
130
+ readonly name: string;
131
+ readonly type: ReadonlyDeep<AttributeType> | readonly ReadonlyDeep<AttributeType>[];
132
+ readonly description?: string;
133
+ readonly caseSensitive?: true;
134
+ readonly experimental?: boolean;
135
+ readonly obsolete?: true;
136
+ readonly deprecated?: boolean;
137
+ readonly nonStandard?: true;
135
138
  } & ExtendableAttributeSpec;
136
- type ExtendableAttributeSpec = Omit<AttributeJSON, 'type'>;
139
+ type ExtendableAttributeSpec = Omit<ReadonlyDeep<AttributeJSON>, 'type'>;
137
140
  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[];
141
+ readonly name: string;
142
+ readonly isAbstract: boolean;
143
+ readonly requiredContextRole: readonly string[];
144
+ readonly requiredOwnedElements: readonly string[];
145
+ readonly accessibleNameRequired: boolean;
146
+ readonly accessibleNameFromAuthor: boolean;
147
+ readonly accessibleNameFromContent: boolean;
148
+ readonly accessibleNameProhibited: boolean;
149
+ readonly childrenPresentational: boolean;
150
+ readonly ownedProperties: readonly ARIARoleOwnedProperties[];
151
+ readonly prohibitedProperties: readonly string[];
149
152
  };
150
- export type ARIARoleInSchema = Partial<ARIARole & {
151
- description: string;
152
- generalization: string[];
153
- }> & {
154
- name: string;
153
+ export type ARIARoleInSchema = Partial<
154
+ ARIARole & {
155
+ readonly description: string;
156
+ readonly generalization: readonly string[];
157
+ }
158
+ > & {
159
+ readonly name: string;
155
160
  };
156
161
  export type ARIARoleOwnedProperties = {
157
- name: string;
158
- inherited?: true;
159
- required?: true;
160
- deprecated?: true;
162
+ readonly name: string;
163
+ readonly inherited?: true;
164
+ readonly required?: true;
165
+ readonly deprecated?: true;
161
166
  };
162
167
  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;
171
- }[];
172
- enum: string[];
173
- defaultValue?: string;
174
- equivalentHtmlAttrs?: EquivalentHtmlAttr[];
175
- valueDescriptions?: Record<string, string>;
168
+ readonly name: string;
169
+ readonly type: 'property' | 'state';
170
+ readonly deprecated?: true;
171
+ readonly isGlobal?: true;
172
+ readonly value: ARIAAttributeValue;
173
+ readonly conditionalValue?: readonly {
174
+ readonly role: readonly string[];
175
+ readonly value: ARIAAttributeValue;
176
+ }[];
177
+ readonly enum: readonly string[];
178
+ readonly defaultValue?: string;
179
+ readonly equivalentHtmlAttrs?: readonly EquivalentHtmlAttr[];
180
+ readonly valueDescriptions?: Readonly<Record<string, string>>;
176
181
  };
177
- export type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI';
178
- export type ARIAVersion = '1.1' | '1.2';
182
+ export type ARIAAttributeValue =
183
+ | 'true/false'
184
+ | 'tristate'
185
+ | 'true/false/undefined'
186
+ | 'ID reference'
187
+ | 'ID reference list'
188
+ | 'integer'
189
+ | 'number'
190
+ | 'string'
191
+ | 'token'
192
+ | 'token list'
193
+ | 'URI';
194
+ export type ARIAVersion = (typeof ariaVersions)[number];
179
195
  export type EquivalentHtmlAttr = {
180
- htmlAttrName: string;
181
- isNotStrictEquivalent?: true;
182
- value: string | null;
196
+ readonly htmlAttrName: string;
197
+ readonly isNotStrictEquivalent?: true;
198
+ readonly value: string | null;
183
199
  };
184
200
  export type Matches = (selector: string) => boolean;
185
201
  export type ComputedRole = {
186
- el: Element;
187
- role: (ARIARole & {
188
- superClassRoles: ARIARoleInSchema[];
189
- isImplicit?: boolean;
190
- }) | null;
191
- errorType?: RoleComputationError;
202
+ readonly el: Element;
203
+ readonly role:
204
+ | (ARIARole & {
205
+ readonly superClassRoles: readonly ARIARoleInSchema[];
206
+ readonly isImplicit?: boolean;
207
+ })
208
+ | null;
209
+ readonly errorType?: RoleComputationError;
192
210
  };
193
- 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';
211
+ export type RoleComputationError =
212
+ | 'ABSTRACT'
213
+ | 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL'
214
+ | 'IMPLICIT_ROLE_NAMESPACE_ERROR'
215
+ | 'INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
216
+ | 'INVALID_LANDMARK'
217
+ | 'INVALID_REQUIRED_CONTEXT_ROLE'
218
+ | 'NO_EXPLICIT'
219
+ | 'NO_OWNER'
220
+ | 'NO_PERMITTED'
221
+ | 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
222
+ | 'ROLE_NO_EXISTS';
194
223
  export {};
@@ -3,52 +3,95 @@
3
3
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
4
  * and run json-schema-to-typescript to regenerate this file.
5
5
  */
6
- export type PermittedContentPattern = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentTransparent;
6
+ export type PermittedContentPattern =
7
+ | PermittedContentRequire
8
+ | PermittedContentOptional
9
+ | PermittedContentOneOrMore
10
+ | PermittedContentZeroOrMore
11
+ | PermittedContentChoice
12
+ | PermittedContentTransparent;
7
13
  export type Model = ContentType | ContentType[];
8
14
  export type ContentType = string | Category;
9
- export type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild';
15
+ export type Category =
16
+ | '#text'
17
+ | '#phrasing'
18
+ | '#flow'
19
+ | '#interactive'
20
+ | '#heading'
21
+ | '#sectioning'
22
+ | '#metadata'
23
+ | '#embedded'
24
+ | '#palpable'
25
+ | '#script-supporting'
26
+ | '#SVGAnimation'
27
+ | '#SVGBasicShapes'
28
+ | '#SVGContainer'
29
+ | '#SVGDescriptive'
30
+ | '#SVGFilterPrimitive'
31
+ | '#SVGFont'
32
+ | '#SVGGradient'
33
+ | '#SVGGraphics'
34
+ | '#SVGGraphicsReferencing'
35
+ | '#SVGLightSource'
36
+ | '#SVGNeverRendered'
37
+ | '#SVGNone'
38
+ | '#SVGPaintServer'
39
+ | '#SVGRenderable'
40
+ | '#SVGShape'
41
+ | '#SVGStructural'
42
+ | '#SVGStructurallyExternal'
43
+ | '#SVGTextContent'
44
+ | '#SVGTextContentChild';
10
45
  export interface ContentModelsSchema {
11
- __contentModel?: ContentModel;
46
+ __contentModel?: ContentModel;
12
47
  }
13
48
  export interface ContentModel {
14
- contents: PermittedContentPattern[] | boolean;
15
- descendantOf?: string;
16
- conditional?: {
17
- condition: string;
18
- contents: PermittedContentPattern[] | boolean;
19
- }[];
49
+ contents: PermittedContentPattern[] | boolean;
50
+ descendantOf?: string;
51
+ conditional?: {
52
+ condition: string;
53
+ contents: PermittedContentPattern[] | boolean;
54
+ }[];
20
55
  }
21
56
  export interface PermittedContentRequire {
22
- require: Model;
23
- max?: number;
24
- min?: number;
25
- _TODO_?: string;
57
+ require: Model | PermittedContentPattern[];
58
+ max?: number;
59
+ min?: number;
60
+ _TODO_?: string;
26
61
  }
27
62
  export interface PermittedContentOptional {
28
- optional: Model;
29
- max?: number;
30
- _TODO_?: string;
63
+ optional: Model | PermittedContentPattern[];
64
+ max?: number;
65
+ _TODO_?: string;
31
66
  }
32
67
  export interface PermittedContentOneOrMore {
33
- oneOrMore: Model | PermittedContentPattern[];
34
- max?: number;
35
- _TODO_?: string;
68
+ oneOrMore: Model | PermittedContentPattern[];
69
+ max?: number;
70
+ _TODO_?: string;
36
71
  }
37
72
  export interface PermittedContentZeroOrMore {
38
- zeroOrMore: Model | PermittedContentPattern[];
39
- max?: number;
40
- _TODO_?: string;
73
+ zeroOrMore: Model | PermittedContentPattern[];
74
+ max?: number;
75
+ _TODO_?: string;
41
76
  }
42
77
  export interface PermittedContentChoice {
43
- choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
44
- PermittedContentPattern[],
45
- PermittedContentPattern[],
46
- PermittedContentPattern[],
47
- PermittedContentPattern[],
48
- PermittedContentPattern[]
49
- ];
50
- _TODO_?: string;
78
+ /**
79
+ * @minItems 2
80
+ * @maxItems 5
81
+ */
82
+ choice:
83
+ | [PermittedContentPattern[], PermittedContentPattern[]]
84
+ | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
85
+ | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
86
+ | [
87
+ PermittedContentPattern[],
88
+ PermittedContentPattern[],
89
+ PermittedContentPattern[],
90
+ PermittedContentPattern[],
91
+ PermittedContentPattern[],
92
+ ];
93
+ _TODO_?: string;
51
94
  }
52
95
  export interface PermittedContentTransparent {
53
- transparent: string;
96
+ transparent: string;
54
97
  }
@@ -1,5 +1,10 @@
1
- type NamedDefinition = string | {
2
- name: string;
3
- };
4
- export declare function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[];
1
+ type NamedDefinition =
2
+ | string
3
+ | {
4
+ readonly name: string;
5
+ };
6
+ export declare function mergeArray<T extends NamedDefinition>(
7
+ a: readonly T[],
8
+ b: readonly T[] | null | undefined,
9
+ ): readonly T[];
5
10
  export {};
@@ -1,9 +1,9 @@
1
1
  import type { NamespaceURI, Namespace } from '@markuplint/ml-ast';
2
2
  type NamespacedElementName = {
3
- localNameWithNS: string;
4
- localName: string;
5
- namespace: Namespace;
6
- namespaceURI: NamespaceURI;
3
+ localNameWithNS: string;
4
+ localName: string;
5
+ namespace: Namespace;
6
+ namespaceURI: NamespaceURI;
7
7
  };
8
8
  export declare function resolveNamespace(name: string, namespaceURI?: string | null): NamespacedElementName;
9
9
  export {};
@@ -10,14 +10,15 @@ 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 namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS || (0, get_ns_1.getNS)(namespaceURI || null))) ||
20
+ const localName = (_a = _localName !== null && _localName !== void 0 ? _localName : _explicitNS) !== null && _a !== void 0 ? _a : '';
21
+ const namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS || (0, get_ns_1.getNS)(namespaceURI !== null && namespaceURI !== void 0 ? namespaceURI : null))) ||
21
22
  'html';
22
23
  const result = {
23
24
  localNameWithNS: `${namespace === 'html' ? '' : `${namespace}:`}${localName}`,
@@ -0,0 +1,2 @@
1
+ import type { ARIAVersion } from '../types';
2
+ export declare function validateAriaVersion(version: string): version is ARIAVersion;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAriaVersion = void 0;
4
+ const aria_version_1 = require("../constant/aria-version");
5
+ function validateAriaVersion(version) {
6
+ return aria_version_1.ariaVersions.includes(version);
7
+ }
8
+ exports.validateAriaVersion = validateAriaVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-spec",
3
- "version": "3.0.0-canary.5+382d1365",
3
+ "version": "3.0.0-dev.176+f6ad62e9",
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>",
@@ -11,25 +11,30 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
+ "typedoc": {
15
+ "entryPoint": "./src/index.ts"
16
+ },
14
17
  "scripts": {
15
18
  "build": "tsc",
16
19
  "dev": "tsc --build --watch",
17
20
  "clean": "tsc --build --clean",
18
21
  "schema:gen": "ts-node ./gen/gen.ts; prettier --write './schemas/*.json';",
19
- "schema:content-models": "json2ts ./schemas/content-models.schema.json > ./src/types/permitted-structres.ts; prettier --write ./src/types/permitted-structres.ts; eslint --fix --config ../../../.eslintrc ./src/types/permitted-structres.ts",
22
+ "schema:content-models": "json2ts ./schemas/content-models.schema.json > ./src/types/permitted-structures.ts; prettier --write ./src/types/permitted-structures.ts; eslint --fix --config ../../../.eslintrc ./src/types/permitted-structures.ts",
20
23
  "schema:attributes": "json2ts ./schemas/attributes.schema.json --cwd ./schemas > ./src/types/attributes.ts; prettier --write ./src/types/attributes.ts; eslint --fix --config ../../../.eslintrc ./src/types/attributes.ts",
21
24
  "schema:aria": "json2ts ./schemas/aria.schema.json --cwd ./schemas > ./src/types/aria.ts; prettier --write ./src/types/aria.ts; eslint --fix --config ../../../.eslintrc ./src/types/aria.ts",
22
25
  "schema": "run-s schema:*"
23
26
  },
24
27
  "dependencies": {
25
- "@markuplint/ml-ast": "3.0.0-canary.69+382d1365",
28
+ "@markuplint/ml-ast": "3.0.0-dev.176+f6ad62e9",
29
+ "@markuplint/types": "3.0.0-dev.176+f6ad62e9",
26
30
  "dom-accessibility-api": "^0.5.14",
27
- "tslib": "^2.4.0"
31
+ "is-plain-object": "^5.0.0",
32
+ "tslib": "^2.4.1",
33
+ "type-fest": "^3.8.0"
28
34
  },
29
35
  "devDependencies": {
30
- "@markuplint/test-tools": "3.0.0-rc.0",
31
- "@markuplint/types": "3.0.0-canary.5+382d1365",
32
- "json-schema-to-typescript": "^11.0.2"
36
+ "@markuplint/test-tools": "3.2.0",
37
+ "json-schema-to-typescript": "11.0.2"
33
38
  },
34
- "gitHead": "382d13653071bd02210d5430403d1a87c840398c"
39
+ "gitHead": "f6ad62e992e1569be4067f1e90d2d6017a658f57"
35
40
  }
@@ -1,6 +1,6 @@
1
- import { createJSDOMElement as c } from '@markuplint/test-tools';
1
+ const { createJSDOMElement: c } = require('@markuplint/test-tools');
2
2
 
3
- import { getAccname } from './accname-computation';
3
+ const { getAccname } = require('../../lib/dom-traverse/accname-computation');
4
4
 
5
5
  test('Get accessible name', () => {
6
6
  expect(getAccname(c('<button>label</button>'))).toBe('label');
@@ -35,7 +35,7 @@ test('accname-1.1 Example 1', () => {
35
35
  });
36
36
 
37
37
  /**
38
- * https://www.w3.org/TR/accname-1.1/#ex-2-example-2-h1-files-h1-ul-li-a-id-file_row1-href-files-documentation-pdf-documentation-pdf-a-span-role-button-tabindex-0-id-del_row1-aria-label-delete-aria-labelledby-del_row1-file_row1-span-li-li-a-id-file_row2-href-files-holidayletter-pdf-holidayletter-pdf-a-span-role-button-tabindex-0-id-del_row2-aria-label-delete-aria-labelledby-del_row2-file_row2-span-li-ul
38
+ * @see https://www.w3.org/TR/accname-1.1/#ex-2-example-2-h1-files-h1-ul-li-a-id-file_row1-href-files-documentation-pdf-documentation-pdf-a-span-role-button-tabindex-0-id-del_row1-aria-label-delete-aria-labelledby-del_row1-file_row1-span-li-li-a-id-file_row2-href-files-holidayletter-pdf-holidayletter-pdf-a-span-role-button-tabindex-0-id-del_row2-aria-label-delete-aria-labelledby-del_row2-file_row2-span-li-ul
39
39
  */
40
40
  test('accname-1.1 Example 2', () => {
41
41
  const complex = c(`<ul>
@@ -54,7 +54,7 @@ test('accname-1.1 Example 2', () => {
54
54
  });
55
55
 
56
56
  /**
57
- * https://www.w3.org/TR/accname-1.1/#ex-3-example-3-div-role-checkbox-aria-checked-false-flash-the-screen-span-role-textbox-aria-multiline-false-5-span-times-div
57
+ * @see https://www.w3.org/TR/accname-1.1/#ex-3-example-3-div-role-checkbox-aria-checked-false-flash-the-screen-span-role-textbox-aria-multiline-false-5-span-times-div
58
58
  */
59
59
  test('accname-1.1 Example 3', () => {
60
60
  const complex = c(