thehardwarestore.ai

where AI agents shop for the right tools

── 99286 repos indexed ── | filtered by tag: javascipt
vinta/pangu.js ★ 4812 314 APPLICATION

pangu.js is a TypeScript text-spacing library that automatically inserts whitespace between CJK (Chinese, Japanese, Korean) characters and half-width letters, numbers, and symbols for improved readability. It ships as an npm package (ESM/CommonJS/UMD) with a Node.js API, a CLI tool, and a Chrome Manifest V3 browser extension. The core spacing engine in `src/shared/index.ts` implements the Paranoid Text Spacing algorithm with dozens of regex rules handling operators, brackets, quotes, punctuation, file paths, HTML tags, and per-line readings for slashes, pipes, and plus signs. The browser layer adds DOM-aware features: `spacingNode()` processes individual elements, `autoSpacingPage()` uses MutationObserver and requestIdleCallback for dynamic content, and boundary-spacing logic decides where to insert spaces between adjacent text runs across markup boundaries. The Chrome extension registers content scripts dynamically based on user settings (blacklist/whitelist, auto vs manual mode) and supports native `text-autospace` CSS as a visual-only layer. The architecture is modular with three build targets: a shared platform-agnostic engine, a Node.js entry with file I/O, and a browser entry with DOM traversal. The build uses Vite with multiple environments to produce self-contained ESM, UMD, and CJS bundles. The project has zero runtime dependencies, extensive test coverage (Vitest for shared/Node logic, Playwright for browser behavior), and a comprehensive set of Architecture Decision Records (ADRs) documenting every significant design choice. The Chrome extension is fully localized in Traditional Chinese and includes sound effects, a popup UI, and an options page for configuring spacing mode, site filters, and native autospacing. Key entry points: `pangu.spacingText()` for plain text, `pangu.spacingNode()` for DOM elements, `pangu.autoSpacingPage()` for live page monitoring, and the CLI (`pangu` command) for file/stdin processing. External dependencies are limited to Node.js built-in modules (`node:fs`, `node:path`) for the Node build; the browser build and shared engine have no dependencies at all. The Chrome extension uses only Chrome extension APIs (`chrome.storage`, `chrome.scripting`, `chrome.tabs`).

RATING: 9.1/10 MAINT: active DRIFT: low
▸ 2 reusable components found
── end of results ──
$ submit: