@readium/shared 2.5.0 → 2.5.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.
@@ -1 +1 @@
1
- class O{constructor(i={}){this.conformsTo=i.conformsTo??[],this.certification=i.certification??null,this.summary=i.summary??null,this.accessMode=i.accessMode??[],this.accessModeSufficient=i.accessModeSufficient??[],this.feature=i.feature??[],this.hazard=i.hazard??[],this.exemption=i.exemption??[]}static deserialize(i){if(!i||typeof i!="object")return;const a=i;return new O({conformsTo:a.conformsTo?a.conformsTo.map(e=>c.deserialize(e)).filter(e=>e!==void 0):void 0,certification:a.certification?I.deserialize(a.certification):void 0,summary:a.summary,accessMode:a.accessMode?a.accessMode.map(e=>w.deserialize(e)).filter(e=>e!==void 0):void 0,accessModeSufficient:a.accessModeSufficient?a.accessModeSufficient.map(e=>o.deserialize(e)).filter(e=>e!==void 0):void 0,feature:a.feature?a.feature.map(e=>T.deserialize(e)).filter(e=>e!==void 0):void 0,hazard:a.hazard?a.hazard.map(e=>l.deserialize(e)).filter(e=>e!==void 0):void 0,exemption:a.exemption?a.exemption.map(e=>N.deserialize(e)).filter(e=>e!==void 0):void 0})}serialize(){const i={};return this.conformsTo?.length>0&&(i.conformsTo=this.conformsTo.map(a=>a.serialize())),this.certification!==void 0&&this.certification!==null&&(i.certification=this.certification.serialize()),this.summary!==void 0&&this.summary!==null&&(i.summary=this.summary),this.accessMode?.length>0&&(i.accessMode=this.accessMode.map(a=>a.serialize())),this.accessModeSufficient?.length>0&&(i.accessModeSufficient=this.accessModeSufficient.map(a=>a.serialize())),this.feature?.length>0&&(i.feature=this.feature.map(a=>a.serialize())),this.hazard?.length>0&&(i.hazard=this.hazard.map(a=>a.serialize())),this.exemption?.length>0&&(i.exemption=this.exemption.map(a=>a.serialize())),i}}const s=class s{constructor(i){this.uri=i}static deserialize(i){if(!(!i||typeof i!="string"))return new s(i)}serialize(){return this.uri}get isWCAGLevelA(){return this===s.EPUB_A11Y_10_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_21_A||this===s.EPUB_A11Y_11_WCAG_22_A}get isWCAGLevelAA(){return this===s.EPUB_A11Y_10_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_21_AA||this===s.EPUB_A11Y_11_WCAG_22_AA}get isWCAGLevelAAA(){return this===s.EPUB_A11Y_10_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_21_AAA||this===s.EPUB_A11Y_11_WCAG_22_AAA}};s.EPUB_A11Y_10_WCAG_20_A=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"),s.EPUB_A11Y_10_WCAG_20_AA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"),s.EPUB_A11Y_10_WCAG_20_AAA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"),s.EPUB_A11Y_11_WCAG_20_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"),s.EPUB_A11Y_11_WCAG_20_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"),s.EPUB_A11Y_11_WCAG_20_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"),s.EPUB_A11Y_11_WCAG_21_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"),s.EPUB_A11Y_11_WCAG_21_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"),s.EPUB_A11Y_11_WCAG_21_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"),s.EPUB_A11Y_11_WCAG_22_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"),s.EPUB_A11Y_11_WCAG_22_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"),s.EPUB_A11Y_11_WCAG_22_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");let c=s;class I{constructor(i=null,a=null,e=null){this.certifiedBy=i,this.credential=a,this.report=e}static deserialize(i){if(!(!i||typeof i!="object"))return new I(i.certifiedBy,i.credential,i.report)}serialize(){const i={};return this.certifiedBy&&(i.certifiedBy=this.certifiedBy),this.credential&&(i.credential=this.credential),this.report&&(i.report=this.report),i}}const n=class n{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new n(i)}serialize(){return this.value}};n.AUDITORY=new n("auditory"),n.CHART_ON_VISUAL=new n("chartOnVisual"),n.CHEM_ON_VISUAL=new n("chemOnVisual"),n.COLOR_DEPENDENT=new n("colorDependent"),n.DIAGRAM_ON_VISUAL=new n("diagramOnVisual"),n.MATH_ON_VISUAL=new n("mathOnVisual"),n.MUSIC_ON_VISUAL=new n("musicOnVisual"),n.TACTILE=new n("tactile"),n.TEXT_ON_VISUAL=new n("textOnVisual"),n.TEXTUAL=new n("textual"),n.VISUAL=new n("visual");let w=n;const r=class r{constructor(i){if(typeof i=="string"){if(!r.VALID_MODES.has(i.toLowerCase()))return;this.value=i.toLowerCase()}else{const a=i.filter(e=>r.VALID_MODES.has(e.toLowerCase()));if(a.length===0)return;this.value=Array.from(new Set(a))}}static deserialize(i){if(!i)return;if(typeof i=="string")return new r(i);if(!Array.isArray(i))return;const a=i.filter(e=>e?r.VALID_MODES.has(e.toLowerCase()):!1);if(a.length!==0)return new r(a)}serialize(){return this.value}};r.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),r.AUDITORY=new r("auditory"),r.TACTILE=new r("tactile"),r.TEXTUAL=new r("textual"),r.VISUAL=new r("visual");let o=r;const t=class t{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new t(i)}serialize(){return this.value}};t.NONE=new t("none"),t.ANNOTATIONS=new t("annotations"),t.ARIA=new t("ARIA"),t.INDEX=new t("index"),t.PAGE_BREAK_MARKERS=new t("pageBreakMarkers"),t.PAGE_NAVIGATION=new t("pageNavigation"),t.PRINT_PAGE_NUMBERS=new t("printPageNumbers"),t.READING_ORDER=new t("readingOrder"),t.STRUCTURAL_NAVIGATION=new t("structuralNavigation"),t.TABLE_OF_CONTENTS=new t("tableOfContents"),t.TAGGED_PDF=new t("taggedPDF"),t.ALTERNATIVE_TEXT=new t("alternativeText"),t.AUDIO_DESCRIPTION=new t("audioDescription"),t.CAPTIONS=new t("captions"),t.CLOSED_CAPTIONS=new t("closedCaptions"),t.DESCRIBED_MATH=new t("describedMath"),t.LONG_DESCRIPTION=new t("longDescription"),t.OPEN_CAPTIONS=new t("openCaptions"),t.SIGN_LANGUAGE=new t("signLanguage"),t.TRANSCRIPT=new t("transcript"),t.DISPLAY_TRANSFORMABILITY=new t("displayTransformability"),t.SYNCHRONIZED_AUDIO_TEXT=new t("synchronizedAudioText"),t.TIMING_CONTROL=new t("timingControl"),t.UNLOCKED=new t("unlocked"),t.CHEM_ML=new t("ChemML"),t.LATEX=new t("latex"),t.LATEX_CHEMISTRY=new t("latex-chemistry"),t.MATH_ML=new t("MathML"),t.MATH_ML_CHEMISTRY=new t("MathML-chemistry"),t.TTS_MARKUP=new t("ttsMarkup"),t.HIGH_CONTRAST_AUDIO=new t("highContrastAudio"),t.HIGH_CONTRAST_DISPLAY=new t("highContrastDisplay"),t.LARGE_PRINT=new t("largePrint"),t.BRAILLE=new t("braille"),t.TACTILE_GRAPHIC=new t("tactileGraphic"),t.TACTILE_OBJECT=new t("tactileObject"),t.FULL_RUBY_ANNOTATIONS=new t("fullRubyAnnotations"),t.HORIZONTAL_WRITING=new t("horizontalWriting"),t.RUBY_ANNOTATIONS=new t("rubyAnnotations"),t.VERTICAL_WRITING=new t("verticalWriting"),t.WITH_ADDITIONAL_WORD_SEGMENTATION=new t("withAdditionalWordSegmentation"),t.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new t("withoutAdditionalWordSegmentation");let T=t;const h=class h{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new h(i)}serialize(){return this.value}};h.FLASHING=new h("flashing"),h.NO_FLASHING_HAZARD=new h("noFlashingHazard"),h.UNKNOWN_FLASHING_HAZARD=new h("unknownFlashingHazard"),h.MOTION_SIMULATION=new h("motionSimulation"),h.NO_MOTION_SIMULATION_HAZARD=new h("noMotionSimulationHazard"),h.UNKNOWN_MOTION_SIMULATION_HAZARD=new h("unknownMotionSimulationHazard"),h.SOUND=new h("sound"),h.NO_SOUND_HAZARD=new h("noSoundHazard"),h.UNKNOWN_SOUND_HAZARD=new h("unknownSoundHazard"),h.UNKNOWN=new h("unknown"),h.NONE=new h("none");let l=h;const A=class A{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new A(i)}serialize(){return this.value}};A.NONE=new A("none"),A.DOCUMENTED=new A("documented"),A.LEGAL=new A("legal"),A.TEMPORARY=new A("temporary"),A.TECHNICAL=new A("technical"),A.EAA_DISPROPORTIONATE_BURDEN=new A("eaa-disproportionate-burden"),A.EAA_FUNDAMENTAL_ALTERATION=new A("eaa-fundamental-alteration"),A.EAA_MICROENTERPRISE=new A("eaa-microenterprise"),A.EAA_TECHNICAL_IMPOSSIBILITY=new A("eaa-technical-impossibility"),A.EAA_TEMPORARY=new A("eaa-temporary");let N=A;export{w as AccessMode,O as Accessibility,c as AccessibilityProfile,I as Certification,N as Exemption,T as Feature,l as Hazard,o as PrimaryAccessMode};
1
+ import{arrayfromJSONorString as w,arrayfromJSON as R}from"../../util/JSONParse.js";class p{constructor(i={}){this.conformsTo=i.conformsTo??[],this.certification=i.certification??null,this.summary=i.summary??null,this.accessMode=i.accessMode??[],this.accessModeSufficient=i.accessModeSufficient??[],this.feature=i.feature??[],this.hazard=i.hazard??[],this.exemption=i.exemption??[]}static deserialize(i){if(!i||typeof i!="object")return;const a=i,c=w(a.conformsTo),u=w(a.accessMode),E=R(a.accessModeSufficient),d=w(a.feature),C=w(a.hazard),S=w(a.exemption);return new p({conformsTo:c?c.map(h=>o.deserialize(h)).filter(h=>h!==void 0):void 0,certification:a.certification?f.deserialize(a.certification):void 0,summary:a.summary,accessMode:u?u.map(h=>T.deserialize(h)).filter(h=>h!==void 0):void 0,accessModeSufficient:E?E.map(h=>l.deserialize(h)).filter(h=>h!==void 0):void 0,feature:d?d.map(h=>N.deserialize(h)).filter(h=>h!==void 0):void 0,hazard:C?C.map(h=>I.deserialize(h)).filter(h=>h!==void 0):void 0,exemption:S?S.map(h=>O.deserialize(h)).filter(h=>h!==void 0):void 0})}serialize(){const i={};return this.conformsTo?.length>0&&(i.conformsTo=this.conformsTo.map(a=>a.serialize())),this.certification!==void 0&&this.certification!==null&&(i.certification=this.certification.serialize()),this.summary!==void 0&&this.summary!==null&&(i.summary=this.summary),this.accessMode?.length>0&&(i.accessMode=this.accessMode.map(a=>a.serialize())),this.accessModeSufficient?.length>0&&(i.accessModeSufficient=this.accessModeSufficient.map(a=>a.serialize())),this.feature?.length>0&&(i.feature=this.feature.map(a=>a.serialize())),this.hazard?.length>0&&(i.hazard=this.hazard.map(a=>a.serialize())),this.exemption?.length>0&&(i.exemption=this.exemption.map(a=>a.serialize())),i}}const s=class s{constructor(i){this.uri=i}static deserialize(i){if(!(!i||typeof i!="string"))return new s(i)}serialize(){return this.uri}get isWCAGLevelA(){return this===s.EPUB_A11Y_10_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_21_A||this===s.EPUB_A11Y_11_WCAG_22_A}get isWCAGLevelAA(){return this===s.EPUB_A11Y_10_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_21_AA||this===s.EPUB_A11Y_11_WCAG_22_AA}get isWCAGLevelAAA(){return this===s.EPUB_A11Y_10_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_21_AAA||this===s.EPUB_A11Y_11_WCAG_22_AAA}};s.EPUB_A11Y_10_WCAG_20_A=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"),s.EPUB_A11Y_10_WCAG_20_AA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"),s.EPUB_A11Y_10_WCAG_20_AAA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"),s.EPUB_A11Y_11_WCAG_20_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"),s.EPUB_A11Y_11_WCAG_20_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"),s.EPUB_A11Y_11_WCAG_20_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"),s.EPUB_A11Y_11_WCAG_21_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"),s.EPUB_A11Y_11_WCAG_21_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"),s.EPUB_A11Y_11_WCAG_21_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"),s.EPUB_A11Y_11_WCAG_22_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"),s.EPUB_A11Y_11_WCAG_22_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"),s.EPUB_A11Y_11_WCAG_22_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");let o=s;class f{constructor(i=null,a=null,c=null){this.certifiedBy=i,this.credential=a,this.report=c}static deserialize(i){if(!(!i||typeof i!="object"))return new f(i.certifiedBy,i.credential,i.report)}serialize(){const i={};return this.certifiedBy&&(i.certifiedBy=this.certifiedBy),this.credential&&(i.credential=this.credential),this.report&&(i.report=this.report),i}}const e=class e{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new e(i)}serialize(){return this.value}};e.AUDITORY=new e("auditory"),e.CHART_ON_VISUAL=new e("chartOnVisual"),e.CHEM_ON_VISUAL=new e("chemOnVisual"),e.COLOR_DEPENDENT=new e("colorDependent"),e.DIAGRAM_ON_VISUAL=new e("diagramOnVisual"),e.MATH_ON_VISUAL=new e("mathOnVisual"),e.MUSIC_ON_VISUAL=new e("musicOnVisual"),e.TACTILE=new e("tactile"),e.TEXT_ON_VISUAL=new e("textOnVisual"),e.TEXTUAL=new e("textual"),e.VISUAL=new e("visual");let T=e;const A=class A{constructor(i){if(typeof i=="string"){if(!A.VALID_MODES.has(i.toLowerCase()))return;this.value=i.toLowerCase()}else{const a=i.filter(c=>A.VALID_MODES.has(c.toLowerCase()));if(a.length===0)return;this.value=Array.from(new Set(a))}}static deserialize(i){if(!i)return;if(typeof i=="string")return A.VALID_MODES.has(i.toLowerCase())?new A(i):void 0;if(!Array.isArray(i))return;const a=i.filter(c=>c?A.VALID_MODES.has(c.toLowerCase()):!1);if(a.length!==0)return new A(a)}serialize(){return this.value}};A.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),A.AUDITORY=new A("auditory"),A.TACTILE=new A("tactile"),A.TEXTUAL=new A("textual"),A.VISUAL=new A("visual");let l=A;const t=class t{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new t(i)}serialize(){return this.value}};t.NONE=new t("none"),t.ANNOTATIONS=new t("annotations"),t.ARIA=new t("ARIA"),t.INDEX=new t("index"),t.PAGE_BREAK_MARKERS=new t("pageBreakMarkers"),t.PAGE_NAVIGATION=new t("pageNavigation"),t.PRINT_PAGE_NUMBERS=new t("printPageNumbers"),t.READING_ORDER=new t("readingOrder"),t.STRUCTURAL_NAVIGATION=new t("structuralNavigation"),t.TABLE_OF_CONTENTS=new t("tableOfContents"),t.TAGGED_PDF=new t("taggedPDF"),t.ALTERNATIVE_TEXT=new t("alternativeText"),t.AUDIO_DESCRIPTION=new t("audioDescription"),t.CAPTIONS=new t("captions"),t.CLOSED_CAPTIONS=new t("closedCaptions"),t.DESCRIBED_MATH=new t("describedMath"),t.LONG_DESCRIPTION=new t("longDescription"),t.OPEN_CAPTIONS=new t("openCaptions"),t.SIGN_LANGUAGE=new t("signLanguage"),t.TRANSCRIPT=new t("transcript"),t.DISPLAY_TRANSFORMABILITY=new t("displayTransformability"),t.SYNCHRONIZED_AUDIO_TEXT=new t("synchronizedAudioText"),t.TIMING_CONTROL=new t("timingControl"),t.UNLOCKED=new t("unlocked"),t.CHEM_ML=new t("ChemML"),t.LATEX=new t("latex"),t.LATEX_CHEMISTRY=new t("latex-chemistry"),t.MATH_ML=new t("MathML"),t.MATH_ML_CHEMISTRY=new t("MathML-chemistry"),t.TTS_MARKUP=new t("ttsMarkup"),t.HIGH_CONTRAST_AUDIO=new t("highContrastAudio"),t.HIGH_CONTRAST_DISPLAY=new t("highContrastDisplay"),t.LARGE_PRINT=new t("largePrint"),t.BRAILLE=new t("braille"),t.TACTILE_GRAPHIC=new t("tactileGraphic"),t.TACTILE_OBJECT=new t("tactileObject"),t.FULL_RUBY_ANNOTATIONS=new t("fullRubyAnnotations"),t.HORIZONTAL_WRITING=new t("horizontalWriting"),t.RUBY_ANNOTATIONS=new t("rubyAnnotations"),t.VERTICAL_WRITING=new t("verticalWriting"),t.WITH_ADDITIONAL_WORD_SEGMENTATION=new t("withAdditionalWordSegmentation"),t.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new t("withoutAdditionalWordSegmentation");let N=t;const n=class n{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new n(i)}serialize(){return this.value}};n.FLASHING=new n("flashing"),n.NO_FLASHING_HAZARD=new n("noFlashingHazard"),n.UNKNOWN_FLASHING_HAZARD=new n("unknownFlashingHazard"),n.MOTION_SIMULATION=new n("motionSimulation"),n.NO_MOTION_SIMULATION_HAZARD=new n("noMotionSimulationHazard"),n.UNKNOWN_MOTION_SIMULATION_HAZARD=new n("unknownMotionSimulationHazard"),n.SOUND=new n("sound"),n.NO_SOUND_HAZARD=new n("noSoundHazard"),n.UNKNOWN_SOUND_HAZARD=new n("unknownSoundHazard"),n.UNKNOWN=new n("unknown"),n.NONE=new n("none");let I=n;const r=class r{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new r(i)}serialize(){return this.value}};r.NONE=new r("none"),r.DOCUMENTED=new r("documented"),r.LEGAL=new r("legal"),r.TEMPORARY=new r("temporary"),r.TECHNICAL=new r("technical"),r.EAA_DISPROPORTIONATE_BURDEN=new r("eaa-disproportionate-burden"),r.EAA_FUNDAMENTAL_ALTERATION=new r("eaa-fundamental-alteration"),r.EAA_MICROENTERPRISE=new r("eaa-microenterprise"),r.EAA_TECHNICAL_IMPOSSIBILITY=new r("eaa-technical-impossibility"),r.EAA_TEMPORARY=new r("eaa-temporary");let O=r;export{T as AccessMode,p as Accessibility,o as AccessibilityProfile,f as Certification,O as Exemption,N as Feature,I as Hazard,l as PrimaryAccessMode};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/shared",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "type": "module",
5
5
  "description": "Shared models to be used across other Readium projects and implementations in Typescript",
