react-ebookjs 0.0.5 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2025 Lennart Kerkvliet
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/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 {
@@ -25,18 +24,23 @@ type EPUBEntity = {
25
24
  code?: string;
26
25
  scheme?: string;
27
26
  };
27
+ type Contributor = string | EPUBEntity;
28
+ type LocalizedString = string | Record<string, string>;
28
29
  interface Book {
29
30
  metadata?: {
30
31
  identifier?: string;
31
- title?: string;
32
- language?: string[] | string;
32
+ title?: LocalizedString;
33
+ language?: string | string[];
33
34
  description?: string;
34
- author?: string[] | EPUBEntity[];
35
- translator?: string[] | EPUBEntity[];
36
- contributor?: string[] | EPUBEntity[];
37
- publisher?: string | EPUBEntity | null;
35
+ author?: Contributor | Contributor[];
36
+ translator?: Contributor | Contributor[];
37
+ contributor?: Contributor | Contributor[];
38
+ publisher?: Contributor | Contributor[];
38
39
  published?: string;
39
40
  modified?: string;
41
+ subtitle?: string;
42
+ sortAs?: LocalizedString;
43
+ pageBreakSource?: string;
40
44
  };
41
45
  toc: TableOfContentsItem[];
42
46
  pageList?: TableOfContentsItem[];
@@ -54,91 +58,13 @@ interface Book {
54
58
  isExternal?: (href: string) => boolean;
55
59
  }
56
60
 
57
- declare function loadEPUB(blob: Blob): Promise<Book>;
58
- declare function loadFB2(blob: Blob): Promise<Book>;
59
- declare function loadComicBook(blob: Blob): Promise<Book>;
60
-
61
- declare class Paginator extends HTMLElement {
62
- static observedAttributes: string[];
63
- attributeChangedCallback(name: any, _: any, value: any): void;
64
- open(book: any): void;
65
- bookDir: any;
66
- sections: any;
67
- heads: Element[] | null | undefined;
68
- feet: Element[] | null | undefined;
69
- render(): void;
70
- get scrolled(): boolean;
71
- get scrollProp(): "scrollLeft" | "scrollTop";
72
- get sideProp(): "width" | "height";
73
- get size(): number;
74
- get viewSize(): any;
75
- get start(): number;
76
- get end(): number;
77
- get page(): number;
78
- get pages(): number;
79
- scrollBy(dx: any, dy: any): void;
80
- snap(vx: any, vy: any): void;
81
- scrollToAnchor(anchor: any, select: any): Promise<void>;
82
- goTo(target: any): Promise<void>;
83
- get atStart(): boolean;
84
- get atEnd(): boolean;
85
- prev(distance: any): Promise<void>;
86
- next(distance: any): Promise<void>;
87
- prevSection(): Promise<void>;
88
- nextSection(): Promise<void>;
89
- firstSection(): Promise<void>;
90
- lastSection(): Promise<void>;
91
- getContents(): {
92
- index: number;
93
- overlayer: any;
94
- doc: any;
95
- }[];
96
- setStyles(styles: any): void;
97
- focusView(): void;
98
- destroy(): void;
99
- #private;
100
- }
101
-
102
- declare class FixedLayout extends HTMLElement {
103
- static observedAttributes: string[];
104
- defaultViewport: any;
105
- spread: any;
106
- attributeChangedCallback(name: any, _: any, value: any): void;
107
- open(book: any): void;
108
- book: any;
109
- rtl: boolean | undefined;
110
- get index(): any;
111
- getSpreadOf(section: any): {
112
- index: number;
113
- side: string;
114
- } | undefined;
115
- goToSpread(index: any, side: any, reason: any): Promise<void>;
116
- select(target: any): Promise<void>;
117
- goTo(target: any): Promise<void>;
118
- next(): Promise<void>;
119
- prev(): Promise<void>;
120
- getContents(): {
121
- doc: Document | null;
122
- }[];
123
- destroy(): void;
124
- #private;
125
- }
126
-
127
- declare module "react" {
128
- namespace JSX {
129
- interface IntrinsicElements {
130
- 'foliate-paginator': React.DetailedHTMLProps<React.HTMLAttributes<Paginator>, Paginator>;
131
- 'foliate-fxl': React.DetailedHTMLProps<React.HTMLAttributes<FixedLayout>, FixedLayout>;
132
- }
133
- }
134
- }
135
61
  interface ReaderProps {
136
62
  book: Book;
137
63
  progress?: number;
138
64
  onProgressChange?: (progress: number) => void;
139
65
  children: React.ReactNode;
140
66
  }
141
- declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): react_jsx_runtime.JSX.Element;
67
+ declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): React.JSX.Element;
142
68
  interface ReaderContentProps {
143
69
  fontSize?: number;
144
70
  lineSpacing?: number;
@@ -146,9 +72,9 @@ interface ReaderContentProps {
146
72
  hyphenate?: boolean;
147
73
  flow?: "paginated" | "scrolled";
148
74
  }
149
- declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow }: ReaderContentProps): react_jsx_runtime.JSX.Element;
150
- declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): react_jsx_runtime.JSX.Element;
151
- declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): react_jsx_runtime.JSX.Element;
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;
152
78
 
153
79
  declare function useBookNavigator(): {
154
80
  goTo: (target: number | string | {
@@ -166,4 +92,8 @@ declare function useSearch(query?: string): {
166
92
  }[] | undefined;
167
93
  };
168
94
 
169
- export { type Book, Reader, ReaderContent, ReaderNext, ReaderPrevious, loadComicBook, loadEPUB, loadFB2, useBookNavigator, useSearch };
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 {
@@ -25,18 +24,23 @@ type EPUBEntity = {
25
24
  code?: string;
26
25
  scheme?: string;
27
26
  };
27
+ type Contributor = string | EPUBEntity;
28
+ type LocalizedString = string | Record<string, string>;
28
29
  interface Book {
29
30
  metadata?: {
30
31
  identifier?: string;
31
- title?: string;
32
- language?: string[] | string;
32
+ title?: LocalizedString;
33
+ language?: string | string[];
33
34
  description?: string;
34
- author?: string[] | EPUBEntity[];
35
- translator?: string[] | EPUBEntity[];
36
- contributor?: string[] | EPUBEntity[];
37
- publisher?: string | EPUBEntity | null;
35
+ author?: Contributor | Contributor[];
36
+ translator?: Contributor | Contributor[];
37
+ contributor?: Contributor | Contributor[];
38
+ publisher?: Contributor | Contributor[];
38
39
  published?: string;
39
40
  modified?: string;
41
+ subtitle?: string;
42
+ sortAs?: LocalizedString;
43
+ pageBreakSource?: string;
40
44
  };
41
45
  toc: TableOfContentsItem[];
42
46
  pageList?: TableOfContentsItem[];
@@ -54,91 +58,13 @@ interface Book {
54
58
  isExternal?: (href: string) => boolean;
55
59
  }
56
60
 
57
- declare function loadEPUB(blob: Blob): Promise<Book>;
58
- declare function loadFB2(blob: Blob): Promise<Book>;
59
- declare function loadComicBook(blob: Blob): Promise<Book>;
60
-
61
- declare class Paginator extends HTMLElement {
62
- static observedAttributes: string[];
63
- attributeChangedCallback(name: any, _: any, value: any): void;
64
- open(book: any): void;
65
- bookDir: any;
66
- sections: any;
67
- heads: Element[] | null | undefined;
68
- feet: Element[] | null | undefined;
69
- render(): void;
70
- get scrolled(): boolean;
71
- get scrollProp(): "scrollLeft" | "scrollTop";
72
- get sideProp(): "width" | "height";
73
- get size(): number;
74
- get viewSize(): any;
75
- get start(): number;
76
- get end(): number;
77
- get page(): number;
78
- get pages(): number;
79
- scrollBy(dx: any, dy: any): void;
80
- snap(vx: any, vy: any): void;
81
- scrollToAnchor(anchor: any, select: any): Promise<void>;
82
- goTo(target: any): Promise<void>;
83
- get atStart(): boolean;
84
- get atEnd(): boolean;
85
- prev(distance: any): Promise<void>;
86
- next(distance: any): Promise<void>;
87
- prevSection(): Promise<void>;
88
- nextSection(): Promise<void>;
89
- firstSection(): Promise<void>;
90
- lastSection(): Promise<void>;
91
- getContents(): {
92
- index: number;
93
- overlayer: any;
94
- doc: any;
95
- }[];
96
- setStyles(styles: any): void;
97
- focusView(): void;
98
- destroy(): void;
99
- #private;
100
- }
101
-
102
- declare class FixedLayout extends HTMLElement {
103
- static observedAttributes: string[];
104
- defaultViewport: any;
105
- spread: any;
106
- attributeChangedCallback(name: any, _: any, value: any): void;
107
- open(book: any): void;
108
- book: any;
109
- rtl: boolean | undefined;
110
- get index(): any;
111
- getSpreadOf(section: any): {
112
- index: number;
113
- side: string;
114
- } | undefined;
115
- goToSpread(index: any, side: any, reason: any): Promise<void>;
116
- select(target: any): Promise<void>;
117
- goTo(target: any): Promise<void>;
118
- next(): Promise<void>;
119
- prev(): Promise<void>;
120
- getContents(): {
121
- doc: Document | null;
122
- }[];
123
- destroy(): void;
124
- #private;
125
- }
126
-
127
- declare module "react" {
128
- namespace JSX {
129
- interface IntrinsicElements {
130
- 'foliate-paginator': React.DetailedHTMLProps<React.HTMLAttributes<Paginator>, Paginator>;
131
- 'foliate-fxl': React.DetailedHTMLProps<React.HTMLAttributes<FixedLayout>, FixedLayout>;
132
- }
133
- }
134
- }
135
61
  interface ReaderProps {
136
62
  book: Book;
137
63
  progress?: number;
138
64
  onProgressChange?: (progress: number) => void;
139
65
  children: React.ReactNode;
140
66
  }
141
- declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): react_jsx_runtime.JSX.Element;
67
+ declare function Reader({ book, progress, onProgressChange, children }: ReaderProps): React.JSX.Element;
142
68
  interface ReaderContentProps {
143
69
  fontSize?: number;
144
70
  lineSpacing?: number;
@@ -146,9 +72,9 @@ interface ReaderContentProps {
146
72
  hyphenate?: boolean;
147
73
  flow?: "paginated" | "scrolled";
148
74
  }
149
- declare function ReaderContent({ fontSize, lineSpacing, justify, hyphenate, flow }: ReaderContentProps): react_jsx_runtime.JSX.Element;
150
- declare function ReaderNext({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): react_jsx_runtime.JSX.Element;
151
- declare function ReaderPrevious({ children, ...props }: Omit<React.ComponentProps<"button">, "onClick">): react_jsx_runtime.JSX.Element;
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;
152
78
 
153
79
  declare function useBookNavigator(): {
154
80
  goTo: (target: number | string | {
@@ -166,4 +92,8 @@ declare function useSearch(query?: string): {
166
92
  }[] | undefined;
167
93
  };
168
94
 
169
- export { type Book, Reader, ReaderContent, ReaderNext, ReaderPrevious, loadComicBook, loadEPUB, loadFB2, useBookNavigator, useSearch };
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 };