@readium/shared 2.4.0 → 2.5.0
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
|
|
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
|
-
import{DomRange as u}from"./DomRange.js";import{parseNptTime as h}from"../../util/npt.js";function
|
|
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
|
|
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.
|
|
3
|
+
"version": "2.5.0",
|
|
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",
|
|
@@ -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;
|