6
6
  "author": "readium",
@@ -3,6 +3,8 @@
3
3
  * available in the LICENSE file present in the Github repository of the project.
4
4
  */
5
5
 
6
+ import { arrayfromJSON, arrayfromJSONorString } from '../../util/JSONParse.ts';
7
+
6
8
  /**
7
9
  * Holds the accessibility metadata of a Publication.
8
10
  *
@@ -77,49 +79,57 @@ export class Accessibility {
77
79
  if (!json || typeof json !== 'object') return;
78
80
 
79
81
  type AccessibilityJson = {
80
- conformsTo?: string[];
82
+ conformsTo?: string | string[];
81
83
  certification?: {
82
84
  certifiedBy: string;
83
85
  credential: string;
84
86
  report: string;
85
87
  };
86
88
  summary?: string;
87
- accessMode?: string[];
88
- accessModeSufficient?: string[][];
89
- feature?: string[];
90
- hazard?: string[];
91
- exemption?: string[];
89
+ accessMode?: string | string[];
90
+ accessModeSufficient?: (string | string[])[];
91
+ feature?: string | string[];
92
+ hazard?: string | string[];
93
+ exemption?: string | string[];
92
94
  };
93
95
 
94
96
  const accessibilityJson = json as AccessibilityJson;
95
97
 
98
+ // Per the RWPM a11y schema, these fields may be a bare string or an array of strings.
99
+ const conformsTo = arrayfromJSONorString(accessibilityJson.conformsTo);
100
+ const accessMode = arrayfromJSONorString(accessibilityJson.accessMode);
101
+ const accessModeSufficient = arrayfromJSON(accessibilityJson.accessModeSufficient);
102
+ const feature = arrayfromJSONorString(accessibilityJson.feature);
103
+ const hazard = arrayfromJSONorString(accessibilityJson.hazard);
104
+ const exemption = arrayfromJSONorString(accessibilityJson.exemption);
105
+
96
106
  return new Accessibility({
97
- conformsTo: accessibilityJson.conformsTo
98
- ? accessibilityJson.conformsTo.map(uri => AccessibilityProfile.deserialize(uri))
107
+ conformsTo: conformsTo
108
+ ? conformsTo.map(uri => AccessibilityProfile.deserialize(uri))
99
109
  .filter((profile): profile is AccessibilityProfile => profile !== undefined)
100
110
  : undefined,
101
- certification: accessibilityJson.certification
111
+ certification: accessibilityJson.certification
102
112
  ? Certification.deserialize(accessibilityJson.certification)
103
113
  : undefined,
104
114
  summary: accessibilityJson.summary,
105
- accessMode: accessibilityJson.accessMode
106
- ? accessibilityJson.accessMode.map(value => AccessMode.deserialize(value))
115
+ accessMode: accessMode
116
+ ? accessMode.map(value => AccessMode.deserialize(value))
107
117
  .filter((mode): mode is AccessMode => mode !== undefined)
108
118
  : undefined,
109
- accessModeSufficient: accessibilityJson.accessModeSufficient
110
- ? accessibilityJson.accessModeSufficient.map(modes => PrimaryAccessMode.deserialize(modes))
111
- .filter((mode): mode is PrimaryAccessMode => mode !== undefined)
119
+ accessModeSufficient: accessModeSufficient
120
+ ? accessModeSufficient.map(modes => PrimaryAccessMode.deserialize(modes))
121
+ .filter((mode): mode is PrimaryAccessMode => mode !== undefined)
112
122
  : undefined,
113
- feature: accessibilityJson.feature
114
- ? accessibilityJson.feature.map(value => Feature.deserialize(value))
123
+ feature: feature
124
+ ? feature.map(value => Feature.deserialize(value))
115
125
  .filter((feature): feature is Feature => feature !== undefined)
116
126
  : undefined,
117
- hazard: accessibilityJson.hazard
118
- ? accessibilityJson.hazard.map(value => Hazard.deserialize(value))
127
+ hazard: hazard
128
+ ? hazard.map(value => Hazard.deserialize(value))
119
129
  .filter((hazard): hazard is Hazard => hazard !== undefined)
120
130
  : undefined,
121
- exemption: accessibilityJson.exemption
122
- ? accessibilityJson.exemption.map(value => Exemption.deserialize(value))
131
+ exemption: exemption
132
+ ? exemption.map(value => Exemption.deserialize(value))
123
133
  .filter((exemption): exemption is Exemption => exemption !== undefined)
124
134
  : undefined
125
135
  });
@@ -427,6 +437,9 @@ export class PrimaryAccessMode {
427
437
  if (!json) return;
428
438
 
429
439
  if (typeof json === 'string') {
440
+ if (!PrimaryAccessMode.VALID_MODES.has(json.toLowerCase())) {
441
+ return undefined;
442
+ }
430
443
  return new PrimaryAccessMode(json);
431
444
  }
432
445