@readium/shared 2.2.3 → 2.3.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 (163) hide show
  1. package/LICENSE +28 -0
  2. package/README.MD +8 -7
  3. package/dist/_virtual/preload-helper.js +1 -0
  4. package/dist/fetcher/Fetcher.js +1 -0
  5. package/dist/fetcher/HttpFetcher.js +1 -0
  6. package/dist/fetcher/Resource.js +1 -0
  7. package/dist/index.js +1 -4993
  8. package/dist/locales/publication-metadata/ar.json.js +1 -0
  9. package/dist/locales/publication-metadata/da.json.js +1 -0
  10. package/dist/locales/publication-metadata/el.json.js +1 -0
  11. package/dist/locales/publication-metadata/en.json.js +1 -0
  12. package/dist/locales/publication-metadata/es.json.js +1 -0
  13. package/dist/locales/publication-metadata/et.json.js +1 -0
  14. package/dist/locales/publication-metadata/fi.json.js +1 -0
  15. package/dist/locales/publication-metadata/fr.json.js +1 -0
  16. package/dist/locales/publication-metadata/it.json.js +1 -0
  17. package/dist/locales/publication-metadata/pl.json.js +1 -0
  18. package/dist/locales/publication-metadata/pt_PT.json.js +1 -0
  19. package/dist/locales/publication-metadata/sv.json.js +1 -0
  20. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/constants.js +1 -0
  21. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/index.js +1 -0
  22. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-attribute.js +1 -0
  23. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-class.js +1 -0
  24. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-fallback.js +1 -0
  25. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-id.js +1 -0
  26. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-child.js +1 -0
  27. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-of-type.js +1 -0
  28. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-tag.js +1 -0
  29. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/types.js +1 -0
  30. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-cartesian.js +1 -0
  31. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-data.js +1 -0
  32. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-dom.js +1 -0
  33. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-element-data.js +1 -0
  34. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-iselement.js +1 -0
  35. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-messages.js +1 -0
  36. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-options.js +1 -0
  37. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-powerset.js +1 -0
  38. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-selectors.js +1 -0
  39. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-typescript.js +1 -0
  40. package/dist/opds/Acquisition.js +1 -0
  41. package/dist/opds/Availability.js +1 -0
  42. package/dist/opds/Copies.js +1 -0
  43. package/dist/opds/Holds.js +1 -0
  44. package/dist/opds/Price.js +1 -0
  45. package/dist/publication/AltIdentifier.js +1 -0
  46. package/dist/publication/BelongsTo.js +1 -0
  47. package/dist/publication/Contributor.js +1 -0
  48. package/dist/publication/GuidedNavigation.js +1 -0
  49. package/dist/publication/Layout.js +1 -0
  50. package/dist/publication/Link.js +1 -0
  51. package/dist/publication/LocalizedString.js +1 -0
  52. package/dist/publication/Locator.js +1 -0
  53. package/dist/publication/LocatorCollection.js +1 -0
  54. package/dist/publication/Manifest.js +1 -0
  55. package/dist/publication/Metadata.js +1 -0
  56. package/dist/publication/Profiles.js +1 -0
  57. package/dist/publication/Properties.js +1 -0
  58. package/dist/publication/Publication.js +1 -0
  59. package/dist/publication/PublicationCollection.js +1 -0
  60. package/dist/publication/ReadingProgression.js +1 -0
  61. package/dist/publication/Subject.js +1 -0
  62. package/dist/publication/TDM.js +1 -0
  63. package/dist/publication/accessibility/Accessibility.js +1 -0
  64. package/dist/publication/accessibility/AccessibilityMetadataDisplayGuide.js +1 -0
  65. package/dist/publication/accessibility/Localization.js +1 -0
  66. package/dist/publication/accessibility/SupportedLanguages.js +1 -0
  67. package/dist/publication/encryption/Encryption.js +1 -0
  68. package/dist/publication/encryption/Properties.js +1 -0
  69. package/dist/publication/encryption/index.js +1 -0
  70. package/dist/publication/epub/MediaOverlay.js +1 -0
  71. package/dist/publication/epub/Metadata.js +1 -0
  72. package/dist/publication/epub/Properties.js +1 -0
  73. package/dist/publication/epub/Publication.js +1 -0
  74. package/dist/publication/epub/index.js +1 -0
  75. package/dist/publication/html/DomRange.js +1 -0
  76. package/dist/publication/html/DomRangePoint.js +1 -0
  77. package/dist/publication/html/Locations.js +1 -0
  78. package/dist/publication/html/index.js +1 -0
  79. package/dist/publication/opds/Properties.js +1 -0
  80. package/dist/publication/opds/Publication.js +1 -0
  81. package/dist/publication/opds/index.js +1 -0
  82. package/dist/publication/services/content/Content.js +2 -0
  83. package/dist/publication/services/content/ContentTokenizer.js +1 -0
  84. package/dist/publication/services/content/Iterator.js +1 -0
  85. package/dist/publication/services/content/element/attributes.js +1 -0
  86. package/dist/publication/services/content/element/element.js +1 -0
  87. package/dist/publication/services/content/element/text_role.js +1 -0
  88. package/dist/publication/services/content/iterators/HTMLResourceContentIterator.js +1 -0
  89. package/dist/publication/services/content/iterators/PDFTextContentIterator.js +1 -0
  90. package/dist/publication/services/content/iterators/PublicationContentIterator.js +1 -0
  91. package/dist/publication/services/content/iterators/helpers.js +1 -0
  92. package/dist/publication/services/timeline/Timeline.js +1 -0
  93. package/dist/publication/services/timeline/audio.js +1 -0
  94. package/dist/publication/services/timeline/html.js +1 -0
  95. package/dist/publication/services/timeline/index.js +1 -0
  96. package/dist/util/JSONParse.js +1 -0
  97. package/dist/util/URITemplate.js +1 -0
  98. package/dist/util/mediatype/MediaType.js +1 -0
  99. package/dist/util/npt.js +1 -0
  100. package/dist/util/tokenizer/TextTokenizer.js +1 -0
  101. package/dist/util/tokenizer/tokenize-english/abbreviations.js +1 -0
  102. package/dist/util/tokenizer/tokenize-english/index.js +2 -0
  103. package/dist/util/tokenizer/tokenize-english/utils.js +1 -0
  104. package/dist/util/tokenizer/tokenize-text/index.js +1 -0
  105. package/dist/util/tokenizer/tokenize-text/tokens.js +1 -0
  106. package/package.json +34 -27
  107. package/src/locales/publication-metadata/ar.json +402 -0
  108. package/src/locales/publication-metadata/brh.json +1 -0
  109. package/src/locales/publication-metadata/da.json +310 -0
  110. package/src/locales/publication-metadata/el.json +310 -0
  111. package/src/locales/publication-metadata/en.json +310 -0
  112. package/src/locales/publication-metadata/es.json +333 -0
  113. package/src/locales/publication-metadata/et.json +310 -0
  114. package/src/locales/publication-metadata/fi.json +310 -0
  115. package/src/locales/publication-metadata/fr.json +333 -0
  116. package/src/locales/publication-metadata/he.json +9 -0
  117. package/src/locales/publication-metadata/it.json +333 -0
  118. package/src/locales/publication-metadata/lt.json +8 -0
  119. package/src/locales/publication-metadata/pl.json +333 -0
  120. package/src/locales/publication-metadata/pt_PT.json +329 -0
  121. package/src/locales/publication-metadata/sv.json +310 -0
  122. package/src/locales/publication-metadata/tr.json +51 -0
  123. package/src/locales/publication-metadata/uk.json +1 -0
  124. package/src/publication/Link.ts +2 -6
  125. package/src/publication/Locator.ts +21 -3
  126. package/src/publication/Manifest.ts +5 -7
  127. package/src/publication/Publication.ts +2 -1
  128. package/src/publication/accessibility/Localization.ts +12 -14
  129. package/src/publication/accessibility/SupportedLanguages.ts +1 -1
  130. package/src/publication/encryption/Properties.ts +3 -15
  131. package/src/publication/epub/Metadata.ts +6 -12
  132. package/src/publication/epub/Properties.ts +3 -13
  133. package/src/publication/epub/Publication.ts +18 -39
  134. package/src/publication/html/Locations.ts +54 -101
  135. package/src/publication/opds/Properties.ts +21 -66
  136. package/src/publication/opds/Publication.ts +3 -9
  137. package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +3 -1
  138. package/src/publication/services/timeline/Timeline.ts +305 -59
  139. package/src/publication/services/timeline/TimelineItem.ts +3 -3
  140. package/src/publication/services/timeline/audio.ts +31 -0
  141. package/src/publication/services/timeline/html.ts +5 -0
  142. package/src/publication/services/timeline/index.ts +12 -0
  143. package/src/util/npt.ts +19 -0
  144. package/types/src/publication/encryption/Properties.d.ts +2 -9
  145. package/types/src/publication/epub/Metadata.d.ts +3 -6
  146. package/types/src/publication/epub/Properties.d.ts +2 -10
  147. package/types/src/publication/epub/Publication.d.ts +7 -18
  148. package/types/src/publication/html/Locations.d.ts +15 -44
  149. package/types/src/publication/opds/Properties.d.ts +8 -36
  150. package/types/src/publication/opds/Publication.d.ts +2 -5
  151. package/types/src/publication/services/timeline/Timeline.d.ts +91 -12
  152. package/types/src/publication/services/timeline/TimelineItem.d.ts +3 -3
  153. package/types/src/publication/services/timeline/audio.d.ts +4 -0
  154. package/types/src/publication/services/timeline/html.d.ts +4 -0
  155. package/types/src/publication/services/timeline/index.d.ts +6 -0
  156. package/types/src/util/npt.d.ts +10 -0
  157. package/dist/ar-DyHX_uy2.js +0 -7
  158. package/dist/da-Dct0PS3E.js +0 -7
  159. package/dist/fr-C5HEel98.js +0 -7
  160. package/dist/index.umd.cjs +0 -3
  161. package/dist/it-DFOBoXGy.js +0 -7
  162. package/dist/pt_PT-Di3sVjze.js +0 -7
  163. package/dist/sv-BfzAFsVN.js +0 -7
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, Readium Foundation
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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};