@readium/shared 2.0.0 → 2.1.1
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/dist/index.js +2277 -1487
- package/dist/index.umd.cjs +3 -3
- package/package.json +17 -16
- package/src/opds/Acquisition.ts +1 -1
- package/src/publication/BelongsTo.ts +1 -1
- package/src/publication/Contributor.ts +2 -2
- package/src/publication/GuidedNavigation.ts +1 -1
- package/src/publication/Link.ts +2 -2
- package/src/publication/LocatorCollection.ts +1 -1
- package/src/publication/Metadata.ts +9 -1
- package/src/publication/PublicationCollection.ts +3 -3
- package/src/publication/Subject.ts +1 -1
- package/src/publication/accessibility/Accessibility.ts +860 -0
- package/src/publication/accessibility/AccessibilityMetadataDisplayGuide.ts +1055 -0
- package/src/publication/accessibility/Localization.md +203 -0
- package/src/publication/accessibility/Localization.ts +115 -0
- package/src/publication/accessibility/index.ts +3 -0
- package/src/publication/accessibility/locales/en.json +231 -0
- package/src/publication/accessibility/locales/fr.json +231 -0
- package/src/publication/index.ts +1 -0
- package/src/publication/opds/Properties.ts +1 -1
- package/src/util/JSONParse.ts +1 -1
- package/types/src/publication/Metadata.d.ts +3 -0
- package/types/src/publication/accessibility/Accessibility.d.ts +321 -0
- package/types/src/publication/accessibility/Localization.d.ts +8 -0
- package/types/src/publication/index.d.ts +1 -0
|
@@ -0,0 +1,860 @@
|
|
|
1
|
+
/* Copyright 2025 Readium Foundation. All rights reserved.
|
|
2
|
+
* Use of this source code is governed by a BSD-style license,
|
|
3
|
+
* available in the LICENSE file present in the Github repository of the project.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Holds the accessibility metadata of a Publication.
|
|
8
|
+
*
|
|
9
|
+
* https://www.w3.org/2021/a11y-discov-vocab/latest/
|
|
10
|
+
* https://readium.org/webpub-manifest/schema/a11y.schema.json
|
|
11
|
+
*/
|
|
12
|
+
export class Accessibility {
|
|
13
|
+
/**
|
|
14
|
+
* An established standard to which the described resource conforms.
|
|
15
|
+
*/
|
|
16
|
+
public conformsTo: AccessibilityProfile[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Certification of accessible publications.
|
|
20
|
+
*/
|
|
21
|
+
public certification: Certification | null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A human-readable summary of specific accessibility features or deficiencies.
|
|
25
|
+
*/
|
|
26
|
+
public summary: string | null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The human sensory perceptual system through which a person may process or perceive information.
|
|
30
|
+
*/
|
|
31
|
+
public accessMode: AccessMode[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A list of single or combined accessModes that are sufficient to understand all the intellectual content.
|
|
35
|
+
*/
|
|
36
|
+
public accessModeSufficient: PrimaryAccessMode[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Content features of the resource.
|
|
40
|
+
*/
|
|
41
|
+
public feature: Feature[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A characteristic of the described resource that is physiologically dangerous to some users.
|
|
45
|
+
*/
|
|
46
|
+
public hazard: Hazard[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Justifications for non-conformance based on exemptions in a given jurisdiction.
|
|
50
|
+
*/
|
|
51
|
+
public exemption: Exemption[];
|
|
52
|
+
|
|
53
|
+
constructor(values: {
|
|
54
|
+
conformsTo?: AccessibilityProfile[],
|
|
55
|
+
certification?: Certification | null,
|
|
56
|
+
summary?: string | null,
|
|
57
|
+
accessMode?: AccessMode[],
|
|
58
|
+
accessModeSufficient?: PrimaryAccessMode[],
|
|
59
|
+
feature?: Feature[],
|
|
60
|
+
hazard?: Hazard[],
|
|
61
|
+
exemption?: Exemption[]
|
|
62
|
+
} = {}) {
|
|
63
|
+
this.conformsTo = values.conformsTo ?? [];
|
|
64
|
+
this.certification = values.certification ?? null;
|
|
65
|
+
this.summary = values.summary ?? null;
|
|
66
|
+
this.accessMode = values.accessMode ?? [];
|
|
67
|
+
this.accessModeSufficient = values.accessModeSufficient ?? [];
|
|
68
|
+
this.feature = values.feature ?? [];
|
|
69
|
+
this.hazard = values.hazard ?? [];
|
|
70
|
+
this.exemption = values.exemption ?? [];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parses an [Accessibility] from its RWPM JSON representation.
|
|
75
|
+
*/
|
|
76
|
+
public static deserialize(json: Record<string, any> | string): Accessibility | undefined {
|
|
77
|
+
if (!json || typeof json !== 'object') return;
|
|
78
|
+
|
|
79
|
+
type AccessibilityJson = {
|
|
80
|
+
conformsTo?: string[];
|
|
81
|
+
certification?: {
|
|
82
|
+
certifiedBy: string;
|
|
83
|
+
credential: string;
|
|
84
|
+
report: string;
|
|
85
|
+
};
|
|
86
|
+
summary?: string;
|
|
87
|
+
accessMode?: string[];
|
|
88
|
+
accessModeSufficient?: string[][];
|
|
89
|
+
feature?: string[];
|
|
90
|
+
hazard?: string[];
|
|
91
|
+
exemption?: string[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const accessibilityJson = json as AccessibilityJson;
|
|
95
|
+
|
|
96
|
+
return new Accessibility({
|
|
97
|
+
conformsTo: accessibilityJson.conformsTo
|
|
98
|
+
? accessibilityJson.conformsTo.map(uri => AccessibilityProfile.deserialize(uri))
|
|
99
|
+
.filter((profile): profile is AccessibilityProfile => profile !== undefined)
|
|
100
|
+
: undefined,
|
|
101
|
+
certification: accessibilityJson.certification
|
|
102
|
+
? Certification.deserialize(accessibilityJson.certification)
|
|
103
|
+
: undefined,
|
|
104
|
+
summary: accessibilityJson.summary,
|
|
105
|
+
accessMode: accessibilityJson.accessMode
|
|
106
|
+
? accessibilityJson.accessMode.map(value => AccessMode.deserialize(value))
|
|
107
|
+
.filter((mode): mode is AccessMode => mode !== undefined)
|
|
108
|
+
: undefined,
|
|
109
|
+
accessModeSufficient: accessibilityJson.accessModeSufficient
|
|
110
|
+
? accessibilityJson.accessModeSufficient.map(modes => PrimaryAccessMode.deserialize(modes))
|
|
111
|
+
.filter((mode): mode is PrimaryAccessMode => mode !== undefined)
|
|
112
|
+
: undefined,
|
|
113
|
+
feature: accessibilityJson.feature
|
|
114
|
+
? accessibilityJson.feature.map(value => Feature.deserialize(value))
|
|
115
|
+
.filter((feature): feature is Feature => feature !== undefined)
|
|
116
|
+
: undefined,
|
|
117
|
+
hazard: accessibilityJson.hazard
|
|
118
|
+
? accessibilityJson.hazard.map(value => Hazard.deserialize(value))
|
|
119
|
+
.filter((hazard): hazard is Hazard => hazard !== undefined)
|
|
120
|
+
: undefined,
|
|
121
|
+
exemption: accessibilityJson.exemption
|
|
122
|
+
? accessibilityJson.exemption.map(value => Exemption.deserialize(value))
|
|
123
|
+
.filter((exemption): exemption is Exemption => exemption !== undefined)
|
|
124
|
+
: undefined
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Serializes an [Accessibility] to its RWPM JSON representation.
|
|
130
|
+
*/
|
|
131
|
+
public serialize(): Record<string, any> {
|
|
132
|
+
const result: Record<string, any> = {};
|
|
133
|
+
|
|
134
|
+
if (this.conformsTo?.length > 0) {
|
|
135
|
+
result.conformsTo = this.conformsTo.map(profile => profile.serialize());
|
|
136
|
+
}
|
|
137
|
+
if (this.certification !== undefined && this.certification !== null) {
|
|
138
|
+
result.certification = this.certification.serialize();
|
|
139
|
+
}
|
|
140
|
+
if (this.summary !== undefined && this.summary !== null) {
|
|
141
|
+
result.summary = this.summary;
|
|
142
|
+
}
|
|
143
|
+
if (this.accessMode?.length > 0) {
|
|
144
|
+
result.accessMode = this.accessMode.map(mode => mode.serialize());
|
|
145
|
+
}
|
|
146
|
+
if (this.accessModeSufficient?.length > 0) {
|
|
147
|
+
result.accessModeSufficient = this.accessModeSufficient.map(mode => mode.serialize());
|
|
148
|
+
}
|
|
149
|
+
if (this.feature?.length > 0) {
|
|
150
|
+
result.feature = this.feature.map(feature => feature.serialize());
|
|
151
|
+
}
|
|
152
|
+
if (this.hazard?.length > 0) {
|
|
153
|
+
result.hazard = this.hazard.map(hazard => hazard.serialize());
|
|
154
|
+
}
|
|
155
|
+
if (this.exemption?.length > 0) {
|
|
156
|
+
result.exemption = this.exemption.map(exemption => exemption.serialize());
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export class AccessibilityProfile {
|
|
164
|
+
public readonly uri: string;
|
|
165
|
+
|
|
166
|
+
constructor(uri: string) {
|
|
167
|
+
this.uri = uri;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Parses an [AccessibilityProfile] from its RWPM JSON representation.
|
|
172
|
+
*/
|
|
173
|
+
public static deserialize(json: any): AccessibilityProfile | undefined {
|
|
174
|
+
if (!json || typeof json !== 'string') return;
|
|
175
|
+
return new AccessibilityProfile(json);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Serializes an [AccessibilityProfile] to its RWPM JSON representation.
|
|
180
|
+
*/
|
|
181
|
+
public serialize(): any {
|
|
182
|
+
return this.uri;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* EPUB Accessibility 1.0 WCAG 2.0 A – http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a
|
|
187
|
+
*/
|
|
188
|
+
public static readonly EPUB_A11Y_10_WCAG_20_A = new AccessibilityProfile('http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a');
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* EPUB Accessibility 1.0 WCAG 2.0 AA – http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa
|
|
192
|
+
*/
|
|
193
|
+
public static readonly EPUB_A11Y_10_WCAG_20_AA = new AccessibilityProfile('http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa');
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* EPUB Accessibility 1.0 WCAG 2.0 AAA – http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa
|
|
197
|
+
*/
|
|
198
|
+
public static readonly EPUB_A11Y_10_WCAG_20_AAA = new AccessibilityProfile('http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa');
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* EPUB Accessibility 1.1 WCAG 2.0 A – https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a
|
|
202
|
+
*/
|
|
203
|
+
public static readonly EPUB_A11Y_11_WCAG_20_A = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a');
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* EPUB Accessibility 1.1 WCAG 2.0 AA – https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa
|
|
207
|
+
*/
|
|
208
|
+
public static readonly EPUB_A11Y_11_WCAG_20_AA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa');
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* EPUB Accessibility 1.1 WCAG 2.0 AAA – https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa
|
|
212
|
+
*/
|
|
213
|
+
public static readonly EPUB_A11Y_11_WCAG_20_AAA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa');
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* EPUB Accessibility 1.1 WCAG 2.1 A – https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a
|
|
217
|
+
*/
|
|
218
|
+
public static readonly EPUB_A11Y_11_WCAG_21_A = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a');
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* EPUB Accessibility 1.1 WCAG 2.1 AA – https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa
|
|
222
|
+
*/
|
|
223
|
+
public static readonly EPUB_A11Y_11_WCAG_21_AA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa');
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* EPUB Accessibility 1.1 WCAG 2.1 AAA – https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa
|
|
227
|
+
*/
|
|
228
|
+
public static readonly EPUB_A11Y_11_WCAG_21_AAA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa');
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* EPUB Accessibility 1.1 WCAG 2.2 A – https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a
|
|
232
|
+
*/
|
|
233
|
+
public static readonly EPUB_A11Y_11_WCAG_22_A = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a');
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* EPUB Accessibility 1.1 WCAG 2.2 AA – https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa
|
|
237
|
+
*/
|
|
238
|
+
public static readonly EPUB_A11Y_11_WCAG_22_AA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa');
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* EPUB Accessibility 1.1 WCAG 2.2 AAA – https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa
|
|
242
|
+
*/
|
|
243
|
+
public static readonly EPUB_A11Y_11_WCAG_22_AAA = new AccessibilityProfile('https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa');
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Returns true if the profile is a WCAG Level A profile.
|
|
247
|
+
*/
|
|
248
|
+
public get isWCAGLevelA(): boolean {
|
|
249
|
+
return this === AccessibilityProfile.EPUB_A11Y_10_WCAG_20_A ||
|
|
250
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_20_A ||
|
|
251
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_21_A ||
|
|
252
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_22_A;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Returns true if the profile is a WCAG Level AA profile.
|
|
257
|
+
*/
|
|
258
|
+
public get isWCAGLevelAA(): boolean {
|
|
259
|
+
return this === AccessibilityProfile.EPUB_A11Y_10_WCAG_20_AA ||
|
|
260
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_20_AA ||
|
|
261
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_21_AA ||
|
|
262
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_22_AA;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Returns true if the profile is a WCAG Level AAA profile.
|
|
267
|
+
*/
|
|
268
|
+
public get isWCAGLevelAAA(): boolean {
|
|
269
|
+
return this === AccessibilityProfile.EPUB_A11Y_10_WCAG_20_AAA ||
|
|
270
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_20_AAA ||
|
|
271
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_21_AAA ||
|
|
272
|
+
this === AccessibilityProfile.EPUB_A11Y_11_WCAG_22_AAA;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export class Certification {
|
|
277
|
+
public readonly certifiedBy: string | null;
|
|
278
|
+
public readonly credential: string | null;
|
|
279
|
+
public readonly report: string | null;
|
|
280
|
+
|
|
281
|
+
constructor(
|
|
282
|
+
certifiedBy: string | null = null,
|
|
283
|
+
credential: string | null = null,
|
|
284
|
+
report: string | null = null
|
|
285
|
+
) {
|
|
286
|
+
this.certifiedBy = certifiedBy;
|
|
287
|
+
this.credential = credential;
|
|
288
|
+
this.report = report;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Parses a [Certification] from its RWPM JSON representation.
|
|
293
|
+
*/
|
|
294
|
+
public static deserialize(json: any): Certification | undefined {
|
|
295
|
+
if (!json || typeof json !== 'object') return;
|
|
296
|
+
return new Certification(
|
|
297
|
+
json.certifiedBy,
|
|
298
|
+
json.credential,
|
|
299
|
+
json.report
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Serializes a [Certification] to its RWPM JSON representation.
|
|
305
|
+
*/
|
|
306
|
+
public serialize(): Record<string, any> {
|
|
307
|
+
const json: any = {};
|
|
308
|
+
if (this.certifiedBy) {
|
|
309
|
+
json.certifiedBy = this.certifiedBy;
|
|
310
|
+
}
|
|
311
|
+
if (this.credential) {
|
|
312
|
+
json.credential = this.credential;
|
|
313
|
+
}
|
|
314
|
+
if (this.report) {
|
|
315
|
+
json.report = this.report;
|
|
316
|
+
}
|
|
317
|
+
return json;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export class AccessMode {
|
|
322
|
+
public readonly value: string;
|
|
323
|
+
|
|
324
|
+
constructor(value: string) {
|
|
325
|
+
this.value = value;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Parses an [AccessMode] from its RWPM JSON representation.
|
|
330
|
+
*/
|
|
331
|
+
public static deserialize(json: any): AccessMode | undefined {
|
|
332
|
+
if (!json || typeof json !== 'string') return;
|
|
333
|
+
return new AccessMode(json);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Serializes an [AccessMode] to its RWPM JSON representation.
|
|
338
|
+
*/
|
|
339
|
+
public serialize(): any {
|
|
340
|
+
return this.value;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Access mode for auditory content.
|
|
345
|
+
*/
|
|
346
|
+
public static readonly AUDITORY = new AccessMode('auditory');
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Access mode for chart on visual content.
|
|
350
|
+
*/
|
|
351
|
+
public static readonly CHART_ON_VISUAL = new AccessMode('chartOnVisual');
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Access mode for chemical on visual content.
|
|
355
|
+
*/
|
|
356
|
+
public static readonly CHEM_ON_VISUAL = new AccessMode('chemOnVisual');
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Access mode for color dependent content.
|
|
360
|
+
*/
|
|
361
|
+
public static readonly COLOR_DEPENDENT = new AccessMode('colorDependent');
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Access mode for diagram on visual content.
|
|
365
|
+
*/
|
|
366
|
+
public static readonly DIAGRAM_ON_VISUAL = new AccessMode('diagramOnVisual');
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Access mode for math on visual content.
|
|
370
|
+
*/
|
|
371
|
+
public static readonly MATH_ON_VISUAL = new AccessMode('mathOnVisual');
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Access mode for music on visual content.
|
|
375
|
+
*/
|
|
376
|
+
public static readonly MUSIC_ON_VISUAL = new AccessMode('musicOnVisual');
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Access mode for tactile content.
|
|
380
|
+
*/
|
|
381
|
+
public static readonly TACTILE = new AccessMode('tactile');
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Access mode for text on visual content.
|
|
385
|
+
*/
|
|
386
|
+
public static readonly TEXT_ON_VISUAL = new AccessMode('textOnVisual');
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Access mode for textual content.
|
|
390
|
+
*/
|
|
391
|
+
public static readonly TEXTUAL = new AccessMode('textual');
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Access mode for visual content.
|
|
395
|
+
*/
|
|
396
|
+
public static readonly VISUAL = new AccessMode('visual');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export class PrimaryAccessMode {
|
|
400
|
+
public readonly value!: string | string[];
|
|
401
|
+
private static readonly VALID_MODES = new Set(['auditory', 'tactile', 'textual', 'visual']);
|
|
402
|
+
|
|
403
|
+
constructor(value: string | string[]) {
|
|
404
|
+
if (typeof value === 'string') {
|
|
405
|
+
if (!PrimaryAccessMode.VALID_MODES.has(value.toLowerCase())) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
this.value = value.toLowerCase();
|
|
409
|
+
} else {
|
|
410
|
+
// Filter out invalid modes and duplicates
|
|
411
|
+
const validModes = value.filter(mode =>
|
|
412
|
+
PrimaryAccessMode.VALID_MODES.has(mode.toLowerCase())
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
if (validModes.length === 0) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
this.value = Array.from(new Set(validModes));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Parses a [PrimaryAccessMode] from its RWPM JSON representation.
|
|
425
|
+
*/
|
|
426
|
+
public static deserialize(json: any): PrimaryAccessMode | undefined {
|
|
427
|
+
if (!json) return;
|
|
428
|
+
|
|
429
|
+
if (typeof json === 'string') {
|
|
430
|
+
return new PrimaryAccessMode(json);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (!Array.isArray(json)) return undefined;
|
|
434
|
+
|
|
435
|
+
// Create a new array with only valid modes
|
|
436
|
+
const validModes = json.filter(mode => {
|
|
437
|
+
if (!mode) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
return PrimaryAccessMode.VALID_MODES.has(mode.toLowerCase());
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (validModes.length === 0) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return new PrimaryAccessMode(validModes);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
452
|
+
*/
|
|
453
|
+
public serialize(): string | string[] {
|
|
454
|
+
return this.value;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Primary access mode for auditory content.
|
|
459
|
+
*/
|
|
460
|
+
public static readonly AUDITORY = new PrimaryAccessMode('auditory');
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Primary access mode for tactile content.
|
|
464
|
+
*/
|
|
465
|
+
public static readonly TACTILE = new PrimaryAccessMode('tactile');
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Primary access mode for textual content.
|
|
469
|
+
*/
|
|
470
|
+
public static readonly TEXTUAL = new PrimaryAccessMode('textual');
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Primary access mode for visual content.
|
|
474
|
+
*/
|
|
475
|
+
public static readonly VISUAL = new PrimaryAccessMode('visual');
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export class Feature {
|
|
479
|
+
public readonly value: string;
|
|
480
|
+
|
|
481
|
+
constructor(value: string) {
|
|
482
|
+
this.value = value;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Parses a [Feature] from its RWPM JSON representation.
|
|
487
|
+
*/
|
|
488
|
+
public static deserialize(json: any): Feature | undefined {
|
|
489
|
+
if (!json || typeof json !== 'string') return;
|
|
490
|
+
return new Feature(json);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Serializes a [Feature] to its RWPM JSON representation.
|
|
495
|
+
*/
|
|
496
|
+
public serialize(): any {
|
|
497
|
+
return this.value;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Feature for no accessibility features.
|
|
502
|
+
*/
|
|
503
|
+
public static readonly NONE = new Feature('none');
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Feature for annotations.
|
|
507
|
+
*/
|
|
508
|
+
public static readonly ANNOTATIONS = new Feature('annotations');
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Feature for ARIA.
|
|
512
|
+
*/
|
|
513
|
+
public static readonly ARIA = new Feature('ARIA');
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Feature for index.
|
|
517
|
+
*/
|
|
518
|
+
public static readonly INDEX = new Feature('index');
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Feature for page break markers.
|
|
522
|
+
*/
|
|
523
|
+
public static readonly PAGE_BREAK_MARKERS = new Feature('pageBreakMarkers');
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Feature for page navigation.
|
|
527
|
+
*/
|
|
528
|
+
public static readonly PAGE_NAVIGATION = new Feature('pageNavigation');
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Feature for print page numbers.
|
|
532
|
+
*/
|
|
533
|
+
public static readonly PRINT_PAGE_NUMBERS = new Feature('printPageNumbers');
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Feature for reading order.
|
|
537
|
+
*/
|
|
538
|
+
public static readonly READING_ORDER = new Feature('readingOrder');
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Feature for structural navigation.
|
|
542
|
+
*/
|
|
543
|
+
public static readonly STRUCTURAL_NAVIGATION = new Feature('structuralNavigation');
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Feature for table of contents.
|
|
547
|
+
*/
|
|
548
|
+
public static readonly TABLE_OF_CONTENTS = new Feature('tableOfContents');
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Feature for tagged PDF.
|
|
552
|
+
*/
|
|
553
|
+
public static readonly TAGGED_PDF = new Feature('taggedPDF');
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Feature for alternative text.
|
|
557
|
+
*/
|
|
558
|
+
public static readonly ALTERNATIVE_TEXT = new Feature('alternativeText');
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Feature for audio description.
|
|
562
|
+
*/
|
|
563
|
+
public static readonly AUDIO_DESCRIPTION = new Feature('audioDescription');
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Feature for captions.
|
|
567
|
+
*/
|
|
568
|
+
public static readonly CAPTIONS = new Feature('captions');
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Feature for closed captions.
|
|
572
|
+
*/
|
|
573
|
+
public static readonly CLOSED_CAPTIONS = new Feature('closedCaptions');
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Feature for described math.
|
|
577
|
+
*/
|
|
578
|
+
public static readonly DESCRIBED_MATH = new Feature('describedMath');
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Feature for long description.
|
|
582
|
+
*/
|
|
583
|
+
public static readonly LONG_DESCRIPTION = new Feature('longDescription');
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Feature for open captions.
|
|
587
|
+
*/
|
|
588
|
+
public static readonly OPEN_CAPTIONS = new Feature('openCaptions');
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Feature for sign language.
|
|
592
|
+
*/
|
|
593
|
+
public static readonly SIGN_LANGUAGE = new Feature('signLanguage');
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Feature for transcript.
|
|
597
|
+
*/
|
|
598
|
+
public static readonly TRANSCRIPT = new Feature('transcript');
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Feature for display transformability.
|
|
602
|
+
*/
|
|
603
|
+
public static readonly DISPLAY_TRANSFORMABILITY = new Feature('displayTransformability');
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Feature for synchronized audio text.
|
|
607
|
+
*/
|
|
608
|
+
public static readonly SYNCHRONIZED_AUDIO_TEXT = new Feature('synchronizedAudioText');
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Feature for timing control.
|
|
612
|
+
*/
|
|
613
|
+
public static readonly TIMING_CONTROL = new Feature('timingControl');
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Feature for unlocked.
|
|
617
|
+
*/
|
|
618
|
+
public static readonly UNLOCKED = new Feature('unlocked');
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Feature for ChemML.
|
|
622
|
+
*/
|
|
623
|
+
public static readonly CHEM_ML = new Feature('ChemML');
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Feature for LaTeX.
|
|
627
|
+
*/
|
|
628
|
+
public static readonly LATEX = new Feature('latex');
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Feature for LaTeX chemistry.
|
|
632
|
+
*/
|
|
633
|
+
public static readonly LATEX_CHEMISTRY = new Feature('latex-chemistry');
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Feature for MathML.
|
|
637
|
+
*/
|
|
638
|
+
public static readonly MATH_ML = new Feature('MathML');
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Feature for MathML chemistry.
|
|
642
|
+
*/
|
|
643
|
+
public static readonly MATH_ML_CHEMISTRY = new Feature('MathML-chemistry');
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Feature for TTS markup.
|
|
647
|
+
*/
|
|
648
|
+
public static readonly TTS_MARKUP = new Feature('ttsMarkup');
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Feature for high contrast audio.
|
|
652
|
+
*/
|
|
653
|
+
public static readonly HIGH_CONTRAST_AUDIO = new Feature('highContrastAudio');
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Feature for high contrast display.
|
|
657
|
+
*/
|
|
658
|
+
public static readonly HIGH_CONTRAST_DISPLAY = new Feature('highContrastDisplay');
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Feature for large print.
|
|
662
|
+
*/
|
|
663
|
+
public static readonly LARGE_PRINT = new Feature('largePrint');
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Feature for braille.
|
|
667
|
+
*/
|
|
668
|
+
public static readonly BRAILLE = new Feature('braille');
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Feature for tactile graphic.
|
|
672
|
+
*/
|
|
673
|
+
public static readonly TACTILE_GRAPHIC = new Feature('tactileGraphic');
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Feature for tactile object.
|
|
677
|
+
*/
|
|
678
|
+
public static readonly TACTILE_OBJECT = new Feature('tactileObject');
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Feature for full ruby annotations.
|
|
682
|
+
*/
|
|
683
|
+
public static readonly FULL_RUBY_ANNOTATIONS = new Feature('fullRubyAnnotations');
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Feature for horizontal writing.
|
|
687
|
+
*/
|
|
688
|
+
public static readonly HORIZONTAL_WRITING = new Feature('horizontalWriting');
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Feature for ruby annotations.
|
|
692
|
+
*/
|
|
693
|
+
public static readonly RUBY_ANNOTATIONS = new Feature('rubyAnnotations');
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Feature for vertical writing.
|
|
697
|
+
*/
|
|
698
|
+
public static readonly VERTICAL_WRITING = new Feature('verticalWriting');
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Feature for additional word segmentation.
|
|
702
|
+
*/
|
|
703
|
+
public static readonly WITH_ADDITIONAL_WORD_SEGMENTATION = new Feature('withAdditionalWordSegmentation');
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Feature for lack of additional word segmentation.
|
|
707
|
+
*/
|
|
708
|
+
public static readonly WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new Feature('withoutAdditionalWordSegmentation');
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export class Hazard {
|
|
712
|
+
public readonly value: string;
|
|
713
|
+
|
|
714
|
+
constructor(value: string) {
|
|
715
|
+
this.value = value;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Parses a [Hazard] from its RWPM JSON representation.
|
|
720
|
+
*/
|
|
721
|
+
public static deserialize(json: any): Hazard | undefined {
|
|
722
|
+
if (!json || typeof json !== 'string') return;
|
|
723
|
+
return new Hazard(json);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Serializes a [Hazard] to its RWPM JSON representation.
|
|
728
|
+
*/
|
|
729
|
+
public serialize(): any {
|
|
730
|
+
return this.value;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Hazard for flashing.
|
|
735
|
+
*/
|
|
736
|
+
public static readonly FLASHING = new Hazard('flashing');
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Hazard for no flashing hazard.
|
|
740
|
+
*/
|
|
741
|
+
public static readonly NO_FLASHING_HAZARD = new Hazard('noFlashingHazard');
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Hazard for unknown flashing hazard.
|
|
745
|
+
*/
|
|
746
|
+
public static readonly UNKNOWN_FLASHING_HAZARD = new Hazard('unknownFlashingHazard');
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Hazard for motion simulation.
|
|
750
|
+
*/
|
|
751
|
+
public static readonly MOTION_SIMULATION = new Hazard('motionSimulation');
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Hazard for no motion simulation hazard.
|
|
755
|
+
*/
|
|
756
|
+
public static readonly NO_MOTION_SIMULATION_HAZARD = new Hazard('noMotionSimulationHazard');
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Hazard for unknown motion simulation hazard.
|
|
760
|
+
*/
|
|
761
|
+
public static readonly UNKNOWN_MOTION_SIMULATION_HAZARD = new Hazard('unknownMotionSimulationHazard');
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Hazard for sound.
|
|
765
|
+
*/
|
|
766
|
+
public static readonly SOUND = new Hazard('sound');
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Hazard for no sound hazard.
|
|
770
|
+
*/
|
|
771
|
+
public static readonly NO_SOUND_HAZARD = new Hazard('noSoundHazard');
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Hazard for unknown sound hazard.
|
|
775
|
+
*/
|
|
776
|
+
public static readonly UNKNOWN_SOUND_HAZARD = new Hazard('unknownSoundHazard');
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Hazard for unknown hazard.
|
|
780
|
+
*/
|
|
781
|
+
public static readonly UNKNOWN = new Hazard('unknown');
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Hazard for no hazard.
|
|
785
|
+
*/
|
|
786
|
+
public static readonly NONE = new Hazard('none');
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export class Exemption {
|
|
790
|
+
public readonly value: string;
|
|
791
|
+
|
|
792
|
+
constructor(value: string) {
|
|
793
|
+
this.value = value;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Parses an [Exemption] from its RWPM JSON representation.
|
|
798
|
+
*/
|
|
799
|
+
public static deserialize(json: any): Exemption | undefined {
|
|
800
|
+
if (!json || typeof json !== 'string') return;
|
|
801
|
+
return new Exemption(json);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Serializes an [Exemption] to its RWPM JSON representation.
|
|
806
|
+
*/
|
|
807
|
+
public serialize(): any {
|
|
808
|
+
return this.value;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* None exemption.
|
|
813
|
+
*/
|
|
814
|
+
public static readonly NONE = new Exemption('none');
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Documented exemption.
|
|
818
|
+
*/
|
|
819
|
+
public static readonly DOCUMENTED = new Exemption('documented');
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Legal exemption.
|
|
823
|
+
*/
|
|
824
|
+
public static readonly LEGAL = new Exemption('legal');
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Temporary exemption.
|
|
828
|
+
*/
|
|
829
|
+
public static readonly TEMPORARY = new Exemption('temporary');
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Technical exemption.
|
|
833
|
+
*/
|
|
834
|
+
public static readonly TECHNICAL = new Exemption('technical');
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* EAA disproportionate burden exemption.
|
|
838
|
+
*/
|
|
839
|
+
public static readonly EAA_DISPROPORTIONATE_BURDEN = new Exemption('eaa-disproportionate-burden');
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* EAA fundamental alteration exemption.
|
|
843
|
+
*/
|
|
844
|
+
public static readonly EAA_FUNDAMENTAL_ALTERATION = new Exemption('eaa-fundamental-alteration');
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* EAA microenterprise exemption.
|
|
848
|
+
*/
|
|
849
|
+
public static readonly EAA_MICROENTERPRISE = new Exemption('eaa-microenterprise');
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* EAA technical impossibility exemption.
|
|
853
|
+
*/
|
|
854
|
+
public static readonly EAA_TECHNICAL_IMPOSSIBILITY = new Exemption('eaa-technical-impossibility');
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* EAA temporary exemption.
|
|
858
|
+
*/
|
|
859
|
+
public static readonly EAA_TEMPORARY = new Exemption('eaa-temporary');
|
|
860
|
+
}
|