@likecoin/epub-ts 0.5.0 → 0.6.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/README.md CHANGED
@@ -1,30 +1,43 @@
1
1
  # epub.ts (`@likecoin/epub-ts`)
2
2
 
3
- A TypeScript fork of [epubjs](https://github.com/futurepress/epub.js) v0.3.93 by [Fred Chasen](https://github.com/fchasen) / [FuturePress](https://github.com/futurepress) — parse and render EPUB documents in the browser.
4
-
5
3
  [![CI](https://github.com/likecoin/epub.ts/actions/workflows/ci.yml/badge.svg)](https://github.com/likecoin/epub.ts/actions/workflows/ci.yml)
6
4
  [![npm](https://img.shields.io/npm/v/%40likecoin%2Fepub-ts)](https://www.npmjs.com/package/@likecoin/epub-ts)
7
5
  [![License](https://img.shields.io/npm/l/%40likecoin%2Fepub-ts)](./LICENSE)
8
6
 
9
- > **Note**: This library is primarily developed for internal use at [3ook.com](https://3ook.com) and is provided as-is. It was mainly built with AI-assisted development. For the original library, see [epubjs](https://github.com/futurepress/epub.js).
7
+ **Drop-in replacement for [epubjs](https://github.com/futurepress/epub.js)** same API, fully typed, 1 runtime dependency, actively maintained.
8
+
9
+ A complete TypeScript rewrite of epubjs v0.3.93 with strict mode, modern tooling, and ongoing bug fixes — without breaking your existing code.
10
+
11
+ ## What you get
12
+
13
+ - **Same API, zero migration cost** — change one import line and everything works
14
+ - **Full TypeScript strict mode** — generated `.d.ts` from source, so autocomplete matches runtime
15
+ - **1 runtime dependency** (`jszip`) — smaller bundle, simpler supply chain
16
+ - **970+ tests** across 40 files — Vitest with robust coverage
17
+ - **Vite build** — ESM, CJS, and UMD outputs out of the box
18
+ - **Node.js support** — `@likecoin/epub-ts/node` parses EPUBs server-side with `linkedom`
19
+ - **Active maintenance** — [20+ bug fixes](./CHANGELOG.md) and counting
10
20
 
11
- ## Features
21
+ > **Note**: Built at [3ook.com](https://3ook.com) and provided as-is. Forked from [epubjs](https://github.com/futurepress/epub.js) v0.3.93 by [Fred Chasen](https://github.com/fchasen) / [FuturePress](https://github.com/futurepress).
12
22
 
13
- - **Drop-in replacement** for epubjs v0.3.93 — same API, just change the import
14
- - **TypeScript first** — full strict mode, typed emitter, generated `.d.ts` declarations
15
- - **Modern build** — Vite library build, ESM + CJS output
16
- - **Fewer dependencies** — only 1 runtime dependency (`jszip`); removed `core-js`, `lodash`, `path-webpack`, `event-emitter`, `localforage`, `@xmldom/xmldom`
17
- - **Named exports** — import individual classes like `Book`, `EpubCFI`, `Rendition`, etc.
23
+ ## Get started
18
24
 
19
- ## Installation
25
+ ### Install
20
26
 
21
27
  ```bash
22
28
  npm install @likecoin/epub-ts
23
29
  ```
24
30
 
25
- ## Quick Start
31
+ ### Migrate from epubjs
32
+
33
+ Change one line — everything else stays the same:
34
+
35
+ ```diff
36
+ - import ePub from "epubjs";
37
+ + import ePub from "@likecoin/epub-ts";
38
+ ```
26
39
 
27
- ### ES Modules (recommended)
40
+ ### Render an EPUB (browser)
28
41
 
29
42
  ```typescript
30
43
  import ePub from "@likecoin/epub-ts";
@@ -34,7 +47,7 @@ const rendition = book.renderTo("viewer", { width: 600, height: 400 });
34
47
  rendition.display();
35
48
  ```
36
49
 
37
- ### Browser (from ArrayBuffer)
50
+ ### Load from file input
38
51
 
39
52
  ```typescript
40
53
  import ePub from "@likecoin/epub-ts";
@@ -49,9 +62,9 @@ fileInput.addEventListener("change", async (event) => {
49
62
  });
50
63
  ```
51
64
 
52
- ### Node.js (parsing only)
65
+ ### Parse on Node.js (no browser needed)
53
66
 
54
- Parse EPUB metadata, spine, navigation, and section content without a browser. Requires [`linkedom`](https://github.com/WebReflection/linkedom) as a peer dependency.
67
+ Extract metadata, table of contents, and chapter HTML server-side. Requires [`linkedom`](https://github.com/WebReflection/linkedom):
55
68
 
56
69
  ```bash
57
70
  npm install linkedom
@@ -73,18 +86,7 @@ const section = book.spine.first();
73
86
  const html = await section.render(book.archive.request.bind(book.archive));
74
87
  ```
75
88
 
76
- ## Migration from epubjs
77
-
78
- Drop-in replacement. Change your import:
79
-
80
- ```diff
81
- - import ePub from "epubjs";
82
- + import ePub from "@likecoin/epub-ts";
83
- ```
84
-
85
- All APIs remain the same.
86
-
87
- ## Named Exports
89
+ ## Named exports
88
90
 
89
91
  ```js
90
92
  import {
@@ -95,36 +97,21 @@ import {
95
97
  } from "@likecoin/epub-ts";
96
98
  ```
97
99
 
98
- ## API
100
+ ## API reference
99
101
 
100
- See the full [API documentation](https://likecoin.github.io/epub.ts/) for details on all classes, interfaces, and methods.
102
+ Full documentation: [likecoin.github.io/epub.ts](https://likecoin.github.io/epub.ts/)
101
103
 
102
- Key classes:
103
-
104
- | Class | Description |
104
+ | Class | What it does |
105
105
  |-------|-------------|
106
- | `Book` | Main EPUB representation loading, parsing, manipulation |
107
- | `Rendition` | Renders a book to a DOM element |
108
- | `Contents` | Manages content within an iframe |
109
- | `EpubCFI` | EPUB Canonical Fragment Identifier parser |
110
- | `Locations` | Generates and manages reading locations |
106
+ | `Book` | Load, parse, and manipulate an EPUB |
107
+ | `Rendition` | Render a book into a DOM element |
108
+ | `Contents` | Manage content inside an iframe |
109
+ | `EpubCFI` | Parse EPUB Canonical Fragment Identifiers |
110
+ | `Locations` | Generate and query reading positions |
111
111
  | `Navigation` | Table of contents and landmarks |
112
112
  | `Annotations` | Highlights, underlines, and marks |
113
113
 
114
- ## Comparison with epubjs
115
-
116
- | Aspect | epub.ts | epubjs |
117
- |--------|---------|--------|
118
- | Language | TypeScript (strict mode) | JavaScript |
119
- | Build | Vite | webpack + Babel |
120
- | Tests | Vitest | Karma + Mocha |
121
- | Type definitions | Generated from source | Hand-written `.d.ts` |
122
- | Dependencies | 1 (`jszip`) | 7+ (`core-js`, `lodash`, `event-emitter`, etc.) |
123
- | API compatibility | 100% (drop-in replacement) | — |
124
- | Bundle format | ESM + CJS + UMD | UMD |
125
- | Maintenance | Active | Inactive since 2022 |
126
-
127
- ## Supported Environments
114
+ ## Supported environments
128
115
 
129
116
  | Environment | Import | Notes |
130
117
  |-------------|--------|-------|
@@ -132,48 +119,29 @@ Key classes:
132
119
  | Vite / webpack | `@likecoin/epub-ts` | ESM or CJS |
133
120
  | Node.js 18+ | `@likecoin/epub-ts/node` | Parsing only (no rendering); requires `linkedom` peer dep |
134
121
 
135
- ## What's Changed from epubjs
136
-
137
- - Build: webpack + Babel → Vite
138
- - Tests: Karma + Mocha → Vitest
139
- - Source: JavaScript → TypeScript (full strict mode)
140
- - Removed dependencies: `core-js`, `lodash`, `path-webpack`, `localforage`, `@xmldom/xmldom`
141
- - Replaced `event-emitter` with inline typed emitter
142
- - Replaced `localforage` with native IndexedDB wrapper
143
- - Replaced `@xmldom/xmldom` with native DOMParser/XMLSerializer
144
- - Added Node.js parsing-only entry point (`@likecoin/epub-ts/node`) with `linkedom`
145
- - Dropped IE8–IE11 support
146
-
147
122
  ## Development
148
123
 
149
- ### Prerequisites
150
-
151
- - Node.js 18+
152
- - npm 9+
153
-
154
- ### Setup
155
-
156
124
  ```bash
157
125
  git clone https://github.com/likecoin/epub.ts.git
158
126
  cd epub.ts
159
127
  npm install
160
128
  ```
161
129
 
162
- ### Scripts
163
-
164
130
  | Script | Description |
165
131
  |--------|-------------|
166
132
  | `npm run build` | Vite library build → `dist/` |
167
133
  | `npm test` | Run tests (Vitest) |
168
134
  | `npm run test:watch` | Run tests in watch mode |
169
- | `npm run typecheck` | TypeScript type checking (`tsc --noEmit`) |
135
+ | `npm run typecheck` | `tsc --noEmit` |
170
136
  | `npm run lint` | ESLint |
171
137
  | `npm run lint:fix` | ESLint with auto-fix |
172
138
  | `npm run docs` | Generate API docs (HTML + Markdown) |
173
139
 
140
+ Requires Node.js 18+ and npm 9+.
141
+
174
142
  ## Contributing
175
143
 
176
- See [PROJECT_STATUS.md](./PROJECT_STATUS.md) for current conversion progress and what to work on.
144
+ See [PROJECT_STATUS.md](./PROJECT_STATUS.md) for current status and what to work on.
177
145
 
178
146
  For AI agents contributing to this project, see [AGENTS.md](./AGENTS.md).
179
147
 
@@ -186,11 +154,11 @@ For AI agents contributing to this project, see [AGENTS.md](./AGENTS.md).
186
154
  - [epubjs](https://github.com/futurepress/epub.js) by [Fred Chasen](https://github.com/fchasen) / [FuturePress](https://github.com/futurepress) — the original library this is forked from
187
155
  - [jszip](https://github.com/Stuk/jszip) — ZIP file handling
188
156
 
189
- ## Built by 3ook.com
157
+ ## Built by [3ook.com](https://3ook.com)
190
158
 
191
- This project is built and maintained by the [3ook.com](https://3ook.com) team. 3ook is a Web3 eBook platform where authors can publish EPUB ebooks and readers can collect them as digital assets.
159
+ 3ook is a Web3 eBook platform where authors publish EPUB ebooks and readers collect them as digital assets.
192
160
 
193
- ## Related Projects
161
+ ## Related projects
194
162
 
195
163
  - [epubjs](https://github.com/futurepress/epub.js) — Original EPUB reader library
196
164
  - [epubcheck-ts](https://github.com/likecoin/epubcheck-ts) — TypeScript EPUB validator (also by 3ook.com)
@@ -92,12 +92,10 @@ declare class Annotations {
92
92
  clear(view: AnnotationView): void;
93
93
  /**
94
94
  * [Not Implemented] Show annotations
95
- * @TODO: needs implementation in View
96
95
  */
97
96
  show(): void;
98
97
  /**
99
98
  * [Not Implemented] Hide annotations
100
- * @TODO: needs implementation in View
101
99
  */
102
100
  hide(): void;
103
101
  }
@@ -156,7 +154,6 @@ declare class Annotation implements IEventEmitter<AnnotationEvents> {
156
154
  detach(view: AnnotationView): void;
157
155
  /**
158
156
  * [Not Implemented] Get text of an annotation
159
- * @TODO: needs implementation in contents
160
157
  */
161
158
  text(): void;
162
159
  }