@readium/shared 2.2.2 → 2.3.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.
Files changed (174) hide show
  1. package/README.MD +8 -7
  2. package/dist/_virtual/preload-helper.js +1 -0
  3. package/dist/fetcher/Fetcher.js +1 -0
  4. package/dist/fetcher/HttpFetcher.js +1 -0
  5. package/dist/fetcher/Resource.js +1 -0
  6. package/dist/index.js +1 -4972
  7. package/dist/locales/publication-metadata/ar.json.js +1 -0
  8. package/dist/locales/publication-metadata/da.json.js +1 -0
  9. package/dist/locales/publication-metadata/el.json.js +1 -0
  10. package/dist/locales/publication-metadata/en.json.js +1 -0
  11. package/dist/locales/publication-metadata/es.json.js +1 -0
  12. package/dist/locales/publication-metadata/et.json.js +1 -0
  13. package/dist/locales/publication-metadata/fi.json.js +1 -0
  14. package/dist/locales/publication-metadata/fr.json.js +1 -0
  15. package/dist/locales/publication-metadata/it.json.js +1 -0
  16. package/dist/locales/publication-metadata/pl.json.js +1 -0
  17. package/dist/locales/publication-metadata/pt_PT.json.js +1 -0
  18. package/dist/locales/publication-metadata/sv.json.js +1 -0
  19. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/constants.js +1 -0
  20. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/index.js +1 -0
  21. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-attribute.js +1 -0
  22. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-class.js +1 -0
  23. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-fallback.js +1 -0
  24. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-id.js +1 -0
  25. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-child.js +1 -0
  26. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-of-type.js +1 -0
  27. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-tag.js +1 -0
  28. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/types.js +1 -0
  29. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-cartesian.js +1 -0
  30. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-data.js +1 -0
  31. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-dom.js +1 -0
  32. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-element-data.js +1 -0
  33. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-iselement.js +1 -0
  34. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-messages.js +1 -0
  35. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-options.js +1 -0
  36. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-powerset.js +1 -0
  37. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-selectors.js +1 -0
  38. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-typescript.js +1 -0
  39. package/dist/opds/Acquisition.js +1 -0
  40. package/dist/opds/Availability.js +1 -0
  41. package/dist/opds/Copies.js +1 -0
  42. package/dist/opds/Holds.js +1 -0
  43. package/dist/opds/Price.js +1 -0
  44. package/dist/publication/AltIdentifier.js +1 -0
  45. package/dist/publication/BelongsTo.js +1 -0
  46. package/dist/publication/Contributor.js +1 -0
  47. package/dist/publication/GuidedNavigation.js +1 -0
  48. package/dist/publication/Layout.js +1 -0
  49. package/dist/publication/Link.js +1 -0
  50. package/dist/publication/LocalizedString.js +1 -0
  51. package/dist/publication/Locator.js +1 -0
  52. package/dist/publication/LocatorCollection.js +1 -0
  53. package/dist/publication/Manifest.js +1 -0
  54. package/dist/publication/Metadata.js +1 -0
  55. package/dist/publication/Profiles.js +1 -0
  56. package/dist/publication/Properties.js +1 -0
  57. package/dist/publication/Publication.js +1 -0
  58. package/dist/publication/PublicationCollection.js +1 -0
  59. package/dist/publication/ReadingProgression.js +1 -0
  60. package/dist/publication/Subject.js +1 -0
  61. package/dist/publication/TDM.js +1 -0
  62. package/dist/publication/accessibility/Accessibility.js +1 -0
  63. package/dist/publication/accessibility/AccessibilityMetadataDisplayGuide.js +1 -0
  64. package/dist/publication/accessibility/Localization.js +1 -0
  65. package/dist/publication/accessibility/SupportedLanguages.js +1 -0
  66. package/dist/publication/encryption/Encryption.js +1 -0
  67. package/dist/publication/encryption/Properties.js +1 -0
  68. package/dist/publication/encryption/index.js +1 -0
  69. package/dist/publication/epub/MediaOverlay.js +1 -0
  70. package/dist/publication/epub/Metadata.js +1 -0
  71. package/dist/publication/epub/Properties.js +1 -0
  72. package/dist/publication/epub/Publication.js +1 -0
  73. package/dist/publication/epub/index.js +1 -0
  74. package/dist/publication/html/DomRange.js +1 -0
  75. package/dist/publication/html/DomRangePoint.js +1 -0
  76. package/dist/publication/html/Locations.js +1 -0
  77. package/dist/publication/html/index.js +1 -0
  78. package/dist/publication/opds/Properties.js +1 -0
  79. package/dist/publication/opds/Publication.js +1 -0
  80. package/dist/publication/opds/index.js +1 -0
  81. package/dist/publication/services/content/Content.js +2 -0
  82. package/dist/publication/services/content/ContentTokenizer.js +1 -0
  83. package/dist/publication/services/content/Iterator.js +1 -0
  84. package/dist/publication/services/content/element/attributes.js +1 -0
  85. package/dist/publication/services/content/element/element.js +1 -0
  86. package/dist/publication/services/content/element/text_role.js +1 -0
  87. package/dist/publication/services/content/iterators/HTMLResourceContentIterator.js +1 -0
  88. package/dist/publication/services/content/iterators/PDFTextContentIterator.js +1 -0
  89. package/dist/publication/services/content/iterators/PublicationContentIterator.js +1 -0
  90. package/dist/publication/services/content/iterators/helpers.js +1 -0
  91. package/dist/publication/services/timeline/Timeline.js +1 -0
  92. package/dist/publication/services/timeline/audio.js +1 -0
  93. package/dist/publication/services/timeline/html.js +1 -0
  94. package/dist/publication/services/timeline/index.js +1 -0
  95. package/dist/util/JSONParse.js +1 -0
  96. package/dist/util/URITemplate.js +1 -0
  97. package/dist/util/mediatype/MediaType.js +1 -0
  98. package/dist/util/npt.js +1 -0
  99. package/dist/util/tokenizer/TextTokenizer.js +1 -0
  100. package/dist/util/tokenizer/tokenize-english/abbreviations.js +1 -0
  101. package/dist/util/tokenizer/tokenize-english/index.js +2 -0
  102. package/dist/util/tokenizer/tokenize-english/utils.js +1 -0
  103. package/dist/util/tokenizer/tokenize-text/index.js +1 -0
  104. package/dist/util/tokenizer/tokenize-text/tokens.js +1 -0
  105. package/package.json +26 -19
  106. package/src/locales/publication-metadata/ar.json +402 -0
  107. package/src/locales/publication-metadata/brh.json +1 -0
  108. package/src/locales/publication-metadata/da.json +310 -0
  109. package/src/locales/publication-metadata/el.json +310 -0
  110. package/src/locales/publication-metadata/en.json +310 -0
  111. package/src/locales/publication-metadata/es.json +333 -0
  112. package/src/locales/publication-metadata/et.json +310 -0
  113. package/src/locales/publication-metadata/fi.json +310 -0
  114. package/src/locales/publication-metadata/fr.json +333 -0
  115. package/src/locales/publication-metadata/he.json +9 -0
  116. package/src/locales/publication-metadata/it.json +333 -0
  117. package/src/locales/publication-metadata/lt.json +8 -0
  118. package/src/locales/publication-metadata/pl.json +333 -0
  119. package/src/locales/publication-metadata/pt_PT.json +329 -0
  120. package/src/locales/publication-metadata/sv.json +310 -0
  121. package/src/locales/publication-metadata/tr.json +51 -0
  122. package/src/locales/publication-metadata/uk.json +1 -0
  123. package/src/opds/Acquisition.ts +1 -1
  124. package/src/opds/Availability.ts +1 -1
  125. package/src/opds/Copies.ts +1 -1
  126. package/src/opds/Holds.ts +1 -1
  127. package/src/opds/Price.ts +1 -1
  128. package/src/publication/Link.ts +2 -6
  129. package/src/publication/Locator.ts +21 -3
  130. package/src/publication/Manifest.ts +5 -7
  131. package/src/publication/Publication.ts +2 -1
  132. package/src/publication/accessibility/Localization.ts +12 -14
  133. package/src/publication/accessibility/SupportedLanguages.ts +1 -1
  134. package/src/publication/encryption/Properties.ts +3 -15
  135. package/src/publication/epub/Metadata.ts +6 -12
  136. package/src/publication/epub/Properties.ts +3 -13
  137. package/src/publication/epub/Publication.ts +18 -39
  138. package/src/publication/html/Locations.ts +57 -104
  139. package/src/publication/opds/Properties.ts +22 -67
  140. package/src/publication/opds/Publication.ts +3 -9
  141. package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +3 -1
  142. package/src/publication/services/timeline/Timeline.ts +274 -65
  143. package/src/publication/services/timeline/TimelineItem.ts +3 -3
  144. package/src/publication/services/timeline/audio.ts +31 -0
  145. package/src/publication/services/timeline/html.ts +5 -0
  146. package/src/publication/services/timeline/index.ts +12 -0
  147. package/src/util/index.ts +1 -0
  148. package/src/util/npt.ts +70 -0
  149. package/types/src/opds/Acquisition.d.ts +1 -1
  150. package/types/src/opds/Availability.d.ts +1 -1
  151. package/types/src/opds/Copies.d.ts +1 -1
  152. package/types/src/opds/Holds.d.ts +1 -1
  153. package/types/src/opds/Price.d.ts +1 -1
  154. package/types/src/publication/encryption/Properties.d.ts +2 -9
  155. package/types/src/publication/epub/Metadata.d.ts +3 -6
  156. package/types/src/publication/epub/Properties.d.ts +2 -10
  157. package/types/src/publication/epub/Publication.d.ts +7 -18
  158. package/types/src/publication/html/Locations.d.ts +15 -44
  159. package/types/src/publication/opds/Properties.d.ts +8 -36
  160. package/types/src/publication/opds/Publication.d.ts +2 -5
  161. package/types/src/publication/services/timeline/Timeline.d.ts +80 -15
  162. package/types/src/publication/services/timeline/TimelineItem.d.ts +3 -3
  163. package/types/src/publication/services/timeline/audio.d.ts +4 -0
  164. package/types/src/publication/services/timeline/html.d.ts +4 -0
  165. package/types/src/publication/services/timeline/index.d.ts +6 -0
  166. package/types/src/util/index.d.ts +1 -0
  167. package/types/src/util/npt.d.ts +30 -0
  168. package/dist/ar-DyHX_uy2.js +0 -7
  169. package/dist/da-Dct0PS3E.js +0 -7
  170. package/dist/fr-C5HEel98.js +0 -7
  171. package/dist/index.umd.cjs +0 -3
  172. package/dist/it-DFOBoXGy.js +0 -7
  173. package/dist/pt_PT-Di3sVjze.js +0 -7
  174. package/dist/sv-BfzAFsVN.js +0 -7
package/README.MD CHANGED
@@ -11,17 +11,18 @@ pnpm run test
11
11
 
12
12
  It will output the results in your shell.
13
13
 
14
- To build:
14
+ Locale files from [edrlab/thorium-locales](https://github.com/edrlab/thorium-locales) are vendored in `src/locales/` and must be present before building. Update them when upstream changes:
15
15
 
16
16
  ```sh
17
- pnpm run build
17
+ pnpm run update-locales
18
18
  ```
19
19
 
20
- It will output 6 files (`shared.js` and `shared.umd.cjs`, `fetcher.js` and `fetcher.cjs`) in `dist`.
20
+ This fetches all available locale files from the upstream repository and runs a coverage check.
21
21
 
22
- To check the size limit:
22
+ To build:
23
23
 
24
24
  ```sh
25
- # Check ths size limit is not exceeded
26
- pnpm run size
27
- ```
25
+ pnpm run build
26
+ ```
27
+
28
+ It will output files in `dist`.
@@ -0,0 +1 @@
1
+ const p="modulepreload",v=function(l){return"/"+l},u={},y=function(d,c,E){let i=Promise.resolve();if(c&&c.length>0){let f=function(e){return Promise.all(e.map(o=>Promise.resolve(o).then(s=>({status:"fulfilled",value:s}),s=>({status:"rejected",reason:s}))))};document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");i=f(c.map(e=>{if(e=v(e),e in u)return;u[e]=!0;const o=e.endsWith(".css"),s=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${s}`))return;const n=document.createElement("link");if(n.rel=o?"stylesheet":p,o||(n.as="script"),n.crossOrigin="",n.href=e,t&&n.setAttribute("nonce",t),document.head.appendChild(n),o)return new Promise((m,h)=>{n.addEventListener("load",m),n.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${e}`)))})}))}function a(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return i.then(r=>{for(const t of r||[])t.status==="rejected"&&a(t.reason);return d().catch(a)})};export{y as __vitePreload};
@@ -0,0 +1 @@
1
+ class t{close(){}links(){return[]}get(r){throw Error("This is an empty fetcher")}}export{t as EmptyFetcher};
@@ -0,0 +1 @@
1
+ class n{constructor(t,r){this.client=t||window.fetch.bind(window),this.baseUrl=r}links(){return[]}get(t){const r=t.toURL(this.baseUrl);if(r===void 0)throw Error(`Invalid HREF: ${t.href}`);return new i(this.client,t,r)}close(){}}class i{constructor(t,r,s){this.client=t||window.fetch.bind(window),this._link=r,this.url=s}async headResponse(){if(this._headResponse)return this._headResponse;const t=await this.client(this.url,{method:"HEAD"});if(!t.ok)throw new Error(`http HEAD request for ${this.url} failed with HTTP status code ${t.status}`);return this._headResponse=t,t}close(){}async link(){return this._link}async read(t){if(t)throw new Error("http read range not implemented!");const r=await this.client(this.url);if(!r.ok)throw new Error(`http GET request for ${this.url} failed with HTTP status code ${r.status}`);return new Uint8Array(await r.arrayBuffer())}async length(){const r=(await this.headResponse()).headers.get("content-length");if(r===null||r==="")throw new Error("length for resource unavailable");return parseInt(r)}async readAsJSON(){const t=await this.client(this.url);if(!t.ok)throw new Error(`http GET request for ${this.url} failed with HTTP status code ${t.status}`);return await t.json()}async readAsString(){const t=await this.client(this.url);if(!t.ok)throw new Error(`http GET request for ${this.url} failed with HTTP status code ${t.status}`);return await t.text()}async readAsXML(){const t=await this.client(this.url);if(!t.ok)throw new Error(`http GET request for ${this.url} failed with HTTP status code ${t.status}`);return new DOMParser().parseFromString(await t.text(),"application/xml")}}export{n as HttpFetcher,i as HttpResource};
@@ -0,0 +1 @@
1
+ class n{constructor(r,t){this.start=r,this.endInclusive=t}}class i{readAsString(){return this.read().then(r=>r===void 0?r:new TextDecoder().decode(r))}readAsJSON(){return this.readAsString().then(r=>r===void 0?r:JSON.parse(r))}readAsXML(){return this.readAsString().then(r=>r===void 0?r:new DOMParser().parseFromString(r,"text/xml"))}}export{n as NumberRange,i as Resource};