Skip to content

2.0.0

Latest

Choose a tag to compare

@chiahsien chiahsien released this 13 Feb 02:40

ZenReader v2.0.0 Release Notes

Complete TypeScript Rebuild

ZenReader v2.0.0 is a ground-up rewrite of the entire extension from vanilla JavaScript to TypeScript, with a modern build toolchain powered by Vite. All core functionality — element selection, focus mode, and style preservation — remains identical. The user experience is unchanged.

What's New

TypeScript + Strict Mode

  • Every source file rewritten in TypeScript with strict: true
  • Interfaces for all state objects, message payloads, and function signatures
  • Type-safe Chrome API usage via @types/chrome

Vite Build System

  • Vite with vite-plugin-web-extension replaces direct file loading
  • ES Modules bundled into optimized IIFE for content script injection
  • Tree-shaking eliminates dead code from the final bundle
  • npm run build runs type checking (tsc --noEmit) then Vite build
  • npm run dev starts a Vite dev server for faster iteration

ES Module Architecture

  • Global variables and script loading order replaced with explicit import/export
  • Singleton state module (getState()) replaces shared zenReaderState global
  • Clean dependency graph with no circular references

On-Demand Content Script Injection

  • Content scripts are no longer declared in manifest.json content_scripts
  • Background service worker injects scripts via chrome.scripting API only when the user activates the extension
  • Re-injection guard (window.__zenReaderInjected) prevents double initialization
  • Zero performance impact on pages where ZenReader is not used

Unit Test Suite

  • 63 tests across 4 test files using Vitest with happy-dom environment
  • Coverage for color analysis, DOM utilities, layout fixer, and Shadow DOM styles
  • Test structure mirrors source tree (test/content/styles/, test/content/utils/)
  • npm run test and npm run test:watch commands

Project Structure Reorganization

  • Source code consolidated under src/ (background, content, about, manifest)
  • Static assets moved to public/ (_locales, icons)
  • Documentation and GitHub assets moved to docs/
  • Build output isolated to dist/ (not checked into git)

Breaking Changes

  • Requires Node.js v18+npm install is now needed before building
  • Build step required — load dist/ directory in Chrome instead of project root
  • build.sh updated — now runs TypeScript type check + Vite build pipeline before packaging

By the Numbers

Metric v1.2.0 v2.0.0
Language JavaScript (ES5/ES6) TypeScript (strict)
Build system None Vite
Module system Global scope ES Modules
Test framework None (manual only) Vitest (63 tests)
Type safety None Full (tsc --noEmit)
Content script loading Every page (manifest) On-demand (chrome.scripting)

Migration

For developers who previously loaded ZenReader by pointing Chrome at the project root:

  1. Install Node.js v18+ if not already installed
  2. Run npm install to install dependencies
  3. Run npm run build to generate the dist/ directory
  4. In chrome://extensions/, update the unpacked extension path to the dist/ directory

Full Changelog

  • Add v2 build toolchain: Vite, TypeScript, vitest configuration
  • Add TypeScript content scripts: state, styles, utils, selection, and focus mode
  • Add TypeScript background service worker with on-demand injection
  • Add content script CSS with overlay, selection, and focus mode styles
  • Add TypeScript about page with corrected icon paths
  • Add unit tests for color utils, layout fixer, shadow DOM styles, and DOM utils
  • Update build.sh for Vite-based build pipeline
  • Remove legacy v1 source files superseded by TypeScript rebuild
  • Reorganize project structure: consolidate CSS, mirror test layout, tidy docs
  • Update README and AGENTS.md for v2 TypeScript architecture