@d-i-t-a/reader 2.5.1 → 3.0.0-alpha.2
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/esm/index.js +8442 -10149
- package/dist/esm/index.js.map +4 -4
- package/dist/reader.js +70 -86
- package/dist/reader.js.map +4 -4
- package/dist/types/model/Link.d.ts +8 -10
- package/dist/types/model/Locator.d.ts +4 -41
- package/dist/types/model/Publication.d.ts +4 -51
- package/dist/types/model/v3/Link.d.ts +42 -0
- package/dist/types/model/v3/Locator.d.ts +55 -0
- package/dist/types/model/v3/MediaOverlayNode.d.ts +28 -0
- package/dist/types/model/v3/Publication.d.ts +51 -0
- package/dist/types/model/v3/index.d.ts +11 -0
- package/dist/types/modules/mediaoverlays/MediaOverlayModule.d.ts +1 -1
- package/dist/types/modules/search/searchWithDomSeek.d.ts +2 -2
- package/dist/types/reader.d.ts +2 -2
- package/dist/types/utils/JsonUtil.d.ts +19 -3
- package/package.json +2 -3
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
contentWeight?: number;
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from "./v3/Link" instead. This file re-exports for backwards compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { Link, D2Link, Links } from "./v3/Link";
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated No longer needed — @readium/shared uses camelCase natively.
|
|
7
|
+
* Kept for backwards compatibility with code that calls convertAndCamel().
|
|
8
|
+
*/
|
|
11
9
|
export declare function convertAndCamel(o: any): any;
|
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
title?: string;
|
|
6
|
-
locations: Locations;
|
|
7
|
-
text?: LocatorText;
|
|
8
|
-
displayInfo?: any;
|
|
9
|
-
}
|
|
10
|
-
export interface LocatorText {
|
|
11
|
-
after?: string;
|
|
12
|
-
before?: string;
|
|
13
|
-
highlight?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface Locations {
|
|
16
|
-
fragment?: string;
|
|
17
|
-
progression?: number;
|
|
18
|
-
position?: number;
|
|
19
|
-
totalProgression?: number;
|
|
20
|
-
remainingPositions?: number;
|
|
21
|
-
totalRemainingPositions?: number;
|
|
22
|
-
}
|
|
23
|
-
export interface ReadingPosition extends Locator {
|
|
24
|
-
created: Date;
|
|
25
|
-
}
|
|
26
|
-
export interface Bookmark extends Locator {
|
|
27
|
-
id?: any;
|
|
28
|
-
created: Date;
|
|
29
|
-
}
|
|
30
|
-
export declare enum AnnotationMarker {
|
|
31
|
-
Highlight = 0,
|
|
32
|
-
Underline = 1,
|
|
33
|
-
Bookmark = 2,
|
|
34
|
-
Custom = 3,
|
|
35
|
-
Comment = 4
|
|
36
|
-
}
|
|
37
|
-
export interface Annotation extends Locator {
|
|
38
|
-
id?: any;
|
|
39
|
-
created: Date;
|
|
40
|
-
highlight?: IHighlight;
|
|
41
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from "./v3/Locator" instead. This file re-exports for backwards compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { Locator, LocatorText, Locations, ReadingPosition, Bookmark, Annotation, AnnotationMarker, } from "./v3/Locator";
|
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { GetContentBytesLength, RequestConfig } from "../navigator/IFrameNavigator";
|
|
6
|
-
import { SampleRead } from "../navigator/IFrameNavigator";
|
|
7
|
-
export declare class Publication extends R2Publication {
|
|
8
|
-
manifestUrl: URL;
|
|
9
|
-
positions: Array<Locator>;
|
|
10
|
-
sample?: SampleRead;
|
|
11
|
-
/**
|
|
12
|
-
* Initialize a publication from a manifest URL
|
|
13
|
-
*/
|
|
14
|
-
static fromUrl(url: URL, requestConfig?: RequestConfig): Promise<Publication>;
|
|
15
|
-
get readingOrder(): Link[];
|
|
16
|
-
get resources(): Link[];
|
|
17
|
-
get tableOfContents(): R2Link[];
|
|
18
|
-
private limitedTOC;
|
|
19
|
-
get landmarks(): R2Link[];
|
|
20
|
-
get pageList(): R2Link[] | undefined;
|
|
21
|
-
get isFixedLayout(): boolean;
|
|
22
|
-
get isReflowable(): boolean;
|
|
23
|
-
get layout(): "fixed" | "reflowable";
|
|
24
|
-
get hasMediaOverlays(): boolean;
|
|
25
|
-
getStartLink(): Link | undefined;
|
|
26
|
-
getPreviousSpineItem(href: string): Link | undefined;
|
|
27
|
-
getNextSpineItem(href: string): Link | undefined;
|
|
28
|
-
getSpineItem(href: string): Link | undefined;
|
|
29
|
-
getSpineIndex(href: string): number | undefined;
|
|
30
|
-
getAbsoluteHref(href: string): string;
|
|
31
|
-
getRelativeHref(href: string): string;
|
|
32
|
-
getTOCItemAbsolute(href: string): Link | undefined;
|
|
33
|
-
getTOCItem(href: string): Link | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* positionsByHref
|
|
36
|
-
*/
|
|
37
|
-
positionsByHref(href: string): Locator[];
|
|
38
|
-
/**
|
|
39
|
-
* Fetches the contents to build up the positions manually,
|
|
40
|
-
* at least for fluid layout pubs
|
|
41
|
-
*/
|
|
42
|
-
autoGeneratePositions(requestConfig?: RequestConfig, getContentBytesLength?: GetContentBytesLength): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Fetches the positions from a given service href
|
|
45
|
-
*/
|
|
46
|
-
fetchPositionsFromService(href: string, requestConfig?: RequestConfig): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Fetches weights from a given service href
|
|
49
|
-
*/
|
|
50
|
-
fetchWeightsFromService(href: string, requestConfig?: RequestConfig): Promise<void>;
|
|
51
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from "./v3/Publication" instead. This file re-exports for backwards compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { Publication } from "./v3/Publication";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Link as ReadiumLink, Links as ReadiumLinks } from "@readium/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Simple link interface for external use.
|
|
4
|
+
*/
|
|
5
|
+
export interface D2Link {
|
|
6
|
+
href: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* R2D2BC Link — extends @readium/shared Link with R2D2BC extensions.
|
|
12
|
+
*
|
|
13
|
+
* All property access uses camelCase directly (href, type, title, etc.).
|
|
14
|
+
* No Proxy, no PascalCase compat layer — clean code.
|
|
15
|
+
*
|
|
16
|
+
* R2D2BC extensions: contentLength, contentWeight, mediaOverlayNode
|
|
17
|
+
*/
|
|
18
|
+
export declare class Link extends ReadiumLink {
|
|
19
|
+
/** Byte size of the resource (used for position calculation) */
|
|
20
|
+
contentLength?: number;
|
|
21
|
+
/** Percentage weight for reading progression */
|
|
22
|
+
contentWeight?: number;
|
|
23
|
+
/** Parsed media overlay node (set by MediaOverlayModule after fetching SMIL) */
|
|
24
|
+
mediaOverlayNode?: any;
|
|
25
|
+
/**
|
|
26
|
+
* Media overlay URL from link properties.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Media overlay URL from link properties.
|
|
30
|
+
* The manifest JSON uses hyphenated key "media-overlay".
|
|
31
|
+
*/
|
|
32
|
+
get mediaOverlay(): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Decoded href (URL-decoded).
|
|
35
|
+
*/
|
|
36
|
+
get hrefDecoded(): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Rels as array (convenience — @readium/shared uses Set).
|
|
39
|
+
*/
|
|
40
|
+
get relArray(): string[];
|
|
41
|
+
}
|
|
42
|
+
export { ReadiumLinks as Links };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IHighlight } from "../../modules/highlight/common/highlight";
|
|
2
|
+
/**
|
|
3
|
+
* Locator model aligned with the Readium Locator spec.
|
|
4
|
+
* https://github.com/readium/architecture/tree/master/models/locators
|
|
5
|
+
*
|
|
6
|
+
* R2D2BC extensions (remainingPositions, totalRemainingPositions, displayInfo)
|
|
7
|
+
* are preserved for backwards compatibility.
|
|
8
|
+
*/
|
|
9
|
+
export interface Locator {
|
|
10
|
+
href: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
locations: Locations;
|
|
14
|
+
text?: LocatorText;
|
|
15
|
+
/** @deprecated R2D2BC extension — may be removed in a future version */
|
|
16
|
+
displayInfo?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface LocatorText {
|
|
19
|
+
after?: string;
|
|
20
|
+
before?: string;
|
|
21
|
+
highlight?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Locations {
|
|
24
|
+
/** Fragment identifier (TOC, page lists, landmarks) */
|
|
25
|
+
fragment?: string;
|
|
26
|
+
/** Progression in the resource expressed as a percentage (0–1) */
|
|
27
|
+
progression?: number;
|
|
28
|
+
/** An index in the publication (>= 1) */
|
|
29
|
+
position?: number;
|
|
30
|
+
/** Progression in the publication expressed as a percentage (0–1) */
|
|
31
|
+
totalProgression?: number;
|
|
32
|
+
/** R2D2BC extension: remaining positions in current resource */
|
|
33
|
+
remainingPositions?: number;
|
|
34
|
+
/** R2D2BC extension: remaining positions in publication */
|
|
35
|
+
totalRemainingPositions?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ReadingPosition extends Locator {
|
|
38
|
+
created: Date;
|
|
39
|
+
}
|
|
40
|
+
export interface Bookmark extends Locator {
|
|
41
|
+
id?: any;
|
|
42
|
+
created: Date;
|
|
43
|
+
}
|
|
44
|
+
export declare enum AnnotationMarker {
|
|
45
|
+
Highlight = 0,
|
|
46
|
+
Underline = 1,
|
|
47
|
+
Bookmark = 2,
|
|
48
|
+
Custom = 3,
|
|
49
|
+
Comment = 4
|
|
50
|
+
}
|
|
51
|
+
export interface Annotation extends Locator {
|
|
52
|
+
id?: any;
|
|
53
|
+
created: Date;
|
|
54
|
+
highlight?: IHighlight;
|
|
55
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Overlay Node for SMIL-based synchronized audio+text.
|
|
3
|
+
*
|
|
4
|
+
* @readium/shared only provides MediaOverlay metadata (activeClass, playbackActiveClass).
|
|
5
|
+
* The full SMIL overlay tree (Text, Audio, Children, Role) is an R2D2BC model
|
|
6
|
+
* because the ts-toolkit doesn't implement media overlay playback.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MediaOverlayNode {
|
|
9
|
+
/** Text fragment reference (e.g., "chapter1.xhtml#para1") */
|
|
10
|
+
Text?: string;
|
|
11
|
+
/** Audio file reference (e.g., "audio/chapter1.mp3#t=0,5.5") */
|
|
12
|
+
Audio?: string;
|
|
13
|
+
/** Child overlay nodes (for nested SMIL structures) */
|
|
14
|
+
Children?: MediaOverlayNode[];
|
|
15
|
+
/** Semantic roles (e.g., ["bodymatter", "chapter"]) */
|
|
16
|
+
Role?: string[];
|
|
17
|
+
/** Whether this node has been initialized/loaded */
|
|
18
|
+
initialized?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Deserialize a MediaOverlayNode from plain JSON.
|
|
21
|
+
* Replaces the old TaJsonDeserialize<MediaOverlayNode> approach.
|
|
22
|
+
*/
|
|
23
|
+
static deserialize(json: any): MediaOverlayNode | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Serialize to plain JSON.
|
|
26
|
+
*/
|
|
27
|
+
serialize(): any;
|
|
28
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Manifest } from "@readium/shared";
|
|
2
|
+
import { Locator } from "./Locator";
|
|
3
|
+
import { Link } from "./Link";
|
|
4
|
+
import { GetContentBytesLength, RequestConfig, SampleRead } from "../../navigator/IFrameNavigator";
|
|
5
|
+
/**
|
|
6
|
+
* R2D2BC Publication — wraps @readium/shared Manifest with
|
|
7
|
+
* all R2D2BC-specific extensions (positions, sample read, spine helpers).
|
|
8
|
+
*
|
|
9
|
+
* No Proxies. Clean property access. All camelCase.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Publication {
|
|
12
|
+
readonly manifest: Manifest;
|
|
13
|
+
manifestUrl: URL;
|
|
14
|
+
positions: Array<Locator>;
|
|
15
|
+
sample?: SampleRead;
|
|
16
|
+
/** Cached converted links — extensions persist across accesses */
|
|
17
|
+
private _readingOrder?;
|
|
18
|
+
private _resources?;
|
|
19
|
+
private _toc?;
|
|
20
|
+
private _links?;
|
|
21
|
+
constructor(manifest: Manifest, manifestUrl: URL);
|
|
22
|
+
static fromUrl(url: URL, requestConfig?: RequestConfig): Promise<Publication>;
|
|
23
|
+
get metadata(): import("@readium/shared").Metadata;
|
|
24
|
+
get readingOrder(): Link[];
|
|
25
|
+
get resources(): Link[];
|
|
26
|
+
get tableOfContents(): Link[];
|
|
27
|
+
get landmarks(): Link[];
|
|
28
|
+
get pageList(): Link[];
|
|
29
|
+
get links(): Link[];
|
|
30
|
+
get isFixedLayout(): boolean;
|
|
31
|
+
get isReflowable(): boolean;
|
|
32
|
+
get layout(): "fixed" | "reflowable";
|
|
33
|
+
get hasMediaOverlays(): boolean;
|
|
34
|
+
get publicationLanguages(): string[] | undefined;
|
|
35
|
+
get publicationTitle(): any;
|
|
36
|
+
get publicationReadingProgression(): string | undefined;
|
|
37
|
+
getStartLink(): Link | undefined;
|
|
38
|
+
getPreviousSpineItem(href: string): Link | undefined;
|
|
39
|
+
getNextSpineItem(href: string): Link | undefined;
|
|
40
|
+
getSpineItem(href: string): Link | undefined;
|
|
41
|
+
getSpineIndex(href: string): number | undefined;
|
|
42
|
+
getAbsoluteHref(href: string): string;
|
|
43
|
+
getRelativeHref(href: string): string;
|
|
44
|
+
getTOCItemAbsolute(href: string): Link | undefined;
|
|
45
|
+
getTOCItem(href: string): Link | undefined;
|
|
46
|
+
positionsByHref(href: string): Locator[];
|
|
47
|
+
autoGeneratePositions(requestConfig?: RequestConfig, getContentBytesLength?: GetContentBytesLength): Promise<void>;
|
|
48
|
+
fetchPositionsFromService(href: string, requestConfig?: RequestConfig): Promise<void>;
|
|
49
|
+
fetchWeightsFromService(href: string, requestConfig?: RequestConfig): Promise<void>;
|
|
50
|
+
private limitedTOC;
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v3 Model Layer
|
|
3
|
+
*
|
|
4
|
+
* Built on @readium/shared instead of r2-shared-js + ta-json-x.
|
|
5
|
+
* All models use plain JSON deserialization (no decorators).
|
|
6
|
+
* PascalCase compatibility getters provided for backwards compat.
|
|
7
|
+
*/
|
|
8
|
+
export { Publication } from "./Publication";
|
|
9
|
+
export { Link, D2Link, Links } from "./Link";
|
|
10
|
+
export { Locator, LocatorText, Locations, ReadingPosition, Bookmark, Annotation, AnnotationMarker, } from "./Locator";
|
|
11
|
+
export { MediaOverlayNode } from "./MediaOverlayNode";
|
|
@@ -2,7 +2,7 @@ import { Publication } from "../../model/Publication";
|
|
|
2
2
|
import { IFrameNavigator } from "../../navigator/IFrameNavigator";
|
|
3
3
|
import { ReaderModule } from "../ReaderModule";
|
|
4
4
|
import { Link } from "../../model/Link";
|
|
5
|
-
import { MediaOverlayNode } from "
|
|
5
|
+
import { MediaOverlayNode } from "../../model/v3/MediaOverlayNode";
|
|
6
6
|
import { MediaOverlaySettings } from "./MediaOverlaySettings";
|
|
7
7
|
export interface MediaOverlayModuleAPI {
|
|
8
8
|
started: any;
|
|
@@ -5,10 +5,10 @@ export interface ISearchResult {
|
|
|
5
5
|
textBefore: string;
|
|
6
6
|
textAfter: string;
|
|
7
7
|
href: string;
|
|
8
|
-
title: string;
|
|
8
|
+
title: string | undefined;
|
|
9
9
|
uuid: string;
|
|
10
10
|
highlight?: any;
|
|
11
11
|
}
|
|
12
12
|
export declare function escapeRegExp(str: string): string;
|
|
13
13
|
export declare const reset: () => void;
|
|
14
|
-
export declare function searchDocDomSeek(searchInput: string, doc: Document | null, href: string, title: string, fullWordSearch?: boolean): Promise<ISearchResult[]>;
|
|
14
|
+
export declare function searchDocDomSeek(searchInput: string, doc: Document | null, href: string, title: string | undefined, fullWordSearch?: boolean): Promise<ISearchResult[]>;
|
package/dist/types/reader.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ export default class D2Reader {
|
|
|
142
142
|
get currentResource(): number | undefined;
|
|
143
143
|
get mostRecentNavigatedTocItem(): string | false;
|
|
144
144
|
get totalResources(): number;
|
|
145
|
-
get publicationLanguage(): string[];
|
|
145
|
+
get publicationLanguage(): string[] | undefined;
|
|
146
146
|
/**
|
|
147
147
|
* Settings
|
|
148
148
|
*/
|
|
@@ -170,7 +170,7 @@ export default class D2Reader {
|
|
|
170
170
|
scroll: (value: boolean, direction?: string) => Promise<void>;
|
|
171
171
|
private isTTSIncrementable;
|
|
172
172
|
private isMOIncrementable;
|
|
173
|
-
/**
|
|
173
|
+
w: any; /**
|
|
174
174
|
* Used to increase anything that can be increased,
|
|
175
175
|
* such as pitch, rate, volume, fontSize
|
|
176
176
|
*/
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated ta-json-x is removed in v3. These functions now use
|
|
3
|
+
* @readium/shared's built-in deserialize/serialize methods or plain JSON.
|
|
4
|
+
*
|
|
5
|
+
* Kept for backwards compatibility with code that calls TaJsonDeserialize/TaJsonSerialize.
|
|
6
|
+
*/
|
|
1
7
|
export interface IStringMap {
|
|
2
8
|
[key: string]: string;
|
|
3
9
|
}
|
|
@@ -8,7 +14,17 @@ export interface JsonMap {
|
|
|
8
14
|
}
|
|
9
15
|
export interface JsonArray extends Array<AnyJson> {
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use Manifest.deserialize(), Link.deserialize(), etc. from @readium/shared directly.
|
|
19
|
+
*
|
|
20
|
+
* This wrapper now calls the type's static deserialize() if available,
|
|
21
|
+
* otherwise falls back to Object.assign for simple types.
|
|
22
|
+
*/
|
|
23
|
+
export declare function TaJsonDeserialize<T>(json: any, type: {
|
|
24
|
+
new (...args: any[]): T;
|
|
25
|
+
deserialize?: (json: any) => T | undefined;
|
|
26
|
+
}): T;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use the object's serialize() method directly.
|
|
29
|
+
*/
|
|
13
30
|
export declare function TaJsonSerialize<T>(obj: T): JsonMap;
|
|
14
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-i-t-a/reader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "A viewer application for EPUB files.",
|
|
5
5
|
"repository": "https://github.com/d-i-t-a/R2D2BC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"test:watch": "vitest"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@readium/shared": "^2.1.5",
|
|
41
42
|
"browserslist-useragent-regexp": "^4.1.0",
|
|
42
43
|
"cssesc": "^3.0.0",
|
|
43
44
|
"debounce": "^2.0.0",
|
|
@@ -47,10 +48,8 @@
|
|
|
47
48
|
"lodash": "^4.17.21",
|
|
48
49
|
"loglevel": "^1.8.0",
|
|
49
50
|
"pdfjs-dist": "^5.5.207",
|
|
50
|
-
"r2-shared-js": "^1.0.82",
|
|
51
51
|
"recursive-readdir": "^2.2.2",
|
|
52
52
|
"sanitize-html": "^2.3.3",
|
|
53
|
-
"ta-json-x": "^2.5.3",
|
|
54
53
|
"util": "^0.12.4",
|
|
55
54
|
"uuid": "^11.0.0"
|
|
56
55
|
},
|