-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMedia.ts
More file actions
267 lines (243 loc) · 6.36 KB
/
Copy pathMedia.ts
File metadata and controls
267 lines (243 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import { SchemaDefinition } from '@sozialhelden/simpl-schema';
import IETFLanguageCodeSchemaKeyDefinition, { IETFLanguageTag } from './ietfLanguageTags.js';
import { getInteractableSchemaDefinition, Interactable } from './Interactable.js';
import { getLocalizedStringSchemaDefinition, LocalizedString } from './LocalizedString.js';
import { getPrefixedQuantitySchemaDefinition, Length, LengthSchema } from './Quantity.js';
import validateUrl from './validateUrl.js';
import { W3CAccessibilityControl, w3cAccessibilityControls } from './W3CAccessibilityControl.js';
import { W3CAccessibilityFeature, w3cAccessibilityFeatures } from './W3CAccessibilityFeature.js';
import { W3CAccessibilityHazard, w3cAccessibilityHazards } from './W3CAccessibilityHazard.js';
import { W3CAccessMode, w3cAccessModes } from './W3CAccessMode.js';
export const MediaInteractions = [
'watch',
'listen',
'feel',
'discover',
'open',
'close',
'rent',
'recognize',
'browse',
'read',
'interact',
] as const;
export type MediaInteraction = typeof MediaInteractions[number];
export const MediaInteractionsSet = new Set(MediaInteractions);
export const MediaTypes = [
'document',
'menu',
'guide',
'tour',
'presentation',
'exhibit',
'movie',
'play',
'screen',
'website',
'form',
] as const;
export type MediaType = typeof MediaTypes[number];
export const MediaTypeSet = new Set(MediaTypes);
/**
* Describes a media unit provided at this place, for example an exhibit at a museum or a movie in
* a cinema.
*/
export interface Media extends Interactable<MediaInteraction> {
/**
* Type of the media unit
*/
type?: MediaType;
/**
* Name of the media unit (relevant if there are multiple units of the same kind)
*/
name?: LocalizedString;
/**
* Is the media unit consumable or described for Braille readers?
*/
isBraille?: boolean;
/**
* Is the media unit consumable as audio-only option?
*/
isAudio?: boolean;
/**
* Is the media tactile?
*/
isTactile?: boolean;
/**
* If the media unit is printed, is the print large?
*/
isLargePrint?: boolean;
/**
* If the media unit is printed or on a screen, does it have high contrast between background and
* foreground?
*/
hasContrastingBackground?: boolean;
/**
* Relevant for movies, screens and presentations: Is there a dedicated screen where subtitles can
* be read?
*/
hasDedicatedScreenForSubtitles?: boolean;
/**
* Is the media unit provided with subtitles?
*/
hasSubtitles?: boolean;
/**
* Is the media unit provided with audio description?
*/
hasAudioDescription?: boolean;
/**
* Does the media unit have [real time captioning](https://www.washington.edu/doit/what-real-time-captioning)?
*/
hasRealTimeCaptioning?: boolean;
/**
* Is the media unit provided in a [Plain Language](https://en.wikipedia.org/wiki/Plain_language) option?
*/
hasPlainLanguageOption?: boolean;
/**
* Specifies which languages (including sign languages) in which the media unit is provided
*/
languages?: IETFLanguageTag[];
/**
* If the media is consumed while the consumer is directly in front of it, this property specifies
* how much turning space there is in front of it.
*/
turningSpaceInFront?: Length;
/**
* URLs that contain the media. Use this to link data, for example with [RDF](https://www.w3.org/RDF/).
*/
sameAs?: string[];
/**
* Access modes supported by this equipment.
*
* @see https://www.w3.org/2021/a11y-discov-vocab/latest/
*/
accessMode?: W3CAccessMode[];
/**
* Access mode combinations that allow understanding and using the equipment.
*
* @see https://www.w3.org/2021/a11y-discov-vocab/latest/
*/
accessModeSufficient?: W3CAccessMode[];
/**
* The accessibility controls that allow controlling this equipment.
*
* @see https://www.w3.org/2021/a11y-discov-vocab/latest/
*/
accessibilityControl?: W3CAccessibilityControl[];
/**
* Indicates the access mode combinations that allow understanding and using the equipment.
*
* @see https://www.w3.org/2021/a11y-discov-vocab/latest/
*/
accessibilityFeature?: W3CAccessibilityFeature[];
/**
* Indicates the access mode combinations that allow understanding and using the equipment.
*
* @see https://www.w3.org/2021/a11y-discov-vocab/latest/
*/
accessibilityHazard?: W3CAccessibilityHazard[];
}
export const getMediaSchemaDefinition: () => SchemaDefinition = () => ({
type: {
type: String,
optional: true,
allowedValues: (MediaTypes as any) as any[],
},
...getLocalizedStringSchemaDefinition('name', {
}),
isBraille: {
type: Boolean,
optional: true,
},
isAudio: {
type: Boolean,
optional: true,
},
isTactile: {
type: Boolean,
optional: true,
},
isLargePrint: {
type: Boolean,
optional: true,
},
hasContrastingBackground: {
type: Boolean,
optional: true,
},
hasDedicatedScreenForSubtitles: {
type: Boolean,
optional: true,
},
hasSubtitles: {
type: Boolean,
optional: true,
},
hasAudioDescription: {
type: Boolean,
optional: true,
},
hasRealTimeCaptioning: {
type: Boolean,
optional: true,
},
hasPlainLanguageOption: {
type: Boolean,
optional: true,
},
languages: {
type: Array,
optional: true,
},
'languages.$': IETFLanguageCodeSchemaKeyDefinition,
accessMode: {
type: Array,
optional: true,
},
'accessMode.$': {
type: String,
allowedValues: w3cAccessModes,
},
accessModeSufficient: {
type: Array,
optional: true,
},
'accessModeSufficient.$': {
type: String,
allowedValues: w3cAccessModes,
},
accessibilityControl: {
type: Array,
optional: true,
},
'accessibilityControl.$': {
type: String,
allowedValues: w3cAccessibilityControls,
},
accessibilityFeature: {
type: Array,
optional: true,
},
'accessibilityFeature.$': {
type: String,
allowedValues: w3cAccessibilityFeatures,
},
accessibilityHazard: {
type: Array,
optional: true,
},
'accessibilityHazard.$': {
type: String,
allowedValues: w3cAccessibilityHazards,
},
...getPrefixedQuantitySchemaDefinition('turningSpaceInFront', LengthSchema),
sameAs: {
type: Array,
optional: true,
},
'sameAs.$': {
type: String,
custom: validateUrl,
},
...getInteractableSchemaDefinition(MediaInteractionsSet),
});