@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
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
# 型定義リファレンス
|
|
2
|
+
|
|
3
|
+
このドキュメントでは、`@markuplint/ml-spec` で使用される型定義と JSON スキーマについて説明します。
|
|
4
|
+
|
|
5
|
+
## 概要
|
|
6
|
+
|
|
7
|
+
`@markuplint/ml-spec` は2層の型システムを採用しています。
|
|
8
|
+
|
|
9
|
+
1. **手書きの型** (`src/types/index.ts`) -- 要素スペック、ARIA ロール、属性、ロール計算結果のために markuplint 全体で使用されるランタイムインターフェースを定義します。
|
|
10
|
+
2. **生成された型** (JSON スキーマから生成) -- `.schema.json` ファイルから `json-schema-to-typescript` を使用して自動生成される、スキーマ検証済みの構造体を定義します。これらのファイルには「DO NOT MODIFY」ヘッダーが付きます。
|
|
11
|
+
|
|
12
|
+
手書きの型は必要に応じて生成された型をインポート・拡張しており(例: `Attribute` は `AttributeJSON` を拡張)、スキーマ検証データ層とランタイムAPI層の間に明確な分離を実現しています。
|
|
13
|
+
|
|
14
|
+
## コア仕様型
|
|
15
|
+
|
|
16
|
+
これらの型は `src/types/index.ts` で定義されており、markuplint のスペックシステムの基盤を形成します。
|
|
17
|
+
|
|
18
|
+
### `MLMLSpec`
|
|
19
|
+
|
|
20
|
+
完全なマークアップ言語仕様を表すルート仕様型です。
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
interface MLMLSpec {
|
|
24
|
+
readonly cites: Cites; // 参照URL(readonly string[])
|
|
25
|
+
readonly def: SpecDefs; // 内部定義(グローバル属性、ARIA、コンテンツモデル)
|
|
26
|
+
readonly specs: readonly ElementSpec[]; // 要素仕様の配列
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### `ExtendedSpec`
|
|
31
|
+
|
|
32
|
+
フレームワーク固有のパッケージがベース仕様を拡張またはカスタマイズするために使用される部分仕様型です。`@markuplint/vue-spec`、`@markuplint/react-spec` などのパッケージで使用されます。
|
|
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` は `ElementSpec` の部分バージョンで、`name` のみが必須です。他のプロパティはすべてオプションのオーバーライドです。属性は `Partial<Attribute>` を使用して変更されたフィールドのみを指定できます:
|
|
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
|
+
マークアップ言語仕様内の内部定義データで、グローバル属性、ARIA ロール/プロパティ定義、コンテンツモデルカテゴリマッピングを含みます。
|
|
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`** -- カテゴリをキーとした属性定義。各カテゴリ(例: `#HTMLGlobalAttrs`、`#ARIAAttrs`)は部分的な属性定義のレコードにマッピングされます。
|
|
72
|
+
- **`#aria`** -- 各仕様バージョン(1.1、1.2、1.3)の ARIA ロール/プロパティ定義。各バージョンには `roles`、`graphicsRoles`、`props` 配列が含まれます。
|
|
73
|
+
- **`#contentModels`** -- コンテンツモデルカテゴリからセレクタ配列へのマッピング。`Category` 値(`#flow`、`#phrasing` など)を、そのカテゴリに属する要素にマッチする CSS セレクタの配列にマッピングします。
|
|
74
|
+
|
|
75
|
+
### `ElementSpec`
|
|
76
|
+
|
|
77
|
+
単一の HTML または SVG 要素のすべての側面を記述する完全な要素仕様です。
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
type ElementSpec = {
|
|
81
|
+
readonly name: string; // タグ名
|
|
82
|
+
readonly namespace?: NamespaceURI; // XML 名前空間 URI
|
|
83
|
+
readonly cite: string; // 参照URL
|
|
84
|
+
readonly description?: string; // 人間が読める説明
|
|
85
|
+
|
|
86
|
+
// ステータスフラグ
|
|
87
|
+
readonly experimental?: true; // 実験的技術
|
|
88
|
+
readonly obsolete?: true | { readonly alt: string }; // 廃止(代替要素の指定可)
|
|
89
|
+
readonly deprecated?: true; // 非推奨
|
|
90
|
+
readonly nonStandard?: true; // 非標準
|
|
91
|
+
|
|
92
|
+
// 構造プロパティ
|
|
93
|
+
readonly categories: readonly Category[]; // 要素カテゴリ
|
|
94
|
+
readonly contentModel: ReadonlyDeep<ContentModel>; // 許可されるコンテンツパターン
|
|
95
|
+
readonly omission: ElementSpecOmission; // タグ省略ルール
|
|
96
|
+
|
|
97
|
+
// 属性と ARIA
|
|
98
|
+
readonly globalAttrs: ReadonlyDeep<GlobalAttributes>; // グローバル属性の選択
|
|
99
|
+
readonly attributes: Readonly<Record<string, Attribute>>; // 要素固有の属性
|
|
100
|
+
readonly aria: ReadonlyDeep<ARIA>; // WAI-ARIA ロールとプロパティのマッピング
|
|
101
|
+
|
|
102
|
+
// テンプレートエンジンサポート
|
|
103
|
+
readonly possibleToAddProperties?: true; // 任意のプロパティを許可(テンプレートエンジン用)
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`ElementSpecOmission` は `false`(省略不可)またはオブジェクト(`startTag` と `endTag` フィールドでタグ省略の可否を示す)のいずれかです。
|
|
108
|
+
|
|
109
|
+
### `Attribute`
|
|
110
|
+
|
|
111
|
+
単一の HTML/SVG 属性を型、説明、ステータスフラグとともに記述します。
|
|
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
|
+
`& ExtendableAttributeSpec` の交差型により、生成された `AttributeJSON` 型のフィールド(`type` を除く。`ReadonlyDeep` ラッパーでオーバーライドされるため)が追加されます: `defaultValue`、`required`、`requiredEither`、`noUse`、`condition`、`ineffective`、`animatable`。
|
|
127
|
+
|
|
128
|
+
## ARIA 型
|
|
129
|
+
|
|
130
|
+
### `ARIARole`
|
|
131
|
+
|
|
132
|
+
プロパティ、要件、名前付け制約がすべて解決された ARIA ロールです。
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
type ARIARole = {
|
|
136
|
+
readonly name: string; // ロール名(例: 'button', 'navigation')
|
|
137
|
+
readonly isAbstract: boolean; // 抽象ロールかどうか
|
|
138
|
+
readonly deprecated: boolean; // 非推奨のロールかどうか
|
|
139
|
+
|
|
140
|
+
// コンテキスト要件
|
|
141
|
+
readonly requiredContextRole: readonly string[]; // 必要な親ロール
|
|
142
|
+
readonly requiredOwnedElements: readonly string[]; // 必要な子ロール
|
|
143
|
+
|
|
144
|
+
// アクセシブル名の制約
|
|
145
|
+
readonly accessibleNameRequired: boolean; // アクセシブル名が必須
|
|
146
|
+
readonly accessibleNameFromAuthor: boolean; // 著者からの名前(aria-label 等)が可能
|
|
147
|
+
readonly accessibleNameFromContent: boolean; // 要素コンテンツからの名前が可能
|
|
148
|
+
readonly accessibleNameProhibited: boolean; // 名前が禁止
|
|
149
|
+
|
|
150
|
+
// プロパティ
|
|
151
|
+
readonly childrenPresentational: boolean; // 子要素がプレゼンテーショナル
|
|
152
|
+
readonly ownedProperties: readonly ARIARoleOwnedProperties[];
|
|
153
|
+
readonly prohibitedProperties: readonly string[];
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### `ARIARoleInSchema`
|
|
158
|
+
|
|
159
|
+
生のスキーマデータで定義された ARIA ロールです。スキーマは部分的なロール情報のみを提供する場合があるため、`name` 以外のすべてのプロパティはオプションです。オプションの `description` と `generalization`(スーパークラスロール)フィールドも含みます。
|
|
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
|
+
ARIA ロールが所有するプロパティを、継承・必須・非推奨の情報とともに記述します。
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
type ARIARoleOwnedProperties = {
|
|
178
|
+
readonly name: string; // プロパティ名(例: 'aria-expanded')
|
|
179
|
+
readonly inherited?: true; // スーパークラスロールから継承
|
|
180
|
+
readonly required?: true; // このロールで必須
|
|
181
|
+
readonly deprecated?: true; // このロールで非推奨
|
|
182
|
+
};
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `ARIAProperty`
|
|
186
|
+
|
|
187
|
+
ARIA プロパティまたはステートを、その値の型、列挙値、等価な HTML 属性とともに記述します。
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
type ARIAProperty = {
|
|
191
|
+
readonly name: string; // プロパティ名(例: 'aria-hidden')
|
|
192
|
+
readonly type: 'property' | 'state'; // プロパティかステートか
|
|
193
|
+
readonly deprecated?: true;
|
|
194
|
+
readonly isGlobal?: true; // グローバル ARIA 属性かどうか
|
|
195
|
+
readonly value: ARIAAttributeValue; // 値の型
|
|
196
|
+
readonly conditionalValue?: readonly {
|
|
197
|
+
// ロール固有の値オーバーライド
|
|
198
|
+
readonly role: readonly string[];
|
|
199
|
+
readonly value: ARIAAttributeValue;
|
|
200
|
+
}[];
|
|
201
|
+
readonly enum: readonly string[]; // 許可されるトークン値
|
|
202
|
+
readonly defaultValue?: string;
|
|
203
|
+
readonly equivalentHtmlAttrs?: readonly EquivalentHtmlAttr[];
|
|
204
|
+
readonly valueDescriptions?: Readonly<Record<string, string>>;
|
|
205
|
+
};
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `ARIAAttributeValue`
|
|
209
|
+
|
|
210
|
+
WAI-ARIA 仕様で定義された、ARIA 属性の値の型です。
|
|
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
|
+
サポートされている ARIA 仕様バージョン文字列の共用体型で、`ariaVersions` タプル(`['1.1', '1.2', '1.3'] as const`)から導出されます。
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
type ARIAVersion = '1.1' | '1.2' | '1.3';
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
推奨デフォルトバージョンは `'1.2'` です(`src/utils/aria-version.ts` の `ARIA_RECOMMENDED_VERSION` として定義)。
|
|
236
|
+
|
|
237
|
+
### `ComputedRole`
|
|
238
|
+
|
|
239
|
+
要素の ARIA ロール計算の結果です。
|
|
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`** -- DOM 要素の参照。
|
|
255
|
+
- **`role`** -- 解決されたロール(スーパークラスチェーンと暗黙フラグ付き)、またはロールが適用されない場合は `null`。
|
|
256
|
+
- **`errorType`** -- ロール計算中の問題を示すオプションのエラーコード。
|
|
257
|
+
|
|
258
|
+
### `RoleComputationError`
|
|
259
|
+
|
|
260
|
+
ARIA ロール計算中に発生しうるエラーコードで、抽象ロール、無効なコンテキスト、プレゼンテーショナルの競合などの具体的な問題を示します。
|
|
261
|
+
|
|
262
|
+
| エラーコード | 説明 |
|
|
263
|
+
| --------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
264
|
+
| `ABSTRACT` | 抽象ロールが割り当てられた(抽象ロールは直接使用してはならない) |
|
|
265
|
+
| `GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL` | グローバル ARIA プロパティを持つ要素はプレゼンテーショナルであってはならない |
|
|
266
|
+
| `IMPLICIT_ROLE_NAMESPACE_ERROR` | 暗黙のロールが要素の名前空間と一致しない |
|
|
267
|
+
| `INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL` | インタラクティブ要素はプレゼンテーショナルであってはならない |
|
|
268
|
+
| `INVALID_LANDMARK` | ランドマークロールの使用が無効 |
|
|
269
|
+
| `INVALID_REQUIRED_CONTEXT_ROLE` | 必須コンテキストロールが満たされていない |
|
|
270
|
+
| `NO_EXPLICIT` | 明示的なロールが割り当てられていない |
|
|
271
|
+
| `NO_OWNER` | 必須コンテキストの所有元要素が見つからない |
|
|
272
|
+
| `NO_PERMITTED` | この要素でそのロールは許可されていない |
|
|
273
|
+
| `REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL` | 必須の所有子要素はプレゼンテーショナルであってはならない |
|
|
274
|
+
| `ROLE_NO_EXISTS` | 指定されたロールが存在しない |
|
|
275
|
+
|
|
276
|
+
## ユーティリティ型
|
|
277
|
+
|
|
278
|
+
### `Matches`
|
|
279
|
+
|
|
280
|
+
要素が指定された CSS セレクタ文字列にマッチするかどうかをテストする関数型です。通常は `Element.prototype.matches` にバインドされます。
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
type Matches = (selector: string) => boolean;
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### `Cites`
|
|
287
|
+
|
|
288
|
+
仕様全体で使用される参照 URL 配列型です。
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
type Cites = readonly string[];
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### `EquivalentHtmlAttr`
|
|
295
|
+
|
|
296
|
+
ARIA プロパティと意味的に等価な HTML 属性を記述し、HTML 属性から ARIA ステート/プロパティへの自動マッピングを可能にします。
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
type EquivalentHtmlAttr = {
|
|
300
|
+
readonly htmlAttrName: string;
|
|
301
|
+
readonly isNotStrictEquivalent?: true;
|
|
302
|
+
readonly value: string | null;
|
|
303
|
+
};
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 生成された型
|
|
307
|
+
|
|
308
|
+
これらの型は `json-schema-to-typescript` により JSON スキーマファイルから自動生成されます。「DO NOT MODIFY」ヘッダーが付いており、直接編集してはいけません。
|
|
309
|
+
|
|
310
|
+
### `aria.schema.json` から -- `src/types/aria.ts`
|
|
311
|
+
|
|
312
|
+
**`ARIA`** -- 条件とバージョンオーバーライドを含む要素レベルの ARIA 仕様です。
|
|
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
|
+
/* 条件ごとのオーバーライド */
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
'1.3'?: {
|
|
327
|
+
/* バージョン固有のオーバーライド */
|
|
328
|
+
};
|
|
329
|
+
'1.2'?: {
|
|
330
|
+
/* バージョン固有のオーバーライド */
|
|
331
|
+
};
|
|
332
|
+
'1.1'?: {
|
|
333
|
+
/* バージョン固有のオーバーライド */
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**`ImplicitRole`** -- 要素の暗黙的(デフォルト)ロールです。
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
type ImplicitRole = false | string; // false は「対応するロールなし」を意味する
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**`PermittedRoles`** -- 要素で許可されるロールです。
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
type PermittedRoles =
|
|
348
|
+
| boolean // true = 「任意のロール」、false = 「ロールなし」
|
|
349
|
+
| (string | { name: string; deprecated?: true })[] // 特定のロールリスト
|
|
350
|
+
| PermittedARIAAAMInfo; // AAM委任(core-aam または graphics-aam)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**`PermittedARIAProperties`** -- 要素の ARIA プロパティ制約です。
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
type PermittedARIAProperties =
|
|
357
|
+
| false // 「ロールや aria-* 属性なし」
|
|
358
|
+
| {
|
|
359
|
+
global?: true; // グローバル ARIA プロパティを許可
|
|
360
|
+
role?: true | string | [string, ...string[]]; // 許可されたロールに適用されるプロパティ
|
|
361
|
+
only?: [
|
|
362
|
+
/* 特定のプロパティ */
|
|
363
|
+
]; // 許可されるプロパティのホワイトリスト
|
|
364
|
+
without?: [
|
|
365
|
+
/* 重大度付きの禁止プロパティ */
|
|
366
|
+
]; // 重大度レベル付きのブラックリスト
|
|
367
|
+
};
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**`ImplicitProperties`** -- デフォルトの ARIA プロパティ値(`^aria-.+` にマッチするキー)。
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
interface ImplicitProperties {
|
|
374
|
+
[ariaProperty: string]: string; // 例: { 'aria-checked': 'false' }
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### `attributes.schema.json` から -- `src/types/attributes.ts`
|
|
379
|
+
|
|
380
|
+
**`AttributeType`** -- 認識されるすべての属性値型をカバーする大きな共用体型です。以下を含みます:
|
|
381
|
+
|
|
382
|
+
- **CSS プロパティ名**: `<'color'>`、`<'display'>`、`<'font-size'>` など(標準、ベンダープレフィックス付き、非推奨の CSS プロパティが数百個)
|
|
383
|
+
- **CSS 値型**: `<color>`、`<length>`、`<number>`、`<url>`、`<integer>` など
|
|
384
|
+
- **SVG 固有型**: `<svg-path>`、`<view-box>`、`<preserve-aspect-ratio>` など
|
|
385
|
+
- **markuplint カスタム型**: `DOMID`、`URL`、`BCP47`、`MIMEType`、`DateTime`、`AutoComplete`、`Int`、`Uint`、`Number`、`Boolean`、`Any`、`JSON`、`FunctionBody` など
|
|
386
|
+
- **構造化型バリアント**: `List`、`Enum`、`Number`、`Directive`
|
|
387
|
+
|
|
388
|
+
**`GlobalAttributes`** -- 要素に適用されるグローバル属性カテゴリを指定する属性カテゴリ選択です。
|
|
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`** -- 型、条件、フラグを含む生の属性定義です。
|
|
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`** -- スペース区切りまたはカンマ区切りのトークンリスト用の構造化型です。
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
interface List {
|
|
435
|
+
token: string | Enum; // トークン型または列挙定義
|
|
436
|
+
separator: 'space' | 'comma'; // 区切り文字の型
|
|
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`** -- 列挙属性値です。
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
interface Enum {
|
|
450
|
+
enum: [string, ...string[]]; // 少なくとも1つの値が必須
|
|
451
|
+
disallowToSurroundBySpaces?: boolean;
|
|
452
|
+
caseInsensitive?: boolean;
|
|
453
|
+
invalidValueDefault?: string; // 値が無効な場合のデフォルト
|
|
454
|
+
missingValueDefault?: string; // 属性が欠落している場合のデフォルト
|
|
455
|
+
sameStates?: { [k: string]: unknown };
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**`Number`** -- 数値属性の制約です。
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
interface Number {
|
|
463
|
+
type: 'float' | 'integer';
|
|
464
|
+
gt?: number; // より大きい
|
|
465
|
+
gte?: number; // 以上
|
|
466
|
+
lt?: number; // より小さい
|
|
467
|
+
lte?: number; // 以下
|
|
468
|
+
clampable?: boolean;
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**`Directive`** -- ディレクティブとトークンの両方を含む複雑な属性のためのディレクティブベースの属性バリデーションです。
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
interface Directive {
|
|
476
|
+
directive: [string, ...string[]]; // 少なくとも1つのディレクティブ
|
|
477
|
+
token: AttributeType; // バリデーション対象のトークン型
|
|
478
|
+
ref?: string; // 参照URL
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### `content-models.schema.json` から -- `src/types/permitted-structures.ts`
|
|
483
|
+
|
|
484
|
+
**`PermittedContentPattern`** -- すべてのコンテンツモデルパターン型の共用体です。
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
type PermittedContentPattern =
|
|
488
|
+
| PermittedContentRequire // 必須コンテンツ
|
|
489
|
+
| PermittedContentOptional // オプションのコンテンツ
|
|
490
|
+
| PermittedContentOneOrMore // 1回以上の出現
|
|
491
|
+
| PermittedContentZeroOrMore // 0回以上の出現
|
|
492
|
+
| PermittedContentChoice // コンテンツ選択肢の中から選択
|
|
493
|
+
| PermittedContentTransparent; // トランスペアレントコンテンツモデル
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
各パターンバリアント(`PermittedContentTransparent` を除く)は `Model` またはネストされた `PermittedContentPattern[]` を受け取り、オプションの `max` カウントをサポートします。
|
|
497
|
+
|
|
498
|
+
**`ContentModel`** -- 要素の完全なコンテンツモデルです。
|
|
499
|
+
|
|
500
|
+
```ts
|
|
501
|
+
interface ContentModel {
|
|
502
|
+
contents: PermittedContentPattern[] | boolean; // コンテンツパターンまたは真偽値
|
|
503
|
+
descendantOf?: string; // コンテキスト制約
|
|
504
|
+
conditional?: {
|
|
505
|
+
// 条件依存のコンテンツ
|
|
506
|
+
condition: string;
|
|
507
|
+
contents: PermittedContentPattern[] | boolean;
|
|
508
|
+
}[];
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**`Category`** -- コンテンツモデルカテゴリ。13個の HTML カテゴリと19個の SVG カテゴリを含みます。
|
|
513
|
+
|
|
514
|
+
HTML カテゴリ:
|
|
515
|
+
|
|
516
|
+
- `#text`、`#phrasing`、`#flow`、`#interactive`、`#heading`
|
|
517
|
+
- `#sectioning`、`#metadata`、`#embedded`、`#palpable`、`#script-supporting`
|
|
518
|
+
|
|
519
|
+
SVG カテゴリ:
|
|
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`** と **`ContentType`**:
|
|
528
|
+
|
|
529
|
+
```ts
|
|
530
|
+
type Model = ContentType | ContentType[];
|
|
531
|
+
type ContentType = string | Category;
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## JSON スキーマファイル
|
|
535
|
+
|
|
536
|
+
以下の JSON スキーマファイルは `schemas/` ディレクトリにあります。
|
|
537
|
+
|
|
538
|
+
| スキーマファイル | 行数 | 説明 |
|
|
539
|
+
| ------------------------------- | ---- | ------------------------------------------------------------------------------------------------------- |
|
|
540
|
+
| `element.schema.json` | 11 | コンテンツモデル、属性、グローバル属性、ARIA への `$ref` ポインタを組み合わせるトップレベル要素スキーマ |
|
|
541
|
+
| `aria.schema.json` | 291 | 暗黙のロール、許可されたロール、プロパティ、バージョンオーバーライドを含む ARIA ロール/プロパティ定義 |
|
|
542
|
+
| `attributes.schema.json` | 190 | 属性型の共用体、属性 JSON 定義、グローバル属性カテゴリ選択、属性名パターン |
|
|
543
|
+
| `content-models.schema.json` | 215 | コンテンツモデルパターン(require、optional、oneOrMore、zeroOrMore、choice、transparent)とカテゴリ定義 |
|
|
544
|
+
| `global-attributes.schema.json` | 787 | HTML と SVG のグローバル属性カテゴリ(`gen/global-attribute.data.ts` から自動生成) |
|
|
545
|
+
|
|
546
|
+
## スキーマ生成ワークフロー
|
|
547
|
+
|
|
548
|
+
スキーマ生成パイプラインは以下のように動作します:
|
|
549
|
+
|
|
550
|
+
1. **`gen/global-attribute.data.ts`** がグローバル属性カテゴリの信頼できるデータソースを定義し、カテゴリごとにすべての属性名をリストします。
|
|
551
|
+
|
|
552
|
+
2. **`gen/gen.ts`** がグローバル属性データを読み取り、2つのスキーマファイルを生成します:
|
|
553
|
+
- `schemas/global-attributes.schema.json` -- カテゴリ定義とカテゴリごとの列挙を含む完全なグローバル属性スキーマ。
|
|
554
|
+
- `schemas/attributes.schema.json` -- カテゴリ固有のプロパティセレクタを含む `GlobalAttributes` 型を含む属性スキーマ。
|
|
555
|
+
|
|
556
|
+
3. **`json-schema-to-typescript`** が各 `.schema.json` ファイルを対応する TypeScript ファイルに変換します:
|
|
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. 生成された TypeScript ファイルには「DO NOT MODIFY」ヘッダーが含まれます。生成された型を更新するには、ソース JSON スキーマ(または自動生成スキーマの場合は生成スクリプト)を変更してから、生成パイプラインを再実行します。
|