New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@likecoin/epub-ts

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@likecoin/epub-ts

TypeScript EPUB parser and renderer, forked from epubjs

latest
Source
npmnpm
Version
0.5.1
Version published
Weekly downloads
253
1.2%
Maintainers
3
Weekly downloads
 
Created
Source

epub.ts (@likecoin/epub-ts)

A TypeScript fork of epubjs v0.3.93 by Fred Chasen / FuturePress — parse and render EPUB documents in the browser.

CI npm License

Note: This library is primarily developed for internal use at 3ook.com and is provided as-is. It was mainly built with AI-assisted development. For the original library, see epubjs.

Features

  • Drop-in replacement for epubjs v0.3.93 — same API, just change the import
  • TypeScript first — full strict mode, typed emitter, generated .d.ts declarations
  • Modern build — Vite library build, ESM + CJS output
  • Fewer dependencies — only 1 runtime dependency (jszip); removed core-js, lodash, path-webpack, event-emitter, localforage, @xmldom/xmldom
  • Named exports — import individual classes like Book, EpubCFI, Rendition, etc.

Installation

npm install @likecoin/epub-ts

Quick Start

import ePub from "@likecoin/epub-ts";

const book = ePub("/path/to/book.epub");
const rendition = book.renderTo("viewer", { width: 600, height: 400 });
rendition.display();

Browser (from ArrayBuffer)

import ePub from "@likecoin/epub-ts";

const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener("change", async (event) => {
	const file = event.target.files[0];
	const data = await file.arrayBuffer();
	const book = ePub(data);
	const rendition = book.renderTo("viewer", { width: 600, height: 400 });
	rendition.display();
});

Node.js (parsing only)

Parse EPUB metadata, spine, navigation, and section content without a browser. Requires linkedom as a peer dependency.

npm install linkedom
import { Book } from "@likecoin/epub-ts/node";
import { readFileSync } from "node:fs";

const data = readFileSync("book.epub");
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
const book = new Book(arrayBuffer);
await book.opened;

console.log(book.packaging.metadata.title);
console.log(book.navigation.toc.map(item => item.label));

const section = book.spine.first();
const html = await section.render(book.archive.request.bind(book.archive));

Migration from epubjs

Drop-in replacement. Change your import:

- import ePub from "epubjs";
+ import ePub from "@likecoin/epub-ts";

All APIs remain the same.

Named Exports

import {
	Book, EpubCFI, Rendition, Contents, Layout,
	Section, Spine, Locations, Navigation, PageList,
	Resources, Packaging, Archive, Store,
	Annotations, Themes, Mapping,
} from "@likecoin/epub-ts";

API

See the full API documentation for details on all classes, interfaces, and methods.

Key classes:

ClassDescription
BookMain EPUB representation — loading, parsing, manipulation
RenditionRenders a book to a DOM element
ContentsManages content within an iframe
EpubCFIEPUB Canonical Fragment Identifier parser
LocationsGenerates and manages reading locations
NavigationTable of contents and landmarks
AnnotationsHighlights, underlines, and marks

Comparison with epubjs

Aspectepub.tsepubjs
LanguageTypeScript (strict mode)JavaScript
BuildVitewebpack + Babel
TestsVitestKarma + Mocha
Type definitionsGenerated from sourceHand-written .d.ts
Dependencies1 (jszip)7+ (core-js, lodash, event-emitter, etc.)
API compatibility100% (drop-in replacement)
Bundle formatESM + CJS + UMDUMD
MaintenanceActiveInactive since 2022

Supported Environments

EnvironmentImportNotes
Modern browsers@likecoin/epub-tsChrome, Firefox, Safari, Edge
Vite / webpack@likecoin/epub-tsESM or CJS
Node.js 18+@likecoin/epub-ts/nodeParsing only (no rendering); requires linkedom peer dep

What's Changed from epubjs

  • Build: webpack + Babel → Vite
  • Tests: Karma + Mocha → Vitest
  • Source: JavaScript → TypeScript (full strict mode)
  • Removed dependencies: core-js, lodash, path-webpack, localforage, @xmldom/xmldom
  • Replaced event-emitter with inline typed emitter
  • Replaced localforage with native IndexedDB wrapper
  • Replaced @xmldom/xmldom with native DOMParser/XMLSerializer
  • Added Node.js parsing-only entry point (@likecoin/epub-ts/node) with linkedom
  • Dropped IE8–IE11 support

Development

Prerequisites

  • Node.js 18+
  • npm 9+

Setup

git clone https://github.com/likecoin/epub.ts.git
cd epub.ts
npm install

Scripts

ScriptDescription
npm run buildVite library build → dist/
npm testRun tests (Vitest)
npm run test:watchRun tests in watch mode
npm run typecheckTypeScript type checking (tsc --noEmit)
npm run lintESLint
npm run lint:fixESLint with auto-fix
npm run docsGenerate API docs (HTML + Markdown)

Contributing

See PROJECT_STATUS.md for current conversion progress and what to work on.

For AI agents contributing to this project, see AGENTS.md.

License

BSD-2-Clause (same as epubjs)

Acknowledgments

Built by 3ook.com

This project is built and maintained by the 3ook.com team. 3ook is a Web3 eBook platform where authors can publish EPUB ebooks and readers can collect them as digital assets.

  • epubjs — Original EPUB reader library
  • epubcheck-ts — TypeScript EPUB validator (also by 3ook.com)

Keywords

epub

FAQs

Package last updated on 30 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts