@readium/shared 2.3.0 → 2.4.0-alpha.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.
Files changed (167) hide show
  1. package/LICENSE +28 -0
  2. package/README.MD +7 -8
  3. package/dist/ar-DyHX_uy2.js +7 -0
  4. package/dist/da-Dct0PS3E.js +7 -0
  5. package/dist/fr-C5HEel98.js +7 -0
  6. package/dist/index.js +4993 -1
  7. package/dist/index.umd.cjs +3 -0
  8. package/dist/it-DFOBoXGy.js +7 -0
  9. package/dist/pt_PT-Di3sVjze.js +7 -0
  10. package/dist/sv-BfzAFsVN.js +7 -0
  11. package/package.json +26 -33
  12. package/src/fetcher/HttpFetcher.ts +5 -5
  13. package/src/fetcher/Resource.ts +10 -5
  14. package/src/publication/Link.ts +6 -2
  15. package/src/publication/Locator.ts +3 -21
  16. package/src/publication/Manifest.ts +10 -10
  17. package/src/publication/Publication.ts +1 -2
  18. package/src/publication/accessibility/Localization.ts +14 -12
  19. package/src/publication/accessibility/SupportedLanguages.ts +1 -1
  20. package/src/publication/encryption/Properties.ts +15 -3
  21. package/src/publication/epub/Metadata.ts +12 -6
  22. package/src/publication/epub/Properties.ts +13 -3
  23. package/src/publication/epub/Publication.ts +39 -18
  24. package/src/publication/html/Locations.ts +101 -54
  25. package/src/publication/opds/Properties.ts +66 -21
  26. package/src/publication/opds/Publication.ts +9 -3
  27. package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +1 -3
  28. package/src/publication/services/timeline/Timeline.ts +59 -268
  29. package/src/publication/services/timeline/TimelineItem.ts +3 -3
  30. package/src/publication/services/timeline/index.ts +0 -12
  31. package/src/util/npt.ts +0 -19
  32. package/types/src/fetcher/HttpFetcher.d.ts +3 -3
  33. package/types/src/fetcher/Resource.d.ts +6 -2
  34. package/types/src/publication/encryption/Properties.d.ts +9 -2
  35. package/types/src/publication/epub/Metadata.d.ts +6 -3
  36. package/types/src/publication/epub/Properties.d.ts +10 -2
  37. package/types/src/publication/epub/Publication.d.ts +18 -7
  38. package/types/src/publication/html/Locations.d.ts +44 -15
  39. package/types/src/publication/opds/Properties.d.ts +36 -8
  40. package/types/src/publication/opds/Publication.d.ts +5 -2
  41. package/types/src/publication/services/timeline/Timeline.d.ts +12 -78
  42. package/types/src/publication/services/timeline/TimelineItem.d.ts +3 -3
  43. package/types/src/publication/services/timeline/index.d.ts +0 -6
  44. package/types/src/util/npt.d.ts +0 -10
  45. package/dist/_virtual/preload-helper.js +0 -1
  46. package/dist/fetcher/Fetcher.js +0 -1
  47. package/dist/fetcher/HttpFetcher.js +0 -1
  48. package/dist/fetcher/Resource.js +0 -1
  49. package/dist/locales/publication-metadata/ar.json.js +0 -1
  50. package/dist/locales/publication-metadata/da.json.js +0 -1
  51. package/dist/locales/publication-metadata/el.json.js +0 -1
  52. package/dist/locales/publication-metadata/en.json.js +0 -1
  53. package/dist/locales/publication-metadata/es.json.js +0 -1
  54. package/dist/locales/publication-metadata/et.json.js +0 -1
  55. package/dist/locales/publication-metadata/fi.json.js +0 -1
  56. package/dist/locales/publication-metadata/fr.json.js +0 -1
  57. package/dist/locales/publication-metadata/it.json.js +0 -1
  58. package/dist/locales/publication-metadata/pl.json.js +0 -1
  59. package/dist/locales/publication-metadata/pt_PT.json.js +0 -1
  60. package/dist/locales/publication-metadata/sv.json.js +0 -1
  61. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/constants.js +0 -1
  62. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/index.js +0 -1
  63. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-attribute.js +0 -1
  64. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-class.js +0 -1
  65. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-fallback.js +0 -1
  66. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-id.js +0 -1
  67. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-child.js +0 -1
  68. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-of-type.js +0 -1
  69. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-tag.js +0 -1
  70. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/types.js +0 -1
  71. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-cartesian.js +0 -1
  72. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-data.js +0 -1
  73. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-dom.js +0 -1
  74. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-element-data.js +0 -1
  75. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-iselement.js +0 -1
  76. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-messages.js +0 -1
  77. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-options.js +0 -1
  78. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-powerset.js +0 -1
  79. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-selectors.js +0 -1
  80. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-typescript.js +0 -1
  81. package/dist/opds/Acquisition.js +0 -1
  82. package/dist/opds/Availability.js +0 -1
  83. package/dist/opds/Copies.js +0 -1
  84. package/dist/opds/Holds.js +0 -1
  85. package/dist/opds/Price.js +0 -1
  86. package/dist/publication/AltIdentifier.js +0 -1
  87. package/dist/publication/BelongsTo.js +0 -1
  88. package/dist/publication/Contributor.js +0 -1
  89. package/dist/publication/GuidedNavigation.js +0 -1
  90. package/dist/publication/Layout.js +0 -1
  91. package/dist/publication/Link.js +0 -1
  92. package/dist/publication/LocalizedString.js +0 -1
  93. package/dist/publication/Locator.js +0 -1
  94. package/dist/publication/LocatorCollection.js +0 -1
  95. package/dist/publication/Manifest.js +0 -1
  96. package/dist/publication/Metadata.js +0 -1
  97. package/dist/publication/Profiles.js +0 -1
  98. package/dist/publication/Properties.js +0 -1
  99. package/dist/publication/Publication.js +0 -1
  100. package/dist/publication/PublicationCollection.js +0 -1
  101. package/dist/publication/ReadingProgression.js +0 -1
  102. package/dist/publication/Subject.js +0 -1
  103. package/dist/publication/TDM.js +0 -1
  104. package/dist/publication/accessibility/Accessibility.js +0 -1
  105. package/dist/publication/accessibility/AccessibilityMetadataDisplayGuide.js +0 -1
  106. package/dist/publication/accessibility/Localization.js +0 -1
  107. package/dist/publication/accessibility/SupportedLanguages.js +0 -1
  108. package/dist/publication/encryption/Encryption.js +0 -1
  109. package/dist/publication/encryption/Properties.js +0 -1
  110. package/dist/publication/encryption/index.js +0 -1
  111. package/dist/publication/epub/MediaOverlay.js +0 -1
  112. package/dist/publication/epub/Metadata.js +0 -1
  113. package/dist/publication/epub/Properties.js +0 -1
  114. package/dist/publication/epub/Publication.js +0 -1
  115. package/dist/publication/epub/index.js +0 -1
  116. package/dist/publication/html/DomRange.js +0 -1
  117. package/dist/publication/html/DomRangePoint.js +0 -1
  118. package/dist/publication/html/Locations.js +0 -1
  119. package/dist/publication/html/index.js +0 -1
  120. package/dist/publication/opds/Properties.js +0 -1
  121. package/dist/publication/opds/Publication.js +0 -1
  122. package/dist/publication/opds/index.js +0 -1
  123. package/dist/publication/services/content/Content.js +0 -2
  124. package/dist/publication/services/content/ContentTokenizer.js +0 -1
  125. package/dist/publication/services/content/Iterator.js +0 -1
  126. package/dist/publication/services/content/element/attributes.js +0 -1
  127. package/dist/publication/services/content/element/element.js +0 -1
  128. package/dist/publication/services/content/element/text_role.js +0 -1
  129. package/dist/publication/services/content/iterators/HTMLResourceContentIterator.js +0 -1
  130. package/dist/publication/services/content/iterators/PDFTextContentIterator.js +0 -1
  131. package/dist/publication/services/content/iterators/PublicationContentIterator.js +0 -1
  132. package/dist/publication/services/content/iterators/helpers.js +0 -1
  133. package/dist/publication/services/timeline/Timeline.js +0 -1
  134. package/dist/publication/services/timeline/audio.js +0 -1
  135. package/dist/publication/services/timeline/html.js +0 -1
  136. package/dist/publication/services/timeline/index.js +0 -1
  137. package/dist/util/JSONParse.js +0 -1
  138. package/dist/util/URITemplate.js +0 -1
  139. package/dist/util/mediatype/MediaType.js +0 -1
  140. package/dist/util/npt.js +0 -1
  141. package/dist/util/tokenizer/TextTokenizer.js +0 -1
  142. package/dist/util/tokenizer/tokenize-english/abbreviations.js +0 -1
  143. package/dist/util/tokenizer/tokenize-english/index.js +0 -2
  144. package/dist/util/tokenizer/tokenize-english/utils.js +0 -1
  145. package/dist/util/tokenizer/tokenize-text/index.js +0 -1
  146. package/dist/util/tokenizer/tokenize-text/tokens.js +0 -1
  147. package/src/locales/publication-metadata/ar.json +0 -402
  148. package/src/locales/publication-metadata/brh.json +0 -1
  149. package/src/locales/publication-metadata/da.json +0 -310
  150. package/src/locales/publication-metadata/el.json +0 -310
  151. package/src/locales/publication-metadata/en.json +0 -310
  152. package/src/locales/publication-metadata/es.json +0 -333
  153. package/src/locales/publication-metadata/et.json +0 -310
  154. package/src/locales/publication-metadata/fi.json +0 -310
  155. package/src/locales/publication-metadata/fr.json +0 -333
  156. package/src/locales/publication-metadata/he.json +0 -9
  157. package/src/locales/publication-metadata/it.json +0 -333
  158. package/src/locales/publication-metadata/lt.json +0 -8
  159. package/src/locales/publication-metadata/pl.json +0 -333
  160. package/src/locales/publication-metadata/pt_PT.json +0 -329
  161. package/src/locales/publication-metadata/sv.json +0 -310
  162. package/src/locales/publication-metadata/tr.json +0 -51
  163. package/src/locales/publication-metadata/uk.json +0 -1
  164. package/src/publication/services/timeline/audio.ts +0 -31
  165. package/src/publication/services/timeline/html.ts +0 -5
  166. package/types/src/publication/services/timeline/audio.d.ts +0 -4
  167. package/types/src/publication/services/timeline/html.d.ts +0 -4
@@ -2,81 +2,128 @@ import { LocatorLocations } from '../Locator.ts';
2
2
  import { DomRange } from './DomRange.ts';
3
3
  import { parseNptTime } from '../../util/npt.ts';
4
4
 
5
- // HTML extensions for LocatorLocations.
5
+ // HTML extensions for [Locations].
6
6
  // https://github.com/readium/architecture/blob/master/models/locators/extensions/html.md
7
7
 
8
- export function getCssSelector(loc: LocatorLocations): string | undefined {
9
- return loc.otherLocations?.get('cssSelector');
10
- }
8
+ declare module '../Locator' {
9
+ export interface LocatorLocations {
10
+ /**
11
+ * A CSS Selector.
12
+ */
13
+ getCssSelector(): string | undefined;
11
14
 
12
- export function getPartialCfi(loc: LocatorLocations): string | undefined {
13
- return loc.otherLocations?.get('partialCfi');
14
- }
15
+ /**
16
+ * [partialCfi] is an expression conforming to the "right-hand" side of the EPUB CFI syntax, that is
17
+ * to say: without the EPUB-specific OPF spine item reference that precedes the first ! exclamation
18
+ * mark (which denotes the "step indirection" into a publication document). Note that the wrapping
19
+ * epubcfi(***) syntax is not used for the [partialCfi] string, i.e. the "fragment" part of the CFI
20
+ * grammar is ignored.
21
+ */
22
+ getPartialCfi(): string | undefined;
23
+
24
+ /**
25
+ * An HTML DOM range.
26
+ */
27
+ getDomRange(): DomRange | undefined;
28
+
29
+ /**
30
+ * All named parameters found in the fragments, such as `p=5`.
31
+ */
32
+ fragmentParameters(): Map<string, string>;
33
+
34
+ /**
35
+ * HTML ID fragment identifier.
36
+ */
37
+ htmlId(): string | undefined;
15
38
 
16
- export function getDomRange(loc: LocatorLocations): DomRange | undefined {
17
- return DomRange.deserialize(loc.otherLocations?.get('domRange'));
39
+ /**
40
+ * Page fragment identifier, used for example in PDF.
41
+ */
42
+ page(): number | undefined;
43
+
44
+ /**
45
+ * Temporal Dimension media fragment, used for example in audiobooks.
46
+ *
47
+ * https://www.w3.org/TR/media-frags/
48
+ */
49
+ time(): number | undefined;
50
+
51
+ /**
52
+ * Spatial Dimension media fragment, used for example in audiobooks.
53
+ *
54
+ * https://www.w3.org/TR/media-frags/
55
+ */
56
+ space(): [number, number, number, number] | undefined;
57
+ }
18
58
  }
19
59
 
20
- export function getFragmentParameters(loc: LocatorLocations): Map<string, string> {
60
+ LocatorLocations.prototype.getCssSelector = function(): string | undefined {
61
+ return this.otherLocations?.get('cssSelector');
62
+ };
63
+
64
+ LocatorLocations.prototype.getPartialCfi = function(): string | undefined {
65
+ return this.otherLocations?.get('partialCfi');
66
+ };
67
+
68
+ LocatorLocations.prototype.getDomRange = function(): DomRange | undefined {
69
+ return DomRange.deserialize(this.otherLocations?.get('domRange'));
70
+ };
71
+
72
+ // Below is technically part of the Navigator's Locator extensions, we're putting it here for now
73
+
74
+ // Reference: https://www.w3.org/TR/fragid-best-practices
75
+ LocatorLocations.prototype.fragmentParameters = function(): Map<string, string> {
21
76
  return new Map(
22
- loc.fragments
23
- .map(f => f.startsWith('#') ? f.slice(1) : f)
24
- .join('&')
25
- .split('&')
26
- .filter(f => !f.startsWith('#'))
27
- .map(f => f.split('='))
77
+ this.fragments
78
+ // Concatenates fragments together, after dropping any #
79
+ .map(f => f.startsWith("#") ? f.slice(1) : f)
80
+ .join("&")
81
+ // Splits parameters
82
+ .split("&")
83
+ .filter(f => !f.startsWith("#"))
84
+ .map(f => f.split("="))
85
+ // Only keep named parameters
28
86
  .filter(f => f.length === 2)
29
- .map(f => [f[0].trim().toLowerCase(), f[1].trim()])
87
+ .map(f => [
88
+ f[0].trim().toLowerCase(),
89
+ f[1].trim()
90
+ ])
30
91
  );
31
- }
92
+ };
32
93
 
33
- export function getHtmlId(loc: LocatorLocations): string | undefined {
94
+ LocatorLocations.prototype.htmlId = function(): string | undefined {
34
95
  /*
35
96
  The HTML 5 specification (used for WebPub) allows any character in an HTML ID, except spaces.
36
97
  This is an issue to differentiate with named parameters, so we ignore any ID containing `=`.
37
98
  */
38
- if (!loc.fragments.length) return;
39
- let f = loc.fragments.find(f => f.length && !f.includes('='));
40
- if (!f) {
41
- const fp = getFragmentParameters(loc);
42
- if (fp.has('id')) f = fp.get('id');
43
- else if (fp.has('name')) f = fp.get('name');
99
+ if(!this.fragments.length) return;
100
+ let f = this.fragments.find(f => f.length && !f.includes("="));
101
+ if(!f) {
102
+ const fp = this.fragmentParameters();
103
+ if(fp.has("id")) f = fp.get("id");
104
+ else if(fp.has("name")) f = fp.get("name");
44
105
  }
45
- return f?.startsWith('#') ? f.slice(1) : f;
46
- }
106
+ return f?.startsWith("#") ? f.slice(1) : f;
107
+ };
47
108
 
48
- export function getPage(loc: LocatorLocations): number | undefined {
49
- const i = parseInt(getFragmentParameters(loc).get('page')!);
50
- if (!isNaN(i) && i >= 0) return i;
109
+ LocatorLocations.prototype.page = function(): number | undefined {
110
+ const i = parseInt(this.fragmentParameters().get("page")!);
111
+ if(!isNaN(i) && i >= 0) return i;
51
112
  return undefined;
52
113
  }
53
114
 
54
- export function getTime(loc: LocatorLocations): number | undefined {
55
- const raw = getFragmentParameters(loc).get('t');
115
+ LocatorLocations.prototype.time = function(): number | undefined {
116
+ const raw = this.fragmentParameters().get("t");
56
117
  if (!raw) return undefined;
57
118
  return parseNptTime(raw);
58
119
  }
59
120
 
60
- export function getSpace(loc: LocatorLocations): { unit: "pixel" | "percent"; x: number; y: number; width: number; height: number } | undefined {
61
- const fp = getFragmentParameters(loc);
62
- if (!fp.has('xywh')) return;
63
-
64
- const raw = fp.get('xywh')!;
65
- let unit: "pixel" | "percent" = "pixel";
66
- let coords = raw;
67
-
68
- const normalizedRaw = raw.toLowerCase();
69
- if (normalizedRaw.startsWith("pixel:")) {
70
- coords = raw.slice(6);
71
- } else if (normalizedRaw.startsWith("percent:")) {
72
- unit = "percent";
73
- coords = raw.slice(8);
74
- }
75
-
76
- const parse = unit === "percent" ? parseFloat : (s: string) => parseInt(s, 10);
77
- const parts = coords.split(",").map(parse);
78
- if (parts.length !== 4 || parts.some(isNaN)) return;
79
-
80
- const [x, y, width, height] = parts;
81
- return { unit, x, y, width, height };
121
+ LocatorLocations.prototype.space = function(): [number, number, number, number] | undefined {
122
+ const fp = this.fragmentParameters();
123
+ if(!fp.has("xywh")) return;
124
+ // TODO more sophiticated parsing to handle the format
125
+ const xywh = fp.get("xywh")!.split(",").map(s => parseInt(s));
126
+ if(xywh.length !== 4) return; // Must have four parts
127
+ if(xywh.some(isNaN)) return; // All parts must be numbers
128
+ return xywh as [number, number, number, number];
82
129
  }
@@ -3,37 +3,82 @@ import { positiveNumberfromJSON } from '../../util/JSONParse.ts';
3
3
  import { Link } from '../Link.ts';
4
4
  import { Properties } from '../Properties.ts';
5
5
 
6
- // OPDS extensions for link Properties.
6
+ // OPDS extensions for link [Properties].
7
7
  // https://specs.opds.io/schema/properties.schema.json
8
8
 
9
- export function getNumberOfItems(properties: Properties): number | undefined {
10
- return positiveNumberfromJSON(properties.otherProperties['numberOfItems']);
11
- }
9
+ declare module '../Properties' {
10
+ export interface Properties {
11
+ /**
12
+ * Provides a hint about the expected number of items returned.
13
+ */
14
+ getNumberOfItems(): number | undefined;
15
+
16
+ /**
17
+ * The price of a publication is tied to its acquisition link.
18
+ */
19
+ getPrice(): Price | undefined;
20
+
21
+ /**
22
+ * Indirect acquisition provides a hint for the expected media type that will be acquired after
23
+ * additional steps.
24
+ */
25
+ getIndirectAcquisitions(): Array<Acquisition> | undefined;
26
+
27
+ /**
28
+ * Library-specific features when a specific book is unavailable but provides a hold list.
29
+ */
30
+ getHolds(): Holds | undefined;
12
31
 
13
- export function getPrice(properties: Properties): Price | undefined {
14
- return Price.deserialize(properties.otherProperties['price']);
32
+ /**
33
+ * Library-specific feature that contains information about the copies that a library has acquired.
34
+ */
35
+ getCopies(): Copies | undefined;
36
+
37
+ /**
38
+ * Indicated the availability of a given resource.
39
+ */
40
+ getAvailability(): Availability | undefined;
41
+
42
+ /**
43
+ * Indicates that the linked resource supports authentication with the associated Authentication
44
+ * Document.
45
+ *
46
+ * See https://specs.opds.io/authentication-for-opds-1.0.html
47
+ */
48
+ getAuthenticate(): Link | undefined;
49
+ }
15
50
  }
16
51
 
17
- export function getIndirectAcquisitions(properties: Properties): Array<Acquisition> | undefined {
18
- const json = properties.otherProperties['indirectAcquisition'];
52
+ Properties.prototype.getNumberOfItems = function(): number | undefined {
53
+ return positiveNumberfromJSON(this.otherProperties['numberOfItems']);
54
+ };
55
+
56
+ Properties.prototype.getPrice = function(): Price | undefined {
57
+ return Price.deserialize(this.otherProperties['price']);
58
+ };
59
+
60
+ Properties.prototype.getIndirectAcquisitions = function():
61
+ | Array<Acquisition>
62
+ | undefined {
63
+ const json = this.otherProperties['indirectAcquisition'];
19
64
  if (!(json && Array.isArray(json))) return;
20
65
  return json
21
66
  .map<Acquisition>(item => Acquisition.deserialize(item) as Acquisition)
22
67
  .filter(x => x !== undefined);
23
- }
68
+ };
24
69
 
25
- export function getHolds(properties: Properties): Holds | undefined {
26
- return Holds.deserialize(properties.otherProperties['holds']);
27
- }
70
+ Properties.prototype.getHolds = function(): Holds | undefined {
71
+ return Holds.deserialize(this.otherProperties['holds']);
72
+ };
28
73
 
29
- export function getCopies(properties: Properties): Copies | undefined {
30
- return Copies.deserialize(properties.otherProperties['copies']);
31
- }
74
+ Properties.prototype.getCopies = function(): Copies | undefined {
75
+ return Copies.deserialize(this.otherProperties['copies']);
76
+ };
32
77
 
33
- export function getAvailability(properties: Properties): Availability | undefined {
34
- return Availability.deserialize(properties.otherProperties['availability']);
35
- }
78
+ Properties.prototype.getAvailability = function(): Availability | undefined {
79
+ return Availability.deserialize(this.otherProperties['availability']);
80
+ };
36
81
 
37
- export function getAuthenticate(properties: Properties): Link | undefined {
38
- return Link.deserialize(properties.otherProperties['authenticate']);
39
- }
82
+ Properties.prototype.getAuthenticate = function(): Link | undefined {
83
+ return Link.deserialize(this.otherProperties['authenticate']);
84
+ };
@@ -1,8 +1,14 @@
1
1
  import { Links } from '../Link.ts';
2
2
  import { Publication } from '../Publication.ts';
3
3
 
4
- // OPDS extensions for Publication.
4
+ // OPDS extensions for [Publication]
5
5
 
6
- export function getImages(pub: Publication): Links | undefined {
7
- return pub.linksWithRole('images');
6
+ declare module '../Publication' {
7
+ export interface Publication {
8
+ getImages(): Links | undefined;
9
+ }
8
10
  }
11
+
12
+ Publication.prototype.getImages = function(): Links | undefined {
13
+ return this.linksWithRole('images');
14
+ };
@@ -5,7 +5,6 @@ import { IllegalStateError, Iterator } from "../Iterator.ts";
5
5
  import { Attribute, AttributeKeys, AudioElement, Body, ContentElement, Footnote, Heading, ImageElement, TextElement, TextQuote, TextRole, TextSegment, VideoElement } from "../element/index.ts";
6
6
  import { appendNormalizedWhitespace, elementLanguage, isBlank, isInlineTag, srcRelativeToHref, trimUnicodeSpace, trimUnicodeSpaceEnd, trimUnicodeSpaceStart, trimmingTextLocator } from "./helpers.ts";
7
7
  import { getCssSelector } from "css-selector-generator";
8
- import { getCssSelector as locatorCssSelector } from "../../../html/Locations.ts";
9
8
 
10
9
  interface ElementWithDelta {
11
10
  element: ContentElement;
@@ -94,11 +93,10 @@ export class HTMLResourceContentIterator extends Iterator {
94
93
  private async parseElements(): Promise<ParsedElementRecipes> {
95
94
  const raw = await this.resource.readAsString();
96
95
  const doc = (new DOMParser()).parseFromString(raw!, this.locator.type as DOMParserSupportedType);
97
- const startSel = locatorCssSelector(this.locator.locations);
98
96
  this.parser = new ContentParser(
99
97
  doc,
100
98
  this.locator,
101
- startSel ? doc.querySelector(startSel) as Element : null,
99
+ this.locator.locations.getCssSelector() ? doc.querySelector(this.locator.locations.getCssSelector()!) as Element : null,
102
100
  this.beforeMaxLength
103
101
  );
104
102