@readium/shared 2.4.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.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{EmptyFetcher as o}from"./fetcher/Fetcher.js";import{HttpFetcher as i,HttpResource as a}from"./fetcher/HttpFetcher.js";import{NumberRange as n,Resource as p}from"./fetcher/Resource.js";import{AccessMode as x,Accessibility as l,AccessibilityProfile as s,Certification as g,Exemption as c,Feature as d,Hazard as u,PrimaryAccessMode as T}from"./publication/accessibility/Accessibility.js";import{AccessibilityMetadataDisplayGuide as y,AccessibilitySummary as C,AdditionalInformation as A,Conformance as P,HazardType as L,Hazards as N,Legal as S,Navigation as I,NonvisualReading as O,PrerecordedAudio as R,RichContent as v,RichContentType as E,VisualAdjustments as H,WaysOfReading as M}from"./publication/accessibility/AccessibilityMetadataDisplayGuide.js";import{Localization as k}from"./publication/accessibility/Localization.js";import{Encryption as F}from"./publication/encryption/Encryption.js";import{getEncryption as J}from"./publication/encryption/Properties.js";import{MediaOverlay as G}from"./publication/epub/MediaOverlay.js";import{getMediaOverlay as q}from"./publication/epub/Metadata.js";import{getContains as U}from"./publication/epub/Properties.js";import{getLandmarks as Q,getListOfAudioClips as W,getListOfIllustrations as w,getListOfTables as X,getListOfVideoClips as Y,getPageList as Z}from"./publication/epub/Publication.js";import{DomRange as $}from"./publication/html/DomRange.js";import{DomRangePoint as te}from"./publication/html/DomRangePoint.js";import{getCssSelector as re,getDomRange as ie,getFragmentParameters as ae,getHtmlId as me,getPage as ne,getPartialCfi as pe,getSpace as fe,getTime as xe}from"./publication/html/Locations.js";import{getAuthenticate as se,getAvailability as ge,getCopies as ce,getHolds as de,getIndirectAcquisitions as ue,getNumberOfItems as Te,getPrice as be}from"./publication/opds/Properties.js";import{getImages as Ce}from"./publication/opds/Publication.js";import{buildHtmlTimeline as Pe}from"./publication/services/timeline/html.js";import{buildAudioTimeline as Ne}from"./publication/services/timeline/audio.js";import{Timeline as Ie}from"./publication/services/timeline/Timeline.js";import{buildTimeline as Re}from"./publication/services/timeline/index.js";import{Content as Ee}from"./publication/services/content/Content.js";import{TextContentTokenizer as Me}from"./publication/services/content/ContentTokenizer.js";import{IllegalStateError as ke,Iterator as ze}from"./publication/services/content/Iterator.js";import{AudioElement as he,ContentElement as Je,ImageElement as je,TextElement as Ge,TextSegment as Ve,TextualElement as qe,VideoElement as Be}from"./publication/services/content/element/element.js";import{Attribute as Ke,AttributeKeys as Qe,AttributesHolder as We}from"./publication/services/content/element/attributes.js";import{Body as Xe,Footnote as Ye,Heading as Ze,TextQuote as _e}from"./publication/services/content/element/text_role.js";import{PublicationContentIterator as et}from"./publication/services/content/iterators/PublicationContentIterator.js";import{PDFContentElement as ot,PageContentIteratorPDF as rt}from"./publication/services/content/iterators/PDFTextContentIterator.js";import{HTMLResourceContentIterator as at}from"./publication/services/content/iterators/HTMLResourceContentIterator.js";import{AltIdentifier as nt}from"./publication/AltIdentifier.js";import{BelongsTo as ft}from"./publication/BelongsTo.js";import{Contributor as lt,Contributors as st}from"./publication/Contributor.js";import{Link as ct,Links as dt}from"./publication/Link.js";import{LocalizedString as Tt}from"./publication/LocalizedString.js";import{Locator as yt,LocatorLocations as Ct,LocatorText as At}from"./publication/Locator.js";import{LocatorCollection as Lt,LocatorCollectionMetadata as Nt}from"./publication/LocatorCollection.js";import{Manifest as It}from"./publication/Manifest.js";import{Metadata as Rt}from"./publication/Metadata.js";import{Profile as Et}from"./publication/Profiles.js";import{Page as Mt,Properties as Dt}from"./publication/Properties.js";import{Publication as zt}from"./publication/Publication.js";import{PublicationCollection as ht}from"./publication/PublicationCollection.js";import{Layout as jt}from"./publication/Layout.js";import{ReadingProgression as Vt,leadingPage as qt}from"./publication/ReadingProgression.js";import{Subject as Ut,Subjects as Kt}from"./publication/Subject.js";import{TDM as Wt,TDMReservation as wt}from"./publication/TDM.js";import{GuidedNavigationDocument as Yt,GuidedNavigationObject as Zt,GuidedNavigationText as _t}from"./publication/GuidedNavigation.js";import{Price as eo}from"./opds/Price.js";import{Acquisition as oo}from"./opds/Acquisition.js";import{Holds as io}from"./opds/Holds.js";import{Copies as mo}from"./opds/Copies.js";import{Availability as po,AvailabilityStatus as fo}from"./opds/Availability.js";import{MediaType as lo}from"./util/mediatype/MediaType.js";import{arrayfromJSON as go,arrayfromJSONorString as co,datefromJSON as uo,numberfromJSON as To,positiveNumberfromJSON as bo,setToArray as yo}from"./util/JSONParse.js";import{formatNptTime as Ao,isNptStartOfResource as Po,parseNptTime as Lo}from"./util/npt.js";import{URITemplate as So}from"./util/URITemplate.js";import{DefaultTextContentTokenizer as Oo,IntlTextTokenizer as Ro,NaiveTextTokenizer as vo,TextUnit as Eo,speakableToken as Ho}from"./util/tokenizer/TextTokenizer.js";export{x as AccessMode,l as Accessibility,y as AccessibilityMetadataDisplayGuide,s as AccessibilityProfile,C as AccessibilitySummary,oo as Acquisition,A as AdditionalInformation,nt as AltIdentifier,Ke as Attribute,Qe as AttributeKeys,We as AttributesHolder,he as AudioElement,po as Availability,fo as AvailabilityStatus,ft as BelongsTo,Xe as Body,g as Certification,P as Conformance,Ee as Content,Je as ContentElement,lt as Contributor,st as Contributors,mo as Copies,Oo as DefaultTextContentTokenizer,$ as DomRange,te as DomRangePoint,o as EmptyFetcher,F as Encryption,c as Exemption,d as Feature,Ye as Footnote,Yt as GuidedNavigationDocument,Zt as GuidedNavigationObject,_t as GuidedNavigationText,at as HTMLResourceContentIterator,u as Hazard,L as HazardType,N as Hazards,Ze as Heading,io as Holds,i as HttpFetcher,a as HttpResource,ke as IllegalStateError,je as ImageElement,Ro as IntlTextTokenizer,ze as Iterator,jt as Layout,S as Legal,ct as Link,dt as Links,k as Localization,Tt as LocalizedString,yt as Locator,Lt as LocatorCollection,Nt as LocatorCollectionMetadata,Ct as LocatorLocations,At as LocatorText,It as Manifest,G as MediaOverlay,lo as MediaType,Rt as Metadata,vo as NaiveTextTokenizer,I as Navigation,O as NonvisualReading,n as NumberRange,ot as PDFContentElement,Mt as Page,rt as PageContentIteratorPDF,R as PrerecordedAudio,eo as Price,T as PrimaryAccessMode,Et as Profile,Dt as Properties,zt as Publication,ht as PublicationCollection,et as PublicationContentIterator,Vt as ReadingProgression,p as Resource,v as RichContent,E as RichContentType,Ut as Subject,Kt as Subjects,Wt as TDM,wt as TDMReservation,Me as TextContentTokenizer,Ge as TextElement,_e as TextQuote,Ve as TextSegment,Eo as TextUnit,qe as TextualElement,Ie as Timeline,So as URITemplate,Be as VideoElement,H as VisualAdjustments,M as WaysOfReading,go as arrayfromJSON,co as arrayfromJSONorString,Ne as buildAudioTimeline,Pe as buildHtmlTimeline,Re as buildTimeline,uo as datefromJSON,Ao as formatNptTime,se as getAuthenticate,ge as getAvailability,U as getContains,ce as getCopies,re as getCssSelector,ie as getDomRange,J as getEncryption,ae as getFragmentParameters,de as getHolds,me as getHtmlId,Ce as getImages,ue as getIndirectAcquisitions,Q as getLandmarks,W as getListOfAudioClips,w as getListOfIllustrations,X as getListOfTables,Y as getListOfVideoClips,q as getMediaOverlay,Te as getNumberOfItems,ne as getPage,Z as getPageList,pe as getPartialCfi,be as getPrice,fe as getSpace,xe as getTime,Po as isNptStartOfResource,qt as leadingPage,To as numberfromJSON,Lo as parseNptTime,bo as positiveNumberfromJSON,yo as setToArray,Ho as speakableToken};
1
+ import{EmptyFetcher as o}from"./fetcher/Fetcher.js";import{HttpFetcher as i,HttpResource as a}from"./fetcher/HttpFetcher.js";import{NumberRange as n,Resource as p}from"./fetcher/Resource.js";import{AccessMode as x,Accessibility as l,AccessibilityProfile as s,Certification as g,Exemption as c,Feature as d,Hazard as u,PrimaryAccessMode as T}from"./publication/accessibility/Accessibility.js";import{AccessibilityMetadataDisplayGuide as y,AccessibilitySummary as C,AdditionalInformation as A,Conformance as P,HazardType as L,Hazards as N,Legal as S,Navigation as I,NonvisualReading as O,PrerecordedAudio as R,RichContent as v,RichContentType as E,VisualAdjustments as H,WaysOfReading as M}from"./publication/accessibility/AccessibilityMetadataDisplayGuide.js";import{Localization as k}from"./publication/accessibility/Localization.js";import{Encryption as F}from"./publication/encryption/Encryption.js";import{getEncryption as J}from"./publication/encryption/Properties.js";import{MediaOverlay as G}from"./publication/epub/MediaOverlay.js";import{getMediaOverlay as q}from"./publication/epub/Metadata.js";import{getContains as U}from"./publication/epub/Properties.js";import{getLandmarks as Q,getListOfAudioClips as W,getListOfIllustrations as w,getListOfTables as X,getListOfVideoClips as Y,getPageList as Z}from"./publication/epub/Publication.js";import{DomRange as $}from"./publication/html/DomRange.js";import{DomRangePoint as te}from"./publication/html/DomRangePoint.js";import{getCssSelector as re,getDomRange as ie,getFragmentParameters as ae,getHtmlId as me,getPage as ne,getPartialCfi as pe,getSpace as fe,getTextFragment as xe,getTime as le}from"./publication/html/Locations.js";import{getAuthenticate as ge,getAvailability as ce,getCopies as de,getHolds as ue,getIndirectAcquisitions as Te,getNumberOfItems as be,getPrice as ye}from"./publication/opds/Properties.js";import{getImages as Ae}from"./publication/opds/Publication.js";import{buildHtmlTimeline as Le}from"./publication/services/timeline/html.js";import{buildAudioTimeline as Se}from"./publication/services/timeline/audio.js";import{Timeline as Oe}from"./publication/services/timeline/Timeline.js";import{buildTimeline as ve}from"./publication/services/timeline/index.js";import{Content as He}from"./publication/services/content/Content.js";import{TextContentTokenizer as De}from"./publication/services/content/ContentTokenizer.js";import{IllegalStateError as ze,Iterator as Fe}from"./publication/services/content/Iterator.js";import{AudioElement as Je,ContentElement as je,ImageElement as Ge,TextElement as Ve,TextSegment as qe,TextualElement as Be,VideoElement as Ue}from"./publication/services/content/element/element.js";import{Attribute as Qe,AttributeKeys as We,AttributesHolder as we}from"./publication/services/content/element/attributes.js";import{Body as Ye,Footnote as Ze,Heading as _e,TextQuote as $e}from"./publication/services/content/element/text_role.js";import{PublicationContentIterator as tt}from"./publication/services/content/iterators/PublicationContentIterator.js";import{PDFContentElement as rt,PageContentIteratorPDF as it}from"./publication/services/content/iterators/PDFTextContentIterator.js";import{HTMLResourceContentIterator as mt}from"./publication/services/content/iterators/HTMLResourceContentIterator.js";import{AltIdentifier as pt}from"./publication/AltIdentifier.js";import{BelongsTo as xt}from"./publication/BelongsTo.js";import{Contributor as st,Contributors as gt}from"./publication/Contributor.js";import{Link as dt,Links as ut}from"./publication/Link.js";import{LocalizedString as bt}from"./publication/LocalizedString.js";import{Locator as Ct,LocatorLocations as At,LocatorText as Pt}from"./publication/Locator.js";import{LocatorCollection as Nt,LocatorCollectionMetadata as St}from"./publication/LocatorCollection.js";import{Manifest as Ot}from"./publication/Manifest.js";import{Metadata as vt}from"./publication/Metadata.js";import{Profile as Ht}from"./publication/Profiles.js";import{Page as Dt,Properties as kt}from"./publication/Properties.js";import{Publication as Ft}from"./publication/Publication.js";import{PublicationCollection as Jt}from"./publication/PublicationCollection.js";import{Layout as Gt}from"./publication/Layout.js";import{ReadingProgression as qt,leadingPage as Bt}from"./publication/ReadingProgression.js";import{Subject as Kt,Subjects as Qt}from"./publication/Subject.js";import{TDM as wt,TDMReservation as Xt}from"./publication/TDM.js";import{GuidedNavigationDocument as Zt,GuidedNavigationObject as _t,GuidedNavigationText as $t}from"./publication/GuidedNavigation.js";import{Price as to}from"./opds/Price.js";import{Acquisition as ro}from"./opds/Acquisition.js";import{Holds as ao}from"./opds/Holds.js";import{Copies as no}from"./opds/Copies.js";import{Availability as fo,AvailabilityStatus as xo}from"./opds/Availability.js";import{MediaType as so}from"./util/mediatype/MediaType.js";import{arrayfromJSON as co,arrayfromJSONorString as uo,datefromJSON as To,numberfromJSON as bo,positiveNumberfromJSON as yo,setToArray as Co}from"./util/JSONParse.js";import{formatNptTime as Po,isNptStartOfResource as Lo,parseNptTime as No}from"./util/npt.js";import{URITemplate as Io}from"./util/URITemplate.js";import{DefaultTextContentTokenizer as Ro,IntlTextTokenizer as vo,NaiveTextTokenizer as Eo,TextUnit as Ho,speakableToken as Mo}from"./util/tokenizer/TextTokenizer.js";export{x as AccessMode,l as Accessibility,y as AccessibilityMetadataDisplayGuide,s as AccessibilityProfile,C as AccessibilitySummary,ro as Acquisition,A as AdditionalInformation,pt as AltIdentifier,Qe as Attribute,We as AttributeKeys,we as AttributesHolder,Je as AudioElement,fo as Availability,xo as AvailabilityStatus,xt as BelongsTo,Ye as Body,g as Certification,P as Conformance,He as Content,je as ContentElement,st as Contributor,gt as Contributors,no as Copies,Ro as DefaultTextContentTokenizer,$ as DomRange,te as DomRangePoint,o as EmptyFetcher,F as Encryption,c as Exemption,d as Feature,Ze as Footnote,Zt as GuidedNavigationDocument,_t as GuidedNavigationObject,$t as GuidedNavigationText,mt as HTMLResourceContentIterator,u as Hazard,L as HazardType,N as Hazards,_e as Heading,ao as Holds,i as HttpFetcher,a as HttpResource,ze as IllegalStateError,Ge as ImageElement,vo as IntlTextTokenizer,Fe as Iterator,Gt as Layout,S as Legal,dt as Link,ut as Links,k as Localization,bt as LocalizedString,Ct as Locator,Nt as LocatorCollection,St as LocatorCollectionMetadata,At as LocatorLocations,Pt as LocatorText,Ot as Manifest,G as MediaOverlay,so as MediaType,vt as Metadata,Eo as NaiveTextTokenizer,I as Navigation,O as NonvisualReading,n as NumberRange,rt as PDFContentElement,Dt as Page,it as PageContentIteratorPDF,R as PrerecordedAudio,to as Price,T as PrimaryAccessMode,Ht as Profile,kt as Properties,Ft as Publication,Jt as PublicationCollection,tt as PublicationContentIterator,qt as ReadingProgression,p as Resource,v as RichContent,E as RichContentType,Kt as Subject,Qt as Subjects,wt as TDM,Xt as TDMReservation,De as TextContentTokenizer,Ve as TextElement,$e as TextQuote,qe as TextSegment,Ho as TextUnit,Be as TextualElement,Oe as Timeline,Io as URITemplate,Ue as VideoElement,H as VisualAdjustments,M as WaysOfReading,co as arrayfromJSON,uo as arrayfromJSONorString,Se as buildAudioTimeline,Le as buildHtmlTimeline,ve as buildTimeline,To as datefromJSON,Po as formatNptTime,ge as getAuthenticate,ce as getAvailability,U as getContains,de as getCopies,re as getCssSelector,ie as getDomRange,J as getEncryption,ae as getFragmentParameters,ue as getHolds,me as getHtmlId,Ae as getImages,Te as getIndirectAcquisitions,Q as getLandmarks,W as getListOfAudioClips,w as getListOfIllustrations,X as getListOfTables,Y as getListOfVideoClips,q as getMediaOverlay,be as getNumberOfItems,ne as getPage,Z as getPageList,pe as getPartialCfi,ye as getPrice,fe as getSpace,xe as getTextFragment,le as getTime,Lo as isNptStartOfResource,Bt as leadingPage,bo as numberfromJSON,No as parseNptTime,yo as positiveNumberfromJSON,Co as setToArray,Mo as speakableToken};
@@ -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};
@@ -1 +1 @@
1
- import{DomRange as u}from"./DomRange.js";import{parseNptTime as h}from"../../util/npt.js";function x(e){return e.otherLocations?.get("cssSelector")}function C(e){return e.otherLocations?.get("partialCfi")}function L(e){return u.deserialize(e.otherLocations?.get("domRange"))}function n(e){return new Map(e.fragments.map(t=>t.startsWith("#")?t.slice(1):t).join("&").split("&").filter(t=>!t.startsWith("#")).map(t=>t.split("=")).filter(t=>t.length===2).map(t=>[t[0].trim().toLowerCase(),t[1].trim()]))}function N(e){if(!e.fragments.length)return;let t=e.fragments.find(r=>r.length&&!r.includes("="));if(!t){const r=n(e);r.has("id")?t=r.get("id"):r.has("name")&&(t=r.get("name"))}return t?.startsWith("#")?t.slice(1):t}function W(e){const t=parseInt(n(e).get("page"));if(!isNaN(t)&&t>=0)return t}function R(e){const t=n(e).get("t");if(t)return h(t)}function y(e){const t=n(e);if(!t.has("xywh"))return;const r=t.get("xywh");let i="pixel",s=r;const o=r.toLowerCase();o.startsWith("pixel:")?s=r.slice(6):o.startsWith("percent:")&&(i="percent",s=r.slice(8));const c=i==="percent"?parseFloat:m=>parseInt(m,10),a=s.split(",").map(c);if(a.length!==4||a.some(isNaN))return;const[g,p,f,l]=a;return{unit:i,x:g,y:p,width:f,height:l}}export{x as getCssSelector,L as getDomRange,n as getFragmentParameters,N as getHtmlId,W as getPage,C as getPartialCfi,y as getSpace,R as getTime};
1
+ import{DomRange as u}from"./DomRange.js";import{parseNptTime as h}from"../../util/npt.js";import{decodeTextFragmentDirective as d}from"@readium/helpers";function C(e){return e.otherLocations?.get("cssSelector")}function L(e){return e.otherLocations?.get("partialCfi")}function N(e){return u.deserialize(e.otherLocations?.get("domRange"))}function W(e){for(const t of e.fragments){const r=d(t);if(r)return r}}function n(e){return new Map(e.fragments.map(t=>t.startsWith("#")?t.slice(1):t).join("&").split("&").filter(t=>!t.startsWith("#")).map(t=>t.split("=")).filter(t=>t.length===2).map(t=>[t[0].trim().toLowerCase(),t[1].trim()]))}function F(e){if(!e.fragments.length)return;let t=e.fragments.find(r=>r.length&&!r.includes("="));if(!t){const r=n(e);r.has("id")?t=r.get("id"):r.has("name")&&(t=r.get("name"))}return t?.startsWith("#")?t.slice(1):t}function R(e){const t=parseInt(n(e).get("page"));if(!isNaN(t)&&t>=0)return t}function T(e){const t=n(e).get("t");if(t)return h(t)}function y(e){const t=n(e);if(!t.has("xywh"))return;const r=t.get("xywh");let i="pixel",s=r;const a=r.toLowerCase();a.startsWith("pixel:")?s=r.slice(6):a.startsWith("percent:")&&(i="percent",s=r.slice(8));const c=i==="percent"?parseFloat:l=>parseInt(l,10),o=s.split(",").map(c);if(o.length!==4||o.some(isNaN))return;const[g,f,m,p]=o;return{unit:i,x:g,y:f,width:m,height:p}}export{C as getCssSelector,N as getDomRange,n as getFragmentParameters,F as getHtmlId,R as getPage,L as getPartialCfi,y as getSpace,W as getTextFragment,T as getTime};
@@ -1 +1 @@
1
- import{DomRange as g}from"./DomRange.js";import{DomRangePoint as r}from"./DomRangePoint.js";import{getCssSelector as m,getDomRange as n,getFragmentParameters as f,getHtmlId as i,getPage as p,getPartialCfi as P,getSpace as l,getTime as s}from"./Locations.js";export{g as DomRange,r as DomRangePoint,m as getCssSelector,n as getDomRange,f as getFragmentParameters,i as getHtmlId,p as getPage,P as getPartialCfi,l as getSpace,s as getTime};
1
+ import{DomRange as g}from"./DomRange.js";import{DomRangePoint as a}from"./DomRangePoint.js";import{getCssSelector as o,getDomRange as n,getFragmentParameters as f,getHtmlId as i,getPage as p,getPartialCfi as x,getSpace as P,getTextFragment as l,getTime as s}from"./Locations.js";export{g as DomRange,a as DomRangePoint,o as getCssSelector,n as getDomRange,f as getFragmentParameters,i as getHtmlId,p as getPage,x as getPartialCfi,P as getSpace,l as getTextFragment,s as getTime};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/shared",
3
- "version": "2.4.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",
@@ -55,6 +55,9 @@
55
55
  }
