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",
|
||||
"license": "BSD-2-Clause",
|
||||
"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-commonjs": "^21.0.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 Epub from "./epub/epub.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";
|
||||
export {
|
||||
Publication,
|
||||
|
@ -15,5 +17,7 @@ export {
|
|||
Rendition,
|
||||
Contents,
|
||||
Layout,
|
||||
generateLocations
|
||||
generateLocations,
|
||||
core,
|
||||
url
|
||||
};
|
||||
|
|
|
@ -10,8 +10,8 @@ import { createUrl, resolve } from "../utils/url.js";
|
|||
* @example new Manifest(manifest)
|
||||
*/
|
||||
class Manifest extends Publication {
|
||||
constructor(url, options) {
|
||||
super();
|
||||
constructor(url, requestMethod, requestOptions) {
|
||||
super(null, requestMethod, requestOptions);
|
||||
|
||||
if (url) {
|
||||
this.opened = this.open(url);
|
||||
|
|
|
@ -153,7 +153,12 @@ class Publication {
|
|||
return;
|
||||
}
|
||||
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);
|
||||
// TEMP hack for handling EpubCFI
|
||||
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
||||
|
@ -206,7 +211,12 @@ class Publication {
|
|||
return;
|
||||
}
|
||||
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);
|
||||
// TEMP hack for handling EpubCFI
|
||||
const id = encodeURIComponent(filename(item.url).split(".")[0]);
|
||||
|
|
|
@ -19,7 +19,7 @@ class Resource {
|
|||
canonical: item.canonical,
|
||||
type: item.type,
|
||||
encoding: item.encoding || lookup(item.url),
|
||||
properites: item.properites,
|
||||
properites: item.properites || [],
|
||||
rel: item.rel || [],
|
||||
name: item.name,
|
||||
cfiPos: item.cfiPos,
|
||||
|
@ -80,7 +80,7 @@ class Resource {
|
|||
}
|
||||
|
||||
set properites(properites) {
|
||||
this.data.id = properites;
|
||||
this.data.properites = properites;
|
||||
}
|
||||
|
||||
get rel() {
|
||||
|
|
|
@ -42,8 +42,12 @@ export function extension(inputUrl) {
|
|||
}
|
||||
|
||||
export function resolve(inputUrl, path) {
|
||||
const url = createUrl(inputUrl);
|
||||
return new URL(path, url).href;
|
||||
const url = createUrl(inputUrl);
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue