react-ebookjs 0.0.3 → 0.1.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.
- package/LICENSE +1 -1
- package/README.md +2 -0
- package/dist/index.d.mts +24 -90
- package/dist/index.d.ts +24 -90
- package/dist/index.js +3334 -3184
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3335 -3185
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -5
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2026 Lennart Kerkvliet
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
3
|
interface TableOfContentsItem {
|
|
@@ -12,6 +11,7 @@ interface Section {
|
|
|
12
11
|
linear?: string;
|
|
13
12
|
cfi?: string;
|
|
14
13
|
createDocument: () => Promise<any>;
|
|
14
|
+
resolveHref?: (href: string) => string | null;
|
|
15
15
|
}
|
|
16
16
|
type ResolveIndex = {
|
|
17
17
|
index: number;
|
|
@@ -24,18 +24,23 @@ type EPUBEntity = {
|
|
|
24
24
|
code?: string;
|
|
25
25
|
scheme?: string;
|
|
26
26
|
};
|
|
27
|
+
type Contributor = string | EPUBEntity;
|
|
28
|
+
type LocalizedString = string | Record<string, string>;
|
|
27
29
|
interface Book {
|
|
28
30
|
metadata?: {
|
|
29
31
|
identifier?: string;
|
|
30
|
-
title?:
|
|
31
|
-
language?: string
|
|
32
|
+
title?: LocalizedString;
|
|
33
|
+
language?: string | string[];
|
|
32
34
|
description?: string;
|
|
33
|
-
author?:
|
|
34
|
-
translator?:
|
|
35
|
-
contributor?:
|
|
36
|
-
publisher?:
|
|
35
|
+
author?: Contributor | Contributor[];
|
|
36
|
+
translator?: Contributor | Contributor[];
|
|
37
|
+
contributor?: Contributor | Contributor[];
|
|
38
|
+
publisher?: Contributor | Contributor[];
|
|
37
39
|
published?: string;
|
|
38
40
|
modified?: string;
|
|
41
|
+
subtitle?: string;
|
|
42
|
+
sortAs?: LocalizedString;
|
|
43
|
+
pageBreakSource?: string;
|
|
39
44
|
};
|
|
40
45
|
toc: TableOfContentsItem[];
|
|
41
46
|
pageList?: TableOfContentsItem[];
|
|
@@ -50,93 +55,16 @@ interface Book {
|
|
|
50
55
|
resolveCFI?: (cfi: string) => ResolveIndex;
|
|
51
56
|
splitTOCHref?: (href: string) => string | string[];
|
|
52
57
|
getTOCFragment?: (href: string) => string;
|
|
58
|
+
isExternal?: (href: string) => boolean;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
declare function loadEPUB(blob: Blob): Promise<Book>;
|
|
56
|
-
declare function loadFB2(blob: Blob): Promise<Book>;
|
|
57
|
-
declare function loadComicBook(blob: Blob): Promise<Book>;
|
|
58
|
-
|
|
59
|
-
declare class Paginator extends HTMLElement {
|
|
60
|
-
static observedAttributes: string[];
|
|
61
|
-
attributeChangedCallback(name: any, _: any, value: any): void;
|
|
62
|
-
open(book: any): void;
|
|
63
|
-
bookDir: any;
|
|
64
|
-
sections: any;
|
|
65
|
-
heads: Element[] | null | undefined;
|
|
66
|
-
feet: Element[] | null | undefined;
|
|
67
|
-
render(): void;
|
|
68
|
-
get scrolled(): boolean;
|
|
69
|
-
get scrollProp(): "scrollLeft" | "scrollTop";
|
|
70
|
-
get sideProp(): "width" | "height";
|
|
71
|
-
get size(): number;
|
|
72
|
-
get viewSize(): any;
|
|
73
|
-
get start(): number;
|
|
74
|
-
get end(): number;
|
|
75
|
-
get page(): number;
|
|
76
|
-
get pages(): number;
|
|
77
|
-
scrollBy(dx: any, dy: any): void;
|
|
78
|
-
snap(vx: any, vy: any): void;
|
|
79
|
-
scrollToAnchor(anchor: any, select: any): Promise<void>;
|
|
80
|
-
goTo(target: any): Promise<void>;
|
|
81
|
-
get atStart(): boolean;
|
|
82
|
-
get atEnd(): boolean;
|
|
83
|
-
prev(distance: any): Promise<void>;
|
|
84
|
-
next(distance: any): Promise<void>;
|
|
85
|
-
prevSection(): Promise<void>;
|
|
86
|
-
nextSection(): Promise<void>;
|
|
87
|
-
firstSection(): Promise<void>;
|
|
88
|
-
lastSection(): Promise<void>;
|
|
89
|
-
getContents(): {
|
|
90
|
-
index: number;
|
|
91
|
-
overlayer: any;
|
|
92
|
-
doc: any;
|
|
93
|
-
}[];
|
|
94
|
-
setStyles(styles: any): void;
|
|
95
|
-
focusView(): void;
|
|
96
|
-
destroy(): void;
|
|
97
|
-
#private;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
declare class FixedLayout extends HTMLElement {
|
|
101
|
-
static observedAttributes: string[];
|
|
102
|
-
defaultViewport: any;
|
|
103
|
-
spread: any;
|
|
104
|
-
attributeChangedCallback(name: any, _: any, value: any): void;
|
|
105
|
-
open(book: any): void;
|
|
106
|
-
book: any;
|
|
107
|
-
rtl: boolean | undefined;
|
|
108
|
-
get index(): any;
|
|
109
|
-
getSpreadOf(section: any): {
|
|
110
|
-
index: number;
|
|
111
|
-
side: string;
|
|
112
|
-
} | undefined;
|
|
113
|
-
goToSpread(index: any, side: any, reason: any): Promise<void>;
|
|
114
|
-
select(target: any): Promise<void>;
|
|
115
|
-
goTo(target: any): Promise<void>;
|
|
116
|
-
next(): Promise<void>;
|
|
117
|
-
prev(): Promise<void>;
|
|
118
|
-
getContents(): {
|
|
119
|
-
doc: Document | null;
|
|
120
|
-
}[];
|
|
121
|
-
destroy(): void;
|
|
122
|
-
#private;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
declare module "react" {
|
|
126
|
-
namespace JSX {
|
|
127
|
-
interface IntrinsicElements {
|
|
128
|
-
'foliate-paginator': React.DetailedHTMLProps<React.HTMLAttributes<Paginator>, Paginator>;
|
|
129
|
-
'foliate-fixed-layout': React.DetailedHTMLProps<React.HTMLAttributes<FixedLayout>, FixedLayout>;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
61
|
interface ReaderProps {
|
|
134
62
|
book: Book;
|
|
135
63
|
progress?: number;
|
|
136
64
|
onProgressChange?: (progress: number) => void;
|
|
137
65
|
children: React.ReactNode;
|
|
138
66
|
}
|
|
139
|
-
declare function Reader({ book, progress, onProgressChange, children }: ReaderProps):
|
|
67
|
+
declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): React.JSX.Element;
|
|
140
68
|
interface ReaderContentProps {
|
|
141
69
|
fontSize?: number;
|
|
142
70
|
lineSpacing?: number;
|
|
@@ -144,9 +72,10 @@ interface ReaderContentProps {
|
|
|
144
72
|
hyphenate?: boolean;
|
|
145
73
|
flow?: "paginated" | "scrolled";
|
|
146
74
|
}
|
|
147
|
-
declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow }: ReaderContentProps):
|
|
148
|
-
declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">):
|
|
149
|
-
declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">):
|
|
75
|
+
declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow, }: ReaderContentProps): React.JSX.Element;
|
|
76
|
+
declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): React.JSX.Element;
|
|
77
|
+
declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): React.JSX.Element;
|
|
78
|
+
|
|
150
79
|
declare function useBookNavigator(): {
|
|
151
80
|
goTo: (target: number | string | {
|
|
152
81
|
fraction: number;
|
|
@@ -154,6 +83,7 @@ declare function useBookNavigator(): {
|
|
|
154
83
|
next: (distance?: number) => Promise<void>;
|
|
155
84
|
previous: (distance?: number) => Promise<void>;
|
|
156
85
|
};
|
|
86
|
+
|
|
157
87
|
declare function useSearch(query?: string): {
|
|
158
88
|
loading: boolean;
|
|
159
89
|
results: {
|
|
@@ -162,4 +92,8 @@ declare function useSearch(query?: string): {
|
|
|
162
92
|
}[] | undefined;
|
|
163
93
|
};
|
|
164
94
|
|
|
165
|
-
|
|
95
|
+
declare function loadEPUB(blob: Blob): Promise<Book>;
|
|
96
|
+
declare function loadFB2(blob: Blob): Promise<Book>;
|
|
97
|
+
declare function loadComicBook(blob: Blob): Promise<Book>;
|
|
98
|
+
|
|
99
|
+
export { type Book, type Contributor, type LocalizedString, Reader, ReaderContent, ReaderNext, ReaderPrevious, loadComicBook, loadEPUB, loadFB2, useBookNavigator, useSearch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
3
|
interface TableOfContentsItem {
|
|
@@ -12,6 +11,7 @@ interface Section {
|
|
|
12
11
|
linear?: string;
|
|
13
12
|
cfi?: string;
|
|
14
13
|
createDocument: () => Promise<any>;
|
|
14
|
+
resolveHref?: (href: string) => string | null;
|
|
15
15
|
}
|
|
16
16
|
type ResolveIndex = {
|
|
17
17
|
index: number;
|
|
@@ -24,18 +24,23 @@ type EPUBEntity = {
|
|
|
24
24
|
code?: string;
|
|
25
25
|
scheme?: string;
|
|
26
26
|
};
|
|
27
|
+
type Contributor = string | EPUBEntity;
|
|
28
|
+
type LocalizedString = string | Record<string, string>;
|
|
27
29
|
interface Book {
|
|
28
30
|
metadata?: {
|
|
29
31
|
identifier?: string;
|
|
30
|
-
title?:
|
|
31
|
-
language?: string
|
|
32
|
+
title?: LocalizedString;
|
|
33
|
+
language?: string | string[];
|
|
32
34
|
description?: string;
|
|
33
|
-
author?:
|
|
34
|
-
translator?:
|
|
35
|
-
contributor?:
|
|
36
|
-
publisher?:
|
|
35
|
+
author?: Contributor | Contributor[];
|
|
36
|
+
translator?: Contributor | Contributor[];
|
|
37
|
+
contributor?: Contributor | Contributor[];
|
|
38
|
+
publisher?: Contributor | Contributor[];
|
|
37
39
|
published?: string;
|
|
38
40
|
modified?: string;
|
|
41
|
+
subtitle?: string;
|
|
42
|
+
sortAs?: LocalizedString;
|
|
43
|
+
pageBreakSource?: string;
|
|
39
44
|
};
|
|
40
45
|
toc: TableOfContentsItem[];
|
|
41
46
|
pageList?: TableOfContentsItem[];
|
|
@@ -50,93 +55,16 @@ interface Book {
|
|
|
50
55
|
resolveCFI?: (cfi: string) => ResolveIndex;
|
|
51
56
|
splitTOCHref?: (href: string) => string | string[];
|
|
52
57
|
getTOCFragment?: (href: string) => string;
|
|
58
|
+
isExternal?: (href: string) => boolean;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
declare function loadEPUB(blob: Blob): Promise<Book>;
|
|
56
|
-
declare function loadFB2(blob: Blob): Promise<Book>;
|
|
57
|
-
declare function loadComicBook(blob: Blob): Promise<Book>;
|
|
58
|
-
|
|
59
|
-
declare class Paginator extends HTMLElement {
|
|
60
|
-
static observedAttributes: string[];
|
|
61
|
-
attributeChangedCallback(name: any, _: any, value: any): void;
|
|
62
|
-
open(book: any): void;
|
|
63
|
-
bookDir: any;
|
|
64
|
-
sections: any;
|
|
65
|
-
heads: Element[] | null | undefined;
|
|
66
|
-
feet: Element[] | null | undefined;
|
|
67
|
-
render(): void;
|
|
68
|
-
get scrolled(): boolean;
|
|
69
|
-
get scrollProp(): "scrollLeft" | "scrollTop";
|
|
70
|
-
get sideProp(): "width" | "height";
|
|
71
|
-
get size(): number;
|
|
72
|
-
get viewSize(): any;
|
|
73
|
-
get start(): number;
|
|
74
|
-
get end(): number;
|
|
75
|
-
get page(): number;
|
|
76
|
-
get pages(): number;
|
|
77
|
-
scrollBy(dx: any, dy: any): void;
|
|
78
|
-
snap(vx: any, vy: any): void;
|
|
79
|
-
scrollToAnchor(anchor: any, select: any): Promise<void>;
|
|
80
|
-
goTo(target: any): Promise<void>;
|
|
81
|
-
get atStart(): boolean;
|
|
82
|
-
get atEnd(): boolean;
|
|
83
|
-
prev(distance: any): Promise<void>;
|
|
84
|
-
next(distance: any): Promise<void>;
|
|
85
|
-
prevSection(): Promise<void>;
|
|
86
|
-
nextSection(): Promise<void>;
|
|
87
|
-
firstSection(): Promise<void>;
|
|
88
|
-
lastSection(): Promise<void>;
|
|
89
|
-
getContents(): {
|
|
90
|
-
index: number;
|
|
91
|
-
overlayer: any;
|
|
92
|
-
doc: any;
|
|
93
|
-
}[];
|
|
94
|
-
setStyles(styles: any): void;
|
|
95
|
-
focusView(): void;
|
|
96
|
-
destroy(): void;
|
|
97
|
-
#private;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
declare class FixedLayout extends HTMLElement {
|
|
101
|
-
static observedAttributes: string[];
|
|
102
|
-
defaultViewport: any;
|
|
103
|
-
spread: any;
|
|
104
|
-
attributeChangedCallback(name: any, _: any, value: any): void;
|
|
105
|
-
open(book: any): void;
|
|
106
|
-
book: any;
|
|
107
|
-
rtl: boolean | undefined;
|
|
108
|
-
get index(): any;
|
|
109
|
-
getSpreadOf(section: any): {
|
|
110
|
-
index: number;
|
|
111
|
-
side: string;
|
|
112
|
-
} | undefined;
|
|
113
|
-
goToSpread(index: any, side: any, reason: any): Promise<void>;
|
|
114
|
-
select(target: any): Promise<void>;
|
|
115
|
-
goTo(target: any): Promise<void>;
|
|
116
|
-
next(): Promise<void>;
|
|
117
|
-
prev(): Promise<void>;
|
|
118
|
-
getContents(): {
|
|
119
|
-
doc: Document | null;
|
|
120
|
-
}[];
|
|
121
|
-
destroy(): void;
|
|
122
|
-
#private;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
declare module "react" {
|
|
126
|
-
namespace JSX {
|
|
127
|
-
interface IntrinsicElements {
|
|
128
|
-
'foliate-paginator': React.DetailedHTMLProps<React.HTMLAttributes<Paginator>, Paginator>;
|
|
129
|
-
'foliate-fixed-layout': React.DetailedHTMLProps<React.HTMLAttributes<FixedLayout>, FixedLayout>;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
61
|
interface ReaderProps {
|
|
134
62
|
book: Book;
|
|
135
63
|
progress?: number;
|
|
136
64
|
onProgressChange?: (progress: number) => void;
|
|
137
65
|
children: React.ReactNode;
|
|
138
66
|
}
|
|
139
|
-
declare function Reader({ book, progress, onProgressChange, children }: ReaderProps):
|
|
67
|
+
declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): React.JSX.Element;
|
|
140
68
|
interface ReaderContentProps {
|
|
141
69
|
fontSize?: number;
|
|
142
70
|
lineSpacing?: number;
|
|
@@ -144,9 +72,10 @@ interface ReaderContentProps {
|
|
|
144
72
|
hyphenate?: boolean;
|
|
145
73
|
flow?: "paginated" | "scrolled";
|
|
146
74
|
}
|
|
147
|
-
declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow }: ReaderContentProps):
|
|
148
|
-
declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">):
|
|
149
|
-
declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">):
|
|
75
|
+
declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow, }: ReaderContentProps): React.JSX.Element;
|
|
76
|
+
declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): React.JSX.Element;
|
|
77
|
+
declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): React.JSX.Element;
|
|
78
|
+
|
|
150
79
|
declare function useBookNavigator(): {
|
|
151
80
|
goTo: (target: number | string | {
|
|
152
81
|
fraction: number;
|
|
@@ -154,6 +83,7 @@ declare function useBookNavigator(): {
|
|
|
154
83
|
next: (distance?: number) => Promise<void>;
|
|
155
84
|
previous: (distance?: number) => Promise<void>;
|
|
156
85
|
};
|
|
86
|
+
|
|
157
87
|
declare function useSearch(query?: string): {
|
|
158
88
|
loading: boolean;
|
|
159
89
|
results: {
|
|
@@ -162,4 +92,8 @@ declare function useSearch(query?: string): {
|
|
|
162
92
|
}[] | undefined;
|
|
163
93
|
};
|
|
164
94
|
|
|
165
|
-
|
|
95
|
+
declare function loadEPUB(blob: Blob): Promise<Book>;
|
|
96
|
+
declare function loadFB2(blob: Blob): Promise<Book>;
|
|
97
|
+
declare function loadComicBook(blob: Blob): Promise<Book>;
|
|
98
|
+
|
|
99
|
+
export { type Book, type Contributor, type LocalizedString, Reader, ReaderContent, ReaderNext, ReaderPrevious, loadComicBook, loadEPUB, loadFB2, useBookNavigator, useSearch };
|