@readium/navigator 2.5.0-beta.2 → 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.
Files changed (29) hide show
  1. package/dist/{ReadiumCSS-after-C-T_0paD.js → ReadiumCSS-after-AX2xHXM6.js} +3 -3
  2. package/dist/{ReadiumCSS-after-lr-n3fz2.js → ReadiumCSS-after-DIfxADJu.js} +4 -4
  3. package/dist/{ReadiumCSS-after-B_e3a-PY.js → ReadiumCSS-after-Djsq77vV.js} +10 -10
  4. package/dist/{ReadiumCSS-after-mXeKKPap.js → ReadiumCSS-after-DwG-6hYO.js} +4 -4
  5. package/dist/{ReadiumCSS-before-CfXPAGaQ.js → ReadiumCSS-before-B8zaPxhu.js} +1 -1
  6. package/dist/{ReadiumCSS-before-KVen5ceo.js → ReadiumCSS-before-BA9Irzag.js} +1 -1
  7. package/dist/{ReadiumCSS-before-CrNWvuyE.js → ReadiumCSS-before-Cz5-ynli.js} +1 -1
  8. package/dist/{ReadiumCSS-before-Bjd3POej.js → ReadiumCSS-before-DKjdmFso.js} +1 -1
  9. package/dist/{ReadiumCSS-default-C63bYOYF.js → ReadiumCSS-default-BGrBd7Sk.js} +1 -1
  10. package/dist/{ReadiumCSS-default-BKAG5pGU.js → ReadiumCSS-default-CcWmjgaR.js} +1 -1
  11. package/dist/{ReadiumCSS-default-DnlgDaBu.js → ReadiumCSS-default-DsgDIxGa.js} +1 -1
  12. package/dist/{ReadiumCSS-default-CclvbeNC.js → ReadiumCSS-default-DzJEDDcb.js} +1 -1
  13. package/dist/index.js +75 -71
  14. package/dist/index.umd.cjs +58 -58
  15. package/package.json +2 -2
  16. package/src/epub/EpubNavigator.ts +1 -1
  17. package/src/epub/css/ReadiumCSS.ts +12 -3
  18. package/src/epub/frame/FrameBlobBuilder.ts +1 -1
  19. package/src/epub/index.ts +0 -1
  20. package/src/helpers/dimensions.ts +7 -0
  21. package/src/helpers/index.ts +1 -0
  22. package/src/injection/epubInjectables.ts +1 -1
  23. package/src/webpub/WebPubNavigator.ts +1 -1
  24. package/types/src/epub/css/ReadiumCSS.d.ts +1 -0
  25. package/types/src/epub/index.d.ts +0 -1
  26. package/types/src/helpers/dimensions.d.ts +1 -0
  27. package/types/src/helpers/index.d.ts +1 -0
  28. /package/src/{epub/helpers → helpers}/scriptMode.ts +0 -0
  29. /package/types/src/{epub/helpers → helpers}/scriptMode.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.5.0-beta.2",
3
+ "version": "2.5.0",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -50,7 +50,7 @@
50
50
  "generate:css-selector": "node scripts/generate-css-selector.js"
51
51
  },
