@readium/navigator 2.4.0-alpha.7 → 2.4.0-alpha.9
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 +64 -67
- package/dist/index.umd.cjs +4 -4
- package/package.json +3 -3
- package/src/epub/frame/FrameBlobBuilder.ts +3 -9
- package/src/epub/frame/FrameManager.ts +3 -3
- package/src/epub/fxl/FXLFrameManager.ts +14 -11
- package/src/webpub/WebPubFrameManager.ts +3 -3
- package/types/src/epub/fxl/FXLFrameManager.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/navigator",
|
|
3
|
-
"version": "2.4.0-alpha.
|
|
3
|
+
"version": "2.4.0-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Next generation SDK for publications in Web Apps",
|
|
6
6
|
"author": "readium",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"typescript-plugin-css-modules": "^5.2.0",
|
|
56
56
|
"user-agent-data-types": "^0.4.2",
|
|
57
57
|
"vite": "^7.3.1",
|
|
58
|
-
"@readium/
|
|
59
|
-
"@readium/
|
|
58
|
+
"@readium/navigator-html-injectables": "2.3.0",
|
|
59
|
+
"@readium/shared": "2.1.5"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"clean": "rimraf types dist",
|
|
@@ -76,14 +76,8 @@ export default class FrameBlobBuilder {
|
|
|
76
76
|
|
|
77
77
|
// Load the HTML resource
|
|
78
78
|
const link = await this.currentResource.link();
|
|
79
|
-
const
|
|
80
|
-
if(!
|
|
81
|
-
|
|
82
|
-
const doc = new DOMParser().parseFromString(
|
|
83
|
-
txt,
|
|
84
|
-
link.mediaType.string as DOMParserSupportedType
|
|
85
|
-
);
|
|
86
|
-
|
|
79
|
+
const doc = await this.currentResource.readAsXML() as HTMLDocument;
|
|
80
|
+
if(!doc) throw new Error(`Failed reading item ${link.href}`);
|
|
87
81
|
const perror = doc.querySelector("parsererror");
|
|
88
82
|
if (perror) {
|
|
89
83
|
const details = perror.querySelector("div");
|
|
@@ -118,7 +112,7 @@ export default class FrameBlobBuilder {
|
|
|
118
112
|
const simg = document.createElement("img");
|
|
119
113
|
simg.src = burl || "";
|
|
120
114
|
simg.alt = link.title || "";
|
|
121
|
-
simg.
|
|
115
|
+
await simg.decode(); // Reduce repaints
|
|
122
116
|
doc.body.appendChild(simg);
|
|
123
117
|
|
|
124
118
|
// Apply resource injections if injection service is provided
|
|
@@ -25,7 +25,7 @@ export class FrameManager {
|
|
|
25
25
|
this.frame.sandbox.value = "allow-same-origin allow-scripts";
|
|
26
26
|
this.frame.classList.add("readium-navigator-iframe");
|
|
27
27
|
this.frame.style.visibility = "hidden";
|
|
28
|
-
this.frame.
|
|
28
|
+
this.frame.ariaHidden = "true";
|
|
29
29
|
this.frame.style.opacity = "0";
|
|
30
30
|
this.frame.style.position = "absolute";
|
|
31
31
|
this.frame.style.pointerEvents = "none";
|
|
@@ -100,7 +100,7 @@ export class FrameManager {
|
|
|
100
100
|
async hide(): Promise<void> {
|
|
101
101
|
if(this.destroyed) return;
|
|
102
102
|
this.frame.style.visibility = "hidden";
|
|
103
|
-
this.frame.
|
|
103
|
+
this.frame.ariaHidden = "true";
|
|
104
104
|
this.frame.style.opacity = "0";
|
|
105
105
|
this.frame.style.pointerEvents = "none";
|
|
106
106
|
this.hidden = true;
|
|
@@ -129,9 +129,9 @@ export class FrameManager {
|
|
|
129
129
|
|
|
130
130
|
const remove = () => {
|
|
131
131
|
this.frame.style.removeProperty("visibility");
|
|
132
|
-
this.frame.style.removeProperty("aria-hidden");
|
|
133
132
|
this.frame.style.removeProperty("opacity");
|
|
134
133
|
this.frame.style.removeProperty("pointer-events");
|
|
134
|
+
this.frame.ariaHidden = null;
|
|
135
135
|
this.hidden = false;
|
|
136
136
|
|
|
137
137
|
if (sML.UA.WebKit) {
|
|
@@ -21,7 +21,7 @@ export class FXLFrameManager {
|
|
|
21
21
|
public debugHref: string;
|
|
22
22
|
private loadPromise: Promise<Window> | undefined;
|
|
23
23
|
private showPromise: Promise<void> | undefined;
|
|
24
|
-
private
|
|
24
|
+
private viewportSize: { width: number, height: number } | undefined = undefined;
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
27
|
peripherals: FXLPeripherals,
|
|
@@ -41,7 +41,7 @@ export class FXLFrameManager {
|
|
|
41
41
|
this.frame.classList.add("blank");
|
|
42
42
|
this.frame.scrolling = "no";
|
|
43
43
|
this.frame.style.visibility = "hidden";
|
|
44
|
-
this.frame.
|
|
44
|
+
this.frame.ariaHidden = "true";
|
|
45
45
|
this.frame.style.display = "none";
|
|
46
46
|
this.frame.style.position = "absolute";
|
|
47
47
|
this.frame.style.pointerEvents = "none";
|
|
@@ -52,9 +52,9 @@ export class FXLFrameManager {
|
|
|
52
52
|
this.frame.dataset.originalHref = debugHref;
|
|
53
53
|
this.source = "about:blank";
|
|
54
54
|
|
|
55
|
-
// NEW
|
|
56
55
|
this.wrapper = document.createElement("div");
|
|
57
56
|
this.wrapper.style.position = "relative";
|
|
57
|
+
this.wrapper.style.contain = "strict";
|
|
58
58
|
this.wrapper.style.float = this.wrapper.style.cssFloat = direction === ReadingProgression.rtl ? "right" : "left";
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -108,7 +108,7 @@ export class FXLFrameManager {
|
|
|
108
108
|
|
|
109
109
|
// Parses the page size from the viewport meta tag of the loaded resource.
|
|
110
110
|
loadPageSize(): { width: number, height: number } {
|
|
111
|
-
if(this.
|
|
111
|
+
if(this.viewportSize) return this.viewportSize;
|
|
112
112
|
const wnd = this.frame.contentWindow!;
|
|
113
113
|
|
|
114
114
|
// Try to get the page size from the viewport meta tag
|
|
@@ -125,16 +125,17 @@ export class FXLFrameManager {
|
|
|
125
125
|
else if(match[1] === "height")
|
|
126
126
|
height = Number.parseFloat(match[2]);
|
|
127
127
|
}
|
|
128
|
-
if(width > 0 && height > 0)
|
|
129
|
-
|
|
128
|
+
if(width > 0 && height > 0) {
|
|
129
|
+
this.viewportSize = { width, height };
|
|
130
|
+
return this.viewportSize;
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
// Otherwise get it from the size of the loaded content
|
|
133
|
-
|
|
135
|
+
return {
|
|
134
136
|
width: wnd.document.body.scrollWidth,
|
|
135
137
|
height: wnd.document.body.scrollHeight
|
|
136
|
-
}
|
|
137
|
-
return this.pageSize;
|
|
138
|
+
}
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
update(page?: Page) {
|
|
@@ -158,7 +159,7 @@ export class FXLFrameManager {
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
this.frame.style.removeProperty("visibility");
|
|
161
|
-
this.frame.
|
|
162
|
+
this.frame.ariaHidden = null;
|
|
162
163
|
this.frame.style.removeProperty("pointer-events");
|
|
163
164
|
this.frame.classList.remove("blank");
|
|
164
165
|
this.frame.classList.add("loaded");
|
|
@@ -174,7 +175,7 @@ export class FXLFrameManager {
|
|
|
174
175
|
if(!this.loaded) return;
|
|
175
176
|
this.deselect();
|
|
176
177
|
this.frame.style.visibility = "hidden";
|
|
177
|
-
this.frame.
|
|
178
|
+
this.frame.ariaHidden = "true";
|
|
178
179
|
this.frame.style.pointerEvents = "none";
|
|
179
180
|
this.frame.classList.add("blank");
|
|
180
181
|
this.frame.classList.remove("loaded");
|
|
@@ -192,6 +193,8 @@ export class FXLFrameManager {
|
|
|
192
193
|
this.source = "about:blank";
|
|
193
194
|
this.frame.contentWindow!.location.replace("about:blank");
|
|
194
195
|
this.frame.style.display = "none";
|
|
196
|
+
this.frame.style.width = "0px";
|
|
197
|
+
this.frame.style.height = "0px";
|
|
195
198
|
});
|
|
196
199
|
}
|
|
197
200
|
|
|
@@ -23,7 +23,7 @@ export class WebPubFrameManager {
|
|
|
23
23
|
this.frame = document.createElement("iframe");
|
|
24
24
|
this.frame.classList.add("readium-navigator-iframe");
|
|
25
25
|
this.frame.style.visibility = "hidden";
|
|
26
|
-
this.frame.
|
|
26
|
+
this.frame.ariaHidden = "true";
|
|
27
27
|
this.frame.style.opacity = "0";
|
|
28
28
|
this.frame.style.position = "absolute";
|
|
29
29
|
this.frame.style.pointerEvents = "none";
|
|
@@ -98,7 +98,7 @@ export class WebPubFrameManager {
|
|
|
98
98
|
async hide(): Promise<void> {
|
|
99
99
|
if(this.destroyed) return;
|
|
100
100
|
this.frame.style.visibility = "hidden";
|
|
101
|
-
this.frame.
|
|
101
|
+
this.frame.ariaHidden = "true";
|
|
102
102
|
this.frame.style.opacity = "0";
|
|
103
103
|
this.frame.style.pointerEvents = "none";
|
|
104
104
|
this.hidden = true;
|
|
@@ -129,7 +129,7 @@ export class WebPubFrameManager {
|
|
|
129
129
|
this.applyContentProtection();
|
|
130
130
|
const remove = () => {
|
|
131
131
|
this.frame.style.removeProperty("visibility");
|
|
132
|
-
this.frame.
|
|
132
|
+
this.frame.ariaHidden = null;
|
|
133
133
|
this.frame.style.removeProperty("opacity");
|
|
134
134
|
this.frame.style.removeProperty("pointer-events");
|
|
135
135
|
this.hidden = false;
|
|
@@ -17,7 +17,7 @@ export declare class FXLFrameManager {
|
|
|
17
17
|
debugHref: string;
|
|
18
18
|
private loadPromise;
|
|
19
19
|
private showPromise;
|
|
20
|
-
private
|
|
20
|
+
private viewportSize;
|
|
21
21
|
constructor(peripherals: FXLPeripherals, direction: ReadingProgression, debugHref: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
|
|
22
22
|
load(modules: ModuleName[], source: string): Promise<Window>;
|
|
23
23
|
loadPageSize(): {
|