56
56
  },
57
57
  "sideEffects": false,
58
+ "dependencies": {
59
+ "@readium/helpers": "1.1.0"
60
+ },
58
61
  "files": [
59
62
  "dist",
60
63
  "src",
@@ -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
 
@@ -1,6 +1,7 @@
1
1
  import { LocatorLocations } from '../Locator.ts';
2
2
  import { DomRange } from './DomRange.ts';
3
3
  import { parseNptTime } from '../../util/npt.ts';
4
+ import { decodeTextFragmentDirective, TextFragmentDirective } from '@readium/helpers';
4
5
 
5
6
  // HTML extensions for LocatorLocations.
6
7
  // https://github.com/readium/architecture/blob/master/models/locators/extensions/html.md
@@ -17,6 +18,16 @@ export function getDomRange(loc: LocatorLocations): DomRange | undefined {
17
18
  return DomRange.deserialize(loc.otherLocations?.get('domRange'));
18
19
  }
19
20
 
21
+ // A WICG text-fragment directive (":~:text=...") found among fragments, per
22
+ // https://wicg.github.io/scroll-to-text-fragment/.
23
+ export function getTextFragment(loc: LocatorLocations): TextFragmentDirective | undefined {
24
+ for (const fragment of loc.fragments) {
25
+ const directive = decodeTextFragmentDirective(fragment);
26
+ if (directive) return directive;
27
+ }
28
+ return undefined;
29
+ }
30
+
20
31
  export function getFragmentParameters(loc: LocatorLocations): Map<string, string> {
21
32
  return new Map(
22
33
  loc.fragments
@@ -1,8 +1,10 @@
1
1
  import { LocatorLocations } from '../Locator.ts';
2
2
  import { DomRange } from './DomRange.ts';
3
+ import { TextFragmentDirective } from '@readium/helpers';
3
4
  export declare function getCssSelector(loc: LocatorLocations): string | undefined;
4
5
  export declare function getPartialCfi(loc: LocatorLocations): string | undefined;
5
6
  export declare function getDomRange(loc: LocatorLocations): DomRange | undefined;
7
+ export declare function getTextFragment(loc: LocatorLocations): TextFragmentDirective | undefined;
6
8
  export declare function getFragmentParameters(loc: LocatorLocations): Map<string, string>;
7
9
  export declare function getHtmlId(loc: LocatorLocations): string | undefined;
8
10
  export declare function getPage(loc: LocatorLocations): number | undefined;