52
52
  "devDependencies": {
53
- "@readium/css": "^2.0.1",
53
+ "@readium/css": "^2.0.2",
54
54
  "@readium/navigator-html-injectables": "workspace:*",
55
55
  "@readium/shared": "workspace:*",
56
56
  "@types/path-browserify": "^1.0.3",
@@ -19,7 +19,7 @@ import { IInjectableRule, IInjectablesConfig } from "../injection/Injectable.ts"
19
19
  import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator.ts";
20
20
  import { NavigatorProtector, NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT } from "../protection/NavigatorProtector.ts";
21
21
  import { KeyboardPeripherals, NAVIGATOR_KEYBOARD_PERIPHERAL_EVENT } from "../peripherals/KeyboardPeripherals.ts";
22
- import { getScriptMode } from "./helpers/scriptMode.ts";
22
+ import { getScriptMode } from "../helpers/scriptMode.ts";
23
23
 
24
24
  export type ManagerEventKey = "zoom";
25
25
 
@@ -1,5 +1,5 @@
1
1
  import { LineLengths } from "../../helpers/index.ts";
2
- import { getContentWidth } from "../../helpers/dimensions.ts";
2
+ import { getContentWidth, getContentHeight } from "../../helpers/dimensions.ts";
3
3
  import { EpubSettings } from "../preferences/EpubSettings.ts";
4
4
  import { IUserProperties, RSProperties, UserProperties } from "./Properties.ts";
5
5
 
@@ -138,8 +138,7 @@ export class ReadiumCSS {
138
138
  // (width) must not be constrained by line-length at all — use the full
139
139
  // parent width minus the known constraint.
140
140
  if (this.isCJKVertical) {
141
- const w = Math.round(getContentWidth(this.containerParent) - this.constraint);
142
- return { colCount: undefined, effectiveContainerWidth: w, effectiveLineLength: w };
141
+ return this.computeCJKVerticalLength(scale, ignoreCompensation);
143
142
  }
144
143
 
145
144
  const isScroll = scroll ?? this.userProperties.view === "scroll";
@@ -246,6 +245,16 @@ export class ReadiumCSS {
246
245
  };
247
246
  }
248
247
 
248
+ private computeCJKVerticalLength(scale: number | null, ignoreCompensation: boolean | null) {
249
+ const w = Math.round(getContentWidth(this.containerParent) - this.constraint);
250
+ const h = Math.round(getContentHeight(this.containerParent));
251
+ const metrics = this.getCompensatedMetrics(scale, ignoreCompensation);
252
+ const effectiveLineLength = metrics.maximal !== null
253
+ ? Math.min(Math.round(metrics.maximal * metrics.zoomCompensation), h)
254
+ : h;
255
+ return { colCount: undefined, effectiveContainerWidth: w, effectiveLineLength };
256
+ }
257
+
249
258
  // This behaves as paginate where colCount = 1
250
259
  private computeScrollLength(scale: number | null, ignoreCompensation: boolean | null) {
251
260
  const constrainedWidth = Math.round(getContentWidth(this.containerParent) - (this.constraint));
@@ -1,6 +1,6 @@
1
1
  import { Link, MediaType, Publication, ReadingProgression } from "@readium/shared";
2
2
  import { Injector } from "../../injection/Injector.ts";
3
- import { getScriptMode } from "../helpers/scriptMode.ts";
3
+ import { getScriptMode } from "../../helpers/scriptMode.ts";
4
4
 
5
5
  const csp = (domains: string[]) => {
6
6
  const d = domains.join(" ");
package/src/epub/index.ts CHANGED
@@ -3,4 +3,3 @@ export * from "./frame/index.ts";
3
3
  export * from "./fxl/index.ts";
4
4
  export * from "./preferences/index.ts";
5
5
  export * from "./css/index.ts";
6
- export { getScriptMode, type ScriptMode } from "./helpers/scriptMode.ts";
@@ -11,3 +11,10 @@ export function getContentWidth(el: Element) {
11
11
  return el.clientWidth - paddingLeft - paddingRight;
12
12
  }
13
13
 
14
+ export function getContentHeight(el: Element) {
15
+ const cStyle = getComputedStyle(el);
16
+ const paddingTop = parseFloat(cStyle.paddingTop || "0");
17
+ const paddingBottom = parseFloat(cStyle.paddingBottom || "0");
18
+ return el.clientHeight - paddingTop - paddingBottom;
19
+ }
20
+
@@ -1,2 +1,3 @@
1
1
  export * from "./lineLength.ts";
2
2
  export * from './sML.ts';
3
+ export * from './scriptMode.ts';
@@ -1,7 +1,7 @@
1
1
  import { IInjectableRule, IInjectable } from "../injection/Injectable.ts";
2
2
  import { stripJS, stripCSS } from "../helpers/minify.ts";
3
3
  import { Metadata, Layout, Link } from "@readium/shared";
4
- import { getScriptMode } from "../epub/helpers/scriptMode.ts";
4
+ import { getScriptMode } from "../helpers/scriptMode.ts";
5
5
 
6
6
  import cssSelectorGeneratorContent from "../dom/_readium_cssSelectorGenerator.js?raw";
7
7
  import executionPreventionContent from "../dom/_readium_executionPrevention.js?raw";
@@ -7,7 +7,7 @@ import * as path from "path-browserify";
7
7
  import { WebPubFrameManager } from "./WebPubFrameManager.ts";
8
8
 
9
9
  import { ManagerEventKey } from "../epub/EpubNavigator.ts";
10
- import { getScriptMode } from "../epub/helpers/scriptMode.ts";
10
+ import { getScriptMode } from "../helpers/scriptMode.ts";
11
11
  import { WebPubCSS } from "./css/WebPubCSS.ts";
12
12
  import { WebUserProperties, WebRSProperties } from "./css/Properties.ts";
13
13
  import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences.ts";
@@ -24,6 +24,7 @@ export declare class ReadiumCSS {
24
24
  private updateLayout;
25
25
  private getCompensatedMetrics;
26
26
  private paginate;
27
+ private computeCJKVerticalLength;
27
28
  private computeScrollLength;
28
29
  setContainerWidth(): void;
29
30
  resizeHandler(): void;
@@ -3,4 +3,3 @@ export * from "./frame/index.ts";
3
3
  export * from "./fxl/index.ts";
4
4
  export * from "./preferences/index.ts";
5
5
  export * from "./css/index.ts";
6
- export { getScriptMode, type ScriptMode } from "./helpers/scriptMode.ts";
@@ -5,3 +5,4 @@
5
5
  * @param el - The element to measure.
6
6
  */
7
7
  export declare function getContentWidth(el: Element): number;
8
+ export declare function getContentHeight(el: Element): number;
@@ -1,2 +1,3 @@
1
1
  export * from "./lineLength.ts";
2
2
  export * from './sML.ts';
3
+ export * from './scriptMode.ts';
File without changes