mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Resource loading fixes
This commit is contained in:
parent
4458c7d584
commit
7cf8dc151b
7 changed files with 3288 additions and 4971 deletions
8217
package-lock.json
generated
8217
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,9 @@
|
||||||
"author": "fchasen@gmail.com",
|
"author": "fchasen@gmail.com",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.17.9",
|
"@babel/cli": "^7.19.3",
|
||||||
|
"@babel/core": "^7.20.5",
|
||||||
|
"@babel/preset-env": "^7.20.2",
|
||||||
"@rollup/plugin-babel": "^5.3.1",
|
"@rollup/plugin-babel": "^5.3.1",
|
||||||
"@rollup/plugin-commonjs": "^21.0.3",
|
"@rollup/plugin-commonjs": "^21.0.3",
|
||||||
"@rollup/plugin-node-resolve": "^13.1.3",
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
||||||
|
|
|
@ -5,7 +5,9 @@ import Contents from "./rendition/contents.js";
|
||||||
import Layout from "./rendition/layout.js";
|
import Layout from "./rendition/layout.js";
|
||||||
import Epub from "./epub/epub.js";
|
import Epub from "./epub/epub.js";
|
||||||
import Manifest from "./manifest/manifest.js";
|
import Manifest from "./manifest/manifest.js";
|
||||||
import { generateLocations } from "./utils/locations.js"
|
import { generateLocations } from "./utils/locations.js";
|
||||||
|
import * as core from "./utils/core.js";
|
||||||
|
import * as url from "./utils/url.js";
|
||||||
// import ePub from "./epub.js";
|
// import ePub from "./epub.js";
|
||||||
export {
|
export {
|
||||||
Publication,
|
Publication,
|
||||||
|
@ -15,5 +17,7 @@ export {
|
||||||
Rendition,
|
Rendition,
|
||||||
Contents,
|
Contents,
|
||||||
Layout,
|
Layout,
|
||||||
generateLocations
|
generateLocations,
|
||||||
|
core,
|
||||||
|
url
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,8 +10,8 @@ import { createUrl, resolve } from "../utils/url.js";
|
||||||
* @example new Manifest(manifest)
|
* @example new Manifest(manifest)
|
||||||
*/
|
*/
|
||||||
class Manifest extends Publication {
|
class Manifest extends Publication {
|
||||||
constructor(url, options) {
|
constructor(url, requestMethod, requestOptions) {
|
||||||
super();
|
super(null, requestMethod, requestOptions);
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
this.opened = this.open(url);
|
this.opened = this.open(url);
|
||||||
|
|
|
@ -153,7 +153,12 @@ class Publication {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (const item of items) {
|
for (let item of items) {
|
||||||
|
if (typeof item === "string") {
|
||||||
|
item = {
|
||||||
|
url: item
|
||||||
|
};
|
||||||
|
}
|
||||||
item.url = resolve(this.url, item.url || item.href);
|
item.url = resolve(this.url, item.url || item.href);
|
||||||
// TEMP hack for handling EpubCFI
|
// TEMP hack for handling EpubCFI
|
||||||
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
||||||
|
@ -206,7 +211,12 @@ class Publication {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (const item of items) {
|
for (let item of items) {
|
||||||
|
if (typeof item === "string") {
|
||||||
|
item = {
|
||||||
|
url: item
|
||||||
|
};
|
||||||
|
}
|
||||||
item.url = this.resolve(item.url || item.href);
|
item.url = this.resolve(item.url || item.href);
|
||||||
// TEMP hack for handling EpubCFI
|
// TEMP hack for handling EpubCFI
|
||||||
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Resource {
|
||||||
canonical: item.canonical,
|
canonical: item.canonical,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
encoding: item.encoding || lookup(item.url),
|
encoding: item.encoding || lookup(item.url),
|
||||||
properites: item.properites,
|
properites: item.properites || [],
|
||||||
rel: item.rel || [],
|
rel: item.rel || [],
|
||||||
name: item.name,
|
name: item.name,
|
||||||
cfiPos: item.cfiPos,
|
cfiPos: item.cfiPos,
|
||||||
|
@ -80,7 +80,7 @@ class Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
set properites(properites) {
|
set properites(properites) {
|
||||||
this.data.id = properites;
|
this.data.properites = properites;
|
||||||
}
|
}
|
||||||
|
|
||||||
get rel() {
|
get rel() {
|
||||||
|
|
|
@ -42,8 +42,12 @@ export function extension(inputUrl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolve(inputUrl, path) {
|
export function resolve(inputUrl, path) {
|
||||||
const url = createUrl(inputUrl);
|
const url = createUrl(inputUrl);
|
||||||
return new URL(path, url).href;
|
if (url.origin === "http://example.com") {
|
||||||
|
return new URL(path, url).href.replace("http://example.com/", "");
|
||||||
|
} else {
|
||||||
|
return new URL(path, url).href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function relative(inputUrl, path) {
|
export function relative(inputUrl, path) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue